aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2001-01-11 01:10:44 +0800
committerDan Winship <danw@src.gnome.org>2001-01-11 01:10:44 +0800
commit54c085cc3cec41cc3d5a77efadb98450a7c5b4b6 (patch)
treed2a6bb21bfc182acdfb83535dd8b311abb5fb4ad /camel
parent4d9047b9b04e1dc5fc74d8bcc2bd360948d6dd76 (diff)
downloadgsoc2013-evolution-54c085cc3cec41cc3d5a77efadb98450a7c5b4b6.tar
gsoc2013-evolution-54c085cc3cec41cc3d5a77efadb98450a7c5b4b6.tar.gz
gsoc2013-evolution-54c085cc3cec41cc3d5a77efadb98450a7c5b4b6.tar.bz2
gsoc2013-evolution-54c085cc3cec41cc3d5a77efadb98450a7c5b4b6.tar.lz
gsoc2013-evolution-54c085cc3cec41cc3d5a77efadb98450a7c5b4b6.tar.xz
gsoc2013-evolution-54c085cc3cec41cc3d5a77efadb98450a7c5b4b6.tar.zst
gsoc2013-evolution-54c085cc3cec41cc3d5a77efadb98450a7c5b4b6.zip
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
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog13
-rw-r--r--camel/camel-store.c35
-rw-r--r--camel/camel-store.h7
-rw-r--r--camel/providers/imap/camel-imap-store.c18
4 files changed, 72 insertions, 1 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index c947b4e04e..76f4d130fb 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,16 @@
+2001-01-10 Dan Winship <danw@helixcode.com>
+
+ * 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.
+
2001-01-09 Dan Winship <danw@helixcode.com>
Mostly IMAP changes. Use the NAMESPACE extension (where
diff --git a/camel/camel-store.c b/camel/camel-store.c
index 7c61809150..05bffcdd97 100644
--- a/camel/camel-store.c
+++ b/camel/camel-store.c
@@ -50,6 +50,7 @@ static char *get_folder_name (CamelStore *store, const char *folder_name,
static char *get_root_folder_name (CamelStore *store, CamelException *ex);
static char *get_default_folder_name (CamelStore *store, CamelException *ex);
+static void store_sync (CamelStore *store, CamelException *ex);
static CamelFolderInfo *get_folder_info (CamelStore *store, const char *top,
gboolean fast, gboolean recursive,
gboolean subscribed_only,
@@ -77,6 +78,7 @@ camel_store_class_init (CamelStoreClass *camel_store_class)
camel_store_class->get_folder_name = get_folder_name;
camel_store_class->get_root_folder_name = get_root_folder_name;
camel_store_class->get_default_folder_name = get_default_folder_name;
+ camel_store_class->sync = store_sync;
camel_store_class->get_folder_info = get_folder_info;
camel_store_class->free_folder_info = free_folder_info;
camel_store_class->lookup_folder = lookup_folder;
@@ -434,6 +436,38 @@ camel_store_get_default_folder (CamelStore *store, CamelException *ex)
}
+static void
+sync_folder (gpointer key, gpointer folder, gpointer ex)
+{
+ if (!camel_exception_is_set (ex))
+ camel_folder_sync (folder, FALSE, ex);
+}
+
+static void
+store_sync (CamelStore *store, CamelException *ex)
+{
+ CAMEL_STORE_LOCK(store, cache_lock);
+ g_hash_table_foreach (store->folders, sync_folder, ex);
+ CAMEL_STORE_UNLOCK(store, cache_lock);
+}
+
+/**
+ * camel_store_sync:
+ * @store: a CamelStore
+ * @ex: a CamelException
+ *
+ * Syncs any changes that have been made to the store object and its
+ * folders with the real store.
+ **/
+void
+camel_store_sync (CamelStore *store, CamelException *ex)
+{
+ g_return_if_fail (CAMEL_IS_STORE (store));
+
+ CS_CLASS (store)->sync (store, ex);
+}
+
+
static CamelFolderInfo *
get_folder_info (CamelStore *store, const char *top,
gboolean fast, gboolean recursive,
@@ -737,4 +771,3 @@ camel_store_unsubscribe_folder (CamelStore *store,
CAMEL_STORE_UNLOCK(store, folder_lock);
}
-
diff --git a/camel/camel-store.h b/camel/camel-store.h
index 4df8fa369f..1141f09dcf 100644
--- a/camel/camel-store.h
+++ b/camel/camel-store.h
@@ -85,6 +85,10 @@ typedef struct {
const char *old_name,
const char *new_name,
CamelException *ex);
+
+ void (*sync) (CamelStore *store,
+ CamelException *ex);
+
char * (*get_folder_name) (CamelStore *store,
const char *folder_name,
CamelException *ex);
@@ -143,6 +147,9 @@ void camel_store_rename_folder (CamelStore *store,
const char *new_name,
CamelException *ex);
+void camel_store_sync (CamelStore *store,
+ CamelException *ex);
+
CamelFolderInfo *camel_store_get_folder_info (CamelStore *store,
const char *top,
gboolean fast,
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)",