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.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp
index 91332c3..d79df4f 100644
--- a/kmicromail/libmailwrapper/imapwrapper.cpp
+++ b/kmicromail/libmailwrapper/imapwrapper.cpp
@@ -755,388 +755,391 @@ void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&t
755 target_body->addPart(targetPart); 755 target_body->addPart(targetPart);
756 QString id(""); 756 QString id("");
757 for (unsigned int j = 0; j < countlist.count();++j) { 757 for (unsigned int j = 0; j < countlist.count();++j) {
758 id+=(j>0?" ":""); 758 id+=(j>0?" ":"");
759 id+=QString("%1").arg(countlist[j]); 759 id+=QString("%1").arg(countlist[j]);
760 } 760 }
761 // odebug << "ID(mpart) = " << id.latin1() << "" << oendl; 761 // odebug << "ID(mpart) = " << id.latin1() << "" << oendl;
762 } 762 }
763 traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount); 763 traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount);
764 if (current_body->bd_type==MAILIMAP_BODY_MPART) { 764 if (current_body->bd_type==MAILIMAP_BODY_MPART) {
765 countlist = recList; 765 countlist = recList;
766 } 766 }
767 ++ccount; 767 ++ccount;
768 } 768 }
769 } 769 }
770 break; 770 break;
771 default: 771 default:
772 break; 772 break;
773 } 773 }
774} 774}
775 775
776void IMAPwrapper::fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description) 776void IMAPwrapper::fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description)
777{ 777{
778 if (!Description) { 778 if (!Description) {
779 return; 779 return;
780 } 780 }
781 switch (Description->bd_type) { 781 switch (Description->bd_type) {
782 case MAILIMAP_BODY_TYPE_1PART_TEXT: 782 case MAILIMAP_BODY_TYPE_1PART_TEXT:
783 target_part->setType("text"); 783 target_part->setType("text");
784 fillSingleTextPart(target_part,Description->bd_data.bd_type_text); 784 fillSingleTextPart(target_part,Description->bd_data.bd_type_text);
785 break; 785 break;
786 case MAILIMAP_BODY_TYPE_1PART_BASIC: 786 case MAILIMAP_BODY_TYPE_1PART_BASIC:
787 fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); 787 fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic);
788 break; 788 break;
789 case MAILIMAP_BODY_TYPE_1PART_MSG: 789 case MAILIMAP_BODY_TYPE_1PART_MSG:
790 target_part->setType("message"); 790 target_part->setType("message");
791 fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg); 791 fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg);
792 break; 792 break;
793 default: 793 default:
794 break; 794 break;
795 } 795 }
796} 796}
797 797
798void IMAPwrapper::fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which) 798void IMAPwrapper::fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which)
799{ 799{
800 if (!which) { 800 if (!which) {
801 return; 801 return;
802 } 802 }
803 QString sub; 803 QString sub;
804 sub = which->bd_media_text; 804 sub = which->bd_media_text;
805 //odebug << "Type= text/" << which->bd_media_text << "" << oendl; 805 //odebug << "Type= text/" << which->bd_media_text << "" << oendl;
806 target_part->setSubtype(sub.lower()); 806 target_part->setSubtype(sub.lower());
807 target_part->setLines(which->bd_lines); 807 target_part->setLines(which->bd_lines);
808 fillBodyFields(target_part,which->bd_fields); 808 fillBodyFields(target_part,which->bd_fields);
809} 809}
810 810
811void IMAPwrapper::fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which) 811void IMAPwrapper::fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which)
812{ 812{
813 if (!which) { 813 if (!which) {
814 return; 814 return;
815 } 815 }
816 target_part->setSubtype("rfc822"); 816 target_part->setSubtype("rfc822");
817 //odebug << "Message part" << oendl; 817 //odebug << "Message part" << oendl;
818 /* we set this type to text/plain */ 818 /* we set this type to text/plain */
819 target_part->setLines(which->bd_lines); 819 target_part->setLines(which->bd_lines);
820 fillBodyFields(target_part,which->bd_fields); 820 fillBodyFields(target_part,which->bd_fields);
821} 821}
822 822
823void IMAPwrapper::fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which) 823void IMAPwrapper::fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which)
824{ 824{
825 if (!which) return; 825 if (!which) return;
826 QString sub = which->bd_media_subtype; 826 QString sub = which->bd_media_subtype;
827 target_part->setSubtype(sub.lower()); 827 target_part->setSubtype(sub.lower());
828 if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) { 828 if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) {
829 clistcell*cur = 0; 829 clistcell*cur = 0;
830 mailimap_single_body_fld_param*param=0; 830 mailimap_single_body_fld_param*param=0;
831 for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { 831 for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) {
832 param = (mailimap_single_body_fld_param*)cur->data; 832 param = (mailimap_single_body_fld_param*)cur->data;
833 if (param) { 833 if (param) {
834 target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); 834 target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
835 } 835 }
836 } 836 }
837 } 837 }
838} 838}
839 839
840void IMAPwrapper::fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_basic*which) 840void IMAPwrapper::fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_basic*which)
841{ 841{
842 if (!which) { 842 if (!which) {
843 return; 843 return;
844 } 844 }
845 QString type,sub; 845 QString type,sub;
846 switch (which->bd_media_basic->med_type) { 846 switch (which->bd_media_basic->med_type) {
847 case MAILIMAP_MEDIA_BASIC_APPLICATION: 847 case MAILIMAP_MEDIA_BASIC_APPLICATION:
848 type = "application"; 848 type = "application";
849 break; 849 break;
850 case MAILIMAP_MEDIA_BASIC_AUDIO: 850 case MAILIMAP_MEDIA_BASIC_AUDIO:
851 type = "audio"; 851 type = "audio";
852 break; 852 break;
853 case MAILIMAP_MEDIA_BASIC_IMAGE: 853 case MAILIMAP_MEDIA_BASIC_IMAGE:
854 type = "image"; 854 type = "image";
855 break; 855 break;
856 case MAILIMAP_MEDIA_BASIC_MESSAGE: 856 case MAILIMAP_MEDIA_BASIC_MESSAGE:
857 type = "message"; 857 type = "message";
858 break; 858 break;
859 case MAILIMAP_MEDIA_BASIC_VIDEO: 859 case MAILIMAP_MEDIA_BASIC_VIDEO:
860 type = "video"; 860 type = "video";
861 break; 861 break;
862 case MAILIMAP_MEDIA_BASIC_OTHER: 862 case MAILIMAP_MEDIA_BASIC_OTHER:
863 default: 863 default:
864 if (which->bd_media_basic->med_basic_type) { 864 if (which->bd_media_basic->med_basic_type) {
865 type = which->bd_media_basic->med_basic_type; 865 type = which->bd_media_basic->med_basic_type;
866 } else { 866 } else {
867 type = ""; 867 type = "";
868 } 868 }
869 break; 869 break;
870 } 870 }
871 if (which->bd_media_basic->med_subtype) { 871 if (which->bd_media_basic->med_subtype) {
872 sub = which->bd_media_basic->med_subtype; 872 sub = which->bd_media_basic->med_subtype;
873 } else { 873 } else {
874 sub = ""; 874 sub = "";
875 } 875 }
876 // odebug << "Type = " << type.latin1() << "/" << sub.latin1() << "" << oendl; 876 // odebug << "Type = " << type.latin1() << "/" << sub.latin1() << "" << oendl;
877 target_part->setType(type.lower()); 877 target_part->setType(type.lower());
878 target_part->setSubtype(sub.lower()); 878 target_part->setSubtype(sub.lower());
879 fillBodyFields(target_part,which->bd_fields); 879 fillBodyFields(target_part,which->bd_fields);
880} 880}
881 881
882void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which) 882void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which)
883{ 883{
884 if (!which) return; 884 if (!which) return;
885 if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) { 885 if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) {
886 clistcell*cur; 886 clistcell*cur;
887 mailimap_single_body_fld_param*param=0; 887 mailimap_single_body_fld_param*param=0;
888 for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { 888 for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) {
889 param = (mailimap_single_body_fld_param*)cur->data; 889 param = (mailimap_single_body_fld_param*)cur->data;
890 if (param) { 890 if (param) {
891 target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); 891 target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
892 } 892 }
893 } 893 }
894 } 894 }
895 mailimap_body_fld_enc*enc = which->bd_encoding; 895 mailimap_body_fld_enc*enc = which->bd_encoding;
896 QString encoding(""); 896 QString encoding("");
897 switch (enc->enc_type) { 897 switch (enc->enc_type) {
898 case MAILIMAP_BODY_FLD_ENC_7BIT: 898 case MAILIMAP_BODY_FLD_ENC_7BIT:
899 encoding = "7bit"; 899 encoding = "7bit";
900 break; 900 break;
901 case MAILIMAP_BODY_FLD_ENC_8BIT: 901 case MAILIMAP_BODY_FLD_ENC_8BIT:
902 encoding = "8bit"; 902 encoding = "8bit";
903 break; 903 break;
904 case MAILIMAP_BODY_FLD_ENC_BINARY: 904 case MAILIMAP_BODY_FLD_ENC_BINARY:
905 encoding="binary"; 905 encoding="binary";
906 break; 906 break;
907 case MAILIMAP_BODY_FLD_ENC_BASE64: 907 case MAILIMAP_BODY_FLD_ENC_BASE64:
908 encoding="base64"; 908 encoding="base64";
909 break; 909 break;
910 case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: 910 case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE:
911 encoding="quoted-printable"; 911 encoding="quoted-printable";
912 break; 912 break;
913 case MAILIMAP_BODY_FLD_ENC_OTHER: 913 case MAILIMAP_BODY_FLD_ENC_OTHER:
914 default: 914 default:
915 if (enc->enc_value) { 915 if (enc->enc_value) {
916 char*t=enc->enc_value; 916 char*t=enc->enc_value;
917 encoding=QString(enc->enc_value); 917 encoding=QString(enc->enc_value);
918 enc->enc_value=0L; 918 enc->enc_value=0L;
919 free(t); 919 free(t);
920 } 920 }
921 } 921 }
922 if (which->bd_description) { 922 if (which->bd_description) {
923 target_part->setDescription(QString(which->bd_description)); 923 target_part->setDescription(QString(which->bd_description));
924 } 924 }
925 target_part->setEncoding(encoding); 925 target_part->setEncoding(encoding);
926 target_part->setSize(which->bd_size); 926 target_part->setSize(which->bd_size);
927} 927}
928void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target) 928void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target)
929{ 929{
930 //#if 0 930 //#if 0
931 mailimap_flag_list*flist; 931 mailimap_flag_list*flist;
932 mailimap_set *set; 932 mailimap_set *set;
933 mailimap_store_att_flags * store_flags; 933 mailimap_store_att_flags * store_flags;
934 int err; 934 int err;
935 login(); 935 login();
936 //#endif 936 //#endif
937 if (!m_imap) { 937 if (!m_imap) {
938 return; 938 return;
939 } 939 }
940 int iii = 0; 940 int iii = 0;
941 int count = target.count(); 941 int count = target.count();
942 // qDebug("imap remove count %d ", count); 942 // qDebug("imap remove count %d ", count);
943 943
944 944
945 mMax = count; 945 mMax = count;
946 //progress( tr("Delete")); 946 //progress( tr("Delete"));
947 QWidget wid; 947
948 QProgressBar wid ( count );
949 wid.setCaption( tr("Deleting ..."));
948 wid.show(); 950 wid.show();
949 while (iii < count ) { 951 while (iii < count ) {
950 Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count)); 952 Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count));
953 wid.setProgress( iii );
951 wid.raise(); 954 wid.raise();
952 qApp->processEvents(); 955 qApp->processEvents();
953 RecMailP mail = (*target.at( iii )); 956 RecMailP mail = (*target.at( iii ));
954 //#if 0 957 //#if 0
955 //qDebug("IMAP remove %d %d ", iii, mail->getNumber() ); 958 //qDebug("IMAP remove %d %d ", iii, mail->getNumber() );
956 err = selectMbox(mail->getMbox()); 959 err = selectMbox(mail->getMbox());
957 if ( err != MAILIMAP_NO_ERROR ) { 960 if ( err != MAILIMAP_NO_ERROR ) {
958 return; 961 return;
959 } 962 }
960 flist = mailimap_flag_list_new_empty(); 963 flist = mailimap_flag_list_new_empty();
961 mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); 964 mailimap_flag_list_add(flist,mailimap_flag_new_deleted());
962 store_flags = mailimap_store_att_flags_new_set_flags(flist); 965 store_flags = mailimap_store_att_flags_new_set_flags(flist);
963 set = mailimap_set_new_single(mail->getNumber()); 966 set = mailimap_set_new_single(mail->getNumber());
964 err = mailimap_store(m_imap,set,store_flags); 967 err = mailimap_store(m_imap,set,store_flags);
965 mailimap_set_free( set ); 968 mailimap_set_free( set );
966 mailimap_store_att_flags_free(store_flags); 969 mailimap_store_att_flags_free(store_flags);
967 970
968 if (err != MAILIMAP_NO_ERROR) { 971 if (err != MAILIMAP_NO_ERROR) {
969 // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; 972 // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl;
970 return; 973 return;
971 } 974 }
972 // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; 975 // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl;
973 /* should we realy do that at this moment? */ 976 /* should we realy do that at this moment? */
974 977
975 // err = mailimap_expunge(m_imap); 978 // err = mailimap_expunge(m_imap);
976 //if (err != MAILIMAP_NO_ERROR) { 979 //if (err != MAILIMAP_NO_ERROR) {
977 // Global::statusMessage(tr("Error deleting mails: %s").arg(m_imap->imap_response)); 980 // Global::statusMessage(tr("Error deleting mails: %s").arg(m_imap->imap_response));
978 // } 981 // }
979 //#endif 982 //#endif
980 //deleteMail( mail); 983 //deleteMail( mail);
981 ++iii; 984 ++iii;
982 } 985 }
983 //qDebug("Deleting imap mails... "); 986 //qDebug("Deleting imap mails... ");
984 err = mailimap_expunge(m_imap); 987 err = mailimap_expunge(m_imap);
985 if (err != MAILIMAP_NO_ERROR) { 988 if (err != MAILIMAP_NO_ERROR) {
986 Global::statusMessage(tr("Error deleting mails: %s").arg(m_imap->imap_response)); 989 Global::statusMessage(tr("Error deleting mails: %s").arg(m_imap->imap_response));
987 } 990 }
988} 991}
989void IMAPwrapper::deleteMail(const RecMailP&mail) 992void IMAPwrapper::deleteMail(const RecMailP&mail)
990{ 993{
991 mailimap_flag_list*flist; 994 mailimap_flag_list*flist;
992 mailimap_set *set; 995 mailimap_set *set;
993 mailimap_store_att_flags * store_flags; 996 mailimap_store_att_flags * store_flags;
994 int err; 997 int err;
995 login(); 998 login();
996 if (!m_imap) { 999 if (!m_imap) {
997 return; 1000 return;
998 } 1001 }
999 err = selectMbox(mail->getMbox()); 1002 err = selectMbox(mail->getMbox());
1000 if ( err != MAILIMAP_NO_ERROR ) { 1003 if ( err != MAILIMAP_NO_ERROR ) {
1001 return; 1004 return;
1002 } 1005 }
1003 flist = mailimap_flag_list_new_empty(); 1006 flist = mailimap_flag_list_new_empty();
1004 mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); 1007 mailimap_flag_list_add(flist,mailimap_flag_new_deleted());
1005 store_flags = mailimap_store_att_flags_new_set_flags(flist); 1008 store_flags = mailimap_store_att_flags_new_set_flags(flist);
1006 set = mailimap_set_new_single(mail->getNumber()); 1009 set = mailimap_set_new_single(mail->getNumber());
1007 err = mailimap_store(m_imap,set,store_flags); 1010 err = mailimap_store(m_imap,set,store_flags);
1008 mailimap_set_free( set ); 1011 mailimap_set_free( set );
1009 mailimap_store_att_flags_free(store_flags); 1012 mailimap_store_att_flags_free(store_flags);
1010 1013
1011 if (err != MAILIMAP_NO_ERROR) { 1014 if (err != MAILIMAP_NO_ERROR) {
1012 // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; 1015 // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl;
1013 return; 1016 return;
1014 } 1017 }
1015 // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; 1018 // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl;
1016 /* should we realy do that at this moment? */ 1019 /* should we realy do that at this moment? */
1017 1020
1018 err = mailimap_expunge(m_imap); 1021 err = mailimap_expunge(m_imap);
1019 if (err != MAILIMAP_NO_ERROR) { 1022 if (err != MAILIMAP_NO_ERROR) {
1020 Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); 1023 Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response));
1021 } 1024 }
1022 //qDebug("IMAPwrapper::deleteMail 2"); 1025 //qDebug("IMAPwrapper::deleteMail 2");
1023 1026
1024} 1027}
1025 1028
1026void IMAPwrapper::answeredMail(const RecMailP&mail) 1029void IMAPwrapper::answeredMail(const RecMailP&mail)
1027{ 1030{
1028 mailimap_flag_list*flist; 1031 mailimap_flag_list*flist;
1029 mailimap_set *set; 1032 mailimap_set *set;
1030 mailimap_store_att_flags * store_flags; 1033 mailimap_store_att_flags * store_flags;
1031 int err; 1034 int err;
1032 login(); 1035 login();
1033 if (!m_imap) { 1036 if (!m_imap) {
1034 return; 1037 return;
1035 } 1038 }
1036 err = selectMbox(mail->getMbox()); 1039 err = selectMbox(mail->getMbox());
1037 if ( err != MAILIMAP_NO_ERROR ) { 1040 if ( err != MAILIMAP_NO_ERROR ) {
1038 return; 1041 return;
1039 } 1042 }
1040 flist = mailimap_flag_list_new_empty(); 1043 flist = mailimap_flag_list_new_empty();
1041 mailimap_flag_list_add(flist,mailimap_flag_new_answered()); 1044 mailimap_flag_list_add(flist,mailimap_flag_new_answered());
1042 store_flags = mailimap_store_att_flags_new_add_flags(flist); 1045 store_flags = mailimap_store_att_flags_new_add_flags(flist);
1043 set = mailimap_set_new_single(mail->getNumber()); 1046 set = mailimap_set_new_single(mail->getNumber());
1044 err = mailimap_store(m_imap,set,store_flags); 1047 err = mailimap_store(m_imap,set,store_flags);
1045 mailimap_set_free( set ); 1048 mailimap_set_free( set );
1046 mailimap_store_att_flags_free(store_flags); 1049 mailimap_store_att_flags_free(store_flags);
1047 1050
1048 if (err != MAILIMAP_NO_ERROR) { 1051 if (err != MAILIMAP_NO_ERROR) {
1049 // odebug << "error marking mail: " << m_imap->imap_response << "" << oendl; 1052 // odebug << "error marking mail: " << m_imap->imap_response << "" << oendl;
1050 return; 1053 return;
1051 } 1054 }
1052} 1055}
1053 1056
1054QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call,const QString&enc) 1057QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call,const QString&enc)
1055{ 1058{
1056 QString body(""); 1059 QString body("");
1057 encodedString*res = fetchRawPart(mail,path,internal_call); 1060 encodedString*res = fetchRawPart(mail,path,internal_call);
1058 encodedString*r = decode_String(res,enc); 1061 encodedString*r = decode_String(res,enc);
1059 delete res; 1062 delete res;
1060 if (r) { 1063 if (r) {
1061 if (r->Length()>0) { 1064 if (r->Length()>0) {
1062 body = r->Content(); 1065 body = r->Content();
1063 } 1066 }
1064 delete r; 1067 delete r;
1065 } 1068 }
1066 return body; 1069 return body;
1067} 1070}
1068 1071
1069QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part) 1072QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part)
1070{ 1073{
1071 return fetchTextPart(mail,part->Positionlist(),false,part->Encoding()); 1074 return fetchTextPart(mail,part->Positionlist(),false,part->Encoding());
1072} 1075}
1073 1076
1074encodedString* IMAPwrapper::fetchDecodedPart(const RecMailP&mail,const RecPartP&part) 1077encodedString* IMAPwrapper::fetchDecodedPart(const RecMailP&mail,const RecPartP&part)
1075{ 1078{
1076 encodedString*res = fetchRawPart(mail,part->Positionlist(),false); 1079 encodedString*res = fetchRawPart(mail,part->Positionlist(),false);
1077 encodedString*r = decode_String(res,part->Encoding()); 1080 encodedString*r = decode_String(res,part->Encoding());
1078 delete res; 1081 delete res;
1079 return r; 1082 return r;
1080} 1083}
1081 1084
1082encodedString* IMAPwrapper::fetchRawPart(const RecMailP&mail,const RecPartP&part) 1085encodedString* IMAPwrapper::fetchRawPart(const RecMailP&mail,const RecPartP&part)
1083{ 1086{
1084 return fetchRawPart(mail,part->Positionlist(),false); 1087 return fetchRawPart(mail,part->Positionlist(),false);
1085} 1088}
1086 1089
1087int IMAPwrapper::deleteAllMail(const FolderP&folder) 1090int IMAPwrapper::deleteAllMail(const FolderP&folder)
1088{ 1091{
1089 login(); 1092 login();
1090 if (!m_imap) { 1093 if (!m_imap) {
1091 return 0; 1094 return 0;
1092 } 1095 }
1093 mailimap_flag_list*flist; 1096 mailimap_flag_list*flist;
1094 mailimap_set *set; 1097 mailimap_set *set;
1095 mailimap_store_att_flags * store_flags; 1098 mailimap_store_att_flags * store_flags;
1096 int err = selectMbox(folder->getName()); 1099 int err = selectMbox(folder->getName());
1097 if ( err != MAILIMAP_NO_ERROR ) { 1100 if ( err != MAILIMAP_NO_ERROR ) {
1098 return 0; 1101 return 0;
1099 } 1102 }
1100 1103
1101 int last = m_imap->imap_selection_info->sel_exists; 1104 int last = m_imap->imap_selection_info->sel_exists;
1102 if (last == 0) { 1105 if (last == 0) {
1103 Global::statusMessage(tr("Mailbox has no mails!")); 1106 Global::statusMessage(tr("Mailbox has no mails!"));
1104 return 0; 1107 return 0;
1105 } 1108 }
1106 flist = mailimap_flag_list_new_empty(); 1109 flist = mailimap_flag_list_new_empty();
1107 mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); 1110 mailimap_flag_list_add(flist,mailimap_flag_new_deleted());
1108 store_flags = mailimap_store_att_flags_new_set_flags(flist); 1111 store_flags = mailimap_store_att_flags_new_set_flags(flist);
1109 set = mailimap_set_new_interval( 1, last ); 1112 set = mailimap_set_new_interval( 1, last );
1110 err = mailimap_store(m_imap,set,store_flags); 1113 err = mailimap_store(m_imap,set,store_flags);
1111 mailimap_set_free( set ); 1114 mailimap_set_free( set );
1112 mailimap_store_att_flags_free(store_flags); 1115 mailimap_store_att_flags_free(store_flags);
1113 if (err != MAILIMAP_NO_ERROR) { 1116 if (err != MAILIMAP_NO_ERROR) {
1114 Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); 1117 Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response));
1115 return 0; 1118 return 0;
1116 } 1119 }
1117 // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; 1120 // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl;
1118 /* should we realy do that at this moment? */ 1121 /* should we realy do that at this moment? */
1119 err = mailimap_expunge(m_imap); 1122 err = mailimap_expunge(m_imap);
1120 if (err != MAILIMAP_NO_ERROR) { 1123 if (err != MAILIMAP_NO_ERROR) {
1121 Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); 1124 Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response));
1122 return 0; 1125 return 0;
1123 } 1126 }
1124 // odebug << "Delete successfull " << m_imap->imap_response << "" << oendl; 1127 // odebug << "Delete successfull " << m_imap->imap_response << "" << oendl;
1125 return 1; 1128 return 1;
1126} 1129}
1127 1130
1128int IMAPwrapper::createMbox(const QString&folder,const FolderP&parentfolder,const QString& delemiter,bool getsubfolder) 1131int IMAPwrapper::createMbox(const QString&folder,const FolderP&parentfolder,const QString& delemiter,bool getsubfolder)
1129{ 1132{
1130 if (folder.length()==0) return 0; 1133 if (folder.length()==0) return 0;
1131 login(); 1134 login();
1132 if (!m_imap) {return 0;} 1135 if (!m_imap) {return 0;}
1133 QString pre = account->getPrefix(); 1136 QString pre = account->getPrefix();
1134 if (delemiter.length()>0 && pre.findRev(delemiter)!=pre.length()-1) { 1137 if (delemiter.length()>0 && pre.findRev(delemiter)!=pre.length()-1) {
1135 pre+=delemiter; 1138 pre+=delemiter;
1136 } 1139 }
1137 if (parentfolder) { 1140 if (parentfolder) {
1138 pre += parentfolder->getDisplayName()+delemiter; 1141 pre += parentfolder->getDisplayName()+delemiter;
1139 } 1142 }
1140 pre+=folder; 1143 pre+=folder;
1141 if (getsubfolder) { 1144 if (getsubfolder) {
1142 if (delemiter.length()>0) { 1145 if (delemiter.length()>0) {