Changeset 7967433
- Timestamp:
- Sep 13, 2009, 8:05:38 PM (15 years ago)
- Branches:
- master, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 799f36c
- Parents:
- 5118b32
- git-author:
- Nelson Elhage <nelhage@mit.edu> (09/12/09 22:02:50)
- git-committer:
- Nelson Elhage <nelhage@mit.edu> (09/13/09 20:05:38)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
owl.c
r4542047 r7967433 36 36 owl_global g; 37 37 38 void owl_register_signal_handlers(void) /* noproto */ { 39 struct sigaction sigact; 40 41 /* signal handler */ 42 /*sigact.sa_handler=sig_handler;*/ 43 sigact.sa_sigaction=sig_handler; 44 sigemptyset(&sigact.sa_mask); 45 sigact.sa_flags=SA_SIGINFO; 46 sigaction(SIGWINCH, &sigact, NULL); 47 sigaction(SIGALRM, &sigact, NULL); 48 sigaction(SIGPIPE, &sigact, NULL); 49 sigaction(SIGTERM, &sigact, NULL); 50 sigaction(SIGHUP, &sigact, NULL); 51 52 sigact.sa_sigaction=sigint_handler; 53 sigaction(SIGINT, &sigact, NULL); 54 55 } 56 57 void owl_start_color(void) /* noproto */ { 58 start_color(); 59 #ifdef HAVE_USE_DEFAULT_COLORS 60 use_default_colors(); 61 #endif 62 63 /* define simple color pairs */ 64 if (has_colors() && COLOR_PAIRS>=8) { 65 int bg = COLOR_BLACK; 66 #ifdef HAVE_USE_DEFAULT_COLORS 67 bg = -1; 68 #endif 69 init_pair(OWL_COLOR_BLACK, COLOR_BLACK, bg); 70 init_pair(OWL_COLOR_RED, COLOR_RED, bg); 71 init_pair(OWL_COLOR_GREEN, COLOR_GREEN, bg); 72 init_pair(OWL_COLOR_YELLOW, COLOR_YELLOW, bg); 73 init_pair(OWL_COLOR_BLUE, COLOR_BLUE, bg); 74 init_pair(OWL_COLOR_MAGENTA, COLOR_MAGENTA, bg); 75 init_pair(OWL_COLOR_CYAN, COLOR_CYAN, bg); 76 init_pair(OWL_COLOR_WHITE, COLOR_WHITE, bg); 77 } 78 } 79 80 void owl_start_curses(void) /* noproto */ { 81 struct termios tio; 82 /* save initial terminal settings */ 83 tcgetattr(0, owl_global_get_startup_tio(&g)); 84 85 /* turn ISTRIP off */ 86 tcgetattr(0, &tio); 87 tio.c_iflag &= ~(ISTRIP|IEXTEN); 88 tio.c_cc[VQUIT] = 0; 89 tcsetattr(0, TCSAFLUSH, &tio); 90 91 /* screen init */ 92 initscr(); 93 cbreak(); 94 noecho(); 95 96 owl_start_color(); 97 } 98 99 void owl_setup_default_filters(void) /* noproto */ { 100 owl_filter *f; 101 102 owl_function_debugmsg("startup: creating default filters"); 103 f=owl_malloc(sizeof(owl_filter)); 104 owl_filter_init_fromstring(f, "personal", "isprivate ^true$ and ( not type ^zephyr$" 105 " or ( class ^message ) )"); 106 owl_list_append_element(owl_global_get_filterlist(&g), f); 107 108 f=owl_malloc(sizeof(owl_filter)); 109 owl_filter_init_fromstring(f, "wordwrap", "not ( type ^admin$ or type ^zephyr$ ) "); 110 owl_list_append_element(owl_global_get_filterlist(&g), f); 111 112 f=owl_malloc(sizeof(owl_filter)); 113 owl_filter_init_fromstring(f, "trash", "class ^mail$ or opcode ^ping$ or type ^admin$ or ( not login ^none$ )"); 114 owl_list_append_element(owl_global_get_filterlist(&g), f); 115 116 f=owl_malloc(sizeof(owl_filter)); 117 owl_filter_init_fromstring(f, "ping", "opcode ^ping$"); 118 owl_list_append_element(owl_global_get_filterlist(&g), f); 119 120 f=owl_malloc(sizeof(owl_filter)); 121 owl_filter_init_fromstring(f, "auto", "opcode ^auto$"); 122 owl_list_append_element(owl_global_get_filterlist(&g), f); 123 124 f=owl_malloc(sizeof(owl_filter)); 125 owl_filter_init_fromstring(f, "login", "not login ^none$"); 126 owl_list_append_element(owl_global_get_filterlist(&g), f); 127 128 f=owl_malloc(sizeof(owl_filter)); 129 owl_filter_init_fromstring(f, "reply-lockout", "class ^noc or class ^mail$"); 130 owl_list_append_element(owl_global_get_filterlist(&g), f); 131 132 f=owl_malloc(sizeof(owl_filter)); 133 owl_filter_init_fromstring(f, "out", "direction ^out$"); 134 owl_list_append_element(owl_global_get_filterlist(&g), f); 135 136 f=owl_malloc(sizeof(owl_filter)); 137 owl_filter_init_fromstring(f, "aim", "type ^aim$"); 138 owl_list_append_element(owl_global_get_filterlist(&g), f); 139 140 f=owl_malloc(sizeof(owl_filter)); 141 owl_filter_init_fromstring(f, "zephyr", "type ^zephyr$"); 142 owl_list_append_element(owl_global_get_filterlist(&g), f); 143 144 f=owl_malloc(sizeof(owl_filter)); 145 owl_filter_init_fromstring(f, "none", "false"); 146 owl_list_append_element(owl_global_get_filterlist(&g), f); 147 148 f=owl_malloc(sizeof(owl_filter)); 149 owl_filter_init_fromstring(f, "all", "true"); 150 owl_list_append_element(owl_global_get_filterlist(&g), f); 151 } 152 38 153 int main(int argc, char **argv, char **env) 39 154 { … … 43 158 int debug, argcsave, followlast; 44 159 int newmsgs, nexttimediff; 45 struct sigaction sigact;46 160 const char *configfile, *tty, *const *argvsave; 47 161 char *perlout, *perlerr; 48 162 const char *confdir; 49 owl_filter *f;50 163 const owl_style *s; 51 164 time_t nexttime, now; 52 165 struct tm *today; 53 166 const char *dir; 54 struct termios tio;55 167 owl_message *m; 56 168 … … 125 237 owl_function_debugmsg("startup: Finished parsing arguments"); 126 238 127 /* signal handler */ 128 /*sigact.sa_handler=sig_handler;*/ 129 sigact.sa_sigaction=sig_handler; 130 sigemptyset(&sigact.sa_mask); 131 sigact.sa_flags=SA_SIGINFO; 132 sigaction(SIGWINCH, &sigact, NULL); 133 sigaction(SIGALRM, &sigact, NULL); 134 sigaction(SIGPIPE, &sigact, NULL); 135 sigaction(SIGTERM, &sigact, NULL); 136 sigaction(SIGHUP, &sigact, NULL); 137 138 sigact.sa_sigaction=sigint_handler; 139 sigaction(SIGINT, &sigact, NULL); 140 141 /* save initial terminal settings */ 142 tcgetattr(0, owl_global_get_startup_tio(&g)); 143 144 /* turn ISTRIP off */ 145 tcgetattr(0, &tio); 146 tio.c_iflag &= ~(ISTRIP|IEXTEN); 147 tio.c_cc[VQUIT] = 0; 148 tcsetattr(0, TCSAFLUSH, &tio); 149 150 /* screen init */ 151 if (!getenv("TERMINFO")) { 152 owl_function_debugmsg("startup: Not setting TERMINFO"); 153 } else { 154 owl_function_debugmsg("startup: leaving TERMINFO as %s from envrionment", getenv("TERMINFO")); 155 } 156 initscr(); 157 start_color(); 158 #ifdef HAVE_USE_DEFAULT_COLORS 159 use_default_colors(); 160 #endif 161 cbreak(); 162 noecho(); 163 164 /* define simple color pairs */ 165 if (has_colors() && COLOR_PAIRS>=8) { 166 int bg = COLOR_BLACK; 167 #ifdef HAVE_USE_DEFAULT_COLORS 168 bg = -1; 169 #endif 170 init_pair(OWL_COLOR_BLACK, COLOR_BLACK, bg); 171 init_pair(OWL_COLOR_RED, COLOR_RED, bg); 172 init_pair(OWL_COLOR_GREEN, COLOR_GREEN, bg); 173 init_pair(OWL_COLOR_YELLOW, COLOR_YELLOW, bg); 174 init_pair(OWL_COLOR_BLUE, COLOR_BLUE, bg); 175 init_pair(OWL_COLOR_MAGENTA, COLOR_MAGENTA, bg); 176 init_pair(OWL_COLOR_CYAN, COLOR_CYAN, bg); 177 init_pair(OWL_COLOR_WHITE, COLOR_WHITE, bg); 178 } 239 owl_register_signal_handlers(); 240 owl_start_curses(); 179 241 180 242 /* owl global init */ … … 237 299 owl_global_complete_setup(&g); 238 300 239 /* setup the default filters */ 240 /* the personal filter will need to change again when AIM chat's are 241 * included. Also, there should be an %aimme% */ 242 owl_function_debugmsg("startup: creating default filters"); 243 f=owl_malloc(sizeof(owl_filter)); 244 owl_filter_init_fromstring(f, "personal", "isprivate ^true$ and ( not type ^zephyr$" 245 " or ( class ^message ) )"); 246 owl_list_append_element(owl_global_get_filterlist(&g), f); 247 248 f=owl_malloc(sizeof(owl_filter)); 249 owl_filter_init_fromstring(f, "wordwrap", "not ( type ^admin$ or type ^zephyr$ ) "); 250 owl_list_append_element(owl_global_get_filterlist(&g), f); 251 252 f=owl_malloc(sizeof(owl_filter)); 253 owl_filter_init_fromstring(f, "trash", "class ^mail$ or opcode ^ping$ or type ^admin$ or ( not login ^none$ )"); 254 owl_list_append_element(owl_global_get_filterlist(&g), f); 255 256 f=owl_malloc(sizeof(owl_filter)); 257 owl_filter_init_fromstring(f, "ping", "opcode ^ping$"); 258 owl_list_append_element(owl_global_get_filterlist(&g), f); 259 260 f=owl_malloc(sizeof(owl_filter)); 261 owl_filter_init_fromstring(f, "auto", "opcode ^auto$"); 262 owl_list_append_element(owl_global_get_filterlist(&g), f); 263 264 f=owl_malloc(sizeof(owl_filter)); 265 owl_filter_init_fromstring(f, "login", "not login ^none$"); 266 owl_list_append_element(owl_global_get_filterlist(&g), f); 267 268 f=owl_malloc(sizeof(owl_filter)); 269 owl_filter_init_fromstring(f, "reply-lockout", "class ^noc or class ^mail$"); 270 owl_list_append_element(owl_global_get_filterlist(&g), f); 271 272 f=owl_malloc(sizeof(owl_filter)); 273 owl_filter_init_fromstring(f, "out", "direction ^out$"); 274 owl_list_append_element(owl_global_get_filterlist(&g), f); 275 276 f=owl_malloc(sizeof(owl_filter)); 277 owl_filter_init_fromstring(f, "aim", "type ^aim$"); 278 owl_list_append_element(owl_global_get_filterlist(&g), f); 279 280 f=owl_malloc(sizeof(owl_filter)); 281 owl_filter_init_fromstring(f, "zephyr", "type ^zephyr$"); 282 owl_list_append_element(owl_global_get_filterlist(&g), f); 283 284 f=owl_malloc(sizeof(owl_filter)); 285 owl_filter_init_fromstring(f, "none", "false"); 286 owl_list_append_element(owl_global_get_filterlist(&g), f); 287 288 f=owl_malloc(sizeof(owl_filter)); 289 owl_filter_init_fromstring(f, "all", "true"); 290 owl_list_append_element(owl_global_get_filterlist(&g), f); 301 owl_setup_default_filters(); 291 302 292 303 /* set the current view */ 293 304 owl_function_debugmsg("startup: setting the current view"); 294 owl_view_create(owl_global_get_current_view(&g), "main", f, owl_global_get_style_by_name(&g, "default")); 305 owl_view_create(owl_global_get_current_view(&g), "main", 306 owl_global_get_filter(&g, "all"), 307 owl_global_get_style_by_name(&g, "default")); 295 308 296 309 /* AIM init */ … … 331 344 wrefresh(sepwin); 332 345 333 /* First buddy check to sync the list without notifications */ 334 owl_function_debugmsg("startup: doing initial zephyr buddy check"); 335 /* owl_function_zephyr_buddy_check(0); */ 336 337 /* set the startup and default style, based on userclue and presence of a 338 * formatting function */ 346 /* Set the default style */ 339 347 owl_function_debugmsg("startup: setting startup and default style"); 340 348 if (0 != strcmp(owl_global_get_default_style(&g), "__unspecified__")) { … … 356 364 nexttimediff=10; 357 365 nexttime=time(NULL); 358 359 366 360 367 owl_select_add_timer(180, 180, owl_zephyr_buddycheck_timer, NULL, NULL);
Note: See TracChangeset
for help on using the changeset viewer.