aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@helixcode.com>2000-07-10 15:30:59 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2000-07-10 15:30:59 +0800
commit3e2188235f0cde226477d268aa4928ebb83af831 (patch)
tree5daf1b2bc32a1b4d766c089692fa4f9a80a38292 /camel
parentcccc6d3b5b40488dfdf8354ce78b8ad65b50e74a (diff)
downloadgsoc2013-evolution-3e2188235f0cde226477d268aa4928ebb83af831.tar.gz
gsoc2013-evolution-3e2188235f0cde226477d268aa4928ebb83af831.tar.zst
gsoc2013-evolution-3e2188235f0cde226477d268aa4928ebb83af831.zip
Implemented.
2000-07-10 Jeffrey Stedfast <fejj@helixcode.com> * providers/mbox/camel-mbox-folder.c (mbox_get_unread_message_count): * providers/vee/camel-vee-folder.c (vee_get_unread_message_count): * providers/imap/camel-imap-folder.c (imap_get_unread_message_count): Implemented. * camel-folder.c (camel_folder_get_unread_message_count): New convenience function to allow the mailer to query the number of unread messages in a folder (for displaying message stats in a folder tree?). svn path=/trunk/; revision=4028
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog12
-rw-r--r--camel/camel-folder.c25
-rw-r--r--camel/camel-folder.h6
-rw-r--r--camel/providers/imap/camel-imap-folder.c29
-rw-r--r--camel/providers/mbox/camel-mbox-folder.c28
-rw-r--r--camel/providers/vee/camel-vee-folder.c24
6 files changed, 124 insertions, 0 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 7802970b25..013a73af37 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,15 @@
+2000-07-10 Jeffrey Stedfast <fejj@helixcode.com>
+
+ * providers/mbox/camel-mbox-folder.c (mbox_get_unread_message_count):
+ * providers/vee/camel-vee-folder.c (vee_get_unread_message_count):
+ * providers/imap/camel-imap-folder.c (imap_get_unread_message_count):
+ Implemented.
+
+ * camel-folder.c (camel_folder_get_unread_message_count): New
+ convenience function to allow the mailer to query the number
+ of unread messages in a folder (for displaying message stats
+ in a folder tree?).
+
2000-07-09 Dan Winship <danw@helixcode.com>
* camel-mime-utils.c (header_references_dup): New function to copy
diff --git a/camel/camel-folder.c b/camel/camel-folder.c
index 8420bd75cf..454db69773 100644
--- a/camel/camel-folder.c
+++ b/camel/camel-folder.c
@@ -89,6 +89,7 @@ static CamelStore *get_parent_store (CamelFolder *folder,
static gint get_message_count (CamelFolder *folder, CamelException *ex);
+static gint get_unread_message_count (CamelFolder *folder, CamelException *ex);
static void expunge (CamelFolder *folder,
CamelException *ex);
@@ -164,6 +165,7 @@ camel_folder_class_init (CamelFolderClass *camel_folder_class)
camel_folder_class->free_subfolder_names = free_uids;
camel_folder_class->expunge = expunge;
camel_folder_class->get_message_count = get_message_count;
+ camel_folder_class->get_unread_message_count = get_unread_message_count;
camel_folder_class->append_message = append_message;
camel_folder_class->get_permanent_flags = get_permanent_flags;
camel_folder_class->get_message_flags = get_message_flags;
@@ -593,6 +595,29 @@ camel_folder_get_message_count (CamelFolder *folder, CamelException *ex)
return CF_CLASS (folder)->get_message_count (folder, ex);
}
+static gint
+get_unread_message_count (CamelFolder *folder, CamelException *ex)
+{
+ g_warning ("CamelFolder::get_unread_message_count not implemented "
+ "for `%s'", gtk_type_name (GTK_OBJECT_TYPE (folder)));
+ return -1;
+}
+
+/**
+ * camel_folder_unread_get_message_count:
+ * @folder: A CamelFolder object
+ * @ex: a CamelException
+ *
+ * Return value: the number of unread messages in the folder, or -1 if unknown.
+ **/
+gint
+camel_folder_get_unread_message_count (CamelFolder *folder, CamelException *ex)
+{
+ g_return_val_if_fail (CAMEL_IS_FOLDER (folder), -1);
+
+ return CF_CLASS (folder)->get_message_count (folder, ex);
+}
+
static void
append_message (CamelFolder *folder, CamelMimeMessage *message,
diff --git a/camel/camel-folder.h b/camel/camel-folder.h
index a7fc8fa89c..1d749be294 100644
--- a/camel/camel-folder.h
+++ b/camel/camel-folder.h
@@ -106,6 +106,9 @@ typedef struct {
gint (*get_message_count) (CamelFolder *folder,
CamelException *ex);
+ gint (*get_unread_message_count) (CamelFolder *folder,
+ CamelException *ex);
+
void (*append_message) (CamelFolder *folder,
CamelMimeMessage *message,
CamelException *ex);
@@ -255,6 +258,9 @@ gboolean camel_folder_has_summary_capability (CamelFolder *folder);
gint camel_folder_get_message_count (CamelFolder *folder,
CamelException *ex);
+gint camel_folder_get_unread_message_count (CamelFolder *folder,
+ CamelException *ex);
+
GPtrArray * camel_folder_get_summary (CamelFolder *folder,
CamelException *ex);
void camel_folder_free_summary (CamelFolder *folder,
diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c
index d92f260870..53c77e2f1e 100644
--- a/camel/providers/imap/camel-imap-folder.c
+++ b/camel/providers/imap/camel-imap-folder.c
@@ -63,6 +63,7 @@ static void imap_init (CamelFolder *folder, CamelStore *parent_store,
static void imap_sync (CamelFolder *folder, gboolean expunge, CamelException *ex);
static gint imap_get_message_count (CamelFolder *folder, CamelException *ex);
+static gint imap_get_unread_message_count (CamelFolder *folder, CamelException *ex);
static void imap_append_message (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex);
static void imap_copy_message_to (CamelFolder *source, const char *uid, CamelFolder *destination, CamelException *ex);
static void imap_move_message_to (CamelFolder *source, const char *uid, CamelFolder *destination, CamelException *ex);
@@ -111,6 +112,7 @@ camel_imap_folder_class_init (CamelImapFolderClass *camel_imap_folder_class)
camel_folder_class->get_subfolder_names = imap_get_subfolder_names;
camel_folder_class->get_message_count = imap_get_message_count;
+ camel_folder_class->get_unread_message_count = imap_get_unread_message_count;
camel_folder_class->get_message = imap_get_message;
camel_folder_class->append_message = imap_append_message;
camel_folder_class->delete_message = imap_delete_message;
@@ -446,6 +448,33 @@ imap_get_message_count (CamelFolder *folder, CamelException *ex)
return imap_folder->count;
}
+static gint
+imap_get_unread_message_count (CamelFolder *folder, CamelException *ex)
+{
+ CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
+ CamelMessageInfo *info;
+ GPtrArray *infolist;
+ gint i, count = 0;
+
+ g_return_val_if_fail (folder != NULL, -1);
+
+ /* If we don't have a message count, return */
+ if (imap_folder->count == -1)
+ return -1;
+
+ infolist = imap_get_summary (folder, ex);
+
+ for (i = 0; i < infolist->len; i++) {
+ info = (CamelMessageInfo *) g_ptr_array_index (infolist, i);
+ if (!(info->flags & CAMEL_MESSAGE_SEEN))
+ count++;
+ }
+
+ imap_free_summary (folder, infolist);
+
+ return count;
+}
+
static void
imap_append_message (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex)
{
diff --git a/camel/providers/mbox/camel-mbox-folder.c b/camel/providers/mbox/camel-mbox-folder.c
index ca313ec045..e8c3f7c795 100644
--- a/camel/providers/mbox/camel-mbox-folder.c
+++ b/camel/providers/mbox/camel-mbox-folder.c
@@ -4,6 +4,7 @@
/*
* Authors: Bertrand Guiheneuf <bertrand@helixcode.com>
* Michael Zucchi <notzed@helixcode.com>
+ * Jeffrey Stedfast <fejj@helixcode.com>
*
* Copyright (C) 1999, 2000 Helix Code Inc.
*
@@ -63,6 +64,7 @@ static void mbox_init (CamelFolder *folder, CamelStore *parent_store,
static void mbox_sync (CamelFolder *folder, gboolean expunge, CamelException *ex);
static gint mbox_get_message_count (CamelFolder *folder, CamelException *ex);
+static gint mbox_get_unread_message_count (CamelFolder *folder, CamelException *ex);
static void mbox_append_message (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex);
static GPtrArray *mbox_get_uids (CamelFolder *folder, CamelException *ex);
static GPtrArray *mbox_get_subfolder_names (CamelFolder *folder, CamelException *ex);
@@ -100,6 +102,7 @@ camel_mbox_folder_class_init (CamelMboxFolderClass *camel_mbox_folder_class)
camel_folder_class->init = mbox_init;
camel_folder_class->sync = mbox_sync;
camel_folder_class->get_message_count = mbox_get_message_count;
+ camel_folder_class->get_unread_message_count = mbox_get_unread_message_count;
camel_folder_class->append_message = mbox_append_message;
camel_folder_class->get_uids = mbox_get_uids;
camel_folder_class->get_subfolder_names = mbox_get_subfolder_names;
@@ -269,6 +272,31 @@ mbox_get_message_count (CamelFolder *folder, CamelException *ex)
return camel_folder_summary_count (CAMEL_FOLDER_SUMMARY (mbox_folder->summary));
}
+static gint
+mbox_get_unread_message_count (CamelFolder *folder, CamelException *ex)
+{
+ CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (folder);
+ CamelMessageInfo *info;
+ GPtrArray *infolist;
+ gint i, max, count = 0;
+
+ g_return_val_if_fail (folder != NULL, -1);
+
+ max = camel_folder_summary_count (CAMEL_FOLDER_SUMMARY (mbox_folder->summary));
+ if (max == -1)
+ return -1;
+
+ infolist = mbox_get_summary (folder, ex);
+
+ for (i = 0; i < infolist->len; i++) {
+ info = (CamelMessageInfo *) g_ptr_array_index (infolist, i);
+ if (!(info->flags & CAMEL_MESSAGE_SEEN))
+ count++;
+ }
+
+ return count;
+}
+
/* FIXME: this may need some tweaking for performance? */
static void
mbox_append_message (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex)
diff --git a/camel/providers/vee/camel-vee-folder.c b/camel/providers/vee/camel-vee-folder.c
index 745e9a78ea..dea476eb13 100644
--- a/camel/providers/vee/camel-vee-folder.c
+++ b/camel/providers/vee/camel-vee-folder.c
@@ -2,6 +2,7 @@
* Copyright (C) 2000 Helix Code Inc.
*
* Authors: Michael Zucchi <notzed@helixcode.com>
+ * Jeffrey Stedfast <fejj@helixcode.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -49,6 +50,7 @@ GPtrArray *vee_get_summary (CamelFolder *folder, CamelException *ex);
void vee_free_summary (CamelFolder *folder, GPtrArray *array);
static gint vee_get_message_count (CamelFolder *folder, CamelException *ex);
+static gint vee_get_unread_message_count (CamelFolder *folder, CamelException *ex);
static CamelMimeMessage *vee_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex);
static const CamelMessageInfo *vee_get_message_info (CamelFolder *folder, const char *uid);
@@ -118,6 +120,7 @@ camel_vee_folder_class_init (CamelVeeFolderClass *klass)
folder_class->get_message_info = vee_get_message_info;
folder_class->get_message_count = vee_get_message_count;
+ folder_class->get_unread_message_count = vee_get_unread_message_count;
folder_class->search_by_expression = vee_search_by_expression;
folder_class->get_message_flags = vee_get_message_flags;
@@ -292,6 +295,27 @@ static gint vee_get_message_count (CamelFolder *folder, CamelException *ex)
return vf->messages->len;
}
+static gint
+vee_get_unread_message_count (CamelFolder *folder, CamelException *ex)
+{
+ CamelVeeFolder *vee_folder = CAMEL_VEE_FOLDER (folder);
+ CamelMessageInfo *info;
+ GPtrArray *infolist;
+ gint i, count = 0;
+
+ g_return_val_if_fail (folder != NULL, -1);
+
+ infolist = vee_folder->messages;
+
+ for (i = 0; i < infolist->len; i++) {
+ info = (CamelMessageInfo *) g_ptr_array_index (infolist, i);
+ if (!(info->flags & CAMEL_MESSAGE_SEEN))
+ count++;
+ }
+
+ return count;
+}
+
static gboolean
get_real_message (CamelFolder *folder, const char *uid,
CamelFolder **out_folder, const char **out_uid,