-rw-r--r-- | kmicromail/libmailwrapper/imapwrapper.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp index b0dd1b8..a6688ed 100644 --- a/kmicromail/libmailwrapper/imapwrapper.cpp +++ b/kmicromail/libmailwrapper/imapwrapper.cpp | |||
@@ -58,20 +58,21 @@ void IMAPwrapper::imap_progress( size_t current, size_t maximum ) | |||
58 | void IMAPwrapper::progress( QString m ) | 58 | void IMAPwrapper::progress( QString m ) |
59 | { | 59 | { |
60 | 60 | ||
61 | static QString mProgrMess; | 61 | static QString mProgrMess; |
62 | if ( m != QString::null ) { | 62 | if ( m != QString::null ) { |
63 | mProgrMess = m; | 63 | mProgrMess = m; |
64 | mCurrent = 0; | 64 | mCurrent = 1; |
65 | return; | 65 | return; |
66 | } | 66 | } |
67 | QString mess; | 67 | QString mess; |
68 | //qDebug("progress "); | 68 | //qDebug("progress "); |
69 | if ( mMax ) mess = mProgrMess +tr(" message %1 of %2").arg( mCurrent++).arg(mMax); | 69 | if ( mMax ) mess = mProgrMess +tr(" message %1 of %2").arg( mCurrent++).arg(mMax); |
70 | else mess = mProgrMess +tr(" message %1").arg( mCurrent++); | 70 | else mess = mProgrMess +tr(" message %1").arg( mCurrent++); |
71 | Global::statusMessage(mess); | 71 | Global::statusMessage(mess); |
72 | qDebug("Progress %s %s", mess.latin1(), m.latin1()); | ||
72 | qApp->processEvents(); | 73 | qApp->processEvents(); |
73 | } | 74 | } |
74 | bool IMAPwrapper::start_tls(bool force_tls) | 75 | bool IMAPwrapper::start_tls(bool force_tls) |
75 | { | 76 | { |
76 | int err; | 77 | int err; |
77 | bool try_tls; | 78 | bool try_tls; |
@@ -230,12 +231,15 @@ void IMAPwrapper::logout() | |||
230 | m_imap = 0; | 231 | m_imap = 0; |
231 | m_Lastmbox = ""; | 232 | m_Lastmbox = ""; |
232 | } | 233 | } |
233 | 234 | ||
234 | void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target , int maxSizeInKb) | 235 | void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target , int maxSizeInKb) |
235 | { | 236 | { |
237 | |||
238 | int tryAgain = 1; | ||
239 | while ( tryAgain >= 0 ) { | ||
236 | int err = MAILIMAP_NO_ERROR; | 240 | int err = MAILIMAP_NO_ERROR; |
237 | clist *result = 0; | 241 | clist *result = 0; |
238 | clistcell *current; | 242 | clistcell *current; |
239 | mailimap_fetch_type *fetchType = 0; | 243 | mailimap_fetch_type *fetchType = 0; |
240 | mailimap_set *set = 0; | 244 | mailimap_set *set = 0; |
241 | 245 | ||
@@ -253,17 +257,21 @@ void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSma | |||
253 | 257 | ||
254 | if (last == 0) { | 258 | if (last == 0) { |
255 | Global::statusMessage(tr("Mailbox has no mails")); | 259 | Global::statusMessage(tr("Mailbox has no mails")); |
256 | return; | 260 | return; |
257 | } else { | 261 | } else { |
258 | } | 262 | } |
259 | 263 | progress( tr("Fetch ")); | |
264 | mMax = last; | ||
265 | //qDebug("last %d ", last); | ||
260 | Global::statusMessage(tr("Fetching header list")); | 266 | Global::statusMessage(tr("Fetching header list")); |
261 | qApp->processEvents(); | 267 | qApp->processEvents(); |
262 | /* the range has to start at 1!!! not with 0!!!! */ | 268 | /* the range has to start at 1!!! not with 0!!!! */ |
263 | set = mailimap_set_new_interval( 1, last ); | 269 | //LR the access to web.de imap server is no working with value 1 |
270 | qDebug("interval %d - %d ", tryAgain, last-1+tryAgain ); | ||
271 | set = mailimap_set_new_interval( tryAgain, last ); | ||
264 | fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); | 272 | fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); |
265 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); | 273 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); |
266 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); | 274 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); |
267 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); | 275 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); |
268 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); | 276 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); |
269 | 277 | ||
@@ -271,16 +279,18 @@ void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSma | |||
271 | mailimap_set_free( set ); | 279 | mailimap_set_free( set ); |
272 | mailimap_fetch_type_free( fetchType ); | 280 | mailimap_fetch_type_free( fetchType ); |
273 | 281 | ||
274 | QString date,subject,from; | 282 | QString date,subject,from; |
275 | 283 | ||
276 | if ( err == MAILIMAP_NO_ERROR ) { | 284 | if ( err == MAILIMAP_NO_ERROR ) { |
285 | tryAgain = -1; | ||
277 | mailimap_msg_att * msg_att; | 286 | mailimap_msg_att * msg_att; |
278 | int i = 0; | 287 | int i = 0; |
279 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { | 288 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { |
280 | ++i; | 289 | ++i; |
290 | //qDebug("iii %d ",i); | ||
281 | msg_att = (mailimap_msg_att*)current->data; | 291 | msg_att = (mailimap_msg_att*)current->data; |
282 | RecMail*m = parse_list_result(msg_att); | 292 | RecMail*m = parse_list_result(msg_att); |
283 | if (m) { | 293 | if (m) { |
284 | if ( maxSizeInKb == 0 || m->Msgsize()<=maxSizeInKb*1024 ) { | 294 | if ( maxSizeInKb == 0 || m->Msgsize()<=maxSizeInKb*1024 ) { |
285 | m->setNumber(i); | 295 | m->setNumber(i); |
286 | m->setMbox(mailbox); | 296 | m->setMbox(mailbox); |
@@ -288,16 +298,23 @@ void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSma | |||
288 | target.append(m); | 298 | target.append(m); |
289 | } | 299 | } |
290 | } | 300 | } |
291 | } | 301 | } |
292 | Global::statusMessage(tr("Mailbox has %1 mails").arg(target.count())); | 302 | Global::statusMessage(tr("Mailbox has %1 mails").arg(target.count())); |
293 | } else { | 303 | } else { |
304 | --tryAgain; | ||
305 | --tryAgain; | ||
306 | if ( tryAgain < 0 ) | ||
294 | Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response)); | 307 | Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response)); |
308 | else | ||
309 | qDebug("try again... "); | ||
295 | } | 310 | } |
311 | |||
296 | if (result) mailimap_fetch_list_free(result); | 312 | if (result) mailimap_fetch_list_free(result); |
297 | } | 313 | } |
314 | } | ||
298 | 315 | ||
299 | QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() | 316 | QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() |
300 | { | 317 | { |
301 | const char *path, *mask; | 318 | const char *path, *mask; |
302 | int err = MAILIMAP_NO_ERROR; | 319 | int err = MAILIMAP_NO_ERROR; |
303 | clist *result = 0; | 320 | clist *result = 0; |
@@ -949,13 +966,13 @@ void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target) | |||
949 | int iii = 0; | 966 | int iii = 0; |
950 | int count = target.count(); | 967 | int count = target.count(); |
951 | // qDebug("imap remove count %d ", count); | 968 | // qDebug("imap remove count %d ", count); |
952 | 969 | ||
953 | 970 | ||
954 | mMax = count; | 971 | mMax = count; |
955 | //progress( tr("Delete")); | 972 | progress( tr("Delete")); |
956 | 973 | ||
957 | QProgressBar wid ( count ); | 974 | QProgressBar wid ( count ); |
958 | wid.setCaption( tr("Deleting ...")); | 975 | wid.setCaption( tr("Deleting ...")); |
959 | wid.show(); | 976 | wid.show(); |
960 | while (iii < count ) { | 977 | while (iii < count ) { |
961 | Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count)); | 978 | Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count)); |