Changeset d559df9


Ignore:
Timestamp:
Jun 7, 2003, 12:09:47 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:
b2b0773
Parents:
dafd919
Message:
AIM messages now go through format_msg() in .owlconf if it exists.
Additional Perl variables will need to be added so users can distinguish
  AIM login/logout messages from normal messages.
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • aim.c

    rae4cd12 rd559df9  
    12771277  nz_screenname=owl_aim_normalize_screenname(userinfo->sn);
    12781278  m=owl_malloc(sizeof(owl_message));
    1279   owl_message_create_incoming_aim(m, nz_screenname, owl_global_get_aim_screenname(&g), stripmsg);
     1279  owl_message_create_aim(m,
     1280                         nz_screenname,
     1281                         owl_global_get_aim_screenname(&g),
     1282                         stripmsg,
     1283                         OWL_MESSAGE_DIRECTION_IN,
     1284                         0);
    12801285  owl_global_messagequeue_addmsg(&g, m);
    12811286  owl_free(stripmsg);
  • buddylist.c

    r38cf544c rd559df9  
    2828
    2929    m=owl_malloc(sizeof(owl_message));
    30     owl_message_create_aim_login(m, 0, screenname);
     30    owl_message_create_aim(m,
     31                           screenname,
     32                           owl_global_get_aim_screenname(&g),
     33                           "",
     34                           OWL_MESSAGE_DIRECTION_IN,
     35                           1);
    3136    owl_global_messagequeue_addmsg(&g, m);
    3237  }
     
    5661  if (found) {
    5762    m=owl_malloc(sizeof(owl_message));
    58     owl_message_create_aim_login(m, 1, screenname);
     63    owl_message_create_aim(m,
     64                           screenname,
     65                           owl_global_get_aim_screenname(&g),
     66                           "",
     67                           OWL_MESSAGE_DIRECTION_IN,
     68                           -1);
     69
    5970    owl_global_messagequeue_addmsg(&g, m);
    6071  }
  • fmtext.c

    r5789230 rd559df9  
    457457}
    458458
    459 
     459 
     460/* the first column is column 0 */
     461/* the message is expected to end in a new line for now */
    460462void owl_fmtext_truncate_cols(owl_fmtext *in, int acol, int bcol, owl_fmtext *out)
    461463{
    462464  char *ptr1, *ptr2, *last;
    463465  int len, offset;
    464  
    465   /* the first column is column 0 */
    466 
    467   /* the message is expected to end in a new line for now */
    468466
    469467  last=in->textbuff+in->textlen-1;
     
    485483    len=bcol-acol;
    486484    if (len > (ptr2-(ptr1+acol))) {
     485      /* the whole line fits with room to spare, don't take a full 'len' */
    487486      len=ptr2-(ptr1+acol);
    488487    }
    489488    if (len>last-ptr1) {
     489      /* the whole rest of the text fits with room to spare, adjust for it */
    490490      len-=(last-ptr1);
    491491    }
    492492    if (len<=0) {
     493      /* saftey check */
    493494      owl_fmtext_append_normal(out, "\n");
    494495      ptr1=ptr2+1;
  • functions.c

    r378fa14 rd559df9  
    139139  /* create the message */
    140140  m=owl_malloc(sizeof(owl_message));
    141   owl_message_create_outgoing_aim(m, owl_global_get_aim_screenname(&g), to, body);
     141  owl_message_create_aim(m,
     142                         owl_global_get_aim_screenname(&g),
     143                         to,
     144                         body,
     145                         OWL_MESSAGE_DIRECTION_OUT,
     146                         0);
    142147
    143148  /* add it to the global list and current view */
  • logging.c

    raac889a rd559df9  
    5757  FILE *file;
    5858  char filename[MAXPATHLEN], *logpath;
    59   char *tobuff, *ptr;
     59  char *tobuff;
    6060
    6161  tobuff=owl_sprintf("aim:%s", to);
  • message.c

    r5789230 rd559df9  
    219219
    220220
    221 void owl_message_set_isloginout(owl_message *m)
    222 {
    223   owl_message_set_attribute(m, "isloginout", "");
     221void owl_message_set_islogin(owl_message *m)
     222{
     223  owl_message_set_attribute(m, "loginout", "login");
     224}
     225
     226
     227void owl_message_set_islogout(owl_message *m)
     228{
     229  owl_message_set_attribute(m, "loginout", "logout");
    224230}
    225231
     
    228234  char *res;
    229235
    230   res=owl_message_get_attribute_value(m, "isloginout");
     236  res=owl_message_get_attribute_value(m, "loginout");
    231237  if (!res) return(0);
    232238  return(1);
     239}
     240
     241int owl_message_is_login(owl_message *m)
     242{
     243  char *res;
     244
     245  res=owl_message_get_attribute_value(m, "loginout");
     246  if (!res) return(0);
     247  if (!strcmp(res, "login")) return(1);
     248  return(0);
     249}
     250
     251
     252int owl_message_is_logout(owl_message *m)
     253{
     254  char *res;
     255
     256  res=owl_message_get_attribute_value(m, "loginout");
     257  if (!res) return(0);
     258  if (!strcmp(res, "logout")) return(1);
     259  return(0);
    233260}
    234261
     
    541568}
    542569
    543 void owl_message_create_incoming_aim(owl_message *m, char *sender, char *recipient, char *text)
    544 {
    545   char *indent;
    546 
     570/* if loginout == -1 it's a logout message
     571 *                 0 it's not a login/logout message
     572 *                 1 it's a login message
     573 */
     574void owl_message_create_aim(owl_message *m, char *sender, char *recipient, char *text, int direction, int loginout)
     575{
    547576  owl_message_init(m);
    548577  owl_message_set_body(m, text);
     
    550579  owl_message_set_recipient(m, recipient);
    551580  owl_message_set_type_aim(m);
    552   owl_message_set_direction_in(m);
    553 
    554   /* for now, all AIM messages are private messages since we don't do chat rooms */
    555   owl_message_set_isprivate(m);
    556 
    557   indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10);
    558   owl_text_indent(indent, text, OWL_MSGTAB);
    559   owl_fmtext_init_null(&(m->fmtext));
    560   owl_fmtext_append_bold(&(m->fmtext), OWL_TABSTR);
    561   owl_fmtext_append_bold(&(m->fmtext), "AIM from ");
    562   owl_fmtext_append_bold(&(m->fmtext), sender);
    563   owl_fmtext_append_bold(&(m->fmtext), "\n");
    564   owl_fmtext_append_bold(&(m->fmtext), indent);
    565   if (text[strlen(text)-1]!='\n') {
     581
     582  if (direction==OWL_MESSAGE_DIRECTION_IN) {
     583    owl_message_set_direction_in(m);
     584  } else if (direction==OWL_MESSAGE_DIRECTION_OUT) {
     585    owl_message_set_direction_out(m);
     586  }
     587
     588  /* for now all messages that aren't loginout are private */
     589  if (!loginout) {
     590    owl_message_set_isprivate(m);
     591  }
     592
     593  if (loginout==-1) {
     594    owl_message_set_islogout(m);
     595  } else if (loginout==1) {
     596    owl_message_set_islogin(m);
     597  }
     598
     599  /* create the formatted message */
     600  if (owl_global_is_config_format(&g)) {
     601    _owl_message_make_text_from_config(m);
     602  } else {
     603    _owl_message_make_text_from_aim(m);
     604  }
     605}
     606
     607void _owl_message_make_text_from_aim(owl_message *m)
     608{
     609  char *indent;
     610
     611  if (owl_message_is_loginout(m)) {
     612    owl_fmtext_init_null(&(m->fmtext));
     613    owl_fmtext_append_normal(&(m->fmtext), OWL_TABSTR);
     614    if (owl_message_is_login(m)) {
     615      owl_fmtext_append_bold(&(m->fmtext), "AIM LOGIN");
     616    } else {
     617      owl_fmtext_append_bold(&(m->fmtext), "AIM LOGOUT");
     618    }
     619    owl_fmtext_append_normal(&(m->fmtext), " for ");
     620    owl_fmtext_append_normal(&(m->fmtext), owl_message_get_sender(m));
     621    owl_fmtext_append_normal(&(m->fmtext), "\n");
     622  } else if (owl_message_is_direction_in(m)) {
     623    indent=owl_malloc(strlen(owl_message_get_body(m))+owl_text_num_lines(owl_message_get_body(m))*OWL_MSGTAB+10);
     624    owl_text_indent(indent, owl_message_get_body(m), OWL_MSGTAB);
     625    owl_fmtext_init_null(&(m->fmtext));
     626    owl_fmtext_append_bold(&(m->fmtext), OWL_TABSTR);
     627    owl_fmtext_append_bold(&(m->fmtext), "AIM from ");
     628    owl_fmtext_append_bold(&(m->fmtext), owl_message_get_sender(m));
    566629    owl_fmtext_append_bold(&(m->fmtext), "\n");
    567   }
    568  
    569   owl_free(indent);
    570 }
    571 
    572 void owl_message_create_outgoing_aim(owl_message *m, char *sender, char *recipient, char *text)
    573 {
    574   char *indent;
    575 
    576   owl_message_init(m);
    577   owl_message_set_body(m, text);
    578   owl_message_set_sender(m, sender);
    579   owl_message_set_recipient(m, recipient);
    580   owl_message_set_type_aim(m);
    581   owl_message_set_direction_out(m);
    582 
    583   indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10);
    584   owl_text_indent(indent, text, OWL_MSGTAB);
    585   owl_fmtext_init_null(&(m->fmtext));
    586   owl_fmtext_append_normal(&(m->fmtext), OWL_TABSTR);
    587   owl_fmtext_append_normal(&(m->fmtext), "AIM sent to ");
    588   owl_fmtext_append_normal(&(m->fmtext), recipient);
    589   owl_fmtext_append_normal(&(m->fmtext), "\n");
    590   owl_fmtext_append_ztext(&(m->fmtext), indent);
    591   if (text[strlen(text)-1]!='\n') {
     630    owl_fmtext_append_bold(&(m->fmtext), indent);
     631    if (indent[strlen(indent)-1]!='\n') {
     632      owl_fmtext_append_normal(&(m->fmtext), "\n");
     633    }
     634    owl_free(indent);
     635  } else if (owl_message_is_direction_out(m)) {
     636    indent=owl_malloc(strlen(owl_message_get_body(m))+owl_text_num_lines(owl_message_get_body(m))*OWL_MSGTAB+10);
     637    owl_text_indent(indent, owl_message_get_body(m), OWL_MSGTAB);
     638    owl_fmtext_init_null(&(m->fmtext));
     639    owl_fmtext_append_normal(&(m->fmtext), OWL_TABSTR);
     640    owl_fmtext_append_normal(&(m->fmtext), "AIM sent to ");
     641    owl_fmtext_append_normal(&(m->fmtext), owl_message_get_recipient(m));
    592642    owl_fmtext_append_normal(&(m->fmtext), "\n");
    593   }
    594  
    595   owl_free(indent);
    596 }
    597 
    598 /* For login direction == 0
    599  * For logout direction == 1
    600  */
    601 void owl_message_create_aim_login(owl_message *m, int direction, char *screenname)
    602 {
    603   owl_message_init(m);
    604   owl_message_set_body(m, "");
    605   owl_message_set_sender(m, screenname);
    606   owl_message_set_recipient(m, owl_global_get_aim_screenname(&g));
    607   owl_message_set_type_aim(m);
    608   owl_message_set_direction_in(m);
    609 
    610   owl_message_set_isloginout(m);
    611 
    612   owl_fmtext_init_null(&(m->fmtext));
    613   owl_fmtext_append_normal(&(m->fmtext), OWL_TABSTR);
    614   if (direction==0) {
    615     owl_fmtext_append_bold(&(m->fmtext), "AIM LOGIN");
    616   } else if (direction==1) {
    617     owl_fmtext_append_bold(&(m->fmtext), "AIM LOGOUT");
    618   }
    619   owl_fmtext_append_normal(&(m->fmtext), " for ");
    620   owl_fmtext_append_normal(&(m->fmtext), screenname);
    621   owl_fmtext_append_normal(&(m->fmtext), "\n");
     643    owl_fmtext_append_ztext(&(m->fmtext), indent);
     644    if (indent[strlen(indent)-1]!='\n') {
     645      owl_fmtext_append_normal(&(m->fmtext), "\n");
     646    }
     647    owl_free(indent);
     648  }
    622649}
    623650
     
    687714  /* Set the "isloginout" attribute if it's a login message */
    688715  if (!strcasecmp(n->z_class, "login")) {
    689     owl_message_set_isloginout(m);
     716    if (!strcasecmp(n->z_opcode, "user_login")) {
     717      owl_message_set_islogin(m);
     718    } else if (!strcasecmp(n->z_opcode, "user_logout")) {
     719      owl_message_set_islogout(m);
     720    }
    690721  }
    691722
  • readconfig.c

    rac70242 rd559df9  
    173173
    174174  /* set owl::type */
    175   if (owl_message_is_type_zephyr(m)) {
    176     sv_setpv(perl_get_sv("owl::type", TRUE), "zephyr");
    177   } else if (owl_message_is_type_admin(m)) {
    178     sv_setpv(perl_get_sv("owl::type", TRUE), "admin");
    179   } else {
    180     sv_setpv(perl_get_sv("owl::type", TRUE), "unknown");
    181   }
     175  sv_setpv(perl_get_sv("owl::type", TRUE), owl_message_type_to_string(m));
    182176
    183177  /* set owl::direction */
Note: See TracChangeset for help on using the changeset viewer.