summaryrefslogtreecommitdiff
path: root/noncore
authoralwin <alwin>2003-12-16 13:14:05 (UTC)
committer alwin <alwin>2003-12-16 13:14:05 (UTC)
commit49c02bbbb7a0aeee933d58ba1d3d3e86e6bc7838 (patch) (side-by-side diff)
tree710393582789ed1db97592fed5bb88ad4d56550d /noncore
parentf42c15f884d4377bc99d73e16fa1722b0fb2a4d3 (diff)
downloadopie-49c02bbbb7a0aeee933d58ba1d3d3e86e6bc7838.zip
opie-49c02bbbb7a0aeee933d58ba1d3d3e86e6bc7838.tar.gz
opie-49c02bbbb7a0aeee933d58ba1d3d3e86e6bc7838.tar.bz2
saving of attachments implemented.
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/abstractmail.cpp28
-rw-r--r--noncore/net/mail/abstractmail.h8
-rw-r--r--noncore/net/mail/imapwrapper.cpp78
-rw-r--r--noncore/net/mail/imapwrapper.h12
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.cpp28
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.h8
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp78
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.h12
-rw-r--r--noncore/net/mail/libmailwrapper/mailtypes.cpp90
-rw-r--r--noncore/net/mail/libmailwrapper/mailtypes.h47
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.cpp11
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.h6
-rw-r--r--noncore/net/mail/mailtypes.cpp90
-rw-r--r--noncore/net/mail/mailtypes.h47
-rw-r--r--noncore/net/mail/pop3wrapper.cpp11
-rw-r--r--noncore/net/mail/pop3wrapper.h6
-rw-r--r--noncore/net/mail/viewmail.cpp13
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
@@ -3,2 +3,3 @@
#include "pop3wrapper.h"
+#include "mailtypes.h"
@@ -18,7 +19,7 @@ AbstractMail* AbstractMail::getWrapper(POP3account *a)
-QString AbstractMail::decode_quoted_printable(const char*text)
+encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc)
{
+ qDebug("Decode string start");
char*result_text;
size_t index = 0;
- QString result = "";
/* reset for recursive use! */
@@ -26,8 +27,21 @@ QString AbstractMail::decode_quoted_printable(const char*text)
result_text = 0;
- int err = mailmime_quoted_printable_body_parse(text,strlen(text),
- &index,&result_text,&target_length,0);
- if (result_text) {
- result = result_text;
- free(result_text);
+ int mimetype = MAILMIME_MECHANISM_7BIT;
+ if (enc.lower()=="quoted-printable") {
+ mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE;
+ } else if (enc.lower()=="base64") {
+ mimetype = MAILMIME_MECHANISM_BASE64;
+ } else if (enc.lower()=="8bit") {
+ mimetype = MAILMIME_MECHANISM_8BIT;
+ } else if (enc.lower()=="binary") {
+ mimetype = MAILMIME_MECHANISM_BINARY;
}
+
+ int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype,
+ &result_text,&target_length);
+
+ encodedString* result = new encodedString();
+ if (err == MAILIMF_NO_ERROR) {
+ result->setContent(result_text,target_length);
+ }
+ qDebug("Decode string finished");
return result;
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
@@ -12,2 +12,3 @@ class POP3wrapper;
class Folder;
+class encodedString;
@@ -22,3 +23,6 @@ public:
virtual RecBody fetchBody(const RecMail&mail)=0;
- virtual QString fetchPart(const RecMail&mail,const RecPart&part)=0;
+ virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0;
+ virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0;
+ virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0;
+
virtual void deleteMail(const RecMail&mail)=0;
@@ -28,3 +32,3 @@ public:
static AbstractMail* getWrapper(POP3account *a);
- static QString decode_quoted_printable(const char*text);
+ static encodedString*decode_String(const encodedString*text,const QString&enc);
};
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
@@ -304,4 +304,5 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
} else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) {
- mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date;
#if 0
+
+ mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date;
QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec));
@@ -393,6 +394,3 @@ void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mai
path.append(1);
- body_text = fetchPart(mail,path,true);
- if (singlePart.Encoding()=="quoted-printable") {
- body_text = decode_quoted_printable(body_text.latin1());
- }
+ body_text = fetchTextPart(mail,path,true,singlePart.Encoding());
target_body.setBodytext(body_text);
@@ -403,6 +401,3 @@ void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mai
path.append(1);
- body_text = fetchPart(mail,path,true);
- if (singlePart.Encoding()=="quoted-printable") {
- body_text = decode_quoted_printable(body_text.latin1());
- }
+ body_text = fetchTextPart(mail,path,true,singlePart.Encoding());
target_body.setBodytext(body_text);
@@ -463,5 +458,5 @@ QStringList IMAPwrapper::address_list_to_stringlist(clist*list)
-QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call,const QString&enc)
+encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call)
{
- QString body("");
+ encodedString*res=new encodedString;
const char*mb;
@@ -474,3 +469,3 @@ QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,boo
if (!m_imap) {
- return body;
+ return res;
}
@@ -481,3 +476,3 @@ QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,boo
qDebug("error selecting mailbox: %s",m_imap->imap_response);
- return body;
+ return res;
}
@@ -513,17 +508,8 @@ QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,boo
char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part;
+ /* detach - we take over the content */
msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L;
- if (text) {
- if (enc=="quoted-printable") {
- body = decode_quoted_printable(text);
- } else {
- body = QString(text);
- }
- free(text);
- } else {
- body = "";
- }
+ res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length);
}
}
- }
-
+ }
} else {
@@ -532,3 +518,3 @@ QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,boo
mailimap_fetch_list_free(result);
- return body;
+ return res;
}
@@ -559,3 +545,3 @@ void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mai
if (currentPart.Type()=="text" && target_body.Bodytext().isNull() ) {
- QString body_text = fetchPart(mail,clist,true,currentPart.Encoding());
+ QString body_text = fetchTextPart(mail,clist,true,currentPart.Encoding());
target_body.setDescription(currentPart);
@@ -715,7 +701,2 @@ void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which)
-QString IMAPwrapper::fetchPart(const RecMail&mail,const RecPart&part)
-{
- return fetchPart(mail,part.Positionlist(),false,part.Encoding());
-}
-
void IMAPwrapper::deleteMail(const RecMail&mail)
@@ -786 +767,34 @@ void IMAPwrapper::answeredMail(const RecMail&mail)
}
+
+QString IMAPwrapper::fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call,const QString&enc)
+{
+ QString body("");
+ encodedString*res = fetchRawPart(mail,path,internal_call);
+ encodedString*r = decode_String(res,enc);
+ delete res;
+ if (r) {
+ if (r->Length()>0) {
+ body = r->Content();
+ }
+ delete r;
+ }
+ return body;
+}
+
+QString IMAPwrapper::fetchTextPart(const RecMail&mail,const RecPart&part)
+{
+ return fetchTextPart(mail,part.Positionlist(),false,part.Encoding());
+}
+
+encodedString* IMAPwrapper::fetchDecodedPart(const RecMail&mail,const RecPart&part)
+{
+ encodedString*res = fetchRawPart(mail,part.Positionlist(),false);
+ encodedString*r = decode_String(res,part.Encoding());
+ delete res;
+ return r;
+}
+
+encodedString* IMAPwrapper::fetchRawPart(const RecMail&mail,const RecPart&part)
+{
+ return fetchRawPart(mail,part.Positionlist(),false);
+}
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
@@ -15,2 +15,3 @@ struct mailimap_body_fields;
struct mailimap_msg_att;
+class encodedString;
@@ -24,4 +25,3 @@ public:
virtual void listMessages(const QString & mailbox,QList<RecMail>&target );
- virtual RecBody fetchBody(const RecMail&mail);
- virtual QString fetchPart(const RecMail&mail,const RecPart&part);
+
virtual void deleteMail(const RecMail&mail);
@@ -29,2 +29,7 @@ public:
+ virtual RecBody fetchBody(const RecMail&mail);
+ virtual QString fetchTextPart(const RecMail&mail,const RecPart&part);
+ virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part);
+ virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part);
+
static void imap_progress( size_t current, size_t maximum );
@@ -36,3 +41,4 @@ protected:
- virtual QString fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc="");
+ virtual QString fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc="");
+ virtual encodedString*fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call);
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
@@ -3,2 +3,3 @@
#include "pop3wrapper.h"
+#include "mailtypes.h"
@@ -18,7 +19,7 @@ AbstractMail* AbstractMail::getWrapper(POP3account *a)
-QString AbstractMail::decode_quoted_printable(const char*text)
+encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc)
{
+ qDebug("Decode string start");
char*result_text;
size_t index = 0;
- QString result = "";
/* reset for recursive use! */
@@ -26,8 +27,21 @@ QString AbstractMail::decode_quoted_printable(const char*text)
result_text = 0;
- int err = mailmime_quoted_printable_body_parse(text,strlen(text),
- &index,&result_text,&target_length,0);
- if (result_text) {
- result = result_text;
- free(result_text);
+ int mimetype = MAILMIME_MECHANISM_7BIT;
+ if (enc.lower()=="quoted-printable") {
+ mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE;
+ } else if (enc.lower()=="base64") {
+ mimetype = MAILMIME_MECHANISM_BASE64;
+ } else if (enc.lower()=="8bit") {
+ mimetype = MAILMIME_MECHANISM_8BIT;
+ } else if (enc.lower()=="binary") {
+ mimetype = MAILMIME_MECHANISM_BINARY;
}
+
+ int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype,
+ &result_text,&target_length);
+
+ encodedString* result = new encodedString();
+ if (err == MAILIMF_NO_ERROR) {
+ result->setContent(result_text,target_length);
+ }
+ qDebug("Decode string finished");
return result;
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
@@ -12,2 +12,3 @@ class POP3wrapper;
class Folder;
+class encodedString;
@@ -22,3 +23,6 @@ public:
virtual RecBody fetchBody(const RecMail&mail)=0;
- virtual QString fetchPart(const RecMail&mail,const RecPart&part)=0;
+ virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0;
+ virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0;
+ virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0;
+
virtual void deleteMail(const RecMail&mail)=0;
@@ -28,3 +32,3 @@ public:
static AbstractMail* getWrapper(POP3account *a);
- static QString decode_quoted_printable(const char*text);
+ static encodedString*decode_String(const encodedString*text,const QString&enc);
};
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
@@ -304,4 +304,5 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
} else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) {
- mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date;
#if 0
+
+ mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date;
QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec));
@@ -393,6 +394,3 @@ void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mai
path.append(1);
- body_text = fetchPart(mail,path,true);
- if (singlePart.Encoding()=="quoted-printable") {
- body_text = decode_quoted_printable(body_text.latin1());
- }
+ body_text = fetchTextPart(mail,path,true,singlePart.Encoding());
target_body.setBodytext(body_text);
@@ -403,6 +401,3 @@ void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mai
path.append(1);
- body_text = fetchPart(mail,path,true);
- if (singlePart.Encoding()=="quoted-printable") {
- body_text = decode_quoted_printable(body_text.latin1());
- }
+ body_text = fetchTextPart(mail,path,true,singlePart.Encoding());
target_body.setBodytext(body_text);
@@ -463,5 +458,5 @@ QStringList IMAPwrapper::address_list_to_stringlist(clist*list)
-QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call,const QString&enc)
+encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call)
{
- QString body("");
+ encodedString*res=new encodedString;
const char*mb;
@@ -474,3 +469,3 @@ QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,boo
if (!m_imap) {
- return body;
+ return res;
}
@@ -481,3 +476,3 @@ QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,boo
qDebug("error selecting mailbox: %s",m_imap->imap_response);
- return body;
+ return res;
}
@@ -513,17 +508,8 @@ QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,boo
char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part;
+ /* detach - we take over the content */
msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L;
- if (text) {
- if (enc=="quoted-printable") {
- body = decode_quoted_printable(text);
- } else {
- body = QString(text);
- }
- free(text);
- } else {
- body = "";
- }
+ res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length);
}
}
- }
-
+ }
} else {
@@ -532,3 +518,3 @@ QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,boo
mailimap_fetch_list_free(result);
- return body;
+ return res;
}
@@ -559,3 +545,3 @@ void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mai
if (currentPart.Type()=="text" && target_body.Bodytext().isNull() ) {
- QString body_text = fetchPart(mail,clist,true,currentPart.Encoding());
+ QString body_text = fetchTextPart(mail,clist,true,currentPart.Encoding());
target_body.setDescription(currentPart);
@@ -715,7 +701,2 @@ void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which)
-QString IMAPwrapper::fetchPart(const RecMail&mail,const RecPart&part)
-{
- return fetchPart(mail,part.Positionlist(),false,part.Encoding());
-}
-
void IMAPwrapper::deleteMail(const RecMail&mail)
@@ -786 +767,34 @@ void IMAPwrapper::answeredMail(const RecMail&mail)
}
+
+QString IMAPwrapper::fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call,const QString&enc)
+{
+ QString body("");
+ encodedString*res = fetchRawPart(mail,path,internal_call);
+ encodedString*r = decode_String(res,enc);
+ delete res;
+ if (r) {
+ if (r->Length()>0) {
+ body = r->Content();
+ }
+ delete r;
+ }
+ return body;
+}
+
+QString IMAPwrapper::fetchTextPart(const RecMail&mail,const RecPart&part)
+{
+ return fetchTextPart(mail,part.Positionlist(),false,part.Encoding());
+}
+
+encodedString* IMAPwrapper::fetchDecodedPart(const RecMail&mail,const RecPart&part)
+{
+ encodedString*res = fetchRawPart(mail,part.Positionlist(),false);
+ encodedString*r = decode_String(res,part.Encoding());
+ delete res;
+ return r;
+}
+
+encodedString* IMAPwrapper::fetchRawPart(const RecMail&mail,const RecPart&part)
+{
+ return fetchRawPart(mail,part.Positionlist(),false);
+}
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
@@ -15,2 +15,3 @@ struct mailimap_body_fields;
struct mailimap_msg_att;
+class encodedString;
@@ -24,4 +25,3 @@ public:
virtual void listMessages(const QString & mailbox,QList<RecMail>&target );
- virtual RecBody fetchBody(const RecMail&mail);
- virtual QString fetchPart(const RecMail&mail,const RecPart&part);
+
virtual void deleteMail(const RecMail&mail);
@@ -29,2 +29,7 @@ public:
+ virtual RecBody fetchBody(const RecMail&mail);
+ virtual QString fetchTextPart(const RecMail&mail,const RecPart&part);
+ virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part);
+ virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part);
+
static void imap_progress( size_t current, size_t maximum );
@@ -36,3 +41,4 @@ protected:
- virtual QString fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc="");
+ virtual QString fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc="");
+ virtual encodedString*fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call);
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,3 +1,3 @@
#include "mailtypes.h"
-
+#include <stdlib.h>
@@ -247 +247,89 @@ const RecPart& RecBody::Description()const
}
+
+/* handling encoded content */
+encodedString::encodedString()
+{
+ init();
+}
+
+encodedString::encodedString(const char*nContent,unsigned int nSize)
+{
+ init();
+ setContent(nContent,nSize);
+}
+
+encodedString::encodedString(char*nContent,unsigned int nSize)
+{
+ init();
+ setContent(nContent,nSize);
+}
+
+encodedString::encodedString(const encodedString&old)
+{
+ init();
+ copy_old(old);
+ qDebug("encodedeString: copy constructor!");
+}
+
+encodedString& encodedString::operator=(const encodedString&old)
+{
+ init();
+ copy_old(old);
+ qDebug("encodedString: assign operator!");
+ return *this;
+}
+
+encodedString::~encodedString()
+{
+ clean();
+}
+
+void encodedString::init()
+{
+ content = 0;
+ size = 0;
+}
+
+void encodedString::clean()
+{
+ if (content) {
+ free(content);
+ }
+ content = 0;
+ size = 0;
+}
+
+void encodedString::copy_old(const encodedString&old)
+{
+ clean();
+ if (old.size>0 && old.content) {
+ content = (char*)malloc(old.size*sizeof(char));
+ memcpy(content,old.content,size);
+ size = old.size;
+ }
+}
+
+const char*encodedString::Content()const
+{
+ return content;
+}
+
+const int encodedString::Length()const
+{
+ return size;
+}
+
+void encodedString::setContent(const char*nContent,int nSize)
+{
+ if (nSize>0 && nContent) {
+ content = (char*)malloc(nSize*sizeof(char));
+ memcpy(content,nContent,nSize);
+ size = nSize;
+ }
+}
+
+void encodedString::setContent(char*nContent,int nSize)
+{
+ content = nContent;
+ size = nSize;
+}
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
@@ -137,2 +137,49 @@ public:
+class encodedString
+{
+public:
+ encodedString();
+ /*
+ creates an new content string.
+ it makes a deep copy of it!
+ */
+ encodedString(const char*nContent,unsigned int length);
+ /*
+ Take over the nContent. Means: it will just copy the pointer, not the content.
+ so make sure: No one else frees the string, the string has allocated with
+ malloc for compatibility with c-based libs
+ */
+ encodedString(char*nContent,unsigned int nSize);
+ /* copy construkor - makes ALWAYS a deep copy!!!! */
+ encodedString(const encodedString&old);
+ /* assign operator - makes ALWAYS a deep copy!!!! */
+ encodedString& operator=(const encodedString&old);
+ /* destructor - cleans the content */
+ virtual ~encodedString();
+
+ /* returns a pointer to the content - do not delete yoursel! */
+ const char*Content()const;
+ /* returns the lengths of the content 'cause it must not be a null-terminated string! */
+ const int Length()const;
+
+ /*
+ makes a deep copy of nContent!
+ */
+ void setContent(const char*nContent,int nSize);
+ /*
+ Take over the nContent. Means: it will just copy the pointer, not the content.
+ so make sure: No one else frees the string, the string has allocated with
+ malloc for compatibility with c-based libs
+ */
+ void setContent(char*nContent,int nSize);
+
+protected:
+ char * content;
+ unsigned int size;
+
+ void init();
+ void copy_old(const encodedString&old);
+ void clean();
+};
+
#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
@@ -330,3 +330,3 @@ QList<Folder>* POP3wrapper::listFolders()
-QString POP3wrapper::fetchPart(const RecMail&,const RecPart&)
+QString POP3wrapper::fetchTextPart(const RecMail&,const RecPart&)
{
@@ -349 +349,10 @@ void POP3wrapper::answeredMail(const RecMail&)
+encodedString* POP3wrapper::fetchDecodedPart(const RecMail&,const RecPart&)
+{
+ return new encodedString();
+}
+
+encodedString* POP3wrapper::fetchRawPart(const RecMail&,const RecPart&)
+{
+ return new encodedString();
+}
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
@@ -8,2 +8,3 @@ class RecMail;
class RecBody;
+class encodedString;
struct mailpop3;
@@ -20,3 +21,6 @@ public:
virtual QList<Folder>* listFolders();
- virtual QString fetchPart(const RecMail&mail,const RecPart&part);
+ virtual QString fetchTextPart(const RecMail&mail,const RecPart&part);
+ virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part);
+ virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part);
+
virtual void deleteMail(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,3 +1,3 @@
#include "mailtypes.h"
-
+#include <stdlib.h>
@@ -247 +247,89 @@ const RecPart& RecBody::Description()const
}
+
+/* handling encoded content */
+encodedString::encodedString()
+{
+ init();
+}
+
+encodedString::encodedString(const char*nContent,unsigned int nSize)
+{
+ init();
+ setContent(nContent,nSize);
+}
+
+encodedString::encodedString(char*nContent,unsigned int nSize)
+{
+ init();
+ setContent(nContent,nSize);
+}
+
+encodedString::encodedString(const encodedString&old)
+{
+ init();
+ copy_old(old);
+ qDebug("encodedeString: copy constructor!");
+}
+
+encodedString& encodedString::operator=(const encodedString&old)
+{
+ init();
+ copy_old(old);
+ qDebug("encodedString: assign operator!");
+ return *this;
+}
+
+encodedString::~encodedString()
+{
+ clean();
+}
+
+void encodedString::init()
+{
+ content = 0;
+ size = 0;
+}
+
+void encodedString::clean()
+{
+ if (content) {
+ free(content);
+ }
+ content = 0;
+ size = 0;
+}
+
+void encodedString::copy_old(const encodedString&old)
+{
+ clean();
+ if (old.size>0 && old.content) {
+ content = (char*)malloc(old.size*sizeof(char));
+ memcpy(content,old.content,size);
+ size = old.size;
+ }
+}
+
+const char*encodedString::Content()const
+{
+ return content;
+}
+
+const int encodedString::Length()const
+{
+ return size;
+}
+
+void encodedString::setContent(const char*nContent,int nSize)
+{
+ if (nSize>0 && nContent) {
+ content = (char*)malloc(nSize*sizeof(char));
+ memcpy(content,nContent,nSize);
+ size = nSize;
+ }
+}
+
+void encodedString::setContent(char*nContent,int nSize)
+{
+ content = nContent;
+ size = nSize;
+}
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
@@ -137,2 +137,49 @@ public:
+class encodedString
+{
+public:
+ encodedString();
+ /*
+ creates an new content string.
+ it makes a deep copy of it!
+ */
+ encodedString(const char*nContent,unsigned int length);
+ /*
+ Take over the nContent. Means: it will just copy the pointer, not the content.
+ so make sure: No one else frees the string, the string has allocated with
+ malloc for compatibility with c-based libs
+ */
+ encodedString(char*nContent,unsigned int nSize);
+ /* copy construkor - makes ALWAYS a deep copy!!!! */
+ encodedString(const encodedString&old);
+ /* assign operator - makes ALWAYS a deep copy!!!! */
+ encodedString& operator=(const encodedString&old);
+ /* destructor - cleans the content */
+ virtual ~encodedString();
+
+ /* returns a pointer to the content - do not delete yoursel! */
+ const char*Content()const;
+ /* returns the lengths of the content 'cause it must not be a null-terminated string! */
+ const int Length()const;
+
+ /*
+ makes a deep copy of nContent!
+ */
+ void setContent(const char*nContent,int nSize);
+ /*
+ Take over the nContent. Means: it will just copy the pointer, not the content.
+ so make sure: No one else frees the string, the string has allocated with
+ malloc for compatibility with c-based libs
+ */
+ void setContent(char*nContent,int nSize);
+
+protected:
+ char * content;
+ unsigned int size;
+
+ void init();
+ void copy_old(const encodedString&old);
+ void clean();
+};
+
#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
@@ -330,3 +330,3 @@ QList<Folder>* POP3wrapper::listFolders()
-QString POP3wrapper::fetchPart(const RecMail&,const RecPart&)
+QString POP3wrapper::fetchTextPart(const RecMail&,const RecPart&)
{
@@ -349 +349,10 @@ void POP3wrapper::answeredMail(const RecMail&)
+encodedString* POP3wrapper::fetchDecodedPart(const RecMail&,const RecPart&)
+{
+ return new encodedString();
+}
+
+encodedString* POP3wrapper::fetchRawPart(const RecMail&,const RecPart&)
+{
+ return new encodedString();
+}
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
@@ -8,2 +8,3 @@ class RecMail;
class RecBody;
+class encodedString;
struct mailpop3;
@@ -20,3 +21,6 @@ public:
virtual QList<Folder>* listFolders();
- virtual QString fetchPart(const RecMail&mail,const RecPart&part);
+ virtual QString fetchTextPart(const RecMail&mail,const RecPart&part);
+ virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part);
+ virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part);
+
virtual void deleteMail(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
@@ -5,2 +5,3 @@
#include <qpopupmenu.h>
+#include <qfile.h>
#include <qapplication.h>
@@ -14,2 +15,3 @@
#include "accountview.h"
+#include "mailtypes.h"
@@ -136,3 +138,10 @@ void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int
if( !str.isEmpty() ) {
- qDebug( "first we will need a MIME wrapper" );
+ encodedString*content = m_recMail.Wrapper()->fetchDecodedPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] );
+ if (content) {
+ QFile output(str);
+ output.open(IO_WriteOnly);
+ output.writeBlock(content->Content(),content->Length());
+ output.close();
+ delete content;
+ }
}
@@ -146,3 +155,3 @@ void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int
if ( m_recMail.Wrapper() != 0l ) { // make sure that there is a wrapper , even after delete or simular actions
- browser->setText( m_recMail.Wrapper()->fetchPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) );
+ browser->setText( m_recMail.Wrapper()->fetchTextPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) );
}