summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/imapwrapper.cpp143
-rw-r--r--noncore/net/mail/imapwrapper.h6
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp143
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.h6
-rw-r--r--noncore/net/mail/libmailwrapper/mailtypes.cpp62
-rw-r--r--noncore/net/mail/libmailwrapper/mailtypes.h25
-rw-r--r--noncore/net/mail/mailtypes.cpp62
-rw-r--r--noncore/net/mail/mailtypes.h25
8 files changed, 282 insertions, 190 deletions
diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp
index fa967da..da5974c 100644
--- a/noncore/net/mail/imapwrapper.cpp
+++ b/noncore/net/mail/imapwrapper.cpp
@@ -372,81 +372,35 @@ void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mai
{
if (!mailDescription) {
return;
}
- QString sub;
+ QString sub,body_text;
+ RecPart singlePart;
+ QValueList<int> path;
+ fillSinglePart(singlePart,mailDescription);
switch (mailDescription->bd_type) {
case MAILIMAP_BODY_TYPE_1PART_MSG:
- target_body.setType("text");
- sub = mailDescription->bd_data.bd_type_text->bd_media_text;
- target_body.setSubtype(sub.lower());
- fillPlainBody(mail,target_body);
+ path.append(1);
+ body_text = fetchPart(mail,path,true);
+ target_body.setBodytext(body_text);
+ target_body.setDescription(singlePart);
break;
case MAILIMAP_BODY_TYPE_1PART_TEXT:
qDebug("Mediatype single: %s",mailDescription->bd_data.bd_type_text->bd_media_text);
- target_body.setType("text");
- sub = mailDescription->bd_data.bd_type_text->bd_media_text;
- target_body.setSubtype(sub.lower());
- fillPlainBody(mail,target_body);
+ path.append(1);
+ body_text = fetchPart(mail,path,true);
+ target_body.setBodytext(body_text);
+ target_body.setDescription(singlePart);
+ break;
+ case MAILIMAP_BODY_TYPE_1PART_BASIC:
+ qDebug("Single attachment");
+ target_body.setBodytext("");
+ target_body.addPart(singlePart);
break;
default:
break;
}
- return;
-}
-
-void IMAPwrapper::fillPlainBody(const RecMail&mail,RecBody&target_body)
-{
- const char *mb;
- QString body="";
- int err = MAILIMAP_NO_ERROR;
- clist *result;
- clistcell *current,*cur;
- mailimap_fetch_att *fetchAtt;
- mailimap_fetch_type *fetchType;
- mailimap_set *set;
-
- mb = mail.getMbox().latin1();
-
- if (!m_imap) {
- return;
- }
-
- result = clist_new();
- set = set = mailimap_set_new_single(mail.getNumber());
- mailimap_section * section = mailimap_section_new_text();
- fetchAtt = mailimap_fetch_att_new_body_peek_section(section);
- fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt);
- err = mailimap_fetch( m_imap, set, fetchType, &result );
- mailimap_set_free( set );
- mailimap_fetch_type_free( fetchType );
-
- if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) {
- mailimap_msg_att * msg_att;
- msg_att = (mailimap_msg_att*)current->data;
- mailimap_msg_att_item*msg_att_item;
- for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) {
- msg_att_item = (mailimap_msg_att_item*)clist_content(cur);
- if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) {
- if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) {
- char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part;
- msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L;
- if (text) {
- body = QString(text);
- free(text);
- } else {
- body = "";
- }
- }
- }
- }
-
- } else {
- qDebug("error fetching text: %s",m_imap->imap_response);
- }
- mailimap_fetch_list_free(result);
- target_body.setBodytext(body);
return;
}
QStringList IMAPwrapper::address_list_to_stringlist(clist*list)
@@ -489,9 +443,9 @@ QStringList IMAPwrapper::address_list_to_stringlist(clist*list)
}
return l;
}
-QString IMAPwrapper::fetchPart(const RecMail&mail,QValueList<int>&path,bool internal_call)
+QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call)
{
QString body("");
const char*mb;
int err;
@@ -583,19 +537,19 @@ void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mai
clist.append(count);
/* important: Check for is NULL 'cause a body can be empty! */
if (currentPart.Type()=="text" && target_body.Bodytext().isNull() ) {
QString body_text = fetchPart(mail,clist,true);
+ target_body.setDescription(currentPart);
target_body.setBodytext(body_text);
- target_body.setType(currentPart.Type());
- target_body.setSubtype(currentPart.Subtype());
} else {
QString id("");
for (unsigned int j = 0; j < clist.count();++j) {
- id+=(j>0?".":"");
+ id+=(j>0?" ":"");
id+=QString("%1").arg(clist[j]);
}
qDebug("ID= %s",id.latin1());
currentPart.setIdentifier(id);
+ currentPart.setPositionlist(clist);
target_body.addPart(currentPart);
}
}
}
@@ -613,8 +567,11 @@ void IMAPwrapper::fillSinglePart(RecPart&target_part,mailimap_body_type_1part*De
break;
case MAILIMAP_BODY_TYPE_1PART_BASIC:
fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic);
break;
+ case MAILIMAP_BODY_TYPE_1PART_MSG:
+ fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg);
+ break;
default:
break;
}
}
@@ -630,8 +587,24 @@ void IMAPwrapper::fillSingleTextPart(RecPart&target_part,mailimap_body_type_text
target_part.setLines(which->bd_lines);
fillBodyFields(target_part,which->bd_fields);
}
+void IMAPwrapper::fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which)
+{
+ if (!which) {
+ return;
+ }
+// QString sub;
+// sub = which->bd_media_text;
+// target_part.setSubtype(sub.lower());
+ qDebug("Message part");
+ /* we set this type to text/plain */
+ target_part.setType("text");
+ target_part.setSubtype("plain");
+ target_part.setLines(which->bd_lines);
+ fillBodyFields(target_part,which->bd_fields);
+}
+
void IMAPwrapper::fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which)
{
if (!which) {
return;
@@ -679,6 +652,42 @@ void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which)
clistcell*cur;
mailimap_single_body_fld_param*param;
for (cur = clist_begin(which->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));
+ }
}
+ mailimap_body_fld_enc*enc = which->bd_encoding;
+ QString encoding("");
+ switch (enc->enc_type) {
+ case MAILIMAP_BODY_FLD_ENC_7BIT:
+ encoding = "7bit";
+ break;
+ case MAILIMAP_BODY_FLD_ENC_8BIT:
+ encoding = "8bit";
+ break;
+ case MAILIMAP_BODY_FLD_ENC_BINARY:
+ encoding="binary";
+ break;
+ case MAILIMAP_BODY_FLD_ENC_BASE64:
+ encoding="base64";
+ break;
+ case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE:
+ encoding="quoted-printable";
+ break;
+ case MAILIMAP_BODY_FLD_ENC_OTHER:
+ default:
+ if (enc->enc_value) {
+ char*t=enc->enc_value;
+ encoding=QString(enc->enc_value);
+ enc->enc_value=0L;
+ free(t);
+ }
+ }
+ target_part.setEncoding(encoding);
+}
+
+QString IMAPwrapper::fetchPart(const RecMail&mail,const RecPart&part)
+{
+ return fetchPart(mail,part.Positionlist(),false);
}
diff --git a/noncore/net/mail/imapwrapper.h b/noncore/net/mail/imapwrapper.h
index 5ea45f3..95de215 100644
--- a/noncore/net/mail/imapwrapper.h
+++ b/noncore/net/mail/imapwrapper.h
@@ -7,8 +7,9 @@
struct mailimap;
struct mailimap_body_type_1part;
struct mailimap_body_type_text;
struct mailimap_body_type_basic;
+struct mailimap_body_type_msg;
struct mailimap_body_type_mpart;
struct mailimap_body_fields;
struct mailimap_msg_att;
class RecMail;
@@ -24,9 +25,10 @@ public:
virtual ~IMAPwrapper();
QList<IMAPFolder>* listFolders();
void listMessages(const QString & mailbox,QList<RecMail>&target );
RecBody fetchBody(const RecMail&mail);
- QString fetchPart(const RecMail&mail,QValueList<int>&path,bool internal_call=false);
+ QString fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false);
+ QString fetchPart(const RecMail&mail,const RecPart&part);
static void imap_progress( size_t current, size_t maximum );
protected:
RecMail*parse_list_result(mailimap_msg_att*);
@@ -35,12 +37,12 @@ protected:
void searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body);
void searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion=0,QValueList<int>recList=QValueList<int>());
- void fillPlainBody(const RecMail&mail,RecBody&target_body);
void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description);
void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which);
void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which);
+ void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which);
/* just helpers */
static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which);
static QStringList address_list_to_stringlist(clist*list);
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
index fa967da..da5974c 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
@@ -372,81 +372,35 @@ void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mai
{
if (!mailDescription) {
return;
}
- QString sub;
+ QString sub,body_text;
+ RecPart singlePart;
+ QValueList<int> path;
+ fillSinglePart(singlePart,mailDescription);
switch (mailDescription->bd_type) {
case MAILIMAP_BODY_TYPE_1PART_MSG:
- target_body.setType("text");
- sub = mailDescription->bd_data.bd_type_text->bd_media_text;
- target_body.setSubtype(sub.lower());
- fillPlainBody(mail,target_body);
+ path.append(1);
+ body_text = fetchPart(mail,path,true);
+ target_body.setBodytext(body_text);
+ target_body.setDescription(singlePart);
break;
case MAILIMAP_BODY_TYPE_1PART_TEXT:
qDebug("Mediatype single: %s",mailDescription->bd_data.bd_type_text->bd_media_text);
- target_body.setType("text");
- sub = mailDescription->bd_data.bd_type_text->bd_media_text;
- target_body.setSubtype(sub.lower());
- fillPlainBody(mail,target_body);
+ path.append(1);
+ body_text = fetchPart(mail,path,true);
+ target_body.setBodytext(body_text);
+ target_body.setDescription(singlePart);
+ break;
+ case MAILIMAP_BODY_TYPE_1PART_BASIC:
+ qDebug("Single attachment");
+ target_body.setBodytext("");
+ target_body.addPart(singlePart);
break;
default:
break;
}
- return;
-}
-
-void IMAPwrapper::fillPlainBody(const RecMail&mail,RecBody&target_body)
-{
- const char *mb;
- QString body="";
- int err = MAILIMAP_NO_ERROR;
- clist *result;
- clistcell *current,*cur;
- mailimap_fetch_att *fetchAtt;
- mailimap_fetch_type *fetchType;
- mailimap_set *set;
-
- mb = mail.getMbox().latin1();
-
- if (!m_imap) {
- return;
- }
-
- result = clist_new();
- set = set = mailimap_set_new_single(mail.getNumber());
- mailimap_section * section = mailimap_section_new_text();
- fetchAtt = mailimap_fetch_att_new_body_peek_section(section);
- fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt);
- err = mailimap_fetch( m_imap, set, fetchType, &result );
- mailimap_set_free( set );
- mailimap_fetch_type_free( fetchType );
-
- if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) {
- mailimap_msg_att * msg_att;
- msg_att = (mailimap_msg_att*)current->data;
- mailimap_msg_att_item*msg_att_item;
- for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) {
- msg_att_item = (mailimap_msg_att_item*)clist_content(cur);
- if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) {
- if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) {
- char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part;
- msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L;
- if (text) {
- body = QString(text);
- free(text);
- } else {
- body = "";
- }
- }
- }
- }
-
- } else {
- qDebug("error fetching text: %s",m_imap->imap_response);
- }
- mailimap_fetch_list_free(result);
- target_body.setBodytext(body);
return;
}
QStringList IMAPwrapper::address_list_to_stringlist(clist*list)
@@ -489,9 +443,9 @@ QStringList IMAPwrapper::address_list_to_stringlist(clist*list)
}
return l;
}
-QString IMAPwrapper::fetchPart(const RecMail&mail,QValueList<int>&path,bool internal_call)
+QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call)
{
QString body("");
const char*mb;
int err;
@@ -583,19 +537,19 @@ void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mai
clist.append(count);
/* important: Check for is NULL 'cause a body can be empty! */
if (currentPart.Type()=="text" && target_body.Bodytext().isNull() ) {
QString body_text = fetchPart(mail,clist,true);
+ target_body.setDescription(currentPart);
target_body.setBodytext(body_text);
- target_body.setType(currentPart.Type());
- target_body.setSubtype(currentPart.Subtype());
} else {
QString id("");
for (unsigned int j = 0; j < clist.count();++j) {
- id+=(j>0?".":"");
+ id+=(j>0?" ":"");
id+=QString("%1").arg(clist[j]);
}
qDebug("ID= %s",id.latin1());
currentPart.setIdentifier(id);
+ currentPart.setPositionlist(clist);
target_body.addPart(currentPart);
}
}
}
@@ -613,8 +567,11 @@ void IMAPwrapper::fillSinglePart(RecPart&target_part,mailimap_body_type_1part*De
break;
case MAILIMAP_BODY_TYPE_1PART_BASIC:
fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic);
break;
+ case MAILIMAP_BODY_TYPE_1PART_MSG:
+ fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg);
+ break;
default:
break;
}
}
@@ -630,8 +587,24 @@ void IMAPwrapper::fillSingleTextPart(RecPart&target_part,mailimap_body_type_text
target_part.setLines(which->bd_lines);
fillBodyFields(target_part,which->bd_fields);
}
+void IMAPwrapper::fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which)
+{
+ if (!which) {
+ return;
+ }
+// QString sub;
+// sub = which->bd_media_text;
+// target_part.setSubtype(sub.lower());
+ qDebug("Message part");
+ /* we set this type to text/plain */
+ target_part.setType("text");
+ target_part.setSubtype("plain");
+ target_part.setLines(which->bd_lines);
+ fillBodyFields(target_part,which->bd_fields);
+}
+
void IMAPwrapper::fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which)
{
if (!which) {
return;
@@ -679,6 +652,42 @@ void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which)
clistcell*cur;
mailimap_single_body_fld_param*param;
for (cur = clist_begin(which->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));
+ }
}
+ mailimap_body_fld_enc*enc = which->bd_encoding;
+ QString encoding("");
+ switch (enc->enc_type) {
+ case MAILIMAP_BODY_FLD_ENC_7BIT:
+ encoding = "7bit";
+ break;
+ case MAILIMAP_BODY_FLD_ENC_8BIT:
+ encoding = "8bit";
+ break;
+ case MAILIMAP_BODY_FLD_ENC_BINARY:
+ encoding="binary";
+ break;
+ case MAILIMAP_BODY_FLD_ENC_BASE64:
+ encoding="base64";
+ break;
+ case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE:
+ encoding="quoted-printable";
+ break;
+ case MAILIMAP_BODY_FLD_ENC_OTHER:
+ default:
+ if (enc->enc_value) {
+ char*t=enc->enc_value;
+ encoding=QString(enc->enc_value);
+ enc->enc_value=0L;
+ free(t);
+ }
+ }
+ target_part.setEncoding(encoding);
+}
+
+QString IMAPwrapper::fetchPart(const RecMail&mail,const RecPart&part)
+{
+ return fetchPart(mail,part.Positionlist(),false);
}
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h
index 5ea45f3..95de215 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.h
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.h
@@ -7,8 +7,9 @@
struct mailimap;
struct mailimap_body_type_1part;
struct mailimap_body_type_text;
struct mailimap_body_type_basic;
+struct mailimap_body_type_msg;
struct mailimap_body_type_mpart;
struct mailimap_body_fields;
struct mailimap_msg_att;
class RecMail;
@@ -24,9 +25,10 @@ public:
virtual ~IMAPwrapper();
QList<IMAPFolder>* listFolders();
void listMessages(const QString & mailbox,QList<RecMail>&target );
RecBody fetchBody(const RecMail&mail);
- QString fetchPart(const RecMail&mail,QValueList<int>&path,bool internal_call=false);
+ QString fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false);
+ QString fetchPart(const RecMail&mail,const RecPart&part);
static void imap_progress( size_t current, size_t maximum );
protected:
RecMail*parse_list_result(mailimap_msg_att*);
@@ -35,12 +37,12 @@ protected:
void searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body);
void searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion=0,QValueList<int>recList=QValueList<int>());
- void fillPlainBody(const RecMail&mail,RecBody&target_body);
void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description);
void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which);
void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which);
+ void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which);
/* just helpers */
static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which);
static QStringList address_list_to_stringlist(clist*list);
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.cpp b/noncore/net/mail/libmailwrapper/mailtypes.cpp
index 6a66113..f56bb63 100644
--- a/noncore/net/mail/libmailwrapper/mailtypes.cpp
+++ b/noncore/net/mail/libmailwrapper/mailtypes.cpp
@@ -69,13 +69,10 @@ const QStringList& RecMail::Bcc()const
RecPart::RecPart()
: m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_lines(0)
{
-}
-
-RecPart::RecPart(const QString&identifier,const QString&type,const QString&subtype,const QString&encoding,unsigned int lines)
- : m_type(type),m_subtype(subtype),m_identifier(identifier),m_encoding(encoding),m_lines(lines)
-{
+ m_Parameters.clear();
+ m_poslist.clear();
}
RecPart::~RecPart()
{
@@ -130,10 +127,45 @@ void RecPart::setEncoding(const QString&encoding)
{
m_encoding = encoding;
}
+void RecPart::setParameters(const part_plist_t&list)
+{
+ m_Parameters = list;
+}
+
+const part_plist_t& RecPart::Parameters()const
+{
+ return m_Parameters;
+}
+
+void RecPart::addParameter(const QString&key,const QString&value)
+{
+ m_Parameters[key]=value;
+}
+
+const QString RecPart::searchParamter(const QString&key)const
+{
+ QString value("");
+ part_plist_t::ConstIterator it = m_Parameters.find(key);
+ if (it != m_Parameters.end()) {
+ value = it.data();
+ }
+ return value;
+}
+
+void RecPart::setPositionlist(const QValueList<int>&poslist)
+{
+ m_poslist = poslist;
+}
+
+const QValueList<int>& RecPart::Positionlist()const
+{
+ return m_poslist;
+}
+
RecBody::RecBody()
- : m_BodyText(),m_PartsList()
+ : m_BodyText(),m_PartsList(),m_description()
{
m_PartsList.setAutoDelete(true);
}
@@ -167,23 +199,13 @@ void RecBody::addPart(const RecPart& part)
RecPart*p = new RecPart(part);
m_PartsList.append(p);
}
-void RecBody::setType(const QString&type)
+void RecBody::setDescription(const RecPart&des)
{
- m_type = type;
+ m_description = des;
}
-const QString& RecBody::Type()const
+const RecPart& RecBody::Description()const
{
- return m_type;
-}
-
-void RecBody::setSubtype(const QString&type)
-{
- m_subtype = type;
-}
-
-const QString& RecBody::Subtype()const
-{
- return m_subtype;
+ return m_description;
}
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.h b/noncore/net/mail/libmailwrapper/mailtypes.h
index 900f10a..60db527 100644
--- a/noncore/net/mail/libmailwrapper/mailtypes.h
+++ b/noncore/net/mail/libmailwrapper/mailtypes.h
@@ -11,8 +11,10 @@
#include <qlist.h>
#include <qbitarray.h>
#include <qstring.h>
#include <qstringlist.h>
+#include <qmap.h>
+#include <qvaluelist.h>
/* a class to describe mails in a mailbox */
/* Attention!
From programmers point of view it would make sense to
@@ -67,16 +69,21 @@ protected:
void init();
void copy_old(const RecMail&old);
};
+typedef QMap<QString,QString> part_plist_t;
+
class RecPart
{
protected:
QString m_type,m_subtype,m_identifier,m_encoding;
unsigned int m_lines;
+ part_plist_t m_Parameters;
+ /* describes the position in the mail */
+ QValueList<int> m_poslist;
+
public:
RecPart();
- RecPart(const QString&identifier,const QString&type="",const QString&subtype="",const QString&encoding="BASE64",unsigned int lines=0);
virtual ~RecPart();
const QString&Type()const;
void setType(const QString&type);
@@ -87,26 +94,32 @@ public:
const QString&Encoding()const;
void setEncoding(const QString&encoding);
void setLines(unsigned int lines);
const unsigned int Lines()const;
+
+ void setParameters(const part_plist_t&list);
+ const part_plist_t&Parameters()const;
+ void addParameter(const QString&key,const QString&value);
+ const QString searchParamter(const QString&key)const;
+ void setPositionlist(const QValueList<int>&poslist);
+ const QValueList<int>& Positionlist()const;
};
class RecBody
{
protected:
- QString m_BodyText,m_type,m_subtype;
+ QString m_BodyText;
QList<RecPart> m_PartsList;
+ RecPart m_description;
public:
RecBody();
virtual ~RecBody();
void setBodytext(const QString&);
const QString& Bodytext()const;
- void setType(const QString&);
- const QString&Type()const;
- void setSubtype(const QString&);
- const QString&Subtype()const;
+ void setDescription(const RecPart&des);
+ const RecPart& Description()const;
void setParts(const QList<RecPart>&parts);
const QList<RecPart>& Parts()const;
void addPart(const RecPart&part);
diff --git a/noncore/net/mail/mailtypes.cpp b/noncore/net/mail/mailtypes.cpp
index 6a66113..f56bb63 100644
--- a/noncore/net/mail/mailtypes.cpp
+++ b/noncore/net/mail/mailtypes.cpp
@@ -69,13 +69,10 @@ const QStringList& RecMail::Bcc()const
RecPart::RecPart()
: m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_lines(0)
{
-}
-
-RecPart::RecPart(const QString&identifier,const QString&type,const QString&subtype,const QString&encoding,unsigned int lines)
- : m_type(type),m_subtype(subtype),m_identifier(identifier),m_encoding(encoding),m_lines(lines)
-{
+ m_Parameters.clear();
+ m_poslist.clear();
}
RecPart::~RecPart()
{
@@ -130,10 +127,45 @@ void RecPart::setEncoding(const QString&encoding)
{
m_encoding = encoding;
}
+void RecPart::setParameters(const part_plist_t&list)
+{
+ m_Parameters = list;
+}
+
+const part_plist_t& RecPart::Parameters()const
+{
+ return m_Parameters;
+}
+
+void RecPart::addParameter(const QString&key,const QString&value)
+{
+ m_Parameters[key]=value;
+}
+
+const QString RecPart::searchParamter(const QString&key)const
+{
+ QString value("");
+ part_plist_t::ConstIterator it = m_Parameters.find(key);
+ if (it != m_Parameters.end()) {
+ value = it.data();
+ }
+ return value;
+}
+
+void RecPart::setPositionlist(const QValueList<int>&poslist)
+{
+ m_poslist = poslist;
+}
+
+const QValueList<int>& RecPart::Positionlist()const
+{
+ return m_poslist;
+}
+
RecBody::RecBody()
- : m_BodyText(),m_PartsList()
+ : m_BodyText(),m_PartsList(),m_description()
{
m_PartsList.setAutoDelete(true);
}
@@ -167,23 +199,13 @@ void RecBody::addPart(const RecPart& part)
RecPart*p = new RecPart(part);
m_PartsList.append(p);
}
-void RecBody::setType(const QString&type)
+void RecBody::setDescription(const RecPart&des)
{
- m_type = type;
+ m_description = des;
}
-const QString& RecBody::Type()const
+const RecPart& RecBody::Description()const
{
- return m_type;
-}
-
-void RecBody::setSubtype(const QString&type)
-{
- m_subtype = type;
-}
-
-const QString& RecBody::Subtype()const
-{
- return m_subtype;
+ return m_description;
}
diff --git a/noncore/net/mail/mailtypes.h b/noncore/net/mail/mailtypes.h
index 900f10a..60db527 100644
--- a/noncore/net/mail/mailtypes.h
+++ b/noncore/net/mail/mailtypes.h
@@ -11,8 +11,10 @@
#include <qlist.h>
#include <qbitarray.h>
#include <qstring.h>
#include <qstringlist.h>
+#include <qmap.h>
+#include <qvaluelist.h>
/* a class to describe mails in a mailbox */
/* Attention!
From programmers point of view it would make sense to
@@ -67,16 +69,21 @@ protected:
void init();
void copy_old(const RecMail&old);
};
+typedef QMap<QString,QString> part_plist_t;
+
class RecPart
{
protected:
QString m_type,m_subtype,m_identifier,m_encoding;
unsigned int m_lines;
+ part_plist_t m_Parameters;
+ /* describes the position in the mail */
+ QValueList<int> m_poslist;
+
public:
RecPart();
- RecPart(const QString&identifier,const QString&type="",const QString&subtype="",const QString&encoding="BASE64",unsigned int lines=0);
virtual ~RecPart();
const QString&Type()const;
void setType(const QString&type);
@@ -87,26 +94,32 @@ public:
const QString&Encoding()const;
void setEncoding(const QString&encoding);
void setLines(unsigned int lines);
const unsigned int Lines()const;
+
+ void setParameters(const part_plist_t&list);
+ const part_plist_t&Parameters()const;
+ void addParameter(const QString&key,const QString&value);
+ const QString searchParamter(const QString&key)const;
+ void setPositionlist(const QValueList<int>&poslist);
+ const QValueList<int>& Positionlist()const;
};
class RecBody
{
protected:
- QString m_BodyText,m_type,m_subtype;
+ QString m_BodyText;
QList<RecPart> m_PartsList;
+ RecPart m_description;
public:
RecBody();
virtual ~RecBody();
void setBodytext(const QString&);
const QString& Bodytext()const;
- void setType(const QString&);
- const QString&Type()const;
- void setSubtype(const QString&);
- const QString&Subtype()const;
+ void setDescription(const RecPart&des);
+ const RecPart& Description()const;
void setParts(const QList<RecPart>&parts);
const QList<RecPart>& Parts()const;
void addPart(const RecPart&part);