mail-storage-private.h revision 306b3f41b05da642d87e7ca7a1496efce9f5902f
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainen/* Block size when read()ing message header. */
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen/* Block size when read()ing message (header and) body. */
07e4875d250e7a7157cd99132aafc773cf3cdf83Timo Sirainen#define MAIL_READ_FULL_BLOCK_SIZE IO_BLOCK_SIZE
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen unsigned int id;
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainen unsigned int id;
a94936bafd127680184da114c6a177b37ff656e5Timo Sirainen const struct setting_parser_info *(*get_setting_parser_info)(void);
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen int (*create)(struct mail_storage *storage, struct mail_namespace *ns,
07e4875d250e7a7157cd99132aafc773cf3cdf83Timo Sirainen const char **error_r);
8cb72c59d5ea4e9e5f638d7ec840bb853f5a188eTimo Sirainen void (*destroy)(struct mail_storage *storage);
8cb72c59d5ea4e9e5f638d7ec840bb853f5a188eTimo Sirainen void (*add_list)(struct mail_storage *storage,
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen void (*get_list_settings)(const struct mail_namespace *ns,
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen bool (*autodetect)(const struct mail_namespace *ns,
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen struct mailbox *(*mailbox_alloc)(struct mail_storage *storage,
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen /* mailboxes are files, not directories */
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen MAIL_STORAGE_CLASS_FLAG_MAILBOX_IS_FILE = 0x01,
a94936bafd127680184da114c6a177b37ff656e5Timo Sirainen /* root_dir points to a unique directory */
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainen /* mailbox_open_stream() is supported */
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen /* never use quota for this storage (e.g. virtual mailboxes) */
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen /* Storage doesn't need a mail root directory */
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen /* Storage uses one file per message */
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen/* private: */
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen /* counting number of times mail_storage_create() has returned this
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen same storage. */
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen /* counting number of objects (e.g. mailbox) that have a pointer
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen to this storage. */
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen /* Linked list of all mailboxes in the storage */
67c24901ac5e1521e38a91efc452faeb3e2135a1Timo Sirainen /* Module-specific contexts. See mail_storage_module_id. */
67c24901ac5e1521e38a91efc452faeb3e2135a1Timo Sirainen ARRAY_DEFINE(module_contexts, union mail_storage_module_context *);
67c24901ac5e1521e38a91efc452faeb3e2135a1Timo Sirainen const char *content_type, *content_disposition;
67c24901ac5e1521e38a91efc452faeb3e2135a1Timo Sirainen int (*enable)(struct mailbox *box, enum mailbox_feature features);
67c24901ac5e1521e38a91efc452faeb3e2135a1Timo Sirainen int (*exists)(struct mailbox *box, bool auto_boxes,
8cb72c59d5ea4e9e5f638d7ec840bb853f5a188eTimo Sirainen int (*create)(struct mailbox *box, const struct mailbox_update *update,
8cb72c59d5ea4e9e5f638d7ec840bb853f5a188eTimo Sirainen int (*update)(struct mailbox *box, const struct mailbox_update *update);
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen int (*rename)(struct mailbox *src, struct mailbox *dest,
c09f9f95db314e7482c95e502e1c56ed6c555797Timo Sirainen int (*get_status)(struct mailbox *box, enum mailbox_status_items items,
a94936bafd127680184da114c6a177b37ff656e5Timo Sirainen int (*set_subscribed)(struct mailbox *box, bool set);
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainen /* Lookup sync extension record and figure out if it mailbox has
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen changed since. Returns 1 = yes, 0 = no, -1 = error. */
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen int (*list_index_has_changed)(struct mailbox *box,
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen /* Update the sync extension record. */
b3142c8e513bc78da821fa70f479016148fa95e5Timo Sirainen void (*list_index_update_sync)(struct mailbox *box,
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen bool (*sync_next)(struct mailbox_sync_context *ctx,
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen int (*sync_deinit)(struct mailbox_sync_context *ctx,
07e4875d250e7a7157cd99132aafc773cf3cdf83Timo Sirainen /* Called once for each expunge. Called one or more times for
07e4875d250e7a7157cd99132aafc773cf3cdf83Timo Sirainen flag/keyword changes. Once the sync is finished, called with
07e4875d250e7a7157cd99132aafc773cf3cdf83Timo Sirainen uid=0 and sync_type=0. */
07e4875d250e7a7157cd99132aafc773cf3cdf83Timo Sirainen void (*sync_notify)(struct mailbox *box, uint32_t uid,
07e4875d250e7a7157cd99132aafc773cf3cdf83Timo Sirainen int (*transaction_commit)(struct mailbox_transaction_context *t,
07e4875d250e7a7157cd99132aafc773cf3cdf83Timo Sirainen struct mail_transaction_commit_changes *changes_r);
07e4875d250e7a7157cd99132aafc773cf3cdf83Timo Sirainen void (*transaction_rollback)(struct mailbox_transaction_context *t);
8cb72c59d5ea4e9e5f638d7ec840bb853f5a188eTimo Sirainen enum mail_flags (*get_private_flags_mask)(struct mailbox *box);
07e4875d250e7a7157cd99132aafc773cf3cdf83Timo Sirainen (*mail_alloc)(struct mailbox_transaction_context *t,
07e4875d250e7a7157cd99132aafc773cf3cdf83Timo Sirainen struct mailbox_header_lookup_ctx *wanted_headers);
07e4875d250e7a7157cd99132aafc773cf3cdf83Timo Sirainen (*search_init)(struct mailbox_transaction_context *t,
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainen struct mailbox_header_lookup_ctx *wanted_headers);
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainen int (*search_deinit)(struct mail_search_context *ctx);
07e4875d250e7a7157cd99132aafc773cf3cdf83Timo Sirainen bool (*search_next_nonblock)(struct mail_search_context *ctx,
07e4875d250e7a7157cd99132aafc773cf3cdf83Timo Sirainen /* Internal search function which updates ctx->seq */
07e4875d250e7a7157cd99132aafc773cf3cdf83Timo Sirainen bool (*search_next_update_seq)(struct mail_search_context *ctx);
fe363b433b8038a69b55169da9dca27892ad7d18Timo Sirainen (*save_alloc)(struct mailbox_transaction_context *t);
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainen int (*save_begin)(struct mail_save_context *ctx, struct istream *input);
6ef7e31619edfaa17ed044b45861d106a86191efTimo Sirainen int (*save_continue)(struct mail_save_context *ctx);
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen int (*save_finish)(struct mail_save_context *ctx);
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainen void (*save_cancel)(struct mail_save_context *ctx);
03f5c621d06d6b6d77a145196c9633a7aa64dc78Timo Sirainen int (*copy)(struct mail_save_context *ctx, struct mail *mail);
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen /* Called during transaction commit/rollback if saving was done */
e11a64ffc7f08b4cb05bcc27668d154d33d0c2e0Timo Sirainen int (*transaction_save_commit_pre)(struct mail_save_context *save_ctx);
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen struct mail_index_transaction_commit_result *result_r);
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainen void (*transaction_save_rollback)(struct mail_save_context *save_ctx);
a94936bafd127680184da114c6a177b37ff656e5Timo Sirainen /* mailbox's virtual name (from mail_namespace_get_vname()) */
9511a40d933181045343110c8101b75887062aaeTimo Sirainen/* private: */
03f5c621d06d6b6d77a145196c9633a7aa64dc78Timo Sirainen /* Linked list of all mailboxes in this storage */
03f5c621d06d6b6d77a145196c9633a7aa64dc78Timo Sirainen /* these won't be set until mailbox is opened: */
const char *_path;
const char *index_prefix;
unsigned int transaction_count;
void *notify_context;
unsigned int generation_sequence;
struct mail_vfuncs {
const char **value_r);
union mail_module_context {
struct mail_private {
struct mailbox_list_context {
bool failed;
struct mailbox_transaction_stats {
unsigned long open_lookup_count;
unsigned long stat_lookup_count;
unsigned long fstat_lookup_count;
unsigned long files_read_count;
unsigned long long files_read_bytes;
unsigned long cache_hit_count;
struct mailbox_transaction_context {
int mail_ref_count;
union mailbox_transaction_module_context *);
union mail_search_module_context {
struct mail_search_context {
struct mail_save_context {
int received_tz_offset;
unsigned int pop3_order;
struct mailbox_sync_context {
struct mailbox_header_lookup_ctx {
int refcount;
unsigned int count;
const char *const *name;
unsigned int *idx;
int *fd_r);
unsigned int secs);