[1151] in BarnOwl Developers
[D-O-H] r1099 - trunk/owl
daemon@ATHENA.MIT.EDU (geofft@MIT.EDU)
Thu Oct 29 18:13:32 2009
Resent-From: nelhage@mit.edu
Resent-To: barnowl-dev-mtg@charon.mit.edu
X-Original-To: nelhage@nelhage.com
Date: Sun, 3 Aug 2008 22:00:30 -0400 (EDT)
To: dirty-owl-hackers@MIT.EDU
From: geofft@MIT.EDU
Reply-to: dirty-owl-hackers@MIT.EDU
Author: geofft
Date: 2008-08-03 22:00:30 -0400 (Sun, 03 Aug 2008)
New Revision: 1099
Modified:
trunk/owl/
trunk/owl/owl.c
trunk/owl/perlconfig.c
trunk/owl/perlwrap.pm
Log:
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.
Property changes on: trunk/owl
___________________________________________________________________
Name: svn:ignore
- Makefile
TAGS
autom4te.cache
barnowl
config.h
config.in
config.log
config.status
configure
core
jabber.log
owl_prototypes.*
perlglue.c
perlwrap.c
tester
varstubs.c
*.o
+ Makefile
TAGS
autom4te.cache
barnowl
config.h
config.in
config.log
config.status
config.cache
configure
core
jabber.log
owl_prototypes.*
perlglue.c
perlwrap.c
tester
varstubs.c
*.o
Modified: trunk/owl/owl.c
===================================================================
--- trunk/owl/owl.c 2008-08-03 23:27:27 UTC (rev 1098)
+++ trunk/owl/owl.c 2008-08-04 02:00:30 UTC (rev 1099)
@@ -604,6 +604,8 @@
}
}
+ /* let perl know about it */
+ owl_perlconfig_newmsg(m, NULL);
/* log the message if we need to */
owl_log_message(m);
Modified: trunk/owl/perlconfig.c
===================================================================
--- trunk/owl/perlconfig.c 2008-08-03 23:27:27 UTC (rev 1098)
+++ trunk/owl/perlconfig.c 2008-08-04 02:00:30 UTC (rev 1099)
@@ -420,6 +420,17 @@
if (ptr) owl_free(ptr);
}
+/* Called on all new messages; receivemsg is only called on incoming ones */
+void owl_perlconfig_newmsg(owl_message *m, char *subname)
+{
+ char *ptr = NULL;
+ if (owl_perlconfig_is_function("BarnOwl::Hooks::_new_msg")) {
+ ptr = owl_perlconfig_call_with_message(subname?subname
+ :"BarnOwl::Hooks::_new_msg", m);
+ }
+ if (ptr) owl_free(ptr);
+}
+
char *owl_perlconfig_perlcmd(owl_cmd *cmd, int argc, char **argv)
{
int i, count;
Modified: trunk/owl/perlwrap.pm
===================================================================
--- trunk/owl/perlwrap.pm 2008-08-03 23:27:27 UTC (rev 1098)
+++ trunk/owl/perlwrap.pm 2008-08-04 02:00:30 UTC (rev 1099)
@@ -684,14 +684,15 @@
use Exporter;
our @EXPORT_OK = qw($startup $shutdown
- $receiveMessage $mainLoop
- $getBuddyList);
+ $receiveMessage $newMessage
+ $mainLoop $getBuddyList);
our %EXPORT_TAGS = (all => [@EXPORT_OK]);
our $startup = BarnOwl::Hook->new;
our $shutdown = BarnOwl::Hook->new;
our $receiveMessage = BarnOwl::Hook->new;
+our $newMessage = BarnOwl::Hook->new;
our $mainLoop = BarnOwl::Hook->new;
our $getBuddyList = BarnOwl::Hook->new;
@@ -770,6 +771,14 @@
BarnOwl::receive_msg($m) if *BarnOwl::receive_msg{CODE};
}
+sub _new_msg {
+ my $m = shift;
+
+ $newMessage->run($m);
+
+ BarnOwl::new_msg($m) if *BarnOwl::new_msg{CODE};
+}
+
sub _mainloop_hook {
$mainLoop->run;
BarnOwl::mainloop_hook() if *BarnOwl::mainloop_hook{CODE};