1 | /* |
2 | * Copyright (C) 2003-2008 Justin Karneges <justin@affinix.com> |
3 | * |
4 | * This library is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU Lesser General Public |
6 | * License as published by the Free Software Foundation; either |
7 | * version 2.1 of the License, or (at your option) any later version. |
8 | * |
9 | * This library is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | * Lesser General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU Lesser General Public |
15 | * License along with this library; if not, write to the Free Software |
16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA |
17 | */ |
18 | |
19 | #pragma once |
20 | |
21 | #include "gpgop.h" |
22 | #include "mykeystoreentry.h" |
23 | #include "qcaprovider.h" |
24 | #include "ringwatch.h" |
25 | #include <QMutex> |
26 | |
27 | namespace gpgQCAPlugin { |
28 | |
29 | class MyKeyStoreList : public QCA::KeyStoreListContext |
30 | { |
31 | Q_OBJECT |
32 | public: |
33 | int init_step; |
34 | bool initialized; |
35 | GpgOp gpg; |
36 | GpgOp::KeyList pubkeys, seckeys; |
37 | QString pubring, secring, homeDir; |
38 | bool pubdirty, secdirty; |
39 | RingWatch ringWatch; |
40 | QMutex ringMutex; |
41 | |
42 | MyKeyStoreList(QCA::Provider *p); |
43 | ~MyKeyStoreList() override; |
44 | |
45 | // reimplemented Provider::Context |
46 | QCA::Provider::Context *clone() const override; |
47 | |
48 | // reimplemented KeyStoreListContext |
49 | QString name(int) const override; |
50 | QCA::KeyStore::Type type(int) const override; |
51 | QString storeId(int) const override; |
52 | QList<int> keyStores() override; |
53 | |
54 | void start() override; |
55 | |
56 | bool isReadOnly(int) const override; |
57 | |
58 | QList<QCA::KeyStoreEntry::Type> entryTypes(int) const override; |
59 | QList<QCA::KeyStoreEntryContext *> entryList(int) override; |
60 | QCA::KeyStoreEntryContext *entry(int, const QString &entryId) override; |
61 | QCA::KeyStoreEntryContext *entryPassive(const QString &serialized) override; |
62 | QString writeEntry(int, const QCA::PGPKey &key) override; |
63 | bool removeEntry(int, const QString &entryId) override; |
64 | |
65 | static MyKeyStoreList *instance(); |
66 | void ext_keyStoreLog(const QString &str); |
67 | |
68 | QCA::PGPKey getPubKey(const QString &keyId) const; |
69 | QCA::PGPKey getSecKey(const QString &keyId, const QStringList &userIdsOverride) const; |
70 | QCA::PGPKey publicKeyFromId(const QString &keyId); |
71 | QCA::PGPKey secretKeyFromId(const QString &keyId); |
72 | |
73 | private Q_SLOTS: |
74 | void gpg_finished(); |
75 | void ring_changed(const QString &filePath); |
76 | |
77 | private: |
78 | void pub_changed(); |
79 | void sec_changed(); |
80 | void handleDirtyRings(); |
81 | }; |
82 | |
83 | } // end namespace gpgQCAPlugin |
84 | |