bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch#ifndef MAIL_INDEX_VIEW_PRIVATE_H
52ffa11d672a9bd150ae3e758a19f1cc4f01471bTimo Sirainen#define MAIL_INDEX_VIEW_PRIVATE_H
52ffa11d672a9bd150ae3e758a19f1cc4f01471bTimo Sirainen
52ffa11d672a9bd150ae3e758a19f1cc4f01471bTimo Sirainen#include "mail-index-private.h"
bdd36cfdba3ff66d25570a9ff568d69e1eb543cfTimo Sirainen
52ffa11d672a9bd150ae3e758a19f1cc4f01471bTimo Sirainenstruct mail_index_view_log_sync_area {
3ef05dbd1be6cb311e4d196bab87e73fdc660e19Timo Sirainen uint32_t log_file_seq;
52ffa11d672a9bd150ae3e758a19f1cc4f01471bTimo Sirainen unsigned int length;
7ed711d973b319320da100d3e905ef7b99ed69d6Timo Sirainen uoff_t log_file_offset;
7a60e1dc9e93ef3f7c7fe1af6385a0bfa1e31bc3Timo Sirainen};
52ffa11d672a9bd150ae3e758a19f1cc4f01471bTimo SirainenARRAY_DEFINE_TYPE(view_log_sync_area, struct mail_index_view_log_sync_area);
7ed711d973b319320da100d3e905ef7b99ed69d6Timo Sirainen
381daab1e3b56a0bc94d2191cf62beba0df51af9Pascal Volkstruct mail_index_view_vfuncs {
52ffa11d672a9bd150ae3e758a19f1cc4f01471bTimo Sirainen void (*close)(struct mail_index_view *view);
52ffa11d672a9bd150ae3e758a19f1cc4f01471bTimo Sirainen uint32_t (*get_messages_count)(struct mail_index_view *view);
52ffa11d672a9bd150ae3e758a19f1cc4f01471bTimo Sirainen const struct mail_index_header *
52ffa11d672a9bd150ae3e758a19f1cc4f01471bTimo Sirainen (*get_header)(struct mail_index_view *view);
52ffa11d672a9bd150ae3e758a19f1cc4f01471bTimo Sirainen const struct mail_index_record *
52ffa11d672a9bd150ae3e758a19f1cc4f01471bTimo Sirainen (*lookup_full)(struct mail_index_view *view, uint32_t seq,
c68ba18d99f3e4fead1e259b9dc50cb139e0b1c7Timo Sirainen struct mail_index_map **map_r, bool *expunged_r);
4ee00532a265bdfb38539d811fcd12d51210ac35Timo Sirainen void (*lookup_uid)(struct mail_index_view *view, uint32_t seq,
4ee00532a265bdfb38539d811fcd12d51210ac35Timo Sirainen uint32_t *uid_r);
52ffa11d672a9bd150ae3e758a19f1cc4f01471bTimo Sirainen void (*lookup_seq_range)(struct mail_index_view *view,
52ffa11d672a9bd150ae3e758a19f1cc4f01471bTimo Sirainen uint32_t first_uid, uint32_t last_uid,
52ffa11d672a9bd150ae3e758a19f1cc4f01471bTimo Sirainen uint32_t *first_seq_r, uint32_t *last_seq_r);
f6b8ff28fe15eff03e0127f11cd122d3eb872e2eTimo Sirainen void (*lookup_first)(struct mail_index_view *view,
f6b8ff28fe15eff03e0127f11cd122d3eb872e2eTimo Sirainen enum mail_flags flags, uint8_t flags_mask,
f6b8ff28fe15eff03e0127f11cd122d3eb872e2eTimo Sirainen uint32_t *seq_r);
f6b8ff28fe15eff03e0127f11cd122d3eb872e2eTimo Sirainen void (*lookup_keywords)(struct mail_index_view *view, uint32_t seq,
f6b8ff28fe15eff03e0127f11cd122d3eb872e2eTimo Sirainen ARRAY_TYPE(keyword_indexes) *keyword_idx);
f6b8ff28fe15eff03e0127f11cd122d3eb872e2eTimo Sirainen void (*lookup_ext_full)(struct mail_index_view *view, uint32_t seq,
f6b8ff28fe15eff03e0127f11cd122d3eb872e2eTimo Sirainen uint32_t ext_id, struct mail_index_map **map_r,
f6b8ff28fe15eff03e0127f11cd122d3eb872e2eTimo Sirainen const void **data_r, bool *expunged_r);
f6b8ff28fe15eff03e0127f11cd122d3eb872e2eTimo Sirainen void (*get_header_ext)(struct mail_index_view *view,
f6b8ff28fe15eff03e0127f11cd122d3eb872e2eTimo Sirainen struct mail_index_map *map, uint32_t ext_id,
678d0463849ba777106eb7875f27db07a5d8e3dfTimo Sirainen const void **data_r, size_t *data_size_r);
c68ba18d99f3e4fead1e259b9dc50cb139e0b1c7Timo Sirainen bool (*ext_get_reset_id)(struct mail_index_view *view,
f6b8ff28fe15eff03e0127f11cd122d3eb872e2eTimo Sirainen struct mail_index_map *map,
f6b8ff28fe15eff03e0127f11cd122d3eb872e2eTimo Sirainen uint32_t ext_id, uint32_t *reset_id_r);
f6b8ff28fe15eff03e0127f11cd122d3eb872e2eTimo Sirainen};
f6b8ff28fe15eff03e0127f11cd122d3eb872e2eTimo Sirainen
f6b8ff28fe15eff03e0127f11cd122d3eb872e2eTimo Sirainenunion mail_index_view_module_context {
f6b8ff28fe15eff03e0127f11cd122d3eb872e2eTimo Sirainen struct mail_index_module_register *reg;
f6b8ff28fe15eff03e0127f11cd122d3eb872e2eTimo Sirainen};
f6b8ff28fe15eff03e0127f11cd122d3eb872e2eTimo Sirainen
f6b8ff28fe15eff03e0127f11cd122d3eb872e2eTimo Sirainenstruct mail_index_view {
f6b8ff28fe15eff03e0127f11cd122d3eb872e2eTimo Sirainen struct mail_index_view *prev, *next;
c68ba18d99f3e4fead1e259b9dc50cb139e0b1c7Timo Sirainen int refcount;
c68ba18d99f3e4fead1e259b9dc50cb139e0b1c7Timo Sirainen
678d0463849ba777106eb7875f27db07a5d8e3dfTimo Sirainen struct mail_index_view_vfuncs v;
678d0463849ba777106eb7875f27db07a5d8e3dfTimo Sirainen struct mail_index *index;
c68ba18d99f3e4fead1e259b9dc50cb139e0b1c7Timo Sirainen struct mail_transaction_log_view *log_view;
c68ba18d99f3e4fead1e259b9dc50cb139e0b1c7Timo Sirainen
c68ba18d99f3e4fead1e259b9dc50cb139e0b1c7Timo Sirainen const char *source_filename;
c68ba18d99f3e4fead1e259b9dc50cb139e0b1c7Timo Sirainen unsigned int source_linenum;
c68ba18d99f3e4fead1e259b9dc50cb139e0b1c7Timo Sirainen
f6b8ff28fe15eff03e0127f11cd122d3eb872e2eTimo Sirainen uint32_t indexid;
f6b8ff28fe15eff03e0127f11cd122d3eb872e2eTimo Sirainen unsigned int inconsistency_id;
f6b8ff28fe15eff03e0127f11cd122d3eb872e2eTimo Sirainen uint64_t highest_modseq;
f6b8ff28fe15eff03e0127f11cd122d3eb872e2eTimo Sirainen
f6b8ff28fe15eff03e0127f11cd122d3eb872e2eTimo Sirainen struct mail_index_map *map;
f6b8ff28fe15eff03e0127f11cd122d3eb872e2eTimo Sirainen /* All mappings where we have returned records. They need to be kept
f6b8ff28fe15eff03e0127f11cd122d3eb872e2eTimo Sirainen valid until view is synchronized. */
f6b8ff28fe15eff03e0127f11cd122d3eb872e2eTimo Sirainen ARRAY(struct mail_index_map *) map_refs;
f6b8ff28fe15eff03e0127f11cd122d3eb872e2eTimo Sirainen
c68ba18d99f3e4fead1e259b9dc50cb139e0b1c7Timo Sirainen /* expunge <= head */
c68ba18d99f3e4fead1e259b9dc50cb139e0b1c7Timo Sirainen uint32_t log_file_expunge_seq, log_file_head_seq;
c68ba18d99f3e4fead1e259b9dc50cb139e0b1c7Timo Sirainen uoff_t log_file_expunge_offset, log_file_head_offset;
52ffa11d672a9bd150ae3e758a19f1cc4f01471bTimo Sirainen
52ffa11d672a9bd150ae3e758a19f1cc4f01471bTimo Sirainen /* Transaction log offsets which we don't want to return in view sync */
52ffa11d672a9bd150ae3e758a19f1cc4f01471bTimo Sirainen ARRAY_TYPE(view_log_sync_area) syncs_hidden;
52ffa11d672a9bd150ae3e758a19f1cc4f01471bTimo Sirainen
52ffa11d672a9bd150ae3e758a19f1cc4f01471bTimo Sirainen /* Module-specific contexts. */
52ffa11d672a9bd150ae3e758a19f1cc4f01471bTimo Sirainen ARRAY(union mail_index_view_module_context *) module_contexts;
52ffa11d672a9bd150ae3e758a19f1cc4f01471bTimo Sirainen
52ffa11d672a9bd150ae3e758a19f1cc4f01471bTimo Sirainen struct mail_index_transaction *transactions_list;
52ffa11d672a9bd150ae3e758a19f1cc4f01471bTimo Sirainen int transactions;
52ffa11d672a9bd150ae3e758a19f1cc4f01471bTimo Sirainen
52ffa11d672a9bd150ae3e758a19f1cc4f01471bTimo Sirainen bool inconsistent:1;
52ffa11d672a9bd150ae3e758a19f1cc4f01471bTimo Sirainen /* this view was created by mail_index_sync_begin() */
c03f712279c54fc29368a914375a4c66855d253bTimo Sirainen bool index_sync_view:1;
52ffa11d672a9bd150ae3e758a19f1cc4f01471bTimo Sirainen /* this view is being synced */
7a60e1dc9e93ef3f7c7fe1af6385a0bfa1e31bc3Timo Sirainen bool syncing:1;
52ffa11d672a9bd150ae3e758a19f1cc4f01471bTimo Sirainen};
c68ba18d99f3e4fead1e259b9dc50cb139e0b1c7Timo Sirainen
c68ba18d99f3e4fead1e259b9dc50cb139e0b1c7Timo Sirainenstruct mail_index_view *
c68ba18d99f3e4fead1e259b9dc50cb139e0b1c7Timo Sirainenmail_index_view_open_with_map(struct mail_index *index,
c68ba18d99f3e4fead1e259b9dc50cb139e0b1c7Timo Sirainen struct mail_index_map *map);
efe78d3ba24fc866af1c79b9223dc0809ba26cadStephan Boschvoid mail_index_view_clone(struct mail_index_view *dest,
52ffa11d672a9bd150ae3e758a19f1cc4f01471bTimo Sirainen const struct mail_index_view *src);
2fa41e3cd6393ce4b5f7e6f6048d7706aa93ac0dTimo Sirainenstruct mail_index_view *
2fa41e3cd6393ce4b5f7e6f6048d7706aa93ac0dTimo Sirainenmail_index_view_dup_private(const struct mail_index_view *src);
52ffa11d672a9bd150ae3e758a19f1cc4f01471bTimo Sirainenvoid mail_index_view_ref(struct mail_index_view *view);
ffcf7f97c7d82b895bbb745031042ee8c378c6b6Timo Sirainenvoid mail_index_view_unref_maps(struct mail_index_view *view);
ffcf7f97c7d82b895bbb745031042ee8c378c6b6Timo Sirainenvoid mail_index_view_add_hidden_transaction(struct mail_index_view *view,
e48f289d2e5b2546a2c5dcc90f7ab624cc58cca2Stephan Bosch uint32_t log_file_seq,
e48f289d2e5b2546a2c5dcc90f7ab624cc58cca2Stephan Bosch uoff_t log_file_offset,
c68ba18d99f3e4fead1e259b9dc50cb139e0b1c7Timo Sirainen unsigned int length);
c68ba18d99f3e4fead1e259b9dc50cb139e0b1c7Timo Sirainen
2fa41e3cd6393ce4b5f7e6f6048d7706aa93ac0dTimo Sirainenstruct mail_index_view *mail_index_dummy_view_open(struct mail_index *index);
2fa41e3cd6393ce4b5f7e6f6048d7706aa93ac0dTimo Sirainen
2fa41e3cd6393ce4b5f7e6f6048d7706aa93ac0dTimo Sirainen#endif
2fa41e3cd6393ce4b5f7e6f6048d7706aa93ac0dTimo Sirainen