mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2026-07-09 17:25:37 -06:00
sceNpWebApi2Initialize, sceNpWebApi2InitializeForPresence, sceNpWebApi2IntInitialize, sceNpWebApi2IntInitialize2
Defines classes for various existing objects in the library, and adds support for creating library context objects.
This commit is contained in:
parent
8b12fc2fc6
commit
1e25d73f48
@ -641,8 +641,6 @@ set(NP_LIBS src/core/libraries/np/np_error.h
|
||||
src/core/libraries/np/np_tus.h
|
||||
src/core/libraries/np/trophy_ui.cpp
|
||||
src/core/libraries/np/trophy_ui.h
|
||||
src/core/libraries/np/np_web_api2.cpp
|
||||
src/core/libraries/np/np_web_api2.h
|
||||
src/core/libraries/np/np_party.cpp
|
||||
src/core/libraries/np/np_party.h
|
||||
src/core/libraries/np/np_auth.cpp
|
||||
@ -677,6 +675,14 @@ set(NP_LIBS src/core/libraries/np/np_error.h
|
||||
src/core/libraries/np/np_web_api/np_web_api.h
|
||||
src/core/libraries/np/np_web_api/np_web_api_internal.cpp
|
||||
src/core/libraries/np/np_web_api/np_web_api_internal.h
|
||||
src/core/libraries/np/np_web_api2/np_web_api2.cpp
|
||||
src/core/libraries/np/np_web_api2/np_web_api2.h
|
||||
src/core/libraries/np/np_web_api2/np_web_api2_internal.cpp
|
||||
src/core/libraries/np/np_web_api2/np_web_api2_internal.h
|
||||
src/core/libraries/np/np_web_api2/np_web_api2_context.cpp
|
||||
src/core/libraries/np/np_web_api2/np_web_api2_context.h
|
||||
src/core/libraries/np/np_web_api2/np_web_api2_push_event.cpp
|
||||
src/core/libraries/np/np_web_api2/np_web_api2_push_event.h
|
||||
)
|
||||
|
||||
set(ZLIB_LIB src/core/libraries/zlib/zlib.cpp
|
||||
|
||||
@ -48,7 +48,7 @@
|
||||
#include "core/libraries/np/np_trophy.h"
|
||||
#include "core/libraries/np/np_tus.h"
|
||||
#include "core/libraries/np/np_web_api/np_web_api.h"
|
||||
#include "core/libraries/np/np_web_api2.h"
|
||||
#include "core/libraries/np/np_web_api2/np_web_api2.h"
|
||||
#include "core/libraries/pad/pad.h"
|
||||
#include "core/libraries/playgo/playgo.h"
|
||||
#include "core/libraries/playgo/playgo_dialog.h"
|
||||
|
||||
@ -6,7 +6,8 @@
|
||||
#include "core/libraries/error_codes.h"
|
||||
#include "core/libraries/libs.h"
|
||||
#include "core/libraries/np/np_error.h"
|
||||
#include "core/libraries/np/np_web_api2.h"
|
||||
#include "core/libraries/np/np_web_api2/np_web_api2.h"
|
||||
#include "core/libraries/np/np_web_api2/np_web_api2_internal.h"
|
||||
#include "core/libraries/system/userservice.h"
|
||||
|
||||
namespace Libraries::Np::NpWebApi2 {
|
||||
@ -85,15 +86,21 @@ s32 PS4_SYSV_ABI sceNpWebApi2GetMemoryPoolStats(s32 lib_ctx_id,
|
||||
}
|
||||
|
||||
s32 PS4_SYSV_ABI sceNpWebApi2Initialize(s32 lib_http_ctx_id, u64 pool_size) {
|
||||
LOG_ERROR(Lib_NpWebApi2, "(STUBBED) called, lib_http_ctx_id = {:#x}, pool_size = {:#x}",
|
||||
lib_http_ctx_id, pool_size);
|
||||
return ORBIS_OK;
|
||||
LOG_DEBUG(Lib_NpWebApi2, "called, lib_http_ctx_id = {:#x}, pool_size = {:#x}", lib_http_ctx_id,
|
||||
pool_size);
|
||||
|
||||
s32 ctx_id = createLibraryContext(lib_http_ctx_id, nullptr);
|
||||
LOG_INFO(Lib_NpWebApi2, "created ctx_id = {:#x}", ctx_id);
|
||||
return ctx_id;
|
||||
}
|
||||
|
||||
s32 PS4_SYSV_ABI sceNpWebApi2InitializeForPresence(s32 lib_http_ctx_id, u64 pool_size) {
|
||||
LOG_ERROR(Lib_NpWebApi2, "(STUBBED) called, lib_http_ctx_id = {:#x}, pool_size = {:#x}",
|
||||
lib_http_ctx_id, pool_size);
|
||||
return ORBIS_OK;
|
||||
LOG_DEBUG(Lib_NpWebApi2, "called, lib_http_ctx_id = {:#x}, pool_size = {:#x}", lib_http_ctx_id,
|
||||
pool_size);
|
||||
|
||||
s32 ctx_id = createLibraryContext(lib_http_ctx_id, nullptr);
|
||||
LOG_INFO(Lib_NpWebApi2, "created ctx_id = {:#x}", ctx_id);
|
||||
return ctx_id;
|
||||
}
|
||||
|
||||
s32 PS4_SYSV_ABI sceNpWebApi2IntCreateRequest() {
|
||||
@ -103,23 +110,32 @@ s32 PS4_SYSV_ABI sceNpWebApi2IntCreateRequest() {
|
||||
|
||||
s32 PS4_SYSV_ABI sceNpWebApi2IntInitialize(const OrbisNpWebApi2IntInitializeArgs* args) {
|
||||
if (args == nullptr || args->struct_size != sizeof(OrbisNpWebApi2IntInitializeArgs)) {
|
||||
LOG_ERROR(Lib_NpWebApi2, "Invalid arguments");
|
||||
return ORBIS_NP_WEBAPI2_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
LOG_ERROR(Lib_NpWebApi2,
|
||||
"(STUBBED) called, lib_http_ctx_id = {:#x}, pool_size = {:#x}, name = '{}'",
|
||||
args->lib_http_ctx_id, args->pool_size, args->name);
|
||||
return ORBIS_OK;
|
||||
LOG_DEBUG(Lib_NpWebApi2, "called, lib_http_ctx_id = {:#x}, pool_size = {:#x}, name = {}",
|
||||
args->lib_http_ctx_id, args->pool_size, args->name ? args->name : "(null)");
|
||||
|
||||
s32 ctx_id = createLibraryContext(args->lib_http_ctx_id, args->name);
|
||||
LOG_INFO(Lib_NpWebApi2, "created ctx_id = {:#x}", ctx_id);
|
||||
return ctx_id;
|
||||
}
|
||||
|
||||
s32 PS4_SYSV_ABI sceNpWebApi2IntInitialize2(const OrbisNpWebApi2IntInitialize2Args* args) {
|
||||
|
||||
if (args == nullptr || args->struct_size != sizeof(OrbisNpWebApi2IntInitialize2Args)) {
|
||||
LOG_ERROR(Lib_NpWebApi2, "Invalid arguments");
|
||||
return ORBIS_NP_WEBAPI2_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
LOG_ERROR(Lib_NpWebApi2,
|
||||
"(STUBBED) called, lib_http_ctx_id = {:#x}, pool_size = {:#x}, name = '{}', "
|
||||
"group = {:#x}",
|
||||
args->lib_http_ctx_id, args->pool_size, args->name, args->push_config_group);
|
||||
return ORBIS_OK;
|
||||
LOG_DEBUG(
|
||||
Lib_NpWebApi2,
|
||||
"called, lib_http_ctx_id = {:#x}, pool_size = {:#x}, name = {}, push_config_group = {:#x}",
|
||||
args->lib_http_ctx_id, args->pool_size, args->name ? args->name : "(null)",
|
||||
args->push_config_group);
|
||||
|
||||
s32 ctx_id = createLibraryContext(args->lib_http_ctx_id, args->name);
|
||||
LOG_INFO(Lib_NpWebApi2, "created ctx_id = {:#x}", ctx_id);
|
||||
return ctx_id;
|
||||
}
|
||||
|
||||
s32 PS4_SYSV_ABI sceNpWebApi2IntPushEventCreateCtxIndFilter() {
|
||||
@ -0,0 +1,8 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2026 shadPS4 Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "core/libraries/np/np_web_api2/np_web_api2_context.h"
|
||||
|
||||
namespace Libraries::Np::NpWebApi2 {
|
||||
|
||||
};
|
||||
53
src/core/libraries/np/np_web_api2/np_web_api2_context.h
Normal file
53
src/core/libraries/np/np_web_api2/np_web_api2_context.h
Normal file
@ -0,0 +1,53 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2026 shadPS4 Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "core/libraries/np/np_web_api2/np_web_api2.h"
|
||||
#include "core/libraries/np/np_web_api2/np_web_api2_push_event.h"
|
||||
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
namespace Libraries::Np::NpWebApi2 {
|
||||
|
||||
// Forward declarations to prevent compile issues
|
||||
class LibraryContext;
|
||||
class UserContext;
|
||||
class Request;
|
||||
|
||||
class LibraryContext {
|
||||
public:
|
||||
LibraryContext(s32 ctx_id, s32 http_ctx_id) : id(ctx_id), http_ctx_id(http_ctx_id) {};
|
||||
LibraryContext(s32 ctx_id, s32 http_ctx_id, const char* name)
|
||||
: id(ctx_id), http_ctx_id(http_ctx_id), name(name) {};
|
||||
|
||||
void Lock() {
|
||||
lock.lock();
|
||||
};
|
||||
|
||||
void Unlock() {
|
||||
lock.unlock();
|
||||
};
|
||||
|
||||
s32 GetId() {
|
||||
return id;
|
||||
};
|
||||
|
||||
s32 GetHttpCtxId() {
|
||||
return http_ctx_id;
|
||||
};
|
||||
|
||||
private:
|
||||
s32 id{};
|
||||
s32 http_ctx_id{};
|
||||
std::recursive_mutex lock{};
|
||||
std::string name{};
|
||||
std::map<s32, PushEventHandle*> push_event_handles{};
|
||||
std::map<s32, PushEventFilter*> push_event_filters{};
|
||||
};
|
||||
|
||||
class UserContext {};
|
||||
|
||||
class Request {};
|
||||
|
||||
}; // namespace Libraries::Np::NpWebApi2
|
||||
45
src/core/libraries/np/np_web_api2/np_web_api2_internal.cpp
Normal file
45
src/core/libraries/np/np_web_api2/np_web_api2_internal.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2026 shadPS4 Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "common/logging/log.h"
|
||||
#include "core/libraries/np/np_error.h"
|
||||
#include "core/libraries/np/np_web_api2/np_web_api2_context.h"
|
||||
#include "core/libraries/np/np_web_api2/np_web_api2_internal.h"
|
||||
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
|
||||
namespace Libraries::Np::NpWebApi2 {
|
||||
|
||||
std::recursive_mutex g_mutex{};
|
||||
s32 g_current_lib_context_id{};
|
||||
std::map<s32, LibraryContext*> g_lib_contexts{};
|
||||
|
||||
s32 createLibraryContext(s32 http_ctx_id, const char* name) {
|
||||
std::scoped_lock lk{g_mutex};
|
||||
|
||||
if (g_lib_contexts.size() >= 0x8000) {
|
||||
LOG_ERROR(Lib_NpWebApi2, "Too many library contexts!");
|
||||
return ORBIS_NP_WEBAPI2_ERROR_LIB_CONTEXT_MAX;
|
||||
}
|
||||
|
||||
// Find next valid ID
|
||||
do {
|
||||
g_current_lib_context_id++;
|
||||
if (g_current_lib_context_id >= 0x8000) {
|
||||
g_current_lib_context_id = 1;
|
||||
}
|
||||
} while(g_lib_contexts.contains(g_current_lib_context_id));
|
||||
|
||||
// Create new LibraryContext
|
||||
if (!name) {
|
||||
g_lib_contexts[g_current_lib_context_id] =
|
||||
new LibraryContext(g_current_lib_context_id, http_ctx_id);
|
||||
} else {
|
||||
g_lib_contexts[g_current_lib_context_id] =
|
||||
new LibraryContext(g_current_lib_context_id, http_ctx_id, name);
|
||||
}
|
||||
return g_current_lib_context_id;
|
||||
};
|
||||
|
||||
}; // namespace Libraries::Np::NpWebApi2
|
||||
8
src/core/libraries/np/np_web_api2/np_web_api2_internal.h
Normal file
8
src/core/libraries/np/np_web_api2/np_web_api2_internal.h
Normal file
@ -0,0 +1,8 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2026 shadPS4 Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
namespace Libraries::Np::NpWebApi2 {
|
||||
|
||||
s32 createLibraryContext(s32 http_ctx_id, const char* name);
|
||||
|
||||
};
|
||||
@ -0,0 +1,8 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2026 shadPS4 Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "core/libraries/np/np_web_api2/np_web_api2_push_event.h"
|
||||
|
||||
namespace Libraries::Np::NpWebApi2 {
|
||||
|
||||
};
|
||||
23
src/core/libraries/np/np_web_api2/np_web_api2_push_event.h
Normal file
23
src/core/libraries/np/np_web_api2/np_web_api2_push_event.h
Normal file
@ -0,0 +1,23 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2026 shadPS4 Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
namespace Libraries::Np::NpWebApi2 {
|
||||
|
||||
// Forward declarations to prevent compile issues
|
||||
class PushEventHandle;
|
||||
class PushEventFilter;
|
||||
class PushEventCallback;
|
||||
class PushEventPushContext;
|
||||
class PushEventPushContextCallback;
|
||||
|
||||
class PushEventHandle {};
|
||||
|
||||
class PushEventFilter {};
|
||||
|
||||
class PushEventCallback {};
|
||||
|
||||
class PushEventPushContext {};
|
||||
|
||||
class PushEventPushContextCallback {};
|
||||
|
||||
}; // namespace Libraries::Np::NpWebApi2
|
||||
Loading…
Reference in New Issue
Block a user