7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen#ifndef DSYNC_MAILBOX_H
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen#define DSYNC_MAILBOX_H
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen#include "mail-storage.h"
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen
c864fdd520b0c3f10a4b9bc5373368f4ae8faaffTimo Sirainenstruct dsync_brain;
c864fdd520b0c3f10a4b9bc5373368f4ae8faaffTimo Sirainen
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen/* Mailbox that is going to be synced. Its name was already sent in the
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen mailbox tree. */
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainenstruct dsync_mailbox {
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen guid_128_t mailbox_guid;
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen bool mailbox_lost;
280bc7d8b07490dfa5cf0fc20aee8e9e2d15aa99Aki Tuomi bool mailbox_ignore;
d1e843e77f4760e303c53d9fce10123fc8d230a1Timo Sirainen bool have_guids, have_save_guids, have_only_guid128;
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen uint32_t uid_validity, uid_next, messages_count, first_recent_uid;
6abf66a3731d52889517bd644595c540e3a9b3ecTimo Sirainen uint64_t highest_modseq, highest_pvt_modseq;
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen ARRAY_TYPE(mailbox_cache_field) cache_fields;
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen};
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen
55d33f807765482eb47374aaaced1fe714e0b256Timo Sirainenstruct dsync_mailbox_attribute {
55d33f807765482eb47374aaaced1fe714e0b256Timo Sirainen enum mail_attribute_type type;
55d33f807765482eb47374aaaced1fe714e0b256Timo Sirainen const char *key;
41e51b972f02e8b16c19fab9160294ea0a07c343Timo Sirainen /* if both values are NULL = not looked up yet / deleted */
41e51b972f02e8b16c19fab9160294ea0a07c343Timo Sirainen const char *value;
41e51b972f02e8b16c19fab9160294ea0a07c343Timo Sirainen struct istream *value_stream;
55d33f807765482eb47374aaaced1fe714e0b256Timo Sirainen
55d33f807765482eb47374aaaced1fe714e0b256Timo Sirainen time_t last_change; /* 0 = unknown */
55d33f807765482eb47374aaaced1fe714e0b256Timo Sirainen uint64_t modseq; /* 0 = unknown */
55d33f807765482eb47374aaaced1fe714e0b256Timo Sirainen
55d33f807765482eb47374aaaced1fe714e0b256Timo Sirainen bool deleted; /* attribute is known to have been deleted */
55d33f807765482eb47374aaaced1fe714e0b256Timo Sirainen bool exported; /* internally used by exporting */
55d33f807765482eb47374aaaced1fe714e0b256Timo Sirainen};
41e51b972f02e8b16c19fab9160294ea0a07c343Timo Sirainen#define DSYNC_ATTR_HAS_VALUE(attr) \
41e51b972f02e8b16c19fab9160294ea0a07c343Timo Sirainen ((attr)->value != NULL || (attr)->value_stream != NULL)
55d33f807765482eb47374aaaced1fe714e0b256Timo Sirainen
55d33f807765482eb47374aaaced1fe714e0b256Timo Sirainenvoid dsync_mailbox_attribute_dup(pool_t pool,
55d33f807765482eb47374aaaced1fe714e0b256Timo Sirainen const struct dsync_mailbox_attribute *src,
55d33f807765482eb47374aaaced1fe714e0b256Timo Sirainen struct dsync_mailbox_attribute *dest_r);
55d33f807765482eb47374aaaced1fe714e0b256Timo Sirainen
c864fdd520b0c3f10a4b9bc5373368f4ae8faaffTimo Sirainenint dsync_mailbox_lock(struct dsync_brain *brain, struct mailbox *box,
c864fdd520b0c3f10a4b9bc5373368f4ae8faaffTimo Sirainen struct file_lock **lock_r);
c864fdd520b0c3f10a4b9bc5373368f4ae8faaffTimo Sirainen
7bd5b1c64cc987715bdaf8cc4907c3c37d5d7b29Timo Sirainen#endif