Changeset bd3f232
- Timestamp:
- Jun 10, 2003, 3:14:59 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:
- f14a7ee
- Parents:
- 6e05655
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
ChangeLog
r6e05655 rbd3f232 1 1 $Id$ 2 2 3 2.0.4-pre-1 4 Make command line option -n actualy work 5 6 'set style' now works. Possbile values at the moment are 7 'default' 'basic' or 'perl', but the last only if a 8 format_msg() function is found in .owlconf 9 3 10 2.0.3 4 11 Don't ring the terminal bell on mail messages. -
Makefile.in
r6a415e9 rbd3f232 23 23 regex.c history.c view.c dict.c variable.c filterelement.c pair.c \ 24 24 keypress.c keymap.c keybinding.c cmd.c context.c zcrypt.c \ 25 aim.c buddylist.c timer.c 25 aim.c buddylist.c timer.c style.c stylefunc.c 26 26 OWL_SRC = owl.c 27 27 TESTER_SRC = tester.c -
buddylist.c
rb2b0773 rbd3f232 1 1 #include "owl.h" 2 3 static const char fileIdent[] = "$Id$"; 2 4 3 5 void owl_buddylist_init(owl_buddylist *b) -
fmtext.c
r6bf73ce rbd3f232 468 468 for (i=0; i<lines; i++) { 469 469 offset=ptr1-in->textbuff; 470 ptr2=strchr(ptr1, '\n'); /* this is a valgrind suspicious line */470 ptr2=strchr(ptr1, '\n'); 471 471 if (!ptr2) { 472 472 _owl_fmtext_append_fmtext(out, in, offset, (in->textlen)-1); … … 578 578 } 579 579 dst->textlen=src->textlen; 580 dst->textbuff=owl_malloc(mallocsize); /* valgrind suspcious line */580 dst->textbuff=owl_malloc(mallocsize); 581 581 dst->fmbuff=owl_malloc(mallocsize); 582 582 dst->colorbuff=owl_malloc(mallocsize); -
global.c
r6a415e9 rbd3f232 52 52 owl_list_create(&(g->puntlist)); 53 53 owl_list_create(&(g->messagequeue)); 54 owl_list_create(&(g->stylelist)); 54 55 g->curmsg_vert_offset=0; 55 56 g->resizepending=0; … … 728 729 } 729 730 731 /* style */ 732 733 /* Return the style with name 'name'. If it does not exist return 734 * NULL */ 735 owl_style *owl_global_get_style_by_name(owl_global *g, char *name) 736 { 737 int i, j; 738 owl_style *s; 739 740 j=owl_list_get_size(&(g->stylelist)); 741 for (i=0; i<j; i++) { 742 s=owl_list_get_element(&(g->stylelist), i); 743 if (owl_style_matches_name(s, name)) { 744 return(s); 745 } 746 } 747 return(NULL); 748 } 749 750 owl_style *owl_global_get_current_style(owl_global *g) { 751 return(owl_global_get_style_by_name(g, owl_global_get_style(g))); 752 } 753 754 void owl_global_add_style(owl_global *g, owl_style *s) { 755 owl_list_append_element(&(g->stylelist), s); 756 } -
message.c
rd559df9 rbd3f232 24 24 strcpy(m->hostname, ""); 25 25 m->zwriteline=strdup(""); 26 m->invalid_format=1; 26 27 27 28 owl_list_create(&(m->attributes)); … … 31 32 m->time=owl_strdup(ctime(&t)); 32 33 m->time[strlen(m->time)-1]='\0'; 34 owl_fmtext_init_null(&(m->fmtext)); 33 35 } 34 36 … … 98 100 } 99 101 102 void owl_message_invalidate_format(owl_message *m) 103 { 104 m->invalid_format=1; 105 } 106 100 107 owl_fmtext *owl_message_get_fmtext(owl_message *m) 101 108 { 109 owl_style *s; 110 111 /* if the format is invalid, regenerate the text based on the 112 * current style 113 */ 114 if (m->invalid_format) { 115 owl_fmtext_free(&(m->fmtext)); 116 owl_fmtext_init_null(&(m->fmtext)); 117 s=owl_global_get_current_style(&g); 118 owl_style_get_formattext(s, &(m->fmtext), m); 119 m->invalid_format=0; 120 } 102 121 return(&(m->fmtext)); 103 122 } … … 371 390 { 372 391 if (m == NULL) return(0); 392 (void) owl_message_get_fmtext(m); 373 393 return(owl_fmtext_num_lines(&(m->fmtext))); 374 394 } … … 417 437 { 418 438 owl_fmtext a, b; 439 440 /* this will ensure that our cached copy is up to date */ 441 (void) owl_message_get_fmtext(m); 419 442 420 443 owl_fmtext_init_null(&a); … … 538 561 return(m->id); 539 562 } 540 563 564 /* return 1 if the message contains "string", 0 otherwise. This is 565 * case insensitive because the functions it uses are 566 */ 541 567 int owl_message_search(owl_message *m, char *string) 542 568 { 543 /* return 1 if the message contains "string", 0 otherwise. This is 544 * case insensitive because the functions it uses are*/545 569 570 (void) owl_message_get_fmtext(m); /* is this necessary? */ 571 546 572 return (owl_fmtext_search(&(m->fmtext), string)); 547 573 } 548 574 549 void owl_message_create(owl_message *m, char *header, char *text)550 {551 char *indent;552 553 owl_message_init(m);554 owl_message_set_body(m, text);555 556 indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10);557 owl_text_indent(indent, text, OWL_MSGTAB);558 owl_fmtext_init_null(&(m->fmtext));559 owl_fmtext_append_normal(&(m->fmtext), OWL_TABSTR);560 owl_fmtext_append_ztext(&(m->fmtext), header);561 owl_fmtext_append_normal(&(m->fmtext), "\n");562 owl_fmtext_append_ztext(&(m->fmtext), indent);563 if (text[strlen(text)-1]!='\n') {564 owl_fmtext_append_normal(&(m->fmtext), "\n");565 }566 567 owl_free(indent);568 }569 575 570 576 /* if loginout == -1 it's a logout message … … 596 602 owl_message_set_islogin(m); 597 603 } 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));629 owl_fmtext_append_bold(&(m->fmtext), "\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));642 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 }649 604 } 650 605 651 606 void owl_message_create_admin(owl_message *m, char *header, char *text) 652 607 { 653 char *indent;654 655 608 owl_message_init(m); 656 609 owl_message_set_type_admin(m); 657 658 610 owl_message_set_body(m, text); 659 660 /* do something to make it clear the notice shouldn't be used for now */ 661 662 indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10); 663 owl_text_indent(indent, text, OWL_MSGTAB); 664 owl_fmtext_init_null(&(m->fmtext)); 665 owl_fmtext_append_normal(&(m->fmtext), OWL_TABSTR); 666 owl_fmtext_append_bold(&(m->fmtext), "OWL ADMIN "); 667 owl_fmtext_append_ztext(&(m->fmtext), header); 668 owl_fmtext_append_normal(&(m->fmtext), "\n"); 669 owl_fmtext_append_ztext(&(m->fmtext), indent); 670 if (text[strlen(text)-1]!='\n') { 671 owl_fmtext_append_normal(&(m->fmtext), "\n"); 672 } 673 674 owl_free(indent); 611 owl_message_set_attribute(m, "adminheader", header); /* just a hack for now */ 675 612 } 676 613 … … 770 707 m->time=owl_strdup(ctime((time_t *) &n->z_time.tv_sec)); 771 708 m->time[strlen(m->time)-1]='\0'; 772 773 /* create the formatted message */774 if (owl_global_is_config_format(&g)) {775 _owl_message_make_text_from_config(m);776 } else if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES)) {777 _owl_message_make_text_from_notice_standard(m);778 } else {779 _owl_message_make_text_from_notice_simple(m);780 }781 782 709 } 783 710 … … 812 739 } 813 740 814 /* create the formatted message */815 if (owl_global_is_config_format(&g)) {816 _owl_message_make_text_from_config(m);817 } else if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES)) {818 _owl_message_make_text_from_zwriteline_standard(m);819 } else {820 _owl_message_make_text_from_zwriteline_simple(m);821 }822 823 741 owl_zwrite_free(&z); 824 742 } 825 743 826 void _owl_message_make_text_from_config(owl_message *m)827 {828 char *body, *indent;829 830 owl_fmtext_init_null(&(m->fmtext));831 832 /* get body from the config */833 body=owl_config_getmsg(m, 1);834 835 /* indent */836 indent=owl_malloc(strlen(body)+owl_text_num_lines(body)*OWL_TAB+10);837 owl_text_indent(indent, body, OWL_TAB);838 839 /* fmtext_append. This needs to change */840 owl_fmtext_append_ztext(&(m->fmtext), indent);841 842 owl_free(indent);843 owl_free(body);844 }845 846 void _owl_message_make_text_from_zwriteline_standard(owl_message *m)847 {848 char *indent, *text, *zsigbuff, *foo;849 850 text=owl_message_get_body(m);851 852 indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10);853 owl_text_indent(indent, text, OWL_MSGTAB);854 owl_fmtext_init_null(&(m->fmtext));855 owl_fmtext_append_normal(&(m->fmtext), OWL_TABSTR);856 owl_fmtext_append_normal(&(m->fmtext), "Zephyr sent to ");857 foo=short_zuser(owl_message_get_recipient(m));858 owl_fmtext_append_normal(&(m->fmtext), foo);859 owl_free(foo);860 owl_fmtext_append_normal(&(m->fmtext), " (Zsig: ");861 862 zsigbuff=owl_malloc(strlen(owl_message_get_zsig(m))+30);863 owl_message_pretty_zsig(m, zsigbuff);864 owl_fmtext_append_ztext(&(m->fmtext), zsigbuff);865 owl_free(zsigbuff);866 867 owl_fmtext_append_normal(&(m->fmtext), ")");868 owl_fmtext_append_normal(&(m->fmtext), "\n");869 owl_fmtext_append_ztext(&(m->fmtext), indent);870 if (text[strlen(text)-1]!='\n') {871 owl_fmtext_append_normal(&(m->fmtext), "\n");872 }873 874 owl_free(indent);875 }876 877 void _owl_message_make_text_from_zwriteline_simple(owl_message *m)878 {879 char *indent, *text, *zsigbuff, *foo;880 881 text=owl_message_get_body(m);882 883 indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10);884 owl_text_indent(indent, text, OWL_MSGTAB);885 owl_fmtext_init_null(&(m->fmtext));886 owl_fmtext_append_normal(&(m->fmtext), OWL_TABSTR);887 owl_fmtext_append_normal(&(m->fmtext), "To: ");888 foo=short_zuser(owl_message_get_recipient(m));889 owl_fmtext_append_normal(&(m->fmtext), foo);890 owl_free(foo);891 owl_fmtext_append_normal(&(m->fmtext), " (Zsig: ");892 893 zsigbuff=owl_malloc(strlen(owl_message_get_zsig(m))+30);894 owl_message_pretty_zsig(m, zsigbuff);895 owl_fmtext_append_ztext(&(m->fmtext), zsigbuff);896 owl_free(zsigbuff);897 898 owl_fmtext_append_normal(&(m->fmtext), ")");899 owl_fmtext_append_normal(&(m->fmtext), "\n");900 owl_fmtext_append_ztext(&(m->fmtext), indent);901 if (text[strlen(text)-1]!='\n') {902 owl_fmtext_append_normal(&(m->fmtext), "\n");903 }904 905 owl_free(indent);906 }907 908 void _owl_message_make_text_from_notice_standard(owl_message *m)909 {910 char *body, *indent, *ptr, *zsigbuff, frombuff[LINE];911 ZNotice_t *n;912 913 n=&(m->notice);914 915 /* get the body */916 body=owl_malloc(strlen(owl_message_get_body(m))+30);917 strcpy(body, owl_message_get_body(m));918 919 /* add a newline if we need to */920 if (body[0]!='\0' && body[strlen(body)-1]!='\n') {921 strcat(body, "\n");922 }923 924 /* do the indenting into indent */925 indent=owl_malloc(strlen(body)+owl_text_num_lines(body)*OWL_MSGTAB+10);926 owl_text_indent(indent, body, OWL_MSGTAB);927 928 /* edit the from addr for printing */929 strcpy(frombuff, owl_message_get_sender(m));930 ptr=strchr(frombuff, '@');931 if (ptr && !strncmp(ptr+1, ZGetRealm(), strlen(ZGetRealm()))) {932 *ptr='\0';933 }934 935 /* set the message for printing */936 owl_fmtext_init_null(&(m->fmtext));937 owl_fmtext_append_normal(&(m->fmtext), OWL_TABSTR);938 939 if (!strcasecmp(owl_message_get_opcode(m), "ping") && owl_message_is_private(m)) {940 owl_fmtext_append_bold(&(m->fmtext), "PING");941 owl_fmtext_append_normal(&(m->fmtext), " from ");942 owl_fmtext_append_bold(&(m->fmtext), frombuff);943 owl_fmtext_append_normal(&(m->fmtext), "\n");944 } else if (!strcasecmp(n->z_class, "login")) {945 char *ptr, host[LINE], tty[LINE];946 int len;947 948 ptr=owl_zephyr_get_field(n, 1, &len);949 strncpy(host, ptr, len);950 host[len]='\0';951 ptr=owl_zephyr_get_field(n, 3, &len);952 strncpy(tty, ptr, len);953 tty[len]='\0';954 955 if (!strcasecmp(n->z_opcode, "user_login")) {956 owl_fmtext_append_bold(&(m->fmtext), "LOGIN");957 } else if (!strcasecmp(n->z_opcode, "user_logout")) {958 owl_fmtext_append_bold(&(m->fmtext), "LOGOUT");959 }960 owl_fmtext_append_normal(&(m->fmtext), " for ");961 ptr=short_zuser(n->z_class_inst);962 owl_fmtext_append_bold(&(m->fmtext), ptr);963 owl_free(ptr);964 owl_fmtext_append_normal(&(m->fmtext), " at ");965 owl_fmtext_append_normal(&(m->fmtext), host);966 owl_fmtext_append_normal(&(m->fmtext), " ");967 owl_fmtext_append_normal(&(m->fmtext), tty);968 owl_fmtext_append_normal(&(m->fmtext), "\n");969 } else {970 owl_fmtext_append_normal(&(m->fmtext), owl_message_get_class(m));971 owl_fmtext_append_normal(&(m->fmtext), " / ");972 owl_fmtext_append_normal(&(m->fmtext), owl_message_get_instance(m));973 owl_fmtext_append_normal(&(m->fmtext), " / ");974 owl_fmtext_append_bold(&(m->fmtext), frombuff);975 if (strcasecmp(owl_message_get_realm(m), ZGetRealm())) {976 owl_fmtext_append_normal(&(m->fmtext), " {");977 owl_fmtext_append_normal(&(m->fmtext), owl_message_get_realm(m));978 owl_fmtext_append_normal(&(m->fmtext), "} ");979 }980 if (n->z_opcode[0]!='\0') {981 owl_fmtext_append_normal(&(m->fmtext), " [");982 owl_fmtext_append_normal(&(m->fmtext), owl_message_get_opcode(m));983 owl_fmtext_append_normal(&(m->fmtext), "] ");984 }985 986 /* stick on the zsig */987 zsigbuff=owl_malloc(strlen(owl_message_get_zsig(m))+30);988 owl_message_pretty_zsig(m, zsigbuff);989 owl_fmtext_append_normal(&(m->fmtext), " (");990 owl_fmtext_append_ztext(&(m->fmtext), zsigbuff);991 owl_fmtext_append_normal(&(m->fmtext), ")");992 owl_fmtext_append_normal(&(m->fmtext), "\n");993 owl_free(zsigbuff);994 995 /* then the indented message */996 owl_fmtext_append_ztext(&(m->fmtext), indent);997 998 /* make private messages bold for smaat users */999 if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES)) {1000 if (owl_message_is_personal(m)) {1001 owl_fmtext_addattr((&m->fmtext), OWL_FMTEXT_ATTR_BOLD);1002 }1003 }1004 }1005 1006 owl_free(body);1007 owl_free(indent);1008 }1009 1010 void _owl_message_make_text_from_notice_simple(owl_message *m)1011 {1012 char *body, *indent, *ptr, *zsigbuff, frombuff[LINE];1013 ZNotice_t *n;1014 1015 n=&(m->notice);1016 1017 /* get the body */1018 body=owl_strdup(owl_message_get_body(m));1019 body=realloc(body, strlen(body)+30);1020 1021 /* add a newline if we need to */1022 if (body[0]!='\0' && body[strlen(body)-1]!='\n') {1023 strcat(body, "\n");1024 }1025 1026 /* do the indenting into indent */1027 indent=owl_malloc(strlen(body)+owl_text_num_lines(body)*OWL_MSGTAB+10);1028 owl_text_indent(indent, body, OWL_MSGTAB);1029 1030 /* edit the from addr for printing */1031 strcpy(frombuff, owl_message_get_sender(m));1032 ptr=strchr(frombuff, '@');1033 if (ptr && !strncmp(ptr+1, ZGetRealm(), strlen(ZGetRealm()))) {1034 *ptr='\0';1035 }1036 1037 /* set the message for printing */1038 owl_fmtext_init_null(&(m->fmtext));1039 owl_fmtext_append_normal(&(m->fmtext), OWL_TABSTR);1040 1041 if (!strcasecmp(owl_message_get_opcode(m), "ping")) {1042 owl_fmtext_append_bold(&(m->fmtext), "PING");1043 owl_fmtext_append_normal(&(m->fmtext), " from ");1044 owl_fmtext_append_bold(&(m->fmtext), frombuff);1045 owl_fmtext_append_normal(&(m->fmtext), "\n");1046 } else if (!strcasecmp(owl_message_get_class(m), "login")) {1047 char *ptr, host[LINE], tty[LINE];1048 int len;1049 1050 ptr=owl_zephyr_get_field(n, 1, &len);1051 strncpy(host, ptr, len);1052 host[len]='\0';1053 ptr=owl_zephyr_get_field(n, 3, &len);1054 strncpy(tty, ptr, len);1055 tty[len]='\0';1056 1057 if (!strcasecmp(owl_message_get_opcode(m), "user_login")) {1058 owl_fmtext_append_bold(&(m->fmtext), "LOGIN");1059 } else if (!strcasecmp(owl_message_get_opcode(m), "user_logout")) {1060 owl_fmtext_append_bold(&(m->fmtext), "LOGOUT");1061 }1062 owl_fmtext_append_normal(&(m->fmtext), " for ");1063 ptr=short_zuser(owl_message_get_instance(m));1064 owl_fmtext_append_bold(&(m->fmtext), ptr);1065 owl_free(ptr);1066 owl_fmtext_append_normal(&(m->fmtext), " at ");1067 owl_fmtext_append_normal(&(m->fmtext), host);1068 owl_fmtext_append_normal(&(m->fmtext), " ");1069 owl_fmtext_append_normal(&(m->fmtext), tty);1070 owl_fmtext_append_normal(&(m->fmtext), "\n");1071 } else {1072 owl_fmtext_append_normal(&(m->fmtext), "From: ");1073 if (strcasecmp(owl_message_get_class(m), "message")) {1074 owl_fmtext_append_normal(&(m->fmtext), "Class ");1075 owl_fmtext_append_normal(&(m->fmtext), owl_message_get_class(m));1076 owl_fmtext_append_normal(&(m->fmtext), " / Instance ");1077 owl_fmtext_append_normal(&(m->fmtext), owl_message_get_instance(m));1078 owl_fmtext_append_normal(&(m->fmtext), " / ");1079 }1080 owl_fmtext_append_normal(&(m->fmtext), frombuff);1081 if (strcasecmp(owl_message_get_realm(m), ZGetRealm())) {1082 owl_fmtext_append_normal(&(m->fmtext), " {");1083 owl_fmtext_append_normal(&(m->fmtext), owl_message_get_realm(m));1084 owl_fmtext_append_normal(&(m->fmtext), "} ");1085 }1086 1087 /* stick on the zsig */1088 zsigbuff=owl_malloc(strlen(owl_message_get_zsig(m))+30);1089 owl_message_pretty_zsig(m, zsigbuff);1090 owl_fmtext_append_normal(&(m->fmtext), " (");1091 owl_fmtext_append_ztext(&(m->fmtext), zsigbuff);1092 owl_fmtext_append_normal(&(m->fmtext), ")");1093 owl_fmtext_append_normal(&(m->fmtext), "\n");1094 owl_free(zsigbuff);1095 1096 /* then the indented message */1097 owl_fmtext_append_ztext(&(m->fmtext), indent);1098 1099 /* make personal messages bold for smaat users */1100 if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES)) {1101 if (owl_message_is_personal(m)) {1102 owl_fmtext_addattr((&m->fmtext), OWL_FMTEXT_ATTR_BOLD);1103 }1104 }1105 }1106 1107 owl_free(body);1108 owl_free(indent);1109 }1110 744 1111 745 void owl_message_pretty_zsig(owl_message *m, char *buff) -
messagelist.c
r1aee7d9 rbd3f232 5 5 static const char fileIdent[] = "$Id$"; 6 6 7 int owl_messagelist_create(owl_messagelist *ml) { 7 int owl_messagelist_create(owl_messagelist *ml) 8 { 8 9 owl_list_create(&(ml->list)); 9 10 return(0); 10 11 } 11 12 12 int owl_messagelist_get_size(owl_messagelist *ml) { 13 int owl_messagelist_get_size(owl_messagelist *ml) 14 { 13 15 return(owl_list_get_size(&(ml->list))); 14 16 } 15 17 16 void *owl_messagelist_get_element(owl_messagelist *ml, int n) { 18 void *owl_messagelist_get_element(owl_messagelist *ml, int n) 19 { 17 20 return(owl_list_get_element(&(ml->list), n)); 18 21 } 19 22 20 owl_message *owl_messagelist_get_by_id(owl_messagelist *ml, int id) { 23 owl_message *owl_messagelist_get_by_id(owl_messagelist *ml, int id) 24 { 21 25 /* return the message with id == 'id'. If it doesn't exist return NULL. */ 22 26 /* we could make this much more efficient at some point */ … … 36 40 } 37 41 38 int owl_messagelist_append_element(owl_messagelist *ml, void *element) { 42 int owl_messagelist_append_element(owl_messagelist *ml, void *element) 43 { 39 44 return(owl_list_append_element(&(ml->list), element)); 40 45 } 41 46 42 47 /* do we really still want this? */ 43 int owl_messagelist_delete_element(owl_messagelist *ml, int n) { 48 int owl_messagelist_delete_element(owl_messagelist *ml, int n) 49 { 44 50 /* mark a message as deleted */ 45 51 owl_message_mark_delete(owl_list_get_element(&(ml->list), n)); … … 47 53 } 48 54 49 int owl_messagelist_undelete_element(owl_messagelist *ml, int n) { 55 int owl_messagelist_undelete_element(owl_messagelist *ml, int n) 56 { 50 57 /* mark a message as deleted */ 51 58 owl_message_unmark_delete(owl_list_get_element(&(ml->list), n)); … … 53 60 } 54 61 55 int owl_messagelist_expunge(owl_messagelist *ml) { 62 int owl_messagelist_expunge(owl_messagelist *ml) 63 { 56 64 /* expunge deleted messages */ 57 65 int i, j; … … 79 87 return(0); 80 88 } 89 90 void owl_messagelist_invalidate_formats(owl_messagelist *ml) 91 { 92 int i, j; 93 owl_message *m; 94 95 j=owl_list_get_size(&(ml->list)); 96 for (i=0; i<j; i++) { 97 m=owl_list_get_element(&(ml->list), i); 98 owl_message_invalidate_format(m); 99 } 100 } -
owl.c
r6bf73ce rbd3f232 37 37 char *configfile, *tty, *perlout, **argvsave, buff[LINE], startupmsg[LINE]; 38 38 owl_filter *f; 39 owl_style *s; 39 40 time_t nexttime, now; 40 41 struct tm *today; … … 46 47 tty=NULL; 47 48 debug=0; 49 initialsubs=1; 48 50 if (argc>0) { 49 51 argv++; … … 128 130 129 131 130 /* owl init */132 /* owl global init */ 131 133 owl_global_init(&g); 132 134 if (debug) owl_global_set_debug_on(&g); … … 145 147 } 146 148 149 /* setup the built-in styles */ 150 s=owl_malloc(sizeof(owl_style)); 151 owl_style_create_internal(s, "default", &owl_stylefunc_default); 152 owl_global_add_style(&g, s); 153 154 s=owl_malloc(sizeof(owl_style)); 155 owl_style_create_internal(s, "basic", &owl_stylefunc_basic); 156 owl_global_add_style(&g, s); 157 147 158 /* setup the default filters */ 148 159 /* the personal filter will need to change again when AIM chat's are 149 160 * included. Also, there should be an %aimme% */ 150 f= malloc(sizeof(owl_filter));161 f=owl_malloc(sizeof(owl_filter)); 151 162 owl_filter_init_fromstring(f, "personal", "( type ^zephyr$ " 152 163 "and class ^message$ and instance ^personal$ " … … 155 166 owl_list_append_element(owl_global_get_filterlist(&g), f); 156 167 157 f= malloc(sizeof(owl_filter));168 f=owl_malloc(sizeof(owl_filter)); 158 169 owl_filter_init_fromstring(f, "trash", "class ^mail$ or opcode ^ping$ or type ^admin$ or class ^login$"); 159 170 owl_list_append_element(owl_global_get_filterlist(&g), f); 160 171 161 f= malloc(sizeof(owl_filter));172 f=owl_malloc(sizeof(owl_filter)); 162 173 owl_filter_init_fromstring(f, "ping", "opcode ^ping$"); 163 174 owl_list_append_element(owl_global_get_filterlist(&g), f); 164 175 165 f= malloc(sizeof(owl_filter));176 f=owl_malloc(sizeof(owl_filter)); 166 177 owl_filter_init_fromstring(f, "auto", "opcode ^auto$"); 167 178 owl_list_append_element(owl_global_get_filterlist(&g), f); 168 179 169 f= malloc(sizeof(owl_filter));180 f=owl_malloc(sizeof(owl_filter)); 170 181 owl_filter_init_fromstring(f, "login", "class ^login$"); 171 182 owl_list_append_element(owl_global_get_filterlist(&g), f); 172 183 173 f= malloc(sizeof(owl_filter));184 f=owl_malloc(sizeof(owl_filter)); 174 185 owl_filter_init_fromstring(f, "reply-lockout", "class ^noc or class ^mail$"); 175 186 owl_list_append_element(owl_global_get_filterlist(&g), f); 176 187 177 f= malloc(sizeof(owl_filter));188 f=owl_malloc(sizeof(owl_filter)); 178 189 owl_filter_init_fromstring(f, "out", "direction ^out$"); 179 190 owl_list_append_element(owl_global_get_filterlist(&g), f); 180 191 181 f= malloc(sizeof(owl_filter));192 f=owl_malloc(sizeof(owl_filter)); 182 193 owl_filter_init_fromstring(f, "aim", "type ^aim$"); 183 194 owl_list_append_element(owl_global_get_filterlist(&g), f); 184 195 185 f= malloc(sizeof(owl_filter));196 f=owl_malloc(sizeof(owl_filter)); 186 197 owl_filter_init_fromstring(f, "zephyr", "type ^zephyr$"); 187 198 owl_list_append_element(owl_global_get_filterlist(&g), f); 188 199 189 f= malloc(sizeof(owl_filter));200 f=owl_malloc(sizeof(owl_filter)); 190 201 owl_filter_init_fromstring(f, "none", "false"); 191 202 owl_list_append_element(owl_global_get_filterlist(&g), f); 192 203 193 f= malloc(sizeof(owl_filter));204 f=owl_malloc(sizeof(owl_filter)); 194 205 owl_filter_init_fromstring(f, "all", "true"); 195 206 owl_list_append_element(owl_global_get_filterlist(&g), f); … … 211 222 printf("\nError parsing configfile\n"); 212 223 exit(1); 224 } 225 226 /* if the config defaults a formatting function, add 'perl' as a style */ 227 if (owl_global_is_config_format(&g)) { 228 owl_function_debugmsg("Found perl formatting"); 229 s=owl_malloc(sizeof(owl_style)); 230 owl_style_create_perl(s, "perl", "owl::format_msg"); 231 owl_global_add_style(&g, s); 213 232 } 214 233 … … 228 247 229 248 /* load zephyr subs */ 230 ret=owl_zephyr_loadsubs(NULL); 231 if (ret!=-1) { 232 owl_global_add_userclue(&g, OWL_USERCLUE_CLASSES); 233 } 234 235 /* load login subs */ 236 if (owl_global_is_loginsubs(&g)) { 237 owl_function_loadloginsubs(NULL); 249 if (initialsubs) { 250 /* load normal subscriptions */ 251 ret=owl_zephyr_loadsubs(NULL); 252 if (ret!=-1) { 253 owl_global_add_userclue(&g, OWL_USERCLUE_CLASSES); 254 } 255 256 /* load login subscriptions */ 257 if (owl_global_is_loginsubs(&g)) { 258 owl_function_loadloginsubs(NULL); 259 } 238 260 } 239 261 … … 241 263 if (owl_global_is_startuplogin(&g)) { 242 264 owl_zephyr_zlog_in(); 265 } 266 267 /* set the default style, based on userclue and presence of a 268 * formatting function */ 269 if (owl_global_is_config_format(&g)) { 270 owl_global_set_style(&g, "perl"); 271 } else if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES)) { 272 owl_global_set_style(&g, "default"); 273 } else { 274 owl_global_set_style(&g, "basic"); 243 275 } 244 276 … … 275 307 276 308 followlast=owl_global_should_followlast(&g); 277 278 309 279 310 /* If we're logged into AIM, do AIM stuff */ … … 306 337 owl_message *m; 307 338 owl_filter *f; 308 339 340 /* grab the new message, stick it in 'm' */ 309 341 if (ZPending()) { 310 342 /* grab a zephyr notice, but if we've done 20 without stopping, … … 332 364 } 333 365 334 /* if it's on the puntlist then, nuke it and continue */366 /* if this message it on the puntlist, nuke it and continue */ 335 367 if (owl_global_message_is_puntable(&g, m)) { 336 368 owl_message_free(m); … … 343 375 344 376 /* let the config know the new message has been received */ 345 owl_config_getmsg(m, 0);377 owl_config_getmsg(m, "owl::receive_msg();"); 346 378 347 379 /* add it to any necessary views; right now there's only the current view */ … … 432 464 } 433 465 434 /* Handle all keypresses. 435 * If no key has been pressed sleep for a little bit, but 436 * otherwise do not, this lets input be grabbed as quickly 437 * as possbile */ 466 /* Handle all keypresses. If no key has been pressed, sleep for a 467 * little bit, but otherwise do not. This lets input be grabbed 468 * as quickly as possbile */ 438 469 j=wgetch(typwin); 439 470 if (j==ERR) { … … 471 502 void sig_handler(int sig) { 472 503 if (sig==SIGWINCH) { 473 /* we can't inturrupt a malloc here, so it just sets a flag */ 504 /* we can't inturrupt a malloc here, so it just sets a flag 505 * schedulding a resize for later 506 */ 474 507 owl_function_resize(); 475 508 } -
owl.h
r6e05655 rbd3f232 14 14 static const char owl_h_fileIdent[] = "$Id$"; 15 15 16 #define OWL_VERSION 2.0. 317 #define OWL_VERSION_STRING "2.0. 3"16 #define OWL_VERSION 2.0.4-pre-1 17 #define OWL_VERSION_STRING "2.0.4-pre-1" 18 18 19 19 #define OWL_DEBUG 0 20 20 #define OWL_DEBUG_FILE "/var/tmp/owldebug" 21 21 22 #define OWL_CONFIG_DIR "/.owl" /* this is relative to the user's home directory */22 #define OWL_CONFIG_DIR "/.owl" /* this is relative to the user's home directory */ 23 23 #define OWL_STARTUP_FILE "/.owl/startup" /* this is relative to the user's home directory */ 24 24 … … 64 64 #define OWL_SCROLLMODE_PAGED 4 65 65 #define OWL_SCROLLMODE_PAGEDCENTER 5 66 67 #define OWL_STYLE_TYPE_INTERNAL 0 68 #define OWL_STYLE_TYPE_PERL 1 66 69 67 70 #define OWL_TAB 3 /* This *HAS* to be the size of TABSTR below */ … … 245 248 int direction; 246 249 ZNotice_t notice; 247 owl_fmtext fmtext; 250 owl_fmtext fmtext; /* this is now only a CACHED copy */ 251 int invalid_format; /* indicates whether fmtext needs to be regenerated */ 248 252 int delete; 249 253 char hostname[MAXHOSTNAMELEN+1]; … … 252 256 char *zwriteline; 253 257 } owl_message; 258 259 typedef struct _owl_style { 260 char *name; 261 int type; 262 char *perlfuncname; 263 void (*formatfunc) (owl_fmtext *fm, owl_message *m); 264 } owl_style; 254 265 255 266 typedef struct _owl_mainwin { … … 415 426 owl_timer aim_noop_timer; 416 427 owl_timer aim_ignorelogin_timer; 417 int aim_loggedin; 418 char *aim_screenname; 419 owl_buddylist buddylist; 420 owl_list messagequeue; /* for queueing up aim and other messages */ 428 int aim_loggedin; /* true if currently logged into AIM */ 429 char *aim_screenname; /* currently logged in AIM screen name */ 430 owl_buddylist buddylist; /* list of logged in AIM buddies */ 431 owl_list messagequeue; /* for queueing up aim and other messages */ 432 owl_list stylelist; /* global list of available styles */ 421 433 } owl_global; 422 434 -
readconfig.c
rd559df9 rbd3f232 131 131 } 132 132 133 char *owl_config_getmsg(owl_message *m, int mode) { 134 /* if mode==1 we are doing message formatting. The returned 135 * formatted message needs to be freed by the caller. 136 * 137 * if mode==0 we are just doing the message-has-been-received 138 * thing. 139 */ 140 133 char *owl_config_getmsg(owl_message *m, char *funcname) { 141 134 int i, j, len; 142 135 char *ptr, *ptr2; 136 char runstr[LINE]; 143 137 144 138 if (!owl_global_have_config(&g)) return(""); … … 236 230 237 231 /* run the procedure corresponding to the mode */ 238 if (mode==1) { 239 return(owl_config_execute("owl::format_msg();")); 240 } else { 241 ptr=owl_config_execute("owl::receive_msg();"); 242 if (ptr) owl_free(ptr); 243 return(NULL); 244 } 245 } 246 232 sprintf(runstr, "%s();", funcname); 233 return(owl_config_execute(runstr)); 234 } 235 -
variable.c
r6a415e9 rbd3f232 198 198 OWLVAR_STRING_FULL( "tty" /* %OwlVarStub */, "", "tty name for zephyr location", "", 199 199 NULL, owl_variable_tty_set, NULL), 200 200 201 OWLVAR_STRING_FULL( "style" /* %OwlVarStub */, "default", "name of the current formatting style", "", 202 NULL, owl_variable_style_set, NULL), 203 201 204 OWLVAR_INT( "edit:maxfillcols" /* %OwlVarStub:edit_maxfillcols */, 70, 202 205 "maximum number of columns for M-q to fill text to", … … 347 350 ZInitLocationInfo(owl_global_get_hostname(&g), newval); 348 351 return(owl_variable_string_set_default(v, newval)); 352 } 353 354 int owl_variable_style_set(owl_variable *v, void *newval) { 355 /* Invalidate all message formats first */ 356 int ret; 357 owl_style *s; 358 359 s=owl_global_get_style_by_name(&g, newval); 360 if (!s) { 361 /* this message won't get seen, we'll need to deal with that later */ 362 owl_function_makemsg("No style named '%s' exists.", newval); 363 return(0); 364 } 365 366 owl_messagelist_invalidate_formats(owl_global_get_msglist(&g)); 367 ret=owl_variable_string_set_default(v, newval); 368 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 369 return(ret); 349 370 } 350 371
Note: See TracChangeset
for help on using the changeset viewer.