mail-storage-private.h revision 4b41116563110d00330896a568eff1078c382827
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen/* Called after mail storage has been created */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenextern void (*hook_mail_storage_created)(struct mail_storage *storage);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen/* Called after mailbox has been opened */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenextern void (*hook_mailbox_opened)(struct mailbox *box);
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen unsigned int id;
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen unsigned int id;
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen void (*class_init)(void);
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen int (*create)(struct mail_storage *storage, const char *data);
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen void (*destroy)(struct mail_storage *storage);
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen bool (*autodetect)(const char *data, enum mail_storage_flags flags);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen struct mailbox *(*mailbox_open)(struct mail_storage *storage,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen int (*mailbox_create)(struct mail_storage *storage, const char *name,
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainen/* private: */
98c1cf256927e254f0c092acd2ddcd7ea50bd009Timo Sirainen const char *user; /* name of user accessing the storage */
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen /* Module-specific contexts. See mail_storage_module_id. */
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen ARRAY_DEFINE(module_contexts, union mail_storage_module_context *);
8153fdec343e40e2a78f5c12353e89b994b28f74Timo Sirainen /* IMAP: Give a BAD reply instead of NO */
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen /* Internal temporary error, as opposed to visible user errors like
b5e6f6f27c1461f0f9f202615eeb738a645188c3Timo Sirainen "permission denied" or "out of disk space" */
8d80659e504ffb34bb0c6a633184fece35751b18Timo Sirainen bool (*allow_new_keywords)(struct mailbox *box);
39775ad03c459efe64cce924658da5094ba417e1Timo Sirainen int (*get_status)(struct mailbox *box, enum mailbox_status_items items,
84e1634acc701d14e358e27f1beff5ad74f5004aTimo Sirainen int (*sync_next)(struct mailbox_sync_context *ctx,
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen int (*sync_deinit)(struct mailbox_sync_context *ctx,
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen /* Called once for each expunge. Called one or more times for
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen flag/keyword changes. Once the sync is finished, called with
39775ad03c459efe64cce924658da5094ba417e1Timo Sirainen uid=0 and sync_type=0. */
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen void (*sync_notify)(struct mailbox *box, uint32_t uid,
178511b57faa7c3f8203dd8b7e4059d00cbfc23aTimo Sirainen int (*transaction_commit)(struct mailbox_transaction_context *t,
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen void (*transaction_rollback)(struct mailbox_transaction_context *t);
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen (*keywords_create)(struct mailbox_transaction_context *t,
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen const char *const keywords[]);
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen void (*keywords_free)(struct mailbox_transaction_context *t,
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen int (*get_uids)(struct mailbox *box, uint32_t uid1, uint32_t uid2,
e5c08648676d1989f6e70b95e5990c26b3e8b96bTimo Sirainen (*mail_alloc)(struct mailbox_transaction_context *t,
c3412ddeb9abc13f99d3caf50faf76cd99f7e9d2Timo Sirainen struct mailbox_header_lookup_ctx *wanted_headers);
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen const char *const headers[]);
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen void (*header_lookup_deinit)(struct mailbox_header_lookup_ctx *ctx);
b5e6f6f27c1461f0f9f202615eeb738a645188c3Timo Sirainen (*search_init)(struct mailbox_transaction_context *t,
9a06cabdfdf4d5e2f19a07e506c3c7d08a7e7038Timo Sirainen const char *charset, struct mail_search_arg *args,
9a06cabdfdf4d5e2f19a07e506c3c7d08a7e7038Timo Sirainen int (*search_deinit)(struct mail_search_context *ctx);
e8a35266a5ceacdfafeeffd6bddae77931ff97ebTimo Sirainen int (*search_next_nonblock)(struct mail_search_context *ctx,
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen /* Internal search function which updates ctx->seq */
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen int (*search_next_update_seq)(struct mail_search_context *ctx);
8d80659e504ffb34bb0c6a633184fece35751b18Timo Sirainen int (*save_init)(struct mailbox_transaction_context *t,
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen const char *from_envelope, struct istream *input,
39775ad03c459efe64cce924658da5094ba417e1Timo Sirainen int (*save_continue)(struct mail_save_context *ctx);
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen int (*save_finish)(struct mail_save_context *ctx);
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen void (*save_cancel)(struct mail_save_context *ctx);
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen int (*copy)(struct mailbox_transaction_context *t, struct mail *mail,
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen enum mail_flags flags, struct mail_keywords *keywords,
6843896c40bee4f9b6680ca7ced598c446e9f999Timo Sirainen/* private: */
7a6b45405fb1544ac476e6eb1402a70cc1ddcdcfTimo Sirainen /* Mailbox notification settings: */
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen /* Module-specific contexts. See mail_storage_module_id. */
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen ARRAY_DEFINE(module_contexts, union mailbox_module_context *);
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen /* When FAST open flag is used, the mailbox isn't actually opened until
36e2fa21c22452470c1509cc63de20f7415c7b5eTimo Sirainen it's synced for the first time. */
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen int (*set_seq)(struct mail *mail, uint32_t seq);
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen int (*set_uid)(struct mail *mail, uint32_t uid);
345212e8f61ebf14ff4f80df26df9e655eb5121eTimo Sirainen enum mail_flags (*get_flags)(struct mail *mail);
ccb70ccfd9a25e490aab46d15d9b8323ad9ea3bfTimo Sirainen const char *const *(*get_keywords)(struct mail *mail);
ccb70ccfd9a25e490aab46d15d9b8323ad9ea3bfTimo Sirainen const struct message_part *(*get_parts)(struct mail *mail);
345212e8f61ebf14ff4f80df26df9e655eb5121eTimo Sirainen time_t (*get_date)(struct mail *mail, int *timezone);
345212e8f61ebf14ff4f80df26df9e655eb5121eTimo Sirainen time_t (*get_received_date)(struct mail *mail);
ccb70ccfd9a25e490aab46d15d9b8323ad9ea3bfTimo Sirainen uoff_t (*get_virtual_size)(struct mail *mail);
ccb70ccfd9a25e490aab46d15d9b8323ad9ea3bfTimo Sirainen uoff_t (*get_physical_size)(struct mail *mail);
ccb70ccfd9a25e490aab46d15d9b8323ad9ea3bfTimo Sirainen const char *(*get_first_header)(struct mail *mail, const char *field);
ccb70ccfd9a25e490aab46d15d9b8323ad9ea3bfTimo Sirainen const char *const *(*get_headers)(struct mail *mail, const char *field);
ccb70ccfd9a25e490aab46d15d9b8323ad9ea3bfTimo Sirainen struct istream *(*get_stream)(struct mail *mail,
ccb70ccfd9a25e490aab46d15d9b8323ad9ea3bfTimo Sirainen int (*update_flags)(struct mail *mail, enum modify_type modify_type,
43d504fb5b23e14878e9777cdebff9c623f0b52cTimo Sirainen int (*update_keywords)(struct mail *mail, enum modify_type modify_type,
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen ARRAY_DEFINE(module_contexts, union mail_module_context *);
bb10ebcf076c959c752f583746d83805d7686df8Timo Sirainen struct mailbox_transaction_context *transaction;
91dca97b367c54a139c268b56a0c67f564bd9197Timo Sirainen struct mail_search_sort_program *sort_program;
bb10ebcf076c959c752f583746d83805d7686df8Timo Sirainen ARRAY_DEFINE(module_contexts, union mail_search_module_context *);
bb10ebcf076c959c752f583746d83805d7686df8Timo Sirainen struct mailbox_transaction_context *transaction;
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen/* Modules should use do "my_id = mail_storage_module_id++" and
6843896c40bee4f9b6680ca7ced598c446e9f999Timo Sirainen use objects' module_contexts[id] for their own purposes. */
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainenextern struct mail_storage_module_register mail_storage_module_register;
df4018ae2f0a95be602f724ca70df7e0e3bd6a7dTimo Sirainen/* Storage's module_id for mail_index. */
a393d9d6dabdc46cf724f8cb004a652b4036d53dTimo Sirainenextern struct mail_module_register mail_module_register;
6843896c40bee4f9b6680ca7ced598c446e9f999Timo Sirainen MODULE_CONTEXT(obj, mail_storage_mail_index_module)
b5e6f6f27c1461f0f9f202615eeb738a645188c3Timo Sirainenextern MODULE_CONTEXT_DEFINE(mail_storage_mail_index_module,
2bf7bb14894faf721518e2122a14a2389ef94078Timo Sirainen/* Set error message in storage. Critical errors are logged with i_error(),
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen but user sees only "internal error" message. */
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainenvoid mail_storage_clear_error(struct mail_storage *storage);
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainenvoid mail_storage_set_error(struct mail_storage *storage,
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainenvoid mail_storage_set_syntax_error(struct mail_storage *storage,
a393d9d6dabdc46cf724f8cb004a652b4036d53dTimo Sirainenvoid mail_storage_set_critical(struct mail_storage *storage,
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainenvoid mail_storage_set_internal_error(struct mail_storage *storage);
2bf7bb14894faf721518e2122a14a2389ef94078Timo Sirainenconst char *mail_storage_class_get_last_error(struct mail_storage *storage,
2bf7bb14894faf721518e2122a14a2389ef94078Timo Sirainenmail_storage_get_list_flags(enum mail_storage_flags storage_flags);
2bf7bb14894faf721518e2122a14a2389ef94078Timo Sirainenbool mail_storage_errno2str(const char **error_r);