summaryrefslogtreecommitdiff
authoralwin <alwin>2005-03-11 22:15:12 (UTC)
committer alwin <alwin>2005-03-11 22:15:12 (UTC)
commitcff58fc3b963a09506a17d17cf4e3f9a3887d491 (patch) (side-by-side diff)
tree450d113bd74f5a4934b9540dd6ec883a6e23e6cf
parente851ff8f826be005a2aa935133d40b162f23de53 (diff)
downloadopie-cff58fc3b963a09506a17d17cf4e3f9a3887d491.zip
opie-cff58fc3b963a09506a17d17cf4e3f9a3887d491.tar.gz
opie-cff58fc3b963a09506a17d17cf4e3f9a3887d491.tar.bz2
even a full correct mail comes via generic protocoll like pop3 or mh
parts of were stored with wrong identifier inside cache.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/genericwrapper.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.cpp b/noncore/net/mail/libmailwrapper/genericwrapper.cpp
index 0ac842d..6fcc701 100644
--- a/noncore/net/mail/libmailwrapper/genericwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/genericwrapper.cpp
@@ -103,167 +103,168 @@ void Genericwrapper::fillParameters(RecPartP&target,clist*parameters)
if (param) {
target->addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
}
}
}
QString Genericwrapper::getencoding(mailmime_mechanism*aEnc)
{
QString enc="7bit";
if (!aEnc) return enc;
switch(aEnc->enc_type) {
case MAILMIME_MECHANISM_7BIT:
enc = "7bit";
break;
case MAILMIME_MECHANISM_8BIT:
enc = "8bit";
break;
case MAILMIME_MECHANISM_BINARY:
enc = "binary";
break;
case MAILMIME_MECHANISM_QUOTED_PRINTABLE:
enc = "quoted-printable";
break;
case MAILMIME_MECHANISM_BASE64:
enc = "base64";
break;
case MAILMIME_MECHANISM_TOKEN:
default:
if (aEnc->enc_token) {
enc = QString(aEnc->enc_token);
}
break;
}
return enc;
}
void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count)
{
if (current_rec >= 10) {
odebug << "too deep recursion!" << oendl;
}
if (!message || !mime) {
return;
}
int r;
char*data = 0;
size_t len;
clistiter * cur = 0;
- QString b;
RecPartP part = new RecPart();
switch (mime->mm_type) {
case MAILMIME_SINGLE:
{
QValueList<int>countlist = recList;
countlist.append(current_count);
r = mailmessage_fetch_section(message,mime,&data,&len);
part->setSize(len);
part->setPositionlist(countlist);
- b = gen_attachment_id();
- part->setIdentifier(b);
fillSingleBody(part,message,mime);
+ if (part->Identifier().isEmpty()) {
+ part->setIdentifier(gen_attachment_id());
+ }
+
if (part->Type()=="text" && target->Bodytext().isNull()) {
encodedString*rs = new encodedString();
rs->setContent(data,len);
encodedString*res = decode_String(rs,part->Encoding());
if (countlist.count()>2) {
- bodyCache[b]=rs;
+ bodyCache[part->Identifier()]=rs;
target->addPart(part);
} else {
delete rs;
}
+ QString b;
b = QString(res->Content());
delete res;
target->setBodytext(b);
target->setDescription(part);
} else {
- bodyCache[b]=new encodedString(data,len);
+ bodyCache[part->Identifier()]=new encodedString(data,len);
target->addPart(part);
}
}
break;
case MAILMIME_MULTIPLE:
{
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)) {
cbody = (mailmime*)clist_content(cur);
if (cbody->mm_type==MAILMIME_MULTIPLE) {
RecPartP targetPart = new RecPart();
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;
case MAILMIME_MESSAGE:
{
QValueList<int>countlist = recList;
countlist.append(current_count);
/* the own header is always at recursion 0 - we don't need that */
if (current_rec > 0) {
part->setPositionlist(countlist);
r = mailmessage_fetch_section(message,mime,&data,&len);
part->setSize(len);
part->setPositionlist(countlist);
- b = gen_attachment_id();
- part->setIdentifier(b);
+ part->setIdentifier(gen_attachment_id());
part->setType("message");
part->setSubtype("rfc822");
- bodyCache[b]=new encodedString(data,len);
+ bodyCache[part->Identifier()]=new encodedString(data,len);
target->addPart(part);
}
if (mime->mm_data.mm_message.mm_msg_mime != NULL) {
traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1);
}
}
break;
}
}
RecBodyP Genericwrapper::parseMail( mailmessage * msg )
{
int err = MAILIMF_NO_ERROR;
mailmime_single_fields fields;
/* is bound to msg and will be freed there */
mailmime * mime=0;
RecBodyP body = new RecBody();
memset(&fields, 0, sizeof(struct mailmime_single_fields));
err = mailmessage_get_bodystructure(msg,&mime);
QValueList<int>recList;
traverseBody(body,msg,mime,recList);
return body;
}
QString Genericwrapper::parseAddressList( mailimf_address_list *list )
{
QString result( "" );
bool first = true;
if (list == 0) return result;
for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) {
mailimf_address *addr = (mailimf_address *) current->data;
if ( !first ) {
result.append( "," );
} else {
first = false;
}
switch ( addr->ad_type ) {
case MAILIMF_ADDRESS_MAILBOX:
result.append( parseMailbox( addr->ad_data.ad_mailbox ) );
break;
case MAILIMF_ADDRESS_GROUP:
result.append( parseGroup( addr->ad_data.ad_group ) );
break;
default:
odebug << "Generic: unkown mailimf address type" << oendl;