diff options
author | Saturn&Eric <[email protected]> | 2023-04-04 19:25:40 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2023-04-04 19:25:40 +0000 |
commit | 770e0d6ab61ec9ade91f1109244043195d99b720 (patch) | |
tree | c9605d79f53468176225d2c9314fceb0e036791e /src/core/GpgCoreInit.cpp | |
parent | Merge pull request #93 from saturneric/dev/2.0.10/main (diff) | |
parent | feat: upgrade version to 2.1.1 (diff) | |
download | GpgFrontend-770e0d6ab61ec9ade91f1109244043195d99b720.tar.gz GpgFrontend-770e0d6ab61ec9ade91f1109244043195d99b720.zip |
Merge pull request #95 from saturneric/dev/2.1.0/main
Develop 2.1.1.1
Diffstat (limited to 'src/core/GpgCoreInit.cpp')
-rw-r--r-- | src/core/GpgCoreInit.cpp | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/src/core/GpgCoreInit.cpp b/src/core/GpgCoreInit.cpp index 9395bac7..48883048 100644 --- a/src/core/GpgCoreInit.cpp +++ b/src/core/GpgCoreInit.cpp @@ -32,6 +32,8 @@ #include <spdlog/sinks/rotating_file_sink.h> #include <spdlog/sinks/stdout_color_sinks.h> +#include <filesystem> + #include "GpgFunctionObject.h" #include "core/GpgContext.h" #include "core/function/GlobalSettingStation.h" @@ -150,6 +152,34 @@ void init_gpgfrontend_core() { SPDLOG_DEBUG("core loaded custom key databse path: {}", custom_key_database_path); + bool use_custom_gnupg_install_path = false; + try { + use_custom_gnupg_install_path = + settings.lookup("general.use_custom_gnupg_install_path"); + } catch (...) { + SPDLOG_ERROR("setting operation error: use_custom_gnupg_install_path"); + } + + // read from settings file + std::filesystem::path custom_gnupg_install_path; + try { + custom_gnupg_install_path = std::filesystem::path(static_cast<std::string>( + settings.lookup("general.custom_gnupg_install_path"))); + + } catch (...) { + SPDLOG_ERROR("setting operation error: custom_gnupg_install_path"); + } + + // check gpgconf path + if (!custom_gnupg_install_path.is_absolute()) { + use_custom_gnupg_install_path = false; + SPDLOG_ERROR("core loaded custom gpgconf path error: {}", + custom_gnupg_install_path.u8string()); + } else { + SPDLOG_DEBUG("core loaded custom gpgconf path: {}", + custom_gnupg_install_path.u8string()); + } + // init default channel auto& default_ctx = GpgFrontend::GpgContext::CreateInstance( GPGFRONTEND_DEFAULT_CHANNEL, [=]() -> std::unique_ptr<ChannelObject> { @@ -163,13 +193,19 @@ void init_gpgfrontend_core() { args.offline_mode = forbid_all_gnupg_connection; args.auto_import_missing_key = auto_import_missing_key; + if (use_custom_gnupg_install_path) { + args.custom_gpgconf = true; + args.custom_gpgconf_path = + (custom_gnupg_install_path / "gpgconf").u8string(); + } + return std::unique_ptr<ChannelObject>(new GpgContext(args)); }); // exit if failed if (!default_ctx.good()) { SPDLOG_ERROR("default gpgme context init error, exit."); - QCoreApplication::exit(); + return; }; // async init no-ascii channel |