mailbox-list.h revision b66d803de86bfb411165b3465b0d9ef64ecfe2a1
#ifndef MAILBOX_LIST_H
#define MAILBOX_LIST_H
#include "guid.h"
#include "mail-error.h"
#ifdef PATH_MAX
# define MAILBOX_LIST_NAME_MAX_LENGTH PATH_MAX
#else
# define MAILBOX_LIST_NAME_MAX_LENGTH 4096
#endif
enum namespace_type;
struct mail_namespace;
struct mail_storage;
struct mailbox_list;
struct mailbox_list_iterate_context;
enum mailbox_list_properties {
/* maildir_name must always be empty */
/* alt directories not supported */
MAILBOX_LIST_PROP_NO_ALT_DIR = 0x02,
/* no support for \noselect directories, only mailboxes */
MAILBOX_LIST_PROP_NO_NOSELECT = 0x04,
/* mail root directory isn't required */
MAILBOX_LIST_PROP_NO_ROOT = 0x08,
/* Automatically create mailbox directories when needed */
};
enum mailbox_list_flags {
/* Mailboxes are files, not directories. */
MAILBOX_LIST_FLAG_MAILBOX_FILES = 0x01,
/* Namespace already has a mailbox list, don't assign this
mailbox list to it. */
MAILBOX_LIST_FLAG_SECONDARY = 0x02
};
enum mailbox_info_flags {
MAILBOX_NOSELECT = 0x001,
MAILBOX_NONEXISTENT = 0x002,
MAILBOX_CHILDREN = 0x004,
MAILBOX_NOCHILDREN = 0x008,
MAILBOX_NOINFERIORS = 0x010,
MAILBOX_MARKED = 0x020,
MAILBOX_UNMARKED = 0x040,
MAILBOX_SUBSCRIBED = 0x080,
MAILBOX_CHILD_SUBSCRIBED = 0x100,
/* Internally used by lib-storage */
MAILBOX_SELECT = 0x20000000,
MAILBOX_MATCHED = 0x40000000
};
enum mailbox_list_iter_flags {
/* Ignore index file and ACLs (used by ACL plugin internally) */
MAILBOX_LIST_ITER_RAW_LIST = 0x000001,
/* When listing "foo/%" and "foo" is an existing mailbox
(maybe \noselect), have LIST also return "foo/" in the replies.
This is needed by IMAP, but messes up internal code. */
MAILBOX_LIST_ITER_SHOW_EXISTING_PARENT = 0x000002,
/* Don't list autocreated mailboxes (e.g. INBOX) unless they
physically exist */
MAILBOX_LIST_ITER_NO_AUTO_BOXES = 0x000004,
/* For mailbox_list_iter_init_namespaces(): Skip namespaces that
have alias_for set. */
MAILBOX_LIST_ITER_SKIP_ALIASES = 0x000008,
/* For mailbox_list_iter_init_namespaces(): '*' in a pattern doesn't
match beyond namespace boundary (e.g. "foo*" or "*o" doesn't match
"foo." namespace's mailboxes, but "*.*" does). also '%' can't match
namespace prefixes, if there exists a parent namespace whose children
it matches. */
MAILBOX_LIST_ITER_STAR_WITHIN_NS = 0x000010,
/* List only subscribed mailboxes */
MAILBOX_LIST_ITER_SELECT_SUBSCRIBED = 0x000100,
/* Return MAILBOX_CHILD_* if mailbox's children match selection
criteria, even if the mailbox itself wouldn't match. */
MAILBOX_LIST_ITER_SELECT_RECURSIVEMATCH = 0x000200,
/* Return only mailboxes that have special use flags */
MAILBOX_LIST_ITER_SELECT_SPECIALUSE = 0x000400,
/* Don't return any flags unless it can be done without cost */
MAILBOX_LIST_ITER_RETURN_NO_FLAGS = 0x001000,
/* Return MAILBOX_SUBSCRIBED flag */
MAILBOX_LIST_ITER_RETURN_SUBSCRIBED = 0x002000,
/* Return children flags */
MAILBOX_LIST_ITER_RETURN_CHILDREN = 0x004000,
/* Return IMAP special use flags */
MAILBOX_LIST_ITER_RETURN_SPECIALUSE = 0x008000
};
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) */
};
enum mailbox_list_file_type {
};
struct mailbox_list_settings {
const char *layout; /* FIXME: shouldn't be here */
const char *root_dir;
const char *index_dir;
const char *index_pvt_dir;
const char *control_dir;
const char *alt_dir; /* FIXME: dbox-specific.. */
const char *inbox_path;
const char *subscription_fname;
/* 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;
/* Use UTF-8 mailbox names on filesystem instead of mUTF-7 */
bool utf8;
};
struct mailbox_info {
const char *name;
const char *special_use;
enum mailbox_info_flags flags;
struct mail_namespace *ns;
};
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 *
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). */
/* Create path's directory with proper permissions. */
/* Like mailbox_list_mkdir(), but create path's parent parent directory.
Since most directories are created lazily, this function can be used to
easily create them whenever file creation fails with ENOENT. */
ATTR_NULL(2);
/* mkdir() a root directory of given type with proper permissions. */
enum mailbox_list_path_type type,
const char **error_r);
/* Returns TRUE if the name doesn't contain any invalid characters.
The create name check can be more strict. */
const char *pattern);
const char *name);
const char *name);
const char *vname);
/* Return full path for the given mailbox name. The name must be a valid
existing mailbox name. For INDEX=MEMORY it returns "" as the path. */
enum mailbox_list_path_type type);
/* Returns root directory path for given type. */
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.". */
/* Returns a single pattern from given reference and pattern. */
/* Initialize new mailbox list request. Pattern may contain '%' and '*'
wildcards as defined by RFC-3501. */
struct mailbox_list_iterate_context *
enum mailbox_list_iter_flags flags);
/* Like mailbox_list_iter_init(), but support multiple patterns. Patterns is
a NULL-terminated list of strings. It must contain at least one pattern. */
struct mailbox_list_iterate_context *
const char *const *patterns,
enum mailbox_list_iter_flags flags);
/* List mailbox_list_iter_init_multiple(), but list mailboxes from all the
specified namespaces. */
struct mailbox_list_iterate_context *
const char *const *patterns,
enum namespace_type type_mask,
enum mailbox_list_iter_flags flags);
/* Get next mailbox. Returns the mailbox name */
const struct mailbox_info *
/* Deinitialize mailbox list request. Returns -1 if some error
occurred while listing. */
/* List one mailbox. Returns 1 if info returned, 0 if mailbox doesn't exist,
-1 if error. */
enum mailbox_info_flags *flags_r);
/* Returns 1 if mailbox has children, 0 if not, -1 if error. */
/* Subscribe/unsubscribe mailbox. There should be no error when
subscribing to already subscribed mailbox. Subscribing to
unexisting mailboxes is optional. */
/* Create a non-selectable mailbox. Fail with MAIL_ERROR_NOTPOSSIBLE if only
a selectable mailbox can be created. */
/* 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);
#endif