[evolution-data-server/gnome-2-30] Cope with unsolicited FETCH having both FLAGS and UID.



commit 79603ec0951bd8193acac1a3efbda70bb7404e28
Author: David Woodhouse <David Woodhouse intel com>
Date:   Sat Jun 19 22:03:00 2010 +0100

    Cope with unsolicited FETCH having both FLAGS and UID.
    
    This'll happen once we're using CONDSTORE or QRESYNC
    (cherry picked from commit 25646a07ead3bc8b042397805f867894156b4861)

 camel/providers/imapx/camel-imapx-server.c |   55 +++++++++++++++-------------
 1 files changed, 30 insertions(+), 25 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index 2520167..377f022 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -1255,8 +1255,23 @@ imapx_untagged(CamelIMAPXServer *imap, CamelException *ex)
 			}
 		}
 
-		if (finfo->got & FETCH_FLAGS && !(finfo->got & FETCH_UID)) {
-			if (imap->select_folder) {
+		if ((finfo->got & FETCH_FLAGS) && !(finfo->got & FETCH_HEADER)) {
+			CamelIMAPXJob *job = imapx_match_active_job (imap, IMAPX_JOB_FETCH_NEW_MESSAGES|IMAPX_JOB_REFRESH_INFO, NULL);
+			/* 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)) {
+				struct _refresh_info r;
+
+				r.uid = finfo->uid;
+				finfo->uid = NULL;
+				r.server_flags = finfo->flags;
+				r.server_user_flags = finfo->user_flags;
+				finfo->user_flags = NULL;
+				r.exists = FALSE;
+				g_array_append_val(job->u.refresh_info.infos, r);
+			} else if (imap->select_folder) {
 				CamelFolder *folder;
 				CamelMessageInfo *mi = NULL;
 				gboolean changed = FALSE;
@@ -1267,11 +1282,22 @@ imapx_untagged(CamelIMAPXServer *imap, CamelException *ex)
 
 				c(printf("flag changed: %d\n", id));
 
-				if ( (uid = camel_folder_summary_uid_from_index (folder->summary, id - 1)))
-				{
+				if (finfo->got & FETCH_UID) {
+					uid = finfo->uid;
+					finfo->uid = NULL;
+				} else {
+					uid = camel_folder_summary_uid_from_index (folder->summary, id - 1);
+				}
+
+				if (uid) {
 					mi = camel_folder_summary_uid (folder->summary, uid);
 					if (mi)
 						changed = imapx_update_message_info_flags (mi, finfo->flags, finfo->user_flags, folder);
+					else {
+						/* This (UID + FLAGS for previously unknown message) might
+						   happen during a SELECT (QRESYNC). We should use it. */
+						c(printf("flags changed for unknown uid %s\n.", uid));
+					}
 					finfo->user_flags = NULL;
 				}
 
@@ -1296,27 +1322,6 @@ imapx_untagged(CamelIMAPXServer *imap, CamelException *ex)
 			}
 		}
 
-		if ((finfo->got & (FETCH_FLAGS|FETCH_UID)) == (FETCH_FLAGS|FETCH_UID) && !(finfo->got & FETCH_HEADER)) {
-			CamelIMAPXJob *job = imapx_match_active_job (imap, IMAPX_JOB_FETCH_NEW_MESSAGES|IMAPX_JOB_REFRESH_INFO, NULL);
-
-			/* 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) {
-				struct _refresh_info r;
-
-				r.uid = finfo->uid;
-				finfo->uid = NULL;
-				r.server_flags = finfo->flags;
-				r.server_user_flags = finfo->user_flags;
-				finfo->user_flags = NULL;
-				r.exists = FALSE;
-				g_array_append_val(job->u.refresh_info.infos, r);
-			} else {
-			}
-		}
-
 		if ((finfo->got & (FETCH_HEADER|FETCH_UID)) == (FETCH_HEADER|FETCH_UID)) {
 			CamelIMAPXJob *job = imapx_match_active_job (imap, IMAPX_JOB_FETCH_NEW_MESSAGES|IMAPX_JOB_REFRESH_INFO, NULL);
 



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