mailbox-list.h revision 547847191d4a95cd267fc846a1ca3c2111214719
bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch#ifndef MAILBOX_LIST_H
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi#define MAILBOX_LIST_H
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi#include "mail-error.h"
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomistruct mail_namespace;
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomistruct mail_storage;
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomistruct mailbox_list;
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomistruct mailbox_list_iterate_context;
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomienum mailbox_list_properties {
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi /* maildir_name must always be empty */
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi MAILBOX_LIST_PROP_NO_MAILDIR_NAME = 0x01
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi};
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomienum mailbox_list_flags {
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi /* Mailboxes are files, not directories. */
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi MAILBOX_LIST_FLAG_MAILBOX_FILES = 0x01
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi};
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomienum mailbox_info_flags {
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi MAILBOX_NOSELECT = 0x001,
fe4a5467c998dfd79a071416068ca59d5a6a388fTimo Sirainen MAILBOX_NONEXISTENT = 0x002,
fe4a5467c998dfd79a071416068ca59d5a6a388fTimo Sirainen MAILBOX_CHILDREN = 0x004,
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi MAILBOX_NOCHILDREN = 0x008,
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi MAILBOX_NOINFERIORS = 0x010,
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi MAILBOX_MARKED = 0x020,
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi MAILBOX_UNMARKED = 0x040,
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi MAILBOX_SUBSCRIBED = 0x080,
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi MAILBOX_CHILD_SUBSCRIBED = 0x100,
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi /* Internally used by lib-storage */
84b746f56209d4a85af73cd26850e75f519ae0b0Timo Sirainen MAILBOX_MATCHED = 0x40000000
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi};
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomienum mailbox_name_status {
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi MAILBOX_NAME_EXISTS,
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi MAILBOX_NAME_VALID,
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi MAILBOX_NAME_INVALID,
84b746f56209d4a85af73cd26850e75f519ae0b0Timo Sirainen MAILBOX_NAME_NOINFERIORS
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi};
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomienum mailbox_list_iter_flags {
39435f00a35a276d329283179b3e7e0351482939Timo Sirainen /* Ignore index file and ACLs (used by ACL plugin internally) */
39435f00a35a276d329283179b3e7e0351482939Timo Sirainen MAILBOX_LIST_ITER_RAW_LIST = 0x000001,
39435f00a35a276d329283179b3e7e0351482939Timo Sirainen /* Use virtual mailbox names (virtual separators and namespace
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi prefixes) for patterns and for returned mailbox names. */
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi MAILBOX_LIST_ITER_VIRTUAL_NAMES = 0x000002,
39435f00a35a276d329283179b3e7e0351482939Timo Sirainen /* For mailbox_list_iter_init_namespaces(): Skip namespaces that
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi have alias_for set. */
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi MAILBOX_LIST_ITER_SKIP_ALIASES = 0x000004,
fe4a5467c998dfd79a071416068ca59d5a6a388fTimo Sirainen
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi /* List only subscribed mailboxes */
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi MAILBOX_LIST_ITER_SELECT_SUBSCRIBED = 0x000010,
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi /* Return MAILBOX_CHILD_* if mailbox's children match selection
fe4a5467c998dfd79a071416068ca59d5a6a388fTimo Sirainen criteria, even if the mailbox itself wouldn't match. */
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi MAILBOX_LIST_ITER_SELECT_RECURSIVEMATCH = 0x000020,
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi /* Don't return any flags unless it can be done without cost */
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi MAILBOX_LIST_ITER_RETURN_NO_FLAGS = 0x001000,
39435f00a35a276d329283179b3e7e0351482939Timo Sirainen /* Return MAILBOX_SUBSCRIBED flag */
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi MAILBOX_LIST_ITER_RETURN_SUBSCRIBED = 0x002000,
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi /* Return children flags */
fe4a5467c998dfd79a071416068ca59d5a6a388fTimo Sirainen MAILBOX_LIST_ITER_RETURN_CHILDREN = 0x004000
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi};
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomienum mailbox_list_path_type {
39435f00a35a276d329283179b3e7e0351482939Timo Sirainen /* Return directory's path (eg. ~/dbox/INBOX) */
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi MAILBOX_LIST_PATH_TYPE_DIR,
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi /* Return mailbox path (eg. ~/dbox/INBOX/dbox-Mails) */
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi MAILBOX_LIST_PATH_TYPE_MAILBOX,
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi /* Return control directory */
fe4a5467c998dfd79a071416068ca59d5a6a388fTimo Sirainen MAILBOX_LIST_PATH_TYPE_CONTROL,
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi /* Return index file directory */
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi MAILBOX_LIST_PATH_TYPE_INDEX
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi};
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomienum mailbox_list_file_type {
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi MAILBOX_LIST_FILE_TYPE_UNKNOWN = 0,
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi MAILBOX_LIST_FILE_TYPE_FILE,
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi MAILBOX_LIST_FILE_TYPE_DIR,
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi MAILBOX_LIST_FILE_TYPE_SYMLINK,
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi MAILBOX_LIST_FILE_TYPE_OTHER
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi};
39435f00a35a276d329283179b3e7e0351482939Timo Sirainen
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomistruct mailbox_list_settings {
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi const char *layout; /* FIXME: shouldn't be here */
fe4a5467c998dfd79a071416068ca59d5a6a388fTimo Sirainen const char *root_dir;
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi const char *index_dir;
39435f00a35a276d329283179b3e7e0351482939Timo Sirainen const char *control_dir;
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi const char *alt_dir; /* FIXME: dbox-specific.. */
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi const char *inbox_path;
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi const char *subscription_fname;
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi /* If non-empty, it means that mails exist in a maildir_name
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi subdirectory. eg. if you have a directory containing directories:
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi mail/
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi mail/foo/
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi mail/foo/Maildir
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi If mailbox_name is empty, you have mailboxes "mail", "mail/foo" and
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi "mail/foo/Maildir".
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi If mailbox_name is "Maildir", you have a non-selectable mailbox
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi "mail" and a selectable mailbox "mail/foo". */
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi const char *maildir_name;
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi /* if set, store mailboxes under root_dir/mailbox_dir_name/.
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi this setting contains either "" or "dir/". */
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi const char *mailbox_dir_name;
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi};
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomistruct mailbox_info {
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi const char *name;
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi enum mailbox_info_flags flags;
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi struct mail_namespace *ns;
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi};
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi/* register all drivers */
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomivoid mailbox_list_register_all(void);
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomivoid mailbox_list_register(const struct mailbox_list *list);
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomivoid mailbox_list_unregister(const struct mailbox_list *list);
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi/* Returns 0 if ok, -1 if driver was unknown. */
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomiint mailbox_list_create(const char *driver, struct mail_namespace *ns,
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi const struct mailbox_list_settings *set,
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi enum mailbox_list_flags flags, const char **error_r);
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomivoid mailbox_list_destroy(struct mailbox_list **list);
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomiconst char *
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomimailbox_list_get_driver_name(const struct mailbox_list *list) ATTR_PURE;
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomichar mailbox_list_get_hierarchy_sep(const struct mailbox_list *list) ATTR_PURE;
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomienum mailbox_list_flags
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomimailbox_list_get_flags(const struct mailbox_list *list) ATTR_PURE;
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomistruct mail_namespace *
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomimailbox_list_get_namespace(const struct mailbox_list *list) ATTR_PURE;
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomistruct mail_user *
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomimailbox_list_get_user(const struct mailbox_list *list) ATTR_PURE;
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomiint mailbox_list_get_storage(struct mailbox_list **list, const char **name,
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi struct mail_storage **storage_r);
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomivoid mailbox_list_get_closest_storage(struct mailbox_list *list,
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi struct mail_storage **storage);
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi/* Returns the mode and GID that should be used when creating new files to
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi the specified mailbox, or to mailbox list root if name is NULL. (gid_t)-1 is
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi returned if it's not necessary to change the default gid. */
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomivoid mailbox_list_get_permissions(struct mailbox_list *list, const char *name,
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi mode_t *mode_r, gid_t *gid_r);
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi/* Like mailbox_list_get_permissions(), but add execute-bits for mode
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi if either read or write bit is set (e.g. 0640 -> 0750). */
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomivoid mailbox_list_get_dir_permissions(struct mailbox_list *list,
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi const char *name,
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi mode_t *mode_r, gid_t *gid_r);
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi/* Returns TRUE if the name doesn't contain any invalid characters.
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi The create name check can be more strict. */
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomibool mailbox_list_is_valid_pattern(struct mailbox_list *list,
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi const char *pattern);
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomibool mailbox_list_is_valid_existing_name(struct mailbox_list *list,
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi const char *name);
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomibool mailbox_list_is_valid_create_name(struct mailbox_list *list,
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi const char *name);
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi/* Return full path for the given mailbox name. The name must be a valid
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi existing mailbox name, or NULL to get the root directory.
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi For INDEX=MEMORY it returns "" as the path. */
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomiconst char *mailbox_list_get_path(struct mailbox_list *list, const char *name,
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi enum mailbox_list_path_type type);
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi/* Returns mailbox name status */
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomiint mailbox_list_get_mailbox_name_status(struct mailbox_list *list,
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi const char *name,
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi enum mailbox_name_status *status);
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi/* Returns a prefix that temporary files should use without conflicting
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi with the namespace. */
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomiconst char *mailbox_list_get_temp_prefix(struct mailbox_list *list);
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi/* Returns prefix that's common to all get_temp_prefix() calls.
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi Typically this returns either "temp." or ".temp.". */
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomiconst char *mailbox_list_get_global_temp_prefix(struct mailbox_list *list);
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi/* Returns a single pattern from given reference and pattern. */
5f1d689131a75c39f064cbd4202373e7edf78f18Josef 'Jeff' Sipekconst char *mailbox_list_join_refpattern(struct mailbox_list *list,
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi const char *ref, const char *pattern);
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi
fe4a5467c998dfd79a071416068ca59d5a6a388fTimo Sirainen/* Initialize new mailbox list request. Pattern may contain '%' and '*'
fe4a5467c998dfd79a071416068ca59d5a6a388fTimo Sirainen wildcards as defined by RFC-3501. */
fe4a5467c998dfd79a071416068ca59d5a6a388fTimo Sirainenstruct mailbox_list_iterate_context *
fe4a5467c998dfd79a071416068ca59d5a6a388fTimo Sirainenmailbox_list_iter_init(struct mailbox_list *list, const char *pattern,
fe4a5467c998dfd79a071416068ca59d5a6a388fTimo Sirainen enum mailbox_list_iter_flags flags);
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi/* Like mailbox_list_iter_init(), but support multiple patterns. Patterns is
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi a NULL-terminated list of strings. It must contain at least one pattern. */
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomistruct mailbox_list_iterate_context *
3bc5b80ae9075e5d940616553f81e8acdd4bd88fTimo Sirainenmailbox_list_iter_init_multiple(struct mailbox_list *list,
3bc5b80ae9075e5d940616553f81e8acdd4bd88fTimo Sirainen const char *const *patterns,
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi enum mailbox_list_iter_flags flags);
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi/* List mailbox_list_iter_init_multiple(), but list mailboxes from all the
08c0bffa1c9ccb1ac67689093f3c99cd38cfd3a4Aki Tuomi specified namespaces. */
struct mailbox_list_iterate_context *
mailbox_list_iter_init_namespaces(struct mail_namespace *namespaces,
const char *const *patterns,
enum mailbox_list_iter_flags flags);
/* Get next mailbox. Returns the mailbox name */
const struct mailbox_info *
mailbox_list_iter_next(struct mailbox_list_iterate_context *ctx);
/* Deinitialize mailbox list request. Returns -1 if some error
occurred while listing. */
int mailbox_list_iter_deinit(struct mailbox_list_iterate_context **ctx);
/* Subscribe/unsubscribe mailbox. There should be no error when
subscribing to already subscribed mailbox. Subscribing to
unexisting mailboxes is optional. */
int mailbox_list_set_subscribed(struct mailbox_list *list,
const char *name, bool set);
/* Delete the given mailbox. If it has children, they aren't deleted. */
int mailbox_list_delete_mailbox(struct mailbox_list *list, const char *name);
/* Rename mailbox. Renaming across different mailbox lists is possible only
between private namespaces and storages of the same type. If the rename
fails, the error is set to oldlist. */
int mailbox_list_rename_mailbox(struct mailbox_list *oldlist,
const char *oldname,
struct mailbox_list *newlist,
const char *newname, bool rename_children);
/* Returns the error message of last occurred error. */
const char *mailbox_list_get_last_error(struct mailbox_list *list,
enum mail_error *error_r);
#endif