NDEVR
API Documentation
QTNetworkRequest.h
1#pragma once
2#include <NDEVR/NtpClient.h>
3#include <NDEVR/ItemDownloader.h>
4#include <NDEVR/String.h>
5#include <NDEVR/File.h>
6#include <NDEVR/Thread.h>
7#include <QNetworkRequest>
8#include <QNetworkAccessManager>
9#include <QNetworkReply>
10#include <QFile>
11namespace NDEVR
12{
13 static uint02 ntp_rx_port = 42912;
18 {
19 Q_OBJECT
20 public:
26 QtNetworkRequest(const QNetworkRequest& request, QNetworkAccessManager* manager);
36 void setData(const File& data);
40 virtual void close() override;
44 virtual void abort() override;
49 void setReply(QNetworkReply* reply);
54 virtual bool isRunning() override;
59 virtual QByteArray data() override;
64 virtual bool start() override;
65 protected slots:
70 void processErrorSlot(QNetworkReply::NetworkError error);
71 protected:
72 QNetworkRequest m_request;
73 QNetworkReply* m_reply = nullptr;
74 QNetworkAccessManager* m_manager;
77 };
78
82 {
83 public:
89 static QNetworkRequest ConvertToRequest(const WebTarget& target);
95 virtual NetworkRequest* downloadFromURL(const WebTarget& url) override;
102 virtual NetworkRequest* uploadToURL(const WebTarget& request, const Buffer<uint01>& data) override;
109 NetworkRequest* uploadToURL(const WebTarget& request, const File& data) override;
116 virtual TimeRequest* networkTimeFromURL(const StringView& url, uint02 port) override;
117 protected:
118 QNetworkAccessManager* m_manager = nullptr;
119 };
120}
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
Logic for reading or writing to a file as well as navigating filesystems or other common file operati...
Definition File.h:53
Provides an interface for accessing resources on the internet.
A request for data or information from a network.
Allows the application to request network data using the Qt Framework.
virtual NetworkRequest * downloadFromURL(const WebTarget &url) override
Creates a network request to download content from the specified URL.
QNetworkAccessManager * m_manager
The underlying Qt network access manager.
static QNetworkRequest ConvertToRequest(const WebTarget &target)
Converts a WebTarget into a QNetworkRequest.
virtual NetworkRequest * uploadToURL(const WebTarget &request, const Buffer< uint01 > &data) override
Creates a network request to upload raw byte data to the specified URL.
virtual TimeRequest * networkTimeFromURL(const StringView &url, uint02 port) override
Creates an NTP time request to retrieve network time from the specified server.
NetworkRequest * uploadToURL(const WebTarget &request, const File &data) override
Creates a network request to upload a file to the specified URL.
void setData(const Buffer< uint01 > &data)
Sets the raw byte data to upload with this request.
void setData(const File &data)
Sets a file whose contents will be uploaded with this request.
void processErrorSlot(QNetworkReply::NetworkError error)
Handles network errors emitted by the QNetworkReply.
QNetworkRequest m_request
The underlying Qt network request.
QNetworkAccessManager * m_manager
The Qt network access manager executing the request.
virtual QByteArray data() override
Returns the response data received from the network.
File m_file
File to upload with the request.
Buffer< uint01 > m_data
Raw byte data to upload with the request.
void setReply(QNetworkReply *reply)
Assigns the QNetworkReply received from the network access manager.
virtual bool start() override
Initiates the network request.
QNetworkReply * m_reply
The active network reply, or nullptr if not started.
virtual void close() override
Closes the network reply and releases associated resources.
QtNetworkRequest(const QNetworkRequest &request, QNetworkAccessManager *manager)
Constructs a network request from a QNetworkRequest and access manager.
virtual void abort() override
Aborts the in-progress network request.
virtual bool isRunning() override
Checks whether the network request is still in progress.
The core String View class for the NDEVR API.
Definition StringView.h:58
A request to get the time from the network.
The primary namespace for the NDEVR SDK.
uint16_t uint02
-Defines an alias representing a 2 byte, unsigned integer -Can represent exact integer values 0 throu...
static uint02 ntp_rx_port
Default local port for receiving NTP responses.
A url target and optional username and password for a network request.