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