File indexing completed on 2025-01-12 04:19:46
0001 /* 0002 * Copyright (C) 2003-2008 Justin Karneges <justin@affinix.com> 0003 * 0004 * This library is free software; you can redistribute it and/or 0005 * modify it under the terms of the GNU Lesser General Public 0006 * License as published by the Free Software Foundation; either 0007 * version 2.1 of the License, or (at your option) any later version. 0008 * 0009 * This library is distributed in the hope that it will be useful, 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 * Lesser General Public License for more details. 0013 * 0014 * You should have received a copy of the GNU Lesser General Public 0015 * License along with this library; if not, write to the Free Software 0016 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 0017 */ 0018 0019 #pragma once 0020 0021 #include "gpgop.h" 0022 #include "mykeystoreentry.h" 0023 #include "qcaprovider.h" 0024 #include "ringwatch.h" 0025 #include <QMutex> 0026 0027 namespace gpgQCAPlugin { 0028 0029 class MyKeyStoreList : public QCA::KeyStoreListContext 0030 { 0031 Q_OBJECT 0032 public: 0033 int init_step; 0034 bool initialized; 0035 GpgOp gpg; 0036 GpgOp::KeyList pubkeys, seckeys; 0037 QString pubring, secring, homeDir; 0038 bool pubdirty, secdirty; 0039 RingWatch ringWatch; 0040 QMutex ringMutex; 0041 0042 MyKeyStoreList(QCA::Provider *p); 0043 ~MyKeyStoreList() override; 0044 0045 // reimplemented Provider::Context 0046 QCA::Provider::Context *clone() const override; 0047 0048 // reimplemented KeyStoreListContext 0049 QString name(int) const override; 0050 QCA::KeyStore::Type type(int) const override; 0051 QString storeId(int) const override; 0052 QList<int> keyStores() override; 0053 0054 void start() override; 0055 0056 bool isReadOnly(int) const override; 0057 0058 QList<QCA::KeyStoreEntry::Type> entryTypes(int) const override; 0059 QList<QCA::KeyStoreEntryContext *> entryList(int) override; 0060 QCA::KeyStoreEntryContext *entry(int, const QString &entryId) override; 0061 QCA::KeyStoreEntryContext *entryPassive(const QString &serialized) override; 0062 QString writeEntry(int, const QCA::PGPKey &key) override; 0063 bool removeEntry(int, const QString &entryId) override; 0064 0065 static MyKeyStoreList *instance(); 0066 void ext_keyStoreLog(const QString &str); 0067 0068 QCA::PGPKey getPubKey(const QString &keyId) const; 0069 QCA::PGPKey getSecKey(const QString &keyId, const QStringList &userIdsOverride) const; 0070 QCA::PGPKey publicKeyFromId(const QString &keyId); 0071 QCA::PGPKey secretKeyFromId(const QString &keyId); 0072 0073 private Q_SLOTS: 0074 void gpg_finished(); 0075 void ring_changed(const QString &filePath); 0076 0077 private: 0078 void pub_changed(); 0079 void sec_changed(); 0080 void handleDirtyRings(); 0081 }; 0082 0083 } // end namespace gpgQCAPlugin