mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-22 13:02:38 +02:00
Renamed WebPageConfig to WebCommonConfig with more fields. Renamed webPageShow to webShow. Various web improvements including version handling.
This commit is contained in:
parent
9f45bb4d7e
commit
ec5f1dc17f
@ -62,7 +62,9 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
WebCommonTLVStorage arg;
|
||||
} WebPageConfig;
|
||||
AppletId appletid;
|
||||
u32 version;
|
||||
} WebCommonConfig;
|
||||
|
||||
/**
|
||||
* @brief Creates the config for WifiWebAuthApplet.
|
||||
@ -83,15 +85,15 @@ 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.
|
||||
* @param config WebPageConfig object.
|
||||
* @param config WebCommonConfig object.
|
||||
* @param url Initial URL navigated to by the applet.
|
||||
*/
|
||||
void webPageCreate(WebPageConfig* config, const char* url);
|
||||
void webPageCreate(WebCommonConfig* config, const char* url);
|
||||
|
||||
/**
|
||||
* @brief Launches WebApplet with the specified config and waits for it to exit.
|
||||
* @param config WebPageConfig object.
|
||||
* @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 webPageShow(WebPageConfig* config, WebCommonReturnValue *out);
|
||||
Result webShow(WebCommonConfig* config, WebCommonReturnValue *out);
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "services/applet.h"
|
||||
#include "applets/libapplet.h"
|
||||
#include "applets/web.h"
|
||||
#include "runtime/hosversion.h"
|
||||
|
||||
static Result _webLaunch(AppletHolder* holder, AppletId id, u32 version, void* arg, size_t arg_size) {
|
||||
Result rc=0;
|
||||
@ -55,11 +56,20 @@ static Result _webShow(AppletId id, u32 version, void* arg, size_t arg_size, voi
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void _webArgInitialize(WebCommonTLVStorage *storage, WebShimKind shimKind) {
|
||||
WebArgHeader *hdr = (WebArgHeader*)storage->data;
|
||||
static void _webArgInitialize(WebCommonConfig* config, AppletId appletid, WebShimKind shimKind) {
|
||||
memset(config, 0, sizeof(*config));
|
||||
|
||||
memset(storage, 0, sizeof(*storage));
|
||||
WebArgHeader *hdr = (WebArgHeader*)config->arg.data;
|
||||
hdr->shimKind = shimKind;
|
||||
config->appletid = appletid;
|
||||
|
||||
u32 hosver = hosversionGet();
|
||||
if (hosver >= MAKEHOSVERSION(5,0,0))
|
||||
config->version = 0x50000;
|
||||
else if (hosver >= MAKEHOSVERSION(3,0,0))
|
||||
config->version = 0x30000;
|
||||
else
|
||||
config->version = 0x20000; // [1.0.0+] version
|
||||
}
|
||||
|
||||
static void _webTLVWrite(WebCommonTLVStorage *storage, u16 type, const void* argdata, u16 argdata_size) {
|
||||
@ -121,21 +131,21 @@ Result webWifiShow(WebWifiConfig* config, WebWifiReturnValue *out) {
|
||||
return _webShow(AppletId_wifiWebAuth, 0, &config->arg, sizeof(config->arg), out, sizeof(*out));
|
||||
}
|
||||
|
||||
void webPageCreate(WebPageConfig* config, const char* url) {
|
||||
void webPageCreate(WebCommonConfig* config, const char* url) {
|
||||
char tmpurl[0xc00];
|
||||
|
||||
_webArgInitialize(&config->arg, WebShimKind_Web);
|
||||
_webArgInitialize(config, AppletId_web, WebShimKind_Web);
|
||||
|
||||
u8 tmpval=1;
|
||||
_webTLVWrite(&config->arg, 0xD, &tmpval, sizeof(tmpval));
|
||||
_webTLVWrite(&config->arg, 0x12, &tmpval, sizeof(tmpval)); // Removed from user-process init with [3.0.0+].
|
||||
if (config->version < 0x30000) _webTLVWrite(&config->arg, 0x12, &tmpval, sizeof(tmpval)); // Removed from user-process init with [3.0.0+].
|
||||
|
||||
memset(tmpurl, 0, sizeof(tmpurl));
|
||||
strncpy(tmpurl, url, sizeof(tmpurl)-1);
|
||||
_webTLVWrite(&config->arg, 0x1, tmpurl, sizeof(tmpurl));
|
||||
}
|
||||
|
||||
Result webPageShow(WebPageConfig* config, WebCommonReturnValue *out) {
|
||||
return _webShow(AppletId_web, 0x20000, &config->arg, sizeof(config->arg), out, sizeof(*out));
|
||||
Result webShow(WebCommonConfig* config, WebCommonReturnValue *out) {
|
||||
return _webShow(config->appletid, config->version, &config->arg, sizeof(config->arg), out, sizeof(*out));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user