diff --git a/nx/include/switch/applets/web.h b/nx/include/switch/applets/web.h index ff2cc925..267acba1 100644 --- a/nx/include/switch/applets/web.h +++ b/nx/include/switch/applets/web.h @@ -1,7 +1,7 @@ /** * @file web.h * @brief Wrapper for using the WifiWebAuthApplet LibraryApplet. - * @author p-sam + * @author p-sam, yellows8 * @copyright libnx Authors */ #pragma once @@ -9,20 +9,30 @@ #include "../services/applet.h" typedef struct { - u8 unk_x0[0x4]; - char url[0xFC]; -} WebWifiPageArgUrl; - -typedef struct { - WebWifiPageArgUrl url1; - WebWifiPageArgUrl url2; - u8 unk_x200[0x300]; - u8 unk_x500[0x18]; -} WebWifiPageArg; + u32 unk_x0; ///< Official sw sets this to 0 with appletStorageWrite, seperately from the rest of the config struct. + char conntest_url[0x100]; + char initial_url[0x400]; + u128 userID; + u32 unk_x514; +} PACKED WebWifiPageArg; typedef struct { WebWifiPageArg arg; } WebWifiConfig; -void webWifiCreate(WebWifiConfig* config, const char* url); +/** + * @brief Creates the config for WifiWebAuthApplet. + * @param config WebWifiConfig object. + * @param conntest_url URL used for the connection-test requests, if NULL initial_url is used for this. + * @param initial_url Initial URL navigated to by the applet. + * @param userID Account userID, 0 for common. + * @param unk Value written to \ref WebWifiPageArg unk_x514, this can be 0. + */ +void webWifiCreate(WebWifiConfig* config, const char* conntest_url, const char* initial_url, u128 userID, u32 unk); + +/** + * @brief Launches WifiWebAuthApplet with the specified config and waits for it to exit. + * @param config WebWifiConfig object. + */ Result webWifiShow(WebWifiConfig* config); + diff --git a/nx/source/applets/web.c b/nx/source/applets/web.c index 82edf880..73385012 100644 --- a/nx/source/applets/web.c +++ b/nx/source/applets/web.c @@ -6,14 +6,16 @@ #include "applets/libapplet.h" #include "applets/web.h" -static void _webWifiUrlCreate(WebWifiPageArgUrl* argUrl, const char* url) { - strncpy(argUrl->url, url, sizeof(argUrl->url)-1); -} - -void webWifiCreate(WebWifiConfig* config, const char* url) { +void webWifiCreate(WebWifiConfig* config, const char* conntest_url, const char* initial_url, u128 userID, u32 unk) { memset(config, 0, sizeof(WebWifiConfig)); - _webWifiUrlCreate(&config->arg.url1, url); - _webWifiUrlCreate(&config->arg.url2, url); + + if (conntest_url==NULL) conntest_url = initial_url; + + strncpy(config->arg.conntest_url, conntest_url, sizeof(config->arg.conntest_url)-1); + strncpy(config->arg.initial_url, initial_url, sizeof(config->arg.initial_url)-1); + + config->arg.userID = userID; + config->arg.unk_x514 = unk; } Result webWifiShow(WebWifiConfig* config) {