certmanager/lib

keyrequester.h
1/*
2 keyrequester.h
3
4 This file is part of libkleopatra, the KDE keymanagement library
5 Copyright (c) 2004 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 Based on kpgpui.h
34 Copyright (C) 2001,2002 the KPGP authors
35 See file libtdenetwork/AUTHORS.kpgp for details
36
37 This file is part of KPGP, the KDE PGP/GnuPG support library.
38
39 KPGP is free software; you can redistribute it and/or modify
40 it under the terms of the GNU General Public License as published by
41 the Free Software Foundation; either version 2 of the License, or
42 (at your option) any later version.
43
44 You should have received a copy of the GNU General Public License
45 along with this program; if not, write to the Free Software Foundation,
46 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
47 */
48
49#ifndef __KLEO_UI_KEYREQUESTER_H__
50#define __KLEO_UI_KEYREQUESTER_H__
51
52#include <tqwidget.h>
53#include <kleo/cryptobackend.h>
54
55#include <vector>
56#include <tdemacros.h>
57
58namespace Kleo {
59 class KeyListView;
60 class KeyListViewItem;
61}
62
63namespace GpgME {
64 class Key;
65 class KeyListResult;
66}
67
68class TQStringList;
69class TQString;
70class TQPushButton;
71class TQLabel;
72
73namespace Kleo {
74
76 class TDE_EXPORT KeyRequester : public TQWidget {
77 TQ_OBJECT
78
79 public:
80 KeyRequester( unsigned int allowedKeys, bool multipleKeys=false,
81 TQWidget * parent=0, const char * name=0 );
82 // Constructor for TQt Designer
83 KeyRequester( TQWidget * parent=0, const char * name=0 );
85
86 const GpgME::Key & key() const;
91 void setKey( const GpgME::Key & key );
92
93 const std::vector<GpgME::Key> & keys() const;
97 void setKeys( const std::vector<GpgME::Key> & keys );
98
99 TQString fingerprint() const;
103 void setFingerprint( const TQString & fingerprint );
104
105 TQStringList fingerprints() const;
109 void setFingerprints( const TQStringList & fingerprints );
110
111
112 TQPushButton * eraseButton();
113 TQPushButton * dialogButton();
114
115 void setDialogCaption( const TQString & caption );
116 void setDialogMessage( const TQString & message );
117
118 bool isMultipleKeysEnabled() const;
119 void setMultipleKeysEnabled( bool enable );
120
121 unsigned int allowedKeys() const;
122 void setAllowedKeys( unsigned int allowed );
123
124 void setInitialQuery( const TQString & s ) { mInitialQuery = s; }
125 const TQString & initialQuery() const { return mInitialQuery; }
126
127 signals:
128 void changed();
129
130 private:
131 void init();
132 void startKeyListJob( const TQStringList & fingerprints );
133 void updateKeys();
134
135 private slots:
136 void slotNextKey( const GpgME::Key & key );
137 void slotKeyListResult( const GpgME::KeyListResult & result );
138 void slotDialogButtonClicked();
139 void slotEraseButtonClicked();
140
141 private:
142 const CryptoBackend::Protocol * mOpenPGPBackend;
143 const CryptoBackend::Protocol * mSMIMEBackend;
144 TQLabel * mLabel;
145 TQPushButton * mEraseButton;
146 TQPushButton * mDialogButton;
147 TQString mDialogCaption, mDialogMessage, mInitialQuery;
148 bool mMulti;
149 unsigned int mKeyUsage;
150 int mJobs;
151 std::vector<GpgME::Key> mKeys;
152 std::vector<GpgME::Key> mTmpKeys;
153
154 private:
155 class Private;
156 Private * d;
157 protected:
158 virtual void virtual_hook( int, void* );
159 };
160
161
162 class TDE_EXPORT EncryptionKeyRequester : public KeyRequester {
163 TQ_OBJECT
164
165 public:
166 enum { OpenPGP = 1, SMIME = 2, AllProtocols = OpenPGP|SMIME };
167
171 EncryptionKeyRequester( bool multipleKeys=false, unsigned int proto=AllProtocols,
172 TQWidget * parent=0, const char * name=0,
173 bool onlyTrusted=true, bool onlyValid=true );
177 EncryptionKeyRequester( TQWidget * parent=0, const char * name=0 );
178 ~EncryptionKeyRequester();
179
180 void setAllowedKeys( unsigned int proto, bool onlyTrusted=true, bool onlyValid=true );
181
182 private:
183 class Private;
184 Private * d;
185 protected:
186 virtual void virtual_hook( int, void* );
187 };
188
189
190 class TDE_EXPORT SigningKeyRequester : public KeyRequester {
191 TQ_OBJECT
192
193 public:
194 enum { OpenPGP = 1, SMIME = 2, AllProtocols = OpenPGP|SMIME };
195
204 SigningKeyRequester( bool multipleKeys=false, unsigned int proto=AllProtocols,
205 TQWidget * parent=0, const char * name=0,
206 bool onlyTrusted=true, bool onlyValid=true );
210 SigningKeyRequester( TQWidget * parent=0, const char * name=0 );
211 ~SigningKeyRequester();
212
213 /*
214 * Those parameters affect the parameters given to the key selection dialog.
215 * @param proto the allowed protocols, OpenPGP and/or SMIME
216 * @param onlyTrusted only show trusted keys
217 * @param onlyValid only show valid keys
218 */
219 void setAllowedKeys( unsigned int proto, bool onlyTrusted=true, bool onlyValid=true );
220
221 private:
222 class Private;
223 Private * d;
224 protected:
225 virtual void virtual_hook( int, void* );
226 };
227
228}
229
230#endif // __KLEO_UI_KEYREQUESTER_H__
Base class for SigningKeyRequester and EncryptionKeyRequester.
Definition: keyrequester.h:76