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