mail-storage-private.h revision d9a129b491613014ce5f31fe1ab20903e2899ea4
8cb72c59d5ea4e9e5f638d7ec840bb853f5a188eTimo Sirainen/* Default prefix for indexes */
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen/* Block size when read()ing message header. */
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen/* Block size when read()ing message (header and) body. */
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen#define MAIL_READ_FULL_BLOCK_SIZE IO_BLOCK_SIZE
8cb72c59d5ea4e9e5f638d7ec840bb853f5a188eTimo Sirainen unsigned int id;
8b247780e911909a9fdc47f69ce6d1478902ad98Timo Sirainen unsigned int id;
862ec874f9373e3e499e237d3b9f71fdf1413feeTimo Sirainen const struct setting_parser_info *(*get_setting_parser_info)(void);
862ec874f9373e3e499e237d3b9f71fdf1413feeTimo Sirainen int (*create)(struct mail_storage *storage, struct mail_namespace *ns,
862ec874f9373e3e499e237d3b9f71fdf1413feeTimo Sirainen const char **error_r);
862ec874f9373e3e499e237d3b9f71fdf1413feeTimo Sirainen void (*destroy)(struct mail_storage *storage);
862ec874f9373e3e499e237d3b9f71fdf1413feeTimo Sirainen void (*add_list)(struct mail_storage *storage,
862ec874f9373e3e499e237d3b9f71fdf1413feeTimo Sirainen void (*get_list_settings)(const struct mail_namespace *ns,
862ec874f9373e3e499e237d3b9f71fdf1413feeTimo Sirainen bool (*autodetect)(const struct mail_namespace *ns,
862ec874f9373e3e499e237d3b9f71fdf1413feeTimo Sirainen struct mailbox *(*mailbox_alloc)(struct mail_storage *storage,
2d2ebe91d56e9a158de000c9d0026f65600fbcfaTimo Sirainen /* mailboxes are files, not directories */
e2ce8d4a6ac5d82a906178148453e7613fab9ba0Timo Sirainen MAIL_STORAGE_CLASS_FLAG_MAILBOX_IS_FILE = 0x01,
f988b93c2ef773987bcdcbfb4cca39b955e3a392Timo Sirainen /* root_dir points to a unique directory */
e2ce8d4a6ac5d82a906178148453e7613fab9ba0Timo Sirainen /* mailbox_open_stream() is supported */
cd56a23e21f1df3f79648cf07e2f4385e2fadebbTimo Sirainen /* never use quota for this storage (e.g. virtual mailboxes) */
e2ce8d4a6ac5d82a906178148453e7613fab9ba0Timo Sirainen /* Storage doesn't need a mail root directory */
cd56a23e21f1df3f79648cf07e2f4385e2fadebbTimo Sirainen /* Storage uses one file per message */
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen/* private: */
eb98a038ca8b0ef33d1d11794803ce09547496faTimo Sirainen /* counting number of times mail_storage_create() has returned this
eb98a038ca8b0ef33d1d11794803ce09547496faTimo Sirainen same storage. */
eb98a038ca8b0ef33d1d11794803ce09547496faTimo Sirainen /* counting number of objects (e.g. mailbox) that have a pointer
eb98a038ca8b0ef33d1d11794803ce09547496faTimo Sirainen to this storage. */
eb98a038ca8b0ef33d1d11794803ce09547496faTimo Sirainen /* Linked list of all mailboxes in the storage */
252db51b6c0a605163326b3ea5d09e9936ca3b29Timo Sirainen /* Filled lazily by mailbox_attribute_*() when accessing shared
2767104d81e97a109f0aa9758792bfa1da325a97Timo Sirainen attributes. */
2767104d81e97a109f0aa9758792bfa1da325a97Timo Sirainen /* Module-specific contexts. See mail_storage_module_id. */
59151b71059df1190acd75d8717ed04a7920c862Timo Sirainen ARRAY(union mail_storage_module_context *) module_contexts;
a10ed8c47534b4c6b6bf2711ccfe577e720a47b4Timo Sirainen /* Failed to create shared attribute dict, don't try again */
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen const char *content_type, *content_disposition;
556f95092c3bc850517d5ab2bb502024a55645f1Timo Sirainen int (*enable)(struct mailbox *box, enum mailbox_feature features);
556f95092c3bc850517d5ab2bb502024a55645f1Timo Sirainen int (*exists)(struct mailbox *box, bool auto_boxes,
2767104d81e97a109f0aa9758792bfa1da325a97Timo Sirainen const struct mailbox_update *update, bool directory);
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen int (*rename_box)(struct mailbox *src, struct mailbox *dest);
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen int (*get_status)(struct mailbox *box, enum mailbox_status_items items,
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen int (*set_subscribed)(struct mailbox *box, bool set);
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen int (*attribute_set)(struct mailbox *box, enum mail_attribute_type type,
10ff47d5d6146995e16da00d36eca7d162064a7bTimo Sirainen int (*attribute_get)(struct mailbox *box, enum mail_attribute_type type,
10ff47d5d6146995e16da00d36eca7d162064a7bTimo Sirainen const char *prefix);
10ff47d5d6146995e16da00d36eca7d162064a7bTimo Sirainen const char *(*attribute_iter_next)(struct mailbox_attribute_iter *iter);
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainen int (*attribute_iter_deinit)(struct mailbox_attribute_iter *iter);
252db51b6c0a605163326b3ea5d09e9936ca3b29Timo Sirainen /* Lookup sync extension record and figure out if it mailbox has
8f32e59200da904613506f5649ffa4d9f5989cebTimo 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. */
d66ef20c30fee728899ee168c75fcc5ff8fbdac1Timo Sirainen void (*list_index_update_sync)(struct mailbox *box,
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen bool (*sync_next)(struct mailbox_sync_context *ctx,
6ef7e31619edfaa17ed044b45861d106a86191efTimo Sirainen int (*sync_deinit)(struct mailbox_sync_context *ctx,
5238111c460098d9cc8cc22527026138a278b9a4Timo Sirainen /* Called once for each expunge. Called one or more times for
3d77cc0d502dc69ffe2afe318605964dd40b7b20Timo Sirainen flag/keyword changes. Once the sync is finished, called with
c9bf63e9094761767a63ac6b189bcf60bcffdc44Timo Sirainen uid=0 and sync_type=0. */
c9bf63e9094761767a63ac6b189bcf60bcffdc44Timo Sirainen void (*sync_notify)(struct mailbox *box, uint32_t uid,
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen int (*transaction_commit)(struct mailbox_transaction_context *t,
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen struct mail_transaction_commit_changes *changes_r);
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen void (*transaction_rollback)(struct mailbox_transaction_context *t);
de954ff15b495be13007a8aca2c09fd1d356a283Timo Sirainen enum mail_flags (*get_private_flags_mask)(struct mailbox *box);
de954ff15b495be13007a8aca2c09fd1d356a283Timo Sirainen (*mail_alloc)(struct mailbox_transaction_context *t,
de954ff15b495be13007a8aca2c09fd1d356a283Timo Sirainen struct mailbox_header_lookup_ctx *wanted_headers);
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen (*search_init)(struct mailbox_transaction_context *t,
d66ef20c30fee728899ee168c75fcc5ff8fbdac1Timo Sirainen struct mailbox_header_lookup_ctx *wanted_headers);
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen int (*search_deinit)(struct mail_search_context *ctx);
d66ef20c30fee728899ee168c75fcc5ff8fbdac1Timo Sirainen bool (*search_next_nonblock)(struct mail_search_context *ctx,
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen /* Internal search function which updates ctx->seq */
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen bool (*search_next_update_seq)(struct mail_search_context *ctx);
6cc0546c058f3e6253c6f99727b28dd602712974Timo Sirainen (*save_alloc)(struct mailbox_transaction_context *t);
6cc0546c058f3e6253c6f99727b28dd602712974Timo Sirainen int (*save_begin)(struct mail_save_context *ctx, struct istream *input);
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen int (*save_continue)(struct mail_save_context *ctx);
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen int (*save_finish)(struct mail_save_context *ctx);
b92e979748a22925b0770d3004eaab043ed69574Timo Sirainen void (*save_cancel)(struct mail_save_context *ctx);
2767104d81e97a109f0aa9758792bfa1da325a97Timo Sirainen int (*copy)(struct mail_save_context *ctx, struct mail *mail);
2767104d81e97a109f0aa9758792bfa1da325a97Timo Sirainen /* Called during transaction commit/rollback if saving was done */
35283613d4c04ce18836e9fc431582c87b3710a0Timo Sirainen int (*transaction_save_commit_pre)(struct mail_save_context *save_ctx);
2767104d81e97a109f0aa9758792bfa1da325a97Timo Sirainen struct mail_index_transaction_commit_result *result_r);
35283613d4c04ce18836e9fc431582c87b3710a0Timo Sirainen void (*transaction_save_rollback)(struct mail_save_context *save_ctx);
0ce5f96804e81cb0f857e7df32c0272f1eed9377Timo Sirainen /* mailbox's virtual name (from mail_namespace_get_vname()) */
6cc0546c058f3e6253c6f99727b28dd602712974Timo Sirainen/* private: */
9de176ef7f3d28ff486c2a8805110b84389e4f19Timo Sirainen /* Linked list of all mailboxes in this storage */
0ce5f96804e81cb0f857e7df32c0272f1eed9377Timo Sirainen /* these won't be set until mailbox is opened: */
9de176ef7f3d28ff486c2a8805110b84389e4f19Timo Sirainen /* Private per-user index/view for shared mailboxes. These are synced
9de176ef7f3d28ff486c2a8805110b84389e4f19Timo Sirainen against the primary index and used to store per-user flags.
9de176ef7f3d28ff486c2a8805110b84389e4f19Timo Sirainen These are non-NULL only when mailbox has per-user flags. */
9de176ef7f3d28ff486c2a8805110b84389e4f19Timo Sirainen /* Filled lazily by mailbox_get_permissions() */
9de176ef7f3d28ff486c2a8805110b84389e4f19Timo Sirainen /* Filled lazily when mailbox is opened, use mailbox_get_path()
9de176ef7f3d28ff486c2a8805110b84389e4f19Timo Sirainen to access it */
b92e979748a22925b0770d3004eaab043ed69574Timo Sirainen /* default vfuncs for new struct mails. */
555ebb032f9b8f0cdb66f27ce7374734833e7cacTimo Sirainen /* Mailbox settings, or NULL if defaults */
e2a88d59c0d47d63ce1ad5b1fd95e487124a3fd4Timo Sirainen /* If non-zero, fail mailbox_open() with this error. mailbox_alloc()
e2a88d59c0d47d63ce1ad5b1fd95e487124a3fd4Timo Sirainen can set this to force open to fail. */
e2a88d59c0d47d63ce1ad5b1fd95e487124a3fd4Timo Sirainen struct mail_msgpart_partial_cache partial_cache;
e2a88d59c0d47d63ce1ad5b1fd95e487124a3fd4Timo Sirainen /* Mailbox notification settings: */
9de176ef7f3d28ff486c2a8805110b84389e4f19Timo Sirainen /* Increased by one for each new struct mailbox. */
9de176ef7f3d28ff486c2a8805110b84389e4f19Timo Sirainen /* Saved search results */
9de176ef7f3d28ff486c2a8805110b84389e4f19Timo Sirainen ARRAY(struct mail_search_result *) search_results;
e2a88d59c0d47d63ce1ad5b1fd95e487124a3fd4Timo Sirainen /* Module-specific contexts. See mail_storage_module_id. */
e2a88d59c0d47d63ce1ad5b1fd95e487124a3fd4Timo Sirainen ARRAY(union mailbox_module_context *) module_contexts;
e2a88d59c0d47d63ce1ad5b1fd95e487124a3fd4Timo Sirainen /* When FAST open flag is used, the mailbox isn't actually opened until
e2a88d59c0d47d63ce1ad5b1fd95e487124a3fd4Timo Sirainen it's synced for the first time. */
e2a88d59c0d47d63ce1ad5b1fd95e487124a3fd4Timo Sirainen /* Mailbox was deleted while we had it open. */
e2a88d59c0d47d63ce1ad5b1fd95e487124a3fd4Timo Sirainen /* Mailbox is being created */
e2a88d59c0d47d63ce1ad5b1fd95e487124a3fd4Timo Sirainen /* Mailbox is being deleted */
e2a88d59c0d47d63ce1ad5b1fd95e487124a3fd4Timo Sirainen /* Delete mailbox only if it's empty */
e2a88d59c0d47d63ce1ad5b1fd95e487124a3fd4Timo Sirainen /* Mailbox was already marked as deleted within this allocation. */
e2a88d59c0d47d63ce1ad5b1fd95e487124a3fd4Timo Sirainen /* TRUE if this is an INBOX for this user */
98a73e104c7b9c3747053e63113451e24daf7f36Timo Sirainen /* TRUE if this is an INBOX for this namespace (user or shared) */
9de176ef7f3d28ff486c2a8805110b84389e4f19Timo Sirainen /* When copying to this mailbox, require that mailbox_copy() uses
9de176ef7f3d28ff486c2a8805110b84389e4f19Timo Sirainen mailbox_save_*() to actually save a new physical copy rather than
9de176ef7f3d28ff486c2a8805110b84389e4f19Timo Sirainen simply incrementing a reference count (e.g. via hard link) */
9de176ef7f3d28ff486c2a8805110b84389e4f19Timo Sirainen /* Don't allow creating any new keywords */
e2a88d59c0d47d63ce1ad5b1fd95e487124a3fd4Timo Sirainen /* Mailbox has been synced at least once */
98a73e104c7b9c3747053e63113451e24daf7f36Timo Sirainen void (*set_seq)(struct mail *mail, uint32_t seq, bool saving);
e2a88d59c0d47d63ce1ad5b1fd95e487124a3fd4Timo Sirainen bool (*set_uid)(struct mail *mail, uint32_t uid);
e2a88d59c0d47d63ce1ad5b1fd95e487124a3fd4Timo Sirainen void (*set_uid_cache_updates)(struct mail *mail, bool set);
e2a88d59c0d47d63ce1ad5b1fd95e487124a3fd4Timo Sirainen void (*add_temp_wanted_fields)(struct mail *mail,
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainen enum mail_flags (*get_flags)(struct mail *mail);
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen const char *const *(*get_keywords)(struct mail *mail);
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen int (*get_date)(struct mail *mail, time_t *date_r, int *timezone_r);
d66ef20c30fee728899ee168c75fcc5ff8fbdac1Timo Sirainen int (*get_received_date)(struct mail *mail, time_t *date_r);
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen int (*get_save_date)(struct mail *mail, time_t *date_r);
989cafb9d84d8c98d6441fc1ab45b4c37762a98aTimo Sirainen int (*get_virtual_size)(struct mail *mail, uoff_t *size_r);
d66ef20c30fee728899ee168c75fcc5ff8fbdac1Timo Sirainen int (*get_physical_size)(struct mail *mail, uoff_t *size_r);
63866b7a81355543832d3fe01cd744ddd4ea197bTimo Sirainen int (*get_first_header)(struct mail *mail, const char *field,
63866b7a81355543832d3fe01cd744ddd4ea197bTimo Sirainen int (*get_headers)(struct mail *mail, const char *field,
63866b7a81355543832d3fe01cd744ddd4ea197bTimo Sirainen bool decode_to_utf8, const char *const **value_r);
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen int (*get_stream)(struct mail *mail, bool get_body,
8cdb3234fe3c77e477c7a0e6934678f58fc54d4dTimo Sirainen int (*get_special)(struct mail *mail, enum mail_fetch_field field,
8cdb3234fe3c77e477c7a0e6934678f58fc54d4dTimo Sirainen const char **value_r);
8cdb3234fe3c77e477c7a0e6934678f58fc54d4dTimo Sirainen struct mail *(*get_real_mail)(struct mail *mail);
8cdb3234fe3c77e477c7a0e6934678f58fc54d4dTimo Sirainen void (*update_flags)(struct mail *mail, enum modify_type modify_type,
8cdb3234fe3c77e477c7a0e6934678f58fc54d4dTimo Sirainen void (*update_keywords)(struct mail *mail, enum modify_type modify_type,
8cdb3234fe3c77e477c7a0e6934678f58fc54d4dTimo Sirainen void (*update_modseq)(struct mail *mail, uint64_t min_modseq);
8cdb3234fe3c77e477c7a0e6934678f58fc54d4dTimo Sirainen void (*update_pop3_uidl)(struct mail *mail, const char *uidl);
8ab3d88c56dff2f567193f80cc29821a64e576d1Timo Sirainen void (*set_cache_corrupted)(struct mail *mail,
8ab3d88c56dff2f567193f80cc29821a64e576d1Timo Sirainen int (*istream_opened)(struct mail *mail, struct istream **input);
8ab3d88c56dff2f567193f80cc29821a64e576d1Timo Sirainen /* initial wanted fields/headers, set by mail_alloc(): */
8ab3d88c56dff2f567193f80cc29821a64e576d1Timo Sirainen struct mailbox_header_lookup_ctx *wanted_headers;
8ab3d88c56dff2f567193f80cc29821a64e576d1Timo Sirainen ARRAY(union mail_module_context *) module_contexts;
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen /* number of files we've opened and read */
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen /* number of bytes we've had to read from files */
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen unsigned long long files_read_bytes;
e2ce8d4a6ac5d82a906178148453e7613fab9ba0Timo Sirainen /* number of cache lookup hits */
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen union mail_index_transaction_module_context module_ctx;
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen /* view contains all changes done within this transaction */
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen /* for private index updates: */
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen struct mail_cache_transaction_ctx *cache_trans;
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen struct mail_transaction_commit_changes *changes;
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen ARRAY(union mailbox_transaction_module_context *) module_contexts;
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen /* these statistics are never reset by mail-storage API: */
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen /* Set to TRUE to update stats_* fields */
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen /* We've done some non-transactional (e.g. dovecot-uidlist updates) */
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen struct mailbox_transaction_context *transaction;
2d2ebe91d56e9a158de000c9d0026f65600fbcfaTimo Sirainen struct mail_search_sort_program *sort_program;
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen struct mailbox_header_lookup_ctx *wanted_headers;
d691782ae9eb4f6ab06bc42f1617e889e7c18a3bTimo Sirainen /* if non-NULL, specifies that a search resulting is being updated.
d691782ae9eb4f6ab06bc42f1617e889e7c18a3bTimo Sirainen this can be used as a search optimization: if searched message
d691782ae9eb4f6ab06bc42f1617e889e7c18a3bTimo Sirainen already exists in search result, it's not necessary to check if
d691782ae9eb4f6ab06bc42f1617e889e7c18a3bTimo Sirainen static data matches. */
d691782ae9eb4f6ab06bc42f1617e889e7c18a3bTimo Sirainen /* add matches to these search results */
d691782ae9eb4f6ab06bc42f1617e889e7c18a3bTimo Sirainen ARRAY(union mail_search_module_context *) module_contexts;
f28583935a4509d3f7932738bba6c548ef455c82Timo Sirainen struct mailbox_transaction_context *transaction;
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen /* data that changes for each saved mail */
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen /* returns TRUE if message part is an attachment. */
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen bool (*part_is_attachment)(struct mail_save_context *ctx,
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen /* mail was copied using saving */
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen /* mail is being saved, not copied */
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen /* mail is being moved - ignore quota */
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen unsigned int count;
981139bb2e446bb2050c1158614725f8413fd709Timo Sirainen const char *const *name;
981139bb2e446bb2050c1158614725f8413fd709Timo Sirainen unsigned int *idx;
981139bb2e446bb2050c1158614725f8413fd709Timo Sirainen/* Modules should use do "my_id = mail_storage_module_id++" and
981139bb2e446bb2050c1158614725f8413fd709Timo Sirainen use objects' module_contexts[id] for their own purposes. */
981139bb2e446bb2050c1158614725f8413fd709Timo Sirainenextern struct mail_storage_module_register mail_storage_module_register;
981139bb2e446bb2050c1158614725f8413fd709Timo Sirainen/* Storage's module_id for mail_index. */
981139bb2e446bb2050c1158614725f8413fd709Timo Sirainenextern struct mail_module_register mail_module_register;
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen MODULE_CONTEXT(obj, mail_storage_mail_index_module)
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainenextern MODULE_CONTEXT_DEFINE(mail_storage_mail_index_module,
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainenvoid mail_storage_obj_ref(struct mail_storage *storage);
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainenvoid mail_storage_obj_unref(struct mail_storage *storage);
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen/* Set error message in storage. Critical errors are logged with i_error(),
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen but user sees only "internal error" message. */
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainenvoid mail_storage_clear_error(struct mail_storage *storage);
46631c1d903c409444b1b1c4a1d41a033c09ee37Timo Sirainenvoid mail_storage_set_error(struct mail_storage *storage,
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainenvoid mail_storage_set_critical(struct mail_storage *storage,
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainenvoid mail_storage_set_internal_error(struct mail_storage *storage);
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainenvoid mailbox_set_index_error(struct mailbox *box);
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainenbool mail_storage_set_error_from_errno(struct mail_storage *storage);
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainenvoid mail_storage_copy_list_error(struct mail_storage *storage,
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainenvoid mail_storage_copy_error(struct mail_storage *dest,
8b247780e911909a9fdc47f69ce6d1478902ad98Timo Sirainen/* Returns TRUE if everything should already be in memory after this call
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen or if prefetching is not supported, i.e. the caller shouldn't do more
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen prefetching before this message is handled. */
f28583935a4509d3f7932738bba6c548ef455c82Timo Sirainenvoid mail_set_seq_saving(struct mail *mail, uint32_t seq);
f28583935a4509d3f7932738bba6c548ef455c82Timo Sirainenint mailbox_mark_index_deleted(struct mailbox *box, bool del);
e2a88d59c0d47d63ce1ad5b1fd95e487124a3fd4Timo Sirainen/* Easy wrapper for getting mailbox's MAILBOX_LIST_PATH_TYPE_MAILBOX.
e2a88d59c0d47d63ce1ad5b1fd95e487124a3fd4Timo Sirainen The mailbox must already be opened and the caller must know that the
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen storage has mailbox files (i.e. NULL/empty path is never returned). */
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainenconst char *mailbox_get_path(struct mailbox *box) ATTR_PURE;
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen/* Wrapper to mailbox_list_get_path() */
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainenint mailbox_get_path_to(struct mailbox *box, enum mailbox_list_path_type type,
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen const char **path_r);
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen/* Get mailbox permissions. */
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainenconst struct mailbox_permissions *mailbox_get_permissions(struct mailbox *box);
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen/* Force permissions to be refreshed on next lookup */
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainenvoid mailbox_refresh_permissions(struct mailbox *box);
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen/* Create path's directory with proper permissions. The root directory is also
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen created if necessary. Returns 1 if created, 0 if it already existed,
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen -1 if error. */
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainenint mailbox_mkdir(struct mailbox *box, const char *path,
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen/* Create a non-mailbox type directory for mailbox if it's missing (e.g. index).
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen Optimized for case where the directory usually exists. */
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainenint mailbox_create_missing_dir(struct mailbox *box,
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen/* Returns -1 if error, 0 if failed with EEXIST, 1 if ok */
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainenint mailbox_create_fd(struct mailbox *box, const char *path, int flags,
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainenunsigned int mail_storage_get_lock_timeout(struct mail_storage *storage,
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen unsigned int secs);
981139bb2e446bb2050c1158614725f8413fd709Timo Sirainenvoid mail_storage_free_binary_cache(struct mail_storage *storage);