12#include "kleo_export.h"
16#include <gpgme++/global.h>
25class DecryptionResult;
26class VerificationResult;
42class FileSystemWatcher;
46class KeyCacheAutoRefreshSuspension;
48class KLEO_EXPORT KeyCache :
public QObject
69 static std::shared_ptr<const KeyCache> instance();
70 static std::shared_ptr<KeyCache> mutableInstance();
74 void setGroupsEnabled(
bool enabled);
75 void setGroupConfig(
const std::shared_ptr<KeyGroupConfig> &groupConfig);
77 void insert(
const GpgME::Key &key);
78 void insert(
const std::vector<GpgME::Key> &keys);
79 bool insert(
const KeyGroup &group);
81 void refresh(
const std::vector<GpgME::Key> &keys);
82 bool update(
const KeyGroup &group);
84 void remove(
const GpgME::Key &key);
85 void remove(
const std::vector<GpgME::Key> &keys);
86 bool remove(
const KeyGroup &group);
88 void addFileSystemWatcher(
const std::shared_ptr<FileSystemWatcher> &watcher);
90 void enableFileSystemWatcher(
bool enable);
92 void setRefreshInterval(
int hours);
93 int refreshInterval()
const;
95 std::shared_ptr<KeyCacheAutoRefreshSuspension> suspendAutoRefresh();
97 void enableRemarks(
bool enable);
98 bool remarksEnabled()
const;
100 const std::vector<GpgME::Key> &keys()
const;
101 std::vector<GpgME::Key> secretKeys()
const;
103 KeyGroup group(
const QString &
id)
const;
104 std::vector<KeyGroup> groups()
const;
105 std::vector<KeyGroup> configurableGroups()
const;
106 void saveConfigurableGroups(
const std::vector<KeyGroup> &groups);
108 const GpgME::Key &findByFingerprint(
const char *fpr)
const;
109 const GpgME::Key &findByFingerprint(
const std::string &fpr)
const;
111 std::vector<GpgME::Key> findByFingerprint(
const std::vector<std::string> &fprs)
const;
113 std::vector<GpgME::Key> findByEMailAddress(
const char *email)
const;
114 std::vector<GpgME::Key> findByEMailAddress(
const std::string &email)
const;
125 GpgME::Key findBestByMailBox(
const char *addr, GpgME::Protocol proto, KeyUsage usage)
const;
144 KeyGroup findGroup(
const QString &name, GpgME::Protocol protocol, KeyUsage usage)
const;
146 const GpgME::Key &findByShortKeyID(
const char *
id)
const;
147 const GpgME::Key &findByShortKeyID(
const std::string &
id)
const;
149 const GpgME::Key &findByKeyIDOrFingerprint(
const char *
id)
const;
150 const GpgME::Key &findByKeyIDOrFingerprint(
const std::string &
id)
const;
152 std::vector<GpgME::Key> findByKeyIDOrFingerprint(
const std::vector<std::string> &ids)
const;
154 const GpgME::Subkey &findSubkeyByKeyGrip(
const char *grip, GpgME::Protocol protocol = GpgME::UnknownProtocol)
const;
155 const GpgME::Subkey &findSubkeyByKeyGrip(
const std::string &grip, GpgME::Protocol protocol = GpgME::UnknownProtocol)
const;
157 std::vector<GpgME::Subkey> findSubkeysByKeyID(
const std::vector<std::string> &ids)
const;
159 std::vector<GpgME::Key> findRecipients(
const GpgME::DecryptionResult &result)
const;
160 std::vector<GpgME::Key> findSigners(
const GpgME::VerificationResult &result)
const;
162 std::vector<GpgME::Key> findSigningKeysByMailbox(
const QString &mb)
const;
163 std::vector<GpgME::Key> findEncryptionKeysByMailbox(
const QString &mb)
const;
168 std::vector<GpgME::Key> getGroupKeys(
const QString &groupName)
const;
177 Q_DECLARE_FLAGS(Options, Option)
179 std::vector<GpgME::Key> findSubjects(
const GpgME::Key &key, Options option = RecursiveSearch)
const;
180 std::vector<GpgME::Key> findSubjects(
const std::vector<GpgME::Key> &keys, Options options = RecursiveSearch)
const;
182 std::vector<GpgME::Key> findIssuers(
const GpgME::Key &key, Options options = RecursiveSearch)
const;
185 bool initialized()
const;
188 bool pgpOnly()
const;
191 void setKeys(
const std::vector<GpgME::Key> &keys);
193 void setGroups(
const std::vector<KeyGroup> &groups);
197 void startKeyListing(GpgME::Protocol proto = GpgME::UnknownProtocol)
201 void reload(GpgME::Protocol proto = GpgME::UnknownProtocol, ReloadOption option = Reload);
202 void cancelKeyListing();
205 void keyListingDone(
const GpgME::KeyListResult &result);
206 void keysMayHaveChanged();
207 void groupAdded(
const Kleo::KeyGroup &group);
208 void groupUpdated(
const Kleo::KeyGroup &group);
209 void groupRemoved(
const Kleo::KeyGroup &group);
212 class RefreshKeysJob;
void update(Part *part, const QByteArray &data, qint64 dataSize)
const QList< QKeySequence > & reload()