summaryrefslogtreecommitdiffstats
path: root/src/plugins/bearer/qnetworksession_impl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/bearer/qnetworksession_impl.cpp')
-rw-r--r--src/plugins/bearer/qnetworksession_impl.cpp56
1 files changed, 44 insertions, 12 deletions
diff --git a/src/plugins/bearer/qnetworksession_impl.cpp b/src/plugins/bearer/qnetworksession_impl.cpp
index 11585ef..db1759c 100644
--- a/src/plugins/bearer/qnetworksession_impl.cpp
+++ b/src/plugins/bearer/qnetworksession_impl.cpp
@@ -100,9 +100,6 @@ void QNetworkSessionManagerPrivate::forceSessionClose(const QNetworkConfiguratio
void QNetworkSessionPrivateImpl::syncStateWithInterface()
{
- connect(&manager, SIGNAL(updateCompleted()), this, SLOT(networkConfigurationsChanged()));
- connect(&manager, SIGNAL(configurationChanged(QNetworkConfiguration)),
- this, SLOT(configurationChanged(QNetworkConfiguration)));
connect(sessionManager(), SIGNAL(forcedSessionClose(QNetworkConfiguration)),
this, SLOT(forcedSessionClose(QNetworkConfiguration)));
@@ -119,6 +116,10 @@ void QNetworkSessionPrivateImpl::syncStateWithInterface()
activeConfig = publicConfig;
engine = getEngineFromId(activeConfig.identifier());
if (engine) {
+ qRegisterMetaType<QNetworkConfigurationPrivatePointer>("QNetworkConfigurationPrivatePointer");
+ connect(engine, SIGNAL(configurationChanged(QNetworkConfigurationPrivatePointer)),
+ this, SLOT(configurationChanged(QNetworkConfigurationPrivatePointer)),
+ Qt::QueuedConnection);
connect(engine, SIGNAL(connectionError(QString,QBearerEngineImpl::ConnectionError)),
this, SLOT(connectionError(QString,QBearerEngineImpl::ConnectionError)),
Qt::QueuedConnection);
@@ -203,22 +204,18 @@ void QNetworkSessionPrivateImpl::stop()
void QNetworkSessionPrivateImpl::migrate()
{
- qWarning("This platform does not support roaming (%s).", Q_FUNC_INFO);
}
void QNetworkSessionPrivateImpl::accept()
{
- qWarning("This platform does not support roaming (%s).", Q_FUNC_INFO);
}
void QNetworkSessionPrivateImpl::ignore()
{
- qWarning("This platform does not support roaming (%s).", Q_FUNC_INFO);
}
void QNetworkSessionPrivateImpl::reject()
{
- qWarning("This platform does not support roaming (%s).", Q_FUNC_INFO);
}
QNetworkInterface QNetworkSessionPrivateImpl::currentInterface() const
@@ -233,13 +230,37 @@ QNetworkInterface QNetworkSessionPrivateImpl::currentInterface() const
return QNetworkInterface::interfaceFromName(interface);
}
-QVariant QNetworkSessionPrivateImpl::sessionProperty(const QString& /*key*/) const
+QVariant QNetworkSessionPrivateImpl::sessionProperty(const QString &key) const
{
+ if (key == QLatin1String("AutoCloseSessionTimeout")) {
+ if (engine && engine->requiresPolling() &&
+ !(engine->capabilities() & QNetworkConfigurationManager::CanStartAndStopInterfaces)) {
+ if (sessionTimeout >= 0)
+ return sessionTimeout * 10000;
+ else
+ return -1;
+ }
+ }
+
return QVariant();
}
-void QNetworkSessionPrivateImpl::setSessionProperty(const QString& /*key*/, const QVariant& /*value*/)
+void QNetworkSessionPrivateImpl::setSessionProperty(const QString &key, const QVariant &value)
{
+ if (key == QLatin1String("AutoCloseSessionTimeout")) {
+ if (engine && engine->requiresPolling() &&
+ !(engine->capabilities() & QNetworkConfigurationManager::CanStartAndStopInterfaces)) {
+ int timeout = value.toInt();
+ if (timeout >= 0) {
+ connect(engine, SIGNAL(updateCompleted()),
+ this, SLOT(decrementTimeout()), Qt::UniqueConnection);
+ sessionTimeout = timeout / 10000; // convert to poll intervals
+ } else {
+ disconnect(engine, SIGNAL(updateCompleted()), this, SLOT(decrementTimeout()));
+ sessionTimeout = -1;
+ }
+ }
+ }
}
QString QNetworkSessionPrivateImpl::errorString() const
@@ -364,12 +385,14 @@ void QNetworkSessionPrivateImpl::networkConfigurationsChanged()
startTime = engine->startTime(activeConfig.identifier());
}
-void QNetworkSessionPrivateImpl::configurationChanged(const QNetworkConfiguration &config)
+void QNetworkSessionPrivateImpl::configurationChanged(QNetworkConfigurationPrivatePointer config)
{
- if (serviceConfig.isValid() && (config == serviceConfig || config == activeConfig))
+ if (serviceConfig.isValid() &&
+ (config->id == serviceConfig.identifier() || config->id == activeConfig.identifier())) {
updateStateFromServiceNetwork();
- else if (config == activeConfig)
+ } else if (config->id == activeConfig.identifier()) {
updateStateFromActiveConfig();
+ }
}
void QNetworkSessionPrivateImpl::forcedSessionClose(const QNetworkConfiguration &config)
@@ -406,4 +429,13 @@ void QNetworkSessionPrivateImpl::connectionError(const QString &id,
}
}
+void QNetworkSessionPrivateImpl::decrementTimeout()
+{
+ if (--sessionTimeout <= 0) {
+ disconnect(engine, SIGNAL(updateCompleted()), this, SLOT(decrementTimeout()));
+ sessionTimeout = -1;
+ close();
+ }
+}
+
QT_END_NAMESPACE