diff --git a/src/qt/downloader.cpp b/src/qt/downloader.cpp index d925c77c..25790895 100644 --- a/src/qt/downloader.cpp +++ b/src/qt/downloader.cpp @@ -220,3 +220,23 @@ quint64 Downloader::total() const { return m_httpClient->contentLength(); } + +QString Downloader::proxyAddress() const +{ + QMutexLocker locker(&m_proxyMutex); + return m_proxyAddress; +} + +void Downloader::setProxyAddress(QString address) +{ + m_scheduler.run([this, address] { + if (!m_httpClient->set_proxy(address.toStdString())) + { + qCritical() << "Failed to set proxy address" << address; + } + + QMutexLocker locker(&m_proxyMutex); + m_proxyAddress = address; + emit proxyAddressChanged(); + }); +} diff --git a/src/qt/downloader.h b/src/qt/downloader.h index 418627a5..b60eeeae 100644 --- a/src/qt/downloader.h +++ b/src/qt/downloader.h @@ -38,6 +38,7 @@ class Downloader : public QObject Q_PROPERTY(bool active READ active NOTIFY activeChanged); Q_PROPERTY(quint64 loaded READ loaded NOTIFY loadedChanged); Q_PROPERTY(quint64 total READ total NOTIFY totalChanged); + Q_PROPERTY(QString proxyAddress READ proxyAddress WRITE setProxyAddress NOTIFY proxyAddressChanged) public: Downloader(QObject *parent = nullptr); @@ -51,11 +52,14 @@ signals: void activeChanged() const; void loadedChanged() const; void totalChanged() const; + void proxyAddressChanged() const; private: bool active() const; quint64 loaded() const; quint64 total() const; + QString proxyAddress() const; + void setProxyAddress(QString address); private: bool m_active; @@ -63,5 +67,7 @@ private: std::shared_ptr m_httpClient; mutable QReadWriteLock m_mutex; Network m_network; + QString m_proxyAddress; + mutable QMutex m_proxyMutex; mutable FutureScheduler m_scheduler; };