diff options
Diffstat (limited to 'framework/src/domain/mime/mimetreeparser/decryptverifybodypartmemento.cpp')
-rw-r--r-- | framework/src/domain/mime/mimetreeparser/decryptverifybodypartmemento.cpp | 86 |
1 files changed, 0 insertions, 86 deletions
diff --git a/framework/src/domain/mime/mimetreeparser/decryptverifybodypartmemento.cpp b/framework/src/domain/mime/mimetreeparser/decryptverifybodypartmemento.cpp deleted file mode 100644 index 9810797a..00000000 --- a/framework/src/domain/mime/mimetreeparser/decryptverifybodypartmemento.cpp +++ /dev/null | |||
@@ -1,86 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (c) 2014-2017 Montel Laurent <montel@kde.org> | ||
3 | |||
4 | This program is free software; you can redistribute it and/or modify it | ||
5 | under the terms of the GNU General Public License, version 2, as | ||
6 | published by the Free Software Foundation. | ||
7 | |||
8 | This program is distributed in the hope that it will be useful, but | ||
9 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
11 | General Public License for more details. | ||
12 | |||
13 | You should have received a copy of the GNU General Public License along | ||
14 | with this program; if not, write to the Free Software Foundation, Inc., | ||
15 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
16 | */ | ||
17 | |||
18 | #include "decryptverifybodypartmemento.h" | ||
19 | |||
20 | #include <QGpgME/DecryptVerifyJob> | ||
21 | |||
22 | #include <qstringlist.h> | ||
23 | |||
24 | using namespace QGpgME; | ||
25 | using namespace GpgME; | ||
26 | using namespace MimeTreeParser; | ||
27 | |||
28 | DecryptVerifyBodyPartMemento::DecryptVerifyBodyPartMemento(DecryptVerifyJob *job, const QByteArray &cipherText) | ||
29 | : CryptoBodyPartMemento(), | ||
30 | m_cipherText(cipherText), | ||
31 | m_job(job) | ||
32 | { | ||
33 | Q_ASSERT(m_job); | ||
34 | } | ||
35 | |||
36 | DecryptVerifyBodyPartMemento::~DecryptVerifyBodyPartMemento() | ||
37 | { | ||
38 | if (m_job) { | ||
39 | m_job->slotCancel(); | ||
40 | } | ||
41 | } | ||
42 | |||
43 | bool DecryptVerifyBodyPartMemento::start() | ||
44 | { | ||
45 | Q_ASSERT(m_job); | ||
46 | if (const Error err = m_job->start(m_cipherText)) { | ||
47 | m_dr = DecryptionResult(err); | ||
48 | return false; | ||
49 | } | ||
50 | connect(m_job.data(), &DecryptVerifyJob::result, | ||
51 | this, &DecryptVerifyBodyPartMemento::slotResult); | ||
52 | setRunning(true); | ||
53 | return true; | ||
54 | } | ||
55 | |||
56 | void DecryptVerifyBodyPartMemento::exec() | ||
57 | { | ||
58 | Q_ASSERT(m_job); | ||
59 | QByteArray plainText; | ||
60 | setRunning(true); | ||
61 | const std::pair<DecryptionResult, VerificationResult> p = m_job->exec(m_cipherText, plainText); | ||
62 | saveResult(p.first, p.second, plainText); | ||
63 | m_job->deleteLater(); // exec'ed jobs don't delete themselves | ||
64 | m_job = nullptr; | ||
65 | } | ||
66 | |||
67 | void DecryptVerifyBodyPartMemento::saveResult(const DecryptionResult &dr, | ||
68 | const VerificationResult &vr, | ||
69 | const QByteArray &plainText) | ||
70 | { | ||
71 | Q_ASSERT(m_job); | ||
72 | setRunning(false); | ||
73 | m_dr = dr; | ||
74 | m_vr = vr; | ||
75 | m_plainText = plainText; | ||
76 | setAuditLog(m_job->auditLogError(), m_job->auditLogAsHtml()); | ||
77 | } | ||
78 | |||
79 | void DecryptVerifyBodyPartMemento::slotResult(const DecryptionResult &dr, | ||
80 | const VerificationResult &vr, | ||
81 | const QByteArray &plainText) | ||
82 | { | ||
83 | saveResult(dr, vr, plainText); | ||
84 | m_job = nullptr; | ||
85 | notify(); | ||
86 | } | ||