summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-09-10 19:57:55 (UTC)
committer zautrix <zautrix>2004-09-10 19:57:55 (UTC)
commitcebdd6de7481514ad5ea0517f7a2e8f4db422be5 (patch) (unidiff)
tree0b29859b5bbfdcb702724c3b0c721f22b0d0e666
parent157120031b77a3d9f10d780a66b6441dac1399fa (diff)
downloadkdepimpi-cebdd6de7481514ad5ea0517f7a2e8f4db422be5.zip
kdepimpi-cebdd6de7481514ad5ea0517f7a2e8f4db422be5.tar.gz
kdepimpi-cebdd6de7481514ad5ea0517f7a2e8f4db422be5.tar.bz2
Added status info when deleting mails
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--kmicromail/libmailwrapper/abstractmail.cpp49
-rw-r--r--kmicromail/libmailwrapper/imapwrapper.cpp58
-rw-r--r--kmicromail/libmailwrapper/imapwrapper.h4
-rw-r--r--kmicromail/libmailwrapper/pop3wrapper.cpp47
4 files changed, 62 insertions, 96 deletions
diff --git a/kmicromail/libmailwrapper/abstractmail.cpp b/kmicromail/libmailwrapper/abstractmail.cpp
index cef4e97..f876235 100644
--- a/kmicromail/libmailwrapper/abstractmail.cpp
+++ b/kmicromail/libmailwrapper/abstractmail.cpp
@@ -5,6 +5,7 @@
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#include <qpe/global.h>
8 9
9 10
10#include <qprogressbar.h> 11#include <qprogressbar.h>
@@ -146,24 +147,11 @@ void AbstractMail::deleteMailList(const QValueList<RecMailP>&target)
146 // this is currently re-implemented in pop3wrapper and imapwrapper 147 // this is currently re-implemented in pop3wrapper and imapwrapper
147 int iii = 0; 148 int iii = 0;
148 int count = target.count(); 149 int count = target.count();
149 QProgressBar bar( count,0 ); 150 QWidget wid;
150 bar.setCaption (("Removing mails - close to abort!") ); 151 wid.show();
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 ) { 152 while (iii < count ) {
162 if ( ! bar.isVisible() ) 153 Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count));
163 return ; 154 wid.raise();
164 if ( incCounter % modulo == 0 )
165 bar.setProgress( incCounter );
166 ++incCounter;
167 qApp->processEvents(); 155 qApp->processEvents();
168 RecMailP mail = (*target.at( iii )); 156 RecMailP mail = (*target.at( iii ));
169 deleteMail(mail); 157 deleteMail(mail);
@@ -186,28 +174,14 @@ void AbstractMail::mvcpMailList(const QValueList<RecMailP>& t,
186 int count = t.count(); 174 int count = t.count();
187 if ( count == 0 ) 175 if ( count == 0 )
188 return; 176 return;
189 177 // wel, processevents is qite strange, we need a widget for getting
190 QProgressBar bar( count,0 ); 178 // Global::statusMessage(tr("Copy2 message %1").arg(iii)); displayed
191 bar.setCaption (("Copying mails - close to abort!") ); 179 QWidget wid;
192 int w = 300; 180 wid.show();
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;
202 while (iii < count ) { 181 while (iii < count ) {
203 if ( ! bar.isVisible() ) 182 Global::statusMessage(tr("Copy message %1 of %2").arg(iii).arg(count));
204 return ; 183 wid.raise();
205 if ( incCounter % modulo == 0 )
206 bar.setProgress( incCounter );
207 ++incCounter;
208 bar.raise();
209 qApp->processEvents(); 184 qApp->processEvents();
210 //qDebug("copy ");
211 RecMailP r = (*t.at( iii )); 185 RecMailP r = (*t.at( iii ));
212 st = fetchRawBody(r); 186 st = fetchRawBody(r);
213 if (st) { 187 if (st) {
@@ -216,7 +190,6 @@ void AbstractMail::mvcpMailList(const QValueList<RecMailP>& t,
216 } 190 }
217 ++iii; 191 ++iii;
218 } 192 }
219 bar.hide();
220 if (moveit) { 193 if (moveit) {
221 deleteMailList( t ); 194 deleteMailList( t );
222 //deleteAllMail(fromFolder); 195 //deleteAllMail(fromFolder);
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp
index 021633b..be825ef 100644
--- a/kmicromail/libmailwrapper/imapwrapper.cpp
+++ b/kmicromail/libmailwrapper/imapwrapper.cpp
@@ -9,12 +9,17 @@
9#include <qprogressbar.h> 9#include <qprogressbar.h>
10 10
11using namespace Opie::Core; 11using namespace Opie::Core;
12int IMAPwrapper::mMax = 0;
13int IMAPwrapper::mCurrent = 0;
14
12IMAPwrapper::IMAPwrapper( IMAPaccount *a ) 15IMAPwrapper::IMAPwrapper( IMAPaccount *a )
13 : AbstractMail() 16 : AbstractMail()
14{ 17{
15 account = a; 18 account = a;
16 m_imap = 0; 19 m_imap = 0;
17 m_Lastmbox = ""; 20 m_Lastmbox = "";
21 mCurrent = 0;
22 mMax = 0;
18} 23}
19 24
20IMAPwrapper::~IMAPwrapper() 25IMAPwrapper::~IMAPwrapper()
@@ -40,10 +45,30 @@ int IMAPwrapper::selectMbox(const QString&mbox)
40 45
41void IMAPwrapper::imap_progress( size_t current, size_t maximum ) 46void IMAPwrapper::imap_progress( size_t current, size_t maximum )
42{ 47{
48 //qDebug("imap progress %d of %d ",current,maximum );
49 //Global::statusMessage(tr("Downloading message %1 of %2").arg( current).arg(maximum));
50 //qApp->processEvents()
51 static int last = 0;
52 if ( last != current )
53 IMAPwrapper::progress();
54 last = current;
55}
56void IMAPwrapper::progress( QString m )
57{
58
59 static QString mProgrMess;
60 if ( m != QString::null ) {
61 mProgrMess = m;
62 mCurrent = 0;
63 return;
64 }
65 QString mess;
66 //qDebug("progress ");
67 if ( mMax ) mess = mProgrMess +tr(" message %1 of %2").arg( mCurrent++).arg(mMax);
68 else mess = mProgrMess +tr(" message %1").arg( mCurrent++);
69 Global::statusMessage(mess);
43 qApp->processEvents(); 70 qApp->processEvents();
44 qDebug("imap progress %d of %d ",current,maximum );
45} 71}
46
47bool IMAPwrapper::start_tls(bool force_tls) 72bool IMAPwrapper::start_tls(bool force_tls)
48{ 73{
49 int err; 74 int err;
@@ -465,8 +490,7 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
465#if 0 490#if 0
466 mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; 491 mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date;
467 QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); 492 QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec));
468 //odebug << "" << d->dt_year << " " << d->dt_month << " " << d->dt_day << " - " << d->dt_hour << " " << d->dt_min << " " << d->dt_sec << "" << oendl; 493 qDebug("time %s ",da.toString().latin1() );
469 //odebug << da.toString() << oendl;
470#endif 494#endif
471 } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { 495 } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) {
472 size = item->att_data.att_static->att_data.att_rfc822_size; 496 size = item->att_data.att_static->att_data.att_rfc822_size;
@@ -886,25 +910,14 @@ void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target)
886 int count = target.count(); 910 int count = target.count();
887 // qDebug("imap remove count %d ", count); 911 // qDebug("imap remove count %d ", count);
888 912
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 913
914 mMax = count;
915 //progress( tr("Delete"));
916 QWidget wid;
917 wid.show();
902 while (iii < count ) { 918 while (iii < count ) {
903 if ( ! bar.isVisible() ) 919 Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count));
904 return ; 920 wid.raise();
905 if ( incCounter % modulo == 0 )
906 bar.setProgress( incCounter );
907 ++incCounter;
908 qApp->processEvents(); 921 qApp->processEvents();
909 RecMailP mail = (*target.at( iii )); 922 RecMailP mail = (*target.at( iii ));
910 //#if 0 923 //#if 0
@@ -1200,6 +1213,8 @@ void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder,
1200 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) 1213 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb)
1201{ 1214{
1202 if (targetWrapper != this || maxSizeInKb > 0 ) { 1215 if (targetWrapper != this || maxSizeInKb > 0 ) {
1216 mMax = 0;
1217 progress( tr("Copy"));
1203 AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit, maxSizeInKb); 1218 AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit, maxSizeInKb);
1204 qDebug("IMAPwrapper::mvcpAllMails::Using generic"); 1219 qDebug("IMAPwrapper::mvcpAllMails::Using generic");
1205 // odebug << "Using generic" << oendl; 1220 // odebug << "Using generic" << oendl;
@@ -1214,6 +1229,7 @@ void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder,
1214 if ( err != MAILIMAP_NO_ERROR ) { 1229 if ( err != MAILIMAP_NO_ERROR ) {
1215 return; 1230 return;
1216 } 1231 }
1232 Global::statusMessage( tr("Copying mails on server...") );
1217 int last = m_imap->imap_selection_info->sel_exists; 1233 int last = m_imap->imap_selection_info->sel_exists;
1218 set = mailimap_set_new_interval( 1, last ); 1234 set = mailimap_set_new_interval( 1, last );
1219 err = mailimap_copy(m_imap,set,targetFolder.latin1()); 1235 err = mailimap_copy(m_imap,set,targetFolder.latin1());
diff --git a/kmicromail/libmailwrapper/imapwrapper.h b/kmicromail/libmailwrapper/imapwrapper.h
index 222fe95..db8ab5b 100644
--- a/kmicromail/libmailwrapper/imapwrapper.h
+++ b/kmicromail/libmailwrapper/imapwrapper.h
@@ -73,7 +73,9 @@ protected:
73 static void fillBodyFields(RecPartP&target_part,mailimap_body_fields*which); 73 static void fillBodyFields(RecPartP&target_part,mailimap_body_fields*which);
74 static QStringList address_list_to_stringlist(clist*list); 74 static QStringList address_list_to_stringlist(clist*list);
75 75
76 76 static void progress(QString mess = QString::null);
77 static int mCurrent;
78 static int mMax;
77 IMAPaccount *account; 79 IMAPaccount *account;
78 mailimap *m_imap; 80 mailimap *m_imap;
79 QString m_Lastmbox; 81 QString m_Lastmbox;
diff --git a/kmicromail/libmailwrapper/pop3wrapper.cpp b/kmicromail/libmailwrapper/pop3wrapper.cpp
index f430121..8d2f778 100644
--- a/kmicromail/libmailwrapper/pop3wrapper.cpp
+++ b/kmicromail/libmailwrapper/pop3wrapper.cpp
@@ -126,11 +126,11 @@ void POP3wrapper::login()
126 port = account->getPort().toUInt(); 126 port = account->getPort().toUInt();
127 127
128 if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { 128 if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) {
129 qApp->processEvents();
129 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); 130 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true );
130 login.show(); 131 login.show();
131 if ( QDialog::Accepted == login.exec() ) { 132 if ( QDialog::Accepted == login.exec() ) {
132 // ok 133 // ok
133 qDebug("ok ");
134 user = login.getUser(); 134 user = login.getUser();
135 pass = login.getPassword(); 135 pass = login.getPassword();
136 } else { 136 } else {
@@ -165,7 +165,7 @@ void POP3wrapper::login()
165 err = mailstorage_connect(m_pop3); 165 err = mailstorage_connect(m_pop3);
166 if (err != MAIL_NO_ERROR) { 166 if (err != MAIL_NO_ERROR) {
167 ; // odebug << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl; 167 ; // odebug << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl;
168 Global::statusMessage(tr("Error initializing folder")); 168 Global::statusMessage(tr("Error %1 initializing folder").arg( err ));
169 mailstorage_free(m_pop3); 169 mailstorage_free(m_pop3);
170 m_pop3 = 0; 170 m_pop3 = 0;
171 } else { 171 } else {
@@ -200,24 +200,11 @@ void POP3wrapper::deleteMailList(const QValueList<RecMailP>&target)
200 return; 200 return;
201 int iii = 0; 201 int iii = 0;
202 int count = target.count(); 202 int count = target.count();
203 QProgressBar bar( count,0 ); 203 QWidget wid;
204 bar.setCaption (("Removing mails - close to abort!") ); 204 wid.show();
205 int w = 300;
206 if ( QApplication::desktop()->width() < 320 )
207 w = 220;
208 int h = bar.sizeHint().height() ;
209 int dw = QApplication::desktop()->width();
210 int dh = QApplication::desktop()->height();
211 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
212 bar.show();
213 int modulo = (count/10)+1;
214 int incCounter = 0;
215 while (iii < count ) { 205 while (iii < count ) {
216 if ( ! bar.isVisible() ) 206 Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count));
217 return ; 207 wid.raise();
218 if ( incCounter % modulo == 0 )
219 bar.setProgress( incCounter );
220 ++incCounter;
221 qApp->processEvents(); 208 qApp->processEvents();
222 //qDebug("delete "); 209 //qDebug("delete ");
223 RecMailP mail = (*target.at( iii )); 210 RecMailP mail = (*target.at( iii ));
@@ -252,25 +239,13 @@ int POP3wrapper::deleteAllMail(const FolderP&) {
252 Global::statusMessage(tr("Error getting folder info")); 239 Global::statusMessage(tr("Error getting folder info"));
253 return 0; 240 return 0;
254 } 241 }
255 QProgressBar bar( result,0 ); 242 QWidget wid;
256 bar.setCaption (("Deleting mails - close to abort!") ); 243 wid.show();
257 int w = 300;
258 if ( QApplication::desktop()->width() < 320 )
259 w = 220;
260 int h = bar.sizeHint().height() ;
261 int dw = QApplication::desktop()->width();
262 int dh = QApplication::desktop()->height();
263 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
264 bar.show();
265 int modulo = (result/10)+1;
266 int incCounter = 0;
267 for (unsigned int i = 0; i < result; ++i) { 244 for (unsigned int i = 0; i < result; ++i) {
268 if ( ! bar.isVisible() ) 245 Global::statusMessage(tr("Delete message %1 of %2").arg(i).arg(result));
269 return 0; 246 wid.raise();
270 if ( incCounter % modulo == 0 )
271 bar.setProgress( incCounter );
272 ++incCounter;
273 qApp->processEvents(); 247 qApp->processEvents();
248
274 err = mailsession_remove_message(m_pop3->sto_session,i+1); 249 err = mailsession_remove_message(m_pop3->sto_session,i+1);
275 if (err != MAIL_NO_ERROR) { 250 if (err != MAIL_NO_ERROR) {
276 Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); 251 Global::statusMessage(tr("Error deleting mail %1").arg(i+1));