]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap: Access enabled features via new imap_client_feature_* variables
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 28 Nov 2018 10:26:33 +0000 (12:26 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 29 Nov 2018 10:58:37 +0000 (10:58 +0000)
This simplifies the following commits.

12 files changed:
src/imap/cmd-enable.c
src/imap/cmd-fetch.c
src/imap/cmd-select.c
src/imap/cmd-store.c
src/imap/imap-client.c
src/imap/imap-client.h
src/imap/imap-fetch.c
src/imap/imap-notify.c
src/imap/imap-search.c
src/imap/imap-state.c
src/imap/imap-status.c
src/imap/imap-sync.c

index 2200856d5545f08ebaa62eae9882faa739aa8d25..2c7e2fbb2f4da7ada1c484ea1c0d339af8b335e1 100644 (file)
@@ -22,11 +22,11 @@ bool cmd_enable(struct client_command_context *cmd)
                str = t_str_ucase(str);
                if (strcmp(str, "CONDSTORE") == 0) {
                        if (client_enable(cmd->client,
-                                         MAILBOX_FEATURE_CONDSTORE) == 0)
+                                         imap_feature_condstore) == 0)
                                str_append(reply, " CONDSTORE");
                } else if (strcmp(str, "QRESYNC") == 0) {
-                       if (client_enable(cmd->client, MAILBOX_FEATURE_QRESYNC |
-                                         MAILBOX_FEATURE_CONDSTORE) == 0)
+                       if (client_enable(cmd->client, imap_feature_qresync |
+                                         imap_feature_condstore) == 0)
                                str_append(reply, " QRESYNC");
                }
        }
index 7b9ff2d220ce39cf5b1743753775d05a3408269d..0e1d30e5a363dddfa77bb4418be5a4dfb2dadf8e 100644 (file)
@@ -128,7 +128,7 @@ fetch_parse_modifier(struct imap_fetch_context *ctx,
        }
        if (strcmp(name, "VANISHED") == 0 && cmd->uid) {
                if ((ctx->client->enabled_features &
-                    MAILBOX_FEATURE_QRESYNC) == 0) {
+                    imap_feature_qresync) == 0) {
                        client_send_command_error(cmd, "QRESYNC not enabled");
                        return FALSE;
                }
index 206601005cc21266dbc34fa171b8b4e7d94de194..f72a331df92c7d356485b9fa040157c5f334b7ab 100644 (file)
@@ -109,7 +109,7 @@ select_parse_qresync(struct imap_select_context *ctx,
        unsigned int count;
 
        if ((ctx->cmd->client->enabled_features &
-            MAILBOX_FEATURE_QRESYNC) == 0) {
+            imap_feature_qresync) == 0) {
                *error_r = "QRESYNC not enabled";
                return FALSE;
        }
@@ -411,7 +411,7 @@ bool cmd_select_full(struct client_command_context *cmd, bool readonly)
        if (ctx->condstore) {
                /* Enable while no mailbox is opened to avoid sending
                   HIGHESTMODSEQ for previously opened mailbox */
-               (void)client_enable(client, MAILBOX_FEATURE_CONDSTORE);
+               (void)client_enable(client, imap_feature_condstore);
        }
 
        ret = select_open(ctx, mailbox, readonly);
