sdbox-storage.h revision 9f19a50d5966643c4d1c5ca06868ac2ad31bc4d5
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen#ifndef SDBOX_STORAGE_H
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen#define SDBOX_STORAGE_H
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen#include "index-storage.h"
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen#include "dbox-storage.h"
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen#include "mailbox-list-private.h"
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen#define SDBOX_STORAGE_NAME "dbox"
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen#define SDBOX_MAIL_FILE_PREFIX "u."
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen#define SDBOX_MAIL_FILE_FORMAT SDBOX_MAIL_FILE_PREFIX"%u"
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen/* Flag specifies if the message should be in primary or alternative storage */
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen#define SDBOX_INDEX_FLAG_ALT MAIL_INDEX_MAIL_FLAG_BACKEND
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen#define SDBOX_INDEX_HEADER_MIN_SIZE (sizeof(uint32_t))
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenstruct sdbox_index_header {
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen uint32_t oldv1_highest_maildir_uid;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen uint8_t mailbox_guid[MAIL_GUID_128_SIZE];
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen};
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenstruct sdbox_storage {
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen struct dbox_storage storage;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen union mailbox_list_module_context list_module_ctx;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen};
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenstruct sdbox_mailbox {
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen struct index_mailbox ibox;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen struct sdbox_storage *storage;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen uint32_t hdr_ext_id;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen const char *alt_path;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen unsigned int creating:1;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen unsigned int sync_rebuild:1;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen};
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenextern struct mail_vfuncs sdbox_mail_vfuncs;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenstruct mailbox *
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainensdbox_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list,
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen const char *name, struct istream *input,
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen enum mailbox_flags flags);
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenint sdbox_mail_open(struct dbox_mail *mail, uoff_t *offset_r,
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen struct dbox_file **file_r);
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenuint32_t dbox_get_uidvalidity_next(struct mailbox_list *list);
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenint sdbox_read_header(struct sdbox_mailbox *mbox,
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen struct sdbox_index_header *hdr);
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenvoid sdbox_update_header(struct sdbox_mailbox *mbox,
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen struct mail_index_transaction *trans,
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen const struct mailbox_update *update);
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenstruct mail_save_context *
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainensdbox_save_alloc(struct mailbox_transaction_context *_t);
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenint sdbox_save_begin(struct mail_save_context *ctx, struct istream *input);
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenint sdbox_save_finish(struct mail_save_context *ctx);
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenvoid sdbox_save_cancel(struct mail_save_context *ctx);
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenstruct dbox_file *
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainensdbox_save_file_get_file(struct mailbox_transaction_context *t, uint32_t seq);
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenint sdbox_transaction_save_commit_pre(struct mail_save_context *ctx);
9f19a50d5966643c4d1c5ca06868ac2ad31bc4d5Timo Sirainenvoid sdbox_transaction_save_commit_post(struct mail_save_context *ctx,
9f19a50d5966643c4d1c5ca06868ac2ad31bc4d5Timo Sirainen struct mail_index_transaction_commit_result *result);
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenvoid sdbox_transaction_save_rollback(struct mail_save_context *ctx);
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenint sdbox_copy(struct mail_save_context *ctx, struct mail *mail);
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen#endif