aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/function/gpg/GpgKeyGetter.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/function/gpg/GpgKeyGetter.h')
-rw-r--r--src/core/function/gpg/GpgKeyGetter.h74
1 files changed, 21 insertions, 53 deletions
diff --git a/src/core/function/gpg/GpgKeyGetter.h b/src/core/function/gpg/GpgKeyGetter.h
index c96dbea7..91138623 100644
--- a/src/core/function/gpg/GpgKeyGetter.h
+++ b/src/core/function/gpg/GpgKeyGetter.h
@@ -1,5 +1,5 @@
/**
- * Copyright (C) 2021 Saturneric
+ * Copyright (C) 2021 Saturneric <[email protected]>
*
* This file is part of GpgFrontend.
*
@@ -20,21 +20,16 @@
* the gpg4usb project, which is under GPL-3.0-or-later.
*
* All the source code of GpgFrontend was modified and released by
- * Saturneric<[email protected]> starting on May 12, 2021.
+ * Saturneric <[email protected]> starting on May 12, 2021.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*
*/
-#ifndef GPGFRONTEND_ZH_CN_TS_GPGKEYGETTER_H
-#define GPGFRONTEND_ZH_CN_TS_GPGKEYGETTER_H
+#pragma once
-#include <mutex>
-#include <vector>
-
-#include "core/GpgContext.h"
-#include "core/GpgFunctionObject.h"
-#include "core/GpgModel.h"
+#include "core/function/basic/GpgFunctionObject.h"
+#include "core/typedef/GpgTypedef.h"
namespace GpgFrontend {
@@ -50,8 +45,13 @@ class GPGFRONTEND_CORE_EXPORT GpgKeyGetter
*
* @param channel
*/
- explicit GpgKeyGetter(
- int channel = SingletonFunctionObject::GetDefaultChannel());
+ explicit GpgKeyGetter(int channel = kGpgFrontendDefaultChannel);
+
+ /**
+ * @brief Destroy the Gpg Key Getter object
+ *
+ */
+ ~GpgKeyGetter();
/**
* @brief Get the Key object
@@ -59,7 +59,7 @@ class GPGFRONTEND_CORE_EXPORT GpgKeyGetter
* @param fpr
* @return GpgKey
*/
- GpgKey GetKey(const std::string& id, bool use_cache = true);
+ auto GetKey(const QString& key_id, bool use_cache = true) -> GpgKey;
/**
* @brief Get the Keys object
@@ -67,7 +67,7 @@ class GPGFRONTEND_CORE_EXPORT GpgKeyGetter
* @param ids
* @return KeyListPtr
*/
- KeyListPtr GetKeys(const KeyIdArgsListPtr& ids);
+ auto GetKeys(const KeyIdArgsListPtr& key_ids) -> KeyListPtr;
/**
* @brief Get the Pubkey object
@@ -75,20 +75,20 @@ class GPGFRONTEND_CORE_EXPORT GpgKeyGetter
* @param fpr
* @return GpgKey
*/
- GpgKey GetPubkey(const std::string& id, bool use_cache = true);
+ auto GetPubkey(const QString& key_id, bool use_cache = true) -> GpgKey;
/**
* @brief Get all the keys by receiving a linked list
*
* @return KeyLinkListPtr
*/
- KeyLinkListPtr FetchKey();
+ auto FetchKey() -> KeyLinkListPtr;
/**
* @brief flush the keys in the cache
*
*/
- void FlushKeyCache();
+ auto FlushKeyCache() -> bool;
/**
* @brief Get the Keys Copy object
@@ -96,7 +96,7 @@ class GPGFRONTEND_CORE_EXPORT GpgKeyGetter
* @param keys
* @return KeyListPtr
*/
- KeyListPtr GetKeysCopy(const KeyListPtr& keys);
+ auto GetKeysCopy(const KeyListPtr& keys) -> KeyListPtr;
/**
* @brief Get the Keys Copy object
@@ -104,42 +104,10 @@ class GPGFRONTEND_CORE_EXPORT GpgKeyGetter
* @param keys
* @return KeyLinkListPtr
*/
- KeyLinkListPtr GetKeysCopy(const KeyLinkListPtr& keys);
+ auto GetKeysCopy(const KeyLinkListPtr& keys) -> KeyLinkListPtr;
private:
- /**
- * @brief Get the gpgme context object
- *
- */
- GpgContext& ctx_ =
- GpgContext::GetInstance(SingletonFunctionObject::GetChannel());
-
- /**
- * @brief shared mutex for the keys cache
- *
- */
- mutable std::mutex ctx_mutex_;
-
- /**
- * @brief cache the keys with key id
- *
- */
- std::map<std::string, GpgKey> keys_cache_;
-
- /**
- * @brief shared mutex for the keys cache
- *
- */
- mutable std::mutex keys_cache_mutex_;
-
- /**
- * @brief Get the Key object
- *
- * @param id
- * @return GpgKey
- */
- GpgKey get_key_in_cache(const std::string& id);
+ class Impl;
+ SecureUniquePtr<Impl> p_;
};
} // namespace GpgFrontend
-
-#endif // GPGFRONTEND_ZH_CN_TS_GPGKEYGETTER_H