94 lines
2.9 KiB
C++
94 lines
2.9 KiB
C++
#include <atomic>
|
|
#include <cstdint>
|
|
#include <stdexcept>
|
|
#include <cstddef>
|
|
#include "SceTypes.hpp"
|
|
#include "prx/libc/include/General.hpp"
|
|
|
|
namespace {
|
|
std::atomic<int> g_status{0};
|
|
|
|
constexpr int COMMON_DIALOG_STATUS_NONE = 0;
|
|
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_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);
|
|
}
|
|
|
|
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");
|
|
return 0;
|
|
}
|
|
|
|
int APS5_VABI sceWebBrowserDialogTerminate(void) {
|
|
int expected = 1;
|
|
if (!g_status.compare_exchange_strong(expected, 0)) throw std::logic_error("sceWebBrowserDialogTerminate: not initialized or still running");
|
|
return 0;
|
|
}
|
|
|
|
int APS5_VABI sceWebBrowserDialogClose(void) {
|
|
if (g_status.load() == COMMON_DIALOG_STATUS_NONE) return COMMON_DIALOG_ERROR_NOT_INITIALIZED;
|
|
return 0;
|
|
}
|
|
|
|
int APS5_VABI sceWebBrowserDialogGetResult(void* result) {
|
|
const int status = g_status.load();
|
|
if (status == COMMON_DIALOG_STATUS_NONE) return COMMON_DIALOG_ERROR_NOT_INITIALIZED;
|
|
if (result == nullptr) return COMMON_DIALOG_ERROR_ARG_NULL;
|
|
if (status != COMMON_DIALOG_STATUS_FINISHED) return COMMON_DIALOG_ERROR_NOT_FINISHED;
|
|
*static_cast<std::int32_t*>(result) = COMMON_DIALOG_RESULT_USER_CANCELED;
|
|
return 0;
|
|
}
|
|
|
|
int APS5_VABI sceWebBrowserDialogGetStatus(void) {
|
|
return g_status.load();
|
|
}
|
|
|
|
int APS5_VABI sceWebBrowserDialogOpen(const void* param) {
|
|
const int status = g_status.load();
|
|
if (status == COMMON_DIALOG_STATUS_NONE) return COMMON_DIALOG_ERROR_NOT_INITIALIZED;
|
|
if (status == COMMON_DIALOG_STATUS_RUNNING) return COMMON_DIALOG_ERROR_BUSY;
|
|
if (param == nullptr) return COMMON_DIALOG_ERROR_ARG_NULL;
|
|
g_status = COMMON_DIALOG_STATUS_FINISHED;
|
|
return 0;
|
|
}
|
|
|
|
int APS5_VABI sceWebBrowserDialogUpdateStatus(void) {
|
|
return g_status.load();
|
|
}
|
|
|
|
|
|
int APS5_VABI sceWebBrowserDialogSetCookie(void) {
|
|
NotImplemented_nid_no_patch(__func__);
|
|
return 0;
|
|
}
|
|
|
|
int APS5_VABI sceWebBrowserDialogOpenForPredeterminedContent() {
|
|
NotImplemented_nid_no_patch(__func__);
|
|
return 0;
|
|
}
|
|
|
|
int APS5_VABI sceWebBrowserDialogResetCookie() {
|
|
NotImplemented_nid_no_patch(__func__);
|
|
return 0;
|
|
}
|
|
|
|
APS5_EXPORT("5tRaBjtdTzY", sceWebBrowserDialogUnknown00);
|
|
int APS5_VABI sceWebBrowserDialogUnknown00(void) {
|
|
NotImplemented_nid_no_patch("5tRaBjtdTzY");
|
|
return 0;
|
|
}
|
|
|
|
APS5_EXPORT("T4ucGB8CsnM", sceWebBrowserDialogUnknown01);
|
|
int APS5_VABI sceWebBrowserDialogUnknown01(void) {
|
|
NotImplemented_nid_no_patch("T4ucGB8CsnM");
|
|
return 0;
|
|
}
|
|
}
|