changeset 6367:9fd154ca6a94

[gaim-migrate @ 6872] The buddy removal code on account deletion has been moved to gaim_accounts_remove(). I think this is more correct, but still wonder about having an API function for actually deleting an account... This should do though. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Mon, 04 Aug 2003 19:35:17 +0000
parents 773b8ce563f5
children 41e6d15f4687
files src/account.c src/account.h
diffstat 2 files changed, 27 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/account.c	Mon Aug 04 19:29:06 2003 +0000
+++ b/src/account.c	Mon Aug 04 19:35:17 2003 +0000
@@ -1260,11 +1260,35 @@
 void
 gaim_accounts_remove(GaimAccount *account)
 {
+	GaimBlistNode *gnode, *bnode;
+
 	g_return_if_fail(account != NULL);
 
 	accounts = g_list_remove(accounts, account);
 
 	schedule_accounts_save();
+
+	for (gnode = gaim_get_blist()->root; gnode != NULL; gnode = gnode->next) {
+		if (!GAIM_BLIST_NODE_IS_GROUP(gnode))
+			continue;
+
+		for (bnode = gnode->child; bnode != NULL; bnode = bnode->next) {
+			if (GAIM_BLIST_NODE_IS_BUDDY(bnode)) {
+				struct buddy *b = (struct buddy *)bnode;
+
+				if (b->account == account)
+					gaim_blist_remove_buddy(b);
+			}
+			else if (GAIM_BLIST_NODE_IS_CHAT(bnode)) {
+				struct chat *c = (struct chat *)bnode;
+
+				if (c->account == account)
+					gaim_blist_remove_chat(c);
+			}
+		}
+	}
+
+	gaim_blist_save();
 }
 
 void
--- a/src/account.h	Mon Aug 04 19:29:06 2003 +0000
+++ b/src/account.h	Mon Aug 04 19:35:17 2003 +0000
@@ -516,6 +516,9 @@
 /**
  * Removes an account from the list of accounts.
  *
+ * This will remove any buddies from the buddy list that belong to this
+ * account.
+ *
  * @param account The account.
  */
 void gaim_accounts_remove(GaimAccount *account);