Diffstat (limited to 'noncore/net/mail/imapwrapper.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/mail/imapwrapper.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp index eae85a7..dc02780 100644 --- a/noncore/net/mail/imapwrapper.cpp +++ b/noncore/net/mail/imapwrapper.cpp | |||
@@ -14,49 +14,55 @@ IMAPwrapper::IMAPwrapper( IMAPaccount *a ) | |||
14 | IMAPwrapper::~IMAPwrapper() | 14 | IMAPwrapper::~IMAPwrapper() |
15 | { | 15 | { |
16 | logout(); | 16 | logout(); |
17 | } | 17 | } |
18 | 18 | ||
19 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) | 19 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) |
20 | { | 20 | { |
21 | qDebug( "IMAP: %i of %i", current, maximum ); | 21 | qDebug( "IMAP: %i of %i", current, maximum ); |
22 | } | 22 | } |
23 | 23 | ||
24 | void IMAPwrapper::login() | 24 | void IMAPwrapper::login() |
25 | { | 25 | { |
26 | logout(); | 26 | logout(); |
27 | const char *server, *user, *pass; | 27 | const char *server, *user, *pass; |
28 | uint16_t port; | 28 | uint16_t port; |
29 | int err = MAILIMAP_NO_ERROR; | 29 | int err = MAILIMAP_NO_ERROR; |
30 | 30 | ||
31 | server = account->getServer().latin1(); | 31 | server = account->getServer().latin1(); |
32 | port = account->getPort().toUInt(); | 32 | port = account->getPort().toUInt(); |
33 | user = account->getUser().latin1(); | 33 | user = account->getUser().latin1(); |
34 | pass = account->getPassword().latin1(); | 34 | pass = account->getPassword().latin1(); |
35 | 35 | ||
36 | m_imap = mailimap_new( 20, &imap_progress ); | 36 | m_imap = mailimap_new( 20, &imap_progress ); |
37 | /* connect */ | 37 | /* connect */ |
38 | // err = mailimap_socket_connect( m_imap, (char*)server, port ); | ||
39 | if (account->getSSL()) { | ||
40 | err = mailimap_ssl_connect( m_imap, (char*)server, port ); | ||
41 | } else { | ||
38 | err = mailimap_socket_connect( m_imap, (char*)server, port ); | 42 | err = mailimap_socket_connect( m_imap, (char*)server, port ); |
43 | } | ||
44 | |||
39 | if ( err != MAILIMAP_NO_ERROR && | 45 | if ( err != MAILIMAP_NO_ERROR && |
40 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && | 46 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && |
41 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { | 47 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { |
42 | qDebug("error connecting server: %s",m_imap->response); | 48 | qDebug("error connecting server: %s",m_imap->response); |
43 | mailimap_free( m_imap ); | 49 | mailimap_free( m_imap ); |
44 | m_imap = 0; | 50 | m_imap = 0; |
45 | return; | 51 | return; |
46 | } | 52 | } |
47 | 53 | ||
48 | /* login */ | 54 | /* login */ |
49 | err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); | 55 | err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); |
50 | if ( err != MAILIMAP_NO_ERROR ) { | 56 | if ( err != MAILIMAP_NO_ERROR ) { |
51 | qDebug("error logging in imap: %s",m_imap->response); | 57 | qDebug("error logging in imap: %s",m_imap->response); |
52 | err = mailimap_close( m_imap ); | 58 | err = mailimap_close( m_imap ); |
53 | mailimap_free( m_imap ); | 59 | mailimap_free( m_imap ); |
54 | m_imap = 0; | 60 | m_imap = 0; |
55 | } | 61 | } |
56 | } | 62 | } |
57 | 63 | ||
58 | void IMAPwrapper::logout() | 64 | void IMAPwrapper::logout() |
59 | { | 65 | { |
60 | int err = MAILIMAP_NO_ERROR; | 66 | int err = MAILIMAP_NO_ERROR; |
61 | if (!m_imap) return; | 67 | if (!m_imap) return; |
62 | err = mailimap_logout( m_imap ); | 68 | err = mailimap_logout( m_imap ); |