summaryrefslogtreecommitdiffabout
path: root/libetpan/src/engine/mailengine.h
Unidiff
Diffstat (limited to 'libetpan/src/engine/mailengine.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libetpan/src/engine/mailengine.h190
1 files changed, 190 insertions, 0 deletions
diff --git a/libetpan/src/engine/mailengine.h b/libetpan/src/engine/mailengine.h
new file mode 100644
index 0000000..acb6a16
--- a/dev/null
+++ b/libetpan/src/engine/mailengine.h
@@ -0,0 +1,190 @@
1/*
2 * libEtPan! -- a mail 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 MAILENGINE_H
37
38#define MAILENGINE_H
39
40#include <libetpan/mailmessage.h>
41#include <libetpan/mailfolder.h>
42#include <libetpan/mailprivacy_types.h>
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
48/*
49 to run things in thread, you must protect the storage again concurrency.
50*/
51
52
53/*
54 storage data
55*/
56
57struct mailengine *
58libetpan_engine_new(struct mailprivacy * privacy);
59
60void libetpan_engine_free(struct mailengine * engine);
61
62
63struct mailprivacy *
64libetpan_engine_get_privacy(struct mailengine * engine);
65
66
67/*
68 message ref and unref
69*/
70
71/*
72 these function can only take messages returned by get_msg_list()
73 as arguments.
74
75 these functions cannot fail.
76*/
77
78int libetpan_message_ref(struct mailengine * engine,
79 mailmessage * msg);
80
81int libetpan_message_unref(struct mailengine * engine,
82 mailmessage * msg);
83
84
85/*
86 when you want to access the MIME structure of the message
87 with msg->mime, you have to call libetpan_message_mime_ref()
88 and libetpan_message_mime_unref() when you have finished.
89
90 if libetpan_mime_ref() returns a value <= 0, it means this failed.
91 the value is -MAIL_ERROR_XXX
92*/
93
94int libetpan_message_mime_ref(struct mailengine * engine,
95 mailmessage * msg);
96
97int libetpan_message_mime_unref(struct mailengine * engine,
98 mailmessage * msg);
99
100/*
101 message list
102*/
103
104/*
105 libetpan_folder_get_msg_list()
106
107 This function returns two list.
108 - List of lost message (the messages that were previously returned
109 but that does no more exist) (p_lost_msg_list)
110 - List of valid messages (p_new_msg_list).
111
112 These two list can only be freed by libetpan_folder_free_msg_list()
113*/
114
115int libetpan_folder_get_msg_list(struct mailengine * engine,
116 struct mailfolder * folder,
117 struct mailmessage_list ** p_new_msg_list,
118 struct mailmessage_list ** p_lost_msg_list);
119
120int libetpan_folder_fetch_env_list(struct mailengine * engine,
121 struct mailfolder * folder,
122 struct mailmessage_list * msg_list);
123
124void libetpan_folder_free_msg_list(struct mailengine * engine,
125 struct mailfolder * folder,
126 struct mailmessage_list * env_list);
127
128
129/*
130 connect and disconnect storage
131*/
132
133int libetpan_storage_add(struct mailengine * engine,
134 struct mailstorage * storage);
135
136void libetpan_storage_remove(struct mailengine * engine,
137 struct mailstorage * storage);
138
139int libetpan_storage_connect(struct mailengine * engine,
140 struct mailstorage * storage);
141
142void libetpan_storage_disconnect(struct mailengine * engine,
143 struct mailstorage * storage);
144
145int libetpan_storage_used(struct mailengine * engine,
146 struct mailstorage * storage);
147
148
149/*
150 libetpan_folder_connect()
151 libetpan_folder_disconnect()
152
153 You can disconnect the folder only when you have freed all the message
154 you were given.
155*/
156
157int libetpan_folder_connect(struct mailengine * engine,
158 struct mailfolder * folder);
159
160void libetpan_folder_disconnect(struct mailengine * engine,
161 struct mailfolder * folder);
162
163
164struct mailfolder *
165libetpan_message_get_folder(struct mailengine * engine,
166 mailmessage * msg);
167
168struct mailstorage *
169libetpan_message_get_storage(struct mailengine * engine,
170 mailmessage * msg);
171
172
173/*
174 register a message
175*/
176
177int libetpan_message_register(struct mailengine * engine,
178 struct mailfolder * folder,
179 mailmessage * msg);
180
181
182void libetpan_engine_debug(struct mailengine * engine, FILE * f);
183
184extern void * engine_app;
185
186#ifdef __cplusplus
187}
188#endif
189
190#endif