Changeset 4b464a4 for functions.c


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
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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;
Note: See TracChangeset for help on using the changeset viewer.