e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainen#ifndef MAILBOX_LIST_INDEX_SYNC_H
e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainen#define MAILBOX_LIST_INDEX_SYNC_H
e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainen
e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainen#include "mailbox-list-index.h"
e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainen
e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainenstruct mailbox_list_index_sync_context {
e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainen struct mailbox_list *list;
e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainen struct mailbox_list_index *ilist;
e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainen char sep[2];
e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainen uint32_t next_uid;
e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainen uint32_t orig_highest_name_id;
e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainen
e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainen struct mail_index_sync_ctx *index_sync_ctx;
e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainen struct mail_index_view *view;
e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainen struct mail_index_transaction *trans;
e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainen
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool syncing_list:1;
e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainen};
e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainen
e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainenint mailbox_list_index_sync_begin(struct mailbox_list *list,
e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainen struct mailbox_list_index_sync_context **sync_ctx_r);
e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainenint mailbox_list_index_sync_end(struct mailbox_list_index_sync_context **_sync_ctx,
e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainen bool success);
4fc372faccaa5ee46ebf61e4ec8954ae44a39d62Timo Sirainenint mailbox_list_index_sync(struct mailbox_list *list, bool refresh);
e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainen
e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainen/* Add name to index, return seq in index. */
e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainenuint32_t mailbox_list_index_sync_name(struct mailbox_list_index_sync_context *ctx,
e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainen const char *name,
e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainen struct mailbox_list_index_node **node_r,
e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainen bool *created_r);
e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainen
330865e1eb92715b34462af25c90c7308624c2afTimo Sirainenint mailbox_list_index_sync_delete(struct mailbox_list_index_sync_context *sync_ctx,
330865e1eb92715b34462af25c90c7308624c2afTimo Sirainen const char *name, bool delete_selectable);
c44f7761bba61503d573eb950b9377f9d55ce2aaTimo Sirainen
e0aff4c7e3336ec4b5edbcfc3a72e1e118603ee2Timo Sirainen#endif