From 78607d9d1bd8f2feebe5d67e82ba033cb012ae4c Mon Sep 17 00:00:00 2001 From: Saturneric Date: Mon, 6 Feb 2023 21:22:24 +0800 Subject: feat: support buddled gnupg for posix platform --- src/main.cpp | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 36c3c7e9..52a20334 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -33,9 +33,13 @@ #include #include #include +#include +#include #include "core/GpgConstants.h" #include "core/GpgCoreInit.h" +#include "core/function/GlobalSettingStation.h" +#include "spdlog/spdlog.h" #include "ui/GpgFrontendApplication.h" #include "ui/GpgFrontendUIInit.h" @@ -93,12 +97,27 @@ int main(int argc, char* argv[]) { auto* app = GpgFrontend::UI::GpgFrontendApplication::GetInstance(argc, argv, true); - // init the logging system + // init the logging system for main init_logging_system(); // init the logging system for core GpgFrontend::InitLoggingSystem(); + // change path to search for related + std::string path_value = getenv("PATH"); + SPDLOG_DEBUG("PATH: {}", path_value); + setenv("PATH", + ((GpgFrontend::GlobalSettingStation::GetInstance() + .GetAppDir() + .parent_path() / + "GnuPG" / "bin") + .u8string() + + ":" + path_value) + .c_str(), + 1); + std::string modified_path_value = getenv("PATH"); + SPDLOG_DEBUG("Modified PATH: {}", modified_path_value); + /** * internationalisation. loop to restart main window * with changed translation when settings change. @@ -132,16 +151,22 @@ int main(int argc, char* argv[]) { return_from_event_loop_code = CRASH_CODE; } - SPDLOG_INFO("loop refresh"); + SPDLOG_INFO("restart loop refresh"); } while (return_from_event_loop_code == RESTART_CODE); // reset core GpgFrontend::ResetGpgFrontendCore(); + // log for debug + SPDLOG_INFO("deep restart or cash loop refresh"); + // deep restart mode } while (return_from_event_loop_code == DEEP_RESTART_CODE || return_from_event_loop_code == CRASH_CODE); + // log for debug + SPDLOG_INFO("GpgFrontend about to exit"); + // exit the program return return_from_event_loop_code; } -- cgit v1.2.3