author | alwin <alwin> | 2003-12-13 12:49:27 (UTC) |
---|---|---|
committer | alwin <alwin> | 2003-12-13 12:49:27 (UTC) |
commit | 865b023c57f657c8eff26baa670fc76bbcd548e4 (patch) (unidiff) | |
tree | 1d40c66d0b4e571277be77db1692791688569c9f | |
parent | cb7b0d2e509d5fc1759fee7c8c855e259e44ed95 (diff) | |
download | opie-865b023c57f657c8eff26baa670fc76bbcd548e4.zip opie-865b023c57f657c8eff26baa670fc76bbcd548e4.tar.gz opie-865b023c57f657c8eff26baa670fc76bbcd548e4.tar.bz2 |
try to solve the problems with slow imap-server
-rw-r--r-- | noncore/net/mail/imapwrapper.cpp | 3 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp index 11bf3b8..48e476b 100644 --- a/noncore/net/mail/imapwrapper.cpp +++ b/noncore/net/mail/imapwrapper.cpp | |||
@@ -1,96 +1,97 @@ | |||
1 | 1 | ||
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | 3 | ||
4 | #include "imapwrapper.h" | 4 | #include "imapwrapper.h" |
5 | #include "mailtypes.h" | 5 | #include "mailtypes.h" |
6 | #include <libetpan/mailimap.h> | 6 | #include <libetpan/mailimap.h> |
7 | 7 | ||
8 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) | 8 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) |
9 | { | 9 | { |
10 | account = a; | 10 | account = a; |
11 | m_imap = 0; | 11 | m_imap = 0; |
12 | } | 12 | } |
13 | 13 | ||
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 | 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 | ||
57 | /* login */ | 58 | /* login */ |
58 | err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); | 59 | err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); |
59 | if ( err != MAILIMAP_NO_ERROR ) { | 60 | if ( err != MAILIMAP_NO_ERROR ) { |
60 | qDebug("error logging in imap: %s",m_imap->imap_response); | 61 | qDebug("error logging in imap: %s",m_imap->imap_response); |
61 | err = mailimap_close( m_imap ); | 62 | err = mailimap_close( m_imap ); |
62 | mailimap_free( m_imap ); | 63 | mailimap_free( m_imap ); |
63 | m_imap = 0; | 64 | m_imap = 0; |
64 | } | 65 | } |
65 | } | 66 | } |
66 | 67 | ||
67 | void IMAPwrapper::logout() | 68 | void IMAPwrapper::logout() |
68 | { | 69 | { |
69 | int err = MAILIMAP_NO_ERROR; | 70 | int err = MAILIMAP_NO_ERROR; |
70 | if (!m_imap) return; | 71 | if (!m_imap) return; |
71 | err = mailimap_logout( m_imap ); | 72 | err = mailimap_logout( m_imap ); |
72 | err = mailimap_close( m_imap ); | 73 | err = mailimap_close( m_imap ); |
73 | mailimap_free( m_imap ); | 74 | mailimap_free( m_imap ); |
74 | m_imap = 0; | 75 | m_imap = 0; |
75 | } | 76 | } |
76 | 77 | ||
77 | void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) | 78 | void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) |
78 | { | 79 | { |
79 | const char *mb; | 80 | const char *mb; |
80 | int err = MAILIMAP_NO_ERROR; | 81 | int err = MAILIMAP_NO_ERROR; |
81 | clist *result; | 82 | clist *result; |
82 | clistcell *current; | 83 | clistcell *current; |
83 | // mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate,*fetchAttSize; | 84 | // mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate,*fetchAttSize; |
84 | mailimap_fetch_type *fetchType; | 85 | mailimap_fetch_type *fetchType; |
85 | mailimap_set *set; | 86 | mailimap_set *set; |
86 | 87 | ||
87 | mb = mailbox.latin1(); | 88 | mb = mailbox.latin1(); |
88 | login(); | 89 | login(); |
89 | if (!m_imap) { | 90 | if (!m_imap) { |
90 | return; | 91 | return; |
91 | } | 92 | } |
92 | /* select mailbox READONLY for operations */ | 93 | /* select mailbox READONLY for operations */ |
93 | err = mailimap_examine( m_imap, (char*)mb); | 94 | err = mailimap_examine( m_imap, (char*)mb); |
94 | if ( err != MAILIMAP_NO_ERROR ) { | 95 | if ( err != MAILIMAP_NO_ERROR ) { |
95 | qDebug("error selecting mailbox: %s",m_imap->imap_response); | 96 | qDebug("error selecting mailbox: %s",m_imap->imap_response); |
96 | return; | 97 | return; |
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 | |||
@@ -1,96 +1,97 @@ | |||
1 | 1 | ||
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | 3 | ||
4 | #include "imapwrapper.h" | 4 | #include "imapwrapper.h" |
5 | #include "mailtypes.h" | 5 | #include "mailtypes.h" |
6 | #include <libetpan/mailimap.h> | 6 | #include <libetpan/mailimap.h> |
7 | 7 | ||
8 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) | 8 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) |
9 | { | 9 | { |
10 | account = a; | 10 | account = a; |
11 | m_imap = 0; | 11 | m_imap = 0; |
12 | } | 12 | } |
13 | 13 | ||
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 | 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 | ||
57 | /* login */ | 58 | /* login */ |
58 | err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); | 59 | err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); |
59 | if ( err != MAILIMAP_NO_ERROR ) { | 60 | if ( err != MAILIMAP_NO_ERROR ) { |
60 | qDebug("error logging in imap: %s",m_imap->imap_response); | 61 | qDebug("error logging in imap: %s",m_imap->imap_response); |
61 | err = mailimap_close( m_imap ); | 62 | err = mailimap_close( m_imap ); |
62 | mailimap_free( m_imap ); | 63 | mailimap_free( m_imap ); |
63 | m_imap = 0; | 64 | m_imap = 0; |
64 | } | 65 | } |
65 | } | 66 | } |
66 | 67 | ||
67 | void IMAPwrapper::logout() | 68 | void IMAPwrapper::logout() |
68 | { | 69 | { |
69 | int err = MAILIMAP_NO_ERROR; | 70 | int err = MAILIMAP_NO_ERROR; |
70 | if (!m_imap) return; | 71 | if (!m_imap) return; |
71 | err = mailimap_logout( m_imap ); | 72 | err = mailimap_logout( m_imap ); |
72 | err = mailimap_close( m_imap ); | 73 | err = mailimap_close( m_imap ); |
73 | mailimap_free( m_imap ); | 74 | mailimap_free( m_imap ); |
74 | m_imap = 0; | 75 | m_imap = 0; |
75 | } | 76 | } |
76 | 77 | ||
77 | void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) | 78 | void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) |
78 | { | 79 | { |
79 | const char *mb; | 80 | const char *mb; |
80 | int err = MAILIMAP_NO_ERROR; | 81 | int err = MAILIMAP_NO_ERROR; |
81 | clist *result; | 82 | clist *result; |
82 | clistcell *current; | 83 | clistcell *current; |
83 | // mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate,*fetchAttSize; | 84 | // mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate,*fetchAttSize; |
84 | mailimap_fetch_type *fetchType; | 85 | mailimap_fetch_type *fetchType; |
85 | mailimap_set *set; | 86 | mailimap_set *set; |
86 | 87 | ||
87 | mb = mailbox.latin1(); | 88 | mb = mailbox.latin1(); |
88 | login(); | 89 | login(); |
89 | if (!m_imap) { | 90 | if (!m_imap) { |
90 | return; | 91 | return; |
91 | } | 92 | } |
92 | /* select mailbox READONLY for operations */ | 93 | /* select mailbox READONLY for operations */ |
93 | err = mailimap_examine( m_imap, (char*)mb); | 94 | err = mailimap_examine( m_imap, (char*)mb); |
94 | if ( err != MAILIMAP_NO_ERROR ) { | 95 | if ( err != MAILIMAP_NO_ERROR ) { |
95 | qDebug("error selecting mailbox: %s",m_imap->imap_response); | 96 | qDebug("error selecting mailbox: %s",m_imap->imap_response); |
96 | return; | 97 | return; |