mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-26 14:52:39 +02:00
Moved web applet-exit handling into a dedicated func, which can optionally handle reading the applet reply storage. Added out param to webWifiShow for the applet reply data.
This commit is contained in:
parent
f392dc0ce2
commit
e2f05654dd
@ -16,6 +16,11 @@ typedef struct {
|
||||
u32 unk_x514;
|
||||
} PACKED WebWifiPageArg;
|
||||
|
||||
typedef struct {
|
||||
u32 unk_x0;
|
||||
Result res;
|
||||
} PACKED WebWifiReturnValue;
|
||||
|
||||
typedef struct {
|
||||
WebWifiPageArg arg;
|
||||
} WebWifiConfig;
|
||||
@ -33,6 +38,7 @@ void webWifiCreate(WebWifiConfig* config, const char* conntest_url, const char*
|
||||
/**
|
||||
* @brief Launches WifiWebAuthApplet with the specified config and waits for it to exit.
|
||||
* @param config WebWifiConfig object.
|
||||
* @param out Optional output applet reply data, can be NULL.
|
||||
*/
|
||||
Result webWifiShow(WebWifiConfig* config);
|
||||
Result webWifiShow(WebWifiConfig* config, WebWifiReturnValue *out);
|
||||
|
||||
|
@ -6,6 +6,25 @@
|
||||
#include "applets/libapplet.h"
|
||||
#include "applets/web.h"
|
||||
|
||||
static Result _webHandleExit(AppletHolder* holder, void* reply_buffer, size_t reply_size) {
|
||||
Result rc=0;
|
||||
size_t transfer_size=0;
|
||||
appletHolderJoin(holder);
|
||||
|
||||
LibAppletExitReason reason = appletHolderGetExitReason(holder);
|
||||
|
||||
if (reason == LibAppletExitReason_Canceled || reason == LibAppletExitReason_Abnormal || reason == LibAppletExitReason_Unexpected) {
|
||||
rc = MAKERESULT(Module_Libnx, LibnxError_LibAppletBadExit);
|
||||
}
|
||||
|
||||
if (R_SUCCEEDED(rc) && reply_buffer && reply_size) {
|
||||
rc = libappletPopOutData(holder, reply_buffer, reply_size, &transfer_size);
|
||||
if (R_SUCCEEDED(rc) && transfer_size != reply_size) rc = MAKERESULT(Module_Libnx, LibnxError_BadInput);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
void webWifiCreate(WebWifiConfig* config, const char* conntest_url, const char* initial_url, u128 userID, u32 unk) {
|
||||
memset(config, 0, sizeof(WebWifiConfig));
|
||||
|
||||
@ -18,7 +37,7 @@ void webWifiCreate(WebWifiConfig* config, const char* conntest_url, const char*
|
||||
config->arg.unk_x514 = unk;
|
||||
}
|
||||
|
||||
Result webWifiShow(WebWifiConfig* config) {
|
||||
Result webWifiShow(WebWifiConfig* config, WebWifiReturnValue *out) {
|
||||
Result rc = 0;
|
||||
AppletHolder holder;
|
||||
|
||||
@ -33,15 +52,7 @@ Result webWifiShow(WebWifiConfig* config) {
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
if (R_SUCCEEDED(rc)) rc = _webHandleExit(&holder, out, sizeof(*out));
|
||||
|
||||
appletHolderClose(&holder);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user