summaryrefslogtreecommitdiffabout
path: root/kmicromail
Side-by-side diff
Diffstat (limited to 'kmicromail') (more/less context) (show whitespace changes)
-rw-r--r--kmicromail/composemail.cpp12
-rw-r--r--kmicromail/koprefs.cpp7
-rw-r--r--kmicromail/koprefs.h5
-rw-r--r--kmicromail/koprefsdialog.cpp7
-rw-r--r--kmicromail/koprefsdialog.h1
-rw-r--r--kmicromail/libetpan/mime/mailmime_decode.c21
-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
-rw-r--r--kmicromail/mailistviewitem.cpp4
-rw-r--r--kmicromail/mainwindow.cpp45
-rw-r--r--kmicromail/mainwindow.h3
-rw-r--r--kmicromail/opiemail.cpp16
-rw-r--r--kmicromail/viewmail.cpp20
16 files changed, 147 insertions, 40 deletions
diff --git a/kmicromail/composemail.cpp b/kmicromail/composemail.cpp
index 2dcbc75..f44100b 100644
--- a/kmicromail/composemail.cpp
+++ b/kmicromail/composemail.cpp
@@ -483,12 +483,12 @@ ComposeMail::~ComposeMail()
void ComposeMail::reEditMail(const RecMailP&current)
{
RecMailP data = current;
- message->setText(QString::fromUtf8( data->Wrapper()->fetchBody(current)->Bodytext().latin1() ));
- subjectLine->setText( QString::fromUtf8( data->getSubject().latin1() ));
- toLine->setText(QString::fromUtf8( data->To().join(",").latin1() ));
- ccLine->setText(QString::fromUtf8( data->CC().join(",").latin1() ));
- bccLine->setText(QString::fromUtf8( data->Bcc().join(",").latin1() ));
- replyLine->setText(QString::fromUtf8( data->Replyto().latin1() ));
+ message->setText(data->Wrapper()->fetchBody(current)->Bodytext());
+ subjectLine->setText( data->getSubject());
+ toLine->setText(data->To().join(","));
+ ccLine->setText(data->CC().join(","));
+ bccLine->setText(data->Bcc().join(","));
+ replyLine->setText(data->Replyto());
}
AttachViewItem::AttachViewItem( QListView *parent, Attachment *att )
diff --git a/kmicromail/koprefs.cpp b/kmicromail/koprefs.cpp
index 8143b6f..342bbf3 100644
--- a/kmicromail/koprefs.cpp
+++ b/kmicromail/koprefs.cpp
@@ -57,23 +57,27 @@ KOPrefs::KOPrefs() :
mReadFont = QFont("helvetica",12);
KPrefs::setCurrentGroup("General");
+ addItemString("SendCodec",&mSendCodec,i18n ("userdefined") );
addItemString("SenderName",&mName,i18n ("Please set at") );
addItemString("SenderEmail",&mEmail,i18n ("Settings@General TAB") );
addItemBool("ViewMailAsHtml",&mViewAsHtml,false);
addItemBool("SendMailLater",&mSendLater,true);
addItemBool("UseKapi",&mUseKapi,false);
+ addItemInt("CurrentCodec",&mCurrentCodec,0);
KPrefs::setCurrentGroup("Fonts");
addItemFont("Application Font",&mAppFont);
addItemFont("Compose Font",&mComposeFont);
addItemFont("Read Font",&mReadFont);
fillMailDefaults();
-
+ isDirty = false;
}
KOPrefs::~KOPrefs()
{
+ if ( isDirty )
+ writeConfig();
if (mInstance == this)
mInstance = insd.setObject(0);
@@ -110,7 +114,6 @@ void KOPrefs::usrReadConfig()
void KOPrefs::usrWriteConfig()
{
-
KPimPrefs::usrWriteConfig();
}
diff --git a/kmicromail/koprefs.h b/kmicromail/koprefs.h
index f0a4463..91f3fa3 100644
--- a/kmicromail/koprefs.h
+++ b/kmicromail/koprefs.h
@@ -68,8 +68,11 @@ class KOPrefs : public KPimPrefs
QFont mComposeFont;
QFont mReadFont;
QString mName;
+ QString mSendCodec;
QString mEmail;
- bool mSendLater, mViewAsHtml, mUseKapi;
+ QString mCurrentCodeName;
+ int mCurrentCodec;
+ bool mSendLater, mViewAsHtml, mUseKapi, isDirty;
private:
};
diff --git a/kmicromail/koprefsdialog.cpp b/kmicromail/koprefsdialog.cpp
index c878fc9..4abf859 100644
--- a/kmicromail/koprefsdialog.cpp
+++ b/kmicromail/koprefsdialog.cpp
@@ -147,7 +147,10 @@ void KOPrefsDialog::setupMailTab()
ttt = addWidBool(i18n("Send mails later"),
&(KOPrefs::instance()->mSendLater),topFrame);
topLayout->addMultiCellWidget(ttt->checkBox(),1,1,0,1);
-
+ mCodecEdit = new QLineEdit(topFrame);
+ topLayout->addMultiCellWidget( new QLabel(mCodecEdit, i18n("User defined codec for new mails:"), topFrame),2,2,0,1);
+ topLayout->addMultiCellWidget(mCodecEdit,3,3,0,1);
+ topLayout->addMultiCellWidget( new QLabel(0, i18n("Example: iso-8859-15"), topFrame),4,4,0,1);
}
void KOPrefsDialog::setupFontsTab()
@@ -195,12 +198,14 @@ void KOPrefsDialog::usrReadConfig()
mNameEdit->setText(KOPrefs::instance()->mName);
mEmailEdit->setText(KOPrefs::instance()->mEmail);
+ mCodecEdit->setText(KOPrefs::instance()->mSendCodec);
kdelibcfg->readConfig();
}
void KOPrefsDialog::usrWriteConfig()
{
KOPrefs::instance()->mName = mNameEdit->text();
KOPrefs::instance()->mEmail = mEmailEdit->text();
+ KOPrefs::instance()->mSendCodec = mCodecEdit->text();
kdelibcfg->writeConfig();
diff --git a/kmicromail/koprefsdialog.h b/kmicromail/koprefsdialog.h
index 615574b..a0416ae 100644
--- a/kmicromail/koprefsdialog.h
+++ b/kmicromail/koprefsdialog.h
@@ -63,6 +63,7 @@ protected:
private:
KDEPIMConfigWidget* kdelibcfg;
QLineEdit *mNameEdit;
+ QLineEdit *mCodecEdit;
QLineEdit *mEmailEdit;
QLabel *mNameLabel;
QLabel *mEmailLabel;
diff --git a/kmicromail/libetpan/mime/mailmime_decode.c b/kmicromail/libetpan/mime/mailmime_decode.c
index dbaeb68..b2ab0f7 100644
--- a/kmicromail/libetpan/mime/mailmime_decode.c
+++ b/kmicromail/libetpan/mime/mailmime_decode.c
@@ -117,8 +117,9 @@ int mailmime_encoded_phrase_parse(const char * default_fromcode,
first = TRUE;
type = TYPE_ERROR; /* XXX - removes a gcc warning */
-
- while (1) {
+ // LUTZ add
+ int appendNewLine = FALSE;
+ while (1) { //while
r = mailmime_encoded_word_parse(message, length, &cur_token, &word);
if (r == MAILIMF_NO_ERROR) {
@@ -199,7 +200,17 @@ int mailmime_encoded_phrase_parse(const char * default_fromcode,
res = MAILIMF_ERROR_PARSE;
goto free;
}
-
+ // LUTZ add
+ if ( appendNewLine ) {
+ appendNewLine = FALSE;
+ if (mmap_string_append(gphrase, "\n") == NULL) {
+ free(wordutf8);
+ free(raw_word);
+ res = MAILIMF_ERROR_MEMORY;
+ goto free;
+ }
+ }
+ //fprintf(stderr,"append *%s* \n",wordutf8 );
if (mmap_string_append(gphrase, wordutf8) == NULL) {
free(wordutf8);
free(raw_word);
@@ -212,7 +223,11 @@ int mailmime_encoded_phrase_parse(const char * default_fromcode,
first = FALSE;
}
else if (r == MAILIMF_ERROR_PARSE) {
+ // LUTZ add
+ if ( cur_token >= length )
break;
+ ++cur_token;
+ appendNewLine = TRUE;
}
else {
res = r;
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
@@ -76,7 +76,6 @@ encodedString* AbstractMail::decode_String(const encodedString*text,const QStrin
} else if (enc.lower()=="binary") {
mimetype = MAILMIME_MECHANISM_BINARY;
}
-
int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype,
&result_text,&target_length);
@@ -95,11 +94,13 @@ QString AbstractMail::convert_String(const char*text)
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);
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
@@ -220,6 +220,20 @@ void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*m
}
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 {
@@ -344,7 +358,7 @@ QString Genericwrapper::parseMailbox( mailimf_mailbox *box )
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( ">" );
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
@@ -752,6 +752,25 @@ void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&t
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);
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
@@ -125,6 +125,7 @@ RecBodyP MBOXwrapper::fetchBody( const RecMailP &mail )
mailmessage_free(msg);
return body;
}
+ qDebug("MBOXwrapper::fetchBody ");
body = parseMail(msg);
mailmessage_fetch_result_free(msg,data);
mailfolder_free(folder);
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
@@ -128,6 +128,7 @@ void MHwrapper::answeredMail(const RecMailP&)
RecBodyP MHwrapper::fetchBody( const RecMailP &mail )
{
+ qDebug("MHwrapper::fetchBody ");
RecBodyP body = new RecBody();
init_storage();
if (!m_storage) {
diff --git a/kmicromail/mailistviewitem.cpp b/kmicromail/mailistviewitem.cpp
index 5ef5b6a..484a635 100644
--- a/kmicromail/mailistviewitem.cpp
+++ b/kmicromail/mailistviewitem.cpp
@@ -55,8 +55,8 @@ void MailListViewItem::showEntry()
//setText(3, fsize + "MB");
mKeyMap.insert(3, "M" +fsort );
}
- setText(1,QString::fromUtf8( mail_data->getSubject().latin1()));
- setText(2,QString::fromUtf8( mail_data->getFrom().latin1()));
+ setText(1,mail_data->getSubject());
+ setText(2,mail_data->getFrom());
#if 0
QString date = mail_data->getDate();
diff --git a/kmicromail/mainwindow.cpp b/kmicromail/mainwindow.cpp
index 98eb9a5..3013931 100644
--- a/kmicromail/mainwindow.cpp
+++ b/kmicromail/mainwindow.cpp
@@ -12,6 +12,7 @@
#ifdef DESKTOP_VERSION
#include <qapplication.h>
#include <qstatusbar.h>
+#include <kabc/stdaddressbook.h>
extern QStatusBar* globalSstatusBarMainWindow;
#else
#include <qpe/qpeapplication.h>
@@ -20,7 +21,7 @@ extern QStatusBar* globalSstatusBarMainWindow;
#include "mainwindow.h"
#include <KDGanttMinimizeSplitter.h>
-#include <kabc/stdaddressbook.h>
+#include "koprefs.h"
MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
: QMainWindow( parent, name ) //, flags )
@@ -99,7 +100,14 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
editAccounts = new QAction( i18n( "Configure accounts" ), SmallIcon("editaccounts") ,
0, 0, this );
editAccounts->addTo( settingsMenu );
-
+ codecMenu = new QPopupMenu( menuBar );
+ codecMenu->insertItem( "Western (iso-8859-1)",0,0);
+ codecMenu->insertItem( "Cyrillic (iso-8859-5)",1,1);
+ codecMenu->insertItem( "Western (iso-8859-15)",2,2);
+ codecMenu->insertItem( "Chinese (big-5)",3,3);
+ codecMenu->insertItem( "Unicode (utf-8)",4,4);
+ codecMenu->insertItem( "Userdefined ("+KOPrefs::instance()->mSendCodec+")",5,5);
+ settingsMenu->insertItem( i18n("Codec for new mails"), codecMenu);
//setCentralWidget( view );
QVBox* wrapperBox = new QVBox( this );
@@ -183,6 +191,8 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
li = new QAction(i18n("LibEtPan Licence"), QPixmap(), 0, 0, this);
connect( li, SIGNAL( activated() ), SLOT( showEtpanLicence()) );
li->addTo(helpMenu);
+ connect( codecMenu, SIGNAL( activated(int) ), this, SLOT( slotSetCodec( int )) );
+ slotSetCodec( KOPrefs::instance()->mCurrentCodec );
#ifdef DESKTOP_VERSION
resize ( 640, 480 );
#endif
@@ -192,6 +202,37 @@ MainWindow::~MainWindow()
{
}
+void MainWindow::slotSetCodec( int codec )
+{
+ codecMenu->setItemChecked(KOPrefs::instance()->mCurrentCodec, false );
+ //qDebug("codec %d ", codec);
+ KOPrefs::instance()->mCurrentCodec = codec;
+ KOPrefs::instance()->isDirty = true;
+ QString name;
+ switch ( codec ) {
+ case 0:
+ name = "iso-8859-1";
+ break;
+ case 1:
+ name = "iso-8859-5";
+ break;
+ case 2:
+ name = "iso-8859-15";
+ break;
+ case 3:
+ name = "big-5";
+ break;
+ case 4:
+ name = "utf-8";
+ break;
+ case 5:
+ name = KOPrefs::instance()->mSendCodec.lower();
+ break;
+ }
+ KOPrefs::instance()->mCurrentCodeName = name ;
+ codecMenu->changeItem ( 5, "Userdefined ("+KOPrefs::instance()->mSendCodec+")");
+ codecMenu->setItemChecked(KOPrefs::instance()->mCurrentCodec, true );
+}
void MainWindow::showLicence()
{
KApplication::showLicence();
diff --git a/kmicromail/mainwindow.h b/kmicromail/mainwindow.h
index f5ab69b..d0a5caf 100644
--- a/kmicromail/mainwindow.h
+++ b/kmicromail/mainwindow.h
@@ -45,6 +45,7 @@ protected slots:
virtual void slotGetMail() = 0;
virtual void slotGetAllMail() = 0;
virtual void slotDeleteMail();
+ virtual void slotSetCodec(int);
virtual void mailHold(int, QListViewItem *,const QPoint&,int);
virtual void slotAdjustLayout();
virtual void slotEditSettings();
@@ -57,7 +58,7 @@ protected:
QToolBar *toolBar;
StatusWidget *statusWidget;
QPEMenuBar *menuBar;
- QPopupMenu *mailMenu, *settingsMenu;
+ QPopupMenu *mailMenu, *settingsMenu, *codecMenu;
QAction *composeMail, *sendQueued, *showFolders, *searchMails, *deleteMails,
*editSettings, *editAccounts, *syncFolders;
AccountView *folderView;
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp
index af5376f..18a5600 100644
--- a/kmicromail/opiemail.cpp
+++ b/kmicromail/opiemail.cpp
@@ -33,6 +33,7 @@
#include <libmailwrapper/smtpwrapper.h>
#include <libmailwrapper/mailtypes.h>
#include <libmailwrapper/abstractmail.h>
+#include "koprefs.h"
//using namespace Opie::Core;
@@ -237,6 +238,7 @@ void OpieMail::slotEditSettings()
#endif
settingsDialog.exec();
+ slotSetCodec( KOPrefs::instance()->mCurrentCodec );
// KApplication::execDialog(settingsDialog);
}
@@ -263,10 +265,10 @@ void OpieMail::replyMail()
QString rtext;
rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose
- .arg( QString::fromUtf8( mail->getFrom().latin1()))
- .arg( QString::fromUtf8( mail->getDate().latin1() ));
+ .arg( mail->getFrom())
+ .arg( mail->getDate());
- QString text = QString::fromUtf8( body->Bodytext().latin1() );
+ QString text = body->Bodytext();
QStringList lines = QStringList::split(QRegExp("\\n"), text);
QStringList::Iterator it;
for (it = lines.begin(); it != lines.end(); it++)
@@ -282,13 +284,13 @@ void OpieMail::replyMail()
Settings *settings = new Settings();
ComposeMail composer( settings ,this, 0, true);
if (mail->Replyto().isEmpty()) {
- composer.setTo( QString::fromUtf8( mail->getFrom().latin1()));
+ composer.setTo( mail->getFrom());
} else {
- composer.setTo( QString::fromUtf8(mail->Replyto().latin1()));
+ composer.setTo( mail->Replyto());
}
- composer.setSubject( prefix + QString::fromUtf8( mail->getSubject().latin1() ) );
+ composer.setSubject( prefix + mail->getSubject());
composer.setMessage( rtext );
- composer.setInReplyTo( QString::fromUtf8(mail->Msgid().latin1()));
+ composer.setInReplyTo( mail->Msgid());
if ( QDialog::Accepted == KApplication::execDialog( &composer ) )
{
diff --git a/kmicromail/viewmail.cpp b/kmicromail/viewmail.cpp
index 2093678..4883231 100644
--- a/kmicromail/viewmail.cpp
+++ b/kmicromail/viewmail.cpp
@@ -98,7 +98,7 @@ void ViewMail::setBody(const RecBodyP&body )
{
m_body = body;
- m_mail[2] = QString::fromUtf8( body->Bodytext().latin1() );
+ m_mail[2] = body->Bodytext();
// qDebug("********text %s ",m_mail[2].latin1() );
attachbutton->setEnabled(body->Parts().count()>0);
attachments->setEnabled(body->Parts().count()>0);
@@ -301,10 +301,10 @@ void ViewMail::setMail(const RecMailP&mail )
m_recMail = mail;
- m_mail[0] = QString::fromUtf8( mail->getFrom().latin1() );
- m_mail[1] = QString::fromUtf8( mail->getSubject().latin1() );
- m_mail[3] = QString::fromUtf8( mail->getDate().latin1() );
- m_mail[4] = QString::fromUtf8( mail->Msgid().latin1() );
+ m_mail[0] = mail->getFrom();
+ m_mail[1] = mail->getSubject();
+ m_mail[3] = mail->getDate();
+ m_mail[4] = mail->Msgid();
m_mail2[0] = mail->To();
m_mail2[1] = mail->CC();
@@ -350,9 +350,9 @@ void ViewMail::setText()
QString bccString;
- toString = QString::fromUtf8(m_mail2[0].join(",").latin1());
- ccString = QString::fromUtf8(m_mail2[1].join(",").latin1());
- bccString = QString::fromUtf8(m_mail2[2].join(",").latin1());
+ toString = m_mail2[0].join(",");
+ ccString = m_mail2[1].join(",");
+ bccString = m_mail2[2].join(",");
setCaption( i18n("E-Mail by %1").arg( m_mail[0] ) );
@@ -450,9 +450,9 @@ void ViewMail::slotReply()
Settings *settings = new Settings();
ComposeMail composer( settings ,this, 0, true);
if (m_recMail->Replyto().isEmpty()) {
- composer.setTo( QString::fromUtf8( m_recMail->getFrom().latin1()));
+ composer.setTo(m_recMail->getFrom());
} else {
- composer.setTo( QString::fromUtf8( m_recMail->Replyto().latin1()));
+ composer.setTo(m_recMail->Replyto());
}
composer.setSubject( prefix + m_mail[1] );
composer.setMessage( rtext );