bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2015-2018 Dovecot authors, see the included COPYING file */
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainenbool cmd_x_state(struct client_command_context *cmd)
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen /* FIXME: state importing can cause unnecessarily large memory usage
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen by specifying an old modseq, because the EXPUNGE/FETCH replies
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen aren't currently sent asynchronously. so this command is disabled
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen state = buffer_create_dynamic(cmd->pool, 256);
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen "BAD Can't be used in SELECTED state");
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen if (base64_decode(str, strlen(str), NULL, state) < 0)
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen } else if (ret == 0) {
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen client_send_tagline(cmd, "OK State imported.");
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen if (!imap_state_export_external(cmd->client, state, &error)) {
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen state_encoded = buffer_create_dynamic(cmd->pool,
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen base64_encode(state->data, state->used, state_encoded);
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen client_send_line(cmd->client, str_c(state_encoded));
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen client_send_tagline(cmd, "OK State exported.");
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen client_send_command_error(cmd, "Invalid arguments.");
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen client_send_command_error(cmd, "Command is disabled for now.");