[evolution-data-server] Do not update unread count in source folder for junk/deleted messages



commit 9aa4388613db1dadd48c00a364120e84fe141091
Author: Milan Crha <mcrha redhat com>
Date:   Thu Aug 9 19:21:15 2012 +0200

    Do not update unread count in source folder for junk/deleted messages

 camel/camel-folder-summary.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c
index 6c11f88..4fc3e29 100644
--- a/camel/camel-folder-summary.c
+++ b/camel/camel-folder-summary.c
@@ -881,6 +881,7 @@ camel_folder_summary_replace_flags (CamelFolderSummary *summary,
                                     CamelMessageInfo *info)
 {
 	guint32 old_flags, new_flags, added_flags, removed_flags;
+	gboolean is_junk_folder = FALSE, is_trash_folder = FALSE;
 	GObject *summary_object;
 	gboolean changed = FALSE;
 
@@ -905,6 +906,13 @@ camel_folder_summary_replace_flags (CamelFolderSummary *summary,
 		return FALSE;
 	}
 
+	if (summary->priv->folder && CAMEL_IS_VTRASH_FOLDER (summary->priv->folder)) {
+		CamelVTrashFolder *vtrash = CAMEL_VTRASH_FOLDER (summary->priv->folder);
+
+		is_junk_folder = vtrash && vtrash->type == CAMEL_VTRASH_FOLDER_JUNK;
+		is_trash_folder = vtrash && vtrash->type == CAMEL_VTRASH_FOLDER_TRASH;
+	}
+
 	added_flags = new_flags & (~(old_flags & new_flags));
 	removed_flags = old_flags & (~(old_flags & new_flags));
 
@@ -915,6 +923,15 @@ camel_folder_summary_replace_flags (CamelFolderSummary *summary,
 		 * on unread counts */
 		added_flags |= CAMEL_MESSAGE_SEEN;
 		removed_flags |= CAMEL_MESSAGE_SEEN;
+	} else if ((!is_junk_folder && (new_flags & CAMEL_MESSAGE_JUNK) != 0 &&
+		   (old_flags & CAMEL_MESSAGE_JUNK) == (new_flags & CAMEL_MESSAGE_JUNK)) ||
+		   (!is_trash_folder && (new_flags & CAMEL_MESSAGE_DELETED) != 0 &&
+		   (old_flags & CAMEL_MESSAGE_DELETED) == (new_flags & CAMEL_MESSAGE_DELETED))) {
+		/* The message was set read or unread, but it is a junk or deleted message,
+		 * in a non-Junk/non-Trash folder, thus it doesn't influence an unread count
+		 * there, thus pretend unread didn't change */
+		added_flags |= CAMEL_MESSAGE_SEEN;
+		removed_flags |= CAMEL_MESSAGE_SEEN;
 	}
 
 	/* decrement counts with removed flags */



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