Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+260
@@ -0,0 +1,260 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* SAAChooser
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Steve Kemayou, ESZS, 2025-10-16
|
||||
*/
|
||||
|
||||
#include <ConnectDialog/connect_dialog_nt.h>
|
||||
#include <LtsSession/lts_session_manager.h>
|
||||
#include <LtsWidgets/lts_message_dialog.h>
|
||||
#include <LtsWidgets/lts_global_wait_dialog.h>
|
||||
#include <QAbstractItemView>
|
||||
#include <saa_dialog_model.h>
|
||||
#include "saa_chooser.h"
|
||||
#include "ui_saa_chooser.h"
|
||||
|
||||
#include <QProcess>
|
||||
#include <QTimer>
|
||||
|
||||
namespace SAAInterfaceAdapterAdler
|
||||
{
|
||||
SaaChooser::SaaChooser(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_ui(new Ui::SaaChooser)
|
||||
, m_close(false)
|
||||
, m_selected(false)
|
||||
, m_pingTimer(new QTimer(this))
|
||||
, m_logger(getLogger("SaaChooser"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_pingTimer->setInterval(15000); // ping saa each 30 sec.
|
||||
setOnlineHelpFilename(QStringLiteral("Extras-SAA"));
|
||||
}
|
||||
|
||||
SaaChooser::~SaaChooser()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void SaaChooser::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("SAA"));
|
||||
}
|
||||
|
||||
bool SaaChooser::init(LtsSession::LtsSession *session)
|
||||
{
|
||||
m_session = session;
|
||||
|
||||
delete m_model;
|
||||
m_model = new SaaDialogModel(this);
|
||||
m_model->initModel(m_session);
|
||||
m_ui->widget->setModel(m_model);
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->widget->hideColumn(SaaDialogModel::Id);
|
||||
#endif
|
||||
m_ui->widget->setSortingEnabled(false);
|
||||
m_ui->widget->setSortIndicator(-1, Qt::AscendingOrder);
|
||||
|
||||
m_ui->widget->resizeSection(SaaDialogModel::Columns::Name, 300);
|
||||
m_ui->widget->resizeSection(SaaDialogModel::Columns::Connected, 300);
|
||||
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Show)->setText(tr("Start"));
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Show)->setIcon(QIcon(QStringLiteral("icon:saa_remote_desktop.svg")));
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Show, this, &SaaChooser::slotSelectSaa);
|
||||
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalSelectionChanged,
|
||||
this, &SaaChooser::enaDisa);
|
||||
enaDisa();
|
||||
|
||||
connect(m_pingTimer, &QTimer::timeout, this, &SaaChooser::startPingSaa);
|
||||
startPingSaa();
|
||||
m_pingTimer->start(); // timer to pin saa each .. sec. currently 30sec.
|
||||
return true;
|
||||
}
|
||||
|
||||
QString SaaChooser::rdesktopCodeToString(RdesktopCodes code)
|
||||
{
|
||||
switch(code)
|
||||
{
|
||||
case RdesktopCodes::FailedToConnect:
|
||||
return tr("Failed to connect to remote host");
|
||||
break;
|
||||
case RdesktopCodes::ConnectionRefused:
|
||||
return tr("Connection refused by remote host");
|
||||
break;
|
||||
case RdesktopCodes::UnableToConnect:
|
||||
return tr("Unable to connect to remote host");
|
||||
break;
|
||||
case RdesktopCodes::DnsError:
|
||||
return tr("DNS resolution failed to remote host");
|
||||
break;
|
||||
case RdesktopCodes::ConnectionTimeOut:
|
||||
return tr("Connection timed out");
|
||||
break;
|
||||
case RdesktopCodes::NetworkError:
|
||||
return tr("Remote network error");
|
||||
case RdesktopCodes::AuthenticationError:
|
||||
return tr("SAA Authentification failed");
|
||||
case RdesktopCodes::Unknown:
|
||||
default:
|
||||
return tr("Unknown rdesktop error");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief SaaChooser::getRdesktopInterpretation
|
||||
* Protocol Reason Codes
|
||||
* \param code
|
||||
* \return
|
||||
*/
|
||||
SaaChooser::RdesktopCodes SaaChooser::getRdesktopInterpretation(int code) const
|
||||
{
|
||||
DEBUG_LOG(m_logger)<<">> getRdesktopInterpretation: rdesktop error code: "<<code;
|
||||
switch (code)
|
||||
{
|
||||
case 0:
|
||||
case 62: // on client exit
|
||||
return RdesktopCodes::Normal;
|
||||
case 76:
|
||||
return RdesktopCodes::FailedToConnect;
|
||||
case 77:
|
||||
return RdesktopCodes::ConnectionTimeOut;
|
||||
case 78:
|
||||
return RdesktopCodes::ConnectionRefused;
|
||||
case 79:
|
||||
return RdesktopCodes::NetworkError;
|
||||
case 80:
|
||||
case 81:
|
||||
return RdesktopCodes::DnsError;
|
||||
case 82:
|
||||
return RdesktopCodes::AuthenticationError;
|
||||
default:
|
||||
return RdesktopCodes::Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
bool SaaChooser::normalExit(int code) const
|
||||
{
|
||||
DEBUG_LOG(m_logger)<<">> process finished!! exitCode: "<<code;
|
||||
return getRdesktopInterpretation(code) == RdesktopCodes::Normal;
|
||||
}
|
||||
|
||||
void SaaChooser::startPingSaa()
|
||||
{
|
||||
if (!m_model)
|
||||
return;
|
||||
|
||||
m_model->pingAllSaa();
|
||||
}
|
||||
|
||||
void SaaChooser::slotSelectSaa()
|
||||
{
|
||||
const QModelIndex curIdx = m_ui->widget->currentIndex();
|
||||
if (!curIdx.isValid())
|
||||
return;
|
||||
const AssetManagement::Asset asset = m_model->getRowData(curIdx.row());
|
||||
|
||||
const SAAUtils::AsmAssetProps assetProps(QString::fromStdString(asset.properties()));
|
||||
QPointer<QProcess> process = new QProcess(this);
|
||||
|
||||
///------------- QProcess::finished
|
||||
connect(process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
||||
this, [this, process, asset](int code, QProcess::ExitStatus)
|
||||
{
|
||||
if (process != qobject_cast<QProcess * >(sender()))
|
||||
return;
|
||||
|
||||
// set connected to false and update view
|
||||
if (m_model)
|
||||
m_model->saaConnected(asset.id(), false);
|
||||
|
||||
QString errMsg = QString::fromUtf8(process->readAllStandardError());
|
||||
if (!normalExit(code))
|
||||
new LtsWidgets::LtsMessageDialogNew(this, rdesktopCodeToString(getRdesktopInterpretation(code)));
|
||||
if (!process.isNull())
|
||||
process->deleteLater();
|
||||
});
|
||||
|
||||
//------------- QProcess::readyReadStandardError
|
||||
connect(process, &QProcess::readyReadStandardError,
|
||||
this, [this, process]()
|
||||
{
|
||||
if (process != qobject_cast<QProcess *>(sender()) || process.isNull())
|
||||
return;
|
||||
ERROR_LOG(m_logger) << ">> SAA Remote desktop: error:" << process->readAllStandardError();
|
||||
});
|
||||
|
||||
//------------- QProcess::readyReadStandardOutput
|
||||
connect(process, &QProcess::readyReadStandardOutput,
|
||||
this, [this, process]()
|
||||
{
|
||||
if (process != qobject_cast<QProcess *>(sender()) || process.isNull())
|
||||
return;
|
||||
INFO_LOG(m_logger) << ">> SAA Remote desktop: " << process->readAllStandardOutput();
|
||||
});
|
||||
|
||||
///------------- QProcess::errorOccurred
|
||||
connect(process, &QProcess::errorOccurred,
|
||||
this, [this, process, asset](QProcess::ProcessError )
|
||||
{
|
||||
if (process != qobject_cast<QProcess *>(sender()) || process.isNull())
|
||||
return;
|
||||
if (process->state() != QProcess::Running)
|
||||
LtsWidgets::LtsGlobalWaitDialog::getInstance()->done();
|
||||
|
||||
WARNING_LOG(m_logger)<<">> saa with id ("<<asset.id()<<")"<<" started ";
|
||||
//new LtsWidgets::LtsMessageDialogNew(this, tr("SAA Remote desktop process error: %1.").arg(process->errorString()));
|
||||
});
|
||||
|
||||
///------------- QProcess::started
|
||||
connect(process, &QProcess::started,
|
||||
this, [this, asset]()
|
||||
{
|
||||
WARNING_LOG(m_logger)<<">> saa with id ("<<asset.id()<<")"<<" started ";
|
||||
|
||||
LtsWidgets::LtsGlobalWaitDialog::getInstance()->done();
|
||||
// set connected to true and update view
|
||||
if (m_model)
|
||||
m_model->saaConnected(asset.id(), true);
|
||||
});
|
||||
const QString saaIp = QStringLiteral("%1:%2").arg(assetProps.host).arg(assetProps.port);
|
||||
QStringList args;
|
||||
const QString program = QStringLiteral("rdesktop");
|
||||
args <<QStringLiteral("-g")<<QStringLiteral(" 1920x1100")
|
||||
<< QStringLiteral("-u")<< assetProps.userName
|
||||
<< QStringLiteral("-p")<< assetProps.password
|
||||
<< saaIp;
|
||||
|
||||
DEBUG_LOG(m_logger)<<">> Process rdesktop: "<<args.join(QStringLiteral(" "));
|
||||
process->start(program, args);
|
||||
if (!process->waitForStarted())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not start saa process "<<process->program() <<" " << process->arguments().join(QStringLiteral(" "));
|
||||
process->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
void SaaChooser::enaDisa()
|
||||
{
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Show)->setEnabled(false);
|
||||
const QModelIndex curIdx = m_ui->widget->currentIndex();
|
||||
if (!curIdx.isValid())
|
||||
return;
|
||||
const AssetManagement::Asset &asset = m_model->getRowData(curIdx.row());
|
||||
SAAUtils::AsmAssetProps assetProps(QString::fromStdString(asset.properties()));
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Show)->setEnabled(assetProps.hasCredential());
|
||||
}
|
||||
|
||||
void SaaChooser::tableColumnOrganiserSetting()
|
||||
{
|
||||
//LtsColumnOrganiser
|
||||
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
} // namespace SAAInterfaceAdapterAdler
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* SAAChooser
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Steve Kemayou, ESZS, 2025-10-16
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <SAAs/Common/logger.h>
|
||||
#include <Services/ParticipantManagement/ppm_dtc.h>
|
||||
|
||||
#include <SAAs/Common/saa_utils.h>
|
||||
#include <QDialog>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class SaaChooser;
|
||||
}
|
||||
|
||||
|
||||
namespace ParticipantManagement {
|
||||
class Party;
|
||||
}
|
||||
|
||||
namespace SAAInterfaceAdapterAdler
|
||||
{
|
||||
class SaaDialogModel;
|
||||
|
||||
|
||||
class SaaChooser final : public LtsWidgets::LtsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SaaChooser(QWidget *parent = nullptr);
|
||||
~SaaChooser();
|
||||
void retranslate() override;
|
||||
|
||||
bool init(LtsSession::LtsSession *session);
|
||||
|
||||
enum class RdesktopCodes
|
||||
{
|
||||
Normal,
|
||||
FailedToConnect,
|
||||
ConnectionRefused,
|
||||
UnableToConnect,
|
||||
DnsError,
|
||||
ConnectionTimeOut,
|
||||
NetworkError,
|
||||
AuthenticationError,
|
||||
Unknown
|
||||
};
|
||||
|
||||
QString rdesktopCodeToString(RdesktopCodes code);
|
||||
RdesktopCodes getRdesktopInterpretation(int code) const;
|
||||
bool normalExit(int code) const;
|
||||
|
||||
private slots:
|
||||
void startPingSaa();
|
||||
void slotSelectSaa();
|
||||
void enaDisa();
|
||||
|
||||
private:
|
||||
void tableColumnOrganiserSetting() override;
|
||||
|
||||
Ui::SaaChooser *m_ui;
|
||||
SaaDialogModel *m_model{nullptr};
|
||||
LtsSession::LtsSession *m_session{nullptr};
|
||||
bool m_close;
|
||||
bool m_selected;
|
||||
|
||||
QTimer *m_pingTimer;
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
|
||||
}//namespace SAAInterfaceAdapterAdler
|
||||
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SaaChooser</class>
|
||||
<widget class="QWidget" name="SaaChooser">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>589</width>
|
||||
<height>305</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="LtsDataView::LtsDataView" name="widget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>250</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsDataView::LtsDataView</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsDataView/lts_data_view.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in new issue
Block a user