Changeset 4b464a4


Ignore:
Timestamp:
Aug 25, 2002, 11:35:03 AM (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:
56330ff
Parents:
7131cf2
Message:
Messages now have a direciton (in, out or none).  Filters can
     this direction
Outbound messages are no longer type 'admin' but are of the
     appropriate message type (i.e. 'zephyr') and are direction
     'out'.
Smartnarrow now works on outgoing messages
'info' updated to show more information for admin and outgoing
     messages
Renamed pretty_sender to short_zuser and renamed long_sender to
     long_zuser
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r7131cf2 r4b464a4  
    11$Id$
    22
    3 1.2.4-pre
    4         Temporary fix to bug where C-SPACE would cause
    5              the key handler to lock up.
    6        
    731.2.3
    84        Added filters "ping", "auto" and "login" by default.
    95        Added "body" as a valid field to match on in a filter.
     6        Temporary fix to bug where C-SPACE would cause the key handler to
     7             lock up.
     8        Messages now have a direciton (in, out or none).  Filters can
     9             this direction
     10        Outbound messages are no longer type 'admin' but are of the
     11             appropriate message type (i.e. 'zephyr') and are direction
     12             'out'.
     13        Smartnarrow now works on outgoing messages
     14        'info' updated to show more information for admin and outgoing
     15             messages
     16        Renamed pretty_sender to short_zuser and renamed long_sender to
     17             long_zuser
    1018       
    11191.2.2
  • filter.c

    r75be7c0 r4b464a4  
    5959          !strcasecmp(argv[i], "opcode") ||
    6060          !strcasecmp(argv[i], "realm") ||
    61           !strcasecmp(argv[i], "type")) {
     61          !strcasecmp(argv[i], "type") ||
     62          !strcasecmp(argv[i], "direction")) {
    6263        owl_filterelement_create_re(fe, argv[i], argv[i+1]);
    6364        i++;
     
    142143      match=owl_message_get_realm(m);
    143144    } else if (!strcasecmp(field, "type")) {
    144       if (owl_message_is_zephyr(m)) {
     145      if (owl_message_is_type_zephyr(m)) {
    145146        match="zephyr";
    146       } else if (owl_message_is_admin(m)) {
     147      } else if (owl_message_is_type_admin(m)) {
    147148        match="admin";
     149      } else {
     150        match="";
     151      }
     152    } else if (!strcasecmp(field, "direction")) {
     153      if (owl_message_is_direction_out(m)) {
     154        match="out";
     155      } else if (owl_message_is_direction_in(m)) {
     156        match="in";
     157      } else if (owl_message_is_direction_none(m)) {
     158        match="none";
    148159      } else {
    149160        match="";
  • fmtext.c

    r1fd0b25 r4b464a4  
    494494}
    495495
     496void owl_fmtext_set_char(owl_fmtext *f, int index, int ch) {
     497  /* set the charater at 'index' to be 'char'.  If index is out of
     498   * bounds don't do anything */
     499  if ((index < 0) || (index > f->textlen-1)) return;
     500  f->textbuff[index]=ch;
     501}
     502
    496503void owl_fmtext_free(owl_fmtext *f) {
    497504  if (f->textbuff) owl_free(f->textbuff);
  • functions.c

    r1354456 r4b464a4  
    2222void owl_function_command_norv(char *cmdbuff) {
    2323  char *rv;
    24   rv = owl_function_command(cmdbuff);
     24  rv=owl_function_command(cmdbuff);
    2525  if (rv) owl_free(rv);
    2626}
     
    8080}
    8181
    82 void owl_function_adminmsg_outgoing(char *header, char *body, char *zwriteline) {
     82void owl_function_make_outgoing_zephyr(char *header, char *body, char *zwriteline) {
    8383  owl_message *m;
    8484  int followlast;
     85  owl_zwrite z;
     86  char *tobuff, *recip;
    8587 
    8688  followlast=owl_global_should_followlast(&g);
     89
     90  /* create a zwrite for the purpose of filling in other message fields */
     91  owl_zwrite_create_from_line(&z, zwriteline);
     92
     93  /* in 'tobuff' place the "Message sent to foo" string.
     94   * Right now this only works for one recipient */
     95  tobuff=owl_malloc(strlen(owl_zwrite_get_recip_n(&z, 0))+100);
     96  sprintf(tobuff, "Zephyr sent to %s", owl_zwrite_get_recip_n(&z, 0));
     97
     98  /* create the message */
    8799  m=owl_malloc(sizeof(owl_message));
    88   owl_message_create_admin(m, header, body);
    89   owl_message_set_admin_outgoing(m, zwriteline);
     100  owl_message_create(m,  tobuff, body);
     101  owl_message_set_direction_out(m);
     102  owl_message_set_type_zephyr(m);
     103
     104  /* set zwriteline */
     105  owl_message_set_zwriteline(m, zwriteline);
     106
     107  owl_message_set_class(m, owl_zwrite_get_class(&z));
     108  owl_message_set_instance(m, owl_zwrite_get_instance(&z));
     109  owl_message_set_opcode(m, owl_zwrite_get_opcode(&z));
     110  owl_message_set_realm(m, owl_zwrite_get_realm(&z));
     111  owl_message_set_sender(m, ZGetSender());
     112  /* this only gets the first recipient for now, must fix */
     113  recip=long_zuser(owl_zwrite_get_recip_n(&z, 0));
     114  owl_message_set_recipient(m, recip);
     115  owl_free(recip);
     116
     117  /* add it to the global list */
    90118  owl_messagelist_append_element(owl_global_get_msglist(&g), m);
    91119  owl_view_consider_message(owl_global_get_current_view(&g), m);
     
    100128  wnoutrefresh(owl_global_get_curs_recwin(&g));
    101129  owl_global_set_needrefresh(&g);
     130  owl_free(tobuff);
    102131}
    103132
     
    158187    owl_zwrite_get_recipstr(&z, buff);
    159188    tmpbuff = owl_sprintf("Message sent to %s", buff);
    160     owl_function_adminmsg_outgoing(tmpbuff, owl_editwin_get_text(owl_global_get_typwin(&g)), line);
     189    owl_function_make_outgoing_zephyr(tmpbuff, owl_editwin_get_text(owl_global_get_typwin(&g)), line);
    161190    owl_free(tmpbuff);
    162191  }
     
    289318  owl_function_nextmsg_full(NULL, 1, 1);
    290319}
    291 
    292320
    293321void owl_function_prevmsg_notdeleted() {
     
    10591087  owl_message *m;
    10601088  ZNotice_t *n;
    1061   char buff[2048], tmpbuff[1024];
     1089  char buff[5000], tmpbuff[1024];
    10621090  char *ptr;
    10631091  int i, j, fields, len;
     
    10651093
    10661094  v=owl_global_get_current_view(&g);
    1067  
    10681095  m=owl_view_get_element(v, owl_global_get_curmsg(&g));
    1069 
    10701096  if (!m || owl_view_get_size(v)==0) {
    10711097    owl_function_makemsg("No message selected\n");
     
    10731099  }
    10741100
    1075   if (!owl_message_is_zephyr(m)) {
    1076     sprintf(buff,   "Owl Message Id: %i\n", owl_message_get_id(m));
    1077     sprintf(buff, "%sTime          : %s\n", buff, owl_message_get_timestr(m));
     1101  sprintf(buff,     "Msg Id    : %i\n", owl_message_get_id(m));
     1102  if (owl_message_is_type_zephyr(m)) {
     1103    sprintf(buff, "%sType      : zephyr\n", buff);
     1104  } else if (owl_message_is_type_admin(m)) {
     1105    sprintf(buff, "%sType      : admin\n", buff);
     1106  } else if (owl_message_is_type_generic(m)) {
     1107    sprintf(buff, "%sType      : generic\n", buff);
     1108  } else {
     1109    sprintf(buff, "%sType      : unknown\n", buff);
     1110  }
     1111  if (owl_message_is_direction_in(m)) {
     1112    sprintf(buff, "%sDirection : in\n", buff);
     1113  } else if (owl_message_is_direction_out(m)) {
     1114    sprintf(buff, "%sDirection : out\n", buff);
     1115  } else if (owl_message_is_direction_none(m)) {
     1116    sprintf(buff, "%sDirection : none\n", buff);
     1117  } else {
     1118    sprintf(buff, "%sDirection : unknown\n", buff);
     1119  }
     1120  sprintf(buff, "%sTime      : %s\n", buff, owl_message_get_timestr(m));
     1121
     1122  if (!owl_message_is_type_zephyr(m)) {
    10781123    owl_function_popless_text(buff);
    10791124    return;
    10801125  }
    10811126
     1127
     1128  if (owl_message_is_direction_out(m)) {
     1129    sprintf(buff, "%sClass     : %s\n", buff, owl_message_get_class(m));
     1130    sprintf(buff, "%sInstance  : %s\n", buff, owl_message_get_instance(m));
     1131    sprintf(buff, "%sSender    : %s\n", buff, owl_message_get_sender(m));
     1132    sprintf(buff, "%sRecip     : %s\n", buff, owl_message_get_recipient(m));
     1133    sprintf(buff, "%sOpcode    : %s\n", buff, owl_message_get_opcode(m));
     1134   
     1135    owl_function_popless_text(buff);
     1136    return;
     1137  }
     1138
    10821139  n=owl_message_get_notice(m);
    10831140
    1084   sprintf(buff,   "Owl Msg ID: %i\n", owl_message_get_id(m));
    1085   sprintf(buff, "%sClass     : %s\n", buff, n->z_class);
    1086   sprintf(buff, "%sInstance  : %s\n", buff, n->z_class_inst);
    1087   sprintf(buff, "%sSender    : %s\n", buff, n->z_sender);
    1088   sprintf(buff, "%sRecip     : %s\n", buff, n->z_recipient);
    1089   sprintf(buff, "%sOpcode    : %s\n", buff, n->z_opcode);
     1141  sprintf(buff, "%sClass     : %s\n", buff, owl_message_get_class(m));
     1142  sprintf(buff, "%sInstance  : %s\n", buff, owl_message_get_instance(m));
     1143  sprintf(buff, "%sSender    : %s\n", buff, owl_message_get_sender(m));
     1144  sprintf(buff, "%sRecip     : %s\n", buff, owl_message_get_recipient(m));
     1145  sprintf(buff, "%sOpcode    : %s\n", buff, owl_message_get_opcode(m));
    10901146  strcat(buff,    "Kind      : ");
    10911147  if (n->z_kind==UNSAFE) {
     
    15051561      }
    15061562    }
    1507    
    1508     if (owl_message_is_admin(m)) {
    1509       if (owl_message_get_admintype(m)==OWL_MESSAGE_ADMINTYPE_OUTGOING) {
    1510         owl_function_zwrite_setup(owl_message_get_zwriteline(m));
    1511         owl_global_set_buffercommand(&g, owl_message_get_zwriteline(m));
    1512       } else {
    1513         owl_function_makemsg("You cannot reply to this admin message");
    1514       }
     1563
     1564    if (owl_message_is_direction_out(m)) {
     1565      owl_function_zwrite_setup(owl_message_get_zwriteline(m));
     1566      owl_global_set_buffercommand(&g, owl_message_get_zwriteline(m));
     1567    } else if (owl_message_is_type_admin(m)) {
     1568      owl_function_makemsg("You cannot reply to this admin message");
    15151569    } else {
    15161570      if (owl_message_is_login(m)) {
     
    15481602      if (*to != '\0') {
    15491603        char *tmp, *oldtmp;
    1550         tmp=pretty_sender(to);
     1604        tmp=short_zuser(to);
    15511605        if (cc) {
    15521606          tmp = owl_util_uniq(oldtmp=tmp, cc, "-");
     
    15551609          owl_free(oldbuff);
    15561610        } else {
    1557           tmp=pretty_sender(to);
     1611          tmp=short_zuser(to);
    15581612          buff = owl_sprintf("%s %s", oldbuff=buff, tmp);
    15591613          owl_free(oldbuff);
     
    19021956
    19031957  /* stick the local realm on if it's not there */
    1904   longuser=long_sender(user);
    1905   shortuser=pretty_sender(user);
     1958  longuser=long_zuser(user);
     1959  shortuser=short_zuser(user);
    19061960
    19071961  /* name for the filter */
     
    19171971  f=owl_malloc(sizeof(owl_filter));
    19181972
    1919   argbuff=owl_malloc(strlen(longuser)+200);
    1920   sprintf(argbuff, "( ( class ^message$ ) and ( instance ^personal$ ) and ( sender ^%s$ ) )", longuser);
    1921   sprintf(argbuff, "%s or ( ( type ^admin$ ) and ( recipient %s ) )", argbuff, shortuser);
    1922   sprintf(argbuff, "%s or ( ( class ^login$ ) and ( sender ^%s$ ) )", argbuff, longuser);
     1973  argbuff=owl_malloc(strlen(longuser)+1000);
     1974  sprintf(argbuff, "( type ^zephyr$ and ( class ^message$ and instance ^personal$ and ");
     1975  sprintf(argbuff, "%s ( ( direction ^in$ and sender ^%s$ ) or ( direction ^out$ and recipient ^%s$ ) ) )", argbuff, longuser, longuser);
     1976  sprintf(argbuff, "%s or ( ( class ^login$ ) and ( sender ^%s$ ) ) )", argbuff, longuser);
    19231977
    19241978  owl_filter_init_fromstring(f, filtname, argbuff);
     
    19982052  owl_view *v;
    19992053  owl_message *m;
    2000   char *sender, *filtname=NULL;
     2054  char *zperson, *filtname=NULL;
    20012055 
    20022056  v=owl_global_get_current_view(&g);
     
    20052059  if (!m || owl_view_get_size(v)==0) {
    20062060    owl_function_makemsg("No message selected\n");
    2007     return NULL;
     2061    return(NULL);
    20082062  }
    20092063
    20102064  /* very simple handling of admin messages for now */
    2011   if (owl_message_is_admin(m)) {
    2012     return owl_function_fasttypefilt("admin");
    2013   }
    2014 
    2015   /* narrow personal and login messages to the sender */
     2065  if (owl_message_is_type_admin(m)) {
     2066    return(owl_function_fasttypefilt("admin"));
     2067  }
     2068
     2069  /* narrow personal and login messages to the sender or recip as appropriate */
    20162070  if (owl_message_is_personal(m) || owl_message_is_login(m)) {
    2017     if (owl_message_is_zephyr(m)) {
    2018       sender=pretty_sender(owl_message_get_sender(m));
    2019       filtname = owl_function_fastuserfilt(sender);
    2020       owl_free(sender);
    2021       return filtname;
    2022     }
    2023     return NULL;
     2071    if (owl_message_is_type_zephyr(m)) {
     2072      if (owl_message_is_direction_in(m)) {
     2073        zperson=short_zuser(owl_message_get_sender(m));
     2074      } else {
     2075        zperson=short_zuser(owl_message_get_recipient(m));
     2076      }
     2077      filtname=owl_function_fastuserfilt(zperson);
     2078      owl_free(zperson);
     2079      return(filtname);
     2080    }
     2081    return(NULL);
    20242082  }
    20252083
     
    20272085  if (!strcasecmp(owl_message_get_class(m), "message") &&
    20282086      !owl_message_is_personal(m)) {
    2029     filtname = owl_function_fastclassinstfilt(owl_message_get_class(m), owl_message_get_instance(m));
    2030     return filtname;
     2087    filtname=owl_function_fastclassinstfilt(owl_message_get_class(m), owl_message_get_instance(m));
     2088    return(filtname);
    20312089  }
    20322090
    20332091  /* otherwise narrow to the class */
    20342092  if (type==0) {
    2035     filtname = owl_function_fastclassinstfilt(owl_message_get_class(m), NULL);
     2093    filtname=owl_function_fastclassinstfilt(owl_message_get_class(m), NULL);
    20362094  } else if (type==1) {
    2037     filtname = owl_function_fastclassinstfilt(owl_message_get_class(m), owl_message_get_instance(m));
    2038   }
    2039   return filtname;
     2095    filtname=owl_function_fastclassinstfilt(owl_message_get_class(m), owl_message_get_instance(m));
     2096  }
     2097  return(filtname);
    20402098}
    20412099
     
    20562114
    20572115  /* for now we skip admin messages. */
    2058   if (owl_message_is_admin(m)
     2116  if (owl_message_is_type_admin(m)
    20592117      || owl_message_is_login(m)
    2060       || !owl_message_is_zephyr(m)) {
     2118      || !owl_message_is_type_zephyr(m)) {
    20612119    owl_function_makemsg("smartzpunt doesn't support this message type.");
    20622120    return;
     
    22412299}
    22422300
    2243 
    22442301void owl_function_help_for_command(char *cmdname) {
    22452302  owl_fmtext fm;
  • logging.c

    re1c4636 r4b464a4  
    131131  }
    132132
    133   tmp=pretty_sender(owl_message_get_sender(m));
     133  tmp=short_zuser(owl_message_get_sender(m));
    134134 
    135135  fprintf(file, "Class: %s Instance: %s", owl_message_get_class(m), owl_message_get_instance(m));
  • message.c

    r1fd0b25 r4b464a4  
    1313static const char fileIdent[] = "$Id$";
    1414
    15 void owl_message_create_admin(owl_message *m, char *header, char *text) {
    16   char *indent;
     15void owl_message_init_raw(owl_message *m) {
    1716  time_t t;
    1817
    1918  m->id=owl_global_get_nextmsgid(&g);
    20   m->type=OWL_MESSAGE_TYPE_ADMIN;
    21   m->admintype=OWL_MESSAGE_ADMINTYPE_GENERIC;
     19  m->type=OWL_MESSAGE_TYPE_GENERIC;
     20  owl_message_set_direction_none(m);
    2221  m->delete=0;
    23   m->sender=owl_strdup("-owl");
     22  m->sender=owl_strdup("");
    2423  m->class=owl_strdup("");
    2524  m->inst=owl_strdup("");
     
    3433  m->time=owl_strdup(ctime(&t));
    3534  m->time[strlen(m->time)-1]='\0';
     35}
     36
     37
     38owl_fmtext *owl_message_get_fmtext(owl_message *m) {
     39  return(&(m->fmtext));
     40}
     41
     42void owl_message_set_class(owl_message *m, char *class) {
     43  if (m->class) owl_free(m->class);
     44  m->class=owl_strdup(class);
     45}
     46
     47char *owl_message_get_class(owl_message *m) {
     48  return(m->class);
     49}
     50
     51void owl_message_set_instance(owl_message *m, char *inst) {
     52  if (m->inst) owl_free(m->inst);
     53  m->inst=owl_strdup(inst);
     54}
     55
     56char *owl_message_get_instance(owl_message *m) {
     57  return(m->inst);
     58}
     59
     60void owl_message_set_sender(owl_message *m, char *sender) {
     61  if (m->sender) owl_free(m->sender);
     62  m->sender=owl_strdup(sender);
     63}
     64
     65char *owl_message_get_sender(owl_message *m) {
     66  return(m->sender);
     67}
     68
     69void owl_message_set_recipient(owl_message *m, char *recip) {
     70  if (m->recip) owl_free(m->recip);
     71  m->recip=owl_strdup(recip);
     72}
     73
     74char *owl_message_get_recipient(owl_message *m) {
     75  /* this is stupid for outgoing messages, we need to fix it. */
     76     
     77  if (m->type==OWL_MESSAGE_TYPE_ZEPHYR) {
     78    return(m->recip);
     79  } else if (owl_message_is_direction_out(m)) {
     80    return(m->zwriteline);
     81  } else {
     82    return(m->recip);
     83  }
     84}
     85
     86void owl_message_set_realm(owl_message *m, char *realm) {
     87  if (m->realm) owl_free(m->realm);
     88  m->realm=owl_strdup(realm);
     89}
     90
     91char *owl_message_get_realm(owl_message *m) {
     92  return(m->realm);
     93}
     94
     95void owl_message_set_opcode(owl_message *m, char *opcode) {
     96  if (m->opcode) free(m->opcode);
     97  m->opcode=owl_strdup(opcode);
     98}
     99
     100char *owl_message_get_opcode(owl_message *m) {
     101  return(m->opcode);
     102}
     103
     104char *owl_message_get_timestr(owl_message *m) {
     105  return(m->time);
     106}
     107
     108void owl_message_set_type_admin(owl_message *m) {
     109  m->type=OWL_MESSAGE_TYPE_ADMIN;
     110}
     111
     112void owl_message_set_type_zephyr(owl_message *m) {
     113  m->type=OWL_MESSAGE_TYPE_ZEPHYR;
     114}
     115                                               
     116int owl_message_is_type_admin(owl_message *m) {
     117  if (m->type==OWL_MESSAGE_TYPE_ADMIN) return(1);
     118  return(0);
     119}
     120
     121int owl_message_is_type_zephyr(owl_message *m) {
     122  if (m->type==OWL_MESSAGE_TYPE_ZEPHYR) return(1);
     123  return(0);
     124}
     125
     126int owl_message_is_type_generic(owl_message *m) {
     127  if (m->type==OWL_MESSAGE_TYPE_GENERIC) return(1);
     128  return(0);
     129}
     130
     131char *owl_message_get_text(owl_message *m) {
     132  return(owl_fmtext_get_text(&(m->fmtext)));
     133}
     134
     135char *owl_message_get_body(owl_message *m) {
     136  return(m->body);
     137}
     138
     139void owl_message_set_direction_in(owl_message *m) {
     140  m->direction=OWL_MESSAGE_DIRECTION_IN;
     141}
     142
     143void owl_message_set_direction_out(owl_message *m) {
     144  m->direction=OWL_MESSAGE_DIRECTION_OUT;
     145}
     146
     147void owl_message_set_direction_none(owl_message *m) {
     148  m->direction=OWL_MESSAGE_DIRECTION_NONE;
     149}
     150
     151int owl_message_is_direction_in(owl_message *m) {
     152  if (m->direction==OWL_MESSAGE_DIRECTION_IN) return(1);
     153  return(0);
     154}
     155
     156int owl_message_is_direction_out(owl_message *m) {
     157  if (m->direction==OWL_MESSAGE_DIRECTION_OUT) return(1);
     158  return(0);
     159}
     160
     161int owl_message_is_direction_none(owl_message *m) {
     162  if (m->direction==OWL_MESSAGE_DIRECTION_NONE) return(1);
     163  return(0);
     164}
     165
     166int owl_message_get_numlines(owl_message *m) {
     167  if (m == NULL) return(0);
     168  return(owl_fmtext_num_lines(&(m->fmtext)));
     169}
     170
     171void owl_message_mark_delete(owl_message *m) {
     172  if (m == NULL) return;
     173  m->delete=1;
     174}
     175
     176void owl_message_unmark_delete(owl_message *m) {
     177  if (m == NULL) return;
     178  m->delete=0;
     179}
     180
     181char *owl_message_get_zwriteline(owl_message *m) {
     182  return(m->zwriteline);
     183}
     184
     185void owl_message_set_zwriteline(owl_message *m, char *line) {
     186  m->zwriteline=strdup(line);
     187}
     188
     189int owl_message_is_delete(owl_message *m) {
     190  if (m == NULL) return(0);
     191  if (m->delete==1) return(1);
     192  return(0);
     193}
     194
     195ZNotice_t *owl_message_get_notice(owl_message *m) {
     196  return(&(m->notice));
     197}
     198
     199char *owl_message_get_hostname(owl_message *m) {
     200  return(m->hostname);
     201}
     202
     203
     204void owl_message_curs_waddstr(owl_message *m, WINDOW *win, int aline, int bline, int acol, int bcol, int color) {
     205  owl_fmtext a, b;
     206
     207  owl_fmtext_truncate_lines(&(m->fmtext), aline, bline-aline+1, &a);
     208  owl_fmtext_truncate_cols(&a, acol, bcol, &b);
     209  if (color!=OWL_COLOR_DEFAULT) {
     210    owl_fmtext_colorize(&b, color);
     211  }
     212
     213  if (owl_global_is_search_active(&g)) {
     214    owl_fmtext_search_and_highlight(&b, owl_global_get_search_string(&g));
     215  }
     216     
     217  owl_fmtext_curs_waddstr(&b, win);
     218
     219  owl_fmtext_free(&a);
     220  owl_fmtext_free(&b);
     221}
     222
     223int owl_message_is_personal(owl_message *m) {
     224  if (strcasecmp(owl_message_get_class(m), "message")) return(0);
     225  if (strcasecmp(owl_message_get_instance(m), "personal")) return(0);
     226  if (!strcmp(owl_message_get_recipient(m), ZGetSender()) ||
     227      !strcmp(owl_message_get_sender(m), ZGetSender())) {
     228    return(1);
     229  }
     230  return(0);
     231}
     232
     233int owl_message_is_private(owl_message *m) {
     234  if (!strcmp(owl_message_get_recipient(m), ZGetSender())) return(1);
     235  return(0);
     236}
     237
     238int owl_message_is_mail(owl_message *m) {
     239  if (!strcasecmp(owl_message_get_class(m), "mail") && owl_message_is_private(m)) {
     240    return(1);
     241  }
     242  return(0);
     243}
     244
     245int owl_message_is_ping(owl_message *m) {
     246  if (!strcasecmp(owl_message_get_opcode(m), "ping")) return(1);
     247  return(0);
     248}
     249
     250int owl_message_is_login(owl_message *m) {
     251  if (!strcasecmp(owl_message_get_class(m), "login")) return(1);
     252  return(0);
     253  /* is this good enough? */
     254}
     255
     256int owl_message_is_burningears(owl_message *m) {
     257  /* we should add a global to cache the short zsender */
     258  char sender[LINE], *ptr;
     259
     260  /* if the message is from us or to us, it doesn't count */
     261  if (!strcasecmp(ZGetSender(), owl_message_get_sender(m))) return(0);
     262  if (!strcasecmp(ZGetSender(), owl_message_get_recipient(m))) return(0);
     263
     264  strcpy(sender, ZGetSender());
     265  ptr=strchr(sender, '@');
     266  if (ptr) *ptr='\0';
     267
     268  if (stristr(owl_message_get_body(m), sender)) {
     269    return(1);
     270  }
     271  return(0);
     272}
     273
     274/* caller must free return value. */
     275char *owl_message_get_cc(owl_message *m) {
     276  char *cur, *out, *end;
     277
     278  cur = owl_message_get_body(m);
     279  while (*cur && *cur==' ') cur++;
     280  if (strncasecmp(cur, "cc:", 2)) return(NULL);
     281  cur+=3;
     282  while (*cur && *cur==' ') cur++;
     283  out = owl_strdup(cur);
     284  end = strchr(out, '\n');
     285  if (end) end[0] = '\0';
     286  return(out);
     287}
     288
     289int owl_message_get_id(owl_message *m) {
     290  return(m->id);
     291}
     292                                       
     293int owl_message_search(owl_message *m, char *string) {
     294  /* return 1 if the message contains "string", 0 otherwise.  This is
     295   * case insensitive because the functions it uses are */
     296
     297  return (owl_fmtext_search(&(m->fmtext), string));
     298}
     299
     300void owl_message_create(owl_message *m, char *header, char *text) {
     301  char *indent;
     302
     303  owl_message_init_raw(m);
     304
     305  m->body=owl_strdup(text);
     306
     307  indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10);
     308  owl_text_indent(indent, text, OWL_MSGTAB);
     309  owl_fmtext_init_null(&(m->fmtext));
     310  owl_fmtext_append_normal(&(m->fmtext), OWL_TABSTR);
     311  owl_fmtext_append_ztext(&(m->fmtext), header);
     312  owl_fmtext_append_normal(&(m->fmtext), "\n");
     313  owl_fmtext_append_ztext(&(m->fmtext), indent);
     314  if (text[strlen(text)-1]!='\n') {
     315    owl_fmtext_append_normal(&(m->fmtext), "\n");
     316  }
     317
     318  owl_free(indent);
     319}
     320
     321void owl_message_create_admin(owl_message *m, char *header, char *text) {
     322  char *indent;
     323
     324  owl_message_init_raw(m);
     325  owl_message_set_type_admin(m);
    36326
    37327  m->body=owl_strdup(text);
     
    60350
    61351  m->id=owl_global_get_nextmsgid(&g);
    62   m->type=OWL_MESSAGE_TYPE_ZEPHYR;
     352  owl_message_set_type_zephyr(m);
     353  owl_message_set_direction_in(m);
    63354 
    64355  /* first save the full notice */
     
    194485    }
    195486    owl_fmtext_append_normal(&(m->fmtext), " for ");
    196     ptr=pretty_sender(n->z_class_inst);
     487    ptr=short_zuser(n->z_class_inst);
    197488    owl_fmtext_append_bold(&(m->fmtext), ptr);
    198489    owl_free(ptr);
     
    297588    }
    298589    owl_fmtext_append_normal(&(m->fmtext), " for ");
    299     ptr=pretty_sender(n->z_class_inst);
     590    ptr=short_zuser(n->z_class_inst);
    300591    owl_fmtext_append_bold(&(m->fmtext), ptr);
    301592    owl_free(ptr);
     
    376667
    377668
    378 int owl_message_get_numlines(owl_message *m) {
    379   if (m == NULL) return(0);
    380   return(owl_fmtext_num_lines(&(m->fmtext)));
    381 }
    382 
    383 
    384 void owl_message_mark_delete(owl_message *m) {
    385   if (m == NULL) return;
    386   m->delete=1;
    387   /* _owl_message_make_text_from_notice(m); */
    388 }
    389 
    390 
    391 void owl_message_unmark_delete(owl_message *m) {
    392   if (m == NULL) return;
    393   m->delete=0;
    394 }
    395 
    396 
    397 int owl_message_set_admintype(owl_message *m, int admintype) {
    398   if (m->type != OWL_MESSAGE_TYPE_ADMIN) return(-1);
    399   m->admintype=admintype;
    400   return(0);
    401 }
    402 
    403 
    404 int owl_message_get_admintype(owl_message *m) {
    405   return(m->admintype);
    406 }
    407 
    408 void owl_message_set_admin_outgoing(owl_message *m, char *zwriteline) {
    409   owl_message_set_admintype(m, OWL_MESSAGE_ADMINTYPE_OUTGOING);
    410   if (m->zwriteline) {
    411     owl_free(m->zwriteline);
    412     m->zwriteline=owl_strdup(zwriteline);
    413   }
    414 }
    415 
    416 char *owl_message_get_zwriteline(owl_message *m) {
    417   return(m->zwriteline);
    418 }
    419 
    420 int owl_message_is_delete(owl_message *m) {
    421   if (m == NULL) return(0);
    422   if (m->delete==1) return(1);
    423   return(0);
    424 }
    425 
    426 ZNotice_t *owl_message_get_notice(owl_message *m) {
    427   return(&(m->notice));
    428 }
    429 
    430 
    431669void owl_message_free(owl_message *m) {
    432   if (owl_message_is_zephyr(m)) {
     670  if (owl_message_is_type_zephyr(m) && owl_message_is_direction_in(m)) {
    433671    ZFreeNotice(&(m->notice));
    434672  }
     
    446684}
    447685
    448 
    449 char *owl_message_get_hostname(owl_message *m) {
    450   return(m->hostname);
    451 }
    452 
    453 
    454 void owl_message_curs_waddstr(owl_message *m, WINDOW *win, int aline, int bline, int acol, int bcol, int color) {
    455   owl_fmtext a, b;
    456 
    457   owl_fmtext_truncate_lines(&(m->fmtext), aline, bline-aline+1, &a);
    458   owl_fmtext_truncate_cols(&a, acol, bcol, &b);
    459   if (color!=OWL_COLOR_DEFAULT) {
    460     owl_fmtext_colorize(&b, color);
    461   }
    462 
    463   if (owl_global_is_search_active(&g)) {
    464     owl_fmtext_search_and_highlight(&b, owl_global_get_search_string(&g));
    465   }
    466      
    467   owl_fmtext_curs_waddstr(&b, win);
    468 
    469   owl_fmtext_free(&a);
    470   owl_fmtext_free(&b);
    471 }
    472 
    473 owl_fmtext *owl_message_get_fmtext(owl_message *m) {
    474   return(&(m->fmtext));
    475 }
    476 
    477 void owl_message_set_class(owl_message *m, char *class) {
    478   if (m->class) owl_free(m->class);
    479   m->class=owl_strdup(class);
    480 }
    481 
    482 
    483 char *owl_message_get_class(owl_message *m) {
    484   return(m->class);
    485 }
    486 
    487 void owl_message_set_instance(owl_message *m, char *inst) {
    488   if (m->inst) owl_free(m->inst);
    489   m->inst=owl_strdup(inst);
    490 }
    491 
    492 char *owl_message_get_instance(owl_message *m) {
    493   return(m->inst);
    494 }
    495 
    496 void owl_message_set_sender(owl_message *m, char *sender) {
    497   if (m->sender) owl_free(m->sender);
    498   m->sender=owl_strdup(sender);
    499 }
    500 
    501 char *owl_message_get_sender(owl_message *m) {
    502   return(m->sender);
    503 }
    504 
    505 void owl_message_set_recipient(owl_message *m, char *recip) {
    506   if (m->recip) owl_free(m->recip);
    507   m->recip=owl_strdup(recip);
    508 }
    509 
    510 char *owl_message_get_recipient(owl_message *m) {
    511   /* this is very, very stupid for outgoing messages, we need to
    512      fix that. */
    513      
    514   if (m->type==OWL_MESSAGE_TYPE_ZEPHYR) {
    515     return(m->recip);
    516   } else if (m->type==OWL_MESSAGE_TYPE_ADMIN &&
    517              m->admintype==OWL_MESSAGE_ADMINTYPE_OUTGOING) {
    518     return(m->zwriteline);
    519   } else {
    520     return(m->recip);
    521   }
    522 }
    523 
    524 void owl_message_set_realm(owl_message *m, char *realm) {
    525   if (m->realm) owl_free(m->realm);
    526   m->realm=owl_strdup(realm);
    527 }
    528 
    529 char *owl_message_get_realm(owl_message *m) {
    530   return(m->realm);
    531 }
    532 
    533 void owl_message_set_opcode(owl_message *m, char *opcode) {
    534   if (m->opcode) free(m->opcode);
    535   m->opcode=owl_strdup(opcode);
    536 }
    537 
    538 char *owl_message_get_opcode(owl_message *m) {
    539   return(m->opcode);
    540 }
    541 
    542 char *owl_message_get_timestr(owl_message *m) {
    543   return(m->time);
    544 }
    545 
    546 int owl_message_is_admin(owl_message *m) {
    547   if (m->type==OWL_MESSAGE_TYPE_ADMIN) return(1);
    548   return(0);
    549 }
    550 
    551 int owl_message_is_zephyr(owl_message *m) {
    552   if (m->type==OWL_MESSAGE_TYPE_ZEPHYR) return(1);
    553   return(0);
    554 }
    555 
    556 char *owl_message_get_text(owl_message *m) {
    557   return(owl_fmtext_get_text(&(m->fmtext)));
    558 }
    559 
    560 char *owl_message_get_body(owl_message *m) {
    561   return(m->body);
    562 }
    563 
    564 int owl_message_is_personal(owl_message *m) {
    565   if (!strcasecmp(owl_message_get_class(m), "message") &&
    566       !strcasecmp(owl_message_get_instance(m), "personal") &&
    567       !strcmp(owl_message_get_recipient(m), ZGetSender())) {
    568     return(1);
    569   }
    570   return(0);
    571 }
    572 
    573 int owl_message_is_private(owl_message *m) {
    574   if (!strcmp(owl_message_get_recipient(m), ZGetSender())) return(1);
    575   return(0);
    576 }
    577 
    578 int owl_message_is_mail(owl_message *m) {
    579   if (!strcasecmp(owl_message_get_class(m), "mail") && owl_message_is_private(m)) {
    580     return(1);
    581   }
    582   return(0);
    583 }
    584 
    585 int owl_message_is_ping(owl_message *m) {
    586   if (!strcasecmp(owl_message_get_opcode(m), "ping")) return(1);
    587   return(0);
    588 }
    589 
    590 int owl_message_is_login(owl_message *m) {
    591   if (!strcasecmp(owl_message_get_class(m), "login")) return(1);
    592   return(0);
    593   /* is this good enough? */
    594 }
    595 
    596 int owl_message_is_burningears(owl_message *m) {
    597   /* we should add a global to cache the short zsender */
    598   char sender[LINE], *ptr;
    599 
    600   /* if the message is from us or to us, it doesn't count */
    601   if (!strcasecmp(ZGetSender(), owl_message_get_sender(m))) return(0);
    602   if (!strcasecmp(ZGetSender(), owl_message_get_recipient(m))) return(0);
    603 
    604   strcpy(sender, ZGetSender());
    605   ptr=strchr(sender, '@');
    606   if (ptr) *ptr='\0';
    607 
    608   if (stristr(owl_message_get_body(m), sender)) {
    609     return(1);
    610   }
    611   return(0);
    612 }
    613 
    614 /* caller must free return value. */
    615 char *owl_message_get_cc(owl_message *m) {
    616   char *cur, *out, *end;
    617 
    618   cur = owl_message_get_body(m);
    619   while (*cur && *cur==' ') cur++;
    620   if (strncasecmp(cur, "cc:", 2)) return(NULL);
    621   cur+=3;
    622   while (*cur && *cur==' ') cur++;
    623   out = owl_strdup(cur);
    624   end = strchr(out, '\n');
    625   if (end) end[0] = '\0';
    626   return(out);
    627 }
    628 
    629 int owl_message_get_id(owl_message *m) {
    630   return(m->id);
    631 }
    632                                        
    633 int owl_message_search(owl_message *m, char *string) {
    634   /* return 1 if the message contains "string", 0 otherwise.  This is
    635    * case insensitive because the functions it uses are */
    636 
    637   return (owl_fmtext_search(&(m->fmtext), string));
    638 }
  • owl.c

    r0236842 r4b464a4  
    3434  char **argvsave;
    3535  owl_filter *f;
     36  time_t nexttime;
     37  int nexttimediff;
    3638
    3739  argcsave=argc;
     
    217219  owl_context_set_interactive(owl_global_get_context(&g));
    218220
     221  nexttimediff=20;
     222  nexttime=time(NULL);
     223
    219224  /* main loop */
    220225  while (1) {
     
    230235
    231236    followlast=owl_global_should_followlast(&g);
     237
     238    /* little hack */
     239    if (0 && owl_global_get_runtime(&g)<300) {
     240      if (time(NULL)>nexttime) {
     241        if (nexttimediff==1) {
     242          nexttimediff=20;
     243        } else {
     244          nexttimediff=1;
     245        }
     246        nexttime+=nexttimediff;
     247        owl_hack_animate();
     248      }
     249    }
    232250
    233251    /* grab incoming zephyrs */
  • owl.h

    r60ffe04 r4b464a4  
    3636#define OWL_EDITWIN_STYLE_ONELINE   1
    3737
    38 #define OWL_MESSAGE_TYPE_ADMIN  0
    39 #define OWL_MESSAGE_TYPE_ZEPHYR 1
    40 
    41 #define OWL_MESSAGE_ADMINTYPE_GENERIC  0
    42 #define OWL_MESSAGE_ADMINTYPE_OUTGOING 1
    43 #define OWL_MESSAGE_ADMINTYPE_NOTADMIN 2
     38#define OWL_MESSAGE_TYPE_ADMIN      0
     39#define OWL_MESSAGE_TYPE_GENERIC    1
     40#define OWL_MESSAGE_TYPE_ZEPHYR     2
     41
     42#define OWL_MESSAGE_DIRECTION_NONE  0
     43#define OWL_MESSAGE_DIRECTION_IN    1
     44#define OWL_MESSAGE_DIRECTION_OUT   2
    4445
    4546#define OWL_DIRECTION_NONE      0
     
    5354#define OWL_SCROLLMODE_PAGED    4
    5455#define OWL_SCROLLMODE_PAGEDCENTER 5
    55 
    5656
    5757#define OWL_TAB               3  /* This *HAS* to be the size of TABSTR below */
     
    9696#define OWL_FILTER_MAX_DEPTH    300
    9797
    98 #define OWL_KEYMAP_MAXSTACK 20
    99 
    100 #define OWL_KEYBINDING_COMMAND   1 /* command string */
    101 #define OWL_KEYBINDING_FUNCTION  2 /* function taking no args */
    102 
    103 #define OWL_DEFAULT_ZAWAYMSG "I'm sorry, but I am currently away from the terminal and am\nnot able to receive your message.\n"
    104 
    105 #define OWL_INCLUDE_REG_TESTS  1  /* whether to build in regression tests */
     98#define OWL_KEYMAP_MAXSTACK     20
     99
     100#define OWL_KEYBINDING_COMMAND  /* command string */
     101#define OWL_KEYBINDING_FUNCTION /* function taking no args */
     102
     103#define OWL_DEFAULT_ZAWAYMSG    "I'm sorry, but I am currently away from the terminal and am\nnot able to receive your message.\n"
     104
     105#define OWL_INCLUDE_REG_TESTS   1  /* whether to build in regression tests */
    106106
    107107#define OWL_CMD_ALIAS_SUMMARY_PREFIX "command alias to: "
     
    227227  int id;
    228228  int type;
    229   int admintype;
     229  int direction;
    230230  ZNotice_t notice;
    231231  owl_fmtext fmtext;
  • readconfig.c

    r67103d4 r4b464a4  
    159159
    160160  /* set owl::type */
    161   if (owl_message_is_zephyr(m)) {
     161  if (owl_message_is_type_zephyr(m)) {
    162162    sv_setpv(perl_get_sv("owl::type", TRUE), "zephyr");
    163   } else if (owl_message_is_admin(m)) {
     163  } else if (owl_message_is_type_admin(m)) {
    164164    sv_setpv(perl_get_sv("owl::type", TRUE), "admin");
    165165  } else {
  • util.c

    r1fd0b25 r4b464a4  
    392392}
    393393
    394 char *pretty_sender(char *in) {
     394char *short_zuser(char *in) {
    395395  char *out, *ptr;
    396396 
     
    406406}
    407407
    408 char *long_sender(char *in) {
     408char *long_zuser(char *in) {
    409409  char *ptr;
    410410
     
    494494}
    495495
     496void owl_hack_animate() {
     497  owl_messagelist *ml;
     498  owl_message *m;
     499  owl_fmtext *fm;
     500  char *text, *ptr;
     501  int place;
     502
     503  /* grab the first message and make sure its id is 0 */
     504  ml=owl_global_get_msglist(&g);
     505  m=owl_messagelist_get_element(ml, 0);
     506  if (!m) return;
     507  if (owl_message_get_id(m)!=0) return;
     508
     509  fm=owl_message_get_fmtext(m);
     510  text=owl_fmtext_get_text(fm);
     511
     512  ptr=strstr(text, "OvO");
     513  if (ptr) {
     514    place=ptr-text;
     515    owl_fmtext_set_char(fm, place, '-');
     516    owl_fmtext_set_char(fm, place+2, '-');
     517
     518    owl_mainwin_redisplay(owl_global_get_mainwin(&g));
     519    owl_global_set_needrefresh(&g);
     520    return;
     521  }
     522
     523  ptr=strstr(text, "-v-");
     524  if (ptr) {
     525    place=ptr-text;
     526    owl_fmtext_set_char(fm, place, 'O');
     527    owl_fmtext_set_char(fm, place+2, 'O');
     528
     529    owl_mainwin_redisplay(owl_global_get_mainwin(&g));
     530    owl_global_set_needrefresh(&g);
     531    return;
     532  }
     533}
    496534
    497535/**************************************************************************/
  • zephyr.c

    r1c6c4d3 r4b464a4  
    359359    } else if (!strcasecmp(retnotice->z_class, "message") &&
    360360               !strcasecmp(retnotice->z_class_inst, "personal")) {
    361       tmp=pretty_sender(retnotice->z_recipient);
     361      tmp=short_zuser(retnotice->z_recipient);
    362362      owl_function_makemsg("Message sent to %s.", tmp);
    363363      free(tmp);
     
    370370              retnotice->z_class, retnotice->z_class_inst);
    371371    } else {
    372       tmp = pretty_sender(retnotice->z_recipient);
     372      tmp = short_zuser(retnotice->z_recipient);
    373373      owl_function_makemsg("%s: Not logged in or subscribing to messages.",
    374374                           tmp);
     
    446446  for (;numlocs;numlocs--) {
    447447    ZGetLocations(&locations,&one);
    448     myuser=pretty_sender(user);
     448    myuser=short_zuser(user);
    449449    sprintf(out, "%s%s: %s\t%s\t%s\n", out, myuser, locations.host, locations.tty, locations.time);
    450450    owl_free(myuser);
  • zwrite.c

    re1c4636 r4b464a4  
    182182}
    183183
     184char *owl_zwrite_get_opcode(owl_zwrite *z) {
     185  return(z->opcode);
     186}
     187
    184188char *owl_zwrite_get_realm(owl_zwrite *z) {
    185189  return(z->realm);
     
    219223}
    220224 
    221 
    222225void owl_zwrite_free(owl_zwrite *z) {
    223226  owl_list_free_all(&(z->recips), &owl_free);
Note: See TracChangeset for help on using the changeset viewer.