mail-index-transaction-view.c revision 382d45f2557a5e8c787e6170491a6d881d30d195
/* Copyright (c) 2004-2016 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "buffer.h"
#include "seq-range-array.h"
#include "mail-index-private.h"
#include "mail-index-view-private.h"
#include "mail-index-transaction-private.h"
struct mail_index_view_transaction {
struct mail_index_view view;
struct mail_index_view_vfuncs *super;
struct mail_index_transaction *t;
struct mail_index_map *lookup_map;
struct mail_index_header hdr;
unsigned int record_size;
unsigned int recs_count;
void *recs;
};
{
struct mail_index_view_transaction *tview =
(struct mail_index_view_transaction *)view;
struct mail_index_transaction *t = tview->t;
void **recs;
unsigned int i, count;
for (i = 0; i < count; i++)
}
}
{
struct mail_index_view_transaction *tview =
(struct mail_index_view_transaction *)view;
(tview->t->last_new_seq == 0 ? 0 :
}
static const struct mail_index_header *
{
struct mail_index_view_transaction *tview =
(struct mail_index_view_transaction *)view;
const struct mail_index_header *hdr;
/* FIXME: header counters may not be correct */
}
return hdr;
}
static const struct mail_index_record *
struct mail_index_map *map,
{
struct mail_index_transaction *t = tview->t;
const struct mail_index_flag_update *updates;
struct mail_index_record *trec;
/* see if there are any flag updates */
!array_is_created(&t->updates))
return rec;
return rec;
/* yes, we have flag updates. since we can't modify rec directly and
we want to be able to handle multiple mail_index_lookup() calls
without the second one overriding the first one's data, we'll
create a records array and return data from there.
it's also possible that the record size increases, so we potentially
have to create multiple arrays. they all get eventually freed when
the view gets freed. */
tview->recs_count);
}
return trec;
}
static const struct mail_index_record *
{
struct mail_index_view_transaction *tview =
(struct mail_index_view_transaction *)view;
const struct mail_index_record *rec;
/* FIXME: is this right to return index map..?
it's not there yet. */
if (expunged_r != NULL)
*expunged_r = FALSE;
}
if (expunged_r != NULL &&
*expunged_r = TRUE;
return rec;
}
static void
{
struct mail_index_view_transaction *tview =
(struct mail_index_view_transaction *)view;
else
}
{
struct mail_index_view_transaction *tview =
(struct mail_index_view_transaction *)view;
const struct mail_index_record *rec;
} else {
/* index is being reset. we never want to return old
sequences. */
*first_seq_r = *last_seq_r = 0;
}
if (tview->t->last_new_seq == 0) {
/* no new messages, the results are final. */
return;
}
/* new messages don't have UIDs */
return;
}
/* all wanted messages were existing */
return;
}
/* at least some of the wanted messages are newly created */
if (*first_seq_r == 0) {
break;
}
/* no messages in range */
return;
}
*first_seq_r = seq;
/* one seq in range */
*last_seq_r = seq;
return;
}
}
*last_seq_r = seq;
break;
}
}
}
{
struct mail_index_view_transaction *tview =
(struct mail_index_view_transaction *)view;
const struct mail_index_record *rec;
unsigned int append_count;
if (*seq_r != 0)
return;
} else {
*seq_r = 0;
}
break;
}
}
}
unsigned int idx)
{
const unsigned int *indexes;
unsigned int i, count;
for (i = 0; i < count; i++) {
return;
}
}
unsigned int idx)
{
const unsigned int *indexes;
unsigned int i, count;
for (i = 0; i < count; i++) {
break;
}
}
}
{
struct mail_index_view_transaction *tview =
(struct mail_index_view_transaction *)view;
struct mail_index_transaction *t = tview->t;
const struct mail_index_transaction_keyword_update *updates;
unsigned int i, count;
/* no keyword updates for this sequence */
return;
}
if (array_is_created(&t->keyword_updates))
else {
count = 0;
}
for (i = 0; i < count; i++) {
}
}
static const void *
{
const struct mail_index_ext *ext;
const struct mail_index_registered_ext *rext;
const struct mail_transaction_ext_intro *intro;
unsigned int record_align, record_size;
/* data begins with a 32bit sequence, followed by the actual
extension data */
/* we're adding the extension now. */
} else {
}
/* see if the extension has been resized within this transaction */
}
}
if (record_align <= sizeof(uint32_t)) {
/* data is 32bit aligned already */
return data;
} else {
/* assume we want 64bit alignment - copy the data to
temporary buffer and return it */
record_size + 64);
/* clear the buffer between lookups for different
messages */
}
}
}
static bool
{
const struct mail_transaction_ext_reset *resets;
unsigned int count;
return FALSE;
}
static bool
const void **data_r)
{
const void *data;
unsigned int idx;
if (!array_is_created(ext_buf) ||
return FALSE;
tview->lookup_map =
}
/* extension doesn't yet exist in the map. add it there with
the preliminary information (mainly its size) so if caller
looks it up, it's going to be found. */
const struct mail_index_registered_ext *rext =
struct mail_index_ext_header ext_hdr;
}
return TRUE;
}
static void
const void **data_r, bool *expunged_r)
{
struct mail_index_view_transaction *tview =
(struct mail_index_view_transaction *)view;
if (expunged_r != NULL)
*expunged_r = FALSE;
/* there are some ext updates in transaction.
see if there's any for this sequence. */
return;
}
/* not updated, return the existing value, unless ext was
already reset */
} else {
}
}
{
struct mail_index_view_transaction *tview =
(struct mail_index_view_transaction *)view;
/* FIXME: check updates */
}
struct mail_index_map *map,
{
struct mail_index_view_transaction *tview =
(struct mail_index_view_transaction *)view;
const uint32_t *reset_id_p;
*reset_id_r = *reset_id_p;
return TRUE;
}
}
static struct mail_index_view_vfuncs trans_view_vfuncs = {
};
struct mail_index_view *
{
struct mail_index_view_transaction *tview;
/* transaction view is being synced. while it's done, it's not
possible to add new messages, but the view itself might
change. so we can't make a copy of the view. */
mail_index_view_ref(t->view);
return t->view;
}
tview->t = t;
}