Changeset ec6ff52 for stylefunc.c
- Timestamp:
- Oct 17, 2003, 5:16:25 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:
- 836ea3a3
- Parents:
- a053de8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
stylefunc.c
r03955f3 rec6ff52 529 529 530 530 } 531 532 void owl_stylefunc_vt(owl_fmtext *fm, owl_message *m) 533 { 534 #ifdef HAVE_LIBZEPHYR 535 char *body, *indent, *ptr, *zsigbuff, frombuff[LINE]; 536 owl_fmtext fm_first, fm_other, fm_tmp; 537 ZNotice_t *n; 538 #endif 539 char *sender, *hostname, *timestr, *classinst1, *classinst2; 540 541 if (owl_message_is_type_zephyr(m) && owl_message_is_direction_in(m)) { 542 #ifdef HAVE_LIBZEPHYR 543 n=owl_message_get_notice(m); 544 545 /* get the body */ 546 body=owl_malloc(strlen(owl_message_get_body(m))+30); 547 strcpy(body, owl_message_get_body(m)); 548 549 /* add a newline if we need to */ 550 if (body[0]!='\0' && body[strlen(body)-1]!='\n') { 551 strcat(body, "\n"); 552 } 553 554 owl_fmtext_init_null(&fm_tmp); 555 owl_fmtext_append_ztext(&fm_tmp, body); 556 owl_fmtext_init_null(&fm_first); 557 owl_fmtext_truncate_lines(&fm_tmp, 0, 1, &fm_first); 558 559 /* do the indenting into indent */ 560 indent=owl_malloc(strlen(body)+owl_text_num_lines(body)*OWL_MSGTAB+10); 561 owl_text_indent(indent, body, 31); 562 563 owl_fmtext_free(&fm_tmp); 564 owl_fmtext_init_null(&fm_tmp); 565 owl_fmtext_append_ztext(&fm_tmp, indent); 566 owl_fmtext_init_null(&fm_other); 567 owl_fmtext_truncate_lines(&fm_tmp, 1, owl_fmtext_num_lines(&fm_tmp)-1, &fm_other); 568 owl_fmtext_free(&fm_tmp); 569 570 /* edit the from addr for printing */ 571 strcpy(frombuff, owl_message_get_sender(m)); 572 ptr=strchr(frombuff, '@'); 573 if (ptr && !strncmp(ptr+1, owl_zephyr_get_realm(), strlen(owl_zephyr_get_realm()))) { 574 *ptr='\0'; 575 } 576 sender=owl_sprintf("%-9.9s", frombuff); 577 578 hostname=owl_sprintf("%-9.9s", owl_message_get_hostname(m)); 579 timestr=owl_strdup("00:00"); 580 classinst1=owl_sprintf("<%s>[%s]", owl_message_get_class(m), owl_message_get_instance(m)); 581 classinst2=owl_sprintf("%-9.9s", classinst1); 582 583 /* set the message for printing */ 584 owl_fmtext_append_normal(fm, OWL_TABSTR); 585 586 if (owl_message_is_ping(m) && owl_message_is_private(m)) { 587 owl_fmtext_append_bold(fm, "PING"); 588 owl_fmtext_append_normal(fm, " from "); 589 owl_fmtext_append_bold(fm, frombuff); 590 owl_fmtext_append_normal(fm, "\n"); 591 } else if (owl_message_is_loginout(m)) { 592 char *ptr, *host, *tty; 593 int len; 594 595 ptr=owl_zephyr_get_field(n, 1, &len); 596 host=owl_malloc(len+10); 597 strncpy(host, ptr, len); 598 host[len]='\0'; 599 600 ptr=owl_zephyr_get_field(n, 3, &len); 601 tty=owl_malloc(len+10); 602 strncpy(tty, ptr, len); 603 tty[len]='\0'; 604 605 if (owl_message_is_login(m)) { 606 owl_fmtext_append_bold(fm, "LOGIN"); 607 } else if (owl_message_is_logout(m)) { 608 owl_fmtext_append_bold(fm, "LOGOUT"); 609 } 610 owl_fmtext_append_normal(fm, " for "); 611 ptr=short_zuser(owl_message_get_instance(m)); 612 owl_fmtext_append_bold(fm, ptr); 613 owl_free(ptr); 614 owl_fmtext_append_normal(fm, " at "); 615 owl_fmtext_append_normal(fm, host); 616 owl_fmtext_append_normal(fm, " "); 617 owl_fmtext_append_normal(fm, tty); 618 owl_fmtext_append_normal(fm, "\n"); 619 620 owl_free(host); 621 owl_free(tty); 622 } else { 623 owl_fmtext_append_normal(fm, sender); 624 owl_fmtext_append_normal(fm, "|"); 625 owl_fmtext_append_normal(fm, hostname); 626 owl_fmtext_append_normal(fm, " "); 627 owl_fmtext_append_normal(fm, timestr); 628 owl_fmtext_append_normal(fm, " "); 629 owl_fmtext_append_normal(fm, classinst2); 630 631 owl_fmtext_append_normal(fm, " "); 632 owl_fmtext_append_fmtext(fm, &fm_first); 633 owl_fmtext_append_fmtext(fm, &fm_other); 634 635 owl_fmtext_free(&fm_other); 636 owl_fmtext_free(&fm_first); 637 638 /* make private messages bold for smaat users */ 639 if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES)) { 640 if (owl_message_is_personal(m)) { 641 owl_fmtext_addattr((&m->fmtext), OWL_FMTEXT_ATTR_BOLD); 642 } 643 } 644 } 645 646 owl_free(sender); 647 owl_free(hostname); 648 owl_free(timestr); 649 owl_free(classinst1); 650 owl_free(classinst2); 651 652 owl_free(body); 653 owl_free(indent); 654 #endif 655 } else if (owl_message_is_type_zephyr(m) && owl_message_is_direction_out(m)) { 656 char *indent, *text, *zsigbuff, *foo; 657 658 text=owl_message_get_body(m); 659 660 indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10); 661 owl_text_indent(indent, text, OWL_MSGTAB); 662 owl_fmtext_append_normal(fm, OWL_TABSTR); 663 owl_fmtext_append_normal(fm, "Zephyr sent to "); 664 foo=short_zuser(owl_message_get_recipient(m)); 665 owl_fmtext_append_normal(fm, foo); 666 owl_free(foo); 667 owl_fmtext_append_normal(fm, " (Zsig: "); 668 669 zsigbuff=owl_malloc(strlen(owl_message_get_zsig(m))+30); 670 owl_message_pretty_zsig(m, zsigbuff); 671 owl_fmtext_append_ztext(fm, zsigbuff); 672 owl_free(zsigbuff); 673 674 owl_fmtext_append_normal(fm, ")"); 675 owl_fmtext_append_normal(fm, "\n"); 676 owl_fmtext_append_ztext(fm, indent); 677 if (text[strlen(text)-1]!='\n') { 678 owl_fmtext_append_normal(fm, "\n"); 679 } 680 681 owl_free(indent); 682 } else if (owl_message_is_type_aim(m)) { 683 char *indent; 684 685 if (owl_message_is_loginout(m)) { 686 owl_fmtext_append_normal(fm, OWL_TABSTR); 687 if (owl_message_is_login(m)) { 688 owl_fmtext_append_bold(fm, "AIM LOGIN"); 689 } else { 690 owl_fmtext_append_bold(fm, "AIM LOGOUT"); 691 } 692 owl_fmtext_append_normal(fm, " for "); 693 owl_fmtext_append_normal(fm, owl_message_get_sender(m)); 694 owl_fmtext_append_normal(fm, "\n"); 695 } else if (owl_message_is_direction_in(m)) { 696 indent=owl_malloc(strlen(owl_message_get_body(m))+owl_text_num_lines(owl_message_get_body(m))*OWL_MSGTAB+10); 697 owl_text_indent(indent, owl_message_get_body(m), OWL_MSGTAB); 698 owl_fmtext_append_bold(fm, OWL_TABSTR); 699 owl_fmtext_append_bold(fm, "AIM from "); 700 owl_fmtext_append_bold(fm, owl_message_get_sender(m)); 701 owl_fmtext_append_bold(fm, "\n"); 702 owl_fmtext_append_bold(fm, indent); 703 if (indent[strlen(indent)-1]!='\n') { 704 owl_fmtext_append_normal(fm, "\n"); 705 } 706 owl_free(indent); 707 } else if (owl_message_is_direction_out(m)) { 708 indent=owl_malloc(strlen(owl_message_get_body(m))+owl_text_num_lines(owl_message_get_body(m))*OWL_MSGTAB+10); 709 owl_text_indent(indent, owl_message_get_body(m), OWL_MSGTAB); 710 owl_fmtext_append_normal(fm, OWL_TABSTR); 711 owl_fmtext_append_normal(fm, "AIM sent to "); 712 owl_fmtext_append_normal(fm, owl_message_get_recipient(m)); 713 owl_fmtext_append_normal(fm, "\n"); 714 owl_fmtext_append_ztext(fm, indent); 715 if (indent[strlen(indent)-1]!='\n') { 716 owl_fmtext_append_normal(fm, "\n"); 717 } 718 owl_free(indent); 719 } 720 } else if (owl_message_is_type_admin(m)) { 721 char *text, *header, *indent; 722 723 text=owl_message_get_body(m); 724 header=owl_message_get_attribute_value(m, "adminheader"); 725 726 indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10); 727 owl_text_indent(indent, text, OWL_MSGTAB); 728 owl_fmtext_append_normal(fm, OWL_TABSTR); 729 owl_fmtext_append_bold(fm, "OWL ADMIN "); 730 owl_fmtext_append_ztext(fm, header); 731 owl_fmtext_append_normal(fm, "\n"); 732 owl_fmtext_append_ztext(fm, indent); 733 if (text[strlen(text)-1]!='\n') { 734 owl_fmtext_append_normal(fm, "\n"); 735 } 736 737 owl_free(indent); 738 } 739 }
Note: See TracChangeset
for help on using the changeset viewer.