Changes in / [157b042:8d07892a]


Ignore:
Files:
1 added
2 deleted
29 edited

Legend:

Unmodified
Added
Removed
  • .gitignore

    r10e0ab8 ree0574c  
     1*.a
     2autom4te.cache
     3barnowl
     4blib
     5config.cache
     6config.h
     7config.log
     8config.status
     9configure
     10core
     11jabber.log
     12Makefile
     13META.yml
     14*.o
     15owl_prototypes.h
     16owl_prototypes.h.new
     17*.par
     18perlglue.c
     19perlwrap.c
     20pm_to_blib
     21TAGS
     22tester
     23varstubs.c
    124*~
    225libfaim/rxhandlers.c.orig
  • ChangeLog

    rd7a3188 r43a306c  
    1 $Id$
     11.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
     121.0.2.1
     13 * Fix :reload-module's interactions with PAR modules
     14
     151.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
    232
    3331.0.1
  • Makefile.in

    r8363d50 r7e78e49  
    1111CC=@CC@
    1212LIBS=@LIBS@ -L./libfaim -lfaim
    13 CFLAGS=@CFLAGS@ -I. -I./libfaim -DDATADIR=\"${datadir}\" -DOWL_SVN_REVNO=$(shell ./svkversion)
     13CFLAGS=@CFLAGS@ -I./libfaim -DDATADIR=\"${datadir}\"
    1414LDFLAGS=@LDFLAGS@
    1515XSUBPPDIR=@XSUBPPDIR@
     
    129129install: all installdirs
    130130        ${INSTALL_PROGRAM} $(EXE) ${DESTDIR}${bindir}/$(EXE)
    131         ${INSTALL_DATA} doc/owl.1 ${DESTDIR}${mandir}/man1/barnowl.1
     131        ${INSTALL_DATA} doc/barnowl.1 ${DESTDIR}${mandir}/man1/barnowl.1
    132132        ${INSTALL} -d ${DESTDIR}${datadir}/lib
    133133        ${INSTALL} -d ${DESTDIR}${datadir}/modules
  • cmd.c

    r34509d5 rc4ba74d  
    6767}
    6868
     69char *_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
    6982char *owl_cmddict_execute(owl_cmddict *cd, owl_context *ctx, char *cmdbuff) {
    7083  char **argv;
     
    7285  char *tmpbuff;
    7386  char *retval = NULL;
    74   owl_cmd *cmd;
    7587
    7688  tmpbuff=owl_strdup(cmdbuff);
     
    8597  if (argc < 1) return(NULL);
    8698
    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
    93101  owl_parsefree(argv, argc);
    94102  owl_free(tmpbuff);
    95103  sepbar(NULL);
     104  return retval;
     105}
     106
     107char *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);
    96128  return retval;
    97129}
  • commands.c

    r864ed35 r451db9e  
    5151              "when owl is started and a logout notification is sent when owl\n"
    5252              "is exited.  This behavior can be changed with the 'startuplogin'\n"
    53               "and 'shudownlogout' variables.  If a tty is specified for zlog in\n"
     53              "and 'shutdownlogout' variables.  If a tty is specified for zlog in\n"
    5454              "then the owl variable 'tty' will be set to that string, causing\n"
    5555              "it to be used as the zephyr location tty.\n"),
     
    193193  OWLCMD_ARGS("subscribe", owl_command_subscribe, OWL_CTX_ANY,
    194194              "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"),
    202203  OWLCMD_ALIAS("sub", "subscribe"),
    203204
    204205  OWLCMD_ARGS("unsubscribe", owl_command_unsubscribe, OWL_CTX_ANY,
    205206              "unsubscribe from a zephyr class, instance, recipient",
    206               "unsubscribe [-t] <class> <instance> [recipient]",
     207              "unsubscribe [-t] <class> [instance [recipient]]",
    207208              "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"),
    213215  OWLCMD_ALIAS("unsub", "unsubscribe"),
    214216
     
    245247              "delete a buddy from a buddylist",
    246248              "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"),
    248250
    249251  OWLCMD_ARGS("join", owl_command_join, OWL_CTX_INTERACTIVE,
     
    263265              "zpunt <instance>",
    264266              "The zpunt command will supress message to the specified\n"
    265               "zephyr triplet.  In the second usage messages as supressed\n"
     267              "zephyr triplet.  In the second usage messages are suppressed\n"
    266268              "for class MESSAGE and the named instance.\n\n"
    267269              "SEE ALSO:  zunpunt, show zpunts\n"),
     
    271273              "zunpunt <class> <instance> [recipient]\n"
    272274              "zunpunt <instance>",
    273               "The zunpunt command will allow messages that were previosly\n"
     275              "The zunpunt command will allow messages that were previously\n"
    274276              "suppressed to be received again.\n\n"
    275277              "SEE ALSO:  zpunt, show zpunts\n"),
     
    545547              "    true\n"
    546548              "    false\n"
    547               "Spaces must be present before and after parenthesis.  If the\n"
     549              "Spaces must be present before and after parentheses.  If the\n"
    548550              "optional color arguments are used they specifies the colors that\n"
    549551              "messages matching this filter should be displayed in.\n\n"
     
    592594              "If the curmsg is a personal message narrow\n"
    593595              "   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 then narrow\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"
    597599              "    to the class.\n"
    598               "If the curmsg is a class message and '-i' is specied\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"),
    600602
    601603  OWLCMD_ARGS("smartfilter", owl_command_smartfilter, OWL_CTX_INTERACTIVE,
     
    604606              "If the curmsg is a personal message, the filter is\n"
    605607              "   the conversation with that user.\n"
    606               "If the curmsg is a class message, instance foo, recip *\n"
    607               "   message, the filter is the class, inst.\n"
     608              "If the curmsg is a <MESSAGE, foo, *>\n"
     609              "   message, the filter is to that instance.\n"
    608610              "If the curmsg is a class message, the filter is that class.\n"
    609611              "If the curmsg is a class message and '-i' is specied\n"
    610               "    the filter is that <class,instance> pair\n"),
     612              "    the filter is to that class and instance.\n"),
    611613
    612614  OWLCMD_ARGS("viewclass", owl_command_viewclass, OWL_CTX_INTERACTIVE,
     
    674676              "If no message id is specified the current message is marked\n"
    675677              "for deletion.  Otherwise the message with the given message\n"
    676               "id is marked for deltion.\n"
     678              "id is marked for deletion.\n"
    677679              "If '--no-move' is specified, don't move after deletion.\n"
    678680              "If 'trash' is specified, deletes all trash/auto messages\n"
     
    688690              "If no message id is specified the current message is\n"
    689691              "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"
    691693              "If '--no-move' is specified, don't move after deletion.\n"
    692694              "If 'view' is specified, undeletes all messages\n"
     
    713715              "getvar <varname>", ""),
    714716
     717  OWLCMD_ARGS("getfilter", owl_command_getfilter, OWL_CTX_INTERACTIVE,
     718              "returns the definition of a filter",
     719              "getfilter <filtername>", ""),
     720
    715721  OWLCMD_ARGS("getstyle", owl_command_getstyle, OWL_CTX_INTERACTIVE,
    716722              "returns the name of the style for the current view",
     
    723729              "specified string and move the cursor there.  If no string\n"
    724730              "argument is supplied then the previous one is used.  By\n"
    725               "default searches are done fowards, if -r is used the search\n"
     731              "default searches are done forwards; if -r is used the search\n"
    726732              "is performed backwards"),
    727733
     
    732738          "argument and makes it the default argument for future\n"
    733739          "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."),
    735741
    736742  OWLCMD_ARGS("aimlogin", owl_command_aimlogin, OWL_CTX_ANY,
     
    750756
    751757  OWLCMD_ARGS("message", owl_command_message, OWL_CTX_ANY,
    752               "Display an informatative message",
     758              "Display an informative message",
    753759              "message <message>",
    754760              ""),
     
    17391745char *owl_command_subscribe(int argc, char **argv, char *buff)
    17401746{
    1741   char *recip="";
     1747  char *class, *instance, *recip="";
    17421748  int temp=0;
    17431749  int ret=0;
    1744  
    1745   if (argc<3) {
     1750
     1751  if (argc < 2) {
    17461752    owl_function_makemsg("Not enough arguments to the subscribe command");
    17471753    return(NULL);
     
    17551761    argv++;
    17561762  }
    1757   if (argc<2) {
     1763  if (argc < 1) {
    17581764    owl_function_makemsg("Not enough arguments to the subscribe command");
    17591765    return(NULL);
    17601766  }
    17611767
    1762   if (argc>3) {
     1768  if (argc > 3) {
    17631769    owl_function_makemsg("Too many arguments to the subscribe command");
    17641770    return(NULL);
    17651771  }
    17661772
    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) {
    17681782    recip="";
    17691783  } else if (argc==3) {
     
    17711785  }
    17721786
    1773   ret = owl_function_subscribe(argv[0], argv[1], recip);
     1787  ret = owl_function_subscribe(class, instance, recip);
    17741788  if (!temp && !ret) {
    1775     owl_zephyr_addsub(NULL, argv[0], argv[1], recip);
     1789    owl_zephyr_addsub(NULL, class, instance, recip);
    17761790  }
    17771791  return(NULL);
     
    17811795char *owl_command_unsubscribe(int argc, char **argv, char *buff)
    17821796{
    1783   char *recip="";
     1797  char *class, *instance, *recip="";
    17841798  int temp=0;
    17851799
    1786   if (argc<3) {
     1800  if (argc < 2) {
    17871801    owl_function_makemsg("Not enough arguments to the unsubscribe command");
    17881802    return(NULL);
     
    17961810    argv++;
    17971811  }
    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) {
    18041818    owl_function_makemsg("Too many arguments to the unsubscribe command");
    18051819    return(NULL);
    18061820  }
    18071821
    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) {
    18091831    recip="";
    18101832  } else if (argc==3) {
     
    18121834  }
    18131835
    1814   owl_function_unsubscribe(argv[0], argv[1], recip);
     1836  owl_function_unsubscribe(class, instance, recip);
    18151837  if (!temp) {
    1816     owl_zephyr_delsub(NULL, argv[0], argv[1], recip);
     1838    owl_zephyr_delsub(NULL, class, instance, recip);
    18171839  }
    18181840  return(NULL);
     
    24612483}
    24622484
     2485char *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
    24632499char *owl_command_search(int argc, char **argv, char *buff)
    24642500{
     
    25802616  cmd = owl_message_get_attribute_value(m, "yescommand");
    25812617  if(!cmd) {
    2582     owl_function_error("No yes command!");
     2618    owl_function_error("No 'yes' command!");
    25832619    return;
    25842620  }
     
    26142650  cmd = owl_message_get_attribute_value(m, "nocommand");
    26152651  if(!cmd) {
    2616     owl_function_error("No no command!");
     2652    owl_function_error("No 'no' command!");
    26172653    return;
    26182654  }
  • editwin.c

    r2d4ff14 re9bb404  
    330330{
    331331  int i, z;
    332  
     332
    333333  if ((e->bufflen + n) > (e->allocated - 5)) {
    334334    _owl_editwin_addspace(e);
    335335  }
    336336
     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
    337345  e->bufflen += n;
    338346  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
    344348}
    345349
     
    426430
    427431  /* 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);
    431433
    432434  /* insert the new character */
     
    435437  }
    436438
    437   /* housekeeping */
    438   e->bufflen += len;
    439   e->buff[e->bufflen] = '\0';
    440  
    441439  /* advance the cursor */
    442440  z += len;
  • filter.c

    raf1920fd rcdc6ff1  
    2929  while ( argc>=2 && ( !strcmp(argv[0], "-c") ||
    3030                       !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) {
    3232      owl_function_error("The color '%s' is not available, using default.", argv[1]);
    3333    } else {
     
    212212
    213213
    214 void owl_filter_print(owl_filter *f, char *out)
    215 {
    216   strcpy(out, owl_filter_get_name(f));
    217   strcat(out, ": ");
     214char* owl_filter_print(owl_filter *f)
     215{
     216  GString *out = g_string_new("");
    218217
    219218  if (f->fgcolor!=OWL_COLOR_DEFAULT) {
    220     strcat(out, "-c ");
     219    g_string_append(out, "-c ");
    221220    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));
    223222    }
    224223    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, " ");
    230227  }
    231228  if (f->bgcolor!=OWL_COLOR_DEFAULT) {
    232     strcat(out, "-b ");
     229    g_string_append(out, "-b ");
    233230    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));
    235232    }
    236233    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);
    246244}
    247245
     
    249247int owl_filter_equiv(owl_filter *a, owl_filter *b)
    250248{
    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;
    258263}
    259264
  • filterelement.c

    r81655f8 r0504f63  
    126126/* Print methods */
    127127
    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)
     128static void owl_filterelement_print_true(owl_filterelement *fe, GString *buf)
     129{
     130  g_string_append(buf, "true");
     131}
     132
     133static void owl_filterelement_print_false(owl_filterelement *fe, GString *buf)
     134{
     135  g_string_append(buf, "false");
     136}
     137
     138static void owl_filterelement_print_re(owl_filterelement *fe, GString *buf)
    139139{
    140140  char *re, *q;
    141   strcat(buf, fe->field);
    142   strcat(buf, " ");
     141  g_string_append(buf, fe->field);
     142  g_string_append(buf, " ");
    143143
    144144  re = owl_regex_get_string(&(fe->re));
    145145  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
     151static 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
     157static 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
     163static void owl_filterelement_print_group(owl_filterelement *fe, GString *buf)
     164{
     165  g_string_append(buf, "( ");
    166166  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
     170static void owl_filterelement_print_or(owl_filterelement *fe, GString *buf)
    171171{
    172172  owl_filterelement_print(fe->left, buf);
    173   strcat(buf, " or ");
     173  g_string_append(buf, " or ");
    174174  owl_filterelement_print(fe->right, buf);
    175175}
    176176
    177 static void owl_filterelement_print_and(owl_filterelement *fe, char *buf)
     177static void owl_filterelement_print_and(owl_filterelement *fe, GString *buf)
    178178{
    179179  owl_filterelement_print(fe->left, buf);
    180   strcat(buf, " and ");
     180  g_string_append(buf, " and ");
    181181  owl_filterelement_print(fe->right, buf);
    182182}
    183183
    184 static void owl_filterelement_print_not(owl_filterelement *fe, char *buf)
    185 {
    186   strcat(buf, " not ");
     184static void owl_filterelement_print_not(owl_filterelement *fe, GString *buf)
     185{
     186  g_string_append(buf, " not ");
    187187  owl_filterelement_print(fe->left, buf);
    188188}
     
    321321}
    322322
    323 void owl_filterelement_print(owl_filterelement *fe, char *buf)
     323void owl_filterelement_print(owl_filterelement *fe, GString *buf)
    324324{
    325325  if(!fe || !fe->print_elt) return;
  • functions.c

    r4367915 r3f3ee61  
    2525  return owl_cmddict_execute(owl_global_get_cmddict(&g),
    2626                             owl_global_get_context(&g), cmdbuff);
     27}
     28
     29char *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);
    2734}
    2835
     
    283290  owl_editwin_set_dotsend(e);
    284291  strcpy(buff, "----> ");
    285   strcat(buff, line);
     292  strncat(buff, line, 1016);
    286293  strcat(buff, "\n");
    287294  owl_editwin_set_locktext(e, buff);
     
    371378  /* create the zwrite and send the message */
    372379  owl_zwrite_create_from_line(&z, line);
     380  owl_zwrite_populate_zsig(&z);
    373381  if (msg) {
    374382    owl_zwrite_set_message(&z, msg);
     
    409417  /* create the zwrite and send the message */
    410418  owl_zwrite_create_from_line(&z, line);
     419  owl_zwrite_populate_zsig(&z);
    411420  if (msg) {
    412421    owl_zwrite_set_message(&z, msg);
     
    415424  mymsg=owl_zwrite_get_message(&z);
    416425#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);
    418435  ret=owl_zcrypt_encrypt(cryptmsg, mymsg, owl_zwrite_get_class(&z), owl_zwrite_get_instance(&z));
    419436  if (ret) {
     
    421438    owl_function_beep();
    422439    owl_free(cryptmsg);
     440    owl_zwrite_free(&z);
    423441    return;
    424442  }
     
    16331651  }
    16341652
    1635   if (owl_message_is_type_aim(m)) {
    1636     owl_fmtext_append_bold(&fm, "\nAIM Specific Information:\n");
    1637   }
    1638 
    16391653  owl_fmtext_append_bold(&fm, "\nOwl Message Attributes:\n");
    16401654  owl_message_attributes_tofmtext(m, &attrfm);
     
    19651979 
    19661980
    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 
    19751981  owl_fmtext_append_normal(&fm, "\nAIM Status:\n");
    19761982  owl_fmtext_append_normal(&fm, "  Logged in: ");
     
    20252031void owl_function_reply(int type, int enter)
    20262032{
    2027   char *buff=NULL, *oldbuff;
     2033  char *buff=NULL;
    20282034  owl_message *m;
    20292035  owl_filter *f;
     
    20322038    owl_function_error("No message selected");
    20332039  } else {
    2034     char *class, *inst, *to, *cc=NULL;
    20352040   
    20362041    m=owl_view_get_element(owl_global_get_current_view(&g), owl_global_get_curmsg(&g));
     
    20492054    }
    20502055
    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;
    21472062    }
    21482063
     
    21512066        return;
    21522067    }
    2153    
     2068
    21542069    if (enter) {
    21552070      owl_history *hist = owl_global_get_cmd_history(&g);
     
    24042319      return;
    24052320    }
    2406     if (owl_util_string_to_color(argv[3])==-1) {
     2321    if (owl_util_string_to_color(argv[3])==OWL_COLOR_INVALID) {
    24072322      owl_function_error("The color '%s' is not available.", argv[3]);
    24082323      return;
     
    24192334      return;
    24202335    }
    2421     if (owl_util_string_to_color(argv[3])==-1) {
     2336    if (owl_util_string_to_color(argv[3])==OWL_COLOR_INVALID) {
    24222337      owl_function_error("The color '%s' is not available.", argv[3]);
    24232338      return;
     
    25272442{
    25282443  owl_filter *f;
    2529   char buff[5000];
     2444  char *buff, *tmp;
    25302445
    25312446  f=owl_global_get_filter(&g, name);
     
    25342449    return;
    25352450  }
    2536   owl_filter_print(f, buff);
     2451  tmp = owl_filter_print(f);
     2452  buff = owl_sprintf("%s: %s", owl_filter_get_name(f), tmp);
    25372453  owl_function_popless_text(buff);
     2454  owl_free(buff);
     2455  owl_free(tmp);
    25382456}
    25392457
     
    25432461  owl_list *fl;
    25442462  char buff[5000];
     2463  char *tmp;
    25452464  owl_fmtext fm;
    25462465  int i, j;
     
    25562475    snprintf(buff, sizeof(buff), "[% 2d] ", i+1);
    25572476    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);
    25592480    owl_fmtext_append_normal(&fm, buff);
    25602481  }
     
    29532874  }
    29542875
    2955   if (owl_util_string_to_color(fgcolor)==-1) {
     2876  if (owl_util_string_to_color(fgcolor)==OWL_COLOR_INVALID) {
    29562877    owl_function_error("No color named '%s' avilable.", fgcolor);
    29572878    return(-1);
     
    29602881
    29612882  if (bgcolor != NULL) {
    2962     if (owl_util_string_to_color(bgcolor)==-1) {
     2883    if (owl_util_string_to_color(bgcolor)==OWL_COLOR_INVALID) {
    29632884      owl_function_error("No color named '%s' avilable.", bgcolor);
    29642885      return(-1);
     
    35123433  FILE *file;
    35133434  char buff[LINE];
     3435  int fail_silent = 0;
    35143436
    35153437  if (!filename) {
     3438    fail_silent = 1;
    35163439    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");
    35213442  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    }
    35233446    return;
    35243447  }
  • glib_compat.c

    rc60ade2 r731dd1e  
    1 #include <owl.h>
     1#include "owl.h"
    22
    33#if (GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION < 14)
  • global.c

    r9f4e3f8 rda466e0  
    310310
    311311void 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
    312316  g->typwinactive=1;
    313317}
    314318
    315319void 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
    316324  g->typwinactive=0;
    317325}
  • help.c

    rec53338 r0398d55  
    5757     "    M-n           View zephyrs in selected conversation\n"
    5858     "    M-N           View zephyrs in selected converstaion of instance\n"
     59     "    M-p           View only personal zephyrs\n"
    5960     "    V             Change to back to home view ('all' by default)\n"
    6061     "    v             Start a view command\n"
  • logging.c

    raf1920fd rd8671a1  
    5151  if (!owl_global_is_loglogins(&g) && owl_message_is_loginout(m)) return(0);
    5252     
    53   /* check for nolog */
    54   if (!strcasecmp(owl_message_get_opcode(m), "nolog") || !strcasecmp(owl_message_get_instance(m), "nolog")) return(0);
    55 
    5653  /* check direction */
    5754  if ((owl_global_get_loggingdirection(&g)==OWL_LOGGING_DIRECTION_IN) && owl_message_is_direction_out(m)) {
     
    154151  } else if (owl_message_is_type_jabber(m)) {
    155152    to = owl_sprintf("jabber:%s", owl_message_get_recipient(m));
     153    owl_text_tr(to, '/', '_');
    156154  } else if (owl_message_is_type_aim(m)) {
    157155    char *temp2;
  • message.c

    r18108b1e r147d880  
    4242  owl_message_set_direction_none(m);
    4343  m->delete=0;
    44   m->zwriteline=NULL;
    4544
    4645  owl_message_set_hostname(m, "");
     
    485484char *owl_message_get_zwriteline(owl_message *m)
    486485{
    487   if(!m->zwriteline)
    488     return "";
    489   return(m->zwriteline);
     486  char *z = owl_message_get_attribute_value(m, "zwriteline");
     487  if (!z) return "";
     488  return z;
    490489}
    491490
    492491void owl_message_set_zwriteline(owl_message *m, char *line)
    493492{
    494   if(m->zwriteline) owl_free(m->zwriteline);
    495   m->zwriteline=owl_strdup(line);
     493  owl_message_set_attribute(m, "zwriteline", line);
    496494}
    497495
     
    615613      return(0);
    616614    }
    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);
    641615  }
    642616  return(0);
     
    884858  }
    885859
    886   m->zwriteline=owl_strdup("");
    887 
    888860  /* save the hostname */
    889861  owl_function_debugmsg("About to do gethostbyaddr");
     
    966938  }
    967939
    968   m->zwriteline=owl_strdup("");
    969 
    970940  owl_message_set_body(m, "<uninitialized>");
    971941
     
    999969  owl_message_set_opcode(m, owl_zwrite_get_opcode(&z));
    1000970  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);
    1002972  owl_message_set_body(m, body);
    1003973  owl_message_set_zsig(m, zsig);
     
    10401010#endif
    10411011  if (m->timestr) owl_free(m->timestr);
    1042   if (m->zwriteline) owl_free(m->zwriteline);
    10431012
    10441013  /* free all the attributes */
  • owl.c

    r628c897 r7ba9ead9  
    120120      exit(0);
    121121    } else {
    122       fprintf(stderr, "Uknown argument\n");
     122      fprintf(stderr, "Unknown argument\n");
    123123      usage();       
    124124      exit(1);
     
    603603      }
    604604    }
    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);
    617609  /* log the message if we need to */
    618610  owl_log_message(m);
  • owl.h

    rd7a3188 r43a306c  
    2020#include <signal.h>
    2121#include <termios.h>
    22 #include <libfaim/aim.h>
     22#include "libfaim/aim.h"
    2323#include <wchar.h>
    2424#include "config.h"
     
    5151#define _STRINGIFY(x) #x
    5252
    53 #ifndef OWL_SVN_REVNO
    54 #define OWL_SVN_REVNO ????
    55 #endif
    56 
    5753#ifndef OWL_VERSION_STRING
    58 #define OWL_VERSION_STRING "1.0.1"
     54#define OWL_VERSION_STRING "1.0.3"
    5955#endif
    6056
     
    10096#define OWL_COLOR_WHITE     7
    10197#define OWL_COLOR_DEFAULT   -1
     98#define OWL_COLOR_INVALID   -2
    10299
    103100#define OWL_EDITWIN_STYLE_MULTILINE 0
     
    341338  char *timestr;
    342339  time_t time;
    343   char *zwriteline;
    344340} owl_message;
    345341
     
    405401  int (*match_message)(struct _owl_filterelement *fe, owl_message *m);
    406402  /* 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);
    408404  /* Operands for and,or,not*/
    409405  struct _owl_filterelement *left, *right;
  • perl/lib/BarnOwl/ModuleLoader.pm

    r965e14d r41bbb8a  
    88use PAR (BarnOwl::get_config_dir() . "/modules/*.par");
    99
     10our %modules;
     11
    1012sub load_all {
     13    my $class = shift;
     14    $class->rescan_modules;
    1115    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(\&register_keybindings);
     24}
     25
     26sub rescan_modules {
    1227    PAR->import(BarnOwl::get_data_dir() . "/modules/*.par");
    1328    PAR->import(BarnOwl::get_config_dir() . "/modules/*.par");
    14     my %modules;
    1529    my @modules;
     30
     31    %modules = ();
    1632
    1733    my @moddirs = ();
     
    3753        }
    3854    }
    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
     57sub 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;
    4372        }
    4473    }
    4574
    46     $BarnOwl::Hooks::startup->add(\&register_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
     85sub 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);
    4793}
    4894
     
    5298                           usage   => 'reload-modules',
    5399                           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}
    54105                          });
    55106}
     
    63114    $INC{$_} = 1 for (qw(BarnOwl.pm BarnOwl/Hooks.pm
    64115                         BarnOwl/Message.pm BarnOwl/Style.pm));
     116    $class->run_startup_hooks();
     117}
    65118
    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;
     119sub run_startup_hooks {
     120    my $class = shift;
    71121    local $SIG{__WARN__} = \&squelch_redefine;
    72122    $class->load_all;
  • perl/modules/IRC/lib/BarnOwl/Message/IRC.pm

    r8df6cbb r38a7f22  
    2020    my $inst = shift;
    2121
    22     my ($filter, $ftext);
     22    my $filter;
     23    my @filter;
    2324
    2425    if($self->is_private) {
     
    3031        }
    3132        $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);
    3639        return $filter;
    3740    } else {
     
    4346        if ($inst && $self->body =~ /^(\S+):/) {
    4447            $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{)});
    4653        } else {
    4754            $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\$");
    4957        }
    50         BarnOwl::filter("$filter $ftext");
     58        BarnOwl::command("filter", "$filter", @filter);
    5159        return $filter;
    5260    }
     
    5664sub network {shift->{network}}
    5765sub channel {shift->{channel}}
     66sub action {shift->{action}}
     67sub reason {shift->{reason}}
    5868
    5969# display
     
    6575sub login_type {
    6676    my $self = shift;
    67     return " (" . ($self->is_login ? "JOIN" : "PART") . ")";
     77    return " (" . uc $self->action . ")";
    6878}
    6979
    70 sub login_extra { shift->channel; }
    71 
     80sub login_extra {
     81    my $self = shift;
     82    if ($self->action eq "quit") {
     83        return $self->reason;
     84    } else {
     85        return $self->channel;
     86    }
     87}
    7288
    73891;
  • perl/modules/IRC/lib/BarnOwl/Module/IRC.pm

    rf094fc4 r167044b  
    117117    BarnOwl::new_command('irc-who'        => \&cmd_who);
    118118    BarnOwl::new_command('irc-stats'      => \&cmd_stats);
    119 }
    120 
    121 $BarnOwl::Hooks::startup->add(\&startup);
    122 $BarnOwl::Hooks::shutdown->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');
    124124
    125125################################################################################
     
    262262    my $conn = get_connection(\@_);
    263263    my $chan = get_channel(\@_) || die("Usage: $cmd <channel>\n");
     264    $conn->names_tmp([]);
    264265    $conn->conn->names($chan);
    265266}
     
    299300    my $type = shift || die("Usage: $cmd <chiklmouy> [server] \n");
    300301    $conn->conn->stats($type, @_);
     302}
     303
     304sub cmd_topic {
     305    my $cmd = shift;
     306    my $conn = get_connection(\@_);
     307    $conn->conn->topic(@_);
    301308}
    302309
  • perl/modules/IRC/lib/BarnOwl/Module/IRC/Connection.pm

    r8faab0c r4789b17  
    1818
    1919use 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));
    2121our @EXPORT_OK = qw(&is_private);
    2222
     
    4545    $self->motd("");
    4646    $self->connected(0);
     47    $self->names_tmp(0);
     48    $self->whois_tmp("");
    4749
    4850    $self->conn->add_handler(376 => sub { shift; $self->on_connect(@_) });
     
    6264    $self->conn->add_handler(join      => sub { shift; $self->on_join(@_) });
    6365    $self->conn->add_handler(part      => sub { shift; $self->on_part(@_) });
     66    $self->conn->add_handler(quit      => sub { shift; $self->on_quit(@_) });
    6467    $self->conn->add_handler(disconnect => sub { shift; $self->on_disconnect(@_) });
    6568    $self->conn->add_handler(nicknameinuse => sub { shift; $self->on_nickinuse(@_) });
    6669    $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(@_) });
    6775
    6876    return $self;
     
    126134            BarnOwl::Style::boldify('IRC ' . $evt->type . ' message from '
    127135                . $self->alias) . "\n"
    128             . strip_irc_formatting(join '\n', $evt->args));
     136            . strip_irc_formatting(join ' ', cdr($evt->args)));
    129137}
    130138
     
    157165    my $msg = $self->new_message($evt,
    158166        loginout   => 'login',
     167        action     => 'join',
    159168        channel    => $evt->to,
    160         replycmd => 'irc-msg -a ' . $self->alias . ' ' . $evt->nick,
     169        replycmd => 'irc-msg -a ' . $self->alias . ' ' . join(' ', $evt->to),
    161170        replysendercmd => 'irc-msg -a ' . $self->alias . ' ' . $evt->nick
    162171        );
     
    168177    my $msg = $self->new_message($evt,
    169178        loginout   => 'logout',
     179        action     => 'part',
    170180        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
     187sub 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],
    171194        replycmd => 'irc-msg -a ' . $self->alias . ' ' . $evt->nick,
    172195        replysendercmd => 'irc-msg -a ' . $self->alias . ' ' . $evt->nick
     
    193216}
    194217
     218sub 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
     230sub 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
     241sub 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
     247sub 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
     258sub 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
     266sub 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
    195275sub on_event {
    196276    my ($self, $evt) = @_;
     277    return on_whois(@_) if ($evt->type =~ /^whois/);
    197278    BarnOwl::admin_message("IRC",
    198279            "[" . $self->alias . "] Unhandled IRC event of type " . $evt->type . ":\n"
     
    200281        if BarnOwl::getvar('irc:spew') eq 'on';
    201282}
    202 
    203283
    204284################################################################################
     
    214294   
    215295    my @pieces = split /\cB/, $body;
    216      my $out;
     296    my $out = '';
    217297    while(@pieces) {
    218298        $out .= shift @pieces;
  • perl/modules/Jabber/lib/BarnOwl/Message/Jabber.pm

    r693c8f2 r96134cb  
    2222sub subject { shift->{subject} };
    2323sub status { shift->{status} }
     24
     25sub login_type {
     26    my $self = shift;
     27    my $type = $self->jtype;
     28    return " ($type)" if $type;
     29}
    2430
    2531sub login_extra {
     
    5056    my $inst = shift;
    5157
    52     my ($filter, $ftext);
     58    my $filter;
    5359
    5460    if($self->jtype eq 'chat') {
     
    6369        my $room = $self->room;
    6470        $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\$");
    6773        return $filter;
    6874    } elsif ($self->login ne 'none') {
     
    7783    $user   = Net::Jabber::JID->new($user)->GetJID( $inst ? 'full' : 'base' );
    7884    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[ ) ) ]);
    8389    return $filter;
    8490
    8591}
    8692
     93sub 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
     116sub 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
     133sub 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}
    87147
    88148=head1 SEE ALSO
  • perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm

    r8af89a7 re979da9  
    6868        register_keybindings();
    6969        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");
    7272        $vars{show} = '';
    7373        BarnOwl::new_variable_bool("jabber:show_offline_buddies",
    7474                                   { default => 1,
    7575                                     summary => 'Show offline or pending buddies.'});
     76        BarnOwl::new_variable_bool("jabber:show_logins",
     77                                   { default => 0,
     78                                     summary => 'Show login/logout messages.'});
    7679        BarnOwl::new_variable_bool("jabber:spew",
    7780                                   { default => 0,
     
    8588                                    summary => 'After minutes idle, auto extended away.'
    8689                                });
     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";
    8796    } else {
    8897        # Our owl doesn't support queue_message. Unfortunately, this
     
    92101}
    93102
    94 $BarnOwl::Hooks::startup->add(\&onStart);
     103$BarnOwl::Hooks::startup->add("BarnOwl::Module::Jabber::onStart");
    95104
    96105sub onMainLoop {
     
    232241            summary => "Send a Jabber Message",
    233242            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>]"
    234250        }
    235251    );
     
    757773}
    758774
     775sub 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
    759802sub jroster_sub {
    760803    my $jid = shift;
     
    933976sub process_incoming_chat_message {
    934977    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    }
    937982}
    938983
     
    9891034
    9901035sub process_presence_available {
     1036    return unless (BarnOwl::getvar('jabber:show_logins') eq 'on');
    9911037    my ( $sid, $p ) = @_;
    992     my $from = $p->GetFrom();
     1038    my $from = $p->GetFrom('jid')->GetJID('base');
    9931039    my $to = $p->GetTo();
    9941040    my $type = $p->GetType();
    9951041    my %props = (
    9961042        to => $to,
    997         from => $from,
     1043        from => $p->GetFrom(),
    9981044        recipient => $to,
    9991045        sender => $from,
     
    10131059        $props{loginout} = 'logout';
    10141060    }
    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));
    10191062}
    10201063
     
    10991142sub j2hash {
    11001143    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};
    11101149
    11111150    my $jtype = $props{jtype} = $j->GetType();
     
    11201159    $props{subject}    = $j->GetSubject() if ( $j->DefinedSubject() );
    11211160    $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    }
    11231165    $props{error}      = $j->GetError() if ( $j->DefinedError() );
    11241166    $props{error_code} = $j->GetErrorCode() if ( $j->DefinedErrorCode() );
     
    11261168
    11271169    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} );
    11321170        $props{private} = 1;
    11331171
     
    11521190        my $nick = $props{nick} = $from->GetResource();
    11531191        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         }
    11671192
    11681193        $props{sender} = $nick || $room;
     
    11751200    }
    11761201    elsif ( $jtype eq 'normal' ) {
    1177         $props{replycmd}  = "";
    11781202        $props{private} = 1;
    11791203    }
    11801204    elsif ( $jtype eq 'headline' ) {
    1181         $props{replycmd} = "";
    11821205    }
    11831206    elsif ( $jtype eq 'error' ) {
    1184         $props{replycmd} = "";
    11851207        $props{body}     = "Error "
    11861208          . $props{error_code}
     
    11901212    }
    11911213
    1192     $props{replysendercmd} = $props{replycmd} unless $props{replysendercmd};
    11931214    return %props;
    11941215}
  • perlconfig.c

    rb67ab6b rc4ba74d  
    181181{
    182182  dSP ;
    183   int count, len;
     183  int count;
     184  unsigned int len;
    184185  SV *msgref, *srv;
    185186  char *out, *preout;
     
    421422}
    422423
     424/* Called on all new messages; receivemsg is only called on incoming ones */
     425void 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
    423435char *owl_perlconfig_perlcmd(owl_cmd *cmd, int argc, char **argv)
    424436{
     
    446458  if(SvTRUE(ERRSV)) {
    447459    owl_function_error("%s", SvPV(ERRSV, n_a));
    448     POPs;
     460    (void)POPs;
    449461  } else {
    450462    if(count != 1)
  • perlglue.xs

    rb67ab6b r740d5f7  
    1717         *************************************************************
    1818         * These functions, when they are intended to be user-visible,
    19          * are document in perlwrap.pm. If you add functions to this
     19         * are documented in perlwrap.pm. If you add functions to this
    2020         * file, add the appropriate documentation there!
    2121         *
     
    3333
    3434char *
    35 command(cmd)
     35command(cmd, ...)
    3636        char *cmd
    3737        PREINIT:
    3838                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        }
    4256        OUTPUT:
    4357                RETVAL
     
    98112                RETVAL
    99113        CLEANUP:
     114                if (rv) owl_free(rv);
     115
     116char *
     117zephyr_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
     131char *
     132zephyr_getsubs()
     133        PREINIT:
     134                char *rv = NULL;
     135        CODE:
     136                rv = owl_zephyr_getsubs();
     137                RETVAL = rv;
     138    OUTPUT:
     139                RETVAL
     140    CLEANUP:
    100141                if (rv) owl_free(rv);
    101142
  • perlwrap.pm

    rb441079 r740d5f7  
    6767
    6868Strips zephyr formatting from a string and returns the result
     69
     70=head2 zephyr_getsubs
     71
     72Returns the list of subscription triples <class,instance,recipient>,
     73separated by newlines.
    6974
    7075=head2 queue_message MESSAGE
     
    295300        %{$args});
    296301    $func->($name, $args{default}, $args{summary}, $args{description});
     302}
     303
     304=head2 quote STRING
     305
     306Return a version of STRING fully quoted to survive processing by
     307BarnOwl's command parser.
     308
     309=cut
     310
     311sub 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 . '"';
    297322}
    298323
     
    356381sub login_host  { return undef; }
    357382sub 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.
     387sub replycmd         { return shift->{replycmd}};
     388sub replysendercmd   { return shift->{replysendercmd}};
    358389
    359390sub pretty_sender    { return shift->sender; }
     
    463494}
    464495
     496sub replycmd {return 'loopwrite';}
     497sub replysendercmd {return 'loopwrite';}
     498
    465499#####################################################################
    466500#####################################################################
     
    475509}
    476510
     511sub 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
     520sub replysendercmd {
     521    return shift->replycmd;
     522}
     523
    477524#####################################################################
    478525#####################################################################
     
    480527package BarnOwl::Message::Zephyr;
    481528
     529use constant WEBZEPHYR_PRINCIPAL => "daemon.webzephyr";
     530use constant WEBZEPHYR_CLASS     => "webzephyr";
     531use constant WEBZEPHYR_OPCODE    => "webzephyr";
     532
    482533use base qw( BarnOwl::Message );
     534
     535sub strip_realm {
     536    my $sender = shift;
     537    my $realm = BarnOwl::zephyr_getrealm();
     538    $sender =~ s/\@$realm$//;
     539    return $sender;
     540}
    483541
    484542sub login_type {
     
    537595sub pretty_sender {
    538596    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);
    543598}
    544599
    545600sub pretty_recipient {
    546601    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);
    551603}
    552604
     
    563615sub zsig        { return shift->{"zsig"}; }
    564616
    565 #####################################################################
    566 #####################################################################
    567 ################################################################################
     617sub zephyr_cc {
     618    my $self = shift;
     619    return $1 if $self->body =~ /^\s*cc:\s+([^\n]+)/i;
     620    return undef;
     621}
     622
     623sub 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
     688sub replysendercmd {
     689    my $self = shift;
     690    return $self->replycmd(1);
     691}
     692
     693#####################################################################
     694#####################################################################
     695#####################################################################
    568696
    569697package BarnOwl::Hook;
     
    598726    my $self = shift;
    599727    my @args = @_;
    600     return map {$_->(@args)} @$self;
     728    return map {$self->_run($_,@args)} @$self;
     729}
     730
     731sub _run {
     732    my $self = shift;
     733    my $fn = shift;
     734    my @args = @_;
     735    no strict 'refs';
     736    return $fn->(@args);
    601737}
    602738
     
    610746    my $self = shift;
    611747    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;
    613750    push @$self, $func;
    614751}
     
    680817
    681818our @EXPORT_OK = qw($startup $shutdown
    682                     $receiveMessage $mainLoop
    683                     $getBuddyList);
     819                    $receiveMessage $newMessage
     820                    $mainLoop $getBuddyList);
    684821
    685822our %EXPORT_TAGS = (all => [@EXPORT_OK]);
     
    688825our $shutdown = BarnOwl::Hook->new;
    689826our $receiveMessage = BarnOwl::Hook->new;
     827our $newMessage = BarnOwl::Hook->new;
    690828our $mainLoop = BarnOwl::Hook->new;
    691829our $getBuddyList = BarnOwl::Hook->new;
     
    713851        package main;
    714852        do $BarnOwl::configfile;
    715         die $@ if $@;
     853        if($@) {
     854            BarnOwl::error("In startup: $@\n");
     855            return;
     856        }
    716857        package BarnOwl;
    717858        if(*BarnOwl::format_msg{CODE}) {
     
    761902   
    762903    BarnOwl::receive_msg($m) if *BarnOwl::receive_msg{CODE};
     904}
     905
     906sub _new_msg {
     907    my $m = shift;
     908
     909    $newMessage->run($m);
     910   
     911    BarnOwl::new_msg($m) if *BarnOwl::new_msg{CODE};
    763912}
    764913
  • util.c

    raf1920fd r601733d  
    498498    return(c);
    499499  }
    500   return(-1);
     500  return(OWL_COLOR_INVALID);
    501501}
    502502
  • variable.c

    r52f8dd6 r451db9e  
    8484
    8585  OWLVAR_BOOL( "sepbar_disable" /* %OwlVarStub */, 0,
    86                "disable printing information in the seperator bar", "" ),
     86               "disable printing information in the separator bar", "" ),
    8787
    8888  OWLVAR_BOOL( "smartstrip" /* %OwlVarStub */, 1,
     
    142142                    "location of users in your .anyone file.  If a user is present\n"
    143143                    "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",
    145145                    NULL, owl_variable_pseudologins_set, NULL),
    146146
     
    177177                    "off,middle,on",
    178178                    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]", "" ),
    185179
    186180  OWLVAR_PATH( "logpath" /* %OwlVarStub */, "~/zlog/people",
     
    318312                   NULL /* use default for get */
    319313                   ),
     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"),
    320324
    321325  OWLVAR_ENUM( "scrollmode" /* %OwlVarStub */, OWL_SCROLLMODE_NORMAL,
  • zephyr.c

    r02f55dc r451db9e  
    806806  if (numlocs==0) {
    807807    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);
    809809    owl_free(myuser);
    810810    return;
     
    10081008#ifdef HAVE_LIBZEPHYR
    10091009  int ret, num, i, one;
     1010  int buffsize;
    10101011  ZSubscription_t sub;
    1011   char *out, *tmpbuff;
     1012  char *out;
    10121013  one=1;
    10131014
     
    10151016  if (ret==ZERR_TOOMANYSUBS) {
    10161017    return(owl_strdup("Zephyr: too many subscriptions\n"));
    1017   } else if (ret) {
     1018  } else if (ret || (num <= 0)) {
    10181019    return(owl_strdup("Zephyr: error retriving subscriptions\n"));
    10191020  }
    10201021
    1021   out=owl_malloc(num*500);
    1022   tmpbuff=owl_malloc(num*500);
     1022  buffsize = (num + 1) * 50;
     1023  out=owl_malloc(buffsize);
    10231024  strcpy(out, "");
    10241025  for (i=0; i<num; i++) {
    10251026    if ((ret = ZGetSubscriptions(&sub, &one)) != ZERR_NONE) {
    10261027      owl_free(out);
    1027       owl_free(tmpbuff);
    10281028      ZFlushSubscriptions();
    10291029      out=owl_strdup("Error while getting subscriptions\n");
    10301030      return(out);
    10311031    } 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      }
    10331049      strcpy(out, tmpbuff);
    1034     }
    1035   }
    1036 
    1037   owl_free(tmpbuff);
     1050      owl_free(tmpbuff);
     1051    }
     1052  }
     1053
    10381054  ZFlushSubscriptions();
    10391055  return(out);
  • zwrite.c

    r7b1d048 r3f3ee61  
    1111  int argc, badargs, myargc;
    1212  char **argv, **myargv;
    13   char *zsigproc, *zsigowlvar, *zsigzvar, *ptr;
    14   struct passwd *pw;
    1513
    1614  badargs=0;
     
    139137  /* z->message is allowed to stay NULL */
    140138 
     139  return(0);
     140}
     141
     142void owl_zwrite_populate_zsig(owl_zwrite *z)
     143{
     144  char *zsigproc, *zsigowlvar, *zsigzvar, *ptr;
     145  struct passwd *pw;
     146
    141147  /* get a zsig, if not given */
    142148  if (z->zsig==NULL) {
     
    184190    }
    185191  }
    186 
    187   return(0);
    188192}
    189193
     
    285289    owl_zwrite_set_message(&z, msg);
    286290  }
     291  owl_zwrite_populate_zsig(&z);
    287292  owl_zwrite_send_message(&z);
    288293  owl_zwrite_free(&z);
     
    358363  return(0);
    359364}
    360  
     365
    361366void owl_zwrite_free(owl_zwrite *z)
    362367{
Note: See TracChangeset for help on using the changeset viewer.