From 1f9d06c2aac1805bbd3922991d8332b44f16ad3e Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Thu, 15 Mar 2001 20:50:59 +0000 Subject: First batch of disconnected IMAP-related stuff. This adds local caching of message parts, but NOT any actual disconnected support. (But it should speed up IMAP use.) * providers/imap/camel-imap-message-cache.c: New class for caching message data to disk, and removing it when it's no longer relevant. Will eventually also support merging message parts together to save on files. Or maybe using a db instead of files? * providers/imap/camel-imap-private.h: Add a cache_lock to CamelImapFolderPrivate. This lock must be recursive, so make both locks EMutexes rather than GMutex. * providers/imap/camel-imap-folder.c (parse_fetch_response): "The only FETCH response parser you need!" Replaces the various almost-correct bits of code formerly scattered throughout this file with a single fully-correct function that can handle any FETCH response at any time, so we don't get confused by seeing a flags update when we were only expecting a message body, etc. (camel_imap_folder_fetch_data): FETCH a message body part either from the cache or the server (camel_imap_folder_changed): Remove expunged messages from the message cache. (camel_imap_folder_new): Change to take a directory instead of a summary file name. Create a CamelImapMessageCache for the folder. (imap_finalize): Unref the message cache. (camel_imap_folder_selected, imap_rescan, get_content, get_message, imap_get_message, imap_update_summary): Redone a bunch to use parse_fetch_data, CamelImapMessageCache, etc. * providers/imap/camel-imap-store.c (get_folder): Pass directory name to camel_imap_folder_new, not summary filename. Use e_path_to_physical to generate a path with /subfolders/ inserted between directory components. * providers/imap/camel-imap-wrapper.c (camel_imap_wrapper_new): Call camel_imap_folder_fetch_data (with cache_only TRUE) and if the data is cached, return an online datawrapper rather than an offline one. (write_to_stream): Use camel_imap_folder_fetch_data (with cache_only FALSE) here too * providers/imap/camel-imap-utils.c (imap_skip_list): Renamed from skip_list and made non-static. svn path=/trunk/; revision=8743 --- camel/providers/imap/camel-imap-store.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'camel/providers/imap/camel-imap-store.c') diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c index 83f9548bde..44ebea5ebe 100644 --- a/camel/providers/imap/camel-imap-store.c +++ b/camel/providers/imap/camel-imap-store.c @@ -32,6 +32,7 @@ #include #include +#include "e-util/e-path.h" #include "camel-imap-store.h" #include "camel-imap-folder.h" @@ -729,7 +730,7 @@ get_folder (CamelStore *store, const char *folder_name, guint32 flags, { CamelImapStore *imap_store = CAMEL_IMAP_STORE (store); CamelFolder *new_folder = NULL; - char *short_name, *summary_file, *p; + char *short_name, *folder_dir; gboolean selectable; if (!camel_remote_store_connected (CAMEL_REMOTE_STORE (store), ex)) @@ -757,22 +758,18 @@ get_folder (CamelStore *store, const char *folder_name, guint32 flags, return NULL; } - summary_file = g_strdup_printf ("%s/%s/#summary", - imap_store->storage_path, - folder_name); - p = strrchr (summary_file, '/'); - *p = '\0'; - if (e_mkdir_hier (summary_file, S_IRWXU) == 0) { - *p = '/'; + folder_dir = e_path_to_physical (imap_store->storage_path, + folder_name); + if (e_mkdir_hier (folder_dir, S_IRWXU) == 0) { new_folder = camel_imap_folder_new (store, folder_name, - short_name, summary_file, + short_name, folder_dir, ex); } else { camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Could not create directory %s: %s"), - summary_file, g_strerror (errno)); + folder_dir, g_strerror (errno)); } - g_free (summary_file); + g_free (folder_dir); g_free (short_name); if (camel_exception_is_set (ex)) -- cgit v1.2.3