mail-index-transaction-view.c revision 5d27987496b12dbad8c78aba5a9ccc74e6606623
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen/* Copyright (C) 2004-2006 Timo Sirainen */
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen#include "lib.h"
bdd36cfdba3ff66d25570a9ff568d69e1eb543cfTimo Sirainen#include "array.h"
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen#include "buffer.h"
9c6a09aa16095ff72837799a37e0e3b3e93bb3d8Timo Sirainen#include "seq-range-array.h"
31a9637b38d37451b649c86301b2c12e53a7810eTimo Sirainen#include "mail-index-private.h"
9c6a09aa16095ff72837799a37e0e3b3e93bb3d8Timo Sirainen#include "mail-index-view-private.h"
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen#include "mail-index-transaction-private.h"
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainenstruct mail_index_view_transaction {
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen struct mail_index_view view;
6d2b3ce2c6ef62334985ece4f0ab8b154e0e9560Timo Sirainen struct mail_index_view_methods *parent;
c6335901c67a4c9365319190a111a2168f3b06f5Timo Sirainen struct mail_index_transaction *t;
c6335901c67a4c9365319190a111a2168f3b06f5Timo Sirainen};
c6335901c67a4c9365319190a111a2168f3b06f5Timo Sirainen
01230de017cd273de41143d88e9c18df1243ae8aTimo Sirainenstatic void _tview_close(struct mail_index_view *view)
b7b9d4be2a1ff399026a5d6feeffd3a048f22be0Timo Sirainen{
b7b9d4be2a1ff399026a5d6feeffd3a048f22be0Timo Sirainen struct mail_index_view_transaction *tview =
047c00cd3f7f403672f81569413669238df8c15aTimo Sirainen (struct mail_index_view_transaction *)view;
1f9d1bedae25d86f26c239055c5487499dfeeb58Timo Sirainen
047c00cd3f7f403672f81569413669238df8c15aTimo Sirainen mail_index_transaction_unref(&tview->t);
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen tview->parent->close(view);
f37ecd72aad9b806aae83f71bacafdce32146945Timo Sirainen}
f37ecd72aad9b806aae83f71bacafdce32146945Timo Sirainen
e2bdca8201e4aa1cd31332ffbdd4c6eef9151d5eTimo Sirainenstatic uint32_t _tview_get_message_count(struct mail_index_view *view)
e2bdca8201e4aa1cd31332ffbdd4c6eef9151d5eTimo Sirainen{
e2bdca8201e4aa1cd31332ffbdd4c6eef9151d5eTimo Sirainen struct mail_index_view_transaction *tview =
32b78da5dfbbf6a06b3dbdc9278c60b55714f9bcTimo Sirainen (struct mail_index_view_transaction *)view;
32b78da5dfbbf6a06b3dbdc9278c60b55714f9bcTimo Sirainen
32b78da5dfbbf6a06b3dbdc9278c60b55714f9bcTimo Sirainen return view->hdr.messages_count +
32b78da5dfbbf6a06b3dbdc9278c60b55714f9bcTimo Sirainen (tview->t->last_new_seq == 0 ? 0 :
8b5c520883aa37bb55646286d375fdbae294d710Timo Sirainen tview->t->last_new_seq - tview->t->first_new_seq);
8b5c520883aa37bb55646286d375fdbae294d710Timo Sirainen}
0679f8a70a8dda43b204ae35fc6a903818cc6584Timo Sirainen
0679f8a70a8dda43b204ae35fc6a903818cc6584Timo Sirainenstatic const struct mail_index_header *
0679f8a70a8dda43b204ae35fc6a903818cc6584Timo Sirainen_tview_get_header(struct mail_index_view *view)
0679f8a70a8dda43b204ae35fc6a903818cc6584Timo Sirainen{
b63e20ea9bc84f1aa90a551f217d01385e070b73Timo Sirainen struct mail_index_view_transaction *tview =
b63e20ea9bc84f1aa90a551f217d01385e070b73Timo Sirainen (struct mail_index_view_transaction *)view;
b63e20ea9bc84f1aa90a551f217d01385e070b73Timo Sirainen
b63e20ea9bc84f1aa90a551f217d01385e070b73Timo Sirainen /* FIXME: header counters may not be correct */
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen return tview->parent->get_header(view);
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen}
b68b98e1545bad8af9cb58ef89e8d7f6e16577beAki Tuomi
b68b98e1545bad8af9cb58ef89e8d7f6e16577beAki Tuomistatic int _tview_lookup_full(struct mail_index_view *view, uint32_t seq,
b68b98e1545bad8af9cb58ef89e8d7f6e16577beAki Tuomi struct mail_index_map **map_r,
b68b98e1545bad8af9cb58ef89e8d7f6e16577beAki Tuomi const struct mail_index_record **rec_r)
b68b98e1545bad8af9cb58ef89e8d7f6e16577beAki Tuomi{
b68b98e1545bad8af9cb58ef89e8d7f6e16577beAki Tuomi struct mail_index_view_transaction *tview =
b68b98e1545bad8af9cb58ef89e8d7f6e16577beAki Tuomi (struct mail_index_view_transaction *)view;
b68b98e1545bad8af9cb58ef89e8d7f6e16577beAki Tuomi int ret;
b68b98e1545bad8af9cb58ef89e8d7f6e16577beAki Tuomi
b68b98e1545bad8af9cb58ef89e8d7f6e16577beAki Tuomi if (seq >= tview->t->first_new_seq) {
b68b98e1545bad8af9cb58ef89e8d7f6e16577beAki Tuomi /* FIXME: is this right to return index map..?
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen it's not there yet. */
541f258d86b2db26efd5670883966183b4fb6323Timo Sirainen *map_r = view->index->map;
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen *rec_r = mail_index_transaction_lookup(tview->t, seq);
541f258d86b2db26efd5670883966183b4fb6323Timo Sirainen return 1;
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen }
541f258d86b2db26efd5670883966183b4fb6323Timo Sirainen
f7423cbbd9dea363a5df18ebb96da055a977ae79Timo Sirainen ret = tview->parent->lookup_full(view, seq, map_r, rec_r);
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen if (ret <= 0)
541f258d86b2db26efd5670883966183b4fb6323Timo Sirainen return ret;
541f258d86b2db26efd5670883966183b4fb6323Timo Sirainen
72f21884c0bb9bb26edad63623427ac2120901eaStephan Bosch /* if we're expunged within this transaction, return 0 */
009217abb57a24a4076092e8e4e165545747839eStephan Bosch return array_is_created(&tview->t->expunges) &&
72f21884c0bb9bb26edad63623427ac2120901eaStephan Bosch seq_range_exists(&tview->t->expunges, seq) ? 0 : 1;
541f258d86b2db26efd5670883966183b4fb6323Timo Sirainen
72f21884c0bb9bb26edad63623427ac2120901eaStephan Bosch}
009217abb57a24a4076092e8e4e165545747839eStephan Bosch
7487ff578435377bbeefffdbfb78ca09ed1292dfTimo Sirainenstatic int _tview_lookup_uid(struct mail_index_view *view, uint32_t seq,
b68b98e1545bad8af9cb58ef89e8d7f6e16577beAki Tuomi uint32_t *uid_r)
b68b98e1545bad8af9cb58ef89e8d7f6e16577beAki Tuomi{
b68b98e1545bad8af9cb58ef89e8d7f6e16577beAki Tuomi struct mail_index_view_transaction *tview =
b68b98e1545bad8af9cb58ef89e8d7f6e16577beAki Tuomi (struct mail_index_view_transaction *)view;
b68b98e1545bad8af9cb58ef89e8d7f6e16577beAki Tuomi
b68b98e1545bad8af9cb58ef89e8d7f6e16577beAki Tuomi if (seq >= tview->t->first_new_seq) {
541f258d86b2db26efd5670883966183b4fb6323Timo Sirainen *uid_r = mail_index_transaction_lookup(tview->t, seq)->uid;
541f258d86b2db26efd5670883966183b4fb6323Timo Sirainen return 0;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen } else {
541f258d86b2db26efd5670883966183b4fb6323Timo Sirainen return tview->parent->lookup_uid(view, seq, uid_r);
541f258d86b2db26efd5670883966183b4fb6323Timo Sirainen }
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen}
db693bf6fcae96d834567f1782257517b7207655Timo Sirainen
541f258d86b2db26efd5670883966183b4fb6323Timo Sirainenstatic int _tview_lookup_uid_range(struct mail_index_view *view,
541f258d86b2db26efd5670883966183b4fb6323Timo Sirainen uint32_t first_uid, uint32_t last_uid,
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen uint32_t *first_seq_r, uint32_t *last_seq_r)
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen{
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen struct mail_index_view_transaction *tview =
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen (struct mail_index_view_transaction *)view;
db693bf6fcae96d834567f1782257517b7207655Timo Sirainen
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen if (tview->parent->lookup_uid_range(view, first_uid, last_uid,
4d4d6d4745682790c20d759ba93dbea46b812c5dTimo Sirainen first_seq_r, last_seq_r) < 0)
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen return -1;
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen /* FIXME: we don't need this function yet.. new UIDs might be 0 as
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen well.. */
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen if (*first_seq_r == 0) {
a3fe8c0c54d87822f4b4f8f0d10caac611861b2bTimo Sirainen /* nothing found, either doesn't exist or it's completely
578ef2538ccf42e2a48234c24a8b709397101d88Timo Sirainen newly appended. */
578ef2538ccf42e2a48234c24a8b709397101d88Timo Sirainen } else if (*last_seq_r + 1 == tview->t->first_new_seq) {
578ef2538ccf42e2a48234c24a8b709397101d88Timo Sirainen /* last_seq_r may be growed from transactions */
9b0f6b90ff8d1d6efd718b0d7cbe01b2454e9fd6Timo Sirainen }
9b0f6b90ff8d1d6efd718b0d7cbe01b2454e9fd6Timo Sirainen
9b0f6b90ff8d1d6efd718b0d7cbe01b2454e9fd6Timo Sirainen return 0;
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen}
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainenstatic int _tview_lookup_first(struct mail_index_view *view,
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen enum mail_flags flags, uint8_t flags_mask,
d6b3cfd855c0eebed68be50d3111de1b5a6afeb0Timo Sirainen uint32_t *seq_r)
d6b3cfd855c0eebed68be50d3111de1b5a6afeb0Timo Sirainen{
d6b3cfd855c0eebed68be50d3111de1b5a6afeb0Timo Sirainen struct mail_index_view_transaction *tview =
d6b3cfd855c0eebed68be50d3111de1b5a6afeb0Timo Sirainen (struct mail_index_view_transaction *)view;
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen const struct mail_index_record *rec;
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen unsigned int append_count;
8a0a8c982a6ffc75a4b1c8717b6180a811655794Timo Sirainen uint32_t seq, message_count;
8a0a8c982a6ffc75a4b1c8717b6180a811655794Timo Sirainen
8a0a8c982a6ffc75a4b1c8717b6180a811655794Timo Sirainen if (tview->parent->lookup_first(view, flags, flags_mask, seq_r) < 0)
8a0a8c982a6ffc75a4b1c8717b6180a811655794Timo Sirainen return -1;
8a0a8c982a6ffc75a4b1c8717b6180a811655794Timo Sirainen
d5eb47a791ec56149fd711cd8e44efc8babeaae5Timo Sirainen if (*seq_r != 0)
d5eb47a791ec56149fd711cd8e44efc8babeaae5Timo Sirainen return 0;
d5eb47a791ec56149fd711cd8e44efc8babeaae5Timo Sirainen
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen rec = array_get(&tview->t->appends, &append_count);
719abeb2088987f213a33a7dd1fe78958beaef03Timo Sirainen seq = tview->t->first_new_seq;
719abeb2088987f213a33a7dd1fe78958beaef03Timo Sirainen message_count = tview->t->last_new_seq;
e0740628f6ca05f4bc79a9d8a90b650f4d38d4d0Timo Sirainen i_assert(append_count == message_count - seq + 1);
e0740628f6ca05f4bc79a9d8a90b650f4d38d4d0Timo Sirainen
f6f23086d0259d50cde3bd5d4180d67d820d293dTimo Sirainen for (; seq <= message_count; seq++, rec++) {
f6f23086d0259d50cde3bd5d4180d67d820d293dTimo Sirainen if ((rec->flags & flags_mask) == (uint8_t)flags) {
f6f23086d0259d50cde3bd5d4180d67d820d293dTimo Sirainen *seq_r = seq;
f6f23086d0259d50cde3bd5d4180d67d820d293dTimo Sirainen break;
f6f23086d0259d50cde3bd5d4180d67d820d293dTimo Sirainen }
f6f23086d0259d50cde3bd5d4180d67d820d293dTimo Sirainen }
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen
3f603ef00e35fca21605afa0ad8d76e94fee2b96Timo Sirainen return 0;
3f603ef00e35fca21605afa0ad8d76e94fee2b96Timo Sirainen}
3f603ef00e35fca21605afa0ad8d76e94fee2b96Timo Sirainen
3f603ef00e35fca21605afa0ad8d76e94fee2b96Timo Sirainenstatic int
86791365b10f45982c88e70f2eb94fd6c3fea151Timo Sirainen_tview_lookup_ext_full(struct mail_index_view *view, uint32_t seq,
86791365b10f45982c88e70f2eb94fd6c3fea151Timo Sirainen uint32_t ext_id, struct mail_index_map **map_r,
86791365b10f45982c88e70f2eb94fd6c3fea151Timo Sirainen const void **data_r)
86791365b10f45982c88e70f2eb94fd6c3fea151Timo Sirainen{
86791365b10f45982c88e70f2eb94fd6c3fea151Timo Sirainen struct mail_index_view_transaction *tview =
ccf50662cc02b5e703039a4ff7f91a4470e25b71Timo Sirainen (struct mail_index_view_transaction *)view;
ccf50662cc02b5e703039a4ff7f91a4470e25b71Timo Sirainen const array_t *ext_buf;
ccf50662cc02b5e703039a4ff7f91a4470e25b71Timo Sirainen ARRAY_SET_TYPE(ext_buf, void *);
ccf50662cc02b5e703039a4ff7f91a4470e25b71Timo Sirainen const void *data;
ccf50662cc02b5e703039a4ff7f91a4470e25b71Timo Sirainen unsigned int idx;
6fdfa4d4cf14d1d7764d7faa8258f112e39c8dbeTimo Sirainen
6fdfa4d4cf14d1d7764d7faa8258f112e39c8dbeTimo Sirainen i_assert(ext_id < array_count(&view->index->extensions));
6fdfa4d4cf14d1d7764d7faa8258f112e39c8dbeTimo Sirainen
6fdfa4d4cf14d1d7764d7faa8258f112e39c8dbeTimo Sirainen *map_r = view->index->map;
6fdfa4d4cf14d1d7764d7faa8258f112e39c8dbeTimo Sirainen
3f603ef00e35fca21605afa0ad8d76e94fee2b96Timo Sirainen if (array_is_created(&tview->t->ext_rec_updates) &&
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen ext_id < array_count(&tview->t->ext_rec_updates)) {
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen /* there are some ext updates in transaction.
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen see if there's any for this sequence. */
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen ext_buf = array_idx(&tview->t->ext_rec_updates, ext_id);
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen if (array_is_created(ext_buf) &&
1ffb2afe6d7e8860a2231a4827078cf2ef9c22cdTimo Sirainen mail_index_seq_array_lookup(ext_buf, seq, &idx)) {
1ffb2afe6d7e8860a2231a4827078cf2ef9c22cdTimo Sirainen data = array_idx(ext_buf, idx);
1ffb2afe6d7e8860a2231a4827078cf2ef9c22cdTimo Sirainen *data_r = CONST_PTR_OFFSET(data, sizeof(uint32_t));
d4845c4245638fd6f02dc0cb92c3465fae763cbbTimo Sirainen return 1;
d4845c4245638fd6f02dc0cb92c3465fae763cbbTimo Sirainen }
0161376aac025266d8654577c4b9ce371ffc87eaTimo Sirainen }
0161376aac025266d8654577c4b9ce371ffc87eaTimo Sirainen
0161376aac025266d8654577c4b9ce371ffc87eaTimo Sirainen /* not updated, return the existing value */
0161376aac025266d8654577c4b9ce371ffc87eaTimo Sirainen if (seq < tview->t->first_new_seq) {
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen return tview->parent->lookup_ext_full(view, seq, ext_id,
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen map_r, data_r);
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen }
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen *data_r = NULL;
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen return 1;
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen}
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainenstatic int _tview_get_header_ext(struct mail_index_view *view,
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen struct mail_index_map *map, uint32_t ext_id,
7f1b897201d80c83c96b0d663f2a14c517d48f14Timo Sirainen const void **data_r, size_t *data_size_r)
7f1b897201d80c83c96b0d663f2a14c517d48f14Timo Sirainen{
7f1b897201d80c83c96b0d663f2a14c517d48f14Timo Sirainen struct mail_index_view_transaction *tview =
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen (struct mail_index_view_transaction *)view;
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen /* FIXME: check updates */
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen return tview->parent->get_header_ext(view, map, ext_id,
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen data_r, data_size_r);
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen}
b2d562f9c7fd13f9a16e9b3bcee904630b80b1feTimo Sirainen
b2d562f9c7fd13f9a16e9b3bcee904630b80b1feTimo Sirainenstatic struct mail_index_view_methods view_methods = {
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen _tview_close,
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen _tview_get_message_count,
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen _tview_get_header,
a10ed8c47534b4c6b6bf2711ccfe577e720a47b4Timo Sirainen _tview_lookup_full,
a10ed8c47534b4c6b6bf2711ccfe577e720a47b4Timo Sirainen _tview_lookup_uid,
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen _tview_lookup_uid_range,
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen _tview_lookup_first,
275385a2ecc58e41dc7df3ce3cd943caaa58c4d1Timo Sirainen _tview_lookup_ext_full,
275385a2ecc58e41dc7df3ce3cd943caaa58c4d1Timo Sirainen _tview_get_header_ext
275385a2ecc58e41dc7df3ce3cd943caaa58c4d1Timo Sirainen};
71df09024cea5f2faa93da3bb9513ee96ba6bf22Timo Sirainen
71df09024cea5f2faa93da3bb9513ee96ba6bf22Timo Sirainenstruct mail_index_view *
57397188558fcd1a9e24dbbbd2952eac9c45c20dTimo Sirainenmail_index_transaction_open_updated_view(struct mail_index_transaction *t)
03baa1c4c51f7b08fb285e82b528fcb00ac09ebfTimo Sirainen{
03baa1c4c51f7b08fb285e82b528fcb00ac09ebfTimo Sirainen struct mail_index_view_transaction *tview;
57397188558fcd1a9e24dbbbd2952eac9c45c20dTimo Sirainen
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen if (t->view->syncing) {
6c2ce1d5bf17b21e804a079eb0f973b7ab83e0d8Timo Sirainen /* transaction view is being synced. while it's done, it's not
6c2ce1d5bf17b21e804a079eb0f973b7ab83e0d8Timo Sirainen possible to add new messages, but the view itself might
db693bf6fcae96d834567f1782257517b7207655Timo Sirainen change. so we can't make a copy of the view. */
db693bf6fcae96d834567f1782257517b7207655Timo Sirainen mail_index_view_ref(t->view);
21e6b4fd844fd074583b17f09e1f27b9835ee238Timo Sirainen return t->view;
21e6b4fd844fd074583b17f09e1f27b9835ee238Timo Sirainen }
21e6b4fd844fd074583b17f09e1f27b9835ee238Timo Sirainen
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen tview = i_new(struct mail_index_view_transaction, 1);
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen mail_index_view_clone(&tview->view, t->view);
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen tview->view.methods = view_methods;
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen tview->parent = &t->view->methods;
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen tview->t = t;
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen
f158d9a303bb15a6848ca276c9391c7ca52e452bTimo Sirainen mail_index_transaction_ref(t);
f158d9a303bb15a6848ca276c9391c7ca52e452bTimo Sirainen return &tview->view;
f158d9a303bb15a6848ca276c9391c7ca52e452bTimo Sirainen}
f158d9a303bb15a6848ca276c9391c7ca52e452bTimo Sirainen