Changeset b45293f
- Timestamp:
- Oct 11, 2002, 11:56:23 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:
- 68b41b0
- Parents:
- 2adaf1d
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
ChangeLog
r2adaf1d rb45293f 1 1 $Id$ 2 2 3 1.2.7 4 Outgoing messages now go through the config for formatting 5 3 6 1.2.6 4 7 Started adding code for newmsgproc. It doesn't fully work yet! -
functions.c
r2adaf1d rb45293f 82 82 } 83 83 84 void owl_function_make_outgoing_zephyr(char * header, char *body, char *zwriteline, char *zsig) {84 void owl_function_make_outgoing_zephyr(char *body, char *zwriteline, char *zsig) { 85 85 owl_message *m; 86 86 int followlast; 87 87 owl_zwrite z; 88 char *tobuff, *recip;89 88 90 89 followlast=owl_global_should_followlast(&g); … … 93 92 owl_zwrite_create_from_line(&z, zwriteline); 94 93 95 /* in 'tobuff' place the "Message sent to foo" string.96 * Right now this only works for one recipient */97 tobuff=owl_malloc(strlen(owl_zwrite_get_recip_n(&z, 0))+100);98 sprintf(tobuff, "Zephyr sent to %s (Zsig: %s)", owl_zwrite_get_recip_n(&z, 0), zsig);99 100 94 /* create the message */ 101 95 m=owl_malloc(sizeof(owl_message)); 102 owl_message_create(m, tobuff, body); 103 owl_message_set_direction_out(m); 104 owl_message_set_type_zephyr(m); 105 106 /* set zwriteline */ 107 owl_message_set_zwriteline(m, zwriteline); 108 109 owl_message_set_class(m, owl_zwrite_get_class(&z)); 110 owl_message_set_instance(m, owl_zwrite_get_instance(&z)); 111 owl_message_set_opcode(m, owl_zwrite_get_opcode(&z)); 112 owl_message_set_realm(m, owl_zwrite_get_realm(&z)); 113 owl_message_set_sender(m, ZGetSender()); 114 /* this only gets the first recipient for now, must fix */ 115 recip=long_zuser(owl_zwrite_get_recip_n(&z, 0)); 116 owl_message_set_recipient(m, recip); 117 owl_free(recip); 96 owl_message_create_from_zwriteline(m, zwriteline, body, zsig); 118 97 119 98 /* add it to the global list */ … … 130 109 wnoutrefresh(owl_global_get_curs_recwin(&g)); 131 110 owl_global_set_needrefresh(&g); 132 owl_free(tobuff);133 111 owl_zwrite_free(&z); 134 112 } … … 176 154 177 155 void owl_function_zwrite(char *line) { 178 char *tmpbuff,buff[1024];156 char buff[1024]; 179 157 owl_zwrite z; 180 158 int i, j; … … 188 166 if (owl_global_is_displayoutgoing(&g) && owl_zwrite_is_personal(&z)) { 189 167 owl_zwrite_get_recipstr(&z, buff); 190 tmpbuff = owl_sprintf("Message sent to %s", buff); 191 owl_function_make_outgoing_zephyr(tmpbuff, owl_editwin_get_text(owl_global_get_typwin(&g)), line, owl_zwrite_get_zsig(&z)); 192 owl_free(tmpbuff); 168 owl_function_make_outgoing_zephyr(owl_editwin_get_text(owl_global_get_typwin(&g)), line, owl_zwrite_get_zsig(&z)); 193 169 } 194 170 … … 953 929 if (owl_global_is_bell(&g)) { 954 930 beep(); 931 owl_global_set_needrefresh(&g); /* do we really need this? */ 955 932 } 956 933 } -
message.c
r3a2daac rb45293f 1 1 #include <zephyr/zephyr.h> 2 2 #include <stdlib.h> 3 #include <unistd.h> 3 4 #include <string.h> 4 5 #include <sys/socket.h> … … 26 27 m->opcode=owl_strdup(""); 27 28 m->realm=owl_strdup(""); 29 m->zsig=owl_strdup(""); 28 30 strcpy(m->hostname, ""); 29 31 m->zwriteline=strdup(""); … … 65 67 char *owl_message_get_sender(owl_message *m) { 66 68 return(m->sender); 69 } 70 71 void owl_message_set_zsig(owl_message *m, char *zsig) { 72 if (m->zsig) owl_free(m->zsig); 73 m->zsig=owl_strdup(zsig); 74 } 75 76 char *owl_message_get_zsig(owl_message *m) { 77 return(m->zsig); 67 78 } 68 79 … … 347 358 } 348 359 349 void owl_message_create_from_z ephyr(owl_message *m, ZNotice_t *n) {360 void owl_message_create_from_znotice(owl_message *m, ZNotice_t *n) { 350 361 struct hostent *hent; 351 362 int k; … … 374 385 n->z_opcode=owl_strdup(""); 375 386 } 387 m->zsig=owl_strdup(n->z_message); 376 388 377 389 if ((ptr=strchr(n->z_recipient, '@'))!=NULL) { … … 383 395 m->zwriteline=strdup(""); 384 396 397 /* set the body */ 385 398 ptr=owl_zephyr_get_message(n, &k); 386 399 m->body=owl_malloc(k+10); … … 412 425 } 413 426 427 void owl_message_create_from_zwriteline(owl_message *m, char *line, char *body, char *zsig) { 428 owl_zwrite z; 429 int ret; 430 431 owl_message_init_raw(m); 432 433 /* create a zwrite for the purpose of filling in other message fields */ 434 owl_zwrite_create_from_line(&z, line); 435 436 /* set things */ 437 owl_message_set_direction_out(m); 438 owl_message_set_type_zephyr(m); 439 m->sender=owl_strdup(ZGetSender()); 440 m->class=owl_strdup(owl_zwrite_get_class(&z)); 441 m->inst=owl_strdup(owl_zwrite_get_instance(&z)); 442 m->recip=long_zuser(owl_zwrite_get_recip_n(&z, 0)); /* only gets the first user, must fix */ 443 owl_zwrite_get_recipstr(&z, m->recip); 444 m->opcode=owl_strdup(owl_zwrite_get_opcode(&z)); 445 m->realm=owl_strdup(owl_zwrite_get_realm(&z)); /* also a hack, but not here */ 446 m->zwriteline=owl_strdup(line); 447 m->body=owl_strdup(body); 448 m->zsig=owl_strdup(zsig); 449 450 /* save the hostname */ 451 ret=gethostname(m->hostname, MAXHOSTNAMELEN); 452 if (ret) { 453 strcpy(m->hostname, "localhost"); 454 } 455 456 /* create the formatted message */ 457 if (owl_global_is_config_format(&g)) { 458 _owl_message_make_text_from_config(m); 459 } else if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES)) { 460 _owl_message_make_text_from_zwriteline_standard(m); 461 } else { 462 _owl_message_make_text_from_zwriteline_simple(m); 463 } 464 465 owl_zwrite_free(&z); 466 } 414 467 415 468 void _owl_message_make_text_from_config(owl_message *m) { … … 432 485 } 433 486 487 void _owl_message_make_text_from_zwriteline_standard(owl_message *m) { 488 char *indent, *text, *zsigbuff; 489 490 text=owl_message_get_body(m); 491 492 indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10); 493 owl_text_indent(indent, text, OWL_MSGTAB); 494 owl_fmtext_init_null(&(m->fmtext)); 495 owl_fmtext_append_normal(&(m->fmtext), OWL_TABSTR); 496 owl_fmtext_append_normal(&(m->fmtext), "Zephyr sent to "); 497 owl_fmtext_append_normal(&(m->fmtext), owl_message_get_recipient(m)); 498 owl_fmtext_append_normal(&(m->fmtext), " (Zsig: "); 499 500 zsigbuff=owl_malloc(strlen(owl_message_get_zsig(m))); 501 owl_message_pretty_zsig(m, zsigbuff); 502 owl_fmtext_append_ztext(&(m->fmtext), zsigbuff); 503 owl_free(zsigbuff); 504 505 owl_fmtext_append_normal(&(m->fmtext), ")"); 506 owl_fmtext_append_normal(&(m->fmtext), "\n"); 507 owl_fmtext_append_ztext(&(m->fmtext), indent); 508 if (text[strlen(text)-1]!='\n') { 509 owl_fmtext_append_normal(&(m->fmtext), "\n"); 510 } 511 512 owl_free(indent); 513 } 514 515 void _owl_message_make_text_from_zwriteline_simple(owl_message *m) { 516 _owl_message_make_text_from_zwriteline_standard(m); 517 } 518 434 519 void _owl_message_make_text_from_notice_standard(owl_message *m) { 435 char *body, *indent, *ptr; 436 char frombuff[1024]; 437 char zsigbuff[LINE]; 520 char *body, *indent, *ptr, *zsigbuff, frombuff[LINE]; 438 521 ZNotice_t *n; 439 522 int len; … … 514 597 515 598 /* stick on the zsig */ 516 _owl_message_get_zsig(m, zsigbuff, LINE); 517 if (zsigbuff[0]!='\0') { 518 owl_fmtext_append_normal(&(m->fmtext), " ("); 519 owl_fmtext_append_ztext(&(m->fmtext), zsigbuff); 520 owl_fmtext_append_normal(&(m->fmtext), ")"); 521 } 522 owl_fmtext_append_normal(&(m->fmtext), "\n"); 599 zsigbuff=owl_malloc(strlen(owl_message_get_zsig(m))); 600 owl_message_pretty_zsig(m, zsigbuff); 601 owl_fmtext_append_normal(&(m->fmtext), " ("); 602 owl_fmtext_append_ztext(&(m->fmtext), zsigbuff); 603 owl_fmtext_append_normal(&(m->fmtext), ")"); 604 owl_fmtext_append_normal(&(m->fmtext), "\n"); 605 owl_free(zsigbuff); 606 607 /* then the indented message */ 523 608 owl_fmtext_append_ztext(&(m->fmtext), indent); 524 609 … … 536 621 537 622 void _owl_message_make_text_from_notice_simple(owl_message *m) { 538 char *body, *indent, *ptr; 539 char frombuff[1024]; 540 char zsigbuff[LINE]; 623 char *body, *indent, *ptr, *zsigbuff, frombuff[LINE]; 541 624 ZNotice_t *n; 542 625 int len; … … 616 699 617 700 /* stick on the zsig */ 618 _owl_message_get_zsig(m, zsigbuff, LINE); 619 if (zsigbuff[0]!='\0') { 620 owl_fmtext_append_normal(&(m->fmtext), " ("); 621 owl_fmtext_append_ztext(&(m->fmtext), zsigbuff); 622 owl_fmtext_append_normal(&(m->fmtext), ")"); 623 } 624 owl_fmtext_append_normal(&(m->fmtext), "\n"); 701 zsigbuff=owl_malloc(strlen(owl_message_get_zsig(m))); 702 owl_message_pretty_zsig(m, zsigbuff); 703 owl_fmtext_append_normal(&(m->fmtext), " ("); 704 owl_fmtext_append_ztext(&(m->fmtext), zsigbuff); 705 owl_fmtext_append_normal(&(m->fmtext), ")"); 706 owl_fmtext_append_normal(&(m->fmtext), "\n"); 707 owl_free(zsigbuff); 708 709 /* then the indented message */ 625 710 owl_fmtext_append_ztext(&(m->fmtext), indent); 626 711 … … 637 722 } 638 723 639 void _owl_message_get_zsig(owl_message *m, char *buff, int size) { 724 void owl_message_pretty_zsig(owl_message *m, char *buff) { 725 /* stick a one line version of the zsig in buff */ 640 726 char *ptr; 641 ZNotice_t n; 642 int len; 643 /* just a hackish thing for now. We'll only present the first line 644 or the first 'size'. characters. If the message is not 645 appropriate for having a zsig we'll return an empty string */ 646 n=m->notice; 647 648 649 /* bail if it shouldn't have a zsig */ 650 buff[0]='\0'; 651 if (!strcasecmp(n.z_opcode, "ping")) { 652 return; 653 } 654 655 /* find the right length to copy */ 656 len=strlen(n.z_message); 657 if (size < len) { 658 len=size; 659 } 660 if ((ptr=strchr(n.z_message, '\n'))!=NULL) { 661 if ((ptr-n.z_message) < len) { 662 len=ptr-n.z_message; 663 } 664 } 665 666 /* copy */ 667 strncpy(buff, n.z_message, len); 668 buff[len]='\0'; 669 } 670 727 728 strcpy(buff, m->zsig); 729 ptr=strchr(buff, '\n'); 730 if (ptr) ptr[0]='\0'; 731 } 671 732 672 733 void owl_message_free(owl_message *m) { -
owl.c
r55a4578 rb45293f 32 32 owl_editwin *tw; 33 33 owl_popwin *pw; 34 int j, ret, initialsubs, debug, newzephyrs, argcsave, followlast ;34 int j, ret, initialsubs, debug, newzephyrs, argcsave, followlast, nexttimediff; 35 35 struct sigaction sigact; 36 char *configfile, *tty, *perlout; 37 char buff[LINE], startupmsg[LINE]; 38 char **argvsave; 36 char *configfile, *tty, *perlout, **argvsave, buff[LINE], startupmsg[LINE]; 39 37 owl_filter *f; 40 38 time_t nexttime; 41 int nexttimediff;42 39 43 40 argcsave=argc; … … 139 136 /* setup the default filters */ 140 137 f=malloc(sizeof(owl_filter)); 141 owl_filter_init_fromstring(f, "personal", "class ^message$ and instance ^personal$ and ( recipient ^%me%$ or sender ^%me%$ )"); /* fix to use admintype */138 owl_filter_init_fromstring(f, "personal", "class ^message$ and instance ^personal$ and ( recipient ^%me%$ or sender ^%me%$ )"); 142 139 owl_list_append_element(owl_global_get_filterlist(&g), f); 143 140 … … 189 186 sepwin=owl_global_get_curs_sepwin(&g); 190 187 typwin=owl_global_get_curs_typwin(&g); 191 192 188 tw=owl_global_get_typwin(&g); 193 189 … … 279 275 /* create the new message */ 280 276 m=owl_malloc(sizeof(owl_message)); 281 owl_message_create_from_z ephyr(m, ¬ice);277 owl_message_create_from_znotice(m, ¬ice); 282 278 283 279 /* if it's on the puntlist then, nuke it and continue */ … … 305 301 if (owl_global_is_personalbell(&g) && owl_message_is_personal(m)) { 306 302 owl_function_beep(); 307 owl_global_set_needrefresh(&g);308 303 } 309 304 -
owl.h
r88736cb rb45293f 12 12 static const char owl_h_fileIdent[] = "$Id$"; 13 13 14 #define OWL_VERSION 1.2. 615 #define OWL_VERSION_STRING "1.2. 6"14 #define OWL_VERSION 1.2.7 15 #define OWL_VERSION_STRING "1.2.7" 16 16 17 17 #define OWL_DEBUG 0 … … 242 242 char *body; 243 243 char *zwriteline; 244 char *zsig; 244 245 } owl_message; 245 246 -
readconfig.c
r4b464a4 rb45293f 62 62 /* create variables */ 63 63 perl_get_sv("owl::id", TRUE); 64 perl_get_sv("owl::type", TRUE); 65 perl_get_sv("owl::direction", TRUE); 64 66 perl_get_sv("owl::class", TRUE); 65 67 perl_get_sv("owl::instance", TRUE); … … 127 129 int i, j, len; 128 130 char *ptr, *ptr2; 129 ZNotice_t *n;130 131 131 132 if (!owl_global_have_config(&g)) return(""); 132 133 133 134 /* set owl::msg */ 134 n=owl_message_get_notice(m);135 ptr=owl_zephyr_get_message(n, &len);135 ptr=owl_message_get_body(m); 136 len=strlen(ptr); 136 137 ptr2=owl_malloc(len+20); 137 138 memcpy(ptr2, ptr, len); … … 144 145 145 146 /* set owl::zsig */ 146 ptr=owl_zephyr_get_zsig(n, &len); 147 ptr=owl_message_get_zsig(m); 148 len=strlen(ptr); 147 149 if (len>0) { 148 150 ptr2=owl_malloc(len+20); … … 165 167 } else { 166 168 sv_setpv(perl_get_sv("owl::type", TRUE), "unknown"); 169 } 170 171 /* set owl::direction */ 172 if (owl_message_is_direction_in(m)) { 173 sv_setpv(perl_get_sv("owl::direction", TRUE), "in"); 174 } else if (owl_message_is_direction_out(m)) { 175 sv_setpv(perl_get_sv("owl::direction", TRUE), "out"); 176 } else if (owl_message_is_direction_none(m)) { 177 sv_setpv(perl_get_sv("owl::direction", TRUE), "none"); 178 } else { 179 sv_setpv(perl_get_sv("owl::direction", TRUE), "unknown"); 167 180 } 168 181 … … 189 202 190 203 /* set owl::fields */ 191 av_clear(perl_get_av("owl::fields", TRUE)); 192 j=owl_zephyr_get_num_fields(n); 193 for (i=0; i<j; i++) { 194 ptr=owl_zephyr_get_field(n, i+1, &len); 195 ptr2=owl_malloc(len+10); 196 memcpy(ptr2, ptr, len); 197 ptr2[len]='\0'; 198 av_push(perl_get_av("owl::fields", TRUE), newSVpvn(ptr2, len)); 199 owl_free(ptr2); 204 if (owl_message_is_type_zephyr(m) && owl_message_is_direction_in(m)) { 205 av_clear(perl_get_av("owl::fields", TRUE)); 206 j=owl_zephyr_get_num_fields(owl_message_get_notice(m)); 207 for (i=0; i<j; i++) { 208 ptr=owl_zephyr_get_field(owl_message_get_notice(m), i+1, &len); 209 ptr2=owl_malloc(len+10); 210 memcpy(ptr2, ptr, len); 211 ptr2[len]='\0'; 212 av_push(perl_get_av("owl::fields", TRUE), newSVpvn(ptr2, len)); 213 owl_free(ptr2); 214 } 200 215 } 201 216 202 217 /* for backwards compatibilty, because I'm an idiot */ 203 av_clear(perl_get_av("fields", TRUE)); 204 j=owl_zephyr_get_num_fields(n); 205 for (i=0; i<j; i++) { 206 ptr=owl_zephyr_get_field(n, i+1, &len); 207 ptr2=owl_malloc(len+10); 208 memcpy(ptr2, ptr, len); 209 ptr2[len]='\0'; 210 av_push(perl_get_av("fields", TRUE), newSVpvn(ptr2, len)); 211 owl_free(ptr2); 218 if (owl_message_is_type_zephyr(m) && owl_message_is_direction_in(m)) { 219 av_clear(perl_get_av("fields", TRUE)); 220 j=owl_zephyr_get_num_fields(owl_message_get_notice(m)); 221 for (i=0; i<j; i++) { 222 ptr=owl_zephyr_get_field(owl_message_get_notice(m), i+1, &len); 223 ptr2=owl_malloc(len+10); 224 memcpy(ptr2, ptr, len); 225 ptr2[len]='\0'; 226 av_push(perl_get_av("fields", TRUE), newSVpvn(ptr2, len)); 227 owl_free(ptr2); 228 } 212 229 } 213 230
Note: See TracChangeset
for help on using the changeset viewer.