Index: sources/wifi/WifiInterface.cpp =================================================================== diff -u -r87ca1f6fca153e2ac05425d2dc5937d5a46ba206 -rbba484de53409dec9c7d3cf331621d9733154872 --- sources/wifi/WifiInterface.cpp (.../WifiInterface.cpp) (revision 87ca1f6fca153e2ac05425d2dc5937d5a46ba206) +++ sources/wifi/WifiInterface.cpp (.../WifiInterface.cpp) (revision bba484de53409dec9c7d3cf331621d9733154872) @@ -40,6 +40,7 @@ _processSetStaticGateway .setParent(this); _processSetStaticSubnetMask .setParent(this); _processSetDNS .setParent(this); + _processTestNetwork .setParent(this); _processTestInternet .setParent(this); } @@ -149,6 +150,9 @@ connect(&_processTestInternet , SIGNAL( finished(int, QProcess::ExitStatus)), this , SLOT( onProcessFinishedTestInternet(int, QProcess::ExitStatus))); + connect(&_processTestNetwork , SIGNAL( finished(int, QProcess::ExitStatus)), + this , SLOT( onProcessFinishedTestLocalNetwork(int, QProcess::ExitStatus))); + connect(this, SIGNAL(didRequestAutoAssignedIP()), this, SLOT( onRequestAutoAssignedIP())); @@ -262,6 +266,14 @@ */ void WifiInterface::timerEvent(QTimerEvent *) { + if (_processTestNetwork.state() != QProcess::NotRunning) { + LOG_DEBUG("The network test is already running."); + return; + } + + QString script_network; if ( ! checkScript(script_network, Wifi_Test_Network) ) return; + _processTestNetwork.start(script_network, QStringList() << _iface << _network.mIPSettings.mGateway); + if (_processTestInternet.state() != QProcess::NotRunning) { LOG_DEBUG("The internet test is already running."); return; @@ -280,19 +292,42 @@ void WifiInterface::onProcessFinishedTestInternet(int vExitCode, QProcess::ExitStatus) { QString out = _processTestInternet.readAllStandardOutput(); - QString err = _processTestInternet.readAllStandardError(); if (vExitCode != 0) { - didInternetConnectionChange(false); + emit didInternetConnectionChange(false); return; } bool hasInternet = QRegularExpression("4 packets transmitted, 4 packets received, 0% packet loss").match(out).hasMatch(); LOG_DEBUG(QString("Connected to internet? %1").arg(hasInternet)); + if (hasInternet) + emit didLocalNetworkConnectionChange(true); emit didInternetConnectionChange(hasInternet); } /*! + * \brief WifiInterface::onProcessFinishedTestLocalNetwork + * Called when the local network connectivity test has finished + * \param vExitCode - (int) the exit code + * \param vExitStatus - (QProcess::ExitStatus) the exit status + */ +void WifiInterface::onProcessFinishedTestLocalNetwork(int vExitCode, QProcess::ExitStatus) +{ + QString out = _processTestNetwork.readAllStandardOutput(); + if (vExitCode != 0) + { + emit didLocalNetworkConnectionChange(false); + return; + } + + bool hasNetwork = QRegularExpression("4 packets transmitted, 4 packets received, 0% packet loss").match(out).hasMatch(); + LOG_DEBUG(QString("Connected to Wi-Fi network? %1").arg(hasNetwork)); + if (!hasNetwork) + emit didInternetConnectionChange(false); + emit didLocalNetworkConnectionChange(hasNetwork); +} + +/*! * \brief WifiInterface::doScan * Scans for WiFi Access Points */ @@ -652,7 +687,7 @@ if (_useStaticDNS && !dns.isEmpty()) doRequestSetDNS(dns); - emit didConnectToNetwork(_network); + emit didSetupNetworkConnection(_network); } /*!