certmanager/lib

cryptobackend.h
1 /*
2  kleo/cryptobackend.h
3 
4  This file is part of libkleopatra, the KDE keymanagement library
5  Copyright (c) 2004,2005 Klar�lvdalens Datakonsult AB
6 
7  Libkleopatra is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of the
10  License, or (at your option) any later version.
11 
12  Libkleopatra is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 
21  In addition, as a special exception, the copyright holders give
22  permission to link the code of this program with any edition of
23  the TQt library by Trolltech AS, Norway (or with modified versions
24  of TQt that use the same license as TQt), and distribute linked
25  combinations including the two. You must obey the GNU General
26  Public License in all respects for all of the code used other than
27  TQt. If you modify this file, you may extend this exception to
28  your version of the file, but you are not obligated to do so. If
29  you do not wish to do so, delete this exception statement from
30  your version.
31 */
32 
33 #ifndef __KLEO_CRYPTOBACKEND_H__
34 #define __KLEO_CRYPTOBACKEND_H__
35 
36 #include <tqstring.h>
37 #include <tqvariant.h>
38 
39 namespace Kleo {
40  class CryptoConfig;
41  class KeyListJob;
42  class KeyGenerationJob;
43  class ImportJob;
44  class ExportJob;
45  class DownloadJob;
46  class DeleteJob;
47  class EncryptJob;
48  class DecryptJob;
49  class SignJob;
50  class VerifyDetachedJob;
51  class VerifyOpaqueJob;
52  class SignEncryptJob;
53  class DecryptVerifyJob;
54  class RefreshKeysJob;
55  class SpecialJob;
56 }
57 
58 namespace Kleo {
59 
60  class CryptoBackend {
61  public:
62  class Protocol;
63 
64  static const char OpenPGP[];
65  static const char SMIME[];
66 
67  virtual ~CryptoBackend() {}
68 
69  virtual TQString name() const = 0;
70  virtual TQString displayName() const = 0;
71 
72  virtual bool checkForOpenPGP( TQString * reason=0 ) const = 0;
73  virtual bool checkForSMIME( TQString * reason=0 ) const = 0;
74  virtual bool checkForProtocol( const char * name, TQString * reason=0 ) const = 0;
75 
76  virtual bool supportsOpenPGP() const = 0;
77  virtual bool supportsSMIME() const = 0;
78  virtual bool supportsProtocol( const char * name ) const = 0;
79 
80  virtual CryptoConfig * config() const = 0;
81 
82  virtual Protocol * openpgp() const = 0;
83  virtual Protocol * smime() const = 0;
84  virtual Protocol * protocol( const char * name ) const = 0;
85 
86  virtual const char * enumerateProtocols( int i ) const = 0;
87  };
88 
89  class CryptoBackend::Protocol {
90  public:
91  virtual ~Protocol() {}
92 
93  virtual TQString name() const = 0;
94 
95  virtual TQString displayName() const = 0;
96 
97  virtual KeyListJob * keyListJob( bool remote=false, bool includeSigs=false, bool validate=false ) const = 0;
98  virtual EncryptJob * encryptJob( bool armor=false, bool textmode=false ) const = 0;
99  virtual DecryptJob * decryptJob() const = 0;
100  virtual SignJob * signJob( bool armor=false, bool textMode=false ) const = 0;
101  virtual VerifyDetachedJob * verifyDetachedJob( bool textmode=false) const = 0;
102  virtual VerifyOpaqueJob * verifyOpaqueJob( bool textmode=false ) const = 0;
103  virtual KeyGenerationJob * keyGenerationJob() const = 0;
104  virtual ImportJob * importJob() const = 0;
105  virtual ExportJob * publicKeyExportJob( bool armor=false ) const = 0;
106  // @param charset the encoding of the passphrase in the exported file
107  virtual ExportJob * secretKeyExportJob( bool armor=false, const TQString& charset = TQString() ) const = 0;
108  virtual DownloadJob * downloadJob( bool armor=false ) const = 0;
109  virtual DeleteJob * deleteJob() const = 0;
110  virtual SignEncryptJob * signEncryptJob( bool armor=false, bool textMode=false ) const = 0;
111  virtual DecryptVerifyJob * decryptVerifyJob( bool textmode=false ) const = 0;
112  virtual RefreshKeysJob * refreshKeysJob() const = 0;
113 
114  virtual SpecialJob * specialJob( const char * type, const TQStringVariantMap & args ) const = 0;
115  };
116 
117 }
118 
119 #endif // __KLEO_CRYPTOBACKEND_H__