changeset 11691:739d6376dec2

[gaim-migrate @ 13977] Correctly remove Bonjour buddies from the local list. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Tue, 18 Oct 2005 00:01:22 +0000
parents 872932089400
children 969fb599cc1b
files src/protocols/bonjour/bonjour.c
diffstat 1 files changed, 36 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/bonjour/bonjour.c	Mon Oct 17 23:04:59 2005 +0000
+++ b/src/protocols/bonjour/bonjour.c	Tue Oct 18 00:01:22 2005 +0000
@@ -32,6 +32,41 @@
 #include "jabber.h"
 #include "buddy.h"
 
+static void
+bonjour_removeallfromlocal(GaimConnection *gc)
+{
+	GaimAccount *account = gaim_connection_get_account(gc);
+	GaimBuddyList *blist;
+	GaimBlistNode *gnode, *cnode, *bnode;
+	GaimBuddy *buddy;
+
+	blist = gaim_get_blist();
+	if (blist == NULL)
+		return;
+
+	/* Go through and remove all buddies that belong to this account */
+	for (gnode = blist->root; gnode; gnode = gnode->next)
+	{
+		if (!GAIM_BLIST_NODE_IS_GROUP(gnode))
+			continue;
+		for (cnode = gnode->child; cnode; cnode = cnode->next)
+		{
+			if (!GAIM_BLIST_NODE_IS_CONTACT(cnode))
+				continue;
+			for (bnode = cnode->child; bnode; bnode = bnode->next)
+			{
+				if (!GAIM_BLIST_NODE_IS_BUDDY(bnode))
+					continue;
+				buddy = (GaimBuddy *)bnode;
+				if (buddy->account != account)
+					continue;
+				gaim_prpl_got_user_status(account, buddy->name, "offline", NULL);
+				gaim_blist_remove_buddy(buddy);
+			}
+		}
+	}
+}
+
 void
 bonjour_login(GaimAccount *account, GaimStatus *status)
 {
@@ -90,8 +125,6 @@
 bonjour_close(GaimConnection *connection)
 {
 	GaimGroup *bonjour_group = gaim_find_group(BONJOUR_GROUP_NAME);
-	GSList *buddies;
-	GSList *l;
 	BonjourData *bd = (BonjourData*)connection->proto_data;
 
 	// Stop looking for buddies in the LAN
@@ -107,14 +140,7 @@
 	g_free(bd->jabber_data);
 
 	// Remove all the bonjour buddies
-	if(connection != NULL){
-		buddies = gaim_find_buddies(connection->account, connection->account->username);
-		for(l = buddies; l; l = l->next){
-			bonjour_buddy_delete(((GaimBuddy*)(l->data))->proto_data);
-			gaim_blist_remove_buddy(l->data);
-		}
-		g_slist_free(buddies);
-	}
+	bonjour_removeallfromlocal(connection);
 
 	// Delete the bonjour group
 	gaim_blist_remove_group(bonjour_group);