summaryrefslogtreecommitdiff
authoralwin <alwin>2003-12-25 20:10:26 (UTC)
committer alwin <alwin>2003-12-25 20:10:26 (UTC)
commitbde1302aed8a0e2506684eaae7c2d2d823de42c6 (patch) (unidiff)
tree24b16fc0f0c969df001615a00ac08a8bd4acd2df
parent67d7f0b0fc79377fba216e556785f6c630c437ad (diff)
downloadopie-bde1302aed8a0e2506684eaae7c2d2d823de42c6.zip
opie-bde1302aed8a0e2506684eaae7c2d2d823de42c6.tar.gz
opie-bde1302aed8a0e2506684eaae7c2d2d823de42c6.tar.bz2
try to resolve timeouts via NOOP statement in login
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/imapwrapper.cpp9
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp9
2 files changed, 14 insertions, 4 deletions
diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp
index 89ec7ab..ab20249 100644
--- a/noncore/net/mail/imapwrapper.cpp
+++ b/noncore/net/mail/imapwrapper.cpp
@@ -1,85 +1,90 @@
1 1
2#include <stdlib.h> 2#include <stdlib.h>
3 3
4#include <libetpan/libetpan.h> 4#include <libetpan/libetpan.h>
5 5
6#include "imapwrapper.h" 6#include "imapwrapper.h"
7#include "mailtypes.h" 7#include "mailtypes.h"
8#include "logindialog.h" 8#include "logindialog.h"
9 9
10IMAPwrapper::IMAPwrapper( IMAPaccount *a ) 10IMAPwrapper::IMAPwrapper( IMAPaccount *a )
11 : AbstractMail() 11 : AbstractMail()
12{ 12{
13 account = a; 13 account = a;
14 m_imap = 0; 14 m_imap = 0;
15} 15}
16 16
17IMAPwrapper::~IMAPwrapper() 17IMAPwrapper::~IMAPwrapper()
18{ 18{
19 logout(); 19 logout();
20} 20}
21 21
22void IMAPwrapper::imap_progress( size_t current, size_t maximum ) 22void IMAPwrapper::imap_progress( size_t current, size_t maximum )
23{ 23{
24 qDebug( "IMAP: %i of %i", current, maximum ); 24 qDebug( "IMAP: %i of %i", current, maximum );
25} 25}
26 26
27void IMAPwrapper::login() 27void IMAPwrapper::login()
28{ 28{
29 const char *server, *user, *pass; 29 const char *server, *user, *pass;
30 uint16_t port; 30 uint16_t port;
31 int err = MAILIMAP_NO_ERROR; 31 int err = MAILIMAP_NO_ERROR;
32 32
33 /* we are connected this moment */ 33 /* we are connected this moment */
34 /* 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 */
35 if (m_imap) { 35 if (m_imap) {
36 mailstream_flush(m_imap->imap_stream); 36 err = mailimap_noop(m_imap);
37 return; 37 if (err!=MAILIMAP_NO_ERROR) {
38 logout();
39 } else {
40 mailstream_flush(m_imap->imap_stream);
41 return;
42 }
38 } 43 }
39 server = account->getServer().latin1(); 44 server = account->getServer().latin1();
40 port = account->getPort().toUInt(); 45 port = account->getPort().toUInt();
41 if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { 46 if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) {
42 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); 47 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true );
43 login.show(); 48 login.show();
44 if ( QDialog::Accepted == login.exec() ) { 49 if ( QDialog::Accepted == login.exec() ) {
45 // ok 50 // ok
46 user = strdup( login.getUser().latin1() ); 51 user = strdup( login.getUser().latin1() );
47 pass = strdup( login.getPassword().latin1() ); 52 pass = strdup( login.getPassword().latin1() );
48 } else { 53 } else {
49 // cancel 54 // cancel
50 qDebug( "IMAP: Login canceled" ); 55 qDebug( "IMAP: Login canceled" );
51 return; 56 return;
52 } 57 }
53 } else { 58 } else {
54 user = account->getUser().latin1(); 59 user = account->getUser().latin1();
55 pass = account->getPassword().latin1(); 60 pass = account->getPassword().latin1();
56 } 61 }
57 62
58 m_imap = mailimap_new( 20, &imap_progress ); 63 m_imap = mailimap_new( 20, &imap_progress );
59 /* connect */ 64 /* connect */
60 if (account->getSSL()) { 65 if (account->getSSL()) {
61 err = mailimap_ssl_connect( m_imap, (char*)server, port ); 66 err = mailimap_ssl_connect( m_imap, (char*)server, port );
62 } else { 67 } else {
63 err = mailimap_socket_connect( m_imap, (char*)server, port ); 68 err = mailimap_socket_connect( m_imap, (char*)server, port );
64 } 69 }
65 70
66 if ( err != MAILIMAP_NO_ERROR && 71 if ( err != MAILIMAP_NO_ERROR &&
67 err != MAILIMAP_NO_ERROR_AUTHENTICATED && 72 err != MAILIMAP_NO_ERROR_AUTHENTICATED &&
68 err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { 73 err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) {
69 qDebug("error connecting server: %s",m_imap->imap_response); 74 qDebug("error connecting server: %s",m_imap->imap_response);
70 mailimap_free( m_imap ); 75 mailimap_free( m_imap );
71 m_imap = 0; 76 m_imap = 0;
72 return; 77 return;
73 } 78 }
74 79
75 /* login */ 80 /* login */
76 err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); 81 err = mailimap_login_simple( m_imap, (char*)user, (char*)pass );
77 if ( err != MAILIMAP_NO_ERROR ) { 82 if ( err != MAILIMAP_NO_ERROR ) {
78 qDebug("error logging in imap: %s",m_imap->imap_response); 83 qDebug("error logging in imap: %s",m_imap->imap_response);
79 err = mailimap_close( m_imap ); 84 err = mailimap_close( m_imap );
80 mailimap_free( m_imap ); 85 mailimap_free( m_imap );
81 m_imap = 0; 86 m_imap = 0;
82 } 87 }
83} 88}
84 89
85void IMAPwrapper::logout() 90void IMAPwrapper::logout()
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
index 89ec7ab..ab20249 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
@@ -1,85 +1,90 @@
1 1
2#include <stdlib.h> 2#include <stdlib.h>
3 3
4#include <libetpan/libetpan.h> 4#include <libetpan/libetpan.h>
5 5
6#include "imapwrapper.h" 6#include "imapwrapper.h"
7#include "mailtypes.h" 7#include "mailtypes.h"
8#include "logindialog.h" 8#include "logindialog.h"
9 9
10IMAPwrapper::IMAPwrapper( IMAPaccount *a ) 10IMAPwrapper::IMAPwrapper( IMAPaccount *a )
11 : AbstractMail() 11 : AbstractMail()
12{ 12{
13 account = a; 13 account = a;
14 m_imap = 0; 14 m_imap = 0;
15} 15}
16 16
17IMAPwrapper::~IMAPwrapper() 17IMAPwrapper::~IMAPwrapper()
18{ 18{
19 logout(); 19 logout();
20} 20}
21 21
22void IMAPwrapper::imap_progress( size_t current, size_t maximum ) 22void IMAPwrapper::imap_progress( size_t current, size_t maximum )
23{ 23{
24 qDebug( "IMAP: %i of %i", current, maximum ); 24 qDebug( "IMAP: %i of %i", current, maximum );
25} 25}
26 26
27void IMAPwrapper::login() 27void IMAPwrapper::login()
28{ 28{
29 const char *server, *user, *pass; 29 const char *server, *user, *pass;
30 uint16_t port; 30 uint16_t port;
31 int err = MAILIMAP_NO_ERROR; 31 int err = MAILIMAP_NO_ERROR;
32 32
33 /* we are connected this moment */ 33 /* we are connected this moment */
34 /* 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 */
35 if (m_imap) { 35 if (m_imap) {
36 mailstream_flush(m_imap->imap_stream); 36 err = mailimap_noop(m_imap);
37 return; 37 if (err!=MAILIMAP_NO_ERROR) {
38 logout();
39 } else {
40 mailstream_flush(m_imap->imap_stream);
41 return;
42 }
38 } 43 }
39 server = account->getServer().latin1(); 44 server = account->getServer().latin1();
40 port = account->getPort().toUInt(); 45 port = account->getPort().toUInt();
41 if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { 46 if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) {
42 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); 47 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true );
43 login.show(); 48 login.show();
44 if ( QDialog::Accepted == login.exec() ) { 49 if ( QDialog::Accepted == login.exec() ) {
45 // ok 50 // ok
46 user = strdup( login.getUser().latin1() ); 51 user = strdup( login.getUser().latin1() );
47 pass = strdup( login.getPassword().latin1() ); 52 pass = strdup( login.getPassword().latin1() );
48 } else { 53 } else {
49 // cancel 54 // cancel
50 qDebug( "IMAP: Login canceled" ); 55 qDebug( "IMAP: Login canceled" );
51 return; 56 return;
52 } 57 }
53 } else { 58 } else {
54 user = account->getUser().latin1(); 59 user = account->getUser().latin1();
55 pass = account->getPassword().latin1(); 60 pass = account->getPassword().latin1();
56 } 61 }
57 62
58 m_imap = mailimap_new( 20, &imap_progress ); 63 m_imap = mailimap_new( 20, &imap_progress );
59 /* connect */ 64 /* connect */
60 if (account->getSSL()) { 65 if (account->getSSL()) {
61 err = mailimap_ssl_connect( m_imap, (char*)server, port ); 66 err = mailimap_ssl_connect( m_imap, (char*)server, port );
62 } else { 67 } else {
63 err = mailimap_socket_connect( m_imap, (char*)server, port ); 68 err = mailimap_socket_connect( m_imap, (char*)server, port );
64 } 69 }
65 70
66 if ( err != MAILIMAP_NO_ERROR && 71 if ( err != MAILIMAP_NO_ERROR &&
67 err != MAILIMAP_NO_ERROR_AUTHENTICATED && 72 err != MAILIMAP_NO_ERROR_AUTHENTICATED &&
68 err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { 73 err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) {
69 qDebug("error connecting server: %s",m_imap->imap_response); 74 qDebug("error connecting server: %s",m_imap->imap_response);
70 mailimap_free( m_imap ); 75 mailimap_free( m_imap );
71 m_imap = 0; 76 m_imap = 0;
72 return; 77 return;
73 } 78 }
74 79
75 /* login */ 80 /* login */
76 err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); 81 err = mailimap_login_simple( m_imap, (char*)user, (char*)pass );
77 if ( err != MAILIMAP_NO_ERROR ) { 82 if ( err != MAILIMAP_NO_ERROR ) {
78 qDebug("error logging in imap: %s",m_imap->imap_response); 83 qDebug("error logging in imap: %s",m_imap->imap_response);
79 err = mailimap_close( m_imap ); 84 err = mailimap_close( m_imap );
80 mailimap_free( m_imap ); 85 mailimap_free( m_imap );
81 m_imap = 0; 86 m_imap = 0;
82 } 87 }
83} 88}
84 89
85void IMAPwrapper::logout() 90void IMAPwrapper::logout()