Network: instantiable QML type, introduce proxyAddress property

# Conflicts:
#	main.qml
This commit is contained in:
xiphon
2020-07-29 17:43:02 +00:00
parent 7eeda0a8f0
commit 43aeea8eb7
4 changed files with 44 additions and 13 deletions

View File

@@ -35,12 +35,12 @@
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wreorder"
#include <net/http_client.h>
#include <net/http.h>
#pragma GCC diagnostic pop
#include "FutureScheduler.h"
class HttpClient : public QObject, public epee::net_utils::http::http_simple_client
class HttpClient : public QObject, public net::http::client
{
Q_OBJECT
Q_PROPERTY(quint64 contentLength READ contentLength NOTIFY contentLengthChanged);
@@ -70,6 +70,8 @@ private:
class Network : public QObject
{
Q_OBJECT
Q_PROPERTY(QString proxyAddress MEMBER m_proxyAddress NOTIFY proxyAddressChanged)
public:
Network(QObject *parent = nullptr);
@@ -79,11 +81,18 @@ public:
std::string get(const QString &url, const QString &contentType = {}) const;
QString get(
std::shared_ptr<epee::net_utils::http::http_simple_client> httpClient,
std::shared_ptr<epee::net_utils::http::abstract_http_client> httpClient,
const QString &url,
std::string &response,
const QString &contentType = {}) const;
signals:
void proxyAddressChanged() const;
private:
std::shared_ptr<epee::net_utils::http::abstract_http_client> newClient() const;
private:
QString m_proxyAddress;
mutable FutureScheduler m_scheduler;
};