• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

libkpgp

  • sources
  • kde-4.14
  • kdepim
  • libkpgp
kpgpui.h
Go to the documentation of this file.
1 /* -*- c++ -*-
2  kpgpui.h
3 
4  Copyright (C) 2001,2002 the KPGP authors
5  See file AUTHORS.kpgp for details
6 
7  This file is part of KPGP, the KDE PGP/GnuPG support library.
8 
9  KPGP is free software; you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation; either version 2 of the License, or
12  (at your option) any later version.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software Foundation,
16  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18 
19 #ifndef KPGPUI_H
20 #define KPGPUI_H
21 
22 #include "libkpgp_export.h"
23 #include "kpgp.h"
24 #include "kpgpkey.h"
25 
26 #include <QtCore/QString> // is a member in KeyRequester
27 #include <QtCore/QVector> // used in KeyApprovalDialog
28 #include <QWidget> // base class of Config
29 #include <QCheckBox> // used in inlined methods
30 #include <QPixmap>
31 #include <QLabel>
32 
33 #include <kdebug.h> // used in inlined methods
34 #include <kdialog.h> // base class of all dialogs here
35 #include <kpassworddialog.h>
36 
37 class QString;
38 class QRegExp;
39 class QByteArray;
40 class QCheckBox; // needed by Config, KeySelectionDialog
41 class QTextEdit; // needed by CipherTextDialog
42 class QComboBox; // needed by Config
43 class QPixmap; // needed by KeySelectionDialog
44 class QPushButton; // needed by KeyRequester
45 class QTimer; // needed by KeySelectionDialog
46 class QGroupBox;
47 class QTreeWidgetItem;
48 
49 class QTreeWidget; // needed by KeySelectionDialog
50 class KPasswordEdit; // needed by PassphraseDialog
51 
52 namespace Kpgp {
53 
54 class Module;
55 class Key; // needed by KeySelectionDialog
56 class KeyIDList; // needed by KeySelectionDialog
57 
59 class KPGP_EXPORT PassphraseDialog : public KPasswordDialog
60 {
61  Q_OBJECT
62 
63  public:
64  explicit PassphraseDialog( QWidget *parent=0,
65  const QString &caption=QString(),
66  const QString &keyID=QString());
67  virtual ~PassphraseDialog();
68 
69  QString passphrase();
70 };
71 
72 
73 // -------------------------------------------------------------------------
77 class KPGP_EXPORT Config : public QWidget
78 {
79  Q_OBJECT
80 
81  public:
82  explicit Config( QWidget *parent = 0, bool encrypt = true );
83  virtual ~Config();
84 
85  virtual void setValues();
86  virtual void applySettings();
87  QGroupBox* optionsGroupBox() { return mpOptionsGroupBox; }
88  Q_SIGNALS:
89  void changed();
90 
91  protected:
92  Module *pgp;
93  QCheckBox *storePass;
94  QCheckBox *encToSelf;
95  QCheckBox *showCipherText;
96  QCheckBox *showKeyApprovalDlg;
97  QComboBox *toolCombo;
98  QGroupBox* mpOptionsGroupBox;
99 };
100 
101 
102 // -------------------------------------------------------------------------
103 #ifndef QT_NO_TREEWIDGET
104 #define KeySelectionDialogSuper KDialog
105 class KPGP_EXPORT KeySelectionDialog: public KeySelectionDialogSuper
106 {
107  Q_OBJECT
108 
109  enum TrustCheckMode { NoExpensiveTrustCheck,
110  AllowExpensiveTrustCheck,
111  ForceTrustCheck
112  };
113 
114  public:
117  KeySelectionDialog( const KeyList& keyList,
118  const QString& title,
119  const QString& text = QString(),
120  const KeyIDList& keyIds = KeyIDList(),
121  const bool rememberChoice = false,
122  const unsigned int allowedKeys = AllKeys,
123  const bool extendedSelection = false,
124  QWidget *parent=0 );
125  virtual ~KeySelectionDialog();
126 
129  virtual KeyID key() const;
130 
132  virtual KeyIDList keys() const
133  { return mKeyIds; }
134 
135  virtual bool rememberSelection() const
136  { if( mRememberCB )
137  return mRememberCB->isChecked();
138  else
139  return false;
140  }
141 
142  protected Q_SLOTS:
143  virtual void slotRereadKeys();
144  virtual void slotSelectionChanged();
145  virtual void slotCheckSelection( QTreeWidgetItem* = 0 );
146  virtual void slotRMB( const QPoint& pos );
147  virtual void slotRecheckKey();
148  virtual void slotOk();
149  virtual void slotCancel();
150  virtual void slotSearch( const QString & text );
151  virtual void slotFilter();
152 
153  private:
154  void filterByKeyID( const QString & keyID );
155  void filterByKeyIDOrUID( const QString & keyID );
156  void filterByUID( const QString & uid );
157  void showAllItems();
158  bool anyChildMatches( const QTreeWidgetItem * item, QRegExp & rx ) const;
159 
160  void initKeylist( const KeyList& keyList, const KeyIDList& keyIds );
161 
162  QString keyInfo( const Kpgp::Key* ) const;
163 
164  QString beautifyFingerprint( const QByteArray& ) const;
165 
166  // Returns the key ID of the key the given QListViewItem belongs to
167  KeyID getKeyId( const QTreeWidgetItem* ) const;
168 
169  // Returns: -1 = unusable, 0 = unknown, 1 = valid, but untrusted, 2 = trusted
170  int keyValidity( const Kpgp::Key* ) const;
171 
172  // Updates the given QListViewItem with the data of the given key
173  void updateKeyInfo( const Kpgp::Key*, QTreeWidgetItem* ) const;
174 
182  int keyAdmissibility( QTreeWidgetItem*,
183  TrustCheckMode = NoExpensiveTrustCheck ) const;
184 
185  // Perform expensive trust checks for the given keys
186  bool checkKeys( const QList<QTreeWidgetItem*>& ) const;
187 
188  private:
189  QTreeWidget *mListView;
190  QCheckBox *mRememberCB;
191  QPixmap *mKeyGoodPix, *mKeyBadPix, *mKeyUnknownPix, *mKeyValidPix;
192  KeyIDList mKeyIds;
193  unsigned int mAllowedKeys;
194  QTimer* mCheckSelectionTimer;
195  QTimer* mStartSearchTimer;
196  QString mSearchText;
197  QTreeWidgetItem* mCurrentContextMenuItem;
198 
199  static const int sCheckSelectionDelay;
200 };
201 #endif
202 
203 class KPGP_EXPORT KeyRequester: public QWidget
204 {
205  Q_OBJECT
206 
207 public:
208  explicit KeyRequester( QWidget * parent=0, bool multipleKeys=false,
209  unsigned int allowedKeys=AllKeys, const char * name=0 );
210  virtual ~KeyRequester();
211 
212  KeyIDList keyIDs() const;
213  void setKeyIDs( const KeyIDList & keyIDs );
214 
215  QPushButton * eraseButton() const { return mEraseButton; }
216  QPushButton * dialogButton() const { return mDialogButton; }
217 
218  void setDialogCaption( const QString & caption );
219  void setDialogMessage( const QString & message );
220 
221  bool isMultipleKeysEnabled() const;
222  void setMultipleKeysEnabled( bool enable );
223 
224  int allowedKeys() const;
225  void setAllowedKeys( int allowed );
226 
227 protected:
229  virtual KeyIDList keyRequestHook( Module * pgp ) const = 0;
230 
231 protected:
232  QLabel * mLabel;
233  QPushButton * mEraseButton;
234  QPushButton * mDialogButton;
235  QString mDialogCaption, mDialogMessage;
236  bool mMulti;
237  int mAllowedKeys;
238  KeyIDList mKeys;
239 
240 protected Q_SLOTS:
241  void slotDialogButtonClicked();
242  void slotEraseButtonClicked();
243 
244 Q_SIGNALS:
245  void changed();
246 
247 private:
248  class Private;
249  Private * d;
250 protected:
251  virtual void virtual_hook( int, void* );
252 };
253 
254 
255 class KPGP_EXPORT PublicKeyRequester : public KeyRequester {
256  Q_OBJECT
257 public:
258  explicit PublicKeyRequester( QWidget * parent=0, bool multipleKeys=false,
259  unsigned int allowedKeys=PublicKeys,
260  const char * name=0 );
261  virtual ~PublicKeyRequester();
262 
263 protected:
264  KeyIDList keyRequestHook( Module * pgp ) const;
265 
266 private:
267  typedef KeyRequester base;
268  class Private;
269  Private * d;
270 protected:
271  virtual void virtual_hook( int, void* );
272 };
273 
274 
275 class KPGP_EXPORT SecretKeyRequester : public KeyRequester {
276  Q_OBJECT
277 public:
278  explicit SecretKeyRequester( QWidget * parent=0, bool multipleKeys=false,
279  unsigned int allowedKeys=SecretKeys,
280  const char * name=0 );
281  virtual ~SecretKeyRequester();
282 
283 protected:
284  KeyIDList keyRequestHook( Module * pgp ) const;
285 
286 private:
287  typedef KeyRequester base;
288  class Private;
289  Private * d;
290 protected:
291  virtual void virtual_hook( int, void* );
292 };
293 
294 
295 // -------------------------------------------------------------------------
296 class KPGP_EXPORT KeyApprovalDialog: public KDialog
297 {
298  Q_OBJECT
299 
300  public:
301  KeyApprovalDialog( const QStringList&,
302  const QVector<KeyIDList>&,
303  const int allowedKeys,
304  QWidget *parent = 0 );
305  virtual ~KeyApprovalDialog() {}
306 
307  QVector<KeyIDList> keys() const { return mKeys; }
308 
309  bool preferencesChanged() const { return mPrefsChanged; }
310 
311  protected Q_SLOTS:
312  void slotPrefsChanged( int ) { mPrefsChanged = true; }
313  void slotChangeEncryptionKey( int );
314  virtual void slotOk();
315  virtual void slotCancel();
316 
317  private:
318  QVector<KeyIDList> mKeys;
319  int mAllowedKeys;
320  int mEncryptToSelf;
321  bool mPrefsChanged;
322  QVector<QLabel*> mAddressLabels;
323  QVector<QLabel*> mKeyIdsLabels;
324  //QPtrVector<QListBox> mKeyIdListBoxes;
325  QVector<QComboBox*> mEncrPrefCombos;
326 };
327 
328 
329 // -------------------------------------------------------------------------
330 class KPGP_EXPORT CipherTextDialog: public KDialog
331 {
332  Q_OBJECT
333 
334  public:
335  explicit CipherTextDialog( const QByteArray &text,
336  const QByteArray &charset=0,
337  QWidget *parent=0 );
338  virtual ~CipherTextDialog() {}
339 
340  private:
341  void setMinimumSize();
342  QTextEdit *mEditBox;
343 };
344 
345 } // namespace Kpgp
346 
347 #endif
Kpgp::AllKeys
Definition: kpgp.h:60
QWidget
Kpgp::Config::storePass
QCheckBox * storePass
Definition: kpgpui.h:93
Kpgp::KeyRequester::mEraseButton
QPushButton * mEraseButton
Definition: kpgpui.h:233
Kpgp::KeySelectionDialog::rememberSelection
virtual bool rememberSelection() const
Definition: kpgpui.h:135
Kpgp::PassphraseDialog
the passphrase dialog
Definition: kpgpui.h:59
QByteArray
Kpgp::KeyApprovalDialog
Definition: kpgpui.h:296
Kpgp::PublicKeys
Definition: kpgp.h:54
Kpgp::KeyRequester::dialogButton
QPushButton * dialogButton() const
Definition: kpgpui.h:216
Kpgp::KeyApprovalDialog::~KeyApprovalDialog
virtual ~KeyApprovalDialog()
Definition: kpgpui.h:305
Kpgp::KeyApprovalDialog::slotPrefsChanged
void slotPrefsChanged(int)
Definition: kpgpui.h:312
Kpgp::KeyRequester::eraseButton
QPushButton * eraseButton() const
Definition: kpgpui.h:215
Kpgp::PublicKeyRequester
Definition: kpgpui.h:255
Kpgp::KeyRequester::mDialogButton
QPushButton * mDialogButton
Definition: kpgpui.h:234
Kpgp::KeyRequester
Definition: kpgpui.h:203
QPoint
KDialog
Kpgp::KeyApprovalDialog::preferencesChanged
bool preferencesChanged() const
Definition: kpgpui.h:309
Kpgp::KeySelectionDialog::keys
virtual KeyIDList keys() const
Returns a list of selected key IDs.
Definition: kpgpui.h:132
QRegExp
QTreeWidget
Kpgp::Module
Definition: kpgp.h:75
QGroupBox
QTimer
Kpgp::SecretKeys
Definition: kpgp.h:55
Kpgp::Config::encToSelf
QCheckBox * encToSelf
Definition: kpgpui.h:94
QCheckBox
Kpgp::KeyRequester::mAllowedKeys
int mAllowedKeys
Definition: kpgpui.h:237
Kpgp::KeyRequester::mLabel
QLabel * mLabel
Definition: kpgpui.h:232
QString
QList
Kpgp::KeyIDList
Definition: kpgpkey.h:57
Kpgp::CipherTextDialog
Definition: kpgpui.h:330
QStringList
QPixmap
Kpgp::SecretKeyRequester
Definition: kpgpui.h:275
Kpgp::Config::mpOptionsGroupBox
QGroupBox * mpOptionsGroupBox
Definition: kpgpui.h:98
Kpgp::Config::toolCombo
QComboBox * toolCombo
Definition: kpgpui.h:97
Kpgp::KeyApprovalDialog::keys
QVector< KeyIDList > keys() const
Definition: kpgpui.h:307
Kpgp::KeyRequester::mDialogMessage
QString mDialogMessage
Definition: kpgpui.h:235
libkpgp_export.h
KeySelectionDialogSuper
kpgpkey.h
KPasswordDialog
Kpgp::Config
A widget for configuring the pgp interface.
Definition: kpgpui.h:77
QVector
QTreeWidgetItem
Kpgp::CipherTextDialog::~CipherTextDialog
virtual ~CipherTextDialog()
Definition: kpgpui.h:338
Kpgp::Config::optionsGroupBox
QGroupBox * optionsGroupBox()
Definition: kpgpui.h:87
Kpgp::Key
This class is used to store information about a PGP key.
Definition: kpgpkey.h:506
Kpgp::Config::pgp
Module * pgp
Definition: kpgpui.h:92
QPushButton
Kpgp::KeySelectionDialog
Definition: kpgpui.h:105
Kpgp::KeyRequester::mMulti
bool mMulti
Definition: kpgpui.h:236
Kpgp::Config::showCipherText
QCheckBox * showCipherText
Definition: kpgpui.h:95
kpgp.h
Kpgp::Config::showKeyApprovalDlg
QCheckBox * showKeyApprovalDlg
Definition: kpgpui.h:96
QLabel
QTextEdit
KPGP_EXPORT
#define KPGP_EXPORT
Definition: libkpgp_export.h:35
Kpgp::KeyRequester::mKeys
KeyIDList mKeys
Definition: kpgpui.h:238
QComboBox
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:32:22 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

libkpgp

Skip menu "libkpgp"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal