24
24
/* no support for \noselect directories, only mailboxes */
25
25
MAILBOX_LIST_PROP_NO_NOSELECT = 0x04,
26
26
/* mail root directory isn't required */
27
MAILBOX_LIST_PROP_NO_ROOT = 0x08
27
MAILBOX_LIST_PROP_NO_ROOT = 0x08,
28
/* Automatically create mailbox directories when needed */
29
MAILBOX_LIST_PROP_AUTOCREATE_DIRS = 0x10
30
32
enum mailbox_list_flags {
31
33
/* Mailboxes are files, not directories. */
32
MAILBOX_LIST_FLAG_MAILBOX_FILES = 0x01
34
MAILBOX_LIST_FLAG_MAILBOX_FILES = 0x01,
35
/* Namespace already has a mailbox list, don't assign this
36
mailbox list to it. */
37
MAILBOX_LIST_FLAG_SECONDARY = 0x02
35
40
enum mailbox_info_flags {
65
60
(maybe \noselect), have LIST also return "foo/" in the replies.
66
61
This is needed by IMAP, but messes up internal code. */
67
62
MAILBOX_LIST_ITER_SHOW_EXISTING_PARENT = 0x000002,
68
/* Don't list INBOX unless it actually exists */
69
MAILBOX_LIST_ITER_NO_AUTO_INBOX = 0x000004,
63
/* Don't list autocreated mailboxes (e.g. INBOX) unless they
65
MAILBOX_LIST_ITER_NO_AUTO_BOXES = 0x000004,
71
67
/* For mailbox_list_iter_init_namespaces(): Skip namespaces that
72
68
have alias_for set. */
83
79
/* Return MAILBOX_CHILD_* if mailbox's children match selection
84
80
criteria, even if the mailbox itself wouldn't match. */
85
81
MAILBOX_LIST_ITER_SELECT_RECURSIVEMATCH = 0x000200,
82
/* Return only mailboxes that have special use flags */
83
MAILBOX_LIST_ITER_SELECT_SPECIALUSE = 0x000400,
87
85
/* Don't return any flags unless it can be done without cost */
88
86
MAILBOX_LIST_ITER_RETURN_NO_FLAGS = 0x001000,
89
87
/* Return MAILBOX_SUBSCRIBED flag */
90
88
MAILBOX_LIST_ITER_RETURN_SUBSCRIBED = 0x002000,
91
89
/* Return children flags */
92
MAILBOX_LIST_ITER_RETURN_CHILDREN = 0x004000
90
MAILBOX_LIST_ITER_RETURN_CHILDREN = 0x004000,
91
/* Return IMAP special use flags */
92
MAILBOX_LIST_ITER_RETURN_SPECIALUSE = 0x008000
95
95
enum mailbox_list_path_type {
138
138
/* if set, store mailboxes under root_dir/mailbox_dir_name/.
139
139
this setting contains either "" or "dir/". */
140
140
const char *mailbox_dir_name;
142
/* Encode "bad" characters in mailbox names as <escape_char><hex> */
144
/* Use UTF-8 mailbox names on filesystem instead of mUTF-7 */
143
148
struct mailbox_info {
144
149
const char *name;
150
const char *special_use;
145
151
enum mailbox_info_flags flags;
146
153
struct mail_namespace *ns;
156
struct mailbox_permissions {
157
/* The actual uid/gid of the mailbox */
161
/* mode and GID to use for newly created files/dirs.
162
(gid_t)-1 is used if the default GID can be used. */
163
mode_t file_create_mode, dir_create_mode;
164
gid_t file_create_gid;
165
/* origin (e.g. path) where the file_create_gid was got from */
166
const char *file_create_gid_origin;
168
bool mail_index_permissions_set;
149
171
/* register all drivers */
150
172
void mailbox_list_register_all(void);
158
180
/* Returns 0 if ok, -1 if driver was unknown. */
159
181
int mailbox_list_create(const char *driver, struct mail_namespace *ns,
160
182
const struct mailbox_list_settings *set,
161
enum mailbox_list_flags flags, const char **error_r);
183
enum mailbox_list_flags flags,
184
struct mailbox_list **list_r, const char **error_r);
162
185
void mailbox_list_destroy(struct mailbox_list **list);
169
192
mailbox_list_get_namespace(const struct mailbox_list *list) ATTR_PURE;
170
193
struct mail_user *
171
194
mailbox_list_get_user(const struct mailbox_list *list) ATTR_PURE;
172
int mailbox_list_get_storage(struct mailbox_list **list, const char **name,
195
int mailbox_list_get_storage(struct mailbox_list **list, const char *vname,
173
196
struct mail_storage **storage_r);
174
197
void mailbox_list_get_closest_storage(struct mailbox_list *list,
175
198
struct mail_storage **storage);
199
char mailbox_list_get_hierarchy_sep(struct mailbox_list *list);
177
/* Returns the mode and GID that should be used when creating new files to
178
the specified mailbox, or to mailbox list root if name is NULL. (gid_t)-1 is
179
returned if it's not necessary to change the default gid. */
180
void mailbox_list_get_permissions(struct mailbox_list *list,
182
mode_t *mode_r, gid_t *gid_r,
183
const char **gid_origin_r);
184
/* Like mailbox_list_get_permissions(), but add execute-bits for mode
185
if either read or write bit is set (e.g. 0640 -> 0750). */
186
void mailbox_list_get_dir_permissions(struct mailbox_list *list,
188
mode_t *mode_r, gid_t *gid_r,
189
const char **gid_origin_r);
190
/* Create path's parent directory with proper permissions. Since most
191
directories are created lazily, this function can be used to easily create
192
them whenever file creation fails with ENOENT. */
193
int mailbox_list_create_parent_dir(struct mailbox_list *list,
194
const char *mailbox, const char *path);
201
/* Returns the mode and GID that should be used when creating new files and
202
directories to the specified mailbox. (gid_t)-1 is returned if it's not
203
necessary to change the default gid. */
204
void mailbox_list_get_permissions(struct mailbox_list *list, const char *name,
205
struct mailbox_permissions *permissions_r);
206
/* Like mailbox_list_get_permissions(), but for creating files/dirs to the
207
mail root directory (or even the root dir itself). */
208
void mailbox_list_get_root_permissions(struct mailbox_list *list,
209
mode_t *file_mode_r, mode_t *dir_mode_r,
210
gid_t *gid_r, const char **gid_origin_r);
211
/* Create path's directory with proper permissions. */
212
int mailbox_list_mkdir(struct mailbox_list *list,
213
const char *mailbox, const char *path);
214
/* Like mailbox_list_mkdir(), but create path's parent parent directory.
215
Since most directories are created lazily, this function can be used to
216
easily create them whenever file creation fails with ENOENT. */
217
int mailbox_list_mkdir_parent(struct mailbox_list *list,
218
const char *mailbox, const char *path);
219
/* mkdir() a root directory of given type with proper permissions. */
220
int mailbox_list_mkdir_root(struct mailbox_list *list, const char *path,
221
enum mailbox_list_path_type type,
222
const char **error_r);
196
224
/* Returns TRUE if the name doesn't contain any invalid characters.
197
225
The create name check can be more strict. */
202
230
bool mailbox_list_is_valid_create_name(struct mailbox_list *list,
203
231
const char *name);
233
const char *mailbox_list_get_storage_name(struct mailbox_list *list,
235
const char *mailbox_list_get_vname(struct mailbox_list *list, const char *name);
205
237
/* Return full path for the given mailbox name. The name must be a valid
206
238
existing mailbox name, or NULL to get the root directory.
207
239
For INDEX=MEMORY it returns "" as the path. */
208
240
const char *mailbox_list_get_path(struct mailbox_list *list, const char *name,
209
241
enum mailbox_list_path_type type);
210
/* Returns mailbox name status */
211
int mailbox_list_get_mailbox_name_status(struct mailbox_list *list,
213
enum mailbox_name_status *status);
214
242
/* Returns mailbox's change log, or NULL if it doesn't have one. */
215
243
struct mailbox_log *mailbox_list_get_changelog(struct mailbox_list *list);
216
244
/* Specify timestamp to use when writing mailbox changes to changelog.
270
300
int mailbox_list_create_dir(struct mailbox_list *list, const char *name);
271
301
/* Delete a non-selectable mailbox. Fail if the mailbox is selectable. */
272
302
int mailbox_list_delete_dir(struct mailbox_list *list, const char *name);
303
/* Delete a symlinked mailbox. Fail if the mailbox isn't a symlink. */
304
int mailbox_list_delete_symlink(struct mailbox_list *list, const char *name);
274
306
/* Returns the error message of last occurred error. */
275
307
const char *mailbox_list_get_last_error(struct mailbox_list *list,