37 #include "qgpgmeencryptjob.h"
39 #include "ui/messagebox.h"
41 #include <qgpgme/eventloopinteractor.h>
42 #include <qgpgme/dataprovider.h>
44 #include <gpgmepp/context.h>
45 #include <gpgmepp/encryptionresult.h>
46 #include <gpgmepp/data.h>
48 #include <tdelocale.h>
52 Kleo::QGpgMEEncryptJob::QGpgMEEncryptJob( GpgME::Context * context )
53 : EncryptJob( QGpgME::EventLoopInteractor::instance(),
"Kleo::QGpgMEEncryptJob" ),
54 QGpgMEJob( this, context )
59 Kleo::QGpgMEEncryptJob::~QGpgMEEncryptJob() {
62 void Kleo::QGpgMEEncryptJob::setup(
const TQByteArray & plainText ) {
66 createInData( plainText );
70 GpgME::Error Kleo::QGpgMEEncryptJob::start(
const std::vector<GpgME::Key> & recipients,
71 const TQByteArray & plainText,
bool alwaysTrust ) {
74 hookupContextToEventLoopInteractor();
76 const GpgME::Context::EncryptionFlags flags =
77 alwaysTrust ? GpgME::Context::AlwaysTrust : GpgME::Context::None;
78 const GpgME::Error err = mCtx->startEncryption( recipients, *mInData, *mOutData, flags );
82 mResult = GpgME::EncryptionResult( err );
86 GpgME::EncryptionResult Kleo::QGpgMEEncryptJob::exec(
const std::vector<GpgME::Key> & recipients,
87 const TQByteArray & plainText,
89 TQByteArray & ciphertext ) {
91 const GpgME::Context::EncryptionFlags flags =
92 alwaysTrust ? GpgME::Context::AlwaysTrust : GpgME::Context::None;
93 mResult = mCtx->encrypt( recipients, *mInData, *mOutData, flags );
94 ciphertext = mOutDataDataProvider->data();
99 void Kleo::QGpgMEEncryptJob::doOperationDoneEvent(
const GpgME::Error & ) {
100 mResult = mCtx->encryptionResult();
101 const TQByteArray ciphertext = mOutDataDataProvider->data();
103 emit result( mResult, ciphertext );
106 void Kleo::QGpgMEEncryptJob::showErrorDialog( TQWidget * parent,
const TQString & caption )
const {
107 if ( mResult.error() && !mResult.error().isCanceled() )
108 Kleo::MessageBox::error( parent, mResult,
this, caption );
111 #include "qgpgmeencryptjob.moc"