index 0a8302a987182ed590120477b6b83bed8420459d..f97decad2da4e2a07a7bb41124418190014665e1 100644 (file)
@@ -67,7 +67,7 @@ store_parse_modifiers(struct imap_store_context *ctx,
                                return FALSE;
                        }
                        (void)client_enable(ctx->cmd->client,
-                                           MAILBOX_FEATURE_CONDSTORE);
+                                           imap_feature_condstore);
                } else {
                        client_send_command_error(ctx->cmd,
                                                  "Unknown STORE modifier");
@@ -254,7 +254,7 @@ bool cmd_store(struct client_command_context *cmd)
           came externally, so we'll just send the UID for all flag
           changes that we see. */
        if (cmd->uid && (!ctx.silent || (client->enabled_features &
-                                        MAILBOX_FEATURE_CONDSTORE) != 0))
+                                        imap_feature_condstore) != 0))
                imap_sync_flags |= IMAP_SYNC_FLAG_SEND_UID;
 
        return cmd_sync(cmd, (cmd->uid ? 0 : MAILBOX_SYNC_FLAG_NO_EXPUNGES),
index 80b24e787741538965e75288f8a2131ea4851f8e..e994134b2cf925bbd6b1a83820d3474c8fde1bb8 100644 (file)
@@ -39,6 +39,9 @@ struct imap_module_register imap_module_register = { 0 };
 struct client *imap_clients = NULL;
 unsigned int imap_client_count = 0;
 
+unsigned int imap_feature_condstore = MAILBOX_FEATURE_CONDSTORE;
+unsigned int imap_feature_qresync = MAILBOX_FEATURE_QRESYNC;
+
 static const char *client_command_state_names[CLIENT_COMMAND_STATE_DONE+1] = {
        "wait-input",
        "wait-output",
@@ -1457,7 +1460,7 @@ int client_enable(struct client *client, enum mailbox_feature features)
                return 0;
 
        ret = mailbox_enable(client->mailbox, features);
-       if ((features & MAILBOX_FEATURE_CONDSTORE) != 0 && ret == 0) {
+       if ((features & imap_feature_condstore) != 0 && ret == 0) {
                /* CONDSTORE being enabled while mailbox is selected.
                   Notify client of the latest HIGHESTMODSEQ. */
                ret = mailbox_get_status(client->mailbox,
index d53dc1624d66b8cb77935788f63f45ca600735e8..637b644127fc334f48c6bf437f3580f8ecc0ecc1 100644 (file)
@@ -250,6 +250,9 @@ extern struct imap_module_register imap_module_register;
 extern struct client *imap_clients;
 extern unsigned int imap_client_count;
 
+extern unsigned int imap_feature_condstore;
+extern unsigned int imap_feature_qresync;
+
 /* Create new client with specified input/output handles. socket specifies
    if the handle is a socket. */
 struct client *client_create(int fd_in, int fd_out, const char *session_id,
index 4df3cd5ee88677670999b1f12ec5b719dbf8a1b8..ea5c00c8c9437b9a7dc1e550fd60abfd3c070b3d 100644 (file)
@@ -870,7 +870,7 @@ bool imap_fetch_modseq_init(struct imap_fetch_init_context *ctx)
                ctx->error = "FETCH MODSEQ can't be used with non-permanent modseqs";
                return FALSE;
        }
-       (void)client_enable(ctx->fetch_ctx->client, MAILBOX_FEATURE_CONDSTORE);
+       (void)client_enable(ctx->fetch_ctx->client, imap_feature_condstore);
        imap_fetch_add_handler(ctx, IMAP_FETCH_HANDLER_FLAG_BUFFERED,
                               NULL, fetch_modseq, NULL);
        return TRUE;
index cf8199e19ccb85ff93424d3b9b4b3dbfbf68140f..772af33176da26f80254a184e26bd1da41e49af6 100644 (file)
@@ -51,7 +51,7 @@ static int imap_notify_status(struct imap_notify_namespace *notify_ns,
        int ret = 1;
 
        i_zero(&items);
-       if ((client->enabled_features & MAILBOX_FEATURE_CONDSTORE) != 0)
+       if ((client->enabled_features & imap_feature_condstore) != 0)
                items.status |= STATUS_HIGHESTMODSEQ;
 
        box = mailbox_alloc(notify_ns->ns->list, rec->vname, 0);
index 95d5e40e537c22ed35ad42202360032fbd44e08b..521f3adc4d3522f634523e3d7f3bc1758ac2e01b 100644 (file)
@@ -576,7 +576,7 @@ bool imap_search_start(struct imap_search_context *ctx,
 
        if (ctx->have_modseqs) {
                ctx->return_options |= SEARCH_RETURN_MODSEQ;
-               (void)client_enable(cmd->client, MAILBOX_FEATURE_CONDSTORE);
+               (void)client_enable(cmd->client, imap_feature_condstore);
        }
 
        ctx->box = cmd->client->mailbox;
index edb6c15a2f0330882e4a02e72a656a5985fc5a82..1047aadc44005b8e124d779896ba4496521f7ebd 100644 (file)
@@ -238,7 +238,7 @@ imap_state_export_mailbox(buffer_t *dest, struct client *client,
        numpack_encode(dest, status.uidvalidity);
        numpack_encode(dest, status.uidnext);
        numpack_encode(dest, status.messages);
-       if ((client->enabled_features & MAILBOX_FEATURE_QRESYNC) != 0 &&
+       if ((client->enabled_features & imap_feature_qresync) != 0 &&
            !client->nonpermanent_modseqs)
                numpack_encode(dest, client->sync_last_full_modseq);
        else
@@ -284,12 +284,12 @@ int imap_state_export_base(struct client *client, bool internal,
 
        /* IMAP features */
        if (client->enabled_features != 0) {
-               i_assert((client->enabled_features & ~(MAILBOX_FEATURE_CONDSTORE |
-                                                      MAILBOX_FEATURE_QRESYNC)) == 0);
+               i_assert((client->enabled_features & ~(imap_feature_condstore |
+                                                      imap_feature_qresync)) == 0);
                buffer_append_c(dest, IMAP_STATE_TYPE_ENABLED_FEATURES);
-               if ((client->enabled_features & MAILBOX_FEATURE_CONDSTORE) != 0)
+               if ((client->enabled_features & imap_feature_condstore) != 0)
                        buffer_append_c(dest, IMAP_STATE_FEATURE_CONDSTORE);
-               if ((client->enabled_features & MAILBOX_FEATURE_QRESYNC) != 0)
+               if ((client->enabled_features & imap_feature_qresync) != 0)
                        buffer_append_c(dest, IMAP_STATE_FEATURE_QRESYNC);
                buffer_append_c(dest, '\0');
        }
@@ -427,7 +427,7 @@ import_send_expunges(struct client *client,
                return -1;
        }
 
-       if ((client->enabled_features & MAILBOX_FEATURE_QRESYNC) == 0) {
+       if ((client->enabled_features & imap_feature_qresync) == 0) {
                str = t_str_new(32);
                for (i = expunge_count; i > 0; i--) {
                        str_truncate(str, 0);
@@ -475,7 +475,7 @@ import_send_flag_changes(struct client *client,
        pool_unref(&pool);
 
        imap_fetch_init_nofail_handler(fetch_ctx, imap_fetch_flags_init);
-       if ((client->enabled_features & MAILBOX_FEATURE_QRESYNC) != 0) {
+       if ((client->enabled_features & imap_feature_qresync) != 0) {
                imap_fetch_init_nofail_handler(fetch_ctx, imap_fetch_uid_init);
                imap_fetch_init_nofail_handler(fetch_ctx, imap_fetch_modseq_init);
        }
@@ -678,7 +678,7 @@ import_state_mailbox_open(struct client *client,
                *error_r = "Couldn't send flag changes";
                return -1;
        }
-       if ((client->enabled_features & MAILBOX_FEATURE_QRESYNC) != 0 &&
+       if ((client->enabled_features & imap_feature_qresync) != 0 &&
            !client->nonpermanent_modseqs &&
            status.highest_modseq != state->highest_modseq) {
                client_send_line(client, t_strdup_printf(
@@ -730,10 +730,10 @@ import_state_enabled_features(struct client *client, const unsigned char *data,
                feature = data[i];
                switch (feature) {
                case IMAP_STATE_FEATURE_CONDSTORE:
-                       client->enabled_features |= MAILBOX_FEATURE_CONDSTORE;
+                       client->enabled_features |= imap_feature_condstore;
                        break;
                case IMAP_STATE_FEATURE_QRESYNC:
-                       client->enabled_features |= MAILBOX_FEATURE_QRESYNC;
+                       client->enabled_features |= imap_feature_qresync;
                        break;
                default:
                        *error_r = t_strdup_printf(
index 56e7fbb0ac90305d53e03498f4edbfe1819ecc32..01cb8f8883d9fa92de13662c2d5cddd5b1b60061 100644 (file)
@@ -80,7 +80,7 @@ int imap_status_get(struct client_command_context *cmd,
        }
 
        if ((items->status & STATUS_HIGHESTMODSEQ) != 0)
-               (void)client_enable(client, MAILBOX_FEATURE_CONDSTORE);
+               (void)client_enable(client, imap_feature_condstore);
 
        ret = mailbox_get_status(box, items->status, &result_r->status);
        if (items->metadata != 0 && ret == 0) {
index ad5d471f6a3f0cefac9d08a076b40eff2be7ad65..658e0a2a18aa609f08bff3a9b06d3e4eeb1c6e3c 100644 (file)
@@ -195,7 +195,7 @@ imap_sync_init(struct client *client, struct mailbox *box,
        ctx->messages_count = client->messages_count;
        i_array_init(&ctx->tmp_keywords, client->keywords.announce_count + 8);
 
-       if ((client->enabled_features & MAILBOX_FEATURE_QRESYNC) != 0) {
+       if ((client->enabled_features & imap_feature_qresync) != 0) {
                i_array_init(&ctx->expunges, 128);
                /* always send UIDs in FETCH replies */
                ctx->imap_flags |= IMAP_SYNC_FLAG_SEND_UID;
@@ -345,7 +345,7 @@ int imap_sync_deinit(struct imap_sync_context *ctx,
        ret = imap_sync_finish(ctx, TRUE);
        imap_client_notify_finished(ctx->client);
 
-       if ((ctx->client->enabled_features & MAILBOX_FEATURE_QRESYNC) != 0 &&
+       if ((ctx->client->enabled_features & imap_feature_qresync) != 0 &&
            !ctx->client->nonpermanent_modseqs)
                imap_sync_send_highestmodseq(ctx, sync_cmd);
 
@@ -387,7 +387,7 @@ static int imap_sync_send_flags(struct imap_sync_context *ctx, string_t *str)
        str_printfa(str, "* %u FETCH (", ctx->seq);
        if ((ctx->imap_flags & IMAP_SYNC_FLAG_SEND_UID) != 0)
                str_printfa(str, "UID %u ", ctx->mail->uid);
-       if ((ctx->client->enabled_features & MAILBOX_FEATURE_CONDSTORE) != 0 &&
+       if ((ctx->client->enabled_features & imap_feature_condstore) != 0 &&
            !ctx->client->nonpermanent_modseqs) {
                imap_sync_add_modseq(ctx, str);
                str_append_c(str, ' ');
@@ -557,7 +557,7 @@ int imap_sync_more(struct imap_sync_context *ctx)
                        break;
                case MAILBOX_SYNC_TYPE_MODSEQ:
                        if ((ctx->client->enabled_features &
-                            MAILBOX_FEATURE_CONDSTORE) == 0)
+                            imap_feature_condstore) == 0)
                                break;
                        if (!ctx->client->notify_flag_changes) {
                                /* NOTIFY: FlagChange not specified for