-rw-r--r-- | noncore/net/mail/abstractmail.cpp | 21 | ||||
-rw-r--r-- | noncore/net/mail/abstractmail.h | 4 | ||||
-rw-r--r-- | noncore/net/mail/imapwrapper.cpp | 18 | ||||
-rw-r--r-- | noncore/net/mail/imapwrapper.h | 4 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/abstractmail.cpp | 21 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/abstractmail.h | 4 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 18 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.h | 4 |
8 files changed, 78 insertions, 16 deletions
diff --git a/noncore/net/mail/abstractmail.cpp b/noncore/net/mail/abstractmail.cpp index 7380c31..0bb2525 100644 --- a/noncore/net/mail/abstractmail.cpp +++ b/noncore/net/mail/abstractmail.cpp | |||
@@ -1,13 +1,34 @@ | |||
1 | #include "abstractmail.h" | 1 | #include "abstractmail.h" |
2 | #include "imapwrapper.h" | 2 | #include "imapwrapper.h" |
3 | #include "pop3wrapper.h" | 3 | #include "pop3wrapper.h" |
4 | 4 | ||
5 | #include <qstring.h> | ||
6 | #include <stdlib.h> | ||
7 | #include <libetpan/mailmime_content.h> | ||
8 | |||
5 | AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) | 9 | AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) |
6 | { | 10 | { |
7 | return new IMAPwrapper(a); | 11 | return new IMAPwrapper(a); |
8 | } | 12 | } |
9 | 13 | ||
10 | AbstractMail* AbstractMail::getWrapper(POP3account *a) | 14 | AbstractMail* AbstractMail::getWrapper(POP3account *a) |
11 | { | 15 | { |
12 | return new POP3wrapper(a); | 16 | return new POP3wrapper(a); |
13 | } | 17 | } |
18 | |||
19 | QString AbstractMail::decode_quoted_printable(const char*text) | ||
20 | { | ||
21 | char*result_text; | ||
22 | size_t index = 0; | ||
23 | QString result = ""; | ||
24 | /* reset for recursive use! */ | ||
25 | size_t target_length = 0; | ||
26 | result_text = 0; | ||
27 | int err = mailmime_quoted_printable_body_parse(text,strlen(text), | ||
28 | &index,&result_text,&target_length,0); | ||
29 | if (result_text) { | ||
30 | result = result_text; | ||
31 | free(result_text); | ||
32 | } | ||
33 | return result; | ||
34 | } | ||
diff --git a/noncore/net/mail/abstractmail.h b/noncore/net/mail/abstractmail.h index 62e0715..4473ad2 100644 --- a/noncore/net/mail/abstractmail.h +++ b/noncore/net/mail/abstractmail.h | |||
@@ -14,18 +14,18 @@ class Folder; | |||
14 | class AbstractMail:public QObject | 14 | class AbstractMail:public QObject |
15 | { | 15 | { |
16 | Q_OBJECT | 16 | Q_OBJECT |
17 | public: | 17 | public: |
18 | AbstractMail(){}; | 18 | AbstractMail(){}; |
19 | virtual ~AbstractMail(){} | 19 | virtual ~AbstractMail(){} |
20 | virtual QList<Folder>* listFolders()=0; | 20 | virtual QList<Folder>* listFolders()=0; |
21 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0; | 21 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0; |
22 | virtual RecBody fetchBody(const RecMail&mail)=0; | 22 | virtual RecBody fetchBody(const RecMail&mail)=0; |
23 | virtual QString fetchPart(const RecMail&mail,const RecPart&part)=0; | 23 | virtual QString fetchPart(const RecMail&mail,const RecPart&part)=0; |
24 | virtual void deleteMail(const RecMail&mail)=0; | 24 | virtual void deleteMail(const RecMail&mail)=0; |
25 | virtual void answeredMail(const RecMail&mail)=0; | 25 | virtual void answeredMail(const RecMail&mail)=0; |
26 | 26 | ||
27 | static AbstractMail* getWrapper(IMAPaccount *a); | 27 | static AbstractMail* getWrapper(IMAPaccount *a); |
28 | static AbstractMail* getWrapper(POP3account *a); | 28 | static AbstractMail* getWrapper(POP3account *a); |
29 | static QString decode_quoted_printable(const char*text); | ||
29 | }; | 30 | }; |
30 | |||
31 | #endif | 31 | #endif |
diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp index ad95384..a4e6228 100644 --- a/noncore/net/mail/imapwrapper.cpp +++ b/noncore/net/mail/imapwrapper.cpp | |||
@@ -383,31 +383,37 @@ void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mai | |||
383 | { | 383 | { |
384 | if (!mailDescription) { | 384 | if (!mailDescription) { |
385 | return; | 385 | return; |
386 | } | 386 | } |
387 | QString sub,body_text; | 387 | QString sub,body_text; |
388 | RecPart singlePart; | 388 | RecPart singlePart; |
389 | QValueList<int> path; | 389 | QValueList<int> path; |
390 | fillSinglePart(singlePart,mailDescription); | 390 | fillSinglePart(singlePart,mailDescription); |
391 | switch (mailDescription->bd_type) { | 391 | switch (mailDescription->bd_type) { |
392 | case MAILIMAP_BODY_TYPE_1PART_MSG: | 392 | case MAILIMAP_BODY_TYPE_1PART_MSG: |
393 | path.append(1); | 393 | path.append(1); |
394 | body_text = fetchPart(mail,path,true); | 394 | body_text = fetchPart(mail,path,true); |
395 | if (singlePart.Encoding()=="quoted-printable") { | ||
396 | body_text = decode_quoted_printable(body_text.latin1()); | ||
397 | } | ||
395 | target_body.setBodytext(body_text); | 398 | target_body.setBodytext(body_text); |
396 | target_body.setDescription(singlePart); | 399 | target_body.setDescription(singlePart); |
397 | break; | 400 | break; |
398 | case MAILIMAP_BODY_TYPE_1PART_TEXT: | 401 | case MAILIMAP_BODY_TYPE_1PART_TEXT: |
399 | qDebug("Mediatype single: %s",mailDescription->bd_data.bd_type_text->bd_media_text); | 402 | qDebug("Mediatype single: %s",mailDescription->bd_data.bd_type_text->bd_media_text); |
400 | path.append(1); | 403 | path.append(1); |
401 | body_text = fetchPart(mail,path,true); | 404 | body_text = fetchPart(mail,path,true); |
405 | if (singlePart.Encoding()=="quoted-printable") { | ||
406 | body_text = decode_quoted_printable(body_text.latin1()); | ||
407 | } | ||
402 | target_body.setBodytext(body_text); | 408 | target_body.setBodytext(body_text); |
403 | target_body.setDescription(singlePart); | 409 | target_body.setDescription(singlePart); |
404 | break; | 410 | break; |
405 | case MAILIMAP_BODY_TYPE_1PART_BASIC: | 411 | case MAILIMAP_BODY_TYPE_1PART_BASIC: |
406 | qDebug("Single attachment"); | 412 | qDebug("Single attachment"); |
407 | target_body.setBodytext(""); | 413 | target_body.setBodytext(""); |
408 | target_body.addPart(singlePart); | 414 | target_body.addPart(singlePart); |
409 | break; | 415 | break; |
410 | default: | 416 | default: |
411 | break; | 417 | break; |
412 | } | 418 | } |
413 | 419 | ||
@@ -446,25 +452,25 @@ QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | |||
446 | } | 452 | } |
447 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { | 453 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
448 | from+=">"; | 454 | from+=">"; |
449 | } | 455 | } |
450 | l.append(QString(from)); | 456 | l.append(QString(from)); |
451 | if (++count > 99) { | 457 | if (++count > 99) { |
452 | break; | 458 | break; |
453 | } | 459 | } |
454 | } | 460 | } |
455 | return l; | 461 | return l; |
456 | } | 462 | } |
457 | 463 | ||
458 | QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call) | 464 | QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call,const QString&enc) |
459 | { | 465 | { |
460 | QString body(""); | 466 | QString body(""); |
461 | const char*mb; | 467 | const char*mb; |
462 | int err; | 468 | int err; |
463 | mailimap_fetch_type *fetchType; | 469 | mailimap_fetch_type *fetchType; |
464 | mailimap_set *set; | 470 | mailimap_set *set; |
465 | clistcell*current,*cur; | 471 | clistcell*current,*cur; |
466 | 472 | ||
467 | login(); | 473 | login(); |
468 | if (!m_imap) { | 474 | if (!m_imap) { |
469 | return body; | 475 | return body; |
470 | } | 476 | } |
@@ -498,25 +504,29 @@ QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,boo | |||
498 | 504 | ||
499 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 505 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
500 | mailimap_msg_att * msg_att; | 506 | mailimap_msg_att * msg_att; |
501 | msg_att = (mailimap_msg_att*)current->data; | 507 | msg_att = (mailimap_msg_att*)current->data; |
502 | mailimap_msg_att_item*msg_att_item; | 508 | mailimap_msg_att_item*msg_att_item; |
503 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { | 509 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { |
504 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); | 510 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); |
505 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { | 511 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { |
506 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { | 512 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { |
507 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; | 513 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; |
508 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; | 514 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; |
509 | if (text) { | 515 | if (text) { |
510 | body = QString(text); | 516 | if (enc=="quoted-printable") { |
517 | body = decode_quoted_printable(text); | ||
518 | } else { | ||
519 | body = QString(text); | ||
520 | } | ||
511 | free(text); | 521 | free(text); |
512 | } else { | 522 | } else { |
513 | body = ""; | 523 | body = ""; |
514 | } | 524 | } |
515 | } | 525 | } |
516 | } | 526 | } |
517 | } | 527 | } |
518 | 528 | ||
519 | } else { | 529 | } else { |
520 | qDebug("error fetching text: %s",m_imap->imap_response); | 530 | qDebug("error fetching text: %s",m_imap->imap_response); |
521 | } | 531 | } |
522 | mailimap_fetch_list_free(result); | 532 | mailimap_fetch_list_free(result); |
@@ -538,25 +548,25 @@ void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mai | |||
538 | current_body = (mailimap_body*)current->data; | 548 | current_body = (mailimap_body*)current->data; |
539 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { | 549 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { |
540 | QValueList<int>clist = recList; | 550 | QValueList<int>clist = recList; |
541 | clist.append(count); | 551 | clist.append(count); |
542 | searchBodyText(mail,current_body->bd_data.bd_body_mpart,target_body,current_recursion+1,clist); | 552 | searchBodyText(mail,current_body->bd_data.bd_body_mpart,target_body,current_recursion+1,clist); |
543 | } else if (current_body->bd_type==MAILIMAP_BODY_1PART){ | 553 | } else if (current_body->bd_type==MAILIMAP_BODY_1PART){ |
544 | RecPart currentPart; | 554 | RecPart currentPart; |
545 | fillSinglePart(currentPart,current_body->bd_data.bd_body_1part); | 555 | fillSinglePart(currentPart,current_body->bd_data.bd_body_1part); |
546 | QValueList<int>clist = recList; | 556 | QValueList<int>clist = recList; |
547 | clist.append(count); | 557 | clist.append(count); |
548 | /* important: Check for is NULL 'cause a body can be empty! */ | 558 | /* important: Check for is NULL 'cause a body can be empty! */ |
549 | if (currentPart.Type()=="text" && target_body.Bodytext().isNull() ) { | 559 | if (currentPart.Type()=="text" && target_body.Bodytext().isNull() ) { |
550 | QString body_text = fetchPart(mail,clist,true); | 560 | QString body_text = fetchPart(mail,clist,true,currentPart.Encoding()); |
551 | target_body.setDescription(currentPart); | 561 | target_body.setDescription(currentPart); |
552 | target_body.setBodytext(body_text); | 562 | target_body.setBodytext(body_text); |
553 | } else { | 563 | } else { |
554 | QString id(""); | 564 | QString id(""); |
555 | for (unsigned int j = 0; j < clist.count();++j) { | 565 | for (unsigned int j = 0; j < clist.count();++j) { |
556 | id+=(j>0?" ":""); | 566 | id+=(j>0?" ":""); |
557 | id+=QString("%1").arg(clist[j]); | 567 | id+=QString("%1").arg(clist[j]); |
558 | } | 568 | } |
559 | qDebug("ID= %s",id.latin1()); | 569 | qDebug("ID= %s",id.latin1()); |
560 | currentPart.setIdentifier(id); | 570 | currentPart.setIdentifier(id); |
561 | currentPart.setPositionlist(clist); | 571 | currentPart.setPositionlist(clist); |
562 | target_body.addPart(currentPart); | 572 | target_body.addPart(currentPart); |
@@ -696,25 +706,25 @@ void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which) | |||
696 | free(t); | 706 | free(t); |
697 | } | 707 | } |
698 | } | 708 | } |
699 | if (which->bd_description) { | 709 | if (which->bd_description) { |
700 | target_part.setDescription(QString(which->bd_description)); | 710 | target_part.setDescription(QString(which->bd_description)); |
701 | } | 711 | } |
702 | target_part.setEncoding(encoding); | 712 | target_part.setEncoding(encoding); |
703 | target_part.setSize(which->bd_size); | 713 | target_part.setSize(which->bd_size); |
704 | } | 714 | } |
705 | 715 | ||
706 | QString IMAPwrapper::fetchPart(const RecMail&mail,const RecPart&part) | 716 | QString IMAPwrapper::fetchPart(const RecMail&mail,const RecPart&part) |
707 | { | 717 | { |
708 | return fetchPart(mail,part.Positionlist(),false); | 718 | return fetchPart(mail,part.Positionlist(),false,part.Encoding()); |
709 | } | 719 | } |
710 | 720 | ||
711 | void IMAPwrapper::deleteMail(const RecMail&mail) | 721 | void IMAPwrapper::deleteMail(const RecMail&mail) |
712 | { | 722 | { |
713 | mailimap_flag_list*flist; | 723 | mailimap_flag_list*flist; |
714 | mailimap_set *set; | 724 | mailimap_set *set; |
715 | mailimap_store_att_flags * store_flags; | 725 | mailimap_store_att_flags * store_flags; |
716 | int err; | 726 | int err; |
717 | login(); | 727 | login(); |
718 | if (!m_imap) { | 728 | if (!m_imap) { |
719 | return; | 729 | return; |
720 | } | 730 | } |
diff --git a/noncore/net/mail/imapwrapper.h b/noncore/net/mail/imapwrapper.h index 700d512..768a517 100644 --- a/noncore/net/mail/imapwrapper.h +++ b/noncore/net/mail/imapwrapper.h | |||
@@ -25,32 +25,32 @@ public: | |||
25 | virtual RecBody fetchBody(const RecMail&mail); | 25 | virtual RecBody fetchBody(const RecMail&mail); |
26 | virtual QString fetchPart(const RecMail&mail,const RecPart&part); | 26 | virtual QString fetchPart(const RecMail&mail,const RecPart&part); |
27 | virtual void deleteMail(const RecMail&mail); | 27 | virtual void deleteMail(const RecMail&mail); |
28 | virtual void answeredMail(const RecMail&mail); | 28 | virtual void answeredMail(const RecMail&mail); |
29 | 29 | ||
30 | static void imap_progress( size_t current, size_t maximum ); | 30 | static void imap_progress( size_t current, size_t maximum ); |
31 | 31 | ||
32 | protected: | 32 | protected: |
33 | RecMail*parse_list_result(mailimap_msg_att*); | 33 | RecMail*parse_list_result(mailimap_msg_att*); |
34 | void login(); | 34 | void login(); |
35 | void logout(); | 35 | void logout(); |
36 | 36 | ||
37 | virtual QString fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false); | 37 | virtual QString fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); |
38 | 38 | ||
39 | void searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body); | 39 | void searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body); |
40 | void searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion=0,QValueList<int>recList=QValueList<int>()); | 40 | void searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion=0,QValueList<int>recList=QValueList<int>()); |
41 | 41 | ||
42 | void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); | 42 | void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); |
43 | void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); | 43 | void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); |
44 | void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); | 44 | void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); |
45 | void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which); | 45 | void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which); |
46 | 46 | ||
47 | /* just helpers */ | 47 | /* just helpers */ |
48 | static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which); | 48 | static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which); |
49 | static QStringList address_list_to_stringlist(clist*list); | 49 | static QStringList address_list_to_stringlist(clist*list); |
50 | 50 | ||
51 | private: | 51 | |
52 | IMAPaccount *account; | 52 | IMAPaccount *account; |
53 | mailimap *m_imap; | 53 | mailimap *m_imap; |
54 | }; | 54 | }; |
55 | 55 | ||
56 | #endif | 56 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.cpp b/noncore/net/mail/libmailwrapper/abstractmail.cpp index 7380c31..0bb2525 100644 --- a/noncore/net/mail/libmailwrapper/abstractmail.cpp +++ b/noncore/net/mail/libmailwrapper/abstractmail.cpp | |||
@@ -1,13 +1,34 @@ | |||
1 | #include "abstractmail.h" | 1 | #include "abstractmail.h" |
2 | #include "imapwrapper.h" | 2 | #include "imapwrapper.h" |
3 | #include "pop3wrapper.h" | 3 | #include "pop3wrapper.h" |
4 | 4 | ||
5 | #include <qstring.h> | ||
6 | #include <stdlib.h> | ||
7 | #include <libetpan/mailmime_content.h> | ||
8 | |||
5 | AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) | 9 | AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) |
6 | { | 10 | { |
7 | return new IMAPwrapper(a); | 11 | return new IMAPwrapper(a); |
8 | } | 12 | } |
9 | 13 | ||
10 | AbstractMail* AbstractMail::getWrapper(POP3account *a) | 14 | AbstractMail* AbstractMail::getWrapper(POP3account *a) |
11 | { | 15 | { |
12 | return new POP3wrapper(a); | 16 | return new POP3wrapper(a); |
13 | } | 17 | } |
18 | |||
19 | QString AbstractMail::decode_quoted_printable(const char*text) | ||
20 | { | ||
21 | char*result_text; | ||
22 | size_t index = 0; | ||
23 | QString result = ""; | ||
24 | /* reset for recursive use! */ | ||
25 | size_t target_length = 0; | ||
26 | result_text = 0; | ||
27 | int err = mailmime_quoted_printable_body_parse(text,strlen(text), | ||
28 | &index,&result_text,&target_length,0); | ||
29 | if (result_text) { | ||
30 | result = result_text; | ||
31 | free(result_text); | ||
32 | } | ||
33 | return result; | ||
34 | } | ||
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h index 62e0715..4473ad2 100644 --- a/noncore/net/mail/libmailwrapper/abstractmail.h +++ b/noncore/net/mail/libmailwrapper/abstractmail.h | |||
@@ -14,18 +14,18 @@ class Folder; | |||
14 | class AbstractMail:public QObject | 14 | class AbstractMail:public QObject |
15 | { | 15 | { |
16 | Q_OBJECT | 16 | Q_OBJECT |
17 | public: | 17 | public: |
18 | AbstractMail(){}; | 18 | AbstractMail(){}; |
19 | virtual ~AbstractMail(){} | 19 | virtual ~AbstractMail(){} |
20 | virtual QList<Folder>* listFolders()=0; | 20 | virtual QList<Folder>* listFolders()=0; |
21 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0; | 21 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0; |
22 | virtual RecBody fetchBody(const RecMail&mail)=0; | 22 | virtual RecBody fetchBody(const RecMail&mail)=0; |
23 | virtual QString fetchPart(const RecMail&mail,const RecPart&part)=0; | 23 | virtual QString fetchPart(const RecMail&mail,const RecPart&part)=0; |
24 | virtual void deleteMail(const RecMail&mail)=0; | 24 | virtual void deleteMail(const RecMail&mail)=0; |
25 | virtual void answeredMail(const RecMail&mail)=0; | 25 | virtual void answeredMail(const RecMail&mail)=0; |
26 | 26 | ||
27 | static AbstractMail* getWrapper(IMAPaccount *a); | 27 | static AbstractMail* getWrapper(IMAPaccount *a); |
28 | static AbstractMail* getWrapper(POP3account *a); | 28 | static AbstractMail* getWrapper(POP3account *a); |
29 | static QString decode_quoted_printable(const char*text); | ||
29 | }; | 30 | }; |
30 | |||
31 | #endif | 31 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index ad95384..a4e6228 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp | |||
@@ -383,31 +383,37 @@ void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mai | |||
383 | { | 383 | { |
384 | if (!mailDescription) { | 384 | if (!mailDescription) { |
385 | return; | 385 | return; |
386 | } | 386 | } |
387 | QString sub,body_text; | 387 | QString sub,body_text; |
388 | RecPart singlePart; | 388 | RecPart singlePart; |
389 | QValueList<int> path; | 389 | QValueList<int> path; |
390 | fillSinglePart(singlePart,mailDescription); | 390 | fillSinglePart(singlePart,mailDescription); |
391 | switch (mailDescription->bd_type) { | 391 | switch (mailDescription->bd_type) { |
392 | case MAILIMAP_BODY_TYPE_1PART_MSG: | 392 | case MAILIMAP_BODY_TYPE_1PART_MSG: |
393 | path.append(1); | 393 | path.append(1); |
394 | body_text = fetchPart(mail,path,true); | 394 | body_text = fetchPart(mail,path,true); |
395 | if (singlePart.Encoding()=="quoted-printable") { | ||
396 | body_text = decode_quoted_printable(body_text.latin1()); | ||
397 | } | ||
395 | target_body.setBodytext(body_text); | 398 | target_body.setBodytext(body_text); |
396 | target_body.setDescription(singlePart); | 399 | target_body.setDescription(singlePart); |
397 | break; | 400 | break; |
398 | case MAILIMAP_BODY_TYPE_1PART_TEXT: | 401 | case MAILIMAP_BODY_TYPE_1PART_TEXT: |
399 | qDebug("Mediatype single: %s",mailDescription->bd_data.bd_type_text->bd_media_text); | 402 | qDebug("Mediatype single: %s",mailDescription->bd_data.bd_type_text->bd_media_text); |
400 | path.append(1); | 403 | path.append(1); |
401 | body_text = fetchPart(mail,path,true); | 404 | body_text = fetchPart(mail,path,true); |
405 | if (singlePart.Encoding()=="quoted-printable") { | ||
406 | body_text = decode_quoted_printable(body_text.latin1()); | ||
407 | } | ||
402 | target_body.setBodytext(body_text); | 408 | target_body.setBodytext(body_text); |
403 | target_body.setDescription(singlePart); | 409 | target_body.setDescription(singlePart); |
404 | break; | 410 | break; |
405 | case MAILIMAP_BODY_TYPE_1PART_BASIC: | 411 | case MAILIMAP_BODY_TYPE_1PART_BASIC: |
406 | qDebug("Single attachment"); | 412 | qDebug("Single attachment"); |
407 | target_body.setBodytext(""); | 413 | target_body.setBodytext(""); |
408 | target_body.addPart(singlePart); | 414 | target_body.addPart(singlePart); |
409 | break; | 415 | break; |
410 | default: | 416 | default: |
411 | break; | 417 | break; |
412 | } | 418 | } |
413 | 419 | ||
@@ -446,25 +452,25 @@ QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | |||
446 | } | 452 | } |
447 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { | 453 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
448 | from+=">"; | 454 | from+=">"; |
449 | } | 455 | } |
450 | l.append(QString(from)); | 456 | l.append(QString(from)); |
451 | if (++count > 99) { | 457 | if (++count > 99) { |
452 | break; | 458 | break; |
453 | } | 459 | } |
454 | } | 460 | } |
455 | return l; | 461 | return l; |
456 | } | 462 | } |
457 | 463 | ||
458 | QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call) | 464 | QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call,const QString&enc) |
459 | { | 465 | { |
460 | QString body(""); | 466 | QString body(""); |
461 | const char*mb; | 467 | const char*mb; |
462 | int err; | 468 | int err; |
463 | mailimap_fetch_type *fetchType; | 469 | mailimap_fetch_type *fetchType; |
464 | mailimap_set *set; | 470 | mailimap_set *set; |
465 | clistcell*current,*cur; | 471 | clistcell*current,*cur; |
466 | 472 | ||
467 | login(); | 473 | login(); |
468 | if (!m_imap) { | 474 | if (!m_imap) { |
469 | return body; | 475 | return body; |
470 | } | 476 | } |
@@ -498,25 +504,29 @@ QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,boo | |||
498 | 504 | ||
499 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 505 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
500 | mailimap_msg_att * msg_att; | 506 | mailimap_msg_att * msg_att; |
501 | msg_att = (mailimap_msg_att*)current->data; | 507 | msg_att = (mailimap_msg_att*)current->data; |
502 | mailimap_msg_att_item*msg_att_item; | 508 | mailimap_msg_att_item*msg_att_item; |
503 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { | 509 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { |
504 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); | 510 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); |
505 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { | 511 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { |
506 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { | 512 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { |
507 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; | 513 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; |
508 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; | 514 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; |
509 | if (text) { | 515 | if (text) { |
510 | body = QString(text); | 516 | if (enc=="quoted-printable") { |
517 | body = decode_quoted_printable(text); | ||
518 | } else { | ||
519 | body = QString(text); | ||
520 | } | ||
511 | free(text); | 521 | free(text); |
512 | } else { | 522 | } else { |
513 | body = ""; | 523 | body = ""; |
514 | } | 524 | } |
515 | } | 525 | } |
516 | } | 526 | } |
517 | } | 527 | } |
518 | 528 | ||
519 | } else { | 529 | } else { |
520 | qDebug("error fetching text: %s",m_imap->imap_response); | 530 | qDebug("error fetching text: %s",m_imap->imap_response); |
521 | } | 531 | } |
522 | mailimap_fetch_list_free(result); | 532 | mailimap_fetch_list_free(result); |
@@ -538,25 +548,25 @@ void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mai | |||
538 | current_body = (mailimap_body*)current->data; | 548 | current_body = (mailimap_body*)current->data; |
539 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { | 549 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { |
540 | QValueList<int>clist = recList; | 550 | QValueList<int>clist = recList; |
541 | clist.append(count); | 551 | clist.append(count); |
542 | searchBodyText(mail,current_body->bd_data.bd_body_mpart,target_body,current_recursion+1,clist); | 552 | searchBodyText(mail,current_body->bd_data.bd_body_mpart,target_body,current_recursion+1,clist); |
543 | } else if (current_body->bd_type==MAILIMAP_BODY_1PART){ | 553 | } else if (current_body->bd_type==MAILIMAP_BODY_1PART){ |
544 | RecPart currentPart; | 554 | RecPart currentPart; |
545 | fillSinglePart(currentPart,current_body->bd_data.bd_body_1part); | 555 | fillSinglePart(currentPart,current_body->bd_data.bd_body_1part); |
546 | QValueList<int>clist = recList; | 556 | QValueList<int>clist = recList; |
547 | clist.append(count); | 557 | clist.append(count); |
548 | /* important: Check for is NULL 'cause a body can be empty! */ | 558 | /* important: Check for is NULL 'cause a body can be empty! */ |
549 | if (currentPart.Type()=="text" && target_body.Bodytext().isNull() ) { | 559 | if (currentPart.Type()=="text" && target_body.Bodytext().isNull() ) { |
550 | QString body_text = fetchPart(mail,clist,true); | 560 | QString body_text = fetchPart(mail,clist,true,currentPart.Encoding()); |
551 | target_body.setDescription(currentPart); | 561 | target_body.setDescription(currentPart); |
552 | target_body.setBodytext(body_text); | 562 | target_body.setBodytext(body_text); |
553 | } else { | 563 | } else { |
554 | QString id(""); | 564 | QString id(""); |
555 | for (unsigned int j = 0; j < clist.count();++j) { | 565 | for (unsigned int j = 0; j < clist.count();++j) { |
556 | id+=(j>0?" ":""); | 566 | id+=(j>0?" ":""); |
557 | id+=QString("%1").arg(clist[j]); | 567 | id+=QString("%1").arg(clist[j]); |
558 | } | 568 | } |
559 | qDebug("ID= %s",id.latin1()); | 569 | qDebug("ID= %s",id.latin1()); |
560 | currentPart.setIdentifier(id); | 570 | currentPart.setIdentifier(id); |
561 | currentPart.setPositionlist(clist); | 571 | currentPart.setPositionlist(clist); |
562 | target_body.addPart(currentPart); | 572 | target_body.addPart(currentPart); |
@@ -696,25 +706,25 @@ void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which) | |||
696 | free(t); | 706 | free(t); |
697 | } | 707 | } |
698 | } | 708 | } |
699 | if (which->bd_description) { | 709 | if (which->bd_description) { |
700 | target_part.setDescription(QString(which->bd_description)); | 710 | target_part.setDescription(QString(which->bd_description)); |
701 | } | 711 | } |
702 | target_part.setEncoding(encoding); | 712 | target_part.setEncoding(encoding); |
703 | target_part.setSize(which->bd_size); | 713 | target_part.setSize(which->bd_size); |
704 | } | 714 | } |
705 | 715 | ||
706 | QString IMAPwrapper::fetchPart(const RecMail&mail,const RecPart&part) | 716 | QString IMAPwrapper::fetchPart(const RecMail&mail,const RecPart&part) |
707 | { | 717 | { |
708 | return fetchPart(mail,part.Positionlist(),false); | 718 | return fetchPart(mail,part.Positionlist(),false,part.Encoding()); |
709 | } | 719 | } |
710 | 720 | ||
711 | void IMAPwrapper::deleteMail(const RecMail&mail) | 721 | void IMAPwrapper::deleteMail(const RecMail&mail) |
712 | { | 722 | { |
713 | mailimap_flag_list*flist; | 723 | mailimap_flag_list*flist; |
714 | mailimap_set *set; | 724 | mailimap_set *set; |
715 | mailimap_store_att_flags * store_flags; | 725 | mailimap_store_att_flags * store_flags; |
716 | int err; | 726 | int err; |
717 | login(); | 727 | login(); |
718 | if (!m_imap) { | 728 | if (!m_imap) { |
719 | return; | 729 | return; |
720 | } | 730 | } |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h index 700d512..768a517 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.h +++ b/noncore/net/mail/libmailwrapper/imapwrapper.h | |||
@@ -25,32 +25,32 @@ public: | |||
25 | virtual RecBody fetchBody(const RecMail&mail); | 25 | virtual RecBody fetchBody(const RecMail&mail); |
26 | virtual QString fetchPart(const RecMail&mail,const RecPart&part); | 26 | virtual QString fetchPart(const RecMail&mail,const RecPart&part); |
27 | virtual void deleteMail(const RecMail&mail); | 27 | virtual void deleteMail(const RecMail&mail); |
28 | virtual void answeredMail(const RecMail&mail); | 28 | virtual void answeredMail(const RecMail&mail); |
29 | 29 | ||
30 | static void imap_progress( size_t current, size_t maximum ); | 30 | static void imap_progress( size_t current, size_t maximum ); |
31 | 31 | ||
32 | protected: | 32 | protected: |
33 | RecMail*parse_list_result(mailimap_msg_att*); | 33 | RecMail*parse_list_result(mailimap_msg_att*); |
34 | void login(); | 34 | void login(); |
35 | void logout(); | 35 | void logout(); |
36 | 36 | ||
37 | virtual QString fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false); | 37 | virtual QString fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); |
38 | 38 | ||
39 | void searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body); | 39 | void searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body); |
40 | void searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion=0,QValueList<int>recList=QValueList<int>()); | 40 | void searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion=0,QValueList<int>recList=QValueList<int>()); |
41 | 41 | ||
42 | void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); | 42 | void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); |
43 | void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); | 43 | void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); |
44 | void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); | 44 | void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); |
45 | void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which); | 45 | void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which); |
46 | 46 | ||
47 | /* just helpers */ | 47 | /* just helpers */ |
48 | static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which); | 48 | static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which); |
49 | static QStringList address_list_to_stringlist(clist*list); | 49 | static QStringList address_list_to_stringlist(clist*list); |
50 | 50 | ||
51 | private: | 51 | |
52 | IMAPaccount *account; | 52 | IMAPaccount *account; |
53 | mailimap *m_imap; | 53 | mailimap *m_imap; |
54 | }; | 54 | }; |
55 | 55 | ||
56 | #endif | 56 | #endif |