1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen#ifndef SDBOX_SYNC_H
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen#define SDBOX_SYNC_H
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenstruct mailbox;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenstruct sdbox_mailbox;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenenum sdbox_sync_flags {
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen SDBOX_SYNC_FLAG_FORCE = 0x01,
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen SDBOX_SYNC_FLAG_FSYNC = 0x02,
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen SDBOX_SYNC_FLAG_FORCE_REBUILD = 0x04
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen};
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenenum sdbox_sync_entry_type {
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen SDBOX_SYNC_ENTRY_TYPE_EXPUNGE,
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen SDBOX_SYNC_ENTRY_TYPE_MOVE_FROM_ALT,
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen SDBOX_SYNC_ENTRY_TYPE_MOVE_TO_ALT
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen};
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenstruct sdbox_sync_context {
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen struct sdbox_mailbox *mbox;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen struct mail_index_sync_ctx *index_sync_ctx;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen struct mail_index_view *sync_view;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen struct mail_index_transaction *trans;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen enum sdbox_sync_flags flags;
44fb32493e2a989358283426a6054662cafcc56bTimo Sirainen ARRAY_TYPE(uint32_t) expunged_uids;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen};
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenint sdbox_sync_begin(struct sdbox_mailbox *mbox, enum sdbox_sync_flags flags,
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen struct sdbox_sync_context **ctx_r);
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenint sdbox_sync_finish(struct sdbox_sync_context **ctx, bool success);
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenint sdbox_sync(struct sdbox_mailbox *mbox, enum sdbox_sync_flags flags);
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
e5fb952c6d49d3b6bff1746551566202e92947daTimo Sirainenint sdbox_sync_index_rebuild(struct sdbox_mailbox *mbox, bool force);
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenstruct mailbox_sync_context *
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainensdbox_storage_sync_init(struct mailbox *box, enum mailbox_sync_flags flags);
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen#endif