mail-namespace.c revision 142476eefd60e583ffa540e70dfe408f58650b59
c25356d5978632df6203437e1953bcb29e0c736fTimo Sirainen/* Copyright (c) 2005-2009 Dovecot authors, see the included COPYING file */
87a6b7df39d6822a5a8289a62f32deabff9b75e4Timo Sirainenvoid (*hook_mail_namespaces_created)(struct mail_namespace *namespaces);
87a6b7df39d6822a5a8289a62f32deabff9b75e4Timo Sirainenvoid mail_namespace_add_storage(struct mail_namespace *ns,
87a6b7df39d6822a5a8289a62f32deabff9b75e4Timo Sirainen /* currently we support only a single storage */
da2aa032ccfa8e7e4a4380ef738014549f4d2c2dTimo Sirainenvoid mail_namespace_finish_list_init(struct mail_namespace *ns,
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen ns->real_sep = mailbox_list_get_hierarchy_sep(list);
fe363b433b8038a69b55169da9dca27892ad7d18Timo Sirainenstatic void mail_namespace_free(struct mail_namespace *ns)
bdcb00145ad87765e3fd22d4ebc4d2c029a326b9Timo Sirainen if (ns->owner != ns->user && ns->owner != NULL)
8cb72c59d5ea4e9e5f638d7ec840bb853f5a188eTimo Sirainen struct mail_namespace **ns_p, const char **error_r)
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainen if (strncmp(ns_set->type, "private", 7) == 0) {
5ac0b0bf32898c63da086ae169674ecac151a31eTimo Sirainen } else if (strncmp(ns_set->type, "shared", 6) == 0)
a10ed8c47534b4c6b6bf2711ccfe577e720a47b4Timo Sirainen else if (strncmp(ns_set->type, "public", 6) == 0)
1a0ece3e873e3864269ed7eaed957dc10c56d25fTimo Sirainen *error_r = t_strdup_printf("Unknown namespace type: %s",
862ec874f9373e3e499e237d3b9f71fdf1413feeTimo Sirainen *error_r = t_strdup_printf("Invalid list setting value: %s",
7662010b03ffe5f2a6ecf4b4eb220d1c65efea76Timo Sirainen ns->alias_for = mail_namespace_find_prefix(prev_namespaces,
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen *error_r = t_strdup_printf("Invalid namespace alias_for: %s",
71aed7ba87b5fd5e96e97a22d89ac025b883d60aTimo Sirainen *error_r = t_strdup_printf("Chained namespace alias_for: %s",
51e1a1c280ccb461a15827f7987d09cb9708b6e3Timo Sirainen ns->alias_chain_next = ns->alias_for->alias_chain_next;
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen i_info("Namespace: type=%s, prefix=%s, sep=%s, "
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen "inbox=%s, hidden=%s, list=%s, subscriptions=%s",
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainen ns_set->separator == NULL ? "" : ns_set->separator,
07e4875d250e7a7157cd99132aafc773cf3cdf83Timo Sirainen if (ns->type == NAMESPACE_SHARED && strchr(ns->prefix, '%') != NULL) {
7d207b1e77a7b5e3fda640e353acfc86d261fedfTimo Sirainen /* dynamic shared namespace */
7d207b1e77a7b5e3fda640e353acfc86d261fedfTimo Sirainen ns->flags |= NAMESPACE_FLAG_NOQUOTA | NAMESPACE_FLAG_NOACL;
4b9f99761df5014c659cd87fddaf6854af428cfcTimo Sirainen if (mail_storage_create(ns, driver, 0, &error) < 0) {
4b9f99761df5014c659cd87fddaf6854af428cfcTimo Sirainen *error_r = t_strdup_printf("Namespace '%s': %s",
51e1a1c280ccb461a15827f7987d09cb9708b6e3Timo Sirainennamespaces_check(struct mail_namespace *namespaces, const char **error_r)
a0b6b441fc679e562e79be0fb2819ffc24ab5b74Timo Sirainen unsigned int subscriptions_count = 0;
6f08b98ac63c25b747120d0c8f8e319b4e26ab0fTimo Sirainen for (ns = namespaces; ns != NULL; ns = ns->next) {
6f08b98ac63c25b747120d0c8f8e319b4e26ab0fTimo Sirainen if ((ns->flags & NAMESPACE_FLAG_INBOX) != 0) {
6657aee0bb6c603b4ee5111388b93c1a8a9ad680Martti Rannanjärvi "There can be only one namespace with "
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen (ns->flags & NAMESPACE_FLAG_LIST_PREFIX) != 0 &&
699fdc186f982f70d990820796eaa0f12133e27cTimo Sirainen ns->prefix[strlen(ns->prefix)-1] != ns->sep) {
699fdc186f982f70d990820796eaa0f12133e27cTimo Sirainen "namespace configuration error: "
c06f4017027263cf3a08becc551f5126409e2a83Timo Sirainen "list=yes requires prefix=%s "
09142ea11662746ea07475b1a4f69a6a406fb996Phil Carmody "All list=yes namespaces must use "
573424407a2d3c1453638a643583a7cf10c129e1Phil Carmody "the same separator";
09142ea11662746ea07475b1a4f69a6a406fb996Phil Carmody if ((ns->flags & NAMESPACE_FLAG_SUBSCRIPTIONS) != 0)
282a436a74d8835edb45cc019b1c916013013fd3Timo Sirainen "inbox=yes namespace missing";
4c096615cb86a826fda377b87df22c579bfe5525Timo Sirainen "no list=yes namespaces";
4c096615cb86a826fda377b87df22c579bfe5525Timo Sirainen "no subscriptions=yes namespaces";
return TRUE;
unsigned int i, count;
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 *
static struct mail_namespace *
const char **mailbox,
bool inbox;
return ns;
return best;
if (best_len > 0)
return best;
struct mail_namespace *
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;