summaryrefslogtreecommitdiff
authoralwin <alwin>2003-12-18 01:52:02 (UTC)
committer alwin <alwin>2003-12-18 01:52:02 (UTC)
commit77e353da0c33bbfabf1b919e25008d62581bf164 (patch) (side-by-side diff)
treeed9d2ccc255de8159598a647a39f31399568cbb9
parente996a7b13e2860280a63d089716958c7886cdc8d (diff)
downloadopie-77e353da0c33bbfabf1b919e25008d62581bf164.zip
opie-77e353da0c33bbfabf1b919e25008d62581bf164.tar.gz
opie-77e353da0c33bbfabf1b919e25008d62581bf164.tar.bz2
nothing much.
just only check in my tries to finish the pop3 stuff and found another bug inside libetpan. when decoding text with fun "mailmime_encoded_phrase_parse" it works fine on i386 machines but not on arm (segmentation fault inside this fun) - it has to be resolved.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/abstractmail.cpp23
-rw-r--r--noncore/net/mail/abstractmail.h1
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.cpp23
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.h1
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.cpp49
-rw-r--r--noncore/net/mail/pop3wrapper.cpp49
6 files changed, 130 insertions, 16 deletions
diff --git a/noncore/net/mail/abstractmail.cpp b/noncore/net/mail/abstractmail.cpp
index 92a46f1..b7e5eaa 100644
--- a/noncore/net/mail/abstractmail.cpp
+++ b/noncore/net/mail/abstractmail.cpp
@@ -25,24 +25,47 @@ encodedString* AbstractMail::decode_String(const encodedString*text,const QStrin
/* reset for recursive use! */
size_t target_length = 0;
result_text = 0;
int mimetype = MAILMIME_MECHANISM_7BIT;
if (enc.lower()=="quoted-printable") {
mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE;
} else if (enc.lower()=="base64") {
mimetype = MAILMIME_MECHANISM_BASE64;
} else if (enc.lower()=="8bit") {
mimetype = MAILMIME_MECHANISM_8BIT;
} else if (enc.lower()=="binary") {
mimetype = MAILMIME_MECHANISM_BINARY;
}
int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype,
&result_text,&target_length);
encodedString* result = new encodedString();
if (err == MAILIMF_NO_ERROR) {
result->setContent(result_text,target_length);
}
qDebug("Decode string finished");
return result;
}
+
+QString AbstractMail::convert_String(const char*text)
+{
+#if 0
+ size_t index = 0;
+ char*res = 0;
+
+ qDebug("encode start %s",text);
+ /* attention - doesn't work with arm systems! */
+ int err = mailmime_encoded_phrase_parse("iso-8859-1",
+ text, strlen(text),&index, "iso-8859-1",&res);
+ qDebug("encode end");
+ if (err != MAILIMF_NO_ERROR) {
+ if (res) free(res);
+ return QString(text);
+ }
+ QString result(res);
+ free(res);
+ return result;
+#else
+ return QString(text);
+#endif
+}
diff --git a/noncore/net/mail/abstractmail.h b/noncore/net/mail/abstractmail.h
index f1a8468..c16e9c0 100644
--- a/noncore/net/mail/abstractmail.h
+++ b/noncore/net/mail/abstractmail.h
@@ -10,26 +10,27 @@ class RecPart;
class IMAPwrapper;
class POP3wrapper;
class Folder;
class encodedString;
class AbstractMail:public QObject
{
Q_OBJECT
public:
AbstractMail(){};
virtual ~AbstractMail(){}
virtual QList<Folder>* listFolders()=0;
virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0;
virtual RecBody fetchBody(const RecMail&mail)=0;
virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0;
virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0;
virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0;
virtual void deleteMail(const RecMail&mail)=0;
virtual void answeredMail(const RecMail&mail)=0;
static AbstractMail* getWrapper(IMAPaccount *a);
static AbstractMail* getWrapper(POP3account *a);
static encodedString*decode_String(const encodedString*text,const QString&enc);
+ static QString convert_String(const char*text);
};
#endif
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.cpp b/noncore/net/mail/libmailwrapper/abstractmail.cpp
index 92a46f1..b7e5eaa 100644
--- a/noncore/net/mail/libmailwrapper/abstractmail.cpp
+++ b/noncore/net/mail/libmailwrapper/abstractmail.cpp
@@ -25,24 +25,47 @@ encodedString* AbstractMail::decode_String(const encodedString*text,const QStrin
/* reset for recursive use! */
size_t target_length = 0;
result_text = 0;
int mimetype = MAILMIME_MECHANISM_7BIT;
if (enc.lower()=="quoted-printable") {
mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE;
} else if (enc.lower()=="base64") {
mimetype = MAILMIME_MECHANISM_BASE64;
} else if (enc.lower()=="8bit") {
mimetype = MAILMIME_MECHANISM_8BIT;
} else if (enc.lower()=="binary") {
mimetype = MAILMIME_MECHANISM_BINARY;
}
int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype,
&result_text,&target_length);
encodedString* result = new encodedString();
if (err == MAILIMF_NO_ERROR) {
result->setContent(result_text,target_length);
}
qDebug("Decode string finished");
return result;
}
+
+QString AbstractMail::convert_String(const char*text)
+{
+#if 0
+ size_t index = 0;
+ char*res = 0;
+
+ qDebug("encode start %s",text);
+ /* attention - doesn't work with arm systems! */
+ int err = mailmime_encoded_phrase_parse("iso-8859-1",
+ text, strlen(text),&index, "iso-8859-1",&res);
+ qDebug("encode end");
+ if (err != MAILIMF_NO_ERROR) {
+ if (res) free(res);
+ return QString(text);
+ }
+ QString result(res);
+ free(res);
+ return result;
+#else
+ return QString(text);
+#endif
+}
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h
index f1a8468..c16e9c0 100644
--- a/noncore/net/mail/libmailwrapper/abstractmail.h
+++ b/noncore/net/mail/libmailwrapper/abstractmail.h
@@ -10,26 +10,27 @@ class RecPart;
class IMAPwrapper;
class POP3wrapper;
class Folder;
class encodedString;
class AbstractMail:public QObject
{
Q_OBJECT
public:
AbstractMail(){};
virtual ~AbstractMail(){}
virtual QList<Folder>* listFolders()=0;
virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0;
virtual RecBody fetchBody(const RecMail&mail)=0;
virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0;
virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0;
virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0;
virtual void deleteMail(const RecMail&mail)=0;
virtual void answeredMail(const RecMail&mail)=0;
static AbstractMail* getWrapper(IMAPaccount *a);
static AbstractMail* getWrapper(POP3account *a);
static encodedString*decode_String(const encodedString*text,const QString&enc);
+ static QString convert_String(const char*text);
};
#endif
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
index 30f80ff..22a4c70 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
@@ -1,134 +1,168 @@
#include <stdlib.h>
#include "pop3wrapper.h"
#include "mailtypes.h"
#include <libetpan/mailpop3.h>
#include <libetpan/mailmime.h>
+#include <libetpan/data_message_driver.h>
#include <qfile.h>
+/* we don't fetch messages larger than 5 MB */
+#define HARD_MSG_SIZE_LIMIT 5242880
+
POP3wrapper::POP3wrapper( POP3account *a )
{
account = a;
m_pop3 = NULL;
msgTempName = a->getFileName()+"_msg_cache";
last_msg_id = 0;
}
POP3wrapper::~POP3wrapper()
{
logout();
QFile msg_cache(msgTempName);
if (msg_cache.exists()) {
msg_cache.remove();
}
}
void POP3wrapper::pop3_progress( size_t current, size_t maximum )
{
//qDebug( "POP3: %i of %i", current, maximum );
}
RecBody POP3wrapper::fetchBody( const RecMail &mail )
{
int err = MAILPOP3_NO_ERROR;
char *message;
size_t length = 0;
login();
if ( !m_pop3 ) {
return RecBody();
}
+
RecBody body;
QFile msg_cache(msgTempName);
+ if (mail.Msgsize()>HARD_MSG_SIZE_LIMIT) {
+ qDebug("Message to large: %i",mail.Msgsize());
+ return body;
+ }
if (mail.getNumber()!=last_msg_id) {
if (msg_cache.exists()) {
msg_cache.remove();
}
msg_cache.open(IO_ReadWrite|IO_Truncate);
last_msg_id = mail.getNumber();
err = mailpop3_retr( m_pop3, mail.getNumber(), &message, &length );
if ( err != MAILPOP3_NO_ERROR ) {
qDebug( "POP3: error retrieving body with index %i", mail.getNumber() );
last_msg_id = 0;
return RecBody();
}
msg_cache.writeBlock(message,length);
} else {
QString msg="";
msg_cache.open(IO_ReadOnly);
message = new char[4096];
memset(message,0,4096);
while (msg_cache.readBlock(message,4095)>0) {
msg+=message;
memset(message,0,4096);
}
delete message;
message = (char*)malloc(msg.length()+1*sizeof(char));
memset(message,0,msg.length()+1);
memcpy(message,msg.latin1(),msg.length());
}
body = parseMail(message);
free(message);
return body;
}
RecBody POP3wrapper::parseMail( char *message )
{
int err = MAILIMF_NO_ERROR;
/* these vars are used recurcive! set it to 0!!!!!!!!!!!!!!!!! */
size_t curTok = 0;
mailimf_message *result = 0;
+ mailmessage * msg=0;
+ struct mailmime * mime=0;
+ struct mailmime_single_fields fields;
+
RecBody body;
err = mailimf_message_parse( (char *) message, strlen( message ), &curTok, &result );
if ( err != MAILIMF_NO_ERROR ) {
if (result) mailimf_message_free(result);
return body;
}
-
- struct mailimf_body * b = 0;
- struct mailimf_fields * f = 0;
-
-
+
+#if 0
+ char*body_msg = message;
+ if ( result && result->msg_body && result->msg_body->bd_text ) {
+ body_msg = (char*)result->msg_body->bd_text;
+ result->msg_body->bd_text = 0;
+ }
+
+ msg = mailmessage_new();
+ mailmessage_init(msg, NULL, data_message_driver, 0, strlen(body_msg));
+ generic_message_t * msg_data;
+ msg_data = (generic_message_t *)msg->msg_data;
+ msg_data->msg_fetched = 1;
+ msg_data->msg_message = body_msg;
+ msg_data->msg_length = strlen(body_msg);
+ memset(&fields, 0, sizeof(struct mailmime_single_fields));
+ err = mailmessage_get_bodystructure(msg,&mime);
+
+ if (mime->mm_mime_fields != NULL) {
+ mailmime_single_fields_init(&fields, mime->mm_mime_fields,
+ mime->mm_content_type);
+ }
+#endif
+
+#if 1
if ( result && result->msg_body && result->msg_body->bd_text ) {
qDebug( "POP3: bodytext found" );
// when curTok isn't set to 0 this line will fault! 'cause upper line faults!
body.setBodytext( QString( result->msg_body->bd_text ) );
#if 0
curTok = 0;
mailmime_content*mresult = 0;
size_t index = 0;
mailmime_content_parse(result->msg_body->bd_text,
strlen(result->msg_body->bd_text),&index,&mresult);
if (mresult) {
mailmime_content_free(mresult);
}
#endif
mailimf_message_free(result);
}
+#endif
return body;
}
void POP3wrapper::listMessages(const QString &, QList<RecMail> &target )
{
int err = MAILPOP3_NO_ERROR;
char * header = 0;
/* these vars are used recurcive! set it to 0!!!!!!!!!!!!!!!!! */
size_t length = 0;
carray * messages = 0;
login();
if (!m_pop3) return;
mailpop3_list( m_pop3, &messages );
for (unsigned int i = 0; i < carray_count(messages);++i) {
mailpop3_msg_info *info;
err = mailpop3_get_msg_info(m_pop3,i+1,&info);
if (info->msg_deleted)
continue;
err = mailpop3_header( m_pop3, info->msg_index, &header, &length );
if ( err != MAILPOP3_NO_ERROR ) {
qDebug( "POP3: error retrieving header msgid: %i", info->msg_index );
free(header);
@@ -151,80 +185,79 @@ RecMail *POP3wrapper::parseHeader( const char *header )
mailimf_fields *fields;
mailimf_references * refs;
mailimf_keywords*keys;
QString status;
QString value;
QBitArray mFlags(7);
err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields );
for ( clistiter *current = clist_begin( fields->fld_list ); current != NULL; current = current->next ) {
mailimf_field *field = (mailimf_field *) current->data;
switch ( field->fld_type ) {
case MAILIMF_FIELD_FROM:
mail->setFrom( parseMailboxList( field->fld_data.fld_from->frm_mb_list ) );
break;
case MAILIMF_FIELD_TO:
mail->setTo( parseAddressList( field->fld_data.fld_to->to_addr_list ) );
break;
case MAILIMF_FIELD_CC:
mail->setCC( parseAddressList( field->fld_data.fld_cc->cc_addr_list ) );
break;
case MAILIMF_FIELD_BCC:
mail->setBcc( parseAddressList( field->fld_data.fld_bcc->bcc_addr_list ) );
break;
case MAILIMF_FIELD_SUBJECT:
- mail->setSubject( QString( field->fld_data.fld_subject->sbj_value ) );
+ mail->setSubject(convert_String( field->fld_data.fld_subject->sbj_value ) );
break;
case MAILIMF_FIELD_ORIG_DATE:
mail->setDate( parseDateTime( field->fld_data.fld_orig_date->dt_date_time ) );
break;
case MAILIMF_FIELD_MESSAGE_ID:
mail->setMsgid(QString(field->fld_data.fld_message_id->mid_value));
break;
case MAILIMF_FIELD_REFERENCES:
refs = field->fld_data.fld_references;
if (refs && refs->mid_list && clist_count(refs->mid_list)) {
char * text = (char*)refs->mid_list->first->data;
mail->setReplyto(QString(text));
}
break;
case MAILIMF_FIELD_KEYWORDS:
keys = field->fld_data.fld_keywords;
for (clistcell*cur = clist_begin(keys->kw_list);cur!=0;cur=clist_next(cur)) {
qDebug("Keyword: %s",(char*)cur->data);
}
break;
case MAILIMF_FIELD_OPTIONAL_FIELD:
status = field->fld_data.fld_optional_field->fld_name;
value = field->fld_data.fld_optional_field->fld_value;
if (status.lower()=="status") {
if (value.lower()=="ro") {
mFlags.setBit(FLAG_SEEN);
}
} else if (status.lower()=="x-status") {
qDebug("X-Status: %s",value.latin1());
if (value.lower()=="a") {
-
mFlags.setBit(FLAG_ANSWERED);
}
} else {
// qDebug("Optionales feld: %s -> %s)",field->fld_data.fld_optional_field->fld_name,
// field->fld_data.fld_optional_field->fld_value);
}
break;
default:
qDebug("Non parsed field");
break;
}
}
if (fields) mailimf_fields_free(fields);
mail->setFlags(mFlags);
return mail;
}
QString POP3wrapper::parseDateTime( mailimf_date_time *date )
{
char tmp[23];
snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i",
date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone );
@@ -263,49 +296,49 @@ QString POP3wrapper::parseAddressList( mailimf_address_list *list )
QString POP3wrapper::parseGroup( mailimf_group *group )
{
QString result( "" );
result.append( group->grp_display_name );
result.append( ": " );
if ( group->grp_mb_list != NULL ) {
result.append( parseMailboxList( group->grp_mb_list ) );
}
result.append( ";" );
return result;
}
QString POP3wrapper::parseMailbox( mailimf_mailbox *box )
{
QString result( "" );
if ( box->mb_display_name == NULL ) {
result.append( box->mb_addr_spec );
} else {
- result.append( box->mb_display_name );
+ result.append( convert_String(box->mb_display_name).latin1() );
result.append( " <" );
result.append( box->mb_addr_spec );
result.append( ">" );
}
return result;
}
QString POP3wrapper::parseMailboxList( mailimf_mailbox_list *list )
{
QString result( "" );
bool first = true;
for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) {
mailimf_mailbox *box = (mailimf_mailbox *) current->data;
if ( !first ) {
result.append( "," );
} else {
first = false;
}
result.append( parseMailbox( box ) );
}
diff --git a/noncore/net/mail/pop3wrapper.cpp b/noncore/net/mail/pop3wrapper.cpp
index 30f80ff..22a4c70 100644
--- a/noncore/net/mail/pop3wrapper.cpp
+++ b/noncore/net/mail/pop3wrapper.cpp
@@ -1,134 +1,168 @@
#include <stdlib.h>
#include "pop3wrapper.h"
#include "mailtypes.h"
#include <libetpan/mailpop3.h>
#include <libetpan/mailmime.h>
+#include <libetpan/data_message_driver.h>
#include <qfile.h>
+/* we don't fetch messages larger than 5 MB */
+#define HARD_MSG_SIZE_LIMIT 5242880
+
POP3wrapper::POP3wrapper( POP3account *a )
{
account = a;
m_pop3 = NULL;
msgTempName = a->getFileName()+"_msg_cache";
last_msg_id = 0;
}
POP3wrapper::~POP3wrapper()
{
logout();
QFile msg_cache(msgTempName);
if (msg_cache.exists()) {
msg_cache.remove();
}
}
void POP3wrapper::pop3_progress( size_t current, size_t maximum )
{
//qDebug( "POP3: %i of %i", current, maximum );
}
RecBody POP3wrapper::fetchBody( const RecMail &mail )
{
int err = MAILPOP3_NO_ERROR;
char *message;
size_t length = 0;
login();
if ( !m_pop3 ) {
return RecBody();
}
+
RecBody body;
QFile msg_cache(msgTempName);
+ if (mail.Msgsize()>HARD_MSG_SIZE_LIMIT) {
+ qDebug("Message to large: %i",mail.Msgsize());
+ return body;
+ }
if (mail.getNumber()!=last_msg_id) {
if (msg_cache.exists()) {
msg_cache.remove();
}
msg_cache.open(IO_ReadWrite|IO_Truncate);
last_msg_id = mail.getNumber();
err = mailpop3_retr( m_pop3, mail.getNumber(), &message, &length );
if ( err != MAILPOP3_NO_ERROR ) {
qDebug( "POP3: error retrieving body with index %i", mail.getNumber() );
last_msg_id = 0;
return RecBody();
}
msg_cache.writeBlock(message,length);
} else {
QString msg="";
msg_cache.open(IO_ReadOnly);
message = new char[4096];
memset(message,0,4096);
while (msg_cache.readBlock(message,4095)>0) {
msg+=message;
memset(message,0,4096);
}
delete message;
message = (char*)malloc(msg.length()+1*sizeof(char));
memset(message,0,msg.length()+1);
memcpy(message,msg.latin1(),msg.length());
}
body = parseMail(message);
free(message);
return body;
}
RecBody POP3wrapper::parseMail( char *message )
{
int err = MAILIMF_NO_ERROR;
/* these vars are used recurcive! set it to 0!!!!!!!!!!!!!!!!! */
size_t curTok = 0;
mailimf_message *result = 0;
+ mailmessage * msg=0;
+ struct mailmime * mime=0;
+ struct mailmime_single_fields fields;
+
RecBody body;
err = mailimf_message_parse( (char *) message, strlen( message ), &curTok, &result );
if ( err != MAILIMF_NO_ERROR ) {
if (result) mailimf_message_free(result);
return body;
}
-
- struct mailimf_body * b = 0;
- struct mailimf_fields * f = 0;
-
-
+
+#if 0
+ char*body_msg = message;
+ if ( result && result->msg_body && result->msg_body->bd_text ) {
+ body_msg = (char*)result->msg_body->bd_text;
+ result->msg_body->bd_text = 0;
+ }
+
+ msg = mailmessage_new();
+ mailmessage_init(msg, NULL, data_message_driver, 0, strlen(body_msg));
+ generic_message_t * msg_data;
+ msg_data = (generic_message_t *)msg->msg_data;
+ msg_data->msg_fetched = 1;
+ msg_data->msg_message = body_msg;
+ msg_data->msg_length = strlen(body_msg);
+ memset(&fields, 0, sizeof(struct mailmime_single_fields));
+ err = mailmessage_get_bodystructure(msg,&mime);
+
+ if (mime->mm_mime_fields != NULL) {
+ mailmime_single_fields_init(&fields, mime->mm_mime_fields,
+ mime->mm_content_type);
+ }
+#endif
+
+#if 1
if ( result && result->msg_body && result->msg_body->bd_text ) {
qDebug( "POP3: bodytext found" );
// when curTok isn't set to 0 this line will fault! 'cause upper line faults!
body.setBodytext( QString( result->msg_body->bd_text ) );
#if 0
curTok = 0;
mailmime_content*mresult = 0;
size_t index = 0;
mailmime_content_parse(result->msg_body->bd_text,
strlen(result->msg_body->bd_text),&index,&mresult);
if (mresult) {
mailmime_content_free(mresult);
}
#endif
mailimf_message_free(result);
}
+#endif
return body;
}
void POP3wrapper::listMessages(const QString &, QList<RecMail> &target )
{
int err = MAILPOP3_NO_ERROR;
char * header = 0;
/* these vars are used recurcive! set it to 0!!!!!!!!!!!!!!!!! */
size_t length = 0;
carray * messages = 0;
login();
if (!m_pop3) return;
mailpop3_list( m_pop3, &messages );
for (unsigned int i = 0; i < carray_count(messages);++i) {
mailpop3_msg_info *info;
err = mailpop3_get_msg_info(m_pop3,i+1,&info);
if (info->msg_deleted)
continue;
err = mailpop3_header( m_pop3, info->msg_index, &header, &length );
if ( err != MAILPOP3_NO_ERROR ) {
qDebug( "POP3: error retrieving header msgid: %i", info->msg_index );
free(header);
@@ -151,80 +185,79 @@ RecMail *POP3wrapper::parseHeader( const char *header )
mailimf_fields *fields;
mailimf_references * refs;
mailimf_keywords*keys;
QString status;
QString value;
QBitArray mFlags(7);
err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields );
for ( clistiter *current = clist_begin( fields->fld_list ); current != NULL; current = current->next ) {
mailimf_field *field = (mailimf_field *) current->data;
switch ( field->fld_type ) {
case MAILIMF_FIELD_FROM:
mail->setFrom( parseMailboxList( field->fld_data.fld_from->frm_mb_list ) );
break;
case MAILIMF_FIELD_TO:
mail->setTo( parseAddressList( field->fld_data.fld_to->to_addr_list ) );
break;
case MAILIMF_FIELD_CC:
mail->setCC( parseAddressList( field->fld_data.fld_cc->cc_addr_list ) );
break;
case MAILIMF_FIELD_BCC:
mail->setBcc( parseAddressList( field->fld_data.fld_bcc->bcc_addr_list ) );
break;
case MAILIMF_FIELD_SUBJECT:
- mail->setSubject( QString( field->fld_data.fld_subject->sbj_value ) );
+ mail->setSubject(convert_String( field->fld_data.fld_subject->sbj_value ) );
break;
case MAILIMF_FIELD_ORIG_DATE:
mail->setDate( parseDateTime( field->fld_data.fld_orig_date->dt_date_time ) );
break;
case MAILIMF_FIELD_MESSAGE_ID:
mail->setMsgid(QString(field->fld_data.fld_message_id->mid_value));
break;
case MAILIMF_FIELD_REFERENCES:
refs = field->fld_data.fld_references;
if (refs && refs->mid_list && clist_count(refs->mid_list)) {
char * text = (char*)refs->mid_list->first->data;
mail->setReplyto(QString(text));
}
break;
case MAILIMF_FIELD_KEYWORDS:
keys = field->fld_data.fld_keywords;
for (clistcell*cur = clist_begin(keys->kw_list);cur!=0;cur=clist_next(cur)) {
qDebug("Keyword: %s",(char*)cur->data);
}
break;
case MAILIMF_FIELD_OPTIONAL_FIELD:
status = field->fld_data.fld_optional_field->fld_name;
value = field->fld_data.fld_optional_field->fld_value;
if (status.lower()=="status") {
if (value.lower()=="ro") {
mFlags.setBit(FLAG_SEEN);
}
} else if (status.lower()=="x-status") {
qDebug("X-Status: %s",value.latin1());
if (value.lower()=="a") {
-
mFlags.setBit(FLAG_ANSWERED);
}
} else {
// qDebug("Optionales feld: %s -> %s)",field->fld_data.fld_optional_field->fld_name,
// field->fld_data.fld_optional_field->fld_value);
}
break;
default:
qDebug("Non parsed field");
break;
}
}
if (fields) mailimf_fields_free(fields);
mail->setFlags(mFlags);
return mail;
}
QString POP3wrapper::parseDateTime( mailimf_date_time *date )
{
char tmp[23];
snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i",
date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone );
@@ -263,49 +296,49 @@ QString POP3wrapper::parseAddressList( mailimf_address_list *list )
QString POP3wrapper::parseGroup( mailimf_group *group )
{
QString result( "" );
result.append( group->grp_display_name );
result.append( ": " );
if ( group->grp_mb_list != NULL ) {
result.append( parseMailboxList( group->grp_mb_list ) );
}
result.append( ";" );
return result;
}
QString POP3wrapper::parseMailbox( mailimf_mailbox *box )
{
QString result( "" );
if ( box->mb_display_name == NULL ) {
result.append( box->mb_addr_spec );
} else {
- result.append( box->mb_display_name );
+ result.append( convert_String(box->mb_display_name).latin1() );
result.append( " <" );
result.append( box->mb_addr_spec );
result.append( ">" );
}
return result;
}
QString POP3wrapper::parseMailboxList( mailimf_mailbox_list *list )
{
QString result( "" );
bool first = true;
for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) {
mailimf_mailbox *box = (mailimf_mailbox *) current->data;
if ( !first ) {
result.append( "," );
} else {
first = false;
}
result.append( parseMailbox( box ) );
}