]> git.notmuchmail.org Git - notmuch/commitdiff
ruby: Add bindings for notmuch_thread_get_messages
authorAustin Clements <amdragon@MIT.EDU>
Sun, 25 Nov 2012 04:57:07 +0000 (23:57 -0500)
committerDavid Bremner <bremner@debian.org>
Tue, 19 Feb 2013 00:23:40 +0000 (20:23 -0400)
bindings/ruby/defs.h
bindings/ruby/init.c
bindings/ruby/thread.c

index fe81b3f96de5c86b1f4e28fdab3ed1f47d44236a..5b44585a6ad0cc329d311975a7aa4470a6a890ee 100644 (file)
@@ -261,6 +261,9 @@ notmuch_rb_thread_get_total_messages (VALUE self);
 VALUE
 notmuch_rb_thread_get_toplevel_messages (VALUE self);
 
 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
 notmuch_rb_thread_get_matched_messages (VALUE self);
 
index f4931d34a4f39cf321e225e6f21690328654dad9..663271d4e598ed46d60cec5467d4e82f127d8729 100644 (file)
@@ -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, "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 */
     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 */
index efe5aaf7c56a8946325bd71161d14325e834aaa5..56616d9fcf1446c954cdc6608b6d1d8a9ab2e9a2 100644 (file)
@@ -91,6 +91,26 @@ notmuch_rb_thread_get_toplevel_messages (VALUE self)
     return Data_Wrap_Struct (notmuch_rb_cMessages, NULL, NULL, messages);
 }
 
     return Data_Wrap_Struct (notmuch_rb_cMessages, NULL, NULL, messages);
 }
 
+/*
+ * 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
  *
 /*
  * call-seq: THREAD.matched_messages => fixnum
  *