mirror of
https://github.com/RPCS3/rpcs3.git
synced 2026-07-10 01:34:41 -06:00
Use std::string_view in rpcn code
This commit is contained in:
parent
7b5f3e6921
commit
ed6a2f862e
@ -66,7 +66,7 @@ namespace np
|
||||
return sockaddr_ipv6;
|
||||
}
|
||||
|
||||
u32 register_ip(const std::string& ip_bytes)
|
||||
u32 register_ip(std::string_view ip_bytes)
|
||||
{
|
||||
if (ip_bytes.size() == 4)
|
||||
{
|
||||
|
||||
@ -66,7 +66,7 @@ namespace np
|
||||
std::vector<std::array<u8, 16>> ipv4_to_ipv6;
|
||||
};
|
||||
|
||||
u32 register_ip(const std::string& ip_bytes);
|
||||
u32 register_ip(std::string_view ip_bytes);
|
||||
|
||||
enum class IPV6_SUPPORT : u8
|
||||
{
|
||||
|
||||
@ -1303,7 +1303,7 @@ namespace np
|
||||
}
|
||||
}
|
||||
|
||||
bool np_handler::error_and_disconnect(const std::string& error_msg)
|
||||
bool np_handler::error_and_disconnect(std::string_view error_msg)
|
||||
{
|
||||
rpcn_log.error("%s", error_msg);
|
||||
rpcn.reset();
|
||||
|
||||
@ -267,7 +267,7 @@ namespace np
|
||||
error_code abort_request(u32 req_id);
|
||||
|
||||
// For signaling
|
||||
void req_sign_infos(const std::string& npid, u32 conn_id);
|
||||
void req_sign_infos(std::string_view npid, u32 conn_id);
|
||||
|
||||
// For UPNP
|
||||
void upnp_add_port_mapping(u16 internal_port, std::string_view protocol);
|
||||
@ -297,7 +297,7 @@ namespace np
|
||||
// Various generic helpers
|
||||
bool discover_ip_address();
|
||||
bool discover_ether_address();
|
||||
bool error_and_disconnect(const std::string& error_msg);
|
||||
bool error_and_disconnect(std::string_view error_msg);
|
||||
|
||||
// Notification handlers
|
||||
void notif_user_joined_room(vec_stream& noti);
|
||||
|
||||
@ -814,7 +814,7 @@ namespace np
|
||||
cb_info_opt->queue_callback(req_id, 0, error_code, 0);
|
||||
}
|
||||
|
||||
void np_handler::req_sign_infos(const std::string& npid, u32 conn_id)
|
||||
void np_handler::req_sign_infos(std::string_view npid, u32 conn_id)
|
||||
{
|
||||
const u32 req_id = get_req_id(REQUEST_ID_HIGH::MISC);
|
||||
{
|
||||
|
||||
@ -967,7 +967,7 @@ namespace rpcn
|
||||
server_info_received = false;
|
||||
}
|
||||
|
||||
bool rpcn_client::connect(const std::string& host)
|
||||
bool rpcn_client::connect(std::string_view host)
|
||||
{
|
||||
rpcn_log.warning("connect: Attempting to connect");
|
||||
|
||||
@ -1172,7 +1172,7 @@ namespace rpcn
|
||||
return true;
|
||||
}
|
||||
|
||||
bool rpcn_client::login(const std::string& npid, const std::string& password, const std::string& token)
|
||||
bool rpcn_client::login(std::string_view npid, std::string_view password, std::string_view token)
|
||||
{
|
||||
if (npid.empty())
|
||||
{
|
||||
@ -1338,7 +1338,7 @@ namespace rpcn
|
||||
return error;
|
||||
}
|
||||
|
||||
ErrorType rpcn_client::resend_token(const std::string& npid, const std::string& password)
|
||||
ErrorType rpcn_client::resend_token(std::string_view npid, std::string_view password)
|
||||
{
|
||||
if (authentified)
|
||||
{
|
||||
@ -1469,7 +1469,7 @@ namespace rpcn
|
||||
return error;
|
||||
}
|
||||
|
||||
std::optional<ErrorType> rpcn_client::add_friend(const std::string& friend_username)
|
||||
std::optional<ErrorType> rpcn_client::add_friend(std::string_view friend_username)
|
||||
{
|
||||
std::vector<u8> data;
|
||||
std::copy(friend_username.begin(), friend_username.end(), std::back_inserter(data));
|
||||
@ -1494,7 +1494,7 @@ namespace rpcn
|
||||
return error;
|
||||
}
|
||||
|
||||
bool rpcn_client::remove_friend(const std::string& friend_username)
|
||||
bool rpcn_client::remove_friend(std::string_view friend_username)
|
||||
{
|
||||
std::vector<u8> data;
|
||||
std::copy(friend_username.begin(), friend_username.end(), std::back_inserter(data));
|
||||
@ -2159,7 +2159,7 @@ namespace rpcn
|
||||
return forge_request_with_com_id(serialized, communication_id, CommandType::SendRoomMessage, req_id);
|
||||
}
|
||||
|
||||
bool rpcn_client::req_sign_infos(u32 req_id, const std::string& npid)
|
||||
bool rpcn_client::req_sign_infos(u32 req_id, std::string_view npid)
|
||||
{
|
||||
std::vector<u8> data;
|
||||
std::copy(npid.begin(), npid.end(), std::back_inserter(data));
|
||||
@ -2168,7 +2168,7 @@ namespace rpcn
|
||||
return forge_send(CommandType::RequestSignalingInfos, req_id, data);
|
||||
}
|
||||
|
||||
bool rpcn_client::req_ticket(u32 req_id, const std::string& service_id, const std::vector<u8>& cookie)
|
||||
bool rpcn_client::req_ticket(u32 req_id, std::string_view service_id, const std::vector<u8>& cookie)
|
||||
{
|
||||
std::vector<u8> data;
|
||||
std::copy(service_id.begin(), service_id.end(), std::back_inserter(data));
|
||||
@ -2859,7 +2859,7 @@ namespace rpcn
|
||||
memcpy(data.data(), com_id_str.data(), COMMUNICATION_ID_SIZE);
|
||||
}
|
||||
|
||||
bool rpcn_client::forge_request_with_com_id(const std::string& serialized_data, const SceNpCommunicationId& com_id, CommandType command, u64 packet_id)
|
||||
bool rpcn_client::forge_request_with_com_id(std::string_view serialized_data, const SceNpCommunicationId& com_id, CommandType command, u64 packet_id)
|
||||
{
|
||||
const usz bufsize = serialized_data.size();
|
||||
std::vector<u8> data(COMMUNICATION_ID_SIZE + sizeof(u32) + bufsize);
|
||||
@ -2872,7 +2872,7 @@ namespace rpcn
|
||||
return forge_send(command, packet_id, data);
|
||||
}
|
||||
|
||||
bool rpcn_client::forge_request_with_data(const std::string& serialized_data, CommandType command, u64 packet_id)
|
||||
bool rpcn_client::forge_request_with_data(std::string_view serialized_data, CommandType command, u64 packet_id)
|
||||
{
|
||||
const usz bufsize = serialized_data.size();
|
||||
std::vector<u8> data(sizeof(u32) + bufsize);
|
||||
@ -2897,14 +2897,14 @@ namespace rpcn
|
||||
return packet;
|
||||
}
|
||||
|
||||
bool rpcn_client::error_and_disconnect(const std::string& error_msg)
|
||||
bool rpcn_client::error_and_disconnect(std::string_view error_msg)
|
||||
{
|
||||
connected = false;
|
||||
rpcn_log.error("%s", error_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool rpcn_client::error_and_disconnect_notice(const std::string& error_msg)
|
||||
bool rpcn_client::error_and_disconnect_notice(std::string_view error_msg)
|
||||
{
|
||||
connected = false;
|
||||
rpcn_log.notice("%s", error_msg);
|
||||
|
||||
@ -166,7 +166,7 @@ public:
|
||||
vec.push_back(*(reinterpret_cast<u8*>(&value) + index));
|
||||
}
|
||||
}
|
||||
void insert_string(const std::string& str) const
|
||||
void insert_string(std::string_view str) const
|
||||
{
|
||||
std::copy(str.begin(), str.end(), std::back_inserter(vec));
|
||||
vec.push_back(0);
|
||||
@ -277,8 +277,8 @@ namespace rpcn
|
||||
bool send_packet(const std::vector<u8>& packet);
|
||||
|
||||
private:
|
||||
bool connect(const std::string& host);
|
||||
bool login(const std::string& npid, const std::string& password, const std::string& token);
|
||||
bool connect(std::string_view host);
|
||||
bool login(std::string_view npid, std::string_view password, std::string_view token);
|
||||
void disconnect();
|
||||
|
||||
public:
|
||||
@ -297,12 +297,12 @@ namespace rpcn
|
||||
void remove_friend_cb(friend_cb_func, void* cb_param);
|
||||
|
||||
ErrorType create_user(std::string_view npid, std::string_view password, std::string_view online_name, std::string_view avatar_url, std::string_view email);
|
||||
ErrorType resend_token(const std::string& npid, const std::string& password);
|
||||
ErrorType resend_token(std::string_view npid, std::string_view password);
|
||||
ErrorType send_reset_token(std::string_view npid, std::string_view email);
|
||||
ErrorType reset_password(std::string_view npid, std::string_view token, std::string_view password);
|
||||
ErrorType delete_account();
|
||||
std::optional<ErrorType> add_friend(const std::string& friend_username);
|
||||
bool remove_friend(const std::string& friend_username);
|
||||
std::optional<ErrorType> add_friend(std::string_view friend_username);
|
||||
bool remove_friend(std::string_view friend_username);
|
||||
|
||||
u32 get_num_friends() const;
|
||||
u32 get_num_blocks() const;
|
||||
@ -346,8 +346,8 @@ namespace rpcn
|
||||
bool set_userinfo(u32 req_id, const SceNpCommunicationId& communication_id, const SceNpMatching2SetUserInfoRequest* req);
|
||||
bool ping_room_owner(u32 req_id, const SceNpCommunicationId& communication_id, u64 room_id);
|
||||
bool send_room_message(u32 req_id, const SceNpCommunicationId& communication_id, const SceNpMatching2SendRoomMessageRequest* req);
|
||||
bool req_sign_infos(u32 req_id, const std::string& npid);
|
||||
bool req_ticket(u32 req_id, const std::string& service_id, const std::vector<u8>& cookie);
|
||||
bool req_sign_infos(u32 req_id, std::string_view npid);
|
||||
bool req_ticket(u32 req_id, std::string_view service_id, const std::vector<u8>& cookie);
|
||||
bool send_message(const message_data& msg_data, const std::set<std::string>& npids);
|
||||
bool get_board_infos(u32 req_id, const SceNpCommunicationId& communication_id, SceNpScoreBoardId board_id);
|
||||
bool record_score(u32 req_id, const SceNpCommunicationId& communication_id, SceNpScoreBoardId board_id, SceNpScorePcId char_id, SceNpScoreValue score, const std::optional<std::string> comment, const std::optional<std::vector<u8>> score_data);
|
||||
@ -396,12 +396,12 @@ namespace rpcn
|
||||
|
||||
std::vector<u8> forge_request(rpcn::CommandType command, u64 packet_id, const std::vector<u8>& data) const;
|
||||
bool forge_send(rpcn::CommandType command, u64 packet_id, const std::vector<u8>& data);
|
||||
bool forge_request_with_com_id(const std::string& serialized_data, const SceNpCommunicationId& com_id, CommandType command, u64 packet_id);
|
||||
bool forge_request_with_data(const std::string& serialized_data, CommandType command, u64 packet_id);
|
||||
bool forge_request_with_com_id(std::string_view serialized_data, const SceNpCommunicationId& com_id, CommandType command, u64 packet_id);
|
||||
bool forge_request_with_data(std::string_view serialized_data, CommandType command, u64 packet_id);
|
||||
bool forge_send_reply(rpcn::CommandType command, u64 packet_id, const std::vector<u8>& data, std::vector<u8>& reply_data);
|
||||
|
||||
bool error_and_disconnect(const std::string& error_mgs);
|
||||
bool error_and_disconnect_notice(const std::string& error_msg);
|
||||
bool error_and_disconnect(std::string_view error_mgs);
|
||||
bool error_and_disconnect_notice(std::string_view error_msg);
|
||||
|
||||
std::string get_wolfssl_error(WOLFSSL* wssl, int error) const;
|
||||
|
||||
|
||||
@ -119,13 +119,14 @@ void upnp_handler::add_port_redir(const std::string& addr, u16 internal_port, st
|
||||
if (!m_active)
|
||||
return;
|
||||
|
||||
const std::string protocol_str(protocol);
|
||||
|
||||
std::lock_guard lock(m_mutex);
|
||||
|
||||
if (m_bindings[std::string(protocol)].contains(internal_port))
|
||||
if (m_bindings[protocol_str].contains(internal_port))
|
||||
return;
|
||||
|
||||
const std::string internal_port_str = fmt::format("%d", internal_port);
|
||||
const std::string protocol_str(protocol);
|
||||
const u32 max_port = std::min(static_cast<u32>(internal_port) + 100, 0xFFFFu);
|
||||
int res = 0;
|
||||
|
||||
|
||||
@ -1353,7 +1353,7 @@ rpcn_friends_dialog::~rpcn_friends_dialog()
|
||||
}
|
||||
}
|
||||
|
||||
bool rpcn_friends_dialog::add_friend_with_error_dialog(const std::string& friend_username)
|
||||
bool rpcn_friends_dialog::add_friend_with_error_dialog(std::string_view friend_username)
|
||||
{
|
||||
QString err_msg;
|
||||
const auto opt_error = m_rpcn->add_friend(friend_username);
|
||||
|
||||
@ -121,7 +121,7 @@ public:
|
||||
private:
|
||||
void add_update_list(QListWidget* list, const QString& name, const QIcon& icon, const QVariant& data);
|
||||
void remove_list(QListWidget* list, const QString& name);
|
||||
bool add_friend_with_error_dialog(const std::string& friend_username);
|
||||
bool add_friend_with_error_dialog(std::string_view friend_username);
|
||||
|
||||
private Q_SLOTS:
|
||||
void add_update_friend(const QString& name, bool status);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user