[evolution-kolab/gnome-3-4: 1/4] updated IMAPX files as of EDS commit f86152ced36d6d28a6d86c01da40000cbbaee5cf



commit 112edecd51d29ee1571208e47529b32b433e6396
Author: Christian Hilberg <hilberg kernelconcepts de>
Date:   Wed May 30 18:04:48 2012 +0200

    updated IMAPX files as of EDS commit f86152ced36d6d28a6d86c01da40000cbbaee5cf
    
    * updated the local IMAPX code from upstream
    * now at EDS commit
      f86152ced36d6d28a6d86c01da40000cbbaee5cf

 src/camel/providers/imapx/camel-imapx-folder.c |   17 ++++
 src/camel/providers/imapx/camel-imapx-server.c |   94 ++++++++++++++++++++----
 2 files changed, 95 insertions(+), 16 deletions(-)
---
diff --git a/src/camel/providers/imapx/camel-imapx-folder.c b/src/camel/providers/imapx/camel-imapx-folder.c
index f73fe70..23bbbf5 100644
--- a/src/camel/providers/imapx/camel-imapx-folder.c
+++ b/src/camel/providers/imapx/camel-imapx-folder.c
@@ -551,6 +551,23 @@ imapx_get_message_sync (CamelFolder *folder,
 		}
 		g_mutex_unlock (ifolder->stream_lock);
 		g_object_unref (stream);
+
+		if (msg) {
+			CamelMessageInfo *mi = camel_folder_summary_get (folder->summary, uid);
+
+			if (mi) {
+				gboolean has_attachment;
+
+				has_attachment = camel_mime_message_has_attachment (msg);
+				if (((camel_message_info_flags (mi) & CAMEL_MESSAGE_ATTACHMENTS) && !has_attachment) ||
+				    ((camel_message_info_flags (mi) & CAMEL_MESSAGE_ATTACHMENTS) == 0 && has_attachment)) {
+					camel_message_info_set_flags (mi,
+						CAMEL_MESSAGE_ATTACHMENTS, has_attachment ? CAMEL_MESSAGE_ATTACHMENTS : 0);
+				}
+
+				camel_message_info_free (mi);
+			}
+		}
 	}
 
 	return msg;
diff --git a/src/camel/providers/imapx/camel-imapx-server.c b/src/camel/providers/imapx/camel-imapx-server.c
index 35e4384..f4819ef 100644
--- a/src/camel/providers/imapx/camel-imapx-server.c
+++ b/src/camel/providers/imapx/camel-imapx-server.c
@@ -105,6 +105,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;
@@ -1138,6 +1139,7 @@ imapx_untagged (CamelIMAPXServer *is,
 	}
 	case IMAPX_VANISHED: {
 		GPtrArray *uids;
+		GList *uid_list = NULL;
 		gboolean unsolicited = TRUE;
 		gint i;
 		guint len;
@@ -1161,11 +1163,30 @@ imapx_untagged (CamelIMAPXServer *is,
 		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);
-			imapx_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;
 	}
