summaryrefslogtreecommitdiffabout
path: root/kmicromail/libetpan/generic/maildriver_types.h
authorzautrix <zautrix>2004-07-03 16:33:12 (UTC)
committer zautrix <zautrix>2004-07-03 16:33:12 (UTC)
commite3b89230f065c48c84b48c88edb6eb088374c487 (patch) (unidiff)
tree162ea2ef909a6f82ccfcedf45d80d6c821174912 /kmicromail/libetpan/generic/maildriver_types.h
parent2dd6ac0b2d24c91d35ce674a6c26351352df2b15 (diff)
downloadkdepimpi-e3b89230f065c48c84b48c88edb6eb088374c487.zip
kdepimpi-e3b89230f065c48c84b48c88edb6eb088374c487.tar.gz
kdepimpi-e3b89230f065c48c84b48c88edb6eb088374c487.tar.bz2
Initial revision
Diffstat (limited to 'kmicromail/libetpan/generic/maildriver_types.h') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libetpan/generic/maildriver_types.h793
1 files changed, 793 insertions, 0 deletions
diff --git a/kmicromail/libetpan/generic/maildriver_types.h b/kmicromail/libetpan/generic/maildriver_types.h
new file mode 100644
index 0000000..3ff9440
--- a/dev/null
+++ b/kmicromail/libetpan/generic/maildriver_types.h
@@ -0,0 +1,793 @@
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#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_copy_message)(mailsession * session,
511 uint32_t num, char * mb);
512 int (* sess_move_message)(mailsession * session,
513 uint32_t num, char * mb);
514
515 int (* sess_get_message)(mailsession * session,
516 uint32_t num, mailmessage ** result);
517
518 int (* sess_get_message_by_uid)(mailsession * session,
519 const char * uid, mailmessage ** result);
520
521 int (* sess_get_messages_list)(mailsession * session,
522 struct mailmessage_list ** result);
523 int (* sess_get_envelopes_list)(mailsession * session,
524 struct mailmessage_list * env_list);
525 int (* sess_remove_message)(mailsession * session, uint32_t num);
526#if 0
527 int (* sess_search_messages)(mailsession * session, char * charset,
528 struct mail_search_key * key,
529 struct mail_search_result ** result);
530#endif
531};
532
533
534/*
535 session is the data structure for a mail session.
536
537 - data is the internal data structure used by the driver
538 It is called when initializing the mailsession structure.
539
540 - driver is the driver used for the session
541*/
542
543struct mailsession {
544 void * sess_data;
545 mailsession_driver * sess_driver;
546};
547
548
549
550
551/*
552 mailmessage_driver is the driver structure to get information from messages.
553
554 - name is the name of the driver
555
556 - initialize() is the function that will initializes a data structure
557 specific to the driver, it returns a value that will be stored
558 in the field data of the mailsession.
559 The field data of the session is the state of the session,
560 the internal data structure used by the driver.
561 It is called when initializing the mailmessage structure with
562 mailmessage_init().
563
564 - uninitialize() frees the structure created with initialize().
565 It will be called by mailmessage_free().
566
567 - flush() will free from memory all temporary structures of the message
568 (for example, the MIME structure of the message).
569
570 - fetch_result_free() will free all strings resulted by fetch() or
571 any fetch_xxx() functions that returns a string.
572
573 - fetch() returns the content of the message (headers and text).
574
575 - fetch_header() returns the content of the headers.
576
577 - fetch_body() returns the message text (message content without headers)
578
579 - fetch_size() returns the size of the message content.
580
581 - get_bodystructure() returns the MIME structure of the message.
582
583 - fetch_section() returns the content of a given MIME part
584
585 - fetch_section_header() returns the header of the message
586 contained by the given MIME part.
587
588 - fetch_section_mime() returns the MIME headers of the
589 given MIME part.
590
591 - fetch_section_body() returns the text (if this is a message, this is the
592 message content without headers) of the given MIME part.
593
594 - fetch_envelope() returns a mailimf_fields structure, with a list of
595 fields chosen by the driver.
596
597 - get_flags() returns a the flags related to the message.
598 When you want to get flags of a message, you have to make sure to
599 call get_flags() at least once before using directly message->flags.
600*/
601
602#define LIBETPAN_MAIL_MESSAGE_CHECK
603
604struct mailmessage_driver {
605 char * msg_name;
606
607 int (* msg_initialize)(mailmessage * msg_info);
608
609 void (* msg_uninitialize)(mailmessage * msg_info);
610
611 void (* msg_flush)(mailmessage * msg_info);
612
613 void (* msg_check)(mailmessage * msg_info);
614
615 void (* msg_fetch_result_free)(mailmessage * msg_info,
616 char * msg);
617
618 int (* msg_fetch)(mailmessage * msg_info,
619 char ** result,
620 size_t * result_len);
621
622 int (* msg_fetch_header)(mailmessage * msg_info,
623 char ** result,
624 size_t * result_len);
625
626 int (* msg_fetch_body)(mailmessage * msg_info,
627 char ** result, size_t * result_len);
628
629 int (* msg_fetch_size)(mailmessage * msg_info,
630 size_t * result);
631
632 int (* msg_get_bodystructure)(mailmessage * msg_info,
633 struct mailmime ** result);
634
635 int (* msg_fetch_section)(mailmessage * msg_info,
636 struct mailmime * mime,
637 char ** result, size_t * result_len);
638
639 int (* msg_fetch_section_header)(mailmessage * msg_info,
640 struct mailmime * mime,
641 char ** result,
642 size_t * result_len);
643
644 int (* msg_fetch_section_mime)(mailmessage * msg_info,
645 struct mailmime * mime,
646 char ** result,
647 size_t * result_len);
648
649 int (* msg_fetch_section_body)(mailmessage * msg_info,
650 struct mailmime * mime,
651 char ** result,
652 size_t * result_len);
653
654 int (* msg_fetch_envelope)(mailmessage * msg_info,
655 struct mailimf_fields ** result);
656
657 int (* msg_get_flags)(mailmessage * msg_info,
658 struct mail_flags ** result);
659};
660
661
662/*
663 mailmessage is a data structure to get information from messages
664
665 - session is the session linked to the given message, it can be NULL
666
667 - driver is the message driver
668
669 - index is the message number
670
671 - uid, when it is not NULL, it means that the folder
672 the folder has persistant message numbers, the string is
673 the unique message number in the folder.
674 uid should be implemented if possible.
675 for drivers where we cannot generate real uid,
676 a suggestion is "AAAA-IIII" where AAAA is some
677 random session number and IIII the content of index field.
678
679 - size, when it is not 0, is the size of the message content.
680
681 - fields, when it is not NULL, are the header fields of the message.
682
683 - flags, when it is not NULL, are the flags related to the message.
684
685 - single_fields, when resolved != 0, is filled with the data of fields.
686
687 - mime, when it is not NULL
688
689 - cached is != 0 when the header fields were read from the cache.
690
691 - data is data specific to the driver, this is internal data structure,
692 some state of the message.
693*/
694
695struct mailmessage {
696 mailsession * msg_session;
697 mailmessage_driver * msg_driver;
698 uint32_t msg_index;
699 char * msg_uid;
700
701 size_t msg_size;
702 struct mailimf_fields * msg_fields;
703 struct mail_flags * msg_flags;
704
705 int msg_resolved;
706 struct mailimf_single_fields msg_single_fields;
707 struct mailmime * msg_mime;
708
709 /* internal data */
710
711 int msg_cached;
712 void * msg_data;
713
714 /*
715 msg_folder field :
716 used to reference the mailfolder, this is a workaround due
717 to the problem with initial conception, where folder notion
718 did not exist.
719 */
720 void * msg_folder;
721 /* user data */
722 void * msg_user_data;
723};
724
725
726/*
727 mailmessage_tree is a node in the messages tree (thread)
728
729 - parent is the parent of the message, it is NULL if the message
730 is the root of the message tree.
731
732 - date is the date of the message in number of second elapsed
733 since 00:00:00 on January 1, 1970, Coordinated Universal Time (UTC).
734
735 - msg is the message structure that is stored referenced by the node.
736 is msg is NULL, this is a dummy node.
737
738 - children is an array that contains all the children of the node.
739 children are mailmessage_tree structures.
740
741 - is_reply is != 0 when the message is a reply or a forward
742
743 - base_subject is the extracted subject of the message.
744
745 - index is the message number.
746*/
747
748struct mailmessage_tree {
749 struct mailmessage_tree * node_parent;
750 char * node_msgid;
751 time_t node_date;
752 mailmessage * node_msg;
753 carray * node_children; /* array of (struct mailmessage_tree *) */
754
755 /* private, used for threading */
756 int node_is_reply;
757 char * node_base_subject;
758};
759
760
761struct mailmessage_tree *
762mailmessage_tree_new(char * node_msgid, time_t node_date,
763 mailmessage * node_msg);
764
765void mailmessage_tree_free(struct mailmessage_tree * tree);
766
767/*
768 mailmessage_tree_free_recursive
769
770 if you want to release memory of the given tree and all the sub-trees,
771 you can use this function.
772*/
773
774void mailmessage_tree_free_recursive(struct mailmessage_tree * tree);
775
776
777struct generic_message_t {
778 int (* msg_prefetch)(mailmessage * msg_info);
779 void (* msg_prefetch_free)(struct generic_message_t * msg);
780 int msg_fetched;
781 char * msg_message;
782 size_t msg_length;
783 void * msg_data;
784};
785
786
787const char * maildriver_strerror(int err);
788
789#ifdef __cplusplus
790}
791#endif
792
793#endif