diff options
author | Saturneric <[email protected]> | 2023-07-14 14:28:11 +0000 |
---|---|---|
committer | Saturneric <[email protected]> | 2023-07-14 14:28:11 +0000 |
commit | 9634782eedf507a0b952f30dbc6c130992be776b (patch) | |
tree | 7c89f24d556d96d3f0446e80477564697ea6ac3e /src | |
parent | fix: slove issues on README (diff) | |
download | GpgFrontend-9634782eedf507a0b952f30dbc6c130992be776b.tar.gz GpgFrontend-9634782eedf507a0b952f30dbc6c130992be776b.zip |
fix: reduce debug log of core
Diffstat (limited to '')
-rw-r--r-- | src/core/function/CacheManager.cpp | 1 | ||||
-rw-r--r-- | src/core/function/gpg/GpgKeyGetter.cpp | 5 | ||||
-rw-r--r-- | src/core/function/gpg/GpgKeyOpera.cpp | 43 | ||||
-rw-r--r-- | src/core/function/gpg/GpgKeyOpera.h | 4 |
4 files changed, 44 insertions, 9 deletions
diff --git a/src/core/function/CacheManager.cpp b/src/core/function/CacheManager.cpp index b24a8050..d9aead66 100644 --- a/src/core/function/CacheManager.cpp +++ b/src/core/function/CacheManager.cpp @@ -64,7 +64,6 @@ void GpgFrontend::CacheManager::SaveCache(std::string key, nlohmann::json GpgFrontend::CacheManager::LoadCache(std::string key) { auto data_object_key = get_data_object_key(key); - SPDLOG_DEBUG("load cache, data object key: {}", data_object_key); if (!cache_storage_.exists(key)) { cache_storage_.insert(key, load_cache_storage(key, {})); } diff --git a/src/core/function/gpg/GpgKeyGetter.cpp b/src/core/function/gpg/GpgKeyGetter.cpp index a8e685e0..ee6d2b09 100644 --- a/src/core/function/gpg/GpgKeyGetter.cpp +++ b/src/core/function/gpg/GpgKeyGetter.cpp @@ -78,12 +78,9 @@ GpgFrontend::KeyLinkListPtr GpgFrontend::GpgKeyGetter::FetchKey() { // get the lock std::lock_guard<std::mutex> lock(keys_cache_mutex_); - SPDLOG_DEBUG("channel id: {}", GetChannel()); - auto keys_list = std::make_unique<GpgKeyLinkList>(); for (const auto& [key, value] : keys_cache_) { - SPDLOG_DEBUG("fetch key id: {}", value.GetId()); keys_list->push_back(value.Copy()); } return keys_list; @@ -118,8 +115,6 @@ void GpgFrontend::GpgKeyGetter::FlushKeyCache() { gpg_key = GetKey(gpg_key.GetId(), false); } - SPDLOG_DEBUG("load key fpr: {} id: {}", gpg_key.GetFingerprint(), - gpg_key.GetId()); keys_cache_.insert({gpg_key.GetId(), std::move(gpg_key)}); } } diff --git a/src/core/function/gpg/GpgKeyOpera.cpp b/src/core/function/gpg/GpgKeyOpera.cpp index 0d715ba7..d5919cff 100644 --- a/src/core/function/gpg/GpgKeyOpera.cpp +++ b/src/core/function/gpg/GpgKeyOpera.cpp @@ -103,7 +103,48 @@ GpgFrontend::GpgError GpgFrontend::GpgKeyOpera::SetExpire( * @return the process doing this job */ void GpgFrontend::GpgKeyOpera::GenerateRevokeCert( - const GpgKey& key, const std::string& output_file_name) {} + const GpgKey& key, const std::string& output_file_path) { + // get all components + GpgCommandExecutor::GetInstance().Execute( + ctx_.GetInfo().AppPath, + {"--command-fd", "0", "--status-fd", "1", "--no-tty", "-o", + output_file_path, "--gen-revoke", key.GetFingerprint().c_str()}, + [=](int exit_code, const std::string& p_out, const std::string& p_err) { + if (exit_code != 0) { + SPDLOG_ERROR( + "gnupg gen revoke execute error, process stderr: {}, process " + "stdout: {}", + p_err, p_out); + } else { + SPDLOG_DEBUG( + "gnupg gen revoke exit_code: {}, process stdout size: {}", + exit_code, p_out.size()); + } + }, + [](QProcess* proc) -> void { + // Code From Gpg4Win + while (proc->canReadLine()) { + const QString line = QString::fromUtf8(proc->readLine()).trimmed(); + SPDLOG_DEBUG("line: {}", line.toStdString()); + if (line == QLatin1String("[GNUPG:] GET_BOOL gen_revoke.okay")) { + proc->write("y\n"); + } else if (line == QLatin1String("[GNUPG:] GET_LINE " + "ask_revocation_reason.code")) { + proc->write("0\n"); + } else if (line == QLatin1String("[GNUPG:] GET_LINE " + "ask_revocation_reason.text")) { + proc->write("\n"); + } else if (line == QLatin1String( + "[GNUPG:] GET_BOOL openfile.overwrite.okay")) { + // We asked before + proc->write("y\n"); + } else if (line == QLatin1String("[GNUPG:] GET_BOOL " + "ask_revocation_reason.okay")) { + proc->write("y\n"); + } + } + }); +} /** * Generate a new key pair diff --git a/src/core/function/gpg/GpgKeyOpera.h b/src/core/function/gpg/GpgKeyOpera.h index 703eb824..5446bd66 100644 --- a/src/core/function/gpg/GpgKeyOpera.h +++ b/src/core/function/gpg/GpgKeyOpera.h @@ -86,8 +86,8 @@ class GPGFRONTEND_CORE_EXPORT GpgKeyOpera * @param key * @param output_file_name */ - static void GenerateRevokeCert(const GpgKey& key, - const std::string& output_file_name); + void GenerateRevokeCert(const GpgKey& key, + const std::string& output_file_name); /** * @brief |