aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/function/gpg/GpgKeyGetter.h
diff options
context:
space:
mode:
authorSaturn&Eric <[email protected]>2022-05-09 15:58:36 +0000
committerGitHub <[email protected]>2022-05-09 15:58:36 +0000
commita1bef0cc06a5c128a0f868ab59d7c153f5ab8aec (patch)
treef55b3c76f4203590b4bf40b6ab2f97965f5a51ec /src/core/function/gpg/GpgKeyGetter.h
parentMerge pull request #56 from saturneric/develop-2.0.6 (diff)
parentfix: modified init order (diff)
downloadGpgFrontend-a1bef0cc06a5c128a0f868ab59d7c153f5ab8aec.tar.gz
GpgFrontend-a1bef0cc06a5c128a0f868ab59d7c153f5ab8aec.zip
Merge pull request #57 from saturneric/develop-2.0.7v2.0.7
Develop 2.0.7
Diffstat (limited to 'src/core/function/gpg/GpgKeyGetter.h')
-rw-r--r--src/core/function/gpg/GpgKeyGetter.h37
1 files changed, 32 insertions, 5 deletions
diff --git a/src/core/function/gpg/GpgKeyGetter.h b/src/core/function/gpg/GpgKeyGetter.h
index d63238f5..72cd777c 100644
--- a/src/core/function/gpg/GpgKeyGetter.h
+++ b/src/core/function/gpg/GpgKeyGetter.h
@@ -29,6 +29,9 @@
#ifndef GPGFRONTEND_ZH_CN_TS_GPGKEYGETTER_H
#define GPGFRONTEND_ZH_CN_TS_GPGKEYGETTER_H
+#include <mutex>
+#include <vector>
+
#include "core/GpgContext.h"
#include "core/GpgFunctionObject.h"
#include "core/GpgModel.h"
@@ -56,7 +59,7 @@ class GPGFRONTEND_CORE_EXPORT GpgKeyGetter
* @param fpr
* @return GpgKey
*/
- GpgKey GetKey(const std::string& fpr);
+ GpgKey GetKey(const std::string& id);
/**
* @brief Get the Keys object
@@ -72,22 +75,28 @@ class GPGFRONTEND_CORE_EXPORT GpgKeyGetter
* @param fpr
* @return GpgKey
*/
- GpgKey GetPubkey(const std::string& fpr);
+ GpgKey GetPubkey(const std::string& id);
/**
- * @brief
+ * @brief Get all the keys by receiving a linked list
*
* @return KeyLinkListPtr
*/
KeyLinkListPtr FetchKey();
/**
+ * @brief flush the keys in the cache
+ *
+ */
+ void FlushKeyCache();
+
+ /**
* @brief Get the Keys Copy object
*
* @param keys
* @return KeyListPtr
*/
- static KeyListPtr GetKeysCopy(const KeyListPtr& keys);
+ KeyListPtr GetKeysCopy(const KeyListPtr& keys);
/**
* @brief Get the Keys Copy object
@@ -95,7 +104,7 @@ class GPGFRONTEND_CORE_EXPORT GpgKeyGetter
* @param keys
* @return KeyLinkListPtr
*/
- static KeyLinkListPtr GetKeysCopy(const KeyLinkListPtr& keys);
+ KeyLinkListPtr GetKeysCopy(const KeyLinkListPtr& keys);
private:
/**
@@ -104,6 +113,24 @@ class GPGFRONTEND_CORE_EXPORT GpgKeyGetter
*/
GpgContext& ctx_ =
GpgContext::GetInstance(SingletonFunctionObject::GetChannel());
+
+ /**
+ * @brief shared mutex for the keys cache
+ *
+ */
+ mutable std::mutex ctx_mutex_;
+
+ /**
+ * @brief cache the keys with key fpr
+ *
+ */
+ std::map<std::string, GpgKey> keys_cache_;
+
+ /**
+ * @brief shared mutex for the keys cache
+ *
+ */
+ mutable std::mutex keys_cache_mutex_;
};
} // namespace GpgFrontend