From 54c085cc3cec41cc3d5a77efadb98450a7c5b4b6 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Wed, 10 Jan 2001 17:10:44 +0000 Subject: New class function, parallel to camel_folder_sync. (The default * camel-store.c (camel_store_sync): New class function, parallel to camel_folder_sync. (The default implementation just calls camel_folder_sync on each cached folder.) * providers/imap/camel-imap-store.c (get_folder_info): Call camel_store_sync before doing anything else so that the IMAP server and Camel are working from the same data. Don't ask the server for the unread message count of the current folder, since UW will return often-incorrect cached data, and we can calculate it without talking to the server anyway. svn path=/trunk/; revision=7365 --- camel/providers/imap/camel-imap-store.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'camel/providers') diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c index d3701ca5b7..ca4ca2e0d7 100644 --- a/camel/providers/imap/camel-imap-store.c +++ b/camel/providers/imap/camel-imap-store.c @@ -773,6 +773,13 @@ get_folder_info (CamelStore *store, const char *top, gboolean fast, if (!camel_remote_store_connected (CAMEL_REMOTE_STORE (store), ex)) return NULL; + /* Sync flag changes to the server so it has the same ideas about + * read/unread as we do. + */ + camel_store_sync (store, ex); + if (camel_exception_is_set (ex)) + return NULL; + name = top; if (!name) { need_inbox = TRUE; @@ -838,6 +845,17 @@ get_folder_info (CamelStore *store, const char *top, gboolean fast, if (!fi->url || fi->unread_message_count != -1) continue; + /* UW will give cached data for the currently + * selected folder. Grr. Well, I guess this + * also potentially saves us one IMAP command. + */ + if (imap_store->current_folder && + !strcmp (imap_store->current_folder->full_name, + fi->full_name)) { + fi->unread_message_count = camel_folder_get_unread_message_count (imap_store->current_folder); + continue; + } + CAMEL_IMAP_STORE_LOCK (imap_store, command_lock); response = camel_imap_command (imap_store, NULL, NULL, "STATUS %S (UNSEEN)", -- cgit v1.2.3