- Timestamp:
- Jun 7, 2003, 12:09:47 PM (21 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:
- b2b0773
- Parents:
- dafd919
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
message.c
r5789230 rd559df9 219 219 220 220 221 void owl_message_set_isloginout(owl_message *m) 222 { 223 owl_message_set_attribute(m, "isloginout", ""); 221 void owl_message_set_islogin(owl_message *m) 222 { 223 owl_message_set_attribute(m, "loginout", "login"); 224 } 225 226 227 void owl_message_set_islogout(owl_message *m) 228 { 229 owl_message_set_attribute(m, "loginout", "logout"); 224 230 } 225 231 … … 228 234 char *res; 229 235 230 res=owl_message_get_attribute_value(m, " isloginout");236 res=owl_message_get_attribute_value(m, "loginout"); 231 237 if (!res) return(0); 232 238 return(1); 239 } 240 241 int owl_message_is_login(owl_message *m) 242 { 243 char *res; 244 245 res=owl_message_get_attribute_value(m, "loginout"); 246 if (!res) return(0); 247 if (!strcmp(res, "login")) return(1); 248 return(0); 249 } 250 251 252 int owl_message_is_logout(owl_message *m) 253 { 254 char *res; 255 256 res=owl_message_get_attribute_value(m, "loginout"); 257 if (!res) return(0); 258 if (!strcmp(res, "logout")) return(1); 259 return(0); 233 260 } 234 261 … … 541 568 } 542 569 543 void owl_message_create_incoming_aim(owl_message *m, char *sender, char *recipient, char *text) 544 { 545 char *indent; 546 570 /* if loginout == -1 it's a logout message 571 * 0 it's not a login/logout message 572 * 1 it's a login message 573 */ 574 void owl_message_create_aim(owl_message *m, char *sender, char *recipient, char *text, int direction, int loginout) 575 { 547 576 owl_message_init(m); 548 577 owl_message_set_body(m, text); … … 550 579 owl_message_set_recipient(m, recipient); 551 580 owl_message_set_type_aim(m); 552 owl_message_set_direction_in(m); 553 554 /* for now, all AIM messages are private messages since we don't do chat rooms */ 555 owl_message_set_isprivate(m); 556 557 indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10); 558 owl_text_indent(indent, text, OWL_MSGTAB); 559 owl_fmtext_init_null(&(m->fmtext)); 560 owl_fmtext_append_bold(&(m->fmtext), OWL_TABSTR); 561 owl_fmtext_append_bold(&(m->fmtext), "AIM from "); 562 owl_fmtext_append_bold(&(m->fmtext), sender); 563 owl_fmtext_append_bold(&(m->fmtext), "\n"); 564 owl_fmtext_append_bold(&(m->fmtext), indent); 565 if (text[strlen(text)-1]!='\n') { 581 582 if (direction==OWL_MESSAGE_DIRECTION_IN) { 583 owl_message_set_direction_in(m); 584 } else if (direction==OWL_MESSAGE_DIRECTION_OUT) { 585 owl_message_set_direction_out(m); 586 } 587 588 /* for now all messages that aren't loginout are private */ 589 if (!loginout) { 590 owl_message_set_isprivate(m); 591 } 592 593 if (loginout==-1) { 594 owl_message_set_islogout(m); 595 } else if (loginout==1) { 596 owl_message_set_islogin(m); 597 } 598 599 /* create the formatted message */ 600 if (owl_global_is_config_format(&g)) { 601 _owl_message_make_text_from_config(m); 602 } else { 603 _owl_message_make_text_from_aim(m); 604 } 605 } 606 607 void _owl_message_make_text_from_aim(owl_message *m) 608 { 609 char *indent; 610 611 if (owl_message_is_loginout(m)) { 612 owl_fmtext_init_null(&(m->fmtext)); 613 owl_fmtext_append_normal(&(m->fmtext), OWL_TABSTR); 614 if (owl_message_is_login(m)) { 615 owl_fmtext_append_bold(&(m->fmtext), "AIM LOGIN"); 616 } else { 617 owl_fmtext_append_bold(&(m->fmtext), "AIM LOGOUT"); 618 } 619 owl_fmtext_append_normal(&(m->fmtext), " for "); 620 owl_fmtext_append_normal(&(m->fmtext), owl_message_get_sender(m)); 621 owl_fmtext_append_normal(&(m->fmtext), "\n"); 622 } else if (owl_message_is_direction_in(m)) { 623 indent=owl_malloc(strlen(owl_message_get_body(m))+owl_text_num_lines(owl_message_get_body(m))*OWL_MSGTAB+10); 624 owl_text_indent(indent, owl_message_get_body(m), OWL_MSGTAB); 625 owl_fmtext_init_null(&(m->fmtext)); 626 owl_fmtext_append_bold(&(m->fmtext), OWL_TABSTR); 627 owl_fmtext_append_bold(&(m->fmtext), "AIM from "); 628 owl_fmtext_append_bold(&(m->fmtext), owl_message_get_sender(m)); 566 629 owl_fmtext_append_bold(&(m->fmtext), "\n"); 567 } 568 569 owl_free(indent); 570 } 571 572 void owl_message_create_outgoing_aim(owl_message *m, char *sender, char *recipient, char *text) 573 { 574 char *indent; 575 576 owl_message_init(m); 577 owl_message_set_body(m, text); 578 owl_message_set_sender(m, sender); 579 owl_message_set_recipient(m, recipient); 580 owl_message_set_type_aim(m); 581 owl_message_set_direction_out(m); 582 583 indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10); 584 owl_text_indent(indent, text, OWL_MSGTAB); 585 owl_fmtext_init_null(&(m->fmtext)); 586 owl_fmtext_append_normal(&(m->fmtext), OWL_TABSTR); 587 owl_fmtext_append_normal(&(m->fmtext), "AIM sent to "); 588 owl_fmtext_append_normal(&(m->fmtext), recipient); 589 owl_fmtext_append_normal(&(m->fmtext), "\n"); 590 owl_fmtext_append_ztext(&(m->fmtext), indent); 591 if (text[strlen(text)-1]!='\n') { 630 owl_fmtext_append_bold(&(m->fmtext), indent); 631 if (indent[strlen(indent)-1]!='\n') { 632 owl_fmtext_append_normal(&(m->fmtext), "\n"); 633 } 634 owl_free(indent); 635 } else if (owl_message_is_direction_out(m)) { 636 indent=owl_malloc(strlen(owl_message_get_body(m))+owl_text_num_lines(owl_message_get_body(m))*OWL_MSGTAB+10); 637 owl_text_indent(indent, owl_message_get_body(m), OWL_MSGTAB); 638 owl_fmtext_init_null(&(m->fmtext)); 639 owl_fmtext_append_normal(&(m->fmtext), OWL_TABSTR); 640 owl_fmtext_append_normal(&(m->fmtext), "AIM sent to "); 641 owl_fmtext_append_normal(&(m->fmtext), owl_message_get_recipient(m)); 592 642 owl_fmtext_append_normal(&(m->fmtext), "\n"); 593 } 594 595 owl_free(indent); 596 } 597 598 /* For login direction == 0 599 * For logout direction == 1 600 */ 601 void owl_message_create_aim_login(owl_message *m, int direction, char *screenname) 602 { 603 owl_message_init(m); 604 owl_message_set_body(m, ""); 605 owl_message_set_sender(m, screenname); 606 owl_message_set_recipient(m, owl_global_get_aim_screenname(&g)); 607 owl_message_set_type_aim(m); 608 owl_message_set_direction_in(m); 609 610 owl_message_set_isloginout(m); 611 612 owl_fmtext_init_null(&(m->fmtext)); 613 owl_fmtext_append_normal(&(m->fmtext), OWL_TABSTR); 614 if (direction==0) { 615 owl_fmtext_append_bold(&(m->fmtext), "AIM LOGIN"); 616 } else if (direction==1) { 617 owl_fmtext_append_bold(&(m->fmtext), "AIM LOGOUT"); 618 } 619 owl_fmtext_append_normal(&(m->fmtext), " for "); 620 owl_fmtext_append_normal(&(m->fmtext), screenname); 621 owl_fmtext_append_normal(&(m->fmtext), "\n"); 643 owl_fmtext_append_ztext(&(m->fmtext), indent); 644 if (indent[strlen(indent)-1]!='\n') { 645 owl_fmtext_append_normal(&(m->fmtext), "\n"); 646 } 647 owl_free(indent); 648 } 622 649 } 623 650 … … 687 714 /* Set the "isloginout" attribute if it's a login message */ 688 715 if (!strcasecmp(n->z_class, "login")) { 689 owl_message_set_isloginout(m); 716 if (!strcasecmp(n->z_opcode, "user_login")) { 717 owl_message_set_islogin(m); 718 } else if (!strcasecmp(n->z_opcode, "user_logout")) { 719 owl_message_set_islogout(m); 720 } 690 721 } 691 722
Note: See TracChangeset
for help on using the changeset viewer.