evolution-data-server r9829 - branches/gnome-2-24/camel
- From: sragavan svn gnome org
- To: svn-commits-list gnome org
- Subject: evolution-data-server r9829 - branches/gnome-2-24/camel
- Date: Mon, 15 Dec 2008 06:34:21 +0000 (UTC)
Author: sragavan
Date: Mon Dec 15 06:34:21 2008
New Revision: 9829
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=9829&view=rev
Log:
2008-12-15 Srinivasa Ragavan <sragavan novell com>
** Fix for bug #558926 and #546637
* camel/camel-vee-folder.c:
* camel/camel-vee-summary.c:
* camel/camel-vtrash-folder.c:
Modified:
branches/gnome-2-24/camel/ChangeLog
branches/gnome-2-24/camel/camel-vee-folder.c
branches/gnome-2-24/camel/camel-vee-summary.c
branches/gnome-2-24/camel/camel-vtrash-folder.c
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 Mon Dec 15 06:34:21 2008
@@ -150,7 +150,7 @@
camel_vee_folder_construct(vf, parent_store, full, name, flags);
}
- d(printf("returning folder %s %p, count = %d\n", name, vf, camel_folder_get_message_count((CamelFolder *)vf)));
+ d(printf("returning folder %s %p, count = %d\n", full, vf, camel_folder_get_message_count((CamelFolder *)vf)));
if (vf) {
tmp = g_strdup_printf("%s/%s.cmeta", ((CamelService *)parent_store)->url->path, full);
@@ -2017,13 +2017,14 @@
camel_object_unhook_event((CamelObject *)o, "summary_reloaded", (CamelObjectEventHookFunc) summary_reloaded, data);
}
+ /*
m = camel_session_thread_msg_new(session, &folder_flags_ops, sizeof(*m));
m->sub = summary->folder;
camel_object_ref((CamelObject *)summary->folder);
m->vf = vf;
camel_object_ref((CamelObject *)vf);
camel_session_thread_queue(session, &m->msg, 0);
-
+ */
}
/* vfolder base implementaitons */
@@ -2098,6 +2099,94 @@
CAMEL_VEE_FOLDER_UNLOCK(vf, subfolder_lock);
}
+/* This entire code will be useless, since we sync the counts always. */
+static int
+vf_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args)
+{
+ CamelFolder *folder = (CamelFolder *)object;
+ int i;
+ guint32 tag;
+ int unread = -1, deleted = 0, junked = 0, visible = 0, count = -1, junked_not_deleted = -1;
+
+ for (i=0;i<args->argc;i++) {
+ CamelArgGet *arg = &args->argv[i];
+
+ tag = arg->tag;
+
+ /* NB: this is a copy of camel-folder.c with the unread count logic altered.
+ makes sure its still atomically calculated */
+ switch (tag & CAMEL_ARG_TAG) {
+ case CAMEL_FOLDER_ARG_UNREAD:
+ case CAMEL_FOLDER_ARG_DELETED:
+ case CAMEL_FOLDER_ARG_JUNKED:
+ case CAMEL_FOLDER_ARG_JUNKED_NOT_DELETED:
+ case CAMEL_FOLDER_ARG_VISIBLE:
+
+ /* This is so we can get the values atomically, and also so we can calculate them only once */
+ if (unread == -1) {
+ int j;
+ CamelMessageInfoBase *info;
+ CamelVeeMessageInfo *vinfo;
+
+ unread = deleted = visible = junked = junked_not_deleted = 0;
+ count = camel_folder_summary_count(folder->summary);
+ for (j=0; j<count; j++) {
+ if ((info = (CamelMessageInfoBase *) camel_folder_summary_index(folder->summary, j))) {
+ guint32 flags;
+
+ vinfo = (CamelVeeMessageInfo *) info;
+ flags = vinfo->old_flags;// ? vinfo->old_flags : camel_message_info_flags(info);
+
+ if ((flags & (CAMEL_MESSAGE_SEEN)) == 0)
+ unread++;
+ if (flags & CAMEL_MESSAGE_DELETED)
+ deleted++;
+ if (flags & CAMEL_MESSAGE_JUNK) {
+ junked++;
+ if (! (flags & CAMEL_MESSAGE_DELETED))
+ junked_not_deleted++;
+ }
+ if ((flags & (CAMEL_MESSAGE_DELETED|CAMEL_MESSAGE_JUNK)) == 0)
+ visible++;
+ camel_message_info_free(info);
+ }
+ }
+ }
+
+ switch (tag & CAMEL_ARG_TAG) {
+ case CAMEL_FOLDER_ARG_UNREAD:
+ count = unread == -1 ? 0 : unread;
+ break;
+ case CAMEL_FOLDER_ARG_DELETED:
+ count = deleted == -1 ? 0 : deleted;
+ break;
+ case CAMEL_FOLDER_ARG_JUNKED:
+ count = junked == -1 ? 0 : junked;
+ break;
+ case CAMEL_FOLDER_ARG_JUNKED_NOT_DELETED:
+ count = junked_not_deleted == -1 ? 0 : junked_not_deleted;
+ break;
+ case CAMEL_FOLDER_ARG_VISIBLE:
+ count = visible == -1 ? 0 : visible;
+ break;
+ }
+ folder->summary->unread_count = unread == -1 ? 0 : unread;
+ folder->summary->deleted_count = deleted == -1 ? 0 : deleted;
+ junked = folder->summary->junk_count = junked == -1 ? 0 : junked;
+ folder->summary->junk_not_deleted_count = junked_not_deleted == -1 ? 0 : junked_not_deleted;
+ folder->summary->visible_count = visible == -1 ? 0 : visible;
+ *arg->ca_int = count;
+ break;
+ default:
+ continue;
+ }
+
+ arg->tag = (tag & CAMEL_ARG_TYPE) | CAMEL_ARG_IGNORE;
+ }
+
+ return ((CamelObjectClass *)camel_vee_folder_parent)->getv(object, ex, args);
+}
+
static void
camel_vee_folder_class_init (CamelVeeFolderClass *klass)
{
@@ -2105,6 +2194,8 @@
camel_vee_folder_parent = CAMEL_FOLDER_CLASS(camel_type_get_global_classfuncs (camel_folder_get_type ()));
+ ((CamelObjectClass *)klass)->getv = vf_getv;
+
folder_class->refresh_info = vee_refresh_info;
folder_class->sync = vee_sync;
folder_class->expunge = vee_expunge;
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 Mon Dec 15 06:34:21 2008
@@ -176,20 +176,33 @@
{
int res = FALSE;
CamelVeeFolder *vf = (CamelVeeFolder *)mi->summary->folder;
- const char *exp = g_getenv("CAMEL_VFOLDER_UNREAD_EXP");
+ static char *exp = NULL;
+ static only_once = FALSE;
gboolean hacked_unread_folder = FALSE;
+ char *meta = NULL;
/* 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 (!only_once) {
+ exp = g_getenv("CAMEL_VFOLDER_UNREAD_EXP") ? g_strcompress(g_getenv("CAMEL_VFOLDER_UNREAD_EXP")) : NULL;
+ only_once = TRUE;
+ }
+
if (!exp || !*exp)
- exp = unread_str;
+ exp = g_strcompress(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;
+ meta = camel_object_meta_get (mi->summary->folder, "vfolder:unread");
+ if (!hacked_unread_folder && meta && strcmp (meta, "true") == 0)
+ hacked_unread_folder = TRUE;
+ g_free(meta);
+
if (mi->uid) {
guint32 old_visible, old_unread, old_deleted, old_junked, old_junked_not_deleted;
guint32 visible, unread, deleted, junked, junked_not_deleted;
@@ -417,7 +430,7 @@
{
CamelVeeMessageInfo *mi;
char *vuid;
-
+ GHashTable * fcache;
vuid = g_malloc(strlen(uid)+9);
memcpy(vuid, hash, 8);
strcpy(vuid+8, uid);
@@ -440,6 +453,8 @@
mi = (CamelVeeMessageInfo *)camel_message_info_new(&s->summary);
mi->summary = summary;
+ fcache = camel_folder_summary_get_flag_cache(summary);
+ mi->old_flags = GPOINTER_TO_UINT(g_hash_table_lookup (fcache, uid));
/* We would do lazy loading of flags, when the folders are loaded to memory through folder_reloaded signal */
camel_object_ref (summary);
mi->info.uid = (char *) camel_pstring_strdup (vuid);
Modified: branches/gnome-2-24/camel/camel-vtrash-folder.c
==============================================================================
--- branches/gnome-2-24/camel/camel-vtrash-folder.c (original)
+++ branches/gnome-2-24/camel/camel-vtrash-folder.c Mon Dec 15 06:34:21 2008
@@ -151,7 +151,7 @@
guint32 flags;
vinfo = (CamelVeeMessageInfo *) info;
- flags = vinfo->old_flags ? vinfo->old_flags : camel_message_info_flags(info);
+ flags = vinfo->old_flags;// ? vinfo->old_flags : camel_message_info_flags(info);
if ((flags & (CAMEL_MESSAGE_SEEN)) == 0)
unread++;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]