Added support for the additional web [8.0.0+] functionality: webConfigSetMediaPlayerUi and webReplyGetMediaPlayerAutoClosedByCompletion. Various other changes.

This commit is contained in:
yellows8 2019-05-19 15:15:00 -04:00
parent cf8bb1e045
commit d2bfc032f8
No known key found for this signature in database
GPG Key ID: 0AF90DA3F1E60E43
2 changed files with 61 additions and 10 deletions

View File

@ -99,6 +99,7 @@ typedef struct {
/// Common container struct for applets' reply data, from the output storage. /// Common container struct for applets' reply data, from the output storage.
typedef struct { typedef struct {
bool type; ///< Type of reply: false = ret, true = storage. bool type; ///< Type of reply: false = ret, true = storage.
WebShimKind shimKind; ///< ShimKind
WebCommonReturnValue ret; ///< Reply data for reply=false. WebCommonReturnValue ret; ///< Reply data for reply=false.
WebCommonTLVStorage storage; ///< Reply data for reply=true. WebCommonTLVStorage storage; ///< Reply data for reply=true.
} WebCommonReply; } WebCommonReply;
@ -173,11 +174,14 @@ typedef enum {
WebArgType_BootFooterButton = 0x3E, ///< [6.0.0+] Array of \ref WebBootFooterButtonEntry with 0x10 entries. WebArgType_BootFooterButton = 0x3E, ///< [6.0.0+] Array of \ref WebBootFooterButtonEntry with 0x10 entries.
WebArgType_OverrideWebAudioVolume = 0x3F, ///< [6.0.0+] float WebArgType_OverrideWebAudioVolume = 0x3F, ///< [6.0.0+] float
WebArgType_OverrideMediaAudioVolume = 0x40, ///< [6.0.0+] float WebArgType_OverrideMediaAudioVolume = 0x40, ///< [6.0.0+] float
WebArgType_SessionBootMode = 0x41, ///< [7.0.0+] u32 enum WebSessionBootMode
WebArgType_SessionFlag = 0x42, ///< [7.0.0+] u8 bool, enables using WebSession when set.
WebArgType_MediaPlayerUi = 0x43, ///< [8.0.0+] u8 bool
} WebArgType; } WebArgType;
/// Types for \ref WebArgTLV, output storage. /// Types for \ref WebArgTLV, output storage.
typedef enum { typedef enum {
WebReplyType_ExitReason = 0x1, ///< [3.0.0+] u32 ShareExitReason WebReplyType_ExitReason = 0x1, ///< [3.0.0+] u32 ExitReason
WebReplyType_LastUrl = 0x2, ///< [3.0.0+] string WebReplyType_LastUrl = 0x2, ///< [3.0.0+] string
WebReplyType_LastUrlSize = 0x3, ///< [3.0.0+] u64 WebReplyType_LastUrlSize = 0x3, ///< [3.0.0+] u64
WebReplyType_SharePostResult = 0x4, ///< [3.0.0+] u32 SharePostResult WebReplyType_SharePostResult = 0x4, ///< [3.0.0+] u32 SharePostResult
@ -185,6 +189,7 @@ typedef enum {
WebReplyType_PostServiceNameSize = 0x6, ///< [3.0.0+] u64 WebReplyType_PostServiceNameSize = 0x6, ///< [3.0.0+] u64
WebReplyType_PostId = 0x7, ///< [3.0.0+] string WebReplyType_PostId = 0x7, ///< [3.0.0+] string
WebReplyType_PostIdSize = 0x8, ///< [3.0.0+] u64 WebReplyType_PostIdSize = 0x8, ///< [3.0.0+] u64
WebReplyType_MediaPlayerAutoClosedByCompletion = 0x9, ///< [8.0.0+] u8 bool
} WebReplyType; } WebReplyType;
/// This controls the kind of content to mount with Offline-applet. /// This controls the kind of content to mount with Offline-applet.
@ -642,6 +647,14 @@ Result webConfigSetOverrideWebAudioVolume(WebCommonConfig* config, float value);
*/ */
Result webConfigSetOverrideMediaAudioVolume(WebCommonConfig* config, float value); Result webConfigSetOverrideMediaAudioVolume(WebCommonConfig* config, float value);
/**
* @brief Sets whether MediaPlayerUi is enabled.
* @note Only available with config created by \ref webOfflineCreate on [8.0.0+].
* @param config WebCommonConfig object.
* @param flag Flag
*/
Result webConfigSetMediaPlayerUi(WebCommonConfig* config, bool flag);
/** /**
* @brief Launches the {web applet} with the specified config and waits for it to exit. * @brief Launches the {web applet} with the specified config and waits for it to exit.
* @param config WebCommonConfig object. * @param config WebCommonConfig object.
@ -703,3 +716,11 @@ Result webReplyGetPostServiceName(WebCommonReply *reply, char *outstr, size_t ou
*/ */
Result webReplyGetPostId(WebCommonReply *reply, char *outstr, size_t outstr_maxsize, size_t *out_size); Result webReplyGetPostId(WebCommonReply *reply, char *outstr, size_t outstr_maxsize, size_t *out_size);
/**
* @brief Gets the MediaPlayerAutoClosedByCompletion flag from the specified reply.
* @note Only available with reply data from Web on [8.0.0+].
* @param reply WebCommonReply object.
* @param flag Output flag
*/
Result webReplyGetMediaPlayerAutoClosedByCompletion(WebCommonReply *reply, bool *flag);

View File

@ -79,7 +79,9 @@ static void _webArgInitialize(WebCommonConfig* config, AppletId appletid, WebShi
config->appletid = appletid; config->appletid = appletid;
u32 hosver = hosversionGet(); u32 hosver = hosversionGet();
if (hosver >= MAKEHOSVERSION(6,0,0)) if (hosver >= MAKEHOSVERSION(8,0,0))
config->version = 0x80000;
else if (hosver >= MAKEHOSVERSION(6,0,0))
config->version = 0x60000; config->version = 0x60000;
else if (hosver >= MAKEHOSVERSION(5,0,0)) else if (hosver >= MAKEHOSVERSION(5,0,0))
config->version = 0x50000; config->version = 0x50000;
@ -685,14 +687,25 @@ Result webConfigSetOverrideMediaAudioVolume(WebCommonConfig* config, float value
return _webConfigSetFloat(config, WebArgType_OverrideMediaAudioVolume, value); return _webConfigSetFloat(config, WebArgType_OverrideMediaAudioVolume, value);
} }
Result webConfigSetMediaPlayerUi(WebCommonConfig* config, bool flag) {
if (_webGetShimKind(config) != WebShimKind_Offline) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);
if (hosversionBefore(8,0,0)) return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _webConfigSetFlag(config, WebArgType_MediaPlayerUi, flag);
}
Result webConfigShow(WebCommonConfig* config, WebCommonReply *out) { Result webConfigShow(WebCommonConfig* config, WebCommonReply *out) {
void* reply = NULL; void* reply = NULL;
size_t size = 0; size_t size = 0;
WebShimKind shimKind = _webGetShimKind(config);
if (out) { if (out) {
// ShareApplet on [3.0.0+] uses TLV storage for the reply, while older versions + everything else uses *ReturnValue. // ShareApplet on [3.0.0+] uses TLV storage for the reply, while older versions + everything else uses *ReturnValue.
// Web also uses TLV storage for the reply on [8.0.0+].
memset(out, 0, sizeof(*out)); memset(out, 0, sizeof(*out));
if (config->version >= 0x30000 && _webGetShimKind(config) == WebShimKind_Share) out->type = true; out->shimKind = shimKind;
if (config->version >= 0x30000 && shimKind == WebShimKind_Share) out->type = true;
if (config->version >= 0x80000 && shimKind == WebShimKind_Web) out->type = true;
if (!out->type) { if (!out->type) {
reply = &out->ret; reply = &out->ret;
@ -758,6 +771,8 @@ Result webReplyGetLastUrl(WebCommonReply *reply, char *outstr, size_t outstr_max
} }
Result webReplyGetSharePostResult(WebCommonReply *reply, u32 *sharePostResult) { Result webReplyGetSharePostResult(WebCommonReply *reply, u32 *sharePostResult) {
if (reply->shimKind != WebShimKind_Share) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);
if (reply->type) { if (reply->type) {
return _webTLVRead(&reply->storage, WebReplyType_SharePostResult, sharePostResult, sizeof(*sharePostResult)); return _webTLVRead(&reply->storage, WebReplyType_SharePostResult, sharePostResult, sizeof(*sharePostResult));
} }
@ -765,10 +780,25 @@ Result webReplyGetSharePostResult(WebCommonReply *reply, u32 *sharePostResult) {
} }
Result webReplyGetPostServiceName(WebCommonReply *reply, char *outstr, size_t outstr_maxsize, size_t *out_size) { Result webReplyGetPostServiceName(WebCommonReply *reply, char *outstr, size_t outstr_maxsize, size_t *out_size) {
if (reply->shimKind != WebShimKind_Share) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);
return _webReplyGetString(reply, WebReplyType_PostServiceName, WebReplyType_PostServiceNameSize, outstr, outstr_maxsize, out_size); return _webReplyGetString(reply, WebReplyType_PostServiceName, WebReplyType_PostServiceNameSize, outstr, outstr_maxsize, out_size);
} }
Result webReplyGetPostId(WebCommonReply *reply, char *outstr, size_t outstr_maxsize, size_t *out_size) { Result webReplyGetPostId(WebCommonReply *reply, char *outstr, size_t outstr_maxsize, size_t *out_size) {
if (reply->shimKind != WebShimKind_Share) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);
return _webReplyGetString(reply, WebReplyType_PostId, WebReplyType_PostIdSize, outstr, outstr_maxsize, out_size); return _webReplyGetString(reply, WebReplyType_PostId, WebReplyType_PostIdSize, outstr, outstr_maxsize, out_size);
} }
Result webReplyGetMediaPlayerAutoClosedByCompletion(WebCommonReply *reply, bool *flag) {
Result rc=0;
u8 tmpflag=0;
if (!reply->type) return MAKERESULT(Module_Libnx, LibnxError_BadInput);
if (reply->shimKind != WebShimKind_Web) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);
rc = _webTLVRead(&reply->storage, WebReplyType_MediaPlayerAutoClosedByCompletion, &tmpflag, sizeof(tmpflag));
if (R_SUCCEEDED(rc) && flag) *flag = tmpflag!=0;
return rc;
}