wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlmserver.cpp
changeset 19 629e60dfa279
parent 17 41a8eba36f74
child 22 c6a1762761b8
child 30 7d966ab5304a
equal deleted inserted replaced
17:41a8eba36f74 19:629e60dfa279
    14 * Description:  Server class of wlan engine
    14 * Description:  Server class of wlan engine
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 /*
    18 /*
    19 * %version: 105 %
    19 * %version: 106 %
    20 */
    20 */
    21 
    21 
    22 #include <e32def.h>
    22 #include <e32def.h>
    23 #include <e32std.h>
    23 #include <e32std.h>
    24 #include <featmgr.h>
    24 #include <featmgr.h>
   462     TUint aSessionId,
   462     TUint aSessionId,
   463     const RMessage2& aMessage )
   463     const RMessage2& aMessage )
   464     {
   464     {
   465     DEBUG( "CWlmServer::Connect()" );
   465     DEBUG( "CWlmServer::Connect()" );
   466 
   466 
       
   467     // Check that WLAN is ON
       
   468     TWlanOnOffState wlanState( iPlatform->GetWlanOnOffState() );
       
   469 	if( wlanState != EWlanOn )
       
   470 	    {
       
   471 		// WLAN is OFF
       
   472 		DEBUG1( "CWlmServer::Connect() refused due to WLAN is OFF (%d)",
       
   473 		    wlanState );
       
   474 		// WLAN state enumerations map one to one to WLAN error code
       
   475 		aMessage.Complete( wlanState );
       
   476 		
       
   477 		return;
       
   478 		}
       
   479 
   467     // Get WlanSettings and secondarySSID list
   480     // Get WlanSettings and secondarySSID list
   468     // (lanServiceId specifies the table row in wlansettings)
   481     // (lanServiceId specifies the table row in wlansettings)
   469     SWLANSettings iapData;
   482     SWLANSettings iapData;
   470     RArray<TWlanSecondarySsid> secondarySsidList;
   483     RArray<TWlanSecondarySsid> secondarySsidList;
   471     TInt lanServiceId = aMessage.Int0();
   484     TInt lanServiceId = aMessage.Int0();
  1812                             interval,
  1825                             interval,
  1813                             duration );
  1826                             duration );
  1814                         iAggressiveScanningAfterLinkLoss = EFalse;
  1827                         iAggressiveScanningAfterLinkLoss = EFalse;
  1815                         }
  1828                         }
  1816                     
  1829                     
  1817                     // If background scan is on, this call will cause a background scan to occur.
  1830 					// If WLAN is ON, enable background scanning
  1818 					// The icon is updated after the background scan is completed.
  1831 					if( iPlatform->GetWlanOnOffState() == EWlanOn )
  1819                     iBgScanProvider->WlanStateChanged( MWlanBgScanProvider::EWlanStateDisconnected );
  1832 					    {
       
  1833                         iBgScanProvider->WlanSetBgScanState( MWlanBgScanProvider::EWlanBgScanOn );
       
  1834                         }
  1820                     
  1835                     
  1821                     break;
  1836                     break;
  1822                 case EWlanStateInfrastructure:
  1837                 case EWlanStateInfrastructure:
  1823                     DEBUG( "CWlmServer::notify() - STATE: EWlanStateInfrastructure" );
  1838                     DEBUG( "CWlmServer::notify() - STATE: EWlanStateInfrastructure" );
  1824                     iIsRoaming = EFalse;
  1839                     iIsRoaming = EFalse;
  2323                 
  2338                 
  2324                 // Inform BgScan provider about successful connection.
  2339                 // Inform BgScan provider about successful connection.
  2325                 // If background scan is currently on, background scan
  2340                 // If background scan is currently on, background scan
  2326                 // will be disabled and it's request will be removed
  2341                 // will be disabled and it's request will be removed
  2327                 // from the request map.
  2342                 // from the request map.
  2328                 iBgScanProvider->WlanStateChanged( MWlanBgScanProvider::EWlanStateConnected );
  2343                 iBgScanProvider->WlanSetBgScanState( MWlanBgScanProvider::EWlanBgScanOff );
  2329                 
  2344                 
  2330                 }
  2345                 }
  2331             }
  2346             }
  2332         else if ( IsSessionActive( completedMapEntry ) )
  2347         else if ( IsSessionActive( completedMapEntry ) )
  2333             {
  2348             {
  3503     	}
  3518     	}
  3504     
  3519     
  3505     DEBUG1( "CWlmServer::ScanSchedulingTimerExpired() - iRequestId %u", self->iRequestMap[index].iRequestId );
  3520     DEBUG1( "CWlmServer::ScanSchedulingTimerExpired() - iRequestId %u", self->iRequestMap[index].iRequestId );
  3506     
  3521     
  3507     TUint indexNextScan( 0 );
  3522     TUint indexNextScan( 0 );
  3508     // If roaming is ongoing, scanning is not started for GetScanResults. 
  3523     // If roaming is ongoing or WLAN is OFF, scanning is not started for
  3509     if ( self->iRequestMap[index].iRequestId >= KWlanExtCmdBase && 
  3524     // GetScanResults but instead empty scan list is returned. 
  3510          self->iRequestMap[index].iFunction == EGetScanResults && 
  3525     if ( ( self->iRequestMap[index].iRequestId >= KWlanExtCmdBase && 
  3511     	 self->IsRoaming() )
  3526            self->iRequestMap[index].iFunction == EGetScanResults ) && 
  3512         {
  3527     	 ( self->IsRoaming() || self->iPlatform->GetWlanOnOffState() != EWlanOn ) )
  3513         DEBUG( "CWlmServer::ScanSchedulingTimerExpired() - GetScanResults, roam in progress, returning empty scan results" );
  3528         {
       
  3529         DEBUG2( "CWlmServer::ScanSchedulingTimerExpired() - GetScanResults, returning empty list; roaming: %d, WLAN on/off: %d",
       
  3530             self->IsRoaming(),
       
  3531             self->iPlatform->GetWlanOnOffState() );
  3514 
  3532 
  3515         ScanList* completedScanList = reinterpret_cast<ScanList*>( self->iRequestMap[index].iParam0 );
  3533         ScanList* completedScanList = reinterpret_cast<ScanList*>( self->iRequestMap[index].iParam0 );
  3516         core_ssid_s* completedSsid =  reinterpret_cast<core_ssid_s*>( self->iRequestMap[index].iParam1 );
  3534         core_ssid_s* completedSsid =  reinterpret_cast<core_ssid_s*>( self->iRequestMap[index].iParam1 );
  3517         TTime* completedScanTime = reinterpret_cast<TTime*>( self->iRequestMap[index].iTime );
  3535         TTime* completedScanTime = reinterpret_cast<TTime*>( self->iRequestMap[index].iTime );
  3518         
  3536         
  3551     
  3569     
  3552     // If the command is GetAvailableIaps
  3570     // If the command is GetAvailableIaps
  3553     if ( self->iRequestMap[index].iRequestId >= KWlanExtCmdBase && 
  3571     if ( self->iRequestMap[index].iRequestId >= KWlanExtCmdBase && 
  3554          self->iRequestMap[index].iFunction == EGetAvailableIaps )
  3572          self->iRequestMap[index].iFunction == EGetAvailableIaps )
  3555         {
  3573         {
  3556         DEBUG( "CWlmServer::ScanSchedulingTimerExpired() - GetAvailableIaps requested" );
  3574         DEBUG( "CWlmServer::ScanSchedulingTimerExpired() - GetAvailableIaps" );
  3557 
  3575             
  3558         core_type_list_c<core_iap_data_s>* iapDataList = reinterpret_cast<core_type_list_c<core_iap_data_s>*>( self->iRequestMap[index].iParam0 );
  3576         core_type_list_c<core_iap_data_s>* iapDataList = reinterpret_cast<core_type_list_c<core_iap_data_s>*>( self->iRequestMap[index].iParam0 );
  3559         core_type_list_c<u32_t>* iapIdList =  reinterpret_cast<core_type_list_c<u32_t>*>( self->iRequestMap[index].iParam1 );
  3577         core_type_list_c<u32_t>* iapIdList =  reinterpret_cast<core_type_list_c<u32_t>*>( self->iRequestMap[index].iParam1 );
  3560         ScanList* scanList =  reinterpret_cast<ScanList*>( self->iRequestMap[index].iParam2 );
  3578         ScanList* scanList =  reinterpret_cast<ScanList*>( self->iRequestMap[index].iParam2 );
  3561         core_type_list_c<core_ssid_entry_s>* iapSsidList =  reinterpret_cast<core_type_list_c<core_ssid_entry_s>*>( self->iRequestMap[index].iParam3 );
  3579         core_type_list_c<core_ssid_entry_s>* iapSsidList =  reinterpret_cast<core_type_list_c<core_ssid_entry_s>*>( self->iRequestMap[index].iParam3 );
  3562         TTime* scanTime =  reinterpret_cast<TTime*>( self->iRequestMap[index].iTime );        
  3580         TTime* scanTime =  reinterpret_cast<TTime*>( self->iRequestMap[index].iTime );        
  3563         
  3581 
  3564         // If the device is roaming OR there are not WLAN IAPs defined in the device
  3582         // If the device is roaming OR
       
  3583         // there are not WLAN IAPs defined in the device OR
       
  3584         // WLAN is OFF
  3565         // --> return empty list
  3585         // --> return empty list
  3566         if( self->IsRoaming() || iapDataList->count() == 0 )
  3586         if( self->IsRoaming() ||
  3567             {
  3587             iapDataList->count() == 0 ||
  3568             DEBUG( "CWlmServer::ScanSchedulingTimerExpired() - Device is roaming or no IAPs defined, returning empty list" );
  3588             self->iPlatform->GetWlanOnOffState() != EWlanOn )
       
  3589             {
       
  3590             DEBUG3( "CWlmServer::ScanSchedulingTimerExpired() - GetAvailableIaps, returning empty list; roaming: %d, iaps: %d, WLAN on/off: %d",
       
  3591                 self->IsRoaming(),
       
  3592                 iapDataList->count(),
       
  3593                 self->iPlatform->GetWlanOnOffState() );    
       
  3594             
  3569             // Only the triggering request is completed and then scan scheduling timer is set again 
  3595             // Only the triggering request is completed and then scan scheduling timer is set again 
  3570             if( self->IsSessionActive( self->iRequestMap[index] ) )
  3596             if( self->IsSessionActive( self->iRequestMap[index] ) )
  3571                 {
  3597                 {
  3572                 TWlmAvailableIaps tmp = { 0 };
  3598                 TWlmAvailableIaps tmp = { 0 };
  3573                 TPckg<TWlmAvailableIaps> outPckg( tmp );
  3599                 TPckg<TWlmAvailableIaps> outPckg( tmp );
  4349     TUint aSessionId,
  4375     TUint aSessionId,
  4350     const RMessage2& aMessage )
  4376     const RMessage2& aMessage )
  4351     {
  4377     {
  4352     DEBUG( "CWlmServer::RunProtectedSetup()" );
  4378     DEBUG( "CWlmServer::RunProtectedSetup()" );
  4353     
  4379     
       
  4380     // Check that WLAN is ON
       
  4381 	TWlanOnOffState wlanState( iPlatform->GetWlanOnOffState() );
       
  4382 	if( wlanState != EWlanOn )
       
  4383 	    {
       
  4384 		// WLAN is OFF and therefore request is not served.
       
  4385 		DEBUG1( "CWlmServer::RunProtectedSetup() rejected due to WLAN is OFF (%d)",
       
  4386 		    wlanState );
       
  4387 		// WLAN states map one to one to WLAN error codes.
       
  4388 		aMessage.Complete( wlanState );
       
  4389 		return;
       
  4390 		}
       
  4391     
  4354     // Get WlanSettings and secondarySSID list
  4392     // Get WlanSettings and secondarySSID list
  4355     // (lanServiceId specifies the table row in wlansettings)
  4393     // (lanServiceId specifies the table row in wlansettings)
  4356     SWLANSettings iapData;
  4394     SWLANSettings iapData;
  4357     RArray<TWlanSecondarySsid> secondarySsidList;
  4395     RArray<TWlanSecondarySsid> secondarySsidList;
  4358     TInt lanServiceId = aMessage.Int0();
  4396     TInt lanServiceId = aMessage.Int0();
  4970      * that it is up to date after reboot. It can happen that
  5008      * that it is up to date after reboot. It can happen that
  4971      * when WLAN engine boots up commsdat is not up to date yet.
  5009      * when WLAN engine boots up commsdat is not up to date yet.
  4972      */
  5010      */
  4973     UpdateWlanSettings();
  5011     UpdateWlanSettings();
  4974 
  5012 
       
  5013     // If WLAN is set ON, enable background scanning
       
  5014     if( iPlatform->GetWlanOnOffState() == EWlanOn )
       
  5015         {
       
  5016         iBgScanProvider->WlanSetBgScanState( MWlanBgScanProvider::EWlanBgScanOn );
       
  5017         }
       
  5018 
  4975     iPlatform->InitializeSystemTimeHandler();
  5019     iPlatform->InitializeSystemTimeHandler();
  4976     }
  5020     }
  4977 
  5021 
  4978 
  5022 
  4979 // ---------------------------------------------------------
  5023 // ---------------------------------------------------------
  5172     DEBUG1( "CWlmServer::PublishWlanBgScanInterval( %u )", aInterval );
  5216     DEBUG1( "CWlmServer::PublishWlanBgScanInterval( %u )", aInterval );
  5173     
  5217     
  5174     iPlatform->PublishBgScanInterval( aInterval );
  5218     iPlatform->PublishBgScanInterval( aInterval );
  5175     }
  5219     }
  5176     
  5220     
       
  5221 // ---------------------------------------------------------
       
  5222 // CWlmServer::WlanOn
       
  5223 // ---------------------------------------------------------
       
  5224 //
       
  5225 void CWlmServer::WlanOn()
       
  5226     {
       
  5227 	DEBUG( "CWlmServer::WlanOn()" );
       
  5228 	
       
  5229 	// BG scan can be set ON only after BG scan interval has been
       
  5230 	// set and that does not happen until startup has been
       
  5231 	// completed.
       
  5232 	if( iIsStartupComplete )
       
  5233 	    {
       
  5234 	    // Enable background scanning
       
  5235 	    iBgScanProvider->WlanSetBgScanState( MWlanBgScanProvider::EWlanBgScanOn );
       
  5236 	    }
       
  5237 	}
       
  5238 
       
  5239 // ---------------------------------------------------------
       
  5240 // CWlmServer::WlanOff
       
  5241 // ---------------------------------------------------------
       
  5242 //
       
  5243 void CWlmServer::WlanOff()
       
  5244     {
       
  5245 	DEBUG( "CWlmServer::WlanOff()" );
       
  5246 	
       
  5247 	// Disable background scanning
       
  5248 	iBgScanProvider->WlanSetBgScanState( MWlanBgScanProvider::EWlanBgScanOff );
       
  5249 	
       
  5250 	// Cancel all running operations that are forbidden in WLAN OFF
       
  5251     CancelExternalRequestsByType( ERunProtectedSetup );
       
  5252     CancelExternalRequestsByType( EJoinByProfileId );
       
  5253     
       
  5254 	// If WLAN is connected...
       
  5255     if( iConnectionState != EWlanStateNotConnected )
       
  5256         {
       
  5257         //...send out disconnected indication, which brings down
       
  5258         // the connection gracefully
       
  5259         TBuf8<KMaxNotificationLength> buf;
       
  5260         buf.Append( static_cast<u8_t>( EWlanStateNotConnected ) );
       
  5261         SendNotification( EWlmNotifyConnectionStateChanged, buf );
       
  5262         }
       
  5263 	}
       
  5264     
       
  5265 // ---------------------------------------------------------
       
  5266 // CWlmServer::CancelRequestsByType
       
  5267 // ---------------------------------------------------------
       
  5268 //
       
  5269 void CWlmServer::CancelExternalRequestsByType(
       
  5270     const TWLMCommands aCommand )
       
  5271     {
       
  5272     DEBUG1( "CWlmServer::CancelExternalRequestsByType( aCommand=%u )", aCommand );
       
  5273 
       
  5274     // Go through request map and cancel the command given as a parameter
       
  5275     for( TInt i( 0 ); i < iRequestMap.Count(); i++ )
       
  5276         {
       
  5277         if( iRequestMap[i].iFunction == aCommand )
       
  5278             {
       
  5279             DEBUG1( "CWlmServer::CancelExternalRequestsByType() - request found (id=%u), cancelling",
       
  5280                 iRequestMap[i].iRequestId );
       
  5281             
       
  5282             iCoreServer->cancel_request( iRequestMap[i].iRequestId );
       
  5283             }
       
  5284         }
       
  5285     }
       
  5286 
       
  5287 // ---------------------------------------------------------
       
  5288 // CWlmServer::SendNotification
       
  5289 // ---------------------------------------------------------
       
  5290 //
       
  5291 void CWlmServer::SendNotification(
       
  5292     TWlmNotify amNotification,
       
  5293     TBuf8<KMaxNotificationLength>& aParams )
       
  5294     {
       
  5295     DEBUG1( "CWlmServer::SendNotification( notification=%u )",
       
  5296         amNotification );
       
  5297     
       
  5298     // Notify subscribees
       
  5299     for ( TInt i = 0; i < iNotificationArray.Count(); i++ )
       
  5300         {
       
  5301         iNotificationArray[i]->AddNotification( amNotification, aParams );
       
  5302         }
       
  5303     }
       
  5304