bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2013-2018 Dovecot authors, see the included COPYING file */
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainencmd_flags_run_box(struct flags_cmd_context *ctx,
2dbb7b30d9bf6d6b0cd104c6931c4b44a77c2383Aki Tuomi if (doveadm_mail_iter_init(&ctx->ctx, info, ctx->ctx.search_args,
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainen if (mailbox_keywords_create(box, ctx->keywords, &kw) < 0) {
bf7dc750b95039981c0e9d728f313d50cf38a156Martti Rannanjärvi mailbox_get_last_internal_error(box, NULL));
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainen mail_update_flags(mail, ctx->modify_type, ctx->flags);
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainen mail_update_keywords(mail, ctx->modify_type, kw);
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainencmd_flags_run(struct doveadm_mail_cmd_context *_ctx, struct mail_user *user)
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainen struct flags_cmd_context *ctx = (struct flags_cmd_context *)_ctx;
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainen const enum mailbox_list_iter_flags iter_flags =
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainen iter = doveadm_mailbox_list_iter_init(_ctx, user, _ctx->search_args,
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainen while ((info = doveadm_mailbox_list_iter_next(iter)) != NULL) T_BEGIN {
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainen if (doveadm_mailbox_list_iter_deinit(&iter) < 0)
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainenstatic void cmd_flags_init(struct doveadm_mail_cmd_context *_ctx,
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainen const char *const args[])
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainen struct flags_cmd_context *ctx = (struct flags_cmd_context *)_ctx;
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainen for (tmp = t_strsplit(args[0], " "); *tmp != NULL; tmp++) {
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainen if (array_count(&keywords) > 0 || ctx->modify_type == MODIFY_REPLACE) {
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainen _ctx->search_args = doveadm_mail_build_search_args(args+1);
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainen ctx = doveadm_mail_cmd_alloc(struct flags_cmd_context);
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainenstatic struct doveadm_mail_cmd_context *cmd_flags_add_alloc(void)
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainenstatic struct doveadm_mail_cmd_context *cmd_flags_remove_alloc(void)
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainenstatic struct doveadm_mail_cmd_context *cmd_flags_replace_alloc(void)
a893aaa999856b1ba6e4541890016767aaa283c7Aki Tuomistruct doveadm_cmd_ver2 doveadm_cmd_flags_add_ver2 = {
a893aaa999856b1ba6e4541890016767aaa283c7Aki Tuomi .usage = DOVEADM_CMD_MAIL_USAGE_PREFIX "<flags> <search query>",
2d83aa5eebd1bb710ca2fc21316b89442f027f3dAki TuomiDOVEADM_CMD_PARAM('\0', "flag", CMD_PARAM_ARRAY, 0)
2d83aa5eebd1bb710ca2fc21316b89442f027f3dAki TuomiDOVEADM_CMD_PARAM('\0', "flagstr", CMD_PARAM_STR, CMD_PARAM_FLAG_POSITIONAL|CMD_PARAM_FLAG_DO_NOT_EXPOSE)
a893aaa999856b1ba6e4541890016767aaa283c7Aki TuomiDOVEADM_CMD_PARAM('\0', "query", CMD_PARAM_ARRAY, CMD_PARAM_FLAG_POSITIONAL)
a893aaa999856b1ba6e4541890016767aaa283c7Aki Tuomistruct doveadm_cmd_ver2 doveadm_cmd_flags_remove_ver2 = {
a893aaa999856b1ba6e4541890016767aaa283c7Aki Tuomi .usage = DOVEADM_CMD_MAIL_USAGE_PREFIX "<flags> <search query>",
2d83aa5eebd1bb710ca2fc21316b89442f027f3dAki TuomiDOVEADM_CMD_PARAM('\0', "flag", CMD_PARAM_ARRAY, 0)
2d83aa5eebd1bb710ca2fc21316b89442f027f3dAki TuomiDOVEADM_CMD_PARAM('\0', "flagstr", CMD_PARAM_STR, CMD_PARAM_FLAG_POSITIONAL|CMD_PARAM_FLAG_DO_NOT_EXPOSE)
a893aaa999856b1ba6e4541890016767aaa283c7Aki TuomiDOVEADM_CMD_PARAM('\0', "query", CMD_PARAM_ARRAY, CMD_PARAM_FLAG_POSITIONAL)
a893aaa999856b1ba6e4541890016767aaa283c7Aki Tuomistruct doveadm_cmd_ver2 doveadm_cmd_flags_replace_ver2 = {
a893aaa999856b1ba6e4541890016767aaa283c7Aki Tuomi .usage = DOVEADM_CMD_MAIL_USAGE_PREFIX "<flags> <search query>",
2d83aa5eebd1bb710ca2fc21316b89442f027f3dAki TuomiDOVEADM_CMD_PARAM('\0', "flag", CMD_PARAM_ARRAY, 0)
2d83aa5eebd1bb710ca2fc21316b89442f027f3dAki TuomiDOVEADM_CMD_PARAM('\0', "flagstr", CMD_PARAM_STR, CMD_PARAM_FLAG_POSITIONAL|CMD_PARAM_FLAG_DO_NOT_EXPOSE)