Diffstat (limited to 'noncore/net/mail/libmailwrapper') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.cpp | 74 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.h | 28 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/settings.cpp | 4 |
3 files changed, 102 insertions, 4 deletions
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp new file mode 100644 index 0000000..08e97f4 --- a/dev/null +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp | |||
@@ -0,0 +1,74 @@ | |||
1 | |||
2 | #include "pop3wrapper.h" | ||
3 | #include "mailtypes.h" | ||
4 | #include <libetpan/mailpop3.h> | ||
5 | |||
6 | POP3wrapper::POP3wrapper( POP3account *a ) | ||
7 | { | ||
8 | account = a; | ||
9 | } | ||
10 | |||
11 | POP3wrapper::~POP3wrapper() | ||
12 | { | ||
13 | logout(); | ||
14 | } | ||
15 | |||
16 | void POP3wrapper::pop3_progress( size_t current, size_t maximum ) | ||
17 | { | ||
18 | qDebug( "POP3: %i of %i", current, maximum ); | ||
19 | } | ||
20 | |||
21 | void POP3wrapper::listMessages( QList<RecMail> &target ) | ||
22 | { | ||
23 | login(); | ||
24 | //TODO: list messages | ||
25 | logout(); | ||
26 | } | ||
27 | |||
28 | void POP3wrapper::login() | ||
29 | { | ||
30 | logout(); | ||
31 | const char *server, *user, *pass; | ||
32 | uint16_t port; | ||
33 | int err = MAILPOP3_NO_ERROR; | ||
34 | |||
35 | server = account->getServer().latin1(); | ||
36 | port = account->getPort().toUInt(); | ||
37 | user = account->getUser().latin1(); | ||
38 | pass = account->getPassword().latin1(); | ||
39 | |||
40 | m_pop3 = mailpop3_new( 20, &pop3_progress ); | ||
41 | |||
42 | // connect | ||
43 | err = mailpop3_socket_connect( m_pop3, (char *) server, port ); | ||
44 | if ( err != MAILPOP3_NO_ERROR ) { | ||
45 | qDebug( "pop3: error connecting to %s\n reason: %s", server, | ||
46 | m_pop3->response ); | ||
47 | mailpop3_free( m_pop3 ); | ||
48 | m_pop3 = NULL; | ||
49 | return; | ||
50 | } | ||
51 | qDebug( "POP3: connected!" ); | ||
52 | |||
53 | // login | ||
54 | // TODO: decide if apop or plain login should be used | ||
55 | err = mailpop3_login( m_pop3, (char *) user, (char *) pass ); | ||
56 | if ( err != MAILPOP3_NO_ERROR ) { | ||
57 | qDebug( "pop3: error logging in: %s", m_pop3->response ); | ||
58 | logout(); | ||
59 | return; | ||
60 | } | ||
61 | |||
62 | qDebug( "POP3: logged in!" ); | ||
63 | } | ||
64 | |||
65 | void POP3wrapper::logout() | ||
66 | { | ||
67 | int err = MAILPOP3_NO_ERROR; | ||
68 | if ( !m_pop3 ) return; | ||
69 | err = mailpop3_quit( m_pop3 ); | ||
70 | mailpop3_free( m_pop3 ); | ||
71 | m_pop3 = NULL; | ||
72 | } | ||
73 | |||
74 | |||
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h new file mode 100644 index 0000000..b791409 --- a/dev/null +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h | |||
@@ -0,0 +1,28 @@ | |||
1 | #ifndef __POP3WRAPPER | ||
2 | #define __POP3WRAPPER | ||
3 | |||
4 | #include "mailwrapper.h" | ||
5 | |||
6 | class RecMail; | ||
7 | |||
8 | class POP3wrapper : public QObject | ||
9 | { | ||
10 | Q_OBJECT | ||
11 | |||
12 | public: | ||
13 | POP3wrapper( POP3account *a ); | ||
14 | virtual ~POP3wrapper(); | ||
15 | void listMessages( QList<RecMail> &target ); | ||
16 | static void pop3_progress( size_t current, size_t maximum ); | ||
17 | |||
18 | protected: | ||
19 | void login(); | ||
20 | void logout(); | ||
21 | |||
22 | private: | ||
23 | POP3account *account; | ||
24 | mailpop3 *m_pop3; | ||
25 | |||
26 | }; | ||
27 | |||
28 | #endif | ||
diff --git a/noncore/net/mail/libmailwrapper/settings.cpp b/noncore/net/mail/libmailwrapper/settings.cpp index 9632301..b580954 100644 --- a/noncore/net/mail/libmailwrapper/settings.cpp +++ b/noncore/net/mail/libmailwrapper/settings.cpp | |||
@@ -134,3 +134,2 @@ QString IMAPaccount::getUniqueFileName() | |||
134 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); | 134 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); |
135 | QStringList::Iterator it; | ||
136 | 135 | ||
@@ -212,3 +211,2 @@ QString POP3account::getUniqueFileName() | |||
212 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); | 211 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); |
213 | QStringList::Iterator it; | ||
214 | 212 | ||
@@ -290,3 +288,2 @@ QString SMTPaccount::getUniqueFileName() | |||
290 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); | 288 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); |
291 | QStringList::Iterator it; | ||
292 | 289 | ||
@@ -386,3 +383,2 @@ QString NNTPaccount::getUniqueFileName() | |||
386 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); | 383 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); |
387 | QStringList::Iterator it; | ||
388 | 384 | ||