Lines Matching refs:box

34 static void maildir_mailbox_close(struct mailbox *box);
160 mkdir_verify(struct mailbox *box, const char *dir, bool verify)
170 mailbox_set_critical(box, "stat(%s) failed: %m", dir);
175 perm = mailbox_get_permissions(box);
184 mail_storage_set_error(box->storage, MAIL_ERROR_EXISTS,
187 mail_storage_set_error(box->storage, MAIL_ERROR_NOTFOUND,
190 if (box->list->ns->type == MAIL_NAMESPACE_TYPE_SHARED) {
192 mail_storage_set_error(box->storage, MAIL_ERROR_PERM,
196 mailbox_set_critical(box, "%s",
199 mailbox_set_critical(box, "mkdir(%s) failed: %m", dir);
238 static int create_maildir_subdirs(struct mailbox *box, bool verify)
245 if (mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_MAILBOX,
251 if (mkdir_verify(box, path, verify) < 0) {
252 error = mailbox_get_last_mail_error(box);
277 mbox->box = maildir_mailbox;
278 mbox->box.pool = pool;
279 mbox->box.storage = storage;
280 mbox->box.list = list;
281 mbox->box.mail_vfuncs = &maildir_mail_vfuncs;
284 index_storage_mailbox_alloc(&mbox->box, vname, flags, MAIL_INDEX_PREFIX);
287 return &mbox->box;
290 static int maildir_mailbox_open_existing(struct mailbox *box)
292 struct maildir_mailbox *mbox = MAILDIR_MAILBOX(box);
297 if ((box->flags & MAILBOX_FLAG_KEEP_LOCKED) != 0) {
299 maildir_mailbox_close(box);
307 if (index_storage_mailbox_open(box, FALSE) < 0) {
308 maildir_mailbox_close(box);
313 mail_index_ext_register(mbox->box.index, "maildir",
318 static bool maildir_storage_is_readonly(struct mailbox *box)
320 struct maildir_mailbox *mbox = MAILDIR_MAILBOX(box);
322 if (index_storage_is_readonly(box))
328 if (mailbox_get_private_flags_mask(box) == 0)
335 maildir_mailbox_exists(struct mailbox *box, bool auto_boxes ATTR_UNUSED,
338 return index_storage_mailbox_exists_full(box, "cur", existence_r);
341 static int maildir_mailbox_open(struct mailbox *box)
343 const char *box_path = mailbox_get_path(box);
350 ret = maildir_check_tmp(box->storage, box_path);
353 return maildir_mailbox_open_existing(box);
360 if (strcmp(box->list->name, MAILBOX_LIST_NAME_MAILDIRPLUSPLUS) != 0 &&
361 strcmp(box->list->name, MAILBOX_LIST_NAME_IMAPDIR) != 0) {
362 mail_storage_set_error(box->storage, MAIL_ERROR_NOTFOUND,
363 T_MAIL_ERR_MAILBOX_NOT_FOUND(box->vname));
366 root_dir = mailbox_list_get_root_forced(box->list,
368 if (strcmp(box_path, root_dir) == 0 && !box->inbox_any) {
373 if (create_maildir_subdirs(box, TRUE) < 0)
376 return maildir_mailbox_open_existing(box);
380 mail_storage_set_error(box->storage, MAIL_ERROR_NOTFOUND,
381 T_MAIL_ERR_MAILBOX_NOT_FOUND(box->vname));
384 mailbox_set_critical(box, "stat(%s) failed: %m", box_path);
389 static int maildir_create_shared(struct mailbox *box)
391 const struct mailbox_permissions *perm = mailbox_get_permissions(box);
396 ret = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_MAILBOX,
408 mailbox_set_critical(box, "open(%s) failed: %m", path);
414 mailbox_set_critical(box, "%s",
419 mailbox_set_critical(box,
428 maildir_mailbox_update(struct mailbox *box, const struct mailbox_update *update)
430 struct maildir_mailbox *mbox = MAILDIR_MAILBOX(box);
435 if (!box->opened) {
436 if (mailbox_open(box) < 0)
458 ret = index_storage_mailbox_update(box, update);
464 static int maildir_create_maildirfolder_file(struct mailbox *box)
473 if (strcmp(box->list->name, MAILBOX_LIST_NAME_MAILDIRPLUSPLUS) != 0)
475 perm = mailbox_get_permissions(box);
477 path = t_strconcat(mailbox_get_path(box),
485 mail_storage_set_error(box->storage, MAIL_ERROR_NOTFOUND,
489 mailbox_set_critical(box, "open(%s, O_CREAT) failed: %m", path);
497 mailbox_set_critical(box, "%s",
502 mailbox_set_critical(box, "fchown(%s) failed: %m", path);
510 maildir_mailbox_create(struct mailbox *box, const struct mailbox_update *update,
517 if ((ret = index_storage_mailbox_create(box, directory)) <= 0)
521 if (create_maildir_subdirs(box, FALSE) < 0)
523 if (maildir_create_maildirfolder_file(box) < 0)
527 root_dir = mailbox_list_get_root_forced(box->list,
531 if (maildir_create_shared(box) < 0)
535 if (maildir_mailbox_update(box, update) < 0)
542 maildir_mailbox_get_metadata(struct mailbox *box,
546 struct maildir_mailbox *mbox = MAILDIR_MAILBOX(box);
548 if (index_mailbox_get_metadata(box, items, metadata_r) < 0)
559 static void maildir_mailbox_close(struct mailbox *box)
561 struct maildir_mailbox *mbox = MAILDIR_MAILBOX(box);
573 index_storage_mailbox_close(box);
576 static void maildir_notify_changes(struct mailbox *box)
578 struct maildir_mailbox *mbox = MAILDIR_MAILBOX(box);
579 const char *box_path = mailbox_get_path(box);
581 if (box->notify_callback == NULL)
582 mailbox_watch_remove_all(&mbox->box);
584 mailbox_watch_add(&mbox->box,
586 mailbox_watch_add(&mbox->box,
622 static enum mail_flags maildir_get_private_flags_mask(struct mailbox *box)
624 struct maildir_mailbox *mbox = MAILDIR_MAILBOX(box);
632 path = mailbox_list_get_root_forced(box->list, MAILBOX_LIST_PATH_TYPE_MAILBOX);
633 if (box->list->set.index_pvt_dir != NULL) {
637 } else if (!mailbox_list_get_root_path(box->list,
644 path = t_strconcat(mailbox_get_path(box),
655 const char *box_path = mailbox_get_path(&mbox->box);