summaryrefslogtreecommitdiffabout
path: root/kmicromail/libmailwrapper/imapwrapper.cpp
Unidiff
Diffstat (limited to 'kmicromail/libmailwrapper/imapwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libmailwrapper/imapwrapper.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp
index d90a8d2..eb2b47d 100644
--- a/kmicromail/libmailwrapper/imapwrapper.cpp
+++ b/kmicromail/libmailwrapper/imapwrapper.cpp
@@ -731,48 +731,67 @@ void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&t
731{ 731{
732 if (!body || current_recursion>=10) { 732 if (!body || current_recursion>=10) {
733 return; 733 return;
734 } 734 }
735 switch (body->bd_type) { 735 switch (body->bd_type) {
736 case MAILIMAP_BODY_1PART: 736 case MAILIMAP_BODY_1PART:
737 { 737 {
738 QValueList<int>countlist = recList; 738 QValueList<int>countlist = recList;
739 countlist.append(current_count); 739 countlist.append(current_count);
740 RecPartP currentPart = new RecPart(); 740 RecPartP currentPart = new RecPart();
741 mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; 741 mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part;
742 QString id(""); 742 QString id("");
743 currentPart->setPositionlist(countlist); 743 currentPart->setPositionlist(countlist);
744 for (unsigned int j = 0; j < countlist.count();++j) { 744 for (unsigned int j = 0; j < countlist.count();++j) {
745 id+=(j>0?" ":""); 745 id+=(j>0?" ":"");
746 id+=QString("%1").arg(countlist[j]); 746 id+=QString("%1").arg(countlist[j]);
747 } 747 }
748 //odebug << "ID = " << id.latin1() << "" << oendl; 748 //odebug << "ID = " << id.latin1() << "" << oendl;
749 currentPart->setIdentifier(id); 749 currentPart->setIdentifier(id);
750 fillSinglePart(currentPart,part1); 750 fillSinglePart(currentPart,part1);
751 /* important: Check for is NULL 'cause a body can be empty! 751 /* important: Check for is NULL 'cause a body can be empty!
752 And we put it only into the mail if it is the FIRST part */ 752 And we put it only into the mail if it is the FIRST part */
753 if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) { 753 if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) {
754 QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding()); 754 QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding());
755
756 size_t index = 0;
757 char*res = 0;
758 int err = MAILIMF_NO_ERROR;
759
760 QString charset = currentPart->searchParamter( "charset");
761 qDebug("CHARSET %s ",charset.latin1() );
762 //if ( false ) {
763 if ( !charset.isEmpty() ) {
764 //err = mailmime_encoded_phrase_parse("iso-8859-1",
765 // text, strlen(text),&index, "iso-8859-1",&res);
766 err = mailmime_encoded_phrase_parse(charset.latin1(),
767 body_text.latin1(), body_text.length(),&index, "utf-8",&res);
768 if (err == MAILIMF_NO_ERROR && res && strlen(res)) {
769 //qDebug("res %d %s ", index, res);
770 body_text = QString::fromUtf8(res);
771 }
772 if (res) free(res);
773 }
755 //qDebug("encoding %d text %s ",currentPart->Encoding().latin1(), body_text.latin1() ); 774 //qDebug("encoding %d text %s ",currentPart->Encoding().latin1(), body_text.latin1() );
756 target_body->setDescription(currentPart); 775 target_body->setDescription(currentPart);
757 target_body->setBodytext(body_text); 776 target_body->setBodytext(body_text);
758 if (countlist.count()>1) { 777 if (countlist.count()>1) {
759 target_body->addPart(currentPart); 778 target_body->addPart(currentPart);
760 } 779 }
761 } else { 780 } else {
762 target_body->addPart(currentPart); 781 target_body->addPart(currentPart);
763 } 782 }
764 if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) { 783 if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) {
765 traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist); 784 traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist);
766 } 785 }
767 } 786 }
768 break; 787 break;
769 case MAILIMAP_BODY_MPART: 788 case MAILIMAP_BODY_MPART:
770 { 789 {
771 QValueList<int>countlist = recList; 790 QValueList<int>countlist = recList;
772 clistcell*current=0; 791 clistcell*current=0;
773 mailimap_body*current_body=0; 792 mailimap_body*current_body=0;
774 unsigned int ccount = 1; 793 unsigned int ccount = 1;
775 mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart; 794 mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart;
776 for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { 795 for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) {
777 current_body = (mailimap_body*)current->data; 796 current_body = (mailimap_body*)current->data;
778 if (current_body->bd_type==MAILIMAP_BODY_MPART) { 797 if (current_body->bd_type==MAILIMAP_BODY_MPART) {