QCA

certitem.h
1/*
2 Copyright (C) 2007 Justin Karneges <justin@affinix.com>
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
28class QString;
29class QStringList;
30
31namespace QCA {
32class PrivateKey;
33class CertificateChain;
34class KeyStoreEntry;
35}
36
37class CertItemStore;
38class CertItemStorePrivate;
39class CertItemPrivateLoaderPrivate;
40
41class CertItem
42{
43public:
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
61private:
62 class Private;
64
65 friend class CertItemStore;
66 friend class CertItemStorePrivate;
67 friend class CertItemPrivateLoader;
68 friend class CertItemPrivateLoaderPrivate;
69};
70
71class CertItemStore : public QAbstractListModel
72{
74public:
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
115 void addSuccess(int reqId, int id);
116 void addFailed(int reqId);
117
118private:
119 friend class CertItemStorePrivate;
120 CertItemStorePrivate *d;
121
122 friend class CertItemPrivateLoader;
123 friend class CertItemPrivateLoaderPrivate;
124};
125
126class CertItemPrivateLoader : public QObject
127{
129public:
130 explicit CertItemPrivateLoader(CertItemStore *store, QObject *parent = nullptr);
131 ~CertItemPrivateLoader();
132
133 void start(int id);
134
135 QCA::PrivateKey privateKey() const;
136
138 void finished();
139
140private:
141 friend class CertItemPrivateLoaderPrivate;
142 CertItemPrivateLoaderPrivate *d;
143};
144
145#endif
A chain of related Certificates.
Definition qca_cert.h:1226
Single entry in a KeyStore.
Generic private key.
Q_SCRIPTABLE Q_NOREPLY void start()
QCA - the Qt Cryptographic Architecture.
Definition qca_basic.h:41
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const override
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
QObject * parent() const const
typedef ItemFlags
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 24 2024 11:53:51 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.