mirror of
https://github.com/wownero/wowlet.git
synced 2026-10-20 00:28:39 +02:00
Settings: offline mode
This commit is contained in:
@@ -6,16 +6,21 @@
|
||||
|
||||
#include "utils/Utils.h"
|
||||
#include "utils/networking.h"
|
||||
#include "config.h"
|
||||
|
||||
UtilsNetworking::UtilsNetworking(QNetworkAccessManager *networkAccessManager, QObject *parent) :
|
||||
QObject(parent),
|
||||
m_networkAccessManager(networkAccessManager) {}
|
||||
UtilsNetworking::UtilsNetworking(QNetworkAccessManager *networkAccessManager, QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_networkAccessManager(networkAccessManager) {}
|
||||
|
||||
void UtilsNetworking::setUserAgent(const QString &userAgent) {
|
||||
this->m_userAgent = userAgent;
|
||||
}
|
||||
|
||||
QNetworkReply* UtilsNetworking::get(const QString &url) {
|
||||
if (config()->get(Config::offlineMode).toBool()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QNetworkRequest request;
|
||||
request.setUrl(QUrl(url));
|
||||
request.setRawHeader("User-Agent", m_userAgent.toUtf8());
|
||||
@@ -24,6 +29,10 @@ QNetworkReply* UtilsNetworking::get(const QString &url) {
|
||||
}
|
||||
|
||||
QNetworkReply* UtilsNetworking::getJson(const QString &url) {
|
||||
if (config()->get(Config::offlineMode).toBool()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QNetworkRequest request;
|
||||
request.setUrl(QUrl(url));
|
||||
request.setRawHeader("User-Agent", m_userAgent.toUtf8());
|
||||
@@ -33,6 +42,10 @@ QNetworkReply* UtilsNetworking::getJson(const QString &url) {
|
||||
}
|
||||
|
||||
QNetworkReply* UtilsNetworking::postJson(const QString &url, const QJsonObject &data) {
|
||||
if (config()->get(Config::offlineMode).toBool()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QNetworkRequest request;
|
||||
request.setUrl(QUrl(url));
|
||||
request.setRawHeader("User-Agent", m_userAgent.toUtf8());
|
||||
|
||||
Reference in New Issue
Block a user