pidgin: 8095f130: Use purple_find_buddies() instead of ite...

darkrain42 at pidgin.im darkrain42 at pidgin.im
Mon Jun 1 00:25:29 EDT 2009


-----------------------------------------------------------------
Revision: 8095f1308a6051a9a17e89f101fe85659acaa144
Ancestor: 34e3e539a3dc505eed92c20b192370ed1651b96e
Author: darkrain42 at pidgin.im
Date: 2009-06-01T04:02:10
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/8095f1308a6051a9a17e89f101fe85659acaa144

Modified files:
        libpurple/protocols/gg/buddylist.c
        libpurple/protocols/irc/msgs.c
        libpurple/protocols/msn/session.c
        libpurple/protocols/msn/userlist.c
        libpurple/protocols/msnp9/session.c
        libpurple/protocols/oscar/oscar.c
        libpurple/protocols/silc/buddy.c
        libpurple/protocols/silc/ops.c
        libpurple/protocols/simple/simple.c
        libpurple/protocols/zephyr/zephyr.c

ChangeLog: 

Use purple_find_buddies() instead of iterating the buddy list.

-------------- next part --------------
============================================================
--- libpurple/protocols/gg/buddylist.c	c3e71d332738e059ec9e19ccb4d4b7823ab5987a
+++ libpurple/protocols/gg/buddylist.c	98a59485a17634d7a305d42bf324e7f90321cdb4
@@ -40,57 +40,33 @@ void ggp_buddylist_send(PurpleConnection
 {
 	GGPInfo *info = gc->proto_data;
 	PurpleAccount *account = purple_connection_get_account(gc);
+	GSList *buddies;
+	uin_t *userlist;
+	gchar *types;
+	int i = 0, ret = 0;
+	int size;
 
-	PurpleBlistNode *gnode, *cnode, *bnode;
-	PurpleBuddy *buddy;
-	uin_t *userlist = NULL;
-	gchar *types = NULL;
-	int size = 0, ret = 0;
+	buddies = purple_find_buddies(account, NULL);
 
-	for (gnode = purple_blist_get_root();
-	     gnode != NULL;
-	     gnode = purple_blist_node_get_sibling_next(gnode))
-	{
-		if (!PURPLE_BLIST_NODE_IS_GROUP(gnode))
-			continue;
+	size = g_slist_length(buddies);
+	userlist = g_new(uin_t, size);
+	types    = g_new(gchar, size);
 
-		for (cnode = purple_blist_node_get_first_child(gnode);
-		     cnode != NULL;
-		     cnode = purple_blist_node_get_sibling_next(cnode))
-		{
-			if (!PURPLE_BLIST_NODE_IS_CONTACT(cnode))
-				continue;
+	for (buddies = purple_find_buddies(account, NULL); buddies;
+			buddies = g_slist_delete_link(buddies, buddies), ++i)
+	{
+		PurpleBuddy *buddy = buddies->data;
+		const gchar *name = purple_buddy_get_name(buddy);
 
-			for (bnode = purple_blist_node_get_first_child(cnode);
-			     bnode != NULL;
-			     bnode = purple_blist_node_get_sibling_next(bnode))
-			{
-				const gchar *name = NULL;
-
-				if (!PURPLE_BLIST_NODE_IS_BUDDY(bnode))
-					continue;
-
-				buddy = (PurpleBuddy *)bnode;
-
-				if (purple_buddy_get_account(buddy) != account)
-					continue;
-
-				name = purple_buddy_get_name(buddy);
-
-				size++;
-				userlist = (uin_t *) g_renew(uin_t, userlist, size);
-				types    = (gchar *) g_renew(gchar, types, size);
-				userlist[size - 1] = ggp_str_to_uin(name);
-				types[size - 1]    = GG_USER_NORMAL;
-				purple_debug_info("gg", "ggp_buddylist_send: adding %d\n",
-						userlist[size - 1]);
-			}
-		}
+		userlist[i] = ggp_str_to_uin(name);
+		types[i]    = GG_USER_NORMAL;
+		purple_debug_info("gg", "ggp_buddylist_send: adding %d\n",
+		                  userlist[i]);
 	}
 
 	ret = gg_notify_ex(info->session, userlist, types, size);
 	purple_debug_info("gg", "send: ret=%d; size=%d\n", ret, size);
-	
+
 	if (userlist) {
 		g_free(userlist);
 		g_free(types);
@@ -181,53 +157,25 @@ char *ggp_buddylist_dump(PurpleAccount *
 /* char *ggp_buddylist_dump(PurpleAccount *account) {{{ */
 char *ggp_buddylist_dump(PurpleAccount *account)
 {
-	PurpleBlistNode *gnode, *cnode, *bnode;
-	PurpleGroup *group;
-	PurpleBuddy *buddy;
+	GSList *buddies;
 	GString *buddylist = g_string_sized_new(1024);
 	char *ptr;
 
-	for (gnode = purple_blist_get_root();
-	     gnode != NULL;
-	     gnode = purple_blist_node_get_sibling_next(gnode))
-	{
-		if (!PURPLE_BLIST_NODE_IS_GROUP(gnode))
-			continue;
+	for (buddies = purple_find_buddies(account, NULL); buddies;
+			buddies = g_slist_delete_link(buddies, buddies)) {
+		PurpleBuddy *buddy = buddies->data;
+		PurpleGroup *group = purple_buddy_get_group(buddy);
+		const char *bname = purple_buddy_get_name(buddy);
+		const char *gname = purple_group_get_name(group);
+		const char *alias = purple_buddy_get_alias(buddy);
 
-		group = (PurpleGroup *)gnode;
+		if (alias == NULL)
+			alias = bname;
 
-		for (cnode = purple_blist_node_get_first_child(gnode);
-		     cnode != NULL;
-		     cnode = purple_blist_node_get_sibling_next(cnode))
-		{
-			if (!PURPLE_BLIST_NODE_IS_CONTACT(cnode))
-				continue;
-
-			for (bnode = purple_blist_node_get_first_child(cnode);
-			     bnode != NULL;
-			     bnode = purple_blist_node_get_sibling_next(bnode))
-			{
-				const gchar *name, *alias, *gname;
-
-				if (!PURPLE_BLIST_NODE_IS_BUDDY(bnode))
-					continue;
-
-				buddy = (PurpleBuddy *)bnode;
-				if (purple_buddy_get_account(buddy) != account)
-					continue;
-
-				name = purple_buddy_get_name(buddy);
-				alias = purple_buddy_get_alias(buddy);
-				if(alias == NULL)
-					alias = name;
-				gname = purple_group_get_name(group);
-
-				g_string_append_printf(buddylist,
-						"%s;%s;%s;%s;%s;%s;%s;%s%s\r\n",
-						alias, alias, alias, alias,
-						"", gname, name, "", "");
-			}
-		}
+		g_string_append_printf(buddylist,
+				"%s;%s;%s;%s;%s;%s;%s;%s%s\r\n",
+				alias, alias, alias, alias,
+				"", gname, bname, "", "");
 	}
 
 	ptr = charset_convert(buddylist->str, "UTF-8", "CP1250");
============================================================
--- libpurple/protocols/irc/msgs.c	5a6862bee03caec0af17be15aee9e654eb099d4e
+++ libpurple/protocols/irc/msgs.c	4805492a1a66fe1d66e07906bad49f34424c1e32
@@ -78,7 +78,7 @@ static void irc_connected(struct irc_con
 {
 	PurpleConnection *gc;
 	PurpleStatus *status;
-	PurpleBlistNode *gnode, *cnode, *bnode;
+	GSList *buddies;
 	PurpleAccount *account;
 
 	if ((gc = purple_account_get_connection(irc->account)) == NULL
@@ -97,33 +97,13 @@ static void irc_connected(struct irc_con
 	}
 
 	/* this used to be in the core, but it's not now */
-	for (gnode = purple_blist_get_root();
-	     gnode;
-	     gnode = purple_blist_node_get_sibling_next(gnode))
+	for (buddies = purple_find_buddies(account, NULL); buddies;
+			buddies = g_slist_delete_link(buddies, buddies))
 	{
-		if(!PURPLE_BLIST_NODE_IS_GROUP(gnode))
-			continue;
-		for(cnode = purple_blist_node_get_first_child(gnode);
-		    cnode;
-		    cnode = purple_blist_node_get_sibling_next(cnode))
-		{
-			if(!PURPLE_BLIST_NODE_IS_CONTACT(cnode))
-				continue;
-			for(bnode = purple_blist_node_get_first_child(cnode);
-			    bnode;
-			    bnode = purple_blist_node_get_sibling_next(bnode))
-			{
-				PurpleBuddy *b;
-				if(!PURPLE_BLIST_NODE_IS_BUDDY(bnode))
-					continue;
-				b = (PurpleBuddy *)bnode;
-				if(purple_buddy_get_account(b) == account) {
-					struct irc_buddy *ib = g_new0(struct irc_buddy, 1);
-					ib->name = g_strdup(purple_buddy_get_name(b));
-					g_hash_table_insert(irc->buddies, ib->name, ib);
-				}
-			}
-		}
+		PurpleBuddy *b = buddies->data;
+		struct irc_buddy *ib = g_new0(struct irc_buddy, 1);
+		ib->name = g_strdup(purple_buddy_get_name(b));
+		g_hash_table_insert(irc->buddies, ib->name, ib);
 	}
 
 	irc_blist_timeout(irc);
============================================================
--- libpurple/protocols/msn/session.c	c4da27773fb9a470b8b86f801bb6f4572c5b80b2
+++ libpurple/protocols/msn/session.c	1d49938cac714059979332011b8c2e41ce76e202
@@ -261,9 +261,9 @@ msn_session_sync_users(MsnSession *sessi
 static void
 msn_session_sync_users(MsnSession *session)
 {
-	PurpleBlistNode *gnode, *cnode, *bnode;
 	PurpleConnection *gc = purple_account_get_connection(session->account);
 	GList *to_remove = NULL;
+	GSList *buddies;
 
 	g_return_if_fail(gc != NULL);
 
@@ -271,60 +271,36 @@ msn_session_sync_users(MsnSession *sessi
 	 * being logged in. This no longer happens, so we manually iterate
 	 * over the whole buddy list to identify sync issues.
 	 */
-	for (gnode = purple_blist_get_root(); gnode;
-			gnode = purple_blist_node_get_sibling_next(gnode)) {
-		PurpleGroup *group = (PurpleGroup *)gnode;
-		const char *group_name;
-		if(!PURPLE_BLIST_NODE_IS_GROUP(gnode))
-			continue;
-		group_name = purple_group_get_name(group);
-		for(cnode = purple_blist_node_get_first_child(gnode);
-				cnode;
-				cnode = purple_blist_node_get_sibling_next(cnode)) {
-			if(!PURPLE_BLIST_NODE_IS_CONTACT(cnode))
-				continue;
-			for(bnode = purple_blist_node_get_first_child(cnode);
-					bnode;
-					bnode = purple_blist_node_get_sibling_next(bnode)) {
-				PurpleBuddy *b;
-				if(!PURPLE_BLIST_NODE_IS_BUDDY(bnode))
-					continue;
-				b = (PurpleBuddy *)bnode;
-				if(purple_buddy_get_account(b) == purple_connection_get_account(gc)) {
-					MsnUser *remote_user;
-					gboolean found = FALSE;
+	for (buddies = purple_find_buddies(session->account, NULL); buddies;
+			buddies = g_slist_delete_link(buddies, buddies)) {
+		PurpleBuddy *buddy = buddies->data;
+		const gchar *buddy_name = purple_buddy_get_name(buddy);
+		const gchar *group_name = purple_group_get_name(purple_buddy_get_group(buddy));
+		MsnUser *remote_user;
+		gboolean found = FALSE;
 
-					remote_user = msn_userlist_find_user(session->userlist, purple_buddy_get_name(b));
+		remote_user = msn_userlist_find_user(session->userlist, buddy_name);
+		if (remote_user && remote_user->list_op & MSN_LIST_FL_OP) {
+			GList *l;
+			for (l = remote_user->group_ids; l; l = l->next) {
+				const char *name = msn_userlist_find_group_name(remote_user->userlist, l->data);
+				if (name && !g_ascii_strcasecmp(group_name, name)) {
+					found = TRUE;
+					break;
+				}
+			}
 
-					if ((remote_user != NULL) && (remote_user->list_op & MSN_LIST_FL_OP))
-					{
-						GList *l;
-
-						for (l = remote_user->group_ids; l != NULL; l = l->next)
-						{
-							const char *name = msn_userlist_find_group_name(remote_user->userlist, l->data);
-							if (name && !g_ascii_strcasecmp(group_name, name))
-							{
-								found = TRUE;
-								break;
-							}
-						}
-					}
-
-					/* We don't care if they're in a different group, as long as they're on the
-					 * list somewhere. If we check for the group, we cause pain, agony and
-					 * suffering for people who decide to re-arrange their buddy list elsewhere.
-					 */
-					if (!found)
-					{
-						if ((remote_user == NULL) || !(remote_user->list_op & MSN_LIST_FL_OP)) {
-							/* The user is not on the server list */
-							msn_show_sync_issue(session, purple_buddy_get_name(b), group_name);
-						} else {
-							/* The user is not in that group on the server list */
-							to_remove = g_list_prepend(to_remove, b);
-						}
-					}
+			/* We don't care if they're in a different group, as long as they're on the
+			 * list somewhere. If we check for the group, we cause pain, agony and
+			 * suffering for people who decide to re-arrange their buddy list elsewhere.
+			 */
+			if (!found) {
+				if ((remote_user == NULL) || !(remote_user->list_op & MSN_LIST_FL_OP)) {
+					/* The user is not on the server list */
+					msn_show_sync_issue(session, buddy_name, group_name);
+				} else {
+					/* The user is not in that group on the server list */
+					to_remove = g_list_prepend(to_remove, buddy);
 				}
 			}
 		}
============================================================
--- libpurple/protocols/msn/userlist.c	64735bb8ff3632b106efab69f637b9977484ec8c
+++ libpurple/protocols/msn/userlist.c	60a7d766efeae5979b308b530be6c13bddd3f813
@@ -783,7 +783,6 @@ msn_userlist_load(MsnSession *session)
 void
 msn_userlist_load(MsnSession *session)
 {
-	PurpleBlistNode *gnode, *cnode, *bnode;
 	PurpleAccount *account = session->account;
 	PurpleConnection *gc = purple_account_get_connection(account);
 	GSList *l;
@@ -791,34 +790,14 @@ msn_userlist_load(MsnSession *session)
 
 	g_return_if_fail(gc != NULL);
 
-	for (gnode = purple_blist_get_root(); gnode;
-			gnode = purple_blist_node_get_sibling_next(gnode))
-	{
-		if (!PURPLE_BLIST_NODE_IS_GROUP(gnode))
-			continue;
-		for (cnode = purple_blist_node_get_first_child(gnode);
-				cnode;
-				cnode = purple_blist_node_get_sibling_next(cnode))
-		{
-			if (!PURPLE_BLIST_NODE_IS_CONTACT(cnode))
-				continue;
-			for (bnode = purple_blist_node_get_first_child(cnode);
-					bnode;
-					bnode = purple_blist_node_get_sibling_next(bnode))
-			{
-				PurpleBuddy *b;
-				if (!PURPLE_BLIST_NODE_IS_BUDDY(bnode))
-					continue;
-				b = (PurpleBuddy *)bnode;
-				if (purple_buddy_get_account(b) == account)
-				{
-					user = msn_userlist_find_add_user(session->userlist,
-						purple_buddy_get_name(b), NULL);
-					purple_buddy_set_protocol_data(b, user);
-					msn_user_set_op(user, MSN_LIST_FL_OP);
-				}
-			}
-		}
+	for (l = purple_find_buddies(account, NULL); l != NULL;
+			l = g_slist_delete_link(l, l)) {
+		PurpleBuddy *buddy = l->data;
+
+		user = msn_userlist_find_add_user(session->userlist,
+			purple_buddy_get_name(buddy), NULL);
+		purple_buddy_set_protocol_data(buddy, user);
+		msn_user_set_op(user, MSN_LIST_FL_OP);
 	}
 	for (l = session->account->permit; l != NULL; l = l->next)
 	{
============================================================
--- libpurple/protocols/msnp9/session.c	7f20729832b347ebd412f5013eb18bf5ec40cd87
+++ libpurple/protocols/msnp9/session.c	d39656c723d69763d869ad967edfba226fba63a7
@@ -221,68 +221,51 @@ msn_session_sync_users(MsnSession *sessi
 static void
 msn_session_sync_users(MsnSession *session)
 {
-	PurpleBlistNode *gnode, *cnode, *bnode;
 	PurpleConnection *gc = purple_account_get_connection(session->account);
 	GList *to_remove = NULL;
+	GSList *buddies;
 
 	g_return_if_fail(gc != NULL);
 
 	/* The core used to use msn_add_buddy to add all buddies before
 	 * being logged in. This no longer happens, so we manually iterate
 	 * over the whole buddy list to identify sync issues. */
+	for (buddies = purple_find_buddies(session->account, NULL); buddies;
+			buddies = g_slist_delete_link(buddies, buddies)) {
+		PurpleBuddy *buddy = buddies->data;
+		const char *buddy_name = purple_buddy_get_name(buddy);
+		const char *group_name = purple_group_get_name(purple_buddy_get_group(buddy));
+		MsnUser *remote_user;
+		gboolean found = FALSE;
 
-	for (gnode = purple_blist_get_root(); gnode; gnode = gnode->next) {
-		PurpleGroup *group = (PurpleGroup *)gnode;
-		const char *group_name = group->name;
-		if(!PURPLE_BLIST_NODE_IS_GROUP(gnode))
-			continue;
-		for(cnode = gnode->child; cnode; cnode = cnode->next) {
-			if(!PURPLE_BLIST_NODE_IS_CONTACT(cnode))
-				continue;
-			for(bnode = cnode->child; bnode; bnode = bnode->next) {
-				PurpleBuddy *b;
-				if(!PURPLE_BLIST_NODE_IS_BUDDY(bnode))
-					continue;
-				b = (PurpleBuddy *)bnode;
-				if(purple_buddy_get_account(b) == purple_connection_get_account(gc)) {
-					MsnUser *remote_user;
-					gboolean found = FALSE;
+		remote_user = msn_userlist_find_user(session->userlist, buddy_name);
 
-					remote_user = msn_userlist_find_user(session->userlist, purple_buddy_get_name(b));
+		if (remote_user && remote_user->list_op & MSN_LIST_FL_OP) {
+			int group_id;
+			GList *l;
 
-					if ((remote_user != NULL) && (remote_user->list_op & MSN_LIST_FL_OP))
-					{
-						int group_id;
-						GList *l;
+			group_id = msn_userlist_find_group_id(remote_user->userlist,
+					group_name);
 
-						group_id = msn_userlist_find_group_id(remote_user->userlist,
-								group_name);
+			for (l = remote_user->group_ids; l; l = l->next) {
+				if (group_id == GPOINTER_TO_INT(l->data)) {
+					found = TRUE;
+					break;
+				}
+			}
 
-						for (l = remote_user->group_ids; l != NULL; l = l->next)
-						{
-							if (group_id == GPOINTER_TO_INT(l->data))
-							{
-								found = TRUE;
-								break;
-							}
-						}
-
-					}
-
-					/* We don't care if they're in a different group, as long as they're on the
-					 * list somewhere. If we check for the group, we cause pain, agony and
-					 * suffering for people who decide to re-arrange their buddy list elsewhere.
-					 */
-					if (!found)
-					{
-						if ((remote_user == NULL) || !(remote_user->list_op & MSN_LIST_FL_OP)) {
-							/* The user is not on the server list */
-							msn_show_sync_issue(session, purple_buddy_get_name(b), group_name);
-						} else {
-							/* The user is not in that group on the server list */
-							to_remove = g_list_prepend(to_remove, b);
-						}
-					}
+			/* We don't care if they're in a different group, as long as they're on the
+			 * list somewhere. If we check for the group, we cause pain, agony and
+			 * suffering for people who decide to re-arrange their buddy list elsewhere.
+			 */
+			if (!found)
+			{
+				if ((remote_user == NULL) || !(remote_user->list_op & MSN_LIST_FL_OP)) {
+					/* The user is not on the server list */
+					msn_show_sync_issue(session, buddy_name, group_name);
+				} else {
+					/* The user is not in that group on the server list */
+					to_remove = g_list_prepend(to_remove, buddy);
 				}
 			}
 		}
============================================================
--- libpurple/protocols/oscar/oscar.c	de6af754e596084f4a344b0f64e1d1cf7148d75d
+++ libpurple/protocols/oscar/oscar.c	7f3dc807c2040c44d7d1466e47982a706d029734
@@ -6541,47 +6541,35 @@ static void oscar_show_awaitingauth(Purp
 {
 	PurpleConnection *gc = (PurpleConnection *) action->context;
 	OscarData *od = purple_connection_get_protocol_data(gc);
-	gchar *nombre, *text, *tmp;
-	PurpleBlistNode *gnode, *cnode, *bnode;
+	gchar *text, *tmp;
+	GSList *buddies;
 	PurpleAccount *account;
 	int num=0;
 
 	text = g_strdup("");
 	account = purple_connection_get_account(gc);
 
-	for (gnode = purple_blist_get_root(); gnode;
-			gnode = purple_blist_node_get_sibling_next(gnode)) {
-		PurpleGroup *group = (PurpleGroup *)gnode;
-		const char *gname;
-		if(!PURPLE_BLIST_NODE_IS_GROUP(gnode))
-			continue;
-		gname = purple_group_get_name(group);
-		for (cnode = purple_blist_node_get_first_child(gnode);
-				cnode;
-				cnode = purple_blist_node_get_sibling_next(cnode)) {
-			if(!PURPLE_BLIST_NODE_IS_CONTACT(cnode))
-				continue;
-			for (bnode = purple_blist_node_get_first_child(cnode);
-					bnode;
-					bnode = purple_blist_node_get_sibling_next(bnode)) {
-				PurpleBuddy *buddy = (PurpleBuddy *)bnode;
-				const char *bname;
-				if(!PURPLE_BLIST_NODE_IS_BUDDY(bnode))
-					continue;
-				bname = purple_buddy_get_name(buddy);
-				if (purple_buddy_get_account(buddy) == account && aim_ssi_waitingforauth(od->ssi.local, gname, bname)) {
-					if (purple_buddy_get_alias_only(buddy))
-						nombre = g_strdup_printf(" %s (%s)", bname, purple_buddy_get_alias_only(buddy));
-					else
-						nombre = g_strdup_printf(" %s", bname);
-					tmp = g_strdup_printf("%s%s<br>", text, nombre);
-					g_free(text);
-					text = tmp;
-					g_free(nombre);
-					num++;
-				}
-			}
+	buddies = purple_find_buddies(account, NULL);
+	while (buddies) {
+		PurpleBuddy *buddy;
+		const gchar *bname, *gname;
+
+		buddy = buddies->data;
+		bname = purple_buddy_get_name(buddy);
+		gname = purple_group_get_name(purple_buddy_get_group(buddy));
+		if (aim_ssi_waitingforauth(od->ssi.local, gname, bname)) {
+			const gchar *alias = purple_buddy_get_alias_only(buddy);
+			if (alias)
+				tmp = g_strdup_printf("%s %s (%s)<br>", text, bname, alias);
+			else
+				tmp = g_strdup_printf("%s %s<br>", text, bname);
+			g_free(text);
+			text = tmp;
+
+			num++;
 		}
+
+		buddies = g_slist_delete_link(buddies, buddies);
 	}
 
 	if (!num) {
============================================================
--- libpurple/protocols/silc/buddy.c	283c45660e457f88391fec2cbf633b5b74bc2466
+++ libpurple/protocols/silc/buddy.c	519ae809142e0953c2e56021312541de01787ccc
@@ -1407,35 +1407,16 @@ void silcpurple_send_buddylist(PurpleCon
 
 void silcpurple_send_buddylist(PurpleConnection *gc)
 {
-	PurpleBlistNode *gnode, *cnode, *bnode;
-	PurpleBuddy *buddy;
+	GSList *buddies;
 	PurpleAccount *account;
 
 	account = purple_connection_get_account(gc);
 
-	for (gnode = purple_blist_get_root();
-			gnode != NULL;
-			gnode = purple_blist_node_get_sibling_next(gnode))
+	for (buddies = purple_find_buddies(account, NULL); buddies;
+			buddies = g_slist_delete_link(buddies, buddies))
 	{
-		if (!PURPLE_BLIST_NODE_IS_GROUP(gnode))
-			continue;
-		for (cnode = purple_blist_node_get_first_child(gnode);
-				cnode != NULL;
-				cnode = purple_blist_node_get_sibling_next(cnode))
-		{
-			if (!PURPLE_BLIST_NODE_IS_CONTACT(cnode))
-				continue;
-			for (bnode = purple_blist_node_get_first_child(cnode);
-					bnode != NULL;
-					bnode = purple_blist_node_get_sibling_next(bnode))
-			{
-				if (!PURPLE_BLIST_NODE_IS_BUDDY(bnode))
-					continue;
-				buddy = (PurpleBuddy *)bnode;
-				if (purple_buddy_get_account(buddy) == account)
-					silcpurple_add_buddy_i(gc, buddy, TRUE);
-			}
-		}
+		PurpleBuddy *buddy = buddies->data;
+		silcpurple_add_buddy_i(gc, buddy, TRUE);
 	}
 }
 
============================================================
--- libpurple/protocols/silc/ops.c	5241659cdddbc522ee765fdfbacea889da0d7fa5
+++ libpurple/protocols/silc/ops.c	89049a403cabd0a1017f8f3c9e1d923006743e76
@@ -839,7 +839,7 @@ silc_notify(SilcClient client, SilcClien
 
 			b = NULL;
 			if (public_key) {
-				PurpleBlistNode *gnode, *cnode, *bnode;
+				GSList *buddies;
 				const char *f;
 
 				pk = silc_pkcs_public_key_encode(public_key, &pk_len);
@@ -857,29 +857,13 @@ silc_notify(SilcClient client, SilcClien
 				silc_free(pk);
 
 				/* Find buddy by associated public key */
-				for (gnode = purple_blist_get_root(); gnode;
-				     gnode = purple_blist_node_get_sibling_next(gnode)) {
-					if (!PURPLE_BLIST_NODE_IS_GROUP(gnode))
-						continue;
-					for (cnode = purple_blist_node_get_first_child(gnode);
-							cnode;
-							cnode = purple_blist_node_get_sibling_next(cnode)) {
-						if( !PURPLE_BLIST_NODE_IS_CONTACT(cnode))
-							continue;
-						for (bnode = purple_blist_node_get_first_child(cnode);
-								bnode;
-								bnode = purple_blist_node_get_sibling_next(bnode)) {
-							if (!PURPLE_BLIST_NODE_IS_BUDDY(bnode))
-								continue;
-							b = (PurpleBuddy *)bnode;
-							if (purple_buddy_get_account(b) != account)
-								continue;
-							f = purple_blist_node_get_string(bnode, "public-key");
-							if (f && !strcmp(f, buf))
-								goto cont;
-							b = NULL;
-						}
-					}
+				for (buddies = purple_find_buddies(account, NULL); buddies;
+						buddies = g_slist_delete_link(buddies, buddies)) {
+					b = buddies->data;
+					f = purple_blist_node_get_string(PURPLE_BLIST_NODE(b), "public-key");
+					if (purple_strequal(f, buf))
+						goto cont;
+					b = NULL;
 				}
 			}
 		cont:
============================================================
--- libpurple/protocols/simple/simple.c	79ef06c00c8dd75ca09fd33edfe0badfc5a9a2b2
+++ libpurple/protocols/simple/simple.c	051593435439b0a15405a948daf3e29a8119dc46
@@ -213,27 +213,18 @@ static void simple_get_buddies(PurpleCon
 }
 
 static void simple_get_buddies(PurpleConnection *gc) {
-	PurpleBlistNode *gnode, *cnode, *bnode;
+	GSList *buddies;
 	PurpleAccount *account;
 
 	purple_debug_info("simple", "simple_get_buddies\n");
 
 	account = purple_connection_get_account(gc);
-	for(gnode = purple_blist_get_root(); gnode;
-			gnode = purple_blist_node_get_sibling_next(gnode)) {
-		if(!PURPLE_BLIST_NODE_IS_GROUP(gnode)) continue;
-		for(cnode = purple_blist_node_get_first_child(gnode);
-				cnode;
-				cnode = purple_blist_node_get_sibling_next(cnode)) {
-			if(!PURPLE_BLIST_NODE_IS_CONTACT(cnode)) continue;
-			for(bnode = purple_blist_node_get_first_child(cnode);
-					bnode;
-					bnode = purple_blist_node_get_sibling_next(bnode)) {
-				if(!PURPLE_BLIST_NODE_IS_BUDDY(bnode)) continue;
-				if(purple_buddy_get_account((PurpleBuddy*)bnode) == account)
-					simple_add_buddy(gc, (PurpleBuddy*)bnode, (PurpleGroup *)gnode);
-			}
-		}
+	buddies = purple_find_buddies(account, NULL);
+	while (buddies) {
+		PurpleBuddy *buddy = buddies->data;
+		simple_add_buddy(gc, buddy, purple_buddy_get_group(buddy));
+
+		buddies = g_slist_delete_link(buddies, buddies);
 	}
 }
 
============================================================
--- libpurple/protocols/zephyr/zephyr.c	da7c4d206d99812dfe4c97059e8b2f68cf85d501
+++ libpurple/protocols/zephyr/zephyr.c	0b5ed3bfd2a06df1b79369ce36aa4a15b7374538
@@ -1926,8 +1926,7 @@ static void write_anyone(PurpleConnectio
 
 static void write_anyone(PurpleConnection *gc)
 {
-	PurpleBlistNode *gnode, *cnode, *bnode;
-	PurpleBuddy *b;
+	GSList *buddies;
 	char *fname;
 	FILE *fd;
 	PurpleAccount *account;
@@ -1940,29 +1939,12 @@ static void write_anyone(PurpleConnectio
 	}
 
 	account = purple_connection_get_account(gc);
-	for (gnode = purple_blist_get_root();
-			gnode;
-			gnode = purple_blist_node_get_sibling_next(gnode)) {
-		if (!PURPLE_BLIST_NODE_IS_GROUP(gnode))
-			continue;
-		for (cnode = purple_blist_node_get_first_child(gnode);
-				cnode;
-				cnode = purple_blist_node_get_sibling_next(cnode)) {
-			if (!PURPLE_BLIST_NODE_IS_CONTACT(cnode))
-				continue;
-			for (bnode = purple_blist_node_get_first_child(cnode);
-					bnode;
-					bnode = purple_blist_node_get_sibling_next(bnode)) {
-				if (!PURPLE_BLIST_NODE_IS_BUDDY(bnode))
-					continue;
-				b = (PurpleBuddy *) bnode;
-				if (purple_buddy_get_account(b) == account) {
-					gchar *stripped_user = zephyr_strip_local_realm(zephyr, purple_buddy_get_name(b));
-					fprintf(fd, "%s\n", stripped_user);
-					g_free(stripped_user);
-				}
-			}
-		}
+	for (buddies = purple_find_buddies(account, NULL); buddies;
+			buddies = g_slist_delete_link(buddies, buddies)) {
+		PurpleBuddy *b = buddies->data;
+		gchar *stripped_user = zephyr_strip_local_realm(zephyr, purple_buddy_get_name(b));
+		fprintf(fd, "%s\n", stripped_user);
+		g_free(stripped_user);
 	}
 
 	fclose(fd);


More information about the Commits mailing list