summaryrefslogtreecommitdiffabout
path: root/kmicromail/opiemail.cpp
Side-by-side diff
Diffstat (limited to 'kmicromail/opiemail.cpp') (more/less context) (show whitespace changes)
-rw-r--r--kmicromail/opiemail.cpp38
1 files changed, 37 insertions, 1 deletions
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp
index 6e54bf4..760e3b0 100644
--- a/kmicromail/opiemail.cpp
+++ b/kmicromail/opiemail.cpp
@@ -23,2 +23,3 @@
#include "accountitem.h"
+#include "accountview.h"
#include "klocale.h"
@@ -315,3 +316,38 @@ void OpieMail::slotDownloadMail( )
{
- qDebug("slotDownloadMail( ) ");
+ QListViewItem*item = mailView->currentItem();
+ if (!item ) {
+ Global::statusMessage("Error: No item slected!");
+ return;
+ }
+ RecMailP mail = ((MailListViewItem*)item)->data();
+ Account * acc = mail->Wrapper()->getAccount();
+ if ( !acc ) {
+ Global::statusMessage("Mail is already stored locally!");
+ return;
+ }
+ QString lfName = acc->getLocalFolder();
+ //qDebug("local folder " + lfName );
+ if ( lfName.isEmpty() )
+ lfName = acc->getAccountName();
+ AbstractMail* targetMail = folderView->allAccounts()[0]->getWrapper();
+ //qDebug("target %d %d ",targetMail,mail->Wrapper() );
+ if ( targetMail == mail->Wrapper() ) {
+ Global::statusMessage("Mail is already locally stored!");
+ return;
+ }
+ if ( !targetMail->createMbox(lfName)) {
+ Global::statusMessage("Error creating folder!");
+ return;
+ }
+ Global::statusMessage("Fetching mail...please wait!");
+ qApp->processEvents();
+ encodedString*st = 0;
+ st = mail->Wrapper()->fetchRawBody(mail);
+ if ( st ) {
+ targetMail->storeMessage(st->Content(),st->Length(),lfName);
+ Global::statusMessage("Mail stored in "+ lfName);
+ delete st;
+ } else {
+ Global::statusMessage("Error: Cannot fetch mail!");
+ }
}