-rw-r--r-- | kmicromail/opiemail.cpp | 38 |
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 @@ -20,8 +20,9 @@ #include "viewmail.h" #include "selectstore.h" #include "selectsmtp.h" #include "accountitem.h" +#include "accountview.h" #include "klocale.h" #include <qmessagebox.h> #include <qtimer.h> @@ -312,9 +313,44 @@ void OpieMail::closeViewMail(ViewMail * vm) } 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!"); + } } void OpieMail::deleteAndDisplayNextMail(ViewMail * vm) |