doveadm-mail-import.c revision 567728568fc7f9e88eb9629b3bbb342a72810a61
/* Copyright (c) 2010 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "mail-storage.h"
#include "mail-storage-service.h"
#include "mail-namespace.h"
#include "doveadm-mail-list-iter.h"
#include "doveadm-mail-iter.h"
#include "doveadm-mail.h"
struct import_cmd_context {
struct doveadm_mail_cmd_context ctx;
const char *dest_parent;
};
static int
{
struct mail_namespace *ns;
enum mail_error error;
const char *errstr, *storage_name;
/* prefix destination mailbox name with given parent mailbox */
i_error("Can't find namespace for parent mailbox %s",
ctx->dest_parent);
return -1;
}
}
storage_name = name;
return -1;
}
&error);
if (error != MAIL_ERROR_EXISTS) {
mailbox_free(&box);
return -1;
}
}
NULL));
mailbox_free(&box);
return -1;
}
return 0;
}
static int
{
struct mail_save_context *save_ctx;
struct mailbox_transaction_context *dest_trans;
int ret = 0;
do {
if (doveadm_debug) {
i_debug("import: box=%s uid=%u",
}
i_error("Copying box=%s uid=%u failed: %s",
ret = -1;
}
if (mailbox_transaction_commit(&dest_trans) < 0) {
ret = -1;
}
return ret;
}
static int
const struct mailbox_info *info,
struct mail_search_args *search_args)
{
struct doveadm_mail_iter *iter;
struct mailbox_transaction_context *trans;
int ret = 0;
return -1;
/* at least one mail matches in this mailbox */
&box) == 0) {
ret = -1;
mailbox_free(&box);
}
}
if (doveadm_mail_iter_deinit_sync(&iter) < 0)
ret = -1;
return ret;
}
static void
{
const enum mailbox_list_iter_flags iter_flags =
struct doveadm_mail_list_iter *iter;
const struct mailbox_info *info;
} T_END;
}
const char *const args[])
{
struct mail_storage_service_input input;
struct mail_storage_service_user *service_user;
doveadm_mail_help_name("import");
src_location = args[0];
/* @UNSAFE */
/* create a user for accessing the source storage */
}
{
}
static struct doveadm_mail_cmd_context *cmd_import_alloc(void)
{
struct doveadm_mail_cmd_context *ctx;
return ctx;
}
struct doveadm_mail_cmd cmd_import = {
cmd_import_alloc, "import",
"<source mail location> <dest parent mailbox> <search query>"
};