author | alwin <alwin> | 2003-12-18 14:23:15 (UTC) |
---|---|---|
committer | alwin <alwin> | 2003-12-18 14:23:15 (UTC) |
commit | 5cb08b0c69ffc7216405b552e17ff0541578bda0 (patch) (unidiff) | |
tree | 37ea5ec8747f82a90c068422fbb99662789380ec | |
parent | 51e56afac97c5254abfe76b65fd697a3e75e4bdd (diff) | |
download | opie-5cb08b0c69ffc7216405b552e17ff0541578bda0.zip opie-5cb08b0c69ffc7216405b552e17ff0541578bda0.tar.gz opie-5cb08b0c69ffc7216405b552e17ff0541578bda0.tar.bz2 |
ok. char-translation enabled again.
make sure to have the decode patch applied to libetpan!!!!
-rw-r--r-- | noncore/net/mail/abstractmail.cpp | 17 | ||||
-rw-r--r-- | noncore/net/mail/imapwrapper.cpp | 6 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/abstractmail.cpp | 17 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 6 |
4 files changed, 22 insertions, 24 deletions
diff --git a/noncore/net/mail/abstractmail.cpp b/noncore/net/mail/abstractmail.cpp index b7e5eaa..3d76c96 100644 --- a/noncore/net/mail/abstractmail.cpp +++ b/noncore/net/mail/abstractmail.cpp | |||
@@ -1,71 +1,68 @@ | |||
1 | #include "abstractmail.h" | 1 | #include "abstractmail.h" |
2 | #include "imapwrapper.h" | 2 | #include "imapwrapper.h" |
3 | #include "pop3wrapper.h" | 3 | #include "pop3wrapper.h" |
4 | #include "mailtypes.h" | 4 | #include "mailtypes.h" |
5 | 5 | ||
6 | #include <qstring.h> | 6 | #include <qstring.h> |
7 | #include <stdlib.h> | 7 | #include <stdlib.h> |
8 | #include <libetpan/mailmime_content.h> | 8 | #include <libetpan/mailmime_content.h> |
9 | 9 | ||
10 | AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) | 10 | AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) |
11 | { | 11 | { |
12 | return new IMAPwrapper(a); | 12 | return new IMAPwrapper(a); |
13 | } | 13 | } |
14 | 14 | ||
15 | AbstractMail* AbstractMail::getWrapper(POP3account *a) | 15 | AbstractMail* AbstractMail::getWrapper(POP3account *a) |
16 | { | 16 | { |
17 | return new POP3wrapper(a); | 17 | return new POP3wrapper(a); |
18 | } | 18 | } |
19 | 19 | ||
20 | encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc) | 20 | encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc) |
21 | { | 21 | { |
22 | qDebug("Decode string start"); | 22 | qDebug("Decode string start"); |
23 | char*result_text; | 23 | char*result_text; |
24 | size_t index = 0; | 24 | size_t index = 0; |
25 | /* reset for recursive use! */ | 25 | /* reset for recursive use! */ |
26 | size_t target_length = 0; | 26 | size_t target_length = 0; |
27 | result_text = 0; | 27 | result_text = 0; |
28 | int mimetype = MAILMIME_MECHANISM_7BIT; | 28 | int mimetype = MAILMIME_MECHANISM_7BIT; |
29 | if (enc.lower()=="quoted-printable") { | 29 | if (enc.lower()=="quoted-printable") { |
30 | mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE; | 30 | mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE; |
31 | } else if (enc.lower()=="base64") { | 31 | } else if (enc.lower()=="base64") { |
32 | mimetype = MAILMIME_MECHANISM_BASE64; | 32 | mimetype = MAILMIME_MECHANISM_BASE64; |
33 | } else if (enc.lower()=="8bit") { | 33 | } else if (enc.lower()=="8bit") { |
34 | mimetype = MAILMIME_MECHANISM_8BIT; | 34 | mimetype = MAILMIME_MECHANISM_8BIT; |
35 | } else if (enc.lower()=="binary") { | 35 | } else if (enc.lower()=="binary") { |
36 | mimetype = MAILMIME_MECHANISM_BINARY; | 36 | mimetype = MAILMIME_MECHANISM_BINARY; |
37 | } | 37 | } |
38 | 38 | ||
39 | int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype, | 39 | int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype, |
40 | &result_text,&target_length); | 40 | &result_text,&target_length); |
41 | 41 | ||
42 | encodedString* result = new encodedString(); | 42 | encodedString* result = new encodedString(); |
43 | if (err == MAILIMF_NO_ERROR) { | 43 | if (err == MAILIMF_NO_ERROR) { |
44 | result->setContent(result_text,target_length); | 44 | result->setContent(result_text,target_length); |
45 | } | 45 | } |
46 | qDebug("Decode string finished"); | 46 | qDebug("Decode string finished"); |
47 | return result; | 47 | return result; |
48 | } | 48 | } |
49 | 49 | ||
50 | QString AbstractMail::convert_String(const char*text) | 50 | QString AbstractMail::convert_String(const char*text) |
51 | { | 51 | { |
52 | #if 0 | ||
53 | size_t index = 0; | 52 | size_t index = 0; |
54 | char*res = 0; | 53 | char*res = 0; |
55 | 54 | ||
56 | qDebug("encode start %s",text); | 55 | /* attention - doesn't work with arm systems! */ |
57 | /* attention - doesn't work with arm systems! */ | ||
58 | int err = mailmime_encoded_phrase_parse("iso-8859-1", | 56 | int err = mailmime_encoded_phrase_parse("iso-8859-1", |
59 | text, strlen(text),&index, "iso-8859-1",&res); | 57 | text, strlen(text),&index, "iso-8859-1",&res); |
60 | qDebug("encode end"); | ||
61 | if (err != MAILIMF_NO_ERROR) { | 58 | if (err != MAILIMF_NO_ERROR) { |
62 | if (res) free(res); | 59 | if (res) free(res); |
63 | return QString(text); | 60 | return QString(text); |
64 | } | 61 | } |
65 | QString result(res); | 62 | if (res) { |
66 | free(res); | 63 | QString result(res); |
67 | return result; | 64 | free(res); |
68 | #else | 65 | return result; |
69 | return QString(text); | 66 | } |
70 | #endif | 67 | return QString(text); |
71 | } | 68 | } |
diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp index 8a86c95..838300a 100644 --- a/noncore/net/mail/imapwrapper.cpp +++ b/noncore/net/mail/imapwrapper.cpp | |||
@@ -217,129 +217,130 @@ QList<Folder>* IMAPwrapper::listFolders() | |||
217 | mailimap_list_result_free( result ); | 217 | mailimap_list_result_free( result ); |
218 | return folders; | 218 | return folders; |
219 | } | 219 | } |
220 | 220 | ||
221 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | 221 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) |
222 | { | 222 | { |
223 | RecMail * m = 0; | 223 | RecMail * m = 0; |
224 | mailimap_msg_att_item *item=0; | 224 | mailimap_msg_att_item *item=0; |
225 | clistcell *current,*c,*cf; | 225 | clistcell *current,*c,*cf; |
226 | mailimap_msg_att_dynamic*flist; | 226 | mailimap_msg_att_dynamic*flist; |
227 | mailimap_flag_fetch*cflag; | 227 | mailimap_flag_fetch*cflag; |
228 | int size; | 228 | int size; |
229 | QBitArray mFlags(7); | 229 | QBitArray mFlags(7); |
230 | QStringList addresslist; | 230 | QStringList addresslist; |
231 | 231 | ||
232 | if (!m_att) { | 232 | if (!m_att) { |
233 | return m; | 233 | return m; |
234 | } | 234 | } |
235 | m = new RecMail(); | 235 | m = new RecMail(); |
236 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { | 236 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { |
237 | current = c; | 237 | current = c; |
238 | size = 0; | 238 | size = 0; |
239 | item = (mailimap_msg_att_item*)current->data; | 239 | item = (mailimap_msg_att_item*)current->data; |
240 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { | 240 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { |
241 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; | 241 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; |
242 | if (!flist->att_list) { | 242 | if (!flist->att_list) { |
243 | continue; | 243 | continue; |
244 | } | 244 | } |
245 | cf = flist->att_list->first; | 245 | cf = flist->att_list->first; |
246 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { | 246 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { |
247 | cflag = (mailimap_flag_fetch*)cf->data; | 247 | cflag = (mailimap_flag_fetch*)cf->data; |
248 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { | 248 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { |
249 | switch (cflag->fl_flag->fl_type) { | 249 | switch (cflag->fl_flag->fl_type) { |
250 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ | 250 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ |
251 | mFlags.setBit(FLAG_ANSWERED); | 251 | mFlags.setBit(FLAG_ANSWERED); |
252 | break; | 252 | break; |
253 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ | 253 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ |
254 | mFlags.setBit(FLAG_FLAGGED); | 254 | mFlags.setBit(FLAG_FLAGGED); |
255 | break; | 255 | break; |
256 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ | 256 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ |
257 | mFlags.setBit(FLAG_DELETED); | 257 | mFlags.setBit(FLAG_DELETED); |
258 | break; | 258 | break; |
259 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ | 259 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ |
260 | mFlags.setBit(FLAG_SEEN); | 260 | mFlags.setBit(FLAG_SEEN); |
261 | break; | 261 | break; |
262 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ | 262 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ |
263 | mFlags.setBit(FLAG_DRAFT); | 263 | mFlags.setBit(FLAG_DRAFT); |
264 | break; | 264 | break; |
265 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ | 265 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ |
266 | break; | 266 | break; |
267 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ | 267 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ |
268 | break; | 268 | break; |
269 | default: | 269 | default: |
270 | break; | 270 | break; |
271 | } | 271 | } |
272 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { | 272 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { |
273 | mFlags.setBit(FLAG_RECENT); | 273 | mFlags.setBit(FLAG_RECENT); |
274 | } | 274 | } |
275 | } | 275 | } |
276 | continue; | 276 | continue; |
277 | } | 277 | } |
278 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { | 278 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { |
279 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; | 279 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; |
280 | m->setDate(head->env_date); | 280 | m->setDate(head->env_date); |
281 | m->setSubject(head->env_subject); | 281 | m->setSubject(convert_String((const char*)head->env_subject)); |
282 | //m->setSubject(head->env_subject); | ||
282 | if (head->env_from!=NULL) { | 283 | if (head->env_from!=NULL) { |
283 | addresslist = address_list_to_stringlist(head->env_from->frm_list); | 284 | addresslist = address_list_to_stringlist(head->env_from->frm_list); |
284 | if (addresslist.count()) { | 285 | if (addresslist.count()) { |
285 | m->setFrom(addresslist.first()); | 286 | m->setFrom(addresslist.first()); |
286 | } | 287 | } |
287 | } | 288 | } |
288 | if (head->env_to!=NULL) { | 289 | if (head->env_to!=NULL) { |
289 | addresslist = address_list_to_stringlist(head->env_to->to_list); | 290 | addresslist = address_list_to_stringlist(head->env_to->to_list); |
290 | m->setTo(addresslist); | 291 | m->setTo(addresslist); |
291 | } | 292 | } |
292 | if (head->env_cc!=NULL) { | 293 | if (head->env_cc!=NULL) { |
293 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); | 294 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); |
294 | m->setCC(addresslist); | 295 | m->setCC(addresslist); |
295 | } | 296 | } |
296 | if (head->env_bcc!=NULL) { | 297 | if (head->env_bcc!=NULL) { |
297 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); | 298 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); |
298 | m->setBcc(addresslist); | 299 | m->setBcc(addresslist); |
299 | } | 300 | } |
300 | if (head->env_reply_to!=NULL) { | 301 | if (head->env_reply_to!=NULL) { |
301 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); | 302 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); |
302 | if (addresslist.count()) { | 303 | if (addresslist.count()) { |
303 | m->setReplyto(addresslist.first()); | 304 | m->setReplyto(addresslist.first()); |
304 | } | 305 | } |
305 | } | 306 | } |
306 | m->setMsgid(QString(head->env_message_id)); | 307 | m->setMsgid(QString(head->env_message_id)); |
307 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { | 308 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { |
308 | #if 0 | 309 | #if 0 |
309 | 310 | ||
310 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; | 311 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; |
311 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); | 312 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); |
312 | qDebug("%i %i %i - %i %i %i",d->dt_year,d->dt_month,d->dt_day,d->dt_hour,d->dt_min,d->dt_sec); | 313 | qDebug("%i %i %i - %i %i %i",d->dt_year,d->dt_month,d->dt_day,d->dt_hour,d->dt_min,d->dt_sec); |
313 | qDebug(da.toString()); | 314 | qDebug(da.toString()); |
314 | #endif | 315 | #endif |
315 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { | 316 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { |
316 | size = item->att_data.att_static->att_data.att_rfc822_size; | 317 | size = item->att_data.att_static->att_data.att_rfc822_size; |
317 | } | 318 | } |
318 | } | 319 | } |
319 | /* msg is already deleted */ | 320 | /* msg is already deleted */ |
320 | if (mFlags.testBit(FLAG_DELETED) && m) { | 321 | if (mFlags.testBit(FLAG_DELETED) && m) { |
321 | delete m; | 322 | delete m; |
322 | m = 0; | 323 | m = 0; |
323 | } | 324 | } |
324 | if (m) { | 325 | if (m) { |
325 | m->setFlags(mFlags); | 326 | m->setFlags(mFlags); |
326 | m->setMsgsize(size); | 327 | m->setMsgsize(size); |
327 | } | 328 | } |
328 | return m; | 329 | return m; |
329 | } | 330 | } |
330 | 331 | ||
331 | RecBody IMAPwrapper::fetchBody(const RecMail&mail) | 332 | RecBody IMAPwrapper::fetchBody(const RecMail&mail) |
332 | { | 333 | { |
333 | RecBody body; | 334 | RecBody body; |
334 | const char *mb; | 335 | const char *mb; |
335 | int err = MAILIMAP_NO_ERROR; | 336 | int err = MAILIMAP_NO_ERROR; |
336 | clist *result; | 337 | clist *result; |
337 | clistcell *current; | 338 | clistcell *current; |
338 | mailimap_fetch_att *fetchAtt; | 339 | mailimap_fetch_att *fetchAtt; |
339 | mailimap_fetch_type *fetchType; | 340 | mailimap_fetch_type *fetchType; |
340 | mailimap_set *set; | 341 | mailimap_set *set; |
341 | mailimap_body*body_desc; | 342 | mailimap_body*body_desc; |
342 | 343 | ||
343 | mb = mail.getMbox().latin1(); | 344 | mb = mail.getMbox().latin1(); |
344 | 345 | ||
345 | login(); | 346 | login(); |
@@ -373,129 +374,130 @@ RecBody IMAPwrapper::fetchBody(const RecMail&mail) | |||
373 | qDebug("Mulitpart mail"); | 374 | qDebug("Mulitpart mail"); |
374 | searchBodyText(mail,body_desc->bd_data.bd_body_mpart,body); | 375 | searchBodyText(mail,body_desc->bd_data.bd_body_mpart,body); |
375 | } | 376 | } |
376 | } else { | 377 | } else { |
377 | qDebug("error fetching body: %s",m_imap->imap_response); | 378 | qDebug("error fetching body: %s",m_imap->imap_response); |
378 | } | 379 | } |
379 | mailimap_fetch_list_free(result); | 380 | mailimap_fetch_list_free(result); |
380 | return body; | 381 | return body; |
381 | } | 382 | } |
382 | 383 | ||
383 | /* this routine is just called when the mail has only ONE part. | 384 | /* this routine is just called when the mail has only ONE part. |
384 | for filling the parts of a multi-part-message there are other | 385 | for filling the parts of a multi-part-message there are other |
385 | routines 'cause we can not simply fetch the whole body. */ | 386 | routines 'cause we can not simply fetch the whole body. */ |
386 | void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body) | 387 | void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body) |
387 | { | 388 | { |
388 | if (!mailDescription) { | 389 | if (!mailDescription) { |
389 | return; | 390 | return; |
390 | } | 391 | } |
391 | QString sub,body_text; | 392 | QString sub,body_text; |
392 | RecPart singlePart; | 393 | RecPart singlePart; |
393 | QValueList<int> path; | 394 | QValueList<int> path; |
394 | fillSinglePart(singlePart,mailDescription); | 395 | fillSinglePart(singlePart,mailDescription); |
395 | switch (mailDescription->bd_type) { | 396 | switch (mailDescription->bd_type) { |
396 | case MAILIMAP_BODY_TYPE_1PART_MSG: | 397 | case MAILIMAP_BODY_TYPE_1PART_MSG: |
397 | path.append(1); | 398 | path.append(1); |
398 | body_text = fetchTextPart(mail,path,true,singlePart.Encoding()); | 399 | body_text = fetchTextPart(mail,path,true,singlePart.Encoding()); |
399 | target_body.setBodytext(body_text); | 400 | target_body.setBodytext(body_text); |
400 | target_body.setDescription(singlePart); | 401 | target_body.setDescription(singlePart); |
401 | break; | 402 | break; |
402 | case MAILIMAP_BODY_TYPE_1PART_TEXT: | 403 | case MAILIMAP_BODY_TYPE_1PART_TEXT: |
403 | qDebug("Mediatype single: %s",mailDescription->bd_data.bd_type_text->bd_media_text); | 404 | qDebug("Mediatype single: %s",mailDescription->bd_data.bd_type_text->bd_media_text); |
404 | path.append(1); | 405 | path.append(1); |
405 | body_text = fetchTextPart(mail,path,true,singlePart.Encoding()); | 406 | body_text = fetchTextPart(mail,path,true,singlePart.Encoding()); |
406 | target_body.setBodytext(body_text); | 407 | target_body.setBodytext(body_text); |
407 | target_body.setDescription(singlePart); | 408 | target_body.setDescription(singlePart); |
408 | break; | 409 | break; |
409 | case MAILIMAP_BODY_TYPE_1PART_BASIC: | 410 | case MAILIMAP_BODY_TYPE_1PART_BASIC: |
410 | qDebug("Single attachment"); | 411 | qDebug("Single attachment"); |
411 | target_body.setBodytext(""); | 412 | target_body.setBodytext(""); |
412 | target_body.addPart(singlePart); | 413 | target_body.addPart(singlePart); |
413 | break; | 414 | break; |
414 | default: | 415 | default: |
415 | break; | 416 | break; |
416 | } | 417 | } |
417 | 418 | ||
418 | return; | 419 | return; |
419 | } | 420 | } |
420 | 421 | ||
421 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | 422 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) |
422 | { | 423 | { |
423 | QStringList l; | 424 | QStringList l; |
424 | QString from; | 425 | QString from; |
425 | bool named_from; | 426 | bool named_from; |
426 | clistcell *current = NULL; | 427 | clistcell *current = NULL; |
427 | mailimap_address * current_address=NULL; | 428 | mailimap_address * current_address=NULL; |
428 | if (!list) { | 429 | if (!list) { |
429 | return l; | 430 | return l; |
430 | } | 431 | } |
431 | unsigned int count = 0; | 432 | unsigned int count = 0; |
432 | for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { | 433 | for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { |
433 | from = ""; | 434 | from = ""; |
434 | named_from = false; | 435 | named_from = false; |
435 | current_address=(mailimap_address*)current->data; | 436 | current_address=(mailimap_address*)current->data; |
436 | if (current_address->ad_personal_name){ | 437 | if (current_address->ad_personal_name){ |
437 | from+=QString(current_address->ad_personal_name); | 438 | from+=convert_String((const char*)current_address->ad_personal_name); |
439 | //from+=QString(current_address->ad_personal_name); | ||
438 | from+=" "; | 440 | from+=" "; |
439 | named_from = true; | 441 | named_from = true; |
440 | } | 442 | } |
441 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { | 443 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
442 | from+="<"; | 444 | from+="<"; |
443 | } | 445 | } |
444 | if (current_address->ad_mailbox_name) { | 446 | if (current_address->ad_mailbox_name) { |
445 | from+=QString(current_address->ad_mailbox_name); | 447 | from+=QString(current_address->ad_mailbox_name); |
446 | from+="@"; | 448 | from+="@"; |
447 | } | 449 | } |
448 | if (current_address->ad_host_name) { | 450 | if (current_address->ad_host_name) { |
449 | from+=QString(current_address->ad_host_name); | 451 | from+=QString(current_address->ad_host_name); |
450 | } | 452 | } |
451 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { | 453 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
452 | from+=">"; | 454 | from+=">"; |
453 | } | 455 | } |
454 | l.append(QString(from)); | 456 | l.append(QString(from)); |
455 | if (++count > 99) { | 457 | if (++count > 99) { |
456 | break; | 458 | break; |
457 | } | 459 | } |
458 | } | 460 | } |
459 | return l; | 461 | return l; |
460 | } | 462 | } |
461 | 463 | ||
462 | encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call) | 464 | encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call) |
463 | { | 465 | { |
464 | encodedString*res=new encodedString; | 466 | encodedString*res=new encodedString; |
465 | const char*mb; | 467 | const char*mb; |
466 | int err; | 468 | int err; |
467 | mailimap_fetch_type *fetchType; | 469 | mailimap_fetch_type *fetchType; |
468 | mailimap_set *set; | 470 | mailimap_set *set; |
469 | clistcell*current,*cur; | 471 | clistcell*current,*cur; |
470 | 472 | ||
471 | login(); | 473 | login(); |
472 | if (!m_imap) { | 474 | if (!m_imap) { |
473 | return res; | 475 | return res; |
474 | } | 476 | } |
475 | if (!internal_call) { | 477 | if (!internal_call) { |
476 | mb = mail.getMbox().latin1(); | 478 | mb = mail.getMbox().latin1(); |
477 | err = mailimap_select( m_imap, (char*)mb); | 479 | err = mailimap_select( m_imap, (char*)mb); |
478 | if ( err != MAILIMAP_NO_ERROR ) { | 480 | if ( err != MAILIMAP_NO_ERROR ) { |
479 | qDebug("error selecting mailbox: %s",m_imap->imap_response); | 481 | qDebug("error selecting mailbox: %s",m_imap->imap_response); |
480 | return res; | 482 | return res; |
481 | } | 483 | } |
482 | } | 484 | } |
483 | set = mailimap_set_new_single(mail.getNumber()); | 485 | set = mailimap_set_new_single(mail.getNumber()); |
484 | clist*id_list=clist_new(); | 486 | clist*id_list=clist_new(); |
485 | for (unsigned j=0; j < path.count();++j) { | 487 | for (unsigned j=0; j < path.count();++j) { |
486 | uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); | 488 | uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); |
487 | *p_id = path[j]; | 489 | *p_id = path[j]; |
488 | clist_append(id_list,p_id); | 490 | clist_append(id_list,p_id); |
489 | } | 491 | } |
490 | mailimap_section_part * section_part = mailimap_section_part_new(id_list); | 492 | mailimap_section_part * section_part = mailimap_section_part_new(id_list); |
491 | mailimap_section_spec * section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); | 493 | mailimap_section_spec * section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); |
492 | mailimap_section * section = mailimap_section_new(section_spec); | 494 | mailimap_section * section = mailimap_section_new(section_spec); |
493 | mailimap_fetch_att * fetch_att = mailimap_fetch_att_new_body_section(section); | 495 | mailimap_fetch_att * fetch_att = mailimap_fetch_att_new_body_section(section); |
494 | 496 | ||
495 | fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); | 497 | fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); |
496 | 498 | ||
497 | clist*result = clist_new(); | 499 | clist*result = clist_new(); |
498 | 500 | ||
499 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 501 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
500 | mailimap_set_free( set ); | 502 | mailimap_set_free( set ); |
501 | mailimap_fetch_type_free( fetchType ); | 503 | mailimap_fetch_type_free( fetchType ); |
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.cpp b/noncore/net/mail/libmailwrapper/abstractmail.cpp index b7e5eaa..3d76c96 100644 --- a/noncore/net/mail/libmailwrapper/abstractmail.cpp +++ b/noncore/net/mail/libmailwrapper/abstractmail.cpp | |||
@@ -1,71 +1,68 @@ | |||
1 | #include "abstractmail.h" | 1 | #include "abstractmail.h" |
2 | #include "imapwrapper.h" | 2 | #include "imapwrapper.h" |
3 | #include "pop3wrapper.h" | 3 | #include "pop3wrapper.h" |
4 | #include "mailtypes.h" | 4 | #include "mailtypes.h" |
5 | 5 | ||
6 | #include <qstring.h> | 6 | #include <qstring.h> |
7 | #include <stdlib.h> | 7 | #include <stdlib.h> |
8 | #include <libetpan/mailmime_content.h> | 8 | #include <libetpan/mailmime_content.h> |
9 | 9 | ||
10 | AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) | 10 | AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) |
11 | { | 11 | { |
12 | return new IMAPwrapper(a); | 12 | return new IMAPwrapper(a); |
13 | } | 13 | } |
14 | 14 | ||
15 | AbstractMail* AbstractMail::getWrapper(POP3account *a) | 15 | AbstractMail* AbstractMail::getWrapper(POP3account *a) |
16 | { | 16 | { |
17 | return new POP3wrapper(a); | 17 | return new POP3wrapper(a); |
18 | } | 18 | } |
19 | 19 | ||
20 | encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc) | 20 | encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc) |
21 | { | 21 | { |
22 | qDebug("Decode string start"); | 22 | qDebug("Decode string start"); |
23 | char*result_text; | 23 | char*result_text; |
24 | size_t index = 0; | 24 | size_t index = 0; |
25 | /* reset for recursive use! */ | 25 | /* reset for recursive use! */ |
26 | size_t target_length = 0; | 26 | size_t target_length = 0; |
27 | result_text = 0; | 27 | result_text = 0; |
28 | int mimetype = MAILMIME_MECHANISM_7BIT; | 28 | int mimetype = MAILMIME_MECHANISM_7BIT; |
29 | if (enc.lower()=="quoted-printable") { | 29 | if (enc.lower()=="quoted-printable") { |
30 | mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE; | 30 | mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE; |
31 | } else if (enc.lower()=="base64") { | 31 | } else if (enc.lower()=="base64") { |
32 | mimetype = MAILMIME_MECHANISM_BASE64; | 32 | mimetype = MAILMIME_MECHANISM_BASE64; |
33 | } else if (enc.lower()=="8bit") { | 33 | } else if (enc.lower()=="8bit") { |
34 | mimetype = MAILMIME_MECHANISM_8BIT; | 34 | mimetype = MAILMIME_MECHANISM_8BIT; |
35 | } else if (enc.lower()=="binary") { | 35 | } else if (enc.lower()=="binary") { |
36 | mimetype = MAILMIME_MECHANISM_BINARY; | 36 | mimetype = MAILMIME_MECHANISM_BINARY; |
37 | } | 37 | } |
38 | 38 | ||
39 | int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype, | 39 | int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype, |
40 | &result_text,&target_length); | 40 | &result_text,&target_length); |
41 | 41 | ||
42 | encodedString* result = new encodedString(); | 42 | encodedString* result = new encodedString(); |
43 | if (err == MAILIMF_NO_ERROR) { | 43 | if (err == MAILIMF_NO_ERROR) { |
44 | result->setContent(result_text,target_length); | 44 | result->setContent(result_text,target_length); |
45 | } | 45 | } |
46 | qDebug("Decode string finished"); | 46 | qDebug("Decode string finished"); |
47 | return result; | 47 | return result; |
48 | } | 48 | } |
49 | 49 | ||
50 | QString AbstractMail::convert_String(const char*text) | 50 | QString AbstractMail::convert_String(const char*text) |
51 | { | 51 | { |
52 | #if 0 | ||
53 | size_t index = 0; | 52 | size_t index = 0; |
54 | char*res = 0; | 53 | char*res = 0; |
55 | 54 | ||
56 | qDebug("encode start %s",text); | 55 | /* attention - doesn't work with arm systems! */ |
57 | /* attention - doesn't work with arm systems! */ | ||
58 | int err = mailmime_encoded_phrase_parse("iso-8859-1", | 56 | int err = mailmime_encoded_phrase_parse("iso-8859-1", |
59 | text, strlen(text),&index, "iso-8859-1",&res); | 57 | text, strlen(text),&index, "iso-8859-1",&res); |
60 | qDebug("encode end"); | ||
61 | if (err != MAILIMF_NO_ERROR) { | 58 | if (err != MAILIMF_NO_ERROR) { |
62 | if (res) free(res); | 59 | if (res) free(res); |
63 | return QString(text); | 60 | return QString(text); |
64 | } | 61 | } |
65 | QString result(res); | 62 | if (res) { |
66 | free(res); | 63 | QString result(res); |
67 | return result; | 64 | free(res); |
68 | #else | 65 | return result; |
69 | return QString(text); | 66 | } |
70 | #endif | 67 | return QString(text); |
71 | } | 68 | } |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index 8a86c95..838300a 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp | |||
@@ -217,129 +217,130 @@ QList<Folder>* IMAPwrapper::listFolders() | |||
217 | mailimap_list_result_free( result ); | 217 | mailimap_list_result_free( result ); |
218 | return folders; | 218 | return folders; |
219 | } | 219 | } |
220 | 220 | ||
221 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | 221 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) |
222 | { | 222 | { |
223 | RecMail * m = 0; | 223 | RecMail * m = 0; |
224 | mailimap_msg_att_item *item=0; | 224 | mailimap_msg_att_item *item=0; |
225 | clistcell *current,*c,*cf; | 225 | clistcell *current,*c,*cf; |
226 | mailimap_msg_att_dynamic*flist; | 226 | mailimap_msg_att_dynamic*flist; |
227 | mailimap_flag_fetch*cflag; | 227 | mailimap_flag_fetch*cflag; |
228 | int size; | 228 | int size; |
229 | QBitArray mFlags(7); | 229 | QBitArray mFlags(7); |
230 | QStringList addresslist; | 230 | QStringList addresslist; |
231 | 231 | ||
232 | if (!m_att) { | 232 | if (!m_att) { |
233 | return m; | 233 | return m; |
234 | } | 234 | } |
235 | m = new RecMail(); | 235 | m = new RecMail(); |
236 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { | 236 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { |
237 | current = c; | 237 | current = c; |
238 | size = 0; | 238 | size = 0; |
239 | item = (mailimap_msg_att_item*)current->data; | 239 | item = (mailimap_msg_att_item*)current->data; |
240 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { | 240 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { |
241 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; | 241 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; |
242 | if (!flist->att_list) { | 242 | if (!flist->att_list) { |
243 | continue; | 243 | continue; |
244 | } | 244 | } |
245 | cf = flist->att_list->first; | 245 | cf = flist->att_list->first; |
246 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { | 246 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { |
247 | cflag = (mailimap_flag_fetch*)cf->data; | 247 | cflag = (mailimap_flag_fetch*)cf->data; |
248 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { | 248 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { |
249 | switch (cflag->fl_flag->fl_type) { | 249 | switch (cflag->fl_flag->fl_type) { |
250 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ | 250 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ |
251 | mFlags.setBit(FLAG_ANSWERED); | 251 | mFlags.setBit(FLAG_ANSWERED); |
252 | break; | 252 | break; |
253 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ | 253 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ |
254 | mFlags.setBit(FLAG_FLAGGED); | 254 | mFlags.setBit(FLAG_FLAGGED); |
255 | break; | 255 | break; |
256 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ | 256 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ |
257 | mFlags.setBit(FLAG_DELETED); | 257 | mFlags.setBit(FLAG_DELETED); |
258 | break; | 258 | break; |
259 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ | 259 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ |
260 | mFlags.setBit(FLAG_SEEN); | 260 | mFlags.setBit(FLAG_SEEN); |
261 | break; | 261 | break; |
262 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ | 262 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ |
263 | mFlags.setBit(FLAG_DRAFT); | 263 | mFlags.setBit(FLAG_DRAFT); |
264 | break; | 264 | break; |
265 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ | 265 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ |
266 | break; | 266 | break; |
267 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ | 267 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ |
268 | break; | 268 | break; |
269 | default: | 269 | default: |
270 | break; | 270 | break; |
271 | } | 271 | } |
272 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { | 272 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { |
273 | mFlags.setBit(FLAG_RECENT); | 273 | mFlags.setBit(FLAG_RECENT); |
274 | } | 274 | } |
275 | } | 275 | } |
276 | continue; | 276 | continue; |
277 | } | 277 | } |
278 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { | 278 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { |
279 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; | 279 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; |
280 | m->setDate(head->env_date); | 280 | m->setDate(head->env_date); |
281 | m->setSubject(head->env_subject); | 281 | m->setSubject(convert_String((const char*)head->env_subject)); |
282 | //m->setSubject(head->env_subject); | ||
282 | if (head->env_from!=NULL) { | 283 | if (head->env_from!=NULL) { |
283 | addresslist = address_list_to_stringlist(head->env_from->frm_list); | 284 | addresslist = address_list_to_stringlist(head->env_from->frm_list); |
284 | if (addresslist.count()) { | 285 | if (addresslist.count()) { |
285 | m->setFrom(addresslist.first()); | 286 | m->setFrom(addresslist.first()); |
286 | } | 287 | } |
287 | } | 288 | } |
288 | if (head->env_to!=NULL) { | 289 | if (head->env_to!=NULL) { |
289 | addresslist = address_list_to_stringlist(head->env_to->to_list); | 290 | addresslist = address_list_to_stringlist(head->env_to->to_list); |
290 | m->setTo(addresslist); | 291 | m->setTo(addresslist); |
291 | } | 292 | } |
292 | if (head->env_cc!=NULL) { | 293 | if (head->env_cc!=NULL) { |
293 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); | 294 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); |
294 | m->setCC(addresslist); | 295 | m->setCC(addresslist); |
295 | } | 296 | } |
296 | if (head->env_bcc!=NULL) { | 297 | if (head->env_bcc!=NULL) { |
297 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); | 298 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); |
298 | m->setBcc(addresslist); | 299 | m->setBcc(addresslist); |
299 | } | 300 | } |
300 | if (head->env_reply_to!=NULL) { | 301 | if (head->env_reply_to!=NULL) { |
301 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); | 302 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); |
302 | if (addresslist.count()) { | 303 | if (addresslist.count()) { |
303 | m->setReplyto(addresslist.first()); | 304 | m->setReplyto(addresslist.first()); |
304 | } | 305 | } |
305 | } | 306 | } |
306 | m->setMsgid(QString(head->env_message_id)); | 307 | m->setMsgid(QString(head->env_message_id)); |
307 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { | 308 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { |
308 | #if 0 | 309 | #if 0 |
309 | 310 | ||
310 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; | 311 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; |
311 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); | 312 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); |
312 | qDebug("%i %i %i - %i %i %i",d->dt_year,d->dt_month,d->dt_day,d->dt_hour,d->dt_min,d->dt_sec); | 313 | qDebug("%i %i %i - %i %i %i",d->dt_year,d->dt_month,d->dt_day,d->dt_hour,d->dt_min,d->dt_sec); |
313 | qDebug(da.toString()); | 314 | qDebug(da.toString()); |
314 | #endif | 315 | #endif |
315 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { | 316 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { |
316 | size = item->att_data.att_static->att_data.att_rfc822_size; | 317 | size = item->att_data.att_static->att_data.att_rfc822_size; |
317 | } | 318 | } |
318 | } | 319 | } |
319 | /* msg is already deleted */ | 320 | /* msg is already deleted */ |
320 | if (mFlags.testBit(FLAG_DELETED) && m) { | 321 | if (mFlags.testBit(FLAG_DELETED) && m) { |
321 | delete m; | 322 | delete m; |
322 | m = 0; | 323 | m = 0; |
323 | } | 324 | } |
324 | if (m) { | 325 | if (m) { |
325 | m->setFlags(mFlags); | 326 | m->setFlags(mFlags); |
326 | m->setMsgsize(size); | 327 | m->setMsgsize(size); |
327 | } | 328 | } |
328 | return m; | 329 | return m; |
329 | } | 330 | } |
330 | 331 | ||
331 | RecBody IMAPwrapper::fetchBody(const RecMail&mail) | 332 | RecBody IMAPwrapper::fetchBody(const RecMail&mail) |
332 | { | 333 | { |
333 | RecBody body; | 334 | RecBody body; |
334 | const char *mb; | 335 | const char *mb; |
335 | int err = MAILIMAP_NO_ERROR; | 336 | int err = MAILIMAP_NO_ERROR; |
336 | clist *result; | 337 | clist *result; |
337 | clistcell *current; | 338 | clistcell *current; |
338 | mailimap_fetch_att *fetchAtt; | 339 | mailimap_fetch_att *fetchAtt; |
339 | mailimap_fetch_type *fetchType; | 340 | mailimap_fetch_type *fetchType; |
340 | mailimap_set *set; | 341 | mailimap_set *set; |
341 | mailimap_body*body_desc; | 342 | mailimap_body*body_desc; |
342 | 343 | ||
343 | mb = mail.getMbox().latin1(); | 344 | mb = mail.getMbox().latin1(); |
344 | 345 | ||
345 | login(); | 346 | login(); |
@@ -373,129 +374,130 @@ RecBody IMAPwrapper::fetchBody(const RecMail&mail) | |||
373 | qDebug("Mulitpart mail"); | 374 | qDebug("Mulitpart mail"); |
374 | searchBodyText(mail,body_desc->bd_data.bd_body_mpart,body); | 375 | searchBodyText(mail,body_desc->bd_data.bd_body_mpart,body); |
375 | } | 376 | } |
376 | } else { | 377 | } else { |
377 | qDebug("error fetching body: %s",m_imap->imap_response); | 378 | qDebug("error fetching body: %s",m_imap->imap_response); |
378 | } | 379 | } |
379 | mailimap_fetch_list_free(result); | 380 | mailimap_fetch_list_free(result); |
380 | return body; | 381 | return body; |
381 | } | 382 | } |
382 | 383 | ||
383 | /* this routine is just called when the mail has only ONE part. | 384 | /* this routine is just called when the mail has only ONE part. |
384 | for filling the parts of a multi-part-message there are other | 385 | for filling the parts of a multi-part-message there are other |
385 | routines 'cause we can not simply fetch the whole body. */ | 386 | routines 'cause we can not simply fetch the whole body. */ |
386 | void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body) | 387 | void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body) |
387 | { | 388 | { |
388 | if (!mailDescription) { | 389 | if (!mailDescription) { |
389 | return; | 390 | return; |
390 | } | 391 | } |
391 | QString sub,body_text; | 392 | QString sub,body_text; |
392 | RecPart singlePart; | 393 | RecPart singlePart; |
393 | QValueList<int> path; | 394 | QValueList<int> path; |
394 | fillSinglePart(singlePart,mailDescription); | 395 | fillSinglePart(singlePart,mailDescription); |
395 | switch (mailDescription->bd_type) { | 396 | switch (mailDescription->bd_type) { |
396 | case MAILIMAP_BODY_TYPE_1PART_MSG: | 397 | case MAILIMAP_BODY_TYPE_1PART_MSG: |
397 | path.append(1); | 398 | path.append(1); |
398 | body_text = fetchTextPart(mail,path,true,singlePart.Encoding()); | 399 | body_text = fetchTextPart(mail,path,true,singlePart.Encoding()); |
399 | target_body.setBodytext(body_text); | 400 | target_body.setBodytext(body_text); |
400 | target_body.setDescription(singlePart); | 401 | target_body.setDescription(singlePart); |
401 | break; | 402 | break; |
402 | case MAILIMAP_BODY_TYPE_1PART_TEXT: | 403 | case MAILIMAP_BODY_TYPE_1PART_TEXT: |
403 | qDebug("Mediatype single: %s",mailDescription->bd_data.bd_type_text->bd_media_text); | 404 | qDebug("Mediatype single: %s",mailDescription->bd_data.bd_type_text->bd_media_text); |
404 | path.append(1); | 405 | path.append(1); |
405 | body_text = fetchTextPart(mail,path,true,singlePart.Encoding()); | 406 | body_text = fetchTextPart(mail,path,true,singlePart.Encoding()); |
406 | target_body.setBodytext(body_text); | 407 | target_body.setBodytext(body_text); |
407 | target_body.setDescription(singlePart); | 408 | target_body.setDescription(singlePart); |
408 | break; | 409 | break; |
409 | case MAILIMAP_BODY_TYPE_1PART_BASIC: | 410 | case MAILIMAP_BODY_TYPE_1PART_BASIC: |
410 | qDebug("Single attachment"); | 411 | qDebug("Single attachment"); |
411 | target_body.setBodytext(""); | 412 | target_body.setBodytext(""); |
412 | target_body.addPart(singlePart); | 413 | target_body.addPart(singlePart); |
413 | break; | 414 | break; |
414 | default: | 415 | default: |
415 | break; | 416 | break; |
416 | } | 417 | } |
417 | 418 | ||
418 | return; | 419 | return; |
419 | } | 420 | } |
420 | 421 | ||
421 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | 422 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) |
422 | { | 423 | { |
423 | QStringList l; | 424 | QStringList l; |
424 | QString from; | 425 | QString from; |
425 | bool named_from; | 426 | bool named_from; |
426 | clistcell *current = NULL; | 427 | clistcell *current = NULL; |
427 | mailimap_address * current_address=NULL; | 428 | mailimap_address * current_address=NULL; |
428 | if (!list) { | 429 | if (!list) { |
429 | return l; | 430 | return l; |
430 | } | 431 | } |
431 | unsigned int count = 0; | 432 | unsigned int count = 0; |
432 | for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { | 433 | for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { |
433 | from = ""; | 434 | from = ""; |
434 | named_from = false; | 435 | named_from = false; |
435 | current_address=(mailimap_address*)current->data; | 436 | current_address=(mailimap_address*)current->data; |
436 | if (current_address->ad_personal_name){ | 437 | if (current_address->ad_personal_name){ |
437 | from+=QString(current_address->ad_personal_name); | 438 | from+=convert_String((const char*)current_address->ad_personal_name); |
439 | //from+=QString(current_address->ad_personal_name); | ||
438 | from+=" "; | 440 | from+=" "; |
439 | named_from = true; | 441 | named_from = true; |
440 | } | 442 | } |
441 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { | 443 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
442 | from+="<"; | 444 | from+="<"; |
443 | } | 445 | } |
444 | if (current_address->ad_mailbox_name) { | 446 | if (current_address->ad_mailbox_name) { |
445 | from+=QString(current_address->ad_mailbox_name); | 447 | from+=QString(current_address->ad_mailbox_name); |
446 | from+="@"; | 448 | from+="@"; |
447 | } | 449 | } |
448 | if (current_address->ad_host_name) { | 450 | if (current_address->ad_host_name) { |
449 | from+=QString(current_address->ad_host_name); | 451 | from+=QString(current_address->ad_host_name); |
450 | } | 452 | } |
451 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { | 453 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
452 | from+=">"; | 454 | from+=">"; |
453 | } | 455 | } |
454 | l.append(QString(from)); | 456 | l.append(QString(from)); |
455 | if (++count > 99) { | 457 | if (++count > 99) { |
456 | break; | 458 | break; |
457 | } | 459 | } |
458 | } | 460 | } |
459 | return l; | 461 | return l; |
460 | } | 462 | } |
461 | 463 | ||
462 | encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call) | 464 | encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call) |
463 | { | 465 | { |
464 | encodedString*res=new encodedString; | 466 | encodedString*res=new encodedString; |
465 | const char*mb; | 467 | const char*mb; |
466 | int err; | 468 | int err; |
467 | mailimap_fetch_type *fetchType; | 469 | mailimap_fetch_type *fetchType; |
468 | mailimap_set *set; | 470 | mailimap_set *set; |
469 | clistcell*current,*cur; | 471 | clistcell*current,*cur; |
470 | 472 | ||
471 | login(); | 473 | login(); |
472 | if (!m_imap) { | 474 | if (!m_imap) { |
473 | return res; | 475 | return res; |
474 | } | 476 | } |
475 | if (!internal_call) { | 477 | if (!internal_call) { |
476 | mb = mail.getMbox().latin1(); | 478 | mb = mail.getMbox().latin1(); |
477 | err = mailimap_select( m_imap, (char*)mb); | 479 | err = mailimap_select( m_imap, (char*)mb); |
478 | if ( err != MAILIMAP_NO_ERROR ) { | 480 | if ( err != MAILIMAP_NO_ERROR ) { |
479 | qDebug("error selecting mailbox: %s",m_imap->imap_response); | 481 | qDebug("error selecting mailbox: %s",m_imap->imap_response); |
480 | return res; | 482 | return res; |
481 | } | 483 | } |
482 | } | 484 | } |
483 | set = mailimap_set_new_single(mail.getNumber()); | 485 | set = mailimap_set_new_single(mail.getNumber()); |
484 | clist*id_list=clist_new(); | 486 | clist*id_list=clist_new(); |
485 | for (unsigned j=0; j < path.count();++j) { | 487 | for (unsigned j=0; j < path.count();++j) { |
486 | uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); | 488 | uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); |
487 | *p_id = path[j]; | 489 | *p_id = path[j]; |
488 | clist_append(id_list,p_id); | 490 | clist_append(id_list,p_id); |
489 | } | 491 | } |
490 | mailimap_section_part * section_part = mailimap_section_part_new(id_list); | 492 | mailimap_section_part * section_part = mailimap_section_part_new(id_list); |
491 | mailimap_section_spec * section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); | 493 | mailimap_section_spec * section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); |
492 | mailimap_section * section = mailimap_section_new(section_spec); | 494 | mailimap_section * section = mailimap_section_new(section_spec); |
493 | mailimap_fetch_att * fetch_att = mailimap_fetch_att_new_body_section(section); | 495 | mailimap_fetch_att * fetch_att = mailimap_fetch_att_new_body_section(section); |
494 | 496 | ||
495 | fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); | 497 | fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); |
496 | 498 | ||
497 | clist*result = clist_new(); | 499 | clist*result = clist_new(); |
498 | 500 | ||
499 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 501 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
500 | mailimap_set_free( set ); | 502 | mailimap_set_free( set ); |
501 | mailimap_fetch_type_free( fetchType ); | 503 | mailimap_fetch_type_free( fetchType ); |