diff options
Diffstat (limited to 'framework/src/domain/mime/mimetreeparser/qgpgmejobexecutor.cpp')
-rw-r--r-- | framework/src/domain/mime/mimetreeparser/qgpgmejobexecutor.cpp | 158 |
1 files changed, 0 insertions, 158 deletions
diff --git a/framework/src/domain/mime/mimetreeparser/qgpgmejobexecutor.cpp b/framework/src/domain/mime/mimetreeparser/qgpgmejobexecutor.cpp deleted file mode 100644 index 1f453342..00000000 --- a/framework/src/domain/mime/mimetreeparser/qgpgmejobexecutor.cpp +++ /dev/null | |||
@@ -1,158 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (c) 2008 Volker Krause <vkrause@kde.org> | ||
3 | |||
4 | This program is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation; either version 2 of the License, or | ||
7 | (at your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program; if not, write to the Free Software | ||
16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
17 | */ | ||
18 | |||
19 | #include "qgpgmejobexecutor.h" | ||
20 | #include "mimetreeparser_debug.h" | ||
21 | |||
22 | #include <QGpgME/DecryptVerifyJob> | ||
23 | #include <QGpgME/ImportJob> | ||
24 | #include <QGpgME/VerifyDetachedJob> | ||
25 | #include <QGpgME/VerifyOpaqueJob> | ||
26 | |||
27 | #include <QEventLoop> | ||
28 | |||
29 | #include <cassert> | ||
30 | |||
31 | using namespace GpgME; | ||
32 | using namespace MimeTreeParser; | ||
33 | |||
34 | QGpgMEJobExecutor::QGpgMEJobExecutor(QObject *parent) : QObject(parent) | ||
35 | { | ||
36 | setObjectName(QStringLiteral("KleoJobExecutor")); | ||
37 | mEventLoop = new QEventLoop(this); | ||
38 | } | ||
39 | |||
40 | GpgME::VerificationResult QGpgMEJobExecutor::exec( | ||
41 | QGpgME::VerifyDetachedJob *job, | ||
42 | const QByteArray &signature, | ||
43 | const QByteArray &signedData) | ||
44 | { | ||
45 | qCDebug(MIMETREEPARSER_LOG) << "Starting detached verification job"; | ||
46 | connect(job, SIGNAL(result(GpgME::VerificationResult)), SLOT(verificationResult(GpgME::VerificationResult))); | ||
47 | GpgME::Error err = job->start(signature, signedData); | ||
48 | if (err) { | ||
49 | return VerificationResult(err); | ||
50 | } | ||
51 | mEventLoop->exec(QEventLoop::ExcludeUserInputEvents); | ||
52 | return mVerificationResult; | ||
53 | } | ||
54 | |||
55 | GpgME::VerificationResult QGpgMEJobExecutor::exec( | ||
56 | QGpgME::VerifyOpaqueJob *job, | ||
57 | const QByteArray &signedData, | ||
58 | QByteArray &plainText) | ||
59 | { | ||
60 | qCDebug(MIMETREEPARSER_LOG) << "Starting opaque verification job"; | ||
61 | connect(job, SIGNAL(result(GpgME::VerificationResult,QByteArray)), SLOT(verificationResult(GpgME::VerificationResult,QByteArray))); | ||
62 | GpgME::Error err = job->start(signedData); | ||
63 | if (err) { | ||
64 | plainText.clear(); | ||
65 | return VerificationResult(err); | ||
66 | } | ||
67 | mEventLoop->exec(QEventLoop::ExcludeUserInputEvents); | ||
68 | plainText = mData; | ||
69 | return mVerificationResult; | ||
70 | } | ||
71 | |||
72 | std::pair< GpgME::DecryptionResult, GpgME::VerificationResult > QGpgMEJobExecutor::exec( | ||
73 | QGpgME::DecryptVerifyJob *job, | ||
74 | const QByteArray &cipherText, | ||
75 | QByteArray &plainText) | ||
76 | { | ||
77 | qCDebug(MIMETREEPARSER_LOG) << "Starting decryption job"; | ||
78 | connect(job, &QGpgME::DecryptVerifyJob::result, this, &QGpgMEJobExecutor::decryptResult); | ||
79 | GpgME::Error err = job->start(cipherText); | ||
80 | if (err) { | ||
81 | plainText.clear(); | ||
82 | return std::make_pair(DecryptionResult(err), VerificationResult(err)); | ||
83 | } | ||
84 | mEventLoop->exec(QEventLoop::ExcludeUserInputEvents); | ||
85 | plainText = mData; | ||
86 | return std::make_pair(mDecryptResult, mVerificationResult); | ||
87 | } | ||
88 | |||
89 | GpgME::ImportResult QGpgMEJobExecutor::exec(QGpgME::ImportJob *job, const QByteArray &certData) | ||
90 | { | ||
91 | connect(job, SIGNAL(result(GpgME::ImportResult)), SLOT(importResult(GpgME::ImportResult))); | ||
92 | GpgME::Error err = job->start(certData); | ||
93 | if (err) { | ||
94 | return ImportResult(err); | ||
95 | } | ||
96 | mEventLoop->exec(QEventLoop::ExcludeUserInputEvents); | ||
97 | return mImportResult; | ||
98 | } | ||
99 | |||
100 | Error QGpgMEJobExecutor::auditLogError() const | ||
101 | { | ||
102 | return mAuditLogError; | ||
103 | } | ||
104 | |||
105 | void QGpgMEJobExecutor::verificationResult(const GpgME::VerificationResult &result) | ||
106 | { | ||
107 | qCDebug(MIMETREEPARSER_LOG) << "Detached verification job finished"; | ||
108 | QGpgME::Job *job = qobject_cast<QGpgME::Job *>(sender()); | ||
109 | assert(job); | ||
110 | mVerificationResult = result; | ||
111 | mAuditLogError = job->auditLogError(); | ||
112 | mAuditLog = job->auditLogAsHtml(); | ||
113 | mEventLoop->quit(); | ||
114 | } | ||
115 | |||
116 | void QGpgMEJobExecutor::verificationResult(const GpgME::VerificationResult &result, const QByteArray &plainText) | ||
117 | { | ||
118 | qCDebug(MIMETREEPARSER_LOG) << "Opaque verification job finished"; | ||
119 | QGpgME::Job *job = qobject_cast<QGpgME::Job *>(sender()); | ||
120 | assert(job); | ||
121 | mVerificationResult = result; | ||
122 | mData = plainText; | ||
123 | mAuditLogError = job->auditLogError(); | ||
124 | mAuditLog = job->auditLogAsHtml(); | ||
125 | mEventLoop->quit(); | ||
126 | } | ||
127 | |||
128 | void QGpgMEJobExecutor::decryptResult( | ||
129 | const GpgME::DecryptionResult &decryptionresult, | ||
130 | const GpgME::VerificationResult &verificationresult, | ||
131 | const QByteArray &plainText) | ||
132 | { | ||
133 | qCDebug(MIMETREEPARSER_LOG) << "Decryption job finished"; | ||
134 | QGpgME::Job *job = qobject_cast<QGpgME::Job *>(sender()); | ||
135 | assert(job); | ||
136 | mVerificationResult = verificationresult; | ||
137 | mDecryptResult = decryptionresult; | ||
138 | mData = plainText; | ||
139 | mAuditLogError = job->auditLogError(); | ||
140 | mAuditLog = job->auditLogAsHtml(); | ||
141 | mEventLoop->quit(); | ||
142 | } | ||
143 | |||
144 | void QGpgMEJobExecutor::importResult(const GpgME::ImportResult &result) | ||
145 | { | ||
146 | QGpgME::Job *job = qobject_cast<QGpgME::Job *>(sender()); | ||
147 | assert(job); | ||
148 | mImportResult = result; | ||
149 | mAuditLogError = job->auditLogError(); | ||
150 | mAuditLog = job->auditLogAsHtml(); | ||
151 | mEventLoop->quit(); | ||
152 | } | ||
153 | |||
154 | QString QGpgMEJobExecutor::auditLogAsHtml() const | ||
155 | { | ||
156 | return mAuditLog; | ||
157 | } | ||
158 | |||