35 #include "objecttreeparser_p.h"
37 #include <kleo/decryptverifyjob.h>
38 #include <kleo/verifydetachedjob.h>
39 #include <kleo/verifyopaquejob.h>
40 #include <kleo/keylistjob.h>
42 #include <gpgmepp/keylistresult.h>
45 #include <tqstringlist.h>
49 using namespace KMail;
51 using namespace GpgME;
53 CryptoBodyPartMemento::CryptoBodyPartMemento()
55 Interface::BodyPartMemento(),
62 CryptoBodyPartMemento::~CryptoBodyPartMemento() {}
64 void CryptoBodyPartMemento::setAuditLog(
const GpgME::Error & err,
const TQString & log ) {
65 m_auditLogError = err;
69 void CryptoBodyPartMemento::setRunning(
bool running ) {
73 GenericVerifyMemento::GenericVerifyMemento(Kleo::KeyListJob * klj)
77 void GenericVerifyMemento::execKeyListJob() {
78 if ( canStartKeyListJob() ) {
79 std::vector<GpgME::Key> keys;
80 m_keylistjob->exec( keyListPattern(),
false, keys );
87 bool GenericVerifyMemento::startKeyListJob()
89 if ( !canStartKeyListJob() )
91 if (
const GpgME::Error err = m_keylistjob->start( keyListPattern() ) )
93 connect( m_keylistjob, TQ_SIGNAL(done()),
this, TQ_SLOT(slotKeyListJobDone()) );
94 connect( m_keylistjob, TQ_SIGNAL(nextKey(
const GpgME::Key&)),
95 this, TQ_SLOT(slotNextKey(
const GpgME::Key&)) );
99 void GenericVerifyMemento::destroyKeyListJob() {
101 m_keylistjob->deleteLater();
105 bool GenericVerifyMemento::canStartKeyListJob()
const {
108 const char *
const fpr = m_vr.signature( 0 ).fingerprint();
112 void GenericVerifyMemento::slotNextKey(
const GpgME::Key & key )
117 void GenericVerifyMemento::slotKeyListJobDone()
124 TQStringList GenericVerifyMemento::keyListPattern()
const
126 assert( canStartKeyListJob() );
127 return TQStringList( TQString::fromLatin1( m_vr.signature( 0 ).fingerprint() ) );
131 GenericVerifyMemento::~GenericVerifyMemento() {
133 m_keylistjob->slotCancel();
136 DecryptVerifyBodyPartMemento::DecryptVerifyBodyPartMemento( DecryptVerifyJob * job,
137 Kleo::KeyListJob * klj,
138 const TQByteArray & cipherText )
139 : GenericVerifyMemento(klj),
140 m_cipherText( cipherText ),
146 DecryptVerifyBodyPartMemento::~DecryptVerifyBodyPartMemento() {
151 bool DecryptVerifyBodyPartMemento::start() {
153 if (
const GpgME::Error err = m_job->start( m_cipherText ) ) {
154 m_dr = DecryptionResult( err );
157 connect( m_job, TQ_SIGNAL(result(
const GpgME::DecryptionResult&,
const GpgME::VerificationResult&,
const TQByteArray&)),
158 this, TQ_SLOT(slotResult(
const GpgME::DecryptionResult&,
const GpgME::VerificationResult&,
const TQByteArray&)) );
163 void DecryptVerifyBodyPartMemento::exec() {
165 TQByteArray plainText;
167 const std::pair<DecryptionResult,VerificationResult> p = m_job->exec( m_cipherText, plainText );
168 saveResult( p.first, p.second, plainText );
169 m_job->deleteLater();
175 void DecryptVerifyBodyPartMemento::saveResult(
const DecryptionResult & dr,
176 const VerificationResult & vr,
177 const TQByteArray & plainText )
182 setVerificationResult( vr );
183 m_plainText = plainText;
184 setAuditLog( m_job->auditLogError(), m_job->auditLogAsHtml() );
187 void DecryptVerifyBodyPartMemento::slotResult(
const DecryptionResult & dr,
188 const VerificationResult & vr,
189 const TQByteArray & plainText )
191 saveResult( dr, vr, plainText );
194 if ( startKeyListJob() )
202 VerifyDetachedBodyPartMemento::VerifyDetachedBodyPartMemento( VerifyDetachedJob * job,
204 const TQByteArray & signature,
205 const TQByteArray & plainText )
206 : GenericVerifyMemento(klj),
207 m_signature( signature ),
208 m_plainText( plainText ),
214 VerifyDetachedBodyPartMemento::~VerifyDetachedBodyPartMemento() {
219 bool VerifyDetachedBodyPartMemento::start() {
221 if (
const GpgME::Error err = m_job->start( m_signature, m_plainText ) ) {
222 setVerificationResult( VerificationResult( err ) );
225 connect( m_job, TQ_SIGNAL(result(
const GpgME::VerificationResult&)),
226 this, TQ_SLOT(slotResult(
const GpgME::VerificationResult&)) );
231 void VerifyDetachedBodyPartMemento::exec() {
234 saveResult( m_job->exec( m_signature, m_plainText ) );
235 m_job->deleteLater();
241 void VerifyDetachedBodyPartMemento::saveResult(
const VerificationResult & vr )
244 setVerificationResult( vr );
245 setAuditLog( m_job->auditLogError(), m_job->auditLogAsHtml() );
248 void VerifyDetachedBodyPartMemento::slotResult(
const VerificationResult & vr )
252 if ( startKeyListJob() )
259 VerifyOpaqueBodyPartMemento::VerifyOpaqueBodyPartMemento( VerifyOpaqueJob * job,
261 const TQByteArray & signature )
262 : GenericVerifyMemento(klj),
263 m_signature( signature ),
269 VerifyOpaqueBodyPartMemento::~VerifyOpaqueBodyPartMemento() {
274 bool VerifyOpaqueBodyPartMemento::start() {
276 if (
const GpgME::Error err = m_job->start( m_signature ) ) {
277 setVerificationResult( VerificationResult( err ));
280 connect( m_job, TQ_SIGNAL(result(
const GpgME::VerificationResult&,
const TQByteArray&)),
281 this, TQ_SLOT(slotResult(
const GpgME::VerificationResult&,
const TQByteArray&)) );
286 void VerifyOpaqueBodyPartMemento::exec() {
289 TQByteArray plainText;
290 saveResult( m_job->exec( m_signature, plainText ), plainText );
291 m_job->deleteLater();
297 void VerifyOpaqueBodyPartMemento::saveResult(
const VerificationResult & vr,
298 const TQByteArray & plainText )
301 setVerificationResult(vr);
302 m_plainText = plainText;
303 setAuditLog( m_job->auditLogError(), m_job->auditLogAsHtml() );
306 void VerifyOpaqueBodyPartMemento::slotResult(
const VerificationResult & vr,
307 const TQByteArray & plainText )
309 saveResult( vr, plainText );
311 if ( startKeyListJob() )
319 #include "objecttreeparser_p.moc"