summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/mail/accountview.cpp40
-rw-r--r--noncore/net/mail/accountview.h1
-rw-r--r--noncore/net/mail/defines.h3
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.cpp19
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.h2
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp31
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.h1
7 files changed, 83 insertions, 14 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp
index eea021f..b7de7b9 100644
--- a/noncore/net/mail/accountview.cpp
+++ b/noncore/net/mail/accountview.cpp
@@ -8,4 +8,5 @@
#include <qpopupmenu.h>
+#define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );}
/**
* POP3 Account stuff
@@ -16,5 +17,12 @@ POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent )
account = a;
wrapper = AbstractMail::getWrapper( account );
- setPixmap( 0, PIXMAP_POP3FOLDER );
+ SETPIX(PIXMAP_POP3FOLDER);
+#if 0
+ if (!account->getOffline()) {
+ setPixmap( 0, );
+ } else {
+ setPixmap( 0, PIXMAP_OFFLINE );
+ }
+#endif
setText( 0, account->getAccountName() );
setOpen( true );
@@ -33,4 +41,9 @@ AbstractMail *POP3viewItem::getWrapper()
void POP3viewItem::refresh( QList<RecMail> & )
{
+ refresh();
+}
+
+void POP3viewItem::refresh()
+{
if (account->getOffline()) return;
QList<Folder> *folders = wrapper->listFolders();
@@ -90,4 +103,6 @@ void POP3viewItem::setOnOffline()
account->setOffline(!account->getOffline());
account->save();
+ SETPIX(PIXMAP_POP3FOLDER);
+ refresh();
}
@@ -179,5 +194,5 @@ IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent )
account = a;
wrapper = AbstractMail::getWrapper( account );
- setPixmap( 0, PIXMAP_IMAPFOLDER );
+ SETPIX(PIXMAP_IMAPFOLDER);
setText( 0, account->getAccountName() );
setOpen( true );
@@ -338,4 +353,5 @@ void IMAPviewItem::contextMenuSelected(int id)
account->setOffline(!account->getOffline());
account->save();
+ SETPIX(PIXMAP_IMAPFOLDER);
refreshFolders(false);
break;
@@ -666,5 +682,4 @@ void AccountView::setupFolderselect(Selectstore*sels)
void AccountView::downloadMails(Folder*fromFolder,AbstractMail*fromWrapper)
{
- unsigned int i = 0;
AbstractMail*targetMail = 0;
QString targetFolder = "";
@@ -678,16 +693,13 @@ void AccountView::downloadMails(Folder*fromFolder,AbstractMail*fromWrapper)
return;
}
-
- QList<RecMail> t;
- fromWrapper->listMessages(fromFolder->getName(),t);
- encodedString*st = 0;
- for (i = 0; i < t.count();++i) {
- RecMail*r = t.at(i);
- st = fromWrapper->fetchRawBody(*r);
- if (st) {
- targetMail->storeMessage(st->Content(),st->Length(),targetFolder);
- delete st;
- }
+ if (sels.newFolder() && !targetMail->createMbox(targetFolder)) {
+ QMessageBox::critical(0,tr("Error creating new Folder"),
+ tr("<center>Error while creating<br>new folder - breaking.</center>"));
+ return;
}
+ qDebug("Targetfolder: %s",targetFolder.latin1());
+ qDebug("Fromfolder: %s",fromFolder->getName().latin1());
+ fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails());
+ refreshCurrent();
}
diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h
index 48f52c7..df916c1 100644
--- a/noncore/net/mail/accountview.h
+++ b/noncore/net/mail/accountview.h
@@ -49,4 +49,5 @@ public:
protected:
POP3account *account;
+ virtual void refresh();
AbstractMail *wrapper;
void disconnect();
diff --git a/noncore/net/mail/defines.h b/noncore/net/mail/defines.h
index ebe8e08..d840f09 100644
--- a/noncore/net/mail/defines.h
+++ b/noncore/net/mail/defines.h
@@ -17,4 +17,6 @@
#define PIC_LOCALFOLDER "mail/localfolder"
+#define PIC_OFFLINE "mail/notconnected"
+
#define ICON_COMPOSEMAIL QIconSet( Resource::loadPixmap( PIC_COMPOSEMAIL ) )
#define ICON_SENDQUEUED QIconSet( Resource::loadPixmap( PIC_SENDQUEUED ) )
@@ -31,4 +33,5 @@
#define PIXMAP_OUTBOXFOLDER QPixmap( Resource::loadPixmap( PIC_OUTBOXFOLDER) )
#define PIXMAP_LOCALFOLDER QPixmap( Resource::loadPixmap( PIC_LOCALFOLDER) )
+#define PIXMAP_OFFLINE QPixmap( Resource::loadPixmap( PIC_OFFLINE) )
#define IMAP_PORT "143"
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.cpp b/noncore/net/mail/libmailwrapper/abstractmail.cpp
index 3dd2fce..4b4c728 100644
--- a/noncore/net/mail/libmailwrapper/abstractmail.cpp
+++ b/noncore/net/mail/libmailwrapper/abstractmail.cpp
@@ -105,2 +105,21 @@ void AbstractMail::deleteMails(const QString &,QList<RecMail> &)
{
}
+
+void AbstractMail::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
+{
+ QList<RecMail> t;
+ listMessages(fromFolder->getName(),t);
+ encodedString*st = 0;
+ while (t.count()>0) {
+ RecMail*r = t.at(0);
+ st = fetchRawBody(*r);
+ if (st) {
+ targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder);
+ delete st;
+ }
+ t.removeFirst();
+ }
+ if (moveit) {
+ deleteAllMail(fromFolder);
+ }
+}
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h
index 15d83cb..8debaae 100644
--- a/noncore/net/mail/libmailwrapper/abstractmail.h
+++ b/noncore/net/mail/libmailwrapper/abstractmail.h
@@ -36,4 +36,6 @@ public:
virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0;
+ virtual void mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
+
virtual void cleanMimeCache(){};
/* mail box methods */
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
index bb74de9..23c678b 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
@@ -1010,4 +1010,5 @@ const QString&IMAPwrapper::getType()const
const QString&IMAPwrapper::getName()const
{
+ qDebug("Get name: %s",account->getAccountName().latin1());
return account->getAccountName();
}
@@ -1019,2 +1020,32 @@ encodedString* IMAPwrapper::fetchRawBody(const RecMail&mail)
return fetchRawPart(mail,path,false);
}
+
+void IMAPwrapper::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
+{
+ qDebug("mvcp mail imap");
+ if (targetWrapper != this) {
+ AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit);
+ qDebug("Using generic");
+ return;
+ }
+ qDebug("Using internal");
+ mailimap_set *set = 0;
+
+ int err = mailimap_select( m_imap, fromFolder->getName().latin1());
+ 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;
+ set = mailimap_set_new_interval( 1, last );
+ err = mailimap_copy(m_imap,set,targetFolder.latin1());
+ if ( err != MAILIMAP_NO_ERROR ) {
+ Global::statusMessage(tr("error copy mails: %1").arg(m_imap->imap_response));
+ return;
+ }
+ mailimap_set_free( set );
+ if (moveit) {
+ deleteAllMail(fromFolder);
+ }
+}
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h
index b2bd7e9..07c6210 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.h
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.h
@@ -32,4 +32,5 @@ public:
virtual int deleteAllMail(const Folder*folder);
virtual void storeMessage(const char*msg,size_t length, const QString&folder);
+ virtual void mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
virtual RecBody fetchBody(const RecMail&mail);