Files
qt5-legatus-legacy/Lts/Services/OcBaseDownload/handler_pdf_download.h
T
2026-08-13 18:33:10 +02:00

87 lines
2.7 KiB
C++
Executable File

/**
* Handler for PDF download coordination
* $Id$
* $HeadURL$
* $Author$
* Created by Hannes Fritsche, NLE, 26-04-2019
*/
#pragma once
// dds
#include <OcBaseDownload/obd_fts.h>
#include <QSqlDatabase>
#include <FileManagement/flm_db.h>
#include <FileManagement/flm_db_impl_custom.h>
#include "WebSocketInterface/Messages/client_message.h"
#include "WebSocketInterface/websocket_interface_handler.h"
#include "pdf_download_socket.h"
#include "logger.h"
namespace OcBaseDownload
{
class PdfDownloader;
class MainHandler;
class HandlerPdfDownload : public QObject
, protected Interface::Fts::GetPdfListRequestHandler
, protected Interface::Fts::StartPdfDownloadRequestHandler
, protected Interface::Fts::OcPdfDownloadRequestHandler
{
Q_OBJECT
public:
explicit HandlerPdfDownload(MainHandler *mainHandler,
QObject *parent = nullptr);
~HandlerPdfDownload();
bool init();
void handleServicePortsInformation(const QVector<WebSocketInterface::Messages::ServicePortsInformation::ExerciseInformation> &portsInformation);
void handlePdfListData(const WebSocketInterface::Messages::PdfListMessage::PdfListData &pdfListData);
void onGetPdfListRequest(const rti::core::SampleIdentity &cookie, const GetPdfListRequest &request) override final;
void onStartPdfDownloadRequest(const rti::core::SampleIdentity &cookie, const StartPdfDownloadRequest &request) override final;
void onOcPdfDownloadRequest(const rti::core::SampleIdentity &cookie, const OcPdfDownloadRequest &request )override final;
void exportOcPdfFileContent();
bool openRemoteDbConnection(const QString &remoteDatabaseName);
QSqlDatabase openDb(const QString &databaseName, bool remote, bool *bOk);
void closeDb(QSqlDatabase &dbConn);
private Q_SLOTS:
void onConnected();
void onDisconnected();
void onNewDownloadState(int progress, const QString &msg);
void onAllDownloadsFinished();
private: // other
enum class Mode
{
PORT_REQUEST,
LIST_REQUEST,
};
private: // methods
void openWebSocket();
private: // attributes
std::shared_ptr<Interface::Fts> m_fts;
std::shared_ptr<WebSocketInterface::WebSocketInterfaceHandler> m_webSocket;
MainHandler *m_mainHandler;
int m_exerciseId;
int m_folderId;
QString m_operatorName;
QString m_hostname;
QString m_remoteHostName;
int m_currentPort;
rti::core::SampleIdentity m_pdfListCookie;
rti::core::SampleIdentity m_downloadCookie;
rti::core::SampleIdentity m_ocPdfDownloadCookie;
PdfDownloadReply m_downloadReply;
Core::FunctionReply m_ocPdfDownloadReply;
Mode m_currentMode;
QVector<WebSocketInterface::Messages::PdfListMessage::PdfInformation> m_pdfData;
PdfDownloader *m_downloader;
QSqlDatabase m_remoteDbConnection;
LOGGER_T &m_logger;
};
} // namespace OcBaseDownload