changeset 889:ae93e69aaaaf

Fix up pending message flag for the status special buffer It's still disabled (because it isn't useful as is).
author Mikael Berthe <mikael@lilotux.net>
date Tue, 30 May 2006 23:22:37 +0200
parents 578d2034e971
children 788e088702d6
files mcabber/src/roster.c mcabber/src/roster.h mcabber/src/screen.c
diffstat 3 files changed, 41 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/src/roster.c	Tue May 30 20:36:44 2006 +0200
+++ b/mcabber/src/roster.c	Tue May 30 23:22:37 2006 +0200
@@ -99,7 +99,7 @@
 
 void roster_init(void)
 {
-  roster_special.name = "[status]";
+  roster_special.name = SPECIAL_BUFFER_STATUS_ID;
   roster_special.type = ROSTER_TYPE_SPECIAL;
 }
 
@@ -528,12 +528,32 @@
 // Set the ROSTER_FLAG_MSG to the given value for the given jid.
 // It will update the buddy's group message flag.
 // Update the unread messages list too.
-void roster_msg_setflag(const char *jid, guint value)
+void roster_msg_setflag(const char *jid, guint special, guint value)
 {
   GSList *sl_user;
   roster *roster_usr, *roster_grp;
   int new_roster_item = FALSE;
 
+  if (special) {
+    //sl_user = roster_find(jid, namesearch, ROSTER_TYPE_SPECIAL);
+    //if (!sl_user) return;
+    //roster_usr = (roster*)sl_user->data;
+    roster_usr = &roster_special;
+    if (value) {
+      roster_usr->flags |= ROSTER_FLAG_MSG;
+      // Append the roster_usr to unread_list, but avoid duplicates
+      if (!g_slist_find(unread_list, roster_usr))
+        unread_list = g_slist_append(unread_list, roster_usr);
+    } else {
+      roster_usr->flags &= ~ROSTER_FLAG_MSG;
+      if (unread_list) {
+        GSList *node = g_slist_find(unread_list, roster_usr);
+        if (node) unread_list = g_slist_delete_link(unread_list, node);
+      }
+    }
+    return;
+  }
+
   sl_user = roster_find(jid, jidsearch,
                         ROSTER_TYPE_USER|ROSTER_TYPE_ROOM|ROSTER_TYPE_AGENT);
   // If we can't find it, we add it
--- a/mcabber/src/roster.h	Tue May 30 20:36:44 2006 +0200
+++ b/mcabber/src/roster.h	Tue May 30 23:22:37 2006 +0200
@@ -4,6 +4,8 @@
 #include <glib.h>
 #include <time.h>
 
+#define SPECIAL_BUFFER_STATUS_ID  "[status]"
+
 enum imstatus {
     offline,
     available,
@@ -94,7 +96,7 @@
                          enum imrole role, enum imaffiliation affil,
                          const char *realjid);
 void    roster_setflags(const char *jid, guint flags, guint value);
-void    roster_msg_setflag(const char *jid, guint value);
+void    roster_msg_setflag(const char *jid, guint special, guint value);
 const char *roster_getname(const char *jid);
 const char *roster_getnickname(const char *jid);
 void    roster_settype(const char *jid, guint type);
--- a/mcabber/src/screen.c	Tue May 30 20:36:44 2006 +0200
+++ b/mcabber/src/screen.c	Tue May 30 23:22:37 2006 +0200
@@ -603,11 +603,10 @@
   top_panel(win_entry->panel);
   currentWindow = win_entry;
   chatmode = TRUE;
-  if (!special) {
-    if (!win_entry->lock)
-      roster_msg_setflag(winId, FALSE);
+  if (!win_entry->lock)
+    roster_msg_setflag(winId, special, FALSE);
+  if (!special)
     roster_setflags(winId, ROSTER_FLAG_LOCK, TRUE);
-  }
   update_roster = TRUE;
 
   // Refresh the window
@@ -736,7 +735,9 @@
     setmsgflg = TRUE;
   }
   if (setmsgflg && !special) {
-    roster_msg_setflag(winId, TRUE);
+    if (special && !winId)
+      winId = SPECIAL_BUFFER_STATUS_ID;
+    roster_msg_setflag(winId, special, TRUE);
     update_roster = TRUE;
   }
 }
@@ -1431,7 +1432,6 @@
 {
   gpointer unread_ptr;
   gpointer refbuddata;
-  gpointer ngroup;
   GList *nbuddy;
 
   if (!current_buddy) return;
@@ -1442,11 +1442,14 @@
   unread_ptr = unread_msg(refbuddata);
   if (!unread_ptr) return;
 
-  // If buddy is in a folded group, we need to expand it
-  ngroup = buddy_getgroup(unread_ptr);
-  if (buddy_getflags(ngroup) & ROSTER_FLAG_HIDE) {
-    buddy_setflags(ngroup, ROSTER_FLAG_HIDE, FALSE);
-    buddylist_build();
+  if (!(buddy_gettype(unread_ptr) & ROSTER_TYPE_SPECIAL)) {
+    gpointer ngroup;
+    // If buddy is in a folded group, we need to expand it
+    ngroup = buddy_getgroup(unread_ptr);
+    if (buddy_getflags(ngroup) & ROSTER_FLAG_HIDE) {
+      buddy_setflags(ngroup, ROSTER_FLAG_HIDE, FALSE);
+      buddylist_build();
+    }
   }
 
   nbuddy = g_list_find(buddylist, unread_ptr);
@@ -1771,12 +1774,12 @@
 {
   const char *current_jid;
   bool iscurrentlocked = FALSE;
+  guint isspe = FALSE;
 
   if (!jid)
     return;
 
   if (current_buddy) {
-    guint isspe;
     isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL;
     current_jid = buddy_getjid(BUDDATA(current_buddy));
     if (current_jid) {
@@ -1788,7 +1791,7 @@
     current_jid = NULL;
   }
   if (!chatmode || !current_jid || strcmp(jid, current_jid) || iscurrentlocked)
-    roster_msg_setflag(jid, TRUE);
+    roster_msg_setflag(jid, isspe, TRUE);
 }
 
 //  scr_set_multimode()