author | alwin <alwin> | 2004-01-03 13:09:15 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-01-03 13:09:15 (UTC) |
commit | 622bddce6d0cd41c765225f4743b23bf1667f3db (patch) (side-by-side diff) | |
tree | fbe4e839e111e09fce0e64cc68f70f1deb4f7ee0 | |
parent | 22564b62e15c1ea3feada5b2f9b6ec4d98b40c6b (diff) | |
download | opie-622bddce6d0cd41c765225f4743b23bf1667f3db.zip opie-622bddce6d0cd41c765225f4743b23bf1667f3db.tar.gz opie-622bddce6d0cd41c765225f4743b23bf1667f3db.tar.bz2 |
better parsing of mails with recursive multipart content
-rw-r--r-- | noncore/net/mail/genericwrapper.cpp | 26 | ||||
-rw-r--r-- | noncore/net/mail/genericwrapper.h | 2 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/genericwrapper.cpp | 26 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/genericwrapper.h | 2 |
4 files changed, 44 insertions, 12 deletions
diff --git a/noncore/net/mail/genericwrapper.cpp b/noncore/net/mail/genericwrapper.cpp index 62116ba..714396b 100644 --- a/noncore/net/mail/genericwrapper.cpp +++ b/noncore/net/mail/genericwrapper.cpp @@ -137,10 +137,8 @@ void Genericwrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mi clistiter * cur = 0; QString b; RecPart part; - //current_count; - switch (mime->mm_type) { case MAILMIME_SINGLE: { QValueList<int>countlist = recList; @@ -154,10 +152,15 @@ void Genericwrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mi if (part.Type()=="text" && target.Bodytext().isNull()) { encodedString*r = new encodedString(); r->setContent(data,len); encodedString*res = decode_String(r,part.Encoding()); - b = QString(res->Content()); + if (countlist.count()>2) { + bodyCache[b]=r; + target.addPart(part); + } else { delete r; + } + b = QString(res->Content()); delete res; target.setBodytext(b); target.setDescription(part); } else { @@ -167,11 +170,24 @@ void Genericwrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mi } break; case MAILMIME_MULTIPLE: { - unsigned int ccount = current_count; + unsigned int ccount = 1; + mailmime*cbody=0; + QValueList<int>countlist = recList; for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { - traverseBody(target,message, (mailmime*)clist_content(cur),recList,current_rec+1,ccount); + cbody = (mailmime*)clist_content(cur); + if (cbody->mm_type==MAILMIME_MULTIPLE) { + RecPart targetPart; + targetPart.setType("multipart"); + countlist.append(current_count); + targetPart.setPositionlist(countlist); + target.addPart(targetPart); + } + traverseBody(target,message, cbody,countlist,current_rec+1,ccount); + if (cbody->mm_type==MAILMIME_MULTIPLE) { + countlist = recList; + } ++ccount; } } break; diff --git a/noncore/net/mail/genericwrapper.h b/noncore/net/mail/genericwrapper.h index c00d864..32b75c8 100644 --- a/noncore/net/mail/genericwrapper.h +++ b/noncore/net/mail/genericwrapper.h @@ -44,9 +44,9 @@ protected: QString parseGroup( mailimf_group *group ); QString parseAddressList( mailimf_address_list *list ); QString parseDateTime( mailimf_date_time *date ); - void traverseBody(RecBody&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rek=0,int current_count=0); + void traverseBody(RecBody&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rek=0,int current_count=1); static void fillSingleBody(RecPart&target,mailmessage*message,mailmime*mime); static void fillParameters(RecPart&target,clist*parameters); static QString getencoding(mailmime_mechanism*aEnc); virtual void parseList(QList<RecMail> &target,mailsession*session,const QString&mailbox); diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.cpp b/noncore/net/mail/libmailwrapper/genericwrapper.cpp index 62116ba..714396b 100644 --- a/noncore/net/mail/libmailwrapper/genericwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/genericwrapper.cpp @@ -137,10 +137,8 @@ void Genericwrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mi clistiter * cur = 0; QString b; RecPart part; - //current_count; - switch (mime->mm_type) { case MAILMIME_SINGLE: { QValueList<int>countlist = recList; @@ -154,10 +152,15 @@ void Genericwrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mi if (part.Type()=="text" && target.Bodytext().isNull()) { encodedString*r = new encodedString(); r->setContent(data,len); encodedString*res = decode_String(r,part.Encoding()); - b = QString(res->Content()); + if (countlist.count()>2) { + bodyCache[b]=r; + target.addPart(part); + } else { delete r; + } + b = QString(res->Content()); delete res; target.setBodytext(b); target.setDescription(part); } else { @@ -167,11 +170,24 @@ void Genericwrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mi } break; case MAILMIME_MULTIPLE: { - unsigned int ccount = current_count; + unsigned int ccount = 1; + mailmime*cbody=0; + QValueList<int>countlist = recList; for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { - traverseBody(target,message, (mailmime*)clist_content(cur),recList,current_rec+1,ccount); + cbody = (mailmime*)clist_content(cur); + if (cbody->mm_type==MAILMIME_MULTIPLE) { + RecPart targetPart; + targetPart.setType("multipart"); + countlist.append(current_count); + targetPart.setPositionlist(countlist); + target.addPart(targetPart); + } + traverseBody(target,message, cbody,countlist,current_rec+1,ccount); + if (cbody->mm_type==MAILMIME_MULTIPLE) { + countlist = recList; + } ++ccount; } } break; diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.h b/noncore/net/mail/libmailwrapper/genericwrapper.h index c00d864..32b75c8 100644 --- a/noncore/net/mail/libmailwrapper/genericwrapper.h +++ b/noncore/net/mail/libmailwrapper/genericwrapper.h @@ -44,9 +44,9 @@ protected: QString parseGroup( mailimf_group *group ); QString parseAddressList( mailimf_address_list *list ); QString parseDateTime( mailimf_date_time *date ); - void traverseBody(RecBody&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rek=0,int current_count=0); + void traverseBody(RecBody&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rek=0,int current_count=1); static void fillSingleBody(RecPart&target,mailmessage*message,mailmime*mime); static void fillParameters(RecPart&target,clist*parameters); static QString getencoding(mailmime_mechanism*aEnc); virtual void parseList(QList<RecMail> &target,mailsession*session,const QString&mailbox); |