00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef __KLEO_UI_KEYSELECTIONDIALOG_H__
00038 #define __KLEO_UI_KEYSELECTIONDIALOG_H__
00039
00040 #include <kdialogbase.h>
00041
00042 #include <kleo/cryptobackend.h>
00043 #include <gpgmepp/key.h>
00044 #include <kdepimmacros.h>
00045 #include <vector>
00046
00047 class QVBoxLayout;
00048 class QCheckBox;
00049 class QPixmap;
00050 class QTimer;
00051 class QListViewItem;
00052 class QRegExp;
00053 class QPoint;
00054
00055 namespace Kleo {
00056 class KeyListView;
00057 class KeyListViewItem;
00058 }
00059
00060 namespace GpgME {
00061 class KeyListResult;
00062 }
00063
00064 namespace Kleo {
00065
00066 class KDE_EXPORT KeySelectionDialog : public KDialogBase {
00067 Q_OBJECT
00068 public:
00069
00070 enum KeyUsage {
00071 PublicKeys = 1,
00072 SecretKeys = 2,
00073 EncryptionKeys = 4,
00074 SigningKeys = 8,
00075 ValidKeys = 16,
00076 TrustedKeys = 32,
00077 CertificationKeys = 64,
00078 AuthenticationKeys = 128,
00079 OpenPGPKeys = 256,
00080 SMIMEKeys = 512,
00081 AllKeys = PublicKeys | SecretKeys | OpenPGPKeys | SMIMEKeys,
00082 ValidEncryptionKeys = AllKeys | EncryptionKeys | ValidKeys,
00083 ValidTrustedEncryptionKeys = AllKeys | EncryptionKeys | ValidKeys | TrustedKeys
00084 };
00085
00086 KeySelectionDialog( const QString & title,
00087 const QString & text,
00088 const std::vector<GpgME::Key> & selectedKeys=std::vector<GpgME::Key>(),
00089 unsigned int keyUsage=AllKeys,
00090 bool extendedSelection=false,
00091 bool rememberChoice=false,
00092 QWidget * parent=0, const char * name=0,
00093 bool modal=true );
00094 KeySelectionDialog( const QString & title,
00095 const QString & text,
00096 const QString & initialPattern,
00097 unsigned int keyUsage=AllKeys,
00098 bool extendedSelection=false,
00099 bool rememberChoice=false,
00100 QWidget * parent=0, const char * name=0,
00101 bool modal=true );
00102 ~KeySelectionDialog();
00103
00106 const GpgME::Key & selectedKey() const;
00107
00108 QString fingerprint() const;
00109
00111 const std::vector<GpgME::Key> & selectedKeys() const { return mSelectedKeys; }
00112
00114 QStringList fingerprints() const;
00115
00117 QStringList pgpKeyFingerprints() const;
00119 QStringList smimeFingerprints() const;
00120
00121 bool rememberSelection() const;
00122
00123
00124 QVBoxLayout* topLayout() const { return mTopLayout; }
00125
00126 private slots:
00127 void slotRereadKeys();
00128 void slotKeyListResult( const GpgME::KeyListResult & );
00129 void slotSelectionChanged();
00130 void slotCheckSelection() { slotCheckSelection( 0 ); }
00131 void slotCheckSelection( Kleo::KeyListViewItem * );
00132 void slotRMB( Kleo::KeyListViewItem *, const QPoint & );
00133 void slotRecheckKey();
00134 void slotTryOk();
00135 void slotOk();
00136 void slotCancel();
00137 void slotSearch( const QString & text );
00138 void slotSearch();
00139 void slotFilter();
00140
00141 private:
00142 void filterByKeyID( const QString & keyID );
00143 void filterByKeyIDOrUID( const QString & keyID );
00144 void filterByUID( const QString & uid );
00145 void showAllItems();
00146 bool anyChildMatches( const Kleo::KeyListViewItem * item, QRegExp & rx ) const;
00147
00148 void connectSignals();
00149 void disconnectSignals();
00150
00151 void startKeyListJobForBackend( const Kleo::CryptoBackend::Protocol *, const std::vector<GpgME::Key> &, bool );
00152 void startValidatingKeyListing();
00153
00154 void init( bool, bool, const QString &, const QString & );
00155
00156 private:
00157 QVBoxLayout* mTopLayout;
00158 Kleo::KeyListView * mKeyListView;
00159 const Kleo::CryptoBackend::Protocol * mOpenPGPBackend;
00160 const Kleo::CryptoBackend::Protocol * mSMIMEBackend;
00161 QCheckBox * mRememberCB;
00162 std::vector<GpgME::Key> mSelectedKeys, mKeysToCheck;
00163 unsigned int mKeyUsage;
00164 QTimer * mCheckSelectionTimer;
00165 QTimer * mStartSearchTimer;
00166
00167 QString mSearchText;
00168 Kleo::KeyListViewItem * mCurrentContextMenuItem;
00169 int mTruncated, mListJobCount, mSavedOffsetY;
00170 };
00171
00172 }
00173
00174 #endif // __KLEO_UI_KEYSELECTIONDIALOG_H__