summaryrefslogtreecommitdiff
path: root/noncore/net/mail/imapwrapper.cpp
Side-by-side diff
Diffstat (limited to 'noncore/net/mail/imapwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/imapwrapper.cpp78
1 files changed, 46 insertions, 32 deletions
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);
+}