From 636ed0095df6eedf27d679dc2190b0d71590b8b3 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Tue, 16 May 2023 11:01:40 +0200 Subject: [PATCH] feat: Added new `imhex/capabilities` network interface --- cmake/build_helpers.cmake | 2 +- lib/external/libwolv | 2 +- .../source/content/communication_interface.cpp | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/cmake/build_helpers.cmake b/cmake/build_helpers.cmake index 6cf73cb2f..ddffa2132 100644 --- a/cmake/build_helpers.cmake +++ b/cmake/build_helpers.cmake @@ -451,7 +451,7 @@ macro(addBundledLibraries) set_property(TARGET libwolv-io PROPERTY POSITION_INDEPENDENT_CODE ON) set_property(TARGET libwolv-hash PROPERTY POSITION_INDEPENDENT_CODE ON) set_property(TARGET libwolv-containers PROPERTY POSITION_INDEPENDENT_CODE ON) - + set_property(TARGET libwolv-net PROPERTY POSITION_INDEPENDENT_CODE ON) set(XDGPP_INCLUDE_DIRS "${EXTERN_LIBS_FOLDER}/xdgpp") set(CURL_USE_MBEDTLS ON) diff --git a/lib/external/libwolv b/lib/external/libwolv index 7fea1070b..113917c44 160000 --- a/lib/external/libwolv +++ b/lib/external/libwolv @@ -1 +1 @@ -Subproject commit 7fea1070bd4c2d6767ac3ca6ececbb312c5a5049 +Subproject commit 113917c4472d61692ac8e8feff922d416efcef1d diff --git a/plugins/builtin/source/content/communication_interface.cpp b/plugins/builtin/source/content/communication_interface.cpp index ae80e4e26..b24235c66 100644 --- a/plugins/builtin/source/content/communication_interface.cpp +++ b/plugins/builtin/source/content/communication_interface.cpp @@ -12,6 +12,24 @@ namespace hex::plugin::builtin { return { }; }); + + ContentRegistry::CommunicationInterface::registerNetworkEndpoint("imhex/capabilities", [](const nlohmann::json &) -> nlohmann::json { + nlohmann::json result; + + result["build"] = { + { "version", IMHEX_VERSION }, + { "commit", GIT_COMMIT_HASH_LONG }, + { "branch", GIT_BRANCH }, + }; + + std::vector commands; + for (const auto&[command, callback] : ContentRegistry::CommunicationInterface::impl::getNetworkEndpoints()) + commands.emplace_back(command); + + result["commands"] = commands; + + return result; + }); } } \ No newline at end of file