[evolution-kolab/gnome-3-4: 4/4] CamelIMAPXExtdServer: updated for upstream fixes



commit eccb8c15dbf49869b7cf2225de259cce91611055
Author: Christian Hilberg <hilberg kernelconcepts de>
Date:   Wed May 30 19:17:38 2012 +0200

    CamelIMAPXExtdServer: updated for upstream fixes
    
    * updated for upstream CamelIMAPXServer fixes
      (#676403, #676506, #667725)
    * updated refresh data structure local dupe

 .../providers/imapx/camel-imapx-extd-server.c      |   40 +++++++++++++++----
 .../providers/imapx/camel-imapx-server-defs.h      |    1 +
 2 files changed, 32 insertions(+), 9 deletions(-)
---
diff --git a/src/camel/providers/imapx/camel-imapx-extd-server.c b/src/camel/providers/imapx/camel-imapx-extd-server.c
index 8fed359..f71ddfb 100644
--- a/src/camel/providers/imapx/camel-imapx-extd-server.c
+++ b/src/camel/providers/imapx/camel-imapx-extd-server.c
@@ -245,6 +245,7 @@ extd_server_untagged (CamelIMAPXExtdServer *self,
 	}
 	case IMAPX_VANISHED: {
 		GPtrArray *uids;
+		GList *uid_list = NULL;
 		gboolean unsolicited = TRUE;
 		gint i;
 		guint len;
@@ -268,11 +269,30 @@ extd_server_untagged (CamelIMAPXExtdServer *self,
 		uids = imapx_parse_uids (is->stream, cancellable, error);
 		if (uids == NULL)
 			return FALSE;
+
+		if (unsolicited) {
+			CamelIMAPXFolder *ifolder = (CamelIMAPXFolder *)is->select_folder;
+
+			if (ifolder->exists_on_server < uids->len) {
+				c(is->tagprefix, "Error: exists_on_folder %d is fewer than vanished %d\n",
+				  ifolder->exists_on_server, uids->len);
+				ifolder->exists_on_server = 0;
+			} else
+				ifolder->exists_on_server -= uids->len;
+		}
+		if (is->changes == NULL)
+			is->changes = camel_folder_change_info_new ();
+
 		for (i = 0; i < uids->len; i++) {
 			gchar *uid = g_strdup_printf("%u", GPOINTER_TO_UINT(g_ptr_array_index (uids, i)));
+
 			c(is->tagprefix, "vanished: %s\n", uid);
-			camel_imapx_server_expunge_uid_from_summary (is, uid, unsolicited);
+
+			uid_list = g_list_append(uid_list, uid);
+			camel_folder_change_info_remove_uid (is->changes, uid);
 		}
+		camel_folder_summary_remove_uids(is->select_folder->summary, uid_list);
+		is->expunged = g_list_concat(is->expunged, uid_list);
 		g_ptr_array_free (uids, FALSE);
 		break;
 	}
@@ -351,17 +371,19 @@ extd_server_untagged (CamelIMAPXExtdServer *self,
 
 		if ((finfo->got & FETCH_FLAGS) && !(finfo->got & FETCH_HEADER)) {
 			CamelIMAPXJob *job = camel_imapx_server_match_active_job (is, IMAPX_JOB_FETCH_NEW_MESSAGES | IMAPX_JOB_REFRESH_INFO, NULL);
+			RefreshInfoData *data = NULL;
+
+			if (job) {
+				data = camel_imapx_job_get_data (job);
+				g_return_val_if_fail (data != NULL, FALSE);
+			}
+
 			/* This is either a refresh_info job, check to see if it is and update
 			 * if so, otherwise it must've been an unsolicited response, so update
 			 * the summary to match */
-
-			if (job && (finfo->got & FETCH_UID)) {
-				RefreshInfoData *data;
+			if (data && (finfo->got & FETCH_UID) && data->scan_changes) {
 				struct _refresh_info r;
 
-				data = camel_imapx_job_get_data (job);
-				g_return_val_if_fail (data != NULL, FALSE);
-
 				r.uid = finfo->uid;
 				finfo->uid = NULL;
 				r.server_flags = finfo->flags;
@@ -457,7 +479,7 @@ extd_server_untagged (CamelIMAPXExtdServer *self,
 						g_return_val_if_fail (data != NULL, FALSE);
 
 						min = data->last_index;
-						max = data->index;
+						max = data->index - 1;
 
 						/* array is sorted, so use a binary search */
 						do {
@@ -517,8 +539,8 @@ extd_server_untagged (CamelIMAPXExtdServer *self,
 						data = camel_imapx_job_get_data (job);
 						g_return_val_if_fail (data != NULL, FALSE);
 
-						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_summary_add (job->folder->summary, mi);
 						camel_folder_change_info_add_uid (data->changes, mi->uid);
 
 						if (!g_hash_table_lookup (ifolder->ignore_recent, mi->uid)) {
diff --git a/src/camel/providers/imapx/camel-imapx-server-defs.h b/src/camel/providers/imapx/camel-imapx-server-defs.h
index d8bc86d..3278e56 100644
--- a/src/camel/providers/imapx/camel-imapx-server-defs.h
+++ b/src/camel/providers/imapx/camel-imapx-server-defs.h
@@ -92,6 +92,7 @@ struct _RefreshInfoData {
 	gint fetch_msg_limit;
 	CamelFetchType fetch_type;
 	gboolean update_unseen;
+	gboolean scan_changes;
 	struct _uidset_state uidset;
 	/* changes during refresh */
 	CamelFolderChangeInfo *changes;



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