aboutsummaryrefslogtreecommitdiff
path: root/message.cc
AgeCommit message (Collapse)Author
2009-11-09libify: Move library sources down into lib directory.Carl Worth
A "make" invocation still works from the top-level, but not from down inside the lib directory yet.
2009-11-06add_message: Fix segfault for message with no Date header.Carl Worth
I'd fixed this earlier when I had a private copy of GMime's date-parsing code, but I lost the fix when I recently switched to calling the GMime function.
2009-11-02Remove notmuch_message_get_header_size and notmuch_message_get_all_headersCarl Worth
The notmuch.c main program now uses GMime directly rather than using these functions, and I'd rather not export any functions unless we have good evidence that the functions are necessary.
2009-11-02Drop date.c file, (use identical function from GMime instead).Carl Worth
We had originally copied this function in at a time when notmuch wasn't actually depending on the GMime library. Now that it does, we might as well call the function that exists there rather than having a private copy of it.
2009-10-29notmuch show: Add a one-line summary of the message before the header.Carl Worth
The idea here is that a client could usefully display just this one line while optionally hiding the other header fields.
2009-10-29notmuch show: Add body of message as well.Carl Worth
This is just the raw message body for now, (so any MIME parsing will be up to the consumer). And this will likely change in the future.
2009-10-29notmuch show: Initial implementation (headers only)Carl Worth
We're using a delimiter syntax that Keith is optimistic about being able to easily parse in emacs. Note: We're not escaping any occurrence of the delimiters in the message yet, so we'll need to fix that.
2009-10-28Fix add_message and get_filename to strip/re-add the database path.Carl Worth
We now store only a relative path inside the database so the database is not nicely relocatable.
2009-10-28Tweak formatting of internal error messages.Carl Worth
Was neglecting to print the phrase "Internal error: " before, and for the duplicate message-ID error it's nice to actually see the duplicate IDs.
2009-10-28Add full-text indexing using the GMime library for parsing.Carl Worth
This is based on the old notmuch-index-message.cc from early in the history of notmuch, but considerably cleaned up now that we have some experience with Xapian and know just what we want to index, (rather than just blindly trying to index exactly what sup does). This does slow down notmuch_database_add_message a *lot*, but I've got some ideas for getting some time back.
2009-10-27notmuch tag: Fix crash when removing a tag that didn't existCarl Worth
Xapian is trying to be useful by reporting that the specified term didn't exist, but this is one case where we just don't care. :-)
2009-10-26notmuch restore: Fix to remove all tags before adding tags.Carl Worth
This means that the restore operation will now properly pick up the removal of tags indicated by the tag just not being present in the dump file. We added a few new public functions in order to support this: notmuch_message_freeze notmuch_message_remove_all_tags notmuch_message_thaw
2009-10-26Add public notmuch_thread_get_subjectCarl Worth
And use this in "notmuch search" to display subject line as well as thread ID.
2009-10-26tags: Replace sort() and reset() with prepare_iterator().Carl Worth
The previous functions were always called together, so we might as well just have one function for this. Also, the reset() name was poor, and prepare_iterator() is much more descriptive.
2009-10-26tags: Re-implement tags iterator to avoid having C++ in the interfaceCarl Worth
We want to be able to iterate over tags stored in various ways, so the previous TermIterator-based tags object just wasn't general enough. The new interface is nice and simple, and involves only C datatypes.
2009-10-26Hide away the details of the implementation of notmuch_tags_t.Carl Worth
We will soon be wanting multiple different implementations of notmuch_tags_t iterators, so we need to keep the actual structure as an implementation detail inside of tags.cc.
2009-10-26Move terms and tags code to a new tags.cc file.Carl Worth
We want to start using this from both message.cc and thread.cc so we need it in a place we can share the code. This also requires a new notmuch-private-cxx.h header file for interfaces that include C++-specific datatypes (such as Xapian::Document).
2009-10-25Add -Wmising-declarations and fix warnings.Carl Worth
Wow, lots of missing 'static' on internal functions.
2009-10-25Change database to store only a single thread ID per message.Carl Worth
Instead of supporting multiple thread IDs, we now merge together thread IDs if one message is ever found to belong to more than one thread. This allows for constructing complete threads when, for example, a child message doesn't include a complete list of References headers back to the beginning of the thread. It also simplifies dealing with mapping a message ID to a thread ID which is now a simple get_thread_id just like get_message_id, (and no longer an iterator-based thing like get_tags).
2009-10-25Add an INTERNAL_ERROR macro and use it for all internal errors.Carl Worth
We were previously just doing fprintf;exit at each point, but I wanted to add file and line-number details to all messages, so it makes sense to use a single macro for that.
2009-10-25add_message: Propagate error status from notmuch_message_create_for_message_idCarl Worth
What a great feeling to remove an XXX comment.
2009-10-25Drop the storage of thread ID(s) in a value.Carl Worth
Now that we are iterating over the thread terms instead, we can drop this redundant storage (which should shrink our database a tiny bit).
2009-10-25Convert notmuch_thread_ids_t to notmuch_terms_tCarl Worth
Aside from increased code sharing, the benefit here is that now thread_ids iterates over the terms of a message rather than the thread_id value. So we'll now be able to drop that value.
2009-10-25Implement notmuch_tags_t on top of new notmuch_terms_tCarl Worth
The generic notmuch_terms_t iterator should provide support for notmuch_thread_ids_t when we switch as well, (And it would be interesting to see if we could reasonably make this support a PostingIterator too. Time will tell.)
2009-10-24Shuffle the value numbers around in the database.Carl Worth
First, it's nice that for now we don't have any users yet, so we can make incompatible changes to the database layout like this without causing trouble. ;-) There are a few reasons for this change. First, we now use value 0 uniformly as a timestamp for both mail and timestamp documents, (which lets us cleanup an ugly and fragile bare 0 in the add_value and get_value calls in the timestamp code). Second, I want to drop the thread value entirely, so putting it at the end of the list means we can drop it as compatible change in the future. (I almost want to drop the message-ID value too, but it's nice to be able to sort on it to get diff-able output from "notmuch dump".) But the thread value we never use as a value, (we would never sort on it, for example). And it's totally redundant with the thread terms we store already. So expect it to disappear soon.
2009-10-24Change all occurrences of "msgid" to "id".Carl Worth
What's good for the user is good for the internals.
2009-10-24Move the prefix-string arrays back into database.cc from message.ccCarl Worth
Yes, I'm being wishy-washy here, moving code back and forth. But this is where these really do belong.
2009-10-23_find_prefix: Exit when given an invalid prefix name.Carl Worth
This will be a nice safety check for internal sanity.
2009-10-23Add notmuch_database_set_timestamp and notmuch_database_get_timestampCarl Worth
These will be very helpful to implement an efficient "notmuch new" command which imports new mail messages that have appeared.
2009-10-23notmuch_tags_has_more: Fix to use string.empty rather than string.sizeCarl Worth
I'm really interested in the length of the data here, not the size of the storage.
2009-10-23Fix notmuch_message_get_message_id to never return NULL.Carl Worth
With the recent improvements to the handling of message IDs we "know" that a NULL message ID is impossible, (so we simply abort if the impossible happens).
2009-10-23add_message: Fix to not add multiple documents with the same message IDCarl Worth
Here's the second big fix to message-ID handling, (the first was to generate message IDs when an email contained none). Now, with no document missing a message ID, and no two documents having the same message ID, we have a nice consistent database where the message ID can be used as a unique key.
2009-10-23Add _notmuch_message_create_for_message_idCarl Worth
This is the last piece needed for add_message to be able to properly support a message with a duplicate message ID. This function creates a new notmuch_message_t object but one that may reference an existing document in the database.
2009-10-23Fix _notmuch_message_create to catch Xapian DocNotFoundError.Carl Worth
This function is only supposed to be called with a doc_id that was queried from the database already. So there's an internal error if no document with that doc_id can be found in the database. In that case, return NULL.
2009-10-23Add internal functions for manipulating a new notmuch_message_tCarl Worth
This will support the add_message function in incrementally creating state in a new notmuch_message_t. The new functions are _notmuch_message_set_filename _notmuch_message_add_thread_id _notmuch_message_ensure_thread_id _notmuch_message_set_date _notmuch_message_sync
2009-10-23Add notmuch_message_get_filenameCarl Worth
This is a new public function to find the filename of the original email message for a message-object that was found in the database. We may change this function in the future to support returning a list of filenames, (for messages with duplicate message IDs).
2009-10-23Move thread_id generation code from database.cc to message.ccCarl Worth
It's really up to the message to decide how to generate these.
2009-10-23Move the _notmuch_message_sync from private to public interfacesCarl Worth
The idea here is to allow internal users to see a non-synced message object, (for example, while parsing a message file and incrementally adding terms, etc.). We're willing to take the care to get the improved performance. But for the public interface, keeping everything synced will be much less confusing, (reference lots of sup bugs that happen due to message state being altered by the user but not synced to the database).
2009-10-21Merge branch from fixing up bugs after bisecting.Carl Worth
I'm glad that when I implemented "notmuch restore" I went through the extra effort to take the code I had written in one sitting into over a dozen commits. Sure enough, I hadn't tested well enough and had totally broken "notmuch setup", (segfaults and bogus thread_id values). With the little commits I had made, git bisect saved the day, and I went back to make the fixes right on top of the commits that introduced the bugs. So now we octopus merge those in.
2009-10-21Fix lifetime-maintenance bug with std::string and c_str()Carl Worth
Here's more evidence that C++ is a nightmare to program---or that I'm smart enough to realize that C++ is more clever than I will ever be. Most of my issues with C++ have to do with it hiding things from me that I'd really like to and expect to be aware of as a C programmer. For example, the specific problem here is that there's a short-lived std::string, from which I just want to copy the C string. I try to do that on the next line, but before I can, C++ has already called the destructor on the std::string. Now, C++ isn't alone in doing garbage collecting like this. But in a *real* garbage-collecting system, everything would work that way. For example, here, I'm still holding a pointer to the C string contents, so if the garbage collector were aware of that reference, then it might clean up the std::string container and leave the data I'm still using. But that's not what we get with C++. Instead, some things are reference counted and collected, (like the std::string), and some things just aren't (like the C string it contains). The end result is that it's very fragile. It forces me to be aware of the timing of hidden functions. In a "real" system I wouldn't have to be aware of that timing, and in C the function just wouldn't be hidden.
2009-10-21Add notmuch_message_add_tag and notmuch_message_remove_tagCarl Worth
With these two added, we now have enough functionality in the library to implement "notmuch restore".
2009-10-21notmuch_message_get_message_id: Fix to cache resultCarl Worth
Previously, this would allocate new memory with every call. That was with talloc, of course, so there wasn't any leaking (eventually). But since we're now calling this internally we want to be a little less wasteful. It's easy enough to just stash the result into the message on the first call, and then just return that on subsequent calls.
2009-10-21database: Add new notmuch_database_find_messageCarl Worth
With this function, and the recently added support for notmuch_message_get_thread_ids, we now recode the find_thread_ids function to work just the way we expect a user of the public notmuch API to work. Not too bad really.
2009-10-21Add notmuch_message_get_thread_ids functionCarl Worth
Along with all of the notmuch_thread_ids_t iterator functions. Using a consistent idiom seems better here rather than returning a comma-separated string and forcing the user to parse it.
2009-10-21Move find_prefix function from database.cc to message.ccCarl Worth
It's definitely a better fit there for now, (and can likely eventually be made static as add_term moves from database to message as well).
2009-10-20Add destroy functions for results, message, and tags.Carl Worth
None of these are strictly necessary, (everything was leak-free without them), but notmuch_message_destroy can actually be useful for when one query has many message results, but only one is needed to be live at a time. The destroy functions for results and tags are fairly gratuitous, as there's unlikely to be any benefit from calling them. But they're all easy to add, (all of these functions are just wrappers for talloc_free), and we do so for consistency and completeness.
2009-10-20Rename our talloc destructor functions to _destructor.Carl Worth
I want to reserve the _destroy names for some public functions I'm about to add.
2009-10-20Implement 'notmuch dump'.Carl Worth
This is a fairly big milestone for notmuch. It's our first command to do anything besides building the index, so it proves we can actually read valid results out from the index. It also puts in place almost all of the API and infrastructure we will need to allow searching of the database. Finally, with this change we are now using talloc inside of notmuch which is truly a delight to use. And now that I figured out how to use C++ objects with talloc allocation, (it requires grotty parts of C++ such as "placement new" and "explicit destructors"), we are valgrind-clean for "notmuch dump", (as in "no leaks are possible").