[empathy] factor out got_list_channel



commit 944632a01dd934666170583b87e970f32211f810
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Wed Mar 24 11:22:53 2010 +0100

    factor out got_list_channel

 libempathy/empathy-tp-contact-list.c |   46 ++++++++++++++++++++--------------
 1 files changed, 27 insertions(+), 19 deletions(-)
---
diff --git a/libempathy/empathy-tp-contact-list.c b/libempathy/empathy-tp-contact-list.c
index b273ad2..2f2717b 100644
--- a/libempathy/empathy-tp-contact-list.c
+++ b/libempathy/empathy-tp-contact-list.c
@@ -698,49 +698,57 @@ 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,
 	       gpointer data)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]