|
|
@ -143,8 +143,8 @@ struct imap_cmd { |
|
|
|
int uid; /* to identify fetch responses */ |
|
|
|
int uid; /* to identify fetch responses */ |
|
|
|
char high_prio; /* if command is queued, put it at the front of the queue. */ |
|
|
|
char high_prio; /* if command is queued, put it at the front of the queue. */ |
|
|
|
char to_trash; /* we are storing to trash, not current. */ |
|
|
|
char to_trash; /* we are storing to trash, not current. */ |
|
|
|
char create; /* create the mailbox if we get an error ... */ |
|
|
|
char create; /* create the mailbox if we get an error which suggests so. */ |
|
|
|
char trycreate; /* ... but only if this is true or the server says so. */ |
|
|
|
char failok; /* Don't complain about NO response. */ |
|
|
|
} param; |
|
|
|
} param; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -1333,10 +1333,7 @@ imap_socket_read( void *aux ) |
|
|
|
resp = RESP_OK; |
|
|
|
resp = RESP_OK; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (!strcmp( "NO", arg )) { |
|
|
|
if (!strcmp( "NO", arg )) { |
|
|
|
if (cmdp->param.create && |
|
|
|
if (cmdp->param.create && cmd && starts_with( cmd, -1, "[TRYCREATE]", 11 )) { /* APPEND or UID COPY */ |
|
|
|
(cmdp->param.trycreate || |
|
|
|
|
|
|
|
(cmd && starts_with( cmd, -1, "[TRYCREATE]", 11 )))) |
|
|
|
|
|
|
|
{ /* SELECT, APPEND or UID COPY */ |
|
|
|
|
|
|
|
struct imap_cmd_trycreate *cmd2 = |
|
|
|
struct imap_cmd_trycreate *cmd2 = |
|
|
|
(struct imap_cmd_trycreate *)new_imap_cmd( sizeof(*cmd2) ); |
|
|
|
(struct imap_cmd_trycreate *)new_imap_cmd( sizeof(*cmd2) ); |
|
|
|
cmd2->orig_cmd = cmdp; |
|
|
|
cmd2->orig_cmd = cmdp; |
|
|
@ -1348,12 +1345,15 @@ imap_socket_read( void *aux ) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
resp = RESP_NO; |
|
|
|
resp = RESP_NO; |
|
|
|
|
|
|
|
if (cmdp->param.failok) |
|
|
|
|
|
|
|
goto doresp; |
|
|
|
} else /*if (!strcmp( "BAD", arg ))*/ |
|
|
|
} else /*if (!strcmp( "BAD", arg ))*/ |
|
|
|
resp = RESP_CANCEL; |
|
|
|
resp = RESP_CANCEL; |
|
|
|
error( "IMAP command '%s' returned an error: %s %s\n", |
|
|
|
error( "IMAP command '%s' returned an error: %s %s\n", |
|
|
|
!starts_with( cmdp->cmd, -1, "LOGIN", 5 ) ? cmdp->cmd : "LOGIN <user> <pass>", |
|
|
|
!starts_with( cmdp->cmd, -1, "LOGIN", 5 ) ? cmdp->cmd : "LOGIN <user> <pass>", |
|
|
|
arg, cmd ? cmd : "" ); |
|
|
|
arg, cmd ? cmd : "" ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
doresp: |
|
|
|
if ((resp2 = parse_response_code( ctx, cmdp, cmd )) > resp) |
|
|
|
if ((resp2 = parse_response_code( ctx, cmdp, cmd )) > resp) |
|
|
|
resp = resp2; |
|
|
|
resp = resp2; |
|
|
|
imap_ref( ctx ); |
|
|
|
imap_ref( ctx ); |
|
|
@ -2124,7 +2124,7 @@ imap_select_box( store_t *gctx, const char *name ) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
static void |
|
|
|
imap_open_box( store_t *gctx, int create, |
|
|
|
imap_open_box( store_t *gctx, |
|
|
|
void (*cb)( int sts, void *aux ), void *aux ) |
|
|
|
void (*cb)( int sts, void *aux ), void *aux ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
imap_store_t *ctx = (imap_store_t *)gctx; |
|
|
|
imap_store_t *ctx = (imap_store_t *)gctx; |
|
|
@ -2139,13 +2139,33 @@ imap_open_box( store_t *gctx, int create, |
|
|
|
ctx->gen.uidnext = 0; |
|
|
|
ctx->gen.uidnext = 0; |
|
|
|
|
|
|
|
|
|
|
|
INIT_IMAP_CMD(imap_cmd_simple, cmd, cb, aux) |
|
|
|
INIT_IMAP_CMD(imap_cmd_simple, cmd, cb, aux) |
|
|
|
cmd->gen.param.create = create; |
|
|
|
cmd->gen.param.failok = 1; |
|
|
|
cmd->gen.param.trycreate = 1; |
|
|
|
|
|
|
|
imap_exec( ctx, &cmd->gen, imap_done_simple_box, |
|
|
|
imap_exec( ctx, &cmd->gen, imap_done_simple_box, |
|
|
|
"SELECT \"%\\s\"", buf ); |
|
|
|
"SELECT \"%\\s\"", buf ); |
|
|
|
free( buf ); |
|
|
|
free( buf ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/******************* imap_create_box *******************/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
|
|
|
imap_create_box( store_t *gctx, |
|
|
|
|
|
|
|
void (*cb)( int sts, void *aux ), void *aux ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
imap_store_t *ctx = (imap_store_t *)gctx; |
|
|
|
|
|
|
|
struct imap_cmd_simple *cmd; |
|
|
|
|
|
|
|
char *buf; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (prepare_box( &buf, ctx ) < 0) { |
|
|
|
|
|
|
|
cb( DRV_BOX_BAD, aux ); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INIT_IMAP_CMD(imap_cmd_simple, cmd, cb, aux) |
|
|
|
|
|
|
|
imap_exec( ctx, &cmd->gen, imap_done_simple_box, |
|
|
|
|
|
|
|
"CREATE \"%\\s\"", buf ); |
|
|
|
|
|
|
|
free( buf ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/******************* imap_load_box *******************/ |
|
|
|
/******************* imap_load_box *******************/ |
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
static void |
|
|
@ -2788,6 +2808,7 @@ struct driver imap_driver = { |
|
|
|
imap_cancel_store, |
|
|
|
imap_cancel_store, |
|
|
|
imap_list_store, |
|
|
|
imap_list_store, |
|
|
|
imap_select_box, |
|
|
|
imap_select_box, |
|
|
|
|
|
|
|
imap_create_box, |
|
|
|
imap_open_box, |
|
|
|
imap_open_box, |
|
|
|
imap_prepare_load_box, |
|
|
|
imap_prepare_load_box, |
|
|
|
imap_load_box, |
|
|
|
imap_load_box, |
|
|
|