aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
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-23add_message: Re-order the code a bit (find message-id first).Carl Worth
We're preparing for being able to deal with files with duplicate message IDs here. The plan is to create a notmuch_message_t object in add_message that may or may not reference a document that exists in the database. So to do this, we have to find the message ID before we do any manipulation of the doc.
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-23add_message: Rename message to message_fileCarl Worth
I still don't like the name message_file at all, but we're about to start using a notmuch_message_t in this function so we need to do something to keep the identifiers separate for now. Eventually, it probably makes sense to push the message-parsing code from database.cc to message.cc.
2009-10-22Prevent that last bug from reoccurring.Carl Worth
It's even enough to check if a "missing" header was accidentally left off the list in the call to restrict_headers. (And it's cheap since we only check in case no such header was found in the message.)
2009-10-22Don't forget the "to" header when restrict parsing to certain headersCarl Worth
We recently started discarding files as "not email" if they have none of Subject, From, nor To. Apaprently, my mail collection contains a number of messages that I sent, that are saved without Subject and From, (perhaps these were drafts?). Anyway, it's fortunate I had those since they alerted me to this bug, where we were not parsing the "To" header in some cases.
2009-10-22Fix missing error check.Carl Worth
The notmuch_message_file_open function is perfectly capable of returning NULL. So check for it.
2009-10-22Generate message ID (using SHA1) when a mail message contains none.Carl Worth
This is important as we're using the message ID as the unique key in our database. So previously, all messages with no message ID would be treated as the same message---not good at all.
2009-10-21Rename sha1.c to libsha1.cCarl Worth
This way both the .c and .h files have the same name, and all of the code imported from the "libsha1" implementation is in filenames matching libsha1.*. This also gives me room to make my own notmuch_sha1 wrapper functions in sha1.c.
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-21Bring back the insert_thread_id function.Carl Worth
We deleted this in favor of our fancy new thread_ids iterator from the message object. But one of the previous callers of insert_thread_id isn't using notmuch_message_t yet. I made the mistake of thinking I could just call g_hash_table_insert directly, but the problem was that nobody was splitting up the thread_id string at its commas. So with this, we were inserting bogus comma-separated IDs into the hash table, so thread_id values were ballooning out of control. Should be much better now.
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-21List a few more co-conspirators.Carl Worth
Keith's name already shows up in the git log, so it would be wrong to not mention him. And Martin and Jamey have been helpful in discussions about what an ideal mail system would look like.
2009-10-21Add an AUTHORS file.Carl Worth
Now that I've copied in another source file from someone else, I want to be sure I'm keeping a good list of everyone who has helped.
2009-10-21Add sha1.c and libsha1.h for doing SHA-1-based message-ID generation.Mikhail Gusarov
This code comes courtesy of Brian Gladman and Mikhail Gusarov. Both files are available under the GPL and were downloaded as version 0.2 of libsha1 from git://github.com/dottedmag/libsha1.git with the following commit: commit d0f0e7e0dc5ce2d58972cb5a492183c0d4e58433 Author: Mikhail Gusarov <dottedmag@dottedmag.net> Date: Mon Oct 20 22:38:47 2008 +0700 Version bump. Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
2009-10-21Add copy of GNU General Public License (version 3).Carl Worth
All the files were already advertising the license, but we didn't actually have a copy of the license in the repository until now.
2009-10-21Add notmuch_status_to_string function.Carl Worth
Be kind and let the user print error messages, not just error codes.
2009-10-21Implement "notmuch restore".Carl Worth
It's pretty easy to do with all the right infrastructure in place. Now that I can get my tags from sup to notmuch, maybe I'll be able to start reading mail again.
2009-10-21Pull out a chomp_newline function from "notmuch setup"Carl Worth
We'll want this same thing with "notmuch restore", (and really anything using getline).
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-private.h: Move NOTMUCH_BEGIN_DECLS earlierCarl Worth
We actually need this before the include of xutil.h, but it was previously stuck randomly among various system includes. Instead, put it at the top, right after include the notmuch.h header that defines it.
2009-10-21notmuch_query_search: Clarify the documentation.Carl Worth
This is where we wanted to put the note to recommend the user call notmuch_message_destroy if the lifetime of the message is much shorter than the lifetime of the query. (Somehow this had ended up in the documentation of notmuch_message_get_tags before.)
2009-10-21notmuch.h: Fix some copy-paste errors in the documentaton.Carl Worth
In several places we had "results" where "tags" was intended. It actually read fine in some cases, but this is still better.
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-21Add wrappers for regcomp and regexec to xutil.c.Carl Worth
These will be handy for some parsing.
2009-10-21Rename NOTMUCH_MAX_TERM to NOTMUCH_TERM_MAXCarl Worth
Just better consistency with our naming schemes.
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-21notmuch dump: Fix to print spaces between tags.Carl Worth
Simple little bug here made all the tags run together.
2009-10-21Convert notmuch_database_t to start using talloc.Carl Worth
This will be handy as we can hang future talloc allocations off of the datbase now.
2009-10-21Move declarations for xutil.c from notmuch-private to new xutil.h.Carl Worth
The motivation here is that our top-level notmuch.c main program wants to start using these, but we don't want it to see into notmuch-private.h, (since our main program is a test vehicle for the "public" notmuch interface in notmuch.h).
2009-10-21notmuch dump: Fix buffer overrun in error message.Carl Worth
Just a little bug I noticed while editing nearby code.
2009-10-21notmuch setup: Collapse internal whitespace within message-idCarl Worth
I'm too lazy to see what the RFC says, but I know that having whitespace inside a message-ID is sure to confuse things. And besides, this makes things more compatible with sup so that I have some hope of importing sup labels.
2009-10-21notmuch dump: Fix the sorting of results.Carl Worth
To properly support sorting in notmuch_query we know use an Enquire object. We also throw in a QueryParser too, so we're really close to being able to support arbitrary full-text searches. I took a look at the supported QueryParser syntax and chose a set of flags for everything I like, (such as supporting Boolean operators in either case ("AND" or "and"), supporting phrase searching, supporting + and - to include/preclude terms, and supporting a trailing * on any term as a wildcard).
2009-10-21add_message: Add a type:mail ("Kmail") term to all documents.Carl Worth
This gives us an easy way to specify "all mail messages" in a search query. We simply look for this term.
2009-10-21notmuch setup: Print a few protecting spaces after progress reports.Carl Worth
This is to help keep the report looking clean when a new report is shorter than a previous reports, (say, when crossing the boundary from over one minute remaining to less than one minute remaining). This used to be here, but I must have accidentally dropped it when reformatting the progress report recently.
2009-10-20.gitignore: Ignore generated file Makefile.depCarl Worth
Forgot to add this when I first add dependency checking to the Makefile.
2009-10-20database: Remove two little bits of dead code.Carl Worth
2009-10-20query: Remove the magic NOTMUCH_QUERY_ALLCarl Worth
Using the address of a static char* was clever, but really unnecessary. An empty string is much less magic, and even easier to understand as the way to query everything from the database.
2009-10-20notmuch dump: Free each message as it's used.Carl Worth
Previously we were leaking[*] memory in that the memory footprint of a "notmuch dump" run would continue to grow until the output was complete, and then finally all the memory would be freed. Now, the memory footprint is small and constant, O(1) rather than O(n) in the number of messages. [*] Not leaking in a valgrind sense---every byte was still carefully being accounted for and freed eventually.
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").
2009-10-20Rename private notmuch_message_t to notmuch_message_file_tCarl Worth
This is in preparation for a new, public notmuch_message_t. Eventually, the public notmuch_message_t is going to grow enough features to need to be file-backed and will likely need everything that's now in message-file.c. So we may fold these back into one object/implementation in the future.
2009-10-20Makefile: Add automatic dependency tracking to the Makefile.Carl Worth
With this, I really don't miss anything from automake.
2009-10-20notmuch: Fix setup so that accepting the default mail path works.Carl Worth
The recent change from GIOChannel to getline, (with a semantic change of the newline terminator now being included in the result that setup_command sees), broke this.
2009-10-20message: Use g_hash_table_destroy instead of g_hash_table_unrefCarl Worth
I'm trying to chase down 3 still-reachable pointers to glib hash tables. This change didn't help with that, but I think destroy might be a better semantic match for what I actually want. (It shouldn't matter though since I never take any additional references.)
2009-10-20add_message: Fix memory leak of thread_ids GPtrArray.Carl Worth
We were properly feeing this memory when the thread-ids list was not empty, but leaking it when it was. Thanks, of course, to valgrind along with the G_SLICE=always-malloc environment variable which makes leak checking with glib almost bearable.