221 void QNetworkConfigurationManagerPrivate::updateConfigurationsL() |
221 void QNetworkConfigurationManagerPrivate::updateConfigurationsL() |
222 { |
222 { |
223 QList<QString> knownConfigs = accessPointConfigurations.keys(); |
223 QList<QString> knownConfigs = accessPointConfigurations.keys(); |
224 QList<QString> knownSnapConfigs = snapConfigurations.keys(); |
224 QList<QString> knownSnapConfigs = snapConfigurations.keys(); |
225 |
225 |
226 #ifdef SNAP_FUNCTIONALITY_AVAILABLE |
226 #ifdef SNAP_FUNCTIONALITY_AVAILABLE |
227 // S60 version is >= Series60 3rd Edition Feature Pack 2 |
227 // S60 version is >= Series60 3rd Edition Feature Pack 2 |
228 TInt error = KErrNone; |
228 TInt error = KErrNone; |
229 |
229 |
230 // Loop through all IAPs |
230 // Loop through all IAPs |
231 RArray<TUint32> connectionMethods; // IAPs |
231 RArray<TUint32> connectionMethods; // IAPs |
249 item.d = ptr; |
249 item.d = ptr; |
250 // Emit configuration added. Connected slots may throw execptions |
250 // Emit configuration added. Connected slots may throw execptions |
251 // which propagate here --> must be converted to leaves (standard |
251 // which propagate here --> must be converted to leaves (standard |
252 // std::exception would cause any TRAP trapping this function to terminate |
252 // std::exception would cause any TRAP trapping this function to terminate |
253 // program). |
253 // program). |
|
254 QT_TRYCATCH_LEAVING(updateActiveAccessPoints()); |
|
255 updateStatesToSnaps(); |
254 QT_TRYCATCH_LEAVING(emit configurationAdded(item)); |
256 QT_TRYCATCH_LEAVING(emit configurationAdded(item)); |
255 } |
257 } |
256 } |
258 } |
257 } |
259 } |
258 CleanupStack::PopAndDestroy(&connectionMethod); |
260 CleanupStack::PopAndDestroy(&connectionMethod); |
263 RArray<TUint32> destinations; |
265 RArray<TUint32> destinations; |
264 CleanupClosePushL(destinations); |
266 CleanupClosePushL(destinations); |
265 iCmManager.AllDestinationsL(destinations); |
267 iCmManager.AllDestinationsL(destinations); |
266 for(int i = 0; i < destinations.Count(); i++) { |
268 for(int i = 0; i < destinations.Count(); i++) { |
267 RCmDestination destination; |
269 RCmDestination destination; |
268 destination = iCmManager.DestinationL(destinations[i]); |
270 |
|
271 // Some destinatsions require ReadDeviceData -capability (MMS/WAP) |
|
272 // The below function will leave in these cases. Don't. Proceed to |
|
273 // next destination (if any). |
|
274 TRAPD(error, destination = iCmManager.DestinationL(destinations[i])); |
|
275 if (error == KErrPermissionDenied) { |
|
276 continue; |
|
277 } else { |
|
278 User::LeaveIfError(error); |
|
279 } |
|
280 |
269 CleanupClosePushL(destination); |
281 CleanupClosePushL(destination); |
270 QString ident = QT_BEARERMGMT_CONFIGURATION_SNAP_PREFIX+QString::number(qHash(destination.Id())); |
282 QString ident = QT_BEARERMGMT_CONFIGURATION_SNAP_PREFIX+QString::number(qHash(destination.Id())); |
271 if (snapConfigurations.contains(ident)) { |
283 if (snapConfigurations.contains(ident)) { |
272 knownSnapConfigs.removeOne(ident); |
284 knownSnapConfigs.removeOne(ident); |
273 } else { |
285 } else { |
274 QNetworkConfigurationPrivate* cpPriv = new QNetworkConfigurationPrivate(); |
286 QNetworkConfigurationPrivate* cpPriv = new QNetworkConfigurationPrivate(); |
275 |
|
276 HBufC *pName = destination.NameLC(); |
287 HBufC *pName = destination.NameLC(); |
277 QT_TRYCATCH_LEAVING(cpPriv->name = QString::fromUtf16(pName->Ptr(),pName->Length())); |
288 QT_TRYCATCH_LEAVING(cpPriv->name = QString::fromUtf16(pName->Ptr(),pName->Length())); |
278 CleanupStack::PopAndDestroy(pName); |
289 CleanupStack::PopAndDestroy(pName); |
279 pName = NULL; |
290 pName = NULL; |
280 |
|
281 cpPriv->isValid = true; |
291 cpPriv->isValid = true; |
282 cpPriv->id = ident; |
292 cpPriv->id = ident; |
283 cpPriv->numericId = destination.Id(); |
293 cpPriv->numericId = destination.Id(); |
284 cpPriv->connectionId = 0; |
294 cpPriv->connectionId = 0; |
285 cpPriv->state = QNetworkConfiguration::Defined; |
295 cpPriv->state = QNetworkConfiguration::Defined; |
291 QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> ptr(cpPriv); |
301 QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> ptr(cpPriv); |
292 snapConfigurations.insert(ident, ptr); |
302 snapConfigurations.insert(ident, ptr); |
293 if (!iFirstUpdate) { |
303 if (!iFirstUpdate) { |
294 QNetworkConfiguration item; |
304 QNetworkConfiguration item; |
295 item.d = ptr; |
305 item.d = ptr; |
|
306 QT_TRYCATCH_LEAVING(updateActiveAccessPoints()); |
|
307 updateStatesToSnaps(); |
296 QT_TRYCATCH_LEAVING(emit configurationAdded(item)); |
308 QT_TRYCATCH_LEAVING(emit configurationAdded(item)); |
297 } |
309 } |
298 } |
310 } |
299 QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> privSNAP = snapConfigurations.value(ident); |
311 QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> privSNAP = snapConfigurations.value(ident); |
300 |
312 |
311 TRAP(error, cpPriv = configFromConnectionMethodL(connectionMethod)); |
323 TRAP(error, cpPriv = configFromConnectionMethodL(connectionMethod)); |
312 if (error == KErrNone) { |
324 if (error == KErrNone) { |
313 QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> ptr(cpPriv); |
325 QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> ptr(cpPriv); |
314 ptr.data()->serviceNetworkPtr = privSNAP; |
326 ptr.data()->serviceNetworkPtr = privSNAP; |
315 accessPointConfigurations.insert(cpPriv->id, ptr); |
327 accessPointConfigurations.insert(cpPriv->id, ptr); |
|
328 privSNAP->serviceNetworkMembers.append(ptr); |
316 if (!iFirstUpdate) { |
329 if (!iFirstUpdate) { |
317 QNetworkConfiguration item; |
330 QNetworkConfiguration item; |
318 item.d = ptr; |
331 item.d = ptr; |
|
332 QT_TRYCATCH_LEAVING(updateActiveAccessPoints()); |
|
333 updateStatesToSnaps(); |
319 QT_TRYCATCH_LEAVING(emit configurationAdded(item)); |
334 QT_TRYCATCH_LEAVING(emit configurationAdded(item)); |
320 } |
335 } |
321 privSNAP->serviceNetworkMembers.append(ptr); |
|
322 } |
336 } |
323 } else { |
337 } else { |
324 knownConfigs.removeOne(iface); |
338 knownConfigs.removeOne(iface); |
325 // Check that IAP can be found from related SNAP's configuration list |
339 // Check that IAP can be found from related SNAP's configuration list |
326 bool iapFound = false; |
340 bool iapFound = false; |
333 if (!iapFound) { |
347 if (!iapFound) { |
334 priv.data()->serviceNetworkPtr = privSNAP; |
348 priv.data()->serviceNetworkPtr = privSNAP; |
335 privSNAP->serviceNetworkMembers.append(priv); |
349 privSNAP->serviceNetworkMembers.append(priv); |
336 } |
350 } |
337 } |
351 } |
338 |
|
339 CleanupStack::PopAndDestroy(&connectionMethod); |
352 CleanupStack::PopAndDestroy(&connectionMethod); |
340 } |
353 } |
341 |
|
342 if (privSNAP->serviceNetworkMembers.count() > 1) { |
354 if (privSNAP->serviceNetworkMembers.count() > 1) { |
343 // Roaming is supported only if SNAP contains more than one IAP |
355 // Roaming is supported only if SNAP contains more than one IAP |
344 privSNAP->roamingSupported = true; |
356 privSNAP->roamingSupported = true; |
345 } |
357 } |
346 |
|
347 CleanupStack::PopAndDestroy(&destination); |
358 CleanupStack::PopAndDestroy(&destination); |
348 } |
359 } |
349 CleanupStack::PopAndDestroy(&destinations); |
360 CleanupStack::PopAndDestroy(&destinations); |
350 |
361 |
351 #else |
362 #else |
352 // S60 version is < Series60 3rd Edition Feature Pack 2 |
363 // S60 version is < Series60 3rd Edition Feature Pack 2 |
353 CCommsDbTableView* pDbTView = ipCommsDB->OpenTableLC(TPtrC(IAP)); |
364 CCommsDbTableView* pDbTView = ipCommsDB->OpenTableLC(TPtrC(IAP)); |
354 |
365 |
355 // Loop through all IAPs |
366 // Loop through all IAPs |
366 QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> ptr(cpPriv); |
377 QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> ptr(cpPriv); |
367 accessPointConfigurations.insert(ident, ptr); |
378 accessPointConfigurations.insert(ident, ptr); |
368 if (!iFirstUpdate) { |
379 if (!iFirstUpdate) { |
369 QNetworkConfiguration item; |
380 QNetworkConfiguration item; |
370 item.d = ptr; |
381 item.d = ptr; |
|
382 QT_TRYCATCH_LEAVING(updateActiveAccessPoints()); |
|
383 updateStatesToSnaps(); |
371 QT_TRYCATCH_LEAVING(emit configurationAdded(item)); |
384 QT_TRYCATCH_LEAVING(emit configurationAdded(item)); |
372 } |
385 } |
373 } else { |
386 } else { |
374 delete cpPriv; |
387 delete cpPriv; |
375 } |
388 } |
376 } |
389 } |
377 retVal = pDbTView->GotoNextRecord(); |
390 retVal = pDbTView->GotoNextRecord(); |
378 } |
391 } |
379 CleanupStack::PopAndDestroy(pDbTView); |
392 CleanupStack::PopAndDestroy(pDbTView); |
380 #endif |
393 #endif |
|
394 |
381 QT_TRYCATCH_LEAVING(updateActiveAccessPoints()); |
395 QT_TRYCATCH_LEAVING(updateActiveAccessPoints()); |
382 |
396 |
383 foreach (const QString &oldIface, knownConfigs) { |
397 foreach (const QString &oldIface, knownConfigs) { |
384 //remove non existing IAP |
398 //remove non existing IAP |
385 QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> priv = accessPointConfigurations.take(oldIface); |
399 QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> priv = accessPointConfigurations.take(oldIface); |
386 priv->isValid = false; |
400 priv->isValid = false; |
387 if (!iFirstUpdate) { |
401 if (!iFirstUpdate) { |
409 QNetworkConfiguration item; |
423 QNetworkConfiguration item; |
410 item.d = priv; |
424 item.d = priv; |
411 QT_TRYCATCH_LEAVING(emit configurationRemoved(item)); |
425 QT_TRYCATCH_LEAVING(emit configurationRemoved(item)); |
412 } |
426 } |
413 } |
427 } |
|
428 #ifdef SNAP_FUNCTIONALITY_AVAILABLE |
|
429 updateStatesToSnaps(); |
|
430 #endif |
414 } |
431 } |
415 |
432 |
416 #ifdef SNAP_FUNCTIONALITY_AVAILABLE |
433 #ifdef SNAP_FUNCTIONALITY_AVAILABLE |
417 QNetworkConfigurationPrivate* QNetworkConfigurationManagerPrivate::configFromConnectionMethodL( |
434 QNetworkConfigurationPrivate* QNetworkConfigurationManagerPrivate::configFromConnectionMethodL( |
418 RCmConnectionMethod& connectionMethod) |
435 RCmConnectionMethod& connectionMethod) |
635 iConnectionMonitor.GetConnectionInfo(i, connectionId, subConnectionCount); |
651 iConnectionMonitor.GetConnectionInfo(i, connectionId, subConnectionCount); |
636 iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount, KIAPId, apId, status); |
652 iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount, KIAPId, apId, status); |
637 User::WaitForRequest(status); |
653 User::WaitForRequest(status); |
638 QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(apId)); |
654 QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(apId)); |
639 QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> priv = accessPointConfigurations.value(ident); |
655 QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> priv = accessPointConfigurations.value(ident); |
640 #ifdef OCC_FUNCTIONALITY_AVAILABLE |
656 #if defined(OCC_FUNCTIONALITY_AVAILABLE) && defined(SNAP_FUNCTIONALITY_AVAILABLE) |
641 if (!priv.data()) { |
657 if (!priv.data()) { |
642 // If IAP was not found, check if the update was about EasyWLAN |
658 // If IAP was not found, check if the update was about EasyWLAN |
643 priv = configurationFromEasyWlan(apId, connectionId); |
659 priv = configurationFromEasyWlan(apId, connectionId); |
|
660 // Change the ident correspondingly |
|
661 if (priv.data()) { |
|
662 ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(priv.data()->numericId)); |
|
663 } |
644 } |
664 } |
645 #endif |
665 #endif |
646 if (priv.data()) { |
666 if (priv.data()) { |
647 iConnectionMonitor.GetIntAttribute(connectionId, subConnectionCount, KConnectionStatus, connectionStatus, status); |
667 iConnectionMonitor.GetIntAttribute(connectionId, subConnectionCount, KConnectionStatus, connectionStatus, status); |
648 User::WaitForRequest(status); |
668 User::WaitForRequest(status); |
|
669 |
649 if (connectionStatus == KLinkLayerOpen) { |
670 if (connectionStatus == KLinkLayerOpen) { |
650 online = true; |
671 online = true; |
651 inactiveConfigs.removeOne(ident); |
672 inactiveConfigs.removeOne(ident); |
652 priv.data()->connectionId = connectionId; |
673 priv.data()->connectionId = connectionId; |
653 // Configuration is Active |
674 // Configuration is Active |
933 iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount, KIAPId, apId, status); |
954 iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount, KIAPId, apId, status); |
934 User::WaitForRequest(status); |
955 User::WaitForRequest(status); |
935 |
956 |
936 QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(apId)); |
957 QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(apId)); |
937 QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> priv = accessPointConfigurations.value(ident); |
958 QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> priv = accessPointConfigurations.value(ident); |
938 #ifdef OCC_FUNCTIONALITY_AVAILABLE |
959 #if defined(OCC_FUNCTIONALITY_AVAILABLE) && defined(SNAP_FUNCTIONALITY_AVAILABLE) |
939 if (!priv.data()) { |
960 if (!priv.data()) { |
940 // Check if status was regarding EasyWLAN |
961 // Check if status was regarding EasyWLAN |
941 priv = configurationFromEasyWlan(apId, connectionId); |
962 priv = configurationFromEasyWlan(apId, connectionId); |
942 } |
963 } |
943 #endif |
964 #endif |
944 if (priv.data()) { |
965 if (priv.data()) { |
945 priv.data()->connectionId = connectionId; |
966 priv.data()->connectionId = connectionId; |
946 QT_TRYCATCH_LEAVING(emit this->configurationStateChanged(priv.data()->numericId, connectionId, QNetworkSession::Connecting)); |
967 QT_TRYCATCH_LEAVING(emit this->configurationStateChanged(priv.data()->numericId, connectionId, QNetworkSession::Connecting)); |
947 } |
968 } |
948 } else if (connectionStatus == KLinkLayerOpen) { |
969 } else if (connectionStatus == KLinkLayerOpen) { |
949 // Connection has been successfully opened |
970 // Connection has been successfully opened |
950 TUint connectionId = realEvent->ConnectionId(); |
971 TUint connectionId = realEvent->ConnectionId(); |
953 TRequestStatus status; |
974 TRequestStatus status; |
954 iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount, KIAPId, apId, status); |
975 iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount, KIAPId, apId, status); |
955 User::WaitForRequest(status); |
976 User::WaitForRequest(status); |
956 QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(apId)); |
977 QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(apId)); |
957 QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> priv = accessPointConfigurations.value(ident); |
978 QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> priv = accessPointConfigurations.value(ident); |
958 #ifdef OCC_FUNCTIONALITY_AVAILABLE |
979 #if defined(OCC_FUNCTIONALITY_AVAILABLE) && defined(SNAP_FUNCTIONALITY_AVAILABLE) |
959 if (!priv.data()) { |
980 if (!priv.data()) { |
960 // Check for EasyWLAN |
981 // Check for EasyWLAN |
961 priv = configurationFromEasyWlan(apId, connectionId); |
982 priv = configurationFromEasyWlan(apId, connectionId); |
962 } |
983 } |
963 #endif |
984 #endif |
1049 TRequestStatus status; |
1072 TRequestStatus status; |
1050 iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount, KIAPId, apId, status); |
1073 iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount, KIAPId, apId, status); |
1051 User::WaitForRequest(status); |
1074 User::WaitForRequest(status); |
1052 QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(apId)); |
1075 QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(apId)); |
1053 QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> priv = accessPointConfigurations.value(ident); |
1076 QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> priv = accessPointConfigurations.value(ident); |
1054 #ifdef OCC_FUNCTIONALITY_AVAILABLE |
1077 #if defined(OCC_FUNCTIONALITY_AVAILABLE) && defined(SNAP_FUNCTIONALITY_AVAILABLE) |
1055 if (!priv.data()) { |
1078 if (!priv.data()) { |
1056 // If IAP was not found, check if the update was about EasyWLAN |
1079 // If IAP was not found, check if the update was about EasyWLAN |
1057 priv = configurationFromEasyWlan(apId, connectionId); |
1080 priv = configurationFromEasyWlan(apId, connectionId); |
1058 } |
1081 } |
1059 #endif |
1082 #endif |
1069 // For unrecognized events |
1092 // For unrecognized events |
1070 break; |
1093 break; |
1071 } |
1094 } |
1072 } |
1095 } |
1073 |
1096 |
1074 #ifdef OCC_FUNCTIONALITY_AVAILABLE |
1097 #if defined(OCC_FUNCTIONALITY_AVAILABLE) && defined(SNAP_FUNCTIONALITY_AVAILABLE) |
1075 // Tries to derive configuration from EasyWLAN. |
1098 // Tries to derive configuration from EasyWLAN. |
1076 // First checks if the interface brought up was EasyWLAN, then derives the real SSID, |
1099 // First checks if the interface brought up was EasyWLAN, then derives the real SSID, |
1077 // and looks up configuration based on that one. |
1100 // and looks up configuration based on that one. |
1078 QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> QNetworkConfigurationManagerPrivate::configurationFromEasyWlan(TUint32 apId, TUint connectionId) |
1101 QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> QNetworkConfigurationManagerPrivate::configurationFromEasyWlan(TUint32 apId, TUint connectionId) |
1079 { |
1102 { |
1102 } |
1125 } |
1103 } |
1126 } |
1104 } |
1127 } |
1105 return QExplicitlySharedDataPointer<QNetworkConfigurationPrivate>(); |
1128 return QExplicitlySharedDataPointer<QNetworkConfigurationPrivate>(); |
1106 } |
1129 } |
|
1130 |
|
1131 bool QNetworkConfigurationManagerPrivate::easyWlanTrueIapId(TUint32& trueIapId) |
|
1132 { |
|
1133 // Check if this is easy wlan id in the first place |
|
1134 if (trueIapId != iCmManager.EasyWlanIdL()) { |
|
1135 return false; |
|
1136 } |
|
1137 // Loop through all connections that connection monitor is aware |
|
1138 // and check for IAPs based on easy WLAN |
|
1139 TRequestStatus status; |
|
1140 TUint connectionCount; |
|
1141 iConnectionMonitor.GetConnectionCount(connectionCount, status); |
|
1142 User::WaitForRequest(status); |
|
1143 TUint connectionId; |
|
1144 TUint subConnectionCount; |
|
1145 TUint apId; |
|
1146 if (status.Int() == KErrNone) { |
|
1147 for (TUint i = 1; i <= connectionCount; i++) { |
|
1148 iConnectionMonitor.GetConnectionInfo(i, connectionId, subConnectionCount); |
|
1149 iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount, KIAPId, apId, status); |
|
1150 User::WaitForRequest(status); |
|
1151 if (apId == trueIapId) { |
|
1152 QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> priv = |
|
1153 configurationFromEasyWlan(apId, connectionId); |
|
1154 if (priv.data()) { |
|
1155 #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG |
|
1156 qDebug() << "QNCM easyWlanTrueIapId(), found true IAP ID: " << priv.data()->numericId; |
|
1157 #endif |
|
1158 trueIapId = priv.data()->numericId; |
|
1159 return true; |
|
1160 } |
|
1161 } |
|
1162 } |
|
1163 } |
|
1164 return false; |
|
1165 } |
|
1166 |
1107 #endif |
1167 #endif |
1108 |
1168 |
1109 // Sessions may use this function to report configuration state changes, |
1169 // Sessions may use this function to report configuration state changes, |
1110 // because on some Symbian platforms (especially Symbian^3) all state changes are not |
1170 // because on some Symbian platforms (especially Symbian^3) all state changes are not |
1111 // reported by the RConnectionMonitor, in particular in relation to stop() call, |
1171 // reported by the RConnectionMonitor, in particular in relation to stop() call, |