mail-index-sync-private.h revision 20b9283d4af31e45e588014da427fb2dbcd3227a
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin#ifndef MAIL_INDEX_SYNC_PRIVATE_H
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin#define MAIL_INDEX_SYNC_PRIVATE_H
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin#include "mail-transaction-log.h"
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalinstruct uid_range {
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin uint32_t uid1, uid2;
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin};
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey ShabalinARRAY_DEFINE_TYPE(uid_range, struct uid_range);
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalinstruct mail_index_sync_list {
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin const ARRAY_TYPE(uid_range) *array;
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin unsigned int idx;
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin unsigned int keyword_idx:31;
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin unsigned int keyword_remove:1;
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin};
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalinstruct mail_index_expunge_handler {
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin mail_index_expunge_handler_t *handler;
14d9c0f09d1a55d124ef210a4b4e205c9fe7596cStéphane Graber void *context;
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin void **sync_context;
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin uint32_t record_offset;
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin};
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalinstruct mail_index_sync_map_ctx {
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin struct mail_index_view *view;
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin uint32_t cur_ext_map_idx;
ed4616b1cfbc84dd01caa8546d813e8c5d482921Christian Bühler
e29bf450cafa2ce2564aeb0b64d2014c17228407Dwight Engen uint32_t ext_intro_seq;
b031f0d2ca1b40eab86286b82d3c5e8b379122e6Alexey Shabalin uoff_t ext_intro_offset, ext_intro_end_offset;
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin ARRAY_DEFINE(expunge_handlers, struct mail_index_expunge_handler);
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin ARRAY_DEFINE(extra_contexts, void *);
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin buffer_t *unknown_extensions;
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin enum mail_index_sync_handler_type type;
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin unsigned int sync_handlers_initialized:1;
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin unsigned int expunge_handlers_set:1;
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin unsigned int expunge_handlers_used:1;
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin unsigned int cur_ext_ignore:1;
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin unsigned int internal_update:1; /* used by keywords for ext_intro */
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin unsigned int errors:1;
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin};
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalinextern struct mail_transaction_map_functions mail_index_map_sync_funcs;
b031f0d2ca1b40eab86286b82d3c5e8b379122e6Alexey Shabalin
b031f0d2ca1b40eab86286b82d3c5e8b379122e6Alexey Shabalinvoid mail_index_sync_map_init(struct mail_index_sync_map_ctx *sync_map_ctx,
b031f0d2ca1b40eab86286b82d3c5e8b379122e6Alexey Shabalin struct mail_index_view *view,
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin enum mail_index_sync_handler_type type);
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalinvoid mail_index_sync_map_deinit(struct mail_index_sync_map_ctx *sync_map_ctx);
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalinint mail_index_sync_map(struct mail_index_map **map,
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin enum mail_index_sync_handler_type type, bool force);
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin
b031f0d2ca1b40eab86286b82d3c5e8b379122e6Alexey Shabalinint mail_index_sync_record(struct mail_index_sync_map_ctx *ctx,
b031f0d2ca1b40eab86286b82d3c5e8b379122e6Alexey Shabalin const struct mail_transaction_header *hdr,
b031f0d2ca1b40eab86286b82d3c5e8b379122e6Alexey Shabalin const void *data);
b031f0d2ca1b40eab86286b82d3c5e8b379122e6Alexey Shabalin
b031f0d2ca1b40eab86286b82d3c5e8b379122e6Alexey Shabalinstruct mail_index_map *
b031f0d2ca1b40eab86286b82d3c5e8b379122e6Alexey Shabalinmail_index_sync_get_atomic_map(struct mail_index_sync_map_ctx *ctx);
b031f0d2ca1b40eab86286b82d3c5e8b379122e6Alexey Shabalinvoid mail_index_sync_write_seq_update(struct mail_index_sync_map_ctx *ctx,
b031f0d2ca1b40eab86286b82d3c5e8b379122e6Alexey Shabalin uint32_t seq1, uint32_t seq2);
b031f0d2ca1b40eab86286b82d3c5e8b379122e6Alexey Shabalin
b031f0d2ca1b40eab86286b82d3c5e8b379122e6Alexey Shabalinvoid mail_index_sync_init_expunge_handlers(struct mail_index_sync_map_ctx *ctx);
b031f0d2ca1b40eab86286b82d3c5e8b379122e6Alexey Shabalinvoid
b031f0d2ca1b40eab86286b82d3c5e8b379122e6Alexey Shabalinmail_index_sync_deinit_expunge_handlers(struct mail_index_sync_map_ctx *ctx);
b031f0d2ca1b40eab86286b82d3c5e8b379122e6Alexey Shabalinvoid mail_index_sync_init_handlers(struct mail_index_sync_map_ctx *ctx);
b031f0d2ca1b40eab86286b82d3c5e8b379122e6Alexey Shabalinvoid mail_index_sync_deinit_handlers(struct mail_index_sync_map_ctx *ctx);
b031f0d2ca1b40eab86286b82d3c5e8b379122e6Alexey Shabalin
b031f0d2ca1b40eab86286b82d3c5e8b379122e6Alexey Shabalinint mail_index_sync_ext_intro(struct mail_index_sync_map_ctx *ctx,
b031f0d2ca1b40eab86286b82d3c5e8b379122e6Alexey Shabalin const struct mail_transaction_ext_intro *u);
b031f0d2ca1b40eab86286b82d3c5e8b379122e6Alexey Shabalinint mail_index_sync_ext_reset(struct mail_index_sync_map_ctx *ctx,
b031f0d2ca1b40eab86286b82d3c5e8b379122e6Alexey Shabalin const struct mail_transaction_ext_reset *u);
b031f0d2ca1b40eab86286b82d3c5e8b379122e6Alexey Shabalinint
b031f0d2ca1b40eab86286b82d3c5e8b379122e6Alexey Shabalinmail_index_sync_ext_hdr_update(struct mail_index_sync_map_ctx *ctx,
b031f0d2ca1b40eab86286b82d3c5e8b379122e6Alexey Shabalin const struct mail_transaction_ext_hdr_update *u);
b031f0d2ca1b40eab86286b82d3c5e8b379122e6Alexey Shabalinint
b031f0d2ca1b40eab86286b82d3c5e8b379122e6Alexey Shabalinmail_index_sync_ext_rec_update(struct mail_index_sync_map_ctx *ctx,
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin const struct mail_transaction_ext_rec_update *u);
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalinint mail_index_sync_keywords(struct mail_index_sync_map_ctx *ctx,
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin const struct mail_transaction_header *hdr,
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin const struct mail_transaction_keyword_update *rec);
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalinint
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalinmail_index_sync_keywords_reset(struct mail_index_sync_map_ctx *ctx,
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin const struct mail_transaction_header *hdr,
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin const struct mail_transaction_keyword_reset *r);
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalinvoid mail_index_sync_set_corrupted(struct mail_index_sync_map_ctx *ctx,
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin const char *fmt, ...) ATTR_FORMAT(2, 3);
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin
b031f0d2ca1b40eab86286b82d3c5e8b379122e6Alexey Shabalin#ifdef DEBUG
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalinvoid mail_index_map_check(struct mail_index_map *map);
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin#endif
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin
b031f0d2ca1b40eab86286b82d3c5e8b379122e6Alexey Shabalin#endif
262f4e48a51a55ad9cee06abbcfe4a6ad6166f49Alexey Shabalin