aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2011-06-17 17:45:00 +0800
committerRodrigo Moya <rodrigo@gnome-db.org>2011-06-30 00:42:30 +0800
commit6f29c40dbf49e4c2af91fcde0738925d4d8e3974 (patch)
tree6125dc76f26c2579a1c19e64dfc37980c303dd8e /mail
parent41b7c5a007e86a4970d88baef5a8d19866fd3d5f (diff)
downloadgsoc2013-evolution-6f29c40dbf49e4c2af91fcde0738925d4d8e3974.tar
gsoc2013-evolution-6f29c40dbf49e4c2af91fcde0738925d4d8e3974.tar.gz
gsoc2013-evolution-6f29c40dbf49e4c2af91fcde0738925d4d8e3974.tar.bz2
gsoc2013-evolution-6f29c40dbf49e4c2af91fcde0738925d4d8e3974.tar.lz
gsoc2013-evolution-6f29c40dbf49e4c2af91fcde0738925d4d8e3974.tar.xz
gsoc2013-evolution-6f29c40dbf49e4c2af91fcde0738925d4d8e3974.tar.zst
gsoc2013-evolution-6f29c40dbf49e4c2af91fcde0738925d4d8e3974.zip
Bug #638307 - Error when sending mail after converting to maildir
Diffstat (limited to 'mail')
-rw-r--r--mail/e-mail-migrate.c76
1 files changed, 76 insertions, 0 deletions
diff --git a/mail/e-mail-migrate.c b/mail/e-mail-migrate.c
index 9553c8b62a..4dad4d15d7 100644
--- a/mail/e-mail-migrate.c
+++ b/mail/e-mail-migrate.c
@@ -64,6 +64,7 @@
#include "e-mail-backend.h"
#include "e-mail-folder-utils.h"
+#include "e-mail-local.h"
#include "e-mail-store.h"
#include "em-utils.h"
@@ -1085,6 +1086,80 @@ exit:
return TRUE;
}
+static void
+change_sent_and_drafts_local_folders (EShellBackend *shell_backend)
+{
+ EAccountList *accounts;
+ EIterator *iter;
+ const gchar *data_dir;
+ gboolean changed = FALSE;
+ CamelURL *url;
+ gchar *tmp_uri, *drafts_uri, *sent_uri, *old_drafts_uri, *old_sent_uri;
+
+ accounts = e_get_account_list ();
+ if (!accounts)
+ return;
+
+ data_dir = e_shell_backend_get_data_dir (shell_backend);
+
+ tmp_uri = g_strconcat ("mbox:", data_dir, "/", "local", NULL);
+ url = camel_url_new (tmp_uri, NULL);
+ g_free (tmp_uri);
+
+ g_return_if_fail (url != NULL);
+
+ camel_url_set_fragment (url, "Drafts");
+ drafts_uri = camel_url_to_string (url, CAMEL_URL_HIDE_ALL);
+
+ camel_url_set_fragment (url, "Sent");
+ sent_uri = camel_url_to_string (url, CAMEL_URL_HIDE_ALL);
+
+ camel_url_free (url);
+
+ tmp_uri = g_strconcat ("mbox:", g_get_home_dir (), "/.evolution/mail/local", NULL);
+ url = camel_url_new (tmp_uri, NULL);
+ g_free (tmp_uri);
+
+ g_return_if_fail (url != NULL);
+
+ camel_url_set_fragment (url, "Drafts");
+ old_drafts_uri = camel_url_to_string (url, CAMEL_URL_HIDE_ALL);
+
+ camel_url_set_fragment (url, "Sent");
+ old_sent_uri = camel_url_to_string (url, CAMEL_URL_HIDE_ALL);
+
+ camel_url_free (url);
+
+ for (iter = e_list_get_iterator ((EList *) accounts); e_iterator_is_valid (iter); e_iterator_next (iter)) {
+ EAccount *account = (EAccount *) e_iterator_get (iter);
+ const gchar *uri;
+
+ if (!account)
+ continue;
+
+ uri = e_account_get_string (account, E_ACCOUNT_DRAFTS_FOLDER_URI);
+ if (g_strcmp0 (uri, drafts_uri) == 0 || g_strcmp0 (uri, old_drafts_uri) == 0) {
+ changed = TRUE;
+ e_account_set_string (account, E_ACCOUNT_DRAFTS_FOLDER_URI, e_mail_local_get_folder_uri (E_MAIL_LOCAL_FOLDER_DRAFTS));
+ }
+
+ uri = e_account_get_string (account, E_ACCOUNT_SENT_FOLDER_URI);
+ if (g_strcmp0 (uri, sent_uri) == 0 || g_strcmp0 (uri, old_sent_uri) == 0 ) {
+ changed = TRUE;
+ e_account_set_string (account, E_ACCOUNT_SENT_FOLDER_URI, e_mail_local_get_folder_uri (E_MAIL_LOCAL_FOLDER_SENT));
+ }
+ }
+
+ g_object_unref (iter);
+ g_free (old_drafts_uri);
+ g_free (drafts_uri);
+ g_free (old_sent_uri);
+ g_free (sent_uri);
+
+ if (changed)
+ e_account_list_save (accounts);
+}
+
static gboolean
migrate_local_store (EShellBackend *shell_backend)
{
@@ -1115,6 +1190,7 @@ migrate_local_store (EShellBackend *shell_backend)
migrate_mbox_to_maildir (shell_backend, session);
create_mbox_account (shell_backend, session);
+ change_sent_and_drafts_local_folders (shell_backend);
g_object_unref (session);