37 #include "qgpgmekeygenerationjob.h"
39 #include <qgpgme/dataprovider.h>
40 #include <qgpgme/eventloopinteractor.h>
42 #include <gpgmepp/context.h>
43 #include <gpgmepp/keygenerationresult.h>
44 #include <gpgmepp/data.h>
48 Kleo::QGpgMEKeyGenerationJob::QGpgMEKeyGenerationJob( GpgME::Context * context )
49 : KeyGenerationJob( QGpgME::EventLoopInteractor::instance(), "Kleo::QGpgMEKeyGenerationJob" ),
50 QGpgMEJob( this, context ),
51 mPubKeyDataProvider( 0 ),
57 Kleo::QGpgMEKeyGenerationJob::~QGpgMEKeyGenerationJob() {
58 delete mPubKey; mPubKey = 0;
59 delete mPubKeyDataProvider; mPubKeyDataProvider = 0;
62 GpgME::Error Kleo::QGpgMEKeyGenerationJob::start( const TQString & parameters ) {
66 if ( mCtx->protocol() == GpgME::Context::CMS ) {
67 mPubKeyDataProvider = new QGpgME::TQByteArrayDataProvider();
68 mPubKey = new GpgME::Data( mPubKeyDataProvider );
69 assert( !mPubKey->isNull() );
72 hookupContextToEventLoopInteractor();
74 const GpgME::Error err =
75 mCtx->startKeyGeneration( parameters.utf8().data(), mPubKey ? *mPubKey : GpgME::Data::null );
82 void Kleo::QGpgMEKeyGenerationJob::doOperationDoneEvent( const GpgME::Error & ) {
83 const GpgME::KeyGenerationResult res = mCtx->keyGenerationResult();
84 const TQByteArray data = mPubKeyDataProvider ? mPubKeyDataProvider->data() : TQByteArray() ;
86 emit result( res, data );
89 #include "qgpgmekeygenerationjob.moc"
|