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

messageviewer

  • sources
  • kde-4.14
  • kdepim
  • messageviewer
  • viewer
  • memento
decryptverifybodypartmemento.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2014-2015 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 <kdebug.h>
21 #include <kleo/decryptverifyjob.h>
22 
23 #include <gpgme++/keylistresult.h>
24 
25 #include <qstringlist.h>
26 
27 using namespace Kleo;
28 using namespace GpgME;
29 using namespace MessageViewer;
30 
31 DecryptVerifyBodyPartMemento::DecryptVerifyBodyPartMemento( DecryptVerifyJob * job, const QByteArray & cipherText )
32  : CryptoBodyPartMemento(),
33  m_cipherText( cipherText ),
34  m_job( job )
35 {
36  assert( m_job );
37 }
38 
39 DecryptVerifyBodyPartMemento::~DecryptVerifyBodyPartMemento() {
40  if ( m_job )
41  m_job->slotCancel();
42 }
43 
44 bool DecryptVerifyBodyPartMemento::start() {
45  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, SIGNAL(result(GpgME::DecryptionResult,GpgME::VerificationResult,QByteArray)),
51  this, SLOT(slotResult(GpgME::DecryptionResult,GpgME::VerificationResult,QByteArray)) );
52  setRunning( true );
53  return true;
54 }
55 
56 void DecryptVerifyBodyPartMemento::exec() {
57  assert( m_job );
58  QByteArray plainText;
59  setRunning( true );
60  const std::pair<DecryptionResult,VerificationResult> p = m_job->exec( m_cipherText, plainText );
61  saveResult( p.first, p.second, plainText );
62  m_job->deleteLater(); // exec'ed jobs don't delete themselves
63  m_job = 0;
64 }
65 
66 void DecryptVerifyBodyPartMemento::saveResult( const DecryptionResult & dr,
67  const VerificationResult & vr,
68  const QByteArray & plainText )
69 {
70  assert( m_job );
71  setRunning( false );
72  m_dr = dr;
73  m_vr = vr;
74  m_plainText = plainText;
75  setAuditLog( m_job->auditLogError(), m_job->auditLogAsHtml() );
76 }
77 
78 void DecryptVerifyBodyPartMemento::slotResult( const DecryptionResult & dr,
79  const VerificationResult & vr,
80  const QByteArray & plainText )
81 {
82  saveResult( dr, vr, plainText );
83  m_job = 0;
84  notify();
85 }
MessageViewer::DecryptVerifyBodyPartMemento::~DecryptVerifyBodyPartMemento
~DecryptVerifyBodyPartMemento()
Definition: decryptverifybodypartmemento.cpp:39
MessageViewer::CryptoBodyPartMemento::setAuditLog
void setAuditLog(const GpgME::Error &err, const QString &log)
Definition: cryptobodypartmemento.cpp:50
QByteArray
MessageViewer::CryptoBodyPartMemento::notify
void notify()
Definition: cryptobodypartmemento.h:53
MessageViewer::DecryptVerifyBodyPartMemento::exec
void exec()
Definition: decryptverifybodypartmemento.cpp:56
decryptverifybodypartmemento.h
MessageViewer::CryptoBodyPartMemento::setRunning
void setRunning(bool running)
Definition: cryptobodypartmemento.cpp:56
MessageViewer::DecryptVerifyBodyPartMemento::plainText
const QByteArray & plainText() const
Definition: decryptverifybodypartmemento.h:50
MessageViewer::CryptoBodyPartMemento
Definition: cryptobodypartmemento.h:33
MessageViewer::DecryptVerifyBodyPartMemento::start
bool start()
Definition: decryptverifybodypartmemento.cpp:44
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:32:45 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
  • pimprint

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