[evolution-data-server/meego-eds: 31/47] Add POP3 to a individual folder than to Local INBOX.



commit 72764deb7091c50faa92117750ff323123c17980
Author: Srinivasa Ragavan <sragavan gnome org>
Date:   Wed May 18 17:54:10 2011 +0530

    Add POP3 to a individual folder than to Local INBOX.

 mail/daemon/e-mail-data-store.c |    2 +
 mail/daemon/mail-ops.c          |   49 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+), 0 deletions(-)
---
diff --git a/mail/daemon/e-mail-data-store.c b/mail/daemon/e-mail-data-store.c
index 0645491..e669416 100644
--- a/mail/daemon/e-mail-data-store.c
+++ b/mail/daemon/e-mail-data-store.c
@@ -101,6 +101,8 @@ construct_mail_store_path (char *full_name)
 			path[i] = '_';
 		else if (path[i] == '(')
 			path[i] = '_';
+		else if (path[i] == '@')
+			path[i] = '_';
 		else if (path[i] == ')')
 			path[i] = '_';
 		else if (path[i] == ' ')
diff --git a/mail/daemon/mail-ops.c b/mail/daemon/mail-ops.c
index 9232857..06d7509 100644
--- a/mail/daemon/mail-ops.c
+++ b/mail/daemon/mail-ops.c
@@ -239,6 +239,51 @@ uid_cachename_hack (CamelStore *store)
 	return filename;
 }
 
+static CamelFolder *
+fetch_pop3_folder (const char *uri)
+{
+	CamelStore *local = e_mail_local_get_store ();
+	CamelFolder *destination=NULL;
+	EAccountList *accounts;
+	EAccount *account = NULL;
+	EIterator *iter;
+	const char *email;
+	char *folder_name;
+
+	accounts = e_get_account_list ();
+	iter = e_list_get_iterator ((EList *) accounts);
+	while (e_iterator_is_valid (iter)) {
+		account = (EAccount *) e_iterator_get (iter);
+
+		if (account->source->url && strcmp (account->source->url, uri) == 0) {
+			break;
+		}
+
+		e_iterator_next (iter);
+		account = NULL;
+	}
+
+	g_object_unref (iter);
+	email = e_account_get_string(account, E_ACCOUNT_ID_ADDRESS);
+	folder_name = g_strdup_printf ("%s/Inbox", email);
+
+	destination = camel_store_get_folder (local, folder_name, 0, NULL);
+	if (!destination) {
+		/* If its first time, create that folder. */
+		CamelFolderInfo *info;
+
+		info = camel_store_create_folder (local, NULL, folder_name, NULL);
+		if (!info) 
+			g_warning ("Unable to create POP3 folder: %s\n", folder_name);
+		else {
+			destination = camel_store_get_folder (local, folder_name, 0, NULL);
+		}
+	}
+	g_free (folder_name);
+
+	return destination;
+}
+
 static gchar *
 fetch_mail_desc (struct _fetch_mail_msg *m)
 {
@@ -298,6 +343,10 @@ fetch_mail_exec (struct _fetch_mail_msg *m)
 			if (cache) {
 				GPtrArray *folder_uids, *cache_uids, *uids;
 
+				g_object_unref (fm->destination);
+				fm->destination = fetch_pop3_folder (m->source_uri);
+				g_object_ref (fm->destination);
+
 				folder_uids = camel_folder_get_uids (folder);
 				cache_uids = camel_uid_cache_get_new_uids (cache, folder_uids);
 				if (cache_uids) {



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