From ae56c04b7cb2ab3794b8d62f897f12e4cbce06ec Mon Sep 17 00:00:00 2001 From: Maschell Date: Sat, 24 Feb 2024 10:26:01 +0100 Subject: [PATCH] More cleanup and fixes --- Dockerfile | 2 +- src/main.cpp | 60 +++++++++++++++++++++++--------------------- src/utils/config.cpp | 7 ++++-- src/utils/config.h | 7 +++--- 4 files changed, 40 insertions(+), 36 deletions(-) diff --git a/Dockerfile b/Dockerfile index b41810a..648c53b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM ghcr.io/wiiu-env/devkitppc:20231112 -COPY --from=ghcr.io/wiiu-env/wiiupluginsystem:0.8.0-dev-20231221-ca17105 /artifacts $DEVKITPRO +COPY --from=ghcr.io/wiiu-env/wiiupluginsystem:0.8.0-dev-20240223-46f4cf6 /artifacts $DEVKITPRO COPY --from=ghcr.io/wiiu-env/libnotifications:20230621 /artifacts $DEVKITPRO COPY --from=ghcr.io/wiiu-env/librpxloader:20230621 /artifacts $DEVKITPRO COPY --from=ghcr.io/wiiu-env/libcurlwrapper:20230715 /artifacts $DEVKITPRO diff --git a/src/main.cpp b/src/main.cpp index 66cb29a..62eb543 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -23,50 +23,52 @@ WUPS_USE_WUT_DEVOPTAB(); WUPS_USE_STORAGE("aroma_base_plugin"); // Unique id for the storage api bool InitConfigValuesFromStorage() { + bool result = true; WUPSStorageError storageError; auto subItemConfig = WUPSStorageAPI::GetOrCreateSubItem(CAT_CONFIG, storageError); if (!subItemConfig) { DEBUG_FUNCTION_LINE_ERR("Failed to get or create sub category \"%s\"", CAT_CONFIG); - return false; - } - - if (subItemConfig->GetOrStoreDefault(USTEALTH_CONFIG_ID, gActivateUStealth, gActivateUStealth) != WUPS_STORAGE_ERROR_SUCCESS) { - DEBUG_FUNCTION_LINE_ERR("Failed to get or create item \"%s\"", USTEALTH_CONFIG_ID); - return false; - } - if (subItemConfig->GetOrStoreDefault(POWEROFFWARNING_CONFIG_ID, gSkip4SecondOffStatusCheck, gSkip4SecondOffStatusCheck) != WUPS_STORAGE_ERROR_SUCCESS) { - DEBUG_FUNCTION_LINE_ERR("Failed to get or create item \"%s\"", POWEROFFWARNING_CONFIG_ID); - return false; - } - if (subItemConfig->GetOrStoreDefault(FORCE_NDM_SUSPEND_SUCCESS_CONFIG_ID, gForceNDMSuspendSuccess, gForceNDMSuspendSuccess) != WUPS_STORAGE_ERROR_SUCCESS) { - DEBUG_FUNCTION_LINE_ERR("Failed to get or create item \"%s\"", FORCE_NDM_SUSPEND_SUCCESS_CONFIG_ID); - return false; - } - if (subItemConfig->GetOrStoreDefault(ALLOW_ERROR_NOTIFICATIONS, gAllowErrorNotifications, gAllowErrorNotifications) != WUPS_STORAGE_ERROR_SUCCESS) { - DEBUG_FUNCTION_LINE_ERR("Failed to get or create item \"%s\"", ALLOW_ERROR_NOTIFICATIONS); - return false; + result = false; + } else { + if (subItemConfig->GetOrStoreDefault(USTEALTH_CONFIG_ID, gActivateUStealth, ACTIVATE_USTEALTH_DEFAULT) != WUPS_STORAGE_ERROR_SUCCESS) { + DEBUG_FUNCTION_LINE_ERR("Failed to get or create item \"%s\"", USTEALTH_CONFIG_ID); + result = false; + } + if (subItemConfig->GetOrStoreDefault(POWEROFFWARNING_CONFIG_ID, gSkip4SecondOffStatusCheck, SKIP_4_SECOND_OFF_STATUS_CHECK_DEFAULT) != WUPS_STORAGE_ERROR_SUCCESS) { + DEBUG_FUNCTION_LINE_ERR("Failed to get or create item \"%s\"", POWEROFFWARNING_CONFIG_ID); + result = false; + } + if (subItemConfig->GetOrStoreDefault(FORCE_NDM_SUSPEND_SUCCESS_CONFIG_ID, gForceNDMSuspendSuccess, FORCE_NDM_SUSPEND_SUCCESS_DEFAULT) != WUPS_STORAGE_ERROR_SUCCESS) { + DEBUG_FUNCTION_LINE_ERR("Failed to get or create item \"%s\"", FORCE_NDM_SUSPEND_SUCCESS_CONFIG_ID); + result = false; + } + if (subItemConfig->GetOrStoreDefault(ALLOW_ERROR_NOTIFICATIONS, gAllowErrorNotifications, ALLOW_ERROR_NOTIFICATIONS_DEFAULT) != WUPS_STORAGE_ERROR_SUCCESS) { + DEBUG_FUNCTION_LINE_ERR("Failed to get or create item \"%s\"", ALLOW_ERROR_NOTIFICATIONS); + result = false; + } } auto subItemOther = WUPSStorageAPI::GetOrCreateSubItem(CAT_OTHER, storageError); if (!subItemOther) { DEBUG_FUNCTION_LINE_ERR("Failed to get or create sub category \"%s\"", CAT_OTHER); - return false; - } - - if (subItemOther->GetOrStoreDefault(CONFIG_MENU_HINT_SHOWN_ID, gConfigMenuHintShown, gConfigMenuHintShown) != WUPS_STORAGE_ERROR_SUCCESS) { - DEBUG_FUNCTION_LINE_ERR("Failed to get or create item \"%s\"", CONFIG_MENU_HINT_SHOWN_ID); - return false; - } - if (subItemOther->GetOrStoreDefault(CONFIG_MENU_HINT_SHOWN_ID, gLastHash, gLastHash) != WUPS_STORAGE_ERROR_SUCCESS) { - DEBUG_FUNCTION_LINE_ERR("Failed to get or create item \"%s\"", CONFIG_MENU_HINT_SHOWN_ID); - return false; + result = false; + } else { + if ((storageError = subItemOther->GetOrStoreDefault(CONFIG_MENU_HINT_SHOWN_ID, gConfigMenuHintShown, CONFIG_MENU_HINT_SHOWN_DEFAULT)) != WUPS_STORAGE_ERROR_SUCCESS) { + DEBUG_FUNCTION_LINE_ERR("Failed to get or create item \"%s\": %s", CONFIG_MENU_HINT_SHOWN_ID, WUPSStorageAPI_GetStatusStr(storageError)); + result = false; + } + if ((storageError = subItemOther->GetOrStoreDefault(LAST_UPDATE_HASH_ID, gLastHash, LAST_UPDATE_HASH_DEFAULT)) != WUPS_STORAGE_ERROR_SUCCESS) { + DEBUG_FUNCTION_LINE_ERR("Failed to get or create item \"%s\": %s", LAST_UPDATE_HASH_ID, WUPSStorageAPI_GetStatusStr(storageError)); + result = false; + } } if (WUPSStorageAPI::SaveStorage() != WUPS_STORAGE_ERROR_SUCCESS) { DEBUG_FUNCTION_LINE_ERR("Failed to save storage"); + result = false; } - return true; + return result; } INITIALIZE_PLUGIN() { diff --git a/src/utils/config.cpp b/src/utils/config.cpp index e3de51c..9b1befc 100644 --- a/src/utils/config.cpp +++ b/src/utils/config.cpp @@ -67,14 +67,17 @@ WUPSConfigAPICallbackStatus ConfigMenuOpenedCallback(WUPSConfigCategoryHandle ro root.add(std::move(otherPatches)); } catch (std::exception &e) { - OSReport("Exception T_T : %s\n", e.what()); + DEBUG_FUNCTION_LINE_ERR("Exception: %s\n", e.what()); return WUPSCONFIG_API_CALLBACK_RESULT_ERROR; } return WUPSCONFIG_API_CALLBACK_RESULT_SUCCESS; } void ConfigMenuClosedCallback() { - WUPSStorageAPI::SaveStorage(); + WUPSStorageError storageError; + if ((storageError = WUPSStorageAPI::SaveStorage()) != WUPS_STORAGE_ERROR_SUCCESS) { + DEBUG_FUNCTION_LINE_ERR("Failed to save storage: %d %s", storageError, WUPSStorageAPI_GetStatusStr(storageError)); + } } void InitConfigMenu() { diff --git a/src/utils/config.h b/src/utils/config.h index 1c90dda..42b58b1 100644 --- a/src/utils/config.h +++ b/src/utils/config.h @@ -11,16 +11,15 @@ #define POWEROFFWARNING_CONFIG_ID "SkipPowerOffWarning" #define FORCE_NDM_SUSPEND_SUCCESS_CONFIG_ID "forceNDMSuspendSuccess" #define ALLOW_ERROR_NOTIFICATIONS "allowErrorNotifications" - #define CONFIG_MENU_HINT_SHOWN_ID "configMenuHintShown" #define LAST_UPDATE_HASH_ID "lastUpdateHash" #define ACTIVATE_USTEALTH_DEFAULT false -#define SKIP_4_SECOND_OFF_STATUS_CHECK_DEFAULT false +#define SKIP_4_SECOND_OFF_STATUS_CHECK_DEFAULT true #define CONFIG_MENU_HINT_SHOWN_DEFAULT false #define UPDATE_CHECKED_DEFAULT false -#define FORCE_NDM_SUSPEND_SUCCESS_DEFAULT false -#define ALLOW_ERROR_NOTIFICATIONS_DEFAULT false +#define FORCE_NDM_SUSPEND_SUCCESS_DEFAULT true +#define ALLOW_ERROR_NOTIFICATIONS_DEFAULT true #define LAST_UPDATE_HASH_DEFAULT std::string() extern bool gActivateUStealth;