mirror of
https://github.com/wownero/wowlet.git
synced 2026-12-04 05:54:01 +01:00
Settings: offline mode
This commit is contained in:
+5
-1
@@ -238,7 +238,11 @@ bool xdgDesktopEntryRegister() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool portOpen(const QString &hostname, quint16 port){
|
||||
bool portOpen(const QString &hostname, quint16 port) { // TODO: this call should be async
|
||||
if (config()->get(Config::offlineMode).toBool()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
QTcpSocket socket;
|
||||
socket.connectToHost(hostname, port);
|
||||
return socket.waitForConnected(600);
|
||||
|
||||
@@ -69,6 +69,7 @@ static const QHash<Config::ConfigKey, ConfigDirective> configStrings = {
|
||||
{Config::inactivityLockEnabled, {QS("inactivityLockEnabled"), false}},
|
||||
{Config::inactivityLockTimeout, {QS("inactivityLockTimeout"), 10}},
|
||||
{Config::disableWebsocket, {QS("disableWebsocket"), false}},
|
||||
{Config::offlineMode, {QS("offlineMode"), false}},
|
||||
|
||||
{Config::multiBroadcast, {QS("multiBroadcast"), true}},
|
||||
{Config::warnOnExternalLink,{QS("warnOnExternalLink"), true}},
|
||||
|
||||
@@ -73,6 +73,7 @@ public:
|
||||
inactivityLockEnabled,
|
||||
inactivityLockTimeout,
|
||||
disableWebsocket,
|
||||
offlineMode,
|
||||
|
||||
multiBroadcast,
|
||||
warnOnExternalLink,
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -192,6 +192,10 @@ void Nodes::connectToNode(const FeatherNode &node) {
|
||||
if (!node.isValid())
|
||||
return;
|
||||
|
||||
if (config()->get(Config::offlineMode).toBool()) {
|
||||
return;
|
||||
}
|
||||
|
||||
emit updateStatus(QString("Connecting to %1").arg(node.toAddress()));
|
||||
qInfo() << QString("Attempting to connect to %1 (%2)").arg(node.toAddress()).arg(node.custom ? "custom" : "ws");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user