diff options
author | David Woodhouse <David.Woodhouse@intel.com> | 2010-06-20 23:36:28 +0100 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2010-06-28 13:31:35 +0100 |
commit | 93b397e5c397d9c8df9ab308a2e23980d1165d80 (patch) | |
tree | 065f3686a2ae1a39847e0739f9ecad1ce50ea75a | |
parent | 79603ec0951bd8193acac1a3efbda70bb7404e28 (diff) | |
download | evolution-data-server-93b397e5c397d9c8df9ab308a2e23980d1165d80.tar.gz |
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.
(cherry picked from commit 1c3a459945ebfac7a745087c68eb94a21ff86d27)
-rw-r--r-- | camel/providers/imapx/camel-imapx-server.c | 31 | ||||
-rw-r--r-- | camel/providers/imapx/camel-imapx-tokens.txt | 1 | ||||
-rw-r--r-- | camel/providers/imapx/camel-imapx-utils.c | 1 | ||||
-rw-r--r-- | camel/providers/imapx/camel-imapx-utils.h | 1 |
4 files changed, 31 insertions, 3 deletions
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c index 377f0226e..e6569851f 100644 --- a/camel/providers/imapx/camel-imapx-server.c +++ b/camel/providers/imapx/camel-imapx-server.c @@ -1463,6 +1463,16 @@ imapx_untagged(CamelIMAPXServer *imap, CamelException *ex) return -1; camel_object_trigger_event(imap, "status", sinfo); 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")); @@ -2104,15 +2114,25 @@ imapx_command_select_done (CamelIMAPXServer *is, CamelIMAPXCommand *ic) cn = cn->next; } } - if (is->select_pending) camel_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; - is->select = g_strdup(is->select_folder->full_name); + if (!is->select_folder) { + /* This could have been done earlier by a [CLOSED] status */ + is->select_folder = is->select_pending; + is->select = g_strdup(is->select_folder->full_name); + } is->state = IMAPX_SELECTED; ifolder->exists_on_server = is->exists; #if 0 @@ -2166,6 +2186,11 @@ imapx_select (CamelIMAPXServer *is, CamelFolder *folder, gboolean forced, CamelE camel_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; + is->select = g_strdup(is->select_folder->full_name); } is->uidvalidity = 0; diff --git a/camel/providers/imapx/camel-imapx-tokens.txt b/camel/providers/imapx/camel-imapx-tokens.txt index d1d36381c..6a9abbd97 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 f5237dff0..e67cd4aae 100644 --- a/camel/providers/imapx/camel-imapx-utils.c +++ b/camel/providers/imapx/camel-imapx-utils.c @@ -1610,6 +1610,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 a65255333..e05f23ef5 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, |