diff --git a/src/librssguard/definitions/definitions.h b/src/librssguard/definitions/definitions.h index 46eea00c9..cffc0f0e2 100755 --- a/src/librssguard/definitions/definitions.h +++ b/src/librssguard/definitions/definitions.h @@ -14,7 +14,7 @@ #define SERVICE_CODE_INOREADER "inoreader" #define SERVICE_CODE_GMAIL "gmail" -#define ADBLOCK_SERVER_PORT "48484" +#define ADBLOCK_SERVER_PORT 48484 #define ADBLOCK_HOWTO "https://github.com/martinrotter/rssguard/blob/master/resources/docs/Documentation.md#adblock" #define ADBLOCK_ICON_ACTIVE "adblock" #define ADBLOCK_ICON_DISABLED "adblock-disabled" diff --git a/src/librssguard/network-web/adblock/adblockmanager.cpp b/src/librssguard/network-web/adblock/adblockmanager.cpp index 59ce35a37..4575974ff 100644 --- a/src/librssguard/network-web/adblock/adblockmanager.cpp +++ b/src/librssguard/network-web/adblock/adblockmanager.cpp @@ -176,7 +176,7 @@ BlockingResult AdBlockManager::askServerIfBlocked(const QString& url) const { tmr.start(); auto network_res = NetworkFactory::performNetworkOperation(QSL("http://%1:%2").arg(QHostAddress(QHostAddress::SpecialAddress::LocalHost).toString(), - ADBLOCK_SERVER_PORT), + QString::number(ADBLOCK_SERVER_PORT)), 500, QJsonDocument(req_obj).toJson(), out, @@ -217,7 +217,7 @@ QString AdBlockManager::askServerForCosmeticRules(const QString& url) const { tmr.start(); auto network_res = NetworkFactory::performNetworkOperation(QSL("http://%1:%2").arg(QHostAddress(QHostAddress::SpecialAddress::LocalHost).toString(), - ADBLOCK_SERVER_PORT), + QString::number(ADBLOCK_SERVER_PORT)), 500, QJsonDocument(req_obj).toJson(), out, @@ -241,7 +241,7 @@ QString AdBlockManager::askServerForCosmeticRules(const QString& url) const { } } -void AdBlockManager::restartServer() { +void AdBlockManager::restartServer(int port) { if (m_serverProcess->state() == QProcess::ProcessState::Running) { m_serverProcess->kill(); @@ -256,7 +256,7 @@ void AdBlockManager::restartServer() { QSL("adblock-server.js"); if (!IOFactory::copyFile(QSL(":/scripts/adblock/adblock-server.js"), temp_server)) { - qCriticalNN << LOGSEC_ADBLOCK << "Failed to copy server file to TEMP."; + qWarningNN << LOGSEC_ADBLOCK << "Failed to copy server file to TEMP."; } #if defined(Q_OS_WIN) @@ -267,7 +267,7 @@ void AdBlockManager::restartServer() { m_serverProcess->setArguments({ QDir::toNativeSeparators(temp_server), - ADBLOCK_SERVER_PORT, + QString::number(port), QDir::toNativeSeparators(m_unifiedFiltersFile) }); @@ -347,7 +347,7 @@ void AdBlockManager::updateUnifiedFiltersFile() { IOFactory::writeFile(m_unifiedFiltersFile, unified_contents.toUtf8()); if (m_enabled) { - restartServer(); + restartServer(ADBLOCK_SERVER_PORT); } } catch (const ApplicationException& ex) { diff --git a/src/librssguard/network-web/adblock/adblockmanager.h b/src/librssguard/network-web/adblock/adblockmanager.h index 5c0ea0ab7..f9f9fbd71 100644 --- a/src/librssguard/network-web/adblock/adblockmanager.h +++ b/src/librssguard/network-web/adblock/adblockmanager.h @@ -63,7 +63,7 @@ class AdBlockManager : public QObject { BlockingResult askServerIfBlocked(const QString& url) const; QString askServerForCosmeticRules(const QString& url) const; - void restartServer(); + void restartServer(int port); private: bool m_loaded;