/** * Handler for PDF download coordination * $Id$ * $HeadURL$ * $Author$ * Created by Hannes Fritsche, NLE, 26-04-2019 */ #pragma once // dds #include #include #include #include #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 &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 m_fts; std::shared_ptr 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 m_pdfData; PdfDownloader *m_downloader; QSqlDatabase m_remoteDbConnection; LOGGER_T &m_logger; }; } // namespace OcBaseDownload