33 #ifndef __KLEOPATRA_MODELS_KEYCACHE_H__
34 #define __KLEOPATRA_MODELS_KEYCACHE_H__
38 #include <kleo_export.h>
40 #include <gpgme++/global.h>
49 class DecryptionResult;
50 class VerificationResult;
66 class FileSystemWatcher;
74 static std::shared_ptr<const KeyCache> instance();
75 static std::shared_ptr<KeyCache> mutableInstance();
79 void insert(
const GpgME::Key &key);
80 void insert(
const std::vector<GpgME::Key> &keys);
82 void refresh(
const std::vector<GpgME::Key> &keys);
84 void remove(
const GpgME::Key &key);
85 void remove(
const std::vector<GpgME::Key> &keys);
87 void addFileSystemWatcher(
const std::shared_ptr<FileSystemWatcher> &watcher);
89 void enableFileSystemWatcher(
bool enable);
91 void setRefreshInterval(
int hours);
92 int refreshInterval()
const;
94 void enableRemarks(
bool enable);
95 bool remarksEnabled()
const;
97 const std::vector<GpgME::Key> &keys()
const;
98 std::vector<GpgME::Key> secretKeys()
const;
100 const GpgME::Key &findByFingerprint(
const char *fpr)
const;
101 const GpgME::Key &findByFingerprint(
const std::string &fpr)
const;
103 std::vector<GpgME::Key> findByEMailAddress(
const char *
email)
const;
104 std::vector<GpgME::Key> findByEMailAddress(
const std::string &email)
const;
120 std::vector<GpgME::Key> findBestByMailBox(
const char *addr, GpgME::Protocol proto,
121 bool needSign,
bool needEncrypt)
const;
123 const GpgME::Key &findByShortKeyID(
const char *
id)
const;
124 const GpgME::Key &findByShortKeyID(
const std::string &
id)
const;
126 const GpgME::Key &findByKeyIDOrFingerprint(
const char *
id)
const;
127 const GpgME::Key &findByKeyIDOrFingerprint(
const std::string &
id)
const;
129 std::vector<GpgME::Key> findByKeyIDOrFingerprint(
const std::vector<std::string> &ids)
const;
131 std::vector<GpgME::Subkey> findSubkeysByKeyID(
const std::vector<std::string> &ids)
const;
133 std::vector<GpgME::Key> findRecipients(
const GpgME::DecryptionResult &result)
const;
134 std::vector<GpgME::Key> findSigners(
const GpgME::VerificationResult &result)
const;
136 std::vector<GpgME::Key> findSigningKeysByMailbox(
const QString &mb)
const;
137 std::vector<GpgME::Key> findEncryptionKeysByMailbox(
const QString &mb)
const;
142 std::vector<GpgME::Key> getGroupKeys(
const QString &groupName)
const;
149 Q_DECLARE_FLAGS(Options, Option)
151 std::vector<GpgME::Key> findSubjects(const GpgME::Key &key, Options option = RecursiveSearch) const;
152 std::vector<GpgME::Key> findSubjects(const std::vector<GpgME::Key> &keys, Options options = RecursiveSearch) const;
153 std::vector<GpgME::Key> findSubjects(std::vector<GpgME::Key>::const_iterator first, std::vector<GpgME::Key>::const_iterator last, Options options = RecursiveSearch) const;
155 std::vector<GpgME::Key> findIssuers(const GpgME::Key &key, Options options = RecursiveSearch) const;
156 std::vector<GpgME::Key> findIssuers(const std::vector<GpgME::Key> &keys, Options options = RecursiveSearch) const;
157 std::vector<GpgME::Key> findIssuers(std::vector<GpgME::Key>::const_iterator first, std::vector<GpgME::Key>::const_iterator last, Options options = RecursiveSearch) const;
160 bool initialized() const;
163 bool pgpOnly() const;
167 void startKeyListing(GpgME::Protocol proto = GpgME::UnknownProtocol)
171 void reload(GpgME::Protocol proto = GpgME::UnknownProtocol);
172 void cancelKeyListing();
176 void aboutToRemove(
const GpgME::Key &key);
177 void added(
const GpgME::Key &key);
178 void keyListingDone(
const GpgME::KeyListResult &result);
179 void keysMayHaveChanged();
182 class RefreshKeysJob;
190 Q_DECLARE_OPERATORS_FOR_FLAGS(Kleo::KeyCache::Options)
static std::string email(const UserID &uid)