author | alwin <alwin> | 2003-12-16 13:14:05 (UTC) |
---|---|---|
committer | alwin <alwin> | 2003-12-16 13:14:05 (UTC) |
commit | 49c02bbbb7a0aeee933d58ba1d3d3e86e6bc7838 (patch) (side-by-side diff) | |
tree | 710393582789ed1db97592fed5bb88ad4d56550d /noncore/net/mail/libmailwrapper/imapwrapper.cpp | |
parent | f42c15f884d4377bc99d73e16fa1722b0fb2a4d3 (diff) | |
download | opie-49c02bbbb7a0aeee933d58ba1d3d3e86e6bc7838.zip opie-49c02bbbb7a0aeee933d58ba1d3d3e86e6bc7838.tar.gz opie-49c02bbbb7a0aeee933d58ba1d3d3e86e6bc7838.tar.bz2 |
saving of attachments implemented.
Diffstat (limited to 'noncore/net/mail/libmailwrapper/imapwrapper.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 76 |
1 files changed, 45 insertions, 31 deletions
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,12 +508,5 @@ 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); } @@ -526,4 +514,2 @@ QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,boo } - } - } 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); +} |