certmanager/lib

keyselectiondialog.h

00001 /*  -*- c++ -*-
00002     keyselectiondialog.h
00003 
00004     This file is part of libkleopatra, the KDE keymanagement library
00005     Copyright (c) 2004 Klarävdalens Datakonsult AB
00006 
00007     Based on kpgpui.h
00008     Copyright (C) 2001,2002 the KPGP authors
00009     See file libkdenetwork/AUTHORS.kpgp for details
00010 
00011     Libkleopatra is free software; you can redistribute it and/or
00012     modify it under the terms of the GNU General Public License as
00013     published by the Free Software Foundation; either version 2 of the
00014     License, or (at your option) any later version.
00015 
00016     Libkleopatra is distributed in the hope that it will be useful,
00017     but WITHOUT ANY WARRANTY; without even the implied warranty of
00018     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019     General Public License for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with this program; if not, write to the Free Software
00023     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00024 
00025     In addition, as a special exception, the copyright holders give
00026     permission to link the code of this program with any edition of
00027     the Qt library by Trolltech AS, Norway (or with modified versions
00028     of Qt that use the same license as Qt), and distribute linked
00029     combinations including the two.  You must obey the GNU General
00030     Public License in all respects for all of the code used other than
00031     Qt.  If you modify this file, you may extend this exception to
00032     your version of the file, but you are not obligated to do so.  If
00033     you do not wish to do so, delete this exception statement from
00034     your version.
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   protected slots:
00123     // reimplemented to avoid popping up the help, since we
00124     // override the button
00125     void slotHelp();
00126 
00127     // Could be used by derived classes to insert their own widget
00128     QVBoxLayout* topLayout() const { return mTopLayout; }
00129 
00130   private slots:
00131     void slotRereadKeys();
00132     void slotStartCertificateManager( const QString &query = QString() );
00133     void slotKeyListResult( const GpgME::KeyListResult & );
00134     void slotSelectionChanged();
00135     void slotCheckSelection() { slotCheckSelection( 0 ); }
00136     void slotCheckSelection( Kleo::KeyListViewItem * );
00137     void slotRMB( Kleo::KeyListViewItem *, const QPoint & );
00138     void slotRecheckKey();
00139     void slotTryOk();
00140     void slotOk();
00141     void slotCancel();
00142     void slotSearch( const QString & text );
00143     void slotSearch();
00144     void slotFilter();
00145 
00146   private:
00147     void filterByKeyID( const QString & keyID );
00148     void filterByKeyIDOrUID( const QString & keyID );
00149     void filterByUID( const QString & uid );
00150     void showAllItems();
00151     bool anyChildMatches( const Kleo::KeyListViewItem * item, QRegExp & rx ) const;
00152 
00153     void connectSignals();
00154     void disconnectSignals();
00155 
00156     void startKeyListJobForBackend( const Kleo::CryptoBackend::Protocol *, const std::vector<GpgME::Key> &, bool );
00157     void startValidatingKeyListing();
00158 
00159     void init( bool, bool, const QString &, const QString & );
00160 
00161   private:
00162     QVBoxLayout* mTopLayout;
00163     Kleo::KeyListView * mKeyListView;
00164     const Kleo::CryptoBackend::Protocol * mOpenPGPBackend;
00165     const Kleo::CryptoBackend::Protocol * mSMIMEBackend;
00166     QCheckBox * mRememberCB;
00167     std::vector<GpgME::Key> mSelectedKeys, mKeysToCheck;
00168     unsigned int mKeyUsage;
00169     QTimer * mCheckSelectionTimer;
00170     QTimer * mStartSearchTimer;
00171     // cross-eventloop temporaries:
00172     QString mSearchText;
00173     Kleo::KeyListViewItem * mCurrentContextMenuItem;
00174     int mTruncated, mListJobCount, mSavedOffsetY;
00175   };
00176 
00177 }
00178 
00179 #endif // __KLEO_UI_KEYSELECTIONDIALOG_H__
KDE Home | KDE Accessibility Home | Description of Access Keys