diff --git a/Dockerfile b/Dockerfile index 8ec0db0..5b0521e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,8 @@ -FROM ghcr.io/wiiu-env/devkitppc:20230621 +FROM ghcr.io/wiiu-env/devkitppc:20231112 COPY --from=ghcr.io/wiiu-env/libwupsbackend:20230621 /artifacts $DEVKITPRO COPY --from=ghcr.io/wiiu-env/librpxloader:20230621 /artifacts $DEVKITPRO COPY --from=ghcr.io/wiiu-env/wiiupluginsystem:20230719 /artifacts $DEVKITPRO +COPY --from=ghcr.io/wiiu-env/libnotifications:20230621 /artifacts $DEVKITPRO WORKDIR project diff --git a/Makefile b/Makefile index 0479e44..1fbce30 100644 --- a/Makefile +++ b/Makefile @@ -51,7 +51,7 @@ CXXFLAGS += -DDEBUG -DVERBOSE_DEBUG -g CFLAGS += -DDEBUG -DVERBOSE_DEBUG -g endif -LIBS := -lwups -lwut -lwupsbackend -lz -lrpxloader +LIBS := -lwups -lwut -lwupsbackend -lz -lrpxloader -lnotifications #------------------------------------------------------------------------------- # list of directories containing libraries, this must be the top level diff --git a/README.md b/README.md index 69f809e..5fdfe1d 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ 1. Copy the file `wiiload.wps` into `sd:/wiiu/environments/[ENVIRONMENT]/plugins`. 2. Requires the [WiiUPluginLoaderBackend](https://github.com/wiiu-env/WiiUPluginLoaderBackend) in `sd:/wiiu/environments/[ENVIRONMENT]/modules`. 3. Requires the [RPXLoadingModule](https://github.com/wiiu-env/RPXLoadingModule) in `sd:/wiiu/environments/[ENVIRONMENT]/modules`. +4. Requires the [NotificationModule](https://github.com/wiiu-env/NotificationModule) in `sd:/wiiu/environments/[ENVIRONMENT]/modules`. ## Buildflags diff --git a/src/globals.cpp b/src/globals.cpp index a75f836..2e616ac 100644 --- a/src/globals.cpp +++ b/src/globals.cpp @@ -1,4 +1,5 @@ #include "globals.h" -bool gLibRPXLoaderInitDone __attribute__((section(".data"))) = false; -bool gWiiloadServerEnabled __attribute__((section(".data"))) = true; \ No newline at end of file +bool gLibRPXLoaderInitDone __attribute__((section(".data"))) = false; +bool gWiiloadServerEnabled __attribute__((section(".data"))) = true; +bool gNotificationModuleLoaded __attribute__((section(".data"))) = true; \ No newline at end of file diff --git a/src/globals.h b/src/globals.h index 6defe22..a8921bb 100644 --- a/src/globals.h +++ b/src/globals.h @@ -1,4 +1,5 @@ #include extern bool gLibRPXLoaderInitDone; -extern bool gWiiloadServerEnabled; \ No newline at end of file +extern bool gWiiloadServerEnabled; +extern bool gNotificationModuleLoaded; \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 83729f1..0ae37c0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,6 +3,7 @@ #include "utils/TcpReceiver.h" #include "utils/logger.h" #include +#include #include #include #include @@ -28,6 +29,15 @@ INITIALIZE_PLUGIN() { gLibRPXLoaderInitDone = true; } + NotificationModuleStatus res; + if ((res = NotificationModule_InitLibrary()) != NOTIFICATION_MODULE_RESULT_SUCCESS) { + DEBUG_FUNCTION_LINE_ERR("Failed to init NotificationModule"); + gNotificationModuleLoaded = false; + } else { + NotificationModule_SetDefaultValue(NOTIFICATION_MODULE_NOTIFICATION_TYPE_ERROR, NOTIFICATION_MODULE_DEFAULT_OPTION_DURATION_BEFORE_FADE_OUT, 10.0f); + gNotificationModuleLoaded = true; + } + // Open storage to read values WUPSStorageError storageRes = WUPS_OpenStorage(); if (storageRes != WUPS_STORAGE_ERROR_SUCCESS) { diff --git a/src/utils/TcpReceiver.cpp b/src/utils/TcpReceiver.cpp index 7319783..a1e5528 100644 --- a/src/utils/TcpReceiver.cpp +++ b/src/utils/TcpReceiver.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -244,6 +245,10 @@ int32_t TcpReceiver::loadToMemory(int32_t clientSocket, uint32_t ipAddress) { file_path = WUHB_TEMP_FILE_2_EX; } + if (!res) { + NotificationModule_AddErrorNotification("Wiiload plugin: Failed to save .wuhb file to the sd card. Launching will be aborted."); + } + loadedRPX = true; } else if (inflatedData[0x7] == 0xCA && inflatedData[0x8] == 0xFE && inflatedData[0x9] != 0x50 && inflatedData[0xA] != 0x4C) { DEBUG_FUNCTION_LINE("Try to load a .rpx"); @@ -251,6 +256,10 @@ int32_t TcpReceiver::loadToMemory(int32_t clientSocket, uint32_t ipAddress) { res = FSUtils::saveBufferToFile(RPX_TEMP_FILE, inflatedData, fileSize); file_path = RPX_TEMP_FILE_EX; loadedRPX = true; + + if (!res) { + NotificationModule_AddErrorNotification("Wiiload plugin: Failed to save .rpx file to the sd card. Launching will be aborted."); + } } else if (inflatedData[0x7] == 0xCA && inflatedData[0x8] == 0xFE && inflatedData[0x9] == 0x50 && inflatedData[0xA] == 0x4C) { auto newContainer = WUPSBackend::PluginUtils::getPluginForBuffer((char *) inflatedData, fileSize); if (newContainer) { @@ -259,7 +268,6 @@ int32_t TcpReceiver::loadToMemory(int32_t clientSocket, uint32_t ipAddress) { auto &metaInformation = newContainer.value()->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() && @@ -267,7 +275,7 @@ int32_t TcpReceiver::loadToMemory(int32_t clientSocket, uint32_t ipAddress) { }), plugins.end()); - // at the new plugin + // add the new plugin plugins.push_back(std::move(newContainer.value())); #ifdef VERBOSE_DEBUG @@ -280,7 +288,8 @@ int32_t TcpReceiver::loadToMemory(int32_t clientSocket, uint32_t ipAddress) { #endif if (WUPSBackend::PluginUtils::LoadAndLinkOnRestart(plugins) != 0) { - DEBUG_FUNCTION_LINE_ERR("Failed to load & link"); + DEBUG_FUNCTION_LINE_ERR("WUPSBackend::PluginUtils::LoadAndLinkOnRestart failed"); + NotificationModule_AddErrorNotification("Wiiload plugin: Failed to load plugin. Launching will be aborted."); } free(loadAddress); @@ -289,6 +298,9 @@ int32_t TcpReceiver::loadToMemory(int32_t clientSocket, uint32_t ipAddress) { _SYSLaunchTitleWithStdArgsInNoSplash(OSGetTitleID(), nullptr); return fileSize; } else { + if (NotificationModule_AddErrorNotification("Wiiload plugin: Failed to load or parse the plugin. Launching will be aborted.") != NOTIFICATION_MODULE_RESULT_SUCCESS) { + DEBUG_FUNCTION_LINE_ERR("Failed to display error notification"); + } DEBUG_FUNCTION_LINE_ERR("Failed to parse plugin"); } } @@ -309,12 +321,15 @@ int32_t TcpReceiver::loadToMemory(int32_t clientSocket, uint32_t ipAddress) { } else if (loadAddress[0x7] == 0xCA && loadAddress[0x8] == 0xFE && loadAddress[0x9] == 0x50) { OSFatal("Not implemented yet"); } + if (NotificationModule_AddErrorNotification("Failed to write file to the sd card.") != NOTIFICATION_MODULE_RESULT_SUCCESS) { + DEBUG_FUNCTION_LINE_ERR("Failed to display error notification"); + } } free(loadAddress); if (!res) { - DEBUG_FUNCTION_LINE_ERR("Failed to launch save a homebrew to the sd card"); + DEBUG_FUNCTION_LINE_ERR("Failed to launch/save a homebrew to the sd card"); return NOT_ENOUGH_MEMORY; }