kleopatra
decryptverifytask.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef __KLEOPATRA_CRYPTO_DECRYPTVERIFYTASK_H__
00034 #define __KLEOPATRA_CRYPTO_DECRYPTVERIFYTASK_H__
00035
00036 #include "task.h"
00037
00038 #include <utils/types.h>
00039
00040 #include <gpgme++/verificationresult.h>
00041
00042 #include <boost/shared_ptr.hpp>
00043
00044
00045 namespace KMime {
00046 namespace Types {
00047 class Mailbox;
00048 }
00049 }
00050 namespace GpgME {
00051 class DecryptionResult;
00052 class VerificationResult;
00053 class Key;
00054 class Signature;
00055 }
00056
00057 namespace Kleo {
00058
00059 class Input;
00060 class Output;
00061
00062 namespace Crypto {
00063
00064 class DecryptVerifyResult;
00065
00066 class AbstractDecryptVerifyTask : public Task {
00067 Q_OBJECT
00068 public:
00069 explicit AbstractDecryptVerifyTask( QObject* parent = 0 );
00070 virtual ~AbstractDecryptVerifyTask();
00071 virtual void autodetectProtocolFromInput() = 0;
00072
00073 KMime::Types::Mailbox informativeSender() const;
00074 void setInformativeSender( const KMime::Types::Mailbox & senders );
00075
00076 Q_SIGNALS:
00077 void decryptVerifyResult( const boost::shared_ptr<const Kleo::Crypto::DecryptVerifyResult> & );
00078
00079 protected:
00080 boost::shared_ptr<DecryptVerifyResult> fromDecryptResult( const GpgME::DecryptionResult & dr, const QByteArray & plaintext, const QString & auditLog );
00081 boost::shared_ptr<DecryptVerifyResult> fromDecryptResult( const GpgME::Error & err, const QString& details, const QString & auditLog );
00082 boost::shared_ptr<DecryptVerifyResult> fromDecryptVerifyResult( const GpgME::DecryptionResult & dr, const GpgME::VerificationResult & vr, const QByteArray & plaintext, const QString & auditLog );
00083 boost::shared_ptr<DecryptVerifyResult> fromDecryptVerifyResult( const GpgME::Error & err, const QString & what, const QString & auditLog );
00084 boost::shared_ptr<DecryptVerifyResult> fromVerifyOpaqueResult( const GpgME::VerificationResult & vr, const QByteArray & plaintext, const QString & auditLog );
00085 boost::shared_ptr<DecryptVerifyResult> fromVerifyOpaqueResult( const GpgME::Error & err, const QString & details, const QString & auditLog );
00086 boost::shared_ptr<DecryptVerifyResult> fromVerifyDetachedResult( const GpgME::VerificationResult & vr, const QString & auditLog );
00087 boost::shared_ptr<DecryptVerifyResult> fromVerifyDetachedResult( const GpgME::Error & err, const QString & details, const QString & auditLog );
00088
00089 virtual QString inputLabel() const = 0;
00090 virtual QString outputLabel() const = 0;
00091
00092 private:
00093 class Private;
00094 kdtools::pimpl_ptr<Private> d;
00095 };
00096
00097 class DecryptTask : public AbstractDecryptVerifyTask {
00098 Q_OBJECT
00099 public:
00100 explicit DecryptTask( QObject* parent = 0 );
00101 ~DecryptTask();
00102
00103 void setInput( const boost::shared_ptr<Input> & input );
00104 void setOutput( const boost::shared_ptr<Output> & output );
00105
00106 void setProtocol( GpgME::Protocol prot );
00107 void autodetectProtocolFromInput();
00108
00109 QString label() const;
00110
00111 GpgME::Protocol protocol() const;
00112
00113 public Q_SLOTS:
00114 void cancel();
00115
00116 private:
00117 void doStart();
00118 QString inputLabel() const;
00119 QString outputLabel() const;
00120 unsigned long long inputSize() const;
00121
00122 private:
00123 class Private;
00124 kdtools::pimpl_ptr<Private> d;
00125 Q_PRIVATE_SLOT( d, void slotResult( GpgME::DecryptionResult, QByteArray ) )
00126 };
00127
00128 class VerifyDetachedTask : public AbstractDecryptVerifyTask {
00129 Q_OBJECT
00130 public:
00131 explicit VerifyDetachedTask( QObject* parent = 0 );
00132 ~VerifyDetachedTask();
00133
00134 void setInput( const boost::shared_ptr<Input> & input );
00135 void setSignedData( const boost::shared_ptr<Input> & signedData );
00136
00137 void setProtocol( GpgME::Protocol prot );
00138 void autodetectProtocolFromInput();
00139
00140 QString label() const;
00141
00142 GpgME::Protocol protocol() const;
00143
00144 public Q_SLOTS:
00145 void cancel();
00146
00147 private:
00148 void doStart();
00149 QString inputLabel() const;
00150 QString outputLabel() const;
00151 unsigned long long inputSize() const;
00152
00153 private:
00154 class Private;
00155 kdtools::pimpl_ptr<Private> d;
00156 Q_PRIVATE_SLOT( d, void slotResult( GpgME::VerificationResult ) )
00157 };
00158
00159 class VerifyOpaqueTask : public AbstractDecryptVerifyTask {
00160 Q_OBJECT
00161 public:
00162 explicit VerifyOpaqueTask( QObject* parent = 0 );
00163 ~VerifyOpaqueTask();
00164
00165 void setInput( const boost::shared_ptr<Input> & input );
00166 void setOutput( const boost::shared_ptr<Output> & output );
00167
00168 void setProtocol( GpgME::Protocol prot );
00169 void autodetectProtocolFromInput();
00170
00171 QString label() const;
00172
00173 GpgME::Protocol protocol() const;
00174
00175 public Q_SLOTS:
00176 void cancel();
00177
00178 private:
00179 void doStart();
00180 QString inputLabel() const;
00181 QString outputLabel() const;
00182 unsigned long long inputSize() const;
00183
00184 private:
00185 class Private;
00186 kdtools::pimpl_ptr<Private> d;
00187 Q_PRIVATE_SLOT( d, void slotResult( GpgME::VerificationResult, QByteArray ) )
00188 };
00189
00190 class DecryptVerifyTask : public AbstractDecryptVerifyTask {
00191 Q_OBJECT
00192 public:
00193 explicit DecryptVerifyTask( QObject* parent = 0 );
00194 ~DecryptVerifyTask();
00195
00196 void setInput( const boost::shared_ptr<Input> & input );
00197 void setSignedData( const boost::shared_ptr<Input> & signedData );
00198 void setOutput( const boost::shared_ptr<Output> & output );
00199
00200 void setProtocol( GpgME::Protocol prot );
00201 void autodetectProtocolFromInput();
00202
00203 QString label() const;
00204
00205 GpgME::Protocol protocol() const;
00206
00207 public Q_SLOTS:
00208 void cancel();
00209
00210 private:
00211 void doStart();
00212 QString inputLabel() const;
00213 QString outputLabel() const;
00214 unsigned long long inputSize() const;
00215
00216 private:
00217 class Private;
00218 kdtools::pimpl_ptr<Private> d;
00219 Q_PRIVATE_SLOT( d, void slotResult( GpgME::DecryptionResult, GpgME::VerificationResult, QByteArray ) )
00220 };
00221
00222 class DecryptVerifyResult : public Task::Result {
00223 friend class ::Kleo::Crypto::AbstractDecryptVerifyTask;
00224 public:
00225 class SenderInfo;
00226
00227 QString overview() const;
00228 QString details() const;
00229 bool hasError() const;
00230 int errorCode() const;
00231 QString errorString() const;
00232 VisualCode code() const;
00233 QString auditLogAsHtml() const;
00234
00235 GpgME::VerificationResult verificationResult() const;
00236
00237 static const GpgME::Key & keyForSignature( const GpgME::Signature & sig, const std::vector<GpgME::Key> & keys );
00238
00239 private:
00240 static QString keyToString( const GpgME::Key & key );
00241
00242 private:
00243 DecryptVerifyResult();
00244 DecryptVerifyResult( const DecryptVerifyResult& );
00245 DecryptVerifyResult& operator=( const DecryptVerifyResult& other );
00246
00247 DecryptVerifyResult( DecryptVerifyOperation op,
00248 const GpgME::VerificationResult& vr,
00249 const GpgME::DecryptionResult& dr,
00250 const QByteArray& stuff,
00251 int errCode,
00252 const QString & errString,
00253 const QString & inputLabel,
00254 const QString & outputLabel,
00255 const QString & auditLog,
00256 const KMime::Types::Mailbox & informativeSender );
00257
00258 private:
00259 class Private;
00260 kdtools::pimpl_ptr<Private> d;
00261 };
00262 }
00263 }
00264
00265 #endif //__KLEOPATRA_CRYPTO_DECRYPTVERIFYTASK_H__