mail-index-transaction-view.c revision 48a1d109563d54542797e317a1d9efab22c5b1a1
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen/* Copyright (c) 2004-2009 Dovecot authors, see the included COPYING file */
e2bdca8201e4aa1cd31332ffbdd4c6eef9151d5eTimo Sirainenstatic void tview_close(struct mail_index_view *view)
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainenstatic uint32_t tview_get_message_count(struct mail_index_view *view)
b68b98e1545bad8af9cb58ef89e8d7f6e16577beAki Tuomi tview->t->last_new_seq - tview->t->first_new_seq + 1);
b68b98e1545bad8af9cb58ef89e8d7f6e16577beAki Tuomistatic const struct mail_index_header *
541f258d86b2db26efd5670883966183b4fb6323Timo Sirainen /* FIXME: header counters may not be correct */
541f258d86b2db26efd5670883966183b4fb6323Timo Sirainen next_uid = mail_index_transaction_get_next_uid(tview->t);
b68b98e1545bad8af9cb58ef89e8d7f6e16577beAki Tuomistatic const struct mail_index_record *
b68b98e1545bad8af9cb58ef89e8d7f6e16577beAki Tuomitview_apply_flag_updates(struct mail_index_view_transaction *tview,
b68b98e1545bad8af9cb58ef89e8d7f6e16577beAki Tuomi const struct mail_index_record *rec, uint32_t seq)
541f258d86b2db26efd5670883966183b4fb6323Timo Sirainen const struct mail_transaction_flag_update *updates;
541f258d86b2db26efd5670883966183b4fb6323Timo Sirainen /* see if there are any flag updates */
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen if (seq < t->min_flagupdate_seq || seq > t->max_flagupdate_seq ||
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen idx = mail_index_transaction_get_flag_update_pos(t, 0, count, seq);
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen if (seq < updates[idx].uid1 || seq > updates[idx].uid2)
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen /* yes, we have flag updates. since we can't modify rec directly and
4d4d6d4745682790c20d759ba93dbea46b812c5dTimo Sirainen we want to be able to handle multiple mail_index_lookup() calls
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen without the second one overriding the first one's data, we'll
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen create a records array and return data from there */
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen tview->record_size = I_MAX(map->hdr.record_size,
578ef2538ccf42e2a48234c24a8b709397101d88Timo Sirainen i_assert(tview->recs_count == t->first_new_seq);
9b0f6b90ff8d1d6efd718b0d7cbe01b2454e9fd6Timo Sirainen i_assert(seq > 0 && seq <= tview->recs_count);
9b0f6b90ff8d1d6efd718b0d7cbe01b2454e9fd6Timo Sirainen i_assert(map->hdr.record_size <= tview->record_size);
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen trec = PTR_OFFSET(tview->recs, (seq-1) * tview->record_size);
d6b3cfd855c0eebed68be50d3111de1b5a6afeb0Timo Sirainenstatic const struct mail_index_record *
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainentview_lookup_full(struct mail_index_view *view, uint32_t seq,
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen struct mail_index_map **map_r, bool *expunged_r)
d5eb47a791ec56149fd711cd8e44efc8babeaae5Timo Sirainen /* FIXME: is this right to return index map..?
d5eb47a791ec56149fd711cd8e44efc8babeaae5Timo Sirainen it's not there yet. */
719abeb2088987f213a33a7dd1fe78958beaef03Timo Sirainen return mail_index_transaction_lookup(tview->t, seq);
f6f23086d0259d50cde3bd5d4180d67d820d293dTimo Sirainen rec = tview->super->lookup_full(view, seq, map_r, expunged_r);
f6f23086d0259d50cde3bd5d4180d67d820d293dTimo Sirainen rec = tview_apply_flag_updates(tview, *map_r, rec, seq);
f6f23086d0259d50cde3bd5d4180d67d820d293dTimo Sirainen if (mail_index_transaction_is_expunged(tview->t, seq))
3f603ef00e35fca21605afa0ad8d76e94fee2b96Timo Sirainentview_lookup_uid(struct mail_index_view *view, uint32_t seq, uint32_t *uid_r)
86791365b10f45982c88e70f2eb94fd6c3fea151Timo Sirainen *uid_r = mail_index_transaction_lookup(tview->t, seq)->uid;
ccf50662cc02b5e703039a4ff7f91a4470e25b71Timo Sirainenstatic void tview_lookup_seq_range(struct mail_index_view *view,
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen tview->super->lookup_seq_range(view, first_uid, last_uid,
1ffb2afe6d7e8860a2231a4827078cf2ef9c22cdTimo Sirainen /* index is being reset. we never want to return old
1ffb2afe6d7e8860a2231a4827078cf2ef9c22cdTimo Sirainen sequences. */
0161376aac025266d8654577c4b9ce371ffc87eaTimo Sirainen /* no new messages, the results are final. */
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen rec = mail_index_transaction_lookup(tview->t, tview->t->first_new_seq);
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen /* new messages don't have UIDs */
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen /* all wanted messages were existing */
7f1b897201d80c83c96b0d663f2a14c517d48f14Timo Sirainen /* at least some of the wanted messages are newly created */
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen for (; seq <= tview->t->last_new_seq; seq++) {
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen rec = mail_index_transaction_lookup(tview->t, seq);
b2d562f9c7fd13f9a16e9b3bcee904630b80b1feTimo Sirainen /* no messages in range */
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen for (; seq >= tview->t->first_new_seq; seq--) {
275385a2ecc58e41dc7df3ce3cd943caaa58c4d1Timo Sirainen rec = mail_index_transaction_lookup(tview->t, seq);
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainenstatic void tview_lookup_first(struct mail_index_view *view,
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen tview->super->lookup_first(view, flags, flags_mask, seq_r);
f158d9a303bb15a6848ca276c9391c7ca52e452bTimo Sirainen rec = array_get(&tview->t->appends, &append_count);
6303f32ad4af9cb08794561e6324df1c6c5fb637Timo Sirainen i_assert(append_count == message_count - seq + 1);
754896551f0422cda5d78500b26700eec5343c5bAki Tuomi if ((rec->flags & flags_mask) == (uint8_t)flags) {
unsigned int idx)
const unsigned int *indexes;
unsigned int i, count;
for (i = 0; i < count; i++) {
unsigned int idx)
const unsigned int *indexes;
unsigned int i, count;
for (i = 0; i < count; i++) {
unsigned int i, count;
count = 0;
for (i = 0; i < count; i++) {
static struct mail_index_map *
return data;
const void *data;
unsigned int idx;
ext_id);
return TRUE;
struct mail_index_view *
return t->view;
tview->t = t;