@@ -3,8 +3,6 | |||
|
3 | 3 | |
|
4 | 4 | #include "AmdaGlobal.h" |
|
5 | 5 | |
|
6 | #include <Common/spimpl.h> | |
|
7 | ||
|
8 | 6 | #include <Data/IDataProvider.h> |
|
9 | 7 | |
|
10 | 8 | #include <QLoggingCategory> |
@@ -25,14 +23,6 public: | |||
|
25 | 23 | |
|
26 | 24 | private: |
|
27 | 25 | void retrieveData(QUuid token, const SqpDateTime &dateTime); |
|
28 | ||
|
29 | class AmdaProviderPrivate; | |
|
30 | spimpl::unique_impl_ptr<AmdaProviderPrivate> impl; | |
|
31 | ||
|
32 | // private slots: | |
|
33 | // void httpFinished(QNetworkReply *reply, QUuid dataId) noexcept; | |
|
34 | // void httpDownloadFinished(QNetworkReply *reply, QUuid dataId) noexcept; | |
|
35 | // void httpDownloadReadyRead(QNetworkReply *reply, QUuid dataId) noexcept; | |
|
36 | 26 | }; |
|
37 | 27 | |
|
38 | 28 | #endif // SCIQLOP_AMDAPROVIDER_H |
@@ -34,18 +34,9 QString dateFormat(double sqpDateTime) noexcept | |||
|
34 | 34 | return dateTime.toString(AMDA_TIME_FORMAT); |
|
35 | 35 | } |
|
36 | 36 | |
|
37 | ||
|
38 | 37 | } // namespace |
|
39 | 38 | |
|
40 |
|
|
|
41 | SqpDateTime m_DateTime{}; | |
|
42 | std::unique_ptr<QNetworkAccessManager> m_AccessManager{nullptr}; | |
|
43 | QNetworkReply *m_Reply{nullptr}; | |
|
44 | // std::unique_ptr<QTemporaryFile> m_File{nullptr}; | |
|
45 | QUuid m_Token; | |
|
46 | }; | |
|
47 | ||
|
48 | AmdaProvider::AmdaProvider() : impl{spimpl::make_unique_impl<AmdaProviderPrivate>()} | |
|
39 | AmdaProvider::AmdaProvider() | |
|
49 | 40 | { |
|
50 | 41 | qCDebug(LOG_NetworkController()) << tr("AmdaProvider::AmdaProvider") |
|
51 | 42 | << QThread::currentThread(); |
@@ -79,30 +70,31 void AmdaProvider::retrieveData(QUuid token, const SqpDateTime &dateTime) | |||
|
79 | 70 | |
|
80 | 71 | auto tempFile = std::make_shared<QTemporaryFile>(); |
|
81 | 72 | |
|
82 | ||
|
83 | 73 | // LAMBDA |
|
84 | auto httpDownloadFinished = [this, tempFile](QNetworkReply *reply, QUuid dataId) noexcept { | |
|
85 | ||
|
86 | if (tempFile) { | |
|
87 | auto replyReadAll = reply->readAll(); | |
|
88 |
if ( |
|
|
89 |
|
|
|
90 | } | |
|
91 |
tempFile-> |
|
|
92 | ||
|
93 | // Parse results file | |
|
94 | if (auto dataSeries = AmdaResultParser::readTxt(tempFile->fileName())) { | |
|
95 | emit dataProvided(impl->m_Token, dataSeries, impl->m_DateTime); | |
|
96 | } | |
|
97 | else { | |
|
98 |
|
|
|
99 |
|
|
|
100 | } | |
|
101 | ||
|
102 | // Deletes reply | |
|
103 | reply->deleteLater(); | |
|
104 | reply = nullptr; | |
|
105 | }; | |
|
74 | auto httpDownloadFinished | |
|
75 | = [this, dateTime, tempFile, token](QNetworkReply *reply, QUuid dataId) noexcept { | |
|
76 | Q_UNUSED(dataId); | |
|
77 | ||
|
78 | if (tempFile) { | |
|
79 | auto replyReadAll = reply->readAll(); | |
|
80 | if (!replyReadAll.isEmpty()) { | |
|
81 | tempFile->write(replyReadAll); | |
|
82 | } | |
|
83 | tempFile->close(); | |
|
84 | ||
|
85 | // Parse results file | |
|
86 | if (auto dataSeries = AmdaResultParser::readTxt(tempFile->fileName())) { | |
|
87 | emit dataProvided(token, dataSeries, dateTime); | |
|
88 | } | |
|
89 | else { | |
|
90 | /// @todo ALX : debug | |
|
91 | } | |
|
92 | } | |
|
93 | ||
|
94 | // Deletes reply | |
|
95 | reply->deleteLater(); | |
|
96 | reply = nullptr; | |
|
97 | }; | |
|
106 | 98 | auto httpFinishedLambda = [this, httpDownloadFinished, tempFile](QNetworkReply *reply, |
|
107 | 99 | QUuid dataId) noexcept { |
|
108 | 100 | |
@@ -122,8 +114,5 void AmdaProvider::retrieveData(QUuid token, const SqpDateTime &dateTime) | |||
|
122 | 114 | // //////////////// // |
|
123 | 115 | // Executes request // |
|
124 | 116 | // //////////////// // |
|
125 | ||
|
126 | impl->m_Token = token; | |
|
127 | impl->m_DateTime = dateTime; | |
|
128 | 117 | emit requestConstructed(QNetworkRequest{url}, token, httpFinishedLambda); |
|
129 | 118 | } |
General Comments 0
You need to be logged in to leave comments.
Login now