certmanager/lib
qgpgmekeygenerationjob.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifdef HAVE_CONFIG_H
00034 #include <config.h>
00035 #endif
00036
00037 #include "qgpgmekeygenerationjob.h"
00038
00039 #include <qgpgme/dataprovider.h>
00040 #include <qgpgme/eventloopinteractor.h>
00041
00042 #include <gpgmepp/context.h>
00043 #include <gpgmepp/keygenerationresult.h>
00044 #include <gpgmepp/data.h>
00045
00046 #include <assert.h>
00047
00048 Kleo::QGpgMEKeyGenerationJob::QGpgMEKeyGenerationJob( GpgME::Context * context )
00049 : KeyGenerationJob( QGpgME::EventLoopInteractor::instance(), "Kleo::QGpgMEKeyGenerationJob" ),
00050 QGpgMEJob( this, context ),
00051 mPubKeyDataProvider( 0 ),
00052 mPubKey( 0 )
00053 {
00054 assert( context );
00055 }
00056
00057 Kleo::QGpgMEKeyGenerationJob::~QGpgMEKeyGenerationJob() {
00058 delete mPubKey; mPubKey = 0;
00059 delete mPubKeyDataProvider; mPubKeyDataProvider = 0;
00060 }
00061
00062 GpgME::Error Kleo::QGpgMEKeyGenerationJob::start( const QString & parameters ) {
00063 assert( !mPubKey );
00064
00065
00066 if ( mCtx->protocol() == GpgME::Context::CMS ) {
00067 mPubKeyDataProvider = new QGpgME::QByteArrayDataProvider();
00068 mPubKey = new GpgME::Data( mPubKeyDataProvider );
00069 assert( !mPubKey->isNull() );
00070 }
00071
00072 hookupContextToEventLoopInteractor();
00073
00074 const GpgME::Error err =
00075 mCtx->startKeyGeneration( parameters.utf8().data(), mPubKey ? *mPubKey : GpgME::Data::null );
00076
00077 if ( err )
00078 deleteLater();
00079 return err;
00080 }
00081
00082 void Kleo::QGpgMEKeyGenerationJob::doOperationDoneEvent( const GpgME::Error & ) {
00083 emit result( mCtx->keyGenerationResult(), mPubKeyDataProvider ? mPubKeyDataProvider->data() : QByteArray() );
00084 }
00085
00086 #include "qgpgmekeygenerationjob.moc"
|