diff options
author | saturneric <[email protected]> | 2024-01-08 09:26:41 +0000 |
---|---|---|
committer | saturneric <[email protected]> | 2024-01-08 09:26:41 +0000 |
commit | 5222a2fd1ba372f6eb67dc8fa71e334f1ff10bbb (patch) | |
tree | 7a868b8f56986083d5e0aa4c64cb74c34cdbf73f /src/core | |
parent | feat: remove save keys checked function (diff) | |
download | GpgFrontend-5222a2fd1ba372f6eb67dc8fa71e334f1ff10bbb.tar.gz GpgFrontend-5222a2fd1ba372f6eb67dc8fa71e334f1ff10bbb.zip |
fix: solve compile issue
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/function/GlobalSettingStation.h | 20 | ||||
-rw-r--r-- | src/core/function/gpg/GpgAdvancedOperator.cpp | 47 | ||||
-rw-r--r-- | src/core/function/result_analyse/GpgVerifyResultAnalyse.cpp | 3 |
3 files changed, 52 insertions, 18 deletions
diff --git a/src/core/function/GlobalSettingStation.h b/src/core/function/GlobalSettingStation.h index 5582562a..06f37264 100644 --- a/src/core/function/GlobalSettingStation.h +++ b/src/core/function/GlobalSettingStation.h @@ -168,6 +168,26 @@ class GPGFRONTEND_CORE_EXPORT GlobalSettingStation return value; } + /** + * @brief Looks up a setting by path. + * @param path The path to the setting. + * @param default_value The default value to return if setting is not found. + * @return The setting value. + */ + template <typename T> + auto SaveSettings(std::string path, libconfig::Setting::Type type, + T value) noexcept -> T { + try { + if (!GetMainSettings().exists(path)) { + // TODO + GetMainSettings().add(path, type); + } + } catch (...) { + GF_CORE_LOG_WARN("setting not found: {}", path); + } + return value; + } + private: class Impl; SecureUniquePtr<Impl> p_; diff --git a/src/core/function/gpg/GpgAdvancedOperator.cpp b/src/core/function/gpg/GpgAdvancedOperator.cpp index c96b35f7..9195c55e 100644 --- a/src/core/function/gpg/GpgAdvancedOperator.cpp +++ b/src/core/function/gpg/GpgAdvancedOperator.cpp @@ -110,6 +110,7 @@ void GpgFrontend::GpgAdvancedOperator::RestartGpgComponents() { GF_CORE_LOG_ERROR( "gpgconf execute error, process stderr: {}, process stdout: {}", p_err, p_out); + return; } GF_CORE_LOG_DEBUG("gpgconf --kill --all execute result: {}", success); @@ -125,18 +126,21 @@ void GpgFrontend::GpgAdvancedOperator::RestartGpgComponents() { if (!success) { GF_CORE_LOG_ERROR("start gpg agent after core initilized failed"); + return; } success &= StartDirmngr(); if (!success) { GF_CORE_LOG_ERROR("start dirmngr after core initilized failed"); + return; } success &= StartKeyBoxd(); if (!success) { GF_CORE_LOG_ERROR("start keyboxd after core initilized failed"); + return; } Module::UpsertRTValue( @@ -198,16 +202,19 @@ auto GpgFrontend::GpgAdvancedOperator::StartGpgAgent() -> bool { if (exit_code == 0) { success = true; GF_CORE_LOG_INFO("start gpg-agent successfully"); - } else if (exit_code == 2) { + return; + } + + if (exit_code == 2) { success = true; GF_CORE_LOG_INFO("gpg-agent already started"); - } else { - GF_CORE_LOG_ERROR( - "gpg-agent execute error, process stderr: {}, process stdout: " - "{}", - p_err, p_out); return; } + + GF_CORE_LOG_ERROR( + "gpg-agent execute error, " + "process stderr: {}, process stdout: {}", + p_err, p_out); }}); return success; @@ -238,22 +245,25 @@ auto GpgFrontend::GpgAdvancedOperator::StartDirmngr() -> bool { if (exit_code == 0) { success = true; GF_CORE_LOG_INFO("start dirmngr successfully"); - } else if (exit_code == 2) { + return; + } + + if (exit_code == 2) { success = true; GF_CORE_LOG_INFO("dirmngr already started"); - } else { - GF_CORE_LOG_ERROR( - "dirmngr execute error, process stderr: {}, process stdout: {}", - p_err, p_out); return; } + + GF_CORE_LOG_ERROR( + "dirmngr execute error, process stderr: {}, process stdout: {}", + p_err, p_out); }}); return success; } auto GpgFrontend::GpgAdvancedOperator::StartKeyBoxd() -> bool { - bool success = false; + auto success = false; const auto keyboxd_path = Module::RetrieveRTValueTypedOrDefault<>( "com.bktus.gpgfrontend.module.integrated.gnupg-info-gathering", @@ -277,15 +287,18 @@ auto GpgFrontend::GpgAdvancedOperator::StartKeyBoxd() -> bool { if (exit_code == 0) { success = true; GF_CORE_LOG_INFO("start keyboxd successfully"); - } else if (exit_code == 2) { + return; + } + + if (exit_code == 2) { success = true; GF_CORE_LOG_INFO("keyboxd already started"); - } else { - GF_CORE_LOG_ERROR( - "keyboxd execute error, process stderr: {}, process stdout: {}", - p_err, p_out); return; } + + GF_CORE_LOG_ERROR( + "keyboxd execute error, process stderr: {}, process stdout: {}", + p_err, p_out); }}); return success; diff --git a/src/core/function/result_analyse/GpgVerifyResultAnalyse.cpp b/src/core/function/result_analyse/GpgVerifyResultAnalyse.cpp index 064dc087..d497c094 100644 --- a/src/core/function/result_analyse/GpgVerifyResultAnalyse.cpp +++ b/src/core/function/result_analyse/GpgVerifyResultAnalyse.cpp @@ -108,7 +108,8 @@ void GpgFrontend::GpgVerifyResultAnalyse::doAnalyse() { stream_ << _("Signature Fully Valid.") << std::endl; } else { stream_ << _("Signature Not Fully Valid.") << std::endl; - stream_ << _("(May used a subkey to sign)") << std::endl; + stream_ << _("(Adjust Trust Level to make it Fully Vaild)") + << std::endl; } if ((sign->status & GPGME_SIGSUM_KEY_MISSING) == 0U) { |