author | zautrix <zautrix> | 2004-07-03 16:33:12 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-07-03 16:33:12 (UTC) |
commit | e3b89230f065c48c84b48c88edb6eb088374c487 (patch) (unidiff) | |
tree | 162ea2ef909a6f82ccfcedf45d80d6c821174912 /kmicromail/libetpan/generic/mailmessage.h | |
parent | 2dd6ac0b2d24c91d35ce674a6c26351352df2b15 (diff) | |
download | kdepimpi-e3b89230f065c48c84b48c88edb6eb088374c487.zip kdepimpi-e3b89230f065c48c84b48c88edb6eb088374c487.tar.gz kdepimpi-e3b89230f065c48c84b48c88edb6eb088374c487.tar.bz2 |
Initial revision
Diffstat (limited to 'kmicromail/libetpan/generic/mailmessage.h') (more/less context) (show whitespace changes)
-rw-r--r-- | kmicromail/libetpan/generic/mailmessage.h | 379 |
1 files changed, 379 insertions, 0 deletions
diff --git a/kmicromail/libetpan/generic/mailmessage.h b/kmicromail/libetpan/generic/mailmessage.h new file mode 100644 index 0000000..df9b790 --- a/dev/null +++ b/kmicromail/libetpan/generic/mailmessage.h | |||
@@ -0,0 +1,379 @@ | |||
1 | /* | ||
2 | * libEtPan! -- a mail stuff library | ||
3 | * | ||
4 | * Copyright (C) 2001, 2002 - DINH Viet Hoa | ||
5 | * All rights reserved. | ||
6 | * | ||
7 | * Redistribution and use in source and binary forms, with or without | ||
8 | * modification, are permitted provided that the following conditions | ||
9 | * are met: | ||
10 | * 1. Redistributions of source code must retain the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer. | ||
12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer in the | ||
14 | * documentation and/or other materials provided with the distribution. | ||
15 | * 3. Neither the name of the libEtPan! project nor the names of its | ||
16 | * contributors may be used to endorse or promote products derived | ||
17 | * from this software without specific prior written permission. | ||
18 | * | ||
19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
29 | * SUCH DAMAGE. | ||
30 | */ | ||
31 | |||
32 | /* | ||
33 | * $Id$ | ||
34 | */ | ||
35 | |||
36 | #include <libetpan/mailmessage_types.h> | ||
37 | |||
38 | #ifndef MAILMESSAGE_H | ||
39 | |||
40 | #define MAILMESSAGE_H | ||
41 | |||
42 | #ifdef __cplusplus | ||
43 | extern "C" { | ||
44 | #endif | ||
45 | |||
46 | /* | ||
47 | mailmessage_new | ||
48 | |||
49 | This function will initializes a new empty message. | ||
50 | |||
51 | @return a new empty message will be returned. | ||
52 | */ | ||
53 | |||
54 | mailmessage * mailmessage_new(void); | ||
55 | |||
56 | /* | ||
57 | mailmessage_free | ||
58 | |||
59 | This function will release the memory used by this message. | ||
60 | */ | ||
61 | |||
62 | void mailmessage_free(mailmessage * info); | ||
63 | |||
64 | /* | ||
65 | mailmessage_init | ||
66 | |||
67 | This function will initializes a mailmessage structure | ||
68 | with a message from a given session. | ||
69 | |||
70 | @param msg_info This is the message to initialize. | ||
71 | |||
72 | @param session This is the source session of the message. It | ||
73 | can be NULL if the message does not get the information | ||
74 | through the session. | ||
75 | |||
76 | @param driver This is the driver to use for the message. | ||
77 | |||
78 | @param index This is the message number in the session. 0 can | ||
79 | be given if the message is not attached to a session. | ||
80 | |||
81 | @param size is an optional parameter, 0 can be given. | ||
82 | This is informational. This is the size of message content. | ||
83 | |||
84 | @return MAIL_NO_ERROR is returned on success, MAIL_ERROR_XXX is returned | ||
85 | on error | ||
86 | */ | ||
87 | |||
88 | int mailmessage_init(mailmessage * msg_info, | ||
89 | mailsession * session, | ||
90 | mailmessage_driver * driver, | ||
91 | uint32_t index, size_t size); | ||
92 | |||
93 | /* | ||
94 | mailmessage_flush | ||
95 | |||
96 | This function will release all the temporary resources that are not | ||
97 | necessary to use the mailmessage structure from memory. These | ||
98 | resources are for example cached information, such as the MIME | ||
99 | structure. | ||
100 | |||
101 | @param info is the message to clean. | ||
102 | |||
103 | @return MAIL_NO_ERROR is returned on success, MAIL_ERROR_XXX is returned | ||
104 | on error. We can assume that MAIL_NO_ERROR is always returned. | ||
105 | */ | ||
106 | |||
107 | int mailmessage_flush(mailmessage * info); | ||
108 | |||
109 | /* | ||
110 | mailmessage_check | ||
111 | |||
112 | This function will notify the new value of the flags to the session, | ||
113 | it must be called before mailsession_check_folder() in case the flags have | ||
114 | been changed. | ||
115 | |||
116 | @param info is the message to checkpoint. | ||
117 | |||
118 | @return MAIL_NO_ERROR is returned on success, MAIL_ERROR_XXX is returned | ||
119 | on error. We can assume that MAIL_NO_ERROR is always returned. | ||
120 | */ | ||
121 | |||
122 | int mailmessage_check(mailmessage * info); | ||
123 | |||
124 | /* | ||
125 | mailmessage_fetch_result_free | ||
126 | |||
127 | This function releases the memory used by a message returned | ||
128 | by any of the fetch function that returns a (char *). | ||
129 | |||
130 | @param msg_info is the message which the given buffer is from. | ||
131 | |||
132 | @return MAIL_NO_ERROR is returned on success, MAIL_ERROR_XXX is returned | ||
133 | on error. We can assume that MAIL_NO_ERROR is always returned. | ||
134 | */ | ||
135 | |||
136 | int mailmessage_fetch_result_free(mailmessage * msg_info, | ||
137 | char * msg); | ||
138 | |||
139 | /* | ||
140 | mailmessage_fetch | ||
141 | |||
142 | This function returns the content of the message (headers and text). | ||
143 | |||
144 | @param msg_info is the message from which we want to fetch information. | ||
145 | |||
146 | @param result The content of the message is returned in (* result) | ||
147 | |||
148 | @param result_len The length of the returned string is stored | ||
149 | in (* result_len). | ||
150 | |||
151 | @return MAIL_NO_ERROR is returned on success, MAIL_ERROR_XXX is returned | ||
152 | on error. | ||
153 | */ | ||
154 | |||
155 | int mailmessage_fetch(mailmessage * msg_info, | ||
156 | char ** result, | ||
157 | size_t * result_len); | ||
158 | |||
159 | /* | ||
160 | mailmessage_fetch_header | ||
161 | |||
162 | This function returns the header of the message as a string. | ||
163 | |||
164 | @param msg_info is the message from which we want to fetch information. | ||
165 | |||
166 | @param result The header of the message is returned in (* result) | ||
167 | |||
168 | @param result_len The length of the returned string is stored | ||
169 | in (* result_len). | ||
170 | |||
171 | @return MAIL_NO_ERROR is returned on success, MAIL_ERROR_XXX is returned | ||
172 | on error. | ||
173 | */ | ||
174 | |||
175 | int mailmessage_fetch_header(mailmessage * msg_info, | ||
176 | char ** result, | ||
177 | size_t * result_len); | ||
178 | |||
179 | /* | ||
180 | mailmessage_fetch_body | ||
181 | |||
182 | This function returns the content of the message (without headers). | ||
183 | |||
184 | @param msg_info is the message from which we want to fetch information. | ||
185 | @param result The message text (without headers) is returned | ||
186 | in (* result) | ||
187 | @param result_len The length of the returned string is stored | ||
188 | in (* result_len). | ||
189 | |||
190 | @return MAIL_NO_ERROR is returned on success, MAIL_ERROR_XXX is returned | ||
191 | on error. | ||
192 | */ | ||
193 | |||
194 | int mailmessage_fetch_body(mailmessage * msg_info, | ||
195 | char ** result, size_t * result_len); | ||
196 | |||
197 | /* | ||
198 | mailmessage_fetch_size | ||
199 | |||
200 | This function returns the size of the message content. | ||
201 | |||
202 | @param msg_info is the message from which we want to fetch information. | ||
203 | |||
204 | @param result The length of the message content is stored in (* result). | ||
205 | |||
206 | @return MAIL_NO_ERROR is returned on success, MAIL_ERROR_XXX is returned | ||
207 | on error. | ||
208 | */ | ||
209 | |||
210 | int mailmessage_fetch_size(mailmessage * msg_info, | ||
211 | size_t * result); | ||
212 | |||
213 | /* | ||
214 | mailmessage_get_bodystructure | ||
215 | |||
216 | This functions returns the MIME structure of the message. | ||
217 | The returned information MUST not be freed by hand. It is freed by | ||
218 | mailmessage_flush() or mailmessage_free(). | ||
219 | |||
220 | @param msg_info is the message from which we want to fetch information. | ||
221 | |||
222 | @param result The MIME structure is stored in (* result). | ||
223 | |||
224 | @return MAIL_NO_ERROR is returned on success, MAIL_ERROR_XXX is returned | ||
225 | on error. | ||
226 | */ | ||
227 | |||
228 | int mailmessage_get_bodystructure(mailmessage * msg_info, | ||
229 | struct mailmime ** result); | ||
230 | |||
231 | /* | ||
232 | mailmessage_fetch_section | ||
233 | |||
234 | This function returns the content of a MIME part. | ||
235 | |||
236 | @param msg_info is the message from which we want to fetch information. | ||
237 | |||
238 | @param mime is the MIME part identifier. | ||
239 | |||
240 | @param result The content is returned in (* result) | ||
241 | |||
242 | @param result_len The length of the returned string is stored | ||
243 | in (* result_len). | ||
244 | |||
245 | @return MAIL_NO_ERROR is returned on success, MAIL_ERROR_XXX is returned | ||
246 | on error. | ||
247 | */ | ||
248 | |||
249 | int mailmessage_fetch_section(mailmessage * msg_info, | ||
250 | struct mailmime * mime, | ||
251 | char ** result, size_t * result_len); | ||
252 | |||
253 | /* | ||
254 | mailmessage_fetch_section_header | ||
255 | |||
256 | This function returns the header of the message contained | ||
257 | in the given MIME part. | ||
258 | |||
259 | @param msg_info is the message from which we want to fetch information. | ||
260 | |||
261 | @param mime is the MIME part identifier. | ||
262 | |||
263 | @param result The header is returned in (* result) | ||
264 | |||
265 | @param result_len The length of the returned string is stored | ||
266 | in (* result_len). | ||
267 | |||
268 | @return MAIL_NO_ERROR is returned on success, MAIL_ERROR_XXX is returned | ||
269 | on error. | ||
270 | */ | ||
271 | |||
272 | int mailmessage_fetch_section_header(mailmessage * msg_info, | ||
273 | struct mailmime * mime, | ||
274 | char ** result, | ||
275 | size_t * result_len); | ||
276 | |||
277 | /* | ||
278 | mailmessage_fetch_section_mime | ||
279 | |||
280 | This function returns the MIME header of the given MIME part. | ||
281 | |||
282 | @param msg_info is the message from which we want to fetch information. | ||
283 | |||
284 | @param mime is the MIME part identifier. | ||
285 | |||
286 | @param result The MIME header is returned in (* result) | ||
287 | |||
288 | @param result_len The length of the returned string is stored | ||
289 | in (* result_len). | ||
290 | |||
291 | @return MAIL_NO_ERROR is returned on success, MAIL_ERROR_XXX is returned | ||
292 | on error. | ||
293 | */ | ||
294 | |||
295 | int mailmessage_fetch_section_mime(mailmessage * msg_info, | ||
296 | struct mailmime * mime, | ||
297 | char ** result, | ||
298 | size_t * result_len); | ||
299 | |||
300 | /* | ||
301 | mailmessage_fetch_section_body | ||
302 | |||
303 | This function returns the text part of the message contained | ||
304 | in the given MIME part. | ||
305 | |||
306 | @param msg_info is the message from which we want to fetch information. | ||
307 | |||
308 | @param mime is the MIME part identifier. | ||
309 | |||
310 | @param result The message text is returned in (* result) | ||
311 | |||
312 | @param result_len The length of the returned string is stored | ||
313 | in (* result_len). | ||
314 | |||
315 | @return MAIL_NO_ERROR is returned on success, MAIL_ERROR_XXX is returned | ||
316 | on error. | ||
317 | */ | ||
318 | |||
319 | int mailmessage_fetch_section_body(mailmessage * msg_info, | ||
320 | struct mailmime * mime, | ||
321 | char ** result, | ||
322 | size_t * result_len); | ||
323 | |||
324 | /* | ||
325 | mailmessage_fetch_envelope | ||
326 | |||
327 | This function returns a list of parsed fields of the message, | ||
328 | chosen by the driver. | ||
329 | The returned structure must be freed with mailimf_fields_free(). | ||
330 | |||
331 | @param msg_info is the message from which we want to fetch information. | ||
332 | |||
333 | @param result The headers list is returned in (* result) | ||
334 | |||
335 | @return MAIL_NO_ERROR is returned on success, MAIL_ERROR_XXX is returned | ||
336 | on error. | ||
337 | */ | ||
338 | |||
339 | int mailmessage_fetch_envelope(mailmessage * msg_info, | ||
340 | struct mailimf_fields ** result); | ||
341 | |||
342 | |||
343 | /* | ||
344 | mailmessage_get_flags | ||
345 | |||
346 | This function returns the flags related to the message. | ||
347 | The returned information MUST not be freed by hand. It is freed by | ||
348 | mailmessage_free(). | ||
349 | |||
350 | @param msg_info is the message from which we want to fetch information. | ||
351 | |||
352 | @param result The flags are stored in (* result). | ||
353 | |||
354 | @return MAIL_NO_ERROR is returned on success, MAIL_ERROR_XXX is returned | ||
355 | on error. | ||
356 | */ | ||
357 | |||
358 | int mailmessage_get_flags(mailmessage * msg_info, | ||
359 | struct mail_flags ** result); | ||
360 | |||
361 | /* | ||
362 | mailmessage_resolve_single_fields | ||
363 | |||
364 | This function will use the fields information to fill the single_fields | ||
365 | structure in the mailmessage structure. | ||
366 | |||
367 | @param msg_info This is the msg_info to process. | ||
368 | |||
369 | @return MAIL_NO_ERROR is returned on success, MAIL_ERROR_XXX is returned | ||
370 | on error. | ||
371 | */ | ||
372 | |||
373 | void mailmessage_resolve_single_fields(mailmessage * msg_info); | ||
374 | |||
375 | #ifdef __cplusplus | ||
376 | } | ||
377 | #endif | ||
378 | |||
379 | #endif | ||