evolution-data-server r9290 - trunk/camel
- From: sragavan svn gnome org
- To: svn-commits-list gnome org
- Subject: evolution-data-server r9290 - trunk/camel
- Date: Thu, 7 Aug 2008 04:43:23 +0000 (UTC)
Author: sragavan
Date: Thu Aug 7 04:43:22 2008
New Revision: 9290
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=9290&view=rev
Log:
2008-08-07 Srinivasa Ragavan <sragavan novell com>
* camel/camel-vee-folder.c: Fix load/save counts of vee folder.
* camel/camel-vee-summary.c:
Modified:
trunk/camel/ChangeLog
trunk/camel/camel-vee-folder.c
trunk/camel/camel-vee-summary.c
Modified: trunk/camel/camel-vee-folder.c
==============================================================================
--- trunk/camel/camel-vee-folder.c (original)
+++ trunk/camel/camel-vee-folder.c Thu Aug 7 04:43:22 2008
@@ -467,6 +467,33 @@
g_list_free(list);
}
+static int
+count_result (CamelFolderSummary *summary, char *query, CamelException *ex)
+{
+ CamelFolder *folder = summary->folder;
+ CamelVeeFolder *vf = (CamelVeeFolder *)folder;
+ int count=0;
+ char *expr = g_strdup_printf ("(and %s %s)", vf->expression ? vf->expression : "", query);
+ GList *node;
+ struct _CamelVeeFolderPrivate *p = _PRIVATE(vf);
+
+ node = p->folders;
+ while (node) {
+ CamelFolder *f = node->data;
+ GPtrArray *match;
+
+ /* FIXME: Why don't we write a count_search_by_expression. It can be just fast. */
+ match = camel_folder_search_by_expression(f, expr, ex);
+ count += match->len;
+ camel_folder_search_free (f, match);
+
+ node = node->next;
+ }
+
+ g_free(expr);
+ return count;
+}
+
static CamelFIRecord *
summary_header_to_db (CamelFolderSummary *s, CamelException *ex)
{
@@ -486,9 +513,22 @@
record->time = s->time;
record->saved_count = s->uids->len;
- record->junk_count = s->junk_count;
- record->deleted_count = s->deleted_count;
- record->unread_count = s->unread_count;
+ if ((s->unread_count || s->visible_count) && !g_getenv("FORCE_VFOLDER_COUNT")) {
+ /* We should be in sync always. so use the count. Don't search.*/
+ record->junk_count = s->junk_count;
+ record->deleted_count = s->deleted_count;
+ record->unread_count = s->unread_count;
+ record->visible_count = s->visible_count;
+ record->jnd_count = s->junk_not_deleted_count;
+ } else {
+ /* Either first time, or by force we search the count */
+ record->junk_count = count_result (s, "(match-all (system-flag \"junk\"))", ex);
+ record->deleted_count = count_result (s, "(match-all (system-flag \"deleted\"))", ex);
+ record->unread_count = count_result (s, "(match-all (not (system-flag \"Seen\")))", ex);
+ record->visible_count = count_result (s, "(match-all (and (not (system-flag \"deleted\")) (not (system-flag \"junk\"))))", ex);
+ record->jnd_count = count_result (s, "(match-all (and (not (system-flag \"deleted\")) (system-flag \"junk\")))", ex);
+ }
+
return record;
}
Modified: trunk/camel/camel-vee-summary.c
==============================================================================
--- trunk/camel/camel-vee-summary.c (original)
+++ trunk/camel/camel-vee-summary.c Thu Aug 7 04:43:22 2008
@@ -171,9 +171,32 @@
int res = FALSE;
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);
- HANDLE_NULL_INFO(FALSE);
+
+ HANDLE_NULL_INFO(FALSE);
+ camel_object_get(rmi->summary->folder, NULL,
+ CAMEL_FOLDER_DELETED, &old_deleted,
+ 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);
res = camel_message_info_set_flags(rmi, flags, set);
+ 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);
+ /* 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;
+
+ 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));
camel_message_info_free (rmi);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]