aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/function/gpg/GpgKeyGetter.h
diff options
context:
space:
mode:
authorSaturneric <[email protected]>2022-05-09 14:40:54 +0000
committerSaturneric <[email protected]>2022-05-09 14:40:54 +0000
commit670733f7a90d337d546afab22ddedeedec6d3d67 (patch)
tree2c64c0667d2cac45040257802c40963f89737700 /src/core/function/gpg/GpgKeyGetter.h
parentdoc: add entry to developer document. (diff)
downloadGpgFrontend-670733f7a90d337d546afab22ddedeedec6d3d67.tar.gz
GpgFrontend-670733f7a90d337d546afab22ddedeedec6d3d67.zip
fix: fix crash poblem when doing operations
1. refactor GpgFunctionObject to solve shared library problem. 2. fix multi-threading issues in refreshing. 3. improve loading speed for key list 4. improve ui operation 5. do other fixing and improving operations
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