summaryrefslogtreecommitdiffabout
path: root/kmicromail
Unidiff
Diffstat (limited to 'kmicromail') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libmailwrapper/imapwrapper.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp
index be825ef..ca1c7f1 100644
--- a/kmicromail/libmailwrapper/imapwrapper.cpp
+++ b/kmicromail/libmailwrapper/imapwrapper.cpp
@@ -374,145 +374,156 @@ QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders()
374 } 374 }
375 } 375 }
376 del = list->mb_delimiter; 376 del = list->mb_delimiter;
377 folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); 377 folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix()));
378 } 378 }
379 } else { 379 } else {
380 qDebug("error fetching folders "); 380 qDebug("error fetching folders ");
381 381
382 } 382 }
383 if (result) mailimap_list_result_free( result ); 383 if (result) mailimap_list_result_free( result );
384 return folders; 384 return folders;
385} 385}
386 386
387RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) 387RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
388{ 388{
389 RecMail * m = 0; 389 RecMail * m = 0;
390 mailimap_msg_att_item *item=0; 390 mailimap_msg_att_item *item=0;
391 clistcell *current,*c,*cf; 391 clistcell *current,*c,*cf;
392 mailimap_msg_att_dynamic*flist; 392 mailimap_msg_att_dynamic*flist;
393 mailimap_flag_fetch*cflag; 393 mailimap_flag_fetch*cflag;
394 int size; 394 int size;
395 QBitArray mFlags(7); 395 QBitArray mFlags(7);
396 QStringList addresslist; 396 QStringList addresslist;
397 397
398 if (!m_att) { 398 if (!m_att) {
399 return m; 399 return m;
400 } 400 }
401 m = new RecMail(); 401 m = new RecMail();
402 for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { 402 for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) {
403 current = c; 403 current = c;
404 size = 0; 404 size = 0;
405 item = (mailimap_msg_att_item*)current->data; 405 item = (mailimap_msg_att_item*)current->data;
406 if ( !item )
407 continue;
406 if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { 408 if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) {
407 flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; 409 flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn;
408 if (!flist->att_list) { 410 if (!flist || !flist->att_list) {
409 continue; 411 continue;
410 } 412 }
411 cf = flist->att_list->first; 413 cf = flist->att_list->first;
414 if( ! cf )
412 for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { 415 for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) {
413 cflag = (mailimap_flag_fetch*)cf->data; 416 cflag = (mailimap_flag_fetch*)cf->data;
417 if( ! cflag )
418 qDebug("imap:not cflag ");
414 if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { 419 if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) {
415 switch (cflag->fl_flag->fl_type) { 420 switch (cflag->fl_flag->fl_type) {
416 case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ 421 case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */
417 mFlags.setBit(FLAG_ANSWERED); 422 mFlags.setBit(FLAG_ANSWERED);
418 break; 423 break;
419 case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ 424 case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */
420 mFlags.setBit(FLAG_FLAGGED); 425 mFlags.setBit(FLAG_FLAGGED);
421 break; 426 break;
422 case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ 427 case MAILIMAP_FLAG_DELETED: /* \Deleted flag */
423 mFlags.setBit(FLAG_DELETED); 428 mFlags.setBit(FLAG_DELETED);
424 break; 429 break;
425 case MAILIMAP_FLAG_SEEN: /* \Seen flag */ 430 case MAILIMAP_FLAG_SEEN: /* \Seen flag */
426 mFlags.setBit(FLAG_SEEN); 431 mFlags.setBit(FLAG_SEEN);
427 break; 432 break;
428 case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ 433 case MAILIMAP_FLAG_DRAFT: /* \Draft flag */
429 mFlags.setBit(FLAG_DRAFT); 434 mFlags.setBit(FLAG_DRAFT);
430 break; 435 break;
431 case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ 436 case MAILIMAP_FLAG_KEYWORD: /* keyword flag */
432 break; 437 break;
433 case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ 438 case MAILIMAP_FLAG_EXTENSION: /* \extension flag */
434 break; 439 break;
435 default: 440 default:
436 break; 441 break;
437 } 442 }
438 } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { 443 } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) {
439 mFlags.setBit(FLAG_RECENT); 444 mFlags.setBit(FLAG_RECENT);
440 } 445 }
441 } 446 }
442 continue; 447 continue;
443 } 448 }
449 if ( item->att_data.att_static == NULL )
450 continue;
444 if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { 451 if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) {
445 mailimap_envelope * head = item->att_data.att_static->att_data.att_env; 452 mailimap_envelope * head = item->att_data.att_static->att_data.att_env;
446 m->setDate(head->env_date); 453 if ( head == NULL )
447 m->setSubject(convert_String((const char*)head->env_subject)); 454 continue;
455 if ( head->env_date != NULL )
456 m->setDate(head->env_date);
457 if ( head->env_subject != NULL )
458 m->setSubject(convert_String((const char*)head->env_subject));
448 //m->setSubject(head->env_subject); 459 //m->setSubject(head->env_subject);
449 if (head->env_from!=NULL) { 460 if (head->env_from!=NULL) {
450 addresslist = address_list_to_stringlist(head->env_from->frm_list); 461 addresslist = address_list_to_stringlist(head->env_from->frm_list);
451 if (addresslist.count()) { 462 if (addresslist.count()) {
452 m->setFrom(addresslist.first()); 463 m->setFrom(addresslist.first());
453 } 464 }
454 } 465 }
455 if (head->env_to!=NULL) { 466 if (head->env_to!=NULL) {
456 addresslist = address_list_to_stringlist(head->env_to->to_list); 467 addresslist = address_list_to_stringlist(head->env_to->to_list);
457 m->setTo(addresslist); 468 m->setTo(addresslist);
458 } 469 }
459 if (head->env_cc!=NULL) { 470 if (head->env_cc!=NULL) {
460 addresslist = address_list_to_stringlist(head->env_cc->cc_list); 471 addresslist = address_list_to_stringlist(head->env_cc->cc_list);
461 m->setCC(addresslist); 472 m->setCC(addresslist);
462 } 473 }
463 if (head->env_bcc!=NULL) { 474 if (head->env_bcc!=NULL) {
464 addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); 475 addresslist = address_list_to_stringlist(head->env_bcc->bcc_list);
465 m->setBcc(addresslist); 476 m->setBcc(addresslist);
466 } 477 }
467 /* reply to address, eg. email. */ 478 /* reply to address, eg. email. */
468 if (head->env_reply_to!=NULL) { 479 if (head->env_reply_to!=NULL) {
469 addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); 480 addresslist = address_list_to_stringlist(head->env_reply_to->rt_list);
470 if (addresslist.count()) { 481 if (addresslist.count()) {
471 m->setReplyto(addresslist.first()); 482 m->setReplyto(addresslist.first());
472 } 483 }
473 } 484 }
474 if (head->env_in_reply_to!=NULL) { 485 if (head->env_in_reply_to!=NULL) {
475 QString h(head->env_in_reply_to); 486 QString h(head->env_in_reply_to);
476 while (h.length()>0 && h[0]=='<') { 487 while (h.length()>0 && h[0]=='<') {
477 h.remove(0,1); 488 h.remove(0,1);
478 } 489 }
479 while (h.length()>0 && h[h.length()-1]=='>') { 490 while (h.length()>0 && h[h.length()-1]=='>') {
480 h.remove(h.length()-1,1); 491 h.remove(h.length()-1,1);
481 } 492 }
482 if (h.length()>0) { 493 if (h.length()>0) {
483 m->setInreply(QStringList(h)); 494 m->setInreply(QStringList(h));
484 } 495 }
485 } 496 }
486 if (head->env_message_id) { 497 if (head->env_message_id != NULL) {
487 m->setMsgid(QString(head->env_message_id)); 498 m->setMsgid(QString(head->env_message_id));
488 } 499 }
489 } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { 500 } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) {
490#if 0 501#if 0
491 mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; 502 mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date;
492 QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); 503 QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec));
493 qDebug("time %s ",da.toString().latin1() ); 504 qDebug("time %s ",da.toString().latin1() );
494#endif 505#endif
495 } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { 506 } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) {
496 size = item->att_data.att_static->att_data.att_rfc822_size; 507 size = item->att_data.att_static->att_data.att_rfc822_size;
497 } 508 }
498 } 509 }
499 /* msg is already deleted */ 510 /* msg is already deleted */
500 if (mFlags.testBit(FLAG_DELETED) && m) { 511 if (mFlags.testBit(FLAG_DELETED) && m) {
501 delete m; 512 delete m;
502 m = 0; 513 m = 0;
503 } 514 }
504 if (m) { 515 if (m) {
505 m->setFlags(mFlags); 516 m->setFlags(mFlags);
506 m->setMsgsize(size); 517 m->setMsgsize(size);
507 } 518 }
508 return m; 519 return m;
509} 520}
510 521
511RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) 522RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail)
512{ 523{
513 RecBodyP body = new RecBody(); 524 RecBodyP body = new RecBody();
514 const char *mb; 525 const char *mb;
515 int err = MAILIMAP_NO_ERROR; 526 int err = MAILIMAP_NO_ERROR;
516 clist *result = 0; 527 clist *result = 0;
517 clistcell *current; 528 clistcell *current;
518 mailimap_fetch_att *fetchAtt = 0; 529 mailimap_fetch_att *fetchAtt = 0;