summaryrefslogtreecommitdiff
path: root/noncore/net/mail/libmailwrapper/imapwrapper.cpp
Unidiff
Diffstat (limited to 'noncore/net/mail/libmailwrapper/imapwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
index 11bf3b8..48e476b 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
@@ -8,49 +8,50 @@
8IMAPwrapper::IMAPwrapper( IMAPaccount *a ) 8IMAPwrapper::IMAPwrapper( IMAPaccount *a )
9{ 9{
10 account = a; 10 account = a;
11 m_imap = 0; 11 m_imap = 0;
12} 12}
13 13
14IMAPwrapper::~IMAPwrapper() 14IMAPwrapper::~IMAPwrapper()
15{ 15{
16 logout(); 16 logout();
17} 17}
18 18
19void IMAPwrapper::imap_progress( size_t current, size_t maximum ) 19void 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
24void IMAPwrapper::login() 24void IMAPwrapper::login()
25{ 25{
26 const char *server, *user, *pass; 26 const char *server, *user, *pass;
27 uint16_t port; 27 uint16_t port;
28 int err = MAILIMAP_NO_ERROR; 28 int err = MAILIMAP_NO_ERROR;
29 29
30 /* we are connected this moment */ 30 /* we are connected this moment */
31 /* TODO: setup a timer holding the line or if connection closed - delete the value */ 31 /* TODO: setup a timer holding the line or if connection closed - delete the value */
32 if (m_imap) { 32 if (m_imap) {
33 mailstream_flush(m_imap->imap_stream);
33 return; 34 return;
34 } 35 }
35 server = account->getServer().latin1(); 36 server = account->getServer().latin1();
36 port = account->getPort().toUInt(); 37 port = account->getPort().toUInt();
37 user = account->getUser().latin1(); 38 user = account->getUser().latin1();
38 pass = account->getPassword().latin1(); 39 pass = account->getPassword().latin1();
39 40
40 m_imap = mailimap_new( 20, &imap_progress ); 41 m_imap = mailimap_new( 20, &imap_progress );
41 /* connect */ 42 /* connect */
42 if (account->getSSL()) { 43 if (account->getSSL()) {
43 err = mailimap_ssl_connect( m_imap, (char*)server, port ); 44 err = mailimap_ssl_connect( m_imap, (char*)server, port );
44 } else { 45 } else {
45 err = mailimap_socket_connect( m_imap, (char*)server, port ); 46 err = mailimap_socket_connect( m_imap, (char*)server, port );
46 } 47 }
47 48
48 if ( err != MAILIMAP_NO_ERROR && 49 if ( err != MAILIMAP_NO_ERROR &&
49 err != MAILIMAP_NO_ERROR_AUTHENTICATED && 50 err != MAILIMAP_NO_ERROR_AUTHENTICATED &&
50 err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { 51 err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) {
51 qDebug("error connecting server: %s",m_imap->imap_response); 52 qDebug("error connecting server: %s",m_imap->imap_response);
52 mailimap_free( m_imap ); 53 mailimap_free( m_imap );
53 m_imap = 0; 54 m_imap = 0;
54 return; 55 return;
55 } 56 }
56 57