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 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 TQString & title,
00087 const TQString & 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 TQWidget * parent=0, const char * name=0,
00093 bool modal=true );
00094 KeySelectionDialog( const TQString & title,
00095 const TQString & text,
00096 const TQString & initialPattern,
00097 const std::vector<GpgME::Key> & selectedKeys,
00098 unsigned int keyUsage=AllKeys,
00099 bool extendedSelection=false,
00100 bool rememberChoice=false,
00101 TQWidget * parent=0, const char * name=0,
00102 bool modal=true );
00103 KeySelectionDialog( const TQString & title,
00104 const TQString & text,
00105 const TQString & initialPattern,
00106 unsigned int keyUsage=AllKeys,
00107 bool extendedSelection=false,
00108 bool rememberChoice=false,
00109 TQWidget * parent=0, const char * name=0,
00110 bool modal=true );
00111 ~KeySelectionDialog();
00112
00115 const GpgME::Key & selectedKey() const;
00116
00117 TQString fingerprint() const;
00118
00120 const std::vector<GpgME::Key> & selectedKeys() const { return mSelectedKeys; }
00121
00123 TQStringList fingerprints() const;
00124
00126 TQStringList pgpKeyFingerprints() const;
00128 TQStringList smimeFingerprints() const;
00129
00130 bool rememberSelection() const;
00131 protected slots:
00132
00133
00134 void slotHelp();
00135
00136
00137 TQVBoxLayout* topLayout() const { return mTopLayout; }
00138
00139 private slots:
00140 void slotRereadKeys();
00141 void slotStartCertificateManager( const TQString &query = TQString() );
00142 void slotStartSearchForExternalCertificates() {
00143 slotStartCertificateManager( mInitialQuery );
00144 }
00145 void slotKeyListResult( const GpgME::KeyListResult & );
00146 void slotSelectionChanged();
00147 void slotCheckSelection() { slotCheckSelection( 0 ); }
00148 void slotCheckSelection( Kleo::KeyListViewItem * );
00149 void slotRMB( Kleo::KeyListViewItem *, const TQPoint & );
00150 void slotRecheckKey();
00151 void slotTryOk();
00152 void slotOk();
00153 void slotCancel();
00154 void slotSearch( const TQString & text );
00155 void slotSearch();
00156 void slotFilter();
00157
00158 private:
00159 void filterByKeyID( const TQString & keyID );
00160 void filterByKeyIDOrUID( const TQString & keyID );
00161 void filterByUID( const TQString & uid );
00162 void showAllItems();
00163 bool anyChildMatches( const Kleo::KeyListViewItem * item, TQRegExp & rx ) const;
00164
00165 void connectSignals();
00166 void disconnectSignals();
00167
00168 void startKeyListJobForBackend( const Kleo::CryptoBackend::Protocol *, const std::vector<GpgME::Key> &, bool );
00169 void startValidatingKeyListing();
00170
00171 void init( bool, bool, const TQString &, const TQString & );
00172
00173 private:
00174 TQVBoxLayout* mTopLayout;
00175 Kleo::KeyListView * mKeyListView;
00176 const Kleo::CryptoBackend::Protocol * mOpenPGPBackend;
00177 const Kleo::CryptoBackend::Protocol * mSMIMEBackend;
00178 TQCheckBox * mRememberCB;
00179 std::vector<GpgME::Key> mSelectedKeys, mKeysToCheck;
00180 unsigned int mKeyUsage;
00181 TQTimer * mCheckSelectionTimer;
00182 TQTimer * mStartSearchTimer;
00183
00184 TQString mSearchText;
00185 const TQString mInitialQuery;
00186 Kleo::KeyListViewItem * mCurrentContextMenuItem;
00187 int mTruncated, mListJobCount, mSavedOffsetY;
00188 };
00189
00190 }
00191
00192 #endif // __KLEO_UI_KEYSELECTIONDIALOG_H__