From 944632a01dd934666170583b87e970f32211f810 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Wed, 24 Mar 2010 11:22:53 +0100 Subject: factor out got_list_channel --- libempathy/empathy-tp-contact-list.c | 46 +++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/libempathy/empathy-tp-contact-list.c b/libempathy/empathy-tp-contact-list.c index b273ad20e..2f2717b44 100644 --- a/libempathy/empathy-tp-contact-list.c +++ b/libempathy/empathy-tp-contact-list.c @@ -698,48 +698,56 @@ tp_contact_list_finalize (GObject *object) } static void -list_ensure_channel_cb (TpConnection *conn, - gboolean yours, - const gchar *path, - GHashTable *properties, - const GError *error, - gpointer user_data, - GObject *weak_object) +got_list_channel (EmpathyTpContactList *list, + TpChannel *channel) { - EmpathyTpContactList *list = user_data; EmpathyTpContactListPriv *priv = GET_PRIV (list); const gchar *id; - TpChannel *channel; - - if (error != NULL) { - DEBUG ("failed: %s\n", error->message); - return; - } /* We requested that channel by providing TargetID property, so it's * guaranteed that tp_channel_get_identifier will return it. */ - channel = tp_channel_new_from_properties (conn, path, properties, NULL); id = tp_channel_get_identifier (channel); /* TpChannel emits initial set of members just before being ready */ if (!tp_strdiff (id, "stored")) { - priv->stored = channel; + priv->stored = g_object_ref (channel); } else if (!tp_strdiff (id, "publish")) { - priv->publish = channel; + priv->publish = g_object_ref (channel); g_signal_connect (priv->publish, "group-members-changed", G_CALLBACK (tp_contact_list_publish_group_members_changed_cb), list); } else if (!tp_strdiff (id, "subscribe")) { - priv->subscribe = channel; + priv->subscribe = g_object_ref (channel); g_signal_connect (priv->subscribe, "group-members-changed", G_CALLBACK (tp_contact_list_subscribe_group_members_changed_cb), list); } else { g_warn_if_reached (); - g_object_unref (channel); } } +static void +list_ensure_channel_cb (TpConnection *conn, + gboolean yours, + const gchar *path, + GHashTable *properties, + const GError *error, + gpointer user_data, + GObject *weak_object) +{ + EmpathyTpContactList *list = user_data; + TpChannel *channel; + + if (error != NULL) { + DEBUG ("failed: %s\n", error->message); + return; + } + + channel = tp_channel_new_from_properties (conn, path, properties, NULL); + got_list_channel (list, channel); + g_object_unref (channel); +} + static void conn_ready_cb (TpConnection *connection, const GError *error, -- cgit v1.2.3