This fixes some crashes with plugins.
--HG--
branch : HEAD
mailbox_list_set_error(shared_list, error, str);
}
+static int
+shared_get_storage(struct mailbox_list *list, const char *name,
+ struct mail_storage **storage_r)
+{
+ struct mail_namespace *ns;
+
+ if (shared_storage_get_namespace(list->ns->storage, &name, &ns) < 0)
+ return -1;
+ *storage_r = ns->storage;
+ return 0;
+}
+
static bool
shared_is_valid_pattern(struct mailbox_list *list, const char *pattern)
{
{
shared_list_alloc,
shared_list_deinit,
+ shared_get_storage,
shared_is_valid_pattern,
shared_is_valid_existing_name,
shared_is_valid_create_name,
mail_storage_set_error(shared_storage, error, str);
}
-static struct mailbox *
-shared_mailbox_open(struct mail_storage *storage, const char *name,
- struct istream *input, enum mailbox_open_flags flags)
-{
- struct mail_namespace *ns;
- struct mailbox *box;
-
- if (input != NULL) {
- mail_storage_set_critical(storage,
- "Shared storage doesn't support streamed mailboxes");
- return NULL;
- }
-
- if (shared_storage_get_namespace(storage, &name, &ns) < 0)
- return NULL;
-
- /* if we call the normal mailbox_open() here the plugins will see
- mailbox_open() called twice and they could break. */
- box = ns->storage->storage_class->v.
- mailbox_open(ns->storage, name, NULL, flags);
- if (box == NULL)
- shared_mailbox_copy_error(storage, ns);
- else
- ns->flags |= NAMESPACE_FLAG_USABLE;
- return box;
-}
-
static int shared_mailbox_create(struct mail_storage *storage,
const char *name, bool directory)
{
shared_create,
index_storage_destroy,
NULL,
- shared_mailbox_open,
+ NULL,
shared_mailbox_create
}
};
{
fs_list_alloc,
fs_list_deinit,
+ NULL,
fs_is_valid_pattern,
fs_is_valid_existing_name,
fs_is_valid_create_name,
{
maildir_list_alloc,
maildir_list_deinit,
+ NULL,
maildir_is_valid_pattern,
maildir_is_valid_existing_name,
maildir_is_valid_create_name,
{
imapdir_list_alloc,
maildir_list_deinit,
+ NULL,
maildir_is_valid_pattern,
maildir_is_valid_existing_name,
maildir_is_valid_create_name,
enum mailbox_open_flags flags)
{
struct mail_storage *storage = *_storage;
+ struct mailbox_list *list = storage->list;
struct mailbox *box;
+ if (list->v.get_storage != NULL) {
+ if (list->v.get_storage(list, name, &storage) < 0)
+ return NULL;
+ *_storage = storage;
+ }
+
mail_storage_clear_error(storage);
- if (!mailbox_list_is_valid_existing_name(storage->list, name)) {
+ if (!mailbox_list_is_valid_existing_name(list, name)) {
mail_storage_set_error(storage, MAIL_ERROR_PARAMS,
"Invalid mailbox name");
return NULL;
if (hook_mailbox_opened != NULL && box != NULL)
hook_mailbox_opened(box);
} T_END;
-
- if (box != NULL)
- *_storage = box->storage;
return box;
}
struct mailbox_list *(*alloc)(void);
void (*deinit)(struct mailbox_list *list);
+ int (*get_storage)(struct mailbox_list *list,
+ const char *name, struct mail_storage **storage_r);
bool (*is_valid_pattern)(struct mailbox_list *list,
const char *pattern);
bool (*is_valid_existing_name)(struct mailbox_list *list,