# HG changeset patch # User Paul Aurich # Date 1239471678 0 # Node ID d68b338d9eeddb0058504656f2802d2fad96bf24 # Parent fac5f6efb75f7edd9f9ab0c9820d03f18c10d220# Parent 2b7604ede0e4dc0774f041da559c8f644ac3fb8b merge of 'c21c65b2cb75f7371f96b652c904d2d83a072cc5' and 'e8317a2ca5bf7c56db936d94d75c0a92d1432d7a' diff -r fac5f6efb75f -r d68b338d9eed libpurple/blist.c --- a/libpurple/blist.c Sat Apr 11 07:20:53 2009 +0000 +++ b/libpurple/blist.c Sat Apr 11 17:41:18 2009 +0000 @@ -699,10 +699,23 @@ return purplebuddylist ? purplebuddylist->root : NULL; } -GHashTable * +static void +append_buddy(gpointer key, gpointer value, gpointer user_data) +{ + GSList **list = user_data; + *list = g_slist_prepend(*list, value); +} + +GSList * purple_blist_get_buddies() { - return purplebuddylist ? purplebuddylist->buddies : NULL; + GSList *buddies = NULL; + + if (!purplebuddylist) + return NULL; + + g_hash_table_foreach(purplebuddylist->buddies, append_buddy, &buddies); + return buddies; } void * diff -r fac5f6efb75f -r d68b338d9eed libpurple/blist.h --- a/libpurple/blist.h Sat Apr 11 07:20:53 2009 +0000 +++ b/libpurple/blist.h Sat Apr 11 17:41:18 2009 +0000 @@ -260,13 +260,14 @@ PurpleBlistNode *purple_blist_get_root(void); /** - * Returns the hash table of every buddy in the list. + * Returns a list of every buddy in the list. * - * @return The hash table of every buddy in the list. + * @return A list of every buddy in the list. Caller is responsible for + * freeing the list. * * @since 2.6.0 */ -GHashTable *purple_blist_get_buddies(void); +GSList *purple_blist_get_buddies(void); /** * Returns the UI data for the list. diff -r fac5f6efb75f -r d68b338d9eed libpurple/protocols/bonjour/jabber.c --- a/libpurple/protocols/bonjour/jabber.c Sat Apr 11 07:20:53 2009 +0000 +++ b/libpurple/protocols/bonjour/jabber.c Sat Apr 11 17:41:18 2009 +0000 @@ -237,7 +237,7 @@ }; static void -_match_buddies_by_address(gpointer key, gpointer value, gpointer data) +_match_buddies_by_address(gpointer value, gpointer data) { PurpleBuddy *pb = value; PurpleAccount *account = NULL; @@ -638,6 +638,7 @@ char *address_text = NULL; struct _match_buddies_by_address_t *mbba; BonjourJabberConversation *bconv; + GSList *buddies; /* Check that it is a read condition */ if (condition != PURPLE_INPUT_READ) @@ -658,7 +659,10 @@ mbba = g_new0(struct _match_buddies_by_address_t, 1); mbba->address = address_text; mbba->jdata = jdata; - g_hash_table_foreach(purple_blist_get_buddies(), _match_buddies_by_address, mbba); + + buddies = purple_blist_get_buddies(); + 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"); @@ -850,11 +854,15 @@ bonjour_jabber_conv_match_by_ip(BonjourJabberConversation *bconv) { BonjourJabber *jdata = ((BonjourData*) bconv->account->gc->proto_data)->jabber_data; struct _match_buddies_by_address_t *mbba; + GSList *buddies; mbba = g_new0(struct _match_buddies_by_address_t, 1); mbba->address = bconv->ip; mbba->jdata = jdata; - g_hash_table_foreach(purple_blist_get_buddies(), _match_buddies_by_address, mbba); + + buddies = purple_blist_get_buddies(); + g_slist_foreach(buddies, _match_buddies_by_address, mbba); + g_slist_free(buddies); /* If there is exactly one match, use it */ if(mbba->matched_buddies != NULL) {