index-attribute.c revision 9f37ef2a9192e7d47e3d7ac959080fd01120f2e9
/* Copyright (c) 2013-2016 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "ioloop.h"
#include "dict.h"
#include "index-storage.h"
struct index_storage_attribute_iter {
struct mailbox_attribute_iter iter;
struct dict_iterate_context *diter;
char *prefix;
unsigned int prefix_len;
bool dict_disabled;
};
static struct mail_namespace *
{
struct mail_namespace *ns;
return ns;
return ns;
}
return NULL;
}
static int
{
struct dict_settings dict_set;
struct mail_namespace *ns;
struct mail_storage *attr_storage;
const char *error;
return 0;
}
if (user->attr_dict_failed) {
return -1;
}
/* probably never happens? */
"Mailbox attributes not available for this mailbox");
return -1;
}
"Mailbox attributes not enabled");
return -1;
}
"mail_attribute_dict: dict_init(%s) failed: %s",
return -1;
}
return 0;
}
static int
{
struct mail_namespace *ns;
struct mailbox_metadata metadata;
struct dict_settings set;
const char *error;
return -1;
if (type == MAIL_ATTRIBUTE_TYPE_PRIVATE) {
/* private attributes are stored in user's own dict */
/* user owns the mailbox. shared attributes are stored in
the same dict. */
/* accessing shared attribute of a shared mailbox.
use the owner's dict. */
}
/* accessing shared attributes of a public mailbox. no user owns it,
so use the storage's dict. */
return 0;
}
"Mailbox attributes not enabled");
return -1;
}
if (storage->shared_attr_dict_failed) {
return -1;
}
"mail_attribute_dict: dict_init(%s) failed: %s",
return -1;
}
return 0;
}
static const char *
const char *key)
{
switch (type) {
}
i_unreached();
}
static int
enum mail_attribute_type type,
struct dict_transaction_context **dtrans_r,
const char **mailbox_prefix_r)
{
struct mailbox_metadata metadata;
switch (type) {
dtransp = &t->attr_pvt_trans;
break;
dtransp = &t->attr_shared_trans;
break;
}
/* transaction already created */
&metadata) < 0)
return -1;
return 0;
}
return -1;
return 0;
}
int index_storage_attribute_set(struct mailbox_transaction_context *t,
const struct mail_attribute_value *value,
bool internal_attribute)
{
struct dict_transaction_context *dtrans;
const char *mailbox_prefix;
int ret = 0;
if (!internal_attribute &&
"Internal attributes cannot be changed directly");
return -1;
}
&mailbox_prefix) < 0)
return -1;
T_BEGIN {
const char *prefixed_key =
const char *value_str;
&value_str) < 0) {
ret = -1;
} else {
}
} T_END;
return ret;
}
struct mail_attribute_value *value_r,
bool internal_attribute)
{
const char *mailbox_prefix, *error;
int ret;
if (!internal_attribute &&
return 0;
return -1;
if (ret < 0) {
return -1;
}
return ret;
}
struct mailbox_attribute_iter *
enum mail_attribute_type type,
const char *prefix)
{
struct index_storage_attribute_iter *iter;
const char *mailbox_prefix;
} else {
prefix));
}
}
const char *
{
struct index_storage_attribute_iter *iter =
(struct index_storage_attribute_iter *)_iter;
return NULL;
return key;
}
{
struct index_storage_attribute_iter *iter =
(struct index_storage_attribute_iter *)_iter;
const char *error;
int ret;
} else {
"dict_iterate(%s) failed: %s",
}
}
return ret;
}