mail-storage.h revision a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen /* Print debugging information while initializing the storage */
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen /* Allow full filesystem access with absolute or relative paths. */
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen /* Don't try to mmap() files */
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen /* Don't try to write() to mmap()ed files. Required for the few
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen OSes that don't have unified buffer cache
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen (currently OpenBSD <= 3.5) */
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen /* Remember message headers' MD5 sum */
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen /* Use mmap() for reading mail files. */
4e56e6408815c04f2e5b904a648a366a2dcbd408Timo Sirainen /* Use CRLF linefeeds when saving mails. */
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen /* The storage points to shared namespaces */
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen /* Don't try to autodetect anything, require that the given data
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen contains all the necessary information. */
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen /* Ths storage contains INBOX */
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen /* Mailbox must not be modified even if asked */
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen /* Only saving/copying mails to mailbox works. */
7891c8e6debdcfec552cb1beea2a0230fe89957bTimo Sirainen /* Any extra time consuming operations shouldn't be performed
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen (eg. when opening mailbox just for STATUS). */
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen /* Don't reset MAIL_RECENT flags when syncing */
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen /* Don't create index files for the mailbox */
3ba9a079592f46e94ce846e5aa80e4d479cd5e41Timo Sirainen /* Keep mailbox exclusively locked all the time while it's open */
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen /* FIXME: Kludge for deliver: Ignore all but the first From-line */
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen/* Maximum size for sort program (each one separately + END) */
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen MAIL_SORT_FLAG_REVERSE = 0x1000, /* reverse this mask type */
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen MAIL_SORT_END = 0x0000 /* ends sort program */
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen /* specials: */
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen /* Hide changes done in this transaction from next view sync */
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen /* External transaction. Should be used for copying and appends,
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen but nothing else. */
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen /* Make sure we sync all external changes done to mailbox */
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen /* Make sure we write all our internal changes into the mailbox */
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen /* If it's not too much trouble, check if there are some changes */
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen /* Don't sync expunges from our view */
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen /* Don't show new mail */
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen /* Stop auto syncing */
4e56e6408815c04f2e5b904a648a366a2dcbd408Timo Sirainen /* always set */
4e56e6408815c04f2e5b904a648a366a2dcbd408Timo Sirainen struct mailbox_transaction_context *transaction;
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen unsigned int has_nuls:1; /* message data is known to contain NULs */
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen unsigned int has_no_nuls:1; /* -''- known to not contain NULs */
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen /* Alert: Not enough disk space */
7891c8e6debdcfec552cb1beea2a0230fe89957bTimo Sirainen void (*alert_no_diskspace)(struct mailbox *mailbox, void *context);
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen /* "* OK <text>" */
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen void (*notify_ok)(struct mailbox *mailbox, const char *text,
4e56e6408815c04f2e5b904a648a366a2dcbd408Timo Sirainen /* "* NO <text>" */
7891c8e6debdcfec552cb1beea2a0230fe89957bTimo Sirainen void (*notify_no)(struct mailbox *mailbox, const char *text,
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainentypedef void mailbox_notify_callback_t(struct mailbox *box, void *context);
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen/* register all mail storages */
f096367f0f7b0e481f8abe0969afdf2d8250057eTimo Sirainen/* Register mail storage class with given name - all methods that are NULL
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen are set to default methods */
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainenvoid mail_storage_class_register(struct mail_storage *storage_class);
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainenvoid mail_storage_class_unregister(struct mail_storage *storage_class);
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen/* Returns flags and lock_method based on environment settings. */
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainenvoid mail_storage_parse_env(enum mail_storage_flags *flags_r,
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen enum mail_storage_lock_method *lock_method_r);
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen/* Create a new instance of registered mail storage class with given
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen storage-specific data. If data is NULL, it tries to autodetect defaults.
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen May return NULL if anything fails. */
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainenmail_storage_create(const char *driver, const char *data, const char *user,
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainenmail_storage_create_with_data(const char *data, const char *user,
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainenvoid mail_storage_destroy(struct mail_storage **storage);
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainenchar mail_storage_get_hierarchy_sep(struct mail_storage *storage);
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainenstruct mailbox_list *mail_storage_get_list(struct mail_storage *storage);
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainenvoid mail_storage_set_list_error(struct mail_storage *storage);
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen/* Set storage callback functions to use. */
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainenvoid mail_storage_set_callbacks(struct mail_storage *storage,
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen/* name is allowed to contain multiple new hierarchy levels.
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen If directory is TRUE, the mailbox should be created so that it
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen can contain children. The mailbox itself doesn't have to be
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen created as long as it shows in LIST. */
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainenint mail_storage_mailbox_create(struct mail_storage *storage, const char *name,
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen/* Only the specified mailbox is deleted, ie. folders under the
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen specified mailbox must not be deleted. */
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainenint mail_storage_mailbox_delete(struct mail_storage *storage, const char *name);
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen/* If the name has inferior hierarchical names, then the inferior
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen hierarchical names MUST also be renamed (ie. foo -> bar renames
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen also foo/bar -> bar/bar). newname may contain multiple new
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen If oldname is case-insensitively "INBOX", the mails are moved
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen into new folder but the INBOX folder must not be deleted. */
4e56e6408815c04f2e5b904a648a366a2dcbd408Timo Sirainenint mail_storage_mailbox_rename(struct mail_storage *storage,
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen/* Returns the error message of last occurred error. */
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainenconst char *mail_storage_get_last_error(struct mail_storage *storage,
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen/* Returns path to the given mailbox, or NULL if mailbox doesn't exist in
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen filesystem. is_file_r is set to TRUE if returned path points to a file,
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen and FALSE if it points to a directory. If name is "", the root storage
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen directory is returned. */
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainenconst char *mail_storage_get_mailbox_path(struct mail_storage *storage,
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen/* Returns path to the control directory of the mailbox, or NULL if mailbox
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen doesn't exist in filesystem. */
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainenconst char *mail_storage_get_mailbox_control_dir(struct mail_storage *storage,
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen const char *name);
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen/* Returns path to the index directory of the mailbox, or NULL if using
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen in-memory indexes or mailbox doesn't exist. */
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainenconst char *mail_storage_get_mailbox_index_dir(struct mail_storage *storage,
4e56e6408815c04f2e5b904a648a366a2dcbd408Timo Sirainen const char *name);
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainenint mail_storage_is_mailbox(struct mail_storage *storage,
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen/* Open a mailbox. If input stream is given, mailbox is opened read-only
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen using it as a backend. If storage doesn't support stream backends and its
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen tried to be used, NULL is returned.
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen Note that append and copy may open the selected mailbox again
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen with possibly different readonly-state. */
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainenstruct mailbox *mailbox_open(struct mail_storage *storage, const char *name,
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen/* Close the box. Returns -1 if some cleanup errors occurred, but
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen the mailbox was closed anyway. */
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen/* Returns storage of given mailbox */
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainenstruct mail_storage *mailbox_get_storage(struct mailbox *box);
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen/* Returns name of given mailbox */
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainenconst char *mailbox_get_name(struct mailbox *box);
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen/* Returns TRUE if mailbox is read-only. */
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen/* Returns TRUE if mailbox currently supports adding keywords. */
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainenbool mailbox_allow_new_keywords(struct mailbox *box);
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen/* Gets the mailbox status information. */
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainenint mailbox_get_status(struct mailbox *box, enum mailbox_status_items items,
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen/* Synchronize the mailbox. */
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainenmailbox_sync_init(struct mailbox *box, enum mailbox_sync_flags flags);
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainenint mailbox_sync_next(struct mailbox_sync_context *ctx,
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainenint mailbox_sync_deinit(struct mailbox_sync_context **ctx,
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen/* Call given callback function when something changes in the mailbox.
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen It's done until this function is called with callback = NULL. */
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainenvoid mailbox_notify_changes(struct mailbox *box, unsigned int min_interval,
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen mailbox_notify_callback_t *callback, void *context);
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainenint mailbox_transaction_commit(struct mailbox_transaction_context **t,
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainenvoid mailbox_transaction_rollback(struct mailbox_transaction_context **t);
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen/* Build mail_keywords from NULL-terminated keywords list. */
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainenmailbox_keywords_create(struct mailbox_transaction_context *t,
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen const char *const keywords[]);
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainenvoid mailbox_keywords_free(struct mailbox_transaction_context *t,
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen/* Convert uid range to sequence range. */
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainenint mailbox_get_uids(struct mailbox *box, uint32_t uid1, uint32_t uid2,
b71f152acb8a197d20b709ca74366e6d765bd200Timo Sirainen/* Initialize header lookup for given headers. */
b71f152acb8a197d20b709ca74366e6d765bd200Timo Sirainenmailbox_header_lookup_init(struct mailbox *box, const char *const headers[]);
4e56e6408815c04f2e5b904a648a366a2dcbd408Timo Sirainenvoid mailbox_header_lookup_deinit(struct mailbox_header_lookup_ctx **ctx);
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen/* Initialize new search request. charset specifies the character set used in
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen the search argument strings. If sort_program is non-NULL, the messages are
442232f2d1cfdf28f3a18aa00a5c19246d321036Timo Sirainen returned in the requested order, otherwise from first to last. */
3ba9a079592f46e94ce846e5aa80e4d479cd5e41Timo Sirainenmailbox_search_init(struct mailbox_transaction_context *t,
3ba9a079592f46e94ce846e5aa80e4d479cd5e41Timo Sirainen const char *charset, struct mail_search_arg *args,
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen/* Deinitialize search request. */
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainenint mailbox_search_deinit(struct mail_search_context **ctx);
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen/* Search the next message. Returns 1 if found, 0 if not, -1 if failure. */
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainenint mailbox_search_next(struct mail_search_context *ctx, struct mail *mail);
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen/* Save a mail into mailbox. timezone_offset specifies the timezone in
1d3b9fce06b466bcf64f9ab7b622f3a6e4e939baTimo Sirainen minutes in which received_date was originally given with. To use
3ba9a079592f46e94ce846e5aa80e4d479cd5e41Timo Sirainen current time, set received_date to (time_t)-1.
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen If dest_mail is set, the saved message can be accessed using it. Note that
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen setting it may require mailbox syncing, so don't set it unless you need
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen it. Also you shouldn't try to access it before mailbox_save_finish() is
442232f2d1cfdf28f3a18aa00a5c19246d321036Timo Sirainen The given input stream is never read in these functions, only the data
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen inside it is used. So you should call i_stream_read() yourself and then
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen call mailbox_save_continue() whenever more data is read.
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainenint mailbox_save_init(struct mailbox_transaction_context *t,
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen enum mail_flags flags, struct mail_keywords *keywords,
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen const char *from_envelope, struct istream *input,
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen struct mail *dest_mail, struct mail_save_context **ctx_r);
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainenint mailbox_save_continue(struct mail_save_context *ctx);
47f1c273dfaea552c034ffbecdec096f7cbaef35Timo Sirainenint mailbox_save_finish(struct mail_save_context **ctx);
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainenvoid mailbox_save_cancel(struct mail_save_context **ctx);
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen/* Copy given message. If dest_mail is non-NULL, the copied message can be
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen accessed using it. Note that setting it non-NULL may require mailbox
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen syncing, so don't give give it unless you need it. */
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainenint mailbox_copy(struct mailbox_transaction_context *t, struct mail *mail,
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen enum mail_flags flags, struct mail_keywords *keywords,
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen/* Returns TRUE if mailbox is now in inconsistent state, meaning that
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen the message IDs etc. may have changed - only way to recover this
4e56e6408815c04f2e5b904a648a366a2dcbd408Timo Sirainen would be to fully close the mailbox and reopen it. With IMAP
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen connection this would mean a forced disconnection since we can't
442232f2d1cfdf28f3a18aa00a5c19246d321036Timo Sirainen do forced CLOSE. */
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainenbool mailbox_is_inconsistent(struct mailbox *box);
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen/* Returns message's flags */
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainenenum mail_flags mail_get_flags(struct mail *mail);
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen/* Returns message's keywords */
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainenconst char *const *mail_get_keywords(struct mail *mail);
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen/* Returns message's MIME parts */
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainenconst struct message_part *mail_get_parts(struct mail *mail);
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainenstruct mail *mail_alloc(struct mailbox_transaction_context *t,
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen struct mailbox_header_lookup_ctx *wanted_headers);
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainenint mail_set_seq(struct mail *mail, uint32_t seq);
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen/* Returns -1 if error, 0 if UID has already been expunged, 1 if ok */
442232f2d1cfdf28f3a18aa00a5c19246d321036Timo Sirainenint mail_set_uid(struct mail *mail, uint32_t uid);
199d62c0ddfb3c7d634c6940c29869ef56cfd3c4Timo Sirainen/* Get the Date-header of the mail. Timezone is in minutes.
199d62c0ddfb3c7d634c6940c29869ef56cfd3c4Timo Sirainen Returns (time_t)-1 if error occurred, 0 if field wasn't found or
199d62c0ddfb3c7d634c6940c29869ef56cfd3c4Timo Sirainen couldn't be parsed. */
3b1bb5fd562be9d1a5f6894b82d2ba0d529cdcb3Timo Sirainentime_t mail_get_date(struct mail *mail, int *timezone);
442232f2d1cfdf28f3a18aa00a5c19246d321036Timo Sirainen/* Get the time when the mail was received (IMAP INTERNALDATE).
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen Returns (time_t)-1 if error occurred. */
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainentime_t mail_get_received_date(struct mail *mail);
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen/* Get the time when the mail was saved into this mailbox. This time may not
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen always be entirely reliable. Returns (time_t)-1 if error occurred. */
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen/* Get the space used by the mail as seen by the reader. Linefeeds are always
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen counted as being CR+LF. Returns (uoff_t)-1 if error occurred */
f096367f0f7b0e481f8abe0969afdf2d8250057eTimo Sirainenuoff_t mail_get_virtual_size(struct mail *mail);
f096367f0f7b0e481f8abe0969afdf2d8250057eTimo Sirainen/* Get the space used by the mail in disk.
f096367f0f7b0e481f8abe0969afdf2d8250057eTimo Sirainen Returns (uoff_t)-1 if error occurred */
f096367f0f7b0e481f8abe0969afdf2d8250057eTimo Sirainenuoff_t mail_get_physical_size(struct mail *mail);
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen/* Get value for single header field */
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainenconst char *mail_get_first_header(struct mail *mail, const char *field);
442232f2d1cfdf28f3a18aa00a5c19246d321036Timo Sirainen/* Return a NULL-terminated list of values for each found field. */
442232f2d1cfdf28f3a18aa00a5c19246d321036Timo Sirainenconst char *const *mail_get_headers(struct mail *mail, const char *field);
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen/* Returns stream containing specified headers. */
3b1bb5fd562be9d1a5f6894b82d2ba0d529cdcb3Timo Sirainen/* Returns input stream pointing to beginning of message header.
3b1bb5fd562be9d1a5f6894b82d2ba0d529cdcb3Timo Sirainen hdr_size and body_size are updated unless they're NULL. */
442232f2d1cfdf28f3a18aa00a5c19246d321036Timo Sirainenstruct istream *mail_get_stream(struct mail *mail,
4e56e6408815c04f2e5b904a648a366a2dcbd408Timo Sirainen/* Get any of the "special" fields. */
4e56e6408815c04f2e5b904a648a366a2dcbd408Timo Sirainenconst char *mail_get_special(struct mail *mail, enum mail_fetch_field field);
4e56e6408815c04f2e5b904a648a366a2dcbd408Timo Sirainen/* Update message flags. */
4e56e6408815c04f2e5b904a648a366a2dcbd408Timo Sirainenint mail_update_flags(struct mail *mail, enum modify_type modify_type,
4e56e6408815c04f2e5b904a648a366a2dcbd408Timo Sirainen/* Update message keywords. */
4e56e6408815c04f2e5b904a648a366a2dcbd408Timo Sirainenint mail_update_keywords(struct mail *mail, enum modify_type modify_type,
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen/* Expunge this message. Sequence numbers don't change until commit. */