71 lines
2.0 KiB
C++
Executable File
71 lines
2.0 KiB
C++
Executable File
#pragma once
|
|
|
|
#include <QProcess>
|
|
#include <QJsonDocument>
|
|
#include <QJsonObject>
|
|
#include <ParticipantManagement/ppm_enums.hpp>
|
|
|
|
namespace SAAUtils
|
|
{
|
|
|
|
struct PingItem
|
|
{
|
|
int assetId = -1;
|
|
QString host;
|
|
int port;
|
|
QProcess *process = nullptr;
|
|
bool reachable = false;
|
|
bool connected = false;
|
|
};
|
|
|
|
struct AsmAssetProps
|
|
{
|
|
AsmAssetProps(const QString &properties)
|
|
{
|
|
if (properties.isEmpty())
|
|
return;
|
|
const QJsonObject propObj = QJsonDocument::fromJson(properties.toUtf8()).object();
|
|
if (propObj.contains(QStringLiteral("credentials")) )
|
|
{
|
|
const QJsonObject adlerObj = propObj[QStringLiteral("credentials")].toObject();
|
|
exId = propObj.value(QStringLiteral("exerciseId")).toInt(-1);
|
|
userName = adlerObj.value(QStringLiteral("username")).toString();
|
|
password = adlerObj.value(QStringLiteral("password")).toString();
|
|
host = adlerObj.value(QStringLiteral("host")).toString();
|
|
port = adlerObj.value(QStringLiteral("port")).toInt(-1);
|
|
}
|
|
|
|
}
|
|
bool hasCredential() const { return (!userName.isEmpty() && !password.isEmpty()); }
|
|
bool hasExerciseId() const { return exId > 0;}
|
|
QString userName;
|
|
QString password;
|
|
QString host;
|
|
int port=-1;
|
|
int exId = -1;
|
|
};
|
|
|
|
struct SaaProps
|
|
{
|
|
SaaProps(const QString &properties)
|
|
{
|
|
if ( properties.isEmpty())
|
|
return;
|
|
const QJsonObject propertiesObj = QJsonDocument::fromJson(properties.toUtf8()).object();
|
|
if (!propertiesObj.contains(QStringLiteral("Adler")) )
|
|
return;
|
|
const QJsonObject adlerObj = propertiesObj[QStringLiteral("Adler")].toObject();
|
|
isConnected = (adlerObj.value(QStringLiteral("saaConnectedState")).toInt() == ParticipantManagement::ConnectState::Connected);
|
|
name = adlerObj.value(QStringLiteral("SaaName")).toString(QStringLiteral(""));
|
|
assetId = adlerObj.value(QStringLiteral("assetId")).toInt(-1);
|
|
}
|
|
bool hasAsset() const { return assetId > 0; }
|
|
QString name;
|
|
QString ipAdress;
|
|
int assetId = -1;
|
|
bool isConnected = false;
|
|
};
|
|
|
|
|
|
} // namespace SAAUtils
|