summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/imapwrapper.cpp214
-rw-r--r--noncore/net/mail/imapwrapper.h15
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp214
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.h15
-rw-r--r--noncore/net/mail/libmailwrapper/mailtypes.cpp39
-rw-r--r--noncore/net/mail/libmailwrapper/mailtypes.h16
-rw-r--r--noncore/net/mail/mailtypes.cpp39
-rw-r--r--noncore/net/mail/mailtypes.h16
8 files changed, 456 insertions, 112 deletions
diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp
index e6e9fc9..27f1410 100644
--- a/noncore/net/mail/imapwrapper.cpp
+++ b/noncore/net/mail/imapwrapper.cpp
@@ -20,26 +20,29 @@ void IMAPwrapper::imap_progress( size_t current, size_t maximum )
{
qDebug( "IMAP: %i of %i", current, maximum );
}
void IMAPwrapper::login()
{
- logout();
const char *server, *user, *pass;
uint16_t port;
int err = MAILIMAP_NO_ERROR;
+ /* we are connected this moment */
+ /* TODO: setup a timer holding the line or if connection closed - delete the value */
+ if (m_imap) {
+ return;
+ }
server = account->getServer().latin1();
port = account->getPort().toUInt();
user = account->getUser().latin1();
pass = account->getPassword().latin1();
m_imap = mailimap_new( 20, &imap_progress );
/* connect */
- // err = mailimap_socket_connect( m_imap, (char*)server, port );
- if (account->getSSL()) {
+ if (account->getSSL()) {
err = mailimap_ssl_connect( m_imap, (char*)server, port );
} else {
err = mailimap_socket_connect( m_imap, (char*)server, port );
}
if ( err != MAILIMAP_NO_ERROR &&
@@ -74,77 +77,68 @@ void IMAPwrapper::logout()
void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
{
const char *mb;
int err = MAILIMAP_NO_ERROR;
clist *result;
clistcell *current;
- mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate;
+// mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate,*fetchAttSize;
mailimap_fetch_type *fetchType;
mailimap_set *set;
mb = mailbox.latin1();
login();
if (!m_imap) {
return;
}
/* select mailbox READONLY for operations */
err = mailimap_examine( m_imap, (char*)mb);
if ( err != MAILIMAP_NO_ERROR ) {
qDebug("error selecting mailbox: %s",m_imap->imap_response);
- logout();
return;
}
int last = m_imap->imap_selection_info->sel_exists;
if (last == 0) {
qDebug("mailbox has no mails");
- logout();
return;
}
result = clist_new();
/* the range has to start at 1!!! not with 0!!!! */
set = mailimap_set_new_interval( 1, last );
- fetchAtt = mailimap_fetch_att_new_envelope();
- fetchAttFlags = mailimap_fetch_att_new_flags();
- fetchAttDate = mailimap_fetch_att_new_internaldate();
-
- //fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt);
fetchType = mailimap_fetch_type_new_fetch_att_list_empty();
- mailimap_fetch_type_new_fetch_att_list_add(fetchType,fetchAtt);
- mailimap_fetch_type_new_fetch_att_list_add(fetchType,fetchAttFlags);
- mailimap_fetch_type_new_fetch_att_list_add(fetchType,fetchAttDate);
+ mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope());
+ mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags());
+ mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate());
+ mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size());
err = mailimap_fetch( m_imap, set, fetchType, &result );
mailimap_set_free( set );
- /* cleans up the fetch_att's too! */
mailimap_fetch_type_free( fetchType );
QString date,subject,from;
if ( err == MAILIMAP_NO_ERROR ) {
- current = clist_begin(result);
+
mailimap_msg_att * msg_att;
int i = 0;
- while ( current != 0 ) {
+ for (current = clist_begin(result); current != 0; current=clist_next(current)) {
++i;
msg_att = (mailimap_msg_att*)current->data;
RecMail*m = parse_list_result(msg_att);
if (m) {
m->setNumber(i);
m->setMbox(mailbox);
target.append(m);
}
- current = current->next;
}
} else {
qDebug("Error fetching headers: %s",m_imap->imap_response);
}
- logout();
- clist_free(result);
+ mailimap_fetch_list_free(result);
}
QList<IMAPFolder>* IMAPwrapper::listFolders()
{
const char *path, *mask;
int err = MAILIMAP_NO_ERROR;
@@ -216,31 +210,31 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
{
RecMail * m = 0;
mailimap_msg_att_item *item=0;
clistcell *current,*c,*cf;
mailimap_msg_att_dynamic*flist;
mailimap_flag_fetch*cflag;
+ int size;
QBitArray mFlags(7);
QStringList addresslist;
if (!m_att) {
return m;
}
-
- c = clist_begin(m_att->att_list);
- while ( c ) {
+ m = new RecMail();
+ for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) {
current = c;
- c = c->next;
+ size = 0;
item = (mailimap_msg_att_item*)current->data;
if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) {
flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn;
if (!flist->att_list) {
continue;
}
cf = flist->att_list->first;
- while (cf) {
+ for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) {
cflag = (mailimap_flag_fetch*)cf->data;
if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) {
switch (cflag->fl_flag->fl_type) {
case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */
mFlags.setBit(FLAG_ANSWERED);
break;
@@ -263,21 +257,17 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
default:
break;
}
} else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) {
mFlags.setBit(FLAG_RECENT);
}
- cf = cf->next;
}
continue;
}
- if ( item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_RFC822_HEADER ) {
- qDebug( "header: \n%s", item->att_data.att_static->att_data.att_rfc822_header );
- } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) {
+ if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) {
mailimap_envelope * head = item->att_data.att_static->att_data.att_env;
- m = new RecMail();
m->setDate(head->env_date);
m->setSubject(head->env_subject);
if (head->env_from!=NULL) {
addresslist = address_list_to_stringlist(head->env_from->frm_list);
if (addresslist.count()) {
m->setFrom(addresslist.first());
@@ -304,23 +294,24 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
m->setMsgid(QString(head->env_message_id));
} else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) {
mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date;
QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec));
qDebug("%i %i %i - %i %i %i",d->dt_year,d->dt_month,d->dt_day,d->dt_hour,d->dt_min,d->dt_sec);
qDebug(da.toString());
- } else {
- qDebug("Another type");
+ } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) {
+ size = item->att_data.att_static->att_data.att_rfc822_size;
}
}
/* msg is already deleted */
if (mFlags.testBit(FLAG_DELETED) && m) {
delete m;
m = 0;
}
if (m) {
m->setFlags(mFlags);
+ m->setMsgsize(size);
}
return m;
}
RecBody IMAPwrapper::fetchBody(const RecMail&mail)
{
@@ -341,59 +332,72 @@ RecBody IMAPwrapper::fetchBody(const RecMail&mail)
return body;
}
/* select mailbox READONLY for operations */
err = mailimap_examine( m_imap, (char*)mb);
if ( err != MAILIMAP_NO_ERROR ) {
qDebug("error selecting mailbox: %s",m_imap->imap_response);
- logout();
return body;
}
+
result = clist_new();
/* the range has to start at 1!!! not with 0!!!! */
set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() );
- fetchAtt = mailimap_fetch_att_new_body();
+ fetchAtt = mailimap_fetch_att_new_bodystructure();
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*item = (mailimap_msg_att_item*)msg_att->att_list->first->data;
body_desc = item->att_data.att_static->att_data.att_body;
if (body_desc->bd_type==MAILIMAP_BODY_1PART) {
searchBodyText(mail,body_desc->bd_data.bd_body_1part,body);
- } else {
+ } else if (body_desc->bd_type==MAILIMAP_BODY_MPART) {
+ qDebug("Mulitpart mail");
+ searchBodyText(mail,body_desc->bd_data.bd_body_mpart,body,0);
}
-
} else {
qDebug("error fetching body: %s",m_imap->imap_response);
}
-
- clist_free(result);
- logout();
+ mailimap_fetch_list_free(result);
return body;
}
+/* this routine is just called when the mail has only ONE part.
+ for filling the parts of a multi-part-message there are other
+ routines 'cause we can not simply fetch the whole body. */
void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body)
{
if (!mailDescription) {
return;
}
+ QString sub;
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);
+ break;
case MAILIMAP_BODY_TYPE_1PART_TEXT:
- fillPlainBody(mail,target_body,mailDescription->bd_data.bd_type_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);
break;
default:
break;
}
return;
}
-void IMAPwrapper::fillPlainBody(const RecMail&mail,RecBody&target_body, mailimap_body_type_text * bd)
+void IMAPwrapper::fillPlainBody(const RecMail&mail,RecBody&target_body)
{
const char *mb;
QString body="";
int err = MAILIMAP_NO_ERROR;
clist *result;
clistcell *current,*cur;
@@ -423,24 +427,26 @@ void IMAPwrapper::fillPlainBody(const RecMail&mail,RecBody&target_body, mailimap
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;
- int length = msg_att_item->att_data.att_static->att_data.att_body_section->sec_length;
msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L;
- body = QString(text);
- free(text);
+ if (text) {
+ body = QString(text);
+ free(text);
+ } else {
+ body = "";
+ }
}
}
}
} else {
qDebug("error fetching text: %s",m_imap->imap_response);
}
- //clist_free(result);
mailimap_fetch_list_free(result);
target_body.setBodytext(body);
return;
}
QStringList IMAPwrapper::address_list_to_stringlist(clist*list)
@@ -450,19 +456,17 @@ QStringList IMAPwrapper::address_list_to_stringlist(clist*list)
bool named_from;
clistcell *current = NULL;
mailimap_address * current_address=NULL;
if (!list) {
return l;
}
- current = clist_begin(list);
unsigned int count = 0;
- while (current!= NULL) {
+ for (current=clist_begin(list);current!= NULL;current=clist_next(current)) {
from = "";
named_from = false;
current_address=(mailimap_address*)current->data;
- current = current->next;
if (current_address->ad_personal_name){
from+=QString(current_address->ad_personal_name);
from+=" ";
named_from = true;
}
if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) {
@@ -482,6 +486,120 @@ QStringList IMAPwrapper::address_list_to_stringlist(clist*list)
if (++count > 99) {
break;
}
}
return l;
}
+
+void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion)
+{
+ /* current_recursion is for avoiding ugly mails which has a to deep body-structure */
+ if (!mailDescription||current_recursion==2) {
+ return;
+ }
+ qDebug("Mediatype: %s",mailDescription->bd_media_subtype);
+ clistcell*current;
+ mailimap_body*current_body;
+ for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) {
+ current_body = (mailimap_body*)current->data;
+ if (current_body->bd_type==MAILIMAP_BODY_MPART) {
+ searchBodyText(mail,current_body->bd_data.bd_body_mpart,target_body,current_recursion+1);
+ } else if (current_body->bd_type==MAILIMAP_BODY_1PART){
+ RecPart currentPart;
+ fillSinglePart(currentPart,current_body->bd_data.bd_body_1part);
+ target_body.addPart(currentPart);
+ }
+ }
+ if (current_recursion==0) {
+
+ }
+}
+
+void IMAPwrapper::fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description)
+{
+ if (!Description) {
+ return;
+ }
+ switch (Description->bd_type) {
+ case MAILIMAP_BODY_TYPE_1PART_TEXT:
+ target_part.setType("text");
+ fillSingleTextPart(target_part,Description->bd_data.bd_type_text);
+ break;
+ case MAILIMAP_BODY_TYPE_1PART_BASIC:
+ fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic);
+ break;
+ default:
+ break;
+ }
+}
+
+void IMAPwrapper::fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which)
+{
+ if (!which) {
+ return;
+ }
+ QString sub;
+ sub = which->bd_media_text;
+ target_part.setSubtype(sub.lower());
+ 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;
+ }
+ QString type,sub;
+ switch (which->bd_media_basic->med_type) {
+ case MAILIMAP_MEDIA_BASIC_APPLICATION:
+ type = "application";
+ break;
+ case MAILIMAP_MEDIA_BASIC_AUDIO:
+ type = "audio";
+ break;
+ case MAILIMAP_MEDIA_BASIC_IMAGE:
+ type = "image";
+ break;
+ case MAILIMAP_MEDIA_BASIC_MESSAGE:
+ type = "message";
+ break;
+ case MAILIMAP_MEDIA_BASIC_VIDEO:
+ type = "video";
+ break;
+ case MAILIMAP_MEDIA_BASIC_OTHER:
+ default:
+ if (which->bd_media_basic->med_basic_type) {
+ type = which->bd_media_basic->med_basic_type;
+ } else {
+ type = "";
+ }
+ break;
+ }
+ if (which->bd_media_basic->med_subtype) {
+ sub = which->bd_media_basic->med_subtype;
+ } else {
+ sub = "";
+ }
+ qDebug("Type = %s/%s",type.latin1(),sub.latin1());
+ target_part.setType(type.lower());
+ target_part.setSubtype(sub.lower());
+ fillBodyFields(target_part,which->bd_fields);
+}
+
+void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which)
+{
+ if (!which) return;
+ if (which->bd_id) {
+ qDebug("Part ID = %s",which->bd_id);
+ target_part.setIdentifier(which->bd_id);
+ } else {
+ qDebug("ID empty");
+ target_part.setIdentifier("");
+ }
+
+ 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;
+ }
+}
diff --git a/noncore/net/mail/imapwrapper.h b/noncore/net/mail/imapwrapper.h
index 90f3004..f809edb 100644
--- a/noncore/net/mail/imapwrapper.h
+++ b/noncore/net/mail/imapwrapper.h
@@ -4,15 +4,19 @@
#include <qlist.h>
#include "mailwrapper.h"
struct mailimap;
struct mailimap_body_type_1part;
struct mailimap_body_type_text;
+struct mailimap_body_type_basic;
+struct mailimap_body_type_mpart;
+struct mailimap_body_fields;
struct mailimap_msg_att;
class RecMail;
class RecBody;
+class RecPart;
class IMAPwrapper : public QObject
{
Q_OBJECT
public:
@@ -24,14 +28,23 @@ public:
static void imap_progress( size_t current, size_t maximum );
protected:
RecMail*parse_list_result(mailimap_msg_att*);
void login();
void logout();
+
void searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body);
- void fillPlainBody(const RecMail&mail,RecBody&target_body, mailimap_body_type_text * text_body);
+ void searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion);
+
+ 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);
+
+ /* just helpers */
+ static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which);
static QStringList address_list_to_stringlist(clist*list);
private:
IMAPaccount *account;
mailimap *m_imap;
};
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
index e6e9fc9..27f1410 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
@@ -20,26 +20,29 @@ void IMAPwrapper::imap_progress( size_t current, size_t maximum )
{
qDebug( "IMAP: %i of %i", current, maximum );
}
void IMAPwrapper::login()
{
- logout();
const char *server, *user, *pass;
uint16_t port;
int err = MAILIMAP_NO_ERROR;
+ /* we are connected this moment */
+ /* TODO: setup a timer holding the line or if connection closed - delete the value */
+ if (m_imap) {
+ return;
+ }
server = account->getServer().latin1();
port = account->getPort().toUInt();
user = account->getUser().latin1();
pass = account->getPassword().latin1();
m_imap = mailimap_new( 20, &imap_progress );
/* connect */
- // err = mailimap_socket_connect( m_imap, (char*)server, port );
- if (account->getSSL()) {
+ if (account->getSSL()) {
err = mailimap_ssl_connect( m_imap, (char*)server, port );
} else {
err = mailimap_socket_connect( m_imap, (char*)server, port );
}
if ( err != MAILIMAP_NO_ERROR &&
@@ -74,77 +77,68 @@ void IMAPwrapper::logout()
void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
{
const char *mb;
int err = MAILIMAP_NO_ERROR;
clist *result;
clistcell *current;
- mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate;
+// mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate,*fetchAttSize;
mailimap_fetch_type *fetchType;
mailimap_set *set;
mb = mailbox.latin1();
login();
if (!m_imap) {
return;
}
/* select mailbox READONLY for operations */
err = mailimap_examine( m_imap, (char*)mb);
if ( err != MAILIMAP_NO_ERROR ) {
qDebug("error selecting mailbox: %s",m_imap->imap_response);
- logout();
return;
}
int last = m_imap->imap_selection_info->sel_exists;
if (last == 0) {
qDebug("mailbox has no mails");
- logout();
return;
}
result = clist_new();
/* the range has to start at 1!!! not with 0!!!! */
set = mailimap_set_new_interval( 1, last );
- fetchAtt = mailimap_fetch_att_new_envelope();
- fetchAttFlags = mailimap_fetch_att_new_flags();
- fetchAttDate = mailimap_fetch_att_new_internaldate();
-
- //fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt);
fetchType = mailimap_fetch_type_new_fetch_att_list_empty();
- mailimap_fetch_type_new_fetch_att_list_add(fetchType,fetchAtt);
- mailimap_fetch_type_new_fetch_att_list_add(fetchType,fetchAttFlags);
- mailimap_fetch_type_new_fetch_att_list_add(fetchType,fetchAttDate);
+ mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope());
+ mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags());
+ mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate());
+ mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size());
err = mailimap_fetch( m_imap, set, fetchType, &result );
mailimap_set_free( set );
- /* cleans up the fetch_att's too! */
mailimap_fetch_type_free( fetchType );
QString date,subject,from;
if ( err == MAILIMAP_NO_ERROR ) {
- current = clist_begin(result);
+
mailimap_msg_att * msg_att;
int i = 0;
- while ( current != 0 ) {
+ for (current = clist_begin(result); current != 0; current=clist_next(current)) {
++i;
msg_att = (mailimap_msg_att*)current->data;
RecMail*m = parse_list_result(msg_att);
if (m) {
m->setNumber(i);
m->setMbox(mailbox);
target.append(m);
}
- current = current->next;
}
} else {
qDebug("Error fetching headers: %s",m_imap->imap_response);
}
- logout();
- clist_free(result);
+ mailimap_fetch_list_free(result);
}
QList<IMAPFolder>* IMAPwrapper::listFolders()
{
const char *path, *mask;
int err = MAILIMAP_NO_ERROR;
@@ -216,31 +210,31 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
{
RecMail * m = 0;
mailimap_msg_att_item *item=0;
clistcell *current,*c,*cf;
mailimap_msg_att_dynamic*flist;
mailimap_flag_fetch*cflag;
+ int size;
QBitArray mFlags(7);
QStringList addresslist;
if (!m_att) {
return m;
}
-
- c = clist_begin(m_att->att_list);
- while ( c ) {
+ m = new RecMail();
+ for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) {
current = c;
- c = c->next;
+ size = 0;
item = (mailimap_msg_att_item*)current->data;
if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) {
flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn;
if (!flist->att_list) {
continue;
}
cf = flist->att_list->first;
- while (cf) {
+ for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) {
cflag = (mailimap_flag_fetch*)cf->data;
if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) {
switch (cflag->fl_flag->fl_type) {
case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */
mFlags.setBit(FLAG_ANSWERED);
break;
@@ -263,21 +257,17 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
default:
break;
}
} else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) {
mFlags.setBit(FLAG_RECENT);
}
- cf = cf->next;
}
continue;
}
- if ( item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_RFC822_HEADER ) {
- qDebug( "header: \n%s", item->att_data.att_static->att_data.att_rfc822_header );
- } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) {
+ if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) {
mailimap_envelope * head = item->att_data.att_static->att_data.att_env;
- m = new RecMail();
m->setDate(head->env_date);
m->setSubject(head->env_subject);
if (head->env_from!=NULL) {
addresslist = address_list_to_stringlist(head->env_from->frm_list);
if (addresslist.count()) {
m->setFrom(addresslist.first());
@@ -304,23 +294,24 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
m->setMsgid(QString(head->env_message_id));
} else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) {
mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date;
QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec));
qDebug("%i %i %i - %i %i %i",d->dt_year,d->dt_month,d->dt_day,d->dt_hour,d->dt_min,d->dt_sec);
qDebug(da.toString());
- } else {
- qDebug("Another type");
+ } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) {
+ size = item->att_data.att_static->att_data.att_rfc822_size;
}
}
/* msg is already deleted */
if (mFlags.testBit(FLAG_DELETED) && m) {
delete m;
m = 0;
}
if (m) {
m->setFlags(mFlags);
+ m->setMsgsize(size);
}
return m;
}
RecBody IMAPwrapper::fetchBody(const RecMail&mail)
{
@@ -341,59 +332,72 @@ RecBody IMAPwrapper::fetchBody(const RecMail&mail)
return body;
}
/* select mailbox READONLY for operations */
err = mailimap_examine( m_imap, (char*)mb);
if ( err != MAILIMAP_NO_ERROR ) {
qDebug("error selecting mailbox: %s",m_imap->imap_response);
- logout();
return body;
}
+
result = clist_new();
/* the range has to start at 1!!! not with 0!!!! */
set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() );
- fetchAtt = mailimap_fetch_att_new_body();
+ fetchAtt = mailimap_fetch_att_new_bodystructure();
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*item = (mailimap_msg_att_item*)msg_att->att_list->first->data;
body_desc = item->att_data.att_static->att_data.att_body;
if (body_desc->bd_type==MAILIMAP_BODY_1PART) {
searchBodyText(mail,body_desc->bd_data.bd_body_1part,body);
- } else {
+ } else if (body_desc->bd_type==MAILIMAP_BODY_MPART) {
+ qDebug("Mulitpart mail");
+ searchBodyText(mail,body_desc->bd_data.bd_body_mpart,body,0);
}
-
} else {
qDebug("error fetching body: %s",m_imap->imap_response);
}
-
- clist_free(result);
- logout();
+ mailimap_fetch_list_free(result);
return body;
}
+/* this routine is just called when the mail has only ONE part.
+ for filling the parts of a multi-part-message there are other
+ routines 'cause we can not simply fetch the whole body. */
void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body)
{
if (!mailDescription) {
return;
}
+ QString sub;
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);
+ break;
case MAILIMAP_BODY_TYPE_1PART_TEXT:
- fillPlainBody(mail,target_body,mailDescription->bd_data.bd_type_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);
break;
default:
break;
}
return;
}
-void IMAPwrapper::fillPlainBody(const RecMail&mail,RecBody&target_body, mailimap_body_type_text * bd)
+void IMAPwrapper::fillPlainBody(const RecMail&mail,RecBody&target_body)
{
const char *mb;
QString body="";
int err = MAILIMAP_NO_ERROR;
clist *result;
clistcell *current,*cur;
@@ -423,24 +427,26 @@ void IMAPwrapper::fillPlainBody(const RecMail&mail,RecBody&target_body, mailimap
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;
- int length = msg_att_item->att_data.att_static->att_data.att_body_section->sec_length;
msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L;
- body = QString(text);
- free(text);
+ if (text) {
+ body = QString(text);
+ free(text);
+ } else {
+ body = "";
+ }
}
}
}
} else {
qDebug("error fetching text: %s",m_imap->imap_response);
}
- //clist_free(result);
mailimap_fetch_list_free(result);
target_body.setBodytext(body);
return;
}
QStringList IMAPwrapper::address_list_to_stringlist(clist*list)
@@ -450,19 +456,17 @@ QStringList IMAPwrapper::address_list_to_stringlist(clist*list)
bool named_from;
clistcell *current = NULL;
mailimap_address * current_address=NULL;
if (!list) {
return l;
}
- current = clist_begin(list);
unsigned int count = 0;
- while (current!= NULL) {
+ for (current=clist_begin(list);current!= NULL;current=clist_next(current)) {
from = "";
named_from = false;
current_address=(mailimap_address*)current->data;
- current = current->next;
if (current_address->ad_personal_name){
from+=QString(current_address->ad_personal_name);
from+=" ";
named_from = true;
}
if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) {
@@ -482,6 +486,120 @@ QStringList IMAPwrapper::address_list_to_stringlist(clist*list)
if (++count > 99) {
break;
}
}
return l;
}
+
+void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion)
+{
+ /* current_recursion is for avoiding ugly mails which has a to deep body-structure */
+ if (!mailDescription||current_recursion==2) {
+ return;
+ }
+ qDebug("Mediatype: %s",mailDescription->bd_media_subtype);
+ clistcell*current;
+ mailimap_body*current_body;
+ for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) {
+ current_body = (mailimap_body*)current->data;
+ if (current_body->bd_type==MAILIMAP_BODY_MPART) {
+ searchBodyText(mail,current_body->bd_data.bd_body_mpart,target_body,current_recursion+1);
+ } else if (current_body->bd_type==MAILIMAP_BODY_1PART){
+ RecPart currentPart;
+ fillSinglePart(currentPart,current_body->bd_data.bd_body_1part);
+ target_body.addPart(currentPart);
+ }
+ }
+ if (current_recursion==0) {
+
+ }
+}
+
+void IMAPwrapper::fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description)
+{
+ if (!Description) {
+ return;
+ }
+ switch (Description->bd_type) {
+ case MAILIMAP_BODY_TYPE_1PART_TEXT:
+ target_part.setType("text");
+ fillSingleTextPart(target_part,Description->bd_data.bd_type_text);
+ break;
+ case MAILIMAP_BODY_TYPE_1PART_BASIC:
+ fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic);
+ break;
+ default:
+ break;
+ }
+}
+
+void IMAPwrapper::fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which)
+{
+ if (!which) {
+ return;
+ }
+ QString sub;
+ sub = which->bd_media_text;
+ target_part.setSubtype(sub.lower());
+ 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;
+ }
+ QString type,sub;
+ switch (which->bd_media_basic->med_type) {
+ case MAILIMAP_MEDIA_BASIC_APPLICATION:
+ type = "application";
+ break;
+ case MAILIMAP_MEDIA_BASIC_AUDIO:
+ type = "audio";
+ break;
+ case MAILIMAP_MEDIA_BASIC_IMAGE:
+ type = "image";
+ break;
+ case MAILIMAP_MEDIA_BASIC_MESSAGE:
+ type = "message";
+ break;
+ case MAILIMAP_MEDIA_BASIC_VIDEO:
+ type = "video";
+ break;
+ case MAILIMAP_MEDIA_BASIC_OTHER:
+ default:
+ if (which->bd_media_basic->med_basic_type) {
+ type = which->bd_media_basic->med_basic_type;
+ } else {
+ type = "";
+ }
+ break;
+ }
+ if (which->bd_media_basic->med_subtype) {
+ sub = which->bd_media_basic->med_subtype;
+ } else {
+ sub = "";
+ }
+ qDebug("Type = %s/%s",type.latin1(),sub.latin1());
+ target_part.setType(type.lower());
+ target_part.setSubtype(sub.lower());
+ fillBodyFields(target_part,which->bd_fields);
+}
+
+void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which)
+{
+ if (!which) return;
+ if (which->bd_id) {
+ qDebug("Part ID = %s",which->bd_id);
+ target_part.setIdentifier(which->bd_id);
+ } else {
+ qDebug("ID empty");
+ target_part.setIdentifier("");
+ }
+
+ 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;
+ }
+}
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h
index 90f3004..f809edb 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.h
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.h
@@ -4,15 +4,19 @@
#include <qlist.h>
#include "mailwrapper.h"
struct mailimap;
struct mailimap_body_type_1part;
struct mailimap_body_type_text;
+struct mailimap_body_type_basic;
+struct mailimap_body_type_mpart;
+struct mailimap_body_fields;
struct mailimap_msg_att;
class RecMail;
class RecBody;
+class RecPart;
class IMAPwrapper : public QObject
{
Q_OBJECT
public:
@@ -24,14 +28,23 @@ public:
static void imap_progress( size_t current, size_t maximum );
protected:
RecMail*parse_list_result(mailimap_msg_att*);
void login();
void logout();
+
void searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body);
- void fillPlainBody(const RecMail&mail,RecBody&target_body, mailimap_body_type_text * text_body);
+ void searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion);
+
+ 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);
+
+ /* just helpers */
+ static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which);
static QStringList address_list_to_stringlist(clist*list);
private:
IMAPaccount *account;
mailimap *m_imap;
};
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.cpp b/noncore/net/mail/libmailwrapper/mailtypes.cpp
index f9e5794..0e3174d 100644
--- a/noncore/net/mail/libmailwrapper/mailtypes.cpp
+++ b/noncore/net/mail/libmailwrapper/mailtypes.cpp
@@ -1,11 +1,11 @@
#include "mailtypes.h"
RecMail::RecMail()
- :subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7)
+ :subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7)
{
init();
}
RecMail::RecMail(const RecMail&old)
:subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7)
@@ -18,12 +18,13 @@ RecMail::RecMail(const RecMail&old)
void RecMail::copy_old(const RecMail&old)
{
subject = old.subject;
date = old.date;
mbox = old.mbox;
msg_id = old.msg_id;
+ msg_size = old.msg_size;
msg_number = old.msg_number;
from = old.from;
msg_flags = old.msg_flags;
to = old.to;
cc = old.cc;
bcc = old.bcc;
@@ -64,25 +65,35 @@ void RecMail::setBcc(const QStringList&list)
const QStringList& RecMail::Bcc()const
{
return bcc;
}
RecPart::RecPart()
- : m_type(""),m_subtype(""),m_identifier(""),m_encoding("")
+ : 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)
- : m_type(type),m_subtype(subtype),m_identifier(identifier),m_encoding(encoding)
+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)
{
}
RecPart::~RecPart()
{
}
+void RecPart::setLines(unsigned int lines)
+{
+ m_lines = lines;
+}
+
+const unsigned int RecPart::Lines()const
+{
+ return m_lines;
+}
+
const QString& RecPart::Type()const
{
return m_type;
}
void RecPart::setType(const QString&type)
@@ -153,6 +164,26 @@ const QList<RecPart>& RecBody::Parts()const
void RecBody::addPart(const RecPart& part)
{
RecPart*p = new RecPart(part);
m_PartsList.append(p);
}
+
+void RecBody::setType(const QString&type)
+{
+ m_type = type;
+}
+
+const QString& RecBody::Type()const
+{
+ return m_type;
+}
+
+void RecBody::setSubtype(const QString&type)
+{
+ m_subtype = type;
+}
+
+const QString& RecBody::Subtype()const
+{
+ return m_subtype;
+}
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.h b/noncore/net/mail/libmailwrapper/mailtypes.h
index 6d6b080..900f10a 100644
--- a/noncore/net/mail/libmailwrapper/mailtypes.h
+++ b/noncore/net/mail/libmailwrapper/mailtypes.h
@@ -43,12 +43,14 @@ public:
const QString&getMbox()const{return mbox;}
void setMbox(const QString&box){mbox = box;}
void setMsgid(const QString&id){msg_id=id;}
const QString&Msgid()const{return msg_id;}
void setReplyto(const QString&reply){replyto=reply;}
const QString&Replyto()const{return replyto;}
+ void setMsgsize(int size){msg_size = size;}
+ const int Msgsize()const{return msg_size;}
void setTo(const QStringList&list);
const QStringList&To()const;
void setCC(const QStringList&list);
const QStringList&CC()const;
@@ -56,49 +58,57 @@ public:
const QStringList&Bcc()const;
const QBitArray&getFlags()const{return msg_flags;}
void setFlags(const QBitArray&flags){msg_flags = flags;}
protected:
QString subject,date,from,mbox,msg_id,replyto;
- int msg_number;
+ int msg_number,msg_size;
QBitArray msg_flags;
QStringList to,cc,bcc;
void init();
void copy_old(const RecMail&old);
};
class RecPart
{
protected:
QString m_type,m_subtype,m_identifier,m_encoding;
+ unsigned int m_lines;
public:
RecPart();
- RecPart(const QString&identifier,const QString&type="",const QString&subtype="",const QString&encoding="BASE64");
+ 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);
const QString&Subtype()const;
void setSubtype(const QString&subtype);
const QString&Identifier()const;
void setIdentifier(const QString&identifier);
const QString&Encoding()const;
void setEncoding(const QString&encoding);
+ void setLines(unsigned int lines);
+ const unsigned int Lines()const;
};
class RecBody
{
protected:
- QString m_BodyText;
+ QString m_BodyText,m_type,m_subtype;
QList<RecPart> m_PartsList;
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 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 f9e5794..0e3174d 100644
--- a/noncore/net/mail/mailtypes.cpp
+++ b/noncore/net/mail/mailtypes.cpp
@@ -1,11 +1,11 @@
#include "mailtypes.h"
RecMail::RecMail()
- :subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7)
+ :subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7)
{
init();
}
RecMail::RecMail(const RecMail&old)
:subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7)
@@ -18,12 +18,13 @@ RecMail::RecMail(const RecMail&old)
void RecMail::copy_old(const RecMail&old)
{
subject = old.subject;
date = old.date;
mbox = old.mbox;
msg_id = old.msg_id;
+ msg_size = old.msg_size;
msg_number = old.msg_number;
from = old.from;
msg_flags = old.msg_flags;
to = old.to;
cc = old.cc;
bcc = old.bcc;
@@ -64,25 +65,35 @@ void RecMail::setBcc(const QStringList&list)
const QStringList& RecMail::Bcc()const
{
return bcc;
}
RecPart::RecPart()
- : m_type(""),m_subtype(""),m_identifier(""),m_encoding("")
+ : 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)
- : m_type(type),m_subtype(subtype),m_identifier(identifier),m_encoding(encoding)
+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)
{
}
RecPart::~RecPart()
{
}
+void RecPart::setLines(unsigned int lines)
+{
+ m_lines = lines;
+}
+
+const unsigned int RecPart::Lines()const
+{
+ return m_lines;
+}
+
const QString& RecPart::Type()const
{
return m_type;
}
void RecPart::setType(const QString&type)
@@ -153,6 +164,26 @@ const QList<RecPart>& RecBody::Parts()const
void RecBody::addPart(const RecPart& part)
{
RecPart*p = new RecPart(part);
m_PartsList.append(p);
}
+
+void RecBody::setType(const QString&type)
+{
+ m_type = type;
+}
+
+const QString& RecBody::Type()const
+{
+ return m_type;
+}
+
+void RecBody::setSubtype(const QString&type)
+{
+ m_subtype = type;
+}
+
+const QString& RecBody::Subtype()const
+{
+ return m_subtype;
+}
diff --git a/noncore/net/mail/mailtypes.h b/noncore/net/mail/mailtypes.h
index 6d6b080..900f10a 100644
--- a/noncore/net/mail/mailtypes.h
+++ b/noncore/net/mail/mailtypes.h
@@ -43,12 +43,14 @@ public:
const QString&getMbox()const{return mbox;}
void setMbox(const QString&box){mbox = box;}
void setMsgid(const QString&id){msg_id=id;}
const QString&Msgid()const{return msg_id;}
void setReplyto(const QString&reply){replyto=reply;}
const QString&Replyto()const{return replyto;}
+ void setMsgsize(int size){msg_size = size;}
+ const int Msgsize()const{return msg_size;}
void setTo(const QStringList&list);
const QStringList&To()const;
void setCC(const QStringList&list);
const QStringList&CC()const;
@@ -56,49 +58,57 @@ public:
const QStringList&Bcc()const;
const QBitArray&getFlags()const{return msg_flags;}
void setFlags(const QBitArray&flags){msg_flags = flags;}
protected:
QString subject,date,from,mbox,msg_id,replyto;
- int msg_number;
+ int msg_number,msg_size;
QBitArray msg_flags;
QStringList to,cc,bcc;
void init();
void copy_old(const RecMail&old);
};
class RecPart
{
protected:
QString m_type,m_subtype,m_identifier,m_encoding;
+ unsigned int m_lines;
public:
RecPart();
- RecPart(const QString&identifier,const QString&type="",const QString&subtype="",const QString&encoding="BASE64");
+ 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);
const QString&Subtype()const;
void setSubtype(const QString&subtype);
const QString&Identifier()const;
void setIdentifier(const QString&identifier);
const QString&Encoding()const;
void setEncoding(const QString&encoding);
+ void setLines(unsigned int lines);
+ const unsigned int Lines()const;
};
class RecBody
{
protected:
- QString m_BodyText;
+ QString m_BodyText,m_type,m_subtype;
QList<RecPart> m_PartsList;
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 setParts(const QList<RecPart>&parts);
const QList<RecPart>& Parts()const;
void addPart(const RecPart&part);
};