home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kleo / keyrequester.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-09-10  |  6.9 KB  |  228 lines

  1. /*  -*- c++ -*-
  2.     keyrequester.h
  3.  
  4.     This file is part of libkleopatra, the KDE keymanagement library
  5.     Copyright (c) 2004 KlarΣlvdalens Datakonsult AB
  6.  
  7.     Libkleopatra is free software; you can redistribute it and/or
  8.     modify it under the terms of the GNU General Public License as
  9.     published by the Free Software Foundation; either version 2 of the
  10.     License, or (at your option) any later version.
  11.  
  12.     Libkleopatra is distributed in the hope that it will be useful,
  13.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.     General Public License for more details.
  16.  
  17.     You should have received a copy of the GNU General Public License
  18.     along with this program; if not, write to the Free Software
  19.     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  20.  
  21.     In addition, as a special exception, the copyright holders give
  22.     permission to link the code of this program with any edition of
  23.     the Qt library by Trolltech AS, Norway (or with modified versions
  24.     of Qt that use the same license as Qt), and distribute linked
  25.     combinations including the two.  You must obey the GNU General
  26.     Public License in all respects for all of the code used other than
  27.     Qt.  If you modify this file, you may extend this exception to
  28.     your version of the file, but you are not obligated to do so.  If
  29.     you do not wish to do so, delete this exception statement from
  30.     your version.
  31.  
  32.  
  33.     Based on kpgpui.h
  34.     Copyright (C) 2001,2002 the KPGP authors
  35.     See file libkdenetwork/AUTHORS.kpgp for details
  36.  
  37.     This file is part of KPGP, the KDE PGP/GnuPG support library.
  38.  
  39.     KPGP is free software; you can redistribute it and/or modify
  40.     it under the terms of the GNU General Public License as published by
  41.     the Free Software Foundation; either version 2 of the License, or
  42.     (at your option) any later version.
  43.  
  44.     You should have received a copy of the GNU General Public License
  45.     along with this program; if not, write to the Free Software Foundation,
  46.     Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  47.  */
  48.  
  49. #ifndef __KLEO_UI_KEYREQUESTER_H__
  50. #define __KLEO_UI_KEYREQUESTER_H__
  51.  
  52. #include <qwidget.h>
  53. #include <kleo/cryptobackend.h>
  54.  
  55. #include <vector>
  56. #include <kdepimmacros.h>
  57.  
  58. namespace Kleo {
  59.   class KeyListView;
  60.   class KeyListViewItem;
  61. }
  62.  
  63. namespace GpgME {
  64.   class Key;
  65.   class KeyListResult;
  66. }
  67.  
  68. class QStringList;
  69. class QString;
  70. class QPushButton;
  71. class QLabel;
  72.  
  73. namespace Kleo {
  74.  
  75.   /// Base class for SigningKeyRequester and EncryptionKeyRequester
  76.   class KDE_EXPORT KeyRequester : public QWidget {
  77.     Q_OBJECT
  78.   public:
  79.     KeyRequester( unsigned int allowedKeys, bool multipleKeys=false,
  80.           QWidget * parent=0, const char * name=0 );
  81.     // Constructor for Qt Designer
  82.     KeyRequester( QWidget * parent=0, const char * name=0 );
  83.     ~KeyRequester();
  84.  
  85.     const GpgME::Key & key() const;
  86.     /** Preferred method to set a key for
  87.     non-multi-KeyRequesters. Doesn't start a backend
  88.     KeyListJob.
  89.     */
  90.     void setKey( const GpgME::Key & key );
  91.  
  92.     const std::vector<GpgME::Key> & keys() const;
  93.     /** Preferred method to set a key for multi-KeyRequesters. Doesn't
  94.     start a backend KeyListJob.
  95.     */
  96.     void setKeys( const std::vector<GpgME::Key> & keys );
  97.  
  98.     QString fingerprint() const;
  99.     /** Set the key by fingerprint. Starts a background KeyListJob to
  100.     retrive the complete GpgME::Key object
  101.     */
  102.     void setFingerprint( const QString & fingerprint );
  103.  
  104.     QStringList fingerprints() const;
  105.     /** Set the keys by fingerprint. Starts a background KeyListJob to
  106.     retrive the complete GpgME::Key objects
  107.     */
  108.     void setFingerprints( const QStringList & fingerprints );
  109.  
  110.  
  111.     QPushButton * eraseButton();
  112.     QPushButton * dialogButton();
  113.  
  114.     void setDialogCaption( const QString & caption );
  115.     void setDialogMessage( const QString & message );
  116.  
  117.     bool isMultipleKeysEnabled() const;
  118.     void setMultipleKeysEnabled( bool enable );
  119.  
  120.     unsigned int allowedKeys() const;
  121.     void setAllowedKeys( unsigned int allowed );
  122.  
  123.     void setInitialQuery( const QString & s ) { mInitialQuery = s; }
  124.     const QString & initialQuery() const { return mInitialQuery; }
  125.  
  126.   signals:
  127.     void changed();
  128.  
  129.   private:
  130.     void init();
  131.     void startKeyListJob( const QStringList & fingerprints );
  132.     void updateKeys();
  133.  
  134.   private slots:
  135.     void slotNextKey( const GpgME::Key & key );
  136.     void slotKeyListResult( const GpgME::KeyListResult & result );
  137.     void slotDialogButtonClicked();
  138.     void slotEraseButtonClicked();
  139.  
  140.   private:
  141.     const CryptoBackend::Protocol * mOpenPGPBackend;
  142.     const CryptoBackend::Protocol * mSMIMEBackend;
  143.     QLabel * mLabel;
  144.     QPushButton * mEraseButton;
  145.     QPushButton * mDialogButton;
  146.     QString mDialogCaption, mDialogMessage, mInitialQuery;
  147.     bool mMulti;
  148.     unsigned int mKeyUsage;
  149.     int mJobs;
  150.     std::vector<GpgME::Key> mKeys;
  151.     std::vector<GpgME::Key> mTmpKeys;
  152.  
  153.   private:
  154.     class Private;
  155.     Private * d;
  156.   protected:
  157.     virtual void virtual_hook( int, void* );
  158.   };
  159.  
  160.  
  161.   class KDE_EXPORT EncryptionKeyRequester : public KeyRequester {
  162.     Q_OBJECT
  163.   public:
  164.     enum { OpenPGP = 1, SMIME = 2, AllProtocols = OpenPGP|SMIME };
  165.  
  166.     /**
  167.      * Preferred constructor
  168.      */
  169.     EncryptionKeyRequester( bool multipleKeys=false, unsigned int proto=AllProtocols,
  170.                 QWidget * parent=0, const char * name=0,
  171.                 bool onlyTrusted=true, bool onlyValid=true );
  172.     /**
  173.      * Constructor for Qt designer
  174.      */
  175.     EncryptionKeyRequester( QWidget * parent=0, const char * name=0 );
  176.     ~EncryptionKeyRequester();
  177.  
  178.     void setAllowedKeys( unsigned int proto, bool onlyTrusted=true, bool onlyValid=true );
  179.  
  180.   private:
  181.     class Private;
  182.     Private * d;
  183.   protected:
  184.     virtual void virtual_hook( int, void* );
  185.   };
  186.  
  187.  
  188.   class KDE_EXPORT SigningKeyRequester : public KeyRequester {
  189.     Q_OBJECT
  190.   public:
  191.     enum { OpenPGP = 1, SMIME = 2, AllProtocols = OpenPGP|SMIME };
  192.  
  193.     /**
  194.      * Preferred constructor
  195.      * @param multipleKeys whether multiple keys can be selected
  196.      *
  197.      * @param proto the allowed protocols, OpenPGP and/or SMIME
  198.      * @param onlyTrusted only show trusted keys
  199.      * @param onlyValid only show valid keys
  200.      */
  201.     SigningKeyRequester( bool multipleKeys=false, unsigned int proto=AllProtocols,
  202.              QWidget * parent=0, const char * name=0,
  203.              bool onlyTrusted=true, bool onlyValid=true );
  204.     /**
  205.      * Constructor for Qt designer
  206.      */
  207.     SigningKeyRequester( QWidget * parent=0, const char * name=0 );
  208.     ~SigningKeyRequester();
  209.  
  210.     /*
  211.      * Those parameters affect the parameters given to the key selection dialog.
  212.      * @param proto the allowed protocols, OpenPGP and/or SMIME
  213.      * @param onlyTrusted only show trusted keys
  214.      * @param onlyValid only show valid keys
  215.      */
  216.     void setAllowedKeys( unsigned int proto, bool onlyTrusted=true, bool onlyValid=true );
  217.  
  218.   private:
  219.     class Private;
  220.     Private * d;
  221.   protected:
  222.     virtual void virtual_hook( int, void* );
  223.   };
  224.  
  225. }
  226.  
  227. #endif // __KLEO_UI_KEYREQUESTER_H__
  228.