From: Bart Trojanowski Date: Fri, 27 Nov 2009 22:49:54 +0000 (-0500) Subject: Merge remote branch 'origin/master' into vim X-Git-Tag: debian/0.0+201001211401~43^2~1 X-Git-Url: http://rtime.felk.cvut.cz/gitweb/notmuch.git/commitdiff_plain/7a215c2de81e95798ecadd982eecf05e647c3988?hp=-c Merge remote branch 'origin/master' into vim --- 7a215c2de81e95798ecadd982eecf05e647c3988 diff --combined lib/message.cc index e0834f1c,a410394d..b708c181 --- a/lib/message.cc +++ b/lib/message.cc @@@ -37,7 -37,6 +37,7 @@@ struct _notmuch_message char *filename; notmuch_message_file_t *message_file; notmuch_message_list_t *replies; + unsigned long flags; Xapian::Document doc; }; @@@ -109,7 -108,6 +109,7 @@@ _notmuch_message_create (const void *ta message->doc_id = doc_id; message->frozen = 0; + message->flags = 0; /* Each of these will be lazily created as needed. */ message->message_id = NULL; @@@ -447,23 -445,6 +447,23 @@@ notmuch_message_get_filename (notmuch_m return message->filename; } +notmuch_bool_t +notmuch_message_get_flag (notmuch_message_t *message, + notmuch_message_flag_t flag) +{ + return message->flags & (1 << flag); +} + +void +notmuch_message_set_flag (notmuch_message_t *message, + notmuch_message_flag_t flag, notmuch_bool_t enable) +{ + if (enable) + message->flags |= (1 << flag); + else + message->flags &= ~(1 << flag); +} + time_t notmuch_message_get_date (notmuch_message_t *message) { @@@ -482,38 -463,10 +482,10 @@@ notmuch_tags_t * notmuch_message_get_tags (notmuch_message_t *message) { - const char *prefix = _find_prefix ("tag"); Xapian::TermIterator i, end; - notmuch_tags_t *tags; - std::string tag; - - /* Currently this iteration is written with the assumption that - * "tag" has a single-character prefix. */ - assert (strlen (prefix) == 1); - - tags = _notmuch_tags_create (message); - if (unlikely (tags == NULL)) - return NULL; - - i = message->doc.termlist_begin (); - end = message->doc.termlist_end (); - - i.skip_to (prefix); - - while (i != end) { - tag = *i; - - if (tag.empty () || tag[0] != *prefix) - break; - - _notmuch_tags_add_tag (tags, tag.c_str () + 1); - - i++; - } - - _notmuch_tags_prepare_iterator (tags); - - return tags; + i = message->doc.termlist_begin(); + end = message->doc.termlist_end(); + return _notmuch_convert_tags(message, i, end); } void diff --combined lib/notmuch.h index 3974820c,9fa27701..e4f39929 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@@ -280,6 -280,16 +280,16 @@@ notmuch_message_t notmuch_database_find_message (notmuch_database_t *database, const char *message_id); + /* Return a list of all tags found in the database. + * + * This function creates a list of all tags found in the database. The + * resulting list contains all tags from all messages found in the database. + * + * On error this function returns NULL. + */ + notmuch_tags_t * + notmuch_database_get_all_tags (notmuch_database_t *db); + /* Create a new query for 'database'. * * Here, 'database' should be an open database, (see @@@ -625,6 -635,21 +635,21 @@@ notmuch_messages_advance (notmuch_messa void notmuch_messages_destroy (notmuch_messages_t *messages); + /* Return a list of tags from all messages. + * + * The resulting list is guaranteed not to contain duplicated tags. + * + * WARNING: You can no longer iterate over messages after calling this + * function, because the iterator will point at the end of the list. + * We do not have a function to reset the iterator yet and the only + * way how you can iterate over the list again is to recreate the + * message list. + * + * The function returns NULL on error. + */ + notmuch_tags_t * + notmuch_messages_collect_tags (notmuch_messages_t *messages); + /* Get the message ID of 'message'. * * The returned string belongs to 'message' and as such, should not be @@@ -684,21 -709,6 +709,21 @@@ notmuch_message_get_replies (notmuch_me const char * notmuch_message_get_filename (notmuch_message_t *message); +/* Message flags */ +typedef enum _notmuch_message_flag { + NOTMUCH_MSG_FLAG_MATCHING_SEARCH, +} notmuch_message_flag_t; + +/* Get a value of a flag for the email corresponding to 'message'. */ +notmuch_bool_t +notmuch_message_get_flag (notmuch_message_t *message, + notmuch_message_flag_t flag); + +/* Set a value of a flag for the email corresponding to 'message'. */ +void +notmuch_message_set_flag (notmuch_message_t *message, + notmuch_message_flag_t flag, notmuch_bool_t value); + /* Get the date of 'message' as a time_t value. * * For the original textual representation of the Date header from the