aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui/dialog/help/GnupgTab.cpp
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2024-04-21 19:49:04 +0000
committersaturneric <[email protected]>2024-04-21 19:49:04 +0000
commit571a2906063739067e40a02aadd8c265082359de (patch)
tree5ac57f777ec38f6a5f328da4e3df6ad6cc010aff /src/ui/dialog/help/GnupgTab.cpp
parentfix: could not determine the path to the executable based on the desktop file (diff)
parentfeat: adapt linux appimage of modules loading (diff)
downloadGpgFrontend-571a2906063739067e40a02aadd8c265082359de.tar.gz
GpgFrontend-571a2906063739067e40a02aadd8c265082359de.zip
Merge branch 'dev/2.1.2/module' into develop
Diffstat (limited to '')
-rw-r--r--src/ui/dialog/help/GnupgTab.cpp85
1 files changed, 61 insertions, 24 deletions
diff --git a/src/ui/dialog/help/GnupgTab.cpp b/src/ui/dialog/help/GnupgTab.cpp
index 1aceed1a..3dfdd994 100644
--- a/src/ui/dialog/help/GnupgTab.cpp
+++ b/src/ui/dialog/help/GnupgTab.cpp
@@ -35,7 +35,9 @@
#include "core/module/ModuleManager.h"
#include "ui_GnuPGInfo.h"
-GpgFrontend::UI::GnupgTab::GnupgTab(QWidget* parent)
+namespace GpgFrontend::UI {
+
+GnupgTab::GnupgTab(QWidget* parent)
: QWidget(parent),
ui_(GpgFrontend::SecureCreateSharedObject<Ui_GnuPGInfo>()) {
ui_->setupUi(this);
@@ -103,10 +105,15 @@ GpgFrontend::UI::GnupgTab::GnupgTab(QWidget* parent)
ui_->optionDetailsTable->setFocusPolicy(Qt::NoFocus);
ui_->optionDetailsTable->setAlternatingRowColors(true);
- process_software_info();
+ if (Module::RetrieveRTValueTypedOrDefault(
+ "ui", "env.state.gnupg_info_gathering", 0) == 1) {
+ process_software_info();
+ } else {
+ gather_gnupg_info();
+ }
}
-void GpgFrontend::UI::GnupgTab::process_software_info() {
+void GnupgTab::process_software_info() {
const auto gnupg_version = Module::RetrieveRTValueTypedOrDefault<>(
"core", "gpgme.ctx.gnupg_version", QString{"2.0.0"});
GF_UI_LOG_DEBUG("got gnupg version from rt: {}", gnupg_version);
@@ -114,9 +121,8 @@ void GpgFrontend::UI::GnupgTab::process_software_info() {
ui_->gnupgVersionLabel->setText(
QString::fromStdString(fmt::format("Version: {}", gnupg_version)));
- auto components = Module::ListRTChildKeys(
- "com.bktus.gpgfrontend.module.integrated.gnupg-info-gathering",
- "gnupg.components");
+ auto components =
+ Module::ListRTChildKeys(kGnuPGInfoGatheringModuleID, "gnupg.components");
GF_UI_LOG_DEBUG("got gnupg components from rt, size: {}", components.size());
ui_->componentDetailsTable->setRowCount(components.size());
@@ -124,12 +130,12 @@ void GpgFrontend::UI::GnupgTab::process_software_info() {
int row = 0;
for (auto& component : components) {
auto component_info_json_bytes = Module::RetrieveRTValueTypedOrDefault(
- "com.bktus.gpgfrontend.module.integrated.gnupg-info-gathering",
- QString("gnupg.components.%1").arg(component), QByteArray{});
+ kGnuPGInfoGatheringModuleID,
+ QString("gnupg.components.%1").arg(component), QString{});
GF_UI_LOG_DEBUG("got gnupg component {} info from rt", component);
auto component_info_json =
- QJsonDocument::fromJson(component_info_json_bytes);
+ QJsonDocument::fromJson(component_info_json_bytes.toUtf8());
if (!component_info_json.isObject()) {
GF_UI_LOG_WARN("illegal gnupg component info, json: {}",
QString(component_info_json_bytes));
@@ -170,17 +176,16 @@ void GpgFrontend::UI::GnupgTab::process_software_info() {
ui_->componentDetailsTable->resizeColumnsToContents();
- auto directories = Module::ListRTChildKeys(
- "com.bktus.gpgfrontend.module.integrated.gnupg-info-gathering",
- QString("gnupg.dirs"));
+ auto directories = Module::ListRTChildKeys(kGnuPGInfoGatheringModuleID,
+ QString("gnupg.dirs"));
ui_->directoriesDetailsTable->setRowCount(directories.size());
row = 0;
for (auto& dir : directories) {
const auto dir_path = Module::RetrieveRTValueTypedOrDefault(
- "com.bktus.gpgfrontend.module.integrated.gnupg-info-gathering",
- QString("gnupg.dirs.%1").arg(dir), QString{});
+ kGnuPGInfoGatheringModuleID, QString("gnupg.dirs.%1").arg(dir),
+ QString{});
if (dir_path.isEmpty()) continue;
@@ -201,16 +206,17 @@ void GpgFrontend::UI::GnupgTab::process_software_info() {
row = 0;
for (auto& component : components) {
auto options = Module::ListRTChildKeys(
- "com.bktus.gpgfrontend.module.integrated.gnupg-info-gathering",
+ kGnuPGInfoGatheringModuleID,
QString("gnupg.components.%1.options").arg(component));
for (auto& option : options) {
const auto option_info_json =
QJsonDocument::fromJson(Module::RetrieveRTValueTypedOrDefault(
- "com.bktus.gpgfrontend.module.integrated.gnupg-info-gathering",
- QString("gnupg.components.%1.options.%2")
- .arg(component)
- .arg(option),
- QByteArray{}));
+ kGnuPGInfoGatheringModuleID,
+ QString("gnupg.components.%1.options.%2")
+ .arg(component)
+ .arg(option),
+ QString{})
+ .toUtf8());
if (!option_info_json.isObject()) continue;
@@ -228,18 +234,19 @@ void GpgFrontend::UI::GnupgTab::process_software_info() {
QString configuration_group;
for (auto& component : components) {
auto options = Module::ListRTChildKeys(
- "com.bktus.gpgfrontend.module.integrated.gnupg-info-gathering",
+ kGnuPGInfoGatheringModuleID,
QString("gnupg.components.%1.options").arg(component));
for (auto& option : options) {
auto option_info_json_bytes = Module::RetrieveRTValueTypedOrDefault(
- "com.bktus.gpgfrontend.module.integrated.gnupg-info-gathering",
+ kGnuPGInfoGatheringModuleID,
QString("gnupg.components.%1.options.%2").arg(component).arg(option),
- QByteArray{});
+ QString{});
GF_UI_LOG_DEBUG("got gnupg component's option {} info from rt, info: {}",
component, option_info_json_bytes);
- auto option_info_json = QJsonDocument::fromJson(option_info_json_bytes);
+ auto option_info_json =
+ QJsonDocument::fromJson(option_info_json_bytes.toUtf8());
if (!option_info_json.isObject()) {
GF_UI_LOG_WARN("illegal gnupg option info, json: {}",
@@ -291,3 +298,33 @@ void GpgFrontend::UI::GnupgTab::process_software_info() {
}
// ui_->configurationDetailsTable->resizeColumnsToContents();
}
+
+void GnupgTab::gather_gnupg_info() {
+ // if gnupg_info_gathering module activated
+ if (Module::IsModuleActivate(kGnuPGInfoGatheringModuleID)) {
+ GF_CORE_LOG_DEBUG(
+ "module gnupg_info_gathering is activated, "
+ "loading external gnupg info...");
+
+ // gather external gnupg info
+ Module::TriggerEvent(
+ "REQUEST_GATHERING_GNUPG_INFO",
+ [=](const Module::EventIdentifier& /*e*/,
+ const Module::Event::ListenerIdentifier& l_id, DataObjectPtr o) {
+ GF_CORE_LOG_DEBUG(
+ "received event REQUEST_GATHERING_GNUPG_INFO callback "
+ "from module: {}",
+ l_id);
+
+ if (l_id == kGnuPGInfoGatheringModuleID) {
+ Module::UpsertRTValue("ui", "env.state.gnupg_info_gathering", 1);
+
+ // gnupg info gathering process finished
+ GF_CORE_LOG_INFO("gnupg information gathering finished");
+ process_software_info();
+ }
+ });
+ }
+}
+
+} // namespace GpgFrontend::UI \ No newline at end of file