[empathy: 2/3] Remove duplicate and buggy bookkeeping of pending messages



commit c4bd37aa901a9cd8c6cc716508416daa6ae58fbc
Author: Sjoerd Simons <sjoerd simons collabora co uk>
Date:   Mon Feb 15 23:28:57 2010 +0000

    Remove duplicate and buggy bookkeeping of pending messages

 libempathy-gtk/empathy-chat.c |   21 +++++++--------------
 1 files changed, 7 insertions(+), 14 deletions(-)
---
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index 4594d4d..0b8460f 100644
--- a/libempathy-gtk/empathy-chat.c
+++ b/libempathy-gtk/empathy-chat.c
@@ -96,7 +96,7 @@ typedef struct {
 	GtkWidget         *info_bar_vbox;
 	GtkWidget         *search_bar;
 
-	GSList            *pending_messages;
+	guint              unread_messages;
 	/* TRUE if the pending messages can be displayed. This is to avoid to show
 	 * pending messages *before* messages from logs. (#603980) */
 	gboolean           can_show_pending;
@@ -1116,9 +1116,7 @@ chat_message_received (EmpathyChat *chat, EmpathyMessage *message)
 			       TP_CHANNEL_CHAT_STATE_ACTIVE,
 			       chat);
 
-	priv->pending_messages = g_slist_prepend (priv->pending_messages,
-			g_object_ref (message));
-
+	priv->unread_messages++;
 	g_signal_emit (chat, signals[NEW_MESSAGE], 0, message);
 }
 
@@ -2934,9 +2932,9 @@ empathy_chat_get_nb_unread_messages (EmpathyChat *self)
 {
 	EmpathyChatPriv *priv = GET_PRIV (self);
 
-	g_return_val_if_fail (EMPATHY_IS_CHAT (self), FALSE);
+	g_return_val_if_fail (EMPATHY_IS_CHAT (self), 0);
 
-	return g_slist_length (priv->pending_messages);
+	return priv->unread_messages;
 }
 
 /* called when the messages have been read by user */
@@ -2948,13 +2946,8 @@ empathy_chat_messages_read (EmpathyChat *self)
 	g_return_if_fail (EMPATHY_IS_CHAT (self));
 
 	if (priv->tp_chat != NULL) {
-		empathy_tp_chat_acknowledge_messages (priv->tp_chat,
-			priv->pending_messages);
+		empathy_tp_chat_acknowledge_all_messages (priv->tp_chat);
 	}
-	/* ...else, we can't do any acknowledging because the channel (or
-	 * indeed connection) has gone away. */
-
-	g_slist_foreach (priv->pending_messages, (GFunc) g_object_unref, NULL);
-	g_slist_free (priv->pending_messages);
-	priv->pending_messages = NULL;
+	
+	priv->unread_messages = 0;
 }



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