NetworkController.h
53 lines
| 1.5 KiB
| text/x-c
|
CLexer
r339 | #ifndef SCIQLOP_NETWORKCONTROLLER_H | |||
#define SCIQLOP_NETWORKCONTROLLER_H | ||||
Alexandre Leroux
|
r461 | #include "CoreGlobal.h" | ||
r339 | #include <QLoggingCategory> | |||
#include <QObject> | ||||
r389 | #include <QUuid> | |||
r339 | ||||
r751 | #include <Common/MetaTypes.h> | |||
r339 | #include <Common/spimpl.h> | |||
r389 | #include <functional> | |||
r339 | ||||
Q_DECLARE_LOGGING_CATEGORY(LOG_NetworkController) | ||||
r386 | class QNetworkReply; | |||
r389 | class QNetworkRequest; | |||
r386 | ||||
r339 | /** | |||
* @brief The NetworkController class aims to handle all network connection of SciQlop. | ||||
*/ | ||||
Alexandre Leroux
|
r461 | class SCIQLOP_CORE_EXPORT NetworkController : public QObject { | ||
r339 | Q_OBJECT | |||
public: | ||||
explicit NetworkController(QObject *parent = 0); | ||||
void initialize(); | ||||
void finalize(); | ||||
r389 | public slots: | |||
r401 | /// Execute request and call callback when the reply is finished. Identifier is attached to the | |||
/// callback | ||||
r751 | void onProcessRequested(std::shared_ptr<QNetworkRequest> request, QUuid identifier, | |||
r389 | std::function<void(QNetworkReply *, QUuid)> callback); | |||
r401 | /// Cancel the request of identifier | |||
r389 | void onReplyCanceled(QUuid identifier); | |||
r386 | signals: | |||
r389 | void replyFinished(QNetworkReply *reply, QUuid identifier); | |||
r751 | void replyDownloadProgress(QUuid identifier, std::shared_ptr<QNetworkRequest> networkRequest, | |||
r750 | double progress); | |||
r386 | ||||
r339 | private: | |||
void waitForFinish(); | ||||
class NetworkControllerPrivate; | ||||
spimpl::unique_impl_ptr<NetworkControllerPrivate> impl; | ||||
}; | ||||
r751 | SCIQLOP_REGISTER_META_TYPE(NETWORKREQUEST_REGISTRY, std::shared_ptr<QNetworkRequest>) | |||
r339 | #endif // SCIQLOP_NETWORKCONTROLLER_H | |||