Diffstat (limited to 'kmicromail/libmailwrapper/imapwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kmicromail/libmailwrapper/imapwrapper.cpp | 62 |
1 files changed, 39 insertions, 23 deletions
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 @@ -4,22 +4,27 @@ #include <qpe/global.h> #include <qapplication.h> #include "imapwrapper.h" #include "mailtypes.h" #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() { logout(); } /* to avoid to often select statements in loops etc. @@ -35,20 +40,40 @@ int IMAPwrapper::selectMbox(const QString&mbox) return err; } m_Lastmbox = mbox; return err; } 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; mailimap_capability_data * cap_data = 0; err = mailimap_capability(m_imap,&cap_data); if (err != MAILIMAP_NO_ERROR) { @@ -460,18 +485,17 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) } if (head->env_message_id) { m->setMsgid(QString(head->env_message_id)); } } 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; } } /* msg is already deleted */ if (mFlags.testBit(FLAG_DELETED) && m) { delete m; @@ -881,35 +905,24 @@ void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target) //#endif if (!m_imap) { return; } 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() ); err = selectMbox(mail->getMbox()); if ( err != MAILIMAP_NO_ERROR ) { return; } @@ -1194,31 +1207,34 @@ encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail) // dummy QValueList<int> path; return fetchRawPart(mail,path,false); } 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; return; } mailimap_set *set = 0; login(); if (!m_imap) { return; } 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 ); if ( err != MAILIMAP_NO_ERROR ) { QString error_msg = tr("Error copy mails: %1").arg(m_imap->imap_response); Global::statusMessage(error_msg); // odebug << error_msg << oendl; |