aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-folder.c
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2004-04-13 23:58:56 +0800
committerMichael Zucci <zucchi@src.gnome.org>2004-04-13 23:58:56 +0800
commit8563120ccac076a0baf9cb904c23a87bbb59d960 (patch)
treeeb99449985db957cca9fdc21bd2c6f6810e51eab /camel/camel-folder.c
parent6e42b3e7ed225a9ca6dcd166e2a8ddf9d1eae3ed (diff)
downloadgsoc2013-evolution-8563120ccac076a0baf9cb904c23a87bbb59d960.tar
gsoc2013-evolution-8563120ccac076a0baf9cb904c23a87bbb59d960.tar.gz
gsoc2013-evolution-8563120ccac076a0baf9cb904c23a87bbb59d960.tar.bz2
gsoc2013-evolution-8563120ccac076a0baf9cb904c23a87bbb59d960.tar.lz
gsoc2013-evolution-8563120ccac076a0baf9cb904c23a87bbb59d960.tar.xz
gsoc2013-evolution-8563120ccac076a0baf9cb904c23a87bbb59d960.tar.zst
gsoc2013-evolution-8563120ccac076a0baf9cb904c23a87bbb59d960.zip
implement the new counts, and get them all atomically so they're only
2004-04-13 Not Zed <NotZed@Ximian.com> * camel-folder.c (folder_getv): implement the new counts, and get them all atomically so they're only calculated once and can return consistent results. * camel-folder.h: Added CAMEL_FOLDER_DELETED, CAMEL_FOLDER_JUNKED, and CAMEL_FOLDER_VISIBLE args, to support client display of various values. svn path=/trunk/; revision=25437
Diffstat (limited to 'camel/camel-folder.c')
-rw-r--r--camel/camel-folder.c54
1 files changed, 42 insertions, 12 deletions
diff --git a/camel/camel-folder.c b/camel/camel-folder.c
index ca30bb24cd..853c49400d 100644
--- a/camel/camel-folder.c
+++ b/camel/camel-folder.c
@@ -313,6 +313,7 @@ folder_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;
for (i=0;i<args->argc;i++) {
CamelArgGet *arg = &args->argv[i];
@@ -343,21 +344,50 @@ folder_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args)
case CAMEL_FOLDER_ARG_TOTAL:
*arg->ca_int = camel_folder_summary_count(folder->summary);
break;
- case CAMEL_FOLDER_ARG_UNREAD: {
- int j, unread = 0, count;
- CamelMessageInfo *info;
-
- count = camel_folder_summary_count(folder->summary);
- for (j=0; j<count; j++) {
- if ((info = camel_folder_summary_index(folder->summary, j))) {
- if (!(info->flags & CAMEL_MESSAGE_SEEN))
- unread++;
- camel_folder_summary_info_free(folder->summary, info);
+ case CAMEL_FOLDER_ARG_UNREAD:
+ case CAMEL_FOLDER_ARG_DELETED:
+ case CAMEL_FOLDER_ARG_JUNKED:
+ 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;
+ CamelMessageInfo *info;
+
+ /* TODO: Locking? */
+ unread = 0;
+ count = camel_folder_summary_count(folder->summary);
+ for (j=0; j<count; j++) {
+ if ((info = camel_folder_summary_index(folder->summary, j))) {
+ if (!(info->flags & CAMEL_MESSAGE_SEEN))
+ unread++;
+ if (info->flags & CAMEL_MESSAGE_DELETED)
+ deleted++;
+ if (info->flags & CAMEL_MESSAGE_JUNK)
+ junked++;
+ if ((info->flags & (CAMEL_MESSAGE_DELETED|CAMEL_MESSAGE_JUNK)) == 0)
+ visible++;
+ camel_folder_summary_info_free(folder->summary, info);
+ }
}
}
- *arg->ca_int = unread;
- break; }
+ switch (tag & CAMEL_ARG_TAG) {
+ case CAMEL_FOLDER_ARG_UNREAD:
+ count = unread;
+ break;
+ case CAMEL_FOLDER_ARG_DELETED:
+ count = deleted;
+ break;
+ case CAMEL_FOLDER_ARG_JUNKED:
+ count = junked;
+ break;
+ case CAMEL_FOLDER_ARG_VISIBLE:
+ count = visible;
+ break;
+ }
+
+ *arg->ca_int = count;
+ break;
case CAMEL_FOLDER_ARG_UID_ARRAY: {
int j, count;
CamelMessageInfo *info;