From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id D2574431FAF for ; Sat, 24 Nov 2012 20:57:20 -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 17v9DrMx3V9J for ; Sat, 24 Nov 2012 20:57:20 -0800 (PST) Received: from dmz-mailsec-scanner-8.mit.edu (DMZ-MAILSEC-SCANNER-8.MIT.EDU [18.7.68.37]) by olra.theworths.org (Postfix) with ESMTP id 6ED8C431FB6 for ; Sat, 24 Nov 2012 20:57:19 -0800 (PST) X-AuditID: 12074425-b7fcc6d00000091f-4b-50b1a52d3832 Received: from mailhub-auth-3.mit.edu ( [18.9.21.43]) by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP id 68.2A.02335.D25A1B05; Sat, 24 Nov 2012 23:57:17 -0500 (EST) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id qAP4vHVF018858; Sat, 24 Nov 2012 23:57:17 -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 qAP4vECf000087 (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 1TcUHK-0003Zy-1g; Sat, 24 Nov 2012 23:57:14 -0500 From: Austin Clements To: notmuch@notmuchmail.org Subject: [PATCH 6/6] ruby: Add bindings for notmuch_thread_get_messages Date: Sat, 24 Nov 2012 23:57:07 -0500 Message-Id: <1353819427-13182-7-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+NgFtrDIsWRmVeSWpSXmKPExsUixCmqrau7dGOAwcrvOhar5/JYXL85k9mB yWPnrLvsHs9W3WIOYIrisklJzcksSy3St0vgyji/+zt7wV+hio61B9kaGH/zdzFyckgImEg0 fJzABmGLSVy4tx7I5uIQEtjHKPH++nZmCGcDo8TSh7NZIJxHTBLPPj+EKpvLKPFi+gIWkH42 AQ2JbfuXM4LYIgLSEjvvzmYFsZkFHCU+718EtkNYwF3i+rsNYPUsAqoSS/uPgcV5BRwklvx+ yw5xh6JE9zOQmzg4OIF6G/fKgYSFgEpu/ZvEPIGRfwEjwypG2ZTcKt3cxMyc4tRk3eLkxLy8 1CJdC73czBK91JTSTYygQGJ3Ud3BOOGQ0iFGAQ5GJR7eG4kbA4RYE8uKK3MPMUpyMCmJ8mYu AgrxJeWnVGYkFmfEF5XmpBYfYpTgYFYS4bVWBcrxpiRWVqUW5cOkpDlYlMR5b6Tc9BcSSE8s Sc1OTS1ILYLJynBwKEnw3loM1ChYlJqeWpGWmVOCkGbi4AQZzgM0XHQJyPDigsTc4sx0iPwp RkUpcd7PIM0CIImM0jy4Xlikv2IUB3pFmJcJpJ0HmCTgul8BDWYCGvx09jqQwSWJCCmpBsZs kT0imarVb6WEJeX2dhkvDeCe8CqsabXIJdHVfI6aGT8SLfe9dq1mava/kCGp5V+fUxbz06rp /fONt2Uf3V/6uuqpg9WMivXP7J7zzmOz2zJ325XT+yPvM32Zfokjflf2pSh/iS63fZw9hSck TQ5unnWt5tqJTkvvw6uFXCTXh8jE9LEsnqHEUpyRaKjFXFScCABA5MqNzwIAAA== 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:21 -0000 --- bindings/ruby/defs.h | 3 +++ bindings/ruby/init.c | 1 + bindings/ruby/thread.c | 20 ++++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/bindings/ruby/defs.h b/bindings/ruby/defs.h index fe81b3f..5b44585 100644 --- a/bindings/ruby/defs.h +++ b/bindings/ruby/defs.h @@ -262,6 +262,9 @@ VALUE notmuch_rb_thread_get_toplevel_messages (VALUE self); VALUE +notmuch_rb_thread_get_messages (VALUE self); + +VALUE notmuch_rb_thread_get_matched_messages (VALUE self); VALUE diff --git a/bindings/ruby/init.c b/bindings/ruby/init.c index f4931d3..663271d 100644 --- a/bindings/ruby/init.c +++ b/bindings/ruby/init.c @@ -306,6 +306,7 @@ Init_notmuch (void) rb_define_method (notmuch_rb_cThread, "thread_id", notmuch_rb_thread_get_thread_id, 0); /* in thread.c */ rb_define_method (notmuch_rb_cThread, "total_messages", notmuch_rb_thread_get_total_messages, 0); /* in thread.c */ rb_define_method (notmuch_rb_cThread, "toplevel_messages", notmuch_rb_thread_get_toplevel_messages, 0); /* in thread.c */ + rb_define_method (notmuch_rb_cThread, "messages", notmuch_rb_thread_get_messages, 0); /* in thread.c */ rb_define_method (notmuch_rb_cThread, "matched_messages", notmuch_rb_thread_get_matched_messages, 0); /* in thread.c */ rb_define_method (notmuch_rb_cThread, "authors", notmuch_rb_thread_get_authors, 0); /* in thread.c */ rb_define_method (notmuch_rb_cThread, "subject", notmuch_rb_thread_get_subject, 0); /* in thread.c */ diff --git a/bindings/ruby/thread.c b/bindings/ruby/thread.c index efe5aaf..56616d9 100644 --- a/bindings/ruby/thread.c +++ b/bindings/ruby/thread.c @@ -92,6 +92,26 @@ notmuch_rb_thread_get_toplevel_messages (VALUE self) } /* + * call-seq: THREAD.messages => MESSAGES + * + * Get a Notmuch::Messages iterator for the all messages in thread. + */ +VALUE +notmuch_rb_thread_get_messages (VALUE self) +{ + notmuch_messages_t *messages; + notmuch_thread_t *thread; + + Data_Get_Notmuch_Thread (self, thread); + + messages = notmuch_thread_get_messages (thread); + if (!messages) + rb_raise (notmuch_rb_eMemoryError, "Out of memory"); + + return Data_Wrap_Struct (notmuch_rb_cMessages, NULL, NULL, messages); +} + +/* * call-seq: THREAD.matched_messages => fixnum * * Get the number of messages in thread that matched the search -- 1.7.10.4