Changeset d0d65df
- Timestamp:
- Feb 17, 2003, 3:47:41 PM (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:
- 985f85b
- Parents:
- a2641cd9
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
ChangeLog
ra2641cd9 rd0d65df 7 7 Fixed a case sensitivity probelm in owl_message_is_personal and 8 8 owl_message_is_private 9 The message object now uses a list of attributes internally, in 10 prep. for supporting new messaging protocols 11 owl_function_info now uses fmtext instead of one staticly sized 12 buffer 9 13 10 14 1.2.8 -
Makefile.in
rd309eb3 rd0d65df 12 12 global.o text.o fmtext.o editwin.o util.o logging.o readconfig.o keys.o \ 13 13 functions.o zwrite.o viewwin.o help.o filter.o regex.o history.o view.o \ 14 dict.o variable.o varstubs.o filterelement.o \14 dict.o variable.o varstubs.o filterelement.o pair.o \ 15 15 keypress.o keymap.o keybinding.o cmd.o context.o perlglue.o zcrypt.o 16 16 -
functions.c
r8f44c6b rd0d65df 1088 1088 void owl_function_info() { 1089 1089 owl_message *m; 1090 owl_fmtext fm; 1090 1091 ZNotice_t *n; 1091 char buff[ 5000], tmpbuff[1024];1092 char buff[10000], tmpbuff[1024]; 1092 1093 char *ptr; 1093 1094 int i, j, fields, len; 1094 1095 owl_view *v; 1095 1096 1097 owl_fmtext_init_null(&fm); 1098 1096 1099 v=owl_global_get_current_view(&g); 1097 1100 m=owl_view_get_element(v, owl_global_get_curmsg(&g)); … … 1101 1104 } 1102 1105 1103 sprintf(buff, "Msg Id : %i\n", owl_message_get_id(m)); 1106 owl_fmtext_append_normal(&fm, "Msg Id : "); 1107 sprintf(buff, "%i", owl_message_get_id(m)); 1108 owl_fmtext_append_normal(&fm, buff); 1109 owl_fmtext_append_normal(&fm, "\n"); 1104 1110 if (owl_message_is_type_zephyr(m)) { 1105 sprintf(buff, "%sType : zephyr\n", buff);1111 owl_fmtext_append_normal(&fm, "Type : zephyr\n"); 1106 1112 } else if (owl_message_is_type_admin(m)) { 1107 sprintf(buff, "%sType : admin\n", buff);1113 owl_fmtext_append_normal(&fm, "Type : admin\n"); 1108 1114 } else if (owl_message_is_type_generic(m)) { 1109 sprintf(buff, "%sType : generic\n", buff);1115 owl_fmtext_append_normal(&fm, "Type : generic\n"); 1110 1116 } else { 1111 sprintf(buff, "%sType : unknown\n", buff);1117 owl_fmtext_append_normal(&fm, "Type : unknown\n"); 1112 1118 } 1113 1119 if (owl_message_is_direction_in(m)) { 1114 sprintf(buff, "%sDirection : in\n", buff);1120 owl_fmtext_append_normal(&fm, "Direction : in\n"); 1115 1121 } else if (owl_message_is_direction_out(m)) { 1116 sprintf(buff, "%sDirection : out\n", buff);1122 owl_fmtext_append_normal(&fm, "Direction : out\n"); 1117 1123 } else if (owl_message_is_direction_none(m)) { 1118 sprintf(buff, "%sDirection : none\n", buff);1124 owl_fmtext_append_normal(&fm, "Direction : none\n"); 1119 1125 } else { 1120 sprintf(buff, "%sDirection : unknown\n", buff); 1121 } 1122 sprintf(buff, "%sTime : %s\n", buff, owl_message_get_timestr(m)); 1123 1124 if (!owl_message_is_type_zephyr(m)) { 1125 owl_function_popless_text(buff); 1126 return; 1127 } 1128 1129 1130 if (owl_message_is_direction_out(m)) { 1131 sprintf(buff, "%sClass : %s\n", buff, owl_message_get_class(m)); 1132 sprintf(buff, "%sInstance : %s\n", buff, owl_message_get_instance(m)); 1133 sprintf(buff, "%sSender : %s\n", buff, owl_message_get_sender(m)); 1134 sprintf(buff, "%sRecip : %s\n", buff, owl_message_get_recipient(m)); 1135 sprintf(buff, "%sOpcode : %s\n", buff, owl_message_get_opcode(m)); 1136 1137 owl_function_popless_text(buff); 1138 return; 1139 } 1140 1141 n=owl_message_get_notice(m); 1142 1143 sprintf(buff, "%sClass : %s\n", buff, owl_message_get_class(m)); 1144 sprintf(buff, "%sInstance : %s\n", buff, owl_message_get_instance(m)); 1145 sprintf(buff, "%sSender : %s\n", buff, owl_message_get_sender(m)); 1146 sprintf(buff, "%sRecip : %s\n", buff, owl_message_get_recipient(m)); 1147 sprintf(buff, "%sOpcode : %s\n", buff, owl_message_get_opcode(m)); 1148 strcat(buff, "Kind : "); 1149 if (n->z_kind==UNSAFE) { 1150 strcat(buff, "UNSAFE\n"); 1151 } else if (n->z_kind==UNACKED) { 1152 strcat(buff, "UNACKED\n"); 1153 } else if (n->z_kind==ACKED) { 1154 strcat(buff, "ACKED\n"); 1155 } else if (n->z_kind==HMACK) { 1156 strcat(buff, "HMACK\n"); 1157 } else if (n->z_kind==HMCTL) { 1158 strcat(buff, "HMCTL\n"); 1159 } else if (n->z_kind==SERVACK) { 1160 strcat(buff, "SERVACK\n"); 1161 } else if (n->z_kind==SERVNAK) { 1162 strcat(buff, "SERVNAK\n"); 1163 } else if (n->z_kind==CLIENTACK) { 1164 strcat(buff, "CLIENTACK\n"); 1165 } else if (n->z_kind==STAT) { 1166 strcat(buff, "STAT\n"); 1167 } else { 1168 strcat(buff, "ILLEGAL VALUE\n"); 1169 } 1170 sprintf(buff, "%sTime : %s\n", buff, owl_message_get_timestr(m)); 1171 sprintf(buff, "%sHost : %s\n", buff, owl_message_get_hostname(m)); 1172 sprintf(buff, "%sPort : %i\n", buff, n->z_port); 1173 strcat(buff, "Auth : "); 1174 if (n->z_auth == ZAUTH_FAILED) { 1175 strcat(buff, "FAILED\n"); 1176 } else if (n->z_auth == ZAUTH_NO) { 1177 strcat(buff, "NO\n"); 1178 } else if (n->z_auth == ZAUTH_YES) { 1179 strcat(buff, "YES\n"); 1180 } else { 1181 sprintf(buff, "%sUnknown State (%i)\n", buff, n->z_auth); 1182 } 1183 sprintf(buff, "%sCheckd Ath: %i\n", buff, n->z_checked_auth); 1184 sprintf(buff, "%sMulti notc: %s\n", buff, n->z_multinotice); 1185 sprintf(buff, "%sNum other : %i\n", buff, n->z_num_other_fields); 1186 sprintf(buff, "%sMsg Len : %i\n", buff, n->z_message_len); 1187 1188 sprintf(buff, "%sFields : %i\n", buff, owl_zephyr_get_num_fields(n)); 1189 1190 fields=owl_zephyr_get_num_fields(n); 1191 for (i=0; i<fields; i++) { 1192 sprintf(buff, "%sField %i : ", buff, i+1); 1193 1194 ptr=owl_zephyr_get_field(n, i+1, &len); 1195 if (!ptr) break; 1196 if (len<30) { 1197 strncpy(tmpbuff, ptr, len); 1198 tmpbuff[len]='\0'; 1199 } else { 1200 strncpy(tmpbuff, ptr, 30); 1201 tmpbuff[30]='\0'; 1202 strcat(tmpbuff, "..."); 1203 } 1204 1205 /* just for testing for now */ 1206 for (j=0; j<strlen(tmpbuff); j++) { 1207 if (tmpbuff[j]=='\n') tmpbuff[j]='~'; 1208 if (tmpbuff[j]=='\r') tmpbuff[j]='!'; 1209 } 1210 1211 strcat(buff, tmpbuff); 1212 strcat(buff, "\n"); 1213 } 1214 sprintf(buff, "%sDefault Fm: %s\n", buff, n->z_default_format); 1126 owl_fmtext_append_normal(&fm, "Direction : unknown\n"); 1127 } 1128 owl_fmtext_append_normal(&fm, "Time : "); 1129 owl_fmtext_append_normal(&fm, owl_message_get_timestr(m)); 1130 owl_fmtext_append_normal(&fm, "\n"); 1131 1132 if (owl_message_is_type_zephyr(m)) { 1133 1134 if (owl_message_is_direction_in(m)) { 1135 n=owl_message_get_notice(m); 1136 owl_fmtext_append_normal(&fm, "Class : "); 1137 owl_fmtext_append_normal(&fm, owl_message_get_class(m)); 1138 owl_fmtext_append_normal(&fm, "\n"); 1139 owl_fmtext_append_normal(&fm, "Instance : "); 1140 owl_fmtext_append_normal(&fm, owl_message_get_instance(m)); 1141 owl_fmtext_append_normal(&fm, "\n"); 1142 owl_fmtext_append_normal(&fm, "Sender : "); 1143 owl_fmtext_append_normal(&fm, owl_message_get_sender(m)); 1144 owl_fmtext_append_normal(&fm, "\n"); 1145 owl_fmtext_append_normal(&fm, "Recipient : "); 1146 owl_fmtext_append_normal(&fm, owl_message_get_recipient(m)); 1147 owl_fmtext_append_normal(&fm, "\n"); 1148 owl_fmtext_append_normal(&fm, "Opcode : "); 1149 owl_fmtext_append_normal(&fm, owl_message_get_opcode(m)); 1150 owl_fmtext_append_normal(&fm, "\n"); 1151 owl_fmtext_append_normal(&fm, "Kind : "); 1152 if (n->z_kind==UNSAFE) { 1153 owl_fmtext_append_normal(&fm, "UNSAFE\n"); 1154 } else if (n->z_kind==UNACKED) { 1155 owl_fmtext_append_normal(&fm, "UNACKED\n"); 1156 } else if (n->z_kind==ACKED) { 1157 owl_fmtext_append_normal(&fm, "ACKED\n"); 1158 } else if (n->z_kind==HMACK) { 1159 owl_fmtext_append_normal(&fm, "HMACK\n"); 1160 } else if (n->z_kind==HMCTL) { 1161 owl_fmtext_append_normal(&fm, "HMCTL\n"); 1162 } else if (n->z_kind==SERVACK) { 1163 owl_fmtext_append_normal(&fm, "SERVACK\n"); 1164 } else if (n->z_kind==SERVNAK) { 1165 owl_fmtext_append_normal(&fm, "SERVNACK\n"); 1166 } else if (n->z_kind==CLIENTACK) { 1167 owl_fmtext_append_normal(&fm, "CLIENTACK\n"); 1168 } else if (n->z_kind==STAT) { 1169 owl_fmtext_append_normal(&fm, "STAT\n"); 1170 } else { 1171 owl_fmtext_append_normal(&fm, "ILLEGAL VALUE\n"); 1172 } 1173 1174 owl_fmtext_append_normal(&fm, "Time : "); 1175 owl_fmtext_append_normal(&fm, owl_message_get_timestr(m)); 1176 owl_fmtext_append_normal(&fm, "\n"); 1177 owl_fmtext_append_normal(&fm, "Host : "); 1178 owl_fmtext_append_normal(&fm, owl_message_get_hostname(m)); 1179 owl_fmtext_append_normal(&fm, "\n"); 1180 sprintf(buff, "Port : %i\n", n->z_port); 1181 owl_fmtext_append_normal(&fm, buff); 1182 1183 owl_fmtext_append_normal(&fm, "Auth : "); 1184 if (n->z_auth == ZAUTH_FAILED) { 1185 owl_fmtext_append_normal(&fm, "FAILED\n"); 1186 } else if (n->z_auth == ZAUTH_NO) { 1187 owl_fmtext_append_normal(&fm, "NO\n"); 1188 } else if (n->z_auth == ZAUTH_YES) { 1189 owl_fmtext_append_normal(&fm, "YES\n"); 1190 } else { 1191 sprintf(buff, "Unknown State (%i)\n", n->z_auth); 1192 owl_fmtext_append_normal(&fm, buff); 1193 } 1194 1195 sprintf(buff, "Checkd Ath: %i\n", buff, n->z_checked_auth); 1196 sprintf(buff, "%sMulti notc: %s\n", buff, n->z_multinotice); 1197 sprintf(buff, "%sNum other : %i\n", buff, n->z_num_other_fields); 1198 sprintf(buff, "%sMsg Len : %i\n", buff, n->z_message_len); 1199 owl_fmtext_append_normal(&fm, buff); 1200 1201 sprintf(buff, "Fields : %i\n", owl_zephyr_get_num_fields(n)); 1202 owl_fmtext_append_normal(&fm, buff); 1203 1204 fields=owl_zephyr_get_num_fields(n); 1205 for (i=0; i<fields; i++) { 1206 sprintf(buff, "Field %i : ", i+1); 1215 1207 1216 owl_function_popless_text(buff); 1208 ptr=owl_zephyr_get_field(n, i+1, &len); 1209 if (!ptr) break; 1210 if (len<30) { 1211 strncpy(tmpbuff, ptr, len); 1212 tmpbuff[len]='\0'; 1213 } else { 1214 strncpy(tmpbuff, ptr, 30); 1215 tmpbuff[30]='\0'; 1216 strcat(tmpbuff, "..."); 1217 } 1218 1219 /* just for testing for now */ 1220 for (j=0; j<strlen(tmpbuff); j++) { 1221 if (tmpbuff[j]=='\n') tmpbuff[j]='~'; 1222 if (tmpbuff[j]=='\r') tmpbuff[j]='!'; 1223 } 1224 1225 strcat(buff, tmpbuff); 1226 strcat(buff, "\n"); 1227 owl_fmtext_append_normal(&fm, buff); 1228 } 1229 owl_fmtext_append_normal(&fm, "Default Fm:"); 1230 owl_fmtext_append_normal(&fm, n->z_default_format); 1231 } 1232 } 1233 1234 owl_function_popless_fmtext(&fm); 1217 1235 } 1218 1236 -
message.c
ra2641cd9 rd0d65df 14 14 static const char fileIdent[] = "$Id$"; 15 15 16 void owl_message_init _raw(owl_message *m) {16 void owl_message_init(owl_message *m) { 17 17 time_t t; 18 18 … … 21 21 owl_message_set_direction_none(m); 22 22 m->delete=0; 23 m->sender=owl_strdup("");24 m->class=owl_strdup("");25 m->inst=owl_strdup("");26 m->recip=owl_strdup("");27 m->opcode=owl_strdup("");28 m->realm=owl_strdup("");29 m->zsig=owl_strdup("");30 23 strcpy(m->hostname, ""); 31 24 m->zwriteline=strdup(""); 32 25 26 owl_list_create(&(m->attributes)); 27 33 28 /* save the time */ 34 29 t=time(NULL); … … 37 32 } 38 33 34 void owl_message_set_attribute(owl_message *m, char *attrname, char *attrvalue) { 35 /* add the named attribute to the message. If an attribute with the 36 name already exists, replace the old value with the new value */ 37 38 int i, j; 39 owl_pair *p; 40 41 /* look for an existing pair with this key, and nuke the entry if 42 found */ 43 j=owl_list_get_size(&(m->attributes)); 44 for (i=0; i<j; i++) { 45 p=owl_list_get_element(&(m->attributes), i); 46 if (!strcmp(owl_pair_get_key(p), attrname)) { 47 owl_free(owl_pair_get_key(p)); 48 owl_free(owl_pair_get_value(p)); 49 owl_free(p); 50 owl_list_remove_element(&(m->attributes), i); 51 break; 52 } 53 } 54 55 p=owl_malloc(sizeof(owl_pair)); 56 owl_pair_create(p, owl_strdup(attrname), owl_strdup(attrvalue)); 57 owl_list_append_element(&(m->attributes), p); 58 } 59 60 char *owl_message_get_attribute_value(owl_message *m, char *attrname) { 61 /* return the value associated with the named attribute, or NULL if 62 the attribute does not exist */ 63 int i, j; 64 owl_pair *p; 65 66 j=owl_list_get_size(&(m->attributes)); 67 for (i=0; i<j; i++) { 68 p=owl_list_get_element(&(m->attributes), i); 69 if (!strcmp(owl_pair_get_key(p), attrname)) { 70 return(owl_pair_get_value(p)); 71 } 72 } 73 owl_function_debugmsg("No attribute %s found", attrname); 74 return(NULL); 75 } 76 39 77 40 78 owl_fmtext *owl_message_get_fmtext(owl_message *m) { … … 43 81 44 82 void owl_message_set_class(owl_message *m, char *class) { 45 if (m->class) owl_free(m->class); 46 m->class=owl_strdup(class); 83 owl_message_set_attribute(m, "class", class); 47 84 } 48 85 49 86 char *owl_message_get_class(owl_message *m) { 50 return(m->class); 87 char *class; 88 89 class=owl_message_get_attribute_value(m, "class"); 90 if (!class) return(""); 91 return(class); 51 92 } 52 93 53 94 void owl_message_set_instance(owl_message *m, char *inst) { 54 if (m->inst) owl_free(m->inst); 55 m->inst=owl_strdup(inst); 95 owl_message_set_attribute(m, "instance", inst); 56 96 } 57 97 58 98 char *owl_message_get_instance(owl_message *m) { 59 return(m->inst); 99 char *instance; 100 101 instance=owl_message_get_attribute_value(m, "instance"); 102 if (!instance) return(""); 103 return(instance); 60 104 } 61 105 62 106 void owl_message_set_sender(owl_message *m, char *sender) { 63 if (m->sender) owl_free(m->sender); 64 m->sender=owl_strdup(sender); 107 owl_message_set_attribute(m, "sender", sender); 65 108 } 66 109 67 110 char *owl_message_get_sender(owl_message *m) { 68 return(m->sender); 111 char *sender; 112 113 sender=owl_message_get_attribute_value(m, "sender"); 114 if (!sender) return(""); 115 return(sender); 69 116 } 70 117 71 118 void owl_message_set_zsig(owl_message *m, char *zsig) { 72 if (m->zsig) owl_free(m->zsig); 73 m->zsig=owl_strdup(zsig); 119 owl_message_set_attribute(m, "zsig", zsig); 74 120 } 75 121 76 122 char *owl_message_get_zsig(owl_message *m) { 77 return(m->zsig); 123 char *zsig; 124 125 zsig=owl_message_get_attribute_value(m, "zsig"); 126 if (!zsig) return(""); 127 return(zsig); 78 128 } 79 129 80 130 void owl_message_set_recipient(owl_message *m, char *recip) { 81 if (m->recip) owl_free(m->recip); 82 m->recip=owl_strdup(recip); 131 owl_message_set_attribute(m, "recipient", recip); 83 132 } 84 133 85 134 char *owl_message_get_recipient(owl_message *m) { 86 135 /* this is stupid for outgoing messages, we need to fix it. */ 136 137 char *recip; 87 138 88 139 if (m->type==OWL_MESSAGE_TYPE_ZEPHYR) { 89 re turn(m->recip);140 recip=owl_message_get_attribute_value(m, "recipient"); 90 141 } else if (owl_message_is_direction_out(m)) { 91 re turn(m->zwriteline);142 recip=m->zwriteline; 92 143 } else { 93 return(m->recip); 94 } 144 recip=owl_message_get_attribute_value(m, "recipient"); 145 } 146 if (!recip) return(""); 147 return(recip); 95 148 } 96 149 97 150 void owl_message_set_realm(owl_message *m, char *realm) { 98 if (m->realm) owl_free(m->realm); 99 m->realm=owl_strdup(realm); 151 owl_message_set_attribute(m, "realm", realm); 100 152 } 101 153 102 154 char *owl_message_get_realm(owl_message *m) { 103 return(m->realm); 104 } 155 char *realm; 156 157 realm=owl_message_get_attribute_value(m, "realm"); 158 if (!realm) return(""); 159 return(realm); 160 } 161 162 void owl_message_set_body(owl_message *m, char *body) { 163 owl_message_set_attribute(m, "body", body); 164 } 165 166 char *owl_message_get_body(owl_message *m) { 167 char *body; 168 169 body=owl_message_get_attribute_value(m, "body"); 170 if (!body) return(""); 171 return(body); 172 } 173 105 174 106 175 void owl_message_set_opcode(owl_message *m, char *opcode) { 107 if (m->opcode) free(m->opcode); 108 m->opcode=owl_strdup(opcode); 176 owl_message_set_attribute(m, "opcode", opcode); 109 177 } 110 178 111 179 char *owl_message_get_opcode(owl_message *m) { 112 return(m->opcode); 180 char *opcode; 181 182 opcode=owl_message_get_attribute_value(m, "opcode"); 183 if (!opcode) return(""); 184 return(opcode); 113 185 } 114 186 … … 142 214 char *owl_message_get_text(owl_message *m) { 143 215 return(owl_fmtext_get_text(&(m->fmtext))); 144 }145 146 char *owl_message_get_body(owl_message *m) {147 return(m->body);148 216 } 149 217 … … 315 383 char *indent; 316 384 317 owl_message_init _raw(m);318 319 m->body=owl_strdup(text);385 owl_message_init(m); 386 387 owl_message_set_body(m, text); 320 388 321 389 indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10); … … 336 404 char *indent; 337 405 338 owl_message_init _raw(m);406 owl_message_init(m); 339 407 owl_message_set_type_admin(m); 340 408 341 m->body=owl_strdup(text);409 owl_message_set_body(m, text); 342 410 343 411 /* do something to make it clear the notice shouldn't be used for now */ … … 361 429 struct hostent *hent; 362 430 int k, ret; 363 char *ptr, *tmp; 364 365 m->id=owl_global_get_nextmsgid(&g); 431 char *ptr, *tmp, *tmp2; 432 433 owl_message_init(m); 434 366 435 owl_message_set_type_zephyr(m); 367 436 owl_message_set_direction_in(m); … … 376 445 377 446 /* set other info */ 378 m->sender=owl_strdup(n->z_sender);379 m->class=owl_strdup(n->z_class);380 m->inst=owl_strdup(n->z_class_inst);381 m->recip=owl_strdup(n->z_recipient);447 owl_message_set_sender(m, n->z_sender); 448 owl_message_set_class(m, n->z_class); 449 owl_message_set_instance(m, n->z_class_inst); 450 owl_message_set_recipient(m, n->z_recipient); 382 451 if (n->z_opcode) { 383 m->opcode=owl_strdup(n->z_opcode);452 owl_message_set_opcode(m, n->z_opcode); 384 453 } else { 385 n->z_opcode=owl_strdup("");386 } 387 m->zsig=owl_strdup(n->z_message);454 owl_message_set_opcode(m, ""); 455 } 456 owl_message_set_zsig(m, n->z_message); 388 457 389 458 if ((ptr=strchr(n->z_recipient, '@'))!=NULL) { 390 m->realm=owl_strdup(ptr+1);459 owl_message_set_realm(m, ptr+1); 391 460 } else { 392 m->realm=owl_strdup(ZGetRealm());461 owl_message_set_realm(m, ZGetRealm()); 393 462 } 394 463 … … 401 470 tmp[k]='\0'; 402 471 if (owl_global_is_newlinestrip(&g)) { 403 m->body=owl_util_stripnewlines(tmp); 472 tmp2=owl_util_stripnewlines(tmp); 473 owl_message_set_body(m, tmp2); 404 474 owl_free(tmp); 475 owl_free(tmp2); 405 476 } else { 406 m->body=tmp;477 owl_message_set_body(m, tmp); 407 478 } 408 479 … … 411 482 char *out; 412 483 413 out=owl_malloc(strlen( m->body)*16+20);414 ret=zcrypt_decrypt(out, m->body, m->class, m->inst);484 out=owl_malloc(strlen(owl_message_get_body(m))*16+20); 485 ret=zcrypt_decrypt(out, owl_message_get_body(m), owl_message_get_class(m), owl_message_get_instance(m)); 415 486 if (ret==0) { 416 owl_free(m->body); 417 m->body=out; 487 owl_message_set_body(m, out); 418 488 } else { 419 489 owl_free(out); … … 449 519 int ret; 450 520 451 owl_message_init _raw(m);521 owl_message_init(m); 452 522 453 523 /* create a zwrite for the purpose of filling in other message fields */ … … 460 530 owl_message_set_class(m, owl_zwrite_get_class(&z)); 461 531 owl_message_set_instance(m, owl_zwrite_get_instance(&z)); 462 m->recip=long_zuser(owl_zwrite_get_recip_n(&z, 0)); /* only gets the first user, must fix */ 532 owl_message_set_recipient(m, 533 long_zuser(owl_zwrite_get_recip_n(&z, 0))); /* only gets the first user, must fix */ 463 534 owl_message_set_opcode(m, owl_zwrite_get_opcode(&z)); 464 m->realm=owl_strdup(owl_zwrite_get_realm(&z)); /* also a hack, but not here */535 owl_message_set_realm(m, owl_zwrite_get_realm(&z)); /* also a hack, but not here */ 465 536 m->zwriteline=owl_strdup(line); 466 m->body=owl_strdup(body);537 owl_message_set_body(m, body); 467 538 owl_message_set_zsig(m, zsig); 468 539 … … 487 558 void _owl_message_make_text_from_config(owl_message *m) { 488 559 char *body, *indent; 489 560 490 561 owl_fmtext_init_null(&(m->fmtext)); 491 562 … … 571 642 572 643 /* get the body */ 573 body=owl_malloc(strlen( m->body)+30);574 strcpy(body, m->body);644 body=owl_malloc(strlen(owl_message_get_body(m))+30); 645 strcpy(body, owl_message_get_body(m)); 575 646 576 647 /* add a newline if we need to */ … … 584 655 585 656 /* edit the from addr for printing */ 586 strcpy(frombuff, m->sender);657 strcpy(frombuff, owl_message_get_sender(m)); 587 658 ptr=strchr(frombuff, '@'); 588 659 if (ptr && !strncmp(ptr+1, ZGetRealm(), strlen(ZGetRealm()))) { … … 594 665 owl_fmtext_append_normal(&(m->fmtext), OWL_TABSTR); 595 666 596 if (!strcasecmp( n->z_opcode, "ping") && owl_message_is_private(m)) {667 if (!strcasecmp(owl_message_get_opcode(m), "ping") && owl_message_is_private(m)) { 597 668 owl_fmtext_append_bold(&(m->fmtext), "PING"); 598 669 owl_fmtext_append_normal(&(m->fmtext), " from "); … … 625 696 owl_fmtext_append_normal(&(m->fmtext), "\n"); 626 697 } else { 627 owl_fmtext_append_normal(&(m->fmtext), m->class);698 owl_fmtext_append_normal(&(m->fmtext), owl_message_get_class(m)); 628 699 owl_fmtext_append_normal(&(m->fmtext), " / "); 629 owl_fmtext_append_normal(&(m->fmtext), m->inst);700 owl_fmtext_append_normal(&(m->fmtext), owl_message_get_instance(m)); 630 701 owl_fmtext_append_normal(&(m->fmtext), " / "); 631 702 owl_fmtext_append_bold(&(m->fmtext), frombuff); … … 637 708 if (n->z_opcode[0]!='\0') { 638 709 owl_fmtext_append_normal(&(m->fmtext), " ["); 639 owl_fmtext_append_normal(&(m->fmtext), n->z_opcode);710 owl_fmtext_append_normal(&(m->fmtext), owl_message_get_opcode(m)); 640 711 owl_fmtext_append_normal(&(m->fmtext), "] "); 641 712 } … … 672 743 673 744 /* get the body */ 674 body=owl_malloc(strlen( m->body)+30);675 strcpy(body, m->body);745 body=owl_malloc(strlen(owl_message_get_body(m)+30)); 746 strcpy(body, owl_message_get_body(m)); 676 747 677 748 /* add a newline if we need to */ … … 685 756 686 757 /* edit the from addr for printing */ 687 strcpy(frombuff, m->sender);758 strcpy(frombuff, owl_message_get_sender(m)); 688 759 ptr=strchr(frombuff, '@'); 689 760 if (ptr && !strncmp(ptr+1, ZGetRealm(), strlen(ZGetRealm()))) { … … 695 766 owl_fmtext_append_normal(&(m->fmtext), OWL_TABSTR); 696 767 697 if (!strcasecmp( n->z_opcode, "ping")) {768 if (!strcasecmp(owl_message_get_opcode(m), "ping")) { 698 769 owl_fmtext_append_bold(&(m->fmtext), "PING"); 699 770 owl_fmtext_append_normal(&(m->fmtext), " from "); 700 771 owl_fmtext_append_bold(&(m->fmtext), frombuff); 701 772 owl_fmtext_append_normal(&(m->fmtext), "\n"); 702 } else if (!strcasecmp( n->z_class, "login")) {773 } else if (!strcasecmp(owl_message_get_class(m), "login")) { 703 774 char *ptr, host[LINE], tty[LINE]; 704 775 int len; … … 711 782 tty[len]='\0'; 712 783 713 if (!strcasecmp( n->z_opcode, "user_login")) {784 if (!strcasecmp(owl_message_get_opcode(m), "user_login")) { 714 785 owl_fmtext_append_bold(&(m->fmtext), "LOGIN"); 715 } else if (!strcasecmp( n->z_opcode, "user_logout")) {786 } else if (!strcasecmp(owl_message_get_opcode(m), "user_logout")) { 716 787 owl_fmtext_append_bold(&(m->fmtext), "LOGOUT"); 717 788 } 718 789 owl_fmtext_append_normal(&(m->fmtext), " for "); 719 ptr=short_zuser( n->z_class_inst);790 ptr=short_zuser(owl_message_get_instance(m)); 720 791 owl_fmtext_append_bold(&(m->fmtext), ptr); 721 792 owl_free(ptr); … … 727 798 } else { 728 799 owl_fmtext_append_normal(&(m->fmtext), "From: "); 729 if (strcasecmp( m->class, "message")) {800 if (strcasecmp(owl_message_get_class(m), "message")) { 730 801 owl_fmtext_append_normal(&(m->fmtext), "Class "); 731 owl_fmtext_append_normal(&(m->fmtext), m->class);802 owl_fmtext_append_normal(&(m->fmtext), owl_message_get_class(m)); 732 803 owl_fmtext_append_normal(&(m->fmtext), " / Instance "); 733 owl_fmtext_append_normal(&(m->fmtext), m->inst);804 owl_fmtext_append_normal(&(m->fmtext), owl_message_get_instance(m)); 734 805 owl_fmtext_append_normal(&(m->fmtext), " / "); 735 806 } … … 769 840 char *ptr; 770 841 771 strcpy(buff, m->zsig);842 strcpy(buff, owl_message_get_zsig(m)); 772 843 ptr=strchr(buff, '\n'); 773 844 if (ptr) ptr[0]='\0'; … … 775 846 776 847 void owl_message_free(owl_message *m) { 848 int i, j; 849 owl_pair *p; 850 777 851 if (owl_message_is_type_zephyr(m) && owl_message_is_direction_in(m)) { 778 852 ZFreeNotice(&(m->notice)); 779 853 } 780 if (m->sender) owl_free(m->sender);781 if (m->recip) owl_free(m->recip);782 if (m->class) owl_free(m->class);783 if (m->inst) owl_free(m->inst);784 if (m->opcode) owl_free(m->opcode);785 854 if (m->time) owl_free(m->time); 786 if (m->realm) owl_free(m->realm);787 if (m->body) owl_free(m->body);788 855 if (m->zwriteline) owl_free(m->zwriteline); 856 857 /* free all the attributes */ 858 j=owl_list_get_size(&(m->attributes)); 859 for (i=0; i<j; i++) { 860 p=owl_list_get_element(&(m->attributes), i); 861 owl_free(owl_pair_get_key(p)); 862 owl_free(owl_pair_get_value(p)); 863 owl_free(p); 864 } 865 866 owl_list_free_simple(&(m->attributes)); 789 867 790 868 owl_fmtext_free(&(m->fmtext)); -
owl.h
r8f44c6b rd0d65df 39 39 #define OWL_MESSAGE_TYPE_GENERIC 1 40 40 #define OWL_MESSAGE_TYPE_ZEPHYR 2 41 #define OWL_MESSAGE_TYPE_AIM 3 42 #define OWL_MESSAGE_TYPE_JABBER 4 43 #define OWL_MESSAGE_TYPE_ICQ 5 44 #define OWL_MESSAGE_TYPE_YAHOO 6 45 #define OWL_MESSAGE_TYPE_MSN 7 41 46 42 47 #define OWL_MESSAGE_DIRECTION_NONE 0 … … 225 230 } owl_zwrite; 226 231 232 typedef struct _owl_pair { 233 void *key; 234 void *value; 235 } owl_pair; 236 227 237 typedef struct _owl_message { 228 238 int id; … … 233 243 int delete; 234 244 char hostname[MAXHOSTNAMELEN]; 235 char *sender; 236 char *recip; 237 char *class; 238 char *inst; 239 char *opcode; 245 owl_list attributes; /* this is a list of pairs */ 240 246 char *time; 241 char *realm;242 char *body;243 247 char *zwriteline; 244 char *zsig;245 248 } owl_message; 246 249
Note: See TracChangeset
for help on using the changeset viewer.