-rw-r--r-- | kmicromail/libmailwrapper/abstractmail.cpp | 53 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/imapwrapper.cpp | 62 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/imapwrapper.h | 4 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/pop3wrapper.cpp | 49 |
4 files changed, 67 insertions, 101 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 @@ -6,4 +6,5 @@ #include "mhwrapper.h" #include "mailtypes.h" +#include <qpe/global.h> @@ -147,22 +148,9 @@ void AbstractMail::deleteMailList(const QValueList<RecMailP>&target) int iii = 0; int count = target.count(); - QProgressBar bar( count,0 ); - bar.setCaption (("Removing mails - close to abort!") ); - int w = 300; - if ( QApplication::desktop()->width() < 320 ) - w = 220; - int h = bar.sizeHint().height() ; - int dw = QApplication::desktop()->width(); - int dh = QApplication::desktop()->height(); - bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); - bar.show(); - int modulo = (count/10)+1; - int incCounter = 0; - while (iii < count ) { - if ( ! bar.isVisible() ) - return ; - if ( incCounter % modulo == 0 ) - bar.setProgress( incCounter ); - ++incCounter; + QWidget wid; + wid.show(); + while (iii < count ) { + Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count)); + wid.raise(); qApp->processEvents(); RecMailP mail = (*target.at( iii )); @@ -187,26 +175,12 @@ void AbstractMail::mvcpMailList(const QValueList<RecMailP>& t, if ( count == 0 ) return; - - QProgressBar bar( count,0 ); - bar.setCaption (("Copying mails - close to abort!") ); - int w = 300; - if ( QApplication::desktop()->width() < 320 ) - w = 220; - int h = bar.sizeHint().height() ; - int dw = QApplication::desktop()->width(); - int dh = QApplication::desktop()->height(); - bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); - bar.show(); - int modulo = (count/10)+1; - int incCounter = 0; - while (iii < count ) { - if ( ! bar.isVisible() ) - return ; - if ( incCounter % modulo == 0 ) - bar.setProgress( incCounter ); - ++incCounter; - bar.raise(); + // wel, processevents is qite strange, we need a widget for getting + // Global::statusMessage(tr("Copy2 message %1").arg(iii)); displayed + QWidget wid; + wid.show(); + while (iii < count ) { + Global::statusMessage(tr("Copy message %1 of %2").arg(iii).arg(count)); + wid.raise(); qApp->processEvents(); - //qDebug("copy "); RecMailP r = (*t.at( iii )); st = fetchRawBody(r); @@ -217,5 +191,4 @@ void AbstractMail::mvcpMailList(const QValueList<RecMailP>& t, ++iii; } - bar.hide(); if (moveit) { deleteMailList( t ); 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 @@ -10,4 +10,7 @@ using namespace Opie::Core; +int IMAPwrapper::mMax = 0; +int IMAPwrapper::mCurrent = 0; + IMAPwrapper::IMAPwrapper( IMAPaccount *a ) : AbstractMail() @@ -16,4 +19,6 @@ IMAPwrapper::IMAPwrapper( IMAPaccount *a ) m_imap = 0; m_Lastmbox = ""; + mCurrent = 0; + mMax = 0; } @@ -41,8 +46,28 @@ int IMAPwrapper::selectMbox(const QString&mbox) void IMAPwrapper::imap_progress( size_t current, size_t maximum ) { + //qDebug("imap progress %d of %d ",current,maximum ); + //Global::statusMessage(tr("Downloading message %1 of %2").arg( current).arg(maximum)); + //qApp->processEvents() + static int last = 0; + if ( last != current ) + IMAPwrapper::progress(); + last = current; +} +void IMAPwrapper::progress( QString m ) +{ + + static QString mProgrMess; + if ( m != QString::null ) { + mProgrMess = m; + mCurrent = 0; + return; + } + QString mess; + //qDebug("progress "); + if ( mMax ) mess = mProgrMess +tr(" message %1 of %2").arg( mCurrent++).arg(mMax); + else mess = mProgrMess +tr(" message %1").arg( mCurrent++); + Global::statusMessage(mess); qApp->processEvents(); - qDebug("imap progress %d of %d ",current,maximum ); } - bool IMAPwrapper::start_tls(bool force_tls) { @@ -466,6 +491,5 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); - //odebug << "" << d->dt_year << " " << d->dt_month << " " << d->dt_day << " - " << d->dt_hour << " " << d->dt_min << " " << d->dt_sec << "" << oendl; - //odebug << da.toString() << oendl; + qDebug("time %s ",da.toString().latin1() ); #endif } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { @@ -887,23 +911,12 @@ void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target) // qDebug("imap remove count %d ", count); - QProgressBar bar( count,0 ); - bar.setCaption (("Removing mails - close to abort!") ); - int w = 300; - if ( QApplication::desktop()->width() < 320 ) - w = 220; - int h = bar.sizeHint().height() ; - int dw = QApplication::desktop()->width(); - int dh = QApplication::desktop()->height(); - bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); - bar.show(); - int modulo = (count/10)+1; - int incCounter = 0; - + + mMax = count; + //progress( tr("Delete")); + QWidget wid; + wid.show(); while (iii < count ) { - if ( ! bar.isVisible() ) - return ; - if ( incCounter % modulo == 0 ) - bar.setProgress( incCounter ); - ++incCounter; + Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count)); + wid.raise(); qApp->processEvents(); RecMailP mail = (*target.at( iii )); @@ -1200,5 +1213,7 @@ void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) { - if (targetWrapper != this || maxSizeInKb > 0 ) { + if (targetWrapper != this || maxSizeInKb > 0 ) { + mMax = 0; + progress( tr("Copy")); AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit, maxSizeInKb); qDebug("IMAPwrapper::mvcpAllMails::Using generic"); @@ -1215,4 +1230,5 @@ void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, return; } + Global::statusMessage( tr("Copying mails on server...") ); int last = m_imap->imap_selection_info->sel_exists; set = mailimap_set_new_interval( 1, last ); 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 @@ -74,5 +74,7 @@ protected: static QStringList address_list_to_stringlist(clist*list); - + static void progress(QString mess = QString::null); + static int mCurrent; + static int mMax; IMAPaccount *account; mailimap *m_imap; 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 @@ -127,9 +127,9 @@ void POP3wrapper::login() if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { + qApp->processEvents(); LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); login.show(); if ( QDialog::Accepted == login.exec() ) { // ok - qDebug("ok "); user = login.getUser(); pass = login.getPassword(); @@ -166,5 +166,5 @@ void POP3wrapper::login() if (err != MAIL_NO_ERROR) { ; // odebug << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl; - Global::statusMessage(tr("Error initializing folder")); + Global::statusMessage(tr("Error %1 initializing folder").arg( err )); mailstorage_free(m_pop3); m_pop3 = 0; @@ -201,22 +201,9 @@ void POP3wrapper::deleteMailList(const QValueList<RecMailP>&target) int iii = 0; int count = target.count(); - QProgressBar bar( count,0 ); - bar.setCaption (("Removing mails - close to abort!") ); - int w = 300; - if ( QApplication::desktop()->width() < 320 ) - w = 220; - int h = bar.sizeHint().height() ; - int dw = QApplication::desktop()->width(); - int dh = QApplication::desktop()->height(); - bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); - bar.show(); - int modulo = (count/10)+1; - int incCounter = 0; + QWidget wid; + wid.show(); while (iii < count ) { - if ( ! bar.isVisible() ) - return ; - if ( incCounter % modulo == 0 ) - bar.setProgress( incCounter ); - ++incCounter; + Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count)); + wid.raise(); qApp->processEvents(); //qDebug("delete "); @@ -253,23 +240,11 @@ int POP3wrapper::deleteAllMail(const FolderP&) { return 0; } - QProgressBar bar( result,0 ); - bar.setCaption (("Deleting mails - close to abort!") ); - int w = 300; - if ( QApplication::desktop()->width() < 320 ) - w = 220; - int h = bar.sizeHint().height() ; - int dw = QApplication::desktop()->width(); - int dh = QApplication::desktop()->height(); - bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); - bar.show(); - int modulo = (result/10)+1; - int incCounter = 0; - for (unsigned int i = 0; i < result; ++i) { - if ( ! bar.isVisible() ) - return 0; - if ( incCounter % modulo == 0 ) - bar.setProgress( incCounter ); - ++incCounter; + QWidget wid; + wid.show(); + for (unsigned int i = 0; i < result; ++i) { + Global::statusMessage(tr("Delete message %1 of %2").arg(i).arg(result)); + wid.raise(); qApp->processEvents(); + err = mailsession_remove_message(m_pop3->sto_session,i+1); if (err != MAIL_NO_ERROR) { |