474 TUint aSessionId, |
474 TUint aSessionId, |
475 const RMessage2& aMessage ) |
475 const RMessage2& aMessage ) |
476 { |
476 { |
477 DEBUG( "CWlmServer::Connect()" ); |
477 DEBUG( "CWlmServer::Connect()" ); |
478 |
478 |
479 // Check that WLAN is ON |
|
480 TWlanOnOffState wlanState( iPlatform->GetWlanOnOffState() ); |
|
481 if( wlanState != EWlanOn ) |
|
482 { |
|
483 // WLAN is OFF |
|
484 DEBUG1( "CWlmServer::Connect() - refused due to WLAN is OFF (%d)", |
|
485 wlanState ); |
|
486 // WLAN state enumerations map one to one to WLAN error code |
|
487 aMessage.Complete( wlanState ); |
|
488 |
|
489 return; |
|
490 } |
|
491 |
|
492 // Get WlanSettings and secondarySSID list |
479 // Get WlanSettings and secondarySSID list |
493 // (lanServiceId specifies the table row in wlansettings) |
480 // (lanServiceId specifies the table row in wlansettings) |
494 SWLANSettings iapData; |
481 SWLANSettings iapData; |
495 RArray<TWlanSecondarySsid> secondarySsidList; |
482 RArray<TWlanSecondarySsid> secondarySsidList; |
496 TInt lanServiceId = aMessage.Int0(); |
483 TInt lanServiceId = aMessage.Int0(); |
1854 interval, |
1841 interval, |
1855 duration ); |
1842 duration ); |
1856 iAggressiveScanningAfterLinkLoss = EFalse; |
1843 iAggressiveScanningAfterLinkLoss = EFalse; |
1857 } |
1844 } |
1858 |
1845 |
1859 // If WLAN is ON, enable background scanning |
1846 // If background scan is on, this call will cause a background scan to occur. |
1860 if( iPlatform->GetWlanOnOffState() == EWlanOn ) |
1847 // The icon is updated after the background scan is completed. |
1861 { |
1848 iBgScanProvider->WlanStateChanged( MWlanBgScanProvider::EWlanStateDisconnected ); |
1862 iBgScanProvider->SetBgScanState( MWlanBgScanProvider::EWlanBgScanOn ); |
|
1863 } |
|
1864 |
1849 |
1865 break; |
1850 break; |
1866 case EWlanStateInfrastructure: |
1851 case EWlanStateInfrastructure: |
1867 DEBUG( "CWlmServer::notify() - STATE: EWlanStateInfrastructure" ); |
1852 DEBUG( "CWlmServer::notify() - STATE: EWlanStateInfrastructure" ); |
1868 iIsRoaming = EFalse; |
1853 iIsRoaming = EFalse; |
2390 |
2375 |
2391 // Inform BgScan provider about successful connection. |
2376 // Inform BgScan provider about successful connection. |
2392 // If background scan is currently on, background scan |
2377 // If background scan is currently on, background scan |
2393 // will be disabled and it's request will be removed |
2378 // will be disabled and it's request will be removed |
2394 // from the request map. |
2379 // from the request map. |
2395 iBgScanProvider->SetBgScanState( MWlanBgScanProvider::EWlanBgScanOff ); |
2380 iBgScanProvider->WlanStateChanged( MWlanBgScanProvider::EWlanStateConnected ); |
2396 |
2381 |
2397 } |
2382 } |
2398 } |
2383 } |
2399 else if ( IsSessionActive( completedMapEntry ) ) |
2384 else if ( IsSessionActive( completedMapEntry ) ) |
2400 { |
2385 { |
3630 } |
3615 } |
3631 |
3616 |
3632 DEBUG1( "CWlmServer::ScanSchedulingTimerExpired() - iRequestId %u", self->iRequestMap[index].iRequestId ); |
3617 DEBUG1( "CWlmServer::ScanSchedulingTimerExpired() - iRequestId %u", self->iRequestMap[index].iRequestId ); |
3633 |
3618 |
3634 TUint indexNextScan( 0 ); |
3619 TUint indexNextScan( 0 ); |
3635 // If roaming is ongoing or WLAN is OFF, scanning is not started for |
3620 // If roaming is ongoing, scanning is not started for GetScanResults. |
3636 // GetScanResults but instead empty scan list is returned. |
3621 if ( self->iRequestMap[index].iRequestId >= KWlanExtCmdBase && |
3637 if ( ( self->iRequestMap[index].iRequestId >= KWlanExtCmdBase && |
3622 self->iRequestMap[index].iFunction == EGetScanResults && |
3638 self->iRequestMap[index].iFunction == EGetScanResults ) && |
3623 self->IsRoaming() ) |
3639 ( self->IsRoaming() || self->iPlatform->GetWlanOnOffState() != EWlanOn ) ) |
3624 { |
3640 { |
3625 DEBUG( "CWlmServer::ScanSchedulingTimerExpired() - GetScanResults, roam in progress, returning empty scan results" ); |
3641 DEBUG2( "CWlmServer::ScanSchedulingTimerExpired() - GetScanResults, returning empty list; roaming: %d, WLAN on/off: %d", |
|
3642 self->IsRoaming(), |
|
3643 self->iPlatform->GetWlanOnOffState() ); |
|
3644 |
3626 |
3645 ScanList* completedScanList = reinterpret_cast<ScanList*>( self->iRequestMap[index].iParam0 ); |
3627 ScanList* completedScanList = reinterpret_cast<ScanList*>( self->iRequestMap[index].iParam0 ); |
3646 core_ssid_s* completedSsid = reinterpret_cast<core_ssid_s*>( self->iRequestMap[index].iParam1 ); |
3628 core_ssid_s* completedSsid = reinterpret_cast<core_ssid_s*>( self->iRequestMap[index].iParam1 ); |
3647 TUint* completedScanTime = reinterpret_cast<TUint*>( self->iRequestMap[index].iTime ); |
3629 TUint* completedScanTime = reinterpret_cast<TUint*>( self->iRequestMap[index].iTime ); |
3648 |
3630 |
3655 pckgDynamicScanList().size = 0; |
3637 pckgDynamicScanList().size = 0; |
3656 |
3638 |
3657 if( self->IsSessionActive( self->iRequestMap[index] ) ) |
3639 if( self->IsSessionActive( self->iRequestMap[index] ) ) |
3658 { |
3640 { |
3659 self->iRequestMap[index].iMessage.Write( 2, pckgDynamicScanList ); |
3641 self->iRequestMap[index].iMessage.Write( 2, pckgDynamicScanList ); |
3660 |
3642 self->iRequestMap[index].iMessage.Complete( KErrNone ); |
3661 if( self->iPlatform->GetWlanOnOffState() != EWlanOn ) |
|
3662 { |
|
3663 self->iRequestMap[index].iMessage.Complete( self->iPlatform->GetWlanOnOffState() ); |
|
3664 } |
|
3665 else |
|
3666 { |
|
3667 self->iRequestMap[index].iMessage.Complete( KErrServerBusy ); |
|
3668 } |
|
3669 } |
3643 } |
3670 |
3644 |
3671 delete completedScanList; |
3645 delete completedScanList; |
3672 completedScanList = NULL; |
3646 completedScanList = NULL; |
3673 delete completedSsid; |
3647 delete completedSsid; |
3689 |
3663 |
3690 // If the command is GetAvailableIaps |
3664 // If the command is GetAvailableIaps |
3691 if ( self->iRequestMap[index].iRequestId >= KWlanExtCmdBase && |
3665 if ( self->iRequestMap[index].iRequestId >= KWlanExtCmdBase && |
3692 self->iRequestMap[index].iFunction == EGetAvailableIaps ) |
3666 self->iRequestMap[index].iFunction == EGetAvailableIaps ) |
3693 { |
3667 { |
3694 DEBUG( "CWlmServer::ScanSchedulingTimerExpired() - GetAvailableIaps" ); |
3668 DEBUG( "CWlmServer::ScanSchedulingTimerExpired() - GetAvailableIaps requested" ); |
3695 |
3669 |
3696 core_type_list_c<core_iap_data_s>* iapDataList = reinterpret_cast<core_type_list_c<core_iap_data_s>*>( self->iRequestMap[index].iParam0 ); |
3670 core_type_list_c<core_iap_data_s>* iapDataList = reinterpret_cast<core_type_list_c<core_iap_data_s>*>( self->iRequestMap[index].iParam0 ); |
3697 core_type_list_c<core_iap_availability_data_s>* iapAvailabilityList = |
3671 core_type_list_c<core_iap_availability_data_s>* iapAvailabilityList = |
3698 reinterpret_cast<core_type_list_c<core_iap_availability_data_s>*>( self->iRequestMap[index].iParam1 ); |
3672 reinterpret_cast<core_type_list_c<core_iap_availability_data_s>*>( self->iRequestMap[index].iParam1 ); |
3699 ScanList* scanList = reinterpret_cast<ScanList*>( self->iRequestMap[index].iParam2 ); |
3673 ScanList* scanList = reinterpret_cast<ScanList*>( self->iRequestMap[index].iParam2 ); |
3700 core_type_list_c<core_ssid_entry_s>* iapSsidList = reinterpret_cast<core_type_list_c<core_ssid_entry_s>*>( self->iRequestMap[index].iParam3 ); |
3674 core_type_list_c<core_ssid_entry_s>* iapSsidList = reinterpret_cast<core_type_list_c<core_ssid_entry_s>*>( self->iRequestMap[index].iParam3 ); |
3701 TUint* scanTime = reinterpret_cast<TUint*>( self->iRequestMap[index].iTime ); |
3675 TUint* scanTime = reinterpret_cast<TUint*>( self->iRequestMap[index].iTime ); |
3702 |
3676 |
3703 // If the device is roaming OR |
3677 // If the device is roaming OR there are not WLAN IAPs defined in the device |
3704 // there are not WLAN IAPs defined in the device OR |
|
3705 // WLAN is OFF |
|
3706 // --> return empty list |
3678 // --> return empty list |
3707 if( self->IsRoaming() || |
3679 if( self->IsRoaming() || iapDataList->count() == 0 ) |
3708 iapDataList->count() == 0 || |
3680 { |
3709 self->iPlatform->GetWlanOnOffState() != EWlanOn ) |
3681 DEBUG( "CWlmServer::ScanSchedulingTimerExpired() - Device is roaming or no IAPs defined, returning empty list" ); |
3710 { |
|
3711 DEBUG3( "CWlmServer::ScanSchedulingTimerExpired() - GetAvailableIaps, returning empty list; roaming: %d, iaps: %d, WLAN on/off: %d", |
|
3712 self->IsRoaming(), |
|
3713 iapDataList->count(), |
|
3714 self->iPlatform->GetWlanOnOffState() ); |
|
3715 |
|
3716 // Only the triggering request is completed and then scan scheduling timer is set again |
3682 // Only the triggering request is completed and then scan scheduling timer is set again |
3717 if( self->IsSessionActive( self->iRequestMap[index] ) ) |
3683 if( self->IsSessionActive( self->iRequestMap[index] ) ) |
3718 { |
3684 { |
3719 TWlmAvailableIaps tmp = { 0 }; |
3685 TWlmAvailableIaps tmp = { 0 }; |
3720 TPckg<TWlmAvailableIaps> outPckg( tmp ); |
3686 TPckg<TWlmAvailableIaps> outPckg( tmp ); |
3721 self->iRequestMap[index].iMessage.Write( 0, outPckg ); |
3687 self->iRequestMap[index].iMessage.Write( 0, outPckg ); |
3722 |
3688 self->iRequestMap[index].iMessage.Complete( KErrNone ); |
3723 if( self->iPlatform->GetWlanOnOffState() != EWlanOn ) |
|
3724 { |
|
3725 self->iRequestMap[index].iMessage.Complete( self->iPlatform->GetWlanOnOffState() ); |
|
3726 } |
|
3727 else if( iapDataList->count() == 0 ) |
|
3728 { |
|
3729 self->iRequestMap[index].iMessage.Complete( KErrNone ); |
|
3730 } |
|
3731 else |
|
3732 { |
|
3733 self->iRequestMap[index].iMessage.Complete( KErrServerBusy ); |
|
3734 } |
|
3735 } |
3689 } |
3736 |
3690 |
3737 delete iapDataList; |
3691 delete iapDataList; |
3738 iapDataList = NULL; |
3692 iapDataList = NULL; |
3739 delete iapAvailabilityList; |
3693 delete iapAvailabilityList; |
4514 TUint aSessionId, |
4468 TUint aSessionId, |
4515 const RMessage2& aMessage ) |
4469 const RMessage2& aMessage ) |
4516 { |
4470 { |
4517 DEBUG( "CWlmServer::RunProtectedSetup()" ); |
4471 DEBUG( "CWlmServer::RunProtectedSetup()" ); |
4518 |
4472 |
4519 // Check that WLAN is ON |
4473 // Get WlanSettings and secondarySSID list |
4520 TWlanOnOffState wlanState( iPlatform->GetWlanOnOffState() ); |
4474 // (lanServiceId specifies the table row in wlansettings) |
4521 if( wlanState != EWlanOn ) |
4475 SWLANSettings iapData; |
4522 { |
4476 RArray<TWlanSecondarySsid> secondarySsidList; |
4523 // WLAN is OFF and therefore request is not served. |
4477 TInt lanServiceId = aMessage.Int0(); |
4524 DEBUG1( "CWlmServer::RunProtectedSetup() - rejected due to WLAN is OFF (%d)", |
4478 TRAPD( err, GetIapSettingsL( lanServiceId, iapData, secondarySsidList ) ) ; |
4525 wlanState ); |
4479 if( err != KErrNone ) |
4526 // WLAN states map one to one to WLAN error codes. |
4480 { |
4527 aMessage.Complete( wlanState ); |
4481 DEBUG1( "CWlmServer::RunProtectedSetup() - GetIapSettingsL leaved with %d", |
4528 return; |
4482 err ); |
4529 } |
4483 secondarySsidList.Close(); |
4530 |
4484 aMessage.Complete( err ); |
4531 TPckgBuf<TWlanSsid> ssidPckg; |
|
4532 TInt ret( aMessage.Read( 0, ssidPckg ) ); |
|
4533 if( ret != KErrNone ) |
|
4534 { |
|
4535 aMessage.Complete( ret ); |
|
4536 return; |
4485 return; |
4537 } |
4486 } |
4538 |
4487 secondarySsidList.Close(); |
4539 TPckgBuf<TWlanWpsPin> wpsPinPckg; |
4488 |
4540 ret = aMessage.Read( 1, wpsPinPckg ); |
4489 // Type conversion |
4541 if( ret != KErrNone ) |
|
4542 { |
|
4543 aMessage.Complete( ret ); |
|
4544 return; |
|
4545 } |
|
4546 |
|
4547 core_iap_data_s* coreIapData = new core_iap_data_s; |
4490 core_iap_data_s* coreIapData = new core_iap_data_s; |
4548 if( !coreIapData ) |
4491 if( !coreIapData ) |
4549 { |
4492 { |
4550 aMessage.Complete( KErrNoMemory ); |
4493 aMessage.Complete( KErrNoMemory ); |
4551 return; |
4494 return; |
4552 } |
4495 } |
4553 |
4496 |
4554 coreIapData->id = 0; |
4497 TWLMOverrideSettings override = { 0 }; |
4555 coreIapData->op_mode = core_operating_mode_infrastructure; |
4498 TWlanConversionUtil::ConvertIapSettings( |
4556 coreIapData->security_mode = core_security_mode_protected_setup; |
4499 *coreIapData, |
4557 coreIapData->wpa_preshared_key_in_use = ETrue; |
4500 iapData, |
4558 coreIapData->is_wpa_overriden = ETrue; |
4501 ETrue, // dhcp usage is not important here |
4559 |
4502 override ); |
4560 // Type conversion |
4503 |
4561 TWlanConversionUtil::ConvertSSID( |
4504 |
4562 coreIapData->ssid, |
4505 // Create a list for the results. |
4563 ssidPckg() ); |
|
4564 |
|
4565 // Type conversion |
|
4566 TWlanConversionUtil::ConvertWpaPreSharedKey( |
|
4567 coreIapData->wpa_preshared_key, |
|
4568 wpsPinPckg() ); |
|
4569 |
|
4570 // Create a list for the results. |
|
4571 core_type_list_c<core_iap_data_s>* iapDataList = new core_type_list_c<core_iap_data_s>; |
4506 core_type_list_c<core_iap_data_s>* iapDataList = new core_type_list_c<core_iap_data_s>; |
4572 if( iapDataList == NULL ) |
4507 if( iapDataList == NULL ) |
4573 { |
4508 { |
4574 DEBUG( "CWlmServer::RunProtectedSetup() - unable to create iapDataList" ); |
4509 DEBUG( "CWlmServer::RunProtectedSetup() - unable to create iapDataList" ); |
4575 delete coreIapData; |
4510 delete coreIapData; |
5153 * Read the CommsDat data again so that we can be sure |
5088 * Read the CommsDat data again so that we can be sure |
5154 * that it is up to date after reboot. It can happen that |
5089 * that it is up to date after reboot. It can happen that |
5155 * when WLAN engine boots up commsdat is not up to date yet. |
5090 * when WLAN engine boots up commsdat is not up to date yet. |
5156 */ |
5091 */ |
5157 UpdateWlanSettings(); |
5092 UpdateWlanSettings(); |
5158 |
|
5159 // If WLAN is set ON, enable background scanning |
|
5160 if( iPlatform->GetWlanOnOffState() == EWlanOn ) |
|
5161 { |
|
5162 iBgScanProvider->SetBgScanState( MWlanBgScanProvider::EWlanBgScanOn ); |
|
5163 } |
|
5164 |
5093 |
5165 iPlatform->InitializeSystemTimeHandler(); |
5094 iPlatform->InitializeSystemTimeHandler(); |
5166 } |
5095 } |
5167 |
5096 |
5168 |
5097 |
5370 DEBUG1( "CWlmServer::PublishWlanBgScanInterval( %u )", aInterval ); |
5299 DEBUG1( "CWlmServer::PublishWlanBgScanInterval( %u )", aInterval ); |
5371 |
5300 |
5372 iPlatform->PublishBgScanInterval( aInterval ); |
5301 iPlatform->PublishBgScanInterval( aInterval ); |
5373 } |
5302 } |
5374 |
5303 |
5375 // --------------------------------------------------------- |
|
5376 // CWlmServer::WlanOn |
|
5377 // --------------------------------------------------------- |
|
5378 // |
|
5379 void CWlmServer::WlanOn() |
|
5380 { |
|
5381 DEBUG( "CWlmServer::WlanOn()" ); |
|
5382 |
|
5383 // BG scan can be set ON only after BG scan interval has been |
|
5384 // set and that does not happen until startup has been |
|
5385 // completed. |
|
5386 if( iIsStartupComplete ) |
|
5387 { |
|
5388 // Enable background scanning |
|
5389 iBgScanProvider->SetBgScanState( MWlanBgScanProvider::EWlanBgScanOn ); |
|
5390 } |
|
5391 } |
|
5392 |
|
5393 // --------------------------------------------------------- |
|
5394 // CWlmServer::WlanOff |
|
5395 // --------------------------------------------------------- |
|
5396 // |
|
5397 void CWlmServer::WlanOff() |
|
5398 { |
|
5399 DEBUG1( "CWlmServer::WlanOff() - ConnectionState=%d", |
|
5400 iConnectionState ); |
|
5401 |
|
5402 // Disable background scanning |
|
5403 iBgScanProvider->SetBgScanState( MWlanBgScanProvider::EWlanBgScanOff ); |
|
5404 |
|
5405 // Cancel all running operations that are forbidden in WLAN OFF |
|
5406 CancelExternalRequestsByType( ERunProtectedSetup ); |
|
5407 CancelExternalRequestsByType( EJoinByProfileId ); |
|
5408 |
|
5409 // If WLAN is connected... |
|
5410 if( iConnectionState != EWlanStateNotConnected ) |
|
5411 { |
|
5412 //...send out disconnected indication, which brings down |
|
5413 // the connection gracefully |
|
5414 TBuf8<KMaxNotificationLength> buf; |
|
5415 buf.Append( static_cast<u8_t>( EWlanStateNotConnected ) ); |
|
5416 SendNotification( EWlmNotifyConnectionStateChanged, buf ); |
|
5417 } |
|
5418 } |
|
5419 |
|
5420 // --------------------------------------------------------- |
|
5421 // CWlmServer::CancelRequestsByType |
|
5422 // --------------------------------------------------------- |
|
5423 // |
|
5424 void CWlmServer::CancelExternalRequestsByType( |
|
5425 const TWLMCommands aCommand ) |
|
5426 { |
|
5427 DEBUG1( "CWlmServer::CancelExternalRequestsByType( aCommand=%u )", aCommand ); |
|
5428 |
|
5429 // Go through request map and cancel the command given as a parameter |
|
5430 for( TInt i( 0 ); i < iRequestMap.Count(); i++ ) |
|
5431 { |
|
5432 if( iRequestMap[i].iFunction == aCommand ) |
|
5433 { |
|
5434 DEBUG1( "CWlmServer::CancelExternalRequestsByType() - request found (id=%u), cancelling", |
|
5435 iRequestMap[i].iRequestId ); |
|
5436 |
|
5437 iCoreServer->cancel_request( iRequestMap[i].iRequestId ); |
|
5438 } |
|
5439 } |
|
5440 } |
|
5441 |
|
5442 // --------------------------------------------------------- |
|
5443 // CWlmServer::SendNotification |
|
5444 // --------------------------------------------------------- |
|
5445 // |
|
5446 void CWlmServer::SendNotification( |
|
5447 TWlmNotify amNotification, |
|
5448 TBuf8<KMaxNotificationLength>& aParams ) |
|
5449 { |
|
5450 DEBUG1( "CWlmServer::SendNotification( notification=%u )", |
|
5451 amNotification ); |
|
5452 |
|
5453 // Notify subscribees |
|
5454 for ( TInt i = 0; i < iNotificationArray.Count(); i++ ) |
|
5455 { |
|
5456 iNotificationArray[i]->AddNotification( amNotification, aParams ); |
|
5457 } |
|
5458 } |
|
5459 |
|