author | alwin <alwin> | 2004-03-10 22:44:44 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-03-10 22:44:44 (UTC) |
commit | 9454ac48a53f3b49e03288311b71436ccacd2d04 (patch) (side-by-side diff) | |
tree | e05d40f575c87431d84c5ac374ff8ce656e6a419 /noncore/net/mail/libmailwrapper | |
parent | a72855867dedd2b4c16f703fa104b5c6175ce484 (diff) | |
download | opie-9454ac48a53f3b49e03288311b71436ccacd2d04.zip opie-9454ac48a53f3b49e03288311b71436ccacd2d04.tar.gz opie-9454ac48a53f3b49e03288311b71436ccacd2d04.tar.bz2 |
some bugfixes
When edit a mail to send and cancel is pressed the mail can stored in a draft
folder and later edit again. This moment we will not store attachments into
drafts.
Diffstat (limited to 'noncore/net/mail/libmailwrapper') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/abstractmail.cpp | 23 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/abstractmail.h | 10 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/genericwrapper.cpp | 8 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/libmailwrapper.pro | 6 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailtypes.cpp | 1 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/storemail.cpp | 90 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/storemail.h | 29 |
7 files changed, 161 insertions, 6 deletions
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 @@ -30,8 +30,26 @@ AbstractMail* AbstractMail::getWrapper(const QString&a,const QString&name) { return new MHwrapper(a,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) { qDebug("Decode string start"); char*result_text; @@ -104,8 +122,13 @@ QString AbstractMail::defaultLocalfolder() f += "/Applications/opiemail/localmail"; return f; } +QString AbstractMail::draftFolder() +{ + return QString("Drafts"); +} + /* temporary - will be removed when implemented in all classes */ void AbstractMail::deleteMails(const QString &,QList<RecMail> &) { } 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 @@ -39,25 +39,27 @@ public: virtual void mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); virtual void mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); - 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. */ virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); virtual void logout()=0; - + static AbstractMail* getWrapper(IMAPaccount *a); static AbstractMail* getWrapper(POP3account *a); static AbstractMail* getWrapper(NNTPaccount *a); /* mbox only! */ 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; virtual const QString&getName()const=0; protected: 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 @@ -449,13 +449,21 @@ void Genericwrapper::parseList(QList<RecMail> &target,mailsession*session,const mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); qDebug("Msgid == %s",mail->Msgid().latin1()); } + 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; if (refs && refs->mid_list && clist_count(refs->mid_list)) { char * text = (char*)refs->mid_list->first->data; mail->setReplyto(QString(text)); } +#endif if (single_fields.fld_in_reply_to && single_fields.fld_in_reply_to->mid_list && clist_count(single_fields.fld_in_reply_to->mid_list)) { mail->setInreply(parseInreplies(single_fields.fld_in_reply_to)); } 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 @@ -14,9 +14,10 @@ HEADERS = mailwrapper.h \ sendmailprogress.h \ statusmail.h \ mhwrapper.h \ nntpwrapper.h \ - generatemail.h + generatemail.h \ + storemail.h SOURCES = imapwrapper.cpp \ mailwrapper.cpp \ mailtypes.cpp \ @@ -30,9 +31,10 @@ SOURCES = imapwrapper.cpp \ sendmailprogress.cpp \ statusmail.cpp \ mhwrapper.cpp \ nntpwrapper.cpp \ - generatemail.cpp + generatemail.cpp \ + storemail.cpp INTERFACES = logindialogui.ui \ sendmailprogressui.ui 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 @@ -35,8 +35,9 @@ void RecMail::copy_old(const RecMail&old) bcc = old.bcc; wrapper = old.wrapper; in_reply_to = old.in_reply_to; references = old.references; + replyto = old.replyto; } void RecMail::init() { 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 |