[evolution] Bug #638307 - Error when sending mail after converting to maildir



commit 2c4c8af58d44fc73e4f7048476a6fa55573d5e0b
Author: Milan Crha <mcrha redhat com>
Date:   Fri Jun 17 11:45:00 2011 +0200

    Bug #638307 - Error when sending mail after converting to maildir

 mail/e-mail-migrate.c |   76 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 76 insertions(+), 0 deletions(-)
---
diff --git a/mail/e-mail-migrate.c b/mail/e-mail-migrate.c
index 9553c8b..4dad4d1 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);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]