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 | 7 | ||||
-rw-r--r-- | kmicromail/koprefsdialog.h | 1 | ||||
-rw-r--r-- | kmicromail/libetpan/mime/mailmime_decode.c | 21 | ||||
-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, 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 @@ -485,8 +485,8 @@ 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()); } diff --git a/kmicromail/koprefs.cpp b/kmicromail/koprefs.cpp index 8143b6f..342bbf3 100644 --- a/kmicromail/koprefs.cpp +++ b/kmicromail/koprefs.cpp @@ -59,2 +59,3 @@ KOPrefs::KOPrefs() : KPrefs::setCurrentGroup("General"); + addItemString("SendCodec",&mSendCodec,i18n ("userdefined") ); addItemString("SenderName",&mName,i18n ("Please set at") ); @@ -64,2 +65,3 @@ KOPrefs::KOPrefs() : addItemBool("UseKapi",&mUseKapi,false); + addItemInt("CurrentCodec",&mCurrentCodec,0); @@ -70,3 +72,3 @@ KOPrefs::KOPrefs() : fillMailDefaults(); - + isDirty = false; } @@ -76,2 +78,4 @@ KOPrefs::~KOPrefs() { + if ( isDirty ) + writeConfig(); if (mInstance == this) @@ -112,3 +116,2 @@ 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 @@ -70,4 +70,7 @@ class KOPrefs : public KPimPrefs 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 @@ -149,3 +149,6 @@ void KOPrefsDialog::setupMailTab() 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); @@ -197,2 +200,3 @@ void KOPrefsDialog::usrReadConfig() mEmailEdit->setText(KOPrefs::instance()->mEmail); + mCodecEdit->setText(KOPrefs::instance()->mSendCodec); kdelibcfg->readConfig(); @@ -203,2 +207,3 @@ void KOPrefsDialog::usrWriteConfig() 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 @@ -65,2 +65,3 @@ protected: QLineEdit *mNameEdit; + QLineEdit *mCodecEdit; QLineEdit *mEmailEdit; 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 @@ -119,4 +119,5 @@ int mailmime_encoded_phrase_parse(const char * default_fromcode, type = TYPE_ERROR; /* XXX - removes a gcc warning */ - - while (1) { + // LUTZ add + int appendNewLine = FALSE; + while (1) { //while @@ -201,3 +202,13 @@ int mailmime_encoded_phrase_parse(const char * default_fromcode, } - + // 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) { @@ -214,3 +225,7 @@ int mailmime_encoded_phrase_parse(const char * default_fromcode, else if (r == MAILIMF_ERROR_PARSE) { + // LUTZ add + if ( cur_token >= length ) break; + ++cur_token; + appendNewLine = TRUE; } 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 @@ -78,3 +78,2 @@ encodedString* AbstractMail::decode_String(const encodedString*text,const QStrin } - int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype, @@ -97,7 +96,9 @@ QString AbstractMail::convert_String(const char*text) 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); } 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 @@ -222,2 +222,16 @@ void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*m 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); @@ -346,3 +360,3 @@ QString Genericwrapper::parseMailbox( mailimf_mailbox *box ) } else { - result.append( convert_String(box->mb_display_name).latin1() ); + result.append( convert_String(box->mb_display_name) ); 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 @@ -754,2 +754,21 @@ void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&t 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() ); 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 @@ -127,2 +127,3 @@ RecBodyP MBOXwrapper::fetchBody( const RecMailP &mail ) } + qDebug("MBOXwrapper::fetchBody "); body = parseMail(msg); 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 @@ -130,2 +130,3 @@ RecBodyP MHwrapper::fetchBody( const RecMailP &mail ) { + qDebug("MHwrapper::fetchBody "); RecBodyP body = new RecBody(); diff --git a/kmicromail/mailistviewitem.cpp b/kmicromail/mailistviewitem.cpp index 5ef5b6a..484a635 100644 --- a/kmicromail/mailistviewitem.cpp +++ b/kmicromail/mailistviewitem.cpp @@ -57,4 +57,4 @@ void MailListViewItem::showEntry() } - 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 diff --git a/kmicromail/mainwindow.cpp b/kmicromail/mainwindow.cpp index 98eb9a5..3013931 100644 --- a/kmicromail/mainwindow.cpp +++ b/kmicromail/mainwindow.cpp @@ -14,2 +14,3 @@ #include <qstatusbar.h> +#include <kabc/stdaddressbook.h> extern QStatusBar* globalSstatusBarMainWindow; @@ -22,3 +23,3 @@ extern QStatusBar* globalSstatusBarMainWindow; -#include <kabc/stdaddressbook.h> +#include "koprefs.h" @@ -101,3 +102,10 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) 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 ); @@ -185,2 +193,4 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) li->addTo(helpMenu); + connect( codecMenu, SIGNAL( activated(int) ), this, SLOT( slotSetCodec( int )) ); + slotSetCodec( KOPrefs::instance()->mCurrentCodec ); #ifdef DESKTOP_VERSION @@ -194,2 +204,33 @@ 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() diff --git a/kmicromail/mainwindow.h b/kmicromail/mainwindow.h index f5ab69b..d0a5caf 100644 --- a/kmicromail/mainwindow.h +++ b/kmicromail/mainwindow.h @@ -47,2 +47,3 @@ protected slots: virtual void slotDeleteMail(); + virtual void slotSetCodec(int); virtual void mailHold(int, QListViewItem *,const QPoint&,int); @@ -59,3 +60,3 @@ protected: QPEMenuBar *menuBar; - QPopupMenu *mailMenu, *settingsMenu; + QPopupMenu *mailMenu, *settingsMenu, *codecMenu; QAction *composeMail, *sendQueued, *showFolders, *searchMails, *deleteMails, diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp index af5376f..18a5600 100644 --- a/kmicromail/opiemail.cpp +++ b/kmicromail/opiemail.cpp @@ -35,2 +35,3 @@ #include <libmailwrapper/abstractmail.h> +#include "koprefs.h" @@ -239,2 +240,3 @@ void OpieMail::slotEditSettings() + slotSetCodec( KOPrefs::instance()->mCurrentCodec ); // KApplication::execDialog(settingsDialog); @@ -265,6 +267,6 @@ void OpieMail::replyMail() 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); @@ -284,9 +286,9 @@ void OpieMail::replyMail() 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()); diff --git a/kmicromail/viewmail.cpp b/kmicromail/viewmail.cpp index 2093678..4883231 100644 --- a/kmicromail/viewmail.cpp +++ b/kmicromail/viewmail.cpp @@ -100,3 +100,3 @@ 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() ); @@ -303,6 +303,6 @@ void ViewMail::setMail(const RecMailP&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(); @@ -352,5 +352,5 @@ void ViewMail::setText() - 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(","); @@ -452,5 +452,5 @@ void ViewMail::slotReply() 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()); } |