Mercurial > dovecot > core-2.2
changeset 21976:4430a5cc0a3e
imapc: Support imapc_features=search without ESEARCH extension
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Sun, 23 Apr 2017 13:35:18 +0300 |
parents | b523b154523e |
children | 3fcf9d9fa53f |
files | src/lib-storage/index/imapc/imapc-mailbox.c src/lib-storage/index/imapc/imapc-search.c src/lib-storage/index/imapc/imapc-search.h |
diffstat | 3 files changed, 41 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/imapc/imapc-mailbox.c Sun Apr 23 19:14:54 2017 +0300 +++ b/src/lib-storage/index/imapc/imapc-mailbox.c Sun Apr 23 13:35:18 2017 +0300 @@ -546,6 +546,13 @@ mail_index_keywords_unref(&kw); } +static void imapc_untagged_search(const struct imapc_untagged_reply *reply, + struct imapc_mailbox *mbox) +{ + if (mbox != NULL) + imapc_search_reply_search(reply->args, mbox); +} + static void imapc_untagged_esearch(const struct imapc_untagged_reply *reply, struct imapc_mailbox *mbox) { @@ -567,7 +574,7 @@ strcmp(mbox->sync_gmail_pop3_search_tag, str) == 0) imapc_untagged_esearch_gmail_pop3(reply->args+1, mbox); else - imapc_search_reply(reply->args+1, mbox); + imapc_search_reply_esearch(reply->args+1, mbox); } static void @@ -674,6 +681,8 @@ imapc_untagged_fetch); imapc_mailbox_register_untagged(mbox, "EXPUNGE", imapc_untagged_expunge); + imapc_mailbox_register_untagged(mbox, "SEARCH", + imapc_untagged_search); imapc_mailbox_register_untagged(mbox, "ESEARCH", imapc_untagged_esearch); imapc_mailbox_register_resp_text(mbox, "UIDVALIDITY",
--- a/src/lib-storage/index/imapc/imapc-search.c Sun Apr 23 19:14:54 2017 +0300 +++ b/src/lib-storage/index/imapc/imapc-search.c Sun Apr 23 13:35:18 2017 +0300 @@ -168,14 +168,13 @@ /* SEARCH command passthrough not enabled */ return FALSE; } - if ((mbox->capabilities & IMAPC_CAPABILITY_ESEARCH) == 0) { - /* FIXME: not supported for now */ - return FALSE; - } if (imapc_search_is_fast_local(args->args)) return FALSE; - str_append(str, "SEARCH RETURN (ALL) "); + if ((mbox->capabilities & IMAPC_CAPABILITY_ESEARCH) != 0) + str_append(str, "SEARCH RETURN (ALL) "); + else + str_append(str, "SEARCH "); if (!imapc_build_search_query_args(mbox, args->args, FALSE, str)) return FALSE; *query_r = str_c(str); @@ -278,8 +277,29 @@ return index_storage_search_deinit(ctx); } -void imapc_search_reply(const struct imap_arg *args, - struct imapc_mailbox *mbox) +void imapc_search_reply_search(const struct imap_arg *args, + struct imapc_mailbox *mbox) +{ + const char *atom; + uint32_t seq; + + if (mbox->search_ctx == NULL) { + i_error("Unexpected SEARCH reply"); + return; + } + + for (unsigned int i = 0; args[i].type != IMAP_ARG_EOL; i++) { + if (!imap_arg_get_atom(&args[i], &atom) || + str_to_uint32(atom, &seq) < 0 || seq == 0) { + i_error("Invalid SEARCH reply"); + break; + } + seq_range_array_add(&mbox->search_ctx->rseqs, seq); + } +} + +void imapc_search_reply_esearch(const struct imap_arg *args, + struct imapc_mailbox *mbox) { const char *atom;
--- a/src/lib-storage/index/imapc/imapc-search.h Sun Apr 23 19:14:54 2017 +0300 +++ b/src/lib-storage/index/imapc/imapc-search.h Sun Apr 23 13:35:18 2017 +0300 @@ -10,7 +10,9 @@ bool imapc_search_next_update_seq(struct mail_search_context *ctx); int imapc_search_deinit(struct mail_search_context *ctx); -void imapc_search_reply(const struct imap_arg *args, - struct imapc_mailbox *mbox); +void imapc_search_reply_search(const struct imap_arg *args, + struct imapc_mailbox *mbox); +void imapc_search_reply_esearch(const struct imap_arg *args, + struct imapc_mailbox *mbox); #endif