mail-namespace.h revision c8cf8a605e0ddea7cb36fe04551aeca5090e684b
de754cb78f75e8b3b994cddafe41c9ed1467c33dTimo Sirainen /* Namespace contains the INBOX mailbox (there can be only one) */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen /* Namespace is visible only by explicitly using its full prefix */
53dfcefa9440a49d703e49193819a79be99c9ba6Timo Sirainen /* Namespace is visible with LIST */
53dfcefa9440a49d703e49193819a79be99c9ba6Timo Sirainen /* Namespace uses its own subscriptions. */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen /* Namespace is created for internal use only. */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen /* Namespace was created automatically (for shared mailboxes) */
2e78f05b11df23ec2731afaf8f19d5b5240cb29fTimo Sirainen /* Namespaces are sorted by their prefix length, "" comes first */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen /* FIXME: we should support multiple storages in one namespace */
9f627b360ed38fdc54cb02ec5e67246c3f0d5b0fTimo Sirainen/* Called after namespaces has been created */
b9c76fe9d9ca194816606342da1ddbd9be6bc8abTimo Sirainenextern void (*hook_mail_namespaces_created)(struct mail_namespace *namespaces);
9f627b360ed38fdc54cb02ec5e67246c3f0d5b0fTimo Sirainenint mail_namespaces_init(struct mail_user *user);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenstruct mail_namespace *mail_namespaces_init_empty(struct mail_user *user);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenvoid mail_namespaces_deinit(struct mail_namespace **namespaces);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen/* Destroy a single namespace and remove it from user's namespaces list. */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenvoid mail_namespace_destroy(struct mail_namespace *ns);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen/* Update hierarchy separators in given name to real_sep characters. */
9f627b360ed38fdc54cb02ec5e67246c3f0d5b0fTimo Sirainenconst char *mail_namespace_fix_sep(struct mail_namespace *ns, const char *name);
9f627b360ed38fdc54cb02ec5e67246c3f0d5b0fTimo Sirainen/* Write virtual mailbox name to dest and return it. Separators are changed to
b9c76fe9d9ca194816606342da1ddbd9be6bc8abTimo Sirainen virtual ones and namespace prefix is inserted except for INBOX. */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenconst char *mail_namespace_get_vname(struct mail_namespace *ns, string_t *dest,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen const char *name);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen/* Returns the hierarchy separator for mailboxes that are listed at root. */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenchar mail_namespace_get_root_sep(const struct mail_namespace *namespaces)
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen/* Returns namespace based on the mailbox name's prefix. Updates mailbox to
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen be a valid name inside the namespace (prefix is skipped, hierarchy separator
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen is changed to real_sep). If no namespaces were found, returns NULL. */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenmail_namespace_find(struct mail_namespace *namespaces, const char **mailbox);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen/* Like above, but ignore hidden namespaces. */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenmail_namespace_find_visible(struct mail_namespace *namespaces,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen const char **mailbox);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen/* Like above, but find only from namespaces with subscriptions flag set. */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenmail_namespace_find_subscribable(struct mail_namespace *namespaces,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen const char **mailbox);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen/* Like above, but find only from namespaces with subscriptions flag not set. */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenmail_namespace_find_unsubscribable(struct mail_namespace *namespaces,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen const char **mailbox);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen/* Returns the INBOX namespace */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenmail_namespace_find_inbox(struct mail_namespace *namespaces);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen/* Returns TRUE if the given namespace matches the mailbox's prefix.
ca843e046e98b12f4730f4b87ee2e1a659c26e78Timo Sirainen Updates mailbox name to be a valid name inside the namespace. */
ca843e046e98b12f4730f4b87ee2e1a659c26e78Timo Sirainenbool mail_namespace_update_name(const struct mail_namespace *ns,
ca843e046e98b12f4730f4b87ee2e1a659c26e78Timo Sirainen const char **mailbox);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen/* Find a namespace with given prefix. */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenmail_namespace_find_prefix(struct mail_namespace *namespaces,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen const char *prefix);
e7dd5065d21c569e5e6ddd713bd345dadd1cf51dTimo Sirainen/* Like _find_prefix(), but ignore trailing separator */
d694a52bce62c52080c3f87a56dcf77030fd2712Timo Sirainenmail_namespace_find_prefix_nosep(struct mail_namespace *namespaces,
d694a52bce62c52080c3f87a56dcf77030fd2712Timo Sirainen const char *prefix);
009217abb57a24a4076092e8e4e165545747839eStephan Bosch/* Called internally by mail_storage_create(). */