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 | |||
@@ -32,4 +32,22 @@ AbstractMail* AbstractMail::getWrapper(const QString&a,const QString&name) | |||
32 | } | 32 | } |
33 | 33 | ||
34 | AbstractMail* AbstractMail::getWrapper(Account*a) | ||
35 | { | ||
36 | if (!a) return 0; | ||
37 | switch (a->getType()) { | ||
38 | case MAILLIB::A_IMAP: | ||
39 | return new IMAPwrapper((IMAPaccount*)a); | ||
40 | break; | ||
41 | case MAILLIB::A_POP3: | ||
42 | return new POP3wrapper((POP3account*)a); | ||
43 | break; | ||
44 | case MAILLIB::A_NNTP: | ||
45 | return new NNTPwrapper((NNTPaccount*)a); | ||
46 | break; | ||
47 | default: | ||
48 | return 0; | ||
49 | } | ||
50 | } | ||
51 | |||
34 | encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc) | 52 | encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc) |
35 | { | 53 | { |
@@ -106,4 +124,9 @@ QString AbstractMail::defaultLocalfolder() | |||
106 | } | 124 | } |
107 | 125 | ||
126 | QString AbstractMail::draftFolder() | ||
127 | { | ||
128 | return QString("Drafts"); | ||
129 | } | ||
130 | |||
108 | /* temporary - will be removed when implemented in all classes */ | 131 | /* temporary - will be removed when implemented in all classes */ |
109 | void AbstractMail::deleteMails(const QString &,QList<RecMail> &) | 132 | 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 | |||
@@ -41,13 +41,13 @@ public: | |||
41 | virtual void mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 41 | virtual void mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
42 | 42 | ||
43 | virtual void cleanMimeCache(){}; | 43 | virtual void cleanMimeCache(){}; |
44 | /* mail box methods */ | 44 | /* mail box methods */ |
45 | /* parameter is the box to create. | 45 | /* parameter is the box to create. |
46 | * if the implementing subclass has prefixes, | 46 | * if the implementing subclass has prefixes, |
47 | * them has to be appended automatic. | 47 | * them has to be appended automatic. |
48 | */ | 48 | */ |
49 | virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); | 49 | virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); |
50 | virtual void logout()=0; | 50 | virtual void logout()=0; |
51 | 51 | ||
52 | static AbstractMail* getWrapper(IMAPaccount *a); | 52 | static AbstractMail* getWrapper(IMAPaccount *a); |
53 | static AbstractMail* getWrapper(POP3account *a); | 53 | static AbstractMail* getWrapper(POP3account *a); |
@@ -55,7 +55,9 @@ public: | |||
55 | /* mbox only! */ | 55 | /* mbox only! */ |
56 | static AbstractMail* getWrapper(const QString&a,const QString&name="Local Folders"); | 56 | static AbstractMail* getWrapper(const QString&a,const QString&name="Local Folders"); |
57 | static AbstractMail* getWrapper(Account*a); | ||
57 | 58 | ||
58 | static QString defaultLocalfolder(); | 59 | static QString defaultLocalfolder(); |
59 | 60 | static QString draftFolder(); | |
61 | |||
60 | virtual MAILLIB::ATYPE getType()const=0; | 62 | virtual MAILLIB::ATYPE getType()const=0; |
61 | virtual const QString&getName()const=0; | 63 | virtual const QString&getName()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 | |||
@@ -451,4 +451,11 @@ void Genericwrapper::parseList(QList<RecMail> &target,mailsession*session,const | |||
451 | } | 451 | } |
452 | 452 | ||
453 | if (single_fields.fld_reply_to) { | ||
454 | QStringList t = parseAddressList(single_fields.fld_reply_to->rt_addr_list); | ||
455 | if (t.count()>0) { | ||
456 | mail->setReplyto(t[0]); | ||
457 | } | ||
458 | } | ||
459 | #if 0 | ||
453 | refs = single_fields.fld_references; | 460 | refs = single_fields.fld_references; |
454 | if (refs && refs->mid_list && clist_count(refs->mid_list)) { | 461 | if (refs && refs->mid_list && clist_count(refs->mid_list)) { |
@@ -456,4 +463,5 @@ void Genericwrapper::parseList(QList<RecMail> &target,mailsession*session,const | |||
456 | mail->setReplyto(QString(text)); | 463 | mail->setReplyto(QString(text)); |
457 | } | 464 | } |
465 | #endif | ||
458 | if (single_fields.fld_in_reply_to && single_fields.fld_in_reply_to->mid_list && | 466 | if (single_fields.fld_in_reply_to && single_fields.fld_in_reply_to->mid_list && |
459 | clist_count(single_fields.fld_in_reply_to->mid_list)) { | 467 | clist_count(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 | |||
@@ -16,5 +16,6 @@ HEADERS = mailwrapper.h \ | |||
16 | mhwrapper.h \ | 16 | mhwrapper.h \ |
17 | nntpwrapper.h \ | 17 | nntpwrapper.h \ |
18 | generatemail.h | 18 | generatemail.h \ |
19 | storemail.h | ||
19 | 20 | ||
20 | SOURCES = imapwrapper.cpp \ | 21 | SOURCES = imapwrapper.cpp \ |
@@ -32,5 +33,6 @@ SOURCES = imapwrapper.cpp \ | |||
32 | mhwrapper.cpp \ | 33 | mhwrapper.cpp \ |
33 | nntpwrapper.cpp \ | 34 | nntpwrapper.cpp \ |
34 | generatemail.cpp | 35 | generatemail.cpp \ |
36 | storemail.cpp | ||
35 | 37 | ||
36 | INTERFACES = logindialogui.ui \ | 38 | INTERFACES = logindialogui.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 | |||
@@ -37,4 +37,5 @@ void RecMail::copy_old(const RecMail&old) | |||
37 | in_reply_to = old.in_reply_to; | 37 | in_reply_to = old.in_reply_to; |
38 | references = old.references; | 38 | references = old.references; |
39 | replyto = old.replyto; | ||
39 | } | 40 | } |
40 | 41 | ||
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 @@ | |||
1 | #include "storemail.h" | ||
2 | #include "mailwrapper.h" | ||
3 | #include "settings.h" | ||
4 | #include "abstractmail.h" | ||
5 | |||
6 | #include <libetpan/libetpan.h> | ||
7 | |||
8 | #include <qstring.h> | ||
9 | |||
10 | #include <stdlib.h> | ||
11 | |||
12 | Storemail::Storemail(Account*aAccount,const QString&aFolder) | ||
13 | : Generatemail() | ||
14 | { | ||
15 | wrapper = 0; | ||
16 | m_Account = aAccount; | ||
17 | m_tfolder = aFolder; | ||
18 | wrapper = AbstractMail::getWrapper(m_Account); | ||
19 | if (wrapper) { | ||
20 | wrapper->createMbox(m_tfolder); | ||
21 | } | ||
22 | } | ||
23 | |||
24 | Storemail::Storemail(const QString&dir,const QString&aFolder) | ||
25 | : Generatemail() | ||
26 | { | ||
27 | wrapper = 0; | ||
28 | m_Account = 0; | ||
29 | m_tfolder = aFolder; | ||
30 | wrapper = AbstractMail::getWrapper(dir); | ||
31 | if (wrapper) { | ||
32 | wrapper->createMbox(m_tfolder); | ||
33 | } | ||
34 | } | ||
35 | |||
36 | Storemail::Storemail(const QString&aFolder) | ||
37 | : Generatemail() | ||
38 | { | ||
39 | wrapper = 0; | ||
40 | m_Account = 0; | ||
41 | m_tfolder = aFolder; | ||
42 | wrapper = AbstractMail::getWrapper(AbstractMail::defaultLocalfolder()); | ||
43 | if (wrapper) { | ||
44 | wrapper->createMbox(m_tfolder); | ||
45 | } | ||
46 | } | ||
47 | |||
48 | Storemail::~Storemail() | ||
49 | { | ||
50 | } | ||
51 | |||
52 | int Storemail::storeMail(const Mail&mail) | ||
53 | { | ||
54 | if (!wrapper) return 0; | ||
55 | int ret = 1; | ||
56 | |||
57 | mailmime * mimeMail = 0; | ||
58 | mimeMail = createMimeMail(mail ); | ||
59 | if ( mimeMail == NULL ) { | ||
60 | qDebug( "storeMail: error creating mime mail" ); | ||
61 | return 0; | ||
62 | } | ||
63 | char *data; | ||
64 | size_t size; | ||
65 | data = 0; | ||
66 | |||
67 | mailmessage * msg = 0; | ||
68 | msg = mime_message_init(mimeMail); | ||
69 | mime_message_set_tmpdir(msg,getenv( "HOME" )); | ||
70 | int r = mailmessage_fetch(msg,&data,&size); | ||
71 | mime_message_detach_mime(msg); | ||
72 | mailmessage_free(msg); | ||
73 | msg = 0; | ||
74 | if (r != MAIL_NO_ERROR || !data) { | ||
75 | qDebug("Error fetching mime..."); | ||
76 | ret = 0; | ||
77 | } | ||
78 | |||
79 | if (ret) { | ||
80 | wrapper->storeMessage(data,size,m_tfolder); | ||
81 | } | ||
82 | |||
83 | if (data) { | ||
84 | free(data); | ||
85 | } | ||
86 | if (mimeMail) { | ||
87 | mailmime_free( mimeMail ); | ||
88 | } | ||
89 | return ret; | ||
90 | } | ||
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 @@ | |||
1 | #ifndef __STORE_MAIL_H | ||
2 | #define __STORE_MAIL_H | ||
3 | |||
4 | #include <qpe/applnk.h> | ||
5 | |||
6 | #include "generatemail.h" | ||
7 | |||
8 | class Account; | ||
9 | class Mail; | ||
10 | class AbstractMail; | ||
11 | |||
12 | class Storemail : public Generatemail | ||
13 | { | ||
14 | Q_OBJECT | ||
15 | public: | ||
16 | Storemail(Account*aAccount,const QString&aFolder); | ||
17 | Storemail(const QString&dir,const QString&aFolder); | ||
18 | Storemail(const QString&aFolder); | ||
19 | virtual ~Storemail(); | ||
20 | |||
21 | int storeMail(const Mail&mail); | ||
22 | |||
23 | protected: | ||
24 | Account* m_Account; | ||
25 | QString m_tfolder; | ||
26 | AbstractMail*wrapper; | ||
27 | }; | ||
28 | |||
29 | #endif | ||