libkdenetwork Library API Documentation

kpgpui.h

00001 /*  -*- c++ -*-
00002     kpgpui.h
00003 
00004     Copyright (C) 2001,2002 the KPGP authors
00005     See file AUTHORS.kpgp for details
00006 
00007     This file is part of KPGP, the KDE PGP/GnuPG support library.
00008 
00009     KPGP is free software; you can redistribute it and/or modify
00010     it under the terms of the GNU General Public License as published by
00011     the Free Software Foundation; either version 2 of the License, or
00012     (at your option) any later version.
00013 
00014     You should have received a copy of the GNU General Public License
00015     along with this program; if not, write to the Free Software Foundation,
00016     Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
00017  */
00018 
00019 #ifndef KPGPUI_H
00020 #define KPGPUI_H
00021 
00022 #include <kdialogbase.h>  // base class of all dialogs here
00023 #include <qwidget.h>      // base class of Config
00024 #include <qcheckbox.h>    // used in inlined methods
00025 #include <kdebug.h>       // used in inlined methods
00026 #include <qcstring.h>     // used in return-by-value
00027 #include <qstring.h>      // is a member in KeyRequester
00028 #include <qvaluevector.h> // used in KeyApprovalDialog
00029 
00030 #include "kpgp.h"
00031 
00032 class QString;
00033 class QRegExp;
00034 class QCString;
00035 class QCheckBox;            // needed by Config, KeySelectionDialog
00036 class QMultiLineEdit;       // needed by CipherTextDialog
00037 class QComboBox;            // needed by Config
00038 class QPixmap;              // needed by KeySelectionDialog
00039 class QPushButton;          // needed by KeyRequester
00040 class QTimer;               // needed by KeySelectionDialog
00041 
00042 class KListView;            // needed by KeySelectionDialog
00043 class KPasswordEdit;        // needed by PassphraseDialog
00044 
00045 namespace Kpgp {
00046 
00047 class Module;
00048 class KeyList;              // needed by KeySelectionDialog
00049 class Key;                  // needed by KeySelectionDialog
00050 class KeyIDList;            // needed by KeySelectionDialog
00051 
00053 class PassphraseDialog : public KDialogBase
00054 {
00055   Q_OBJECT
00056 
00057   public:
00058     PassphraseDialog( QWidget *parent=0, const QString &caption=QString::null,
00059                       bool modal=true, const QString &keyID=QString::null);
00060     virtual ~PassphraseDialog();
00061 
00062     const char * passphrase();
00063 
00064   private:
00065     KPasswordEdit *lineedit;
00066 };
00067 
00068 
00069 // -------------------------------------------------------------------------
00073 class Config : public QWidget
00074 {
00075   Q_OBJECT
00076 
00077   public:
00078     Config(QWidget *parent = 0, const char *name = 0, bool encrypt =true);
00079     virtual ~Config();
00080 
00081     virtual void setValues();
00082     virtual void applySettings();
00083     QGroupBox* optionsGroupBox() { return mpOptionsGroupBox; };
00084   signals:
00085     void changed();
00086 
00087   protected:
00088     Module *pgp;
00089     QCheckBox *storePass;
00090     QCheckBox *encToSelf;
00091     QCheckBox *showCipherText;
00092     QCheckBox *showKeyApprovalDlg;
00093     QComboBox *toolCombo;
00094     QGroupBox* mpOptionsGroupBox;
00095 };
00096 
00097 
00098 // -------------------------------------------------------------------------
00099 #define KeySelectionDialogSuper KDialogBase
00100 class KeySelectionDialog: public KeySelectionDialogSuper
00101 {
00102   Q_OBJECT
00103 
00104   enum TrustCheckMode { NoExpensiveTrustCheck,
00105                         AllowExpensiveTrustCheck,
00106                         ForceTrustCheck
00107                       };
00108 
00109   public:
00112     KeySelectionDialog( const KeyList& keyList,
00113                         const QString& title,
00114                         const QString& text = QString::null,
00115                         const KeyIDList& keyIds = KeyIDList(),
00116                         const bool rememberChoice = false,
00117                         const unsigned int allowedKeys = AllKeys,
00118                         const bool extendedSelection = false,
00119                         QWidget *parent=0, const char *name=0,
00120                         bool modal=true );
00121     virtual ~KeySelectionDialog();
00122 
00125     virtual KeyID key() const;
00126  
00128     virtual KeyIDList keys() const
00129       { return mKeyIds; };
00130 
00131     virtual bool rememberSelection() const
00132       { if( mRememberCB )
00133           return mRememberCB->isChecked();
00134         else
00135           return false;
00136       };
00137 
00138   protected slots:
00139     virtual void slotRereadKeys();
00140     virtual void slotSelectionChanged( QListViewItem* );
00141     virtual void slotSelectionChanged();
00142     virtual void slotCheckSelection( QListViewItem* = 0 );
00143     virtual void slotRMB( QListViewItem*, const QPoint&, int );
00144     virtual void slotRecheckKey();
00145     virtual void slotOk();
00146     virtual void slotCancel();
00147     virtual void slotSearch( const QString & text );
00148     virtual void slotFilter();
00149 
00150   private:
00151     void filterByKeyID( const QString & keyID );
00152     void filterByKeyIDOrUID( const QString & keyID );
00153     void filterByUID( const QString & uid );
00154     void showAllItems();
00155     bool anyChildMatches( const QListViewItem * item, QRegExp & rx ) const;
00156 
00157     void initKeylist( const KeyList& keyList, const KeyIDList& keyIds );
00158 
00159     QString keyInfo( const Kpgp::Key* ) const;
00160 
00161     QString beautifyFingerprint( const QCString& ) const;
00162 
00163     // Returns the key ID of the key the given QListViewItem belongs to
00164     KeyID getKeyId( const QListViewItem* ) const;
00165 
00166     // Returns: -1 = unusable, 0 = unknown, 1 = valid, but untrusted, 2 = trusted
00167     int keyValidity( const Kpgp::Key* ) const;
00168 
00169     // Updates the given QListViewItem with the data of the given key
00170     void updateKeyInfo( const Kpgp::Key*, QListViewItem* ) const;
00171 
00179     int keyAdmissibility( QListViewItem*,
00180                           TrustCheckMode = NoExpensiveTrustCheck ) const;
00181 
00182     // Perform expensive trust checks for the given keys
00183     bool checkKeys( const QValueList<QListViewItem*>& ) const;
00184 
00185   private:
00186     KListView *mListView;
00187     QCheckBox *mRememberCB;
00188     QPixmap *mKeyGoodPix, *mKeyBadPix, *mKeyUnknownPix, *mKeyValidPix;
00189     KeyIDList mKeyIds;
00190     unsigned int mAllowedKeys;
00191     QTimer* mCheckSelectionTimer;
00192     QTimer* mStartSearchTimer;
00193     QString mSearchText;
00194     QListViewItem* mCurrentContextMenuItem;
00195 
00196   static const int sCheckSelectionDelay;
00197 };
00198 
00199 class KeyRequester: public QWidget
00200 {
00201   Q_OBJECT
00202 
00203 public:
00204   KeyRequester( QWidget * parent=0, bool multipleKeys=false,
00205         unsigned int allowedKeys=AllKeys, const char * name=0 );
00206   virtual ~KeyRequester();
00207 
00208   KeyIDList keyIDs() const;
00209   void setKeyIDs( const KeyIDList & keyIDs );
00210 
00211   QPushButton * eraseButton() const { return mEraseButton; }
00212   QPushButton * dialogButton() const { return mDialogButton; }
00213 
00214   void setDialogCaption( const QString & caption );
00215   void setDialogMessage( const QString & message );
00216 
00217   bool isMultipleKeysEnabled() const;
00218   void setMultipleKeysEnabled( bool enable );
00219 
00220   int allowedKeys() const;
00221   void setAllowedKeys( int allowed );
00222 
00223 protected:
00225   virtual KeyIDList keyRequestHook( Module * pgp ) const = 0;
00226 
00227 protected:
00228   QLabel * mLabel;
00229   QPushButton * mEraseButton;
00230   QPushButton * mDialogButton;
00231   QString mDialogCaption, mDialogMessage;
00232   bool mMulti;
00233   int mAllowedKeys;
00234   KeyIDList mKeys;
00235 
00236 protected slots:
00237   void slotDialogButtonClicked();
00238 
00239 private:
00240   class Private;
00241   Private * d;
00242 protected:
00243   virtual void virtual_hook( int, void* );
00244 };
00245 
00246 
00247 class PublicKeyRequester : public KeyRequester {
00248   Q_OBJECT
00249 public:
00250   PublicKeyRequester( QWidget * parent=0, bool multipleKeys=false,
00251               unsigned int allowedKeys=PublicKeys, const char * name=0 );
00252   virtual ~PublicKeyRequester();
00253 
00254 protected:
00255   KeyIDList keyRequestHook( Module * pgp ) const;
00256 
00257 private:
00258   typedef KeyRequester base;
00259   class Private;
00260   Private * d;
00261 protected:
00262   virtual void virtual_hook( int, void* );
00263 };
00264 
00265 
00266 class SecretKeyRequester : public KeyRequester {
00267   Q_OBJECT
00268 public:
00269   SecretKeyRequester( QWidget * parent=0, bool multipleKeys=false,
00270               unsigned int allowedKeys=SecretKeys, const char * name=0 );
00271   virtual ~SecretKeyRequester();
00272 
00273 protected:
00274   KeyIDList keyRequestHook( Module * pgp ) const;
00275 
00276 private:
00277   typedef KeyRequester base;
00278   class Private;
00279   Private * d;
00280 protected:
00281   virtual void virtual_hook( int, void* );
00282 };
00283 
00284 
00285 // -------------------------------------------------------------------------
00286 class KeyApprovalDialog: public KDialogBase
00287 {
00288   Q_OBJECT
00289 
00290   public:
00291     KeyApprovalDialog( const QStringList&,
00292                        const QValueVector<KeyIDList>&,
00293                        const int allowedKeys,
00294                        QWidget *parent = 0, const char *name = 0,
00295                        bool modal = true );
00296     virtual ~KeyApprovalDialog() {};
00297 
00298     QValueVector<KeyIDList> keys() const { return mKeys; };
00299 
00300     bool preferencesChanged() const { return mPrefsChanged; }
00301 
00302   protected slots:
00303     void slotPrefsChanged( int ) { mPrefsChanged = true; };
00304     void slotChangeEncryptionKey( int );
00305     virtual void slotOk();
00306     virtual void slotCancel();
00307 
00308   private:
00309     QValueVector<KeyIDList> mKeys;
00310     int mAllowedKeys;
00311     int mEncryptToSelf;
00312     bool mPrefsChanged;
00313     QPtrVector<QLabel> mAddressLabels;
00314     QPtrVector<QLabel> mKeyIdsLabels;
00315     //QPtrVector<QListBox> mKeyIdListBoxes;
00316     QPtrVector<QComboBox> mEncrPrefCombos;
00317 };
00318 
00319 
00320 // -------------------------------------------------------------------------
00321 class CipherTextDialog: public KDialogBase
00322 {
00323   Q_OBJECT
00324 
00325   public:
00326     CipherTextDialog( const QCString & text, const QCString & charset=0,
00327                       QWidget *parent=0, const char *name=0, bool modal=true );
00328     virtual ~CipherTextDialog() {};
00329 
00330   private:
00331     void setMinimumSize();
00332     QMultiLineEdit *mEditBox;
00333 };
00334 
00335 } // namespace Kpgp
00336 
00337 #endif
KDE Logo
This file is part of the documentation for libkdenetwork Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Oct 4 14:39:11 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003