certmanager/lib

keyrequester.h

00001 /*  -*- c++ -*-
00002     keyrequester.h
00003 
00004     This file is part of libkleopatra, the KDE keymanagement library
00005     Copyright (c) 2004 Klarälvdalens Datakonsult AB
00006 
00007     Libkleopatra is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU General Public License as
00009     published by the Free Software Foundation; either version 2 of the
00010     License, or (at your option) any later version.
00011 
00012     Libkleopatra is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     General Public License for more details.
00016 
00017     You should have received a copy of the GNU General Public License
00018     along with this program; if not, write to the Free Software
00019     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00020 
00021     In addition, as a special exception, the copyright holders give
00022     permission to link the code of this program with any edition of
00023     the Qt library by Trolltech AS, Norway (or with modified versions
00024     of Qt that use the same license as Qt), and distribute linked
00025     combinations including the two.  You must obey the GNU General
00026     Public License in all respects for all of the code used other than
00027     Qt.  If you modify this file, you may extend this exception to
00028     your version of the file, but you are not obligated to do so.  If
00029     you do not wish to do so, delete this exception statement from
00030     your version.
00031 
00032 
00033     Based on kpgpui.h
00034     Copyright (C) 2001,2002 the KPGP authors
00035     See file libkdenetwork/AUTHORS.kpgp for details
00036 
00037     This file is part of KPGP, the KDE PGP/GnuPG support library.
00038 
00039     KPGP is free software; you can redistribute it and/or modify
00040     it under the terms of the GNU General Public License as published by
00041     the Free Software Foundation; either version 2 of the License, or
00042     (at your option) any later version.
00043 
00044     You should have received a copy of the GNU General Public License
00045     along with this program; if not, write to the Free Software Foundation,
00046     Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
00047  */
00048 
00049 #ifndef __KLEO_UI_KEYREQUESTER_H__
00050 #define __KLEO_UI_KEYREQUESTER_H__
00051 
00052 #include <qwidget.h>
00053 #include <kleo/cryptobackend.h>
00054 
00055 #include <vector>
00056 #include <kdepimmacros.h>
00057 
00058 namespace Kleo {
00059   class KeyListView;
00060   class KeyListViewItem;
00061 }
00062 
00063 namespace GpgME {
00064   class Key;
00065   class KeyListResult;
00066 }
00067 
00068 class QStringList;
00069 class QString;
00070 class QPushButton;
00071 class QLabel;
00072 
00073 namespace Kleo {
00074 
00076   class KDE_EXPORT KeyRequester : public QWidget {
00077     Q_OBJECT
00078   public:
00079     KeyRequester( unsigned int allowedKeys, bool multipleKeys=false,
00080           QWidget * parent=0, const char * name=0 );
00081     // Constructor for Qt Designer
00082     KeyRequester( QWidget * parent=0, const char * name=0 );
00083     ~KeyRequester();
00084 
00085     const GpgME::Key & key() const;
00090     void setKey( const GpgME::Key & key );
00091 
00092     const std::vector<GpgME::Key> & keys() const;
00096     void setKeys( const std::vector<GpgME::Key> & keys );
00097 
00098     QString fingerprint() const;
00102     void setFingerprint( const QString & fingerprint );
00103 
00104     QStringList fingerprints() const;
00108     void setFingerprints( const QStringList & fingerprints );
00109 
00110 
00111     QPushButton * eraseButton();
00112     QPushButton * dialogButton();
00113 
00114     void setDialogCaption( const QString & caption );
00115     void setDialogMessage( const QString & message );
00116 
00117     bool isMultipleKeysEnabled() const;
00118     void setMultipleKeysEnabled( bool enable );
00119 
00120     unsigned int allowedKeys() const;
00121     void setAllowedKeys( unsigned int allowed );
00122 
00123     void setInitialQuery( const QString & s ) { mInitialQuery = s; }
00124     const QString & initialQuery() const { return mInitialQuery; }
00125 
00126   signals:
00127     void changed();
00128 
00129   private:
00130     void init();
00131     void startKeyListJob( const QStringList & fingerprints );
00132     void updateKeys();
00133 
00134   private slots:
00135     void slotNextKey( const GpgME::Key & key );
00136     void slotKeyListResult( const GpgME::KeyListResult & result );
00137     void slotDialogButtonClicked();
00138     void slotEraseButtonClicked();
00139 
00140   private:
00141     const CryptoBackend::Protocol * mOpenPGPBackend;
00142     const CryptoBackend::Protocol * mSMIMEBackend;
00143     QLabel * mLabel;
00144     QPushButton * mEraseButton;
00145     QPushButton * mDialogButton;
00146     QString mDialogCaption, mDialogMessage, mInitialQuery;
00147     bool mMulti;
00148     unsigned int mKeyUsage;
00149     int mJobs;
00150     std::vector<GpgME::Key> mKeys;
00151     std::vector<GpgME::Key> mTmpKeys;
00152 
00153   private:
00154     class Private;
00155     Private * d;
00156   protected:
00157     virtual void virtual_hook( int, void* );
00158   };
00159 
00160 
00161   class KDE_EXPORT EncryptionKeyRequester : public KeyRequester {
00162     Q_OBJECT
00163   public:
00164     enum { OpenPGP = 1, SMIME = 2, AllProtocols = OpenPGP|SMIME };
00165 
00169     EncryptionKeyRequester( bool multipleKeys=false, unsigned int proto=AllProtocols,
00170                 QWidget * parent=0, const char * name=0,
00171                 bool onlyTrusted=true, bool onlyValid=true );
00175     EncryptionKeyRequester( QWidget * parent=0, const char * name=0 );
00176     ~EncryptionKeyRequester();
00177 
00178     void setAllowedKeys( unsigned int proto, bool onlyTrusted=true, bool onlyValid=true );
00179 
00180   private:
00181     class Private;
00182     Private * d;
00183   protected:
00184     virtual void virtual_hook( int, void* );
00185   };
00186 
00187 
00188   class KDE_EXPORT SigningKeyRequester : public KeyRequester {
00189     Q_OBJECT
00190   public:
00191     enum { OpenPGP = 1, SMIME = 2, AllProtocols = OpenPGP|SMIME };
00192 
00201     SigningKeyRequester( bool multipleKeys=false, unsigned int proto=AllProtocols,
00202              QWidget * parent=0, const char * name=0,
00203              bool onlyTrusted=true, bool onlyValid=true );
00207     SigningKeyRequester( QWidget * parent=0, const char * name=0 );
00208     ~SigningKeyRequester();
00209 
00210     /*
00211      * Those parameters affect the parameters given to the key selection dialog.
00212      * @param proto the allowed protocols, OpenPGP and/or SMIME
00213      * @param onlyTrusted only show trusted keys
00214      * @param onlyValid only show valid keys
00215      */
00216     void setAllowedKeys( unsigned int proto, bool onlyTrusted=true, bool onlyValid=true );
00217 
00218   private:
00219     class Private;
00220     Private * d;
00221   protected:
00222     virtual void virtual_hook( int, void* );
00223   };
00224 
00225 }
00226 
00227 #endif // __KLEO_UI_KEYREQUESTER_H__
KDE Home | KDE Accessibility Home | Description of Access Keys