summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorTomasz Bursztyka <tomasz.bursztyka@nokia.com>2010-07-29 12:22:33 (GMT)
committerAaron McCarthy <aaron.mccarthy@nokia.com>2010-08-16 05:09:20 (GMT)
commitb8505789fdf977fcdec91f94557fe13bcef1e7cc (patch)
treec49e5ba8faddca428006f6432d07e5d97f226ef6 /src/plugins
parentd4c8461db653e498b9369c2a36de5b699bcbf87d (diff)
downloadQt-b8505789fdf977fcdec91f94557fe13bcef1e7cc.zip
Qt-b8505789fdf977fcdec91f94557fe13bcef1e7cc.tar.gz
Qt-b8505789fdf977fcdec91f94557fe13bcef1e7cc.tar.bz2
The QNetworkConfigurationManager did not get the online status correctly even when there was an active connection.
Fixes: NB#181984 - QNetworkConfigurationManager reports offline even when connected. Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@nokia.com> Signed-off-by: Jukka Rissanen <jukka.rissanen@nokia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/bearer/icd/qicdengine.cpp97
-rw-r--r--src/plugins/bearer/icd/qicdengine.h2
2 files changed, 71 insertions, 28 deletions
diff --git a/src/plugins/bearer/icd/qicdengine.cpp b/src/plugins/bearer/icd/qicdengine.cpp
index 0900329..87b31da 100644
--- a/src/plugins/bearer/icd/qicdengine.cpp
+++ b/src/plugins/bearer/icd/qicdengine.cpp
@@ -275,6 +275,8 @@ void QIcdEngine::initialize()
userChoiceConfigurations.insert(cpPriv->id, ptr);
doRequestUpdate();
+
+ getIcdInitialState();
}
static inline QString network_attrs_to_security(uint network_attrs)
@@ -623,7 +625,11 @@ void QIcdEngine::doRequestUpdate(QList<Maemo::IcdScanResult> scanned)
changed = true;
}
- if (ptr->state != QNetworkConfiguration::Discovered) {
+ /* If this config is the current active one, we do not set it
+ * to discovered.
+ */
+ if ((ptr->state != QNetworkConfiguration::Discovered) &&
+ (ptr->state != QNetworkConfiguration::Active)) {
ptr->state = QNetworkConfiguration::Discovered;
changed = true;
}
@@ -786,10 +792,50 @@ void QIcdEngine::startListeningStateSignalsForAllConnections()
ICD_DBUS_API_INTERFACE,
ICD_DBUS_API_STATE_SIG,
this, SLOT(connectionStateSignalsSlot(QDBusMessage)));
+}
+
+void QIcdEngine::getIcdInitialState()
+{
+ /* Instead of requesting ICD status asynchronously, we ask it synchronously.
+ * It ensures that we always get right icd status BEFORE initialize() ends.
+ * If not, initialize() might end before we got icd status and
+ * QNetworkConfigurationManager::updateConfigurations()
+ * call from user might also end before receiving icd status.
+ * In such case, we come up to a bug:
+ * QNetworkConfigurationManagerPrivate::isOnline() will be false even
+ * if we are connected.
+ */
+ Maemo::Icd icd;
+ QList<Maemo::IcdStateResult> state_results;
+ QMutexLocker locker(&mutex);
+ QNetworkConfigurationPrivatePointer ptr;
+
+ if (icd.state(state_results) && !state_results.isEmpty()) {
+
+ if (!(state_results.first().params.network_attrs == 0 &&
+ state_results.first().params.network_id.isEmpty())) {
+
+ switch (state_results.first().state) {
+ case ICD_STATE_CONNECTED:
+ m_onlineIapId = state_results.first().params.network_id;
+
+ ptr = accessPointConfigurations.value(m_onlineIapId);
+ if (ptr) {
+ ptr->state = QNetworkConfiguration::Active;
+
+ QMutexLocker configLocker(&ptr->mutex);
+ configLocker.unlock();
- // Calling ICD_DBUS_API_STATE_REQ makes sure that initial state will be updated immediately
- m_gettingInitialConnectionState = true;
- m_dbusInterface->call(ICD_DBUS_API_STATE_REQ);
+ locker.unlock();
+ emit configurationChanged(ptr);
+ locker.relock();
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
}
void QIcdEngine::connectionStateSignalsSlot(QDBusMessage msg)
@@ -814,12 +860,12 @@ void QIcdEngine::connectionStateSignalsSlot(QDBusMessage msg)
ptr->type = QNetworkConfiguration::InternetAccessPoint;
if (ptr->state != QNetworkConfiguration::Active) {
ptr->state = QNetworkConfiguration::Active;
- if (!m_gettingInitialConnectionState) {
- configLocker.unlock();
- locker.unlock();
- emit configurationChanged(ptr);
- locker.relock();
- }
+
+ configLocker.unlock();
+ locker.unlock();
+ emit configurationChanged(ptr);
+ locker.relock();
+
m_onlineIapId = iapid;
}
} else {
@@ -840,22 +886,21 @@ void QIcdEngine::connectionStateSignalsSlot(QDBusMessage msg)
ptr->type = QNetworkConfiguration::InternetAccessPoint;
if (ptr->state == QNetworkConfiguration::Active) {
ptr->state = QNetworkConfiguration::Discovered;
- if (!m_gettingInitialConnectionState) {
- configLocker.unlock();
- locker.unlock();
- emit configurationChanged(ptr);
- locker.relock();
- // Note: If ICD switches used IAP from one to another:
- // 1) new IAP is reported to be online first
- // 2) old IAP is reported to be offline then
- // => Device can be reported to be offline only
- // if last known online IAP is reported to be disconnected
- if (iapid == m_onlineIapId) {
- // It's known that there is only one global ICD connection
- // => Because ICD state was reported to be DISCONNECTED, Device is offline
- m_onlineIapId.clear();
- }
+ configLocker.unlock();
+ locker.unlock();
+ emit configurationChanged(ptr);
+ locker.relock();
+
+ // Note: If ICD switches used IAP from one to another:
+ // 1) new IAP is reported to be online first
+ // 2) old IAP is reported to be offline then
+ // => Device can be reported to be offline only
+ // if last known online IAP is reported to be disconnected
+ if (iapid == m_onlineIapId) {
+ // It's known that there is only one global ICD connection
+ // => Because ICD state was reported to be DISCONNECTED, Device is offline
+ m_onlineIapId.clear();
}
}
} else {
@@ -876,8 +921,6 @@ void QIcdEngine::connectionStateSignalsSlot(QDBusMessage msg)
locker.unlock();
emit iapStateChanged(iapid, icd_connection_state);
locker.relock();
-
- m_gettingInitialConnectionState = false;
}
void QIcdEngine::requestUpdate()
diff --git a/src/plugins/bearer/icd/qicdengine.h b/src/plugins/bearer/icd/qicdengine.h
index a768d84..0d5ba27 100644
--- a/src/plugins/bearer/icd/qicdengine.h
+++ b/src/plugins/bearer/icd/qicdengine.h
@@ -152,6 +152,7 @@ private:
void startListeningStateSignalsForAllConnections();
void doRequestUpdate(QList<Maemo::IcdScanResult> scanned = QList<Maemo::IcdScanResult>());
void cancelAsyncConfigurationUpdate();
+ void getIcdInitialState();
private:
IapMonitor *iapMonitor;
@@ -162,7 +163,6 @@ private:
QList<Maemo::IcdScanResult> m_scanResult;
bool firstUpdate;
- bool m_gettingInitialConnectionState;
bool m_scanGoingOn;
};