QCA

certitem.h
1 /*
2  Copyright (C) 2007 Justin Karneges <[email protected]>
3 
4  Permission is hereby granted, free of charge, to any person obtaining a copy
5  of this software and associated documentation files (the "Software"), to deal
6  in the Software without restriction, including without limitation the rights
7  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  copies of the Software, and to permit persons to whom the Software is
9  furnished to do so, subject to the following conditions:
10 
11  The above copyright notice and this permission notice shall be included in
12  all copies or substantial portions of the Software.
13 
14  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18  AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 */
21 
22 #ifndef CERTITEM_H
23 #define CERTITEM_H
24 
25 #include <QAbstractListModel>
26 #include <QSharedDataPointer>
27 
28 class QString;
29 class QStringList;
30 
31 namespace QCA {
32 class PrivateKey;
33 class CertificateChain;
34 class KeyStoreEntry;
35 }
36 
37 class CertItemStore;
38 class CertItemStorePrivate;
39 class CertItemPrivateLoaderPrivate;
40 
41 class CertItem
42 {
43 public:
44  enum StorageType
45  {
46  File,
47  KeyStore
48  };
49 
50  CertItem();
51  CertItem(const CertItem &from);
52  ~CertItem();
53  CertItem &operator=(const CertItem &from);
54 
55  QString name() const;
56  QCA::CertificateChain certificateChain() const;
57  bool havePrivate() const;
58  StorageType storageType() const; // private key storage type
59  bool isUsable() const; // file/provider present
60 
61 private:
62  class Private;
64 
65  friend class CertItemStore;
66  friend class CertItemStorePrivate;
67  friend class CertItemPrivateLoader;
68  friend class CertItemPrivateLoaderPrivate;
69 };
70 
71 class CertItemStore : public QAbstractListModel
72 {
73  Q_OBJECT
74 public:
75  enum IconType
76  {
77  IconCert,
78  IconCrl,
79  IconKeyBundle,
80  IconPgpPub,
81  IconPgpSec
82  };
83 
84  CertItemStore(QObject *parent = nullptr);
85  ~CertItemStore();
86 
87  int idFromRow(int row) const;
88  int rowFromId(int id) const;
89  CertItem itemFromId(int id) const;
90  CertItem itemFromRow(int row) const;
91 
92  QList<CertItem> items() const;
93 
94  QStringList save() const;
95  bool load(const QStringList &in);
96 
97  // returns a reqId
98  int addFromFile(const QString &fileName);
99  int addFromKeyStore(const QCA::KeyStoreEntry &entry);
100  int addUser(const QCA::CertificateChain &chain);
101 
102  void updateChain(int id, const QCA::CertificateChain &chain);
103 
104  void removeItem(int id);
105 
106  void setIcon(IconType type, const QPixmap &icon);
107 
108  // reimplemented
109  int rowCount(const QModelIndex &parent = QModelIndex()) const;
110  QVariant data(const QModelIndex &index, int role) const;
111  Qt::ItemFlags flags(const QModelIndex &index) const;
112  bool setData(const QModelIndex &index, const QVariant &value, int role);
113 
114 Q_SIGNALS:
115  void addSuccess(int reqId, int id);
116  void addFailed(int reqId);
117 
118 private:
119  friend class CertItemStorePrivate;
120  CertItemStorePrivate *d;
121 
122  friend class CertItemPrivateLoader;
123  friend class CertItemPrivateLoaderPrivate;
124 };
125 
126 class CertItemPrivateLoader : public QObject
127 {
128  Q_OBJECT
129 public:
130  explicit CertItemPrivateLoader(CertItemStore *store, QObject *parent = nullptr);
131  ~CertItemPrivateLoader();
132 
133  void start(int id);
134 
135  QCA::PrivateKey privateKey() const;
136 
137 Q_SIGNALS:
138  void finished();
139 
140 private:
141  friend class CertItemPrivateLoaderPrivate;
142  CertItemPrivateLoaderPrivate *d;
143 };
144 
145 #endif
QString name(const QVariant &location)
Generic private key.
QAction * load(const QObject *recvr, const char *slot, QObject *parent)
const QList< QKeySequence > & save()
QCA - the Qt Cryptographic Architecture.
Definition: qca_basic.h:41
Single entry in a KeyStore.
Definition: qca_keystore.h:140
A chain of related Certificates.
Definition: qca_cert.h:1225
typedef ItemFlags
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Sep 25 2021 23:05:35 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.