mailbox-list.h revision 472369cba85d9f7c995dda60e7cd01d78b4a960a
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch /* maildir_name must always be empty */
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch /* Mailboxes are files, not directories. */
de96afeeaa5242cffe89f1966457e935806b5746Stephan Bosch /* Internally used by lib-storage */
de96afeeaa5242cffe89f1966457e935806b5746Stephan Bosch /* Ignore index file and ACLs (used by ACL plugin internally) */
de96afeeaa5242cffe89f1966457e935806b5746Stephan Bosch /* Use virtual mailbox names (virtual separators and namespace
de96afeeaa5242cffe89f1966457e935806b5746Stephan Bosch prefixes) for patterns and for returned mailbox names. */
de96afeeaa5242cffe89f1966457e935806b5746Stephan Bosch /* For mailbox_list_iter_init_namespaces(): Skip namespaces that
de96afeeaa5242cffe89f1966457e935806b5746Stephan Bosch have alias_for set. */
de96afeeaa5242cffe89f1966457e935806b5746Stephan Bosch /* List only subscribed mailboxes */
de96afeeaa5242cffe89f1966457e935806b5746Stephan Bosch MAILBOX_LIST_ITER_SELECT_SUBSCRIBED = 0x000010,
de96afeeaa5242cffe89f1966457e935806b5746Stephan Bosch /* Return MAILBOX_CHILD_* if mailbox's children match selection
de96afeeaa5242cffe89f1966457e935806b5746Stephan Bosch criteria, even if the mailbox itself wouldn't match. */
6ee9ce5ed955a1283dc22ad28980bf9cc23d4c4eStephan Bosch MAILBOX_LIST_ITER_SELECT_RECURSIVEMATCH = 0x000020,
de96afeeaa5242cffe89f1966457e935806b5746Stephan Bosch /* Don't return any flags unless it can be done without cost */
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch /* Return MAILBOX_SUBSCRIBED flag */
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch MAILBOX_LIST_ITER_RETURN_SUBSCRIBED = 0x002000,
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch /* Return children flags */
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch /* Return directory's path (eg. ~/dbox/INBOX) */
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch /* Return mailbox path (eg. ~/dbox/INBOX/dbox-Mails) */
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch /* Return control directory */
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch /* Return index file directory */
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch const char *layout; /* FIXME: shouldn't be here */
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch const char *alt_dir; /* FIXME: dbox-specific.. */
c275cef636c79e1d08b3a82462c4abdca6f8cef3Martti Rannanjärvi /* If non-empty, it means that mails exist in a maildir_name
7944646fad6aa1e7c649c3d33e454c516b0220b6Timo Sirainen subdirectory. eg. if you have a directory containing directories:
5d31e4b38ef03b002e2ab245a7f8a4c0da3dd03dTimo Sirainen If mailbox_name is empty, you have mailboxes "mail", "mail/foo" and
4219de12b28f1936219e27501b9c4b27a4f8d53cStephan Bosch If mailbox_name is "Maildir", you have a non-selectable mailbox
4219de12b28f1936219e27501b9c4b27a4f8d53cStephan Bosch "mail" and a selectable mailbox "mail/foo". */
4219de12b28f1936219e27501b9c4b27a4f8d53cStephan Bosch /* if set, store mailboxes under root_dir/mailbox_dir_name/.
4219de12b28f1936219e27501b9c4b27a4f8d53cStephan Bosch this setting contains either "" or "dir/". */
4219de12b28f1936219e27501b9c4b27a4f8d53cStephan Bosch/* register all drivers */
7384b4e78eaab44693c985192276e31322155e32Stephan Boschvoid mailbox_list_register(const struct mailbox_list *list);
7384b4e78eaab44693c985192276e31322155e32Stephan Boschvoid mailbox_list_unregister(const struct mailbox_list *list);
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch/* Returns 0 if ok, -1 if driver was unknown. */
9d746c6785d17e421c3f3c74cf29d059ae2ab233Stephan Boschint mailbox_list_create(const char *driver, struct mail_namespace *ns,
fe2b0e3de834dd40b698bb579adc5357d5789ec9Stephan Bosch enum mailbox_list_flags flags, const char **error_r);
fe2b0e3de834dd40b698bb579adc5357d5789ec9Stephan Boschvoid mailbox_list_destroy(struct mailbox_list **list);
94d1b08c9e20d637db568a3eab3dfc2b9e96e62aStephan Boschmailbox_list_get_driver_name(const struct mailbox_list *list) ATTR_PURE;
94d1b08c9e20d637db568a3eab3dfc2b9e96e62aStephan Boschchar mailbox_list_get_hierarchy_sep(const struct mailbox_list *list) ATTR_PURE;
ad03049781fc14807248007d524be4daf06c3ee2Stephan Boschmailbox_list_get_flags(const struct mailbox_list *list) ATTR_PURE;
e47c2f17d8136c4d972d1074a3f84ba2ecef4fdcStephan Boschmailbox_list_get_namespace(const struct mailbox_list *list) ATTR_PURE;
feba5e502b2131c9a1c766b7ef9ff041dbf71d1dStephan Boschmailbox_list_get_user(const struct mailbox_list *list) ATTR_PURE;
b66def5dadd3e7c250313a938d26ad113663f86bStephan Boschint mailbox_list_get_storage(struct mailbox_list **list, const char **name,
5257840e8d31a6cb7051703b4cb0931c82aba638Stephan Boschvoid mailbox_list_get_closest_storage(struct mailbox_list *list,
5257840e8d31a6cb7051703b4cb0931c82aba638Stephan Bosch/* Returns the mode and GID that should be used when creating new files to
a8c4e79ff50fac21b05a7368b052583d410ca15cTimo Sirainen the specified mailbox, or to mailbox list root if name is NULL. (gid_t)-1 is
70505f4839520ac67895992621c97d2480c22e7fTimo Sirainen returned if it's not necessary to change the default gid. */
93cc87bb22386e020cee1093b6bd59295e0b33f0Stephan Boschvoid mailbox_list_get_permissions(struct mailbox_list *list,
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch/* Like mailbox_list_get_permissions(), but add execute-bits for mode
fca68889b287d8eed4babe72a231bd6079da012dStephan Bosch if either read or write bit is set (e.g. 0640 -> 0750). */
fca68889b287d8eed4babe72a231bd6079da012dStephan Boschvoid mailbox_list_get_dir_permissions(struct mailbox_list *list,
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch/* Create path's parent directory with proper permissions. Since most
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch directories are created lazily, this function can be used to easily create
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch them whenever file creation fails with ENOENT. */
7384b4e78eaab44693c985192276e31322155e32Stephan Boschint mailbox_list_create_parent_dir(struct mailbox_list *list,
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch/* Returns TRUE if the name doesn't contain any invalid characters.
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch The create name check can be more strict. */
7384b4e78eaab44693c985192276e31322155e32Stephan Boschbool mailbox_list_is_valid_pattern(struct mailbox_list *list,
6ab81c81be13f33486746deeffe02a1ef2bcc821Stephan Bosch const char *pattern);
7384b4e78eaab44693c985192276e31322155e32Stephan Boschbool mailbox_list_is_valid_existing_name(struct mailbox_list *list,
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch const char *name);
7384b4e78eaab44693c985192276e31322155e32Stephan Boschbool mailbox_list_is_valid_create_name(struct mailbox_list *list,
f9d2a1f21ad65262bc630f0834d7eead06a1bac3Timo Sirainen const char *name);
6ab81c81be13f33486746deeffe02a1ef2bcc821Stephan Bosch/* Return full path for the given mailbox name. The name must be a valid
6ab81c81be13f33486746deeffe02a1ef2bcc821Stephan Bosch existing mailbox name, or NULL to get the root directory.
6ab81c81be13f33486746deeffe02a1ef2bcc821Stephan Bosch For INDEX=MEMORY it returns "" as the path. */
6ab81c81be13f33486746deeffe02a1ef2bcc821Stephan Boschconst char *mailbox_list_get_path(struct mailbox_list *list, const char *name,
6ab81c81be13f33486746deeffe02a1ef2bcc821Stephan Bosch/* Returns mailbox name status */
fca68889b287d8eed4babe72a231bd6079da012dStephan Boschint mailbox_list_get_mailbox_name_status(struct mailbox_list *list,
9dc01e0d10a61cab14867b26bf0d2d1dcf8ad978Timo Sirainen/* Returns a prefix that temporary files should use without conflicting
9dc01e0d10a61cab14867b26bf0d2d1dcf8ad978Timo Sirainen with the namespace. */
ebe0f5e387744621b73c4db79d5891ccbe0a1321Stephan Boschconst char *mailbox_list_get_temp_prefix(struct mailbox_list *list);
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch/* Returns prefix that's common to all get_temp_prefix() calls.
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch Typically this returns either "temp." or ".temp.". */
7384b4e78eaab44693c985192276e31322155e32Stephan Boschconst char *mailbox_list_get_global_temp_prefix(struct mailbox_list *list);
aacf2a69acc59e9382578d6f4e030788abc79706Timo Sirainen/* Returns a single pattern from given reference and pattern. */
aacf2a69acc59e9382578d6f4e030788abc79706Timo Sirainenconst char *mailbox_list_join_refpattern(struct mailbox_list *list,
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch/* Initialize new mailbox list request. Pattern may contain '%' and '*'
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch wildcards as defined by RFC-3501. */
6ab81c81be13f33486746deeffe02a1ef2bcc821Stephan Boschmailbox_list_iter_init(struct mailbox_list *list, const char *pattern,
6ab81c81be13f33486746deeffe02a1ef2bcc821Stephan Bosch/* Like mailbox_list_iter_init(), but support multiple patterns. Patterns is
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch a NULL-terminated list of strings. It must contain at least one pattern. */
415e16c3dc185578695b7d88e561a52de6c8b1b1Timo Sirainenmailbox_list_iter_init_multiple(struct mailbox_list *list,
415e16c3dc185578695b7d88e561a52de6c8b1b1Timo Sirainen const char *const *patterns,
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch/* List mailbox_list_iter_init_multiple(), but list mailboxes from all the
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch specified namespaces. */
7384b4e78eaab44693c985192276e31322155e32Stephan Boschmailbox_list_iter_init_namespaces(struct mail_namespace *namespaces,
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch const char *const *patterns,
fc94140acba51adafedafbc8491a3223a51db7a8Stephan Bosch/* Get next mailbox. Returns the mailbox name */
7384b4e78eaab44693c985192276e31322155e32Stephan Boschmailbox_list_iter_next(struct mailbox_list_iterate_context *ctx);
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch/* Deinitialize mailbox list request. Returns -1 if some error
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch occurred while listing. */
7384b4e78eaab44693c985192276e31322155e32Stephan Boschint mailbox_list_iter_deinit(struct mailbox_list_iterate_context **ctx);
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch/* Subscribe/unsubscribe mailbox. There should be no error when
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch subscribing to already subscribed mailbox. Subscribing to
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch unexisting mailboxes is optional. */
7384b4e78eaab44693c985192276e31322155e32Stephan Boschint mailbox_list_set_subscribed(struct mailbox_list *list,
fc94140acba51adafedafbc8491a3223a51db7a8Stephan Bosch/* Delete the given mailbox. If it has children, they aren't deleted. */
fc94140acba51adafedafbc8491a3223a51db7a8Stephan Boschint mailbox_list_delete_mailbox(struct mailbox_list *list, const char *name);
fc94140acba51adafedafbc8491a3223a51db7a8Stephan Bosch/* Rename mailbox. Renaming across different mailbox lists is possible only
fc94140acba51adafedafbc8491a3223a51db7a8Stephan Bosch between private namespaces and storages of the same type. If the rename
636d0f43138468f8efe685a681326b123f660e49Timo Sirainen fails, the error is set to oldlist. */
636d0f43138468f8efe685a681326b123f660e49Timo Sirainenint mailbox_list_rename_mailbox(struct mailbox_list *oldlist,
fca68889b287d8eed4babe72a231bd6079da012dStephan Bosch/* Returns the error message of last occurred error. */