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.c | |
parent | 2dd6ac0b2d24c91d35ce674a6c26351352df2b15 (diff) | |
download | kdepimpi-e3b89230f065c48c84b48c88edb6eb088374c487.zip kdepimpi-e3b89230f065c48c84b48c88edb6eb088374c487.tar.gz kdepimpi-e3b89230f065c48c84b48c88edb6eb088374c487.tar.bz2 |
Initial revision
Diffstat (limited to 'kmicromail/libetpan/generic/mailmessage.c') (more/less context) (show whitespace changes)
-rw-r--r-- | kmicromail/libetpan/generic/mailmessage.c | 240 |
1 files changed, 240 insertions, 0 deletions
diff --git a/kmicromail/libetpan/generic/mailmessage.c b/kmicromail/libetpan/generic/mailmessage.c new file mode 100644 index 0000000..9d3884f --- a/dev/null +++ b/kmicromail/libetpan/generic/mailmessage.c | |||
@@ -0,0 +1,240 @@ | |||
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 "mailmessage.h" | ||
37 | |||
38 | #include "mail.h" | ||
39 | |||
40 | #include <string.h> | ||
41 | |||
42 | int mailmessage_init(mailmessage * msg_info, | ||
43 | mailsession * msg_session, | ||
44 | mailmessage_driver * msg_driver, | ||
45 | uint32_t msg_index, size_t msg_size) | ||
46 | { | ||
47 | int r; | ||
48 | int res; | ||
49 | |||
50 | msg_info->msg_driver = msg_driver; | ||
51 | msg_info->msg_session = msg_session; | ||
52 | msg_info->msg_index = msg_index; | ||
53 | msg_info->msg_uid = NULL; | ||
54 | |||
55 | msg_info->msg_cached = FALSE; | ||
56 | msg_info->msg_size = msg_size; | ||
57 | msg_info->msg_fields = NULL; | ||
58 | memset(&msg_info->msg_single_fields, 0, | ||
59 | sizeof(struct mailimf_single_fields)); | ||
60 | msg_info->msg_resolved = FALSE; | ||
61 | msg_info->msg_flags = NULL; | ||
62 | |||
63 | msg_info->msg_mime = NULL; | ||
64 | msg_info->msg_data = NULL; | ||
65 | msg_info->msg_folder = NULL; | ||
66 | msg_info->msg_user_data = NULL; | ||
67 | |||
68 | if (msg_driver->msg_initialize != NULL) { | ||
69 | r = msg_driver->msg_initialize(msg_info); | ||
70 | if (r != MAIL_NO_ERROR) { | ||
71 | res = r; | ||
72 | goto err; | ||
73 | } | ||
74 | } | ||
75 | |||
76 | return MAIL_NO_ERROR; | ||
77 | |||
78 | err: | ||
79 | msg_info->msg_driver = NULL; | ||
80 | msg_info->msg_session = NULL; | ||
81 | return res; | ||
82 | } | ||
83 | |||
84 | int mailmessage_flush(mailmessage * msg_info) | ||
85 | { | ||
86 | if (msg_info->msg_driver->msg_flush == NULL) | ||
87 | return MAIL_ERROR_NOT_IMPLEMENTED; | ||
88 | |||
89 | msg_info->msg_driver->msg_flush(msg_info); | ||
90 | |||
91 | return MAIL_NO_ERROR; | ||
92 | } | ||
93 | |||
94 | int mailmessage_check(mailmessage * msg_info) | ||
95 | { | ||
96 | if (msg_info->msg_driver->msg_check == NULL) | ||
97 | return MAIL_ERROR_NOT_IMPLEMENTED; | ||
98 | |||
99 | msg_info->msg_driver->msg_check(msg_info); | ||
100 | |||
101 | return MAIL_NO_ERROR; | ||
102 | } | ||
103 | |||
104 | int mailmessage_fetch_result_free(mailmessage * msg_info, | ||
105 | char * msg) | ||
106 | { | ||
107 | if (msg_info->msg_driver->msg_fetch_result_free == NULL) | ||
108 | return MAIL_ERROR_NOT_IMPLEMENTED; | ||
109 | |||
110 | msg_info->msg_driver->msg_fetch_result_free(msg_info, msg); | ||
111 | |||
112 | return MAIL_NO_ERROR; | ||
113 | } | ||
114 | |||
115 | int mailmessage_fetch(mailmessage * msg_info, | ||
116 | char ** result, | ||
117 | size_t * result_len) | ||
118 | { | ||
119 | if (msg_info->msg_driver->msg_fetch == NULL) | ||
120 | return MAIL_ERROR_NOT_IMPLEMENTED; | ||
121 | |||
122 | return msg_info->msg_driver->msg_fetch(msg_info, result, result_len); | ||
123 | } | ||
124 | |||
125 | int mailmessage_fetch_header(mailmessage * msg_info, | ||
126 | char ** result, | ||
127 | size_t * result_len) | ||
128 | { | ||
129 | if (msg_info->msg_driver->msg_fetch_header == NULL) | ||
130 | return MAIL_ERROR_NOT_IMPLEMENTED; | ||
131 | |||
132 | return msg_info->msg_driver->msg_fetch_header(msg_info, result, result_len); | ||
133 | } | ||
134 | |||
135 | int mailmessage_fetch_body(mailmessage * msg_info, | ||
136 | char ** result, size_t * result_len) | ||
137 | { | ||
138 | if (msg_info->msg_driver->msg_fetch_body == NULL) | ||
139 | return MAIL_ERROR_NOT_IMPLEMENTED; | ||
140 | |||
141 | return msg_info->msg_driver->msg_fetch_body(msg_info, result, result_len); | ||
142 | } | ||
143 | |||
144 | int mailmessage_fetch_size(mailmessage * msg_info, | ||
145 | size_t * result) | ||
146 | { | ||
147 | if (msg_info->msg_driver->msg_fetch_size == NULL) | ||
148 | return MAIL_ERROR_NOT_IMPLEMENTED; | ||
149 | |||
150 | return msg_info->msg_driver->msg_fetch_size(msg_info, result); | ||
151 | } | ||
152 | |||
153 | int mailmessage_get_bodystructure(mailmessage * msg_info, | ||
154 | struct mailmime ** result) | ||
155 | { | ||
156 | if (msg_info->msg_driver->msg_get_bodystructure == NULL) | ||
157 | return MAIL_ERROR_NOT_IMPLEMENTED; | ||
158 | |||
159 | return msg_info->msg_driver->msg_get_bodystructure(msg_info, result); | ||
160 | } | ||
161 | |||
162 | int mailmessage_fetch_section(mailmessage * msg_info, | ||
163 | struct mailmime * mime, | ||
164 | char ** result, size_t * result_len) | ||
165 | { | ||
166 | if (msg_info->msg_driver->msg_fetch_section == NULL) | ||
167 | return MAIL_ERROR_NOT_IMPLEMENTED; | ||
168 | |||
169 | return msg_info->msg_driver->msg_fetch_section(msg_info, mime, result, result_len); | ||
170 | } | ||
171 | |||
172 | int mailmessage_fetch_section_header(mailmessage * msg_info, | ||
173 | struct mailmime * mime, | ||
174 | char ** result, | ||
175 | size_t * result_len) | ||
176 | { | ||
177 | if (msg_info->msg_driver->msg_fetch_section_header == NULL) | ||
178 | return MAIL_ERROR_NOT_IMPLEMENTED; | ||
179 | |||
180 | return msg_info->msg_driver->msg_fetch_section_header(msg_info, mime, | ||
181 | result, result_len); | ||
182 | } | ||
183 | |||
184 | int mailmessage_fetch_section_mime(mailmessage * msg_info, | ||
185 | struct mailmime * mime, | ||
186 | char ** result, | ||
187 | size_t * result_len) | ||
188 | { | ||
189 | if (msg_info->msg_driver->msg_fetch_section_mime == NULL) | ||
190 | return MAIL_ERROR_NOT_IMPLEMENTED; | ||
191 | |||
192 | return msg_info->msg_driver->msg_fetch_section_mime(msg_info, mime, | ||
193 | result, result_len); | ||
194 | } | ||
195 | |||
196 | int mailmessage_fetch_section_body(mailmessage * msg_info, | ||
197 | struct mailmime * mime, | ||
198 | char ** result, | ||
199 | size_t * result_len) | ||
200 | { | ||
201 | if (msg_info->msg_driver->msg_fetch_section_body == NULL) | ||
202 | return MAIL_ERROR_NOT_IMPLEMENTED; | ||
203 | |||
204 | return msg_info->msg_driver->msg_fetch_section_body(msg_info, mime, | ||
205 | result, result_len); | ||
206 | } | ||
207 | |||
208 | int mailmessage_fetch_envelope(mailmessage * msg_info, | ||
209 | struct mailimf_fields ** result) | ||
210 | { | ||
211 | if (msg_info->msg_driver->msg_fetch_envelope == NULL) | ||
212 | return MAIL_ERROR_NOT_IMPLEMENTED; | ||
213 | |||
214 | return msg_info->msg_driver->msg_fetch_envelope(msg_info, result); | ||
215 | } | ||
216 | |||
217 | int mailmessage_get_flags(mailmessage * msg_info, | ||
218 | struct mail_flags ** result) | ||
219 | { | ||
220 | struct mail_flags * dummy; | ||
221 | |||
222 | if (msg_info->msg_driver->msg_get_flags == NULL) | ||
223 | return MAIL_ERROR_NOT_IMPLEMENTED; | ||
224 | |||
225 | if (result != NULL) | ||
226 | return msg_info->msg_driver->msg_get_flags(msg_info, result); | ||
227 | else | ||
228 | return msg_info->msg_driver->msg_get_flags(msg_info, &dummy); | ||
229 | } | ||
230 | |||
231 | void mailmessage_resolve_single_fields(mailmessage * msg_info) | ||
232 | { | ||
233 | if (!msg_info->msg_resolved) { | ||
234 | if (msg_info->msg_fields != NULL) { | ||
235 | mailimf_single_fields_init(&msg_info->msg_single_fields, | ||
236 | msg_info->msg_fields); | ||
237 | msg_info->msg_resolved = TRUE; | ||
238 | } | ||
239 | } | ||
240 | } | ||