]> git.cworth.org Git - notmuch/blob - bindings/ruby/defs.h
ruby: simplify data get helper
[notmuch] / bindings / ruby / defs.h
1 /* The Ruby interface to the notmuch mail library
2  *
3  * Copyright © 2010, 2011, 2012 Ali Polatel
4  *
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.
9  *
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.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see https://www.gnu.org/licenses/ .
17  *
18  * Author: Ali Polatel <alip@exherbo.org>
19  */
20
21 #ifndef DEFS_H
22 #define DEFS_H
23
24 #include <notmuch.h>
25 #include <ruby.h>
26
27 extern VALUE notmuch_rb_cDatabase;
28 extern VALUE notmuch_rb_cDirectory;
29 extern VALUE notmuch_rb_cFileNames;
30 extern VALUE notmuch_rb_cQuery;
31 extern VALUE notmuch_rb_cThreads;
32 extern VALUE notmuch_rb_cThread;
33 extern VALUE notmuch_rb_cMessages;
34 extern VALUE notmuch_rb_cMessage;
35 extern VALUE notmuch_rb_cTags;
36
37 extern VALUE notmuch_rb_eBaseError;
38 extern VALUE notmuch_rb_eDatabaseError;
39 extern VALUE notmuch_rb_eMemoryError;
40 extern VALUE notmuch_rb_eReadOnlyError;
41 extern VALUE notmuch_rb_eXapianError;
42 extern VALUE notmuch_rb_eFileError;
43 extern VALUE notmuch_rb_eFileNotEmailError;
44 extern VALUE notmuch_rb_eNullPointerError;
45 extern VALUE notmuch_rb_eTagTooLongError;
46 extern VALUE notmuch_rb_eUnbalancedFreezeThawError;
47 extern VALUE notmuch_rb_eUnbalancedAtomicError;
48
49 extern ID ID_call;
50 extern ID ID_db_create;
51 extern ID ID_db_mode;
52
53 /* RSTRING_PTR() is new in ruby-1.9 */
54 #if !defined(RSTRING_PTR)
55 # define RSTRING_PTR(v) (RSTRING((v))->ptr)
56 #endif /* !defined (RSTRING_PTR) */
57
58 #define Data_Get_Notmuch_Object(obj, message, ptr)              \
59     do {                                                        \
60         (ptr) = rb_data_object_get ((obj));                     \
61         if (!(ptr))                                             \
62         rb_raise (rb_eRuntimeError, (message));                 \
63     } while (0)
64
65 #define Data_Get_Notmuch_Database(obj, ptr) \
66     Data_Get_Notmuch_Object ((obj), "database closed", (ptr))
67
68 #define Data_Get_Notmuch_Directory(obj, ptr) \
69     Data_Get_Notmuch_Object ((obj), "directory destroyed", (ptr))
70
71 #define Data_Get_Notmuch_FileNames(obj, ptr) \
72     Data_Get_Notmuch_Object ((obj), "filenames destroyed", (ptr))
73
74 #define Data_Get_Notmuch_Query(obj, ptr) \
75     Data_Get_Notmuch_Object ((obj), "query destroyed", (ptr))
76
77 #define Data_Get_Notmuch_Threads(obj, ptr) \
78     Data_Get_Notmuch_Object ((obj), "threads destroyed", (ptr))
79
80 #define Data_Get_Notmuch_Messages(obj, ptr) \
81     Data_Get_Notmuch_Object ((obj), "messages destroyed", (ptr))
82
83 #define Data_Get_Notmuch_Thread(obj, ptr) \
84     Data_Get_Notmuch_Object ((obj), "thread destroyed", (ptr))
85
86 #define Data_Get_Notmuch_Message(obj, ptr) \
87     Data_Get_Notmuch_Object ((obj), "message destroyed", (ptr))
88
89 #define Data_Get_Notmuch_Tags(obj, ptr) \
90     Data_Get_Notmuch_Object ((obj), "tags destroyed", (ptr))
91
92 /* status.c */
93 void
94 notmuch_rb_status_raise (notmuch_status_t status);
95
96 /* database.c */
97 VALUE
98 notmuch_rb_database_alloc (VALUE klass);
99
100 VALUE
101 notmuch_rb_database_initialize (int argc, VALUE *argv, VALUE klass);
102
103 VALUE
104 notmuch_rb_database_open (int argc, VALUE *argv, VALUE klass);
105
106 VALUE
107 notmuch_rb_database_close (VALUE self);
108
109 VALUE
110 notmuch_rb_database_path (VALUE self);
111
112 VALUE
113 notmuch_rb_database_version (VALUE self);
114
115 VALUE
116 notmuch_rb_database_needs_upgrade (VALUE self);
117
118 VALUE
119 notmuch_rb_database_upgrade (VALUE self);
120
121 VALUE
122 notmuch_rb_database_begin_atomic (VALUE self);
123
124 VALUE
125 notmuch_rb_database_end_atomic (VALUE self);
126
127 VALUE
128 notmuch_rb_database_get_directory (VALUE self, VALUE pathv);
129
130 VALUE
131 notmuch_rb_database_add_message (VALUE self, VALUE pathv);
132
133 VALUE
134 notmuch_rb_database_remove_message (VALUE self, VALUE pathv);
135
136 VALUE
137 notmuch_rb_database_find_message (VALUE self, VALUE idv);
138
139 VALUE
140 notmuch_rb_database_find_message_by_filename (VALUE self, VALUE pathv);
141
142 VALUE
143 notmuch_rb_database_get_all_tags (VALUE self);
144
145 VALUE
146 notmuch_rb_database_query_create (VALUE self, VALUE qstrv);
147
148 /* directory.c */
149 VALUE
150 notmuch_rb_directory_destroy (VALUE self);
151
152 VALUE
153 notmuch_rb_directory_get_mtime (VALUE self);
154
155 VALUE
156 notmuch_rb_directory_set_mtime (VALUE self, VALUE mtimev);
157
158 VALUE
159 notmuch_rb_directory_get_child_files (VALUE self);
160
161 VALUE
162 notmuch_rb_directory_get_child_directories (VALUE self);
163
164 /* filenames.c */
165 VALUE
166 notmuch_rb_filenames_destroy (VALUE self);
167
168 VALUE
169 notmuch_rb_filenames_each (VALUE self);
170
171 /* query.c */
172 VALUE
173 notmuch_rb_query_destroy (VALUE self);
174
175 VALUE
176 notmuch_rb_query_get_sort (VALUE self);
177
178 VALUE
179 notmuch_rb_query_set_sort (VALUE self, VALUE sortv);
180
181 VALUE
182 notmuch_rb_query_get_string (VALUE self);
183
184 VALUE
185 notmuch_rb_query_add_tag_exclude (VALUE self, VALUE tagv);
186
187 VALUE
188 notmuch_rb_query_set_omit_excluded (VALUE self, VALUE omitv);
189
190 VALUE
191 notmuch_rb_query_search_threads (VALUE self);
192
193 VALUE
194 notmuch_rb_query_search_messages (VALUE self);
195
196 VALUE
197 notmuch_rb_query_count_messages (VALUE self);
198
199 VALUE
200 notmuch_rb_query_count_threads (VALUE self);
201
202 /* threads.c */
203 VALUE
204 notmuch_rb_threads_destroy (VALUE self);
205
206 VALUE
207 notmuch_rb_threads_each (VALUE self);
208
209 /* messages.c */
210 VALUE
211 notmuch_rb_messages_destroy (VALUE self);
212
213 VALUE
214 notmuch_rb_messages_each (VALUE self);
215
216 VALUE
217 notmuch_rb_messages_collect_tags (VALUE self);
218
219 /* thread.c */
220 VALUE
221 notmuch_rb_thread_destroy (VALUE self);
222
223 VALUE
224 notmuch_rb_thread_get_thread_id (VALUE self);
225
226 VALUE
227 notmuch_rb_thread_get_total_messages (VALUE self);
228
229 VALUE
230 notmuch_rb_thread_get_toplevel_messages (VALUE self);
231
232 VALUE
233 notmuch_rb_thread_get_messages (VALUE self);
234
235 VALUE
236 notmuch_rb_thread_get_matched_messages (VALUE self);
237
238 VALUE
239 notmuch_rb_thread_get_authors (VALUE self);
240
241 VALUE
242 notmuch_rb_thread_get_subject (VALUE self);
243
244 VALUE
245 notmuch_rb_thread_get_oldest_date (VALUE self);
246
247 VALUE
248 notmuch_rb_thread_get_newest_date (VALUE self);
249
250 VALUE
251 notmuch_rb_thread_get_tags (VALUE self);
252
253 /* message.c */
254 VALUE
255 notmuch_rb_message_destroy (VALUE self);
256
257 VALUE
258 notmuch_rb_message_get_message_id (VALUE self);
259
260 VALUE
261 notmuch_rb_message_get_thread_id (VALUE self);
262
263 VALUE
264 notmuch_rb_message_get_replies (VALUE self);
265
266 VALUE
267 notmuch_rb_message_get_filename (VALUE self);
268
269 VALUE
270 notmuch_rb_message_get_filenames (VALUE self);
271
272 VALUE
273 notmuch_rb_message_get_flag (VALUE self, VALUE flagv);
274
275 VALUE
276 notmuch_rb_message_set_flag (VALUE self, VALUE flagv, VALUE valuev);
277
278 VALUE
279 notmuch_rb_message_get_date (VALUE self);
280
281 VALUE
282 notmuch_rb_message_get_header (VALUE self, VALUE headerv);
283
284 VALUE
285 notmuch_rb_message_get_tags (VALUE self);
286
287 VALUE
288 notmuch_rb_message_add_tag (VALUE self, VALUE tagv);
289
290 VALUE
291 notmuch_rb_message_remove_tag (VALUE self, VALUE tagv);
292
293 VALUE
294 notmuch_rb_message_remove_all_tags (VALUE self);
295
296 VALUE
297 notmuch_rb_message_maildir_flags_to_tags (VALUE self);
298
299 VALUE
300 notmuch_rb_message_tags_to_maildir_flags (VALUE self);
301
302 VALUE
303 notmuch_rb_message_freeze (VALUE self);
304
305 VALUE
306 notmuch_rb_message_thaw (VALUE self);
307
308 /* tags.c */
309 VALUE
310 notmuch_rb_tags_destroy (VALUE self);
311
312 VALUE
313 notmuch_rb_tags_each (VALUE self);
314
315 /* init.c */
316 void
317 Init_notmuch (void);
318
319 #endif