summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.cpp33
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.h1
-rw-r--r--noncore/net/mail/pop3wrapper.cpp33
-rw-r--r--noncore/net/mail/pop3wrapper.h1
4 files changed, 52 insertions, 16 deletions
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
index 2c2a42a..65cd4ba 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
@@ -437,37 +437,32 @@ encodedString* POP3wrapper::fetchRawPart(const RecMail&,const RecPart&)
void POP3wrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mime,unsigned int current_rec)
{
if (current_rec >= 10) {
qDebug("too deep recursion!");
}
if (!message || !mime) {
return;
}
int r;
char*data = 0;
size_t len;
clistiter * cur = 0;
- mailmime_single_fields fields;
int res;
QString b;
- memset(&fields, 0, sizeof(struct mailmime_single_fields));
RecPart part;
- if (mime->mm_mime_fields != NULL) {
- mailmime_single_fields_init(&fields, mime->mm_mime_fields,
- mime->mm_content_type);
- }
switch (mime->mm_type) {
case MAILMIME_SINGLE:
r = mailmessage_fetch_section(message,mime,&data,&len);
+ part.setSize(len);
fillSingleBody(part,message,mime);
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());
delete r;
delete res;
target.setBodytext(b);
target.setDescription(part);
} else {
/* TODO: Add the content to a list and store it for later use */
@@ -514,26 +509,33 @@ QString POP3wrapper::getencoding(mailmime_mechanism*aEnc)
enc = QString(aEnc->enc_token);
}
break;
}
return enc;
}
void POP3wrapper::fillSingleBody(RecPart&target,mailmessage*,mailmime*mime)
{
if (!mime) {
return;
}
- mailmime_content*type = mime->mm_content_type;
mailmime_field*field = 0;
+ mailmime_single_fields fields;
+ memset(&fields, 0, sizeof(struct mailmime_single_fields));
+ if (mime->mm_mime_fields != NULL) {
+ mailmime_single_fields_init(&fields, mime->mm_mime_fields,
+ mime->mm_content_type);
+ }
+
+ mailmime_content*type = fields.fld_content;
clistcell*current;
if (!type) {
target.setType("text");
target.setSubtype("plain");
} else {
target.setSubtype(type->ct_subtype);
switch(type->ct_type->tp_data.tp_discrete_type->dt_type) {
case MAILMIME_DISCRETE_TYPE_TEXT:
target.setType("text");
break;
case MAILMIME_DISCRETE_TYPE_IMAGE:
target.setType("image");
@@ -545,33 +547,48 @@ void POP3wrapper::fillSingleBody(RecPart&target,mailmessage*,mailmime*mime)
target.setType("video");
break;
case MAILMIME_DISCRETE_TYPE_APPLICATION:
target.setType("application");
break;
case MAILMIME_DISCRETE_TYPE_EXTENSION:
default:
if (type->ct_type->tp_data.tp_discrete_type->dt_extension) {
target.setType(type->ct_type->tp_data.tp_discrete_type->dt_extension);
}
break;
}
+ if (type->ct_parameters) {
+ fillParameters(target,type->ct_parameters);
+ }
}
if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) {
for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) {
field = (mailmime_field*)current->data;
switch(field->fld_type) {
case MAILMIME_FIELD_TRANSFER_ENCODING:
target.setEncoding(getencoding(field->fld_data.fld_encoding));
break;
case MAILMIME_FIELD_ID:
target.setIdentifier(field->fld_data.fld_id);
break;
case MAILMIME_FIELD_DESCRIPTION:
target.setDescription(field->fld_data.fld_description);
break;
default:
break;
}
}
}
- // TODO search the parameter list for unique id and so on
+}
+
+void POP3wrapper::fillParameters(RecPart&target,clist*parameters)
+{
+ if (!parameters) {return;}
+ clistcell*current=0;
+ mailmime_parameter*param;
+ for (current=clist_begin(parameters);current!=0;current=clist_next(current)) {
+ param = (mailmime_parameter*)current->data;
+ if (param) {
+ target.addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
+ }
+ }
}
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h
index 4171a76..b17928e 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.h
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h
@@ -37,21 +37,22 @@ protected:
void logout();
RecMail *parseHeader( const char *header );
RecBody parseMail( char *message );
QString parseMailboxList( mailimf_mailbox_list *list );
QString parseMailbox( mailimf_mailbox *box );
QString parseGroup( mailimf_group *group );
QString parseAddressList( mailimf_address_list *list );
QString parseDateTime( mailimf_date_time *date );
static void traverseBody(RecBody&target,mailmessage*message,mailmime*mime,unsigned int current_rek=0);
static void fillSingleBody(RecPart&target,mailmessage*message,mailmime*mime);
+ static void fillParameters(RecPart&target,clist*parameters);
static QString POP3wrapper::getencoding(mailmime_mechanism*aEnc);
POP3account *account;
mailpop3 *m_pop3;
QString msgTempName;
unsigned int last_msg_id;
};
#endif
diff --git a/noncore/net/mail/pop3wrapper.cpp b/noncore/net/mail/pop3wrapper.cpp
index 2c2a42a..65cd4ba 100644
--- a/noncore/net/mail/pop3wrapper.cpp
+++ b/noncore/net/mail/pop3wrapper.cpp
@@ -437,37 +437,32 @@ encodedString* POP3wrapper::fetchRawPart(const RecMail&,const RecPart&)
void POP3wrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mime,unsigned int current_rec)
{
if (current_rec >= 10) {
qDebug("too deep recursion!");
}
if (!message || !mime) {
return;
}
int r;
char*data = 0;
size_t len;
clistiter * cur = 0;
- mailmime_single_fields fields;
int res;
QString b;
- memset(&fields, 0, sizeof(struct mailmime_single_fields));
RecPart part;
- if (mime->mm_mime_fields != NULL) {
- mailmime_single_fields_init(&fields, mime->mm_mime_fields,
- mime->mm_content_type);
- }
switch (mime->mm_type) {
case MAILMIME_SINGLE:
r = mailmessage_fetch_section(message,mime,&data,&len);
+ part.setSize(len);
fillSingleBody(part,message,mime);
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());
delete r;
delete res;
target.setBodytext(b);
target.setDescription(part);
} else {
/* TODO: Add the content to a list and store it for later use */
@@ -514,26 +509,33 @@ QString POP3wrapper::getencoding(mailmime_mechanism*aEnc)
enc = QString(aEnc->enc_token);
}
break;
}
return enc;
}
void POP3wrapper::fillSingleBody(RecPart&target,mailmessage*,mailmime*mime)
{
if (!mime) {
return;
}
- mailmime_content*type = mime->mm_content_type;
mailmime_field*field = 0;
+ mailmime_single_fields fields;
+ memset(&fields, 0, sizeof(struct mailmime_single_fields));
+ if (mime->mm_mime_fields != NULL) {
+ mailmime_single_fields_init(&fields, mime->mm_mime_fields,
+ mime->mm_content_type);
+ }
+
+ mailmime_content*type = fields.fld_content;
clistcell*current;
if (!type) {
target.setType("text");
target.setSubtype("plain");
} else {
target.setSubtype(type->ct_subtype);
switch(type->ct_type->tp_data.tp_discrete_type->dt_type) {
case MAILMIME_DISCRETE_TYPE_TEXT:
target.setType("text");
break;
case MAILMIME_DISCRETE_TYPE_IMAGE:
target.setType("image");
@@ -545,33 +547,48 @@ void POP3wrapper::fillSingleBody(RecPart&target,mailmessage*,mailmime*mime)
target.setType("video");
break;
case MAILMIME_DISCRETE_TYPE_APPLICATION:
target.setType("application");
break;
case MAILMIME_DISCRETE_TYPE_EXTENSION:
default:
if (type->ct_type->tp_data.tp_discrete_type->dt_extension) {
target.setType(type->ct_type->tp_data.tp_discrete_type->dt_extension);
}
break;
}
+ if (type->ct_parameters) {
+ fillParameters(target,type->ct_parameters);
+ }
}
if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) {
for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) {
field = (mailmime_field*)current->data;
switch(field->fld_type) {
case MAILMIME_FIELD_TRANSFER_ENCODING:
target.setEncoding(getencoding(field->fld_data.fld_encoding));
break;
case MAILMIME_FIELD_ID:
target.setIdentifier(field->fld_data.fld_id);
break;
case MAILMIME_FIELD_DESCRIPTION:
target.setDescription(field->fld_data.fld_description);
break;
default:
break;
}
}
}
- // TODO search the parameter list for unique id and so on
+}
+
+void POP3wrapper::fillParameters(RecPart&target,clist*parameters)
+{
+ if (!parameters) {return;}
+ clistcell*current=0;
+ mailmime_parameter*param;
+ for (current=clist_begin(parameters);current!=0;current=clist_next(current)) {
+ param = (mailmime_parameter*)current->data;
+ if (param) {
+ target.addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
+ }
+ }
}
diff --git a/noncore/net/mail/pop3wrapper.h b/noncore/net/mail/pop3wrapper.h
index 4171a76..b17928e 100644
--- a/noncore/net/mail/pop3wrapper.h
+++ b/noncore/net/mail/pop3wrapper.h
@@ -37,21 +37,22 @@ protected:
void logout();
RecMail *parseHeader( const char *header );
RecBody parseMail( char *message );
QString parseMailboxList( mailimf_mailbox_list *list );
QString parseMailbox( mailimf_mailbox *box );
QString parseGroup( mailimf_group *group );
QString parseAddressList( mailimf_address_list *list );
QString parseDateTime( mailimf_date_time *date );
static void traverseBody(RecBody&target,mailmessage*message,mailmime*mime,unsigned int current_rek=0);
static void fillSingleBody(RecPart&target,mailmessage*message,mailmime*mime);
+ static void fillParameters(RecPart&target,clist*parameters);
static QString POP3wrapper::getencoding(mailmime_mechanism*aEnc);
POP3account *account;
mailpop3 *m_pop3;
QString msgTempName;
unsigned int last_msg_id;
};
#endif