aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog27
-rw-r--r--mail/em-migrate.c132
-rw-r--r--mail/em-utils.c4
-rw-r--r--mail/mail-autofilter.c6
-rw-r--r--mail/mail-component.c12
-rw-r--r--mail/mail-session.c2
-rw-r--r--mail/mail-vfolder.c18
7 files changed, 181 insertions, 20 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 5fd8347b08..40f3586395 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,30 @@
+2003-11-06 Jeffrey Stedfast <fejj@ximian.com>
+
+ * mail-vfolder.c (mail_vfolder_delete_uri): User vfolder rules
+ should be in ${evolution_dir}/mail/vfolders.xml rather than
+ ${evolution_dir}/vfolders.xml
+ (mail_vfolder_rename_uri): Same.
+ (store_folder_deleted): Here too.
+ (store_folder_renamed): And here.
+ (vfolder_load_storage): Again here.
+ (vfolder_editor_response): Same.
+ (edit_rule_response): And here.
+ (new_rule_clicked): Here too.
+
+ * mail-session.c (main_get_filter_driver): User filter rules
+ should be in ${evolution_dir}/mail/filters.xml rather than
+ ${evolution_dir}/filters.xml
+
+ * mail-autofilter.c (filter_gui_add_from_message): Same.
+ (mail_filter_rename_uri): And here.
+ (mail_filter_delete_uri): Here too.
+
+ * em-utils.c (filter_editor_response): Again here.
+ (em_utils_edit_filters): Same.
+
+ * em-migrate.c (em_migrate_filter_file): Same (also for
+ vfolders.xml)
+
2003-11-05 Jeffrey Stedfast <fejj@ximian.com>
* em-migrate.[c,h]: New source files to migrate from the old mail
diff --git a/mail/em-migrate.c b/mail/em-migrate.c
index 4a4c31f904..d404abd3e0 100644
--- a/mail/em-migrate.c
+++ b/mail/em-migrate.c
@@ -43,6 +43,8 @@
#include <libxml/parser.h>
#include <libxml/xmlmemory.h>
+#include <gal/util/e-xml-utils.h>
+
#include "mail-component.h"
#include "em-migrate.h"
@@ -472,6 +474,130 @@ em_migrate_local_folders (EMMigrateSession *session)
}
+static xmlNodePtr
+xml_find_node (xmlNodePtr parent, const char *name)
+{
+ xmlNodePtr node;
+
+ node = parent->children;
+ while (node != NULL) {
+ if (node->name && !strcmp (node->name, name))
+ return node;
+
+ node = node->next;
+ }
+
+ return NULL;
+}
+
+static int
+em_migrate_filter_file (const char *evolution_dir, const char *filename, CamelException *ex)
+{
+ char *path, *uri, *new;
+ xmlNodePtr node;
+ xmlDocPtr doc;
+ int retval;
+
+ path = g_strdup_printf ("%s/evolution/%s", g_get_home_dir (), filename);
+
+ if (!(doc = xmlParseFile (path))) {
+ /* can't parse - this means nothing to upgrade */
+ g_free (path);
+ return 0;
+ }
+
+ g_free (path);
+
+ if (!(node = xmlDocGetRootElement (doc))) {
+ /* document contains no root node - nothing to upgrade */
+ xmlFreeDoc (doc);
+ return 0;
+ }
+
+ if (!node->name || strcmp (node->name, "filteroptions") != 0) {
+ /* root node is not <filteroptions>, nothing to upgrade */
+ xmlFreeDoc (doc);
+ return 0;
+ }
+
+ if (!(node = xml_find_node (node, "ruleset"))) {
+ /* no ruleset node, nothing to upgrade */
+ xmlFreeDoc (doc);
+ return 0;
+ }
+
+ node = node->children;
+ while (node != NULL) {
+ if (node->name && !strcmp (node->name, "rule")) {
+ xmlNodePtr actionset, part, val, n;
+
+ if ((actionset = xml_find_node (node, "actionset"))) {
+ /* filters.xml */
+ part = actionset->children;
+ while (part != NULL) {
+ if (part->name && !strcmp (part->name, "part")) {
+ val = part->children;
+ while (val != NULL) {
+ if (val->name && !strcmp (val->name, "value")) {
+ char *type;
+
+ type = xmlGetProp (val, "type");
+ if (type && !strcmp (type, "folder")) {
+ if ((n = xml_find_node (val, "folder"))) {
+ uri = xmlGetProp (n, "uri");
+ new = em_uri_from_camel (uri);
+ xmlFree (uri);
+
+ xmlSetProp (n, "uri", new);
+ g_free (new);
+ }
+ }
+
+ xmlFree (type);
+ }
+
+ val = val->next;
+ }
+ }
+
+ part = part->next;
+ }
+ } else if ((actionset = xml_find_node (node, "sources"))) {
+ /* vfolders.xml */
+ n = actionset->children;
+ while (n != NULL) {
+ if (n->name && !strcmp (n->name, "folder")) {
+ uri = xmlGetProp (n, "uri");
+ new = em_uri_from_camel (uri);
+ xmlFree (uri);
+
+ xmlSetProp (n, "uri", new);
+ g_free (new);
+ }
+
+ n = n->next;
+ }
+ }
+ }
+
+ node = node->next;
+ }
+
+ path = g_strdup_printf ("%s/mail/%s", evolution_dir, filename);
+ if ((retval = e_xml_save_file (path, doc)) == -1) {
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
+ _("Failed to migrate `%s': %s"),
+ filename, g_strerror (errno));
+ }
+
+ g_free (path);
+
+ xmlFreeDoc (doc);
+
+ return retval;
+}
+
+
int
em_migrate (MailComponent *component, CamelException *ex)
{
@@ -532,5 +658,11 @@ em_migrate (MailComponent *component, CamelException *ex)
camel_object_unref (session);
+ if (em_migrate_filter_file (evolution_dir, "filters.xml", ex) == -1)
+ return -1;
+
+ if (em_migrate_filter_file (evolution_dir, "vfolders.xml", ex) == -1)
+ return -1;
+
return 0;
}
diff --git a/mail/em-utils.c b/mail/em-utils.c
index 0a92c5e5f4..ab5c86c131 100644
--- a/mail/em-utils.c
+++ b/mail/em-utils.c
@@ -222,7 +222,7 @@ filter_editor_response (GtkWidget *dialog, int button, gpointer user_data)
char *user;
fc = g_object_get_data ((GObject *) dialog, "context");
- user = g_strdup_printf ("%s/filters.xml",
+ user = g_strdup_printf ("%s/mail/filters.xml",
mail_component_peek_base_directory (mail_component_peek ()));
rule_context_save ((RuleContext *) fc, user);
g_free (user);
@@ -260,7 +260,7 @@ em_utils_edit_filters (GtkWidget *parent)
}
fc = filter_context_new ();
- user = g_strdup_printf ("%s/filters.xml", base_directory);
+ user = g_strdup_printf ("%s/mail/filters.xml", base_directory);
system = EVOLUTION_PRIVDATADIR "/filtertypes.xml";
rule_context_load ((RuleContext *) fc, system, user);
g_free (user);
diff --git a/mail/mail-autofilter.c b/mail/mail-autofilter.c
index 06149ed3dd..3eee3ad8eb 100644
--- a/mail/mail-autofilter.c
+++ b/mail/mail-autofilter.c
@@ -355,7 +355,7 @@ filter_gui_add_from_message (CamelMimeMessage *msg, const char *source, int flag
g_return_if_fail (msg != NULL);
fc = filter_context_new ();
- user = g_strdup_printf ("%s/filters.xml",
+ user = g_strdup_printf ("%s/mail/filters.xml",
mail_component_peek_base_directory (mail_component_peek ()));
system = EVOLUTION_PRIVDATADIR "/filtertypes.xml";
rule_context_load ((RuleContext *)fc, system, user);
@@ -377,7 +377,7 @@ mail_filter_rename_uri(CamelStore *store, const char *olduri, const char *newuri
GList *changed;
fc = filter_context_new ();
- user = g_strdup_printf ("%s/filters.xml", mail_component_peek_base_directory (mail_component_peek ()));
+ user = g_strdup_printf ("%s/mail/filters.xml", mail_component_peek_base_directory (mail_component_peek ()));
system = EVOLUTION_PRIVDATADIR "/filtertypes.xml";
rule_context_load ((RuleContext *)fc, system, user);
@@ -402,7 +402,7 @@ mail_filter_delete_uri(CamelStore *store, const char *uri)
GList *deleted;
fc = filter_context_new ();
- user = g_strdup_printf ("%s/filters.xml", mail_component_peek_base_directory (mail_component_peek ()));
+ user = g_strdup_printf ("%s/mail/filters.xml", mail_component_peek_base_directory (mail_component_peek ()));
system = EVOLUTION_PRIVDATADIR "/filtertypes.xml";
rule_context_load ((RuleContext *)fc, system, user);
diff --git a/mail/mail-component.c b/mail/mail-component.c
index afb769564b..f22cb656b3 100644
--- a/mail/mail-component.c
+++ b/mail/mail-component.c
@@ -70,6 +70,8 @@
#include <bonobo/bonobo-widget.h>
+#define d(x) x
+
#define MESSAGE_RFC822_TYPE "message/rfc822"
#define TEXT_URI_LIST_TYPE "text/uri-list"
#define UID_LIST_TYPE "x-uid-list"
@@ -1009,7 +1011,7 @@ mail_component_init (MailComponent *component)
GtkWidget *dialog;
dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_CLOSE,
- _("Some of your mail folders were unable to be migrated:\n%s"),
+ _("The following error occured while migrating your mail data:\n%s"),
camel_exception_get_description (&ex));
g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog);
@@ -1286,8 +1288,9 @@ char *em_uri_from_camel(const char *curi)
if (path[0] == '/')
path++;
euri = g_strdup_printf("email://%s/%s", uid, path);
- printf("em uri from camel '%s' -> '%s'\n", curi, euri);
-
+
+ d(printf("em uri from camel '%s' -> '%s'\n", curi, euri));
+
return euri;
}
@@ -1313,7 +1316,6 @@ char *em_uri_to_camel(const char *euri)
g_assert(eurl->host != NULL);
if (strcmp(eurl->user, "local") == 0 && strcmp(eurl->host, "local") == 0) {
- /* FIXME: needs to track real local store location */
curi = g_strdup_printf("mbox:%s/.evolution/mail/local#%s", g_get_home_dir(), eurl->path);
camel_url_free(eurl);
return curi;
@@ -1344,7 +1346,7 @@ char *em_uri_to_camel(const char *euri)
camel_url_free(eurl);
camel_url_free(curl);
- printf("em uri to camel '%s' -> '%s'\n", euri, curi);
+ d(printf("em uri to camel '%s' -> '%s'\n", euri, curi));
return curi;
}
diff --git a/mail/mail-session.c b/mail/mail-session.c
index 1c41007c53..58773513c4 100644
--- a/mail/mail-session.c
+++ b/mail/mail-session.c
@@ -594,7 +594,7 @@ main_get_filter_driver (CamelSession *session, const char *type, CamelException
gconf = mail_config_get_gconf_client ();
- user = g_strdup_printf ("%s/filters.xml", mail_component_peek_base_directory (mail_component_peek ()));
+ user = g_strdup_printf ("%s/mail/filters.xml", mail_component_peek_base_directory (mail_component_peek ()));
system = EVOLUTION_PRIVDATADIR "/filtertypes.xml";
fc = (RuleContext *) filter_context_new ();
rule_context_load (fc, system, user);
diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c
index 0e8e81dfd4..f47fe4c660 100644
--- a/mail/mail-vfolder.c
+++ b/mail/mail-vfolder.c
@@ -471,7 +471,7 @@ mail_vfolder_delete_uri(CamelStore *store, const char *uri)
g_signal_connect_swapped (dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog);
gtk_widget_show (dialog);
- user = g_strdup_printf ("%s/vfolders.xml",
+ 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);
@@ -527,7 +527,7 @@ mail_vfolder_rename_uri(CamelStore *store, const char *from, const char *to)
char *user;
d(printf("Vfolders updated from renamed folder\n"));
- user = g_strdup_printf("%s/vfolders.xml", mail_component_peek_base_directory (mail_component_peek ()));
+ 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);
}
@@ -700,8 +700,8 @@ store_folder_deleted(CamelObject *o, void *event_data, void *data)
rule_context_remove_rule((RuleContext *)context, rule);
g_object_unref(rule);
g_signal_connect(context, "rule_removed", G_CALLBACK(context_rule_removed), context);
-
- user = g_strdup_printf("%s/vfolders.xml", mail_component_peek_base_directory (mail_component_peek ()));
+
+ 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);
} else {
@@ -742,7 +742,7 @@ store_folder_renamed(CamelObject *o, void *event_data, void *data)
filter_rule_set_name(rule, info->new->full_name);
g_signal_connect(rule, "changed", G_CALLBACK(rule_changed), folder);
- user = g_strdup_printf("%s/vfolders.xml", mail_component_peek_base_directory (mail_component_peek ()));
+ 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);
@@ -780,7 +780,7 @@ vfolder_load_storage(void)
mail_component_load_storage_by_uri(mail_component_peek (), storeuri, _("VFolders"));
/* load our rules */
- user = g_strdup_printf ("%s/vfolders.xml", mail_component_peek_base_directory (mail_component_peek ()));
+ user = g_strdup_printf ("%s/mail/vfolders.xml", mail_component_peek_base_directory (mail_component_peek ()));
context = vfolder_context_new ();
if (rule_context_load ((RuleContext *)context,
EVOLUTION_PRIVDATADIR "/vfoldertypes.xml", user) != 0) {
@@ -810,7 +810,7 @@ vfolder_editor_response (GtkWidget *dialog, int button, void *data)
{
char *user;
- user = g_strdup_printf ("%s/vfolders.xml", mail_component_peek_base_directory (mail_component_peek ()));
+ user = g_strdup_printf ("%s/mail/vfolders.xml", mail_component_peek_base_directory (mail_component_peek ()));
switch(button) {
case GTK_RESPONSE_ACCEPT:
@@ -851,7 +851,7 @@ edit_rule_response(GtkWidget *w, int button, void *data)
FilterRule *orig = g_object_get_data (G_OBJECT (w), "orig");
filter_rule_copy(orig, rule);
- user = g_strdup_printf("%s/vfolders.xml", mail_component_peek_base_directory (mail_component_peek ()));
+ 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);
}
@@ -930,7 +930,7 @@ new_rule_clicked(GtkWidget *w, int button, void *data)
g_object_ref(rule);
rule_context_add_rule((RuleContext *)context, rule);
- user = g_strdup_printf("%s/vfolders.xml", mail_component_peek_base_directory (mail_component_peek ()));
+ 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);
}