Changeset 2182be3 for logging.c


Ignore:
Timestamp:
Oct 29, 2006, 7:18:30 PM (14 years ago)
Author:
Arun A. Tharuvai <aatharuv@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
cd9182d
Parents:
e7ac2b6
Message:
Logging for jabber.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • logging.c

    r3c7d086a r2182be3  
    3939  } else if (owl_message_is_type_loopback(m)) {
    4040    owl_log_outgoing_loopback(m);
    41   } else {
     41  } else if (owl_message_is_type_jabber(m)) {
     42   owl_log_outgoing_jabber(m);   
     43  }else {
    4244    owl_function_error("Unknown message type for logging");
    4345  }
     
    183185}
    184186
     187void owl_log_outgoing_jabber(owl_message *m)
     188{
     189  FILE *file;
     190  char filename[MAXPATHLEN], *logpath;
     191  char *tobuff, *normalto, *text;
     192  owl_function_debugmsg("owl_log_outgoing_jabber: entering");
     193  /* normalize and downcase the screenname */
     194  normalto = owl_message_get_recipient(m);
     195 
     196  /* downstr(normalto); */
     197  tobuff=owl_sprintf("jabber:%s", normalto);
     198  /* owl_free(normalto); */
     199
     200  /* expand ~ in path names */
     201  logpath = owl_text_substitute(owl_global_get_logpath(&g), "~", owl_global_get_homedir(&g));
     202
     203  text=owl_message_get_body(m);
     204 
     205  snprintf(filename, MAXPATHLEN, "%s/%s", logpath, tobuff);
     206  file=fopen(filename, "a");
     207  if (!file) {
     208    owl_function_error("Unable to open file for outgoing logging");
     209    owl_free(logpath);
     210    owl_free(tobuff);
     211    return;
     212  }
     213  fprintf(file, "OUTGOING (owl): %s\n%s\n", tobuff, text);
     214  if (text[strlen(text)-1]!='\n') {
     215    fprintf(file, "\n");
     216  }
     217  fclose(file);
     218
     219  snprintf(filename, MAXPATHLEN, "%s/all", logpath);
     220  owl_free(logpath);
     221  file=fopen(filename, "a");
     222  if (!file) {
     223    owl_function_error("Unable to open file for outgoing logging");
     224    owl_free(tobuff);
     225    return;
     226  }
     227  fprintf(file, "OUTGOING (owl): %s\n%s\n", tobuff, text);
     228  if (text[strlen(text)-1]!='\n') {
     229    fprintf(file, "\n");
     230  }
     231  fclose(file);
     232
     233  owl_free(tobuff);
     234}
     235
     236
    185237void owl_log_outgoing_aim(owl_message *m)
    186238{
     
    291343      personal=0;
    292344    }
     345  } else if (owl_message_is_type_jabber(m)) {
     346          /* This needs to be fixed to handle groupchat */
     347          char* msgtype = owl_message_get_attribute_value(m,"jtype");
     348          if (msgtype && !strcmp(msgtype,"groupchat")) {
     349                  personal =0;
     350          } else {
     351             personal=1;
     352          }
    293353  } else {
    294354    if (owl_message_is_private(m) || owl_message_is_loginout(m)) {
     
    298358    }
    299359  }
     360
     361 
    300362
    301363  if (owl_message_is_type_zephyr(m)) {
     
    316378  } else if (owl_message_is_type_loopback(m)) {
    317379    from=frombuff=owl_strdup("loopback");
     380  } else if (owl_message_is_type_jabber(m)) {
     381        from=frombuff=owl_sprintf("jabber:%s",owl_message_get_sender(m));
    318382  } else {
    319383    from=frombuff=owl_strdup("unknown");
Note: See TracChangeset for help on using the changeset viewer.