+++ /dev/null
-/* Copyright (c) 2015-2018 Dovecot authors, see the included COPYING file */
-
-#include "imap-common.h"
-#include "base64.h"
-#include "str.h"
-#include "imap-commands.h"
-#include "imap-state.h"
-
-bool cmd_x_state(struct client_command_context *cmd)
-{
- /* FIXME: state importing can cause unnecessarily large memory usage
- by specifying an old modseq, because the EXPUNGE/FETCH replies
- aren't currently sent asynchronously. so this command is disabled
- for now. */
-#if 0
- const struct imap_arg *args;
- const char *str, *error;
- buffer_t *state, *state_encoded;
- int ret;
-
- if (!client_read_args(cmd, 0, 0, &args))
- return FALSE;
-
- state = buffer_create_dynamic(cmd->pool, 256);
- if (imap_arg_get_astring(&args[0], &str)) {
- if (cmd->client->mailbox != NULL) {
- client_send_tagline(cmd,
- "BAD Can't be used in SELECTED state");
- return TRUE;
- }
- if (base64_decode(str, strlen(str), NULL, state) < 0)
- ret = 0;
- else {
- ret = imap_state_import_external(cmd->client,
- state->data, state->used, &error);
- }
- if (ret < 0) {
- client_send_tagline(cmd, t_strdup_printf(
- "NO Failed to restore state: %s", error));
- } else if (ret == 0) {
- client_send_tagline(cmd, t_strdup_printf(
- "BAD Broken state: %s", error));
- } else {
- client_send_tagline(cmd, "OK State imported.");
- }
- return TRUE;
- } else if (args[0].type == IMAP_ARG_EOL) {
- if (!imap_state_export_external(cmd->client, state, &error)) {
- client_send_tagline(cmd, t_strdup_printf(
- "NO Can't save state: %s", error));
- return TRUE;
- }
- state_encoded = buffer_create_dynamic(cmd->pool,
- MAX_BASE64_ENCODED_SIZE(state->used)+10);
- str_append(state_encoded, "* STATE ");
- base64_encode(state->data, state->used, state_encoded);
- client_send_line(cmd->client, str_c(state_encoded));
- client_send_tagline(cmd, "OK State exported.");
- return TRUE;
- } else {
- client_send_command_error(cmd, "Invalid arguments.");
- return TRUE;
- }
-#else
- client_send_command_error(cmd, "Command is disabled for now.");
- return TRUE;
-#endif
-}
{ "UID THREAD", cmd_thread, COMMAND_FLAG_BREAKS_SEQS },
{ "UNSELECT", cmd_unselect, COMMAND_FLAG_BREAKS_MAILBOX },
{ "X-CANCEL", cmd_x_cancel, 0 },
- { "X-STATE", cmd_x_state, COMMAND_FLAG_REQUIRES_SYNC },
{ "XLIST", cmd_list, 0 },
/* IMAP URLAUTH (RFC4467): */
{ "GENURLAUTH", cmd_genurlauth, 0 },
int imap_state_export_internal(struct client *client, buffer_t *dest,
const char **error_r)
{
- /* the only IMAP command we allow running is IDLE or X-STATE */
+ /* the only IMAP command we allow running is IDLE */
if (client->command_queue_size > 1) {
*error_r = "Multiple commands in progress";
return 0;
return client->v.state_export(client, TRUE, dest, error_r);
}
-int imap_state_export_external(struct client *client, buffer_t *dest,
- const char **error_r)
-{
- if (client->command_queue_size > 1) {
- *error_r = "Multiple commands in progress";
- return 0;
- }
-
- i_assert(client->command_queue_size == 1);
- i_assert(strcmp(client->command_queue->name, "X-STATE") == 0);
- return client->v.state_export(client, FALSE, dest, error_r);
-}
-
static int
imap_state_import(struct client *client, bool internal,
const unsigned char *data, size_t size, const char **error_r)
0 if state couldn't be exported, -1 if temporary internal error error. */
int imap_state_export_internal(struct client *client, buffer_t *dest,
const char **error_r);
-int imap_state_export_external(struct client *client, buffer_t *dest,
- const char **error_r);
/* Returns 1 if ok, 0 if state was corrupted, -1 if other error. Internal state
comes from another Dovecot component, which can override IP addresses,