evolution-data-server r9669 - branches/gnome-2-24/camel
- From: sragavan svn gnome org
- To: svn-commits-list gnome org
- Subject: evolution-data-server r9669 - branches/gnome-2-24/camel
- Date: Tue, 14 Oct 2008 18:33:54 +0000 (UTC)
Author: sragavan
Date: Tue Oct 14 18:33:54 2008
New Revision: 9669
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=9669&view=rev
Log:
2008-10-14 Srinivasa Ragavan <sragavan novell com>
** Fix for bug #546637
* camel/camel-vee-folder.c:
* camel/camel-vee-folder.h:
* camel/camel-vee-summary.c: Redo for unread vfolder.
* camel/camel-vee-summary.h:
Modified:
branches/gnome-2-24/camel/ChangeLog
branches/gnome-2-24/camel/camel-vee-folder.c
branches/gnome-2-24/camel/camel-vee-folder.h
branches/gnome-2-24/camel/camel-vee-summary.c
branches/gnome-2-24/camel/camel-vee-summary.h
Modified: branches/gnome-2-24/camel/camel-vee-folder.c
==============================================================================
--- branches/gnome-2-24/camel/camel-vee-folder.c (original)
+++ branches/gnome-2-24/camel/camel-vee-folder.c Tue Oct 14 18:33:54 2008
@@ -535,7 +535,13 @@
record->junk_count = s->junk_count;
record->deleted_count = s->deleted_count;
record->unread_count = s->unread_count;
- record->visible_count = s->visible_count;
+
+ if (((CamelVeeSummary *)s)->fake_visible_count)
+ record->visible_count = ((CamelVeeSummary *)s)->fake_visible_count;
+ else
+ record->visible_count = s->visible_count;
+ ((CamelVeeSummary *)s)->fake_visible_count = 0;
+
record->jnd_count = s->junk_not_deleted_count;
} else {
/* Either first time, or by force we search the count */
@@ -562,7 +568,11 @@
CamelVeeFolder *vf = (CamelVeeFolder *)folder;
struct _CamelVeeFolderPrivate *p = _PRIVATE(vf);
GList *node;
-
+
+ if (((CamelVeeSummary *)folder->summary)->fake_visible_count)
+ folder->summary->visible_count = ((CamelVeeSummary *)folder->summary)->fake_visible_count;
+ ((CamelVeeSummary *)folder->summary)->fake_visible_count = 0;
+
CAMEL_VEE_FOLDER_LOCK(vf, subfolder_lock);
node = p->folders;
@@ -2112,6 +2122,20 @@
p->changed_lock = g_mutex_new();
}
+void
+camel_vee_folder_mask_event_folder_changed (CamelVeeFolder *vf, CamelFolder *sub)
+{
+ camel_object_unhook_event((CamelObject *)sub, "folder_changed", (CamelObjectEventHookFunc) folder_changed, vf);
+
+}
+
+void
+camel_vee_folder_unmask_event_folder_changed (CamelVeeFolder *vf, CamelFolder *sub)
+{
+ camel_object_hook_event((CamelObject *)sub, "folder_changed", (CamelObjectEventHookFunc) folder_changed, vf);
+}
+
+
static void
vee_folder_stop_folder(CamelVeeFolder *vf, CamelFolder *sub)
{
@@ -2190,10 +2214,15 @@
camel_vee_folder_sync_headers (CamelFolder *vf, CamelException *ex)
{
CamelFIRecord * record;
+ time_t start, end;
/* Save the counts to DB */
+ start = time(NULL);
record = summary_header_to_db (vf->summary, ex);
camel_db_write_folder_info_record (vf->parent_store->cdb_w, record, ex);
+ end = time(NULL);
+ dd(printf("Sync for vfolder '%s': %ld secs\n", vf->full_name, end-start));
+
g_free (record);
}
Modified: branches/gnome-2-24/camel/camel-vee-folder.h
==============================================================================
--- branches/gnome-2-24/camel/camel-vee-folder.h (original)
+++ branches/gnome-2-24/camel/camel-vee-folder.h Tue Oct 14 18:33:54 2008
@@ -87,6 +87,9 @@
int camel_vee_folder_rebuild_folder(CamelVeeFolder *vf, CamelFolder *sub, CamelException *ex);
void camel_vee_folder_set_expression (CamelVeeFolder *vf, const char *expr);
+void camel_vee_folder_mask_event_folder_changed (CamelVeeFolder *vf, CamelFolder *sub);
+void camel_vee_folder_unmask_event_folder_changed (CamelVeeFolder *vf, CamelFolder *sub);
+
void camel_vee_folder_hash_folder (CamelFolder *folder, char buffer[8]);
void camel_vee_folder_sync_headers (CamelFolder *vf, CamelException *ex);
Modified: branches/gnome-2-24/camel/camel-vee-summary.c
==============================================================================
--- branches/gnome-2-24/camel/camel-vee-summary.c (original)
+++ branches/gnome-2-24/camel/camel-vee-summary.c Tue Oct 14 18:33:54 2008
@@ -34,12 +34,14 @@
#include "camel-store.h"
#include "camel-vee-summary.h"
#include "camel-vee-folder.h"
+#include "camel-vee-store.h"
#include "camel-private.h"
#include "camel-string-utils.h"
#define d(x)
static CamelFolderSummaryClass *camel_vee_summary_parent;
+const char *unread_str = " (and\n \n (match-all (not (system-flag \"Seen\")))\n \n )\n";
static void
vee_message_info_free(CamelFolderSummary *s, CamelMessageInfo *info)
@@ -172,11 +174,26 @@
vee_info_set_flags(CamelMessageInfo *mi, guint32 flags, guint32 set)
{
int res = FALSE;
+ CamelVeeFolder *vf = (CamelVeeFolder *)mi->summary->folder;
+ const char *exp = g_getenv("CAMEL_VFOLDER_UNREAD_EXP");
+ gboolean hacked_unread_folder = FALSE;
+
+ /* HACK: Ugliest of all hacks. Its virtually not possible now
+ * to maintain counts and the non matching uids of unread vfolder here.
+ * So, I hardcode unread vfolder expression and hack it. */
+ if (!exp || !*exp)
+ exp = unread_str;
+ if (camel_debug("vfolderexp"))
+ printf("Expression for vfolder '%s' is '%s'\n", mi->summary->folder->full_name, g_strescape(vf->expression, ""));
+
+ if (strstr(exp, vf->expression) && (vf->flags & CAMEL_STORE_VEE_FOLDER_SPECIAL) == 0)
+ 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;
CamelMessageInfo *rmi = camel_folder_summary_uid (((CamelVeeMessageInfo *)mi)->summary, mi->uid+8);
+ CamelVeeSummary *vsummary = (CamelVeeSummary *)mi->summary;
HANDLE_NULL_INFO(FALSE);
camel_object_get(rmi->summary->folder, NULL,
@@ -184,18 +201,28 @@
CAMEL_FOLDER_VISIBLE, &old_visible,
CAMEL_FOLDER_JUNKED, &old_junked,
CAMEL_FOLDER_JUNKED_NOT_DELETED, &old_junked_not_deleted,
- CAMEL_FOLDER_UNREAD, &old_unread, NULL);
+ CAMEL_FOLDER_UNREAD, &old_unread, NULL);
+
+ if (hacked_unread_folder)
+ camel_vee_folder_mask_event_folder_changed ((CamelVeeFolder *)mi->summary->folder, rmi->summary->folder);
+
camel_folder_freeze(rmi->summary->folder);
res = camel_message_info_set_flags(rmi, flags, set);
((CamelVeeMessageInfo *) mi)->old_flags = camel_message_info_flags (rmi);
camel_folder_thaw(rmi->summary->folder);
-
+
+ if (hacked_unread_folder)
+ camel_vee_folder_unmask_event_folder_changed ((CamelVeeFolder *)mi->summary->folder, rmi->summary->folder);
+
camel_object_get(rmi->summary->folder, NULL,
CAMEL_FOLDER_DELETED, &deleted,
CAMEL_FOLDER_VISIBLE, &visible,
CAMEL_FOLDER_JUNKED, &junked,
CAMEL_FOLDER_JUNKED_NOT_DELETED, &junked_not_deleted,
CAMEL_FOLDER_UNREAD, &unread, NULL);
+ 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;
@@ -203,7 +230,35 @@
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) {
+ CamelFolderChangeInfo *changes = camel_folder_change_info_new();
+ GPtrArray *match, *array;
+
+ camel_folder_change_info_change_uid(changes, mi->uid);
+
+ array = g_ptr_array_new ();
+ g_ptr_array_add (array, (gpointer)rmi->uid);
+
+ match = camel_folder_search_by_uids (rmi->summary->folder, vf->expression, array, NULL);
+ if ((match && !match->len) || !match) {
+ vsummary->fake_visible_count--;
+ } else {
+ vsummary->fake_visible_count++;
+ }
+
+ g_ptr_array_free (array, TRUE);
+ if (match)
+ camel_folder_search_free(rmi->summary->folder, match);
+
+ camel_object_trigger_event(mi->summary->folder, "folder_changed", changes);
+ camel_folder_change_info_free(changes);
+ }
camel_message_info_free (rmi);
}
@@ -329,6 +384,7 @@
s = (CamelVeeSummary *)camel_object_new(camel_vee_summary_get_type());
s->summary.folder = parent;
s->force_counts = FALSE;
+ s->fake_visible_count = 0;
/* FIXME[disk-summary] fix exceptions and note return values */
/* FIXME[disk-summary] if Evo's junk/trash vfolders make it VJunk
Modified: branches/gnome-2-24/camel/camel-vee-summary.h
==============================================================================
--- branches/gnome-2-24/camel/camel-vee-summary.h (original)
+++ branches/gnome-2-24/camel/camel-vee-summary.h Tue Oct 14 18:33:54 2008
@@ -49,6 +49,7 @@
struct _CamelVeeSummary {
CamelFolderSummary summary;
gboolean force_counts;
+ guint32 fake_visible_count;
};
struct _CamelVeeSummaryClass {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]