summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/accountitem.cpp17
-rw-r--r--noncore/net/mail/accountitem.h2
-rw-r--r--noncore/net/mail/accountview.cpp7
-rw-r--r--noncore/net/mail/accountview.h1
-rw-r--r--noncore/net/mail/composemail.cpp90
-rw-r--r--noncore/net/mail/composemail.h25
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.cpp23
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.h10
-rw-r--r--noncore/net/mail/libmailwrapper/genericwrapper.cpp8
-rw-r--r--noncore/net/mail/libmailwrapper/libmailwrapper.pro6
-rw-r--r--noncore/net/mail/libmailwrapper/mailtypes.cpp1
-rw-r--r--noncore/net/mail/libmailwrapper/storemail.cpp90
-rw-r--r--noncore/net/mail/libmailwrapper/storemail.h29
-rw-r--r--noncore/net/mail/mailistviewitem.cpp7
-rw-r--r--noncore/net/mail/mailistviewitem.h6
-rw-r--r--noncore/net/mail/nntpgroupsdlg.cpp2
-rw-r--r--noncore/net/mail/opiemail.cpp23
-rw-r--r--noncore/net/mail/opiemail.h1
18 files changed, 309 insertions, 39 deletions
diff --git a/noncore/net/mail/accountitem.cpp b/noncore/net/mail/accountitem.cpp
index 0d636a4..396dcb7 100644
--- a/noncore/net/mail/accountitem.cpp
+++ b/noncore/net/mail/accountitem.cpp
@@ -915,5 +915,5 @@ void MHfolderItem::initName()
setPixmap( 0, PIXMAP_INBOXFOLDER);
- }
- else
- {
+ } else if (bName.lower() == "drafts") {
+ setPixmap(0, Resource::loadPixmap("inline/edit"));
+ } else {
setPixmap( 0, PIXMAP_MBOXFOLDER );
@@ -1025,2 +1025,8 @@ void MHfolderItem::contextMenuSelected(int which)
+bool MHfolderItem::isDraftfolder()
+{
+ if (folder && folder->getName()==AbstractMail::defaultLocalfolder()+"/"+AbstractMail::draftFolder()) return true;
+ return false;
+}
+
/**
@@ -1129 +1135,6 @@ AccountViewItem*AccountViewItem::findSubItem(const QString&path,AccountViewItem*
}
+
+bool AccountViewItem::isDraftfolder()
+{
+ return false;
+}
diff --git a/noncore/net/mail/accountitem.h b/noncore/net/mail/accountitem.h
index f3c0f5d..eb3baa3 100644
--- a/noncore/net/mail/accountitem.h
+++ b/noncore/net/mail/accountitem.h
@@ -32,2 +32,3 @@ public:
virtual bool matchName(const QString&name)const;
+ virtual bool isDraftfolder();
@@ -195,2 +196,3 @@ public:
virtual Folder*getFolder();
+ virtual bool isDraftfolder();
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp
index 4375044..7938d4f 100644
--- a/noncore/net/mail/accountview.cpp
+++ b/noncore/net/mail/accountview.cpp
@@ -170 +170,8 @@ void AccountView::downloadMails(Folder*fromFolder,AbstractMail*fromWrapper)
}
+
+bool AccountView::currentisDraft()
+{
+ AccountViewItem *view = static_cast<AccountViewItem *>(currentItem());
+ if (!view) return false;
+ return view->isDraftfolder();
+}
diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h
index 9f92090..5000202 100644
--- a/noncore/net/mail/accountview.h
+++ b/noncore/net/mail/accountview.h
@@ -25,2 +25,3 @@ public:
virtual void downloadMails(Folder*fromFolder,AbstractMail*fromWrapper);
+ virtual bool currentisDraft();
diff --git a/noncore/net/mail/composemail.cpp b/noncore/net/mail/composemail.cpp
index b5cd75b..b9c9cbc 100644
--- a/noncore/net/mail/composemail.cpp
+++ b/noncore/net/mail/composemail.cpp
@@ -11,2 +11,5 @@
#include <libmailwrapper/smtpwrapper.h>
+#include <libmailwrapper/storemail.h>
+#include <libmailwrapper/abstractmail.h>
+#include <libmailwrapper/mailtypes.h>
@@ -126,3 +129,3 @@ void ComposeMail::pickAddressReply()
-void ComposeMail::fillValues( int current )
+void ComposeMail::fillValues( int )
{
@@ -187,18 +190,19 @@ void ComposeMail::accept()
#endif
- Mail *mail = new Mail();
+ Mail mail;
SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() );
- mail->setMail(fromBox->currentText());
+ mail.setMail(fromBox->currentText());
if ( !toLine->text().isEmpty() ) {
- mail->setTo( toLine->text() );
+ mail.setTo( toLine->text() );
} else {
- qDebug( "No Reciever spezified -> returning" );
+ QMessageBox::warning(0,tr("Sending mail"),
+ tr("No Receiver spezified" ) );
return;
}
- mail->setName(senderNameEdit->text());
- mail->setCC( ccLine->text() );
- mail->setBCC( bccLine->text() );
- mail->setReply( replyLine->text() );
- mail->setSubject( subjectLine->text() );
+ mail.setName(senderNameEdit->text());
+ mail.setCC( ccLine->text() );
+ mail.setBCC( bccLine->text() );
+ mail.setReply( replyLine->text() );
+ mail.setSubject( subjectLine->text() );
if (!m_replyid.isEmpty()) {
@@ -206,3 +210,3 @@ void ComposeMail::accept()
ids.append(m_replyid);
- mail->setInreply(ids);
+ mail.setInreply(ids);
}
@@ -214,6 +218,6 @@ void ComposeMail::accept()
qDebug(txt);
- mail->setMessage( txt );
+ mail.setMessage( txt );
AttachViewItem *it = (AttachViewItem *) attList->firstChild();
while ( it != NULL ) {
- mail->addAttachment( it->getAttachment() );
+ mail.addAttachment( it->getAttachment() );
it = (AttachViewItem *) it->nextSibling();
@@ -222,3 +226,3 @@ void ComposeMail::accept()
SMTPwrapper wrapper( smtp );
- wrapper.sendMail( *mail,checkBoxLater->isChecked() );
+ wrapper.sendMail( mail,checkBoxLater->isChecked() );
@@ -227,2 +231,60 @@ void ComposeMail::accept()
+void ComposeMail::reject()
+{
+ int yesno = QMessageBox::warning(0,tr("Store message"),
+ tr("Store message into drafts?"),
+ tr("Yes"),
+ tr("No"),QString::null,0,1);
+
+ if (yesno == 0) {
+ Mail mail;
+ mail.setMail(fromBox->currentText());
+ mail.setTo( toLine->text() );
+ mail.setName(senderNameEdit->text());
+ mail.setCC( ccLine->text() );
+ mail.setBCC( bccLine->text() );
+ mail.setReply( replyLine->text() );
+ mail.setSubject( subjectLine->text() );
+ if (!m_replyid.isEmpty()) {
+ QStringList ids;
+ ids.append(m_replyid);
+ mail.setInreply(ids);
+ }
+ QString txt = message->text();
+ if ( !sigMultiLine->text().isEmpty() ) {
+ txt.append( "\n--\n" );
+ txt.append( sigMultiLine->text() );
+ }
+ qDebug(txt);
+ mail.setMessage( txt );
+
+ /* only use the default drafts folder name! */
+ Storemail wrapper(AbstractMail::draftFolder());
+ wrapper.storeMail(mail);
+
+ AttachViewItem *it = (AttachViewItem *) attList->firstChild();
+ /* attachments we will ignore! */
+ if ( it != NULL ) {
+ QMessageBox::warning(0,tr("Store message"),
+ tr("<center>Attachments will not be stored in \"Draft\" folder</center>"));
+ }
+ }
+ QDialog::reject();
+}
+
+ComposeMail::~ComposeMail()
+{
+}
+
+void ComposeMail::reEditMail(const RecMail&current)
+{
+ RecMail data = current;
+ message->setText(data.Wrapper()->fetchBody(current).Bodytext());
+ subjectLine->setText( data.getSubject());
+ toLine->setText(data.To().join(","));
+ ccLine->setText(data.CC().join(","));
+ bccLine->setText(data.Bcc().join(","));
+ replyLine->setText(data.Replyto());
+}
+
AttachViewItem::AttachViewItem( QListView *parent, Attachment *att )
diff --git a/noncore/net/mail/composemail.h b/noncore/net/mail/composemail.h
index 886fb1d..1b9fc79 100644
--- a/noncore/net/mail/composemail.h
+++ b/noncore/net/mail/composemail.h
@@ -15,11 +15,11 @@ class AddressPicker : public AddressPickerUI
{
- Q_OBJECT
+ Q_OBJECT
public:
- AddressPicker( QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags flags = 0 );
- static QString getNames();
+ AddressPicker( QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags flags = 0 );
+ static QString getNames();
protected:
- QString selectedNames;
- void accept();
+ QString selectedNames;
+ void accept();
@@ -27,2 +27,3 @@ protected:
+class RecMail;
@@ -31,5 +32,8 @@ class ComposeMail : public ComposeMailUI
Q_OBJECT
-
+
public:
ComposeMail( Settings *s, QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags flags = 0 );
+ virtual ~ComposeMail();
+
+ void reEditMail(const RecMail&current);
@@ -45,3 +49,4 @@ protected slots:
void accept();
-
+ void reject();
+
private slots:
@@ -64,8 +69,8 @@ class AttachViewItem : public QListViewItem
{
-public:
+public:
AttachViewItem( QListView *parent, Attachment *att );
- Attachment *getAttachment() { return attachment; }
+ Attachment *getAttachment() { return attachment; }
private:
- Attachment *attachment;
+ Attachment *attachment;
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.cpp b/noncore/net/mail/libmailwrapper/abstractmail.cpp
index 9960f88..d71d35c 100644
--- a/noncore/net/mail/libmailwrapper/abstractmail.cpp
+++ b/noncore/net/mail/libmailwrapper/abstractmail.cpp
@@ -33,2 +33,20 @@ AbstractMail* AbstractMail::getWrapper(const QString&a,const QString&name)
+AbstractMail* AbstractMail::getWrapper(Account*a)
+{
+ if (!a) return 0;
+ switch (a->getType()) {
+ case MAILLIB::A_IMAP:
+ return new IMAPwrapper((IMAPaccount*)a);
+ break;
+ case MAILLIB::A_POP3:
+ return new POP3wrapper((POP3account*)a);
+ break;
+ case MAILLIB::A_NNTP:
+ return new NNTPwrapper((NNTPaccount*)a);
+ break;
+ default:
+ return 0;
+ }
+}
+
encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc)
@@ -107,2 +125,7 @@ QString AbstractMail::defaultLocalfolder()
+QString AbstractMail::draftFolder()
+{
+ return QString("Drafts");
+}
+
/* temporary - will be removed when implemented in all classes */
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h
index 442ebfe..d377452 100644
--- a/noncore/net/mail/libmailwrapper/abstractmail.h
+++ b/noncore/net/mail/libmailwrapper/abstractmail.h
@@ -42,6 +42,6 @@ public:
- virtual void cleanMimeCache(){};
+ virtual void cleanMimeCache(){};
/* mail box methods */
/* parameter is the box to create.
- * if the implementing subclass has prefixes,
+ * if the implementing subclass has prefixes,
* them has to be appended automatic.
@@ -50,3 +50,3 @@ public:
virtual void logout()=0;
-
+
static AbstractMail* getWrapper(IMAPaccount *a);
@@ -56,5 +56,7 @@ public:
static AbstractMail* getWrapper(const QString&a,const QString&name="Local Folders");
+ static AbstractMail* getWrapper(Account*a);
static QString defaultLocalfolder();
-
+ static QString draftFolder();
+
virtual MAILLIB::ATYPE getType()const=0;
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.cpp b/noncore/net/mail/libmailwrapper/genericwrapper.cpp
index 137a6ef..ffa049f 100644
--- a/noncore/net/mail/libmailwrapper/genericwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/genericwrapper.cpp
@@ -452,2 +452,9 @@ void Genericwrapper::parseList(QList<RecMail> &target,mailsession*session,const
+ if (single_fields.fld_reply_to) {
+ QStringList t = parseAddressList(single_fields.fld_reply_to->rt_addr_list);
+ if (t.count()>0) {
+ mail->setReplyto(t[0]);
+ }
+ }
+#if 0
refs = single_fields.fld_references;
@@ -457,2 +464,3 @@ void Genericwrapper::parseList(QList<RecMail> &target,mailsession*session,const
}
+#endif
if (single_fields.fld_in_reply_to && single_fields.fld_in_reply_to->mid_list &&
diff --git a/noncore/net/mail/libmailwrapper/libmailwrapper.pro b/noncore/net/mail/libmailwrapper/libmailwrapper.pro
index cb1e573..d28079e 100644
--- a/noncore/net/mail/libmailwrapper/libmailwrapper.pro
+++ b/noncore/net/mail/libmailwrapper/libmailwrapper.pro
@@ -17,3 +17,4 @@ HEADERS = mailwrapper.h \
nntpwrapper.h \
- generatemail.h
+ generatemail.h \
+ storemail.h
@@ -33,3 +34,4 @@ SOURCES = imapwrapper.cpp \
nntpwrapper.cpp \
- generatemail.cpp
+ generatemail.cpp \
+ storemail.cpp
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.cpp b/noncore/net/mail/libmailwrapper/mailtypes.cpp
index e4646d9..49b3caa 100644
--- a/noncore/net/mail/libmailwrapper/mailtypes.cpp
+++ b/noncore/net/mail/libmailwrapper/mailtypes.cpp
@@ -38,2 +38,3 @@ void RecMail::copy_old(const RecMail&old)
references = old.references;
+ replyto = old.replyto;
}
diff --git a/noncore/net/mail/libmailwrapper/storemail.cpp b/noncore/net/mail/libmailwrapper/storemail.cpp
new file mode 100644
index 0000000..53101f8
--- a/dev/null
+++ b/noncore/net/mail/libmailwrapper/storemail.cpp
@@ -0,0 +1,90 @@
+#include "storemail.h"
+#include "mailwrapper.h"
+#include "settings.h"
+#include "abstractmail.h"
+
+#include <libetpan/libetpan.h>
+
+#include <qstring.h>
+
+#include <stdlib.h>
+
+Storemail::Storemail(Account*aAccount,const QString&aFolder)
+ : Generatemail()
+{
+ wrapper = 0;
+ m_Account = aAccount;
+ m_tfolder = aFolder;
+ wrapper = AbstractMail::getWrapper(m_Account);
+ if (wrapper) {
+ wrapper->createMbox(m_tfolder);
+ }
+}
+
+Storemail::Storemail(const QString&dir,const QString&aFolder)
+ : Generatemail()
+{
+ wrapper = 0;
+ m_Account = 0;
+ m_tfolder = aFolder;
+ wrapper = AbstractMail::getWrapper(dir);
+ if (wrapper) {
+ wrapper->createMbox(m_tfolder);
+ }
+}
+
+Storemail::Storemail(const QString&aFolder)
+ : Generatemail()
+{
+ wrapper = 0;
+ m_Account = 0;
+ m_tfolder = aFolder;
+ wrapper = AbstractMail::getWrapper(AbstractMail::defaultLocalfolder());
+ if (wrapper) {
+ wrapper->createMbox(m_tfolder);
+ }
+}
+
+Storemail::~Storemail()
+{
+}
+
+int Storemail::storeMail(const Mail&mail)
+{
+ if (!wrapper) return 0;
+ int ret = 1;
+
+ mailmime * mimeMail = 0;
+ mimeMail = createMimeMail(mail );
+ if ( mimeMail == NULL ) {
+ qDebug( "storeMail: error creating mime mail" );
+ return 0;
+ }
+ char *data;
+ size_t size;
+ data = 0;
+
+ mailmessage * msg = 0;
+ msg = mime_message_init(mimeMail);
+ mime_message_set_tmpdir(msg,getenv( "HOME" ));
+ int r = mailmessage_fetch(msg,&data,&size);
+ mime_message_detach_mime(msg);
+ mailmessage_free(msg);
+ msg = 0;
+ if (r != MAIL_NO_ERROR || !data) {
+ qDebug("Error fetching mime...");
+ ret = 0;
+ }
+
+ if (ret) {
+ wrapper->storeMessage(data,size,m_tfolder);
+ }
+
+ if (data) {
+ free(data);
+ }
+ if (mimeMail) {
+ mailmime_free( mimeMail );
+ }
+ return ret;
+}
diff --git a/noncore/net/mail/libmailwrapper/storemail.h b/noncore/net/mail/libmailwrapper/storemail.h
new file mode 100644
index 0000000..872c981
--- a/dev/null
+++ b/noncore/net/mail/libmailwrapper/storemail.h
@@ -0,0 +1,29 @@
+#ifndef __STORE_MAIL_H
+#define __STORE_MAIL_H
+
+#include <qpe/applnk.h>
+
+#include "generatemail.h"
+
+class Account;
+class Mail;
+class AbstractMail;
+
+class Storemail : public Generatemail
+{
+ Q_OBJECT
+public:
+ Storemail(Account*aAccount,const QString&aFolder);
+ Storemail(const QString&dir,const QString&aFolder);
+ Storemail(const QString&aFolder);
+ virtual ~Storemail();
+
+ int storeMail(const Mail&mail);
+
+protected:
+ Account* m_Account;
+ QString m_tfolder;
+ AbstractMail*wrapper;
+};
+
+#endif
diff --git a/noncore/net/mail/mailistviewitem.cpp b/noncore/net/mail/mailistviewitem.cpp
index f224dc3..75633ef 100644
--- a/noncore/net/mail/mailistviewitem.cpp
+++ b/noncore/net/mail/mailistviewitem.cpp
@@ -1,2 +1,3 @@
#include "mailistviewitem.h"
+#include <libmailwrapper/abstractmail.h>
#include <qtextstream.h>
@@ -65 +66,7 @@ const RecMail& MailListViewItem::data()const
}
+
+MAILLIB::ATYPE MailListViewItem::wrapperType()
+{
+ if (!mail_data.Wrapper()) return MAILLIB::A_UNDEFINED;
+ return mail_data.Wrapper()->getType();
+}
diff --git a/noncore/net/mail/mailistviewitem.h b/noncore/net/mail/mailistviewitem.h
index 3b352a2..f736de0 100644
--- a/noncore/net/mail/mailistviewitem.h
+++ b/noncore/net/mail/mailistviewitem.h
@@ -5,2 +5,3 @@
#include <libmailwrapper/mailtypes.h>
+#include <libmailwrapper/maildefines.h>
@@ -11,3 +12,3 @@ public:
virtual ~MailListViewItem(){}
-
+
void storeData(const RecMail&data);
@@ -15,3 +16,4 @@ public:
void showEntry();
-
+ MAILLIB::ATYPE wrapperType();
+
protected:
diff --git a/noncore/net/mail/nntpgroupsdlg.cpp b/noncore/net/mail/nntpgroupsdlg.cpp
index 752ce3c..c94d9fa 100644
--- a/noncore/net/mail/nntpgroupsdlg.cpp
+++ b/noncore/net/mail/nntpgroupsdlg.cpp
@@ -8,3 +8,3 @@
NNTPGroupsDlg::NNTPGroupsDlg(NNTPaccount *account,QWidget * parent, const char * name)
- : QDialog(parent,name,true)
+ : QDialog(parent,name,true,WStyle_ContextHelp)
{
diff --git a/noncore/net/mail/opiemail.cpp b/noncore/net/mail/opiemail.cpp
index 61e7dc4..d95b3c9 100644
--- a/noncore/net/mail/opiemail.cpp
+++ b/noncore/net/mail/opiemail.cpp
@@ -179,3 +179,3 @@ void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int )
if (!mailView->currentItem()) return;
- RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data();
+ MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType();
/* just the RIGHT button - or hold on pda */
@@ -187,3 +187,3 @@ void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int )
{
- if (mail.Wrapper()->getType()==MAILLIB::A_NNTP) {
+ if (mailtype==MAILLIB::A_NNTP) {
m->insertItem(tr("Read this posting"),this,SLOT(displayMail()));
@@ -191,2 +191,5 @@ void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int )
} else {
+ if (folderView->currentisDraft()) {
+ m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail()));
+ }
m->insertItem(tr("Read this mail"),this,SLOT(displayMail()));
@@ -233,3 +236,7 @@ void OpieMail::mailLeftClicked(int button, QListViewItem *item,const QPoint&,int
if (!item) return;
- displayMail();
+ if (folderView->currentisDraft()) {
+ reEditMail();
+ } else {
+ displayMail();
+ }
}
@@ -261 +268,11 @@ void OpieMail::slotMoveCopyMail()
}
+
+void OpieMail::reEditMail()
+{
+ if (!mailView->currentItem()) return;
+
+ ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp );
+ compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data());
+ compose.slotAdjustColumns();
+ QPEApplication::execDialog( &compose );
+}
diff --git a/noncore/net/mail/opiemail.h b/noncore/net/mail/opiemail.h
index 5821856..88c7ea1 100644
--- a/noncore/net/mail/opiemail.h
+++ b/noncore/net/mail/opiemail.h
@@ -32,2 +32,3 @@ protected slots:
virtual void slotMoveCopyMail();
+ virtual void reEditMail();