1 /* The Ruby interface to the notmuch mail library
3 * Copyright © 2010 Ali Polatel
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see http://www.gnu.org/licenses/ .
18 * Author: Ali Polatel <alip@exherbo.org>
24 * call-seq: THREAD.destroy => nil
26 * Destroys the thread, freeing all resources allocated for it.
29 notmuch_rb_thread_destroy(VALUE self)
31 notmuch_thread_t *thread;
33 Data_Get_Struct(self, notmuch_thread_t, thread);
35 notmuch_thread_destroy(thread);
41 * call-seq: THREAD.thread_id => String
43 * Returns the thread id
46 notmuch_rb_thread_get_thread_id(VALUE self)
49 notmuch_thread_t *thread;
51 Data_Get_Struct(self, notmuch_thread_t, thread);
53 tid = notmuch_thread_get_thread_id(thread);
55 return rb_str_new2(tid);
59 * call-seq: THREAD.total_messages => fixnum
61 * Returns the number of total messages
64 notmuch_rb_thread_get_total_messages(VALUE self)
66 notmuch_thread_t *thread;
68 Data_Get_Struct(self, notmuch_thread_t, thread);
70 return INT2FIX(notmuch_thread_get_total_messages(thread));
74 * call-seq: THREAD.toplevel_messages => MESSAGES
76 * Get a Notmuch::Messages iterator for the top level messages in thread.
79 notmuch_rb_thread_get_toplevel_messages(VALUE self)
81 notmuch_messages_t *messages;
82 notmuch_thread_t *thread;
84 Data_Get_Struct(self, notmuch_thread_t, thread);
86 messages = notmuch_thread_get_toplevel_messages(thread);
88 rb_raise(notmuch_rb_eMemoryError, "Out of memory");
90 return Data_Wrap_Struct(notmuch_rb_cMessages, NULL, NULL, messages);
94 * call-seq: THREAD.matched_messages => fixnum
96 * Get the number of messages in thread that matched the search
99 notmuch_rb_thread_get_matched_messages(VALUE self)
101 notmuch_thread_t *thread;
103 Data_Get_Struct(self, notmuch_thread_t, thread);
105 return INT2FIX(notmuch_thread_get_matched_messages(thread));
109 * call-seq: THREAD.authors => String
111 * Get a comma-separated list of the names of the authors.
114 notmuch_rb_thread_get_authors(VALUE self)
117 notmuch_thread_t *thread;
119 Data_Get_Struct(self, notmuch_thread_t, thread);
121 authors = notmuch_thread_get_authors(thread);
123 return rb_str_new2(authors);
127 * call-seq: THREAD.subject => String
129 * Returns the subject of the thread
132 notmuch_rb_thread_get_subject(VALUE self)
135 notmuch_thread_t *thread;
137 Data_Get_Struct(self, notmuch_thread_t, thread);
139 subject = notmuch_thread_get_subject(thread);
141 return rb_str_new2(subject);
145 * call-seq: THREAD.oldest_date => Fixnum
147 * Get the date of the oldest message in thread.
150 notmuch_rb_thread_get_oldest_date(VALUE self)
152 notmuch_thread_t *thread;
154 Data_Get_Struct(self, notmuch_thread_t, thread);
156 return UINT2NUM(notmuch_thread_get_oldest_date(thread));
160 * call-seq: THREAD.newest_date => fixnum
162 * Get the date of the newest message in thread.
165 notmuch_rb_thread_get_newest_date(VALUE self)
167 notmuch_thread_t *thread;
169 Data_Get_Struct(self, notmuch_thread_t, thread);
171 return UINT2NUM(notmuch_thread_get_newest_date(thread));
175 * call-seq: THREAD.tags => TAGS
177 * Get a Notmuch::Tags iterator for the tags of the thread
180 notmuch_rb_thread_get_tags(VALUE self)
182 notmuch_thread_t *thread;
183 notmuch_tags_t *tags;
185 Data_Get_Struct(self, notmuch_thread_t, thread);
187 tags = notmuch_thread_get_tags(thread);
189 rb_raise(notmuch_rb_eMemoryError, "Out of memory");
191 return Data_Wrap_Struct(notmuch_rb_cTags, NULL, NULL, tags);