changeset 506:74dcd0df532e

"/move" does not jump to the buddy in the new group
author Mikael Berthe <mikael@lilotux.net>
date Fri, 11 Nov 2005 22:47:28 +0100
parents 7ffb1a3ed1b8
children 16dd9b91702f
files mcabber/doc/mcabber.1 mcabber/doc/mcabber.1.html mcabber/doc/mcabber.1.txt mcabber/src/commands.c mcabber/src/roster.c
diffstat 5 files changed, 24 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/doc/mcabber.1	Mon Oct 31 23:06:55 2005 +0100
+++ b/mcabber/doc/mcabber.1	Fri Nov 11 22:47:28 2005 +0100
@@ -175,7 +175,7 @@
 
 .TP
 \fB/move\fR [groupname]
-Move the current buddy to the requested group\&. If no group is specified, then the buddy is moved to the default group\&. This command only works with users (not agents), at the moment\&.
+Move the current buddy to the requested group\&. If no group is specified, then the buddy is moved to the default group\&. This command only works with users (not agents), at the moment\&. Tip: if the chatmode is enabled, you can use "/roster alternate" to jump to the moved buddy\&.
 
 .TP
 \fB/msay\fR begin|verbatim|send|abort
--- a/mcabber/doc/mcabber.1.html	Mon Oct 31 23:06:55 2005 +0100
+++ b/mcabber/doc/mcabber.1.html	Fri Nov 11 22:47:28 2005 +0100
@@ -2,7 +2,7 @@
 <html>
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
-<meta name="generator" content="AsciiDoc 7.0.1" />
+<meta name="generator" content="AsciiDoc 7.0.2" />
 <meta name="author" content="Mikael BERTHE" />
 <meta name="author-email" content="mcabber@lilotux.net" />
 <link rel="stylesheet" href="./manpage.css" type="text/css" />
@@ -366,7 +366,9 @@
 <dd>
         Move the current buddy to the requested group.  If no group is
         specified, then the buddy is moved to the default group.
-        This command only works with users (not agents), at the moment.
+        This command only works with users (not agents), at the moment.<br />
+        Tip: if the chatmode is enabled, you can use "/roster alternate"
+        to jump to the moved buddy.
 </dd>
 <dt><b>
 /msay begin|verbatim|send|abort
@@ -677,8 +679,8 @@
 License (GPL).</p>
 <div id="footer">
 <p>
-Version 0.7.0<br />
-Last updated 09-Oct-2005 22:02:06 CEST
+Version 0.7.1-dev<br />
+Last updated 11-Nov-2005 22:43:12 CEST
 </p>
 </div>
 </div>
--- a/mcabber/doc/mcabber.1.txt	Mon Oct 31 23:06:55 2005 +0100
+++ b/mcabber/doc/mcabber.1.txt	Fri Nov 11 22:47:28 2005 +0100
@@ -146,7 +146,9 @@
 /move [groupname]::
         Move the current buddy to the requested group.  If no group is
         specified, then the buddy is moved to the default group.
-        This command only works with users (not agents), at the moment.
+        This command only works with users (not agents), at the moment. +
+        Tip: if the chatmode is enabled, you can use "/roster alternate"
+        to jump to the moved buddy.
 
 /msay begin|verbatim|send|abort::
         Send a multi-line message.  To write a single message with several
--- a/mcabber/src/commands.c	Mon Oct 31 23:06:55 2005 +0100
+++ b/mcabber/src/commands.c	Fri Nov 11 22:47:28 2005 +0100
@@ -944,6 +944,7 @@
   // clones the buddy and deletes the old one (and thus, jid and name are
   // freed)
   jb_updatebuddy(jid, name, newgroupname);
+  scr_RosterUp();
   buddy_setgroup(bud, newgroupname);
 
   g_free(newgroupname);
--- a/mcabber/src/roster.c	Mon Oct 31 23:06:55 2005 +0100
+++ b/mcabber/src/roster.c	Fri Nov 11 22:47:28 2005 +0100
@@ -676,16 +676,15 @@
 //  buddy_setgroup()
 // Change the group of current buddy
 //
-// Warning!  This function changes current_buddy!
-// Warning!  Old buddy is deleted, so you can't acces to its jid/name after
-//           calling this function.
+// Warning!  This function changes the specified buddy!
+// Warning!  Old buddy is deleted, so you can't access to its jid/name after
+//           calling this function (they are free'd).
 void buddy_setgroup(gpointer rosterdata, char *newgroupname)
 {
   roster *roster_usr = rosterdata;
   GSList **sl_group;
   GSList *sl_clone;
   roster *roster_clone;
-  int is_alternate;
 
   // A group has no group :)
   if (roster_usr->type & ROSTER_TYPE_GROUP) return;
@@ -709,16 +708,17 @@
   free_all_resources(&roster_usr->resource);
   g_free(roster_usr);
 
-  // If new new group is folded, the curren_buddy will be lost, and the
-  // chat window won't be correctly refreshed.  So we make sure it isn't...
-  ((roster*)((GSList*)roster_clone->list)->data)->flags &= ~ROSTER_FLAG_HIDE;
-
-  // Little trick to have current_body pointing to the cloned buddy
-  is_alternate = (alternate_buddy == current_buddy);
   buddylist = g_list_append(buddylist, roster_clone);
-  current_buddy = g_list_find(buddylist, roster_clone);
-  if (is_alternate)
-    alternate_buddy = current_buddy;
+  // We must have current_buddy pointing to the cloned buddy, if this is
+  // the one we have moved.  Same for alternate_buddy.
+  if (rosterdata == BUDDATA(current_buddy)) {
+    current_buddy = g_list_find(buddylist, roster_clone);
+    // If new new group is folded, the current_buddy will be lost, and the
+    // chat window won't be correctly refreshed.  So we make sure it isn't...
+    ((roster*)((GSList*)roster_clone->list)->data)->flags &= ~ROSTER_FLAG_HIDE;
+  }
+  if (alternate_buddy && BUDDATA(alternate_buddy) == rosterdata)
+    alternate_buddy = g_list_find(buddylist, roster_clone);
 
   buddylist_build();
 }