summaryrefslogtreecommitdiff
path: root/noncore/net/mail/libmailwrapper/imapwrapper.cpp
Unidiff
Diffstat (limited to 'noncore/net/mail/libmailwrapper/imapwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp86
1 files changed, 43 insertions, 43 deletions
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
index 56e7df9..230cf53 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
@@ -480,15 +480,15 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
480 m->setFlags(mFlags); 480 m->setFlags(mFlags);
481 m->setMsgsize(size); 481 m->setMsgsize(size);
482 } 482 }
483 return m; 483 return m;
484} 484}
485 485
486RecBody IMAPwrapper::fetchBody(const RecMailP&mail) 486RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail)
487{ 487{
488 RecBody body; 488 RecBodyP body = new RecBody();
489 const char *mb; 489 const char *mb;
490 int err = MAILIMAP_NO_ERROR; 490 int err = MAILIMAP_NO_ERROR;
491 clist *result = 0; 491 clist *result = 0;
492 clistcell *current; 492 clistcell *current;
493 mailimap_fetch_att *fetchAtt = 0; 493 mailimap_fetch_att *fetchAtt = 0;
494 mailimap_fetch_type *fetchType = 0; 494 mailimap_fetch_type *fetchType = 0;
@@ -639,45 +639,45 @@ encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int
639 if (result) mailimap_fetch_list_free(result); 639 if (result) mailimap_fetch_list_free(result);
640 return res; 640 return res;
641} 641}
642 642
643/* current_recursion is for recursive calls. 643/* current_recursion is for recursive calls.
644 current_count means the position inside the internal loop! */ 644 current_count means the position inside the internal loop! */
645void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBody&target_body, 645void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body,
646 int current_recursion,QValueList<int>recList,int current_count) 646 int current_recursion,QValueList<int>recList,int current_count)
647{ 647{
648 if (!body || current_recursion>=10) { 648 if (!body || current_recursion>=10) {
649 return; 649 return;
650 } 650 }
651 switch (body->bd_type) { 651 switch (body->bd_type) {
652 case MAILIMAP_BODY_1PART: 652 case MAILIMAP_BODY_1PART:
653 { 653 {
654 QValueList<int>countlist = recList; 654 QValueList<int>countlist = recList;
655 countlist.append(current_count); 655 countlist.append(current_count);
656 RecPart currentPart; 656 RecPartP currentPart = new RecPart();
657 mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; 657 mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part;
658 QString id(""); 658 QString id("");
659 currentPart.setPositionlist(countlist); 659 currentPart->setPositionlist(countlist);
660 for (unsigned int j = 0; j < countlist.count();++j) { 660 for (unsigned int j = 0; j < countlist.count();++j) {
661 id+=(j>0?" ":""); 661 id+=(j>0?" ":"");
662 id+=QString("%1").arg(countlist[j]); 662 id+=QString("%1").arg(countlist[j]);
663 } 663 }
664 qDebug("ID = %s",id.latin1()); 664 qDebug("ID = %s",id.latin1());
665 currentPart.setIdentifier(id); 665 currentPart->setIdentifier(id);
666 fillSinglePart(currentPart,part1); 666 fillSinglePart(currentPart,part1);
667 /* important: Check for is NULL 'cause a body can be empty! 667 /* important: Check for is NULL 'cause a body can be empty!
668 And we put it only into the mail if it is the FIRST part */ 668 And we put it only into the mail if it is the FIRST part */
669 if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body.Bodytext().isNull() && countlist[0]==1) { 669 if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) {
670 QString body_text = fetchTextPart(mail,countlist,true,currentPart.Encoding()); 670 QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding());
671 target_body.setDescription(currentPart); 671 target_body->setDescription(currentPart);
672 target_body.setBodytext(body_text); 672 target_body->setBodytext(body_text);
673 if (countlist.count()>1) { 673 if (countlist.count()>1) {
674 target_body.addPart(currentPart); 674 target_body->addPart(currentPart);
675 } 675 }
676 } else { 676 } else {
677 target_body.addPart(currentPart); 677 target_body->addPart(currentPart);
678 } 678 }
679 if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) { 679 if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) {
680 traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist); 680 traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist);
681 } 681 }
682 } 682 }
683 break; 683 break;
@@ -688,18 +688,18 @@ void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBody&ta
688 mailimap_body*current_body=0; 688 mailimap_body*current_body=0;
689 unsigned int ccount = 1; 689 unsigned int ccount = 1;
690 mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart; 690 mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart;
691 for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { 691 for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) {
692 current_body = (mailimap_body*)current->data; 692 current_body = (mailimap_body*)current->data;
693 if (current_body->bd_type==MAILIMAP_BODY_MPART) { 693 if (current_body->bd_type==MAILIMAP_BODY_MPART) {
694 RecPart targetPart; 694 RecPartP targetPart = new RecPart();
695 targetPart.setType("multipart"); 695 targetPart->setType("multipart");
696 fillMultiPart(targetPart,mailDescription); 696 fillMultiPart(targetPart,mailDescription);
697 countlist.append(current_count); 697 countlist.append(current_count);
698 targetPart.setPositionlist(countlist); 698 targetPart->setPositionlist(countlist);
699 target_body.addPart(targetPart); 699 target_body->addPart(targetPart);
700 QString id(""); 700 QString id("");
701 for (unsigned int j = 0; j < countlist.count();++j) { 701 for (unsigned int j = 0; j < countlist.count();++j) {
702 id+=(j>0?" ":""); 702 id+=(j>0?" ":"");
703 id+=QString("%1").arg(countlist[j]); 703 id+=QString("%1").arg(countlist[j]);
704 } 704 }
705 qDebug("ID(mpart) = %s",id.latin1()); 705 qDebug("ID(mpart) = %s",id.latin1());
@@ -714,77 +714,77 @@ void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBody&ta
714 break; 714 break;
715 default: 715 default:
716 break; 716 break;
717 } 717 }
718} 718}
719 719
720void IMAPwrapper::fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description) 720void IMAPwrapper::fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description)
721{ 721{
722 if (!Description) { 722 if (!Description) {
723 return; 723 return;
724 } 724 }
725 switch (Description->bd_type) { 725 switch (Description->bd_type) {
726 case MAILIMAP_BODY_TYPE_1PART_TEXT: 726 case MAILIMAP_BODY_TYPE_1PART_TEXT:
727 target_part.setType("text"); 727 target_part->setType("text");
728 fillSingleTextPart(target_part,Description->bd_data.bd_type_text); 728 fillSingleTextPart(target_part,Description->bd_data.bd_type_text);
729 break; 729 break;
730 case MAILIMAP_BODY_TYPE_1PART_BASIC: 730 case MAILIMAP_BODY_TYPE_1PART_BASIC:
731 fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); 731 fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic);
732 break; 732 break;
733 case MAILIMAP_BODY_TYPE_1PART_MSG: 733 case MAILIMAP_BODY_TYPE_1PART_MSG:
734 target_part.setType("message"); 734 target_part->setType("message");
735 fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg); 735 fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg);
736 break; 736 break;
737 default: 737 default:
738 break; 738 break;
739 } 739 }
740} 740}
741 741
742void IMAPwrapper::fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which) 742void IMAPwrapper::fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which)
743{ 743{
744 if (!which) { 744 if (!which) {
745 return; 745 return;
746 } 746 }
747 QString sub; 747 QString sub;
748 sub = which->bd_media_text; 748 sub = which->bd_media_text;
749 qDebug("Type= text/%s",which->bd_media_text); 749 qDebug("Type= text/%s",which->bd_media_text);
750 target_part.setSubtype(sub.lower()); 750 target_part->setSubtype(sub.lower());
751 target_part.setLines(which->bd_lines); 751 target_part->setLines(which->bd_lines);
752 fillBodyFields(target_part,which->bd_fields); 752 fillBodyFields(target_part,which->bd_fields);
753} 753}
754 754
755void IMAPwrapper::fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which) 755void IMAPwrapper::fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which)
756{ 756{
757 if (!which) { 757 if (!which) {
758 return; 758 return;
759 } 759 }
760 target_part.setSubtype("rfc822"); 760 target_part->setSubtype("rfc822");
761 qDebug("Message part"); 761 qDebug("Message part");
762 /* we set this type to text/plain */ 762 /* we set this type to text/plain */
763 target_part.setLines(which->bd_lines); 763 target_part->setLines(which->bd_lines);
764 fillBodyFields(target_part,which->bd_fields); 764 fillBodyFields(target_part,which->bd_fields);
765} 765}
766 766
767void IMAPwrapper::fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which) 767void IMAPwrapper::fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which)
768{ 768{
769 if (!which) return; 769 if (!which) return;
770 QString sub = which->bd_media_subtype; 770 QString sub = which->bd_media_subtype;
771 target_part.setSubtype(sub.lower()); 771 target_part->setSubtype(sub.lower());
772 if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) { 772 if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) {
773 clistcell*cur = 0; 773 clistcell*cur = 0;
774 mailimap_single_body_fld_param*param=0; 774 mailimap_single_body_fld_param*param=0;
775 for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { 775 for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) {
776 param = (mailimap_single_body_fld_param*)cur->data; 776 param = (mailimap_single_body_fld_param*)cur->data;
777 if (param) { 777 if (param) {
778 target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); 778 target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
779 } 779 }
780 } 780 }
781 } 781 }
782} 782}
783 783
784void IMAPwrapper::fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which) 784void IMAPwrapper::fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_basic*which)
785{ 785{
786 if (!which) { 786 if (!which) {
787 return; 787 return;
788 } 788 }
789 QString type,sub; 789 QString type,sub;
790 switch (which->bd_media_basic->med_type) { 790 switch (which->bd_media_basic->med_type) {
@@ -815,27 +815,27 @@ void IMAPwrapper::fillSingleBasicPart(RecPart&target_part,mailimap_body_type_bas
815 if (which->bd_media_basic->med_subtype) { 815 if (which->bd_media_basic->med_subtype) {
816 sub = which->bd_media_basic->med_subtype; 816 sub = which->bd_media_basic->med_subtype;
817 } else { 817 } else {
818 sub = ""; 818 sub = "";
819 } 819 }
820 qDebug("Type = %s/%s",type.latin1(),sub.latin1()); 820 qDebug("Type = %s/%s",type.latin1(),sub.latin1());
821 target_part.setType(type.lower()); 821 target_part->setType(type.lower());
822 target_part.setSubtype(sub.lower()); 822 target_part->setSubtype(sub.lower());
823 fillBodyFields(target_part,which->bd_fields); 823 fillBodyFields(target_part,which->bd_fields);
824} 824}
825 825
826void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which) 826void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which)
827{ 827{
828 if (!which) return; 828 if (!which) return;
829 if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) { 829 if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) {
830 clistcell*cur; 830 clistcell*cur;
831 mailimap_single_body_fld_param*param=0; 831 mailimap_single_body_fld_param*param=0;
832 for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { 832 for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) {
833 param = (mailimap_single_body_fld_param*)cur->data; 833 param = (mailimap_single_body_fld_param*)cur->data;
834 if (param) { 834 if (param) {
835 target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); 835 target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
836 } 836 }
837 } 837 }
838 } 838 }
839 mailimap_body_fld_enc*enc = which->bd_encoding; 839 mailimap_body_fld_enc*enc = which->bd_encoding;
840 QString encoding(""); 840 QString encoding("");
841 switch (enc->enc_type) { 841 switch (enc->enc_type) {
@@ -861,16 +861,16 @@ void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which)
861 encoding=QString(enc->enc_value); 861 encoding=QString(enc->enc_value);
862 enc->enc_value=0L; 862 enc->enc_value=0L;
863 free(t); 863 free(t);
864 } 864 }
865 } 865 }
866 if (which->bd_description) { 866 if (which->bd_description) {
867 target_part.setDescription(QString(which->bd_description)); 867 target_part->setDescription(QString(which->bd_description));
868 } 868 }
869 target_part.setEncoding(encoding); 869 target_part->setEncoding(encoding);
870 target_part.setSize(which->bd_size); 870 target_part->setSize(which->bd_size);
871} 871}
872 872
873void IMAPwrapper::deleteMail(const RecMailP&mail) 873void IMAPwrapper::deleteMail(const RecMailP&mail)
874{ 874{
875 mailimap_flag_list*flist; 875 mailimap_flag_list*flist;
876 mailimap_set *set; 876 mailimap_set *set;
@@ -945,28 +945,28 @@ QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const QValueList<int>&pat
945 } 945 }
946 delete r; 946 delete r;
947 } 947 }
948 return body; 948 return body;
949} 949}
950 950
951QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const RecPart&part) 951QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part)
952{ 952{
953 return fetchTextPart(mail,part.Positionlist(),false,part.Encoding()); 953 return fetchTextPart(mail,part->Positionlist(),false,part->Encoding());
954} 954}
955 955
956encodedString* IMAPwrapper::fetchDecodedPart(const RecMailP&mail,const RecPart&part) 956encodedString* IMAPwrapper::fetchDecodedPart(const RecMailP&mail,const RecPartP&part)
957{ 957{
958 encodedString*res = fetchRawPart(mail,part.Positionlist(),false); 958 encodedString*res = fetchRawPart(mail,part->Positionlist(),false);
959 encodedString*r = decode_String(res,part.Encoding()); 959 encodedString*r = decode_String(res,part->Encoding());
960 delete res; 960 delete res;
961 return r; 961 return r;
962} 962}
963 963
964encodedString* IMAPwrapper::fetchRawPart(const RecMailP&mail,const RecPart&part) 964encodedString* IMAPwrapper::fetchRawPart(const RecMailP&mail,const RecPartP&part)
965{ 965{
966 return fetchRawPart(mail,part.Positionlist(),false); 966 return fetchRawPart(mail,part->Positionlist(),false);
967} 967}
968 968
969int IMAPwrapper::deleteAllMail(const FolderP&folder) 969int IMAPwrapper::deleteAllMail(const FolderP&folder)
970{ 970{
971 login(); 971 login();
972 if (!m_imap) { 972 if (!m_imap) {