changeset 26766:9331016df8ac

Use more efficient purple_find_buddies in bonjour.
author Paul Aurich <paul@darkrain42.org>
date Fri, 01 May 2009 16:25:56 +0000
parents 998f471bb801
children 47d03538ee3f
files libpurple/blist.h libpurple/protocols/bonjour/jabber.c
diffstat 2 files changed, 8 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/blist.h	Fri May 01 16:09:50 2009 +0000
+++ b/libpurple/blist.h	Fri May 01 16:25:56 2009 +0000
@@ -260,11 +260,14 @@
 PurpleBlistNode *purple_blist_get_root(void);
 
 /**
- * Returns a list of every buddy in the list.
+ * Returns a list of every buddy in the list. The usage of this function
+ * is discourage if you do not actually need every buddy in the list. Use
+ * purple_find_buddies instead.
  *
  * @return A list of every buddy in the list. Caller is responsible for
  *         freeing the list.
  *
+ * @see purple_find_buddies
  * @since 2.6.0
  */
 GSList *purple_blist_get_buddies(void);
--- a/libpurple/protocols/bonjour/jabber.c	Fri May 01 16:09:50 2009 +0000
+++ b/libpurple/protocols/bonjour/jabber.c	Fri May 01 16:25:56 2009 +0000
@@ -233,26 +233,22 @@
 struct _match_buddies_by_address_t {
 	const char *address;
 	GSList *matched_buddies;
-	BonjourJabber *jdata;
 };
 
 static void
 _match_buddies_by_address(gpointer value, gpointer data)
 {
 	PurpleBuddy *pb = value;
-	PurpleAccount *account = NULL;
 	BonjourBuddy *bb = NULL;
 	struct _match_buddies_by_address_t *mbba = data;
 
-	account = purple_buddy_get_account(pb);
 	bb = purple_buddy_get_protocol_data(pb);
 
 	/*
-	 * If the current PurpleBuddy's data is not null and the PurpleBuddy's account
-	 * is the same as the account requesting the check then continue to determine
+	 * If the current PurpleBuddy's data is not null, then continue to determine
 	 * whether one of the buddies IPs matches the target IP.
 	 */
-	if (mbba->jdata->account == account && bb != NULL)
+	if (bb != NULL)
 	{
 		const char *ip;
 		GSList *tmp = bb->ips;
@@ -658,15 +654,13 @@
 	purple_debug_info("bonjour", "Received incoming connection from %s.\n", address_text);
 	mbba = g_new0(struct _match_buddies_by_address_t, 1);
 	mbba->address = address_text;
-	mbba->jdata = jdata;
 
-	buddies = purple_blist_get_buddies();
+	buddies = purple_find_buddies(jdata->account, NULL);
 	g_slist_foreach(buddies, _match_buddies_by_address, mbba);
 	g_slist_free(buddies);
 
 	if (mbba->matched_buddies == NULL) {
 		purple_debug_info("bonjour", "We don't like invisible buddies, this is not a superheros comic\n");
-		g_slist_free(mbba->matched_buddies);
 		g_free(mbba);
 		close(client_socket);
 		return;
@@ -858,9 +852,8 @@
 
 	mbba = g_new0(struct _match_buddies_by_address_t, 1);
 	mbba->address = bconv->ip;
-	mbba->jdata = jdata;
 
-	buddies = purple_blist_get_buddies();
+	buddies = purple_find_buddies(jdata->account, NULL);
 	g_slist_foreach(buddies, _match_buddies_by_address, mbba);
 	g_slist_free(buddies);