-rw-r--r-- | noncore/net/mail/imapwrapper.cpp | 143 | ||||
-rw-r--r-- | noncore/net/mail/imapwrapper.h | 6 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 143 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.h | 6 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailtypes.cpp | 62 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailtypes.h | 25 | ||||
-rw-r--r-- | noncore/net/mail/mailtypes.cpp | 62 | ||||
-rw-r--r-- | noncore/net/mail/mailtypes.h | 25 |
8 files changed, 282 insertions, 190 deletions
diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp index fa967da..da5974c 100644 --- a/noncore/net/mail/imapwrapper.cpp +++ b/noncore/net/mail/imapwrapper.cpp | |||
@@ -370,85 +370,39 @@ RecBody IMAPwrapper::fetchBody(const RecMail&mail) | |||
370 | routines 'cause we can not simply fetch the whole body. */ | 370 | routines 'cause we can not simply fetch the whole body. */ |
371 | void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body) | 371 | void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body) |
372 | { | 372 | { |
373 | if (!mailDescription) { | 373 | if (!mailDescription) { |
374 | return; | 374 | return; |
375 | } | 375 | } |
376 | QString sub; | 376 | QString sub,body_text; |
377 | RecPart singlePart; | ||
378 | QValueList<int> path; | ||
379 | fillSinglePart(singlePart,mailDescription); | ||
377 | switch (mailDescription->bd_type) { | 380 | switch (mailDescription->bd_type) { |
378 | case MAILIMAP_BODY_TYPE_1PART_MSG: | 381 | case MAILIMAP_BODY_TYPE_1PART_MSG: |
379 | target_body.setType("text"); | 382 | path.append(1); |
380 | sub = mailDescription->bd_data.bd_type_text->bd_media_text; | 383 | body_text = fetchPart(mail,path,true); |
381 | target_body.setSubtype(sub.lower()); | 384 | target_body.setBodytext(body_text); |
382 | fillPlainBody(mail,target_body); | 385 | target_body.setDescription(singlePart); |
383 | break; | 386 | break; |
384 | case MAILIMAP_BODY_TYPE_1PART_TEXT: | 387 | case MAILIMAP_BODY_TYPE_1PART_TEXT: |
385 | qDebug("Mediatype single: %s",mailDescription->bd_data.bd_type_text->bd_media_text); | 388 | qDebug("Mediatype single: %s",mailDescription->bd_data.bd_type_text->bd_media_text); |
386 | target_body.setType("text"); | 389 | path.append(1); |
387 | sub = mailDescription->bd_data.bd_type_text->bd_media_text; | 390 | body_text = fetchPart(mail,path,true); |
388 | target_body.setSubtype(sub.lower()); | 391 | target_body.setBodytext(body_text); |
389 | fillPlainBody(mail,target_body); | 392 | target_body.setDescription(singlePart); |
393 | break; | ||
394 | case MAILIMAP_BODY_TYPE_1PART_BASIC: | ||
395 | qDebug("Single attachment"); | ||
396 | target_body.setBodytext(""); | ||
397 | target_body.addPart(singlePart); | ||
390 | break; | 398 | break; |
391 | default: | 399 | default: |
392 | break; | 400 | break; |
393 | } | 401 | } |
394 | return; | ||
395 | } | ||
396 | |||
397 | void IMAPwrapper::fillPlainBody(const RecMail&mail,RecBody&target_body) | ||
398 | { | ||
399 | const char *mb; | ||
400 | QString body=""; | ||
401 | int err = MAILIMAP_NO_ERROR; | ||
402 | clist *result; | ||
403 | clistcell *current,*cur; | ||
404 | mailimap_fetch_att *fetchAtt; | ||
405 | mailimap_fetch_type *fetchType; | ||
406 | mailimap_set *set; | ||
407 | |||
408 | mb = mail.getMbox().latin1(); | ||
409 | |||
410 | if (!m_imap) { | ||
411 | return; | ||
412 | } | ||
413 | |||
414 | result = clist_new(); | ||
415 | set = set = mailimap_set_new_single(mail.getNumber()); | ||
416 | mailimap_section * section = mailimap_section_new_text(); | ||
417 | fetchAtt = mailimap_fetch_att_new_body_peek_section(section); | ||
418 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); | ||
419 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | ||
420 | mailimap_set_free( set ); | ||
421 | mailimap_fetch_type_free( fetchType ); | ||
422 | |||
423 | 402 | ||
424 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | ||
425 | mailimap_msg_att * msg_att; | ||
426 | msg_att = (mailimap_msg_att*)current->data; | ||
427 | mailimap_msg_att_item*msg_att_item; | ||
428 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { | ||
429 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); | ||
430 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { | ||
431 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { | ||
432 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; | ||
433 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; | ||
434 | if (text) { | ||
435 | body = QString(text); | ||
436 | free(text); | ||
437 | } else { | ||
438 | body = ""; | ||
439 | } | ||
440 | } | ||
441 | } | ||
442 | } | ||
443 | |||
444 | } else { | ||
445 | qDebug("error fetching text: %s",m_imap->imap_response); | ||
446 | } | ||
447 | mailimap_fetch_list_free(result); | ||
448 | target_body.setBodytext(body); | ||
449 | return; | 403 | return; |
450 | } | 404 | } |
451 | 405 | ||
452 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | 406 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) |
453 | { | 407 | { |
454 | QStringList l; | 408 | QStringList l; |
@@ -487,13 +441,13 @@ QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | |||
487 | break; | 441 | break; |
488 | } | 442 | } |
489 | } | 443 | } |
490 | return l; | 444 | return l; |
491 | } | 445 | } |
492 | 446 | ||
493 | QString IMAPwrapper::fetchPart(const RecMail&mail,QValueList<int>&path,bool internal_call) | 447 | QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call) |
494 | { | 448 | { |
495 | QString body(""); | 449 | QString body(""); |
496 | const char*mb; | 450 | const char*mb; |
497 | int err; | 451 | int err; |
498 | mailimap_fetch_type *fetchType; | 452 | mailimap_fetch_type *fetchType; |
499 | mailimap_set *set; | 453 | mailimap_set *set; |
@@ -581,23 +535,23 @@ void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mai | |||
581 | fillSinglePart(currentPart,current_body->bd_data.bd_body_1part); | 535 | fillSinglePart(currentPart,current_body->bd_data.bd_body_1part); |
582 | QValueList<int>clist = recList; | 536 | QValueList<int>clist = recList; |
583 | clist.append(count); | 537 | clist.append(count); |
584 | /* important: Check for is NULL 'cause a body can be empty! */ | 538 | /* important: Check for is NULL 'cause a body can be empty! */ |
585 | if (currentPart.Type()=="text" && target_body.Bodytext().isNull() ) { | 539 | if (currentPart.Type()=="text" && target_body.Bodytext().isNull() ) { |
586 | QString body_text = fetchPart(mail,clist,true); | 540 | QString body_text = fetchPart(mail,clist,true); |
541 | target_body.setDescription(currentPart); | ||
587 | target_body.setBodytext(body_text); | 542 | target_body.setBodytext(body_text); |
588 | target_body.setType(currentPart.Type()); | ||
589 | target_body.setSubtype(currentPart.Subtype()); | ||
590 | } else { | 543 | } else { |
591 | QString id(""); | 544 | QString id(""); |
592 | for (unsigned int j = 0; j < clist.count();++j) { | 545 | for (unsigned int j = 0; j < clist.count();++j) { |
593 | id+=(j>0?".":""); | 546 | id+=(j>0?" ":""); |
594 | id+=QString("%1").arg(clist[j]); | 547 | id+=QString("%1").arg(clist[j]); |
595 | } | 548 | } |
596 | qDebug("ID= %s",id.latin1()); | 549 | qDebug("ID= %s",id.latin1()); |
597 | currentPart.setIdentifier(id); | 550 | currentPart.setIdentifier(id); |
551 | currentPart.setPositionlist(clist); | ||
598 | target_body.addPart(currentPart); | 552 | target_body.addPart(currentPart); |
599 | } | 553 | } |
600 | } | 554 | } |
601 | } | 555 | } |
602 | } | 556 | } |
603 | 557 | ||
@@ -611,12 +565,15 @@ void IMAPwrapper::fillSinglePart(RecPart&target_part,mailimap_body_type_1part*De | |||
611 | target_part.setType("text"); | 565 | target_part.setType("text"); |
612 | fillSingleTextPart(target_part,Description->bd_data.bd_type_text); | 566 | fillSingleTextPart(target_part,Description->bd_data.bd_type_text); |
613 | break; | 567 | break; |
614 | case MAILIMAP_BODY_TYPE_1PART_BASIC: | 568 | case MAILIMAP_BODY_TYPE_1PART_BASIC: |
615 | fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); | 569 | fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); |
616 | break; | 570 | break; |
571 | case MAILIMAP_BODY_TYPE_1PART_MSG: | ||
572 | fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg); | ||
573 | break; | ||
617 | default: | 574 | default: |
618 | break; | 575 | break; |
619 | } | 576 | } |
620 | } | 577 | } |
621 | 578 | ||
622 | void IMAPwrapper::fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which) | 579 | void IMAPwrapper::fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which) |
@@ -628,12 +585,28 @@ void IMAPwrapper::fillSingleTextPart(RecPart&target_part,mailimap_body_type_text | |||
628 | sub = which->bd_media_text; | 585 | sub = which->bd_media_text; |
629 | target_part.setSubtype(sub.lower()); | 586 | target_part.setSubtype(sub.lower()); |
630 | target_part.setLines(which->bd_lines); | 587 | target_part.setLines(which->bd_lines); |
631 | fillBodyFields(target_part,which->bd_fields); | 588 | fillBodyFields(target_part,which->bd_fields); |
632 | } | 589 | } |
633 | 590 | ||
591 | void IMAPwrapper::fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which) | ||
592 | { | ||
593 | if (!which) { | ||
594 | return; | ||
595 | } | ||
596 | // QString sub; | ||
597 | // sub = which->bd_media_text; | ||
598 | // target_part.setSubtype(sub.lower()); | ||
599 | qDebug("Message part"); | ||
600 | /* we set this type to text/plain */ | ||
601 | target_part.setType("text"); | ||
602 | target_part.setSubtype("plain"); | ||
603 | target_part.setLines(which->bd_lines); | ||
604 | fillBodyFields(target_part,which->bd_fields); | ||
605 | } | ||
606 | |||
634 | void IMAPwrapper::fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which) | 607 | void IMAPwrapper::fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which) |
635 | { | 608 | { |
636 | if (!which) { | 609 | if (!which) { |
637 | return; | 610 | return; |
638 | } | 611 | } |
639 | QString type,sub; | 612 | QString type,sub; |
@@ -677,8 +650,44 @@ void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which) | |||
677 | { | 650 | { |
678 | if (!which) return; | 651 | if (!which) return; |
679 | clistcell*cur; | 652 | clistcell*cur; |
680 | mailimap_single_body_fld_param*param; | 653 | mailimap_single_body_fld_param*param; |
681 | for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { | 654 | for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { |
682 | param = (mailimap_single_body_fld_param*)cur->data; | 655 | param = (mailimap_single_body_fld_param*)cur->data; |
656 | if (param) { | ||
657 | target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); | ||
658 | } | ||
683 | } | 659 | } |
660 | mailimap_body_fld_enc*enc = which->bd_encoding; | ||
661 | QString encoding(""); | ||
662 | switch (enc->enc_type) { | ||
663 | case MAILIMAP_BODY_FLD_ENC_7BIT: | ||
664 | encoding = "7bit"; | ||
665 | break; | ||
666 | case MAILIMAP_BODY_FLD_ENC_8BIT: | ||
667 | encoding = "8bit"; | ||
668 | break; | ||
669 | case MAILIMAP_BODY_FLD_ENC_BINARY: | ||
670 | encoding="binary"; | ||
671 | break; | ||
672 | case MAILIMAP_BODY_FLD_ENC_BASE64: | ||
673 | encoding="base64"; | ||
674 | break; | ||
675 | case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: | ||
676 | encoding="quoted-printable"; | ||
677 | break; | ||
678 | case MAILIMAP_BODY_FLD_ENC_OTHER: | ||
679 | default: | ||
680 | if (enc->enc_value) { | ||
681 | char*t=enc->enc_value; | ||
682 | encoding=QString(enc->enc_value); | ||
683 | enc->enc_value=0L; | ||
684 | free(t); | ||
685 | } | ||
686 | } | ||
687 | target_part.setEncoding(encoding); | ||
688 | } | ||
689 | |||
690 | QString IMAPwrapper::fetchPart(const RecMail&mail,const RecPart&part) | ||
691 | { | ||
692 | return fetchPart(mail,part.Positionlist(),false); | ||
684 | } | 693 | } |
diff --git a/noncore/net/mail/imapwrapper.h b/noncore/net/mail/imapwrapper.h index 5ea45f3..95de215 100644 --- a/noncore/net/mail/imapwrapper.h +++ b/noncore/net/mail/imapwrapper.h | |||
@@ -5,12 +5,13 @@ | |||
5 | #include "mailwrapper.h" | 5 | #include "mailwrapper.h" |
6 | 6 | ||
7 | struct mailimap; | 7 | struct mailimap; |
8 | struct mailimap_body_type_1part; | 8 | struct mailimap_body_type_1part; |
9 | struct mailimap_body_type_text; | 9 | struct mailimap_body_type_text; |
10 | struct mailimap_body_type_basic; | 10 | struct mailimap_body_type_basic; |
11 | struct mailimap_body_type_msg; | ||
11 | struct mailimap_body_type_mpart; | 12 | struct mailimap_body_type_mpart; |
12 | struct mailimap_body_fields; | 13 | struct mailimap_body_fields; |
13 | struct mailimap_msg_att; | 14 | struct mailimap_msg_att; |
14 | class RecMail; | 15 | class RecMail; |
15 | class RecBody; | 16 | class RecBody; |
16 | class RecPart; | 17 | class RecPart; |
@@ -22,27 +23,28 @@ class IMAPwrapper : public QObject | |||
22 | public: | 23 | public: |
23 | IMAPwrapper( IMAPaccount *a ); | 24 | IMAPwrapper( IMAPaccount *a ); |
24 | virtual ~IMAPwrapper(); | 25 | virtual ~IMAPwrapper(); |
25 | QList<IMAPFolder>* listFolders(); | 26 | QList<IMAPFolder>* listFolders(); |
26 | void listMessages(const QString & mailbox,QList<RecMail>&target ); | 27 | void listMessages(const QString & mailbox,QList<RecMail>&target ); |
27 | RecBody fetchBody(const RecMail&mail); | 28 | RecBody fetchBody(const RecMail&mail); |
28 | QString fetchPart(const RecMail&mail,QValueList<int>&path,bool internal_call=false); | 29 | QString fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false); |
30 | QString fetchPart(const RecMail&mail,const RecPart&part); | ||
29 | static void imap_progress( size_t current, size_t maximum ); | 31 | static void imap_progress( size_t current, size_t maximum ); |
30 | 32 | ||
31 | protected: | 33 | protected: |
32 | RecMail*parse_list_result(mailimap_msg_att*); | 34 | RecMail*parse_list_result(mailimap_msg_att*); |
33 | void login(); | 35 | void login(); |
34 | void logout(); | 36 | void logout(); |
35 | 37 | ||
36 | void searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body); | 38 | void searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body); |
37 | void searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion=0,QValueList<int>recList=QValueList<int>()); | 39 | void searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion=0,QValueList<int>recList=QValueList<int>()); |
38 | 40 | ||
39 | void fillPlainBody(const RecMail&mail,RecBody&target_body); | ||
40 | void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); | 41 | void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); |
41 | void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); | 42 | void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); |
42 | void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); | 43 | void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); |
44 | void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which); | ||
43 | 45 | ||
44 | /* just helpers */ | 46 | /* just helpers */ |
45 | static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which); | 47 | static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which); |
46 | static QStringList address_list_to_stringlist(clist*list); | 48 | static QStringList address_list_to_stringlist(clist*list); |
47 | 49 | ||
48 | private: | 50 | private: |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index fa967da..da5974c 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp | |||
@@ -370,85 +370,39 @@ RecBody IMAPwrapper::fetchBody(const RecMail&mail) | |||
370 | routines 'cause we can not simply fetch the whole body. */ | 370 | routines 'cause we can not simply fetch the whole body. */ |
371 | void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body) | 371 | void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body) |
372 | { | 372 | { |
373 | if (!mailDescription) { | 373 | if (!mailDescription) { |
374 | return; | 374 | return; |
375 | } | 375 | } |
376 | QString sub; | 376 | QString sub,body_text; |
377 | RecPart singlePart; | ||
378 | QValueList<int> path; | ||
379 | fillSinglePart(singlePart,mailDescription); | ||
377 | switch (mailDescription->bd_type) { | 380 | switch (mailDescription->bd_type) { |
378 | case MAILIMAP_BODY_TYPE_1PART_MSG: | 381 | case MAILIMAP_BODY_TYPE_1PART_MSG: |
379 | target_body.setType("text"); | 382 | path.append(1); |
380 | sub = mailDescription->bd_data.bd_type_text->bd_media_text; | 383 | body_text = fetchPart(mail,path,true); |
381 | target_body.setSubtype(sub.lower()); | 384 | target_body.setBodytext(body_text); |
382 | fillPlainBody(mail,target_body); | 385 | target_body.setDescription(singlePart); |
383 | break; | 386 | break; |
384 | case MAILIMAP_BODY_TYPE_1PART_TEXT: | 387 | case MAILIMAP_BODY_TYPE_1PART_TEXT: |
385 | qDebug("Mediatype single: %s",mailDescription->bd_data.bd_type_text->bd_media_text); | 388 | qDebug("Mediatype single: %s",mailDescription->bd_data.bd_type_text->bd_media_text); |
386 | target_body.setType("text"); | 389 | path.append(1); |
387 | sub = mailDescription->bd_data.bd_type_text->bd_media_text; | 390 | body_text = fetchPart(mail,path,true); |
388 | target_body.setSubtype(sub.lower()); | 391 | target_body.setBodytext(body_text); |
389 | fillPlainBody(mail,target_body); | 392 | target_body.setDescription(singlePart); |
393 | break; | ||
394 | case MAILIMAP_BODY_TYPE_1PART_BASIC: | ||
395 | qDebug("Single attachment"); | ||
396 | target_body.setBodytext(""); | ||
397 | target_body.addPart(singlePart); | ||
390 | break; | 398 | break; |
391 | default: | 399 | default: |
392 | break; | 400 | break; |
393 | } | 401 | } |
394 | return; | ||
395 | } | ||
396 | |||
397 | void IMAPwrapper::fillPlainBody(const RecMail&mail,RecBody&target_body) | ||
398 | { | ||
399 | const char *mb; | ||
400 | QString body=""; | ||
401 | int err = MAILIMAP_NO_ERROR; | ||
402 | clist *result; | ||
403 | clistcell *current,*cur; | ||
404 | mailimap_fetch_att *fetchAtt; | ||
405 | mailimap_fetch_type *fetchType; | ||
406 | mailimap_set *set; | ||
407 | |||
408 | mb = mail.getMbox().latin1(); | ||
409 | |||
410 | if (!m_imap) { | ||
411 | return; | ||
412 | } | ||
413 | |||
414 | result = clist_new(); | ||
415 | set = set = mailimap_set_new_single(mail.getNumber()); | ||
416 | mailimap_section * section = mailimap_section_new_text(); | ||
417 | fetchAtt = mailimap_fetch_att_new_body_peek_section(section); | ||
418 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); | ||
419 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | ||
420 | mailimap_set_free( set ); | ||
421 | mailimap_fetch_type_free( fetchType ); | ||
422 | |||
423 | 402 | ||
424 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | ||
425 | mailimap_msg_att * msg_att; | ||
426 | msg_att = (mailimap_msg_att*)current->data; | ||
427 | mailimap_msg_att_item*msg_att_item; | ||
428 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { | ||
429 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); | ||
430 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { | ||
431 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { | ||
432 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; | ||
433 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; | ||
434 | if (text) { | ||
435 | body = QString(text); | ||
436 | free(text); | ||
437 | } else { | ||
438 | body = ""; | ||
439 | } | ||
440 | } | ||
441 | } | ||
442 | } | ||
443 | |||
444 | } else { | ||
445 | qDebug("error fetching text: %s",m_imap->imap_response); | ||
446 | } | ||
447 | mailimap_fetch_list_free(result); | ||
448 | target_body.setBodytext(body); | ||
449 | return; | 403 | return; |
450 | } | 404 | } |
451 | 405 | ||
452 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | 406 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) |
453 | { | 407 | { |
454 | QStringList l; | 408 | QStringList l; |
@@ -487,13 +441,13 @@ QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | |||
487 | break; | 441 | break; |
488 | } | 442 | } |
489 | } | 443 | } |
490 | return l; | 444 | return l; |
491 | } | 445 | } |
492 | 446 | ||
493 | QString IMAPwrapper::fetchPart(const RecMail&mail,QValueList<int>&path,bool internal_call) | 447 | QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call) |
494 | { | 448 | { |
495 | QString body(""); | 449 | QString body(""); |
496 | const char*mb; | 450 | const char*mb; |
497 | int err; | 451 | int err; |
498 | mailimap_fetch_type *fetchType; | 452 | mailimap_fetch_type *fetchType; |
499 | mailimap_set *set; | 453 | mailimap_set *set; |
@@ -581,23 +535,23 @@ void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mai | |||
581 | fillSinglePart(currentPart,current_body->bd_data.bd_body_1part); | 535 | fillSinglePart(currentPart,current_body->bd_data.bd_body_1part); |
582 | QValueList<int>clist = recList; | 536 | QValueList<int>clist = recList; |
583 | clist.append(count); | 537 | clist.append(count); |
584 | /* important: Check for is NULL 'cause a body can be empty! */ | 538 | /* important: Check for is NULL 'cause a body can be empty! */ |
585 | if (currentPart.Type()=="text" && target_body.Bodytext().isNull() ) { | 539 | if (currentPart.Type()=="text" && target_body.Bodytext().isNull() ) { |
586 | QString body_text = fetchPart(mail,clist,true); | 540 | QString body_text = fetchPart(mail,clist,true); |
541 | target_body.setDescription(currentPart); | ||
587 | target_body.setBodytext(body_text); | 542 | target_body.setBodytext(body_text); |
588 | target_body.setType(currentPart.Type()); | ||
589 | target_body.setSubtype(currentPart.Subtype()); | ||
590 | } else { | 543 | } else { |
591 | QString id(""); | 544 | QString id(""); |
592 | for (unsigned int j = 0; j < clist.count();++j) { | 545 | for (unsigned int j = 0; j < clist.count();++j) { |
593 | id+=(j>0?".":""); | 546 | id+=(j>0?" ":""); |
594 | id+=QString("%1").arg(clist[j]); | 547 | id+=QString("%1").arg(clist[j]); |
595 | } | 548 | } |
596 | qDebug("ID= %s",id.latin1()); | 549 | qDebug("ID= %s",id.latin1()); |
597 | currentPart.setIdentifier(id); | 550 | currentPart.setIdentifier(id); |
551 | currentPart.setPositionlist(clist); | ||
598 | target_body.addPart(currentPart); | 552 | target_body.addPart(currentPart); |
599 | } | 553 | } |
600 | } | 554 | } |
601 | } | 555 | } |
602 | } | 556 | } |
603 | 557 | ||
@@ -611,12 +565,15 @@ void IMAPwrapper::fillSinglePart(RecPart&target_part,mailimap_body_type_1part*De | |||
611 | target_part.setType("text"); | 565 | target_part.setType("text"); |
612 | fillSingleTextPart(target_part,Description->bd_data.bd_type_text); | 566 | fillSingleTextPart(target_part,Description->bd_data.bd_type_text); |
613 | break; | 567 | break; |
614 | case MAILIMAP_BODY_TYPE_1PART_BASIC: | 568 | case MAILIMAP_BODY_TYPE_1PART_BASIC: |
615 | fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); | 569 | fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); |
616 | break; | 570 | break; |
571 | case MAILIMAP_BODY_TYPE_1PART_MSG: | ||
572 | fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg); | ||
573 | break; | ||
617 | default: | 574 | default: |
618 | break; | 575 | break; |
619 | } | 576 | } |
620 | } | 577 | } |
621 | 578 | ||
622 | void IMAPwrapper::fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which) | 579 | void IMAPwrapper::fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which) |
@@ -628,12 +585,28 @@ void IMAPwrapper::fillSingleTextPart(RecPart&target_part,mailimap_body_type_text | |||
628 | sub = which->bd_media_text; | 585 | sub = which->bd_media_text; |
629 | target_part.setSubtype(sub.lower()); | 586 | target_part.setSubtype(sub.lower()); |
630 | target_part.setLines(which->bd_lines); | 587 | target_part.setLines(which->bd_lines); |
631 | fillBodyFields(target_part,which->bd_fields); | 588 | fillBodyFields(target_part,which->bd_fields); |
632 | } | 589 | } |
633 | 590 | ||
591 | void IMAPwrapper::fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which) | ||
592 | { | ||
593 | if (!which) { | ||
594 | return; | ||
595 | } | ||
596 | // QString sub; | ||
597 | // sub = which->bd_media_text; | ||
598 | // target_part.setSubtype(sub.lower()); | ||
599 | qDebug("Message part"); | ||
600 | /* we set this type to text/plain */ | ||
601 | target_part.setType("text"); | ||
602 | target_part.setSubtype("plain"); | ||
603 | target_part.setLines(which->bd_lines); | ||
604 | fillBodyFields(target_part,which->bd_fields); | ||
605 | } | ||
606 | |||
634 | void IMAPwrapper::fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which) | 607 | void IMAPwrapper::fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which) |
635 | { | 608 | { |
636 | if (!which) { | 609 | if (!which) { |
637 | return; | 610 | return; |
638 | } | 611 | } |
639 | QString type,sub; | 612 | QString type,sub; |
@@ -677,8 +650,44 @@ void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which) | |||
677 | { | 650 | { |
678 | if (!which) return; | 651 | if (!which) return; |
679 | clistcell*cur; | 652 | clistcell*cur; |
680 | mailimap_single_body_fld_param*param; | 653 | mailimap_single_body_fld_param*param; |
681 | for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { | 654 | for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { |
682 | param = (mailimap_single_body_fld_param*)cur->data; | 655 | param = (mailimap_single_body_fld_param*)cur->data; |
656 | if (param) { | ||
657 | target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); | ||
658 | } | ||
683 | } | 659 | } |
660 | mailimap_body_fld_enc*enc = which->bd_encoding; | ||
661 | QString encoding(""); | ||
662 | switch (enc->enc_type) { | ||
663 | case MAILIMAP_BODY_FLD_ENC_7BIT: | ||
664 | encoding = "7bit"; | ||
665 | break; | ||
666 | case MAILIMAP_BODY_FLD_ENC_8BIT: | ||
667 | encoding = "8bit"; | ||
668 | break; | ||
669 | case MAILIMAP_BODY_FLD_ENC_BINARY: | ||
670 | encoding="binary"; | ||
671 | break; | ||
672 | case MAILIMAP_BODY_FLD_ENC_BASE64: | ||
673 | encoding="base64"; | ||
674 | break; | ||
675 | case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: | ||
676 | encoding="quoted-printable"; | ||
677 | break; | ||
678 | case MAILIMAP_BODY_FLD_ENC_OTHER: | ||
679 | default: | ||
680 | if (enc->enc_value) { | ||
681 | char*t=enc->enc_value; | ||
682 | encoding=QString(enc->enc_value); | ||
683 | enc->enc_value=0L; | ||
684 | free(t); | ||
685 | } | ||
686 | } | ||
687 | target_part.setEncoding(encoding); | ||
688 | } | ||
689 | |||
690 | QString IMAPwrapper::fetchPart(const RecMail&mail,const RecPart&part) | ||
691 | { | ||
692 | return fetchPart(mail,part.Positionlist(),false); | ||
684 | } | 693 | } |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h index 5ea45f3..95de215 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.h +++ b/noncore/net/mail/libmailwrapper/imapwrapper.h | |||
@@ -5,12 +5,13 @@ | |||
5 | #include "mailwrapper.h" | 5 | #include "mailwrapper.h" |
6 | 6 | ||
7 | struct mailimap; | 7 | struct mailimap; |
8 | struct mailimap_body_type_1part; | 8 | struct mailimap_body_type_1part; |
9 | struct mailimap_body_type_text; | 9 | struct mailimap_body_type_text; |
10 | struct mailimap_body_type_basic; | 10 | struct mailimap_body_type_basic; |
11 | struct mailimap_body_type_msg; | ||
11 | struct mailimap_body_type_mpart; | 12 | struct mailimap_body_type_mpart; |
12 | struct mailimap_body_fields; | 13 | struct mailimap_body_fields; |
13 | struct mailimap_msg_att; | 14 | struct mailimap_msg_att; |
14 | class RecMail; | 15 | class RecMail; |
15 | class RecBody; | 16 | class RecBody; |
16 | class RecPart; | 17 | class RecPart; |
@@ -22,27 +23,28 @@ class IMAPwrapper : public QObject | |||
22 | public: | 23 | public: |
23 | IMAPwrapper( IMAPaccount *a ); | 24 | IMAPwrapper( IMAPaccount *a ); |
24 | virtual ~IMAPwrapper(); | 25 | virtual ~IMAPwrapper(); |
25 | QList<IMAPFolder>* listFolders(); | 26 | QList<IMAPFolder>* listFolders(); |
26 | void listMessages(const QString & mailbox,QList<RecMail>&target ); | 27 | void listMessages(const QString & mailbox,QList<RecMail>&target ); |
27 | RecBody fetchBody(const RecMail&mail); | 28 | RecBody fetchBody(const RecMail&mail); |
28 | QString fetchPart(const RecMail&mail,QValueList<int>&path,bool internal_call=false); | 29 | QString fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false); |
30 | QString fetchPart(const RecMail&mail,const RecPart&part); | ||
29 | static void imap_progress( size_t current, size_t maximum ); | 31 | static void imap_progress( size_t current, size_t maximum ); |
30 | 32 | ||
31 | protected: | 33 | protected: |
32 | RecMail*parse_list_result(mailimap_msg_att*); | 34 | RecMail*parse_list_result(mailimap_msg_att*); |
33 | void login(); | 35 | void login(); |
34 | void logout(); | 36 | void logout(); |
35 | 37 | ||
36 | void searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body); | 38 | void searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body); |
37 | void searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion=0,QValueList<int>recList=QValueList<int>()); | 39 | void searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion=0,QValueList<int>recList=QValueList<int>()); |
38 | 40 | ||
39 | void fillPlainBody(const RecMail&mail,RecBody&target_body); | ||
40 | void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); | 41 | void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); |
41 | void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); | 42 | void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); |
42 | void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); | 43 | void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); |
44 | void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which); | ||
43 | 45 | ||
44 | /* just helpers */ | 46 | /* just helpers */ |
45 | static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which); | 47 | static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which); |
46 | static QStringList address_list_to_stringlist(clist*list); | 48 | static QStringList address_list_to_stringlist(clist*list); |
47 | 49 | ||
48 | private: | 50 | private: |
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.cpp b/noncore/net/mail/libmailwrapper/mailtypes.cpp index 6a66113..f56bb63 100644 --- a/noncore/net/mail/libmailwrapper/mailtypes.cpp +++ b/noncore/net/mail/libmailwrapper/mailtypes.cpp | |||
@@ -67,17 +67,14 @@ const QStringList& RecMail::Bcc()const | |||
67 | return bcc; | 67 | return bcc; |
68 | } | 68 | } |
69 | 69 | ||
70 | RecPart::RecPart() | 70 | RecPart::RecPart() |
71 | : m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_lines(0) | 71 | : m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_lines(0) |
72 | { | 72 | { |
73 | } | 73 | m_Parameters.clear(); |
74 | 74 | m_poslist.clear(); | |
75 | RecPart::RecPart(const QString&identifier,const QString&type,const QString&subtype,const QString&encoding,unsigned int lines) | ||
76 | : m_type(type),m_subtype(subtype),m_identifier(identifier),m_encoding(encoding),m_lines(lines) | ||
77 | { | ||
78 | } | 75 | } |
79 | 76 | ||
80 | RecPart::~RecPart() | 77 | RecPart::~RecPart() |
81 | { | 78 | { |
82 | } | 79 | } |
83 | 80 | ||
@@ -128,14 +125,49 @@ const QString& RecPart::Encoding()const | |||
128 | 125 | ||
129 | void RecPart::setEncoding(const QString&encoding) | 126 | void RecPart::setEncoding(const QString&encoding) |
130 | { | 127 | { |
131 | m_encoding = encoding; | 128 | m_encoding = encoding; |
132 | } | 129 | } |
133 | 130 | ||
131 | void RecPart::setParameters(const part_plist_t&list) | ||
132 | { | ||
133 | m_Parameters = list; | ||
134 | } | ||
135 | |||
136 | const part_plist_t& RecPart::Parameters()const | ||
137 | { | ||
138 | return m_Parameters; | ||
139 | } | ||
140 | |||
141 | void RecPart::addParameter(const QString&key,const QString&value) | ||
142 | { | ||
143 | m_Parameters[key]=value; | ||
144 | } | ||
145 | |||
146 | const QString RecPart::searchParamter(const QString&key)const | ||
147 | { | ||
148 | QString value(""); | ||
149 | part_plist_t::ConstIterator it = m_Parameters.find(key); | ||
150 | if (it != m_Parameters.end()) { | ||
151 | value = it.data(); | ||
152 | } | ||
153 | return value; | ||
154 | } | ||
155 | |||
156 | void RecPart::setPositionlist(const QValueList<int>&poslist) | ||
157 | { | ||
158 | m_poslist = poslist; | ||
159 | } | ||
160 | |||
161 | const QValueList<int>& RecPart::Positionlist()const | ||
162 | { | ||
163 | return m_poslist; | ||
164 | } | ||
165 | |||
134 | RecBody::RecBody() | 166 | RecBody::RecBody() |
135 | : m_BodyText(),m_PartsList() | 167 | : m_BodyText(),m_PartsList(),m_description() |
136 | { | 168 | { |
137 | m_PartsList.setAutoDelete(true); | 169 | m_PartsList.setAutoDelete(true); |
138 | } | 170 | } |
139 | 171 | ||
140 | RecBody::~RecBody() | 172 | RecBody::~RecBody() |
141 | { | 173 | { |
@@ -165,25 +197,15 @@ const QList<RecPart>& RecBody::Parts()const | |||
165 | void RecBody::addPart(const RecPart& part) | 197 | void RecBody::addPart(const RecPart& part) |
166 | { | 198 | { |
167 | RecPart*p = new RecPart(part); | 199 | RecPart*p = new RecPart(part); |
168 | m_PartsList.append(p); | 200 | m_PartsList.append(p); |
169 | } | 201 | } |
170 | 202 | ||
171 | void RecBody::setType(const QString&type) | 203 | void RecBody::setDescription(const RecPart&des) |
172 | { | 204 | { |
173 | m_type = type; | 205 | m_description = des; |
174 | } | 206 | } |
175 | 207 | ||
176 | const QString& RecBody::Type()const | 208 | const RecPart& RecBody::Description()const |
177 | { | 209 | { |
178 | return m_type; | 210 | return m_description; |
179 | } | ||
180 | |||
181 | void RecBody::setSubtype(const QString&type) | ||
182 | { | ||
183 | m_subtype = type; | ||
184 | } | ||
185 | |||
186 | const QString& RecBody::Subtype()const | ||
187 | { | ||
188 | return m_subtype; | ||
189 | } | 211 | } |
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.h b/noncore/net/mail/libmailwrapper/mailtypes.h index 900f10a..60db527 100644 --- a/noncore/net/mail/libmailwrapper/mailtypes.h +++ b/noncore/net/mail/libmailwrapper/mailtypes.h | |||
@@ -9,12 +9,14 @@ | |||
9 | #define FLAG_RECENT 5 | 9 | #define FLAG_RECENT 5 |
10 | 10 | ||
11 | #include <qlist.h> | 11 | #include <qlist.h> |
12 | #include <qbitarray.h> | 12 | #include <qbitarray.h> |
13 | #include <qstring.h> | 13 | #include <qstring.h> |
14 | #include <qstringlist.h> | 14 | #include <qstringlist.h> |
15 | #include <qmap.h> | ||
16 | #include <qvaluelist.h> | ||
15 | 17 | ||
16 | /* a class to describe mails in a mailbox */ | 18 | /* a class to describe mails in a mailbox */ |
17 | /* Attention! | 19 | /* Attention! |
18 | From programmers point of view it would make sense to | 20 | From programmers point of view it would make sense to |
19 | store the mail body into this class, too. | 21 | store the mail body into this class, too. |
20 | But: not from the point of view of the device. | 22 | But: not from the point of view of the device. |
@@ -65,50 +67,61 @@ protected: | |||
65 | QBitArray msg_flags; | 67 | QBitArray msg_flags; |
66 | QStringList to,cc,bcc; | 68 | QStringList to,cc,bcc; |
67 | void init(); | 69 | void init(); |
68 | void copy_old(const RecMail&old); | 70 | void copy_old(const RecMail&old); |
69 | }; | 71 | }; |
70 | 72 | ||
73 | typedef QMap<QString,QString> part_plist_t; | ||
74 | |||
71 | class RecPart | 75 | class RecPart |
72 | { | 76 | { |
73 | protected: | 77 | protected: |
74 | QString m_type,m_subtype,m_identifier,m_encoding; | 78 | QString m_type,m_subtype,m_identifier,m_encoding; |
75 | unsigned int m_lines; | 79 | unsigned int m_lines; |
80 | part_plist_t m_Parameters; | ||
81 | /* describes the position in the mail */ | ||
82 | QValueList<int> m_poslist; | ||
83 | |||
76 | public: | 84 | public: |
77 | RecPart(); | 85 | RecPart(); |
78 | RecPart(const QString&identifier,const QString&type="",const QString&subtype="",const QString&encoding="BASE64",unsigned int lines=0); | ||
79 | virtual ~RecPart(); | 86 | virtual ~RecPart(); |
80 | 87 | ||
81 | const QString&Type()const; | 88 | const QString&Type()const; |
82 | void setType(const QString&type); | 89 | void setType(const QString&type); |
83 | const QString&Subtype()const; | 90 | const QString&Subtype()const; |
84 | void setSubtype(const QString&subtype); | 91 | void setSubtype(const QString&subtype); |
85 | const QString&Identifier()const; | 92 | const QString&Identifier()const; |
86 | void setIdentifier(const QString&identifier); | 93 | void setIdentifier(const QString&identifier); |
87 | const QString&Encoding()const; | 94 | const QString&Encoding()const; |
88 | void setEncoding(const QString&encoding); | 95 | void setEncoding(const QString&encoding); |
89 | void setLines(unsigned int lines); | 96 | void setLines(unsigned int lines); |
90 | const unsigned int Lines()const; | 97 | const unsigned int Lines()const; |
98 | |||
99 | void setParameters(const part_plist_t&list); | ||
100 | const part_plist_t&Parameters()const; | ||
101 | void addParameter(const QString&key,const QString&value); | ||
102 | const QString searchParamter(const QString&key)const; | ||
103 | void setPositionlist(const QValueList<int>&poslist); | ||
104 | const QValueList<int>& Positionlist()const; | ||
91 | }; | 105 | }; |
92 | 106 | ||
93 | class RecBody | 107 | class RecBody |
94 | { | 108 | { |
95 | protected: | 109 | protected: |
96 | QString m_BodyText,m_type,m_subtype; | 110 | QString m_BodyText; |
97 | QList<RecPart> m_PartsList; | 111 | QList<RecPart> m_PartsList; |
112 | RecPart m_description; | ||
98 | 113 | ||
99 | public: | 114 | public: |
100 | RecBody(); | 115 | RecBody(); |
101 | virtual ~RecBody(); | 116 | virtual ~RecBody(); |
102 | void setBodytext(const QString&); | 117 | void setBodytext(const QString&); |
103 | const QString& Bodytext()const; | 118 | const QString& Bodytext()const; |
104 | void setType(const QString&); | ||
105 | const QString&Type()const; | ||
106 | void setSubtype(const QString&); | ||
107 | const QString&Subtype()const; | ||
108 | 119 | ||
120 | void setDescription(const RecPart&des); | ||
121 | const RecPart& Description()const; | ||
109 | 122 | ||
110 | void setParts(const QList<RecPart>&parts); | 123 | void setParts(const QList<RecPart>&parts); |
111 | const QList<RecPart>& Parts()const; | 124 | const QList<RecPart>& Parts()const; |
112 | void addPart(const RecPart&part); | 125 | void addPart(const RecPart&part); |
113 | }; | 126 | }; |
114 | 127 | ||
diff --git a/noncore/net/mail/mailtypes.cpp b/noncore/net/mail/mailtypes.cpp index 6a66113..f56bb63 100644 --- a/noncore/net/mail/mailtypes.cpp +++ b/noncore/net/mail/mailtypes.cpp | |||
@@ -67,17 +67,14 @@ const QStringList& RecMail::Bcc()const | |||
67 | return bcc; | 67 | return bcc; |
68 | } | 68 | } |
69 | 69 | ||
70 | RecPart::RecPart() | 70 | RecPart::RecPart() |
71 | : m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_lines(0) | 71 | : m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_lines(0) |
72 | { | 72 | { |
73 | } | 73 | m_Parameters.clear(); |
74 | 74 | m_poslist.clear(); | |
75 | RecPart::RecPart(const QString&identifier,const QString&type,const QString&subtype,const QString&encoding,unsigned int lines) | ||
76 | : m_type(type),m_subtype(subtype),m_identifier(identifier),m_encoding(encoding),m_lines(lines) | ||
77 | { | ||
78 | } | 75 | } |
79 | 76 | ||
80 | RecPart::~RecPart() | 77 | RecPart::~RecPart() |
81 | { | 78 | { |
82 | } | 79 | } |
83 | 80 | ||
@@ -128,14 +125,49 @@ const QString& RecPart::Encoding()const | |||
128 | 125 | ||
129 | void RecPart::setEncoding(const QString&encoding) | 126 | void RecPart::setEncoding(const QString&encoding) |
130 | { | 127 | { |
131 | m_encoding = encoding; | 128 | m_encoding = encoding; |
132 | } | 129 | } |
133 | 130 | ||
131 | void RecPart::setParameters(const part_plist_t&list) | ||
132 | { | ||
133 | m_Parameters = list; | ||
134 | } | ||
135 | |||
136 | const part_plist_t& RecPart::Parameters()const | ||
137 | { | ||
138 | return m_Parameters; | ||
139 | } | ||
140 | |||
141 | void RecPart::addParameter(const QString&key,const QString&value) | ||
142 | { | ||
143 | m_Parameters[key]=value; | ||
144 | } | ||
145 | |||
146 | const QString RecPart::searchParamter(const QString&key)const | ||
147 | { | ||
148 | QString value(""); | ||
149 | part_plist_t::ConstIterator it = m_Parameters.find(key); | ||
150 | if (it != m_Parameters.end()) { | ||
151 | value = it.data(); | ||
152 | } | ||
153 | return value; | ||
154 | } | ||
155 | |||
156 | void RecPart::setPositionlist(const QValueList<int>&poslist) | ||
157 | { | ||
158 | m_poslist = poslist; | ||
159 | } | ||
160 | |||
161 | const QValueList<int>& RecPart::Positionlist()const | ||
162 | { | ||
163 | return m_poslist; | ||
164 | } | ||
165 | |||
134 | RecBody::RecBody() | 166 | RecBody::RecBody() |
135 | : m_BodyText(),m_PartsList() | 167 | : m_BodyText(),m_PartsList(),m_description() |
136 | { | 168 | { |
137 | m_PartsList.setAutoDelete(true); | 169 | m_PartsList.setAutoDelete(true); |
138 | } | 170 | } |
139 | 171 | ||
140 | RecBody::~RecBody() | 172 | RecBody::~RecBody() |
141 | { | 173 | { |
@@ -165,25 +197,15 @@ const QList<RecPart>& RecBody::Parts()const | |||
165 | void RecBody::addPart(const RecPart& part) | 197 | void RecBody::addPart(const RecPart& part) |
166 | { | 198 | { |
167 | RecPart*p = new RecPart(part); | 199 | RecPart*p = new RecPart(part); |
168 | m_PartsList.append(p); | 200 | m_PartsList.append(p); |
169 | } | 201 | } |
170 | 202 | ||
171 | void RecBody::setType(const QString&type) | 203 | void RecBody::setDescription(const RecPart&des) |
172 | { | 204 | { |
173 | m_type = type; | 205 | m_description = des; |
174 | } | 206 | } |
175 | 207 | ||
176 | const QString& RecBody::Type()const | 208 | const RecPart& RecBody::Description()const |
177 | { | 209 | { |
178 | return m_type; | 210 | return m_description; |
179 | } | ||
180 | |||
181 | void RecBody::setSubtype(const QString&type) | ||
182 | { | ||
183 | m_subtype = type; | ||
184 | } | ||
185 | |||
186 | const QString& RecBody::Subtype()const | ||
187 | { | ||
188 | return m_subtype; | ||
189 | } | 211 | } |
diff --git a/noncore/net/mail/mailtypes.h b/noncore/net/mail/mailtypes.h index 900f10a..60db527 100644 --- a/noncore/net/mail/mailtypes.h +++ b/noncore/net/mail/mailtypes.h | |||
@@ -9,12 +9,14 @@ | |||
9 | #define FLAG_RECENT 5 | 9 | #define FLAG_RECENT 5 |
10 | 10 | ||
11 | #include <qlist.h> | 11 | #include <qlist.h> |
12 | #include <qbitarray.h> | 12 | #include <qbitarray.h> |
13 | #include <qstring.h> | 13 | #include <qstring.h> |
14 | #include <qstringlist.h> | 14 | #include <qstringlist.h> |
15 | #include <qmap.h> | ||
16 | #include <qvaluelist.h> | ||
15 | 17 | ||
16 | /* a class to describe mails in a mailbox */ | 18 | /* a class to describe mails in a mailbox */ |
17 | /* Attention! | 19 | /* Attention! |
18 | From programmers point of view it would make sense to | 20 | From programmers point of view it would make sense to |
19 | store the mail body into this class, too. | 21 | store the mail body into this class, too. |
20 | But: not from the point of view of the device. | 22 | But: not from the point of view of the device. |
@@ -65,50 +67,61 @@ protected: | |||
65 | QBitArray msg_flags; | 67 | QBitArray msg_flags; |
66 | QStringList to,cc,bcc; | 68 | QStringList to,cc,bcc; |
67 | void init(); | 69 | void init(); |
68 | void copy_old(const RecMail&old); | 70 | void copy_old(const RecMail&old); |
69 | }; | 71 | }; |
70 | 72 | ||
73 | typedef QMap<QString,QString> part_plist_t; | ||
74 | |||
71 | class RecPart | 75 | class RecPart |
72 | { | 76 | { |
73 | protected: | 77 | protected: |
74 | QString m_type,m_subtype,m_identifier,m_encoding; | 78 | QString m_type,m_subtype,m_identifier,m_encoding; |
75 | unsigned int m_lines; | 79 | unsigned int m_lines; |
80 | part_plist_t m_Parameters; | ||
81 | /* describes the position in the mail */ | ||
82 | QValueList<int> m_poslist; | ||
83 | |||
76 | public: | 84 | public: |
77 | RecPart(); | 85 | RecPart(); |
78 | RecPart(const QString&identifier,const QString&type="",const QString&subtype="",const QString&encoding="BASE64",unsigned int lines=0); | ||
79 | virtual ~RecPart(); | 86 | virtual ~RecPart(); |
80 | 87 | ||
81 | const QString&Type()const; | 88 | const QString&Type()const; |
82 | void setType(const QString&type); | 89 | void setType(const QString&type); |
83 | const QString&Subtype()const; | 90 | const QString&Subtype()const; |
84 | void setSubtype(const QString&subtype); | 91 | void setSubtype(const QString&subtype); |
85 | const QString&Identifier()const; | 92 | const QString&Identifier()const; |
86 | void setIdentifier(const QString&identifier); | 93 | void setIdentifier(const QString&identifier); |
87 | const QString&Encoding()const; | 94 | const QString&Encoding()const; |
88 | void setEncoding(const QString&encoding); | 95 | void setEncoding(const QString&encoding); |
89 | void setLines(unsigned int lines); | 96 | void setLines(unsigned int lines); |
90 | const unsigned int Lines()const; | 97 | const unsigned int Lines()const; |
98 | |||
99 | void setParameters(const part_plist_t&list); | ||
100 | const part_plist_t&Parameters()const; | ||
101 | void addParameter(const QString&key,const QString&value); | ||
102 | const QString searchParamter(const QString&key)const; | ||
103 | void setPositionlist(const QValueList<int>&poslist); | ||
104 | const QValueList<int>& Positionlist()const; | ||
91 | }; | 105 | }; |
92 | 106 | ||
93 | class RecBody | 107 | class RecBody |
94 | { | 108 | { |
95 | protected: | 109 | protected: |
96 | QString m_BodyText,m_type,m_subtype; | 110 | QString m_BodyText; |
97 | QList<RecPart> m_PartsList; | 111 | QList<RecPart> m_PartsList; |
112 | RecPart m_description; | ||
98 | 113 | ||
99 | public: | 114 | public: |
100 | RecBody(); | 115 | RecBody(); |
101 | virtual ~RecBody(); | 116 | virtual ~RecBody(); |
102 | void setBodytext(const QString&); | 117 | void setBodytext(const QString&); |
103 | const QString& Bodytext()const; | 118 | const QString& Bodytext()const; |
104 | void setType(const QString&); | ||
105 | const QString&Type()const; | ||
106 | void setSubtype(const QString&); | ||
107 | const QString&Subtype()const; | ||
108 | 119 | ||
120 | void setDescription(const RecPart&des); | ||
121 | const RecPart& Description()const; | ||
109 | 122 | ||
110 | void setParts(const QList<RecPart>&parts); | 123 | void setParts(const QList<RecPart>&parts); |
111 | const QList<RecPart>& Parts()const; | 124 | const QList<RecPart>& Parts()const; |
112 | void addPart(const RecPart&part); | 125 | void addPart(const RecPart&part); |
113 | }; | 126 | }; |
114 | 127 | ||