Apply clang-format to Lts/Common and DTC/enum headers
- Formatted all CodeGen module files (9 files) - Formatted LtsAppDescriptor module files - Formatted LtsAppManager/AppChooser files - Applied clang-format to all DTC and enum headers across modules - Removed coordTransTests from CommonUnitTestsPlaceholder (moved to tests/) Cosmetic changes only, no functional modifications. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
848 files changed
+89305
-100020
No files matched your search
Executable → Regular
+43
-52
@@ -1,102 +1,93 @@
|
||||
|
||||
|
||||
|
||||
#include "lts_plugin_manager_dialog.h"
|
||||
|
||||
#include "../lts_plugin_manager.h"
|
||||
#include "lts_plugin_manager_widget.h"
|
||||
#include "ui_lts_plugin_manager_dialog.h"
|
||||
#include "../lts_plugin_manager.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QString>
|
||||
#include <QDebug>
|
||||
|
||||
#include <QString>
|
||||
|
||||
namespace LtsPluginManager
|
||||
{
|
||||
|
||||
LtsPluginManagerDialog::LtsPluginManagerDialog(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, m_ui(new Ui::LtsPluginManagerDialog)
|
||||
LtsPluginManagerDialog::LtsPluginManagerDialog(QWidget* parent) : QDialog(parent), m_ui(new Ui::LtsPluginManagerDialog)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
|
||||
|
||||
m_ui->masterSplitter->setStretchFactor(m_ui->masterSplitter->indexOf(m_ui->pluginsWidget), 20);
|
||||
m_ui->masterSplitter->setStretchFactor(m_ui->masterSplitter->indexOf(m_ui->lwErrorLog), 0);
|
||||
m_ui->masterSplitter->setStretchFactor(m_ui->masterSplitter->indexOf(m_ui->pluginsWidget), 20);
|
||||
m_ui->masterSplitter->setStretchFactor(m_ui->masterSplitter->indexOf(m_ui->lwErrorLog), 0);
|
||||
}
|
||||
|
||||
|
||||
LtsPluginManagerDialog::~LtsPluginManagerDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
void LtsPluginManagerDialog::setServiceMissing(const QString &newPluginFilename, const QString &missingPluginName)
|
||||
void LtsPluginManagerDialog::setServiceMissing(const QString& newPluginFilename, const QString& missingPluginName)
|
||||
{
|
||||
m_ui->lwErrorLog->addItem(tr("ERROR: Plugin '%1' needs the plugin '%2', which is not available!").arg(newPluginFilename, missingPluginName));
|
||||
getPluginWidget(newPluginFilename)->setStatus(LtsPluginWidget::MISSING_SERVICE);
|
||||
m_ui->lwErrorLog->addItem(tr("ERROR: Plugin '%1' needs the plugin '%2', which is not available!")
|
||||
.arg(newPluginFilename, missingPluginName));
|
||||
getPluginWidget(newPluginFilename)->setStatus(LtsPluginWidget::MISSING_SERVICE);
|
||||
|
||||
if (!isVisible())
|
||||
show();
|
||||
if (!isVisible())
|
||||
show();
|
||||
|
||||
QCoreApplication::processEvents();
|
||||
QCoreApplication::processEvents();
|
||||
}
|
||||
|
||||
|
||||
void LtsPluginManagerDialog::setOptionalServiceMissing(const QString &newPluginFilename, const QString &missingPluginName)
|
||||
void LtsPluginManagerDialog::setOptionalServiceMissing(const QString& newPluginFilename,
|
||||
const QString& missingPluginName)
|
||||
{
|
||||
m_ui->lwErrorLog->addItem(tr("INFO: Plugin %1 asked for plugin %2, which is not available!").arg(newPluginFilename, missingPluginName));
|
||||
m_ui->lwErrorLog->addItem(
|
||||
tr("INFO: Plugin %1 asked for plugin %2, which is not available!").arg(newPluginFilename, missingPluginName));
|
||||
|
||||
if (!isVisible())
|
||||
show();
|
||||
if (!isVisible())
|
||||
show();
|
||||
|
||||
QCoreApplication::processEvents();
|
||||
QCoreApplication::processEvents();
|
||||
}
|
||||
|
||||
|
||||
void LtsPluginManagerDialog::setInvalidPlugin(const QString &newPluginFilename)
|
||||
void LtsPluginManagerDialog::setInvalidPlugin(const QString& newPluginFilename)
|
||||
{
|
||||
m_ui->lwErrorLog->addItem(tr("INFO: Invalid plugin '%1'").arg(newPluginFilename));
|
||||
m_ui->lwErrorLog->addItem(tr("INFO: Invalid plugin '%1'").arg(newPluginFilename));
|
||||
}
|
||||
|
||||
|
||||
LtsPluginWidget *LtsPluginManagerDialog::getPluginWidget(const QString &filename)
|
||||
LtsPluginWidget* LtsPluginManagerDialog::getPluginWidget(const QString& filename)
|
||||
{
|
||||
LtsPluginWidget *pluginWidget = findChild<LtsPluginWidget *>(filename);
|
||||
LtsPluginWidget* pluginWidget = findChild<LtsPluginWidget*>(filename);
|
||||
|
||||
if (!pluginWidget)
|
||||
{
|
||||
pluginWidget = new LtsPluginWidget(filename);
|
||||
pluginWidget->setObjectName(filename);
|
||||
qobject_cast<QHBoxLayout *>(m_ui->pluginsWidget->layout())->insertWidget(0, pluginWidget);
|
||||
}
|
||||
if (!pluginWidget)
|
||||
{
|
||||
pluginWidget = new LtsPluginWidget(filename);
|
||||
pluginWidget->setObjectName(filename);
|
||||
qobject_cast<QHBoxLayout*>(m_ui->pluginsWidget->layout())->insertWidget(0, pluginWidget);
|
||||
}
|
||||
|
||||
return pluginWidget;
|
||||
return pluginWidget;
|
||||
}
|
||||
|
||||
|
||||
void LtsPluginManagerDialog::setPluginLogStatus(const QString &filename, const LtsPluginWidget::Status &status)
|
||||
void LtsPluginManagerDialog::setPluginLogStatus(const QString& filename, const LtsPluginWidget::Status& status)
|
||||
{
|
||||
getPluginWidget(filename)->setStatus(status);
|
||||
getPluginWidget(filename)->setStatus(status);
|
||||
|
||||
QCoreApplication::processEvents();
|
||||
QCoreApplication::processEvents();
|
||||
}
|
||||
|
||||
|
||||
void LtsPluginManagerDialog::setPluginLogType(const QString &filename, const QString &type)
|
||||
void LtsPluginManagerDialog::setPluginLogType(const QString& filename, const QString& type)
|
||||
{
|
||||
getPluginWidget(filename)->setType(type);
|
||||
getPluginWidget(filename)->setType(type);
|
||||
|
||||
QCoreApplication::processEvents();
|
||||
QCoreApplication::processEvents();
|
||||
}
|
||||
|
||||
|
||||
void LtsPluginManagerDialog::setPluginLogIdent(const QString &filename, const QString &ident)
|
||||
void LtsPluginManagerDialog::setPluginLogIdent(const QString& filename, const QString& ident)
|
||||
{
|
||||
getPluginWidget(filename)->setIdent(ident);
|
||||
getPluginWidget(filename)->setIdent(ident);
|
||||
|
||||
QCoreApplication::processEvents();
|
||||
QCoreApplication::processEvents();
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace LtsPluginManager
|
||||
Executable → Regular
+16
-18
@@ -1,13 +1,11 @@
|
||||
|
||||
|
||||
#pragma once
|
||||
#include <QObject>
|
||||
|
||||
#include "ltspluginmanager_export.h"
|
||||
#include "lts_plugin_manager_widget.h"
|
||||
#include "ltspluginmanager_export.h"
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
@@ -18,22 +16,22 @@ namespace LtsPluginManager
|
||||
{
|
||||
class LTSPLUGINMANAGER_EXPORT LtsPluginManagerDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LtsPluginManagerDialog(QWidget *parent = nullptr);
|
||||
~LtsPluginManagerDialog();
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LtsPluginManagerDialog(QWidget* parent = nullptr);
|
||||
~LtsPluginManagerDialog();
|
||||
|
||||
void setServiceMissing(const QString &newPluginFilename, const QString &missingPluginName);
|
||||
void setOptionalServiceMissing(const QString &newPluginFilename, const QString &missingPluginName);
|
||||
void setInvalidPlugin(const QString &newPluginFilename);
|
||||
void setServiceMissing(const QString& newPluginFilename, const QString& missingPluginName);
|
||||
void setOptionalServiceMissing(const QString& newPluginFilename, const QString& missingPluginName);
|
||||
void setInvalidPlugin(const QString& newPluginFilename);
|
||||
|
||||
void setPluginLogStatus(const QString &filename, const LtsPluginWidget::Status &status);
|
||||
void setPluginLogType(const QString &filename, const QString &type);
|
||||
void setPluginLogIdent(const QString &filename, const QString &ident);
|
||||
void setPluginLogStatus(const QString& filename, const LtsPluginWidget::Status& status);
|
||||
void setPluginLogType(const QString& filename, const QString& type);
|
||||
void setPluginLogIdent(const QString& filename, const QString& ident);
|
||||
|
||||
private:
|
||||
Ui::LtsPluginManagerDialog *m_ui;
|
||||
private:
|
||||
Ui::LtsPluginManagerDialog* m_ui;
|
||||
|
||||
LtsPluginWidget *getPluginWidget(const QString &filename);
|
||||
LtsPluginWidget* getPluginWidget(const QString& filename);
|
||||
};
|
||||
}
|
||||
} // namespace LtsPluginManager
|
||||
Executable → Regular
+88
-101
@@ -1,130 +1,117 @@
|
||||
|
||||
|
||||
|
||||
#include "lts_plugin_manager_widget.h"
|
||||
|
||||
#include "ui_lts_plugin_manager_widget.h"
|
||||
|
||||
using namespace LtsPluginManager;
|
||||
|
||||
LtsPluginWidget::LtsPluginWidget(const QString &filename, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_ui(new Ui::LtsPluginWidget)
|
||||
LtsPluginWidget::LtsPluginWidget(const QString& filename, QWidget* parent)
|
||||
: QWidget(parent), m_ui(new Ui::LtsPluginWidget)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_ui->leFilename->setText(filename);
|
||||
setStatus(UNKNOWN);
|
||||
setType();
|
||||
setIdent();
|
||||
m_ui->leFilename->setText(filename);
|
||||
setStatus(UNKNOWN);
|
||||
setType();
|
||||
setIdent();
|
||||
|
||||
|
||||
m_ui->lbGuiPlugins->hide();
|
||||
m_ui->lbGuiPlugins->hide();
|
||||
|
||||
m_ui->lbDtc->hide();
|
||||
m_ui->lwDtcs->hide();
|
||||
m_ui->lbDtc->hide();
|
||||
m_ui->lwDtcs->hide();
|
||||
|
||||
m_ui->lbFtc->hide();
|
||||
m_ui->lwFtcs->hide();
|
||||
m_ui->lbFtc->hide();
|
||||
m_ui->lwFtcs->hide();
|
||||
}
|
||||
|
||||
LtsPluginWidget::~LtsPluginWidget()
|
||||
{
|
||||
delete m_ui;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void LtsPluginWidget::setStatus(Status status)
|
||||
{
|
||||
QString statusText;
|
||||
QString statusText;
|
||||
|
||||
switch (status)
|
||||
{
|
||||
case INVALID:
|
||||
{
|
||||
m_ui->frStatus->setStyleSheet(QLatin1String("background-color: rgb(189, 106, 98);"));
|
||||
statusText = tr("Invalid");
|
||||
break;
|
||||
}
|
||||
case LOADED:
|
||||
{
|
||||
m_ui->frStatus->setStyleSheet(QLatin1String("background-color: rgb(124, 189, 124);"));
|
||||
statusText = tr("Loaded");
|
||||
break;
|
||||
}
|
||||
case CONFLICT:
|
||||
{
|
||||
m_ui->frStatus->setStyleSheet(QLatin1String("background-color: rgb(189, 106, 98);"));
|
||||
statusText = tr("CONFLICT!");
|
||||
break;
|
||||
}
|
||||
case UNLOADED:
|
||||
{
|
||||
m_ui->frStatus->setStyleSheet(QLatin1String("background-color: rgb(100, 100, 100);"));
|
||||
statusText = tr("Unloaded");
|
||||
break;
|
||||
}
|
||||
case INIT_FAILED:
|
||||
{
|
||||
m_ui->frStatus->setStyleSheet(QLatin1String("background-color: rgb(189, 106, 98);"));
|
||||
statusText = tr("INIT FAILED!");
|
||||
break;
|
||||
}
|
||||
case MISSING_SERVICE:
|
||||
{
|
||||
m_ui->frStatus->setStyleSheet(QLatin1String("background-color: rgb(189, 106, 98);"));
|
||||
statusText = tr("MISSING SERVICE!");
|
||||
break;
|
||||
}
|
||||
case OBLIBATORY_INTERFACES_MISSING:
|
||||
{
|
||||
m_ui->frStatus->setStyleSheet(QLatin1String("background-color: rgb(189, 106, 98);"));
|
||||
statusText = tr("OBLIGATORY INTERFACES MISSING!");
|
||||
break;
|
||||
}
|
||||
case INVALID_PLUGIN_VERSION:
|
||||
{
|
||||
m_ui->frStatus->setStyleSheet(QLatin1String("background-color: rgb(189, 106, 98);"));
|
||||
statusText = tr("INVALID PLUGIN VERSION!");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
m_ui->frStatus->setStyleSheet(QLatin1String("background-color: rgb(100, 100, 100);"));
|
||||
statusText = tr("Unknown (%1)").arg(status);
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch (status)
|
||||
{
|
||||
case INVALID: {
|
||||
m_ui->frStatus->setStyleSheet(QLatin1String("background-color: rgb(189, 106, 98);"));
|
||||
statusText = tr("Invalid");
|
||||
break;
|
||||
}
|
||||
case LOADED: {
|
||||
m_ui->frStatus->setStyleSheet(QLatin1String("background-color: rgb(124, 189, 124);"));
|
||||
statusText = tr("Loaded");
|
||||
break;
|
||||
}
|
||||
case CONFLICT: {
|
||||
m_ui->frStatus->setStyleSheet(QLatin1String("background-color: rgb(189, 106, 98);"));
|
||||
statusText = tr("CONFLICT!");
|
||||
break;
|
||||
}
|
||||
case UNLOADED: {
|
||||
m_ui->frStatus->setStyleSheet(QLatin1String("background-color: rgb(100, 100, 100);"));
|
||||
statusText = tr("Unloaded");
|
||||
break;
|
||||
}
|
||||
case INIT_FAILED: {
|
||||
m_ui->frStatus->setStyleSheet(QLatin1String("background-color: rgb(189, 106, 98);"));
|
||||
statusText = tr("INIT FAILED!");
|
||||
break;
|
||||
}
|
||||
case MISSING_SERVICE: {
|
||||
m_ui->frStatus->setStyleSheet(QLatin1String("background-color: rgb(189, 106, 98);"));
|
||||
statusText = tr("MISSING SERVICE!");
|
||||
break;
|
||||
}
|
||||
case OBLIBATORY_INTERFACES_MISSING: {
|
||||
m_ui->frStatus->setStyleSheet(QLatin1String("background-color: rgb(189, 106, 98);"));
|
||||
statusText = tr("OBLIGATORY INTERFACES MISSING!");
|
||||
break;
|
||||
}
|
||||
case INVALID_PLUGIN_VERSION: {
|
||||
m_ui->frStatus->setStyleSheet(QLatin1String("background-color: rgb(189, 106, 98);"));
|
||||
statusText = tr("INVALID PLUGIN VERSION!");
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
m_ui->frStatus->setStyleSheet(QLatin1String("background-color: rgb(100, 100, 100);"));
|
||||
statusText = tr("Unknown (%1)").arg(status);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_ui->leStatus->setText(statusText);
|
||||
m_ui->leStatus->setText(statusText);
|
||||
}
|
||||
|
||||
|
||||
void LtsPluginWidget::setType(const QString &type)
|
||||
void LtsPluginWidget::setType(const QString& type)
|
||||
{
|
||||
if (type.isEmpty())
|
||||
{
|
||||
m_ui->leType->hide();
|
||||
m_ui->lbType->hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->leType->show();
|
||||
m_ui->lbType->show();
|
||||
m_ui->leType->setText(type);
|
||||
}
|
||||
if (type.isEmpty())
|
||||
{
|
||||
m_ui->leType->hide();
|
||||
m_ui->lbType->hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->leType->show();
|
||||
m_ui->lbType->show();
|
||||
m_ui->leType->setText(type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LtsPluginWidget::setIdent(const QString &ident)
|
||||
void LtsPluginWidget::setIdent(const QString& ident)
|
||||
{
|
||||
if (ident.isEmpty())
|
||||
{
|
||||
m_ui->leIdent->hide();
|
||||
m_ui->lbIdent->hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->leIdent->show();
|
||||
m_ui->lbIdent->show();
|
||||
m_ui->leIdent->setText(ident);
|
||||
}
|
||||
if (ident.isEmpty())
|
||||
{
|
||||
m_ui->leIdent->hide();
|
||||
m_ui->lbIdent->hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->leIdent->show();
|
||||
m_ui->lbIdent->show();
|
||||
m_ui->leIdent->setText(ident);
|
||||
}
|
||||
}
|
||||
Executable → Regular
+22
-27
@@ -1,13 +1,9 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
#include <QObject>
|
||||
|
||||
|
||||
#include <lts_plugin_manager.h>
|
||||
#include <QWidget>
|
||||
|
||||
#include <lts_plugin_manager.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
@@ -18,29 +14,28 @@ namespace LtsPluginManager
|
||||
{
|
||||
class LtsPluginWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Status
|
||||
{
|
||||
UNKNOWN = 0,
|
||||
INVALID,
|
||||
LOADED,
|
||||
CONFLICT,
|
||||
UNLOADED,
|
||||
INIT_FAILED,
|
||||
MISSING_SERVICE,
|
||||
OBLIBATORY_INTERFACES_MISSING,
|
||||
INVALID_PLUGIN_VERSION,
|
||||
};
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Status {
|
||||
UNKNOWN = 0,
|
||||
INVALID,
|
||||
LOADED,
|
||||
CONFLICT,
|
||||
UNLOADED,
|
||||
INIT_FAILED,
|
||||
MISSING_SERVICE,
|
||||
OBLIBATORY_INTERFACES_MISSING,
|
||||
INVALID_PLUGIN_VERSION,
|
||||
};
|
||||
|
||||
explicit LtsPluginWidget(const QString &filename, QWidget *parent = nullptr);
|
||||
~LtsPluginWidget();
|
||||
explicit LtsPluginWidget(const QString& filename, QWidget* parent = nullptr);
|
||||
~LtsPluginWidget();
|
||||
|
||||
void setStatus(Status status);
|
||||
void setType(const QString &type = QString());
|
||||
void setIdent(const QString &ident = QString());
|
||||
void setStatus(Status status);
|
||||
void setType(const QString& type = QString());
|
||||
void setIdent(const QString& ident = QString());
|
||||
|
||||
private:
|
||||
Ui::LtsPluginWidget *m_ui;
|
||||
private:
|
||||
Ui::LtsPluginWidget* m_ui;
|
||||
};
|
||||
}
|
||||
} // namespace LtsPluginManager
|
||||
Executable → Regular
+322
-356
@@ -1,450 +1,416 @@
|
||||
|
||||
|
||||
|
||||
#include "lts_plugin_loader.h"
|
||||
#include <utility>
|
||||
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
#include <LtsAppDescriptor/lts_app_descriptor.h>
|
||||
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
#include <QDirIterator>
|
||||
#include <QFileInfo>
|
||||
#include <QJsonObject>
|
||||
#include <QPluginLoader>
|
||||
#include <QMutableListIterator>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include <QPluginLoader>
|
||||
#include <utility>
|
||||
|
||||
namespace LtsPluginManager
|
||||
{
|
||||
|
||||
struct LtsPluginLoaderHandler
|
||||
{
|
||||
LtsPluginLoader ltsPluginLoader;
|
||||
static NGL::INGLLogger &logger() { return NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("LtsPluginLoader"); }
|
||||
static void cleanupPluginLoader();
|
||||
LtsPluginLoader ltsPluginLoader;
|
||||
|
||||
static NGL::INGLLogger& logger()
|
||||
{
|
||||
return NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("LtsPluginLoader");
|
||||
}
|
||||
|
||||
static void cleanupPluginLoader();
|
||||
};
|
||||
Q_GLOBAL_STATIC(LtsPluginLoaderHandler, s_ltsPluginLoader)
|
||||
|
||||
void LtsPluginLoaderHandler::cleanupPluginLoader()
|
||||
{
|
||||
if (s_ltsPluginLoader.exists())
|
||||
s_ltsPluginLoader->ltsPluginLoader.unloadAllPlugins();
|
||||
if (s_ltsPluginLoader.exists())
|
||||
s_ltsPluginLoader->ltsPluginLoader.unloadAllPlugins();
|
||||
}
|
||||
|
||||
|
||||
LtsPluginLoader *LtsPluginLoader::getInstance()
|
||||
LtsPluginLoader* LtsPluginLoader::getInstance()
|
||||
{
|
||||
if (!s_ltsPluginLoader.exists())
|
||||
qAddPostRoutine(&LtsPluginLoaderHandler::cleanupPluginLoader);
|
||||
return &s_ltsPluginLoader->ltsPluginLoader;
|
||||
if (!s_ltsPluginLoader.exists())
|
||||
qAddPostRoutine(&LtsPluginLoaderHandler::cleanupPluginLoader);
|
||||
return &s_ltsPluginLoader->ltsPluginLoader;
|
||||
}
|
||||
|
||||
|
||||
LtsPluginLoader::~LtsPluginLoader()
|
||||
{
|
||||
unloadAllPlugins();
|
||||
unloadAllPlugins();
|
||||
}
|
||||
|
||||
void LtsPluginLoader::unloadAllPlugins()
|
||||
{
|
||||
for (auto &pi : std::as_const(m_loadedPlugins))
|
||||
{
|
||||
QPluginLoader *pluginLoader = pi.pluginLoader;
|
||||
for (auto& pi : std::as_const(m_loadedPlugins))
|
||||
{
|
||||
QPluginLoader* pluginLoader = pi.pluginLoader;
|
||||
|
||||
delete pluginLoader->instance();
|
||||
delete pluginLoader->instance();
|
||||
|
||||
if (!pluginLoader->unload())
|
||||
qWarning() << "~LtsPluginLoader: could not unload" << pi.pluginName << pluginLoader->errorString();
|
||||
if (!pluginLoader->unload())
|
||||
qWarning() << "~LtsPluginLoader: could not unload" << pi.pluginName << pluginLoader->errorString();
|
||||
|
||||
delete pluginLoader;
|
||||
}
|
||||
m_loadedPlugins.clear();
|
||||
delete pluginLoader;
|
||||
}
|
||||
m_loadedPlugins.clear();
|
||||
}
|
||||
|
||||
|
||||
void LtsPluginLoader::checkPlugins(const QVector<LtsAppDescriptor::AppDescription> &appVector,
|
||||
QStringList &errors )
|
||||
void LtsPluginLoader::checkPlugins(const QVector<LtsAppDescriptor::AppDescription>& appVector, QStringList& errors)
|
||||
{
|
||||
NGL::INGLLogger &logger = LtsPluginLoaderHandler::logger();
|
||||
NGL::INGLLogger& logger = LtsPluginLoaderHandler::logger();
|
||||
|
||||
if (appVector.isEmpty())
|
||||
{
|
||||
errors += QStringLiteral("No Apps available");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
QVector<PluginInstance> dataPlugins;
|
||||
QVector<PluginInstance> guiPlugins;
|
||||
auto addDataPluginFn = [&](const PluginInstance &pi)
|
||||
{
|
||||
dataPlugins.append(pi);
|
||||
return true;
|
||||
};
|
||||
auto addGuiPluginFn = [&](const PluginInstance &pi)
|
||||
{
|
||||
guiPlugins.append(pi);
|
||||
return true;
|
||||
};
|
||||
|
||||
if (!loadPlugins(PluginType::DATA, addDataPluginFn))
|
||||
{
|
||||
errors += QStringLiteral("failed to load data plugins");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!loadPlugins(PluginType::GUI, addGuiPluginFn))
|
||||
{
|
||||
errors += QStringLiteral("failed to load gui plugins");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
auto checkDuplicateIidsFn = [&](const QVector<PluginInstance> &plugins, const QString &pluginType)
|
||||
{
|
||||
typedef QMap<QString , QString > IidMap;
|
||||
IidMap iids;
|
||||
|
||||
for (auto i3 = plugins.constBegin(); i3 != plugins.constEnd(); ++i3)
|
||||
if (appVector.isEmpty())
|
||||
{
|
||||
const PluginInstance &pin = *i3;
|
||||
auto iidFound = iids.constFind(pin.pluginName);
|
||||
|
||||
if (iidFound != iids.constEnd())
|
||||
errors += QStringLiteral("Iid duplicate for %1 plugin '%2'").arg(pluginType, pin.pluginName);
|
||||
else
|
||||
iids.insert(pin.pluginName, pin.fullFileName);
|
||||
errors += QStringLiteral("No Apps available");
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
checkDuplicateIidsFn(dataPlugins, QStringLiteral("data"));
|
||||
checkDuplicateIidsFn(guiPlugins, QStringLiteral("gui"));
|
||||
QVector<PluginInstance> dataPlugins;
|
||||
QVector<PluginInstance> guiPlugins;
|
||||
auto addDataPluginFn = [&](const PluginInstance& pi) {
|
||||
dataPlugins.append(pi);
|
||||
return true;
|
||||
};
|
||||
auto addGuiPluginFn = [&](const PluginInstance& pi) {
|
||||
guiPlugins.append(pi);
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
|
||||
QVector<PluginInstance> plugins(dataPlugins + guiPlugins);
|
||||
|
||||
|
||||
|
||||
for (auto i1 = appVector.constBegin(); i1 != appVector.constEnd(); ++i1)
|
||||
{
|
||||
const LtsAppDescriptor::AppDescription &app = *i1;
|
||||
|
||||
|
||||
|
||||
const QVector<LtsAppDescriptor::PluginInfo> &piVector = app.pluginInfos;
|
||||
|
||||
for (auto i2 = piVector.constBegin(); i2 != piVector.constEnd(); i2++)
|
||||
if (!loadPlugins(PluginType::DATA, addDataPluginFn))
|
||||
{
|
||||
const LtsAppDescriptor::PluginInfo &pi = *i2;
|
||||
bool found = false;
|
||||
errors += QStringLiteral("failed to load data plugins");
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto i3 = plugins.constBegin(); i3 != plugins.constEnd(); ++i3)
|
||||
{
|
||||
const PluginInstance &pin = *i3;
|
||||
if (!loadPlugins(PluginType::GUI, addGuiPluginFn))
|
||||
{
|
||||
errors += QStringLiteral("failed to load gui plugins");
|
||||
return;
|
||||
}
|
||||
|
||||
if (pi.iid == pin.pluginName)
|
||||
auto checkDuplicateIidsFn = [&](const QVector<PluginInstance>& plugins, const QString& pluginType) {
|
||||
typedef QMap<QString, QString> IidMap;
|
||||
IidMap iids;
|
||||
|
||||
for (auto i3 = plugins.constBegin(); i3 != plugins.constEnd(); ++i3)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
const PluginInstance& pin = *i3;
|
||||
auto iidFound = iids.constFind(pin.pluginName);
|
||||
|
||||
if (iidFound != iids.constEnd())
|
||||
errors += QStringLiteral("Iid duplicate for %1 plugin '%2'").arg(pluginType, pin.pluginName);
|
||||
else
|
||||
iids.insert(pin.pluginName, pin.fullFileName);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (!found)
|
||||
{
|
||||
ERROR_LOG(logger) << "Plugin with iid '" << pi.iid << "' was requested but was not loaded!";
|
||||
errors += QStringLiteral("App '%1' requires plugin '%2' that could not be found.").arg(app.appName, pi.iid);
|
||||
}
|
||||
checkDuplicateIidsFn(dataPlugins, QStringLiteral("data"));
|
||||
checkDuplicateIidsFn(guiPlugins, QStringLiteral("gui"));
|
||||
|
||||
QVector<PluginInstance> plugins(dataPlugins + guiPlugins);
|
||||
|
||||
for (auto i1 = appVector.constBegin(); i1 != appVector.constEnd(); ++i1)
|
||||
{
|
||||
const LtsAppDescriptor::AppDescription& app = *i1;
|
||||
|
||||
const QVector<LtsAppDescriptor::PluginInfo>& piVector = app.pluginInfos;
|
||||
|
||||
for (auto i2 = piVector.constBegin(); i2 != piVector.constEnd(); i2++)
|
||||
{
|
||||
const LtsAppDescriptor::PluginInfo& pi = *i2;
|
||||
bool found = false;
|
||||
|
||||
for (auto i3 = plugins.constBegin(); i3 != plugins.constEnd(); ++i3)
|
||||
{
|
||||
const PluginInstance& pin = *i3;
|
||||
|
||||
if (pi.iid == pin.pluginName)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
ERROR_LOG(logger) << "Plugin with iid '" << pi.iid << "' was requested but was not loaded!";
|
||||
errors +=
|
||||
QStringLiteral("App '%1' requires plugin '%2' that could not be found.").arg(app.appName, pi.iid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
bool LtsPluginLoader::loadPlugins(PluginType requestedPluginType,
|
||||
const std::function<bool(const PluginInstance &)> &loadPlugin,
|
||||
const QStringList &requiredPlugins,
|
||||
const QString &specialTopicTypeFilter,
|
||||
const QStringList &optionalPlugins)
|
||||
const std::function<bool(const PluginInstance&)>& loadPlugin,
|
||||
const QStringList& requiredPlugins, const QString& specialTopicTypeFilter,
|
||||
const QStringList& optionalPlugins)
|
||||
{
|
||||
NGL::INGLLogger &logger = LtsPluginLoaderHandler::logger();
|
||||
Q_ASSERT(requestedPluginType != PluginType::UNKNOWN);
|
||||
NGL::INGLLogger& logger = LtsPluginLoaderHandler::logger();
|
||||
Q_ASSERT(requestedPluginType != PluginType::UNKNOWN);
|
||||
|
||||
QStringList requiredPluginsList = requiredPlugins;
|
||||
QStringList optionalPluginsList = optionalPlugins;
|
||||
bool checkPluginsLists = (!requiredPluginsList.isEmpty()) || (!optionalPluginsList.isEmpty());
|
||||
QStringList requiredPluginsList = requiredPlugins;
|
||||
QStringList optionalPluginsList = optionalPlugins;
|
||||
bool checkPluginsLists = (!requiredPluginsList.isEmpty()) || (!optionalPluginsList.isEmpty());
|
||||
|
||||
if (checkPluginsLists && !m_loadedPlugins.isEmpty())
|
||||
{
|
||||
if (checkPluginsLists && !m_loadedPlugins.isEmpty())
|
||||
{
|
||||
QMutableListIterator<QString> i1(requiredPluginsList);
|
||||
|
||||
while (i1.hasNext())
|
||||
{
|
||||
const QString pluginName = i1.next().toLower();
|
||||
|
||||
QMap<PluginKey, PluginInstance>::iterator i2 = m_loadedPlugins.find(PluginKey(requestedPluginType, pluginName));
|
||||
|
||||
if (i2 != m_loadedPlugins.end())
|
||||
{
|
||||
DEBUG_LOG(logger) << "Plugin " << pluginName << " already loaded, using that instance";
|
||||
QMutableListIterator<QString> i1(requiredPluginsList);
|
||||
|
||||
if (loadPlugin)
|
||||
loadPlugin(i2.value());
|
||||
while (i1.hasNext())
|
||||
{
|
||||
const QString pluginName = i1.next().toLower();
|
||||
|
||||
i1.remove();
|
||||
QMap<PluginKey, PluginInstance>::iterator i2 =
|
||||
m_loadedPlugins.find(PluginKey(requestedPluginType, pluginName));
|
||||
|
||||
if (i2 != m_loadedPlugins.end())
|
||||
{
|
||||
DEBUG_LOG(logger) << "Plugin " << pluginName << " already loaded, using that instance";
|
||||
|
||||
if (loadPlugin)
|
||||
loadPlugin(i2.value());
|
||||
|
||||
i1.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
QMutableListIterator<QString> i1(optionalPluginsList);
|
||||
|
||||
while (i1.hasNext())
|
||||
{
|
||||
const QString pluginName = i1.next().toLower();
|
||||
|
||||
QMap<PluginKey, PluginInstance>::iterator i2 =
|
||||
m_loadedPlugins.find(PluginKey(requestedPluginType, pluginName));
|
||||
|
||||
if (i2 != m_loadedPlugins.end())
|
||||
{
|
||||
DEBUG_LOG(logger) << "Plugin " << pluginName << " already loaded, using that instance";
|
||||
|
||||
if (loadPlugin)
|
||||
loadPlugin(i2.value());
|
||||
|
||||
i1.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QFileInfo libPathInfo(QCoreApplication::applicationDirPath() + QStringLiteral("/../lib/"));
|
||||
QString libPath(libPathInfo.absolutePath());
|
||||
if (!libPathInfo.exists())
|
||||
{
|
||||
QMutableListIterator<QString> i1(optionalPluginsList);
|
||||
|
||||
while (i1.hasNext())
|
||||
{
|
||||
const QString pluginName = i1.next().toLower();
|
||||
|
||||
QMap<PluginKey, PluginInstance>::iterator i2 = m_loadedPlugins.find(PluginKey(requestedPluginType, pluginName));
|
||||
|
||||
if (i2 != m_loadedPlugins.end())
|
||||
{
|
||||
DEBUG_LOG(logger) << "Plugin " << pluginName << " already loaded, using that instance";
|
||||
|
||||
if (loadPlugin)
|
||||
loadPlugin(i2.value());
|
||||
|
||||
i1.remove();
|
||||
}
|
||||
}
|
||||
libPathInfo.setFile(QCoreApplication::applicationFilePath());
|
||||
libPath = libPathInfo.absolutePath();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QFileInfo libPathInfo(QCoreApplication::applicationDirPath() + QStringLiteral("/../lib/"));
|
||||
QString libPath(libPathInfo.absolutePath());
|
||||
if (!libPathInfo.exists())
|
||||
{
|
||||
|
||||
|
||||
libPathInfo.setFile(QCoreApplication::applicationFilePath());
|
||||
libPath = libPathInfo.absolutePath();
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
const QStringList nameFilter = QStringList(QStringLiteral("*Plugin*.dll"));
|
||||
const QStringList nameFilter = QStringList(QStringLiteral("*Plugin*.dll"));
|
||||
#else
|
||||
const QStringList nameFilter = QStringList(QStringLiteral("*Plugin*.so"));
|
||||
const QStringList nameFilter = QStringList(QStringLiteral("*Plugin*.so"));
|
||||
#endif
|
||||
|
||||
static const QStringList pluginTypes({QStringLiteral("data"),
|
||||
QStringLiteral("gui"),
|
||||
QStringLiteral("topic_type"),
|
||||
QStringLiteral("project"),
|
||||
QStringLiteral("style"),
|
||||
QStringLiteral("special")});
|
||||
static const QStringList pluginTypes({QStringLiteral("data"), QStringLiteral("gui"), QStringLiteral("topic_type"),
|
||||
QStringLiteral("project"), QStringLiteral("style"),
|
||||
QStringLiteral("special")});
|
||||
|
||||
QDirIterator pluginDir(libPath, nameFilter, QDir::Files);
|
||||
while (pluginDir.hasNext())
|
||||
{
|
||||
pluginDir.next();
|
||||
const QString filename = pluginDir.fileName();
|
||||
if (filename.contains(QStringLiteral("PluginInterface"), Qt::CaseSensitive))
|
||||
continue;
|
||||
|
||||
const QString absoluteFilePath = pluginDir.filePath();
|
||||
|
||||
DEBUG_LOG(logger) << "File Path: " << absoluteFilePath;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QScopedPointer<QPluginLoader> pluginLoader(new QPluginLoader);
|
||||
pluginLoader->setFileName(absoluteFilePath);
|
||||
|
||||
const QJsonObject jObj = pluginLoader->metaData();
|
||||
QJsonObject::const_iterator iid = jObj.find(QStringLiteral("IID"));
|
||||
|
||||
if (iid == jObj.end())
|
||||
QDirIterator pluginDir(libPath, nameFilter, QDir::Files);
|
||||
while (pluginDir.hasNext())
|
||||
{
|
||||
DEBUG_LOG(logger) << "Plugin '" << filename << "' has no IID !";
|
||||
continue;
|
||||
}
|
||||
pluginDir.next();
|
||||
const QString filename = pluginDir.fileName();
|
||||
if (filename.contains(QStringLiteral("PluginInterface"), Qt::CaseSensitive))
|
||||
continue;
|
||||
|
||||
const QString jsonIid = iid.value().toString().toLower();
|
||||
const QStringList iidParameters = QString(jsonIid).split(QLatin1Char(':'));
|
||||
const QString absoluteFilePath = pluginDir.filePath();
|
||||
|
||||
DEBUG_LOG(logger) << "Plugin " << absoluteFilePath << " provides iid '" << jsonIid;
|
||||
DEBUG_LOG(logger) << "File Path: " << absoluteFilePath;
|
||||
|
||||
if (iidParameters.count() != 3)
|
||||
{
|
||||
WARNING_LOG(logger) << "Invalid iid "<<jsonIid<<" for plugin " << filename;
|
||||
continue;
|
||||
}
|
||||
QScopedPointer<QPluginLoader> pluginLoader(new QPluginLoader);
|
||||
pluginLoader->setFileName(absoluteFilePath);
|
||||
|
||||
bool ok = false;
|
||||
int pluginLoaderVersion = iidParameters.at(1).toInt(&ok);
|
||||
const QJsonObject jObj = pluginLoader->metaData();
|
||||
QJsonObject::const_iterator iid = jObj.find(QStringLiteral("IID"));
|
||||
|
||||
if (!ok || pluginLoaderVersion != PLUGIN_LOADER_VERSION)
|
||||
{
|
||||
WARNING_LOG(logger) << "Invalid plugin loader version" << pluginLoaderVersion << "for plugin:" << filename;
|
||||
continue;
|
||||
}
|
||||
|
||||
PluginType pluginType = PluginType::UNKNOWN;
|
||||
|
||||
const QString pluginName = iidParameters.at(2);
|
||||
const QString pluginTypeString = iidParameters.at(0);
|
||||
switch (pluginTypes.indexOf(pluginTypeString))
|
||||
{
|
||||
case 0:
|
||||
pluginType = PluginType::DATA;
|
||||
break;
|
||||
case 1:
|
||||
pluginType = PluginType::GUI;
|
||||
break;
|
||||
case 2:
|
||||
pluginType = PluginType::TOPIC_TYPE;
|
||||
break;
|
||||
case 3:
|
||||
pluginType = PluginType::PROJECT;
|
||||
break;
|
||||
case 4:
|
||||
pluginType = PluginType::STYLE;
|
||||
break;
|
||||
case 5:
|
||||
pluginType = PluginType::SPECIAL;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (pluginType != requestedPluginType)
|
||||
{
|
||||
DEBUG_LOG(logger) << "Plugin provides not the requested type " << (int)requestedPluginType << " is: " << (int)pluginType;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (pluginType == PluginType::SPECIAL && !specialTopicTypeFilter.isEmpty())
|
||||
{
|
||||
if (!pluginName.startsWith(specialTopicTypeFilter))
|
||||
{
|
||||
DEBUG_LOG(logger) << "Special plugin, but filter does not match: " << pluginName << " - " << specialTopicTypeFilter;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (checkPluginsLists)
|
||||
{
|
||||
bool found = false;
|
||||
|
||||
{
|
||||
QMutableListIterator<QString> i (requiredPluginsList);
|
||||
|
||||
while (i.hasNext())
|
||||
if (iid == jObj.end())
|
||||
{
|
||||
const QString requiredPlugin = i.next().toLower();
|
||||
|
||||
if (pluginName == requiredPlugin)
|
||||
{
|
||||
found = true;
|
||||
i.remove();
|
||||
break;
|
||||
}
|
||||
DEBUG_LOG(logger) << "Plugin '" << filename << "' has no IID !";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
const QString jsonIid = iid.value().toString().toLower();
|
||||
const QStringList iidParameters = QString(jsonIid).split(QLatin1Char(':'));
|
||||
|
||||
if (!found)
|
||||
{
|
||||
for (auto i = optionalPluginsList.constBegin(); i != optionalPluginsList.constEnd(); i++)
|
||||
DEBUG_LOG(logger) << "Plugin " << absoluteFilePath << " provides iid '" << jsonIid;
|
||||
|
||||
if (iidParameters.count() != 3)
|
||||
{
|
||||
const QString optionalPlugin = (*i).toLower();
|
||||
|
||||
if (pluginName == optionalPlugin)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
WARNING_LOG(logger) << "Invalid iid " << jsonIid << " for plugin " << filename;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
bool ok = false;
|
||||
int pluginLoaderVersion = iidParameters.at(1).toInt(&ok);
|
||||
|
||||
if (!found)
|
||||
{
|
||||
DEBUG_LOG(logger) << "Plugin " << pluginName << " was not requested";
|
||||
continue;
|
||||
}
|
||||
if (!ok || pluginLoaderVersion != PLUGIN_LOADER_VERSION)
|
||||
{
|
||||
WARNING_LOG(logger) << "Invalid plugin loader version" << pluginLoaderVersion << "for plugin:" << filename;
|
||||
continue;
|
||||
}
|
||||
|
||||
PluginType pluginType = PluginType::UNKNOWN;
|
||||
|
||||
const QString pluginName = iidParameters.at(2);
|
||||
const QString pluginTypeString = iidParameters.at(0);
|
||||
switch (pluginTypes.indexOf(pluginTypeString))
|
||||
{
|
||||
case 0:
|
||||
pluginType = PluginType::DATA;
|
||||
break;
|
||||
case 1:
|
||||
pluginType = PluginType::GUI;
|
||||
break;
|
||||
case 2:
|
||||
pluginType = PluginType::TOPIC_TYPE;
|
||||
break;
|
||||
case 3:
|
||||
pluginType = PluginType::PROJECT;
|
||||
break;
|
||||
case 4:
|
||||
pluginType = PluginType::STYLE;
|
||||
break;
|
||||
case 5:
|
||||
pluginType = PluginType::SPECIAL;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (pluginType != requestedPluginType)
|
||||
{
|
||||
DEBUG_LOG(logger) << "Plugin provides not the requested type " << (int)requestedPluginType
|
||||
<< " is: " << (int)pluginType;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (pluginType == PluginType::SPECIAL && !specialTopicTypeFilter.isEmpty())
|
||||
{
|
||||
if (!pluginName.startsWith(specialTopicTypeFilter))
|
||||
{
|
||||
DEBUG_LOG(logger) << "Special plugin, but filter does not match: " << pluginName << " - "
|
||||
<< specialTopicTypeFilter;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (checkPluginsLists)
|
||||
{
|
||||
bool found = false;
|
||||
|
||||
{
|
||||
QMutableListIterator<QString> i(requiredPluginsList);
|
||||
|
||||
while (i.hasNext())
|
||||
{
|
||||
const QString requiredPlugin = i.next().toLower();
|
||||
|
||||
if (pluginName == requiredPlugin)
|
||||
{
|
||||
found = true;
|
||||
i.remove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
for (auto i = optionalPluginsList.constBegin(); i != optionalPluginsList.constEnd(); i++)
|
||||
{
|
||||
const QString optionalPlugin = (*i).toLower();
|
||||
|
||||
if (pluginName == optionalPlugin)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
DEBUG_LOG(logger) << "Plugin " << pluginName << " was not requested";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (loadPlugin && !m_loadedPlugins.isEmpty())
|
||||
{
|
||||
QMap<PluginKey, PluginInstance>::iterator i =
|
||||
m_loadedPlugins.find(PluginKey(requestedPluginType, pluginName));
|
||||
|
||||
if (i != m_loadedPlugins.end())
|
||||
{
|
||||
DEBUG_LOG(logger) << "Plugin " << pluginName << " already loaded, using that instance ("
|
||||
<< i.value().plugin->metaObject()->className() << ")";
|
||||
|
||||
loadPlugin(i.value());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
QObject* plugin = pluginLoader->instance();
|
||||
|
||||
if (!plugin)
|
||||
{
|
||||
ERROR_LOG(logger) << "Failed to load " << filename << " - " << pluginLoader->errorString();
|
||||
continue;
|
||||
}
|
||||
|
||||
PluginInstance pi;
|
||||
pi.pluginName = pluginName;
|
||||
pi.fileName = filename;
|
||||
pi.fullFileName = absoluteFilePath;
|
||||
pi.plugin = plugin;
|
||||
pi.pluginLoader = pluginLoader.data();
|
||||
|
||||
if (loadPlugin && !loadPlugin(pi))
|
||||
{
|
||||
DEBUG_LOG(logger) << "Plugin " << pluginName << " unloaded";
|
||||
delete pluginLoader->instance();
|
||||
pluginLoader->unload();
|
||||
continue;
|
||||
}
|
||||
pi.pluginLoader = pluginLoader.take();
|
||||
|
||||
m_loadedPlugins.insert(PluginKey(requestedPluginType, pluginName), pi);
|
||||
|
||||
DEBUG_LOG(logger) << "Loaded " << jsonIid << " - File: " << filename;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (loadPlugin && !m_loadedPlugins.isEmpty())
|
||||
if (checkPluginsLists && !requiredPluginsList.isEmpty())
|
||||
{
|
||||
QMap<PluginKey, PluginInstance>::iterator i = m_loadedPlugins.find(PluginKey(requestedPluginType, pluginName));
|
||||
|
||||
if (i != m_loadedPlugins.end())
|
||||
{
|
||||
DEBUG_LOG(logger) << "Plugin " << pluginName << " already loaded, using that instance ("<<i.value().plugin->metaObject()->className()<<")";
|
||||
|
||||
loadPlugin(i.value());
|
||||
continue;
|
||||
}
|
||||
WARNING_LOG(logger) << "These plugins could not be found for Plugin Type " << (int)requestedPluginType << ": "
|
||||
<< requiredPluginsList.join(QStringLiteral(", "));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
QObject *plugin = pluginLoader->instance();
|
||||
|
||||
if (!plugin)
|
||||
{
|
||||
ERROR_LOG(logger) << "Failed to load " << filename << " - " << pluginLoader->errorString();
|
||||
continue;
|
||||
}
|
||||
|
||||
PluginInstance pi;
|
||||
pi.pluginName = pluginName;
|
||||
pi.fileName = filename;
|
||||
pi.fullFileName = absoluteFilePath;
|
||||
pi.plugin = plugin;
|
||||
pi.pluginLoader = pluginLoader.data();
|
||||
|
||||
if (loadPlugin && !loadPlugin(pi))
|
||||
{
|
||||
DEBUG_LOG(logger) << "Plugin " << pluginName << " unloaded";
|
||||
delete pluginLoader->instance();
|
||||
pluginLoader->unload();
|
||||
continue;
|
||||
}
|
||||
pi.pluginLoader = pluginLoader.take();
|
||||
|
||||
|
||||
m_loadedPlugins.insert(PluginKey(requestedPluginType, pluginName), pi);
|
||||
|
||||
|
||||
|
||||
|
||||
DEBUG_LOG(logger) << "Loaded " << jsonIid << " - File: " << filename;
|
||||
}
|
||||
|
||||
|
||||
if (checkPluginsLists && !requiredPluginsList.isEmpty())
|
||||
{
|
||||
WARNING_LOG(logger) << "These plugins could not be found for Plugin Type " << (int)requestedPluginType << ": " << requiredPluginsList.join(QStringLiteral(", "));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace LtsPluginManager
|
||||
Executable → Regular
+41
-46
@@ -1,25 +1,24 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#define PLUGIN_LOADER_VERSION 3
|
||||
|
||||
#include <qglobal.h>
|
||||
#include <functional>
|
||||
#include <QMap>
|
||||
#include <QPair>
|
||||
#include <functional>
|
||||
#include <qglobal.h>
|
||||
|
||||
#ifndef LTSPLUGINLOADER_EXPORT
|
||||
# ifdef BUILD_STATIC_LIBRARIES
|
||||
# define LTSPLUGINLOADER_EXPORT
|
||||
# else
|
||||
# if defined(MAKE_LTSPLUGINLOADER_LIB)
|
||||
# define LTSPLUGINLOADER_EXPORT Q_DECL_EXPORT
|
||||
# else
|
||||
# define LTSPLUGINLOADER_EXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
# endif
|
||||
#ifdef BUILD_STATIC_LIBRARIES
|
||||
#define LTSPLUGINLOADER_EXPORT
|
||||
#else
|
||||
#if defined(MAKE_LTSPLUGINLOADER_LIB)
|
||||
#define LTSPLUGINLOADER_EXPORT Q_DECL_EXPORT
|
||||
#else
|
||||
#define LTSPLUGINLOADER_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
class QObject;
|
||||
@@ -33,53 +32,49 @@ struct AppDescription;
|
||||
namespace LtsPluginManager
|
||||
{
|
||||
|
||||
enum class PluginType
|
||||
{
|
||||
UNKNOWN = 0,
|
||||
DATA,
|
||||
GUI,
|
||||
TOPIC_TYPE,
|
||||
PROJECT,
|
||||
STYLE,
|
||||
SPECIAL,
|
||||
enum class PluginType {
|
||||
UNKNOWN = 0,
|
||||
DATA,
|
||||
GUI,
|
||||
TOPIC_TYPE,
|
||||
PROJECT,
|
||||
STYLE,
|
||||
SPECIAL,
|
||||
};
|
||||
|
||||
|
||||
struct PluginInstance
|
||||
struct PluginInstance
|
||||
{
|
||||
QString pluginName;
|
||||
QString fullFileName;
|
||||
QString fileName;
|
||||
QObject *plugin = nullptr;
|
||||
QPluginLoader *pluginLoader = nullptr;
|
||||
QString pluginName;
|
||||
QString fullFileName;
|
||||
QString fileName;
|
||||
QObject* plugin = nullptr;
|
||||
QPluginLoader* pluginLoader = nullptr;
|
||||
};
|
||||
|
||||
|
||||
class LTSPLUGINLOADER_EXPORT LtsPluginLoader
|
||||
{
|
||||
public:
|
||||
static LtsPluginLoader *getInstance();
|
||||
public:
|
||||
static LtsPluginLoader* getInstance();
|
||||
|
||||
void unloadAllPlugins();
|
||||
void unloadAllPlugins();
|
||||
|
||||
void checkPlugins(const QVector<LtsAppDescriptor::AppDescription> &appVector,
|
||||
QStringList &errors );
|
||||
void checkPlugins(const QVector<LtsAppDescriptor::AppDescription>& appVector, QStringList& errors);
|
||||
|
||||
bool loadPlugins(PluginType requestedPluginType,
|
||||
const std::function<bool(const PluginInstance &pluginInstance)> &loadPlugin,
|
||||
const QStringList &requiredPlugins = QStringList(),
|
||||
const QString &specialTopicTypeFilter = QString(),
|
||||
const QStringList &optionalPlugins = QStringList());
|
||||
bool loadPlugins(PluginType requestedPluginType,
|
||||
const std::function<bool(const PluginInstance& pluginInstance)>& loadPlugin,
|
||||
const QStringList& requiredPlugins = QStringList(),
|
||||
const QString& specialTopicTypeFilter = QString(),
|
||||
const QStringList& optionalPlugins = QStringList());
|
||||
|
||||
typedef QPair<PluginType, QString> PluginKey;
|
||||
typedef QPair<PluginType, QString> PluginKey;
|
||||
|
||||
private:
|
||||
friend struct LtsPluginLoaderHandler;
|
||||
private:
|
||||
friend struct LtsPluginLoaderHandler;
|
||||
|
||||
LtsPluginLoader() = default;
|
||||
~LtsPluginLoader();
|
||||
LtsPluginLoader() = default;
|
||||
~LtsPluginLoader();
|
||||
|
||||
QMap<PluginKey, PluginInstance> m_loadedPlugins;
|
||||
QMap<PluginKey, PluginInstance> m_loadedPlugins;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LtsPluginManager
|
||||
Executable → Regular
+123
-219
@@ -1,22 +1,20 @@
|
||||
|
||||
|
||||
|
||||
#include "lts_plugin_manager.h"
|
||||
#include <utility>
|
||||
|
||||
#include "Ui/lts_plugin_manager_dialog.h"
|
||||
|
||||
#include <LtsSession/lts_session_data_dds.h>
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
#include <LtsWidgets/lts_wait_dialog.h>
|
||||
#include <LtsPluginManager/lts_plugin_loader.h>
|
||||
#include <LtsSession/lts_session_manager.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsSession/lts_session_data_dds.h>
|
||||
#include <LtsSession/lts_session_manager.h>
|
||||
#include <LtsWidgets/lts_wait_dialog.h>
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
#include <PluginInterfaces/data_plugin_interface.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
|
||||
#include <QTimer>
|
||||
#include <QDebug>
|
||||
|
||||
#include <QTimer>
|
||||
#include <utility>
|
||||
|
||||
namespace LtsPluginManager
|
||||
{
|
||||
@@ -26,262 +24,168 @@ LtsPluginManager::LtsPluginManager()
|
||||
.getNGLLogger("LtsPluginManager"))
|
||||
, m_markedForDeletion(false)
|
||||
{
|
||||
connect(m_sessionManager, &LtsSession::LtsSessionManager::signalQuit,
|
||||
this, &LtsPluginManager::signalQuit);
|
||||
connect(m_sessionManager, &LtsSession::LtsSessionManager::signalLogout,
|
||||
this, &LtsPluginManager::signalLogout);
|
||||
connect(m_sessionManager, &LtsSession::LtsSessionManager::signalInitializationFinished,
|
||||
this, &LtsPluginManager::signalInitializationFinished);
|
||||
connect(m_sessionManager, &LtsSession::LtsSessionManager::signalInitializationAborted,
|
||||
this, &LtsPluginManager::signalInitializationAborted);
|
||||
connect(m_sessionManager, &LtsSession::LtsSessionManager::signalInitializationFinished,
|
||||
this, &LtsPluginManager::slotInitializationFinished);
|
||||
connect(m_sessionManager, &LtsSession::LtsSessionManager::taskSwitch,
|
||||
this, &LtsPluginManager::taskSwitch);
|
||||
connect(m_sessionManager, &LtsSession::LtsSessionManager::hideAllOtherBLWs,
|
||||
this, &LtsPluginManager::hideAllOtherBLWs);
|
||||
connect(m_sessionManager, &LtsSession::LtsSessionManager::signalQuit, this, &LtsPluginManager::signalQuit);
|
||||
connect(m_sessionManager, &LtsSession::LtsSessionManager::signalLogout, this, &LtsPluginManager::signalLogout);
|
||||
connect(m_sessionManager, &LtsSession::LtsSessionManager::signalInitializationFinished, this,
|
||||
&LtsPluginManager::signalInitializationFinished);
|
||||
connect(m_sessionManager, &LtsSession::LtsSessionManager::signalInitializationAborted, this,
|
||||
&LtsPluginManager::signalInitializationAborted);
|
||||
connect(m_sessionManager, &LtsSession::LtsSessionManager::signalInitializationFinished, this,
|
||||
&LtsPluginManager::slotInitializationFinished);
|
||||
connect(m_sessionManager, &LtsSession::LtsSessionManager::taskSwitch, this, &LtsPluginManager::taskSwitch);
|
||||
connect(m_sessionManager, &LtsSession::LtsSessionManager::hideAllOtherBLWs, this,
|
||||
&LtsPluginManager::hideAllOtherBLWs);
|
||||
|
||||
QTimer *t = new QTimer(this);
|
||||
t->setInterval(1000);
|
||||
connect(t, &QTimer::timeout,
|
||||
this, &LtsPluginManager::signalStillAlive);
|
||||
t->start();
|
||||
QTimer* t = new QTimer(this);
|
||||
t->setInterval(1000);
|
||||
connect(t, &QTimer::timeout, this, &LtsPluginManager::signalStillAlive);
|
||||
t->start();
|
||||
}
|
||||
|
||||
|
||||
LtsPluginManager::~LtsPluginManager()
|
||||
{
|
||||
|
||||
|
||||
delete m_sessionManager;
|
||||
delete m_sessionManager;
|
||||
}
|
||||
|
||||
|
||||
void LtsPluginManager::softQuit()
|
||||
{
|
||||
emit signalSoftQuit();
|
||||
emit signalSoftQuit();
|
||||
}
|
||||
|
||||
|
||||
void LtsPluginManager::_softQuit()
|
||||
{
|
||||
m_sessionManager->softQuit();
|
||||
m_sessionManager->softQuit();
|
||||
}
|
||||
|
||||
|
||||
QVector<LtsSession::LtsSession *> LtsPluginManager::sessions() const
|
||||
QVector<LtsSession::LtsSession*> LtsPluginManager::sessions() const
|
||||
{
|
||||
return m_sessionManager->sessions();
|
||||
return m_sessionManager->sessions();
|
||||
}
|
||||
|
||||
bool LtsPluginManager::hasSituationMapInstance(const LtsAppDescriptor::AppDescription &appDescription, bool alsoTestForScriptApp)
|
||||
bool LtsPluginManager::hasSituationMapInstance(const LtsAppDescriptor::AppDescription& appDescription,
|
||||
bool alsoTestForScriptApp)
|
||||
{
|
||||
if (alsoTestForScriptApp && appDescription.id == LtsAppDescriptor::App::Scripts)
|
||||
return true;
|
||||
if (alsoTestForScriptApp && appDescription.id == LtsAppDescriptor::App::Scripts)
|
||||
return true;
|
||||
|
||||
for (const LtsAppDescriptor::PluginInfo &pluginInfo : std::as_const(appDescription.pluginInfos))
|
||||
{
|
||||
if (pluginInfo.flags.testFlag(LtsAppDescriptor::PluginInfo::Flag::ACTIONS) &&
|
||||
(pluginInfo.iid == QStringLiteral("sitmap")))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
for (const LtsAppDescriptor::PluginInfo& pluginInfo : std::as_const(appDescription.pluginInfos))
|
||||
{
|
||||
if (pluginInfo.flags.testFlag(LtsAppDescriptor::PluginInfo::Flag::ACTIONS) &&
|
||||
(pluginInfo.iid == QStringLiteral("sitmap")))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool LtsPluginManager::hasSituationMapInstance() const
|
||||
{
|
||||
return hasSituationMapInstance(m_app);
|
||||
return hasSituationMapInstance(m_app);
|
||||
}
|
||||
|
||||
LtsSession::LtsSession *LtsPluginManager::getSession(IDL::PartitionType partitionType, int partitionId)
|
||||
LtsSession::LtsSession* LtsPluginManager::getSession(IDL::PartitionType partitionType, int partitionId)
|
||||
{
|
||||
return m_sessionManager->getSession(partitionType, partitionId);
|
||||
return m_sessionManager->getSession(partitionType, partitionId);
|
||||
}
|
||||
|
||||
|
||||
bool LtsPluginManager::startApp(const LtsAppDescriptor::AppDescription &app, bool headless,
|
||||
const LtsSession::DdsConnectionParams &connParams, const QString &workspaceId,
|
||||
bool LtsPluginManager::startApp(const LtsAppDescriptor::AppDescription& app, bool headless,
|
||||
const LtsSession::DdsConnectionParams& connParams, const QString& workspaceId,
|
||||
bool hidden)
|
||||
{
|
||||
|
||||
|
||||
|
||||
LtsWidgets::LtsWaitDialogContainer wait;
|
||||
LtsWidgets::LtsWaitDialogContainer wait;
|
||||
|
||||
m_app = app;
|
||||
LtsPluginLoader *pluginLoader = LtsPluginLoader::getInstance();
|
||||
m_app = app;
|
||||
LtsPluginLoader* pluginLoader = LtsPluginLoader::getInstance();
|
||||
|
||||
QVector<PluginInstance> dataPlugins;
|
||||
auto cb = [&](const PluginInstance& pi) {
|
||||
dataPlugins.append(pi);
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
QVector<PluginInstance> dataPlugins;
|
||||
auto cb = [&](const PluginInstance &pi)
|
||||
{
|
||||
dataPlugins.append(pi);
|
||||
return true;
|
||||
};
|
||||
|
||||
if (!pluginLoader->loadPlugins(PluginType::DATA, cb))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "PluginLoader failed to load data plugins - abort!";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
QVector<PluginInstance> guiPlugins;
|
||||
auto cbLoadPlugins = [&](const PluginInstance &pi)
|
||||
{
|
||||
guiPlugins.append(pi);
|
||||
return true;
|
||||
};
|
||||
|
||||
if (!pluginLoader->loadPlugins(PluginType::GUI, cbLoadPlugins))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "PluginLoader failed to load gui plugins - abort!";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QVector<AppPluginInstance> dataApiList;
|
||||
for (auto i = dataPlugins.constBegin(); i != dataPlugins.constEnd(); ++i)
|
||||
{
|
||||
const PluginInstance &pi = *i;
|
||||
|
||||
AppPluginInstance api;
|
||||
api.pluginInstance = pi;
|
||||
api.m_appName = m_app.appName;
|
||||
api.m_appId = m_app.id;
|
||||
|
||||
|
||||
dataApiList.append(api);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
QVector<AppPluginInstance> guiApiList;
|
||||
for (auto i = guiPlugins.constBegin(); i != guiPlugins.constEnd(); ++i)
|
||||
{
|
||||
const PluginInstance &pi = *i;
|
||||
|
||||
AppPluginInstance api;
|
||||
api.pluginInstance = pi;
|
||||
api.m_appName = m_app.appName;
|
||||
api.m_appId = m_app.id;
|
||||
|
||||
|
||||
|
||||
for (auto i2 = app.pluginInfos.constBegin(); i2 != app.pluginInfos.constEnd(); ++i2)
|
||||
if (!pluginLoader->loadPlugins(PluginType::DATA, cb))
|
||||
{
|
||||
const LtsAppDescriptor::PluginInfo &rp = *i2;
|
||||
|
||||
|
||||
if (rp.type == LtsAppDescriptor::PluginInfo::PluginType::GUI
|
||||
&& rp.iid == pi.pluginName)
|
||||
{
|
||||
|
||||
api.m_flags = rp.flags;
|
||||
api.m_options = rp.options;
|
||||
|
||||
break;
|
||||
}
|
||||
WARNING_LOG(m_logger) << "PluginLoader failed to load data plugins - abort!";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QVector<PluginInstance> guiPlugins;
|
||||
auto cbLoadPlugins = [&](const PluginInstance& pi) {
|
||||
guiPlugins.append(pi);
|
||||
return true;
|
||||
};
|
||||
|
||||
guiApiList.append(api);
|
||||
}
|
||||
if (!pluginLoader->loadPlugins(PluginType::GUI, cbLoadPlugins))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "PluginLoader failed to load gui plugins - abort!";
|
||||
return false;
|
||||
}
|
||||
|
||||
QVector<AppPluginInstance> dataApiList;
|
||||
for (auto i = dataPlugins.constBegin(); i != dataPlugins.constEnd(); ++i)
|
||||
{
|
||||
const PluginInstance& pi = *i;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
AppPluginInstance api;
|
||||
api.pluginInstance = pi;
|
||||
api.m_appName = m_app.appName;
|
||||
api.m_appId = m_app.id;
|
||||
|
||||
dataApiList.append(api);
|
||||
}
|
||||
|
||||
LtsSession::DdsConnectionParams connParamsNew(connParams);
|
||||
if (!connParamsNew.isValid())
|
||||
{
|
||||
INFO_LOG(m_logger) << "Invalid connection params given - using default parameter";
|
||||
|
||||
connParamsNew.domainId = LtsSessionData::LtsSessionData::getInstance()->getDomainIdPreset();
|
||||
connParamsNew.partitionId = 0;
|
||||
connParamsNew.exerciseId = 0;
|
||||
connParamsNew.partitionType = IDL::PartitionType::Global;
|
||||
QVector<AppPluginInstance> guiApiList;
|
||||
for (auto i = guiPlugins.constBegin(); i != guiPlugins.constEnd(); ++i)
|
||||
{
|
||||
const PluginInstance& pi = *i;
|
||||
|
||||
AppPluginInstance api;
|
||||
api.pluginInstance = pi;
|
||||
api.m_appName = m_app.appName;
|
||||
api.m_appId = m_app.id;
|
||||
|
||||
connParamsNew.tcpConnectionUrl = LtsSessionData::LtsSessionData::getInstance()->getTcpConnectionUrl();
|
||||
}
|
||||
if (LtsSessionData::LtsSessionData::getInstance()->getQosFile().size() > 0 && LtsSessionData::LtsSessionData::getInstance()->getQosFile().at(0).size() > 0)
|
||||
connParamsNew.qos_file = LtsSessionData::LtsSessionData::getInstance()->getQosFile();
|
||||
else
|
||||
connParamsNew.qos_file = QStringList();
|
||||
if (!m_sessionManager->init(connParamsNew,
|
||||
dataApiList,
|
||||
guiApiList,
|
||||
m_app.id,
|
||||
workspaceId,
|
||||
headless,
|
||||
hidden))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not create Global Session - abort.";
|
||||
return false;
|
||||
}
|
||||
for (auto i2 = app.pluginInfos.constBegin(); i2 != app.pluginInfos.constEnd(); ++i2)
|
||||
{
|
||||
const LtsAppDescriptor::PluginInfo& rp = *i2;
|
||||
|
||||
return true;
|
||||
if (rp.type == LtsAppDescriptor::PluginInfo::PluginType::GUI && rp.iid == pi.pluginName)
|
||||
{
|
||||
|
||||
api.m_flags = rp.flags;
|
||||
api.m_options = rp.options;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
guiApiList.append(api);
|
||||
}
|
||||
|
||||
LtsSession::DdsConnectionParams connParamsNew(connParams);
|
||||
if (!connParamsNew.isValid())
|
||||
{
|
||||
INFO_LOG(m_logger) << "Invalid connection params given - using default parameter";
|
||||
|
||||
connParamsNew.domainId = LtsSessionData::LtsSessionData::getInstance()->getDomainIdPreset();
|
||||
connParamsNew.partitionId = 0;
|
||||
connParamsNew.exerciseId = 0;
|
||||
connParamsNew.partitionType = IDL::PartitionType::Global;
|
||||
|
||||
connParamsNew.tcpConnectionUrl = LtsSessionData::LtsSessionData::getInstance()->getTcpConnectionUrl();
|
||||
}
|
||||
if (LtsSessionData::LtsSessionData::getInstance()->getQosFile().size() > 0 &&
|
||||
LtsSessionData::LtsSessionData::getInstance()->getQosFile().at(0).size() > 0)
|
||||
connParamsNew.qos_file = LtsSessionData::LtsSessionData::getInstance()->getQosFile();
|
||||
else
|
||||
connParamsNew.qos_file = QStringList();
|
||||
if (!m_sessionManager->init(connParamsNew, dataApiList, guiApiList, m_app.id, workspaceId, headless, hidden))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not create Global Session - abort.";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace LtsPluginManager
|
||||
Executable → Regular
+83
-53
@@ -1,110 +1,140 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "lts_plugin_manager_export.h"
|
||||
|
||||
#include <LtsPluginManager/lts_plugin_loader.h>
|
||||
#include <LtsAppDescriptor/lts_app_descriptor.h>
|
||||
#include <LtsPluginManager/lts_plugin_loader.h>
|
||||
#include <ProjectConfig/project_defines.h>
|
||||
|
||||
#include <QFlags>
|
||||
#include <QMap>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QMap>
|
||||
#include <QVector>
|
||||
#include <QFlags>
|
||||
|
||||
|
||||
namespace NGL
|
||||
{
|
||||
class INGLLogger;
|
||||
}
|
||||
|
||||
namespace DataPluginBase
|
||||
{
|
||||
class Plugin;
|
||||
}
|
||||
|
||||
namespace GuiPluginBase
|
||||
{
|
||||
class Plugin;
|
||||
}
|
||||
|
||||
namespace ProjectPlugin
|
||||
{
|
||||
class Plugin;
|
||||
}
|
||||
|
||||
namespace LtsSession
|
||||
{
|
||||
class LtsSession;
|
||||
class LtsSessionManager;
|
||||
struct DdsConnectionParams;
|
||||
}
|
||||
} // namespace LtsSession
|
||||
|
||||
namespace DeveloperTools
|
||||
{
|
||||
class DevDialog;
|
||||
}
|
||||
|
||||
|
||||
namespace LtsPluginManager
|
||||
{
|
||||
struct AppPluginInstance
|
||||
struct AppPluginInstance
|
||||
{
|
||||
PluginInstance pluginInstance;
|
||||
PluginInstance pluginInstance;
|
||||
|
||||
QFlags<LtsAppDescriptor::PluginInfo::Flag> m_flags;
|
||||
QStringList m_options;
|
||||
QString m_appName;
|
||||
LtsAppDescriptor::App m_appId = LtsAppDescriptor::App::Login;
|
||||
QFlags<LtsAppDescriptor::PluginInfo::Flag> m_flags;
|
||||
QStringList m_options;
|
||||
QString m_appName;
|
||||
LtsAppDescriptor::App m_appId = LtsAppDescriptor::App::Login;
|
||||
};
|
||||
|
||||
class LTSPLUGINMANAGER_EXPORT LtsPluginManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LtsPluginManager();
|
||||
~LtsPluginManager();
|
||||
public:
|
||||
LtsPluginManager();
|
||||
~LtsPluginManager();
|
||||
|
||||
bool startApp(const LtsAppDescriptor::AppDescription &app, bool headless,
|
||||
const LtsSession::DdsConnectionParams &connParams,
|
||||
const QString &workspaceId = QString(), bool hidden = false);
|
||||
LtsSession::LtsSession *getSession(IDL::PartitionType partitionType, int partitionId);
|
||||
bool isInitialized() const { return m_initialized; }
|
||||
const LtsAppDescriptor::AppDescription &appDescription() const { return m_app; }
|
||||
QVector<LtsSession::LtsSession *> sessions() const;
|
||||
Q_DECL_DEPRECATED void setMarkedForDeletion() { m_markedForDeletion = true; }
|
||||
Q_DECL_DEPRECATED bool markedForDeletion() const { return m_markedForDeletion; }
|
||||
const QString &description() const { return m_description; }
|
||||
void setDescription(const QString &description) { m_description = description; }
|
||||
bool startApp(const LtsAppDescriptor::AppDescription& app, bool headless,
|
||||
const LtsSession::DdsConnectionParams& connParams, const QString& workspaceId = QString(),
|
||||
bool hidden = false);
|
||||
LtsSession::LtsSession* getSession(IDL::PartitionType partitionType, int partitionId);
|
||||
|
||||
static bool hasSituationMapInstance(const LtsAppDescriptor::AppDescription &appDescription, bool alsoTestFOrScriptApp = false);
|
||||
bool hasSituationMapInstance() const;
|
||||
void softQuit();
|
||||
void _softQuit();
|
||||
bool isInitialized() const
|
||||
{
|
||||
return m_initialized;
|
||||
}
|
||||
|
||||
const LtsAppDescriptor::AppDescription& appDescription() const
|
||||
{
|
||||
return m_app;
|
||||
}
|
||||
|
||||
QVector<LtsSession::LtsSession*> sessions() const;
|
||||
|
||||
LtsSession::LtsSessionManager *m_sessionManager;
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
friend class DeveloperTools::DevDialog;
|
||||
Q_DECL_DEPRECATED void setMarkedForDeletion()
|
||||
{
|
||||
m_markedForDeletion = true;
|
||||
}
|
||||
|
||||
LtsAppDescriptor::AppDescription m_app;
|
||||
bool m_initialized = false;
|
||||
bool m_markedForDeletion;
|
||||
QString m_description;
|
||||
Q_DECL_DEPRECATED bool markedForDeletion() const
|
||||
{
|
||||
return m_markedForDeletion;
|
||||
}
|
||||
|
||||
private slots:
|
||||
void slotInitializationFinished() { m_initialized = true; }
|
||||
const QString& description() const
|
||||
{
|
||||
return m_description;
|
||||
}
|
||||
|
||||
signals:
|
||||
void signalQuit();
|
||||
void signalSoftQuit();
|
||||
void signalLogout();
|
||||
void signalInitializationFinished();
|
||||
void signalInitializationAborted();
|
||||
void signalStillAlive();
|
||||
void hideAllOtherBLWs(QObject *caller);
|
||||
void taskSwitch(QObject *caller);
|
||||
void setDescription(const QString& description)
|
||||
{
|
||||
m_description = description;
|
||||
}
|
||||
|
||||
static bool hasSituationMapInstance(const LtsAppDescriptor::AppDescription& appDescription,
|
||||
bool alsoTestFOrScriptApp = false);
|
||||
bool hasSituationMapInstance() const;
|
||||
void softQuit();
|
||||
void _softQuit();
|
||||
|
||||
LtsSession::LtsSessionManager* m_sessionManager;
|
||||
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
friend class DeveloperTools::DevDialog;
|
||||
|
||||
LtsAppDescriptor::AppDescription m_app;
|
||||
bool m_initialized = false;
|
||||
bool m_markedForDeletion;
|
||||
QString m_description;
|
||||
|
||||
private slots:
|
||||
|
||||
void slotInitializationFinished()
|
||||
{
|
||||
m_initialized = true;
|
||||
}
|
||||
|
||||
signals:
|
||||
void signalQuit();
|
||||
void signalSoftQuit();
|
||||
void signalLogout();
|
||||
void signalInitializationFinished();
|
||||
void signalInitializationAborted();
|
||||
void signalStillAlive();
|
||||
void hideAllOtherBLWs(QObject* caller);
|
||||
void taskSwitch(QObject* caller);
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LtsPluginManager
|
||||
Executable → Regular
+9
-9
@@ -5,13 +5,13 @@
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#ifndef LTSPLUGINMANAGER_EXPORT
|
||||
# ifdef BUILD_STATIC_LIBRARIES
|
||||
# define LTSPLUGINMANAGER_EXPORT
|
||||
# else
|
||||
# if defined(MAKE_LTSPLUGINMANAGER_LIB)
|
||||
# define LTSPLUGINMANAGER_EXPORT Q_DECL_EXPORT
|
||||
# else
|
||||
# define LTSPLUGINMANAGER_EXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
# endif
|
||||
#ifdef BUILD_STATIC_LIBRARIES
|
||||
#define LTSPLUGINMANAGER_EXPORT
|
||||
#else
|
||||
#if defined(MAKE_LTSPLUGINMANAGER_LIB)
|
||||
#define LTSPLUGINMANAGER_EXPORT Q_DECL_EXPORT
|
||||
#else
|
||||
#define LTSPLUGINMANAGER_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
Reference in new issue
Block a user