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älvdalens 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 QCheckBox;
00048 class QPixmap;
00049 class QTimer;
00050 class QListViewItem;
00051 class QRegExp;
00052 class QPoint;
00053 
00054 namespace Kleo {
00055   class KeyListView;
00056   class KeyListViewItem;
00057 }
00058 
00059 namespace GpgME {
00060   class KeyListResult;
00061 }
00062 
00063 namespace Kleo {
00064 
00065   class KDE_EXPORT KeySelectionDialog : public KDialogBase {
00066     Q_OBJECT
00067   public:
00068 
00069     enum KeyUsage {
00070       PublicKeys = 1,
00071       SecretKeys = 2,
00072       EncryptionKeys = 4,
00073       SigningKeys = 8,
00074       ValidKeys = 16,
00075       TrustedKeys = 32,
00076       CertificationKeys = 64,
00077       AuthenticationKeys = 128,
00078       OpenPGPKeys = 256,
00079       SMIMEKeys = 512,
00080       AllKeys = PublicKeys | SecretKeys | OpenPGPKeys | SMIMEKeys,
00081       ValidTrustedEncryptionKeys = AllKeys | EncryptionKeys | ValidKeys | TrustedKeys
00082     };
00083 
00084     KeySelectionDialog( const QString & title,
00085                         const QString & text,
00086             const std::vector<GpgME::Key> & selectedKeys=std::vector<GpgME::Key>(),
00087                         unsigned int keyUsage=AllKeys,
00088                         bool extendedSelection=false,
00089             bool rememberChoice=false,
00090                         QWidget * parent=0, const char * name=0,
00091                         bool modal=true );
00092     KeySelectionDialog( const QString & title,
00093                         const QString & text,
00094             const QString & initialPattern,
00095                         unsigned int keyUsage=AllKeys,
00096                         bool extendedSelection=false,
00097             bool rememberChoice=false,
00098                         QWidget * parent=0, const char * name=0,
00099                         bool modal=true );
00100     ~KeySelectionDialog();
00101 
00104     const GpgME::Key & selectedKey() const;
00105 
00106     QString fingerprint() const;
00107 
00109     const std::vector<GpgME::Key> & selectedKeys() const { return mSelectedKeys; }
00110 
00112     QStringList fingerprints() const;
00113 
00115     QStringList pgpKeyFingerprints() const;
00117     QStringList smimeFingerprints() const;
00118 
00119     bool rememberSelection() const;
00120 
00121   private slots:
00122     void slotRereadKeys();
00123     void slotKeyListResult( const GpgME::KeyListResult & );
00124     void slotSelectionChanged();
00125     void slotCheckSelection() { slotCheckSelection( 0 ); }
00126     void slotCheckSelection( Kleo::KeyListViewItem * );
00127     void slotRMB( Kleo::KeyListViewItem *, const QPoint & );
00128     void slotRecheckKey();
00129     void slotTryOk();
00130     void slotOk();
00131     void slotCancel();
00132     void slotSearch( const QString & text );
00133     void slotSearch();
00134     void slotFilter();
00135 
00136   private:
00137     void filterByKeyID( const QString & keyID );
00138     void filterByKeyIDOrUID( const QString & keyID );
00139     void filterByUID( const QString & uid );
00140     void showAllItems();
00141     bool anyChildMatches( const Kleo::KeyListViewItem * item, QRegExp & rx ) const;
00142 
00143     void connectSignals();
00144     void disconnectSignals();
00145 
00146     void startKeyListJobForBackend( const Kleo::CryptoBackend::Protocol *, const std::vector<GpgME::Key> &, bool );
00147     void startValidatingKeyListing();
00148 
00149     void init( bool, bool, const QString &, const QString & );
00150 
00151   private:
00152     Kleo::KeyListView * mKeyListView;
00153     const Kleo::CryptoBackend::Protocol * mOpenPGPBackend;
00154     const Kleo::CryptoBackend::Protocol * mSMIMEBackend;
00155     QCheckBox * mRememberCB;
00156     std::vector<GpgME::Key> mSelectedKeys, mKeysToCheck;
00157     unsigned int mKeyUsage;
00158     QTimer * mCheckSelectionTimer;
00159     QTimer * mStartSearchTimer;
00160     // cross-eventloop temporaries:
00161     QString mSearchText;
00162     Kleo::KeyListViewItem * mCurrentContextMenuItem;
00163     int mTruncated, mListJobCount, mSavedOffsetY;
00164   };
00165 
00166 }
00167 
00168 #endif // __KLEO_UI_KEYSELECTIONDIALOG_H__
KDE Home | KDE Accessibility Home | Description of Access Keys