61 |
61 |
62 QNetworkConfigurationManagerPrivate::QNetworkConfigurationManagerPrivate() |
62 QNetworkConfigurationManagerPrivate::QNetworkConfigurationManagerPrivate() |
63 : pollTimer(0), mutex(QMutex::Recursive), forcedPolling(0), firstUpdate(true) |
63 : pollTimer(0), mutex(QMutex::Recursive), forcedPolling(0), firstUpdate(true) |
64 { |
64 { |
65 qRegisterMetaType<QNetworkConfiguration>("QNetworkConfiguration"); |
65 qRegisterMetaType<QNetworkConfiguration>("QNetworkConfiguration"); |
66 |
66 qRegisterMetaType<QNetworkConfigurationPrivatePointer>("QNetworkConfigurationPrivatePointer"); |
67 moveToThread(QCoreApplicationPrivate::mainThread()); |
|
68 updateConfigurations(); |
|
69 } |
67 } |
70 |
68 |
71 QNetworkConfigurationManagerPrivate::~QNetworkConfigurationManagerPrivate() |
69 QNetworkConfigurationManagerPrivate::~QNetworkConfigurationManagerPrivate() |
72 { |
70 { |
73 QMutexLocker locker(&mutex); |
71 QMutexLocker locker(&mutex); |
148 |
146 |
149 for (it = engine->accessPointConfigurations.begin(), |
147 for (it = engine->accessPointConfigurations.begin(), |
150 end = engine->accessPointConfigurations.end(); it != end; ++it) { |
148 end = engine->accessPointConfigurations.end(); it != end; ++it) { |
151 QNetworkConfigurationPrivatePointer ptr = it.value(); |
149 QNetworkConfigurationPrivatePointer ptr = it.value(); |
152 |
150 |
153 const QString bearerName = ptr->bearerName(); |
|
154 QMutexLocker configLocker(&ptr->mutex); |
151 QMutexLocker configLocker(&ptr->mutex); |
|
152 QNetworkConfiguration::BearerType bearerType = ptr->bearerType; |
155 |
153 |
156 if ((ptr->state & QNetworkConfiguration::Discovered) == |
154 if ((ptr->state & QNetworkConfiguration::Discovered) == |
157 QNetworkConfiguration::Discovered) { |
155 QNetworkConfiguration::Discovered) { |
158 if (!defaultConfiguration) { |
156 if (!defaultConfiguration) { |
159 defaultConfiguration = ptr; |
157 defaultConfiguration = ptr; |
160 } else { |
158 } else { |
|
159 QMutexLocker defaultConfigLocker(&defaultConfiguration->mutex); |
|
160 |
161 if (defaultConfiguration->state == ptr->state) { |
161 if (defaultConfiguration->state == ptr->state) { |
162 if (defaultConfiguration->bearerName() == QLatin1String("Ethernet")) { |
162 switch (defaultConfiguration->bearerType) { |
|
163 case QNetworkConfiguration::BearerEthernet: |
163 // do nothing |
164 // do nothing |
164 } else if (defaultConfiguration->bearerName() == QLatin1String("WLAN")) { |
165 break; |
165 // ethernet beats wlan |
166 case QNetworkConfiguration::BearerWLAN: |
166 if (bearerName == QLatin1String("Ethernet")) |
167 // Ethernet beats WLAN |
167 defaultConfiguration = ptr; |
168 defaultConfiguration = ptr; |
168 } else { |
169 break; |
169 // ethernet and wlan beats other |
170 default: |
170 if (bearerName == QLatin1String("Ethernet") || |
171 // Ethernet and WLAN beats other |
171 bearerName == QLatin1String("WLAN")) { |
172 if (bearerType == QNetworkConfiguration::BearerEthernet || |
|
173 bearerType == QNetworkConfiguration::BearerWLAN) { |
172 defaultConfiguration = ptr; |
174 defaultConfiguration = ptr; |
173 } |
175 } |
174 } |
176 } |
175 } else { |
177 } else { |
176 // active beats discovered |
178 // active beats discovered |