diff options
Diffstat (limited to '')
51 files changed, 896 insertions, 560 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b8cab9c3..5d0d0fb8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -140,6 +140,7 @@ if (BASIC_ENV_CONFIG) configure_file(${CMAKE_SOURCE_DIR}/src/GpgFrontend.h.in ${CMAKE_SOURCE_DIR}/src/GpgFrontend.h @ONLY) configure_file(${CMAKE_SOURCE_DIR}/src/GpgFrontendBuildInfo.h.in ${CMAKE_SOURCE_DIR}/src/GpgFrontendBuildInfo.h @ONLY) configure_file(${CMAKE_SOURCE_DIR}/src/GpgFrontendBuildInstallInfo.h.in ${CMAKE_SOURCE_DIR}/src/GpgFrontendBuildInstallInfo.h @ONLY) + configure_file(${CMAKE_SOURCE_DIR}/src/module/sdk/GFSDKBuildInfo.h.in ${CMAKE_SOURCE_DIR}/src/module/sdk/GFSDKBuildInfo.h @ONLY) if (APPLE) configure_file(${CMAKE_SOURCE_DIR}/resource/plist/ExportOptions.plist.in ${CMAKE_BINARY_DIR}/ExportOptions.plist @ONLY) endif () diff --git a/src/core/GpgCoreInit.cpp b/src/core/GpgCoreInit.cpp index 137a118b..8268f798 100644 --- a/src/core/GpgCoreInit.cpp +++ b/src/core/GpgCoreInit.cpp @@ -176,7 +176,7 @@ auto InitGpgME(const QString& gpgconf_path, const QString& gnupg_path) -> bool { GF_CORE_LOG_DEBUG("got gnupg version from rt: {}", gnupg_version); // conditional check: only support gpg 2.1.x now - if (!(CompareSoftwareVersion(gnupg_version, "2.1.0") >= 0 && find_gpgconf && + if (!(GFCompareSoftwareVersion(gnupg_version, "2.1.0") >= 0 && find_gpgconf && find_openpgp && find_cms)) { GF_CORE_LOG_ERROR("gpgme env check failed, abort"); return false; diff --git a/src/core/function/gpg/GpgKeyOpera.cpp b/src/core/function/gpg/GpgKeyOpera.cpp index e0ecb3ce..14d58a10 100644 --- a/src/core/function/gpg/GpgKeyOpera.cpp +++ b/src/core/function/gpg/GpgKeyOpera.cpp @@ -502,7 +502,7 @@ auto GpgKeyOpera::ModifyTOFUPolicy(const GpgKey& key, "core", "gpgme.ctx.gnupg_version", QString{"2.0.0"}); GF_CORE_LOG_DEBUG("got gnupg version from rt: {}", gnupg_version); - if (CompareSoftwareVersion(gnupg_version, "2.1.10") < 0) { + if (GFCompareSoftwareVersion(gnupg_version, "2.1.10") < 0) { GF_CORE_LOG_ERROR("operator not support"); return GPG_ERR_NOT_SUPPORTED; } diff --git a/src/core/module/Event.cpp b/src/core/module/Event.cpp index 01f7bf9b..0285ae6c 100644 --- a/src/core/module/Event.cpp +++ b/src/core/module/Event.cpp @@ -101,19 +101,20 @@ class Event::Impl { } } - auto ToModuleEvent() -> ModuleEvent* { - auto* event = static_cast<ModuleEvent*>(SecureMalloc(sizeof(ModuleEvent))); + auto ToModuleEvent() -> GFModuleEvent* { + auto* event = + static_cast<GFModuleEvent*>(SecureMalloc(sizeof(GFModuleEvent))); event->id = GFStrDup(event_identifier_); event->triggger_id = GFStrDup(trigger_uuid_); - ModuleEventParam* l_param = nullptr; - ModuleEventParam* p_param; + GFModuleEventParam* l_param = nullptr; + GFModuleEventParam* p_param; int index = 0; for (const auto& data : data_) { - p_param = static_cast<ModuleEventParam*>( - SecureMalloc(sizeof(ModuleEventParam))); + p_param = static_cast<GFModuleEventParam*>( + SecureMalloc(sizeof(GFModuleEventParam))); if (index++ == 0) event->params = p_param; p_param->name = GFStrDup(data.first); @@ -173,6 +174,6 @@ void Event::ExecuteCallback(ListenerIdentifier l_id, DataObjectPtr d_o) { p_->ExecuteCallback(std::move(l_id), d_o); } -auto Event::ToModuleEvent() -> ModuleEvent* { return p_->ToModuleEvent(); } +auto Event::ToModuleEvent() -> GFModuleEvent* { return p_->ToModuleEvent(); } } // namespace GpgFrontend::Module
\ No newline at end of file diff --git a/src/core/module/Event.h b/src/core/module/Event.h index d7c35314..8983d560 100644 --- a/src/core/module/Event.h +++ b/src/core/module/Event.h @@ -34,7 +34,7 @@ #include "core/GpgFrontendCore.h" #include "core/model/DataObject.h" -#include "module/sdk/Module.h" +#include "module/sdk/GFSDKModule.h" namespace GpgFrontend::Module { @@ -83,7 +83,7 @@ class GPGFRONTEND_CORE_EXPORT Event { void ExecuteCallback(ListenerIdentifier, DataObjectPtr); - auto ToModuleEvent() -> ModuleEvent*; + auto ToModuleEvent() -> GFModuleEvent*; private: class Impl; diff --git a/src/core/module/GlobalModuleContext.cpp b/src/core/module/GlobalModuleContext.cpp index cd970df4..6032e090 100644 --- a/src/core/module/GlobalModuleContext.cpp +++ b/src/core/module/GlobalModuleContext.cpp @@ -171,13 +171,6 @@ class GlobalModuleContext::Impl { auto ListenEvent(ModuleIdentifier module_id, EventIdentifier event) -> bool { GF_CORE_LOG_DEBUG("module: {} is attempting to listen to event {}", module_id, event); - // Check if the event exists, if not, create it. - auto met_it = module_events_table_.find(event); - if (met_it == module_events_table_.end()) { - module_events_table_[event] = std::unordered_set<ModuleIdentifier>(); - met_it = module_events_table_.find(event); - GF_CORE_LOG_DEBUG("new event {} of module system created", event); - } // module -> event auto module_info_opt = search_module_register_table(module_id); @@ -186,6 +179,15 @@ class GlobalModuleContext::Impl { module_id); return false; } + + // Check if the event exists, if not, create it. + auto met_it = module_events_table_.find(event); + if (met_it == module_events_table_.end()) { + module_events_table_[event] = std::unordered_set<ModuleIdentifier>(); + met_it = module_events_table_.find(event); + GF_CORE_LOG_DEBUG("new event {} of module system created", event); + } + module_info_opt.value()->listening_event_ids.push_back(event); auto& listeners_set = met_it->second; @@ -198,7 +200,7 @@ class GlobalModuleContext::Impl { } auto DeactivateModule(ModuleIdentifier module_id) -> bool { - // Search for the module in the register table. + // search for the module in the register table. auto module_info_opt = search_module_register_table(module_id); if (!module_info_opt.has_value()) { GF_CORE_LOG_ERROR("cannot find module id {} at register table", @@ -207,8 +209,16 @@ class GlobalModuleContext::Impl { } auto module_info = module_info_opt.value(); - // Activate the module if it is not already deactive. - if (!module_info->activate && (module_info->module->Deactive() == 0)) { + // activate the module if it is not already deactive. + if (module_info->activate && (module_info->module->Deactive() == 0)) { + for (const auto& event_ids : module_info->listening_event_ids) { + auto& modules = module_events_table_[event_ids]; + if (auto it = modules.find(module_id); it != modules.end()) { + modules.erase(it); + } + } + + module_info->listening_event_ids.clear(); module_info->activate = false; } diff --git a/src/core/module/Module.cpp b/src/core/module/Module.cpp index 0534d261..0c45dcbe 100644 --- a/src/core/module/Module.cpp +++ b/src/core/module/Module.cpp @@ -29,7 +29,9 @@ #include "Module.h" #include "core/module/GlobalModuleContext.h" +#include "core/utils/CommonUtils.h" #include "core/utils/IOUtils.h" +#include "module/sdk/GFSDKModule.h" namespace GpgFrontend::Module { @@ -63,18 +65,15 @@ class Module::Impl { } } - GF_CORE_LOG_INFO("module loaded, id: {}, verison: {}, hash: {}, path: {}", - QString::fromUtf8(get_id_api_()), - QString::fromUtf8(get_version_api_()), module_hash_, - module_library_path_); + identifier_ = GFUnStrDup(get_id_api_()); + version_ = GFUnStrDup(get_version_api_()); - identifier_ = QString::fromUtf8(get_id_api_()); - version_ = QString::fromUtf8(get_version_api_()); + GF_CORE_LOG_INFO("module loaded, id: {}, verison: {}, hash: {}, path: {}", + identifier_, version_, module_hash_, module_library_path_); - ::ModuleMetaData* p_meta_data = get_metadata_api_(); - ::ModuleMetaData* l_meta_data; + ::GFModuleMetaData* p_meta_data = get_metadata_api_(); + ::GFModuleMetaData* l_meta_data; - GF_CORE_LOG_DEBUG("AAAAAA: {}", static_cast<void*>(p_meta_data)); while (p_meta_data != nullptr) { meta_data_[QString::fromUtf8(p_meta_data->key)] = QString::fromUtf8(p_meta_data->value); @@ -157,16 +156,22 @@ class Module::Impl { ModuleMetaData meta_data_; QString module_hash_; QString module_library_path_; + QString gf_sdk_ver_; + QString qt_env_ver_; bool good_; - ModuleAPIGetModuleID get_id_api_; - ModuleAPIGetModuleVersion get_version_api_; - ModuleAPIGetModuleMetaData get_metadata_api_; - ModuleAPIRegisterModule register_api_; - ModuleAPIActivateModule activate_api_; - ModuleAPIExecuteModule execute_api_; - ModuleAPIDeactivateModule deactivate_api_; - ModuleAPIUnregisterModule unregister_api_; + + GFModuleAPIGetModuleGFSDKVersion get_sdk_ver_api_; + GFModuleAPIGetModuleQtEnvVersion get_qt_ver_api_; + + GFModuleAPIGetModuleID get_id_api_; + GFModuleAPIGetModuleVersion get_version_api_; + GFModuleAPIGetModuleMetaData get_metadata_api_; + GFModuleAPIRegisterModule register_api_; + GFModuleAPIActivateModule activate_api_; + GFModuleAPIExecuteModule execute_api_; + GFModuleAPIDeactivateModule deactivate_api_; + GFModuleAPIUnregisterModule unregister_api_; struct Symbol { const char* name; @@ -174,14 +179,16 @@ class Module::Impl { }; QList<Symbol> module_required_symbols_ = { - {"GetModuleID", reinterpret_cast<void**>(&get_id_api_)}, - {"GetModuleVersion", reinterpret_cast<void**>(&get_version_api_)}, - {"GetModuleMetaData", reinterpret_cast<void**>(&get_metadata_api_)}, - {"RegisterModule", reinterpret_cast<void**>(®ister_api_)}, - {"ActiveModule", reinterpret_cast<void**>(&activate_api_)}, - {"ExecuteModule", reinterpret_cast<void**>(&execute_api_)}, - {"DeactiveModule", reinterpret_cast<void**>(&deactivate_api_)}, - {"UnregisterModule", reinterpret_cast<void**>(&unregister_api_)}, + {"GFGetModuleGFSDKVersion", reinterpret_cast<void**>(&get_sdk_ver_api_)}, + {"GFGetModuleQtEnvVersion", reinterpret_cast<void**>(&get_qt_ver_api_)}, + {"GFGetModuleID", reinterpret_cast<void**>(&get_id_api_)}, + {"GFGetModuleVersion", reinterpret_cast<void**>(&get_version_api_)}, + {"GFGetModuleMetaData", reinterpret_cast<void**>(&get_metadata_api_)}, + {"GFRegisterModule", reinterpret_cast<void**>(®ister_api_)}, + {"GFActiveModule", reinterpret_cast<void**>(&activate_api_)}, + {"GFExecuteModule", reinterpret_cast<void**>(&execute_api_)}, + {"GFDeactiveModule", reinterpret_cast<void**>(&deactivate_api_)}, + {"GFUnregisterModule", reinterpret_cast<void**>(&unregister_api_)}, }; auto get_gpc() -> GlobalModuleContext* { diff --git a/src/core/module/Module.h b/src/core/module/Module.h index 097c7b00..3e51357d 100644 --- a/src/core/module/Module.h +++ b/src/core/module/Module.h @@ -30,7 +30,6 @@ #include "core/module/Event.h" #include "core/thread/TaskRunner.h" -#include "module/sdk/Module.h" namespace GpgFrontend::Module { diff --git a/src/core/module/ModuleManager.cpp b/src/core/module/ModuleManager.cpp index f49a0b1e..253ea8eb 100644 --- a/src/core/module/ModuleManager.cpp +++ b/src/core/module/ModuleManager.cpp @@ -143,6 +143,17 @@ class ModuleManager::Impl { __func__, nullptr)); } + void DeactiveModule(const ModuleIdentifier& identifier) { + Thread::TaskRunnerGetter::GetInstance() + .GetTaskRunner(Thread::TaskRunnerGetter::kTaskRunnerType_Default) + ->PostTask(new Thread::Task( + [=](const GpgFrontend::DataObjectPtr&) -> int { + gmc_->DeactivateModule(identifier); + return 0; + }, + __func__, nullptr)); + } + auto GetTaskRunner(ModuleIdentifier module_id) -> std::optional<TaskRunnerPtr> { return gmc_->GetTaskRunner(std::move(module_id)); @@ -236,6 +247,10 @@ void ModuleManager::ActiveModule(ModuleIdentifier id) { return p_->ActiveModule(id); } +void ModuleManager::DeactiveModule(ModuleIdentifier id) { + return p_->DeactiveModule(id); +} + auto ModuleManager::GetTaskRunner(ModuleIdentifier id) -> std::optional<TaskRunnerPtr> { return p_->GetTaskRunner(std::move(id)); diff --git a/src/core/utils/AsyncUtils.cpp b/src/core/utils/AsyncUtils.cpp index 9ce94247..3c007fb6 100644 --- a/src/core/utils/AsyncUtils.cpp +++ b/src/core/utils/AsyncUtils.cpp @@ -45,7 +45,7 @@ auto RunGpgOperaAsync(const GpgOperaRunnable& runnable, GF_CORE_LOG_DEBUG("got gnupg version from rt: {}, operation: {}", gnupg_version, operation); - if (CompareSoftwareVersion(gnupg_version, minial_version) < 0) { + if (GFCompareSoftwareVersion(gnupg_version, minial_version) < 0) { GF_CORE_LOG_ERROR("operaton {} not support for gnupg version: {}", operation, gnupg_version); callback(GPG_ERR_NOT_SUPPORTED, TransferParams()); @@ -85,7 +85,7 @@ auto RunGpgOperaSync(const GpgOperaRunnable& runnable, const QString& operation, GF_CORE_LOG_DEBUG("got gnupg version from rt: {}, operation: {}", gnupg_version, operation); - if (CompareSoftwareVersion(gnupg_version, minial_version) < 0) { + if (GFCompareSoftwareVersion(gnupg_version, minial_version) < 0) { GF_CORE_LOG_ERROR("operaton {} not support for gnupg version: {}", operation, gnupg_version); return {GPG_ERR_NOT_SUPPORTED, TransferParams()}; diff --git a/src/core/utils/CommonUtils.cpp b/src/core/utils/CommonUtils.cpp index 20851cca..d1704312 100644 --- a/src/core/utils/CommonUtils.cpp +++ b/src/core/utils/CommonUtils.cpp @@ -43,7 +43,7 @@ auto BeautifyFingerprint(QString fingerprint) -> QString { return out.readAll(); } -auto CompareSoftwareVersion(const QString& a, const QString& b) -> int { +auto GFCompareSoftwareVersion(const QString& a, const QString& b) -> int { auto remove_prefix = [](const QString& version) { return version.startsWith('v') ? version.mid(1) : version; }; @@ -81,4 +81,15 @@ auto GFStrDup(const QString& str) -> char* { c_str[utf8_str.size()] = '\0'; return c_str; } + +auto GPGFRONTEND_CORE_EXPORT GFUnStrDup(char* str) -> QString { + auto qt_str = QString::fromUtf8(str); + SecureFree(static_cast<void*>(const_cast<char*>(str))); + return qt_str; +} + +auto GPGFRONTEND_CORE_EXPORT GFUnStrDup(const char* str) -> QString { + return GFUnStrDup(const_cast<char*>(str)); +} + } // namespace GpgFrontend
\ No newline at end of file diff --git a/src/core/utils/CommonUtils.h b/src/core/utils/CommonUtils.h index d348cc71..6ef38fad 100644 --- a/src/core/utils/CommonUtils.h +++ b/src/core/utils/CommonUtils.h @@ -48,8 +48,8 @@ auto GPGFRONTEND_CORE_EXPORT BeautifyFingerprint(QString fingerprint) * @param b * @return int */ -auto GPGFRONTEND_CORE_EXPORT CompareSoftwareVersion(const QString& a, - const QString& b) -> int; +auto GPGFRONTEND_CORE_EXPORT GFCompareSoftwareVersion(const QString& a, + const QString& b) -> int; /** * @brief @@ -58,4 +58,11 @@ auto GPGFRONTEND_CORE_EXPORT CompareSoftwareVersion(const QString& a, */ auto GPGFRONTEND_CORE_EXPORT GFStrDup(const QString&) -> char*; +/** + * @brief + * + * @return QString + */ +auto GPGFRONTEND_CORE_EXPORT GFUnStrDup(const char*) -> QString; + } // namespace GpgFrontend
\ No newline at end of file diff --git a/src/module/CMakeLists.txt b/src/module/CMakeLists.txt index 90b695af..e8f8a11e 100644 --- a/src/module/CMakeLists.txt +++ b/src/module/CMakeLists.txt @@ -30,7 +30,7 @@ set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) aux_source_directory(sdk MODULE_SDK_SOURCE) add_library(gpgfrontend_module_sdk SHARED ${MODULE_SDK_SOURCE}) -set(_export_file_sdk "${CMAKE_CURRENT_SOURCE_DIR}/sdk/GpgFrontendModuleSDKExport.h") +set(_export_file_sdk "${CMAKE_CURRENT_SOURCE_DIR}/sdk/GFSDKExport.h") generate_export_header(gpgfrontend_module_sdk EXPORT_FILE_NAME "${_export_file_sdk}") target_include_directories(gpgfrontend_module_sdk PUBLIC sdk diff --git a/src/module/GpgFrontendModuleInit.cpp b/src/module/GpgFrontendModuleInit.cpp index 2b1d8ac9..b03dbab2 100644 --- a/src/module/GpgFrontendModuleInit.cpp +++ b/src/module/GpgFrontendModuleInit.cpp @@ -28,9 +28,7 @@ #include "GpgFrontendModuleInit.h" -#include <core/module/ModuleManager.h> - -#include "Module.h" +#include "core/module/ModuleManager.h" #include "core/thread/Task.h" #include "core/thread/TaskRunnerGetter.h" diff --git a/src/module/integrated/gnupg_info_gathering_module/CMakeLists.txt b/src/module/integrated/gnupg_info_gathering_module/CMakeLists.txt index cdd2f5b6..5b72004b 100644 --- a/src/module/integrated/gnupg_info_gathering_module/CMakeLists.txt +++ b/src/module/integrated/gnupg_info_gathering_module/CMakeLists.txt @@ -29,7 +29,7 @@ aux_source_directory(. INTEGRATED_MODULE_SOURCE) # define libgpgfrontend_module add_library(gpgfrontend_gnupg_info_gathering SHARED ${INTEGRATED_MODULE_SOURCE}) -set(_export_file "${CMAKE_CURRENT_SOURCE_DIR}/GpgFrontendModuleExport.h") +set(_export_file "${CMAKE_CURRENT_SOURCE_DIR}/GFModuleExport.h") generate_export_header(gpgfrontend_gnupg_info_gathering BASE_NAME "GF_MODULE" EXPORT_FILE_NAME "${_export_file}") diff --git a/src/module/integrated/gnupg_info_gathering_module/GpgFrontendModuleExport.h b/src/module/integrated/gnupg_info_gathering_module/GFModuleExport.h index fd18dfb1..fd18dfb1 100644 --- a/src/module/integrated/gnupg_info_gathering_module/GpgFrontendModuleExport.h +++ b/src/module/integrated/gnupg_info_gathering_module/GFModuleExport.h diff --git a/src/module/integrated/gnupg_info_gathering_module/GnuPGInfoGatheringModule.cpp b/src/module/integrated/gnupg_info_gathering_module/GnuPGInfoGatheringModule.cpp index 0595a8ac..38bdde11 100644 --- a/src/module/integrated/gnupg_info_gathering_module/GnuPGInfoGatheringModule.cpp +++ b/src/module/integrated/gnupg_info_gathering_module/GnuPGInfoGatheringModule.cpp @@ -28,9 +28,11 @@ #include "GnuPGInfoGatheringModule.h" -#include "Basic.h" +#include <GFSDKBasic.h> +#include <GFSDKBuildInfo.h> +#include <GFSDKLog.h> + #include "GpgInfo.h" -#include "Log.h" extern auto CalculateBinaryChacksum(const QString &path) -> std::optional<QString>; @@ -47,27 +49,30 @@ using Context = struct { GpgComponentInfo component_info; }; -auto RegisterModule() -> int { - ModuleLogDebug("gnupg info gathering module registering"); - return 0; +auto GFGetModuleGFSDKVersion() -> const char * { + return GFModuleStrDup(GF_SDK_VERSION_STR); +} + +auto GFGetModuleQtEnvVersion() -> const char * { + return GFModuleStrDup(QT_VERSION_STR); } -auto GetModuleID() -> const char * { +auto GFGetModuleID() -> const char * { return GFModuleStrDup( "com.bktus.gpgfrontend.module.integrated.gnupg-info-gathering"); } -auto GetModuleVersion() -> const char * { return GFModuleStrDup("1.0.0"); } +auto GFGetModuleVersion() -> const char * { return GFModuleStrDup("1.0.0"); } -auto GetModuleMetaData() -> ModuleMetaData * { - auto *p_meta = - static_cast<ModuleMetaData *>(AllocateMemory(sizeof(ModuleMetaData))); +auto GFGetModuleMetaData() -> GFModuleMetaData * { + auto *p_meta = static_cast<GFModuleMetaData *>( + GFAllocateMemory(sizeof(GFModuleMetaData))); auto *h_meta = p_meta; p_meta->key = "Description"; - p_meta->value = "Try to gathering gnupg informations"; - p_meta->next = - static_cast<ModuleMetaData *>(AllocateMemory(sizeof(ModuleMetaData))); + p_meta->value = "Try gathering gnupg informations"; + p_meta->next = static_cast<GFModuleMetaData *>( + GFAllocateMemory(sizeof(GFModuleMetaData))); p_meta = p_meta->next; p_meta->key = "Author"; p_meta->value = "Saturneric"; @@ -76,49 +81,57 @@ auto GetModuleMetaData() -> ModuleMetaData * { return h_meta; } -auto ActiveModule() -> int { - ModuleLogDebug("gnupg info gathering module activating"); - ListenEvent(GetModuleID(), "GPGFRONTEND_CORE_INITLIZED"); +auto GFRegisterModule() -> int { + GFModuleLogDebug("gnupg info gathering module registering"); + return 0; +} + +auto GFActiveModule() -> int { + GFModuleLogDebug("gnupg info gathering module activating"); + GFModuleListenEvent(GFGetModuleID(), + GFModuleStrDup("GPGFRONTEND_CORE_INITLIZED")); return 0; } -auto ExecuteModule(ModuleEvent *event) -> int { - ModuleLogDebug( +auto GFExecuteModule(GFModuleEvent *event) -> int { + GFModuleLogDebug( fmt::format("gnupg info gathering module executing, event id: {}", event->id) .c_str()); - ModuleLogDebug("start to load extra info at module gnupginfogathering..."); + GFModuleLogDebug("start to load extra info at module gnupginfogathering..."); - const auto *const gpgme_version = - RetrieveRTValueOrDefault("core", "gpgme.version", "0.0.0"); - ModuleLogDebug( + const auto *const gpgme_version = GFModuleRetrieveRTValueOrDefault( + GFModuleStrDup("core"), GFModuleStrDup("gpgme.version"), + GFModuleStrDup("0.0.0")); + GFModuleLogDebug( fmt::format("got gpgme version from rt: {}", gpgme_version).c_str()); - const auto *const gpgconf_path = - RetrieveRTValueOrDefault("core", "gpgme.ctx.gpgconf_path", ""); - ModuleLogDebug( + const auto *const gpgconf_path = GFModuleRetrieveRTValueOrDefault( + GFModuleStrDup("core"), GFModuleStrDup("gpgme.ctx.gpgconf_path"), + GFModuleStrDup("")); + GFModuleLogDebug( fmt::format("got gpgconf path from rt: {}", gpgconf_path).c_str()); auto context = Context{gpgme_version, gpgconf_path}; // get all components const char *argv[] = {GFModuleStrDup("--list-components")}; - ExecuteCommandSync(gpgconf_path, 1, argv, GetGpgComponentInfos, &context); - ModuleLogDebug("load gnupg component info done."); + GFExecuteCommandSync(gpgconf_path, 1, argv, GetGpgComponentInfos, &context); + GFModuleLogDebug("load gnupg component info done."); - QList<CommandExecuteContext> exec_contexts; + QList<GFCommandExecuteContext> exec_contexts; const char **argv_0 = - static_cast<const char **>(AllocateMemory(sizeof(const char *))); + static_cast<const char **>(GFAllocateMemory(sizeof(const char *))); argv_0[0] = GFModuleStrDup("--list-dirs"); exec_contexts.push_back( {gpgconf_path, 1, argv_0, GetGpgDirectoryInfos, nullptr}); char **components_c_array; - int ret = - ListRTChildKeys(GetModuleID(), "gnupg.components", &components_c_array); + int ret = GFModuleListRTChildKeys( + GFGetModuleID(), GFModuleStrDup("gnupg.components"), &components_c_array); if (components_c_array == nullptr || ret == 0) return -1; QStringList components; @@ -126,8 +139,9 @@ auto ExecuteModule(ModuleEvent *event) -> int { for (int i = 0; i < ret; i++) components.append(QString::fromUtf8(p_a[i])); for (const auto &component : components) { - const auto *component_info_json = RetrieveRTValueOrDefault( - GetModuleID(), QString("gnupg.components.%1").arg(component).toUtf8(), + const auto *component_info_json = GFModuleRetrieveRTValueOrDefault( + GFGetModuleID(), + GFModuleStrDup(QString("gnupg.components.%1").arg(component).toUtf8()), nullptr); auto jsonlized_component_info = @@ -135,9 +149,9 @@ auto ExecuteModule(ModuleEvent *event) -> int { assert(jsonlized_component_info.isObject()); auto component_info = GpgComponentInfo(jsonlized_component_info.object()); - ModuleLogDebug(fmt::format("gpgconf check options ready, component: {}", - component_info.name) - .c_str()); + GFModuleLogDebug(fmt::format("gpgconf check options ready, component: {}", + component_info.name) + .c_str()); if (component_info.name == "gpgme" || component_info.name == "gpgconf") { continue; @@ -146,31 +160,33 @@ auto ExecuteModule(ModuleEvent *event) -> int { auto context = Context{gpgme_version, gpgconf_path, component_info}; const char **argv_0 = - static_cast<const char **>(AllocateMemory(sizeof(const char *) * 2)); + static_cast<const char **>(GFAllocateMemory(sizeof(const char *) * 2)); argv_0[0] = GFModuleStrDup("--list-options"), argv_0[1] = GFModuleStrDup(component_info.name.toUtf8()); exec_contexts.push_back( {gpgconf_path, 2, argv_0, GetGpgDirectoryInfos, &context}); } - ExecuteCommandBatchSync(static_cast<int32_t>(exec_contexts.size()), - exec_contexts.constData()); + GFExecuteCommandBatchSync(static_cast<int32_t>(exec_contexts.size()), + exec_contexts.constData()); - UpsertRTValue(GetModuleID(), "gnupg.gathering_done", "true"); + GFModuleUpsertRTValueBool(GFGetModuleID(), + GFModuleStrDup("gnupg.gathering_done"), 0); - char **event_argv = static_cast<char **>(AllocateMemory(sizeof(char **) * 1)); - event_argv[0] = GFModuleStrDup("true"); + char **event_argv = + static_cast<char **>(GFAllocateMemory(sizeof(char **) * 1)); + event_argv[0] = GFModuleStrDup("0"); - TriggerModuleEventCallback(event, GetModuleID(), 1, event_argv); + GFModuleTriggerModuleEventCallback(event, GFGetModuleID(), 1, event_argv); - ModuleLogDebug("gnupg external info gathering done"); + GFModuleLogDebug("gnupg external info gathering done"); return 0; } -auto DeactiveModule() -> int { return 0; } +auto GFDeactiveModule() -> int { return 0; } -auto UnregisterModule() -> int { - ModuleLogDebug("gnupg info gathering module unregistering"); +auto GFUnregisterModule() -> int { + GFModuleLogDebug("gnupg info gathering module unregistering"); return 0; } @@ -178,19 +194,19 @@ auto CalculateBinaryChacksum(const QString &path) -> std::optional<QString> { // check file info and access rights QFileInfo info(path); if (!info.exists() || !info.isFile() || !info.isReadable()) { - ModuleLogError(fmt::format("get info for file {} error, exists: {}", - info.filePath(), info.exists()) - .c_str()); + GFModuleLogError(fmt::format("get info for file {} error, exists: {}", + info.filePath(), info.exists()) + .c_str()); return {}; } // open and read file QFile f(info.filePath()); if (!f.open(QIODevice::ReadOnly)) { - ModuleLogError(fmt::format("open {} to calculate checksum error: {}", - path.toStdString(), - f.errorString().toStdString()) - .c_str()); + GFModuleLogError(fmt::format("open {} to calculate checksum error: {}", + path.toStdString(), + f.errorString().toStdString()) + .c_str()); return {}; } @@ -201,7 +217,7 @@ auto CalculateBinaryChacksum(const QString &path) -> std::optional<QString> { while (!f.atEnd()) { QByteArray buffer = f.read(buffer_size); if (buffer.isEmpty()) { - ModuleLogError( + GFModuleLogError( fmt::format("error reading file {} during checksum calculation", path.toStdString()) .c_str()); @@ -223,16 +239,16 @@ void GetGpgComponentInfos(void *data, int exit_code, const char *out, auto p_out = QString::fromUtf8(out); auto p_err = QString::fromUtf8(err); - ModuleLogDebug( + GFModuleLogDebug( fmt::format("gpgconf components exit_code: {} process stdout size: {}", exit_code, p_out.size()) .c_str()); if (exit_code != 0) { - ModuleLogError(fmt::format("gpgconf execute error, process stderr: {}, " - "process stdout: {}", - p_err, p_out) - .c_str()); + GFModuleLogError(fmt::format("gpgconf execute error, process stderr: {}, " + "process stdout: {}", + p_err, p_out) + .c_str()); return; } @@ -259,10 +275,12 @@ void GetGpgComponentInfos(void *data, int exit_code, const char *out, auto const jsonlized_gpgme_component_info = c_i_gpgme.Json(); auto const jsonlized_gpgconf_component_info = c_i_gpgconf.Json(); - UpsertRTValue(GetModuleID(), "gnupg.components.gpgme", - QJsonDocument(jsonlized_gpgme_component_info).toJson()); - UpsertRTValue(GetModuleID(), "gnupg.components.gpgconf", - QJsonDocument(jsonlized_gpgconf_component_info).toJson()); + GFModuleUpsertRTValue( + GFGetModuleID(), GFModuleStrDup("gnupg.components.gpgme"), + GFModuleStrDup(QJsonDocument(jsonlized_gpgme_component_info).toJson())); + GFModuleUpsertRTValue( + GFGetModuleID(), GFModuleStrDup("gnupg.components.gpgconf"), + GFModuleStrDup(QJsonDocument(jsonlized_gpgconf_component_info).toJson())); auto line_split_list = p_out.split("\n"); @@ -282,7 +300,7 @@ void GetGpgComponentInfos(void *data, int exit_code, const char *out, auto binary_checksum = CalculateBinaryChacksum(component_path); - ModuleLogDebug( + GFModuleLogDebug( fmt::format("gnupg component name: {} desc: {} checksum: {} path: {} ", component_name, component_desc, binary_checksum.has_value() ? binary_checksum.value() : "/", @@ -292,20 +310,24 @@ void GetGpgComponentInfos(void *data, int exit_code, const char *out, QString version = "/"; if (component_name == "gpg") { - version = - RetrieveRTValueOrDefault("core", "gpgme.ctx.gnupg_version", "2.0.0"); + version = GFModuleRetrieveRTValueOrDefault( + GFModuleStrDup("core"), GFModuleStrDup("gpgme.ctx.gnupg_version"), + GFModuleStrDup("2.0.0")); } if (component_name == "gpg-agent") { - UpsertRTValue(GetModuleID(), "gnupg.gpg_agent_path", - QString(component_path).toUtf8()); + GFModuleUpsertRTValue(GFGetModuleID(), + GFModuleStrDup("gnupg.gpg_agent_path"), + GFModuleStrDup(QString(component_path).toUtf8())); } if (component_name == "dirmngr") { - UpsertRTValue(GetModuleID(), "gnupg.dirmngr_path", - QString(component_path).toUtf8()); + GFModuleUpsertRTValue(GFGetModuleID(), + GFModuleStrDup("gnupg.dirmngr_path"), + GFModuleStrDup(QString(component_path).toUtf8())); } if (component_name == "keyboxd") { - UpsertRTValue(GetModuleID(), "gnupg.keyboxd_path", - QString(component_path).toUtf8()); + GFModuleUpsertRTValue(GFGetModuleID(), + GFModuleStrDup("gnupg.keyboxd_path"), + GFModuleStrDup(QString(component_path).toUtf8())); } { @@ -319,14 +341,16 @@ void GetGpgComponentInfos(void *data, int exit_code, const char *out, : QString("/")); auto const jsonlized_component_info = c_i.Json(); - UpsertRTValue(GetModuleID(), - QString("gnupg.components.%1").arg(component_name).toUtf8(), - QJsonDocument(jsonlized_component_info).toJson()); + GFModuleUpsertRTValue( + GFGetModuleID(), + GFModuleStrDup( + QString("gnupg.components.%1").arg(component_name).toUtf8()), + GFModuleStrDup(QJsonDocument(jsonlized_component_info).toJson())); component_infos.push_back(c_i); } - ModuleLogDebug("load gnupg component info actually done."); + GFModuleLogDebug("load gnupg component info actually done."); } } @@ -340,7 +364,7 @@ void GetGpgDirectoryInfos(void *, int exit_code, const char *out, for (const auto &line : line_split_list) { auto info_split_list = line.split(":"); - ModuleLogDebug( + GFModuleLogDebug( fmt::format("gpgconf direcrotries info line: {} info size: {}", line, info_split_list.size()) .c_str()); @@ -357,13 +381,15 @@ void GetGpgDirectoryInfos(void *, int exit_code, const char *out, // record gnupg home path if (configuration_name == "homedir") { - UpsertRTValue(GetModuleID(), "gnupg.home_path", - configuration_value.toUtf8()); + GFModuleUpsertRTValue(GFGetModuleID(), GFModuleStrDup("gnupg.home_path"), + GFModuleStrDup(configuration_value.toUtf8())); } - UpsertRTValue(GetModuleID(), - QString("gnupg.dirs.%1").arg(configuration_name).toUtf8(), - configuration_value.toUtf8()); + GFModuleUpsertRTValue( + GFGetModuleID(), + GFModuleStrDup( + QString("gnupg.dirs.%1").arg(configuration_name).toUtf8()), + GFModuleStrDup(configuration_value.toUtf8())); } } @@ -375,7 +401,7 @@ void GetGpgOptionInfos(void *data, int exit_code, const char *out, auto p_err = QString::fromUtf8(err); auto *context = reinterpret_cast<Context *>(data); - ModuleLogDebug( + GFModuleLogDebug( fmt::format("gpgconf {} avaliable options exit_code: {} process stdout " "size: {} ", context->component_info.name, exit_code, p_out.size()) @@ -388,7 +414,7 @@ void GetGpgOptionInfos(void *data, int exit_code, const char *out, for (const auto &line : line_split_list) { auto info_split_list = line.split(":"); - ModuleLogDebug( + GFModuleLogDebug( fmt::format("component {} avaliable options line: {} info size: {}", context->component_info.name, line, info_split_list.size()) .c_str()); @@ -422,12 +448,13 @@ void GetGpgOptionInfos(void *data, int exit_code, const char *out, info.value = option_value; auto const jsonlized_option_info = info.Json(); - UpsertRTValue(GetModuleID(), - QString("gnupg.components.%1.options.%2") - .arg(context->component_info.name) - .arg(option_name) - .toUtf8(), - QJsonDocument(jsonlized_option_info).toJson()); + GFModuleUpsertRTValue( + GFGetModuleID(), + GFModuleStrDup(QString("gnupg.components.%1.options.%2") + .arg(context->component_info.name) + .arg(option_name) + .toUtf8()), + GFModuleStrDup(QJsonDocument(jsonlized_option_info).toJson())); options_infos.push_back(info); } } diff --git a/src/module/integrated/gnupg_info_gathering_module/GnuPGInfoGatheringModule.h b/src/module/integrated/gnupg_info_gathering_module/GnuPGInfoGatheringModule.h index 44adbab0..35ee4ac3 100644 --- a/src/module/integrated/gnupg_info_gathering_module/GnuPGInfoGatheringModule.h +++ b/src/module/integrated/gnupg_info_gathering_module/GnuPGInfoGatheringModule.h @@ -28,24 +28,29 @@ #pragma once -#include "GpgFrontendModuleExport.h" -#include "module/sdk/Module.h" +#include <GFSDKModule.h> + +#include "GFModuleExport.h" extern "C" { -auto GF_MODULE_EXPORT GetModuleID() -> const char *; +auto GF_MODULE_EXPORT GFGetModuleGFSDKVersion() -> const char *; + +auto GF_MODULE_EXPORT GFGetModuleQtEnvVersion() -> const char *; + +auto GF_MODULE_EXPORT GFGetModuleID() -> const char *; -auto GF_MODULE_EXPORT GetModuleVersion() -> const char *; +auto GF_MODULE_EXPORT GFGetModuleVersion() -> const char *; -auto GF_MODULE_EXPORT GetModuleMetaData() -> ModuleMetaData *; +auto GF_MODULE_EXPORT GFGetModuleMetaData() -> GFModuleMetaData *; -auto GF_MODULE_EXPORT RegisterModule() -> int; +auto GF_MODULE_EXPORT GFRegisterModule() -> int; -auto GF_MODULE_EXPORT ActiveModule() -> int; +auto GF_MODULE_EXPORT GFActiveModule() -> int; -auto GF_MODULE_EXPORT ExecuteModule(ModuleEvent *) -> int; +auto GF_MODULE_EXPORT GFExecuteModule(GFModuleEvent *) -> int; -auto GF_MODULE_EXPORT DeactiveModule() -> int; +auto GF_MODULE_EXPORT GFDeactiveModule() -> int; -auto GF_MODULE_EXPORT UnregisterModule() -> int; +auto GF_MODULE_EXPORT GFUnregisterModule() -> int; }; diff --git a/src/module/integrated/gnupg_info_gathering_module/GpgInfo.cpp b/src/module/integrated/gnupg_info_gathering_module/GpgInfo.cpp index 2aa9c455..680f4a8a 100644 --- a/src/module/integrated/gnupg_info_gathering_module/GpgInfo.cpp +++ b/src/module/integrated/gnupg_info_gathering_module/GpgInfo.cpp @@ -26,7 +26,7 @@ * */ -#include "module/integrated/gnupg_info_gathering_module/GpgInfo.h" +#include "GpgInfo.h" GpgOptionsInfo::GpgOptionsInfo(const QJsonObject &j) { if (const auto v = j["name"]; v.isString()) name = v.toString(); diff --git a/src/module/integrated/version_checking_module/CMakeLists.txt b/src/module/integrated/version_checking_module/CMakeLists.txt index 232e64a6..ba1ea591 100644 --- a/src/module/integrated/version_checking_module/CMakeLists.txt +++ b/src/module/integrated/version_checking_module/CMakeLists.txt @@ -29,7 +29,7 @@ aux_source_directory(. INTEGRATED_MODULE_SOURCE) # define libgpgfrontend_module add_library(gpgfrontend_version_checking SHARED ${INTEGRATED_MODULE_SOURCE}) -set(_export_file "${CMAKE_CURRENT_SOURCE_DIR}/GpgFrontendModuleExport.h") +set(_export_file "${CMAKE_CURRENT_SOURCE_DIR}/GFModuleExport.h") generate_export_header(gpgfrontend_version_checking BASE_NAME "GF_MODULE" EXPORT_FILE_NAME "${_export_file}") diff --git a/src/module/integrated/version_checking_module/GpgFrontendModuleExport.h b/src/module/integrated/version_checking_module/GFModuleExport.h index 6e02c878..6e02c878 100644 --- a/src/module/integrated/version_checking_module/GpgFrontendModuleExport.h +++ b/src/module/integrated/version_checking_module/GFModuleExport.h diff --git a/src/module/integrated/version_checking_module/SoftwareVersion.cpp b/src/module/integrated/version_checking_module/SoftwareVersion.cpp index 46b05a8a..4e1c2dfa 100644 --- a/src/module/integrated/version_checking_module/SoftwareVersion.cpp +++ b/src/module/integrated/version_checking_module/SoftwareVersion.cpp @@ -28,35 +28,35 @@ #include "SoftwareVersion.h" -#include "core/utils/CommonUtils.h" -#include "module/sdk/Log.h" +#include <GFSDKBasic.h> +#include <GFSDKExtra.h> +#include <GFSDKLog.h> -namespace GpgFrontend::Module::Integrated::VersionCheckingModule { - -auto VersionCheckingModule::SoftwareVersion::NeedUpgrade() const -> bool { - ModuleLogDebug( - fmt::format("compair version current {} latest {}, result {}", - current_version, latest_version, - CompareSoftwareVersion(current_version, latest_version)) +auto SoftwareVersion::NeedUpgrade() const -> bool { + GFModuleLogDebug( + fmt::format( + "compair version current {} latest {}, result {}", current_version, + latest_version, + GFCompareSoftwareVersion(GFModuleStrDup(current_version.toUtf8()), + GFModuleStrDup(latest_version.toUtf8()))) .c_str()); - ModuleLogDebug(fmt::format("load done: {}, pre-release: {}, draft: {}", - loading_done, - latest_prerelease_version_from_remote, - latest_draft_from_remote) - .c_str()); + GFModuleLogDebug(fmt::format("load done: {}, pre-release: {}, draft: {}", + loading_done, + latest_prerelease_version_from_remote, + latest_draft_from_remote) + .c_str()); return loading_done && !latest_prerelease_version_from_remote && !latest_draft_from_remote && - CompareSoftwareVersion(current_version, latest_version) < 0; + GFCompareSoftwareVersion(GFModuleStrDup(current_version.toUtf8()), + GFModuleStrDup(latest_version.toUtf8())) < 0; } -auto VersionCheckingModule::SoftwareVersion::VersionWithdrawn() const -> bool { +auto SoftwareVersion::VersionWithdrawn() const -> bool { return loading_done && !current_version_publish_in_remote && current_version_is_a_prerelease && !current_version_is_drafted; } -auto VersionCheckingModule::SoftwareVersion::CurrentVersionReleased() const - -> bool { +auto SoftwareVersion::CurrentVersionReleased() const -> bool { return loading_done && current_version_publish_in_remote; -} -} // namespace GpgFrontend::Module::Integrated::VersionCheckingModule
\ No newline at end of file +}
\ No newline at end of file diff --git a/src/module/integrated/version_checking_module/SoftwareVersion.h b/src/module/integrated/version_checking_module/SoftwareVersion.h index 43f718fa..f0af8d3e 100644 --- a/src/module/integrated/version_checking_module/SoftwareVersion.h +++ b/src/module/integrated/version_checking_module/SoftwareVersion.h @@ -28,9 +28,6 @@ #pragma once -#include <module/sdk/GpgFrontendModuleSDK.h> - -namespace GpgFrontend::Module::Integrated::VersionCheckingModule { /** * @brief * @@ -53,7 +50,7 @@ struct SoftwareVersion { * @return true * @return false */ - [[nodiscard]] bool InfoValid() const { return loading_done; } + [[nodiscard]] auto InfoValid() const -> bool { return loading_done; } /** * @brief @@ -61,7 +58,7 @@ struct SoftwareVersion { * @return true * @return false */ - [[nodiscard]] bool NeedUpgrade() const; + [[nodiscard]] auto NeedUpgrade() const -> bool; /** * @brief @@ -69,7 +66,7 @@ struct SoftwareVersion { * @return true * @return false */ - [[nodiscard]] bool VersionWithdrawn() const; + [[nodiscard]] auto VersionWithdrawn() const -> bool; /** * @brief @@ -77,9 +74,8 @@ struct SoftwareVersion { * @return true * @return false */ - [[nodiscard]] bool CurrentVersionReleased() const; + [[nodiscard]] auto CurrentVersionReleased() const -> bool; private: - static int version_compare(const QString& a, const QString& b); + static auto version_compare(const QString& a, const QString& b) -> int; }; -} // namespace GpgFrontend::Module::Integrated::VersionCheckingModule diff --git a/src/module/integrated/version_checking_module/VersionCheckTask.cpp b/src/module/integrated/version_checking_module/VersionCheckTask.cpp index eeb0231c..044f81ec 100644 --- a/src/module/integrated/version_checking_module/VersionCheckTask.cpp +++ b/src/module/integrated/version_checking_module/VersionCheckTask.cpp @@ -28,31 +28,29 @@ #include "VersionCheckTask.h" +#include <GFSDKBasic.h> +#include <GFSDKExtra.h> +#include <GFSDKLog.h> + #include <QMetaType> #include <QtNetwork> -#include "core/utils/BuildInfoUtils.h" - -namespace GpgFrontend::Module::Integrated::VersionCheckingModule { - VersionCheckTask::VersionCheckTask() - : Task("version_check_task"), - network_manager_(new QNetworkAccessManager(this)), - current_version_(GetProjectVersion()) { - HoldOnLifeCycle(true); + : network_manager_(new QNetworkAccessManager(this)), + current_version_(GFProjectVersion()) { qRegisterMetaType<SoftwareVersion>("SoftwareVersion"); version_.current_version = current_version_; } auto VersionCheckTask::Run() -> int { - ModuleLogDebug( + GFModuleLogDebug( fmt::format("current project version: {}", current_version_).c_str()); QString latest_version_url = "https://api.github.com/repos/saturneric/gpgfrontend/releases/latest"; QNetworkRequest latest_request(latest_version_url); latest_request.setHeader(QNetworkRequest::UserAgentHeader, - GetHttpRequestUserAgent()); + GFHttpRequestUserAgent()); latest_reply_ = network_manager_->get(latest_request); connect(latest_reply_, &QNetworkReply::finished, this, @@ -65,9 +63,9 @@ void VersionCheckTask::slot_parse_latest_version_info() { version_.latest_version = current_version_; version_.loading_done = false; } else if (latest_reply_->error() != QNetworkReply::NoError) { - ModuleLogError(fmt::format("latest version request error: ", - latest_reply_->errorString()) - .c_str()); + GFModuleLogError(fmt::format("latest version request error: ", + latest_reply_->errorString()) + .c_str()); version_.latest_version = current_version_; } else { latest_reply_bytes_ = latest_reply_->readAll(); @@ -80,12 +78,12 @@ void VersionCheckTask::slot_parse_latest_version_info() { auto version_match = re.match(latest_version); if (version_match.hasMatch()) { latest_version = version_match.captured(0); - ModuleLogInfo( + GFModuleLogInfo( fmt::format("latest version from github: {}", latest_version) .c_str()); } else { latest_version = current_version_; - ModuleLogWarn( + GFModuleLogWarn( fmt::format("latest version unknown, set to current version: {}", current_version_) .c_str()); @@ -101,9 +99,9 @@ void VersionCheckTask::slot_parse_latest_version_info() { version_.publish_date = publish_date; version_.release_note = release_note; } else { - ModuleLogWarn(fmt::format("cannot parse data got from github: {}", - latest_reply_bytes_) - .c_str()); + GFModuleLogWarn(fmt::format("cannot parse data got from github: {}", + latest_reply_bytes_) + .c_str()); } } @@ -115,21 +113,20 @@ void VersionCheckTask::slot_parse_latest_version_info() { QString current_version_url = "https://api.github.com/repos/saturneric/gpgfrontend/releases/tags/" + current_version_; - ModuleLogDebug( + GFModuleLogDebug( fmt::format("current version info query url: {}", current_version_url) .c_str()); QNetworkRequest current_request(current_version_url); current_request.setHeader(QNetworkRequest::UserAgentHeader, - GetHttpRequestUserAgent()); + GFHttpRequestUserAgent()); current_reply_ = network_manager_->get(current_request); connect(current_reply_, &QNetworkReply::finished, this, &VersionCheckTask::slot_parse_current_version_info); } catch (...) { - ModuleLogError("current version request create error"); - emit SignalTaskShouldEnd(-1); + GFModuleLogError("current version request create error"); } } @@ -139,9 +136,9 @@ void VersionCheckTask::slot_parse_current_version_info() { version_.loading_done = false; } else if (current_reply_->error() != QNetworkReply::NoError) { - ModuleLogError(fmt::format("current version request network error: {}", - current_reply_->errorString()) - .c_str()); + GFModuleLogError(fmt::format("current version request network error: {}", + current_reply_->errorString()) + .c_str()); // loading done version_.loading_done = true; @@ -159,19 +156,16 @@ void VersionCheckTask::slot_parse_current_version_info() { // loading done version_.loading_done = true; } else { - ModuleLogWarn(fmt::format("cannot parse data got from github: {}", - current_reply_bytes_) - .c_str()); + GFModuleLogWarn(fmt::format("cannot parse data got from github: {}", + current_reply_bytes_) + .c_str()); } } - ModuleLogDebug(fmt::format("current version parse done: {}", - version_.current_version_publish_in_remote) - .c_str()); + GFModuleLogDebug(fmt::format("current version parse done: {}", + version_.current_version_publish_in_remote) + .c_str()); if (current_reply_ != nullptr) current_reply_->deleteLater(); emit SignalUpgradeVersion(version_); - emit SignalTaskShouldEnd(0); } - -} // namespace GpgFrontend::Module::Integrated::VersionCheckingModule diff --git a/src/module/integrated/version_checking_module/VersionCheckTask.h b/src/module/integrated/version_checking_module/VersionCheckTask.h index f5091819..df801570 100644 --- a/src/module/integrated/version_checking_module/VersionCheckTask.h +++ b/src/module/integrated/version_checking_module/VersionCheckTask.h @@ -29,20 +29,17 @@ #pragma once #include <core/thread/Task.h> -#include <module/sdk/GpgFrontendModuleSDK.h> #include "SoftwareVersion.h" class QNetworkReply; class QNetworkAccessManager; -namespace GpgFrontend::Module::Integrated::VersionCheckingModule { - /** * @brief * */ -class VersionCheckTask : public Thread::Task { +class VersionCheckTask : public QObject { Q_OBJECT public: /** @@ -51,22 +48,21 @@ class VersionCheckTask : public Thread::Task { */ VersionCheckTask(); - signals: - /** * @brief * - * @param version + * @return int */ - void SignalUpgradeVersion(SoftwareVersion version); + auto Run() -> int; + + signals: - protected: /** * @brief - * + * @param version */ - auto Run() -> int override; + void SignalUpgradeVersion(SoftwareVersion version); private slots: @@ -91,6 +87,3 @@ class VersionCheckTask : public Thread::Task { QString current_version_; SoftwareVersion version_; }; - -} // namespace GpgFrontend::Module::Integrated::VersionCheckingModule - // GpgFrontend::Module::Custom::IntegradedModule::VersionCheckingModule diff --git a/src/module/integrated/version_checking_module/VersionCheckingModule.cpp b/src/module/integrated/version_checking_module/VersionCheckingModule.cpp index f0ce207b..4ec63792 100644 --- a/src/module/integrated/version_checking_module/VersionCheckingModule.cpp +++ b/src/module/integrated/version_checking_module/VersionCheckingModule.cpp @@ -28,81 +28,130 @@ #include "VersionCheckingModule.h" -#include "Log.h" +#include <GFSDKBasic.h> +#include <GFSDKBuildInfo.h> +#include <GFSDKExtra.h> +#include <GFSDKLog.h> + +#include <QMetaType> +#include <QtNetwork> + #include "SoftwareVersion.h" #include "VersionCheckTask.h" -#include "core/module/Module.h" -#include "core/module/ModuleManager.h" -namespace GpgFrontend::Module::Integrated::VersionCheckingModule { +extern void VersionCheckDone(const SoftwareVersion& version); + +auto GFGetModuleGFSDKVersion() -> const char* { + return GFModuleStrDup(GF_SDK_VERSION_STR); +} + +auto GFGetModuleQtEnvVersion() -> const char* { + return GFModuleStrDup(QT_VERSION_STR); +} + +auto GFGetModuleID() -> const char* { + return GFModuleStrDup( + "com.bktus.gpgfrontend.module.integrated.version-checking"); +} -VersionCheckingModule::VersionCheckingModule() - : Module("com.bktus.gpgfrontend.module.integrated.version-checking", - "1.0.0", - ModuleMetaData{{"description", "try to check gpgfrontend version"}, - {"author", "saturneric"}}) {} +auto GFGetModuleVersion() -> const char* { return GFModuleStrDup("1.0.0"); } -VersionCheckingModule::~VersionCheckingModule() = default; +auto GFGetModuleMetaData() -> GFModuleMetaData* { + auto* p_meta = static_cast<GFModuleMetaData*>( + GFAllocateMemory(sizeof(GFModuleMetaData))); + auto* h_meta = p_meta; -auto VersionCheckingModule::Register() -> int { - ModuleLogInfo("version checking module registering"); - listenEvent("APPLICATION_LOADED"); - listenEvent("CHECK_APPLICATION_VERSION"); + p_meta->key = "Description"; + p_meta->value = "Try checking gpgfrontend version"; + p_meta->next = static_cast<GFModuleMetaData*>( + GFAllocateMemory(sizeof(GFModuleMetaData))); + p_meta = p_meta->next; + p_meta->key = "Author"; + p_meta->value = "Saturneric"; + p_meta->next = nullptr; + + return h_meta; +} + +auto GFRegisterModule() -> int { + GFModuleLogInfo("version checking module registering"); return 0; } -auto VersionCheckingModule::Active() -> int { - ModuleLogInfo("version checking module activating"); +auto GFActiveModule() -> int { + GFModuleLogInfo("version checking module activating"); + + GFModuleListenEvent(GFGetModuleID(), GFModuleStrDup("APPLICATION_LOADED")); + GFModuleListenEvent(GFGetModuleID(), + GFModuleStrDup("CHECK_APPLICATION_VERSION")); return 0; } -auto VersionCheckingModule::Exec(EventRefrernce event) -> int { - ModuleLogInfo(fmt::format("version checking module executing, event id: {}", - event->GetIdentifier()) - .c_str()); +auto GFExecuteModule(GFModuleEvent* event) -> int { + GFModuleLogInfo( + fmt::format("version checking module executing, event id: {}", event->id) + .c_str()); auto* task = new VersionCheckTask(); - connect(task, &VersionCheckTask::SignalUpgradeVersion, this, - &VersionCheckingModule::SignalVersionCheckDone); - connect(this, &VersionCheckingModule::SignalVersionCheckDone, this, - [this, event](SoftwareVersion version) { - SlotVersionCheckDone(std::move(version)); - event->ExecuteCallback(GetModuleIdentifier(), - TransferParams(version.loading_done)); - }); - getTaskRunner()->PostTask(task); + QObject::connect( + task, &VersionCheckTask::SignalUpgradeVersion, QThread::currentThread(), + [event](const SoftwareVersion& version) { + VersionCheckDone(version); + + char** event_argv = + static_cast<char**>(GFAllocateMemory(sizeof(char**) * 1)); + event_argv[0] = GFModuleStrDup("0"); + + GFModuleTriggerModuleEventCallback(event, GFGetModuleID(), 1, + event_argv); + }); + QObject::connect(task, &VersionCheckTask::SignalUpgradeVersion, task, + &QObject::deleteLater); + task->Run(); + return 0; } -auto VersionCheckingModule::Deactive() -> int { return 0; } - -void VersionCheckingModule::SlotVersionCheckDone(SoftwareVersion version) { - ModuleLogDebug("registering software information info to rt"); - - UpsertRTValue(GetModuleIdentifier(), "version.current_version", - version.current_version); - UpsertRTValue(GetModuleIdentifier(), "version.latest_version", - version.latest_version); - UpsertRTValue(GetModuleIdentifier(), "version.current_version_is_drafted", - version.current_version_is_drafted); - UpsertRTValue(GetModuleIdentifier(), - "version.current_version_is_a_prerelease", - version.current_version_is_a_prerelease); - UpsertRTValue(GetModuleIdentifier(), - "version.current_version_publish_in_remote", - version.current_version_publish_in_remote); - UpsertRTValue(GetModuleIdentifier(), - "version.latest_prerelease_version_from_remote", - version.latest_prerelease_version_from_remote); - UpsertRTValue(GetModuleIdentifier(), "version.need_upgrade", - version.NeedUpgrade()); - UpsertRTValue(GetModuleIdentifier(), "version.current_version_released", - version.CurrentVersionReleased()); - UpsertRTValue(GetModuleIdentifier(), "version.current_a_withdrawn_version", - version.VersionWithdrawn()); - UpsertRTValue(GetModuleIdentifier(), "version.loading_done", - version.loading_done); - - ModuleLogDebug("register software information to rt done"); +auto GFDeactiveModule() -> int { return 0; } + +auto GFUnregisterModule() -> int { return 0; } + +void VersionCheckDone(const SoftwareVersion& version) { + GFModuleLogDebug("filling software information info in rt..."); + + GFModuleUpsertRTValue(GFGetModuleID(), + GFModuleStrDup("version.current_version"), + GFModuleStrDup(version.current_version.toUtf8())); + GFModuleUpsertRTValue(GFGetModuleID(), + GFModuleStrDup("version.latest_version"), + GFModuleStrDup(version.latest_version.toUtf8())); + GFModuleUpsertRTValueBool( + GFGetModuleID(), GFModuleStrDup("version.current_version_is_drafted"), + version.current_version_is_drafted ? 1 : 0); + GFModuleUpsertRTValueBool( + GFGetModuleID(), + GFModuleStrDup("version.current_version_is_a_prerelease"), + version.current_version_is_a_prerelease ? 1 : 0); + GFModuleUpsertRTValueBool( + GFGetModuleID(), + GFModuleStrDup("version.current_version_publish_in_remote"), + version.current_version_publish_in_remote ? 1 : 0); + GFModuleUpsertRTValueBool( + GFGetModuleID(), + GFModuleStrDup("version.latest_prerelease_version_from_remote"), + version.latest_prerelease_version_from_remote ? 1 : 0); + GFModuleUpsertRTValueBool(GFGetModuleID(), + GFModuleStrDup("version.need_upgrade"), + version.NeedUpgrade() ? 1 : 0); + GFModuleUpsertRTValueBool(GFGetModuleID(), + GFModuleStrDup("version.current_version_released"), + version.CurrentVersionReleased() ? 1 : 0); + GFModuleUpsertRTValueBool( + GFGetModuleID(), GFModuleStrDup("version.current_a_withdrawn_version"), + version.VersionWithdrawn() ? 1 : 0); + GFModuleUpsertRTValueBool(GFGetModuleID(), + GFModuleStrDup("version.loading_done"), + version.loading_done ? 1 : 0); + + GFModuleLogDebug("software information filled in rt"); } -} // namespace GpgFrontend::Module::Integrated::VersionCheckingModule diff --git a/src/module/integrated/version_checking_module/VersionCheckingModule.h b/src/module/integrated/version_checking_module/VersionCheckingModule.h index 387cdb3c..35ee4ac3 100644 --- a/src/module/integrated/version_checking_module/VersionCheckingModule.h +++ b/src/module/integrated/version_checking_module/VersionCheckingModule.h @@ -28,35 +28,29 @@ #pragma once -#include "GpgFrontendModuleExport.h" -#include "SoftwareVersion.h" -#include "core/module/Module.h" +#include <GFSDKModule.h> +#include "GFModuleExport.h" +extern "C" { -namespace GpgFrontend::Module::Integrated::VersionCheckingModule { +auto GF_MODULE_EXPORT GFGetModuleGFSDKVersion() -> const char *; -class GF_MODULE_EXPORT VersionCheckingModule : public Module { - Q_OBJECT - public: - VersionCheckingModule(); +auto GF_MODULE_EXPORT GFGetModuleQtEnvVersion() -> const char *; - ~VersionCheckingModule() override; +auto GF_MODULE_EXPORT GFGetModuleID() -> const char *; - auto Register() -> int override; +auto GF_MODULE_EXPORT GFGetModuleVersion() -> const char *; - auto Active() -> int override; +auto GF_MODULE_EXPORT GFGetModuleMetaData() -> GFModuleMetaData *; - auto Exec(EventRefrernce) -> int override; +auto GF_MODULE_EXPORT GFRegisterModule() -> int; - auto Deactive() -> int override; +auto GF_MODULE_EXPORT GFActiveModule() -> int; - signals: +auto GF_MODULE_EXPORT GFExecuteModule(GFModuleEvent *) -> int; - void SignalVersionCheckDone(SoftwareVersion); +auto GF_MODULE_EXPORT GFDeactiveModule() -> int; - public slots: - - void SlotVersionCheckDone(SoftwareVersion); +auto GF_MODULE_EXPORT GFUnregisterModule() -> int; }; -} // namespace GpgFrontend::Module::Integrated::VersionCheckingModule diff --git a/src/module/sdk/Log.h b/src/module/sdk/GFSDK.h index 761f7b07..77e019af 100644 --- a/src/module/sdk/Log.h +++ b/src/module/sdk/GFSDK.h @@ -28,17 +28,17 @@ #pragma once -#include "module/sdk/GpgFrontendModuleSDKExport.h" +#include "GFSDKExport.h" extern "C" { -void GPGFRONTEND_MODULE_SDK_EXPORT ModuleLogTrace(const char*); +void GPGFRONTEND_MODULE_SDK_EXPORT GFModuleLogTrace(const char*); -void GPGFRONTEND_MODULE_SDK_EXPORT ModuleLogDebug(const char*); +void GPGFRONTEND_MODULE_SDK_EXPORT GFModuleLogDebug(const char*); -void GPGFRONTEND_MODULE_SDK_EXPORT ModuleLogInfo(const char*); +void GPGFRONTEND_MODULE_SDK_EXPORT GFModuleLogInfo(const char*); -void GPGFRONTEND_MODULE_SDK_EXPORT ModuleLogWarn(const char*); +void GPGFRONTEND_MODULE_SDK_EXPORT GFModuleLogWarn(const char*); -void GPGFRONTEND_MODULE_SDK_EXPORT ModuleLogError(const char*); +void GPGFRONTEND_MODULE_SDK_EXPORT GFModuleLogError(const char*); }
\ No newline at end of file diff --git a/src/module/sdk/Basic.cpp b/src/module/sdk/GFSDKBasic.cpp index ce222fbd..ac0b74d2 100644 --- a/src/module/sdk/Basic.cpp +++ b/src/module/sdk/GFSDKBasic.cpp @@ -26,24 +26,34 @@ * */ -#include "Basic.h" +#include "GFSDKBasic.h" #include "core/function/SecureMemoryAllocator.h" #include "core/function/gpg/GpgCommandExecutor.h" +#include "core/utils/BuildInfoUtils.h" +#include "core/utils/CommonUtils.h" -auto AllocateMemory(uint32_t size) -> void* { +auto GFAllocateMemory(uint32_t size) -> void* { return GpgFrontend::SecureMemoryAllocator::Allocate(size); } -void FreeMemory(void* ptr) { +void GFFreeMemory(void* ptr) { return GpgFrontend::SecureMemoryAllocator::Deallocate(ptr); } -void ExecuteCommandSync(const char* cmd, int32_t argc, const char** argv, - CommandExeucteCallback cb, void* data) { +auto GFProjectVersion() -> const char* { + return GpgFrontend::GFStrDup(GpgFrontend::GetProjectVersion()); +} + +auto GFQtEnvVersion() -> const char* { + return GpgFrontend::GFStrDup(QT_VERSION_STR); +} + +void GFExecuteCommandSync(const char* cmd, int32_t argc, const char** argv, + GFCommandExeucteCallback cb, void* data) { QStringList args; for (int i = 0; i < argc; i++) { - args.append(QString::fromUtf8(argv[i])); + args.append(GpgFrontend::GFUnStrDup(argv[i])); } GpgFrontend::GpgCommandExecutor::ExecuteContext context{ @@ -54,8 +64,8 @@ void ExecuteCommandSync(const char* cmd, int32_t argc, const char** argv, GpgFrontend::GpgCommandExecutor::ExecuteSync(context); } -void ExecuteCommandBatchSync(int32_t context_size, - const CommandExecuteContext* context) { +void GFExecuteCommandBatchSync(int32_t context_size, + const GFCommandExecuteContext* context) { QList<GpgFrontend::GpgCommandExecutor::ExecuteContext> contexts; for (int i = 0; i < context_size; i++) { @@ -64,7 +74,7 @@ void ExecuteCommandBatchSync(int32_t context_size, QStringList args; const char** argv = exec_context.argv; for (int j = 0; j < exec_context.argc; j++) { - args.append(QString::fromUtf8(argv[j])); + args.append(GpgFrontend::GFUnStrDup(argv[j])); } contexts.append( @@ -81,7 +91,7 @@ void ExecuteCommandBatchSync(int32_t context_size, auto GPGFRONTEND_MODULE_SDK_EXPORT GFModuleStrDup(const char* src) -> char* { auto len = strlen(src); - char* dst = static_cast<char*>(AllocateMemory((len + 1) * sizeof(char))); + char* dst = static_cast<char*>(GFAllocateMemory((len + 1) * sizeof(char))); memcpy(dst, src, len); dst[len] = '\0'; diff --git a/src/module/sdk/Basic.h b/src/module/sdk/GFSDKBasic.h index 123b3783..ad6302d0 100644 --- a/src/module/sdk/Basic.h +++ b/src/module/sdk/GFSDKBasic.h @@ -28,63 +28,77 @@ #pragma once -#include "GpgFrontendModuleSDKExport.h" +#include <stdint.h> + +#include "GFSDKExport.h" extern "C" { -using CommandExeucteCallback = void (*)(void* data, int errcode, - const char* out, const char* err); +using GFCommandExeucteCallback = void (*)(void* data, int errcode, + const char* out, const char* err); -using CommandExecuteContext = struct { +using GFCommandExecuteContext = struct { const char* cmd; int32_t argc; const char** argv; - CommandExeucteCallback cb; + GFCommandExeucteCallback cb; void* data; }; /** - * @brief - * - * @param size - * @return void* + * @brief + * + * @param size + * @return void* + */ +auto GPGFRONTEND_MODULE_SDK_EXPORT GFAllocateMemory(uint32_t size) -> void*; + +/** + * @brief + * + * @return const char* + */ +auto GPGFRONTEND_MODULE_SDK_EXPORT GFProjectVersion() -> const char*; + +/** + * @brief + * + * @return const char* */ -auto GPGFRONTEND_MODULE_SDK_EXPORT AllocateMemory(uint32_t size) -> void*; +auto GPGFRONTEND_MODULE_SDK_EXPORT GFQtEnvVersion() -> const char*; /** - * @brief - * + * @brief + * */ -void GPGFRONTEND_MODULE_SDK_EXPORT FreeMemory(void*); +void GPGFRONTEND_MODULE_SDK_EXPORT GFFreeMemory(void*); /** - * @brief - * - * @param cmd - * @param argc - * @param argv - * @param cb - * @param data + * @brief + * + * @param cmd + * @param argc + * @param argv + * @param cb + * @param data */ -void GPGFRONTEND_MODULE_SDK_EXPORT ExecuteCommandSync(const char* cmd, - int32_t argc, - const char** argv, - CommandExeucteCallback cb, - void* data); +void GPGFRONTEND_MODULE_SDK_EXPORT +GFExecuteCommandSync(const char* cmd, int32_t argc, const char** argv, + GFCommandExeucteCallback cb, void* data); /** - * @brief - * - * @param context_size - * @param context + * @brief + * + * @param context_size + * @param context */ -void GPGFRONTEND_MODULE_SDK_EXPORT ExecuteCommandBatchSync( - int32_t context_size, const CommandExecuteContext* context); +void GPGFRONTEND_MODULE_SDK_EXPORT GFExecuteCommandBatchSync( + int32_t context_size, const GFCommandExecuteContext* context); /** - * @brief - * - * @return char* + * @brief + * + * @return char* */ auto GPGFRONTEND_MODULE_SDK_EXPORT GFModuleStrDup(const char*) -> char*; }
\ No newline at end of file diff --git a/src/module/sdk/GpgFrontendModuleSDK.h b/src/module/sdk/GFSDKBuildInfo.h index 97769462..aea49f03 100644 --- a/src/module/sdk/GpgFrontendModuleSDK.h +++ b/src/module/sdk/GFSDKBuildInfo.h @@ -28,6 +28,9 @@ #pragma once -#include <core/module/GpgFrontendModuleSystem.h> -#include <module/sdk/GpgFrontendModuleSDKExport.h> -#include <module/sdk/Log.h>
\ No newline at end of file +#define GF_SDK_VERSION_MAJOR "2" +#define GF_SDK_VERSION_MINOR "1" +#define GF_SDK_VERSION_PATCH "2" + +#define GF_SDK_VERSION_STR \ + GF_SDK_VERSION_MAJOR "." GF_SDK_VERSION_MINOR "." GF_SDK_VERSION_PATCH diff --git a/src/module/sdk/GFSDKBuildInfo.h.in b/src/module/sdk/GFSDKBuildInfo.h.in new file mode 100644 index 00000000..508c35d4 --- /dev/null +++ b/src/module/sdk/GFSDKBuildInfo.h.in @@ -0,0 +1,36 @@ +/** + * Copyright (C) 2021 Saturneric <[email protected]> + * + * This file is part of GpgFrontend. + * + * GpgFrontend is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GpgFrontend is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>. + * + * The initial version of the source code is inherited from + * the gpg4usb project, which is under GPL-3.0-or-later. + * + * All the source code of GpgFrontend was modified and released by + * Saturneric <[email protected]> starting on May 12, 2021. + * + * SPDX-License-Identifier: GPL-3.0-or-later + * + */ + +#pragma once + +#define GF_SDK_VERSION_MAJOR "@CMAKE_PROJECT_VERSION_MAJOR@" +#define GF_SDK_VERSION_MINOR "@CMAKE_PROJECT_VERSION_MINOR@" +#define GF_SDK_VERSION_PATCH "@CMAKE_PROJECT_VERSION_PATCH@" + +#define GF_SDK_VERSION_STR \ + GF_SDK_VERSION_MAJOR "." GF_SDK_VERSION_MINOR "." GF_SDK_VERSION_PATCH
\ No newline at end of file diff --git a/src/module/sdk/GpgFrontendModuleSDKExport.h b/src/module/sdk/GFSDKExport.h index a62168bc..a62168bc 100644 --- a/src/module/sdk/GpgFrontendModuleSDKExport.h +++ b/src/module/sdk/GFSDKExport.h diff --git a/src/module/sdk/GFSDKExtra.cpp b/src/module/sdk/GFSDKExtra.cpp new file mode 100644 index 00000000..bbfa8575 --- /dev/null +++ b/src/module/sdk/GFSDKExtra.cpp @@ -0,0 +1,42 @@ +/** + * Copyright (C) 2021 Saturneric <[email protected]> + * + * This file is part of GpgFrontend. + * + * GpgFrontend is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GpgFrontend is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>. + * + * The initial version of the source code is inherited from + * the gpg4usb project, which is under GPL-3.0-or-later. + * + * All the source code of GpgFrontend was modified and released by + * Saturneric <[email protected]> starting on May 12, 2021. + * + * SPDX-License-Identifier: GPL-3.0-or-later + * + */ + +#include "GFSDKExtra.h" + +#include "core/utils/BuildInfoUtils.h" +#include "core/utils/CommonUtils.h" + +auto GFCompareSoftwareVersion(const char *current_version, + const char *latest_version) -> int { + return GpgFrontend::GFCompareSoftwareVersion( + GpgFrontend::GFUnStrDup(current_version), + GpgFrontend::GFUnStrDup(latest_version)); +} +auto GFHttpRequestUserAgent() -> const char * { + return GpgFrontend::GFStrDup(GpgFrontend::GetHttpRequestUserAgent()); +}
\ No newline at end of file diff --git a/src/module/sdk/GFSDKExtra.h b/src/module/sdk/GFSDKExtra.h new file mode 100644 index 00000000..3d7f4226 --- /dev/null +++ b/src/module/sdk/GFSDKExtra.h @@ -0,0 +1,39 @@ +/** + * Copyright (C) 2021 Saturneric <[email protected]> + * + * This file is part of GpgFrontend. + * + * GpgFrontend is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GpgFrontend is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>. + * + * The initial version of the source code is inherited from + * the gpg4usb project, which is under GPL-3.0-or-later. + * + * All the source code of GpgFrontend was modified and released by + * Saturneric <[email protected]> starting on May 12, 2021. + * + * SPDX-License-Identifier: GPL-3.0-or-later + * + */ + +#pragma once + +#include "GFSDKExport.h" + +extern "C" { + +auto GPGFRONTEND_MODULE_SDK_EXPORT GFCompareSoftwareVersion( + const char *current_version, const char *latest_version) -> int; + +auto GPGFRONTEND_MODULE_SDK_EXPORT GFHttpRequestUserAgent() -> const char *; +}
\ No newline at end of file diff --git a/src/module/sdk/Gpg.cpp b/src/module/sdk/GFSDKGpg.cpp index 63859763..63859763 100644 --- a/src/module/sdk/Gpg.cpp +++ b/src/module/sdk/GFSDKGpg.cpp diff --git a/src/module/sdk/Gpg.h b/src/module/sdk/GFSDKGpg.h index 8823bfc5..8823bfc5 100644 --- a/src/module/sdk/Gpg.h +++ b/src/module/sdk/GFSDKGpg.h diff --git a/src/module/sdk/Log.cpp b/src/module/sdk/GFSDKLog.cpp index e7448973..603cc325 100644 --- a/src/module/sdk/Log.cpp +++ b/src/module/sdk/GFSDKLog.cpp @@ -26,7 +26,7 @@ * */ -#include "Log.h" +#include "GFSDKLog.h" #include "core/utils/LogUtils.h" @@ -36,12 +36,12 @@ #define MODULE_LOG_WARN(...) GF_LOG_WARN("module", __VA_ARGS__) #define MODULE_LOG_ERROR(...) GF_LOG_ERROR("module", __VA_ARGS__) -void ModuleLogTrace(const char* l) { MODULE_LOG_TRACE(l); } +void GFModuleLogTrace(const char* l) { MODULE_LOG_TRACE(l); } -void ModuleLogDebug(const char* l) { MODULE_LOG_DEBUG(l); } +void GFModuleLogDebug(const char* l) { MODULE_LOG_DEBUG(l); } -void ModuleLogInfo(const char* l) { MODULE_LOG_INFO(l); } +void GFModuleLogInfo(const char* l) { MODULE_LOG_INFO(l); } -void ModuleLogWarn(const char* l) { MODULE_LOG_WARN(l); } +void GFModuleLogWarn(const char* l) { MODULE_LOG_WARN(l); } -void ModuleLogError(const char* l) { MODULE_LOG_ERROR(l); } +void GFModuleLogError(const char* l) { MODULE_LOG_ERROR(l); } diff --git a/src/module/sdk/GFSDKLog.h b/src/module/sdk/GFSDKLog.h new file mode 100644 index 00000000..77e019af --- /dev/null +++ b/src/module/sdk/GFSDKLog.h @@ -0,0 +1,44 @@ +/** + * Copyright (C) 2021 Saturneric <[email protected]> + * + * This file is part of GpgFrontend. + * + * GpgFrontend is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GpgFrontend is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>. + * + * The initial version of the source code is inherited from + * the gpg4usb project, which is under GPL-3.0-or-later. + * + * All the source code of GpgFrontend was modified and released by + * Saturneric <[email protected]> starting on May 12, 2021. + * + * SPDX-License-Identifier: GPL-3.0-or-later + * + */ + +#pragma once + +#include "GFSDKExport.h" + +extern "C" { + +void GPGFRONTEND_MODULE_SDK_EXPORT GFModuleLogTrace(const char*); + +void GPGFRONTEND_MODULE_SDK_EXPORT GFModuleLogDebug(const char*); + +void GPGFRONTEND_MODULE_SDK_EXPORT GFModuleLogInfo(const char*); + +void GPGFRONTEND_MODULE_SDK_EXPORT GFModuleLogWarn(const char*); + +void GPGFRONTEND_MODULE_SDK_EXPORT GFModuleLogError(const char*); +}
\ No newline at end of file diff --git a/src/module/sdk/GFSDKModule.cpp b/src/module/sdk/GFSDKModule.cpp new file mode 100644 index 00000000..1eea578a --- /dev/null +++ b/src/module/sdk/GFSDKModule.cpp @@ -0,0 +1,98 @@ +/** + * Copyright (C) 2021 Saturneric <[email protected]> + * + * This file is part of GpgFrontend. + * + * GpgFrontend is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GpgFrontend is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>. + * + * The initial version of the source code is inherited from + * the gpg4usb project, which is under GPL-3.0-or-later. + * + * All the source code of GpgFrontend was modified and released by + * Saturneric <[email protected]> starting on May 12, 2021. + * + * SPDX-License-Identifier: GPL-3.0-or-later + * + */ + +#include "GFSDKModule.h" + +#include <core/module/ModuleManager.h> +#include <core/utils/CommonUtils.h> + +#include "GFSDKBasic.h" + +void GFModuleListenEvent(const char *module_id, const char *event_id) { + return GpgFrontend::Module::ModuleManager::GetInstance().ListenEvent( + GpgFrontend::GFUnStrDup(module_id).toLower(), + GpgFrontend::GFUnStrDup(event_id).toUpper()); +} + +auto GFModuleRetrieveRTValueOrDefault(const char *namespace_, const char *key, + const char *default_value) -> const + char * { + return GpgFrontend::GFStrDup( + GpgFrontend::Module::RetrieveRTValueTypedOrDefault( + GpgFrontend::GFUnStrDup(namespace_), GpgFrontend::GFUnStrDup(key), + GpgFrontend::GFUnStrDup(default_value))); +} + +void GFModuleUpsertRTValue(const char *namespace_, const char *key, + const char *vaule) { + GpgFrontend::Module::UpsertRTValue( + GpgFrontend::GFUnStrDup(namespace_).toLower(), + GpgFrontend::GFUnStrDup(key).toLower(), GpgFrontend::GFUnStrDup(vaule)); +} + +void GFModuleUpsertRTValueBool(const char *namespace_, const char *key, + int value) { + GpgFrontend::Module::UpsertRTValue( + GpgFrontend::GFUnStrDup(namespace_).toLower(), + GpgFrontend::GFUnStrDup(key).toLower(), value != 0); +} + +auto GFModuleListRTChildKeys(const char *namespace_, const char *key, + char ***child_keys) -> int32_t { + *child_keys = nullptr; + auto keys = GpgFrontend::Module::ListRTChildKeys( + GpgFrontend::GFUnStrDup(namespace_).toLower(), + GpgFrontend::GFUnStrDup(key).toLower()); + + if (keys.empty()) return 0; + + *child_keys = + static_cast<char **>(GFAllocateMemory(sizeof(char **) * keys.size())); + + for (int i = 0; i < keys.size(); i++) { + (*child_keys)[i] = GpgFrontend::GFStrDup(keys[i]); + } + + return static_cast<int32_t>(keys.size()); +} + +void GFModuleTriggerModuleEventCallback(GFModuleEvent *module_event, + const char *module_id, int argc, + char **argv) { + auto data_object = GpgFrontend::TransferParams(); + for (int i = 0; i < argc; i++) { + data_object->AppendObject(GpgFrontend::GFUnStrDup(argv[i])); + } + + auto event = GpgFrontend::Module::ModuleManager::GetInstance().SearchEvent( + GpgFrontend::GFUnStrDup(module_event->triggger_id).toLower()); + if (!event) return; + + event.value()->ExecuteCallback(GpgFrontend::GFUnStrDup(module_id), + data_object); +}
\ No newline at end of file diff --git a/src/module/sdk/GFSDKModule.h b/src/module/sdk/GFSDKModule.h new file mode 100644 index 00000000..0ae23cf3 --- /dev/null +++ b/src/module/sdk/GFSDKModule.h @@ -0,0 +1,92 @@ +/** + * Copyright (C) 2021 Saturneric <[email protected]> + * + * This file is part of GpgFrontend. + * + * GpgFrontend is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GpgFrontend is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>. + * + * The initial version of the source code is inherited from + * the gpg4usb project, which is under GPL-3.0-or-later. + * + * All the source code of GpgFrontend was modified and released by + * Saturneric <[email protected]> starting on May 12, 2021. + * + * SPDX-License-Identifier: GPL-3.0-or-later + * + */ + +#pragma once + +#include "GFSDKExport.h" + +extern "C" { + +struct GFModuleMetaData { + const char *key; + const char *value; + GFModuleMetaData *next; +}; + +struct GFModuleEventParam { + const char *name; + const char *value; + GFModuleEventParam *next; +}; + +struct GFModuleEvent { + const char *id; + const char *triggger_id; + GFModuleEventParam *params; +}; + +using GFModuleAPIGetModuleGFSDKVersion = auto (*)() -> const char *; + +using GFModuleAPIGetModuleQtEnvVersion = auto (*)() -> const char *; + +using GFModuleAPIGetModuleID = auto (*)() -> const char *; + +using GFModuleAPIGetModuleVersion = auto (*)() -> const char *; + +using GFModuleAPIGetModuleMetaData = auto (*)() -> GFModuleMetaData *; + +using GFModuleAPIRegisterModule = auto (*)() -> int; + +using GFModuleAPIActivateModule = auto (*)() -> int; + +using GFModuleAPIExecuteModule = auto (*)(GFModuleEvent *) -> int; + +using GFModuleAPIDeactivateModule = auto (*)() -> int; + +using GFModuleAPIUnregisterModule = auto (*)() -> int; + +void GPGFRONTEND_MODULE_SDK_EXPORT GFModuleListenEvent(const char *module_id, + const char *event_id); + +auto GPGFRONTEND_MODULE_SDK_EXPORT GFModuleRetrieveRTValueOrDefault( + const char *namespace_, const char *key, const char *default_value) -> const + char *; + +void GPGFRONTEND_MODULE_SDK_EXPORT GFModuleUpsertRTValue(const char *namespace_, + const char *key, + const char *vaule); + +void GPGFRONTEND_MODULE_SDK_EXPORT +GFModuleUpsertRTValueBool(const char *namespace_, const char *key, int value); + +auto GPGFRONTEND_MODULE_SDK_EXPORT GFModuleListRTChildKeys( + const char *namespace_, const char *key, char ***child_keys) -> int32_t; + +void GPGFRONTEND_MODULE_SDK_EXPORT GFModuleTriggerModuleEventCallback( + GFModuleEvent *event, const char *module_id, int argc, char **argv); +};
\ No newline at end of file diff --git a/src/module/sdk/UI.cpp b/src/module/sdk/GFSDKUI.cpp index 63859763..63859763 100644 --- a/src/module/sdk/UI.cpp +++ b/src/module/sdk/GFSDKUI.cpp diff --git a/src/module/sdk/UI.h b/src/module/sdk/GFSDKUI.h index 0702632a..0702632a 100644 --- a/src/module/sdk/UI.h +++ b/src/module/sdk/GFSDKUI.h diff --git a/src/module/sdk/Utils.cpp b/src/module/sdk/GFSDKUtils.cpp index 8e9dbefb..fcb510e3 100644 --- a/src/module/sdk/Utils.cpp +++ b/src/module/sdk/GFSDKUtils.cpp @@ -26,4 +26,4 @@ * */ -#include "Utils.h"
\ No newline at end of file +#include "GFSDKUtils.h"
\ No newline at end of file diff --git a/src/module/sdk/Utils.h b/src/module/sdk/GFSDKUtils.h index 7d72e9ee..7d72e9ee 100644 --- a/src/module/sdk/Utils.h +++ b/src/module/sdk/GFSDKUtils.h diff --git a/src/module/sdk/Module.cpp b/src/module/sdk/Module.cpp deleted file mode 100644 index c69f6e5c..00000000 --- a/src/module/sdk/Module.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Copyright (C) 2021 Saturneric <[email protected]> - * - * This file is part of GpgFrontend. - * - * GpgFrontend is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * GpgFrontend is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>. - * - * The initial version of the source code is inherited from - * the gpg4usb project, which is under GPL-3.0-or-later. - * - * All the source code of GpgFrontend was modified and released by - * Saturneric <[email protected]> starting on May 12, 2021. - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#include "Module.h" - -#include <core/module/ModuleManager.h> -#include <core/utils/CommonUtils.h> - -#include "Basic.h" - -void ListenEvent(const char *module_id, const char *event_id) { - return GpgFrontend::Module::ModuleManager::GetInstance().ListenEvent( - module_id, event_id); -} - -auto RetrieveRTValueOrDefault(const char *namespace_, const char *key, - const char *default_value) -> const char * { - return GpgFrontend::GFStrDup( - GpgFrontend::Module::RetrieveRTValueTypedOrDefault( - QString::fromUtf8(namespace_), QString::fromUtf8(key), - QString::fromUtf8(default_value))); -} - -void UpsertRTValue(const char *namespace_, const char *key, const char *vaule) { - GpgFrontend::Module::UpsertRTValue(QString::fromUtf8(namespace_), - QString::fromUtf8(key), - QString::fromUtf8(vaule)); -} - -auto ListRTChildKeys(const char *namespace_, const char *key, - char ***child_keys) -> int32_t { - *child_keys = nullptr; - auto keys = GpgFrontend::Module::ListRTChildKeys(namespace_, key); - - if (keys.empty()) return 0; - - *child_keys = - static_cast<char **>(AllocateMemory(sizeof(char **) * keys.size())); - - for (int i = 0; i < keys.size(); i++) { - (*child_keys)[i] = GpgFrontend::GFStrDup(keys[i]); - } - - return static_cast<int32_t>(keys.size()); -} - -void TriggerModuleEventCallback(ModuleEvent *module_event, - const char *module_id, int argc, char **argv) { - auto data_object = GpgFrontend::TransferParams(); - for (int i = 0; i < argc; i++) { - data_object->AppendObject(QString::fromUtf8(argv[i])); - } - - auto event = GpgFrontend::Module::ModuleManager::GetInstance().SearchEvent( - module_event->triggger_id); - if (!event) return; - - event.value()->ExecuteCallback(QString::fromUtf8(module_id), data_object); -}
\ No newline at end of file diff --git a/src/module/sdk/Module.h b/src/module/sdk/Module.h deleted file mode 100644 index b2f9a7ce..00000000 --- a/src/module/sdk/Module.h +++ /dev/null @@ -1,87 +0,0 @@ -/** - * Copyright (C) 2021 Saturneric <[email protected]> - * - * This file is part of GpgFrontend. - * - * GpgFrontend is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * GpgFrontend is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>. - * - * The initial version of the source code is inherited from - * the gpg4usb project, which is under GPL-3.0-or-later. - * - * All the source code of GpgFrontend was modified and released by - * Saturneric <[email protected]> starting on May 12, 2021. - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#pragma once - -#include "GpgFrontendModuleSDKExport.h" - -extern "C" { - -struct GPGFRONTEND_MODULE_SDK_EXPORT ModuleMetaData { - const char *key; - const char *value; - ModuleMetaData *next; -}; - -struct GPGFRONTEND_MODULE_SDK_EXPORT ModuleEventParam { - const char *name; - const char *value; - ModuleEventParam *next; -}; - -struct GPGFRONTEND_MODULE_SDK_EXPORT ModuleEvent { - const char *id; - const char *triggger_id; - ModuleEventParam *params; -}; - -using ModuleAPIGetModuleID = auto (*)() -> const char *; - -using ModuleAPIGetModuleVersion = auto (*)() -> const char *; - -using ModuleAPIGetModuleMetaData = auto (*)() -> ModuleMetaData *; - -using ModuleAPIRegisterModule = auto (*)() -> int; - -using ModuleAPIActivateModule = auto (*)() -> int; - -using ModuleAPIExecuteModule = auto (*)(ModuleEvent *) -> int; - -using ModuleAPIDeactivateModule = auto (*)() -> int; - -using ModuleAPIUnregisterModule = auto (*)() -> int; - -void GPGFRONTEND_MODULE_SDK_EXPORT ListenEvent(const char *module_id, - const char *event_id); - -auto GPGFRONTEND_MODULE_SDK_EXPORT RetrieveRTValueOrDefault( - const char *namespace_, const char *key, const char *default_value) -> const - char *; - -void GPGFRONTEND_MODULE_SDK_EXPORT UpsertRTValue(const char *namespace_, - const char *key, - const char *vaule); - -auto GPGFRONTEND_MODULE_SDK_EXPORT ListRTChildKeys(const char *namespace_, - const char *key, - char ***child_keys) - -> int32_t; - -void GPGFRONTEND_MODULE_SDK_EXPORT TriggerModuleEventCallback( - ModuleEvent *event, const char *module_id, int argc, char **argv); -};
\ No newline at end of file diff --git a/src/ui/dialog/controller/ModuleControllerDialog.cpp b/src/ui/dialog/controller/ModuleControllerDialog.cpp index db177155..71e39502 100644 --- a/src/ui/dialog/controller/ModuleControllerDialog.cpp +++ b/src/ui/dialog/controller/ModuleControllerDialog.cpp @@ -39,7 +39,8 @@ namespace GpgFrontend::UI { ModuleControllerDialog::ModuleControllerDialog(QWidget* parent) : QDialog(parent), ui_(std::make_shared<Ui_ModuleControllerDialog>()), - model_list_view_(new ModuleListView(this)) { + model_list_view_(new ModuleListView(this)), + module_mamager_(&Module::ModuleManager::GetInstance()) { ui_->setupUi(this); model_list_view_->setMinimumWidth(250); @@ -50,11 +51,16 @@ ModuleControllerDialog::ModuleControllerDialog(QWidget* parent) connect(model_list_view_, &ModuleListView::SignalSelectModule, this, &ModuleControllerDialog::slot_load_module_details); - connect(ui_->activateButton, &QPushButton::clicked, this, [=]() { + connect(ui_->activateOrDeactiveButton, &QPushButton::clicked, this, [=]() { auto module_id = model_list_view_->GetCurrentModuleID(); if (module_id.isEmpty()) return; - Module::ModuleManager::GetInstance().ActiveModule(module_id); + if (!module_mamager_->IsModuleActivated(module_id)) { + module_mamager_->ActiveModule(module_id); + } else { + module_mamager_->DeactiveModule(module_id); + } + QTimer::singleShot(1000, [=]() { slot_load_module_details(module_id); }); }); @@ -69,7 +75,7 @@ void ModuleControllerDialog::slot_load_module_details( Module::ModuleIdentifier module_id) { GF_UI_LOG_DEBUG("loading module detailes, module id: {}", module_id); - auto module = Module::ModuleManager::GetInstance().SearchModule(module_id); + auto module = module_mamager_->SearchModule(module_id); ui_->moduleIDLabel->setText(module->GetModuleIdentifier()); @@ -82,10 +88,9 @@ void ModuleControllerDialog::slot_load_module_details( info << tr("Hash") << ": " << module->GetModuleHash() << Qt::endl; info << tr("Path") << ": " << module->GetModulePath() << Qt::endl; - info << tr("Active") << ": " - << (Module::ModuleManager::GetInstance().IsModuleActivated(module_id) - ? tr("True") - : tr("False")) + bool if_activated = module_mamager_->IsModuleActivated(module_id); + + info << tr("Active") << ": " << (if_activated ? tr("True") : tr("False")) << Qt::endl; info << Qt::endl; @@ -100,12 +105,13 @@ void ModuleControllerDialog::slot_load_module_details( info << "# Listening Event" << Qt::endl << Qt::endl; - auto listening_event_ids = - Module::ModuleManager::GetInstance().GetModuleListening(module_id); + auto listening_event_ids = module_mamager_->GetModuleListening(module_id); for (const auto& event_id : listening_event_ids) { info << " - " << event_id << "\n"; } ui_->moduleInfoTextBrowser->setText(buffer); + ui_->activateOrDeactiveButton->setText(if_activated ? tr("Deactivate") + : tr("Activate")); } } // namespace GpgFrontend::UI diff --git a/src/ui/dialog/controller/ModuleControllerDialog.h b/src/ui/dialog/controller/ModuleControllerDialog.h index 59b6cc6b..57444aea 100644 --- a/src/ui/dialog/controller/ModuleControllerDialog.h +++ b/src/ui/dialog/controller/ModuleControllerDialog.h @@ -56,6 +56,7 @@ class ModuleControllerDialog : public QDialog { private: std::shared_ptr<Ui_ModuleControllerDialog> ui_; ///< ModuleListView* model_list_view_; + Module::ModuleManager* module_mamager_; }; } // namespace GpgFrontend::UI diff --git a/src/ui/widgets/ModuleListView.cpp b/src/ui/widgets/ModuleListView.cpp index 05e4c021..41c8b259 100644 --- a/src/ui/widgets/ModuleListView.cpp +++ b/src/ui/widgets/ModuleListView.cpp @@ -35,6 +35,7 @@ namespace GpgFrontend::UI { ModuleListView::ModuleListView(QWidget *parent) : QListView(parent), model_(new QStringListModel(this)) { setModel(model_); + setEditTriggers(QAbstractItemView::NoEditTriggers); load_module_informations(); } diff --git a/ui/ModuleControllerDialog.ui b/ui/ModuleControllerDialog.ui index 7a81d2ca..167cbfe7 100644 --- a/ui/ModuleControllerDialog.ui +++ b/ui/ModuleControllerDialog.ui @@ -16,9 +16,18 @@ <layout class="QVBoxLayout" name="verticalLayout"> <item> <widget class="QTabWidget" name="tabWidget"> + <property name="tabPosition"> + <enum>QTabWidget::North</enum> + </property> + <property name="tabShape"> + <enum>QTabWidget::Rounded</enum> + </property> <property name="currentIndex"> <number>0</number> </property> + <property name="documentMode"> + <bool>false</bool> + </property> <widget class="QWidget" name="registeredModuleTab"> <attribute name="title"> <string>Registered Modules</string> @@ -108,16 +117,16 @@ </widget> </item> <item> - <widget class="QPushButton" name="activateButton"> + <widget class="QPushButton" name="activateOrDeactiveButton"> <property name="text"> <string>Activate</string> </property> </widget> </item> <item> - <widget class="QPushButton" name="deactivateButton"> + <widget class="QPushButton" name="autoActivateButton"> <property name="text"> - <string>Deactivate</string> + <string>Auto Activate</string> </property> </widget> </item> @@ -140,6 +149,11 @@ </item> </layout> </widget> + <widget class="QWidget" name="tab"> + <attribute name="title"> + <string>Trusted Key</string> + </attribute> + </widget> <widget class="QWidget" name="tab_2"> <attribute name="title"> <string>Debugger</string> |