]> git.0d.be Git - empathy.git/commitdiff
Only update the topic of it has really be changed, avoid diplaying many
authorXavier Claessens <xclaesse@gmail.com>
Mon, 13 Aug 2007 10:50:49 +0000 (10:50 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Mon, 13 Aug 2007 10:50:49 +0000 (10:50 +0000)
2007-08-13 Xavier Claessens  <xclaesse@gmail.com>

* libempathy-gtk/empathy-group-chat.c: Only update the topic of it has
really be changed, avoid diplaying many times "Topic set to:" message.

* libempathy-gtk/empathy-chat.c: Some Jabber chatroom sends messages
received before we joined the room, this avoid displaying those messages
if we already logged them last time we joined that room. Previous
workaround prevented Empathy to log offline messages.

svn path=/trunk/; revision=255

ChangeLog
libempathy-gtk/empathy-chat.c
libempathy-gtk/empathy-group-chat.c

index 772489d127144b1223f3641f665cf1fad3a0e21b..2bc7fe7c50744a1837ef31033790b01c644c1479 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2007-08-13 Xavier Claessens  <xclaesse@gmail.com>
+
+       * libempathy-gtk/empathy-group-chat.c: Only update the topic of it has
+       really be changed, avoid diplaying many times "Topic set to:" message.
+
+       * libempathy-gtk/empathy-chat.c: Some Jabber chatroom sends messages
+       received before we joined the room, this avoid displaying those messages
+       if we already logged them last time we joined that room. Previous
+       workaround prevented Empathy to log offline messages.
+
 2007-08-12 Xavier Claessens  <xclaesse@gmail.com>
 
        * configure.ac: Bump version to 0.12.
index 304e8d447111f54c3ca1df6b77b388e1c52697eb..9de1caa07370452e3715f57f974000878c69aa66 100644 (file)
@@ -76,7 +76,7 @@ struct _EmpathyChatPriv {
        GList                 *compositors;
        guint                  scroll_idle_id;
        gboolean               first_tp_chat;
-       EmpathyTime             time_joined;
+       EmpathyTime            last_log_timestamp;
        /* Used to automatically shrink a window that has temporarily
         * grown due to long input. 
         */
@@ -406,18 +406,26 @@ chat_message_received_cb (EmpathyTpChat  *tp_chat,
 
        priv = GET_PRIV (chat);
 
+       timestamp = empathy_message_get_timestamp (message);
+       if (timestamp <= priv->last_log_timestamp) {
+               /* Do not take care of messages anterior of the last
+                * logged message. Some Jabber chatroom sends messages
+                * received before we joined the room, this avoid
+                * displaying those messages if we already logged them
+                * last time we joined that room. */
+               empathy_debug (DEBUG_DOMAIN, "Skipping message because it is "
+                              "anterior of last logged message.");
+               return;
+       }
+
        sender = empathy_message_get_sender (message);
        empathy_debug (DEBUG_DOMAIN, "Appending message ('%s')",
                      empathy_contact_get_name (sender));
 
-       /* Log the message only if it's not backlog */
-       timestamp = empathy_message_get_timestamp (message);
-       if (timestamp >= priv->time_joined) {
-               empathy_log_manager_add_message (priv->log_manager,
-                                                empathy_chat_get_id (chat),
-                                                empathy_chat_is_group_chat (chat),
-                                                message);
-       }
+       empathy_log_manager_add_message (priv->log_manager,
+                                        empathy_chat_get_id (chat),
+                                        empathy_chat_is_group_chat (chat),
+                                        message);
 
        empathy_chat_view_append_message (chat->view, message);
 
@@ -1137,11 +1145,6 @@ chat_add_logs (EmpathyChat *chat)
 
        priv = GET_PRIV (chat);
 
-       /* Do not display backlog for chatrooms */
-       if (empathy_chat_is_group_chat (chat)) {
-               return;
-       }
-
        /* Turn off scrolling temporarily */
        empathy_chat_view_scroll (chat->view, FALSE);
 
@@ -1163,8 +1166,9 @@ chat_add_logs (EmpathyChat *chat)
                        continue;
                }
 
-
+               priv->last_log_timestamp = empathy_message_get_timestamp (message);
                empathy_chat_view_append_message (chat->view, message);
+
                g_object_unref (message);
        }
        g_list_free (messages);
@@ -1360,7 +1364,6 @@ empathy_chat_set_tp_chat (EmpathyChat   *chat,
        g_free (priv->id);
        priv->tp_chat = g_object_ref (tp_chat);
        priv->id = g_strdup (empathy_tp_chat_get_id (tp_chat));
-       priv->time_joined = empathy_time_get_current ();
 
        if (priv->first_tp_chat) {
                chat_add_logs (chat);
index 4d62d51b68e412bb04acecf8baceab9e7a34d68c..ca046a3d76848b4025ad2c0518188051c91f3157 100644 (file)
@@ -560,13 +560,18 @@ group_chat_subject_notify_cb (EmpathyTpChat   *tp_chat,
                              EmpathyGroupChat *chat)
 {
        EmpathyGroupChatPriv *priv;
-       gchar               *str;
+       gchar                *str = NULL;
 
        priv = GET_PRIV (chat);
 
-       g_free (priv->topic);
+       g_object_get (priv->tp_chat, "subject", &str, NULL);
+       if (!empathy_strdiff (priv->topic, str)) {
+               g_free (str);
+               return;
+       }
 
-       g_object_get (priv->tp_chat, "subject", &priv->topic, NULL);
+       g_free (priv->topic);
+       priv->topic = str;
        gtk_label_set_text (GTK_LABEL (priv->label_topic), priv->topic);
 
        if (!G_STR_EMPTY (priv->topic)) {