mailbox-list.h revision 8ca217bf3aa23c7922d0d4aa44fcd2320416d61c
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen /* maildir_name must always be empty */
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen /* alt directories not supported */
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen /* no support for \noselect directories, only mailboxes */
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen /* mail root directory isn't required */
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen /* Automatically create mailbox directories when needed */
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen /* Mailboxes are files, not directories. */
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen /* Namespace already has a mailbox list, don't assign this
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen mailbox list to it. */
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen /* There are no mail files, only index and/or control files. */
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen /* LAYOUT=index: Don't delete any files in delete_mailbox(). */
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen /* Internally used by lib-storage, use mailbox_info.special_use
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen to actually access these: */
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen /* Internally used by lib-storage: */
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainen /* Return directory's path (eg. ~/dbox/INBOX) */
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen /* Return mailbox path (eg. ~/dbox/INBOX/dbox-Mails) */
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen /* Return control directory */
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen /* Return index directory ("" for in-memory) */
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen /* Return the private index directory (NULL if none) */
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen const char *layout; /* FIXME: shouldn't be here */
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen const char *alt_dir; /* FIXME: dbox-specific.. */
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 If mailbox_name is empty, you have mailboxes "mail", "mail/foo" and
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen If mailbox_name is "Maildir", you have a non-selectable mailbox
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen "mail" and a selectable mailbox "mail/foo". */
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen /* if set, store mailboxes under root_dir/mailbox_dir_name/.
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen this setting contains either "" or "dir/". */
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen /* Encode "bad" characters in mailbox names as <escape_char><hex> */
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. */
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen /* Use UTF-8 mailbox names on filesystem instead of mUTF-7 */
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen /* Don't check/create the alt-dir symlink. */
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 /* The actual uid/gid of the mailbox */
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. */
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen /* origin (e.g. path) where the file_create_gid was got from */
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen/* register all drivers */
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenvoid mailbox_list_register(const struct mailbox_list *list);
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenvoid mailbox_list_unregister(const struct mailbox_list *list);
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 struct mailbox_list **list_r, const char **error_r);
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenvoid mailbox_list_destroy(struct mailbox_list **list);
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenmailbox_list_get_driver_name(const struct mailbox_list *list) ATTR_PURE;
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenmailbox_list_get_settings(const struct mailbox_list *list) ATTR_PURE;
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenmailbox_list_get_flags(const struct mailbox_list *list) ATTR_PURE;
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenmailbox_list_get_namespace(const struct mailbox_list *list) ATTR_PURE;
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 Sirainenvoid mailbox_list_get_default_storage(struct mailbox_list *list,
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenchar mailbox_list_get_hierarchy_sep(struct mailbox_list *list);
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/* 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/* 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/* 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 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/* 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 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/* 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 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 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/* 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/* 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/* 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,
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/* Returns the error message of last occurred error. */
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenmailbox_list_get_last_error(struct mailbox_list *list,
704efd0b34e3611e3decf1d559fe6a93214b0bd0Timo Sirainenmailbox_list_get_last_internal_error(struct mailbox_list *list,
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/* Return mailbox_list that was used to create the fs via
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen mailbox_list_init_fs(). */