author | zautrix <zautrix> | 2004-09-10 19:57:55 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-10 19:57:55 (UTC) |
commit | cebdd6de7481514ad5ea0517f7a2e8f4db422be5 (patch) (side-by-side diff) | |
tree | 0b29859b5bbfdcb702724c3b0c721f22b0d0e666 | |
parent | 157120031b77a3d9f10d780a66b6441dac1399fa (diff) | |
download | kdepimpi-cebdd6de7481514ad5ea0517f7a2e8f4db422be5.zip kdepimpi-cebdd6de7481514ad5ea0517f7a2e8f4db422be5.tar.gz kdepimpi-cebdd6de7481514ad5ea0517f7a2e8f4db422be5.tar.bz2 |
Added status info when deleting mails
-rw-r--r-- | kmicromail/libmailwrapper/abstractmail.cpp | 49 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/imapwrapper.cpp | 58 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/imapwrapper.h | 4 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/pop3wrapper.cpp | 47 |
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 @@ -4,8 +4,9 @@ #include "pop3wrapper.h" #include "nntpwrapper.h" #include "mhwrapper.h" #include "mailtypes.h" +#include <qpe/global.h> #include <qprogressbar.h> #include <qapplication.h> @@ -145,26 +146,13 @@ void AbstractMail::deleteMailList(const QValueList<RecMailP>&target) //qDebug("AbstractMail::deleteMailList:: Please reimplement! "); // this is currently re-implemented in pop3wrapper and imapwrapper 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(); RecMailP mail = (*target.at( iii )); deleteMail(mail); ++iii; @@ -185,39 +173,24 @@ void AbstractMail::mvcpMailList(const QValueList<RecMailP>& t, int iii = 0; int count = t.count(); 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; + // 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 ) { - if ( ! bar.isVisible() ) - return ; - if ( incCounter % modulo == 0 ) - bar.setProgress( incCounter ); - ++incCounter; - bar.raise(); + 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); if (st) { targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); delete st; } ++iii; } - bar.hide(); if (moveit) { deleteMailList( t ); //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 @@ -8,14 +8,19 @@ #include "logindialog.h" #include <qprogressbar.h> using namespace Opie::Core; +int IMAPwrapper::mMax = 0; +int IMAPwrapper::mCurrent = 0; + IMAPwrapper::IMAPwrapper( IMAPaccount *a ) : AbstractMail() { account = a; m_imap = 0; m_Lastmbox = ""; + mCurrent = 0; + mMax = 0; } IMAPwrapper::~IMAPwrapper() { @@ -39,12 +44,32 @@ 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) { int err; bool try_tls; @@ -464,10 +489,9 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { #if 0 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) { size = item->att_data.att_static->att_data.att_rfc822_size; } @@ -885,27 +909,16 @@ void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target) int iii = 0; int count = target.count(); // 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 )); //#if 0 //qDebug("IMAP remove %d %d ", iii, mail->getNumber() ); @@ -1199,8 +1212,10 @@ encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail) void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) { if (targetWrapper != this || maxSizeInKb > 0 ) { + mMax = 0; + progress( tr("Copy")); AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit, maxSizeInKb); qDebug("IMAPwrapper::mvcpAllMails::Using generic"); // odebug << "Using generic" << oendl; return; @@ -1213,8 +1228,9 @@ void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, int err = selectMbox(fromFolder->getName()); if ( err != MAILIMAP_NO_ERROR ) { return; } + Global::statusMessage( tr("Copying mails on server...") ); int last = m_imap->imap_selection_info->sel_exists; set = mailimap_set_new_interval( 1, last ); err = mailimap_copy(m_imap,set,targetFolder.latin1()); mailimap_set_free( set ); 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 @@ -72,9 +72,11 @@ protected: /* just helpers */ static void fillBodyFields(RecPartP&target_part,mailimap_body_fields*which); 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; 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 @@ -125,13 +125,13 @@ void POP3wrapper::login() server = account->getServer().latin1(); port = account->getPort().toUInt(); 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(); } else { // cancel @@ -164,9 +164,9 @@ void POP3wrapper::login() err = mailstorage_connect(m_pop3); 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; } else { mailsession * session = m_pop3->sto_session; @@ -199,26 +199,13 @@ void POP3wrapper::deleteMailList(const QValueList<RecMailP>&target) if (!m_pop3) return; 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 "); RecMailP mail = (*target.at( iii )); int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); @@ -251,27 +238,15 @@ int POP3wrapper::deleteAllMail(const FolderP&) { if (err != MAIL_NO_ERROR) { Global::statusMessage(tr("Error getting folder info")); 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; + QWidget wid; + wid.show(); for (unsigned int i = 0; i < result; ++i) { - if ( ! bar.isVisible() ) - return 0; - if ( incCounter % modulo == 0 ) - bar.setProgress( incCounter ); - ++incCounter; + 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) { Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); res=0; |