empathy r907 - in trunk: libempathy libempathy-gtk src



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

Log:
Update for new API


Modified:
   trunk/libempathy-gtk/empathy-chat.c
   trunk/libempathy/empathy-tp-contact-list.c
   trunk/src/empathy-call-chandler.c
   trunk/src/empathy-status-icon.c
   trunk/src/empathy.c

Modified: trunk/libempathy-gtk/empathy-chat.c
==============================================================================
--- trunk/libempathy-gtk/empathy-chat.c	(original)
+++ trunk/libempathy-gtk/empathy-chat.c	Fri Apr 11 14:11:06 2008
@@ -1572,10 +1572,10 @@
 			  EmpathyTpChat *tp_chat)
 {
 	EmpathyChatPriv *priv;
-	TpChan          *tp_chan;
 
 	g_return_if_fail (EMPATHY_IS_CHAT (chat));
 	g_return_if_fail (EMPATHY_IS_TP_CHAT (tp_chat));
+	g_return_if_fail (empathy_tp_chat_is_ready (tp_chat));
 
 	priv = GET_PRIV (chat);
 
@@ -1594,8 +1594,6 @@
 	priv->tp_chat = g_object_ref (tp_chat);
 	priv->id = g_strdup (empathy_tp_chat_get_id (tp_chat));
 	priv->account = g_object_ref (empathy_tp_chat_get_account (tp_chat));
-	tp_chan = empathy_tp_chat_get_channel (tp_chat);
-	priv->handle_type = tp_chan->handle_type;
 
 	g_signal_connect (tp_chat, "message-received",
 			  G_CALLBACK (chat_message_received_cb),

Modified: trunk/libempathy/empathy-tp-contact-list.c
==============================================================================
--- trunk/libempathy/empathy-tp-contact-list.c	(original)
+++ trunk/libempathy/empathy-tp-contact-list.c	Fri Apr 11 14:11:06 2008
@@ -403,7 +403,7 @@
 				  object_path, channel_type,
 				  handle_type, handle, NULL);
 
-	group = empathy_tp_group_new (priv->account, channel);
+	group = empathy_tp_group_new (channel);
 	empathy_run_until_ready (group);
 	g_object_unref (channel);
 

Modified: trunk/src/empathy-call-chandler.c
==============================================================================
--- trunk/src/empathy-call-chandler.c	(original)
+++ trunk/src/empathy-call-chandler.c	Fri Apr 11 14:11:06 2008
@@ -47,13 +47,12 @@
 
 static void
 new_channel_cb (EmpathyChandler *chandler,
-                TpConn *connection,
-                TpChan *channel,
+                TpChannel *channel,
                 MissionControl *mc)
 {
   EmpathyTpCall *call;
 
-  call = empathy_tp_call_new (connection, channel);
+  call = empathy_tp_call_new (channel);
   empathy_call_window_new (call);
   g_object_unref (call);
 

Modified: trunk/src/empathy-status-icon.c
==============================================================================
--- trunk/src/empathy-status-icon.c	(original)
+++ trunk/src/empathy-status-icon.c	Fri Apr 11 14:11:06 2008
@@ -92,13 +92,11 @@
 static void       empathy_status_icon_class_init  (EmpathyStatusIconClass *klass);
 static void       empathy_status_icon_init        (EmpathyStatusIcon      *icon);
 static void       status_icon_finalize            (GObject                *object);
-static void       status_icon_text_filter_new_channel (EmpathyFilter          *filter,
-						   TpConn                 *tp_conn,
-						   TpChan                 *tp_chan,
+static void       status_icon_text_filter_new_channel (EmpathyFilter      *filter,
+						   TpChannel              *channel,
 						   EmpathyStatusIcon      *icon);
-static void       status_icon_call_filter_new_channel (EmpathyFilter          *filter,
-						   TpConn                 *tp_conn,
-						   TpChan                 *tp_chan,
+static void       status_icon_call_filter_new_channel (EmpathyFilter      *filter,
+						   TpChannel              *channel,
 						   EmpathyStatusIcon      *icon);
 static void       status_icon_message_received_cb (EmpathyTpChat          *tp_chat,
 						   EmpathyMessage         *message,
@@ -292,24 +290,17 @@
 
 static void
 status_icon_text_filter_new_channel (EmpathyFilter     *filter,
-				     TpConn            *tp_conn,
-				     TpChan            *tp_chan,
+				     TpChannel         *channel,
 				     EmpathyStatusIcon *icon)
 {
-	EmpathyStatusIconPriv *priv;
-	McAccount             *account;
-	EmpathyTpChat         *tp_chat;
-
-	priv = GET_PRIV (icon);
-
-	account = mission_control_get_account_for_connection (priv->mc, tp_conn, NULL);
+	EmpathyTpChat *tp_chat;
 
-	empathy_debug (DEBUG_DOMAIN, "New text channel to be filtered for contact %s",
-		       empathy_inspect_channel (account, tp_chan));
+	empathy_debug (DEBUG_DOMAIN, "New text channel to be filtered for contact %p",
+		       channel);
 
-	tp_chat = empathy_tp_chat_new (account, tp_chan, FALSE);
+	tp_chat = empathy_tp_chat_new (channel, FALSE);
 	g_object_set_data (G_OBJECT (tp_chat), "filter", filter);
-	g_object_unref (account);
+	g_object_set_data (G_OBJECT (tp_chat), "channel", channel);
 
 	g_signal_connect (tp_chat, "message-received",
 			  G_CALLBACK (status_icon_message_received_cb),
@@ -343,68 +334,60 @@
 }
 
 static void
-status_icon_call_member_added_cb (EmpathyTpGroup    *group,
-				  EmpathyContact    *member,
-				  EmpathyContact    *actor,
-				  guint              reason,
-				  const gchar       *message,
-				  EmpathyStatusIcon *icon)
-{
-	EmpathyFilter *filter;
-
-	if (empathy_contact_is_user (member)) {
-		/* We are member, it's an outgoing call, we can dispatch
-		 * the channel without asking the user */
-		empathy_debug (DEBUG_DOMAIN, "Process OUTGOING call channel");
-		filter = g_object_get_data (G_OBJECT (group), "filter");
-		empathy_filter_process (filter,
-					empathy_tp_group_get_channel (group),
-					TRUE);
-		g_object_unref (group);
-	}
-}
-
-static void
 status_icon_event_call_cb (StatusIconEvent *event)
 {
-	EmpathyFilter  *filter;
 	EmpathyTpGroup *group;
+	EmpathyFilter  *filter;
+	TpChannel      *channel;
 
 	empathy_debug (DEBUG_DOMAIN, "Dispatching call channel");
 
 	group = event->user_data;
 	filter = g_object_get_data (G_OBJECT (group), "filter");
-	empathy_filter_process (filter,
-				empathy_tp_group_get_channel (group),
-				TRUE);
+	channel = g_object_get_data (G_OBJECT (group), "channel");
+	empathy_filter_process (filter, channel, TRUE);
 	g_object_unref (group);
 }
 
 static void
-status_icon_call_local_pending_cb (EmpathyTpGroup    *group,
-				   EmpathyContact    *member,
-				   EmpathyContact    *actor,
-				   guint              reason,
-				   const gchar       *message,
-				   EmpathyStatusIcon *icon)
+status_icon_call_filter_new_channel (EmpathyFilter     *filter,
+				     TpChannel         *channel,
+				     EmpathyStatusIcon *icon)
 {
-	StatusIconEvent *event;
+	EmpathyTpGroup     *group;
+	EmpathyPendingInfo *invitation;
+	EmpathyContact     *contact = NULL;
+
+	empathy_debug (DEBUG_DOMAIN, "New media channel to be filtered");
+
+	/* FIXME: We have to check if the user is member or local-pending to
+	 * know if it's an incoming or outgoing call because of the way we
+	 * request media channels MC can't know if it's incoming or outgoing */
+	group = empathy_tp_group_new (channel);
+	empathy_run_until_ready (group);
 
-	if (empathy_contact_is_user (member)) {
-		gchar *msg;
+	invitation = empathy_tp_group_get_invitation (group, &contact);	
+	if (!invitation) {
+		empathy_debug (DEBUG_DOMAIN, "Process OUTGOING call channel");
+		empathy_filter_process (filter, channel, TRUE);
+	} else {
+		StatusIconEvent *event;
+		gchar           *msg;
 
 		/* We are local pending, it's an incoming call, we need to ask
 		 * the user if he wants to accept the call. */
-		empathy_contact_run_until_ready (member,
+		empathy_contact_run_until_ready (contact,
 						 EMPATHY_CONTACT_READY_NAME,
 						 NULL);
 
 		empathy_debug (DEBUG_DOMAIN, "INCOMING call, add event");
 
 		msg = g_strdup_printf (_("Incoming call from %s:\n%s"),
-				       empathy_contact_get_name (member),
-				       message);
+				       empathy_contact_get_name (contact),
+				       invitation->message);
 
+		g_object_set_data (G_OBJECT (group), "filter", filter);
+		g_object_set_data (G_OBJECT (group), "channel", channel);
 		event = status_icon_event_new (icon, EMPATHY_IMAGE_VOIP, msg);
 		event->func = status_icon_event_call_cb;
 		event->user_data = group;
@@ -413,37 +396,6 @@
 }
 
 static void
-status_icon_call_filter_new_channel (EmpathyFilter     *filter,
-				     TpConn            *tp_conn,
-				     TpChan            *tp_chan,
-				     EmpathyStatusIcon *icon)
-{
-	EmpathyStatusIconPriv *priv;
-	McAccount             *account;
-	EmpathyTpGroup        *group;
-
-	priv = GET_PRIV (icon);
-
-	account = mission_control_get_account_for_connection (priv->mc, tp_conn, NULL);
-
-	empathy_debug (DEBUG_DOMAIN, "New media channel to be filtered");
-
-	/* FIXME: We have to check if the user is member or local-pending to
-	 * know if it's an incoming or outgoing call because of the way we
-	 * request media channels MC can't know if it's incoming or outgoing */
-	group = empathy_tp_group_new (account, tp_chan);
-	g_object_set_data (G_OBJECT (group), "filter", filter);
-	g_object_unref (account);
-
-	g_signal_connect (group, "member-added",
-			  G_CALLBACK (status_icon_call_member_added_cb),
-			  icon);
-	g_signal_connect (group, "local-pending",
-			  G_CALLBACK (status_icon_call_local_pending_cb),
-			  icon);
-}
-
-static void
 status_icon_idle_notify_cb (EmpathyStatusIcon *icon)
 {
 	EmpathyStatusIconPriv *priv;
@@ -745,14 +697,14 @@
 {
 	EmpathyFilter *filter;
 	EmpathyTpChat *tp_chat;
+	TpChannel     *channel;
 
 	empathy_debug (DEBUG_DOMAIN, "Dispatching text channel");
 
 	tp_chat = event->user_data;
 	filter = g_object_get_data (G_OBJECT (tp_chat), "filter");
-	empathy_filter_process (filter,
-				empathy_tp_chat_get_channel (tp_chat),
-				TRUE);
+	channel = g_object_get_data (G_OBJECT (tp_chat), "channel");
+	empathy_filter_process (filter, channel, TRUE);
 
 	g_object_unref (tp_chat);
 }

Modified: trunk/src/empathy.c
==============================================================================
--- trunk/src/empathy.c	(original)
+++ trunk/src/empathy.c	Fri Apr 11 14:11:06 2008
@@ -33,6 +33,8 @@
 #include <libebook/e-book.h>
 
 #include <telepathy-glib/util.h>
+#include <telepathy-glib/channel.h>
+#include <telepathy-glib/connection.h>
 #include <libmissioncontrol/mc-account.h>
 #include <libmissioncontrol/mission-control.h>
 
@@ -58,17 +60,36 @@
 
 static void
 new_text_channel_cb (EmpathyChandler *chandler,
-		     TpConn          *tp_conn,
-		     TpChan          *tp_chan,
+		     TpChannel       *channel,
 		     MissionControl  *mc)
 {
 	EmpathyTpChat *tp_chat;
+	TpConnection  *connection;
+	guint          handle_type;
+	guint          handle;
+	gchar        **names;
 	McAccount     *account;
 	EmpathyChat   *chat;
 	gchar         *id;
+	GArray        *handles;
 
-	account = mission_control_get_account_for_connection (mc, tp_conn, NULL);
-	id = empathy_inspect_channel (account, tp_chan);
+	g_object_get (channel,
+		      "connection", &connection,
+		      "handle-type", &handle_type,
+		      "handle", &handle,
+		      NULL);
+	handles = g_array_new (FALSE, FALSE, sizeof (guint));
+	g_array_append_val (handles, handle);
+	tp_cli_connection_run_inspect_handles (connection, -1,
+					       handle_type, handles,
+					       &names,
+					       NULL, NULL);
+	id = *names;
+	g_free (names);
+	g_object_unref (connection);
+	g_array_free (handles, TRUE);
+
+	account = empathy_channel_get_account (channel);
 	chat = empathy_chat_window_find_chat (account, id);
 	g_free (id);
 
@@ -76,7 +97,8 @@
 		/* The chat already exists */
 		if (!empathy_chat_get_tp_chat (chat)) {
 			/* The chat died, give him the new text channel */
-			tp_chat = empathy_tp_chat_new (account, tp_chan, TRUE);
+			tp_chat = empathy_tp_chat_new (channel, TRUE);
+			empathy_run_until_ready (tp_chat);
 			empathy_chat_set_tp_chat (chat, tp_chat);
 			g_object_unref (tp_chat);
 		}
@@ -86,7 +108,9 @@
 		return;
 	}
 
-	tp_chat = empathy_tp_chat_new (account, tp_chan, TRUE);
+	tp_chat = empathy_tp_chat_new (channel, TRUE);
+	empathy_run_until_ready (tp_chat);
+
 	chat = empathy_chat_new (tp_chat);
 	empathy_chat_window_present_chat (chat);
 



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