Diffstat (limited to 'noncore/net/mail/libmailwrapper') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/abstractmail.cpp | 9 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/abstractmail.h | 4 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 6 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.h | 2 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mboxwrapper.cpp | 9 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mboxwrapper.h | 6 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.cpp | 6 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.h | 1 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/settings.cpp | 12 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/settings.h | 5 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/smtpwrapper.cpp | 10 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/smtpwrapper.h | 4 |
12 files changed, 58 insertions, 16 deletions
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.cpp b/noncore/net/mail/libmailwrapper/abstractmail.cpp index 80d0b52..3dd2fce 100644 --- a/noncore/net/mail/libmailwrapper/abstractmail.cpp +++ b/noncore/net/mail/libmailwrapper/abstractmail.cpp | |||
@@ -12,27 +12,27 @@ | |||
12 | #include <libetpan/mailmime.h> | 12 | #include <libetpan/mailmime.h> |
13 | 13 | ||
14 | AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) | 14 | AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) |
15 | { | 15 | { |
16 | return new IMAPwrapper(a); | 16 | return new IMAPwrapper(a); |
17 | } | 17 | } |
18 | 18 | ||
19 | AbstractMail* AbstractMail::getWrapper(POP3account *a) | 19 | AbstractMail* AbstractMail::getWrapper(POP3account *a) |
20 | { | 20 | { |
21 | return new POP3wrapper(a); | 21 | return new POP3wrapper(a); |
22 | } | 22 | } |
23 | 23 | ||
24 | AbstractMail* AbstractMail::getWrapper(const QString&a) | 24 | AbstractMail* AbstractMail::getWrapper(const QString&a,const QString&name) |
25 | { | 25 | { |
26 | return new MBOXwrapper(a); | 26 | return new MBOXwrapper(a,name); |
27 | } | 27 | } |
28 | 28 | ||
29 | encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc) | 29 | encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc) |
30 | { | 30 | { |
31 | qDebug("Decode string start"); | 31 | qDebug("Decode string start"); |
32 | char*result_text; | 32 | char*result_text; |
33 | size_t index = 0; | 33 | size_t index = 0; |
34 | /* reset for recursive use! */ | 34 | /* reset for recursive use! */ |
35 | size_t target_length = 0; | 35 | size_t target_length = 0; |
36 | result_text = 0; | 36 | result_text = 0; |
37 | int mimetype = MAILMIME_MECHANISM_7BIT; | 37 | int mimetype = MAILMIME_MECHANISM_7BIT; |
38 | if (enc.lower()=="quoted-printable") { | 38 | if (enc.lower()=="quoted-printable") { |
@@ -90,12 +90,17 @@ QString AbstractMail::gen_attachment_id() | |||
90 | 90 | ||
91 | int AbstractMail::createMbox(const QString&,const Folder*,const QString& delemiter,bool) | 91 | int AbstractMail::createMbox(const QString&,const Folder*,const QString& delemiter,bool) |
92 | { | 92 | { |
93 | return 0; | 93 | return 0; |
94 | } | 94 | } |
95 | 95 | ||
96 | QString AbstractMail::defaultLocalfolder() | 96 | QString AbstractMail::defaultLocalfolder() |
97 | { | 97 | { |
98 | QString f = getenv( "HOME" ); | 98 | QString f = getenv( "HOME" ); |
99 | f += "/Applications/opiemail/localmail"; | 99 | f += "/Applications/opiemail/localmail"; |
100 | return f; | 100 | return f; |
101 | } | 101 | } |
102 | |||
103 | /* temporary - will be removed when implemented in all classes */ | ||
104 | void AbstractMail::deleteMails(const QString &,QList<RecMail> &) | ||
105 | { | ||
106 | } | ||
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h index 9770991..15d83cb 100644 --- a/noncore/net/mail/libmailwrapper/abstractmail.h +++ b/noncore/net/mail/libmailwrapper/abstractmail.h | |||
@@ -22,39 +22,41 @@ public: | |||
22 | virtual QList<Folder>* listFolders()=0; | 22 | virtual QList<Folder>* listFolders()=0; |
23 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0; | 23 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0; |
24 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0; | 24 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0; |
25 | virtual RecBody fetchBody(const RecMail&mail)=0; | 25 | virtual RecBody fetchBody(const RecMail&mail)=0; |
26 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0; | 26 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0; |
27 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0; | 27 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0; |
28 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0; | 28 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0; |
29 | virtual encodedString* fetchRawBody(const RecMail&mail)=0; | 29 | virtual encodedString* fetchRawBody(const RecMail&mail)=0; |
30 | 30 | ||
31 | virtual void deleteMail(const RecMail&mail)=0; | 31 | virtual void deleteMail(const RecMail&mail)=0; |
32 | virtual void answeredMail(const RecMail&mail)=0; | 32 | virtual void answeredMail(const RecMail&mail)=0; |
33 | virtual int deleteAllMail(const Folder*)=0; | 33 | virtual int deleteAllMail(const Folder*)=0; |
34 | virtual void deleteMails(const QString & FolderName,QList<RecMail> &target); | ||
34 | virtual int deleteMbox(const Folder*)=0; | 35 | virtual int deleteMbox(const Folder*)=0; |
35 | virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0; | 36 | virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0; |
36 | 37 | ||
37 | virtual void cleanMimeCache(){}; | 38 | virtual void cleanMimeCache(){}; |
38 | /* mail box methods */ | 39 | /* mail box methods */ |
39 | /* parameter is the box to create. | 40 | /* parameter is the box to create. |
40 | * if the implementing subclass has prefixes, | 41 | * if the implementing subclass has prefixes, |
41 | * them has to be appended automatic. | 42 | * them has to be appended automatic. |
42 | */ | 43 | */ |
43 | virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); | 44 | virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); |
44 | virtual void logout()=0; | 45 | virtual void logout()=0; |
45 | 46 | ||
46 | static AbstractMail* getWrapper(IMAPaccount *a); | 47 | static AbstractMail* getWrapper(IMAPaccount *a); |
47 | static AbstractMail* getWrapper(POP3account *a); | 48 | static AbstractMail* getWrapper(POP3account *a); |
48 | /* mbox only! */ | 49 | /* mbox only! */ |
49 | static AbstractMail* getWrapper(const QString&a); | 50 | static AbstractMail* getWrapper(const QString&a,const QString&name="Local Folders"); |
50 | 51 | ||
51 | static QString defaultLocalfolder(); | 52 | static QString defaultLocalfolder(); |
52 | 53 | ||
53 | virtual const QString&getType()const=0; | 54 | virtual const QString&getType()const=0; |
55 | virtual const QString&getName()const=0; | ||
54 | 56 | ||
55 | protected: | 57 | protected: |
56 | static encodedString*decode_String(const encodedString*text,const QString&enc); | 58 | static encodedString*decode_String(const encodedString*text,const QString&enc); |
57 | static QString convert_String(const char*text); | 59 | static QString convert_String(const char*text); |
58 | static QString gen_attachment_id(); | 60 | static QString gen_attachment_id(); |
59 | }; | 61 | }; |
60 | #endif | 62 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index d252159..bb74de9 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp | |||
@@ -20,24 +20,25 @@ IMAPwrapper::~IMAPwrapper() | |||
20 | 20 | ||
21 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) | 21 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) |
22 | { | 22 | { |
23 | qDebug( "IMAP: %i of %i", current, maximum ); | 23 | qDebug( "IMAP: %i of %i", current, maximum ); |
24 | } | 24 | } |
25 | 25 | ||
26 | void IMAPwrapper::login() | 26 | void IMAPwrapper::login() |
27 | { | 27 | { |
28 | const char *server, *user, *pass; | 28 | const char *server, *user, *pass; |
29 | uint16_t port; | 29 | uint16_t port; |
30 | int err = MAILIMAP_NO_ERROR; | 30 | int err = MAILIMAP_NO_ERROR; |
31 | 31 | ||
32 | if (account->getOffline()) return; | ||
32 | /* we are connected this moment */ | 33 | /* we are connected this moment */ |
33 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ | 34 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ |
34 | if (m_imap) { | 35 | if (m_imap) { |
35 | err = mailimap_noop(m_imap); | 36 | err = mailimap_noop(m_imap); |
36 | if (err!=MAILIMAP_NO_ERROR) { | 37 | if (err!=MAILIMAP_NO_ERROR) { |
37 | logout(); | 38 | logout(); |
38 | } else { | 39 | } else { |
39 | mailstream_flush(m_imap->imap_stream); | 40 | mailstream_flush(m_imap->imap_stream); |
40 | return; | 41 | return; |
41 | } | 42 | } |
42 | } | 43 | } |
43 | server = account->getServer().latin1(); | 44 | server = account->getServer().latin1(); |
@@ -997,18 +998,23 @@ void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folde | |||
997 | if (!msg) return; | 998 | if (!msg) return; |
998 | int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length); | 999 | int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length); |
999 | if (r != MAILIMAP_NO_ERROR) { | 1000 | if (r != MAILIMAP_NO_ERROR) { |
1000 | Global::statusMessage("Error storing mail!"); | 1001 | Global::statusMessage("Error storing mail!"); |
1001 | } | 1002 | } |
1002 | } | 1003 | } |
1003 | 1004 | ||
1004 | const QString&IMAPwrapper::getType()const | 1005 | const QString&IMAPwrapper::getType()const |
1005 | { | 1006 | { |
1006 | return account->getType(); | 1007 | return account->getType(); |
1007 | } | 1008 | } |
1008 | 1009 | ||
1010 | const QString&IMAPwrapper::getName()const | ||
1011 | { | ||
1012 | return account->getAccountName(); | ||
1013 | } | ||
1014 | |||
1009 | encodedString* IMAPwrapper::fetchRawBody(const RecMail&mail) | 1015 | encodedString* IMAPwrapper::fetchRawBody(const RecMail&mail) |
1010 | { | 1016 | { |
1011 | // dummy | 1017 | // dummy |
1012 | QValueList<int> path; | 1018 | QValueList<int> path; |
1013 | return fetchRawPart(mail,path,false); | 1019 | return fetchRawPart(mail,path,false); |
1014 | } | 1020 | } |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h index b246f58..b2bd7e9 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.h +++ b/noncore/net/mail/libmailwrapper/imapwrapper.h | |||
@@ -36,24 +36,26 @@ public: | |||
36 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); | 36 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); |
37 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); | 37 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); |
38 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); | 38 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); |
39 | virtual encodedString* fetchRawBody(const RecMail&mail); | 39 | virtual encodedString* fetchRawBody(const RecMail&mail); |
40 | 40 | ||
41 | virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); | 41 | virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); |
42 | virtual int deleteMbox(const Folder*folder); | 42 | virtual int deleteMbox(const Folder*folder); |
43 | 43 | ||
44 | static void imap_progress( size_t current, size_t maximum ); | 44 | static void imap_progress( size_t current, size_t maximum ); |
45 | 45 | ||
46 | virtual void logout(); | 46 | virtual void logout(); |
47 | virtual const QString&getType()const; | 47 | virtual const QString&getType()const; |
48 | virtual const QString&getName()const; | ||
49 | |||
48 | protected: | 50 | protected: |
49 | RecMail*parse_list_result(mailimap_msg_att*); | 51 | RecMail*parse_list_result(mailimap_msg_att*); |
50 | void login(); | 52 | void login(); |
51 | 53 | ||
52 | virtual QString fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); | 54 | virtual QString fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); |
53 | virtual encodedString*fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call); | 55 | virtual encodedString*fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call); |
54 | 56 | ||
55 | void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); | 57 | void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); |
56 | void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); | 58 | void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); |
57 | void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); | 59 | void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); |
58 | void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which); | 60 | void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which); |
59 | void fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which); | 61 | void fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which); |
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp index bc496f7..97f301e 100644 --- a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp | |||
@@ -1,24 +1,24 @@ | |||
1 | #include "mboxwrapper.h" | 1 | #include "mboxwrapper.h" |
2 | #include "mailtypes.h" | 2 | #include "mailtypes.h" |
3 | #include "mailwrapper.h" | 3 | #include "mailwrapper.h" |
4 | #include <libetpan/libetpan.h> | 4 | #include <libetpan/libetpan.h> |
5 | #include <qdir.h> | 5 | #include <qdir.h> |
6 | #include <stdlib.h> | 6 | #include <stdlib.h> |
7 | #include <qpe/global.h> | 7 | #include <qpe/global.h> |
8 | 8 | ||
9 | const QString MBOXwrapper::wrapperType="MBOX"; | 9 | const QString MBOXwrapper::wrapperType="MBOX"; |
10 | 10 | ||
11 | MBOXwrapper::MBOXwrapper(const QString & mbox_dir) | 11 | MBOXwrapper::MBOXwrapper(const QString & mbox_dir,const QString&mbox_name) |
12 | : Genericwrapper(),MBOXPath(mbox_dir) | 12 | : Genericwrapper(),MBOXPath(mbox_dir),MBOXName(mbox_name) |
13 | { | 13 | { |
14 | QDir dir(MBOXPath); | 14 | QDir dir(MBOXPath); |
15 | if (!dir.exists()) { | 15 | if (!dir.exists()) { |
16 | dir.mkdir(MBOXPath); | 16 | dir.mkdir(MBOXPath); |
17 | } | 17 | } |
18 | } | 18 | } |
19 | 19 | ||
20 | MBOXwrapper::~MBOXwrapper() | 20 | MBOXwrapper::~MBOXwrapper() |
21 | { | 21 | { |
22 | } | 22 | } |
23 | 23 | ||
24 | void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target ) | 24 | void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target ) |
@@ -321,12 +321,17 @@ void MBOXwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) | |||
321 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 321 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
322 | r = mailfolder_connect(folder); | 322 | r = mailfolder_connect(folder); |
323 | r = mailsession_status_folder(folder->fld_session,(char*)mailbox.latin1(),&target_stat.message_count, | 323 | r = mailsession_status_folder(folder->fld_session,(char*)mailbox.latin1(),&target_stat.message_count, |
324 | &target_stat.message_recent,&target_stat.message_unseen); | 324 | &target_stat.message_recent,&target_stat.message_unseen); |
325 | if (folder) mailfolder_free(folder); | 325 | if (folder) mailfolder_free(folder); |
326 | if (storage) mailstorage_free(storage); | 326 | if (storage) mailstorage_free(storage); |
327 | } | 327 | } |
328 | 328 | ||
329 | const QString&MBOXwrapper::getType()const | 329 | const QString&MBOXwrapper::getType()const |
330 | { | 330 | { |
331 | return wrapperType; | 331 | return wrapperType; |
332 | } | 332 | } |
333 | |||
334 | const QString&MBOXwrapper::getName()const | ||
335 | { | ||
336 | return MBOXName; | ||
337 | } | ||
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.h b/noncore/net/mail/libmailwrapper/mboxwrapper.h index 2794014..194ff86 100644 --- a/noncore/net/mail/libmailwrapper/mboxwrapper.h +++ b/noncore/net/mail/libmailwrapper/mboxwrapper.h | |||
@@ -4,42 +4,44 @@ | |||
4 | #include "genericwrapper.h" | 4 | #include "genericwrapper.h" |
5 | #include <qstring.h> | 5 | #include <qstring.h> |
6 | 6 | ||
7 | class RecMail; | 7 | class RecMail; |
8 | class RecBody; | 8 | class RecBody; |
9 | class encodedString; | 9 | class encodedString; |
10 | struct mailmbox_folder; | 10 | struct mailmbox_folder; |
11 | 11 | ||
12 | class MBOXwrapper : public Genericwrapper | 12 | class MBOXwrapper : public Genericwrapper |
13 | { | 13 | { |
14 | Q_OBJECT | 14 | Q_OBJECT |
15 | public: | 15 | public: |
16 | MBOXwrapper(const QString & dir); | 16 | MBOXwrapper(const QString & dir,const QString&name); |
17 | virtual ~MBOXwrapper(); | 17 | virtual ~MBOXwrapper(); |
18 | 18 | ||
19 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); | 19 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); |
20 | virtual QList<Folder>* listFolders(); | 20 | virtual QList<Folder>* listFolders(); |
21 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 21 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
22 | 22 | ||
23 | virtual void deleteMail(const RecMail&mail); | 23 | virtual void deleteMail(const RecMail&mail); |
24 | virtual void answeredMail(const RecMail&mail); | 24 | virtual void answeredMail(const RecMail&mail); |
25 | 25 | ||
26 | virtual int createMbox(const QString&folder,const Folder*f=0,const QString&d="",bool s=false); | 26 | virtual int createMbox(const QString&folder,const Folder*f=0,const QString&d="",bool s=false); |
27 | virtual int deleteMbox(const Folder*); | 27 | virtual int deleteMbox(const Folder*); |
28 | 28 | ||
29 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); | 29 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); |
30 | 30 | ||
31 | virtual RecBody fetchBody( const RecMail &mail ); | 31 | virtual RecBody fetchBody( const RecMail &mail ); |
32 | static void mbox_progress( size_t current, size_t maximum ); | 32 | static void mbox_progress( size_t current, size_t maximum ); |
33 | 33 | ||
34 | virtual encodedString* fetchRawBody(const RecMail&mail); | 34 | virtual encodedString* fetchRawBody(const RecMail&mail); |
35 | virtual void deleteMails(const QString & mailbox,QList<RecMail> &target); | 35 | virtual void deleteMails(const QString & FolderName,QList<RecMail> &target); |
36 | virtual int deleteAllMail(const Folder*); | 36 | virtual int deleteAllMail(const Folder*); |
37 | virtual const QString&getType()const; | 37 | virtual const QString&getType()const; |
38 | virtual const QString&getName()const; | ||
38 | 39 | ||
39 | protected: | 40 | protected: |
40 | static void deleteMails(mailmbox_folder*f,QList<RecMail> &target); | 41 | static void deleteMails(mailmbox_folder*f,QList<RecMail> &target); |
41 | QString MBOXPath; | 42 | QString MBOXPath; |
43 | QString MBOXName; | ||
42 | static const QString wrapperType; | 44 | static const QString wrapperType; |
43 | }; | 45 | }; |
44 | 46 | ||
45 | #endif | 47 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp index cceb22e..67bde38 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp | |||
@@ -99,24 +99,25 @@ RecBody POP3wrapper::fetchBody( const RecMail &mail ) | |||
99 | void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) | 99 | void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) |
100 | { | 100 | { |
101 | login(); | 101 | login(); |
102 | if (!m_pop3) return; | 102 | if (!m_pop3) return; |
103 | uint32_t res_messages,res_recent,res_unseen; | 103 | uint32_t res_messages,res_recent,res_unseen; |
104 | mailsession_status_folder(m_folder->fld_session,"INBOX",&res_messages,&res_recent,&res_unseen); | 104 | mailsession_status_folder(m_folder->fld_session,"INBOX",&res_messages,&res_recent,&res_unseen); |
105 | parseList(target,m_folder->fld_session,"INBOX"); | 105 | parseList(target,m_folder->fld_session,"INBOX"); |
106 | Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(res_messages)); | 106 | Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(res_messages)); |
107 | } | 107 | } |
108 | 108 | ||
109 | void POP3wrapper::login() | 109 | void POP3wrapper::login() |
110 | { | 110 | { |
111 | if (account->getOffline()) return; | ||
111 | /* we'll hold the line */ | 112 | /* we'll hold the line */ |
112 | if ( m_pop3 != NULL ) return; | 113 | if ( m_pop3 != NULL ) return; |
113 | 114 | ||
114 | const char *server, *user, *pass; | 115 | const char *server, *user, *pass; |
115 | uint16_t port; | 116 | uint16_t port; |
116 | int err = MAILPOP3_NO_ERROR; | 117 | int err = MAILPOP3_NO_ERROR; |
117 | 118 | ||
118 | server = account->getServer().latin1(); | 119 | server = account->getServer().latin1(); |
119 | port = account->getPort().toUInt(); | 120 | port = account->getPort().toUInt(); |
120 | 121 | ||
121 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { | 122 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { |
122 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); | 123 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); |
@@ -240,12 +241,17 @@ encodedString* POP3wrapper::fetchRawBody(const RecMail&mail) | |||
240 | err = mailmessage_fetch(mailmsg,&target,&length); | 241 | err = mailmessage_fetch(mailmsg,&target,&length); |
241 | if (mailmsg) mailmessage_free(mailmsg); | 242 | if (mailmsg) mailmessage_free(mailmsg); |
242 | if (target) { | 243 | if (target) { |
243 | res = new encodedString(target,length); | 244 | res = new encodedString(target,length); |
244 | } | 245 | } |
245 | return res; | 246 | return res; |
246 | } | 247 | } |
247 | 248 | ||
248 | const QString&POP3wrapper::getType()const | 249 | const QString&POP3wrapper::getType()const |
249 | { | 250 | { |
250 | return account->getType(); | 251 | return account->getType(); |
251 | } | 252 | } |
253 | |||
254 | const QString&POP3wrapper::getName()const | ||
255 | { | ||
256 | return account->getAccountName(); | ||
257 | } | ||
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h index f0307b6..d2b708d 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.h +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h | |||
@@ -21,22 +21,23 @@ public: | |||
21 | virtual QList<Folder>* listFolders(); | 21 | virtual QList<Folder>* listFolders(); |
22 | /* mailbox will be ignored */ | 22 | /* mailbox will be ignored */ |
23 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 23 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
24 | 24 | ||
25 | virtual void deleteMail(const RecMail&mail); | 25 | virtual void deleteMail(const RecMail&mail); |
26 | virtual void answeredMail(const RecMail&mail); | 26 | virtual void answeredMail(const RecMail&mail); |
27 | virtual int deleteAllMail(const Folder*); | 27 | virtual int deleteAllMail(const Folder*); |
28 | 28 | ||
29 | virtual RecBody fetchBody( const RecMail &mail ); | 29 | virtual RecBody fetchBody( const RecMail &mail ); |
30 | virtual encodedString* fetchRawBody(const RecMail&mail); | 30 | virtual encodedString* fetchRawBody(const RecMail&mail); |
31 | virtual void logout(); | 31 | virtual void logout(); |
32 | virtual const QString&getType()const; | 32 | virtual const QString&getType()const; |
33 | virtual const QString&getName()const; | ||
33 | static void pop3_progress( size_t current, size_t maximum ); | 34 | static void pop3_progress( size_t current, size_t maximum ); |
34 | 35 | ||
35 | protected: | 36 | protected: |
36 | void login(); | 37 | void login(); |
37 | POP3account *account; | 38 | POP3account *account; |
38 | mailstorage*m_pop3; | 39 | mailstorage*m_pop3; |
39 | mailfolder*m_folder; | 40 | mailfolder*m_folder; |
40 | }; | 41 | }; |
41 | 42 | ||
42 | #endif | 43 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/settings.cpp b/noncore/net/mail/libmailwrapper/settings.cpp index c5187f5..02a80a3 100644 --- a/noncore/net/mail/libmailwrapper/settings.cpp +++ b/noncore/net/mail/libmailwrapper/settings.cpp | |||
@@ -159,41 +159,45 @@ void IMAPaccount::read() | |||
159 | if (accountName.isNull()) accountName = ""; | 159 | if (accountName.isNull()) accountName = ""; |
160 | server = conf->readEntry( "Server","" ); | 160 | server = conf->readEntry( "Server","" ); |
161 | if (server.isNull()) server=""; | 161 | if (server.isNull()) server=""; |
162 | port = conf->readEntry( "Port","" ); | 162 | port = conf->readEntry( "Port","" ); |
163 | if (port.isNull()) port="143"; | 163 | if (port.isNull()) port="143"; |
164 | ssl = conf->readBoolEntry( "SSL",false ); | 164 | ssl = conf->readBoolEntry( "SSL",false ); |
165 | user = conf->readEntry( "User","" ); | 165 | user = conf->readEntry( "User","" ); |
166 | if (user.isNull()) user = ""; | 166 | if (user.isNull()) user = ""; |
167 | password = conf->readEntryCrypt( "Password","" ); | 167 | password = conf->readEntryCrypt( "Password","" ); |
168 | if (password.isNull()) password = ""; | 168 | if (password.isNull()) password = ""; |
169 | prefix = conf->readEntry("MailPrefix",""); | 169 | prefix = conf->readEntry("MailPrefix",""); |
170 | if (prefix.isNull()) prefix = ""; | 170 | if (prefix.isNull()) prefix = ""; |
171 | offline = conf->readBoolEntry("Offline",false); | ||
172 | delete conf; | ||
171 | } | 173 | } |
172 | 174 | ||
173 | void IMAPaccount::save() | 175 | void IMAPaccount::save() |
174 | { | 176 | { |
175 | qDebug( "saving " + getFileName() ); | 177 | qDebug( "saving " + getFileName() ); |
176 | Settings::checkDirectory(); | 178 | Settings::checkDirectory(); |
177 | 179 | ||
178 | Config *conf = new Config( getFileName(), Config::File ); | 180 | Config *conf = new Config( getFileName(), Config::File ); |
179 | conf->setGroup( "IMAP Account" ); | 181 | conf->setGroup( "IMAP Account" ); |
180 | conf->writeEntry( "Account", accountName ); | 182 | conf->writeEntry( "Account", accountName ); |
181 | conf->writeEntry( "Server", server ); | 183 | conf->writeEntry( "Server", server ); |
182 | conf->writeEntry( "Port", port ); | 184 | conf->writeEntry( "Port", port ); |
183 | conf->writeEntry( "SSL", ssl ); | 185 | conf->writeEntry( "SSL", ssl ); |
184 | conf->writeEntry( "User", user ); | 186 | conf->writeEntry( "User", user ); |
185 | conf->writeEntryCrypt( "Password", password ); | 187 | conf->writeEntryCrypt( "Password", password ); |
186 | conf->writeEntry( "MailPrefix",prefix); | 188 | conf->writeEntry( "MailPrefix",prefix); |
189 | conf->writeEntry( "Offline",offline); | ||
187 | conf->write(); | 190 | conf->write(); |
191 | delete conf; | ||
188 | } | 192 | } |
189 | 193 | ||
190 | 194 | ||
191 | QString IMAPaccount::getFileName() | 195 | QString IMAPaccount::getFileName() |
192 | { | 196 | { |
193 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/imap-" + file; | 197 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/imap-" + file; |
194 | } | 198 | } |
195 | 199 | ||
196 | POP3account::POP3account() | 200 | POP3account::POP3account() |
197 | : Account() | 201 | : Account() |
198 | { | 202 | { |
199 | file = POP3account::getUniqueFileName(); | 203 | file = POP3account::getUniqueFileName(); |
@@ -229,40 +233,44 @@ QString POP3account::getUniqueFileName() | |||
229 | } | 233 | } |
230 | 234 | ||
231 | void POP3account::read() | 235 | void POP3account::read() |
232 | { | 236 | { |
233 | Config *conf = new Config( getFileName(), Config::File ); | 237 | Config *conf = new Config( getFileName(), Config::File ); |
234 | conf->setGroup( "POP3 Account" ); | 238 | conf->setGroup( "POP3 Account" ); |
235 | accountName = conf->readEntry( "Account" ); | 239 | accountName = conf->readEntry( "Account" ); |
236 | server = conf->readEntry( "Server" ); | 240 | server = conf->readEntry( "Server" ); |
237 | port = conf->readEntry( "Port" ); | 241 | port = conf->readEntry( "Port" ); |
238 | ssl = conf->readBoolEntry( "SSL" ); | 242 | ssl = conf->readBoolEntry( "SSL" ); |
239 | user = conf->readEntry( "User" ); | 243 | user = conf->readEntry( "User" ); |
240 | password = conf->readEntryCrypt( "Password" ); | 244 | password = conf->readEntryCrypt( "Password" ); |
245 | offline = conf->readBoolEntry("Offline",false); | ||
246 | delete conf; | ||
241 | } | 247 | } |
242 | 248 | ||
243 | void POP3account::save() | 249 | void POP3account::save() |
244 | { | 250 | { |
245 | qDebug( "saving " + getFileName() ); | 251 | qDebug( "saving " + getFileName() ); |
246 | Settings::checkDirectory(); | 252 | Settings::checkDirectory(); |
247 | 253 | ||
248 | Config *conf = new Config( getFileName(), Config::File ); | 254 | Config *conf = new Config( getFileName(), Config::File ); |
249 | conf->setGroup( "POP3 Account" ); | 255 | conf->setGroup( "POP3 Account" ); |
250 | conf->writeEntry( "Account", accountName ); | 256 | conf->writeEntry( "Account", accountName ); |
251 | conf->writeEntry( "Server", server ); | 257 | conf->writeEntry( "Server", server ); |
252 | conf->writeEntry( "Port", port ); | 258 | conf->writeEntry( "Port", port ); |
253 | conf->writeEntry( "SSL", ssl ); | 259 | conf->writeEntry( "SSL", ssl ); |
254 | conf->writeEntry( "User", user ); | 260 | conf->writeEntry( "User", user ); |
255 | conf->writeEntryCrypt( "Password", password ); | 261 | conf->writeEntryCrypt( "Password", password ); |
262 | conf->writeEntry( "Offline",offline); | ||
256 | conf->write(); | 263 | conf->write(); |
264 | delete conf; | ||
257 | } | 265 | } |
258 | 266 | ||
259 | 267 | ||
260 | QString POP3account::getFileName() | 268 | QString POP3account::getFileName() |
261 | { | 269 | { |
262 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/pop3-" + file; | 270 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/pop3-" + file; |
263 | } | 271 | } |
264 | 272 | ||
265 | SMTPaccount::SMTPaccount() | 273 | SMTPaccount::SMTPaccount() |
266 | : Account() | 274 | : Account() |
267 | { | 275 | { |
268 | file = SMTPaccount::getUniqueFileName(); | 276 | file = SMTPaccount::getUniqueFileName(); |
@@ -304,41 +312,43 @@ QString SMTPaccount::getUniqueFileName() | |||
304 | 312 | ||
305 | void SMTPaccount::read() | 313 | void SMTPaccount::read() |
306 | { | 314 | { |
307 | Config *conf = new Config( getFileName(), Config::File ); | 315 | Config *conf = new Config( getFileName(), Config::File ); |
308 | conf->setGroup( "SMTP Account" ); | 316 | conf->setGroup( "SMTP Account" ); |
309 | accountName = conf->readEntry( "Account" ); | 317 | accountName = conf->readEntry( "Account" ); |
310 | server = conf->readEntry( "Server" ); | 318 | server = conf->readEntry( "Server" ); |
311 | port = conf->readEntry( "Port" ); | 319 | port = conf->readEntry( "Port" ); |
312 | ssl = conf->readBoolEntry( "SSL" ); | 320 | ssl = conf->readBoolEntry( "SSL" ); |
313 | login = conf->readBoolEntry( "Login" ); | 321 | login = conf->readBoolEntry( "Login" ); |
314 | user = conf->readEntry( "User" ); | 322 | user = conf->readEntry( "User" ); |
315 | password = conf->readEntryCrypt( "Password" ); | 323 | password = conf->readEntryCrypt( "Password" ); |
324 | delete conf; | ||
316 | } | 325 | } |
317 | 326 | ||
318 | void SMTPaccount::save() | 327 | void SMTPaccount::save() |
319 | { | 328 | { |
320 | qDebug( "saving " + getFileName() ); | 329 | qDebug( "saving " + getFileName() ); |
321 | Settings::checkDirectory(); | 330 | Settings::checkDirectory(); |
322 | 331 | ||
323 | Config *conf = new Config( getFileName(), Config::File ); | 332 | Config *conf = new Config( getFileName(), Config::File ); |
324 | conf->setGroup( "SMTP Account" ); | 333 | conf->setGroup( "SMTP Account" ); |
325 | conf->writeEntry( "Account", accountName ); | 334 | conf->writeEntry( "Account", accountName ); |
326 | conf->writeEntry( "Server", server ); | 335 | conf->writeEntry( "Server", server ); |
327 | conf->writeEntry( "Port", port ); | 336 | conf->writeEntry( "Port", port ); |
328 | conf->writeEntry( "SSL", ssl ); | 337 | conf->writeEntry( "SSL", ssl ); |
329 | conf->writeEntry( "Login", login ); | 338 | conf->writeEntry( "Login", login ); |
330 | conf->writeEntry( "User", user ); | 339 | conf->writeEntry( "User", user ); |
331 | conf->writeEntryCrypt( "Password", password ); | 340 | conf->writeEntryCrypt( "Password", password ); |
332 | conf->write(); | 341 | conf->write(); |
342 | delete conf; | ||
333 | } | 343 | } |
334 | 344 | ||
335 | 345 | ||
336 | QString SMTPaccount::getFileName() | 346 | QString SMTPaccount::getFileName() |
337 | { | 347 | { |
338 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/smtp-" + file; | 348 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/smtp-" + file; |
339 | } | 349 | } |
340 | 350 | ||
341 | NNTPaccount::NNTPaccount() | 351 | NNTPaccount::NNTPaccount() |
342 | : Account() | 352 | : Account() |
343 | { | 353 | { |
344 | file = NNTPaccount::getUniqueFileName(); | 354 | file = NNTPaccount::getUniqueFileName(); |
@@ -377,37 +387,39 @@ QString NNTPaccount::getUniqueFileName() | |||
377 | 387 | ||
378 | void NNTPaccount::read() | 388 | void NNTPaccount::read() |
379 | { | 389 | { |
380 | Config *conf = new Config( getFileName(), Config::File ); | 390 | Config *conf = new Config( getFileName(), Config::File ); |
381 | conf->setGroup( "NNTP Account" ); | 391 | conf->setGroup( "NNTP Account" ); |
382 | accountName = conf->readEntry( "Account" ); | 392 | accountName = conf->readEntry( "Account" ); |
383 | server = conf->readEntry( "Server" ); | 393 | server = conf->readEntry( "Server" ); |
384 | port = conf->readEntry( "Port" ); | 394 | port = conf->readEntry( "Port" ); |
385 | ssl = conf->readBoolEntry( "SSL" ); | 395 | ssl = conf->readBoolEntry( "SSL" ); |
386 | login = conf->readBoolEntry( "Login" ); | 396 | login = conf->readBoolEntry( "Login" ); |
387 | user = conf->readEntry( "User" ); | 397 | user = conf->readEntry( "User" ); |
388 | password = conf->readEntryCrypt( "Password" ); | 398 | password = conf->readEntryCrypt( "Password" ); |
399 | delete conf; | ||
389 | } | 400 | } |
390 | 401 | ||
391 | void NNTPaccount::save() | 402 | void NNTPaccount::save() |
392 | { | 403 | { |
393 | qDebug( "saving " + getFileName() ); | 404 | qDebug( "saving " + getFileName() ); |
394 | Settings::checkDirectory(); | 405 | Settings::checkDirectory(); |
395 | 406 | ||
396 | Config *conf = new Config( getFileName(), Config::File ); | 407 | Config *conf = new Config( getFileName(), Config::File ); |
397 | conf->setGroup( "NNTP Account" ); | 408 | conf->setGroup( "NNTP Account" ); |
398 | conf->writeEntry( "Account", accountName ); | 409 | conf->writeEntry( "Account", accountName ); |
399 | conf->writeEntry( "Server", server ); | 410 | conf->writeEntry( "Server", server ); |
400 | conf->writeEntry( "Port", port ); | 411 | conf->writeEntry( "Port", port ); |
401 | conf->writeEntry( "SSL", ssl ); | 412 | conf->writeEntry( "SSL", ssl ); |
402 | conf->writeEntry( "Login", login ); | 413 | conf->writeEntry( "Login", login ); |
403 | conf->writeEntry( "User", user ); | 414 | conf->writeEntry( "User", user ); |
404 | conf->writeEntryCrypt( "Password", password ); | 415 | conf->writeEntryCrypt( "Password", password ); |
405 | conf->write(); | 416 | conf->write(); |
417 | delete conf; | ||
406 | } | 418 | } |
407 | 419 | ||
408 | 420 | ||
409 | QString NNTPaccount::getFileName() | 421 | QString NNTPaccount::getFileName() |
410 | { | 422 | { |
411 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/nntp-" + file; | 423 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/nntp-" + file; |
412 | } | 424 | } |
413 | 425 | ||
diff --git a/noncore/net/mail/libmailwrapper/settings.h b/noncore/net/mail/libmailwrapper/settings.h index caa5dfc..2104997 100644 --- a/noncore/net/mail/libmailwrapper/settings.h +++ b/noncore/net/mail/libmailwrapper/settings.h | |||
@@ -21,33 +21,36 @@ public: | |||
21 | 21 | ||
22 | void setPort(const QString&str) { port = str; } | 22 | void setPort(const QString&str) { port = str; } |
23 | const QString&getPort()const{ return port; } | 23 | const QString&getPort()const{ return port; } |
24 | 24 | ||
25 | void setUser(const QString&str){ user = str; } | 25 | void setUser(const QString&str){ user = str; } |
26 | const QString&getUser()const{ return user; } | 26 | const QString&getUser()const{ return user; } |
27 | 27 | ||
28 | void setPassword(const QString&str) { password = str; } | 28 | void setPassword(const QString&str) { password = str; } |
29 | const QString&getPassword()const { return password; } | 29 | const QString&getPassword()const { return password; } |
30 | 30 | ||
31 | void setSSL( bool b ) { ssl = b; } | 31 | void setSSL( bool b ) { ssl = b; } |
32 | bool getSSL() { return ssl; } | 32 | bool getSSL() { return ssl; } |
33 | |||
34 | void setOffline(bool b) {offline = b;} | ||
35 | bool getOffline()const{return offline;} | ||
33 | 36 | ||
34 | virtual QString getFileName() { return accountName; } | 37 | virtual QString getFileName() { return accountName; } |
35 | virtual void read() { qDebug( "base reading..." ); } | 38 | virtual void read() { qDebug( "base reading..." ); } |
36 | virtual void save() { qDebug( "base saving..." ); } | 39 | virtual void save() { qDebug( "base saving..." ); } |
37 | 40 | ||
38 | protected: | 41 | protected: |
39 | QString accountName, type, server, port, user, password; | 42 | QString accountName, type, server, port, user, password; |
40 | bool ssl; | 43 | bool ssl; |
41 | 44 | bool offline; | |
42 | }; | 45 | }; |
43 | 46 | ||
44 | class IMAPaccount : public Account | 47 | class IMAPaccount : public Account |
45 | { | 48 | { |
46 | 49 | ||
47 | public: | 50 | public: |
48 | IMAPaccount(); | 51 | IMAPaccount(); |
49 | IMAPaccount( QString filename ); | 52 | IMAPaccount( QString filename ); |
50 | 53 | ||
51 | static QString getUniqueFileName(); | 54 | static QString getUniqueFileName(); |
52 | 55 | ||
53 | virtual void read(); | 56 | virtual void read(); |
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp index 4764b77..281b88e 100644 --- a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp | |||
@@ -480,25 +480,25 @@ char *SMTPwrapper::getFrom( mailmime *mail ) | |||
480 | void SMTPwrapper::progress( size_t current, size_t maximum ) | 480 | void SMTPwrapper::progress( size_t current, size_t maximum ) |
481 | { | 481 | { |
482 | if (SMTPwrapper::sendProgress) { | 482 | if (SMTPwrapper::sendProgress) { |
483 | SMTPwrapper::sendProgress->setSingleMail(current, maximum ); | 483 | SMTPwrapper::sendProgress->setSingleMail(current, maximum ); |
484 | qApp->processEvents(); | 484 | qApp->processEvents(); |
485 | } | 485 | } |
486 | } | 486 | } |
487 | 487 | ||
488 | void SMTPwrapper::storeMail(const char*mail, size_t length, const QString&box) | 488 | void SMTPwrapper::storeMail(const char*mail, size_t length, const QString&box) |
489 | { | 489 | { |
490 | if (!mail) return; | 490 | if (!mail) return; |
491 | QString localfolders = AbstractMail::defaultLocalfolder(); | 491 | QString localfolders = AbstractMail::defaultLocalfolder(); |
492 | MBOXwrapper*wrap = new MBOXwrapper(localfolders); | 492 | AbstractMail*wrap = AbstractMail::getWrapper(localfolders); |
493 | wrap->storeMessage(mail,length,box); | 493 | wrap->storeMessage(mail,length,box); |
494 | delete wrap; | 494 | delete wrap; |
495 | } | 495 | } |
496 | 496 | ||
497 | void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ) | 497 | void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ) |
498 | { | 498 | { |
499 | clist *rcpts = 0; | 499 | clist *rcpts = 0; |
500 | char *from, *data; | 500 | char *from, *data; |
501 | size_t size; | 501 | size_t size; |
502 | 502 | ||
503 | if ( smtp == NULL ) { | 503 | if ( smtp == NULL ) { |
504 | return; | 504 | return; |
@@ -507,29 +507,27 @@ void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ) | |||
507 | 507 | ||
508 | mailmessage * msg = 0; | 508 | mailmessage * msg = 0; |
509 | msg = mime_message_init(mail); | 509 | msg = mime_message_init(mail); |
510 | mime_message_set_tmpdir(msg,getenv( "HOME" )); | 510 | mime_message_set_tmpdir(msg,getenv( "HOME" )); |
511 | int r = mailmessage_fetch(msg,&data,&size); | 511 | int r = mailmessage_fetch(msg,&data,&size); |
512 | mime_message_detach_mime(msg); | 512 | mime_message_detach_mime(msg); |
513 | mailmessage_free(msg); | 513 | mailmessage_free(msg); |
514 | if (r != MAIL_NO_ERROR || !data) { | 514 | if (r != MAIL_NO_ERROR || !data) { |
515 | if (data) free(data); | 515 | if (data) free(data); |
516 | qDebug("Error fetching mime..."); | 516 | qDebug("Error fetching mime..."); |
517 | return; | 517 | return; |
518 | } | 518 | } |
519 | QString tmp = data; | ||
520 | tmp.replace(QRegExp("\r+",true,false),""); | ||
521 | msg = 0; | 519 | msg = 0; |
522 | if (later) { | 520 | if (later) { |
523 | storeMail((char*)tmp.data(),tmp.length(),"Outgoing"); | 521 | storeMail(data,size,"Outgoing"); |
524 | if (data) free( data ); | 522 | if (data) free( data ); |
525 | Config cfg( "mail" ); | 523 | Config cfg( "mail" ); |
526 | cfg.setGroup( "Status" ); | 524 | cfg.setGroup( "Status" ); |
527 | cfg.writeEntry( "outgoing", ++m_queuedMail ); | 525 | cfg.writeEntry( "outgoing", ++m_queuedMail ); |
528 | emit queuedMails( m_queuedMail ); | 526 | emit queuedMails( m_queuedMail ); |
529 | return; | 527 | return; |
530 | } | 528 | } |
531 | from = getFrom( mail ); | 529 | from = getFrom( mail ); |
532 | rcpts = createRcptList( mail->mm_data.mm_message.mm_fields ); | 530 | rcpts = createRcptList( mail->mm_data.mm_message.mm_fields ); |
533 | smtpSend(from,rcpts,data,size,smtp); | 531 | smtpSend(from,rcpts,data,size,smtp); |
534 | if (data) {free(data);} | 532 | if (data) {free(data);} |
535 | if (from) {free(from);} | 533 | if (from) {free(from);} |
@@ -627,25 +625,25 @@ void SMTPwrapper::sendMail(const Mail&mail,SMTPaccount*aSmtp,bool later ) | |||
627 | sendProgress = new progressMailSend(); | 625 | sendProgress = new progressMailSend(); |
628 | sendProgress->show(); | 626 | sendProgress->show(); |
629 | sendProgress->setMaxMails(1); | 627 | sendProgress->setMaxMails(1); |
630 | smtpSend( mimeMail,later,smtp); | 628 | smtpSend( mimeMail,later,smtp); |
631 | qDebug("Clean up done"); | 629 | qDebug("Clean up done"); |
632 | sendProgress->hide(); | 630 | sendProgress->hide(); |
633 | delete sendProgress; | 631 | delete sendProgress; |
634 | sendProgress = 0; | 632 | sendProgress = 0; |
635 | mailmime_free( mimeMail ); | 633 | mailmime_free( mimeMail ); |
636 | } | 634 | } |
637 | } | 635 | } |
638 | 636 | ||
639 | int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which) | 637 | int SMTPwrapper::sendQueuedMail(AbstractMail*wrap,SMTPaccount*smtp,RecMail*which) |
640 | { | 638 | { |
641 | size_t curTok = 0; | 639 | size_t curTok = 0; |
642 | mailimf_fields *fields = 0; | 640 | mailimf_fields *fields = 0; |
643 | mailimf_field*ffrom = 0; | 641 | mailimf_field*ffrom = 0; |
644 | clist *rcpts = 0; | 642 | clist *rcpts = 0; |
645 | char*from = 0; | 643 | char*from = 0; |
646 | int res = 0; | 644 | int res = 0; |
647 | 645 | ||
648 | encodedString * data = wrap->fetchRawBody(*which); | 646 | encodedString * data = wrap->fetchRawBody(*which); |
649 | if (!data) return 0; | 647 | if (!data) return 0; |
650 | int err = mailimf_fields_parse( data->Content(), data->Length(), &curTok, &fields ); | 648 | int err = mailimf_fields_parse( data->Content(), data->Length(), &curTok, &fields ); |
651 | if (err != MAILIMF_NO_ERROR) { | 649 | if (err != MAILIMF_NO_ERROR) { |
@@ -676,25 +674,25 @@ int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which) | |||
676 | } | 674 | } |
677 | return res; | 675 | return res; |
678 | } | 676 | } |
679 | 677 | ||
680 | /* this is a special fun */ | 678 | /* this is a special fun */ |
681 | bool SMTPwrapper::flushOutbox(SMTPaccount*smtp) | 679 | bool SMTPwrapper::flushOutbox(SMTPaccount*smtp) |
682 | { | 680 | { |
683 | bool returnValue = true; | 681 | bool returnValue = true; |
684 | 682 | ||
685 | if (!smtp) return false; | 683 | if (!smtp) return false; |
686 | 684 | ||
687 | QString localfolders = AbstractMail::defaultLocalfolder(); | 685 | QString localfolders = AbstractMail::defaultLocalfolder(); |
688 | MBOXwrapper*wrap = new MBOXwrapper(localfolders); | 686 | AbstractMail*wrap = AbstractMail::getWrapper(localfolders); |
689 | if (!wrap) { | 687 | if (!wrap) { |
690 | qDebug("memory error"); | 688 | qDebug("memory error"); |
691 | return false; | 689 | return false; |
692 | } | 690 | } |
693 | QList<RecMail> mailsToSend; | 691 | QList<RecMail> mailsToSend; |
694 | QList<RecMail> mailsToRemove; | 692 | QList<RecMail> mailsToRemove; |
695 | QString mbox("Outgoing"); | 693 | QString mbox("Outgoing"); |
696 | wrap->listMessages(mbox,mailsToSend); | 694 | wrap->listMessages(mbox,mailsToSend); |
697 | if (mailsToSend.count()==0) { | 695 | if (mailsToSend.count()==0) { |
698 | delete wrap; | 696 | delete wrap; |
699 | return false; | 697 | return false; |
700 | } | 698 | } |
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.h b/noncore/net/mail/libmailwrapper/smtpwrapper.h index 04fc4b0..7dcdbfd 100644 --- a/noncore/net/mail/libmailwrapper/smtpwrapper.h +++ b/noncore/net/mail/libmailwrapper/smtpwrapper.h | |||
@@ -1,25 +1,25 @@ | |||
1 | #ifndef SMTPwrapper_H | 1 | #ifndef SMTPwrapper_H |
2 | #define SMTPwrapper_H | 2 | #define SMTPwrapper_H |
3 | 3 | ||
4 | #include <qpe/applnk.h> | 4 | #include <qpe/applnk.h> |
5 | 5 | ||
6 | #include <qbitarray.h> | 6 | #include <qbitarray.h> |
7 | #include <qdatetime.h> | 7 | #include <qdatetime.h> |
8 | #include <libetpan/clist.h> | 8 | #include <libetpan/clist.h> |
9 | 9 | ||
10 | #include "settings.h" | 10 | #include "settings.h" |
11 | 11 | ||
12 | class Mail; | 12 | class Mail; |
13 | class MBOXwrapper; | 13 | class AbstractMail; |
14 | class RecMail; | 14 | class RecMail; |
15 | class Attachment; | 15 | class Attachment; |
16 | struct mailimf_fields; | 16 | struct mailimf_fields; |
17 | struct mailimf_field; | 17 | struct mailimf_field; |
18 | struct mailimf_mailbox; | 18 | struct mailimf_mailbox; |
19 | struct mailmime; | 19 | struct mailmime; |
20 | struct mailimf_address_list; | 20 | struct mailimf_address_list; |
21 | class progressMailSend; | 21 | class progressMailSend; |
22 | 22 | ||
23 | class SMTPwrapper : public QObject | 23 | class SMTPwrapper : public QObject |
24 | { | 24 | { |
25 | Q_OBJECT | 25 | Q_OBJECT |
@@ -50,23 +50,23 @@ protected: | |||
50 | static void storeMail(const char*mail, size_t length, const QString&box); | 50 | static void storeMail(const char*mail, size_t length, const QString&box); |
51 | static QString mailsmtpError( int err ); | 51 | static QString mailsmtpError( int err ); |
52 | static void progress( size_t current, size_t maximum ); | 52 | static void progress( size_t current, size_t maximum ); |
53 | static void addRcpts( clist *list, mailimf_address_list *addr_list ); | 53 | static void addRcpts( clist *list, mailimf_address_list *addr_list ); |
54 | static char *getFrom( mailmime *mail ); | 54 | static char *getFrom( mailmime *mail ); |
55 | static char *getFrom( mailimf_field *ffrom); | 55 | static char *getFrom( mailimf_field *ffrom); |
56 | static mailimf_field *getField( mailimf_fields *fields, int type ); | 56 | static mailimf_field *getField( mailimf_fields *fields, int type ); |
57 | int smtpSend(char*from,clist*rcpts,const char*data,size_t size, SMTPaccount *smtp ); | 57 | int smtpSend(char*from,clist*rcpts,const char*data,size_t size, SMTPaccount *smtp ); |
58 | 58 | ||
59 | void storeMail(mailmime*mail, const QString&box); | 59 | void storeMail(mailmime*mail, const QString&box); |
60 | Settings *settings; | 60 | Settings *settings; |
61 | 61 | ||
62 | int sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which); | 62 | int sendQueuedMail(AbstractMail*wrap,SMTPaccount*smtp,RecMail*which); |
63 | 63 | ||
64 | int m_queuedMail; | 64 | int m_queuedMail; |
65 | static const char* USER_AGENT; | 65 | static const char* USER_AGENT; |
66 | 66 | ||
67 | protected slots: | 67 | protected slots: |
68 | void emitQCop( int queued ); | 68 | void emitQCop( int queued ); |
69 | 69 | ||
70 | }; | 70 | }; |
71 | 71 | ||
72 | #endif | 72 | #endif |