From ae2cb3ebd3357c0146b0a3e0e6f1b0539dd83763 Mon Sep 17 00:00:00 2001 From: Markus Mittendrein Date: Thu, 29 Dec 2016 16:51:55 +0100 Subject: Add management scripting support Management Clients with a name starting with ! dont get any buffer replay or normal log output and dont create buffer holes anymore --- src/ClientInfo.hpp | 1 + src/crsm.cpp | 27 ++++++++++++++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/ClientInfo.hpp b/src/ClientInfo.hpp index d176965..57d2587 100644 --- a/src/ClientInfo.hpp +++ b/src/ClientInfo.hpp @@ -15,6 +15,7 @@ public: QTcpSocket* socket = 0; QString name = ""; + bool noLogging = false; }; class ClientInfo diff --git a/src/crsm.cpp b/src/crsm.cpp index 06ec498..e65aeb2 100644 --- a/src/crsm.cpp +++ b/src/crsm.cpp @@ -570,9 +570,18 @@ void CRSM::newManagementData() ManagementConnection conn; conn.socket = sock; conn.name = data; + + if(conn.name.length() > 1 && conn.name.at(0) == '!') + { + conn.noLogging = true; + } + out(conn.name + " logged in on Management-Interface.\n"); managementConnections.insert(sock, conn); - replayOutputBuffer(sock); + if(!conn.noLogging) + { + replayOutputBuffer(sock); + } } } else @@ -1673,17 +1682,21 @@ void CRSM::out(const QString &text) return; } Log.log(text); - if(managementConnections.size() == 0) - { - outputBuffer.write(text.toUtf8()); - } - else + bool buffer = true; + + foreach(const ManagementConnection& conn, managementConnections) { - foreach(const ManagementConnection& conn, managementConnections) + if(!conn.noLogging) { conn.socket->write(text.toUtf8()); + buffer = false; } } + + if(buffer) + { + outputBuffer.write(text.toUtf8()); + } } void CRSM::replayOutputBuffer(QTcpSocket *socket, bool clear) -- cgit v1.2.3-54-g00ecf