empathy r889 - trunk/libempathy



Author: xclaesse
Date: Fri Apr 11 14:10:25 2008
New Revision: 889
URL: http://svn.gnome.org/viewvc/empathy?rev=889&view=rev

Log:
Use tp-glib client API


Modified:
   trunk/libempathy/empathy-tp-group.c
   trunk/libempathy/empathy-tp-group.h

Modified: trunk/libempathy/empathy-tp-group.c
==============================================================================
--- trunk/libempathy/empathy-tp-group.c	(original)
+++ trunk/libempathy/empathy-tp-group.c	Fri Apr 11 14:10:25 2008
@@ -216,7 +216,7 @@
 				     "  removed-len=%d\n"
 				     "  local-pending-len=%d, current-len=%d\n"
 				     "  remote-pending-len=%d, current-len=%d",
-		       empathy_tp_group_get_name (group),
+		       priv->group_name,
 		       added ? added->len : 0, g_list_length (priv->members),
 		       removed ? removed->len : 0,
 		       local_pending ? local_pending->len : 0,
@@ -298,7 +298,7 @@
 				     "  members-len=%d\n"
 				     "  local-pendings-len=%d\n"
 				     "  remote-pendings-len=%d",
-		       empathy_tp_group_get_name (group),
+		       priv->group_name,
 		       g_list_length (priv->members),
 		       g_list_length (priv->local_pendings),
 		       g_list_length (priv->remote_pendings));
@@ -424,6 +424,24 @@
 }
 
 static void
+tp_group_inspect_handles_cb (TpConnection  *connection,
+			     const gchar  **names,
+			     const GError  *error,
+			     gpointer       user_data,
+			     GObject       *group)
+{
+	EmpathyTpGroupPriv *priv = GET_PRIV (group);
+
+	if (error) {
+		empathy_debug (DEBUG_DOMAIN, "Failed to inspect channel handle: %s",
+			       error->message);
+		return;
+	}
+
+	priv->group_name = g_strdup (*names);
+}
+
+static void
 tp_group_invalidated_cb (TpProxy        *proxy,
 			 guint           domain,
 			 gint            code,
@@ -442,6 +460,10 @@
 			     GObject      *group)
 {
 	EmpathyTpGroupPriv *priv = GET_PRIV (group);
+	TpConnection       *connection;
+	guint               channel_handle;
+	guint               channel_handle_type;
+	GArray             *handles;
 
 	if (error) {
 		empathy_debug (DEBUG_DOMAIN, "Failed to get self handle: %s",
@@ -449,13 +471,29 @@
 		return;
 	}
 
-	/* GetMembers is called last, so it will be the last to get the reply,
-	 * so we'll be ready once that call return. */
 	priv->self_handle = handle;
 	tp_cli_channel_interface_group_connect_to_members_changed (priv->channel,
 								   tp_group_members_changed_cb,
 								   NULL, NULL,
 								   group, NULL);
+
+	/* GetMembers is called last, so it will be the last to get the reply,
+	 * so we'll be ready once that call return. */
+	g_object_get (priv->channel,
+		      "connection", &connection,
+		      "handle-type", &channel_handle_type,
+		      "handle", &channel_handle,
+		      NULL);
+	handles = g_array_sized_new (FALSE, FALSE, sizeof (guint), 1);
+	g_array_prepend_val (handles, channel_handle);
+	tp_cli_connection_call_inspect_handles (connection, -1,
+						channel_handle_type,
+						handles,
+						tp_group_inspect_handles_cb,
+						NULL, NULL,
+						group);
+	g_array_free (handles, TRUE);
+
 	tp_cli_channel_interface_group_call_get_local_pending_members_with_info
 							(priv->channel, -1,
 							 tp_group_get_local_pending_cb,
@@ -546,10 +584,8 @@
 static void
 tp_group_constructed (GObject *group)
 {
-	EmpathyTpGroupPriv      *priv = GET_PRIV (group);
-	gboolean                 channel_ready;
-
-	G_OBJECT_CLASS (empathy_tp_group_parent_class)->constructed (group);
+	EmpathyTpGroupPriv *priv = GET_PRIV (group);
+	gboolean            channel_ready;
 
 	priv->factory = empathy_contact_factory_new ();
 
@@ -908,16 +944,10 @@
 const gchar *
 empathy_tp_group_get_name (EmpathyTpGroup *group)
 {
-	EmpathyTpGroupPriv *priv;
+	EmpathyTpGroupPriv *priv = GET_PRIV (group);
 
 	g_return_val_if_fail (EMPATHY_IS_TP_GROUP (group), NULL);
-
-	priv = GET_PRIV (group);
-
-	/* Lazy initialisation */
-	if (!priv->group_name && priv->tp_chan->handle != 0) {
-		priv->group_name = empathy_inspect_channel (priv->account, priv->tp_chan);
-	}
+	g_return_val_if_fail (priv->ready, NULL);
 
 	return priv->group_name;
 }
@@ -969,3 +999,14 @@
 	return g_list_find (priv->members, contact) != NULL;
 }
 
+gboolean
+empathy_tp_group_is_ready (EmpathyTpGroup *group)
+{
+	EmpathyTpGroupPriv *priv = GET_PRIV (group);
+
+	g_return_val_if_fail (EMPATHY_IS_TP_GROUP (group), FALSE);
+
+	return priv->ready;
+}
+
+

Modified: trunk/libempathy/empathy-tp-group.h
==============================================================================
--- trunk/libempathy/empathy-tp-group.h	(original)
+++ trunk/libempathy/empathy-tp-group.h	Fri Apr 11 14:10:25 2008
@@ -83,6 +83,7 @@
 TpChan *            empathy_tp_group_get_channel         (EmpathyTpGroup     *group);
 gboolean            empathy_tp_group_is_member           (EmpathyTpGroup     *group,
 							  EmpathyContact     *contact);
+gboolean            empathy_tp_group_is_ready            (EmpathyTpGroup     *group);
 EmpathyPendingInfo *empathy_pending_info_new             (EmpathyContact     *member,
 							  EmpathyContact     *actor,
 							  const gchar        *message);



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