[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdepim/certmanager/lib/backends/qgpgme
From: David Faure <faure () kde ! org>
Date: 2004-07-15 21:17:14
Message-ID: 20040715211714.6C68A16B0D () office ! kde ! org
[Download RAW message or body]
CVS commit by faure:
Applied patch from Marc Mutz which implements a passphrase dialog in KMail,
shown when gpg-agent isn't running.
I adjusted the text of the dialog to explain that
"This dialog will reappear every time the passphrase is needed.
For a more secure solution that also allows caching the passphrase, install \
gpg-agent. gpg-agent is part of gnupg-1.9, which you can download from \
http://www.gnupg.org/download" [would be nice to make the URL clickable]
What remains is to tell people how to set up gpg-agent, but that's a bit too much
for a dialog :)
CCMAIL: 85009@bugs.kde.org
M +28 -1 qgpgmejob.cpp 1.5
M +4 -1 qgpgmejob.h 1.5
--- kdepim/certmanager/lib/backends/qgpgme/qgpgmejob.cpp #1.4:1.5
@@ -39,4 +39,5 @@
#include <kleo/job.h>
+#include <ui/passphrasedialog.h>
#include <qgpgme/eventloopinteractor.h>
@@ -46,4 +47,6 @@
#include <gpgmepp/data.h>
+#include <klocale.h>
+
#include <qstring.h>
#include <qstringlist.h>
@@ -54,4 +57,5 @@
Kleo::QGpgMEJob::QGpgMEJob( Kleo::Job * _this, GpgME::Context * context )
: GpgME::ProgressProvider(),
+ GpgME::PassphraseProvider(),
mThis( _this ),
mCtx( context ),
@@ -65,4 +69,6 @@ Kleo::QGpgMEJob::QGpgMEJob( Kleo::Job *
QObject::connect( QGpgME::EventLoopInteractor::instance(), \
SIGNAL(aboutToDestroy()), _this, SLOT(slotCancel()) );
+ context->setProgressProvider( this );
+ context->setPassphraseProvider( this );
}
@@ -84,5 +90,4 @@ void Kleo::QGpgMEJob::hookupContextToEve
SIGNAL(operationDoneEventSignal(GpgME::Context*,const \
GpgME::Error&)),
mThis, SLOT(slotOperationDoneEvent(GpgME::Context*,const \
GpgME::Error&)) );
- mCtx->setProgressProvider( this );
}
@@ -140,2 +145,24 @@ void Kleo::QGpgMEJob::showProgress( cons
}
+char * Kleo::QGpgMEJob::getPassphrase( const char * useridHint, const char * \
/*description*/, + bool previousWasBad, bool & \
canceled ) { + // DF: here, description is the key fingerprint, twice, then "17 0". \
Not really descriptive. + // So I'm ignoring QString::fromLocal8Bit( description \
) ) + QString msg = previousWasBad ?
+ i18n( "You need a passphrase to unlock the secret key for user:<br/> \
%1 (retry)" ) : + i18n( "You need a passphrase to unlock the secret \
key for user:<br/> %1" ); + msg = msg.arg( QString::fromUtf8( useridHint ) ) + \
"<br/><br/>"; + msg.prepend( "<qt>" );
+ msg += i18n( "This dialog will reappear every time the passphrase is needed. For a \
more secure solution that also allows caching the passphrase, install gpg-agent." ); \
+ msg += i18n( "gpg-agent is part of gnupg-%1, which you can download from %2" ) + \
.arg( "1.9" ) + .arg( "http://www.gnupg.org/download" ); // add #gnupg2 if \
you can make this a real link + Kleo::PassphraseDialog dlg( msg, i18n("Passphrase \
Dialog") ); + if ( dlg.exec() != QDialog::Accepted ) {
+ canceled = true;
+ return 0;
+ }
+ canceled = false;
+ // gpgme++ free()s it, and we need to copy as long as dlg isn't deleted :o
+ return strdup( dlg.passphrase() );
+}
--- kdepim/certmanager/lib/backends/qgpgme/qgpgmejob.h #1.4:1.5
@@ -35,4 +35,5 @@
#include <gpgmepp/interfaces/progressprovider.h>
+#include <gpgmepp/interfaces/passphraseprovider.h>
#include <gpgmepp/key.h>
@@ -74,5 +75,5 @@ namespace Kleo {
ctor. The rest is dealt with automatically.
*/
- class QGpgMEJob : public GpgME::ProgressProvider {
+ class QGpgMEJob : public GpgME::ProgressProvider, public GpgME::PassphraseProvider \
{ public:
QGpgMEJob( Kleo::Job * _this, GpgME::Context * context );
@@ -109,4 +110,6 @@ namespace Kleo {
/*! \reimp from GpgME::ProgressProvider */
void showProgress( const char * what, int type, int current, int total );
+ char * getPassphrase( const char * useridHint, const char * description,
+ bool previousWasBad, bool & canceled );
protected:
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic