diff --git a/nx/include/switch/applets/web.h b/nx/include/switch/applets/web.h index eb1d208f..5532c0f2 100644 --- a/nx/include/switch/applets/web.h +++ b/nx/include/switch/applets/web.h @@ -191,6 +191,14 @@ Result webConfigSetCallbackableUrl(WebCommonConfig* config, const char* url); */ Result webConfigSetWhitelist(WebCommonConfig* config, const char* whitelist); +/** + * @brief Sets the account UserID. Controls which user-specific savedata to mount. + * @note Only available with config created by \ref webPageCreate, or with Share-applet/Lobby-applet. + * @param config WebCommonConfig object. + * @param userID Account userID + */ +Result webConfigSetUserID(WebCommonConfig* config, u128 userID); + /** * @brief Sets the EcClientCert flag. * @note Only available with config created by \ref webPageCreate or with Offline-applet. diff --git a/nx/source/applets/web.c b/nx/source/applets/web.c index d3084402..da4f4264 100644 --- a/nx/source/applets/web.c +++ b/nx/source/applets/web.c @@ -141,12 +141,12 @@ static Result _webTLVWrite(WebCommonTLVStorage *storage, u16 type, const void* a return 0; } -static Result _webTLVSet(WebCommonTLVStorage *storage, u16 type, const void* argdata, u16 argdata_size) { - return _webTLVWrite(storage, type, argdata, argdata_size, argdata_size); +static Result _webTLVSet(WebCommonConfig* config, u16 type, const void* argdata, u16 argdata_size) { + return _webTLVWrite(&config->arg, type, argdata, argdata_size, argdata_size); } static Result _webConfigSetU8(WebCommonConfig* config, u16 type, u8 arg) { - return _webTLVSet(&config->arg, type, &arg, sizeof(arg)); + return _webTLVSet(config, type, &arg, sizeof(arg)); } static Result _webConfigSetFlag(WebCommonConfig* config, u16 type, bool arg) { @@ -154,7 +154,7 @@ static Result _webConfigSetFlag(WebCommonConfig* config, u16 type, bool arg) { } static Result _webConfigSetU32(WebCommonConfig* config, u16 type, u32 arg) { - return _webTLVSet(&config->arg, type, &arg, sizeof(arg)); + return _webTLVSet(config, type, &arg, sizeof(arg)); } static Result _webConfigSetString(WebCommonConfig* config, u16 type, const char* str, u16 argdata_size_total) { @@ -225,6 +225,12 @@ Result webConfigSetWhitelist(WebCommonConfig* config, const char* whitelist) { return _webConfigSetString(config, WebArgType_Whitelist, whitelist, 0x1000); } +Result webConfigSetUserID(WebCommonConfig* config, u128 userID) { + WebShimKind shim = _webGetShimKind(config); + if (shim != WebShimKind_Share && shim != WebShimKind_Web && shim != WebShimKind_Lobby) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); + return _webTLVSet(config, WebArgType_UserID, &userID, sizeof(userID)); +} + Result webConfigSetEcClientCert(WebCommonConfig* config, bool flag) { WebShimKind shim = _webGetShimKind(config); if (shim != WebShimKind_Web && shim != WebShimKind_Offline) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);