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 @@ -22,24 +22,42 @@ AbstractMail* AbstractMail::getWrapper(POP3account *a) } AbstractMail* AbstractMail::getWrapper(NNTPaccount *a) { return new NNTPwrapper(a); } 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; size_t index = 0; /* reset for recursive use! */ size_t target_length = 0; result_text = 0; int mimetype = MAILMIME_MECHANISM_7BIT; if (enc.lower()=="quoted-printable") { mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE; } else if (enc.lower()=="base64") { @@ -96,24 +114,29 @@ QString AbstractMail::gen_attachment_id() int AbstractMail::createMbox(const QString&,const Folder*,const QString& delemiter,bool) { return 0; } QString AbstractMail::defaultLocalfolder() { QString f = getenv( "HOME" ); 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> &) { } 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); 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 @@ -31,38 +31,40 @@ public: virtual encodedString* fetchRawBody(const RecMail&mail)=0; virtual void deleteMail(const RecMail&mail)=0; virtual void answeredMail(const RecMail&mail)=0; virtual int deleteAllMail(const Folder*)=0; virtual void deleteMails(const QString & FolderName,QList<RecMail> &target); virtual int deleteMbox(const Folder*)=0; 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 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: static encodedString*decode_String(const encodedString*text,const QString&enc); static QString convert_String(const char*text); static QString gen_attachment_id(); }; #endif 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 @@ -441,27 +441,35 @@ void Genericwrapper::parseList(QList<RecMail> &target,mailsession*session,const if (single_fields.fld_cc) mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); if (single_fields.fld_bcc) mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); if (single_fields.fld_orig_date) mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) ); // crashes when accessing pop3 account? if (single_fields.fld_message_id->mid_value) { 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)); } target.append(mail); } if (env_list) { mailmessage_list_free(env_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 @@ -6,41 +6,43 @@ HEADERS = mailwrapper.h \ mailtypes.h \ pop3wrapper.h \ abstractmail.h \ smtpwrapper.h \ genericwrapper.h \ mboxwrapper.h \ settings.h \ logindialog.h \ sendmailprogress.h \ statusmail.h \ mhwrapper.h \ nntpwrapper.h \ - generatemail.h + generatemail.h \ + storemail.h SOURCES = imapwrapper.cpp \ mailwrapper.cpp \ mailtypes.cpp \ pop3wrapper.cpp \ abstractmail.cpp \ smtpwrapper.cpp \ genericwrapper.cpp \ mboxwrapper.cpp \ settings.cpp \ logindialog.cpp \ sendmailprogress.cpp \ statusmail.cpp \ mhwrapper.cpp \ nntpwrapper.cpp \ - generatemail.cpp + generatemail.cpp \ + storemail.cpp INTERFACES = logindialogui.ui \ sendmailprogressui.ui INCLUDEPATH += $(OPIEDIR)/include CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX ) contains( CONFTEST, y ){ LIBS += -lqpe -letpan -lssl -lcrypto -liconv }else{ LIBS += -lqpe -letpan -lssl -lcrypto 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 @@ -27,24 +27,25 @@ void RecMail::copy_old(const RecMail&old) mbox = old.mbox; msg_id = old.msg_id; msg_size = old.msg_size; msg_number = old.msg_number; from = old.from; msg_flags = old.msg_flags; to = old.to; cc = old.cc; bcc = old.bcc; wrapper = old.wrapper; in_reply_to = old.in_reply_to; references = old.references; + replyto = old.replyto; } void RecMail::init() { to.clear(); cc.clear(); bcc.clear(); in_reply_to.clear(); references.clear(); wrapper = 0; } 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 |