From 4bf7c3e051034b5524d4ab23d05212216b853c3c Mon Sep 17 00:00:00 2001 From: Sepalani Date: Sun, 10 May 2020 23:27:21 +0400 Subject: [PATCH] NetworkWidget: Add Blocking column --- Source/Core/Core/IOS/Network/Socket.cpp | 6 ++++++ Source/Core/Core/IOS/Network/Socket.h | 1 + Source/Core/DolphinQt/Debugger/NetworkWidget.cpp | 14 ++++++++++++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core/IOS/Network/Socket.cpp b/Source/Core/Core/IOS/Network/Socket.cpp index fa39308514..915189dff2 100644 --- a/Source/Core/Core/IOS/Network/Socket.cpp +++ b/Source/Core/Core/IOS/Network/Socket.cpp @@ -652,6 +652,12 @@ s32 WiiSockMan::AddSocket(s32 fd, bool is_rw) return wii_fd; } +bool WiiSockMan::IsSocketBlocking(s32 wii_fd) const +{ + const auto it = WiiSockets.find(wii_fd); + return it != WiiSockets.end() && !it->second.nonBlock; +} + s32 WiiSockMan::NewSocket(s32 af, s32 type, s32 protocol) { if (af != 2 && af != 23) // AF_INET && AF_INET6 diff --git a/Source/Core/Core/IOS/Network/Socket.h b/Source/Core/Core/IOS/Network/Socket.h index 615560f305..79e63d11dd 100644 --- a/Source/Core/Core/IOS/Network/Socket.h +++ b/Source/Core/Core/IOS/Network/Socket.h @@ -226,6 +226,7 @@ public: // NON-BLOCKING FUNCTIONS s32 NewSocket(s32 af, s32 type, s32 protocol); s32 AddSocket(s32 fd, bool is_rw); + bool IsSocketBlocking(s32 wii_fd) const; s32 GetHostSocket(s32 wii_fd) const; s32 DeleteSocket(s32 s); s32 GetLastNetError() const { return errno_last; } diff --git a/Source/Core/DolphinQt/Debugger/NetworkWidget.cpp b/Source/Core/DolphinQt/Debugger/NetworkWidget.cpp index 537bf4be65..0b0af84f96 100644 --- a/Source/Core/DolphinQt/Debugger/NetworkWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/NetworkWidget.cpp @@ -90,6 +90,15 @@ QTableWidgetItem* GetSocketState(s32 host_fd) return new QTableWidgetItem(QTableWidget::tr("Unbound")); } +QTableWidgetItem* GetSocketBlocking(s32 wii_fd) +{ + const auto& socket_manager = IOS::HLE::WiiSockMan::GetInstance(); + if (socket_manager.GetHostSocket(wii_fd) < 0) + return new QTableWidgetItem(); + const bool is_blocking = socket_manager.IsSocketBlocking(wii_fd); + return new QTableWidgetItem(is_blocking ? QTableWidget::tr("Yes") : QTableWidget::tr("No")); +} + static QString GetAddressAndPort(const sockaddr_in& addr) { char buffer[16]; @@ -214,7 +223,8 @@ void NetworkWidget::Update() m_socket_table->setItem(wii_fd, 1, GetSocketDomain(host_fd)); m_socket_table->setItem(wii_fd, 2, GetSocketType(host_fd)); m_socket_table->setItem(wii_fd, 3, GetSocketState(host_fd)); - m_socket_table->setItem(wii_fd, 4, GetSocketName(host_fd)); + m_socket_table->setItem(wii_fd, 4, GetSocketBlocking(wii_fd)); + m_socket_table->setItem(wii_fd, 5, GetSocketName(host_fd)); } m_socket_table->resizeColumnsToContents(); @@ -253,7 +263,7 @@ QGroupBox* NetworkWidget::CreateSocketTableGroup() m_socket_table = new QTableWidget(); // i18n: FD stands for file descriptor (and in this case refers to sockets, not regular files) - QStringList header{tr("FD"), tr("Domain"), tr("Type"), tr("State"), tr("Name")}; + QStringList header{tr("FD"), tr("Domain"), tr("Type"), tr("State"), tr("Blocking"), tr("Name")}; m_socket_table->setColumnCount(header.size()); m_socket_table->setHorizontalHeaderLabels(header);