new_docker_build.sh gains Group 12 (212 GUI/Data plugins); fixes LtsUtilsGuiDds visibility (LTO-stripped exports), LtsProjectionWorkstation unity name shadow, 6 unity-off dirs (dup file-scope statics, ddsftc INTERFACE sources) and reconfigures BUILD_FILTERMANAGEMENT/BUILD_PLUGINS_SERVICEMONITOR=ON
212 lines
6.8 KiB
C++
212 lines
6.8 KiB
C++
|
|
|
|
#include "messages.h"
|
|
|
|
#include <QtCore/QDebug>
|
|
#include <QtCore/QJsonArray>
|
|
|
|
namespace LtsProjectionWorkstation
|
|
{
|
|
|
|
STC::LoginRequestReply::LoginRequestReply(const QString& uuid, Reason reason, int reasonUserId,
|
|
const QVector<VncScreen>& screens)
|
|
: Message(nullptr, nullptr, JsonKeys::LOGIN_REPLY(), uuid, QJsonValue()), m_screens(screens),
|
|
m_reasonUserId(reasonUserId), m_reason(reason)
|
|
{
|
|
QJsonObject result;
|
|
QJsonArray arr;
|
|
for (const VncScreen& vncScreen : screens)
|
|
{
|
|
QJsonObject screen;
|
|
screen.insert(JsonKeys::NAME(), vncScreen.name);
|
|
screen.insert(JsonKeys::PORT(), vncScreen.port);
|
|
screen.insert(JsonKeys::WIDTH(), vncScreen.geometry.width());
|
|
screen.insert(JsonKeys::HEIGHT(), vncScreen.geometry.height());
|
|
arr.append(screen);
|
|
}
|
|
result.insert(JsonKeys::REASON(), reason);
|
|
result.insert(JsonKeys::USER_ID(), reasonUserId);
|
|
result.insert(JsonKeys::SCREENS(), arr);
|
|
m_replyData = QJsonValue(result);
|
|
}
|
|
|
|
void STC::LoginRequestReply::process()
|
|
{
|
|
if (!m_handler || !m_client)
|
|
return;
|
|
QJsonObject dataObj = m_data.toObject();
|
|
m_reason = Reason(dataObj.value(JsonKeys::REASON()).toInt());
|
|
m_reasonUserId = dataObj.value(JsonKeys::USER_ID()).toInt();
|
|
const auto arr = dataObj.value(JsonKeys::SCREENS()).toArray();
|
|
for (const QJsonValue& val : arr)
|
|
{
|
|
const QJsonObject obj(val.toObject());
|
|
VncScreen screen;
|
|
screen.name = obj.value(JsonKeys::NAME()).toString(QStringLiteral("err"));
|
|
screen.port = obj.value(JsonKeys::PORT()).toInt(-1);
|
|
screen.geometry = QRect(0, 0, obj.value(JsonKeys::WIDTH()).toInt(-1), obj.value(JsonKeys::HEIGHT()).toInt(-1));
|
|
m_screens.append(std::move(screen));
|
|
}
|
|
m_handler->handleMessage(this);
|
|
}
|
|
|
|
bool STC::LoginRequestReply::hasValidData() const
|
|
{
|
|
if (!m_handler || !m_client)
|
|
return false;
|
|
QJsonObject obj = m_data.toObject();
|
|
if (obj.value(JsonKeys::REASON()).isUndefined())
|
|
return false;
|
|
if (obj.value(JsonKeys::USER_ID()).isUndefined())
|
|
return false;
|
|
if (obj.value(JsonKeys::SCREENS()).isUndefined())
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
STC::DedicatedDisconnect::DedicatedDisconnect(const QString& uuid, int userId)
|
|
: Message(nullptr, nullptr, JsonKeys::DEDICAED_DISCONNECT(), uuid, QJsonValue()), m_userId(userId)
|
|
{
|
|
QJsonObject result;
|
|
result.insert(JsonKeys::USER_ID(), m_userId);
|
|
m_replyData = result;
|
|
}
|
|
|
|
void STC::DedicatedDisconnect::process()
|
|
{
|
|
if (!m_handler || !m_client)
|
|
return;
|
|
QJsonObject obj = m_data.toObject();
|
|
m_userId = obj.value(JsonKeys::USER_ID()).toInt(-1);
|
|
m_handler->handleMessage(this);
|
|
}
|
|
|
|
bool STC::DedicatedDisconnect::hasValidData() const
|
|
{
|
|
if (!m_handler || !m_client)
|
|
return false;
|
|
QJsonObject obj = m_data.toObject();
|
|
if (obj.value(JsonKeys::USER_ID()).isUndefined())
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
CTS::LoginRequest::LoginRequest(const QString& uuid, int userId, int priority, int exerciseId,
|
|
const QByteArray& settingsData)
|
|
: Message(nullptr, nullptr, JsonKeys::LOGIN_REQUEST(), uuid, QJsonValue()), m_settingsData(settingsData),
|
|
m_userId(userId), m_priority(priority), m_exerciseId(exerciseId)
|
|
{
|
|
QJsonObject result;
|
|
result.insert(JsonKeys::USER_ID(), m_userId);
|
|
result.insert(JsonKeys::USER_PRIORITY(), m_priority);
|
|
result.insert(JsonKeys::EXERCISE_ID(), m_exerciseId);
|
|
result.insert(JsonKeys::SETTINGS_DATA(), QString::fromLatin1(m_settingsData.toBase64()));
|
|
m_replyData = result;
|
|
}
|
|
|
|
void CTS::LoginRequest::process()
|
|
{
|
|
if (!m_handler || !m_client)
|
|
return;
|
|
QJsonObject obj = m_data.toObject();
|
|
m_userId = obj.value(JsonKeys::USER_ID()).toInt(-1);
|
|
m_priority = obj.value(JsonKeys::USER_PRIORITY()).toInt(-1);
|
|
m_exerciseId = obj.value(JsonKeys::EXERCISE_ID()).toInt(-1);
|
|
m_settingsData = QByteArray::fromBase64(obj.value(JsonKeys::SETTINGS_DATA()).toString().toLatin1());
|
|
m_handler->handleMessage(this);
|
|
}
|
|
|
|
bool CTS::LoginRequest::hasValidData() const
|
|
{
|
|
if (!m_handler || !m_client)
|
|
return false;
|
|
QJsonObject obj = m_data.toObject();
|
|
if (obj.value(JsonKeys::USER_ID()).isUndefined())
|
|
return false;
|
|
if (obj.value(JsonKeys::EXERCISE_ID()).isUndefined())
|
|
return false;
|
|
if (obj.value(JsonKeys::USER_PRIORITY()).isUndefined())
|
|
return false;
|
|
if (obj.value(JsonKeys::SETTINGS_DATA()).isUndefined())
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
void CTS::LogoutRequest::process()
|
|
{
|
|
if (!m_handler || !m_client)
|
|
return;
|
|
m_handler->handleMessage(this);
|
|
}
|
|
|
|
bool CTS::LogoutRequest::hasValidData() const
|
|
{
|
|
if (!m_handler || !m_client)
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
CTS::DisconnectRequest::DisconnectRequest(const QString& uuid, int userId)
|
|
: Message(nullptr, nullptr, JsonKeys::DISCONNECT_REQUEST(), uuid, QJsonValue()), m_userId(userId)
|
|
{
|
|
qDebug() << " 1 m_userId = " << m_userId;
|
|
QJsonObject result;
|
|
result.insert(JsonKeys::USER_ID(), m_userId);
|
|
m_replyData = result;
|
|
}
|
|
|
|
void CTS::DisconnectRequest::process()
|
|
{
|
|
if (!m_handler || !m_client)
|
|
return;
|
|
QJsonObject obj = m_data.toObject();
|
|
m_userId = obj.value(JsonKeys::USER_ID()).toInt(-1);
|
|
qDebug() << " 2 m_userId = " << m_userId;
|
|
m_handler->handleMessage(this);
|
|
}
|
|
|
|
bool CTS::DisconnectRequest::hasValidData() const
|
|
{
|
|
if (!m_handler || !m_client)
|
|
return false;
|
|
QJsonObject obj = m_data.toObject();
|
|
if (obj.value(JsonKeys::USER_ID()).isUndefined())
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
// Unqualified: we are already inside namespace LtsProjectionWorkstation, and the unity
|
|
// build concatenates lts_projection_workstation.cpp (which declares
|
|
// class LtsProjectionWorkstation in this same namespace) into this TU, so
|
|
// "LtsProjectionWorkstation::ErrorMessage" would resolve to the class (which has no
|
|
// such member) instead of the namespace. In a separate TU (legacy structure) the
|
|
// class is not visible here and the qualified name resolved to the namespace.
|
|
ErrorMessage::ErrorMessage(const QString& uuid, const QString& reason)
|
|
: Message(nullptr, nullptr, JsonKeys::ERROR_MESSAGE(), uuid, QJsonValue()), m_reason(reason)
|
|
{
|
|
QJsonObject result;
|
|
result.insert(JsonKeys::REASON(), m_reason);
|
|
m_replyData = result;
|
|
}
|
|
|
|
void ErrorMessage::process()
|
|
{
|
|
if (!m_handler || !m_client)
|
|
return;
|
|
QJsonObject obj = m_data.toObject();
|
|
m_reason = obj.value(JsonKeys::REASON()).toString(QStringLiteral("err"));
|
|
m_handler->handleMessage(this);
|
|
}
|
|
|
|
bool ErrorMessage::hasValidData() const
|
|
{
|
|
if (!m_handler || !m_client)
|
|
return false;
|
|
QJsonObject obj = m_data.toObject();
|
|
if (obj.value(JsonKeys::REASON()).isUndefined())
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
} // namespace LtsProjectionWorkstation
|