#ifndef MAILBOX_LIST_H
#define MAILBOX_LIST_H
#include "mail-error.h"
#ifdef PATH_MAX
#else
#endif
struct fs;
struct mail_namespace;
struct mail_storage;
struct mailbox_list;
enum mailbox_list_properties {
/* maildir_name must always be empty */
/* alt directories not supported */
/* no support for \noselect directories, only mailboxes */
/* mail root directory isn't required */
/* Automatically create mailbox directories when needed. Normally it's
assumed that if a mailbox directory doesn't exist, the mailbox
doesn't exist either. */
/* Explicitly disable mailbox list index */
/* Disable checking mailbox_list.is_internal_name(). The layout is
implemented in a way that there aren't any such reserved internal
names. For example Maildir++ prefixes all mailboxes with "." */
};
enum mailbox_list_flags {
/* Mailboxes are files, not directories. */
/* Namespace already has a mailbox list, don't assign this
mailbox list to it. */
/* LAYOUT=index: Don't delete any files in delete_mailbox(). */
};
enum mailbox_info_flags {
/* Internally used by lib-storage, use mailbox_info.special_use
to actually access these: */
/* Internally used by lib-storage: */
};
enum mailbox_list_path_type {
/* Return mailbox path (eg. ~/dbox/INBOX/dbox-Mails) */
/* Return control directory */
/* Return index directory ("" for in-memory) */
/* Return the private index directory (NULL if none) */
/* Return the index cache directory (usually same as
MAILBOX_LIST_PATH_TYPE_INDEX) */
/* Return mailbox list index directory (usually same as
MAILBOX_LIST_PATH_TYPE_INDEX) */
};
enum mailbox_list_file_type {
};
struct mailbox_list_settings {
const char *root_dir;
const char *index_dir;
const char *index_pvt_dir;
const char *index_cache_dir;
const char *control_dir;
/* Backend-local directory where volatile data, such as lock files,
can be temporarily created. This setting allows specifying a
separate directory for them to reduce disk I/O on the real storage.
The volatile_dir can point to an in-memory filesystem. */
const char *volatile_dir;
const char *inbox_path;
const char *subscription_fname;
const char *list_index_fname;
/* Mailbox list index directory. NULL defaults to index directory.
The path may be relative to the index directory. */
const char *list_index_dir;
/* If non-empty, it means that mails exist in a maildir_name
subdirectory. eg. if you have a directory containing directories:
mail/
If mailbox_name is "Maildir", you have a non-selectable mailbox
const char *maildir_name;
/* if set, store mailboxes under root_dir/mailbox_dir_name/.
this setting contains either "" or "dir/". */
const char *mailbox_dir_name;
/* Encode "bad" characters in mailbox names as <escape_char><hex> */
char escape_char;
/* If mailbox name can't be changed reversibly to UTF-8 and back,
encode the problematic parts using <broken_char><hex> in the
user-visible UTF-8 name. The broken_char itself also has to be
encoded the same way. */
char broken_char;
/* Use UTF-8 mailbox names on filesystem instead of mUTF-7 */
bool utf8;
bool alt_dir_nocheck;
have been the default since the beginning, but for backwards
compatibility it had to be made an option. */
/* Perform mailbox iteration using the index directory instead of the
mail root directory. This can be helpful if the indexes are on a
faster storage. This could perhaps be made the default at some point,
but for now since it's less tested it's optional. */
bool iter_from_index_dir;
/* Avoid creating or listing \NoSelect mailboxes. */
bool no_noselect;
/* Do not validate names as fs names (allows weird names) */
bool no_fs_validation;
};
struct mailbox_permissions {
(gid_t)-1 is used if the default GID can be used. */
/* origin (e.g. path) where the file_create_gid was got from */
const char *file_create_gid_origin;
};
/* register all drivers */
void mailbox_list_register_all(void);
const struct mailbox_list *
mailbox_list_find_class(const char *driver);
/* Returns 0 if ok, -1 if driver was unknown. */
const struct mailbox_list_settings *set,
enum mailbox_list_flags flags,
const char *
const struct mailbox_list_settings *
enum mailbox_list_flags
struct mail_namespace *
struct mail_user *
struct mail_storage **storage_r);
struct mail_storage **storage);
/* Returns the mode and GID that should be used when creating new files and
directories to the specified mailbox. (gid_t)-1 is returned if it's not
necessary to change the default gid. */
struct mailbox_permissions *permissions_r);
mail root directory (or even the root dir itself). */
struct mailbox_permissions *permissions_r);
/* mkdir() a root directory of given type with proper permissions. The path can
be either the root itself or point to a directory under the root. */
enum mailbox_list_path_type type);
/* Like mailbox_list_mkdir_root(), but don't log an error if it fails. */
enum mailbox_list_path_type type,
const char **error_r);
/* Call mailbox_list_mkdir_root() for index, unless the index root is the
same as mailbox root. Returns 1 if ok, 0 if there are no indexes, -1 if
error. Calling this multiple times does the check only once. */
/* Like mailbox_list_mkdir_missing_index_root(), but for mailbox list
index root. */
/* Returns TRUE if name is ok, FALSE if it can't be safely passed to
mailbox_list_*() functions */
const char *vname);
/* Get path to specified type of files in mailbox. Returns -1 if an error
occurred (e.g. mailbox no longer exists), 0 if there are no files of this
type (in-memory index, no alt dir, storage with no files), 1 if path was
returned successfully. The path is set to NULL when returning -1/0. */
enum mailbox_list_path_type type,
const char **path_r);
/* Get path to the root directory for files of specified type. Returns TRUE
if path was returned, FALSE if there are no files of this type. */
enum mailbox_list_path_type type,
const char **path_r);
/* Like mailbox_list_get_root_path(), but assume that the root directory
exists (assert crash if not) */
enum mailbox_list_path_type type);
/* Returns mailbox's change log, or NULL if it doesn't have one. */
/* Specify timestamp to use when writing mailbox changes to changelog.
The same timestamp is used until stamp is set to (time_t)-1, after which
current time is used */
/* Returns a prefix that temporary files should use without conflicting
with the namespace. */
/* Returns prefix that's common to all get_temp_prefix() calls.
Typically this returns either "temp." or ".temp.". */
/* Subscribe/unsubscribe mailbox. There should be no error when
subscribing to already subscribed mailbox. Subscribing to
unexisting mailboxes is optional. */
/* Delete a non-selectable mailbox. Fail if the mailbox is selectable. */
/* Delete a symlinked mailbox. Fail if the mailbox isn't a symlink. */
/* Returns the error message of last occurred error. */
const char * ATTR_NOWARN_UNUSED_RESULT
enum mail_error *error_r);
/* Wrapper for mailbox_list_get_last_error() */
const char * ATTR_NOWARN_UNUSED_RESULT
enum mail_error *error_r);
/* Save the last error until it's popped. This is useful for cases where the
list operation has already failed, but the cleanup code path changes the
error to something else unwanted. */
/* Create a fs based on the settings in the given mailbox_list. */
/* Return mailbox_list that was used to create the fs via
mailbox_list_init_fs(). */
#endif