From: Timo Sirainen Date: Thu, 23 Oct 2008 17:15:16 +0000 (+0300) Subject: Fixed shared mailboxes to work with plugins. X-Git-Tag: 1.2.alpha4~170 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f1743785713e7632459d623d5df2108f4b93accb;p=thirdparty%2Fdovecot%2Fcore.git Fixed shared mailboxes to work with plugins. --HG-- branch : HEAD --- diff --git a/src/lib-storage/index/cydir/cydir-storage.c b/src/lib-storage/index/cydir/cydir-storage.c index 1314cf639c..288dd02b17 100644 --- a/src/lib-storage/index/cydir/cydir-storage.c +++ b/src/lib-storage/index/cydir/cydir-storage.c @@ -68,6 +68,7 @@ static struct mail_storage *cydir_alloc(void) storage = p_new(pool, struct cydir_storage, 1); storage->storage = cydir_storage; storage->storage.pool = pool; + storage->storage.storage_class = &cydir_storage; return &storage->storage; } diff --git a/src/lib-storage/index/dbox/dbox-storage.c b/src/lib-storage/index/dbox/dbox-storage.c index de368a7513..9e3cd40d96 100644 --- a/src/lib-storage/index/dbox/dbox-storage.c +++ b/src/lib-storage/index/dbox/dbox-storage.c @@ -81,6 +81,7 @@ static struct mail_storage *dbox_alloc(void) storage = p_new(pool, struct dbox_storage, 1); storage->storage = dbox_storage; storage->storage.pool = pool; + storage->storage.storage_class = &dbox_storage; return &storage->storage; } diff --git a/src/lib-storage/index/maildir/maildir-storage.c b/src/lib-storage/index/maildir/maildir-storage.c index 8e1de79b2f..09344e4dbe 100644 --- a/src/lib-storage/index/maildir/maildir-storage.c +++ b/src/lib-storage/index/maildir/maildir-storage.c @@ -178,6 +178,7 @@ static struct mail_storage *maildir_alloc(void) storage = p_new(pool, struct maildir_storage, 1); storage->storage = maildir_storage; storage->storage.pool = pool; + storage->storage.storage_class = &maildir_storage; return &storage->storage; } diff --git a/src/lib-storage/index/mbox/mbox-storage.c b/src/lib-storage/index/mbox/mbox-storage.c index 9947c402ca..48d72da757 100644 --- a/src/lib-storage/index/mbox/mbox-storage.c +++ b/src/lib-storage/index/mbox/mbox-storage.c @@ -403,6 +403,7 @@ static struct mail_storage *mbox_alloc(void) storage = p_new(pool, struct mbox_storage, 1); storage->storage = mbox_storage; storage->storage.pool = pool; + storage->storage.storage_class = &mbox_storage; return &storage->storage; } diff --git a/src/lib-storage/index/shared/shared-storage.c b/src/lib-storage/index/shared/shared-storage.c index a61763246e..5e097eacb3 100644 --- a/src/lib-storage/index/shared/shared-storage.c +++ b/src/lib-storage/index/shared/shared-storage.c @@ -24,6 +24,7 @@ static struct mail_storage *shared_alloc(void) storage = p_new(pool, struct shared_storage, 1); storage->storage = shared_storage; storage->storage.pool = pool; + storage->storage.storage_class = &shared_storage; return &storage->storage; } @@ -227,7 +228,10 @@ shared_mailbox_open(struct mail_storage *storage, const char *name, if (shared_storage_get_namespace(storage, &name, &ns) < 0) return NULL; - box = mailbox_open(ns->storage, name, NULL, flags); + /* 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); return box; diff --git a/src/lib-storage/mail-storage-private.h b/src/lib-storage/mail-storage-private.h index 933922bb97..3c31831eb6 100644 --- a/src/lib-storage/mail-storage-private.h +++ b/src/lib-storage/mail-storage-private.h @@ -58,6 +58,7 @@ struct mail_storage { char *error_string; enum mail_error error; + const struct mail_storage *storage_class; struct mail_namespace *ns; struct mailbox_list *list;