aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-vfolder.c
diff options
context:
space:
mode:
author6 <NotZed@Ximian.com>2001-10-27 14:02:04 +0800
committerMichael Zucci <zucchi@src.gnome.org>2001-10-27 14:02:04 +0800
commit8f8b24c737a907f91b88bf0b2b985d56b4051848 (patch)
tree8af1be6e77686cb935ae5a21ac17d7b14a9b0463 /mail/mail-vfolder.c
parentc4d87ba45ad016d5a6607df96ed27ba02910e2e6 (diff)
downloadgsoc2013-evolution-8f8b24c737a907f91b88bf0b2b985d56b4051848.tar.gz
gsoc2013-evolution-8f8b24c737a907f91b88bf0b2b985d56b4051848.tar.zst
gsoc2013-evolution-8f8b24c737a907f91b88bf0b2b985d56b4051848.zip
Changed to open the source store from '/', so we can do renames across
2001-10-26 <NotZed@Ximian.com> * mail-local.c (mlf_set_folder): Changed to open the source store from '/', so we can do renames across directories. Of course, this doesn't quite work with different filesystems, but we'll assume this isn't a problem we're going to have. (mail_local_folder_get_type): Setup parent_class. (mlf_rename): Implement folder rename call, rename internal data. Is this a security issue? Well, not really, no more than anything else. * mail-folder-cache.c (mail_note_store): Listen to rename event. (store_folder_renamed): Function to handle it, empty. (mail_note_store_remove): Unhook from rename event. (mail_note_folder): Hook onto renamed event. (unset_folder_info): Unhook from renamed event. (folder_finalised): Lock around update. (folder_deleted): Lock around update. (real_flush_updates): If we have a path to remove remove it. (rename_folders): Scan folderinfo's, if we can find ones renamed, rename them, otherwise add them. * component-factory.c (owner_unset_cb): Use a timeout not an idle handler. (storage_xfer_folder): Implementation of xfer_folder signal handler, so we can rename imap/vfolders/etc. svn path=/trunk/; revision=14205
Diffstat (limited to 'mail/mail-vfolder.c')
-rw-r--r--mail/mail-vfolder.c61
1 files changed, 55 insertions, 6 deletions
diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c
index 2132d8b699..d4c979060f 100644
--- a/mail/mail-vfolder.c
+++ b/mail/mail-vfolder.c
@@ -44,7 +44,7 @@
#include "e-util/e-unicode-i18n.h"
-#define d(x)
+#define d(x) x
static VfolderContext *context; /* context remains open all time */
static CamelStore *vfolder_store; /* the 1 static vfolder store */
@@ -458,16 +458,30 @@ rule_changed(FilterRule *rule, CamelFolder *folder)
char *path, *key;
CamelFolder *old;
- gtk_signal_disconnect_by_func((GtkObject *)rule, rule_changed, folder);
-
- context_rule_added((RuleContext *)context, rule);
+ LOCK();
+ if (g_hash_table_lookup_extended(vfolder_hash, folder->full_name, (void **)&key, (void **)&old)) {
+ g_hash_table_remove(vfolder_hash, key);
+ g_free(key);
+ g_hash_table_insert(vfolder_hash, g_strdup(rule->name), folder);
+ UNLOCK();
+ } else {
+ UNLOCK();
+ g_warning("couldn't find a vfolder rule in our table? %s", folder->full_name);
+ }
- /* TODO: remove folder from folder info cache? */
+ camel_store_rename_folder(vfolder_store, folder->full_name, rule->name, NULL);
+#if 0
path = g_strdup_printf("/%s", folder->full_name);
evolution_storage_removed_folder(mail_lookup_storage(vfolder_store), path);
g_free(path);
+ gtk_signal_disconnect_by_func((GtkObject *)rule, rule_changed, folder);
+
+ context_rule_added((RuleContext *)context, rule);
+
+ /* TODO: remove folder from folder info cache? */
+
LOCK();
if (g_hash_table_lookup_extended(vfolder_hash, folder->full_name, (void **)&key, (void **)&old)) {
g_hash_table_remove(vfolder_hash, key);
@@ -480,6 +494,7 @@ rule_changed(FilterRule *rule, CamelFolder *folder)
}
return;
+#endif
}
d(printf("Filter rule changed? for folder '%s'!!\n", folder->name));
@@ -595,8 +610,12 @@ store_folder_deleted(CamelObject *o, void *event_data, void *data)
d(printf("Folder deleted: %s\n", info->name));
store = store;
+ /* WARNING: Not thread safe, joy! */
+
+ LOCK();
+
/* delete it from our list */
- rule = rule_context_find_rule((RuleContext *)context, info->name, NULL);
+ rule = rule_context_find_rule((RuleContext *)context, info->full_name, NULL);
if (rule) {
/* We need to stop listening to removed events, otherwise we'll try and remove it again */
gtk_signal_disconnect_by_func((GtkObject *)context, context_rule_removed, context);
@@ -610,6 +629,34 @@ store_folder_deleted(CamelObject *o, void *event_data, void *data)
} else {
g_warning("Cannot find rule for deleted vfolder '%s'", info->name);
}
+
+ UNLOCK();
+}
+
+static void
+store_folder_renamed(CamelObject *o, void *event_data, void *data)
+{
+ CamelStore *store = (CamelStore *)o;
+ CamelRenameInfo *info = event_data;
+ FilterRule *rule;
+ char *user;
+
+ /* TODO: Scan all sub-folders? */
+
+ printf("Folder renamed to '%s' from '%s'\n", info->new->full_name, info->old_base);
+
+ rule = rule_context_find_rule((RuleContext *)context, info->old_base, NULL);
+ if (rule) {
+ /* TODO: We need to stop listening to removed events, otherwise we'll try and rename it again? */
+
+ filter_rule_set_name(rule, info->new->name);
+
+ user = g_strdup_printf("%s/vfolders.xml", evolution_dir);
+ rule_context_save((RuleContext *)context, user);
+ g_free(user);
+ } else {
+ /* We just got it inside renaming it ourself, ignore */
+ }
}
void
@@ -632,6 +679,8 @@ vfolder_load_storage(GNOME_Evolution_Shell shell)
(CamelObjectEventHookFunc)store_folder_created, NULL);
camel_object_hook_event((CamelObject *)vfolder_store, "folder_deleted",
(CamelObjectEventHookFunc)store_folder_deleted, NULL);
+ camel_object_hook_event((CamelObject *)vfolder_store, "folder_renamed",
+ (CamelObjectEventHookFunc)store_folder_renamed, NULL);
d(printf("got store '%s' = %p\n", storeuri, vfolder_store));
mail_load_storage_by_uri(shell, storeuri, U_("VFolders"));