empathy r1032 - in trunk: libempathy libempathy-gtk src



Author: xclaesse
Date: Wed Apr 23 13:58:10 2008
New Revision: 1032
URL: http://svn.gnome.org/viewvc/empathy?rev=1032&view=rev

Log:
Make sure we don't assume Text channel's handle_type is != NONE.


Modified:
   trunk/libempathy-gtk/empathy-chat.c
   trunk/libempathy/empathy-tp-chat.c
   trunk/libempathy/empathy-tp-chat.h
   trunk/src/empathy-chat-window.c
   trunk/src/empathy-filter.c

Modified: trunk/libempathy-gtk/empathy-chat.c
==============================================================================
--- trunk/libempathy-gtk/empathy-chat.c	(original)
+++ trunk/libempathy-gtk/empathy-chat.c	Wed Apr 23 13:58:10 2008
@@ -191,7 +191,7 @@
 
 	if (status == TP_CONNECTION_STATUS_CONNECTED && !priv->tp_chat &&
 	    empathy_account_equal (account, priv->account) &&
-	    priv->handle_type != 0) {
+	    priv->handle_type != TP_HANDLE_TYPE_NONE) {
 		empathy_debug (DEBUG_DOMAIN,
 			       "Account reconnected, request a new Text channel");
 		mission_control_request_channel_with_string_handle (mc,
@@ -529,10 +529,14 @@
 		       empathy_contact_get_name (sender),
 		       empathy_contact_get_handle (sender));
 
-	empathy_log_manager_add_message (priv->log_manager,
-					 empathy_chat_get_id (chat),
-					 FALSE,
-					 message);
+	if (priv->id) {
+		gboolean is_chatroom;
+
+		is_chatroom = priv->handle_type == TP_HANDLE_TYPE_ROOM;
+		empathy_log_manager_add_message (priv->log_manager,
+						 priv->id, is_chatroom,
+						 message);
+	}
 
 	empathy_chat_view_append_message (chat->view, message);
 
@@ -1168,21 +1172,25 @@
 static void
 chat_add_logs (EmpathyChat *chat)
 {
-	EmpathyChatPriv *priv;
-	GList          *messages, *l;
-	guint           num_messages;
-	guint           i;
+	EmpathyChatPriv *priv = GET_PRIV (chat);
+	gboolean         is_chatroom;
+	GList           *messages, *l;
+	guint            num_messages;
+	guint            i;
 
-	priv = GET_PRIV (chat);
+	if (!priv->id) {
+		return;
+	}
 
 	/* Turn off scrolling temporarily */
 	empathy_chat_view_scroll (chat->view, FALSE);
 
 	/* Add messages from last conversation */
+	is_chatroom = priv->handle_type == TP_HANDLE_TYPE_ROOM;
 	messages = empathy_log_manager_get_last_messages (priv->log_manager,
 							  priv->account,
-							  empathy_chat_get_id (chat),
-							  FALSE);
+							  priv->id,
+							  is_chatroom);
 	num_messages  = g_list_length (messages);
 
 	/* Only keep the 10 last messages */
@@ -1319,11 +1327,23 @@
 	priv->remote_contact = empathy_tp_chat_get_remote_contact (priv->tp_chat);
 	if (priv->remote_contact) {
 		g_object_ref (priv->remote_contact);
+		priv->handle_type = TP_HANDLE_TYPE_CONTACT;
+		g_free (priv->id);
+		priv->id = g_strdup (empathy_contact_get_id (priv->remote_contact));
+	}
+	else if (priv->tp_chat) {
+		TpChannel *channel;
+
+		channel = empathy_tp_chat_get_channel (priv->tp_chat);
+		g_object_get (channel, "handle-type", &priv->handle_type, NULL);
+		g_free (priv->id);
+		priv->id = g_strdup (empathy_tp_chat_get_id (priv->tp_chat));
 	}
 
 	chat_set_show_contacts (chat, priv->remote_contact == NULL);
 
 	g_object_notify (G_OBJECT (chat), "remote-contact");
+	g_object_notify (G_OBJECT (chat), "id");
 }
 
 static void
@@ -1678,10 +1698,8 @@
 	if (priv->account) {
 		g_object_unref (priv->account);
 	}
-	g_free (priv->id);
 
 	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));
 
 	g_signal_connect (tp_chat, "message-received",

Modified: trunk/libempathy/empathy-tp-chat.c
==============================================================================
--- trunk/libempathy/empathy-tp-chat.c	(original)
+++ trunk/libempathy/empathy-tp-chat.c	Wed Apr 23 13:58:10 2008
@@ -1119,6 +1119,16 @@
 	return priv->account;
 }
 
