NetworkController.h
48 lines
| 1.3 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 | ||||
#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 | ||||
r389 | void onProcessRequested(const QNetworkRequest &request, QUuid identifier, | |||
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); | |||
r401 | void replyDownloadProgress(QUuid identifier, double progress); | |||
r386 | ||||
r339 | private: | |||
void waitForFinish(); | ||||
class NetworkControllerPrivate; | ||||
spimpl::unique_impl_ptr<NetworkControllerPrivate> impl; | ||||
}; | ||||
#endif // SCIQLOP_NETWORKCONTROLLER_H | ||||