[evolution/webkit] Bug #643218 - Local delivery doesn't deliver after maildir migration



commit 67ad94622bcf14315d4da791b40ee60efd1dec19
Author: Milan Crha <mcrha redhat com>
Date:   Thu Mar 3 14:11:41 2011 +0100

    Bug #643218 - Local delivery doesn't deliver after maildir migration

 mail/e-mail-store.c   |    5 +++++
 mail/em-utils.c       |   24 ++++++++++++++++++++++++
 mail/em-utils.h       |    2 ++
 mail/mail-ops.c       |    2 +-
 mail/mail-send-recv.c |    7 ++++---
 mail/mail-tools.c     |    2 +-
 6 files changed, 37 insertions(+), 5 deletions(-)
---
diff --git a/mail/e-mail-store.c b/mail/e-mail-store.c
index 9dfaab6..e5607ef 100644
--- a/mail/e-mail-store.c
+++ b/mail/e-mail-store.c
@@ -30,6 +30,7 @@
 
 #include "mail/e-mail-local.h"
 #include "mail/em-folder-tree-model.h"
+#include "mail/em-utils.h"
 #include "mail/mail-folder-cache.h"
 #include "mail/mail-mt.h"
 #include "mail/mail-ops.h"
@@ -251,6 +252,10 @@ mail_store_load_accounts (EMailSession *session,
 		if (uri == NULL || *uri == '\0')
 			continue;
 
+		/* do not add local-delivery files into the tree those are server specifically */
+		if (em_utils_is_local_delivery_mbox_file (uri))
+			continue;
+
 		e_mail_store_add_by_uri (session, uri, display_name);
 	}
 
diff --git a/mail/em-utils.c b/mail/em-utils.c
index 2fdee28..09692f0 100644
--- a/mail/em-utils.c
+++ b/mail/em-utils.c
@@ -2353,3 +2353,27 @@ emu_restore_folder_tree_state (EMFolderTree *folder_tree)
 
 	g_key_file_free (key_file);
 }
+
+/* checks whether uri points to a local mbox file and returns TRUE if yes. */
+gboolean
+em_utils_is_local_delivery_mbox_file (const gchar *uri)
+{
+	g_return_val_if_fail (uri != NULL, FALSE);
+
+	if (g_str_has_prefix (uri, "mbox:///")) {
+		CamelURL *curl;
+
+		curl = camel_url_new (uri, NULL);
+		if (curl) {
+			if (curl->path
+			    && g_file_test (curl->path, G_FILE_TEST_EXISTS)
+			    && !g_file_test (curl->path, G_FILE_TEST_IS_DIR)) {
+				camel_url_free (curl);
+				return TRUE;
+			}
+			camel_url_free (curl);
+		}
+	}
+
+	return FALSE;
+}
diff --git a/mail/em-utils.h b/mail/em-utils.h
index 2b45b37..73916b1 100644
--- a/mail/em-utils.h
+++ b/mail/em-utils.h
@@ -102,6 +102,8 @@ void emu_free_mail_cache (void);
 
 void emu_restore_folder_tree_state (EMFolderTree *folder_tree);
 
+gboolean em_utils_is_local_delivery_mbox_file (const gchar *uri);
+
 G_END_DECLS
 
 #endif /* __EM_UTILS_H__ */
diff --git a/mail/mail-ops.c b/mail/mail-ops.c
index 920b8bc..79fce90 100644
--- a/mail/mail-ops.c
+++ b/mail/mail-ops.c
@@ -241,7 +241,7 @@ fetch_mail_exec (struct _fetch_mail_msg *m,
 
 	/* FIXME: this should support keep_on_server too, which would then perform a spool
 	   access thingy, right?  problem is matching raw messages to uid's etc. */
-	if (!strncmp (m->source_uri, "maildir:", 5)) {
+	if (em_utils_is_local_delivery_mbox_file (m->source_uri)) {
 		gchar *path = mail_tool_do_movemail (m->source_uri, error);
 
 		if (path && (!error || !*error)) {
diff --git a/mail/mail-send-recv.c b/mail/mail-send-recv.c
index 3ca7b23..e548d8b 100644
--- a/mail/mail-send-recv.c
+++ b/mail/mail-send-recv.c
@@ -39,6 +39,7 @@
 #include "e-mail-session.h"
 #include "em-event.h"
 #include "em-filter-rule.h"
+#include "em-utils.h"
 #include "mail-folder-cache.h"
 #include "mail-mt.h"
 #include "mail-ops.h"
@@ -382,9 +383,9 @@ get_receive_type (const gchar *url)
 {
 	CamelProvider *provider;
 
-	/* HACK: since mbox is ALSO used for native evolution trees now, we need to
-	   fudge this to treat it as a special 'movemail' source */
-	if (!strncmp(url, "maildir:", 8))
+	/* mbox pointing to a file is a 'Local delivery' source
+	   which requires special processing */
+	if (em_utils_is_local_delivery_mbox_file (url))
 		return SEND_RECEIVE;
 
 	provider = camel_provider_get (url, NULL);
diff --git a/mail/mail-tools.c b/mail/mail-tools.c
index 4bb006d..1e1680b 100644
--- a/mail/mail-tools.c
+++ b/mail/mail-tools.c
@@ -94,7 +94,7 @@ mail_tool_do_movemail (const gchar *source_url, GError **error)
 	if (uri == NULL)
 		return NULL;
 
-	if (strcmp(uri->protocol, "maildir") != 0) {
+	if (strcmp (uri->protocol, "mbox") != 0) {
 		/* This is really only an internal error anyway */
 		g_set_error (
 			error, CAMEL_SERVICE_ERROR,



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