From 962c18f5e1e2796eebc8a0c439c6b893000d4cd7 Mon Sep 17 00:00:00 2001 From: Laurent Montel Date: Wed, 30 Sep 2009 12:14:16 +0000 Subject: [PATCH] Use kleojobexecutor.h from libmessageviewer (temporary, will remove when we will remove old code) svn path=/branches/work/akonadi-ports/kdepim/; revision=1029627 --- CMakeLists.txt | 1 - kleojobexecutor.cpp | 161 ------------------------------------------- kleojobexecutor.h | 84 ---------------------- objecttreeparser.cpp | 2 +- 4 files changed, 1 insertion(+), 247 deletions(-) delete mode 100644 kleojobexecutor.cpp delete mode 100644 kleojobexecutor.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a021d9f7..6ef92dfdb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -224,7 +224,6 @@ set(kmailprivate_LIB_SRCS messageactions.cpp statusbarlabel.cpp groupware_types.cpp - kleojobexecutor.cpp messagetree.cpp procmailparser.cpp stringutil.cpp diff --git a/kleojobexecutor.cpp b/kleojobexecutor.cpp deleted file mode 100644 index 904dbfd83..000000000 --- a/kleojobexecutor.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/* - Copyright (c) 2008 Volker Krause - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "kleojobexecutor.h" - -#include -#include -#include -#include - -#include - -#include -#include - -#include - -using namespace KMail; -using namespace Kleo; -using namespace GpgME; -using boost::shared_ptr; - -KleoJobExecutor::KleoJobExecutor( QObject* parent ) : QObject( parent ) -{ - setObjectName( "KleoJobExecutor" ); - mEventLoop = new QEventLoop( this ); -} - - -GpgME::VerificationResult KleoJobExecutor::exec( - Kleo::VerifyDetachedJob* job, - const QByteArray & signature, - const QByteArray & signedData ) -{ - kDebug() << "Starting detached verification job"; - connect( job, SIGNAL(result(GpgME::VerificationResult)), - SLOT(verificationResult(GpgME::VerificationResult)) ); - GpgME::Error err = job->start( signature, signedData ); - if ( err ) - return VerificationResult( err ); - mEventLoop->exec( QEventLoop::ExcludeUserInputEvents ); - return mVerificationResult; -} - -GpgME::VerificationResult KleoJobExecutor::exec( - Kleo::VerifyOpaqueJob * job, - const QByteArray & signedData, - QByteArray & plainText ) -{ - kDebug() << "Starting opaque verification job"; - connect( job, SIGNAL(result(GpgME::VerificationResult,QByteArray)), - SLOT(verificationResult(GpgME::VerificationResult,QByteArray)) ); - GpgME::Error err = job->start( signedData ); - if ( err ) { - plainText.clear(); - return VerificationResult( err ); - } - mEventLoop->exec( QEventLoop::ExcludeUserInputEvents ); - plainText = mData; - return mVerificationResult; -} - -std::pair< GpgME::DecryptionResult, GpgME::VerificationResult > KleoJobExecutor::exec( - Kleo::DecryptVerifyJob * job, - const QByteArray & cipherText, - QByteArray & plainText ) -{ - kDebug() << "Starting decryption job"; - connect( job, SIGNAL(result(GpgME::DecryptionResult,GpgME::VerificationResult,QByteArray)), - SLOT(decryptResult(GpgME::DecryptionResult,GpgME::VerificationResult,QByteArray)) ); - GpgME::Error err = job->start( cipherText ); - if ( err ) { - plainText.clear(); - return std::make_pair( DecryptionResult( err ), VerificationResult( err ) ); - } - mEventLoop->exec( QEventLoop::ExcludeUserInputEvents ); - plainText = mData; - return std::make_pair( mDecryptResult, mVerificationResult ); -} - -GpgME::ImportResult KleoJobExecutor::exec(Kleo::ImportJob* job, const QByteArray & certData) -{ - connect( job, SIGNAL(result(GpgME::ImportResult)), SLOT(importResult(GpgME::ImportResult)) ); - GpgME::Error err = job->start( certData ); - if ( err ) - return ImportResult( err ); - mEventLoop->exec( QEventLoop::ExcludeUserInputEvents ); - return mImportResult; -} - -void KleoJobExecutor::verificationResult(const GpgME::VerificationResult & result) -{ - kDebug() << "Detached verification job finished"; - Kleo::Job * job = dynamic_cast( sender() ); - assert(job); - mVerificationResult = result; - mAuditLogError = job->auditLogError(); - mAuditLog = job->auditLogAsHtml(); - mEventLoop->quit(); -} - -void KleoJobExecutor::verificationResult(const GpgME::VerificationResult & result, const QByteArray & plainText) -{ - kDebug() << "Opaque verification job finished"; - Kleo::Job * job = dynamic_cast( sender() ); - assert(job); - mVerificationResult = result; - mData = plainText; - mAuditLogError = job->auditLogError(); - mAuditLog = job->auditLogAsHtml(); - mEventLoop->quit(); -} - -void KleoJobExecutor::decryptResult( - const GpgME::DecryptionResult & decryptionresult, - const GpgME::VerificationResult & verificationresult, - const QByteArray & plainText ) -{ - kDebug() << "Decryption job finished"; - Kleo::Job * job = dynamic_cast( sender() ); - assert(job); - mVerificationResult = verificationresult; - mDecryptResult = decryptionresult; - mData = plainText; - mAuditLogError = job->auditLogError(); - mAuditLog = job->auditLogAsHtml(); - mEventLoop->quit(); -} - -void KleoJobExecutor::importResult(const GpgME::ImportResult & result) -{ - Kleo::Job * job = dynamic_cast( sender() ); - assert(job); - mImportResult = result; - mAuditLogError = job->auditLogError(); - mAuditLog = job->auditLogAsHtml(); - mEventLoop->quit(); -} - - -QString KleoJobExecutor::auditLogAsHtml() const -{ - return mAuditLog; -} - -#include "kleojobexecutor.moc" diff --git a/kleojobexecutor.h b/kleojobexecutor.h deleted file mode 100644 index 4eff93fc7..000000000 --- a/kleojobexecutor.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - Copyright (c) 2008 Volker Krause - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#ifndef KMAIl_KLEOJOBEXECUTOR_H -#define KMAIl_KLEOJOBEXECUTOR_H - -#include -#include -#include - -#include - -#include - -class QEventLoop; - -namespace Kleo { - class DecryptVerifyJob; - class ImportJob; - class VerifyDetachedJob; - class VerifyOpaqueJob; -} - -namespace KMail { - -/** - Helper class for synchronous execution of Kleo crypto jobs. -*/ -class KleoJobExecutor : public QObject -{ - Q_OBJECT - public: - KleoJobExecutor( QObject *parent = 0 ); - - GpgME::VerificationResult exec( Kleo::VerifyDetachedJob* job, - const QByteArray &signature, - const QByteArray &signedData ); - GpgME::VerificationResult exec( Kleo::VerifyOpaqueJob* job, - const QByteArray &signedData, - QByteArray &plainText ); - std::pair exec( Kleo::DecryptVerifyJob *job, - const QByteArray &cipherText, - QByteArray &plainText ); - GpgME::ImportResult exec( Kleo::ImportJob* job, const QByteArray &certData ); - - GpgME::Error auditLogError() const { return mAuditLogError; } - QString auditLogAsHtml() const; - - private slots: - void verificationResult( const GpgME::VerificationResult &result ); - void verificationResult( const GpgME::VerificationResult &result, const QByteArray &plainText ); - void decryptResult( const GpgME::DecryptionResult & decryptionresult, - const GpgME::VerificationResult & verificationresult, - const QByteArray & plainText ); - void importResult( const GpgME::ImportResult &result ); - - private: - QEventLoop *mEventLoop; - GpgME::VerificationResult mVerificationResult; - GpgME::DecryptionResult mDecryptResult; - GpgME::ImportResult mImportResult; - QByteArray mData; - GpgME::Error mAuditLogError; - QString mAuditLog; -}; - -} - -#endif diff --git a/objecttreeparser.cpp b/objecttreeparser.cpp index 923041f28..3db9626a1 100644 --- a/objecttreeparser.cpp +++ b/objecttreeparser.cpp @@ -51,7 +51,7 @@ #include "interfaces/bodypartformatter.h" #include "globalsettings.h" #include "util.h" -#include "kleojobexecutor.h" +#include "libmessageviewer/kleojobexecutor.h" #include "stringutil.h" #include "iconnamecache.h" #include "libmessageviewer/autoqpointer.h"