Changeset 5789230 for message.c


Ignore:
Timestamp:
Jun 5, 2003, 2:26:51 PM (18 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:
aac889a
Parents:
ae4cd12
Message:
'isloginout' and 'isprivate' are now message attributes
improved 'info' function lists seperate info for zephyr, aim and
   also prints all message attributes
File:
1 edited

Legend:

Unmodified
Added
Removed
  • message.c

    raa5f725 r5789230  
    7878}
    7979
     80/* We cheat and indent it for now, since we really want this for
     81 * the 'info' function.  Later there should just be a generic
     82 * function to indent fmtext.
     83 */
     84void owl_message_attributes_tofmtext(owl_message *m, owl_fmtext *fm) {
     85  int i, j;
     86  owl_pair *p;
     87  char *buff;
     88
     89  owl_fmtext_init_null(fm);
     90
     91  j=owl_list_get_size(&(m->attributes));
     92  for (i=0; i<j; i++) {
     93    p=owl_list_get_element(&(m->attributes), i);
     94    buff=owl_sprintf("  %-15.15s: %-35.35s\n", owl_pair_get_key(p), owl_pair_get_value(p));
     95    owl_fmtext_append_normal(fm, buff);
     96    owl_free(buff);
     97  }
     98}
    8099
    81100owl_fmtext *owl_message_get_fmtext(owl_message *m)
     
    197216  if (!opcode) return("");
    198217  return(opcode);
     218}
     219
     220
     221void owl_message_set_isloginout(owl_message *m)
     222{
     223  owl_message_set_attribute(m, "isloginout", "");
     224}
     225
     226int owl_message_is_loginout(owl_message *m)
     227{
     228  char *res;
     229
     230  res=owl_message_get_attribute_value(m, "isloginout");
     231  if (!res) return(0);
     232  return(1);
     233}
     234
     235void owl_message_set_isprivate(owl_message *m)
     236{
     237  owl_message_set_attribute(m, "isprivate", "");
     238}
     239
     240int owl_message_is_private(owl_message *m)
     241{
     242  char *res;
     243
     244  res=owl_message_get_attribute_value(m, "isprivate");
     245  if (!res) return(0);
     246  return(1);
    199247}
    200248
     
    255303}
    256304
    257 
    258305char *owl_message_get_text(owl_message *m)
    259306{
     
    376423}
    377424
    378 /* true if the message is only intended for one recipient (me) */
    379 int owl_message_is_to_me(owl_message *m)
    380 {
    381   if (owl_message_is_type_zephyr(m)) {
    382     if (!strcasecmp(owl_message_get_recipient(m), ZGetSender())) {
    383       return(1);
    384     } else {
    385       return(0);
    386     }
    387   } else if (owl_message_is_type_aim(m)) {
    388     /* right now we don't support chat rooms */
    389     return(1);
    390   } else if (owl_message_is_type_admin(m)) {
    391     return(1);
    392   }
    393   return(0);
    394 }
    395 
    396 
    397425int owl_message_is_from_me(owl_message *m)
    398426{
     
    418446{
    419447  if (owl_message_is_type_zephyr(m)) {
    420     if (!strcasecmp(owl_message_get_class(m), "mail") && owl_message_is_to_me(m)) {
     448    if (!strcasecmp(owl_message_get_class(m), "mail") && owl_message_is_private(m)) {
    421449      return(1);
    422450    } else {
     
    439467}
    440468
    441 int owl_message_is_login(owl_message *m)
    442 {
    443   if (owl_message_is_type_zephyr(m)) {
    444     if (!strcasecmp(owl_message_get_class(m), "login")) {
    445       return(1);
    446     } else {
    447       return(0);
    448     }
    449   } else if (owl_message_is_type_aim(m)) {
    450     /* deal with this once we can use buddy lists */
    451     return(0);
    452   }
    453        
    454   return(0);
    455 }
    456 
    457469int owl_message_is_burningears(owl_message *m)
    458470{
     
    461473
    462474  /* if the message is from us or to us, it doesn't count */
    463   if (owl_message_is_from_me(m) || owl_message_is_to_me(m)) return(0);
     475  if (owl_message_is_from_me(m) || owl_message_is_private(m)) return(0);
    464476
    465477  if (owl_message_is_type_zephyr(m)) {
     
    539551  owl_message_set_type_aim(m);
    540552  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);
    541556
    542557  indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10);
     
    593608  owl_message_set_direction_in(m);
    594609
     610  owl_message_set_isloginout(m);
     611
    595612  owl_fmtext_init_null(&(m->fmtext));
    596613  owl_fmtext_append_normal(&(m->fmtext), OWL_TABSTR);
     
    666683  } else {
    667684    owl_message_set_realm(m, ZGetRealm());
     685  }
     686
     687  /* Set the "isloginout" attribute if it's a login message */
     688  if (!strcasecmp(n->z_class, "login")) {
     689    owl_message_set_isloginout(m);
     690  }
     691
     692  /* is the "isprivate" attribute if it's a private zephyr */
     693  if (!strcasecmp(n->z_recipient, ZGetSender())) {
     694    owl_message_set_isprivate(m);
    668695  }
    669696
     
    879906  owl_fmtext_append_normal(&(m->fmtext), OWL_TABSTR);
    880907
    881   if (!strcasecmp(owl_message_get_opcode(m), "ping") && owl_message_is_to_me(m)) {
     908  if (!strcasecmp(owl_message_get_opcode(m), "ping") && owl_message_is_private(m)) {
    882909    owl_fmtext_append_bold(&(m->fmtext), "PING");
    883910    owl_fmtext_append_normal(&(m->fmtext), " from ");
Note: See TracChangeset for help on using the changeset viewer.