libkpgp

kpgpui.h
1/*
2 kpgpui.h
3
4 Copyright (C) 2001,2002 the KPGP authors
5 See file AUTHORS.kpgp for details
6
7 This file is part of KPGP, the KDE PGP/GnuPG support library.
8
9 KPGP is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software Foundation,
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19#ifndef KPGPUI_H
20#define KPGPUI_H
21
22#include <kdialogbase.h> // base class of all dialogs here
23#include <tqwidget.h> // base class of Config
24#include <tqcheckbox.h> // used in inlined methods
25#include <kdebug.h> // used in inlined methods
26#include <tqcstring.h> // used in return-by-value
27#include <tqstring.h> // is a member in KeyRequester
28#include <tqvaluevector.h> // used in KeyApprovalDialog
29
30#include "kpgp.h"
31
32#include <tdemacros.h>
33
34class TQString;
35class TQRegExp;
36class TQCString;
37class TQCheckBox; // needed by Config, KeySelectionDialog
38class TQMultiLineEdit; // needed by CipherTextDialog
39class TQComboBox; // needed by Config
40class TQPixmap; // needed by KeySelectionDialog
41class TQPushButton; // needed by KeyRequester
42class TQTimer; // needed by KeySelectionDialog
43
44class TDEListView; // needed by KeySelectionDialog
45class KPasswordEdit; // needed by PassphraseDialog
46
47namespace Kpgp {
48
49class Module;
50class KeyList; // needed by KeySelectionDialog
51class Key; // needed by KeySelectionDialog
52class KeyIDList; // needed by KeySelectionDialog
53
55class TDE_EXPORT PassphraseDialog : public KDialogBase
56{
57 TQ_OBJECT
58
59
60 public:
61 PassphraseDialog( TQWidget *parent=0, const TQString &caption=TQString(),
62 bool modal=true, const TQString &keyID=TQString());
63 virtual ~PassphraseDialog();
64
65 TQString passphrase();
66
67 private:
68 KPasswordEdit *lineedit;
69};
70
71
72// -------------------------------------------------------------------------
76class TDE_EXPORT Config : public TQWidget
77{
78 TQ_OBJECT
79
80
81 public:
82 Config(TQWidget *parent = 0, const char *name = 0, bool encrypt =true);
83 virtual ~Config();
84
85 virtual void setValues();
86 virtual void applySettings();
87 TQGroupBox* optionsGroupBox() { return mpOptionsGroupBox; };
88 signals:
89 void changed();
90
91 protected:
92 Module *pgp;
93 TQCheckBox *storePass;
94 TQCheckBox *encToSelf;
95 TQCheckBox *showCipherText;
96 TQCheckBox *showKeyApprovalDlg;
97 TQComboBox *toolCombo;
98 TQGroupBox* mpOptionsGroupBox;
99};
100
101
102// -------------------------------------------------------------------------
103#define KeySelectionDialogSuper KDialogBase
104class TDE_EXPORT KeySelectionDialog: public KeySelectionDialogSuper
105{
106 TQ_OBJECT
107
108
109 enum TrustCheckMode { NoExpensiveTrustCheck,
110 AllowExpensiveTrustCheck,
111 ForceTrustCheck
112 };
113
114 public:
117 KeySelectionDialog( const KeyList& keyList,
118 const TQString& title,
119 const TQString& text = TQString(),
120 const KeyIDList& keyIds = KeyIDList(),
121 const bool rememberChoice = false,
122 const unsigned int allowedKeys = AllKeys,
123 const bool extendedSelection = false,
124 TQWidget *parent=0, const char *name=0,
125 bool modal=true );
126 virtual ~KeySelectionDialog();
127
130 virtual KeyID key() const;
131
133 virtual KeyIDList keys() const
134 { return mKeyIds; };
135
136 virtual bool rememberSelection() const
137 { if( mRememberCB )
138 return mRememberCB->isChecked();
139 else
140 return false;
141 };
142
143 protected slots:
144 virtual void slotRereadKeys();
145 virtual void slotSelectionChanged( TQListViewItem* );
146 virtual void slotSelectionChanged();
147 virtual void slotCheckSelection( TQListViewItem* = 0 );
148 virtual void slotRMB( TQListViewItem*, const TQPoint&, int );
149 virtual void slotRecheckKey();
150 virtual void slotOk();
151 virtual void slotCancel();
152 virtual void slotSearch( const TQString & text );
153 virtual void slotFilter();
154
155 private:
156 void filterByKeyID( const TQString & keyID );
157 void filterByKeyIDOrUID( const TQString & keyID );
158 void filterByUID( const TQString & uid );
159 void showAllItems();
160 bool anyChildMatches( const TQListViewItem * item, TQRegExp & rx ) const;
161
162 void initKeylist( const KeyList& keyList, const KeyIDList& keyIds );
163
164 TQString keyInfo( const Kpgp::Key* ) const;
165
166 TQString beautifyFingerprint( const TQCString& ) const;
167
168 // Returns the key ID of the key the given TQListViewItem belongs to
169 KeyID getKeyId( const TQListViewItem* ) const;
170
171 // Returns: -1 = unusable, 0 = unknown, 1 = valid, but untrusted, 2 = trusted
172 int keyValidity( const Kpgp::Key* ) const;
173
174 // Updates the given TQListViewItem with the data of the given key
175 void updateKeyInfo( const Kpgp::Key*, TQListViewItem* ) const;
176
184 int keyAdmissibility( TQListViewItem*,
185 TrustCheckMode = NoExpensiveTrustCheck ) const;
186
187 // Perform expensive trust checks for the given keys
188 bool checkKeys( const TQValueList<TQListViewItem*>& ) const;
189
190 private:
191 TDEListView *mListView;
192 TQCheckBox *mRememberCB;
193 TQPixmap *mKeyGoodPix, *mKeyBadPix, *mKeyUnknownPix, *mKeyValidPix;
194 KeyIDList mKeyIds;
195 unsigned int mAllowedKeys;
196 TQTimer* mCheckSelectionTimer;
197 TQTimer* mStartSearchTimer;
198 TQString mSearchText;
199 TQListViewItem* mCurrentContextMenuItem;
200
201 static const int sCheckSelectionDelay;
202};
203
204class TDE_EXPORT KeyRequester: public TQWidget
205{
206 TQ_OBJECT
207
208
209public:
210 KeyRequester( TQWidget * parent=0, bool multipleKeys=false,
211 unsigned int allowedKeys=AllKeys, const char * name=0 );
212 virtual ~KeyRequester();
213
214 KeyIDList keyIDs() const;
215 void setKeyIDs( const KeyIDList & keyIDs );
216
217 TQPushButton * eraseButton() const { return mEraseButton; }
218 TQPushButton * dialogButton() const { return mDialogButton; }
219
220 void setDialogCaption( const TQString & caption );
221 void setDialogMessage( const TQString & message );
222
223 bool isMultipleKeysEnabled() const;
224 void setMultipleKeysEnabled( bool enable );
225
226 int allowedKeys() const;
227 void setAllowedKeys( int allowed );
228
229protected:
231 virtual KeyIDList keyRequestHook( Module * pgp ) const = 0;
232
233protected:
234 TQLabel * mLabel;
235 TQPushButton * mEraseButton;
236 TQPushButton * mDialogButton;
237 TQString mDialogCaption, mDialogMessage;
238 bool mMulti;
239 int mAllowedKeys;
240 KeyIDList mKeys;
241
242protected slots:
243 void slotDialogButtonClicked();
244 void slotEraseButtonClicked();
245
246signals:
247 void changed();
248
249private:
250 class Private;
251 Private * d;
252protected:
253 virtual void virtual_hook( int, void* );
254};
255
256
257class TDE_EXPORT PublicKeyRequester : public KeyRequester {
258 TQ_OBJECT
259
260public:
261 PublicKeyRequester( TQWidget * parent=0, bool multipleKeys=false,
262 unsigned int allowedKeys=PublicKeys, const char * name=0 );
263 virtual ~PublicKeyRequester();
264
265protected:
266 KeyIDList keyRequestHook( Module * pgp ) const;
267
268private:
269 typedef KeyRequester base;
270 class Private;
271 Private * d;
272protected:
273 virtual void virtual_hook( int, void* );
274};
275
276
277class TDE_EXPORT SecretKeyRequester : public KeyRequester {
278 TQ_OBJECT
279
280public:
281 SecretKeyRequester( TQWidget * parent=0, bool multipleKeys=false,
282 unsigned int allowedKeys=SecretKeys, const char * name=0 );
283 virtual ~SecretKeyRequester();
284
285protected:
286 KeyIDList keyRequestHook( Module * pgp ) const;
287
288private:
289 typedef KeyRequester base;
290 class Private;
291 Private * d;
292protected:
293 virtual void virtual_hook( int, void* );
294};
295
296
297// -------------------------------------------------------------------------
298class TDE_EXPORT KeyApprovalDialog: public KDialogBase
299{
300 TQ_OBJECT
301
302
303 public:
304 KeyApprovalDialog( const TQStringList&,
305 const TQValueVector<KeyIDList>&,
306 const int allowedKeys,
307 TQWidget *parent = 0, const char *name = 0,
308 bool modal = true );
309 virtual ~KeyApprovalDialog() {};
310
311 TQValueVector<KeyIDList> keys() const { return mKeys; };
312
313 bool preferencesChanged() const { return mPrefsChanged; }
314
315 protected slots:
316 void slotPrefsChanged( int ) { mPrefsChanged = true; };
317 void slotChangeEncryptionKey( int );
318 virtual void slotOk();
319 virtual void slotCancel();
320
321 private:
322 TQValueVector<KeyIDList> mKeys;
323 int mAllowedKeys;
324 int mEncryptToSelf;
325 bool mPrefsChanged;
326 TQPtrVector<TQLabel> mAddressLabels;
327 TQPtrVector<TQLabel> mKeyIdsLabels;
328 //TQPtrVector<TQListBox> mKeyIdListBoxes;
329 TQPtrVector<TQComboBox> mEncrPrefCombos;
330};
331
332
333// -------------------------------------------------------------------------
334class TDE_EXPORT CipherTextDialog: public KDialogBase
335{
336 TQ_OBJECT
337
338
339 public:
340 CipherTextDialog( const TQCString & text, const TQCString & charset=0,
341 TQWidget *parent=0, const char *name=0, bool modal=true );
342 virtual ~CipherTextDialog() {};
343
344 private:
345 void setMinimumSize();
346 TQMultiLineEdit *mEditBox;
347};
348
349} // namespace Kpgp
350
351#endif
a widget for configuring the pgp interface.
Definition: kpgpui.h:77
This class is used to store information about a PGP key.
Definition: kpgpkey.h:433
the passphrase dialog
Definition: kpgpui.h:56