mirror of
https://github.com/moparisthebest/curl
synced 2024-12-22 08:08:50 -05:00
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.
This commit is contained in:
parent
226c1c6876
commit
ad8b76d094
27
lib/imap.c
27
lib/imap.c
@ -1794,8 +1794,8 @@ static CURLcode imap_done(struct connectdata *conn, CURLcode status,
|
|||||||
*
|
*
|
||||||
* imap_perform()
|
* imap_perform()
|
||||||
*
|
*
|
||||||
* This is the actual DO function for IMAP. Fetch or append a message
|
* This is the actual DO function for IMAP. Fetch or append a message, or do
|
||||||
* according to the options previously setup.
|
* other things according to the options previously setup.
|
||||||
*/
|
*/
|
||||||
static CURLcode imap_perform(struct connectdata *conn, bool *connected,
|
static CURLcode imap_perform(struct connectdata *conn, bool *connected,
|
||||||
bool *dophase_done)
|
bool *dophase_done)
|
||||||
@ -1805,6 +1805,7 @@ static CURLcode imap_perform(struct connectdata *conn, bool *connected,
|
|||||||
struct SessionHandle *data = conn->data;
|
struct SessionHandle *data = conn->data;
|
||||||
struct IMAP *imap = data->state.proto.imap;
|
struct IMAP *imap = data->state.proto.imap;
|
||||||
struct imap_conn *imapc = &conn->proto.imapc;
|
struct imap_conn *imapc = &conn->proto.imapc;
|
||||||
|
bool selected = FALSE;
|
||||||
|
|
||||||
DEBUGF(infof(conn->data, "DO phase starts\n"));
|
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 */
|
*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 */
|
/* Start the first command in the DO phase */
|
||||||
if(conn->data->set.upload)
|
if(conn->data->set.upload)
|
||||||
/* APPEND can be executed directly */
|
/* APPEND can be executed directly */
|
||||||
result = imap_append(conn);
|
result = imap_append(conn);
|
||||||
/* FETCH needs a selected mailbox */
|
else if(imap->custom && (selected || !imap->mailbox))
|
||||||
else if(imap->mailbox && imapc->mailbox &&
|
/* Custom command using the same mailbox or no mailbox */
|
||||||
!strcmp(imap->mailbox, imapc->mailbox) &&
|
result = imap_custom(conn);
|
||||||
(!imap->uidvalidity || !imapc->mailbox_uidvalidity ||
|
else if(!imap->custom && selected)
|
||||||
!strcmp(imap->uidvalidity, imapc->mailbox_uidvalidity))) {
|
/* FETCH from the same mailbox */
|
||||||
/* This mailbox (with the same UIDVALIDITY if set) is already selected on
|
|
||||||
this connection so go straight to the next fetch operation */
|
|
||||||
result = imap_fetch(conn);
|
result = imap_fetch(conn);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
|
/* SELECT the mailbox */
|
||||||
result = imap_select(conn);
|
result = imap_select(conn);
|
||||||
|
|
||||||
if(result)
|
if(result)
|
||||||
|
Loading…
Reference in New Issue
Block a user