diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2010-04-07 16:02:01 +0800 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2010-04-08 18:34:57 +0800 |
commit | c92e1b6631677972dbd25b1164d00ea983340fee (patch) | |
tree | f4b994c75b911597795827f83f9da606701deada | |
parent | 2a6a15152ede1372f283b87fc9db0c50cec0955e (diff) | |
download | gsoc2013-empathy-c92e1b6631677972dbd25b1164d00ea983340fee.tar gsoc2013-empathy-c92e1b6631677972dbd25b1164d00ea983340fee.tar.gz gsoc2013-empathy-c92e1b6631677972dbd25b1164d00ea983340fee.tar.bz2 gsoc2013-empathy-c92e1b6631677972dbd25b1164d00ea983340fee.tar.lz gsoc2013-empathy-c92e1b6631677972dbd25b1164d00ea983340fee.tar.xz gsoc2013-empathy-c92e1b6631677972dbd25b1164d00ea983340fee.tar.zst gsoc2013-empathy-c92e1b6631677972dbd25b1164d00ea983340fee.zip |
factor out iteration on channels
-rw-r--r-- | libempathy/empathy-tp-contact-list.c | 46 |
1 files changed, 18 insertions, 28 deletions
diff --git a/libempathy/empathy-tp-contact-list.c b/libempathy/empathy-tp-contact-list.c index ef0d53212..93742681a 100644 --- a/libempathy/empathy-tp-contact-list.c +++ b/libempathy/empathy-tp-contact-list.c @@ -800,12 +800,9 @@ list_ensure_channel_cb (TpConnection *conn, } static void -new_channels_cb (TpConnection *conn, - const GPtrArray *channels, - gpointer user_data, - GObject *weak_object) +iterate_on_channels (EmpathyTpContactList *list, + const GPtrArray *channels) { - EmpathyTpContactList *list = EMPATHY_TP_CONTACT_LIST (weak_object); guint i; for (i = 0; i < channels->len ; i++) { @@ -828,13 +825,25 @@ new_channels_cb (TpConnection *conn, handle_type = tp_asv_get_uint32 (properties, TP_IFACE_CHANNEL ".TargetHandleType", NULL); - if (handle_type == TP_HANDLE_TYPE_GROUP) { - tp_contact_list_group_add_channel (list, path, properties); - } + if (handle_type != TP_HANDLE_TYPE_GROUP) + return; + + tp_contact_list_group_add_channel (list, path, properties); } } static void +new_channels_cb (TpConnection *conn, + const GPtrArray *channels, + gpointer user_data, + GObject *weak_object) +{ + EmpathyTpContactList *list = EMPATHY_TP_CONTACT_LIST (weak_object); + + iterate_on_channels (list, channels); +} + +static void got_channels_cb (TpProxy *conn, const GValue *out, const GError *error, @@ -842,7 +851,6 @@ got_channels_cb (TpProxy *conn, GObject *weak_object) { EmpathyTpContactList *list = EMPATHY_TP_CONTACT_LIST (weak_object); - guint i; const GPtrArray *channels; if (error != NULL) { @@ -851,25 +859,7 @@ got_channels_cb (TpProxy *conn, } channels = g_value_get_boxed (out); - for (i = 0; i < channels->len ; i++) { - GValueArray *arr = g_ptr_array_index (channels, i); - const gchar *path; - GHashTable *properties; - - path = g_value_get_boxed (g_value_array_get_nth (arr, 0)); - properties = g_value_get_boxed (g_value_array_get_nth (arr, 1)); - - if (tp_strdiff (tp_asv_get_string (properties, - TP_IFACE_CHANNEL ".ChannelType"), - TP_IFACE_CHANNEL_TYPE_CONTACT_LIST)) - continue; - - if (tp_asv_get_uint32 (properties, - TP_IFACE_CHANNEL ".TargetHandleType", NULL) != TP_HANDLE_TYPE_GROUP) - continue; - - tp_contact_list_group_add_channel (list, path, properties); - } + iterate_on_channels (list, channels); } static void |