/* Copyright (c) 2014-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "str.h"
#include "mail-namespace.h"
#include "mail-storage.h"
#include "doveadm-print.h"
#include "doveadm-mail.h"
#include "doveadm-mailbox-list-iter.h"
struct metadata_cmd_context {
const char *mailbox;
const char *key;
bool empty_mailbox_name;
bool allow_empty_mailbox_name;
};
static int
const char *op,
struct mail_namespace **ns_r,
{
if (mctx->empty_mailbox_name) {
if (!mctx->allow_empty_mailbox_name) {
"mailbox name cannot be empty");
return -1;
}
/* server attribute */
} else {
/* mailbox attributes */
}
if (mailbox_open(*box_r) < 0) {
i_error("Failed to open mailbox: %s",
return -1;
}
return 0;
}
static int
{
int ret;
if (ret != 0)
return ret;
__func__);
if (ret < 0) {
i_error("Failed to set attribute: %s",
} else if (mailbox_transaction_commit(&trans) < 0) {
i_error("Failed to commit transaction: %s",
ret = -1;
}
mailbox_free(&box);
return ret;
}
static void
enum mail_attribute_type *type_r,
const char **key_r)
{
*key_r = "";
*key_r = "";
} else {
"Must begin with /private or /shared", arg);
}
}
static void
const char *const args[])
{
const char *key;
doveadm_mail_help_name("mailbox metadata set");
}
static bool
{
(struct metadata_cmd_context *)_ctx;
switch (c) {
case 's':
break;
default:
return FALSE;
}
return TRUE;
}
{
}
static void
const char *const args[])
{
const char *key;
doveadm_mail_help_name("mailbox metadata unset");
}
{
}
static int
{
int ret;
if (ret != 0)
return ret;
if (ret < 0) {
i_error("Failed to get attribute: %s",
} else if (ret == 0) {
/* not found, print as empty */
doveadm_print("");
} else {
}
mailbox_free(&box);
return ret;
}
static void
const char *const args[])
{
const char *key;
doveadm_mail_help_name("mailbox metadata get");
}
{
}
static int
enum mail_attribute_type type)
{
const char *key;
if (mailbox_attribute_iter_deinit(&iter) < 0) {
i_error("Mailbox %s: Failed to iterate mailbox attributes: %s",
return -1;
}
return 0;
}
static int
{
int ret = 0;
if (ret != 0)
return ret;
ret = -1;
}
}
ret = -1;
}
}
mailbox_free(&box);
return ret;
}
static void
const char *const args[])
{
doveadm_mail_help_name("mailbox metadata list");
}
{
}
.name = "mailbox metadata set",
};
.name = "mailbox metadata unset",
};
.name = "mailbox metadata get",
};
.name = "mailbox metadata list",
};