summaryrefslogtreecommitdiffabout
path: root/kmicromail/libmailwrapper
Side-by-side diff
Diffstat (limited to 'kmicromail/libmailwrapper') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libmailwrapper/abstractmail.cpp9
-rw-r--r--kmicromail/libmailwrapper/genericwrapper.cpp16
-rw-r--r--kmicromail/libmailwrapper/imapwrapper.cpp19
-rw-r--r--kmicromail/libmailwrapper/mboxwrapper.cpp1
-rw-r--r--kmicromail/libmailwrapper/mhwrapper.cpp1
5 files changed, 41 insertions, 5 deletions
diff --git a/kmicromail/libmailwrapper/abstractmail.cpp b/kmicromail/libmailwrapper/abstractmail.cpp
index 8ee112c..ed5c898 100644
--- a/kmicromail/libmailwrapper/abstractmail.cpp
+++ b/kmicromail/libmailwrapper/abstractmail.cpp
@@ -67,48 +67,49 @@ encodedString* AbstractMail::decode_String(const encodedString*text,const QStrin
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);
}
//odebug << "Decode string finished" << oendl;
return result;
}
QString AbstractMail::convert_String(const char*text)
{
size_t index = 0;
char*res = 0;
int err = MAILIMF_NO_ERROR;
QString result(text);
-
+ //qDebug("convert_String %s ", text);
+ //err = mailmime_encoded_phrase_parse("iso-8859-1",
+ // text, strlen(text),&index, "iso-8859-1",&res);
err = mailmime_encoded_phrase_parse("iso-8859-1",
- text, strlen(text),&index, "iso-8859-1",&res);
+ text, strlen(text),&index, "utf-8",&res);
if (err == MAILIMF_NO_ERROR && res && strlen(res)) {
- result = QString(res);
+ result = QString::fromUtf8(res);
}
//qDebug("convert_String:%s ",result.latin1() );
if (res) free(res);
return result;
}
/* cp & paste from launcher */
QString AbstractMail::gen_attachment_id()
{
QFile file( "/proc/sys/kernel/random/uuid" );
if (!file.open(IO_ReadOnly ) )
return QString::null;
diff --git a/kmicromail/libmailwrapper/genericwrapper.cpp b/kmicromail/libmailwrapper/genericwrapper.cpp
index d89a5f9..49227dd 100644
--- a/kmicromail/libmailwrapper/genericwrapper.cpp
+++ b/kmicromail/libmailwrapper/genericwrapper.cpp
@@ -211,24 +211,38 @@ void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*m
if (part->Type()=="text" && target->Bodytext().isNull()) {
encodedString*rs = new encodedString();
rs->setContent(data,len);
encodedString*res = decode_String(rs,part->Encoding());
if (countlist.count()>2) {
bodyCache[b]=rs;
target->addPart(part);
} else {
delete rs;
}
b = QString(res->Content());
delete res;
+ size_t index = 0;
+ char*resu = 0;
+ int err = MAILIMF_NO_ERROR;
+ QString charset = part->searchParamter( "charset");
+ qDebug("CHARSET %s ",charset.latin1() );
+ if ( !charset.isEmpty() ) {
+ err = mailmime_encoded_phrase_parse(charset.latin1(),
+ b.latin1(), b.length(),&index, "utf-8",&resu);
+ if (err == MAILIMF_NO_ERROR && resu && strlen(resu)) {
+ //qDebug("res %d %s ", index, resu);
+ b = QString::fromUtf8(resu);
+ }
+ if (resu) free(resu);
+ }
target->setBodytext(b);
target->setDescription(part);
} else {
bodyCache[b]=new encodedString(data,len);
target->addPart(part);
}
}
break;
case MAILMIME_MULTIPLE:
{
unsigned int ccount = 1;
mailmime*cbody=0;
@@ -335,25 +349,25 @@ QString Genericwrapper::parseGroup( mailimf_group *group )
result.append( ";" );
return result;
}
QString Genericwrapper::parseMailbox( mailimf_mailbox *box )
{
QString result( "" );
if ( box->mb_display_name == NULL ) {
result.append( box->mb_addr_spec );
} else {
- result.append( convert_String(box->mb_display_name).latin1() );
+ result.append( convert_String(box->mb_display_name) );
result.append( " <" );
result.append( box->mb_addr_spec );
result.append( ">" );
}
return result;
}
QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list )
{
QString result( "" );
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp
index d90a8d2..eb2b47d 100644
--- a/kmicromail/libmailwrapper/imapwrapper.cpp
+++ b/kmicromail/libmailwrapper/imapwrapper.cpp
@@ -743,24 +743,43 @@ void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&t
currentPart->setPositionlist(countlist);
for (unsigned int j = 0; j < countlist.count();++j) {
id+=(j>0?" ":"");
id+=QString("%1").arg(countlist[j]);
}
//odebug << "ID = " << id.latin1() << "" << oendl;
currentPart->setIdentifier(id);
fillSinglePart(currentPart,part1);
/* important: Check for is NULL 'cause a body can be empty!
And we put it only into the mail if it is the FIRST part */
if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) {
QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding());
+
+ size_t index = 0;
+ char*res = 0;
+ int err = MAILIMF_NO_ERROR;
+
+ QString charset = currentPart->searchParamter( "charset");
+ qDebug("CHARSET %s ",charset.latin1() );
+ //if ( false ) {
+ if ( !charset.isEmpty() ) {
+ //err = mailmime_encoded_phrase_parse("iso-8859-1",
+ // text, strlen(text),&index, "iso-8859-1",&res);
+ err = mailmime_encoded_phrase_parse(charset.latin1(),
+ body_text.latin1(), body_text.length(),&index, "utf-8",&res);
+ if (err == MAILIMF_NO_ERROR && res && strlen(res)) {
+ //qDebug("res %d %s ", index, res);
+ body_text = QString::fromUtf8(res);
+ }
+ if (res) free(res);
+ }
//qDebug("encoding %d text %s ",currentPart->Encoding().latin1(), body_text.latin1() );
target_body->setDescription(currentPart);
target_body->setBodytext(body_text);
if (countlist.count()>1) {
target_body->addPart(currentPart);
}
} else {
target_body->addPart(currentPart);
}
if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) {
traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist);
}
diff --git a/kmicromail/libmailwrapper/mboxwrapper.cpp b/kmicromail/libmailwrapper/mboxwrapper.cpp
index 0cdbae4..87f8c8a 100644
--- a/kmicromail/libmailwrapper/mboxwrapper.cpp
+++ b/kmicromail/libmailwrapper/mboxwrapper.cpp
@@ -116,24 +116,25 @@ RecBodyP MBOXwrapper::fetchBody( const RecMailP &mail )
mailfolder_free(folder);
mailstorage_free(storage);
return body;
}
r = mailmessage_fetch(msg,&data,&size);
if (r != MAIL_NO_ERROR) {
; // << "Error fetching mail " << mail->getNumber() << "" << oendl;
mailfolder_free(folder);
mailstorage_free(storage);
mailmessage_free(msg);
return body;
}
+ qDebug("MBOXwrapper::fetchBody ");
body = parseMail(msg);
mailmessage_fetch_result_free(msg,data);
mailfolder_free(folder);
mailstorage_free(storage);
return body;
}
void MBOXwrapper::mbox_progress( size_t current, size_t maximum )
{
; // << "MBOX " << current << " von " << maximum << "" << oendl;
}
diff --git a/kmicromail/libmailwrapper/mhwrapper.cpp b/kmicromail/libmailwrapper/mhwrapper.cpp
index 90b5d23..982d7a6 100644
--- a/kmicromail/libmailwrapper/mhwrapper.cpp
+++ b/kmicromail/libmailwrapper/mhwrapper.cpp
@@ -119,24 +119,25 @@ void MHwrapper::deleteMail(const RecMailP&mail)
r = mailsession_remove_message(m_storage->sto_session,mail->getNumber());
if (r != MAIL_NO_ERROR) {
qDebug("error deleting mail ");
}
}
void MHwrapper::answeredMail(const RecMailP&)
{
}
RecBodyP MHwrapper::fetchBody( const RecMailP &mail )
{
+ qDebug("MHwrapper::fetchBody ");
RecBodyP body = new RecBody();
init_storage();
if (!m_storage) {
return body;
}
mailmessage * msg;
char*data=0;
/* mail should hold the complete path! */
int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1());
if (r != MAIL_NO_ERROR) {
return body;