changeset 10853:2409700be3dc

[gaim-migrate @ 12527] (15:46:50) LSchiere2: grim: commit message? (15:47:01) grim: LSchiere2: whatever..[sic] grim fixed a crash and some oddness in renaming groups. a related patch went into oldstatus a while back (also from grim). This is the HEAD version, removing a server.[ch] function in the process. committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Tue, 19 Apr 2005 19:48:29 +0000
parents 62b5117114d2
children bdd72261ec8c
files plugins/ChangeLog.API src/blist.c src/server.c src/server.h
diffstat 4 files changed, 38 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/ChangeLog.API	Tue Apr 19 16:00:20 2005 +0000
+++ b/plugins/ChangeLog.API	Tue Apr 19 19:48:29 2005 +0000
@@ -47,6 +47,7 @@
 	* Removed: gaim_conversation_set_history, gaim_conversation_get_history,
 	           and GaimConversation->history.  Use gtk_imhtml_get_markup
 	           instead.
+	* Removed: serv_rename_group
 
 	Signals:
 	* Changed: "received-im-msg and "received-chat-msg" to match, both
--- a/src/blist.c	Tue Apr 19 16:00:20 2005 +0000
+++ b/src/blist.c	Tue Apr 19 19:48:29 2005 +0000
@@ -988,9 +988,43 @@
 		ops->update(gaimbuddylist, (GaimBlistNode*)source);
 
 	/* Notify all PRPLs */
-	for (accts = gaim_group_get_accounts(source); accts; accts = g_slist_remove(accts, accts->data)) {
-		GaimAccount *account = accts->data;
-		serv_rename_group(account->gc, old_name, source, moved_buddies);
+	if(old_name && source && strcmp(source->name, old_name)) {
+		for (accts = gaim_group_get_accounts(source); accts; accts = g_slist_remove(accts, accts->data)) {
+			GaimAccount *account = accts->data;
+			GaimPluginProtocolInfo *prpl_info = NULL;
+			GList *l = NULL, *buddies = NULL;
+
+			if(account->gc && account->gc->prpl)
+				prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl);
+
+			if(!prpl_info)
+				continue;
+
+			for(l = moved_buddies; l; l = l->next) {
+				GaimBuddy *buddy = (GaimBuddy *)l->data;
+
+				if(buddy && buddy->account == account)
+					buddies = g_list_append(buddies, (GaimBlistNode *)buddy);
+			}
+
+			if(prpl_info->rename_group) {
+				prpl_info->rename_group(account->gc, old_name, source, buddies);
+			} else {
+				GList *cur, *groups = NULL;
+
+				/* Make a list of what the groups each buddy is in */
+				for(cur = buddies; cur; cur = cur->next) {
+					GaimBlistNode *node = (GaimBlistNode *)cur->data;
+					groups = g_list_append(groups, node->parent->parent);
+				}
+
+				serv_remove_buddies(account->gc, buddies, groups);
+				g_list_free(groups);
+				serv_add_buddies(account->gc, buddies);
+			}
+
+			g_list_free(buddies);
+		}
 	}
 	g_list_free(moved_buddies);
 	g_free(old_name);
--- a/src/server.c	Tue Apr 19 16:00:20 2005 +0000
+++ b/src/server.c	Tue Apr 19 19:48:29 2005 +0000
@@ -381,38 +381,6 @@
 	}
 }
 
-/*
- * Rename a group on server roster/list.
- */
-void serv_rename_group(GaimConnection *gc, const char *old_name,
-					   GaimGroup *group, GList *moved_buddies)
-{
-	GaimPluginProtocolInfo *prpl_info = NULL;
-
-	if (gc != NULL && gc->prpl != NULL)
-		prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
-
-	if (prpl_info && old_name && group && strcmp(old_name, group->name)) {
-		if (prpl_info->rename_group) {
-			/* prpl's might need to check if the group already
-			 * exists or not, and handle that differently */
-			prpl_info->rename_group(gc, old_name, group, moved_buddies);
-		} else {
-			GList *cur, *groups = NULL;
-
-			/* Make a list of what the groups each buddy is in */
-			for (cur = moved_buddies; cur != NULL; cur = cur->next) {
-				GaimBlistNode *node = cur->data;
-				groups = g_list_append(groups, node->parent->parent);
-			}
-
-			serv_remove_buddies(gc, moved_buddies, groups);
-			g_list_free(groups);
-			serv_add_buddies(gc, moved_buddies);
-		}
-	}
-}
-
 void serv_add_permit(GaimConnection *g, const char *name)
 {
 	GaimPluginProtocolInfo *prpl_info = NULL;
--- a/src/server.h	Tue Apr 19 16:00:20 2005 +0000
+++ b/src/server.h	Tue Apr 19 19:48:29 2005 +0000
@@ -47,7 +47,6 @@
 void serv_remove_buddies(GaimConnection *, GList *, GList *);
 void serv_remove_group(GaimConnection *, GaimGroup *);
 void serv_move_buddy(GaimBuddy *, GaimGroup *, GaimGroup *);
-void serv_rename_group(GaimConnection *, const char *, GaimGroup *, GList *);
 void serv_add_permit(GaimConnection *, const char *);
 void serv_add_deny(GaimConnection *, const char *);
 void serv_rem_permit(GaimConnection *, const char *);