summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/imapwrapper.cpp3
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp3
2 files changed, 4 insertions, 2 deletions
diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp
index ae196bb..b437df0 100644
--- a/noncore/net/mail/imapwrapper.cpp
+++ b/noncore/net/mail/imapwrapper.cpp
@@ -523,257 +523,258 @@ encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int>
523 523
524/* current_recursion is for recursive calls. 524/* current_recursion is for recursive calls.
525 current_count means the position inside the internal loop! */ 525 current_count means the position inside the internal loop! */
526void IMAPwrapper::traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body, 526void 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 switch (body->bd_type) { 532 switch (body->bd_type) {
533 case MAILIMAP_BODY_1PART: 533 case MAILIMAP_BODY_1PART:
534 { 534 {
535 QValueList<int>countlist = recList; 535 QValueList<int>countlist = recList;
536 countlist.append(current_count); 536 countlist.append(current_count);
537 RecPart currentPart; 537 RecPart currentPart;
538 mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; 538 mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part;
539 QString id(""); 539 QString id("");
540 currentPart.setPositionlist(countlist); 540 currentPart.setPositionlist(countlist);
541 for (unsigned int j = 0; j < countlist.count();++j) { 541 for (unsigned int j = 0; j < countlist.count();++j) {
542 id+=(j>0?" ":""); 542 id+=(j>0?" ":"");
543 id+=QString("%1").arg(countlist[j]); 543 id+=QString("%1").arg(countlist[j]);
544 } 544 }
545 qDebug("ID = %s",id.latin1()); 545 qDebug("ID = %s",id.latin1());
546 currentPart.setIdentifier(id); 546 currentPart.setIdentifier(id);
547 fillSinglePart(currentPart,part1); 547 fillSinglePart(currentPart,part1);
548 /* important: Check for is NULL 'cause a body can be empty! 548 /* important: Check for is NULL 'cause a body can be empty!
549 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 */
550 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) {
551 QString body_text = fetchTextPart(mail,countlist,true,currentPart.Encoding()); 551 QString body_text = fetchTextPart(mail,countlist,true,currentPart.Encoding());
552 target_body.setDescription(currentPart); 552 target_body.setDescription(currentPart);
553 target_body.setBodytext(body_text); 553 target_body.setBodytext(body_text);
554 if (countlist.count()>1) { 554 if (countlist.count()>1) {
555 target_body.addPart(currentPart); 555 target_body.addPart(currentPart);
556 } 556 }
557 } else { 557 } else {
558 target_body.addPart(currentPart); 558 target_body.addPart(currentPart);
559 } 559 }
560 if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) { 560 if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) {
561 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);
562 } 562 }
563 } 563 }
564 break; 564 break;
565 case MAILIMAP_BODY_MPART: 565 case MAILIMAP_BODY_MPART:
566 { 566 {
567 QValueList<int>countlist = recList; 567 QValueList<int>countlist = recList;
568 clistcell*current=0; 568 clistcell*current=0;
569 mailimap_body*current_body=0; 569 mailimap_body*current_body=0;
570 unsigned int ccount = 1; 570 unsigned int ccount = 1;
571 mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart; 571 mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart;
572 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)) {
573 current_body = (mailimap_body*)current->data; 573 current_body = (mailimap_body*)current->data;
574 if (current_body->bd_type==MAILIMAP_BODY_MPART) { 574 if (current_body->bd_type==MAILIMAP_BODY_MPART) {
575 RecPart targetPart; 575 RecPart targetPart;
576 targetPart.setType("multipart"); 576 targetPart.setType("multipart");
577 fillMultiPart(targetPart,mailDescription); 577 fillMultiPart(targetPart,mailDescription);
578 countlist.append(current_count); 578 countlist.append(current_count);
579 targetPart.setPositionlist(countlist); 579 targetPart.setPositionlist(countlist);
580 target_body.addPart(targetPart); 580 target_body.addPart(targetPart);
581 QString id(""); 581 QString id("");
582 for (unsigned int j = 0; j < countlist.count();++j) { 582 for (unsigned int j = 0; j < countlist.count();++j) {
583 id+=(j>0?" ":""); 583 id+=(j>0?" ":"");
584 id+=QString("%1").arg(countlist[j]); 584 id+=QString("%1").arg(countlist[j]);
585 } 585 }
586 qDebug("ID(mpart) = %s",id.latin1()); 586 qDebug("ID(mpart) = %s",id.latin1());
587 } 587 }
588 traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount); 588 traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount);
589 if (current_body->bd_type==MAILIMAP_BODY_MPART) { 589 if (current_body->bd_type==MAILIMAP_BODY_MPART) {
590 countlist = recList; 590 countlist = recList;
591 } 591 }
592 ++ccount; 592 ++ccount;
593 } 593 }
594 } 594 }
595 break; 595 break;
596 default: 596 default:
597 break; 597 break;
598 } 598 }
599} 599}
600 600
601void IMAPwrapper::fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description) 601void IMAPwrapper::fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description)
602{ 602{
603 if (!Description) { 603 if (!Description) {
604 return; 604 return;
605 } 605 }
606 switch (Description->bd_type) { 606 switch (Description->bd_type) {
607 case MAILIMAP_BODY_TYPE_1PART_TEXT: 607 case MAILIMAP_BODY_TYPE_1PART_TEXT:
608 target_part.setType("text"); 608 target_part.setType("text");
609 fillSingleTextPart(target_part,Description->bd_data.bd_type_text); 609 fillSingleTextPart(target_part,Description->bd_data.bd_type_text);
610 break; 610 break;
611 case MAILIMAP_BODY_TYPE_1PART_BASIC: 611 case MAILIMAP_BODY_TYPE_1PART_BASIC:
612 fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); 612 fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic);
613 break; 613 break;
614 case MAILIMAP_BODY_TYPE_1PART_MSG: 614 case MAILIMAP_BODY_TYPE_1PART_MSG:
615 target_part.setType("message"); 615 target_part.setType("message");
616 fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg); 616 fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg);
617 break; 617 break;
618 default: 618 default:
619 break; 619 break;
620 } 620 }
621} 621}
622 622
623void IMAPwrapper::fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which) 623void IMAPwrapper::fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which)
624{ 624{
625 if (!which) { 625 if (!which) {
626 return; 626 return;
627 } 627 }
628 QString sub; 628 QString sub;
629 sub = which->bd_media_text; 629 sub = which->bd_media_text;
630 qDebug("Type= text/%s",which->bd_media_text); 630 qDebug("Type= text/%s",which->bd_media_text);
631 target_part.setSubtype(sub.lower()); 631 target_part.setSubtype(sub.lower());
632 target_part.setLines(which->bd_lines); 632 target_part.setLines(which->bd_lines);
633 fillBodyFields(target_part,which->bd_fields); 633 fillBodyFields(target_part,which->bd_fields);
634} 634}
635 635
636void IMAPwrapper::fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which) 636void IMAPwrapper::fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which)
637{ 637{
638 if (!which) { 638 if (!which) {
639 return; 639 return;
640 } 640 }
641 target_part.setSubtype("rfc822"); 641 target_part.setSubtype("rfc822");
642 qDebug("Message part"); 642 qDebug("Message part");
643 /* we set this type to text/plain */ 643 /* we set this type to text/plain */
644 target_part.setLines(which->bd_lines); 644 target_part.setLines(which->bd_lines);
645 fillBodyFields(target_part,which->bd_fields); 645 fillBodyFields(target_part,which->bd_fields);
646} 646}
647 647
648void IMAPwrapper::fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which) 648void IMAPwrapper::fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which)
649{ 649{
650 if (!which) return; 650 if (!which) return;
651 target_part.setSubtype(which->bd_media_subtype); 651 QString sub = which->bd_media_subtype;
652 target_part.setSubtype(sub.lower());
652 if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) { 653 if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) {
653 clistcell*cur = 0; 654 clistcell*cur = 0;
654 mailimap_single_body_fld_param*param=0; 655 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 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 param = (mailimap_single_body_fld_param*)cur->data;
657 if (param) { 658 if (param) {
658 target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); 659 target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
659 } 660 }
660 } 661 }
661 } 662 }
662} 663}
663 664
664void IMAPwrapper::fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which) 665void IMAPwrapper::fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which)
665{ 666{
666 if (!which) { 667 if (!which) {
667 return; 668 return;
668 } 669 }
669 QString type,sub; 670 QString type,sub;
670 switch (which->bd_media_basic->med_type) { 671 switch (which->bd_media_basic->med_type) {
671 case MAILIMAP_MEDIA_BASIC_APPLICATION: 672 case MAILIMAP_MEDIA_BASIC_APPLICATION:
672 type = "application"; 673 type = "application";
673 break; 674 break;
674 case MAILIMAP_MEDIA_BASIC_AUDIO: 675 case MAILIMAP_MEDIA_BASIC_AUDIO:
675 type = "audio"; 676 type = "audio";
676 break; 677 break;
677 case MAILIMAP_MEDIA_BASIC_IMAGE: 678 case MAILIMAP_MEDIA_BASIC_IMAGE:
678 type = "image"; 679 type = "image";
679 break; 680 break;
680 case MAILIMAP_MEDIA_BASIC_MESSAGE: 681 case MAILIMAP_MEDIA_BASIC_MESSAGE:
681 type = "message"; 682 type = "message";
682 break; 683 break;
683 case MAILIMAP_MEDIA_BASIC_VIDEO: 684 case MAILIMAP_MEDIA_BASIC_VIDEO:
684 type = "video"; 685 type = "video";
685 break; 686 break;
686 case MAILIMAP_MEDIA_BASIC_OTHER: 687 case MAILIMAP_MEDIA_BASIC_OTHER:
687 default: 688 default:
688 if (which->bd_media_basic->med_basic_type) { 689 if (which->bd_media_basic->med_basic_type) {
689 type = which->bd_media_basic->med_basic_type; 690 type = which->bd_media_basic->med_basic_type;
690 } else { 691 } else {
691 type = ""; 692 type = "";
692 } 693 }
693 break; 694 break;
694 } 695 }
695 if (which->bd_media_basic->med_subtype) { 696 if (which->bd_media_basic->med_subtype) {
696 sub = which->bd_media_basic->med_subtype; 697 sub = which->bd_media_basic->med_subtype;
697 } else { 698 } else {
698 sub = ""; 699 sub = "";
699 } 700 }
700 qDebug("Type = %s/%s",type.latin1(),sub.latin1()); 701 qDebug("Type = %s/%s",type.latin1(),sub.latin1());
701 target_part.setType(type.lower()); 702 target_part.setType(type.lower());
702 target_part.setSubtype(sub.lower()); 703 target_part.setSubtype(sub.lower());
703 fillBodyFields(target_part,which->bd_fields); 704 fillBodyFields(target_part,which->bd_fields);
704} 705}
705 706
706void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which) 707void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which)
707{ 708{
708 if (!which) return; 709 if (!which) return;
709 if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) { 710 if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) {
710 clistcell*cur; 711 clistcell*cur;
711 mailimap_single_body_fld_param*param=0; 712 mailimap_single_body_fld_param*param=0;
712 for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { 713 for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) {
713 param = (mailimap_single_body_fld_param*)cur->data; 714 param = (mailimap_single_body_fld_param*)cur->data;
714 if (param) { 715 if (param) {
715 target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); 716 target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
716 } 717 }
717 } 718 }
718 } 719 }
719 mailimap_body_fld_enc*enc = which->bd_encoding; 720 mailimap_body_fld_enc*enc = which->bd_encoding;
720 QString encoding(""); 721 QString encoding("");
721 switch (enc->enc_type) { 722 switch (enc->enc_type) {
722 case MAILIMAP_BODY_FLD_ENC_7BIT: 723 case MAILIMAP_BODY_FLD_ENC_7BIT:
723 encoding = "7bit"; 724 encoding = "7bit";
724 break; 725 break;
725 case MAILIMAP_BODY_FLD_ENC_8BIT: 726 case MAILIMAP_BODY_FLD_ENC_8BIT:
726 encoding = "8bit"; 727 encoding = "8bit";
727 break; 728 break;
728 case MAILIMAP_BODY_FLD_ENC_BINARY: 729 case MAILIMAP_BODY_FLD_ENC_BINARY:
729 encoding="binary"; 730 encoding="binary";
730 break; 731 break;
731 case MAILIMAP_BODY_FLD_ENC_BASE64: 732 case MAILIMAP_BODY_FLD_ENC_BASE64:
732 encoding="base64"; 733 encoding="base64";
733 break; 734 break;
734 case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: 735 case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE:
735 encoding="quoted-printable"; 736 encoding="quoted-printable";
736 break; 737 break;
737 case MAILIMAP_BODY_FLD_ENC_OTHER: 738 case MAILIMAP_BODY_FLD_ENC_OTHER:
738 default: 739 default:
739 if (enc->enc_value) { 740 if (enc->enc_value) {
740 char*t=enc->enc_value; 741 char*t=enc->enc_value;
741 encoding=QString(enc->enc_value); 742 encoding=QString(enc->enc_value);
742 enc->enc_value=0L; 743 enc->enc_value=0L;
743 free(t); 744 free(t);
744 } 745 }
745 } 746 }
746 if (which->bd_description) { 747 if (which->bd_description) {
747 target_part.setDescription(QString(which->bd_description)); 748 target_part.setDescription(QString(which->bd_description));
748 } 749 }
749 target_part.setEncoding(encoding); 750 target_part.setEncoding(encoding);
750 target_part.setSize(which->bd_size); 751 target_part.setSize(which->bd_size);
751} 752}
752 753
753void IMAPwrapper::deleteMail(const RecMail&mail) 754void IMAPwrapper::deleteMail(const RecMail&mail)
754{ 755{
755 mailimap_flag_list*flist; 756 mailimap_flag_list*flist;
756 mailimap_set *set; 757 mailimap_set *set;
757 mailimap_store_att_flags * store_flags; 758 mailimap_store_att_flags * store_flags;
758 int err; 759 int err;
759 login(); 760 login();
760 if (!m_imap) { 761 if (!m_imap) {
761 return; 762 return;
762 } 763 }
763 const char *mb = mail.getMbox().latin1(); 764 const char *mb = mail.getMbox().latin1();
764 err = mailimap_select( m_imap, (char*)mb); 765 err = mailimap_select( m_imap, (char*)mb);
765 if ( err != MAILIMAP_NO_ERROR ) { 766 if ( err != MAILIMAP_NO_ERROR ) {
766 qDebug("error selecting mailbox for delete: %s",m_imap->imap_response); 767 qDebug("error selecting mailbox for delete: %s",m_imap->imap_response);
767 return; 768 return;
768 } 769 }
769 flist = mailimap_flag_list_new_empty(); 770 flist = mailimap_flag_list_new_empty();
770 mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); 771 mailimap_flag_list_add(flist,mailimap_flag_new_deleted());
771 store_flags = mailimap_store_att_flags_new_set_flags(flist); 772 store_flags = mailimap_store_att_flags_new_set_flags(flist);
772 set = mailimap_set_new_single(mail.getNumber()); 773 set = mailimap_set_new_single(mail.getNumber());
773 err = mailimap_store(m_imap,set,store_flags); 774 err = mailimap_store(m_imap,set,store_flags);
774 mailimap_set_free( set ); 775 mailimap_set_free( set );
775 mailimap_store_att_flags_free(store_flags); 776 mailimap_store_att_flags_free(store_flags);
776 777
777 if (err != MAILIMAP_NO_ERROR) { 778 if (err != MAILIMAP_NO_ERROR) {
778 qDebug("error deleting mail: %s",m_imap->imap_response); 779 qDebug("error deleting mail: %s",m_imap->imap_response);
779 return; 780 return;
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
index ae196bb..b437df0 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
@@ -523,257 +523,258 @@ encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int>
523 523
524/* current_recursion is for recursive calls. 524/* current_recursion is for recursive calls.
525 current_count means the position inside the internal loop! */ 525 current_count means the position inside the internal loop! */
526void IMAPwrapper::traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body, 526void 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 switch (body->bd_type) { 532 switch (body->bd_type) {
533 case MAILIMAP_BODY_1PART: 533 case MAILIMAP_BODY_1PART:
534 { 534 {
535 QValueList<int>countlist = recList; 535 QValueList<int>countlist = recList;
536 countlist.append(current_count); 536 countlist.append(current_count);
537 RecPart currentPart; 537 RecPart currentPart;
538 mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; 538 mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part;
539 QString id(""); 539 QString id("");
540 currentPart.setPositionlist(countlist); 540 currentPart.setPositionlist(countlist);
541 for (unsigned int j = 0; j < countlist.count();++j) { 541 for (unsigned int j = 0; j < countlist.count();++j) {
542 id+=(j>0?" ":""); 542 id+=(j>0?" ":"");
543 id+=QString("%1").arg(countlist[j]); 543 id+=QString("%1").arg(countlist[j]);
544 } 544 }
545 qDebug("ID = %s",id.latin1()); 545 qDebug("ID = %s",id.latin1());
546 currentPart.setIdentifier(id); 546 currentPart.setIdentifier(id);
547 fillSinglePart(currentPart,part1); 547 fillSinglePart(currentPart,part1);
548 /* important: Check for is NULL 'cause a body can be empty! 548 /* important: Check for is NULL 'cause a body can be empty!
549 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 */
550 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) {
551 QString body_text = fetchTextPart(mail,countlist,true,currentPart.Encoding()); 551 QString body_text = fetchTextPart(mail,countlist,true,currentPart.Encoding());
552 target_body.setDescription(currentPart); 552 target_body.setDescription(currentPart);
553 target_body.setBodytext(body_text); 553 target_body.setBodytext(body_text);
554 if (countlist.count()>1) { 554 if (countlist.count()>1) {
555 target_body.addPart(currentPart); 555 target_body.addPart(currentPart);
556 } 556 }
557 } else { 557 } else {
558 target_body.addPart(currentPart); 558 target_body.addPart(currentPart);
559 } 559 }
560 if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) { 560 if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) {
561 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);
562 } 562 }
563 } 563 }
564 break; 564 break;
565 case MAILIMAP_BODY_MPART: 565 case MAILIMAP_BODY_MPART:
566 { 566 {
567 QValueList<int>countlist = recList; 567 QValueList<int>countlist = recList;
568 clistcell*current=0; 568 clistcell*current=0;
569 mailimap_body*current_body=0; 569 mailimap_body*current_body=0;
570 unsigned int ccount = 1; 570 unsigned int ccount = 1;
571 mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart; 571 mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart;
572 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)) {
573 current_body = (mailimap_body*)current->data; 573 current_body = (mailimap_body*)current->data;
574 if (current_body->bd_type==MAILIMAP_BODY_MPART) { 574 if (current_body->bd_type==MAILIMAP_BODY_MPART) {
575 RecPart targetPart; 575 RecPart targetPart;
576 targetPart.setType("multipart"); 576 targetPart.setType("multipart");
577 fillMultiPart(targetPart,mailDescription); 577 fillMultiPart(targetPart,mailDescription);
578 countlist.append(current_count); 578 countlist.append(current_count);
579 targetPart.setPositionlist(countlist); 579 targetPart.setPositionlist(countlist);
580 target_body.addPart(targetPart); 580 target_body.addPart(targetPart);
581 QString id(""); 581 QString id("");
582 for (unsigned int j = 0; j < countlist.count();++j) { 582 for (unsigned int j = 0; j < countlist.count();++j) {
583 id+=(j>0?" ":""); 583 id+=(j>0?" ":"");
584 id+=QString("%1").arg(countlist[j]); 584 id+=QString("%1").arg(countlist[j]);
585 } 585 }
586 qDebug("ID(mpart) = %s",id.latin1()); 586 qDebug("ID(mpart) = %s",id.latin1());
587 } 587 }
588 traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount); 588 traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount);
589 if (current_body->bd_type==MAILIMAP_BODY_MPART) { 589 if (current_body->bd_type==MAILIMAP_BODY_MPART) {
590 countlist = recList; 590 countlist = recList;
591 } 591 }
592 ++ccount; 592 ++ccount;
593 } 593 }
594 } 594 }
595 break; 595 break;
596 default: 596 default:
597 break; 597 break;
598 } 598 }
599} 599}
600 600
601void IMAPwrapper::fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description) 601void IMAPwrapper::fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description)
602{ 602{
603 if (!Description) { 603 if (!Description) {
604 return; 604 return;
605 } 605 }
606 switch (Description->bd_type) { 606 switch (Description->bd_type) {
607 case MAILIMAP_BODY_TYPE_1PART_TEXT: 607 case MAILIMAP_BODY_TYPE_1PART_TEXT:
608 target_part.setType("text"); 608 target_part.setType("text");
609 fillSingleTextPart(target_part,Description->bd_data.bd_type_text); 609 fillSingleTextPart(target_part,Description->bd_data.bd_type_text);
610 break; 610 break;
611 case MAILIMAP_BODY_TYPE_1PART_BASIC: 611 case MAILIMAP_BODY_TYPE_1PART_BASIC:
612 fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); 612 fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic);
613 break; 613 break;
614 case MAILIMAP_BODY_TYPE_1PART_MSG: 614 case MAILIMAP_BODY_TYPE_1PART_MSG:
615 target_part.setType("message"); 615 target_part.setType("message");
616 fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg); 616 fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg);
617 break; 617 break;
618 default: 618 default:
619 break; 619 break;
620 } 620 }
621} 621}
622 622
623void IMAPwrapper::fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which) 623void IMAPwrapper::fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which)
624{ 624{
625 if (!which) { 625 if (!which) {
626 return; 626 return;
627 } 627 }
628 QString sub; 628 QString sub;
629 sub = which->bd_media_text; 629 sub = which->bd_media_text;
630 qDebug("Type= text/%s",which->bd_media_text); 630 qDebug("Type= text/%s",which->bd_media_text);
631 target_part.setSubtype(sub.lower()); 631 target_part.setSubtype(sub.lower());
632 target_part.setLines(which->bd_lines); 632 target_part.setLines(which->bd_lines);
633 fillBodyFields(target_part,which->bd_fields); 633 fillBodyFields(target_part,which->bd_fields);
634} 634}
635 635
636void IMAPwrapper::fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which) 636void IMAPwrapper::fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which)
637{ 637{
638 if (!which) { 638 if (!which) {
639 return; 639 return;
640 } 640 }
641 target_part.setSubtype("rfc822"); 641 target_part.setSubtype("rfc822");
642 qDebug("Message part"); 642 qDebug("Message part");
643 /* we set this type to text/plain */ 643 /* we set this type to text/plain */
644 target_part.setLines(which->bd_lines); 644 target_part.setLines(which->bd_lines);
645 fillBodyFields(target_part,which->bd_fields); 645 fillBodyFields(target_part,which->bd_fields);
646} 646}
647 647
648void IMAPwrapper::fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which) 648void IMAPwrapper::fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which)
649{ 649{
650 if (!which) return; 650 if (!which) return;
651 target_part.setSubtype(which->bd_media_subtype); 651 QString sub = which->bd_media_subtype;
652 target_part.setSubtype(sub.lower());
652 if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) { 653 if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) {
653 clistcell*cur = 0; 654 clistcell*cur = 0;
654 mailimap_single_body_fld_param*param=0; 655 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 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 param = (mailimap_single_body_fld_param*)cur->data;
657 if (param) { 658 if (param) {
658 target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); 659 target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
659 } 660 }
660 } 661 }
661 } 662 }
662} 663}
663 664
664void IMAPwrapper::fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which) 665void IMAPwrapper::fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which)
665{ 666{
666 if (!which) { 667 if (!which) {
667 return; 668 return;
668 } 669 }
669 QString type,sub; 670 QString type,sub;
670 switch (which->bd_media_basic->med_type) { 671 switch (which->bd_media_basic->med_type) {
671 case MAILIMAP_MEDIA_BASIC_APPLICATION: 672 case MAILIMAP_MEDIA_BASIC_APPLICATION:
672 type = "application"; 673 type = "application";
673 break; 674 break;
674 case MAILIMAP_MEDIA_BASIC_AUDIO: 675 case MAILIMAP_MEDIA_BASIC_AUDIO:
675 type = "audio"; 676 type = "audio";
676 break; 677 break;
677 case MAILIMAP_MEDIA_BASIC_IMAGE: 678 case MAILIMAP_MEDIA_BASIC_IMAGE:
678 type = "image"; 679 type = "image";
679 break; 680 break;
680 case MAILIMAP_MEDIA_BASIC_MESSAGE: 681 case MAILIMAP_MEDIA_BASIC_MESSAGE:
681 type = "message"; 682 type = "message";
682 break; 683 break;
683 case MAILIMAP_MEDIA_BASIC_VIDEO: 684 case MAILIMAP_MEDIA_BASIC_VIDEO:
684 type = "video"; 685 type = "video";
685 break; 686 break;
686 case MAILIMAP_MEDIA_BASIC_OTHER: 687 case MAILIMAP_MEDIA_BASIC_OTHER:
687 default: 688 default:
688 if (which->bd_media_basic->med_basic_type) { 689 if (which->bd_media_basic->med_basic_type) {
689 type = which->bd_media_basic->med_basic_type; 690 type = which->bd_media_basic->med_basic_type;
690 } else { 691 } else {
691 type = ""; 692 type = "";
692 } 693 }
693 break; 694 break;
694 } 695 }
695 if (which->bd_media_basic->med_subtype) { 696 if (which->bd_media_basic->med_subtype) {
696 sub = which->bd_media_basic->med_subtype; 697 sub = which->bd_media_basic->med_subtype;
697 } else { 698 } else {
698 sub = ""; 699 sub = "";
699 } 700 }
700 qDebug("Type = %s/%s",type.latin1(),sub.latin1()); 701 qDebug("Type = %s/%s",type.latin1(),sub.latin1());
701 target_part.setType(type.lower()); 702 target_part.setType(type.lower());
702 target_part.setSubtype(sub.lower()); 703 target_part.setSubtype(sub.lower());
703 fillBodyFields(target_part,which->bd_fields); 704 fillBodyFields(target_part,which->bd_fields);
704} 705}
705 706
706void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which) 707void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which)
707{ 708{
708 if (!which) return; 709 if (!which) return;
709 if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) { 710 if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) {
710 clistcell*cur; 711 clistcell*cur;
711 mailimap_single_body_fld_param*param=0; 712 mailimap_single_body_fld_param*param=0;
712 for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { 713 for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) {
713 param = (mailimap_single_body_fld_param*)cur->data; 714 param = (mailimap_single_body_fld_param*)cur->data;
714 if (param) { 715 if (param) {
715 target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); 716 target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
716 } 717 }
717 } 718 }
718 } 719 }
719 mailimap_body_fld_enc*enc = which->bd_encoding; 720 mailimap_body_fld_enc*enc = which->bd_encoding;
720 QString encoding(""); 721 QString encoding("");
721 switch (enc->enc_type) { 722 switch (enc->enc_type) {
722 case MAILIMAP_BODY_FLD_ENC_7BIT: 723 case MAILIMAP_BODY_FLD_ENC_7BIT:
723 encoding = "7bit"; 724 encoding = "7bit";
724 break; 725 break;
725 case MAILIMAP_BODY_FLD_ENC_8BIT: 726 case MAILIMAP_BODY_FLD_ENC_8BIT:
726 encoding = "8bit"; 727 encoding = "8bit";
727 break; 728 break;
728 case MAILIMAP_BODY_FLD_ENC_BINARY: 729 case MAILIMAP_BODY_FLD_ENC_BINARY:
729 encoding="binary"; 730 encoding="binary";
730 break; 731 break;
731 case MAILIMAP_BODY_FLD_ENC_BASE64: 732 case MAILIMAP_BODY_FLD_ENC_BASE64:
732 encoding="base64"; 733 encoding="base64";
733 break; 734 break;
734 case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: 735 case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE:
735 encoding="quoted-printable"; 736 encoding="quoted-printable";
736 break; 737 break;
737 case MAILIMAP_BODY_FLD_ENC_OTHER: 738 case MAILIMAP_BODY_FLD_ENC_OTHER:
738 default: 739 default:
739 if (enc->enc_value) { 740 if (enc->enc_value) {
740 char*t=enc->enc_value; 741 char*t=enc->enc_value;
741 encoding=QString(enc->enc_value); 742 encoding=QString(enc->enc_value);
742 enc->enc_value=0L; 743 enc->enc_value=0L;
743 free(t); 744 free(t);
744 } 745 }
745 } 746 }
746 if (which->bd_description) { 747 if (which->bd_description) {
747 target_part.setDescription(QString(which->bd_description)); 748 target_part.setDescription(QString(which->bd_description));
748 } 749 }
749 target_part.setEncoding(encoding); 750 target_part.setEncoding(encoding);
750 target_part.setSize(which->bd_size); 751 target_part.setSize(which->bd_size);
751} 752}
752 753
753void IMAPwrapper::deleteMail(const RecMail&mail) 754void IMAPwrapper::deleteMail(const RecMail&mail)
754{ 755{
755 mailimap_flag_list*flist; 756 mailimap_flag_list*flist;
756 mailimap_set *set; 757 mailimap_set *set;
757 mailimap_store_att_flags * store_flags; 758 mailimap_store_att_flags * store_flags;
758 int err; 759 int err;
759 login(); 760 login();
760 if (!m_imap) { 761 if (!m_imap) {
761 return; 762 return;
762 } 763 }
763 const char *mb = mail.getMbox().latin1(); 764 const char *mb = mail.getMbox().latin1();
764 err = mailimap_select( m_imap, (char*)mb); 765 err = mailimap_select( m_imap, (char*)mb);
765 if ( err != MAILIMAP_NO_ERROR ) { 766 if ( err != MAILIMAP_NO_ERROR ) {
766 qDebug("error selecting mailbox for delete: %s",m_imap->imap_response); 767 qDebug("error selecting mailbox for delete: %s",m_imap->imap_response);
767 return; 768 return;
768 } 769 }
769 flist = mailimap_flag_list_new_empty(); 770 flist = mailimap_flag_list_new_empty();
770 mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); 771 mailimap_flag_list_add(flist,mailimap_flag_new_deleted());
771 store_flags = mailimap_store_att_flags_new_set_flags(flist); 772 store_flags = mailimap_store_att_flags_new_set_flags(flist);
772 set = mailimap_set_new_single(mail.getNumber()); 773 set = mailimap_set_new_single(mail.getNumber());
773 err = mailimap_store(m_imap,set,store_flags); 774 err = mailimap_store(m_imap,set,store_flags);
774 mailimap_set_free( set ); 775 mailimap_set_free( set );
775 mailimap_store_att_flags_free(store_flags); 776 mailimap_store_att_flags_free(store_flags);
776 777
777 if (err != MAILIMAP_NO_ERROR) { 778 if (err != MAILIMAP_NO_ERROR) {
778 qDebug("error deleting mail: %s",m_imap->imap_response); 779 qDebug("error deleting mail: %s",m_imap->imap_response);
779 return; 780 return;