7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen#ifndef DSYNC_MAILBOX_IMPORT_H
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen#define DSYNC_MAILBOX_IMPORT_H
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen
ce0e25f26d6e67480ee39b5ca0ad634fa60c4605Timo Sirainen#include "mail-error.h"
ce0e25f26d6e67480ee39b5ca0ad634fa60c4605Timo Sirainen
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainenenum dsync_mailbox_import_flags {
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen DSYNC_MAILBOX_IMPORT_FLAG_MASTER_BRAIN = 0x01,
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen DSYNC_MAILBOX_IMPORT_FLAG_WANT_MAIL_REQUESTS = 0x02,
c267b524417ac7472ac58675e61ff4370484cb1aTimo Sirainen DSYNC_MAILBOX_IMPORT_FLAG_REVERT_LOCAL_CHANGES = 0x04,
975a784c2e02ecdcb56efb7a1db5e4769c7756d8Timo Sirainen DSYNC_MAILBOX_IMPORT_FLAG_DEBUG = 0x08,
d1e843e77f4760e303c53d9fce10123fc8d230a1Timo Sirainen DSYNC_MAILBOX_IMPORT_FLAG_MAILS_HAVE_GUIDS = 0x10,
14b1d2a2634e75b988078baee1e8ad678de28a04Timo Sirainen DSYNC_MAILBOX_IMPORT_FLAG_MAILS_USE_GUID128 = 0x20,
45af47783693b3ba2768c5ad34eeff68132382d0Timo Sirainen DSYNC_MAILBOX_IMPORT_FLAG_NO_NOTIFY = 0x40,
afd6d387ea65843b59fb6051fb567719d2a5279cAki Tuomi DSYNC_MAILBOX_IMPORT_FLAG_EMPTY_HDR_WORKAROUND = 0x100
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen};
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainenstruct mailbox;
55d33f807765482eb47374aaaced1fe714e0b256Timo Sirainenstruct dsync_mailbox_attribute;
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainenstruct dsync_mail;
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainenstruct dsync_mail_change;
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainenstruct dsync_transaction_log_scan;
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainenstruct dsync_mailbox_importer *
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainendsync_mailbox_import_init(struct mailbox *box,
70df8f39fb3db7c49b18c855178f8172176a037aTimo Sirainen struct mailbox *virtual_all_box,
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen struct dsync_transaction_log_scan *log_scan,
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen uint32_t last_common_uid,
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen uint64_t last_common_modseq,
6abf66a3731d52889517bd644595c540e3a9b3ecTimo Sirainen uint64_t last_common_pvt_modseq,
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen uint32_t remote_uid_next,
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen uint32_t remote_first_recent_uid,
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen uint64_t remote_highest_modseq,
6abf66a3731d52889517bd644595c540e3a9b3ecTimo Sirainen uint64_t remote_highest_pvt_modseq,
ee8294dbc7bb549557f6ba1264d66b55fbef69b6Aki Tuomi time_t sync_since_timestamp,
ee8294dbc7bb549557f6ba1264d66b55fbef69b6Aki Tuomi time_t sync_until_timestamp,
ee8294dbc7bb549557f6ba1264d66b55fbef69b6Aki Tuomi uoff_t sync_max_size,
ae949831f1f668b5501b4b125e7f7b1767fb109bTimo Sirainen const char *sync_flag,
a76faea3eb26c4cd67886fbe02c604f74d54be8cTimo Sirainen unsigned int commit_msgs_interval,
f3c24c2c92802cb773315eba1132254932d8709bTimo Sirainen enum dsync_mailbox_import_flags flags,
69a71891361b2b27ff68ed84b29278486628464aAki Tuomi unsigned int hdr_hash_version,
69a71891361b2b27ff68ed84b29278486628464aAki Tuomi const char *const *hashed_headers);
55d33f807765482eb47374aaaced1fe714e0b256Timo Sirainenint dsync_mailbox_import_attribute(struct dsync_mailbox_importer *importer,
55d33f807765482eb47374aaaced1fe714e0b256Timo Sirainen const struct dsync_mailbox_attribute *attr);
0c47c2096714b50880d48d00ce0bf28349eb4aceTimo Sirainenint dsync_mailbox_import_change(struct dsync_mailbox_importer *importer,
0c47c2096714b50880d48d00ce0bf28349eb4aceTimo Sirainen const struct dsync_mail_change *change);
69f6407b20f623193981d672c26fa722ee75d941Timo Sirainenint dsync_mailbox_import_changes_finish(struct dsync_mailbox_importer *importer);
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainenconst struct dsync_mail_request *
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainendsync_mailbox_import_next_request(struct dsync_mailbox_importer *importer);
7ae6552482fe6e6a613f883335fdafdf9afbc7b7Timo Sirainenint dsync_mailbox_import_mail(struct dsync_mailbox_importer *importer,
7ae6552482fe6e6a613f883335fdafdf9afbc7b7Timo Sirainen const struct dsync_mail *mail);
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainenint dsync_mailbox_import_deinit(struct dsync_mailbox_importer **importer,
d9b9687bf8cae9cfb070b1b7aadefa683220269fTimo Sirainen bool success,
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen uint32_t *last_common_uid_r,
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen uint64_t *last_common_modseq_r,
6abf66a3731d52889517bd644595c540e3a9b3ecTimo Sirainen uint64_t *last_common_pvt_modseq_r,
7d315281ae13a66e13da2b1ad006bdb883018278Timo Sirainen uint32_t *last_messages_count_r,
4f7951e71128c120d8a502d6406cc603fcc8eb0bTimo Sirainen const char **changes_during_sync_r,
805d7834412465268486c50711962407ad13fbf6Timo Sirainen bool *require_full_resync_r,
ce0e25f26d6e67480ee39b5ca0ad634fa60c4605Timo Sirainen enum mail_error *error_r);
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen
47255691575e06a1c95ce78ff0a1b502199de3abTimo Sirainenconst char *dsync_mailbox_import_get_proctitle(struct dsync_mailbox_importer *importer);
47255691575e06a1c95ce78ff0a1b502199de3abTimo Sirainen
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen#endif