]> git.notmuchmail.org Git - notmuch/commitdiff
lib: Add an iterator over all messages in a thread
authorAustin Clements <amdragon@MIT.EDU>
Sun, 25 Nov 2012 04:57:05 +0000 (23:57 -0500)
committerDavid Bremner <bremner@debian.org>
Tue, 19 Feb 2013 00:20:59 +0000 (20:20 -0400)
Previously, getting the list of all messages in a thread required
recursively traversing the thread's message hierarchy, which was both
difficult and resulted in messages being out of order.  This adds a
public function to retrieve an iterator over all of the messages in a
thread in oldest-first order.

lib/notmuch.h
lib/thread.cc

index 3633bedde20acafc064b62a52f319dcdde153111..373933677772234958a494eea03c8a18e0d4ae3f 100644 (file)
@@ -719,20 +719,21 @@ int
 notmuch_thread_get_total_messages (notmuch_thread_t *thread);
 
 /* Get a notmuch_messages_t iterator for the top-level messages in
- * 'thread'.
+ * 'thread' in oldest-first order.
  *
  * This iterator will not necessarily iterate over all of the messages
  * in the thread. It will only iterate over the messages in the thread
  * which are not replies to other messages in the thread.
- *
- * To iterate over all messages in the thread, the caller will need to
- * iterate over the result of notmuch_message_get_replies for each
- * top-level message (and do that recursively for the resulting
- * messages, etc.).
  */
 notmuch_messages_t *
 notmuch_thread_get_toplevel_messages (notmuch_thread_t *thread);
 
+/* Get a notmuch_thread_t iterator for all messages in 'thread' in
+ * oldest-first order.
+ */
+notmuch_messages_t *
+notmuch_thread_get_messages (notmuch_thread_t *thread);
+
 /* Get the number of messages in 'thread' that matched the search.
  *
  * This count includes only the messages in this thread that were
index 45a7d1d023dcdb4b86395475e752760ca2c6a6eb..c126aac8cc8b945e9018f7505f7910174c83535e 100644 (file)
@@ -508,6 +508,12 @@ notmuch_thread_get_toplevel_messages (notmuch_thread_t *thread)
     return _notmuch_messages_create (thread->toplevel_list);
 }
 
+notmuch_messages_t *
+notmuch_thread_get_messages (notmuch_thread_t *thread)
+{
+    return _notmuch_messages_create (thread->message_list);
+}
+
 const char *
 notmuch_thread_get_thread_id (notmuch_thread_t *thread)
 {