author | alwin <alwin> | 2004-01-03 02:17:50 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-01-03 02:17:50 (UTC) |
commit | 1214e08e45cda6f0de39a8f3bcff2e69244bb87f (patch) (unidiff) | |
tree | d51a018b6014904c09272c684e211d8d05cf360e | |
parent | 79bca648a80c42d5dc7e7674b251715292db33b3 (diff) | |
download | opie-1214e08e45cda6f0de39a8f3bcff2e69244bb87f.zip opie-1214e08e45cda6f0de39a8f3bcff2e69244bb87f.tar.gz opie-1214e08e45cda6f0de39a8f3bcff2e69244bb87f.tar.bz2 |
improved parsing of mailbodies 'cause it failed on multi-part fields which
contains multipart-fields, too.
-rw-r--r-- | noncore/net/mail/imapwrapper.cpp | 43 | ||||
-rw-r--r-- | noncore/net/mail/imapwrapper.h | 3 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 43 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.h | 3 |
4 files changed, 84 insertions, 8 deletions
diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp index f7e93aa..ae196bb 100644 --- a/noncore/net/mail/imapwrapper.cpp +++ b/noncore/net/mail/imapwrapper.cpp | |||
@@ -531,3 +531,2 @@ void IMAPwrapper::traverseBody(const RecMail&mail,mailimap_body*body,RecBody&tar | |||
531 | } | 531 | } |
532 | ++current_count; | ||
533 | switch (body->bd_type) { | 532 | switch (body->bd_type) { |
@@ -554,2 +553,5 @@ void IMAPwrapper::traverseBody(const RecMail&mail,mailimap_body*body,RecBody&tar | |||
554 | target_body.setBodytext(body_text); | 553 | target_body.setBodytext(body_text); |
554 | if (countlist.count()>1) { | ||
555 | target_body.addPart(currentPart); | ||
556 | } | ||
555 | } else { | 557 | } else { |
@@ -564,5 +566,6 @@ void IMAPwrapper::traverseBody(const RecMail&mail,mailimap_body*body,RecBody&tar | |||
564 | { | 566 | { |
567 | QValueList<int>countlist = recList; | ||
565 | clistcell*current=0; | 568 | clistcell*current=0; |
566 | mailimap_body*current_body=0; | 569 | mailimap_body*current_body=0; |
567 | unsigned int ccount = current_count-1; | 570 | unsigned int ccount = 1; |
568 | mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart; | 571 | mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart; |
@@ -570,3 +573,20 @@ void IMAPwrapper::traverseBody(const RecMail&mail,mailimap_body*body,RecBody&tar | |||
570 | current_body = (mailimap_body*)current->data; | 573 | current_body = (mailimap_body*)current->data; |
571 | traverseBody(mail,current_body,target_body,current_recursion+1,recList,ccount); | 574 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { |
575 | RecPart targetPart; | ||
576 | targetPart.setType("multipart"); | ||
577 | fillMultiPart(targetPart,mailDescription); | ||
578 | countlist.append(current_count); | ||
579 | targetPart.setPositionlist(countlist); | ||
580 | target_body.addPart(targetPart); | ||
581 | QString id(""); | ||
582 | for (unsigned int j = 0; j < countlist.count();++j) { | ||
583 | id+=(j>0?" ":""); | ||
584 | id+=QString("%1").arg(countlist[j]); | ||
585 | } | ||
586 | qDebug("ID(mpart) = %s",id.latin1()); | ||
587 | } | ||
588 | traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount); | ||
589 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { | ||
590 | countlist = recList; | ||
591 | } | ||
572 | ++ccount; | 592 | ++ccount; |
@@ -609,2 +629,3 @@ void IMAPwrapper::fillSingleTextPart(RecPart&target_part,mailimap_body_type_text | |||
609 | sub = which->bd_media_text; | 629 | sub = which->bd_media_text; |
630 | qDebug("Type= text/%s",which->bd_media_text); | ||
610 | target_part.setSubtype(sub.lower()); | 631 | target_part.setSubtype(sub.lower()); |
@@ -626,2 +647,18 @@ void IMAPwrapper::fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*w | |||
626 | 647 | ||
648 | void IMAPwrapper::fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which) | ||
649 | { | ||
650 | if (!which) return; | ||
651 | target_part.setSubtype(which->bd_media_subtype); | ||
652 | if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) { | ||
653 | clistcell*cur = 0; | ||
654 | mailimap_single_body_fld_param*param=0; | ||
655 | for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { | ||
656 | param = (mailimap_single_body_fld_param*)cur->data; | ||
657 | if (param) { | ||
658 | target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); | ||
659 | } | ||
660 | } | ||
661 | } | ||
662 | } | ||
663 | |||
627 | void IMAPwrapper::fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which) | 664 | void IMAPwrapper::fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which) |
diff --git a/noncore/net/mail/imapwrapper.h b/noncore/net/mail/imapwrapper.h index e5846f8..7941046 100644 --- a/noncore/net/mail/imapwrapper.h +++ b/noncore/net/mail/imapwrapper.h | |||
@@ -54,3 +54,4 @@ protected: | |||
54 | void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which); | 54 | void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which); |
55 | void traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body,int current_recursion,QValueList<int>recList,int current_count=0); | 55 | void fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which); |
56 | void traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body,int current_recursion,QValueList<int>recList,int current_count=1); | ||
56 | 57 | ||
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index f7e93aa..ae196bb 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp | |||
@@ -531,3 +531,2 @@ void IMAPwrapper::traverseBody(const RecMail&mail,mailimap_body*body,RecBody&tar | |||
531 | } | 531 | } |
532 | ++current_count; | ||
533 | switch (body->bd_type) { | 532 | switch (body->bd_type) { |
@@ -554,2 +553,5 @@ void IMAPwrapper::traverseBody(const RecMail&mail,mailimap_body*body,RecBody&tar | |||
554 | target_body.setBodytext(body_text); | 553 | target_body.setBodytext(body_text); |
554 | if (countlist.count()>1) { | ||
555 | target_body.addPart(currentPart); | ||
556 | } | ||
555 | } else { | 557 | } else { |
@@ -564,5 +566,6 @@ void IMAPwrapper::traverseBody(const RecMail&mail,mailimap_body*body,RecBody&tar | |||
564 | { | 566 | { |
567 | QValueList<int>countlist = recList; | ||
565 | clistcell*current=0; | 568 | clistcell*current=0; |
566 | mailimap_body*current_body=0; | 569 | mailimap_body*current_body=0; |
567 | unsigned int ccount = current_count-1; | 570 | unsigned int ccount = 1; |
568 | mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart; | 571 | mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart; |
@@ -570,3 +573,20 @@ void IMAPwrapper::traverseBody(const RecMail&mail,mailimap_body*body,RecBody&tar | |||
570 | current_body = (mailimap_body*)current->data; | 573 | current_body = (mailimap_body*)current->data; |
571 | traverseBody(mail,current_body,target_body,current_recursion+1,recList,ccount); | 574 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { |
575 | RecPart targetPart; | ||
576 | targetPart.setType("multipart"); | ||
577 | fillMultiPart(targetPart,mailDescription); | ||
578 | countlist.append(current_count); | ||
579 | targetPart.setPositionlist(countlist); | ||
580 | target_body.addPart(targetPart); | ||
581 | QString id(""); | ||
582 | for (unsigned int j = 0; j < countlist.count();++j) { | ||
583 | id+=(j>0?" ":""); | ||
584 | id+=QString("%1").arg(countlist[j]); | ||
585 | } | ||
586 | qDebug("ID(mpart) = %s",id.latin1()); | ||
587 | } | ||
588 | traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount); | ||
589 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { | ||
590 | countlist = recList; | ||
591 | } | ||
572 | ++ccount; | 592 | ++ccount; |
@@ -609,2 +629,3 @@ void IMAPwrapper::fillSingleTextPart(RecPart&target_part,mailimap_body_type_text | |||
609 | sub = which->bd_media_text; | 629 | sub = which->bd_media_text; |
630 | qDebug("Type= text/%s",which->bd_media_text); | ||
610 | target_part.setSubtype(sub.lower()); | 631 | target_part.setSubtype(sub.lower()); |
@@ -626,2 +647,18 @@ void IMAPwrapper::fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*w | |||
626 | 647 | ||
648 | void IMAPwrapper::fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which) | ||
649 | { | ||
650 | if (!which) return; | ||
651 | target_part.setSubtype(which->bd_media_subtype); | ||
652 | if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) { | ||
653 | clistcell*cur = 0; | ||
654 | mailimap_single_body_fld_param*param=0; | ||
655 | for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { | ||
656 | param = (mailimap_single_body_fld_param*)cur->data; | ||
657 | if (param) { | ||
658 | target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); | ||
659 | } | ||
660 | } | ||
661 | } | ||
662 | } | ||
663 | |||
627 | void IMAPwrapper::fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which) | 664 | void IMAPwrapper::fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which) |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h index e5846f8..7941046 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.h +++ b/noncore/net/mail/libmailwrapper/imapwrapper.h | |||
@@ -54,3 +54,4 @@ protected: | |||
54 | void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which); | 54 | void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which); |
55 | void traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body,int current_recursion,QValueList<int>recList,int current_count=0); | 55 | void fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which); |
56 | void traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body,int current_recursion,QValueList<int>recList,int current_count=1); | ||
56 | 57 | ||