Remove obsolete network connection checks

refs #869
This commit is contained in:
Roland Winklmeier
2017-02-15 15:12:10 +01:00
committed by Mathew Sutcliffe
parent 98b2061d3d
commit 7faffc520d
4 changed files with 0 additions and 51 deletions

View File

@@ -574,17 +574,6 @@ namespace BlackCore
return this->m_accessManager.networkAccessible() == QNetworkAccessManager::Accessible;
}
bool CApplication::isNetworkConnected() const
{
static bool con = CNetworkUtils::hasConnectedInterface();
return con;
}
bool CApplication::isNetworkConnectedAndAccessible() const
{
return this->isNetworkConnected() && this->isNetworkAccessible();
}
void CApplication::exit(int retcode)
{
if (instance())

View File

@@ -154,12 +154,6 @@ namespace BlackCore
//! Network accessible?
bool isNetworkAccessible() const;
//! Network connected (at startup time)
bool isNetworkConnected() const;
//! Network connected and also accessible
bool isNetworkConnectedAndAccessible() const;
//! Setup already synchronized
bool isSetupAvailable() const;

View File

@@ -48,30 +48,6 @@ namespace BlackMisc
return 2000;
}
bool CNetworkUtils::hasConnectedInterface(bool withDebugOutput)
{
// http://stackoverflow.com/questions/2475266/verfiying-the-network-connection-using-qt-4-4
const QList<QNetworkInterface> interfaces = QNetworkInterface::allInterfaces();
for (const QNetworkInterface &interface : interfaces)
{
// details of connection
if (withDebugOutput) qDebug() << "name:" << interface.name() << endl << "ip addresses:" << endl << "mac:" << interface.hardwareAddress() << endl;
if (interface.flags().testFlag(QNetworkInterface::IsUp) && !interface.flags().testFlag(QNetworkInterface::IsLoopBack))
{
// this loop is important to check if there are addresses
for (const QNetworkAddressEntry &entry : interface.addressEntries())
{
if (withDebugOutput) qDebug() << entry.ip().toString() << " / " << entry.netmask().toString() << endl;
// we have an interface that is up, and has an ip address, therefore the link is present
// we will only enable this check on first positive, all later results are incorrect
return true;
}
}
}
return false;
}
bool CNetworkUtils::canPing(const QString &hostAddress)
{
if (hostAddress.isEmpty()) { return false; }
@@ -110,12 +86,6 @@ namespace BlackMisc
bool CNetworkUtils::canConnect(const QString &hostAddress, int port, QString &message, int timeoutMs)
{
if (!CNetworkUtils::hasConnectedInterface(false))
{
message = QObject::tr("No connected network interface", "BlackMisc");
return false;
}
// KB: I have had an issue with QTcpSocket. It was stuck in HostLookupState and did
// only recover after a reboot for no obvious reason.
// Currently trying the ping alternative

View File

@@ -50,10 +50,6 @@ namespace BlackMisc
//! Default for timeout
static int getTimeoutMs();
//! Is a connected interface available?
//! \param withDebugOutput enables some debugging output
static bool hasConnectedInterface(bool withDebugOutput = false);
//! Can ping the address?
//! \note uses OS ping
static bool canPing(const QString &hostAddress);