Diffstat (limited to 'noncore/net/mail/libmailwrapper/imapwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 49 |
1 files changed, 24 insertions, 25 deletions
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index 3b3be0f..071e734 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp | |||
@@ -202,13 +202,13 @@ void IMAPwrapper::logout() | |||
202 | err = mailimap_close( m_imap ); | 202 | err = mailimap_close( m_imap ); |
203 | mailimap_free( m_imap ); | 203 | mailimap_free( m_imap ); |
204 | m_imap = 0; | 204 | m_imap = 0; |
205 | m_Lastmbox = ""; | 205 | m_Lastmbox = ""; |
206 | } | 206 | } |
207 | 207 | ||
208 | void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) | 208 | void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::OSmartPointer<RecMail> > &target ) |
209 | { | 209 | { |
210 | int err = MAILIMAP_NO_ERROR; | 210 | int err = MAILIMAP_NO_ERROR; |
211 | clist *result = 0; | 211 | clist *result = 0; |
212 | clistcell *current; | 212 | clistcell *current; |
213 | mailimap_fetch_type *fetchType = 0; | 213 | mailimap_fetch_type *fetchType = 0; |
214 | mailimap_set *set = 0; | 214 | mailimap_set *set = 0; |
@@ -263,13 +263,13 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) | |||
263 | } else { | 263 | } else { |
264 | Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response)); | 264 | Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response)); |
265 | } | 265 | } |
266 | if (result) mailimap_fetch_list_free(result); | 266 | if (result) mailimap_fetch_list_free(result); |
267 | } | 267 | } |
268 | 268 | ||
269 | QValueList<Opie::osmart_pointer<Folder> >* IMAPwrapper::listFolders() | 269 | QValueList<Opie::OSmartPointer<Folder> >* IMAPwrapper::listFolders() |
270 | { | 270 | { |
271 | const char *path, *mask; | 271 | const char *path, *mask; |
272 | int err = MAILIMAP_NO_ERROR; | 272 | int err = MAILIMAP_NO_ERROR; |
273 | clist *result = 0; | 273 | clist *result = 0; |
274 | clistcell *current = 0; | 274 | clistcell *current = 0; |
275 | clistcell*cur_flag = 0; | 275 | clistcell*cur_flag = 0; |
@@ -479,37 +479,37 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
479 | m->setFlags(mFlags); | 479 | m->setFlags(mFlags); |
480 | m->setMsgsize(size); | 480 | m->setMsgsize(size); |
481 | } | 481 | } |
482 | return m; | 482 | return m; |
483 | } | 483 | } |
484 | 484 | ||
485 | RecBody IMAPwrapper::fetchBody(const RecMail&mail) | 485 | RecBody IMAPwrapper::fetchBody(const RecMailP&mail) |
486 | { | 486 | { |
487 | RecBody body; | 487 | RecBody body; |
488 | const char *mb; | 488 | const char *mb; |
489 | int err = MAILIMAP_NO_ERROR; | 489 | int err = MAILIMAP_NO_ERROR; |
490 | clist *result = 0; | 490 | clist *result = 0; |
491 | clistcell *current; | 491 | clistcell *current; |
492 | mailimap_fetch_att *fetchAtt = 0; | 492 | mailimap_fetch_att *fetchAtt = 0; |
493 | mailimap_fetch_type *fetchType = 0; | 493 | mailimap_fetch_type *fetchType = 0; |
494 | mailimap_set *set = 0; | 494 | mailimap_set *set = 0; |
495 | mailimap_body*body_desc = 0; | 495 | mailimap_body*body_desc = 0; |
496 | 496 | ||
497 | mb = mail.getMbox().latin1(); | 497 | mb = mail->getMbox().latin1(); |
498 | 498 | ||
499 | login(); | 499 | login(); |
500 | if (!m_imap) { | 500 | if (!m_imap) { |
501 | return body; | 501 | return body; |
502 | } | 502 | } |
503 | err = selectMbox(mail.getMbox()); | 503 | err = selectMbox(mail->getMbox()); |
504 | if ( err != MAILIMAP_NO_ERROR ) { | 504 | if ( err != MAILIMAP_NO_ERROR ) { |
505 | return body; | 505 | return body; |
506 | } | 506 | } |
507 | 507 | ||
508 | /* the range has to start at 1!!! not with 0!!!! */ | 508 | /* the range has to start at 1!!! not with 0!!!! */ |
509 | set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() ); | 509 | set = mailimap_set_new_interval( mail->getNumber(),mail->getNumber() ); |
510 | fetchAtt = mailimap_fetch_att_new_bodystructure(); | 510 | fetchAtt = mailimap_fetch_att_new_bodystructure(); |
511 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); | 511 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); |
512 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 512 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
513 | mailimap_set_free( set ); | 513 | mailimap_set_free( set ); |
514 | mailimap_fetch_type_free( fetchType ); | 514 | mailimap_fetch_type_free( fetchType ); |
515 | 515 | ||
@@ -565,13 +565,13 @@ QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | |||
565 | break; | 565 | break; |
566 | } | 566 | } |
567 | } | 567 | } |
568 | return l; | 568 | return l; |
569 | } | 569 | } |
570 | 570 | ||
571 | encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call) | 571 | encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call) |
572 | { | 572 | { |
573 | encodedString*res=new encodedString; | 573 | encodedString*res=new encodedString; |
574 | int err; | 574 | int err; |
575 | mailimap_fetch_type *fetchType; | 575 | mailimap_fetch_type *fetchType; |
576 | mailimap_set *set; | 576 | mailimap_set *set; |
577 | clistcell*current,*cur; | 577 | clistcell*current,*cur; |
@@ -582,18 +582,18 @@ encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int> | |||
582 | 582 | ||
583 | login(); | 583 | login(); |
584 | if (!m_imap) { | 584 | if (!m_imap) { |
585 | return res; | 585 | return res; |
586 | } | 586 | } |
587 | if (!internal_call) { | 587 | if (!internal_call) { |
588 | err = selectMbox(mail.getMbox()); | 588 | err = selectMbox(mail->getMbox()); |
589 | if ( err != MAILIMAP_NO_ERROR ) { | 589 | if ( err != MAILIMAP_NO_ERROR ) { |
590 | return res; | 590 | return res; |
591 | } | 591 | } |
592 | } | 592 | } |
593 | set = mailimap_set_new_single(mail.getNumber()); | 593 | set = mailimap_set_new_single(mail->getNumber()); |
594 | 594 | ||
595 | clist*id_list = 0; | 595 | clist*id_list = 0; |
596 | 596 | ||
597 | /* if path == empty then its a request for the whole rfc822 mail and generates | 597 | /* if path == empty then its a request for the whole rfc822 mail and generates |
598 | a "fetch <id> (body[])" statement on imap server */ | 598 | a "fetch <id> (body[])" statement on imap server */ |
599 | if (path.count()>0 ) { | 599 | if (path.count()>0 ) { |
@@ -638,13 +638,13 @@ encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int> | |||
638 | if (result) mailimap_fetch_list_free(result); | 638 | if (result) mailimap_fetch_list_free(result); |
639 | return res; | 639 | return res; |
640 | } | 640 | } |
641 | 641 | ||
642 | /* current_recursion is for recursive calls. | 642 | /* current_recursion is for recursive calls. |
643 | current_count means the position inside the internal loop! */ | 643 | current_count means the position inside the internal loop! */ |
644 | void IMAPwrapper::traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body, | 644 | void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBody&target_body, |
645 | int current_recursion,QValueList<int>recList,int current_count) | 645 | int current_recursion,QValueList<int>recList,int current_count) |
646 | { | 646 | { |
647 | if (!body || current_recursion>=10) { | 647 | if (!body || current_recursion>=10) { |
648 | return; | 648 | return; |
649 | } | 649 | } |
650 | switch (body->bd_type) { | 650 | switch (body->bd_type) { |
@@ -866,30 +866,30 @@ void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which) | |||
866 | target_part.setDescription(QString(which->bd_description)); | 866 | target_part.setDescription(QString(which->bd_description)); |
867 | } | 867 | } |
868 | target_part.setEncoding(encoding); | 868 | target_part.setEncoding(encoding); |
869 | target_part.setSize(which->bd_size); | 869 | target_part.setSize(which->bd_size); |
870 | } | 870 | } |
871 | 871 | ||
872 | void IMAPwrapper::deleteMail(const RecMail&mail) | 872 | void IMAPwrapper::deleteMail(const RecMailP&mail) |
873 | { | 873 | { |
874 | mailimap_flag_list*flist; | 874 | mailimap_flag_list*flist; |
875 | mailimap_set *set; | 875 | mailimap_set *set; |
876 | mailimap_store_att_flags * store_flags; | 876 | mailimap_store_att_flags * store_flags; |
877 | int err; | 877 | int err; |
878 | login(); | 878 | login(); |
879 | if (!m_imap) { | 879 | if (!m_imap) { |
880 | return; | 880 | return; |
881 | } | 881 | } |
882 | err = selectMbox(mail.getMbox()); | 882 | err = selectMbox(mail->getMbox()); |
883 | if ( err != MAILIMAP_NO_ERROR ) { | 883 | if ( err != MAILIMAP_NO_ERROR ) { |
884 | return; | 884 | return; |
885 | } | 885 | } |
886 | flist = mailimap_flag_list_new_empty(); | 886 | flist = mailimap_flag_list_new_empty(); |
887 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 887 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
888 | store_flags = mailimap_store_att_flags_new_set_flags(flist); | 888 | store_flags = mailimap_store_att_flags_new_set_flags(flist); |
889 | set = mailimap_set_new_single(mail.getNumber()); | 889 | set = mailimap_set_new_single(mail->getNumber()); |
890 | err = mailimap_store(m_imap,set,store_flags); | 890 | err = mailimap_store(m_imap,set,store_flags); |
891 | mailimap_set_free( set ); | 891 | mailimap_set_free( set ); |
892 | mailimap_store_att_flags_free(store_flags); | 892 | mailimap_store_att_flags_free(store_flags); |
893 | 893 | ||
894 | if (err != MAILIMAP_NO_ERROR) { | 894 | if (err != MAILIMAP_NO_ERROR) { |
895 | qDebug("error deleting mail: %s",m_imap->imap_response); | 895 | qDebug("error deleting mail: %s",m_imap->imap_response); |
@@ -901,41 +901,41 @@ void IMAPwrapper::deleteMail(const RecMail&mail) | |||
901 | if (err != MAILIMAP_NO_ERROR) { | 901 | if (err != MAILIMAP_NO_ERROR) { |
902 | qDebug("error deleting mail: %s",m_imap->imap_response); | 902 | qDebug("error deleting mail: %s",m_imap->imap_response); |
903 | } | 903 | } |
904 | qDebug("Delete successfull %s",m_imap->imap_response); | 904 | qDebug("Delete successfull %s",m_imap->imap_response); |
905 | } | 905 | } |
906 | 906 | ||
907 | void IMAPwrapper::answeredMail(const RecMail&mail) | 907 | void IMAPwrapper::answeredMail(const RecMailP&mail) |
908 | { | 908 | { |
909 | mailimap_flag_list*flist; | 909 | mailimap_flag_list*flist; |
910 | mailimap_set *set; | 910 | mailimap_set *set; |
911 | mailimap_store_att_flags * store_flags; | 911 | mailimap_store_att_flags * store_flags; |
912 | int err; | 912 | int err; |
913 | login(); | 913 | login(); |
914 | if (!m_imap) { | 914 | if (!m_imap) { |
915 | return; | 915 | return; |
916 | } | 916 | } |
917 | err = selectMbox(mail.getMbox()); | 917 | err = selectMbox(mail->getMbox()); |
918 | if ( err != MAILIMAP_NO_ERROR ) { | 918 | if ( err != MAILIMAP_NO_ERROR ) { |
919 | return; | 919 | return; |
920 | } | 920 | } |
921 | flist = mailimap_flag_list_new_empty(); | 921 | flist = mailimap_flag_list_new_empty(); |
922 | mailimap_flag_list_add(flist,mailimap_flag_new_answered()); | 922 | mailimap_flag_list_add(flist,mailimap_flag_new_answered()); |
923 | store_flags = mailimap_store_att_flags_new_add_flags(flist); | 923 | store_flags = mailimap_store_att_flags_new_add_flags(flist); |
924 | set = mailimap_set_new_single(mail.getNumber()); | 924 | set = mailimap_set_new_single(mail->getNumber()); |
925 | err = mailimap_store(m_imap,set,store_flags); | 925 | err = mailimap_store(m_imap,set,store_flags); |
926 | mailimap_set_free( set ); | 926 | mailimap_set_free( set ); |
927 | mailimap_store_att_flags_free(store_flags); | 927 | mailimap_store_att_flags_free(store_flags); |
928 | 928 | ||
929 | if (err != MAILIMAP_NO_ERROR) { | 929 | if (err != MAILIMAP_NO_ERROR) { |
930 | qDebug("error marking mail: %s",m_imap->imap_response); | 930 | qDebug("error marking mail: %s",m_imap->imap_response); |
931 | return; | 931 | return; |
932 | } | 932 | } |
933 | } | 933 | } |
934 | 934 | ||
935 | QString IMAPwrapper::fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call,const QString&enc) | 935 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call,const QString&enc) |
936 | { | 936 | { |
937 | QString body(""); | 937 | QString body(""); |
938 | encodedString*res = fetchRawPart(mail,path,internal_call); | 938 | encodedString*res = fetchRawPart(mail,path,internal_call); |
939 | encodedString*r = decode_String(res,enc); | 939 | encodedString*r = decode_String(res,enc); |
940 | delete res; | 940 | delete res; |
941 | if (r) { | 941 | if (r) { |
@@ -944,26 +944,26 @@ QString IMAPwrapper::fetchTextPart(const RecMail&mail,const QValueList<int>&path | |||
944 | } | 944 | } |
945 | delete r; | 945 | delete r; |
946 | } | 946 | } |
947 | return body; | 947 | return body; |
948 | } | 948 | } |
949 | 949 | ||
950 | QString IMAPwrapper::fetchTextPart(const RecMail&mail,const RecPart&part) | 950 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const RecPart&part) |
951 | { | 951 | { |
952 | return fetchTextPart(mail,part.Positionlist(),false,part.Encoding()); | 952 | return fetchTextPart(mail,part.Positionlist(),false,part.Encoding()); |
953 | } | 953 | } |
954 | 954 | ||
955 | encodedString* IMAPwrapper::fetchDecodedPart(const RecMail&mail,const RecPart&part) | 955 | encodedString* IMAPwrapper::fetchDecodedPart(const RecMailP&mail,const RecPart&part) |
956 | { | 956 | { |
957 | encodedString*res = fetchRawPart(mail,part.Positionlist(),false); | 957 | encodedString*res = fetchRawPart(mail,part.Positionlist(),false); |
958 | encodedString*r = decode_String(res,part.Encoding()); | 958 | encodedString*r = decode_String(res,part.Encoding()); |
959 | delete res; | 959 | delete res; |
960 | return r; | 960 | return r; |
961 | } | 961 | } |
962 | 962 | ||
963 | encodedString* IMAPwrapper::fetchRawPart(const RecMail&mail,const RecPart&part) | 963 | encodedString* IMAPwrapper::fetchRawPart(const RecMailP&mail,const RecPart&part) |
964 | { | 964 | { |
965 | return fetchRawPart(mail,part.Positionlist(),false); | 965 | return fetchRawPart(mail,part.Positionlist(),false); |
966 | } | 966 | } |
967 | 967 | ||
968 | int IMAPwrapper::deleteAllMail(const FolderP&folder) | 968 | int IMAPwrapper::deleteAllMail(const FolderP&folder) |
969 | { | 969 | { |
@@ -1052,13 +1052,12 @@ int IMAPwrapper::deleteMbox(const FolderP&folder) | |||
1052 | void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) | 1052 | void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) |
1053 | { | 1053 | { |
1054 | mailimap_status_att_list * att_list =0; | 1054 | mailimap_status_att_list * att_list =0; |
1055 | mailimap_mailbox_data_status * status=0; | 1055 | mailimap_mailbox_data_status * status=0; |
1056 | clistiter * cur = 0; | 1056 | clistiter * cur = 0; |
1057 | int r = 0; | 1057 | int r = 0; |
1058 | int res = 0; | ||
1059 | target_stat.message_count = 0; | 1058 | target_stat.message_count = 0; |
1060 | target_stat.message_unseen = 0; | 1059 | target_stat.message_unseen = 0; |
1061 | target_stat.message_recent = 0; | 1060 | target_stat.message_recent = 0; |
1062 | login(); | 1061 | login(); |
1063 | if (!m_imap) { | 1062 | if (!m_imap) { |
1064 | return; | 1063 | return; |
@@ -1112,13 +1111,13 @@ MAILLIB::ATYPE IMAPwrapper::getType()const | |||
1112 | const QString&IMAPwrapper::getName()const | 1111 | const QString&IMAPwrapper::getName()const |
1113 | { | 1112 | { |
1114 | qDebug("Get name: %s",account->getAccountName().latin1()); | 1113 | qDebug("Get name: %s",account->getAccountName().latin1()); |
1115 | return account->getAccountName(); | 1114 | return account->getAccountName(); |
1116 | } | 1115 | } |
1117 | 1116 | ||
1118 | encodedString* IMAPwrapper::fetchRawBody(const RecMail&mail) | 1117 | encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail) |
1119 | { | 1118 | { |
1120 | // dummy | 1119 | // dummy |
1121 | QValueList<int> path; | 1120 | QValueList<int> path; |
1122 | return fetchRawPart(mail,path,false); | 1121 | return fetchRawPart(mail,path,false); |
1123 | } | 1122 | } |
1124 | 1123 | ||
@@ -1151,29 +1150,29 @@ void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, | |||
1151 | } | 1150 | } |
1152 | if (moveit) { | 1151 | if (moveit) { |
1153 | deleteAllMail(fromFolder); | 1152 | deleteAllMail(fromFolder); |
1154 | } | 1153 | } |
1155 | } | 1154 | } |
1156 | 1155 | ||
1157 | void IMAPwrapper::mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 1156 | void IMAPwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
1158 | { | 1157 | { |
1159 | if (targetWrapper != this) { | 1158 | if (targetWrapper != this) { |
1160 | qDebug("Using generic"); | 1159 | qDebug("Using generic"); |
1161 | AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit); | 1160 | AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit); |
1162 | return; | 1161 | return; |
1163 | } | 1162 | } |
1164 | mailimap_set *set = 0; | 1163 | mailimap_set *set = 0; |
1165 | login(); | 1164 | login(); |
1166 | if (!m_imap) { | 1165 | if (!m_imap) { |
1167 | return; | 1166 | return; |
1168 | } | 1167 | } |
1169 | int err = selectMbox(mail.getMbox()); | 1168 | int err = selectMbox(mail->getMbox()); |
1170 | if ( err != MAILIMAP_NO_ERROR ) { | 1169 | if ( err != MAILIMAP_NO_ERROR ) { |
1171 | return; | 1170 | return; |
1172 | } | 1171 | } |
1173 | set = mailimap_set_new_single(mail.getNumber()); | 1172 | set = mailimap_set_new_single(mail->getNumber()); |
1174 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); | 1173 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); |
1175 | mailimap_set_free( set ); | 1174 | mailimap_set_free( set ); |
1176 | if ( err != MAILIMAP_NO_ERROR ) { | 1175 | if ( err != MAILIMAP_NO_ERROR ) { |
1177 | QString error_msg = tr("error copy mail: %1").arg(m_imap->imap_response); | 1176 | QString error_msg = tr("error copy mail: %1").arg(m_imap->imap_response); |
1178 | Global::statusMessage(error_msg); | 1177 | Global::statusMessage(error_msg); |
1179 | qDebug(error_msg); | 1178 | qDebug(error_msg); |