mirror of
https://github.com/RPCS3/rpcs3.git
synced 2026-02-13 11:14:50 +01:00
Improve add friend logging/dialogs
Some checks failed
Generate Translation Template / Generate Translation Template (push) Has been cancelled
Build RPCS3 / RPCS3 Linux ${{ matrix.os }} ${{ matrix.compiler }} (/rpcs3/.ci/build-linux-aarch64.sh, gcc, rpcs3/rpcs3-ci-jammy-aarch64:1.7, ubuntu-24.04-arm) (push) Has been cancelled
Build RPCS3 / RPCS3 Linux ${{ matrix.os }} ${{ matrix.compiler }} (/rpcs3/.ci/build-linux.sh, gcc, rpcs3/rpcs3-ci-jammy:1.7, ubuntu-24.04) (push) Has been cancelled
Build RPCS3 / RPCS3 Linux ${{ matrix.os }} ${{ matrix.compiler }} (a1d35836e8d45bfc6f63c26f0a3e5d46ef622fe1, rpcs3/rpcs3-binaries-linux-arm64, /rpcs3/.ci/build-linux-aarch64.sh, clang, rpcs3/rpcs3-ci-jammy-aarch64:1.7, ubuntu-24.04-arm) (push) Has been cancelled
Build RPCS3 / RPCS3 Linux ${{ matrix.os }} ${{ matrix.compiler }} (d812f1254a1157c80fd402f94446310560f54e5f, rpcs3/rpcs3-binaries-linux, /rpcs3/.ci/build-linux.sh, clang, rpcs3/rpcs3-ci-jammy:1.7, ubuntu-24.04) (push) Has been cancelled
Build RPCS3 / RPCS3 Mac ${{ matrix.name }} (0, 51ae32f468089a8169aaf1567de355ff4a3e0842, rpcs3/rpcs3-binaries-mac, Intel) (push) Has been cancelled
Build RPCS3 / RPCS3 Mac ${{ matrix.name }} (1, 8e21bdbc40711a3fccd18fbf17b742348b0f4281, rpcs3/rpcs3-binaries-mac-arm64, Apple Silicon) (push) Has been cancelled
Build RPCS3 / RPCS3 Windows (push) Has been cancelled
Build RPCS3 / RPCS3 Windows Clang ${{ matrix.arch }} (aarch64, clang, clangarm64, ARM64, windows-11-arm) (push) Has been cancelled
Build RPCS3 / RPCS3 Windows Clang ${{ matrix.arch }} (x86_64, clang, clang64, X64, windows-2025) (push) Has been cancelled
Build RPCS3 / RPCS3 FreeBSD (push) Has been cancelled
Some checks failed
Generate Translation Template / Generate Translation Template (push) Has been cancelled
Build RPCS3 / RPCS3 Linux ${{ matrix.os }} ${{ matrix.compiler }} (/rpcs3/.ci/build-linux-aarch64.sh, gcc, rpcs3/rpcs3-ci-jammy-aarch64:1.7, ubuntu-24.04-arm) (push) Has been cancelled
Build RPCS3 / RPCS3 Linux ${{ matrix.os }} ${{ matrix.compiler }} (/rpcs3/.ci/build-linux.sh, gcc, rpcs3/rpcs3-ci-jammy:1.7, ubuntu-24.04) (push) Has been cancelled
Build RPCS3 / RPCS3 Linux ${{ matrix.os }} ${{ matrix.compiler }} (a1d35836e8d45bfc6f63c26f0a3e5d46ef622fe1, rpcs3/rpcs3-binaries-linux-arm64, /rpcs3/.ci/build-linux-aarch64.sh, clang, rpcs3/rpcs3-ci-jammy-aarch64:1.7, ubuntu-24.04-arm) (push) Has been cancelled
Build RPCS3 / RPCS3 Linux ${{ matrix.os }} ${{ matrix.compiler }} (d812f1254a1157c80fd402f94446310560f54e5f, rpcs3/rpcs3-binaries-linux, /rpcs3/.ci/build-linux.sh, clang, rpcs3/rpcs3-ci-jammy:1.7, ubuntu-24.04) (push) Has been cancelled
Build RPCS3 / RPCS3 Mac ${{ matrix.name }} (0, 51ae32f468089a8169aaf1567de355ff4a3e0842, rpcs3/rpcs3-binaries-mac, Intel) (push) Has been cancelled
Build RPCS3 / RPCS3 Mac ${{ matrix.name }} (1, 8e21bdbc40711a3fccd18fbf17b742348b0f4281, rpcs3/rpcs3-binaries-mac-arm64, Apple Silicon) (push) Has been cancelled
Build RPCS3 / RPCS3 Windows (push) Has been cancelled
Build RPCS3 / RPCS3 Windows Clang ${{ matrix.arch }} (aarch64, clang, clangarm64, ARM64, windows-11-arm) (push) Has been cancelled
Build RPCS3 / RPCS3 Windows Clang ${{ matrix.arch }} (x86_64, clang, clang64, X64, windows-2025) (push) Has been cancelled
Build RPCS3 / RPCS3 FreeBSD (push) Has been cancelled
This commit is contained in:
parent
93fd33a19a
commit
93dbdead24
|
|
@ -1467,7 +1467,7 @@ namespace rpcn
|
|||
return error;
|
||||
}
|
||||
|
||||
bool rpcn_client::add_friend(const std::string& friend_username)
|
||||
std::optional<ErrorType> rpcn_client::add_friend(const std::string& friend_username)
|
||||
{
|
||||
std::vector<u8> data;
|
||||
std::copy(friend_username.begin(), friend_username.end(), std::back_inserter(data));
|
||||
|
|
@ -1478,19 +1478,18 @@ namespace rpcn
|
|||
std::vector<u8> packet_data;
|
||||
if (!forge_send_reply(CommandType::AddFriend, req_id, data, packet_data))
|
||||
{
|
||||
return false;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
vec_stream reply(packet_data);
|
||||
auto error = static_cast<ErrorType>(reply.get<u8>());
|
||||
const auto error = static_cast<ErrorType>(reply.get<u8>());
|
||||
|
||||
if (error != rpcn::ErrorType::NoError)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (error == ErrorType::NoError)
|
||||
rpcn_log.success("add_friend(\"%s\") succeeded", friend_username);
|
||||
else
|
||||
rpcn_log.error("add_friend(\"%s\") failed with error: %s", error);
|
||||
|
||||
rpcn_log.success("You have successfully added \"%s\" as a friend", friend_username);
|
||||
return true;
|
||||
return error;
|
||||
}
|
||||
|
||||
bool rpcn_client::remove_friend(const std::string& friend_username)
|
||||
|
|
|
|||
|
|
@ -293,7 +293,7 @@ namespace rpcn
|
|||
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();
|
||||
bool add_friend(const std::string& friend_username);
|
||||
std::optional<ErrorType> add_friend(const std::string& friend_username);
|
||||
bool remove_friend(const std::string& friend_username);
|
||||
|
||||
u32 get_num_friends();
|
||||
|
|
|
|||
|
|
@ -1262,13 +1262,10 @@ rpcn_friends_dialog::rpcn_friends_dialog(QWidget* parent)
|
|||
|
||||
connect(accept_request_action, &QAction::triggered, this, [this, str_sel_friend]()
|
||||
{
|
||||
if (!m_rpcn->add_friend(str_sel_friend))
|
||||
{
|
||||
QMessageBox::critical(this, tr("Error adding a friend!"), tr("An error occurred while trying to add a friend!"), QMessageBox::Ok);
|
||||
}
|
||||
else
|
||||
if (add_friend_with_error_dialog(str_sel_friend))
|
||||
{
|
||||
QMessageBox::information(this, tr("Friend added!"), tr("You've successfully added a friend!"), QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -1304,11 +1301,8 @@ rpcn_friends_dialog::rpcn_friends_dialog(QWidget* parent)
|
|||
|
||||
connect(send_friend_request_action, &QAction::triggered, this, [this, str_sel_friend]()
|
||||
{
|
||||
if (!m_rpcn->add_friend(str_sel_friend))
|
||||
{
|
||||
QMessageBox::critical(this, tr("Error sending a friend request!"), tr("An error occurred while trying to send a friend request!"), QMessageBox::Ok);
|
||||
if (!add_friend_with_error_dialog(str_sel_friend))
|
||||
return;
|
||||
}
|
||||
|
||||
QString qstr_friend = QString::fromStdString(str_sel_friend);
|
||||
add_update_list(m_lst_requests, qstr_friend, m_icon_request_sent, QVariant(false));
|
||||
|
|
@ -1341,11 +1335,7 @@ rpcn_friends_dialog::rpcn_friends_dialog(QWidget* parent)
|
|||
QMessageBox::critical(this, tr("Error validating username!"), tr("The username you entered is invalid!"), QMessageBox::Ok);
|
||||
}
|
||||
|
||||
if (!m_rpcn->add_friend(str_friend_username))
|
||||
{
|
||||
QMessageBox::critical(this, tr("Error adding friend!"), tr("An error occurred while adding a friend!"), QMessageBox::Ok);
|
||||
}
|
||||
else
|
||||
if (add_friend_with_error_dialog(str_friend_username))
|
||||
{
|
||||
add_update_list(m_lst_requests, QString::fromStdString(str_friend_username), m_icon_request_sent, QVariant(false));
|
||||
QMessageBox::information(this, tr("Friend added!"), tr("Friend was successfully added!"), QMessageBox::Ok);
|
||||
|
|
@ -1360,6 +1350,42 @@ rpcn_friends_dialog::~rpcn_friends_dialog()
|
|||
m_rpcn->remove_friend_cb(friend_callback, this);
|
||||
}
|
||||
|
||||
bool rpcn_friends_dialog::add_friend_with_error_dialog(const std::string& friend_username)
|
||||
{
|
||||
QString err_msg;
|
||||
const auto opt_error = m_rpcn->add_friend(friend_username);
|
||||
|
||||
if (opt_error.has_value())
|
||||
{
|
||||
const auto error = opt_error.value();
|
||||
|
||||
if (error != rpcn::ErrorType::NoError)
|
||||
{
|
||||
switch (error)
|
||||
{
|
||||
case rpcn::ErrorType::NotFound: err_msg = tr("The specified username does not exist."); break;
|
||||
case rpcn::ErrorType::InvalidInput: err_msg = tr("You cannot add yourself as a friend."); break;
|
||||
case rpcn::ErrorType::Blocked: err_msg = tr("You or the other user have the other blocked."); break;
|
||||
case rpcn::ErrorType::AlreadyFriend: err_msg = tr("You are already friends with this user."); break;
|
||||
case rpcn::ErrorType::DbFail: err_msg = tr("A database error occurred. Please try again later."); break;
|
||||
default: err_msg = tr("An unexpected error occurred."); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
err_msg = tr("Failed to send the friend request.");
|
||||
}
|
||||
|
||||
if (!err_msg.isEmpty())
|
||||
{
|
||||
QMessageBox::critical(this, tr("Friend Request Failed"), err_msg, QMessageBox::Ok);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool rpcn_friends_dialog::is_ok() const
|
||||
{
|
||||
return m_rpcn_ok;
|
||||
|
|
|
|||
|
|
@ -121,6 +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);
|
||||
|
||||
private Q_SLOTS:
|
||||
void add_update_friend(const QString& name, bool status);
|
||||
|
|
|
|||
Loading…
Reference in a new issue