Diffstat (limited to 'noncore/net/mail/libmailwrapper/pop3wrapper.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.cpp | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp index 65cd4ba..d3447f4 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp @@ -17,4 +17,5 @@ POP3wrapper::POP3wrapper( POP3account *a ) msgTempName = a->getFileName()+"_msg_cache"; last_msg_id = 0; + bodyCache.clear(); } @@ -26,4 +27,16 @@ POP3wrapper::~POP3wrapper() msg_cache.remove(); } + cleanUpCache(); +} + +void POP3wrapper::cleanUpCache() +{ + QMap<QString,encodedString*>::Iterator it = bodyCache.begin(); + for (;it!=bodyCache.end();++it) { + encodedString*t = it.data(); + //it.setValue(0); + if (t) delete t; + } + bodyCache.clear(); } @@ -52,4 +65,5 @@ RecBody POP3wrapper::fetchBody( const RecMail &mail ) return body; } + cleanUpCache(); if (mail.getNumber()!=last_msg_id) { if (msg_cache.exists()) { @@ -406,7 +420,10 @@ QList<Folder>* POP3wrapper::listFolders() } -QString POP3wrapper::fetchTextPart(const RecMail&,const RecPart&) +QString POP3wrapper::fetchTextPart(const RecMail&mail,const RecPart&part) { - return ""; + encodedString*t = fetchDecodedPart(mail,part); + QString text=t->Content(); + delete t; + return text; } @@ -425,12 +442,18 @@ void POP3wrapper::answeredMail(const RecMail&) } -encodedString* POP3wrapper::fetchDecodedPart(const RecMail&,const RecPart&) +encodedString* POP3wrapper::fetchDecodedPart(const RecMail&,const RecPart&part) { - return new encodedString(); + QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part.Identifier()); + if (it==bodyCache.end()) return new encodedString(); + encodedString*t = decode_String(it.data(),part.Encoding()); + return t; } -encodedString* POP3wrapper::fetchRawPart(const RecMail&,const RecPart&) +encodedString* POP3wrapper::fetchRawPart(const RecMail&mail,const RecPart&part) { - return new encodedString(); + QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part.Identifier()); + if (it==bodyCache.end()) return new encodedString(); + encodedString*t = it.data(); + return t; } @@ -466,6 +489,7 @@ void POP3wrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mime, target.setDescription(part); } else { - /* TODO: Add the content to a list and store it for later use */ - if (data) free(data); + b = gen_attachment_id(); + part.setIdentifier(b); + bodyCache[b]=new encodedString(data,len); target.addPart(part); } |