[empathy/gnome-2-28] Iterate avatar tokens with a GHashTableIter
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [empathy/gnome-2-28] Iterate avatar tokens with a GHashTableIter
- Date: Thu, 15 Oct 2009 12:00:44 +0000 (UTC)
commit ef109f7f0d83a5122da14e9bca67e973bfd4ff4f
Author: Will Thompson <will thompson collabora co uk>
Date: Sat Aug 22 18:30:46 2009 +0100
Iterate avatar tokens with a GHashTableIter
libempathy/empathy-tp-contact-factory.c | 49 ++++++++++++-------------------
1 files changed, 19 insertions(+), 30 deletions(-)
---
diff --git a/libempathy/empathy-tp-contact-factory.c b/libempathy/empathy-tp-contact-factory.c
index 20e3f70..dd6b605 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]