SVN commit 727760 by cconnell:
Add label to prefs page to user knows what's what
Discard messages rather than make them say
"Cryptography Processing"
GUI:String change from "signing key" to
"private key"
Add CryptographyMessageHandler and
CryptographyMessageHandlerFactory based on
PrivacyMessageHanlder and PrivacyMessageHandlerFactory and
have slotIncomingMessage take MessageEvent*
rather than Message, so it can discard it
Since we're now crypto-implementation independent, don't say
GPG or PGP anymore, say OpenPGP
M +2 -1 CMakeLists.txt
M +50 -55 cryptographyguiclient.cpp
A cryptographymessagehandler.cpp [License:
LGPL (v2+)]
A cryptographymessagehandler.h [License: LGPL
(v2+)]
M +9 -11 cryptographyplugin.cpp
M +8 -6 cryptographyplugin.h
M +6 -2 cryptographypreferences.cpp
M +1 -1 kopete_cryptography.desktop
M +1 -1 kopete_cryptography_config.desktop
---
trunk/extragear/network/kopete-plugins/cryptography/CMakeLis
ts.txt #727759:727760
 -12,7
+12,8 
cryptographyguiclient.cpp
cryptographyselectuserkey.cpp
cryptographyconfig.cpp
- exportkeys.cpp )
+ exportkeys.cpp
+ cryptographymessagehandler.cpp )
kde4_add_ui_files(kopete_cryptography_PART_SRCS
kabckeyselectorbase.ui exportkeysbase.ui )
---
trunk/extragear/network/kopete-plugins/cryptography/cryptogr
aphyguiclient.cpp #727759:727760
 -63,15
