bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2003-2018 Dovecot authors, see the included COPYING file */
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomi
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomi#include "imap-common.h"
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomi#include "str.h"
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomi
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomibool cmd_enable(struct client_command_context *cmd)
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomi{
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomi const struct imap_arg *args;
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomi const char *str;
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomi string_t *reply;
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomi
1acc8d6538864577b8f40cc4e1ca922a62f52327Aki Tuomi if (!client_read_args(cmd, 0, 0, &args))
4fbe0d10901a80b27aacc9d9e6848e30e5fe727dAki Tuomi return FALSE;
17541ea25593c656060199715051db2c1eef221dAki Tuomi
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomi reply = t_str_new(64);
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomi str_append(reply, "* ENABLED");
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomi for (; !IMAP_ARG_IS_EOL(args); args++) {
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomi if (!imap_arg_get_atom(args, &str)) {
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomi client_send_command_error(cmd, "Invalid arguments.");
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomi return TRUE;
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomi }
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomi str = t_str_ucase(str);
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomi if (strcmp(str, "CONDSTORE") == 0) {
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomi if (client_enable(cmd->client,
4fbe0d10901a80b27aacc9d9e6848e30e5fe727dAki Tuomi MAILBOX_FEATURE_CONDSTORE) == 0)
4fbe0d10901a80b27aacc9d9e6848e30e5fe727dAki Tuomi str_append(reply, " CONDSTORE");
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomi } else if (strcmp(str, "QRESYNC") == 0) {
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomi if (client_enable(cmd->client, MAILBOX_FEATURE_QRESYNC |
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomi MAILBOX_FEATURE_CONDSTORE) == 0)
4fbe0d10901a80b27aacc9d9e6848e30e5fe727dAki Tuomi str_append(reply, " QRESYNC");
4fbe0d10901a80b27aacc9d9e6848e30e5fe727dAki Tuomi }
4fbe0d10901a80b27aacc9d9e6848e30e5fe727dAki Tuomi }
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomi if (str_len(reply) > 9)
4fbe0d10901a80b27aacc9d9e6848e30e5fe727dAki Tuomi client_send_line(cmd->client, str_c(reply));
4fbe0d10901a80b27aacc9d9e6848e30e5fe727dAki Tuomi client_send_tagline(cmd, "OK Enabled.");
4fbe0d10901a80b27aacc9d9e6848e30e5fe727dAki Tuomi return TRUE;
4fbe0d10901a80b27aacc9d9e6848e30e5fe727dAki Tuomi}
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomi
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomi