1 /* The Ruby interface to the notmuch mail library
3 * Copyright © 2010, 2011 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_Notmuch_Thread (self, thread);
35 notmuch_thread_destroy (thread);
36 DATA_PTR (self) = NULL;
42 * call-seq: THREAD.thread_id => String
44 * Returns the thread id
47 notmuch_rb_thread_get_thread_id (VALUE self)
50 notmuch_thread_t *thread;
52 Data_Get_Notmuch_Thread (self, thread);
54 tid = notmuch_thread_get_thread_id (thread);
56 return rb_str_new2 (tid);
60 * call-seq: THREAD.total_messages => fixnum
62 * Returns the number of total messages
65 notmuch_rb_thread_get_total_messages (VALUE self)
67 notmuch_thread_t *thread;
69 Data_Get_Notmuch_Thread (self, thread);
71 return INT2FIX (notmuch_thread_get_total_messages (thread));
75 * call-seq: THREAD.toplevel_messages => MESSAGES
77 * Get a Notmuch::Messages iterator for the top level messages in thread.
80 notmuch_rb_thread_get_toplevel_messages (VALUE self)
82 notmuch_messages_t *messages;
83 notmuch_thread_t *thread;
85 Data_Get_Notmuch_Thread (self, thread);
87 messages = notmuch_thread_get_toplevel_messages (thread);
89 rb_raise (notmuch_rb_eMemoryError, "Out of memory");
91 return Data_Wrap_Struct (notmuch_rb_cMessages, NULL, NULL, messages);
95 * call-seq: THREAD.matched_messages => fixnum
97 * Get the number of messages in thread that matched the search
100 notmuch_rb_thread_get_matched_messages (VALUE self)
102 notmuch_thread_t *thread;
104 Data_Get_Notmuch_Thread (self, thread);
106 return INT2FIX (notmuch_thread_get_matched_messages (thread));
110 * call-seq: THREAD.authors => String
112 * Get a comma-separated list of the names of the authors.
115 notmuch_rb_thread_get_authors (VALUE self)
118 notmuch_thread_t *thread;
120 Data_Get_Notmuch_Thread (self, thread);
122 authors = notmuch_thread_get_authors (thread);
124 return rb_str_new2 (authors);
128 * call-seq: THREAD.subject => String
130 * Returns the subject of the thread
133 notmuch_rb_thread_get_subject (VALUE self)
136 notmuch_thread_t *thread;
138 Data_Get_Notmuch_Thread (self, thread);
140 subject = notmuch_thread_get_subject (thread);
142 return rb_str_new2 (subject);
146 * call-seq: THREAD.oldest_date => Fixnum
148 * Get the date of the oldest message in thread.
151 notmuch_rb_thread_get_oldest_date (VALUE self)
153 notmuch_thread_t *thread;
155 Data_Get_Notmuch_Thread (self, thread);
157 return UINT2NUM (notmuch_thread_get_oldest_date (thread));
161 * call-seq: THREAD.newest_date => fixnum
163 * Get the date of the newest message in thread.
166 notmuch_rb_thread_get_newest_date (VALUE self)
168 notmuch_thread_t *thread;
170 Data_Get_Notmuch_Thread (self, thread);
172 return UINT2NUM (notmuch_thread_get_newest_date (thread));
176 * call-seq: THREAD.tags => TAGS
178 * Get a Notmuch::Tags iterator for the tags of the thread
181 notmuch_rb_thread_get_tags (VALUE self)
183 notmuch_thread_t *thread;
184 notmuch_tags_t *tags;
186 Data_Get_Notmuch_Thread (self, thread);
188 tags = notmuch_thread_get_tags (thread);
190 rb_raise (notmuch_rb_eMemoryError, "Out of memory");
192 return Data_Wrap_Struct (notmuch_rb_cTags, NULL, NULL, tags);