[255] in BarnOwl Developers

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

[D-O-H] r429 - trunk/owl

daemon@ATHENA.MIT.EDU (aatharuv@MIT.EDU)
Thu Oct 29 18:04:11 2009

Resent-From: nelhage@mit.edu
Resent-To: barnowl-dev-mtg@charon.mit.edu
Date: Sun, 29 Oct 2006 19:18:32 -0500 (EST)
To: dirty-owl-hackers@mit.edu
From: aatharuv@MIT.EDU
Reply-To: dirty-owl-hackers@MIT.EDU

Author: aatharuv
Date: 2006-10-29 19:18:30 -0500 (Sun, 29 Oct 2006)
New Revision: 429

Modified:
   trunk/owl/logging.c
Log:
Logging for jabber.


Modified: trunk/owl/logging.c
===================================================================
--- trunk/owl/logging.c	2006-10-30 00:06:35 UTC (rev 428)
+++ trunk/owl/logging.c	2006-10-30 00:18:30 UTC (rev 429)
@@ -38,7 +38,9 @@
     owl_log_outgoing_zephyr(m);
   } else if (owl_message_is_type_loopback(m)) {
     owl_log_outgoing_loopback(m);
-  } else {
+  } else if (owl_message_is_type_jabber(m)) {
+   owl_log_outgoing_jabber(m);	  
+  }else {
     owl_function_error("Unknown message type for logging");
   }
   owl_function_debugmsg("owl_log_message: leaving");
@@ -182,6 +184,56 @@
   owl_free(tobuff);
 }
 
+void owl_log_outgoing_jabber(owl_message *m)
+{
+  FILE *file;
+  char filename[MAXPATHLEN], *logpath;
+  char *tobuff, *normalto, *text;
+  owl_function_debugmsg("owl_log_outgoing_jabber: entering");
+  /* normalize and downcase the screenname */
+  normalto = owl_message_get_recipient(m);
+  
+  /* downstr(normalto); */
+  tobuff=owl_sprintf("jabber:%s", normalto);
+  /* owl_free(normalto); */
+
+  /* expand ~ in path names */
+  logpath = owl_text_substitute(owl_global_get_logpath(&g), "~", owl_global_get_homedir(&g));
+
+  text=owl_message_get_body(m);
+  
+  snprintf(filename, MAXPATHLEN, "%s/%s", logpath, tobuff);
+  file=fopen(filename, "a");
+  if (!file) {
+    owl_function_error("Unable to open file for outgoing logging");
+    owl_free(logpath);
+    owl_free(tobuff);
+    return;
+  }
+  fprintf(file, "OUTGOING (owl): %s\n%s\n", tobuff, text);
+  if (text[strlen(text)-1]!='\n') {
+    fprintf(file, "\n");
+  }
+  fclose(file);
+
+  snprintf(filename, MAXPATHLEN, "%s/all", logpath);
+  owl_free(logpath);
+  file=fopen(filename, "a");
+  if (!file) {
+    owl_function_error("Unable to open file for outgoing logging");
+    owl_free(tobuff);
+    return;
+  }
+  fprintf(file, "OUTGOING (owl): %s\n%s\n", tobuff, text);
+  if (text[strlen(text)-1]!='\n') {
+    fprintf(file, "\n");
+  }
+  fclose(file);
+
+  owl_free(tobuff);
+}
+
+
 void owl_log_outgoing_aim(owl_message *m)
 {
   FILE *file;
@@ -290,6 +342,14 @@
     } else {
       personal=0;
     }
+  } else if (owl_message_is_type_jabber(m)) {
+	  /* This needs to be fixed to handle groupchat */
+	  char* msgtype = owl_message_get_attribute_value(m,"jtype");
+	  if (msgtype && !strcmp(msgtype,"groupchat")) {
+		  personal =0;
+	  } else {
+  	     personal=1;
+	  }
   } else {
     if (owl_message_is_private(m) || owl_message_is_loginout(m)) {
       personal=1;
@@ -298,6 +358,8 @@
     }
   }
 
+  
+
   if (owl_message_is_type_zephyr(m)) {
     if (personal) {
       if (owl_message_is_type_zephyr(m)) {
@@ -315,6 +377,8 @@
     owl_free(normalto);
   } else if (owl_message_is_type_loopback(m)) {
     from=frombuff=owl_strdup("loopback");
+  } else if (owl_message_is_type_jabber(m)) {
+        from=frombuff=owl_sprintf("jabber:%s",owl_message_get_sender(m));
   } else {
     from=frombuff=owl_strdup("unknown");
   }


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