aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-vfolder.c
diff options
context:
space:
mode:
Diffstat (limited to 'mail/mail-vfolder.c')
-rw-r--r--mail/mail-vfolder.c101
1 files changed, 37 insertions, 64 deletions
diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c
index 66b29de918..727ed89866 100644
--- a/mail/mail-vfolder.c
+++ b/mail/mail-vfolder.c
@@ -49,7 +49,7 @@
#include "mail-tools.h"
#include "mail-vfolder.h"
-#define d(x) /*(printf("%s(%d):%s: ", __FILE__, __LINE__, __PRETTY_FUNCTION__), (x))*/
+#define d(x) /* (printf("%s(%d):%s: ", __FILE__, __LINE__, __PRETTY_FUNCTION__), (x))*/
static EMVFolderContext *context; /* context remains open all time */
CamelStore *vfolder_store; /* the 1 static vfolder store */
@@ -453,8 +453,8 @@ mail_vfolder_add_uri(CamelStore *store, const char *curi, int remove)
LOCK();
- d(printf("%s uri to check: %s\n", remove?"Removing":"Adding", uri));
-
+/* d(printf("%s uri to check: %s\n", remove?"Removing":"Adding", uri)); */
+
/* maintain the source folders lists for changed rules later on */
if (CAMEL_IS_VEE_STORE(store)) {
is_ignore = TRUE;
@@ -489,7 +489,6 @@ mail_vfolder_add_uri(CamelStore *store, const char *curi, int remove)
d(printf("invalid rule (%p): rule->name is set to NULL\n", rule));
continue;
}
-
/* dont auto-add any sent/drafts folders etc, they must be explictly listed as a source */
if (rule->source
&& !is_ignore
@@ -501,7 +500,6 @@ mail_vfolder_add_uri(CamelStore *store, const char *curi, int remove)
source = NULL;
while (!found && (source = em_vfolder_rule_next_source((EMVFolderRule *)rule, source))) {
char *csource;
-
csource = em_uri_to_camel(source);
found = camel_store_folder_uri_equal(store, curi, csource);
d(printf(found?" '%s' == '%s'?\n":" '%s' != '%s'\n", curi, csource));
@@ -664,6 +662,18 @@ mail_vfolder_rename_uri(CamelStore *store, const char *cfrom, const char *cto)
g_free(to);
}
+GList *
+mail_vfolder_get_sources_local ()
+{
+ return source_folders_local;
+}
+
+GList *
+mail_vfolder_get_sources_remote ()
+{
+ return source_folders_remote;
+}
+
/* ********************************************************************** */
static void context_rule_added(RuleContext *ctx, FilterRule *rule);
@@ -834,80 +844,43 @@ store_folder_deleted(CamelObject *o, void *event_data, void *data)
UNLOCK();
}
-static int
-store_folder_renamed_rec(char *prefix, int ignore, CamelFolderInfo *new)
-{
- int changed = 0;
- FilterRule *rule;
- char *key;
- GString *old = g_string_new(prefix);
- CamelFolder *folder;
-
- while (new) {
- if (new->child)
- changed |= store_folder_renamed_rec(prefix, ignore, new->child);
-
- g_string_truncate(old, strlen(prefix));
- g_string_append(old, new->full_name+ignore);
-
- d(printf("Changing folder name in hash table to '%s'\n", new->full_name));
- if (g_hash_table_lookup_extended(vfolder_hash, old->str, (void **)&key, (void **)&folder)) {
- g_hash_table_remove(vfolder_hash, key);
- g_hash_table_insert(vfolder_hash, g_strdup(new->full_name), folder);
-
- rule = rule_context_find_rule((RuleContext *)context, key, NULL);
- g_free(key);
- g_assert(rule);
- g_signal_handlers_disconnect_matched(rule, G_SIGNAL_MATCH_FUNC|G_SIGNAL_MATCH_DATA, 0,
- 0, NULL, rule_changed, folder);
- filter_rule_set_name(rule, new->full_name);
- g_signal_connect(rule, "changed", G_CALLBACK(rule_changed), folder);
- changed = 1;
- } else {
- g_warning("couldn't find a vfolder rule in our table? %s", new->full_name);
- }
- new = new->next;
- }
-
- g_string_free(old, TRUE);
- return changed;
-}
-
static void
store_folder_renamed(CamelObject *o, void *event_data, void *data)
{
CamelRenameInfo *info = event_data;
- char *end, *prefix;
- int ignore;
-
+ FilterRule *rule;
+ char *user;
+ char *key;
+ CamelFolder *folder;
+
/* This should be more-or-less thread-safe */
d(printf("Folder renamed to '%s' from '%s'\n", info->new->full_name, info->old_base));
/* Folder is already renamed? */
LOCK();
- end = strrchr(info->new->full_name, '/');
- if (end == NULL) {
- ignore = 0;
- end = strrchr(info->old_base, '/');
- if (end) {
- prefix = g_alloca(end-info->old_base+2);
- memcpy(prefix, info->old_base, end-info->old_base+1);
- prefix[end-info->old_base+1] = 0;
- } else
- prefix = "";
- } else {
- ignore = end-info->new->full_name+1;
- prefix = "";
- }
- if (store_folder_renamed_rec(prefix, ignore, info->new)) {
- char *user;
+ d(printf("Changing folder name in hash table to '%s'\n", info->new->full_name));
+ if (g_hash_table_lookup_extended(vfolder_hash, info->old_base, (void **)&key, (void **)&folder)) {
+ g_hash_table_remove(vfolder_hash, key);
+ g_free(key);
+ g_hash_table_insert(vfolder_hash, g_strdup(info->new->full_name), folder);
+
+ rule = rule_context_find_rule((RuleContext *)context, info->old_base, NULL);
+ g_assert(rule);
+ g_signal_handlers_disconnect_matched(rule, G_SIGNAL_MATCH_FUNC|G_SIGNAL_MATCH_DATA, 0,
+ 0, NULL, rule_changed, folder);
+ filter_rule_set_name(rule, info->new->full_name);
+ g_signal_connect(rule, "changed", G_CALLBACK(rule_changed), folder);
user = g_strdup_printf("%s/mail/vfolders.xml", mail_component_peek_base_directory (mail_component_peek ()));
rule_context_save((RuleContext *)context, user);
g_free(user);
+
+ UNLOCK();
+ } else {
+ UNLOCK();
+ g_warning("couldn't find a vfolder rule in our table? %s", info->new->full_name);
}
- UNLOCK();
}
void