empathy r766 - trunk/libempathy



Author: xclaesse
Date: Tue Mar 11 12:22:57 2008
New Revision: 766
URL: http://svn.gnome.org/viewvc/empathy?rev=766&view=rev

Log:
Prepare a new API for chat properties


Modified:
   trunk/libempathy/empathy-tp-chat.c
   trunk/libempathy/empathy-tp-chatroom.c
   trunk/libempathy/empathy-tp-chatroom.h

Modified: trunk/libempathy/empathy-tp-chat.c
==============================================================================
--- trunk/libempathy/empathy-tp-chat.c	(original)
+++ trunk/libempathy/empathy-tp-chat.c	Tue Mar 11 12:22:57 2008
@@ -369,6 +369,53 @@
 	}
 }
 
+static void
+tp_chat_properties_changed_cb (TpProxy         *proxy,
+			       const GPtrArray *properties,
+			       gpointer         user_data,
+			       GObject         *chat)
+{
+}
+
+static void
+tp_chat_get_properties_cb (TpProxy         *proxy,
+			   const GPtrArray *properties,
+			   const GError    *error,
+			   gpointer         user_data,
+			   GObject         *chat)
+{
+	tp_chat_properties_changed_cb (proxy, properties, user_data, chat);
+}
+
+static void
+tp_chat_list_properties_cb (TpProxy         *proxy,
+			    const GPtrArray *properties,
+			    const GError    *error,
+			    gpointer         user_data,
+			    GObject         *chat)
+{
+	GArray *ids;
+	guint   i;
+
+	ids = g_array_sized_new (FALSE, FALSE, sizeof (guint), properties->len);
+	for (i = 0; i < properties->len; i++) {
+		GValueArray *prop_struct;
+		guint        id;
+
+		prop_struct = g_ptr_array_index (properties, i);
+		id = g_value_get_uint (g_value_array_get_nth (prop_struct, 0));
+		g_array_append_val (ids, id);
+	}
+
+	tp_cli_properties_interface_call_get_properties (proxy, -1,
+							 ids,
+							 tp_chat_get_properties_cb,
+							 NULL, NULL,
+							 chat);
+
+	g_array_free (ids, TRUE);
+}
+
 static gboolean
 tp_chat_channel_ready_cb (EmpathyTpChat *chat)
 {
@@ -381,6 +428,11 @@
 							     tp_chat_list_pending_messages_cb,
 							     NULL, NULL,
 							     G_OBJECT (chat));
+	tp_cli_properties_interface_call_list_properties (priv->channel, -1,
+							  tp_chat_list_properties_cb,
+							  NULL, NULL,
+							  G_OBJECT (chat));
+
 
 	tp_cli_channel_type_text_connect_to_received (priv->channel,
 						      tp_chat_received_cb,
@@ -398,6 +450,14 @@
 									   tp_chat_state_changed_cb,
 									   NULL, NULL,
 									   G_OBJECT (chat), NULL);
+	tp_cli_channel_interface_chat_state_connect_to_chat_state_changed (priv->channel,
+									   tp_chat_state_changed_cb,
+									   NULL, NULL,
+									   G_OBJECT (chat), NULL);
+	tp_cli_properties_interface_connect_to_properties_changed (priv->channel,
+								   tp_chat_properties_changed_cb,
+								   NULL, NULL,
+								   G_OBJECT (chat), NULL);
 
 	return FALSE;
 }
@@ -465,10 +525,6 @@
 					  chat);
 	}
 
-	/* FIXME: We do that in a cb to let time to set the acknowledge
-	 * property, this property should be required for construct. */
-	g_idle_add ((GSourceFunc) empathy_tp_chat_get_pendings, chat);
-
 	return chat;
 }
 

Modified: trunk/libempathy/empathy-tp-chatroom.c
==============================================================================
--- trunk/libempathy/empathy-tp-chatroom.c	(original)
+++ trunk/libempathy/empathy-tp-chatroom.c	Tue Mar 11 12:22:57 2008
@@ -43,63 +43,12 @@
 static void            empathy_tp_chatroom_class_init (EmpathyTpChatroomClass  *klass);
 static void            tp_chatroom_iface_init         (EmpathyContactListIface *iface);
 static void            empathy_tp_chatroom_init       (EmpathyTpChatroom       *chatroom);
