summaryrefslogtreecommitdiffabout
path: root/kmicromail/libmailwrapper
authorzautrix <zautrix>2004-09-01 10:23:29 (UTC)
committer zautrix <zautrix>2004-09-01 10:23:29 (UTC)
commit6cefbdc9c8f3f3001373f10715361e2740c45395 (patch) (unidiff)
treecb2c36f57620e698913c27ca4ebe59e4a7c9d46e /kmicromail/libmailwrapper
parentb9257cb225cd29bab5d96fcdaf557926603ee587 (diff)
downloadkdepimpi-6cefbdc9c8f3f3001373f10715361e2740c45395.zip
kdepimpi-6cefbdc9c8f3f3001373f10715361e2740c45395.tar.gz
kdepimpi-6cefbdc9c8f3f3001373f10715361e2740c45395.tar.bz2
Mail fixes and libetpan updated
Diffstat (limited to 'kmicromail/libmailwrapper') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libmailwrapper/abstractmail.cpp58
-rw-r--r--kmicromail/libmailwrapper/imapwrapper.cpp46
-rw-r--r--kmicromail/libmailwrapper/pop3wrapper.cpp47
-rw-r--r--kmicromail/libmailwrapper/pop3wrapper.h2
4 files changed, 136 insertions, 17 deletions
diff --git a/kmicromail/libmailwrapper/abstractmail.cpp b/kmicromail/libmailwrapper/abstractmail.cpp
index 3998abd..3b0ca1f 100644
--- a/kmicromail/libmailwrapper/abstractmail.cpp
+++ b/kmicromail/libmailwrapper/abstractmail.cpp
@@ -1,25 +1,27 @@
1// CHANGED 2004-09-31 Lutz Rogowski 1// CHANGED 2004-09-31 Lutz Rogowski
2#include "abstractmail.h" 2#include "abstractmail.h"
3#include "imapwrapper.h" 3#include "imapwrapper.h"
4#include "pop3wrapper.h" 4#include "pop3wrapper.h"
5#include "nntpwrapper.h" 5#include "nntpwrapper.h"
6#include "mhwrapper.h" 6#include "mhwrapper.h"
7#include "mailtypes.h" 7#include "mailtypes.h"
8 8
9 9
10#include <qprogressbar.h>
11#include <qapplication.h>
10 12
11#include <kdecore/kstandarddirs.h> 13#include <kdecore/kstandarddirs.h>
12#include <qfile.h> 14#include <qfile.h>
13#include <qtextstream.h> 15#include <qtextstream.h>
14#include <stdlib.h> 16#include <stdlib.h>
15#include <libetpan/mailmime_content.h> 17#include <libetpan/mailmime_content.h>
16#include <libetpan/mailmime.h> 18#include <libetpan/mailmime.h>
17 19
18using namespace Opie::Core; 20using namespace Opie::Core;
19AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) 21AbstractMail* AbstractMail::getWrapper(IMAPaccount *a)
20{ 22{
21 return new IMAPwrapper(a); 23 return new IMAPwrapper(a);
22} 24}
23 25
24AbstractMail* AbstractMail::getWrapper(POP3account *a) 26AbstractMail* AbstractMail::getWrapper(POP3account *a)
25{ 27{
@@ -127,59 +129,107 @@ QString AbstractMail::defaultLocalfolder()
127 QString f = locateLocal( "data", "kmicromail/localmail"); 129 QString f = locateLocal( "data", "kmicromail/localmail");
128 // f += "/Applications/opiemail/localmail"; 130 // f += "/Applications/opiemail/localmail";
129 return f; 131 return f;
130} 132}
131 133
132QString AbstractMail::draftFolder() 134QString AbstractMail::draftFolder()
133{ 135{
134 return QString("Drafts"); 136 return QString("Drafts");
135} 137}
136 138
137/* temporary - will be removed when implemented in all classes */ 139/* temporary - will be removed when implemented in all classes */
138void AbstractMail::deleteMails(const QString &,const QValueList<Opie::Core::OSmartPointer<RecMail> > &) 140void AbstractMail::deleteMails(const QString &,const QValueList<Opie::Core::OSmartPointer<RecMail> > &)
139{ 141{
140} 142}
141void AbstractMail::deleteMailList(const QValueList<RecMailP>&target) 143void AbstractMail::deleteMailList(const QValueList<RecMailP>&target)
142{ 144{
143 qDebug("AbstractMail::deleteMailList:: Please reimplement! "); 145 //qDebug("AbstractMail::deleteMailList:: Please reimplement! ");
144 146 // this is currently re-implemented in pop3wrapper and imapwrapper
147 int iii = 0;
148 int count = target.count();
149 QProgressBar bar( count,0 );
150 bar.setCaption (("Removing mails - close to abort!") );
151 int w = 300;
152 if ( QApplication::desktop()->width() < 320 )
153 w = 220;
154 int h = bar.sizeHint().height() ;
155 int dw = QApplication::desktop()->width();
156 int dh = QApplication::desktop()->height();
157 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
158 bar.show();
159 int modulo = (count/10)+1;
160 int incCounter = 0;
161 while (iii < count ) {
162 if ( ! bar.isVisible() )
163 return ;
164 if ( incCounter % modulo == 0 )
165 bar.setProgress( incCounter );
166 ++incCounter;
167 qApp->processEvents();
168 RecMailP mail = (*target.at( iii ));
169 deleteMail(mail);
170 ++iii;
171 }
145} 172}
146void AbstractMail::mvcpAllMails(const FolderP&fromFolder, 173void AbstractMail::mvcpAllMails(const FolderP&fromFolder,
147 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) 174 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb)
148{ 175{
149 QValueList<RecMailP> t; 176 QValueList<RecMailP> t;
150 listMessages(fromFolder->getName(),t, maxSizeInKb); 177 listMessages(fromFolder->getName(),t, maxSizeInKb);
151 mvcpMailList( t,targetFolder,targetWrapper,moveit); 178 mvcpMailList( t,targetFolder,targetWrapper,moveit);
152 179
153} 180}
154void AbstractMail::mvcpMailList(const QValueList<RecMailP>& t, 181void AbstractMail::mvcpMailList(const QValueList<RecMailP>& t,
155 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) 182 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
156{ 183{
157
158 encodedString*st = 0; 184 encodedString*st = 0;
159 int iii = 0; 185 int iii = 0;
160 int count = t.count(); 186 int count = t.count();
187 if ( count == 0 )
188 return;
189
190 QProgressBar bar( count,0 );
191 bar.setCaption (("Copying mails - close to abort!") );
192 int w = 300;
193 if ( QApplication::desktop()->width() < 320 )
194 w = 220;
195 int h = bar.sizeHint().height() ;
196 int dw = QApplication::desktop()->width();
197 int dh = QApplication::desktop()->height();
198 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
199 bar.show();
200 int modulo = (count/10)+1;
201 int incCounter = 0;
161 while (iii < count ) { 202 while (iii < count ) {
203 if ( ! bar.isVisible() )
204 return ;
205 if ( incCounter % modulo == 0 )
206 bar.setProgress( incCounter );
207 ++incCounter;
208 bar.raise();
209 qApp->processEvents();
210 //qDebug("copy ");
162 RecMailP r = (*t.at( iii )); 211 RecMailP r = (*t.at( iii ));
163 st = fetchRawBody(r); 212 st = fetchRawBody(r);
164 if (st) { 213 if (st) {
165 targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); 214 targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder);
166 delete st; 215 delete st;
167 } 216 }
168 ++iii; 217 ++iii;
169 } 218 }
219 bar.hide();
170 if (moveit) { 220 if (moveit) {
171 deleteMailList( t ); 221 deleteMailList( t );
172 //deleteAllMail(fromFolder); 222 //deleteAllMail(fromFolder);
173 } 223 }
174} 224}
175 225
176void AbstractMail::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) 226void AbstractMail::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
177{ 227{
178 encodedString*st = 0; 228 encodedString*st = 0;
179 st = fetchRawBody(mail); 229 st = fetchRawBody(mail);
180 if (st) { 230 if (st) {
181 targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); 231 targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder);
182 delete st; 232 delete st;
183 } 233 }
184 if (moveit) { 234 if (moveit) {
185 deleteMail(mail); 235 deleteMail(mail);
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,24 +1,25 @@
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
10using namespace Opie::Core; 11using namespace Opie::Core;
11IMAPwrapper::IMAPwrapper( IMAPaccount *a ) 12IMAPwrapper::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
19IMAPwrapper::~IMAPwrapper() 20IMAPwrapper::~IMAPwrapper()
20{ 21{
21 logout(); 22 logout();
22} 23}
23 24
24/* to avoid to often select statements in loops etc. 25/* to avoid to often select statements in loops etc.
@@ -858,72 +859,101 @@ void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which
858 default: 859 default:
859 if (enc->enc_value) { 860 if (enc->enc_value) {
860 char*t=enc->enc_value; 861 char*t=enc->enc_value;
861 encoding=QString(enc->enc_value); 862 encoding=QString(enc->enc_value);
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}
872void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target) 873void 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 } 943 }
912 ++iii;
913 }
914} 944}
915void IMAPwrapper::deleteMail(const RecMailP&mail) 945void 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 }
925 err = selectMbox(mail->getMbox()); 955 err = selectMbox(mail->getMbox());
926 if ( err != MAILIMAP_NO_ERROR ) { 956 if ( err != MAILIMAP_NO_ERROR ) {
927 return; 957 return;
928 } 958 }
929 flist = mailimap_flag_list_new_empty(); 959 flist = mailimap_flag_list_new_empty();
@@ -932,33 +962,33 @@ void IMAPwrapper::deleteMail(const RecMailP&mail)
932 set = mailimap_set_new_single(mail->getNumber()); 962 set = mailimap_set_new_single(mail->getNumber());
933 err = mailimap_store(m_imap,set,store_flags); 963 err = mailimap_store(m_imap,set,store_flags);
934 mailimap_set_free( set ); 964 mailimap_set_free( set );
935 mailimap_store_att_flags_free(store_flags); 965 mailimap_store_att_flags_free(store_flags);
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
952void IMAPwrapper::answeredMail(const RecMailP&mail) 982void 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;
961 } 991 }
962 err = selectMbox(mail->getMbox()); 992 err = selectMbox(mail->getMbox());
963 if ( err != MAILIMAP_NO_ERROR ) { 993 if ( err != MAILIMAP_NO_ERROR ) {
964 return; 994 return;
@@ -1176,33 +1206,33 @@ void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder,
1176 return; 1206 return;
1177 } 1207 }
1178 mailimap_set *set = 0; 1208 mailimap_set *set = 0;
1179 login(); 1209 login();
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
1202void IMAPwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) 1232void IMAPwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
1203{ 1233{
1204 if (targetWrapper != this) { 1234 if (targetWrapper != this) {
1205 // odebug << "Using generic" << oendl; 1235 // odebug << "Using generic" << oendl;
1206 AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit); 1236 AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit);
1207 return; 1237 return;
1208 } 1238 }
diff --git a/kmicromail/libmailwrapper/pop3wrapper.cpp b/kmicromail/libmailwrapper/pop3wrapper.cpp
index 7a84b30..0e6612c 100644
--- a/kmicromail/libmailwrapper/pop3wrapper.cpp
+++ b/kmicromail/libmailwrapper/pop3wrapper.cpp
@@ -1,26 +1,28 @@
1// CHANGED 2004-09-31 Lutz Rogowski 1// CHANGED 2004-09-31 Lutz Rogowski
2#include <stdlib.h> 2#include <stdlib.h>
3#include "pop3wrapper.h" 3#include "pop3wrapper.h"
4#include "mailtypes.h" 4#include "mailtypes.h"
5#include "logindialog.h" 5#include "logindialog.h"
6#include <libetpan/libetpan.h> 6#include <libetpan/libetpan.h>
7 7
8 8
9#include <qpe/global.h> 9#include <qpe/global.h>
10#include <qfile.h> 10#include <qfile.h>
11#include <qprogressbar.h>
12#include <qapplication.h>
11 13
12/* we don't fetch messages larger than 5 MB */ 14/* we don't fetch messages larger than 5 MB */
13#define HARD_MSG_SIZE_LIMIT 5242880 15#define HARD_MSG_SIZE_LIMIT 5242880
14 16
15using namespace Opie::Core; 17using namespace Opie::Core;
16POP3wrapper::POP3wrapper( POP3account *a ) 18POP3wrapper::POP3wrapper( POP3account *a )
17: Genericwrapper() { 19: Genericwrapper() {
18 account = a; 20 account = a;
19 m_pop3 = NULL; 21 m_pop3 = NULL;
20 msgTempName = a->getFileName()+"_msg_cache"; 22 msgTempName = a->getFileName()+"_msg_cache";
21 last_msg_id = 0; 23 last_msg_id = 0;
22} 24}
23 25
24POP3wrapper::~POP3wrapper() { 26POP3wrapper::~POP3wrapper() {
25 logout(); 27 logout();
26 QFile msg_cache(msgTempName); 28 QFile msg_cache(msgTempName);
@@ -180,73 +182,110 @@ void POP3wrapper::login()
180void POP3wrapper::logout() 182void POP3wrapper::logout()
181{ 183{
182 if ( m_pop3 == NULL ) 184 if ( m_pop3 == NULL )
183 return; 185 return;
184 mailstorage_free(m_pop3); 186 mailstorage_free(m_pop3);
185 m_pop3 = 0; 187 m_pop3 = 0;
186} 188}
187 189
188 190
189QValueList<Opie::Core::OSmartPointer<Folder> >* POP3wrapper::listFolders() { 191QValueList<Opie::Core::OSmartPointer<Folder> >* POP3wrapper::listFolders() {
190 QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<FolderP>(); 192 QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<FolderP>();
191 FolderP inb=new Folder("INBOX","/"); 193 FolderP inb=new Folder("INBOX","/");
192 folders->append(inb); 194 folders->append(inb);
193 return folders; 195 return folders;
194} 196}
195 197
196void POP3wrapper::deleteMailList(QValueList<RecMailP>&target) 198void POP3wrapper::deleteMailList(const QValueList<RecMailP>&target)
197{ 199{
198 login(); 200 login();
199 if (!m_pop3) 201 if (!m_pop3)
200 return; 202 return;
201 int iii = 0; 203 int iii = 0;
202 int count = target.count(); 204 int count = target.count();
203 while (iii < count ) { 205 QProgressBar bar( count,0 );
206 bar.setCaption (("Removing mails - close to abort!") );
207 int w = 300;
208 if ( QApplication::desktop()->width() < 320 )
209 w = 220;
210 int h = bar.sizeHint().height() ;
211 int dw = QApplication::desktop()->width();
212 int dh = QApplication::desktop()->height();
213 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
214 bar.show();
215 int modulo = (count/10)+1;
216 int incCounter = 0;
217 while (iii < count ) {
218 if ( ! bar.isVisible() )
219 return ;
220 if ( incCounter % modulo == 0 )
221 bar.setProgress( incCounter );
222 ++incCounter;
223 qApp->processEvents();
224 //qDebug("delete ");
204 RecMailP mail = (*target.at( iii )); 225 RecMailP mail = (*target.at( iii ));
205 int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); 226 int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber());
206 if (err != MAIL_NO_ERROR) { 227 if (err != MAIL_NO_ERROR) {
207 Global::statusMessage(tr("error deleting mail")); 228 Global::statusMessage(tr("Error deleting mail"));
208 } 229 }
209 ++iii; 230 ++iii;
210 } 231 }
211} 232}
212void POP3wrapper::deleteMail(const RecMailP&mail) { 233void POP3wrapper::deleteMail(const RecMailP&mail) {
213 login(); 234 login();
214 if (!m_pop3) 235 if (!m_pop3)
215 return; 236 return;
216 int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); 237 int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber());
217 if (err != MAIL_NO_ERROR) { 238 if (err != MAIL_NO_ERROR) {
218 Global::statusMessage(tr("error deleting mail")); 239 Global::statusMessage(tr("error deleting mail"));
219 } 240 }
220} 241}
221 242
222void POP3wrapper::answeredMail(const RecMailP&) {} 243void POP3wrapper::answeredMail(const RecMailP&) {}
223 244
224int POP3wrapper::deleteAllMail(const FolderP&) { 245int POP3wrapper::deleteAllMail(const FolderP&) {
225 login(); 246 login();
226 if (!m_pop3) 247 if (!m_pop3)
227 return 0; 248 return 0;
228 int res = 1; 249 int res = 1;
229 250
230 uint32_t result = 0; 251 uint32_t result = 0;
231 int err = mailsession_messages_number(m_pop3->sto_session,NULL,&result); 252 int err = mailsession_messages_number(m_pop3->sto_session,NULL,&result);
232 if (err != MAIL_NO_ERROR) { 253 if (err != MAIL_NO_ERROR) {
233 Global::statusMessage(tr("Error getting folder info")); 254 Global::statusMessage(tr("Error getting folder info"));
234 return 0; 255 return 0;
235 } 256 }
257 QProgressBar bar( result,0 );
258 bar.setCaption (("Deleting mails - close to abort!") );
259 int w = 300;
260 if ( QApplication::desktop()->width() < 320 )
261 w = 220;
262 int h = bar.sizeHint().height() ;
263 int dw = QApplication::desktop()->width();
264 int dh = QApplication::desktop()->height();
265 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
266 bar.show();
267 int modulo = (result/10)+1;
268 int incCounter = 0;
236 for (unsigned int i = 0; i < result; ++i) { 269 for (unsigned int i = 0; i < result; ++i) {
270 if ( ! bar.isVisible() )
271 return 0;
272 if ( incCounter % modulo == 0 )
273 bar.setProgress( incCounter );
274 ++incCounter;
275 qApp->processEvents();
237 err = mailsession_remove_message(m_pop3->sto_session,i+1); 276 err = mailsession_remove_message(m_pop3->sto_session,i+1);
238 if (err != MAIL_NO_ERROR) { 277 if (err != MAIL_NO_ERROR) {
239 Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); 278 Global::statusMessage(tr("Error deleting mail %1").arg(i+1));
240 res=0; 279 res=0;
241 } 280 }
242 break; 281 break;
243 } 282 }
244 return res; 283 return res;
245} 284}
246 285
247void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) { 286void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) {
248 login(); 287 login();
249 target_stat.message_count = 0; 288 target_stat.message_count = 0;
250 target_stat.message_unseen = 0; 289 target_stat.message_unseen = 0;
251 target_stat.message_recent = 0; 290 target_stat.message_recent = 0;
252 if (!m_pop3) 291 if (!m_pop3)
diff --git a/kmicromail/libmailwrapper/pop3wrapper.h b/kmicromail/libmailwrapper/pop3wrapper.h
index ee754a4..7c70942 100644
--- a/kmicromail/libmailwrapper/pop3wrapper.h
+++ b/kmicromail/libmailwrapper/pop3wrapper.h
@@ -11,34 +11,34 @@ struct mailstorage;
11struct mailfolder; 11struct mailfolder;
12 12
13class POP3wrapper : public Genericwrapper 13class POP3wrapper : public Genericwrapper
14{ 14{
15 Q_OBJECT 15 Q_OBJECT
16 16
17public: 17public:
18 POP3wrapper( POP3account *a ); 18 POP3wrapper( POP3account *a );
19 virtual ~POP3wrapper(); 19 virtual ~POP3wrapper();
20 /* mailbox will be ignored */ 20 /* mailbox will be ignored */
21 virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb = 0 ); 21 virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb = 0 );
22 virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); 22 virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders();
23 /* mailbox will be ignored */ 23 /* mailbox will be ignored */
24 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); 24 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX");
25 25
26 virtual void deleteMail(const RecMailP&mail); 26 virtual void deleteMail(const RecMailP&mail);
27 virtual void deleteMailList(const QValueList<RecMailP>&target);
27 virtual void answeredMail(const RecMailP&mail); 28 virtual void answeredMail(const RecMailP&mail);
28 virtual void deleteMailList(QValueList<RecMailP>&target);
29 virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); 29 virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&);
30 30
31 virtual RecBodyP fetchBody( const RecMailP &mail ); 31 virtual RecBodyP fetchBody( const RecMailP &mail );
32 virtual encodedString* fetchRawBody(const RecMailP&mail); 32 virtual encodedString* fetchRawBody(const RecMailP&mail);
33 virtual void logout(); 33 virtual void logout();
34 virtual MAILLIB::ATYPE getType()const; 34 virtual MAILLIB::ATYPE getType()const;
35 virtual const QString&getName()const; 35 virtual const QString&getName()const;
36 static void pop3_progress( size_t current, size_t maximum ); 36 static void pop3_progress( size_t current, size_t maximum );
37 37
38protected: 38protected:
39 void login(); 39 void login();
40 POP3account *account; 40 POP3account *account;
41 mailstorage*m_pop3; 41 mailstorage*m_pop3;
42}; 42};
43 43
44#endif 44#endif