63 #include <cmpluginpacketdatadef.h> |
63 #include <cmpluginpacketdatadef.h> |
64 #include <cmplugindialcommondefs.h> |
64 #include <cmplugindialcommondefs.h> |
65 #else |
65 #else |
66 #include <ApAccessPointItem.h> |
66 #include <ApAccessPointItem.h> |
67 #include <ApDataHandler.h> |
67 #include <ApDataHandler.h> |
68 #include <ApUtils.h> |
68 #include <ApUtils.h> |
69 #endif |
69 #endif |
70 |
70 |
71 #ifndef QT_NO_BEARERMANAGEMENT |
71 #ifndef QT_NO_BEARERMANAGEMENT |
72 |
72 |
73 QT_BEGIN_NAMESPACE |
73 QT_BEGIN_NAMESPACE |
74 |
74 |
75 static const int KUserChoiceIAPId = 0; |
75 static const int KUserChoiceIAPId = 0; |
76 |
76 |
77 SymbianNetworkConfigurationPrivate::SymbianNetworkConfigurationPrivate() |
77 SymbianNetworkConfigurationPrivate::SymbianNetworkConfigurationPrivate() |
78 : bearer(BearerUnknown), numericId(0), connectionId(0) |
78 : numericId(0), connectionId(0) |
79 { |
79 { |
80 } |
80 } |
81 |
81 |
82 SymbianNetworkConfigurationPrivate::~SymbianNetworkConfigurationPrivate() |
82 SymbianNetworkConfigurationPrivate::~SymbianNetworkConfigurationPrivate() |
83 { |
83 { |
84 } |
|
85 |
|
86 QString SymbianNetworkConfigurationPrivate::bearerName() const |
|
87 { |
|
88 QMutexLocker locker(&mutex); |
|
89 |
|
90 switch (bearer) { |
|
91 case BearerEthernet: |
|
92 return QLatin1String("Ethernet"); |
|
93 case BearerWLAN: |
|
94 return QLatin1String("WLAN"); |
|
95 case Bearer2G: |
|
96 return QLatin1String("2G"); |
|
97 case BearerCDMA2000: |
|
98 return QLatin1String("CDMA2000"); |
|
99 case BearerWCDMA: |
|
100 return QLatin1String("WCDMA"); |
|
101 case BearerHSPA: |
|
102 return QLatin1String("HSPA"); |
|
103 case BearerBluetooth: |
|
104 return QLatin1String("Bluetooth"); |
|
105 case BearerWiMAX: |
|
106 return QLatin1String("WiMAX"); |
|
107 default: |
|
108 return QString(); |
|
109 } |
|
110 } |
84 } |
111 |
85 |
112 SymbianEngine::SymbianEngine(QObject *parent) |
86 SymbianEngine::SymbianEngine(QObject *parent) |
113 : QBearerEngine(parent), CActive(CActive::EPriorityHigh), iFirstUpdate(true), iInitOk(true), |
87 : QBearerEngine(parent), CActive(CActive::EPriorityHigh), iFirstUpdate(true), iInitOk(true), |
114 iUpdatePending(false) |
88 iUpdatePending(false) |
144 } |
118 } |
145 #endif |
119 #endif |
146 |
120 |
147 SymbianNetworkConfigurationPrivate *cpPriv = new SymbianNetworkConfigurationPrivate; |
121 SymbianNetworkConfigurationPrivate *cpPriv = new SymbianNetworkConfigurationPrivate; |
148 cpPriv->name = "UserChoice"; |
122 cpPriv->name = "UserChoice"; |
149 cpPriv->bearer = SymbianNetworkConfigurationPrivate::BearerUnknown; |
123 cpPriv->bearerType = QNetworkConfiguration::BearerUnknown; |
150 cpPriv->state = QNetworkConfiguration::Discovered; |
124 cpPriv->state = QNetworkConfiguration::Discovered; |
151 cpPriv->isValid = true; |
125 cpPriv->isValid = true; |
152 cpPriv->id = QString::number(qHash(KUserChoiceIAPId)); |
126 cpPriv->id = QString::number(qHash(KUserChoiceIAPId)); |
153 cpPriv->numericId = KUserChoiceIAPId; |
127 cpPriv->numericId = KUserChoiceIAPId; |
154 cpPriv->connectionId = 0; |
128 cpPriv->connectionId = 0; |
268 void SymbianEngine::updateConfigurationsL() |
242 void SymbianEngine::updateConfigurationsL() |
269 { |
243 { |
270 QList<QString> knownConfigs = accessPointConfigurations.keys(); |
244 QList<QString> knownConfigs = accessPointConfigurations.keys(); |
271 QList<QString> knownSnapConfigs = snapConfigurations.keys(); |
245 QList<QString> knownSnapConfigs = snapConfigurations.keys(); |
272 |
246 |
273 #ifdef SNAP_FUNCTIONALITY_AVAILABLE |
247 #ifdef SNAP_FUNCTIONALITY_AVAILABLE |
274 // S60 version is >= Series60 3rd Edition Feature Pack 2 |
248 // S60 version is >= Series60 3rd Edition Feature Pack 2 |
275 TInt error = KErrNone; |
249 TInt error = KErrNone; |
276 |
250 |
277 // Loop through all IAPs |
251 // Loop through all IAPs |
278 RArray<TUint32> connectionMethods; // IAPs |
252 RArray<TUint32> connectionMethods; // IAPs |
289 SymbianNetworkConfigurationPrivate* cpPriv = NULL; |
263 SymbianNetworkConfigurationPrivate* cpPriv = NULL; |
290 TRAP(error, cpPriv = configFromConnectionMethodL(connectionMethod)); |
264 TRAP(error, cpPriv = configFromConnectionMethodL(connectionMethod)); |
291 if (error == KErrNone) { |
265 if (error == KErrNone) { |
292 QNetworkConfigurationPrivatePointer ptr(cpPriv); |
266 QNetworkConfigurationPrivatePointer ptr(cpPriv); |
293 accessPointConfigurations.insert(ptr->id, ptr); |
267 accessPointConfigurations.insert(ptr->id, ptr); |
294 |
268 if (!iFirstUpdate) { |
295 mutex.unlock(); |
269 // Emit configuration added. Connected slots may throw execptions |
296 // Emit configuration added. Connected slots may throw execptions |
270 // which propagate here --> must be converted to leaves (standard |
297 // which propagate here --> must be converted to leaves (standard |
271 // std::exception would cause any TRAP trapping this function to terminate |
298 // std::exception would cause any TRAP trapping this function to terminate |
272 // program). |
299 // program). |
273 QT_TRYCATCH_LEAVING(updateActiveAccessPoints()); |
300 QT_TRYCATCH_LEAVING(emit configurationAdded(ptr)); |
274 updateStatesToSnaps(); |
301 mutex.lock(); |
275 mutex.unlock(); |
|
276 QT_TRYCATCH_LEAVING(emit configurationAdded(ptr)); |
|
277 mutex.lock(); |
|
278 } |
302 } |
279 } |
303 } |
280 } |
304 CleanupStack::PopAndDestroy(&connectionMethod); |
281 CleanupStack::PopAndDestroy(&connectionMethod); |
305 } |
282 } |
306 CleanupStack::PopAndDestroy(&connectionMethods); |
283 CleanupStack::PopAndDestroy(&connectionMethods); |
309 RArray<TUint32> destinations; |
286 RArray<TUint32> destinations; |
310 CleanupClosePushL(destinations); |
287 CleanupClosePushL(destinations); |
311 iCmManager.AllDestinationsL(destinations); |
288 iCmManager.AllDestinationsL(destinations); |
312 for(int i = 0; i < destinations.Count(); i++) { |
289 for(int i = 0; i < destinations.Count(); i++) { |
313 RCmDestination destination; |
290 RCmDestination destination; |
314 destination = iCmManager.DestinationL(destinations[i]); |
291 |
|
292 // Some destinatsions require ReadDeviceData -capability (MMS/WAP) |
|
293 // The below function will leave in these cases. Don't. Proceed to |
|
294 // next destination (if any). |
|
295 TRAPD(error, destination = iCmManager.DestinationL(destinations[i])); |
|
296 if (error == KErrPermissionDenied) { |
|
297 continue; |
|
298 } else { |
|
299 User::LeaveIfError(error); |
|
300 } |
|
301 |
315 CleanupClosePushL(destination); |
302 CleanupClosePushL(destination); |
316 QString ident = QT_BEARERMGMT_CONFIGURATION_SNAP_PREFIX + |
303 QString ident = QT_BEARERMGMT_CONFIGURATION_SNAP_PREFIX + |
317 QString::number(qHash(destination.Id())); |
304 QString::number(qHash(destination.Id())); |
318 if (snapConfigurations.contains(ident)) { |
305 if (snapConfigurations.contains(ident)) { |
319 knownSnapConfigs.removeOne(ident); |
306 knownSnapConfigs.removeOne(ident); |
320 } else { |
307 } else { |
321 SymbianNetworkConfigurationPrivate *cpPriv = new SymbianNetworkConfigurationPrivate; |
308 SymbianNetworkConfigurationPrivate *cpPriv = new SymbianNetworkConfigurationPrivate; |
322 |
309 |
323 HBufC *pName = destination.NameLC(); |
310 HBufC *pName = destination.NameLC(); |
324 QT_TRYCATCH_LEAVING(cpPriv->name = QString::fromUtf16(pName->Ptr(),pName->Length())); |
311 QT_TRYCATCH_LEAVING(cpPriv->name = QString::fromUtf16(pName->Ptr(),pName->Length())); |
325 CleanupStack::PopAndDestroy(pName); |
312 CleanupStack::PopAndDestroy(pName); |
326 pName = NULL; |
313 pName = NULL; |
327 |
314 |
328 cpPriv->isValid = true; |
315 cpPriv->isValid = true; |
329 cpPriv->id = ident; |
316 cpPriv->id = ident; |
330 cpPriv->numericId = destination.Id(); |
317 cpPriv->numericId = destination.Id(); |
331 cpPriv->connectionId = 0; |
318 cpPriv->connectionId = 0; |
332 cpPriv->state = QNetworkConfiguration::Defined; |
319 cpPriv->state = QNetworkConfiguration::Defined; |
334 cpPriv->purpose = QNetworkConfiguration::UnknownPurpose; |
321 cpPriv->purpose = QNetworkConfiguration::UnknownPurpose; |
335 cpPriv->roamingSupported = false; |
322 cpPriv->roamingSupported = false; |
336 |
323 |
337 QNetworkConfigurationPrivatePointer ptr(cpPriv); |
324 QNetworkConfigurationPrivatePointer ptr(cpPriv); |
338 snapConfigurations.insert(ident, ptr); |
325 snapConfigurations.insert(ident, ptr); |
339 |
326 if (!iFirstUpdate) { |
340 mutex.unlock(); |
327 QT_TRYCATCH_LEAVING(updateActiveAccessPoints()); |
341 QT_TRYCATCH_LEAVING(emit configurationAdded(ptr)); |
328 updateStatesToSnaps(); |
342 mutex.lock(); |
329 mutex.unlock(); |
|
330 QT_TRYCATCH_LEAVING(emit configurationAdded(ptr)); |
|
331 mutex.lock(); |
|
332 } |
343 } |
333 } |
344 |
334 |
345 // Loop through all connection methods in this SNAP |
335 // Loop through all connection methods in this SNAP |
346 QMap<unsigned int, QNetworkConfigurationPrivatePointer> connections; |
336 QMap<unsigned int, QNetworkConfigurationPrivatePointer> connections; |
347 for (int j=0; j < destination.ConnectionMethodCount(); j++) { |
337 for (int j=0; j < destination.ConnectionMethodCount(); j++) { |
350 |
340 |
351 TUint32 iapId = connectionMethod.GetIntAttributeL(CMManager::ECmIapId); |
341 TUint32 iapId = connectionMethod.GetIntAttributeL(CMManager::ECmIapId); |
352 QString iface = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(iapId)); |
342 QString iface = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(iapId)); |
353 // Check that IAP can be found from accessPointConfigurations list |
343 // Check that IAP can be found from accessPointConfigurations list |
354 QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(iface); |
344 QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(iface); |
355 if (ptr) { |
345 if (!ptr) { |
356 knownConfigs.removeOne(iface); |
|
357 } else { |
|
358 SymbianNetworkConfigurationPrivate *cpPriv = NULL; |
346 SymbianNetworkConfigurationPrivate *cpPriv = NULL; |
359 TRAP(error, cpPriv = configFromConnectionMethodL(connectionMethod)); |
347 TRAP(error, cpPriv = configFromConnectionMethodL(connectionMethod)); |
360 if (error == KErrNone) { |
348 if (error == KErrNone) { |
361 ptr = QNetworkConfigurationPrivatePointer(cpPriv); |
349 ptr = QNetworkConfigurationPrivatePointer(cpPriv); |
362 accessPointConfigurations.insert(ptr->id, ptr); |
350 accessPointConfigurations.insert(ptr->id, ptr); |
363 |
351 |
364 mutex.unlock(); |
352 if (!iFirstUpdate) { |
365 QT_TRYCATCH_LEAVING(emit configurationAdded(ptr)); |
353 QT_TRYCATCH_LEAVING(updateActiveAccessPoints()); |
366 mutex.lock(); |
354 updateStatesToSnaps(); |
|
355 mutex.unlock(); |
|
356 QT_TRYCATCH_LEAVING(emit configurationAdded(ptr)); |
|
357 mutex.lock(); |
|
358 } |
367 } |
359 } |
|
360 } else { |
|
361 knownConfigs.removeOne(iface); |
368 } |
362 } |
369 |
363 |
370 if (ptr) { |
364 if (ptr) { |
371 unsigned int priority; |
365 unsigned int priority; |
372 TRAPD(error, priority = destination.PriorityL(connectionMethod)); |
366 TRAPD(error, priority = destination.PriorityL(connectionMethod)); |
385 |
379 |
386 // Roaming is supported only if SNAP contains more than one IAP |
380 // Roaming is supported only if SNAP contains more than one IAP |
387 privSNAP->roamingSupported = privSNAP->serviceNetworkMembers.count() > 1; |
381 privSNAP->roamingSupported = privSNAP->serviceNetworkMembers.count() > 1; |
388 |
382 |
389 snapConfigLocker.unlock(); |
383 snapConfigLocker.unlock(); |
|
384 |
|
385 updateStatesToSnaps(); |
|
386 |
390 mutex.unlock(); |
387 mutex.unlock(); |
391 QT_TRYCATCH_LEAVING(emit configurationChanged(privSNAP)); |
388 QT_TRYCATCH_LEAVING(emit configurationChanged(privSNAP)); |
392 mutex.lock(); |
389 mutex.lock(); |
393 } |
390 } |
394 |
391 |
395 CleanupStack::PopAndDestroy(&destination); |
392 CleanupStack::PopAndDestroy(&destination); |
396 } |
393 } |
397 CleanupStack::PopAndDestroy(&destinations); |
394 CleanupStack::PopAndDestroy(&destinations); |
398 |
|
399 #else |
395 #else |
400 // S60 version is < Series60 3rd Edition Feature Pack 2 |
396 // S60 version is < Series60 3rd Edition Feature Pack 2 |
401 CCommsDbTableView* pDbTView = ipCommsDB->OpenTableLC(TPtrC(IAP)); |
397 CCommsDbTableView* pDbTView = ipCommsDB->OpenTableLC(TPtrC(IAP)); |
402 |
398 |
403 // Loop through all IAPs |
399 // Loop through all IAPs |
411 } else { |
407 } else { |
412 SymbianNetworkConfigurationPrivate *cpPriv = new SymbianNetworkConfigurationPrivate; |
408 SymbianNetworkConfigurationPrivate *cpPriv = new SymbianNetworkConfigurationPrivate; |
413 if (readNetworkConfigurationValuesFromCommsDb(apId, cpPriv)) { |
409 if (readNetworkConfigurationValuesFromCommsDb(apId, cpPriv)) { |
414 QNetworkConfigurationPrivatePointer ptr(cpPriv); |
410 QNetworkConfigurationPrivatePointer ptr(cpPriv); |
415 accessPointConfigurations.insert(ident, ptr); |
411 accessPointConfigurations.insert(ident, ptr); |
416 |
412 if (!iFirstUpdate) { |
417 mutex.unlock(); |
413 QT_TRYCATCH_LEAVING(updateActiveAccessPoints()); |
418 QT_TRYCATCH_LEAVING(emit configurationAdded(ptr)); |
414 updateStatesToSnaps(); |
419 mutex.lock(); |
415 mutex.unlock(); |
|
416 QT_TRYCATCH_LEAVING(emit configurationAdded(ptr)); |
|
417 mutex.lock(); |
|
418 } |
420 } else { |
419 } else { |
421 delete cpPriv; |
420 delete cpPriv; |
422 } |
421 } |
423 } |
422 } |
424 retVal = pDbTView->GotoNextRecord(); |
423 retVal = pDbTView->GotoNextRecord(); |
425 } |
424 } |
426 CleanupStack::PopAndDestroy(pDbTView); |
425 CleanupStack::PopAndDestroy(pDbTView); |
427 #endif |
426 #endif |
|
427 |
428 QT_TRYCATCH_LEAVING(updateActiveAccessPoints()); |
428 QT_TRYCATCH_LEAVING(updateActiveAccessPoints()); |
429 |
429 |
430 foreach (const QString &oldIface, knownConfigs) { |
430 foreach (const QString &oldIface, knownConfigs) { |
431 //remove non existing IAP |
431 //remove non existing IAP |
432 QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.take(oldIface); |
432 QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.take(oldIface); |
433 |
433 |
434 mutex.unlock(); |
434 mutex.unlock(); |
466 |
466 |
467 // find default configuration. |
467 // find default configuration. |
468 stopCommsDatabaseNotifications(); |
468 stopCommsDatabaseNotifications(); |
469 TRAP_IGNORE(defaultConfig = defaultConfigurationL()); |
469 TRAP_IGNORE(defaultConfig = defaultConfigurationL()); |
470 startCommsDatabaseNotifications(); |
470 startCommsDatabaseNotifications(); |
|
471 |
|
472 #ifdef SNAP_FUNCTIONALITY_AVAILABLE |
|
473 updateStatesToSnaps(); |
|
474 #endif |
471 } |
475 } |
472 |
476 |
473 #ifdef SNAP_FUNCTIONALITY_AVAILABLE |
477 #ifdef SNAP_FUNCTIONALITY_AVAILABLE |
474 SymbianNetworkConfigurationPrivate *SymbianEngine::configFromConnectionMethodL( |
478 SymbianNetworkConfigurationPrivate *SymbianEngine::configFromConnectionMethodL( |
475 RCmConnectionMethod& connectionMethod) |
479 RCmConnectionMethod& connectionMethod) |
485 pName = NULL; |
489 pName = NULL; |
486 |
490 |
487 TUint32 bearerId = connectionMethod.GetIntAttributeL(CMManager::ECmCommsDBBearerType); |
491 TUint32 bearerId = connectionMethod.GetIntAttributeL(CMManager::ECmCommsDBBearerType); |
488 switch (bearerId) { |
492 switch (bearerId) { |
489 case KCommDbBearerCSD: |
493 case KCommDbBearerCSD: |
490 cpPriv->bearer = SymbianNetworkConfigurationPrivate::Bearer2G; |
494 cpPriv->bearerType = QNetworkConfiguration::Bearer2G; |
491 break; |
495 break; |
492 case KCommDbBearerWcdma: |
496 case KCommDbBearerWcdma: |
493 cpPriv->bearer = SymbianNetworkConfigurationPrivate::BearerWCDMA; |
497 cpPriv->bearerType = QNetworkConfiguration::BearerWCDMA; |
494 break; |
498 break; |
495 case KCommDbBearerLAN: |
499 case KCommDbBearerLAN: |
496 cpPriv->bearer = SymbianNetworkConfigurationPrivate::BearerEthernet; |
500 cpPriv->bearerType = QNetworkConfiguration::BearerEthernet; |
497 break; |
501 break; |
498 case KCommDbBearerVirtual: |
502 case KCommDbBearerVirtual: |
499 cpPriv->bearer = SymbianNetworkConfigurationPrivate::BearerUnknown; |
503 cpPriv->bearerType = QNetworkConfiguration::BearerUnknown; |
500 break; |
504 break; |
501 case KCommDbBearerPAN: |
505 case KCommDbBearerPAN: |
502 cpPriv->bearer = SymbianNetworkConfigurationPrivate::BearerUnknown; |
506 cpPriv->bearerType = QNetworkConfiguration::BearerUnknown; |
503 break; |
507 break; |
504 case KCommDbBearerWLAN: |
508 case KCommDbBearerWLAN: |
505 cpPriv->bearer = SymbianNetworkConfigurationPrivate::BearerWLAN; |
509 cpPriv->bearerType = QNetworkConfiguration::BearerWLAN; |
506 break; |
510 break; |
507 default: |
511 default: |
508 cpPriv->bearer = SymbianNetworkConfigurationPrivate::BearerUnknown; |
512 cpPriv->bearerType = QNetworkConfiguration::BearerUnknown; |
509 break; |
513 break; |
510 } |
514 } |
511 |
515 |
512 TInt error = KErrNone; |
516 TInt error = KErrNone; |
513 TUint32 bearerType = connectionMethod.GetIntAttributeL(CMManager::ECmBearerType); |
517 TUint32 bearerType = connectionMethod.GetIntAttributeL(CMManager::ECmBearerType); |
587 apNetworkConfiguration->type = QNetworkConfiguration::InternetAccessPoint; |
591 apNetworkConfiguration->type = QNetworkConfiguration::InternetAccessPoint; |
588 apNetworkConfiguration->purpose = QNetworkConfiguration::UnknownPurpose; |
592 apNetworkConfiguration->purpose = QNetworkConfiguration::UnknownPurpose; |
589 apNetworkConfiguration->roamingSupported = false; |
593 apNetworkConfiguration->roamingSupported = false; |
590 switch (pAPItem->BearerTypeL()) { |
594 switch (pAPItem->BearerTypeL()) { |
591 case EApBearerTypeCSD: |
595 case EApBearerTypeCSD: |
592 apNetworkConfiguration->bearer = SymbianNetworkConfigurationPrivate::Bearer2G; |
596 apNetworkConfiguration->bearerType = QNetworkConfiguration::Bearer2G; |
593 break; |
597 break; |
594 case EApBearerTypeGPRS: |
598 case EApBearerTypeGPRS: |
595 apNetworkConfiguration->bearer = SymbianNetworkConfigurationPrivate::Bearer2G; |
599 apNetworkConfiguration->bearerType = QNetworkConfiguration::Bearer2G; |
596 break; |
600 break; |
597 case EApBearerTypeHSCSD: |
601 case EApBearerTypeHSCSD: |
598 apNetworkConfiguration->bearer = SymbianNetworkConfigurationPrivate::BearerHSPA; |
602 apNetworkConfiguration->bearerType = QNetworkConfiguration::BearerHSPA; |
599 break; |
603 break; |
600 case EApBearerTypeCDMA: |
604 case EApBearerTypeCDMA: |
601 apNetworkConfiguration->bearer = SymbianNetworkConfigurationPrivate::BearerCDMA2000; |
605 apNetworkConfiguration->bearerType = QNetworkConfiguration::BearerCDMA2000; |
602 break; |
606 break; |
603 case EApBearerTypeWLAN: |
607 case EApBearerTypeWLAN: |
604 apNetworkConfiguration->bearer = SymbianNetworkConfigurationPrivate::BearerWLAN; |
608 apNetworkConfiguration->bearerType = QNetworkConfiguration::BearerWLAN; |
605 break; |
609 break; |
606 case EApBearerTypeLAN: |
610 case EApBearerTypeLAN: |
607 apNetworkConfiguration->bearer = SymbianNetworkConfigurationPrivate::BearerEthernet; |
611 apNetworkConfiguration->bearerType = QNetworkConfiguration::BearerEthernet; |
608 break; |
612 break; |
609 case EApBearerTypeLANModem: |
613 case EApBearerTypeLANModem: |
610 apNetworkConfiguration->bearer = SymbianNetworkConfigurationPrivate::BearerEthernet; |
614 apNetworkConfiguration->bearerType = QNetworkConfiguration::BearerEthernet; |
611 break; |
615 break; |
612 default: |
616 default: |
613 apNetworkConfiguration->bearer = SymbianNetworkConfigurationPrivate::BearerUnknown; |
617 apNetworkConfiguration->bearerType = QNetworkConfiguration::BearerUnknown; |
614 break; |
618 break; |
615 } |
619 } |
616 |
620 |
617 CleanupStack::PopAndDestroy(pApUtils); |
621 CleanupStack::PopAndDestroy(pApUtils); |
618 CleanupStack::PopAndDestroy(pAPItem); |
622 CleanupStack::PopAndDestroy(pAPItem); |
686 iConnectionMonitor.GetConnectionInfo(i, connectionId, subConnectionCount); |
690 iConnectionMonitor.GetConnectionInfo(i, connectionId, subConnectionCount); |
687 iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount, KIAPId, apId, status); |
691 iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount, KIAPId, apId, status); |
688 User::WaitForRequest(status); |
692 User::WaitForRequest(status); |
689 QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(apId)); |
693 QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(apId)); |
690 QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); |
694 QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); |
691 #ifdef OCC_FUNCTIONALITY_AVAILABLE |
695 #ifdef SNAP_FUNCTIONALITY_AVAILABLE |
692 if (!ptr) { |
696 if (!ptr) { |
693 // If IAP was not found, check if the update was about EasyWLAN |
697 // If IAP was not found, check if the update was about EasyWLAN |
694 ptr = configurationFromEasyWlan(apId, connectionId); |
698 ptr = configurationFromEasyWlan(apId, connectionId); |
|
699 // Change the ident correspondingly |
|
700 if (ptr) { |
|
701 ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX + |
|
702 QString::number(qHash(toSymbianConfig(ptr)->numericIdentifier())); |
|
703 } |
695 } |
704 } |
696 #endif |
705 #endif |
697 if (ptr) { |
706 if (ptr) { |
698 iConnectionMonitor.GetIntAttribute(connectionId, subConnectionCount, KConnectionStatus, connectionStatus, status); |
707 iConnectionMonitor.GetIntAttribute(connectionId, subConnectionCount, KConnectionStatus, connectionStatus, status); |
699 User::WaitForRequest(status); |
708 User::WaitForRequest(status); |
|
709 |
700 if (connectionStatus == KLinkLayerOpen) { |
710 if (connectionStatus == KLinkLayerOpen) { |
701 online = true; |
711 online = true; |
702 inactiveConfigs.removeOne(ident); |
712 inactiveConfigs.removeOne(ident); |
703 |
713 |
704 ptr->mutex.lock(); |
714 ptr->mutex.lock(); |
832 |
842 |
833 QMutexLocker locker(&ptr->mutex); |
843 QMutexLocker locker(&ptr->mutex); |
834 |
844 |
835 SymbianNetworkConfigurationPrivate *p = toSymbianConfig(ptr); |
845 SymbianNetworkConfigurationPrivate *p = toSymbianConfig(ptr); |
836 |
846 |
837 if (p->bearer >= SymbianNetworkConfigurationPrivate::Bearer2G && |
847 if (p->bearerType >= QNetworkConfiguration::Bearer2G && |
838 p->bearer <= SymbianNetworkConfigurationPrivate::BearerHSPA) { |
848 p->bearerType <= QNetworkConfiguration::BearerHSPA) { |
839 switch (bearerInfo) { |
849 switch (bearerInfo) { |
840 case EBearerInfoCSD: |
850 case EBearerInfoCSD: |
841 p->bearer = SymbianNetworkConfigurationPrivate::Bearer2G; |
851 p->bearerType = QNetworkConfiguration::Bearer2G; |
842 break; |
852 break; |
843 case EBearerInfoWCDMA: |
853 case EBearerInfoWCDMA: |
844 p->bearer = SymbianNetworkConfigurationPrivate::BearerWCDMA; |
854 p->bearerType = QNetworkConfiguration::BearerWCDMA; |
845 break; |
855 break; |
846 case EBearerInfoCDMA2000: |
856 case EBearerInfoCDMA2000: |
847 p->bearer = SymbianNetworkConfigurationPrivate::BearerCDMA2000; |
857 p->bearerType = QNetworkConfiguration::BearerCDMA2000; |
848 break; |
858 break; |
849 case EBearerInfoGPRS: |
859 case EBearerInfoGPRS: |
850 p->bearer = SymbianNetworkConfigurationPrivate::Bearer2G; |
860 p->bearerType = QNetworkConfiguration::Bearer2G; |
851 break; |
861 break; |
852 case EBearerInfoHSCSD: |
862 case EBearerInfoHSCSD: |
853 p->bearer = SymbianNetworkConfigurationPrivate::Bearer2G; |
863 p->bearerType = QNetworkConfiguration::Bearer2G; |
854 break; |
864 break; |
855 case EBearerInfoEdgeGPRS: |
865 case EBearerInfoEdgeGPRS: |
856 p->bearer = SymbianNetworkConfigurationPrivate::Bearer2G; |
866 p->bearerType = QNetworkConfiguration::Bearer2G; |
857 break; |
867 break; |
858 case EBearerInfoWcdmaCSD: |
868 case EBearerInfoWcdmaCSD: |
859 p->bearer = SymbianNetworkConfigurationPrivate::BearerWCDMA; |
869 p->bearerType = QNetworkConfiguration::BearerWCDMA; |
860 break; |
870 break; |
861 case EBearerInfoHSDPA: |
871 case EBearerInfoHSDPA: |
862 p->bearer = SymbianNetworkConfigurationPrivate::BearerHSPA; |
872 p->bearerType = QNetworkConfiguration::BearerHSPA; |
863 break; |
873 break; |
864 case EBearerInfoHSUPA: |
874 case EBearerInfoHSUPA: |
865 p->bearer = SymbianNetworkConfigurationPrivate::BearerHSPA; |
875 p->bearerType = QNetworkConfiguration::BearerHSPA; |
866 break; |
876 break; |
867 case EBearerInfoHSxPA: |
877 case EBearerInfoHSxPA: |
868 p->bearer = SymbianNetworkConfigurationPrivate::BearerHSPA; |
878 p->bearerType = QNetworkConfiguration::BearerHSPA; |
869 break; |
879 break; |
870 } |
880 } |
871 } |
881 } |
872 |
882 |
873 ++i; |
883 ++i; |
1042 iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount, KIAPId, apId, status); |
1052 iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount, KIAPId, apId, status); |
1043 User::WaitForRequest(status); |
1053 User::WaitForRequest(status); |
1044 |
1054 |
1045 QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(apId)); |
1055 QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(apId)); |
1046 QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); |
1056 QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); |
1047 #ifdef OCC_FUNCTIONALITY_AVAILABLE |
1057 #ifdef SNAP_FUNCTIONALITY_AVAILABLE |
1048 if (!ptr) { |
1058 if (!ptr) { |
1049 // Check if status was regarding EasyWLAN |
1059 // Check if status was regarding EasyWLAN |
1050 ptr = configurationFromEasyWlan(apId, connectionId); |
1060 ptr = configurationFromEasyWlan(apId, connectionId); |
1051 } |
1061 } |
1052 #endif |
1062 #endif |
1067 TRequestStatus status; |
1077 TRequestStatus status; |
1068 iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount, KIAPId, apId, status); |
1078 iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount, KIAPId, apId, status); |
1069 User::WaitForRequest(status); |
1079 User::WaitForRequest(status); |
1070 QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(apId)); |
1080 QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(apId)); |
1071 QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); |
1081 QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); |
1072 #ifdef OCC_FUNCTIONALITY_AVAILABLE |
1082 #ifdef SNAP_FUNCTIONALITY_AVAILABLE |
1073 if (!ptr) { |
1083 if (!ptr) { |
1074 // Check for EasyWLAN |
1084 // Check for EasyWLAN |
1075 ptr = configurationFromEasyWlan(apId, connectionId); |
1085 ptr = configurationFromEasyWlan(apId, connectionId); |
1076 } |
1086 } |
1077 #endif |
1087 #endif |
1175 TRequestStatus status; |
1187 TRequestStatus status; |
1176 iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount, KIAPId, apId, status); |
1188 iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount, KIAPId, apId, status); |
1177 User::WaitForRequest(status); |
1189 User::WaitForRequest(status); |
1178 QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(apId)); |
1190 QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(apId)); |
1179 QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); |
1191 QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); |
1180 #ifdef OCC_FUNCTIONALITY_AVAILABLE |
1192 #ifdef SNAP_FUNCTIONALITY_AVAILABLE |
1181 if (!ptr) { |
1193 if (!ptr) { |
1182 // If IAP was not found, check if the update was about EasyWLAN |
1194 // If IAP was not found, check if the update was about EasyWLAN |
1183 ptr = configurationFromEasyWlan(apId, connectionId); |
1195 ptr = configurationFromEasyWlan(apId, connectionId); |
1184 } |
1196 } |
1185 #endif |
1197 #endif |
1196 // For unrecognized events |
1208 // For unrecognized events |
1197 break; |
1209 break; |
1198 } |
1210 } |
1199 } |
1211 } |
1200 |
1212 |
1201 #ifdef OCC_FUNCTIONALITY_AVAILABLE |
1213 /* |
|
1214 Returns the network configuration that matches the given SSID. |
|
1215 */ |
|
1216 QNetworkConfigurationPrivatePointer SymbianEngine::configurationFromSsid(const QString &ssid) |
|
1217 { |
|
1218 QMutexLocker locker(&mutex); |
|
1219 |
|
1220 // Browser through all items and check their name for match |
|
1221 QHash<QString, QNetworkConfigurationPrivatePointer>::ConstIterator i = |
|
1222 accessPointConfigurations.constBegin(); |
|
1223 while (i != accessPointConfigurations.constEnd()) { |
|
1224 QNetworkConfigurationPrivatePointer ptr = i.value(); |
|
1225 |
|
1226 QMutexLocker configLocker(&ptr->mutex); |
|
1227 |
|
1228 if (ptr->name == ssid) { |
|
1229 #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG |
|
1230 qDebug() << "QNCM EasyWlan uses real SSID: " << ssid; |
|
1231 #endif |
|
1232 return ptr; |
|
1233 } |
|
1234 ++i; |
|
1235 } |
|
1236 |
|
1237 return QNetworkConfigurationPrivatePointer(); |
|
1238 } |
|
1239 |
|
1240 #ifdef SNAP_FUNCTIONALITY_AVAILABLE |
1202 // Tries to derive configuration from EasyWLAN. |
1241 // Tries to derive configuration from EasyWLAN. |
1203 // First checks if the interface brought up was EasyWLAN, then derives the real SSID, |
1242 // First checks if the interface brought up was EasyWLAN, then derives the real SSID, |
1204 // and looks up configuration based on that one. |
1243 // and looks up configuration based on that one. |
1205 QNetworkConfigurationPrivatePointer SymbianEngine::configurationFromEasyWlan(TUint32 apId, TUint connectionId) |
1244 QNetworkConfigurationPrivatePointer SymbianEngine::configurationFromEasyWlan(TUint32 apId, |
|
1245 TUint connectionId) |
1206 { |
1246 { |
1207 if (apId == iCmManager.EasyWlanIdL()) { |
1247 if (apId == iCmManager.EasyWlanIdL()) { |
1208 TRequestStatus status; |
1248 TRequestStatus status; |
1209 TBuf<50> easyWlanNetworkName; |
1249 TBuf<50> easyWlanNetworkName; |
1210 iConnectionMonitor.GetStringAttribute( connectionId, 0, KNetworkName, |
1250 iConnectionMonitor.GetStringAttribute( connectionId, 0, KNetworkName, |
1211 easyWlanNetworkName, status ); |
1251 easyWlanNetworkName, status ); |
1212 User::WaitForRequest(status); |
1252 User::WaitForRequest(status); |
1213 if (status.Int() == KErrNone) { |
1253 if (status.Int() == KErrNone) { |
1214 QString realSSID = QString::fromUtf16(easyWlanNetworkName.Ptr(), easyWlanNetworkName.Length()); |
1254 const QString realSSID = QString::fromUtf16(easyWlanNetworkName.Ptr(), |
|
1255 easyWlanNetworkName.Length()); |
1215 |
1256 |
1216 // Browser through all items and check their name for match |
1257 // Browser through all items and check their name for match |
1217 QHash<QString, QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> >::const_iterator i = |
1258 QHash<QString, QNetworkConfigurationPrivatePointer>::ConstIterator i = |
1218 accessPointConfigurations.constBegin(); |
1259 accessPointConfigurations.constBegin(); |
1219 while (i != accessPointConfigurations.constEnd()) { |
1260 while (i != accessPointConfigurations.constEnd()) { |
1220 QNetworkConfigurationPrivatePointer ptr = i.value(); |
1261 QNetworkConfigurationPrivatePointer ptr = i.value(); |
1221 |
1262 |
1222 QMutexLocker configLocker(&ptr->mutex); |
1263 QMutexLocker configLocker(&ptr->mutex); |
1223 |
1264 |