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