Add error notifications if wiiloading a rpx/wuhb fails

This commit is contained in:
Maschell 2023-11-27 17:52:54 +01:00
parent 458e3ba0f2
commit cee5d8e838
7 changed files with 38 additions and 9 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,4 +1,5 @@
#include "globals.h"
bool gLibRPXLoaderInitDone __attribute__((section(".data"))) = false;
bool gWiiloadServerEnabled __attribute__((section(".data"))) = true;
bool gLibRPXLoaderInitDone __attribute__((section(".data"))) = false;
bool gWiiloadServerEnabled __attribute__((section(".data"))) = true;
bool gNotificationModuleLoaded __attribute__((section(".data"))) = true;

View File

@ -1,4 +1,5 @@
#include <stdint.h>
extern bool gLibRPXLoaderInitDone;
extern bool gWiiloadServerEnabled;
extern bool gWiiloadServerEnabled;
extern bool gNotificationModuleLoaded;

View File

@ -3,6 +3,7 @@
#include "utils/TcpReceiver.h"
#include "utils/logger.h"
#include <coreinit/debug.h>
#include <notifications/notifications.h>
#include <rpxloader/rpxloader.h>
#include <wups.h>
#include <wups/config/WUPSConfigItemBoolean.h>
@ -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) {

View File

@ -9,6 +9,7 @@
#include <coreinit/dynload.h>
#include <coreinit/title.h>
#include <cstring>
#include <notifications/notifications.h>
#include <rpxloader/rpxloader.h>
#include <sysapp/launch.h>
#include <vector>
@ -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;
}