From b81392b818807b3ac4772c29a3e8352a818baab9 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 8 Aug 2020 18:29:36 -0700 Subject: [PATCH] Add an option to disable the automatic connection testing --- app/backend/computermanager.cpp | 15 ++++++++++++--- app/gui/SettingsView.qml | 19 +++++++++++++++++++ app/settings/streamingpreferences.cpp | 3 +++ app/settings/streamingpreferences.h | 3 +++ app/streaming/session.cpp | 2 +- 5 files changed, 38 insertions(+), 4 deletions(-) diff --git a/app/backend/computermanager.cpp b/app/backend/computermanager.cpp index 0f91e018..28bd1648 100644 --- a/app/backend/computermanager.cpp +++ b/app/backend/computermanager.cpp @@ -637,10 +637,19 @@ private: return serverInfo; } catch (...) { if (!m_Mdns) { - // We failed to connect to the specified PC. Let's test to make sure this network - // isn't blocking Moonlight, so we can tell the user about it. - int portTestResult = LiTestClientConnectivity("qt.conntest.moonlight-stream.org", 443, + StreamingPreferences prefs; + int portTestResult; + + if (prefs.detectNetworkBlocking) { + // We failed to connect to the specified PC. Let's test to make sure this network + // isn't blocking Moonlight, so we can tell the user about it. + portTestResult = LiTestClientConnectivity("qt.conntest.moonlight-stream.org", 443, ML_PORT_FLAG_TCP_47984 | ML_PORT_FLAG_TCP_47989); + } + else { + portTestResult = 0; + } + emit computerAddCompleted(false, portTestResult != 0 && portTestResult != ML_TEST_RESULT_INCONCLUSIVE); } return QString(); diff --git a/app/gui/SettingsView.qml b/app/gui/SettingsView.qml index e09a5960..15a9ff6d 100644 --- a/app/gui/SettingsView.qml +++ b/app/gui/SettingsView.qml @@ -842,6 +842,25 @@ Flickable { } } } + + CheckBox { + id: detectNetworkBlocking + width: parent.width + text: "Automatically detect blocked connections (Recommended)" + font.pointSize: 12 + checked: StreamingPreferences.detectNetworkBlocking + onCheckedChanged: { + // This is called on init, so only do the work if we've + // actually changed the value. + if (StreamingPreferences.detectNetworkBlocking != checked) { + StreamingPreferences.detectNetworkBlocking = checked + + // We must save the updated preference to ensure + // ComputerManager can observe the change internally. + StreamingPreferences.save() + } + } + } } } } diff --git a/app/settings/streamingpreferences.cpp b/app/settings/streamingpreferences.cpp index 33313975..81494891 100644 --- a/app/settings/streamingpreferences.cpp +++ b/app/settings/streamingpreferences.cpp @@ -28,6 +28,7 @@ #define SER_GAMEPADMOUSE "gamepadmouse" #define SER_DEFAULTVER "defaultver" #define SER_PACKETSIZE "packetsize" +#define SER_DETECTNETBLOCKING "detectnetblocking" #define CURRENT_DEFAULT_VER 1 @@ -67,6 +68,7 @@ void StreamingPreferences::reload() connectionWarnings = settings.value(SER_CONNWARNINGS, true).toBool(); richPresence = settings.value(SER_RICHPRESENCE, true).toBool(); gamepadMouse = settings.value(SER_GAMEPADMOUSE, true).toBool(); + detectNetworkBlocking = settings.value(SER_DETECTNETBLOCKING, true).toBool(); packetSize = settings.value(SER_PACKETSIZE, 0).toInt(); audioConfig = static_cast(settings.value(SER_AUDIOCFG, static_cast(AudioConfig::AC_STEREO)).toInt()); @@ -113,6 +115,7 @@ void StreamingPreferences::save() settings.setValue(SER_RICHPRESENCE, richPresence); settings.setValue(SER_GAMEPADMOUSE, gamepadMouse); settings.setValue(SER_PACKETSIZE, packetSize); + settings.setValue(SER_DETECTNETBLOCKING, detectNetworkBlocking); settings.setValue(SER_AUDIOCFG, static_cast(audioConfig)); settings.setValue(SER_VIDEOCFG, static_cast(videoCodecConfig)); settings.setValue(SER_VIDEODEC, static_cast(videoDecoderSelection)); diff --git a/app/settings/streamingpreferences.h b/app/settings/streamingpreferences.h index 6d3efa16..f50d8a88 100644 --- a/app/settings/streamingpreferences.h +++ b/app/settings/streamingpreferences.h @@ -68,6 +68,7 @@ public: Q_PROPERTY(bool connectionWarnings MEMBER connectionWarnings NOTIFY connectionWarningsChanged) Q_PROPERTY(bool richPresence MEMBER richPresence NOTIFY richPresenceChanged) Q_PROPERTY(bool gamepadMouse MEMBER gamepadMouse NOTIFY gamepadMouseChanged) + Q_PROPERTY(bool detectNetworkBlocking MEMBER detectNetworkBlocking NOTIFY detectNetworkBlockingChanged); Q_PROPERTY(AudioConfig audioConfig MEMBER audioConfig NOTIFY audioConfigChanged) Q_PROPERTY(VideoCodecConfig videoCodecConfig MEMBER videoCodecConfig NOTIFY videoCodecConfigChanged) Q_PROPERTY(VideoDecoderSelection videoDecoderSelection MEMBER videoDecoderSelection NOTIFY videoDecoderSelectionChanged) @@ -93,6 +94,7 @@ public: bool connectionWarnings; bool richPresence; bool gamepadMouse; + bool detectNetworkBlocking; int packetSize; AudioConfig audioConfig; VideoCodecConfig videoCodecConfig; @@ -121,5 +123,6 @@ signals: void connectionWarningsChanged(); void richPresenceChanged(); void gamepadMouseChanged(); + void detectNetworkBlockingChanged(); }; diff --git a/app/streaming/session.cpp b/app/streaming/session.cpp index 5a83d4f7..3b53f495 100644 --- a/app/streaming/session.cpp +++ b/app/streaming/session.cpp @@ -721,7 +721,7 @@ private: else { portFlags = 0; } - if (portFlags != 0) { + if (portFlags != 0 && m_Session->m_Preferences->detectNetworkBlocking) { portTestResult = LiTestClientConnectivity("qt.conntest.moonlight-stream.org", 443, portFlags); // Ignore an inconclusive result