summaryrefslogtreecommitdiff
path: root/noncore
authoralwin <alwin>2003-12-16 02:13:09 (UTC)
committer alwin <alwin>2003-12-16 02:13:09 (UTC)
commitf42c15f884d4377bc99d73e16fa1722b0fb2a4d3 (patch) (unidiff)
tree0ecd625c8a5913285fa31a050a9a6e49c13fbe4b /noncore
parent32d48372f7b5ec9e4586ea74cc444838b157248e (diff)
downloadopie-f42c15f884d4377bc99d73e16fa1722b0fb2a4d3.zip
opie-f42c15f884d4377bc99d73e16fa1722b0fb2a4d3.tar.gz
opie-f42c15f884d4377bc99d73e16fa1722b0fb2a4d3.tar.bz2
quoted-printable text will be decoded for display
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/abstractmail.cpp21
-rw-r--r--noncore/net/mail/abstractmail.h4
-rw-r--r--noncore/net/mail/imapwrapper.cpp18
-rw-r--r--noncore/net/mail/imapwrapper.h4
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.cpp21
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.h4
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp18
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.h4
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
@@ -2,6 +2,10 @@
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
5AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) 9AbstractMail* AbstractMail::getWrapper(IMAPaccount *a)
6{ 10{
7 return new IMAPwrapper(a); 11 return new IMAPwrapper(a);
@@ -11,3 +15,20 @@ AbstractMail* AbstractMail::getWrapper(POP3account *a)
11{ 15{
12 return new POP3wrapper(a); 16 return new POP3wrapper(a);
13} 17}
18
19QString 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
@@ -23,9 +23,9 @@ public:
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
@@ -392,6 +392,9 @@ void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mai
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;
@@ -399,6 +402,9 @@ void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mai
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;
@@ -455,7 +461,7 @@ QStringList IMAPwrapper::address_list_to_stringlist(clist*list)
455 return l; 461 return l;
456} 462}
457 463
458QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call) 464QString 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;
@@ -507,7 +513,11 @@ QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,boo
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 = "";
@@ -547,7 +557,7 @@ void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mai
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 {
@@ -705,7 +715,7 @@ void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which)
705 715
706QString IMAPwrapper::fetchPart(const RecMail&mail,const RecPart&part) 716QString 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
711void IMAPwrapper::deleteMail(const RecMail&mail) 721void IMAPwrapper::deleteMail(const RecMail&mail)
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
@@ -34,7 +34,7 @@ protected:
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>());
@@ -48,7 +48,7 @@ protected:
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
51private: 51
52 IMAPaccount *account; 52 IMAPaccount *account;
53 mailimap *m_imap; 53 mailimap *m_imap;
54}; 54};
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
@@ -2,6 +2,10 @@
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
5AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) 9AbstractMail* AbstractMail::getWrapper(IMAPaccount *a)
6{ 10{
7 return new IMAPwrapper(a); 11 return new IMAPwrapper(a);
@@ -11,3 +15,20 @@ AbstractMail* AbstractMail::getWrapper(POP3account *a)
11{ 15{
12 return new POP3wrapper(a); 16 return new POP3wrapper(a);
13} 17}
18
19QString 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
@@ -23,9 +23,9 @@ public:
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
@@ -392,6 +392,9 @@ void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mai
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;
@@ -399,6 +402,9 @@ void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mai
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;
@@ -455,7 +461,7 @@ QStringList IMAPwrapper::address_list_to_stringlist(clist*list)
455 return l; 461 return l;
456} 462}
457 463
458QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call) 464QString 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;
@@ -507,7 +513,11 @@ QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,boo
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 = "";
@@ -547,7 +557,7 @@ void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mai
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 {
@@ -705,7 +715,7 @@ void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which)
705 715
706QString IMAPwrapper::fetchPart(const RecMail&mail,const RecPart&part) 716QString 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
711void IMAPwrapper::deleteMail(const RecMail&mail) 721void IMAPwrapper::deleteMail(const RecMail&mail)
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
@@ -34,7 +34,7 @@ protected:
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>());
@@ -48,7 +48,7 @@ protected:
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
51private: 51
52 IMAPaccount *account; 52 IMAPaccount *account;
53 mailimap *m_imap; 53 mailimap *m_imap;
54}; 54};