author | alwin <alwin> | 2003-12-16 13:14:05 (UTC) |
---|---|---|
committer | alwin <alwin> | 2003-12-16 13:14:05 (UTC) |
commit | 49c02bbbb7a0aeee933d58ba1d3d3e86e6bc7838 (patch) (unidiff) | |
tree | 710393582789ed1db97592fed5bb88ad4d56550d | |
parent | f42c15f884d4377bc99d73e16fa1722b0fb2a4d3 (diff) | |
download | opie-49c02bbbb7a0aeee933d58ba1d3d3e86e6bc7838.zip opie-49c02bbbb7a0aeee933d58ba1d3d3e86e6bc7838.tar.gz opie-49c02bbbb7a0aeee933d58ba1d3d3e86e6bc7838.tar.bz2 |
saving of attachments implemented.
-rw-r--r-- | noncore/net/mail/abstractmail.cpp | 28 | ||||
-rw-r--r-- | noncore/net/mail/abstractmail.h | 8 | ||||
-rw-r--r-- | noncore/net/mail/imapwrapper.cpp | 78 | ||||
-rw-r--r-- | noncore/net/mail/imapwrapper.h | 12 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/abstractmail.cpp | 28 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/abstractmail.h | 8 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 78 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.h | 12 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailtypes.cpp | 90 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailtypes.h | 47 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.cpp | 11 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.h | 6 | ||||
-rw-r--r-- | noncore/net/mail/mailtypes.cpp | 90 | ||||
-rw-r--r-- | noncore/net/mail/mailtypes.h | 47 | ||||
-rw-r--r-- | noncore/net/mail/pop3wrapper.cpp | 11 | ||||
-rw-r--r-- | noncore/net/mail/pop3wrapper.h | 6 | ||||
-rw-r--r-- | noncore/net/mail/viewmail.cpp | 13 |
17 files changed, 477 insertions, 96 deletions
diff --git a/noncore/net/mail/abstractmail.cpp b/noncore/net/mail/abstractmail.cpp index 0bb2525..92a46f1 100644 --- a/noncore/net/mail/abstractmail.cpp +++ b/noncore/net/mail/abstractmail.cpp | |||
@@ -2,4 +2,5 @@ | |||
2 | #include "imapwrapper.h" | 2 | #include "imapwrapper.h" |
3 | #include "pop3wrapper.h" | 3 | #include "pop3wrapper.h" |
4 | #include "mailtypes.h" | ||
4 | 5 | ||
5 | #include <qstring.h> | 6 | #include <qstring.h> |
@@ -17,18 +18,31 @@ AbstractMail* AbstractMail::getWrapper(POP3account *a) | |||
17 | } | 18 | } |
18 | 19 | ||
19 | QString AbstractMail::decode_quoted_printable(const char*text) | 20 | encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc) |
20 | { | 21 | { |
22 | qDebug("Decode string start"); | ||
21 | char*result_text; | 23 | char*result_text; |
22 | size_t index = 0; | 24 | size_t index = 0; |
23 | QString result = ""; | ||
24 | /* reset for recursive use! */ | 25 | /* reset for recursive use! */ |
25 | size_t target_length = 0; | 26 | size_t target_length = 0; |
26 | result_text = 0; | 27 | result_text = 0; |
27 | int err = mailmime_quoted_printable_body_parse(text,strlen(text), | 28 | int mimetype = MAILMIME_MECHANISM_7BIT; |
28 | &index,&result_text,&target_length,0); | 29 | if (enc.lower()=="quoted-printable") { |
29 | if (result_text) { | 30 | mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE; |
30 | result = result_text; | 31 | } else if (enc.lower()=="base64") { |
31 | free(result_text); | 32 | mimetype = MAILMIME_MECHANISM_BASE64; |
33 | } else if (enc.lower()=="8bit") { | ||
34 | mimetype = MAILMIME_MECHANISM_8BIT; | ||
35 | } else if (enc.lower()=="binary") { | ||
36 | mimetype = MAILMIME_MECHANISM_BINARY; | ||
32 | } | 37 | } |
38 | |||
39 | int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype, | ||
40 | &result_text,&target_length); | ||
41 | |||
42 | encodedString* result = new encodedString(); | ||
43 | if (err == MAILIMF_NO_ERROR) { | ||
44 | result->setContent(result_text,target_length); | ||
45 | } | ||
46 | qDebug("Decode string finished"); | ||
33 | return result; | 47 | return result; |
34 | } | 48 | } |
diff --git a/noncore/net/mail/abstractmail.h b/noncore/net/mail/abstractmail.h index 4473ad2..f1a8468 100644 --- a/noncore/net/mail/abstractmail.h +++ b/noncore/net/mail/abstractmail.h | |||
@@ -11,4 +11,5 @@ class IMAPwrapper; | |||
11 | class POP3wrapper; | 11 | class POP3wrapper; |
12 | class Folder; | 12 | class Folder; |
13 | class encodedString; | ||
13 | 14 | ||
14 | class AbstractMail:public QObject | 15 | class AbstractMail:public QObject |
@@ -21,5 +22,8 @@ public: | |||
21 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0; | 22 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0; |
22 | virtual RecBody fetchBody(const RecMail&mail)=0; | 23 | virtual RecBody fetchBody(const RecMail&mail)=0; |
23 | virtual QString fetchPart(const RecMail&mail,const RecPart&part)=0; | 24 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0; |
25 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0; | ||
26 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0; | ||
27 | |||
24 | virtual void deleteMail(const RecMail&mail)=0; | 28 | virtual void deleteMail(const RecMail&mail)=0; |
25 | virtual void answeredMail(const RecMail&mail)=0; | 29 | virtual void answeredMail(const RecMail&mail)=0; |
@@ -27,5 +31,5 @@ public: | |||
27 | static AbstractMail* getWrapper(IMAPaccount *a); | 31 | static AbstractMail* getWrapper(IMAPaccount *a); |
28 | static AbstractMail* getWrapper(POP3account *a); | 32 | static AbstractMail* getWrapper(POP3account *a); |
29 | static QString decode_quoted_printable(const char*text); | 33 | static encodedString*decode_String(const encodedString*text,const QString&enc); |
30 | }; | 34 | }; |
31 | #endif | 35 | #endif |
diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp index a4e6228..d56d7f9 100644 --- a/noncore/net/mail/imapwrapper.cpp +++ b/noncore/net/mail/imapwrapper.cpp | |||
@@ -303,6 +303,7 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
303 | m->setMsgid(QString(head->env_message_id)); | 303 | m->setMsgid(QString(head->env_message_id)); |
304 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { | 304 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { |
305 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; | ||
306 | #if 0 | 305 | #if 0 |
306 | |||
307 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; | ||
307 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); | 308 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); |
308 | qDebug("%i %i %i - %i %i %i",d->dt_year,d->dt_month,d->dt_day,d->dt_hour,d->dt_min,d->dt_sec); | 309 | qDebug("%i %i %i - %i %i %i",d->dt_year,d->dt_month,d->dt_day,d->dt_hour,d->dt_min,d->dt_sec); |
@@ -392,8 +393,5 @@ void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mai | |||
392 | case MAILIMAP_BODY_TYPE_1PART_MSG: | 393 | case MAILIMAP_BODY_TYPE_1PART_MSG: |
393 | path.append(1); | 394 | path.append(1); |
394 | body_text = fetchPart(mail,path,true); | 395 | body_text = fetchTextPart(mail,path,true,singlePart.Encoding()); |
395 | if (singlePart.Encoding()=="quoted-printable") { | ||
396 | body_text = decode_quoted_printable(body_text.latin1()); | ||
397 | } | ||
398 | target_body.setBodytext(body_text); | 396 | target_body.setBodytext(body_text); |
399 | target_body.setDescription(singlePart); | 397 | target_body.setDescription(singlePart); |
@@ -402,8 +400,5 @@ void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mai | |||
402 | qDebug("Mediatype single: %s",mailDescription->bd_data.bd_type_text->bd_media_text); | 400 | qDebug("Mediatype single: %s",mailDescription->bd_data.bd_type_text->bd_media_text); |
403 | path.append(1); | 401 | path.append(1); |
404 | body_text = fetchPart(mail,path,true); | 402 | body_text = fetchTextPart(mail,path,true,singlePart.Encoding()); |
405 | if (singlePart.Encoding()=="quoted-printable") { | ||
406 | body_text = decode_quoted_printable(body_text.latin1()); | ||
407 | } | ||
408 | target_body.setBodytext(body_text); | 403 | target_body.setBodytext(body_text); |
409 | target_body.setDescription(singlePart); | 404 | target_body.setDescription(singlePart); |
@@ -462,7 +457,7 @@ QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | |||
462 | } | 457 | } |
463 | 458 | ||
464 | QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call,const QString&enc) | 459 | encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call) |
465 | { | 460 | { |
466 | QString body(""); | 461 | encodedString*res=new encodedString; |
467 | const char*mb; | 462 | const char*mb; |
468 | int err; | 463 | int err; |
@@ -473,5 +468,5 @@ QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,boo | |||
473 | login(); | 468 | login(); |
474 | if (!m_imap) { | 469 | if (!m_imap) { |
475 | return body; | 470 | return res; |
476 | } | 471 | } |
477 | if (!internal_call) { | 472 | if (!internal_call) { |
@@ -480,5 +475,5 @@ QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,boo | |||
480 | if ( err != MAILIMAP_NO_ERROR ) { | 475 | if ( err != MAILIMAP_NO_ERROR ) { |
481 | qDebug("error selecting mailbox: %s",m_imap->imap_response); | 476 | qDebug("error selecting mailbox: %s",m_imap->imap_response); |
482 | return body; | 477 | return res; |
483 | } | 478 | } |
484 | } | 479 | } |
@@ -512,24 +507,15 @@ QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,boo | |||
512 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { | 507 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { |
513 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; | 508 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; |
509 | /* detach - we take over the content */ | ||
514 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; | 510 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; |
515 | if (text) { | 511 | res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length); |
516 | if (enc=="quoted-printable") { | ||
517 | body = decode_quoted_printable(text); | ||
518 | } else { | ||
519 | body = QString(text); | ||
520 | } | ||
521 | free(text); | ||
522 | } else { | ||
523 | body = ""; | ||
524 | } | ||
525 | } | 512 | } |
526 | } | 513 | } |
527 | } | 514 | } |
528 | |||
529 | } else { | 515 | } else { |
530 | qDebug("error fetching text: %s",m_imap->imap_response); | 516 | qDebug("error fetching text: %s",m_imap->imap_response); |
531 | } | 517 | } |
532 | mailimap_fetch_list_free(result); | 518 | mailimap_fetch_list_free(result); |
533 | return body; | 519 | return res; |
534 | } | 520 | } |
535 | 521 | ||
@@ -558,5 +544,5 @@ void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mai | |||
558 | /* important: Check for is NULL 'cause a body can be empty! */ | 544 | /* important: Check for is NULL 'cause a body can be empty! */ |
559 | if (currentPart.Type()=="text" && target_body.Bodytext().isNull() ) { | 545 | if (currentPart.Type()=="text" && target_body.Bodytext().isNull() ) { |
560 | QString body_text = fetchPart(mail,clist,true,currentPart.Encoding()); | 546 | QString body_text = fetchTextPart(mail,clist,true,currentPart.Encoding()); |
561 | target_body.setDescription(currentPart); | 547 | target_body.setDescription(currentPart); |
562 | target_body.setBodytext(body_text); | 548 | target_body.setBodytext(body_text); |
@@ -714,9 +700,4 @@ void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which) | |||
714 | } | 700 | } |
715 | 701 | ||
716 | QString IMAPwrapper::fetchPart(const RecMail&mail,const RecPart&part) | ||
717 | { | ||
718 | return fetchPart(mail,part.Positionlist(),false,part.Encoding()); | ||
719 | } | ||
720 | |||
721 | void IMAPwrapper::deleteMail(const RecMail&mail) | 702 | void IMAPwrapper::deleteMail(const RecMail&mail) |
722 | { | 703 | { |
@@ -785,2 +766,35 @@ void IMAPwrapper::answeredMail(const RecMail&mail) | |||
785 | } | 766 | } |
786 | } | 767 | } |
768 | |||
769 | QString IMAPwrapper::fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call,const QString&enc) | ||
770 | { | ||
771 | QString body(""); | ||
772 | encodedString*res = fetchRawPart(mail,path,internal_call); | ||
773 | encodedString*r = decode_String(res,enc); | ||
774 | delete res; | ||
775 | if (r) { | ||
776 | if (r->Length()>0) { | ||
777 | body = r->Content(); | ||
778 | } | ||
779 | delete r; | ||
780 | } | ||
781 | return body; | ||
782 | } | ||
783 | |||
784 | QString IMAPwrapper::fetchTextPart(const RecMail&mail,const RecPart&part) | ||
785 | { | ||
786 | return fetchTextPart(mail,part.Positionlist(),false,part.Encoding()); | ||
787 | } | ||
788 | |||
789 | encodedString* IMAPwrapper::fetchDecodedPart(const RecMail&mail,const RecPart&part) | ||
790 | { | ||
791 | encodedString*res = fetchRawPart(mail,part.Positionlist(),false); | ||
792 | encodedString*r = decode_String(res,part.Encoding()); | ||
793 | delete res; | ||
794 | return r; | ||
795 | } | ||
796 | |||
797 | encodedString* IMAPwrapper::fetchRawPart(const RecMail&mail,const RecPart&part) | ||
798 | { | ||
799 | return fetchRawPart(mail,part.Positionlist(),false); | ||
800 | } | ||
diff --git a/noncore/net/mail/imapwrapper.h b/noncore/net/mail/imapwrapper.h index 768a517..aeebda8 100644 --- a/noncore/net/mail/imapwrapper.h +++ b/noncore/net/mail/imapwrapper.h | |||
@@ -14,4 +14,5 @@ struct mailimap_body_type_mpart; | |||
14 | struct mailimap_body_fields; | 14 | struct mailimap_body_fields; |
15 | struct mailimap_msg_att; | 15 | struct mailimap_msg_att; |
16 | class encodedString; | ||
16 | 17 | ||
17 | class IMAPwrapper : public AbstractMail | 18 | class IMAPwrapper : public AbstractMail |
@@ -23,9 +24,13 @@ public: | |||
23 | virtual QList<Folder>* listFolders(); | 24 | virtual QList<Folder>* listFolders(); |
24 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target ); | 25 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target ); |
25 | virtual RecBody fetchBody(const RecMail&mail); | 26 | |
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 | virtual RecBody fetchBody(const RecMail&mail); | ||
31 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); | ||
32 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); | ||
33 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); | ||
34 | |||
30 | static void imap_progress( size_t current, size_t maximum ); | 35 | static void imap_progress( size_t current, size_t maximum ); |
31 | 36 | ||
@@ -35,5 +40,6 @@ protected: | |||
35 | void logout(); | 40 | void logout(); |
36 | 41 | ||
37 | virtual QString fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); | 42 | virtual QString fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); |
43 | virtual encodedString*fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call); | ||
38 | 44 | ||
39 | void searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body); | 45 | void searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body); |
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.cpp b/noncore/net/mail/libmailwrapper/abstractmail.cpp index 0bb2525..92a46f1 100644 --- a/noncore/net/mail/libmailwrapper/abstractmail.cpp +++ b/noncore/net/mail/libmailwrapper/abstractmail.cpp | |||
@@ -2,4 +2,5 @@ | |||
2 | #include "imapwrapper.h" | 2 | #include "imapwrapper.h" |
3 | #include "pop3wrapper.h" | 3 | #include "pop3wrapper.h" |
4 | #include "mailtypes.h" | ||
4 | 5 | ||
5 | #include <qstring.h> | 6 | #include <qstring.h> |
@@ -17,18 +18,31 @@ AbstractMail* AbstractMail::getWrapper(POP3account *a) | |||
17 | } | 18 | } |
18 | 19 | ||
19 | QString AbstractMail::decode_quoted_printable(const char*text) | 20 | encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc) |
20 | { | 21 | { |
22 | qDebug("Decode string start"); | ||
21 | char*result_text; | 23 | char*result_text; |
22 | size_t index = 0; | 24 | size_t index = 0; |
23 | QString result = ""; | ||
24 | /* reset for recursive use! */ | 25 | /* reset for recursive use! */ |
25 | size_t target_length = 0; | 26 | size_t target_length = 0; |
26 | result_text = 0; | 27 | result_text = 0; |
27 | int err = mailmime_quoted_printable_body_parse(text,strlen(text), | 28 | int mimetype = MAILMIME_MECHANISM_7BIT; |
28 | &index,&result_text,&target_length,0); | 29 | if (enc.lower()=="quoted-printable") { |
29 | if (result_text) { | 30 | mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE; |
30 | result = result_text; | 31 | } else if (enc.lower()=="base64") { |
31 | free(result_text); | 32 | mimetype = MAILMIME_MECHANISM_BASE64; |
33 | } else if (enc.lower()=="8bit") { | ||
34 | mimetype = MAILMIME_MECHANISM_8BIT; | ||
35 | } else if (enc.lower()=="binary") { | ||
36 | mimetype = MAILMIME_MECHANISM_BINARY; | ||
32 | } | 37 | } |
38 | |||
39 | int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype, | ||
40 | &result_text,&target_length); | ||
41 | |||
42 | encodedString* result = new encodedString(); | ||
43 | if (err == MAILIMF_NO_ERROR) { | ||
44 | result->setContent(result_text,target_length); | ||
45 | } | ||
46 | qDebug("Decode string finished"); | ||
33 | return result; | 47 | return result; |
34 | } | 48 | } |
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h index 4473ad2..f1a8468 100644 --- a/noncore/net/mail/libmailwrapper/abstractmail.h +++ b/noncore/net/mail/libmailwrapper/abstractmail.h | |||
@@ -11,4 +11,5 @@ class IMAPwrapper; | |||
11 | class POP3wrapper; | 11 | class POP3wrapper; |
12 | class Folder; | 12 | class Folder; |
13 | class encodedString; | ||
13 | 14 | ||
14 | class AbstractMail:public QObject | 15 | class AbstractMail:public QObject |
@@ -21,5 +22,8 @@ public: | |||
21 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0; | 22 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0; |
22 | virtual RecBody fetchBody(const RecMail&mail)=0; | 23 | virtual RecBody fetchBody(const RecMail&mail)=0; |
23 | virtual QString fetchPart(const RecMail&mail,const RecPart&part)=0; | 24 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0; |
25 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0; | ||
26 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0; | ||
27 | |||
24 | virtual void deleteMail(const RecMail&mail)=0; | 28 | virtual void deleteMail(const RecMail&mail)=0; |
25 | virtual void answeredMail(const RecMail&mail)=0; | 29 | virtual void answeredMail(const RecMail&mail)=0; |
@@ -27,5 +31,5 @@ public: | |||
27 | static AbstractMail* getWrapper(IMAPaccount *a); | 31 | static AbstractMail* getWrapper(IMAPaccount *a); |
28 | static AbstractMail* getWrapper(POP3account *a); | 32 | static AbstractMail* getWrapper(POP3account *a); |
29 | static QString decode_quoted_printable(const char*text); | 33 | static encodedString*decode_String(const encodedString*text,const QString&enc); |
30 | }; | 34 | }; |
31 | #endif | 35 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index a4e6228..d56d7f9 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp | |||
@@ -303,6 +303,7 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
303 | m->setMsgid(QString(head->env_message_id)); | 303 | m->setMsgid(QString(head->env_message_id)); |
304 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { | 304 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { |
305 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; | ||
306 | #if 0 | 305 | #if 0 |
306 | |||
307 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; | ||
307 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); | 308 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); |
308 | qDebug("%i %i %i - %i %i %i",d->dt_year,d->dt_month,d->dt_day,d->dt_hour,d->dt_min,d->dt_sec); | 309 | qDebug("%i %i %i - %i %i %i",d->dt_year,d->dt_month,d->dt_day,d->dt_hour,d->dt_min,d->dt_sec); |
@@ -392,8 +393,5 @@ void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mai | |||
392 | case MAILIMAP_BODY_TYPE_1PART_MSG: | 393 | case MAILIMAP_BODY_TYPE_1PART_MSG: |
393 | path.append(1); | 394 | path.append(1); |
394 | body_text = fetchPart(mail,path,true); | 395 | body_text = fetchTextPart(mail,path,true,singlePart.Encoding()); |
395 | if (singlePart.Encoding()=="quoted-printable") { | ||
396 | body_text = decode_quoted_printable(body_text.latin1()); | ||
397 | } | ||
398 | target_body.setBodytext(body_text); | 396 | target_body.setBodytext(body_text); |
399 | target_body.setDescription(singlePart); | 397 | target_body.setDescription(singlePart); |
@@ -402,8 +400,5 @@ void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mai | |||
402 | qDebug("Mediatype single: %s",mailDescription->bd_data.bd_type_text->bd_media_text); | 400 | qDebug("Mediatype single: %s",mailDescription->bd_data.bd_type_text->bd_media_text); |
403 | path.append(1); | 401 | path.append(1); |
404 | body_text = fetchPart(mail,path,true); | 402 | body_text = fetchTextPart(mail,path,true,singlePart.Encoding()); |
405 | if (singlePart.Encoding()=="quoted-printable") { | ||
406 | body_text = decode_quoted_printable(body_text.latin1()); | ||
407 | } | ||
408 | target_body.setBodytext(body_text); | 403 | target_body.setBodytext(body_text); |
409 | target_body.setDescription(singlePart); | 404 | target_body.setDescription(singlePart); |
@@ -462,7 +457,7 @@ QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | |||
462 | } | 457 | } |
463 | 458 | ||
464 | QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call,const QString&enc) | 459 | encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call) |
465 | { | 460 | { |
466 | QString body(""); | 461 | encodedString*res=new encodedString; |
467 | const char*mb; | 462 | const char*mb; |
468 | int err; | 463 | int err; |
@@ -473,5 +468,5 @@ QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,boo | |||
473 | login(); | 468 | login(); |
474 | if (!m_imap) { | 469 | if (!m_imap) { |
475 | return body; | 470 | return res; |
476 | } | 471 | } |
477 | if (!internal_call) { | 472 | if (!internal_call) { |
@@ -480,5 +475,5 @@ QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,boo | |||
480 | if ( err != MAILIMAP_NO_ERROR ) { | 475 | if ( err != MAILIMAP_NO_ERROR ) { |
481 | qDebug("error selecting mailbox: %s",m_imap->imap_response); | 476 | qDebug("error selecting mailbox: %s",m_imap->imap_response); |
482 | return body; | 477 | return res; |
483 | } | 478 | } |
484 | } | 479 | } |
@@ -512,24 +507,15 @@ QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,boo | |||
512 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { | 507 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { |
513 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; | 508 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; |
509 | /* detach - we take over the content */ | ||
514 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; | 510 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; |
515 | if (text) { | 511 | res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length); |
516 | if (enc=="quoted-printable") { | ||
517 | body = decode_quoted_printable(text); | ||
518 | } else { | ||
519 | body = QString(text); | ||
520 | } | ||
521 | free(text); | ||
522 | } else { | ||
523 | body = ""; | ||
524 | } | ||
525 | } | 512 | } |
526 | } | 513 | } |
527 | } | 514 | } |
528 | |||
529 | } else { | 515 | } else { |
530 | qDebug("error fetching text: %s",m_imap->imap_response); | 516 | qDebug("error fetching text: %s",m_imap->imap_response); |
531 | } | 517 | } |
532 | mailimap_fetch_list_free(result); | 518 | mailimap_fetch_list_free(result); |
533 | return body; | 519 | return res; |
534 | } | 520 | } |
535 | 521 | ||
@@ -558,5 +544,5 @@ void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mai | |||
558 | /* important: Check for is NULL 'cause a body can be empty! */ | 544 | /* important: Check for is NULL 'cause a body can be empty! */ |
559 | if (currentPart.Type()=="text" && target_body.Bodytext().isNull() ) { | 545 | if (currentPart.Type()=="text" && target_body.Bodytext().isNull() ) { |
560 | QString body_text = fetchPart(mail,clist,true,currentPart.Encoding()); | 546 | QString body_text = fetchTextPart(mail,clist,true,currentPart.Encoding()); |
561 | target_body.setDescription(currentPart); | 547 | target_body.setDescription(currentPart); |
562 | target_body.setBodytext(body_text); | 548 | target_body.setBodytext(body_text); |
@@ -714,9 +700,4 @@ void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which) | |||
714 | } | 700 | } |
715 | 701 | ||
716 | QString IMAPwrapper::fetchPart(const RecMail&mail,const RecPart&part) | ||
717 | { | ||
718 | return fetchPart(mail,part.Positionlist(),false,part.Encoding()); | ||
719 | } | ||
720 | |||
721 | void IMAPwrapper::deleteMail(const RecMail&mail) | 702 | void IMAPwrapper::deleteMail(const RecMail&mail) |
722 | { | 703 | { |
@@ -785,2 +766,35 @@ void IMAPwrapper::answeredMail(const RecMail&mail) | |||
785 | } | 766 | } |
786 | } | 767 | } |
768 | |||
769 | QString IMAPwrapper::fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call,const QString&enc) | ||
770 | { | ||
771 | QString body(""); | ||
772 | encodedString*res = fetchRawPart(mail,path,internal_call); | ||
773 | encodedString*r = decode_String(res,enc); | ||
774 | delete res; | ||
775 | if (r) { | ||
776 | if (r->Length()>0) { | ||
777 | body = r->Content(); | ||
778 | } | ||
779 | delete r; | ||
780 | } | ||
781 | return body; | ||
782 | } | ||
783 | |||
784 | QString IMAPwrapper::fetchTextPart(const RecMail&mail,const RecPart&part) | ||
785 | { | ||
786 | return fetchTextPart(mail,part.Positionlist(),false,part.Encoding()); | ||
787 | } | ||
788 | |||
789 | encodedString* IMAPwrapper::fetchDecodedPart(const RecMail&mail,const RecPart&part) | ||
790 | { | ||
791 | encodedString*res = fetchRawPart(mail,part.Positionlist(),false); | ||
792 | encodedString*r = decode_String(res,part.Encoding()); | ||
793 | delete res; | ||
794 | return r; | ||
795 | } | ||
796 | |||
797 | encodedString* IMAPwrapper::fetchRawPart(const RecMail&mail,const RecPart&part) | ||
798 | { | ||
799 | return fetchRawPart(mail,part.Positionlist(),false); | ||
800 | } | ||
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h index 768a517..aeebda8 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.h +++ b/noncore/net/mail/libmailwrapper/imapwrapper.h | |||
@@ -14,4 +14,5 @@ struct mailimap_body_type_mpart; | |||
14 | struct mailimap_body_fields; | 14 | struct mailimap_body_fields; |
15 | struct mailimap_msg_att; | 15 | struct mailimap_msg_att; |
16 | class encodedString; | ||
16 | 17 | ||
17 | class IMAPwrapper : public AbstractMail | 18 | class IMAPwrapper : public AbstractMail |
@@ -23,9 +24,13 @@ public: | |||
23 | virtual QList<Folder>* listFolders(); | 24 | virtual QList<Folder>* listFolders(); |
24 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target ); | 25 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target ); |
25 | virtual RecBody fetchBody(const RecMail&mail); | 26 | |
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 | virtual RecBody fetchBody(const RecMail&mail); | ||
31 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); | ||
32 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); | ||
33 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); | ||
34 | |||
30 | static void imap_progress( size_t current, size_t maximum ); | 35 | static void imap_progress( size_t current, size_t maximum ); |
31 | 36 | ||
@@ -35,5 +40,6 @@ protected: | |||
35 | void logout(); | 40 | void logout(); |
36 | 41 | ||
37 | virtual QString fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); | 42 | virtual QString fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); |
43 | virtual encodedString*fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call); | ||
38 | 44 | ||
39 | void searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body); | 45 | void searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body); |
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.cpp b/noncore/net/mail/libmailwrapper/mailtypes.cpp index 8d9b247..d8a36e7 100644 --- a/noncore/net/mail/libmailwrapper/mailtypes.cpp +++ b/noncore/net/mail/libmailwrapper/mailtypes.cpp | |||
@@ -1,4 +1,4 @@ | |||
1 | #include "mailtypes.h" | 1 | #include "mailtypes.h" |
2 | 2 | #include <stdlib.h> | |
3 | 3 | ||
4 | RecMail::RecMail() | 4 | RecMail::RecMail() |
@@ -246,2 +246,90 @@ const RecPart& RecBody::Description()const | |||
246 | return m_description; | 246 | return m_description; |
247 | } | 247 | } |
248 | |||
249 | /* handling encoded content */ | ||
250 | encodedString::encodedString() | ||
251 | { | ||
252 | init(); | ||
253 | } | ||
254 | |||
255 | encodedString::encodedString(const char*nContent,unsigned int nSize) | ||
256 | { | ||
257 | init(); | ||
258 | setContent(nContent,nSize); | ||
259 | } | ||
260 | |||
261 | encodedString::encodedString(char*nContent,unsigned int nSize) | ||
262 | { | ||
263 | init(); | ||
264 | setContent(nContent,nSize); | ||
265 | } | ||
266 | |||
267 | encodedString::encodedString(const encodedString&old) | ||
268 | { | ||
269 | init(); | ||
270 | copy_old(old); | ||
271 | qDebug("encodedeString: copy constructor!"); | ||
272 | } | ||
273 | |||
274 | encodedString& encodedString::operator=(const encodedString&old) | ||
275 | { | ||
276 | init(); | ||
277 | copy_old(old); | ||
278 | qDebug("encodedString: assign operator!"); | ||
279 | return *this; | ||
280 | } | ||
281 | |||
282 | encodedString::~encodedString() | ||
283 | { | ||
284 | clean(); | ||
285 | } | ||
286 | |||
287 | void encodedString::init() | ||
288 | { | ||
289 | content = 0; | ||
290 | size = 0; | ||
291 | } | ||
292 | |||
293 | void encodedString::clean() | ||
294 | { | ||
295 | if (content) { | ||
296 | free(content); | ||
297 | } | ||
298 | content = 0; | ||
299 | size = 0; | ||
300 | } | ||
301 | |||
302 | void encodedString::copy_old(const encodedString&old) | ||
303 | { | ||
304 | clean(); | ||
305 | if (old.size>0 && old.content) { | ||
306 | content = (char*)malloc(old.size*sizeof(char)); | ||
307 | memcpy(content,old.content,size); | ||
308 | size = old.size; | ||
309 | } | ||
310 | } | ||
311 | |||
312 | const char*encodedString::Content()const | ||
313 | { | ||
314 | return content; | ||
315 | } | ||
316 | |||
317 | const int encodedString::Length()const | ||
318 | { | ||
319 | return size; | ||
320 | } | ||
321 | |||
322 | void encodedString::setContent(const char*nContent,int nSize) | ||
323 | { | ||
324 | if (nSize>0 && nContent) { | ||
325 | content = (char*)malloc(nSize*sizeof(char)); | ||
326 | memcpy(content,nContent,nSize); | ||
327 | size = nSize; | ||
328 | } | ||
329 | } | ||
330 | |||
331 | void encodedString::setContent(char*nContent,int nSize) | ||
332 | { | ||
333 | content = nContent; | ||
334 | size = nSize; | ||
335 | } | ||
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.h b/noncore/net/mail/libmailwrapper/mailtypes.h index 7d7bebc..abfbe65 100644 --- a/noncore/net/mail/libmailwrapper/mailtypes.h +++ b/noncore/net/mail/libmailwrapper/mailtypes.h | |||
@@ -136,3 +136,50 @@ public: | |||
136 | }; | 136 | }; |
137 | 137 | ||
138 | class encodedString | ||
139 | { | ||
140 | public: | ||
141 | encodedString(); | ||
142 | /* | ||
143 | creates an new content string. | ||
144 | it makes a deep copy of it! | ||
145 | */ | ||
146 | encodedString(const char*nContent,unsigned int length); | ||
147 | /* | ||
148 | Take over the nContent. Means: it will just copy the pointer, not the content. | ||
149 | so make sure: No one else frees the string, the string has allocated with | ||
150 | malloc for compatibility with c-based libs | ||
151 | */ | ||
152 | encodedString(char*nContent,unsigned int nSize); | ||
153 | /* copy construkor - makes ALWAYS a deep copy!!!! */ | ||
154 | encodedString(const encodedString&old); | ||
155 | /* assign operator - makes ALWAYS a deep copy!!!! */ | ||
156 | encodedString& operator=(const encodedString&old); | ||
157 | /* destructor - cleans the content */ | ||
158 | virtual ~encodedString(); | ||
159 | |||
160 | /* returns a pointer to the content - do not delete yoursel! */ | ||
161 | const char*Content()const; | ||
162 | /* returns the lengths of the content 'cause it must not be a null-terminated string! */ | ||
163 | const int Length()const; | ||
164 | |||
165 | /* | ||
166 | makes a deep copy of nContent! | ||
167 | */ | ||
168 | void setContent(const char*nContent,int nSize); | ||
169 | /* | ||
170 | Take over the nContent. Means: it will just copy the pointer, not the content. | ||
171 | so make sure: No one else frees the string, the string has allocated with | ||
172 | malloc for compatibility with c-based libs | ||
173 | */ | ||
174 | void setContent(char*nContent,int nSize); | ||
175 | |||
176 | protected: | ||
177 | char * content; | ||
178 | unsigned int size; | ||
179 | |||
180 | void init(); | ||
181 | void copy_old(const encodedString&old); | ||
182 | void clean(); | ||
183 | }; | ||
184 | |||
138 | #endif | 185 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp index a33a16b..075d8c7 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp | |||
@@ -329,5 +329,5 @@ QList<Folder>* POP3wrapper::listFolders() | |||
329 | } | 329 | } |
330 | 330 | ||
331 | QString POP3wrapper::fetchPart(const RecMail&,const RecPart&) | 331 | QString POP3wrapper::fetchTextPart(const RecMail&,const RecPart&) |
332 | { | 332 | { |
333 | return ""; | 333 | return ""; |
@@ -348,2 +348,11 @@ void POP3wrapper::answeredMail(const RecMail&) | |||
348 | } | 348 | } |
349 | 349 | ||
350 | encodedString* POP3wrapper::fetchDecodedPart(const RecMail&,const RecPart&) | ||
351 | { | ||
352 | return new encodedString(); | ||
353 | } | ||
354 | |||
355 | encodedString* POP3wrapper::fetchRawPart(const RecMail&,const RecPart&) | ||
356 | { | ||
357 | return new encodedString(); | ||
358 | } | ||
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h index 6ff8d62..8d3adda 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.h +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h | |||
@@ -7,4 +7,5 @@ | |||
7 | class RecMail; | 7 | class RecMail; |
8 | class RecBody; | 8 | class RecBody; |
9 | class encodedString; | ||
9 | struct mailpop3; | 10 | struct mailpop3; |
10 | 11 | ||
@@ -19,5 +20,8 @@ public: | |||
19 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); | 20 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); |
20 | virtual QList<Folder>* listFolders(); | 21 | virtual QList<Folder>* listFolders(); |
21 | virtual QString fetchPart(const RecMail&mail,const RecPart&part); | 22 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); |
23 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); | ||
24 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); | ||
25 | |||
22 | virtual void deleteMail(const RecMail&mail); | 26 | virtual void deleteMail(const RecMail&mail); |
23 | virtual void answeredMail(const RecMail&mail); | 27 | virtual void answeredMail(const RecMail&mail); |
diff --git a/noncore/net/mail/mailtypes.cpp b/noncore/net/mail/mailtypes.cpp index 8d9b247..d8a36e7 100644 --- a/noncore/net/mail/mailtypes.cpp +++ b/noncore/net/mail/mailtypes.cpp | |||
@@ -1,4 +1,4 @@ | |||
1 | #include "mailtypes.h" | 1 | #include "mailtypes.h" |
2 | 2 | #include <stdlib.h> | |
3 | 3 | ||
4 | RecMail::RecMail() | 4 | RecMail::RecMail() |
@@ -246,2 +246,90 @@ const RecPart& RecBody::Description()const | |||
246 | return m_description; | 246 | return m_description; |
247 | } | 247 | } |
248 | |||
249 | /* handling encoded content */ | ||
250 | encodedString::encodedString() | ||
251 | { | ||
252 | init(); | ||
253 | } | ||
254 | |||
255 | encodedString::encodedString(const char*nContent,unsigned int nSize) | ||
256 | { | ||
257 | init(); | ||
258 | setContent(nContent,nSize); | ||
259 | } | ||
260 | |||
261 | encodedString::encodedString(char*nContent,unsigned int nSize) | ||
262 | { | ||
263 | init(); | ||
264 | setContent(nContent,nSize); | ||
265 | } | ||
266 | |||
267 | encodedString::encodedString(const encodedString&old) | ||
268 | { | ||
269 | init(); | ||
270 | copy_old(old); | ||
271 | qDebug("encodedeString: copy constructor!"); | ||
272 | } | ||
273 | |||
274 | encodedString& encodedString::operator=(const encodedString&old) | ||
275 | { | ||
276 | init(); | ||
277 | copy_old(old); | ||
278 | qDebug("encodedString: assign operator!"); | ||
279 | return *this; | ||
280 | } | ||
281 | |||
282 | encodedString::~encodedString() | ||
283 | { | ||
284 | clean(); | ||
285 | } | ||
286 | |||
287 | void encodedString::init() | ||
288 | { | ||
289 | content = 0; | ||
290 | size = 0; | ||
291 | } | ||
292 | |||
293 | void encodedString::clean() | ||
294 | { | ||
295 | if (content) { | ||
296 | free(content); | ||
297 | } | ||
298 | content = 0; | ||
299 | size = 0; | ||
300 | } | ||
301 | |||
302 | void encodedString::copy_old(const encodedString&old) | ||
303 | { | ||
304 | clean(); | ||
305 | if (old.size>0 && old.content) { | ||
306 | content = (char*)malloc(old.size*sizeof(char)); | ||
307 | memcpy(content,old.content,size); | ||
308 | size = old.size; | ||
309 | } | ||
310 | } | ||
311 | |||
312 | const char*encodedString::Content()const | ||
313 | { | ||
314 | return content; | ||
315 | } | ||
316 | |||
317 | const int encodedString::Length()const | ||
318 | { | ||
319 | return size; | ||
320 | } | ||
321 | |||
322 | void encodedString::setContent(const char*nContent,int nSize) | ||
323 | { | ||
324 | if (nSize>0 && nContent) { | ||
325 | content = (char*)malloc(nSize*sizeof(char)); | ||
326 | memcpy(content,nContent,nSize); | ||
327 | size = nSize; | ||
328 | } | ||
329 | } | ||
330 | |||
331 | void encodedString::setContent(char*nContent,int nSize) | ||
332 | { | ||
333 | content = nContent; | ||
334 | size = nSize; | ||
335 | } | ||
diff --git a/noncore/net/mail/mailtypes.h b/noncore/net/mail/mailtypes.h index 7d7bebc..abfbe65 100644 --- a/noncore/net/mail/mailtypes.h +++ b/noncore/net/mail/mailtypes.h | |||
@@ -136,3 +136,50 @@ public: | |||
136 | }; | 136 | }; |
137 | 137 | ||
138 | class encodedString | ||
139 | { | ||
140 | public: | ||
141 | encodedString(); | ||
142 | /* | ||
143 | creates an new content string. | ||
144 | it makes a deep copy of it! | ||
145 | */ | ||
146 | encodedString(const char*nContent,unsigned int length); | ||
147 | /* | ||
148 | Take over the nContent. Means: it will just copy the pointer, not the content. | ||
149 | so make sure: No one else frees the string, the string has allocated with | ||
150 | malloc for compatibility with c-based libs | ||
151 | */ | ||
152 | encodedString(char*nContent,unsigned int nSize); | ||
153 | /* copy construkor - makes ALWAYS a deep copy!!!! */ | ||
154 | encodedString(const encodedString&old); | ||
155 | /* assign operator - makes ALWAYS a deep copy!!!! */ | ||
156 | encodedString& operator=(const encodedString&old); | ||
157 | /* destructor - cleans the content */ | ||
158 | virtual ~encodedString(); | ||
159 | |||
160 | /* returns a pointer to the content - do not delete yoursel! */ | ||
161 | const char*Content()const; | ||
162 | /* returns the lengths of the content 'cause it must not be a null-terminated string! */ | ||
163 | const int Length()const; | ||
164 | |||
165 | /* | ||
166 | makes a deep copy of nContent! | ||
167 | */ | ||
168 | void setContent(const char*nContent,int nSize); | ||
169 | /* | ||
170 | Take over the nContent. Means: it will just copy the pointer, not the content. | ||
171 | so make sure: No one else frees the string, the string has allocated with | ||
172 | malloc for compatibility with c-based libs | ||
173 | */ | ||
174 | void setContent(char*nContent,int nSize); | ||
175 | |||
176 | protected: | ||
177 | char * content; | ||
178 | unsigned int size; | ||
179 | |||
180 | void init(); | ||
181 | void copy_old(const encodedString&old); | ||
182 | void clean(); | ||
183 | }; | ||
184 | |||
138 | #endif | 185 | #endif |
diff --git a/noncore/net/mail/pop3wrapper.cpp b/noncore/net/mail/pop3wrapper.cpp index a33a16b..075d8c7 100644 --- a/noncore/net/mail/pop3wrapper.cpp +++ b/noncore/net/mail/pop3wrapper.cpp | |||
@@ -329,5 +329,5 @@ QList<Folder>* POP3wrapper::listFolders() | |||
329 | } | 329 | } |
330 | 330 | ||
331 | QString POP3wrapper::fetchPart(const RecMail&,const RecPart&) | 331 | QString POP3wrapper::fetchTextPart(const RecMail&,const RecPart&) |
332 | { | 332 | { |
333 | return ""; | 333 | return ""; |
@@ -348,2 +348,11 @@ void POP3wrapper::answeredMail(const RecMail&) | |||
348 | } | 348 | } |
349 | 349 | ||
350 | encodedString* POP3wrapper::fetchDecodedPart(const RecMail&,const RecPart&) | ||
351 | { | ||
352 | return new encodedString(); | ||
353 | } | ||
354 | |||
355 | encodedString* POP3wrapper::fetchRawPart(const RecMail&,const RecPart&) | ||
356 | { | ||
357 | return new encodedString(); | ||
358 | } | ||
diff --git a/noncore/net/mail/pop3wrapper.h b/noncore/net/mail/pop3wrapper.h index 6ff8d62..8d3adda 100644 --- a/noncore/net/mail/pop3wrapper.h +++ b/noncore/net/mail/pop3wrapper.h | |||
@@ -7,4 +7,5 @@ | |||
7 | class RecMail; | 7 | class RecMail; |
8 | class RecBody; | 8 | class RecBody; |
9 | class encodedString; | ||
9 | struct mailpop3; | 10 | struct mailpop3; |
10 | 11 | ||
@@ -19,5 +20,8 @@ public: | |||
19 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); | 20 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); |
20 | virtual QList<Folder>* listFolders(); | 21 | virtual QList<Folder>* listFolders(); |
21 | virtual QString fetchPart(const RecMail&mail,const RecPart&part); | 22 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); |
23 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); | ||
24 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); | ||
25 | |||
22 | virtual void deleteMail(const RecMail&mail); | 26 | virtual void deleteMail(const RecMail&mail); |
23 | virtual void answeredMail(const RecMail&mail); | 27 | virtual void answeredMail(const RecMail&mail); |
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp index 48b71eb..0947879 100644 --- a/noncore/net/mail/viewmail.cpp +++ b/noncore/net/mail/viewmail.cpp | |||
@@ -4,4 +4,5 @@ | |||
4 | #include <qaction.h> | 4 | #include <qaction.h> |
5 | #include <qpopupmenu.h> | 5 | #include <qpopupmenu.h> |
6 | #include <qfile.h> | ||
6 | #include <qapplication.h> | 7 | #include <qapplication.h> |
7 | 8 | ||
@@ -13,4 +14,5 @@ | |||
13 | #include "abstractmail.h" | 14 | #include "abstractmail.h" |
14 | #include "accountview.h" | 15 | #include "accountview.h" |
16 | #include "mailtypes.h" | ||
15 | 17 | ||
16 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, | 18 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, |
@@ -135,5 +137,12 @@ void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int | |||
135 | 137 | ||
136 | if( !str.isEmpty() ) { | 138 | if( !str.isEmpty() ) { |
137 | qDebug( "first we will need a MIME wrapper" ); | 139 | encodedString*content = m_recMail.Wrapper()->fetchDecodedPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); |
140 | if (content) { | ||
141 | QFile output(str); | ||
142 | output.open(IO_WriteOnly); | ||
143 | output.writeBlock(content->Content(),content->Length()); | ||
144 | output.close(); | ||
145 | delete content; | ||
146 | } | ||
138 | } | 147 | } |
139 | } | 148 | } |
@@ -145,5 +154,5 @@ void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int | |||
145 | } else { | 154 | } else { |
146 | if ( m_recMail.Wrapper() != 0l ) { // make sure that there is a wrapper , even after delete or simular actions | 155 | if ( m_recMail.Wrapper() != 0l ) { // make sure that there is a wrapper , even after delete or simular actions |
147 | browser->setText( m_recMail.Wrapper()->fetchPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); | 156 | browser->setText( m_recMail.Wrapper()->fetchTextPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); |
148 | } | 157 | } |
149 | } | 158 | } |