]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Moved struct mail_index_* from index_mailbox to mailbox.
authorTimo Sirainen <tss@iki.fi>
Sun, 7 Feb 2010 13:44:33 +0000 (15:44 +0200)
committerTimo Sirainen <tss@iki.fi>
Sun, 7 Feb 2010 13:44:33 +0000 (15:44 +0200)
We're relying more and more of all mailboxes being used via lib-index, and
this change makes accessing the indexes easier.

--HG--
branch : HEAD

50 files changed:
src/lib-storage/index/cydir/cydir-save.c
src/lib-storage/index/cydir/cydir-storage.c
src/lib-storage/index/cydir/cydir-sync.c
src/lib-storage/index/dbox-common/dbox-sync-rebuild.c
src/lib-storage/index/dbox-multi/mdbox-mail.c
src/lib-storage/index/dbox-multi/mdbox-save.c
src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c
src/lib-storage/index/dbox-multi/mdbox-storage.c
src/lib-storage/index/dbox-multi/mdbox-sync.c
src/lib-storage/index/dbox-single/sdbox-mail.c
src/lib-storage/index/dbox-single/sdbox-save.c
src/lib-storage/index/dbox-single/sdbox-storage.c
src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c
src/lib-storage/index/dbox-single/sdbox-sync.c
src/lib-storage/index/index-fetch.c
src/lib-storage/index/index-mail-headers.c
src/lib-storage/index/index-mail.c
src/lib-storage/index/index-search-result.c
src/lib-storage/index/index-search.c
src/lib-storage/index/index-sort-string.c
src/lib-storage/index/index-status.c
src/lib-storage/index/index-storage.c
src/lib-storage/index/index-storage.h
src/lib-storage/index/index-sync-search.c
src/lib-storage/index/index-sync.c
src/lib-storage/index/index-thread.c
src/lib-storage/index/index-transaction.c
src/lib-storage/index/maildir/maildir-copy.c
src/lib-storage/index/maildir/maildir-mail.c
src/lib-storage/index/maildir/maildir-save.c
src/lib-storage/index/maildir/maildir-storage.c
src/lib-storage/index/maildir/maildir-sync-index.c
src/lib-storage/index/maildir/maildir-sync.c
src/lib-storage/index/maildir/maildir-uidlist.c
src/lib-storage/index/maildir/maildir-util.c
src/lib-storage/index/mbox/mbox-lock.c
src/lib-storage/index/mbox/mbox-mail.c
src/lib-storage/index/mbox/mbox-save.c
src/lib-storage/index/mbox/mbox-storage.c
src/lib-storage/index/mbox/mbox-sync-parse.c
src/lib-storage/index/mbox/mbox-sync.c
src/lib-storage/index/raw/raw-storage.c
src/lib-storage/index/raw/raw-sync.c
src/lib-storage/index/test-index-fetch.c
src/lib-storage/mail-storage-private.h
src/lib-storage/mail-storage.c
src/plugins/virtual/virtual-mail.c
src/plugins/virtual/virtual-search.c
src/plugins/virtual/virtual-storage.c
src/plugins/virtual/virtual-sync.c

index e3967c61bea0be8889d62448e1c35b3a1790fe32..8088747efa813a6e91087b97a6446d0008ad2faa 100644 (file)
@@ -85,7 +85,7 @@ int cydir_save_begin(struct mail_save_context *_ctx, struct istream *input)
        enum mail_flags save_flags;
        struct istream *crlf_input;
 
