dovecot-2.1: doveadm import: Added -s parameter to subscribe to ...
dovecot at dovecot.org
dovecot at dovecot.org
Sat Nov 5 19:49:38 EET 2011
details: http://hg.dovecot.org/dovecot-2.1/rev/afec4ceda8e1
changeset: 13665:afec4ceda8e1
user: Timo Sirainen <tss at iki.fi>
date: Sat Nov 05 19:59:55 2011 +0200
description:
doveadm import: Added -s parameter to subscribe to created mailboxes.
diffstat:
src/doveadm/doveadm-mail-import.c | 25 ++++++++++++++++++++++++-
1 files changed, 24 insertions(+), 1 deletions(-)
diffs (59 lines):
diff -r 3248730d84ae -r afec4ceda8e1 src/doveadm/doveadm-mail-import.c
--- a/src/doveadm/doveadm-mail-import.c Sat Nov 05 19:37:23 2011 +0200
+++ b/src/doveadm/doveadm-mail-import.c Sat Nov 05 19:59:55 2011 +0200
@@ -14,6 +14,7 @@
struct mail_user *src_user;
const char *dest_parent;
+ bool subscribe;
};
static int
@@ -53,6 +54,12 @@
return -1;
}
}
+ if (ctx->subscribe) {
+ if (mailbox_set_subscribed(box, TRUE) < 0) {
+ i_error("Couldn't subscribe to mailbox %s: %s",
+ name, mailbox_get_last_error(box, NULL));
+ }
+ }
if (mailbox_sync(box, MAILBOX_SYNC_FLAG_FULL_READ) < 0) {
i_error("Syncing mailbox %s failed: %s", name,
mailbox_get_last_error(box, NULL));
@@ -183,11 +190,27 @@
mail_user_unref(&ctx->src_user);
}
+static bool cmd_import_parse_arg(struct doveadm_mail_cmd_context *_ctx, int c)
+{
+ struct import_cmd_context *ctx = (struct import_cmd_context *)_ctx;
+
+ switch (c) {
+ case 's':
+ ctx->subscribe = TRUE;
+ break;
+ default:
+ return FALSE;
+ }
+ return TRUE;
+}
+
static struct doveadm_mail_cmd_context *cmd_import_alloc(void)
{
struct import_cmd_context *ctx;
ctx = doveadm_mail_cmd_alloc(struct import_cmd_context);
+ ctx->ctx.getopt_args = "s";
+ ctx->ctx.v.parse_arg = cmd_import_parse_arg;
ctx->ctx.v.init = cmd_import_init;
ctx->ctx.v.deinit = cmd_import_deinit;
ctx->ctx.v.run = cmd_import_run;
@@ -196,5 +219,5 @@
struct doveadm_mail_cmd cmd_import = {
cmd_import_alloc, "import",
- "<source mail location> <dest parent mailbox> <search query>"
+ "[-s] <source mail location> <dest parent mailbox> <search query>"
};
More information about the dovecot-cvs
mailing list