1 /* notmuch - Not much of an email library, (just index and search)
3 * Copyright © 2009 Carl Worth
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see http://www.gnu.org/licenses/ .
18 * Author: Carl Worth <cworth@cworth.org>
22 * @defgroup notmuch The notmuch API
24 * Not much of an email library, (just index and search)
35 # define NOTMUCH_BEGIN_DECLS extern "C" {
36 # define NOTMUCH_END_DECLS }
38 # define NOTMUCH_BEGIN_DECLS
39 # define NOTMUCH_END_DECLS
55 * The library version number. This must agree with the soname
56 * version in Makefile.local.
58 #define LIBNOTMUCH_MAJOR_VERSION 4
59 #define LIBNOTMUCH_MINOR_VERSION 3
60 #define LIBNOTMUCH_MICRO_VERSION 0
63 #if defined (__clang_major__) && __clang_major__ >= 3 \
64 || defined (__GNUC__) && __GNUC__ >= 5 \
65 || defined (__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ >= 5
66 #define NOTMUCH_DEPRECATED(major,minor) \
67 __attribute__ ((deprecated ("function deprecated as of libnotmuch " #major "." #minor)))
69 #define NOTMUCH_DEPRECATED(major,minor) __attribute__ ((deprecated))
73 #endif /* __DOXYGEN__ */
76 * Check the version of the notmuch library being compiled against.
78 * Return true if the library being compiled against is of the
79 * specified version or above. For example:
82 * #if LIBNOTMUCH_CHECK_VERSION(3, 1, 0)
83 * (code requiring libnotmuch 3.1.0 or above)
87 * LIBNOTMUCH_CHECK_VERSION has been defined since version 3.1.0; to
88 * check for versions prior to that, use:
91 * #if !defined(NOTMUCH_CHECK_VERSION)
92 * (code requiring libnotmuch prior to 3.1.0)
96 #define LIBNOTMUCH_CHECK_VERSION(major, minor, micro) \
97 (LIBNOTMUCH_MAJOR_VERSION > (major) || \
98 (LIBNOTMUCH_MAJOR_VERSION == (major) && LIBNOTMUCH_MINOR_VERSION > (minor)) || \
99 (LIBNOTMUCH_MAJOR_VERSION == (major) && LIBNOTMUCH_MINOR_VERSION == (minor) && \
100 LIBNOTMUCH_MICRO_VERSION >= (micro)))
103 * Notmuch boolean type.
105 typedef int notmuch_bool_t;
108 * Status codes used for the return values of most functions.
110 * A zero value (NOTMUCH_STATUS_SUCCESS) indicates that the function
111 * completed without error. Any other value indicates an error.
113 typedef enum _notmuch_status {
117 NOTMUCH_STATUS_SUCCESS = 0,
121 NOTMUCH_STATUS_OUT_OF_MEMORY,
123 * An attempt was made to write to a database opened in read-only
126 NOTMUCH_STATUS_READ_ONLY_DATABASE,
128 * A Xapian exception occurred.
130 NOTMUCH_STATUS_XAPIAN_EXCEPTION,
132 * An error occurred trying to read or write to a file (this could
133 * be file not found, permission denied, etc.)
135 * @todo We don't really want to expose this lame XAPIAN_EXCEPTION
136 * value. Instead we should map to things like DATABASE_LOCKED or
139 NOTMUCH_STATUS_FILE_ERROR,
141 * A file was presented that doesn't appear to be an email
144 NOTMUCH_STATUS_FILE_NOT_EMAIL,
146 * A file contains a message ID that is identical to a message
147 * already in the database.
149 NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID,
151 * The user erroneously passed a NULL pointer to a notmuch
154 NOTMUCH_STATUS_NULL_POINTER,
156 * A tag value is too long (exceeds NOTMUCH_TAG_MAX).
158 NOTMUCH_STATUS_TAG_TOO_LONG,
160 * The notmuch_message_thaw function has been called more times
161 * than notmuch_message_freeze.
163 NOTMUCH_STATUS_UNBALANCED_FREEZE_THAW,
165 * notmuch_database_end_atomic has been called more times than
166 * notmuch_database_begin_atomic.
168 NOTMUCH_STATUS_UNBALANCED_ATOMIC,
170 * The operation is not supported.
172 NOTMUCH_STATUS_UNSUPPORTED_OPERATION,
174 * The operation requires a database upgrade.
176 NOTMUCH_STATUS_UPGRADE_REQUIRED,
178 * There is a problem with the proposed path, e.g. a relative path
179 * passed to a function expecting an absolute path.
181 NOTMUCH_STATUS_PATH_ERROR,
183 * Not an actual status value. Just a way to find out how many
184 * valid status values there are.
186 NOTMUCH_STATUS_LAST_STATUS
190 * Get a string representation of a notmuch_status_t value.
192 * The result is read-only.
195 notmuch_status_to_string (notmuch_status_t status);
197 /* Various opaque data types. For each notmuch_<foo>_t see the various
198 * notmuch_<foo> functions below. */
200 typedef struct _notmuch_database notmuch_database_t;
201 typedef struct _notmuch_query notmuch_query_t;
202 typedef struct _notmuch_threads notmuch_threads_t;
203 typedef struct _notmuch_thread notmuch_thread_t;
204 typedef struct _notmuch_messages notmuch_messages_t;
205 typedef struct _notmuch_message notmuch_message_t;
206 typedef struct _notmuch_tags notmuch_tags_t;
207 typedef struct _notmuch_directory notmuch_directory_t;
208 typedef struct _notmuch_filenames notmuch_filenames_t;
209 #endif /* __DOXYGEN__ */
212 * Create a new, empty notmuch database located at 'path'.
214 * The path should be a top-level directory to a collection of
215 * plain-text email messages (one message per file). This call will
216 * create a new ".notmuch" directory within 'path' where notmuch will
219 * After a successful call to notmuch_database_create, the returned
220 * database will be open so the caller should call
221 * notmuch_database_destroy when finished with it.
223 * The database will not yet have any data in it
224 * (notmuch_database_create itself is a very cheap function). Messages
225 * contained within 'path' can be added to the database by calling
226 * notmuch_database_add_message.
228 * In case of any failure, this function returns an error status and
229 * sets *database to NULL (after printing an error message on stderr).
233 * NOTMUCH_STATUS_SUCCESS: Successfully created the database.
235 * NOTMUCH_STATUS_NULL_POINTER: The given 'path' argument is NULL.
237 * NOTMUCH_STATUS_OUT_OF_MEMORY: Out of memory.
239 * NOTMUCH_STATUS_FILE_ERROR: An error occurred trying to create the
240 * database file (such as permission denied, or file not found,
241 * etc.), or the database already exists.
243 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred.
246 notmuch_database_create (const char *path, notmuch_database_t **database);
249 * Like notmuch_database_create, except optionally return an error
250 * message. This message is allocated by malloc and should be freed by
254 notmuch_database_create_verbose (const char *path,
255 notmuch_database_t **database,
256 char **error_message);
259 * Database open mode for notmuch_database_open.
263 * Open database for reading only.
265 NOTMUCH_DATABASE_MODE_READ_ONLY = 0,
267 * Open database for reading and writing.
269 NOTMUCH_DATABASE_MODE_READ_WRITE
270 } notmuch_database_mode_t;
273 * Open an existing notmuch database located at 'path'.
275 * The database should have been created at some time in the past,
276 * (not necessarily by this process), by calling
277 * notmuch_database_create with 'path'. By default the database should be
278 * opened for reading only. In order to write to the database you need to
279 * pass the NOTMUCH_DATABASE_MODE_READ_WRITE mode.
281 * An existing notmuch database can be identified by the presence of a
282 * directory named ".notmuch" below 'path'.
284 * The caller should call notmuch_database_destroy when finished with
287 * In case of any failure, this function returns an error status and
288 * sets *database to NULL (after printing an error message on stderr).
292 * NOTMUCH_STATUS_SUCCESS: Successfully opened the database.
294 * NOTMUCH_STATUS_NULL_POINTER: The given 'path' argument is NULL.
296 * NOTMUCH_STATUS_OUT_OF_MEMORY: Out of memory.
298 * NOTMUCH_STATUS_FILE_ERROR: An error occurred trying to open the
299 * database file (such as permission denied, or file not found,
300 * etc.), or the database version is unknown.
302 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred.
305 notmuch_database_open (const char *path,
306 notmuch_database_mode_t mode,
307 notmuch_database_t **database);
309 * Like notmuch_database_open, except optionally return an error
310 * message. This message is allocated by malloc and should be freed by
315 notmuch_database_open_verbose (const char *path,
316 notmuch_database_mode_t mode,
317 notmuch_database_t **database,
318 char **error_message);
321 * Retrieve last status string for given database.
325 notmuch_database_status_string (const notmuch_database_t *notmuch);
328 * Commit changes and close the given notmuch database.
330 * After notmuch_database_close has been called, calls to other
331 * functions on objects derived from this database may either behave
332 * as if the database had not been closed (e.g., if the required data
333 * has been cached) or may fail with a
334 * NOTMUCH_STATUS_XAPIAN_EXCEPTION. The only further operation
335 * permitted on the database itself is to call
336 * notmuch_database_destroy.
338 * notmuch_database_close can be called multiple times. Later calls
341 * For writable databases, notmuch_database_close commits all changes
342 * to disk before closing the database. If the caller is currently in
343 * an atomic section (there was a notmuch_database_begin_atomic
344 * without a matching notmuch_database_end_atomic), this will discard
345 * changes made in that atomic section (but still commit changes made
346 * prior to entering the atomic section).
350 * NOTMUCH_STATUS_SUCCESS: Successfully closed the database.
352 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred; the
353 * database has been closed but there are no guarantees the
354 * changes to the database, if any, have been flushed to disk.
357 notmuch_database_close (notmuch_database_t *database);
360 * A callback invoked by notmuch_database_compact to notify the user
361 * of the progress of the compaction process.
363 typedef void (*notmuch_compact_status_cb_t)(const char *message, void *closure);
366 * Compact a notmuch database, backing up the original database to the
369 * The database will be opened with NOTMUCH_DATABASE_MODE_READ_WRITE
370 * during the compaction process to ensure no writes are made.
372 * If the optional callback function 'status_cb' is non-NULL, it will
373 * be called with diagnostic and informational messages. The argument
374 * 'closure' is passed verbatim to any callback invoked.
377 notmuch_database_compact (const char* path,
378 const char* backup_path,
379 notmuch_compact_status_cb_t status_cb,
383 * Destroy the notmuch database, closing it if necessary and freeing
384 * all associated resources.
386 * Return value as in notmuch_database_close if the database was open;
387 * notmuch_database_destroy itself has no failure modes.
390 notmuch_database_destroy (notmuch_database_t *database);
393 * Return the database path of the given database.
395 * The return value is a string owned by notmuch so should not be
396 * modified nor freed by the caller.
399 notmuch_database_get_path (notmuch_database_t *database);
402 * Return the database format version of the given database.
405 notmuch_database_get_version (notmuch_database_t *database);
408 * Can the database be upgraded to a newer database version?
410 * If this function returns TRUE, then the caller may call
411 * notmuch_database_upgrade to upgrade the database. If the caller
412 * does not upgrade an out-of-date database, then some functions may
413 * fail with NOTMUCH_STATUS_UPGRADE_REQUIRED. This always returns
414 * FALSE for a read-only database because there's no way to upgrade a
415 * read-only database.
418 notmuch_database_needs_upgrade (notmuch_database_t *database);
421 * Upgrade the current database to the latest supported version.
423 * This ensures that all current notmuch functionality will be
424 * available on the database. After opening a database in read-write
425 * mode, it is recommended that clients check if an upgrade is needed
426 * (notmuch_database_needs_upgrade) and if so, upgrade with this
427 * function before making any modifications. If
428 * notmuch_database_needs_upgrade returns FALSE, this will be a no-op.
430 * The optional progress_notify callback can be used by the caller to
431 * provide progress indication to the user. If non-NULL it will be
432 * called periodically with 'progress' as a floating-point value in
433 * the range of [0.0 .. 1.0] indicating the progress made so far in
434 * the upgrade process. The argument 'closure' is passed verbatim to
435 * any callback invoked.
438 notmuch_database_upgrade (notmuch_database_t *database,
439 void (*progress_notify) (void *closure,
444 * Begin an atomic database operation.
446 * Any modifications performed between a successful begin and a
447 * notmuch_database_end_atomic will be applied to the database
448 * atomically. Note that, unlike a typical database transaction, this
449 * only ensures atomicity, not durability; neither begin nor end
450 * necessarily flush modifications to disk.
452 * Atomic sections may be nested. begin_atomic and end_atomic must
453 * always be called in pairs.
457 * NOTMUCH_STATUS_SUCCESS: Successfully entered atomic section.
459 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred;
460 * atomic section not entered.
463 notmuch_database_begin_atomic (notmuch_database_t *notmuch);
466 * Indicate the end of an atomic database operation.
470 * NOTMUCH_STATUS_SUCCESS: Successfully completed atomic section.
472 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred;
473 * atomic section not ended.
475 * NOTMUCH_STATUS_UNBALANCED_ATOMIC: The database is not currently in
479 notmuch_database_end_atomic (notmuch_database_t *notmuch);
482 * Return the committed database revision and UUID.
484 * The database revision number increases monotonically with each
485 * commit to the database. Hence, all messages and message changes
486 * committed to the database (that is, visible to readers) have a last
487 * modification revision <= the committed database revision. Any
488 * messages committed in the future will be assigned a modification
489 * revision > the committed database revision.
491 * The UUID is a NUL-terminated opaque string that uniquely identifies
492 * this database. Two revision numbers are only comparable if they
493 * have the same database UUID.
496 notmuch_database_get_revision (notmuch_database_t *notmuch,
500 * Retrieve a directory object from the database for 'path'.
502 * Here, 'path' should be a path relative to the path of 'database'
503 * (see notmuch_database_get_path), or else should be an absolute path
504 * with initial components that match the path of 'database'.
506 * If this directory object does not exist in the database, this
507 * returns NOTMUCH_STATUS_SUCCESS and sets *directory to NULL.
509 * Otherwise the returned directory object is owned by the database
510 * and as such, will only be valid until notmuch_database_destroy is
515 * NOTMUCH_STATUS_SUCCESS: Successfully retrieved directory.
517 * NOTMUCH_STATUS_NULL_POINTER: The given 'directory' argument is NULL.
519 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred;
520 * directory not retrieved.
522 * NOTMUCH_STATUS_UPGRADE_REQUIRED: The caller must upgrade the
523 * database to use this function.
526 notmuch_database_get_directory (notmuch_database_t *database,
528 notmuch_directory_t **directory);
531 * Add a new message to the given notmuch database or associate an
532 * additional filename with an existing message.
534 * Here, 'filename' should be a path relative to the path of
535 * 'database' (see notmuch_database_get_path), or else should be an
536 * absolute filename with initial components that match the path of
539 * The file should be a single mail message (not a multi-message mbox)
540 * that is expected to remain at its current location, (since the
541 * notmuch database will reference the filename, and will not copy the
542 * entire contents of the file.
544 * If another message with the same message ID already exists in the
545 * database, rather than creating a new message, this adds 'filename'
546 * to the list of the filenames for the existing message.
548 * If 'message' is not NULL, then, on successful return
549 * (NOTMUCH_STATUS_SUCCESS or NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) '*message'
550 * will be initialized to a message object that can be used for things
551 * such as adding tags to the just-added message. The user should call
552 * notmuch_message_destroy when done with the message. On any failure
553 * '*message' will be set to NULL.
557 * NOTMUCH_STATUS_SUCCESS: Message successfully added to database.
559 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred,
562 * NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID: Message has the same message
563 * ID as another message already in the database. The new
564 * filename was successfully added to the message in the database
565 * (if not already present) and the existing message is returned.
567 * NOTMUCH_STATUS_FILE_ERROR: an error occurred trying to open the
568 * file, (such as permission denied, or file not found,
569 * etc.). Nothing added to the database.
571 * NOTMUCH_STATUS_FILE_NOT_EMAIL: the contents of filename don't look
572 * like an email message. Nothing added to the database.
574 * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only
575 * mode so no message can be added.
577 * NOTMUCH_STATUS_UPGRADE_REQUIRED: The caller must upgrade the
578 * database to use this function.
581 notmuch_database_add_message (notmuch_database_t *database,
582 const char *filename,
583 notmuch_message_t **message);
586 * Remove a message filename from the given notmuch database. If the
587 * message has no more filenames, remove the message.
589 * If the same message (as determined by the message ID) is still
590 * available via other filenames, then the message will persist in the
591 * database for those filenames. When the last filename is removed for
592 * a particular message, the database content for that message will be
597 * NOTMUCH_STATUS_SUCCESS: The last filename was removed and the
598 * message was removed from the database.
600 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred,
601 * message not removed.
603 * NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID: This filename was removed but
604 * the message persists in the database with at least one other
607 * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only
608 * mode so no message can be removed.
610 * NOTMUCH_STATUS_UPGRADE_REQUIRED: The caller must upgrade the
611 * database to use this function.
614 notmuch_database_remove_message (notmuch_database_t *database,
615 const char *filename);
618 * Find a message with the given message_id.
620 * If a message with the given message_id is found then, on successful return
621 * (NOTMUCH_STATUS_SUCCESS) '*message' will be initialized to a message
622 * object. The caller should call notmuch_message_destroy when done with the
625 * On any failure or when the message is not found, this function initializes
626 * '*message' to NULL. This means, when NOTMUCH_STATUS_SUCCESS is returned, the
627 * caller is supposed to check '*message' for NULL to find out whether the
628 * message with the given message_id was found.
632 * NOTMUCH_STATUS_SUCCESS: Successful return, check '*message'.
634 * NOTMUCH_STATUS_NULL_POINTER: The given 'message' argument is NULL
636 * NOTMUCH_STATUS_OUT_OF_MEMORY: Out of memory, creating message object
638 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred
641 notmuch_database_find_message (notmuch_database_t *database,
642 const char *message_id,
643 notmuch_message_t **message);
646 * Find a message with the given filename.
648 * If the database contains a message with the given filename then, on
649 * successful return (NOTMUCH_STATUS_SUCCESS) '*message' will be initialized to
650 * a message object. The caller should call notmuch_message_destroy when done
653 * On any failure or when the message is not found, this function initializes
654 * '*message' to NULL. This means, when NOTMUCH_STATUS_SUCCESS is returned, the
655 * caller is supposed to check '*message' for NULL to find out whether the
656 * message with the given filename is found.
660 * NOTMUCH_STATUS_SUCCESS: Successful return, check '*message'
662 * NOTMUCH_STATUS_NULL_POINTER: The given 'message' argument is NULL
664 * NOTMUCH_STATUS_OUT_OF_MEMORY: Out of memory, creating the message object
666 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred
668 * NOTMUCH_STATUS_UPGRADE_REQUIRED: The caller must upgrade the
669 * database to use this function.
672 notmuch_database_find_message_by_filename (notmuch_database_t *notmuch,
673 const char *filename,
674 notmuch_message_t **message);
677 * Return a list of all tags found in the database.
679 * This function creates a list of all tags found in the database. The
680 * resulting list contains all tags from all messages found in the database.
682 * On error this function returns NULL.
685 notmuch_database_get_all_tags (notmuch_database_t *db);
688 * Create a new query for 'database'.
690 * Here, 'database' should be an open database, (see
691 * notmuch_database_open and notmuch_database_create).
693 * For the query string, we'll document the syntax here more
694 * completely in the future, but it's likely to be a specialized
695 * version of the general Xapian query syntax:
697 * http://xapian.org/docs/queryparser.html
699 * As a special case, passing either a length-zero string, (that is ""),
700 * or a string consisting of a single asterisk (that is "*"), will
701 * result in a query that returns all messages in the database.
703 * See notmuch_query_set_sort for controlling the order of results.
704 * See notmuch_query_search_messages and notmuch_query_search_threads
705 * to actually execute the query.
707 * User should call notmuch_query_destroy when finished with this
710 * Will return NULL if insufficient memory is available.
713 notmuch_query_create (notmuch_database_t *database,
714 const char *query_string);
717 * Sort values for notmuch_query_set_sort.
723 NOTMUCH_SORT_OLDEST_FIRST,
727 NOTMUCH_SORT_NEWEST_FIRST,
729 * Sort by message-id.
731 NOTMUCH_SORT_MESSAGE_ID,
735 NOTMUCH_SORT_UNSORTED
739 * Return the query_string of this query. See notmuch_query_create.
742 notmuch_query_get_query_string (const notmuch_query_t *query);
745 * Return the notmuch database of this query. See notmuch_query_create.
748 notmuch_query_get_database (const notmuch_query_t *query);
751 * Exclude values for notmuch_query_set_omit_excluded. The strange
752 * order is to maintain backward compatibility: the old FALSE/TRUE
753 * options correspond to the new
754 * NOTMUCH_EXCLUDE_FLAG/NOTMUCH_EXCLUDE_TRUE options.
757 NOTMUCH_EXCLUDE_FLAG,
758 NOTMUCH_EXCLUDE_TRUE,
759 NOTMUCH_EXCLUDE_FALSE,
764 * Specify whether to omit excluded results or simply flag them. By
765 * default, this is set to TRUE.
767 * If set to TRUE or ALL, notmuch_query_search_messages will omit excluded
768 * messages from the results, and notmuch_query_search_threads will omit
769 * threads that match only in excluded messages. If set to TRUE,
770 * notmuch_query_search_threads will include all messages in threads that
771 * match in at least one non-excluded message. Otherwise, if set to ALL,
772 * notmuch_query_search_threads will omit excluded messages from all threads.
774 * If set to FALSE or FLAG then both notmuch_query_search_messages and
775 * notmuch_query_search_threads will return all matching
776 * messages/threads regardless of exclude status. If set to FLAG then
777 * the exclude flag will be set for any excluded message that is
778 * returned by notmuch_query_search_messages, and the thread counts
779 * for threads returned by notmuch_query_search_threads will be the
780 * number of non-excluded messages/matches. Otherwise, if set to
781 * FALSE, then the exclude status is completely ignored.
783 * The performance difference when calling
784 * notmuch_query_search_messages should be relatively small (and both
785 * should be very fast). However, in some cases,
786 * notmuch_query_search_threads is very much faster when omitting
787 * excluded messages as it does not need to construct the threads that
788 * only match in excluded messages.
791 notmuch_query_set_omit_excluded (notmuch_query_t *query,
792 notmuch_exclude_t omit_excluded);
795 * Specify the sorting desired for this query.
798 notmuch_query_set_sort (notmuch_query_t *query, notmuch_sort_t sort);
801 * Return the sort specified for this query. See
802 * notmuch_query_set_sort.
805 notmuch_query_get_sort (const notmuch_query_t *query);
808 * Add a tag that will be excluded from the query results by default.
809 * This exclusion will be overridden if this tag appears explicitly in
813 notmuch_query_add_tag_exclude (notmuch_query_t *query, const char *tag);
816 * Execute a query for threads, returning a notmuch_threads_t object
817 * which can be used to iterate over the results. The returned threads
818 * object is owned by the query and as such, will only be valid until
819 * notmuch_query_destroy.
821 * Typical usage might be:
823 * notmuch_query_t *query;
824 * notmuch_threads_t *threads;
825 * notmuch_thread_t *thread;
827 * query = notmuch_query_create (database, query_string);
829 * for (threads = notmuch_query_search_threads (query);
830 * notmuch_threads_valid (threads);
831 * notmuch_threads_move_to_next (threads))
833 * thread = notmuch_threads_get (threads);
835 * notmuch_thread_destroy (thread);
838 * notmuch_query_destroy (query);
840 * Note: If you are finished with a thread before its containing
841 * query, you can call notmuch_thread_destroy to clean up some memory
842 * sooner (as in the above example). Otherwise, if your thread objects
843 * are long-lived, then you don't need to call notmuch_thread_destroy
844 * and all the memory will still be reclaimed when the query is
847 * Note that there's no explicit destructor needed for the
848 * notmuch_threads_t object. (For consistency, we do provide a
849 * notmuch_threads_destroy function, but there's no good reason
850 * to call it if the query is about to be destroyed).
852 * @since libnotmuch 4.2 (notmuch 0.20)
855 notmuch_query_search_threads_st (notmuch_query_t *query,
856 notmuch_threads_t **out);
859 * Like notmuch_query_search_threads_st, but without a status return.
861 * If a Xapian exception occurs this function will return NULL.
863 * @deprecated Deprecated as of libnotmuch 4.3 (notmuch 0.21). Please
864 * use notmuch_query_search_threads_st instead.
867 NOTMUCH_DEPRECATED(4,3)
869 notmuch_query_search_threads (notmuch_query_t *query);
872 * Execute a query for messages, returning a notmuch_messages_t object
873 * which can be used to iterate over the results. The returned
874 * messages object is owned by the query and as such, will only be
875 * valid until notmuch_query_destroy.
877 * Typical usage might be:
879 * notmuch_query_t *query;
880 * notmuch_messages_t *messages;
881 * notmuch_message_t *message;
883 * query = notmuch_query_create (database, query_string);
885 * for (messages = notmuch_query_search_messages (query);
886 * notmuch_messages_valid (messages);
887 * notmuch_messages_move_to_next (messages))
889 * message = notmuch_messages_get (messages);
891 * notmuch_message_destroy (message);
894 * notmuch_query_destroy (query);
896 * Note: If you are finished with a message before its containing
897 * query, you can call notmuch_message_destroy to clean up some memory
898 * sooner (as in the above example). Otherwise, if your message
899 * objects are long-lived, then you don't need to call
900 * notmuch_message_destroy and all the memory will still be reclaimed
901 * when the query is destroyed.
903 * Note that there's no explicit destructor needed for the
904 * notmuch_messages_t object. (For consistency, we do provide a
905 * notmuch_messages_destroy function, but there's no good
906 * reason to call it if the query is about to be destroyed).
908 * If a Xapian exception occurs this function will return NULL.
910 * @since libnotmuch 4.2 (notmuch 0.20)
913 notmuch_query_search_messages_st (notmuch_query_t *query,
914 notmuch_messages_t **out);
916 * Like notmuch_query_search_messages, but without a status return.
918 * If a Xapian exception occurs this function will return NULL.
920 * @deprecated Deprecated as of libnotmuch 4.3 (notmuch 0.21). Please use
921 * notmuch_query_search_messages_st instead.
924 NOTMUCH_DEPRECATED(4,3)
926 notmuch_query_search_messages (notmuch_query_t *query);
929 * Destroy a notmuch_query_t along with any associated resources.
931 * This will in turn destroy any notmuch_threads_t and
932 * notmuch_messages_t objects generated by this query, (and in
933 * turn any notmuch_thread_t and notmuch_message_t objects generated
934 * from those results, etc.), if such objects haven't already been
938 notmuch_query_destroy (notmuch_query_t *query);
941 * Is the given 'threads' iterator pointing at a valid thread.
943 * When this function returns TRUE, notmuch_threads_get will return a
944 * valid object. Whereas when this function returns FALSE,
945 * notmuch_threads_get will return NULL.
947 * If passed a NULL pointer, this function returns FALSE
949 * See the documentation of notmuch_query_search_threads for example
950 * code showing how to iterate over a notmuch_threads_t object.
953 notmuch_threads_valid (notmuch_threads_t *threads);
956 * Get the current thread from 'threads' as a notmuch_thread_t.
958 * Note: The returned thread belongs to 'threads' and has a lifetime
959 * identical to it (and the query to which it belongs).
961 * See the documentation of notmuch_query_search_threads for example
962 * code showing how to iterate over a notmuch_threads_t object.
964 * If an out-of-memory situation occurs, this function will return
968 notmuch_threads_get (notmuch_threads_t *threads);
971 * Move the 'threads' iterator to the next thread.
973 * If 'threads' is already pointing at the last thread then the
974 * iterator will be moved to a point just beyond that last thread,
975 * (where notmuch_threads_valid will return FALSE and
976 * notmuch_threads_get will return NULL).
978 * See the documentation of notmuch_query_search_threads for example
979 * code showing how to iterate over a notmuch_threads_t object.
982 notmuch_threads_move_to_next (notmuch_threads_t *threads);
985 * Destroy a notmuch_threads_t object.
987 * It's not strictly necessary to call this function. All memory from
988 * the notmuch_threads_t object will be reclaimed when the
989 * containing query object is destroyed.
992 notmuch_threads_destroy (notmuch_threads_t *threads);
995 * Return the number of messages matching a search.
997 * This function performs a search and returns the number of matching
1002 * NOTMUCH_STATUS_SUCCESS: query completed successfully.
1004 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: a Xapian exception occured. The
1005 * value of *count is not defined.
1007 * @since libnotmuch 4.3 (notmuch 0.21)
1010 notmuch_query_count_messages_st (notmuch_query_t *query, unsigned int *count);
1013 * like notmuch_query_count_messages_st, but without a status return.
1015 * May return 0 in the case of errors.
1017 * @deprecated Deprecated since libnotmuch 4.3 (notmuch 0.21). Please
1018 * use notmuch_query_count_messages_st instead.
1020 NOTMUCH_DEPRECATED(4,3)
1022 notmuch_query_count_messages (notmuch_query_t *query);
1025 * Return the number of threads matching a search.
1027 * This function performs a search and returns the number of unique thread IDs
1028 * in the matching messages. This is the same as number of threads matching a
1031 * Note that this is a significantly heavier operation than
1032 * notmuch_query_count_messages{_st}().
1036 * NOTMUCH_STATUS_OUT_OF_MEMORY: Memory allocation failed. The value
1037 * of *count is not defined
1039 * NOTMUCH_STATUS_SUCCESS: query completed successfully.
1041 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: a Xapian exception occured. The
1042 * value of *count is not defined.
1044 * @since libnotmuch 4.3 (notmuch 0.21)
1047 notmuch_query_count_threads_st (notmuch_query_t *query, unsigned *count);
1050 * like notmuch_query_count_threads, but without a status return.
1052 * May return 0 in case of errors.
1054 * @deprecated Deprecated as of libnotmuch 4.3 (notmuch 0.21). Please
1055 * use notmuch_query_count_threads_st instead.
1057 NOTMUCH_DEPRECATED(4,3)
1059 notmuch_query_count_threads (notmuch_query_t *query);
1062 * Get the thread ID of 'thread'.
1064 * The returned string belongs to 'thread' and as such, should not be
1065 * modified by the caller and will only be valid for as long as the
1066 * thread is valid, (which is until notmuch_thread_destroy or until
1067 * the query from which it derived is destroyed).
1070 notmuch_thread_get_thread_id (notmuch_thread_t *thread);
1073 * Get the total number of messages in 'thread'.
1075 * This count consists of all messages in the database belonging to
1076 * this thread. Contrast with notmuch_thread_get_matched_messages() .
1079 notmuch_thread_get_total_messages (notmuch_thread_t *thread);
1082 * Get a notmuch_messages_t iterator for the top-level messages in
1083 * 'thread' in oldest-first order.
1085 * This iterator will not necessarily iterate over all of the messages
1086 * in the thread. It will only iterate over the messages in the thread
1087 * which are not replies to other messages in the thread.
1089 * The returned list will be destroyed when the thread is destroyed.
1091 notmuch_messages_t *
1092 notmuch_thread_get_toplevel_messages (notmuch_thread_t *thread);
1095 * Get a notmuch_thread_t iterator for all messages in 'thread' in
1096 * oldest-first order.
1098 * The returned list will be destroyed when the thread is destroyed.
1100 notmuch_messages_t *
1101 notmuch_thread_get_messages (notmuch_thread_t *thread);
1104 * Get the number of messages in 'thread' that matched the search.
1106 * This count includes only the messages in this thread that were
1107 * matched by the search from which the thread was created and were
1108 * not excluded by any exclude tags passed in with the query (see
1109 * notmuch_query_add_tag_exclude). Contrast with
1110 * notmuch_thread_get_total_messages() .
1113 notmuch_thread_get_matched_messages (notmuch_thread_t *thread);
1116 * Get the authors of 'thread' as a UTF-8 string.
1118 * The returned string is a comma-separated list of the names of the
1119 * authors of mail messages in the query results that belong to this
1122 * The string contains authors of messages matching the query first, then
1123 * non-matched authors (with the two groups separated by '|'). Within
1124 * each group, authors are ordered by date.
1126 * The returned string belongs to 'thread' and as such, should not be
1127 * modified by the caller and will only be valid for as long as the
1128 * thread is valid, (which is until notmuch_thread_destroy or until
1129 * the query from which it derived is destroyed).
1132 notmuch_thread_get_authors (notmuch_thread_t *thread);
1135 * Get the subject of 'thread' as a UTF-8 string.
1137 * The subject is taken from the first message (according to the query
1138 * order---see notmuch_query_set_sort) in the query results that
1139 * belongs to this thread.
1141 * The returned string belongs to 'thread' and as such, should not be
1142 * modified by the caller and will only be valid for as long as the
1143 * thread is valid, (which is until notmuch_thread_destroy or until
1144 * the query from which it derived is destroyed).
1147 notmuch_thread_get_subject (notmuch_thread_t *thread);
1150 * Get the date of the oldest message in 'thread' as a time_t value.
1153 notmuch_thread_get_oldest_date (notmuch_thread_t *thread);
1156 * Get the date of the newest message in 'thread' as a time_t value.
1159 notmuch_thread_get_newest_date (notmuch_thread_t *thread);
1162 * Get the tags for 'thread', returning a notmuch_tags_t object which
1163 * can be used to iterate over all tags.
1165 * Note: In the Notmuch database, tags are stored on individual
1166 * messages, not on threads. So the tags returned here will be all
1167 * tags of the messages which matched the search and which belong to
1170 * The tags object is owned by the thread and as such, will only be
1171 * valid for as long as the thread is valid, (for example, until
1172 * notmuch_thread_destroy or until the query from which it derived is
1175 * Typical usage might be:
1177 * notmuch_thread_t *thread;
1178 * notmuch_tags_t *tags;
1181 * thread = notmuch_threads_get (threads);
1183 * for (tags = notmuch_thread_get_tags (thread);
1184 * notmuch_tags_valid (tags);
1185 * notmuch_tags_move_to_next (tags))
1187 * tag = notmuch_tags_get (tags);
1191 * notmuch_thread_destroy (thread);
1193 * Note that there's no explicit destructor needed for the
1194 * notmuch_tags_t object. (For consistency, we do provide a
1195 * notmuch_tags_destroy function, but there's no good reason to call
1196 * it if the message is about to be destroyed).
1199 notmuch_thread_get_tags (notmuch_thread_t *thread);
1202 * Destroy a notmuch_thread_t object.
1205 notmuch_thread_destroy (notmuch_thread_t *thread);
1208 * Is the given 'messages' iterator pointing at a valid message.
1210 * When this function returns TRUE, notmuch_messages_get will return a
1211 * valid object. Whereas when this function returns FALSE,
1212 * notmuch_messages_get will return NULL.
1214 * See the documentation of notmuch_query_search_messages for example
1215 * code showing how to iterate over a notmuch_messages_t object.
1218 notmuch_messages_valid (notmuch_messages_t *messages);
1221 * Get the current message from 'messages' as a notmuch_message_t.
1223 * Note: The returned message belongs to 'messages' and has a lifetime
1224 * identical to it (and the query to which it belongs).
1226 * See the documentation of notmuch_query_search_messages for example
1227 * code showing how to iterate over a notmuch_messages_t object.
1229 * If an out-of-memory situation occurs, this function will return
1233 notmuch_messages_get (notmuch_messages_t *messages);
1236 * Move the 'messages' iterator to the next message.
1238 * If 'messages' is already pointing at the last message then the
1239 * iterator will be moved to a point just beyond that last message,
1240 * (where notmuch_messages_valid will return FALSE and
1241 * notmuch_messages_get will return NULL).
1243 * See the documentation of notmuch_query_search_messages for example
1244 * code showing how to iterate over a notmuch_messages_t object.
1247 notmuch_messages_move_to_next (notmuch_messages_t *messages);
1250 * Destroy a notmuch_messages_t object.
1252 * It's not strictly necessary to call this function. All memory from
1253 * the notmuch_messages_t object will be reclaimed when the containing
1254 * query object is destroyed.
1257 notmuch_messages_destroy (notmuch_messages_t *messages);
1260 * Return a list of tags from all messages.
1262 * The resulting list is guaranteed not to contain duplicated tags.
1264 * WARNING: You can no longer iterate over messages after calling this
1265 * function, because the iterator will point at the end of the list.
1266 * We do not have a function to reset the iterator yet and the only
1267 * way how you can iterate over the list again is to recreate the
1270 * The function returns NULL on error.
1273 notmuch_messages_collect_tags (notmuch_messages_t *messages);
1276 * Get the message ID of 'message'.
1278 * The returned string belongs to 'message' and as such, should not be
1279 * modified by the caller and will only be valid for as long as the
1280 * message is valid, (which is until the query from which it derived
1283 * This function will not return NULL since Notmuch ensures that every
1284 * message has a unique message ID, (Notmuch will generate an ID for a
1285 * message if the original file does not contain one).
1288 notmuch_message_get_message_id (notmuch_message_t *message);
1291 * Get the thread ID of 'message'.
1293 * The returned string belongs to 'message' and as such, should not be
1294 * modified by the caller and will only be valid for as long as the
1295 * message is valid, (for example, until the user calls
1296 * notmuch_message_destroy on 'message' or until a query from which it
1297 * derived is destroyed).
1299 * This function will not return NULL since Notmuch ensures that every
1300 * message belongs to a single thread.
1303 notmuch_message_get_thread_id (notmuch_message_t *message);
1306 * Get a notmuch_messages_t iterator for all of the replies to
1309 * Note: This call only makes sense if 'message' was ultimately
1310 * obtained from a notmuch_thread_t object, (such as by coming
1311 * directly from the result of calling notmuch_thread_get_
1312 * toplevel_messages or by any number of subsequent
1313 * calls to notmuch_message_get_replies).
1315 * If 'message' was obtained through some non-thread means, (such as
1316 * by a call to notmuch_query_search_messages), then this function
1319 * If there are no replies to 'message', this function will return
1320 * NULL. (Note that notmuch_messages_valid will accept that NULL
1321 * value as legitimate, and simply return FALSE for it.)
1323 notmuch_messages_t *
1324 notmuch_message_get_replies (notmuch_message_t *message);
1327 * Get a filename for the email corresponding to 'message'.
1329 * The returned filename is an absolute filename, (the initial
1330 * component will match notmuch_database_get_path() ).
1332 * The returned string belongs to the message so should not be
1333 * modified or freed by the caller (nor should it be referenced after
1334 * the message is destroyed).
1336 * Note: If this message corresponds to multiple files in the mail
1337 * store, (that is, multiple files contain identical message IDs),
1338 * this function will arbitrarily return a single one of those
1339 * filenames. See notmuch_message_get_filenames for returning the
1340 * complete list of filenames.
1343 notmuch_message_get_filename (notmuch_message_t *message);
1346 * Get all filenames for the email corresponding to 'message'.
1348 * Returns a notmuch_filenames_t iterator listing all the filenames
1349 * associated with 'message'. These files may not have identical
1350 * content, but each will have the identical Message-ID.
1352 * Each filename in the iterator is an absolute filename, (the initial
1353 * component will match notmuch_database_get_path() ).
1355 notmuch_filenames_t *
1356 notmuch_message_get_filenames (notmuch_message_t *message);
1361 typedef enum _notmuch_message_flag {
1362 NOTMUCH_MESSAGE_FLAG_MATCH,
1363 NOTMUCH_MESSAGE_FLAG_EXCLUDED,
1365 /* This message is a "ghost message", meaning it has no filenames
1366 * or content, but we know it exists because it was referenced by
1367 * some other message. A ghost message has only a message ID and
1370 NOTMUCH_MESSAGE_FLAG_GHOST,
1371 } notmuch_message_flag_t;
1374 * Get a value of a flag for the email corresponding to 'message'.
1377 notmuch_message_get_flag (notmuch_message_t *message,
1378 notmuch_message_flag_t flag);
1381 * Set a value of a flag for the email corresponding to 'message'.
1384 notmuch_message_set_flag (notmuch_message_t *message,
1385 notmuch_message_flag_t flag, notmuch_bool_t value);
1388 * Get the date of 'message' as a time_t value.
1390 * For the original textual representation of the Date header from the
1391 * message call notmuch_message_get_header() with a header value of
1395 notmuch_message_get_date (notmuch_message_t *message);
1398 * Get the value of the specified header from 'message' as a UTF-8 string.
1400 * Common headers are stored in the database when the message is
1401 * indexed and will be returned from the database. Other headers will
1402 * be read from the actual message file.
1404 * The header name is case insensitive.
1406 * The returned string belongs to the message so should not be
1407 * modified or freed by the caller (nor should it be referenced after
1408 * the message is destroyed).
1410 * Returns an empty string ("") if the message does not contain a
1411 * header line matching 'header'. Returns NULL if any error occurs.
1414 notmuch_message_get_header (notmuch_message_t *message, const char *header);
1417 * Get the tags for 'message', returning a notmuch_tags_t object which
1418 * can be used to iterate over all tags.
1420 * The tags object is owned by the message and as such, will only be
1421 * valid for as long as the message is valid, (which is until the
1422 * query from which it derived is destroyed).
1424 * Typical usage might be:
1426 * notmuch_message_t *message;
1427 * notmuch_tags_t *tags;
1430 * message = notmuch_database_find_message (database, message_id);
1432 * for (tags = notmuch_message_get_tags (message);
1433 * notmuch_tags_valid (tags);
1434 * notmuch_tags_move_to_next (tags))
1436 * tag = notmuch_tags_get (tags);
1440 * notmuch_message_destroy (message);
1442 * Note that there's no explicit destructor needed for the
1443 * notmuch_tags_t object. (For consistency, we do provide a
1444 * notmuch_tags_destroy function, but there's no good reason to call
1445 * it if the message is about to be destroyed).
1448 notmuch_message_get_tags (notmuch_message_t *message);
1451 * The longest possible tag value.
1453 #define NOTMUCH_TAG_MAX 200
1456 * Add a tag to the given message.
1460 * NOTMUCH_STATUS_SUCCESS: Tag successfully added to message
1462 * NOTMUCH_STATUS_NULL_POINTER: The 'tag' argument is NULL
1464 * NOTMUCH_STATUS_TAG_TOO_LONG: The length of 'tag' is too long
1465 * (exceeds NOTMUCH_TAG_MAX)
1467 * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only
1468 * mode so message cannot be modified.
1471 notmuch_message_add_tag (notmuch_message_t *message, const char *tag);
1474 * Remove a tag from the given message.
1478 * NOTMUCH_STATUS_SUCCESS: Tag successfully removed from message
1480 * NOTMUCH_STATUS_NULL_POINTER: The 'tag' argument is NULL
1482 * NOTMUCH_STATUS_TAG_TOO_LONG: The length of 'tag' is too long
1483 * (exceeds NOTMUCH_TAG_MAX)
1485 * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only
1486 * mode so message cannot be modified.
1489 notmuch_message_remove_tag (notmuch_message_t *message, const char *tag);
1492 * Remove all tags from the given message.
1494 * See notmuch_message_freeze for an example showing how to safely
1495 * replace tag values.
1497 * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only
1498 * mode so message cannot be modified.
1501 notmuch_message_remove_all_tags (notmuch_message_t *message);
1504 * Add/remove tags according to maildir flags in the message filename(s).
1506 * This function examines the filenames of 'message' for maildir
1507 * flags, and adds or removes tags on 'message' as follows when these
1508 * flags are present:
1510 * Flag Action if present
1511 * ---- -----------------
1512 * 'D' Adds the "draft" tag to the message
1513 * 'F' Adds the "flagged" tag to the message
1514 * 'P' Adds the "passed" tag to the message
1515 * 'R' Adds the "replied" tag to the message
1516 * 'S' Removes the "unread" tag from the message
1518 * For each flag that is not present, the opposite action (add/remove)
1519 * is performed for the corresponding tags.
1521 * Flags are identified as trailing components of the filename after a
1522 * sequence of ":2,".
1524 * If there are multiple filenames associated with this message, the
1525 * flag is considered present if it appears in one or more
1526 * filenames. (That is, the flags from the multiple filenames are
1527 * combined with the logical OR operator.)
1529 * A client can ensure that notmuch database tags remain synchronized
1530 * with maildir flags by calling this function after each call to
1531 * notmuch_database_add_message. See also
1532 * notmuch_message_tags_to_maildir_flags for synchronizing tag changes
1533 * back to maildir flags.
1536 notmuch_message_maildir_flags_to_tags (notmuch_message_t *message);
1539 * Rename message filename(s) to encode tags as maildir flags.
1541 * Specifically, for each filename corresponding to this message:
1543 * If the filename is not in a maildir directory, do nothing. (A
1544 * maildir directory is determined as a directory named "new" or
1545 * "cur".) Similarly, if the filename has invalid maildir info,
1546 * (repeated or outof-ASCII-order flag characters after ":2,"), then
1549 * If the filename is in a maildir directory, rename the file so that
1550 * its filename ends with the sequence ":2," followed by zero or more
1551 * of the following single-character flags (in ASCII order):
1553 * 'D' iff the message has the "draft" tag
1554 * 'F' iff the message has the "flagged" tag
1555 * 'P' iff the message has the "passed" tag
1556 * 'R' iff the message has the "replied" tag
1557 * 'S' iff the message does not have the "unread" tag
1559 * Any existing flags unmentioned in the list above will be preserved
1562 * Also, if this filename is in a directory named "new", rename it to
1563 * be within the neighboring directory named "cur".
1565 * A client can ensure that maildir filename flags remain synchronized
1566 * with notmuch database tags by calling this function after changing
1567 * tags, (after calls to notmuch_message_add_tag,
1568 * notmuch_message_remove_tag, or notmuch_message_freeze/
1569 * notmuch_message_thaw). See also notmuch_message_maildir_flags_to_tags
1570 * for synchronizing maildir flag changes back to tags.
1573 notmuch_message_tags_to_maildir_flags (notmuch_message_t *message);
1576 * Freeze the current state of 'message' within the database.
1578 * This means that changes to the message state, (via
1579 * notmuch_message_add_tag, notmuch_message_remove_tag, and
1580 * notmuch_message_remove_all_tags), will not be committed to the
1581 * database until the message is thawed with notmuch_message_thaw.
1583 * Multiple calls to freeze/thaw are valid and these calls will
1584 * "stack". That is there must be as many calls to thaw as to freeze
1585 * before a message is actually thawed.
1587 * The ability to do freeze/thaw allows for safe transactions to
1588 * change tag values. For example, explicitly setting a message to
1589 * have a given set of tags might look like this:
1591 * notmuch_message_freeze (message);
1593 * notmuch_message_remove_all_tags (message);
1595 * for (i = 0; i < NUM_TAGS; i++)
1596 * notmuch_message_add_tag (message, tags[i]);
1598 * notmuch_message_thaw (message);
1600 * With freeze/thaw used like this, the message in the database is
1601 * guaranteed to have either the full set of original tag values, or
1602 * the full set of new tag values, but nothing in between.
1604 * Imagine the example above without freeze/thaw and the operation
1605 * somehow getting interrupted. This could result in the message being
1606 * left with no tags if the interruption happened after
1607 * notmuch_message_remove_all_tags but before notmuch_message_add_tag.
1611 * NOTMUCH_STATUS_SUCCESS: Message successfully frozen.
1613 * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only
1614 * mode so message cannot be modified.
1617 notmuch_message_freeze (notmuch_message_t *message);
1620 * Thaw the current 'message', synchronizing any changes that may have
1621 * occurred while 'message' was frozen into the notmuch database.
1623 * See notmuch_message_freeze for an example of how to use this
1624 * function to safely provide tag changes.
1626 * Multiple calls to freeze/thaw are valid and these calls with
1627 * "stack". That is there must be as many calls to thaw as to freeze
1628 * before a message is actually thawed.
1632 * NOTMUCH_STATUS_SUCCESS: Message successfully thawed, (or at least
1633 * its frozen count has successfully been reduced by 1).
1635 * NOTMUCH_STATUS_UNBALANCED_FREEZE_THAW: An attempt was made to thaw
1636 * an unfrozen message. That is, there have been an unbalanced
1637 * number of calls to notmuch_message_freeze and
1638 * notmuch_message_thaw.
1641 notmuch_message_thaw (notmuch_message_t *message);
1644 * Destroy a notmuch_message_t object.
1646 * It can be useful to call this function in the case of a single
1647 * query object with many messages in the result, (such as iterating
1648 * over the entire database). Otherwise, it's fine to never call this
1649 * function and there will still be no memory leaks. (The memory from
1650 * the messages get reclaimed when the containing query is destroyed.)
1653 notmuch_message_destroy (notmuch_message_t *message);
1656 * Is the given 'tags' iterator pointing at a valid tag.
1658 * When this function returns TRUE, notmuch_tags_get will return a
1659 * valid string. Whereas when this function returns FALSE,
1660 * notmuch_tags_get will return NULL.
1662 * See the documentation of notmuch_message_get_tags for example code
1663 * showing how to iterate over a notmuch_tags_t object.
1666 notmuch_tags_valid (notmuch_tags_t *tags);
1669 * Get the current tag from 'tags' as a string.
1671 * Note: The returned string belongs to 'tags' and has a lifetime
1672 * identical to it (and the query to which it ultimately belongs).
1674 * See the documentation of notmuch_message_get_tags for example code
1675 * showing how to iterate over a notmuch_tags_t object.
1678 notmuch_tags_get (notmuch_tags_t *tags);
1681 * Move the 'tags' iterator to the next tag.
1683 * If 'tags' is already pointing at the last tag then the iterator
1684 * will be moved to a point just beyond that last tag, (where
1685 * notmuch_tags_valid will return FALSE and notmuch_tags_get will
1688 * See the documentation of notmuch_message_get_tags for example code
1689 * showing how to iterate over a notmuch_tags_t object.
1692 notmuch_tags_move_to_next (notmuch_tags_t *tags);
1695 * Destroy a notmuch_tags_t object.
1697 * It's not strictly necessary to call this function. All memory from
1698 * the notmuch_tags_t object will be reclaimed when the containing
1699 * message or query objects are destroyed.
1702 notmuch_tags_destroy (notmuch_tags_t *tags);
1705 * Store an mtime within the database for 'directory'.
1707 * The 'directory' should be an object retrieved from the database
1708 * with notmuch_database_get_directory for a particular path.
1710 * The intention is for the caller to use the mtime to allow efficient
1711 * identification of new messages to be added to the database. The
1712 * recommended usage is as follows:
1714 * o Read the mtime of a directory from the filesystem
1716 * o Call add_message for all mail files in the directory
1718 * o Call notmuch_directory_set_mtime with the mtime read from the
1721 * Then, when wanting to check for updates to the directory in the
1722 * future, the client can call notmuch_directory_get_mtime and know
1723 * that it only needs to add files if the mtime of the directory and
1724 * files are newer than the stored timestamp.
1726 * Note: The notmuch_directory_get_mtime function does not allow the
1727 * caller to distinguish a timestamp of 0 from a non-existent
1728 * timestamp. So don't store a timestamp of 0 unless you are
1729 * comfortable with that.
1733 * NOTMUCH_STATUS_SUCCESS: mtime successfully stored in database.
1735 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception
1736 * occurred, mtime not stored.
1738 * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only
1739 * mode so directory mtime cannot be modified.
1742 notmuch_directory_set_mtime (notmuch_directory_t *directory,
1746 * Get the mtime of a directory, (as previously stored with
1747 * notmuch_directory_set_mtime).
1749 * Returns 0 if no mtime has previously been stored for this
1753 notmuch_directory_get_mtime (notmuch_directory_t *directory);
1756 * Get a notmuch_filenames_t iterator listing all the filenames of
1757 * messages in the database within the given directory.
1759 * The returned filenames will be the basename-entries only (not
1762 notmuch_filenames_t *
1763 notmuch_directory_get_child_files (notmuch_directory_t *directory);
1766 * Get a notmuch_filenames_t iterator listing all the filenames of
1767 * sub-directories in the database within the given directory.
1769 * The returned filenames will be the basename-entries only (not
1772 notmuch_filenames_t *
1773 notmuch_directory_get_child_directories (notmuch_directory_t *directory);
1776 * Delete directory document from the database, and destroy the
1777 * notmuch_directory_t object. Assumes any child directories and files
1778 * have been deleted by the caller.
1780 * @since libnotmuch 4.3 (notmuch 0.21)
1783 notmuch_directory_delete (notmuch_directory_t *directory);
1786 * Destroy a notmuch_directory_t object.
1789 notmuch_directory_destroy (notmuch_directory_t *directory);
1792 * Is the given 'filenames' iterator pointing at a valid filename.
1794 * When this function returns TRUE, notmuch_filenames_get will return
1795 * a valid string. Whereas when this function returns FALSE,
1796 * notmuch_filenames_get will return NULL.
1798 * It is acceptable to pass NULL for 'filenames', in which case this
1799 * function will always return FALSE.
1802 notmuch_filenames_valid (notmuch_filenames_t *filenames);
1805 * Get the current filename from 'filenames' as a string.
1807 * Note: The returned string belongs to 'filenames' and has a lifetime
1808 * identical to it (and the directory to which it ultimately belongs).
1810 * It is acceptable to pass NULL for 'filenames', in which case this
1811 * function will always return NULL.
1814 notmuch_filenames_get (notmuch_filenames_t *filenames);
1817 * Move the 'filenames' iterator to the next filename.
1819 * If 'filenames' is already pointing at the last filename then the
1820 * iterator will be moved to a point just beyond that last filename,
1821 * (where notmuch_filenames_valid will return FALSE and
1822 * notmuch_filenames_get will return NULL).
1824 * It is acceptable to pass NULL for 'filenames', in which case this
1825 * function will do nothing.
1828 notmuch_filenames_move_to_next (notmuch_filenames_t *filenames);
1831 * Destroy a notmuch_filenames_t object.
1833 * It's not strictly necessary to call this function. All memory from
1834 * the notmuch_filenames_t object will be reclaimed when the
1835 * containing directory object is destroyed.
1837 * It is acceptable to pass NULL for 'filenames', in which case this
1838 * function will do nothing.
1841 notmuch_filenames_destroy (notmuch_filenames_t *filenames);