SVN commit 726802 by cconnell:
Don't disable/enable export action based on whether we think
we have the key; it was buggy.
Add architecture explanation
GUI:Make strings easier on translators
M +0 -18 cryptographyguiclient.cpp
M +0 -2 cryptographyguiclient.h
M +20 -53 cryptographyplugin.cpp
M +27 -2 cryptographyplugin.h
M +1 -5 cryptographypreferences.cpp
M +6 -0 kabckeyselectorbase.ui
---
trunk/extragear/network/kopete-plugins/cryptography/cryptogr
aphyguiclient.cpp #726801:726802
 -93,10
+93,6 
connect ( m_encAction, SIGNAL ( triggered ( bool ) ),
this, SLOT ( slotEncryptToggled() ) );
connect ( m_signAction, SIGNAL ( triggered ( bool ) ),
this, SLOT ( slotSignToggled() ) );
connect ( m_exportAction, SIGNAL ( triggered ( bool ) ),
this, SLOT ( slotExport() ) );
-
- connect ( parent, SIGNAL ( contactAdded ( const
Kopete::Contact*, bool ) ), this, SLOT (
slotContactsChanged() ) );
- connect ( parent, SIGNAL ( contactRemoved ( const
Kopete::Contact*, const QString&, Qt::TextFormat, bool )
), this, SLOT ( slotContactsChanged() ) );
- slotContactsChanged();
}
 -202,19
+198,5 
dialog.exec();
}
-// if no contacts have keys, we disable the "export to
kabc" action
-void CryptographyGUIClient::slotContactsChanged()
-{
- kDebug ( 14303 );
- bool keyFound = false;
- foreach ( Kopete::MetaContact * mc,
Kopete::ContactList::self()->selectedMetaContacts() )
- if ( mc->pluginData ( CryptographyPlugin::plugin(),
"gpgKey" ) != QString() )
- keyFound = true;
- if ( keyFound )
- m_exportAction->setEnabled ( true );
- else
- m_exportAction->setEnabled ( false );
-}
-
#include "cryptographyguiclient.moc"
---
trunk/extragear/network/kopete-plugins/cryptography/cryptogr
aphyguiclient.h #726801:726802
 -43,8
+43,6 
KToggleAction *m_signAction;
KAction *m_exportAction;
- public slots:
- void slotContactsChanged();
private slots:
void slotEncryptToggled();
---
trunk/extragear/network/kopete-plugins/cryptography/cryptogr
aphyplugin.cpp #726801:726802
 -87,27
