aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2009-08-23 01:30:46 +0800
committerCosimo Cecchi <cosimoc@gnome.org>2009-09-17 16:41:00 +0800
commit847aa7cd822ea23d0619ebfdfcbee61ad374c42c (patch)
tree8b187902eec06f558a7b27760b70e1fb6ab7f9c0
parent7eb816f6c5ce610f767a40f387f0b4aef2a6e153 (diff)
downloadgsoc2013-empathy-847aa7cd822ea23d0619ebfdfcbee61ad374c42c.tar
gsoc2013-empathy-847aa7cd822ea23d0619ebfdfcbee61ad374c42c.tar.gz
gsoc2013-empathy-847aa7cd822ea23d0619ebfdfcbee61ad374c42c.tar.bz2
gsoc2013-empathy-847aa7cd822ea23d0619ebfdfcbee61ad374c42c.tar.lz
gsoc2013-empathy-847aa7cd822ea23d0619ebfdfcbee61ad374c42c.tar.xz
gsoc2013-empathy-847aa7cd822ea23d0619ebfdfcbee61ad374c42c.tar.zst
gsoc2013-empathy-847aa7cd822ea23d0619ebfdfcbee61ad374c42c.zip
Iterate avatar tokens with a GHashTableIter
-rw-r--r--libempathy/empathy-tp-contact-factory.c49
1 files changed, 19 insertions, 30 deletions
diff --git a/libempathy/empathy-tp-contact-factory.c b/libempathy/empathy-tp-contact-factory.c
index 20e3f70a0..dd6b60586 100644
--- a/libempathy/empathy-tp-contact-factory.c
+++ b/libempathy/empathy-tp-contact-factory.c
@@ -237,26 +237,6 @@ tp_contact_factory_avatar_maybe_update (EmpathyTpContactFactory *tp_factory,
return FALSE;
}
-typedef struct {
- EmpathyTpContactFactory *tp_factory;
- GArray *handles;
-} TokensData;
-
-static void
-tp_contact_factory_avatar_tokens_foreach (gpointer key,
- gpointer value,
- gpointer user_data)
-{
- TokensData *data = user_data;
- const gchar *token = value;
- guint handle = GPOINTER_TO_UINT (key);
-
- if (!tp_contact_factory_avatar_maybe_update (data->tp_factory,
- handle, token)) {
- g_array_append_val (data->handles, handle);
- }
-}
-
static void
tp_contact_factory_got_known_avatar_tokens (TpConnection *connection,
GHashTable *tokens,
@@ -266,33 +246,42 @@ tp_contact_factory_got_known_avatar_tokens (TpConnection *connection,
{
EmpathyTpContactFactory *tp_factory = EMPATHY_TP_CONTACT_FACTORY (weak_object);
EmpathyTpContactFactoryPriv *priv = GET_PRIV (tp_factory);
- TokensData data;
+ GArray *handles;
+ GHashTableIter iter;
+ gpointer key, value;
if (error) {
DEBUG ("Error: %s", error->message);
return;
}
- data.tp_factory = tp_factory;
- data.handles = g_array_new (FALSE, FALSE, sizeof (guint));
- g_hash_table_foreach (tokens,
- tp_contact_factory_avatar_tokens_foreach,
- &data);
+ handles = g_array_new (FALSE, FALSE, sizeof (guint));
+
+ g_hash_table_iter_init (&iter, tokens);
+ while (g_hash_table_iter_next (&iter, &key, &value)) {
+ guint handle = GPOINTER_TO_UINT (key);
+ const gchar *token = value;
+
+ if (!tp_contact_factory_avatar_maybe_update (tp_factory,
+ handle, token)) {
+ g_array_append_val (handles, handle);
+ }
+ }
DEBUG ("Got %d tokens, need to request %d avatars",
- g_hash_table_size (tokens), data.handles->len);
+ g_hash_table_size (tokens), handles->len);
/* Request needed avatars */
- if (data.handles->len > 0) {
+ if (handles->len > 0) {
tp_cli_connection_interface_avatars_call_request_avatars (priv->connection,
-1,
- data.handles,
+ handles,
tp_contact_factory_request_avatars_cb,
NULL, NULL,
G_OBJECT (tp_factory));
}
- g_array_free (data.handles, TRUE);
+ g_array_free (handles, TRUE);
}
static void