mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 20:42:44 +02:00
Added WifiWebAuthApplet launching (#233)
* Added WifiWebAuthApplet launching
This commit is contained in:
parent
40d5fb8587
commit
8360e561c5
@ -101,6 +101,7 @@ extern "C" {
|
||||
|
||||
#include "switch/applets/libapplet.h"
|
||||
#include "switch/applets/swkbd.h"
|
||||
#include "switch/applets/web.h"
|
||||
|
||||
#include "switch/runtime/env.h"
|
||||
#include "switch/runtime/nxlink.h"
|
||||
|
28
nx/include/switch/applets/web.h
Normal file
28
nx/include/switch/applets/web.h
Normal file
@ -0,0 +1,28 @@
|
||||
/**
|
||||
* @file web.h
|
||||
* @brief Wrapper for using the WifiWebAuthApplet LibraryApplet.
|
||||
* @author p-sam
|
||||
* @copyright libnx Authors
|
||||
*/
|
||||
#pragma once
|
||||
#include "../types.h"
|
||||
#include "../services/applet.h"
|
||||
|
||||
typedef struct {
|
||||
u8 unk_x0[0x4];
|
||||
char url[0xFC];
|
||||
} WebWifiPageArgUrl;
|
||||
|
||||
typedef struct {
|
||||
WebWifiPageArgUrl url1;
|
||||
WebWifiPageArgUrl url2;
|
||||
u8 unk_x200[0x300];
|
||||
u8 unk_x500[0x18];
|
||||
} WebWifiPageArg;
|
||||
|
||||
typedef struct {
|
||||
WebWifiPageArg arg;
|
||||
} WebWifiConfig;
|
||||
|
||||
void webWifiCreate(WebWifiConfig* config, const char* url);
|
||||
Result webWifiShow(WebWifiConfig* config);
|
47
nx/source/applets/web.c
Normal file
47
nx/source/applets/web.c
Normal file
@ -0,0 +1,47 @@
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#include "types.h"
|
||||
#include "result.h"
|
||||
#include "services/applet.h"
|
||||
#include "applets/libapplet.h"
|
||||
#include "applets/web.h"
|
||||
|
||||
static void _webWifiUrlCreate(WebWifiPageArgUrl* argUrl, const char* url) {
|
||||
strncpy(argUrl->url, url, sizeof(argUrl->url)-1);
|
||||
}
|
||||
|
||||
void webWifiCreate(WebWifiConfig* config, const char* url) {
|
||||
memset(config, 0, sizeof(WebWifiConfig));
|
||||
_webWifiUrlCreate(&config->arg.url1, url);
|
||||
_webWifiUrlCreate(&config->arg.url2, url);
|
||||
}
|
||||
|
||||
Result webWifiShow(WebWifiConfig* config) {
|
||||
Result rc = 0;
|
||||
AppletHolder holder;
|
||||
|
||||
rc = appletCreateLibraryApplet(&holder, AppletId_wifiWebAuth, LibAppletMode_AllForeground);
|
||||
if (R_FAILED(rc)) return rc;
|
||||
|
||||
LibAppletArgs commonargs;
|
||||
libappletArgsCreate(&commonargs, 0);
|
||||
rc = libappletArgsPush(&commonargs, &holder);
|
||||
|
||||
if (R_SUCCEEDED(rc)) rc = libappletPushInData(&holder, &config->arg, sizeof(config->arg));
|
||||
|
||||
if (R_SUCCEEDED(rc)) rc = appletHolderStart(&holder);
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
appletHolderJoin(&holder);
|
||||
|
||||
LibAppletExitReason reason = appletHolderGetExitReason(&holder);
|
||||
|
||||
if (reason == LibAppletExitReason_Canceled || reason == LibAppletExitReason_Abnormal || reason == LibAppletExitReason_Unexpected) {
|
||||
rc = MAKERESULT(Module_Libnx, LibnxError_LibAppletBadExit);
|
||||
}
|
||||
}
|
||||
|
||||
appletHolderClose(&holder);
|
||||
|
||||
return rc;
|
||||
}
|
Loading…
Reference in New Issue
Block a user