aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib
Commit message (Collapse)AuthorAge
...
* 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.
* lib: do not leak the database in compactionGravatar Jani Nikula2013-11-07
| | | | | Destroy instead of close the database after compaction, and also on error path, to not leak the database.
* lib: check talloc success in compactGravatar Jani Nikula2013-11-06
| | | | In line with the allocation checks all around.
* lib: construct compactor within try block to catch any exceptionsGravatar Jani Nikula2013-11-06
| | | | Constructors may also throw exceptions. Catch them.
* query: bind queries to database objectsGravatar Felipe Contreras2013-11-02
| | | | | | | | The queries don't really work after a database is closed, and we would like them to be freed if the database is destroyed. Acknowledged-by: David Bremner <david@tethera.net> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
* lib: fix build on !HAVE_XAPIAN_COMPACTGravatar Jani Nikula2013-10-30
| | | | | Minimal change to build notmuch against xapian that doesn't have compaction support.
* 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/cli: pass GMIME_ENABLE_RFC2047_WORKAROUNDS to g_mime_init()Gravatar Jani Nikula2013-09-14
| | | | | | | | | | | | | | As explained by Jeffrey Stedfast, the author of GMime, quoted in [1]: > Passing the GMIME_ENABLE_RFC2047_WORKAROUNDS flag to g_mime_init() > *should* solve the decoding problem mentioned in the thread. This > flag should be safe to pass into g_mime_init() without any bad side > effects and my unit tests do test that code-path. The thread being referred to is [2]. [1] id:87bo56viyo.fsf@nikula.org [2] id:08cb1dcd-c5db-4e33-8b09-7730cb3d59a2@gmail.com
* tags_to_maildir_flags: Don't rename if no flags changeGravatar Louis Rilling2013-09-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | notmuch_message_tags_to_maildir_flags() unconditionally moves messages from maildir directory "new/" to maildir directory "cur/", which makes messages lose their "new" status in the MUA. However some users want to keep this "new" status after, for instance, an auto-tagging of new messages. However, as Austin mentioned and according to the maildir specification, messages living in "new/" are not allowed to have flags, even if mutt allows it to happen. For this reason, this patch prevents moving messages from "new/" to "cur/", only if no flags have to be changed. It's hopefully enough to satisfy mutt (and maybe other MUAs showing the "new" status) users checking the "new" status. Changelog: * v2: Fix bool type as well as NULL returned despite having no errors (Austin Clements) * v4: Tag the related test (contributed by Michal Sojka) as working Signed-off-by: Louis Rilling <l.rilling@av7.net> [Condition for keeping messages in new/ was extended to satisfy all tests from the previous patch. -Michal Sojka] [Added by David Bremner, to keep the tests passing at each commit] update insert tests for new maildir synchronization rules As of id:1355952747-27350-4-git-send-email-sojkam1@fel.cvut.cz we are more conservative about moving messages from ./new to ./cur. This updates the insert tests to match
* lib: fix clang buildGravatar Jani Nikula2013-09-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Long story short, fix build on recent (3.2+) clang. The long story for posterity follows. gcc 4.6 added new warnings about structs with greater visibility than their fields. The warnings were silenced by adjusting visibility in commit d5523ead90b6be2b07d4af745b8ed9b980a6b9f1 Author: Carl Worth <cworth@cworth.org> Date: Wed May 11 13:23:13 2011 -0700 Mark some structures in the library interface with visibility=default attribute. Later on, commit 3b76adf9e2c026dd03b820f4c6eab50e25444113 Author: Austin Clements <amdragon@MIT.EDU> Date: Sat Jan 14 19:17:33 2012 -0500 lib: Add support for automatically excluding tags from queries changed visibility of struct _notmuch_string_list for the same reason, and commit 1a53f9f116fa7c460cda3df532be921baaafb082 Author: Mark Walters <markwalters1009@gmail.com> Date: Thu Mar 1 22:30:38 2012 +0000 lib: Add the exclude flag to notmuch_query_search_threads split the struct _notmuch_string_list and its typedef notmuch_string_list_t as a way to make a forward declaration for _notmuch_thread_create(). The subtle difference was that the struct definition now had 'visible' in it, while the typedef didn't, and it was within the #pragma GCC visibility push(hidden) block. This went unnoticed, as the then common versions of clang didn't care about this. A later change in clang (I did not dig into when this change was introduced) caused the following error: CXX -O2 lib/database.o In file included from lib/database.cc:21: In file included from ./lib/database-private.h:33: ./lib/notmuch-private.h:479:8: error: visibility does not match previous declaration struct visible _notmuch_string_list { ^ ./lib/notmuch-private.h:67:33: note: expanded from macro 'visible' ^ ./lib/notmuch-private.h:52:13: note: previous attribute is here ^ 1 error generated. make: *** [lib/database.o] Error 1 This is slightly misleading due to the reference to the #pragma. The real culprit is the typedef within the #pragma. We could just add 'visible' to the typedef, or move the typedef outside of the #pragma, and be done with it, but juggle the declarations a bit to accommodate moving the typedef back with the struct, and keep the visibility attribute in one place. The problem was originally reported by Simonas Kazlauskas <s@kazlauskas.me> in id:20130418102507.GA23688@godbox but I was only able to reproduce and investigate now that I upgraded clang.
* 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.
* cli: Guard deprecated g_type_init callsGravatar Tomi Ollila2013-06-08
| | | | | | | g_type_init was deprecated in GLib 2.35.1. In order to compile cleanly, guard these with a suitable #if. (commit msg from https://bugs.freedesktop.org/attachment.cgi?id=73774 )
* 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/database.cc: change how the parent of a message is calculatedGravatar Aaron Ecay2013-05-13
| | | | | | | | | | | | | | | | | | | | Presently, the code which finds the parent of a message as it is being added to the database assumes that the first Message-ID-like substring of the In-Reply-To header is the parent Message ID. Some mail clients, however, put stuff other than the Message-ID of the parent in the In-Reply-To header, such as the email address of the sender of the parent. This can fool notmuch. The updated algorithm prefers the last Message ID in the References header. The References header lists messages oldest-first, so the last Message ID is the parent (RFC2822, p. 24). The References header is also less likely to be in a non-standard syntax (http://cr.yp.to/immhf/thread.html, http://www.jwz.org/doc/threading.html). In case the References header is not to be found, fall back to the old behavior. V2 of this patch, incorporating feedback from Jani and (indirectly) Austin.
* lib/message.cc: stale pointer bug (v3)Gravatar Vladimir Marek2013-05-03
| | | | | | | | Xapian::TermIterator::operator* returns std::string which is destroyed as soon as (*i).c_str() finishes. The remembered pointer 'term' then references invalid memory. Signed-off-by: Vladimir Marek <vlmarek@volny.cz>
* lib: Fix name reordering to handle commas without spacesGravatar Adam Wolfe Gordon2013-03-29
| | | | | | | | Notmuch automatically re-orders names of the format "Last, First" to "First Last" when the associated email address is First.Last@example.com. But, if a name is of the format "Last,First" then notmuch will format the name as "irst Last". Handle any number of spaces after the comma, including none.
* 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: Eliminate _notmuch_message_list_appendGravatar Austin Clements2013-02-18
| | | | | This API invited micro-optimized and complicated list pointer manipulation and is no longer used.
* lib: Separate list of all messages from top-level messagesGravatar Austin Clements2013-02-18
| | | | | | | | | | | | Previously, thread.cc built up a list of all messages, then proceeded to tear it apart to transform it into a list of top-level messages. Now we simply build a new list of top-level messages. This simplifies the interface to _notmuch_message_add_reply, eliminates the pointer acrobatics from _resolve_thread_relationships, and will enable us to do things with the list of all messages in the following patches.
* lib: Clean up error handling in _notmuch_thread_createGravatar Austin Clements2013-02-18
| | | | | | | Previously, there were various opportunities for memory leaks in the error-handling paths of this function. Use a local talloc context and some reparenting to make eliminate these leaks, while keeping the control flow simple.
* bitmap:improve memory usage using CHAR_BITS and unsigned CHARGravatar Robert Mast2013-02-15
| | | | | | | Using char instead of int allows for simpler definitions of the DOCIDSET macros so the code is easier to understand and consistent with respect to memory-usage. Estimated reduction of memory-usage for bitmap about 8 times.
* lib/Makefile.local: depend on libs we are linking withGravatar Amadeusz Żołnowski2013-01-22
|
* _notmuch_message_index_file: unref (free) address lists from gmime.Gravatar David Bremner2012-12-24
| | | | | | | | | Apparently as of GMime 2.4, you don't need to call internet_address_list_destroy anymore, but you still need to call g_object_unref (from the GMime Changelog). On the medium performance corpus, valgrind shows "possibly lost" leakage in "notmuch new" dropping from 7M to 300k.
* lib/message-file.c: use g_malloc () & g_free () in hash table valuesGravatar Tomi Ollila2012-12-24
| | | | | | | | | | | | | | | | | | | | | The message->headers hash table values get data returned by g_mime_utils_header_decode_text (). The pointer returned by g_mime_utils_header_decode_text is from the following line in rfc2047_decode_tokens return g_string_free (decoded, FALSE); The docs for g_string_free say Frees the memory allocated for the GString. If free_segment is TRUE it also frees the character data. If it's FALSE, the caller gains ownership of the buffer and must free it after use with g_free(). The remaining frees and allocations referencing to message->headers hash values have been changed to use g_free and g_malloc functions. This combines and completes the changes started by David Bremner.
* lib: fix warnings when building with clangGravatar Jani Nikula2012-12-01
| | | | | | | | | | | | | | | | | | | | | | | | | | Building notmuch with CC=clang and CXX=clang++ produces the warnings: CC -O2 lib/tags.o lib/tags.c:43:5: warning: expression result unused [-Wunused-value] talloc_steal (tags, list); ^~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/talloc.h:345:143: note: expanded from: ...__location__); __talloc_steal_ret; }) ^~~~~~~~~~~~~~~~~~ 1 warning generated. CXX -O2 lib/message.o lib/message.cc:791:5: warning: expression result unused [-Wunused-value] talloc_reference (message, message->tag_list); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/talloc.h:932:36: note: expanded from: ...(_TALLOC_TYPEOF(ptr))_talloc_reference_loc((ctx),(ptr), __location__) ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 warning generated. Check talloc_reference() return value, and explicitly ignore talloc_steal() return value as it has no failure modes, to silence the warnings.
* lib: Reject multi-message mboxes and deprecate single-message mboxGravatar Austin Clements2012-11-26
| | | | | | | | Previously, we would treat multi-message mboxes as one giant email, which, besides the obvious incorrect indexing, often led to out-of-memory errors for archival mboxes. Now we explicitly reject multi-message mboxes. For historical reasons, we retain support for single-message mboxes, but official deprecate this behavior.
* lib: add date range query supportGravatar Jani Nikula2012-10-31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a custom value range processor to enable date and time searches of the form date:since..until, where "since" and "until" are expressions understood by the previously added date/time parser, to restrict the results to messages within a particular time range (based on the Date: header). If "since" or "until" describes date/time at an accuracy of days or less, the values are rounded according to the accuracy, towards past for "since" and towards future for "until". For example, date:november..yesterday would match from the beginning of November until the end of yesterday. Expressions such as date:today..today means since the beginning of today until the end of today. Open-ended ranges are supported (since Xapian 1.2.1), i.e. you can specify date:..until or date:since.. to not limit the start or end date, respectively. CAVEATS: Xapian does not support spaces in range expressions. You can replace the spaces with '_', or (in most cases) '-', or (in some cases) leave the spaces out altogether. Entering date:expr without ".." (for example date:yesterday) will not work as you might expect. You can achieve the expected result by duplicating the expr both sides of ".." (for example date:yesterday..yesterday). Open-ended ranges won't work with pre-1.2.1 Xapian, but they don't produce an error either. Signed-off-by: Jani Nikula <jani@nikula.org>
* build: build parse-time-string as part of the notmuch lib and static cliGravatar Jani Nikula2012-10-31
|
* Support OpenBSDGravatar Austin Clements2012-10-27
| | | | | | | | OpenBSD's build flags are identical to FreeBSD, except that libraries need to be explicitly linked against libc. No code changes are necessary. From: Cody Cutler <ccutler@csail.mit.edu>
* Fix the COERCE_STATUS macroGravatar Justus Winter2012-09-27
| | | | | | | | | | Fix the COERCE_STATUS macro to handle _internal_error being declared as void function. Note that the function _internal_error does not return. Evaluating to NOTMUCH_STATUS_SUCCESS is done purely to appease the compiler. Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
* lib: fix NULL checks for filenames iteratorsGravatar Sascha Silbe2012-09-01
| | | | | | | | The API documentation (notmuch.h) states that the parameter may be NULL, but the implementation only checked the current element, potentially dereferencing a NULL pointer in the process. Signed-off-by: Sascha Silbe <sascha-pgp@silbe.org>
* lib: Treat messages in new/ as maildir messages with no flags setGravatar Austin Clements2012-06-10
| | | | | | | | | | | | Previously, notmuch new only synchronized maildir flags to tags for files with a maildir "info" part. Since messages in new/ don't have an info part, notmuch would ignore them for flag-to-tag synchronization. This patch makes notmuch consider messages in new/ to be legitimate maildir messages that simply have no maildir flags set. The most visible effect of this is that such messages now automatically get the unread tag.
* lib: Only synchronize maildir flags for messages in maildirsGravatar Austin Clements2012-06-10
| | | | | | | | | | | | | Previously, we synchronized flags to tags for any message that looked like it had maildir flags in its file name, regardless of whether it was in a maildir-like directory structure. This was asymmetric with tag-to-flag synchronization, which only applied to messages in directories named new/ and cur/ (introduced by 95dd5fe5). This change makes our interpretation stricter and addresses this asymmetry by only synchronizing flags to tags for messages in directories named new/ or cur/. It also prepares us to treat messages in new/ as maildir messages, even though they lack maildir flags.
* lib: Move _filename_is_in_maildirGravatar Austin Clements2012-06-10
| | | | | | This way notmuch_message_maildir_flags_to_tags can call it. It makes more sense for this to be just above all of the maildir synchronization code rather than mixed in the middle.
* lib: Don't needlessly create directory docs in _notmuch_message_remove_filenameGravatar Austin Clements2012-05-23
| | | | | | Previously, if passed a filename with a directory that did not exist in the database, _notmuch_message_remove_filename would needlessly create that directory document. Fix it so that doesn't happen.
* lib: Make notmuch_database_find_message_by_filename not crash on read-only ↵Gravatar Austin Clements2012-05-23
| | | | | | | | | | | databases Previously, _notmuch_database_filename_to_direntry would abort with an internal error when called on a read-only database. Now that creating the directory document is optional, notmuch_database_find_message_by_filename can disable directory document creation (as it should) and, as a result, not abort on read-only databases.
* 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: Perform the same transformation to _notmuch_database_filename_to_direntryGravatar Austin Clements2012-05-23
| | | | | | Now _notmuch_database_filename_to_direntry takes a flags argument and can indicate if the necessary directory documents do not exist. Again, callers have been updated, but retain their original behavior.
* lib: Perform the same transformation to _notmuch_database_find_directory_idGravatar Austin Clements2012-05-23
| | | | | | | Now _notmuch_database_find_directory_id takes a flags argument, which it passes through to _notmuch_directory_create and can indicate if the directory does not exist. Again, callers have been updated, but retain their original behavior.
* lib: Make directory document creation optional for _notmuch_directory_createGravatar Austin Clements2012-05-23
| | | | | | | | | | | Previously this function would create directory documents if they didn't exist. As a result, it could only be used on writable databases. This adds an argument to make creation optional and to make this function work on read-only databases. We use a flag argument to avoid a bare boolean and to permit future expansion. Both callers have been updated, but currently retain the old behavior. We'll take advantage of the new argument in the following patches.
* 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: Bump SO version from 2.0.0 to 3.0.0Gravatar Austin Clements2012-05-05
| | | | | | | We've changed the APIs of notmuch_database_open, notmuch_database_create, and notmuch_database_close. Amended by db: also bump string in bindings/python/notmuch/globals.py
* 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: work around talloc_steal usage from C++ codeGravatar Jani Nikula2012-04-15
| | | | | | | | | | | | | | | | Implicit typecast from 'void *' to 'T *' is okay in C, but not in C++. In talloc_steal, an explicit cast is provided for type safety in some GCC versions. Otherwise, a cast is required. Provide a template function for this to maintain type safety, and redefine talloc_steal to use it. The template must be outside the extern "C" block (NOTMUCH_BEGIN_DECLS and NOTMUCH_END_DECLS), but keep it within the GCC visibility #pragma. No functional changes, apart from making the library build with compilers other than recent GCC. Signed-off-by: Jani Nikula <jani@nikula.org>
* lib: change default for notmuch_query_set_omit_excludedGravatar Mark Walters2012-04-07
|