# HG changeset patch # User Paul Aurich # Date 1241195156 0 # Node ID 9331016df8ac3d2c57e1333af231f9e8c48eed25 # Parent 998f471bb801922f2d2d2a501da4f47bea0dccaf Use more efficient purple_find_buddies in bonjour. diff -r 998f471bb801 -r 9331016df8ac libpurple/blist.h --- 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); diff -r 998f471bb801 -r 9331016df8ac libpurple/protocols/bonjour/jabber.c --- 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);