aboutsummaryrefslogtreecommitdiffhomepage
path: root/message.cc
Commit message (Collapse)AuthorAge
* libify: Move library sources down into lib directory.Gravatar Carl Worth2009-11-09
| | | | | A "make" invocation still works from the top-level, but not from down inside the lib directory yet.
* add_message: Fix segfault for message with no Date header.Gravatar Carl Worth2009-11-06
| | | | | | 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.
* Remove notmuch_message_get_header_size and notmuch_message_get_all_headersGravatar Carl Worth2009-11-02
| | | | | | 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.
* Drop date.c file, (use identical function from GMime instead).Gravatar Carl Worth2009-11-02
| | | | | | | 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.
* notmuch show: Add a one-line summary of the message before the header.Gravatar Carl Worth2009-10-29
| | | | | The idea here is that a client could usefully display just this one line while optionally hiding the other header fields.
* notmuch show: Add body of message as well.Gravatar Carl Worth2009-10-29
| | | | | 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.
* notmuch show: Initial implementation (headers only)Gravatar Carl Worth2009-10-29
| | | | | | | 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.
* Fix add_message and get_filename to strip/re-add the database path.Gravatar Carl Worth2009-10-28
| | | | | We now store only a relative path inside the database so the database is not nicely relocatable.
* Tweak formatting of internal error messages.Gravatar Carl Worth2009-10-28
| | | | | | 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.
* Add full-text indexing using the GMime library for parsing.Gravatar Carl Worth2009-10-28
| | | | | | | | | | | 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.
* notmuch tag: Fix crash when removing a tag that didn't existGravatar Carl Worth2009-10-27
| | | | | 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. :-)
* notmuch restore: Fix to remove all tags before adding tags.Gravatar Carl Worth2009-10-26
| | | | | | | | | | | | 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
* Add public notmuch_thread_get_subjectGravatar Carl Worth2009-10-26
| | | | | And use this in "notmuch search" to display subject line as well as thread ID.
* tags: Replace sort() and reset() with prepare_iterator().Gravatar Carl Worth2009-10-26
| | | | | | 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.
* tags: Re-implement tags iterator to avoid having C++ in the interfaceGravatar Carl Worth2009-10-26
| | | | | | | 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.
* Hide away the details of the implementation of notmuch_tags_t.Gravatar Carl Worth2009-10-26
| | | | | | 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.
* Move terms and tags code to a new tags.cc file.Gravatar Carl Worth2009-10-26
| | | | | | | 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).
* Add -Wmising-declarations and fix warnings.Gravatar Carl Worth2009-10-25
| | | | Wow, lots of missing 'static' on internal functions.
* Change database to store only a single thread ID per message.Gravatar Carl Worth2009-10-25
| | | | | | | | | | | | 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).
* Add an INTERNAL_ERROR macro and use it for all internal errors.Gravatar Carl Worth2009-10-25
| | | | | | 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.
* add_message: Propagate error status from notmuch_message_create_for_message_idGravatar Carl Worth2009-10-25
| | | | What a great feeling to remove an XXX comment.
* Drop the storage of thread ID(s) in a value.Gravatar Carl Worth2009-10-25
| | | | | | Now that we are iterating over the thread terms instead, we can drop this redundant storage (which should shrink our database a tiny bit).
* Convert notmuch_thread_ids_t to notmuch_terms_tGravatar Carl Worth2009-10-25
| | | | | | 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.
* Implement notmuch_tags_t on top of new notmuch_terms_tGravatar Carl Worth2009-10-25
| | | | | | | 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.)
* Shuffle the value numbers around in the database.Gravatar Carl Worth2009-10-24
| | | | | | | | | | | | | | | | | | | | 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.
* Change all occurrences of "msgid" to "id".Gravatar Carl Worth2009-10-24
| | | | What's good for the user is good for the internals.
* Move the prefix-string arrays back into database.cc from message.ccGravatar Carl Worth2009-10-24
| | | | | Yes, I'm being wishy-washy here, moving code back and forth. But this is where these really do belong.
* _find_prefix: Exit when given an invalid prefix name.Gravatar Carl Worth2009-10-23
| | | | This will be a nice safety check for internal sanity.
* Add notmuch_database_set_timestamp and notmuch_database_get_timestampGravatar Carl Worth2009-10-23
| | | | | These will be very helpful to implement an efficient "notmuch new" command which imports new mail messages that have appeared.
* notmuch_tags_has_more: Fix to use string.empty rather than string.sizeGravatar Carl Worth2009-10-23
| | | | | I'm really interested in the length of the data here, not the size of the storage.
* Fix notmuch_message_get_message_id to never return NULL.Gravatar Carl Worth2009-10-23
| | | | | | 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).
* add_message: Fix to not add multiple documents with the same message IDGravatar Carl Worth2009-10-23
| | | | | | | | 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.
* Add _notmuch_message_create_for_message_idGravatar Carl Worth2009-10-23
| | | | | | | 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.
* Fix _notmuch_message_create to catch Xapian DocNotFoundError.Gravatar Carl Worth2009-10-23
| | | | | | | | 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.
* Add internal functions for manipulating a new notmuch_message_tGravatar Carl Worth2009-10-23
| | | | | | | | | | | 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
* Add notmuch_message_get_filenameGravatar Carl Worth2009-10-23
| | | | | | | | 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).
* Move thread_id generation code from database.cc to message.ccGravatar Carl Worth2009-10-23
| | | | It's really up to the message to decide how to generate these.
* Move the _notmuch_message_sync from private to public interfacesGravatar Carl Worth2009-10-23
| | | | | | | | | | | 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).
*-. Merge branch from fixing up bugs after bisecting.Gravatar Carl Worth2009-10-21
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * | Fix lifetime-maintenance bug with std::string and c_str()Gravatar Carl Worth2009-10-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | Add notmuch_message_add_tag and notmuch_message_remove_tagGravatar Carl Worth2009-10-21
| | | | | | | | | | | | | | | With these two added, we now have enough functionality in the library to implement "notmuch restore".
* | | notmuch_message_get_message_id: Fix to cache resultGravatar Carl Worth2009-10-21
| |/ |/| | | | | | | | | | | | | | | 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.
* | database: Add new notmuch_database_find_messageGravatar Carl Worth2009-10-21
|/ | | | | | | 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.
* Add notmuch_message_get_thread_ids functionGravatar Carl Worth2009-10-21
| | | | | | 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.
* Move find_prefix function from database.cc to message.ccGravatar Carl Worth2009-10-21
| | | | | | 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).
* Add destroy functions for results, message, and tags.Gravatar Carl Worth2009-10-20
| | | | | | | | | | | | 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.
* Rename our talloc destructor functions to _destructor.Gravatar Carl Worth2009-10-20
| | | | | I want to reserve the _destroy names for some public functions I'm about to add.
* Implement 'notmuch dump'.Gravatar Carl Worth2009-10-20
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").