summaryrefslogtreecommitdiffabout
path: root/libetpan/include/libetpan/maildriver_types.h
Unidiff
Diffstat (limited to 'libetpan/include/libetpan/maildriver_types.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libetpan/include/libetpan/maildriver_types.h795
1 files changed, 795 insertions, 0 deletions
diff --git a/libetpan/include/libetpan/maildriver_types.h b/libetpan/include/libetpan/maildriver_types.h
new file mode 100644
index 0000000..2225236
--- a/dev/null
+++ b/libetpan/include/libetpan/maildriver_types.h
@@ -0,0 +1,795 @@
1/*
2 * libEtPan! -- a mail stuff library
3 *
4 * Copyright (C) 2001, 2005 - 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 AUTHORS 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 AUTHORS 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#ifndef MAILDRIVER_TYPES_H
37
38#define MAILDRIVER_TYPES_H
39
40#include <inttypes.h>
41#include <sys/types.h>
42
43#include <libetpan/mailstream.h>
44#include <libetpan/mailimf.h>
45#include <libetpan/mailmime.h>
46#include <libetpan/carray.h>
47
48#include <libetpan/mailthread_types.h>
49#include <libetpan/maildriver_errors.h>
50
51#ifdef __cplusplus
52extern "C" {
53#endif
54
55typedef struct mailsession_driver mailsession_driver;
56
57typedef struct mailsession mailsession;
58
59typedef struct mailmessage_driver mailmessage_driver;
60
61typedef struct mailmessage mailmessage;
62
63
64/*
65 mailmessage_list is a list of mailmessage
66
67 - tab is an array of mailmessage structures
68*/
69
70struct mailmessage_list {
71 carray * msg_tab; /* elements are (mailmessage *) */
72};
73
74struct mailmessage_list * mailmessage_list_new(carray * msg_tab);
75void mailmessage_list_free(struct mailmessage_list * env_list);
76
77/*
78 mail_list is a list of mailbox names
79
80 - list is a list of mailbox names
81*/
82
83struct mail_list {
84 clist * mb_list; /* elements are (char *) */
85};
86
87struct mail_list * mail_list_new(clist * mb_list);
88void mail_list_free(struct mail_list * resp);
89
90/*
91 This is a flag value.
92 Flags can be combined with OR operation
93*/
94
95enum {
96 MAIL_FLAG_NEW = 1 << 0,
97 MAIL_FLAG_SEEN = 1 << 1,
98 MAIL_FLAG_FLAGGED = 1 << 2,
99 MAIL_FLAG_DELETED = 1 << 3,
100 MAIL_FLAG_ANSWERED = 1 << 4,
101 MAIL_FLAG_FORWARDED = 1 << 5,
102 MAIL_FLAG_CANCELLED = 1 << 6,
103};
104
105/*
106 mail_flags is the value of a flag related to a message.
107
108 - flags is the standard flags value
109
110 - extension is a list of unknown flags for libEtPan!
111*/
112
113struct mail_flags {
114 uint32_t fl_flags;
115 clist * fl_extension; /* elements are (char *) */
116};
117
118struct mail_flags * mail_flags_new(uint32_t fl_flags, clist * fl_ext);
119void mail_flags_free(struct mail_flags * flags);
120
121/*
122 This function creates a flag for a new message
123*/
124
125struct mail_flags * mail_flags_new_empty(void);
126
127
128/*
129 mailimf_date_time_comp compares two dates
130
131
132*/
133
134int32_t mailimf_date_time_comp(struct mailimf_date_time * date1,
135 struct mailimf_date_time * date2);
136
137/*
138 this is type type of the search criteria
139*/
140
141enum {
142 MAIL_SEARCH_KEY_ALL, /* all messages correspond */
143 MAIL_SEARCH_KEY_ANSWERED, /* messages with flag \Answered */
144 MAIL_SEARCH_KEY_BCC, /* messages which Bcc field contains
145 a given string */
146 MAIL_SEARCH_KEY_BEFORE, /* messages which internal date is earlier
147 than the specified date */
148 MAIL_SEARCH_KEY_BODY, /* message that contains the given string
149 (in header and text parts) */
150 MAIL_SEARCH_KEY_CC, /* messages whose Cc field contains the
151 given string */
152 MAIL_SEARCH_KEY_DELETED, /* messages with the flag \Deleted */
153 MAIL_SEARCH_KEY_FLAGGED, /* messages with the flag \Flagged */
154 MAIL_SEARCH_KEY_FROM, /* messages whose From field contains the
155 given string */
156 MAIL_SEARCH_KEY_NEW, /* messages with the flag \Recent and not
157 the \Seen flag */
158 MAIL_SEARCH_KEY_OLD, /* messages that do not have the
159 \Recent flag set */
160 MAIL_SEARCH_KEY_ON, /* messages whose internal date is the
161 specified date */
162 MAIL_SEARCH_KEY_RECENT, /* messages with the flag \Recent */
163 MAIL_SEARCH_KEY_SEEN, /* messages with the flag \Seen */
164 MAIL_SEARCH_KEY_SINCE, /* messages whose internal date is later
165 than specified date */
166 MAIL_SEARCH_KEY_SUBJECT, /* messages whose Subject field contains the
167 given string */
168 MAIL_SEARCH_KEY_TEXT, /* messages whose text part contains the
169 given string */
170 MAIL_SEARCH_KEY_TO, /* messages whose To field contains the
171 given string */
172 MAIL_SEARCH_KEY_UNANSWERED, /* messages with no flag \Answered */
173 MAIL_SEARCH_KEY_UNDELETED, /* messages with no flag \Deleted */
174 MAIL_SEARCH_KEY_UNFLAGGED, /* messages with no flag \Flagged */
175 MAIL_SEARCH_KEY_UNSEEN, /* messages with no flag \Seen */
176 MAIL_SEARCH_KEY_HEADER, /* messages whose given field
177 contains the given string */
178 MAIL_SEARCH_KEY_LARGER, /* messages whose size is larger then
179 the given size */
180 MAIL_SEARCH_KEY_NOT, /* not operation of the condition */
181 MAIL_SEARCH_KEY_OR, /* or operation between two conditions */
182 MAIL_SEARCH_KEY_SMALLER, /* messages whose size is smaller than
183 the given size */
184 MAIL_SEARCH_KEY_MULTIPLE /* the boolean operator between the
185 conditions is AND */
186};
187
188/*
189 mail_search_key is the condition on the messages to return
190
191 - type is the type of the condition
192
193 - bcc is the text to search in the Bcc field when type is
194 MAIL_SEARCH_KEY_BCC, should be allocated with malloc()
195
196 - before is a date when type is MAIL_SEARCH_KEY_BEFORE
197
198 - body is the text to search in the message when type is
199 MAIL_SEARCH_KEY_BODY, should be allocated with malloc()
200
201 - cc is the text to search in the Cc field when type is
202 MAIL_SEARCH_KEY_CC, should be allocated with malloc()
203
204 - from is the text to search in the From field when type is
205 MAIL_SEARCH_KEY_FROM, should be allocated with malloc()
206
207 - on is a date when type is MAIL_SEARCH_KEY_ON
208
209 - since is a date when type is MAIL_SEARCH_KEY_SINCE
210
211 - subject is the text to search in the Subject field when type is
212 MAILIMAP_SEARCH_KEY_SUBJECT, should be allocated with malloc()
213
214 - text is the text to search in the text part of the message when
215 type is MAILIMAP_SEARCH_KEY_TEXT, should be allocated with malloc()
216
217 - to is the text to search in the To field when type is
218 MAILIMAP_SEARCH_KEY_TO, should be allocated with malloc()
219
220 - header_name is the header name when type is MAILIMAP_SEARCH_KEY_HEADER,
221 should be allocated with malloc()
222
223 - header_value is the text to search in the given header when type is
224 MAILIMAP_SEARCH_KEY_HEADER, should be allocated with malloc()
225
226 - larger is a size when type is MAILIMAP_SEARCH_KEY_LARGER
227
228 - not is a condition when type is MAILIMAP_SEARCH_KEY_NOT
229
230 - or1 is a condition when type is MAILIMAP_SEARCH_KEY_OR
231
232 - or2 is a condition when type is MAILIMAP_SEARCH_KEY_OR
233
234 - sentbefore is a date when type is MAILIMAP_SEARCH_KEY_SENTBEFORE
235
236 - senton is a date when type is MAILIMAP_SEARCH_KEY_SENTON
237
238 - sentsince is a date when type is MAILIMAP_SEARCH_KEY_SENTSINCE
239
240 - smaller is a size when type is MAILIMAP_SEARCH_KEY_SMALLER
241
242 - multiple is a set of message when type is MAILIMAP_SEARCH_KEY_MULTIPLE
243*/
244
245#if 0
246struct mail_search_key {
247 int sk_type;
248 union {
249 char * sk_bcc;
250 struct mailimf_date_time * sk_before;
251 char * sk_body;
252 char * sk_cc;
253 char * sk_from;
254 struct mailimf_date_time * sk_on;
255 struct mailimf_date_time * sk_since;
256 char * sk_subject;
257 char * sk_text;
258 char * sk_to;
259 char * sk_header_name;
260 char * sk_header_value;
261 size_t sk_larger;
262 struct mail_search_key * sk_not;
263 struct mail_search_key * sk_or1;
264 struct mail_search_key * sk_or2;
265 size_t sk_smaller;
266 clist * sk_multiple; /* list of (struct mailimap_search_key *) */
267 } sk_data;
268};
269
270
271struct mail_search_key *
272mail_search_key_new(int sk_type,
273 char * sk_bcc, struct mailimf_date_time * sk_before,
274 char * sk_body, char * sk_cc, char * sk_from,
275 struct mailimf_date_time * sk_on, struct mailimf_date_time * sk_since,
276 char * sk_subject, char * sk_text, char * sk_to,
277 char * sk_header_name, char * sk_header_value, size_t sk_larger,
278 struct mail_search_key * sk_not, struct mail_search_key * sk_or1,
279 struct mail_search_key * sk_or2, size_t sk_smaller,
280 clist * sk_multiple);
281
282void mail_search_key_free(struct mail_search_key * key);
283#endif
284
285/*
286 mail_search_result is a list of message numbers that is returned
287 by the mailsession_search_messages function()
288*/
289
290#if 0
291struct mail_search_result {
292 clist * sr_list; /* list of (uint32_t *) */
293};
294
295struct mail_search_result * mail_search_result_new(clist * sr_list);
296
297void mail_search_result_free(struct mail_search_result * search_result);
298#endif
299
300
301/*
302 There is three kinds of identities :
303 - storage
304 - folders
305 - session
306
307 A storage (struct mailstorage) represents whether a server or
308 a main path,
309
310 A storage can be an IMAP server, the root path of a MH or a mbox file.
311
312 Folders (struct mailfolder) are the mailboxes we can
313 choose in the server or as sub-folder of the main path.
314
315 Folders for IMAP are the IMAP mailboxes, for MH this is one of the
316 folder of the MH storage, for mbox, there is only one folder, the
317 mbox file content;
318
319 A mail session (struct mailsession) is whether a connection to a server
320 or a path that is open. It is the abstraction lower folders and storage.
321 It allow us to send commands.
322
323 We have a session driver for mail session for each kind of storage.
324
325 From a session, we can get a message (struct mailmessage) to read.
326 We have a message driver for each kind of storage.
327*/
328
329/*
330 maildriver is the driver structure for mail sessions
331
332 - name is the name of the driver
333
334 - initialize() is the function that will initializes a data structure
335 specific to the driver, it returns a value that will be stored
336 in the field data of the session.
337 The field data of the session is the state of the session,
338 the internal data structure used by the driver.
339 It is called when creating the mailsession structure with
340 mailsession_new().
341
342 - uninitialize() frees the structure created with initialize()
343
344 - parameters() implements functions specific to the given mail access
345
346 - connect_stream() connects a stream to the session
347
348 - connect_path() notify a main path to the session
349
350 - starttls() changes the current stream to a TLS stream
351
352 - login() notifies the user and the password to authenticate to the
353 session
354
355 - logout() exits the session and closes the stream
356
357 - noop() does no operation on the session, but it can be
358 used to poll for the status of the connection.
359
360 - build_folder_name() will return an allocated string with
361 that contains the complete path of the folder to create
362
363 - create_folder() creates the folder that corresponds to the
364 given name
365
366 - delete_folder() deletes the folder that corresponds to the
367 given name
368
369 - rename_folder() change the name of the folder
370
371 - check_folder() makes a checkpoint of the session
372
373 - examine_folder() selects a mailbox as readonly
374
375 - select_folder() selects a mailbox
376
377 - expunge_folder() deletes all messages marked \Deleted
378
379 - status_folder() queries the status of the folder
380 (number of messages, number of recent messages, number of
381 unseen messages)
382
383 - messages_number() queries the number of messages in the folder
384
385 - recent_number() queries the number of recent messages in the folder
386
387 - unseen_number() queries the number of unseen messages in the folder
388
389 - list_folders() returns the list of all sub-mailboxes
390 of the given mailbox
391
392 - lsub_folders() returns the list of subscribed
393 sub-mailboxes of the given mailbox
394
395 - subscribe_folder() subscribes to the given mailbox
396
397 - unsubscribe_folder() unsubscribes to the given mailbox
398
399 - append_message() adds a RFC 2822 message to the current
400 given mailbox
401
402 - copy_message() copies a message whose number is given to
403 a given mailbox. The mailbox must be accessible from
404 the same session.
405
406 - move_message() copies a message whose number is given to
407 a given mailbox. The mailbox must be accessible from the
408 same session.
409
410 - get_messages_list() returns the list of message numbers
411 of the current mailbox.
412
413 - get_envelopes_list() fills the parsed fields in the
414 mailmessage structures of the mailmessage_list.
415
416 - remove_message() removes the given message from the mailbox.
417 The message is permanently deleted.
418
419 - search_message() returns a list of message numbers that
420 corresponds to the given criteria.
421
422 - get_message returns a mailmessage structure that corresponds
423 to the given message number.
424
425 - get_message_by_uid returns a mailmessage structure that corresponds
426 to the given message unique identifier.
427
428 * mandatory functions are the following :
429
430 - connect_stream() of connect_path()
431 - logout()
432 - get_messages_list()
433 - get_envelopes_list()
434
435 * we advise you to implement these functions :
436
437 - select_folder() (in case a session can access several folders)
438 - noop() (to check if the server is responding)
439 - check_folder() (to make a checkpoint of the session)
440 - status_folder(), messages_number(), recent_number(), unseen_number()
441 (to get stat of the folder)
442 - append_message() (but can't be done in the case of POP3 at least)
443 - login() in a case of an authenticated driver.
444 - starttls() in a case of a stream driver, if the procotol supports
445 STARTTLS.
446 - get_message_by_uid() so that the application can remember the message
447 by UID and build its own list of messages.
448
449 * drivers' specific :
450
451 Everything that is specific to the driver will be implemented in this
452 function :
453
454 - parameters()
455*/
456
457struct mailsession_driver {
458 char * sess_name;
459
460 int (* sess_initialize)(mailsession * session);
461 void (* sess_uninitialize)(mailsession * session);
462
463 int (* sess_parameters)(mailsession * session,
464 int id, void * value);
465
466 int (* sess_connect_stream)(mailsession * session, mailstream * s);
467 int (* sess_connect_path)(mailsession * session, char * path);
468
469 int (* sess_starttls)(mailsession * session);
470
471 int (* sess_login)(mailsession * session, char * userid, char * password);
472 int (* sess_logout)(mailsession * session);
473 int (* sess_noop)(mailsession * session);
474
475 /* folders operations */
476
477 int (* sess_build_folder_name)(mailsession * session, char * mb,
478 char * name, char ** result);
479
480 int (* sess_create_folder)(mailsession * session, char * mb);
481 int (* sess_delete_folder)(mailsession * session, char * mb);
482 int (* sess_rename_folder)(mailsession * session, char * mb,
483 char * new_name);
484 int (* sess_check_folder)(mailsession * session);
485 int (* sess_examine_folder)(mailsession * session, char * mb);
486 int (* sess_select_folder)(mailsession * session, char * mb);
487 int (* sess_expunge_folder)(mailsession * session);
488 int (* sess_status_folder)(mailsession * session, char * mb,
489 uint32_t * result_num, uint32_t * result_recent,
490 uint32_t * result_unseen);
491 int (* sess_messages_number)(mailsession * session, char * mb,
492 uint32_t * result);
493 int (* sess_recent_number)(mailsession * session, char * mb,
494 uint32_t * result);
495 int (* sess_unseen_number)(mailsession * session, char * mb,
496 uint32_t * result);
497
498 int (* sess_list_folders)(mailsession * session, char * mb,
499 struct mail_list ** result);
500 int (* sess_lsub_folders)(mailsession * session, char * mb,
501 struct mail_list ** result);
502
503 int (* sess_subscribe_folder)(mailsession * session, char * mb);
504 int (* sess_unsubscribe_folder)(mailsession * session, char * mb);
505
506 /* messages operations */
507
508 int (* sess_append_message)(mailsession * session,
509 char * message, size_t size);
510 int (* sess_append_message_flags)(mailsession * session,
511 char * message, size_t size, struct mail_flags * flags);
512 int (* sess_copy_message)(mailsession * session,
513 uint32_t num, char * mb);
514 int (* sess_move_message)(mailsession * session,
515 uint32_t num, char * mb);
516
517 int (* sess_get_message)(mailsession * session,
518 uint32_t num, mailmessage ** result);
519
520 int (* sess_get_message_by_uid)(mailsession * session,
521 const char * uid, mailmessage ** result);
522
523 int (* sess_get_messages_list)(mailsession * session,
524 struct mailmessage_list ** result);
525 int (* sess_get_envelopes_list)(mailsession * session,
526 struct mailmessage_list * env_list);
527 int (* sess_remove_message)(mailsession * session, uint32_t num);
528#if 0
529 int (* sess_search_messages)(mailsession * session, char * charset,
530 struct mail_search_key * key,
531 struct mail_search_result ** result);
532#endif
533};
534
535
536/*
537 session is the data structure for a mail session.
538
539 - data is the internal data structure used by the driver
540 It is called when initializing the mailsession structure.
541
542 - driver is the driver used for the session
543*/
544
545struct mailsession {
546 void * sess_data;
547 mailsession_driver * sess_driver;
548};
549
550
551
552
553/*
554 mailmessage_driver is the driver structure to get information from messages.
555
556 - name is the name of the driver
557
558 - initialize() is the function that will initializes a data structure
559 specific to the driver, it returns a value that will be stored
560 in the field data of the mailsession.
561 The field data of the session is the state of the session,
562 the internal data structure used by the driver.
563 It is called when initializing the mailmessage structure with
564 mailmessage_init().
565
566 - uninitialize() frees the structure created with initialize().
567 It will be called by mailmessage_free().
568
569 - flush() will free from memory all temporary structures of the message
570 (for example, the MIME structure of the message).
571
572 - fetch_result_free() will free all strings resulted by fetch() or
573 any fetch_xxx() functions that returns a string.
574
575 - fetch() returns the content of the message (headers and text).
576
577 - fetch_header() returns the content of the headers.
578
579 - fetch_body() returns the message text (message content without headers)
580
581 - fetch_size() returns the size of the message content.
582
583 - get_bodystructure() returns the MIME structure of the message.
584
585 - fetch_section() returns the content of a given MIME part
586
587 - fetch_section_header() returns the header of the message
588 contained by the given MIME part.
589
590 - fetch_section_mime() returns the MIME headers of the
591 given MIME part.
592
593 - fetch_section_body() returns the text (if this is a message, this is the
594 message content without headers) of the given MIME part.
595
596 - fetch_envelope() returns a mailimf_fields structure, with a list of
597 fields chosen by the driver.
598
599 - get_flags() returns a the flags related to the message.
600 When you want to get flags of a message, you have to make sure to
601 call get_flags() at least once before using directly message->flags.
602*/
603
604#define LIBETPAN_MAIL_MESSAGE_CHECK
605
606struct mailmessage_driver {
607 char * msg_name;
608
609 int (* msg_initialize)(mailmessage * msg_info);
610
611 void (* msg_uninitialize)(mailmessage * msg_info);
612
613 void (* msg_flush)(mailmessage * msg_info);
614
615 void (* msg_check)(mailmessage * msg_info);
616
617 void (* msg_fetch_result_free)(mailmessage * msg_info,
618 char * msg);
619
620 int (* msg_fetch)(mailmessage * msg_info,
621 char ** result,
622 size_t * result_len);
623
624 int (* msg_fetch_header)(mailmessage * msg_info,
625 char ** result,
626 size_t * result_len);
627
628 int (* msg_fetch_body)(mailmessage * msg_info,
629 char ** result, size_t * result_len);
630
631 int (* msg_fetch_size)(mailmessage * msg_info,
632 size_t * result);
633
634 int (* msg_get_bodystructure)(mailmessage * msg_info,
635 struct mailmime ** result);
636
637 int (* msg_fetch_section)(mailmessage * msg_info,
638 struct mailmime * mime,
639 char ** result, size_t * result_len);
640
641 int (* msg_fetch_section_header)(mailmessage * msg_info,
642 struct mailmime * mime,
643 char ** result,
644 size_t * result_len);
645
646 int (* msg_fetch_section_mime)(mailmessage * msg_info,
647 struct mailmime * mime,
648 char ** result,
649 size_t * result_len);
650
651 int (* msg_fetch_section_body)(mailmessage * msg_info,
652 struct mailmime * mime,
653 char ** result,
654 size_t * result_len);
655
656 int (* msg_fetch_envelope)(mailmessage * msg_info,
657 struct mailimf_fields ** result);
658
659 int (* msg_get_flags)(mailmessage * msg_info,
660 struct mail_flags ** result);
661};
662
663
664/*
665 mailmessage is a data structure to get information from messages
666
667 - session is the session linked to the given message, it can be NULL
668
669 - driver is the message driver
670
671 - index is the message number
672
673 - uid, when it is not NULL, it means that the folder
674 the folder has persistant message numbers, the string is
675 the unique message number in the folder.
676 uid should be implemented if possible.
677 for drivers where we cannot generate real uid,
678 a suggestion is "AAAA-IIII" where AAAA is some
679 random session number and IIII the content of index field.
680
681 - size, when it is not 0, is the size of the message content.
682
683 - fields, when it is not NULL, are the header fields of the message.
684
685 - flags, when it is not NULL, are the flags related to the message.
686
687 - single_fields, when resolved != 0, is filled with the data of fields.
688
689 - mime, when it is not NULL
690
691 - cached is != 0 when the header fields were read from the cache.
692
693 - data is data specific to the driver, this is internal data structure,
694 some state of the message.
695*/
696
697struct mailmessage {
698 mailsession * msg_session;
699 mailmessage_driver * msg_driver;
700 uint32_t msg_index;
701 char * msg_uid;
702
703 size_t msg_size;
704 struct mailimf_fields * msg_fields;
705 struct mail_flags * msg_flags;
706
707 int msg_resolved;
708 struct mailimf_single_fields msg_single_fields;
709 struct mailmime * msg_mime;
710
711 /* internal data */
712
713 int msg_cached;
714 void * msg_data;
715
716 /*
717 msg_folder field :
718 used to reference the mailfolder, this is a workaround due
719 to the problem with initial conception, where folder notion
720 did not exist.
721 */
722 void * msg_folder;
723 /* user data */
724 void * msg_user_data;
725};
726
727
728/*
729 mailmessage_tree is a node in the messages tree (thread)
730
731 - parent is the parent of the message, it is NULL if the message
732 is the root of the message tree.
733
734 - date is the date of the message in number of second elapsed
735 since 00:00:00 on January 1, 1970, Coordinated Universal Time (UTC).
736
737 - msg is the message structure that is stored referenced by the node.
738 is msg is NULL, this is a dummy node.
739
740 - children is an array that contains all the children of the node.
741 children are mailmessage_tree structures.
742
743 - is_reply is != 0 when the message is a reply or a forward
744
745 - base_subject is the extracted subject of the message.
746
747 - index is the message number.
748*/
749
750struct mailmessage_tree {
751 struct mailmessage_tree * node_parent;
752 char * node_msgid;
753 time_t node_date;
754 mailmessage * node_msg;
755 carray * node_children; /* array of (struct mailmessage_tree *) */
756
757 /* private, used for threading */
758 int node_is_reply;
759 char * node_base_subject;
760};
761
762
763struct mailmessage_tree *
764mailmessage_tree_new(char * node_msgid, time_t node_date,
765 mailmessage * node_msg);
766
767void mailmessage_tree_free(struct mailmessage_tree * tree);
768
769/*
770 mailmessage_tree_free_recursive
771
772 if you want to release memory of the given tree and all the sub-trees,
773 you can use this function.
774*/
775
776void mailmessage_tree_free_recursive(struct mailmessage_tree * tree);
777
778
779struct generic_message_t {
780 int (* msg_prefetch)(mailmessage * msg_info);
781 void (* msg_prefetch_free)(struct generic_message_t * msg);
782 int msg_fetched;
783 char * msg_message;
784 size_t msg_length;
785 void * msg_data;
786};
787
788
789const char * maildriver_strerror(int err);
790
791#ifdef __cplusplus
792}
793#endif
794
795#endif