author | zautrix <zautrix> | 2004-11-07 10:11:25 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-11-07 10:11:25 (UTC) |
commit | b6ef669713ee1d52adcfc9754dd039a4ff6675da (patch) (side-by-side diff) | |
tree | eac59d1b135cbf87e0b9aca21213115331995203 | |
parent | dcb3a171bca38934185de67e378956e6fd044f17 (diff) | |
download | kdepimpi-b6ef669713ee1d52adcfc9754dd039a4ff6675da.zip kdepimpi-b6ef669713ee1d52adcfc9754dd039a4ff6675da.tar.gz kdepimpi-b6ef669713ee1d52adcfc9754dd039a4ff6675da.tar.bz2 |
encoding fixes
-rw-r--r-- | kmicromail/composemail.cpp | 58 | ||||
-rw-r--r-- | kmicromail/composemail.h | 2 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/genericwrapper.cpp | 1 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/imapwrapper.cpp | 11 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mailtypes.cpp | 11 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mailtypes.h | 3 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mailwrapper.h | 5 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/storemail.cpp | 12 | ||||
-rw-r--r-- | kmicromail/opiemail.cpp | 2 | ||||
-rw-r--r-- | kmicromail/viewmail.cpp | 1 |
10 files changed, 74 insertions, 32 deletions
diff --git a/kmicromail/composemail.cpp b/kmicromail/composemail.cpp index f44100b..49fd14f 100644 --- a/kmicromail/composemail.cpp +++ b/kmicromail/composemail.cpp @@ -1,14 +1,14 @@ // CHANGED 2004-08-06 Lutz Rogowski -#include <kabc/addresseedialog.h> -#include <kabc/stdaddressbook.h> -#include <kabc/addressee.h> + #ifdef DESKTOP_VERSION #include <qapplication.h> #include <kabc/addresseedialog.h> +#include <kabc/stdaddressbook.h> +#include <kabc/addressee.h> #endif //DESKTOP_VERSION #include <libkdepim/externalapphandler.h> #include "koprefs.h" #ifdef MINIKDE_KDIALOG_H @@ -45,13 +45,15 @@ //using namespace Opie::Core; //using namespace Opie::Ui; ComposeMail::ComposeMail( Settings *sett, QWidget *parent, const char *name, bool modal ) : ComposeMailUI( parent, name, modal ) { + mPickLineEdit = 0; + mEncoding = KOPrefs::instance()->mCurrentCodeName; connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); settings = sett; m_replyid = ""; if ( KOPrefs::instance()->mUseKapi) { KConfig config( locateLocal("config", "kabcrc") ); @@ -162,31 +164,31 @@ void ComposeMail::fillSettings() void ComposeMail::saveAsDraft() { Opie::Core::OSmartPointer<Mail> mail= new Mail(); - mail->setMail(fromBox->currentText().utf8 ()); - mail->setTo( toLine->text().utf8 () ); - mail->setName(senderNameEdit->text().utf8 ()); - mail->setCC( ccLine->text().utf8 () ); - mail->setBCC( bccLine->text().utf8 () ); - mail->setReply( replyLine->text().utf8 () ); - mail->setSubject( subjectLine->text().utf8 () ); + mail->setMail(fromBox->currentText()); + mail->setTo( toLine->text() ); + mail->setName(senderNameEdit->text()); + mail->setCC( ccLine->text() ); + mail->setBCC( bccLine->text() ); + mail->setReply( replyLine->text() ); + mail->setSubject( subjectLine->text() ); if (!m_replyid.isEmpty()) { QStringList ids; ids.append(m_replyid); mail->setInreply(ids); } - QString txt = message->text().utf8 (); + QString txt = message->text(); if ( !sigMultiLine->text().isEmpty() ) { txt.append( "\n--\n" ); txt.append( sigMultiLine->text() ); } mail->setMessage( txt ); - + mail->setCharset (mEncoding); /* only use the default drafts folder name! */ Storemail wrapper(AbstractMail::draftFolder()); wrapper.storeMail(mail); AttachViewItem *it = (AttachViewItem *) attList->firstChild(); /* attachments we will ignore! */ @@ -405,38 +407,39 @@ void ComposeMail::accept() odebug << "Sending Mail with " << smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() << oendl; #endif Opie::Core::OSmartPointer<Mail> mail=new Mail; SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); - mail->setMail(fromBox->currentText().utf8 ()); + mail->setMail(fromBox->currentText()); if ( !toLine->text().isEmpty() ) { - mail->setTo( toLine->text().utf8 () ); + mail->setTo( toLine->text() ); } else { QMessageBox::warning(0,i18n("Sending mail"), i18n("No Receiver spezified" ) ); return; } - mail->setName(senderNameEdit->text().utf8 ()); - mail->setCC( ccLine->text().utf8 () ); - mail->setBCC( bccLine->text().utf8 () ); - mail->setReply( replyLine->text().utf8 () ); - mail->setSubject( subjectLine->text().utf8 () ); + mail->setName(senderNameEdit->text()); + mail->setCC( ccLine->text() ); + mail->setBCC( bccLine->text() ); + mail->setReply( replyLine->text() ); + mail->setSubject( subjectLine->text() ); if (!m_replyid.isEmpty()) { QStringList ids; - ids.append(m_replyid.utf8 ()); + ids.append(m_replyid); mail->setInreply(ids); } - QString txt = message->text().utf8 (); + QString txt = message->text(); if ( !sigMultiLine->text().isEmpty() ) { txt.append( "\n--\n" ); - txt.append( sigMultiLine->text().utf8 () ); + txt.append( sigMultiLine->text() ); } mail->setMessage( txt ); + mail->setCharset (mEncoding); AttachViewItem *it = (AttachViewItem *) attList->firstChild(); while ( it != 0 ) { mail->addAttachment( it->getAttachment() ); it = (AttachViewItem *) it->nextSibling(); } @@ -473,25 +476,34 @@ void ComposeMail::reject() qDebug("return "); return; } QDialog::reject(); } +void ComposeMail::setCharset(const QString& charset) +{ + if ( !charset.isEmpty() ) + mEncoding = charset; + qDebug("ComposeMail::setCharset %s ", mEncoding.latin1()); +} ComposeMail::~ComposeMail() { } void ComposeMail::reEditMail(const RecMailP¤t) { RecMailP data = current; - message->setText(data->Wrapper()->fetchBody(current)->Bodytext()); + RecBodyP body = data->Wrapper()->fetchBody(current); + + message->setText(body->Bodytext()); subjectLine->setText( data->getSubject()); toLine->setText(data->To().join(",")); ccLine->setText(data->CC().join(",")); bccLine->setText(data->Bcc().join(",")); replyLine->setText(data->Replyto()); + setCharset(body->getCharset()); } AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) : QListViewItem( parent ) { attachment = att; diff --git a/kmicromail/composemail.h b/kmicromail/composemail.h index 0fc41fb..a7fa41c 100644 --- a/kmicromail/composemail.h +++ b/kmicromail/composemail.h @@ -45,12 +45,13 @@ public slots: void setTo( const QString & to ); void setSubject( const QString & subject ); void setInReplyTo( const QString & messageId ); void setMessage( const QString & text ); void insertAttendees(const QString&, const QStringList& namelist, const QStringList& emaillist, const QStringList& uidlist); + void setCharset(const QString&); protected slots: void accept(); void reject(); @@ -71,12 +72,13 @@ private slots: protected: QLineEdit* mPickLineEdit; Opie::Core::OSmartPointer<Mail> mMail; Settings *settings; QList<SMTPaccount> smtpAccounts; QString m_replyid; + QString mEncoding; bool warnAttach; }; class AttachViewItem : public QListViewItem { public: diff --git a/kmicromail/libmailwrapper/genericwrapper.cpp b/kmicromail/libmailwrapper/genericwrapper.cpp index 49227dd..28d45ce 100644 --- a/kmicromail/libmailwrapper/genericwrapper.cpp +++ b/kmicromail/libmailwrapper/genericwrapper.cpp @@ -223,12 +223,13 @@ void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*m 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() ) { + target->setCharset( charset ); 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); } diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp index eb2b47d..2a54381 100644 --- a/kmicromail/libmailwrapper/imapwrapper.cpp +++ b/kmicromail/libmailwrapper/imapwrapper.cpp @@ -47,13 +47,13 @@ int IMAPwrapper::selectMbox(const QString&mbox) void IMAPwrapper::imap_progress( size_t current, size_t maximum ) { //qDebug("imap progress %d of %d ",current,maximum ); //Global::statusMessage(i18n("Downloading message %1 of %2").arg( current).arg(maximum)); //qApp->processEvents() - static int last = 0; + static unsigned int last = 0; if ( last != current ) IMAPwrapper::progress(); last = current; } void IMAPwrapper::progress( QString m ) { @@ -286,16 +286,16 @@ void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSma tryAgain = -1; mailimap_msg_att * msg_att; int i = 0; for (current = clist_begin(result); current != 0; current=clist_next(current)) { ++i; //qDebug("iii %d ",i); - msg_att = (mailimap_msg_att*)current->data; + msg_att = (mailimap_msg_att*)current->data; RecMail*m = parse_list_result(msg_att); if (m) { - if ( maxSizeInKb == 0 || m->Msgsize()<=maxSizeInKb*1024 ) { + if ( maxSizeInKb == 0 || m->Msgsize()<=(unsigned int ) maxSizeInKb*1024 ) { m->setNumber(i); m->setMbox(mailbox); m->setWrapper(this); target.append(m); } } @@ -412,13 +412,13 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) { RecMail * m = 0; mailimap_msg_att_item *item=0; clistcell *current,*c,*cf; mailimap_msg_att_dynamic*flist; mailimap_flag_fetch*cflag; - int size; + int size = 0; QBitArray mFlags(7); QStringList addresslist; if (!m_att) { return m; } @@ -758,12 +758,13 @@ void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&t int err = MAILIMF_NO_ERROR; QString charset = currentPart->searchParamter( "charset"); qDebug("CHARSET %s ",charset.latin1() ); //if ( false ) { if ( !charset.isEmpty() ) { + target_body->setCharset( charset ); //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); @@ -1179,13 +1180,13 @@ int IMAPwrapper::deleteAllMail(const FolderP&folder) int IMAPwrapper::createMbox(const QString&folder,const FolderP&parentfolder,const QString& delemiter,bool getsubfolder) { if (folder.length()==0) return 0; login(); if (!m_imap) {return 0;} QString pre = account->getPrefix(); - if (delemiter.length()>0 && pre.findRev(delemiter)!=pre.length()-1) { + if (delemiter.length()>0 && pre.findRev(delemiter)!=((int)pre.length())-1) { pre+=delemiter; } if (parentfolder) { pre += parentfolder->getDisplayName()+delemiter; } pre+=folder; diff --git a/kmicromail/libmailwrapper/mailtypes.cpp b/kmicromail/libmailwrapper/mailtypes.cpp index af3b9d0..89150ad 100644 --- a/kmicromail/libmailwrapper/mailtypes.cpp +++ b/kmicromail/libmailwrapper/mailtypes.cpp @@ -284,12 +284,13 @@ RecBody::RecBody() RecBody::RecBody(const RecBody&old) :Opie::Core::ORefCount(),m_BodyText(),m_PartsList(),m_description(new RecPart()) { m_BodyText = old.m_BodyText; m_PartsList = old.m_PartsList; m_description = old.m_description; + mCharset = old.mCharset; // odebug << "Recbody copy constructor" << oendl; } RecBody::~RecBody() { } @@ -327,12 +328,22 @@ void RecBody::setDescription(const RecPartP&des) const RecPartP& RecBody::Description()const { return m_description; } +void RecBody::setCharset(const QString& str) +{ + mCharset = str; +} + +QString RecBody::getCharset()const +{ + return mCharset; +} + /* handling encoded content */ encodedString::encodedString() { init(); } diff --git a/kmicromail/libmailwrapper/mailtypes.h b/kmicromail/libmailwrapper/mailtypes.h index c1c1a74..32d92c0 100644 --- a/kmicromail/libmailwrapper/mailtypes.h +++ b/kmicromail/libmailwrapper/mailtypes.h @@ -130,21 +130,24 @@ public: typedef Opie::Core::OSmartPointer<RecPart> RecPartP; class RecBody:public Opie::Core::ORefCount { protected: QString m_BodyText; + QString mCharset; QValueList<RecPartP> m_PartsList; RecPartP m_description; public: RecBody(); RecBody(const RecBody&old); virtual ~RecBody(); void setBodytext(const QString&); const QString& Bodytext()const; + void setCharset(const QString&); + QString getCharset()const; void setDescription(const RecPartP&des); const RecPartP& Description()const; void setParts(const QValueList<RecPartP>&parts); const QValueList<RecPartP>& Parts()const; diff --git a/kmicromail/libmailwrapper/mailwrapper.h b/kmicromail/libmailwrapper/mailwrapper.h index 88f10da..ea6bf36 100644 --- a/kmicromail/libmailwrapper/mailwrapper.h +++ b/kmicromail/libmailwrapper/mailwrapper.h @@ -79,15 +79,18 @@ public: void setSubject( const QString&s ) { subject = s; } const QString&getReply()const{ return reply; } void setReply( const QString&a ) { reply = a; } void setInreply(const QStringList&list){m_in_reply_to = list;} const QStringList&Inreply()const{return m_in_reply_to;} + void setCharset( const QString&a ) { charset= a; } + const QString& getCharset() { return charset; } + private: QList<Attachment> attList; - QString name, mail, to, cc, bcc, reply, subject, message; + QString name, mail, to, cc, bcc, reply, subject, message, charset; QStringList m_in_reply_to; }; class Folder:public Opie::Core::ORefCount { public: diff --git a/kmicromail/libmailwrapper/storemail.cpp b/kmicromail/libmailwrapper/storemail.cpp index ed1d44a..9d1735f 100644 --- a/kmicromail/libmailwrapper/storemail.cpp +++ b/kmicromail/libmailwrapper/storemail.cpp @@ -4,12 +4,13 @@ #include "abstractmail.h" #include <libetpan/libetpan.h> #include <qstring.h> #include <stdlib.h> +#include <kglobal.h> using namespace Opie::Core; Storemail::Storemail(Account*aAccount,const QString&aFolder) : Generatemail() { wrapper = 0; @@ -62,14 +63,21 @@ int Storemail::storeMail(const Opie::Core::OSmartPointer<Mail>&mail) } char *data; size_t size; data = 0; mailmessage * msg = 0; - msg = mime_message_init(mimeMail); - mime_message_set_tmpdir(msg,getenv( "HOME" )); + msg = mime_message_init(mimeMail); + QString fileName; +#ifdef DESKTOP_VERSION + fileName = locateLocal("tmp", ""); +#else + fileName = "/tmp/"; +#endif + //mime_message_set_tmpdir(msg,getenv( "HOME" )); + mime_message_set_tmpdir(msg,(char*)fileName.latin1()); int r = mailmessage_fetch(msg,&data,&size); mime_message_detach_mime(msg); mailmessage_free(msg); msg = 0; if (r != MAIL_NO_ERROR || !data) { qDebug("Error fetching mime... "); diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp index 18a5600..c20c7ce 100644 --- a/kmicromail/opiemail.cpp +++ b/kmicromail/opiemail.cpp @@ -288,13 +288,13 @@ void OpieMail::replyMail() } else { composer.setTo( mail->Replyto()); } composer.setSubject( prefix + mail->getSubject()); composer.setMessage( rtext ); composer.setInReplyTo( mail->Msgid()); - + composer.setCharset( body->getCharset() ); if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) { mail->Wrapper()->answeredMail(mail); } delete settings; diff --git a/kmicromail/viewmail.cpp b/kmicromail/viewmail.cpp index 4883231..3bd6f41 100644 --- a/kmicromail/viewmail.cpp +++ b/kmicromail/viewmail.cpp @@ -454,12 +454,13 @@ void ViewMail::slotReply() } else { composer.setTo(m_recMail->Replyto()); } composer.setSubject( prefix + m_mail[1] ); composer.setMessage( rtext ); composer.setInReplyTo(m_recMail->Msgid()); + composer.setCharset( m_body->getCharset() ); if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) { m_recMail->Wrapper()->answeredMail(m_recMail); } delete settings; |