refactor: UtilsNetworking -> Networking

This commit is contained in:
tobtoht
2023-03-29 09:46:12 +02:00
parent ba826c7705
commit e86377de5c
11 changed files with 23 additions and 25 deletions
@@ -5,18 +5,18 @@
#include <QNetworkReply>
#include "utils/Utils.h"
#include "utils/networking.h"
#include "utils/Networking.h"
#include "utils/NetworkManager.h"
#include "config.h"
UtilsNetworking::UtilsNetworking(QObject *parent)
Networking::Networking(QObject *parent)
: QObject(parent) {}
void UtilsNetworking::setUserAgent(const QString &userAgent) {
void Networking::setUserAgent(const QString &userAgent) {
this->m_userAgent = userAgent;
}
QNetworkReply* UtilsNetworking::get(const QString &url) {
QNetworkReply* Networking::get(const QString &url) {
if (config()->get(Config::offlineMode).toBool()) {
return nullptr;
}
@@ -30,7 +30,7 @@ QNetworkReply* UtilsNetworking::get(const QString &url) {
return this->m_networkAccessManager->get(request);
}
QNetworkReply* UtilsNetworking::getJson(const QString &url) {
QNetworkReply* Networking::getJson(const QString &url) {
if (config()->get(Config::offlineMode).toBool()) {
return nullptr;
}
@@ -45,7 +45,7 @@ QNetworkReply* UtilsNetworking::getJson(const QString &url) {
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()) {
return nullptr;
}
@@ -4,19 +4,17 @@
#ifndef FEATHER_NETWORKING_H
#define FEATHER_NETWORKING_H
#include <QRegularExpression>
#include <QtNetwork>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include "utils/Utils.h"
class UtilsNetworking : public QObject
class Networking : public QObject
{
Q_OBJECT
public:
explicit UtilsNetworking(QObject *parent = nullptr);
explicit Networking(QObject *parent = nullptr);
QNetworkReply* get(const QString &url);
QNetworkReply* getJson(const QString &url);
+3 -3
View File
@@ -11,7 +11,7 @@
#include "config-feather.h"
#include "Utils.h"
#include "utils/AsyncTask.h"
#include "utils/networking.h"
#include "utils/Networking.h"
#include "utils/NetworkManager.h"
#include "utils/SemanticVersion.h"
@@ -25,7 +25,7 @@ Updater::Updater(QObject *parent) :
}
void Updater::checkForUpdates() {
UtilsNetworking network{this};
Networking network{this};
QNetworkReply *reply = network.getJson(QString("%1/updates.json").arg(this->getWebsiteUrl()));
if (!reply) {
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);
qDebug() << hashesUrl;
UtilsNetworking network{this};
Networking network{this};
QNetworkReply *reply = network.get(hashesUrl);
connect(reply, &QNetworkReply::finished, this, std::bind(&Updater::onSignedHashesReceived, this, reply, platformTag, newVersion));
+1 -1
View File
@@ -5,7 +5,7 @@
DaemonRpc::DaemonRpc(QObject *parent, QString daemonAddress)
: QObject(parent)
, m_network(new UtilsNetworking(this))
, m_network(new Networking(this))
, m_daemonAddress(std::move(daemonAddress))
{
}
+2 -2
View File
@@ -6,7 +6,7 @@
#include <QObject>
#include "utils/networking.h"
#include "utils/Networking.h"
class DaemonRpc : public QObject {
Q_OBJECT
@@ -42,7 +42,7 @@ private slots:
QString onSendRawTransactionFailed(const QJsonObject &obj);
private:
UtilsNetworking *m_network;
Networking *m_network;
QString m_daemonAddress;
};