Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions core/libs/prx/libSceWebBrowserDialog/Export.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include <atomic>
#include <cstdint>
#include <stdexcept>
#include <cstddef>
#include "SceTypes.hpp"
#include "prx/libc/include/General.hpp"
Expand All @@ -13,6 +12,7 @@ constexpr int COMMON_DIALOG_STATUS_RUNNING = 2;
constexpr int COMMON_DIALOG_STATUS_FINISHED = 3;
constexpr int COMMON_DIALOG_RESULT_USER_CANCELED = 1;
constexpr int COMMON_DIALOG_ERROR_NOT_INITIALIZED = static_cast<int>(0x80B80003u);
constexpr int COMMON_DIALOG_ERROR_ALREADY_INITIALIZED = static_cast<int>(0x80B80004u);
constexpr int COMMON_DIALOG_ERROR_NOT_FINISHED = static_cast<int>(0x80B80005u);
constexpr int COMMON_DIALOG_ERROR_BUSY = static_cast<int>(0x80B80007u);
constexpr int COMMON_DIALOG_ERROR_ARG_NULL = static_cast<int>(0x80B8000Du);
Expand All @@ -21,17 +21,18 @@ constexpr int COMMON_DIALOG_ERROR_ARG_NULL = static_cast<int>(0x80B8000Du);
extern "C" {

int APS5_VABI sceWebBrowserDialogInitialize(void) {
int expected = 0;
if (!g_status.compare_exchange_strong(expected, 1)) throw std::logic_error("sceWebBrowserDialogInitialize: already initialized");
int expected = COMMON_DIALOG_STATUS_NONE;
if (!g_status.compare_exchange_strong(expected, 1)) return COMMON_DIALOG_ERROR_ALREADY_INITIALIZED;
return 0;
}

int APS5_VABI sceWebBrowserDialogTerminate(void) {
int expected = 1;
if (g_status.compare_exchange_strong(expected, 0)) return 0;
if (g_status.compare_exchange_strong(expected, COMMON_DIALOG_STATUS_NONE)) return 0;
expected = COMMON_DIALOG_STATUS_FINISHED;
if (!g_status.compare_exchange_strong(expected, 0)) throw std::logic_error("sceWebBrowserDialogTerminate: not initialized or still running");
return 0;
if (g_status.compare_exchange_strong(expected, COMMON_DIALOG_STATUS_NONE)) return 0;
if (g_status.load() == COMMON_DIALOG_STATUS_NONE) return COMMON_DIALOG_ERROR_NOT_INITIALIZED;
return COMMON_DIALOG_ERROR_BUSY;
}

int APS5_VABI sceWebBrowserDialogClose(void) {
Expand Down
5 changes: 5 additions & 0 deletions core/libs/tests/GuestWebBrowserDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ constexpr int COMMON_DIALOG_STATUS_INITIALIZED = 1;
constexpr int COMMON_DIALOG_STATUS_FINISHED = 3;
constexpr int COMMON_DIALOG_RESULT_USER_CANCELED = 1;
constexpr int COMMON_DIALOG_ERROR_NOT_INITIALIZED = static_cast<int>(0x80B80003u);
constexpr int COMMON_DIALOG_ERROR_ALREADY_INITIALIZED = static_cast<int>(0x80B80004u);
constexpr int COMMON_DIALOG_ERROR_NOT_FINISHED = static_cast<int>(0x80B80005u);
constexpr int COMMON_DIALOG_ERROR_ARG_NULL = static_cast<int>(0x80B8000Du);

Expand All @@ -30,19 +31,22 @@ int main() {
std::uint8_t param[64] = {};
std::int32_t result = 0x5a5a5a5a;

Require(sceWebBrowserDialogTerminate() == COMMON_DIALOG_ERROR_NOT_INITIALIZED);
Require(sceWebBrowserDialogGetStatus() == COMMON_DIALOG_STATUS_NONE);
Require(sceWebBrowserDialogClose() == COMMON_DIALOG_ERROR_NOT_INITIALIZED);
Require(sceWebBrowserDialogOpen(param) == COMMON_DIALOG_ERROR_NOT_INITIALIZED);
Require(sceWebBrowserDialogGetResult(&result) == COMMON_DIALOG_ERROR_NOT_INITIALIZED);
Require(result == 0x5a5a5a5a);

Require(sceWebBrowserDialogInitialize() == 0);
Require(sceWebBrowserDialogInitialize() == COMMON_DIALOG_ERROR_ALREADY_INITIALIZED);
Require(sceWebBrowserDialogGetStatus() == COMMON_DIALOG_STATUS_INITIALIZED);
Require(sceWebBrowserDialogUpdateStatus() == COMMON_DIALOG_STATUS_INITIALIZED);
Require(sceWebBrowserDialogGetResult(&result) == COMMON_DIALOG_ERROR_NOT_FINISHED);
Require(result == 0x5a5a5a5a);

Require(sceWebBrowserDialogTerminate() == 0);
Require(sceWebBrowserDialogTerminate() == COMMON_DIALOG_ERROR_NOT_INITIALIZED);
Require(sceWebBrowserDialogGetStatus() == COMMON_DIALOG_STATUS_NONE);

Require(sceWebBrowserDialogInitialize() == 0);
Expand All @@ -57,6 +61,7 @@ int main() {

Require(sceWebBrowserDialogClose() == 0);
Require(sceWebBrowserDialogTerminate() == 0);
Require(sceWebBrowserDialogTerminate() == COMMON_DIALOG_ERROR_NOT_INITIALIZED);
Require(sceWebBrowserDialogGetStatus() == COMMON_DIALOG_STATUS_NONE);

return 0;
Expand Down
Loading