Changeset 0f9eca7


Ignore:
Timestamp:
Aug 3, 2008, 10:00:30 PM (13 years ago)
Author:
Geoffrey Thomas <geofft@mit.edu>
Branches:
master, debian, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
d81f8d0
Parents:
719c699
Message:
Add a hook, newMessage, that catches every message that's added to the message
list. receiveMessage only sees incoming messages, and I don't want to change
that behavior. newMessage is probably most useful for people writing fancy
loggers in Perl.
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • owl.c

    rb1fd36e r0f9eca7  
    605605  }
    606606
     607  /* let perl know about it */
     608  owl_perlconfig_newmsg(m, NULL);
    607609  /* log the message if we need to */
    608610  owl_log_message(m);
  • perlconfig.c

    rdb0ac7e r0f9eca7  
    421421}
    422422
     423/* Called on all new messages; receivemsg is only called on incoming ones */
     424void owl_perlconfig_newmsg(owl_message *m, char *subname)
     425{
     426  char *ptr = NULL;
     427  if (owl_perlconfig_is_function("BarnOwl::Hooks::_new_msg")) {
     428    ptr = owl_perlconfig_call_with_message(subname?subname
     429                                           :"BarnOwl::Hooks::_new_msg", m);
     430  }
     431  if (ptr) owl_free(ptr);
     432}
     433
    423434char *owl_perlconfig_perlcmd(owl_cmd *cmd, int argc, char **argv)
    424435{
  • perlwrap.pm

    racb13bb r0f9eca7  
    685685
    686686our @EXPORT_OK = qw($startup $shutdown
    687                     $receiveMessage $mainLoop
    688                     $getBuddyList);
     687                    $receiveMessage $newMessage
     688                    $mainLoop $getBuddyList);
    689689
    690690our %EXPORT_TAGS = (all => [@EXPORT_OK]);
     
    693693our $shutdown = BarnOwl::Hook->new;
    694694our $receiveMessage = BarnOwl::Hook->new;
     695our $newMessage = BarnOwl::Hook->new;
    695696our $mainLoop = BarnOwl::Hook->new;
    696697our $getBuddyList = BarnOwl::Hook->new;
     
    771772}
    772773
     774sub _new_msg {
     775    my $m = shift;
     776
     777    $newMessage->run($m);
     778   
     779    BarnOwl::new_msg($m) if *BarnOwl::new_msg{CODE};
     780}
     781
    773782sub _mainloop_hook {
    774783    $mainLoop->run;
Note: See TracChangeset for help on using the changeset viewer.