Changeset 1cf32e7d


Ignore:
Timestamp:
Mar 28, 2007, 9:32:11 PM (14 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
b3a40c7
Parents:
3066d23 (diff), a387d12e (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.
Message:
Merging the PAR branch back to trunk.

r20272@phanatique (orig r665):  nelhage | 2007-03-14 19:25:05 -0400
 Branching for the PAR module rewrite.
 r20274@phanatique (orig r667):  nelhage | 2007-03-16 00:45:19 -0400
 First phase of the module rewrite. Internals now (IMO) somewhat
 cleaner.
 
  r19586@phanatique:  nelhage | 2007-03-14 20:35:39 -0400
  First pass at a cleaned up perlwrap.pm
  
  * Using a new hook style
  * Modules loaded by BarnOwl::ModuleLoader (not yet written)
  
  reload is unimplemented for now. If possible, I'd like it to live
  elsewhere.
  
  r19587@phanatique:  nelhage | 2007-03-14 20:36:58 -0400
  Switching to the new underscore internal hook names.
  r19592@phanatique:  nelhage | 2007-03-16 00:34:00 -0400
  Actually switch to _receive_msg
  
  r19593@phanatique:  nelhage | 2007-03-16 00:34:27 -0400
  Some minor cleanup of perlwrap.pm. Shoving fake entries into @INC.
  
  r19594@phanatique:  nelhage | 2007-03-16 00:34:47 -0400
  First revision of ModuleLoader.
  
 
 r20281@phanatique (orig r669):  nelhage | 2007-03-17 14:48:02 -0400
  r20279@phanatique:  nelhage | 2007-03-17 14:46:56 -0400
  For reasons I don't claim to understand, using the old-style new was
  throwing odd errors about undefined functions.
  
 
 r20286@phanatique (orig r670):  nelhage | 2007-03-18 16:28:23 -0400
  r20282@phanatique:  nelhage | 2007-03-17 14:48:22 -0400
  Report more errors when something goes wrong
  
 
 r20287@phanatique (orig r671):  nelhage | 2007-03-18 16:28:31 -0400
  r20285@phanatique:  nelhage | 2007-03-18 16:28:18 -0400
  Adding the new M::Iified jabber module. There isn't a target to build
  the PAR yet.
 
 r20291@phanatique (orig r672):  nelhage | 2007-03-18 19:14:04 -0400
  r20290@phanatique:  nelhage | 2007-03-18 19:13:57 -0400
  Adding a Module::Install plugin for building barnowl plugins. It needs
  a lot of improvement.
 
 r20309@phanatique (orig r673):  nelhage | 2007-03-19 14:14:23 -0400
  r20301@phanatique:  nelhage | 2007-03-19 13:31:07 -0400
  Changing the dependency on the par target, so we don't rebuild unless
  we need to.
 
 r20310@phanatique (orig r674):  nelhage | 2007-03-19 14:14:33 -0400
  r20303@phanatique:  nelhage | 2007-03-19 13:32:25 -0400
  Modifying the makefile to build and install perl modules
 
 r20643@phanatique (orig r677):  nelhage | 2007-03-23 15:09:45 -0400
  r20640@phanatique:  nelhage | 2007-03-23 15:09:38 -0400
  Implement loading of unpacked modules, and module reloading.
 
 r20645@phanatique (orig r678):  nelhage | 2007-03-23 15:11:05 -0400
  r20644@phanatique:  nelhage | 2007-03-23 15:10:57 -0400
  Tighten up the reloaded regex a little.
  
 
 r20649@phanatique (orig r679):  nelhage | 2007-03-23 16:18:44 -0400
  r20648@phanatique:  nelhage | 2007-03-23 16:18:25 -0400
  Correctly install modules on a clean install.
  
 
 r20655@phanatique (orig r680):  nelhage | 2007-03-25 12:53:07 -0400
  r20650@phanatique:  nelhage | 2007-03-23 17:01:20 -0400
  Still not sure why old-style new seems to be eiting us so much...
  
 
 r20656@phanatique (orig r681):  nelhage | 2007-03-25 12:53:11 -0400
  r20653@phanatique:  nelhage | 2007-03-25 12:52:38 -0400
  Let's not segfault if the user asks for a nonexistant style in .owl/startup
  
 
 r20657@phanatique (orig r682):  nelhage | 2007-03-25 12:53:16 -0400
  r20654@phanatique:  nelhage | 2007-03-25 12:52:59 -0400
  That line doesn't need to be there twice -- probably a mismerge
  
 
 r20706@phanatique (orig r683):  nelhage | 2007-03-26 21:04:43 -0400
  r20704@phanatique:  nelhage | 2007-03-26 20:00:24 -0400
  We don't need two package lines..
  
 
 r20707@phanatique (orig r684):  nelhage | 2007-03-26 21:04:54 -0400
  r20705@phanatique:  nelhage | 2007-03-26 21:04:37 -0400
  Getting rid of indirect object syntax new calls. Quoting perlobj:
  
  > But what if there are no arguments? In that case, Perl must guess what
  > you want. Even worse, it must make that guess *at compile time*. Usually
  > Perl gets it right, but when it doesn't you get a function call compiled
  > as a method, or vice versa. This can introduce subtle bugs that are hard
  > to detect.
  > 
  > For example, a call to a method "new" in indirect notation -- as C++
  > programmers are wont to make -- can be miscompiled into a subroutine
  > call if there's already a "new" function in scope. You'd end up calling
  > the current package's "new" as a subroutine, rather than the desired
  > class's method. The compiler tries to cheat by remembering bareword
  > "require"s, but the grief when it messes up just isn't worth the years
  > of debugging it will take you to track down such subtle bugs.
      
 
 r20710@phanatique (orig r685):  nelhage | 2007-03-26 21:14:41 -0400
  r20708@phanatique:  nelhage | 2007-03-26 21:11:34 -0400
  Adding a reload-modules command
  
 
 r20711@phanatique (orig r686):  nelhage | 2007-03-26 21:14:49 -0400
  r20709@phanatique:  nelhage | 2007-03-26 21:14:31 -0400
  Moving Net::Jabber into Jabber.par
 
 r20714@phanatique (orig r687):  nelhage | 2007-03-26 21:18:13 -0400
  r20713@phanatique:  nelhage | 2007-03-26 21:17:59 -0400
  Don't install .svn dirs
  
 
 r20720@phanatique (orig r688):  nelhage | 2007-03-27 22:04:10 -0400
  r20719@phanatique:  nelhage | 2007-03-27 22:04:03 -0400
  Implementing an LRU cache of the message list fmtexts. This reduces
  memory usage by roughly 1MB/kilo-zephyrs in steady state.
 

 r20272@phanatique (orig r665):  nelhage | 2007-03-14 19:25:05 -0400
 Branching for the PAR module rewrite.
 r20274@phanatique (orig r667):  nelhage | 2007-03-16 00:45:19 -0400
 First phase of the module rewrite. Internals now (IMO) somewhat
 cleaner.
 
  r19586@phanatique:  nelhage | 2007-03-14 20:35:39 -0400
  First pass at a cleaned up perlwrap.pm
  
  * Using a new hook style
  * Modules loaded by BarnOwl::ModuleLoader (not yet written)
  
  reload is unimplemented for now. If possible, I'd like it to live
  elsewhere.
  
  r19587@phanatique:  nelhage | 2007-03-14 20:36:58 -0400
  Switching to the new underscore internal hook names.
  r19592@phanatique:  nelhage | 2007-03-16 00:34:00 -0400
  Actually switch to _receive_msg
  
  r19593@phanatique:  nelhage | 2007-03-16 00:34:27 -0400
  Some minor cleanup of perlwrap.pm. Shoving fake entries into @INC.
  
  r19594@phanatique:  nelhage | 2007-03-16 00:34:47 -0400
  First revision of ModuleLoader.
  
 
 r20281@phanatique (orig r669):  nelhage | 2007-03-17 14:48:02 -0400
  r20279@phanatique:  nelhage | 2007-03-17 14:46:56 -0400
  For reasons I don't claim to understand, using the old-style new was
  throwing odd errors about undefined functions.
  
 
 r20286@phanatique (orig r670):  nelhage | 2007-03-18 16:28:23 -0400
  r20282@phanatique:  nelhage | 2007-03-17 14:48:22 -0400
  Report more errors when something goes wrong
  
 
 r20287@phanatique (orig r671):  nelhage | 2007-03-18 16:28:31 -0400
  r20285@phanatique:  nelhage | 2007-03-18 16:28:18 -0400
  Adding the new M::Iified jabber module. There isn't a target to build
  the PAR yet.
 
 r20291@phanatique (orig r672):  nelhage | 2007-03-18 19:14:04 -0400
  r20290@phanatique:  nelhage | 2007-03-18 19:13:57 -0400
  Adding a Module::Install plugin for building barnowl plugins. It needs
  a lot of improvement.
 
 r20309@phanatique (orig r673):  nelhage | 2007-03-19 14:14:23 -0400
  r20301@phanatique:  nelhage | 2007-03-19 13:31:07 -0400
  Changing the dependency on the par target, so we don't rebuild unless
  we need to.
 
 r20310@phanatique (orig r674):  nelhage | 2007-03-19 14:14:33 -0400
  r20303@phanatique:  nelhage | 2007-03-19 13:32:25 -0400
  Modifying the makefile to build and install perl modules
 
 r20643@phanatique (orig r677):  nelhage | 2007-03-23 15:09:45 -0400
  r20640@phanatique:  nelhage | 2007-03-23 15:09:38 -0400
  Implement loading of unpacked modules, and module reloading.
 
 r20645@phanatique (orig r678):  nelhage | 2007-03-23 15:11:05 -0400
  r20644@phanatique:  nelhage | 2007-03-23 15:10:57 -0400
  Tighten up the reloaded regex a little.
  
 
 r20649@phanatique (orig r679):  nelhage | 2007-03-23 16:18:44 -0400
  r20648@phanatique:  nelhage | 2007-03-23 16:18:25 -0400
  Correctly install modules on a clean install.
  
 
 r20655@phanatique (orig r680):  nelhage | 2007-03-25 12:53:07 -0400
  r20650@phanatique:  nelhage | 2007-03-23 17:01:20 -0400
  Still not sure why old-style new seems to be eiting us so much...
  
 
 r20656@phanatique (orig r681):  nelhage | 2007-03-25 12:53:11 -0400
  r20653@phanatique:  nelhage | 2007-03-25 12:52:38 -0400
  Let's not segfault if the user asks for a nonexistant style in .owl/startup
  
 
 r20657@phanatique (orig r682):  nelhage | 2007-03-25 12:53:16 -0400
  r20654@phanatique:  nelhage | 2007-03-25 12:52:59 -0400
  That line doesn't need to be there twice -- probably a mismerge
  
 
 r20706@phanatique (orig r683):  nelhage | 2007-03-26 21:04:43 -0400
  r20704@phanatique:  nelhage | 2007-03-26 20:00:24 -0400
  We don't need two package lines..
  
 
 r20707@phanatique (orig r684):  nelhage | 2007-03-26 21:04:54 -0400
  r20705@phanatique:  nelhage | 2007-03-26 21:04:37 -0400
  Getting rid of indirect object syntax new calls. Quoting perlobj:
  
  > But what if there are no arguments? In that case, Perl must guess what
  > you want. Even worse, it must make that guess *at compile time*. Usually
  > Perl gets it right, but when it doesn't you get a function call compiled
  > as a method, or vice versa. This can introduce subtle bugs that are hard
  > to detect.
  > 
  > For example, a call to a method "new" in indirect notation -- as C++
  > programmers are wont to make -- can be miscompiled into a subroutine
  > call if there's already a "new" function in scope. You'd end up calling
  > the current package's "new" as a subroutine, rather than the desired
  > class's method. The compiler tries to cheat by remembering bareword
  > "require"s, but the grief when it messes up just isn't worth the years
  > of debugging it will take you to track down such subtle bugs.
      
 
 r20710@phanatique (orig r685):  nelhage | 2007-03-26 21:14:41 -0400
  r20708@phanatique:  nelhage | 2007-03-26 21:11:34 -0400
  Adding a reload-modules command
  
 
 r20711@phanatique (orig r686):  nelhage | 2007-03-26 21:14:49 -0400
  r20709@phanatique:  nelhage | 2007-03-26 21:14:31 -0400
  Moving Net::Jabber into Jabber.par
 
 r20714@phanatique (orig r687):  nelhage | 2007-03-26 21:18:13 -0400
  r20713@phanatique:  nelhage | 2007-03-26 21:17:59 -0400
  Don't install .svn dirs
  
 
 r20720@phanatique (orig r688):  nelhage | 2007-03-27 22:04:10 -0400
  r20719@phanatique:  nelhage | 2007-03-27 22:04:03 -0400
  Implementing an LRU cache of the message list fmtexts. This reduces
  memory usage by roughly 1MB/kilo-zephyrs in steady state.
 
Files:
15 added
12 edited
44 moved

Legend:

Unmodified
Added
Removed
  • BUGS

    r69d66aa7 r0337203  
    55* reply to resource names from ichat (foo's computer) fails badly [hartmans]
    66* viewuser doesn't work with AIM or Jabber
    7 * jmuc join'ing a MUC you're already in has weird behavior [nelhage]
  • Makefile.in

    ra956288 r702aee7  
    3131
    3232EXE = barnowl
     33PERL_MODULES = Jabber
     34MODULE_DIRS = $(PERL_MODULES:%=perl/modules/%)
    3335
    3436BASE_OBJS = $(BASE_SRCS:.c=.o)
     
    5759        ./tester reg
    5860
    59 clean: libfaimclean
     61clean: libfaimclean modules_clean
    6062        $(RM) $(EXE) tester *.o $(AUTOGEN) owl_prototypes.h.new
    6163
    6264distclean: clean libfaimdistclean
    6365        $(RM) config.cache config.log config.status  Makefile config.h TAGS *~ core
     66
     67.PHONY: $(MODULE_DIRS)
     68
     69modules: $(MODULE_DIRS)
     70modules_clean:
     71        for i in $(MODULE_DIRS); do \
     72                cd $$i; test ! -f Makefile || make clean; \
     73        done
     74
     75$(MODULE_DIRS): %: %/Makefile
     76        ( cd $@ && make $(notdir $@).par )
     77
     78$(MODULE_DIRS:=/Makefile): %/Makefile: %/Makefile.PL
     79        ( cd $(dir $@) && perl -I../../lib Makefile.PL )
    6480
    6581proto: owl_prototypes.h
     
    104120        (cd libfaim; $(MAKE) distclean)
    105121
    106 all: $(EXE)
     122all: $(EXE) $(MODULE_DIRS)
    107123
    108124install: all installdirs
    109125        ${INSTALL_PROGRAM} $(EXE) ${DESTDIR}${bindir}/$(EXE)
    110126        ${INSTALL_DATA} doc/owl.1 ${DESTDIR}${mandir}/man1/barnowl.1
    111         tar -C perl -c . | tar -C ${DESTDIR}${datadir} -x
     127        ${INSTALL} -d ${DESTDIR}${datadir}/lib
     128        ${INSTALL} -d ${DESTDIR}${datadir}/modules
     129        tar -C perl/lib --exclude .svn -c . | tar -C ${DESTDIR}${datadir}/lib -x
     130        for i in $(PERL_MODULES); do \
     131                ${INSTALL_DATA} perl/modules/$$i/$$i.par ${DESTDIR}${datadir}/modules/$$i.par; \
     132        done
    112133
    113134installdirs: mkinstalldirs
  • fmtext.c

    r801b7ac ra387d12e  
    99{
    1010  f->textlen=0;
    11   f->textbuff=owl_strdup("");
     11  f->bufflen=5;
     12  f->textbuff=owl_malloc(5);
    1213  f->fmbuff=owl_malloc(5);
    1314  f->fgcolorbuff=owl_malloc(5);
    1415  f->bgcolorbuff=owl_malloc(5);
     16  f->textbuff[0]=0;
    1517  f->fmbuff[0]=OWL_FMTEXT_ATTR_NONE;
    1618  f->fgcolorbuff[0]=OWL_COLOR_DEFAULT;
     
    1820}
    1921
     22/* Clear the data from an fmtext, but don't deallocate memory. This
     23   fmtext can then be appended to again. */
     24void owl_fmtext_clear(owl_fmtext *f)
     25{
     26    f->textlen = 0;
     27    f->textbuff[0] = 0;
     28    f->fmbuff[0]=OWL_FMTEXT_ATTR_NONE;
     29    f->fgcolorbuff[0]=OWL_COLOR_DEFAULT;
     30    f->bgcolorbuff[0]=OWL_COLOR_DEFAULT;
     31}
     32
    2033/* Internal function.  Set the attribute 'attr' from index 'first' to
    2134 * index 'last'
     
    5972}
    6073
     74void _owl_fmtext_realloc(owl_fmtext *f, int newlen) /*noproto*/
     75{
     76    if(newlen + 1 > f->bufflen) {
     77      f->textbuff=owl_realloc(f->textbuff, newlen+1);
     78      f->fmbuff=owl_realloc(f->fmbuff, newlen+1);
     79      f->fgcolorbuff=owl_realloc(f->fgcolorbuff, newlen+1);
     80      f->bgcolorbuff=owl_realloc(f->bgcolorbuff, newlen+1);
     81      f->bufflen = newlen+1;
     82  }
     83}
     84
    6185/* append text to the end of 'f' with attribute 'attr' and color
    6286 * 'color'
     
    6589{
    6690  int newlen;
    67 
    6891  newlen=strlen(f->textbuff)+strlen(text);
    69   f->textbuff=owl_realloc(f->textbuff, newlen+2);
    70   f->fmbuff=owl_realloc(f->fmbuff, newlen+2);
    71   f->fgcolorbuff=owl_realloc(f->fgcolorbuff, newlen+2);
    72   f->bgcolorbuff=owl_realloc(f->bgcolorbuff, newlen+2);
    73 
     92  _owl_fmtext_realloc(f, newlen);
     93 
    7494  strcat(f->textbuff, text);
    7595  _owl_fmtext_set_attr(f, attr, f->textlen, newlen);
     
    154174
    155175  newlen=strlen(f->textbuff)+(stop-start+1);
    156   f->textbuff=owl_realloc(f->textbuff, newlen+1);
    157   f->fmbuff=owl_realloc(f->fmbuff, newlen+1);
    158   f->fgcolorbuff=owl_realloc(f->fgcolorbuff, newlen+1);
    159   f->bgcolorbuff=owl_realloc(f->bgcolorbuff, newlen+1);
     176  _owl_fmtext_realloc(f, newlen);
    160177
    161178  strncat(f->textbuff, in->textbuff+start, stop-start+1);
  • functions.c

    ra5fc448 r0337203  
    10351035
    10361036  /* execute the commands in shutdown */
    1037   ret = owl_perlconfig_execute("BarnOwl::Hooks::shutdown();");
     1037  ret = owl_perlconfig_execute("BarnOwl::Hooks::_shutdown();");
    10381038  if (ret) owl_free(ret);
    10391039
     
    33653365
    33663366  if(aim && zephyr) {
    3367       if(owl_perlconfig_is_function("BarnOwl::Hooks::get_blist")) {
    3368           char * perlblist = owl_perlconfig_execute("BarnOwl::Hooks::get_blist()");
     3367      if(owl_perlconfig_is_function("BarnOwl::Hooks::_get_blist")) {
     3368          char * perlblist = owl_perlconfig_execute("BarnOwl::Hooks::_get_blist()");
    33693369          if(perlblist) {
    33703370              owl_fmtext_append_ztext(&fm, perlblist);
  • global.c

    r8e401cae ra387d12e  
    108108
    109109  owl_obarray_init(&(g->obarray));
     110
     111  owl_message_init_fmtext_cache();
    110112}
    111113
  • message.c

    r963542b ra387d12e  
    1313static const char fileIdent[] = "$Id$";
    1414
     15static owl_fmtext_cache fmtext_cache[OWL_FMTEXT_CACHE_SIZE];
     16static owl_fmtext_cache * fmtext_cache_next = fmtext_cache;
     17
     18void owl_message_init_fmtext_cache ()
     19{
     20    int i;
     21    for(i = 0; i < OWL_FMTEXT_CACHE_SIZE; i++) {
     22        owl_fmtext_init_null(&(fmtext_cache[i].fmtext));
     23        fmtext_cache[i].message = NULL;
     24    }
     25}
     26
     27owl_fmtext_cache * owl_message_next_fmtext() /*noproto*/
     28{
     29    if(fmtext_cache_next->message != NULL) {
     30        owl_message_invalidate_format(fmtext_cache_next->message);
     31    }
     32    owl_fmtext_cache * f = fmtext_cache_next;
     33    fmtext_cache_next++;
     34    if(fmtext_cache_next - fmtext_cache == OWL_FMTEXT_CACHE_SIZE)
     35        fmtext_cache_next = fmtext_cache;
     36    return f;
     37}
     38
    1539void owl_message_init(owl_message *m)
    1640{
     
    1943  m->delete=0;
    2044  m->zwriteline=NULL;
    21   m->invalid_format=1;
    2245
    2346  owl_message_set_hostname(m, "");
     
    2952  m->timestr[strlen(m->timestr)-1]='\0';
    3053
    31   /* initialize the fmtext */
    32   owl_fmtext_init_null(&(m->fmtext));
     54  m->fmtext = NULL;
    3355}
    3456
     
    106128void owl_message_invalidate_format(owl_message *m)
    107129{
    108   m->invalid_format=1;
     130  if(m->fmtext) {
     131    m->fmtext->message = NULL;
     132    owl_fmtext_clear(&(m->fmtext->fmtext));
     133    m->fmtext=NULL;
     134  }
    109135}
    110136
     
    112138{
    113139  owl_message_format(m);
    114   return(&(m->fmtext));
     140  return(&(m->fmtext->fmtext));
    115141}
    116142
     
    120146  owl_view *v;
    121147
    122   if (m->invalid_format) {
     148  if (!m->fmtext) {
     149    m->fmtext = owl_message_next_fmtext();
     150    m->fmtext->message = m;
    123151    /* for now we assume there's just the one view and use that style */
    124152    v=owl_global_get_current_view(&g);
    125153    s=owl_view_get_style(v);
    126154
    127     owl_fmtext_free(&(m->fmtext));
    128     owl_fmtext_init_null(&(m->fmtext));
    129     owl_style_get_formattext(s, &(m->fmtext), m);
    130     m->invalid_format=0;
     155    owl_style_get_formattext(s, &(m->fmtext->fmtext), m);
    131156  }
    132157}
     
    392417char *owl_message_get_text(owl_message *m)
    393418{
    394   return(owl_fmtext_get_text(&(m->fmtext)));
     419  return(owl_fmtext_get_text(&(m->fmtext->fmtext)));
    395420}
    396421
     
    437462  if (m == NULL) return(0);
    438463  owl_message_format(m);
    439   return(owl_fmtext_num_lines(&(m->fmtext)));
     464  return(owl_fmtext_num_lines(&(m->fmtext->fmtext)));
    440465}
    441466
     
    504529  owl_fmtext_init_null(&b);
    505530 
    506   owl_fmtext_truncate_lines(&(m->fmtext), aline, bline-aline+1, &a);
     531  owl_fmtext_truncate_lines(&(m->fmtext->fmtext), aline, bline-aline+1, &a);
    507532  owl_fmtext_truncate_cols(&a, acol, bcol, &b);
    508533  if (fgcolor!=OWL_COLOR_DEFAULT) {
     
    698723  owl_message_format(m); /* is this necessary? */
    699724 
    700   return (owl_fmtext_search(&(m->fmtext), string));
     725  return (owl_fmtext_search(&(m->fmtext->fmtext), string));
    701726}
    702727
     
    9891014  owl_list_free_simple(&(m->attributes));
    9901015 
    991   owl_fmtext_free(&(m->fmtext));
    992 }
     1016  owl_message_invalidate_format(m);
     1017}
  • owl.c

    r2058d7a r72c210f  
    318318  /* execute the startup function in the configfile */
    319319  owl_function_debugmsg("startup: executing perl startup, if applicable");
    320   perlout = owl_perlconfig_execute("BarnOwl::Hooks::startup();");
     320  perlout = owl_perlconfig_execute("BarnOwl::Hooks::_startup();");
    321321  if (perlout) owl_free(perlout);
    322322
     
    397397
    398398  owl_function_debugmsg("startup: set style for the view: %s", owl_global_get_default_style(&g));
    399   owl_view_set_style(owl_global_get_current_view(&g),
    400                      owl_global_get_style_by_name(&g, owl_global_get_default_style(&g)));   
     399  s = owl_global_get_style_by_name(&g, owl_global_get_default_style(&g));
     400  if(s)
     401      owl_view_set_style(owl_global_get_current_view(&g), s);
     402  else
     403      owl_function_error("No such style: %s", owl_global_get_default_style(&g));
    401404
    402405  owl_function_debugmsg("startup: setting context interactive");
  • owl.h

    rd08162a ra387d12e  
    249249typedef struct _owl_fmtext {
    250250  int textlen;
     251  int bufflen;
    251252  char *textbuff;
    252253  char *fmbuff;
     
    329330} owl_pair;
    330331
     332struct _owl_fmtext_cache;
     333
    331334typedef struct _owl_message {
    332335  int id;
     
    335338  ZNotice_t notice;
    336339#endif
    337   owl_fmtext fmtext;              /* this is now only a CACHED copy */
    338   int invalid_format;             /* indicates whether fmtext needs to be regenerated */
     340  struct _owl_fmtext_cache * fmtext;
    339341  int delete;
    340342  char *hostname;
     
    344346  char *zwriteline;
    345347} owl_message;
     348
     349#define OWL_FMTEXT_CACHE_SIZE 1000
     350/* We cache the saved fmtexts for the last bunch of messages we
     351   rendered */
     352typedef struct _owl_fmtext_cache {
     353    owl_message * message;
     354    owl_fmtext fmtext;
     355} owl_fmtext_cache;
    346356
    347357typedef struct _owl_style {
  • perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm

    r3066d23 r2cedb7a  
    1 # -*- mode: cperl; cperl-indent-level: 4; indent-tabs-mode: nil -*-
     1use strict;
    22use warnings;
    3 use strict;
    4 
    5 package BarnOwl::Jabber;
     3
     4package BarnOwl::Module::Jabber;
     5
     6=head1 NAME
     7
     8BarnOwl::Module::Jabber
     9
     10=head1 DESCRIPTION
     11
     12This module implements Jabber support for barnowl.
     13
     14=cut
     15
     16use BarnOwl;
     17use BarnOwl::Hooks;
     18use BarnOwl::Message::Jabber;
     19use BarnOwl::Module::Jabber::Connection;
     20use BarnOwl::Module::Jabber::ConnectionManager;
    621
    722use Authen::SASL qw(Perl);
     
    1025use Net::DNS;
    1126use Getopt::Long;
     27
     28our $VERSION = 0.1;
    1229
    1330BEGIN {
     
    3855################################################################################
    3956
    40 
    41 ################################################################################
    42 ################################################################################
    43 package BarnOwl::Jabber::Connection;
    44 
    45 use base qw(Net::Jabber::Client);
    46 
    47 sub new {
    48     my $class = shift;
    49 
    50     my %args = ();
    51     if(BarnOwl::getvar('debug') eq 'on') {
    52         $args{debuglevel} = 1;
    53         $args{debugfile} = 'jabber.log';
    54     }
    55     my $self = $class->SUPER::new(%args);
    56     $self->{_BARNOWL_MUCS} = [];
    57     return $self;
    58 }
    59 
    60 =head2 MUCJoin
    61 
    62 Extends MUCJoin to keep track of the MUCs we're joined to as
    63 Net::Jabber::MUC objects. Takes the same arguments as
    64 L<Net::Jabber::MUC/new> and L<Net::Jabber::MUC/Connect>
    65 
    66 =cut
    67 
    68 sub MUCJoin {
    69     my $self = shift;
    70     my $muc = Net::Jabber::MUC->new(connection => $self, @_);
    71     $muc->Join(@_);
    72 
    73     # Add MUC to list of MUCs, unless we're just changing nicks.
    74     push @{$self->MUCs}, $muc unless grep {$_->BaseJID eq $muc->BaseJID} $self->MUCs;
    75 }
    76 
    77 =head2 MUCLeave ARGS
    78 
    79 Leave a MUC. The MUC is specified in the same form as L</FindMUC>
    80 
    81 =cut
    82 
    83 sub MUCLeave {
    84     my $self = shift;
    85     my $muc = $self->FindMUC(@_);
    86     return unless $muc;
    87 
    88     $muc->Leave();
    89     $self->{_BARNOWL_MUCS} = [grep {$_->BaseJID ne $muc->BaseJID} $self->MUCs];
    90 }
    91 
    92 =head2 FindMUC ARGS
    93 
    94 Return the Net::Jabber::MUC object representing a specific MUC we're
    95 joined to, undef if it doesn't exists. ARGS can be either JID => $JID,
    96 or Room => $room, Server => $server.
    97 
    98 =cut
    99 
    100 sub FindMUC {
    101     my $self = shift;
    102 
    103     my %args;
    104     while($#_ >= 0) { $args{ lc(pop(@_)) } = pop(@_); }
    105 
    106     my $jid;
    107     if($args{jid}) {
    108         $jid = $args{jid};
    109     } elsif($args{room} && $args{server}) {
    110         $jid = Net::Jabber::JID->new(userid => $args{room},
    111                                      server => $args{server});
    112     }
    113     $jid = $jid->GetJID('base') if UNIVERSAL::isa($jid, 'Net::XMPP::JID');
    114 
    115     foreach my $muc ($self->MUCs) {
    116         return $muc if $muc->BaseJID eq $jid;
    117     }
    118     return undef;
    119 }
    120 
    121 =head2 MUCs
    122 
    123 Returns a list (or arrayref in scalar context) of Net::Jabber::MUC
    124 objects we believe ourself to be connected to.
    125 
    126 =cut
    127 
    128 sub MUCs {
    129     my $self = shift;
    130     my $mucs = $self->{_BARNOWL_MUCS};
    131     return wantarray ? @$mucs : $mucs;
    132 }
    133 
    134 ################################################################################
    135 ################################################################################
    136 package BarnOwl::Jabber::ConnectionManager;
    137 sub new {
    138     my $class = shift;
    139     return bless { }, $class;
    140 }
    141 
    142 sub addConnection {
    143     my $self = shift;
    144     my $jidStr = shift;
    145 
    146     my $client = BarnOwl::Jabber::Connection->new;
    147 
    148     $self->{$jidStr}->{Client} = $client;
    149     $self->{$jidStr}->{Roster} = $client->Roster();
    150     $self->{$jidStr}->{Status} = "available";
    151     return $client;
    152 }
    153 
    154 sub removeConnection {
    155     my $self = shift;
    156     my $jidStr = shift;
    157     return 0 unless exists $self->{$jidStr};
    158 
    159     $self->{$jidStr}->{Client}->Disconnect()
    160       if $self->{$jidStr}->{Client};
    161     delete $self->{$jidStr};
    162 
    163     return 1;
    164 }
    165 
    166 sub connected {
    167     my $self = shift;
    168     return scalar keys %{ $self };
    169 }
    170 
    171 sub getJIDs {
    172     my $self = shift;
    173     return keys %{ $self };
    174 }
    175 
    176 sub jidExists {
    177     my $self = shift;
    178     my $jidStr = shift;
    179     return exists $self->{$jidStr};
    180 }
    181 
    182 sub sidExists {
    183     my $self = shift;
    184     my $sid = shift || "";
    185     foreach my $c ( values %{ $self } ) {
    186         return 1 if ($c->{Client}->{SESSION}->{id} eq $sid);
    187     }
    188     return 0;
    189 }
    190 
    191 sub getConnectionFromSid {
    192     my $self = shift;
    193     my $sid = shift;
    194     foreach my $c (values %{ $self }) {
    195         return $c->{Client} if $c->{Client}->{SESSION}->{id} eq $sid;
    196     }
    197     return undef;
    198 }
    199 
    200 sub getConnectionFromJID {
    201     my $self = shift;
    202     my $jid = shift;
    203     $jid = $jid->GetJID('full') if UNIVERSAL::isa($jid, 'Net::XMPP::JID');
    204     return $self->{$jid}->{Client} if exists $self->{$jid};
    205 }
    206 
    207 sub getRosterFromSid {
    208     my $self = shift;
    209     my $sid = shift;
    210     foreach my $c (values %{ $self }) {
    211         return $c->{Roster}
    212           if $c->{Client}->{SESSION}->{id} eq $sid;
    213     }
    214     return undef;
    215 }
    216 
    217 sub getRosterFromJID {
    218     my $self = shift;
    219     my $jid = shift;
    220     $jid = $jid->GetJID('full') if UNIVERSAL::isa($jid, 'Net::XMPP::JID');
    221     return $self->{$jid}->{Roster} if exists $self->{$jid};
    222 }
    223 ################################################################################
    224 
    225 package BarnOwl::Jabber;
    226 
    227 our $conn = new BarnOwl::Jabber::ConnectionManager unless $conn;;
     57our $conn = BarnOwl::Module::Jabber::ConnectionManager->new unless $conn;;
    22858our %vars;
    22959
     
    23161    if ( *BarnOwl::queue_message{CODE} ) {
    23262        register_owl_commands();
    233         register_keybindings() unless $BarnOwl::reload;
    234         register_filters() unless $BarnOwl::reload;
    235         push @::onMainLoop,     sub { BarnOwl::Jabber::onMainLoop(@_) };
    236         push @::onGetBuddyList, sub { BarnOwl::Jabber::onGetBuddyList(@_) };
     63        register_keybindings();
     64        register_filters();
     65        $BarnOwl::Hooks::mainLoop->add(\&onMainLoop);
     66        $BarnOwl::Hooks::getBuddyList->add(\&onGetBuddyList);
    23767        $vars{show} = '';
    23868    } else {
     
    24373}
    24474
    245 push @::onStartSubs, sub { BarnOwl::Jabber::onStart(@_) };
     75$BarnOwl::Hooks::startup->add(\&onStart);
    24676
    24777sub onMainLoop {
     
    305135        $blistStr .= " [" . ( $rq{show} ? $rq{show} : 'online' ) . "]";
    306136        $blistStr .= " " . $rq{status} if $rq{status};
    307         $blistStr = boldify($blistStr);
     137        $blistStr = BarnOwl::Style::boldify($blistStr);
    308138    }
    309139    else {
     
    328158    my $roster = $conn->getRosterFromJID($jid);
    329159    if ($roster) {
    330         $blist .= "\n" . boldify("Jabber Roster for $jid\n");
     160        $blist .= "\n" . BarnOwl::Style::boldify("Jabber Roster for $jid\n");
    331161
    332162        foreach my $group ( $roster->groups() ) {
     
    499329        # when we reload
    500330        $client->SetMessageCallBacks(
    501             chat      => sub { BarnOwl::Jabber::process_incoming_chat_message(@_) },
    502             error     => sub { BarnOwl::Jabber::process_incoming_error_message(@_) },
    503             groupchat => sub { BarnOwl::Jabber::process_incoming_groupchat_message(@_) },
    504             headline  => sub { BarnOwl::Jabber::process_incoming_headline_message(@_) },
    505             normal    => sub { BarnOwl::Jabber::process_incoming_normal_message(@_) }
     331            chat      => sub { BarnOwl::Module::Jabber::process_incoming_chat_message(@_) },
     332            error     => sub { BarnOwl::Module::Jabber::process_incoming_error_message(@_) },
     333            groupchat => sub { BarnOwl::Module::Jabber::process_incoming_groupchat_message(@_) },
     334            headline  => sub { BarnOwl::Module::Jabber::process_incoming_headline_message(@_) },
     335            normal    => sub { BarnOwl::Module::Jabber::process_incoming_normal_message(@_) }
    506336        );
    507337        $client->SetPresenceCallBacks(
    508             available    => sub { BarnOwl::Jabber::process_presence_available(@_) },
    509             unavailable  => sub { BarnOwl::Jabber::process_presence_available(@_) },
    510             subscribe    => sub { BarnOwl::Jabber::process_presence_subscribe(@_) },
    511             subscribed   => sub { BarnOwl::Jabber::process_presence_subscribed(@_) },
    512             unsubscribe  => sub { BarnOwl::Jabber::process_presence_unsubscribe(@_) },
    513             unsubscribed => sub { BarnOwl::Jabber::process_presence_unsubscribed(@_) },
    514             error        => sub { BarnOwl::Jabber::process_presence_error(@_) });
     338            available    => sub { BarnOwl::Module::Jabber::process_presence_available(@_) },
     339            unavailable  => sub { BarnOwl::Module::Jabber::process_presence_available(@_) },
     340            subscribe    => sub { BarnOwl::Module::Jabber::process_presence_subscribe(@_) },
     341            subscribed   => sub { BarnOwl::Module::Jabber::process_presence_subscribed(@_) },
     342            unsubscribe  => sub { BarnOwl::Module::Jabber::process_presence_unsubscribe(@_) },
     343            unsubscribed => sub { BarnOwl::Module::Jabber::process_presence_unsubscribed(@_) },
     344            error        => sub { BarnOwl::Module::Jabber::process_presence_error(@_) });
    515345
    516346        my $status = $client->Connect( %{ $vars{jlogin_connhash} } );
     
    802632        my $str = "";
    803633        foreach my $jid ($conn->getJIDs()) {
    804             $str .= boldify("Conferences for $jid:\n");
     634            $str .= BarnOwl::Style::boldify("Conferences for $jid:\n");
    805635            my $connection = $conn->getConnectionFromJID($jid);
    806636            foreach my $muc ($connection->MUCs) {
     
    1026856    my $m = j2o( $j, { direction => 'out' } );
    1027857    if ( $vars{jwrite}{type} ne 'groupchat') {
    1028         BarnOwl::add_and_log_message($m);
     858        BarnOwl::add_message($m);
    1029859    }
    1030860
     
    13091139}
    13101140
    1311 sub boldify($) {
    1312     my $str = shift;
    1313 
    1314     return '@b(' . $str . ')' if ( $str !~ /\)/ );
    1315     return '@b<' . $str . '>' if ( $str !~ /\>/ );
    1316     return '@b{' . $str . '}' if ( $str !~ /\}/ );
    1317     return '@b[' . $str . ']' if ( $str !~ /\]/ );
    1318 
    1319     my $txt = "$str";
    1320     $txt =~ s{[)]}{)\@b[)]\@b(}g;
    1321     return '@b(' . $txt . ')';
    1322 }
    1323 
    13241141sub getServerFromJID {
    13251142    my $jid = shift;
     
    14591276}
    14601277
    1461 #####################################################################
    1462 #####################################################################
    1463 
    1464 package BarnOwl::Message::Jabber;
    1465 
    1466 our @ISA = qw( BarnOwl::Message );
    1467 
    1468 sub jtype { shift->{jtype} };
    1469 sub from { shift->{from} };
    1470 sub to { shift->{to} };
    1471 sub room { shift->{room} };
    1472 sub status { shift->{status} }
    1473 
    1474 sub login_extra {
    1475     my $self = shift;
    1476     my $show = $self->{show};
    1477     my $status = $self->status;
    1478     my $s = "";
    1479     $s .= $show if $show;
    1480     $s .= ", $status" if $status;
    1481     return $s;
    1482 }
    1483 
    1484 sub long_sender {
    1485     my $self = shift;
    1486     return $self->from;
    1487 }
    1488 
    1489 sub context {
    1490     return shift->room;
    1491 }
    1492 
    1493 sub smartfilter {
    1494     my $self = shift;
    1495     my $inst = shift;
    1496 
    1497     my ($filter, $ftext);
    1498 
    1499     if($self->jtype eq 'chat') {
    1500         my $user;
    1501         if($self->direction eq 'in') {
    1502             $user = $self->from;
    1503         } else {
    1504             $user = $self->to;
    1505         }
    1506         return smartfilter_user($user, $inst);
    1507     } elsif ($self->jtype eq 'groupchat') {
    1508         my $room = $self->room;
    1509         $filter = "jabber-room-$room";
    1510         $ftext = qq{type ^jabber\$ and room ^$room\$};
    1511         BarnOwl::filter("$filter $ftext");
    1512         return $filter;
    1513     } elsif ($self->login ne 'none') {
    1514         return smartfilter_user($self->from, $inst);
    1515     }
    1516 }
    1517 
    1518 sub smartfilter_user {
    1519     my $user = shift;
    1520     my $inst = shift;
    1521 
    1522     $user   = Net::Jabber::JID->new($user)->GetJID( $inst ? 'full' : 'base' );
    1523     my $filter = "jabber-user-$user";
    1524     my $ftext  =
    1525         qq{type ^jabber\$ and ( ( direction ^in\$ and from ^$user ) }
    1526       . qq{or ( direction ^out\$ and to ^$user ) ) };
    1527     BarnOwl::filter("$filter $ftext");
    1528     return $filter;
    1529 
    1530 }
    1531 
    1532 
    153312781;
  • perl/modules/Jabber/lib/Net/Jabber.pm

    r0ff8d110 rc2bed55  
    6161    For a client:
    6262      use Net::Jabber;
    63       my $client = new Net::Jabber::Client();
     63      my $client = Net::Jabber::Client->new();
    6464
    6565    For a component:
    6666      use Net::Jabber;
    67       my $component = new Net::Jabber::Component();
     67      my $component = Net::Jabber::Component->new();
    6868
    6969=head1 METHODS
  • perl/modules/Jabber/lib/Net/Jabber/Component.pm

    r0ff8d110 rc2bed55  
    5454    use Net::Jabber;
    5555
    56     $Con = new Net::Jabber::Component();
     56    $Con = Net::Jabber::Component->new();
    5757
    5858    $Con->Execute(hostname=>"jabber.org",
  • perl/modules/Jabber/lib/Net/Jabber/Data.pm

    r0ff8d110 rc2bed55  
    5656  Net::Jabber::Client module.
    5757
    58     my $xdb = new Net::Jabber::XDB(%hash);
     58    my $xdb = Net::Jabber::XDB->new(%hash);
    5959
    6060  There has been a change from the old way of handling the callbacks.
     
    8383    use Net::Jabber;
    8484
    85     my $xdb = new Net::Jabber::XDB();
     85    my $xdb = Net::Jabber::XDB->new();
    8686    $data = $xdb->NewData("jabber:iq:auth");
    8787
  • perl/modules/Jabber/lib/Net/Jabber/Dialback.pm

    r0ff8d110 rc2bed55  
    3838  the XML::Stream hash.  For example:
    3939
    40     my $dialback = new Net::Jabber::Dialback(%hash);
     40    my $dialback = Net::Jabber::Dialback->new(%hash);
    4141
    4242  You now have access to all of the retrieval functions available.
     
    4646    use Net::Jabber qw(Server);
    4747
    48     $DB = new Net::Jabber::Dialback("verify");
    49     $DB = new Net::Jabber::Dialback("result");
     48    $DB = Net::Jabber::Dialback->new("verify");
     49    $DB = Net::Jabber::Dialback->new("result");
    5050
    5151  Please see the specific documentation for Net::Jabber::Dialback::Result
     
    9898        {
    9999            my ($temp) = @_;
    100             return new Net::Jabber::Dialback::Result()
     100            return Net::Jabber::Dialback::Result->new()
    101101                if ($temp eq "result");
    102             return new Net::Jabber::Dialback::Verify()
     102            return Net::Jabber::Dialback::Verify->new()
    103103                if ($temp eq "verify");
    104104
    105105            my @temp = @{$temp};
    106             return new Net::Jabber::Dialback::Result(@temp)
     106            return Net::Jabber::Dialback::Result->new(@temp)
    107107                if ($temp[0] eq "db:result");
    108             return new Net::Jabber::Dialback::Verify(@temp)
     108            return Net::Jabber::Dialback::Verify->new(@temp)
    109109                if ($temp[0] eq "db:verify");
    110110        }
  • perl/modules/Jabber/lib/Net/Jabber/Dialback/Result.pm

    r0ff8d110 rc2bed55  
    3838  the XML::Stream hash.  For example:
    3939
    40     my $dialback = new Net::Jabber::Dialback::Result(%hash);
     40    my $dialback = Net::Jabber::Dialback::Result->new(%hash);
    4141
    4242  There has been a change from the old way of handling the callbacks.
     
    6363    use Net::Jabber qw(Server);
    6464
    65     $Result = new Net::Jabber::Dialback::Result();
     65    $Result = Net::Jabber::Dialback::Result->new();
    6666
    6767  Now you can call the creation functions below to populate the tag before
  • perl/modules/Jabber/lib/Net/Jabber/Dialback/Verify.pm

    r0ff8d110 rc2bed55  
    3838  the XML::Stream hash.  For example:
    3939
    40     my $dialback = new Net::Jabber::Dialback::Verify(%hash);
     40    my $dialback = Net::Jabber::Dialback::Verify->new(%hash);
    4141
    4242  There has been a change from the old way of handling the callbacks.
     
    6363    use Net::Jabber qw(Server);
    6464
    65     $Verify = new Net::Jabber::Dialback::Verify();
     65    $Verify = Net::Jabber::Dialback::Verify->new();
    6666
    6767  Now you can call the creation functions below to populate the tag before
  • perl/modules/Jabber/lib/Net/Jabber/IQ.pm

    r0ff8d110 rc2bed55  
    6363sub RemoveX  { my $self = shift; $self->RemoveChild(@_);  }
    6464
    65 sub _new_jid    { my $self = shift; return new Net::Jabber::JID(@_);    }
    66 sub _new_packet { my $self = shift; return new Net::Jabber::Stanza(@_); }
    67 sub _iq         { my $self = shift; return new Net::Jabber::IQ(@_);     }
     65sub _new_jid    { my $self = shift; return Net::Jabber::JID->new(@_);    }
     66sub _new_packet { my $self = shift; return Net::Jabber::Stanza->new(@_); }
     67sub _iq         { my $self = shift; return Net::Jabber::IQ->new(@_);     }
    6868
    69691;
  • perl/modules/Jabber/lib/Net/Jabber/Key.pm

    r0ff8d110 rc2bed55  
    4141=head2 Basic Functions
    4242
    43     $Key = new Net::Jabber::Key();
     43    $Key = Net::Jabber::Key->new();
    4444
    4545    $key = $Key->Generate();
     
    9797    my $self = { };
    9898
    99     $self->{DEBUG} = new Net::Jabber::Debug(usedefault=>1,
    100                       header=>"NJ::Key");
     99    $self->{DEBUG} = Net::Jabber::Debug->new(usedefault=>1,
     100                                             header=>"NJ::Key");
    101101
    102102    $self->{VERSION} = $VERSION;
  • perl/modules/Jabber/lib/Net/Jabber/Log.pm

    r0ff8d110 rc2bed55  
    3838  XML::Parser Tree array.  For example:
    3939
    40     my $log = new Net::Jabber::Log(@tree);
     40    my $log = Net::Jabber::Log->new(@tree);
    4141
    4242  There has been a change from the old way of handling the callbacks.
     
    5959    use Net::Jabber;
    6060
    61     $Log = new Net::Jabber::Log();
     61    $Log = Net::Jabber::Log->new();
    6262
    6363  Now you can call the creation functions below to populate the tag before
     
    176176    bless($self, $proto);
    177177
    178     $self->{DEBUG} = new Net::Jabber::Debug(usedefault=>1,
    179                                                     header=>"NJ::Log");
     178    $self->{DEBUG} = Net::Jabber::Debug->new(usedefault=>1,
     179                                             header=>"NJ::Log");
    180180
    181181    if ("@_" ne (""))
  • perl/modules/Jabber/lib/Net/Jabber/Message.pm

    r0ff8d110 rc2bed55  
    5858sub RemoveX  { my $self = shift; $self->RemoveChild(@_); }
    5959
    60 sub _new_jid    { my $self = shift; return new Net::Jabber::JID(@_);     }
    61 sub _new_packet { my $self = shift; return new Net::Jabber::Stanza(@_);  }
    62 sub _message    { my $self = shift; return new Net::Jabber::Message(@_); }
     60sub _new_jid    { my $self = shift; return Net::Jabber::JID->new(@_);     }
     61sub _new_packet { my $self = shift; return Net::Jabber::Stanza->new(@_);  }
     62sub _message    { my $self = shift; return Net::Jabber::Message->new(@_); }
    6363
    64641;
  • perl/modules/Jabber/lib/Net/Jabber/Presence.pm

    r0ff8d110 rc2bed55  
    5858sub RemoveX  { my $self = shift; $self->RemoveChild(@_); }
    5959
    60 sub _new_jid    { my $self = shift; return new Net::Jabber::JID(@_);      }
    61 sub _new_packet { my $self = shift; return new Net::Jabber::Stanza(@_);   }
    62 sub _presence   { my $self = shift; return new Net::Jabber::Presence(@_); }
     60sub _new_jid    { my $self = shift; return Net::Jabber::JID->new(@_);      }
     61sub _new_packet { my $self = shift; return Net::Jabber::Stanza->new(@_);   }
     62sub _presence   { my $self = shift; return Net::Jabber::Presence->new(@_); }
    6363
    64641;
  • perl/modules/Jabber/lib/Net/Jabber/Protocol.pm

    r0ff8d110 rc2bed55  
    7878
    7979    use Net::Jabber qw( Client );
    80     $Con = new Net::Jabber::Client();                # From
     80    $Con = Net::Jabber::Client->new();                # From
    8181    $status = $Con->Connect(hostname=>"jabber.org"); # Net::Jabber::Client
    8282
     
    8484
    8585    use Net::Jabber qw( Component );
    86     $Con = new Net::Jabber::Component();             #
     86    $Con = Net::Jabber::Component->new();             #
    8787    $status = $Con->Connect(hostname=>"jabber.org",  # From
    8888                            secret=>"bob");          # Net::Jabber::Component
     
    16601660        if exists($Net::Jabber::Query::TAGS{'http://jabber.org/protocol/feature-neg'});
    16611661   
    1662     my $query = new Net::Jabber::Query($tag);
     1662    my $query = Net::Jabber::Query->new($tag);
    16631663    $query->SetXMLNS("http://jabber.org/protocol/feature-neg");
    16641664    my $xdata = $query->NewX("jabber:x:data");
     
    21832183    while($#_ >= 0) { $args{ lc pop(@_) } = pop(@_); }
    21842184
    2185     my $query = new Net::Jabber::Stanza("query");
     2185    my $query = Net::Jabber::Stanza->new("query");
    21862186    $query->SetXMLNS("jabber:iq:rpc");
    21872187
  • perl/modules/Jabber/lib/Net/Jabber/Server.pm

    r0ff8d110 rc2bed55  
    5454    use Net::Jabber qw(Server);
    5555
    56     $Server = new Net::Jabber::Server();
     56    $Server = Net::Jabber::Server->new();
    5757
    5858    $Server->Start();
     
    155155    bless($self, $proto);
    156156
    157     $self->{KEY} = new Net::Jabber::Key();
     157    $self->{KEY} = Net::Jabber::Key->new();
    158158
    159159    $self->{DEBUG} =
    160         new Net::Jabber::Debug(level=>exists($args{debuglevel}) ? $args{debuglevel} : -1,
    161                                file=>exists($args{debugfile}) ? $args{debugfile} : "stdout",
    162                                time=>exists($args{debugtime}) ? $args{debugtime} : 0,
    163                                setdefault=>1,
    164                                header=>"NJ::Server"
    165                               );
     160        Net::Jabber::Debug->new(level=>exists($args{debuglevel}) ? $args{debuglevel} : -1,
     161                                file=>exists($args{debugfile}) ? $args{debugfile} : "stdout",
     162                                time=>exists($args{debugtime}) ? $args{debugtime} : 0,
     163                                setdefault=>1,
     164                                header=>"NJ::Server"
     165                               );
    166166
    167167    $self->{SERVER} = { hostname => "localhost",
     
    329329    $self->{DEBUG}->Log2("dbresultHandler: dbresult(",$dbresult->GetXML(),")");
    330330
    331     my $dbverify = new Net::Jabber::Dialback::Verify();
     331    my $dbverify = Net::Jabber::Dialback::Verify->new();
    332332    $dbverify->SetVerify(to=>$dbresult->GetFrom(),
    333333                         from=>$dbresult->GetTo(),
  • perl/modules/Jabber/lib/Net/Jabber/Stanza.pm

    r0ff8d110 rc2bed55  
    17381738sub RemoveQuery  { my $self = shift; $self->RemoveChild(@_);  }
    17391739
    1740 sub _new_jid    { my $self = shift; return new Net::Jabber::JID(@_);    }
    1741 sub _new_packet { my $self = shift; return new Net::Jabber::Stanza(@_); }
     1740sub _new_jid    { my $self = shift; return Net::Jabber::JID->new(@_);    }
     1741sub _new_packet { my $self = shift; return Net::Jabber::Stanza->new(@_); }
    17421742
    17431743
  • perl/modules/Jabber/lib/Net/Jabber/XDB.pm

    r0ff8d110 rc2bed55  
    4444  XML::Parser Tree array.  For example:
    4545
    46     my $xdb = new Net::Jabber::XDB(@tree);
     46    my $xdb = Net::Jabber::XDB->new(@tree);
    4747
    4848  There has been a change from the old way of handling the callbacks.
     
    6565    use Net::Jabber;
    6666
    67     $XDB = new Net::Jabber::XDB();
     67    $XDB = Net::Jabber::XDB->new();
    6868    $XDBType = $XDB->NewData( type );
    6969    $XDBType->SetXXXXX("yyyyy");
     
    418418    while($#_ >= 0) { $args{ lc pop(@_) } = pop(@_); }
    419419
    420     my $reply = new Net::Jabber::XDB();
     420    my $reply = Net::Jabber::XDB->new();
    421421
    422422    $reply->SetID($self->GetID()) if ($self->GetID() ne "");
  • perl/modules/Jabber/lib/Net/XMPP.pm

    r0ff8d110 rc2bed55  
    6161
    6262      use Net::XMPP;
    63       my $client = new Net::XMPP::Client();
     63      my $client = Net::XMPP::Client->new();
    6464
    6565=head1 METHODS
  • perl/modules/Jabber/lib/Net/XMPP/Client.pm

    r0ff8d110 rc2bed55  
    5454    use Net::XMPP;
    5555
    56     $Con = new Net::XMPP::Client();
     56    $Con = Net::XMPP::Client->new();
    5757
    5858    $Con->SetCallbacks(...);
  • perl/modules/Jabber/lib/Net/XMPP/Connection.pm

    reaf9ed0 rc2bed55  
    8181
    8282    $self->{DEBUG} =
    83         new Net::XMPP::Debug(level      => $self->_arg("debuglevel",-1),
    84                              file       => $self->_arg("debugfile","stdout"),
    85                              time       => $self->_arg("debugtime",0),
    86                              setdefault => 1,
    87                              header     => "XMPP::Conn"
    88                     );
     83        Net::XMPP::Debug->new(level      => $self->_arg("debuglevel",-1),
     84                              file       => $self->_arg("debugfile","stdout"),
     85                              time       => $self->_arg("debugtime",0),
     86                              setdefault => 1,
     87                              header     => "XMPP::Conn"
     88                             );
    8989
    9090    $self->{SERVER} = {};
     
    9898
    9999    $self->{STREAM} =
    100         new XML::Stream(style      => "node",
    101                         debugfh    => $self->{DEBUG}->GetHandle(),
    102                         debuglevel => $self->{DEBUG}->GetLevel(),
    103                         debugtime  => $self->{DEBUG}->GetTime(),
    104                        );
     100        XML::Stream->new(style      => "node",
     101                         debugfh    => $self->{DEBUG}->GetHandle(),
     102                         debuglevel => $self->{DEBUG}->GetLevel(),
     103                         debugtime  => $self->{DEBUG}->GetTime(),
     104                        );
    105105   
    106106    $self->{RCVDB}->{currentID} = 0;
  • perl/modules/Jabber/lib/Net/XMPP/Debug.pm

    r0ff8d110 rc2bed55  
    3939=head2 Basic Functions
    4040
    41     $Debug = new Net::XMPP::Debug();
     41    $Debug = Net::XMPP::Debug->new();
    4242
    4343    $Debug->Init(level=>2,
     
    8686=head1 EXAMPLE
    8787
    88   $Debug = new Net::XMPP:Debug(level=>2,
     88  $Debug = Net::XMPP:Debug->new(level=>2,
    8989                               header=>"Example");
    9090
  • perl/modules/Jabber/lib/Net/XMPP/IQ.pm

    r0ff8d110 rc2bed55  
    6262    use Net::XMPP;
    6363
    64     $IQ = new Net::XMPP::IQ();
     64    $IQ = Net::XMPP::IQ->new();
    6565    $IQType = $IQ->NewChild( type );
    6666    $IQType->SetXXXXX("yyyyy");
     
    291291}
    292292
    293 sub _iq { my $self = shift; return new Net::XMPP::IQ(); }
     293sub _iq { my $self = shift; return Net::XMPP::IQ->new(); }
    294294
    295295$FUNCTIONS{Error}->{path} = 'error/text()';
  • perl/modules/Jabber/lib/Net/XMPP/JID.pm

    r0ff8d110 rc2bed55  
    4242
    4343    sub foo {
    44       my $foo = new Net::XMPP::Foo(@_);
     44      my $foo = Net::XMPP::Foo->new(@_);
    4545      my $from = $foo->GetFrom();
    46       my $JID = new Net::XMPP::JID($from);
     46      my $JID = Net::XMPP::JID->new($from);
    4747      .
    4848      .
     
    5656    use Net::XMPP;
    5757
    58     $JID = new Net::XMPP::JID();
     58    $JID = Net::XMPP::JID->new();
    5959
    6060  Now you can call the creation functions below to populate the tag
  • perl/modules/Jabber/lib/Net/XMPP/Message.pm

    r0ff8d110 rc2bed55  
    5555    use Net::XMPP;
    5656
    57     $Mess = new Net::XMPP::Message();
     57    $Mess = Net::XMPP::Message->new();
    5858
    5959  Now you can call the creation functions below to populate the tag
     
    315315}
    316316
    317 sub _message { my $self = shift; return new Net::XMPP::Message(); }
     317sub _message { my $self = shift; return Net::XMPP::Message->new(); }
    318318
    319319
  • perl/modules/Jabber/lib/Net/XMPP/Presence.pm

    r0ff8d110 rc2bed55  
    5555    use Net::XMPP;
    5656
    57     $Pres = new Net::XMPP::Presence();
     57    $Pres = Net::XMPP::Presence->new();
    5858
    5959  Now you can call the creation functions below to populate the tag
     
    270270}
    271271
    272 sub _presence { my $self = shift; return new Net::XMPP::Presence(); }
     272sub _presence { my $self = shift; return Net::XMPP::Presence->new(); }
    273273
    274274
  • perl/modules/Jabber/lib/Net/XMPP/Protocol.pm

    r3405394 rc2bed55  
    7474
    7575    use Net::XMPP qw( Client );
    76     $Con = new Net::XMPP::Client();                  # From
     76    $Con = Net::XMPP::Client->new();                  # From
    7777    $status = $Con->Connect(hostname=>"jabber.org"); # Net::XMPP::Client
    7878
     
    20492049    my $self = shift;
    20502050
    2051     return new Net::XMPP::PrivacyLists(connection=>$self);
     2051    return Net::XMPP::PrivacyLists->new(connection=>$self);
    20522052}
    20532053
     
    23722372    my $self = shift;
    23732373
    2374     return new Net::XMPP::Roster(connection=>$self);
     2374    return Net::XMPP::Roster->new(connection=>$self);
    23752375}
    23762376
  • perl/modules/Jabber/lib/Net/XMPP/Roster.pm

    r17b7fc5 rc2bed55  
    4141=head2 Basic Functions
    4242
    43   my $Client = new Net::XMPP::Client(...);
    44 
    45   my $Roster = new Net::XMPP::Roster(connection=>$Client);
     43  my $Client = Net::XMPP::Client->new(...);
     44
     45  my $Roster = Net::XMPP::Roster->new(connection=>$Client);
    4646    or
    4747  my $Roster = $Client->Roster();
     
    544544                     ($#{$self->{JIDS}->{$jid}->{groups}} > -1));
    545545
    546             push(@jids,new Net::XMPP::JID($jid));
     546            push(@jids, Net::XMPP::JID->new($jid));
    547547        }
    548548    }
     
    555555            foreach my $jid (keys(%{$self->{GROUPS}->{$group}}))
    556556            {
    557                 push(@jids,new Net::XMPP::JID($jid));
     557                push(@jids, Net::XMPP::JID->new($jid));
    558558            }
    559559        }
  • perl/modules/Jabber/lib/Net/XMPP/Stanza.pm

    r0ff8d110 rc2bed55  
    216216use vars qw( $AUTOLOAD %FUNCTIONS $DEBUG );
    217217
    218 $DEBUG = new Net::XMPP::Debug(usedefault=>1,
    219                               header=>"XMPP");
     218$DEBUG = Net::XMPP::Debug->new(usedefault=>1,
     219                               header=>"XMPP");
    220220
    221221# XXX need to look at evals and $@
     
    14121412{
    14131413    my $self = shift;
    1414     return new Net::XMPP::JID(@_);
     1414    return Net::XMPP::JID->new(@_);
    14151415}
    14161416
     
    14241424{
    14251425    my $self = shift;
    1426     return new Net::XMPP::Stanza(@_);
     1426    return Net::XMPP::Stanza->new(@_);
    14271427}
    14281428
  • perl/modules/Jabber/lib/XML/Stream.pm

    ra75309a rc2bed55  
    681681        if ($NETDNS)
    682682        {
    683             my $res = new Net::DNS::Resolver();
     683            my $res = Net::DNS::Resolver->new();
    684684            my $query = $res->query($self->{SIDS}->{newconnection}->{srv}.".".$self->{SIDS}->{newconnection}->{hostname},"SRV");
    685685           
  • perlconfig.c

    r1cc95709 r0337203  
    422422  } else {
    423423    char *ptr = NULL;
    424     if (owl_perlconfig_is_function("BarnOwl::Hooks::receive_msg")) {
     424    if (owl_perlconfig_is_function("BarnOwl::Hooks::_receive_msg")) {
    425425      ptr = owl_perlconfig_call_with_message(subname?subname
    426426                                       :"BarnOwl::_receive_msg_legacy_wrap", m);
     
    506506void owl_perlconfig_mainloop()
    507507{
    508   if (!owl_perlconfig_is_function("BarnOwl::Hooks::mainloop_hook"))
     508  if (!owl_perlconfig_is_function("BarnOwl::Hooks::_mainloop_hook"))
    509509    return;
    510510  dSP ;
    511511  PUSHMARK(SP) ;
    512   call_pv("BarnOwl::Hooks::mainloop_hook", G_DISCARD|G_EVAL);
     512  call_pv("BarnOwl::Hooks::_mainloop_hook", G_DISCARD|G_EVAL);
    513513  if(SvTRUE(ERRSV)) {
    514514    STRLEN n_a;
  • perlwrap.pm

    r37dd88c r1cf32e7d  
    77# XXX NOTE: This file is sourced before almost any barnowl
    88# architecture is loaded. This means, for example, that it cannot
    9 # execute any owl commands. Any code that needs to do so, should
    10 # create a function wrapping it and push it onto @onStartSubs
    11 
     9# execute any owl commands. Any code that needs to do so should live
     10# in BarnOwl::Hooks::_startup
    1211
    1312use strict;
     
    1514
    1615package BarnOwl;
    17 
    1816
    1917BEGIN {
     
    4442    my ($m) = @_;
    4543    $m->legacy_populate_global();
    46     return &BarnOwl::Hooks::receive_msg($m);
     44    return &BarnOwl::Hooks::_receive_msg($m);
    4745}
    4846
     
    204202
    205203sub smartfilter {
    206     die("smartfilter not supported for this message");
     204    die("smartfilter not supported for this message\n");
    207205}
    208206
     
    351349#####################################################################
    352350################################################################################
    353 package BarnOwl;
    354 
    355 ################################################################################
    356 # Mainloop hook
    357 ################################################################################
    358 
    359 our $shutdown;
    360 $shutdown = 0;
    361 our $reload;
    362 $reload = 0;
    363 
    364 #Run this on start and reload. Adds modules
    365 sub onStart
    366 {
    367     _load_owlconf();
    368     reload_init();
    369     loadModules();
    370 }
    371 ################################################################################
    372 # Reload Code, taken from /afs/sipb/user/jdaniel/project/owl/perl
    373 ################################################################################
    374 sub reload_hook (@)
    375 {
    376     BarnOwl::Hooks::startup();
    377     return 1;
    378 }
    379 
    380 sub reload
    381 {
    382     # Use $reload to tell modules that we're performing a reload.
    383   {
    384       local $reload = 1;
    385       BarnOwl::mainloop_hook() if *BarnOwl::mainloop_hook{CODE};
    386   }
    387 
    388   @BarnOwl::Hooks::onMainLoop = ();
    389   @BarnOwl::Hooks::onStartSubs = ();
    390 
    391   # Do reload
    392   package main;
    393   if (-r $BarnOwl::configfile) {
    394       undef $@;
    395       do $BarnOwl::configfile;
    396       BarnOwl::error("Error reloading $BarnOwl::configfile: $@") if $@;
    397   }
    398   BarnOwl::reload_hook(@_);
    399   package BarnOwl;
    400 }
    401 
    402 sub reload_init ()
    403 {
    404     BarnOwl::command('alias reload perl BarnOwl::reload()');
    405     BarnOwl::command('bindkey global "C-x C-r" command reload');
    406 }
    407 
    408 ################################################################################
    409 # Loads modules from ~/.owl/modules and owl's data directory
    410 ################################################################################
    411 
    412 sub loadModules () {
    413     my @modules;
    414     my $rv;
    415     foreach my $dir ( BarnOwl::get_data_dir() . "/modules",
    416                       $ENV{HOME} . "/.owl/modules" )
    417     {
    418         opendir( MODULES, $dir );
    419 
    420         # source ./modules/*.pl
    421         @modules = sort grep( /\.pl$/, readdir(MODULES) );
    422 
    423         foreach my $mod (@modules) {
    424             unless ($rv = do "$dir/$mod") {
    425                 BarnOwl::error("Couldn't load $dir/$mod:\n $@") if $@;
    426                 BarnOwl::error("Couldn't run $dir/$mod:\n $!") unless defined $rv;
    427             }
    428         }
    429         closedir(MODULES);
    430     }
    431 }
     351
     352package BarnOwl::Hook;
     353
     354sub new {
     355    my $class = shift;
     356    return bless [], $class;
     357}
     358
     359sub run {
     360    my $self = shift;
     361    my @args = @_;
     362    return map {$_->(@args)} @$self;
     363}
     364
     365sub add {
     366    my $self = shift;
     367    my $func = shift;
     368    die("Not a coderef!") unless ref($func) eq 'CODE';
     369    push @$self, $func;
     370}
     371
     372sub clear {
     373    my $self = shift;
     374    @$self = ();
     375}
     376
     377package BarnOwl::Hooks;
     378
     379use Exporter;
     380
     381our @EXPORT_OK = qw($startup $shutdown
     382                    $receiveMessage $mainLoop
     383                    $getBuddyList);
     384
     385our %EXPORT_TAGS = (all => [@EXPORT_OK]);
     386
     387our $startup = BarnOwl::Hook->new;
     388our $shutdown = BarnOwl::Hook->new;
     389our $receiveMessage = BarnOwl::Hook->new;
     390our $mainLoop = BarnOwl::Hook->new;
     391our $getBuddyList = BarnOwl::Hook->new;
     392
     393# Internal startup/shutdown routines called by the C code
    432394
    433395sub _load_owlconf {
    434     # Only do this the first time
    435     return if $BarnOwl::reload;
    436396    # load the config  file
    437397    if ( -r $BarnOwl::configfile ) {
     
    451411}
    452412
    453 package BarnOwl::Hooks;
    454 
    455 # Arrays of subrefs to be called at specific times.
    456 our @onStartSubs = ();
    457 our @onReceiveMsg = ();
    458 our @onMainLoop = ();
    459 our @onGetBuddyList = ();
    460 
    461 # Functions to call hook lists
    462 sub runHook($@)
    463 {
    464     my $hook = shift;
    465     my @args = @_;
    466     $_->(@args) for (@$hook);
    467 }
    468 
    469 sub runHook_accumulate($@)
    470 {
    471     my $hook = shift;
    472     my @args = @_;
    473     return join("\n", map {$_->(@args)} @$hook);
    474 }
    475 
    476 ################################################################################
    477 # Startup and Shutdown code
    478 ################################################################################
    479 sub startup
    480 {
    481     # Modern versions of owl provides a great place to have startup stuff.
    482     # Put things in ~/.owl/startup
    483 
    484     #So that the user's .owlconf can have startsubs, we don't clear
    485     #onStartSubs; reload does however
    486     @onReceiveMsg = ();
    487     @onMainLoop = ();
    488     @onGetBuddyList = ();
    489 
    490     BarnOwl::onStart();
    491 
    492     runHook(\@onStartSubs);
    493 
     413sub _startup {
     414    _load_owlconf();
     415
     416    if(eval {require BarnOwl::ModuleLoader}) {
     417        eval {
     418            BarnOwl::ModuleLoader->load_all;
     419        };
     420        BarnOwl::error("Error loading modules: $@") if $@;
     421    } else {
     422        BarnOwl::error("Can't load BarnOwl::ModuleLoader, loadable module support disabled:\n$@");
     423    }
     424   
     425    $startup->run(0);
    494426    BarnOwl::startup() if *BarnOwl::startup{CODE};
    495427}
    496428
    497 sub shutdown
    498 {
    499 # Modern versions of owl provides a great place to have shutdown stuff.
    500 # Put things in ~/.owl/shutdown
    501 
    502     # use $shutdown to tell modules that that's what we're doing.
    503     $BarnOwl::shutdown = 1;
     429sub _shutdown {
     430    $shutdown->run;
     431   
     432    BarnOwl::shutdown() if *BarnOwl::shutdown{CODE};
     433}
     434
     435sub _receive_msg {
     436    my $m = shift;
     437
     438    $receiveMessage->run($m);
     439   
     440    BarnOwl::receive_msg($m) if *BarnOwl::receive_msg{CODE};
     441}
     442
     443sub _mainloop_hook {
     444    $mainLoop->run;
    504445    BarnOwl::mainloop_hook() if *BarnOwl::mainloop_hook{CODE};
    505 
    506     BarnOwl::shutdown() if *BarnOwl::shutdown{CODE};
    507 }
    508 
    509 sub mainloop_hook
    510 {
    511     runHook(\@onMainLoop);
    512     BarnOwl::mainloop_hook() if *BarnOwl::mainloop_hook{CODE};
    513 }
    514 
    515 ################################################################################
    516 # Hooks into receive_msg()
    517 ################################################################################
    518 
    519 sub receive_msg
    520 {
    521     my $m = shift;
    522     runHook(\@onReceiveMsg, $m);
    523     BarnOwl::receive_msg($m) if *BarnOwl::receive_msg{CODE};
    524 }
    525 
    526 ################################################################################
    527 # Hooks into get_blist()
    528 ################################################################################
    529 
    530 sub get_blist
    531 {
    532     return runHook_accumulate(\@onGetBuddyList);
     446}
     447
     448sub _get_blist {
     449    return join("\n", $getBuddyList->run);
    533450}
    534451
     
    644561# switch to package main when we're done
    645562package main;
    646 # alias the hooks
    647 {
    648     no strict 'refs';
    649     foreach my $hook  qw (onStartSubs
    650                           onReceiveMsg
    651                           onMainLoop
    652                           onGetBuddyList ) {
    653         *{"main::".$hook} = \*{"BarnOwl::Hooks::".$hook};
    654         *{"owl::".$hook} = \*{"BarnOwl::Hooks::".$hook};
    655     }
    656 }
     563
     564# Shove a bunch of fake entries into @INC so modules can use or
     565# require them without choking
     566$::INC{$_} = 1 for (qw(BarnOwl.pm BarnOwl/Hooks.pm
     567                       BarnOwl/Message.pm BarnOwl/Style.pm));
    657568
    6585691;
     570
  • logging.c

    r5c30091 r3066d23  
    363363  if (owl_message_is_type_zephyr(m)) {
    364364    if (personal) {
    365       if (owl_message_is_type_zephyr(m)) {
    366         from=frombuff=short_zuser(owl_message_get_sender(m));
    367       }
     365      from=frombuff=short_zuser(owl_message_get_sender(m));
    368366    } else {
    369367      from=frombuff=owl_strdup(owl_message_get_class(m));
     
    384382      from=frombuff=owl_sprintf("jabber:%s",owl_message_get_recipient(m));
    385383    }
    386      
    387384  } else {
    388385    from=frombuff=owl_strdup("unknown");
  • perlglue.xs

    rb6c067a r3066d23  
    121121        {
    122122                if(!SvROK(msg) || SvTYPE(SvRV(msg)) != SVt_PVHV) {
    123                         croak("Usage: owl::queue_message($message)");
     123                        croak("Usage: BarnOwl::queue_message($message)");
    124124                }
    125125
     
    136136        {
    137137                if(!SvROK(msg) || SvTYPE(SvRV(msg)) != SVt_PVHV) {
    138                         croak("Usage: owl::add_message($message)");
     138                        croak("Usage: BarnOwl::add_message($message)");
    139139                }
    140140
     
    142142                        m = owl_perlconfig_hashref2message(msg);
    143143                        owl_function_add_message(m);
     144                }
     145        }
     146
     147void log_message(msg)
     148        SV *msg
     149        PREINIT:
     150                owl_message *m;
     151        CODE:
     152        {
     153                if(!SvROK(msg) || SvTYPE(SvRV(msg)) != SVt_PVHV) {
     154                        croak("Usage: BarnOwl::log_message($message)");
     155                }
     156
     157                m = owl_perlconfig_hashref2message(msg);
     158                owl_log_message(m);
     159                owl_message_free(m);
     160        }
     161
     162void add_and_log_message(msg)
     163        SV *msg
     164        PREINIT:
     165                owl_message *m;
     166        CODE:
     167        {
     168                if(!SvROK(msg) || SvTYPE(SvRV(msg)) != SVt_PVHV) {
     169                        croak("Usage: BarnOwl::add_and_log_message($message)");
     170                }
     171
     172                m = owl_perlconfig_hashref2message(msg);
     173                owl_log_message(m);
     174                if (owl_global_is_displayoutgoing(&g)) {
     175                        owl_function_add_message(m);
     176                } else {
     177                        owl_message_free(m);
    144178                }
    145179        }
Note: See TracChangeset for help on using the changeset viewer.