changeset 484:00e2d3821a5b

Display PRIV for private messages in a room when using /say_to Private conf. messages are not logged.
author Mikael Berthe <mikael@lilotux.net>
date Thu, 06 Oct 2005 21:51:34 +0200
parents 4a10c04ac2fb
children 55aa45eb7ece
files mcabber/src/commands.c mcabber/src/hooks.c mcabber/src/hooks.h
diffstat 3 files changed, 29 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/src/commands.c	Wed Oct 05 21:46:13 2005 +0200
+++ b/mcabber/src/commands.c	Thu Oct 06 21:51:34 2005 +0200
@@ -252,7 +252,7 @@
 
   if (buddy_gettype(BUDDATA(current_buddy)) != ROSTER_TYPE_ROOM) {
     // local part (UI, logging, etc.)
-    hk_message_out(jid, 0, msg);
+    hk_message_out(jid, NULL, 0, msg);
   }
 
   // Network part
@@ -693,8 +693,15 @@
   // Jump to window, create one if needed
   scr_RosterJumpJid(bare_jid);
 
+  // Check if we're sending a message to a conference room
+  // If not, we must make sure p is NULL, for hk_message_out()
+  if (p) {
+    if (roster_find(bare_jid, jidsearch, ROSTER_TYPE_ROOM)) p++;
+    else p = NULL;
+  }
+
   // local part (UI, logging, etc.)
-  hk_message_out(bare_jid, 0, msg);
+  hk_message_out(bare_jid, p, 0, msg);
 
   // Network part
   jb_send_msg(jid, msg, ROSTER_TYPE_USER, NULL);
--- a/mcabber/src/hooks.c	Wed Oct 05 21:46:13 2005 +0200
+++ b/mcabber/src/hooks.c	Thu Oct 06 21:51:34 2005 +0200
@@ -113,12 +113,27 @@
   if (bmsg) g_free(bmsg);
 }
 
-inline void hk_message_out(const char *jid, time_t timestamp, const char *msg)
+//  hk_message_out()
+// nick should be set for private messages in a chat room, and null for
+// normal messages.
+inline void hk_message_out(const char *jid, const char *nick,
+                           time_t timestamp, const char *msg)
 {
-  scr_WriteOutgoingMessage(jid, msg);
-  hlog_write_message(jid, timestamp, TRUE, msg);
+  char *wmsg = NULL, *bmsg = NULL;
+
+  if (nick) {
+    wmsg = bmsg = g_strdup_printf("PRIV#<%s> %s", nick, msg);
+  } else {
+    wmsg = (char*)msg;
+    // We don't log private messages
+    hlog_write_message(jid, timestamp, TRUE, msg);
+  }
+
+  scr_WriteOutgoingMessage(jid, wmsg);
   // External command
   hk_ext_cmd(jid, 'M', 'S', NULL);
+
+  if (bmsg) g_free(bmsg);
 }
 
 inline void hk_statuschange(const char *jid, const char *resname, gchar prio,
--- a/mcabber/src/hooks.h	Wed Oct 05 21:46:13 2005 +0200
+++ b/mcabber/src/hooks.h	Thu Oct 06 21:51:34 2005 +0200
@@ -7,7 +7,8 @@
 
 inline void hk_message_in(const char *jid, const char *resname,
                           time_t timestamp, const char *msg, const char *type);
-inline void hk_message_out(const char *jid, time_t timestamp, const char *msg);
+inline void hk_message_out(const char *jid, const char *nickname,
+                           time_t timestamp, const char *msg);
 inline void hk_statuschange(const char *jid, const char *resname, gchar prio,
                             time_t timestamp, enum imstatus status,
                             char const *status_msg);