Changeset 4b464a4 for functions.c
- Timestamp:
- Aug 25, 2002, 11:35:03 AM (22 years ago)
- 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:
- 56330ff
- Parents:
- 7131cf2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
functions.c
r1354456 r4b464a4 22 22 void owl_function_command_norv(char *cmdbuff) { 23 23 char *rv; 24 rv =owl_function_command(cmdbuff);24 rv=owl_function_command(cmdbuff); 25 25 if (rv) owl_free(rv); 26 26 } … … 80 80 } 81 81 82 void owl_function_ adminmsg_outgoing(char *header, char *body, char *zwriteline) {82 void owl_function_make_outgoing_zephyr(char *header, char *body, char *zwriteline) { 83 83 owl_message *m; 84 84 int followlast; 85 owl_zwrite z; 86 char *tobuff, *recip; 85 87 86 88 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 */ 87 99 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 */ 90 118 owl_messagelist_append_element(owl_global_get_msglist(&g), m); 91 119 owl_view_consider_message(owl_global_get_current_view(&g), m); … … 100 128 wnoutrefresh(owl_global_get_curs_recwin(&g)); 101 129 owl_global_set_needrefresh(&g); 130 owl_free(tobuff); 102 131 } 103 132 … … 158 187 owl_zwrite_get_recipstr(&z, buff); 159 188 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); 161 190 owl_free(tmpbuff); 162 191 } … … 289 318 owl_function_nextmsg_full(NULL, 1, 1); 290 319 } 291 292 320 293 321 void owl_function_prevmsg_notdeleted() { … … 1059 1087 owl_message *m; 1060 1088 ZNotice_t *n; 1061 char buff[ 2048], tmpbuff[1024];1089 char buff[5000], tmpbuff[1024]; 1062 1090 char *ptr; 1063 1091 int i, j, fields, len; … … 1065 1093 1066 1094 v=owl_global_get_current_view(&g); 1067 1068 1095 m=owl_view_get_element(v, owl_global_get_curmsg(&g)); 1069 1070 1096 if (!m || owl_view_get_size(v)==0) { 1071 1097 owl_function_makemsg("No message selected\n"); … … 1073 1099 } 1074 1100 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)) { 1078 1123 owl_function_popless_text(buff); 1079 1124 return; 1080 1125 } 1081 1126 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 1082 1139 n=owl_message_get_notice(m); 1083 1140 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)); 1090 1146 strcat(buff, "Kind : "); 1091 1147 if (n->z_kind==UNSAFE) { … … 1505 1561 } 1506 1562 } 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"); 1515 1569 } else { 1516 1570 if (owl_message_is_login(m)) { … … 1548 1602 if (*to != '\0') { 1549 1603 char *tmp, *oldtmp; 1550 tmp= pretty_sender(to);1604 tmp=short_zuser(to); 1551 1605 if (cc) { 1552 1606 tmp = owl_util_uniq(oldtmp=tmp, cc, "-"); … … 1555 1609 owl_free(oldbuff); 1556 1610 } else { 1557 tmp= pretty_sender(to);1611 tmp=short_zuser(to); 1558 1612 buff = owl_sprintf("%s %s", oldbuff=buff, tmp); 1559 1613 owl_free(oldbuff); … … 1902 1956 1903 1957 /* 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); 1906 1960 1907 1961 /* name for the filter */ … … 1917 1971 f=owl_malloc(sizeof(owl_filter)); 1918 1972 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); 1923 1977 1924 1978 owl_filter_init_fromstring(f, filtname, argbuff); … … 1998 2052 owl_view *v; 1999 2053 owl_message *m; 2000 char * sender, *filtname=NULL;2054 char *zperson, *filtname=NULL; 2001 2055 2002 2056 v=owl_global_get_current_view(&g); … … 2005 2059 if (!m || owl_view_get_size(v)==0) { 2006 2060 owl_function_makemsg("No message selected\n"); 2007 return NULL;2061 return(NULL); 2008 2062 } 2009 2063 2010 2064 /* 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 */ 2016 2070 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); 2024 2082 } 2025 2083 … … 2027 2085 if (!strcasecmp(owl_message_get_class(m), "message") && 2028 2086 !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); 2031 2089 } 2032 2090 2033 2091 /* otherwise narrow to the class */ 2034 2092 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); 2036 2094 } 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); 2040 2098 } 2041 2099 … … 2056 2114 2057 2115 /* for now we skip admin messages. */ 2058 if (owl_message_is_ admin(m)2116 if (owl_message_is_type_admin(m) 2059 2117 || owl_message_is_login(m) 2060 || !owl_message_is_ zephyr(m)) {2118 || !owl_message_is_type_zephyr(m)) { 2061 2119 owl_function_makemsg("smartzpunt doesn't support this message type."); 2062 2120 return; … … 2241 2299 } 2242 2300 2243 2244 2301 void owl_function_help_for_command(char *cmdname) { 2245 2302 owl_fmtext fm;
Note: See TracChangeset
for help on using the changeset viewer.