mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-25 12:12:50 +01:00
Invite changes
This commit is contained in:
parent
192f4825a2
commit
02a53c582c
@ -19,6 +19,7 @@
|
||||
#include "Emu/NP/np_handler.h"
|
||||
#include "Emu/NP/np_contexts.h"
|
||||
#include "Emu/NP/np_helpers.h"
|
||||
#include "Emu/NP/np_structs_extra.h"
|
||||
#include "Emu/system_config.h"
|
||||
|
||||
LOG_CHANNEL(sceNp);
|
||||
@ -985,6 +986,26 @@ error_code sceNpBasicSendMessageGui(vm::cptr<SceNpBasicMessageDetails> msg, sys_
|
||||
msg_data.data.assign(msg->data.get_ptr(), msg->data.get_ptr() + msg->size);
|
||||
}
|
||||
|
||||
if (sceNp.trace)
|
||||
{
|
||||
std::string datrace;
|
||||
const char hex[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
|
||||
|
||||
const u8* buf = msg->data.get_ptr();
|
||||
|
||||
for (u32 index = 0; index < msg->size; index++)
|
||||
{
|
||||
if ((index % 16) == 0)
|
||||
datrace += '\n';
|
||||
|
||||
datrace += hex[(buf[index] >> 4) & 15];
|
||||
datrace += hex[(buf[index]) & 15];
|
||||
datrace += ' ';
|
||||
}
|
||||
|
||||
sceNp.trace("Message Data: %s", datrace);
|
||||
}
|
||||
|
||||
bool result = false;
|
||||
|
||||
input::SetIntercepted(true);
|
||||
@ -1082,7 +1103,7 @@ error_code sceNpBasicRecvMessageAttachment(sys_memory_container_t containerId)
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
error_code sceNpBasicRecvMessageAttachmentLoad(u32 id, vm::ptr<void> buffer, vm::ptr<u32> size)
|
||||
error_code sceNpBasicRecvMessageAttachmentLoad(ppu_thread& ppu, SceNpBasicAttachmentDataId id, vm::ptr<void> buffer, vm::ptr<u32> size)
|
||||
{
|
||||
sceNp.warning("sceNpBasicRecvMessageAttachmentLoad(id=%d, buffer=*0x%x, size=*0x%x)", id, buffer, size);
|
||||
|
||||
@ -1103,12 +1124,19 @@ error_code sceNpBasicRecvMessageAttachmentLoad(u32 id, vm::ptr<void> buffer, vm:
|
||||
return SCE_NP_BASIC_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
const auto opt_msg = nph.get_message(id);
|
||||
if (id != SCE_NP_BASIC_SELECTED_INVITATION_DATA && id != SCE_NP_BASIC_SELECTED_MESSAGE_DATA)
|
||||
{
|
||||
return SCE_NP_BASIC_ERROR_INVALID_DATA_ID;
|
||||
}
|
||||
|
||||
const auto opt_msg = nph.get_message_selected(id);
|
||||
if (!opt_msg)
|
||||
{
|
||||
return SCE_NP_BASIC_ERROR_INVALID_DATA_ID;
|
||||
}
|
||||
|
||||
// nph.clear_message_selected(id);
|
||||
|
||||
const auto msg_pair = opt_msg.value();
|
||||
const auto msg = msg_pair->second;
|
||||
|
||||
@ -1116,6 +1144,25 @@ error_code sceNpBasicRecvMessageAttachmentLoad(u32 id, vm::ptr<void> buffer, vm:
|
||||
const u32 size_to_copy = std::min(static_cast<u32>(msg.data.size()), orig_size);
|
||||
memcpy(buffer.get_ptr(), msg.data.data(), size_to_copy);
|
||||
|
||||
if (sceNp.trace)
|
||||
{
|
||||
std::string datrace;
|
||||
const char hex[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
|
||||
|
||||
const u8* buf = static_cast<u8*>(buffer.get_ptr());
|
||||
for (u32 index = 0; index < size_to_copy; index++)
|
||||
{
|
||||
if ((index % 16) == 0)
|
||||
datrace += '\n';
|
||||
|
||||
datrace += hex[(buf[index] >> 4) & 15];
|
||||
datrace += hex[(buf[index]) & 15];
|
||||
datrace += ' ';
|
||||
}
|
||||
|
||||
sceNp.trace("Message Data received: %s", datrace);
|
||||
}
|
||||
|
||||
*size = size_to_copy;
|
||||
if (size_to_copy < msg.data.size())
|
||||
{
|
||||
@ -1180,11 +1227,17 @@ error_code sceNpBasicRecvMessageCustom(u16 mainType, u32 recvOptions, sys_memory
|
||||
SceNpBasicExtendedAttachmentData* att_data = reinterpret_cast<SceNpBasicExtendedAttachmentData*>(to_add.data.data());
|
||||
att_data->flags = 0; // ?
|
||||
att_data->msgId = chosen_msg_id;
|
||||
att_data->data.id = static_cast<u32>(chosen_msg_id);
|
||||
att_data->data.id = (mainType == SCE_NP_BASIC_MESSAGE_MAIN_TYPE_INVITE) ? SCE_NP_BASIC_SELECTED_INVITATION_DATA : SCE_NP_BASIC_SELECTED_MESSAGE_DATA;
|
||||
att_data->data.size = static_cast<u32>(msg.data.size());
|
||||
att_data->userAction = recv_result;
|
||||
att_data->markedAsUsed = (recvOptions & SCE_NP_BASIC_RECV_MESSAGE_OPTIONS_PRESERVE) ? 0 : 1;
|
||||
|
||||
extra_nps::print_SceNpBasicExtendedAttachmentData(att_data);
|
||||
|
||||
nph.set_message_selected(att_data->data.id, chosen_msg_id);
|
||||
|
||||
// sysutil_send_system_cmd(CELL_SYSUTIL_NP_INVITATION_SELECTED, 0);
|
||||
|
||||
nph.queue_basic_event(to_add);
|
||||
nph.send_basic_event(event_to_send, 0, 0);
|
||||
|
||||
@ -1985,7 +2038,7 @@ error_code sceNpBasicGetMessageEntry(u32 type, u32 index, vm::ptr<SceNpUserInfo>
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
error_code sceNpBasicGetEvent(vm::ptr<s32> event, vm::ptr<SceNpUserInfo> from, vm::ptr<s32> data, vm::ptr<u32> size)
|
||||
error_code sceNpBasicGetEvent(vm::ptr<s32> event, vm::ptr<SceNpUserInfo> from, vm::ptr<u8> data, vm::ptr<u32> size)
|
||||
{
|
||||
sceNp.warning("sceNpBasicGetEvent(event=*0x%x, from=*0x%x, data=*0x%x, size=*0x%x)", event, from, data, size);
|
||||
|
||||
|
@ -1057,7 +1057,7 @@ struct SceNpManagerCacheParam
|
||||
// Message attachment data
|
||||
struct SceNpBasicAttachmentData
|
||||
{
|
||||
be_t<u32> id; // SceNpBasicAttachmentDataId
|
||||
be_t<SceNpBasicAttachmentDataId> id;
|
||||
be_t<u32> size;
|
||||
};
|
||||
|
||||
@ -1068,7 +1068,7 @@ struct SceNpBasicExtendedAttachmentData
|
||||
be_t<u64> msgId;
|
||||
SceNpBasicAttachmentData data;
|
||||
be_t<u32> userAction;
|
||||
b8 markedAsUsed;
|
||||
u8 markedAsUsed;
|
||||
u8 reserved[3];
|
||||
};
|
||||
|
||||
|
@ -790,7 +790,7 @@ namespace np
|
||||
queue_basic_events.push(std::move(to_queue));
|
||||
}
|
||||
|
||||
error_code np_handler::get_basic_event(vm::ptr<s32> event, vm::ptr<SceNpUserInfo> from, vm::ptr<s32> data, vm::ptr<u32> size)
|
||||
error_code np_handler::get_basic_event(vm::ptr<s32> event, vm::ptr<SceNpUserInfo> from, vm::ptr<u8> data, vm::ptr<u32> size)
|
||||
{
|
||||
basic_event cur_event;
|
||||
{
|
||||
@ -817,6 +817,8 @@ namespace np
|
||||
return SCE_NP_BASIC_ERROR_DATA_LOST;
|
||||
}
|
||||
|
||||
nph_log.notice("basic_event: event:%d, from:%s(%s), size:%d", *event, static_cast<char*>(from->userId.handle.data), static_cast<char*>(from->name.data), *size);
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
@ -825,6 +827,55 @@ namespace np
|
||||
return get_rpcn()->get_message(id);
|
||||
}
|
||||
|
||||
void np_handler::set_message_selected(SceNpBasicAttachmentDataId id, u64 msg_id)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case SCE_NP_BASIC_SELECTED_INVITATION_DATA:
|
||||
selected_invite_id = msg_id;
|
||||
break;
|
||||
case SCE_NP_BASIC_SELECTED_MESSAGE_DATA:
|
||||
selected_message_id = msg_id;
|
||||
break;
|
||||
default:
|
||||
fmt::throw_exception("set_message_selected with id %d", id);
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<std::shared_ptr<std::pair<std::string, message_data>>> np_handler::get_message_selected(SceNpBasicAttachmentDataId id)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case SCE_NP_BASIC_SELECTED_INVITATION_DATA:
|
||||
if (!selected_invite_id)
|
||||
return std::nullopt;
|
||||
|
||||
return get_message(*selected_invite_id);
|
||||
case SCE_NP_BASIC_SELECTED_MESSAGE_DATA:
|
||||
if (!selected_message_id)
|
||||
return std::nullopt;
|
||||
|
||||
return get_message(*selected_message_id);
|
||||
default:
|
||||
fmt::throw_exception("get_message_selected with id %d", id);
|
||||
}
|
||||
}
|
||||
|
||||
void np_handler::clear_message_selected(SceNpBasicAttachmentDataId id)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case SCE_NP_BASIC_SELECTED_INVITATION_DATA:
|
||||
selected_invite_id = std::nullopt;
|
||||
break;
|
||||
case SCE_NP_BASIC_SELECTED_MESSAGE_DATA:
|
||||
selected_message_id = std::nullopt;
|
||||
break;
|
||||
default:
|
||||
fmt::throw_exception("clear_message_selected with id %d", id);
|
||||
}
|
||||
}
|
||||
|
||||
void np_handler::operator()()
|
||||
{
|
||||
if (g_cfg.net.psn_status != np_psn_status::psn_rpcn)
|
||||
|
@ -123,10 +123,13 @@ namespace np
|
||||
|
||||
void queue_basic_event(basic_event to_queue);
|
||||
bool send_basic_event(s32 event, s32 retCode, u32 reqId);
|
||||
error_code get_basic_event(vm::ptr<s32> event, vm::ptr<SceNpUserInfo> from, vm::ptr<s32> data, vm::ptr<u32> size);
|
||||
error_code get_basic_event(vm::ptr<s32> event, vm::ptr<SceNpUserInfo> from, vm::ptr<u8> data, vm::ptr<u32> size);
|
||||
|
||||
// Messages-related functions
|
||||
std::optional<std::shared_ptr<std::pair<std::string, message_data>>> get_message(u64 id);
|
||||
void set_message_selected(SceNpBasicAttachmentDataId id, u64 msg_id);
|
||||
std::optional<std::shared_ptr<std::pair<std::string, message_data>>> get_message_selected(SceNpBasicAttachmentDataId id);
|
||||
void clear_message_selected(SceNpBasicAttachmentDataId id);
|
||||
|
||||
// Those should probably be under match2 ctx
|
||||
vm::ptr<SceNpMatching2RoomEventCallback> room_event_cb{}; // Room events
|
||||
@ -328,6 +331,10 @@ namespace np
|
||||
std::optional<SceNpMatching2SessionPassword> cached_cj_password;
|
||||
cache_manager np_cache;
|
||||
|
||||
// Messages related
|
||||
std::optional<u64> selected_invite_id{};
|
||||
std::optional<u64> selected_message_id{};
|
||||
|
||||
// Requests(reqEventKey : data)
|
||||
shared_mutex mutex_match2_req_results;
|
||||
std::unordered_map<u32, event_data> match2_req_results;
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "Emu/System.h"
|
||||
#include "np_structs_extra.h"
|
||||
|
||||
LOG_CHANNEL(sceNp);
|
||||
LOG_CHANNEL(sceNp2);
|
||||
|
||||
// Helper functions for printing
|
||||
@ -329,4 +330,16 @@ namespace extra_nps
|
||||
}
|
||||
}
|
||||
|
||||
void print_SceNpBasicExtendedAttachmentData(const SceNpBasicExtendedAttachmentData* data)
|
||||
{
|
||||
sceNp.warning("SceNpBasicExtendedAttachmentData:");
|
||||
|
||||
sceNp.warning("flags: 0x%x", data->flags);
|
||||
sceNp.warning("msgId: %d", data->msgId);
|
||||
sceNp.warning("SceNpBasicAttachmentData.id: %d", data->data.id);
|
||||
sceNp.warning("SceNpBasicAttachmentData.size: %d", data->data.size);
|
||||
sceNp.warning("userAction: %d", data->userAction);
|
||||
sceNp.warning("markedAsUsed: %d", data->markedAsUsed);
|
||||
}
|
||||
|
||||
} // namespace extra_nps
|
||||
|
@ -23,4 +23,6 @@ namespace extra_nps
|
||||
void print_set_roommemberdata_int_req(const SceNpMatching2SetRoomMemberDataInternalRequest* req);
|
||||
void print_get_roomdata_external_list_req(const SceNpMatching2GetRoomDataExternalListRequest* req);
|
||||
void print_get_roomdata_external_list_resp(const SceNpMatching2GetRoomDataExternalListResponse* resp);
|
||||
|
||||
void print_SceNpBasicExtendedAttachmentData(const SceNpBasicExtendedAttachmentData* data);
|
||||
} // namespace extra_nps
|
||||
|
@ -2151,6 +2151,10 @@ namespace rpcn
|
||||
{
|
||||
{
|
||||
std::lock_guard lock(mutex_messages);
|
||||
|
||||
if (!messages.contains(id))
|
||||
return std::nullopt;
|
||||
|
||||
return ::at32(messages, id);
|
||||
}
|
||||
}
|
||||
@ -2194,7 +2198,7 @@ namespace rpcn
|
||||
}
|
||||
}
|
||||
|
||||
void rpcn_client::discard_active_message(u64 id)
|
||||
void rpcn_client::mark_message_used(u64 id)
|
||||
{
|
||||
std::lock_guard lock(mutex_messages);
|
||||
|
||||
|
@ -360,7 +360,7 @@ namespace rpcn
|
||||
std::optional<std::shared_ptr<std::pair<std::string, message_data>>> get_message(u64 id);
|
||||
std::vector<std::pair<u64, std::shared_ptr<std::pair<std::string, message_data>>>> get_messages_and_register_cb(SceNpBasicMessageMainType type, bool include_bootable, message_cb_func cb_func, void* cb_param);
|
||||
void remove_message_cb(message_cb_func cb_func, void* cb_param);
|
||||
void discard_active_message(u64 id);
|
||||
void mark_message_used(u64 id);
|
||||
|
||||
bool is_connected() const
|
||||
{
|
||||
|
@ -75,7 +75,7 @@ bool recvmessage_dialog_frame::Exec(SceNpBasicMessageMainType type, SceNpBasicMe
|
||||
|
||||
if (!preserve)
|
||||
{
|
||||
m_rpcn->discard_active_message(chosen_msg_id);
|
||||
m_rpcn->mark_message_used(chosen_msg_id);
|
||||
}
|
||||
|
||||
m_dialog->close();
|
||||
@ -85,6 +85,8 @@ bool recvmessage_dialog_frame::Exec(SceNpBasicMessageMainType type, SceNpBasicMe
|
||||
{ accept_or_deny(SCE_NP_BASIC_MESSAGE_ACTION_ACCEPT); });
|
||||
connect(btn_deny, &QAbstractButton::clicked, this, [&accept_or_deny]()
|
||||
{ accept_or_deny(SCE_NP_BASIC_MESSAGE_ACTION_DENY); });
|
||||
connect(btn_cancel, &QAbstractButton::clicked, this, [m_dialog=this->m_dialog]()
|
||||
{ m_dialog->close(); });
|
||||
connect(this, &recvmessage_dialog_frame::signal_new_message, this, &recvmessage_dialog_frame::slot_new_message);
|
||||
|
||||
// Get list of messages
|
||||
|
Loading…
Reference in New Issue
Block a user