00001
00029 #ifndef cryptplugwrapper_h
00030 #define cryptplugwrapper_h
00031
00032 #include "kleo/cryptplug.h"
00033
00034 #ifndef LIBKLEOPATRA_NO_COMPAT
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 #include "kleo/kleo_export.h"
00049 #include "kleo/cryptobackend.h"
00050
00051 #include <QtCore/QMap>
00052 #include <QtCore/QString>
00053 #include <QtCore/QVariant>
00054
00055 class QGpgMECryptoConfig;
00056
00057 namespace GpgME {
00058 class ImportResult;
00059 }
00060
00061 namespace Kleo {
00062 class KeyListJob;
00063 class EncryptJob;
00064 class DecryptJob;
00065 class SignJob;
00066 class VerifyDetachedJob;
00067 class VerifyOpaqueJob;
00068 class KeyGenerationJob;
00069 class ImportJob;
00070 class ExportJob;
00071 class DownloadJob;
00072 class DeleteJob;
00073 class SignEncryptJob;
00074 class DecryptVerifyJob;
00075 class CryptoConfig;
00076 class RefreshKeysJob;
00077 class SpecialJob;
00078 }
00079
00220 class CryptPlugWrapper;
00428 class StructuringInfoWrapper {
00429 public:
00430 StructuringInfoWrapper( CryptPlugWrapper* wrapper );
00431 ~StructuringInfoWrapper();
00432 void reset();
00433 CryptPlug::StructuringInfo data;
00434 private:
00435 void initMe();
00436 void freeMe();
00437 bool _initDone;
00438 CryptPlugWrapper* _wrapper;
00439 };
00440
00441
00442
00446 class KLEO_EXPORT CryptPlugWrapper : public Kleo::CryptoBackend::Protocol {
00447 public:
00448 static QString errorIdToText( int errId, bool & isPassphraseError );
00449
00460 typedef enum {
00461 InitStatus_undef = 0,
00462
00463 InitStatus_Ok = 1,
00464 InitStatus_NoLibName = 2,
00465 InitStatus_LoadError = 0x1000,
00466 InitStatus_InitError = 0x2000
00467 } InitStatus;
00468
00494 enum {
00495 SigStatus_UNKNOWN = 0x0000,
00496 SigStatus_VALID = SigStat_VALID,
00497 SigStatus_GREEN = SigStat_GREEN,
00498 SigStatus_RED = SigStat_RED,
00499 SigStatus_KEY_REVOKED = SigStat_KEY_REVOKED,
00500 SigStatus_KEY_EXPIRED = SigStat_KEY_EXPIRED,
00501 SigStatus_SIG_EXPIRED = SigStat_SIG_EXPIRED,
00502 SigStatus_KEY_MISSING = SigStat_KEY_MISSING,
00503 SigStatus_CRL_MISSING = SigStat_CRL_MISSING,
00504 SigStatus_CRL_TOO_OLD = SigStat_CRL_TOO_OLD,
00505 SigStatus_BAD_POLICY = SigStat_BAD_POLICY,
00506 SigStatus_SYS_ERROR = SigStat_SYS_ERROR,
00507
00508 SigStatus_NUMERICAL_CODE = 0x8000
00509 };
00510 typedef unsigned long SigStatusFlags;
00511
00512
00513 enum {
00514 CertStatus_EXPIRES_NEVER = CRYPTPLUG_CERT_DOES_NEVER_EXPIRE
00515 };
00516
00517
00541 explicit CryptPlugWrapper( const QString& name=QString(),
00542 const QString& libName=QString(),
00543 const QString& update=QString(),
00544 bool active = false );
00545
00555 ~CryptPlugWrapper();
00556
00557 QString protocol() const;
00558
00559 QString name() const {
00560 return protocol();
00561 }
00562
00588 void setActive( bool active );
00589
00597 bool active() const;
00598
00599
00624 bool setLibName( const QString& libName );
00625
00634 QString libName() const;
00635
00636
00641 void setDisplayName( const QString& name );
00642
00643
00648 QString displayName() const;
00649
00650 private:
00668 bool initialize( InitStatus* initStatus, QString* errorMsg );
00669
00670 public:
00683 void deinitialize();
00684
00697 InitStatus initStatus( QString* errorMsg ) const;
00698
00699
00714 bool hasFeature( Feature );
00715
00716
00717
00718
00719
00720
00721
00722 void freeSignatureMetaData( CryptPlug::SignatureMetaData* );
00723
00745 bool checkMessageSignature( char** cleartext,
00746 const char* signaturetext,
00747 bool signatureIsBinary,
00748 int signatureLen,
00749 CryptPlug::SignatureMetaData* sigmeta );
00750
00761 bool decryptMessage( const char* ciphertext,
00762 bool cipherIsBinary,
00763 int cipherLen,
00764 char** cleartext,
00765 const char* certificate,
00766 int* errId,
00767 char** errTxt );
00768
00781 bool decryptAndCheckMessage( const char* ciphertext,
00782 bool cipherIsBinary,
00783 int cipherLen,
00784 char** cleartext,
00785 const char* certificate,
00786 bool* signatureFound,
00787 CryptPlug::SignatureMetaData* sigmeta,
00788 int* errId,
00789 char** errTxt );
00790
00791 Kleo::KeyListJob * keyListJob( bool remote=false, bool includeSigs=false, bool validate=true ) const;
00792 Kleo::EncryptJob * encryptJob( bool armor=false, bool textmode=false ) const;
00793 Kleo::DecryptJob * decryptJob() const;
00794 Kleo::SignJob * signJob( bool armor=false, bool textMode=false ) const;
00795 Kleo::VerifyDetachedJob * verifyDetachedJob( bool textmode=false) const;
00796 Kleo::VerifyOpaqueJob * verifyOpaqueJob( bool textmode=false ) const;
00797 Kleo::KeyGenerationJob * keyGenerationJob() const;
00798
00799 Kleo::ImportJob * importJob() const;
00800 Kleo::ExportJob * publicKeyExportJob( bool armor=false ) const;
00801 Kleo::ExportJob * secretKeyExportJob( bool armor=false, const QString& charset = QString() ) const;
00802 Kleo::DownloadJob * downloadJob( bool armor=false ) const;
00803 Kleo::DeleteJob * deleteJob() const;
00804
00805 Kleo::SignEncryptJob * signEncryptJob( bool armor=false, bool textmode=false ) const;
00806 Kleo::DecryptVerifyJob * decryptVerifyJob( bool textmode=false ) const;
00807 Kleo::RefreshKeysJob * refreshKeysJob() const;
00808
00809 Kleo::SpecialJob * specialJob( const char *, const QMap<QString,QVariant> & ) const { return 0; }
00810
00811 GpgME::ImportResult importCertificate( const char* data, size_t length );
00812
00813 CryptPlug * cryptPlug() const { return _cp; }
00814
00815 private:
00816 QString _name;
00817 QString _libName;
00818 QString _updateURL;
00819 bool _active;
00820 InitStatus _initStatus;
00821 QString _lastError;
00822 CryptPlug* _cp;
00823
00824 bool mAlwaysEncryptToSelf;
00825 class Config;
00826 Config * _config;
00827 QGpgMECryptoConfig * _cryptoConfig;
00828 };
00829
00830 #endif // !LIBKLEOPATRA_NO_COMPAT
00831
00832 #endif // cryptplugwrapper_h