+TpChannel *
+empathy_tp_chat_get_channel (EmpathyTpChat *chat)
+{
+	EmpathyTpChatPriv *priv = GET_PRIV (chat);
+
+	g_return_val_if_fail (EMPATHY_IS_TP_CHAT (chat), NULL);
+
+	return priv->channel;
+}
+
 gboolean
 empathy_tp_chat_is_ready (EmpathyTpChat *chat)
 {

Modified: trunk/libempathy/empathy-tp-chat.h
==============================================================================
--- trunk/libempathy/empathy-tp-chat.h	(original)
+++ trunk/libempathy/empathy-tp-chat.h	Wed Apr 23 13:58:10 2008
@@ -58,6 +58,7 @@
 const gchar *  empathy_tp_chat_get_id               (EmpathyTpChat      *chat);
 EmpathyContact*empathy_tp_chat_get_remote_contact   (EmpathyTpChat      *chat);
 McAccount *    empathy_tp_chat_get_account          (EmpathyTpChat      *chat);
+TpChannel *    empathy_tp_chat_get_channel          (EmpathyTpChat      *chat);
 gboolean       empathy_tp_chat_is_ready             (EmpathyTpChat      *chat);
 guint          empathy_tp_chat_get_members_count    (EmpathyTpChat      *chat);
 void           empathy_tp_chat_set_acknowledge      (EmpathyTpChat      *chat,

Modified: trunk/src/empathy-chat-window.c
==============================================================================
--- trunk/src/empathy-chat-window.c	(original)
+++ trunk/src/empathy-chat-window.c	Wed Apr 23 13:58:10 2008
@@ -34,6 +34,7 @@
 #include <glade/glade.h>
 #include <glib/gi18n.h>
 
+#include <telepathy-glib/util.h>
 #include <libmissioncontrol/mission-control.h>
 
 #include <libempathy/empathy-contact-factory.h>
@@ -470,17 +471,18 @@
 static const gchar *
 chat_get_window_id_for_geometry (EmpathyChat *chat)
 {
-	gboolean separate_windows;
+	const gchar *res = NULL;
+	gboolean     separate_windows;
 
 	empathy_conf_get_bool (empathy_conf_get (),
 			       EMPATHY_PREFS_UI_SEPARATE_CHAT_WINDOWS,
 			       &separate_windows);
 
 	if (separate_windows) {
-		return empathy_chat_get_id (chat);
-	} else {
-		return "chat-window";
+		res = empathy_chat_get_id (chat);
 	}
+
+	return res ? res : "chat-window";
 }
 
 static gboolean
@@ -1455,7 +1457,7 @@
 			chat = ll->data;
 
 			if (empathy_account_equal (account, empathy_chat_get_account (chat)) &&
-			    strcmp (id, empathy_chat_get_id (chat)) == 0) {
+			    !tp_strdiff (id, empathy_chat_get_id (chat))) {
 				return chat;
 			}
 		}

Modified: trunk/src/empathy-filter.c
==============================================================================
--- trunk/src/empathy-filter.c	(original)
+++ trunk/src/empathy-filter.c	Wed Apr 23 13:58:10 2008
@@ -183,13 +183,25 @@
 		      gpointer       user_data)
 {
 	EmpathyTpChat *tp_chat = EMPATHY_TP_CHAT (user_data);
-	McAccount     *account;
-	EmpathyChat   *chat;
+	EmpathyChat   *chat = NULL;
 	const gchar   *id;
 
 	id = empathy_tp_chat_get_id (tp_chat);
-	account = empathy_tp_chat_get_account (tp_chat);
-	chat = empathy_chat_window_find_chat (account, id);
+	if (!id) {
+		EmpathyContact *contact;
+
+		contact = empathy_tp_chat_get_remote_contact (tp_chat);
+		if (contact) {
+			id = empathy_contact_get_id (contact);
+		}
+	}
+
+	if (id) {
+		McAccount *account;
+
+		account = empathy_tp_chat_get_account (tp_chat);
+		chat = empathy_chat_window_find_chat (account, id);
+	}
 
 	if (chat) {
 		empathy_chat_set_tp_chat (chat, tp_chat);
@@ -235,6 +247,7 @@
 		       channel);
 
 	tp_chat = empathy_tp_chat_new (channel, FALSE);
+	empathy_run_until_ready (tp_chat);
 	if (is_incoming) {
 		filter_chat_dispatch (filter, tp_chat);
 	} else {



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