From 81514d58dbf63ea16beb0d9b72eb8e3778e83100 Mon Sep 17 00:00:00 2001 From: Martin Koller Date: Tue, 12 Feb 2013 08:23:00 +0100 Subject: [PATCH] fix character encoding for body in composer window on cmdline usage assemble message before it is passed to the composer window, which makes sure that also the ContentType header is used which contains the charset. BUG: 259039 FIXED-IN: 4.10.1 REVIEW: 108884 --- kmkernel.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kmkernel.cpp b/kmkernel.cpp index 243ba8f37..f568d3a9d 100644 --- a/kmkernel.cpp +++ b/kmkernel.cpp @@ -629,7 +629,7 @@ int KMKernel::openComposer( const QString &to, const QString &cc, } else if ( !body.isEmpty() ) { context = KMail::Composer::NoTemplate; - msg->setBody( body.toLatin1() ); + msg->setBody( body.toUtf8() ); } else { TemplateParser::TemplateParser parser( msg, TemplateParser::TemplateParser::NewMessage ); @@ -656,6 +656,7 @@ int KMKernel::openComposer( const QString &to, const QString &cc, } } + msg->assemble(); KMail::Composer * cWin = KMail::makeComposer( msg, false, false, context ); if (!to.isEmpty()) cWin->setFocusToSubject(); @@ -754,6 +755,7 @@ int KMKernel::openComposer (const QString &to, const QString &cc, } } + msg->assemble(); KMail::Composer * cWin = KMail::makeComposer( KMime::Message::Ptr(), false, false,context ); cWin->setMessage( msg, false, false, !isICalInvitation /* mayAutoSign */ ); cWin->setSigningAndEncryptionDisabled( isICalInvitation @@ -799,13 +801,14 @@ QDBusObjectPath KMKernel::openComposer( const QString &to, const QString &cc, if ( !subject.isEmpty() ) msg->subject()->fromUnicodeString( subject, "utf-8" ); if ( !to.isEmpty() ) msg->to()->fromUnicodeString( to, "utf-8" ); if ( !body.isEmpty() ) { - msg->setBody(body.toLatin1()); + msg->setBody( body.toUtf8() ); } else { TemplateParser::TemplateParser parser( msg, TemplateParser::TemplateParser::NewMessage ); parser.setIdentityManager( KMKernel::self()->identityManager() ); parser.process( KMime::Message::Ptr() ); } + msg->assemble(); const KMail::Composer::TemplateContext context = body.isEmpty() ? KMail::Composer::New : KMail::Composer::NoTemplate; KMail::Composer * cWin = KMail::makeComposer( msg, false, false, context ); @@ -851,6 +854,7 @@ QDBusObjectPath KMKernel::newMessage( const QString &to, if ( !bcc.isEmpty() ) msg->bcc()->fromUnicodeString( bcc, "utf-8" ); if ( !to.isEmpty() ) msg->to()->fromUnicodeString( to, "utf-8" ); + msg->assemble(); TemplateParser::TemplateParser parser( msg, TemplateParser::TemplateParser::NewMessage ); parser.setIdentityManager( identityManager() ); Akonadi::Collection col = folder ? folder->collection() : Akonadi::Collection();