certmanager/lib
qgpgmedecryptjob.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 "qgpgmedecryptjob.h"
00038
00039 #include <qgpgme/eventloopinteractor.h>
00040 #include <qgpgme/dataprovider.h>
00041
00042 #include <gpgmepp/context.h>
00043 #include <gpgmepp/decryptionresult.h>
00044 #include <gpgmepp/data.h>
00045
00046 #include <assert.h>
00047
00048 Kleo::QGpgMEDecryptJob::QGpgMEDecryptJob( GpgME::Context * context )
00049 : DecryptJob( QGpgME::EventLoopInteractor::instance(), "Kleo::QGpgMEDecryptJob" ),
00050 QGpgMEJob( this, context )
00051 {
00052 assert( context );
00053 }
00054
00055 Kleo::QGpgMEDecryptJob::~QGpgMEDecryptJob() {
00056 }
00057
00058 void Kleo::QGpgMEDecryptJob::setup( const QByteArray & cipherText ) {
00059 assert( !mInData );
00060 assert( !mOutData );
00061
00062 createInData( cipherText );
00063 createOutData();
00064 }
00065
00066 GpgME::Error Kleo::QGpgMEDecryptJob::start( const QByteArray & cipherText ) {
00067 setup( cipherText );
00068
00069 hookupContextToEventLoopInteractor();
00070
00071 const GpgME::Error err = mCtx->startDecryption( *mInData, *mOutData );
00072
00073 if ( err )
00074 deleteLater();
00075 return err;
00076 }
00077
00078 GpgME::DecryptionResult Kleo::QGpgMEDecryptJob::exec( const QByteArray & cipherText,
00079 QByteArray & plainText ) {
00080 setup( cipherText );
00081 const GpgME::DecryptionResult result = mCtx->decrypt( *mInData, *mOutData );
00082 plainText = mOutDataDataProvider->data();
00083 return result;
00084 }
00085
00086 void Kleo::QGpgMEDecryptJob::doOperationDoneEvent( const GpgME::Error & ) {
00087 emit result( mCtx->decryptionResult(), mOutDataDataProvider->data() );
00088 }
00089
00090 #include "qgpgmedecryptjob.moc"
|