Files
qt-migration-legatus/qt5-before/dlbo/Lts/Common/LtsLicence/lts_licence.cpp
T
torstenandCopilot 7173785915 Qt6 Migration: Complete migration with DDS/RTI support and build validation
Major Changes:
- Merged latest Qt5 devel content from dlbo (292 files changed, 7 new dirs)
- Consolidated forward-declarations and include folders
- Removed unneeded modules per Niklas' repo check list

Build System Fixes:
- Fixed CMake VERSION_GREATER syntax in ParticipantManagement/CMakeLists.txt
- Added VLC packages (libvlc-dev, vlc-plugin-base) to docker_build.sh
- Added PostgreSQL dev packages (libpq-dev, postgresql-server-dev-all) to Dockerfile
- Fixed locale warnings (ANSI_X3.4-1968 → C.UTF-8)
- Fixed ArcGIS SDK path warnings when BUILD_ARCGIS=OFF

Code Generation Fixes:
- Fixed IDL enum collisions (PortType→CorePortType/DdsutPortType, PdmEventType)
- Fixed Grantlee template svc_translation.cpp.grantlee:
  - Changed {{ idl_enum.name }}_def:: to {{ idl_enum.name }}::
  - Fixed .underlying() calls for C++11 scoped enums (enum class)
- Removed generated files from repo (moc_*, *_dtc.h, *_ftc.h)

Validation:
- BUILD_RTI=ON: SUCCESS
- BUILD_RTI=OFF: SUCCESS
- C++17 standard maintained for RTI 7.7 compatibility
- Ubuntu 26.04 Docker environment verified

Remaining Warnings (expected):
- BgViewer, KDChart, KDReports, Poppler-Qt6 not found (optional features)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-09-15 18:20:26 +00:00

182 lines
5.7 KiB
C++

/**
* @RDE_HEADER@
* Licence Library
* $Id$
* $HeadURL$
* $Author$
* Created by hjl, SLSE, 2016-06-01
*/
#include "lts_licence.h"
#include <QDomDocument>
#include <NGLLogger/NGLLoggerBootstrap.h>
#include <QObject>
namespace LtsLicence
{
static bool extractLicence(const QDomElement &licenceElement, QVector<Licence> &licenceVec);
static NGL::INGLLogger &getLogger()
{
return NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("LtsLicence");
}
QVector<Licence> readLicences(const QByteArray &unencryptedXmlData)
{
QVector<Licence> licenceVec;
QDomDocument xmlDoc;
QString errorMsg;
int errorLine = 0;
int errorColumn = 0;
if (!xmlDoc.setContent(unencryptedXmlData, &errorMsg, &errorLine, &errorColumn))
{
ERROR_LOG(getLogger()) << "Error reading xml data, " << "error in line " << errorLine
<< ", column " << errorColumn
<< ", message: " << errorMsg;
return licenceVec;
}
INFO_LOG(getLogger()) << "Try to extract licences";
QDomElement licenceElement = xmlDoc.documentElement().firstChildElement(QLatin1String("licence"));
while (!licenceElement.isNull())
{
if (!extractLicence(licenceElement, licenceVec))
{
licenceVec.clear();
return licenceVec;
}
licenceElement = licenceElement.nextSiblingElement(QLatin1String("licence"));
}
return licenceVec;
} // end of readLicences()
//-----------------------------------------------------------------------------
QByteArray writeUnencryptedLicences(const QVector<Licence> &licences)
{
QDomDocument xmlDoc;
QDomProcessingInstruction instr = xmlDoc.createProcessingInstruction(QLatin1String("xml"),
QLatin1String("version='1.0' encoding='UTF-8' standalone='yes'"));
xmlDoc.appendChild(instr);
QDomElement root = xmlDoc.createElement(QLatin1String("licences"));
xmlDoc.appendChild(root);
for (int i = 0; i < licences.size(); ++i)
{
QDomElement lic = xmlDoc.createElement(QLatin1String("licence"));
root.appendChild(lic);
// set licencename
QDomElement element = xmlDoc.createElement(QLatin1String("name"));
QDomText text = xmlDoc.createTextNode(licences[i].name);
element.appendChild(text);
lic.appendChild(element);
// set ignoreMaxCount flag
element = xmlDoc.createElement(QLatin1String("ignoreMaxCount"));
text = xmlDoc.createTextNode(QString::number(licences[i].ignoreMaxCount));
element.appendChild(text);
lic.appendChild(element);
// set ignoreExpiration flag
element = xmlDoc.createElement(QLatin1String("ignoreExpiration"));
text = xmlDoc.createTextNode(QString::number(licences[i].ignoreExpiration));
element.appendChild(text);
lic.appendChild(element);
// set maxCount
element = xmlDoc.createElement(QLatin1String("maxCount"));
text = xmlDoc.createTextNode(QString::number(licences[i].maxCount));
element.appendChild(text);
lic.appendChild(element);
// check dateTime format
const QLatin1String format("dd.MM.yyyy hh:mm:ss");
const QString qs = licences[i].expiration.toString(format);
// set expiration
element = xmlDoc.createElement(QLatin1String("expiration"));
text = xmlDoc.createTextNode(qs);
element.appendChild(text);
lic.appendChild(element);
}
INFO_LOG(getLogger()) << "Generated XML Data...\n" << xmlDoc.toByteArray();
return xmlDoc.toByteArray();
} // end of writeUnencryptedLicences()
//-----------------------------------------------------------------------------
bool extractLicence(const QDomElement &licenceElement, QVector<Licence> &licenceVec)
{
Licence licence;
// get licencename
QDomElement tag = licenceElement.firstChildElement(QLatin1String("name"));
licence.name = tag.text();
// get ignoreMaxCount flag
tag = licenceElement.firstChildElement(QLatin1String("ignoreMaxCount"));
licence.ignoreMaxCount = tag.text().toInt();
// get ignoreExpiration flag
tag = licenceElement.firstChildElement(QLatin1String("ignoreExpiration"));
licence.ignoreExpiration = tag.text().toInt();
// get max number of licence
tag = licenceElement.firstChildElement(QLatin1String("maxCount"));
licence.maxCount = tag.text().toInt();
// get expiration date
tag = licenceElement.firstChildElement(QLatin1String("expiration"));
const QString qs(tag.text());
// check dateTime format
const QLatin1String format("dd.MM.yyyy hh:mm:ss");
const QDateTime qdt = QDateTime::fromString(qs, format);
if (!qdt.isValid())
{
ERROR_LOG(getLogger()) << "Invalid expiration format! " << qs
<< " used format: " << format
;
return false;
}
licence.expiration = qdt;
INFO_LOG(getLogger()) << "Read licence for:'" << licence.name << "'"
<< " IgnoreMaxCount: " << licence.ignoreMaxCount
<< " IgnoreExpiration: " << licence.ignoreExpiration
<< " MaxCount: " << licence.maxCount
<< " Expiration: " << licence.expiration.date().toString()
<< " " << licence.expiration.time().toString()
<< " RefCount: " << licence.licenceRefCount
;
licenceVec.append(licence);
return true;
} // end of extractLicence()
/**
* @brief Licence::toString
* @return QString
*/
QString Licence::toString() const
{
return QObject::tr("Name: %1, Count: %2, ExpireDate: %3, Expires: %4, UseMaxCount: %5")
.arg(name)
.arg(maxCount)
.arg(expiration.toString())
.arg(ignoreExpiration)
.arg(ignoreMaxCount);
}
//-----------------------------------------------------------------------------
} // namespace LtsLicenceLib