maildir-sync.h revision f7ad1162969feff6b08f0e640a928db1783daae9
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen#ifndef MAILDIR_SYNC_H
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen#define MAILDIR_SYNC_H
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen/* All systems accessing the filesystem must have their clock less than this
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen many seconds apart from each others. 0 works only for local filesystems. */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen#define MAILDIR_SYNC_SECS 1
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen/* After moving this many mails from new/ to cur/, check if we need to touch
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen the uidlist lock. */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen#define MAILDIR_SLOW_MOVE_COUNT 100
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen/* readdir() should be pretty fast to do, but check anyway every n files
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen to see if we need to touch the uidlist lock. */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen#define MAILDIR_SLOW_CHECK_COUNT 10000
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainenstruct maildir_mailbox;
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainenstruct maildir_sync_context;
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainenstruct maildir_keywords_sync_ctx;
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainenstruct maildir_index_sync_context;
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainenint maildir_sync_is_synced(struct maildir_mailbox *mbox);
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainenstruct mailbox_sync_context *
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainenmaildir_storage_sync_init(struct mailbox *box, enum mailbox_sync_flags flags);
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainenint maildir_storage_sync_force(struct maildir_mailbox *mbox, uint32_t uid);
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainenint maildir_sync_index_begin(struct maildir_mailbox *mbox,
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen struct maildir_sync_context *maildir_sync_ctx,
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen struct maildir_index_sync_context **ctx_r);
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainenint maildir_sync_index(struct maildir_index_sync_context *sync_ctx,
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen bool partial);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenint maildir_sync_index_finish(struct maildir_index_sync_context **sync_ctx,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen bool failed, bool cancel);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainenstruct maildir_keywords_sync_ctx *
16f816d3f3c32ae3351834253f52ddd0212bcbf3Timo Sirainenmaildir_sync_get_keywords_sync_ctx(struct maildir_index_sync_context *ctx);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenvoid maildir_sync_notify(struct maildir_sync_context *ctx);
98c1cf256927e254f0c092acd2ddcd7ea50bd009Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenint maildir_list_index_has_changed(struct mailbox *box,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen struct mail_index_view *list_view,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen uint32_t seq);
84e1634acc701d14e358e27f1beff5ad74f5004aTimo Sirainenint maildir_list_index_update_sync(struct mailbox *box,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen struct mail_index_transaction *trans,
98c1cf256927e254f0c092acd2ddcd7ea50bd009Timo Sirainen uint32_t seq);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen#endif
98c1cf256927e254f0c092acd2ddcd7ea50bd009Timo Sirainen