pidgin: e8317a2c: Change purple_blist_get_buddies to retur...

paul at darkrain42.org paul at darkrain42.org
Sat Apr 11 13:45:45 EDT 2009


-----------------------------------------------------------------
Revision: e8317a2ca5bf7c56db936d94d75c0a92d1432d7a
Ancestor: 079a5ca1aa110ee9f6661eba31e5ea3f0b5a07e7
Author: paul at darkrain42.org
Date: 2009-04-11T17:41:10
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/e8317a2ca5bf7c56db936d94d75c0a92d1432d7a

Modified files:
        libpurple/blist.c libpurple/blist.h
        libpurple/protocols/bonjour/jabber.c

ChangeLog: 

Change purple_blist_get_buddies to return a list instead of the hash table.

Closes #8644.

-------------- next part --------------
============================================================
--- libpurple/blist.c	13be96798de3c2e52b38a9e6381974820b90ffd2
+++ libpurple/blist.c	d234a0baebdf64267995d36b6f385c3e3167c3d4
@@ -699,10 +699,23 @@ purple_blist_get_root()
 	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 *
============================================================
--- libpurple/blist.h	b1d8652bb542bc432a48db33454250a44b26b797
+++ libpurple/blist.h	5d3369221ea75622b3d9b3e0f0b36c8ad651897e
@@ -260,13 +260,14 @@ PurpleBlistNode *purple_blist_get_root(v
 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.
============================================================
--- libpurple/protocols/bonjour/jabber.c	59f1b998a98ca974582745d6dbed8e81e604c921
+++ libpurple/protocols/bonjour/jabber.c	d1f2fa81128bad84a2b44af0484263f99e5643d0
@@ -237,7 +237,7 @@ static void
 };
 
 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 @@ _server_socket_handler(gpointer data, in
 	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,8 +659,11 @@ _server_socket_handler(gpointer data, in
 	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");
 		g_slist_free(mbba->matched_buddies);
@@ -850,12 +854,16 @@ bonjour_jabber_conv_match_by_ip(BonjourJ
 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) {
 		if(mbba->matched_buddies->next != NULL)


More information about the Commits mailing list