From 4ef0dd09f0be91a273833687daae7fd5bf11d7f3 Mon Sep 17 00:00:00 2001 From: yellows8 Date: Thu, 28 Feb 2019 21:54:08 -0500 Subject: [PATCH] Added webConfigSetMediaPlayerUserGestureRestriction, webConfigSetJsExtension, webConfigSetTouchEnabledOnContents, webConfigSetPageCache, webConfigSetWebAudio, webConfigSetFooterFixedKind, webConfigSetPageFade, webConfigSetBootLoadingIcon, and webConfigSetPageScrollIndicator. Minor other changes. --- nx/include/switch/applets/web.h | 74 ++++++++++++++++++++++++++++++++- nx/source/applets/web.c | 61 +++++++++++++++++++++++++++ 2 files changed, 134 insertions(+), 1 deletion(-) diff --git a/nx/include/switch/applets/web.h b/nx/include/switch/applets/web.h index 7a6745eb..df3298bf 100644 --- a/nx/include/switch/applets/web.h +++ b/nx/include/switch/applets/web.h @@ -107,7 +107,7 @@ typedef enum { WebArgType_WebAudio = 0x2E, ///< [4.0.0+] u8 bool WebArgType_2F = 0x2F, ///< [5.0.0+] u8 WebArgType_YouTubeVideoFlag = 0x31, ///< [5.0.0+] u8 bool Indicates that the built-in whitelist for YouTubeVideo should be used. - WebArgType_FooterFixedKind = 0x32, ///< [5.0.0+] u32 enum *WebFooterFixedKind + WebArgType_FooterFixedKind = 0x32, ///< [5.0.0+] u32 enum *FooterFixedKind WebArgType_PageFade = 0x33, ///< [5.0.0+] u8 bool WebArgType_MediaCreatorApplicationRatingAge = 0x34, ///< [5.0.0+] Share-applet 0x20-byte s8 array, MediaCreatorApplicationRatingAge. WebArgType_BootLoadingIcon = 0x35, ///< [5.0.0+] u8 bool @@ -295,6 +295,14 @@ Result webConfigSetBootAsMediaPlayer(WebCommonConfig* config, bool flag); */ Result webConfigSetShopJump(WebCommonConfig* config, bool flag); +/** + * @brief Sets the MediaPlayerUserGestureRestriction flag. + * @note Only available with config created by \ref webPageCreate on [2.0.0+]. + * @param config WebCommonConfig object. + * @param flag Flag + */ +Result webConfigSetMediaPlayerUserGestureRestriction(WebCommonConfig* config, bool flag); + /** * @brief Sets the LobbyParameter. * @note Only available with config created by \ref webLobbyCreate. @@ -303,6 +311,22 @@ Result webConfigSetShopJump(WebCommonConfig* config, bool flag); */ Result webConfigSetLobbyParameter(WebCommonConfig* config, const char* str); +/** + * @brief Sets whether JsExtension is enabled. + * @note Only available with config created by \ref webPageCreate or with Offline-applet, on [3.0.0+]. + * @param config WebCommonConfig object. + * @param flag Flag + */ +Result webConfigSetJsExtension(WebCommonConfig* config, bool flag); + +/** + * @brief Sets the TouchEnabledOnContents flag. + * @note Only available with config created by \ref webPageCreate or with Offline-applet, on [4.0.0+]. + * @param config WebCommonConfig object. + * @param flag Flag + */ +Result webConfigSetTouchEnabledOnContents(WebCommonConfig* config, bool flag); + /** * @brief Sets the UserAgentAdditionalString. " " followed by this string are appended to the normal User-Agent string. * @note Only available with config created by \ref webPageCreate on [4.0.0+]. @@ -319,6 +343,54 @@ Result webConfigSetUserAgentAdditionalString(WebCommonConfig* config, const char */ Result webConfigSetMediaPlayerAutoClose(WebCommonConfig* config, bool flag); +/** + * @brief Sets whether PageCache is enabled. + * @note Only available with config created by \ref webPageCreate or with Offline-applet, on [4.0.0+]. + * @param config WebCommonConfig object. + * @param flag Flag + */ +Result webConfigSetPageCache(WebCommonConfig* config, bool flag); + +/** + * @brief Sets whether WebAudio is enabled. + * @note Only available with config created by \ref webPageCreate or with Offline-applet, on [4.0.0+]. + * @param config WebCommonConfig object. + * @param flag Flag + */ +Result webConfigSetWebAudio(WebCommonConfig* config, bool flag); + +/** + * @brief Sets the FooterFixedKind. + * @note Only available with config created by \ref webPageCreate or with Offline-applet, on [5.0.0+]. + * @param config WebCommonConfig object. + * @param kind Kind, different enums for Web and Offline. + */ +Result webConfigSetFooterFixedKind(WebCommonConfig* config, u32 kind); + +/** + * @brief Sets the PageFade flag. + * @note Only available with config created by \ref webPageCreate or with Offline-applet, on [5.0.0+]. + * @param config WebCommonConfig object. + * @param flag Flag + */ +Result webConfigSetPageFade(WebCommonConfig* config, bool flag); + +/** + * @brief Sets the BootLoadingIcon flag. + * @note Only available with Offline-applet on [5.0.0+]. + * @param config WebCommonConfig object. + * @param flag Flag + */ +Result webConfigSetBootLoadingIcon(WebCommonConfig* config, bool flag); + +/** + * @brief Sets the PageScrollIndicator flag. + * @note Only available with config created by \ref webPageCreate or with Offline-applet, on [5.0.0+]. + * @param config WebCommonConfig object. + * @param flag Flag + */ +Result webConfigSetPageScrollIndicator(WebCommonConfig* config, bool flag); + /** * @brief Launches the {web applet} with the specified config and waits for it to exit. * @param config WebCommonConfig object. diff --git a/nx/source/applets/web.c b/nx/source/applets/web.c index bea8ea64..dd51f1f8 100644 --- a/nx/source/applets/web.c +++ b/nx/source/applets/web.c @@ -305,6 +305,7 @@ Result webConfigSetBootAsMediaPlayer(WebCommonConfig* config, bool flag) { if (shim != WebShimKind_Offline && shim != WebShimKind_Web) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); if (hosversionBefore(2,0,0)) return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); return _webConfigSetFlag(config, WebArgType_BootAsMediaPlayer, flag); + //TODO: Need to check for News somehow and set WebArgType_BootAsMediaPlayerInverted. } Result webConfigSetShopJump(WebCommonConfig* config, bool flag) { @@ -313,11 +314,31 @@ Result webConfigSetShopJump(WebCommonConfig* config, bool flag) { return _webConfigSetFlag(config, WebArgType_ShopJump, flag); } +Result webConfigSetMediaPlayerUserGestureRestriction(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_MediaPlayerUserGestureRestriction, flag); +} + Result webConfigSetLobbyParameter(WebCommonConfig* config, const char* str) { if (_webGetShimKind(config) != WebShimKind_Lobby) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); return _webConfigSetString(config, WebArgType_LobbyParameter, str, 0x100); } +Result webConfigSetJsExtension(WebCommonConfig* config, bool flag) { + WebShimKind shim = _webGetShimKind(config); + if (shim != WebShimKind_Offline && shim != WebShimKind_Web) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); + if (hosversionBefore(3,0,0)) return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); + return _webConfigSetFlag(config, WebArgType_JsExtension, flag); +} + +Result webConfigSetTouchEnabledOnContents(WebCommonConfig* config, bool flag) { + WebShimKind shim = _webGetShimKind(config); + if (shim != WebShimKind_Offline && shim != WebShimKind_Web) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); + if (hosversionBefore(4,0,0)) return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); + return _webConfigSetFlag(config, WebArgType_TouchEnabledOnContents, flag); +} + Result webConfigSetUserAgentAdditionalString(WebCommonConfig* config, const char* str) { if (_webGetShimKind(config) != WebShimKind_Web) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); if (hosversionBefore(4,0,0)) return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); @@ -330,6 +351,46 @@ Result webConfigSetMediaPlayerAutoClose(WebCommonConfig* config, bool flag) { return _webConfigSetFlag(config, WebArgType_MediaPlayerAutoClose, flag); } +Result webConfigSetPageCache(WebCommonConfig* config, bool flag) { + WebShimKind shim = _webGetShimKind(config); + if (shim != WebShimKind_Offline && shim != WebShimKind_Web) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); + if (hosversionBefore(4,0,0)) return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); + return _webConfigSetFlag(config, WebArgType_PageCache, flag); +} + +Result webConfigSetWebAudio(WebCommonConfig* config, bool flag) { + WebShimKind shim = _webGetShimKind(config); + if (shim != WebShimKind_Offline && shim != WebShimKind_Web) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); + if (hosversionBefore(4,0,0)) return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); + return _webConfigSetFlag(config, WebArgType_WebAudio, flag); +} + +Result webConfigSetFooterFixedKind(WebCommonConfig* config, u32 kind) { + WebShimKind shim = _webGetShimKind(config); + if (shim != WebShimKind_Offline && shim != WebShimKind_Web) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); + return _webConfigSetU32(config, WebArgType_FooterFixedKind, kind); +} + +Result webConfigSetPageFade(WebCommonConfig* config, bool flag) { + WebShimKind shim = _webGetShimKind(config); + if (shim != WebShimKind_Offline && shim != WebShimKind_Web) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); + if (hosversionBefore(5,0,0)) return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); + return _webConfigSetFlag(config, WebArgType_PageFade, flag); +} + +Result webConfigSetBootLoadingIcon(WebCommonConfig* config, bool flag) { + if (_webGetShimKind(config) != WebShimKind_Offline) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); + if (hosversionBefore(5,0,0)) return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); + return _webConfigSetFlag(config, WebArgType_BootLoadingIcon, flag); +} + +Result webConfigSetPageScrollIndicator(WebCommonConfig* config, bool flag) { + WebShimKind shim = _webGetShimKind(config); + if (shim != WebShimKind_Offline && shim != WebShimKind_Web) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); + if (hosversionBefore(5,0,0)) return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); + return _webConfigSetFlag(config, WebArgType_PageScrollIndicator, flag); +} + Result webConfigShow(WebCommonConfig* config, WebCommonReturnValue *out) { return _webShow(config->appletid, config->version, &config->arg, sizeof(config->arg), out, sizeof(*out)); }