summaryrefslogtreecommitdiff
authoralwin <alwin>2004-01-03 02:17:50 (UTC)
committer alwin <alwin>2004-01-03 02:17:50 (UTC)
commit1214e08e45cda6f0de39a8f3bcff2e69244bb87f (patch) (side-by-side diff)
treed51a018b6014904c09272c684e211d8d05cf360e
parent79bca648a80c42d5dc7e7674b251715292db33b3 (diff)
downloadopie-1214e08e45cda6f0de39a8f3bcff2e69244bb87f.zip
opie-1214e08e45cda6f0de39a8f3bcff2e69244bb87f.tar.gz
opie-1214e08e45cda6f0de39a8f3bcff2e69244bb87f.tar.bz2
improved parsing of mailbodies 'cause it failed on multi-part fields which
contains multipart-fields, too.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/imapwrapper.cpp43
-rw-r--r--noncore/net/mail/imapwrapper.h3
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp43
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.h3
4 files changed, 84 insertions, 8 deletions
diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp
index f7e93aa..ae196bb 100644
--- a/noncore/net/mail/imapwrapper.cpp
+++ b/noncore/net/mail/imapwrapper.cpp
@@ -531,3 +531,2 @@ void IMAPwrapper::traverseBody(const RecMail&mail,mailimap_body*body,RecBody&tar
}
- ++current_count;
switch (body->bd_type) {
@@ -554,2 +553,5 @@ void IMAPwrapper::traverseBody(const RecMail&mail,mailimap_body*body,RecBody&tar
target_body.setBodytext(body_text);
+ if (countlist.count()>1) {
+ target_body.addPart(currentPart);
+ }
} else {
@@ -564,5 +566,6 @@ void IMAPwrapper::traverseBody(const RecMail&mail,mailimap_body*body,RecBody&tar
{
+ QValueList<int>countlist = recList;
clistcell*current=0;
mailimap_body*current_body=0;
- unsigned int ccount = current_count-1;
+ unsigned int ccount = 1;
mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart;
@@ -570,3 +573,20 @@ void IMAPwrapper::traverseBody(const RecMail&mail,mailimap_body*body,RecBody&tar
current_body = (mailimap_body*)current->data;
- traverseBody(mail,current_body,target_body,current_recursion+1,recList,ccount);
+ if (current_body->bd_type==MAILIMAP_BODY_MPART) {
+ RecPart targetPart;
+ targetPart.setType("multipart");
+ fillMultiPart(targetPart,mailDescription);
+ countlist.append(current_count);
+ targetPart.setPositionlist(countlist);
+ target_body.addPart(targetPart);
+ QString id("");
+ for (unsigned int j = 0; j < countlist.count();++j) {
+ id+=(j>0?" ":"");
+ id+=QString("%1").arg(countlist[j]);
+ }
+ qDebug("ID(mpart) = %s",id.latin1());
+ }
+ traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount);
+ if (current_body->bd_type==MAILIMAP_BODY_MPART) {
+ countlist = recList;
+ }
++ccount;
@@ -609,2 +629,3 @@ void IMAPwrapper::fillSingleTextPart(RecPart&target_part,mailimap_body_type_text
sub = which->bd_media_text;
+ qDebug("Type= text/%s",which->bd_media_text);
target_part.setSubtype(sub.lower());
@@ -626,2 +647,18 @@ void IMAPwrapper::fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*w
+void IMAPwrapper::fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which)
+{
+ if (!which) return;
+ target_part.setSubtype(which->bd_media_subtype);
+ if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) {
+ clistcell*cur = 0;
+ mailimap_single_body_fld_param*param=0;
+ for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) {
+ param = (mailimap_single_body_fld_param*)cur->data;
+ if (param) {
+ target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
+ }
+ }
+ }
+}
+
void IMAPwrapper::fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which)
diff --git a/noncore/net/mail/imapwrapper.h b/noncore/net/mail/imapwrapper.h
index e5846f8..7941046 100644
--- a/noncore/net/mail/imapwrapper.h
+++ b/noncore/net/mail/imapwrapper.h
@@ -54,3 +54,4 @@ protected:
void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which);
- void traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body,int current_recursion,QValueList<int>recList,int current_count=0);
+ void fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which);
+ void traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body,int current_recursion,QValueList<int>recList,int current_count=1);
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
index f7e93aa..ae196bb 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
@@ -531,3 +531,2 @@ void IMAPwrapper::traverseBody(const RecMail&mail,mailimap_body*body,RecBody&tar
}
- ++current_count;
switch (body->bd_type) {
@@ -554,2 +553,5 @@ void IMAPwrapper::traverseBody(const RecMail&mail,mailimap_body*body,RecBody&tar
target_body.setBodytext(body_text);
+ if (countlist.count()>1) {
+ target_body.addPart(currentPart);
+ }
} else {
@@ -564,5 +566,6 @@ void IMAPwrapper::traverseBody(const RecMail&mail,mailimap_body*body,RecBody&tar
{
+ QValueList<int>countlist = recList;
clistcell*current=0;
mailimap_body*current_body=0;
- unsigned int ccount = current_count-1;
+ unsigned int ccount = 1;
mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart;
@@ -570,3 +573,20 @@ void IMAPwrapper::traverseBody(const RecMail&mail,mailimap_body*body,RecBody&tar
current_body = (mailimap_body*)current->data;
- traverseBody(mail,current_body,target_body,current_recursion+1,recList,ccount);
+ if (current_body->bd_type==MAILIMAP_BODY_MPART) {
+ RecPart targetPart;
+ targetPart.setType("multipart");
+ fillMultiPart(targetPart,mailDescription);
+ countlist.append(current_count);
+ targetPart.setPositionlist(countlist);
+ target_body.addPart(targetPart);
+ QString id("");
+ for (unsigned int j = 0; j < countlist.count();++j) {
+ id+=(j>0?" ":"");
+ id+=QString("%1").arg(countlist[j]);
+ }
+ qDebug("ID(mpart) = %s",id.latin1());
+ }
+ traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount);
+ if (current_body->bd_type==MAILIMAP_BODY_MPART) {
+ countlist = recList;
+ }
++ccount;
@@ -609,2 +629,3 @@ void IMAPwrapper::fillSingleTextPart(RecPart&target_part,mailimap_body_type_text
sub = which->bd_media_text;
+ qDebug("Type= text/%s",which->bd_media_text);
target_part.setSubtype(sub.lower());
@@ -626,2 +647,18 @@ void IMAPwrapper::fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*w
+void IMAPwrapper::fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which)
+{
+ if (!which) return;
+ target_part.setSubtype(which->bd_media_subtype);
+ if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) {
+ clistcell*cur = 0;
+ mailimap_single_body_fld_param*param=0;
+ for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) {
+ param = (mailimap_single_body_fld_param*)cur->data;
+ if (param) {
+ target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
+ }
+ }
+ }
+}
+
void IMAPwrapper::fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which)
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h
index e5846f8..7941046 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.h
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.h
@@ -54,3 +54,4 @@ protected:
void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which);
- void traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body,int current_recursion,QValueList<int>recList,int current_count=0);
+ void fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which);
+ void traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body,int current_recursion,QValueList<int>recList,int current_count=1);