mail-namespace.h revision 9a2149cccfab52ca88cd6b5eecec776a0c3584ec
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen#ifndef MAIL_NAMESPACE_H
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen#define MAIL_NAMESPACE_H
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen#include "mail-user.h"
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen
b039dabf4c53f72454e795930e7643b6e0e625f9Timo Sirainenstruct mail_storage_callbacks;
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen
a35cbba04d0a2823da98e693bd09a051addffdb2Timo Sirainenenum mail_namespace_type {
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen MAIL_NAMESPACE_TYPE_PRIVATE = 0x01,
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen MAIL_NAMESPACE_TYPE_SHARED = 0x02,
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen MAIL_NAMESPACE_TYPE_PUBLIC = 0x04
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen#define MAIL_NAMESPACE_TYPE_MASK_ALL \
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen (MAIL_NAMESPACE_TYPE_PRIVATE | MAIL_NAMESPACE_TYPE_SHARED | \
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen MAIL_NAMESPACE_TYPE_PUBLIC)
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen};
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainenenum namespace_flags {
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen /* Namespace contains the user's INBOX mailbox. Normally only a single
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen namespace has this flag set, but when using alias_for for the INBOX
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen namespace the flag gets copied to the alias namespace as well */
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen NAMESPACE_FLAG_INBOX_USER = 0x01,
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen /* Namespace contains someone's INBOX. This is set for both user's
cb951d3282610a9a0960230865bc5f3e3347b203Timo Sirainen INBOX namespace and also for any other users' shared namespaces. */
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen NAMESPACE_FLAG_INBOX_ANY = 0x02,
cb951d3282610a9a0960230865bc5f3e3347b203Timo Sirainen /* Namespace is visible only by explicitly using its full prefix */
a35cbba04d0a2823da98e693bd09a051addffdb2Timo Sirainen NAMESPACE_FLAG_HIDDEN = 0x04,
3fe44a0df5a0bdd80c495f79cbf0e384441d6fccTimo Sirainen /* Namespace prefix is visible with LIST */
a35cbba04d0a2823da98e693bd09a051addffdb2Timo Sirainen NAMESPACE_FLAG_LIST_PREFIX = 0x08,
cb951d3282610a9a0960230865bc5f3e3347b203Timo Sirainen /* Namespace prefix isn't visible with LIST, but child mailboxes are */
a35cbba04d0a2823da98e693bd09a051addffdb2Timo Sirainen NAMESPACE_FLAG_LIST_CHILDREN = 0x10,
cb951d3282610a9a0960230865bc5f3e3347b203Timo Sirainen /* Namespace uses its own subscriptions. */
cb951d3282610a9a0960230865bc5f3e3347b203Timo Sirainen NAMESPACE_FLAG_SUBSCRIPTIONS = 0x20,
cb951d3282610a9a0960230865bc5f3e3347b203Timo Sirainen
a35cbba04d0a2823da98e693bd09a051addffdb2Timo Sirainen /* Namespace was created automatically (for shared mailboxes) */
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen NAMESPACE_FLAG_AUTOCREATED = 0x1000,
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen /* Namespace has at least some usable mailboxes. Autocreated namespaces
3fe44a0df5a0bdd80c495f79cbf0e384441d6fccTimo Sirainen that don't have usable mailboxes may be removed automatically. */
3fe44a0df5a0bdd80c495f79cbf0e384441d6fccTimo Sirainen NAMESPACE_FLAG_USABLE = 0x2000,
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen /* Automatically created namespace for a user that doesn't exist. */
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen NAMESPACE_FLAG_UNUSABLE = 0x4000,
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen /* Don't track quota for this namespace */
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen NAMESPACE_FLAG_NOQUOTA = 0x8000,
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen /* Don't enforce ACLs for this namespace */
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen NAMESPACE_FLAG_NOACL = 0x10000
3fe44a0df5a0bdd80c495f79cbf0e384441d6fccTimo Sirainen};
fc84f8af4794f4bb6caf6e5ec3fb1f8cebd0462aTimo Sirainen
91dca97b367c54a139c268b56a0c67f564bd9197Timo Sirainenstruct mail_namespace {
91dca97b367c54a139c268b56a0c67f564bd9197Timo Sirainen /* Namespaces are sorted by their prefix length, "" comes first */
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen struct mail_namespace *next;
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen int refcount;
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen enum mail_namespace_type type;
bd7b1a9000b12349e2a99bb43b3ce8b96a18e92bTimo Sirainen enum namespace_flags flags;
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen
bd7b1a9000b12349e2a99bb43b3ce8b96a18e92bTimo Sirainen char *prefix;
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen size_t prefix_len;
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen
bd7b1a9000b12349e2a99bb43b3ce8b96a18e92bTimo Sirainen /* If non-NULL, this points to a namespace with identical mail location
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen and it should be considered as the primary way to access the
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen mailboxes. This allows for example FTS plugin to avoid duplicating
bd7b1a9000b12349e2a99bb43b3ce8b96a18e92bTimo Sirainen indexes for same mailboxes when they're accessed via different
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen namespaces. */
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen struct mail_namespace *alias_for;
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen /* alias_for->alias_chain_next starts each chain. The chain goes
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen through all namespaces that have the same alias_for. */
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen struct mail_namespace *alias_chain_next;
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen struct mail_user *user, *owner;
3fe44a0df5a0bdd80c495f79cbf0e384441d6fccTimo Sirainen struct mailbox_list *list;
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen struct mail_storage *storage; /* default storage */
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen ARRAY(struct mail_storage *) all_storages;
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen /* This may point to user->set, but it may also point to
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen namespace-specific settings. When accessing namespace-specific
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen settings it should be done through here instead of through the
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen mail_user. */
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen struct mail_user_settings *user_set;
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen const struct mail_namespace_settings *set, *unexpanded_set;
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen const struct mail_storage_settings *mail_set;
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen bool special_use_mailboxes:1;
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen bool destroyed:1;
3fe44a0df5a0bdd80c495f79cbf0e384441d6fccTimo Sirainen};
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen/* Allocate a new namespace, and fill it based on the passed in settings.
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen This is the most low-level namespace creation function. The storage isn't
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen initialized for the namespace.
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen user_all_settings normally points to user->set. If you want to override
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen settings for the created namespace, you can duplicate the user's settings
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen and provide a pointer to it here. Note that the pointer must contain
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen ALL the settings, including the dynamic driver-specific settings, so it
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen needs to created via settings-parser API. */
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainenint mail_namespace_alloc(struct mail_user *user,
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen void *user_all_settings,
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen struct mail_namespace_settings *ns_set,
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen struct mail_namespace_settings *unexpanded_set,
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen struct mail_namespace **ns_r,
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen const char **error_r);
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen/* Add and initialize namespaces to user based on namespace settings. */
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainenint mail_namespaces_init(struct mail_user *user, const char **error_r);
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen/* Add and initialize INBOX namespace to user based on the given location. */
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainenint mail_namespaces_init_location(struct mail_user *user, const char *location,
3fe44a0df5a0bdd80c495f79cbf0e384441d6fccTimo Sirainen const char **error_r) ATTR_NULL(2);
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen/* Add an empty namespace to user. */
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainenstruct mail_namespace *mail_namespaces_init_empty(struct mail_user *user);
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen/* Deinitialize all namespaces. mail_user_deinit() calls this automatically
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen for user's namespaces. */
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainenvoid mail_namespaces_deinit(struct mail_namespace **namespaces);
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen/* Allocate a new namespace and initialize it. This is called automatically by
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen mail_namespaces_init(). */
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainenint mail_namespaces_init_add(struct mail_user *user,
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen struct mail_namespace_settings *ns_set,
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen struct mail_namespace_settings *unexpanded_ns_set,
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen struct mail_namespace **ns_p, const char **error_r);
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainenint mail_namespaces_init_finish(struct mail_namespace *namespaces,
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen const char **error_r);
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainenvoid mail_namespace_ref(struct mail_namespace *ns);
91dca97b367c54a139c268b56a0c67f564bd9197Timo Sirainenvoid mail_namespace_unref(struct mail_namespace **ns);
26a8b7deb3a5b6f26f9c4d71538e1248f680e4beTimo Sirainen
26a8b7deb3a5b6f26f9c4d71538e1248f680e4beTimo Sirainen/* Set storage callback functions to use in all namespaces. */
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainenvoid mail_namespaces_set_storage_callbacks(struct mail_namespace *namespaces,
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen struct mail_storage_callbacks *callbacks,
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen void *context);
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen/* Add a new storage to namespace. */
bd7b1a9000b12349e2a99bb43b3ce8b96a18e92bTimo Sirainenvoid mail_namespace_add_storage(struct mail_namespace *ns,
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen struct mail_storage *storage);
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen/* Destroy a single namespace and remove it from user's namespaces list. */
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainenvoid mail_namespace_destroy(struct mail_namespace *ns);
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen/* Returns the default storage to use for newly created mailboxes. */
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainenstruct mail_storage *
bd7b1a9000b12349e2a99bb43b3ce8b96a18e92bTimo Sirainenmail_namespace_get_default_storage(struct mail_namespace *ns);
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen
bd7b1a9000b12349e2a99bb43b3ce8b96a18e92bTimo Sirainen/* Return namespace's hierarchy separator. */
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainenchar mail_namespace_get_sep(struct mail_namespace *ns);
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen/* Returns the hierarchy separator for mailboxes that are listed at root. */
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainenchar mail_namespaces_get_root_sep(struct mail_namespace *namespaces)
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen ATTR_PURE;
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen/* Returns namespace based on the mailbox name's prefix. Note that there is
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen always a prefix="" namespace, so for this function NULL is never returned. */
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainenstruct mail_namespace *
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainenmail_namespace_find(struct mail_namespace *namespaces, const char *mailbox);
bd7b1a9000b12349e2a99bb43b3ce8b96a18e92bTimo Sirainen/* Same as mail_namespace_find(), but if the namespace has alias_for set,
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen return that namespace instead and change mailbox name to be a valid
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen inside it. */
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainenstruct mail_namespace *
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainenmail_namespace_find_unalias(struct mail_namespace *namespaces,
3fe44a0df5a0bdd80c495f79cbf0e384441d6fccTimo Sirainen const char **mailbox);
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen/* Like mail_namespace_find(), but ignore hidden namespaces. */
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainenstruct mail_namespace *
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainenmail_namespace_find_visible(struct mail_namespace *namespaces,
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen const char *mailbox);
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen/* Like mail_namespace_find(), but find only from namespaces with
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen subscriptions=yes. */
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainenstruct mail_namespace *
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainenmail_namespace_find_subscribable(struct mail_namespace *namespaces,
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen const char *mailbox);
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen/* Like mail_namespace_find(), but find only from namespaces with
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen subscriptions=no. */
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainenstruct mail_namespace *
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainenmail_namespace_find_unsubscribable(struct mail_namespace *namespaces,
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen const char *mailbox);
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen/* Returns the INBOX namespace. It always exists, so NULL is never returned. */
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainenstruct mail_namespace *
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainenmail_namespace_find_inbox(struct mail_namespace *namespaces);
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen/* Find a namespace with given prefix. */
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainenstruct mail_namespace *
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainenmail_namespace_find_prefix(struct mail_namespace *namespaces,
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen const char *prefix);
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen/* Like _find_prefix(), but ignore trailing separator */
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainenstruct mail_namespace *
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainenmail_namespace_find_prefix_nosep(struct mail_namespace *namespaces,
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen const char *prefix);
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen/* Called internally by mailbox_list_create(). */
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainenvoid mail_namespace_finish_list_init(struct mail_namespace *ns,
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen struct mailbox_list *list);
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen/* Returns TRUE if this is the root of a type=shared namespace that is actually
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen used for accessing shared users' mailboxes (as opposed to marking a
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen type=public namespace "wrong"). */
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainenbool mail_namespace_is_shared_user_root(struct mail_namespace *ns);
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen/* Returns TRUE if namespace includes INBOX that should be \Noinferiors.
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen This happens when the namespace has a prefix, which is not empty and not
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen "INBOX". This happens, because if storage_name=INBOX/foo it would be
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen converted to vname=prefix/INBOX/foo. */
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainenstatic inline bool
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainenmail_namespace_is_inbox_noinferiors(struct mail_namespace *ns)
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen{
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen return (ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0 &&
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen ns->prefix_len > 0 &&
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen strncmp(ns->prefix, "INBOX", ns->prefix_len-1) != 0;
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen}
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen#endif
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen