00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef KPGPUI_H
00020 #define KPGPUI_H
00021
00022 #include <kdialogbase.h>
00023 #include <qwidget.h>
00024 #include <qcheckbox.h>
00025 #include <kdebug.h>
00026 #include <qcstring.h>
00027 #include <qstring.h>
00028 #include <qvaluevector.h>
00029
00030 #include "kpgp.h"
00031
00032 class QString;
00033 class QRegExp;
00034 class QCString;
00035 class QCheckBox;
00036 class QMultiLineEdit;
00037 class QComboBox;
00038 class QPixmap;
00039 class QPushButton;
00040 class QTimer;
00041
00042 class KListView;
00043 class KPasswordEdit;
00044
00045 namespace Kpgp {
00046
00047 class Module;
00048 class KeyList;
00049 class Key;
00050 class KeyIDList;
00051
00053 class PassphraseDialog : public KDialogBase
00054 {
00055 Q_OBJECT
00056
00057 public:
00058 PassphraseDialog( QWidget *parent=0, const QString &caption=QString::null,
00059 bool modal=true, const QString &keyID=QString::null);
00060 virtual ~PassphraseDialog();
00061
00062 const char * passphrase();
00063
00064 private:
00065 KPasswordEdit *lineedit;
00066 };
00067
00068
00069
00073 class Config : public QWidget
00074 {
00075 Q_OBJECT
00076
00077 public:
00078 Config(QWidget *parent = 0, const char *name = 0, bool encrypt =true);
00079 virtual ~Config();
00080
00081 virtual void setValues();
00082 virtual void applySettings();
00083 QGroupBox* optionsGroupBox() { return mpOptionsGroupBox; };
00084 signals:
00085 void changed();
00086
00087 protected:
00088 Module *pgp;
00089 QCheckBox *storePass;
00090 QCheckBox *encToSelf;
00091 QCheckBox *showCipherText;
00092 QCheckBox *showKeyApprovalDlg;
00093 QComboBox *toolCombo;
00094 QGroupBox* mpOptionsGroupBox;
00095 };
00096
00097
00098
00099 #define KeySelectionDialogSuper KDialogBase
00100 class KeySelectionDialog: public KeySelectionDialogSuper
00101 {
00102 Q_OBJECT
00103
00104 enum TrustCheckMode { NoExpensiveTrustCheck,
00105 AllowExpensiveTrustCheck,
00106 ForceTrustCheck
00107 };
00108
00109 public:
00112 KeySelectionDialog( const KeyList& keyList,
00113 const QString& title,
00114 const QString& text = QString::null,
00115 const KeyIDList& keyIds = KeyIDList(),
00116 const bool rememberChoice = false,
00117 const unsigned int allowedKeys = AllKeys,
00118 const bool extendedSelection = false,
00119 QWidget *parent=0, const char *name=0,
00120 bool modal=true );
00121 virtual ~KeySelectionDialog();
00122
00125 virtual KeyID key() const;
00126
00128 virtual KeyIDList keys() const
00129 { return mKeyIds; };
00130
00131 virtual bool rememberSelection() const
00132 { if( mRememberCB )
00133 return mRememberCB->isChecked();
00134 else
00135 return false;
00136 };
00137
00138 protected slots:
00139 virtual void slotRereadKeys();
00140 virtual void slotSelectionChanged( QListViewItem* );
00141 virtual void slotSelectionChanged();
00142 virtual void slotCheckSelection( QListViewItem* = 0 );
00143 virtual void slotRMB( QListViewItem*, const QPoint&, int );
00144 virtual void slotRecheckKey();
00145 virtual void slotOk();
00146 virtual void slotCancel();
00147 virtual void slotSearch( const QString & text );
00148 virtual void slotFilter();
00149
00150 private:
00151 void filterByKeyID( const QString & keyID );
00152 void filterByKeyIDOrUID( const QString & keyID );
00153 void filterByUID( const QString & uid );
00154 void showAllItems();
00155 bool anyChildMatches( const QListViewItem * item, QRegExp & rx ) const;
00156
00157 void initKeylist( const KeyList& keyList, const KeyIDList& keyIds );
00158
00159 QString keyInfo( const Kpgp::Key* ) const;
00160
00161 QString beautifyFingerprint( const QCString& ) const;
00162
00163
00164 KeyID getKeyId( const QListViewItem* ) const;
00165
00166
00167 int keyValidity( const Kpgp::Key* ) const;
00168
00169
00170 void updateKeyInfo( const Kpgp::Key*, QListViewItem* ) const;
00171
00179 int keyAdmissibility( QListViewItem*,
00180 TrustCheckMode = NoExpensiveTrustCheck ) const;
00181
00182
00183 bool checkKeys( const QValueList<QListViewItem*>& ) const;
00184
00185 private:
00186 KListView *mListView;
00187 QCheckBox *mRememberCB;
00188 QPixmap *mKeyGoodPix, *mKeyBadPix, *mKeyUnknownPix, *mKeyValidPix;
00189 KeyIDList mKeyIds;
00190 unsigned int mAllowedKeys;
00191 QTimer* mCheckSelectionTimer;
00192 QTimer* mStartSearchTimer;
00193 QString mSearchText;
00194 QListViewItem* mCurrentContextMenuItem;
00195
00196 static const int sCheckSelectionDelay;
00197 };
00198
00199 class KeyRequester: public QWidget
00200 {
00201 Q_OBJECT
00202
00203 public:
00204 KeyRequester( QWidget * parent=0, bool multipleKeys=false,
00205 unsigned int allowedKeys=AllKeys, const char * name=0 );
00206 virtual ~KeyRequester();
00207
00208 KeyIDList keyIDs() const;
00209 void setKeyIDs( const KeyIDList & keyIDs );
00210
00211 QPushButton * eraseButton() const { return mEraseButton; }
00212 QPushButton * dialogButton() const { return mDialogButton; }
00213
00214 void setDialogCaption( const QString & caption );
00215 void setDialogMessage( const QString & message );
00216
00217 bool isMultipleKeysEnabled() const;
00218 void setMultipleKeysEnabled( bool enable );
00219
00220 int allowedKeys() const;
00221 void setAllowedKeys( int allowed );
00222
00223 protected:
00225 virtual KeyIDList keyRequestHook( Module * pgp ) const = 0;
00226
00227 protected:
00228 QLabel * mLabel;
00229 QPushButton * mEraseButton;
00230 QPushButton * mDialogButton;
00231 QString mDialogCaption, mDialogMessage;
00232 bool mMulti;
00233 int mAllowedKeys;
00234 KeyIDList mKeys;
00235
00236 protected slots:
00237 void slotDialogButtonClicked();
00238
00239 private:
00240 class Private;
00241 Private * d;
00242 protected:
00243 virtual void virtual_hook( int, void* );
00244 };
00245
00246
00247 class PublicKeyRequester : public KeyRequester {
00248 Q_OBJECT
00249 public:
00250 PublicKeyRequester( QWidget * parent=0, bool multipleKeys=false,
00251 unsigned int allowedKeys=PublicKeys, const char * name=0 );
00252 virtual ~PublicKeyRequester();
00253
00254 protected:
00255 KeyIDList keyRequestHook( Module * pgp ) const;
00256
00257 private:
00258 typedef KeyRequester base;
00259 class Private;
00260 Private * d;
00261 protected:
00262 virtual void virtual_hook( int, void* );
00263 };
00264
00265
00266 class SecretKeyRequester : public KeyRequester {
00267 Q_OBJECT
00268 public:
00269 SecretKeyRequester( QWidget * parent=0, bool multipleKeys=false,
00270 unsigned int allowedKeys=SecretKeys, const char * name=0 );
00271 virtual ~SecretKeyRequester();
00272
00273 protected:
00274 KeyIDList keyRequestHook( Module * pgp ) const;
00275
00276 private:
00277 typedef KeyRequester base;
00278 class Private;
00279 Private * d;
00280 protected:
00281 virtual void virtual_hook( int, void* );
00282 };
00283
00284
00285
00286 class KeyApprovalDialog: public KDialogBase
00287 {
00288 Q_OBJECT
00289
00290 public:
00291 KeyApprovalDialog( const QStringList&,
00292 const QValueVector<KeyIDList>&,
00293 const int allowedKeys,
00294 QWidget *parent = 0, const char *name = 0,
00295 bool modal = true );
00296 virtual ~KeyApprovalDialog() {};
00297
00298 QValueVector<KeyIDList> keys() const { return mKeys; };
00299
00300 bool preferencesChanged() const { return mPrefsChanged; }
00301
00302 protected slots:
00303 void slotPrefsChanged( int ) { mPrefsChanged = true; };
00304 void slotChangeEncryptionKey( int );
00305 virtual void slotOk();
00306 virtual void slotCancel();
00307
00308 private:
00309 QValueVector<KeyIDList> mKeys;
00310 int mAllowedKeys;
00311 int mEncryptToSelf;
00312 bool mPrefsChanged;
00313 QPtrVector<QLabel> mAddressLabels;
00314 QPtrVector<QLabel> mKeyIdsLabels;
00315
00316 QPtrVector<QComboBox> mEncrPrefCombos;
00317 };
00318
00319
00320
00321 class CipherTextDialog: public KDialogBase
00322 {
00323 Q_OBJECT
00324
00325 public:
00326 CipherTextDialog( const QCString & text, const QCString & charset=0,
00327 QWidget *parent=0, const char *name=0, bool modal=true );
00328 virtual ~CipherTextDialog() {};
00329
00330 private:
00331 void setMinimumSize();
00332 QMultiLineEdit *mEditBox;
00333 };
00334
00335 }
00336
00337 #endif