[evolution-data-server] Fix QRESYNC protocol violation (RH #648082)



commit 0c866faf3815388b04176777b9b785a31db8a1a3
Author: David Woodhouse <David Woodhouse intel com>
Date:   Thu Nov 11 01:34:18 2010 +0000

    Fix QRESYNC protocol violation (RH #648082)
    
    The sequence-set '1:*' isn't valid in QRESYNC, and newer versions of
    Dovecot (>=2.0) have started to object to it.
    
    Ideally we'd omit the parameter completely, since it's supposed to be
    optional â?? but *older* versions of Dovecot (<=1.2.13) require it.
    
    We only really care about messages which we already knew about. For any
    *new* messages, we're going to fetch the headers and the flags in an
    explicit FETCH command anyway, and we'll ignore anything that QRESYNC
    tells us about them. So just use the first and last UID from our existing
    summary cache as the range for the QRESYNC command.
    
    Fix a shadow declaration of the 'uid' variable in an inner block, while
    we're at it.

 camel/providers/imapx/camel-imapx-server.c |   25 +++++++++++++++++++------
 1 files changed, 19 insertions(+), 6 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index d8d72dd..30a8ecd 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -2602,14 +2602,28 @@ imapx_select (CamelIMAPXServer *is,
 		CamelIMAPXSummary *isum = (CamelIMAPXSummary *)folder->summary;
 		CamelIMAPXFolder *ifolder = (CamelIMAPXFolder *)folder;
 		gint total = camel_folder_summary_count (folder->summary);
-		gchar *uid = NULL;
+		gchar *firstuid = NULL, *lastuid = NULL;
 
-		if (total)
-			uid = camel_folder_summary_uid_from_index (folder->summary, 0);
+		if (total) {
+			firstuid = camel_folder_summary_uid_from_index (folder->summary, 0);
+			lastuid = camel_folder_summary_uid_from_index (folder->summary, total - 1);
+		}
 
 		if (isum->modseq && ifolder->uidvalidity_on_server) {
-			c(is->tagprefix, "SELECT QRESYNC %" G_GUINT64_FORMAT " %" G_GUINT64_FORMAT "\n", ifolder->uidvalidity_on_server, isum->modseq);
-			camel_imapx_command_add(ic, " (QRESYNC (%" G_GUINT64_FORMAT " %" G_GUINT64_FORMAT " %s:*", ifolder->uidvalidity_on_server, isum->modseq, uid?uid:"1");
+			c(is->tagprefix, "SELECT QRESYNC %" G_GUINT64_FORMAT
+			  " %" G_GUINT64_FORMAT "\n",
+			  ifolder->uidvalidity_on_server, isum->modseq);
+
+			camel_imapx_command_add(ic, " (QRESYNC (%"
+						G_GUINT64_FORMAT " %"
+						G_GUINT64_FORMAT " %s:%s",
+						ifolder->uidvalidity_on_server,
+						isum->modseq,
+						firstuid?firstuid:"1",
+						lastuid?lastuid:"1");
+
+			g_free (firstuid);
+			g_free (lastuid);
 
 			if (total > 10) {
 				gint i;
@@ -2657,7 +2671,6 @@ imapx_select (CamelIMAPXServer *is,
 			}
 			camel_imapx_command_add(ic, "))");
 		}
-		g_free (uid);
 	}
 
 	ic->complete = imapx_command_select_done;



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