summaryrefslogtreecommitdiffabout
path: root/kmicromail/libmailwrapper
Side-by-side diff
Diffstat (limited to 'kmicromail/libmailwrapper') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libmailwrapper/abstractmail.cpp53
-rw-r--r--kmicromail/libmailwrapper/imapwrapper.cpp62
-rw-r--r--kmicromail/libmailwrapper/imapwrapper.h4
-rw-r--r--kmicromail/libmailwrapper/pop3wrapper.cpp49
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
@@ -2,12 +2,13 @@
#include "abstractmail.h"
#include "imapwrapper.h"
#include "pop3wrapper.h"
#include "nntpwrapper.h"
#include "mhwrapper.h"
#include "mailtypes.h"
+#include <qpe/global.h>
#include <qprogressbar.h>
#include <qapplication.h>
#include <kdecore/kstandarddirs.h>
@@ -143,30 +144,17 @@ void AbstractMail::deleteMails(const QString &,const QValueList<Opie::Core::OSma
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;
- 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);
++iii;
}
}
@@ -183,43 +171,28 @@ void AbstractMail::mvcpMailList(const QValueList<RecMailP>& t,
{
encodedString*st = 0;
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;
- 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) {
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
@@ -6,18 +6,23 @@
#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();
}
@@ -37,16 +42,36 @@ int IMAPwrapper::selectMbox(const QString&mbox)
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;
@@ -462,14 +487,13 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
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 */
@@ -883,31 +907,20 @@ void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target)
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 ) {
@@ -1196,13 +1209,15 @@ encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail)
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;
@@ -1211,12 +1226,13 @@ void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder,
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);
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
@@ -70,13 +70,15 @@ protected:
void traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body,int current_recursion,QValueList<int>recList,int current_count=1);
/* 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;
};
#endif
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
@@ -123,17 +123,17 @@ void POP3wrapper::login()
int err = MAILPOP3_NO_ERROR;
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
; // odebug << "POP3: Login canceled" << oendl;
return;
@@ -162,13 +162,13 @@ void POP3wrapper::login()
pop3_mailstorage_init(m_pop3,(char*)server.latin1(), port, NULL, conntype, POP3_AUTH_TYPE_PLAIN,
(char*)user.latin1(),(char*)pass.latin1(),0,0,0);
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;
mailpop3 * mail = ( ( pop3_session_state_data * )session->sess_data )->pop3_session;
if (mail) {
@@ -197,30 +197,17 @@ void POP3wrapper::deleteMailList(const QValueList<RecMailP>&target)
{
login();
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());
if (err != MAIL_NO_ERROR) {
Global::statusMessage(tr("Error deleting mail"));
@@ -249,31 +236,19 @@ int POP3wrapper::deleteAllMail(const FolderP&) {
uint32_t result = 0;
int err = mailsession_messages_number(m_pop3->sto_session,NULL,&result);
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;
- 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));
res=0;
}
break;