Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id C7C7A431FBF for ; Sat, 24 Nov 2012 20:57:24 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wTEjIsKdfJZv for ; Sat, 24 Nov 2012 20:57:20 -0800 (PST) Received: from dmz-mailsec-scanner-4.mit.edu (DMZ-MAILSEC-SCANNER-4.MIT.EDU [18.9.25.15]) by olra.theworths.org (Postfix) with ESMTP id 726D6431FBD for ; Sat, 24 Nov 2012 20:57:19 -0800 (PST) X-AuditID: 1209190f-b7f636d00000095b-63-50b1a52e591f Received: from mailhub-auth-1.mit.edu ( [18.9.21.35]) by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP id DC.2B.02395.E25A1B05; Sat, 24 Nov 2012 23:57:18 -0500 (EST) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id qAP4vG10000523; Sat, 24 Nov 2012 23:57:16 -0500 Received: from drake.dyndns.org (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com [209.6.116.242]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id qAP4vEGI000085 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Sat, 24 Nov 2012 23:57:16 -0500 (EST) Received: from amthrax by drake.dyndns.org with local (Exim 4.77) (envelope-from ) id 1TcUHJ-0003Zs-VB; Sat, 24 Nov 2012 23:57:13 -0500 From: Austin Clements To: notmuch@notmuchmail.org Subject: [PATCH 4/6] lib: Add an iterator over all messages in a thread Date: Sat, 24 Nov 2012 23:57:05 -0500 Message-Id: <1353819427-13182-5-git-send-email-amdragon@mit.edu> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1353819427-13182-1-git-send-email-amdragon@mit.edu> References: <1353819427-13182-1-git-send-email-amdragon@mit.edu> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrOIsWRmVeSWpSXmKPExsUixCmqrKu3dGOAwfdrrBar5/JYXL85k9mB yWPnrLvsHs9W3WIOYIrisklJzcksSy3St0vgynh64iZLwTuBirvnTzA3MD7n7WLk5JAQMJFo XtXHBGGLSVy4t54NxBYS2Mco8faUHYS9gVFiTZdbFyMXkP2ISeL09m5miMRcRonXe+pAbDYB DYlt+5czgtgiAtISO+/OZgWxmQUcJT7vXwQ0lINDWMBd4s1lPxCTRUBV4vgisCm8Ag4SE25f ZIY4QVGi+9kEsGpOoM7GvXIQixwkbv2bxDyBkX8BI8MqRtmU3Crd3MTMnOLUZN3i5MS8vNQi XRO93MwSvdSU0k2M4PCR5N/B+O2g0iFGAQ5GJR7eG4kbA4RYE8uKK3MPMUpyMCmJ8mYuAgrx JeWnVGYkFmfEF5XmpBYfYpTgYFYS4bVWBcrxpiRWVqUW5cOkpDlYlMR5r6bc9BcSSE8sSc1O TS1ILYLJynBwKEnwBi0BahQsSk1PrUjLzClBSDNxcIIM5wEaLgpSw1tckJhbnJkOkT/FqCgl zmsOkhAASWSU5sH1wuL7FaM40CvCvA4gVTzA1ADX/QpoMBPQ4Kez14EMLklESEk1MHrPXqzM xWijevHLJNVcfYmJyx4Flx7SSumLiO5d/p5tk6Deia2+e58/5bjJNOe8wpTIC7MNL+llnutZ fHiN9TdeliDm7S5OL39ouGYz7XS7NVnxzD/tT7au9YKRes0+Xg+etslnzJ0rrK/7w9p/u0/M W6vkg2m3nmgqHk8NzDvz6Qrb1Kj2K0osxRmJhlrMRcWJAGvN5J/KAgAA X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Nov 2012 04:57:25 -0000 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 | 13 +++++++------ lib/thread.cc | 6 ++++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/notmuch.h b/lib/notmuch.h index 3633bed..3739336 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -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 diff --git a/lib/thread.cc b/lib/thread.cc index 45a7d1d..c126aac 100644 --- a/lib/thread.cc +++ b/lib/thread.cc @@ -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) { -- 1.7.10.4