author | zautrix <zautrix> | 2004-11-06 23:30:02 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-11-06 23:30:02 (UTC) |
commit | 023e0e82dd8bf6421d12492a2dd25534fc43ad31 (patch) (side-by-side diff) | |
tree | cf0533e3ccc642cb57a41953f184f457fa5365ba /kmicromail | |
parent | f8841c92d5251f713eb7a025af8fdee52de45b3d (diff) | |
download | kdepimpi-023e0e82dd8bf6421d12492a2dd25534fc43ad31.zip kdepimpi-023e0e82dd8bf6421d12492a2dd25534fc43ad31.tar.gz kdepimpi-023e0e82dd8bf6421d12492a2dd25534fc43ad31.tar.bz2 |
many ompi fixes
-rw-r--r-- | kmicromail/composemail.cpp | 12 | ||||
-rw-r--r-- | kmicromail/koprefs.cpp | 7 | ||||
-rw-r--r-- | kmicromail/koprefs.h | 5 | ||||
-rw-r--r-- | kmicromail/koprefsdialog.cpp | 19 | ||||
-rw-r--r-- | kmicromail/koprefsdialog.h | 1 | ||||
-rw-r--r-- | kmicromail/libetpan/mime/mailmime_decode.c | 203 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/abstractmail.cpp | 9 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/genericwrapper.cpp | 16 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/imapwrapper.cpp | 19 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mboxwrapper.cpp | 1 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mhwrapper.cpp | 1 | ||||
-rw-r--r-- | kmicromail/mailistviewitem.cpp | 4 | ||||
-rw-r--r-- | kmicromail/mainwindow.cpp | 45 | ||||
-rw-r--r-- | kmicromail/mainwindow.h | 3 | ||||
-rw-r--r-- | kmicromail/opiemail.cpp | 16 | ||||
-rw-r--r-- | kmicromail/viewmail.cpp | 20 |
16 files changed, 244 insertions, 137 deletions
diff --git a/kmicromail/composemail.cpp b/kmicromail/composemail.cpp index 2dcbc75..f44100b 100644 --- a/kmicromail/composemail.cpp +++ b/kmicromail/composemail.cpp @@ -480,18 +480,18 @@ ComposeMail::~ComposeMail() { } void ComposeMail::reEditMail(const RecMailP¤t) { 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 ) : QListViewItem( 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 @@ -54,29 +54,33 @@ KOPrefs::KOPrefs() : { mAppFont = QFont("helvetica",12); mComposeFont = QFont("helvetica",12); 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); } @@ -107,13 +111,12 @@ void KOPrefs::usrReadConfig() KPimPrefs::usrReadConfig(); } void KOPrefs::usrWriteConfig() { - KPimPrefs::usrWriteConfig(); } KConfig* KOPrefs::getConfig() diff --git a/kmicromail/koprefs.h b/kmicromail/koprefs.h index f0a4463..91f3fa3 100644 --- a/kmicromail/koprefs.h +++ b/kmicromail/koprefs.h @@ -65,13 +65,16 @@ class KOPrefs : public KPimPrefs // preferences data KConfig* getConfig(); QFont mAppFont; QFont mComposeFont; QFont mReadFont; QString mName; + QString mSendCodec; QString mEmail; - bool mSendLater, mViewAsHtml, mUseKapi; + QString mCurrentCodeName; + int mCurrentCodec; + bool mSendLater, mViewAsHtml, mUseKapi, isDirty; private: }; #endif diff --git a/kmicromail/koprefsdialog.cpp b/kmicromail/koprefsdialog.cpp index c878fc9..4abf859 100644 --- a/kmicromail/koprefsdialog.cpp +++ b/kmicromail/koprefsdialog.cpp @@ -138,19 +138,22 @@ void KOPrefsDialog::setupMailTab() QGridLayout *topLayout = new QGridLayout(topFrame,4,2); topLayout->setSpacing(spacingHint()); topLayout->setMargin(marginHint()); KPrefsDialogWidBool* ttt = addWidBool(i18n("View mail as html"), &(KOPrefs::instance()->mViewAsHtml),topFrame); - topLayout->addMultiCellWidget(ttt->checkBox(),0,0,0,1); - - + topLayout->addMultiCellWidget(ttt->checkBox(),0,0,0,1); + + ttt = addWidBool(i18n("Send mails later"), - &(KOPrefs::instance()->mSendLater),topFrame); - topLayout->addMultiCellWidget(ttt->checkBox(),1,1,0,1); - + &(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() { QFrame *topFrame = addPage(i18n("Fonts"),0,0); @@ -192,19 +195,21 @@ void KOPrefsDialog::setupFontsTab() } 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(); - kdelibcfg->writeConfig(); + KOPrefs::instance()->mSendCodec = mCodecEdit->text(); + kdelibcfg->writeConfig(); } #if 0 void KOPrefsDialog::setupLocaleDateTab() diff --git a/kmicromail/koprefsdialog.h b/kmicromail/koprefsdialog.h index 615574b..a0416ae 100644 --- a/kmicromail/koprefsdialog.h +++ b/kmicromail/koprefsdialog.h @@ -60,12 +60,13 @@ protected: void setupGlobalTab(); void setupMailTab(); void setupFontsTab(); private: KDEPIMConfigWidget* kdelibcfg; QLineEdit *mNameEdit; + QLineEdit *mCodecEdit; QLineEdit *mEmailEdit; QLabel *mNameLabel; QLabel *mEmailLabel; #if 0 /* public slots: 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 @@ -114,114 +114,129 @@ int mailmime_encoded_phrase_parse(const char * default_fromcode, goto err; } first = TRUE; type = TYPE_ERROR; /* XXX - removes a gcc warning */ + // LUTZ add + int appendNewLine = FALSE; + while (1) { //while - while (1) { - - r = mailmime_encoded_word_parse(message, length, &cur_token, &word); - if (r == MAILIMF_NO_ERROR) { - if (!first) { - if (type != TYPE_ENCODED_WORD) { - if (mmap_string_append_c(gphrase, ' ') == NULL) { - mailmime_encoded_word_free(word); - res = MAILIMF_ERROR_MEMORY; - goto free; - } - } - } - type = TYPE_ENCODED_WORD; - wordutf8 = NULL; - r = charconv(tocode, word->wd_charset, word->wd_text, - strlen(word->wd_text), &wordutf8); - switch (r) { - case MAIL_CHARCONV_ERROR_MEMORY: - mailmime_encoded_word_free(word); - res = MAILIMF_ERROR_MEMORY; - goto free; - - case MAIL_CHARCONV_ERROR_UNKNOWN_CHARSET: - case MAIL_CHARCONV_ERROR_CONV: - mailmime_encoded_word_free(word); - res = MAILIMF_ERROR_PARSE; - goto free; - } + r = mailmime_encoded_word_parse(message, length, &cur_token, &word); + if (r == MAILIMF_NO_ERROR) { + if (!first) { + if (type != TYPE_ENCODED_WORD) { + if (mmap_string_append_c(gphrase, ' ') == NULL) { + mailmime_encoded_word_free(word); + res = MAILIMF_ERROR_MEMORY; + goto free; + } + } + } + type = TYPE_ENCODED_WORD; + wordutf8 = NULL; + r = charconv(tocode, word->wd_charset, word->wd_text, + strlen(word->wd_text), &wordutf8); + switch (r) { + case MAIL_CHARCONV_ERROR_MEMORY: + mailmime_encoded_word_free(word); + res = MAILIMF_ERROR_MEMORY; + goto free; + + case MAIL_CHARCONV_ERROR_UNKNOWN_CHARSET: + case MAIL_CHARCONV_ERROR_CONV: + mailmime_encoded_word_free(word); + res = MAILIMF_ERROR_PARSE; + goto free; + } - if (wordutf8 != NULL) { - if (mmap_string_append(gphrase, wordutf8) == NULL) { + if (wordutf8 != NULL) { + if (mmap_string_append(gphrase, wordutf8) == NULL) { + mailmime_encoded_word_free(word); + free(wordutf8); + res = MAILIMF_ERROR_MEMORY; + goto free; + } + free(wordutf8); + } mailmime_encoded_word_free(word); - free(wordutf8); - res = MAILIMF_ERROR_MEMORY; + first = FALSE; + } + else if (r == MAILIMF_ERROR_PARSE) { + /* do nothing */ + } + else { + res = r; goto free; - } - free(wordutf8); } - mailmime_encoded_word_free(word); - first = FALSE; - } - else if (r == MAILIMF_ERROR_PARSE) { - /* do nothing */ - } - else { - res = r; - goto free; - } - - if (r == MAILIMF_ERROR_PARSE) { - char * raw_word; - r = mailmime_non_encoded_word_parse(message, length, - &cur_token, &raw_word); - if (r == MAILIMF_NO_ERROR) { - if (!first) { - if (mmap_string_append_c(gphrase, ' ') == NULL) { - free(raw_word); - res = MAILIMF_ERROR_MEMORY; - goto free; - } - } - type = TYPE_WORD; + if (r == MAILIMF_ERROR_PARSE) { + char * raw_word; + + r = mailmime_non_encoded_word_parse(message, length, + &cur_token, &raw_word); + if (r == MAILIMF_NO_ERROR) { + if (!first) { + if (mmap_string_append_c(gphrase, ' ') == NULL) { + free(raw_word); + res = MAILIMF_ERROR_MEMORY; + goto free; + } + } + type = TYPE_WORD; - wordutf8 = NULL; - r = charconv(tocode, default_fromcode, raw_word, - strlen(raw_word), &wordutf8); + wordutf8 = NULL; + r = charconv(tocode, default_fromcode, raw_word, + strlen(raw_word), &wordutf8); - switch (r) { - case MAIL_CHARCONV_ERROR_MEMORY: - free(raw_word); - res = MAILIMF_ERROR_MEMORY; - goto free; + switch (r) { + case MAIL_CHARCONV_ERROR_MEMORY: + free(raw_word); + res = MAILIMF_ERROR_MEMORY; + goto free; - case MAIL_CHARCONV_ERROR_UNKNOWN_CHARSET: - case MAIL_CHARCONV_ERROR_CONV: - free(raw_word); - res = MAILIMF_ERROR_PARSE; - goto free; - } - - if (mmap_string_append(gphrase, wordutf8) == NULL) { - free(wordutf8); - free(raw_word); - res = MAILIMF_ERROR_MEMORY; - goto free; - } - // LUTZ fix - free(wordutf8); - free(raw_word); - first = FALSE; + case MAIL_CHARCONV_ERROR_UNKNOWN_CHARSET: + case MAIL_CHARCONV_ERROR_CONV: + free(raw_word); + 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); + res = MAILIMF_ERROR_MEMORY; + goto free; + } + // LUTZ fix + free(wordutf8); + free(raw_word); + first = FALSE; + } + else if (r == MAILIMF_ERROR_PARSE) { + // LUTZ add + if ( cur_token >= length ) + break; + ++cur_token; + appendNewLine = TRUE; + } + else { + res = r; + goto free; + } } - else if (r == MAILIMF_ERROR_PARSE) { - break; - } - else { - res = r; - goto free; - } - } } if (first) { res = MAILIMF_ERROR_PARSE; goto free; } @@ -284,14 +299,14 @@ mailmime_non_encoded_word_parse(const char * message, size_t length, break; cur_token ++; } if (cur_token - begin == 0) { - res = MAILIMF_ERROR_PARSE; - goto err; + res = MAILIMF_ERROR_PARSE; + goto err; } text = malloc(cur_token - begin + 1); if (text == NULL) { res = MAILIMF_ERROR_MEMORY; goto err; 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 @@ -73,13 +73,12 @@ encodedString* AbstractMail::decode_String(const encodedString*text,const QStrin 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); @@ -92,17 +91,19 @@ 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; } 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 @@ -217,12 +217,26 @@ void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*m 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); } @@ -341,13 +355,13 @@ 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; 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 @@ -749,12 +749,31 @@ void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&t 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); } 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 @@ -122,12 +122,13 @@ RecBodyP MBOXwrapper::fetchBody( const RecMailP &mail ) ; // << "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; 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 @@ -125,12 +125,13 @@ void MHwrapper::deleteMail(const RecMailP&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; diff --git a/kmicromail/mailistviewitem.cpp b/kmicromail/mailistviewitem.cpp index 5ef5b6a..484a635 100644 --- a/kmicromail/mailistviewitem.cpp +++ b/kmicromail/mailistviewitem.cpp @@ -52,14 +52,14 @@ void MailListViewItem::showEntry() mKeyMap.insert(3, "k" + fsort); //setText(3, "kB" + fsort ); // test only } else { //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(); int kom = date.find( ",")+2; if ( kom == 1 ) kom = 0; diff --git a/kmicromail/mainwindow.cpp b/kmicromail/mainwindow.cpp index 98eb9a5..3013931 100644 --- a/kmicromail/mainwindow.cpp +++ b/kmicromail/mainwindow.cpp @@ -9,21 +9,22 @@ #include <kiconloader.h> #include <kapplication.h> #ifdef DESKTOP_VERSION #include <qapplication.h> #include <qstatusbar.h> +#include <kabc/stdaddressbook.h> extern QStatusBar* globalSstatusBarMainWindow; #else #include <qpe/qpeapplication.h> #endif #include "defines.h" #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 ) { #ifdef DESKTOP_VERSION globalSstatusBarMainWindow = statusBar(); @@ -96,13 +97,20 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) editSettings->addTo( settingsMenu ); connect( editSettings, SIGNAL( activated() ), SLOT( slotEditSettings() ) ); 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 ); setCentralWidget( wrapperBox ); // QWidget *view = new QWidget( wrapperBox ); @@ -180,21 +188,54 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) li = new QAction(i18n("Licence"),QPixmap(), 0, 0, this); connect( li, SIGNAL( activated() ), SLOT( showLicence()) ); li->addTo(helpMenu); 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 } 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(); } void MainWindow::showAbout() { diff --git a/kmicromail/mainwindow.h b/kmicromail/mainwindow.h index f5ab69b..d0a5caf 100644 --- a/kmicromail/mainwindow.h +++ b/kmicromail/mainwindow.h @@ -42,25 +42,26 @@ protected slots: virtual void slotShowFolders( bool show ); virtual void refreshMailView(const QValueList<RecMailP>&); virtual void displayMail(); 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(); virtual void mailLeftClicked( QListViewItem * ); void showLicence(); void showAbout(); void showEtpanLicence(); 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; QListView *mailView; //QBoxLayout *layout; }; diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp index af5376f..18a5600 100644 --- a/kmicromail/opiemail.cpp +++ b/kmicromail/opiemail.cpp @@ -30,12 +30,13 @@ #else #include <qpe/qpeapplication.h> #endif #include <libmailwrapper/smtpwrapper.h> #include <libmailwrapper/mailtypes.h> #include <libmailwrapper/abstractmail.h> +#include "koprefs.h" //using namespace Opie::Core; OpieMail::OpieMail( QWidget *parent, const char *name ) : MainWindow( parent, name) //, WStyle_ContextHelp ) { @@ -234,12 +235,13 @@ void OpieMail::slotEditSettings() KOPrefsDialog settingsDialog( this, "koprefs", true ); #ifndef DESKTOP_VERSION settingsDialog.showMaximized(); #endif settingsDialog.exec(); + slotSetCodec( KOPrefs::instance()->mCurrentCodec ); // KApplication::execDialog(settingsDialog); } void OpieMail::slotEditAccounts() { EditAccounts eaDialog( settings, this, 0, true ); @@ -260,16 +262,16 @@ void OpieMail::replyMail() if (!item) return; RecMailP mail = ((MailListViewItem*)item)->data(); RecBodyP body = folderView->fetchBody(mail); 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++) { rtext += "> " + *it + "\n"; } @@ -279,19 +281,19 @@ void OpieMail::replyMail() if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; else prefix = "Re: "; // no i18n on purpose 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 ) ) { mail->Wrapper()->answeredMail(mail); } delete settings; diff --git a/kmicromail/viewmail.cpp b/kmicromail/viewmail.cpp index 2093678..4883231 100644 --- a/kmicromail/viewmail.cpp +++ b/kmicromail/viewmail.cpp @@ -95,13 +95,13 @@ AttachItem* ViewMail::lastChild(AttachItem*parent) } 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); if (body->Parts().count()==0) { return; @@ -298,16 +298,16 @@ void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int 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(); m_mail2[2] = mail->Bcc(); setText(); @@ -347,15 +347,15 @@ void ViewMail::setText() QString toString; QString ccString; 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] ) ); m_mailHtml = "<html><body>" "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" @@ -447,15 +447,15 @@ void ViewMail::slotReply() if ( m_mail[1].find(QRegExp("^Re: .*$")) != -1) prefix = ""; else prefix = "Re: "; // no i18n on purpose 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 ); composer.setInReplyTo(m_recMail->Msgid()); if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) |