Changeset 3e9485d
- Timestamp:
- Nov 2, 2008, 3:06:37 PM (16 years ago)
- Children:
- e729e3b
- Parents:
- f8d0bc0 (diff), 43a306c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Files:
-
- 13 added
- 2 deleted
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
.gitignore
r10e0ab8 r3e9485d 1 1 *~ 2 *.a 3 autom4te.cache 4 barnowl 5 blib 6 config.cache 7 config.h 8 config.log 9 config.status 10 configure 11 core 12 jabber.log 2 13 libfaim/rxhandlers.c.orig 14 Makefile 15 META.yml 16 *.o 17 owl_prototypes.h 18 owl_prototypes.h.new 19 *.par 20 perlglue.c 21 perlwrap.c 22 pm_to_blib 23 TAGS 24 tester 25 varstubs.c -
ChangeLog
rd7a3188 r43a306c 1 $Id$ 1 1.0.3 2 * Moved BarnOwl source control to git on github. 3 * Only call the zsig proc when we actually send a message. -asedeno 4 * Strip out BOMs from Jabber messages. -asedeno 5 * Fix logging of personal jabbers from JIDs containing / -nelhage 6 * Fix Jabber breakage under reload-modules. -asedeno 7 * Make reload-moduled correctly re-run startup hooks. -asedeno 8 * Squelch Jabbers with no bodies, such as typing notifications. -asedeno 9 * Various small spelling and grammar fixes. -geofft 10 * Fix a segfault when sending short zcrypted messages. -asedeno 11 12 1.0.2.1 13 * Fix :reload-module's interactions with PAR modules 14 15 1.0.2 16 * Fix a segfault on retrieving zephyr subs when the user doesn't 17 have any or has expired tickets. -asedeno 18 * Don't complain about non-existant ~/.owl/startup when starting. -asedeno 19 * Fix narrowing to personals in IRC. -alexmv 20 * Don't segfault retrieving subscriptions without valid tickets. -asedeno 21 * Load modules even if .owlconf doesn't run successfully. -nelhage 22 * Update the manpage for barnowl. -nelhage 23 * Better support for irc-names, irc-topic, and irc-whois. -geofft 24 * Display /quit messages in IRC -geofft. 25 * Add a new perl hook for all new messages. -geofft 26 * Fix a bug causing corrupted input in the editwin on end-of-line. -nelhage 27 * Add better support for adding hooks in perl that behave correctly 28 on module reload. -nelhage 29 * Added a :reload-module command to reload a single module. -nelhage 30 * Fixed quoting issues replying to jabber users or MUCs containing 31 whitespace or quites. -nelhage 2 32 3 33 1.0.1 -
Makefile.in
r8363d50 r3e9485d 11 11 CC=@CC@ 12 12 LIBS=@LIBS@ -L./libfaim -lfaim 13 CFLAGS=@CFLAGS@ -I. -I./libfaim -DDATADIR=\"${datadir}\" -DOWL_SVN_REVNO=$(shell ./svkversion)13 CFLAGS=@CFLAGS@ -I./libfaim -DDATADIR=\"${datadir}\" 14 14 LDFLAGS=@LDFLAGS@ 15 15 XSUBPPDIR=@XSUBPPDIR@ … … 129 129 install: all installdirs 130 130 ${INSTALL_PROGRAM} $(EXE) ${DESTDIR}${bindir}/$(EXE) 131 ${INSTALL_DATA} doc/ owl.1 ${DESTDIR}${mandir}/man1/barnowl.1131 ${INSTALL_DATA} doc/barnowl.1 ${DESTDIR}${mandir}/man1/barnowl.1 132 132 ${INSTALL} -d ${DESTDIR}${datadir}/lib 133 133 ${INSTALL} -d ${DESTDIR}${datadir}/modules -
cmd.c
r34509d5 rc4ba74d 67 67 } 68 68 69 char *_owl_cmddict_execute(owl_cmddict *cd, owl_context *ctx, char **argv, int argc, char *buff) { 70 char *retval = NULL; 71 owl_cmd *cmd; 72 73 if (!strcmp(argv[0], "")) { 74 } else if (NULL != (cmd = (owl_cmd*)owl_dict_find_element(cd, argv[0]))) { 75 retval = owl_cmd_execute(cmd, cd, ctx, argc, argv, buff); 76 } else { 77 owl_function_makemsg("Unknown command '%s'.", buff); 78 } 79 return retval; 80 } 81 69 82 char *owl_cmddict_execute(owl_cmddict *cd, owl_context *ctx, char *cmdbuff) { 70 83 char **argv; … … 72 85 char *tmpbuff; 73 86 char *retval = NULL; 74 owl_cmd *cmd;75 87 76 88 tmpbuff=owl_strdup(cmdbuff); … … 85 97 if (argc < 1) return(NULL); 86 98 87 if (!strcmp(argv[0], "")) { 88 } else if (NULL != (cmd = (owl_cmd*)owl_dict_find_element(cd, argv[0]))) { 89 retval = owl_cmd_execute(cmd, cd, ctx, argc, argv, cmdbuff); 90 } else { 91 owl_function_makemsg("Unknown command '%s'.", cmdbuff); 92 } 99 retval = _owl_cmddict_execute(cd, ctx, argv, argc, cmdbuff); 100 93 101 owl_parsefree(argv, argc); 94 102 owl_free(tmpbuff); 95 103 sepbar(NULL); 104 return retval; 105 } 106 107 char *owl_cmddict_execute_argv(owl_cmddict *cd, owl_context *ctx, char **argv, int argc) { 108 char *buff, *ptr; 109 int len = 0, i; 110 char *retval = NULL; 111 112 for(i = 0; i < argc; i++) { 113 len += strlen(argv[i]) + 1; 114 } 115 116 ptr = buff = owl_malloc(len); 117 118 for(i = 0; i < argc; i++) { 119 strcpy(ptr, argv[i]); 120 ptr += strlen(argv[i]); 121 *(ptr++) = ' '; 122 } 123 *(ptr - 1) = 0; 124 125 retval = _owl_cmddict_execute(cd, ctx, argv, argc, buff); 126 127 owl_free(buff); 96 128 return retval; 97 129 } -
commands.c
r864ed35 r451db9e 51 51 "when owl is started and a logout notification is sent when owl\n" 52 52 "is exited. This behavior can be changed with the 'startuplogin'\n" 53 "and 'shu downlogout' variables. If a tty is specified for zlog in\n"53 "and 'shutdownlogout' variables. If a tty is specified for zlog in\n" 54 54 "then the owl variable 'tty' will be set to that string, causing\n" 55 55 "it to be used as the zephyr location tty.\n"), … … 193 193 OWLCMD_ARGS("subscribe", owl_command_subscribe, OWL_CTX_ANY, 194 194 "subscribe to a zephyr class, instance, recipient", 195 "subscribe [-t] <class> <instance> [recipient]", 196 "Subscribe the specified class and instance. If the recipient\n" 197 "is not listed on the command line it defaults\n" 198 "to * (the wildcard recipient). If the -t option is present\n" 199 "the subscription will only be temporary, i.e., it will not\n" 200 "be written to the subscription file and will therefore not\n" 201 "be present the next time owl is started.\n"), 195 "subscribe [-t] <class> [instance [recipient]]", 196 "Subscribe to the specified class and instance. If the\n" 197 "instance or recipient is not listed on the command\n" 198 "line they default to * (the wildcard recipient).\n" 199 "If the -t option is present the subscription will\n" 200 "only be temporary, i.e., it will not be written to\n" 201 "the subscription file and will therefore not be\n" 202 "present the next time owl is started.\n"), 202 203 OWLCMD_ALIAS("sub", "subscribe"), 203 204 204 205 OWLCMD_ARGS("unsubscribe", owl_command_unsubscribe, OWL_CTX_ANY, 205 206 "unsubscribe from a zephyr class, instance, recipient", 206 "unsubscribe [-t] <class> <instance> [recipient]",207 "unsubscribe [-t] <class> [instance [recipient]]", 207 208 "Unsubscribe from the specified class and instance. If the\n" 208 "recipient is not listed on the command line it defaults\n" 209 "to * (the wildcard recipient). If the -t option is present\n" 210 "the unsubscription will only be temporary, i.e., it will not\n" 211 "be updated in the subscription file and will therefore not\n" 212 "be in effect the next time owl is started.\n"), 209 "instance or recipient is not listed on the command\n" 210 "line they default to * (the wildcard recipient).\n" 211 "If the -t option is present the unsubscription will\n" 212 "only be temporary, i.e., it will not be updated in\n" 213 "the subscription file and will therefore not be\n" 214 "in effect the next time owl is started.\n"), 213 215 OWLCMD_ALIAS("unsub", "unsubscribe"), 214 216 … … 245 247 "delete a buddy from a buddylist", 246 248 "delbuddy <protocol> <screenname>", 247 "Delete the named buddy to your buddylist. <protocol<can be aim or zephyr\n"),249 "Delete the named buddy from your buddylist. <protocol> can be aim or zephyr\n"), 248 250 249 251 OWLCMD_ARGS("join", owl_command_join, OWL_CTX_INTERACTIVE, … … 263 265 "zpunt <instance>", 264 266 "The zpunt command will supress message to the specified\n" 265 "zephyr triplet. In the second usage messages a s supressed\n"267 "zephyr triplet. In the second usage messages are suppressed\n" 266 268 "for class MESSAGE and the named instance.\n\n" 267 269 "SEE ALSO: zunpunt, show zpunts\n"), … … 271 273 "zunpunt <class> <instance> [recipient]\n" 272 274 "zunpunt <instance>", 273 "The zunpunt command will allow messages that were previo sly\n"275 "The zunpunt command will allow messages that were previously\n" 274 276 "suppressed to be received again.\n\n" 275 277 "SEE ALSO: zpunt, show zpunts\n"), … … 545 547 " true\n" 546 548 " false\n" 547 "Spaces must be present before and after parenthes is. If the\n"549 "Spaces must be present before and after parentheses. If the\n" 548 550 "optional color arguments are used they specifies the colors that\n" 549 551 "messages matching this filter should be displayed in.\n\n" … … 592 594 "If the curmsg is a personal message narrow\n" 593 595 " to the conversation with that user.\n" 594 "If the curmsg is a class message, instance foo, recip *\n"595 " message, narrow to the class, inst.\n"596 "If the curmsg is a class message thennarrow\n"596 "If the curmsg is a <MESSAGE, foo, *>\n" 597 " message, narrow to the instance.\n" 598 "If the curmsg is a class message, narrow\n" 597 599 " to the class.\n" 598 "If the curmsg is a class message and '-i' is speci ed\n"599 " then narrow to the class , instance\n"),600 "If the curmsg is a class message and '-i' is specified\n" 601 " then narrow to the class and instance.\n"), 600 602 601 603 OWLCMD_ARGS("smartfilter", owl_command_smartfilter, OWL_CTX_INTERACTIVE, … … 604 606 "If the curmsg is a personal message, the filter is\n" 605 607 " the conversation with that user.\n" 606 "If the curmsg is a class message, instance foo, recip *\n"607 " message, the filter is t he class, inst.\n"608 "If the curmsg is a <MESSAGE, foo, *>\n" 609 " message, the filter is to that instance.\n" 608 610 "If the curmsg is a class message, the filter is that class.\n" 609 611 "If the curmsg is a class message and '-i' is specied\n" 610 " the filter is t hat <class,instance> pair\n"),612 " the filter is to that class and instance.\n"), 611 613 612 614 OWLCMD_ARGS("viewclass", owl_command_viewclass, OWL_CTX_INTERACTIVE, … … 674 676 "If no message id is specified the current message is marked\n" 675 677 "for deletion. Otherwise the message with the given message\n" 676 "id is marked for del tion.\n"678 "id is marked for deletion.\n" 677 679 "If '--no-move' is specified, don't move after deletion.\n" 678 680 "If 'trash' is specified, deletes all trash/auto messages\n" … … 688 690 "If no message id is specified the current message is\n" 689 691 "unmarked for deletion. Otherwise the message with the\n" 690 "given message id is marked for undeltion.\n"692 "given message id is unmarked for deletion.\n" 691 693 "If '--no-move' is specified, don't move after deletion.\n" 692 694 "If 'view' is specified, undeletes all messages\n" … … 713 715 "getvar <varname>", ""), 714 716 717 OWLCMD_ARGS("getfilter", owl_command_getfilter, OWL_CTX_INTERACTIVE, 718 "returns the definition of a filter", 719 "getfilter <filtername>", ""), 720 715 721 OWLCMD_ARGS("getstyle", owl_command_getstyle, OWL_CTX_INTERACTIVE, 716 722 "returns the name of the style for the current view", … … 723 729 "specified string and move the cursor there. If no string\n" 724 730 "argument is supplied then the previous one is used. By\n" 725 "default searches are done fo wards,if -r is used the search\n"731 "default searches are done forwards; if -r is used the search\n" 726 732 "is performed backwards"), 727 733 … … 732 738 "argument and makes it the default argument for future\n" 733 739 "search commands, but does not move the cursor. With\n" 734 "no argument, it makes search inactive."),740 "no argument, it makes search highlighting inactive."), 735 741 736 742 OWLCMD_ARGS("aimlogin", owl_command_aimlogin, OWL_CTX_ANY, … … 750 756 751 757 OWLCMD_ARGS("message", owl_command_message, OWL_CTX_ANY, 752 "Display an informat ative message",758 "Display an informative message", 753 759 "message <message>", 754 760 ""), … … 1739 1745 char *owl_command_subscribe(int argc, char **argv, char *buff) 1740 1746 { 1741 char * recip="";1747 char *class, *instance, *recip=""; 1742 1748 int temp=0; 1743 1749 int ret=0; 1744 1745 if (argc <3) {1750 1751 if (argc < 2) { 1746 1752 owl_function_makemsg("Not enough arguments to the subscribe command"); 1747 1753 return(NULL); … … 1755 1761 argv++; 1756 1762 } 1757 if (argc <2) {1763 if (argc < 1) { 1758 1764 owl_function_makemsg("Not enough arguments to the subscribe command"); 1759 1765 return(NULL); 1760 1766 } 1761 1767 1762 if (argc >3) {1768 if (argc > 3) { 1763 1769 owl_function_makemsg("Too many arguments to the subscribe command"); 1764 1770 return(NULL); 1765 1771 } 1766 1772 1767 if (argc==2) { 1773 class = argv[0]; 1774 1775 if (argc == 1) { 1776 instance = "*"; 1777 } else { 1778 instance = argv[1]; 1779 } 1780 1781 if (argc <= 2) { 1768 1782 recip=""; 1769 1783 } else if (argc==3) { … … 1771 1785 } 1772 1786 1773 ret = owl_function_subscribe( argv[0], argv[1], recip);1787 ret = owl_function_subscribe(class, instance, recip); 1774 1788 if (!temp && !ret) { 1775 owl_zephyr_addsub(NULL, argv[0], argv[1], recip);1789 owl_zephyr_addsub(NULL, class, instance, recip); 1776 1790 } 1777 1791 return(NULL); … … 1781 1795 char *owl_command_unsubscribe(int argc, char **argv, char *buff) 1782 1796 { 1783 char * recip="";1797 char *class, *instance, *recip=""; 1784 1798 int temp=0; 1785 1799 1786 if (argc <3) {1800 if (argc < 2) { 1787 1801 owl_function_makemsg("Not enough arguments to the unsubscribe command"); 1788 1802 return(NULL); … … 1796 1810 argv++; 1797 1811 } 1798 if (argc <2) {1799 owl_function_makemsg("Not enough arguments to the subscribe command");1800 return(NULL); 1801 } 1802 1803 if (argc >3) {1812 if (argc < 1) { 1813 owl_function_makemsg("Not enough arguments to the unsubscribe command"); 1814 return(NULL); 1815 } 1816 1817 if (argc > 3) { 1804 1818 owl_function_makemsg("Too many arguments to the unsubscribe command"); 1805 1819 return(NULL); 1806 1820 } 1807 1821 1808 if (argc==2) { 1822 class = argv[0]; 1823 1824 if (argc == 1) { 1825 instance = "*"; 1826 } else { 1827 instance = argv[1]; 1828 } 1829 1830 if (argc <= 2) { 1809 1831 recip=""; 1810 1832 } else if (argc==3) { … … 1812 1834 } 1813 1835 1814 owl_function_unsubscribe( argv[0], argv[1], recip);1836 owl_function_unsubscribe(class, instance, recip); 1815 1837 if (!temp) { 1816 owl_zephyr_delsub(NULL, argv[0], argv[1], recip);1838 owl_zephyr_delsub(NULL, class, instance, recip); 1817 1839 } 1818 1840 return(NULL); … … 2461 2483 } 2462 2484 2485 char *owl_command_getfilter(int argc, char **argv, char *buf) 2486 { 2487 owl_filter *f; 2488 if (argc != 2) { 2489 owl_function_makemsg("Wrong number of arguments for %s", argv[0]); 2490 return NULL; 2491 } 2492 f = owl_global_get_filter(&g, argv[1]); 2493 if (!f) { 2494 return NULL; 2495 } 2496 return owl_filter_print(f); 2497 } 2498 2463 2499 char *owl_command_search(int argc, char **argv, char *buff) 2464 2500 { … … 2580 2616 cmd = owl_message_get_attribute_value(m, "yescommand"); 2581 2617 if(!cmd) { 2582 owl_function_error("No yescommand!");2618 owl_function_error("No 'yes' command!"); 2583 2619 return; 2584 2620 } … … 2614 2650 cmd = owl_message_get_attribute_value(m, "nocommand"); 2615 2651 if(!cmd) { 2616 owl_function_error("No nocommand!");2652 owl_function_error("No 'no' command!"); 2617 2653 return; 2618 2654 } -
editwin.c
r2d4ff14 re9bb404 330 330 { 331 331 int i, z; 332 332 333 333 if ((e->bufflen + n) > (e->allocated - 5)) { 334 334 _owl_editwin_addspace(e); 335 335 } 336 336 337 z = _owl_editwin_get_index_from_xy(e); 338 339 if(z != e->bufflen) { 340 for (i = e->bufflen + n - 1; i > z; i--) { 341 e->buff[i] = e->buff[i - n]; 342 } 343 } 344 337 345 e->bufflen += n; 338 346 e->buff[e->bufflen] = '\0'; 339 340 z = _owl_editwin_get_index_from_xy(e); 341 for (i = e->bufflen - 1; i > z; i--) { 342 e->buff[i] = e->buff[i - n]; 343 } 347 344 348 } 345 349 … … 426 430 427 431 /* shift all the other characters right */ 428 if (z != e->bufflen) { 429 _owl_editwin_insert_bytes(e, len); 430 } 432 _owl_editwin_insert_bytes(e, len); 431 433 432 434 /* insert the new character */ … … 435 437 } 436 438 437 /* housekeeping */438 e->bufflen += len;439 e->buff[e->bufflen] = '\0';440 441 439 /* advance the cursor */ 442 440 z += len; -
filter.c
raf1920fd rcdc6ff1 29 29 while ( argc>=2 && ( !strcmp(argv[0], "-c") || 30 30 !strcmp(argv[0], "-b") ) ) { 31 if (owl_util_string_to_color(argv[1])== -1) {31 if (owl_util_string_to_color(argv[1])==OWL_COLOR_INVALID) { 32 32 owl_function_error("The color '%s' is not available, using default.", argv[1]); 33 33 } else { … … 212 212 213 213 214 void owl_filter_print(owl_filter *f, char *out) 215 { 216 strcpy(out, owl_filter_get_name(f)); 217 strcat(out, ": "); 214 char* owl_filter_print(owl_filter *f) 215 { 216 GString *out = g_string_new(""); 218 217 219 218 if (f->fgcolor!=OWL_COLOR_DEFAULT) { 220 strcat(out, "-c ");219 g_string_append(out, "-c "); 221 220 if (f->fgcolor < 8) { 222 strcat(out, owl_util_color_to_string(f->fgcolor));221 g_string_append(out, owl_util_color_to_string(f->fgcolor)); 223 222 } 224 223 else { 225 char* c = owl_sprintf("%i",f->fgcolor); 226 strcat(out, c); 227 owl_free(c); 228 } 229 strcat(out, " "); 224 g_string_append_printf(out, "%i",f->fgcolor); 225 } 226 g_string_append(out, " "); 230 227 } 231 228 if (f->bgcolor!=OWL_COLOR_DEFAULT) { 232 strcat(out, "-b ");229 g_string_append(out, "-b "); 233 230 if (f->bgcolor < 8) { 234 strcat(out, owl_util_color_to_string(f->bgcolor));231 g_string_append(out, owl_util_color_to_string(f->bgcolor)); 235 232 } 236 233 else { 237 char* c = owl_sprintf("%i",f->bgcolor); 238 strcat(out, c); 239 owl_free(c); 240 } 241 strcat(out, " "); 242 } 243 if(!f->root) return; 244 owl_filterelement_print(f->root, out); 245 strcat(out, "\n"); 234 g_string_append_printf(out, "%i",f->fgcolor); 235 } 236 g_string_append(out, " "); 237 } 238 if(f->root) { 239 owl_filterelement_print(f->root, out); 240 g_string_append(out, "\n"); 241 } 242 243 return g_string_free(out, 0); 246 244 } 247 245 … … 249 247 int owl_filter_equiv(owl_filter *a, owl_filter *b) 250 248 { 251 char buff[LINE], buff2[LINE]; 252 253 owl_filter_print(a, buff); 254 owl_filter_print(b, buff2); 255 256 if (!strcmp(buff, buff2)) return(1); 257 return(0); 249 char *buffa, *buffb; 250 int ret; 251 252 buffa = owl_filter_print(a); 253 buffb = owl_filter_print(b); 254 255 ret = !strcmp(buffa, buffb); 256 ret = ret && !strcmp(owl_filter_get_name(a), 257 owl_filter_get_name(b)); 258 259 owl_free(buffa); 260 owl_free(buffb); 261 262 return ret; 258 263 } 259 264 -
filterelement.c
r81655f8 r0504f63 126 126 /* Print methods */ 127 127 128 static void owl_filterelement_print_true(owl_filterelement *fe, char*buf)129 { 130 strcat(buf, "true");131 } 132 133 static void owl_filterelement_print_false(owl_filterelement *fe, char*buf)134 { 135 strcat(buf, "false");136 } 137 138 static void owl_filterelement_print_re(owl_filterelement *fe, char*buf)128 static void owl_filterelement_print_true(owl_filterelement *fe, GString *buf) 129 { 130 g_string_append(buf, "true"); 131 } 132 133 static void owl_filterelement_print_false(owl_filterelement *fe, GString *buf) 134 { 135 g_string_append(buf, "false"); 136 } 137 138 static void owl_filterelement_print_re(owl_filterelement *fe, GString *buf) 139 139 { 140 140 char *re, *q; 141 strcat(buf, fe->field);142 strcat(buf, " ");141 g_string_append(buf, fe->field); 142 g_string_append(buf, " "); 143 143 144 144 re = owl_regex_get_string(&(fe->re)); 145 145 q = owl_getquoting(re); 146 strcat(buf, q);147 strcat(buf, re);148 strcat(buf, q);149 } 150 151 static void owl_filterelement_print_filter(owl_filterelement *fe, char*buf)152 { 153 strcat(buf, "filter ");154 strcat(buf, fe->field);155 } 156 157 static void owl_filterelement_print_perl(owl_filterelement *fe, char*buf)158 { 159 strcat(buf, "perl ");160 strcat(buf, fe->field);161 } 162 163 static void owl_filterelement_print_group(owl_filterelement *fe, char*buf)164 { 165 strcat(buf, "( ");146 g_string_append(buf, q); 147 g_string_append(buf, re); 148 g_string_append(buf, q); 149 } 150 151 static void owl_filterelement_print_filter(owl_filterelement *fe, GString *buf) 152 { 153 g_string_append(buf, "filter "); 154 g_string_append(buf, fe->field); 155 } 156 157 static void owl_filterelement_print_perl(owl_filterelement *fe, GString *buf) 158 { 159 g_string_append(buf, "perl "); 160 g_string_append(buf, fe->field); 161 } 162 163 static void owl_filterelement_print_group(owl_filterelement *fe, GString *buf) 164 { 165 g_string_append(buf, "( "); 166 166 owl_filterelement_print(fe->left, buf) ; 167 strcat(buf, " )");168 } 169 170 static void owl_filterelement_print_or(owl_filterelement *fe, char*buf)167 g_string_append(buf, " )"); 168 } 169 170 static void owl_filterelement_print_or(owl_filterelement *fe, GString *buf) 171 171 { 172 172 owl_filterelement_print(fe->left, buf); 173 strcat(buf, " or ");173 g_string_append(buf, " or "); 174 174 owl_filterelement_print(fe->right, buf); 175 175 } 176 176 177 static void owl_filterelement_print_and(owl_filterelement *fe, char*buf)177 static void owl_filterelement_print_and(owl_filterelement *fe, GString *buf) 178 178 { 179 179 owl_filterelement_print(fe->left, buf); 180 strcat(buf, " and ");180 g_string_append(buf, " and "); 181 181 owl_filterelement_print(fe->right, buf); 182 182 } 183 183 184 static void owl_filterelement_print_not(owl_filterelement *fe, char*buf)185 { 186 strcat(buf, " not ");184 static void owl_filterelement_print_not(owl_filterelement *fe, GString *buf) 185 { 186 g_string_append(buf, " not "); 187 187 owl_filterelement_print(fe->left, buf); 188 188 } … … 321 321 } 322 322 323 void owl_filterelement_print(owl_filterelement *fe, char*buf)323 void owl_filterelement_print(owl_filterelement *fe, GString *buf) 324 324 { 325 325 if(!fe || !fe->print_elt) return; -
functions.c
r4367915 r3f3ee61 25 25 return owl_cmddict_execute(owl_global_get_cmddict(&g), 26 26 owl_global_get_context(&g), cmdbuff); 27 } 28 29 char *owl_function_command_argv(char **argv, int argc) 30 { 31 return owl_cmddict_execute_argv(owl_global_get_cmddict(&g), 32 owl_global_get_context(&g), 33 argv, argc); 27 34 } 28 35 … … 283 290 owl_editwin_set_dotsend(e); 284 291 strcpy(buff, "----> "); 285 str cat(buff, line);292 strncat(buff, line, 1016); 286 293 strcat(buff, "\n"); 287 294 owl_editwin_set_locktext(e, buff); … … 371 378 /* create the zwrite and send the message */ 372 379 owl_zwrite_create_from_line(&z, line); 380 owl_zwrite_populate_zsig(&z); 373 381 if (msg) { 374 382 owl_zwrite_set_message(&z, msg); … … 409 417 /* create the zwrite and send the message */ 410 418 owl_zwrite_create_from_line(&z, line); 419 owl_zwrite_populate_zsig(&z); 411 420 if (msg) { 412 421 owl_zwrite_set_message(&z, msg); … … 415 424 mymsg=owl_zwrite_get_message(&z); 416 425 #ifdef OWL_ENABLE_ZCRYPT 417 cryptmsg=owl_malloc(strlen(mymsg)*4); 426 /* Allocate enough space for the crypted message. For each byte of 427 * the message, the encoded cyphertext will have two bytes. Block 428 * size is 8 bytes of input, or 16 bytes of output, so make sure we 429 * have at least one block worth of space allocated. If the message 430 * is empty, no blocks are sent, but we still allocate one 431 * block. The additional 16 bytes also provide space for the null 432 * terminator, as we will never use all of it for cyphertext. 433 */ 434 cryptmsg=owl_malloc((strlen(mymsg)*2)+16); 418 435 ret=owl_zcrypt_encrypt(cryptmsg, mymsg, owl_zwrite_get_class(&z), owl_zwrite_get_instance(&z)); 419 436 if (ret) { … … 421 438 owl_function_beep(); 422 439 owl_free(cryptmsg); 440 owl_zwrite_free(&z); 423 441 return; 424 442 } … … 1633 1651 } 1634 1652 1635 if (owl_message_is_type_aim(m)) {1636 owl_fmtext_append_bold(&fm, "\nAIM Specific Information:\n");1637 }1638 1639 1653 owl_fmtext_append_bold(&fm, "\nOwl Message Attributes:\n"); 1640 1654 owl_message_attributes_tofmtext(m, &attrfm); … … 1965 1979 1966 1980 1967 owl_fmtext_append_normal(&fm, "\nMemory Usage:\n");1968 owl_fmtext_append_normal(&fm, " Not currently available.\n");1969 /*1970 sprintf(buff, "%sMemory Malloced: %i\n", buff, owl_global_get_malloced(&g));1971 sprintf(buff, "%sMemory Freed: %i\n", buff, owl_global_get_freed(&g));1972 sprintf(buff, "%sMemory In Use: %i\n", buff, owl_global_get_meminuse(&g));1973 */1974 1975 1981 owl_fmtext_append_normal(&fm, "\nAIM Status:\n"); 1976 1982 owl_fmtext_append_normal(&fm, " Logged in: "); … … 2025 2031 void owl_function_reply(int type, int enter) 2026 2032 { 2027 char *buff=NULL , *oldbuff;2033 char *buff=NULL; 2028 2034 owl_message *m; 2029 2035 owl_filter *f; … … 2032 2038 owl_function_error("No message selected"); 2033 2039 } else { 2034 char *class, *inst, *to, *cc=NULL;2035 2040 2036 2041 m=owl_view_get_element(owl_global_get_current_view(&g), owl_global_get_curmsg(&g)); … … 2049 2054 } 2050 2055 2051 /* loopback */ 2052 if (owl_message_is_type_loopback(m)) { 2053 owl_function_loopwrite_setup(); 2054 return; 2055 } 2056 2057 /* zephyr */ 2058 if (owl_message_is_type_zephyr(m)) { 2059 /* if it's a zephyr we sent, send it out the same way again */ 2060 if (owl_message_is_direction_out(m)) { 2061 buff = owl_strdup(owl_message_get_zwriteline(m)); 2062 } else { 2063 2064 /* Special case a personal reply to a webzephyr user on a class */ 2065 if ((type==1) && !strcasecmp(owl_message_get_opcode(m), OWL_WEBZEPHYR_OPCODE)) { 2066 class=OWL_WEBZEPHYR_CLASS; 2067 inst=owl_message_get_sender(m); 2068 to=OWL_WEBZEPHYR_PRINCIPAL; 2069 } else if (!strcasecmp(owl_message_get_class(m), OWL_WEBZEPHYR_CLASS) && owl_message_is_loginout(m)) { 2070 /* Special case LOGIN/LOGOUT notifications on class "webzephyr" */ 2071 class=OWL_WEBZEPHYR_CLASS; 2072 inst=owl_message_get_instance(m); 2073 to=OWL_WEBZEPHYR_PRINCIPAL; 2074 } else if (owl_message_is_loginout(m)) { 2075 /* Normal LOGIN/LOGOUT messages */ 2076 class="MESSAGE"; 2077 inst="PERSONAL"; 2078 to=owl_message_get_sender(m); 2079 } else if (type==1) { 2080 /* Personal reply */ 2081 class="MESSAGE"; 2082 inst="PERSONAL"; 2083 to=owl_message_get_sender(m); 2084 } else { 2085 /* General reply */ 2086 class=owl_message_get_class(m); 2087 inst=owl_message_get_instance(m); 2088 to=owl_message_get_recipient(m); 2089 cc=owl_message_get_cc_without_recipient(m); 2090 if (!strcmp(to, "") || !strcmp(to, "*")) { 2091 to=""; 2092 } else if (to[0]=='@') { 2093 /* leave it, to get the realm */ 2094 } else { 2095 to=owl_message_get_sender(m); 2096 } 2097 } 2098 2099 /* create the command line */ 2100 if (!strcasecmp(owl_message_get_opcode(m), "CRYPT")) { 2101 buff=owl_strdup("zcrypt"); 2102 } else { 2103 buff = owl_strdup("zwrite"); 2104 } 2105 if (strcasecmp(class, "message")) { 2106 buff = owl_sprintf("%s -c %s%s%s", oldbuff=buff, owl_getquoting(class), class, owl_getquoting(class)); 2107 owl_free(oldbuff); 2108 } 2109 if (strcasecmp(inst, "personal")) { 2110 buff = owl_sprintf("%s -i %s%s%s", oldbuff=buff, owl_getquoting(inst), inst, owl_getquoting(inst)); 2111 owl_free(oldbuff); 2112 } 2113 if (*to != '\0') { 2114 char *tmp, *oldtmp, *tmp2; 2115 tmp=short_zuser(to); 2116 if (cc) { 2117 tmp = owl_util_uniq(oldtmp=tmp, cc, "-"); 2118 owl_free(oldtmp); 2119 buff = owl_sprintf("%s -C %s", oldbuff=buff, tmp); 2120 owl_free(oldbuff); 2121 } else { 2122 if (owl_global_is_smartstrip(&g)) { 2123 tmp2=tmp; 2124 tmp=owl_zephyr_smartstripped_user(tmp2); 2125 owl_free(tmp2); 2126 } 2127 buff = owl_sprintf("%s %s", oldbuff=buff, tmp); 2128 owl_free(oldbuff); 2129 } 2130 owl_free(tmp); 2131 } 2132 if (cc) owl_free(cc); 2133 } 2134 } else if (owl_message_is_type_aim(m)) { 2135 /* aim */ 2136 if (owl_message_is_direction_out(m)) { 2137 buff=owl_sprintf("aimwrite %s", owl_message_get_recipient(m)); 2138 } else { 2139 buff=owl_sprintf("aimwrite %s", owl_message_get_sender(m)); 2140 } 2141 } else { 2142 char *cmd; 2143 if((type==0 && (cmd=owl_message_get_attribute_value(m, "replycmd"))) 2144 || (type==1 && (cmd=owl_message_get_attribute_value(m, "replysendercmd")))) { 2145 buff = owl_strdup(cmd); 2146 } 2056 char *cmd; 2057 if((type == 0 && 2058 (cmd=owl_perlconfig_message_call_method(m, "replycmd", 0, NULL))) || 2059 (type == 1 && 2060 (cmd=owl_perlconfig_message_call_method(m, "replysendercmd", 0, NULL)))) { 2061 buff = cmd; 2147 2062 } 2148 2063 … … 2151 2066 return; 2152 2067 } 2153 2068 2154 2069 if (enter) { 2155 2070 owl_history *hist = owl_global_get_cmd_history(&g); … … 2404 2319 return; 2405 2320 } 2406 if (owl_util_string_to_color(argv[3])== -1) {2321 if (owl_util_string_to_color(argv[3])==OWL_COLOR_INVALID) { 2407 2322 owl_function_error("The color '%s' is not available.", argv[3]); 2408 2323 return; … … 2419 2334 return; 2420 2335 } 2421 if (owl_util_string_to_color(argv[3])== -1) {2336 if (owl_util_string_to_color(argv[3])==OWL_COLOR_INVALID) { 2422 2337 owl_function_error("The color '%s' is not available.", argv[3]); 2423 2338 return; … … 2527 2442 { 2528 2443 owl_filter *f; 2529 char buff[5000];2444 char *buff, *tmp; 2530 2445 2531 2446 f=owl_global_get_filter(&g, name); … … 2534 2449 return; 2535 2450 } 2536 owl_filter_print(f, buff); 2451 tmp = owl_filter_print(f); 2452 buff = owl_sprintf("%s: %s", owl_filter_get_name(f), tmp); 2537 2453 owl_function_popless_text(buff); 2454 owl_free(buff); 2455 owl_free(tmp); 2538 2456 } 2539 2457 … … 2543 2461 owl_list *fl; 2544 2462 char buff[5000]; 2463 char *tmp; 2545 2464 owl_fmtext fm; 2546 2465 int i, j; … … 2556 2475 snprintf(buff, sizeof(buff), "[% 2d] ", i+1); 2557 2476 owl_fmtext_append_normal(&fm, buff); 2558 owl_filter_print(f, buff); 2477 tmp = owl_filter_print(f); 2478 owl_fmtext_append_normal(&fm, tmp); 2479 owl_free(tmp); 2559 2480 owl_fmtext_append_normal(&fm, buff); 2560 2481 } … … 2953 2874 } 2954 2875 2955 if (owl_util_string_to_color(fgcolor)== -1) {2876 if (owl_util_string_to_color(fgcolor)==OWL_COLOR_INVALID) { 2956 2877 owl_function_error("No color named '%s' avilable.", fgcolor); 2957 2878 return(-1); … … 2960 2881 2961 2882 if (bgcolor != NULL) { 2962 if (owl_util_string_to_color(bgcolor)== -1) {2883 if (owl_util_string_to_color(bgcolor)==OWL_COLOR_INVALID) { 2963 2884 owl_function_error("No color named '%s' avilable.", bgcolor); 2964 2885 return(-1); … … 3512 3433 FILE *file; 3513 3434 char buff[LINE]; 3435 int fail_silent = 0; 3514 3436 3515 3437 if (!filename) { 3438 fail_silent = 1; 3516 3439 filename=owl_global_get_startupfile(&g); 3517 file=fopen(filename, "r"); 3518 } else { 3519 file=fopen(filename, "r"); 3520 } 3440 } 3441 file=fopen(filename, "r"); 3521 3442 if (!file) { 3522 owl_function_error("Error opening file: %s", filename); 3443 if (!fail_silent) { 3444 owl_function_error("Error opening file: %s", filename); 3445 } 3523 3446 return; 3524 3447 } -
glib_compat.c
rc60ade2 r731dd1e 1 #include <owl.h>1 #include "owl.h" 2 2 3 3 #if (GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION < 14) -
global.c
r9f4e3f8 rda466e0 310 310 311 311 void owl_global_set_typwin_active(owl_global *g) { 312 int d = owl_global_get_typewindelta(g); 313 if (d > 0) 314 owl_function_resize_typwin(owl_global_get_typwin_lines(g) + d); 315 312 316 g->typwinactive=1; 313 317 } 314 318 315 319 void owl_global_set_typwin_inactive(owl_global *g) { 320 int d = owl_global_get_typewindelta(g); 321 if (d > 0) 322 owl_function_resize_typwin(owl_global_get_typwin_lines(g) - d); 323 316 324 g->typwinactive=0; 317 325 } -
help.c
rec53338 r0398d55 57 57 " M-n View zephyrs in selected conversation\n" 58 58 " M-N View zephyrs in selected converstaion of instance\n" 59 " M-p View only personal zephyrs\n" 59 60 " V Change to back to home view ('all' by default)\n" 60 61 " v Start a view command\n" -
logging.c
ree310eb rd8671a1 51 51 if (!owl_global_is_loglogins(&g) && owl_message_is_loginout(m)) return(0); 52 52 53 /* check for nolog */54 if (!strcasecmp(owl_message_get_opcode(m), "nolog") || !strcasecmp(owl_message_get_instance(m), "nolog")) return(0);55 56 53 /* check direction */ 57 54 if ((owl_global_get_loggingdirection(&g)==OWL_LOGGING_DIRECTION_IN) && owl_message_is_direction_out(m)) { … … 154 151 } else if (owl_message_is_type_jabber(m)) { 155 152 to = owl_sprintf("jabber:%s", owl_message_get_recipient(m)); 153 owl_text_tr(to, '/', '_'); 156 154 } else if (owl_message_is_type_aim(m)) { 157 155 char *temp2; -
message.c
r07bfbc2 r147d880 42 42 owl_message_set_direction_none(m); 43 43 m->delete=0; 44 m->zwriteline=NULL;45 44 46 45 owl_message_set_hostname(m, ""); … … 485 484 char *owl_message_get_zwriteline(owl_message *m) 486 485 { 487 if(!m->zwriteline)488 489 return (m->zwriteline);486 char *z = owl_message_get_attribute_value(m, "zwriteline"); 487 if (!z) return ""; 488 return z; 490 489 } 491 490 492 491 void owl_message_set_zwriteline(owl_message *m, char *line) 493 492 { 494 if(m->zwriteline) owl_free(m->zwriteline); 495 m->zwriteline=owl_strdup(line); 493 owl_message_set_attribute(m, "zwriteline", line); 496 494 } 497 495 … … 615 613 return(0); 616 614 } 617 }618 return(0);619 }620 621 int owl_message_is_burningears(owl_message *m)622 {623 /* we should add a global to cache the short zsender */624 char sender[LINE], *ptr;625 626 /* if the message is from us or to us, it doesn't count */627 if (owl_message_is_from_me(m) || owl_message_is_private(m)) return(0);628 629 if (owl_message_is_type_zephyr(m)) {630 strcpy(sender, owl_zephyr_get_sender());631 ptr=strchr(sender, '@');632 if (ptr) *ptr='\0';633 } else if (owl_message_is_type_aim(m)) {634 strcpy(sender, owl_global_get_aim_screenname(&g));635 } else {636 return(0);637 }638 639 if (stristr(owl_message_get_body(m), sender)) {640 return(1);641 615 } 642 616 return(0); … … 884 858 } 885 859 886 m->zwriteline=owl_strdup("");887 888 860 /* save the hostname */ 889 861 owl_function_debugmsg("About to do gethostbyaddr"); … … 966 938 } 967 939 968 m->zwriteline=owl_strdup("");969 970 940 owl_message_set_body(m, "<uninitialized>"); 971 941 … … 999 969 owl_message_set_opcode(m, owl_zwrite_get_opcode(&z)); 1000 970 owl_message_set_realm(m, owl_zwrite_get_realm(&z)); /* also a hack, but not here */ 1001 m->zwriteline=owl_strdup(line);971 owl_message_set_zwriteline(m, line); 1002 972 owl_message_set_body(m, body); 1003 973 owl_message_set_zsig(m, zsig); … … 1040 1010 #endif 1041 1011 if (m->timestr) owl_free(m->timestr); 1042 if (m->zwriteline) owl_free(m->zwriteline);1043 1012 1044 1013 /* free all the attributes */ -
owl.c
r628c897 r7ba9ead9 120 120 exit(0); 121 121 } else { 122 fprintf(stderr, "U known argument\n");122 fprintf(stderr, "Unknown argument\n"); 123 123 usage(); 124 124 exit(1); … … 603 603 } 604 604 } 605 606 /* check for burning ears message */ 607 /* this is an unsupported feature */ 608 if (owl_global_is_burningears(&g) && owl_message_is_burningears(m)) { 609 char *buff; 610 buff = owl_sprintf("@i(Burning ears message on class %s)", owl_message_get_class(m)); 611 owl_function_adminmsg(buff, ""); 612 owl_free(buff); 613 owl_function_beep(); 614 } 615 } 616 605 } 606 607 /* let perl know about it */ 608 owl_perlconfig_newmsg(m, NULL); 617 609 /* log the message if we need to */ 618 610 owl_log_message(m); -
owl.h
rd7a3188 r43a306c 20 20 #include <signal.h> 21 21 #include <termios.h> 22 #include <libfaim/aim.h>22 #include "libfaim/aim.h" 23 23 #include <wchar.h> 24 24 #include "config.h" … … 51 51 #define _STRINGIFY(x) #x 52 52 53 #ifndef OWL_SVN_REVNO54 #define OWL_SVN_REVNO ????55 #endif56 57 53 #ifndef OWL_VERSION_STRING 58 #define OWL_VERSION_STRING "1.0. 1"54 #define OWL_VERSION_STRING "1.0.3" 59 55 #endif 60 56 … … 100 96 #define OWL_COLOR_WHITE 7 101 97 #define OWL_COLOR_DEFAULT -1 98 #define OWL_COLOR_INVALID -2 102 99 103 100 #define OWL_EDITWIN_STYLE_MULTILINE 0 … … 341 338 char *timestr; 342 339 time_t time; 343 char *zwriteline;344 340 } owl_message; 345 341 … … 405 401 int (*match_message)(struct _owl_filterelement *fe, owl_message *m); 406 402 /* Append a string representation of the filterelement onto buf*/ 407 void (*print_elt)(struct _owl_filterelement *fe, char *buf);403 void (*print_elt)(struct _owl_filterelement *fe, GString *buf); 408 404 /* Operands for and,or,not*/ 409 405 struct _owl_filterelement *left, *right; -
perl/lib/BarnOwl/ModuleLoader.pm
r965e14d r41bbb8a 8 8 use PAR (BarnOwl::get_config_dir() . "/modules/*.par"); 9 9 10 our %modules; 11 10 12 sub load_all { 13 my $class = shift; 14 $class->rescan_modules; 11 15 PAR::reload_libs(); 16 17 for my $mod (keys %modules) { 18 if(!defined eval "use BarnOwl::Module::$mod") { 19 BarnOwl::error("Unable to load module $mod: \n$@\n") if $@; 20 } 21 } 22 23 $BarnOwl::Hooks::startup->add(\®ister_keybindings); 24 } 25 26 sub rescan_modules { 12 27 PAR->import(BarnOwl::get_data_dir() . "/modules/*.par"); 13 28 PAR->import(BarnOwl::get_config_dir() . "/modules/*.par"); 14 my %modules;15 29 my @modules; 30 31 %modules = (); 16 32 17 33 my @moddirs = (); … … 37 53 } 38 54 } 39 for my $class (keys %modules) { 40 if(!defined eval "use BarnOwl::Module::$class") { 41 # BarnOwl::error("Unable to load module $class: $!") if $!; 42 BarnOwl::error("Unable to load module $class: \n$@\n") if $@; 55 } 56 57 sub reload_module { 58 my $class = shift; 59 my $module = shift; 60 61 $class->rescan_modules(); 62 63 for my $m (keys %INC) { 64 delete $INC{$m} if $m =~ m{^BarnOwl/Module/$module}; 65 } 66 67 my $parfile; 68 for my $p (@PAR::PAR_INC) { 69 if($p =~ m/\Q$module\E[.]par$/) { 70 $parfile = $p; 71 last; 43 72 } 44 73 } 45 74 46 $BarnOwl::Hooks::startup->add(\®ister_keybindings); 75 local $SIG{__WARN__} = \&squelch_redefine; 76 77 if(defined $parfile) { 78 PAR::reload_libs($parfile); 79 $class->run_startup_hooks(); 80 } elsif(!defined eval "use BarnOwl::Module::$module") { 81 BarnOwl::error("Unable to load module $module: \n$@\n") if $@; 82 } 83 } 84 85 sub reload_module_cmd { 86 my $class = shift; 87 shift; # Command 88 my $module = shift; 89 unless(defined($module)) { 90 die("Usage: reload-module [MODULE]"); 91 }; 92 $class->reload_module($module); 47 93 } 48 94 … … 52 98 usage => 'reload-modules', 53 99 description => q{Reloads all modules located in ~/.owl/modules and the system modules directory} 100 }); 101 BarnOwl::new_command('reload-module', sub {BarnOwl::ModuleLoader->reload_module_cmd(@_)}, { 102 summary => 'Reload one module', 103 usage => 'reload-module [MODULE]', 104 description => q{Reloads a single module located in ~/.owl/modules or the system modules directory} 54 105 }); 55 106 } … … 63 114 $INC{$_} = 1 for (qw(BarnOwl.pm BarnOwl/Hooks.pm 64 115 BarnOwl/Message.pm BarnOwl/Style.pm)); 116 $class->run_startup_hooks(); 117 } 65 118 66 $BarnOwl::Hooks::startup->clear; 67 $BarnOwl::Hooks::getBuddyList->clear; 68 $BarnOwl::Hooks::mainLoop->clear; 69 $BarnOwl::Hooks::shutdown->clear; 70 $BarnOwl::Hooks::receiveMessage->clear; 119 sub run_startup_hooks { 120 my $class = shift; 71 121 local $SIG{__WARN__} = \&squelch_redefine; 72 122 $class->load_all; -
perl/modules/IRC/lib/BarnOwl/Message/IRC.pm
r8df6cbb r38a7f22 20 20 my $inst = shift; 21 21 22 my ($filter, $ftext); 22 my $filter; 23 my @filter; 23 24 24 25 if($self->is_private) { … … 30 31 } 31 32 $filter = "irc-user-$who"; 32 my $ftext = 33 qq{type ^irc\$ and ( ( direction ^in\$ and sender ^$who\$ ) } 34 . qq{or ( direction ^out\$ and recipient ^$who\$ ) ) }; 35 BarnOwl::filter("$filter $ftext"); 33 @filter = 34 (qw{( type ^irc$ and filter personal and }, 35 qw{( ( direction ^in$ and sender}, "^$who\$", 36 qw{ ) or ( direction ^out$ and recipient}, "^$who\$", 37 qw{) ) ) }); 38 BarnOwl::command("filter", "$filter", @filter); 36 39 return $filter; 37 40 } else { … … 43 46 if ($inst && $self->body =~ /^(\S+):/) { 44 47 $filter = "irc-$network-channel-$channel-$sender-$1"; 45 $ftext = qq{type ^irc\$ and network ^$network\$ and channel ^$channel\$ and ( sender ^$sender\$ or sender ^$1\$ )}; 48 @filter = 49 (qw{type ^irc$ and network}, "^$network\$", 50 qw{and channel}, "^$channel\$", 51 qw{and ( sender}, "^$sender\$", 52 qw{or sender}, "^$1\$",qq{)}); 46 53 } else { 47 54 $filter = "irc-$network-channel-$channel"; 48 $ftext = qq{type ^irc\$ and network ^$network\$ and channel ^$channel\$}; 55 @filter = (qw{type ^irc$ and network}, "^$network\$", 56 qw{and channel}, "^$channel\$"); 49 57 } 50 BarnOwl:: filter("$filter $ftext");58 BarnOwl::command("filter", "$filter", @filter); 51 59 return $filter; 52 60 } … … 56 64 sub network {shift->{network}} 57 65 sub channel {shift->{channel}} 66 sub action {shift->{action}} 67 sub reason {shift->{reason}} 58 68 59 69 # display … … 65 75 sub login_type { 66 76 my $self = shift; 67 return " (" . ($self->is_login ? "JOIN" : "PART"). ")";77 return " (" . uc $self->action . ")"; 68 78 } 69 79 70 sub login_extra { shift->channel; } 71 80 sub login_extra { 81 my $self = shift; 82 if ($self->action eq "quit") { 83 return $self->reason; 84 } else { 85 return $self->channel; 86 } 87 } 72 88 73 89 1; -
perl/modules/IRC/lib/BarnOwl/Module/IRC.pm
rf094fc4 r167044b 117 117 BarnOwl::new_command('irc-who' => \&cmd_who); 118 118 BarnOwl::new_command('irc-stats' => \&cmd_stats); 119 } 120 121 $BarnOwl::Hooks::startup->add(\&startup); 122 $BarnOwl::Hooks::s hutdown->add(\&shutdown);123 #$BarnOwl::Hooks::mainLoop->add(\&mainloop_hook);119 BarnOwl::new_command('irc-topic' => \&cmd_topic); 120 } 121 122 $BarnOwl::Hooks::startup->add('BarnOwl::Module::IRC::startup'); 123 $BarnOwl::Hooks::shutdown->add('BarnOwl::Module::IRC::shutdown'); 124 124 125 125 ################################################################################ … … 262 262 my $conn = get_connection(\@_); 263 263 my $chan = get_channel(\@_) || die("Usage: $cmd <channel>\n"); 264 $conn->names_tmp([]); 264 265 $conn->conn->names($chan); 265 266 } … … 299 300 my $type = shift || die("Usage: $cmd <chiklmouy> [server] \n"); 300 301 $conn->conn->stats($type, @_); 302 } 303 304 sub cmd_topic { 305 my $cmd = shift; 306 my $conn = get_connection(\@_); 307 $conn->conn->topic(@_); 301 308 } 302 309 -
perl/modules/IRC/lib/BarnOwl/Module/IRC/Connection.pm
r8faab0c r4789b17 18 18 19 19 use base qw(Class::Accessor Exporter); 20 __PACKAGE__->mk_accessors(qw(conn alias channels connected motd ));20 __PACKAGE__->mk_accessors(qw(conn alias channels connected motd names_tmp whois_tmp)); 21 21 our @EXPORT_OK = qw(&is_private); 22 22 … … 45 45 $self->motd(""); 46 46 $self->connected(0); 47 $self->names_tmp(0); 48 $self->whois_tmp(""); 47 49 48 50 $self->conn->add_handler(376 => sub { shift; $self->on_connect(@_) }); … … 62 64 $self->conn->add_handler(join => sub { shift; $self->on_join(@_) }); 63 65 $self->conn->add_handler(part => sub { shift; $self->on_part(@_) }); 66 $self->conn->add_handler(quit => sub { shift; $self->on_quit(@_) }); 64 67 $self->conn->add_handler(disconnect => sub { shift; $self->on_disconnect(@_) }); 65 68 $self->conn->add_handler(nicknameinuse => sub { shift; $self->on_nickinuse(@_) }); 66 69 $self->conn->add_handler(cping => sub { shift; $self->on_ping(@_) }); 70 $self->conn->add_handler(topic => sub { shift; $self->on_topic(@_) }); 71 $self->conn->add_handler(topicinfo => sub { shift; $self->on_topicinfo(@_) }); 72 $self->conn->add_handler(namreply => sub { shift; $self->on_namreply(@_) }); 73 $self->conn->add_handler(endofnames=> sub { shift; $self->on_endofnames(@_) }); 74 $self->conn->add_handler(endofwhois=> sub { shift; $self->on_endofwhois(@_) }); 67 75 68 76 return $self; … … 126 134 BarnOwl::Style::boldify('IRC ' . $evt->type . ' message from ' 127 135 . $self->alias) . "\n" 128 . strip_irc_formatting(join ' \n', $evt->args));136 . strip_irc_formatting(join ' ', cdr($evt->args))); 129 137 } 130 138 … … 157 165 my $msg = $self->new_message($evt, 158 166 loginout => 'login', 167 action => 'join', 159 168 channel => $evt->to, 160 replycmd => 'irc-msg -a ' . $self->alias . ' ' . $evt->nick,169 replycmd => 'irc-msg -a ' . $self->alias . ' ' . join(' ', $evt->to), 161 170 replysendercmd => 'irc-msg -a ' . $self->alias . ' ' . $evt->nick 162 171 ); … … 168 177 my $msg = $self->new_message($evt, 169 178 loginout => 'logout', 179 action => 'part', 170 180 channel => $evt->to, 181 replycmd => 'irc-msg -a ' . $self->alias . ' ' . join(' ', $evt->to), 182 replysendercmd => 'irc-msg -a ' . $self->alias . ' ' . $evt->nick 183 ); 184 BarnOwl::queue_message($msg); 185 } 186 187 sub on_quit { 188 my ($self, $evt) = @_; 189 my $msg = $self->new_message($evt, 190 loginout => 'logout', 191 action => 'quit', 192 from => $evt->to, 193 reason => [$evt->args]->[0], 171 194 replycmd => 'irc-msg -a ' . $self->alias . ' ' . $evt->nick, 172 195 replysendercmd => 'irc-msg -a ' . $self->alias . ' ' . $evt->nick … … 193 216 } 194 217 218 sub on_topic { 219 my ($self, $evt) = @_; 220 my @args = $evt->args; 221 if (scalar @args > 1) { 222 BarnOwl::admin_message("IRC", 223 "Topic for $args[1] on " . $self->alias . " is $args[2]"); 224 } else { 225 BarnOwl::admin_message("IRC", 226 "Topic changed to $args[0]"); 227 } 228 } 229 230 sub on_topicinfo { 231 my ($self, $evt) = @_; 232 my @args = $evt->args; 233 BarnOwl::admin_message("IRC", 234 "Topic for $args[1] set by $args[2] at " . localtime($args[3])); 235 } 236 237 # IRC gives us a bunch of namreply messages, followed by an endofnames. 238 # We need to collect them from the namreply and wait for the endofnames message. 239 # After this happens, the names_tmp variable is cleared. 240 241 sub on_namreply { 242 my ($self, $evt) = @_; 243 return unless $self->names_tmp; 244 $self->names_tmp([@{$self->names_tmp}, split(' ', [$evt->args]->[3])]); 245 } 246 247 sub on_endofnames { 248 my ($self, $evt) = @_; 249 return unless $self->names_tmp; 250 my $names = BarnOwl::Style::boldify("Members of " . [$evt->args]->[1] . ":\n"); 251 for my $name (@{$self->names_tmp}) { 252 $names .= " $name\n"; 253 } 254 BarnOwl::popless_ztext($names); 255 $self->names_tmp(0); 256 } 257 258 sub on_whois { 259 my ($self, $evt) = @_; 260 $self->whois_tmp( 261 $self->whois_tmp . "\n" . $evt->type . ":\n " . 262 join("\n ", cdr(cdr($evt->args))) . "\n" 263 ); 264 } 265 266 sub on_endofwhois { 267 my ($self, $evt) = @_; 268 BarnOwl::popless_ztext( 269 BarnOwl::Style::boldify("/whois for " . [$evt->args]->[1] . ":\n") . 270 $self->whois_tmp 271 ); 272 $self->whois_tmp([]); 273 } 274 195 275 sub on_event { 196 276 my ($self, $evt) = @_; 277 return on_whois(@_) if ($evt->type =~ /^whois/); 197 278 BarnOwl::admin_message("IRC", 198 279 "[" . $self->alias . "] Unhandled IRC event of type " . $evt->type . ":\n" … … 200 281 if BarnOwl::getvar('irc:spew') eq 'on'; 201 282 } 202 203 283 204 284 ################################################################################ … … 214 294 215 295 my @pieces = split /\cB/, $body; 216 my $out;296 my $out = ''; 217 297 while(@pieces) { 218 298 $out .= shift @pieces; -
perl/modules/Jabber/lib/BarnOwl/Message/Jabber.pm
r693c8f2 r96134cb 22 22 sub subject { shift->{subject} }; 23 23 sub status { shift->{status} } 24 25 sub login_type { 26 my $self = shift; 27 my $type = $self->jtype; 28 return " ($type)" if $type; 29 } 24 30 25 31 sub login_extra { … … 50 56 my $inst = shift; 51 57 52 my ($filter, $ftext);58 my $filter; 53 59 54 60 if($self->jtype eq 'chat') { … … 63 69 my $room = $self->room; 64 70 $filter = "jabber-room-$room"; 65 $ftext = qq{type ^jabber\$ and room ^$room\$};66 BarnOwl::filter("$filter $ftext");71 BarnOwl::command(qw[filter], $filter, 72 qw[type ^jabber$ and room], "^$room\$"); 67 73 return $filter; 68 74 } elsif ($self->login ne 'none') { … … 77 83 $user = Net::Jabber::JID->new($user)->GetJID( $inst ? 'full' : 'base' ); 78 84 my $filter = "jabber-user-$user"; 79 my $ftext =80 qq{type ^jabber\$ and ( ( direction ^in\$ and from ^$user ) }81 . qq{or ( direction ^out\$ and to ^$user ) ) };82 BarnOwl::filter("$filter $ftext");85 BarnOwl::command(qw[filter], $filter, qw[type ^jabber$], 86 qw[and ( ( direction ^in$ and from], "^$user", 87 qw[) or ( direction ^out$ and to ], "^$user", 88 qw[ ) ) ]); 83 89 return $filter; 84 90 85 91 } 86 92 93 sub replycmd { 94 my $self = shift; 95 my ($recip, $account, $subject); 96 if ($self->is_loginout) { 97 $recip = $self->sender; 98 $account = $self->recipient; 99 } elsif ($self->jtype eq 'chat') { 100 return $self->replysendercmd; 101 } elsif ($self->jtype eq 'groupchat') { 102 $recip = $self->room; 103 if ($self->is_incoming) { 104 $account = $self->to; 105 } else { 106 $account = $self->from; 107 } 108 $subject = $self->subject; 109 } else { 110 # Unknown type 111 return; 112 } 113 return jwrite_cmd($recip, $account, $subject); 114 } 115 116 sub replysendercmd { 117 my $self = shift; 118 if($self->jtype eq 'groupchat' 119 || $self->jtype eq 'chat') { 120 my ($recip, $account); 121 if ($self->is_incoming) { 122 $recip = $self->from; 123 $account = $self->to; 124 } else { 125 $recip = $self->to; 126 $account = $self->from; 127 } 128 return jwrite_cmd($recip, $account); 129 } 130 return $self->replycmd; 131 } 132 133 sub jwrite_cmd { 134 my ($recip, $account, $subject) = @_; 135 if (defined $recip) { 136 $recip = BarnOwl::quote($recip); 137 $account = BarnOwl::quote($account); 138 my $cmd = "jwrite $recip -a $account"; 139 if (defined $subject) { 140 $cmd .= " -s " . BarnOwl::quote($subject); 141 } 142 return $cmd; 143 } else { 144 return undef; 145 } 146 } 87 147 88 148 =head1 SEE ALSO -
perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm
r8af89a7 re979da9 68 68 register_keybindings(); 69 69 register_filters(); 70 $BarnOwl::Hooks::mainLoop->add( \&onMainLoop);71 $BarnOwl::Hooks::getBuddyList->add( \&onGetBuddyList);70 $BarnOwl::Hooks::mainLoop->add("BarnOwl::Module::Jabber::onMainLoop"); 71 $BarnOwl::Hooks::getBuddyList->add("BarnOwl::Module::Jabber::onGetBuddyList"); 72 72 $vars{show} = ''; 73 73 BarnOwl::new_variable_bool("jabber:show_offline_buddies", 74 74 { default => 1, 75 75 summary => 'Show offline or pending buddies.'}); 76 BarnOwl::new_variable_bool("jabber:show_logins", 77 { default => 0, 78 summary => 'Show login/logout messages.'}); 76 79 BarnOwl::new_variable_bool("jabber:spew", 77 80 { default => 0, … … 85 88 summary => 'After minutes idle, auto extended away.' 86 89 }); 90 # Force these. Reload can screw them up. 91 # Taken from Net::Jabber::Protocol. 92 $Net::XMPP::Protocol::NEWOBJECT{'iq'} = "Net::Jabber::IQ"; 93 $Net::XMPP::Protocol::NEWOBJECT{'message'} = "Net::Jabber::Message"; 94 $Net::XMPP::Protocol::NEWOBJECT{'presence'} = "Net::Jabber::Presence"; 95 $Net::XMPP::Protocol::NEWOBJECT{'jid'} = "Net::Jabber::JID"; 87 96 } else { 88 97 # Our owl doesn't support queue_message. Unfortunately, this … … 92 101 } 93 102 94 $BarnOwl::Hooks::startup->add( \&onStart);103 $BarnOwl::Hooks::startup->add("BarnOwl::Module::Jabber::onStart"); 95 104 96 105 sub onMainLoop { … … 232 241 summary => "Send a Jabber Message", 233 242 usage => "jwrite JID [-t thread] [-s subject]" 243 } 244 ); 245 BarnOwl::new_command( 246 jaway => \&cmd_jaway, 247 { 248 summary => "Set Jabber away / presence information", 249 usage => "jaway [-s online|dnd|...] [<message>]" 234 250 } 235 251 ); … … 757 773 } 758 774 775 sub cmd_jaway { 776 my $cmd = shift; 777 local @ARGV = @_; 778 my $getopt = Getopt::Long::Parser->new; 779 my ($jid, $show); 780 my $p = new Net::Jabber::Presence; 781 782 $getopt->configure('pass_through', 'no_getopt_compat'); 783 $getopt->getoptions( 784 'account=s' => \$jid, 785 'show=s' => \$show 786 ); 787 $jid ||= defaultJID(); 788 if ($jid) { 789 $jid = resolveConnectedJID($jid); 790 return unless $jid; 791 } 792 else { 793 BarnOwl::error('You must specify an account with -a {jid}'); 794 } 795 796 $p->SetShow($show eq "online" ? "" : $show) if $show; 797 $p->SetStatus(join(' ', @ARGV)) if @ARGV; 798 $conn->getConnectionFromJID($jid)->Send($p); 799 } 800 801 759 802 sub jroster_sub { 760 803 my $jid = shift; … … 933 976 sub process_incoming_chat_message { 934 977 my ( $sid, $j ) = @_; 935 BarnOwl::queue_message( j2o( $j, { direction => 'in', 936 sid => $sid } ) ); 978 if ($j->DefinedBody()) { 979 BarnOwl::queue_message( j2o( $j, { direction => 'in', 980 sid => $sid } ) ); 981 } 937 982 } 938 983 … … 989 1034 990 1035 sub process_presence_available { 1036 return unless (BarnOwl::getvar('jabber:show_logins') eq 'on'); 991 1037 my ( $sid, $p ) = @_; 992 my $from = $p->GetFrom( );1038 my $from = $p->GetFrom('jid')->GetJID('base'); 993 1039 my $to = $p->GetTo(); 994 1040 my $type = $p->GetType(); 995 1041 my %props = ( 996 1042 to => $to, 997 from => $ from,1043 from => $p->GetFrom(), 998 1044 recipient => $to, 999 1045 sender => $from, … … 1013 1059 $props{loginout} = 'logout'; 1014 1060 } 1015 $props{replysendercmd} = $props{replycmd} = "jwrite $from -i $sid"; 1016 if(BarnOwl::getvar('debug') eq 'on') { 1017 BarnOwl::queue_message(BarnOwl::Message->new(%props)); 1018 } 1061 BarnOwl::queue_message(BarnOwl::Message->new(%props)); 1019 1062 } 1020 1063 … … 1099 1142 sub j2hash { 1100 1143 my $j = shift; 1101 my %initProps = %{ shift() }; 1102 1103 my $dir = 'none'; 1104 my %props = ( type => 'jabber' ); 1105 1106 foreach my $k (keys %initProps) { 1107 $dir = $initProps{$k} if ($k eq 'direction'); 1108 $props{$k} = $initProps{$k}; 1109 } 1144 my %props = (type => 'jabber', 1145 dir => 'none', 1146 %{$_[0]}); 1147 1148 my $dir = $props{direction}; 1110 1149 1111 1150 my $jtype = $props{jtype} = $j->GetType(); … … 1120 1159 $props{subject} = $j->GetSubject() if ( $j->DefinedSubject() ); 1121 1160 $props{thread} = $j->GetThread() if ( $j->DefinedThread() ); 1122 $props{body} = $j->GetBody() if ( $j->DefinedBody() ); 1161 if ( $j->DefinedBody() ) { 1162 $props{body} = $j->GetBody(); 1163 $props{body} =~ s/\xEF\xBB\xBF//g; # Strip stray Byte-Order-Marks. 1164 } 1123 1165 $props{error} = $j->GetError() if ( $j->DefinedError() ); 1124 1166 $props{error_code} = $j->GetErrorCode() if ( $j->DefinedErrorCode() ); … … 1126 1168 1127 1169 if ( $jtype eq 'chat' ) { 1128 $props{replycmd} =1129 "jwrite " . ( ( $dir eq 'in' ) ? $props{from} : $props{to} );1130 $props{replycmd} .=1131 " -a " . ( ( $dir eq 'out' ) ? $props{from} : $props{to} );1132 1170 $props{private} = 1; 1133 1171 … … 1152 1190 my $nick = $props{nick} = $from->GetResource(); 1153 1191 my $room = $props{room} = $from->GetJID('base'); 1154 $props{replycmd} = "jwrite $room";1155 $props{replycmd} .=1156 " -a " . ( ( $dir eq 'out' ) ? $props{from} : $props{to} );1157 if ($props{subject}) {1158 $props{replycmd} .= " -s " . $props{subject}1159 }1160 1161 if ($dir eq 'out') {1162 $props{replysendercmd} = "jwrite ".$props{to}." -a ".$props{from};1163 }1164 else {1165 $props{replysendercmd} = "jwrite ".$props{from}." -a ".$props{to};1166 }1167 1192 1168 1193 $props{sender} = $nick || $room; … … 1175 1200 } 1176 1201 elsif ( $jtype eq 'normal' ) { 1177 $props{replycmd} = "";1178 1202 $props{private} = 1; 1179 1203 } 1180 1204 elsif ( $jtype eq 'headline' ) { 1181 $props{replycmd} = "";1182 1205 } 1183 1206 elsif ( $jtype eq 'error' ) { 1184 $props{replycmd} = "";1185 1207 $props{body} = "Error " 1186 1208 . $props{error_code} … … 1190 1212 } 1191 1213 1192 $props{replysendercmd} = $props{replycmd} unless $props{replysendercmd};1193 1214 return %props; 1194 1215 } -
perlconfig.c
rdb0ac7e rc4ba74d 181 181 { 182 182 dSP ; 183 int count, len; 183 int count; 184 unsigned int len; 184 185 SV *msgref, *srv; 185 186 char *out, *preout; … … 421 422 } 422 423 424 /* Called on all new messages; receivemsg is only called on incoming ones */ 425 void owl_perlconfig_newmsg(owl_message *m, char *subname) 426 { 427 char *ptr = NULL; 428 if (owl_perlconfig_is_function("BarnOwl::Hooks::_new_msg")) { 429 ptr = owl_perlconfig_call_with_message(subname?subname 430 :"BarnOwl::Hooks::_new_msg", m); 431 } 432 if (ptr) owl_free(ptr); 433 } 434 423 435 char *owl_perlconfig_perlcmd(owl_cmd *cmd, int argc, char **argv) 424 436 { … … 446 458 if(SvTRUE(ERRSV)) { 447 459 owl_function_error("%s", SvPV(ERRSV, n_a)); 448 POPs;460 (void)POPs; 449 461 } else { 450 462 if(count != 1) -
perlglue.xs
rb67ab6b r740d5f7 17 17 ************************************************************* 18 18 * These functions, when they are intended to be user-visible, 19 * are document in perlwrap.pm. If you add functions to this19 * are documented in perlwrap.pm. If you add functions to this 20 20 * file, add the appropriate documentation there! 21 21 * … … 33 33 34 34 char * 35 command(cmd )35 command(cmd, ...) 36 36 char *cmd 37 37 PREINIT: 38 38 char *rv = NULL; 39 CODE: 40 rv = owl_function_command(cmd); 41 RETVAL = rv; 39 char **argv; 40 int i; 41 CODE: 42 { 43 if (items == 1) { 44 rv = owl_function_command(cmd); 45 } else { 46 argv = owl_malloc((items + 1) * sizeof *argv); 47 argv[0] = cmd; 48 for(i = 1; i < items; i++) { 49 argv[i] = SvPV_nolen(ST(i)); 50 } 51 rv = owl_function_command_argv(argv, items); 52 owl_free(argv); 53 } 54 RETVAL = rv; 55 } 42 56 OUTPUT: 43 57 RETVAL … … 98 112 RETVAL 99 113 CLEANUP: 114 if (rv) owl_free(rv); 115 116 char * 117 zephyr_smartstrip_user(in) 118 char *in 119 PREINIT: 120 char *rv = NULL; 121 CODE: 122 { 123 rv = owl_zephyr_smartstripped_user(in); 124 RETVAL = rv; 125 } 126 OUTPUT: 127 RETVAL 128 CLEANUP: 129 owl_free(rv); 130 131 char * 132 zephyr_getsubs() 133 PREINIT: 134 char *rv = NULL; 135 CODE: 136 rv = owl_zephyr_getsubs(); 137 RETVAL = rv; 138 OUTPUT: 139 RETVAL 140 CLEANUP: 100 141 if (rv) owl_free(rv); 101 142 -
perlwrap.pm
rb441079 r740d5f7 67 67 68 68 Strips zephyr formatting from a string and returns the result 69 70 =head2 zephyr_getsubs 71 72 Returns the list of subscription triples <class,instance,recipient>, 73 separated by newlines. 69 74 70 75 =head2 queue_message MESSAGE … … 295 300 %{$args}); 296 301 $func->($name, $args{default}, $args{summary}, $args{description}); 302 } 303 304 =head2 quote STRING 305 306 Return a version of STRING fully quoted to survive processing by 307 BarnOwl's command parser. 308 309 =cut 310 311 sub quote { 312 my $str = shift; 313 return "''" if $str eq ''; 314 if ($str !~ /['" ]/) { 315 return "$str"; 316 } 317 if ($str !~ /'/) { 318 return "'$str'"; 319 } 320 $str =~ s/"/"'"'"/g; 321 return '"' . $str . '"'; 297 322 } 298 323 … … 356 381 sub login_host { return undef; } 357 382 sub login_tty { return undef; } 383 384 # This is for back-compat with old messages that set these properties 385 # New protocol implementations are encourages to user override these 386 # methods. 387 sub replycmd { return shift->{replycmd}}; 388 sub replysendercmd { return shift->{replysendercmd}}; 358 389 359 390 sub pretty_sender { return shift->sender; } … … 463 494 } 464 495 496 sub replycmd {return 'loopwrite';} 497 sub replysendercmd {return 'loopwrite';} 498 465 499 ##################################################################### 466 500 ##################################################################### … … 475 509 } 476 510 511 sub replycmd { 512 my $self = shift; 513 if ($self->is_incoming) { 514 return "aimwrite " . BarnOwl::quote($self->sender); 515 } else { 516 return "aimwrite " . BarnOwl::quote($self->recipient); 517 } 518 } 519 520 sub replysendercmd { 521 return shift->replycmd; 522 } 523 477 524 ##################################################################### 478 525 ##################################################################### … … 480 527 package BarnOwl::Message::Zephyr; 481 528 529 use constant WEBZEPHYR_PRINCIPAL => "daemon.webzephyr"; 530 use constant WEBZEPHYR_CLASS => "webzephyr"; 531 use constant WEBZEPHYR_OPCODE => "webzephyr"; 532 482 533 use base qw( BarnOwl::Message ); 534 535 sub strip_realm { 536 my $sender = shift; 537 my $realm = BarnOwl::zephyr_getrealm(); 538 $sender =~ s/\@$realm$//; 539 return $sender; 540 } 483 541 484 542 sub login_type { … … 537 595 sub pretty_sender { 538 596 my ($m) = @_; 539 my $sender = $m->sender; 540 my $realm = BarnOwl::zephyr_getrealm(); 541 $sender =~ s/\@$realm$//; 542 return $sender; 597 return strip_realm($m->sender); 543 598 } 544 599 545 600 sub pretty_recipient { 546 601 my ($m) = @_; 547 my $recip = $m->recipient; 548 my $realm = BarnOwl::zephyr_getrealm(); 549 $recip =~ s/\@$realm$//; 550 return $recip; 602 return strip_realm($m->recipient); 551 603 } 552 604 … … 563 615 sub zsig { return shift->{"zsig"}; } 564 616 565 ##################################################################### 566 ##################################################################### 567 ################################################################################ 617 sub zephyr_cc { 618 my $self = shift; 619 return $1 if $self->body =~ /^\s*cc:\s+([^\n]+)/i; 620 return undef; 621 } 622 623 sub replycmd { 624 my $self = shift; 625 my $sender = shift; 626 $sender = 0 unless defined $sender; 627 my ($class, $instance, $to, $cc); 628 if($self->is_outgoing) { 629 return $self->{zwriteline}; 630 } 631 632 if($sender && $self->opcode eq WEBZEPHYR_OPCODE) { 633 $class = WEBZEPHYR_CLASS; 634 $instance = $self->sender; 635 $to = WEBZEPHYR_PRINCIPAL; 636 } elsif($self->class eq WEBZEPHYR_CLASS 637 && $self->is_loginout) { 638 $class = WEBZEPHYR_CLASS; 639 $instance = $self->instance; 640 $to = WEBZEPHYR_PRINCIPAL; 641 } elsif($self->is_loginout || $sender) { 642 $class = 'MESSAGE'; 643 $instance = 'PERSONAL'; 644 $to = $self->sender; 645 } else { 646 $class = $self->class; 647 $instance = $self->instance; 648 $to = $self->recipient; 649 $cc = $self->zephyr_cc(); 650 if($to eq '*' || $to eq '') { 651 $to = ''; 652 } elsif($to !~ /^@/) { 653 $to = $self->sender; 654 } 655 } 656 657 my $cmd; 658 if(lc $self->opcode eq 'crypt') { 659 $cmd = 'zcrypt'; 660 } else { 661 $cmd = 'zwrite'; 662 } 663 664 if (lc $class ne 'message') { 665 $cmd .= " -c " . BarnOwl::quote($self->class); 666 } 667 if (lc $instance ne 'personal') { 668 $cmd .= " -i " . BarnOwl::quote($self->instance); 669 } 670 if ($to ne '') { 671 $to = strip_realm($to); 672 if (defined $cc) { 673 my @cc = grep /^[^-]/, ($to, split /\s+/, $cc); 674 my %cc = map {$_ => 1} @cc; 675 delete $cc{strip_realm(BarnOwl::zephyr_getsender())}; 676 @cc = keys %cc; 677 $cmd .= " -C " . join(" ", @cc); 678 } else { 679 if(BarnOwl::getvar('smartstrip') eq 'on') { 680 $to = BarnOwl::zephyr_smartstrip_user($to); 681 } 682 $cmd .= " $to"; 683 } 684 } 685 return $cmd; 686 } 687 688 sub replysendercmd { 689 my $self = shift; 690 return $self->replycmd(1); 691 } 692 693 ##################################################################### 694 ##################################################################### 695 ##################################################################### 568 696 569 697 package BarnOwl::Hook; … … 598 726 my $self = shift; 599 727 my @args = @_; 600 return map {$_->(@args)} @$self; 728 return map {$self->_run($_,@args)} @$self; 729 } 730 731 sub _run { 732 my $self = shift; 733 my $fn = shift; 734 my @args = @_; 735 no strict 'refs'; 736 return $fn->(@args); 601 737 } 602 738 … … 610 746 my $self = shift; 611 747 my $func = shift; 612 die("Not a coderef!") unless ref($func) eq 'CODE'; 748 die("Not a coderef!") unless ref($func) eq 'CODE' || !ref($func); 749 return if grep {$_ eq $func} @$self; 613 750 push @$self, $func; 614 751 } … … 680 817 681 818 our @EXPORT_OK = qw($startup $shutdown 682 $receiveMessage $ mainLoop683 $ getBuddyList);819 $receiveMessage $newMessage 820 $mainLoop $getBuddyList); 684 821 685 822 our %EXPORT_TAGS = (all => [@EXPORT_OK]); … … 688 825 our $shutdown = BarnOwl::Hook->new; 689 826 our $receiveMessage = BarnOwl::Hook->new; 827 our $newMessage = BarnOwl::Hook->new; 690 828 our $mainLoop = BarnOwl::Hook->new; 691 829 our $getBuddyList = BarnOwl::Hook->new; … … 713 851 package main; 714 852 do $BarnOwl::configfile; 715 die $@ if $@; 853 if($@) { 854 BarnOwl::error("In startup: $@\n"); 855 return; 856 } 716 857 package BarnOwl; 717 858 if(*BarnOwl::format_msg{CODE}) { … … 761 902 762 903 BarnOwl::receive_msg($m) if *BarnOwl::receive_msg{CODE}; 904 } 905 906 sub _new_msg { 907 my $m = shift; 908 909 $newMessage->run($m); 910 911 BarnOwl::new_msg($m) if *BarnOwl::new_msg{CODE}; 763 912 } 764 913 -
util.c
ree310eb r601733d 498 498 return(c); 499 499 } 500 return( -1);500 return(OWL_COLOR_INVALID); 501 501 } 502 502 -
variable.c
r52f8dd6 r451db9e 84 84 85 85 OWLVAR_BOOL( "sepbar_disable" /* %OwlVarStub */, 0, 86 "disable printing information in the sep erator bar", "" ),86 "disable printing information in the separator bar", "" ), 87 87 88 88 OWLVAR_BOOL( "smartstrip" /* %OwlVarStub */, 1, … … 142 142 "location of users in your .anyone file. If a user is present\n" 143 143 "but sent no login message, or a user is not present that sent no\n" 144 "logout message a pseudo login or logout message wil be created\n",144 "logout message, a pseudo login or logout message wil be created\n", 145 145 NULL, owl_variable_pseudologins_set, NULL), 146 146 … … 177 177 "off,middle,on", 178 178 NULL, owl_variable_disable_ctrl_d_set, NULL), 179 180 OWLVAR_BOOL( "_burningears" /* %OwlVarStub:burningears */, 0,181 "[NOT YET IMPLEMENTED] beep on messages matching patterns", "" ),182 183 OWLVAR_BOOL( "_summarymode" /* %OwlVarStub:summarymode */, 0,184 "[NOT YET IMPLEMENTED]", "" ),185 179 186 180 OWLVAR_PATH( "logpath" /* %OwlVarStub */, "~/zlog/people", … … 318 312 NULL /* use default for get */ 319 313 ), 314 315 OWLVAR_INT( "typewindelta" /* %OwlVarStub */, 0, 316 "number of lines to add to the typing window when in use", 317 "On small screens you may want the typing window to\n" 318 "auto-hide when not entering a command or message.\n" 319 "This variable is the number of lines to add to the\n" 320 "typing window when it is in use; you can then set\n" 321 "typewinsize to 1.\n\n" 322 "This works a lot better with a non-default scrollmode;\n" 323 "try :set scrollmode pagedcenter.\n"), 320 324 321 325 OWLVAR_ENUM( "scrollmode" /* %OwlVarStub */, OWL_SCROLLMODE_NORMAL, -
zephyr.c
r02f55dc r451db9e 806 806 if (numlocs==0) { 807 807 myuser=short_zuser(user); 808 sprintf(out, "%s: Hidden or not logged -in\n", myuser);808 sprintf(out, "%s: Hidden or not logged in\n", myuser); 809 809 owl_free(myuser); 810 810 return; … … 1008 1008 #ifdef HAVE_LIBZEPHYR 1009 1009 int ret, num, i, one; 1010 int buffsize; 1010 1011 ZSubscription_t sub; 1011 char *out , *tmpbuff;1012 char *out; 1012 1013 one=1; 1013 1014 … … 1015 1016 if (ret==ZERR_TOOMANYSUBS) { 1016 1017 return(owl_strdup("Zephyr: too many subscriptions\n")); 1017 } else if (ret ) {1018 } else if (ret || (num <= 0)) { 1018 1019 return(owl_strdup("Zephyr: error retriving subscriptions\n")); 1019 1020 } 1020 1021 1021 out=owl_malloc(num*500);1022 tmpbuff=owl_malloc(num*500);1022 buffsize = (num + 1) * 50; 1023 out=owl_malloc(buffsize); 1023 1024 strcpy(out, ""); 1024 1025 for (i=0; i<num; i++) { 1025 1026 if ((ret = ZGetSubscriptions(&sub, &one)) != ZERR_NONE) { 1026 1027 owl_free(out); 1027 owl_free(tmpbuff);1028 1028 ZFlushSubscriptions(); 1029 1029 out=owl_strdup("Error while getting subscriptions\n"); 1030 1030 return(out); 1031 1031 } else { 1032 sprintf(tmpbuff, "<%s,%s,%s>\n%s", sub.zsub_class, sub.zsub_classinst, sub.zsub_recipient, out); 1032 int tmpbufflen; 1033 char *tmpbuff; 1034 tmpbuff = owl_sprintf("<%s,%s,%s>\n%s", sub.zsub_class, sub.zsub_classinst, sub.zsub_recipient, out); 1035 tmpbufflen = strlen(tmpbuff) + 1; 1036 if (tmpbufflen > buffsize) { 1037 char *out2; 1038 buffsize = tmpbufflen * 2; 1039 out2 = owl_realloc(out, buffsize); 1040 if (out2 == NULL) { 1041 owl_free(out); 1042 owl_free(tmpbuff); 1043 ZFlushSubscriptions(); 1044 out=owl_strdup("Realloc error while getting subscriptions\n"); 1045 return(out); 1046 } 1047 out = out2; 1048 } 1033 1049 strcpy(out, tmpbuff); 1034 }1035 }1036 1037 owl_free(tmpbuff); 1050 owl_free(tmpbuff); 1051 } 1052 } 1053 1038 1054 ZFlushSubscriptions(); 1039 1055 return(out); -
zwrite.c
r7b1d048 r3f3ee61 11 11 int argc, badargs, myargc; 12 12 char **argv, **myargv; 13 char *zsigproc, *zsigowlvar, *zsigzvar, *ptr;14 struct passwd *pw;15 13 16 14 badargs=0; … … 139 137 /* z->message is allowed to stay NULL */ 140 138 139 return(0); 140 } 141 142 void owl_zwrite_populate_zsig(owl_zwrite *z) 143 { 144 char *zsigproc, *zsigowlvar, *zsigzvar, *ptr; 145 struct passwd *pw; 146 141 147 /* get a zsig, if not given */ 142 148 if (z->zsig==NULL) { … … 184 190 } 185 191 } 186 187 return(0);188 192 } 189 193 … … 285 289 owl_zwrite_set_message(&z, msg); 286 290 } 291 owl_zwrite_populate_zsig(&z); 287 292 owl_zwrite_send_message(&z); 288 293 owl_zwrite_free(&z); … … 358 363 return(0); 359 364 } 360 365 361 366 void owl_zwrite_free(owl_zwrite *z) 362 367 {
Note: See TracChangeset
for help on using the changeset viewer.