• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

messageviewer

  • sources
  • kde-4.12
  • kdepim
  • messageviewer
  • viewer
kleojobexecutor.cpp
Go to the documentation of this file.
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 
20 
21 #include "kleojobexecutor.h"
22 
23 #include <kleo/decryptverifyjob.h>
24 #include <kleo/importjob.h>
25 #include <kleo/verifydetachedjob.h>
26 #include <kleo/verifyopaquejob.h>
27 
28 #include <kdebug.h>
29 
30 #include <QBuffer>
31 #include <QEventLoop>
32 
33 #include <cassert>
34 
35 using namespace Kleo;
36 using namespace GpgME;
37 using namespace MessageViewer;
38 using boost::shared_ptr;
39 
40 KleoJobExecutor::KleoJobExecutor( QObject* parent ) : QObject( parent )
41 {
42  setObjectName( QLatin1String("KleoJobExecutor") );
43  mEventLoop = new QEventLoop( this );
44 }
45 
46 
47 GpgME::VerificationResult KleoJobExecutor::exec(
48  Kleo::VerifyDetachedJob* job,
49  const QByteArray & signature,
50  const QByteArray & signedData )
51 {
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 );
56  if ( err )
57  return VerificationResult( err );
58  mEventLoop->exec( QEventLoop::ExcludeUserInputEvents );
59  return mVerificationResult;
60 }
61 
62 GpgME::VerificationResult KleoJobExecutor::exec(
63  Kleo::VerifyOpaqueJob * job,
64  const QByteArray & signedData,
65  QByteArray & plainText )
66 {
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 );
71  if ( err ) {
72  plainText.clear();
73  return VerificationResult( err );
74  }
75  mEventLoop->exec( QEventLoop::ExcludeUserInputEvents );
76  plainText = mData;
77  return mVerificationResult;
78 }
79 
80 std::pair< GpgME::DecryptionResult, GpgME::VerificationResult > KleoJobExecutor::exec(
81  Kleo::DecryptVerifyJob * job,
82  const QByteArray & cipherText,
83  QByteArray & plainText )
84 {
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 );
89  if ( err ) {
90  plainText.clear();
91  return std::make_pair( DecryptionResult( err ), VerificationResult( err ) );
92  }
93  mEventLoop->exec( QEventLoop::ExcludeUserInputEvents );
94  plainText = mData;
95  return std::make_pair( mDecryptResult, mVerificationResult );
96 }
97 
98 GpgME::ImportResult KleoJobExecutor::exec(Kleo::ImportJob* job, const QByteArray & certData)
99 {
100  connect( job, SIGNAL(result(GpgME::ImportResult)), SLOT(importResult(GpgME::ImportResult)) );
101  GpgME::Error err = job->start( certData );
102  if ( err )
103  return ImportResult( err );
104  mEventLoop->exec( QEventLoop::ExcludeUserInputEvents );
105  return mImportResult;
106 }
107 
108 void KleoJobExecutor::verificationResult(const GpgME::VerificationResult & result)
109 {
110  kDebug() << "Detached verification job finished";
111  Kleo::Job * job = dynamic_cast<Kleo::Job*>( sender() );
112  assert(job);
113  mVerificationResult = result;
114  mAuditLogError = job->auditLogError();
115  mAuditLog = job->auditLogAsHtml();
116  mEventLoop->quit();
117 }
118 
119 void KleoJobExecutor::verificationResult(const GpgME::VerificationResult & result, const QByteArray & plainText)
120 {
121  kDebug() << "Opaque verification job finished";
122  Kleo::Job * job = dynamic_cast<Kleo::Job*>( sender() );
123  assert(job);
124  mVerificationResult = result;
125  mData = plainText;
126  mAuditLogError = job->auditLogError();
127  mAuditLog = job->auditLogAsHtml();
128  mEventLoop->quit();
129 }
130 
131 void KleoJobExecutor::decryptResult(
132  const GpgME::DecryptionResult & decryptionresult,
133  const GpgME::VerificationResult & verificationresult,
134  const QByteArray & plainText )
135 {
136  kDebug() << "Decryption job finished";
137  Kleo::Job * job = dynamic_cast<Kleo::Job*>( sender() );
138  assert(job);
139  mVerificationResult = verificationresult;
140  mDecryptResult = decryptionresult;
141  mData = plainText;
142  mAuditLogError = job->auditLogError();
143  mAuditLog = job->auditLogAsHtml();
144  mEventLoop->quit();
145 }
146 
147 void KleoJobExecutor::importResult(const GpgME::ImportResult & result)
148 {
149  Kleo::Job * job = dynamic_cast<Kleo::Job*>( sender() );
150  assert(job);
151  mImportResult = result;
152  mAuditLogError = job->auditLogError();
153  mAuditLog = job->auditLogAsHtml();
154  mEventLoop->quit();
155 }
156 
157 
158 QString KleoJobExecutor::auditLogAsHtml() const
159 {
160  return mAuditLog;
161 }
162 
163 #include "kleojobexecutor.moc"
MessageViewer::KleoJobExecutor::auditLogAsHtml
QString auditLogAsHtml() const
Definition: kleojobexecutor.cpp:158
QObject
kleojobexecutor.h
MessageViewer::KleoJobExecutor::exec
GpgME::VerificationResult exec(Kleo::VerifyDetachedJob *job, const QByteArray &signature, const QByteArray &signedData)
Definition: kleojobexecutor.cpp:47
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:57 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

messageviewer

Skip menu "messageviewer"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal