aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiri Hruska <jirka@fud.cz>2013-03-03 11:21:29 +0100
committerSteve Holme <steve_holme@hotmail.com>2013-03-03 13:10:32 +0000
commitad8b76d094b4c68cb78a78ad126e60d631f05960 (patch)
treeafdd451f40bc856f22992d98d100329a5eb14c8d
parent226c1c6876fffd362f22c4a507be360fb1bc8103 (diff)
imap: Enabled custom requests in imap_perform()
Modified imap_perform() to start with the custom command instead of SELECT when a custom command is to be performed and no mailbox has been given.
-rw-r--r--lib/imap.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/lib/imap.c b/lib/imap.c
index 274513950..b9a4b9cfe 100644
--- a/lib/imap.c
+++ b/lib/imap.c
@@ -1794,8 +1794,8 @@ static CURLcode imap_done(struct connectdata *conn, CURLcode status,
*
* imap_perform()
*
- * This is the actual DO function for IMAP. Fetch or append a message
- * according to the options previously setup.
+ * This is the actual DO function for IMAP. Fetch or append a message, or do
+ * other things according to the options previously setup.
*/
static CURLcode imap_perform(struct connectdata *conn, bool *connected,
bool *dophase_done)
@@ -1805,6 +1805,7 @@ static CURLcode imap_perform(struct connectdata *conn, bool *connected,
struct SessionHandle *data = conn->data;
struct IMAP *imap = data->state.proto.imap;
struct imap_conn *imapc = &conn->proto.imapc;
+ bool selected = FALSE;
DEBUGF(infof(conn->data, "DO phase starts\n"));
@@ -1815,20 +1816,26 @@ static CURLcode imap_perform(struct connectdata *conn, bool *connected,
*dophase_done = FALSE; /* not done yet */
+ /* Determine if the requested mailbox (with the same UIDVALIDITY if set)
+ has already been selected on this connection */
+ if(imap->mailbox && imapc->mailbox &&
+ !strcmp(imap->mailbox, imapc->mailbox) &&
+ (!imap->uidvalidity || !imapc->mailbox_uidvalidity ||
+ !strcmp(imap->uidvalidity, imapc->mailbox_uidvalidity)))
+ selected = TRUE;
+
/* Start the first command in the DO phase */
if(conn->data->set.upload)
/* APPEND can be executed directly */
result = imap_append(conn);
- /* FETCH needs a selected mailbox */
- else if(imap->mailbox && imapc->mailbox &&
- !strcmp(imap->mailbox, imapc->mailbox) &&
- (!imap->uidvalidity || !imapc->mailbox_uidvalidity ||
- !strcmp(imap->uidvalidity, imapc->mailbox_uidvalidity))) {
- /* This mailbox (with the same UIDVALIDITY if set) is already selected on
- this connection so go straight to the next fetch operation */
+ else if(imap->custom && (selected || !imap->mailbox))
+ /* Custom command using the same mailbox or no mailbox */
+ result = imap_custom(conn);
+ else if(!imap->custom && selected)
+ /* FETCH from the same mailbox */
result = imap_fetch(conn);
- }
else
+ /* SELECT the mailbox */
result = imap_select(conn);
if(result)