2021-04-22 07:29:46 +00:00
|
|
|
/*
|
2024-09-17 19:00:25 +00:00
|
|
|
* Deskflow -- mouse and keyboard sharing utility
|
2024-08-07 14:05:18 +00:00
|
|
|
* Copyright (C) 2021 Symless Ltd.
|
2021-04-22 07:29:46 +00:00
|
|
|
*
|
|
|
|
|
* This package is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* found in the file LICENSE that should have accompanied this file.
|
|
|
|
|
*
|
|
|
|
|
* This package is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
2024-08-07 14:05:18 +00:00
|
|
|
|
2021-04-22 07:29:46 +00:00
|
|
|
#include "ServerMessage.h"
|
|
|
|
|
|
2024-09-17 19:00:25 +00:00
|
|
|
namespace deskflow::gui {
|
2024-08-07 14:05:18 +00:00
|
|
|
|
2024-10-17 18:04:35 +00:00
|
|
|
ServerMessage::ServerMessage(const QString &message) : m_message(message), m_clientName(parseClientName(message))
|
|
|
|
|
{
|
|
|
|
|
}
|
2021-04-22 07:29:46 +00:00
|
|
|
|
2024-10-17 18:04:35 +00:00
|
|
|
bool ServerMessage::isNewClientMessage() const
|
|
|
|
|
{
|
2024-07-02 19:07:06 +00:00
|
|
|
return m_message.contains("unrecognised client name");
|
2021-04-22 07:29:46 +00:00
|
|
|
}
|
|
|
|
|
|
2024-10-17 18:04:35 +00:00
|
|
|
bool ServerMessage::isExitMessage() const
|
|
|
|
|
{
|
2024-07-02 19:07:06 +00:00
|
|
|
return m_message.contains("process exited");
|
2021-04-22 07:29:46 +00:00
|
|
|
}
|
|
|
|
|
|
2024-10-17 18:04:35 +00:00
|
|
|
bool ServerMessage::isConnectedMessage() const
|
|
|
|
|
{
|
2024-07-02 19:07:06 +00:00
|
|
|
return m_message.contains("has connected");
|
2021-04-22 07:29:46 +00:00
|
|
|
}
|
|
|
|
|
|
2024-10-17 18:04:35 +00:00
|
|
|
bool ServerMessage::isDisconnectedMessage() const
|
|
|
|
|
{
|
2024-07-02 19:07:06 +00:00
|
|
|
return m_message.contains("has disconnected");
|
2021-04-22 07:29:46 +00:00
|
|
|
}
|
|
|
|
|
|
2024-10-17 18:04:35 +00:00
|
|
|
const QString &ServerMessage::getClientName() const
|
|
|
|
|
{
|
|
|
|
|
return m_clientName;
|
|
|
|
|
}
|
2021-04-22 07:29:46 +00:00
|
|
|
|
2024-10-17 18:04:35 +00:00
|
|
|
QString ServerMessage::parseClientName(const QString &line) const
|
|
|
|
|
{
|
2024-07-02 19:07:06 +00:00
|
|
|
QString clientName("Unknown");
|
|
|
|
|
auto nameStart = line.indexOf('"') + 1;
|
|
|
|
|
auto nameEnd = line.indexOf('"', nameStart);
|
2021-04-22 07:29:46 +00:00
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
if (nameEnd > nameStart) {
|
|
|
|
|
clientName = line.mid(nameStart, nameEnd - nameStart);
|
|
|
|
|
}
|
2021-04-22 07:29:46 +00:00
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
return clientName;
|
2021-04-22 07:29:46 +00:00
|
|
|
}
|
2024-08-07 14:05:18 +00:00
|
|
|
|
2024-09-17 19:00:25 +00:00
|
|
|
} // namespace deskflow::gui
|