mail-storage-private.h revision 70ead6466f9baa8294e71fc2fba0a4f54f488b5e
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen/* Called after mail storage has been created */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenextern void (*hook_mail_storage_created)(struct mail_storage *storage);
6a19e109ee8c5a6f688da83a86a7f6abeb71abddTimo Sirainen/* Called after mailbox has been opened */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenextern void (*hook_mailbox_opened)(struct mailbox *box);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen/* Called after mailbox index has been opened */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenextern void (*hook_mailbox_index_opened)(struct mailbox *box);
31ddc75584c5cde53d2e78a737587f2e7fdcb0d2Timo Sirainen unsigned int id;
51b979b6414b940f04677a7e2d064be119345954Timo Sirainen unsigned int id;
c53e8ee216904ffe6de4f6518d9f9f5107b7610eTimo Sirainen void (*class_init)(void);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen int (*create)(struct mail_storage *storage, const char *data,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen const char **error_r);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen void (*destroy)(struct mail_storage *storage);
b7b81543899e306c71e6152516d8698416162bcbTimo Sirainen bool (*autodetect)(const char *data, enum mail_storage_flags flags);
6ec7cf71ccd0eed1f9cc1b0bda8960796b04160bTimo Sirainen struct mailbox *(*mailbox_open)(struct mail_storage *storage,
db5164c9a1129af0cfb11fc18d88da361a8011fbTimo Sirainen int (*mailbox_create)(struct mail_storage *storage, const char *name,
024815ea2ffdda9ea79919f18e865663977f73eaTimo Sirainen/* private: */
1d3f7c1278168d5b1cbfa9a2cc9929a0909056b4Timo Sirainen /* Module-specific contexts. See mail_storage_module_id. */
1d3f7c1278168d5b1cbfa9a2cc9929a0909056b4Timo Sirainen ARRAY_DEFINE(module_contexts, union mail_storage_module_context *);
51795bfe9d05d92fe942cb451aec2b9d16d32a11Timo Sirainen bool (*allow_new_keywords)(struct mailbox *box);
51795bfe9d05d92fe942cb451aec2b9d16d32a11Timo Sirainen int (*enable)(struct mailbox *box, enum mailbox_feature features);
8aacc9e7c84f8376822823ec98c2f551d4919b2eTimo Sirainen void (*get_status)(struct mailbox *box, enum mailbox_status_items items,
8aacc9e7c84f8376822823ec98c2f551d4919b2eTimo Sirainen /* Lookup sync extension record and figure out if it mailbox has
8aacc9e7c84f8376822823ec98c2f551d4919b2eTimo Sirainen changed since. Returns 1 = yes, 0 = no, -1 = error. */
8aacc9e7c84f8376822823ec98c2f551d4919b2eTimo Sirainen int (*list_index_has_changed)(struct mailbox *box,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen /* Update the sync extension record. Returns 0 = ok, -1 = error. */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen int (*list_index_update_sync)(struct mailbox *box,
bb10ebcf076c959c752f583746d83805d7686df8Timo Sirainen bool (*sync_next)(struct mailbox_sync_context *ctx,
bb10ebcf076c959c752f583746d83805d7686df8Timo Sirainen int (*sync_deinit)(struct mailbox_sync_context *ctx,
db87d16551d1081ada01f787ea21aa3ed1402c31Timo Sirainen /* Called once for each expunge. Called one or more times for
db87d16551d1081ada01f787ea21aa3ed1402c31Timo Sirainen flag/keyword changes. Once the sync is finished, called with
db87d16551d1081ada01f787ea21aa3ed1402c31Timo Sirainen uid=0 and sync_type=0. */
db87d16551d1081ada01f787ea21aa3ed1402c31Timo Sirainen void (*sync_notify)(struct mailbox *box, uint32_t uid,
db87d16551d1081ada01f787ea21aa3ed1402c31Timo Sirainen int (*transaction_commit)(struct mailbox_transaction_context *t,
26ff8f8a4867bf8e9551a27a2de8c12cd138b065Timo Sirainen void (*transaction_rollback)(struct mailbox_transaction_context *t);
26ff8f8a4867bf8e9551a27a2de8c12cd138b065Timo Sirainen void (*transaction_set_max_modseq)(struct mailbox_transaction_context *t,
2d39dc1a453546892109b35c0d9770369011a13dTimo Sirainen const char *const keywords[],
2d39dc1a453546892109b35c0d9770369011a13dTimo Sirainen void (*keywords_free)(struct mail_keywords *keywords);
c8adec8db635f5efb13b9879a5f3fb523abdc969Timo Sirainen bool (*keyword_is_valid)(struct mailbox *box, const char *keyword,
c8adec8db635f5efb13b9879a5f3fb523abdc969Timo Sirainen const char **error_r);
d6a1fa1d65c6d1996937802c2482c0f14dd821a7Timo Sirainen void (*get_seq_range)(struct mailbox *box, uint32_t uid1, uint32_t uid2,
7761758f43d6150be4b07f4c54457ce662f78c4cTimo Sirainen bool (*get_expunged_uids)(struct mailbox *box, uint64_t modseq,
6bc98d3898c475ba7615ba2b016e5142c8b2c09fTimo Sirainen void (*get_virtual_backend_boxes)(struct mailbox *box,
659fe5d24825b160cae512538088020d97a60239Timo Sirainen void (*get_virtual_box_patterns)(struct mailbox *box,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen ARRAY_TYPE(mailbox_virtual_patterns) *includes,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen ARRAY_TYPE(mailbox_virtual_patterns) *excludes);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen (*mail_alloc)(struct mailbox_transaction_context *t,
bb10ebcf076c959c752f583746d83805d7686df8Timo Sirainen struct mailbox_header_lookup_ctx *wanted_headers);
020a39a395d2adb768e0179631b37bc78ecd9471Timo Sirainen const char *const headers[]);
020a39a395d2adb768e0179631b37bc78ecd9471Timo Sirainen void (*header_lookup_ref)(struct mailbox_header_lookup_ctx *ctx);
020a39a395d2adb768e0179631b37bc78ecd9471Timo Sirainen void (*header_lookup_unref)(struct mailbox_header_lookup_ctx *ctx);
020a39a395d2adb768e0179631b37bc78ecd9471Timo Sirainen (*search_init)(struct mailbox_transaction_context *t,
6a19e109ee8c5a6f688da83a86a7f6abeb71abddTimo Sirainen int (*search_deinit)(struct mail_search_context *ctx);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen int (*search_next_nonblock)(struct mail_search_context *ctx,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen /* Internal search function which updates ctx->seq */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen bool (*search_next_update_seq)(struct mail_search_context *ctx);
d5cebe7f98e63d4e2822863ef2faa4971e8b3a5dTimo Sirainen (*save_alloc)(struct mailbox_transaction_context *t);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen int (*save_begin)(struct mail_save_context *ctx, struct istream *input);
80fc743146da5130de34174cdaad2576f103723fTimo Sirainen int (*save_continue)(struct mail_save_context *ctx);
80fc743146da5130de34174cdaad2576f103723fTimo Sirainen int (*save_finish)(struct mail_save_context *ctx);
80fc743146da5130de34174cdaad2576f103723fTimo Sirainen void (*save_cancel)(struct mail_save_context *ctx);
80fc743146da5130de34174cdaad2576f103723fTimo Sirainen int (*copy)(struct mail_save_context *ctx, struct mail *mail);
d30da25fb6be1f1c667d93767c9194000194b618Timo Sirainen/* private: */
d5cebe7f98e63d4e2822863ef2faa4971e8b3a5dTimo Sirainen /* User's private flags if this is a shared mailbox */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen /* mode and GID to use for newly created files/dirs */
6ef7e31619edfaa17ed044b45861d106a86191efTimo Sirainen /* Mailbox notification settings: */
db87d16551d1081ada01f787ea21aa3ed1402c31Timo Sirainen /* Saved search results */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen ARRAY_DEFINE(search_results, struct mail_search_result *);
db87d16551d1081ada01f787ea21aa3ed1402c31Timo Sirainen /* Module-specific contexts. See mail_storage_module_id. */
d5cebe7f98e63d4e2822863ef2faa4971e8b3a5dTimo Sirainen ARRAY_DEFINE(module_contexts, union mailbox_module_context *);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen /* When FAST open flag is used, the mailbox isn't actually opened until
d5cebe7f98e63d4e2822863ef2faa4971e8b3a5dTimo Sirainen it's synced for the first time. */
2674b4f0cf8f3c203d8e56b29735f5e267038dafTimo Sirainen /* Mailbox was deleted while we had it open. */
e376693bfa3985232c41df99c7010fca22612c89Timo Sirainen void (*set_seq)(struct mail *mail, uint32_t seq);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen bool (*set_uid)(struct mail *mail, uint32_t uid);
09c3a491f4f6ccebe290c7709bdc0d79a187610bTimo Sirainen enum mail_flags (*get_flags)(struct mail *mail);
09c3a491f4f6ccebe290c7709bdc0d79a187610bTimo Sirainen const char *const *(*get_keywords)(struct mail *mail);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen int (*get_date)(struct mail *mail, time_t *date_r, int *timezone_r);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen int (*get_received_date)(struct mail *mail, time_t *date_r);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen int (*get_save_date)(struct mail *mail, time_t *date_r);
b92813e2f96d4b28f989528ed5dd6115da7d9bdbTimo Sirainen int (*get_virtual_size)(struct mail *mail, uoff_t *size_r);
b92813e2f96d4b28f989528ed5dd6115da7d9bdbTimo Sirainen int (*get_physical_size)(struct mail *mail, uoff_t *size_r);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen int (*get_first_header)(struct mail *mail, const char *field,
d152ccd0d29fae1bc6092bf198ee7eb843202f96Timo Sirainen int (*get_headers)(struct mail *mail, const char *field,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen bool decode_to_utf8, const char *const **value_r);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen int (*get_stream)(struct mail *mail, struct message_size *hdr_size,
d152ccd0d29fae1bc6092bf198ee7eb843202f96Timo Sirainen int (*get_special)(struct mail *mail, enum mail_fetch_field field,
d152ccd0d29fae1bc6092bf198ee7eb843202f96Timo Sirainen const char **value_r);
d152ccd0d29fae1bc6092bf198ee7eb843202f96Timo Sirainen void (*update_flags)(struct mail *mail, enum modify_type modify_type,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen void (*update_keywords)(struct mail *mail, enum modify_type modify_type,
2d39dc1a453546892109b35c0d9770369011a13dTimo Sirainen void (*set_cache_corrupted)(struct mail *mail,
8f8315e4b4e27ead12dd1c3da65bf4dee3762f18Timo Sirainen struct index_mail *(*get_index_mail)(struct mail *mail);
b08b33d1f5ce3721dc2d83586c9cb0ca141331fdTimo Sirainen struct mailbox_header_lookup_ctx *wanted_headers;
6ef7e31619edfaa17ed044b45861d106a86191efTimo Sirainen ARRAY_DEFINE(module_contexts, union mail_module_context *);
94a8cb0ee1d85569ad1a2acacd92d3ce22f8a1cbTimo Sirainen struct mailbox_transaction_context *transaction;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen struct mail_search_sort_program *sort_program;
b20fb5b1df9d604a7541f5118fc5b4b466d211efTimo Sirainen /* if non-NULL, specifies that a search resulting is being updated.
73b50eecfc31750a312e2f940023f522eb07178cTimo Sirainen this can be used as a search optimization: if searched message
73b50eecfc31750a312e2f940023f522eb07178cTimo Sirainen already exists in search result, it's not necessary to check if
73b50eecfc31750a312e2f940023f522eb07178cTimo Sirainen static data matches. */
73b50eecfc31750a312e2f940023f522eb07178cTimo Sirainen /* add matches to these search results */
73b50eecfc31750a312e2f940023f522eb07178cTimo Sirainen ARRAY_DEFINE(results, struct mail_search_result *);
73b50eecfc31750a312e2f940023f522eb07178cTimo Sirainen ARRAY_DEFINE(module_contexts, union mail_search_module_context *);
3da614c39dd29f536c485089e67839b4cf89fed3Timo Sirainen struct mailbox_transaction_context *transaction;
09c3a491f4f6ccebe290c7709bdc0d79a187610bTimo Sirainen const char *const *headers;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen/* Modules should use do "my_id = mail_storage_module_id++" and
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen use objects' module_contexts[id] for their own purposes. */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenextern struct mail_storage_module_register mail_storage_module_register;
16c89b1260c9d07c01c83a9219424d3727069b2eTimo Sirainen/* Storage's module_id for mail_index. */
c251a38df327599a62d341bf5c2282f31352faa5Timo Sirainenextern struct mail_module_register mail_module_register;
c251a38df327599a62d341bf5c2282f31352faa5Timo Sirainen MODULE_CONTEXT(obj, mail_storage_mail_index_module)
ae8817f05005f57bba32479a610b52d083e2b6ebTimo Sirainenextern MODULE_CONTEXT_DEFINE(mail_storage_mail_index_module,
16c89b1260c9d07c01c83a9219424d3727069b2eTimo Sirainen/* Set error message in storage. Critical errors are logged with i_error(),
6825360d446542046757b06064282301c4c6b27cTimo Sirainen but user sees only "internal error" message. */
6ef7e31619edfaa17ed044b45861d106a86191efTimo Sirainenvoid mail_storage_clear_error(struct mail_storage *storage);
6825360d446542046757b06064282301c4c6b27cTimo Sirainenvoid mail_storage_set_error(struct mail_storage *storage,
6825360d446542046757b06064282301c4c6b27cTimo Sirainenvoid mail_storage_set_critical(struct mail_storage *storage,
bb10ebcf076c959c752f583746d83805d7686df8Timo Sirainenvoid mail_storage_set_internal_error(struct mail_storage *storage);
bb10ebcf076c959c752f583746d83805d7686df8Timo Sirainenbool mail_storage_set_error_from_errno(struct mail_storage *storage);