mail-namespace.c revision 98b27a037e337fdd3965469884245b409e3a1e84
02c335c23bf5fa225a467c19f2c063fb0dc7b8c3Timo Sirainen/* Copyright (c) 2005-2010 Dovecot authors, see the included COPYING file */
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainenvoid mail_namespace_add_storage(struct mail_namespace *ns,
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainen /* currently we support only a single storage */
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainenvoid mail_namespace_finish_list_init(struct mail_namespace *ns,
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainen /* allow plugins to override real_sep */
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainenstatic void mail_namespace_free(struct mail_namespace *ns)
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainen if (ns->owner != ns->user && ns->owner != NULL)
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainen struct mail_namespace_settings *unexpanded_ns_set,
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainen struct mail_namespace **ns_p, const char **error_r)
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainen if (strncmp(ns_set->type, "private", 7) == 0) {
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainen } else if (strncmp(ns_set->type, "shared", 6) == 0)
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainen else if (strncmp(ns_set->type, "public", 6) == 0)
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainen *error_r = t_strdup_printf("Unknown namespace type: %s",
209335fbc1a5fe68e662242ea91e236fdb2ba29dTimo Sirainen *error_r = t_strdup_printf("Invalid list setting value: %s",
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainen i_debug("Namespace %s: type=%s, prefix=%s, sep=%s, "
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainen "inbox=%s, hidden=%s, list=%s, subscriptions=%s "
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainen "location=%s",
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainen ns_set->separator == NULL ? "" : ns_set->separator,
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainen ns_set->subscriptions ? "yes" : "no", ns_set->location);
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainen /* dynamic shared namespace. the above check catches wrong
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainen mixed %% usage, but still allows for specifying a shared
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainen namespace to an explicit location without any %% */
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainen ns->flags |= NAMESPACE_FLAG_NOQUOTA | NAMESPACE_FLAG_NOACL;
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainen if (mail_storage_create(ns, driver, 0, &error) < 0) {
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainen *error_r = t_strdup_printf("Namespace '%s': %s",
2d83aa5eebd1bb710ca2fc21316b89442f027f3dAki Tuomistatic bool namespace_is_valid_alias_storage(struct mail_namespace *ns,
a893aaa999856b1ba6e4541890016767aaa283c7Aki Tuomi const char **error_r)
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainen if (strcmp(ns->storage->name, ns->alias_for->storage->name) != 0) {
a893aaa999856b1ba6e4541890016767aaa283c7Aki Tuomi "Namespace %s can't have alias_for=%s "
a893aaa999856b1ba6e4541890016767aaa283c7Aki Tuomi "to a different storage type (%s vs %s)",
2d83aa5eebd1bb710ca2fc21316b89442f027f3dAki Tuomi if ((ns->storage->class_flags & MAIL_STORAGE_CLASS_FLAG_UNIQUE_ROOT) != 0 &&
6eb7938cd366fc087b39fc9a901e7de426131384Timo Sirainen "Namespace %s can't have alias_for=%s "
a893aaa999856b1ba6e4541890016767aaa283c7Aki Tuomi "to a different storage (different root dirs)",
a893aaa999856b1ba6e4541890016767aaa283c7Aki Tuomi const char **error_r)
unsigned int subscriptions_count = 0;
return FALSE;
return FALSE;
return FALSE;
NAMESPACE_FLAG_LIST_CHILDREN)) != 0 &&
return FALSE;
NAMESPACE_FLAG_LIST_CHILDREN)) != 0 &&
return FALSE;
NAMESPACE_FLAG_LIST_CHILDREN)) != 0) {
return FALSE;
return FALSE;
return FALSE;
if (subscriptions_count == 0) {
return FALSE;
return TRUE;
count = 0;
for (i = 0; i < count; i++) {
T_BEGIN {
} T_END;
T_BEGIN {
} T_END;
return ns;
void *context)
char *ret, *p;
return name;
return name;
return ret;
const char *name)
if (len > 0) {
const char *name)
struct mail_storage *
return TRUE;
return TRUE;
return TRUE;
return FALSE;
static struct mail_namespace *
const char **mailbox,
bool inbox;
return ns;
return best;
if (best_len > 0) {
return best;
static struct mail_namespace *
return ns;
struct mail_namespace *
return ns;
struct mail_namespace *
const char **mailbox)
struct mail_namespace *
const char **mailbox)
struct mail_namespace *
const char **mailbox)
struct mail_namespace *
return namespaces;
const char **mailbox)
struct mail_namespace *
const char *prefix)
return ns;
return NULL;
struct mail_namespace *
const char *prefix)
return ns;
return NULL;