From 38d4578c36860ed084835ec985afb226a4a2be0e Mon Sep 17 00:00:00 2001 From: Maschell Date: Sun, 24 Mar 2024 11:14:35 +0100 Subject: [PATCH] Use latest libwupsbackend version --- Dockerfile | 2 +- src/utils/TcpReceiver.cpp | 46 ++++++++++++++++++++------------------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/Dockerfile b/Dockerfile index 064482d..3b5e2ec 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM ghcr.io/wiiu-env/devkitppc:20231112 COPY --from=ghcr.io/wiiu-env/wiiupluginsystem:0.8.0-dev-20240302-3b5cc2f /artifacts $DEVKITPRO -COPY --from=ghcr.io/wiiu-env/libwupsbackend:20230621 /artifacts $DEVKITPRO +COPY --from=ghcr.io/wiiu-env/libwupsbackend:0.1.3-dev-20240323-9493c4f /artifacts $DEVKITPRO COPY --from=ghcr.io/wiiu-env/librpxloader:20230621 /artifacts $DEVKITPRO COPY --from=ghcr.io/wiiu-env/libnotifications:20230621 /artifacts $DEVKITPRO diff --git a/src/utils/TcpReceiver.cpp b/src/utils/TcpReceiver.cpp index 763d2df..0807f3e 100644 --- a/src/utils/TcpReceiver.cpp +++ b/src/utils/TcpReceiver.cpp @@ -183,39 +183,41 @@ TcpReceiver::eLoadResults TcpReceiver::tryLoadRPX(uint8_t *data, uint32_t fileSi TcpReceiver::eLoadResults TcpReceiver::tryLoadWPS(uint8_t *data, uint32_t fileSize) { if (data[0x7] == 0xCA && data[0x8] == 0xFE && data[0x9] == 0x50 && data[0xA] == 0x4C) { - auto newContainer = WUPSBackend::PluginUtils::getPluginForBuffer((char *) data, fileSize); - if (newContainer) { - auto plugins = WUPSBackend::PluginUtils::getLoadedPlugins(32); - - auto &metaInformation = newContainer.value()->getMetaInformation(); + PluginBackendApiErrorType err; + auto newContainerOpt = WUPSBackend::PluginUtils::getPluginForBuffer((char *) data, fileSize, err); + if (newContainerOpt) { + auto pluginList = WUPSBackend::PluginUtils::getLoadedPlugins(err); + if (err != PLUGIN_BACKEND_API_ERROR_NONE) { + DEBUG_FUNCTION_LINE_ERR("Failed to load plugin list."); + return PLUGIN_PARSE_FAILED; + } + const auto &metaInformation = newContainerOpt->getMetaInformation(); // remove plugins with the same name and author as our new plugin - plugins.erase(std::remove_if(plugins.begin(), plugins.end(), - [metaInformation](auto &plugin) { - return plugin->getMetaInformation()->getName() == metaInformation->getName() && - plugin->getMetaInformation()->getAuthor() == metaInformation->getAuthor(); - }), - plugins.end()); - + pluginList.erase(std::remove_if(pluginList.begin(), pluginList.end(), + [&metaInformation](auto &plugin) { + auto res = plugin.getMetaInformation().getName() == metaInformation.getName() && + plugin.getMetaInformation().getAuthor() == metaInformation.getAuthor(); + return res; + }), + pluginList.end()); // add the new plugin - plugins.push_back(std::move(newContainer.value())); - + pluginList.push_back(std::move(newContainerOpt.value())); #ifdef VERBOSE_DEBUG - for (auto &plugin : plugins) { - DEBUG_FUNCTION_LINE_VERBOSE("name: %s", plugin->getMetaInformation()->getName().c_str()); - DEBUG_FUNCTION_LINE_VERBOSE("author: %s", plugin->getMetaInformation()->getAuthor().c_str()); - DEBUG_FUNCTION_LINE_VERBOSE("handle: %08X", plugin->getPluginData()->getHandle()); + for (const auto &plugin : pluginList) { + DEBUG_FUNCTION_LINE_VERBOSE("name: %s", plugin.getMetaInformation().getName().c_str()); + DEBUG_FUNCTION_LINE_VERBOSE("author: %s", plugin.getMetaInformation().getAuthor().c_str()); + DEBUG_FUNCTION_LINE_VERBOSE("handle: %08X", plugin.getPluginData().getHandle()); DEBUG_FUNCTION_LINE_VERBOSE("===="); } #endif - - if (WUPSBackend::PluginUtils::LoadAndLinkOnRestart(plugins) != 0) { - DEBUG_FUNCTION_LINE_ERR("WUPSBackend::PluginUtils::LoadAndLinkOnRestart failed"); + if ((err = WUPSBackend::PluginUtils::LoadAndLinkOnRestart(pluginList)) != PLUGIN_BACKEND_API_ERROR_NONE) { + DEBUG_FUNCTION_LINE_ERR("WUPSBackend::PluginUtils::LoadAndLinkOnRestart failed. %s", WUPSBackend::GetStatusStr(err)); return PLUGIN_LOAD_LINK_FAILED; } return SUCCESS; } else { - DEBUG_FUNCTION_LINE_ERR("Failed to parse plugin for buffer: %08X size %d", data, fileSize); + DEBUG_FUNCTION_LINE_ERR("Failed to parse plugin for buffer: %08X size %d. Error: %s", data, fileSize, WUPSBackend::GetStatusStr(err)); return PLUGIN_PARSE_FAILED; } }