aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author9 <NotZed@Ximian.com>2001-10-29 16:24:00 +0800
committerMichael Zucci <zucchi@src.gnome.org>2001-10-29 16:24:00 +0800
commitc43aa966cbac71c6e5dbceb55bb172dcc3687bbf (patch)
tree12a9b86802e1a65afc9049e6d5d81e114b26182e
parentfa9505a288ebeab16883eb940bd1418f176fc426 (diff)
downloadgsoc2013-evolution-c43aa966cbac71c6e5dbceb55bb172dcc3687bbf.tar
gsoc2013-evolution-c43aa966cbac71c6e5dbceb55bb172dcc3687bbf.tar.gz
gsoc2013-evolution-c43aa966cbac71c6e5dbceb55bb172dcc3687bbf.tar.bz2
gsoc2013-evolution-c43aa966cbac71c6e5dbceb55bb172dcc3687bbf.tar.lz
gsoc2013-evolution-c43aa966cbac71c6e5dbceb55bb172dcc3687bbf.tar.xz
gsoc2013-evolution-c43aa966cbac71c6e5dbceb55bb172dcc3687bbf.tar.zst
gsoc2013-evolution-c43aa966cbac71c6e5dbceb55bb172dcc3687bbf.zip
Turn off w() -> warnings.
2001-10-29 <NotZed@Ximian.com> * camel-mime-utils.c: Turn off w() -> warnings. * providers/imap/camel-imap-store.c (rename_folder): Also rename the message cache. (rename_folder): Fix subscribed folders table with rename(s). * providers/imap/camel-imap-folder.c (imap_rename): Implement, rename the cache dir pointer. * providers/imap/camel-imap-message-cache.c (camel_imap_message_cache_set_path): New method to set the path used by a message cache. svn path=/trunk/; revision=14327
-rw-r--r--camel/ChangeLog13
-rw-r--r--camel/camel-folder.c2
-rw-r--r--camel/camel-mime-utils.c4
-rw-r--r--camel/camel-vee-store.c7
-rw-r--r--camel/providers/imap/camel-imap-folder.c26
-rw-r--r--camel/providers/imap/camel-imap-message-cache.c14
-rw-r--r--camel/providers/imap/camel-imap-message-cache.h3
-rw-r--r--camel/providers/imap/camel-imap-store.c74
-rw-r--r--camel/providers/imap/camel-imap-store.h1
9 files changed, 133 insertions, 11 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index cc37be2f76..fbc70f6db2 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,5 +1,18 @@
2001-10-29 <NotZed@Ximian.com>
+ * camel-mime-utils.c: Turn off w() -> warnings.
+
+ * providers/imap/camel-imap-store.c (rename_folder): Also rename
+ the message cache.
+ (rename_folder): Fix subscribed folders table with rename(s).
+
+ * providers/imap/camel-imap-folder.c (imap_rename): Implement,
+ rename the cache dir pointer.
+
+ * providers/imap/camel-imap-message-cache.c
+ (camel_imap_message_cache_set_path): New method to set the path
+ used by a message cache.
+
* camel-vee-store.c (build_info): Fix the 'is this a matching
subfolder or subfolder'' logic to match camel-store
get_subfolders'.
diff --git a/camel/camel-folder.c b/camel/camel-folder.c
index 405107e2a8..fd1fc13736 100644
--- a/camel/camel-folder.c
+++ b/camel/camel-folder.c
@@ -1349,7 +1349,7 @@ folder_rename (CamelFolder *folder, const char *new)
g_free(folder->full_name);
folder->full_name = g_strdup(new);
g_free(folder->name);
- tmp = strrchr(new, '/');
+ tmp = strrchr(new, folder->parent_store->dir_sep);
folder->name = g_strdup(tmp?tmp+1:new);
}
diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c
index 3b2d0f94f3..405939183d 100644
--- a/camel/camel-mime-utils.c
+++ b/camel/camel-mime-utils.c
@@ -72,7 +72,7 @@ int free_count = 0;
#endif
/* for all warnings ... */
-#define w(x) x
+#define w(x)
#define d(x)
#define d2(x)
@@ -2959,7 +2959,7 @@ header_param_list_format_append (GString *out, struct _header_param *p)
value = header_encode_param (p->value, &encoded);
if (!value) {
- g_warning ("appending parameter %s=%s violates rfc2184", p->name, p->value);
+ w(g_warning ("appending parameter %s=%s violates rfc2184", p->name, p->value));
value = g_strdup (p->value);
}
diff --git a/camel/camel-vee-store.c b/camel/camel-vee-store.c
index e909671e36..6fe9e31339 100644
--- a/camel/camel-vee-store.c
+++ b/camel/camel-vee-store.c
@@ -167,14 +167,13 @@ static void
build_info(char *name, CamelVeeFolder *folder, struct _build_info *data)
{
CamelFolderInfo *info;
- int toplen, namelen;
-
- namelen = strlen(name);
- toplen = strlen(data->top);
/* check we have to include this one */
if (data->top) {
if (data->flags & CAMEL_STORE_FOLDER_INFO_RECURSIVE) {
+ int namelen = strlen(name);
+ int toplen = strlen(data->top);
+
if (!((namelen == toplen &&
strcmp(name, data->top) == 0)
|| ((namelen > toplen)
diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c
index e1bd4bc101..adc43514a0 100644
--- a/camel/providers/imap/camel-imap-folder.c
+++ b/camel/providers/imap/camel-imap-folder.c
@@ -37,6 +37,8 @@
#include <fcntl.h>
#include <ctype.h>
+#include "e-util/e-path.h"
+
#include "camel-imap-folder.h"
#include "camel-imap-command.h"
#include "camel-imap-message-cache.h"
@@ -74,6 +76,7 @@ static void imap_expunge_uids_online (CamelFolder *folder, GPtrArray *uids, Came
static void imap_expunge_uids_offline (CamelFolder *folder, GPtrArray *uids, CamelException *ex);
static void imap_expunge_uids_resyncing (CamelFolder *folder, GPtrArray *uids, CamelException *ex);
static void imap_cache_message (CamelDiscoFolder *disco_folder, const char *uid, CamelException *ex);
+static void imap_rename (CamelFolder *folder, const char *new);
/* message manipulation */
static CamelMimeMessage *imap_get_message (CamelFolder *folder, const gchar *uid,
@@ -114,6 +117,7 @@ camel_imap_folder_class_init (CamelImapFolderClass *camel_imap_folder_class)
/* virtual method overload */
camel_folder_class->get_message = imap_get_message;
camel_folder_class->move_messages_to = imap_move_messages_to;
+ camel_folder_class->rename = imap_rename;
camel_folder_class->search_by_expression = imap_search_by_expression;
camel_folder_class->search_by_uids = imap_search_by_uids;
camel_folder_class->search_free = imap_search_free;
@@ -368,6 +372,28 @@ imap_finalize (CamelObject *object)
}
static void
+imap_rename(CamelFolder *folder, const char *new)
+{
+ CamelImapFolder *imap_folder = (CamelImapFolder *)folder;
+ CamelImapStore *imap_store = (CamelImapStore *)folder->parent_store;
+ char *folder_dir, *summary_path;
+
+ folder_dir = e_path_to_physical (imap_store->storage_path, new);
+ summary_path = g_strdup_printf("%s/summary", folder_dir);
+
+ CAMEL_IMAP_FOLDER_LOCK (folder, cache_lock);
+ camel_imap_message_cache_set_path(imap_folder->cache, folder_dir);
+ CAMEL_IMAP_FOLDER_UNLOCK (folder, cache_lock);
+
+ camel_folder_summary_set_filename(folder->summary, summary_path);
+
+ g_free(summary_path);
+ g_free(folder_dir);
+
+ ((CamelFolderClass *)disco_folder_class)->rename(folder, new);
+}
+
+static void
imap_refresh_info (CamelFolder *folder, CamelException *ex)
{
CamelImapStore *imap_store = CAMEL_IMAP_STORE (folder->parent_store);
diff --git a/camel/providers/imap/camel-imap-message-cache.c b/camel/providers/imap/camel-imap-message-cache.c
index ab5d125d6e..e5cddf9bae 100644
--- a/camel/providers/imap/camel-imap-message-cache.c
+++ b/camel/providers/imap/camel-imap-message-cache.c
@@ -209,6 +209,20 @@ camel_imap_message_cache_max_uid (CamelImapMessageCache *cache)
return cache->max_uid;
}
+/**
+ * camel_imap_message_cache_set_path:
+ * @cache:
+ * @path:
+ *
+ * Set the path used for the message cache.
+ **/
+void
+camel_imap_message_cache_set_path (CamelImapMessageCache *cache, const char *path)
+{
+ g_free(cache->path);
+ cache->path = g_strdup(path);
+}
+
static void
stream_finalize (CamelObject *stream, gpointer event_data, gpointer user_data)
{
diff --git a/camel/providers/imap/camel-imap-message-cache.h b/camel/providers/imap/camel-imap-message-cache.h
index efdc832694..eb3f056b44 100644
--- a/camel/providers/imap/camel-imap-message-cache.h
+++ b/camel/providers/imap/camel-imap-message-cache.h
@@ -63,6 +63,9 @@ CamelImapMessageCache *camel_imap_message_cache_new (const char *path,
CamelFolderSummary *summ,
CamelException *ex);
+void camel_imap_message_cache_set_path (CamelImapMessageCache *cache,
+ const char *path);
+
guint32 camel_imap_message_cache_max_uid (CamelImapMessageCache *cache);
CamelStream *camel_imap_message_cache_insert (CamelImapMessageCache *cache,
diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c
index aa7fc5fb17..f429ef6a76 100644
--- a/camel/providers/imap/camel-imap-store.c
+++ b/camel/providers/imap/camel-imap-store.c
@@ -79,8 +79,7 @@ static CamelFolder *get_folder_online (CamelStore *store, const char *folder_nam
static CamelFolder *get_folder_offline (CamelStore *store, const char *folder_name, guint32 flags, CamelException *ex);
static CamelFolderInfo *create_folder (CamelStore *store, const char *parent_name, const char *folder_name, CamelException *ex);
static void delete_folder (CamelStore *store, const char *folder_name, CamelException *ex);
-static void rename_folder (CamelStore *store, const char *old_name,
- const char *new_name, CamelException *ex);
+static void rename_folder (CamelStore *store, const char *old_name, const char *new_name, CamelException *ex);
static CamelFolderInfo *get_folder_info_online (CamelStore *store,
const char *top,
guint32 flags,
@@ -1103,11 +1102,41 @@ delete_folder (CamelStore *store, const char *folder_name, CamelException *ex)
}
}
+struct _fix_subscribe {
+ char dir_sep;
+
+ const char *old_name;
+ const char *new_name;
+
+ GPtrArray *old;
+ GPtrArray *new;
+};
+
+/* Fixes subscribed names to take into account a rename */
+static void
+fix_subscribed(char *key, void *val, struct _fix_subscribe *data)
+{
+ int oldlen, namelen;
+
+ namelen = strlen(key);
+ oldlen = strlen(data->old_name);
+
+ if ((namelen == oldlen &&
+ strcmp(data->old_name, key) == 0)
+ || ((namelen > oldlen)
+ && strncmp(data->old_name, key, oldlen) == 0
+ && key[oldlen] == data->dir_sep)) {
+ g_ptr_array_add(data->old, key);
+ g_ptr_array_add(data->new, g_strdup_printf("%s%s", data->new_name, key+oldlen));
+ }
+}
+
static void
rename_folder (CamelStore *store, const char *old_name, const char *new_name, CamelException *ex)
{
CamelImapStore *imap_store = CAMEL_IMAP_STORE (store);
CamelImapResponse *response;
+ char *oldpath, *newpath;
if (!camel_disco_store_check_online (CAMEL_DISCO_STORE (store), ex))
return;
@@ -1130,6 +1159,43 @@ rename_folder (CamelStore *store, const char *old_name, const char *new_name, Ca
if (response)
camel_imap_response_free (imap_store, response);
+
+ if (camel_exception_is_set(ex))
+ return;
+
+ /* Fix up the subscriptions table */
+ if (store->flags & CAMEL_STORE_SUBSCRIPTIONS) {
+ struct _fix_subscribe data;
+ int i;
+
+ data.dir_sep = imap_store->dir_sep;
+ data.old_name = old_name;
+ data.new_name = new_name;
+ data.old = g_ptr_array_new();
+ data.new = g_ptr_array_new();
+ g_hash_table_foreach(imap_store->subscribed_folders, (GHFunc)fix_subscribed, &data);
+
+ for (i=0;i<data.old->len;i++) {
+ printf("moving subscribed folder from '%s' to '%s'\n", (char *)data.old->pdata[i], (char *)data.new->pdata[i]);
+ g_hash_table_remove(imap_store->subscribed_folders, data.old->pdata[i]);
+ g_free(data.old->pdata[i]);
+ g_hash_table_insert(imap_store->subscribed_folders, data.new->pdata[i], (void *)1);
+ }
+
+ g_ptr_array_free(data.old, TRUE);
+ g_ptr_array_free(data.new, TRUE);
+ }
+
+ oldpath = e_path_to_physical (imap_store->storage_path, old_name);
+ newpath = e_path_to_physical (imap_store->storage_path, new_name);
+
+ /* So do we care if this didn't work? Its just a cache? */
+ if (rename(oldpath, newpath) == -1) {
+ g_warning("Could not rename message cache '%s' to '%s': %s: cache reset", oldpath, newpath, strerror(errno));
+ }
+
+ g_free(oldpath);
+ g_free(newpath);
}
static CamelFolderInfo *
@@ -1646,7 +1712,7 @@ subscribe_folder (CamelStore *store, const char *folder_name,
g_hash_table_insert (imap_store->subscribed_folders,
g_strdup (folder_name), GUINT_TO_POINTER (1));
-
+
name = strrchr (folder_name, imap_store->dir_sep);
if (name)
name++;
@@ -1695,7 +1761,7 @@ unsubscribe_folder (CamelStore *store, const char *folder_name,
folder_name, &key, &value);
g_hash_table_remove (imap_store->subscribed_folders, folder_name);
g_free (key);
-
+
name = strrchr (folder_name, imap_store->dir_sep);
if (name)
name++;
diff --git a/camel/providers/imap/camel-imap-store.h b/camel/providers/imap/camel-imap-store.h
index 66ebe13f1d..25c416385e 100644
--- a/camel/providers/imap/camel-imap-store.h
+++ b/camel/providers/imap/camel-imap-store.h
@@ -91,6 +91,7 @@ struct _CamelImapStore {
guint32 capabilities, parameters;
char *namespace, dir_sep, *base_url, *storage_path;
GHashTable *authtypes, *subscribed_folders;
+
#ifdef ENABLE_THREADS
EThread *async_thread;
#endif