diff options
author | Ken Moore <ken@ixsystems.com> | 2018-02-02 12:37:44 -0500 |
---|---|---|
committer | Ken Moore <ken@ixsystems.com> | 2018-02-02 12:37:44 -0500 |
commit | ff7bbe1daeaeb3cb15e463065e64417ed04ef376 (patch) | |
tree | 37bb9dfffb84d580a989e6b0404f2d7883747653 /src-qt5/src-cpp | |
parent | Fix up the battery status text. (diff) | |
download | lumina-ff7bbe1daeaeb3cb15e463065e64417ed04ef376.tar.gz lumina-ff7bbe1daeaeb3cb15e463065e64417ed04ef376.tar.bz2 lumina-ff7bbe1daeaeb3cb15e463065e64417ed04ef376.zip |
Try to adjust/fix the network device detection routine for status reporting.
Diffstat (limited to 'src-qt5/src-cpp')
-rw-r--r-- | src-qt5/src-cpp/framework-OSInterface_private.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src-qt5/src-cpp/framework-OSInterface_private.cpp b/src-qt5/src-cpp/framework-OSInterface_private.cpp index e6d082cc..99b3125f 100644 --- a/src-qt5/src-cpp/framework-OSInterface_private.cpp +++ b/src-qt5/src-cpp/framework-OSInterface_private.cpp @@ -296,7 +296,20 @@ void OSInterface::syncNetworkInfo(OSInterface *os, QHash<QString, QVariant> *has //qDebug() << "[DEBUG] Got Net Access Changed"; hash->insert("netaccess/available", netman->networkAccessible()== QNetworkAccessManager::Accessible); //Update all the other network status info at the same time - QNetworkConfiguration active = netman->activeConfiguration(); + QNetworkConfiguration active; + QList<QNetworkConfiguration> netconfigL = netman->configuration().children(); + for(int i=0; i<netconfigL.length(); i++){ + if(!netconfigL[i].state().testFlag(QNetworkConfiguration::Discovered) ){ continue; } //skip this interface + QList<QNetworkAddressEntry> addressList = QNetworkInterface::interfaceFromName(netconfigL[i].name()).addressEntries(); + //NOTE: There are often 2 addresses, IPv4 and IPv6 + bool ok = false; + for(int j=0; j<addressList.length() && !ok; j++){ + if( addressList[j].ip().isLoopback() ){ continue; } + addressList[j].ip().toIPv4Address(&ok); + } + if(ok){ active = netconfigL[i]; break; } + } + if(!active.isValid()){ active = netman->activeConfiguration(); } //use the default Qt-detected interface //Type of connection QString type; switch(active.bearerTypeFamily()){ |