Changeset 15b34fd


Ignore:
Timestamp:
Jan 4, 2005, 11:04:52 PM (16 years ago)
Author:
James M. Kretchmar <kretch@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
180cd15
Parents:
95474d7
Message:
Fixed some small memory leaks in logging if files unwriteable
If the variable logfilter is set it names a filter.  Any messages
  matching this filter are logged.  This is an independent
  mechanism from the other logging variables.  If you want to
  control all logging with logfilter the other variables must be
  set to their default (off) settings. [BZ 37]
Relatively substantial changes made under the hood to support
  filter logging.  Now have more consistent interfaces to
  creating messages etc.  Still needs more work though.
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r95474d7 r15b34fd  
    1111          readable.  Still prints an error either way if zephyr reports a
    1212          failure. [BZ 19]
     13        Fixed some small memory leaks in logging if files unwriteable
     14        If the variable logfilter is set it names a filter.  Any messages
     15          matching this filter are logged.  This is an independent
     16          mechanism from the other logging variables.  If you want to
     17          control all logging with logfilter the other variables must be
     18          set to their default (off) settings. [BZ 37]
     19        Relatively substantial changes made under the hood to support
     20          filter logging.  Now have more consistent interfaces to
     21          creating messages etc.  Still needs more work though.
    1322
    14232.1.10
  • filter.c

    r32eed98 r15b34fd  
    160160}
    161161
     162/* return 1 if the message matches the given filter, otherwise
     163 * return 0.
     164 */
    162165int owl_filter_message_match(owl_filter *f, owl_message *m)
    163166{
  • functions.c

    r95474d7 r15b34fd  
    164164}
    165165
    166 void owl_function_adminmsg(char *header, char *body)
    167 {
    168   owl_message *m;
    169   int followlast;
    170 
    171   followlast=owl_global_should_followlast(&g);
    172   m=owl_malloc(sizeof(owl_message));
    173   owl_message_create_admin(m, header, body);
     166
     167/* Add the given message to Owl's internal queue.  If displayoutgoing
     168 * is disabled, the message is NOT added to any internal queue, -1 is
     169 * returned and THE CALLER IS EXPECTED TO FREE THE GIVEN MESSAGE.
     170 * Otherwise 0 is returned and the caller need do nothing more
     171 */
     172int owl_function_add_message(owl_message *m)
     173{
     174  /* if displayoutgoing is disabled, nuke the message and move on */
     175  if (! owl_global_is_displayoutgoing(&g)) {
     176    return(-1);
     177  }
     178
     179  /* add it to the global list and current view */
    174180  owl_messagelist_append_element(owl_global_get_msglist(&g), m);
    175181  owl_view_consider_message(owl_global_get_current_view(&g), m);
    176182
    177   if (followlast) owl_function_lastmsg_noredisplay();
    178 
     183  /* do followlast if necessary */
     184  if (owl_global_should_followlast(&g)) owl_function_lastmsg_noredisplay();
     185
     186  /* redisplay etc. */
    179187  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    180188  if (owl_popwin_is_active(owl_global_get_popwin(&g))) {
    181189    owl_popwin_refresh(owl_global_get_popwin(&g));
    182190  }
    183  
    184191  wnoutrefresh(owl_global_get_curs_recwin(&g));
    185192  owl_global_set_needrefresh(&g);
    186 }
    187 
    188 void owl_function_make_outgoing_zephyr(char *body, char *zwriteline, char *zsig)
     193  return(0);
     194}
     195
     196/* Create an admin message, append it to the global list of messages
     197 * and redisplay if necessary.
     198 */
     199void owl_function_adminmsg(char *header, char *body)
    189200{
    190201  owl_message *m;
    191   int followlast;
     202
     203  m=owl_malloc(sizeof(owl_message));
     204  owl_message_create_admin(m, header, body);
     205 
     206  /* add it to the global list and current view */
     207  owl_messagelist_append_element(owl_global_get_msglist(&g), m);
     208  owl_view_consider_message(owl_global_get_current_view(&g), m);
     209
     210  /* do followlast if necessary */
     211  if (owl_global_should_followlast(&g)) owl_function_lastmsg_noredisplay();
     212
     213  /* redisplay etc. */
     214  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
     215  if (owl_popwin_is_active(owl_global_get_popwin(&g))) {
     216    owl_popwin_refresh(owl_global_get_popwin(&g));
     217  }
     218  wnoutrefresh(owl_global_get_curs_recwin(&g));
     219  owl_global_set_needrefresh(&g);
     220}
     221
     222/* Create an outgoing zephyr message and return a pointer to it.  Does
     223 * not put it on the global queue, use owl_function_add_message() for
     224 * that.
     225 */
     226owl_message *owl_function_make_outgoing_zephyr(char *body, char *zwriteline, char *zsig)
     227{
     228  owl_message *m;
    192229  owl_zwrite z;
    193230 
    194   followlast=owl_global_should_followlast(&g);
    195 
    196231  /* create a zwrite for the purpose of filling in other message fields */
    197232  owl_zwrite_create_from_line(&z, zwriteline);
     
    200235  m=owl_malloc(sizeof(owl_message));
    201236  owl_message_create_from_zwriteline(m, zwriteline, body, zsig);
    202 
    203   /* add it to the global list and current view */
    204   owl_messagelist_append_element(owl_global_get_msglist(&g), m);
    205   owl_view_consider_message(owl_global_get_current_view(&g), m);
    206 
    207   if (followlast) owl_function_lastmsg_noredisplay();
    208 
    209   owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    210   if (owl_popwin_is_active(owl_global_get_popwin(&g))) {
    211     owl_popwin_refresh(owl_global_get_popwin(&g));
    212   }
     237  owl_zwrite_free(&z);
     238
     239  return(m);
     240}
     241
     242/* Create an outgoing AIM message, returns a pointer to the created
     243 * message or NULL if we're not logged into AIM (and thus unable to
     244 * create the message).  Does not put it on the global queue.  Use
     245 * owl_function_add_message() for that .
     246 */
     247owl_message *owl_function_make_outgoing_aim(char *body, char *to)
     248{
     249  owl_message *m;
     250
     251  /* error if we're not logged into aim */
     252  if (!owl_global_is_aimloggedin(&g)) return(NULL);
    213253 
    214   wnoutrefresh(owl_global_get_curs_recwin(&g));
    215   owl_global_set_needrefresh(&g);
    216   owl_zwrite_free(&z);
    217 }
    218 
    219 int owl_function_make_outgoing_aim(char *body, char *to)
    220 {
    221   owl_message *m;
    222   int followlast;
    223 
    224 
    225   if (!owl_global_is_aimloggedin(&g)) {
    226     return(-1);
    227   }
    228  
    229   followlast=owl_global_should_followlast(&g);
    230 
    231   /* create the message */
    232254  m=owl_malloc(sizeof(owl_message));
    233255  owl_message_create_aim(m,
     
    237259                         OWL_MESSAGE_DIRECTION_OUT,
    238260                         0);
    239 
    240   /* add it to the global list and current view */
    241   owl_messagelist_append_element(owl_global_get_msglist(&g), m);
    242   owl_view_consider_message(owl_global_get_current_view(&g), m);
    243 
    244   if (followlast) owl_function_lastmsg_noredisplay();
    245 
    246   owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    247   if (owl_popwin_is_active(owl_global_get_popwin(&g))) {
    248     owl_popwin_refresh(owl_global_get_popwin(&g));
    249   }
    250  
    251   wnoutrefresh(owl_global_get_curs_recwin(&g));
    252   owl_global_set_needrefresh(&g);
    253   return(0);
    254 }
    255 
    256 int owl_function_make_outgoing_loopback(char *body)
     261  return(m);
     262}
     263
     264/* Create an outgoing loopback message and return a pointer to it.
     265 * Does not append it to the global queue, use
     266 * owl_function_add_message() for that.
     267 */
     268owl_message *owl_function_make_outgoing_loopback(char *body)
    257269{
    258270  owl_message *m;
    259   int followlast;
    260 
    261   followlast=owl_global_should_followlast(&g);
    262271
    263272  /* create the message */
     
    266275  owl_message_set_direction_out(m);
    267276
    268   /* add it to the global list and current view */
    269   owl_messagelist_append_element(owl_global_get_msglist(&g), m);
    270   owl_view_consider_message(owl_global_get_current_view(&g), m);
    271 
    272   if (followlast) owl_function_lastmsg_noredisplay();
    273 
    274   owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    275   if (owl_popwin_is_active(owl_global_get_popwin(&g))) {
    276     owl_popwin_refresh(owl_global_get_popwin(&g));
    277   }
    278  
    279   wnoutrefresh(owl_global_get_curs_recwin(&g));
    280   owl_global_set_needrefresh(&g);
    281   return(0);
     277  return(m);
    282278}
    283279
     
    386382{
    387383  owl_zwrite z;
    388   int i, j;
    389384  char *mymsg;
     385  owl_message *m;
    390386
    391387  /* create the zwrite and send the message */
     
    394390    owl_zwrite_set_message(&z, msg);
    395391  }
    396 
    397392  owl_zwrite_send_message(&z);
    398393  owl_function_makemsg("Waiting for ack...");
    399394
    400   mymsg=owl_zwrite_get_message(&z);
    401 
    402   /* display the message as an outgoing message in the receive window */
    403   if (owl_global_is_displayoutgoing(&g) && owl_zwrite_is_personal(&z)) {
    404     owl_function_make_outgoing_zephyr(mymsg, line, owl_zwrite_get_zsig(&z));
    405   }
    406 
    407   /* log it if we have logging turned on */
    408   if (owl_global_is_logging(&g) && owl_zwrite_is_personal(&z)) {
    409     j=owl_zwrite_get_numrecips(&z);
    410     for (i=0; i<j; i++) {
    411       owl_log_outgoing_zephyr(owl_zwrite_get_recip_n(&z, i), mymsg);
     395  /* If it's personal */
     396  if (owl_zwrite_is_personal(&z)) {
     397    /* create the outgoing message */
     398    mymsg=owl_zwrite_get_message(&z);
     399    m=owl_function_make_outgoing_zephyr(mymsg, line, owl_zwrite_get_zsig(&z));
     400
     401    /* log it */
     402    owl_log_message(m);
     403
     404    /* add it or nuke it */
     405    if (owl_global_is_displayoutgoing(&g)) {
     406      owl_function_add_message(m);
     407    } else {
     408      owl_message_free(m);
    412409    }
    413410  }
     
    423420{
    424421  owl_zwrite z;
    425   int i, j;
    426422  char *mymsg;
    427423  char *cryptmsg;
     424  owl_message *m;
    428425#ifdef OWL_ENABLE_ZCRYPT
    429426  int ret;
     
    457454  owl_function_makemsg("Waiting for ack...");
    458455
    459   /* display the message as an outgoing message in the receive window */
    460   if (owl_global_is_displayoutgoing(&g) && owl_zwrite_is_personal(&z)) {
    461     owl_function_make_outgoing_zephyr(mymsg, line, owl_zwrite_get_zsig(&z));
    462   }
    463 
    464   /* log it if we have logging turned on */
    465   if (owl_global_is_logging(&g) && owl_zwrite_is_personal(&z)) {
    466     j=owl_zwrite_get_numrecips(&z);
    467     for (i=0; i<j; i++) {
    468       owl_log_outgoing_zephyr(owl_zwrite_get_recip_n(&z, i), mymsg);
     456  /* If it's personal */
     457  if (owl_zwrite_is_personal(&z)) {
     458    /* create the outgoing message */
     459    mymsg=owl_zwrite_get_message(&z);
     460    m=owl_function_make_outgoing_zephyr(mymsg, line, owl_zwrite_get_zsig(&z));
     461   
     462    /* log it */
     463    owl_log_message(m);
     464   
     465    /* add it or nuke it */
     466    if (owl_global_is_displayoutgoing(&g)) {
     467      owl_function_add_message(m);
     468    } else {
     469      owl_message_free(m);
    469470    }
    470471  }
     
    479480  int ret;
    480481  char *msg, *format_msg;
     482  owl_message *m;
    481483
    482484  /* make a formatted copy of the message */
     
    493495  }
    494496
    495   /* display the message as an outgoing message in the receive window */
     497  /* create the outgoing message */
     498  m=owl_function_make_outgoing_aim(msg, to);
     499
     500  /* log it */
     501  owl_log_message(m);
     502
     503  /* display it or nuke it */
    496504  if (owl_global_is_displayoutgoing(&g)) {
    497     owl_function_make_outgoing_aim(msg, to);
    498   }
    499 
    500   /* log it if we have logging turned on */
    501   if (owl_global_is_logging(&g)) {
    502     owl_log_outgoing_aim(to, msg);
     505    owl_function_add_message(m);
     506  } else {
     507    owl_message_free(m);
    503508  }
    504509
     
    510515  int ret;
    511516  char *format_msg;
     517  owl_message *m;
    512518
    513519  /* make a formatted copy of the message */
     
    523529  }
    524530
    525   /* display the message as an outgoing message in the receive window */
    526   if (owl_global_is_displayoutgoing(&g)) {
    527     owl_function_make_outgoing_aim(msg, to);
    528   }
    529 
    530   /* log it if we have logging turned on */
    531   if (owl_global_is_logging(&g)) {
    532     owl_log_outgoing_aim(to, msg);
    533   }
    534 
     531  /* create the message */
     532  m=owl_function_make_outgoing_aim(msg, to);
     533  if (m) {
     534    /* log it */
     535    owl_log_message(m);
     536
     537    /* display it or nuke it */
     538    if (owl_global_is_displayoutgoing(&g)) {
     539      owl_function_add_message(m);
     540    } else {
     541      owl_message_free(m);
     542    }
     543  } else {
     544    owl_function_error("Could not create AIM message");
     545  }
    535546  owl_free(format_msg);
    536547}
     
    538549void owl_function_loopwrite()
    539550{
    540   owl_message *m;
     551  owl_message *min, *mout;
    541552
    542553  /* create a message and put it on the message queue.  This simulates
    543554   * an incoming message */
    544   m=owl_malloc(sizeof(owl_message));
    545   owl_message_create_loopback(m, owl_editwin_get_text(owl_global_get_typwin(&g)));
    546   owl_message_set_direction_in(m);
    547   owl_global_messagequeue_addmsg(&g, m);
    548 
    549   /* display the message as an outgoing message in the receive window */
     555  min=owl_malloc(sizeof(owl_message));
     556  owl_message_create_loopback(min, owl_editwin_get_text(owl_global_get_typwin(&g)));
     557  owl_message_set_direction_in(min);
     558  owl_global_messagequeue_addmsg(&g, min);
     559
     560  mout=owl_function_make_outgoing_loopback(owl_editwin_get_text(owl_global_get_typwin(&g)));
     561  owl_log_message(mout);
    550562  if (owl_global_is_displayoutgoing(&g)) {
    551     owl_function_make_outgoing_loopback(owl_editwin_get_text(owl_global_get_typwin(&g)));
     563    owl_function_add_message(mout);
     564  } else {
     565    owl_message_free(mout);
    552566  }
    553567
    554568  /* fake a makemsg */
    555569  owl_function_makemsg("loopback message sent");
    556 
    557   /* log it if we have logging turned on */
    558   if (owl_global_is_logging(&g)) {
    559     owl_log_outgoing_loopback(owl_editwin_get_text(owl_global_get_typwin(&g)));
    560   }
    561570}
    562571
  • logging.c

    rdebb15d r15b34fd  
    77static const char fileIdent[] = "$Id$";
    88
    9 void owl_log_outgoing_zephyr(char *to, char *text)
     9/* This is now the one function that should be called to log a
     10 * message.  It will do all the work necessary by calling the other
     11 * functions in this file as necessary.
     12 */
     13void owl_log_message(owl_message *m) {
     14  owl_function_debugmsg("owl_log_message: entering");
     15
     16  /* should we be logging this message? */
     17  if (!owl_log_shouldlog_message(m)) {
     18    owl_function_debugmsg("owl_log_message: not logging message");
     19    return;
     20  }
     21
     22  /* handle incmoing messages */
     23  if (owl_message_is_direction_in(m)) {
     24    owl_log_incoming(m);
     25    owl_function_debugmsg("owl_log_message: leaving");
     26    return;
     27  }
     28
     29  /* handle outgoing messages */
     30  if (owl_message_is_type_aim(m)) {
     31    owl_log_outgoing_aim(m);
     32  } else if (owl_message_is_type_zephyr(m)) {
     33    owl_log_outgoing_zephyr(m);
     34  } else if (owl_message_is_type_loopback(m)) {
     35    owl_log_outgoing_loopback(m);
     36  } else {
     37    owl_function_error("Unknown message type for logging");
     38  }
     39  owl_function_debugmsg("owl_log_message: leaving");
     40}
     41
     42/* Return 1 if we should log the given message, otherwise return 0 */
     43int owl_log_shouldlog_message(owl_message *m) {
     44  owl_filter *f;
     45
     46  /* If there's a logfilter and this message matches it, log */
     47  f=owl_global_get_filter(&g, owl_global_get_logfilter(&g));
     48  if (f && owl_filter_message_match(f, m)) return(1);
     49
     50  /* otherwise we do things based on the logging variables */
     51
     52  /* skip login/logout messages if appropriate */
     53  if (!owl_global_is_loglogins(&g) && owl_message_is_loginout(m)) return(0);
     54     
     55  /* check for nolog */
     56  if (!strcasecmp(owl_message_get_opcode(m), "nolog") || !strcasecmp(owl_message_get_instance(m), "nolog")) return(0);
     57
     58  /* check direction */
     59  if ((owl_global_get_loggingdirection(&g)==OWL_LOGGING_DIRECTION_IN) && owl_message_is_direction_out(m)) {
     60    return(0);
     61  }
     62  if ((owl_global_get_loggingdirection(&g)==OWL_LOGGING_DIRECTION_OUT) && owl_message_is_direction_in(m)) {
     63    return(0);
     64  }
     65
     66  if (owl_message_is_type_zephyr(m)) {
     67    if (owl_message_is_personal(m) && !owl_global_is_logging(&g)) return(0);
     68    if (!owl_message_is_personal(m) && !owl_global_is_classlogging(&g)) return(0);
     69  } else {
     70    if (owl_message_is_private(m) || owl_message_is_loginout(m)) {
     71      if (!owl_global_is_logging(&g)) return(0);
     72    } else {
     73      if (!owl_global_is_classlogging(&g)) return(0);
     74    }
     75  }
     76  return(1);
     77}
     78
     79void owl_log_outgoing_zephyr(owl_message *m)
    1080{
    1181  FILE *file;
    1282  char filename[MAXPATHLEN], *logpath;
    13   char *tobuff, *ptr="";
    14 
    15   if (owl_global_get_loggingdirection(&g)==OWL_LOGGING_DIRECTION_IN) return;
    16 
    17   tobuff=owl_malloc(strlen(to)+20);
    18   strcpy(tobuff, to);
    19 
    20   /* chop off a local realm */
    21   ptr=strchr(tobuff, '@');
    22   if (ptr && !strncmp(ptr+1, owl_zephyr_get_realm(), strlen(owl_zephyr_get_realm()))) {
    23     *ptr='\0';
    24   }
     83  char *to, *text;
     84
     85  /* strip local realm */
     86  to=short_zuser(owl_message_get_recipient(m));
    2587
    2688  /* expand ~ in path names */
    27   logpath = owl_text_substitute(owl_global_get_logpath(&g), "~",
    28                                 owl_global_get_homedir(&g));
    29 
    30   snprintf(filename, MAXPATHLEN, "%s/%s", logpath, tobuff);
     89  logpath=owl_text_substitute(owl_global_get_logpath(&g), "~", owl_global_get_homedir(&g));
     90
     91  text=owl_message_get_body(m);
     92
     93  snprintf(filename, MAXPATHLEN, "%s/%s", logpath, to);
    3194  file=fopen(filename, "a");
    3295  if (!file) {
    3396    owl_function_error("Unable to open file for outgoing logging");
    3497    owl_free(logpath);
    35     return;
    36   }
    37   fprintf(file, "OUTGOING (owl): %s\n%s\n", tobuff, text);
     98    owl_free(to);
     99    return;
     100  }
     101  fprintf(file, "OUTGOING (owl): %s\n%s\n", to, text);
    38102  if (text[strlen(text)-1]!='\n') {
    39103    fprintf(file, "\n");
     
    46110  if (!file) {
    47111    owl_function_error("Unable to open file for outgoing logging");
    48     return;
    49   }
    50   fprintf(file, "OUTGOING (owl): %s\n%s\n", tobuff, text);
    51   if (text[strlen(text)-1]!='\n') {
    52     fprintf(file, "\n");
    53   }
    54   fclose(file);
    55 
    56   owl_free(tobuff);
     112    owl_free(to);
     113    return;
     114  }
     115  fprintf(file, "OUTGOING (owl): %s\n%s\n", to, text);
     116  if (text[strlen(text)-1]!='\n') {
     117    fprintf(file, "\n");
     118  }
     119  fclose(file);
     120
     121  owl_free(to);
    57122}
    58123
     
    61126  FILE *file;
    62127  char filename[MAXPATHLEN], *logpath;
    63   char *tobuff, *ptr="";
    64 
    65   tobuff=owl_malloc(strlen(to)+20);
    66   strcpy(tobuff, to);
    67 
    68   /* chop off a local realm */
    69   ptr=strchr(tobuff, '@');
    70   if (ptr && !strncmp(ptr+1, owl_zephyr_get_realm(), strlen(owl_zephyr_get_realm()))) {
    71     *ptr='\0';
    72   }
     128  char *tobuff;
     129
     130  tobuff=short_zuser(to);
    73131
    74132  /* expand ~ in path names */
    75   logpath = owl_text_substitute(owl_global_get_logpath(&g), "~",
    76                                 owl_global_get_homedir(&g));
     133  logpath = owl_text_substitute(owl_global_get_logpath(&g), "~", owl_global_get_homedir(&g));
    77134
    78135  snprintf(filename, MAXPATHLEN, "%s/%s", logpath, tobuff);
     
    81138    owl_function_error("Unable to open file for outgoing logging");
    82139    owl_free(logpath);
     140    owl_free(tobuff);
    83141    return;
    84142  }
     
    94152  if (!file) {
    95153    owl_function_error("Unable to open file for outgoing logging");
     154    owl_free(tobuff);
    96155    return;
    97156  }
     
    105164}
    106165
    107 void owl_log_outgoing_aim(char *to, char *text)
     166void owl_log_outgoing_aim(owl_message *m)
    108167{
    109168  FILE *file;
    110169  char filename[MAXPATHLEN], *logpath;
    111   char *tobuff, *normalto;
    112 
    113   if (owl_global_get_loggingdirection(&g)==OWL_LOGGING_DIRECTION_IN) return;
    114 
    115   normalto=owl_aim_normalize_screenname(to);
     170  char *tobuff, *normalto, *text;
     171
     172  owl_function_debugmsg("owl_log_outgoing_aim: entering");
     173
     174  /* normalize and downcase the screenname */
     175  normalto=owl_aim_normalize_screenname(owl_message_get_recipient(m));
    116176  downstr(normalto);
    117177  tobuff=owl_sprintf("aim:%s", normalto);
     
    119179
    120180  /* expand ~ in path names */
    121   logpath = owl_text_substitute(owl_global_get_logpath(&g), "~",
    122                                 owl_global_get_homedir(&g));
    123 
     181  logpath = owl_text_substitute(owl_global_get_logpath(&g), "~", owl_global_get_homedir(&g));
     182
     183  text=owl_message_get_body(m);
     184 
    124185  snprintf(filename, MAXPATHLEN, "%s/%s", logpath, tobuff);
    125186  file=fopen(filename, "a");
     
    127188    owl_function_error("Unable to open file for outgoing logging");
    128189    owl_free(logpath);
     190    owl_free(tobuff);
    129191    return;
    130192  }
     
    140202  if (!file) {
    141203    owl_function_error("Unable to open file for outgoing logging");
     204    owl_free(tobuff);
    142205    return;
    143206  }
     
    151214}
    152215
    153 void owl_log_outgoing_loopback(char *text)
     216void owl_log_outgoing_loopback(owl_message *m)
    154217{
    155218  FILE *file;
    156219  char filename[MAXPATHLEN], *logpath;
    157   char *tobuff;
    158 
    159   if (owl_global_get_loggingdirection(&g)==OWL_LOGGING_DIRECTION_IN) return;
     220  char *tobuff, *text;
    160221
    161222  tobuff=owl_sprintf("loopback");
    162223
    163224  /* expand ~ in path names */
    164   logpath = owl_text_substitute(owl_global_get_logpath(&g), "~",
    165                                 owl_global_get_homedir(&g));
     225  logpath = owl_text_substitute(owl_global_get_logpath(&g), "~", owl_global_get_homedir(&g));
     226
     227  text=owl_message_get_body(m);
    166228
    167229  snprintf(filename, MAXPATHLEN, "%s/%s", logpath, tobuff);
     
    170232    owl_function_error("Unable to open file for outgoing logging");
    171233    owl_free(logpath);
     234    owl_free(tobuff);
    172235    return;
    173236  }
     
    183246  if (!file) {
    184247    owl_function_error("Unable to open file for outgoing logging");
     248    owl_free(tobuff);
    185249    return;
    186250  }
     
    201265  int len, ch, i, personal;
    202266
    203   if (owl_global_get_loggingdirection(&g)==OWL_LOGGING_DIRECTION_OUT) return;
    204 
    205   /* skip login/logout messages if appropriate */
    206   if (!owl_global_is_loglogins(&g) && owl_message_is_loginout(m)) return;
    207      
    208   /* check for nolog */
    209   if (!strcasecmp(owl_message_get_opcode(m), "nolog") ||
    210       !strcasecmp(owl_message_get_instance(m), "nolog")) return;
    211 
    212   /* this is kind of a mess */
     267  /* figure out if it's a "personal" message or not */
    213268  if (owl_message_is_type_zephyr(m)) {
    214269    if (owl_message_is_personal(m)) {
    215270      personal=1;
    216       if (!owl_global_is_logging(&g)) return;
    217271    } else {
    218272      personal=0;
    219       if (!owl_global_is_classlogging(&g)) return;
    220273    }
    221274  } else {
    222275    if (owl_message_is_private(m) || owl_message_is_loginout(m)) {
    223276      personal=1;
    224       if (!owl_global_is_logging(&g)) return;
    225277    } else {
    226278      personal=0;
    227       if (!owl_global_is_classlogging(&g)) return;
    228279    }
    229280  }
    230281
    231282  if (owl_message_is_type_zephyr(m)) {
    232     /* chop off a local realm for personal zephyr messages */
    233283    if (personal) {
    234284      if (owl_message_is_type_zephyr(m)) {
    235         from=frombuff=owl_strdup(owl_message_get_sender(m));
    236         ptr=strchr(frombuff, '@');
    237         if (ptr && !strncmp(ptr+1, owl_zephyr_get_realm(), strlen(owl_zephyr_get_realm()))) {
    238           *ptr='\0';
    239         }
     285        from=frombuff=short_zuser(owl_message_get_sender(m));
    240286      }
    241287    } else {
    242       /* we assume zephyr for now */
    243288      from=frombuff=owl_strdup(owl_message_get_class(m));
    244289    }
     
    276321  /* create the filename (expanding ~ in path names) */
    277322  if (personal) {
    278     logpath = owl_text_substitute(owl_global_get_logpath(&g), "~",
    279                                   owl_global_get_homedir(&g));
     323    logpath = owl_text_substitute(owl_global_get_logpath(&g), "~", owl_global_get_homedir(&g));
    280324    snprintf(filename, MAXPATHLEN, "%s/%s", logpath, from);
    281325    snprintf(allfilename, MAXPATHLEN, "%s/all", logpath);
    282326
    283327  } else {
    284     logpath = owl_text_substitute(owl_global_get_classlogpath(&g), "~",
    285                                 owl_global_get_homedir(&g));
    286 
     328    logpath = owl_text_substitute(owl_global_get_classlogpath(&g), "~", owl_global_get_homedir(&g));
    287329    snprintf(filename, MAXPATHLEN, "%s/%s", logpath, from);
    288330  }
     
    292334  if (!file) {
    293335    owl_function_error("Unable to open file for incoming logging");
     336    owl_free(frombuff);
    294337    return;
    295338  }
     
    300343    if (!allfile) {
    301344      owl_function_error("Unable to open file for incoming logging");
     345      owl_free(frombuff);
    302346      fclose(file);
    303347      return;
  • owl.c

    r95474d7 r15b34fd  
    589589
    590590      /* log the message if we need to */
    591       if (owl_global_is_logging(&g) || owl_global_is_classlogging(&g)) {
    592         owl_log_incoming(m);
    593       }
     591      owl_log_message(m);
    594592    }
    595593
  • variable.c

    r213a3eb r15b34fd  
    150150               "for AIM, zephyr, or other protocols.  If disabled Owl will not print\n"
    151151               "login or logout notifications.\n"),
     152
     153  OWLVAR_STRING( "logfilter" /* %OwlVarStub */, "",
     154                 "name of a filter controlling which messages to log",
     155
     156                 "If non empty, any messages matching the given filter will be logged.\n"
     157                 "This is a completely separate mechanisim from the other logging\n"
     158                 "variables like logging, classlogging, loglogins, loggingdirection,\n"
     159                 "etc.  If you want this variable to control all logging, make sure\n"
     160                 "all other logging variables are in their default state.\n"),
    152161
    153162  OWLVAR_BOOL( "loglogins" /* %OwlVarStub */, 0,
  • zephyr.c

    r95474d7 r15b34fd  
    518518#ifdef HAVE_LIBZEPHYR
    519519  char *tmpbuff, *myuser, *to;
     520  owl_message *mout;
    520521 
    521522  /* bail if it doesn't look like a message we should reply to.  Some
     
    554555
    555556  /* display the message as an admin message in the receive window */
    556   owl_function_make_outgoing_zephyr(owl_global_get_zaway_msg(&g), tmpbuff, "Automated reply:");
     557  mout=owl_function_make_outgoing_zephyr(owl_global_get_zaway_msg(&g), tmpbuff, "Automated reply:");
     558  owl_function_add_message(mout);
    557559  owl_free(tmpbuff);
    558560#endif
Note: See TracChangeset for help on using the changeset viewer.