mail-index-transaction.c revision b44a50ea4123f21dfc8e1b6c602f690fd9721b67
/* Copyright (C) 2003-2004 Timo Sirainen */
/* Inside transaction we keep messages stored in sequences in uid fields.
Before they're written to transaction log the sequences are changed to
UIDs. This is because we're able to compress sequence ranges better. */
#include "lib.h"
#include "buffer.h"
#include "mail-index-view-private.h"
#include "mail-transaction-log.h"
#include "mail-index-transaction-private.h"
#include <stddef.h>
static void mail_index_transaction_add_last(struct mail_index_transaction *t);
struct mail_index_transaction *
{
struct mail_index_transaction *t;
/* don't allow syncing view while there's ongoing transactions */
t->hide_transaction = hide;
return t;
}
static void mail_index_transaction_free(struct mail_index_transaction *t)
{
unsigned int i;
if (t->extra_rec_updates[i] != NULL)
buffer_free(t->extra_rec_updates[i]);
}
buffer_free(t->appends);
buffer_free(t->expunges);
buffer_free(t->updates);
if (t->cache_updates != NULL)
buffer_free(t->cache_updates);
i_free(t);
}
static void
{
unsigned char *data;
return;
/* @UNSAFE */
for (i = 0; i < size; i += record_size) {
if (range) {
}
}
}
static int
{
unsigned int i;
if (mail_index_view_lock(t->view) < 0)
return -1;
for (i = 0; i < index->extra_records_count; i++) {
if (t->extra_rec_updates[i] == NULL)
continue;
t->extra_rec_updates[i],
sizeof(uint32_t) +
FALSE);
}
sizeof(struct mail_transaction_expunge), TRUE);
sizeof(struct mail_transaction_flag_update), TRUE);
sizeof(struct mail_transaction_cache_update), FALSE);
return 0;
}
int mail_index_transaction_commit(struct mail_index_transaction *t,
{
int ret;
if (mail_index_view_is_inconsistent(t->view)) {
return -1;
}
if (t->last_update.uid1 != 0)
if (mail_index_transaction_convert_to_uids(t) < 0)
ret = -1;
else {
}
return ret;
}
void mail_index_transaction_rollback(struct mail_index_transaction *t)
{
}
static struct mail_index_record *
{
}
int mail_index_transaction_lookup(struct mail_index_transaction *t,
const struct mail_index_record **rec_r)
{
return 1;
} else {
}
}
{
struct mail_index_record *rec;
}
/* sequence number is visible only inside given view,
so let it generate it */
if (t->last_new_seq != 0)
*seq_r = ++t->last_new_seq;
else {
}
}
{
/* expunges is a sorted array of {seq1, seq2, ..}, .. */
return;
}
/* quick checks */
/* grow last range */
return;
}
return;
}
/* grow down first range */
return;
}
return;
}
/* somewhere in the middle, array is sorted so find it with
binary search */
else
break;
}
idx++;
/* idx == size couldn't happen because we already handle it above */
/* already expunged */
return;
}
/* merge */
sizeof(*data));
}
/* merge */
sizeof(*data));
}
} else {
}
}
enum modify_type modify_type,
enum mail_flags flags,
{
int i;
switch (modify_type) {
case MODIFY_REPLACE:
break;
case MODIFY_ADD:
for (i = 0; i < INDEX_KEYWORDS_BYTE_COUNT; i++)
break;
case MODIFY_REMOVE:
for (i = 0; i < INDEX_KEYWORDS_BYTE_COUNT; i++)
break;
}
}
((t)->last_update_modify_type == (modify_type) && \
INDEX_KEYWORDS_BYTE_COUNT) == 0)
enum modify_type modify_type,
{
struct mail_index_record *rec;
/* just appended message, modify it directly */
return;
}
/* first get group updates into same structure. this allows faster
updates if same mails have multiple flag updates during same
transaction (eg. 1:10 +seen, 1:10 +deleted) */
if (t->last_update.uid1 != 0 &&
return;
}
if (t->last_update.uid1 != 0 &&
return;
}
}
if (t->last_update.uid1 != 0)
}
static void
struct mail_transaction_flag_update *update)
{
int i;
*update = t->last_update;
switch (t->last_update_modify_type) {
case MODIFY_REPLACE:
/* remove_flags = ~add_flags */
for (i = 0; i < INDEX_KEYWORDS_BYTE_COUNT; i++)
break;
case MODIFY_ADD:
/* already in add_flags */
break;
case MODIFY_REMOVE:
/* add_flags -> remove_flags */
break;
}
}
static void mail_index_transaction_add_last(struct mail_index_transaction *t)
{
}
/* find the nearest sequence from existing updates */
else
break;
}
idx++;
/* insert it into buffer, split it in multiple parts if needed
to make sure the ordering stays the same */
break;
/* partial */
size++;
}
}
}
{
void *data;
/* we're probably appending it, check */
if (size == 0)
idx = 0;
else {
else {
/* already there, update */
return;
}
}
}
idx *= full_record_size;
}
}
void mail_index_reset_cache(struct mail_index_transaction *t,
{
}
void mail_index_update_cache(struct mail_index_transaction *t,
{
struct mail_index_record *rec;
/* just appended message, modify it directly */
} else {
}
}
void mail_index_update_extra_rec(struct mail_index_transaction *t,
const void *data)
{
struct mail_index_record *rec;
/* just appended message, modify it directly */
/* FIXME: do data_id mapping conversion */
} else {
}
}
void mail_index_update_header(struct mail_index_transaction *t,
{
t->hdr_changed = TRUE;
}