mail-storage.h revision ab9a91eb05a54f7675e0bf861aca53f417e1980d
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio#ifndef MAIL_STORAGE_H
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio#define MAIL_STORAGE_H
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidênciostruct message_size;
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio#include "seq-range-array.h"
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio#include "file-lock.h"
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio#include "guid.h"
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio#include "mail-types.h"
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio#include "mail-error.h"
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio#include "mailbox-list.h"
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio/* If some operation is taking long, call notify_ok every n seconds. */
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio#define MAIL_STORAGE_STAYALIVE_SECS 15
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncioenum mail_storage_flags {
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio /* Remember message headers' MD5 sum */
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAIL_STORAGE_FLAG_KEEP_HEADER_MD5 = 0x01,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio /* Don't try to autodetect anything, require that the given data
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio contains all the necessary information. */
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAIL_STORAGE_FLAG_NO_AUTODETECTION = 0x02,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio /* Don't autocreate any directories. If they don't exist,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio fail to create the storage. */
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAIL_STORAGE_FLAG_NO_AUTOCREATE = 0x04,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio /* Don't verify existence or accessibility of any directories.
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio Create the storage in any case. */
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAIL_STORAGE_FLAG_NO_AUTOVERIFY = 0x08
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio};
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncioenum mailbox_flags {
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio /* Mailbox must not be modified even if asked */
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAILBOX_FLAG_READONLY = 0x01,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio /* Only saving/copying mails to mailbox works. */
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAILBOX_FLAG_SAVEONLY = 0x02,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio /* Remove MAIL_RECENT flags when syncing */
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAILBOX_FLAG_DROP_RECENT = 0x04,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio /* Don't create index files for the mailbox */
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAILBOX_FLAG_NO_INDEX_FILES = 0x10,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio /* Keep mailbox exclusively locked all the time while it's open */
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAILBOX_FLAG_KEEP_LOCKED = 0x20,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio /* Enable if mailbox is used for serving POP3. This allows making
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio better caching decisions. */
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAILBOX_FLAG_POP3_SESSION = 0x40,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio /* Enable if mailbox is used for saving a mail delivery using MDA.
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio This causes ACL plugin to use POST right rather than INSERT. */
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAILBOX_FLAG_POST_SESSION = 0x80,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio /* Force opening mailbox and ignoring any ACLs */
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAILBOX_FLAG_IGNORE_ACLS = 0x100,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio /* Open mailbox even if it's already marked as deleted */
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAILBOX_FLAG_OPEN_DELETED = 0x200
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio};
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncioenum mailbox_feature {
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio /* Enable tracking modsequences */
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAILBOX_FEATURE_CONDSTORE = 0x01,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio /* Enable tracking expunge modsequences */
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAILBOX_FEATURE_QRESYNC = 0x02
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio};
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncioenum mailbox_existence {
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAILBOX_EXISTENCE_NONE,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAILBOX_EXISTENCE_NOSELECT,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAILBOX_EXISTENCE_SELECT
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio};
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncioenum mailbox_status_items {
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio STATUS_MESSAGES = 0x01,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio STATUS_RECENT = 0x02,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio STATUS_UIDNEXT = 0x04,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio STATUS_UIDVALIDITY = 0x08,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio STATUS_UNSEEN = 0x10,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio STATUS_FIRST_UNSEEN_SEQ = 0x20,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio STATUS_KEYWORDS = 0x40,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio STATUS_HIGHESTMODSEQ = 0x80,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio STATUS_PERMANENT_FLAGS = 0x200,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio STATUS_FIRST_RECENT_UID = 0x400
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio};
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncioenum mailbox_metadata_items {
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAILBOX_METADATA_GUID = 0x01,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAILBOX_METADATA_VIRTUAL_SIZE = 0x02,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAILBOX_METADATA_CACHE_FIELDS = 0x04
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio};
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncioenum mailbox_search_result_flags {
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio /* Update search results whenever the mailbox view is synced.
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio Expunged messages are removed even without this flag. */
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAILBOX_SEARCH_RESULT_FLAG_UPDATE = 0x01,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio /* Queue changes so _sync() can be used. */
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAILBOX_SEARCH_RESULT_FLAG_QUEUE_SYNC = 0x02
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio};
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncioenum mail_sort_type {
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio/* Maximum size for sort program (each one separately + END) */
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio#define MAX_SORT_PROGRAM_SIZE (8 + 1)
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAIL_SORT_ARRIVAL = 0x0001,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAIL_SORT_CC = 0x0002,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAIL_SORT_DATE = 0x0004,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAIL_SORT_FROM = 0x0008,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAIL_SORT_SIZE = 0x0010,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAIL_SORT_SUBJECT = 0x0020,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAIL_SORT_TO = 0x0040,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAIL_SORT_RELEVANCY = 0x0080,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAIL_SORT_DISPLAYFROM = 0x0100,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAIL_SORT_DISPLAYTO = 0x0200,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAIL_SORT_POP3_ORDER = 0x0400,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAIL_SORT_MASK = 0x0fff,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAIL_SORT_FLAG_REVERSE = 0x1000, /* reverse this mask type */
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAIL_SORT_END = 0x0000 /* ends sort program */
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio};
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncioenum mail_fetch_field {
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAIL_FETCH_FLAGS = 0x00000001,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAIL_FETCH_MESSAGE_PARTS = 0x00000002,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAIL_FETCH_STREAM_HEADER = 0x00000004,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAIL_FETCH_STREAM_BODY = 0x00000008,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAIL_FETCH_DATE = 0x00000010,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAIL_FETCH_RECEIVED_DATE = 0x00000020,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAIL_FETCH_SAVE_DATE = 0x00000040,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAIL_FETCH_PHYSICAL_SIZE = 0x00000080,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAIL_FETCH_VIRTUAL_SIZE = 0x00000100,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio /* Set has_nuls / has_no_nuls fields */
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAIL_FETCH_NUL_STATE = 0x00000200,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio /* specials: */
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAIL_FETCH_IMAP_BODY = 0x00001000,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAIL_FETCH_IMAP_BODYSTRUCTURE = 0x00002000,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAIL_FETCH_IMAP_ENVELOPE = 0x00004000,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAIL_FETCH_FROM_ENVELOPE = 0x00008000,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAIL_FETCH_HEADER_MD5 = 0x00010000,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAIL_FETCH_UIDL_FILE_NAME = 0x00020000,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAIL_FETCH_UIDL_BACKEND = 0x00040000,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAIL_FETCH_MAILBOX_NAME = 0x00080000,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAIL_FETCH_SEARCH_RELEVANCY = 0x00100000,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAIL_FETCH_GUID = 0x00200000,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAIL_FETCH_POP3_ORDER = 0x00400000
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio};
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncioenum mailbox_transaction_flags {
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio /* Hide changes done in this transaction from next view sync */
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAILBOX_TRANSACTION_FLAG_HIDE = 0x01,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio /* External transaction. Should be used for copying and appends,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio but nothing else. */
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAILBOX_TRANSACTION_FLAG_EXTERNAL = 0x02,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio /* Always assign UIDs to messages when saving/copying. Normally this
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio is done only if it can be done easily. */
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAILBOX_TRANSACTION_FLAG_ASSIGN_UIDS = 0x04,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio /* Refresh the index so lookups return latest flags/modseqs */
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAILBOX_TRANSACTION_FLAG_REFRESH = 0x08,
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio /* Don't update caching decisions no matter what we do in this
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio transaction (useful for e.g. precaching) */
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAILBOX_TRANSACTION_FLAG_NO_CACHE_DEC = 0x10
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio};
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncioenum mailbox_sync_flags {
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio /* Make sure we sync all external changes done to mailbox */
9a18f78f38e274f4906af6ef8e1a82d844fde4ccFabiano Fidêncio MAILBOX_SYNC_FLAG_FULL_READ = 0x01,
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio /* Make sure we write all our internal changes into the mailbox */
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio MAILBOX_SYNC_FLAG_FULL_WRITE = 0x02,
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio /* If it's not too much trouble, check if there are some changes */
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio MAILBOX_SYNC_FLAG_FAST = 0x04,
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio /* Don't sync expunges from our view */
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio MAILBOX_SYNC_FLAG_NO_EXPUNGES = 0x08,
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio /* If mailbox is currently inconsistent, fix it instead of failing. */
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio MAILBOX_SYNC_FLAG_FIX_INCONSISTENT = 0x40,
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio /* Syncing after an EXPUNGE command. This is just an informational
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio flag for plugins. */
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio MAILBOX_SYNC_FLAG_EXPUNGE = 0x80,
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio /* Force doing a full resync of indexes. */
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio MAILBOX_SYNC_FLAG_FORCE_RESYNC = 0x100,
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio /* Add all missing data to cache and fts index ("doveadm index") */
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio MAILBOX_SYNC_FLAG_PRECACHE = 0x200,
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio /* FIXME: kludge until something better comes along:
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio Request full text search index optimization */
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio MAILBOX_SYNC_FLAG_OPTIMIZE = 0x400
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio};
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncioenum mailbox_sync_type {
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio MAILBOX_SYNC_TYPE_EXPUNGE = 0x01,
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio MAILBOX_SYNC_TYPE_FLAGS = 0x02,
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio MAILBOX_SYNC_TYPE_MODSEQ = 0x04
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio};
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidênciostruct message_part;
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidênciostruct mail_namespace;
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidênciostruct mail_storage;
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidênciostruct mail_search_args;
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidênciostruct mail_search_result;
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidênciostruct mail_keywords;
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidênciostruct mail_save_context;
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidênciostruct mailbox;
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidênciostruct mailbox_transaction_context;
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidênciostruct mailbox_status {
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio uint32_t messages;
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio uint32_t recent;
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio uint32_t unseen;
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio uint32_t uidvalidity;
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio uint32_t uidnext;
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio uint32_t first_unseen_seq;
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio uint32_t first_recent_uid;
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio uint64_t highest_modseq;
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio /* NULL-terminated array of keywords */
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio const ARRAY_TYPE(keywords) *keywords;
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio /* These flags can be permanently modified */
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio enum mail_flags permanent_flags;
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio /* Modseqs aren't permanent (index is in memory) */
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio unsigned int nonpermanent_modseqs:1;
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio /* All keywords can be permanently modified */
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio unsigned int permanent_keywords:1;
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio /* More keywords can be created */
e17e37cd0e2109e7f1bd4ae48edfc8cca85b3f93Fabiano Fidêncio unsigned int allow_new_keywords:1;
d2a0b4a6a220bf9a58c7306c3f673891efc419ebFabiano Fidêncio};
d2a0b4a6a220bf9a58c7306c3f673891efc419ebFabiano Fidêncio
d2a0b4a6a220bf9a58c7306c3f673891efc419ebFabiano Fidênciostruct mailbox_metadata {
d2a0b4a6a220bf9a58c7306c3f673891efc419ebFabiano Fidêncio guid_128_t guid;
d2a0b4a6a220bf9a58c7306c3f673891efc419ebFabiano Fidêncio /* sum of virtual size of all messages in mailbox */
d2a0b4a6a220bf9a58c7306c3f673891efc419ebFabiano Fidêncio uint64_t virtual_size;
d2a0b4a6a220bf9a58c7306c3f673891efc419ebFabiano Fidêncio /* Fields that have "temp" or "yes" caching decision. */
d2a0b4a6a220bf9a58c7306c3f673891efc419ebFabiano Fidêncio const ARRAY_TYPE(const_string) *cache_fields;
d2a0b4a6a220bf9a58c7306c3f673891efc419ebFabiano Fidêncio};
d2a0b4a6a220bf9a58c7306c3f673891efc419ebFabiano Fidêncio
d2a0b4a6a220bf9a58c7306c3f673891efc419ebFabiano Fidênciostruct mailbox_update {
d2a0b4a6a220bf9a58c7306c3f673891efc419ebFabiano Fidêncio /* All non-zero fields are changed. */
d2a0b4a6a220bf9a58c7306c3f673891efc419ebFabiano Fidêncio guid_128_t mailbox_guid;
d2a0b4a6a220bf9a58c7306c3f673891efc419ebFabiano Fidêncio uint32_t uid_validity;
d2a0b4a6a220bf9a58c7306c3f673891efc419ebFabiano Fidêncio uint32_t min_next_uid;
d2a0b4a6a220bf9a58c7306c3f673891efc419ebFabiano Fidêncio uint32_t min_first_recent_uid;
d2a0b4a6a220bf9a58c7306c3f673891efc419ebFabiano Fidêncio uint64_t min_highest_modseq;
d2a0b4a6a220bf9a58c7306c3f673891efc419ebFabiano Fidêncio /* Add these fields to be temporarily cached, if they aren't already. */
d2a0b4a6a220bf9a58c7306c3f673891efc419ebFabiano Fidêncio const char *const *cache_fields;
d2a0b4a6a220bf9a58c7306c3f673891efc419ebFabiano Fidêncio};
d2a0b4a6a220bf9a58c7306c3f673891efc419ebFabiano Fidêncio
d2a0b4a6a220bf9a58c7306c3f673891efc419ebFabiano Fidênciostruct mail_transaction_commit_changes {
d2a0b4a6a220bf9a58c7306c3f673891efc419ebFabiano Fidêncio /* Unreference the pool to free memory used by these changes. */
d2a0b4a6a220bf9a58c7306c3f673891efc419ebFabiano Fidêncio pool_t pool;
d2a0b4a6a220bf9a58c7306c3f673891efc419ebFabiano Fidêncio
d2a0b4a6a220bf9a58c7306c3f673891efc419ebFabiano Fidêncio /* UIDVALIDITY for assigned UIDs. */
d2a0b4a6a220bf9a58c7306c3f673891efc419ebFabiano Fidêncio uint32_t uid_validity;
d2a0b4a6a220bf9a58c7306c3f673891efc419ebFabiano Fidêncio /* UIDs assigned to saved messages. Not necessarily ascending. */
d2a0b4a6a220bf9a58c7306c3f673891efc419ebFabiano Fidêncio ARRAY_TYPE(seq_range) saved_uids;
d2a0b4a6a220bf9a58c7306c3f673891efc419ebFabiano Fidêncio
d2a0b4a6a220bf9a58c7306c3f673891efc419ebFabiano Fidêncio /* number of modseq changes that couldn't be changed as requested */
d2a0b4a6a220bf9a58c7306c3f673891efc419ebFabiano Fidêncio unsigned int ignored_modseq_changes;
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio};
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidênciostruct mailbox_sync_rec {
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio uint32_t seq1, seq2;
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio enum mailbox_sync_type type;
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio};
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidênciostruct mailbox_sync_status {
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio /* There are expunges that haven't been synced yet */
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio unsigned int sync_delayed_expunges:1;
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio};
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidênciostruct mailbox_expunge_rec {
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio /* IMAP UID */
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio uint32_t uid;
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio /* 128 bit GUID. If the actual GUID has a different size, this
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio contains last bits of its SHA1 sum. */
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio guid_128_t guid_128;
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio};
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano FidêncioARRAY_DEFINE_TYPE(mailbox_expunge_rec, struct mailbox_expunge_rec);
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncioenum mail_lookup_abort {
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio /* Perform everything no matter what it takes */
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio MAIL_LOOKUP_ABORT_NEVER = 0,
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio /* Abort if the operation would require reading message header/body */
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio MAIL_LOOKUP_ABORT_READ_MAIL,
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio /* Abort if the operation can't be done fully using cache file */
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio MAIL_LOOKUP_ABORT_NOT_IN_CACHE
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio};
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidênciostruct mail {
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio /* always set */
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio struct mailbox *box;
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio struct mailbox_transaction_context *transaction;
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio uint32_t seq, uid;
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio unsigned int expunged:1;
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio unsigned int saving:1; /* This mail is still being saved */
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio unsigned int has_nuls:1; /* message data is known to contain NULs */
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio unsigned int has_no_nuls:1; /* -''- known to not contain NULs */
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio /* If the lookup is aborted, error is set to MAIL_ERROR_NOTPOSSIBLE */
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio enum mail_lookup_abort lookup_abort;
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio};
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidênciostruct mail_storage_callbacks {
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio /* "* OK <text>" */
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio void (*notify_ok)(struct mailbox *mailbox, const char *text,
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio void *context);
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio /* "* NO <text>" */
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio void (*notify_no)(struct mailbox *mailbox, const char *text,
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio void *context);
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio};
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidênciostruct mailbox_virtual_pattern {
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio struct mail_namespace *ns;
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio const char *pattern;
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio};
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano FidêncioARRAY_DEFINE_TYPE(mailbox_virtual_patterns, struct mailbox_virtual_pattern);
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano FidêncioARRAY_DEFINE_TYPE(mail_storage, struct mail_storage *);
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano FidêncioARRAY_DEFINE_TYPE(mailboxes, struct mailbox *);
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncioextern ARRAY_TYPE(mail_storage) mail_storage_classes;
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidênciotypedef void mailbox_notify_callback_t(struct mailbox *box, void *context);
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidênciovoid mail_storage_init(void);
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidênciovoid mail_storage_deinit(void);
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio/* register all mail storages */
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidênciovoid mail_storage_register_all(void);
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio/* Register mail storage class with given name - all methods that are NULL
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio are set to default methods */
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidênciovoid mail_storage_class_register(struct mail_storage *storage_class);
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidênciovoid mail_storage_class_unregister(struct mail_storage *storage_class);
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio/* Find mail storage class by name */
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidênciostruct mail_storage *mail_storage_find_class(const char *name);
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio/* Create a new instance of registered mail storage class with given
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio storage-specific data. If driver is NULL, it's tried to be autodetected
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio from ns location. If ns location is NULL, it uses the first storage that
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio exists. The storage is put into ns->storage. */
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncioint mail_storage_create(struct mail_namespace *ns, const char *driver,
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio enum mail_storage_flags flags, const char **error_r);
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidênciovoid mail_storage_unref(struct mail_storage **storage);
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncio/* Returns the mail storage settings. */
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidêncioconst struct mail_storage_settings *
0f623456437c96f50330fe0ff21afd9638d14e57Fabiano Fidênciomail_storage_get_settings(struct mail_storage *storage) ATTR_PURE;
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidênciostruct mail_user *mail_storage_get_user(struct mail_storage *storage) ATTR_PURE;
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio/* Set storage callback functions to use. */
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidênciovoid mail_storage_set_callbacks(struct mail_storage *storage,
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio struct mail_storage_callbacks *callbacks,
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio void *context);
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio/* Purge storage's mailboxes (freeing disk space from expunged mails),
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio if supported by the storage. Otherwise just a no-op. */
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncioint mail_storage_purge(struct mail_storage *storage);
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio/* Returns the error message of last occurred error. */
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncioconst char *mail_storage_get_last_error(struct mail_storage *storage,
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio enum mail_error *error_r);
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio/* Wrapper for mail_storage_get_last_error(); */
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncioconst char *mailbox_get_last_error(struct mailbox *box,
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio enum mail_error *error_r);
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio/* Wrapper for mail_storage_get_last_error(); */
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncioenum mail_error mailbox_get_last_mail_error(struct mailbox *box);
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio/* Returns TRUE if mailboxes are files. */
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidênciobool mail_storage_is_mailbox_file(struct mail_storage *storage) ATTR_PURE;
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio/* Initialize mailbox without actually opening any files or verifying that
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio it exists. Note that append and copy may open the selected mailbox again
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio with possibly different readonly-state. */
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidênciostruct mailbox *mailbox_alloc(struct mailbox_list *list, const char *vname,
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio enum mailbox_flags flags);
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio/* Like mailbox_alloc(), but use mailbox GUID. */
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidênciostruct mailbox *mailbox_alloc_guid(struct mailbox_list *list,
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio const guid_128_t guid,
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio enum mailbox_flags flags);
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio/* Get mailbox existence state. If auto_boxes=FALSE, return
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio MAILBOX_EXISTENCE_NONE for autocreated mailboxes that haven't been
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio physically created yet */
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncioint mailbox_exists(struct mailbox *box, bool auto_boxes,
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio enum mailbox_existence *existence_r);
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio/* Open the mailbox. If this function isn't called explicitly, it's also called
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio internally by lib-storage when necessary. */
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncioint mailbox_open(struct mailbox *box);
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio/* Open mailbox as read-only using the given stream as input. */
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncioint mailbox_open_stream(struct mailbox *box, struct istream *input);
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio/* Close mailbox. Same as if mailbox was freed and re-allocated. */
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidênciovoid mailbox_close(struct mailbox *box);
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio/* Close and free the mailbox. */
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidênciovoid mailbox_free(struct mailbox **box);
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio/* Create a mailbox. Returns failure if it already exists. Mailbox name is
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio allowed to contain multiple new nonexistent hierarchy levels. If directory
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio is TRUE, the mailbox should be created so that it can contain children. The
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio mailbox itself doesn't have to be created as long as it shows up in LIST.
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio If update is non-NULL, its contents are used to set initial mailbox
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio metadata. */
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncioint mailbox_create(struct mailbox *box, const struct mailbox_update *update,
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio bool directory);
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio/* Update existing mailbox's metadata. */
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncioint mailbox_update(struct mailbox *box, const struct mailbox_update *update);
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio/* Delete mailbox (and its parent directory, if it has no siblings) */
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncioint mailbox_delete(struct mailbox *box);
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio/* Rename mailbox. Renaming across different mailbox lists is possible only
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio between private namespaces and storages of the same type. If the rename
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio fails, the error is set to src's storage. */
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncioint mailbox_rename(struct mailbox *src, struct mailbox *dest,
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio bool rename_children);
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio/* Subscribe/unsubscribe mailbox. Subscribing to
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio nonexistent mailboxes is optional. */
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncioint mailbox_set_subscribed(struct mailbox *box, bool set);
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio/* Enable the given feature for the mailbox. */
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncioint mailbox_enable(struct mailbox *box, enum mailbox_feature features);
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio/* Returns all enabled features. */
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncioenum mailbox_feature
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidênciomailbox_get_enabled_features(struct mailbox *box) ATTR_PURE;
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio/* Returns storage of given mailbox */
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidênciostruct mail_storage *mailbox_get_storage(const struct mailbox *box) ATTR_PURE;
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio/* Return namespace of given mailbox. */
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidênciostruct mail_namespace *
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidênciomailbox_get_namespace(const struct mailbox *box) ATTR_PURE;
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio/* Returns the storage's settings. */
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncioconst struct mail_storage_settings *
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidênciomailbox_get_settings(struct mailbox *box) ATTR_PURE;
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio/* Returns name of given mailbox */
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncioconst char *mailbox_get_name(const struct mailbox *box) ATTR_PURE;
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio/* Returns the virtual name of the given mailbox. This is the same as using
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio mail_namespace_get_vname(). */
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncioconst char *mailbox_get_vname(const struct mailbox *box) ATTR_PURE;
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio/* Returns TRUE if mailbox is read-only. */
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidênciobool mailbox_is_readonly(struct mailbox *box);
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio/* Returns TRUE if two mailboxes point to the same physical mailbox. */
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidênciobool mailbox_backends_equal(const struct mailbox *box1,
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio const struct mailbox *box2);
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio/* Returns TRUE if mailbox is now in inconsistent state, meaning that
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio the message IDs etc. may have changed - only way to recover this
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio would be to fully close the mailbox and reopen it. With IMAP
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio connection this would mean a forced disconnection since we can't
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio do forced CLOSE. */
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidênciobool mailbox_is_inconsistent(struct mailbox *box);
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio/* Gets the mailbox status information, opening the mailbox if necessary. */
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncioint mailbox_get_status(struct mailbox *box, enum mailbox_status_items items,
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio struct mailbox_status *status_r);
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio/* Gets the mailbox status, requires that mailbox is already opened. */
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidênciovoid mailbox_get_open_status(struct mailbox *box,
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio enum mailbox_status_items items,
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio struct mailbox_status *status_r);
ee164913f9c12a557044eb469f4498b9be9a8f50Fabiano Fidêncio/* Gets mailbox metadata */
int mailbox_get_metadata(struct mailbox *box, enum mailbox_metadata_items items,
struct mailbox_metadata *metadata_r);
/* Returns a mask of flags that are private to user in this mailbox
(as opposed to flags shared between users). */
enum mail_flags mailbox_get_private_flags_mask(struct mailbox *box);
/* Synchronize the mailbox. */
struct mailbox_sync_context *
mailbox_sync_init(struct mailbox *box, enum mailbox_sync_flags flags);
bool mailbox_sync_next(struct mailbox_sync_context *ctx,
struct mailbox_sync_rec *sync_rec_r);
int mailbox_sync_deinit(struct mailbox_sync_context **ctx,
struct mailbox_sync_status *status_r);
/* One-step mailbox synchronization. Use this if you don't care about
changes. */
int mailbox_sync(struct mailbox *box, enum mailbox_sync_flags flags);
/* Call given callback function when something changes in the mailbox. */
void mailbox_notify_changes(struct mailbox *box, unsigned int min_interval,
mailbox_notify_callback_t *callback, void *context);
#ifdef CONTEXT_TYPE_SAFETY
# define mailbox_notify_changes(box, min_interval, callback, context) \
({(void)(1 ? 0 : callback((struct mailbox *)NULL, context)); \
mailbox_notify_changes(box, min_interval, \
(mailbox_notify_callback_t *)callback, context); })
#else
# define mailbox_notify_changes(box, min_interval, callback, context) \
mailbox_notify_changes(box, min_interval, \
(mailbox_notify_callback_t *)callback, context)
#endif
void mailbox_notify_changes_stop(struct mailbox *box);
struct mailbox_transaction_context *
mailbox_transaction_begin(struct mailbox *box,
enum mailbox_transaction_flags flags);
int mailbox_transaction_commit(struct mailbox_transaction_context **t);
int mailbox_transaction_commit_get_changes(
struct mailbox_transaction_context **t,
struct mail_transaction_commit_changes *changes_r);
void mailbox_transaction_rollback(struct mailbox_transaction_context **t);
/* Return the number of active transactions for the mailbox. */
unsigned int mailbox_transaction_get_count(const struct mailbox *box) ATTR_PURE;
/* When committing transaction, drop flag/keyword updates for messages whose
modseq is larger than max_modseq. Save those messages' sequences to the
given array. */
void mailbox_transaction_set_max_modseq(struct mailbox_transaction_context *t,
uint64_t max_modseq,
ARRAY_TYPE(seq_range) *seqs);
struct mailbox *
mailbox_transaction_get_mailbox(const struct mailbox_transaction_context *t)
ATTR_PURE;
/* Convert uid range to sequence range. */
void mailbox_get_seq_range(struct mailbox *box, uint32_t uid1, uint32_t uid2,
uint32_t *seq1_r, uint32_t *seq2_r);
/* Convert sequence range to uid range. If sequences contain
(uint32_t)-1 to specify "*", they're preserved. */
void mailbox_get_uid_range(struct mailbox *box,
const ARRAY_TYPE(seq_range) *seqs,
ARRAY_TYPE(seq_range) *uids);
/* Get list of messages' that have been expunged after prev_modseq and that
exist in uids_filter range. UIDs that have been expunged after the last
mailbox sync aren't returned. Returns TRUE if ok, FALSE if modseq is lower
than we can check for (but expunged_uids is still set as best as it can). */
bool mailbox_get_expunges(struct mailbox *box, uint64_t prev_modseq,
const ARRAY_TYPE(seq_range) *uids_filter,
ARRAY_TYPE(mailbox_expunge_rec) *expunges);
/* Same as mailbox_get_expunges(), but return only list of UIDs. Not caring
about GUIDs is slightly faster. */
bool mailbox_get_expunged_uids(struct mailbox *box, uint64_t prev_modseq,
const ARRAY_TYPE(seq_range) *uids_filter,
ARRAY_TYPE(seq_range) *expunged_uids);
/* Initialize header lookup for given headers. */
struct mailbox_header_lookup_ctx *
mailbox_header_lookup_init(struct mailbox *box, const char *const headers[]);
void mailbox_header_lookup_ref(struct mailbox_header_lookup_ctx *ctx);
void mailbox_header_lookup_unref(struct mailbox_header_lookup_ctx **ctx);
/* Initialize new search request. If sort_program is non-NULL, the messages are
returned in the requested order, otherwise from first to last. */
struct mail_search_context *
mailbox_search_init(struct mailbox_transaction_context *t,
struct mail_search_args *args,
const enum mail_sort_type *sort_program,
enum mail_fetch_field wanted_fields,
struct mailbox_header_lookup_ctx *wanted_headers);
/* Deinitialize search request. */
int mailbox_search_deinit(struct mail_search_context **ctx);
/* Search the next message. Returns TRUE if found, FALSE if not. */
bool mailbox_search_next(struct mail_search_context *ctx, struct mail **mail_r);
/* Like mailbox_search_next(), but don't spend too much time searching.
Returns FALSE with tryagain_r=FALSE if finished, and tryagain_r=TRUE if
more results will be returned by calling the function again. */
bool mailbox_search_next_nonblock(struct mail_search_context *ctx,
struct mail **mail_r, bool *tryagain_r);
/* Returns TRUE if some messages were already expunged and we couldn't
determine correctly if those messages should have been returned in this
search. */
bool mailbox_search_seen_lost_data(struct mail_search_context *ctx);
/* Remember the search result for future use. This must be called before the
first mailbox_search_next*() call. */
struct mail_search_result *
mailbox_search_result_save(struct mail_search_context *ctx,
enum mailbox_search_result_flags flags);
/* Free memory used by search result. */
void mailbox_search_result_free(struct mail_search_result **result);
/* A simplified API for searching and saving the result. */
int mailbox_search_result_build(struct mailbox_transaction_context *t,
struct mail_search_args *args,
enum mailbox_search_result_flags flags,
struct mail_search_result **result_r);
/* Return all messages' UIDs in the search result. */
const ARRAY_TYPE(seq_range) *
mailbox_search_result_get(struct mail_search_result *result);
/* Return messages that have been removed and added since the last sync call.
This function must not be called if search result wasn't saved with
_QUEUE_SYNC flag. */
void mailbox_search_result_sync(struct mail_search_result *result,
ARRAY_TYPE(seq_range) *removed_uids,
ARRAY_TYPE(seq_range) *added_uids);
/* Build mail_keywords from NULL-terminated keywords list.
Returns 0 if successful, -1 if there are invalid keywords (error is set). */
int mailbox_keywords_create(struct mailbox *box, const char *const keywords[],
struct mail_keywords **keywords_r);
/* Like mailbox_keywords_create(), except ignore invalid keywords. */
struct mail_keywords *
mailbox_keywords_create_valid(struct mailbox *box,
const char *const keywords[]);
struct mail_keywords *
mailbox_keywords_create_from_indexes(struct mailbox *box,
const ARRAY_TYPE(keyword_indexes) *idx);
void mailbox_keywords_ref(struct mail_keywords *keywords);
void mailbox_keywords_unref(struct mail_keywords **keywords);
/* Returns TRUE if keyword is valid, FALSE and error if not. */
bool mailbox_keyword_is_valid(struct mailbox *box, const char *keyword,
const char **error_r);
/* Initialize saving a new mail. You must not try to save more than one mail
at a time. */
struct mail_save_context *
mailbox_save_alloc(struct mailbox_transaction_context *t);
/* Set the flags and keywords. Nothing is set by default. */
void mailbox_save_set_flags(struct mail_save_context *ctx,
enum mail_flags flags,
struct mail_keywords *keywords);
/* Copy flags and keywords from given mail. */
void mailbox_save_copy_flags(struct mail_save_context *ctx, struct mail *mail);
/* Set message's modseq to be at least min_modseq. */
void mailbox_save_set_min_modseq(struct mail_save_context *ctx,
uint64_t min_modseq);
/* If received date isn't specified the current time is used. timezone_offset
specifies the preferred timezone in minutes, but it may be ignored if
backend doesn't support storing it. */
void mailbox_save_set_received_date(struct mail_save_context *ctx,
time_t received_date, int timezone_offset);
/* Set the "message saved" date. This should be set only when you're
replicating/restoring an existing mailbox. */
void mailbox_save_set_save_date(struct mail_save_context *ctx,
time_t save_date);
/* Set the envelope sender. This is currently used only with mbox files to
specify the address in From_-line. */
void mailbox_save_set_from_envelope(struct mail_save_context *ctx,
const char *envelope);
/* Set message's UID. If UID is smaller than the current next_uid, it's given
a new UID anyway. */
void mailbox_save_set_uid(struct mail_save_context *ctx, uint32_t uid);
/* Set globally unique ID for the saved mail. A new GUID is generated by
default. This function should usually be called only when copying an
existing mail (or restoring a mail from backup). */
void mailbox_save_set_guid(struct mail_save_context *ctx, const char *guid);
/* Set message's POP3 UIDL, if the backend supports it. */
void mailbox_save_set_pop3_uidl(struct mail_save_context *ctx,
const char *uidl);
/* If dest_mail is set, the saved message can be accessed using it. Note that
setting it may require mailbox syncing, so don't set it unless you need
it. Also you shouldn't try to access it before mailbox_save_finish() is
called. */
void mailbox_save_set_dest_mail(struct mail_save_context *ctx,
struct mail *mail);
/* Begin saving the message. All mail_save_set_*() calls must have been called
before this function. If the save initialization fails, the context is freed
and -1 is returned. After beginning the save you should keep calling
i_stream_read() and calling mailbox_save_continue() as long as there's
more input. */
int mailbox_save_begin(struct mail_save_context **ctx, struct istream *input);
int mailbox_save_continue(struct mail_save_context *ctx);
int mailbox_save_finish(struct mail_save_context **ctx);
void mailbox_save_cancel(struct mail_save_context **ctx);
struct mailbox_transaction_context *
mailbox_save_get_transaction(struct mail_save_context *ctx);
/* Copy the given message. You'll need to specify the flags etc. using the
mailbox_save_*() functions. */
int mailbox_copy(struct mail_save_context **ctx, struct mail *mail);
struct mail *mail_alloc(struct mailbox_transaction_context *t,
enum mail_fetch_field wanted_fields,
struct mailbox_header_lookup_ctx *wanted_headers);
void mail_free(struct mail **mail);
void mail_set_seq(struct mail *mail, uint32_t seq);
/* Returns TRUE if successful, FALSE if message doesn't exist.
mail_*() functions shouldn't be called if FALSE is returned. */
bool mail_set_uid(struct mail *mail, uint32_t uid);
/* Returns message's flags */
enum mail_flags mail_get_flags(struct mail *mail);
/* Returns message's keywords */
const char *const *mail_get_keywords(struct mail *mail);
/* Returns message's keywords */
const ARRAY_TYPE(keyword_indexes) *mail_get_keyword_indexes(struct mail *mail);
/* Returns message's modseq */
uint64_t mail_get_modseq(struct mail *mail);
/* Returns message's MIME parts */
int mail_get_parts(struct mail *mail, struct message_part **parts_r);
/* Get the Date-header of the mail. Timezone is in minutes. date=0 if it
wasn't found or it was invalid. */
int mail_get_date(struct mail *mail, time_t *date_r, int *timezone_r);
/* Get the time when the mail was received (IMAP INTERNALDATE). */
int mail_get_received_date(struct mail *mail, time_t *date_r);
/* Get the time when the mail was saved into this mailbox. This time may not
always be entirely reliable. */
int mail_get_save_date(struct mail *mail, time_t *date_r);
/* Get the space used by the mail as seen by the reader. Linefeeds are always
counted as being CR+LF. */
int mail_get_virtual_size(struct mail *mail, uoff_t *size_r);
/* Get the size of the stream returned by mail_get_stream(). */
int mail_get_physical_size(struct mail *mail, uoff_t *size_r);
/* Get value for single header field, or NULL if header wasn't found.
Returns 1 if header was found, 0 if not, -1 if error. */
int mail_get_first_header(struct mail *mail, const char *field,
const char **value_r);
/* Like mail_get_first_header(), but decode MIME encoded words to UTF-8.
Also multiline headers are returned unfolded.
Do not use this function for getting structured fields (e.g. address fields),
because decoding may break the structuring. Instead parse them first and
only afterwards decode the encoded words. */
int mail_get_first_header_utf8(struct mail *mail, const char *field,
const char **value_r);
/* Return a NULL-terminated list of values for each found field.
Returns -1 if error, 0 otherwise (with or without headers found). */
int mail_get_headers(struct mail *mail, const char *field,
const char *const **value_r);
/* Like mail_get_headers(), but decode MIME encoded words to UTF-8.
Also multiline headers are returned unfolded.
Do not use for structured fields (see mail_get_first_header_utf8()). */
int mail_get_headers_utf8(struct mail *mail, const char *field,
const char *const **value_r);
/* Returns stream containing specified headers. */
int mail_get_header_stream(struct mail *mail,
struct mailbox_header_lookup_ctx *headers,
struct istream **stream_r);
/* Returns input stream pointing to beginning of message header.
hdr_size and body_size are updated unless they're NULL. The returned stream
is destroyed automatically, don't unreference it. */
int mail_get_stream(struct mail *mail, struct message_size *hdr_size,
struct message_size *body_size, struct istream **stream_r);
/* Get any of the "special" fields. Unhandled specials are returned as "". */
int mail_get_special(struct mail *mail, enum mail_fetch_field field,
const char **value_r);
/* Returns the mail for the physical message. Normally this is the mail itself,
but in virtual mailboxes it points to the backend mailbox. */
struct mail *mail_get_real_mail(struct mail *mail);
/* Update message flags. */
void mail_update_flags(struct mail *mail, enum modify_type modify_type,
enum mail_flags flags);
/* Update message keywords. */
void mail_update_keywords(struct mail *mail, enum modify_type modify_type,
struct mail_keywords *keywords);
/* Update message's modseq to be at least min_modseq. */
void mail_update_modseq(struct mail *mail, uint64_t min_modseq);
/* Update message's POP3 UIDL (if possible). */
void mail_update_pop3_uidl(struct mail *mail, const char *uidl);
/* Expunge this message. Sequence numbers don't change until commit. */
void mail_expunge(struct mail *mail);
/* Returns TRUE if anything is cached for the mail, FALSE if not. */
bool mail_is_cached(struct mail *mail);
/* Parse mail's header and optionally body so that fields using them get
cached. */
void mail_parse(struct mail *mail, bool parse_body);
/* Mark a cached field corrupted and have it recalculated. */
void mail_set_cache_corrupted(struct mail *mail, enum mail_fetch_field field);
/* Return 128 bit GUID using input string. If guid is already 128 bit hex
encoded, it's returned as-is. Otherwise SHA1 sum is taken and its last
128 bits are returned. */
void mail_generate_guid_128_hash(const char *guid, guid_128_t guid_128_r);
#endif