Renamed webShow to webConfigShow. Added webConfigSetWhitelist.

This commit is contained in:
yellows8 2019-02-25 20:12:36 -05:00
parent 7ccc29f397
commit 708ad83ead
2 changed files with 20 additions and 2 deletions

View File

@ -90,10 +90,18 @@ 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.
* @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.
*/
void webConfigSetWhitelist(WebCommonConfig* config, const char* whitelist);
/**
* @brief Launches the {web applet} with the specified config and waits for it to exit.
* @param config WebCommonConfig object.
* @param out Optional output applet reply data, can be NULL.
*/
Result webShow(WebCommonConfig* config, WebCommonReturnValue *out);
Result webConfigShow(WebCommonConfig* config, WebCommonReturnValue *out);

View File

@ -72,6 +72,11 @@ static void _webArgInitialize(WebCommonConfig* config, AppletId appletid, WebShi
config->version = 0x20000; // [1.0.0+] version
}
WebShimKind _webGetShimKind(WebCommonConfig* config) {
WebArgHeader *hdr = (WebArgHeader*)config->arg.data;
return hdr->shimKind;
}
static void _webTLVWrite(WebCommonTLVStorage *storage, u16 type, const void* argdata, u16 argdata_size, u16 argdata_size_total) {
size_t i, count, offset;
u8 *dataptr = storage->data;
@ -158,7 +163,12 @@ void webPageCreate(WebCommonConfig* config, const char* url) {
_webConfigSetUrl(config, url);
}
Result webShow(WebCommonConfig* config, WebCommonReturnValue *out) {
void webConfigSetWhitelist(WebCommonConfig* config, const char* whitelist) {
if (_webGetShimKind(config) != WebShimKind_Web) return;
_webConfigSetString(config, 0xA, whitelist, 0x1000);
}
Result webConfigShow(WebCommonConfig* config, WebCommonReturnValue *out) {
return _webShow(config->appletid, config->version, &config->arg, sizeof(config->arg), out, sizeof(*out));
}