-       if (mail_index_is_deleted(ctx->mbox->ibox.index)) {
+       if (mail_index_is_deleted(trans->box->index)) {
                mailbox_set_deleted(trans->box);
                return -1;
        }
index 5d63d427c6816fba525a67c0445777b19a38a246..0046f2b01db16ed2a5f03f824ebafa44065120cb 100644 (file)
@@ -65,7 +65,7 @@ cydir_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list,
        mbox->ibox.box.pool = pool;
        mbox->ibox.box.storage = storage;
        mbox->ibox.box.list = list;
-       mbox->ibox.mail_vfuncs = &cydir_mail_vfuncs;
+       mbox->ibox.box.mail_vfuncs = &cydir_mail_vfuncs;
 
        mbox->ibox.save_commit_pre = cydir_transaction_save_commit_pre;
        mbox->ibox.save_commit_post = cydir_transaction_save_commit_post;
@@ -73,7 +73,7 @@ cydir_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list,
 
        index_storage_mailbox_alloc(&mbox->ibox, name, input, flags,
                                    CYDIR_INDEX_PREFIX);
-       mail_index_set_fsync_types(mbox->ibox.index,
+       mail_index_set_fsync_types(mbox->ibox.box.index,
                                   MAIL_INDEX_SYNC_TYPE_APPEND |
                                   MAIL_INDEX_SYNC_TYPE_EXPUNGE);
 
index 26f5bf79bff6e3400ad8da446dbaab62be0322be..c395f2ba91b8113cc5904115ec09b3e3aab48c96 100644 (file)
@@ -122,12 +122,12 @@ int cydir_sync_begin(struct cydir_mailbox *mbox,
        if (!force)
                sync_flags |= MAIL_INDEX_SYNC_FLAG_REQUIRE_CHANGES;
 
-       ret = mail_index_sync_begin(mbox->ibox.index, &ctx->index_sync_ctx,
+       ret = mail_index_sync_begin(mbox->ibox.box.index, &ctx->index_sync_ctx,
                                    &ctx->sync_view, &ctx->trans,
                                    sync_flags);
        if (ret <= 0) {
                if (ret < 0)
-                       mail_storage_set_index_error(&mbox->ibox);
+                       mail_storage_set_index_error(&mbox->ibox.box);
                i_free(ctx);
                *ctx_r = NULL;
                return ret;
@@ -146,7 +146,7 @@ int cydir_sync_finish(struct cydir_sync_context **_ctx, bool success)
        *_ctx = NULL;
        if (success) {
                if (mail_index_sync_commit(&ctx->index_sync_ctx) < 0) {
-                       mail_storage_set_index_error(&ctx->mbox->ibox);
+                       mail_storage_set_index_error(&ctx->mbox->ibox.box);
                        ret = -1;
                }
        } else {
index f7059fa176e3f6a1404ec196739a5f089057ad96..f79de03e34e51a00a49472d084e47a88df4905d8 100644 (file)
@@ -99,7 +99,7 @@ dbox_sync_index_rebuild_init(struct index_mailbox *ibox,
        ctx->trans = trans;
        mail_index_reset(ctx->trans);
        index_mailbox_reset_uidvalidity(ibox);
-       mail_index_ext_lookup(ibox->index, "cache", &ctx->cache_ext_id);
+       mail_index_ext_lookup(box->index, "cache", &ctx->cache_ext_id);
 
        /* if backup index file exists, try to use it */
        index_dir = mailbox_list_get_path(box->list, box->name,
index 6151356d34deb4017316bba82052a23a347a1643..668d094a3f77cd69b0a23d7858befc3a2db72251 100644 (file)
@@ -61,8 +61,8 @@ static void dbox_mail_set_expunged(struct dbox_mail *mail, uint32_t map_uid)
        struct mdbox_mailbox *mbox = (struct mdbox_mailbox *)mail->imail.ibox;
        struct mail *_mail = &mail->imail.mail.mail;
 
-       (void)mail_index_refresh(mbox->ibox.index);
-       if (mail_index_is_expunged(mbox->ibox.view, _mail->seq)) {
+       (void)mail_index_refresh(_mail->box->index);
+       if (mail_index_is_expunged(_mail->box->view, _mail->seq)) {
                mail_set_expunged(_mail);
                return;
        }
@@ -112,8 +112,8 @@ int mdbox_mail_open(struct dbox_mail *mail, uoff_t *offset_r,
                if (mail->open_file != NULL) {
                        /* already open */
                } else if (_mail->uid != 0) {
-                       if (mdbox_mail_lookup(mbox, mbox->ibox.view, _mail->seq,
-                                             &map_uid) < 0)
+                       if (mdbox_mail_lookup(mbox, _mail->box->view,
+                                             _mail->seq, &map_uid) < 0)
                                return -1;
                        if (dbox_mail_open_init(mail, map_uid) < 0)
                                return -1;
@@ -160,7 +160,7 @@ static int mdbox_mail_get_save_date(struct mail *mail, time_t *date_r)
        const void *data;
        bool expunged;
 
-       mail_index_lookup_ext(mbox->ibox.view, mail->seq,
+       mail_index_lookup_ext(mail->box->view, mail->seq,
                              mbox->ext_id, &data, &expunged);
        dbox_rec = data;
        if (dbox_rec == NULL || dbox_rec->map_uid == 0) {
index 9a6ca987029c92d78691a42d6532eb4a73d4126f..0c9fdd8e68613d6bbc748277b23809fdf59bfa36 100644 (file)
@@ -97,7 +97,7 @@ int mdbox_save_begin(struct mail_save_context *_ctx, struct istream *input)
        struct dbox_save_mail *save_mail;
        uoff_t mail_size, append_offset;
 
-       if (mail_index_is_deleted(ctx->mbox->ibox.index)) {
+       if (mail_index_is_deleted(_ctx->transaction->box->index)) {
                mailbox_set_deleted(_ctx->transaction->box);
                return -1;
        }
@@ -344,7 +344,7 @@ int mdbox_copy(struct mail_save_context *_ctx, struct mail *mail)
 
        memset(&rec, 0, sizeof(rec));
        rec.save_date = ioloop_time;
-       if (mdbox_mail_lookup(src_mbox, src_mbox->ibox.view, mail->seq,
+       if (mdbox_mail_lookup(src_mbox, mail->box->view, mail->seq,
                              &rec.map_uid) < 0)
                return -1;
 
@@ -358,7 +358,7 @@ int mdbox_copy(struct mail_save_context *_ctx, struct mail *mail)
        mail_index_update_ext(ctx->ctx.trans, ctx->ctx.seq,
                              ctx->mbox->ext_id, &rec, NULL);
 
-       mail_index_lookup_ext(src_mbox->ibox.view, mail->seq,
+       mail_index_lookup_ext(mail->box->view, mail->seq,
                              src_mbox->guid_ext_id, &data, &expunged);
        if (data != NULL) {
                mail_index_update_ext(ctx->ctx.trans, ctx->ctx.seq,
index 634053eba650a6b70013c5a4f51959cd1af3e16d..c83da17b87dc6f54521a9872f43890dedeb74ec3 100644 (file)
@@ -420,11 +420,11 @@ rebuild_mailbox(struct mdbox_storage_rebuild_context *ctx,
        }
        mbox = (struct mdbox_mailbox *)box;
 
-       ret = mail_index_sync_begin(mbox->ibox.index, &sync_ctx, &view, &trans,
+       ret = mail_index_sync_begin(box->index, &sync_ctx, &view, &trans,
                                    MAIL_INDEX_SYNC_FLAG_AVOID_FLAG_UPDATES);
        if (ret <= 0) {
                i_assert(ret != 0);
-               mail_storage_set_index_error(&mbox->ibox);
+               mail_storage_set_index_error(box);
                mailbox_close(&box);
                return -1;
        }
@@ -434,7 +434,7 @@ rebuild_mailbox(struct mdbox_storage_rebuild_context *ctx,
        dbox_sync_index_rebuild_deinit(&rebuild_ctx);
 
        if (mail_index_sync_commit(&sync_ctx) < 0) {
-               mail_storage_set_index_error(&mbox->ibox);
+               mail_storage_set_index_error(box);
                ret = -1;
        }
 
@@ -580,13 +580,13 @@ static int rebuild_restore_msg(struct mdbox_storage_rebuild_context *ctx,
                        return -1;
        }
        if (ctx->prev_msg.box == NULL) {
-               ret = mail_index_sync_begin(mbox->ibox.index,
+               ret = mail_index_sync_begin(box->index,
                                            &ctx->prev_msg.sync_ctx,
                                            &ctx->prev_msg.view,
                                            &ctx->prev_msg.trans, 0);
                if (ret <= 0) {
                        i_assert(ret != 0);
-                       mail_storage_set_index_error(&mbox->ibox);
+                       mail_storage_set_index_error(box);
                        mailbox_close(&box);
                        return -1;
                }
index fba15c34841be4adde79fc28a4d05d63929be948..3e0f4259805d0fb71bbf5ea32ebc9f7ad3a5b5c2 100644 (file)
@@ -116,7 +116,7 @@ mdbox_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list,
        mbox->ibox.box.pool = pool;
        mbox->ibox.box.storage = storage;
        mbox->ibox.box.list = list;
-       mbox->ibox.mail_vfuncs = &mdbox_mail_vfuncs;
+       mbox->ibox.box.mail_vfuncs = &mdbox_mail_vfuncs;
 
        mbox->ibox.save_commit_pre = mdbox_transaction_save_commit_pre;
        mbox->ibox.save_commit_post = mdbox_transaction_save_commit_post;
@@ -124,7 +124,7 @@ mdbox_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list,
 
        index_storage_mailbox_alloc(&mbox->ibox, name, input, flags,
                                    DBOX_INDEX_PREFIX);
-       mail_index_set_fsync_types(mbox->ibox.index,
+       mail_index_set_fsync_types(mbox->ibox.box.index,
                                   MAIL_INDEX_SYNC_TYPE_APPEND |
                                   MAIL_INDEX_SYNC_TYPE_EXPUNGE);
 
@@ -133,14 +133,14 @@ mdbox_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list,
 
        mbox->storage = (struct mdbox_storage *)storage;
        mbox->ext_id =
-               mail_index_ext_register(mbox->ibox.index, "mdbox", 0,
+               mail_index_ext_register(mbox->ibox.box.index, "mdbox", 0,
                                        sizeof(struct mdbox_mail_index_record),
                                        sizeof(uint32_t));
        mbox->hdr_ext_id =
-               mail_index_ext_register(mbox->ibox.index, "mdbox-hdr",
+               mail_index_ext_register(mbox->ibox.box.index, "mdbox-hdr",
                                        sizeof(struct mdbox_index_header), 0, 0);
        mbox->guid_ext_id =
-               mail_index_ext_register(mbox->ibox.index, "guid",
+               mail_index_ext_register(mbox->ibox.box.index, "guid",
                                        0, MAIL_GUID_128_SIZE, 1);
        return &mbox->ibox.box;
 }
@@ -151,7 +151,7 @@ int mdbox_read_header(struct mdbox_mailbox *mbox,
        const void *data;
        size_t data_size;
 
-       mail_index_get_header_ext(mbox->ibox.view, mbox->hdr_ext_id,
+       mail_index_get_header_ext(mbox->ibox.box.view, mbox->hdr_ext_id,
                                  &data, &data_size);
        if (data_size < MDBOX_INDEX_HEADER_MIN_SIZE &&
            (!mbox->creating || data_size != 0)) {
@@ -202,8 +202,8 @@ static int mdbox_write_index_header(struct mailbox *box,
        if (dbox_map_open(mbox->storage->map, TRUE) < 0)
                return -1;
 
-       hdr = mail_index_get_header(mbox->ibox.view);
-       trans = mail_index_transaction_begin(mbox->ibox.view, 0);
+       hdr = mail_index_get_header(box->view);
+       trans = mail_index_transaction_begin(box->view, 0);
        mdbox_update_header(mbox, trans, update);
 
        uid_validity = hdr->uid_validity;
@@ -226,7 +226,7 @@ static int mdbox_write_index_header(struct mailbox *box,
                        &uid_next, sizeof(uid_next), TRUE);
        }
        if (update != NULL && update->min_highest_modseq != 0 &&
-           mail_index_modseq_get_highest(mbox->ibox.view) <
+           mail_index_modseq_get_highest(box->view) <
                                                update->min_highest_modseq) {
                mail_index_update_highest_modseq(trans,
                                                 update->min_highest_modseq);
@@ -234,7 +234,7 @@ static int mdbox_write_index_header(struct mailbox *box,
 
        if (mail_index_transaction_commit(&trans) < 0) {
                mail_storage_set_internal_error(box->storage);
-               mail_index_reset_error(mbox->ibox.index);
+               mail_index_reset_error(box->index);
                return -1;
        }
        return 0;
@@ -326,9 +326,9 @@ mdbox_mailbox_unref_mails(struct mailbox_list *list, const char *path)
 
        /* get a list of all map_uids in this mailbox */
        i_array_init(&map_uids, 128);
-       hdr = mail_index_get_header(mbox->ibox.view);
+       hdr = mail_index_get_header(box->view);
        for (seq = 1; seq <= hdr->messages_count; seq++) {
-               mail_index_lookup_ext(mbox->ibox.view, seq, mbox->ext_id,
+               mail_index_lookup_ext(box->view, seq, mbox->ext_id,
                                      &data, &expunged);
                dbox_rec = data;
                if (dbox_rec == NULL) {
index ed6c39bdada9fd9a4d1e926260768b772c936886..94fb61dcdbfa6a91c39bfbb1805782f0869a6fc8 100644 (file)
@@ -167,14 +167,14 @@ static int mdbox_refresh_header(struct mdbox_mailbox *mbox, bool retry)
        struct mdbox_index_header hdr;
        int ret;
 
-       view = mail_index_view_open(mbox->ibox.index);
+       view = mail_index_view_open(mbox->ibox.box.index);
        ret = mdbox_read_header(mbox, &hdr);
        mail_index_view_close(&view);
 
        if (ret == 0) {
                ret = mbox->storage->storage.files_corrupted ? -1 : 0;
        } else if (retry) {
-               (void)mail_index_refresh(mbox->ibox.index);
+               (void)mail_index_refresh(mbox->ibox.box.index);
                return mdbox_refresh_header(mbox, FALSE);
        }
        return ret;
@@ -213,13 +213,13 @@ int mdbox_sync_begin(struct mdbox_mailbox *mbox, enum mdbox_sync_flags flags,
        sync_flags |= MAIL_INDEX_SYNC_FLAG_AVOID_FLAG_UPDATES;
 
        for (i = 0;; i++) {
-               ret = mail_index_sync_begin(mbox->ibox.index,
+               ret = mail_index_sync_begin(mbox->ibox.box.index,
                                            &ctx->index_sync_ctx,
                                            &ctx->sync_view, &ctx->trans,
                                            sync_flags);
                if (ret <= 0) {
                        if (ret < 0)
-                               mail_storage_set_index_error(&mbox->ibox);
+                               mail_storage_set_index_error(&mbox->ibox.box);
                        i_free(ctx);
                        *ctx_r = NULL;
                        return ret;
@@ -269,7 +269,7 @@ int mdbox_sync_finish(struct mdbox_sync_context **_ctx, bool success)
 
        if (success) {
                if (mail_index_sync_commit(&ctx->index_sync_ctx) < 0) {
-                       mail_storage_set_index_error(&ctx->mbox->ibox);
+                       mail_storage_set_index_error(&ctx->mbox->ibox.box);
                        ret = -1;
                }
        } else {
index 9e404797ac1997b17e55b3264b8dcdfe43b673d2..a337cdb7764c0b9ca8fdfcbab0ff59bf7dcd9b2b 100644 (file)
@@ -17,8 +17,8 @@ static void sdbox_mail_set_expunged(struct dbox_mail *mail)
        struct sdbox_mailbox *mbox = (struct sdbox_mailbox *)mail->imail.ibox;
        struct mail *_mail = &mail->imail.mail.mail;
 
-       (void)mail_index_refresh(mbox->ibox.index);
-       if (mail_index_is_expunged(mbox->ibox.view, _mail->seq)) {
+       (void)mail_index_refresh(_mail->box->index);
+       if (mail_index_is_expunged(_mail->box->view, _mail->seq)) {
                mail_set_expunged(_mail);
                return;
        }
index 0ddfe64a31821fbd13e55b5dfd23c490e24c6a7d..c2073836a7488fdefa77591e3856465ab05b61d5 100644 (file)
@@ -78,7 +78,7 @@ int sdbox_save_begin(struct mail_save_context *_ctx, struct istream *input)
        struct dbox_file *file;
        int ret;
 
-       if (mail_index_is_deleted(ctx->mbox->ibox.index)) {
+       if (mail_index_is_deleted(_ctx->transaction->box->index)) {
                mailbox_set_deleted(_ctx->transaction->box);
                return -1;
        }
index 17742c93e6fb46de775246e2fc07bc5ca5a602b3..5222d1e1007c2f43130d5e2fab78470184d37022 100644 (file)
@@ -65,7 +65,7 @@ sdbox_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list,
        mbox->ibox.box.pool = pool;
        mbox->ibox.box.storage = storage;
        mbox->ibox.box.list = list;
-       mbox->ibox.mail_vfuncs = &sdbox_mail_vfuncs;
+       mbox->ibox.box.mail_vfuncs = &sdbox_mail_vfuncs;
 
        mbox->ibox.save_commit_pre = sdbox_transaction_save_commit_pre;
        mbox->ibox.save_commit_post = sdbox_transaction_save_commit_post;
@@ -73,7 +73,7 @@ sdbox_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list,
 
        index_storage_mailbox_alloc(&mbox->ibox, name, input, flags,
                                    DBOX_INDEX_PREFIX);
-       mail_index_set_fsync_types(mbox->ibox.index,
+       mail_index_set_fsync_types(mbox->ibox.box.index,
                                   MAIL_INDEX_SYNC_TYPE_APPEND |
                                   MAIL_INDEX_SYNC_TYPE_EXPUNGE);
 
@@ -85,7 +85,7 @@ sdbox_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list,
                p_strconcat(pool, list->set.alt_dir, "/",
                            list->set.maildir_name, NULL);
        mbox->hdr_ext_id =
-               mail_index_ext_register(mbox->ibox.index, "dbox-hdr",
+               mail_index_ext_register(mbox->ibox.box.index, "dbox-hdr",
                                        sizeof(struct sdbox_index_header), 0, 0);
        return &mbox->ibox.box;
 }
@@ -96,7 +96,7 @@ int sdbox_read_header(struct sdbox_mailbox *mbox,
        const void *data;
        size_t data_size;
 
-       mail_index_get_header_ext(mbox->ibox.view, mbox->hdr_ext_id,
+       mail_index_get_header_ext(mbox->ibox.box.view, mbox->hdr_ext_id,
                                  &data, &data_size);
        if (data_size < SDBOX_INDEX_HEADER_MIN_SIZE &&
            (!mbox->creating || data_size != 0)) {
@@ -142,8 +142,8 @@ static int sdbox_write_index_header(struct mailbox *box,
        const struct mail_index_header *hdr;
        uint32_t uid_validity, uid_next;
 
-       hdr = mail_index_get_header(mbox->ibox.view);
-       trans = mail_index_transaction_begin(mbox->ibox.view, 0);
+       hdr = mail_index_get_header(box->view);
+       trans = mail_index_transaction_begin(box->view, 0);
        sdbox_update_header(mbox, trans, update);
 
        if (update != NULL && update->uid_validity != 0)
@@ -165,7 +165,7 @@ static int sdbox_write_index_header(struct mailbox *box,
                        &uid_next, sizeof(uid_next), TRUE);
        }
        if (update != NULL && update->min_highest_modseq != 0 &&
-           mail_index_modseq_get_highest(mbox->ibox.view) <
+           mail_index_modseq_get_highest(box->view) <
                                                update->min_highest_modseq) {
                mail_index_update_highest_modseq(trans,
                                                 update->min_highest_modseq);
@@ -173,7 +173,7 @@ static int sdbox_write_index_header(struct mailbox *box,
 
        if (mail_index_transaction_commit(&trans) < 0) {
                mail_storage_set_internal_error(box->storage);
-               mail_index_reset_error(mbox->ibox.index);
+               mail_index_reset_error(box->index);
                return -1;
        }
        return 0;
index 8fbc34abf5bffa1e4145f0e21ae16ec1c50d1743..33e22a88f56752573528fa19910418246677ea2a 100644 (file)
@@ -162,7 +162,7 @@ int sdbox_sync_index_rebuild(struct sdbox_mailbox *mbox)
        struct mail_index_transaction *trans;
        int ret;
 
-       view = mail_index_view_open(mbox->ibox.index);
+       view = mail_index_view_open(mbox->ibox.box.index);
        trans = mail_index_transaction_begin(view,
                                        MAIL_INDEX_TRANSACTION_FLAG_EXTERNAL);
 
index 7bb38bb26ed14b36c4d0911de5e149f630d4b439..3498706a2f1c49b1e73f008d94393f46499f69f9 100644 (file)
@@ -148,14 +148,14 @@ static int sdbox_refresh_header(struct sdbox_mailbox *mbox, bool retry)
        struct sdbox_index_header hdr;
        int ret;
 
-       view = mail_index_view_open(mbox->ibox.index);
+       view = mail_index_view_open(mbox->ibox.box.index);
        ret = sdbox_read_header(mbox, &hdr);
        mail_index_view_close(&view);
 
        if (ret == 0) {
                ret = mbox->sync_rebuild ? -1 : 0;
        } else if (retry) {
-               (void)mail_index_refresh(mbox->ibox.index);
+               (void)mail_index_refresh(mbox->ibox.box.index);
                return sdbox_refresh_header(mbox, FALSE);
        }
        return ret;
@@ -188,13 +188,13 @@ int sdbox_sync_begin(struct sdbox_mailbox *mbox, enum sdbox_sync_flags flags,
        sync_flags |= MAIL_INDEX_SYNC_FLAG_AVOID_FLAG_UPDATES;
 
        for (i = 0;; i++) {
-               ret = mail_index_sync_begin(mbox->ibox.index,
+               ret = mail_index_sync_begin(mbox->ibox.box.index,
                                            &ctx->index_sync_ctx,
                                            &ctx->sync_view, &ctx->trans,
                                            sync_flags);
                if (ret <= 0) {
                        if (ret < 0)
-                               mail_storage_set_index_error(&mbox->ibox);
+                               mail_storage_set_index_error(&mbox->ibox.box);
                        i_free(ctx);
                        *ctx_r = NULL;
                        return ret;
@@ -243,7 +243,7 @@ int sdbox_sync_finish(struct sdbox_sync_context **_ctx, bool success)
 
        if (success) {
                if (mail_index_sync_commit(&ctx->index_sync_ctx) < 0) {
-                       mail_storage_set_index_error(&ctx->mbox->ibox);
+                       mail_storage_set_index_error(&ctx->mbox->ibox.box);
                        ret = -1;
                }
        } else {
index 736269ba91fec2171d401eff1a871a342045e710..9191477975d7d038f8c9d68c34468b5136efebb2 100644 (file)
@@ -10,16 +10,13 @@ void index_storage_get_seq_range(struct mailbox *box,
                                 uint32_t uid1, uint32_t uid2,
                                 uint32_t *seq1_r, uint32_t *seq2_r)
 {
-       struct index_mailbox *ibox = (struct index_mailbox *)box;
-
-       mail_index_lookup_seq_range(ibox->view, uid1, uid2, seq1_r, seq2_r);
+       mail_index_lookup_seq_range(box->view, uid1, uid2, seq1_r, seq2_r);
 }
 
 void index_storage_get_uid_range(struct mailbox *box,
                                 const ARRAY_TYPE(seq_range) *seqs,
                                 ARRAY_TYPE(seq_range) *uids)
 {
-       struct index_mailbox *ibox = (struct index_mailbox *)box;
        const struct seq_range *range;
        unsigned int i, count;
        uint32_t seq, uid;
@@ -28,12 +25,12 @@ void index_storage_get_uid_range(struct mailbox *box,
        for (i = 0; i < count; i++) {
                if (range[i].seq2 == (uint32_t)-1) {
                        i_assert(count == i-1);
-                       mail_index_lookup_uid(ibox->view, range[i].seq1, &uid);
+                       mail_index_lookup_uid(box->view, range[i].seq1, &uid);
                        seq_range_array_add_range(uids, uid, (uint32_t)-1);
                        break;
                }
                for (seq = range[i].seq1; seq <= range[i].seq2; seq++) {
-                       mail_index_lookup_uid(ibox->view, seq, &uid);
+                       mail_index_lookup_uid(box->view, seq, &uid);
                        seq_range_array_add(uids, 0, uid);
                }
        }
@@ -82,7 +79,6 @@ bool index_storage_get_expunges(struct mailbox *box, uint64_t prev_modseq,
                                const ARRAY_TYPE(seq_range) *uids_filter,
                                ARRAY_TYPE(mailbox_expunge_rec) *expunges)
 {
-       struct index_mailbox *ibox = (struct index_mailbox *)box;
        struct mail_transaction_log_view *log_view;
        const struct mail_transaction_header *thdr;
        const void *tdata;
@@ -91,27 +87,27 @@ bool index_storage_get_expunges(struct mailbox *box, uint64_t prev_modseq,
        bool reset;
        int ret;
 
-       if (!mail_index_modseq_get_next_log_offset(ibox->view, prev_modseq,
+       if (!mail_index_modseq_get_next_log_offset(box->view, prev_modseq,
                                                   &log_seq, &log_offset))
                return FALSE;
-       if (log_seq > ibox->view->log_file_head_seq ||
-           (log_seq == ibox->view->log_file_head_seq &&
-            log_offset >= ibox->view->log_file_head_offset)) {
+       if (log_seq > box->view->log_file_head_seq ||
+           (log_seq == box->view->log_file_head_seq &&
+            log_offset >= box->view->log_file_head_offset)) {
                /* we haven't seen this high expunges at all */
                return TRUE;
        }
 
-       log_view = mail_transaction_log_view_open(ibox->index->log);
+       log_view = mail_transaction_log_view_open(box->index->log);
        ret = mail_transaction_log_view_set(log_view, log_seq, log_offset,
-                                           ibox->view->log_file_head_seq,
-                                           ibox->view->log_file_head_offset,
+                                           box->view->log_file_head_seq,
+                                           box->view->log_file_head_offset,
                                            &reset);
        if (ret == 0) {
-               mail_transaction_log_get_tail(ibox->index->log, &tail_seq);
+               mail_transaction_log_get_tail(box->index->log, &tail_seq);
                i_assert(tail_seq > log_seq);
                ret = mail_transaction_log_view_set(log_view, tail_seq, 0,
-                                       ibox->view->log_file_head_seq,
-                                       ibox->view->log_file_head_offset,
+                                       box->view->log_file_head_seq,
+                                       box->view->log_file_head_offset,
                                        &reset);
                i_assert(ret != 0);
        }
index 94a0b35c929c5d37f617f259293ec80b4b35057e..0215a80af8d45e901e1dfd11a047316f50670fd0 100644 (file)
@@ -146,7 +146,7 @@ static void index_mail_parse_header_finish(struct index_mail *mail)
 }
 
 static unsigned int
-get_header_field_idx(struct index_mailbox *ibox, const char *field,
+get_header_field_idx(struct mailbox *box, const char *field,
                     enum mail_cache_decision_type decision)
 {
        struct mail_cache_field header_field = {
@@ -157,7 +157,7 @@ get_header_field_idx(struct index_mailbox *ibox, const char *field,
        header_field.decision = decision;
        T_BEGIN {
                header_field.name = t_strconcat("hdr.", field, NULL);
-               mail_cache_register_fields(ibox->cache, &header_field, 1);
+               mail_cache_register_fields(box->cache, &header_field, 1);
        } T_END;
        return header_field.idx;
 }
@@ -180,7 +180,7 @@ static void index_mail_parse_header_register_all_wanted(struct index_mail *mail)
        unsigned int i, count;
 
        all_cache_fields =
-               mail_cache_register_get_list(mail->ibox->cache,
+               mail_cache_register_get_list(mail->ibox->box.cache,
                                             pool_datastack_create(), &count);
        for (i = 0; i < count; i++) {
                if (strncasecmp(all_cache_fields[i].name, "hdr.", 4) != 0)
@@ -248,7 +248,7 @@ void index_mail_parse_header_init(struct index_mail *mail,
           Date: header. if we have Date field's index set at this point we
           know that we want it. otherwise add it and remember that we don't
           want it cached. */
-       field_idx = get_header_field_idx(mail->ibox, "Date",
+       field_idx = get_header_field_idx(&mail->ibox->box, "Date",
                                         MAIL_CACHE_DECISION_NO);
        match = array_get(&mail->header_match, &match_count);
        if (field_idx < match_count &&
@@ -319,7 +319,7 @@ void index_mail_parse_header(struct message_part *part,
                        const char *cache_field_name =
                                t_strconcat("hdr.", hdr->name, NULL);
                        data->parse_line.field_idx =
-                               mail_cache_register_lookup(mail->ibox->cache,
+                               mail_cache_register_lookup(mail->ibox->box.cache,
                                                           cache_field_name);
                } T_END;
        }
@@ -606,7 +606,7 @@ index_mail_get_raw_headers(struct index_mail *mail, const char *field,
 
        i_assert(field != NULL);
 
-       field_idx = get_header_field_idx(mail->ibox, field,
+       field_idx = get_header_field_idx(&mail->ibox->box, field,
                                         MAIL_CACHE_DECISION_TEMP);
 
        dest = str_new(mail->data_pool, 128);
@@ -751,7 +751,7 @@ int index_mail_get_headers(struct mail *_mail, const char *field,
                } T_END;
 
                if (ret < 0) {
-                       mail_cache_set_corrupted(mail->ibox->cache,
+                       mail_cache_set_corrupted(_mail->box->cache,
                                "Broken header %s for mail UID %u",
                                field, _mail->uid);
                }
@@ -779,7 +779,7 @@ int index_mail_get_first_header(struct mail *_mail, const char *field,
                } T_END;
 
                if (ret < 0) {
-                       mail_cache_set_corrupted(mail->ibox->cache,
+                       mail_cache_set_corrupted(_mail->box->cache,
                                "Broken header %s for mail UID %u",
                                field, _mail->uid);
                }
@@ -851,7 +851,6 @@ int index_mail_get_header_stream(struct mail *_mail,
 static struct mailbox_header_lookup_ctx *
 index_header_lookup_init_real(struct mailbox *box, const char *const headers[])
 {
-       struct index_mailbox *ibox = (struct index_mailbox *)box;
        struct mail_cache_field *fields, header_field = {
                NULL, 0, MAIL_CACHE_FIELD_HEADER, 0,
                MAIL_CACHE_DECISION_TEMP
@@ -879,7 +878,7 @@ index_header_lookup_init_real(struct mailbox *box, const char *const headers[])
                header_field.name = t_strconcat("hdr.", headers[i], NULL);
                fields[i] = header_field;
        }
-       mail_cache_register_fields(ibox->cache, fields, count);
+       mail_cache_register_fields(box->cache, fields, count);
 
        pool = pool_alloconly_create("index_header_lookup_ctx", 1024);
        ctx = p_new(pool, struct index_header_lookup_ctx, 1);
index 06c1bc1c3b9dbd3b3b23ca11b722be4732523f1f..6512233fe9feae02fb5767cea2af87b6bca4a4ca 100644 (file)
@@ -69,7 +69,7 @@ static struct message_part *get_unserialized_parts(struct index_mail *mail)
        parts = message_part_deserialize(mail->data_pool, part_buf->data,
                                         part_buf->used, &error);
        if (parts == NULL) {
-               mail_cache_set_corrupted(mail->ibox->cache,
+               mail_cache_set_corrupted(mail->ibox->box.cache,
                        "Corrupted cached message_part data (%s)", error);
        }
        return parts;
@@ -147,7 +147,7 @@ uint64_t index_mail_get_modseq(struct mail *_mail)
        if (mail->data.modseq != 0)
                return mail->data.modseq;
 
-       mail_index_modseq_enable(mail->ibox->index);
+       mail_index_modseq_enable(_mail->box->index);
        mail->data.modseq =
                mail_index_modseq_lookup(mail->trans->trans_view, _mail->seq);
        return mail->data.modseq;
@@ -429,7 +429,7 @@ void index_mail_cache_add_idx(struct index_mail *mail, unsigned int field_idx,
        if (set->mail_cache_min_mail_count > 0) {
                /* First check if we've configured caching not to be used with
                   low enough message count. */
-               hdr = mail_index_get_header(mail->ibox->view);
+               hdr = mail_index_get_header(mail->ibox->box.view);
                if (hdr->messages_count < set->mail_cache_min_mail_count)
                        return;
        }
@@ -527,7 +527,7 @@ static void index_mail_body_parsed_cache_message_parts(struct index_mail *mail)
                return;
        }
 
-       decision = mail_cache_field_get_decision(mail->ibox->cache,
+       decision = mail_cache_field_get_decision(mail->ibox->box.cache,
                                                 cache_field);
        if (decision == (MAIL_CACHE_DECISION_NO | MAIL_CACHE_DECISION_FORCED)) {
                /* we never want it cached */
@@ -611,7 +611,7 @@ index_mail_body_parsed_cache_bodystructure(struct index_mail *mail,
 
        /* normally don't cache both BODY and BODYSTRUCTURE, but do it
           if BODY is forced to be cached */
-       dec = mail_cache_field_get_decision(mail->ibox->cache,
+       dec = mail_cache_field_get_decision(mail->ibox->box.cache,
                                            cache_field_body);
        if (plain_bodystructure ||
            (bodystructure_cached &&
@@ -1090,13 +1090,13 @@ void index_mail_init(struct index_mail *mail,
        array_create(&mail->mail.module_contexts, mail->mail.pool,
                     sizeof(void *), 5);
 
-       mail->mail.v = *ibox->mail_vfuncs;
+       mail->mail.v = *ibox->box.mail_vfuncs;
        mail->mail.mail.box = &ibox->box;
        mail->mail.mail.transaction = &t->mailbox_ctx;
        mail->mail.wanted_fields = wanted_fields;
        mail->mail.wanted_headers = _wanted_headers;
 
-       hdr = mail_index_get_header(ibox->view);
+       hdr = mail_index_get_header(ibox->box.view);
        mail->uid_validity = hdr->uid_validity;
 
        t->mail_ref_count++;
@@ -1183,7 +1183,7 @@ static void check_envelope(struct index_mail *mail)
        /* don't waste time doing full checks for all required
           headers. assume that if we have "hdr.message-id" cached,
           we don't need to parse the header. */
-       cache_field_hdr = mail_cache_register_lookup(mail->ibox->cache,
+       cache_field_hdr = mail_cache_register_lookup(mail->ibox->box.cache,
                                                     "hdr.message-id");
        if (cache_field_hdr == (unsigned int)-1 ||
            mail_cache_field_exists(mail->trans->cache_view,
@@ -1307,7 +1307,7 @@ void index_mail_set_seq(struct mail *_mail, uint32_t seq)
 
                /* open the stream only if we didn't get here from
                   mailbox_save_init() */
-               hdr = mail_index_get_header(mail->ibox->view);
+               hdr = mail_index_get_header(mail->ibox->box.view);
                if (_mail->uid != 0 && _mail->uid < hdr->next_uid)
                        (void)mail_get_stream(_mail, NULL, NULL, &input);
        }
@@ -1318,7 +1318,7 @@ bool index_mail_set_uid(struct mail *_mail, uint32_t uid)
        struct index_mail *mail = (struct index_mail *)_mail;
        uint32_t seq;
 
-       if (mail_index_lookup_seq(mail->ibox->view, uid, &seq)) {
+       if (mail_index_lookup_seq(_mail->box->view, uid, &seq)) {
                index_mail_set_seq(_mail, seq);
                return TRUE;
        } else {
@@ -1528,7 +1528,7 @@ void index_mail_set_cache_corrupted(struct mail *mail,
        mail_cache_transaction_reset(imail->trans->cache_trans);
        imail->data.no_caching = TRUE;
        imail->data.forced_no_caching = TRUE;
-       mail_cache_set_corrupted(imail->ibox->cache,
+       mail_cache_set_corrupted(mail->box->cache,
                                 "Broken %s for mail UID %u",
                                 field_name, mail->uid);
 }
index f65c0de9122f983370e0fcba9f036fae15c952f1..abb67d0d74b8b77ebcaf65c31ec26056dcb71479 100644 (file)
@@ -139,7 +139,6 @@ int index_search_result_update_flags(struct mail_search_result *result,
 int index_search_result_update_appends(struct mail_search_result *result,
                                       unsigned int old_messages_count)
 {
-       struct index_mailbox *ibox = (struct index_mailbox *)result->box;
        struct mailbox_transaction_context *t;
        struct mail_search_context *search_ctx;
        struct mail *mail;
@@ -147,7 +146,7 @@ int index_search_result_update_appends(struct mail_search_result *result,
        uint32_t message_count;
        int ret;
 
-       message_count = mail_index_view_get_messages_count(ibox->view);
+       message_count = mail_index_view_get_messages_count(result->box->view);
        if (old_messages_count == message_count) {
                /* no new messages */
                return 0;
@@ -184,7 +183,6 @@ int index_search_result_update_appends(struct mail_search_result *result,
 void index_search_results_update_expunges(struct mailbox *box,
                                          const ARRAY_TYPE(seq_range) *expunges)
 {
-       struct index_mailbox *ibox = (struct index_mailbox *)box;
        const struct seq_range *seqs;
        uint32_t seq, uid;
 
@@ -193,7 +191,7 @@ void index_search_results_update_expunges(struct mailbox *box,
 
        array_foreach(expunges, seqs) {
                for (seq = seqs->seq1; seq <= seqs->seq2; seq++) {
-                       mail_index_lookup_uid(ibox->view, seq, &uid);
+                       mail_index_lookup_uid(box->view, seq, &uid);
                        mailbox_search_results_remove(box, uid);
                }
        }
index 37e1c95a98966a76e05b8b6614e8e21014f1ed64..f8a3ae215c69166f7049151a59072e9e13e4b81a 100644 (file)
@@ -96,7 +96,7 @@ static void search_init_arg(struct mail_search_arg *arg,
        case SEARCH_KEYWORDS:
        case SEARCH_MODSEQ:
                if (arg->type == SEARCH_MODSEQ)
-                       mail_index_modseq_enable(ctx->ibox->index);
+                       mail_index_modseq_enable(ctx->ibox->box.index);
                ctx->have_index_args = TRUE;
                break;
        case SEARCH_ALL:
index 6159b9248b74e3c66c77be571419eb8d597e2b3d..e358a589d5bede2b1f83ddcf55d222fde3972f47 100644 (file)
@@ -54,7 +54,6 @@ static void index_sort_node_add(struct sort_string_context *ctx,
 
 void index_sort_list_init_string(struct mail_search_sort_program *program)
 {
-       struct index_mailbox *ibox = (struct index_mailbox *)program->t->box;
        struct sort_string_context *ctx;
        const char *name;
 
@@ -85,7 +84,7 @@ void index_sort_list_init_string(struct mail_search_sort_program *program)
        ctx->reverse = (program->sort_program[0] & MAIL_SORT_FLAG_REVERSE) != 0;
        ctx->program = program;
        ctx->primary_sort_name = name;
-       ctx->ext_id = mail_index_ext_register(ibox->index, name, 0,
+       ctx->ext_id = mail_index_ext_register(program->t->box->index, name, 0,
                                              sizeof(uint32_t),
                                              sizeof(uint32_t));
        i_array_init(&ctx->zero_nodes, 128);
index f0f6b6edc4e95109156814ea0c9744709f77e345..c65058bba99d5aa5abd3d035f42f3c2f4424ca52 100644 (file)
@@ -7,7 +7,7 @@
 #include "mail-index-modseq.h"
 
 static void
-index_storage_get_status_cache_fields(struct index_mailbox *ibox,
+index_storage_get_status_cache_fields(struct mailbox *box,
                                      struct mailbox_status *status_r)
 {
        const struct mail_cache_field *fields;
@@ -15,13 +15,13 @@ index_storage_get_status_cache_fields(struct index_mailbox *ibox,
        ARRAY_TYPE(const_string) *cache_fields;
        unsigned int i, count;
 
-       fields = mail_cache_register_get_list(ibox->cache,
+       fields = mail_cache_register_get_list(box->cache,
                                              pool_datastack_create(), &count);
 
        /* a bit leaky to allocate memory from mailbox pool every time, but this
           is unlikely to be called more than once for the mailbox anyway. */
-       cache_fields = p_new(ibox->box.pool, ARRAY_TYPE(const_string), 1);
-       p_array_init(cache_fields, ibox->box.pool, count);
+       cache_fields = p_new(box->pool, ARRAY_TYPE(const_string), 1);
+       p_array_init(cache_fields, box->pool, count);
        for (i = 0; i < count; i++) {
                dec = fields[i].decision & ~MAIL_CACHE_DECISION_FORCED;
                if (dec != MAIL_CACHE_DECISION_NO)
@@ -42,7 +42,7 @@ void index_storage_get_status(struct mailbox *box,
        memset(status_r, 0, sizeof(struct mailbox_status));
 
        /* we can get most of the status items without any trouble */
-       hdr = mail_index_get_header(ibox->view);
+       hdr = mail_index_get_header(box->view);
        status_r->messages = hdr->messages_count;
        if ((items & STATUS_RECENT) != 0) {
                status_r->recent = index_mailbox_get_recent_count(ibox);
@@ -51,10 +51,10 @@ void index_storage_get_status(struct mailbox *box,
        status_r->unseen = hdr->messages_count - hdr->seen_messages_count;
        status_r->uidvalidity = hdr->uid_validity;
        status_r->uidnext = hdr->next_uid;
-       status_r->nonpermanent_modseqs = mail_index_is_in_memory(ibox->index);
+       status_r->nonpermanent_modseqs = mail_index_is_in_memory(box->index);
        if ((items & STATUS_HIGHESTMODSEQ) != 0) {
                status_r->highest_modseq =
-                       mail_index_modseq_get_highest(ibox->view);
+                       mail_index_modseq_get_highest(box->view);
                if (status_r->highest_modseq == 0) {
                        /* modseqs not enabled yet, but we can't return 0 */
                        status_r->highest_modseq = 1;
@@ -62,12 +62,12 @@ void index_storage_get_status(struct mailbox *box,
        }
 
        if ((items & STATUS_FIRST_UNSEEN_SEQ) != 0) {
-               mail_index_lookup_first(ibox->view, 0, MAIL_SEEN,
+               mail_index_lookup_first(box->view, 0, MAIL_SEEN,
                                        &status_r->first_unseen_seq);
        }
 
        if ((items & STATUS_KEYWORDS) != 0)
-               status_r->keywords = mail_index_get_keywords(ibox->index);
+               status_r->keywords = mail_index_get_keywords(box->index);
        if ((items & STATUS_CACHE_FIELDS) != 0)
-               index_storage_get_status_cache_fields(ibox, status_r);
+               index_storage_get_status_cache_fields(box, status_r);
 }
index 100b20c832f63b6aff27c07a225a27b2e88c4912..a2bae8ceb96471d904af801354098ac6e0aab5ac 100644 (file)
@@ -108,7 +108,7 @@ static void index_cache_register_defaults(struct index_mailbox *ibox)
 {
        const struct mail_storage_settings *set = ibox->box.storage->set;
        static bool initialized = FALSE;
-       struct mail_cache *cache = ibox->cache;
+       struct mail_cache *cache = ibox->box.cache;
 
        if (!initialized) {
                initialized = TRUE;
@@ -198,7 +198,7 @@ int index_storage_mailbox_open(struct mailbox *box)
                ibox->index_flags &= ~MAIL_INDEX_OPEN_FLAG_CREATE;
 
        if ((index_flags & MAIL_INDEX_OPEN_FLAG_NEVER_IN_MEMORY) != 0) {
-               if (mail_index_is_in_memory(ibox->index)) {
+               if (mail_index_is_in_memory(box->index)) {
                        mail_storage_set_critical(box->storage,
                                "Couldn't create index file");
                        return -1;
@@ -210,30 +210,30 @@ int index_storage_mailbox_open(struct mailbox *box)
                return -1;
        }
 
-       ret = mail_index_open(ibox->index, index_flags, lock_method);
+       ret = mail_index_open(box->index, index_flags, lock_method);
        if (ret <= 0 || ibox->move_to_memory) {
                if ((index_flags & MAIL_INDEX_OPEN_FLAG_NEVER_IN_MEMORY) != 0) {
-                       mail_storage_set_index_error(ibox);
+                       mail_storage_set_index_error(box);
                        return -1;
                }
 
-               if (mail_index_move_to_memory(ibox->index) < 0) {
+               if (mail_index_move_to_memory(box->index) < 0) {
                        /* try opening once more. it should be created
                           directly into memory now. */
-                       if (mail_index_open_or_create(ibox->index,
+                       if (mail_index_open_or_create(box->index,
                                                      index_flags,
                                                      lock_method) < 0)
                                i_panic("in-memory index creation failed");
                }
        }
 
-       ibox->cache = mail_index_get_cache(ibox->index);
+       box->cache = mail_index_get_cache(box->index);
        index_cache_register_defaults(ibox);
-       ibox->view = mail_index_view_open(ibox->index);
-       ibox->keyword_names = mail_index_get_keywords(ibox->index);
+       box->view = mail_index_view_open(box->index);
+       ibox->keyword_names = mail_index_get_keywords(box->index);
 
-       MODULE_CONTEXT_SET_FULL(ibox->view, mail_storage_mail_index_module,
-                               ibox, &ibox->view_module_ctx);
+       MODULE_CONTEXT_SET_FULL(box->view, mail_storage_mail_index_module,
+                               box, &ibox->view_module_ctx);
 
        box->opened = TRUE;
 
@@ -241,7 +241,7 @@ int index_storage_mailbox_open(struct mailbox *box)
        if (hook_mailbox_opened != NULL)
                hook_mailbox_opened(box);
 
-       if (mail_index_is_deleted(ibox->index)) {
+       if (mail_index_is_deleted(box->index)) {
                mailbox_set_deleted(box);
                return -1;
        }
@@ -287,11 +287,11 @@ void index_storage_mailbox_alloc(struct index_mailbox *ibox, const char *name,
                mail_storage_settings_to_index_flags(box->storage->set);
 
        ibox->next_lock_notify = time(NULL) + LOCK_NOTIFY_INTERVAL;
-       ibox->index = index_storage_alloc(box->list, name, flags, index_prefix);
+       box->index = index_storage_alloc(box->list, name, flags, index_prefix);
 
        if (box->file_create_mode == 0)
                mailbox_refresh_permissions(box);
-       mail_index_set_permissions(ibox->index, box->file_create_mode,
+       mail_index_set_permissions(box->index, box->file_create_mode,
                                   box->file_create_gid,
                                   box->file_create_gid_origin);
 }
@@ -299,8 +299,6 @@ void index_storage_mailbox_alloc(struct index_mailbox *ibox, const char *name,
 int index_storage_mailbox_enable(struct mailbox *box,
                                 enum mailbox_feature feature)
 {
-       struct index_mailbox *ibox = (struct index_mailbox *)box;
-
        if ((feature & MAILBOX_FEATURE_CONDSTORE) != 0) {
                box->enabled_features |= MAILBOX_FEATURE_CONDSTORE;
                if (!box->opened) {
@@ -308,7 +306,7 @@ int index_storage_mailbox_enable(struct mailbox *box,
                                return -1;
                }
                T_BEGIN {
-                       mail_index_modseq_enable(ibox->index);
+                       mail_index_modseq_enable(box->index);
                } T_END;
        }
        return 0;
@@ -318,14 +316,14 @@ void index_storage_mailbox_close(struct mailbox *box)
 {
        struct index_mailbox *ibox = (struct index_mailbox *) box;
 
-       if (ibox->view != NULL)
-               mail_index_view_close(&ibox->view);
+       if (box->view != NULL)
+               mail_index_view_close(&box->view);
 
        index_mailbox_check_remove_all(ibox);
        if (ibox->box.input != NULL)
                i_stream_unref(&ibox->box.input);
-       if (ibox->index != NULL)
-               mail_index_alloc_cache_unref(ibox->index);
+       if (box->index != NULL)
+               mail_index_alloc_cache_unref(box->index);
        if (array_is_created(&ibox->recent_flags))
                array_free(&ibox->recent_flags);
        i_free(ibox->cache_fields);
@@ -343,7 +341,7 @@ index_storage_mailbox_update_cache_fields(struct index_mailbox *ibox,
        struct mail_cache_field field;
        unsigned int i, j, old_count;
 
-       old_fields = mail_cache_register_get_list(ibox->cache,
+       old_fields = mail_cache_register_get_list(ibox->box.cache,
                                                  pool_datastack_create(),
                                                  &old_count);
 
@@ -373,7 +371,7 @@ index_storage_mailbox_update_cache_fields(struct index_mailbox *ibox,
                }
        }
        if (array_count(&new_fields) > 0) {
-               mail_cache_register_fields(ibox->cache,
+               mail_cache_register_fields(ibox->box.cache,
                                           array_idx_modifiable(&new_fields, 0),
                                           array_count(&new_fields));
        }
@@ -396,8 +394,8 @@ int index_storage_mailbox_update(struct mailbox *box,
                index_storage_mailbox_update_cache_fields(ibox, update);
 
        /* make sure we get the latest index info */
-       (void)mail_index_refresh(ibox->index);
-       view = mail_index_view_open(ibox->index);
+       (void)mail_index_refresh(ibox->box.index);
+       view = mail_index_view_open(ibox->box.index);
        hdr = mail_index_get_header(view);
 
        trans = mail_index_transaction_begin(view,
@@ -446,18 +444,7 @@ bool index_storage_allow_new_keywords(struct mailbox *box)
 
 bool index_storage_is_inconsistent(struct mailbox *box)
 {
-       struct index_mailbox *ibox = (struct index_mailbox *) box;
-
-       return mail_index_view_is_inconsistent(ibox->view);
-}
-
-void mail_storage_set_index_error(struct index_mailbox *ibox)
-{
-       if (mail_index_is_deleted(ibox->index))
-               mailbox_set_deleted(&ibox->box);
-       else
-               mail_storage_set_internal_error(ibox->box.storage);
-       mail_index_reset_error(ibox->index);
+       return mail_index_view_is_inconsistent(box->view);
 }
 
 bool index_keyword_is_valid(struct mailbox *box, const char *keyword,
@@ -467,7 +454,7 @@ bool index_keyword_is_valid(struct mailbox *box, const char *keyword,
        unsigned int i, idx;
 
        /* if it already exists, skip validity checks */
-       if (mail_index_keyword_lookup(ibox->index, keyword, &idx))
+       if (mail_index_keyword_lookup(box->index, keyword, &idx))
                return TRUE;
 
        if (*keyword == '\0') {
@@ -507,7 +494,7 @@ index_keywords_create_skip(struct index_mailbox *ibox,
                        array_append(&valid_keywords, keywords, 1);
        }
        (void)array_append_space(&valid_keywords); /* NULL-terminate */
-       return mail_index_keywords_create(ibox->index, keywords);
+       return mail_index_keywords_create(ibox->box.index, keywords);
 }
 
 int index_keywords_create(struct mailbox *_box, const char *const keywords[],
@@ -535,7 +522,7 @@ int index_keywords_create(struct mailbox *_box, const char *const keywords[],
                return 0;
        }
 
-       *keywords_r = mail_index_keywords_create(ibox->index, keywords);
+       *keywords_r = mail_index_keywords_create(ibox->box.index, keywords);
        return 0;
 }
 
@@ -543,9 +530,7 @@ struct mail_keywords *
 index_keywords_create_from_indexes(struct mailbox *_box,
                                   const ARRAY_TYPE(keyword_indexes) *idx)
 {
-       struct index_mailbox *ibox = (struct index_mailbox *)_box;
-
-       return mail_index_keywords_create_from_indexes(ibox->index, idx);
+       return mail_index_keywords_create_from_indexes(_box->index, idx);
 }
 
 void index_keywords_ref(struct mail_keywords *keywords)
index c8c63dd9ce11bdf29c5683f3763cc99f64224b00..8670af0b7098560f518c38fc1077389b07235ba0 100644 (file)
@@ -39,11 +39,6 @@ struct index_mailbox {
                                 struct mail_index_transaction_commit_result *result_r);
        void (*save_rollback)(struct mail_save_context *save_ctx);
 
-       struct mail_index *index;
-       struct mail_index_view *view;
-       struct mail_cache *cache;
-       struct mail_vfuncs *mail_vfuncs;
-
        struct timeout *notify_to, *notify_delay_to;
        struct index_notify_file *notify_files;
         struct index_notify_io *notify_ios;
@@ -66,8 +61,6 @@ struct index_mailbox {
        unsigned int move_to_memory:1;
 };
 
-void mail_storage_set_index_error(struct index_mailbox *ibox);
-
 void index_storage_lock_notify(struct index_mailbox *ibox,
                               enum mailbox_lock_notify_type notify_type,
                               unsigned int secs_left);
index 7e816b4df9868a1d2407c29b5e9663b317ac727b..1f0a2581ed9184f878f8e80a198722e39f962117 100644 (file)
@@ -27,7 +27,7 @@ static void index_sync_uidify_array(struct index_mailbox_sync_context *ctx,
 
        array_foreach(changes, range) {
                for (seq = range->seq1; seq <= range->seq2; seq++) {
-                       mail_index_lookup_uid(ctx->ibox->view, seq, &uid);
+                       mail_index_lookup_uid(ctx->ibox->box.view, seq, &uid);
                        seq_range_array_add(&ctx->all_flag_update_uids, 0, uid);
                }
        }
index 17bf3764adfed09efa2a777b408f6e745f6031f0..164b78c0f2c598fa6f050d420e0956f856a4460a 100644 (file)
@@ -67,7 +67,7 @@ unsigned int index_mailbox_get_recent_count(struct index_mailbox *ibox)
        if (!array_is_created(&ibox->recent_flags))
                return 0;
 
-       hdr = mail_index_get_header(ibox->view);
+       hdr = mail_index_get_header(ibox->box.view);
        recent_count = ibox->recent_flags_count;
        range = array_get(&ibox->recent_flags, &count);
        for (i = count; i > 0; ) {
@@ -96,7 +96,7 @@ static void index_mailbox_expunge_recent(struct index_mailbox *ibox,
                return;
 
        for (; seq1 <= seq2; seq1++) {
-               mail_index_lookup_uid(ibox->view, seq1, &uid);
+               mail_index_lookup_uid(ibox->box.view, seq1, &uid);
                if (seq_range_array_remove(&ibox->recent_flags, uid))
                        ibox->recent_flags_count--;
        }
@@ -112,7 +112,7 @@ static void index_view_sync_recs_get(struct index_mailbox_sync_context *ctx)
        while (mail_index_view_sync_next(ctx->sync_ctx, &sync_rec)) {
                switch (sync_rec.type) {
                case MAIL_INDEX_VIEW_SYNC_TYPE_FLAGS:
-                       if (!mail_index_lookup_seq_range(ctx->ibox->view,
+                       if (!mail_index_lookup_seq_range(ctx->ibox->box.view,
                                                         sync_rec.uid1,
                                                         sync_rec.uid2,
                                                         &seq1, &seq2))
@@ -166,10 +166,10 @@ index_mailbox_sync_init(struct mailbox *box, enum mailbox_sync_flags flags,
                ctx->messages_count = 0;
        } else {
                ctx->messages_count =
-                       mail_index_view_get_messages_count(ibox->view);
+                       mail_index_view_get_messages_count(box->view);
        }
 
-       ctx->sync_ctx = mail_index_view_sync_begin(ibox->view, sync_flags);
+       ctx->sync_ctx = mail_index_view_sync_begin(box->view, sync_flags);
        if ((flags & MAILBOX_SYNC_FLAG_NO_EXPUNGES) == 0) {
                mail_index_view_sync_get_expunges(ctx->sync_ctx,
                                                  &ctx->expunges);
@@ -242,6 +242,7 @@ static void
 index_mailbox_expunge_unseen_recent(struct index_mailbox_sync_context *ctx)
 {
        struct index_mailbox *ibox = ctx->ibox;
+       struct mail_index_view *view = ibox->box.view;
        const struct mail_index_header *hdr;
        uint32_t seq, start_uid, uid;
 
@@ -252,19 +253,19 @@ index_mailbox_expunge_unseen_recent(struct index_mailbox_sync_context *ctx)
           visible in this view, but append+expunge would be invisible.
           recent_flags may however contain the append UID, so we'll have to
           remove it separately */
-       hdr = mail_index_get_header(ibox->view);
+       hdr = mail_index_get_header(view);
        if (ctx->messages_count == 0)
                uid = 0;
        else if (ctx->messages_count <= hdr->messages_count)
-               mail_index_lookup_uid(ibox->view, ctx->messages_count, &uid);
+               mail_index_lookup_uid(view, ctx->messages_count, &uid);
        else {
-               i_assert(mail_index_view_is_inconsistent(ibox->view));
+               i_assert(mail_index_view_is_inconsistent(view));
                return;
        }
 
        for (seq = ctx->messages_count + 1; seq <= hdr->messages_count; seq++) {
                start_uid = uid;
-               mail_index_lookup_uid(ibox->view, seq, &uid);
+               mail_index_lookup_uid(view, seq, &uid);
                if (start_uid + 1 > uid - 1)
                        continue;
 
@@ -280,7 +281,7 @@ index_mailbox_expunge_unseen_recent(struct index_mailbox_sync_context *ctx)
                                                     hdr->next_uid - 1);
        }
 #ifdef DEBUG
-       if (!mail_index_view_is_inconsistent(ibox->view)) {
+       if (!mail_index_view_is_inconsistent(view)) {
                const struct seq_range *range;
                unsigned int i, count;
 
@@ -289,7 +290,7 @@ index_mailbox_expunge_unseen_recent(struct index_mailbox_sync_context *ctx)
                        for (uid = range[i].seq1; uid <= range[i].seq2; uid++) {
                                if (uid >= hdr->next_uid)
                                        break;
-                               mail_index_lookup_seq(ibox->view, uid, &seq);
+                               mail_index_lookup_seq(view, uid, &seq);
                                i_assert(seq != 0);
                        }
                }
@@ -319,23 +320,24 @@ int index_mailbox_sync_deinit(struct mailbox_sync_context *_ctx,
        if (ctx->sync_ctx != NULL) {
                if (mail_index_view_sync_commit(&ctx->sync_ctx,
                                                &delayed_expunges) < 0) {
-                       mail_storage_set_index_error(ibox);
+                       mail_storage_set_index_error(_ctx->box);
                        ret = -1;
                }
        }
        index_mailbox_expunge_unseen_recent(ctx);
 
-       if ((ibox->box.flags & MAILBOX_FLAG_KEEP_RECENT) != 0 &&
-           ibox->box.opened) {
+       if ((_ctx->box->flags & MAILBOX_FLAG_KEEP_RECENT) != 0 &&
+           _ctx->box->opened) {
                /* mailbox syncing didn't necessarily update our recent state */
-               hdr = mail_index_get_header(ibox->view);
+               hdr = mail_index_get_header(_ctx->box->view);
                if (hdr->first_recent_uid > ibox->recent_flags_prev_uid) {
-                       mail_index_lookup_seq_range(ibox->view,
+                       mail_index_lookup_seq_range(_ctx->box->view,
                                                    hdr->first_recent_uid,
                                                    hdr->next_uid,
                                                    &seq1, &seq2);
                        if (seq1 != 0) {
-                               index_mailbox_set_recent_seq(ibox, ibox->view,
+                               index_mailbox_set_recent_seq(ibox,
+                                                            _ctx->box->view,
                                                             seq1, seq2);
                        }
                }
index fbeafad8b43b816b1fc7795b5bf382b2ceb0bd6d..a1f558b82b4bba79b102708f89ab766d9afe1e37 100644 (file)
@@ -307,10 +307,9 @@ static int mail_thread_index_map_build(struct mail_thread_context *ctx)
 
        if (tbox->strmap_view == NULL) {
                /* first time we're threading this mailbox */
-               struct index_mailbox *ibox = (struct index_mailbox *)ctx->box;
-
                tbox->strmap_view =
-                       mail_index_strmap_view_open(tbox->strmap, ibox->view,
+                       mail_index_strmap_view_open(tbox->strmap,
+                                                   ctx->box->view,
                                                    mail_thread_hash_key_cmp,
                                                    mail_thread_hash_rec_cmp,
                                                    mail_thread_strmap_remap,
@@ -642,7 +641,7 @@ void index_thread_mailbox_opened(struct index_mailbox *ibox)
        tbox->module_ctx.super = box->v;
        box->v.close = mail_thread_mailbox_close;
 
-       tbox->strmap = mail_index_strmap_init(ibox->index,
+       tbox->strmap = mail_index_strmap_init(box->index,
                                              MAIL_THREAD_INDEX_SUFFIX);
        tbox->next_msgid_idx = 1;
 
index 509ad3500357ae97ef0d2c3f449514a479e60da3..2d1b330cc8549396265cacab71eee582d8c8ec02 100644 (file)
@@ -35,7 +35,7 @@ index_transaction_index_commit(struct mail_index_transaction *index_trans,
                it->super.rollback(it->trans);
        else {
                if (it->super.commit(it->trans, result_r) < 0) {
-                       mail_storage_set_index_error(ibox);
+                       mail_storage_set_index_error(t->box);
                        ret = -1;
                }
        }
@@ -64,7 +64,6 @@ void index_transaction_init(struct index_transaction_context *it,
                            struct mailbox *box,
                            enum mailbox_transaction_flags flags)
 {
-       struct index_mailbox *ibox = (struct index_mailbox *)box;
        enum mail_index_transaction_flags trans_flags;
 
        i_assert(box->opened);
@@ -75,16 +74,16 @@ void index_transaction_init(struct index_transaction_context *it,
        if ((flags & MAILBOX_TRANSACTION_FLAG_EXTERNAL) != 0)
                trans_flags |= MAIL_INDEX_TRANSACTION_FLAG_EXTERNAL;
        if ((flags & MAILBOX_TRANSACTION_FLAG_REFRESH) != 0)
-               (void)mail_index_refresh(ibox->index);
+               (void)mail_index_refresh(box->index);
 
-       it->trans = mail_index_transaction_begin(ibox->view, trans_flags);
-       it->mailbox_ctx.box = &ibox->box;
+       it->trans = mail_index_transaction_begin(box->view, trans_flags);
+       it->mailbox_ctx.box = box;
 
        array_create(&it->mailbox_ctx.module_contexts, default_pool,
                     sizeof(void *), 5);
 
        it->trans_view = mail_index_transaction_open_updated_view(it->trans);
-       it->cache_view = mail_cache_view_open(ibox->cache, it->trans_view);
+       it->cache_view = mail_cache_view_open(box->cache, it->trans_view);
        it->cache_trans = mail_cache_get_transaction(it->cache_view, it->trans);
 
        /* set up after mail_cache_get_transaction(), so that we'll still
@@ -111,8 +110,8 @@ int index_transaction_commit(struct mailbox_transaction_context *_t,
 {
        struct index_transaction_context *t =
                (struct index_transaction_context *)_t;
+       struct mailbox *box = _t->box;
        struct mail_index_transaction *itrans = t->trans;
-       struct index_mailbox *ibox = (struct index_mailbox *)_t->box;
        struct mail_index_transaction_commit_result result;
        int ret;
 
@@ -122,14 +121,14 @@ int index_transaction_commit(struct mailbox_transaction_context *_t,
        _t->changes = changes_r;
 
        ret = mail_index_transaction_commit_full(&itrans, &result);
-       if (ret < 0 && mail_index_is_deleted(ibox->index))
-               mailbox_set_deleted(&ibox->box);
+       if (ret < 0 && mail_index_is_deleted(_t->box->index))
+               mailbox_set_deleted(_t->box);
 
        changes_r->ignored_uid_changes = result.ignored_uid_changes;
        changes_r->ignored_modseq_changes = result.ignored_modseq_changes;
 
-       i_assert(ibox->box.transaction_count > 0 ||
-                ibox->view->transactions == 0);
+       i_assert(box->transaction_count > 0 ||
+                box->view->transactions == 0);
        return ret;
 }
 
@@ -137,13 +136,13 @@ void index_transaction_rollback(struct mailbox_transaction_context *_t)
 {
        struct index_transaction_context *t =
                (struct index_transaction_context *)_t;
+       struct mailbox *box = _t->box;
        struct mail_index_transaction *itrans = t->trans;
-       struct index_mailbox *ibox = (struct index_mailbox *)_t->box;
 
        mail_index_transaction_rollback(&itrans);
 
-       i_assert(ibox->box.transaction_count > 0 ||
-                ibox->view->transactions == 0);
+       i_assert(box->transaction_count > 0 ||
+                box->view->transactions == 0);
 }
 
 void index_transaction_set_max_modseq(struct mailbox_transaction_context *_t,
index caaabb8bc5c90fce201e2551596421d3bd7f1294..0f700a4721e55f25fb21d59df8ed3620cb23ee1f 100644 (file)
@@ -170,7 +170,7 @@ maildir_copy_hardlink(struct mail_save_context *ctx, struct mail *mail)
                return 0;
        }
 
-       if (mail_index_is_deleted(dest_mbox->ibox.index)) {
+       if (mail_index_is_deleted(dest_mbox->ibox.box.index)) {
                mailbox_set_deleted(&dest_mbox->ibox.box);
                return -1;
        }
index ddccb62773ad7c352785fd0f37d556e5be17cefd..c08071896ddb00f9481ee398d97f6c95b1ff50b3 100644 (file)
@@ -177,8 +177,8 @@ maildir_mail_get_fname(struct maildir_mailbox *mbox, struct mail *mail,
        /* one reason this could happen is if we delayed opening
           dovecot-uidlist and we're trying to open a mail that got recently
           expunged. Let's test this theory first: */
-       (void)mail_index_refresh(mbox->ibox.index);
-       view = mail_index_view_open(mbox->ibox.index);
+       (void)mail_index_refresh(mbox->ibox.box.index);
+       view = mail_index_view_open(mbox->ibox.box.index);
        exists = mail_index_lookup_seq(view, mail->uid, &seq);
        mail_index_view_close(&view);
 
@@ -216,13 +216,13 @@ static int maildir_get_pop3_state(struct index_mail *mail)
        psize_idx = mail->ibox->cache_fields[MAIL_CACHE_PHYSICAL_FULL_SIZE].idx;
        vsize_idx = mail->ibox->cache_fields[MAIL_CACHE_VIRTUAL_FULL_SIZE].idx;
        if (not_pop3_only) {
-               vsize_dec = mail_cache_field_get_decision(mail->ibox->cache,
+               vsize_dec = mail_cache_field_get_decision(mail->ibox->box.cache,
                                                          vsize_idx);
                vsize_dec &= ~MAIL_CACHE_DECISION_FORCED;
        } else {
                /* also check if there are any non-[pv]size cached fields */
                vsize_dec = MAIL_CACHE_DECISION_NO;
-               fields = mail_cache_register_get_list(mail->ibox->cache,
+               fields = mail_cache_register_get_list(mail->ibox->box.cache,
                                                      pool_datastack_create(),
                                                      &count);
                for (i = 0; i < count; i++) {
@@ -313,14 +313,14 @@ maildir_handle_size_caching(struct index_mail *mail, bool quick_check,
                   including to the uidlist if it's already in filename.
                   do some extra checks here to catch potential cache bugs. */
                if (vsize && mail->data.virtual_size != size) {
-                       mail_cache_set_corrupted(mail->ibox->cache,
+                       mail_cache_set_corrupted(mail->ibox->box.cache,
                                "Corrupted virtual size for uid=%u: "
                                "%"PRIuUOFF_T" != %"PRIuUOFF_T,
                                mail->mail.mail.uid,
                                mail->data.virtual_size, size);
                        mail->data.virtual_size = size;
                } else if (!vsize && mail->data.physical_size != size) {
-                       mail_cache_set_corrupted(mail->ibox->cache,
+                       mail_cache_set_corrupted(mail->ibox->box.cache,
                                "Corrupted physical size for uid=%u: "
                                "%"PRIuUOFF_T" != %"PRIuUOFF_T,
                                mail->mail.mail.uid,
index 5b77d534fc93052a89f8533c95a34edac1af0334..5654c966dae6902f3695b044cb5a70bbc350e1cc 100644 (file)
@@ -305,7 +305,7 @@ static int maildir_create_tmp(struct maildir_mailbox *mbox, const char *dir,
        string_t *path;
        int fd;
 
-       if (mail_index_is_deleted(mbox->ibox.index)) {
+       if (mail_index_is_deleted(mbox->ibox.box.index)) {
                mailbox_set_deleted(box);
                return -1;
        }
@@ -957,7 +957,7 @@ int maildir_transaction_save_commit_pre(struct mail_save_context *_ctx)
        if (ret < 0) {
                ctx->keywords_sync_ctx = !ctx->have_keywords ? NULL :
                        maildir_keywords_sync_init(ctx->mbox->keywords,
-                                                  ctx->mbox->ibox.index);
+                                                  ctx->mbox->ibox.box.index);
 
                /* unlink the files we just moved in an attempt to rollback
                   the transaction. uidlist is still locked, so at least other
index e09b20c30a73beb6d46899f799cdc0937465ebb4..608736493761aa4debb9ca0e32f22dd336431e8b 100644 (file)
@@ -337,7 +337,7 @@ maildir_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list,
        mbox->ibox.box.pool = pool;
        mbox->ibox.box.storage = storage;
        mbox->ibox.box.list = list;
-       mbox->ibox.mail_vfuncs = &maildir_mail_vfuncs;
+       mbox->ibox.box.mail_vfuncs = &maildir_mail_vfuncs;
 
        mbox->ibox.save_commit_pre = maildir_transaction_save_commit_pre;
        mbox->ibox.save_commit_post = maildir_transaction_save_commit_post;
@@ -348,7 +348,7 @@ maildir_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list,
 
        mbox->storage = (struct maildir_storage *)storage;
        mbox->maildir_ext_id =
-               mail_index_ext_register(mbox->ibox.index, "maildir",
+               mail_index_ext_register(mbox->ibox.box.index, "maildir",
                                        sizeof(mbox->maildir_hdr), 0, 0);
        mbox->uidlist = maildir_uidlist_init(mbox);
        mbox->keywords = maildir_keywords_init(mbox);
index 751f7a01390980ae09840970d0a1ad06469a3f10..6d9798c5ffd2d34f7de088235db0810e7d787c6b 100644 (file)
@@ -212,6 +212,7 @@ int maildir_sync_index_begin(struct maildir_mailbox *mbox,
                             struct maildir_sync_context *maildir_sync_ctx,
                             struct maildir_index_sync_context **ctx_r)
 {
+       struct mailbox *_box = &mbox->ibox.box;
        struct maildir_index_sync_context *ctx;
        struct mail_index_sync_ctx *sync_ctx;
        struct mail_index_view *view;
@@ -220,13 +221,13 @@ int maildir_sync_index_begin(struct maildir_mailbox *mbox,
 
        sync_flags = 0;
        /* don't drop recent messages if we're saving messages */
-       if ((mbox->ibox.box.flags & MAILBOX_FLAG_KEEP_RECENT) == 0 &&
+       if ((_box->flags & MAILBOX_FLAG_KEEP_RECENT) == 0 &&
            maildir_sync_ctx != NULL)
                sync_flags |= MAIL_INDEX_SYNC_FLAG_DROP_RECENT;
 
-       if (mail_index_sync_begin(mbox->ibox.index, &sync_ctx, &view, &trans,
-                                 sync_flags) < 0) {
-               mail_storage_set_index_error(&mbox->ibox);
+       if (mail_index_sync_begin(_box->index, &sync_ctx, &view,
+                                 &trans, sync_flags) < 0) {
+               mail_storage_set_index_error(_box);
                return -1;
        }
 
@@ -237,7 +238,7 @@ int maildir_sync_index_begin(struct maildir_mailbox *mbox,
        ctx->view = view;
        ctx->trans = trans;
        ctx->keywords_sync_ctx =
-               maildir_keywords_sync_init(mbox->keywords, mbox->ibox.index);
+               maildir_keywords_sync_init(mbox->keywords, _box->index);
        ctx->sync_changes =
                index_sync_changes_init(&mbox->ibox, ctx->sync_ctx,
                                        ctx->view, ctx->trans,
@@ -286,7 +287,7 @@ maildir_sync_index_update_ext_header(struct maildir_index_sync_context *ctx)
                mbox->maildir_hdr.cur_mtime_nsecs = ST_MTIME_NSEC(st);
        }
 
-       mail_index_get_header_ext(mbox->ibox.view, mbox->maildir_ext_id,
+       mail_index_get_header_ext(mbox->ibox.box.view, mbox->maildir_ext_id,
                                  &data, &data_size);
        if (data_size != sizeof(mbox->maildir_hdr) ||
            maildir_index_header_has_changed(data, &mbox->maildir_hdr)) {
@@ -313,7 +314,7 @@ static int maildir_sync_index_finish(struct maildir_index_sync_context *ctx,
                   start a second index sync and crash. */
                mbox->syncing_commit = TRUE;
                if (mail_index_sync_commit(&ctx->sync_ctx) < 0) {
-                       mail_storage_set_index_error(&mbox->ibox);
+                       mail_storage_set_index_error(&mbox->ibox.box);
                        ret = -1;
                }
                mbox->syncing_commit = FALSE;
@@ -356,7 +357,7 @@ static int uint_cmp(const void *p1, const void *p2)
 static void
 maildir_sync_mail_keywords(struct maildir_index_sync_context *ctx, uint32_t seq)
 {
-       struct maildir_mailbox *mbox = ctx->mbox;
+       struct mailbox *box = &ctx->mbox->ibox.box;
        struct mail_keywords *kw;
        unsigned int i, j, old_count, new_count;
        const unsigned int *old_indexes, *new_indexes;
@@ -386,7 +387,7 @@ maildir_sync_mail_keywords(struct maildir_index_sync_context *ctx, uint32_t seq)
        if (!have_indexonly_keywords) {
                /* no index-only keywords found, so something changed.
                   just replace them all. */
-               kw = mail_index_keywords_create_from_indexes(mbox->ibox.index,
+               kw = mail_index_keywords_create_from_indexes(box->index,
                                                             &ctx->keywords);
                mail_index_update_keywords(ctx->trans, seq, MODIFY_REPLACE, kw);
                mail_index_keywords_unref(&kw);
@@ -417,14 +418,14 @@ maildir_sync_mail_keywords(struct maildir_index_sync_context *ctx, uint32_t seq)
        }
 
        if (array_count(&ctx->idx_keywords) > 0) {
-               kw = mail_index_keywords_create_from_indexes(mbox->ibox.index,
+               kw = mail_index_keywords_create_from_indexes(box->index,
                                                             &ctx->idx_keywords);
                mail_index_update_keywords(ctx->trans, seq, MODIFY_REMOVE, kw);
                mail_index_keywords_unref(&kw);
        }
 
        if (array_count(&ctx->keywords) > 0) {
-               kw = mail_index_keywords_create_from_indexes(mbox->ibox.index,
+               kw = mail_index_keywords_create_from_indexes(box->index,
                                                             &ctx->keywords);
                mail_index_update_keywords(ctx->trans, seq, MODIFY_ADD, kw);
                mail_index_keywords_unref(&kw);
@@ -523,7 +524,7 @@ int maildir_sync_index(struct maildir_index_sync_context *ctx,
                                struct mail_keywords *kw;
 
                                kw = mail_index_keywords_create_from_indexes(
-                                       mbox->ibox.index, &ctx->keywords);
+                                       mbox->ibox.box.index, &ctx->keywords);
                                mail_index_update_keywords(trans, seq,
                                                           MODIFY_REPLACE, kw);
                                mail_index_keywords_unref(&kw);
index edea494a40444cf54b996249b5417605ab024bf2..782783a2fa07ab9fed6f0006e7ca0816ded08277 100644 (file)
@@ -537,12 +537,12 @@ int maildir_sync_header_refresh(struct maildir_mailbox *mbox)
        const void *data;
        size_t data_size;
 
-       if (mail_index_refresh(mbox->ibox.index) < 0) {
-               mail_storage_set_index_error(&mbox->ibox);
+       if (mail_index_refresh(mbox->ibox.box.index) < 0) {
+               mail_storage_set_index_error(&mbox->ibox.box);
                return -1;
        }
 
-       mail_index_get_header_ext(mbox->ibox.view, mbox->maildir_ext_id,
+       mail_index_get_header_ext(mbox->ibox.box.view, mbox->maildir_ext_id,
                                  &data, &data_size);
        if (data_size == 0) {
                /* doesn't exist */
@@ -636,7 +636,7 @@ static void maildir_sync_update_next_uid(struct maildir_mailbox *mbox)
        const struct mail_index_header *hdr;
        uint32_t uid_validity, next_uid;
 
-       hdr = mail_index_get_header(mbox->ibox.view);
+       hdr = mail_index_get_header(mbox->ibox.box.view);
        if (hdr->uid_validity == 0)
                return;
 
@@ -662,7 +662,7 @@ static bool have_recent_messages(struct maildir_sync_context *ctx)
 
        /* if there are files in new/, we'll need to move them. we'll check
           this by checking if we have any recent messages */
-       hdr = mail_index_get_header(ctx->mbox->ibox.view);
+       hdr = mail_index_get_header(ctx->mbox->ibox.box.view);
        return hdr->first_recent_uid <
                maildir_uidlist_get_next_uid(ctx->mbox->uidlist);
 }
@@ -696,7 +696,7 @@ static int maildir_sync_get_changes(struct maildir_sync_context *ctx,
        if ((mbox->ibox.box.flags & MAILBOX_FLAG_KEEP_RECENT) == 0)
                flags |= MAIL_INDEX_SYNC_FLAG_DROP_RECENT;
 
-       return mail_index_sync_have_any(mbox->ibox.index, flags) ? 1 : 0;
+       return mail_index_sync_have_any(mbox->ibox.box.index, flags) ? 1 : 0;
 }
 
 static int maildir_sync_context(struct maildir_sync_context *ctx, bool forced,
@@ -947,12 +947,12 @@ maildir_storage_sync_init(struct mailbox *box, enum mailbox_sync_flags flags)
 
                if (mbox->flags_view == NULL) {
                        mbox->flags_view =
-                               mail_index_view_open(mbox->ibox.index);
+                               mail_index_view_open(mbox->ibox.box.index);
                }
                sync_ctx = mail_index_view_sync_begin(mbox->flags_view,
                                MAIL_INDEX_VIEW_SYNC_FLAG_FIX_INCONSISTENT);
                if (mail_index_view_sync_commit(&sync_ctx, &b) < 0) {
-                       mail_storage_set_index_error(&mbox->ibox);
+                       mail_storage_set_index_error(&mbox->ibox.box);
                        ret = -1;
                }
                /* make sure the map stays in private memory */
index c9e182e91e101d4012cf66d0fd8f055c28b590c8..34274d4b25fe0882aec0c96faf5d864bdc1487a1 100644 (file)
@@ -961,7 +961,7 @@ int maildir_uidlist_refresh(struct maildir_uidlist *uidlist)
 int maildir_uidlist_refresh_fast_init(struct maildir_uidlist *uidlist)
 {
        const struct maildir_index_header *mhdr = &uidlist->mbox->maildir_hdr;
-       struct mail_index *index = uidlist->mbox->ibox.index;
+       struct mail_index *index = uidlist->mbox->ibox.box.index;
        struct mail_index_view *view;
        const struct mail_index_header *hdr;
        struct stat st;
@@ -1224,7 +1224,7 @@ maildir_uidlist_generate_uid_validity(struct maildir_uidlist *uidlist)
        const struct mail_index_header *hdr;
 
        if (uidlist->ibox->box.opened) {
-               hdr = mail_index_get_header(uidlist->ibox->view);
+               hdr = mail_index_get_header(uidlist->ibox->box.view);
                if (hdr->uid_validity != 0) {
                        uidlist->uid_validity = hdr->uid_validity;
                        return;
@@ -1334,8 +1334,8 @@ maildir_uidlist_records_drop_expunges(struct maildir_uidlist *uidlist)
        if (!uidlist->mbox->ibox.box.opened)
                return;
 
-       mail_index_refresh(uidlist->mbox->ibox.index);
-       view = mail_index_view_open(uidlist->mbox->ibox.index);
+       mail_index_refresh(uidlist->mbox->ibox.box.index);
+       view = mail_index_view_open(uidlist->mbox->ibox.box.index);
        count = array_count(&uidlist->records);
        hdr = mail_index_get_header(view);
        if (count * UIDLIST_COMPRESS_PERCENTAGE / 100 <= hdr->messages_count) {
@@ -1486,7 +1486,7 @@ int maildir_uidlist_update(struct maildir_uidlist *uidlist)
 
 static bool maildir_uidlist_want_compress(struct maildir_uidlist_sync_ctx *ctx)
 {
-       struct mail_index_view *view = ctx->uidlist->mbox->ibox.view;
+       struct mail_index_view *view = ctx->uidlist->mbox->ibox.box.view;
        unsigned int min_rewrite_count, messages_count;
 
        if (!ctx->uidlist->locked_refresh)
index 7b7dcb530d07722ee713a5e9ebdb03d30d767fe2..285db42495f9c7af45d3cb8b5594d700219eafda 100644 (file)
@@ -43,7 +43,7 @@ maildir_filename_guess(struct maildir_mailbox *mbox, uint32_t uid,
        } else {
                *have_flags_r = TRUE;
                kw_ctx = maildir_keywords_sync_init_readonly(mbox->keywords,
-                                                            mbox->ibox.index);
+                                                            mbox->ibox.box.index);
                fname = maildir_filename_set_flags(kw_ctx, fname,
                                                   flags, &keywords);
                maildir_keywords_sync_deinit(&kw_ctx);
index e2ec99a7f19f0387e72063ec15e9efee230a57cd..d24a9d5a9dde62c555239c5bd6486159c96da08a 100644 (file)
@@ -777,7 +777,7 @@ int mbox_lock(struct mbox_mailbox *mbox, int lock_type,
        i_assert(lock_type == F_RDLCK || mbox->mbox_lock_type != F_RDLCK);
 
        /* mbox must be locked before index */
-       i_assert(mbox->ibox.index->lock_type != F_WRLCK);
+       i_assert(mbox->ibox.box.index->lock_type != F_WRLCK);
 
        if (mbox->mbox_lock_type == F_UNLCK) {
                ret = mbox_update_locking(mbox, lock_type, &fcntl_locked);
index 81430e49bc2e600517326c2c90ee2475a4930bf2..a24e5c2dc1fdd60b3982bd172f635f6e85e08ffb 100644 (file)
@@ -65,8 +65,8 @@ static int mbox_mail_seek(struct index_mail *mail)
 
                        /* refresh index file after mbox has been locked to
                           make sure we get only up-to-date mbox offsets. */
-                       if (mail_index_refresh(mbox->ibox.index) < 0) {
-                               mail_storage_set_index_error(&mbox->ibox);
+                       if (mail_index_refresh(mbox->ibox.box.index) < 0) {
+                               mail_storage_set_index_error(&mbox->ibox.box);
                                return -1;
                        }
 
@@ -232,7 +232,7 @@ mbox_mail_get_next_offset(struct index_mail *mail, uoff_t *next_offset_r)
        if (mbox_sync_header_refresh(mbox) < 0)
                return -1;
 
-       view = mail_index_view_open(mail->ibox->index);
+       view = mail_index_view_open(mail->ibox->box.index);
        hdr = mail_index_get_header(view);
        if (!mail_index_lookup_seq(view, mail->mail.mail.uid, &seq))
                i_panic("Message unexpectedly expunged from index");
index 43148513a683bdf8237a3b9fd8c08f3b462922b8..e0b0cf1cadc7e1767a3332961eb92a3a1a5e4661 100644 (file)
@@ -179,8 +179,8 @@ static void mbox_save_init_sync(struct mailbox_transaction_context *t)
 
        /* open a new view to get the header. this is required if we just
           synced the mailbox so we can get updated next_uid. */
-       (void)mail_index_refresh(mbox->ibox.index);
-       view = mail_index_view_open(mbox->ibox.index);
+       (void)mail_index_refresh(mbox->ibox.box.index);
+       view = mail_index_view_open(mbox->ibox.box.index);
        hdr = mail_index_get_header(view);
 
        ctx->next_uid = hdr->next_uid;
@@ -227,7 +227,7 @@ mbox_save_append_keyword_headers(struct mbox_save_context *ctx,
        const char *const *keyword_names;
        unsigned int i, count, keyword_names_count;
 
-       keyword_names_list = mail_index_get_keywords(ctx->mbox->ibox.index);
+       keyword_names_list = mail_index_get_keywords(ctx->mbox->ibox.box.index);
        keyword_names = array_get(keyword_names_list, &keyword_names_count);
 
        str_append(ctx->headers, "X-Keywords:");
@@ -261,7 +261,7 @@ mbox_save_init_file(struct mbox_save_context *ctx,
                return -1;
        }
 
-       if (mail_index_is_deleted(mbox->ibox.index)) {
+       if (mail_index_is_deleted(mbox->ibox.box.index)) {
                mailbox_set_deleted(&mbox->ibox.box);
                return -1;
        }
index 387b5b412a509968f5a57d05b62400abbbdfbf55..c8e0abed4fbdb445057990dcaa18259f8e032db9 100644 (file)
@@ -346,7 +346,7 @@ mbox_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list,
        mbox->ibox.box.pool = pool;
        mbox->ibox.box.storage = storage;
        mbox->ibox.box.list = list;
-       mbox->ibox.mail_vfuncs = &mbox_mail_vfuncs;
+       mbox->ibox.box.mail_vfuncs = &mbox_mail_vfuncs;
 
        mbox->ibox.save_commit_pre = mbox_transaction_save_commit_pre;
        mbox->ibox.save_commit_post = mbox_transaction_save_commit_post;
@@ -359,11 +359,11 @@ mbox_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list,
        mbox->mbox_fd = -1;
        mbox->mbox_lock_type = F_UNLCK;
        mbox->mbox_ext_idx =
-               mail_index_ext_register(mbox->ibox.index, "mbox",
+               mail_index_ext_register(mbox->ibox.box.index, "mbox",
                                        sizeof(mbox->mbox_hdr),
                                        sizeof(uint64_t), sizeof(uint64_t));
        mbox->md5hdr_ext_idx =
-               mail_index_ext_register(mbox->ibox.index, "header-md5",
+               mail_index_ext_register(mbox->ibox.box.index, "header-md5",
                                        0, 16, 1);
 
        if ((storage->flags & MAIL_STORAGE_FLAG_KEEP_HEADER_MD5) != 0)
@@ -546,8 +546,8 @@ static void mbox_mailbox_close(struct mailbox *box)
                sync_flags |= MBOX_SYNC_UNDIRTY | MBOX_SYNC_FORCE_SYNC;
        }
 
-       if (mbox->ibox.view != NULL) {
-               hdr = mail_index_get_header(mbox->ibox.view);
+       if (box->view != NULL) {
+               hdr = mail_index_get_header(box->view);
                if ((hdr->flags & MAIL_INDEX_HDR_FLAG_HAVE_DIRTY) != 0 &&
                    !mbox->ibox.backend_readonly) {
                        /* we've done changes to mbox which haven't been
index cbc09eb364310afdf70a3cf82a3e2ab64b25284e..10ead9d13d7634fdc236a86e828bcd93a37d2ead 100644 (file)
@@ -113,6 +113,7 @@ static void
 parse_imap_keywords_list(struct mbox_sync_mail_context *ctx,
                          struct message_header_line *hdr, size_t pos)
 {
+       struct mailbox *box = &ctx->sync_ctx->mbox->ibox.box;
        const char *keyword, *error;
        size_t keyword_start;
        unsigned int idx, count;
@@ -136,8 +137,8 @@ parse_imap_keywords_list(struct mbox_sync_mail_context *ctx,
                                    pos - keyword_start);
                if (mailbox_keyword_is_valid(&ctx->sync_ctx->mbox->ibox.box,
                                             keyword, &error)) {
-                       mail_index_keyword_lookup_or_create(
-                               ctx->sync_ctx->mbox->ibox.index, keyword, &idx);
+                       mail_index_keyword_lookup_or_create(box->index,
+                                                           keyword, &idx);
                }
                count++;
        }
@@ -246,6 +247,7 @@ static bool parse_x_imap(struct mbox_sync_mail_context *ctx,
 static bool parse_x_keywords_real(struct mbox_sync_mail_context *ctx,
                                  struct message_header_line *hdr)
 {
+       struct mailbox *box = &ctx->sync_ctx->mbox->ibox.box;
        ARRAY_TYPE(keyword_indexes) keyword_list;
        const unsigned int *list;
        string_t *keyword;
@@ -276,8 +278,8 @@ static bool parse_x_keywords_real(struct mbox_sync_mail_context *ctx,
                str_truncate(keyword, 0);
                str_append_n(keyword, hdr->full_value + keyword_start,
                             pos - keyword_start);
-               if (!mail_index_keyword_lookup(ctx->sync_ctx->mbox->ibox.index,
-                                              str_c(keyword), &idx)) {
+               if (!mail_index_keyword_lookup(box->index, str_c(keyword),
+                                              &idx)) {
                        /* keyword wasn't found. that means the sent mail
                           originally contained X-Keywords header. Delete it. */
                        return FALSE;
index c68f25e19037d8478d8d8f6992d461ab1df03901..578ffa2233298143c4f45760058f7e90f244a726 100644 (file)
@@ -295,13 +295,14 @@ mbox_sync_update_from_offset(struct mbox_sync_context *sync_ctx,
 static void
 mbox_sync_update_index_keywords(struct mbox_sync_mail_context *mail_ctx)
 {
-        struct mbox_sync_context *sync_ctx = mail_ctx->sync_ctx;
+       struct mbox_sync_context *sync_ctx = mail_ctx->sync_ctx;
+       struct mail_index *index = sync_ctx->mbox->ibox.box.index;
        struct mail_keywords *keywords;
 
        keywords = !array_is_created(&mail_ctx->mail.keywords) ?
-               mail_index_keywords_create(sync_ctx->mbox->ibox.index, NULL) :
-               mail_index_keywords_create_from_indexes(
-                       sync_ctx->mbox->ibox.index, &mail_ctx->mail.keywords);
+               mail_index_keywords_create(index, NULL) :
+               mail_index_keywords_create_from_indexes(index,
+                       &mail_ctx->mail.keywords);
        mail_index_update_keywords(sync_ctx->t, sync_ctx->idx_seq,
                                   MODIFY_REPLACE, keywords);
        mail_index_keywords_unref(&keywords);
@@ -1389,7 +1390,7 @@ mbox_sync_index_update_ext_header(struct mbox_sync_context *sync_ctx)
                mail_generate_guid_128(mbox->mbox_hdr.mailbox_guid);
        }
 
-       mail_index_get_header_ext(mbox->ibox.view, mbox->mbox_ext_idx,
+       mail_index_get_header_ext(mbox->ibox.box.view, mbox->mbox_ext_idx,
                                  &data, &data_size);
        if (data_size != sizeof(mbox->mbox_hdr) ||
            memcmp(data, &mbox->mbox_hdr, data_size) != 0) {
@@ -1630,16 +1631,16 @@ int mbox_sync_header_refresh(struct mbox_mailbox *mbox)
        const void *data;
        size_t data_size;
 
-       if (mail_index_refresh(mbox->ibox.index) < 0) {
-               mail_storage_set_index_error(&mbox->ibox);
+       if (mail_index_refresh(mbox->ibox.box.index) < 0) {
+               mail_storage_set_index_error(&mbox->ibox.box);
                return -1;
        }
 
-       mail_index_get_header_ext(mbox->ibox.view, mbox->mbox_ext_idx,
+       mail_index_get_header_ext(mbox->ibox.box.view, mbox->mbox_ext_idx,
                                  &data, &data_size);
        if (data_size == 0) {
                /* doesn't exist. FIXME: backwards compatibility copying */
-               hdr = mail_index_get_header(mbox->ibox.view);
+               hdr = mail_index_get_header(mbox->ibox.box.view);
                mbox->mbox_hdr.sync_mtime = hdr->sync_stamp;
                mbox->mbox_hdr.sync_size = hdr->sync_size;
                return 0;
@@ -1797,11 +1798,11 @@ again:
        if ((flags & MBOX_SYNC_REWRITE) != 0)
                sync_flags |= MAIL_INDEX_SYNC_FLAG_FLUSH_DIRTY;
 
-       ret = mail_index_sync_begin(mbox->ibox.index, &index_sync_ctx,
+       ret = mail_index_sync_begin(mbox->ibox.box.index, &index_sync_ctx,
                                    &sync_view, &trans, sync_flags);
        if (ret <= 0) {
                if (ret < 0)
-                       mail_storage_set_index_error(&mbox->ibox);
+                       mail_storage_set_index_error(&mbox->ibox.box);
                return ret;
        }
 
@@ -1818,7 +1819,7 @@ again:
                /* index may need to do internal syncing though, so commit
                   instead of rollbacking. */
                if (mail_index_sync_commit(&index_sync_ctx) < 0) {
-                       mail_storage_set_index_error(&mbox->ibox);
+                       mail_storage_set_index_error(&mbox->ibox.box);
                        return -1;
                }
                return 0;
@@ -1842,7 +1843,7 @@ again:
                pool_alloconly_create("mbox saved keywords", 4096);
 
        /* make sure we've read the latest keywords in index */
-       (void)mail_index_get_keywords(mbox->ibox.index);
+       (void)mail_index_get_keywords(mbox->ibox.box.index);
 
        i_array_init(&sync_ctx.mails, 64);
 
@@ -1894,7 +1895,7 @@ again:
        if (ret < 0)
                mail_index_sync_rollback(&index_sync_ctx);
        else if (mail_index_sync_commit(&index_sync_ctx) < 0) {
-               mail_storage_set_index_error(&mbox->ibox);
+               mail_storage_set_index_error(&mbox->ibox.box);
                ret = -1;
        }
        sync_ctx.t = NULL;
index a145acc06495fc80f8d7cea4ac4059709c5b61f2..9b5902d0a1e1cd37e09b59d1aa55f5c2c8f77d2d 100644 (file)
@@ -50,7 +50,7 @@ raw_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list,
        mbox->ibox.box.pool = pool;
        mbox->ibox.box.storage = storage;
        mbox->ibox.box.list = list;
-       mbox->ibox.mail_vfuncs = &raw_mail_vfuncs;
+       mbox->ibox.box.mail_vfuncs = &raw_mail_vfuncs;
 
        index_storage_mailbox_alloc(&mbox->ibox, name, input, flags, NULL);
 
index 4120b22c37bc9a1790a2a65d4e9952dd26bf4802..4a9262f8e22a0cc6304b9eceb5d71ba488252033 100644 (file)
@@ -21,11 +21,11 @@ static int raw_sync(struct raw_mailbox *mbox)
        if ((mbox->ibox.box.flags & MAILBOX_FLAG_KEEP_RECENT) == 0)
                sync_flags |= MAIL_INDEX_SYNC_FLAG_DROP_RECENT;
 
-       ret = mail_index_sync_begin(mbox->ibox.index, &index_sync_ctx,
+       ret = mail_index_sync_begin(mbox->ibox.box.index, &index_sync_ctx,
                                    &sync_view, &trans, sync_flags);
        if (ret <= 0) {
                if (ret < 0)
-                       mail_storage_set_index_error(&mbox->ibox);
+                       mail_storage_set_index_error(&mbox->ibox.box);
                return ret;
        }
 
@@ -39,7 +39,7 @@ static int raw_sync(struct raw_mailbox *mbox)
        index_mailbox_set_recent_uid(&mbox->ibox, 1);
 
        if (mail_index_sync_commit(&index_sync_ctx) < 0) {
-               mail_storage_set_index_error(&mbox->ibox);
+               mail_storage_set_index_error(&mbox->ibox.box);
                return -1;
        }
        mbox->synced = TRUE;
index d29b8cbf50f931a9d949d0ece4c243c7fc88e0e3..3972738e7885a9a7e9d3ac43818bed1a910d931c 100644 (file)
@@ -95,11 +95,11 @@ static void test_index_storage_get_expunges(void)
        uint64_t modseq;
 
        ibox = t_new(struct index_mailbox, 1);
-       ibox->index = t_new(struct mail_index, 1);
-       ibox->view = t_new(struct mail_index_view, 1);
+       ibox->box.index = t_new(struct mail_index, 1);
+       ibox->box.view = t_new(struct mail_index_view, 1);
 
-       ibox->view->log_file_head_seq = 101;
-       ibox->view->log_file_head_offset = 1024;
+       ibox->box.view->log_file_head_seq = 101;
+       ibox->box.view->log_file_head_offset = 1024;
 
        test_begin("index storage get expunges");
 
index 4e5a8d1cb0260b0b0e476efdaa9a68fe367e0710..aa4b76c85d28ab8eebab284fc14aedfd78e24af3 100644 (file)
@@ -212,6 +212,13 @@ struct mailbox {
 /* private: */
        pool_t pool;
 
+       struct mail_index *index;
+       struct mail_index_view *view;
+       struct mail_cache *cache;
+
+       /* default vfuncs for new struct mails. */
+       const struct mail_vfuncs *mail_vfuncs;
+
        /* mailbox's MAILBOX_LIST_PATH_TYPE_MAILBOX */
        const char *path;
        /* mailbox's virtual name (from mail_namespace_get_vname()) */
@@ -425,6 +432,7 @@ void mail_storage_set_error(struct mail_storage *storage,
 void mail_storage_set_critical(struct mail_storage *storage,
                               const char *fmt, ...) ATTR_FORMAT(2, 3);
 void mail_storage_set_internal_error(struct mail_storage *storage);
+void mail_storage_set_index_error(struct mailbox *box);
 bool mail_storage_set_error_from_errno(struct mail_storage *storage);
 
 int mail_set_aborted(struct mail *mail);
index 6986b10e84dc4278f7d4d16c305721283a0092c6..99d23921675ddab00fd2212f838f8cd76ed349a4 100644 (file)
@@ -381,6 +381,15 @@ void mail_storage_set_critical(struct mail_storage *storage,
        }
 }
 
+void mail_storage_set_index_error(struct mailbox *box)
+{
+       if (mail_index_is_deleted(box->index))
+               mailbox_set_deleted(box);
+       else
+               mail_storage_set_internal_error(box->storage);
+       mail_index_reset_error(box->index);
+}
+
 const struct mail_storage_settings *
 mail_storage_get_settings(struct mail_storage *storage)
 {
index 2fd5c17e66ac4d5ab0eaf5b2234ac546e95c5e5b..06b1dd887c99e0d167c5470657557b5574bbde72 100644 (file)
@@ -116,7 +116,7 @@ static void virtual_mail_set_seq(struct mail *mail, uint32_t seq)
        const void *data;
        bool expunged;
 
-       mail_index_lookup_ext(mbox->ibox.view, seq, mbox->virtual_ext_id,
+       mail_index_lookup_ext(mail->box->view, seq, mbox->virtual_ext_id,
                              &data, &expunged);
        vrec = data;
 
@@ -130,7 +130,7 @@ static void virtual_mail_set_seq(struct mail *mail, uint32_t seq)
 
        vmail->imail.data.seq = seq;
        mail->seq = seq;
-       mail_index_lookup_uid(mbox->ibox.view, seq, &mail->uid);
+       mail_index_lookup_uid(mail->box->view, seq, &mail->uid);
 
        if (!vmail->lost) {
                mail->expunged = vmail->backend_mail->expunged;
@@ -145,10 +145,9 @@ static void virtual_mail_set_seq(struct mail *mail, uint32_t seq)
 
 static bool virtual_mail_set_uid(struct mail *mail, uint32_t uid)
 {
-       struct virtual_mailbox *mbox = (struct virtual_mailbox *)mail->box;
        uint32_t seq;
 
-       if (!mail_index_lookup_seq(mbox->ibox.view, uid, &seq))
+       if (!mail_index_lookup_seq(mail->box->view, uid, &seq))
                return FALSE;
 
        virtual_mail_set_seq(mail, seq);
index 7620864649a54f69328d88723a382d2b4418cff7..55a6ea277772925a6006129780356b8da73e1198 100644 (file)
@@ -82,7 +82,7 @@ static void virtual_search_get_records(struct mail_search_context *ctx,
                        seq_range_array_add(&vctx->result, 0, ctx->seq);
                } else {
                        /* possible match, save and check later */
-                       mail_index_lookup_ext(mbox->ibox.view, ctx->seq,
+                       mail_index_lookup_ext(mbox->ibox.box.view, ctx->seq,
                                              mbox->virtual_ext_id,
                                              &data, &expunged);
                        vrec = data;
index 2d54ba2fe2d71c7b0c8fb6ce9f5767e7bb05c526..b17fdac6fce0881482625127072c77bece98005f 100644 (file)
@@ -201,7 +201,7 @@ virtual_mailbox_alloc(struct mail_storage *_storage, struct mailbox_list *list,
        mbox->ibox.box.pool = pool;
        mbox->ibox.box.storage = _storage;
        mbox->ibox.box.list = list;
-       mbox->ibox.mail_vfuncs = &virtual_mail_vfuncs;
+       mbox->ibox.box.mail_vfuncs = &virtual_mail_vfuncs;
 
        index_storage_mailbox_alloc(&mbox->ibox, name, input, flags,
                                    VIRTUAL_INDEX_PREFIX);
@@ -210,7 +210,7 @@ virtual_mailbox_alloc(struct mail_storage *_storage, struct mailbox_list *list,
        mbox->vseq_lookup_prev_mailbox = i_strdup("");
 
        mbox->virtual_ext_id =
-               mail_index_ext_register(mbox->ibox.index, "virtual", 0,
+               mail_index_ext_register(mbox->ibox.box.index, "virtual", 0,
                        sizeof(struct virtual_mail_index_record),
                        sizeof(uint32_t));
        return &mbox->ibox.box;
index e86434d658ae3e161287966d7707c29a2c59ba17..511406f99c73347625200a86baf550ec14a420f1 100644 (file)
@@ -642,7 +642,6 @@ virtual_sync_backend_handle_old_vmsgs(struct virtual_sync_context *ctx,
                                      struct virtual_backend_box *bbox,
                                      struct mail_search_result *result)
 {
-       struct index_mailbox *ibox = (struct index_mailbox *)bbox->box;
        const struct virtual_mail_index_record *vrec;
        struct virtual_backend_uidmap uidmap;
        const void *data;
@@ -666,8 +665,8 @@ virtual_sync_backend_handle_old_vmsgs(struct virtual_sync_context *ctx,
                        uidmap.virtual_uid = vuid;
                        array_append(&bbox->uids, &uidmap, 1);
 
-                       if (mail_index_lookup_seq(ibox->view, vrec->real_uid,
-                                                 &seq)) {
+                       if (mail_index_lookup_seq(bbox->box->view,
+                                                 vrec->real_uid, &seq)) {
                                seq_range_array_add(&result->uids, 0,
                                                    vrec->real_uid);
                        } else {
@@ -686,7 +685,7 @@ static int virtual_sync_backend_box_continue(struct virtual_sync_context *ctx,
        const enum mailbox_search_result_flags result_flags =
                MAILBOX_SEARCH_RESULT_FLAG_UPDATE |
                MAILBOX_SEARCH_RESULT_FLAG_QUEUE_SYNC;
-       struct index_mailbox *ibox = (struct index_mailbox *)bbox->box;
+       struct mail_index_view *view = bbox->box->view;
        struct mail_search_result *result;
        ARRAY_TYPE(seq_range) removed_uids, added_uids, flag_update_uids;
        uint64_t modseq, old_highest_modseq;
@@ -703,17 +702,17 @@ static int virtual_sync_backend_box_continue(struct virtual_sync_context *ctx,
           virtual index), based on modseq changes. (we'll assume all modseq
           changes are due to flag changes, which may not be true in future) */
        if (bbox->sync_next_uid <= 1 ||
-           !mail_index_lookup_seq_range(ibox->view, 1, bbox->sync_next_uid-1,
+           !mail_index_lookup_seq_range(view, 1, bbox->sync_next_uid-1,
                                         &seq, &old_msg_count))
                old_msg_count = 0;
-       old_highest_modseq = mail_index_modseq_get_highest(ibox->view);
+       old_highest_modseq = mail_index_modseq_get_highest(view);
 
        t_array_init(&flag_update_uids, I_MIN(128, old_msg_count));
        if (bbox->sync_highest_modseq < old_highest_modseq) {
                for (seq = 1; seq <= old_msg_count; seq++) {
-                       modseq = mail_index_modseq_lookup(ibox->view, seq);
+                       modseq = mail_index_modseq_lookup(view, seq);
                        if (modseq > bbox->sync_highest_modseq) {
-                               mail_index_lookup_uid(ibox->view, seq, &uid);
+                               mail_index_lookup_uid(view, seq, &uid);
                                seq_range_array_add(&flag_update_uids, 0, uid);
                        }
                }
@@ -882,13 +881,12 @@ static bool virtual_sync_find_seqs(struct virtual_backend_box *bbox,
                                   unsigned int *idx1_r,
                                   unsigned int *idx2_r)
 {
-       struct index_mailbox *ibox = (struct index_mailbox *)bbox->box;
        const struct virtual_backend_uidmap *uidmap;
        unsigned int idx, count;
        uint32_t uid1, uid2;
 
-       mail_index_lookup_uid(ibox->view, sync_rec->seq1, &uid1);
-       mail_index_lookup_uid(ibox->view, sync_rec->seq2, &uid2);
+       mail_index_lookup_uid(bbox->box->view, sync_rec->seq1, &uid1);
+       mail_index_lookup_uid(bbox->box->view, sync_rec->seq2, &uid2);
        (void)array_bsearch_insert_pos(&bbox->uids, &uid1,
                                       virtual_backend_uidmap_bsearch_cmp,
                                       &idx);
@@ -907,13 +905,12 @@ static void virtual_sync_expunge_add(struct virtual_sync_context *ctx,
                                     struct virtual_backend_box *bbox,
                                     const struct mailbox_sync_rec *sync_rec)
 {
-       struct index_mailbox *ibox = (struct index_mailbox *)bbox->box;
        struct virtual_backend_uidmap *uidmap;
        uint32_t uid1, uid2;
        unsigned int i, idx1, count;
 
-       mail_index_lookup_uid(ibox->view, sync_rec->seq1, &uid1);
-       mail_index_lookup_uid(ibox->view, sync_rec->seq2, &uid2);
+       mail_index_lookup_uid(bbox->box->view, sync_rec->seq1, &uid1);
+       mail_index_lookup_uid(bbox->box->view, sync_rec->seq2, &uid2);
 
        /* remember only the expunges for messages that
           already exist for this mailbox */
@@ -1019,7 +1016,6 @@ static void virtual_sync_backend_ext_header(struct virtual_sync_context *ctx,
 static int virtual_sync_backend_box(struct virtual_sync_context *ctx,
                                    struct virtual_backend_box *bbox)
 {
-       struct index_mailbox *ibox = (struct index_mailbox *)bbox->box;
        enum mailbox_sync_flags sync_flags;
        struct mailbox_status status;
        int ret;
@@ -1034,7 +1030,7 @@ static int virtual_sync_backend_box(struct virtual_sync_context *ctx,
        virtual_backend_box_sync_mail_unset(bbox);
        /* we use modseqs for speeding up initial search result build.
           make sure the backend has them enabled. */
-       mail_index_modseq_enable(ibox->index);
+       mail_index_modseq_enable(bbox->box->index);
 
        sync_flags = ctx->flags & (MAILBOX_SYNC_FLAG_FULL_READ |
                                   MAILBOX_SYNC_FLAG_FULL_WRITE |
@@ -1356,7 +1352,7 @@ virtual_sync_apply_existing_expunges(struct virtual_mailbox *mbox,
 
        seq_range_array_iter_init(&iter, isync_ctx->expunges);
        while (seq_range_array_iter_nth(&iter, n++, &seq)) {
-               mail_index_lookup_ext(mbox->ibox.view, seq,
+               mail_index_lookup_ext(mbox->ibox.box.view, seq,
                                      mbox->virtual_ext_id, &data, &expunged);
                vrec = data;
 
@@ -1418,7 +1414,7 @@ static int virtual_sync_finish(struct virtual_sync_context *ctx, bool success)
        virtual_sync_backend_boxes_finish(ctx);
        if (success) {
                if (mail_index_sync_commit(&ctx->index_sync_ctx) < 0) {
-                       mail_storage_set_index_error(&ctx->mbox->ibox);
+                       mail_storage_set_index_error(&ctx->mbox->ibox.box);
                        ret = -1;
                }
        } else {
@@ -1447,7 +1443,7 @@ static int virtual_sync(struct virtual_mailbox *mbox,
        ctx = i_new(struct virtual_sync_context, 1);
        ctx->mbox = mbox;
        ctx->flags = flags;
-       ctx->index = mbox->ibox.index;
+       ctx->index = mbox->ibox.box.index;
        /* Removed messages are expunged when
           a) EXPUNGE is used
           b) Mailbox is being opened (FIX_INCONSISTENT is set) */
@@ -1465,7 +1461,7 @@ static int virtual_sync(struct virtual_mailbox *mbox,
                                    index_sync_flags);
        if (ret <= 0) {
                if (ret < 0)
-                       mail_storage_set_index_error(&mbox->ibox);
+                       mail_storage_set_index_error(&mbox->ibox.box);
                i_free(ctx);
                return ret;
        }