[empathy: 1/2] Fallback to the contact id if present when there is no room id for empathy_tp_chat



commit 1ca52da13f25b623adb55127aee61c6ea2f68bea
Author: Olivier Le Thanh Duong <olivier lethanh be>
Date:   Sun Sep 20 18:42:20 2009 +0200

    Fallback to the contact id if present when there is no room id for empathy_tp_chat

 libempathy-gtk/empathy-chat.c |    7 +++----
 libempathy/empathy-tp-chat.c  |   11 ++++++++++-
 src/empathy.c                 |   11 +----------
 3 files changed, 14 insertions(+), 15 deletions(-)
---
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index c08b49c..ea6b40e 100644
--- a/libempathy-gtk/empathy-chat.c
+++ b/libempathy-gtk/empathy-chat.c
@@ -1325,20 +1325,19 @@ chat_remote_contact_changed_cb (EmpathyChat *chat)
 		priv->remote_contact = NULL;
 	}
 
+	g_free (priv->id);
+
+	priv->id = g_strdup (empathy_tp_chat_get_id (priv->tp_chat));
 	priv->remote_contact = empathy_tp_chat_get_remote_contact (priv->tp_chat);
 	if (priv->remote_contact != NULL) {
 		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 != NULL) {
 		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_update_contacts_visibility (chat);
diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c
index a8b0eeb..28b9707 100644
--- a/libempathy/empathy-tp-chat.c
+++ b/libempathy/empathy-tp-chat.c
@@ -1251,10 +1251,19 @@ const gchar *
 empathy_tp_chat_get_id (EmpathyTpChat *chat)
 {
 	EmpathyTpChatPriv *priv = GET_PRIV (chat);
+	const gchar *id;
+
 
 	g_return_val_if_fail (EMPATHY_IS_TP_CHAT (chat), NULL);
 
-	return tp_channel_get_identifier (priv->channel);
+	id = tp_channel_get_identifier (priv->channel);
+	if (!EMP_STR_EMPTY (id))
+		return id;
+	else if (priv->remote_contact)
+		return empathy_contact_get_id (priv->remote_contact);
+	else
+		return NULL;
+
 }
 
 EmpathyContact *
diff --git a/src/empathy.c b/src/empathy.c
index 8a2f107..d1c44da 100644
--- a/src/empathy.c
+++ b/src/empathy.c
@@ -100,16 +100,7 @@ dispatch_cb (EmpathyDispatcher *dispatcher,
         (empathy_dispatch_operation_get_channel_wrapper (operation));
 
       id = empathy_tp_chat_get_id (tp_chat);
-      if (!id)
-        {
-          EmpathyContact *contact;
-
-          contact = empathy_tp_chat_get_remote_contact (tp_chat);
-          if (contact)
-            id = empathy_contact_get_id (contact);
-        }
-
-      if (id)
+      if (!EMP_STR_EMPTY (id))
         {
           EmpathyAccountManager *manager;
           TpConnection *connection;



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