Changeset bd3f232 for owl.c


Ignore:
Timestamp:
Jun 10, 2003, 3:14:59 PM (21 years ago)
Author:
James M. Kretchmar <kretch@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
f14a7ee
Parents:
6e05655
Message:
Styles implemented
It's still a little buggy ... if a format_msg(); is used in perl admin
  messages (or maybe just the first admin message) are not formatted.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • owl.c

    r6bf73ce rbd3f232  
    3737  char *configfile, *tty, *perlout, **argvsave, buff[LINE], startupmsg[LINE];
    3838  owl_filter *f;
     39  owl_style *s;
    3940  time_t nexttime, now;
    4041  struct tm *today;
     
    4647  tty=NULL;
    4748  debug=0;
     49  initialsubs=1;
    4850  if (argc>0) {
    4951    argv++;
     
    128130
    129131   
    130   /* owl init */
     132  /* owl global init */
    131133  owl_global_init(&g);
    132134  if (debug) owl_global_set_debug_on(&g);
     
    145147  }
    146148
     149  /* setup the built-in styles */
     150  s=owl_malloc(sizeof(owl_style));
     151  owl_style_create_internal(s, "default", &owl_stylefunc_default);
     152  owl_global_add_style(&g, s);
     153
     154  s=owl_malloc(sizeof(owl_style));
     155  owl_style_create_internal(s, "basic", &owl_stylefunc_basic);
     156  owl_global_add_style(&g, s);
     157
    147158  /* setup the default filters */
    148159  /* the personal filter will need to change again when AIM chat's are
    149160   *  included.  Also, there should be an %aimme% */
    150   f=malloc(sizeof(owl_filter));
     161  f=owl_malloc(sizeof(owl_filter));
    151162  owl_filter_init_fromstring(f, "personal", "( type ^zephyr$ "
    152163                             "and class ^message$ and instance ^personal$ "
     
    155166  owl_list_append_element(owl_global_get_filterlist(&g), f);
    156167
    157   f=malloc(sizeof(owl_filter));
     168  f=owl_malloc(sizeof(owl_filter));
    158169  owl_filter_init_fromstring(f, "trash", "class ^mail$ or opcode ^ping$ or type ^admin$ or class ^login$");
    159170  owl_list_append_element(owl_global_get_filterlist(&g), f);
    160171
    161   f=malloc(sizeof(owl_filter));
     172  f=owl_malloc(sizeof(owl_filter));
    162173  owl_filter_init_fromstring(f, "ping", "opcode ^ping$");
    163174  owl_list_append_element(owl_global_get_filterlist(&g), f);
    164175
    165   f=malloc(sizeof(owl_filter));
     176  f=owl_malloc(sizeof(owl_filter));
    166177  owl_filter_init_fromstring(f, "auto", "opcode ^auto$");
    167178  owl_list_append_element(owl_global_get_filterlist(&g), f);
    168179
    169   f=malloc(sizeof(owl_filter));
     180  f=owl_malloc(sizeof(owl_filter));
    170181  owl_filter_init_fromstring(f, "login", "class ^login$");
    171182  owl_list_append_element(owl_global_get_filterlist(&g), f);
    172183
    173   f=malloc(sizeof(owl_filter));
     184  f=owl_malloc(sizeof(owl_filter));
    174185  owl_filter_init_fromstring(f, "reply-lockout", "class ^noc or class ^mail$");
    175186  owl_list_append_element(owl_global_get_filterlist(&g), f);
    176187
    177   f=malloc(sizeof(owl_filter));
     188  f=owl_malloc(sizeof(owl_filter));
    178189  owl_filter_init_fromstring(f, "out", "direction ^out$");
    179190  owl_list_append_element(owl_global_get_filterlist(&g), f);
    180191
    181   f=malloc(sizeof(owl_filter));
     192  f=owl_malloc(sizeof(owl_filter));
    182193  owl_filter_init_fromstring(f, "aim", "type ^aim$");
    183194  owl_list_append_element(owl_global_get_filterlist(&g), f);
    184195
    185   f=malloc(sizeof(owl_filter));
     196  f=owl_malloc(sizeof(owl_filter));
    186197  owl_filter_init_fromstring(f, "zephyr", "type ^zephyr$");
    187198  owl_list_append_element(owl_global_get_filterlist(&g), f);
    188199
    189   f=malloc(sizeof(owl_filter));
     200  f=owl_malloc(sizeof(owl_filter));
    190201  owl_filter_init_fromstring(f, "none", "false");
    191202  owl_list_append_element(owl_global_get_filterlist(&g), f);
    192203
    193   f=malloc(sizeof(owl_filter));
     204  f=owl_malloc(sizeof(owl_filter));
    194205  owl_filter_init_fromstring(f, "all", "true");
    195206  owl_list_append_element(owl_global_get_filterlist(&g), f);
     
    211222    printf("\nError parsing configfile\n");
    212223    exit(1);
     224  }
     225
     226  /* if the config defaults a formatting function, add 'perl' as a style */
     227  if (owl_global_is_config_format(&g)) {
     228    owl_function_debugmsg("Found perl formatting");
     229    s=owl_malloc(sizeof(owl_style));
     230    owl_style_create_perl(s, "perl", "owl::format_msg");
     231    owl_global_add_style(&g, s);
    213232  }
    214233
     
    228247
    229248  /* load zephyr subs */
    230   ret=owl_zephyr_loadsubs(NULL);
    231   if (ret!=-1) {
    232     owl_global_add_userclue(&g, OWL_USERCLUE_CLASSES);
    233   }
    234 
    235   /* load login subs */
    236   if (owl_global_is_loginsubs(&g)) {
    237     owl_function_loadloginsubs(NULL);
     249  if (initialsubs) {
     250    /* load normal subscriptions */
     251    ret=owl_zephyr_loadsubs(NULL);
     252    if (ret!=-1) {
     253      owl_global_add_userclue(&g, OWL_USERCLUE_CLASSES);
     254    }
     255
     256    /* load login subscriptions */
     257    if (owl_global_is_loginsubs(&g)) {
     258      owl_function_loadloginsubs(NULL);
     259    }
    238260  }
    239261
     
    241263  if (owl_global_is_startuplogin(&g)) {
    242264    owl_zephyr_zlog_in();
     265  }
     266
     267  /* set the default style, based on userclue and presence of a
     268   *  formatting function */
     269  if (owl_global_is_config_format(&g)) {
     270    owl_global_set_style(&g, "perl");
     271  } else if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES)) {
     272    owl_global_set_style(&g, "default");
     273  } else {
     274    owl_global_set_style(&g, "basic");
    243275  }
    244276
     
    275307
    276308    followlast=owl_global_should_followlast(&g);
    277 
    278309   
    279310    /* If we're logged into AIM, do AIM stuff */
     
    306337      owl_message *m;
    307338      owl_filter *f;
    308 
     339     
     340      /* grab the new message, stick it in 'm' */
    309341      if (ZPending()) {
    310342        /* grab a zephyr notice, but if we've done 20 without stopping,
     
    332364      }
    333365     
    334       /* if it's on the puntlist then, nuke it and continue */
     366      /* if this message it on the puntlist, nuke it and continue */
    335367      if (owl_global_message_is_puntable(&g, m)) {
    336368        owl_message_free(m);
     
    343375
    344376      /* let the config know the new message has been received */
    345       owl_config_getmsg(m, 0);
     377      owl_config_getmsg(m, "owl::receive_msg();");
    346378
    347379      /* add it to any necessary views; right now there's only the current view */
     
    432464    }
    433465
    434     /* Handle all keypresses.
    435      * If no key has been pressed sleep for a little bit, but
    436      * otherwise do not, this lets input be grabbed as quickly
    437      * as possbile */
     466    /* Handle all keypresses.  If no key has been pressed, sleep for a
     467     * little bit, but otherwise do not.  This lets input be grabbed
     468     * as quickly as possbile */
    438469    j=wgetch(typwin);
    439470    if (j==ERR) {
     
    471502void sig_handler(int sig) {
    472503  if (sig==SIGWINCH) {
    473     /* we can't inturrupt a malloc here, so it just sets a flag */
     504    /* we can't inturrupt a malloc here, so it just sets a flag
     505     * schedulding a resize for later
     506     */
    474507    owl_function_resize();
    475508  }
Note: See TracChangeset for help on using the changeset viewer.