aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/notmuch.h
Commit message (Collapse)AuthorAge
* lib: Simplify close and codify aborting atomic sectionGravatar Austin Clements2014-10-03
| | | | | | | | | | | | | | | | | | | | | In Xapian, closing a database implicitly aborts any outstanding transaction and commits changes. For historical reasons, notmuch_database_close had grown to almost, but not quite duplicate this behavior. Before closing the database, it would explicitly (and unnecessarily) commit it. However, if there was an outstanding transaction (ie atomic section), commit would throw a Xapian exception, which notmuch_database_close would unnecessarily print to stderr, even though notmuch_database_close would ultimately abort the transaction anyway when it called close. This patch simplifies notmuch_database_close to explicitly abort any outstanding transaction and then just call Database::close. This works for both read-only and read/write databases, takes care of committing changes, unifies the exception handling path, and codifies aborting outstanding transactions. This is currently the only way to abort an atomic section (and may remain so, since it would be difficult to roll back things we may have cached from rolled-back modifications).
* notmuch_thread_get_authors: document match grouping with |Gravatar Gaute Hope2014-09-13
| | | | | | | | | | | | | | as stated in thread.cc:115 /* Construct an authors string from matched_authors_array and * authors_array. The string contains matched authors first, then * non-matched authors (with the two groups separated by '|'). Within * each group, authors are listed in date order. */ this is, however, not reflected in the public API documentation in notmuch.h:970. This patch a paragraph explaining how | separates the group of authors of messages matching the query and those of messages that do not, but are still contained in the thread.
* lib: Update doc of notmuch_database_{needs_upgrade,upgrade}Gravatar Austin Clements2014-08-30
| | | | | | Clients are no longer required to call these functions after opening a database in read/write mode (which is good, because almost none of them do!).
* lib: Return an error from operations that require an upgradeGravatar Austin Clements2014-08-30
| | | | | | | | | | | | | | | | | Previously, there was no protection against a caller invoking an operation on an old database version that would effectively corrupt the database by treating it like a newer version. According to notmuch.h, any caller that opens the database in read/write mode is supposed to check if the database needs upgrading and perform an upgrade if it does. This would protect against this, but nobody (even the CLI) actually does this. However, with features, it's easy to protect against incompatible operations on a fine-grained basis. This lightweight change allows callers to safely operate on old database versions, while preventing specific operations that would corrupt the database with an informative error message.
* lib: add return status to database close and destroyGravatar Jani Nikula2014-07-09
| | | | | | | | | notmuch_database_close may fail in Xapian ->flush() or ->close(), so report the status. Similarly for notmuch_database_destroy which calls close. This is required for notmuch insert to report error status if message indexing failed.
* doc: notmuch_result_move_to_next -> notmuch_tags_move_to_nextGravatar Gaute Hope2014-02-13
| | | | Fix typo in docs.
* lib: update documentation for notmuch_database_get_directoryGravatar David Bremner2014-01-26
| | | | | | | | | Clarify that using the directory after destroying the corresponding database is not permitted. This is implicit in the description of notmuch_database_destroy, but it doesn't hurt to be explicit, and we do express similar "ownership" relationships at other places in the docs.
* lib: make notmuch_threads_valid return FALSE when passed NULLGravatar David Bremner2014-01-24
| | | | | Without this patch, the example code in the header docs crashes for certain invalid queries (see id:871u00oimv.fsf@approx.mit.edu)
* lib: modify notmuch.h for automatic document generationGravatar Jani Nikula2014-01-05
| | | | Minimal changes to produce a sensible result.
* lib: Bump library version from 3.0.0 to 3.1.0Gravatar Austin Clements2013-12-07
| | | | | | This version of the library introduces LIBNOTMUCH_CHECK_VERSION and the *_VERSION macros. Bumping the version number is also necessary to make the comment on LIBNOTMUCH_CHECK_VERSION no longer a lie.
* lib: Replace NOTMUCH_*_VERSION with LIBNOTMUCH_*_VERSIONGravatar Austin Clements2013-12-07
| | | | | | This makes it clear that these macros refer to the *library* version, and not to the notmuch application-level release. Since there are no consumers of these macros yet, this is now or never.
* lib: Make VERSION macros agree with soname versionGravatar Austin Clements2013-12-07
| | | | | | | | | | | | | | | | | | We have two distinct "library version" numbers: the soname version and the version macros. We need both for different reasons: the version macros enable easy compile-time version detection (and conditional compilation), while the soname version enables runtime version detection (which includes the version checking done by things like the Python bindings). However, currently, these two version numbers are different, which is unnecessary and can lead to confusion (especially in things like Debian, which include the soname version in the package name). This patch makes them the same by bumping the version macros up to agree with the soname version. (We should probably keep the version number in just one place so they can't get out of sync, but that can be done in another patch.)
* lib: Document extent of some return valuesGravatar Austin Clements2013-11-08
| | | | | | This documents the extent of the notmuch_messages_t* pointers returned by notmuch_thread_get_toplevel_messages and notmuch_thread_get_messages.
* lib: add library version check macroGravatar Jani Nikula2013-11-07
| | | | | | | | | There have been some plans for making build incompatible changes to the library API. This is inconvenient, but it is much more so without a way to easily conditional build against multiple versions of notmuch. The macro has been lifted from glib.
* lib: update documentation of callback functions for database_compact and ↵Gravatar David Bremner2013-11-07
| | | | | | | database_upgrade. Compact was missing callback documentation entirely, and upgrade did not discuss the closure parameter.
* lib: add closure parameter to compact status update callbackGravatar Jani Nikula2013-11-07
| | | | This provides much more flexibility for the caller.
* database: Add notmuch_database_compact_closeGravatar Ben Gamari2013-10-09
| | | | | | | | | This function uses Xapian's Compactor machinery to compact the notmuch database. The compacted database is built in a temporary directory and later moved into place while the original uncompacted database is preserved. Signed-off-by: Ben Gamari <bgamari.foss@gmail.com>
* lib: Document which strings are returned in UTF-8Gravatar Austin Clements2013-08-13
| | | | | Any string that ultimately comes from notmuch_message_file_get_header is in UTF-8.
* lib: Correct out-of-date doc commentGravatar Austin Clements2013-08-13
| | | | | | notmuch_message_get_header started returning some headers straight from the database in 567bcbc, but this comment explicitly claimed all headers were read from the message file.
* lib: add NOTMUCH_EXCLUDE_FLAG to notmuch_exclude_tGravatar Mark Walters2013-06-24
| | | | | | | | | | | | | | | | | Add NOTMUCH_EXCLUDE_FLAG to notmuch_exclude_t so that it can cover all four values of search --exclude in the cli. Previously the way to avoid any message being marked excluded was to pass in an empty list of excluded tags: since we now have an explicit option we might as well honour it. The enum is in a slightly strange order as the existing FALSE/TRUE options correspond to the new NOTMUCH_EXCLUDE_FLAG/NOTMUCH_EXCLUDE_TRUE options so this means we do not need to bump the version number. Indeed, an example of this is that the cli count and show still use FALSE/TRUE and still work.
* lib: add --exclude=all optionGravatar Mark Walters2013-05-13
| | | | | | Adds a exclude all option to the lib which means that excluded messages are completely ignored (as if they had actually been deleted).
* lib: Add an iterator over all messages in a threadGravatar Austin Clements2013-02-18
| | | | | | | | Previously, getting the list of all messages in a thread required recursively traversing the thread's message hierarchy, which was both difficult and resulted in messages being out of order. This adds a public function to retrieve an iterator over all of the messages in a thread in oldest-first order.
* lib: Make notmuch_database_get_directory return NULL if the directory is not ↵Gravatar Austin Clements2012-05-23
| | | | | | | | | | | | | | | found Using the new support from _notmuch_directory_create, this makes notmuch_database_get_directory a read-only operation that simply returns the directory object if it exists or NULL otherwise. This also means that notmuch_database_get_directory can work on read-only databases. This change breaks the directory mtime workaround in notmuch-new.c by fixing the exact issue it was working around. This permits mtime update races to prevent scans of changed directories, which non-deterministically breaks a few tests. The next patch fixes this.
* lib/cli: Make notmuch_database_get_directory return a status codeGravatar Austin Clements2012-05-15
| | | | | | | | | | | | | | Previously, notmuch_database_get_directory had no way to indicate how it had failed. This changes its prototype to return a status code and set an out-argument to the retrieved directory, like similar functions in the library API. This does *not* change its currently broken behavior of creating directory objects when they don't exist, but it does document it and paves the way for fixing this. Also, it can now check for a read-only database and return NOTMUCH_STATUS_READ_ONLY_DATABASE instead of crashing. In the interest of atomicity, this also updates calls from the CLI so that notmuch still compiles.
* lib/cli: Make notmuch_database_create return a status codeGravatar Austin Clements2012-05-05
| | | | | | | | This is the notmuch_database_create equivalent of the previous change. In this case, there were places where errors were not being propagated correctly in notmuch_database_create or in calls to it. These have been fixed, using the new status value.
* lib/cli: Make notmuch_database_open return a status codeGravatar Austin Clements2012-05-05
| | | | | | | | | | | | It has been a long-standing issue that notmuch_database_open doesn't return any indication of why it failed. This patch changes its prototype to return a notmuch_status_t and set an out-argument to the database itself, like other functions that return both a status and an object. In the interest of atomicity, this also updates every use in the CLI so that notmuch still compiles. Since this patch does not update the bindings, the Python bindings test fails.
* Split notmuch_database_close into two functionsGravatar Justus Winter2012-04-28
| | | | | | | | | | | | | | | | | | Formerly notmuch_database_close closed the xapian database and destroyed the talloc structure associated with the notmuch database object. Split notmuch_database_close into notmuch_database_close and notmuch_database_destroy. This makes it possible for long running programs to close the xapian database and thus release the lock associated with it without destroying the data structures obtained from it. This also makes the api more consistent since every other data structure has a destructor function. The comments in notmuch.h are a courtesy of Austin Clements. Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
* lib: change default for notmuch_query_set_omit_excludedGravatar Mark Walters2012-04-07
|
* lib: Add the exclude flag to notmuch_query_search_threadsGravatar Mark Walters2012-03-02
| | | | | | | | | | | Add the NOTMUCH_MESSAGE_FLAG_EXCLUDED flag to notmuch_query_search_threads. Implemented by inspecting the tags directly in _notmuch_thread_create/_thread_add_message rather than as a Xapian query for speed reasons. Note notmuch_thread_get_matched_messages now returns the number of non-excluded matching messages. This API is not totally desirable but fixing it means breaking binary compatibility so we delay that.
* lib: Make notmuch_query_search_messages set the exclude flagGravatar Mark Walters2012-03-02
| | | | | | | | | | Add a flag NOTMUCH_MESSAGE_FLAG_EXCLUDED which is set by notmuch_query_search_messages for excluded messages. Also add an option omit_excluded_messages to the search that we do not want the excludes at all. This exclude flag will be added to notmuch_query_search threads in the next patch.
* lib: Add support for automatically excluding tags from queriesGravatar Austin Clements2012-01-16
| | | | | | This is useful for tags like "deleted" and "spam" that people generally want to exclude from query results. These exclusions will be overridden if a tag is explicitly mentioned in a query.
* lib: add function to get the number of threads matching a searchGravatar Jani Nikula2011-11-15
| | | | | | | | | Add function notmuch_query_count_threads() to get the number of threads matching a search. This is done by performing a search and figuring out the number of unique thread IDs in the matching messages, a significantly heavier operation than notmuch_query_count_messages(). Signed-off-by: Jani Nikula <jani@nikula.org>
* lib: make find_message{,by_filename) report errorsGravatar Ali Polatel2011-10-04
| | | | | | | | | | | | | | | | Previously, the functions notmuch_database_find_message() and notmuch_database_find_message_by_filename() functions did not properly report error condition to the library user. For more information, read the thread on the notmuch mailing list starting with my mail "id:871uv2unfd.fsf@gmail.com" Make these functions accept a pointer to 'notmuch_message_t' as argument and return notmuch_status_t which may be used to check for any error condition. restore: Modify for the new notmuch_database_find_message() new: Modify for the new notmuch_database_find_message_by_filename()
* lib: Improve notmuch_database_{add,remove}_message documentation.Gravatar Austin Clements2011-09-24
| | | | | | | | State up front that these functions may add a filename to an existing message or remove only a filename (and not the message), respectively. Previously, this key information was buried in return value documentation or in "notes", which made it seem secondary to these functions' semantics.
* lib: Add an API to find a message by filename.Gravatar Austin Clements2011-09-24
| | | | | | | | | notmuch_database_find_message_by_filename is mostly stolen from notmuch_database_remove_message, so this patch also vastly simplfies the latter using the former. This API is also useful in its own right and will be used in a later patch for eager maildir flag synchronization.
* lib: Add support for nested atomic sections.Gravatar Austin Clements2011-09-23
| | | | | | | notmuch_database_t now keeps a nesting count and we only start a transaction or commit for the outermost atomic section. Introduces a new error, NOTMUCH_STATUS_UNBALANCED_ATOMIC.
* lib: Add notmuch_database_{begin,end}_atomic.Gravatar Austin Clements2011-09-23
| | | | | | These operations translate into non-flushed Xapian transactions, allowing arbitrary groups of database operations to be performed atomically.
* fix sum moar typos [comments in source code]Gravatar Pieter Praet2011-06-23
| | | | | | | | | | Various typo fixes in comments within the source code. Signed-off-by: Pieter Praet <pieter@praet.org> Edited-by: Carl Worth <cworth@cworth.org> Restricted to just source-code comments, (and fixed fix of "descriptios" to "descriptors" rather than "descriptions").
* tags_to_maildir_flags: Fix to preserve existing, unsupported flagsGravatar Carl Worth2010-11-11
| | | | | | This is to prevent notmuch from destroying any information the user has encoded as flags in the maildir filename. Tests are also added to the test suite to verify the documented behavior.
* notmuch_message_tags_to_maildir_flags: Do nothing outside of "new" and "cur"Gravatar Carl Worth2010-11-11
| | | | | | | | | | | Some people use notmuch with non-maildir files, (for example, email messages in MH format, or else cool things like using sluk[*] to suck down feeds into a format that notmuch can index). To better support uses like that, don't do any renaming for files that are not in a directory named either "new" or "cur". [*] https://github.com/krl/sluk/
* lib: Be honest in the documentation of the maildir functionsGravatar Carl Worth2010-11-11
| | | | | | | | | | I had originally hoped for better semantics, such as doing nothing in non-maildir directories, and preserving unknown maildir flags that happen to be present. We could still do those things, of course, but for now, remove them from the documentation since the implementation does not do these things yet.
* lib: Document that absence of maildir flags can also remove/add tagsGravatar Carl Worth2010-11-11
| | | | | | | | | | | | | | | Previously the documentation of notmuch_message_maildir_flags_to_tags suggested that the presence of a flag would cause tags to be added, (or in the case of "unread", removed). But the case of absent maildir flags was not explicitly described. What we actually want, is that for supported flags, the absence of the flag in all messages causes the corresponding tag to be removed, (or in the case of "unread", added). So document that explicitly. This is the case recently added to the test suite as a failing test, (so we'll need to do bug fixing before the documentation is honest here).
* lib: Add new, public notmuch_message_get_filenamesGravatar Carl Worth2010-11-11
| | | | | | | | | | | | | | | | | | This augments the existing notmuch_message_get_filename by allowing the caller access to all filenames in the case of multiple files for a single message. To support this, we split the iterator (notmuch_filenames_t) away from the list storage (notmuch_filename_list_t) where previously these were a single object (notmuch_filenames_t). Then, whenever the user asks for a file or filename, the message object lazily creates a complete notmuch_filename_list_t and then: For notmuch_message_get_filename, returns the first filename in the list. For notmuch_message_get_filenames, creates and returns a new iterator for the filename list.
* lib: Remove the notion of TAGS_INVALIDGravatar Carl Worth2010-11-11
| | | | | | | | This rather ugly hack was recently obviated by the removal of the notmuch_database_set_maildir_sync function. Now, clients must make explicit calls to do any syncrhonization between maildir flags and tags. So the library no longer needs to worry about doing inconsistent synchronization while a message is only partially added.
* lib: Rework interface for maildir_flags synchronizationGravatar Carl Worth2010-11-11
| | | | | | | | | | | | | Instead of having an API for setting a library-wide flag for synchronization (notmuch_database_set_maildir_sync) we instead implement maildir synchronization with two new library functions: notmuch_message_maildir_flags_to_tags and notmuch_message_tags_to_maildir_flags These functions are nicely documented here, (though the implementation does not quite match the documentation yet---as plainly evidenced by the current results of the test suite).
* Make maildir synchronization configurableGravatar Michal Sojka2010-11-10
| | | | | | | This adds group [maildir] and key 'synchronize_flags' to the configuration file. Its value enables (true) or diables (false) the synchronization between notmuch tags and maildir flags. By default, the synchronization is disabled.
* Maildir synchronizationGravatar Michal Sojka2010-11-10
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch allows bi-directional synchronization between maildir flags and certain tags. The flag-to-tag mapping is defined by flag2tag array. The synchronization works this way: 1) Whenever notmuch new is executed, the following happens: o New messages are tagged with configured new_tags. o For new or renamed messages with maildir info present in the file name, the tags defined in flag2tag are either added or removed depending on the flags from the file name. 2) Whenever notmuch tag (or notmuch restore) is executed, a new set of flags based on the tags is constructed for every message and a new file name is prepared based on the old file name but with the new flags. If the flags differs and the old message was in 'new' directory then this is replaced with 'cur' in the new file name. If the new and old file names differ, the file is renamed and notmuch database is updated accordingly. The rename happens before the database is updated. In case of crash between rename and database update, the next run of notmuch new brings the database in sync with the mail store again.
* lib: Return added message even if it already was in the databaseGravatar Michal Sojka2010-11-10
|
* lib: Add two functions: notmuch_query_get_query_string and _get_sortGravatar Carl Worth2010-10-28
| | | | | It can be handy to be able to query these settings from an existing query object.
* lib: Fix notmuch_query_search_threads to return NULL on any Xapian exception.Gravatar Carl Worth2010-10-22
| | | | | | Previously, if the underlying search_messages hit an exception and returned NULL, this function would ignore that and return a non-NULL, (but empty) threads object. Fix this to properly propagate the error.