From c1f5b3336836e15d193582e9b8f3e044f7d8bc1b Mon Sep 17 00:00:00 2001 From: saturneric Date: Thu, 29 Feb 2024 18:15:57 +0800 Subject: feat: add module controller and continue to work on module system 1. speed up building by reducing build info sheader including 2. add module controller 3. continue to work on module system --- src/module/sdk/Module.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'src/module/sdk/Module.cpp') diff --git a/src/module/sdk/Module.cpp b/src/module/sdk/Module.cpp index 36fe7b91..c69f6e5c 100644 --- a/src/module/sdk/Module.cpp +++ b/src/module/sdk/Module.cpp @@ -29,9 +29,9 @@ #include "Module.h" #include +#include #include "Basic.h" -#include "core/utils/CommonUtils.h" void ListenEvent(const char *module_id, const char *event_id) { return GpgFrontend::Module::ModuleManager::GetInstance().ListenEvent( @@ -40,13 +40,16 @@ void ListenEvent(const char *module_id, const char *event_id) { auto RetrieveRTValueOrDefault(const char *namespace_, const char *key, const char *default_value) -> const char * { - return GpgFrontend::Module::RetrieveRTValueTypedOrDefault( - namespace_, key, QString::fromUtf8(default_value)) - .toUtf8(); + 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(namespace_, key, vaule); + GpgFrontend::Module::UpsertRTValue(QString::fromUtf8(namespace_), + QString::fromUtf8(key), + QString::fromUtf8(vaule)); } auto ListRTChildKeys(const char *namespace_, const char *key, @@ -57,15 +60,10 @@ auto ListRTChildKeys(const char *namespace_, const char *key, if (keys.empty()) return 0; *child_keys = - static_cast(AllocateMemory(sizeof(const char **) * keys.size())); + static_cast(AllocateMemory(sizeof(char **) * keys.size())); for (int i = 0; i < keys.size(); i++) { - *child_keys[i] = - static_cast(AllocateMemory(sizeof(char) * keys[i].size() + 1)); - - auto key = keys[i].toUtf8(); - memcpy(reinterpret_cast(*child_keys[i]), key, key.size()); - (*child_keys[i])[key.size()] = '\0'; + (*child_keys)[i] = GpgFrontend::GFStrDup(keys[i]); } return static_cast(keys.size()); -- cgit v1.2.3