+87,22 
connect ( Kopete::ContactList::self() , SIGNAL (
metaContactSelected ( bool ) ) , action , SLOT ( setEnabled
( bool ) ) );
action->setEnabled (
Kopete::ContactList::self()->selectedMetaContacts().count
() == 1 );
- mExportKeys = new KAction ( KIcon (
"kgpg-export-kgpg" ), i18n ( "&Export
Public Keys To Address Book..." ), this );
- actionCollection()->addAction ( "exportKey",
mExportKeys );
- connect ( mExportKeys, SIGNAL ( triggered ( bool ) ),
this, SLOT ( slotExportSelectedMetaContactKeys() ) );
- connect ( Kopete::ContactList::self() , SIGNAL (
selectionChanged ( bool ) ) , mExportKeys , SLOT (
slotContactSelectionChanged() () ) );
- slotContactSelectionChanged();
+ action = new KAction ( KIcon (
"kgpg-export-kgpg" ), i18n ( "&Export
Public Keys To Address Book..." ), this );
+ actionCollection()->addAction ( "exportKey",
action );
+ connect ( action, SIGNAL ( triggered ( bool ) ), this,
SLOT ( slotExportSelectedMetaContactKeys() ) );
+ connect ( Kopete::ContactList::self() , SIGNAL (
metaContactSelected ( bool ) ) , action , SLOT ( setEnabled
( bool ) ) );
setXMLFile ( "cryptographyui.rc" );
// add functionality to chat window when one opens
connect ( Kopete::ChatSessionManager::self(), SIGNAL (
chatSessionCreated ( Kopete::ChatSession * ) ) , SLOT (
slotNewKMM ( Kopete::ChatSession * ) ) );
- // when selected metacontacts changes, actions may need to
be enabled/disabled
- connect ( Kopete::ContactList::self(), SIGNAL (
selectionChanged() ), this, SLOT (
slotContactSelectionChanged() ) );
-
//Add GUI action to all already existing kmm (if the
plugin is launched when kopete already running)
QList<Kopete::ChatSession*> sessions =
Kopete::ChatSessionManager::self()->sessions();
foreach ( Kopete::ChatSession *session, sessions )
{
slotNewKMM ( session );
}
-
}
CryptographyPlugin::~CryptographyPlugin()
 -146,7
+141,7 
msg.setPlainBody ( "Cryptography processing..."
);
msg.setType ( Kopete::Message::TypeAction );
-
+
}
// this is called when the incoming crypto job is done
 -159,11
+154,11 
if ( !body.isEmpty() )
{
// if was signed *and* encrypted, this will be true
- if ( verificationResult.signatures().size() ){
+ if ( verificationResult.signatures().size() ) {
if ( decryptionResult.numRecipients() >= 1 )
finalizeMessage ( msg, body, verificationResult, true
);
}
-
+
// was not signed *and* encrypted, may be one or the
other. launch a job to see about both possibilities
else {
const Kleo::CryptoBackendFactory *cpf =
Kleo::CryptoBackendFactory::instance();
 -187,14
+182,14 
// if was only encrypted, this will be called
void
CryptographyPlugin::slotIncomingEncryptedMessageContinued (
const GpgME: ecryptio
nResult & decryptionResult, const QByteArray
&plainText )
{
- kDebug (14303);
+ kDebug ( 14303 );
Kopete::Message msg = mCurrentJobs.take (
static_cast<Kleo::Job*> ( sender() ) );
QString body = plainText;
if ( !body.isEmpty() )
{
- if ( decryptionResult.numRecipients() >= 1 )
+ if ( decryptionResult.numRecipients() >= 1 )
finalizeMessage ( msg, body,
GpgME::VerificationResult(), true );
}
}
 -215,13
+210,13 
void CryptographyPlugin::finalizeMessage ( Kopete::Message
& msg, QString intendedBody, const
GpgME::VerificationResult & validity, bool encrypted )
{
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;
-
+ kDebug ( 14303 ) << intendedBody;
+
if ( ! Qt::mightBeRichText ( intendedBody ) )
- intendedBody = Qt::convertFromPlainText( intendedBody,
Qt::WhiteSpaceNormal );
+ intendedBody = Qt::convertFromPlainText ( intendedBody,
Qt::WhiteSpaceNormal );
intendedBody = intendedBody.remove ( QRegExp (
"<p[^>]*>", Qt::CaseInsensitive ) );
intendedBody = intendedBody.remove ( QRegExp (
"</p>", Qt::CaseInsensitive ) );
 -240,7
+235,7 
intendedBody.prepend ( "<img src="" +
KIconLoader::global()->iconPath ( "encrypted",
KIconLoader::Small ) + ""> " );
kDebug ( 14303 ) << "message was
encrypted";
}
-
+
msg.setHtmlBody ( intendedBody );
kDebug ( 14303 ) << "result is " <<
intendedBody;
msg.manager()->appendMessage ( msg );
 -341,14
+336,9 
// warn about unfriendly protocols
if ( KMM->protocol() ) {
QString protocol (
KMM->protocol()->metaObject()->className() );
- if ( gui->m_encAction->isChecked() ){
- if ( ! supportedProtocols().contains ( protocol ) ){
- KMessageBox::information ( 0, 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." ),
+ if ( gui->m_encAction->isChecked() ) {
+ if ( ! supportedProtocols().contains ( protocol ) ) {
+ KMessageBox::information ( 0, 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 (
KMM->protocol()->metaObject()->className() ) );
}
}
 -385,11
+375,7 
{
// just a Yes/No about whether to accept the key
if ( keys.count() == 1 ) {
- if ( KMessageBox::questionYesNo ( parent, i18n ( QString
( "Cryptography plugin has found an
- encryption key for "+ displayName+ "
(" + addresseeName + ")" + " in your
KDE
- address book. Do you want to use key "+
keys.first().right( 8 ).
- prepend ( "0x" ) +
- " as this contact's public key?"
).toLocal8Bit() ),
+ if ( KMessageBox::questionYesNo ( parent, i18n (
"Cryptography plugin has found an encryption key for %1
(%2) in your KDE address book. Do you want to use key %3 as
this contact's public key? ", displayName,
addresseeName, keys.first().right(8).prepend("0x")
),
i18n ( "Public Key
Found" ) ) == KMessageBox::Yes ) {
return keys.first();
}
 -404,10
+390,8 
dialog.setCaption ( i18n ( "Public Keys Found"
) );
dialog.setButtons ( KDialog::Ok | KDialog::Cancel );
dialog.setMainWidget ( &w );
- ui.label->setText ( i18n ( QString (
"Cryptography plugin has found multiple encryption keys
for "
- + displayName + " (" + addresseeName +
")" +
- " in your KDE address book. To use one of these
keys, select it and choose OK." ).
- toLocal8Bit() ) );
+ ui.label->setText ( i18n ( "Cryptography plugin
has found multiple encryption keys for %1 (%2) in your KDE
address book. To use one of these keys, select it and choose
OK.",
+ displayName, addresseeName )
);
for ( int i = 0; i < keys.count(); i++ )
ui.keyList->addItem ( new QListWidgetItem (
KIconLoader::global()->loadIconSet (
"kgpg-key1-kopete", KIconLoader::Small ),
keys[i].right ( 8 ).prepend ( "0x" ), ui.keyList )
);
ui.keyList->addItems ( keys );
 -424,23
+408,6 
dialog.exec();
}
-// enable or disable "Export Keys" depending on
key whether we have a key for the selected metacontacts
-void CryptographyPlugin::slotContactSelectionChanged()
-{
- kDebug ( 14303 );
- bool keyFound = false;
- foreach ( Kopete::MetaContact * mc,
Kopete::ContactList::self()->selectedMetaContacts() ) {
- if ( mc->pluginData ( CryptographyPlugin::plugin(),
"gpgKey" ) != QString() ) {
- keyFound = true;
- kDebug ( 14303 ) << "metacontact "
<< mc->displayName() << "has a
key";
- }
- }
- if ( keyFound )
- mExportKeys->setEnabled ( true );
- else
- mExportKeys->setEnabled ( false );
-}
-
#include "cryptographyplugin.moc"
// vim: set noet ts=4 sts=4 sw=4:
---
trunk/extragear/network/kopete-plugins/cryptography/cryptogr
aphyplugin.h #726801:726802
 -49,7
+49,34 
/**
* 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".
+ * 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
+ * and signed. If the data is good, it will lookup the
message that it was processing,
+ * and it will set the body to the plaintext the crypto
job returned. If the job's
+ * returned data is not good, its plaintext result will be
right, but the crypto
+ * meta-data will be invalid. So, if
slotIncomingMessageContinued sees an
+ * empty list of signers, it will assume that the PGP
block was not encrypted
+ * *and* signed, but may be one or the other. To check for
each of those
+ * possibilies,slotIncomingMessageContinued then launches
two new jobs,
+ * one to check if the message was only signed, and the
other to check if
+ * the message was only encrypted. If either of these find
their case to be true
+ * by looking at heuristics in the info that the job
returns, they will take the
+ * message from mCurrentJobs and put it into circulation.
Whenever we detect that
+ * a message has had crypto applied to it, we add icons to
the message to
+ * convey what we know to the user through the look of the
message itself.
+ *
*/
class CryptographyPlugin : public Kopete::Plugin
 -74,7
+101,6 
void finalizeMessage( Kopete::Message & msg, QString
intendedBody, const GpgME::VerificationResult &
validity, bool encrypted);
void slotOutgoingMessage( Kopete::Message& msg );
- void slotContactSelectionChanged ();
void slotExportSelectedMetaContactKeys ();
private slots:
 -84,7
+110,6 
private:
static CryptographyPlugin* mPluginStatic;
Kopete::SimpleMessageHandlerFactory *mInboundHandler;
- KAction * mExportKeys;
QHash<Kleo::Job*, Kopete::Message> mCurrentJobs;
};
---
trunk/extragear/network/kopete-plugins/cryptography/cryptogr
aphypreferences.cpp #726801:726802
 -45,11
+45,7 
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 signing key.nn
All messages become plain text when used with this
plugin." ), this );
label->setWordWrap ( true );
l->addWidget ( key );
---
trunk/extragear/network/kopete-plugins/cryptography/kabckeys
electorbase.ui #726801:726802
 -23,6
+23,12 
</item>
<item>
<widget class="KListWidget"
name="keyList" >
+ <property name="toolTip" >
+ <string>Select Keys to Use</string>
+ </property>
+ <property name="whatsThis" >
+ <string>Select the key you want to use for to
encrypt to the metacontact</string>
+ </property>
<property name="editTriggers" >
<set>QAbstractItemView::NoEditTriggers</set>
</property>
_______________________________________________
kde-docbook mailing list
kde-docbook kde.org
htt
ps://mail.kde.org/mailman/listinfo/kde-docbook
|