Diffstat (limited to 'kmicromail/libmailwrapper/pop3wrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kmicromail/libmailwrapper/pop3wrapper.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/kmicromail/libmailwrapper/pop3wrapper.cpp b/kmicromail/libmailwrapper/pop3wrapper.cpp index 9d52f52..2888f7c 100644 --- a/kmicromail/libmailwrapper/pop3wrapper.cpp +++ b/kmicromail/libmailwrapper/pop3wrapper.cpp | |||
@@ -1,19 +1,20 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include "pop3wrapper.h" | 3 | #include "pop3wrapper.h" |
4 | #include "mailtypes.h" | 4 | #include "mailtypes.h" |
5 | #include "logindialog.h" | 5 | #include "logindialog.h" |
6 | #include <libetpan/libetpan.h> | 6 | #include <libetpan/libetpan.h> |
7 | 7 | ||
8 | #include <klocale.h> | ||
8 | 9 | ||
9 | #include <qpe/global.h> | 10 | #include <qpe/global.h> |
10 | #include <qfile.h> | 11 | #include <qfile.h> |
11 | #include <qprogressbar.h> | 12 | #include <qprogressbar.h> |
12 | #include <qapplication.h> | 13 | #include <qapplication.h> |
13 | 14 | ||
14 | /* we don't fetch messages larger than 5 MB */ | 15 | /* we don't fetch messages larger than 5 MB */ |
15 | #define HARD_MSG_SIZE_LIMIT 5242880 | 16 | #define HARD_MSG_SIZE_LIMIT 5242880 |
16 | 17 | ||
17 | using namespace Opie::Core; | 18 | using namespace Opie::Core; |
18 | POP3wrapper::POP3wrapper( POP3account *a ) | 19 | POP3wrapper::POP3wrapper( POP3account *a ) |
19 | : Genericwrapper() { | 20 | : Genericwrapper() { |
@@ -98,25 +99,25 @@ RecBodyP POP3wrapper::fetchBody( const RecMailP &mail ) { | |||
98 | 99 | ||
99 | return body; | 100 | return body; |
100 | } | 101 | } |
101 | 102 | ||
102 | void POP3wrapper::listMessages(const QString &, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb ) | 103 | void POP3wrapper::listMessages(const QString &, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb ) |
103 | { | 104 | { |
104 | login(); | 105 | login(); |
105 | if (!m_pop3) | 106 | if (!m_pop3) |
106 | return; | 107 | return; |
107 | uint32_t res_messages,res_recent,res_unseen; | 108 | uint32_t res_messages,res_recent,res_unseen; |
108 | mailsession_status_folder(m_pop3->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen); | 109 | mailsession_status_folder(m_pop3->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen); |
109 | parseList(target,m_pop3->sto_session,"INBOX", false, maxSizeInKb); | 110 | parseList(target,m_pop3->sto_session,"INBOX", false, maxSizeInKb); |
110 | Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(res_messages)); | 111 | Global::statusMessage( i18n("Mailbox contains %1 mail(s)").arg(res_messages)); |
111 | } | 112 | } |
112 | 113 | ||
113 | void POP3wrapper::login() | 114 | void POP3wrapper::login() |
114 | { | 115 | { |
115 | if (account->getOffline()) | 116 | if (account->getOffline()) |
116 | return; | 117 | return; |
117 | /* we'll hold the line */ | 118 | /* we'll hold the line */ |
118 | if ( m_pop3 != NULL ) | 119 | if ( m_pop3 != NULL ) |
119 | return; | 120 | return; |
120 | 121 | ||
121 | QString server,user, pass; | 122 | QString server,user, pass; |
122 | uint16_t port; | 123 | uint16_t port; |
@@ -156,25 +157,25 @@ void POP3wrapper::login() | |||
156 | } else if ( conntypeset == 0 ) { | 157 | } else if ( conntypeset == 0 ) { |
157 | conntype = CONNECTION_TYPE_TRY_STARTTLS; | 158 | conntype = CONNECTION_TYPE_TRY_STARTTLS; |
158 | } | 159 | } |
159 | 160 | ||
160 | //(ssl?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN); | 161 | //(ssl?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN); |
161 | 162 | ||
162 | pop3_mailstorage_init(m_pop3,(char*)server.latin1(), port, NULL, conntype, POP3_AUTH_TYPE_PLAIN, | 163 | pop3_mailstorage_init(m_pop3,(char*)server.latin1(), port, NULL, conntype, POP3_AUTH_TYPE_PLAIN, |
163 | (char*)user.latin1(),(char*)pass.latin1(),0,0,0); | 164 | (char*)user.latin1(),(char*)pass.latin1(),0,0,0); |
164 | 165 | ||
165 | err = mailstorage_connect(m_pop3); | 166 | err = mailstorage_connect(m_pop3); |
166 | if (err != MAIL_NO_ERROR) { | 167 | if (err != MAIL_NO_ERROR) { |
167 | ; // odebug << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl; | 168 | ; // odebug << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl; |
168 | Global::statusMessage(tr("Error %1 initializing folder").arg( err )); | 169 | Global::statusMessage(i18n("Error %1 initializing folder").arg( err )); |
169 | mailstorage_free(m_pop3); | 170 | mailstorage_free(m_pop3); |
170 | m_pop3 = 0; | 171 | m_pop3 = 0; |
171 | } else { | 172 | } else { |
172 | mailsession * session = m_pop3->sto_session; | 173 | mailsession * session = m_pop3->sto_session; |
173 | mailpop3 * mail = ( ( pop3_session_state_data * )session->sess_data )->pop3_session; | 174 | mailpop3 * mail = ( ( pop3_session_state_data * )session->sess_data )->pop3_session; |
174 | if (mail) { | 175 | if (mail) { |
175 | mail->pop3_progr_fun = &pop3_progress; | 176 | mail->pop3_progr_fun = &pop3_progress; |
176 | } | 177 | } |
177 | } | 178 | } |
178 | } | 179 | } |
179 | 180 | ||
180 | void POP3wrapper::logout() | 181 | void POP3wrapper::logout() |
@@ -193,79 +194,79 @@ QValueList<Opie::Core::OSmartPointer<Folder> >* POP3wrapper::listFolders() { | |||
193 | return folders; | 194 | return folders; |
194 | } | 195 | } |
195 | 196 | ||
196 | void POP3wrapper::deleteMailList(const QValueList<RecMailP>&target) | 197 | void POP3wrapper::deleteMailList(const QValueList<RecMailP>&target) |
197 | { | 198 | { |
198 | login(); | 199 | login(); |
199 | if (!m_pop3) | 200 | if (!m_pop3) |
200 | return; | 201 | return; |
201 | int iii = 0; | 202 | int iii = 0; |
202 | int count = target.count(); | 203 | int count = target.count(); |
203 | 204 | ||
204 | QProgressBar wid ( count ); | 205 | QProgressBar wid ( count ); |
205 | wid.setCaption( tr("Deleting ...")); | 206 | wid.setCaption( i18n("Deleting ...")); |
206 | wid.show(); | 207 | wid.show(); |
207 | while (iii < count ) { | 208 | while (iii < count ) { |
208 | Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count)); | 209 | Global::statusMessage(i18n("Delete message %1 of %2").arg(iii).arg(count)); |
209 | wid.setProgress( iii ); | 210 | wid.setProgress( iii ); |
210 | wid.raise(); | 211 | wid.raise(); |
211 | qApp->processEvents(); | 212 | qApp->processEvents(); |
212 | //qDebug("delete "); | 213 | //qDebug("delete "); |
213 | RecMailP mail = (*target.at( iii )); | 214 | RecMailP mail = (*target.at( iii )); |
214 | int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); | 215 | int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); |
215 | if (err != MAIL_NO_ERROR) { | 216 | if (err != MAIL_NO_ERROR) { |
216 | Global::statusMessage(tr("Error deleting mail")); | 217 | Global::statusMessage(i18n("Error deleting mail")); |
217 | } | 218 | } |
218 | ++iii; | 219 | ++iii; |
219 | } | 220 | } |
220 | } | 221 | } |
221 | void POP3wrapper::deleteMail(const RecMailP&mail) { | 222 | void POP3wrapper::deleteMail(const RecMailP&mail) { |
222 | login(); | 223 | login(); |
223 | if (!m_pop3) | 224 | if (!m_pop3) |
224 | return; | 225 | return; |
225 | int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); | 226 | int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); |
226 | if (err != MAIL_NO_ERROR) { | 227 | if (err != MAIL_NO_ERROR) { |
227 | Global::statusMessage(tr("error deleting mail")); | 228 | Global::statusMessage(i18n("error deleting mail")); |
228 | } | 229 | } |
229 | } | 230 | } |
230 | 231 | ||
231 | void POP3wrapper::answeredMail(const RecMailP&) {} | 232 | void POP3wrapper::answeredMail(const RecMailP&) {} |
232 | 233 | ||
233 | int POP3wrapper::deleteAllMail(const FolderP&) { | 234 | int POP3wrapper::deleteAllMail(const FolderP&) { |
234 | login(); | 235 | login(); |
235 | if (!m_pop3) | 236 | if (!m_pop3) |
236 | return 0; | 237 | return 0; |
237 | int res = 1; | 238 | int res = 1; |
238 | 239 | ||
239 | uint32_t result = 0; | 240 | uint32_t result = 0; |
240 | int err = mailsession_messages_number(m_pop3->sto_session,NULL,&result); | 241 | int err = mailsession_messages_number(m_pop3->sto_session,NULL,&result); |
241 | if (err != MAIL_NO_ERROR) { | 242 | if (err != MAIL_NO_ERROR) { |
242 | Global::statusMessage(tr("Error getting folder info")); | 243 | Global::statusMessage(i18n("Error getting folder info")); |
243 | return 0; | 244 | return 0; |
244 | } | 245 | } |
245 | 246 | ||
246 | 247 | ||
247 | 248 | ||
248 | QProgressBar wid ( result ); | 249 | QProgressBar wid ( result ); |
249 | wid.setCaption( tr("Deleting ...")); | 250 | wid.setCaption( i18n("Deleting ...")); |
250 | wid.show(); | 251 | wid.show(); |
251 | for (unsigned int i = 0; i < result; ++i) { | 252 | for (unsigned int i = 0; i < result; ++i) { |
252 | Global::statusMessage(tr("Delete message %1 of %2").arg(i).arg(result)); | 253 | Global::statusMessage(i18n("Delete message %1 of %2").arg(i).arg(result)); |
253 | wid.setProgress( i ); | 254 | wid.setProgress( i ); |
254 | wid.raise(); | 255 | wid.raise(); |
255 | qApp->processEvents(); | 256 | qApp->processEvents(); |
256 | 257 | ||
257 | err = mailsession_remove_message(m_pop3->sto_session,i+1); | 258 | err = mailsession_remove_message(m_pop3->sto_session,i+1); |
258 | if (err != MAIL_NO_ERROR) { | 259 | if (err != MAIL_NO_ERROR) { |
259 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); | 260 | Global::statusMessage(i18n("Error deleting mail %1").arg(i+1)); |
260 | res=0; | 261 | res=0; |
261 | } | 262 | } |
262 | break; | 263 | break; |
263 | } | 264 | } |
264 | return res; | 265 | return res; |
265 | } | 266 | } |
266 | 267 | ||
267 | void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) { | 268 | void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) { |
268 | login(); | 269 | login(); |
269 | target_stat.message_count = 0; | 270 | target_stat.message_count = 0; |
270 | target_stat.message_unseen = 0; | 271 | target_stat.message_unseen = 0; |
271 | target_stat.message_recent = 0; | 272 | target_stat.message_recent = 0; |