cryptplugwrapper.h
Go to the documentation of this file.
00001 00029 #ifndef cryptplugwrapper_h 00030 #define cryptplugwrapper_h 00031 00032 #include "cryptplug.h" 00033 00034 #ifndef LIBKLEOPATRA_NO_COMPAT 00035 00036 /* 00037 * 00038 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 00039 * * 00040 * This file's source comments are optimized for processing by Doxygen. * 00041 * * 00042 * To obtain best results please get an updated version of Doxygen, * 00043 * for sources and binaries goto http://www.doxygen.org/index.html * 00044 * * 00045 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 00046 00047 * 00048 */ 00049 #include "kleo/cryptobackend.h" 00050 00051 #include <tqdatetime.h> 00052 00053 #include <tqvaluelist.h> 00054 #include <tqpair.h> 00055 #include <tqstringlist.h> 00056 #include <tqstring.h> 00057 #include <tdepimmacros.h> 00058 00059 00060 class TDEConfigBase; 00061 class QGpgMECryptoConfig; 00062 00063 namespace GpgME { 00064 class ImportResult; 00065 class KeyGenerationResult; 00066 } 00067 00068 namespace Kleo { 00069 class KeyListJob; 00070 class EncryptJob; 00071 class DecryptJob; 00072 class SignJob; 00073 class VerifyDetachedJob; 00074 class VerifyOpaqueJob; 00075 class KeyGenerationJob; 00076 class ImportJob; 00077 class ExportJob; 00078 class DownloadJob; 00079 class DeleteJob; 00080 class SignEncryptJob; 00081 class DecryptVerifyJob; 00082 class CryptoConfig; 00083 class RefreshKeysJob; 00084 class SpecialJob; 00085 } 00086 00227 class CryptPlugWrapper; 00435 class StructuringInfoWrapper { 00436 public: 00437 StructuringInfoWrapper( CryptPlugWrapper* wrapper ); 00438 ~StructuringInfoWrapper(); 00439 void reset(); 00440 CryptPlug::StructuringInfo data; 00441 private: 00442 void initMe(); 00443 void freeMe(); 00444 bool _initDone; 00445 CryptPlugWrapper* _wrapper; 00446 }; 00447 00448 00449 00453 class KDE_EXPORT CryptPlugWrapper : public Kleo::CryptoBackend::Protocol { 00454 public: 00455 static TQString errorIdToText( int errId, bool & isPassphraseError ); 00456 00467 typedef enum { 00468 IniStatus_undef = 0, 00469 00470 IniStatus_Ok = 1, 00471 IniStatus_NoLibName = 2, 00472 IniStatus_LoadError = 0x1000, 00473 IniStatus_InitError = 0x2000 00474 } IniStatus; 00475 00501 enum { 00502 SigStatus_UNKNOWN = 0x0000, 00503 SigStatus_VALID = SigStat_VALID, 00504 SigStatus_GREEN = SigStat_GREEN, 00505 SigStatus_RED = SigStat_RED, 00506 SigStatus_KEY_REVOKED = SigStat_KEY_REVOKED, 00507 SigStatus_KEY_EXPIRED = SigStat_KEY_EXPIRED, 00508 SigStatus_SIG_EXPIRED = SigStat_SIG_EXPIRED, 00509 SigStatus_KEY_MISSING = SigStat_KEY_MISSING, 00510 SigStatus_CRL_MISSING = SigStat_CRL_MISSING, 00511 SigStatus_CRL_TOO_OLD = SigStat_CRL_TOO_OLD, 00512 SigStatus_BAD_POLICY = SigStat_BAD_POLICY, 00513 SigStatus_SYS_ERROR = SigStat_SYS_ERROR, 00514 00515 SigStatus_NUMERICAL_CODE = 0x8000 /* An other error occurred. */ 00516 }; 00517 typedef unsigned long SigStatusFlags; 00518 00519 00520 enum { 00521 CerStatus_EXPIRES_NEVER = CRYPTPLUG_CERT_DOES_NEVER_EXPIRE 00522 }; 00523 00524 00548 CryptPlugWrapper( const TQString& name=TQString(), 00549 const TQString& libName=TQString(), 00550 const TQString& update=TQString(), 00551 bool active = false ); 00552 00562 ~CryptPlugWrapper(); 00563 00564 TQString protocol() const; 00565 00566 TQString name() const { 00567 return protocol(); 00568 } 00569 00595 void setActive( bool active ); 00596 00604 bool active() const; 00605 00606 00631 bool setLibName( const TQString& libName ); 00632 00641 TQString libName() const; 00642 00643 00648 void setDisplayName( const TQString& name ); 00649 00650 00655 TQString displayName() const; 00656 00657 private: 00675 bool initialize( IniStatus* iniStatus, TQString* errorMsg ); 00676 00677 public: 00690 void deinitialize(); 00691 00704 IniStatus iniStatus( TQString* errorMsg ) const; 00705 00706 00721 bool hasFeature( ::Feature ); 00722 00723 00724 /* \ingroup groupSignAct 00725 * Frees the members of a signature meta data struct, but not the 00726 * signature meta data struct itself as this could be allocated on 00727 * the stack. 00728 */ 00729 void freeSignatureMetaData( CryptPlug::SignatureMetaData* ); 00730 00752 bool checkMessageSignature( char** cleartext, 00753 const char* signaturetext, 00754 bool signatureIsBinary, 00755 int signatureLen, 00756 CryptPlug::SignatureMetaData* sigmeta ); 00757 00768 bool decryptMessage( const char* ciphertext, 00769 bool cipherIsBinary, 00770 int cipherLen, 00771 char** cleartext, 00772 const char* certificate, 00773 int* errId, 00774 char** errTxt ); 00775 00788 bool decryptAndCheckMessage( const char* ciphertext, 00789 bool cipherIsBinary, 00790 int cipherLen, 00791 char** cleartext, 00792 const char* certificate, 00793 bool* signatureFound, 00794 CryptPlug::SignatureMetaData* sigmeta, 00795 int* errId, 00796 char** errTxt ); 00797 00798 Kleo::KeyListJob * keyListJob( bool remote=false, bool includeSigs=false, bool validate=true ) const; 00799 Kleo::EncryptJob * encryptJob( bool armor=false, bool textmode=false ) const; 00800 Kleo::DecryptJob * decryptJob() const; 00801 Kleo::SignJob * signJob( bool armor=false, bool textMode=false ) const; 00802 Kleo::VerifyDetachedJob * verifyDetachedJob( bool textmode=false) const; 00803 Kleo::VerifyOpaqueJob * verifyOpaqueJob( bool textmode=false ) const; 00804 Kleo::KeyGenerationJob * keyGenerationJob() const; 00805 00806 Kleo::ImportJob * importJob() const; 00807 Kleo::ExportJob * publicKeyExportJob( bool armor=false ) const; 00808 Kleo::ExportJob * secretKeyExportJob( bool armor=false, const TQString& charset = TQString() ) const; 00809 Kleo::DownloadJob * downloadJob( bool armor=false ) const; 00810 Kleo::DeleteJob * deleteJob() const; 00811 00812 Kleo::SignEncryptJob * signEncryptJob( bool armor=false, bool textmode=false ) const; 00813 Kleo::DecryptVerifyJob * decryptVerifyJob( bool textmode=false ) const; 00814 Kleo::RefreshKeysJob * refreshKeysJob() const; 00815 00816 Kleo::SpecialJob * specialJob( const char *, const TQMap<TQString,TQVariant> & ) const { return 0; } 00817 00818 GpgME::ImportResult importCertificate( const char* data, size_t length ); 00819 00820 CryptPlug * cryptPlug() const { return _cp; } 00821 00822 private: 00823 TQString _name; 00824 TQString _libName; 00825 TQString _updateURL; 00826 bool _active; 00827 IniStatus _iniStatus; 00828 TQString _lastError; 00829 CryptPlug* _cp; 00830 // local parameters without representation in cryptplug.h 00831 bool mAlwaysEncryptToSelf; 00832 class Config; 00833 Config * _config; 00834 QGpgMECryptoConfig * _cryptoConfig; 00835 }; 00836 00837 #endif // !LIBKLEOPATRA_NO_COMPAT 00838 00839 #endif // cryptplugwrapper_h