mirror of
https://github.com/feather-wallet/feather.git
synced 2024-12-23 03:59:29 +00:00
refactor: UtilsNetworking -> Networking
This commit is contained in:
parent
ba826c7705
commit
e86377de5c
11 changed files with 23 additions and 25 deletions
|
@ -27,7 +27,7 @@
|
||||||
#include "model/TransactionHistoryModel.h"
|
#include "model/TransactionHistoryModel.h"
|
||||||
#include "model/CoinsModel.h"
|
#include "model/CoinsModel.h"
|
||||||
#include "model/CoinsProxyModel.h"
|
#include "model/CoinsProxyModel.h"
|
||||||
#include "utils/networking.h"
|
#include "utils/Networking.h"
|
||||||
#include "utils/config.h"
|
#include "utils/config.h"
|
||||||
#include "utils/daemonrpc.h"
|
#include "utils/daemonrpc.h"
|
||||||
#include "utils/EventFilter.h"
|
#include "utils/EventFilter.h"
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
#include "utils/AsyncTask.h"
|
#include "utils/AsyncTask.h"
|
||||||
#include "utils/networking.h"
|
#include "utils/Networking.h"
|
||||||
#include "utils/NetworkManager.h"
|
#include "utils/NetworkManager.h"
|
||||||
#include "utils/Updater.h"
|
#include "utils/Updater.h"
|
||||||
#include "utils/Utils.h"
|
#include "utils/Utils.h"
|
||||||
|
@ -86,7 +86,7 @@ void UpdateDialog::onDownloadClicked() {
|
||||||
ui->btn_download->hide();
|
ui->btn_download->hide();
|
||||||
ui->progressBar->show();
|
ui->progressBar->show();
|
||||||
|
|
||||||
UtilsNetworking network{this};
|
Networking network{this};
|
||||||
|
|
||||||
m_reply = network.get(m_updater->downloadUrl);
|
m_reply = network.get(m_updater->downloadUrl);
|
||||||
connect(m_reply, &QNetworkReply::downloadProgress, this, &UpdateDialog::onDownloadProgress);
|
connect(m_reply, &QNetworkReply::downloadProgress, this, &UpdateDialog::onDownloadProgress);
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#include "utils/config.h"
|
#include "utils/config.h"
|
||||||
|
|
||||||
LocalMoneroApi::LocalMoneroApi(QObject *parent, UtilsNetworking *network)
|
LocalMoneroApi::LocalMoneroApi(QObject *parent, Networking *network)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, m_network(network)
|
, m_network(network)
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#define FEATHER_LOCALMONEROAPI_H
|
#define FEATHER_LOCALMONEROAPI_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include "utils/networking.h"
|
#include "utils/Networking.h"
|
||||||
|
|
||||||
class LocalMoneroApi : public QObject {
|
class LocalMoneroApi : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -27,7 +27,7 @@ public:
|
||||||
QJsonObject obj;
|
QJsonObject obj;
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit LocalMoneroApi(QObject *parent, UtilsNetworking *network);
|
explicit LocalMoneroApi(QObject *parent, Networking *network);
|
||||||
|
|
||||||
void countryCodes();
|
void countryCodes();
|
||||||
void currencies();
|
void currencies();
|
||||||
|
@ -46,7 +46,7 @@ private:
|
||||||
QString getBuySellUrl(bool buy, const QString ¤cyCode, const QString &countryCode="", const QString &paymentMethod="", const QString &amount = "", int page = 0);
|
QString getBuySellUrl(bool buy, const QString ¤cyCode, const QString &countryCode="", const QString &paymentMethod="", const QString &amount = "", int page = 0);
|
||||||
QString getBaseUrl();
|
QString getBaseUrl();
|
||||||
|
|
||||||
UtilsNetworking *m_network;
|
Networking *m_network;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ LocalMoneroWidget::LocalMoneroWidget(QWidget *parent, Wallet *wallet)
|
||||||
|
|
||||||
ui->combo_currency->addItem(config()->get(Config::preferredFiatCurrency).toString());
|
ui->combo_currency->addItem(config()->get(Config::preferredFiatCurrency).toString());
|
||||||
|
|
||||||
m_network = new UtilsNetworking(this);
|
m_network = new Networking(this);
|
||||||
m_api = new LocalMoneroApi(this, m_network);
|
m_api = new LocalMoneroApi(this, m_network);
|
||||||
|
|
||||||
m_model = new LocalMoneroModel(this);
|
m_model = new LocalMoneroModel(this);
|
||||||
|
|
|
@ -48,7 +48,7 @@ private:
|
||||||
|
|
||||||
LocalMoneroApi *m_api;
|
LocalMoneroApi *m_api;
|
||||||
LocalMoneroModel *m_model;
|
LocalMoneroModel *m_model;
|
||||||
UtilsNetworking *m_network;
|
Networking *m_network;
|
||||||
QJsonObject m_paymentMethods;
|
QJsonObject m_paymentMethods;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -5,18 +5,18 @@
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
|
|
||||||
#include "utils/Utils.h"
|
#include "utils/Utils.h"
|
||||||
#include "utils/networking.h"
|
#include "utils/Networking.h"
|
||||||
#include "utils/NetworkManager.h"
|
#include "utils/NetworkManager.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
UtilsNetworking::UtilsNetworking(QObject *parent)
|
Networking::Networking(QObject *parent)
|
||||||
: QObject(parent) {}
|
: QObject(parent) {}
|
||||||
|
|
||||||
void UtilsNetworking::setUserAgent(const QString &userAgent) {
|
void Networking::setUserAgent(const QString &userAgent) {
|
||||||
this->m_userAgent = userAgent;
|
this->m_userAgent = userAgent;
|
||||||
}
|
}
|
||||||
|
|
||||||
QNetworkReply* UtilsNetworking::get(const QString &url) {
|
QNetworkReply* Networking::get(const QString &url) {
|
||||||
if (config()->get(Config::offlineMode).toBool()) {
|
if (config()->get(Config::offlineMode).toBool()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ QNetworkReply* UtilsNetworking::get(const QString &url) {
|
||||||
return this->m_networkAccessManager->get(request);
|
return this->m_networkAccessManager->get(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
QNetworkReply* UtilsNetworking::getJson(const QString &url) {
|
QNetworkReply* Networking::getJson(const QString &url) {
|
||||||
if (config()->get(Config::offlineMode).toBool()) {
|
if (config()->get(Config::offlineMode).toBool()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ QNetworkReply* UtilsNetworking::getJson(const QString &url) {
|
||||||
return this->m_networkAccessManager->get(request);
|
return this->m_networkAccessManager->get(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
QNetworkReply* UtilsNetworking::postJson(const QString &url, const QJsonObject &data) {
|
QNetworkReply* Networking::postJson(const QString &url, const QJsonObject &data) {
|
||||||
if (config()->get(Config::offlineMode).toBool()) {
|
if (config()->get(Config::offlineMode).toBool()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
|
@ -4,19 +4,17 @@
|
||||||
#ifndef FEATHER_NETWORKING_H
|
#ifndef FEATHER_NETWORKING_H
|
||||||
#define FEATHER_NETWORKING_H
|
#define FEATHER_NETWORKING_H
|
||||||
|
|
||||||
#include <QRegularExpression>
|
|
||||||
#include <QtNetwork>
|
|
||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
|
|
||||||
#include "utils/Utils.h"
|
#include "utils/Utils.h"
|
||||||
|
|
||||||
class UtilsNetworking : public QObject
|
class Networking : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit UtilsNetworking(QObject *parent = nullptr);
|
explicit Networking(QObject *parent = nullptr);
|
||||||
|
|
||||||
QNetworkReply* get(const QString &url);
|
QNetworkReply* get(const QString &url);
|
||||||
QNetworkReply* getJson(const QString &url);
|
QNetworkReply* getJson(const QString &url);
|
|
@ -11,7 +11,7 @@
|
||||||
#include "config-feather.h"
|
#include "config-feather.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
#include "utils/AsyncTask.h"
|
#include "utils/AsyncTask.h"
|
||||||
#include "utils/networking.h"
|
#include "utils/Networking.h"
|
||||||
#include "utils/NetworkManager.h"
|
#include "utils/NetworkManager.h"
|
||||||
#include "utils/SemanticVersion.h"
|
#include "utils/SemanticVersion.h"
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ Updater::Updater(QObject *parent) :
|
||||||
}
|
}
|
||||||
|
|
||||||
void Updater::checkForUpdates() {
|
void Updater::checkForUpdates() {
|
||||||
UtilsNetworking network{this};
|
Networking network{this};
|
||||||
QNetworkReply *reply = network.getJson(QString("%1/updates.json").arg(this->getWebsiteUrl()));
|
QNetworkReply *reply = network.getJson(QString("%1/updates.json").arg(this->getWebsiteUrl()));
|
||||||
if (!reply) {
|
if (!reply) {
|
||||||
emit updateCheckFailed("offline mode enabled");
|
emit updateCheckFailed("offline mode enabled");
|
||||||
|
@ -87,7 +87,7 @@ void Updater::wsUpdatesReceived(const QJsonObject &updates) {
|
||||||
QString hashesUrl = QString("%1/files/releases/hashes-%2-plain.txt").arg(this->getWebsiteUrl(), newVersion);
|
QString hashesUrl = QString("%1/files/releases/hashes-%2-plain.txt").arg(this->getWebsiteUrl(), newVersion);
|
||||||
qDebug() << hashesUrl;
|
qDebug() << hashesUrl;
|
||||||
|
|
||||||
UtilsNetworking network{this};
|
Networking network{this};
|
||||||
QNetworkReply *reply = network.get(hashesUrl);
|
QNetworkReply *reply = network.get(hashesUrl);
|
||||||
|
|
||||||
connect(reply, &QNetworkReply::finished, this, std::bind(&Updater::onSignedHashesReceived, this, reply, platformTag, newVersion));
|
connect(reply, &QNetworkReply::finished, this, std::bind(&Updater::onSignedHashesReceived, this, reply, platformTag, newVersion));
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
DaemonRpc::DaemonRpc(QObject *parent, QString daemonAddress)
|
DaemonRpc::DaemonRpc(QObject *parent, QString daemonAddress)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, m_network(new UtilsNetworking(this))
|
, m_network(new Networking(this))
|
||||||
, m_daemonAddress(std::move(daemonAddress))
|
, m_daemonAddress(std::move(daemonAddress))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include "utils/networking.h"
|
#include "utils/Networking.h"
|
||||||
|
|
||||||
class DaemonRpc : public QObject {
|
class DaemonRpc : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -42,7 +42,7 @@ private slots:
|
||||||
QString onSendRawTransactionFailed(const QJsonObject &obj);
|
QString onSendRawTransactionFailed(const QJsonObject &obj);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UtilsNetworking *m_network;
|
Networking *m_network;
|
||||||
QString m_daemonAddress;
|
QString m_daemonAddress;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue