[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kdepim/KDE/4.9] kmail: Fix Bug 304940 - kmail should warn when replying to an encrypted mail
From: Montel Laurent <montel () kde ! org>
Date: 2012-09-05 11:06:12
Message-ID: 20120905110612.F2DD7A6094 () git ! kde ! org
[Download RAW message or body]
Git commit e4564c4266078eda3ef8d987f33e194665455720 by Montel Laurent.
Committed on 05/09/2012 at 13:05.
Pushed by mlaurent into branch 'KDE/4.9'.
Fix Bug 304940 - kmail should warn when replying to an encrypted mail
unencrypted
FIXED-IN: 4.9.2
BUG: 304940
M +2 -2 kmail/composer.h
M +38 -11 kmail/kmcommands.cpp
M +11 -8 kmail/kmcomposewin.cpp
M +4 -4 kmail/kmcomposewin.h
M +6 -6 kmail/kmkernel.cpp
M +2 -2 kmail/kmmainwidget.cpp
M +1 -1 kmail/mailserviceimpl.cpp
M +7 -2 kmail/util.cpp
M +1 -1 kmail/util.h
http://commits.kde.org/kdepim/e4564c4266078eda3ef8d987f33e194665455720
diff --git a/kmail/composer.h b/kmail/composer.h
index 082834d..117faa3 100644
--- a/kmail/composer.h
+++ b/kmail/composer.h
@@ -76,7 +76,7 @@ class Composer : public KMail::SecondaryWindow
* Set the message the composer shall work with. This discards
* previous messages without calling applyChanges() on them before.
*/
- virtual void setMsg( const KMime::Message::Ptr &newMsg, bool mayAutoSign=true,
+ virtual void setMessage( const KMime::Message::Ptr &newMsg, bool lastSignState \
= false, bool lastEncryptState = false, bool mayAutoSign=true,
bool allowDecryption=false, bool isModified=false ) = 0;
virtual void setCurrentTransport( int transportId ) = 0;
@@ -153,7 +153,7 @@ class Composer : public KMail::SecondaryWindow
virtual void addAttach( KMime::Content *msgPart ) = 0;
};
-Composer *makeComposer( const KMime::Message::Ptr &msg = KMime::Message::Ptr(),
+Composer *makeComposer( const KMime::Message::Ptr &msg = KMime::Message::Ptr(), bool \
lastSignState = false, bool lastEncryptState = false,
Composer::TemplateContext context = Composer::NoTemplate,
uint identity = 0, const QString & textSelection = \
QString(), const QString & customTemplate = QString() );
diff --git a/kmail/kmcommands.cpp b/kmail/kmcommands.cpp
index 03a51be..23bde3b 100644
--- a/kmail/kmcommands.cpp
+++ b/kmail/kmcommands.cpp
@@ -423,7 +423,7 @@ KMCommand::Result KMMailtoComposeCommand::execute()
msg->contentType()->setCharset("utf-8");
msg->to()->fromUnicodeString( KPIMUtils::decodeMailtoUrl( mUrl ), "utf-8" );
- KMail::Composer * win = KMail::makeComposer( msg, KMail::Composer::New, id );
+ KMail::Composer * win = KMail::makeComposer( msg, false, \
false,KMail::Composer::New, id ); win->setFocusToSubject();
win->show();
return OK;
@@ -453,8 +453,11 @@ KMCommand::Result KMMailtoReplyCommand::execute()
factory.setSelection( mSelection );
KMime::Message::Ptr rmsg = factory.createReply().msg;
rmsg->to()->fromUnicodeString( KPIMUtils::decodeMailtoUrl( mUrl ), "utf-8" ); \
//TODO Check the UTF-8 + bool lastEncrypt = false;
+ bool lastSign = false;
+ KMail::Util::lastEncryptAndSignState(lastEncrypt, lastSign, msg);
- KMail::Composer * win = KMail::makeComposer( rmsg, KMail::Composer::Reply, 0, \
mSelection ); + KMail::Composer * win = KMail::makeComposer( rmsg, lastSign, \
lastEncrypt, KMail::Composer::Reply, 0, mSelection ); win->setReplyFocus();
win->show();
@@ -482,8 +485,11 @@ KMCommand::Result KMMailtoForwardCommand::execute()
factory.setFolderIdentity( MailCommon::Util::folderIdentity( item ) );
KMime::Message::Ptr fmsg = factory.createForward();
fmsg->to()->fromUnicodeString( KPIMUtils::decodeMailtoUrl( mUrl ), "utf-8" ); \
//TODO check the utf-8 + bool lastEncrypt = false;
+ bool lastSign = false;
+ KMail::Util::lastEncryptAndSignState(lastEncrypt, lastSign, msg);
- KMail::Composer * win = KMail::makeComposer( fmsg, KMail::Composer::Forward );
+ KMail::Composer * win = KMail::makeComposer( fmsg, lastSign, lastEncrypt, \
KMail::Composer::Forward ); win->show();
return OK;
@@ -559,7 +565,10 @@ KMCommand::Result KMEditMessageCommand::execute()
return Failed;
KMail::Composer *win = KMail::makeComposer();
- win->setMsg( mMessage, false, false );
+ bool lastEncrypt = false;
+ bool lastSign = false;
+ KMail::Util::lastEncryptAndSignState(lastEncrypt, lastSign, mMessage);
+ win->setMessage( mMessage, lastSign, lastEncrypt, false, false );
win->show();
win->setModified( true );
return OK;
@@ -598,7 +607,11 @@ KMCommand::Result KMEditItemCommand::execute()
connect( job, SIGNAL(result(KJob*)), this, SLOT(slotDeleteItem(KJob*)) );
}
KMail::Composer *win = KMail::makeComposer();
- win->setMsg( msg, false, true );
+ bool lastEncrypt = false;
+ bool lastSign = false;
+ KMail::Util::lastEncryptAndSignState(lastEncrypt, lastSign, msg);
+ win->setMessage( msg, lastSign, lastEncrypt, false, true );
+
win->setFolder( item.parentCollection() );
const MailTransport::TransportAttribute *transportAttribute = \
item.attribute<MailTransport::TransportAttribute>(); @@ -669,7 +682,8 @@ \
KMCommand::Result KMUseTemplateCommand::execute() \
newMsg->removeHeader("Message-ID");
KMail::Composer *win = KMail::makeComposer();
- win->setMsg( newMsg, false, true );
+
+ win->setMessage( newMsg, false, false, false, true );
win->show();
return OK;
}
@@ -818,6 +832,7 @@ KMCommand::Result KMReplyCommand::execute()
KMime::Message::Ptr msg = MessageCore::Util::message( item );
if ( !msg )
return Failed;
+
MessageFactory factory( msg, item.id(), \
MailCommon::Util::updatedCollection(item.parentCollection()) ); \
factory.setIdentityManager( KMKernel::self()->identityManager() ); \
factory.setFolderIdentity( MailCommon::Util::folderIdentity( item ) ); @@ -830,8 \
+845,12 @@ KMCommand::Result KMReplyCommand::execute() if(mNoQuote) {
factory.setQuote(false);
}
+ bool lastEncrypt = false;
+ bool lastSign = false;
+ KMail::Util::lastEncryptAndSignState(lastEncrypt, lastSign, msg);
+
MessageFactory::MessageReply reply = factory.createReply();
- KMail::Composer * win = KMail::makeComposer( KMime::Message::Ptr( reply.msg ), \
replyContext( reply ), 0, + KMail::Composer * win = KMail::makeComposer( \
KMime::Message::Ptr( reply.msg ), lastSign, lastEncrypt, replyContext( reply ), 0, \
mSelection,mTemplate ); win->setReplyFocus();
win->show();
@@ -877,10 +896,14 @@ KMCommand::Result KMForwardCommand::createComposer(const \
Akonadi::Item& item)
uint id = msg->headerByType( "X-KMail-Identity" ) ? \
msg->headerByType("X-KMail-Identity")->asUnicodeString().trimmed().toUInt() : 0; \
kDebug() << "mail" << msg->encodedContent(); + bool lastEncrypt = false;
+ bool lastSign = false;
+ KMail::Util::lastEncryptAndSignState(lastEncrypt, lastSign, msg);
+
if ( id == 0 )
id = mIdentity;
{
- KMail::Composer * win = KMail::makeComposer( fwdMsg, KMail::Composer::Forward, \
id,QString(), mTemplate ); + KMail::Composer * win = KMail::makeComposer( fwdMsg, \
lastSign, lastEncrypt, KMail::Composer::Forward, id,QString(), mTemplate ); \
win->show(); }
return OK;
@@ -908,7 +931,7 @@ KMCommand::Result KMForwardCommand::execute()
factory.setFolderIdentity( MailCommon::Util::folderIdentity( firstItem ) );
QPair< KMime::Message::Ptr, KMime::Content* > fwdMsg = \
factory.createForwardDigestMIME(msgList );
- KMail::Composer * win = KMail::makeComposer( fwdMsg.first, \
KMail::Composer::Forward, mIdentity ); + KMail::Composer * win = \
KMail::makeComposer( fwdMsg.first, false, false, KMail::Composer::Forward, mIdentity \
); win->addAttach( fwdMsg.second );
win->show();
return OK;
@@ -963,7 +986,7 @@ KMCommand::Result KMForwardAttachedCommand::execute()
QPair< KMime::Message::Ptr, QList< KMime::Content* > > fwdMsg = \
factory.createAttachedForward( msgList ); if ( !mWin ) {
- mWin = KMail::makeComposer( fwdMsg.first, KMail::Composer::Forward, mIdentity );
+ mWin = KMail::makeComposer( fwdMsg.first, false, false, \
KMail::Composer::Forward, mIdentity ); }
foreach( KMime::Content* attach, fwdMsg.second ) {
mWin->addAttach( attach );
@@ -1534,7 +1557,11 @@ KMCommand::Result KMResendMessageCommand::execute()
const QString replyTo = msg->headerByType( "Reply-To" )->asUnicodeString();
win->setCurrentReplyTo(replyTo);
}
- win->setMsg( newMsg, false, true );
+ bool lastEncrypt = false;
+ bool lastSign = false;
+ KMail::Util::lastEncryptAndSignState(lastEncrypt, lastSign, msg);
+ win->setMessage( newMsg, lastSign, lastEncrypt, false, true );
+
win->show();
return OK;
diff --git a/kmail/kmcomposewin.cpp b/kmail/kmcomposewin.cpp
index 9ce77da..bc946ae 100644
--- a/kmail/kmcomposewin.cpp
+++ b/kmail/kmcomposewin.cpp
@@ -159,22 +159,22 @@ using MailTransport::Transport;
using KPIM::RecentAddresses;
using Message::KMeditor;
-KMail::Composer *KMail::makeComposer( const KMime::Message::Ptr &msg, \
Composer::TemplateContext context, +KMail::Composer *KMail::makeComposer( const \
KMime::Message::Ptr &msg, bool lastSignState, bool lastEncryptState, \
Composer::TemplateContext context,
uint identity, const QString & textSelection,
const QString & customTemplate ) {
- return KMComposeWin::create( msg, context, identity, textSelection, customTemplate \
); + return KMComposeWin::create( msg, lastSignState, lastEncryptState, context, \
identity, textSelection, customTemplate ); }
-KMail::Composer *KMComposeWin::create( const KMime::Message::Ptr &msg, \
Composer::TemplateContext context, +KMail::Composer *KMComposeWin::create( const \
KMime::Message::Ptr &msg, bool lastSignState, bool lastEncryptState, \
Composer::TemplateContext context,
uint identity, const QString & textSelection,
const QString & customTemplate ) {
- return new KMComposeWin( msg, context, identity, textSelection, customTemplate );
+ return new KMComposeWin( msg, lastSignState, lastEncryptState, context, identity, \
textSelection, customTemplate ); }
int KMComposeWin::s_composerNumber = 0;
//-----------------------------------------------------------------------------
-KMComposeWin::KMComposeWin( const KMime::Message::Ptr &aMsg, \
Composer::TemplateContext context, uint id, +KMComposeWin::KMComposeWin( const \
KMime::Message::Ptr &aMsg, bool lastSignState, bool lastEncryptState, \
Composer::TemplateContext context, uint id,
const QString & textSelection, const QString & \
customTemplate ) : KMail::Composer( "kmail-composer#" ),
mDone( false ),
@@ -457,7 +457,7 @@ KMComposeWin::KMComposeWin( const KMime::Message::Ptr &aMsg, \
Composer::TemplateC }
if ( aMsg ) {
- setMsg( aMsg );
+ setMessage( aMsg, lastSignState, lastEncryptState );
}
mComposerBase->recipientsEditor()->setFocus();
@@ -1495,7 +1495,7 @@ void KMComposeWin::setCurrentReplyTo(const QString& replyTo)
}
//-----------------------------------------------------------------------------
-void KMComposeWin::setMsg( const KMime::Message::Ptr &newMsg, bool mayAutoSign,
+void KMComposeWin::setMessage( const KMime::Message::Ptr &newMsg, bool \
lastSignState, bool lastEncryptState, bool mayAutoSign, bool allowDecryption, bool \
isModified ) {
if ( !newMsg ) {
@@ -1503,6 +1503,9 @@ void KMComposeWin::setMsg( const KMime::Message::Ptr &newMsg, \
bool mayAutoSign, return;
}
+ mLastSignActionState = lastSignState;
+ mLastEncryptActionState = lastEncryptState;
+
mComposerBase->setMessage( newMsg );
mMsg = newMsg;
KPIMIdentities::IdentityManager * im = KMKernel::self()->identityManager();
@@ -2347,7 +2350,7 @@ void KMComposeWin::slotNewComposer()
KMime::Message::Ptr msg( new KMime::Message );
MessageHelper::initHeader( msg, KMKernel::self()->identityManager() );
- win = new KMComposeWin( msg );
+ win = new KMComposeWin( msg, false, false );
win->show();
}
diff --git a/kmail/kmcomposewin.h b/kmail/kmcomposewin.h
index fdc25fb..adfb317 100644
--- a/kmail/kmcomposewin.h
+++ b/kmail/kmcomposewin.h
@@ -116,13 +116,13 @@ class KMComposeWin : public KMail::Composer
friend class ::KMComposerEditor;
private: // mailserviceimpl, kmkernel, kmcommands, callback, kmmainwidget
- explicit KMComposeWin( const KMime::Message::Ptr &msg = KMime::Message::Ptr(), \
TemplateContext context = NoTemplate, + explicit KMComposeWin(const \
KMime::Message::Ptr &msg, bool lastSignState, bool lastEncryptState, TemplateContext \
context = NoTemplate,
uint identity = 0, const QString & textSelection = \
QString(), const QString & customTemplate = QString() );
~KMComposeWin();
public:
- static Composer *create( const KMime::Message::Ptr &msg = KMime::Message::Ptr(), \
TemplateContext context = NoTemplate, + static Composer *create( const \
KMime::Message::Ptr &msg, bool lastSignState, bool lastEncryptState, TemplateContext \
context = NoTemplate,
uint identity = 0, const QString & textSelection = \
QString(),
const QString & customTemplate = QString() );
@@ -164,8 +164,8 @@ class KMComposeWin : public KMail::Composer
* Set the message the composer shall work with. This discards
* previous messages without calling applyChanges() on them before.
*/
- void setMsg( const KMime::Message::Ptr &newMsg, bool mayAutoSign=true,
- bool allowDecryption=false, bool isModified=false );
+ void setMessage( const KMime::Message::Ptr &newMsg, bool lastSignState = false, \
bool lastEncryptState = false, + bool mayAutoSign=true, bool \
allowDecryption=false, bool isModified=false );
void setCurrentTransport( int transportId );
diff --git a/kmail/kmkernel.cpp b/kmail/kmkernel.cpp
index de6730a..47a8925 100644
--- a/kmail/kmkernel.cpp
+++ b/kmail/kmkernel.cpp
@@ -651,7 +651,7 @@ int KMKernel::openComposer( const QString &to, const QString &cc,
}
}
- KMail::Composer * cWin = KMail::makeComposer( msg, context );
+ KMail::Composer * cWin = KMail::makeComposer( msg, false, false, context );
if (!to.isEmpty())
cWin->setFocusToSubject();
KUrl::List attachURLs = KUrl::List( attachmentPaths );
@@ -749,8 +749,8 @@ int KMKernel::openComposer (const QString &to, const QString &cc,
}
}
- KMail::Composer * cWin = KMail::makeComposer( KMime::Message::Ptr(), context );
- cWin->setMsg( msg, !isICalInvitation /* mayAutoSign */ );
+ KMail::Composer * cWin = KMail::makeComposer( KMime::Message::Ptr(), false, \
false,context ); + cWin->setMessage( msg, false, false, !isICalInvitation /* \
mayAutoSign */ ); cWin->setSigningAndEncryptionDisabled( isICalInvitation
&& MessageViewer::GlobalSettings::self()->legacyBodyInvites() );
if ( noWordWrap )
@@ -803,7 +803,7 @@ QDBusObjectPath KMKernel::openComposer( const QString &to, const \
QString &cc,
const KMail::Composer::TemplateContext context = body.isEmpty() ? \
KMail::Composer::New :
KMail::Composer::NoTemplate;
- KMail::Composer * cWin = KMail::makeComposer( msg, context );
+ KMail::Composer * cWin = KMail::makeComposer( msg, false, false, context );
if ( !hidden ) {
cWin->show();
// Activate window - doing this instead of \
KWindowSystem::activateWindow(cWin->winId()); @@ -850,7 +850,7 @@ QDBusObjectPath \
KMKernel::newMessage( const QString &to, parser.setIdentityManager( \
identityManager() ); parser.process( msg, folder ? folder->collection() : \
Akonadi::Collection() );
- KMail::Composer *win = makeComposer( msg, KMail::Composer::New, id );
+ KMail::Composer *win = makeComposer( msg, false, false, KMail::Composer::New, id \
);
//Add the attachment if we have one
if ( !attachURL.isEmpty() && attachURL.isValid() ) {
@@ -1146,7 +1146,7 @@ void KMKernel::recoverDeadLetters()
// Show the a new composer dialog for the message
KMail::Composer * autoSaveWin = KMail::makeComposer();
- autoSaveWin->setMsg( autoSaveMessage, false );
+ autoSaveWin->setMessage( autoSaveMessage, false, false, false );
autoSaveWin->setAutoSaveFileName( filename );
autoSaveWin->show();
autoSaveFile.close();
diff --git a/kmail/kmmainwidget.cpp b/kmail/kmmainwidget.cpp
index abef848..147a92b 100644
--- a/kmail/kmmainwidget.cpp
+++ b/kmail/kmmainwidget.cpp
@@ -1565,13 +1565,13 @@ void KMMainWidget::slotCompose()
TemplateParser::TemplateParser parser( msg, \
TemplateParser::TemplateParser::NewMessage ); parser.setIdentityManager( \
KMKernel::self()->identityManager() ); parser.process( msg, \
mCurrentFolder->collection() );
- win = KMail::makeComposer( msg, KMail::Composer::New, \
mCurrentFolder->identity() ); + win = KMail::makeComposer( msg, false, false, \
KMail::Composer::New, mCurrentFolder->identity() ); } else {
MessageHelper::initHeader( msg, KMKernel::self()->identityManager() );
TemplateParser::TemplateParser parser( msg, \
TemplateParser::TemplateParser::NewMessage ); parser.setIdentityManager( \
KMKernel::self()->identityManager() ); parser.process( KMime::Message::Ptr(), \
Akonadi::Collection() );
- win = KMail::makeComposer( msg, KMail::Composer::New );
+ win = KMail::makeComposer( msg, false, false, KMail::Composer::New );
}
win->show();
diff --git a/kmail/mailserviceimpl.cpp b/kmail/mailserviceimpl.cpp
index fac3d6d..caa6aea 100644
--- a/kmail/mailserviceimpl.cpp
+++ b/kmail/mailserviceimpl.cpp
@@ -109,7 +109,7 @@ bool MailServiceImpl::sendMessage( const QString& from, const \
QString& to, part->setBody( attachment ); //TODO: check it!
msg->addContent( part );
- KMail::Composer * cWin = KMail::makeComposer( msg );
+ KMail::Composer * cWin = KMail::makeComposer( msg, false, false );
return true;
}
diff --git a/kmail/util.cpp b/kmail/util.cpp
index d6cbf95..d2ca250 100644
--- a/kmail/util.cpp
+++ b/kmail/util.cpp
@@ -118,7 +118,7 @@ void KMail::Util::handleClickedURL( const KUrl &url )
if ( !fields.value( "cc" ).isEmpty() )
msg->cc()->fromUnicodeString( fields.value( "cc" ),"utf-8" );
- KMail::Composer * win = KMail::makeComposer( msg, KMail::Composer::New, 0 );
+ KMail::Composer * win = KMail::makeComposer( msg, false, \
false,KMail::Composer::New, 0 ); win->setFocusToSubject();
win->show();
} else {
@@ -149,7 +149,7 @@ void KMail::Util::handleClickedURL( const KUrl &url, const \
QSharedPointer<MailCo parser.setIdentityManager( KMKernel::self()->identityManager() \
); parser.process( msg, folder->collection() );
- KMail::Composer * win = KMail::makeComposer( msg, KMail::Composer::New, identity \
); + KMail::Composer * win = KMail::makeComposer( msg, false, false, \
KMail::Composer::New, identity ); win->setFocusToSubject();
win->show();
} else {
@@ -211,3 +211,8 @@ void KMail::Util::mailingListHelp( const \
QSharedPointer<MailCommon::FolderCollec
KMail::Util::mailingListsHandleURL( fd->mailingList().helpUrls(),fd );
}
+void KMail::Util::lastEncryptAndSignState(bool &lastEncrypt, bool &lastSign, const \
KMime::Message::Ptr& msg) +{
+ lastSign = KMime::isSigned(msg.get());
+ lastEncrypt = KMime::isEncrypted(msg.get());
+}
diff --git a/kmail/util.h b/kmail/util.h
index 13f0674..2fade75 100644
--- a/kmail/util.h
+++ b/kmail/util.h
@@ -109,7 +109,7 @@ namespace Util {
void mailingListUnsubscribe( const QSharedPointer<MailCommon::FolderCollection> \
&fd );
void mailingListArchives( const QSharedPointer<MailCommon::FolderCollection> &fd \
);
void mailingListHelp( const QSharedPointer<MailCommon::FolderCollection> &fd );
-
+ void lastEncryptAndSignState(bool &lastEncrypt, bool &lastSign, const \
KMime::Message::Ptr& msg); }
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic