make qtbearer networkmanager defaultConfiguration more reliable

The defaultConfiguration could switch and be either active connection,
so we determine the default should be what has the default route.

Change-Id: I194f27b60e7a3598eca2ff09c2225ba1a46564d9
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
This commit is contained in:
Lorn Potter 2014-11-07 15:38:32 +10:00
parent a61247723a
commit 7a593e0d00
3 changed files with 17 additions and 0 deletions

View File

@ -953,6 +953,15 @@ QNetworkSessionPrivate *QNetworkManagerEngine::createSessionBackend()
QNetworkConfigurationPrivatePointer QNetworkManagerEngine::defaultConfiguration()
{
QHashIterator<QString, QNetworkManagerConnectionActive*> i(activeConnectionsList);
while (i.hasNext()) {
i.next();
QNetworkManagerConnectionActive *activeConnection = i.value();
if ((activeConnection->defaultRoute() || activeConnection->default6Route())) {
return accessPointConfigurations.value(activeConnection->connection().path());
}
}
return QNetworkConfigurationPrivatePointer();
}

View File

@ -1282,6 +1282,13 @@ bool QNetworkManagerConnectionActive::defaultRoute() const
return false;
}
bool QNetworkManagerConnectionActive::default6Route() const
{
if (propertyMap.contains("Default6"))
return propertyMap.value("Default6").toBool();
return false;
}
void QNetworkManagerConnectionActive::propertiesSwap(QMap<QString,QVariant> map)
{
QMapIterator<QString, QVariant> i(map);

View File

@ -499,6 +499,7 @@ public:
QStringList devices() const;
quint32 state() const;
bool defaultRoute() const;
bool default6Route() const;
bool setConnections();
bool isValid();