Diffstat (limited to 'kmicromail/libmailwrapper/imapwrapper.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | kmicromail/libmailwrapper/imapwrapper.cpp | 46 |
1 files changed, 38 insertions, 8 deletions
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp index bb8bbfc..11d3343 100644 --- a/kmicromail/libmailwrapper/imapwrapper.cpp +++ b/kmicromail/libmailwrapper/imapwrapper.cpp | |||
@@ -1,20 +1,21 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include <libetpan/libetpan.h> | 3 | #include <libetpan/libetpan.h> |
4 | #include <qpe/global.h> | 4 | #include <qpe/global.h> |
5 | #include <qapplication.h> | 5 | #include <qapplication.h> |
6 | #include "imapwrapper.h" | 6 | #include "imapwrapper.h" |
7 | #include "mailtypes.h" | 7 | #include "mailtypes.h" |
8 | #include "logindialog.h" | 8 | #include "logindialog.h" |
9 | #include <qprogressbar.h> | ||
9 | 10 | ||
10 | using namespace Opie::Core; | 11 | using namespace Opie::Core; |
11 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) | 12 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) |
12 | : AbstractMail() | 13 | : AbstractMail() |
13 | { | 14 | { |
14 | account = a; | 15 | account = a; |
15 | m_imap = 0; | 16 | m_imap = 0; |
16 | m_Lastmbox = ""; | 17 | m_Lastmbox = ""; |
17 | } | 18 | } |
18 | 19 | ||
19 | IMAPwrapper::~IMAPwrapper() | 20 | IMAPwrapper::~IMAPwrapper() |
20 | { | 21 | { |
@@ -862,63 +863,92 @@ void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which | |||
862 | enc->enc_value=0L; | 863 | enc->enc_value=0L; |
863 | free(t); | 864 | free(t); |
864 | } | 865 | } |
865 | } | 866 | } |
866 | if (which->bd_description) { | 867 | if (which->bd_description) { |
867 | target_part->setDescription(QString(which->bd_description)); | 868 | target_part->setDescription(QString(which->bd_description)); |
868 | } | 869 | } |
869 | target_part->setEncoding(encoding); | 870 | target_part->setEncoding(encoding); |
870 | target_part->setSize(which->bd_size); | 871 | target_part->setSize(which->bd_size); |
871 | } | 872 | } |
872 | void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target) | 873 | void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target) |
873 | { | 874 | { |
875 | //#if 0 | ||
874 | mailimap_flag_list*flist; | 876 | mailimap_flag_list*flist; |
875 | mailimap_set *set; | 877 | mailimap_set *set; |
876 | mailimap_store_att_flags * store_flags; | 878 | mailimap_store_att_flags * store_flags; |
877 | int err; | 879 | int err; |
878 | login(); | 880 | login(); |
881 | //#endif | ||
879 | if (!m_imap) { | 882 | if (!m_imap) { |
880 | return; | 883 | return; |
881 | } | 884 | } |
882 | int iii = 0; | 885 | int iii = 0; |
883 | int count = target.count(); | 886 | int count = target.count(); |
884 | qDebug("imap remove count %d ", count); | 887 | // qDebug("imap remove count %d ", count); |
888 | |||
889 | QProgressBar bar( count,0 ); | ||
890 | bar.setCaption (("Removing mails - close to abort!") ); | ||
891 | int w = 300; | ||
892 | if ( QApplication::desktop()->width() < 320 ) | ||
893 | w = 220; | ||
894 | int h = bar.sizeHint().height() ; | ||
895 | int dw = QApplication::desktop()->width(); | ||
896 | int dh = QApplication::desktop()->height(); | ||
897 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | ||
898 | bar.show(); | ||
899 | int modulo = (count/10)+1; | ||
900 | int incCounter = 0; | ||
901 | |||
885 | while (iii < count ) { | 902 | while (iii < count ) { |
886 | qDebug("IMAP remove %d ", iii); | 903 | if ( ! bar.isVisible() ) |
904 | return ; | ||
905 | if ( incCounter % modulo == 0 ) | ||
906 | bar.setProgress( incCounter ); | ||
907 | ++incCounter; | ||
908 | qApp->processEvents(); | ||
887 | RecMailP mail = (*target.at( iii )); | 909 | RecMailP mail = (*target.at( iii )); |
888 | 910 | //#if 0 | |
911 | //qDebug("IMAP remove %d %d ", iii, mail->getNumber() ); | ||
889 | err = selectMbox(mail->getMbox()); | 912 | err = selectMbox(mail->getMbox()); |
890 | if ( err != MAILIMAP_NO_ERROR ) { | 913 | if ( err != MAILIMAP_NO_ERROR ) { |
891 | return; | 914 | return; |
892 | } | 915 | } |
893 | flist = mailimap_flag_list_new_empty(); | 916 | flist = mailimap_flag_list_new_empty(); |
894 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 917 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
895 | store_flags = mailimap_store_att_flags_new_set_flags(flist); | 918 | store_flags = mailimap_store_att_flags_new_set_flags(flist); |
896 | set = mailimap_set_new_single(mail->getNumber()); | 919 | set = mailimap_set_new_single(mail->getNumber()); |
897 | err = mailimap_store(m_imap,set,store_flags); | 920 | err = mailimap_store(m_imap,set,store_flags); |
898 | mailimap_set_free( set ); | 921 | mailimap_set_free( set ); |
899 | mailimap_store_att_flags_free(store_flags); | 922 | mailimap_store_att_flags_free(store_flags); |
900 | 923 | ||
901 | if (err != MAILIMAP_NO_ERROR) { | 924 | if (err != MAILIMAP_NO_ERROR) { |
902 | // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; | 925 | // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; |
903 | return; | 926 | return; |
904 | } | 927 | } |
905 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; | 928 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; |
906 | /* should we realy do that at this moment? */ | 929 | /* should we realy do that at this moment? */ |
907 | 930 | ||
931 | // err = mailimap_expunge(m_imap); | ||
932 | //if (err != MAILIMAP_NO_ERROR) { | ||
933 | // Global::statusMessage(tr("Error deleting mails: %s").arg(m_imap->imap_response)); | ||
934 | // } | ||
935 | //#endif | ||
936 | //deleteMail( mail); | ||
937 | ++iii; | ||
938 | } | ||
939 | //qDebug("Deleting imap mails... "); | ||
908 | err = mailimap_expunge(m_imap); | 940 | err = mailimap_expunge(m_imap); |
909 | if (err != MAILIMAP_NO_ERROR) { | 941 | if (err != MAILIMAP_NO_ERROR) { |
910 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); | 942 | Global::statusMessage(tr("Error deleting mails: %s").arg(m_imap->imap_response)); |
911 | } | ||
912 | ++iii; | ||
913 | } | 943 | } |
914 | } | 944 | } |
915 | void IMAPwrapper::deleteMail(const RecMailP&mail) | 945 | void IMAPwrapper::deleteMail(const RecMailP&mail) |
916 | { | 946 | { |
917 | mailimap_flag_list*flist; | 947 | mailimap_flag_list*flist; |
918 | mailimap_set *set; | 948 | mailimap_set *set; |
919 | mailimap_store_att_flags * store_flags; | 949 | mailimap_store_att_flags * store_flags; |
920 | int err; | 950 | int err; |
921 | login(); | 951 | login(); |
922 | if (!m_imap) { | 952 | if (!m_imap) { |
923 | return; | 953 | return; |
924 | } | 954 | } |
@@ -936,25 +966,25 @@ void IMAPwrapper::deleteMail(const RecMailP&mail) | |||
936 | 966 | ||
937 | if (err != MAILIMAP_NO_ERROR) { | 967 | if (err != MAILIMAP_NO_ERROR) { |
938 | // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; | 968 | // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; |
939 | return; | 969 | return; |
940 | } | 970 | } |
941 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; | 971 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; |
942 | /* should we realy do that at this moment? */ | 972 | /* should we realy do that at this moment? */ |
943 | 973 | ||
944 | err = mailimap_expunge(m_imap); | 974 | err = mailimap_expunge(m_imap); |
945 | if (err != MAILIMAP_NO_ERROR) { | 975 | if (err != MAILIMAP_NO_ERROR) { |
946 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); | 976 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); |
947 | } | 977 | } |
948 | qDebug("IMAPwrapper::deleteMail "); | 978 | //qDebug("IMAPwrapper::deleteMail 2"); |
949 | 979 | ||
950 | } | 980 | } |
951 | 981 | ||
952 | void IMAPwrapper::answeredMail(const RecMailP&mail) | 982 | void IMAPwrapper::answeredMail(const RecMailP&mail) |
953 | { | 983 | { |
954 | mailimap_flag_list*flist; | 984 | mailimap_flag_list*flist; |
955 | mailimap_set *set; | 985 | mailimap_set *set; |
956 | mailimap_store_att_flags * store_flags; | 986 | mailimap_store_att_flags * store_flags; |
957 | int err; | 987 | int err; |
958 | login(); | 988 | login(); |
959 | if (!m_imap) { | 989 | if (!m_imap) { |
960 | return; | 990 | return; |
@@ -1180,25 +1210,25 @@ void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, | |||
1180 | if (!m_imap) { | 1210 | if (!m_imap) { |
1181 | return; | 1211 | return; |
1182 | } | 1212 | } |
1183 | int err = selectMbox(fromFolder->getName()); | 1213 | int err = selectMbox(fromFolder->getName()); |
1184 | if ( err != MAILIMAP_NO_ERROR ) { | 1214 | if ( err != MAILIMAP_NO_ERROR ) { |
1185 | return; | 1215 | return; |
1186 | } | 1216 | } |
1187 | int last = m_imap->imap_selection_info->sel_exists; | 1217 | int last = m_imap->imap_selection_info->sel_exists; |
1188 | set = mailimap_set_new_interval( 1, last ); | 1218 | set = mailimap_set_new_interval( 1, last ); |
1189 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); | 1219 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); |
1190 | mailimap_set_free( set ); | 1220 | mailimap_set_free( set ); |
1191 | if ( err != MAILIMAP_NO_ERROR ) { | 1221 | if ( err != MAILIMAP_NO_ERROR ) { |
1192 | QString error_msg = tr("error copy mails: %1").arg(m_imap->imap_response); | 1222 | QString error_msg = tr("Error copy mails: %1").arg(m_imap->imap_response); |
1193 | Global::statusMessage(error_msg); | 1223 | Global::statusMessage(error_msg); |
1194 | // odebug << error_msg << oendl; | 1224 | // odebug << error_msg << oendl; |
1195 | return; | 1225 | return; |
1196 | } | 1226 | } |
1197 | if (moveit) { | 1227 | if (moveit) { |
1198 | deleteAllMail(fromFolder); | 1228 | deleteAllMail(fromFolder); |
1199 | } | 1229 | } |
1200 | } | 1230 | } |
1201 | 1231 | ||
1202 | void IMAPwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 1232 | void IMAPwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
1203 | { | 1233 | { |
1204 | if (targetWrapper != this) { | 1234 | if (targetWrapper != this) { |