@@ -1244,17 +1265,19 @@ imapx_untagged (CamelIMAPXServer *is,
 
 		if ((finfo->got & FETCH_FLAGS) && !(finfo->got & FETCH_HEADER)) {
 			CamelIMAPXJob *job = imapx_match_active_job (is, IMAPX_JOB_FETCH_NEW_MESSAGES | IMAPX_JOB_REFRESH_INFO | IMAPX_JOB_FETCH_MESSAGES, 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;
@@ -1350,7 +1373,7 @@ imapx_untagged (CamelIMAPXServer *is,
 						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 {
@@ -1410,8 +1433,8 @@ imapx_untagged (CamelIMAPXServer *is,
 						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)) {
@@ -2432,10 +2455,25 @@ imapx_command_select_done (CamelIMAPXServer *is,
 		ifolder->exists_on_server = is->exists;
 		ifolder->modseq_on_server = is->highestmodseq;
 		if (ifolder->uidnext_on_server < is->uidnext) {
+			/* We don't want to fetch new messages if the command we selected this
+			   folder for is *already* fetching all messages (i.e. scan_changes).
+			   Bug #667725. */
+			CamelIMAPXJob *job = imapx_is_job_in_queue (is, is->select_pending,
+								    IMAPX_JOB_REFRESH_INFO, NULL);
+			if (job) {
+				RefreshInfoData *data = camel_imapx_job_get_data (job);
+
+				if (data->scan_changes) {
+					c(is->tagprefix, "Will not fetch_new_messages when already in scan_changes\n");
+					goto no_fetch_new;
+				}
+			}
 			imapx_server_fetch_new_messages (is, is->select_pending, TRUE, TRUE, NULL, NULL);
 			/* We don't do this right now because we want the new messages to
 			 * update the unseen count. */
 			//ifolder->uidnext_on_server = is->uidnext;
+		no_fetch_new:
+			;
 		}
 		ifolder->uidvalidity_on_server = is->uidvalidity;
 		selected_folder = camel_folder_get_full_name (is->select_folder);
@@ -2628,7 +2666,6 @@ connect_to_server_process (CamelIMAPXServer *is,
 	password = camel_service_get_password (service);
 	provider = camel_service_get_provider (service);
 	settings = camel_service_get_settings (service);
-	g_return_val_if_fail (password != NULL, FALSE);
 
 	network_settings = CAMEL_NETWORK_SETTINGS (settings);
 	host = camel_network_settings_dup_host (network_settings);
@@ -3443,7 +3480,7 @@ imapx_command_copy_messages_step_start (CamelIMAPXServer *is,
 		res = imapx_uidset_add (&data->uidset, ic, uid);
 		if (res == 1) {
 			camel_imapx_command_add (ic, " %f", data->dest);
-			data->index = i;
+			data->index = i + 1;
 			imapx_command_queue (is, ic);
 			return;
 		}
@@ -3524,11 +3561,11 @@ imapx_command_append_message_done (CamelIMAPXServer *is,
 			g_rename (data->path, cur);
 
 			/* should we update the message count ? */
-			camel_folder_summary_add (job->folder->summary, mi);
 			imapx_set_message_info_flags_for_new_message (mi,
 								      ((CamelMessageInfoBase *) data->info)->flags,
 								      ((CamelMessageInfoBase *) data->info)->user_flags,
 								      job->folder);
+			camel_folder_summary_add (job->folder->summary, mi);
 			changes = camel_folder_change_info_new ();
 			camel_folder_change_info_add_uid (changes, mi->uid);
 			camel_folder_changed (job->folder, changes);
@@ -3677,6 +3714,8 @@ imapx_command_step_fetch_done (CamelIMAPXServer *is,
 	data = camel_imapx_job_get_data (job);
 	g_return_val_if_fail (data != NULL, FALSE);
 
+	data->scan_changes = FALSE;
+
 	ifolder = (CamelIMAPXFolder *) job->folder;
 	isum = (CamelIMAPXSummary *) job->folder->summary;
 
@@ -3734,7 +3773,7 @@ imapx_command_step_fetch_done (CamelIMAPXServer *is,
 				res = imapx_uidset_add (&data->uidset, ic, r->uid);
 				if (res == 1) {
 					camel_imapx_command_add (ic, " (RFC822.SIZE RFC822.HEADER)");
-					data->index = i;
+					data->index = i + 1;
 					imapx_command_queue (is, ic);
 					return TRUE;
 				}
@@ -3827,6 +3866,8 @@ imapx_job_scan_changes_done (CamelIMAPXServer *is,
 	data = camel_imapx_job_get_data (job);
 	g_return_val_if_fail (data != NULL, FALSE);
 
+	data->scan_changes = FALSE;
+
 	service = CAMEL_SERVICE (is->store);
 	settings = camel_service_get_settings (service);
 
@@ -3936,10 +3977,10 @@ imapx_job_scan_changes_done (CamelIMAPXServer *is,
 			gchar *uid = (gchar *) l->data;
 
 			camel_folder_change_info_remove_uid (data->changes, uid);
-			camel_folder_summary_remove_uid (s, uid);
 		}
 
 		if (removed != NULL) {
+			camel_folder_summary_remove_uids (s, removed);
 			camel_folder_summary_touch (s);
 
 			g_list_free_full (removed, (GDestroyNotify) g_free);
@@ -3999,7 +4040,18 @@ imapx_job_scan_changes_start (CamelIMAPXJob *job,
 {
 	CamelIMAPXCommand *ic;
 	RefreshInfoData *data;
-	gchar *uid = imapx_get_uid_from_index (job->folder->summary, 0);
+	CamelService *service;
+	CamelSettings *settings;
+	gboolean mobile_mode;
+	gchar *uid = NULL;
+
+	service = CAMEL_SERVICE (is->store);
+	settings = camel_service_get_settings (service);
+	mobile_mode = camel_imapx_settings_get_mobile_mode (
+		CAMEL_IMAPX_SETTINGS (settings));
+
+	if (mobile_mode)
+		uid = imapx_get_uid_from_index (job->folder->summary, 0);
 
 	data = camel_imapx_job_get_data (job);
 	g_return_if_fail (data != NULL);
@@ -4011,12 +4063,16 @@ imapx_job_scan_changes_start (CamelIMAPXJob *job,
 		_("Scanning for changed messages in %s"),
 		camel_folder_get_display_name (job->folder));
 
-	e('E', "Scanning from %s in %s\n", uid, camel_folder_get_full_name (job->folder));	
+	e('E', "Scanning from %s in %s\n", uid ? uid : "start",
+	  camel_folder_get_full_name (job->folder));
+
 	ic = camel_imapx_command_new (
 		is, "FETCH", job->folder,
 		"UID FETCH %s:* (UID FLAGS)", uid ? uid : "1");
 	camel_imapx_command_set_job (ic, job);
 	ic->complete = imapx_job_scan_changes_done;
+
+	data->scan_changes = TRUE;
 	ic->pri = job->pri;
 	data->infos = g_array_new (0, 0, sizeof (struct _refresh_info));
 	imapx_command_queue (is, ic);
@@ -4096,6 +4152,8 @@ imapx_command_fetch_new_uids_done (CamelIMAPXServer *is,
 	data = camel_imapx_job_get_data (job);
 	g_return_val_if_fail (data != NULL, FALSE);
 
+	data->scan_changes = FALSE;
+
 	qsort (
 		data->infos->data,
 		data->infos->len,
@@ -4160,6 +4218,8 @@ imapx_job_fetch_new_messages_start (CamelIMAPXJob *job,
 		data->infos = g_array_new (0, 0, sizeof (struct _refresh_info));
 		ic->pri = job->pri;
 
+		data->scan_changes = TRUE;
+
 		if (fetch_order == CAMEL_SORT_DESCENDING)
 			ic->complete = imapx_command_fetch_new_uids_done;
 		else
@@ -4261,6 +4321,8 @@ imapx_job_fetch_messages_start (CamelIMAPXJob *job,
 		data->infos = g_array_new (0, 0, sizeof (struct _refresh_info));
 		ic->pri = job->pri;
 
+		data->scan_changes = TRUE;
+
 		if (fetch_order == CAMEL_SORT_DESCENDING)
 			ic->complete = imapx_command_fetch_new_uids_done;
 		else



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