mailbox-list.h revision 8ca217bf3aa23c7922d0d4aa44fcd2320416d61c
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen#ifndef MAILBOX_LIST_H
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen#define MAILBOX_LIST_H
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen#include "mail-error.h"
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen#ifdef PATH_MAX
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen# define MAILBOX_LIST_NAME_MAX_LENGTH PATH_MAX
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen#else
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen# define MAILBOX_LIST_NAME_MAX_LENGTH 4096
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen#endif
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainenstruct fs;
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainenstruct mail_namespace;
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainenstruct mail_storage;
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainenstruct mailbox_list;
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainenenum mailbox_list_properties {
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen /* maildir_name must always be empty */
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen MAILBOX_LIST_PROP_NO_MAILDIR_NAME = 0x01,
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen /* alt directories not supported */
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen MAILBOX_LIST_PROP_NO_ALT_DIR = 0x02,
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen /* no support for \noselect directories, only mailboxes */
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen MAILBOX_LIST_PROP_NO_NOSELECT = 0x04,
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen /* mail root directory isn't required */
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen MAILBOX_LIST_PROP_NO_ROOT = 0x08,
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen /* Automatically create mailbox directories when needed */
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen MAILBOX_LIST_PROP_AUTOCREATE_DIRS = 0x10
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen};
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainenenum mailbox_list_flags {
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen /* Mailboxes are files, not directories. */
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen MAILBOX_LIST_FLAG_MAILBOX_FILES = 0x01,
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen /* Namespace already has a mailbox list, don't assign this
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen mailbox list to it. */
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen MAILBOX_LIST_FLAG_SECONDARY = 0x02,
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen /* There are no mail files, only index and/or control files. */
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen MAILBOX_LIST_FLAG_NO_MAIL_FILES = 0x04,
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen /* LAYOUT=index: Don't delete any files in delete_mailbox(). */
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen MAILBOX_LIST_FLAG_NO_DELETES = 0x08
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen};
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenenum mailbox_info_flags {
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen MAILBOX_NOSELECT = 0x001,
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen MAILBOX_NONEXISTENT = 0x002,
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen MAILBOX_CHILDREN = 0x004,
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen MAILBOX_NOCHILDREN = 0x008,
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen MAILBOX_NOINFERIORS = 0x010,
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen MAILBOX_MARKED = 0x020,
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen MAILBOX_UNMARKED = 0x040,
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen MAILBOX_SUBSCRIBED = 0x080,
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen MAILBOX_CHILD_SUBSCRIBED = 0x100,
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen MAILBOX_CHILD_SPECIALUSE = 0x200,
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen /* Internally used by lib-storage, use mailbox_info.special_use
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen to actually access these: */
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen MAILBOX_SPECIALUSE_ALL = 0x00010000,
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen MAILBOX_SPECIALUSE_ARCHIVE = 0x00020000,
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen MAILBOX_SPECIALUSE_DRAFTS = 0x00040000,
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen MAILBOX_SPECIALUSE_FLAGGED = 0x00080000,
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen MAILBOX_SPECIALUSE_JUNK = 0x00100000,
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen MAILBOX_SPECIALUSE_SENT = 0x00200000,
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen MAILBOX_SPECIALUSE_TRASH = 0x00400000,
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen MAILBOX_SPECIALUSE_IMPORTANT = 0x00800000,
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen#define MAILBOX_SPECIALUSE_MASK 0x00ff0000
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen /* Internally used by lib-storage: */
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen MAILBOX_SELECT = 0x20000000,
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen MAILBOX_MATCHED = 0x40000000
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen};
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainenenum mailbox_list_path_type {
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen /* Return directory's path (eg. ~/dbox/INBOX) */
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen MAILBOX_LIST_PATH_TYPE_DIR,
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen MAILBOX_LIST_PATH_TYPE_ALT_DIR,
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen /* Return mailbox path (eg. ~/dbox/INBOX/dbox-Mails) */
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen MAILBOX_LIST_PATH_TYPE_MAILBOX,
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen MAILBOX_LIST_PATH_TYPE_ALT_MAILBOX,
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen /* Return control directory */
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen MAILBOX_LIST_PATH_TYPE_CONTROL,
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen /* Return index directory ("" for in-memory) */
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen MAILBOX_LIST_PATH_TYPE_INDEX,
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen /* Return the private index directory (NULL if none) */
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen MAILBOX_LIST_PATH_TYPE_INDEX_PRIVATE
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen};
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenenum mailbox_list_file_type {
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen MAILBOX_LIST_FILE_TYPE_UNKNOWN = 0,
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen MAILBOX_LIST_FILE_TYPE_FILE,
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen MAILBOX_LIST_FILE_TYPE_DIR,
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen MAILBOX_LIST_FILE_TYPE_SYMLINK,
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen MAILBOX_LIST_FILE_TYPE_OTHER
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen};
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainenstruct mailbox_list_settings {
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen const char *layout; /* FIXME: shouldn't be here */
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen const char *root_dir;
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen const char *index_dir;
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen const char *index_pvt_dir;
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen const char *control_dir;
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen const char *alt_dir; /* FIXME: dbox-specific.. */
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen const char *inbox_path;
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen const char *subscription_fname;
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen const char *list_index_fname;
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen /* If non-empty, it means that mails exist in a maildir_name
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen subdirectory. eg. if you have a directory containing directories:
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen mail/
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen mail/foo/
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen mail/foo/Maildir
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen If mailbox_name is empty, you have mailboxes "mail", "mail/foo" and
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen "mail/foo/Maildir".
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen If mailbox_name is "Maildir", you have a non-selectable mailbox
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen "mail" and a selectable mailbox "mail/foo". */
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen const char *maildir_name;
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen /* if set, store mailboxes under root_dir/mailbox_dir_name/.
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen this setting contains either "" or "dir/". */
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen const char *mailbox_dir_name;
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen /* Encode "bad" characters in mailbox names as <escape_char><hex> */
2c7ab05ef98c46eb70c8ba6ea85e49749aafb2a3Timo Sirainen char escape_char;
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen /* If mailbox name can't be changed reversibly to UTF-8 and back,
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen encode the problematic parts using <broken_char><hex> in the
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen user-visible UTF-8 name. The broken_char itself also has to be
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen encoded the same way. */
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen char broken_char;
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen /* Use UTF-8 mailbox names on filesystem instead of mUTF-7 */
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen bool utf8;
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen /* Don't check/create the alt-dir symlink. */
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen bool alt_dir_nocheck;
2c7ab05ef98c46eb70c8ba6ea85e49749aafb2a3Timo Sirainen /* Use maildir_name also for index/control directories. This should
2c7ab05ef98c46eb70c8ba6ea85e49749aafb2a3Timo Sirainen have been the default since the beginning, but for backwards
2c7ab05ef98c46eb70c8ba6ea85e49749aafb2a3Timo Sirainen compatibility it had to be made an option. */
2c7ab05ef98c46eb70c8ba6ea85e49749aafb2a3Timo Sirainen bool index_control_use_maildir_name;
2c7ab05ef98c46eb70c8ba6ea85e49749aafb2a3Timo Sirainen};
2c7ab05ef98c46eb70c8ba6ea85e49749aafb2a3Timo Sirainen
2c7ab05ef98c46eb70c8ba6ea85e49749aafb2a3Timo Sirainenstruct mailbox_permissions {
2c7ab05ef98c46eb70c8ba6ea85e49749aafb2a3Timo Sirainen /* The actual uid/gid of the mailbox */
2c7ab05ef98c46eb70c8ba6ea85e49749aafb2a3Timo Sirainen uid_t file_uid;
2c7ab05ef98c46eb70c8ba6ea85e49749aafb2a3Timo Sirainen gid_t file_gid;
2c7ab05ef98c46eb70c8ba6ea85e49749aafb2a3Timo Sirainen
2c7ab05ef98c46eb70c8ba6ea85e49749aafb2a3Timo Sirainen /* mode and GID to use for newly created files/dirs.
2c7ab05ef98c46eb70c8ba6ea85e49749aafb2a3Timo Sirainen (gid_t)-1 is used if the default GID can be used. */
2c7ab05ef98c46eb70c8ba6ea85e49749aafb2a3Timo Sirainen mode_t file_create_mode, dir_create_mode;
2c7ab05ef98c46eb70c8ba6ea85e49749aafb2a3Timo Sirainen gid_t file_create_gid;
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen /* origin (e.g. path) where the file_create_gid was got from */
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen const char *file_create_gid_origin;
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen bool gid_origin_is_mailbox_path;
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen bool mail_index_permissions_set;
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen};
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen/* register all drivers */
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainenvoid mailbox_list_register_all(void);
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenvoid mailbox_list_register(const struct mailbox_list *list);
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenvoid mailbox_list_unregister(const struct mailbox_list *list);
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenconst struct mailbox_list *
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenmailbox_list_find_class(const char *driver);
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen/* Returns 0 if ok, -1 if driver was unknown. */
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenint mailbox_list_create(const char *driver, struct mail_namespace *ns,
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen const struct mailbox_list_settings *set,
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen enum mailbox_list_flags flags,
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen struct mailbox_list **list_r, const char **error_r);
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenvoid mailbox_list_destroy(struct mailbox_list **list);
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenconst char *
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenmailbox_list_get_driver_name(const struct mailbox_list *list) ATTR_PURE;
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenconst struct mailbox_list_settings *
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenmailbox_list_get_settings(const struct mailbox_list *list) ATTR_PURE;
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenenum mailbox_list_flags
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenmailbox_list_get_flags(const struct mailbox_list *list) ATTR_PURE;
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenstruct mail_namespace *
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenmailbox_list_get_namespace(const struct mailbox_list *list) ATTR_PURE;
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenstruct mail_user *
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenmailbox_list_get_user(const struct mailbox_list *list) ATTR_PURE;
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenint mailbox_list_get_storage(struct mailbox_list **list, const char *vname,
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen struct mail_storage **storage_r);
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenvoid mailbox_list_get_default_storage(struct mailbox_list *list,
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen struct mail_storage **storage);
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenchar mailbox_list_get_hierarchy_sep(struct mailbox_list *list);
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen/* Returns the mode and GID that should be used when creating new files and
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen directories to the specified mailbox. (gid_t)-1 is returned if it's not
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen necessary to change the default gid. */
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenvoid mailbox_list_get_permissions(struct mailbox_list *list, const char *name,
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen struct mailbox_permissions *permissions_r);
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen/* Like mailbox_list_get_permissions(), but for creating files/dirs to the
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen mail root directory (or even the root dir itself). */
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenvoid mailbox_list_get_root_permissions(struct mailbox_list *list,
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen struct mailbox_permissions *permissions_r);
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen/* mkdir() a root directory of given type with proper permissions. The path can
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen be either the root itself or point to a directory under the root. */
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenint mailbox_list_mkdir_root(struct mailbox_list *list, const char *path,
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen enum mailbox_list_path_type type);
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen/* Like mailbox_list_mkdir_root(), but don't log an error if it fails. */
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenint mailbox_list_try_mkdir_root(struct mailbox_list *list, const char *path,
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen enum mailbox_list_path_type type,
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen const char **error_r);
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen/* Call mailbox_list_mkdir_root() for index, unless the index root is the
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen same as mailbox root. Returns 1 if ok, 0 if there are no indexes, -1 if
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen error. Calling this multiple times does the check only once. */
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenint mailbox_list_mkdir_missing_index_root(struct mailbox_list *list);
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen/* Returns TRUE if name is ok, FALSE if it can't be safely passed to
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen mailbox_list_*() functions */
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenbool mailbox_list_is_valid_name(struct mailbox_list *list,
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen const char *name, const char **error_r);
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenconst char *mailbox_list_get_storage_name(struct mailbox_list *list,
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen const char *vname);
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenconst char *mailbox_list_get_vname(struct mailbox_list *list, const char *name);
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen/* Get path to specified type of files in mailbox. Returns -1 if an error
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen occurred (e.g. mailbox no longer exists), 0 if there are no files of this
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen type (in-memory index, no alt dir, storage with no files), 1 if path was
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen returned successfully. The path is set to NULL when returning -1/0. */
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenint mailbox_list_get_path(struct mailbox_list *list, const char *name,
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen enum mailbox_list_path_type type,
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen const char **path_r);
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen/* Get path to the root directory for files of specified type. Returns TRUE
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen if path was returned, FALSE if there are no files of this type. */
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenbool mailbox_list_get_root_path(struct mailbox_list *list,
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen enum mailbox_list_path_type type,
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen const char **path_r);
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen/* Like mailbox_list_get_root_path(), but assume that the root directory
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen exists (assert crash if not) */
2c7ab05ef98c46eb70c8ba6ea85e49749aafb2a3Timo Sirainenconst char *mailbox_list_get_root_forced(struct mailbox_list *list,
2c7ab05ef98c46eb70c8ba6ea85e49749aafb2a3Timo Sirainen enum mailbox_list_path_type type);
2c7ab05ef98c46eb70c8ba6ea85e49749aafb2a3Timo Sirainen/* Returns mailbox's change log, or NULL if it doesn't have one. */
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenstruct mailbox_log *mailbox_list_get_changelog(struct mailbox_list *list);
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen/* Specify timestamp to use when writing mailbox changes to changelog.
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen The same timestamp is used until stamp is set to (time_t)-1, after which
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen current time is used */
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenvoid mailbox_list_set_changelog_timestamp(struct mailbox_list *list,
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen time_t stamp);
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen/* Returns a prefix that temporary files should use without conflicting
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen with the namespace. */
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenconst char *mailbox_list_get_temp_prefix(struct mailbox_list *list);
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen/* Returns prefix that's common to all get_temp_prefix() calls.
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen Typically this returns either "temp." or ".temp.". */
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenconst char *mailbox_list_get_global_temp_prefix(struct mailbox_list *list);
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen/* Subscribe/unsubscribe mailbox. There should be no error when
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen subscribing to already subscribed mailbox. Subscribing to
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen unexisting mailboxes is optional. */
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenint mailbox_list_set_subscribed(struct mailbox_list *list,
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen const char *name, bool set);
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen/* Delete a non-selectable mailbox. Fail if the mailbox is selectable. */
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenint mailbox_list_delete_dir(struct mailbox_list *list, const char *name);
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen/* Delete a symlinked mailbox. Fail if the mailbox isn't a symlink. */
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainenint mailbox_list_delete_symlink(struct mailbox_list *list, const char *name);
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen/* Returns the error message of last occurred error. */
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenconst char * ATTR_NOWARN_UNUSED_RESULT
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenmailbox_list_get_last_error(struct mailbox_list *list,
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen enum mail_error *error_r);
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenconst char * ATTR_NOWARN_UNUSED_RESULT
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenmailbox_list_get_last_internal_error(struct mailbox_list *list,
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen enum mail_error *error_r);
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen/* Create a fs based on the settings in the given mailbox_list. */
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainenint mailbox_list_init_fs(struct mailbox_list *list, const char *driver,
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen const char *args, const char *root_dir,
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen struct fs **fs_r, const char **error_r);
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen/* Return mailbox_list that was used to create the fs via
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen mailbox_list_init_fs(). */
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainenstruct mailbox_list *mailbox_list_fs_get_list(struct fs *fs);
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen#endif
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen