[evolution-data-server] Bug 610774 - IMAPX : automatic filtering doesn't work



commit aa588cb1b32e90eab43a383c733875735cd8ed9f
Author: Chenthill Palanisamy <pchenthill novell com>
Date:   Thu Mar 11 16:44:43 2010 +0530

    Bug 610774 - IMAPX : automatic filtering doesn't work

 camel/providers/imapx/camel-imapx-folder.c |   14 ++++++++++++++
 camel/providers/imapx/camel-imapx-folder.h |    5 ++++-
 camel/providers/imapx/camel-imapx-server.c |   18 +++++++++++++++++-
 camel/providers/imapx/camel-imapx-store.h  |    3 +++
 4 files changed, 38 insertions(+), 2 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-folder.c b/camel/providers/imapx/camel-imapx-folder.c
index cc3fdd2..ad24664 100644
--- a/camel/providers/imapx/camel-imapx-folder.c
+++ b/camel/providers/imapx/camel-imapx-folder.c
@@ -63,6 +63,7 @@ camel_imapx_folder_new(CamelStore *store, const gchar *folder_dir, const gchar *
 	CamelIMAPXFolder *ifolder;
 	const gchar *short_name;
 	gchar *summary_file;
+	CamelIMAPXStore *istore;
 
 	d(printf("opening imap folder '%s'\n", folder_dir));
 
@@ -97,9 +98,19 @@ camel_imapx_folder_new(CamelStore *store, const gchar *folder_dir, const gchar *
 
 	ifolder->search = camel_folder_search_new ();
 	ifolder->search_lock = g_mutex_new ();
+	ifolder->ignore_recent = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify) g_free, NULL); 
 	ifolder->exists_on_server = 0;
 	ifolder->unread_on_server = 0;
 
+	istore = (CamelIMAPXStore *) store;
+	if (!g_ascii_strcasecmp (folder_name, "INBOX")) {
+		if ((istore->rec_options & IMAPX_FILTER_INBOX))
+			folder->folder_flags |= CAMEL_FOLDER_FILTER_RECENT;
+		if ((istore->rec_options & IMAPX_FILTER_INBOX))
+			folder->folder_flags |= CAMEL_FOLDER_FILTER_JUNK;
+	} else if ((istore->rec_options & (IMAPX_FILTER_JUNK | IMAPX_FILTER_JUNK_INBOX)) == IMAPX_FILTER_JUNK)
+			folder->folder_flags |= CAMEL_FOLDER_FILTER_JUNK;	
+
 	g_free (summary_file);
 
 	return folder;
@@ -412,6 +423,9 @@ imapx_finalize (CamelObject *object)
 	CamelIMAPXFolder *ifolder = (CamelIMAPXFolder *) object;
 
 	camel_object_unref (CAMEL_OBJECT (ifolder->cache));
+	
+	if (ifolder->ignore_recent)
+		g_hash_table_unref (ifolder->ignore_recent);
 
 	g_mutex_free (ifolder->search_lock);
 	if (ifolder->search)
diff --git a/camel/providers/imapx/camel-imapx-folder.h b/camel/providers/imapx/camel-imapx-folder.h
index e005ad7..3a385a2 100644
--- a/camel/providers/imapx/camel-imapx-folder.h
+++ b/camel/providers/imapx/camel-imapx-folder.h
@@ -47,7 +47,10 @@ typedef struct _CamelIMAPXFolder {
 
 	guint32 exists_on_server;
 	guint32 unread_on_server;
-
+	
+	/* hash table of UIDs to ignore as recent when updating folder */
+	GHashTable *ignore_recent;
+	
 	GMutex *search_lock;
 } CamelIMAPXFolder;
 
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index 649236c..74c52a3 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -1326,10 +1326,17 @@ imapx_untagged(CamelIMAPXServer *imap, CamelException *ex)
 					binfo->size = finfo->size;
 
 					if (!camel_folder_summary_check_uid (job->folder->summary, mi->uid)) {
+						CamelIMAPXFolder *ifolder = (CamelIMAPXFolder *)job->folder;
+						
 						camel_folder_summary_add(job->folder->summary, mi);
 						imapx_set_message_info_flags_for_new_message (mi, server_flags, server_user_flags, job->folder);
 						camel_folder_change_info_add_uid (job->u.refresh_info.changes, mi->uid);
 
+						if (!g_hash_table_lookup (ifolder->ignore_recent, mi->uid)) {
+							camel_folder_change_info_recent_uid (job->u.refresh_info.changes, mi->uid);
+							g_hash_table_remove (ifolder->ignore_recent, mi->uid);
+						}
+
 						if (job->op)
 							camel_operation_progress (job->op, (camel_folder_summary_count (job->folder->summary) * 100)/imap->exists);
 					}
@@ -2504,7 +2511,16 @@ imapx_command_copy_messages_step_done (CamelIMAPXServer *is, CamelIMAPXCommand *
 
 	/* TODO copy the summary and cached messages to the new folder. We might need a sorted insert to avoid refreshing the dest folder */
 	if (ic->status->condition == IMAPX_COPYUID) {
-
+		gint i;
+		
+		for (i = 0; i < ic->status->u.copyuid.copied_uids->len; i++) {
+			guint32 uid = GPOINTER_TO_UINT(g_ptr_array_index (ic->status->u.copyuid.copied_uids, i));
+			gchar *str = g_strdup_printf ("%d",uid);
+			CamelIMAPXFolder *ifolder = (CamelIMAPXFolder *) job->u.copy_messages.dest;
+			
+			g_hash_table_insert (ifolder->ignore_recent, str, GINT_TO_POINTER (1));
+		}
+				
 	}
 
 	if (i < uids->len) {
diff --git a/camel/providers/imapx/camel-imapx-store.h b/camel/providers/imapx/camel-imapx-store.h
index c28eaad..652a795 100644
--- a/camel/providers/imapx/camel-imapx-store.h
+++ b/camel/providers/imapx/camel-imapx-store.h
@@ -62,6 +62,9 @@ typedef struct {
 	   moment, could not find anything suitable for this */
 	GMutex *get_finfo_lock;
 	time_t last_refresh_time;
+	
+	/* hash table of UIDs to ignore as recent when updating folder */
+	GHashTable *ignore_recent;
 
 	/* if we had a login error, what to show to user */
 	gchar *login_error;



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