]> git.notmuchmail.org Git - notmuch/blob - bindings/ruby/defs.h
Merge tag '0.18.2'
[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 http://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_Database(obj, ptr)                     \
59     do {                                                        \
60         Check_Type ((obj), T_DATA);                             \
61         if (DATA_PTR ((obj)) == NULL)                           \
62         rb_raise (rb_eRuntimeError, "database closed");         \
63         Data_Get_Struct ((obj), notmuch_database_t, (ptr));     \
64     } while (0)
65
66 #define Data_Get_Notmuch_Directory(obj, ptr)                    \
67     do {                                                        \
68         Check_Type ((obj), T_DATA);                             \
69         if (DATA_PTR ((obj)) == NULL)                           \
70         rb_raise (rb_eRuntimeError, "directory destroyed");     \
71         Data_Get_Struct ((obj), notmuch_directory_t, (ptr));    \
72     } while (0)
73
74 #define Data_Get_Notmuch_FileNames(obj, ptr)                    \
75     do {                                                        \
76         Check_Type ((obj), T_DATA);                             \
77         if (DATA_PTR ((obj)) == NULL)                           \
78         rb_raise (rb_eRuntimeError, "filenames destroyed");     \
79         Data_Get_Struct ((obj), notmuch_filenames_t, (ptr));    \
80     } while (0)
81
82 #define Data_Get_Notmuch_Query(obj, ptr)                        \
83     do {                                                        \
84         Check_Type ((obj), T_DATA);                             \
85         if (DATA_PTR ((obj)) == NULL)                           \
86         rb_raise (rb_eRuntimeError, "query destroyed");         \
87         Data_Get_Struct ((obj), notmuch_query_t, (ptr));        \
88     } while (0)
89
90 #define Data_Get_Notmuch_Threads(obj, ptr)                      \
91     do {                                                        \
92         Check_Type ((obj), T_DATA);                             \
93         if (DATA_PTR ((obj)) == NULL)                           \
94         rb_raise (rb_eRuntimeError, "threads destroyed");       \
95         Data_Get_Struct ((obj), notmuch_threads_t, (ptr));      \
96     } while (0)
97
98 #define Data_Get_Notmuch_Messages(obj, ptr)                     \
99     do {                                                        \
100         Check_Type ((obj), T_DATA);                             \
101         if (DATA_PTR ((obj)) == NULL)                           \
102         rb_raise (rb_eRuntimeError, "messages destroyed");      \
103         Data_Get_Struct ((obj), notmuch_messages_t, (ptr));     \
104     } while (0)
105
106 #define Data_Get_Notmuch_Thread(obj, ptr)                       \
107     do {                                                        \
108         Check_Type ((obj), T_DATA);                             \
109         if (DATA_PTR ((obj)) == NULL)                           \
110         rb_raise (rb_eRuntimeError, "thread destroyed");        \
111         Data_Get_Struct ((obj), notmuch_thread_t, (ptr));       \
112     } while (0)
113
114 #define Data_Get_Notmuch_Message(obj, ptr)                      \
115     do {                                                        \
116         Check_Type ((obj), T_DATA);                             \
117         if (DATA_PTR ((obj)) == NULL)                           \
118         rb_raise (rb_eRuntimeError, "message destroyed");       \
119         Data_Get_Struct ((obj), notmuch_message_t, (ptr));      \
120     } while (0)
121
122 #define Data_Get_Notmuch_Tags(obj, ptr)                 \
123     do {                                                \
124         Check_Type ((obj), T_DATA);                     \
125         if (DATA_PTR ((obj)) == NULL)                   \
126         rb_raise (rb_eRuntimeError, "tags destroyed");  \
127         Data_Get_Struct ((obj), notmuch_tags_t, (ptr)); \
128     } while (0)
129
130 /* status.c */
131 void
132 notmuch_rb_status_raise (notmuch_status_t status);
133
134 /* database.c */
135 VALUE
136 notmuch_rb_database_alloc (VALUE klass);
137
138 VALUE
139 notmuch_rb_database_initialize (int argc, VALUE *argv, VALUE klass);
140
141 VALUE
142 notmuch_rb_database_open (int argc, VALUE *argv, VALUE klass);
143
144 VALUE
145 notmuch_rb_database_close (VALUE self);
146
147 VALUE
148 notmuch_rb_database_path (VALUE self);
149
150 VALUE
151 notmuch_rb_database_version (VALUE self);
152
153 VALUE
154 notmuch_rb_database_needs_upgrade (VALUE self);
155
156 VALUE
157 notmuch_rb_database_upgrade (VALUE self);
158
159 VALUE
160 notmuch_rb_database_begin_atomic (VALUE self);
161
162 VALUE
163 notmuch_rb_database_end_atomic (VALUE self);
164
165 VALUE
166 notmuch_rb_database_get_directory (VALUE self, VALUE pathv);
167
168 VALUE
169 notmuch_rb_database_add_message (VALUE self, VALUE pathv);
170
171 VALUE
172 notmuch_rb_database_remove_message (VALUE self, VALUE pathv);
173
174 VALUE
175 notmuch_rb_database_find_message (VALUE self, VALUE idv);
176
177 VALUE
178 notmuch_rb_database_find_message_by_filename (VALUE self, VALUE pathv);
179
180 VALUE
181 notmuch_rb_database_query_create (VALUE self, VALUE qstrv);
182
183 /* directory.c */
184 VALUE
185 notmuch_rb_directory_destroy (VALUE self);
186
187 VALUE
188 notmuch_rb_directory_get_mtime (VALUE self);
189
190 VALUE
191 notmuch_rb_directory_set_mtime (VALUE self, VALUE mtimev);
192
193 VALUE
194 notmuch_rb_directory_get_child_files (VALUE self);
195
196 VALUE
197 notmuch_rb_directory_get_child_directories (VALUE self);
198
199 /* filenames.c */
200 VALUE
201 notmuch_rb_filenames_destroy (VALUE self);
202
203 VALUE
204 notmuch_rb_filenames_each (VALUE self);
205
206 /* query.c */
207 VALUE
208 notmuch_rb_query_destroy (VALUE self);
209
210 VALUE
211 notmuch_rb_query_get_sort (VALUE self);
212
213 VALUE
214 notmuch_rb_query_set_sort (VALUE self, VALUE sortv);
215
216 VALUE
217 notmuch_rb_query_get_string (VALUE self);
218
219 VALUE
220 notmuch_rb_query_add_tag_exclude (VALUE self, VALUE tagv);
221
222 VALUE
223 notmuch_rb_query_set_omit_excluded (VALUE self, VALUE omitv);
224
225 VALUE
226 notmuch_rb_query_search_threads (VALUE self);
227
228 VALUE
229 notmuch_rb_query_search_messages (VALUE self);
230
231 VALUE
232 notmuch_rb_query_count_messages (VALUE self);
233
234 VALUE
235 notmuch_rb_query_count_threads (VALUE self);
236
237 /* threads.c */
238 VALUE
239 notmuch_rb_threads_destroy (VALUE self);
240
241 VALUE
242 notmuch_rb_threads_each (VALUE self);
243
244 /* messages.c */
245 VALUE
246 notmuch_rb_messages_destroy (VALUE self);
247
248 VALUE
249 notmuch_rb_messages_each (VALUE self);
250
251 VALUE
252 notmuch_rb_messages_collect_tags (VALUE self);
253
254 /* thread.c */
255 VALUE
256 notmuch_rb_thread_destroy (VALUE self);
257
258 VALUE
259 notmuch_rb_thread_get_thread_id (VALUE self);
260
261 VALUE
262 notmuch_rb_thread_get_total_messages (VALUE self);
263
264 VALUE
265 notmuch_rb_thread_get_toplevel_messages (VALUE self);
266
267 VALUE
268 notmuch_rb_thread_get_messages (VALUE self);
269
270 VALUE
271 notmuch_rb_thread_get_matched_messages (VALUE self);
272
273 VALUE
274 notmuch_rb_thread_get_authors (VALUE self);
275
276 VALUE
277 notmuch_rb_thread_get_subject (VALUE self);
278
279 VALUE
280 notmuch_rb_thread_get_oldest_date (VALUE self);
281
282 VALUE
283 notmuch_rb_thread_get_newest_date (VALUE self);
284
285 VALUE
286 notmuch_rb_thread_get_tags (VALUE self);
287
288 /* message.c */
289 VALUE
290 notmuch_rb_message_destroy (VALUE self);
291
292 VALUE
293 notmuch_rb_message_get_message_id (VALUE self);
294
295 VALUE
296 notmuch_rb_message_get_thread_id (VALUE self);
297
298 VALUE
299 notmuch_rb_message_get_replies (VALUE self);
300
301 VALUE
302 notmuch_rb_message_get_filename (VALUE self);
303
304 VALUE
305 notmuch_rb_message_get_filenames (VALUE self);
306
307 VALUE
308 notmuch_rb_message_get_flag (VALUE self, VALUE flagv);
309
310 VALUE
311 notmuch_rb_message_set_flag (VALUE self, VALUE flagv, VALUE valuev);
312
313 VALUE
314 notmuch_rb_message_get_date (VALUE self);
315
316 VALUE
317 notmuch_rb_message_get_header (VALUE self, VALUE headerv);
318
319 VALUE
320 notmuch_rb_message_get_tags (VALUE self);
321
322 VALUE
323 notmuch_rb_message_add_tag (VALUE self, VALUE tagv);
324
325 VALUE
326 notmuch_rb_message_remove_tag (VALUE self, VALUE tagv);
327
328 VALUE
329 notmuch_rb_message_remove_all_tags (VALUE self);
330
331 VALUE
332 notmuch_rb_message_maildir_flags_to_tags (VALUE self);
333
334 VALUE
335 notmuch_rb_message_tags_to_maildir_flags (VALUE self);
336
337 VALUE
338 notmuch_rb_message_freeze (VALUE self);
339
340 VALUE
341 notmuch_rb_message_thaw (VALUE self);
342
343 /* tags.c */
344 VALUE
345 notmuch_rb_tags_destroy (VALUE self);
346
347 VALUE
348 notmuch_rb_tags_each (VALUE self);
349
350 /* init.c */
351 void
352 Init_notmuch (void);
353
354 #endif