From 5795833acac5ff6d1d2332b28390238e77022fd3 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Tue, 24 Oct 2000 18:49:30 +0000 Subject: Fill in the message_count and unread_message_count flags (if !fast). * providers/imap/camel-imap-store.c (get_folder_info): Fill in the message_count and unread_message_count flags (if !fast). svn path=/trunk/; revision=6151 --- camel/ChangeLog | 5 +++++ camel/providers/imap/camel-imap-store.c | 39 ++++++++++++++++++++++++++++----- 2 files changed, 39 insertions(+), 5 deletions(-) (limited to 'camel') diff --git a/camel/ChangeLog b/camel/ChangeLog index 05a6a0d344..a3fdd32896 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,8 @@ +2000-10-24 Dan Winship + + * providers/imap/camel-imap-store.c (get_folder_info): Fill in the + message_count and unread_message_count flags (if !fast). + 2000-10-23 Dan Winship * camel-object.h: #include gnome-i18n.h (and gnome-defs.h since diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c index a731ac9a68..d86e6a4cb6 100644 --- a/camel/providers/imap/camel-imap-store.c +++ b/camel/providers/imap/camel-imap-store.c @@ -507,7 +507,6 @@ parse_list_response_as_folder_info (const char *response, if (!e_strstrcase (flags, "\\NoSelect")) fi->url = g_strdup_printf ("%s%s", base_url, dir); g_free (flags); - /* FIXME: read/unread msg count */ return fi; } @@ -524,6 +523,7 @@ get_folder_info (CamelStore *store, const char *top, gboolean fast, CamelImapResponse *response; GPtrArray *folders; char *dir_sep, *namespace, *base_url, *list; + char *folder_path, *status, *p; CamelFolderInfo *topfi = NULL, *fi; if (!top) @@ -549,9 +549,8 @@ get_folder_info (CamelStore *store, const char *top, gboolean fast, if (response) { list = camel_imap_response_extract (response, "LIST", ex); if (list) { - topfi = parse_list_response_as_folder_info (list, - namespace, - base_url); + topfi = parse_list_response_as_folder_info ( + list, namespace, base_url); g_free (list); } } @@ -595,11 +594,41 @@ get_folder_info (CamelStore *store, const char *top, gboolean fast, fi->full_name = g_strdup ("INBOX"); fi->name = g_strdup ("INBOX"); fi->url = g_strdup_printf ("%sINBOX", base_url); - /* FIXME: read/unread msg count */ g_ptr_array_add (folders, fi); } + if (!fast) { + /* Get read/unread counts */ + for (i = 0; i < folders->len; i++) { + fi = folders->pdata[i]; + if (!fi->url) + continue; + + folder_path = camel_imap_store_folder_path ( + imap_store, fi->full_name); + response = camel_imap_command ( + imap_store, NULL, NULL, + "STATUS %s (MESSAGES UNSEEN)", + folder_path); + g_free (folder_path); + if (!response) + continue; + status = camel_imap_response_extract ( + response, "STATUS", NULL); + if (!status) + continue; + + p = e_strstrcase (status, "MESSAGES"); + if (p) + fi->message_count = strtoul (p + 8, NULL, 10); + p = e_strstrcase (status, "UNSEEN"); + if (p) + fi->unread_message_count = strtoul (p + 6, NULL, 10); + g_free (status); + } + } + /* And assemble */ camel_folder_info_build (folders, topfi, *dir_sep, TRUE); g_ptr_array_free (folders, FALSE); -- cgit v1.2.3