mail-storage.h revision 196124a7343c268c9edc018f86b98bd98401ea15
/* External transaction. Should be used for copying and appends, /* Always assign UIDs to messages when saving/copying. Normally this is done only if it can be done easily. */ /* Refresh the index so lookups return latest flags/modseqs */ /* Don't update caching decisions no matter what we do in this transaction (useful for e.g. precaching) */ /* Sync transaction describes changes to mailbox that already happened to another mailbox with whom we're syncing with (dsync) */ /* Make sure we sync all external changes done to mailbox */ /* Make sure we write all our internal changes into the mailbox */ /* If it's not too much trouble, check if there are some changes */ /* Don't sync expunges from our view */ /* If mailbox is currently inconsistent, fix it instead of failing. */ /* Syncing after an EXPUNGE command. This is just an informational /* Force doing a full resync of indexes. */ /* FIXME: kludge until something better comes along: Request full text search index optimization */ /* RFC 5464 specifies that this is vendor/<vendor-token>/. The registered vendor-tokens always begin with "vendor." so there's some redundancy.. */ /* 0 if no private index (STATUS_HIGHESTPVTMODSEQ) */ /* NULL-terminated array of keywords (STATUS_KEYWORDS) */ /* These flags can be permanently modified (STATUS_PERMANENT_FLAGS) */ /* All keywords can be permanently modified (STATUS_PERMANENT_FLAGS) */ /* More keywords can be created (STATUS_PERMANENT_FLAGS) */ /* Modseqs aren't permanent (index is in memory) (STATUS_HIGHESTMODSEQ) */ /* Messages have GUIDs (always set) */ int decision;
/* enum mail_cache_decision_type */ /* last_used is unchanged, if it's (time_t)-1 */ /* sum of virtual size of all messages in mailbox */ /* Fields that have "temp" or "yes" caching decision. */ /* Fields that should be precached */ /* imapc backend returns this based on the remote NAMESPACE reply, while currently other backends return "" and type the same as the mailbox's real namespace type */ /* All non-zero fields are changed. */ /* Modify caching decisions, terminated by name=NULL */ /* Unreference the pool to free memory used by these changes. */ /* UIDVALIDITY for assigned UIDs. */ /* UIDs assigned to saved messages. Not necessarily ascending. If UID assignment wasn't required (e.g. LDA), this array may also be empty. Otherwise all of the saved mails got an UID. */ /* number of modseq changes that couldn't be changed as requested */ /* TRUE if anything actually changed with this commit */ /* User doesn't have read ACL for the mailbox, so don't show the uid_validity / saved_uids. */ /* There are expunges that haven't been synced yet */ /* 128 bit GUID. If the actual GUID has a different size, this contains last bits of its SHA1 sum. */ /* Perform everything no matter what it takes */ /* Abort if the operation would require reading message header/body */ /* Abort if the operation can't be done fully using cache file */ unsigned int saving:
1;
/* This mail is still being saved */ unsigned int has_nuls:
1;
/* message data is known to contain NULs */ unsigned int has_no_nuls:
1;
/* -''- known to not contain NULs */ /* If the lookup is aborted, error is set to MAIL_ERROR_NOTPOSSIBLE */ /* register all mail storages */ /* Register mail storage class with given name - all methods that are NULL are set to default methods */ /* Find mail storage class by name */ /* Create a new instance of registered mail storage class with given storage-specific data. If driver is NULL, it's tried to be autodetected from ns location. If ns location is NULL, it uses the first storage that exists. The storage is put into ns->storage. */ /* Returns the mail storage settings. */ /* Set storage callback functions to use. */ /* Purge storage's mailboxes (freeing disk space from expunged mails), if supported by the storage. Otherwise just a no-op. */ /* Returns the error message of last occurred error. */ /* Wrapper for mail_storage_get_last_error(); */ /* Wrapper for mail_storage_get_last_error(); */ /* Returns TRUE if mailboxes are files. */ /* Initialize mailbox without actually opening any files or verifying that it exists. Note that append and copy may open the selected mailbox again with possibly different readonly-state. */ /* Like mailbox_alloc(), but use mailbox GUID. */ /* Get mailbox existence state. If auto_boxes=FALSE, return MAILBOX_EXISTENCE_NONE for autocreated mailboxes that haven't been physically created yet */ /* Open the mailbox. If this function isn't called explicitly, it's also called internally by lib-storage when necessary. */ /* Open mailbox as read-only using the given stream as input. */ /* Close mailbox. Same as if mailbox was freed and re-allocated. */ /* Close and free the mailbox. */ /* Returns TRUE if box1 points to the same mailbox as ns2/vname2. */ /* Returns -1 if mailbox_create() is guaranteed to fail because the mailbox name is invalid, 0 not. The error message contains a reason. */ /* Create a mailbox. Returns failure if it already exists. Mailbox name is allowed to contain multiple new nonexistent hierarchy levels. If directory is TRUE, the mailbox should be created so that it can contain children. The mailbox itself doesn't have to be created as long as it shows up in LIST. If update is non-NULL, its contents are used to set initial mailbox /* Update existing mailbox's metadata. */ /* Delete mailbox (and its parent directory, if it has no siblings) */ /* Delete mailbox, but only if it's empty. If it's not, fails with /* Rename mailbox (and its children). Renaming across different mailbox lists is possible only between private namespaces and storages of the same type. If the rename fails, the error is set to src's storage. */ nonexistent mailboxes is optional. */ /* Returns TRUE if mailbox is subscribed, FALSE if not. This function doesn't refresh the subscriptions list, but assumes that it's been done by e.g. mailbox_list_iter*(). */ /* Enable the given feature for the mailbox. */ /* Returns all enabled features. */ /* Returns storage of given mailbox */ /* Return namespace of given mailbox. */ /* Returns the storage's settings. */ /* Returns the mailbox's settings, or NULL if there are none. */ /* Returns the (virtual) name of the given mailbox. */ /* Returns the backend name of given mailbox. */ /* Returns TRUE if mailbox is read-only. */ /* Returns TRUE if two mailboxes point to the same physical mailbox. */ /* Returns TRUE if mailbox is now in inconsistent state, meaning that the message IDs etc. may have changed - only way to recover this would be to fully close the mailbox and reopen it. With IMAP connection this would mean a forced disconnection since we can't /* Gets the mailbox status information, opening the mailbox if necessary. */ /* Gets the mailbox status, requires that mailbox is already opened. */ /* Gets mailbox metadata */ /* Returns a mask of flags that are private to user in this mailbox (as opposed to flags shared between users). */ /* Set mailbox attribute key to value. The key should be compatible with IMAP METADATA, so for Dovecot-specific keys use MAILBOX_ATTRIBUTE_PREFIX_DOVECOT. */ /* Delete mailbox attribute key. */ /* Returns value for mailbox attribute key. Returns 1 if value was returned, 0 if value wasn't found (set to NULL), -1 if error */ /* Iterate through mailbox attributes of the given type. The prefix can be used to restrict what attributes are returned. */ /* Returns the attribute key or NULL if there are no more attributes. */ /* Synchronize the mailbox. */ /* One-step mailbox synchronization. Use this if you don't care about /* Call given callback function when something changes in the mailbox. */ /* Return the number of active transactions for the mailbox. */ /* When committing transaction, drop flag/keyword updates for messages whose modseq is larger than max_modseq. Save those messages' sequences to the /* Convert uid range to sequence range. */ /* Convert sequence range to uid range. If sequences contain (uint32_t)-1 to specify "*", they're preserved. */ /* 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). */ /* Same as mailbox_get_expunges(), but return only list of UIDs. Not caring about GUIDs is slightly faster. */ /* Initialize header lookup for given headers. */ /* Initialize new search request. If sort_program is non-NULL, the messages are returned in the requested order, otherwise from first to last. */ /* Deinitialize search request. */ /* Search the next message. Returns TRUE if found, FALSE if not. */ /* 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. */ /* Returns TRUE if some messages were already expunged and we couldn't determine correctly if those messages should have been returned in this /* Remember the search result for future use. This must be called before the first mailbox_search_next*() call. */ /* Free memory used by search result. */ /* A simplified API for searching and saving the result. */ /* Return all messages' UIDs in the search 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 /* Build mail_keywords from NULL-terminated keywords list. Returns 0 if successful, -1 if there are invalid keywords (error is set). */ /* Like mailbox_keywords_create(), except ignore invalid keywords. */ /* Returns TRUE if keyword is valid, FALSE and error if not. */ /* Initialize saving a new mail. You must not try to save more than one mail /* Set the flags and keywords. Nothing is set by default. */ /* Copy flags and keywords from given mail. */ /* Set message's modseq to be at least 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. */ /* Set the "message saved" date. This should be set only when you're /* Set the envelope sender. This is currently used only with mbox files to specify the address in From_-line. */ /* Set message's UID. If UID is smaller than the current next_uid, it's given /* 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). */ /* Set message's POP3 UIDL, if the backend supports it. */ /* Specify ordering for POP3 messages. The default is to add them to the end of the mailbox. Not all backends support this. */ /* 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 /* 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 /* Copy the given message. You'll need to specify the flags etc. using the mailbox_save_*() functions. */ /* Move the given message. This is usually equivalent to copy+expunge, but without enforcing quota. */ /* Same as mailbox_copy(), but treat the message as if it's being saved, not copied. (For example: New mail delivered to multiple maildirs, with each mails being hard link copies.) */ /* Returns TRUE if successful, FALSE if message doesn't exist. mail_*() functions shouldn't be called if FALSE is returned. */ /* Add wanted fields/headers on top of existing ones. These will be forgotten /* Returns message's flags */ /* Returns message's keywords */ /* Returns message's keywords */ /* Returns message's modseq */ /* Returns message's private modseq, or 0 if message hasn't had any private flag changes. This is useful only for shared mailboxes that have a private index defined. */ /* Returns message's MIME parts */ /* Get the Date-header of the mail. Timezone is in minutes. date=0 if it wasn't found or it was invalid. */ /* Get the time when the mail was received (IMAP INTERNALDATE). */ /* Get the time when the mail was saved into this mailbox. This time may not always be entirely reliable. */ /* Get the space used by the mail as seen by the reader. Linefeeds are always counted as being CR+LF. */ /* Get the size of the stream returned by mail_get_stream(). */ /* 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. */ /* 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. */ /* Return a NULL-terminated list of values for each found field. Returns -1 if error, 0 otherwise (with or without headers found). */ /* 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()). */ /* Returns stream containing specified headers. */ /* 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. */ /* Similar to mail_get_stream(), but the stream may or may not contain the /* Returns the message part's body decoded to 8bit binary. If the Content-Transfer-Encoding isn't supported, returns -1 and sets error to MAIL_ERROR_CONVERSION. If the part refers to a multipart, all of its children are returned decoded. */ /* Like mail_get_binary_stream(), but only return the size. */ /* Get any of the "special" fields. Unhandled specials are returned as "". */ /* Returns the mail for the physical message. Normally this is the mail itself, but in virtual mailboxes it points to the backend mailbox. */ /* Update message flags. */ /* Update message keywords. */ /* Update message's modseq to be at least min_modseq. */ /* Update message's private modseq to be at least min_pvt_modseq. */ /* Update message's POP3 UIDL (if possible). */ /* Expunge this message. Sequence numbers don't change until commit. */ /* Add missing fields to cache. */ /* Mark a cached field corrupted and have it recalculated. */ /* 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. */