From cebdd6de7481514ad5ea0517f7a2e8f4db422be5 Mon Sep 17 00:00:00 2001 From: zautrix Date: Fri, 10 Sep 2004 19:57:55 +0000 Subject: Added status info when deleting mails --- 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 @@ #include "nntpwrapper.h" #include "mhwrapper.h" #include "mailtypes.h" +#include #include @@ -146,24 +147,11 @@ void AbstractMail::deleteMailList(const QValueList&target) // 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; - 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 )); deleteMail(mail); @@ -186,28 +174,14 @@ void AbstractMail::mvcpMailList(const QValueList& t, 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; - 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); if (st) { @@ -216,7 +190,6 @@ void AbstractMail::mvcpMailList(const QValueList& t, } ++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 @@ -9,12 +9,17 @@ #include 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() @@ -40,10 +45,30 @@ 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; @@ -465,8 +490,7 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) #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; @@ -886,25 +910,14 @@ void IMAPwrapper::deleteMailList(const QValueList&target) 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 @@ -1199,7 +1212,9 @@ 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 ) { + 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; @@ -1214,6 +1229,7 @@ void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, 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()); 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: 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 @@ -126,11 +126,11 @@ void POP3wrapper::login() 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 { @@ -165,7 +165,7 @@ 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 { @@ -200,24 +200,11 @@ void POP3wrapper::deleteMailList(const QValueList&target) 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 )); @@ -252,25 +239,13 @@ int POP3wrapper::deleteAllMail(const FolderP&) { 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; - 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) { Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); -- cgit v0.9.0.2