]> git.cworth.org Git - notmuch/commitdiff
Merge remote branch 'origin/master' into vim
authorBart Trojanowski <bart@jukie.net>
Fri, 27 Nov 2009 22:49:54 +0000 (17:49 -0500)
committerBart Trojanowski <bart@jukie.net>
Fri, 27 Nov 2009 22:49:54 +0000 (17:49 -0500)
1  2 
lib/message.cc
lib/notmuch.h

diff --combined lib/message.cc
index e0834f1c7816c6c66a9f0f4286ce33ef0b117f3c,a410394d3d5ac8c2d7772a6b3d1d65762c24ed85..b708c1810fd6682a7f9f3bd31207df4da7a69b23
@@@ -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)
  {
  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 3974820c0d3573305f8b5a168e8a414fd357bdfa,9fa2770116f1041b4067bd2646a6b16d330f6910..e4f399291689d3d533a2aab90fe79d97159e41b8
@@@ -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