changeset 119:d7fbd5293385

[/trunk] Changeset 132 by mikael * Current buddy should not be removed from the buddylist * It should be removed if it is offline and the cursor moves.
author mikael
date Mon, 25 Apr 2005 20:34:59 +0000
parents 1e8f646e2c5b
children cfd3df636d5f
files mcabber/src/TODO.txt mcabber/src/jabglue.c mcabber/src/roster.c mcabber/src/roster.h mcabber/src/screen.c
diffstat 5 files changed, 63 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/src/TODO.txt	Mon Apr 25 19:02:07 2005 +0000
+++ b/mcabber/src/TODO.txt	Mon Apr 25 20:34:59 2005 +0000
@@ -3,7 +3,8 @@
 
 * Should not stay on buddy buffer when one moves to a group
 * Pending message not displayed if buddy outside Contact window
-* Current buddy should not be removed from the buddylist
+* We should rebuild the buddy list when receiving a message from an offline
+  buddy.
 
 
 TODO:
--- a/mcabber/src/jabglue.c	Mon Apr 25 19:02:07 2005 +0000
+++ b/mcabber/src/jabglue.c	Mon Apr 25 20:34:59 2005 +0000
@@ -674,12 +674,6 @@
         }
 
         r = jidtodisp(from);
-        /*
-        if (ust != roster_getstatus(r))
-          scr_LogPrint("Buddy status has changed: [%c>%c] <%s>",
-                  imstatus2char[roster_getstatus(r)], imstatus2char[ust], r);
-        roster_setstatus(r, ust);
-        */
         if (ust != roster_getstatus(r))
           hk_statuschange(r, 0, ust);
         free(r);
--- a/mcabber/src/roster.c	Mon Apr 25 19:02:07 2005 +0000
+++ b/mcabber/src/roster.c	Mon Apr 25 20:34:59 2005 +0000
@@ -391,6 +391,17 @@
   return roster->status;
 }
 
+//  buddy_setflags()
+// Set one or several flags to value (TRUE/FALSE)
+void buddy_setflags(gpointer rosterdata, guint flags, guint value)
+{
+  roster *roster = rosterdata;
+  if (value)
+    roster->flags |= flags;
+  else
+    roster->flags &= ~flags;
+}
+
 guint buddy_getflags(gpointer rosterdata)
 {
   roster *roster = rosterdata;
--- a/mcabber/src/roster.h	Mon Apr 25 19:02:07 2005 +0000
+++ b/mcabber/src/roster.h	Mon Apr 25 20:34:59 2005 +0000
@@ -51,6 +51,7 @@
 const char *buddy_getname(gpointer rosterdata);
 guint buddy_gettype(gpointer rosterdata);
 enum imstatus buddy_getstatus(gpointer rosterdata);
+void buddy_setflags(gpointer rosterdata, guint flags, guint value);
 guint buddy_getflags(gpointer rosterdata);
 
 #endif /* __ROSTER_H__ */
--- a/mcabber/src/screen.c	Mon Apr 25 19:02:07 2005 +0000
+++ b/mcabber/src/screen.c	Mon Apr 25 20:34:59 2005 +0000
@@ -288,6 +288,7 @@
     currentWindow = win_entry;
     chatmode = TRUE;
     roster_setflags(winId, ROSTER_FLAG_MSG, FALSE);
+    roster_setflags(winId, ROSTER_FLAG_LOCK, TRUE);
     update_roster = TRUE;
 
     // Refresh the window
@@ -564,29 +565,61 @@
 
 void scr_RosterTop(void)
 {
+  enum imstatus prev_st;
+
+  if (current_buddy) {
+    prev_st = buddy_getstatus(BUDDATA(current_buddy));
+    if (chatmode)
+      buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE);
+  }
   current_buddy = buddylist;
-  // XXX We should rebuild the buddylist but perhaps not everytime?
+  if (chatmode && current_buddy)
+    buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, TRUE);
+
+  // We should rebuild the buddylist but not everytime
+  if (current_buddy && prev_st == offline)
+    buddylist_build();
   if (chatmode)
     scr_ShowBuddyWindow();
 }
 
 void scr_RosterBottom(void)
 {
+  enum imstatus prev_st;
+
+  if (current_buddy) {
+    prev_st = buddy_getstatus(BUDDATA(current_buddy));
+    if (chatmode)
+      buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE);
+  }
   current_buddy = g_list_last(buddylist);
-  // XXX We should rebuild the buddylist but perhaps not everytime?
+  if (chatmode && current_buddy)
+    buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, TRUE);
+
+  // We should rebuild the buddylist but not everytime
+  if (current_buddy && prev_st == offline)
+    buddylist_build();
   if (chatmode)
     scr_ShowBuddyWindow();
 }
 
 void scr_RosterUp(void)
 {
+  enum imstatus prev_st;
+
   if (current_buddy) {
+    prev_st = buddy_getstatus(BUDDATA(current_buddy));
     if (g_list_previous(current_buddy)) {
+      buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE);
       current_buddy = g_list_previous(current_buddy);
+      if (chatmode)
+        buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, TRUE);
+      // We should rebuild the buddylist but not everytime
+      if (prev_st == offline)
+        buddylist_build();
       scr_DrawRoster();
     }
   }
-  // XXX We should rebuild the buddylist but perhaps not everytime?
 
   if (chatmode)
     scr_ShowBuddyWindow();
@@ -594,13 +627,21 @@
 
 void scr_RosterDown(void)
 {
+  enum imstatus prev_st;
+
   if (current_buddy) {
+    prev_st = buddy_getstatus(BUDDATA(current_buddy));
     if (g_list_next(current_buddy)) {
+      buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE);
       current_buddy = g_list_next(current_buddy);
+      if (chatmode)
+        buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, TRUE);
+      // We should rebuild the buddylist but not everytime
+      if (prev_st == offline)
+        buddylist_build();
       scr_DrawRoster();
     }
   }
-  // XXX We should rebuild the buddylist but perhaps not everytime?
 
   if (chatmode)
     scr_ShowBuddyWindow();
@@ -931,6 +972,8 @@
           break;
       case '\n':  // Enter
           chatmode = TRUE;
+          if (current_buddy)
+            buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, TRUE);
           if (inputLine[0] == 0) {
             scr_ShowBuddyWindow();
             break;
@@ -981,6 +1024,8 @@
       case 27:  // ESC
           currentWindow = NULL;
           chatmode = FALSE;
+          if (current_buddy)
+            buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE);
           top_panel(chatPanel);
           top_panel(inputPanel);
           break;