qca
certitem.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef CERTITEM_H
00023 #define CERTITEM_H
00024
00025 #include <QAbstractListModel>
00026 #include <QSharedDataPointer>
00027
00028 class QString;
00029 class QStringList;
00030
00031 namespace QCA
00032 {
00033 class PrivateKey;
00034 class CertificateChain;
00035 class KeyStoreEntry;
00036 }
00037
00038 class CertItemStore;
00039 class CertItemStorePrivate;
00040 class CertItemPrivateLoaderPrivate;
00041
00042 class CertItem
00043 {
00044 public:
00045 enum StorageType
00046 {
00047 File,
00048 KeyStore
00049 };
00050
00051 CertItem();
00052 CertItem(const CertItem &from);
00053 ~CertItem();
00054 CertItem & operator=(const CertItem &from);
00055
00056 QString name() const;
00057 QCA::CertificateChain certificateChain() const;
00058 bool havePrivate() const;
00059 StorageType storageType() const;
00060 bool isUsable() const;
00061
00062 private:
00063 class Private;
00064 QSharedDataPointer<Private> d;
00065
00066 friend class CertItemStore;
00067 friend class CertItemStorePrivate;
00068 friend class CertItemPrivateLoader;
00069 friend class CertItemPrivateLoaderPrivate;
00070 };
00071
00072 class CertItemStore : public QAbstractListModel
00073 {
00074 Q_OBJECT
00075 public:
00076 enum IconType
00077 {
00078 IconCert,
00079 IconCrl,
00080 IconKeyBundle,
00081 IconPgpPub,
00082 IconPgpSec
00083 };
00084
00085 CertItemStore(QObject *parent = 0);
00086 ~CertItemStore();
00087
00088 int idFromRow(int row) const;
00089 int rowFromId(int id) const;
00090 CertItem itemFromId(int id) const;
00091 CertItem itemFromRow(int row) const;
00092
00093 QList<CertItem> items() const;
00094
00095 QStringList save() const;
00096 bool load(const QStringList &in);
00097
00098
00099 int addFromFile(const QString &fileName);
00100 int addFromKeyStore(const QCA::KeyStoreEntry &entry);
00101 int addUser(const QCA::CertificateChain &chain);
00102
00103 void updateChain(int id, const QCA::CertificateChain &chain);
00104
00105 void removeItem(int id);
00106
00107 void setIcon(IconType type, const QPixmap &icon);
00108
00109
00110 int rowCount(const QModelIndex &parent = QModelIndex()) const;
00111 QVariant data(const QModelIndex &index, int role) const;
00112 Qt::ItemFlags flags(const QModelIndex &index) const;
00113 bool setData(const QModelIndex &index, const QVariant &value, int role);
00114
00115 signals:
00116 void addSuccess(int reqId, int id);
00117 void addFailed(int reqId);
00118
00119 private:
00120 friend class CertItemStorePrivate;
00121 CertItemStorePrivate *d;
00122
00123 friend class CertItemPrivateLoader;
00124 friend class CertItemPrivateLoaderPrivate;
00125 };
00126
00127 class CertItemPrivateLoader : public QObject
00128 {
00129 Q_OBJECT
00130 public:
00131 explicit CertItemPrivateLoader(CertItemStore *store, QObject *parent = 0);
00132 ~CertItemPrivateLoader();
00133
00134 void start(int id);
00135
00136 QCA::PrivateKey privateKey() const;
00137
00138 signals:
00139 void finished();
00140
00141 private:
00142 friend class CertItemPrivateLoaderPrivate;
00143 CertItemPrivateLoaderPrivate *d;
00144 };
00145
00146 #endif