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