-static void            tp_chatroom_finalize           (GObject                 *object);
-static void            tp_chatroom_add                (EmpathyContactList      *list,
-						       EmpathyContact           *contact,
-						       const gchar             *message);
-static void            tp_chatroom_remove             (EmpathyContactList      *list,
-						       EmpathyContact           *contact,
-						       const gchar             *message);
-static GList *         tp_chatroom_get_members        (EmpathyContactList      *list);
 
 G_DEFINE_TYPE_WITH_CODE (EmpathyTpChatroom, empathy_tp_chatroom, EMPATHY_TYPE_TP_CHAT,
 			 G_IMPLEMENT_INTERFACE (EMPATHY_TYPE_CONTACT_LIST,
 						tp_chatroom_iface_init));
 
 static void
-empathy_tp_chatroom_class_init (EmpathyTpChatroomClass *klass)
-{
-	GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
-	object_class->finalize = tp_chatroom_finalize;
-
-	g_type_class_add_private (object_class, sizeof (EmpathyTpChatroomPriv));
-}
-
-static void
-tp_chatroom_iface_init (EmpathyContactListIface *iface)
-{
-	iface->add         = tp_chatroom_add;
-	iface->remove      = tp_chatroom_remove;
-	iface->get_members = tp_chatroom_get_members;
-}
-
-static void
-empathy_tp_chatroom_init (EmpathyTpChatroom *chatroom)
-{
-}
-
-static void
-tp_chatroom_finalize (GObject *object)
-{
-	EmpathyTpChatroomPriv *priv;
-	EmpathyTpChatroom     *chatroom;
-
-	chatroom = EMPATHY_TP_CHATROOM (object);
-	priv = GET_PRIV (chatroom);
-
-	g_object_unref (priv->group);
-
-	if (priv->invitor) {
-		g_object_unref (priv->invitor);
-	}
-
-	g_free (priv->invit_message);
-
-	G_OBJECT_CLASS (empathy_tp_chatroom_parent_class)->finalize (object);
-}
-
-static void
 tp_chatroom_member_added_cb (EmpathyTpGroup    *group,
 			     EmpathyContact    *contact,
 			     EmpathyContact    *actor,
@@ -146,19 +95,113 @@
 	}
 }
 
+static void
+tp_chatroom_add (EmpathyContactList *list,
+		 EmpathyContact     *contact,
+		 const gchar        *message)
+{
+	EmpathyTpChatroomPriv *priv;
+
+	g_return_if_fail (EMPATHY_IS_TP_CHATROOM (list));
+	g_return_if_fail (EMPATHY_IS_CONTACT (contact));
+
+	priv = GET_PRIV (list);
+
+	empathy_tp_group_add_member (priv->group, contact, message);
+}
+
+static void
+tp_chatroom_remove (EmpathyContactList *list,
+		    EmpathyContact     *contact,
+		    const gchar        *message)
+{
+	EmpathyTpChatroomPriv *priv;
+
+	g_return_if_fail (EMPATHY_IS_TP_CHATROOM (list));
+	g_return_if_fail (EMPATHY_IS_CONTACT (contact));
+
+	priv = GET_PRIV (list);
+
+	empathy_tp_group_remove_member (priv->group, contact, message);
+}
+
+static GList *
+tp_chatroom_get_members (EmpathyContactList *list)
+{
+	EmpathyTpChatroomPriv *priv;
+
+	g_return_val_if_fail (EMPATHY_IS_TP_CHATROOM (list), NULL);
+
+	priv = GET_PRIV (list);
+
+	return empathy_tp_group_get_members (priv->group);
+}
+
+static void
+tp_chatroom_finalize (GObject *object)
+{
+	EmpathyTpChatroomPriv *priv;
+	EmpathyTpChatroom     *chatroom;
+
+	chatroom = EMPATHY_TP_CHATROOM (object);
+	priv = GET_PRIV (chatroom);
+
+	g_object_unref (priv->group);
+
+	if (priv->invitor) {
+		g_object_unref (priv->invitor);
+	}
+
+	g_free (priv->invit_message);
+
+	G_OBJECT_CLASS (empathy_tp_chatroom_parent_class)->finalize (object);
+}
+
+static void
+empathy_tp_chatroom_class_init (EmpathyTpChatroomClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+	object_class->finalize = tp_chatroom_finalize;
+
+	g_type_class_add_private (object_class, sizeof (EmpathyTpChatroomPriv));
+}
+
+static void
+tp_chatroom_iface_init (EmpathyContactListIface *iface)
+{
+	iface->add         = tp_chatroom_add;
+	iface->remove      = tp_chatroom_remove;
+	iface->get_members = tp_chatroom_get_members;
+}
+
+static void
+empathy_tp_chatroom_init (EmpathyTpChatroom *chatroom)
+{
+}
+
 EmpathyTpChatroom *
 empathy_tp_chatroom_new (McAccount *account,
 			 TpChan    *tp_chan)
 {
 	EmpathyTpChatroomPriv *priv;
 	EmpathyTpChatroom     *chatroom;
+	TpChannel             *channel;
+	TpConnection          *connection;
+	MissionControl        *mc;
+	TpConn                *tp_conn;
 
 	g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL);
 	g_return_val_if_fail (TELEPATHY_IS_CHAN (tp_chan), NULL);
 
