Show status changes in buddy window, if it is open
authorMikael Berthe <mikael@lilotux.net>
Sun, 13 Nov 2005 22:46:46 +0100
changeset 514 979eb0fe2969
parent 513 d40c434fff46
child 515 180f0a6e4ac9
Show status changes in buddy window, if it is open
mcabber/src/hooks.c
mcabber/src/screen.c
mcabber/src/screen.h
--- a/mcabber/src/hooks.c	Sun Nov 13 22:15:19 2005 +0100
+++ b/mcabber/src/hooks.c	Sun Nov 13 22:46:46 2005 +0100
@@ -171,6 +171,17 @@
                imstatus2char[status], bn,
                ((status_msg) ? status_msg : ""));
   g_free(bn);
+
+  // Write the status change in the buddy's buffer, only if it already exists
+  if (scr_BuddyBufferExists(jid)) {
+    bn = g_strdup_printf("Buddy status has changed: [%c>%c] %s",
+                         imstatus2char[roster_getstatus(jid, resname)],
+                         imstatus2char[status],
+                         ((status_msg) ? status_msg : ""));
+    scr_WriteIncomingMessage(jid, bn, 0, HBB_PREFIX_INFO|HBB_PREFIX_NOFLAG);
+    g_free(bn);
+  }
+
   roster_setstatus(jid, rn, prio, status, status_msg, role_none, NULL);
   buddylist_build();
   scr_DrawRoster();
--- a/mcabber/src/screen.c	Sun Nov 13 22:15:19 2005 +0100
+++ b/mcabber/src/screen.c	Sun Nov 13 22:46:46 2005 +0100
@@ -345,6 +345,11 @@
   return NULL;
 }
 
+bool scr_BuddyBufferExists(const char *jid)
+{
+  return (scr_SearchWindow(jid) != NULL);
+}
+
 //  scr_UpdateWindow()
 // (Re-)Display the given chat window.
 static void scr_UpdateWindow(window_entry_t *win_entry)
--- a/mcabber/src/screen.h	Sun Nov 13 22:15:19 2005 +0100
+++ b/mcabber/src/screen.h	Sun Nov 13 22:46:46 2005 +0100
@@ -33,6 +33,7 @@
         time_t timestamp, guint prefix);
 void scr_WriteOutgoingMessage(const char *jidto,   const char *text);
 void scr_ShowBuddyWindow(void);
+bool scr_BuddyBufferExists(const char *jid);
 inline void scr_set_chatmode(int enable);
 inline void scr_set_multimode(int enable);
 inline int  scr_get_multimode();