summaryrefslogtreecommitdiff
path: root/noncore/net/mail/pop3wrapper.cpp
Unidiff
Diffstat (limited to 'noncore/net/mail/pop3wrapper.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/mail/pop3wrapper.cpp33
1 files changed, 25 insertions, 8 deletions
diff --git a/noncore/net/mail/pop3wrapper.cpp b/noncore/net/mail/pop3wrapper.cpp
index 2c2a42a..65cd4ba 100644
--- a/noncore/net/mail/pop3wrapper.cpp
+++ b/noncore/net/mail/pop3wrapper.cpp
@@ -443,25 +443,20 @@ void POP3wrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mime,
443 return; 443 return;
444 } 444 }
445 int r; 445 int r;
446 char*data = 0; 446 char*data = 0;
447 size_t len; 447 size_t len;
448 clistiter * cur = 0; 448 clistiter * cur = 0;
449 mailmime_single_fields fields;
450 int res; 449 int res;
451 QString b; 450 QString b;
452 memset(&fields, 0, sizeof(struct mailmime_single_fields));
453 RecPart part; 451 RecPart part;
454 452
455 if (mime->mm_mime_fields != NULL) {
456 mailmime_single_fields_init(&fields, mime->mm_mime_fields,
457 mime->mm_content_type);
458 }
459 switch (mime->mm_type) { 453 switch (mime->mm_type) {
460 case MAILMIME_SINGLE: 454 case MAILMIME_SINGLE:
461 r = mailmessage_fetch_section(message,mime,&data,&len); 455 r = mailmessage_fetch_section(message,mime,&data,&len);
456 part.setSize(len);
462 fillSingleBody(part,message,mime); 457 fillSingleBody(part,message,mime);
463 if (part.Type()=="text" && target.Bodytext().isNull()) { 458 if (part.Type()=="text" && target.Bodytext().isNull()) {
464 encodedString*r = new encodedString(); 459 encodedString*r = new encodedString();
465 r->setContent(data,len); 460 r->setContent(data,len);
466 encodedString*res = decode_String(r,part.Encoding()); 461 encodedString*res = decode_String(r,part.Encoding());
467 b = QString(res->Content()); 462 b = QString(res->Content());
@@ -520,14 +515,21 @@ QString POP3wrapper::getencoding(mailmime_mechanism*aEnc)
520 515
521void POP3wrapper::fillSingleBody(RecPart&target,mailmessage*,mailmime*mime) 516void POP3wrapper::fillSingleBody(RecPart&target,mailmessage*,mailmime*mime)
522{ 517{
523 if (!mime) { 518 if (!mime) {
524 return; 519 return;
525 } 520 }
526 mailmime_content*type = mime->mm_content_type;
527 mailmime_field*field = 0; 521 mailmime_field*field = 0;
522 mailmime_single_fields fields;
523 memset(&fields, 0, sizeof(struct mailmime_single_fields));
524 if (mime->mm_mime_fields != NULL) {
525 mailmime_single_fields_init(&fields, mime->mm_mime_fields,
526 mime->mm_content_type);
527 }
528
529 mailmime_content*type = fields.fld_content;
528 clistcell*current; 530 clistcell*current;
529 if (!type) { 531 if (!type) {
530 target.setType("text"); 532 target.setType("text");
531 target.setSubtype("plain"); 533 target.setSubtype("plain");
532 } else { 534 } else {
533 target.setSubtype(type->ct_subtype); 535 target.setSubtype(type->ct_subtype);
@@ -551,12 +553,15 @@ void POP3wrapper::fillSingleBody(RecPart&target,mailmessage*,mailmime*mime)
551 default: 553 default:
552 if (type->ct_type->tp_data.tp_discrete_type->dt_extension) { 554 if (type->ct_type->tp_data.tp_discrete_type->dt_extension) {
553 target.setType(type->ct_type->tp_data.tp_discrete_type->dt_extension); 555 target.setType(type->ct_type->tp_data.tp_discrete_type->dt_extension);
554 } 556 }
555 break; 557 break;
556 } 558 }
559 if (type->ct_parameters) {
560 fillParameters(target,type->ct_parameters);
561 }
557 } 562 }
558 if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) { 563 if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) {
559 for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) { 564 for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) {
560 field = (mailmime_field*)current->data; 565 field = (mailmime_field*)current->data;
561 switch(field->fld_type) { 566 switch(field->fld_type) {
562 case MAILMIME_FIELD_TRANSFER_ENCODING: 567 case MAILMIME_FIELD_TRANSFER_ENCODING:
@@ -570,8 +575,20 @@ void POP3wrapper::fillSingleBody(RecPart&target,mailmessage*,mailmime*mime)
570 break; 575 break;
571 default: 576 default:
572 break; 577 break;
573 } 578 }
574 } 579 }
575 } 580 }
576 // TODO search the parameter list for unique id and so on 581}
582
583void POP3wrapper::fillParameters(RecPart&target,clist*parameters)
584{
585 if (!parameters) {return;}
586 clistcell*current=0;
587 mailmime_parameter*param;
588 for (current=clist_begin(parameters);current!=0;current=clist_next(current)) {
589 param = (mailmime_parameter*)current->data;
590 if (param) {
591 target.addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
592 }
593 }
577} 594}