+	mc = empathy_mission_control_new ();
+	tp_conn = mission_control_get_connection (mc, account, NULL);
+	connection = tp_conn_dup_connection (tp_conn);
+	channel = tp_chan_dup_channel (tp_chan, connection, NULL);
+
 	chatroom = g_object_new (EMPATHY_TYPE_TP_CHATROOM,
 				 "account", account,
-				 "tp-chan", tp_chan,
+				 "channel", channel,
 				 NULL);
 
 	priv = GET_PRIV (chatroom);
@@ -175,6 +218,11 @@
 			  G_CALLBACK (tp_chatroom_local_pending_cb),
 			  chatroom);
 
+	g_object_unref (channel);
+	g_object_unref (tp_conn);
+	g_object_unref (connection);
+	g_object_unref (mc);
+
 	return chatroom;
 }
 
@@ -228,52 +276,3 @@
 	g_object_unref (user);
 }
 
-void
-empathy_tp_chatroom_set_topic (EmpathyTpChatroom *chatroom,
-			       const gchar       *topic)
-{
-	/* FIXME: not implemented */
-}
-
-static void
-tp_chatroom_add (EmpathyContactList *list,
-		 EmpathyContact     *contact,
-		 const gchar        *message)
-{
-	EmpathyTpChatroomPriv *priv;
-
-	g_return_if_fail (EMPATHY_IS_TP_CHATROOM (list));
-	g_return_if_fail (EMPATHY_IS_CONTACT (contact));
-
-	priv = GET_PRIV (list);
-
-	empathy_tp_group_add_member (priv->group, contact, message);
-}
-
-static void
-tp_chatroom_remove (EmpathyContactList *list,
-		    EmpathyContact     *contact,
-		    const gchar        *message)
-{
-	EmpathyTpChatroomPriv *priv;
-
-	g_return_if_fail (EMPATHY_IS_TP_CHATROOM (list));
-	g_return_if_fail (EMPATHY_IS_CONTACT (contact));
-
-	priv = GET_PRIV (list);
-
-	empathy_tp_group_remove_member (priv->group, contact, message);
-}
-
-static GList *
-tp_chatroom_get_members (EmpathyContactList *list)
-{
-	EmpathyTpChatroomPriv *priv;
-
-	g_return_val_if_fail (EMPATHY_IS_TP_CHATROOM (list), NULL);
-
-	priv = GET_PRIV (list);
-
-	return empathy_tp_group_get_members (priv->group);
-}
-

Modified: trunk/libempathy/empathy-tp-chatroom.h
==============================================================================
--- trunk/libempathy/empathy-tp-chatroom.h	(original)
+++ trunk/libempathy/empathy-tp-chatroom.h	Tue Mar 11 12:22:57 2008
@@ -58,8 +58,6 @@
 							  EmpathyContact     **contact,
 							  const gchar       **message);
 void               empathy_tp_chatroom_accept_invitation (EmpathyTpChatroom *chatroom);
-void               empathy_tp_chatroom_set_topic         (EmpathyTpChatroom *chatroom,
-							  const gchar       *topic);
 G_END_DECLS
 
 #endif /* __EMPATHY_TP_CHATROOM_H__ */



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