From 2cd98250745f87699b186573b04d5f2053254d4a Mon Sep 17 00:00:00 2001 From: yellows8 Date: Tue, 26 Feb 2019 15:15:58 -0500 Subject: [PATCH] Added webConfigSetCallbackUrl, webConfigSetCallbackableUrl, and webConfigSetUserAgentAdditionalString. Improved web docs. --- nx/include/switch/applets/web.h | 27 ++++++++++++++++++++++++++- nx/source/applets/web.c | 17 +++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/nx/include/switch/applets/web.h b/nx/include/switch/applets/web.h index a7fdc6ca..b9971551 100644 --- a/nx/include/switch/applets/web.h +++ b/nx/include/switch/applets/web.h @@ -138,7 +138,24 @@ Result webWifiShow(WebWifiConfig* config, WebWifiReturnValue *out); void webPageCreate(WebCommonConfig* config, const char* url); /** - * @brief Sets the whitelist, only available with config created by \ref webPageCreate. + * @brief Sets the CallbackUrl. + * @note Only available with config created by \ref webPageCreate or with Share-applet. + * @param config WebCommonConfig object. + * @param url URL + */ +void webConfigSetCallbackUrl(WebCommonConfig* config, const char* url); + +/** + * @brief Sets the CallbackableUrl. + * @note Only available with config created by \ref webPageCreate. + * @param config WebCommonConfig object. + * @param url URL + */ +void webConfigSetCallbackableUrl(WebCommonConfig* config, const char* url); + +/** + * @brief Sets the whitelist. + * @note Only available with config created by \ref webPageCreate. * @note If the whitelist isn't formatted properly, the applet will exit briefly after the applet is launched. * @param config WebCommonConfig object. * @param whitelist Whitelist string, each line is a regex for each whitelisted URL. @@ -152,6 +169,14 @@ void webConfigSetWhitelist(WebCommonConfig* config, const char* whitelist); */ void webConfigSetDisplayUrlKind(WebCommonConfig* config, bool kind); +/** + * @brief Sets the UserAgentAdditionalString. + * @note Only available with config created by \ref webPageCreate on [4.0.0+]. + * @param config WebCommonConfig object. + * @param str String + */ +void webConfigSetUserAgentAdditionalString(WebCommonConfig* config, const char* str); + /** * @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 269447f4..8cb9c9d6 100644 --- a/nx/source/applets/web.c +++ b/nx/source/applets/web.c @@ -174,6 +174,17 @@ void webPageCreate(WebCommonConfig* config, const char* url) { _webConfigSetUrl(config, url); } +void webConfigSetCallbackUrl(WebCommonConfig* config, const char* url) { + WebShimKind shim = _webGetShimKind(config); + if (shim != WebShimKind_Web && shim != WebShimKind_Share) return; + _webConfigSetString(config, WebArgType_CallbackUrl, url, 0x400); +} + +void webConfigSetCallbackableUrl(WebCommonConfig* config, const char* url) { + if (_webGetShimKind(config) != WebShimKind_Web) return; + _webConfigSetString(config, WebArgType_CallbackableUrl, url, 0x400); +} + void webConfigSetWhitelist(WebCommonConfig* config, const char* whitelist) { if (_webGetShimKind(config) != WebShimKind_Web) return; _webConfigSetString(config, WebArgType_Whitelist, whitelist, 0x1000); @@ -183,6 +194,12 @@ void webConfigSetDisplayUrlKind(WebCommonConfig* config, bool kind) { _webConfigSetFlag(config, WebArgType_DisplayUrlKind, kind); } +void webConfigSetUserAgentAdditionalString(WebCommonConfig* config, const char* str) { + if (_webGetShimKind(config) != WebShimKind_Web) return; + if (hosversionBefore(4,0,0)) return; + _webConfigSetString(config, WebArgType_UserAgentAdditionalString, str, 0x80); +} + Result webConfigShow(WebCommonConfig* config, WebCommonReturnValue *out) { return _webShow(config->appletid, config->version, &config->arg, sizeof(config->arg), out, sizeof(*out)); }