12#include "kleo_export.h"
16#include <gpgme++/global.h>
25class DecryptionResult;
26class VerificationResult;
35class FileSystemWatcher;
39class KeyCacheAutoRefreshSuspension;
41struct CardKeyStorageInfo {
47class KLEO_EXPORT KeyCache :
public QObject
68 static std::shared_ptr<const KeyCache> instance();
69 static std::shared_ptr<KeyCache> mutableInstance();
73 void setGroupsEnabled(
bool enabled);
74 void setGroupConfig(
const std::shared_ptr<KeyGroupConfig> &groupConfig);
76 void insert(
const GpgME::Key &key);
77 void insert(
const std::vector<GpgME::Key> &keys);
78 bool insert(
const KeyGroup &group);
80 void refresh(
const std::vector<GpgME::Key> &keys);
81 bool update(
const KeyGroup &group);
83 void remove(
const GpgME::Key &key);
84 void remove(
const std::vector<GpgME::Key> &keys);
85 bool remove(
const KeyGroup &group);
87 void addFileSystemWatcher(
const std::shared_ptr<FileSystemWatcher> &watcher);
89 void enableFileSystemWatcher(
bool enable);
91 void setRefreshInterval(
int hours);
92 int refreshInterval()
const;
94 std::shared_ptr<KeyCacheAutoRefreshSuspension> suspendAutoRefresh();
96 void enableRemarks(
bool enable);
97 bool remarksEnabled()
const;
99 const std::vector<GpgME::Key> &keys()
const;
100 std::vector<GpgME::Key> secretKeys()
const;
102 KeyGroup group(
const QString &
id)
const;
103 std::vector<KeyGroup> groups()
const;
104 std::vector<KeyGroup> configurableGroups()
const;
105 void saveConfigurableGroups(
const std::vector<KeyGroup> &groups);
107 const GpgME::Key &findByFingerprint(
const char *fpr)
const;
108 const GpgME::Key &findByFingerprint(
const std::string &fpr)
const;
110 std::vector<GpgME::Key> findByFingerprint(
const std::vector<std::string> &fprs)
const;
112 std::vector<GpgME::Key> findByEMailAddress(
const char *email)
const;
113 std::vector<GpgME::Key> findByEMailAddress(
const std::string &email)
const;
124 GpgME::Key findBestByMailBox(
const char *addr, GpgME::Protocol proto, KeyUsage usage)
const;
143 KeyGroup findGroup(
const QString &name, GpgME::Protocol protocol, KeyUsage usage)
const;
145 const GpgME::Key &findByKeyIDOrFingerprint(
const char *
id)
const;
146 const GpgME::Key &findByKeyIDOrFingerprint(
const std::string &
id)
const;
148 std::vector<GpgME::Key> findByKeyIDOrFingerprint(
const std::vector<std::string> &ids)
const;
150 const GpgME::Subkey &findSubkeyByKeyGrip(
const char *grip, GpgME::Protocol protocol = GpgME::UnknownProtocol)
const;
151 const GpgME::Subkey &findSubkeyByKeyGrip(
const std::string &grip, GpgME::Protocol protocol = GpgME::UnknownProtocol)
const;
153 std::vector<GpgME::Subkey> findSubkeysByKeyGrip(
const char *grip, GpgME::Protocol protocol = GpgME::UnknownProtocol)
const;
154 std::vector<GpgME::Subkey> findSubkeysByKeyGrip(
const std::string &grip, GpgME::Protocol protocol = GpgME::UnknownProtocol)
const;
156 std::vector<GpgME::Subkey> findSubkeysByKeyID(
const std::vector<std::string> &ids)
const;
158 const GpgME::Subkey &findSubkeyByFingerprint(
const std::string &fpr)
const;
160 std::vector<GpgME::Key> findRecipients(
const GpgME::DecryptionResult &result)
const;
161 GpgME::Key findSigner(
const GpgME::Signature &signature)
const;
162 std::vector<GpgME::Key> findSigners(
const GpgME::VerificationResult &result)
const;
164 std::vector<GpgME::Key> findSigningKeysByMailbox(
const QString &mb)
const;
165 std::vector<GpgME::Key> findEncryptionKeysByMailbox(
const QString &mb)
const;
168 std::vector<CardKeyStorageInfo> cardsForSubkey(
const GpgME::Subkey &subkey)
const;
173 std::vector<GpgME::Key> getGroupKeys(
const QString &groupName)
const;
182 Q_DECLARE_FLAGS(Options, Option)
184 std::vector<GpgME::Key> findSubjects(
const GpgME::Key &key, Options option = RecursiveSearch)
const;
185 std::vector<GpgME::Key> findSubjects(
const std::vector<GpgME::Key> &keys, Options options = RecursiveSearch)
const;
187 std::vector<GpgME::Key> findIssuers(
const GpgME::Key &key, Options options = RecursiveSearch)
const;
190 bool initialized()
const;
193 bool pgpOnly()
const;
196 void setKeys(
const std::vector<GpgME::Key> &keys);
198 void setGroups(
const std::vector<KeyGroup> &groups);
202 void startKeyListing(GpgME::Protocol proto = GpgME::UnknownProtocol)
206 void reload(GpgME::Protocol proto = GpgME::UnknownProtocol, ReloadOption option = Reload);
207 void cancelKeyListing();
210 void keyListingDone(
const GpgME::KeyListResult &result);
211 void keysMayHaveChanged();
212 void groupAdded(
const Kleo::KeyGroup &group);
213 void groupUpdated(
const Kleo::KeyGroup &group);
214 void groupRemoved(
const Kleo::KeyGroup &group);
217 class RefreshKeysJob;
223Q_DECLARE_OPERATORS_FOR_FLAGS(KeyCache::Options)
bool insert(Part *part, qint64 *insertId=nullptr)
void update(Part *part, const QByteArray &data, qint64 dataSize)
bool remove(const QString &column, const QVariant &value)
const QList< QKeySequence > & reload()