+63,15 
// if any contacts have previously been encrypted/signed
to, enable that now
foreach ( Kopete::Contact *c , parent->members() )
{
- Kopete::MetaContact *mc=c->metaContact();
+ Kopete::MetaContact *mc = c->metaContact();
if ( !mc )
{
deleteLater();
return;
}
- if ( mc->pluginData ( CryptographyPlugin::plugin(),
"encrypt_messages" ) == "on" )
+ if ( c->pluginData ( CryptographyPlugin::plugin(),
"encrypt_messages" ) == "on" )
wantEncrypt = true;
- if ( mc->pluginData ( CryptographyPlugin::plugin(),
"sign_messages" ) == "on" )
+ if ( c->pluginData ( CryptographyPlugin::plugin(),
"sign_messages" ) == "on" )
wantSign = true;
if ( ! ( mc->pluginData (
CryptographyPlugin::plugin(), "gpgKey" ).isEmpty()
) )
keysAvailable = true;
 -105,13
+105,12 
if ( m_signAction->isChecked() ) {
if (
CryptographyConfig::self()->fingerprint().isEmpty() ) {
KMessageBox::sorry ( Kopete::UI::Global::mainWidget(),
- i18n ( "You have not selected
a private key for yourself, so signing is not
possible."
- "Please select a
private key in the Cryptography preferences dialog" ),
+ i18n ( "You have not selected
a private key for yourself, so signing is not possible.
Please select a private key in the Cryptography preferences
dialog" ),
i18n ( "No Private Key" )
);
m_signAction->setChecked ( false );
}
}
- static_cast<Kopete::ChatSession *> ( parent()
)->members().first()->metaContact()->setPluginData
+ static_cast<Kopete::ChatSession *> ( parent()
)->members().first()->setPluginData
( CryptographyPlugin::plugin(), "sign_messages",
m_signAction->isChecked() ? "on" :
"off" );
}
 -119,71
+118,67 
void CryptographyGUIClient::slotEncryptToggled()
{
Kopete::ChatSession *csn =
static_cast<Kopete::ChatSession *> ( parent() );
- QStringList keyless;
-
- QWidget *w = 0;
- if ( csn->view() )
- w = csn->view()->mainWidget();
-
- Kopete::MetaContact *first=0L;
- foreach ( Kopete::Contact * c , csn->members() )
+
+ if ( m_encAction->isChecked() )
{
- Kopete::MetaContact *mc = c->metaContact();
- if ( !mc )
- continue;
+ QStringList keyless;
- if ( !first )
- first=mc;
+ QWidget *w = 0;
+ if ( csn->view() )
+ w = csn->view()->mainWidget();
- // if encrypting and we don't have a key, look in address
book
- if ( mc->pluginData ( CryptographyPlugin::plugin(),
"gpgKey" ).isEmpty() &&
m_encAction->isChecked() )
+ foreach ( Kopete::Contact * c , csn->members() )
{
- // to grab the public key from KABC (this same code is
in crytographyselectuserkey.cpp)
- KABC::Addressee addressee =
Kopete::KABCPersistence::self()->addressBook()->findBy
Uid
- ( mc->metaContactId() );
+ Kopete::MetaContact *mc = c->metaContact();
+ if ( !mc )
+ continue;
- if ( ! addressee.isEmpty() )
+ // if encrypting and we don't have a key, look in
address book
+ if ( mc->pluginData ( CryptographyPlugin::plugin(),
"gpgKey" ).isEmpty() )
{
- QStringList keys;
- keys = CryptographyPlugin::getKabcKeys (
mc->metaContactId() );
+ // to grab the public key from KABC (this same code is
in crytographyselectuserkey.cpp)
+ KABC::Addressee addressee =
Kopete::KABCPersistence::self()->addressBook()->findBy
Uid
+ ( mc->metaContactId() );
- // ask user if they want to use key found in address
book
- KABC::Addressee tempAddressee =
Kopete::KABCPersistence::self()->
-
addressBook()->findByUid ( mc->metaContactId() );
- mc->setPluginData ( CryptographyPlugin::plugin(),
"gpgKey",
- CryptographyPlugin::KabcKeySelector
( mc->displayName(), tempAddressee.assembledName(), keys,
w ) );
+ if ( ! addressee.isEmpty() )
+ {
+ QStringList keys;
+ keys = CryptographyPlugin::getKabcKeys (
mc->metaContactId() );
+
+ // ask user if they want to use key found in address
book
+ KABC::Addressee tempAddressee =
Kopete::KABCPersistence::self()->
+
addressBook()->findByUid ( mc->metaContactId() );
+ mc->setPluginData ( CryptographyPlugin::plugin(),
"gpgKey",
+
CryptographyPlugin::KabcKeySelector ( mc->displayName(),
tempAddressee.assembledName(), keys, w ) );
+ }
}
+ if ( mc->pluginData ( CryptographyPlugin::plugin(),
"gpgKey" ).isEmpty() )
+ keyless.append ( mc->displayName() );
}
- if ( mc->pluginData ( CryptographyPlugin::plugin(),
"gpgKey" ).isEmpty() )
- keyless.append ( mc->displayName() );
- }
- // if encrypting and using unsupported protocols, warn
user
- if ( m_encAction->isChecked() )
- {
+ // if encrypting and using unsupported protocols, warn
user
+
QString protocol (
csn->protocol()->metaObject()->className() );
- if ( m_encAction->isChecked() ) {
- if ( ! CryptographyPlugin::supportedProtocols().contains
( protocol ) ) {
- KMessageBox::information ( w, i18n ( "This
protocol may not work with messages that are encrypted. This
is because encrypted messages are very long, and the server
or peer may reject them due to their length. To avoid being
signed off or your account being warned or temporarily
suspended, turn off encryption." ),
- i18n ( "Cryptography
Unsupported Protocol" ),
- "Warn about unsupported
" + QString (
csn->protocol()->metaObject()->className() ) );
- }
+ if ( ! CryptographyPlugin::supportedProtocols().contains
( protocol ) ) {
+ KMessageBox::information ( w, i18n ( "This protocol
may not work with messages that are encrypted. This is
because encrypted messages are very long, and the server or
peer may reject them due to their length. To avoid being
signed off or your account being warned or temporarily
suspended, turn off encryption." ),
+ i18n ( "Cryptography
Unsupported Protocol" ),
+ "Warn about unsupported
" + QString (
csn->protocol()->metaObject()->className() ) );
}
- }
- // we can't encrypt if we don't have every single key we
need
- if ( m_encAction->isChecked() &&
!keyless.isEmpty() )
- {
- KMessageBox::sorry ( w, i18np ( "To send encrypted
messages to %2, you still need to select a public key for
this contact.", "To send encrypted messages to
them, you still need to select a public key for each of
these contacts:n%2",
- keyless.count(),
keyless.join ( "n" ) ),
- i18np ( "Missing public
key", "Missing public keys", keyless.count()
) );
+ // we can't encrypt if we don't have every single key we
need
+ if ( !keyless.isEmpty() )
+ {
+ KMessageBox::sorry ( w, i18np ( "To send encrypted
messages to %2, you still need to select a public key for
this contact.", "To send encrypted messages to
them, you still need to select a public key for each of
these contacts:n%2",
+ keyless.count(),
keyless.join ( "n" ) ),
+ i18np ( "Missing public
key", "Missing public keys", keyless.count()
) );
- m_encAction->setChecked ( false );
+ m_encAction->setChecked ( false );
+ }
}
-
+
// finally, set the pluginData to reflect new settings
- if ( first )
- first->setPluginData ( CryptographyPlugin::plugin() ,
"encrypt_messages" ,
+ if ( csn->members().first() )
+ csn->members().first()->setPluginData (
CryptographyPlugin::plugin() , "encrypt_messages"
,
m_encAction->isChecked() ?
"on" : "off" );
}
---
trunk/extragear/network/kopete-plugins/cryptography/cryptogr
aphyplugin.cpp #727759:727760
 -38,6
+38,7 
#include <kopete/kopeteuiglobal.h>
#include <kopete/kopetecontact.h>
#include <kopete/kopeteprotocol.h>
+#include <kopete/kopetemessageevent.h>
#include <assert.h>
#include <kleo/cryptobackendfactory.h>
 -59,6
+60,7 
#include "cryptographyselectuserkey.h"
#include "cryptographyguiclient.h"
#include "exportkeys.h"
+#include "cryptographymessagehandler.h"
#include "ui_kabckeyselectorbase.h"
 -74,8
+76,8 
mPluginStatic=this;
// set up slots to handle incoming and outgoing messages
- mInboundHandler = new Kopete::SimpleMessageHandlerFactory
( Kopete::Message::Inbound,
- Kopete::MessageHandlerFactory::InStageToSent,
this, SLOT ( slotIncomingMessage ( Kopete::Message& ) )
);
+ mInboundHandler = new CryptographyMessageHandlerFactory (
Kopete::Message::Inbound,
+ Kopete::MessageHandlerFactory::InStageToSent,
this, SLOT ( slotIncomingMessage ( Kopete::MessageEvent* ) )
);
connect ( Kopete::ChatSessionManager::self(),
SIGNAL ( aboutToSend ( Kopete::Message & )
),
SLOT ( slotOutgoingMessage ( Kopete::Message
& ) ) );
 -118,8
+120,9 
}
// handling an "incoming" message. this means any
message to be displayed in the chat window, including ones
sent by the user
-void CryptographyPlugin::slotIncomingMessage (
Kopete::Message& msg )
+void CryptographyPlugin::slotIncomingMessage (
Kopete::MessageEvent *messageEvent )
{
+ Kopete::Message msg = messageEvent->message();
QString body = msg.plainBody();
if ( !body.startsWith ( QString::fromLatin1 (
"-----BEGIN PGP MESSAGE----" ) )
 -139,9
+142,7 
mCurrentJobs.insert ( decryptVerifyJob, msg );
decryptVerifyJob->start ( body.toLatin1() );
- msg.setPlainBody ( "Cryptography processing..."
);
- msg.setType ( Kopete::Message::TypeAction );
-
+ messageEvent->discard();
}
// this is called when the incoming crypto job is done
 -212,9
+213,6 
msg.addClass ( "cryptography:encrypted" );
// turn our plaintext body into html, so then it makes
sense to stick HTML tags in it
-// msg.setPlainBody ( intendedBody );
- kDebug ( 14303 ) << intendedBody;
-
if ( ! Qt::mightBeRichText ( intendedBody ) )
intendedBody = Qt::convertFromPlainText ( intendedBody,
Qt::WhiteSpaceNormal );
intendedBody = intendedBody.remove ( QRegExp (
"<p[^>]*>", Qt::CaseInsensitive ) );
 -251,8
+249,8 
std::vector<GpgME::Key> encryptingKeys;
std::vector<GpgME::Key> signingKeys;
QList<Kopete::Contact*> contactlist = msg.to();
- bool signing = ( (
msg.to().first()->metaContact()->pluginData ( this,
"sign_messages" ) ) == "on" );
- bool encrypting = ( (
msg.to().first()->metaContact()->pluginData ( this,
"encrypt_messages" ) ) == "on" );
+ bool signing = ( ( msg.to().first()->pluginData ( this,
"sign_messages" ) ) == "on" );
+ bool encrypting = ( ( msg.to().first()->pluginData (
this, "encrypt_messages" ) ) == "on" );
QByteArray result;
kDebug ( 14303 ) << ( signing ? "signing"
: "" ) << ( encrypting ?
"encrypting" : "" ) <<
"message " << msg.plainBody();
---
trunk/extragear/network/kopete-plugins/cryptography/cryptogr
aphyplugin.h #727759:727760
 -43,23
+43,25 
namespace Kopete
{
class Message;
+ class MessageEvent;
class ChatSession;
- class SimpleMessageHandlerFactory;
}
+class CryptographyMessageHandlerFactory;
+
/**
* author Olivier Goffart
* author Charles Connell
* Main plugin class, handles mesages. Also has static
functions used by rest of plugin
*
* Basic architecture:
+ *
* Outgoing messages are routed through
slotOutgoingMessage().
* That uses Kleo::SomethingJob->exec() to do the
actual crypto work
*
* Incoming messages go through slotIncomingMessage().
This starts
* a crypto job to deal with the message, remembers which
job goes with
- * which message (using mCurrentJobs), and then changes
the message body
- * to "Cryptography Processing".
+ * which message (using mCurrentJobs), and then discards
it.
* When the job is done, it itself calls
slotIncomingMessageContinued().
* Since slotIncomingMessageContinued was called to
decrypt and verify the PGP block.
* it will only give back good data if the block was
actually encrypted
 -86,7
+88,7 
public:
static CryptographyPlugin *plugin();
- static QStringList supportedProtocols() { QStringList l;
return l << "MSNProtocol" <<
"MessengerProtocol" <<
"JabberProtocol" <<
"YahooProtocol"; }
+ static QStringList supportedProtocols() { return
QStringList() << "MSNProtocol" <<
"MessengerProtocol" <<
"JabberProtocol" <<
"YahooProtocol"; }
static QStringList getKabcKeys (QString uid);
static QString KabcKeySelector ( QString displayName,
QString addresseeName, QStringList keys, QWidget *parent );
 -94,7
+96,7 
~CryptographyPlugin();
public slots:
- void slotIncomingMessage( Kopete::Message& msg );
+ void slotIncomingMessage( Kopete::MessageEvent *msg );
void slotIncomingMessageContinued(const GpgME: ecryptio
nResult &decryptionResult, const
GpgME::VerificationResult &verificationResult, const
QByteArray &plainText);
void slotIncomingEncryptedMessageContinued(const
GpgME: ecryptio
nResult &decryptionResult, const QByteArray
&plainText);
void slotIncomingSignedMessageContinued(const
GpgME::VerificationResult &verificationResult, const
QByteArray &plainText);
 -109,7
+111,7 
private:
static CryptographyPlugin* mPluginStatic;
- Kopete::SimpleMessageHandlerFactory *mInboundHandler;
+ CryptographyMessageHandlerFactory *mInboundHandler;
QHash<Kleo::Job*, Kopete::Message> mCurrentJobs;
};
---
trunk/extragear/network/kopete-plugins/cryptography/cryptogr
aphypreferences.cpp #727759:727760
 -38,17
+38,21 
{
// Add actual widget generated from ui file.
QVBoxLayout* l = new QVBoxLayout ( this );
+ QHBoxLayout* keyLayout = new QHBoxLayout ( this );
+ QLabel * keyLabel = new QLabel ( i18n ( "Private Key:
" ), this );
key = new Kleo::EncryptionKeyRequester ( false,
Kleo::EncryptionKeyRequester::OpenPGP, this, true, true );
key->setDialogMessage ( i18n ( "Select the key you
want to use to sign and encrypt messages" ) );
key->setDialogCaption ( i18n ( "Select the key you
want to use to sign and encrypt messages" ) );
key->setToolTip ( i18n ( "The private key used for
decryption and signing" ) );
key->setWhatsThis ( i18n ( "See and change the
private key used for signing and encrypting messages using
the Cryptography plugin" ) );
- QLabel * label = new QLabel ( i18n ( "Before you can
send encrypted messages to someone, you must select their
public key by right-clicking on their name in your contact
list, and choose "Select Public Key".nn Before
you can sign messages, you must select a signing key.nn
All messages become plain text when used with this
plugin." ), this );
+ QLabel * label = new QLabel ( i18n ( "Before you can
send encrypted messages to someone, you must select their
public key by right-clicking on their name in your contact
list, and choose "Select Public Key".nn Before
you can sign messages, you must select a private key.nn
All messages become plain text when sent with this
plugin." ), this );
label->setWordWrap ( true );
- l->addWidget ( key );
+ keyLayout->addWidget ( keyLabel );
+ keyLayout->addWidget ( key );
+ l->addLayout ( keyLayout );
l->addWidget ( label );
l->addStretch ();
l->setSpacing(12);
---
trunk/extragear/network/kopete-plugins/cryptography/kopete_c
ryptography.desktop #727759:727760
 -17,6
+17,6 
Name=Cryptography
Name[nds]=Verslöteln
Name[sv]=Kryptering
-Comment=Encrypt and decrypt messages with GPG
+Comment=Encrypt and decrypt messages with OpenPGP
Comment[nds]=Narichten mit GPG ver- un opslöteln
Comment[sv]=Kryptera och avkoda meddelanden med GPG
---
trunk/extragear/network/kopete-plugins/cryptography/kopete_c
ryptography_config.desktop #727759:727760
 -12,7
+12,7 
Name=Cryptography
Name[nds]=Verslöteln
Name[sv]=Kryptering
-Comment=Encrypts messages using PGP
+Comment=Encrypts messages using OpenPGP
Comment[nds]=Verslötelt Narichten mit PGP
Comment[sv]=Krypterar meddelanden med användning av PGP
_______________________________________________
kde-docbook mailing list
kde-docbook kde.org
htt
ps://mail.kde.org/mailman/listinfo/kde-docbook
|