summaryrefslogtreecommitdiff
path: root/message.cc
Commit message (Collapse)AuthorAge
* Add -Wmising-declarations and fix warnings.Carl Worth2009-10-25
| | | | Wow, lots of missing 'static' on internal functions.
* Change database to store only a single thread ID per message.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.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_idCarl Worth2009-10-25
| | | | What a great feeling to remove an XXX comment.
* Drop the storage of thread ID(s) in a value.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_tCarl 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_tCarl 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.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".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.ccCarl 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.Carl Worth2009-10-23
| | | | This will be a nice safety check for internal sanity.
* Add notmuch_database_set_timestamp and notmuch_database_get_timestampCarl 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.sizeCarl 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.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 IDCarl 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_idCarl 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.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_tCarl 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_filenameCarl 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.ccCarl 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 interfacesCarl 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.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()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_tagCarl 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 resultCarl 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_messageCarl 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 functionCarl 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.ccCarl 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.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.Carl Worth2009-10-20
| | | | | I want to reserve the _destroy names for some public functions I'm about to add.
* Implement 'notmuch dump'.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").