wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlmserver.cpp
branchRCL_3
changeset 20 a9473894c0f1
parent 10 0abc8c98be24
child 34 13838cf40350
equal deleted inserted replaced
15:191c8407e577 20:a9473894c0f1
    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: 105.1.1 %
    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>
    25 #include <in_sock.h>
    25 #include <in_sock.h>
    26 #include <bldvariant.hrh> // for feature definitions
    26 #include <bldvariant.hrh> // for feature definitions
       
    27 #include <hal.h>
    27 
    28 
    28 #include "wlmserver.h"
    29 #include "wlmserver.h"
    29 #include "wlmdriverif.h"
    30 #include "wlmdriverif.h"
    30 #include "wlmsession.h"
    31 #include "wlmsession.h"
    31 #include "wlanconversionutil.h"
    32 #include "wlanconversionutil.h"
    36 #include "wlangenericplugin.h"
    37 #include "wlangenericplugin.h"
    37 #include "wlanssidlistdb.h"
    38 #include "wlanssidlistdb.h"
    38 #include "wlandevicesettingsinternalcrkeys.h"
    39 #include "wlandevicesettingsinternalcrkeys.h"
    39 #include "wlanbgscan.h"
    40 #include "wlanbgscan.h"
    40 #include "wlantimerservices.h"
    41 #include "wlantimerservices.h"
       
    42 #include "wlanticktimer.h"
    41 #include "am_debug.h"
    43 #include "am_debug.h"
    42 
    44 
    43 /** Panic codes for WlanEngine */
    45 /** Panic codes for WlanEngine */
    44 const TInt KWlmPanicCleanupStackCreationFailed  = 1;
    46 const TInt KWlmPanicCleanupStackCreationFailed  = 1;
    45 const TInt KWlmPanicOpenSemaforeFailed          = 2;
    47 const TInt KWlmPanicOpenSemaforeFailed          = 2;
    86 
    88 
    87 /** Bitmask of WLAN features enabled at compile-time. */
    89 /** Bitmask of WLAN features enabled at compile-time. */
    88 const TUint KWlanStaticFeatures =
    90 const TUint KWlanStaticFeatures =
    89     CWlmServer::EWlanStaticFeature802dot11k |
    91     CWlmServer::EWlanStaticFeature802dot11k |
    90     CWlmServer::EWlanStaticFeature802dot11n;
    92     CWlmServer::EWlanStaticFeature802dot11n;
    91 
       
    92 /** Multiplier for converting seconds into microseconds */
       
    93 const TUint KWlanSecsToMicrosecsMultiplier( 1000000 );
       
    94 
    93 
    95 /** Minimum value for aggressive background scan interval, in seconds */
    94 /** Minimum value for aggressive background scan interval, in seconds */
    96 const TUint KWlanAggressiveBgScanMinInterval( 1 );
    95 const TUint KWlanAggressiveBgScanMinInterval( 1 );
    97 
    96 
    98 /** Maximum value for aggressive background scan interval, in seconds */
    97 /** Maximum value for aggressive background scan interval, in seconds */
   139     iCoreAsynchCbId( 0 ),
   138     iCoreAsynchCbId( 0 ),
   140     iCoreAsynchCbStatus( core_error_ok ),
   139     iCoreAsynchCbStatus( core_error_ok ),
   141     iIsStartupComplete( EFalse ),
   140     iIsStartupComplete( EFalse ),
   142     iEapolClient( NULL ),
   141     iEapolClient( NULL ),
   143     iEapolHandler( NULL ),
   142     iEapolHandler( NULL ),
       
   143     iSystemTickPeriod( 0 ),
   144     iScanSchedulingTimerExpiration( 0 ),
   144     iScanSchedulingTimerExpiration( 0 ),
   145     iRequestTriggeringScanning( 0 ),
   145     iRequestTriggeringScanning( 0 ),
   146     iCoreHandlingScanRequest( EFalse ),
   146     iCoreHandlingScanRequest( EFalse ),
   147     iPowerSaveMode( EWlanPowerSaveAutomatic ),
   147     iPowerSaveMode( EWlanPowerSaveAutomatic ),
   148     iPowerSaveEnabled( EFalse ),
   148     iPowerSaveEnabled( EFalse ),
   161 void CWlmServer::ConstructL()
   161 void CWlmServer::ConstructL()
   162     {
   162     {
   163     DEBUG( "CWlmServer::ConstructL()" );
   163     DEBUG( "CWlmServer::ConstructL()" );
   164     User::LeaveIfError( User::RenameThread( KWLMDataServerName ) );
   164     User::LeaveIfError( User::RenameThread( KWLMDataServerName ) );
   165     StartL( KWLMDataServerName );    
   165     StartL( KWLMDataServerName );    
       
   166 
       
   167     HAL::Get( HAL::ESystemTickPeriod, iSystemTickPeriod );
       
   168     DEBUG1( "CWlmServer::ConstructL() - system tick period is %d",
       
   169         iSystemTickPeriod );
       
   170     DEBUG1( "CWlmServer::ConstructL() - current system tick count is %u",
       
   171         User::TickCount( ) );
   166 
   172 
   167     // Consult FeatureManager whether startup is allowed
   173     // Consult FeatureManager whether startup is allowed
   168     FeatureManager::InitializeLibL();
   174     FeatureManager::InitializeLibL();
   169     if( !FeatureManager::FeatureSupported( KFeatureIdProtocolWlan ) )
   175     if( !FeatureManager::FeatureSupported( KFeatureIdProtocolWlan ) )
   170         {
   176         {
   218             deviceSettings.enabledFeatures ) ) );
   224             deviceSettings.enabledFeatures ) ) );
   219     iCoreServer->disable_wlan( KWlanIntCmdDisableWlan );
   225     iCoreServer->disable_wlan( KWlanIntCmdDisableWlan );
   220 
   226 
   221     // Create scan timer
   227     // Create scan timer
   222     DEBUG( "CWlmServer::ConstructL() - create backgroundscan timer" );
   228     DEBUG( "CWlmServer::ConstructL() - create backgroundscan timer" );
   223     iScanSchedulingTimer = CPeriodic::NewL( CActive::EPriorityStandard );
   229     TCallBack expiredCb( ScanSchedulingTimerExpired, this );
       
   230     TCallBack canceledCb( ScanSchedulingTimerCanceled, this );
       
   231     TCallBack emptyCb( EmptyCb, NULL );
       
   232     iScanSchedulingTimer = CWlanTickTimer::NewL(
       
   233         expiredCb,
       
   234         canceledCb,
       
   235         emptyCb );
   224 
   236 
   225     // Create scan cache
   237     // Create scan cache
   226     iCache = CWlanScanResultCache::NewL();
   238     iCache = CWlanScanResultCache::NewL();
   227     iConfiguredCacheLifetime = deviceSettings.scanExpirationTimer;
   239     iConfiguredCacheLifetime = deviceSettings.scanExpirationTimer;
   228 
   240 
  1085         aMessage.Complete( KErrNoMemory );
  1097         aMessage.Complete( KErrNoMemory );
  1086 
  1098 
  1087         return;
  1099         return;
  1088         }    
  1100         }    
  1089 
  1101 
  1090     TTime* scanTime( NULL );
  1102     TUint* scanTime( NULL );
  1091     if( scanScheduling.maxDelay != KWlmInfiniteScanDelay )
  1103     if( scanScheduling.maxDelay != KWlmInfiniteScanDelay )
  1092         {
  1104         {
  1093         scanTime = new TTime(
  1105         scanTime = new TUint(
  1094             CalculateScanStartTime( scanScheduling.maxDelay ).Int64() );
  1106             CalculateScanStartTime( scanScheduling.maxDelay ) );
  1095         if( !scanTime )
  1107         if( !scanTime )
  1096             {
  1108             {
  1097             DEBUG( "CWlmServer::GetScanResult() - unable to instantiate TTime" );
  1109             DEBUG( "CWlmServer::GetScanResult() - unable to instantiate TUint" );
  1098     
  1110 
  1099             delete coreSsid;
  1111             delete coreSsid;
  1100             delete scanList;
  1112             delete scanList;
  1101             aMessage.Complete( KErrNoMemory );
  1113             aMessage.Complete( KErrNoMemory );
  1102     
  1114     
  1103             return;
  1115             return;
  1323         delete iapSsidList;
  1335         delete iapSsidList;
  1324         delete iapIdList;
  1336         delete iapIdList;
  1325         return;
  1337         return;
  1326         }
  1338         }
  1327 
  1339 
  1328     TTime* scanTime( NULL );
  1340     TUint* scanTime( NULL );
  1329     if( maxDelayPckg() != KWlmInfiniteScanDelay )
  1341     if( maxDelayPckg() != KWlmInfiniteScanDelay )
  1330         {
  1342         {
  1331         scanTime = new TTime(
  1343         scanTime = new TUint(
  1332             CalculateScanStartTime( maxDelayPckg() ).Int64() );
  1344             CalculateScanStartTime( maxDelayPckg() ) );
  1333         if( !scanTime )
  1345         if( !scanTime )
  1334             {
  1346             {
  1335             DEBUG( "CWlmServer::GetAvailableIaps() - unable to instantiate TTime" );
  1347             DEBUG( "CWlmServer::GetAvailableIaps() - unable to instantiate TUint" );
  1336     
  1348     
  1337             aMessage.Complete( KErrNoMemory );
  1349             aMessage.Complete( KErrNoMemory );
  1338             delete iapDataList;
  1350             delete iapDataList;
  1339             delete iapSsidList;
  1351             delete iapSsidList;
  1340             delete iapIdList;
  1352             delete iapIdList;
  1540 // ---------------------------------------------------------
  1552 // ---------------------------------------------------------
  1541 // CWlmServer::UpdateScanSchedulingTimer
  1553 // CWlmServer::UpdateScanSchedulingTimer
  1542 // ---------------------------------------------------------
  1554 // ---------------------------------------------------------
  1543 //
  1555 //
  1544 void CWlmServer::UpdateScanSchedulingTimer( 
  1556 void CWlmServer::UpdateScanSchedulingTimer( 
  1545 	TTime aScanTime, 
  1557     TUint aScanTime, 
  1546 	TUint aTriggeringRequestId )
  1558 	TUint aTriggeringRequestId )
  1547     {
  1559     {
  1548     DEBUG1( "CWlmServer::UpdateScanSchedulingTimer() - aTriggeringRequestId = %u ", aTriggeringRequestId );
  1560     DEBUG1( "CWlmServer::UpdateScanSchedulingTimer() - aTriggeringRequestId = %u ", aTriggeringRequestId );
  1549 
  1561 
  1550     if( iCoreHandlingScanRequest )
  1562     if( iCoreHandlingScanRequest )
  1553 		DEBUG( "CWlmServer::UpdateScanSchedulingTimer() - core is currently handling scanning, do not set the timer" );
  1565 		DEBUG( "CWlmServer::UpdateScanSchedulingTimer() - core is currently handling scanning, do not set the timer" );
  1554 
  1566 
  1555         return;
  1567         return;
  1556         }
  1568         }
  1557 
  1569 
  1558     TTime timeNow;
  1570     TUint currentTickCount(
  1559     timeNow.UniversalTime();
  1571         User::TickCount() );
  1560 
  1572     TUint difference( 0 );
  1561     TTimeIntervalMicroSeconds difference( aScanTime.MicroSecondsFrom( timeNow ) );
  1573     if( aScanTime > currentTickCount )
  1562     if( difference.Int64() < 0 )
  1574         {
  1563         {
  1575         difference = aScanTime - currentTickCount;  
  1564         difference = TTimeIntervalMicroSeconds( 0 );
  1576         }
  1565         }
       
  1566     TTimeIntervalMicroSeconds32 differenceMicroseconds(
       
  1567         difference.Int64() );
       
  1568 
  1577 
  1569     iScanSchedulingTimer->Cancel();
  1578     iScanSchedulingTimer->Cancel();
  1570     iScanSchedulingTimerExpiration = aScanTime;
  1579     iScanSchedulingTimerExpiration = aScanTime;
  1571     iRequestTriggeringScanning = aTriggeringRequestId;
  1580     iRequestTriggeringScanning = aTriggeringRequestId;
  1572     TCallBack callback( ScanSchedulingTimerExpired, this );
  1581     
  1573 
  1582     DEBUG2( "CWlmServer::UpdateScanSchedulingTimer() - scheduling the timer to %u system ticks(s) [%u s]",
  1574 	DEBUG1( "CWlmServer::UpdateScanSchedulingTimer() - scheduling the timer to %u second(s)",
  1583         difference, difference * iSystemTickPeriod / KWlanSecsToMicrosecsMultiplier );
  1575 	    differenceMicroseconds.Int() / SECONDS_FROM_MICROSECONDS );
  1584 
  1576 	
  1585     iScanSchedulingTimer->After( difference );
  1577 	TTimeIntervalMicroSeconds32 intervalMicroseconds( KWlmMaxScanDelay * SECONDS_FROM_MICROSECONDS );
       
  1578 
       
  1579     iScanSchedulingTimer->Start(
       
  1580             differenceMicroseconds,
       
  1581             intervalMicroseconds,
       
  1582             callback );
       
  1583     
       
  1584     }
  1586     }
  1585 
  1587 
  1586 // ---------------------------------------------------------
  1588 // ---------------------------------------------------------
  1587 // CWlmServer::FindNextTimedScanSchedulingRequest
  1589 // CWlmServer::FindNextTimedScanSchedulingRequest
  1588 // ---------------------------------------------------------
  1590 // ---------------------------------------------------------
  1591 	TUint& aTriggeringRequestIndex )
  1593 	TUint& aTriggeringRequestIndex )
  1592     {
  1594     {
  1593     DEBUG( "CWlmServer::FindNextTimedScanSchedulingRequest()" );
  1595     DEBUG( "CWlmServer::FindNextTimedScanSchedulingRequest()" );
  1594     
  1596     
  1595     TBool pendingScanRequestsFound( EFalse );
  1597     TBool pendingScanRequestsFound( EFalse );
  1596     TTime closestTime = TTime( 0 );
  1598     TUint closestTime( 0 );
  1597     aTriggeringRequestIndex = 0;
  1599     aTriggeringRequestIndex = 0;
  1598     
  1600     
  1599     for(TInt i=0; i < iRequestMap.Count(); i++)
  1601     for(TInt i=0; i < iRequestMap.Count(); i++)
  1600         {
  1602         {
  1601         if( IsPendingTimedScanRequest( i ) )
  1603         if( IsPendingTimedScanRequest( i ) )
  1602             {
  1604             {
  1603             TTime* checkedTime = reinterpret_cast<TTime*>( iRequestMap[i].iTime );
  1605             TUint* checkedTime = reinterpret_cast<TUint*>( iRequestMap[i].iTime );
  1604             if( pendingScanRequestsFound == EFalse || closestTime > *checkedTime )
  1606             if( pendingScanRequestsFound == EFalse || closestTime > *checkedTime )
  1605                 {
  1607                 {
  1606                 closestTime = *checkedTime;
  1608                 closestTime = *checkedTime;
  1607                 aTriggeringRequestIndex = i;
  1609                 aTriggeringRequestIndex = i;
  1608                 pendingScanRequestsFound = ETrue;
  1610                 pendingScanRequestsFound = ETrue;
  1612     
  1614     
  1613     if( pendingScanRequestsFound == EFalse )
  1615     if( pendingScanRequestsFound == EFalse )
  1614         {
  1616         {
  1615         // clear the scan scheduling related variables
  1617         // clear the scan scheduling related variables
  1616         iRequestTriggeringScanning = KWlanIntCmdNull;
  1618         iRequestTriggeringScanning = KWlanIntCmdNull;
  1617         iScanSchedulingTimerExpiration = TTime( 0 );
  1619         iScanSchedulingTimerExpiration = 0;
  1618         }
  1620         }
  1619     else
  1621     else
  1620         {
  1622         {
  1621         DEBUG1( "CWlmServer::FindNextTimedScanSchedulingRequest() - RequestIndex %u ", aTriggeringRequestIndex );
  1623         DEBUG1( "CWlmServer::FindNextTimedScanSchedulingRequest() - RequestIndex %u ", aTriggeringRequestIndex );
  1622         }
  1624         }
  2441     	{
  2443     	{
  2442         iCoreHandlingScanRequest = EFalse;
  2444         iCoreHandlingScanRequest = EFalse;
  2443 
  2445 
  2444     	if( FindNextTimedScanSchedulingRequest( indexNextScan ) )
  2446     	if( FindNextTimedScanSchedulingRequest( indexNextScan ) )
  2445             {
  2447             {
  2446             TTime* nextScanTime = reinterpret_cast<TTime*>( iRequestMap[indexNextScan].iTime );
  2448             TUint* nextScanTime = reinterpret_cast<TUint*>( iRequestMap[indexNextScan].iTime );
  2447             UpdateScanSchedulingTimer( *nextScanTime, iRequestMap[indexNextScan].iRequestId );
  2449             UpdateScanSchedulingTimer( *nextScanTime, iRequestMap[indexNextScan].iRequestId );
  2448             }
  2450             }
  2449         }
  2451         }
  2450 
  2452 
  2451 #ifdef _DEBUG
  2453 #ifdef _DEBUG
  2611             core_type_list_c<core_iap_data_s>* iapDataList =
  2613             core_type_list_c<core_iap_data_s>* iapDataList =
  2612                 reinterpret_cast<core_type_list_c<core_iap_data_s>*>( aRequest.iParam0 );
  2614                 reinterpret_cast<core_type_list_c<core_iap_data_s>*>( aRequest.iParam0 );
  2613             delete iapDataList;
  2615             delete iapDataList;
  2614             iapDataList = NULL;
  2616             iapDataList = NULL;
  2615             
  2617             
  2616             TTime* completedScanTime = reinterpret_cast<TTime*>( aRequest.iTime );
  2618             TUint* completedScanTime = reinterpret_cast<TUint*>( aRequest.iTime );
  2617             delete completedScanTime;
  2619             delete completedScanTime;
  2618             completedScanTime = NULL;
  2620             completedScanTime = NULL;
  2619 
  2621 
  2620             if( aCompletedWasTriggering )
  2622             if( aCompletedWasTriggering )
  2621                 {
  2623                 {
  2676         {
  2678         {
  2677         case EGetScanResults:
  2679         case EGetScanResults:
  2678             {
  2680             {
  2679             ScanList* tmp( NULL );
  2681             ScanList* tmp( NULL );
  2680             core_ssid_s* ssid = reinterpret_cast<core_ssid_s*>( aRequest.iParam1 );
  2682             core_ssid_s* ssid = reinterpret_cast<core_ssid_s*>( aRequest.iParam1 );
  2681             TTime* completedScanTime = reinterpret_cast<TTime*>( aRequest.iTime );
  2683             TUint* completedScanTime = reinterpret_cast<TUint*>( aRequest.iTime );
  2682             ScanList* completedScanList = reinterpret_cast<ScanList*>( aRequest.iParam0 );
  2684             ScanList* completedScanList = reinterpret_cast<ScanList*>( aRequest.iParam0 );
  2683 
  2685 
  2684             if( aTriggerRequest == NULL )
  2686             if( aTriggerRequest == NULL )
  2685                 {
  2687                 {
  2686                 DEBUG( "CWlmServer::CompleteExternalRequest() - GetScanResults request handled by core" );    
  2688                 DEBUG( "CWlmServer::CompleteExternalRequest() - GetScanResults request handled by core" );    
  2776             core_type_list_c<core_iap_data_s>* iapDataList;
  2778             core_type_list_c<core_iap_data_s>* iapDataList;
  2777 
  2779 
  2778             iapSsidList = reinterpret_cast<core_type_list_c<core_ssid_entry_s>*>( aRequest.iParam3 );
  2780             iapSsidList = reinterpret_cast<core_type_list_c<core_ssid_entry_s>*>( aRequest.iParam3 );
  2779             iapDataList = reinterpret_cast<core_type_list_c<core_iap_data_s>*>( aRequest.iParam0 );
  2781             iapDataList = reinterpret_cast<core_type_list_c<core_iap_data_s>*>( aRequest.iParam0 );
  2780             
  2782             
  2781             TTime* completedScanTime = reinterpret_cast<TTime*>( aRequest.iTime );
  2783             TUint* completedScanTime = reinterpret_cast<TUint*>( aRequest.iTime );
  2782             ScanList* completedScanList = reinterpret_cast<ScanList*>( aRequest.iParam2);
  2784             ScanList* completedScanList = reinterpret_cast<ScanList*>( aRequest.iParam2);
  2783             core_type_list_c<u32_t>* completedIdList = reinterpret_cast<core_type_list_c<u32_t>*>( aRequest.iParam1 );
  2785             core_type_list_c<u32_t>* completedIdList = reinterpret_cast<core_type_list_c<u32_t>*>( aRequest.iParam1 );
  2784             
  2786             
  2785             if( aTriggerRequest == NULL )
  2787             if( aTriggerRequest == NULL )
  2786                 {
  2788                 {
  3434         delete iapSsidList;
  3436         delete iapSsidList;
  3435         delete iapIdList;
  3437         delete iapIdList;
  3436         return KErrNoMemory;
  3438         return KErrNoMemory;
  3437         }
  3439         }
  3438 
  3440 
  3439     TTime* scanTime = new TTime(
  3441     TUint* scanTime = new TUint(
  3440         CalculateScanStartTime( aScanStartInterval ).Int64() );
  3442         CalculateScanStartTime( aScanStartInterval ) );
  3441     if( !scanTime )
  3443     if( !scanTime )
  3442         {
  3444         {
  3443         DEBUG( "CWlmServer::BackgroundScanRequest() - unable to instantiate TTime" );
  3445         DEBUG( "CWlmServer::BackgroundScanRequest() - unable to instantiate TUint" );
  3444 
  3446 
  3445         delete iapDataList;
  3447         delete iapDataList;
  3446         delete iapSsidList;
  3448         delete iapSsidList;
  3447         delete iapIdList;
  3449         delete iapIdList;
  3448         delete scanList;
  3450         delete scanList;
  3512         {
  3514         {
  3513         DEBUG( "CWlmServer::ScanSchedulingTimerExpired() - GetScanResults, roam in progress, returning empty scan results" );
  3515         DEBUG( "CWlmServer::ScanSchedulingTimerExpired() - GetScanResults, roam in progress, returning empty scan results" );
  3514 
  3516 
  3515         ScanList* completedScanList = reinterpret_cast<ScanList*>( self->iRequestMap[index].iParam0 );
  3517         ScanList* completedScanList = reinterpret_cast<ScanList*>( self->iRequestMap[index].iParam0 );
  3516         core_ssid_s* completedSsid =  reinterpret_cast<core_ssid_s*>( self->iRequestMap[index].iParam1 );
  3518         core_ssid_s* completedSsid =  reinterpret_cast<core_ssid_s*>( self->iRequestMap[index].iParam1 );
  3517         TTime* completedScanTime = reinterpret_cast<TTime*>( self->iRequestMap[index].iTime );
  3519         TUint* completedScanTime = reinterpret_cast<TUint*>( self->iRequestMap[index].iTime );
  3518         
  3520         
  3519         // Only the triggering request is completed and then scan scheduling timer is set again 
  3521         // Only the triggering request is completed and then scan scheduling timer is set again 
  3520         TPckgBuf<TUint32> pckgCount( 0 );
  3522         TPckgBuf<TUint32> pckgCount( 0 );
  3521         TPckgBuf<TUint32> pckgSize( 0 );
  3523         TPckgBuf<TUint32> pckgSize( 0 );
  3522         
  3524         
  3539         
  3541         
  3540         self->iRequestMap.Remove( index );
  3542         self->iRequestMap.Remove( index );
  3541 
  3543 
  3542         if( self->FindNextTimedScanSchedulingRequest( indexNextScan ) )
  3544         if( self->FindNextTimedScanSchedulingRequest( indexNextScan ) )
  3543             {
  3545             {
  3544             TTime* nextScanTime = reinterpret_cast<TTime*>( self->iRequestMap[indexNextScan].iTime );
  3546             TUint* nextScanTime = reinterpret_cast<TUint*>( self->iRequestMap[indexNextScan].iTime );
  3545         	self->UpdateScanSchedulingTimer( *nextScanTime, self->iRequestMap[indexNextScan].iRequestId );
  3547         	self->UpdateScanSchedulingTimer( *nextScanTime, self->iRequestMap[indexNextScan].iRequestId );
  3546             }
  3548             }
  3547         
  3549         
  3548         DEBUG( "CWlmServer::ScanSchedulingTimerExpired() - message completed with empty scan results" );
  3550         DEBUG( "CWlmServer::ScanSchedulingTimerExpired() - message completed with empty scan results" );
  3549         return KErrNone;        
  3551         return KErrNone;        
  3557 
  3559 
  3558         core_type_list_c<core_iap_data_s>* iapDataList = reinterpret_cast<core_type_list_c<core_iap_data_s>*>( self->iRequestMap[index].iParam0 );
  3560         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 );
  3561         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 );
  3562         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 );
  3563         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 );        
  3564         TUint* scanTime =  reinterpret_cast<TUint*>( self->iRequestMap[index].iTime );        
  3563         
  3565         
  3564         // If the device is roaming OR there are not WLAN IAPs defined in the device
  3566         // If the device is roaming OR there are not WLAN IAPs defined in the device
  3565         // --> return empty list
  3567         // --> return empty list
  3566         if( self->IsRoaming() || iapDataList->count() == 0 )
  3568         if( self->IsRoaming() || iapDataList->count() == 0 )
  3567             {
  3569             {
  3588         
  3590         
  3589             self->iRequestMap.Remove( index );
  3591             self->iRequestMap.Remove( index );
  3590 
  3592 
  3591             if( self->FindNextTimedScanSchedulingRequest( indexNextScan ) )
  3593             if( self->FindNextTimedScanSchedulingRequest( indexNextScan ) )
  3592                 {
  3594                 {
  3593                 TTime* nextScanTime = reinterpret_cast<TTime*>( self->iRequestMap[indexNextScan].iTime );
  3595                 TUint* nextScanTime = reinterpret_cast<TUint*>( self->iRequestMap[indexNextScan].iTime );
  3594                 self->UpdateScanSchedulingTimer( *nextScanTime, self->iRequestMap[indexNextScan].iRequestId );
  3596                 self->UpdateScanSchedulingTimer( *nextScanTime, self->iRequestMap[indexNextScan].iRequestId );
  3595                 }
  3597                 }
  3596         
  3598         
  3597             DEBUG( "CWlmServer::ScanSchedulingTimerExpired() - message completed with empty iap list" );
  3599             DEBUG( "CWlmServer::ScanSchedulingTimerExpired() - message completed with empty iap list" );
  3598             return KErrNone;        
  3600             return KErrNone;        
  3679         
  3681         
  3680         self->iScanSchedulingTimer->Cancel();
  3682         self->iScanSchedulingTimer->Cancel();
  3681         }
  3683         }
  3682     self->iCoreHandlingScanRequest = ETrue;
  3684     self->iCoreHandlingScanRequest = ETrue;
  3683     return KErrNone;
  3685     return KErrNone;
  3684     }
  3686    }
       
  3687 
       
  3688 // ---------------------------------------------------------
       
  3689 // CWlmServer::ScanSchedulingTimerCanceled()
       
  3690 // ---------------------------------------------------------
       
  3691 //
       
  3692 TInt CWlmServer::ScanSchedulingTimerCanceled(
       
  3693     TAny* aThisPtr )
       
  3694     {
       
  3695     DEBUG( "CWlmServer::ScanSchedulingTimerCanceled()" );
       
  3696 
       
  3697     CWlmServer* self = reinterpret_cast<CWlmServer*>( aThisPtr );
       
  3698 
       
  3699     /**
       
  3700      * Scan scheduling timer was canceled, re-arm the timer. 
       
  3701      */
       
  3702     TUint indexNextScan( 0 );
       
  3703     if( self->FindNextTimedScanSchedulingRequest( indexNextScan ) )
       
  3704         {
       
  3705         self->UpdateScanSchedulingTimer(
       
  3706             *(self->iRequestMap[indexNextScan].iTime),
       
  3707             self->iRequestMap[indexNextScan].iRequestId );
       
  3708         }
       
  3709 
       
  3710     return 0;
       
  3711     }
       
  3712 
       
  3713 // ---------------------------------------------------------
       
  3714 // CWlmServer::EmptyCb()
       
  3715 // ---------------------------------------------------------
       
  3716 //
       
  3717 TInt CWlmServer::EmptyCb(
       
  3718     TAny* /* aThisPtr */ )
       
  3719     {
       
  3720     return 0;
       
  3721     }
       
  3722 
  3685     
  3723     
  3686 // ---------------------------------------------------------
  3724 // ---------------------------------------------------------
  3687 // CWlmServer::GetIapDataList()
  3725 // CWlmServer::GetIapDataList()
  3688 // ---------------------------------------------------------
  3726 // ---------------------------------------------------------
  3689 //
  3727 //
  3895     	
  3933     	
  3896         DEBUG("CWlmServer::SystemTimeChanged() - inform timer services about system time change");
  3934         DEBUG("CWlmServer::SystemTimeChanged() - inform timer services about system time change");
  3897     	iTimerServices->HandleTimeout();
  3935     	iTimerServices->HandleTimeout();
  3898         DEBUG("CWlmServer::SystemTimeChanged() - refreshing settings to BgScan provider");
  3936         DEBUG("CWlmServer::SystemTimeChanged() - refreshing settings to BgScan provider");
  3899         iBgScanProvider->NotifyChangedSettings( iBgScanProviderSettings );
  3937         iBgScanProvider->NotifyChangedSettings( iBgScanProviderSettings );
  3900     	
       
  3901     	// Pending scan requests should be handled because after the system time change all the
       
  3902     	// timestamps are invalid. Change the scan start times to start immediately
       
  3903 
       
  3904         DEBUG("CWlmServer::SystemTimeChanged() - set all pending requests to expire immediately");
       
  3905         
       
  3906     	TInt i( 0 );
       
  3907     	for( i = 0; i < iRequestMap.Count(); i++ )
       
  3908     	    {
       
  3909     	    if( IsPendingTimedScanRequest(i) )
       
  3910     	        {
       
  3911                 DEBUG1( "CWlmServer::SystemTimeChanged() - setting iTime to current time for request %i",
       
  3912                         iRequestMap[i].iRequestId );
       
  3913                 
       
  3914     	        TTime* requestedScanTime = reinterpret_cast<TTime*>( iRequestMap[i].iTime );
       
  3915                 requestedScanTime->UniversalTime();              
       
  3916     	        }
       
  3917     	    }
       
  3918         if( !iCoreHandlingScanRequest )
       
  3919             {
       
  3920             // Core is not handling any scan request so update the timer
       
  3921             DEBUG("CWlmServer::SystemTimeChanged() - Core is not currently handling any scan requests");
       
  3922             DEBUG("CWlmServer::SystemTimeChanged() - Cancel timer and set it again to new value");
       
  3923 
       
  3924             iScanSchedulingTimer->Cancel();
       
  3925             TUint indexNextScan;
       
  3926             if( FindNextTimedScanSchedulingRequest( indexNextScan ) )
       
  3927                 {
       
  3928                 TTime* nextScanTime = reinterpret_cast<TTime*>( iRequestMap[indexNextScan].iTime );
       
  3929                 UpdateScanSchedulingTimer( *nextScanTime, iRequestMap[indexNextScan].iRequestId );
       
  3930                 }
       
  3931             }
       
  3932     	}
  3938     	}
  3933     }
  3939     }
  3934 
  3940 
  3935 // ---------------------------------------------------------
  3941 // ---------------------------------------------------------
  3936 // CWlmServer::ClearRegionCache
  3942 // CWlmServer::ClearRegionCache
  4072             SRequestMapEntry entry = iRequestMap[index];
  4078             SRequestMapEntry entry = iRequestMap[index];
  4073             delete reinterpret_cast<core_type_list_c<core_iap_data_s>*>( entry.iParam0 );
  4079             delete reinterpret_cast<core_type_list_c<core_iap_data_s>*>( entry.iParam0 );
  4074             delete reinterpret_cast<core_type_list_c<u32_t>*>( entry.iParam1 );
  4080             delete reinterpret_cast<core_type_list_c<u32_t>*>( entry.iParam1 );
  4075             delete reinterpret_cast<ScanList*>( entry.iParam2);
  4081             delete reinterpret_cast<ScanList*>( entry.iParam2);
  4076             delete reinterpret_cast<core_type_list_c<core_ssid_entry_s>*>( entry.iParam3 );
  4082             delete reinterpret_cast<core_type_list_c<core_ssid_entry_s>*>( entry.iParam3 );
  4077             delete reinterpret_cast<TTime*>( entry.iTime );
  4083             delete reinterpret_cast<TUint*>( entry.iTime );
  4078             iRequestMap.Remove( index );
  4084             iRequestMap.Remove( index );
  4079 
  4085 
  4080             DEBUG( "CWlmServer::CancelScan() - find next possible timed scan scheduling request" );
  4086             DEBUG( "CWlmServer::CancelScan() - find next possible timed scan scheduling request" );
  4081             TUint indexNextScan;
  4087             TUint indexNextScan;
  4082             if( FindNextTimedScanSchedulingRequest( indexNextScan ) )
  4088             if( FindNextTimedScanSchedulingRequest( indexNextScan ) )
  4109                 SRequestMapEntry entry = iRequestMap[index];
  4115                 SRequestMapEntry entry = iRequestMap[index];
  4110                 delete reinterpret_cast<core_type_list_c<core_iap_data_s>*>( entry.iParam0 );
  4116                 delete reinterpret_cast<core_type_list_c<core_iap_data_s>*>( entry.iParam0 );
  4111                 delete reinterpret_cast<core_type_list_c<u32_t>*>( entry.iParam1 );
  4117                 delete reinterpret_cast<core_type_list_c<u32_t>*>( entry.iParam1 );
  4112                 delete reinterpret_cast<ScanList*>( entry.iParam2);
  4118                 delete reinterpret_cast<ScanList*>( entry.iParam2);
  4113                 delete reinterpret_cast<core_type_list_c<core_ssid_entry_s>*>( entry.iParam3 );
  4119                 delete reinterpret_cast<core_type_list_c<core_ssid_entry_s>*>( entry.iParam3 );
  4114                 delete reinterpret_cast<TTime*>( entry.iTime );                
  4120                 delete reinterpret_cast<TUint*>( entry.iTime );                
  4115                 iRequestMap.Remove( index );
  4121                 iRequestMap.Remove( index );
  4116                 }
  4122                 }
  4117             }
  4123             }
  4118         }
  4124         }
  4119     DEBUG( "CWlmServer::CancelScan() - returning" );
  4125     DEBUG( "CWlmServer::CancelScan() - returning" );