aboutsummaryrefslogtreecommitdiffstats
path: root/camel
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
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')
-rw-r--r--camel/ChangeLog10
-rw-r--r--camel/camel-folder.c54
-rw-r--r--camel/camel-folder.h10
3 files changed, 60 insertions, 14 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index df83d0acb6..d01fd2a9b5 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,13 @@
+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.
+
2004-04-13 Jeffrey Stedfast <fejj@ximian.com>
* camel-folder.h (camel_folder_delete_message): Fix NotZed's fix
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;
diff --git a/camel/camel-folder.h b/camel/camel-folder.h
index 24e02fecb2..78f8885dc6 100644
--- a/camel/camel-folder.h
+++ b/camel/camel-folder.h
@@ -49,7 +49,10 @@ enum {
CAMEL_FOLDER_ARG_STORE,
CAMEL_FOLDER_ARG_PERMANENTFLAGS,
CAMEL_FOLDER_ARG_TOTAL,
- CAMEL_FOLDER_ARG_UNREAD,
+ CAMEL_FOLDER_ARG_UNREAD, /* unread messages */
+ CAMEL_FOLDER_ARG_DELETED, /* deleted messages */
+ CAMEL_FOLDER_ARG_JUNKED, /* junked messages */
+ CAMEL_FOLDER_ARG_VISIBLE, /* visible !(deleted or junked) */
CAMEL_FOLDER_ARG_UID_ARRAY,
CAMEL_FOLDER_ARG_INFO_ARRAY,
CAMEL_FOLDER_ARG_PROPERTIES,
@@ -63,7 +66,10 @@ enum {
CAMEL_FOLDER_PERMANENTFLAGS = CAMEL_FOLDER_ARG_PERMANENTFLAGS | CAMEL_ARG_INT,
CAMEL_FOLDER_TOTAL = CAMEL_FOLDER_ARG_TOTAL | CAMEL_ARG_INT,
CAMEL_FOLDER_UNREAD = CAMEL_FOLDER_ARG_UNREAD | CAMEL_ARG_INT,
- /* should we only get static data? not stuff that needs to be free'd? */
+ CAMEL_FOLDER_DELETED = CAMEL_FOLDER_ARG_DELETED | CAMEL_ARG_INT,
+ CAMEL_FOLDER_JUNKED = CAMEL_FOLDER_ARG_JUNKED | CAMEL_ARG_INT,
+ CAMEL_FOLDER_VISIBLE = CAMEL_FOLDER_ARG_VISIBLE | CAMEL_ARG_INT,
+
CAMEL_FOLDER_UID_ARRAY = CAMEL_FOLDER_ARG_UID_ARRAY | CAMEL_ARG_PTR,
CAMEL_FOLDER_INFO_ARRAY = CAMEL_FOLDER_ARG_INFO_ARRAY | CAMEL_ARG_PTR,