author | harlekin <harlekin> | 2004-01-08 17:42:16 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2004-01-08 17:42:16 (UTC) |
commit | eeb69efb4e0639429e5f6fd15e65b1b6fbaa5c35 (patch) (unidiff) | |
tree | d14fa40cddeceb1b04dafa209841727811c6e71c /noncore/net/mail/libmailwrapper/pop3wrapper.cpp | |
parent | c0a0d53fb92f8a1723c57580a5fd0ade66574ec4 (diff) | |
download | opie-eeb69efb4e0639429e5f6fd15e65b1b6fbaa5c35.zip opie-eeb69efb4e0639429e5f6fd15e65b1b6fbaa5c35.tar.gz opie-eeb69efb4e0639429e5f6fd15e65b1b6fbaa5c35.tar.bz2 |
added support for pop3 tls
Diffstat (limited to 'noncore/net/mail/libmailwrapper/pop3wrapper.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.cpp | 95 |
1 files changed, 52 insertions, 43 deletions
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp index 67bde38..f5eca4a 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp | |||
@@ -13,4 +13,3 @@ | |||
13 | POP3wrapper::POP3wrapper( POP3account *a ) | 13 | POP3wrapper::POP3wrapper( POP3account *a ) |
14 | : Genericwrapper() | 14 | : Genericwrapper() { |
15 | { | ||
16 | account = a; | 15 | account = a; |
@@ -22,4 +21,3 @@ POP3wrapper::POP3wrapper( POP3account *a ) | |||
22 | 21 | ||
23 | POP3wrapper::~POP3wrapper() | 22 | POP3wrapper::~POP3wrapper() { |
24 | { | ||
25 | logout(); | 23 | logout(); |
@@ -31,4 +29,3 @@ POP3wrapper::~POP3wrapper() | |||
31 | 29 | ||
32 | void POP3wrapper::pop3_progress( size_t current, size_t maximum ) | 30 | void POP3wrapper::pop3_progress( size_t current, size_t maximum ) { |
33 | { | ||
34 | qDebug( "POP3: %i of %i", current, maximum ); | 31 | qDebug( "POP3: %i of %i", current, maximum ); |
@@ -36,4 +33,3 @@ void POP3wrapper::pop3_progress( size_t current, size_t maximum ) | |||
36 | 33 | ||
37 | RecBody POP3wrapper::fetchBody( const RecMail &mail ) | 34 | RecBody POP3wrapper::fetchBody( const RecMail &mail ) { |
38 | { | ||
39 | int err = MAILPOP3_NO_ERROR; | 35 | int err = MAILPOP3_NO_ERROR; |
@@ -92,4 +88,6 @@ RecBody POP3wrapper::fetchBody( const RecMail &mail ) | |||
92 | /* clean up */ | 88 | /* clean up */ |
93 | if (mailmsg) mailmessage_free(mailmsg); | 89 | if (mailmsg) |
94 | if (message) free(message); | 90 | mailmessage_free(mailmsg); |
91 | if (message) | ||
92 | free(message); | ||
95 | 93 | ||
@@ -98,6 +96,6 @@ RecBody POP3wrapper::fetchBody( const RecMail &mail ) | |||
98 | 96 | ||
99 | void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) | 97 | void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) { |
100 | { | ||
101 | login(); | 98 | login(); |
102 | if (!m_pop3) return; | 99 | if (!m_pop3) |
100 | return; | ||
103 | uint32_t res_messages,res_recent,res_unseen; | 101 | uint32_t res_messages,res_recent,res_unseen; |
@@ -108,7 +106,8 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) | |||
108 | 106 | ||
109 | void POP3wrapper::login() | 107 | void POP3wrapper::login() { |
110 | { | 108 | if (account->getOffline()) |
111 | if (account->getOffline()) return; | 109 | return; |
112 | /* we'll hold the line */ | 110 | /* we'll hold the line */ |
113 | if ( m_pop3 != NULL ) return; | 111 | if ( m_pop3 != NULL ) |
112 | return; | ||
114 | 113 | ||
@@ -138,6 +137,19 @@ void POP3wrapper::login() | |||
138 | 137 | ||
139 | bool ssl = account->getSSL(); | 138 | // bool ssl = account->getSSL(); |
140 | 139 | ||
141 | m_pop3=mailstorage_new(NULL); | 140 | m_pop3=mailstorage_new(NULL); |
142 | int conntype = (ssl?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN); | 141 | |
142 | int conntypeset = account->ConnectionType(); | ||
143 | int conntype = 0; | ||
144 | if ( conntypeset == 3 ) { | ||
145 | conntype = CONNECTION_TYPE_COMMAND; | ||
146 | } else if ( conntypeset == 2 ) { | ||
147 | conntype = CONNECTION_TYPE_TLS; | ||
148 | } else if ( conntypeset == 1 ) { | ||
149 | conntype = CONNECTION_TYPE_STARTTLS; | ||
150 | } else if ( conntypeset == 0 ) { | ||
151 | conntype = CONNECTION_TYPE_TRY_STARTTLS; | ||
152 | } | ||
153 | |||
154 | //(ssl?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN); | ||
143 | 155 | ||
@@ -146,2 +158,4 @@ void POP3wrapper::login() | |||
146 | 158 | ||
159 | |||
160 | |||
147 | m_folder = mailfolder_new(m_pop3, NULL, NULL); | 161 | m_folder = mailfolder_new(m_pop3, NULL, NULL); |
@@ -165,6 +179,6 @@ void POP3wrapper::login() | |||
165 | 179 | ||
166 | void POP3wrapper::logout() | 180 | void POP3wrapper::logout() { |
167 | { | ||
168 | int err = MAILPOP3_NO_ERROR; | 181 | int err = MAILPOP3_NO_ERROR; |
169 | if ( m_pop3 == NULL ) return; | 182 | if ( m_pop3 == NULL ) |
183 | return; | ||
170 | mailfolder_free(m_folder); | 184 | mailfolder_free(m_folder); |
@@ -176,4 +190,3 @@ void POP3wrapper::logout() | |||
176 | 190 | ||
177 | QList<Folder>* POP3wrapper::listFolders() | 191 | QList<Folder>* POP3wrapper::listFolders() { |
178 | { | ||
179 | QList<Folder> * folders = new QList<Folder>(); | 192 | QList<Folder> * folders = new QList<Folder>(); |
@@ -185,6 +198,6 @@ QList<Folder>* POP3wrapper::listFolders() | |||
185 | 198 | ||
186 | void POP3wrapper::deleteMail(const RecMail&mail) | 199 | void POP3wrapper::deleteMail(const RecMail&mail) { |
187 | { | ||
188 | login(); | 200 | login(); |
189 | if (!m_pop3) return; | 201 | if (!m_pop3) |
202 | return; | ||
190 | int err = mailsession_remove_message(m_folder->fld_session,mail.getNumber()); | 203 | int err = mailsession_remove_message(m_folder->fld_session,mail.getNumber()); |
@@ -195,10 +208,8 @@ void POP3wrapper::deleteMail(const RecMail&mail) | |||
195 | 208 | ||
196 | void POP3wrapper::answeredMail(const RecMail&) | 209 | void POP3wrapper::answeredMail(const RecMail&) {} |
197 | { | ||
198 | } | ||
199 | 210 | ||
200 | int POP3wrapper::deleteAllMail(const Folder*) | 211 | int POP3wrapper::deleteAllMail(const Folder*) { |
201 | { | ||
202 | login(); | 212 | login(); |
203 | if (!m_pop3) return 0; | 213 | if (!m_pop3) |
214 | return 0; | ||
204 | int res = 1; | 215 | int res = 1; |
@@ -222,4 +233,3 @@ int POP3wrapper::deleteAllMail(const Folder*) | |||
222 | 233 | ||
223 | void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) | 234 | void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) { |
224 | { | ||
225 | login(); | 235 | login(); |
@@ -228,3 +238,4 @@ void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) | |||
228 | target_stat.message_recent = 0; | 238 | target_stat.message_recent = 0; |
229 | if (!m_pop3) return; | 239 | if (!m_pop3) |
240 | return; | ||
230 | int r = mailsession_status_folder(m_folder->fld_session,0,&target_stat.message_count, | 241 | int r = mailsession_status_folder(m_folder->fld_session,0,&target_stat.message_count, |
@@ -233,4 +244,3 @@ void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) | |||
233 | 244 | ||
234 | encodedString* POP3wrapper::fetchRawBody(const RecMail&mail) | 245 | encodedString* POP3wrapper::fetchRawBody(const RecMail&mail) { |
235 | { | ||
236 | char*target=0; | 246 | char*target=0; |
@@ -241,3 +251,4 @@ encodedString* POP3wrapper::fetchRawBody(const RecMail&mail) | |||
241 | err = mailmessage_fetch(mailmsg,&target,&length); | 251 | err = mailmessage_fetch(mailmsg,&target,&length); |
242 | if (mailmsg) mailmessage_free(mailmsg); | 252 | if (mailmsg) |
253 | mailmessage_free(mailmsg); | ||
243 | if (target) { | 254 | if (target) { |
@@ -248,4 +259,3 @@ encodedString* POP3wrapper::fetchRawBody(const RecMail&mail) | |||
248 | 259 | ||
249 | const QString&POP3wrapper::getType()const | 260 | const QString&POP3wrapper::getType()const { |
250 | { | ||
251 | return account->getType(); | 261 | return account->getType(); |
@@ -253,4 +263,3 @@ const QString&POP3wrapper::getType()const | |||
253 | 263 | ||
254 | const QString&POP3wrapper::getName()const | 264 | const QString&POP3wrapper::getName()const { |
255 | { | ||
256 | return account->getAccountName(); | 265 | return account->getAccountName(); |