[evolution-data-server] Handle [CLOSED] status (RFC5162).



commit 1c3a459945ebfac7a745087c68eb94a21ff86d27
Author: David Woodhouse <David Woodhouse intel com>
Date:   Sun Jun 20 23:36:28 2010 +0100

    Handle [CLOSED] status (RFC5162).
    
    This indicates precisely when the selected mailbox changes to the new
    mailbox during the SELECT command, before its tagged completion.
    
    This allows us to assign unsolicited FETCH responses to the correct
    mailbox; with QRESYNC those will arrive before the SELECT completion.
    
    It also theoretically allows us to pipeline SELECT requests, although
    there's not a huge amount of point in that and we'll have other issues
    with our implementation if we do that.

 camel/providers/imapx/camel-imapx-server.c   |   35 +++++++++++++++++++++++---
 camel/providers/imapx/camel-imapx-tokens.txt |    1 +
 camel/providers/imapx/camel-imapx-utils.c    |    1 +
 camel/providers/imapx/camel-imapx-utils.h    |    1 +
 4 files changed, 34 insertions(+), 4 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index c5483cc..5a13857 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -1460,6 +1460,16 @@ imapx_untagged(CamelIMAPXServer *imap, CamelException *ex)
 		if (camel_exception_is_set(ex))
 			return -1;
 		switch (sinfo->condition) {
+		case IMAPX_CLOSED:
+			c(printf("previously selected folder is now closed\n"));
+			if (imap->select_pending && !imap->select_folder) {
+				const gchar *full_name;
+				imap->select_folder = imap->select_pending;
+				full_name = camel_folder_get_full_name (imap->select_folder);
+
+				imap->select = g_strdup(full_name);
+			}
+			break;
 		case IMAPX_READ_WRITE:
 			imap->mode = IMAPX_MODE_READ|IMAPX_MODE_WRITE;
 			c(printf("folder is read-write\n"));
@@ -2114,17 +2124,27 @@ imapx_command_select_done (CamelIMAPXServer *is, CamelIMAPXCommand *ic)
 				cn = cn->next;
 			}
 		}
-
 		if (is->select_pending)
 			g_object_unref (is->select_pending);
+
+		/* A [CLOSED] status may have caused us to assume that it had happened */
+		if (is->select) {
+			g_free(is->select);
+			is->select = NULL;
+			is->select_folder = NULL;
+		}
+		is->state = IMAPX_INITIALISED;
 	} else {
 		CamelIMAPXFolder *ifolder = (CamelIMAPXFolder *) is->select_pending;
 		c(printf("Select ok!\n"));
 
-		is->select_folder = is->select_pending;
-		full_name = camel_folder_get_full_name (is->select_folder);
+		if (!is->select_folder) {
+			/* This could have been done earlier by a [CLOSED] status */
+			is->select_folder = is->select_pending;
+			full_name = camel_folder_get_full_name (is->select_folder);
 
-		is->select = g_strdup(full_name);
+			is->select = g_strdup(full_name);
+		}
 		is->state = IMAPX_SELECTED;
 		ifolder->exists_on_server = is->exists;
 #if 0
@@ -2181,6 +2201,13 @@ imapx_select (CamelIMAPXServer *is, CamelFolder *folder, gboolean forced, CamelE
 		g_object_unref (is->select_folder);
 		is->select = NULL;
 		is->select_folder = NULL;
+	} else {
+		/* If no folder was selected, we won't get a [CLOSED] status
+		   so just point select_folder at the new folder immediately */
+		is->select_folder = is->select_pending;
+		full_name = camel_folder_get_full_name (is->select_folder);
+
+		is->select = g_strdup(full_name);
 	}
 
 	is->uidvalidity = 0;
diff --git a/camel/providers/imapx/camel-imapx-tokens.txt b/camel/providers/imapx/camel-imapx-tokens.txt
index d1d3638..6a9abbd 100644
--- a/camel/providers/imapx/camel-imapx-tokens.txt
+++ b/camel/providers/imapx/camel-imapx-tokens.txt
@@ -11,6 +11,7 @@ BODYSTRUCTURE,	IMAPX_BODYSTRUCTURE
 BYE,		IMAPX_BYE
 CAPABILITY,	IMAPX_CAPABILITY
 COPYUID,	IMAPX_COPYUID
+CLOSED,		IMAPX_CLOSED
 ENVELOPE,	IMAPX_ENVELOPE
 EXISTS,		IMAPX_EXISTS
 EXPUNGE,	IMAPX_EXPUNGE
diff --git a/camel/providers/imapx/camel-imapx-utils.c b/camel/providers/imapx/camel-imapx-utils.c
index 2e99dcd..cdcbe69 100644
--- a/camel/providers/imapx/camel-imapx-utils.c
+++ b/camel/providers/imapx/camel-imapx-utils.c
@@ -1609,6 +1609,7 @@ imapx_parse_status(CamelIMAPXStream *is, CamelException *ex)
 			case IMAPX_ALERT:
 			case IMAPX_PARSE:
 			case IMAPX_TRYCREATE:
+			case IMAPX_CLOSED:
 				break;
 			case IMAPX_APPENDUID:
 				sinfo->u.appenduid.uidvalidity = camel_imapx_stream_number(is, ex);
diff --git a/camel/providers/imapx/camel-imapx-utils.h b/camel/providers/imapx/camel-imapx-utils.h
index 4e520e1..a87dd1f 100644
--- a/camel/providers/imapx/camel-imapx-utils.h
+++ b/camel/providers/imapx/camel-imapx-utils.h
@@ -20,6 +20,7 @@ typedef enum _camel_imapx_id_t {
 	IMAPX_BODYSTRUCTURE,
 	IMAPX_BYE,
 	IMAPX_CAPABILITY,
+	IMAPX_CLOSED,
 	IMAPX_COPYUID,
 	IMAPX_ENVELOPE,
 	IMAPX_EXISTS,



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