1 /* notmuch - Not much of an email library, (just index and search)
2  *
3  * Copyright © 2009 Carl Worth
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: Carl Worth <cworth@cworth.org>
19  */
20 
21 module derelict.notmuch.types;
22 
23 extern (C) @nogc nothrow:
24 
25 enum LIBNOTMUCH_MAJOR_VERSION = 4;
26 enum LIBNOTMUCH_MINOR_VERSION = 4;
27 enum LIBNOTMUCH_MICRO_VERSION = 0;
28 
29 /**
30  * Notmuch boolean type.
31  */
32 alias notmuch_bool_t = bool;
33 
34 ///
35 alias notmuch_status_t = int;
36 
37 /**
38  * Status codes used for the return values of most functions.
39  *
40  * A zero value (NOTMUCH_STATUS_SUCCESS) indicates that the function
41  * completed without error. Any other value indicates an error.
42  */
43 enum : notmuch_status_t {
44 	/**
45 		* No error occurred.
46 		*/
47 	NOTMUCH_STATUS_SUCCESS = 0,
48 	/**
49 		* Out of memory.
50 		*/
51 	NOTMUCH_STATUS_OUT_OF_MEMORY,
52 	/**
53 		* An attempt was made to write to a database opened in read-only
54 		* mode.
55 		*/
56 	NOTMUCH_STATUS_READ_ONLY_DATABASE,
57 	/**
58 		* A Xapian exception occurred.
59 		*
60 		* @todo We don't really want to expose this lame XAPIAN_EXCEPTION
61 		* value. Instead we should map to things like DATABASE_LOCKED or
62 		* whatever.
63 		*/
64 	NOTMUCH_STATUS_XAPIAN_EXCEPTION,
65 	/**
66 		* An error occurred trying to read or write to a file (this could
67 		* be file not found, permission denied, etc.)
68 		*/
69 	NOTMUCH_STATUS_FILE_ERROR,
70 	/**
71 		* A file was presented that doesn't appear to be an email
72 		* message.
73 		*/
74 	NOTMUCH_STATUS_FILE_NOT_EMAIL,
75 	/**
76 		* A file contains a message ID that is identical to a message
77 		* already in the database.
78 		*/
79 	NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID,
80 	/**
81 		* The user erroneously passed a NULL pointer to a notmuch
82 		* function.
83 		*/
84 	NOTMUCH_STATUS_NULL_POINTER,
85 	/**
86 		* A tag value is too long (exceeds NOTMUCH_TAG_MAX).
87 		*/
88 	NOTMUCH_STATUS_TAG_TOO_LONG,
89 	/**
90 		* The notmuch_message_thaw function has been called more times
91 		* than notmuch_message_freeze.
92 		*/
93 	NOTMUCH_STATUS_UNBALANCED_FREEZE_THAW,
94 	/**
95 		* notmuch_database_end_atomic has been called more times than
96 		* notmuch_database_begin_atomic.
97 		*/
98 	NOTMUCH_STATUS_UNBALANCED_ATOMIC,
99 	/**
100 		* The operation is not supported.
101 		*/
102 	NOTMUCH_STATUS_UNSUPPORTED_OPERATION,
103 	/**
104 		* The operation requires a database upgrade.
105 		*/
106 	NOTMUCH_STATUS_UPGRADE_REQUIRED,
107 	/**
108 		* There is a problem with the proposed path, e.g. a relative path
109 		* passed to a function expecting an absolute path.
110 		*/
111 	NOTMUCH_STATUS_PATH_ERROR,
112 	/**
113 		* One of the arguments violates the preconditions for the
114 		* function, in a way not covered by a more specific argument.
115 		*/
116 	NOTMUCH_STATUS_ILLEGAL_ARGUMENT,
117 	/**
118 		* Not an actual status value. Just a way to find out how many
119 		* valid status values there are.
120 		*/
121 	NOTMUCH_STATUS_LAST_STATUS
122 }
123 
124 /* Various opaque data types. For each notmuch_<foo>_t see the various
125  * notmuch_<foo> functions below. */
126 struct notmuch_database_t {
127 	@disable this();
128 	@disable this(this);
129 }
130 
131 struct notmuch_query_t {
132 	@disable this();
133 	@disable this(this);
134 }
135 
136 struct notmuch_threads_t {
137 	@disable this();
138 	@disable this(this);
139 }
140 
141 struct notmuch_thread_t {
142 	@disable this();
143 	@disable this(this);
144 }
145 
146 struct notmuch_messages_t {
147 	@disable this();
148 	@disable this(this);
149 }
150 
151 struct notmuch_message_t {
152 	@disable this();
153 	@disable this(this);
154 }
155 
156 struct notmuch_tags_t {
157 	@disable this();
158 	@disable this(this);
159 }
160 
161 struct notmuch_directory_t {
162 	@disable this();
163 	@disable this(this);
164 }
165 
166 struct notmuch_filenames_t {
167 	@disable this();
168 	@disable this(this);
169 }
170 
171 struct notmuch_config_list_t {
172 	@disable this();
173 	@disable this(this);
174 }
175 
176 ///
177 alias notmuch_database_mode_t = int;
178 
179 /**
180  * Database open mode for notmuch_database_open.
181  */
182 enum : notmuch_database_mode_t {
183 	/**
184 		* Open database for reading only.
185 		*/
186 	NOTMUCH_DATABASE_MODE_READ_ONLY = 0,
187 	/**
188 		* Open database for reading and writing.
189 		*/
190 	NOTMUCH_DATABASE_MODE_READ_WRITE
191 }
192 
193 /**
194  * A callback invoked by notmuch_database_compact to notify the user
195  * of the progress of the compaction process.
196  */
197 alias notmuch_compact_status_cb_t = void function(const char* message, void* closure);
198 
199 ///
200 alias notmuch_sort_t = int;
201 
202 /**
203  * Sort values for notmuch_query_set_sort.
204  */
205 enum : notmuch_sort_t {
206 	/**
207 		* Oldest first.
208 		*/
209 	NOTMUCH_SORT_OLDEST_FIRST,
210 	/**
211 		* Newest first.
212 		*/
213 	NOTMUCH_SORT_NEWEST_FIRST,
214 	/**
215 		* Sort by message-id.
216 		*/
217 	NOTMUCH_SORT_MESSAGE_ID,
218 	/**
219 		* Do not sort.
220 		*/
221 	NOTMUCH_SORT_UNSORTED
222 }
223 
224 ///
225 alias notmuch_exclude_t = int;
226 
227 /**
228  * Exclude values for notmuch_query_set_omit_excluded. The strange
229  * order is to maintain backward compatibility: the old FALSE/TRUE
230  * options correspond to the new
231  * NOTMUCH_EXCLUDE_FLAG/NOTMUCH_EXCLUDE_TRUE options.
232  */
233 enum : notmuch_exclude_t {
234 	NOTMUCH_EXCLUDE_FLAG,
235 	NOTMUCH_EXCLUDE_TRUE,
236 	NOTMUCH_EXCLUDE_FALSE,
237 	NOTMUCH_EXCLUDE_ALL
238 }
239 
240 ///
241 alias notmuch_message_flag_t = int;
242 
243 /**
244  * Message flags.
245  */
246 enum : notmuch_message_flag_t {
247 	NOTMUCH_MESSAGE_FLAG_MATCH,
248 	NOTMUCH_MESSAGE_FLAG_EXCLUDED,
249 
250 	/* This message is a "ghost message", meaning it has no filenames
251 		* or content, but we know it exists because it was referenced by
252 		* some other message.  A ghost message has only a message ID and
253 		* thread ID.
254 		*/
255 	NOTMUCH_MESSAGE_FLAG_GHOST,
256 }
257 /**
258  * The longest possible tag value.
259  */
260 enum NOTMUCH_TAG_MAX = 200;
261 
262 /**
263  * Opaque message property iterator
264  */
265 struct notmuch_message_properties_t {
266 	@disable this();
267 	@disable this(this);
268 }