diff options
author | Dan Winship <danw@src.gnome.org> | 2001-01-11 01:10:44 +0800 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2001-01-11 01:10:44 +0800 |
commit | 54c085cc3cec41cc3d5a77efadb98450a7c5b4b6 (patch) | |
tree | d2a6bb21bfc182acdfb83535dd8b311abb5fb4ad /camel/camel-store.c | |
parent | 4d9047b9b04e1dc5fc74d8bcc2bd360948d6dd76 (diff) | |
download | gsoc2013-evolution-54c085cc3cec41cc3d5a77efadb98450a7c5b4b6.tar.gz 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/camel-store.c')
-rw-r--r-- | camel/camel-store.c | 35 |
1 files changed, 34 insertions, 1 deletions
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); } - |