bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2007-2018 Dovecot authors, see the included COPYING file */
d22301419109ed4a38351715e6760011421dadecTimo Sirainenindex_sync_changes_init(struct mail_index_sync_ctx *index_sync_ctx,
022412398e56a8f31ef111cfd7271498d64af9a9Timo Sirainen ctx = i_new(struct index_sync_changes_context, 1);
022412398e56a8f31ef111cfd7271498d64af9a9Timo Sirainenvoid index_sync_changes_deinit(struct index_sync_changes_context **_ctx)
022412398e56a8f31ef111cfd7271498d64af9a9Timo Sirainen struct index_sync_changes_context *ctx = *_ctx;
022412398e56a8f31ef111cfd7271498d64af9a9Timo Sirainenvoid index_sync_changes_reset(struct index_sync_changes_context *ctx)
022412398e56a8f31ef111cfd7271498d64af9a9Timo Sirainenvoid index_sync_changes_delete_to(struct index_sync_changes_context *ctx,
022412398e56a8f31ef111cfd7271498d64af9a9Timo Sirainen syncs = array_get_modifiable(&ctx->syncs, &count);
022412398e56a8f31ef111cfd7271498d64af9a9Timo Sirainen /* keep it */
022412398e56a8f31ef111cfd7271498d64af9a9Timo Sirainen array_delete(&ctx->syncs, dest, count - dest);
022412398e56a8f31ef111cfd7271498d64af9a9Timo Sirainenindex_sync_changes_have_expunges(struct index_sync_changes_context *ctx,
0c909e3461607eadcd66f4eac69b7f34e37fccf1Timo Sirainen unsigned int count,
022412398e56a8f31ef111cfd7271498d64af9a9Timo Sirainen unsigned int i;
022412398e56a8f31ef111cfd7271498d64af9a9Timo Sirainen for (i = 0; i < count; i++) {
0c909e3461607eadcd66f4eac69b7f34e37fccf1Timo Sirainen if (syncs[i].type == MAIL_INDEX_SYNC_TYPE_EXPUNGE) {
de62ce819d59a529530da4b57be1b8d6dad13d6bTimo Sirainen memcpy(expunged_guid_128_r, syncs[i].guid_128,
b08b33d1f5ce3721dc2d83586c9cb0ca141331fdTimo Sirainenvoid index_sync_changes_read(struct index_sync_changes_context *ctx,
022412398e56a8f31ef111cfd7271498d64af9a9Timo Sirainen struct mail_index_sync_rec *sync_rec = &ctx->sync_rec;
0c909e3461607eadcd66f4eac69b7f34e37fccf1Timo Sirainen if (sync_rec->type == MAIL_INDEX_SYNC_TYPE_EXPUNGE) {
de62ce819d59a529530da4b57be1b8d6dad13d6bTimo Sirainen memcpy(expunged_guid_128_r, sync_rec->guid_128,
b08b33d1f5ce3721dc2d83586c9cb0ca141331fdTimo Sirainen if (!mail_index_sync_next(ctx->index_sync_ctx, sync_rec)) {
022412398e56a8f31ef111cfd7271498d64af9a9Timo Sirainen /* mark the changes as dirty */
e34d170f8f0e084bd94bfbc1a7085ece67e508dfTimo Sirainen (void)mail_index_lookup_seq_range(ctx->sync_view,
022412398e56a8f31ef111cfd7271498d64af9a9Timo Sirainen mail_index_update_flags_range(ctx->sync_trans,
0c909e3461607eadcd66f4eac69b7f34e37fccf1Timo Sirainen index_sync_changes_have_expunges(ctx, orig_count,
022412398e56a8f31ef111cfd7271498d64af9a9Timo Sirainenbool index_sync_changes_have(struct index_sync_changes_context *ctx)
022412398e56a8f31ef111cfd7271498d64af9a9Timo Sirainenindex_sync_changes_get_next_uid(struct index_sync_changes_context *ctx)
022412398e56a8f31ef111cfd7271498d64af9a9Timo Sirainenvoid index_sync_changes_apply(struct index_sync_changes_context *ctx,
022412398e56a8f31ef111cfd7271498d64af9a9Timo Sirainen for (i = 0; i < count; i++) {
022412398e56a8f31ef111cfd7271498d64af9a9Timo Sirainen mail_index_sync_flags_apply(&syncs[i], flags);
022412398e56a8f31ef111cfd7271498d64af9a9Timo Sirainen /* no existing keywords */
022412398e56a8f31ef111cfd7271498d64af9a9Timo Sirainen /* adding, create the array */