certmanager/lib
qgpgmedecryptverifyjob.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 "qgpgmedecryptverifyjob.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/verificationresult.h>
00045 #include <gpgmepp/data.h>
00046
00047 #include <assert.h>
00048
00049 Kleo::QGpgMEDecryptVerifyJob::QGpgMEDecryptVerifyJob( GpgME::Context * context )
00050 : DecryptVerifyJob( QGpgME::EventLoopInteractor::instance(), "Kleo::QGpgMEDecryptVerifyJob" ),
00051 QGpgMEJob( this, context )
00052 {
00053 assert( context );
00054 }
00055
00056 Kleo::QGpgMEDecryptVerifyJob::~QGpgMEDecryptVerifyJob() {
00057 }
00058
00059 void Kleo::QGpgMEDecryptVerifyJob::setup( const QByteArray & cipherText ) {
00060 assert( !mInData );
00061 assert( !mOutData );
00062
00063 createInData( cipherText );
00064 createOutData();
00065 }
00066
00067 GpgME::Error Kleo::QGpgMEDecryptVerifyJob::start( const QByteArray & cipherText ) {
00068 setup( cipherText );
00069
00070 hookupContextToEventLoopInteractor();
00071
00072 const GpgME::Error err = mCtx->startCombinedDecryptionAndVerification( *mInData, *mOutData );
00073
00074 if ( err )
00075 deleteLater();
00076 return err;
00077 }
00078
00079 std::pair<GpgME::DecryptionResult,GpgME::VerificationResult>
00080 Kleo::QGpgMEDecryptVerifyJob::exec( const QByteArray & cipherText, QByteArray & plainText ) {
00081 setup( cipherText );
00082 const std::pair<GpgME::DecryptionResult,GpgME::VerificationResult> result =
00083 mCtx->decryptAndVerify( *mInData, *mOutData );
00084 plainText = mOutDataDataProvider->data();
00085 return result;
00086 }
00087
00088 void Kleo::QGpgMEDecryptVerifyJob::doOperationDoneEvent( const GpgME::Error & ) {
00089 emit result( mCtx->decryptionResult(),
00090 mCtx->verificationResult(),
00091 mOutDataDataProvider->data() );
00092 }
00093
00094 #include "qgpgmedecryptverifyjob.moc"
|