summaryrefslogtreecommitdiff
path: root/noncore/net/mail/libmailwrapper/imapwrapper.cpp
Unidiff
Diffstat (limited to 'noncore/net/mail/libmailwrapper/imapwrapper.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
index 9b7c0e0..fe75a15 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
@@ -228,30 +228,34 @@ void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSma
228 } 228 }
229 229
230 int last = m_imap->imap_selection_info->sel_exists; 230 int last = m_imap->imap_selection_info->sel_exists;
231 231
232 if (last == 0) { 232 if (last == 0) {
233 Global::statusMessage(tr("Mailbox has no mails")); 233 Global::statusMessage(tr("Mailbox has no mails"));
234 return; 234 return;
235 } else { 235 } else {
236 } 236 }
237 237
238 /* the range has to start at 1!!! not with 0!!!! */ 238 /* the range has to start at 1!!! not with 0!!!! */
239 set = mailimap_set_new_interval( 1, last ); 239 set = mailimap_set_new_interval( 1, last );
240
241
242 fetchType = mailimap_fetch_type_new_all();
243/*
240 fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); 244 fetchType = mailimap_fetch_type_new_fetch_att_list_empty();
241 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); 245 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope());
242 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); 246 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags());
243 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); 247 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate());
244 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); 248 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size());
245 249*/
246 err = mailimap_fetch( m_imap, set, fetchType, &result ); 250 err = mailimap_fetch( m_imap, set, fetchType, &result );
247 mailimap_set_free( set ); 251 mailimap_set_free( set );
248 mailimap_fetch_type_free( fetchType ); 252 mailimap_fetch_type_free( fetchType );
249 253
250 QString date,subject,from; 254 QString date,subject,from;
251 255
252 if ( err == MAILIMAP_NO_ERROR ) { 256 if ( err == MAILIMAP_NO_ERROR ) {
253 mailimap_msg_att * msg_att; 257 mailimap_msg_att * msg_att;
254 int i = 0; 258 int i = 0;
255 for (current = clist_begin(result); current != 0; current=clist_next(current)) { 259 for (current = clist_begin(result); current != 0; current=clist_next(current)) {
256 ++i; 260 ++i;
257 msg_att = (mailimap_msg_att*)current->data; 261 msg_att = (mailimap_msg_att*)current->data;
@@ -366,28 +370,28 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
366 RecMail * m = 0; 370 RecMail * m = 0;
367 mailimap_msg_att_item *item=0; 371 mailimap_msg_att_item *item=0;
368 clistcell *current,*c,*cf; 372 clistcell *current,*c,*cf;
369 mailimap_msg_att_dynamic*flist; 373 mailimap_msg_att_dynamic*flist;
370 mailimap_flag_fetch*cflag; 374 mailimap_flag_fetch*cflag;
371 int size; 375 int size;
372 QBitArray mFlags(7); 376 QBitArray mFlags(7);
373 QStringList addresslist; 377 QStringList addresslist;
374 378
375 if (!m_att) { 379 if (!m_att) {
376 return m; 380 return m;
377 } 381 }
382 size = 0;
378 m = new RecMail(); 383 m = new RecMail();
379 for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { 384 for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) {
380 current = c; 385 current = c;
381 size = 0;
382 item = (mailimap_msg_att_item*)current->data; 386 item = (mailimap_msg_att_item*)current->data;
383 if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { 387 if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) {
384 flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; 388 flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn;
385 if (!flist->att_list) { 389 if (!flist->att_list) {
386 continue; 390 continue;
387 } 391 }
388 cf = flist->att_list->first; 392 cf = flist->att_list->first;
389 for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { 393 for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) {
390 cflag = (mailimap_flag_fetch*)cf->data; 394 cflag = (mailimap_flag_fetch*)cf->data;
391 if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { 395 if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) {
392 switch (cflag->fl_flag->fl_type) { 396 switch (cflag->fl_flag->fl_type) {
393 case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ 397 case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */
@@ -456,41 +460,47 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
456 while (h.length()>0 && h[h.length()-1]=='>') { 460 while (h.length()>0 && h[h.length()-1]=='>') {
457 h.remove(h.length()-1,1); 461 h.remove(h.length()-1,1);
458 } 462 }
459 if (h.length()>0) { 463 if (h.length()>0) {
460 m->setInreply(QStringList(h)); 464 m->setInreply(QStringList(h));
461 } 465 }
462 } 466 }
463 if (head->env_message_id) { 467 if (head->env_message_id) {
464 m->setMsgid(QString(head->env_message_id)); 468 m->setMsgid(QString(head->env_message_id));
465 } 469 }
466 } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { 470 } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) {
467#if 0 471#if 0
468 mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; 472 mailimap_date_time*date = item->att_data.att_static->att_data.att_internal_date;
473 if (date->dt_sec>60 || date->dt_sec<0) date->dt_sec=0;
474 //QDateTime da(QDate(d->dt_year,date->dt_month,date->dt_day),QTime(date->dt_hour,date->dt_min,date->dt_sec));
475 QString timestring = TimeString::numberDateString(QDate(date->dt_year,date->dt_month,date->dt_day))+" ";
476 timestring+=TimeString::timeString(QTime(date->dt_hour,date->dt_min,date->dt_sec))+" ";
477 timestring.sprintf(timestring+" %+05i",date->dt_zone);
478 m->setDate(timestring);
469 QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); 479 QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec));
470 odebug << "" << d->dt_year << " " << d->dt_month << " " << d->dt_day << " - " << d->dt_hour << " " << d->dt_min << " " << d->dt_sec << "" << oendl; 480 odebug << "" << d->dt_year << " " << d->dt_month << " " << d->dt_day << " - " << d->dt_hour << " " << d->dt_min << " " << d->dt_sec << "" << oendl;
471 odebug << da.toString() << oendl; 481 odebug << da.toString() << oendl;
472#endif 482#endif
473 } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { 483 } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) {
474 size = item->att_data.att_static->att_data.att_rfc822_size; 484 //size = item->att_data.att_static->att_data.att_rfc822_size;
485 m->setMsgsize(item->att_data.att_static->att_data.att_rfc822_size);
475 } 486 }
476 } 487 }
477 /* msg is already deleted */ 488 /* msg is already deleted */
478 if (mFlags.testBit(FLAG_DELETED) && m) { 489 if (mFlags.testBit(FLAG_DELETED) && m) {
479 delete m; 490 delete m;
480 m = 0; 491 m = 0;
481 } 492 }
482 if (m) { 493 if (m) {
483 m->setFlags(mFlags); 494 m->setFlags(mFlags);
484 m->setMsgsize(size);
485 } 495 }
486 return m; 496 return m;
487} 497}
488 498
489RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) 499RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail)
490{ 500{
491 RecBodyP body = new RecBody(); 501 RecBodyP body = new RecBody();
492 const char *mb; 502 const char *mb;
493 int err = MAILIMAP_NO_ERROR; 503 int err = MAILIMAP_NO_ERROR;
494 clist *result = 0; 504 clist *result = 0;
495 clistcell *current; 505 clistcell *current;
496 mailimap_fetch_att *fetchAtt = 0; 506 mailimap_fetch_att *fetchAtt = 0;