[558] in BarnOwl Developers

home help back first fref pref prev next nref lref last post

[D-O-H] r676 - in trunk/owl: . perl/modules

daemon@ATHENA.MIT.EDU (asedeno@MIT.EDU)
Thu Oct 29 18:07:24 2009

Resent-From: nelhage@mit.edu
Resent-To: barnowl-dev-mtg@charon.mit.edu
To: dirty-owl-hackers@mit.edu
From: asedeno@MIT.EDU
Reply-to: dirty-owl-hackers@MIT.EDU
Date: Thu, 22 Mar 2007 11:30:13 -0400 (EDT)

Author: asedeno
Date: 2007-03-22 11:30:13 -0400 (Thu, 22 Mar 2007)
New Revision: 676

Modified:
   trunk/owl/logging.c
   trunk/owl/perl/modules/jabber.pl
   trunk/owl/perlglue.xs
Log:
Fix outgoing jabber logging.

Added two new perlglue functions:

* log_message - takes a message hash, turns it into an owl message,
and passes it to the logger.

* add_and_log_message - combination off add_message and
log_message. Takes a message hash, turns it into an owl message, logs
it, and adds the same message to the message list if needed. This
exists for convenience, so we don't have to convert the message hash
twice.

Also, took out an extraneous check from logging.c.



Modified: trunk/owl/logging.c
===================================================================
--- trunk/owl/logging.c	2007-03-22 01:26:16 UTC (rev 675)
+++ trunk/owl/logging.c	2007-03-22 15:30:13 UTC (rev 676)
@@ -362,9 +362,7 @@
 
   if (owl_message_is_type_zephyr(m)) {
     if (personal) {
-      if (owl_message_is_type_zephyr(m)) {
-	from=frombuff=short_zuser(owl_message_get_sender(m));
-      }
+      from=frombuff=short_zuser(owl_message_get_sender(m));
     } else {
       from=frombuff=owl_strdup(owl_message_get_class(m));
     }
@@ -383,7 +381,6 @@
     } else {
       from=frombuff=owl_sprintf("jabber:%s",owl_message_get_recipient(m));
     }
-      
   } else {
     from=frombuff=owl_strdup("unknown");
   }

Modified: trunk/owl/perl/modules/jabber.pl
===================================================================
--- trunk/owl/perl/modules/jabber.pl	2007-03-22 01:26:16 UTC (rev 675)
+++ trunk/owl/perl/modules/jabber.pl	2007-03-22 15:30:13 UTC (rev 676)
@@ -1025,7 +1025,7 @@
 
     my $m = j2o( $j, { direction => 'out' } );
     if ( $vars{jwrite}{type} ne 'groupchat') {
-        BarnOwl::add_message($m);
+        BarnOwl::add_and_log_message($m);
     }
 
     $j->RemoveFrom(); # Kludge to get around gtalk's random bits after the resource.

Modified: trunk/owl/perlglue.xs
===================================================================
--- trunk/owl/perlglue.xs	2007-03-22 01:26:16 UTC (rev 675)
+++ trunk/owl/perlglue.xs	2007-03-22 15:30:13 UTC (rev 676)
@@ -120,7 +120,7 @@
 	CODE:
 	{
 		if(!SvROK(msg) || SvTYPE(SvRV(msg)) != SVt_PVHV) {
-			croak("Usage: owl::queue_message($message)");
+			croak("Usage: BarnOwl::queue_message($message)");
 		}
 
 		m = owl_perlconfig_hashref2message(msg);
@@ -135,7 +135,7 @@
 	CODE:
 	{
 		if(!SvROK(msg) || SvTYPE(SvRV(msg)) != SVt_PVHV) {
-			croak("Usage: owl::add_message($message)");
+			croak("Usage: BarnOwl::add_message($message)");
 		}
 
 		if (owl_global_is_displayoutgoing(&g)) {
@@ -144,6 +144,40 @@
 		}
 	}
 
+void log_message(msg) 
+	SV *msg
+	PREINIT:
+		owl_message *m;
+	CODE:
+	{
+		if(!SvROK(msg) || SvTYPE(SvRV(msg)) != SVt_PVHV) {
+			croak("Usage: BarnOwl::log_message($message)");
+		}
+
+		m = owl_perlconfig_hashref2message(msg);
+		owl_log_message(m);
+		owl_message_free(m);
+	}
+
+void add_and_log_message(msg) 
+	SV *msg
+	PREINIT:
+		owl_message *m;
+	CODE:
+	{
+		if(!SvROK(msg) || SvTYPE(SvRV(msg)) != SVt_PVHV) {
+			croak("Usage: BarnOwl::add_and_log_message($message)");
+		}
+
+		m = owl_perlconfig_hashref2message(msg);
+		owl_log_message(m);
+		if (owl_global_is_displayoutgoing(&g)) {
+			owl_function_add_message(m);
+		} else {
+			owl_message_free(m);
+		}
+	}
+
 void admin_message(header, body) 
 	char *header
 	char *body


home help back first fref pref prev next nref lref last post