diff --git a/nx/include/switch/applets/web.h b/nx/include/switch/applets/web.h index b6a2c57d..0e7ec19b 100644 --- a/nx/include/switch/applets/web.h +++ b/nx/include/switch/applets/web.h @@ -90,7 +90,7 @@ typedef enum { WebArgType_LeftStickMode = 0x1B, ///< [1.0.0+] u32 enum *LeftStickMode WebArgType_KeyRepeatFrame0 = 0x1C, ///< [1.0.0+] s32 KeyRepeatFrame, first param WebArgType_KeyRepeatFrame1 = 0x1D, ///< [1.0.0+] s32 KeyRepeatFrame, second param - WebArgType_BootAsMediaPlayerInverted = 0x1E, ///< [1.0.0+] u8 bool, set after BootAsMediaPlayer with the value inverted. + WebArgType_BootAsMediaPlayerInverted = 0x1E, ///< [1.0.0+] u8 bool. With News this is set after BootAsMediaPlayer with the value inverted. WebArgType_DisplayUrlKind = 0x1F, ///< [1.0.0+] u8 bool, DisplayUrlKind (value = (input_enumval==0x1)). WebArgType_BootAsMediaPlayer = 0x21, ///< [2.0.0+] u8 bool WebArgType_ShopJump = 0x22, ///< [2.0.0+] u8 bool @@ -142,11 +142,21 @@ Result webWifiShow(WebWifiConfig* config, WebWifiReturnValue *out); /** * @brief Creates the config for WebApplet. This applet uses an URL whitelist loaded from the user-process host title. + * @note Sets WebArgType_UnknownD, and WebArgType_Unknown12 on pre-3.0.0, to value 1. * @param config WebCommonConfig object. * @param url Initial URL navigated to by the applet. */ Result webPageCreate(WebCommonConfig* config, const char* url); +/** + * @brief Creates the config for WebApplet. This is based on \ref webPageCreate, for News. Hence other functions referencing \ref webPageCreate also apply to this. + * @note Sets WebArgType_UnknownD to value 1, and sets WebArgType_NewsFlag to true. Also uses \ref webConfigSetEcClientCert and \ref webConfigSetShopJump with flag=true. + * @note The domain from the input URL is automatically whitelisted, in addition to any already loaded whitelist. + * @param config WebCommonConfig object. + * @param url Initial URL navigated to by the applet. + */ +Result webNewsCreate(WebCommonConfig* config, const char* url); + /** * @brief Sets the CallbackUrl. * @note Only available with config created by \ref webPageCreate or with Share-applet. @@ -172,6 +182,15 @@ Result webConfigSetCallbackableUrl(WebCommonConfig* config, const char* url); */ Result webConfigSetWhitelist(WebCommonConfig* config, const char* whitelist); +/** + * @brief Sets the EcClientCert flag. + * @note Only available with config created by \ref webPageCreate or with Offline-applet. + * @note Used automatically by \ref webNewsCreate with flag=true. + * @param config WebCommonConfig object. + * @param flag Flag + */ +Result webConfigSetEcClientCert(WebCommonConfig* config, bool flag); + /** * @brief Sets the BootDisplayKind. * @note Only available with config created by \ref webPageCreate or with Offline-applet. @@ -195,6 +214,15 @@ Result webConfigSetDisplayUrlKind(WebCommonConfig* config, bool kind); */ Result webConfigSetBootAsMediaPlayer(WebCommonConfig* config, bool flag); +/** + * @brief Sets the ShopJump flag. + * @note Only available with config created by \ref webPageCreate on [2.0.0+]. + * @note Used automatically by \ref webNewsCreate with flag=true. + * @param config WebCommonConfig object. + * @param flag Flag + */ +Result webConfigSetShopJump(WebCommonConfig* config, bool flag); + /** * @brief Sets the UserAgentAdditionalString. * @note Only available with config created by \ref webPageCreate on [4.0.0+]. diff --git a/nx/source/applets/web.c b/nx/source/applets/web.c index cef47f87..66de415f 100644 --- a/nx/source/applets/web.c +++ b/nx/source/applets/web.c @@ -180,6 +180,20 @@ Result webPageCreate(WebCommonConfig* config, const char* url) { return rc; } +Result webNewsCreate(WebCommonConfig* config, const char* url) { + Result rc=0; + _webArgInitialize(config, AppletId_web, WebShimKind_Web); + + rc = _webConfigSetU8(config, WebArgType_UnknownD, 1); + if (R_SUCCEEDED(rc)) rc = _webConfigSetFlag(config, WebArgType_NewsFlag, true); + if (R_SUCCEEDED(rc)) rc = webConfigSetEcClientCert(config, true); + if (R_SUCCEEDED(rc) && hosversionAtLeast(2,0,0)) rc = webConfigSetShopJump(config, true); // Check version so that rc isn't set to an error on pre-2.0.0. + + if (R_SUCCEEDED(rc)) rc = _webConfigSetUrl(config, url); + + return rc; +} + Result webConfigSetCallbackUrl(WebCommonConfig* config, const char* url) { WebShimKind shim = _webGetShimKind(config); if (shim != WebShimKind_Share && shim != WebShimKind_Web) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); @@ -196,6 +210,12 @@ Result webConfigSetWhitelist(WebCommonConfig* config, const char* whitelist) { return _webConfigSetString(config, WebArgType_Whitelist, whitelist, 0x1000); } +Result webConfigSetEcClientCert(WebCommonConfig* config, bool flag) { + WebShimKind shim = _webGetShimKind(config); + if (shim != WebShimKind_Web && shim != WebShimKind_Offline) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); + return _webConfigSetU8(config, WebArgType_EcClientCert, flag); +} + Result webConfigSetBootDisplayKind(WebCommonConfig* config, u32 kind) { WebShimKind shim = _webGetShimKind(config); if (shim != WebShimKind_Web && shim != WebShimKind_Offline) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); @@ -225,6 +245,12 @@ Result webConfigSetBootAsMediaPlayer(WebCommonConfig* config, bool flag) { return _webConfigSetFlag(config, WebArgType_BootAsMediaPlayer, flag); } +Result webConfigSetShopJump(WebCommonConfig* config, bool flag) { + if (_webGetShimKind(config) != WebShimKind_Web) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); + if (hosversionBefore(2,0,0)) return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); + return _webConfigSetFlag(config, WebArgType_ShopJump, flag); +} + Result webConfigShow(WebCommonConfig* config, WebCommonReturnValue *out) { return _webShow(config->appletid, config->version, &config->arg, sizeof(config->arg), out, sizeof(*out)); }