diff options
-rw-r--r-- | libempathy-gtk/empathy-chat.c | 46 | ||||
-rw-r--r-- | libempathy/empathy-tp-chat.c | 10 | ||||
-rw-r--r-- | libempathy/empathy-tp-chat.h | 1 | ||||
-rw-r--r-- | src/empathy-chat-window.c | 12 | ||||
-rw-r--r-- | src/empathy-filter.c | 21 |
5 files changed, 67 insertions, 23 deletions
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c index 85956c812..10bffdfc1 100644 --- a/libempathy-gtk/empathy-chat.c +++ b/libempathy-gtk/empathy-chat.c @@ -191,7 +191,7 @@ chat_status_changed_cb (MissionControl *mc, 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 @@ chat_message_received_cb (EmpathyTpChat *tp_chat, 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 @@ chat_text_populate_popup_cb (GtkTextView *view, 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 @@ chat_remote_contact_changed_cb (EmpathyChat *chat) 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 @@ empathy_chat_set_tp_chat (EmpathyChat *chat, 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", diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c index 7e26e34a7..c53bd1b72 100644 --- a/libempathy/empathy-tp-chat.c +++ b/libempathy/empathy-tp-chat.c @@ -1119,6 +1119,16 @@ empathy_tp_chat_get_account (EmpathyTpChat *chat) 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) { diff --git a/libempathy/empathy-tp-chat.h b/libempathy/empathy-tp-chat.h index a6ac3598b..12cd5cf92 100644 --- a/libempathy/empathy-tp-chat.h +++ b/libempathy/empathy-tp-chat.h @@ -58,6 +58,7 @@ EmpathyTpChat *empathy_tp_chat_new (TpChannel *channel 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, diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c index 09a0e4589..4125f9743 100644 --- a/src/empathy-chat-window.c +++ b/src/empathy-chat-window.c @@ -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 @@ chat_window_clear_activate_cb (GtkWidget *menuitem, 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 @@ empathy_chat_window_find_chat (McAccount *account, 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; } } diff --git a/src/empathy-filter.c b/src/empathy-filter.c index 0b2999b4e..d32a9dfe1 100644 --- a/src/empathy-filter.c +++ b/src/empathy-filter.c @@ -183,13 +183,25 @@ filter_chat_dispatch (EmpathyFilter *filter, 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 @@ filter_chat_handle_channel (EmpathyFilter *filter, 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 { |