author | jgf <jgf> | 2003-12-09 21:36:56 (UTC) |
---|---|---|
committer | jgf <jgf> | 2003-12-09 21:36:56 (UTC) |
commit | 6b45c1f8e0293914c1328f15a665d2ea0fba7b43 (patch) (unidiff) | |
tree | d87ef7d3147a52429849a6921e7a8f31fde89aa8 /noncore/net/mail/libmailwrapper/pop3wrapper.cpp | |
parent | 0a1f6405780b18c9f3d953adcfd072de8fd4dc18 (diff) | |
download | opie-6b45c1f8e0293914c1328f15a665d2ea0fba7b43.zip opie-6b45c1f8e0293914c1328f15a665d2ea0fba7b43.tar.gz opie-6b45c1f8e0293914c1328f15a665d2ea0fba7b43.tar.bz2 |
POP3 support - first steps
Diffstat (limited to 'noncore/net/mail/libmailwrapper/pop3wrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.cpp | 74 |
1 files changed, 74 insertions, 0 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 | |||