mail-index-sync.c revision 8c7a59bbb15ccf6e01446d0a5ad88837b3166a00
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes/* Copyright (C) 2003-2004 Timo Sirainen */
70953fb44a7140fe206c3a5f011e24209c8c5c6abnicholesstatic void mail_index_sync_add_expunge(struct mail_index_sync_ctx *ctx)
b387b9d37fc71c534f4718777454a8f5a1169017fuankg const struct mail_transaction_expunge *e = ctx->data;
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes for (i = 0; i < size; i++) {
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholesstatic void mail_index_sync_add_flag_update(struct mail_index_sync_ctx *ctx)
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes const struct mail_transaction_flag_update *u = ctx->data;
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes for (i = 0; i < size; i++) {
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes if (u[i].add_flags != 0) {
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes if (u[i].remove_flags != 0) {
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholesstatic void mail_index_sync_add_keyword_update(struct mail_index_sync_ctx *ctx)
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes const struct mail_transaction_keyword_update *u = ctx->data;
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes keyword_names[0] = t_strndup(u + 1, u->name_size);
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes keywords = mail_index_keywords_create(ctx->trans, keyword_names);
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes size = (ctx->hdr->size - uidset_offset) / sizeof(uint32_t);
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes /* FIXME: mail_index_update_keywords_range() */
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholesstatic void mail_index_sync_add_keyword_reset(struct mail_index_sync_ctx *ctx)
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes const struct mail_transaction_keyword_reset *u = ctx->data;
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes keywords = mail_index_keywords_create(ctx->trans, NULL);
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes for (i = 0; i < size; i++) {
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholesstatic void mail_index_sync_add_append(struct mail_index_sync_ctx *ctx)
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes if (ctx->append_uid_first == 0 || rec->uid < ctx->append_uid_first)
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes rec = CONST_PTR_OFFSET(ctx->data, ctx->hdr->size - sizeof(*rec));
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholesstatic void mail_index_sync_add_transaction(struct mail_index_sync_ctx *ctx)
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes switch (ctx->hdr->type & MAIL_TRANSACTION_TYPE_MASK) {
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholesstatic int mail_index_sync_add_dirty_updates(struct mail_index_sync_ctx *ctx)
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes messages_count = mail_index_view_get_messages_count(ctx->view);
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes if ((rec->flags & MAIL_INDEX_MAIL_FLAG_DIRTY) == 0)
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholesstatic int mail_index_sync_add_recent_updates(struct mail_index_sync_ctx *ctx)
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes messages_count = mail_index_view_get_messages_count(ctx->view);
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes /* no recent messages, drop the sync_recent flag so we
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes don't scan through the message again */
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholesmail_index_sync_read_and_sort(struct mail_index_sync_ctx *ctx,
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes const struct mail_index_transaction_keyword_update *keyword_updates;
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes unsigned int i, keyword_count;
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes if ((ctx->view->map->hdr.flags & MAIL_INDEX_HDR_FLAG_HAVE_DIRTY) &&
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes /* show dirty flags as flag updates */
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg /* read all transactions from log into a transaction in memory */
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg while ((ret = mail_transaction_log_view_next(ctx->view->log_view,
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes if ((ctx->hdr->type & MAIL_TRANSACTION_EXTERNAL) != 0)
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes /* create an array containing all expunge, flag and keyword update
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes arrays so we can easily go through all of the changes. */
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes keyword_count = !array_is_created(&ctx->trans->keyword_updates) ? 0 :
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes /* we must return resets before keyword additions or they get lost */
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes if (array_is_created(&ctx->trans->keyword_resets)) {
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes for (i = 0; i < keyword_count; i++) {
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes if (array_is_created(&keyword_updates[i].add_seq)) {
return ret;
int ret;
if (ret <= 0) {
int ret;
NULL)) > 0) {
if (ret < 0)
if (ret > 0) {
unsigned int lock_id = 0;
bool seen_external;
for (i = 0; i < count; i++) {
next_i = i;
if (i == count) {
i = next_i;
&sync_list[i]);
unsigned int i, count;
return TRUE;
for (i = 0; i < count; i++) {
return TRUE;
return FALSE;
unsigned int i, count;
for (i = 0; i < count; i++)
int ret = 0;
return ret;
const unsigned int *keyword_indexes;
unsigned int i, count;
for (i = 0; i < count; i++) {
return FALSE;
return TRUE;
for (i = 0; i < count; i++) {
return TRUE;
return FALSE;
return FALSE;
return TRUE;
i_unreached();
return FALSE;