summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-18 10:57:05 (UTC)
committer zautrix <zautrix>2004-10-18 10:57:05 (UTC)
commita83b6694d2f80ec58f6eb88684897052c69276a0 (patch) (unidiff)
tree4b20f33e874f035f54021638125ed293e4202613
parent112db6c41265da5255a58424186d95d7a00b6ff0 (diff)
downloadkdepimpi-a83b6694d2f80ec58f6eb88684897052c69276a0.zip
kdepimpi-a83b6694d2f80ec58f6eb88684897052c69276a0.tar.gz
kdepimpi-a83b6694d2f80ec58f6eb88684897052c69276a0.tar.bz2
some mail imap changes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libmailwrapper/imapwrapper.cpp127
1 files changed, 72 insertions, 55 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
@@ -61,7 +61,7 @@ void IMAPwrapper::progress( QString m )
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;
@@ -69,6 +69,7 @@ void IMAPwrapper::progress( QString m )
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}
74bool IMAPwrapper::start_tls(bool force_tls) 75bool IMAPwrapper::start_tls(bool force_tls)
@@ -233,67 +234,83 @@ void IMAPwrapper::logout()
233 234
234void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target , int maxSizeInKb) 235void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target , int maxSizeInKb)
235{ 236{
236 int err = MAILIMAP_NO_ERROR;
237 clist *result = 0;
238 clistcell *current;
239 mailimap_fetch_type *fetchType = 0;
240 mailimap_set *set = 0;
241
242 login();
243 if (!m_imap) {
244 return;
245 }
246 /* select mailbox READONLY for operations */
247 err = selectMbox(mailbox);
248 if ( err != MAILIMAP_NO_ERROR ) {
249 return;
250 }
251 237
252 int last = m_imap->imap_selection_info->sel_exists; 238 int tryAgain = 1;
239 while ( tryAgain >= 0 ) {
240 int err = MAILIMAP_NO_ERROR;
241 clist *result = 0;
242 clistcell *current;
243 mailimap_fetch_type *fetchType = 0;
244 mailimap_set *set = 0;
253 245
254 if (last == 0) { 246 login();
255 Global::statusMessage(tr("Mailbox has no mails")); 247 if (!m_imap) {
256 return; 248 return;
257 } else { 249 }
258 } 250 /* select mailbox READONLY for operations */
259 251 err = selectMbox(mailbox);
260 Global::statusMessage(tr("Fetching header list")); 252 if ( err != MAILIMAP_NO_ERROR ) {
261 qApp->processEvents(); 253 return;
262 /* the range has to start at 1!!! not with 0!!!! */ 254 }
263 set = mailimap_set_new_interval( 1, last );
264 fetchType = mailimap_fetch_type_new_fetch_att_list_empty();
265 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());
267 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());
269
270 err = mailimap_fetch( m_imap, set, fetchType, &result );
271 mailimap_set_free( set );
272 mailimap_fetch_type_free( fetchType );
273 255
274 QString date,subject,from; 256 int last = m_imap->imap_selection_info->sel_exists;
275 257
276 if ( err == MAILIMAP_NO_ERROR ) { 258 if (last == 0) {
277 mailimap_msg_att * msg_att; 259 Global::statusMessage(tr("Mailbox has no mails"));
278 int i = 0; 260 return;
279 for (current = clist_begin(result); current != 0; current=clist_next(current)) { 261 } else {
280 ++i; 262 }
281 msg_att = (mailimap_msg_att*)current->data; 263 progress( tr("Fetch "));
282 RecMail*m = parse_list_result(msg_att); 264 mMax = last;
283 if (m) { 265 //qDebug("last %d ", last);
284 if ( maxSizeInKb == 0 || m->Msgsize()<=maxSizeInKb*1024 ) { 266 Global::statusMessage(tr("Fetching header list"));
285 m->setNumber(i); 267 qApp->processEvents();
286 m->setMbox(mailbox); 268 /* the range has to start at 1!!! not with 0!!!! */
287 m->setWrapper(this); 269 //LR the access to web.de imap server is no working with value 1
288 target.append(m); 270 qDebug("interval %d - %d ", tryAgain, last-1+tryAgain );
271 set = mailimap_set_new_interval( tryAgain, last );
272 fetchType = mailimap_fetch_type_new_fetch_att_list_empty();
273 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope());
274 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags());
275 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate());
276 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size());
277
278 err = mailimap_fetch( m_imap, set, fetchType, &result );
279 mailimap_set_free( set );
280 mailimap_fetch_type_free( fetchType );
281
282 QString date,subject,from;
283
284 if ( err == MAILIMAP_NO_ERROR ) {
285 tryAgain = -1;
286 mailimap_msg_att * msg_att;
287 int i = 0;
288 for (current = clist_begin(result); current != 0; current=clist_next(current)) {
289 ++i;
290 //qDebug("iii %d ",i);
291 msg_att = (mailimap_msg_att*)current->data;
292 RecMail*m = parse_list_result(msg_att);
293 if (m) {
294 if ( maxSizeInKb == 0 || m->Msgsize()<=maxSizeInKb*1024 ) {
295 m->setNumber(i);
296 m->setMbox(mailbox);
297 m->setWrapper(this);
298 target.append(m);
299 }
289 } 300 }
290 } 301 }
302 Global::statusMessage(tr("Mailbox has %1 mails").arg(target.count()));
303 } else {
304 --tryAgain;
305 --tryAgain;
306 if ( tryAgain < 0 )
307 Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response));
308 else
309 qDebug("try again... ");
291 } 310 }
292 Global::statusMessage(tr("Mailbox has %1 mails").arg(target.count())); 311
293 } else { 312 if (result) mailimap_fetch_list_free(result);
294 Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response));
295 } 313 }
296 if (result) mailimap_fetch_list_free(result);
297} 314}
298 315
299QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() 316QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders()
@@ -952,7 +969,7 @@ void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target)
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 ..."));