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.
336 * notmuch_database_close can be called multiple times. Later calls
339 * For writable databases, notmuch_database_close commits all changes
340 * to disk before closing the database. If the caller is currently in
341 * an atomic section (there was a notmuch_database_begin_atomic
342 * without a matching notmuch_database_end_atomic), this will discard
343 * changes made in that atomic section (but still commit changes made
344 * prior to entering the atomic section).
348 * NOTMUCH_STATUS_SUCCESS: Successfully closed the database.
350 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred; the
351 * database has been closed but there are no guarantees the
352 * changes to the database, if any, have been flushed to disk.
355 notmuch_database_close (notmuch_database_t *database);
358 * A callback invoked by notmuch_database_compact to notify the user
359 * of the progress of the compaction process.
361 typedef void (*notmuch_compact_status_cb_t)(const char *message, void *closure);
364 * Compact a notmuch database, backing up the original database to the
367 * The database will be opened with NOTMUCH_DATABASE_MODE_READ_WRITE
368 * during the compaction process to ensure no writes are made.
370 * If the optional callback function 'status_cb' is non-NULL, it will
371 * be called with diagnostic and informational messages. The argument
372 * 'closure' is passed verbatim to any callback invoked.
375 notmuch_database_compact (const char* path,
376 const char* backup_path,
377 notmuch_compact_status_cb_t status_cb,
381 * Destroy the notmuch database, closing it if necessary and freeing
382 * all associated resources.
384 * Return value as in notmuch_database_close if the database was open;
385 * notmuch_database_destroy itself has no failure modes.
388 notmuch_database_destroy (notmuch_database_t *database);
391 * Return the database path of the given database.
393 * The return value is a string owned by notmuch so should not be
394 * modified nor freed by the caller.
397 notmuch_database_get_path (notmuch_database_t *database);
400 * Return the database format version of the given database.
403 notmuch_database_get_version (notmuch_database_t *database);
406 * Can the database be upgraded to a newer database version?
408 * If this function returns TRUE, then the caller may call
409 * notmuch_database_upgrade to upgrade the database. If the caller
410 * does not upgrade an out-of-date database, then some functions may
411 * fail with NOTMUCH_STATUS_UPGRADE_REQUIRED. This always returns
412 * FALSE for a read-only database because there's no way to upgrade a
413 * read-only database.
416 notmuch_database_needs_upgrade (notmuch_database_t *database);
419 * Upgrade the current database to the latest supported version.
421 * This ensures that all current notmuch functionality will be
422 * available on the database. After opening a database in read-write
423 * mode, it is recommended that clients check if an upgrade is needed
424 * (notmuch_database_needs_upgrade) and if so, upgrade with this
425 * function before making any modifications. If
426 * notmuch_database_needs_upgrade returns FALSE, this will be a no-op.
428 * The optional progress_notify callback can be used by the caller to
429 * provide progress indication to the user. If non-NULL it will be
430 * called periodically with 'progress' as a floating-point value in
431 * the range of [0.0 .. 1.0] indicating the progress made so far in
432 * the upgrade process. The argument 'closure' is passed verbatim to
433 * any callback invoked.
436 notmuch_database_upgrade (notmuch_database_t *database,
437 void (*progress_notify) (void *closure,
442 * Begin an atomic database operation.
444 * Any modifications performed between a successful begin and a
445 * notmuch_database_end_atomic will be applied to the database
446 * atomically. Note that, unlike a typical database transaction, this
447 * only ensures atomicity, not durability; neither begin nor end
448 * necessarily flush modifications to disk.
450 * Atomic sections may be nested. begin_atomic and end_atomic must
451 * always be called in pairs.
455 * NOTMUCH_STATUS_SUCCESS: Successfully entered atomic section.
457 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred;
458 * atomic section not entered.
461 notmuch_database_begin_atomic (notmuch_database_t *notmuch);
464 * Indicate the end of an atomic database operation.
468 * NOTMUCH_STATUS_SUCCESS: Successfully completed atomic section.
470 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred;
471 * atomic section not ended.
473 * NOTMUCH_STATUS_UNBALANCED_ATOMIC: The database is not currently in
477 notmuch_database_end_atomic (notmuch_database_t *notmuch);
480 * Return the committed database revision and UUID.
482 * The database revision number increases monotonically with each
483 * commit to the database. Hence, all messages and message changes
484 * committed to the database (that is, visible to readers) have a last
485 * modification revision <= the committed database revision. Any
486 * messages committed in the future will be assigned a modification
487 * revision > the committed database revision.
489 * The UUID is a NUL-terminated opaque string that uniquely identifies
490 * this database. Two revision numbers are only comparable if they
491 * have the same database UUID.
494 notmuch_database_get_revision (notmuch_database_t *notmuch,
498 * Retrieve a directory object from the database for 'path'.
500 * Here, 'path' should be a path relative to the path of 'database'
501 * (see notmuch_database_get_path), or else should be an absolute path
502 * with initial components that match the path of 'database'.
504 * If this directory object does not exist in the database, this
505 * returns NOTMUCH_STATUS_SUCCESS and sets *directory to NULL.
507 * Otherwise the returned directory object is owned by the database
508 * and as such, will only be valid until notmuch_database_destroy is
513 * NOTMUCH_STATUS_SUCCESS: Successfully retrieved directory.
515 * NOTMUCH_STATUS_NULL_POINTER: The given 'directory' argument is NULL.
517 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred;
518 * directory not retrieved.
520 * NOTMUCH_STATUS_UPGRADE_REQUIRED: The caller must upgrade the
521 * database to use this function.
524 notmuch_database_get_directory (notmuch_database_t *database,
526 notmuch_directory_t **directory);
529 * Add a new message to the given notmuch database or associate an
530 * additional filename with an existing message.
532 * Here, 'filename' should be a path relative to the path of
533 * 'database' (see notmuch_database_get_path), or else should be an
534 * absolute filename with initial components that match the path of
537 * The file should be a single mail message (not a multi-message mbox)
538 * that is expected to remain at its current location, (since the
539 * notmuch database will reference the filename, and will not copy the
540 * entire contents of the file.
542 * If another message with the same message ID already exists in the
543 * database, rather than creating a new message, this adds 'filename'
544 * to the list of the filenames for the existing message.
546 * If 'message' is not NULL, then, on successful return
547 * (NOTMUCH_STATUS_SUCCESS or NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) '*message'
548 * will be initialized to a message object that can be used for things
549 * such as adding tags to the just-added message. The user should call
550 * notmuch_message_destroy when done with the message. On any failure
551 * '*message' will be set to NULL.
555 * NOTMUCH_STATUS_SUCCESS: Message successfully added to database.
557 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred,
560 * NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID: Message has the same message
561 * ID as another message already in the database. The new
562 * filename was successfully added to the message in the database
563 * (if not already present) and the existing message is returned.
565 * NOTMUCH_STATUS_FILE_ERROR: an error occurred trying to open the
566 * file, (such as permission denied, or file not found,
567 * etc.). Nothing added to the database.
569 * NOTMUCH_STATUS_FILE_NOT_EMAIL: the contents of filename don't look
570 * like an email message. Nothing added to the database.
572 * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only
573 * mode so no message can be added.
575 * NOTMUCH_STATUS_UPGRADE_REQUIRED: The caller must upgrade the
576 * database to use this function.
579 notmuch_database_add_message (notmuch_database_t *database,
580 const char *filename,
581 notmuch_message_t **message);
584 * Remove a message filename from the given notmuch database. If the
585 * message has no more filenames, remove the message.
587 * If the same message (as determined by the message ID) is still
588 * available via other filenames, then the message will persist in the
589 * database for those filenames. When the last filename is removed for
590 * a particular message, the database content for that message will be
595 * NOTMUCH_STATUS_SUCCESS: The last filename was removed and the
596 * message was removed from the database.
598 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred,
599 * message not removed.
601 * NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID: This filename was removed but
602 * the message persists in the database with at least one other
605 * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only
606 * mode so no message can be removed.
608 * NOTMUCH_STATUS_UPGRADE_REQUIRED: The caller must upgrade the
609 * database to use this function.
612 notmuch_database_remove_message (notmuch_database_t *database,
613 const char *filename);
616 * Find a message with the given message_id.
618 * If a message with the given message_id is found then, on successful return
619 * (NOTMUCH_STATUS_SUCCESS) '*message' will be initialized to a message
620 * object. The caller should call notmuch_message_destroy when done with the
623 * On any failure or when the message is not found, this function initializes
624 * '*message' to NULL. This means, when NOTMUCH_STATUS_SUCCESS is returned, the
625 * caller is supposed to check '*message' for NULL to find out whether the
626 * message with the given message_id was found.
630 * NOTMUCH_STATUS_SUCCESS: Successful return, check '*message'.
632 * NOTMUCH_STATUS_NULL_POINTER: The given 'message' argument is NULL
634 * NOTMUCH_STATUS_OUT_OF_MEMORY: Out of memory, creating message object
636 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred
639 notmuch_database_find_message (notmuch_database_t *database,
640 const char *message_id,
641 notmuch_message_t **message);
644 * Find a message with the given filename.
646 * If the database contains a message with the given filename then, on
647 * successful return (NOTMUCH_STATUS_SUCCESS) '*message' will be initialized to
648 * a message object. The caller should call notmuch_message_destroy when done
651 * On any failure or when the message is not found, this function initializes
652 * '*message' to NULL. This means, when NOTMUCH_STATUS_SUCCESS is returned, the
653 * caller is supposed to check '*message' for NULL to find out whether the
654 * message with the given filename is found.
658 * NOTMUCH_STATUS_SUCCESS: Successful return, check '*message'
660 * NOTMUCH_STATUS_NULL_POINTER: The given 'message' argument is NULL
662 * NOTMUCH_STATUS_OUT_OF_MEMORY: Out of memory, creating the message object
664 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred
666 * NOTMUCH_STATUS_UPGRADE_REQUIRED: The caller must upgrade the
667 * database to use this function.
670 notmuch_database_find_message_by_filename (notmuch_database_t *notmuch,
671 const char *filename,
672 notmuch_message_t **message);
675 * Return a list of all tags found in the database.
677 * This function creates a list of all tags found in the database. The
678 * resulting list contains all tags from all messages found in the database.
680 * On error this function returns NULL.
683 notmuch_database_get_all_tags (notmuch_database_t *db);
686 * Create a new query for 'database'.
688 * Here, 'database' should be an open database, (see
689 * notmuch_database_open and notmuch_database_create).
691 * For the query string, we'll document the syntax here more
692 * completely in the future, but it's likely to be a specialized
693 * version of the general Xapian query syntax:
695 * http://xapian.org/docs/queryparser.html
697 * As a special case, passing either a length-zero string, (that is ""),
698 * or a string consisting of a single asterisk (that is "*"), will
699 * result in a query that returns all messages in the database.
701 * See notmuch_query_set_sort for controlling the order of results.
702 * See notmuch_query_search_messages and notmuch_query_search_threads
703 * to actually execute the query.
705 * User should call notmuch_query_destroy when finished with this
708 * Will return NULL if insufficient memory is available.
711 notmuch_query_create (notmuch_database_t *database,
712 const char *query_string);
715 * Sort values for notmuch_query_set_sort.
721 NOTMUCH_SORT_OLDEST_FIRST,
725 NOTMUCH_SORT_NEWEST_FIRST,
727 * Sort by message-id.
729 NOTMUCH_SORT_MESSAGE_ID,
733 NOTMUCH_SORT_UNSORTED
737 * Return the query_string of this query. See notmuch_query_create.
740 notmuch_query_get_query_string (const notmuch_query_t *query);
743 * Return the notmuch database of this query. See notmuch_query_create.
746 notmuch_query_get_database (const notmuch_query_t *query);
749 * Exclude values for notmuch_query_set_omit_excluded. The strange
750 * order is to maintain backward compatibility: the old FALSE/TRUE
751 * options correspond to the new
752 * NOTMUCH_EXCLUDE_FLAG/NOTMUCH_EXCLUDE_TRUE options.
755 NOTMUCH_EXCLUDE_FLAG,
756 NOTMUCH_EXCLUDE_TRUE,
757 NOTMUCH_EXCLUDE_FALSE,
762 * Specify whether to omit excluded results or simply flag them. By
763 * default, this is set to TRUE.
765 * If set to TRUE or ALL, notmuch_query_search_messages will omit excluded
766 * messages from the results, and notmuch_query_search_threads will omit
767 * threads that match only in excluded messages. If set to TRUE,
768 * notmuch_query_search_threads will include all messages in threads that
769 * match in at least one non-excluded message. Otherwise, if set to ALL,
770 * notmuch_query_search_threads will omit excluded messages from all threads.
772 * If set to FALSE or FLAG then both notmuch_query_search_messages and
773 * notmuch_query_search_threads will return all matching
774 * messages/threads regardless of exclude status. If set to FLAG then
775 * the exclude flag will be set for any excluded message that is
776 * returned by notmuch_query_search_messages, and the thread counts
777 * for threads returned by notmuch_query_search_threads will be the
778 * number of non-excluded messages/matches. Otherwise, if set to
779 * FALSE, then the exclude status is completely ignored.
781 * The performance difference when calling
782 * notmuch_query_search_messages should be relatively small (and both
783 * should be very fast). However, in some cases,
784 * notmuch_query_search_threads is very much faster when omitting
785 * excluded messages as it does not need to construct the threads that
786 * only match in excluded messages.
789 notmuch_query_set_omit_excluded (notmuch_query_t *query,
790 notmuch_exclude_t omit_excluded);
793 * Specify the sorting desired for this query.
796 notmuch_query_set_sort (notmuch_query_t *query, notmuch_sort_t sort);
799 * Return the sort specified for this query. See
800 * notmuch_query_set_sort.
803 notmuch_query_get_sort (const notmuch_query_t *query);
806 * Add a tag that will be excluded from the query results by default.
807 * This exclusion will be overridden if this tag appears explicitly in
811 notmuch_query_add_tag_exclude (notmuch_query_t *query, const char *tag);
814 * Execute a query for threads, returning a notmuch_threads_t object
815 * which can be used to iterate over the results. The returned threads
816 * object is owned by the query and as such, will only be valid until
817 * notmuch_query_destroy.
819 * Typical usage might be:
821 * notmuch_query_t *query;
822 * notmuch_threads_t *threads;
823 * notmuch_thread_t *thread;
825 * query = notmuch_query_create (database, query_string);
827 * for (threads = notmuch_query_search_threads (query);
828 * notmuch_threads_valid (threads);
829 * notmuch_threads_move_to_next (threads))
831 * thread = notmuch_threads_get (threads);
833 * notmuch_thread_destroy (thread);
836 * notmuch_query_destroy (query);
838 * Note: If you are finished with a thread before its containing
839 * query, you can call notmuch_thread_destroy to clean up some memory
840 * sooner (as in the above example). Otherwise, if your thread objects
841 * are long-lived, then you don't need to call notmuch_thread_destroy
842 * and all the memory will still be reclaimed when the query is
845 * Note that there's no explicit destructor needed for the
846 * notmuch_threads_t object. (For consistency, we do provide a
847 * notmuch_threads_destroy function, but there's no good reason
848 * to call it if the query is about to be destroyed).
850 * @since libnotmuch 4.2 (notmuch 0.20)
853 notmuch_query_search_threads_st (notmuch_query_t *query,
854 notmuch_threads_t **out);
857 * Like notmuch_query_search_threads_st, but without a status return.
859 * If a Xapian exception occurs this function will return NULL.
861 * @deprecated Deprecated as of libnotmuch 4.3 (notmuch 0.21). Please
862 * use notmuch_query_search_threads_st instead.
865 NOTMUCH_DEPRECATED(4,3)
867 notmuch_query_search_threads (notmuch_query_t *query);
870 * Execute a query for messages, returning a notmuch_messages_t object
871 * which can be used to iterate over the results. The returned
872 * messages object is owned by the query and as such, will only be
873 * valid until notmuch_query_destroy.
875 * Typical usage might be:
877 * notmuch_query_t *query;
878 * notmuch_messages_t *messages;
879 * notmuch_message_t *message;
881 * query = notmuch_query_create (database, query_string);
883 * for (messages = notmuch_query_search_messages (query);
884 * notmuch_messages_valid (messages);
885 * notmuch_messages_move_to_next (messages))
887 * message = notmuch_messages_get (messages);
889 * notmuch_message_destroy (message);
892 * notmuch_query_destroy (query);
894 * Note: If you are finished with a message before its containing
895 * query, you can call notmuch_message_destroy to clean up some memory
896 * sooner (as in the above example). Otherwise, if your message
897 * objects are long-lived, then you don't need to call
898 * notmuch_message_destroy and all the memory will still be reclaimed
899 * when the query is destroyed.
901 * Note that there's no explicit destructor needed for the
902 * notmuch_messages_t object. (For consistency, we do provide a
903 * notmuch_messages_destroy function, but there's no good
904 * reason to call it if the query is about to be destroyed).
906 * If a Xapian exception occurs this function will return NULL.
908 * @since libnotmuch 4.2 (notmuch 0.20)
911 notmuch_query_search_messages_st (notmuch_query_t *query,
912 notmuch_messages_t **out);
914 * Like notmuch_query_search_messages, but without a status return.
916 * If a Xapian exception occurs this function will return NULL.
918 * @deprecated Deprecated as of libnotmuch 4.3 (notmuch 0.21). Please use
919 * notmuch_query_search_messages_st instead.
922 NOTMUCH_DEPRECATED(4,3)
924 notmuch_query_search_messages (notmuch_query_t *query);
927 * Destroy a notmuch_query_t along with any associated resources.
929 * This will in turn destroy any notmuch_threads_t and
930 * notmuch_messages_t objects generated by this query, (and in
931 * turn any notmuch_thread_t and notmuch_message_t objects generated
932 * from those results, etc.), if such objects haven't already been
936 notmuch_query_destroy (notmuch_query_t *query);
939 * Is the given 'threads' iterator pointing at a valid thread.
941 * When this function returns TRUE, notmuch_threads_get will return a
942 * valid object. Whereas when this function returns FALSE,
943 * notmuch_threads_get will return NULL.
945 * If passed a NULL pointer, this function returns FALSE
947 * See the documentation of notmuch_query_search_threads for example
948 * code showing how to iterate over a notmuch_threads_t object.
951 notmuch_threads_valid (notmuch_threads_t *threads);
954 * Get the current thread from 'threads' as a notmuch_thread_t.
956 * Note: The returned thread belongs to 'threads' and has a lifetime
957 * identical to it (and the query to which it belongs).
959 * See the documentation of notmuch_query_search_threads for example
960 * code showing how to iterate over a notmuch_threads_t object.
962 * If an out-of-memory situation occurs, this function will return
966 notmuch_threads_get (notmuch_threads_t *threads);
969 * Move the 'threads' iterator to the next thread.
971 * If 'threads' is already pointing at the last thread then the
972 * iterator will be moved to a point just beyond that last thread,
973 * (where notmuch_threads_valid will return FALSE and
974 * notmuch_threads_get will return NULL).
976 * See the documentation of notmuch_query_search_threads for example
977 * code showing how to iterate over a notmuch_threads_t object.
980 notmuch_threads_move_to_next (notmuch_threads_t *threads);
983 * Destroy a notmuch_threads_t object.
985 * It's not strictly necessary to call this function. All memory from
986 * the notmuch_threads_t object will be reclaimed when the
987 * containing query object is destroyed.
990 notmuch_threads_destroy (notmuch_threads_t *threads);
993 * Return the number of messages matching a search.
995 * This function performs a search and returns the number of matching
1000 * NOTMUCH_STATUS_SUCCESS: query completed successfully.
1002 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: a Xapian exception occured. The
1003 * value of *count is not defined.
1005 * @since libnotmuch 4.3 (notmuch 0.21)
1008 notmuch_query_count_messages_st (notmuch_query_t *query, unsigned int *count);
1011 * like notmuch_query_count_messages_st, but without a status return.
1013 * May return 0 in the case of errors.
1015 * @deprecated Deprecated since libnotmuch 4.3 (notmuch 0.21). Please
1016 * use notmuch_query_count_messages_st instead.
1018 NOTMUCH_DEPRECATED(4,3)
1020 notmuch_query_count_messages (notmuch_query_t *query);
1023 * Return the number of threads matching a search.
1025 * This function performs a search and returns the number of unique thread IDs
1026 * in the matching messages. This is the same as number of threads matching a
1029 * Note that this is a significantly heavier operation than
1030 * notmuch_query_count_messages{_st}().
1034 * NOTMUCH_STATUS_OUT_OF_MEMORY: Memory allocation failed. The value
1035 * of *count is not defined
1037 * NOTMUCH_STATUS_SUCCESS: query completed successfully.
1039 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: a Xapian exception occured. The
1040 * value of *count is not defined.
1042 * @since libnotmuch 4.3 (notmuch 0.21)
1045 notmuch_query_count_threads_st (notmuch_query_t *query, unsigned *count);
1048 * like notmuch_query_count_threads, but without a status return.
1050 * May return 0 in case of errors.
1052 * @deprecated Deprecated as of libnotmuch 4.3 (notmuch 0.21). Please
1053 * use notmuch_query_count_threads_st instead.
1055 NOTMUCH_DEPRECATED(4,3)
1057 notmuch_query_count_threads (notmuch_query_t *query);
1060 * Get the thread ID of 'thread'.
1062 * The returned string belongs to 'thread' and as such, should not be
1063 * modified by the caller and will only be valid for as long as the
1064 * thread is valid, (which is until notmuch_thread_destroy or until
1065 * the query from which it derived is destroyed).
1068 notmuch_thread_get_thread_id (notmuch_thread_t *thread);
1071 * Get the total number of messages in 'thread'.
1073 * This count consists of all messages in the database belonging to
1074 * this thread. Contrast with notmuch_thread_get_matched_messages() .
1077 notmuch_thread_get_total_messages (notmuch_thread_t *thread);
1080 * Get a notmuch_messages_t iterator for the top-level messages in
1081 * 'thread' in oldest-first order.
1083 * This iterator will not necessarily iterate over all of the messages
1084 * in the thread. It will only iterate over the messages in the thread
1085 * which are not replies to other messages in the thread.
1087 * The returned list will be destroyed when the thread is destroyed.
1089 notmuch_messages_t *
1090 notmuch_thread_get_toplevel_messages (notmuch_thread_t *thread);
1093 * Get a notmuch_thread_t iterator for all messages in 'thread' in
1094 * oldest-first order.
1096 * The returned list will be destroyed when the thread is destroyed.
1098 notmuch_messages_t *
1099 notmuch_thread_get_messages (notmuch_thread_t *thread);
1102 * Get the number of messages in 'thread' that matched the search.
1104 * This count includes only the messages in this thread that were
1105 * matched by the search from which the thread was created and were
1106 * not excluded by any exclude tags passed in with the query (see
1107 * notmuch_query_add_tag_exclude). Contrast with
1108 * notmuch_thread_get_total_messages() .
1111 notmuch_thread_get_matched_messages (notmuch_thread_t *thread);
1114 * Get the authors of 'thread' as a UTF-8 string.
1116 * The returned string is a comma-separated list of the names of the
1117 * authors of mail messages in the query results that belong to this
1120 * The string contains authors of messages matching the query first, then
1121 * non-matched authors (with the two groups separated by '|'). Within
1122 * each group, authors are ordered by date.
1124 * The returned string belongs to 'thread' and as such, should not be
1125 * modified by the caller and will only be valid for as long as the
1126 * thread is valid, (which is until notmuch_thread_destroy or until
1127 * the query from which it derived is destroyed).
1130 notmuch_thread_get_authors (notmuch_thread_t *thread);
1133 * Get the subject of 'thread' as a UTF-8 string.
1135 * The subject is taken from the first message (according to the query
1136 * order---see notmuch_query_set_sort) in the query results that
1137 * belongs to this thread.
1139 * The returned string belongs to 'thread' and as such, should not be
1140 * modified by the caller and will only be valid for as long as the
1141 * thread is valid, (which is until notmuch_thread_destroy or until
1142 * the query from which it derived is destroyed).
1145 notmuch_thread_get_subject (notmuch_thread_t *thread);
1148 * Get the date of the oldest message in 'thread' as a time_t value.
1151 notmuch_thread_get_oldest_date (notmuch_thread_t *thread);
1154 * Get the date of the newest message in 'thread' as a time_t value.
1157 notmuch_thread_get_newest_date (notmuch_thread_t *thread);
1160 * Get the tags for 'thread', returning a notmuch_tags_t object which
1161 * can be used to iterate over all tags.
1163 * Note: In the Notmuch database, tags are stored on individual
1164 * messages, not on threads. So the tags returned here will be all
1165 * tags of the messages which matched the search and which belong to
1168 * The tags object is owned by the thread and as such, will only be
1169 * valid for as long as the thread is valid, (for example, until
1170 * notmuch_thread_destroy or until the query from which it derived is
1173 * Typical usage might be:
1175 * notmuch_thread_t *thread;
1176 * notmuch_tags_t *tags;
1179 * thread = notmuch_threads_get (threads);
1181 * for (tags = notmuch_thread_get_tags (thread);
1182 * notmuch_tags_valid (tags);
1183 * notmuch_tags_move_to_next (tags))
1185 * tag = notmuch_tags_get (tags);
1189 * notmuch_thread_destroy (thread);
1191 * Note that there's no explicit destructor needed for the
1192 * notmuch_tags_t object. (For consistency, we do provide a
1193 * notmuch_tags_destroy function, but there's no good reason to call
1194 * it if the message is about to be destroyed).
1197 notmuch_thread_get_tags (notmuch_thread_t *thread);
1200 * Destroy a notmuch_thread_t object.
1203 notmuch_thread_destroy (notmuch_thread_t *thread);
1206 * Is the given 'messages' iterator pointing at a valid message.
1208 * When this function returns TRUE, notmuch_messages_get will return a
1209 * valid object. Whereas when this function returns FALSE,
1210 * notmuch_messages_get will return NULL.
1212 * See the documentation of notmuch_query_search_messages for example
1213 * code showing how to iterate over a notmuch_messages_t object.
1216 notmuch_messages_valid (notmuch_messages_t *messages);
1219 * Get the current message from 'messages' as a notmuch_message_t.
1221 * Note: The returned message belongs to 'messages' and has a lifetime
1222 * identical to it (and the query to which it belongs).
1224 * See the documentation of notmuch_query_search_messages for example
1225 * code showing how to iterate over a notmuch_messages_t object.
1227 * If an out-of-memory situation occurs, this function will return
1231 notmuch_messages_get (notmuch_messages_t *messages);
1234 * Move the 'messages' iterator to the next message.
1236 * If 'messages' is already pointing at the last message then the
1237 * iterator will be moved to a point just beyond that last message,
1238 * (where notmuch_messages_valid will return FALSE and
1239 * notmuch_messages_get will return NULL).
1241 * See the documentation of notmuch_query_search_messages for example
1242 * code showing how to iterate over a notmuch_messages_t object.
1245 notmuch_messages_move_to_next (notmuch_messages_t *messages);
1248 * Destroy a notmuch_messages_t object.
1250 * It's not strictly necessary to call this function. All memory from
1251 * the notmuch_messages_t object will be reclaimed when the containing
1252 * query object is destroyed.
1255 notmuch_messages_destroy (notmuch_messages_t *messages);
1258 * Return a list of tags from all messages.
1260 * The resulting list is guaranteed not to contain duplicated tags.
1262 * WARNING: You can no longer iterate over messages after calling this
1263 * function, because the iterator will point at the end of the list.
1264 * We do not have a function to reset the iterator yet and the only
1265 * way how you can iterate over the list again is to recreate the
1268 * The function returns NULL on error.
1271 notmuch_messages_collect_tags (notmuch_messages_t *messages);
1274 * Get the message ID of 'message'.
1276 * The returned string belongs to 'message' and as such, should not be
1277 * modified by the caller and will only be valid for as long as the
1278 * message is valid, (which is until the query from which it derived
1281 * This function will not return NULL since Notmuch ensures that every
1282 * message has a unique message ID, (Notmuch will generate an ID for a
1283 * message if the original file does not contain one).
1286 notmuch_message_get_message_id (notmuch_message_t *message);
1289 * Get the thread ID of 'message'.
1291 * The returned string belongs to 'message' and as such, should not be
1292 * modified by the caller and will only be valid for as long as the
1293 * message is valid, (for example, until the user calls
1294 * notmuch_message_destroy on 'message' or until a query from which it
1295 * derived is destroyed).
1297 * This function will not return NULL since Notmuch ensures that every
1298 * message belongs to a single thread.
1301 notmuch_message_get_thread_id (notmuch_message_t *message);
1304 * Get a notmuch_messages_t iterator for all of the replies to
1307 * Note: This call only makes sense if 'message' was ultimately
1308 * obtained from a notmuch_thread_t object, (such as by coming
1309 * directly from the result of calling notmuch_thread_get_
1310 * toplevel_messages or by any number of subsequent
1311 * calls to notmuch_message_get_replies).
1313 * If 'message' was obtained through some non-thread means, (such as
1314 * by a call to notmuch_query_search_messages), then this function
1317 * If there are no replies to 'message', this function will return
1318 * NULL. (Note that notmuch_messages_valid will accept that NULL
1319 * value as legitimate, and simply return FALSE for it.)
1321 notmuch_messages_t *
1322 notmuch_message_get_replies (notmuch_message_t *message);
1325 * Get a filename for the email corresponding to 'message'.
1327 * The returned filename is an absolute filename, (the initial
1328 * component will match notmuch_database_get_path() ).
1330 * The returned string belongs to the message so should not be
1331 * modified or freed by the caller (nor should it be referenced after
1332 * the message is destroyed).
1334 * Note: If this message corresponds to multiple files in the mail
1335 * store, (that is, multiple files contain identical message IDs),
1336 * this function will arbitrarily return a single one of those
1337 * filenames. See notmuch_message_get_filenames for returning the
1338 * complete list of filenames.
1341 notmuch_message_get_filename (notmuch_message_t *message);
1344 * Get all filenames for the email corresponding to 'message'.
1346 * Returns a notmuch_filenames_t iterator listing all the filenames
1347 * associated with 'message'. These files may not have identical
1348 * content, but each will have the identical Message-ID.
1350 * Each filename in the iterator is an absolute filename, (the initial
1351 * component will match notmuch_database_get_path() ).
1353 notmuch_filenames_t *
1354 notmuch_message_get_filenames (notmuch_message_t *message);
1359 typedef enum _notmuch_message_flag {
1360 NOTMUCH_MESSAGE_FLAG_MATCH,
1361 NOTMUCH_MESSAGE_FLAG_EXCLUDED,
1363 /* This message is a "ghost message", meaning it has no filenames
1364 * or content, but we know it exists because it was referenced by
1365 * some other message. A ghost message has only a message ID and
1368 NOTMUCH_MESSAGE_FLAG_GHOST,
1369 } notmuch_message_flag_t;
1372 * Get a value of a flag for the email corresponding to 'message'.
1375 notmuch_message_get_flag (notmuch_message_t *message,
1376 notmuch_message_flag_t flag);
1379 * Set a value of a flag for the email corresponding to 'message'.
1382 notmuch_message_set_flag (notmuch_message_t *message,
1383 notmuch_message_flag_t flag, notmuch_bool_t value);
1386 * Get the date of 'message' as a time_t value.
1388 * For the original textual representation of the Date header from the
1389 * message call notmuch_message_get_header() with a header value of
1393 notmuch_message_get_date (notmuch_message_t *message);
1396 * Get the value of the specified header from 'message' as a UTF-8 string.
1398 * Common headers are stored in the database when the message is
1399 * indexed and will be returned from the database. Other headers will
1400 * be read from the actual message file.
1402 * The header name is case insensitive.
1404 * The returned string belongs to the message so should not be
1405 * modified or freed by the caller (nor should it be referenced after
1406 * the message is destroyed).
1408 * Returns an empty string ("") if the message does not contain a
1409 * header line matching 'header'. Returns NULL if any error occurs.
1412 notmuch_message_get_header (notmuch_message_t *message, const char *header);
1415 * Get the tags for 'message', returning a notmuch_tags_t object which
1416 * can be used to iterate over all tags.
1418 * The tags object is owned by the message and as such, will only be
1419 * valid for as long as the message is valid, (which is until the
1420 * query from which it derived is destroyed).
1422 * Typical usage might be:
1424 * notmuch_message_t *message;
1425 * notmuch_tags_t *tags;
1428 * message = notmuch_database_find_message (database, message_id);
1430 * for (tags = notmuch_message_get_tags (message);
1431 * notmuch_tags_valid (tags);
1432 * notmuch_tags_move_to_next (tags))
1434 * tag = notmuch_tags_get (tags);
1438 * notmuch_message_destroy (message);
1440 * Note that there's no explicit destructor needed for the
1441 * notmuch_tags_t object. (For consistency, we do provide a
1442 * notmuch_tags_destroy function, but there's no good reason to call
1443 * it if the message is about to be destroyed).
1446 notmuch_message_get_tags (notmuch_message_t *message);
1449 * The longest possible tag value.
1451 #define NOTMUCH_TAG_MAX 200
1454 * Add a tag to the given message.
1458 * NOTMUCH_STATUS_SUCCESS: Tag successfully added to message
1460 * NOTMUCH_STATUS_NULL_POINTER: The 'tag' argument is NULL
1462 * NOTMUCH_STATUS_TAG_TOO_LONG: The length of 'tag' is too long
1463 * (exceeds NOTMUCH_TAG_MAX)
1465 * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only
1466 * mode so message cannot be modified.
1469 notmuch_message_add_tag (notmuch_message_t *message, const char *tag);
1472 * Remove a tag from the given message.
1476 * NOTMUCH_STATUS_SUCCESS: Tag successfully removed from message
1478 * NOTMUCH_STATUS_NULL_POINTER: The 'tag' argument is NULL
1480 * NOTMUCH_STATUS_TAG_TOO_LONG: The length of 'tag' is too long
1481 * (exceeds NOTMUCH_TAG_MAX)
1483 * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only
1484 * mode so message cannot be modified.
1487 notmuch_message_remove_tag (notmuch_message_t *message, const char *tag);
1490 * Remove all tags from the given message.
1492 * See notmuch_message_freeze for an example showing how to safely
1493 * replace tag values.
1495 * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only
1496 * mode so message cannot be modified.
1499 notmuch_message_remove_all_tags (notmuch_message_t *message);
1502 * Add/remove tags according to maildir flags in the message filename(s).
1504 * This function examines the filenames of 'message' for maildir
1505 * flags, and adds or removes tags on 'message' as follows when these
1506 * flags are present:
1508 * Flag Action if present
1509 * ---- -----------------
1510 * 'D' Adds the "draft" tag to the message
1511 * 'F' Adds the "flagged" tag to the message
1512 * 'P' Adds the "passed" tag to the message
1513 * 'R' Adds the "replied" tag to the message
1514 * 'S' Removes the "unread" tag from the message
1516 * For each flag that is not present, the opposite action (add/remove)
1517 * is performed for the corresponding tags.
1519 * Flags are identified as trailing components of the filename after a
1520 * sequence of ":2,".
1522 * If there are multiple filenames associated with this message, the
1523 * flag is considered present if it appears in one or more
1524 * filenames. (That is, the flags from the multiple filenames are
1525 * combined with the logical OR operator.)
1527 * A client can ensure that notmuch database tags remain synchronized
1528 * with maildir flags by calling this function after each call to
1529 * notmuch_database_add_message. See also
1530 * notmuch_message_tags_to_maildir_flags for synchronizing tag changes
1531 * back to maildir flags.
1534 notmuch_message_maildir_flags_to_tags (notmuch_message_t *message);
1537 * Rename message filename(s) to encode tags as maildir flags.
1539 * Specifically, for each filename corresponding to this message:
1541 * If the filename is not in a maildir directory, do nothing. (A
1542 * maildir directory is determined as a directory named "new" or
1543 * "cur".) Similarly, if the filename has invalid maildir info,
1544 * (repeated or outof-ASCII-order flag characters after ":2,"), then
1547 * If the filename is in a maildir directory, rename the file so that
1548 * its filename ends with the sequence ":2," followed by zero or more
1549 * of the following single-character flags (in ASCII order):
1551 * 'D' iff the message has the "draft" tag
1552 * 'F' iff the message has the "flagged" tag
1553 * 'P' iff the message has the "passed" tag
1554 * 'R' iff the message has the "replied" tag
1555 * 'S' iff the message does not have the "unread" tag
1557 * Any existing flags unmentioned in the list above will be preserved
1560 * Also, if this filename is in a directory named "new", rename it to
1561 * be within the neighboring directory named "cur".
1563 * A client can ensure that maildir filename flags remain synchronized
1564 * with notmuch database tags by calling this function after changing
1565 * tags, (after calls to notmuch_message_add_tag,
1566 * notmuch_message_remove_tag, or notmuch_message_freeze/
1567 * notmuch_message_thaw). See also notmuch_message_maildir_flags_to_tags
1568 * for synchronizing maildir flag changes back to tags.
1571 notmuch_message_tags_to_maildir_flags (notmuch_message_t *message);
1574 * Freeze the current state of 'message' within the database.
1576 * This means that changes to the message state, (via
1577 * notmuch_message_add_tag, notmuch_message_remove_tag, and
1578 * notmuch_message_remove_all_tags), will not be committed to the
1579 * database until the message is thawed with notmuch_message_thaw.
1581 * Multiple calls to freeze/thaw are valid and these calls will
1582 * "stack". That is there must be as many calls to thaw as to freeze
1583 * before a message is actually thawed.
1585 * The ability to do freeze/thaw allows for safe transactions to
1586 * change tag values. For example, explicitly setting a message to
1587 * have a given set of tags might look like this:
1589 * notmuch_message_freeze (message);
1591 * notmuch_message_remove_all_tags (message);
1593 * for (i = 0; i < NUM_TAGS; i++)
1594 * notmuch_message_add_tag (message, tags[i]);
1596 * notmuch_message_thaw (message);
1598 * With freeze/thaw used like this, the message in the database is
1599 * guaranteed to have either the full set of original tag values, or
1600 * the full set of new tag values, but nothing in between.
1602 * Imagine the example above without freeze/thaw and the operation
1603 * somehow getting interrupted. This could result in the message being
1604 * left with no tags if the interruption happened after
1605 * notmuch_message_remove_all_tags but before notmuch_message_add_tag.
1609 * NOTMUCH_STATUS_SUCCESS: Message successfully frozen.
1611 * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only
1612 * mode so message cannot be modified.
1615 notmuch_message_freeze (notmuch_message_t *message);
1618 * Thaw the current 'message', synchronizing any changes that may have
1619 * occurred while 'message' was frozen into the notmuch database.
1621 * See notmuch_message_freeze for an example of how to use this
1622 * function to safely provide tag changes.
1624 * Multiple calls to freeze/thaw are valid and these calls with
1625 * "stack". That is there must be as many calls to thaw as to freeze
1626 * before a message is actually thawed.
1630 * NOTMUCH_STATUS_SUCCESS: Message successfully thawed, (or at least
1631 * its frozen count has successfully been reduced by 1).
1633 * NOTMUCH_STATUS_UNBALANCED_FREEZE_THAW: An attempt was made to thaw
1634 * an unfrozen message. That is, there have been an unbalanced
1635 * number of calls to notmuch_message_freeze and
1636 * notmuch_message_thaw.
1639 notmuch_message_thaw (notmuch_message_t *message);
1642 * Destroy a notmuch_message_t object.
1644 * It can be useful to call this function in the case of a single
1645 * query object with many messages in the result, (such as iterating
1646 * over the entire database). Otherwise, it's fine to never call this
1647 * function and there will still be no memory leaks. (The memory from
1648 * the messages get reclaimed when the containing query is destroyed.)
1651 notmuch_message_destroy (notmuch_message_t *message);
1654 * Is the given 'tags' iterator pointing at a valid tag.
1656 * When this function returns TRUE, notmuch_tags_get will return a
1657 * valid string. Whereas when this function returns FALSE,
1658 * notmuch_tags_get will return NULL.
1660 * See the documentation of notmuch_message_get_tags for example code
1661 * showing how to iterate over a notmuch_tags_t object.
1664 notmuch_tags_valid (notmuch_tags_t *tags);
1667 * Get the current tag from 'tags' as a string.
1669 * Note: The returned string belongs to 'tags' and has a lifetime
1670 * identical to it (and the query to which it ultimately belongs).
1672 * See the documentation of notmuch_message_get_tags for example code
1673 * showing how to iterate over a notmuch_tags_t object.
1676 notmuch_tags_get (notmuch_tags_t *tags);
1679 * Move the 'tags' iterator to the next tag.
1681 * If 'tags' is already pointing at the last tag then the iterator
1682 * will be moved to a point just beyond that last tag, (where
1683 * notmuch_tags_valid will return FALSE and notmuch_tags_get will
1686 * See the documentation of notmuch_message_get_tags for example code
1687 * showing how to iterate over a notmuch_tags_t object.
1690 notmuch_tags_move_to_next (notmuch_tags_t *tags);
1693 * Destroy a notmuch_tags_t object.
1695 * It's not strictly necessary to call this function. All memory from
1696 * the notmuch_tags_t object will be reclaimed when the containing
1697 * message or query objects are destroyed.
1700 notmuch_tags_destroy (notmuch_tags_t *tags);
1703 * Store an mtime within the database for 'directory'.
1705 * The 'directory' should be an object retrieved from the database
1706 * with notmuch_database_get_directory for a particular path.
1708 * The intention is for the caller to use the mtime to allow efficient
1709 * identification of new messages to be added to the database. The
1710 * recommended usage is as follows:
1712 * o Read the mtime of a directory from the filesystem
1714 * o Call add_message for all mail files in the directory
1716 * o Call notmuch_directory_set_mtime with the mtime read from the
1719 * Then, when wanting to check for updates to the directory in the
1720 * future, the client can call notmuch_directory_get_mtime and know
1721 * that it only needs to add files if the mtime of the directory and
1722 * files are newer than the stored timestamp.
1724 * Note: The notmuch_directory_get_mtime function does not allow the
1725 * caller to distinguish a timestamp of 0 from a non-existent
1726 * timestamp. So don't store a timestamp of 0 unless you are
1727 * comfortable with that.
1731 * NOTMUCH_STATUS_SUCCESS: mtime successfully stored in database.
1733 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception
1734 * occurred, mtime not stored.
1736 * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only
1737 * mode so directory mtime cannot be modified.
1740 notmuch_directory_set_mtime (notmuch_directory_t *directory,
1744 * Get the mtime of a directory, (as previously stored with
1745 * notmuch_directory_set_mtime).
1747 * Returns 0 if no mtime has previously been stored for this
1751 notmuch_directory_get_mtime (notmuch_directory_t *directory);
1754 * Get a notmuch_filenames_t iterator listing all the filenames of
1755 * messages in the database within the given directory.
1757 * The returned filenames will be the basename-entries only (not
1760 notmuch_filenames_t *
1761 notmuch_directory_get_child_files (notmuch_directory_t *directory);
1764 * Get a notmuch_filenames_t iterator listing all the filenames of
1765 * sub-directories in the database within the given directory.
1767 * The returned filenames will be the basename-entries only (not
1770 notmuch_filenames_t *
1771 notmuch_directory_get_child_directories (notmuch_directory_t *directory);
1774 * Delete directory document from the database, and destroy the
1775 * notmuch_directory_t object. Assumes any child directories and files
1776 * have been deleted by the caller.
1778 * @since libnotmuch 4.3 (notmuch 0.21)
1781 notmuch_directory_delete (notmuch_directory_t *directory);
1784 * Destroy a notmuch_directory_t object.
1787 notmuch_directory_destroy (notmuch_directory_t *directory);
1790 * Is the given 'filenames' iterator pointing at a valid filename.
1792 * When this function returns TRUE, notmuch_filenames_get will return
1793 * a valid string. Whereas when this function returns FALSE,
1794 * notmuch_filenames_get will return NULL.
1796 * It is acceptable to pass NULL for 'filenames', in which case this
1797 * function will always return FALSE.
1800 notmuch_filenames_valid (notmuch_filenames_t *filenames);
1803 * Get the current filename from 'filenames' as a string.
1805 * Note: The returned string belongs to 'filenames' and has a lifetime
1806 * identical to it (and the directory to which it ultimately belongs).
1808 * It is acceptable to pass NULL for 'filenames', in which case this
1809 * function will always return NULL.
1812 notmuch_filenames_get (notmuch_filenames_t *filenames);
1815 * Move the 'filenames' iterator to the next filename.
1817 * If 'filenames' is already pointing at the last filename then the
1818 * iterator will be moved to a point just beyond that last filename,
1819 * (where notmuch_filenames_valid will return FALSE and
1820 * notmuch_filenames_get will return NULL).
1822 * It is acceptable to pass NULL for 'filenames', in which case this
1823 * function will do nothing.
1826 notmuch_filenames_move_to_next (notmuch_filenames_t *filenames);
1829 * Destroy a notmuch_filenames_t object.
1831 * It's not strictly necessary to call this function. All memory from
1832 * the notmuch_filenames_t object will be reclaimed when the
1833 * containing directory object is destroyed.
1835 * It is acceptable to pass NULL for 'filenames', in which case this
1836 * function will do nothing.
1839 notmuch_filenames_destroy (notmuch_filenames_t *filenames);