summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp63
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.h4
2 files changed, 38 insertions, 29 deletions
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
index 23c678b..98634a3 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
@@ -13,2 +13,3 @@ IMAPwrapper::IMAPwrapper( IMAPaccount *a )
m_imap = 0;
+ m_Lastmbox = "";
}
@@ -20,2 +21,19 @@ IMAPwrapper::~IMAPwrapper()
+/* to avoid to often select statements in loops etc.
+ we trust that we are logged in and connection is established!*/
+int IMAPwrapper::selectMbox(const QString&mbox)
+{
+ if (mbox == m_Lastmbox) {
+ return MAILIMAP_NO_ERROR;
+ }
+ int err = mailimap_select( m_imap, (char*)mbox.latin1());
+ if ( err != MAILIMAP_NO_ERROR ) {
+ qDebug("error selecting mailbox: %s",m_imap->imap_response);
+ m_Lastmbox = "";
+ return err;
+ }
+ m_Lastmbox = mbox;
+ return err;
+}
+
void IMAPwrapper::imap_progress( size_t current, size_t maximum )
@@ -104,2 +122,3 @@ void IMAPwrapper::logout()
m_imap = 0;
+ m_Lastmbox = "";
}
@@ -108,3 +127,2 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
{
- const char *mb = 0;
int err = MAILIMAP_NO_ERROR;
@@ -112,3 +130,2 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
clistcell *current;
-// mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate,*fetchAttSize;
mailimap_fetch_type *fetchType = 0;
@@ -116,3 +133,2 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
- mb = mailbox.latin1();
login();
@@ -122,5 +138,4 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
/* select mailbox READONLY for operations */
- err = mailimap_examine( m_imap, (char*)mb);
+ err = selectMbox(mailbox);
if ( err != MAILIMAP_NO_ERROR ) {
- Global::statusMessage(tr("error selecting mailbox: %1").arg(m_imap->imap_response));
return;
@@ -391,6 +406,4 @@ RecBody IMAPwrapper::fetchBody(const RecMail&mail)
}
-
- err = mailimap_select( m_imap, (char*)mb);
+ err = selectMbox(mail.getMbox());
if ( err != MAILIMAP_NO_ERROR ) {
- qDebug("error selecting mailbox: %s",m_imap->imap_response);
return body;
@@ -464,3 +477,2 @@ encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int>
encodedString*res=new encodedString;
- const char*mb;
int err;
@@ -479,6 +491,4 @@ encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int>
if (!internal_call) {
- mb = mail.getMbox().latin1();
- err = mailimap_select( m_imap, (char*)mb);
+ err = selectMbox(mail.getMbox());
if ( err != MAILIMAP_NO_ERROR ) {
- qDebug("error selecting mailbox: %s",m_imap->imap_response);
return res;
@@ -775,6 +785,4 @@ void IMAPwrapper::deleteMail(const RecMail&mail)
}
- const char *mb = mail.getMbox().latin1();
- err = mailimap_select( m_imap, (char*)mb);
+ err = selectMbox(mail.getMbox());
if ( err != MAILIMAP_NO_ERROR ) {
- qDebug("error selecting mailbox for delete: %s",m_imap->imap_response);
return;
@@ -812,6 +820,4 @@ void IMAPwrapper::answeredMail(const RecMail&mail)
}
- const char *mb = mail.getMbox().latin1();
- err = mailimap_select( m_imap, (char*)mb);
+ err = selectMbox(mail.getMbox());
if ( err != MAILIMAP_NO_ERROR ) {
- qDebug("error selecting mailbox for mark: %s",m_imap->imap_response);
return;
@@ -874,7 +880,7 @@ int IMAPwrapper::deleteAllMail(const Folder*folder)
mailimap_store_att_flags * store_flags;
- int err = mailimap_select( m_imap, folder->getName().latin1());
+ int err = selectMbox(folder->getName());
if ( err != MAILIMAP_NO_ERROR ) {
- Global::statusMessage(tr("error selecting mailbox: %1").arg(m_imap->imap_response));
return 0;
}
+
int last = m_imap->imap_selection_info->sel_exists;
@@ -1024,3 +1030,2 @@ void IMAPwrapper::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,Abst
{
- qDebug("mvcp mail imap");
if (targetWrapper != this) {
@@ -1030,11 +1035,11 @@ void IMAPwrapper::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,Abst
}
- qDebug("Using internal");
mailimap_set *set = 0;
-
- int err = mailimap_select( m_imap, fromFolder->getName().latin1());
+ login();
+ if (!m_imap) {
+ return;
+ }
+ int err = selectMbox(fromFolder->getName());
if ( err != MAILIMAP_NO_ERROR ) {
- Global::statusMessage(tr("error selecting mailbox: %1").arg(m_imap->imap_response));
return;
}
-
int last = m_imap->imap_selection_info->sel_exists;
@@ -1042,7 +1047,9 @@ void IMAPwrapper::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,Abst
err = mailimap_copy(m_imap,set,targetFolder.latin1());
+ mailimap_set_free( set );
if ( err != MAILIMAP_NO_ERROR ) {
- Global::statusMessage(tr("error copy mails: %1").arg(m_imap->imap_response));
+ QString error_msg = tr("error copy mails: %1").arg(m_imap->imap_response);
+ Global::statusMessage(error_msg);
+ qDebug(error_msg);
return;
}
- mailimap_set_free( set );
if (moveit) {
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h
index 07c6210..99986c2 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.h
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.h
@@ -56,3 +56,4 @@ protected:
virtual encodedString*fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call);
-
+ int selectMbox(const QString&mbox);
+
void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description);
@@ -71,2 +72,3 @@ protected:
mailimap *m_imap;
+ QString m_Lastmbox;
};