diff -r a828660c511c -r d3d7683d16f5 wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlmserver.cpp --- a/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlmserver.cpp Tue Aug 31 17:02:06 2010 +0300 +++ b/wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlmserver.cpp Wed Sep 01 12:41:05 2010 +0100 @@ -16,7 +16,7 @@ */ /* -* %version: 111 % +* %version: 105.1.3 % */ #include @@ -476,19 +476,6 @@ { DEBUG( "CWlmServer::Connect()" ); - // Check that WLAN is ON - TWlanOnOffState wlanState( iPlatform->GetWlanOnOffState() ); - if( wlanState != EWlanOn ) - { - // WLAN is OFF - DEBUG1( "CWlmServer::Connect() - refused due to WLAN is OFF (%d)", - wlanState ); - // WLAN state enumerations map one to one to WLAN error code - aMessage.Complete( wlanState ); - - return; - } - // Get WlanSettings and secondarySSID list // (lanServiceId specifies the table row in wlansettings) SWLANSettings iapData; @@ -1856,11 +1843,9 @@ iAggressiveScanningAfterLinkLoss = EFalse; } - // If WLAN is ON, enable background scanning - if( iPlatform->GetWlanOnOffState() == EWlanOn ) - { - iBgScanProvider->SetBgScanState( MWlanBgScanProvider::EWlanBgScanOn ); - } + // If background scan is on, this call will cause a background scan to occur. + // The icon is updated after the background scan is completed. + iBgScanProvider->WlanStateChanged( MWlanBgScanProvider::EWlanStateDisconnected ); break; case EWlanStateInfrastructure: @@ -2392,7 +2377,7 @@ // If background scan is currently on, background scan // will be disabled and it's request will be removed // from the request map. - iBgScanProvider->SetBgScanState( MWlanBgScanProvider::EWlanBgScanOff ); + iBgScanProvider->WlanStateChanged( MWlanBgScanProvider::EWlanStateConnected ); } } @@ -2446,7 +2431,7 @@ if( IsSessionActive( completedMapEntry ) ) { TPckg outPckg( tmp ); - completedMapEntry.iMessage.Write( 2, outPckg ); + completedMapEntry.iMessage.Write( 1, outPckg ); } if( status == core_error_ok && IsSessionActive( completedMapEntry ) ) @@ -3632,15 +3617,12 @@ DEBUG1( "CWlmServer::ScanSchedulingTimerExpired() - iRequestId %u", self->iRequestMap[index].iRequestId ); TUint indexNextScan( 0 ); - // If roaming is ongoing or WLAN is OFF, scanning is not started for - // GetScanResults but instead empty scan list is returned. - if ( ( self->iRequestMap[index].iRequestId >= KWlanExtCmdBase && - self->iRequestMap[index].iFunction == EGetScanResults ) && - ( self->IsRoaming() || self->iPlatform->GetWlanOnOffState() != EWlanOn ) ) + // If roaming is ongoing, scanning is not started for GetScanResults. + if ( self->iRequestMap[index].iRequestId >= KWlanExtCmdBase && + self->iRequestMap[index].iFunction == EGetScanResults && + self->IsRoaming() ) { - DEBUG2( "CWlmServer::ScanSchedulingTimerExpired() - GetScanResults, returning empty list; roaming: %d, WLAN on/off: %d", - self->IsRoaming(), - self->iPlatform->GetWlanOnOffState() ); + DEBUG( "CWlmServer::ScanSchedulingTimerExpired() - GetScanResults, roam in progress, returning empty scan results" ); ScanList* completedScanList = reinterpret_cast( self->iRequestMap[index].iParam0 ); core_ssid_s* completedSsid = reinterpret_cast( self->iRequestMap[index].iParam1 ); @@ -3657,15 +3639,7 @@ if( self->IsSessionActive( self->iRequestMap[index] ) ) { self->iRequestMap[index].iMessage.Write( 2, pckgDynamicScanList ); - - if( self->iPlatform->GetWlanOnOffState() != EWlanOn ) - { - self->iRequestMap[index].iMessage.Complete( self->iPlatform->GetWlanOnOffState() ); - } - else - { - self->iRequestMap[index].iMessage.Complete( KErrServerBusy ); - } + self->iRequestMap[index].iMessage.Complete( KErrNone ); } delete completedScanList; @@ -3691,47 +3665,27 @@ if ( self->iRequestMap[index].iRequestId >= KWlanExtCmdBase && self->iRequestMap[index].iFunction == EGetAvailableIaps ) { - DEBUG( "CWlmServer::ScanSchedulingTimerExpired() - GetAvailableIaps" ); - + DEBUG( "CWlmServer::ScanSchedulingTimerExpired() - GetAvailableIaps requested" ); + core_type_list_c* iapDataList = reinterpret_cast*>( self->iRequestMap[index].iParam0 ); core_type_list_c* iapAvailabilityList = reinterpret_cast*>( self->iRequestMap[index].iParam1 ); ScanList* scanList = reinterpret_cast( self->iRequestMap[index].iParam2 ); core_type_list_c* iapSsidList = reinterpret_cast*>( self->iRequestMap[index].iParam3 ); TUint* scanTime = reinterpret_cast( self->iRequestMap[index].iTime ); - - // If the device is roaming OR - // there are not WLAN IAPs defined in the device OR - // WLAN is OFF + + // If the device is roaming OR there are not WLAN IAPs defined in the device // --> return empty list - if( self->IsRoaming() || - iapDataList->count() == 0 || - self->iPlatform->GetWlanOnOffState() != EWlanOn ) + if( self->IsRoaming() || iapDataList->count() == 0 ) { - DEBUG3( "CWlmServer::ScanSchedulingTimerExpired() - GetAvailableIaps, returning empty list; roaming: %d, iaps: %d, WLAN on/off: %d", - self->IsRoaming(), - iapDataList->count(), - self->iPlatform->GetWlanOnOffState() ); - + DEBUG( "CWlmServer::ScanSchedulingTimerExpired() - Device is roaming or no IAPs defined, returning empty list" ); // Only the triggering request is completed and then scan scheduling timer is set again if( self->IsSessionActive( self->iRequestMap[index] ) ) { TWlmAvailableIaps tmp = { 0 }; TPckg outPckg( tmp ); self->iRequestMap[index].iMessage.Write( 0, outPckg ); - - if( self->iPlatform->GetWlanOnOffState() != EWlanOn ) - { - self->iRequestMap[index].iMessage.Complete( self->iPlatform->GetWlanOnOffState() ); - } - else if( iapDataList->count() == 0 ) - { - self->iRequestMap[index].iMessage.Complete( KErrNone ); - } - else - { - self->iRequestMap[index].iMessage.Complete( KErrServerBusy ); - } + self->iRequestMap[index].iMessage.Complete( KErrNone ); } delete iapDataList; @@ -4516,58 +4470,39 @@ { DEBUG( "CWlmServer::RunProtectedSetup()" ); - // Check that WLAN is ON - TWlanOnOffState wlanState( iPlatform->GetWlanOnOffState() ); - if( wlanState != EWlanOn ) - { - // WLAN is OFF and therefore request is not served. - DEBUG1( "CWlmServer::RunProtectedSetup() - rejected due to WLAN is OFF (%d)", - wlanState ); - // WLAN states map one to one to WLAN error codes. - aMessage.Complete( wlanState ); - return; - } - - TPckgBuf ssidPckg; - TInt ret( aMessage.Read( 0, ssidPckg ) ); - if( ret != KErrNone ) + // Get WlanSettings and secondarySSID list + // (lanServiceId specifies the table row in wlansettings) + SWLANSettings iapData; + RArray secondarySsidList; + TInt lanServiceId = aMessage.Int0(); + TRAPD( err, GetIapSettingsL( lanServiceId, iapData, secondarySsidList ) ) ; + if( err != KErrNone ) { - aMessage.Complete( ret ); + DEBUG1( "CWlmServer::RunProtectedSetup() - GetIapSettingsL leaved with %d", + err ); + secondarySsidList.Close(); + aMessage.Complete( err ); return; } - - TPckgBuf wpsPinPckg; - ret = aMessage.Read( 1, wpsPinPckg ); - if( ret != KErrNone ) - { - aMessage.Complete( ret ); - return; - } - + secondarySsidList.Close(); + + // Type conversion core_iap_data_s* coreIapData = new core_iap_data_s; if( !coreIapData ) { aMessage.Complete( KErrNoMemory ); return; } - - coreIapData->id = 0; - coreIapData->op_mode = core_operating_mode_infrastructure; - coreIapData->security_mode = core_security_mode_protected_setup; - coreIapData->wpa_preshared_key_in_use = ETrue; - coreIapData->is_wpa_overriden = ETrue; - - // Type conversion - TWlanConversionUtil::ConvertSSID( - coreIapData->ssid, - ssidPckg() ); - - // Type conversion - TWlanConversionUtil::ConvertWpaPreSharedKey( - coreIapData->wpa_preshared_key, - wpsPinPckg() ); - - // Create a list for the results. + + TWLMOverrideSettings override = { 0 }; + TWlanConversionUtil::ConvertIapSettings( + *coreIapData, + iapData, + ETrue, // dhcp usage is not important here + override ); + + + // Create a list for the results. core_type_list_c* iapDataList = new core_type_list_c; if( iapDataList == NULL ) { @@ -5156,12 +5091,6 @@ */ UpdateWlanSettings(); - // If WLAN is set ON, enable background scanning - if( iPlatform->GetWlanOnOffState() == EWlanOn ) - { - iBgScanProvider->SetBgScanState( MWlanBgScanProvider::EWlanBgScanOn ); - } - iPlatform->InitializeSystemTimeHandler(); } @@ -5372,88 +5301,3 @@ iPlatform->PublishBgScanInterval( aInterval ); } -// --------------------------------------------------------- -// CWlmServer::WlanOn -// --------------------------------------------------------- -// -void CWlmServer::WlanOn() - { - DEBUG( "CWlmServer::WlanOn()" ); - - // BG scan can be set ON only after BG scan interval has been - // set and that does not happen until startup has been - // completed. - if( iIsStartupComplete ) - { - // Enable background scanning - iBgScanProvider->SetBgScanState( MWlanBgScanProvider::EWlanBgScanOn ); - } - } - -// --------------------------------------------------------- -// CWlmServer::WlanOff -// --------------------------------------------------------- -// -void CWlmServer::WlanOff() - { - DEBUG1( "CWlmServer::WlanOff() - ConnectionState=%d", - iConnectionState ); - - // Disable background scanning - iBgScanProvider->SetBgScanState( MWlanBgScanProvider::EWlanBgScanOff ); - - // Cancel all running operations that are forbidden in WLAN OFF - CancelExternalRequestsByType( ERunProtectedSetup ); - CancelExternalRequestsByType( EJoinByProfileId ); - - // If WLAN is connected... - if( iConnectionState != EWlanStateNotConnected ) - { - //...send out disconnected indication, which brings down - // the connection gracefully - TBuf8 buf; - buf.Append( static_cast( EWlanStateNotConnected ) ); - SendNotification( EWlmNotifyConnectionStateChanged, buf ); - } - } - -// --------------------------------------------------------- -// CWlmServer::CancelRequestsByType -// --------------------------------------------------------- -// -void CWlmServer::CancelExternalRequestsByType( - const TWLMCommands aCommand ) - { - DEBUG1( "CWlmServer::CancelExternalRequestsByType( aCommand=%u )", aCommand ); - - // Go through request map and cancel the command given as a parameter - for( TInt i( 0 ); i < iRequestMap.Count(); i++ ) - { - if( iRequestMap[i].iFunction == aCommand ) - { - DEBUG1( "CWlmServer::CancelExternalRequestsByType() - request found (id=%u), cancelling", - iRequestMap[i].iRequestId ); - - iCoreServer->cancel_request( iRequestMap[i].iRequestId ); - } - } - } - -// --------------------------------------------------------- -// CWlmServer::SendNotification -// --------------------------------------------------------- -// -void CWlmServer::SendNotification( - TWlmNotify amNotification, - TBuf8& aParams ) - { - DEBUG1( "CWlmServer::SendNotification( notification=%u )", - amNotification ); - - // Notify subscribees - for ( TInt i = 0; i < iNotificationArray.Count(); i++ ) - { - iNotificationArray[i]->AddNotification( amNotification, aParams ); - } - } -