37 #include "qgpgmesignjob.h"
39 #include "ui/messagebox.h"
41 #include <qgpgme/eventloopinteractor.h>
42 #include <qgpgme/dataprovider.h>
44 #include <gpgmepp/context.h>
45 #include <gpgmepp/signingresult.h>
46 #include <gpgmepp/data.h>
47 #include <gpgmepp/key.h>
49 #include <tdelocale.h>
54 Kleo::QGpgMESignJob::QGpgMESignJob( GpgME::Context * context )
55 : SignJob( QGpgME::EventLoopInteractor::instance(),
"Kleo::QGpgMESignJob" ),
56 QGpgMEJob( this, context )
61 Kleo::QGpgMESignJob::~QGpgMESignJob() {
64 GpgME::Error Kleo::QGpgMESignJob::setup(
const std::vector<GpgME::Key> & signers,
65 const TQByteArray & plainText ) {
69 createInData( plainText );
72 return setSigningKeys( signers );
75 GpgME::Error Kleo::QGpgMESignJob::start(
const std::vector<GpgME::Key> & signers,
76 const TQByteArray & plainText,
77 GpgME::Context::SignatureMode mode ) {
78 if (
const GpgME::Error error = setup( signers, plainText ) ) {
83 hookupContextToEventLoopInteractor();
85 const GpgME::Error err = mCtx->startSigning( *mInData, *mOutData, mode );
89 mResult = GpgME::SigningResult( err );
93 GpgME::SigningResult Kleo::QGpgMESignJob::exec(
const std::vector<GpgME::Key> & signers,
94 const TQByteArray & plainText,
95 GpgME::Context::SignatureMode mode,
96 TQByteArray & signature ) {
97 if (
const GpgME::Error err = setup( signers, plainText ) )
98 return mResult = GpgME::SigningResult( 0, err );
99 mResult = mCtx->sign( *mInData, *mOutData, mode );
100 signature = mOutDataDataProvider->data();
105 void Kleo::QGpgMESignJob::doOperationDoneEvent(
const GpgME::Error & ) {
106 mResult = mCtx->signingResult();
107 const TQByteArray signature = mOutDataDataProvider->data();
109 emit result( mResult, signature );
112 void Kleo::QGpgMESignJob::showErrorDialog( TQWidget * parent,
const TQString & caption )
const {
113 if ( mResult.error() && !mResult.error().isCanceled() )
114 Kleo::MessageBox::error( parent, mResult,
this, caption );
117 #include "qgpgmesignjob.moc"