diff options
Diffstat (limited to 'src/core/function')
-rw-r--r-- | src/core/function/GlobalSettingStation.cpp | 8 | ||||
-rw-r--r-- | src/core/function/SecureMemoryAllocator.cpp | 7 | ||||
-rw-r--r-- | src/core/function/SecureMemoryAllocator.h | 6 | ||||
-rw-r--r-- | src/core/function/basic/ChannelObject.cpp | 11 | ||||
-rw-r--r-- | src/core/function/basic/ChannelObject.h | 3 | ||||
-rw-r--r-- | src/core/function/basic/GpgFunctionObject.h | 3 | ||||
-rw-r--r-- | src/core/function/gpg/GpgContext.cpp | 6 | ||||
-rw-r--r-- | src/core/function/gpg/GpgKeyImportExporter.h | 2 | ||||
-rw-r--r-- | src/core/function/gpg/GpgKeyManager.cpp | 5 |
9 files changed, 28 insertions, 23 deletions
diff --git a/src/core/function/GlobalSettingStation.cpp b/src/core/function/GlobalSettingStation.cpp index 5031effe..d1c1068e 100644 --- a/src/core/function/GlobalSettingStation.cpp +++ b/src/core/function/GlobalSettingStation.cpp @@ -28,7 +28,8 @@ #include "GlobalSettingStation.h" -#include <qcoreapplication.h> +#include <boost/dll.hpp> +#include <filesystem> #include "core/utils/FilesystemUtils.h" #include "core/utils/IOUtils.h" @@ -216,8 +217,9 @@ class GlobalSettingStation::Impl } private: - std::filesystem::path app_path_ = QCoreApplication::applicationDirPath() - .toStdString(); ///< Program Location + std::filesystem::path app_path_ = + std::filesystem::path(boost::dll::program_location().string()) + .parent_path(); std::filesystem::path app_data_path_ = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) diff --git a/src/core/function/SecureMemoryAllocator.cpp b/src/core/function/SecureMemoryAllocator.cpp index b9201942..2c584753 100644 --- a/src/core/function/SecureMemoryAllocator.cpp +++ b/src/core/function/SecureMemoryAllocator.cpp @@ -48,9 +48,6 @@ auto SecureMemoryAllocator::Reallocate(void* ptr, std::size_t size) -> void* { return addr; } -void SecureMemoryAllocator::Deallocate(void* p) { - SPDLOG_TRACE("secure memory allocator trys to free memory, address: {}", - static_cast<void*>(p)); - mi_free(p); -} +void SecureMemoryAllocator::Deallocate(void* p) { mi_free(p); } + } // namespace GpgFrontend
\ No newline at end of file diff --git a/src/core/function/SecureMemoryAllocator.h b/src/core/function/SecureMemoryAllocator.h index b938429e..e9f1c1c3 100644 --- a/src/core/function/SecureMemoryAllocator.h +++ b/src/core/function/SecureMemoryAllocator.h @@ -31,6 +31,8 @@ #include <cstdint> #include <memory> +#include "core/utils/LogUtils.h" + namespace GpgFrontend { class GPGFRONTEND_CORE_EXPORT SecureMemoryAllocator { @@ -46,10 +48,6 @@ template <typename T> struct SecureObjectDeleter { void operator()(T *ptr) { if (ptr) { - SPDLOG_TRACE( - "secure object deleter trys to deconstruct and free object, " - "type: {}, addr: {}", - typeid(T).name(), static_cast<void *>(ptr)); ptr->~T(); SecureMemoryAllocator::Deallocate(ptr); } diff --git a/src/core/function/basic/ChannelObject.cpp b/src/core/function/basic/ChannelObject.cpp index 7a41d4d1..3f040ca6 100644 --- a/src/core/function/basic/ChannelObject.cpp +++ b/src/core/function/basic/ChannelObject.cpp @@ -28,13 +28,20 @@ #include "ChannelObject.h" +#include <ostream> +#include <utility> +#include <iostream> + namespace GpgFrontend { ChannelObject::ChannelObject() noexcept = default; -ChannelObject::ChannelObject(int channel) : channel_(channel) {} +ChannelObject::ChannelObject(int channel, std::string type) + : channel_(channel), type_(std::move(type)) {} -ChannelObject::~ChannelObject() noexcept = default; +ChannelObject::~ChannelObject() noexcept { + std::cout << "deleting channel object: " << type_ << std::endl; +} void ChannelObject::SetChannel(int channel) { this->channel_ = channel; } diff --git a/src/core/function/basic/ChannelObject.h b/src/core/function/basic/ChannelObject.h index 6fb315ae..18317ee2 100644 --- a/src/core/function/basic/ChannelObject.h +++ b/src/core/function/basic/ChannelObject.h @@ -55,7 +55,7 @@ class GPGFRONTEND_CORE_EXPORT ChannelObject { * * @param channel */ - explicit ChannelObject(int channel); + explicit ChannelObject(int channel, std::string type); /** * @brief Get the Default Channel object @@ -80,6 +80,7 @@ class GPGFRONTEND_CORE_EXPORT ChannelObject { private: int channel_ = kGpgFrontendDefaultChannel; ///< The channel id + std::string type_; }; template <typename Derived> diff --git a/src/core/function/basic/GpgFunctionObject.h b/src/core/function/basic/GpgFunctionObject.h index dd06608d..afe81131 100644 --- a/src/core/function/basic/GpgFunctionObject.h +++ b/src/core/function/basic/GpgFunctionObject.h @@ -216,7 +216,8 @@ class SingletonFunctionObject : public ChannelObject { * * @param channel */ - explicit SingletonFunctionObject(int channel) : ChannelObject(channel) {} + explicit SingletonFunctionObject(int channel) + : ChannelObject(channel, typeid(T).name()) {} /** * @brief Destroy the Singleton Function Object object diff --git a/src/core/function/gpg/GpgContext.cpp b/src/core/function/gpg/GpgContext.cpp index 0477b00a..443c139b 100644 --- a/src/core/function/gpg/GpgContext.cpp +++ b/src/core/function/gpg/GpgContext.cpp @@ -32,12 +32,12 @@ #include <gpgme.h> #include <cassert> +#include <mutex> #include "core/function/CoreSignalStation.h" #include "core/function/basic/GpgFunctionObject.h" #include "core/module/ModuleManager.h" #include "core/utils/GpgUtils.h" -#include "spdlog/spdlog.h" #include "utils/MemoryUtils.h" #ifdef _WIN32 @@ -158,6 +158,8 @@ class GpgContext::Impl : public SingletonFunctionObject<GpgContext::Impl> { gpgme_ctx_t ctx_ref_ = nullptr; ///< gpgme_ctx_t binary_ctx_ref_ = nullptr; ///< bool good_ = true; + std::mutex ctx_ref_lock_; + std::mutex binary_ctx_ref_lock_; static auto set_ctx_key_list_mode(const gpgme_ctx_t &ctx) -> bool { assert(ctx != nullptr); @@ -205,6 +207,8 @@ class GpgContext::Impl : public SingletonFunctionObject<GpgContext::Impl> { assert(CheckGpgError(err) == GPG_ERR_NO_ERROR); return CheckGpgError(err) == GPG_ERR_NO_ERROR; + + return true; } auto common_ctx_initialize(const gpgme_ctx_t &ctx, diff --git a/src/core/function/gpg/GpgKeyImportExporter.h b/src/core/function/gpg/GpgKeyImportExporter.h index 20eacd71..3c88c2c5 100644 --- a/src/core/function/gpg/GpgKeyImportExporter.h +++ b/src/core/function/gpg/GpgKeyImportExporter.h @@ -100,7 +100,7 @@ class GPGFRONTEND_CORE_EXPORT GpgKeyImportExporter * @param inBuffer * @return GpgImportInformation */ - auto ImportKey(StdBypeArrayPtr inBuffer) -> GpgImportInformation; + auto ImportKey(StdBypeArrayPtr) -> GpgImportInformation; /** * @brief diff --git a/src/core/function/gpg/GpgKeyManager.cpp b/src/core/function/gpg/GpgKeyManager.cpp index 4a67a3f4..7afc356a 100644 --- a/src/core/function/gpg/GpgKeyManager.cpp +++ b/src/core/function/gpg/GpgKeyManager.cpp @@ -184,11 +184,6 @@ auto GpgFrontend::GpgKeyManager::SetOwnerTrustLevel(const GpgKey& key, auto err = gpgme_op_interact( ctx_.DefaultContext(), static_cast<gpgme_key_t>(key), 0, GpgKeyManager::interactor_cb_fnc, (void*)&handel_struct, data_out); - if (err != GPG_ERR_NO_ERROR) { - SPDLOG_ERROR("fail to set owner trust level {} to key {}, err: {}", - trust_level, key.GetId(), gpgme_strerror(err)); - } - return CheckGpgError(err) == GPG_ERR_NO_ERROR && handel_struct.Success(); } |