Continue the Qt5->Qt6 migration so the LTS Projects (Group 10) and LTS
Application (Group 11) compile, link, and ctest runs.
Qt5->Qt6 API migration (resolves removed/deprecated Qt6 APIs) across Lts
Tools and Apps, e.g. QAction->QActionGroup, QAbstractSocket::errorOccurred,
Qt::SkipEmptyParts, QRandomGenerator, QInputDevice::DeviceType,
QRegularExpression, QLatin1Literal->QStringLiteral, and the SampleModel
m_description->description rename.
CMake build fixes:
- CMakeLists.txt: add Lts/Common to CMAKE_AUTOMOC_INCLUDE_DIRECTORIES so moc
resolves Q_INTERFACES(ProjectPlugin::Plugin) for the migrated Projects.
- cmake/NGLMacros.cmake: NGL_COMPILE_RESOURCES - replace return() (which aborts
the calling CMakeLists.txt) with an if/else/endif.
- OpApp/THP: guard the ArcGISQt5Hack link with $<IF:$<TARGET_EXISTS:...>> (the
target is absent when the SituationMap viewer is stubbed); matches
CentralEffectSimulation.
- LtsSession: prefer the in-tree svcCoreClient target over a FIND_LIBRARY in
/usr/local/lib.
- CnrProxyTester/DotMatrixDisplay: set AUTOUIC_SEARCH_PATHS for the ui/ subdir.
- TopicDiscover: link NGLLogger.
Export-header visibility stubs (expand the empty *_EXPORT macro to
__attribute__((visibility("default"))); the build sets -fvisibility=hidden and
these stubs shadow the CMake-generated header):
- include/LtsProjectionWorkstation/ltsprojectionworkstation_export.h (fixes
undefined reference to LtsProjectionWorkstation::getInstance /
setProjectionOperatorPreset)
- include/LtsSession/ltssession_export.h, include/LtsUtilsGuiDds/ltsutilsguidds_export.h (same pattern)
New plugin modules (copied from legacy) so LtsAppDescriptorChecker finds the
gui:3 IIDs referenced by the Projects' apps.json:
- TakeHomePackageManager/OldTHP gui:3:tpm.man, gui:3:tpm.usb
- PresentationManagement/.../ScriptEditor gui:3:pre.script.edit
- Timeline/Gui/EventTimelineClassic gui:3:tln.view
new_docker_build.sh: correct group targets to the actual CMake target names,
guard LtsReportDisplay on BUILD_CODIFICATION, and skip modules unavailable in
the prebuilt image (AsmWorkstationCertifier/botan2, TrajectoryWidget,
VideoImport, thp_viewer/VLC).
283 lines
8.7 KiB
C++
283 lines
8.7 KiB
C++
|
|
|
|
#include "lts_login.h"
|
|
|
|
#include "logout_info_dialog.h"
|
|
|
|
#include <LtsAppDescriptor/lts_app_descriptor.h>
|
|
#include <LtsPluginManager/lts_plugin_manager.h>
|
|
#include <LtsSession/lts_session.h>
|
|
#include <LtsSession/lts_session_data.h>
|
|
#include <LtsSession/lts_session_manager.h>
|
|
#include <LtsUtils/LtsUtilsCore/dds_vector.h>
|
|
#include <LtsUtilsSettings/settings.h>
|
|
#include <LtsWidgets/lts_wait_dialog.h>
|
|
#include <QtCore/QCoreApplication>
|
|
#include <QtCore/QDebug>
|
|
#include <QtCore/QDir>
|
|
#include <QtWidgets/QMessageBox>
|
|
#include <QtCore/QProcess>
|
|
|
|
namespace LtsLogin
|
|
{
|
|
const int logoutShutdownTimeout = 2 * 60;
|
|
|
|
LtsLogin::LtsLogin()
|
|
: m_loginApp(nullptr), m_shutdownAction(AssetManagement::ShutdownAction::NoAction), m_isInLogoutDialog(false)
|
|
{
|
|
}
|
|
|
|
LtsLogin::~LtsLogin()
|
|
{
|
|
delete m_loginApp;
|
|
m_loginApp = nullptr;
|
|
}
|
|
|
|
void LtsLogin::login()
|
|
{
|
|
LtsAppDescriptor::PluginInfo opmDataPlugin;
|
|
opmDataPlugin.iid = QStringLiteral("opm");
|
|
opmDataPlugin.type = LtsAppDescriptor::PluginInfo::PluginType::DATA;
|
|
|
|
LtsAppDescriptor::PluginInfo pdmDataPlugin;
|
|
pdmDataPlugin.iid = QStringLiteral("pdm");
|
|
pdmDataPlugin.type = LtsAppDescriptor::PluginInfo::PluginType::DATA;
|
|
|
|
LtsAppDescriptor::PluginInfo asmDataPlugin;
|
|
asmDataPlugin.iid = QStringLiteral("asm");
|
|
asmDataPlugin.type = LtsAppDescriptor::PluginInfo::PluginType::DATA;
|
|
|
|
LtsAppDescriptor::PluginInfo srmDataPlugin;
|
|
srmDataPlugin.iid = QStringLiteral("srm");
|
|
srmDataPlugin.type = LtsAppDescriptor::PluginInfo::PluginType::DATA;
|
|
|
|
LtsAppDescriptor::PluginInfo guiPlugin;
|
|
guiPlugin.iid = m_loginPluginIid;
|
|
guiPlugin.type = LtsAppDescriptor::PluginInfo::PluginType::GUI;
|
|
guiPlugin.flags |= LtsAppDescriptor::PluginInfo::Flag::PAYLOAD;
|
|
|
|
QVector<LtsAppDescriptor::PluginInfo> plugins;
|
|
plugins.append(opmDataPlugin);
|
|
plugins.append(pdmDataPlugin);
|
|
plugins.append(asmDataPlugin);
|
|
plugins.append(srmDataPlugin);
|
|
plugins.append(guiPlugin);
|
|
|
|
LtsAppDescriptor::AppDescription app;
|
|
app.active = true;
|
|
app.appName = QStringLiteral("Login");
|
|
app.pluginInfos = plugins;
|
|
|
|
LtsSession::DdsConnectionParams connParams;
|
|
connParams.domainId = LtsSessionData::LtsSessionData::getInstance()->getDomainIdPreset();
|
|
connParams.tcpConnectionUrl = LtsSessionData::LtsSessionData::getInstance()->getTcpConnectionUrl();
|
|
connParams.partitionType = IDL::PartitionType::Global;
|
|
connParams.partitionId = 0;
|
|
|
|
m_loginApp = new LtsPluginManager::LtsPluginManager();
|
|
bool result = m_loginApp->startApp(app, true, connParams);
|
|
if (!result)
|
|
{
|
|
qWarning() << "no login plugin - probably an offline project";
|
|
emit signalLoginDone();
|
|
return;
|
|
}
|
|
|
|
connect(m_loginApp, &LtsPluginManager::LtsPluginManager::signalInitializationFinished, this, [this]() {
|
|
disconnect(m_loginApp, &LtsPluginManager::LtsPluginManager::signalInitializationFinished, this, nullptr);
|
|
|
|
LtsSession::LtsSession* session = getAdminSession();
|
|
|
|
if (!session)
|
|
{
|
|
qCritical() << "I cannot find the Admin Session :( - abort!";
|
|
QMessageBox::critical(nullptr, tr("Error loading login app"), tr("Could not load login app - abort."));
|
|
abort();
|
|
}
|
|
|
|
if (session->isInitializationDone())
|
|
QMetaObject::invokeMethod(this, &LtsLogin::slotLoginDone);
|
|
else
|
|
connect(session, &LtsSession::LtsSession::signalDoneInitializingSession, this, &LtsLogin::slotLoginDone,
|
|
Qt::UniqueConnection);
|
|
});
|
|
}
|
|
|
|
void LtsLogin::slotLoginDone()
|
|
{
|
|
LtsSession::LtsSession* session = getAdminSession();
|
|
|
|
if (session != nullptr)
|
|
{
|
|
disconnect(session, &LtsSession::LtsSession::signalDoneInitializingSession, this, &LtsLogin::slotLoginDone);
|
|
|
|
if (session->getDtc<AssetManagement::DataInterface>(m_asmDtc))
|
|
{
|
|
m_asmDtc->enableWorkstationLogout();
|
|
connect(m_asmDtc.get(), &AssetManagement::Interface::Dtc::workstationLogoutChanged, this,
|
|
&LtsLogin::slotLogoutShutdown);
|
|
}
|
|
else
|
|
qWarning() << "LtsLogin: no asm dtc, no remote logout/shutdown!";
|
|
}
|
|
else
|
|
{
|
|
qCritical() << "LtsLogin: no admin session for login!!";
|
|
QMessageBox::critical(nullptr, tr("Login error"), tr("Could not finalize login - abort."));
|
|
abort();
|
|
}
|
|
|
|
emit signalLoginDone();
|
|
}
|
|
|
|
void LtsLogin::showLogoutInformationDialog(AssetManagement::ShutdownAction action)
|
|
{
|
|
LogoutInformationDialog* lid = new LogoutInformationDialog(logoutShutdownTimeout, action, nullptr);
|
|
connect(lid, &LogoutInformationDialog::accepted, this, [this, action]() {
|
|
m_shutdownAction = action;
|
|
m_isInLogoutDialog = false;
|
|
emit signalLogout();
|
|
});
|
|
|
|
connect(lid, &LogoutInformationDialog::rejected, this, [this]() { m_isInLogoutDialog = false; });
|
|
|
|
lid->show();
|
|
}
|
|
|
|
void LtsLogin::slotLogoutShutdown(const AssetManagement::WorkstationLogout& data, DataModification modType)
|
|
{
|
|
if (m_isInLogoutDialog)
|
|
return;
|
|
|
|
if (m_asmDtc == nullptr || modType != DataModification::eAdded)
|
|
return;
|
|
|
|
if (!m_asmDtc->isAssetEnabled())
|
|
m_asmDtc->enableAsset();
|
|
for (int id : data.ids)
|
|
{
|
|
if (QString::fromStdString(m_asmDtc->asset(id).name)
|
|
.compare(LtsSession::LtsSession::workstationName(), Qt::CaseInsensitive) == 0)
|
|
{
|
|
m_isInLogoutDialog = true;
|
|
showLogoutInformationDialog(data.shutdownAction);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
LtsSession::LtsSession* LtsLogin::getAdminSession()
|
|
{
|
|
return m_loginApp->m_sessionManager->getSession(IDL::PartitionType::Global, 0);
|
|
}
|
|
|
|
void LtsLogin::logoff()
|
|
{
|
|
if (m_loginApp == nullptr)
|
|
{
|
|
qCritical() << "LtsLogin::logoff: missing login app!";
|
|
return;
|
|
}
|
|
|
|
LtsSession::LtsSession* datSession = getAdminSession();
|
|
|
|
if (!datSession)
|
|
{
|
|
qCritical() << "LtsLogin::logoff: no admin session for logout!";
|
|
abort();
|
|
}
|
|
|
|
int operatorId = LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
|
int workstationId = LtsSessionData::LtsSessionData::getInstance()->getWorkstationId();
|
|
|
|
LtsSessionData::LtsSessionData::getInstance()->clear();
|
|
|
|
std::shared_ptr<OperatorManagement::Interface::Ftc> opmFtc;
|
|
if (operatorId == -1 || !datSession->getFtc<OperatorManagement::DataInterface>(opmFtc))
|
|
{
|
|
}
|
|
else
|
|
{
|
|
try
|
|
{
|
|
|
|
LtsUtils::OperatorSettings* os = LtsUtils::OperatorSettings::getInstance();
|
|
|
|
const QByteArray settings = os->exportSettings();
|
|
|
|
const auto vec(LtsUtils::convert<std::vector<uint8_t>>(settings));
|
|
os->clear();
|
|
opmFtc->operatorGetSetSettingsRequest(OperatorManagement::OperatorGetSetSettingsRequest(operatorId, vec));
|
|
}
|
|
catch (const std::runtime_error& err)
|
|
{
|
|
qCritical() << "Saving operator settings failed!" << err.what();
|
|
}
|
|
|
|
std::shared_ptr<SituationReplayManagement::ForeignDataInterface> srmIfc;
|
|
if (datSession->getForeignDataInterface<SituationReplayManagement::DataInterface>(srmIfc))
|
|
{
|
|
try
|
|
{
|
|
srmIfc->removeReplayPartitionsWorkstation(workstationId);
|
|
}
|
|
catch (const std::runtime_error& err)
|
|
{
|
|
qCritical() << "Removing reply partitions from this workstation failed!" << err.what();
|
|
}
|
|
|
|
try
|
|
{
|
|
srmIfc->removeReplayPartitionsOperator(operatorId);
|
|
}
|
|
catch (const std::runtime_error& err)
|
|
{
|
|
qCritical() << "Removing reply partitions from this operator failed!" << err.what();
|
|
}
|
|
}
|
|
|
|
try
|
|
{
|
|
opmFtc->operatorLogoutRequest(OperatorManagement::OperatorLogoutRequest(operatorId));
|
|
}
|
|
catch (const std::runtime_error& err)
|
|
{
|
|
qCritical() << "Logout failed!" << err.what();
|
|
}
|
|
}
|
|
|
|
m_loginApp->deleteLater();
|
|
m_loginApp = nullptr;
|
|
|
|
QString cmd;
|
|
switch (m_shutdownAction)
|
|
{
|
|
case AssetManagement::ShutdownAction::Shutdown:
|
|
#ifdef LTS_DEBUG
|
|
cmd = QStringLiteral("xeyes");
|
|
#else
|
|
cmd = QStringLiteral("systemctl poweroff");
|
|
#endif
|
|
break;
|
|
case AssetManagement::ShutdownAction::Reboot:
|
|
#ifdef LTS_DEBUG
|
|
cmd = QStringLiteral("kcalc");
|
|
#else
|
|
cmd = QStringLiteral("systemctl reboot");
|
|
#endif
|
|
break;
|
|
case AssetManagement::ShutdownAction::Logout:
|
|
case AssetManagement::ShutdownAction::NoAction:
|
|
emit signalLogoffDone();
|
|
break;
|
|
}
|
|
|
|
if (!cmd.isEmpty())
|
|
{
|
|
QProcess::startDetached(cmd);
|
|
QCoreApplication::quit();
|
|
}
|
|
}
|
|
|
|
} // namespace LtsLogin
|