-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite logic, clean up and remove unused parts
- Loading branch information
Showing
22 changed files
with
441 additions
and
1,368 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ cmake-build-debug/ | |
.idea/ | ||
*.rpx | ||
*.txt | ||
*.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#include "config.h" | ||
#include "globals.h" | ||
#include "utils/TcpReceiver.h" | ||
#include "utils/logger.h" | ||
#include "utils/utils.h" | ||
#include <string> | ||
#include <wups/config/WUPSConfigItemBoolean.h> | ||
#include <wups/storage.h> | ||
|
||
static void gServerEnabledChanged(ConfigItemBoolean *item, bool newValue) { | ||
if (std::string_view(WIILOAD_ENABLED_STRING) != item->identifier) { | ||
DEBUG_FUNCTION_LINE_WARN("Unexpected identifier in bool callback: %s", item->identifier); | ||
return; | ||
} | ||
DEBUG_FUNCTION_LINE_VERBOSE("New value in gWiiloadServerEnabled: %d", newValue); | ||
gWiiloadServerEnabled = newValue; | ||
|
||
gTcpReceiverThread.reset(); | ||
|
||
if (gWiiloadServerEnabled) { | ||
DEBUG_FUNCTION_LINE("Starting server!"); | ||
gTcpReceiverThread = make_unique_nothrow<TcpReceiver>(4299); | ||
if (gTcpReceiverThread == nullptr) { | ||
DEBUG_FUNCTION_LINE_ERR("Failed to create wiiload thread"); | ||
} | ||
} else { | ||
DEBUG_FUNCTION_LINE("Wiiload server has been stopped!"); | ||
} | ||
// If the value has changed, we store it in the storage. | ||
WUPSStorageError res; | ||
if ((res = WUPSStorageAPI::Store(item->identifier, gWiiloadServerEnabled)) != WUPS_STORAGE_ERROR_SUCCESS) { | ||
DEBUG_FUNCTION_LINE_ERR("Failed to store gWiiloadServerEnabled: %s (%d)", WUPSStorageAPI_GetStatusStr(res), res); | ||
} | ||
} | ||
|
||
static WUPSConfigAPICallbackStatus ConfigMenuOpenedCallback(WUPSConfigCategoryHandle rootHandle) { | ||
try { | ||
WUPSConfigCategory root = WUPSConfigCategory(rootHandle); | ||
|
||
root.add(WUPSConfigItemBoolean::Create(WIILOAD_ENABLED_STRING, "Enable Wiiload", | ||
DEFAULT_WIILOAD_ENABLED_VALUE, gWiiloadServerEnabled, | ||
&gServerEnabledChanged)); | ||
|
||
} catch (std::exception &e) { | ||
OSReport("Exception: %s\n", e.what()); | ||
return WUPSCONFIG_API_CALLBACK_RESULT_ERROR; | ||
} | ||
return WUPSCONFIG_API_CALLBACK_RESULT_SUCCESS; | ||
} | ||
|
||
static void ConfigMenuClosedCallback() { | ||
// Save all changes | ||
if (WUPSStorageAPI::SaveStorage() != WUPS_STORAGE_ERROR_SUCCESS) { | ||
DEBUG_FUNCTION_LINE_ERR("Failed to close storage"); | ||
} | ||
} | ||
|
||
void InitConfigAndStorage() { | ||
WUPSConfigAPIOptionsV1 configOptions = {.name = "Wiiload Plugin"}; | ||
if (WUPSConfigAPI_Init(configOptions, ConfigMenuOpenedCallback, ConfigMenuClosedCallback) != WUPSCONFIG_API_RESULT_SUCCESS) { | ||
DEBUG_FUNCTION_LINE_ERR("Failed to init config api"); | ||
} | ||
|
||
if (WUPSStorageAPI::GetOrStoreDefault(WIILOAD_ENABLED_STRING, gWiiloadServerEnabled, DEFAULT_WIILOAD_ENABLED_VALUE) != WUPS_STORAGE_ERROR_SUCCESS) { | ||
DEBUG_FUNCTION_LINE_ERR("Failed to get or create item \"%s\"", WIILOAD_ENABLED_STRING); | ||
} | ||
|
||
if (WUPSStorageAPI::SaveStorage() != WUPS_STORAGE_ERROR_SUCCESS) { | ||
DEBUG_FUNCTION_LINE_ERR("Failed to save storage"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#pragma once | ||
|
||
#define WIILOAD_ENABLED_STRING "enabled" | ||
#define DEFAULT_WIILOAD_ENABLED_VALUE true | ||
|
||
void InitConfigAndStorage(); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.