Initial commit

This commit is contained in:
torsten committed 2026-08-13 18:33:10 +02:00
commit b7d90b9afe
16245 files changed
+3396666

No files matched your search

@@ -0,0 +1,48 @@
#
# $Id: CMakeLists.txt 51804 2020-07-31 04:47:28Z fritsche_h $
# $HeadURL: svn://slssvn/TDS/branches/product/iterations/21_03_salted_caramel/Lts/Plugins/TakeHomePackageManager/CMakeLists.txt $
# $Author: fritsche_h $
#
# Created by Gerlinde Rudolphus, NLE, 2019-03-25
#
#
# Common
#
SET(thp_SRCS
tpm_gui_plugin.cpp
tpm_gui_plugin.h
tpm_exported_scripts_dialog.cpp
tpm_exported_scripts_dialog.h
logger.cpp
logger.h
)
QT5_WRAP_UI(thp_SRCS
tpm_exported_scripts_dialog.ui
)
#TODO: auto-remove "libTakeHomePackageManagerGuiPlugin.so" from lib as this lib replaces it
NGL_ADD_LIBRARY2(WS ThpManagementGuiPlugin MODULE ${thp_SRCS})
NGL_TARGET_LINK_LIBRARIES(ThpManagementGuiPlugin
ThpCommon
TpmGuiPluginInterface
Qt5::Widgets
Qt5::Network
Qt5::WebSockets
NGLLogger
LtsWidgets
LtsSession
LtsDataView
nglcompression
nglsettings
ngltools
AsmDataPluginInterface
ExmDataPluginInterface
LtsSessionData
httq
)
NGL_INSTALL_TARGET(ThpManagementGuiPlugin)
@@ -0,0 +1,37 @@
/**
* @RDE_HEADER@
* Building Config - logging facility
* $Id: logger.cpp 46225 2019-03-25 13:59:56Z rudolphus_g $
* $HeadURL: svn://slssvn/TDS/branches/product/iterations/21_03_salted_caramel/Lts/Plugins/TakeHomePackageManager/logger.cpp $
* $Author: rudolphus_g $
*/
#include "logger.h"
#include <NGLLogger/NGLLoggerBootstrap.h>
namespace TakeHomePackageManager
{
LOGGER_T getLogger(const char *name)
{
static const char ns[] = "TPM.";
std::string loggerName;
const size_t len = strlen(name);
loggerName.reserve(sizeof(ns) + len);
loggerName.append(ns, sizeof(ns) - 1);
loggerName.append(name, len);
try
{
return NGL::NGLLoggerBootstrap::getNGLRootLogger().
getNGLLogger(loggerName);
}
catch (const std::exception &ex)
{
fprintf(stderr, "Error retrieving logger: %s", ex.what());
abort();
}
}
} // namespace TakeHomePackageManager
@@ -0,0 +1,22 @@
/**
* @RDE_HEADER@
* Logging for CentralEffectSimulation
* $Id: logger.h 46225 2019-03-25 13:59:56Z rudolphus_g $
* $HeadURL: svn://slssvn/TDS/branches/product/iterations/21_03_salted_caramel/Lts/Plugins/TakeHomePackageManager/logger.h $
* $Author: rudolphus_g $
*/
#pragma once
#include <NGLLogger/INGLLogger.h>
namespace TakeHomePackageManager
{
typedef NGL::INGLLogger &LOGGER_T;
LOGGER_T getLogger(const char *name);
inline LOGGER_T getLogger(const QString &loggerName)
{
return getLogger(loggerName.toUtf8().constData());
}
} // namespace TakeHomePackageManager
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,214 @@
/**
* @RDE_HEADER@
* Show the exported scripts and allow them to upload them to the server
* $Id: tpm_exported_scripts_dialog.h 51804 2020-07-31 04:47:28Z fritsche_h $
* $HeadURL: svn://slssvn/TDS/branches/product/iterations/21_03_salted_caramel/Lts/Plugins/TakeHomePackageManager/tpm_exported_scripts_dialog.h $
* $Author: fritsche_h $
*
* Created by Gerlinde Rudolphus, NLE, 2019-03-25
* Rebuilt to use httq by Mike Wille, NLE, 2020-07-07
*/
#pragma once
#include "logger.h"
#include <Common/tpm_exported_scripts_model.h>
#include <LtsWidgets/lts_dialog.h>
#include <QUrlQuery>
namespace Ui
{
class ExportedScriptsDialog;
}
namespace NGL
{
class Compress;
}
namespace LtsSession
{
class LtsSession;
}
class QTemporaryFile;
class QNetworkAccessManager;
class QNetworkReply;
class QNetworkRequest;
class QFileSystemWatcher;
namespace TakeHomePackageManager
{
class ProcessOverlay;
class HttpProcess : public QObject
{
Q_OBJECT
public:
HttpProcess(ExportedScriptInformation &&esi, QObject *parent);
virtual ~HttpProcess();
ProcessOverlay *process() const { return m_process; }
signals:
void signalReadyRead();
//void signalFailed(int status, const QString &msg);
void signalSuccess();
void signalTimeout();
void signalCancel();
void signalError();
private slots:
void slotReadyRead();
void slotError();
void slotSuccess();
protected slots:
void stopTimeout();
void resetTimeout();
private:
void doConnections(QNetworkReply *r);
protected:
// do not connect to QNetworkReply's readyRead, connect to this classe's signalReadyRead
QNetworkReply *post(const QString &path, QIODevice *data, const QUrlQuery &q = QUrlQuery(), const QString &contentType = QStringLiteral("application/octet-stream"));
QNetworkReply *get(const QString &path, const QUrlQuery &q = QUrlQuery());
QNetworkReply *deleteResource(const QString &path, const QUrlQuery &q = QUrlQuery());
ExportedScriptInformation m_esi;
bool m_isError { false };
NGL::INGLLogger &m_logger;
ProcessOverlay *m_process;
bool m_wasCanceled { false };
bool m_isTimeout { false };
private:
static QNetworkRequest forgeRequest(const QString &path, const QUrlQuery &q, const QString &contentType = QString());
QNetworkAccessManager *m_nam;
QTimer *m_timeout;
};
class UploadProcess : public HttpProcess
{
Q_OBJECT
public:
UploadProcess(const QString &rootFolder, ExportedScriptInformation &&esi, QObject *parent);
signals:
//void signalDone();
private slots:
void compressionDone();
private:
void abortCompress();
QTemporaryFile *m_tempFile;
NGL::Compress *m_compress;
QString m_rootDir;
};
class DownloadProcess : public HttpProcess
{
Q_OBJECT
public:
DownloadProcess(const QString &rootFolder, int modelRowId, ExportedScriptInformation &&esi, QObject *parent);
int modelRowId() const { return m_modelRowId; }
private slots:
void downloadFinished();
signals:
void signalDone();
private:
QTemporaryFile *m_tempFile;
NGL::Compress *m_compress { nullptr };
int m_modelRowId { -1 };
QString m_rootFolder;
};
class RemoveProcess : public HttpProcess
{
Q_OBJECT
public:
RemoveProcess(int modelRowId, ExportedScriptInformation &&esi, QObject *parent);
int modelRowId() const { return m_modelRowId; }
signals:
void signalDone();
private:
int m_modelRowId { -1 };
};
class ExportedScriptsDialog : public LtsWidgets::LtsDialog
{
Q_OBJECT
public:
explicit ExportedScriptsDialog(QWidget *parent = nullptr);
~ExportedScriptsDialog();
void retranslate() override;
bool init(LtsSession::LtsSession *session);
static QString getContentFolder(const QString &rootFolder, int exerciseId);
private slots:
void uploadScript();
void downloadScript();
void removeScriptFromServer();
void removeScriptLocal();
void openScript();
void onSelectionChanged();
private:
enum class WsConnectionStatus
{
NotConnected,
Connecting,
Disconnected,
Error,
Connected,
};
void startUpload();
QString getContentFolder(int exerciseId) const;
QString getRootFolder() const;
bool initModel();
void setWsConnectionStatus(WsConnectionStatus status);
void setWsConnectionStatusLabel();
private:
ExportedScriptsModel *m_model;
Ui::ExportedScriptsDialog *m_ui;
LtsSession::LtsSession *m_session;
int m_exerciseId;
QFileSystemWatcher *m_fsWatcher;
QString m_lastServerContent;
WsConnectionStatus m_wsStatus { WsConnectionStatus::NotConnected };
NGL::INGLLogger &m_logger;
};
} // namespace TakeHomePackageManager
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ExportedScriptsDialog</class>
<widget class="QWidget" name="ExportedScriptsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>834</width>
<height>491</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true">Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>The following Scripts are already exported. You can remove them from your local hard disk or upload them to the server here.</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Server connection status:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblWsStatus">
<property name="text">
<string notr="true">-</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="LtsDataView::LtsDataView" name="ltsDataView">
<property name="showColumnCount" stdset="0">
<bool>false</bool>
</property>
<property name="toolButtonsVisible">
<bool>false</bool>
</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>
@@ -0,0 +1,60 @@
/**
* @RDE_HEADER@
* GUI Plugin for ExerciseManangement
* $Id: tpm_gui_plugin.cpp 48572 2019-10-02 11:47:04Z rudolphus_g $
* $HeadURL: svn://slssvn/TDS/branches/product/iterations/21_03_salted_caramel/Lts/Plugins/TakeHomePackageManager/tpm_gui_plugin.cpp $
* $Author: rudolphus_g $
* Created by Christian Ehrlicher, SLSE, 2016-02-29
*/
#include "tpm_gui_plugin.h"
#include "tpm_exported_scripts_dialog.h"
#include "logger.h"
namespace TakeHomePackageManager
{
std::shared_ptr<GuiPluginBase::Interface> GuiPlugin::createGuiInterface(LtsSession::LtsSession *session)
{
return std::make_shared<InterfaceImpl>(session);
}
InterfaceImpl::InterfaceImpl(LtsSession::LtsSession *session)
: GuiPluginBase::Interface(session, getLogger("Plugins.Gui.Tpm"))
{}
bool InterfaceImpl::fetchInterfaces()
{
return true;
}
QString InterfaceImpl::menuGroup() const
{
return tr("Presentation");
}
QVector<LtsWidgets::PluginData> InterfaceImpl::getActions()
{
QVector<LtsWidgets::PluginData> ret;
LtsWidgets::PluginData plData;
plData.menuGroup = menuGroup();
if (m_session->app() == LtsAppDescriptor::App::Scripts)
plData.exercisePart = LtsWidgets::ExercisePart::eSpecial;
else
plData.exercisePart = LtsWidgets::ExercisePart::eAfterAction;
plData.identifier = QLatin1String("PresentationManagement.ScriptDialog.ManageExportedScripts");
plData.menuIcon = QIcon(QLatin1String("icon:export_documents.svg"));
plData.menuText = tr("Manage Exported Scripts");
// plData.operatorRight = OperatorRights::ScriptEditorEdit;
plData.createWidgetFunc = [this](QWidget *)
{
return LtsWidgets::initDialog(new ExportedScriptsDialog(), m_session);
};
ret.append(plData);
return ret;
}
} // namespace TakeHomePackageManager
@@ -0,0 +1,51 @@
/**
* @RDE_HEADER@
* Gui Plugin for MarkerManagement
* $Id: tpm_gui_plugin.h 49807 2020-02-06 09:53:16Z ehrlicher $
* $HeadURL: svn://slssvn/TDS/branches/product/iterations/21_03_salted_caramel/Lts/Plugins/TakeHomePackageManager/tpm_gui_plugin.h $
* $Author: ehrlicher $
* Created by Christian Ehrlicher, SLSE, 2016-02-29
*/
#pragma once
#include <OldTHP/tpm_gui_plugin_interface.h>
#include "logger.h"
#include <LtsSession/lts_session.h>
#include <PluginInterfaces/gui_plugin_interface.h>
namespace TakeHomePackageManager
{
class GuiPlugin final : public QObject, public GuiPluginBase::Plugin
{
Q_PLUGIN_METADATA(IID "gui:3:tpm.man")
Q_INTERFACES(GuiPluginBase::Plugin)
Q_OBJECT
public:
GuiPlugin() = default;
~GuiPlugin() = default;
QString pluginName() override { return QLatin1String("TakeHomePackageManager"); }
std::shared_ptr<GuiPluginBase::Interface> createGuiInterface(LtsSession::LtsSession *session) override;
bool availableInPartition(IDL::PartitionType partition) const override
{
return partition == IDL::PartitionType::Exercise;
}
};
class InterfaceImpl final : public QObject, public GuiPluginBase::Interface, public ForeignTpmGuiInterface
{
Q_OBJECT
public:
explicit InterfaceImpl(LtsSession::LtsSession *session);
bool fetchInterfaces() override;
QString menuGroup() const override;
QVector<LtsWidgets::PluginData> getActions() override;
bool availableInPartition(IDL::PartitionType partition) const override { return partition == IDL::PartitionType::Exercise; }
private:
};
} // namespace TakeHomePackageManager