Diffstat (limited to 'noncore/net/mail/imapwrapper.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/mail/imapwrapper.cpp | 43 |
1 files changed, 40 insertions, 3 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 | |||
@@ -526,13 +526,12 @@ encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int> | |||
526 | void IMAPwrapper::traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body, | 526 | void IMAPwrapper::traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body, |
527 | int current_recursion,QValueList<int>recList,int current_count) | 527 | int current_recursion,QValueList<int>recList,int current_count) |
528 | { | 528 | { |
529 | if (!body || current_recursion>=10) { | 529 | if (!body || current_recursion>=10) { |
530 | return; | 530 | return; |
531 | } | 531 | } |
532 | ++current_count; | ||
533 | switch (body->bd_type) { | 532 | switch (body->bd_type) { |
534 | case MAILIMAP_BODY_1PART: | 533 | case MAILIMAP_BODY_1PART: |
535 | { | 534 | { |
536 | QValueList<int>countlist = recList; | 535 | QValueList<int>countlist = recList; |
537 | countlist.append(current_count); | 536 | countlist.append(current_count); |
538 | RecPart currentPart; | 537 | RecPart currentPart; |
@@ -549,29 +548,50 @@ void IMAPwrapper::traverseBody(const RecMail&mail,mailimap_body*body,RecBody&tar | |||
549 | /* important: Check for is NULL 'cause a body can be empty! | 548 | /* important: Check for is NULL 'cause a body can be empty! |
550 | And we put it only into the mail if it is the FIRST part */ | 549 | And we put it only into the mail if it is the FIRST part */ |
551 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body.Bodytext().isNull() && countlist[0]==1) { | 550 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body.Bodytext().isNull() && countlist[0]==1) { |
552 | QString body_text = fetchTextPart(mail,countlist,true,currentPart.Encoding()); | 551 | QString body_text = fetchTextPart(mail,countlist,true,currentPart.Encoding()); |
553 | target_body.setDescription(currentPart); | 552 | target_body.setDescription(currentPart); |
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 { |
556 | target_body.addPart(currentPart); | 558 | target_body.addPart(currentPart); |
557 | } | 559 | } |
558 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) { | 560 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) { |
559 | traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist); | 561 | traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist); |
560 | } | 562 | } |
561 | } | 563 | } |
562 | break; | 564 | break; |
563 | case MAILIMAP_BODY_MPART: | 565 | case MAILIMAP_BODY_MPART: |
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; |
569 | for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { | 572 | for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { |
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; |
573 | } | 593 | } |
574 | } | 594 | } |
575 | break; | 595 | break; |
576 | default: | 596 | default: |
577 | break; | 597 | break; |
@@ -604,12 +624,13 @@ void IMAPwrapper::fillSingleTextPart(RecPart&target_part,mailimap_body_type_text | |||
604 | { | 624 | { |
605 | if (!which) { | 625 | if (!which) { |
606 | return; | 626 | return; |
607 | } | 627 | } |
608 | QString sub; | 628 | QString sub; |
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()); |
611 | target_part.setLines(which->bd_lines); | 632 | target_part.setLines(which->bd_lines); |
612 | fillBodyFields(target_part,which->bd_fields); | 633 | fillBodyFields(target_part,which->bd_fields); |
613 | } | 634 | } |
614 | 635 | ||
615 | void IMAPwrapper::fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which) | 636 | void IMAPwrapper::fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which) |
@@ -621,12 +642,28 @@ void IMAPwrapper::fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*w | |||
621 | qDebug("Message part"); | 642 | qDebug("Message part"); |
622 | /* we set this type to text/plain */ | 643 | /* we set this type to text/plain */ |
623 | target_part.setLines(which->bd_lines); | 644 | target_part.setLines(which->bd_lines); |
624 | fillBodyFields(target_part,which->bd_fields); | 645 | fillBodyFields(target_part,which->bd_fields); |
625 | } | 646 | } |
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) |
628 | { | 665 | { |
629 | if (!which) { | 666 | if (!which) { |
630 | return; | 667 | return; |
631 | } | 668 | } |
632 | QString type,sub; | 669 | QString type,sub; |