Diffstat (limited to 'noncore/net/mail/libmailwrapper/imapwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 78 |
1 files changed, 46 insertions, 32 deletions
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index a4e6228..d56d7f9 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp | |||
@@ -302,8 +302,9 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
302 | } | 302 | } |
303 | m->setMsgid(QString(head->env_message_id)); | 303 | m->setMsgid(QString(head->env_message_id)); |
304 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { | 304 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { |
305 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; | ||
306 | #if 0 | 305 | #if 0 |
306 | |||
307 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; | ||
307 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); | 308 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); |
308 | 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); | 309 | 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); |
309 | qDebug(da.toString()); | 310 | qDebug(da.toString()); |
@@ -391,20 +392,14 @@ void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mai | |||
391 | switch (mailDescription->bd_type) { | 392 | switch (mailDescription->bd_type) { |
392 | case MAILIMAP_BODY_TYPE_1PART_MSG: | 393 | case MAILIMAP_BODY_TYPE_1PART_MSG: |
393 | path.append(1); | 394 | path.append(1); |
394 | body_text = fetchPart(mail,path,true); | 395 | body_text = fetchTextPart(mail,path,true,singlePart.Encoding()); |
395 | if (singlePart.Encoding()=="quoted-printable") { | ||
396 | body_text = decode_quoted_printable(body_text.latin1()); | ||
397 | } | ||
398 | target_body.setBodytext(body_text); | 396 | target_body.setBodytext(body_text); |
399 | target_body.setDescription(singlePart); | 397 | target_body.setDescription(singlePart); |
400 | break; | 398 | break; |
401 | case MAILIMAP_BODY_TYPE_1PART_TEXT: | 399 | case MAILIMAP_BODY_TYPE_1PART_TEXT: |
402 | qDebug("Mediatype single: %s",mailDescription->bd_data.bd_type_text->bd_media_text); | 400 | qDebug("Mediatype single: %s",mailDescription->bd_data.bd_type_text->bd_media_text); |
403 | path.append(1); | 401 | path.append(1); |
404 | body_text = fetchPart(mail,path,true); | 402 | body_text = fetchTextPart(mail,path,true,singlePart.Encoding()); |
405 | if (singlePart.Encoding()=="quoted-printable") { | ||
406 | body_text = decode_quoted_printable(body_text.latin1()); | ||
407 | } | ||
408 | target_body.setBodytext(body_text); | 403 | target_body.setBodytext(body_text); |
409 | target_body.setDescription(singlePart); | 404 | target_body.setDescription(singlePart); |
410 | break; | 405 | break; |
@@ -461,9 +456,9 @@ QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | |||
461 | return l; | 456 | return l; |
462 | } | 457 | } |
463 | 458 | ||
464 | QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call,const QString&enc) | 459 | encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call) |
465 | { | 460 | { |
466 | QString body(""); | 461 | encodedString*res=new encodedString; |
467 | const char*mb; | 462 | const char*mb; |
468 | int err; | 463 | int err; |
469 | mailimap_fetch_type *fetchType; | 464 | mailimap_fetch_type *fetchType; |
@@ -472,14 +467,14 @@ QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,boo | |||
472 | 467 | ||
473 | login(); | 468 | login(); |
474 | if (!m_imap) { | 469 | if (!m_imap) { |
475 | return body; | 470 | return res; |
476 | } | 471 | } |
477 | if (!internal_call) { | 472 | if (!internal_call) { |
478 | mb = mail.getMbox().latin1(); | 473 | mb = mail.getMbox().latin1(); |
479 | err = mailimap_select( m_imap, (char*)mb); | 474 | err = mailimap_select( m_imap, (char*)mb); |
480 | if ( err != MAILIMAP_NO_ERROR ) { | 475 | if ( err != MAILIMAP_NO_ERROR ) { |
481 | qDebug("error selecting mailbox: %s",m_imap->imap_response); | 476 | qDebug("error selecting mailbox: %s",m_imap->imap_response); |
482 | return body; | 477 | return res; |
483 | } | 478 | } |
484 | } | 479 | } |
485 | set = mailimap_set_new_single(mail.getNumber()); | 480 | set = mailimap_set_new_single(mail.getNumber()); |
@@ -511,26 +506,17 @@ QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,boo | |||
511 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { | 506 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { |
512 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { | 507 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { |
513 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; | 508 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; |
509 | /* detach - we take over the content */ | ||
514 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; | 510 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; |
515 | if (text) { | 511 | res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length); |
516 | if (enc=="quoted-printable") { | ||
517 | body = decode_quoted_printable(text); | ||
518 | } else { | ||
519 | body = QString(text); | ||
520 | } | ||
521 | free(text); | ||
522 | } else { | ||
523 | body = ""; | ||
524 | } | ||
525 | } | 512 | } |
526 | } | 513 | } |
527 | } | 514 | } |
528 | |||
529 | } else { | 515 | } else { |
530 | qDebug("error fetching text: %s",m_imap->imap_response); | 516 | qDebug("error fetching text: %s",m_imap->imap_response); |
531 | } | 517 | } |
532 | mailimap_fetch_list_free(result); | 518 | mailimap_fetch_list_free(result); |
533 | return body; | 519 | return res; |
534 | } | 520 | } |
535 | 521 | ||
536 | void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion,QValueList<int>recList) | 522 | void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion,QValueList<int>recList) |
@@ -557,7 +543,7 @@ void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mai | |||
557 | clist.append(count); | 543 | clist.append(count); |
558 | /* important: Check for is NULL 'cause a body can be empty! */ | 544 | /* important: Check for is NULL 'cause a body can be empty! */ |
559 | if (currentPart.Type()=="text" && target_body.Bodytext().isNull() ) { | 545 | if (currentPart.Type()=="text" && target_body.Bodytext().isNull() ) { |
560 | QString body_text = fetchPart(mail,clist,true,currentPart.Encoding()); | 546 | QString body_text = fetchTextPart(mail,clist,true,currentPart.Encoding()); |
561 | target_body.setDescription(currentPart); | 547 | target_body.setDescription(currentPart); |
562 | target_body.setBodytext(body_text); | 548 | target_body.setBodytext(body_text); |
563 | } else { | 549 | } else { |
@@ -713,11 +699,6 @@ void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which) | |||
713 | target_part.setSize(which->bd_size); | 699 | target_part.setSize(which->bd_size); |
714 | } | 700 | } |
715 | 701 | ||
716 | QString IMAPwrapper::fetchPart(const RecMail&mail,const RecPart&part) | ||
717 | { | ||
718 | return fetchPart(mail,part.Positionlist(),false,part.Encoding()); | ||
719 | } | ||
720 | |||
721 | void IMAPwrapper::deleteMail(const RecMail&mail) | 702 | void IMAPwrapper::deleteMail(const RecMail&mail) |
722 | { | 703 | { |
723 | mailimap_flag_list*flist; | 704 | mailimap_flag_list*flist; |
@@ -784,3 +765,36 @@ void IMAPwrapper::answeredMail(const RecMail&mail) | |||
784 | return; | 765 | return; |
785 | } | 766 | } |
786 | } | 767 | } |
768 | |||
769 | QString IMAPwrapper::fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call,const QString&enc) | ||
770 | { | ||
771 | QString body(""); | ||
772 | encodedString*res = fetchRawPart(mail,path,internal_call); | ||
773 | encodedString*r = decode_String(res,enc); | ||
774 | delete res; | ||
775 | if (r) { | ||
776 | if (r->Length()>0) { | ||
777 | body = r->Content(); | ||
778 | } | ||
779 | delete r; | ||
780 | } | ||
781 | return body; | ||
782 | } | ||
783 | |||
784 | QString IMAPwrapper::fetchTextPart(const RecMail&mail,const RecPart&part) | ||
785 | { | ||
786 | return fetchTextPart(mail,part.Positionlist(),false,part.Encoding()); | ||
787 | } | ||
788 | |||
789 | encodedString* IMAPwrapper::fetchDecodedPart(const RecMail&mail,const RecPart&part) | ||
790 | { | ||
791 | encodedString*res = fetchRawPart(mail,part.Positionlist(),false); | ||
792 | encodedString*r = decode_String(res,part.Encoding()); | ||
793 | delete res; | ||
794 | return r; | ||
795 | } | ||
796 | |||
797 | encodedString* IMAPwrapper::fetchRawPart(const RecMail&mail,const RecPart&part) | ||
798 | { | ||
799 | return fetchRawPart(mail,part.Positionlist(),false); | ||
800 | } | ||