23 #include <kleo/decryptverifyjob.h>
24 #include <kleo/importjob.h>
25 #include <kleo/verifydetachedjob.h>
26 #include <kleo/verifyopaquejob.h>
36 using namespace GpgME;
37 using namespace MessageViewer;
38 using boost::shared_ptr;
42 setObjectName( QLatin1String(
"KleoJobExecutor") );
43 mEventLoop =
new QEventLoop(
this );
48 Kleo::VerifyDetachedJob* job,
49 const QByteArray & signature,
50 const QByteArray & signedData )
52 kDebug() <<
"Starting detached verification job";
53 connect( job, SIGNAL(result(GpgME::VerificationResult)),
54 SLOT(verificationResult(GpgME::VerificationResult)) );
55 GpgME::Error err = job->start( signature, signedData );
57 return VerificationResult( err );
58 mEventLoop->exec( QEventLoop::ExcludeUserInputEvents );
59 return mVerificationResult;
63 Kleo::VerifyOpaqueJob * job,
64 const QByteArray & signedData,
65 QByteArray & plainText )
67 kDebug() <<
"Starting opaque verification job";
68 connect( job, SIGNAL(result(GpgME::VerificationResult,QByteArray)),
69 SLOT(verificationResult(GpgME::VerificationResult,QByteArray)) );
70 GpgME::Error err = job->start( signedData );
73 return VerificationResult( err );
75 mEventLoop->exec( QEventLoop::ExcludeUserInputEvents );
77 return mVerificationResult;
81 Kleo::DecryptVerifyJob * job,
82 const QByteArray & cipherText,
83 QByteArray & plainText )
85 kDebug() <<
"Starting decryption job";
86 connect( job, SIGNAL(result(GpgME::DecryptionResult,GpgME::VerificationResult,QByteArray)),
87 SLOT(decryptResult(GpgME::DecryptionResult,GpgME::VerificationResult,QByteArray)) );
88 GpgME::Error err = job->start( cipherText );
91 return std::make_pair( DecryptionResult( err ), VerificationResult( err ) );
93 mEventLoop->exec( QEventLoop::ExcludeUserInputEvents );
95 return std::make_pair( mDecryptResult, mVerificationResult );
100 connect( job, SIGNAL(result(GpgME::ImportResult)), SLOT(importResult(GpgME::ImportResult)) );
101 GpgME::Error err = job->start( certData );
103 return ImportResult( err );
104 mEventLoop->exec( QEventLoop::ExcludeUserInputEvents );
105 return mImportResult;
108 void KleoJobExecutor::verificationResult(
const GpgME::VerificationResult & result)
110 kDebug() <<
"Detached verification job finished";
111 Kleo::Job * job =
dynamic_cast<Kleo::Job*
>( sender() );
113 mVerificationResult = result;
114 mAuditLogError = job->auditLogError();
115 mAuditLog = job->auditLogAsHtml();
119 void KleoJobExecutor::verificationResult(
const GpgME::VerificationResult & result,
const QByteArray & plainText)
121 kDebug() <<
"Opaque verification job finished";
122 Kleo::Job * job =
dynamic_cast<Kleo::Job*
>( sender() );
124 mVerificationResult = result;
126 mAuditLogError = job->auditLogError();
127 mAuditLog = job->auditLogAsHtml();
131 void KleoJobExecutor::decryptResult(
132 const GpgME::DecryptionResult & decryptionresult,
133 const GpgME::VerificationResult & verificationresult,
134 const QByteArray & plainText )
136 kDebug() <<
"Decryption job finished";
137 Kleo::Job * job =
dynamic_cast<Kleo::Job*
>( sender() );
139 mVerificationResult = verificationresult;
140 mDecryptResult = decryptionresult;
142 mAuditLogError = job->auditLogError();
143 mAuditLog = job->auditLogAsHtml();
147 void KleoJobExecutor::importResult(
const GpgME::ImportResult & result)
149 Kleo::Job * job =
dynamic_cast<Kleo::Job*
>( sender() );
151 mImportResult = result;
152 mAuditLogError = job->auditLogError();
153 mAuditLog = job->auditLogAsHtml();
163 #include "kleojobexecutor.moc"
QString auditLogAsHtml() const
GpgME::VerificationResult exec(Kleo::VerifyDetachedJob *job, const QByteArray &signature, const QByteArray &signedData)