summaryrefslogtreecommitdiff
authoralwin <alwin>2004-01-02 02:46:27 (UTC)
committer alwin <alwin>2004-01-02 02:46:27 (UTC)
commit5fbf2a6b9cda98ab16fa1f0e1ac848a9bb523a72 (patch) (unidiff)
tree3056d87b4ef4f5684f357b3aa45dd654f3b49e14
parent8bd5873a04bc8c506694d00be4111549d969fd2a (diff)
downloadopie-5fbf2a6b9cda98ab16fa1f0e1ac848a9bb523a72.zip
opie-5fbf2a6b9cda98ab16fa1f0e1ac848a9bb523a72.tar.gz
opie-5fbf2a6b9cda98ab16fa1f0e1ac848a9bb523a72.tar.bz2
mail-parts will get a path id for hierarchic structure of the content
while displaying enclosed rfc mails (like forwards) will be marked as a body-part.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/genericwrapper.cpp47
-rw-r--r--noncore/net/mail/genericwrapper.h2
-rw-r--r--noncore/net/mail/libmailwrapper/genericwrapper.cpp47
-rw-r--r--noncore/net/mail/libmailwrapper/genericwrapper.h2
4 files changed, 78 insertions, 20 deletions
diff --git a/noncore/net/mail/genericwrapper.cpp b/noncore/net/mail/genericwrapper.cpp
index bef6ae5..5de9299 100644
--- a/noncore/net/mail/genericwrapper.cpp
+++ b/noncore/net/mail/genericwrapper.cpp
@@ -1,312 +1,341 @@
1#include "genericwrapper.h" 1#include "genericwrapper.h"
2#include <libetpan/libetpan.h> 2#include <libetpan/libetpan.h>
3#include "mailtypes.h" 3#include "mailtypes.h"
4 4
5Genericwrapper::Genericwrapper() 5Genericwrapper::Genericwrapper()
6 : AbstractMail() 6 : AbstractMail()
7{ 7{
8 bodyCache.clear(); 8 bodyCache.clear();
9} 9}
10 10
11Genericwrapper::~Genericwrapper() 11Genericwrapper::~Genericwrapper()
12{ 12{
13 cleanMimeCache(); 13 cleanMimeCache();
14} 14}
15 15
16void Genericwrapper::fillSingleBody(RecPart&target,mailmessage*,mailmime*mime) 16void Genericwrapper::fillSingleBody(RecPart&target,mailmessage*,mailmime*mime)
17{ 17{
18 if (!mime) { 18 if (!mime) {
19 return; 19 return;
20 } 20 }
21 mailmime_field*field = 0; 21 mailmime_field*field = 0;
22 mailmime_single_fields fields; 22 mailmime_single_fields fields;
23 memset(&fields, 0, sizeof(struct mailmime_single_fields)); 23 memset(&fields, 0, sizeof(struct mailmime_single_fields));
24 if (mime->mm_mime_fields != NULL) { 24 if (mime->mm_mime_fields != NULL) {
25 mailmime_single_fields_init(&fields, mime->mm_mime_fields, 25 mailmime_single_fields_init(&fields, mime->mm_mime_fields,
26 mime->mm_content_type); 26 mime->mm_content_type);
27 } 27 }
28 28
29 mailmime_content*type = fields.fld_content; 29 mailmime_content*type = fields.fld_content;
30 clistcell*current; 30 clistcell*current;
31 if (!type) { 31 if (!type) {
32 target.setType("text"); 32 target.setType("text");
33 target.setSubtype("plain"); 33 target.setSubtype("plain");
34 } else { 34 } else {
35 target.setSubtype(type->ct_subtype); 35 target.setSubtype(type->ct_subtype);
36 switch(type->ct_type->tp_data.tp_discrete_type->dt_type) { 36 switch(type->ct_type->tp_data.tp_discrete_type->dt_type) {
37 case MAILMIME_DISCRETE_TYPE_TEXT: 37 case MAILMIME_DISCRETE_TYPE_TEXT:
38 target.setType("text"); 38 target.setType("text");
39 break; 39 break;
40 case MAILMIME_DISCRETE_TYPE_IMAGE: 40 case MAILMIME_DISCRETE_TYPE_IMAGE:
41 target.setType("image"); 41 target.setType("image");
42 break; 42 break;
43 case MAILMIME_DISCRETE_TYPE_AUDIO: 43 case MAILMIME_DISCRETE_TYPE_AUDIO:
44 target.setType("audio"); 44 target.setType("audio");
45 break; 45 break;
46 case MAILMIME_DISCRETE_TYPE_VIDEO: 46 case MAILMIME_DISCRETE_TYPE_VIDEO:
47 target.setType("video"); 47 target.setType("video");
48 break; 48 break;
49 case MAILMIME_DISCRETE_TYPE_APPLICATION: 49 case MAILMIME_DISCRETE_TYPE_APPLICATION:
50 target.setType("application"); 50 target.setType("application");
51 break; 51 break;
52 case MAILMIME_DISCRETE_TYPE_EXTENSION: 52 case MAILMIME_DISCRETE_TYPE_EXTENSION:
53 default: 53 default:
54 if (type->ct_type->tp_data.tp_discrete_type->dt_extension) { 54 if (type->ct_type->tp_data.tp_discrete_type->dt_extension) {
55 target.setType(type->ct_type->tp_data.tp_discrete_type->dt_extension); 55 target.setType(type->ct_type->tp_data.tp_discrete_type->dt_extension);
56 } 56 }
57 break; 57 break;
58 } 58 }
59 if (type->ct_parameters) { 59 if (type->ct_parameters) {
60 fillParameters(target,type->ct_parameters); 60 fillParameters(target,type->ct_parameters);
61 } 61 }
62 } 62 }
63 if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) { 63 if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) {
64 for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) { 64 for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) {
65 field = (mailmime_field*)current->data; 65 field = (mailmime_field*)current->data;
66 switch(field->fld_type) { 66 switch(field->fld_type) {
67 case MAILMIME_FIELD_TRANSFER_ENCODING: 67 case MAILMIME_FIELD_TRANSFER_ENCODING:
68 target.setEncoding(getencoding(field->fld_data.fld_encoding)); 68 target.setEncoding(getencoding(field->fld_data.fld_encoding));
69 break; 69 break;
70 case MAILMIME_FIELD_ID: 70 case MAILMIME_FIELD_ID:
71 target.setIdentifier(field->fld_data.fld_id); 71 target.setIdentifier(field->fld_data.fld_id);
72 break; 72 break;
73 case MAILMIME_FIELD_DESCRIPTION: 73 case MAILMIME_FIELD_DESCRIPTION:
74 target.setDescription(field->fld_data.fld_description); 74 target.setDescription(field->fld_data.fld_description);
75 break; 75 break;
76 default: 76 default:
77 break; 77 break;
78 } 78 }
79 } 79 }
80 } 80 }
81} 81}
82 82
83void Genericwrapper::fillParameters(RecPart&target,clist*parameters) 83void Genericwrapper::fillParameters(RecPart&target,clist*parameters)
84{ 84{
85 if (!parameters) {return;} 85 if (!parameters) {return;}
86 clistcell*current=0; 86 clistcell*current=0;
87 mailmime_parameter*param; 87 mailmime_parameter*param;
88 for (current=clist_begin(parameters);current!=0;current=clist_next(current)) { 88 for (current=clist_begin(parameters);current!=0;current=clist_next(current)) {
89 param = (mailmime_parameter*)current->data; 89 param = (mailmime_parameter*)current->data;
90 if (param) { 90 if (param) {
91 target.addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); 91 target.addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
92 } 92 }
93 } 93 }
94} 94}
95 95
96QString Genericwrapper::getencoding(mailmime_mechanism*aEnc) 96QString Genericwrapper::getencoding(mailmime_mechanism*aEnc)
97{ 97{
98 QString enc="7bit"; 98 QString enc="7bit";
99 if (!aEnc) return enc; 99 if (!aEnc) return enc;
100 switch(aEnc->enc_type) { 100 switch(aEnc->enc_type) {
101 case MAILMIME_MECHANISM_7BIT: 101 case MAILMIME_MECHANISM_7BIT:
102 enc = "7bit"; 102 enc = "7bit";
103 break; 103 break;
104 case MAILMIME_MECHANISM_8BIT: 104 case MAILMIME_MECHANISM_8BIT:
105 enc = "8bit"; 105 enc = "8bit";
106 break; 106 break;
107 case MAILMIME_MECHANISM_BINARY: 107 case MAILMIME_MECHANISM_BINARY:
108 enc = "binary"; 108 enc = "binary";
109 break; 109 break;
110 case MAILMIME_MECHANISM_QUOTED_PRINTABLE: 110 case MAILMIME_MECHANISM_QUOTED_PRINTABLE:
111 enc = "quoted-printable"; 111 enc = "quoted-printable";
112 break; 112 break;
113 case MAILMIME_MECHANISM_BASE64: 113 case MAILMIME_MECHANISM_BASE64:
114 enc = "base64"; 114 enc = "base64";
115 break; 115 break;
116 case MAILMIME_MECHANISM_TOKEN: 116 case MAILMIME_MECHANISM_TOKEN:
117 default: 117 default:
118 if (aEnc->enc_token) { 118 if (aEnc->enc_token) {
119 enc = QString(aEnc->enc_token); 119 enc = QString(aEnc->enc_token);
120 } 120 }
121 break; 121 break;
122 } 122 }
123 return enc; 123 return enc;
124} 124}
125 125
126void Genericwrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mime,unsigned int current_rec) 126void Genericwrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count)
127{ 127{
128 if (current_rec >= 10) { 128 if (current_rec >= 10) {
129 qDebug("too deep recursion!"); 129 qDebug("too deep recursion!");
130 } 130 }
131 if (!message || !mime) { 131 if (!message || !mime) {
132 return; 132 return;
133 } 133 }
134 int r; 134 int r;
135 char*data = 0; 135 char*data = 0;
136 size_t len; 136 size_t len;
137 clistiter * cur = 0; 137 clistiter * cur = 0;
138 QString b; 138 QString b;
139 RecPart part; 139 RecPart part;
140 140
141 //current_count;
142
141 switch (mime->mm_type) { 143 switch (mime->mm_type) {
142 case MAILMIME_SINGLE: 144 case MAILMIME_SINGLE:
145 {
146 QValueList<int>countlist = recList;
147 countlist.append(current_count);
143 r = mailmessage_fetch_section(message,mime,&data,&len); 148 r = mailmessage_fetch_section(message,mime,&data,&len);
144 part.setSize(len); 149 part.setSize(len);
150 part.setPositionlist(countlist);
151 b = gen_attachment_id();
152 part.setIdentifier(b);
145 fillSingleBody(part,message,mime); 153 fillSingleBody(part,message,mime);
146 if (part.Type()=="text" && target.Bodytext().isNull()) { 154 if (part.Type()=="text" && target.Bodytext().isNull()) {
147 encodedString*r = new encodedString(); 155 encodedString*r = new encodedString();
148 r->setContent(data,len); 156 r->setContent(data,len);
149 encodedString*res = decode_String(r,part.Encoding()); 157 encodedString*res = decode_String(r,part.Encoding());
150 b = QString(res->Content()); 158 b = QString(res->Content());
151 delete r; 159 delete r;
152 delete res; 160 delete res;
153 target.setBodytext(b); 161 target.setBodytext(b);
154 target.setDescription(part); 162 target.setDescription(part);
155 } else { 163 } else {
156 b = gen_attachment_id();
157 part.setIdentifier(b);
158 bodyCache[b]=new encodedString(data,len); 164 bodyCache[b]=new encodedString(data,len);
159 target.addPart(part); 165 target.addPart(part);
160 } 166 }
161 break; 167 }
168 break;
162 case MAILMIME_MULTIPLE: 169 case MAILMIME_MULTIPLE:
170 {
171 unsigned int ccount = current_count;
163 for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { 172 for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) {
164 traverseBody(target,message, (mailmime*)clist_content(cur),current_rec+1); 173 traverseBody(target,message, (mailmime*)clist_content(cur),recList,current_rec+1,ccount);
174 ++ccount;
165 } 175 }
166 break; 176 }
177 break;
167 case MAILMIME_MESSAGE: 178 case MAILMIME_MESSAGE:
179 {
180 QValueList<int>countlist = recList;
181 countlist.append(current_count);
182 /* the own header is always at recursion 0 - we don't need that */
183 if (current_rec > 0) {
184 part.setPositionlist(countlist);
185 r = mailmessage_fetch_section(message,mime,&data,&len);
186 part.setSize(len);
187 part.setPositionlist(countlist);
188 b = gen_attachment_id();
189 part.setIdentifier(b);
190 part.setType("message");
191 part.setSubtype("rfc822");
192 bodyCache[b]=new encodedString(data,len);
193 target.addPart(part);
194 }
168 if (mime->mm_data.mm_message.mm_msg_mime != NULL) { 195 if (mime->mm_data.mm_message.mm_msg_mime != NULL) {
169 traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,current_rec+1); 196 traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1);
170 } 197 }
171 break; 198 }
199 break;
172 } 200 }
173} 201}
174 202
175RecBody Genericwrapper::parseMail( mailmessage * msg ) 203RecBody Genericwrapper::parseMail( mailmessage * msg )
176{ 204{
177 int err = MAILIMF_NO_ERROR; 205 int err = MAILIMF_NO_ERROR;
178 mailmime_single_fields fields; 206 mailmime_single_fields fields;
179 /* is bound to msg and will be freed there */ 207 /* is bound to msg and will be freed there */
180 mailmime * mime=0; 208 mailmime * mime=0;
181 RecBody body; 209 RecBody body;
182 memset(&fields, 0, sizeof(struct mailmime_single_fields)); 210 memset(&fields, 0, sizeof(struct mailmime_single_fields));
183 err = mailmessage_get_bodystructure(msg,&mime); 211 err = mailmessage_get_bodystructure(msg,&mime);
184 traverseBody(body,msg,mime); 212 QValueList<int>recList;
213 traverseBody(body,msg,mime,recList);
185 return body; 214 return body;
186} 215}
187 216
188RecMail *Genericwrapper::parseHeader( const char *header ) 217RecMail *Genericwrapper::parseHeader( const char *header )
189{ 218{
190 int err = MAILIMF_NO_ERROR; 219 int err = MAILIMF_NO_ERROR;
191 size_t curTok = 0; 220 size_t curTok = 0;
192 RecMail *mail = new RecMail(); 221 RecMail *mail = new RecMail();
193 mailimf_fields *fields = 0; 222 mailimf_fields *fields = 0;
194 mailimf_references * refs = 0; 223 mailimf_references * refs = 0;
195 mailimf_keywords*keys = 0; 224 mailimf_keywords*keys = 0;
196 QString status; 225 QString status;
197 QString value; 226 QString value;
198 QBitArray mFlags(7); 227 QBitArray mFlags(7);
199 228
200 err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields ); 229 err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields );
201 for ( clistiter *current = clist_begin( fields->fld_list ); current != NULL; current = current->next ) { 230 for ( clistiter *current = clist_begin( fields->fld_list ); current != NULL; current = current->next ) {
202 mailimf_field *field = (mailimf_field *) current->data; 231 mailimf_field *field = (mailimf_field *) current->data;
203 switch ( field->fld_type ) { 232 switch ( field->fld_type ) {
204 case MAILIMF_FIELD_FROM: 233 case MAILIMF_FIELD_FROM:
205 mail->setFrom( parseMailboxList( field->fld_data.fld_from->frm_mb_list ) ); 234 mail->setFrom( parseMailboxList( field->fld_data.fld_from->frm_mb_list ) );
206 break; 235 break;
207 case MAILIMF_FIELD_TO: 236 case MAILIMF_FIELD_TO:
208 mail->setTo( parseAddressList( field->fld_data.fld_to->to_addr_list ) ); 237 mail->setTo( parseAddressList( field->fld_data.fld_to->to_addr_list ) );
209 break; 238 break;
210 case MAILIMF_FIELD_CC: 239 case MAILIMF_FIELD_CC:
211 mail->setCC( parseAddressList( field->fld_data.fld_cc->cc_addr_list ) ); 240 mail->setCC( parseAddressList( field->fld_data.fld_cc->cc_addr_list ) );
212 break; 241 break;
213 case MAILIMF_FIELD_BCC: 242 case MAILIMF_FIELD_BCC:
214 mail->setBcc( parseAddressList( field->fld_data.fld_bcc->bcc_addr_list ) ); 243 mail->setBcc( parseAddressList( field->fld_data.fld_bcc->bcc_addr_list ) );
215 break; 244 break;
216 case MAILIMF_FIELD_SUBJECT: 245 case MAILIMF_FIELD_SUBJECT:
217 mail->setSubject(convert_String( field->fld_data.fld_subject->sbj_value ) ); 246 mail->setSubject(convert_String( field->fld_data.fld_subject->sbj_value ) );
218 break; 247 break;
219 case MAILIMF_FIELD_ORIG_DATE: 248 case MAILIMF_FIELD_ORIG_DATE:
220 mail->setDate( parseDateTime( field->fld_data.fld_orig_date->dt_date_time ) ); 249 mail->setDate( parseDateTime( field->fld_data.fld_orig_date->dt_date_time ) );
221 break; 250 break;
222 case MAILIMF_FIELD_MESSAGE_ID: 251 case MAILIMF_FIELD_MESSAGE_ID:
223 mail->setMsgid(QString(field->fld_data.fld_message_id->mid_value)); 252 mail->setMsgid(QString(field->fld_data.fld_message_id->mid_value));
224 break; 253 break;
225 case MAILIMF_FIELD_REFERENCES: 254 case MAILIMF_FIELD_REFERENCES:
226 refs = field->fld_data.fld_references; 255 refs = field->fld_data.fld_references;
227 if (refs && refs->mid_list && clist_count(refs->mid_list)) { 256 if (refs && refs->mid_list && clist_count(refs->mid_list)) {
228 char * text = (char*)refs->mid_list->first->data; 257 char * text = (char*)refs->mid_list->first->data;
229 mail->setReplyto(QString(text)); 258 mail->setReplyto(QString(text));
230 } 259 }
231 break; 260 break;
232 case MAILIMF_FIELD_KEYWORDS: 261 case MAILIMF_FIELD_KEYWORDS:
233 keys = field->fld_data.fld_keywords; 262 keys = field->fld_data.fld_keywords;
234 for (clistcell*cur = clist_begin(keys->kw_list);cur!=0;cur=clist_next(cur)) { 263 for (clistcell*cur = clist_begin(keys->kw_list);cur!=0;cur=clist_next(cur)) {
235 qDebug("Keyword: %s",(char*)cur->data); 264 qDebug("Keyword: %s",(char*)cur->data);
236 } 265 }
237 break; 266 break;
238 case MAILIMF_FIELD_OPTIONAL_FIELD: 267 case MAILIMF_FIELD_OPTIONAL_FIELD:
239 status = field->fld_data.fld_optional_field->fld_name; 268 status = field->fld_data.fld_optional_field->fld_name;
240 value = field->fld_data.fld_optional_field->fld_value; 269 value = field->fld_data.fld_optional_field->fld_value;
241 if (status.lower()=="status") { 270 if (status.lower()=="status") {
242 if (value.lower()=="ro") { 271 if (value.lower()=="ro") {
243 mFlags.setBit(FLAG_SEEN); 272 mFlags.setBit(FLAG_SEEN);
244 } 273 }
245 } else if (status.lower()=="x-status") { 274 } else if (status.lower()=="x-status") {
246 qDebug("X-Status: %s",value.latin1()); 275 qDebug("X-Status: %s",value.latin1());
247 if (value.lower()=="a") { 276 if (value.lower()=="a") {
248 mFlags.setBit(FLAG_ANSWERED); 277 mFlags.setBit(FLAG_ANSWERED);
249 } 278 }
250 } else { 279 } else {
251// qDebug("Optionales feld: %s -> %s)",field->fld_data.fld_optional_field->fld_name, 280// qDebug("Optionales feld: %s -> %s)",field->fld_data.fld_optional_field->fld_name,
252// field->fld_data.fld_optional_field->fld_value); 281// field->fld_data.fld_optional_field->fld_value);
253 } 282 }
254 break; 283 break;
255 default: 284 default:
256 qDebug("Non parsed field"); 285 qDebug("Non parsed field");
257 break; 286 break;
258 } 287 }
259 } 288 }
260 if (fields) mailimf_fields_free(fields); 289 if (fields) mailimf_fields_free(fields);
261 mail->setFlags(mFlags); 290 mail->setFlags(mFlags);
262 return mail; 291 return mail;
263} 292}
264 293
265QString Genericwrapper::parseDateTime( mailimf_date_time *date ) 294QString Genericwrapper::parseDateTime( mailimf_date_time *date )
266{ 295{
267 char tmp[23]; 296 char tmp[23];
268 297
269 snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", 298 snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i",
270 date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); 299 date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone );
271 300
272 return QString( tmp ); 301 return QString( tmp );
273} 302}
274 303
275QString Genericwrapper::parseAddressList( mailimf_address_list *list ) 304QString Genericwrapper::parseAddressList( mailimf_address_list *list )
276{ 305{
277 QString result( "" ); 306 QString result( "" );
278 307
279 bool first = true; 308 bool first = true;
280 if (list == 0) return result; 309 if (list == 0) return result;
281 for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { 310 for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) {
282 mailimf_address *addr = (mailimf_address *) current->data; 311 mailimf_address *addr = (mailimf_address *) current->data;
283 312
284 if ( !first ) { 313 if ( !first ) {
285 result.append( "," ); 314 result.append( "," );
286 } else { 315 } else {
287 first = false; 316 first = false;
288 } 317 }
289 318
290 switch ( addr->ad_type ) { 319 switch ( addr->ad_type ) {
291 case MAILIMF_ADDRESS_MAILBOX: 320 case MAILIMF_ADDRESS_MAILBOX:
292 result.append( parseMailbox( addr->ad_data.ad_mailbox ) ); 321 result.append( parseMailbox( addr->ad_data.ad_mailbox ) );
293 break; 322 break;
294 case MAILIMF_ADDRESS_GROUP: 323 case MAILIMF_ADDRESS_GROUP:
295 result.append( parseGroup( addr->ad_data.ad_group ) ); 324 result.append( parseGroup( addr->ad_data.ad_group ) );
296 break; 325 break;
297 default: 326 default:
298 qDebug( "Generic: unkown mailimf address type" ); 327 qDebug( "Generic: unkown mailimf address type" );
299 break; 328 break;
300 } 329 }
301 } 330 }
302 331
303 return result; 332 return result;
304} 333}
305 334
306QString Genericwrapper::parseGroup( mailimf_group *group ) 335QString Genericwrapper::parseGroup( mailimf_group *group )
307{ 336{
308 QString result( "" ); 337 QString result( "" );
309 338
310 result.append( group->grp_display_name ); 339 result.append( group->grp_display_name );
311 result.append( ": " ); 340 result.append( ": " );
312 341
diff --git a/noncore/net/mail/genericwrapper.h b/noncore/net/mail/genericwrapper.h
index 54d6ea9..c00d864 100644
--- a/noncore/net/mail/genericwrapper.h
+++ b/noncore/net/mail/genericwrapper.h
@@ -1,59 +1,59 @@
1#ifndef __GENERIC_WRAPPER_H 1#ifndef __GENERIC_WRAPPER_H
2#define __GENERIC_WRAPPER_H 2#define __GENERIC_WRAPPER_H
3 3
4#include "abstractmail.h" 4#include "abstractmail.h"
5#include <qmap.h> 5#include <qmap.h>
6#include <qstring.h> 6#include <qstring.h>
7#include <libetpan/clist.h> 7#include <libetpan/clist.h>
8 8
9class RecMail; 9class RecMail;
10class RecBody; 10class RecBody;
11class encodedString; 11class encodedString;
12struct mailpop3; 12struct mailpop3;
13struct mailmessage; 13struct mailmessage;
14struct mailmime; 14struct mailmime;
15struct mailmime_mechanism; 15struct mailmime_mechanism;
16struct mailimf_mailbox_list; 16struct mailimf_mailbox_list;
17struct mailimf_mailbox; 17struct mailimf_mailbox;
18struct mailimf_date_time; 18struct mailimf_date_time;
19struct mailimf_group; 19struct mailimf_group;
20struct mailimf_address_list; 20struct mailimf_address_list;
21struct mailsession; 21struct mailsession;
22 22
23/* this class hold just the funs shared between 23/* this class hold just the funs shared between
24 * mbox and pop3 (later mh, too) mail access. 24 * mbox and pop3 (later mh, too) mail access.
25 * it is not desigend to make a instance of it! 25 * it is not desigend to make a instance of it!
26 */ 26 */
27class Genericwrapper : public AbstractMail 27class Genericwrapper : public AbstractMail
28{ 28{
29 Q_OBJECT 29 Q_OBJECT
30public: 30public:
31 Genericwrapper(); 31 Genericwrapper();
32 virtual ~Genericwrapper(); 32 virtual ~Genericwrapper();
33 33
34 virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); 34 virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part);
35 virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); 35 virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part);
36 virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); 36 virtual QString fetchTextPart(const RecMail&mail,const RecPart&part);
37 virtual void cleanMimeCache(); 37 virtual void cleanMimeCache();
38 38
39protected: 39protected:
40 RecMail *parseHeader( const char *header ); 40 RecMail *parseHeader( const char *header );
41 RecBody parseMail( mailmessage * msg ); 41 RecBody parseMail( mailmessage * msg );
42 QString parseMailboxList( mailimf_mailbox_list *list ); 42 QString parseMailboxList( mailimf_mailbox_list *list );
43 QString parseMailbox( mailimf_mailbox *box ); 43 QString parseMailbox( mailimf_mailbox *box );
44 QString parseGroup( mailimf_group *group ); 44 QString parseGroup( mailimf_group *group );
45 QString parseAddressList( mailimf_address_list *list ); 45 QString parseAddressList( mailimf_address_list *list );
46 QString parseDateTime( mailimf_date_time *date ); 46 QString parseDateTime( mailimf_date_time *date );
47 47
48 void traverseBody(RecBody&target,mailmessage*message,mailmime*mime,unsigned int current_rek=0); 48 void traverseBody(RecBody&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rek=0,int current_count=0);
49 static void fillSingleBody(RecPart&target,mailmessage*message,mailmime*mime); 49 static void fillSingleBody(RecPart&target,mailmessage*message,mailmime*mime);
50 static void fillParameters(RecPart&target,clist*parameters); 50 static void fillParameters(RecPart&target,clist*parameters);
51 static QString getencoding(mailmime_mechanism*aEnc); 51 static QString getencoding(mailmime_mechanism*aEnc);
52 virtual void parseList(QList<RecMail> &target,mailsession*session,const QString&mailbox); 52 virtual void parseList(QList<RecMail> &target,mailsession*session,const QString&mailbox);
53 53
54 QString msgTempName; 54 QString msgTempName;
55 unsigned int last_msg_id; 55 unsigned int last_msg_id;
56 QMap<QString,encodedString*> bodyCache; 56 QMap<QString,encodedString*> bodyCache;
57}; 57};
58 58
59#endif 59#endif
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.cpp b/noncore/net/mail/libmailwrapper/genericwrapper.cpp
index bef6ae5..5de9299 100644
--- a/noncore/net/mail/libmailwrapper/genericwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/genericwrapper.cpp
@@ -1,312 +1,341 @@
1#include "genericwrapper.h" 1#include "genericwrapper.h"
2#include <libetpan/libetpan.h> 2#include <libetpan/libetpan.h>
3#include "mailtypes.h" 3#include "mailtypes.h"
4 4
5Genericwrapper::Genericwrapper() 5Genericwrapper::Genericwrapper()
6 : AbstractMail() 6 : AbstractMail()
7{ 7{
8 bodyCache.clear(); 8 bodyCache.clear();
9} 9}
10 10
11Genericwrapper::~Genericwrapper() 11Genericwrapper::~Genericwrapper()
12{ 12{
13 cleanMimeCache(); 13 cleanMimeCache();
14} 14}
15 15
16void Genericwrapper::fillSingleBody(RecPart&target,mailmessage*,mailmime*mime) 16void Genericwrapper::fillSingleBody(RecPart&target,mailmessage*,mailmime*mime)
17{ 17{
18 if (!mime) { 18 if (!mime) {
19 return; 19 return;
20 } 20 }
21 mailmime_field*field = 0; 21 mailmime_field*field = 0;
22 mailmime_single_fields fields; 22 mailmime_single_fields fields;
23 memset(&fields, 0, sizeof(struct mailmime_single_fields)); 23 memset(&fields, 0, sizeof(struct mailmime_single_fields));
24 if (mime->mm_mime_fields != NULL) { 24 if (mime->mm_mime_fields != NULL) {
25 mailmime_single_fields_init(&fields, mime->mm_mime_fields, 25 mailmime_single_fields_init(&fields, mime->mm_mime_fields,
26 mime->mm_content_type); 26 mime->mm_content_type);
27 } 27 }
28 28
29 mailmime_content*type = fields.fld_content; 29 mailmime_content*type = fields.fld_content;
30 clistcell*current; 30 clistcell*current;
31 if (!type) { 31 if (!type) {
32 target.setType("text"); 32 target.setType("text");
33 target.setSubtype("plain"); 33 target.setSubtype("plain");
34 } else { 34 } else {
35 target.setSubtype(type->ct_subtype); 35 target.setSubtype(type->ct_subtype);
36 switch(type->ct_type->tp_data.tp_discrete_type->dt_type) { 36 switch(type->ct_type->tp_data.tp_discrete_type->dt_type) {
37 case MAILMIME_DISCRETE_TYPE_TEXT: 37 case MAILMIME_DISCRETE_TYPE_TEXT:
38 target.setType("text"); 38 target.setType("text");
39 break; 39 break;
40 case MAILMIME_DISCRETE_TYPE_IMAGE: 40 case MAILMIME_DISCRETE_TYPE_IMAGE:
41 target.setType("image"); 41 target.setType("image");
42 break; 42 break;
43 case MAILMIME_DISCRETE_TYPE_AUDIO: 43 case MAILMIME_DISCRETE_TYPE_AUDIO:
44 target.setType("audio"); 44 target.setType("audio");
45 break; 45 break;
46 case MAILMIME_DISCRETE_TYPE_VIDEO: 46 case MAILMIME_DISCRETE_TYPE_VIDEO:
47 target.setType("video"); 47 target.setType("video");
48 break; 48 break;
49 case MAILMIME_DISCRETE_TYPE_APPLICATION: 49 case MAILMIME_DISCRETE_TYPE_APPLICATION:
50 target.setType("application"); 50 target.setType("application");
51 break; 51 break;
52 case MAILMIME_DISCRETE_TYPE_EXTENSION: 52 case MAILMIME_DISCRETE_TYPE_EXTENSION:
53 default: 53 default:
54 if (type->ct_type->tp_data.tp_discrete_type->dt_extension) { 54 if (type->ct_type->tp_data.tp_discrete_type->dt_extension) {
55 target.setType(type->ct_type->tp_data.tp_discrete_type->dt_extension); 55 target.setType(type->ct_type->tp_data.tp_discrete_type->dt_extension);
56 } 56 }
57 break; 57 break;
58 } 58 }
59 if (type->ct_parameters) { 59 if (type->ct_parameters) {
60 fillParameters(target,type->ct_parameters); 60 fillParameters(target,type->ct_parameters);
61 } 61 }
62 } 62 }
63 if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) { 63 if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) {
64 for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) { 64 for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) {
65 field = (mailmime_field*)current->data; 65 field = (mailmime_field*)current->data;
66 switch(field->fld_type) { 66 switch(field->fld_type) {
67 case MAILMIME_FIELD_TRANSFER_ENCODING: 67 case MAILMIME_FIELD_TRANSFER_ENCODING:
68 target.setEncoding(getencoding(field->fld_data.fld_encoding)); 68 target.setEncoding(getencoding(field->fld_data.fld_encoding));
69 break; 69 break;
70 case MAILMIME_FIELD_ID: 70 case MAILMIME_FIELD_ID:
71 target.setIdentifier(field->fld_data.fld_id); 71 target.setIdentifier(field->fld_data.fld_id);
72 break; 72 break;
73 case MAILMIME_FIELD_DESCRIPTION: 73 case MAILMIME_FIELD_DESCRIPTION:
74 target.setDescription(field->fld_data.fld_description); 74 target.setDescription(field->fld_data.fld_description);
75 break; 75 break;
76 default: 76 default:
77 break; 77 break;
78 } 78 }
79 } 79 }
80 } 80 }
81} 81}
82 82
83void Genericwrapper::fillParameters(RecPart&target,clist*parameters) 83void Genericwrapper::fillParameters(RecPart&target,clist*parameters)
84{ 84{
85 if (!parameters) {return;} 85 if (!parameters) {return;}
86 clistcell*current=0; 86 clistcell*current=0;
87 mailmime_parameter*param; 87 mailmime_parameter*param;
88 for (current=clist_begin(parameters);current!=0;current=clist_next(current)) { 88 for (current=clist_begin(parameters);current!=0;current=clist_next(current)) {
89 param = (mailmime_parameter*)current->data; 89 param = (mailmime_parameter*)current->data;
90 if (param) { 90 if (param) {
91 target.addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); 91 target.addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
92 } 92 }
93 } 93 }
94} 94}
95 95
96QString Genericwrapper::getencoding(mailmime_mechanism*aEnc) 96QString Genericwrapper::getencoding(mailmime_mechanism*aEnc)
97{ 97{
98 QString enc="7bit"; 98 QString enc="7bit";
99 if (!aEnc) return enc; 99 if (!aEnc) return enc;
100 switch(aEnc->enc_type) { 100 switch(aEnc->enc_type) {
101 case MAILMIME_MECHANISM_7BIT: 101 case MAILMIME_MECHANISM_7BIT:
102 enc = "7bit"; 102 enc = "7bit";
103 break; 103 break;
104 case MAILMIME_MECHANISM_8BIT: 104 case MAILMIME_MECHANISM_8BIT:
105 enc = "8bit"; 105 enc = "8bit";
106 break; 106 break;
107 case MAILMIME_MECHANISM_BINARY: 107 case MAILMIME_MECHANISM_BINARY:
108 enc = "binary"; 108 enc = "binary";
109 break; 109 break;
110 case MAILMIME_MECHANISM_QUOTED_PRINTABLE: 110 case MAILMIME_MECHANISM_QUOTED_PRINTABLE:
111 enc = "quoted-printable"; 111 enc = "quoted-printable";
112 break; 112 break;
113 case MAILMIME_MECHANISM_BASE64: 113 case MAILMIME_MECHANISM_BASE64:
114 enc = "base64"; 114 enc = "base64";
115 break; 115 break;
116 case MAILMIME_MECHANISM_TOKEN: 116 case MAILMIME_MECHANISM_TOKEN:
117 default: 117 default:
118 if (aEnc->enc_token) { 118 if (aEnc->enc_token) {
119 enc = QString(aEnc->enc_token); 119 enc = QString(aEnc->enc_token);
120 } 120 }
121 break; 121 break;
122 } 122 }
123 return enc; 123 return enc;
124} 124}
125 125
126void Genericwrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mime,unsigned int current_rec) 126void Genericwrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count)
127{ 127{
128 if (current_rec >= 10) { 128 if (current_rec >= 10) {
129 qDebug("too deep recursion!"); 129 qDebug("too deep recursion!");
130 } 130 }
131 if (!message || !mime) { 131 if (!message || !mime) {
132 return; 132 return;
133 } 133 }
134 int r; 134 int r;
135 char*data = 0; 135 char*data = 0;
136 size_t len; 136 size_t len;
137 clistiter * cur = 0; 137 clistiter * cur = 0;
138 QString b; 138 QString b;
139 RecPart part; 139 RecPart part;
140 140
141 //current_count;
142
141 switch (mime->mm_type) { 143 switch (mime->mm_type) {
142 case MAILMIME_SINGLE: 144 case MAILMIME_SINGLE:
145 {
146 QValueList<int>countlist = recList;
147 countlist.append(current_count);
143 r = mailmessage_fetch_section(message,mime,&data,&len); 148 r = mailmessage_fetch_section(message,mime,&data,&len);
144 part.setSize(len); 149 part.setSize(len);
150 part.setPositionlist(countlist);
151 b = gen_attachment_id();
152 part.setIdentifier(b);
145 fillSingleBody(part,message,mime); 153 fillSingleBody(part,message,mime);
146 if (part.Type()=="text" && target.Bodytext().isNull()) { 154 if (part.Type()=="text" && target.Bodytext().isNull()) {
147 encodedString*r = new encodedString(); 155 encodedString*r = new encodedString();
148 r->setContent(data,len); 156 r->setContent(data,len);
149 encodedString*res = decode_String(r,part.Encoding()); 157 encodedString*res = decode_String(r,part.Encoding());
150 b = QString(res->Content()); 158 b = QString(res->Content());
151 delete r; 159 delete r;
152 delete res; 160 delete res;
153 target.setBodytext(b); 161 target.setBodytext(b);
154 target.setDescription(part); 162 target.setDescription(part);
155 } else { 163 } else {
156 b = gen_attachment_id();
157 part.setIdentifier(b);
158 bodyCache[b]=new encodedString(data,len); 164 bodyCache[b]=new encodedString(data,len);
159 target.addPart(part); 165 target.addPart(part);
160 } 166 }
161 break; 167 }
168 break;
162 case MAILMIME_MULTIPLE: 169 case MAILMIME_MULTIPLE:
170 {
171 unsigned int ccount = current_count;
163 for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { 172 for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) {
164 traverseBody(target,message, (mailmime*)clist_content(cur),current_rec+1); 173 traverseBody(target,message, (mailmime*)clist_content(cur),recList,current_rec+1,ccount);
174 ++ccount;
165 } 175 }
166 break; 176 }
177 break;
167 case MAILMIME_MESSAGE: 178 case MAILMIME_MESSAGE:
179 {
180 QValueList<int>countlist = recList;
181 countlist.append(current_count);
182 /* the own header is always at recursion 0 - we don't need that */
183 if (current_rec > 0) {
184 part.setPositionlist(countlist);
185 r = mailmessage_fetch_section(message,mime,&data,&len);
186 part.setSize(len);
187 part.setPositionlist(countlist);
188 b = gen_attachment_id();
189 part.setIdentifier(b);
190 part.setType("message");
191 part.setSubtype("rfc822");
192 bodyCache[b]=new encodedString(data,len);
193 target.addPart(part);
194 }
168 if (mime->mm_data.mm_message.mm_msg_mime != NULL) { 195 if (mime->mm_data.mm_message.mm_msg_mime != NULL) {
169 traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,current_rec+1); 196 traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1);
170 } 197 }
171 break; 198 }
199 break;
172 } 200 }
173} 201}
174 202
175RecBody Genericwrapper::parseMail( mailmessage * msg ) 203RecBody Genericwrapper::parseMail( mailmessage * msg )
176{ 204{
177 int err = MAILIMF_NO_ERROR; 205 int err = MAILIMF_NO_ERROR;
178 mailmime_single_fields fields; 206 mailmime_single_fields fields;
179 /* is bound to msg and will be freed there */ 207 /* is bound to msg and will be freed there */
180 mailmime * mime=0; 208 mailmime * mime=0;
181 RecBody body; 209 RecBody body;
182 memset(&fields, 0, sizeof(struct mailmime_single_fields)); 210 memset(&fields, 0, sizeof(struct mailmime_single_fields));
183 err = mailmessage_get_bodystructure(msg,&mime); 211 err = mailmessage_get_bodystructure(msg,&mime);
184 traverseBody(body,msg,mime); 212 QValueList<int>recList;
213 traverseBody(body,msg,mime,recList);
185 return body; 214 return body;
186} 215}
187 216
188RecMail *Genericwrapper::parseHeader( const char *header ) 217RecMail *Genericwrapper::parseHeader( const char *header )
189{ 218{
190 int err = MAILIMF_NO_ERROR; 219 int err = MAILIMF_NO_ERROR;
191 size_t curTok = 0; 220 size_t curTok = 0;
192 RecMail *mail = new RecMail(); 221 RecMail *mail = new RecMail();
193 mailimf_fields *fields = 0; 222 mailimf_fields *fields = 0;
194 mailimf_references * refs = 0; 223 mailimf_references * refs = 0;
195 mailimf_keywords*keys = 0; 224 mailimf_keywords*keys = 0;
196 QString status; 225 QString status;
197 QString value; 226 QString value;
198 QBitArray mFlags(7); 227 QBitArray mFlags(7);
199 228
200 err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields ); 229 err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields );
201 for ( clistiter *current = clist_begin( fields->fld_list ); current != NULL; current = current->next ) { 230 for ( clistiter *current = clist_begin( fields->fld_list ); current != NULL; current = current->next ) {
202 mailimf_field *field = (mailimf_field *) current->data; 231 mailimf_field *field = (mailimf_field *) current->data;
203 switch ( field->fld_type ) { 232 switch ( field->fld_type ) {
204 case MAILIMF_FIELD_FROM: 233 case MAILIMF_FIELD_FROM:
205 mail->setFrom( parseMailboxList( field->fld_data.fld_from->frm_mb_list ) ); 234 mail->setFrom( parseMailboxList( field->fld_data.fld_from->frm_mb_list ) );
206 break; 235 break;
207 case MAILIMF_FIELD_TO: 236 case MAILIMF_FIELD_TO:
208 mail->setTo( parseAddressList( field->fld_data.fld_to->to_addr_list ) ); 237 mail->setTo( parseAddressList( field->fld_data.fld_to->to_addr_list ) );
209 break; 238 break;
210 case MAILIMF_FIELD_CC: 239 case MAILIMF_FIELD_CC:
211 mail->setCC( parseAddressList( field->fld_data.fld_cc->cc_addr_list ) ); 240 mail->setCC( parseAddressList( field->fld_data.fld_cc->cc_addr_list ) );
212 break; 241 break;
213 case MAILIMF_FIELD_BCC: 242 case MAILIMF_FIELD_BCC:
214 mail->setBcc( parseAddressList( field->fld_data.fld_bcc->bcc_addr_list ) ); 243 mail->setBcc( parseAddressList( field->fld_data.fld_bcc->bcc_addr_list ) );
215 break; 244 break;
216 case MAILIMF_FIELD_SUBJECT: 245 case MAILIMF_FIELD_SUBJECT:
217 mail->setSubject(convert_String( field->fld_data.fld_subject->sbj_value ) ); 246 mail->setSubject(convert_String( field->fld_data.fld_subject->sbj_value ) );
218 break; 247 break;
219 case MAILIMF_FIELD_ORIG_DATE: 248 case MAILIMF_FIELD_ORIG_DATE:
220 mail->setDate( parseDateTime( field->fld_data.fld_orig_date->dt_date_time ) ); 249 mail->setDate( parseDateTime( field->fld_data.fld_orig_date->dt_date_time ) );
221 break; 250 break;
222 case MAILIMF_FIELD_MESSAGE_ID: 251 case MAILIMF_FIELD_MESSAGE_ID:
223 mail->setMsgid(QString(field->fld_data.fld_message_id->mid_value)); 252 mail->setMsgid(QString(field->fld_data.fld_message_id->mid_value));
224 break; 253 break;
225 case MAILIMF_FIELD_REFERENCES: 254 case MAILIMF_FIELD_REFERENCES:
226 refs = field->fld_data.fld_references; 255 refs = field->fld_data.fld_references;
227 if (refs && refs->mid_list && clist_count(refs->mid_list)) { 256 if (refs && refs->mid_list && clist_count(refs->mid_list)) {
228 char * text = (char*)refs->mid_list->first->data; 257 char * text = (char*)refs->mid_list->first->data;
229 mail->setReplyto(QString(text)); 258 mail->setReplyto(QString(text));
230 } 259 }
231 break; 260 break;
232 case MAILIMF_FIELD_KEYWORDS: 261 case MAILIMF_FIELD_KEYWORDS:
233 keys = field->fld_data.fld_keywords; 262 keys = field->fld_data.fld_keywords;
234 for (clistcell*cur = clist_begin(keys->kw_list);cur!=0;cur=clist_next(cur)) { 263 for (clistcell*cur = clist_begin(keys->kw_list);cur!=0;cur=clist_next(cur)) {
235 qDebug("Keyword: %s",(char*)cur->data); 264 qDebug("Keyword: %s",(char*)cur->data);
236 } 265 }
237 break; 266 break;
238 case MAILIMF_FIELD_OPTIONAL_FIELD: 267 case MAILIMF_FIELD_OPTIONAL_FIELD:
239 status = field->fld_data.fld_optional_field->fld_name; 268 status = field->fld_data.fld_optional_field->fld_name;
240 value = field->fld_data.fld_optional_field->fld_value; 269 value = field->fld_data.fld_optional_field->fld_value;
241 if (status.lower()=="status") { 270 if (status.lower()=="status") {
242 if (value.lower()=="ro") { 271 if (value.lower()=="ro") {
243 mFlags.setBit(FLAG_SEEN); 272 mFlags.setBit(FLAG_SEEN);
244 } 273 }
245 } else if (status.lower()=="x-status") { 274 } else if (status.lower()=="x-status") {
246 qDebug("X-Status: %s",value.latin1()); 275 qDebug("X-Status: %s",value.latin1());
247 if (value.lower()=="a") { 276 if (value.lower()=="a") {
248 mFlags.setBit(FLAG_ANSWERED); 277 mFlags.setBit(FLAG_ANSWERED);
249 } 278 }
250 } else { 279 } else {
251// qDebug("Optionales feld: %s -> %s)",field->fld_data.fld_optional_field->fld_name, 280// qDebug("Optionales feld: %s -> %s)",field->fld_data.fld_optional_field->fld_name,
252// field->fld_data.fld_optional_field->fld_value); 281// field->fld_data.fld_optional_field->fld_value);
253 } 282 }
254 break; 283 break;
255 default: 284 default:
256 qDebug("Non parsed field"); 285 qDebug("Non parsed field");
257 break; 286 break;
258 } 287 }
259 } 288 }
260 if (fields) mailimf_fields_free(fields); 289 if (fields) mailimf_fields_free(fields);
261 mail->setFlags(mFlags); 290 mail->setFlags(mFlags);
262 return mail; 291 return mail;
263} 292}
264 293
265QString Genericwrapper::parseDateTime( mailimf_date_time *date ) 294QString Genericwrapper::parseDateTime( mailimf_date_time *date )
266{ 295{
267 char tmp[23]; 296 char tmp[23];
268 297
269 snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", 298 snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i",
270 date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); 299 date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone );
271 300
272 return QString( tmp ); 301 return QString( tmp );
273} 302}
274 303
275QString Genericwrapper::parseAddressList( mailimf_address_list *list ) 304QString Genericwrapper::parseAddressList( mailimf_address_list *list )
276{ 305{
277 QString result( "" ); 306 QString result( "" );
278 307
279 bool first = true; 308 bool first = true;
280 if (list == 0) return result; 309 if (list == 0) return result;
281 for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { 310 for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) {
282 mailimf_address *addr = (mailimf_address *) current->data; 311 mailimf_address *addr = (mailimf_address *) current->data;
283 312
284 if ( !first ) { 313 if ( !first ) {
285 result.append( "," ); 314 result.append( "," );
286 } else { 315 } else {
287 first = false; 316 first = false;
288 } 317 }
289 318
290 switch ( addr->ad_type ) { 319 switch ( addr->ad_type ) {
291 case MAILIMF_ADDRESS_MAILBOX: 320 case MAILIMF_ADDRESS_MAILBOX:
292 result.append( parseMailbox( addr->ad_data.ad_mailbox ) ); 321 result.append( parseMailbox( addr->ad_data.ad_mailbox ) );
293 break; 322 break;
294 case MAILIMF_ADDRESS_GROUP: 323 case MAILIMF_ADDRESS_GROUP:
295 result.append( parseGroup( addr->ad_data.ad_group ) ); 324 result.append( parseGroup( addr->ad_data.ad_group ) );
296 break; 325 break;
297 default: 326 default:
298 qDebug( "Generic: unkown mailimf address type" ); 327 qDebug( "Generic: unkown mailimf address type" );
299 break; 328 break;
300 } 329 }
301 } 330 }
302 331
303 return result; 332 return result;
304} 333}
305 334
306QString Genericwrapper::parseGroup( mailimf_group *group ) 335QString Genericwrapper::parseGroup( mailimf_group *group )
307{ 336{
308 QString result( "" ); 337 QString result( "" );
309 338
310 result.append( group->grp_display_name ); 339 result.append( group->grp_display_name );
311 result.append( ": " ); 340 result.append( ": " );
312 341
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.h b/noncore/net/mail/libmailwrapper/genericwrapper.h
index 54d6ea9..c00d864 100644
--- a/noncore/net/mail/libmailwrapper/genericwrapper.h
+++ b/noncore/net/mail/libmailwrapper/genericwrapper.h
@@ -1,59 +1,59 @@
1#ifndef __GENERIC_WRAPPER_H 1#ifndef __GENERIC_WRAPPER_H
2#define __GENERIC_WRAPPER_H 2#define __GENERIC_WRAPPER_H
3 3
4#include "abstractmail.h" 4#include "abstractmail.h"
5#include <qmap.h> 5#include <qmap.h>
6#include <qstring.h> 6#include <qstring.h>
7#include <libetpan/clist.h> 7#include <libetpan/clist.h>
8 8
9class RecMail; 9class RecMail;
10class RecBody; 10class RecBody;
11class encodedString; 11class encodedString;
12struct mailpop3; 12struct mailpop3;
13struct mailmessage; 13struct mailmessage;
14struct mailmime; 14struct mailmime;
15struct mailmime_mechanism; 15struct mailmime_mechanism;
16struct mailimf_mailbox_list; 16struct mailimf_mailbox_list;
17struct mailimf_mailbox; 17struct mailimf_mailbox;
18struct mailimf_date_time; 18struct mailimf_date_time;
19struct mailimf_group; 19struct mailimf_group;
20struct mailimf_address_list; 20struct mailimf_address_list;
21struct mailsession; 21struct mailsession;
22 22
23/* this class hold just the funs shared between 23/* this class hold just the funs shared between
24 * mbox and pop3 (later mh, too) mail access. 24 * mbox and pop3 (later mh, too) mail access.
25 * it is not desigend to make a instance of it! 25 * it is not desigend to make a instance of it!
26 */ 26 */
27class Genericwrapper : public AbstractMail 27class Genericwrapper : public AbstractMail
28{ 28{
29 Q_OBJECT 29 Q_OBJECT
30public: 30public:
31 Genericwrapper(); 31 Genericwrapper();
32 virtual ~Genericwrapper(); 32 virtual ~Genericwrapper();
33 33
34 virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); 34 virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part);
35 virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); 35 virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part);
36 virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); 36 virtual QString fetchTextPart(const RecMail&mail,const RecPart&part);
37 virtual void cleanMimeCache(); 37 virtual void cleanMimeCache();
38 38
39protected: 39protected:
40 RecMail *parseHeader( const char *header ); 40 RecMail *parseHeader( const char *header );
41 RecBody parseMail( mailmessage * msg ); 41 RecBody parseMail( mailmessage * msg );
42 QString parseMailboxList( mailimf_mailbox_list *list ); 42 QString parseMailboxList( mailimf_mailbox_list *list );
43 QString parseMailbox( mailimf_mailbox *box ); 43 QString parseMailbox( mailimf_mailbox *box );
44 QString parseGroup( mailimf_group *group ); 44 QString parseGroup( mailimf_group *group );
45 QString parseAddressList( mailimf_address_list *list ); 45 QString parseAddressList( mailimf_address_list *list );
46 QString parseDateTime( mailimf_date_time *date ); 46 QString parseDateTime( mailimf_date_time *date );
47 47
48 void traverseBody(RecBody&target,mailmessage*message,mailmime*mime,unsigned int current_rek=0); 48 void traverseBody(RecBody&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rek=0,int current_count=0);
49 static void fillSingleBody(RecPart&target,mailmessage*message,mailmime*mime); 49 static void fillSingleBody(RecPart&target,mailmessage*message,mailmime*mime);
50 static void fillParameters(RecPart&target,clist*parameters); 50 static void fillParameters(RecPart&target,clist*parameters);
51 static QString getencoding(mailmime_mechanism*aEnc); 51 static QString getencoding(mailmime_mechanism*aEnc);
52 virtual void parseList(QList<RecMail> &target,mailsession*session,const QString&mailbox); 52 virtual void parseList(QList<RecMail> &target,mailsession*session,const QString&mailbox);
53 53
54 QString msgTempName; 54 QString msgTempName;
55 unsigned int last_msg_id; 55 unsigned int last_msg_id;
56 QMap<QString,encodedString*> bodyCache; 56 QMap<QString,encodedString*> bodyCache;
57}; 57};
58 58
59#endif 59#endif