1 #ifndef MAILBOX_LIST_ITER_H 2 #define MAILBOX_LIST_ITER_H 3 4 #include "mail-namespace.h" 5 #include "mailbox-list.h" 6 7 enum mailbox_list_iter_flags { 8 /* Ignore index file and ACLs (used by ACL plugin internally) */ 9 MAILBOX_LIST_ITER_RAW_LIST = 0x000001, 10 /* Don't list autocreated mailboxes (e.g. INBOX) unless they 11 physically exist */ 12 MAILBOX_LIST_ITER_NO_AUTO_BOXES = 0x000004, 13 14 /* Skip all kinds of mailbox aliases. This typically includes symlinks 15 that point to the same directory. Also when iterating with 16 mailbox_list_iter_init_namespaces() skip namespaces that 17 have alias_for set. */ 18 MAILBOX_LIST_ITER_SKIP_ALIASES = 0x000008, 19 /* For mailbox_list_iter_init_namespaces(): '*' in a pattern doesn't 20 match beyond namespace boundary (e.g. "foo*" or "*o" doesn't match 21 "foo." namespace's mailboxes, but "*.*" does). also '%' can't match 22 namespace prefixes, if there exists a parent namespace whose children 23 it matches. */ 24 MAILBOX_LIST_ITER_STAR_WITHIN_NS = 0x000010, 25 26 /* List only subscribed mailboxes */ 27 MAILBOX_LIST_ITER_SELECT_SUBSCRIBED = 0x000100, 28 /* Return MAILBOX_CHILD_* if mailbox's children match selection 29 criteria, even if the mailbox itself wouldn't match. */ 30 MAILBOX_LIST_ITER_SELECT_RECURSIVEMATCH = 0x000200, 31 /* Return only mailboxes that have special use flags */ 32 MAILBOX_LIST_ITER_SELECT_SPECIALUSE = 0x000400, 33 34 /* Don't return any flags unless it can be done without cost */ 35 MAILBOX_LIST_ITER_RETURN_NO_FLAGS = 0x001000, 36 /* Return MAILBOX_SUBSCRIBED flag */ 37 MAILBOX_LIST_ITER_RETURN_SUBSCRIBED = 0x002000, 38 /* Return children flags */ 39 MAILBOX_LIST_ITER_RETURN_CHILDREN = 0x004000, 40 /* Return IMAP special use flags */ 41 MAILBOX_LIST_ITER_RETURN_SPECIALUSE = 0x008000 42 }; 43 44 struct mailbox_info { 45 const char *vname; 46 const char *special_use; 47 enum mailbox_info_flags flags; 48 49 struct mail_namespace *ns; 50 }; 51 52 /* Returns a single pattern from given reference and pattern. */ 53 const char *mailbox_list_join_refpattern(struct mailbox_list *list, 54 const char *ref, const char *pattern); 55 56 /* Initialize new mailbox list request. Pattern may contain '%' and '*' 57 wildcards as defined by RFC-3501. */ 58 struct mailbox_list_iterate_context * 59 mailbox_list_iter_init(struct mailbox_list *list, const char *pattern, 60 enum mailbox_list_iter_flags flags); 61 /* Like mailbox_list_iter_init(), but support multiple patterns. Patterns is 62 a NULL-terminated list of strings. It must contain at least one pattern. */ 63 struct mailbox_list_iterate_context * 64 mailbox_list_iter_init_multiple(struct mailbox_list *list, 65 const char *const *patterns, 66 enum mailbox_list_iter_flags flags); 67 /* Like mailbox_list_iter_init_multiple(), but list mailboxes from all the 68 specified namespaces. If it fails, the error message is set to the first 69 namespaces->list. */ 70 struct mailbox_list_iterate_context * 71 mailbox_list_iter_init_namespaces(struct mail_namespace *namespaces, 72 const char *const *patterns, 73 enum mail_namespace_type type_mask, 74 enum mailbox_list_iter_flags flags); 75 /* Get next mailbox. Returns the mailbox name */ 76 const struct mailbox_info * 77 mailbox_list_iter_next(struct mailbox_list_iterate_context *ctx); 78 /* Deinitialize mailbox list request. Returns -1 if some error 79 occurred while listing. The error string can be looked up with 80 mailbox_list_get_last_error(). */ 81 int mailbox_list_iter_deinit(struct mailbox_list_iterate_context **ctx); 82 /* List one mailbox. Returns 1 if info returned, 0 if mailbox doesn't exist, 83 -1 if error. */ 84 int mailbox_list_mailbox(struct mailbox_list *list, const char *name, 85 enum mailbox_info_flags *flags_r); 86 /* Returns 1 if mailbox has children, 0 if not, -1 if error. */ 87 int mailbox_has_children(struct mailbox_list *list, const char *name); 88 89 #endif 90