doveadm-mail-copymove.c revision 00b10a9ca50bca190e72a19aa6571ea612701d82
/* Copyright (c) 2011-2016 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "mail-storage.h"
#include "mail-namespace.h"
#include "doveadm-print.h"
#include "doveadm-mailbox-list-iter.h"
#include "doveadm-mail-iter.h"
#include "doveadm-mail.h"
#include <stdio.h>
struct copy_cmd_context {
struct doveadm_mail_cmd_context ctx;
const char *source_username;
struct mail_user *source_user;
const char *destname;
bool move;
};
static int
const struct mailbox_info *info)
{
struct doveadm_mail_iter *iter;
struct mailbox_transaction_context *desttrans;
struct mail_save_context *save_ctx;
int ret = 0;
return -1;
/* use a separately committed transaction for each mailbox.
this guarantees that mails aren't expunged without actually having
been copied. */
} else {
i_error("Copying message UID %u from '%s' failed: %s",
ret = -1;
}
}
if (mailbox_transaction_commit(&desttrans) < 0) {
i_error("Committing %s mails failed: %s",
/* rollback expunges */
ret = -1;
} else {
if (doveadm_mail_iter_deinit_sync(&iter) < 0)
ret = -1;
}
return ret;
}
static void
{
struct mail_storage_service_input input;
const char *error;
&ctx->source_user,
&error) < 0)
}
static int
{
const enum mailbox_list_iter_flags iter_flags =
struct doveadm_mailbox_list_iter *iter;
struct mail_namespace *ns;
const struct mailbox_info *info;
int ret = 0;
if (mailbox_open(destbox) < 0) {
return -1;
}
ret = -1;
} T_END;
if (doveadm_mailbox_list_iter_deinit(&iter) < 0)
ret = -1;
if (mailbox_sync(destbox, 0) < 0) {
ret = -1;
}
return ret;
}
const char *const args[])
{
args++;
if ((_ctx->service_flags &
i_fatal("Use -u parameter to specify destination user");
args += 2;
}
}
{
}
}
static struct doveadm_mail_cmd_context *cmd_copy_alloc(void)
{
struct copy_cmd_context *ctx;
}
static struct doveadm_mail_cmd_context *cmd_move_alloc(void)
{
struct copy_cmd_context *ctx;
}
struct doveadm_cmd_ver2 doveadm_cmd_copy_ver2 = {
.name = "copy",
};
struct doveadm_cmd_ver2 doveadm_cmd_move_ver2 = {
.name = "move",
};