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 TQVBoxLayout;
00048 class TQCheckBox;
00049 class TQPixmap;
00050 class TQTimer;
00051 class TQListViewItem;
00052 class TQRegExp;
00053 class TQPoint;
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 TQ_OBJECT
00069 public:
00070
00071 enum KeyUsage {
00072 PublicKeys = 1,
00073 SecretKeys = 2,
00074 EncryptionKeys = 4,
00075 SigningKeys = 8,
00076 ValidKeys = 16,
00077 TrustedKeys = 32,
00078 CertificationKeys = 64,
00079 AuthenticationKeys = 128,
00080 OpenPGPKeys = 256,
00081 SMIMEKeys = 512,
00082 AllKeys = PublicKeys | SecretKeys | OpenPGPKeys | SMIMEKeys,
00083 ValidEncryptionKeys = AllKeys | EncryptionKeys | ValidKeys,
00084 ValidTrustedEncryptionKeys = AllKeys | EncryptionKeys | ValidKeys | TrustedKeys
00085 };
00086
00087 KeySelectionDialog( const TQString & title,
00088 const TQString & text,
00089 const std::vector<GpgME::Key> & selectedKeys=std::vector<GpgME::Key>(),
00090 unsigned int keyUsage=AllKeys,
00091 bool extendedSelection=false,
00092 bool rememberChoice=false,
00093 TQWidget * parent=0, const char * name=0,
00094 bool modal=true );
00095 KeySelectionDialog( const TQString & title,
00096 const TQString & text,
00097 const TQString & initialPattern,
00098 const std::vector<GpgME::Key> & selectedKeys,
00099 unsigned int keyUsage=AllKeys,
00100 bool extendedSelection=false,
00101 bool rememberChoice=false,
00102 TQWidget * parent=0, const char * name=0,
00103 bool modal=true );
00104 KeySelectionDialog( const TQString & title,
00105 const TQString & text,
00106 const TQString & initialPattern,
00107 unsigned int keyUsage=AllKeys,
00108 bool extendedSelection=false,
00109 bool rememberChoice=false,
00110 TQWidget * parent=0, const char * name=0,
00111 bool modal=true );
00112 ~KeySelectionDialog();
00113
00116 const GpgME::Key & selectedKey() const;
00117
00118 TQString fingerprint() const;
00119
00121 const std::vector<GpgME::Key> & selectedKeys() const { return mSelectedKeys; }
00122
00124 TQStringList fingerprints() const;
00125
00127 TQStringList pgpKeyFingerprints() const;
00129 TQStringList smimeFingerprints() const;
00130
00131 bool rememberSelection() const;
00132 protected slots:
00133
00134
00135 void slotHelp();
00136
00137
00138 TQVBoxLayout* topLayout() const { return mTopLayout; }
00139
00140 private slots:
00141 void slotRereadKeys();
00142 void slotStartCertificateManager( const TQString &query = TQString() );
00143 void slotStartSearchForExternalCertificates() {
00144 slotStartCertificateManager( mInitialQuery );
00145 }
00146 void slotKeyListResult( const GpgME::KeyListResult & );
00147 void slotSelectionChanged();
00148 void slotCheckSelection() { slotCheckSelection( 0 ); }
00149 void slotCheckSelection( Kleo::KeyListViewItem * );
00150 void slotRMB( Kleo::KeyListViewItem *, const TQPoint & );
00151 void slotRecheckKey();
00152 void slotTryOk();
00153 void slotOk();
00154 void slotCancel();
00155 void slotSearch( const TQString & text );
00156 void slotSearch();
00157 void slotFilter();
00158
00159 private:
00160 void filterByKeyID( const TQString & keyID );
00161 void filterByKeyIDOrUID( const TQString & keyID );
00162 void filterByUID( const TQString & uid );
00163 void showAllItems();
00164 bool anyChildMatches( const Kleo::KeyListViewItem * item, TQRegExp & rx ) const;
00165
00166 void connectSignals();
00167 void disconnectSignals();
00168
00169 void startKeyListJobForBackend( const Kleo::CryptoBackend::Protocol *, const std::vector<GpgME::Key> &, bool );
00170 void startValidatingKeyListing();
00171
00172 void init( bool, bool, const TQString &, const TQString & );
00173
00174 private:
00175 TQVBoxLayout* mTopLayout;
00176 Kleo::KeyListView * mKeyListView;
00177 const Kleo::CryptoBackend::Protocol * mOpenPGPBackend;
00178 const Kleo::CryptoBackend::Protocol * mSMIMEBackend;
00179 TQCheckBox * mRememberCB;
00180 std::vector<GpgME::Key> mSelectedKeys, mKeysToCheck;
00181 unsigned int mKeyUsage;
00182 TQTimer * mCheckSelectionTimer;
00183 TQTimer * mStartSearchTimer;
00184
00185 TQString mSearchText;
00186 const TQString mInitialQuery;
00187 Kleo::KeyListViewItem * mCurrentContextMenuItem;
00188 int mTruncated, mListJobCount, mSavedOffsetY;
00189 };
00190
00191 }
00192
00193 #endif // __KLEO_UI_KEYSELECTIONDIALOG_H__