[evolution-data-server/gnome-2-32] Bug #635339 - 'Mark as read' from popup menu not working on Junk folder
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/gnome-2-32] Bug #635339 - 'Mark as read' from popup menu not working on Junk folder
- Date: Fri, 21 Jan 2011 14:14:52 +0000 (UTC)
commit ff2a3874a379ae3071b40858d096c6633a093e3c
Author: Milan Crha <mcrha redhat com>
Date: Fri Jan 21 15:14:28 2011 +0100
Bug #635339 - 'Mark as read' from popup menu not working on Junk folder
camel/camel-folder-summary.c | 21 ++++++++++++++++++---
camel/camel-store.c | 21 +++++++++++++++++++++
camel/camel-vee-summary.c | 25 +++++++------------------
3 files changed, 46 insertions(+), 21 deletions(-)
---
diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c
index 6b460a9..5667e11 100644
--- a/camel/camel-folder-summary.c
+++ b/camel/camel-folder-summary.c
@@ -56,6 +56,7 @@
#include "camel-string-utils.h"
#include "camel-store.h"
#include "camel-vee-folder.h"
+#include "camel-vtrash-folder.h"
#include "camel-mime-part-utils.h"
#define CAMEL_FOLDER_SUMMARY_GET_PRIVATE(obj) \
@@ -850,7 +851,7 @@ info_set_flags(CamelMessageInfo *info, guint32 flags, guint32 set)
else if ((mi->flags & CAMEL_MESSAGE_JUNK) && deleted)
mi->summary->junk_not_deleted_count -= deleted;
- if (((junk && !(mi->flags & CAMEL_MESSAGE_DELETED)))|| (deleted && !(mi->flags & CAMEL_MESSAGE_JUNK)) )
+ if (((junk && !(mi->flags & CAMEL_MESSAGE_DELETED))) || (deleted && !(mi->flags & CAMEL_MESSAGE_JUNK)))
mi->summary->visible_count -= junk ? junk : deleted;
}
if (mi->uid)
@@ -2492,9 +2493,17 @@ void
camel_folder_summary_update_counts_by_flags (CamelFolderSummary *summary, guint32 flags, gboolean subtract)
{
gint unread=0, deleted=0, junk=0;
+ gboolean is_junk_folder = FALSE, is_trash_folder = FALSE;
g_return_if_fail (summary != NULL);
+ if (summary->folder && CAMEL_IS_VTRASH_FOLDER (summary->folder)) {
+ CamelVTrashFolder *vtrash = CAMEL_VTRASH_FOLDER (summary->folder);
+
+ is_junk_folder = vtrash && vtrash->type == CAMEL_VTRASH_FOLDER_JUNK;
+ is_trash_folder = vtrash && vtrash->type == CAMEL_VTRASH_FOLDER_TRASH;
+ }
+
if (!(flags & CAMEL_MESSAGE_SEEN))
unread = subtract ? -1 : 1;
@@ -2506,8 +2515,6 @@ camel_folder_summary_update_counts_by_flags (CamelFolderSummary *summary, guint3
dd(printf("%p: %d %d %d | %d %d %d \n", (gpointer) summary, unread, deleted, junk, summary->unread_count, summary->visible_count, summary->saved_count));
- if (unread)
- summary->unread_count += unread;
if (deleted)
summary->deleted_count += deleted;
if (junk)
@@ -2517,6 +2524,14 @@ camel_folder_summary_update_counts_by_flags (CamelFolderSummary *summary, guint3
if (!junk && !deleted)
summary->visible_count += subtract ? -1 : 1;
+ if (junk && !is_junk_folder)
+ unread = 0;
+ if (deleted && !is_trash_folder)
+ unread = 0;
+
+ if (unread)
+ summary->unread_count += unread;
+
summary->saved_count += subtract ? -1 : 1;
camel_folder_summary_touch (summary);
diff --git a/camel/camel-store.c b/camel/camel-store.c
index c9c5e73..e30fa1d 100644
--- a/camel/camel-store.c
+++ b/camel/camel-store.c
@@ -1130,6 +1130,27 @@ camel_store_get_folder_info (CamelStore *store,
if (info->uri && (store->flags & CAMEL_STORE_VJUNK))
/* the name of the Junk folder, used for spam messages */
add_special_info (store, info, CAMEL_VJUNK_NAME, _("Junk"), TRUE, CAMEL_FOLDER_VIRTUAL|CAMEL_FOLDER_SYSTEM|CAMEL_FOLDER_VTRASH|CAMEL_FOLDER_TYPE_JUNK);
+ } else if (!info && top && (flags & CAMEL_STORE_FOLDER_INFO_NO_VIRTUAL) == 0) {
+ CamelFolderInfo *root_info = NULL;
+
+ if ((store->flags & CAMEL_STORE_VTRASH) != 0 && g_str_equal (top, CAMEL_VTRASH_NAME)) {
+ root_info = class->get_folder_info (store, NULL, flags & (~CAMEL_STORE_FOLDER_INFO_RECURSIVE), error);
+ if (root_info && root_info->uri)
+ add_special_info (store, root_info, CAMEL_VTRASH_NAME, _("Trash"), FALSE, CAMEL_FOLDER_VIRTUAL|CAMEL_FOLDER_SYSTEM|CAMEL_FOLDER_VTRASH|CAMEL_FOLDER_TYPE_TRASH);
+ } else if ((store->flags & CAMEL_STORE_VJUNK) != 0 && g_str_equal (top, CAMEL_VJUNK_NAME)) {
+ root_info = class->get_folder_info (store, NULL, flags & (~CAMEL_STORE_FOLDER_INFO_RECURSIVE), error);
+ if (root_info && root_info->uri)
+ add_special_info (store, root_info, CAMEL_VJUNK_NAME, _("Junk"), TRUE, CAMEL_FOLDER_VIRTUAL|CAMEL_FOLDER_SYSTEM|CAMEL_FOLDER_VTRASH|CAMEL_FOLDER_TYPE_JUNK);
+ }
+
+ if (root_info) {
+ info = root_info->next;
+ root_info->next = NULL;
+ info->next = NULL;
+ info->parent = NULL;
+
+ camel_store_free_folder_info (store, root_info);
+ }
}
if (camel_debug_start("store:folder_info")) {
diff --git a/camel/camel-vee-summary.c b/camel/camel-vee-summary.c
index 5974ed0..9433fa4 100644
--- a/camel/camel-vee-summary.c
+++ b/camel/camel-vee-summary.c
@@ -247,18 +247,15 @@ vee_info_set_flags(CamelMessageInfo *mi, guint32 flags, guint32 set)
hacked_unread_folder = TRUE;
if (mi->uid) {
- guint32 old_visible, old_unread, old_deleted, old_junked, old_junked_not_deleted;
- guint32 visible, unread, deleted, junked, junked_not_deleted;
+ guint32 old_visible, visible, old_unread;
CamelMessageInfo *rmi = camel_folder_summary_uid (((CamelVeeMessageInfo *)mi)->summary, mi->uid+8);
CamelVeeSummary *vsummary = (CamelVeeSummary *)mi->summary;
HANDLE_NULL_INFO(FALSE);
- old_unread = rmi->summary->unread_count;
- old_deleted = rmi->summary->deleted_count;
- old_junked = rmi->summary->junk_count;
- old_junked_not_deleted = rmi->summary->junk_not_deleted_count;
old_visible = rmi->summary->visible_count;
+ old_unread = mi->summary->unread_count;
+ camel_folder_summary_update_counts_by_flags (mi->summary, camel_message_info_flags (rmi), TRUE);
if (hacked_unread_folder)
camel_vee_folder_mask_event_folder_changed ((CamelVeeFolder *)mi->summary->folder, rmi->summary->folder);
@@ -271,29 +268,21 @@ vee_info_set_flags(CamelMessageInfo *mi, guint32 flags, guint32 set)
if (hacked_unread_folder)
camel_vee_folder_unmask_event_folder_changed ((CamelVeeFolder *)mi->summary->folder, rmi->summary->folder);
- unread = rmi->summary->unread_count;
- deleted = rmi->summary->deleted_count;
- junked = rmi->summary->junk_count;
- junked_not_deleted = rmi->summary->junk_not_deleted_count;
visible = rmi->summary->visible_count;
+ /* Keep the summary in sync */
+ camel_folder_summary_update_counts_by_flags (mi->summary, camel_message_info_flags (rmi), FALSE);
+
if (hacked_unread_folder && !vsummary->fake_visible_count)
vsummary->fake_visible_count = mi->summary->visible_count;
- /* Keep the summary in sync */
- mi->summary->unread_count += unread - old_unread;
- mi->summary->deleted_count += deleted - old_deleted;
- mi->summary->junk_count += junked - old_junked;
- mi->summary->junk_not_deleted_count += junked_not_deleted - old_junked_not_deleted;
- mi->summary->visible_count += visible - old_visible;
-
if (vsummary->fake_visible_count || hacked_unread_folder)
vsummary->fake_visible_count += visible - old_visible;
d(printf("VF %d %d %d %d %d\n", mi->summary->unread_count, mi->summary->deleted_count, mi->summary->junk_count, mi->summary->junk_not_deleted_count, mi->summary->visible_count));
/* This is where the ugly-created-hack is used */
- if (hacked_unread_folder && unread - old_unread != 0) {
+ if (hacked_unread_folder && mi->summary->unread_count - old_unread != 0) {
CamelFolderChangeInfo *changes = camel_folder_change_info_new();
GPtrArray *match, *array;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]