doveadm-mail-import.c revision a4788903191c2218ea46057b70a2b3a1f7c31e13
/* Copyright (c) 2010-2011 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;
bool subscribe;
};
static int
{
struct mail_namespace *ns;
enum mail_error error;
const char *errstr;
/* prefix destination mailbox name with given parent mailbox */
i_error("Can't find namespace for parent mailbox %s",
ctx->dest_parent);
return -1;
}
}
return -1;
}
if (error != MAIL_ERROR_EXISTS) {
mailbox_free(&box);
return -1;
}
}
i_error("Couldn't subscribe to mailbox %s: %s",
}
}
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;
const char *src_location, *error;
doveadm_mail_help_name("import");
src_location = args[0];
/* create a user for accessing the source storage */
}
{
}
{
switch (c) {
case 's':
break;
default:
return FALSE;
}
return TRUE;
}
static struct doveadm_mail_cmd_context *cmd_import_alloc(void)
{
struct import_cmd_context *ctx;
}
struct doveadm_mail_cmd cmd_import = {
cmd_import_alloc, "import",
"[-s] <source mail location> <dest parent mailbox> <search query>"
};