diff --git a/data/locale/en-US.ini b/data/locale/en-US.ini index db31d1b4..817d434b 100644 --- a/data/locale/en-US.ini +++ b/data/locale/en-US.ini @@ -12,6 +12,7 @@ OBSWebSocket.Settings.DebugEnableHoverText="Changing this requires the WebSocket OBSWebSocket.SessionTable.RemoteAddressColumnTitle="Remote Address" OBSWebSocket.SessionTable.SessionDurationColumnTitle="Session Duration" OBSWebSocket.SessionTable.MessagesInOutColumnTitle="Messages In/Out" +OBSWebSocket.SessionTable.IdentifiedTitle="Identified" OBSWebSocket.SessionTable.KickButtonColumnTitle="Kick?" OBSWebSocket.SessionTable.KickButtonText="Kick" diff --git a/src/WebSocketServer.cpp b/src/WebSocketServer.cpp index a8a57acb..4b21eaf6 100644 --- a/src/WebSocketServer.cpp +++ b/src/WebSocketServer.cpp @@ -180,8 +180,9 @@ std::vector WebSocketServer::GetWebSocke uint64_t incomingMessages = session->IncomingMessages(); uint64_t outgoingMessages = session->OutgoingMessages(); std::string remoteAddress = session->RemoteAddress(); + bool isIdentified = session->IsIdentified(); - webSocketSessions.emplace_back(WebSocketSessionState{hdl, remoteAddress, connectedAt, incomingMessages, outgoingMessages}); + webSocketSessions.emplace_back(WebSocketSessionState{hdl, remoteAddress, connectedAt, incomingMessages, outgoingMessages, isIdentified}); } lock.unlock(); @@ -276,8 +277,8 @@ void WebSocketServer::onOpen(websocketpp::connection_hdl hdl) helloMessage["messageType"] = "Hello"; helloMessage["obsWebSocketVersion"] = OBS_WEBSOCKET_VERSION; helloMessage["rpcVersion"] = OBS_WEBSOCKET_RPC_VERSION; - helloMessage["availableRequests"] = WebSocketProtocol::GetRequestList(); - helloMessage["availableEvents"] = WebSocketProtocol::GetEventList(); + //helloMessage["availableRequests"] = WebSocketProtocol::GetRequestList(); + //helloMessage["availableEvents"] = WebSocketProtocol::GetEventList(); if (AuthenticationRequired) { std::string sessionChallenge = Utils::Crypto::GenerateSalt(); session->SetChallenge(sessionChallenge); @@ -323,6 +324,7 @@ void WebSocketServer::onClose(websocketpp::connection_hdl hdl) state.connectedAt = connectedAt; state.incomingMessages = incomingMessages; state.outgoingMessages = outgoingMessages; + state.isIdentified = isIdentified; // Emit signals emit ClientDisconnected(state, conn->get_local_close_code()); diff --git a/src/WebSocketServer.h b/src/WebSocketServer.h index be52c0f3..ebdb16bf 100644 --- a/src/WebSocketServer.h +++ b/src/WebSocketServer.h @@ -58,6 +58,7 @@ class WebSocketServer : QObject uint64_t connectedAt; uint64_t incomingMessages; uint64_t outgoingMessages; + bool isIdentified; }; WebSocketServer(); diff --git a/src/forms/SettingsDialog.cpp b/src/forms/SettingsDialog.cpp index 7e60be34..fa1c72c6 100644 --- a/src/forms/SettingsDialog.cpp +++ b/src/forms/SettingsDialog.cpp @@ -4,6 +4,8 @@ #include #include #include +#include +#include #include "SettingsDialog.h" #include "../obs-websocket.h" @@ -18,7 +20,8 @@ SettingsDialog::SettingsDialog(QWidget* parent) : sessionTableTimer(new QTimer) { ui->setupUi(this); - ui->websocketSessionTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed); + ui->websocketSessionTable->horizontalHeader()->resizeSection(3, 100); + ui->websocketSessionTable->horizontalHeader()->resizeSection(4, 100); connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &SettingsDialog::FormAccepted); @@ -91,9 +94,16 @@ void SettingsDialog::FillSessionTable() auto webSocketSessions = webSocketServer->GetWebSocketSessions(); size_t rowCount = webSocketSessions.size(); + // Manually setting the pixmap size *might* break with highdpi. Not sure though + QIcon checkIcon = style()->standardIcon(QStyle::SP_DialogOkButton); + QPixmap checkIconPixmap = checkIcon.pixmap(QSize(25, 25)); + QIcon crossIcon = style()->standardIcon(QStyle::SP_DialogCancelButton); + QPixmap crossIconPixmap = crossIcon.pixmap(QSize(25, 25)); + obs_frontend_push_ui_translation(obs_module_get_string); QString kickButtonText = QObject::tr("OBSWebSocket.SessionTable.KickButtonText"); obs_frontend_pop_ui_translation(); + ui->websocketSessionTable->setRowCount(rowCount); size_t i = 0; for (auto session : webSocketSessions) { @@ -107,6 +117,15 @@ void SettingsDialog::FillSessionTable() QTableWidgetItem *statsItem = new QTableWidgetItem(QString("%1/%2").arg(session.incomingMessages).arg(session.outgoingMessages)); ui->websocketSessionTable->setItem(i, 2, statsItem); + QLabel *identifiedLabel = new QLabel(); + identifiedLabel->setAlignment(Qt::AlignCenter); + if (session.isIdentified) { + identifiedLabel->setPixmap(checkIconPixmap); + } else { + identifiedLabel->setPixmap(crossIconPixmap); + } + ui->websocketSessionTable->setCellWidget(i, 3, identifiedLabel); + QPushButton *invalidateButton = new QPushButton(kickButtonText, this); QWidget *invalidateButtonWidget = new QWidget(); QHBoxLayout *invalidateButtonLayout = new QHBoxLayout(invalidateButtonWidget); @@ -114,7 +133,7 @@ void SettingsDialog::FillSessionTable() invalidateButtonLayout->setAlignment(Qt::AlignCenter); invalidateButtonLayout->setContentsMargins(0, 0, 0, 0); invalidateButtonWidget->setLayout(invalidateButtonLayout); - ui->websocketSessionTable->setCellWidget(i, 3, invalidateButtonWidget); + ui->websocketSessionTable->setCellWidget(i, 4, invalidateButtonWidget); connect(invalidateButton, &QPushButton::clicked, [=]() { webSocketServer->InvalidateSession(session.hdl); }); diff --git a/src/forms/SettingsDialog.ui b/src/forms/SettingsDialog.ui index 99568c7d..ba271c49 100644 --- a/src/forms/SettingsDialog.ui +++ b/src/forms/SettingsDialog.ui @@ -6,19 +6,19 @@ 0 0 - 600 + 675 437 - 600 - 437 + 675 + 0 - 600 + 675 16777215 @@ -156,7 +156,7 @@ false - 135 + 100 135 @@ -182,6 +182,11 @@ OBSWebSocket.SessionTable.MessagesInOutColumnTitle + + + OBSWebSocket.SessionTable.IdentifiedTitle + + OBSWebSocket.SessionTable.KickButtonColumnTitle