changeset 8328:645a3d07ee45

[gaim-migrate @ 9052] there might be a more user-friendly way to do this, but for now, if someone moves a contact into another group, and there are buddies in that contact that are already in the new group, just delete the duplicate buddies. committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Tue, 24 Feb 2004 02:38:52 +0000
parents 90115b17f590
children 9dd7c75ed433
files src/blist.c
diffstat 1 files changed, 22 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/blist.c	Mon Feb 23 23:34:33 2004 +0000
+++ b/src/blist.c	Tue Feb 24 02:38:52 2004 +0000
@@ -844,7 +844,7 @@
 	GaimBlistUiOps *ops = gaimbuddylist->ui_ops;
 	GaimGroup *g;
 	GaimBlistNode *gnode, *cnode, *bnode;
-	gboolean save = FALSE;
+	gboolean save = FALSE, empty_contact = FALSE;
 
 	g_return_if_fail(contact != NULL);
 	g_return_if_fail(GAIM_BLIST_NODE_IS_CONTACT((GaimBlistNode*)contact));
@@ -896,15 +896,31 @@
 
 				g_hash_table_remove(gaimbuddylist->buddies, hb);
 
-				hb->group = gnode;
-				g_hash_table_replace(gaimbuddylist->buddies, hb, b);
-
-				if(b->account->gc)
-					serv_move_buddy(b, (GaimGroup*)cnode->parent, g);
+				if(!gaim_find_buddy_in_group(b->account, b->name, gnode)) {
+					hb->group = gnode;
+					g_hash_table_replace(gaimbuddylist->buddies, hb, b);
+
+					if(b->account->gc)
+						serv_move_buddy(b, (GaimGroup*)cnode->parent, g);
+				} else {
+					/* this buddy already exists in the group, so we're
+					 * gonna delete it instead */
+					g_free(hb->name);
+					g_free(hb);
+					if(b->account->gc)
+						serv_remove_buddy(b->account->gc, b->name, ((GaimGroup*)cnode->parent)->name);
+
+					if(!cnode->child->next)
+						empty_contact = TRUE;
+					gaim_blist_remove_buddy(b);
+				}
 			}
 		}
 	}
 
+	if(empty_contact)
+		return;
+
 
 	if(node && (GAIM_BLIST_NODE_IS_CONTACT(node) ||
 				GAIM_BLIST_NODE_IS_CHAT(node))) {