wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlmserver.cpp
branchRCL_3
changeset 34 13838cf40350
parent 20 a9473894c0f1
child 42 a828660c511c
equal deleted inserted replaced
21:af3fb27c7511 34:13838cf40350
    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.1.1 %
    19 * %version: 105.1.3 %
    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>
   205         }
   205         }
   206     core_mac_address_s core_mac( ZERO_MAC_ADDR );
   206     core_mac_address_s core_mac( ZERO_MAC_ADDR );
   207     TWlanConversionUtil::ConvertMacAddress( core_mac, mac );
   207     TWlanConversionUtil::ConvertMacAddress( core_mac, mac );
   208 
   208 
   209     // Get Device Settings
   209     // Get Device Settings
   210     CWlanDeviceSettings::SWlanDeviceSettings deviceSettings;
   210     GetWlanSettingsL( iDeviceSettings );
   211     GetWlanSettingsL( deviceSettings );
   211     SetCachedRegion(iDeviceSettings.region, iDeviceSettings.regionTimestamp);    
   212     SetCachedRegion(deviceSettings.region, deviceSettings.regionTimestamp);    
       
   213     core_device_settings_s coreSettings; // core needs the settings here
   212     core_device_settings_s coreSettings; // core needs the settings here
   214     TWlanConversionUtil::ConvertDeviceSettings( coreSettings, deviceSettings );
   213     TWlanConversionUtil::ConvertDeviceSettings( coreSettings, iDeviceSettings );
   215 
   214 
   216     // Create core server    
   215     // Create core server    
   217     User::LeaveIfNull( iCoreServer = core_server_factory_c::instance(
   216     User::LeaveIfNull( iCoreServer = core_server_factory_c::instance(
   218         *this,
   217         *this,
   219         *iDriverIf,
   218         *iDriverIf,
   220         coreSettings,
   219         coreSettings,
   221         core_mac,
   220         core_mac,
   222         TWlanConversionUtil::ConvertFeatureFlags(
   221         TWlanConversionUtil::ConvertFeatureFlags(
   223             iSupportedFeatures,
   222             iSupportedFeatures,
   224             deviceSettings.enabledFeatures ) ) );
   223             iDeviceSettings.enabledFeatures ) ) );
   225     iCoreServer->disable_wlan( KWlanIntCmdDisableWlan );
   224     iCoreServer->disable_wlan( KWlanIntCmdDisableWlan );
   226 
   225 
   227     // Create scan timer
   226     // Create scan timer
   228     DEBUG( "CWlmServer::ConstructL() - create backgroundscan timer" );
   227     DEBUG( "CWlmServer::ConstructL() - create backgroundscan timer" );
   229     TCallBack expiredCb( ScanSchedulingTimerExpired, this );
   228     TCallBack expiredCb( ScanSchedulingTimerExpired, this );
   234         canceledCb,
   233         canceledCb,
   235         emptyCb );
   234         emptyCb );
   236 
   235 
   237     // Create scan cache
   236     // Create scan cache
   238     iCache = CWlanScanResultCache::NewL();
   237     iCache = CWlanScanResultCache::NewL();
   239     iConfiguredCacheLifetime = deviceSettings.scanExpirationTimer;
   238     iConfiguredCacheLifetime = iDeviceSettings.scanExpirationTimer;
   240 
   239 
   241     // Create a callback for asynchronous core requests
   240     // Create a callback for asynchronous core requests
   242     TCallBack callback( HandleCoreAsynchCb, this );
   241     TCallBack callback( HandleCoreAsynchCb, this );
   243     iCoreAsynchCb = new (ELeave) CAsyncCallBack(
   242     iCoreAsynchCb = new (ELeave) CAsyncCallBack(
   244         callback, CActive::EPriorityStandard );
   243         callback, CActive::EPriorityStandard );
   293         }
   292         }
   294 
   293 
   295     // Stop all plugins
   294     // Stop all plugins
   296     iGenericWlanPlugin.StopPlugins();
   295     iGenericWlanPlugin.StopPlugins();
   297 
   296 
       
   297     iIapWeakList.Close();
   298     delete iCoreServer;
   298     delete iCoreServer;
   299     delete iDriverIf;
   299     delete iDriverIf;
   300     iNotificationArray.Close();
   300     iNotificationArray.Close();
   301     delete iCache;
   301     delete iCache;
   302     delete iPlatform;
   302     delete iPlatform;
   645     *connectionStatus = core_connect_undefined;
   645     *connectionStatus = core_connect_undefined;
   646     
   646     
   647     TInt ret = GetCurrentIapId(
   647     TInt ret = GetCurrentIapId(
   648         static_cast<TUint>(lanServiceId), 
   648         static_cast<TUint>(lanServiceId), 
   649         *coreIapData );
   649         *coreIapData );
   650         
   650     iConnectionIapId = coreIapData->iap_id;
       
   651 
   651     if (  ret != KErrNone )
   652     if (  ret != KErrNone )
   652         {
   653         {
   653         secondarySsidList.Close();
   654         secondarySsidList.Close();
   654         delete coreIapData;
   655         delete coreIapData;
   655         delete coreSsidList;
   656         delete coreSsidList;
  1208     DEBUG( "CWlmServer::GetAvailableIaps()" );
  1209     DEBUG( "CWlmServer::GetAvailableIaps()" );
  1209 
  1210 
  1210     // Read cacheLifetime and maxDelay arguments
  1211     // Read cacheLifetime and maxDelay arguments
  1211     TPckgBuf<TInt> cacheLifetimePckg( KWlmDefaultScanCacheLifetime );
  1212     TPckgBuf<TInt> cacheLifetimePckg( KWlmDefaultScanCacheLifetime );
  1212     TPckgBuf<TUint> maxDelayPckg( 0 );
  1213     TPckgBuf<TUint> maxDelayPckg( 0 );
       
  1214     TBool isFiltered(
       
  1215         aMessage.Int3() );
       
  1216     DEBUG1( "CWlmServer::GetAvailableIaps() - isFiltered: %u",
       
  1217         isFiltered );
  1213     if( aMessage.Read( 1, cacheLifetimePckg ) != KErrNone )
  1218     if( aMessage.Read( 1, cacheLifetimePckg ) != KErrNone )
  1214         {
  1219         {
  1215         DEBUG( "CWlmServer::GetAvailableIaps() - unable to read lifetime parameter" );
  1220         DEBUG( "CWlmServer::GetAvailableIaps() - unable to read lifetime parameter" );
  1216 
  1221 
  1217         aMessage.Complete( KErrArgument );
  1222         aMessage.Complete( KErrArgument );
  1239 
  1244 
  1240     /**
  1245     /**
  1241      * See if cached IAP availability information is available.
  1246      * See if cached IAP availability information is available.
  1242      */
  1247      */
  1243     RArray<TWlanLimitedIapData> iapList;
  1248     RArray<TWlanLimitedIapData> iapList;
  1244     RArray<TUint>* list = iCache->AvailableIaps(
  1249     RArray<TWlmAvailabilityData>* list = iCache->AvailableIaps(
  1245                                             iapList,
  1250         iapList,
  1246                                             ( cacheLifetimePckg() == 0 ? 1 : cacheLifetimePckg() ) );
  1251         ( cacheLifetimePckg() == 0 ? 1 : cacheLifetimePckg() ) );
  1247     
       
  1248     // Only complete with valid cache if maxDelay is zero
  1252     // Only complete with valid cache if maxDelay is zero
  1249     if( list && maxDelayPckg() == 0 )
  1253     if( list && maxDelayPckg() == 0 )
  1250         {
  1254         {
  1251 
  1255         TWlmAvailableIaps tmp = { 0 };
  1252         TWlmAvailableIaps tmp;
  1256         if( isFiltered )
  1253         const TInt listCount(
  1257             {            
  1254             Min( list->Count(), KWlmMaxAvailableIaps ) );
  1258             DEBUG1( "CWlmServer::GetAvailableIaps() - using filtered cached IAP list, list contains %d IAP(s)",
  1255         
  1259                 list->Count() );
  1256         DEBUG1( "CWlmServer::GetAvailableIaps() - using cached IAP list, list contains %d IAP(s)", listCount );
  1260 
  1257         
  1261             for( TInt idx( 0 ); idx < list->Count() && tmp.count < KWlmMaxAvailableIaps; ++idx )
  1258         TInt listIdx( 0 );
  1262                 {
  1259 
  1263                 if( (*list)[idx].rcpi >= iDeviceSettings.minRcpiForIapAvailability &&
  1260         while( listIdx < listCount )
  1264                     iIapWeakList.Find( (*list)[idx].iapId ) == KErrNotFound )
  1261             {
  1265                     {
  1262             tmp.iaps[ listIdx ] = (*list)[listIdx];
  1266                     DEBUG2( "CWlmServer::GetAvailableIaps() - IAP %u is available, RCPI is %u",
  1263             ++listIdx;
  1267                         (*list)[idx].iapId, (*list)[idx].rcpi );
  1264             }
  1268                     tmp.iaps[tmp.count++] = (*list)[idx];
  1265         tmp.count = listCount;
  1269                     }
       
  1270                 else
       
  1271                     {
       
  1272                     DEBUG2( "CWlmServer::GetAvailableIaps() - IAP %u filtered, RCPI is %u",
       
  1273                         (*list)[idx].iapId, (*list)[idx].rcpi );
       
  1274                     }
       
  1275                 }
       
  1276             }
       
  1277         else
       
  1278             {
       
  1279             DEBUG1( "CWlmServer::GetAvailableIaps() - using cached IAP list, list contains %d IAP(s)",
       
  1280                 list->Count() );
       
  1281 
       
  1282             for( TInt idx( 0 ); idx < list->Count() && tmp.count < KWlmMaxAvailableIaps; ++idx )
       
  1283                 {
       
  1284                 DEBUG2( "CWlmServer::GetAvailableIaps() - IAP %u is available, RCPI is %u",
       
  1285                     (*list)[idx].iapId, (*list)[idx].rcpi );
       
  1286                 tmp.iaps[tmp.count++] = (*list)[idx];                
       
  1287                 }
       
  1288             }
       
  1289 
  1266         TPckg<TWlmAvailableIaps> outPckg( tmp );
  1290         TPckg<TWlmAvailableIaps> outPckg( tmp );
  1267         aMessage.Write( 0, outPckg );
  1291         aMessage.Write( 0, outPckg );
  1268         aMessage.Complete( KErrNone );
  1292         aMessage.Complete( KErrNone );
  1269         iapList.Close();
  1293         iapList.Close();
  1270 
  1294 
  1315         }
  1339         }
  1316 
  1340 
  1317     iapList.Close();
  1341     iapList.Close();
  1318 
  1342 
  1319     // Create output list
  1343     // Create output list
  1320     core_type_list_c<u32_t>* iapIdList = new core_type_list_c<u32_t>;
  1344     core_type_list_c<core_iap_availability_data_s>* iapAvailabilityList =
  1321     if( iapIdList == NULL )
  1345         new core_type_list_c<core_iap_availability_data_s>;
       
  1346     if( iapAvailabilityList == NULL )
  1322         {
  1347         {
  1323         aMessage.Complete( KErrNoMemory );
  1348         aMessage.Complete( KErrNoMemory );
  1324         delete iapDataList;
  1349         delete iapDataList;
  1325         delete iapSsidList;
  1350         delete iapSsidList;
  1326         return;
  1351         return;
  1331     if( scanList == NULL )
  1356     if( scanList == NULL )
  1332         {
  1357         {
  1333         aMessage.Complete( KErrNoMemory );        
  1358         aMessage.Complete( KErrNoMemory );        
  1334         delete iapDataList;
  1359         delete iapDataList;
  1335         delete iapSsidList;
  1360         delete iapSsidList;
  1336         delete iapIdList;
  1361         delete iapAvailabilityList;
  1337         return;
  1362         return;
  1338         }
  1363         }
  1339 
  1364 
  1340     TUint* scanTime( NULL );
  1365     TUint* scanTime( NULL );
  1341     if( maxDelayPckg() != KWlmInfiniteScanDelay )
  1366     if( maxDelayPckg() != KWlmInfiniteScanDelay )
  1347             DEBUG( "CWlmServer::GetAvailableIaps() - unable to instantiate TUint" );
  1372             DEBUG( "CWlmServer::GetAvailableIaps() - unable to instantiate TUint" );
  1348     
  1373     
  1349             aMessage.Complete( KErrNoMemory );
  1374             aMessage.Complete( KErrNoMemory );
  1350             delete iapDataList;
  1375             delete iapDataList;
  1351             delete iapSsidList;
  1376             delete iapSsidList;
  1352             delete iapIdList;
  1377             delete iapAvailabilityList;
  1353             delete scanList;
  1378             delete scanList;
  1354     
  1379     
  1355             return;
  1380             return;
  1356             }
  1381             }
  1357         }
  1382         }
  1367     mapEntry.iMessage = aMessage;
  1392     mapEntry.iMessage = aMessage;
  1368     mapEntry.iFunction = EGetAvailableIaps;
  1393     mapEntry.iFunction = EGetAvailableIaps;
  1369     mapEntry.iRequestId = iRequestIdCounter++;
  1394     mapEntry.iRequestId = iRequestIdCounter++;
  1370     mapEntry.iSessionId = aSessionId;    
  1395     mapEntry.iSessionId = aSessionId;    
  1371     mapEntry.iParam0 = iapDataList;
  1396     mapEntry.iParam0 = iapDataList;
  1372     mapEntry.iParam1 = iapIdList;
  1397     mapEntry.iParam1 = iapAvailabilityList;
  1373     mapEntry.iParam2 = scanList;
  1398     mapEntry.iParam2 = scanList;
  1374     mapEntry.iParam3 = iapSsidList;
  1399     mapEntry.iParam3 = iapSsidList;
       
  1400     mapEntry.iParam4 = reinterpret_cast<TAny*>( isFiltered );
  1375     mapEntry.iTime = scanTime;
  1401     mapEntry.iTime = scanTime;
  1376     iRequestMap.Append( mapEntry );
  1402     iRequestMap.Append( mapEntry );
  1377 
  1403 
  1378     // Scan scheduling timer needs to be set again if this request needs the results earlier or 
  1404     // Scan scheduling timer needs to be set again if this request needs the results earlier or 
  1379     // if this is the only timed pending request
  1405     // if this is the only timed pending request
  1495         {
  1521         {
  1496         DEBUG1( "CWlmServer::UpdateWlanSettings() - GetWlanSettingsL leaved with code %d", err );
  1522         DEBUG1( "CWlmServer::UpdateWlanSettings() - GetWlanSettingsL leaved with code %d", err );
  1497 
  1523 
  1498         return err;
  1524         return err;
  1499         }
  1525         }
  1500         
  1526     iDeviceSettings = settings;
       
  1527 
  1501     // Only if startup is complete, inform current settings to BgScan
  1528     // Only if startup is complete, inform current settings to BgScan
  1502     if( iIsStartupComplete )
  1529     if( iIsStartupComplete )
  1503         {
  1530         {
  1504         DEBUG( "CWlmServer::UpdateWlanSettings() - notifying settings to BgScan provider" );
  1531         DEBUG( "CWlmServer::UpdateWlanSettings() - notifying settings to BgScan provider" );
  1505         iBgScanProviderSettings = MWlanBgScanProvider::TWlanBgScanSettings( settings.backgroundScanInterval,
  1532         iBgScanProviderSettings = MWlanBgScanProvider::TWlanBgScanSettings( settings.backgroundScanInterval,
  1630 // CWlmServer::NotifyBackgroundScanDone
  1657 // CWlmServer::NotifyBackgroundScanDone
  1631 // ---------------------------------------------------------
  1658 // ---------------------------------------------------------
  1632 //
  1659 //
  1633 void CWlmServer::NotifyBackgroundScanDone(
  1660 void CWlmServer::NotifyBackgroundScanDone(
  1634     ScanList* aScanList, 
  1661     ScanList* aScanList, 
  1635     core_type_list_c<u32_t>* aIapIdList )
  1662     core_type_list_c<core_iap_availability_data_s>& aIapAvailabilityData )
  1636     {
  1663     {
  1637     DEBUG( "CWlmServer::NotifyBackgroundScanDone()" );
  1664     DEBUG( "CWlmServer::NotifyBackgroundScanDone()" );
  1638     ASSERT( aScanList != NULL );
  1665     ASSERT( aScanList != NULL );
  1639     ASSERT( aIapIdList != NULL );
  1666 
  1640     
       
  1641     // Unload the drivers immediately to conserve power.
  1667     // Unload the drivers immediately to conserve power.
  1642     if( !iPlatform->IsWlanDisabled() &&
  1668     if( !iPlatform->IsWlanDisabled() &&
  1643         iConnectionState == EWlanStateNotConnected )
  1669         iConnectionState == EWlanStateNotConnected )
  1644         {
  1670         {
  1645         iCoreServer->unload_drivers();
  1671         iCoreServer->unload_drivers();
  1651     // Update Cached results
  1677     // Update Cached results
  1652     iCache->UpdateScanList( aScanList );
  1678     iCache->UpdateScanList( aScanList );
  1653     TBool newIaps( EFalse );
  1679     TBool newIaps( EFalse );
  1654     TBool lostIaps( EFalse );
  1680     TBool lostIaps( EFalse );
  1655     iCache->UpdateAvailableNetworksList(
  1681     iCache->UpdateAvailableNetworksList(
  1656         *aIapIdList,
  1682         aIapAvailabilityData,
  1657         networkList,
  1683         networkList,
  1658         newIaps,
  1684         newIaps,
  1659         lostIaps );
  1685         lostIaps );
  1660     
  1686     
  1661     networkList.Close();
  1687     networkList.Close();
  1798             switch ( iConnectionState )
  1824             switch ( iConnectionState )
  1799                 {
  1825                 {
  1800                 case EWlanStateNotConnected:
  1826                 case EWlanStateNotConnected:
  1801                     DEBUG( "CWlmServer::notify() - STATE: EWlanStateNotConnected" );
  1827                     DEBUG( "CWlmServer::notify() - STATE: EWlanStateNotConnected" );
  1802                     iIsRoaming = EFalse;
  1828                     iIsRoaming = EFalse;
       
  1829                     iConnectionIapId = 0;
  1803 
  1830 
  1804                     // set icon to "not available"
  1831                     // set icon to "not available"
  1805                     SetIconState( EWlmIconStatusNotAvailable );
  1832                     SetIconState( EWlmIconStatusNotAvailable );
  1806                     
  1833                     
  1807                     // if link was unintentionally lost, scan aggressively
  1834                     // if link was unintentionally lost, scan aggressively
  1880             DEBUG( "CWlmServer::notify() - STATE: EWlmNotifyAcTrafficModeChanged<ind>" );
  1907             DEBUG( "CWlmServer::notify() - STATE: EWlmNotifyAcTrafficModeChanged<ind>" );
  1881             break;
  1908             break;
  1882         case EWlmNotifyAcTrafficStatusChanged:
  1909         case EWlmNotifyAcTrafficStatusChanged:
  1883             DEBUG( "CWlmServer::notify() - STATE: EWlmNotifyAcTrafficStatusChanged<ind>" );
  1910             DEBUG( "CWlmServer::notify() - STATE: EWlmNotifyAcTrafficStatusChanged<ind>" );
  1884             break;
  1911             break;
       
  1912         case EWlmNotifyRcpChanged:
       
  1913             DEBUG( "CWlmServer::notify() - STATE: EWlmNotifyRcpChanged<ind>" );
       
  1914             if( static_cast<core_rcp_class_e>( data[0] ) == core_rcp_normal )
       
  1915                 {
       
  1916                 TInt idx = iIapWeakList.Find( iConnectionIapId );
       
  1917                 if( idx >= 0 )
       
  1918                     {
       
  1919                     DEBUG1( "CWlmServer::notify() - removing IAP %u from weak list",
       
  1920                         iConnectionIapId );
       
  1921                     iIapWeakList.Remove( idx );
       
  1922                     }
       
  1923                 }
       
  1924             else
       
  1925                 {
       
  1926                 TInt idx = iIapWeakList.Find( iConnectionIapId );
       
  1927                 if( idx == KErrNotFound )
       
  1928                     {
       
  1929                     DEBUG1( "CWlmServer::notify() - adding IAP %u to weak list",
       
  1930                         iConnectionIapId );
       
  1931                     iIapWeakList.Append( iConnectionIapId );                    
       
  1932                     }
       
  1933                 }
       
  1934             break;
  1885         default:
  1935         default:
  1886             break;
  1936             break;
  1887         }
  1937         }
  1888     }
  1938     }
  1889 
  1939 
  2605             delete iapSsidList;
  2655             delete iapSsidList;
  2606             iapSsidList = NULL;
  2656             iapSsidList = NULL;
  2607             
  2657             
  2608             ScanList* scanList = 
  2658             ScanList* scanList = 
  2609                 reinterpret_cast<ScanList*>( aRequest.iParam2 );
  2659                 reinterpret_cast<ScanList*>( aRequest.iParam2 );
  2610             core_type_list_c<u32_t>* idList = 
  2660             core_type_list_c<core_iap_availability_data_s>* iapAvailabilityList = 
  2611                 reinterpret_cast<core_type_list_c<u32_t>*>( aRequest.iParam1 );
  2661                 reinterpret_cast<core_type_list_c<core_iap_availability_data_s>*>( aRequest.iParam1 );
  2612                 
       
  2613             core_type_list_c<core_iap_data_s>* iapDataList =
  2662             core_type_list_c<core_iap_data_s>* iapDataList =
  2614                 reinterpret_cast<core_type_list_c<core_iap_data_s>*>( aRequest.iParam0 );
  2663                 reinterpret_cast<core_type_list_c<core_iap_data_s>*>( aRequest.iParam0 );
  2615             delete iapDataList;
  2664             delete iapDataList;
  2616             iapDataList = NULL;
  2665             iapDataList = NULL;
  2617             
  2666             
  2623                 {
  2672                 {
  2624                 DEBUG( "CWlmServer::CompleteInternalRequest() - this request was handled by core" );
  2673                 DEBUG( "CWlmServer::CompleteInternalRequest() - this request was handled by core" );
  2625 
  2674 
  2626                 if( aStatus == core_error_ok )
  2675                 if( aStatus == core_error_ok )
  2627                     {
  2676                     {
  2628                     NotifyBackgroundScanDone( scanList, idList );
  2677                     NotifyBackgroundScanDone( scanList, *iapAvailabilityList );
  2629                     // cache takes the ownership of the scanList
  2678                     // cache takes the ownership of the scanList
  2630                     scanList = NULL;
  2679                     scanList = NULL;
  2631                     }
  2680                     }
  2632             	}
  2681             	}
  2633             else
  2682             else
  2635                 DEBUG( "CWlmServer::CompleteInternalRequest() - this request was not handled by core" );
  2684                 DEBUG( "CWlmServer::CompleteInternalRequest() - this request was not handled by core" );
  2636                 }
  2685                 }
  2637             
  2686             
  2638             delete scanList;
  2687             delete scanList;
  2639             scanList = NULL;
  2688             scanList = NULL;
  2640             delete idList;
  2689             delete iapAvailabilityList;
  2641             idList = NULL;
  2690             iapAvailabilityList = NULL;
  2642                         
  2691                         
  2643             break;
  2692             break;
  2644             }
  2693             }
  2645         case KWlanIntCmdNull: // Fall through on purpose
  2694         case KWlanIntCmdNull: // Fall through on purpose
  2646         default:
  2695         default:
  2772         case EGetAvailableIaps:
  2821         case EGetAvailableIaps:
  2773             {
  2822             {
  2774             // Create pointers to parameters
  2823             // Create pointers to parameters
  2775             core_type_list_c<core_ssid_entry_s>* iapSsidList;
  2824             core_type_list_c<core_ssid_entry_s>* iapSsidList;
  2776             ScanList* scanList;
  2825             ScanList* scanList;
  2777             core_type_list_c<u32_t>* coreIdList;
  2826             core_type_list_c<core_iap_availability_data_s>* coreAvailabilityList;
  2778             core_type_list_c<core_iap_data_s>* iapDataList;
  2827             core_type_list_c<core_iap_data_s>* iapDataList;
       
  2828             TBool isFiltered( reinterpret_cast<TBool>( aRequest.iParam4 ) );
       
  2829             DEBUG1( "CWlmServer::CompleteExternalRequest() - isFiltered: %u",
       
  2830                 isFiltered );
  2779 
  2831 
  2780             iapSsidList = reinterpret_cast<core_type_list_c<core_ssid_entry_s>*>( aRequest.iParam3 );
  2832             iapSsidList = reinterpret_cast<core_type_list_c<core_ssid_entry_s>*>( aRequest.iParam3 );
  2781             iapDataList = reinterpret_cast<core_type_list_c<core_iap_data_s>*>( aRequest.iParam0 );
  2833             iapDataList = reinterpret_cast<core_type_list_c<core_iap_data_s>*>( aRequest.iParam0 );
  2782             
  2834             
  2783             TUint* completedScanTime = reinterpret_cast<TUint*>( aRequest.iTime );
  2835             TUint* completedScanTime = reinterpret_cast<TUint*>( aRequest.iTime );
  2784             ScanList* completedScanList = reinterpret_cast<ScanList*>( aRequest.iParam2);
  2836             ScanList* completedScanList = reinterpret_cast<ScanList*>( aRequest.iParam2);
  2785             core_type_list_c<u32_t>* completedIdList = reinterpret_cast<core_type_list_c<u32_t>*>( aRequest.iParam1 );
  2837             core_type_list_c<core_iap_availability_data_s>* completedAvailabilityList =
       
  2838                 reinterpret_cast<core_type_list_c<core_iap_availability_data_s>*>( aRequest.iParam1 );
  2786             
  2839             
  2787             if( aTriggerRequest == NULL )
  2840             if( aTriggerRequest == NULL )
  2788                 {
  2841                 {
  2789                 DEBUG( "CWlmServer::CompleteExternalRequest() - GetAvailableIaps request handled by core" );    
  2842                 DEBUG( "CWlmServer::CompleteExternalRequest() - GetAvailableIaps request handled by core" );    
  2790 
  2843 
  2791                 scanList = reinterpret_cast<ScanList*>( aRequest.iParam2);
  2844                 scanList = reinterpret_cast<ScanList*>( aRequest.iParam2);
  2792                 coreIdList = reinterpret_cast<core_type_list_c<u32_t>*>( aRequest.iParam1 );
  2845                 coreAvailabilityList = reinterpret_cast<core_type_list_c<core_iap_availability_data_s>*>( aRequest.iParam1 );
  2793                 }
  2846                 }
  2794             else
  2847             else
  2795                 {
  2848                 {
  2796                 DEBUG( "CWlmServer::CompleteExternalRequest() - GetAvailableIaps request not handled by core" );    
  2849                 DEBUG( "CWlmServer::CompleteExternalRequest() - GetAvailableIaps request not handled by core" );    
  2797                 //Use the results of the triggering request to complete also this other request
  2850                 //Use the results of the triggering request to complete also this other request
  2798                 scanList = reinterpret_cast<ScanList*>( aTriggerRequest->iParam2);
  2851                 scanList = reinterpret_cast<ScanList*>( aTriggerRequest->iParam2);
  2799                 coreIdList = reinterpret_cast<core_type_list_c<u32_t>*>( aTriggerRequest->iParam1 );                
  2852                 coreAvailabilityList = reinterpret_cast<core_type_list_c<core_iap_availability_data_s>*>( aTriggerRequest->iParam1 );                
  2800                 }
  2853                 }
  2801 
  2854 
  2802             delete iapSsidList;
  2855             delete iapSsidList;
  2803             iapSsidList = NULL;
  2856             iapSsidList = NULL;
  2804             delete iapDataList;
  2857             delete iapDataList;
  2814                 TBool lostIaps( EFalse );
  2867                 TBool lostIaps( EFalse );
  2815                 
  2868                 
  2816                 if( aTriggerRequest == NULL )
  2869                 if( aTriggerRequest == NULL )
  2817                     {
  2870                     {
  2818                     iCache->UpdateAvailableNetworksList(
  2871                     iCache->UpdateAvailableNetworksList(
  2819                         *coreIdList,
  2872                         *coreAvailabilityList,
  2820                         networkList,
  2873                         networkList,
  2821                         newIaps,
  2874                         newIaps,
  2822                         lostIaps );
  2875                         lostIaps );
  2823                     }
  2876                     }
  2824                 networkList.Close();                
  2877                 networkList.Close();                
  2825 
  2878 
  2826                 TWlmAvailableIaps tmp;                
  2879                 TWlmAvailableIaps tmp = { 0 };
  2827                 TUint32* pInt = coreIdList->first();
  2880                 core_iap_availability_data_s* pInt = coreAvailabilityList->first();
  2828                 TInt idx = 0;
  2881                 if( isFiltered )
  2829                 while( pInt )
       
  2830                     {
  2882                     {
  2831                     DEBUG1( "CWlmServer::CompleteExternalRequest() - IAP %u is available",
  2883                     while( pInt && tmp.count < KWlmMaxAvailableIaps )
  2832                         *pInt );
  2884                         {
  2833                     tmp.iaps[ idx ] = *pInt;
  2885                         if( pInt->rcpi < iDeviceSettings.minRcpiForIapAvailability )
  2834                     idx++;
  2886                             {
  2835                     pInt = coreIdList->next();
  2887                             DEBUG3( "CWlmServer::CompleteExternalRequest() - IAP %u filtered, RCPI is too weak (%u vs %u)",
       
  2888                                 pInt->id, pInt->rcpi, iDeviceSettings.minRcpiForIapAvailability );
       
  2889                             }
       
  2890                         else if( iIapWeakList.Find( pInt->id ) != KErrNotFound )
       
  2891                             {
       
  2892                             if( pInt->rcpi < iDeviceSettings.rcpiTrigger )
       
  2893                                 {
       
  2894                                 DEBUG3( "CWlmServer::CompleteExternalRequest() - IAP %u filtered, in weak list and RCPI is too weak (%u vs %u)",
       
  2895                                     pInt->id, pInt->rcpi, iDeviceSettings.rcpiTrigger );                            
       
  2896                                 }
       
  2897                             else
       
  2898                                 {
       
  2899                                 DEBUG2( "CWlmServer::CompleteExternalRequest() - IAP %u is available, RCPI is %u, removed from weak list",
       
  2900                                     pInt->id, pInt->rcpi );
       
  2901                                 tmp.iaps[tmp.count].iapId = pInt->id;
       
  2902                                 tmp.iaps[tmp.count++].rcpi = pInt->rcpi;
       
  2903                                 iIapWeakList.Remove(
       
  2904                                     iIapWeakList.Find( pInt->id ) );
       
  2905                                 }
       
  2906                             }
       
  2907                         else
       
  2908                             {
       
  2909                             DEBUG2( "CWlmServer::CompleteExternalRequest() - IAP %u is available, RCPI is %u",
       
  2910                                 pInt->id, pInt->rcpi );
       
  2911                             tmp.iaps[tmp.count].iapId = pInt->id;
       
  2912                             tmp.iaps[tmp.count++].rcpi = pInt->rcpi;
       
  2913                             }
       
  2914                         pInt = coreAvailabilityList->next();
       
  2915                         }
  2836                     }
  2916                     }
  2837 
  2917                 else
  2838                 tmp.count = idx;
  2918                     {
  2839                 
  2919                     while( pInt && tmp.count < KWlmMaxAvailableIaps )
       
  2920                         {
       
  2921                         if( pInt->rcpi >= iDeviceSettings.rcpiTrigger &&
       
  2922                             iIapWeakList.Find( pInt->id ) != KErrNotFound )
       
  2923                             {                            
       
  2924                             DEBUG2( "CWlmServer::CompleteExternalRequest() - IAP %u is available, RCPI is %u, removed from weak list",
       
  2925                                 pInt->id, pInt->rcpi );
       
  2926                             iIapWeakList.Remove(
       
  2927                                 iIapWeakList.Find( pInt->id ) );
       
  2928                             }
       
  2929                         else
       
  2930                             {
       
  2931                             DEBUG2( "CWlmServer::CompleteExternalRequest() - IAP %u is available, RCPI is %u",
       
  2932                                 pInt->id, pInt->rcpi );
       
  2933                             }
       
  2934 
       
  2935                         tmp.iaps[tmp.count].iapId = pInt->id;
       
  2936                         tmp.iaps[tmp.count++].rcpi = pInt->rcpi;
       
  2937                         pInt = coreAvailabilityList->next();                        
       
  2938                         }
       
  2939                     }
       
  2940 
  2840                 if( IsSessionActive( aRequest ) )
  2941                 if( IsSessionActive( aRequest ) )
  2841                     {
  2942                     {
  2842                     TPckg<TWlmAvailableIaps> outPckg( tmp );
  2943                     TPckg<TWlmAvailableIaps> outPckg( tmp );
  2843                     aRequest.iMessage.Write( 0, outPckg );
  2944                     aRequest.iMessage.Write( 0, outPckg );
  2844                     }
  2945                     }
  2845                 if( aTriggerRequest == NULL )
  2946                 if( aTriggerRequest == NULL )
  2846                     {
  2947                     {
  2847                     DEBUG("CWlmServer::CompleteExternalRequest() - delete iapIdList" );
  2948                     DEBUG("CWlmServer::CompleteExternalRequest() - delete coreAvailabilityList" );
  2848                     delete coreIdList;	
  2949                     delete coreAvailabilityList;	
  2849                     }
  2950                     }
  2850                 else
  2951                 else
  2851                     {
  2952                     {
  2852                     // If this completed request was not the triggering request then there is no need
  2953                     // If this completed request was not the triggering request then there is no need
  2853                     // to cache anything. The triggering request results will be cached.
  2954                     // to cache anything. The triggering request results will be cached.
  2854                     delete completedIdList;
  2955                     delete completedAvailabilityList;
  2855                     delete completedScanList;
  2956                     delete completedScanList;
  2856                     }
  2957                     }
  2857 
  2958 
  2858                 // handle scan list
  2959                 // handle scan list
  2859                 if( aTriggerRequest == NULL )
  2960                 if( aTriggerRequest == NULL )
  2870             else
  2971             else
  2871                 {
  2972                 {
  2872                 // scan failed due to some reason: not caching anything
  2973                 // scan failed due to some reason: not caching anything
  2873                 if( aTriggerRequest == NULL )
  2974                 if( aTriggerRequest == NULL )
  2874                     {
  2975                     {
  2875                     delete coreIdList;
  2976                     delete coreAvailabilityList;
  2876                     delete scanList;
  2977                     delete scanList;
  2877                     }
  2978                     }
  2878                 else
  2979                 else
  2879                     {
  2980                     {
  2880                     // Delete only the lists of the completed request. Triggering request lists are
  2981                     // Delete only the lists of the completed request. Triggering request lists are
  2881                     // deleted later on when that request is actually handled.
  2982                     // deleted later on when that request is actually handled.
  2882                     delete completedIdList;
  2983                     delete completedAvailabilityList;
  2883                     delete completedScanList; 
  2984                     delete completedScanList; 
  2884                     }
  2985                     }
  2885                 }
  2986                 }
  2886             delete completedScanTime;
  2987             delete completedScanTime;
  2887             break;
  2988             break;
  3009              ieLength <= KMaxSSIDLength )
  3110              ieLength <= KMaxSSIDLength )
  3010             {
  3111             {
  3011             TWlanAvailableNetwork network;
  3112             TWlanAvailableNetwork network;
  3012             network.ssid.Copy( ieData, ieLength );
  3113             network.ssid.Copy( ieData, ieLength );
  3013             network.securityMode = info.SecurityMode();
  3114             network.securityMode = info.SecurityMode();
       
  3115             network.rcpi = info.RXLevel();
  3014             if( info.OperatingMode() == WlanOperatingModeInfra )
  3116             if( info.OperatingMode() == WlanOperatingModeInfra )
  3015                 {
  3117                 {
  3016                 network.networkType = Infrastructure;                
  3118                 network.networkType = Infrastructure;                
  3017                 }
  3119                 }
  3018             else
  3120             else
  3019                 {
  3121                 {
  3020                 network.networkType = Adhoc;
  3122                 network.networkType = Adhoc;
  3021                 }
  3123                 }
  3022 
  3124 
  3023             if ( aNetworkList.Find( network, isEqual ) == KErrNotFound )
  3125             TInt idx = aNetworkList.Find( network, isEqual ); 
       
  3126             if ( idx == KErrNotFound )
  3024                 {
  3127                 {
  3025                 DEBUG1S( "CWlmServer::GetNetworkList() - appending SSID ",
  3128                 DEBUG1S( "CWlmServer::GetNetworkList() - appending SSID ",
  3026                     ieLength, ieData );
  3129                     ieLength, ieData );
  3027                 aNetworkList.Append( network );
  3130                 aNetworkList.Append( network );
       
  3131                 }
       
  3132             else if( idx >= 0 &&
       
  3133                      aNetworkList[idx].rcpi < network.rcpi )
       
  3134                 {
       
  3135                 aNetworkList[idx].rcpi = network.rcpi;            
  3028                 }
  3136                 }
  3029             }
  3137             }
  3030         }
  3138         }
  3031 
  3139 
  3032     return KErrNone;
  3140     return KErrNone;
  3416         }
  3524         }
  3417 
  3525 
  3418     iapList.Close();
  3526     iapList.Close();
  3419 
  3527 
  3420     // Create output list
  3528     // Create output list
  3421     core_type_list_c<u32_t>* iapIdList = new core_type_list_c<u32_t>;
  3529     core_type_list_c<core_iap_availability_data_s>* iapAvailabilityList =
  3422     if( iapIdList == NULL )
  3530         new core_type_list_c<core_iap_availability_data_s>;
       
  3531     if( iapAvailabilityList == NULL )
  3423         {
  3532         {
  3424         DEBUG( "ERROR: Out of memory" );
  3533         DEBUG( "ERROR: Out of memory" );
  3425         delete iapDataList;
  3534         delete iapDataList;
  3426         delete iapSsidList;
  3535         delete iapSsidList;
  3427         return KErrNoMemory;
  3536         return KErrNoMemory;
  3432     if( scanList == NULL )
  3541     if( scanList == NULL )
  3433         {
  3542         {
  3434         DEBUG( "CWlmServer::BackgroundScanRequest() - Out of memory when instantiating ScanList" );
  3543         DEBUG( "CWlmServer::BackgroundScanRequest() - Out of memory when instantiating ScanList" );
  3435         delete iapDataList;
  3544         delete iapDataList;
  3436         delete iapSsidList;
  3545         delete iapSsidList;
  3437         delete iapIdList;
  3546         delete iapAvailabilityList;
  3438         return KErrNoMemory;
  3547         return KErrNoMemory;
  3439         }
  3548         }
  3440 
  3549 
  3441     TUint* scanTime = new TUint(
  3550     TUint* scanTime = new TUint(
  3442         CalculateScanStartTime( aScanStartInterval ) );
  3551         CalculateScanStartTime( aScanStartInterval ) );
  3444         {
  3553         {
  3445         DEBUG( "CWlmServer::BackgroundScanRequest() - unable to instantiate TUint" );
  3554         DEBUG( "CWlmServer::BackgroundScanRequest() - unable to instantiate TUint" );
  3446 
  3555 
  3447         delete iapDataList;
  3556         delete iapDataList;
  3448         delete iapSsidList;
  3557         delete iapSsidList;
  3449         delete iapIdList;
  3558         delete iapAvailabilityList;
  3450         delete scanList;
  3559         delete scanList;
  3451         return KErrNoMemory;
  3560         return KErrNoMemory;
  3452         }
  3561         }
  3453     
  3562     
  3454     // create mapping
  3563     // create mapping
  3455     SRequestMapEntry mapEntry;
  3564     SRequestMapEntry mapEntry;
  3456     mapEntry.iFunction = EGetAvailableIaps;
  3565     mapEntry.iFunction = EGetAvailableIaps;
  3457     mapEntry.iRequestId = KWlanIntCmdBackgroundScan;
  3566     mapEntry.iRequestId = KWlanIntCmdBackgroundScan;
  3458     mapEntry.iSessionId = 0;
  3567     mapEntry.iSessionId = 0;
  3459     mapEntry.iParam0 = iapDataList;
  3568     mapEntry.iParam0 = iapDataList;
  3460     mapEntry.iParam1 = iapIdList;
  3569     mapEntry.iParam1 = iapAvailabilityList;
  3461     mapEntry.iParam2 = scanList;
  3570     mapEntry.iParam2 = scanList;
  3462     mapEntry.iParam3 = iapSsidList;
  3571     mapEntry.iParam3 = iapSsidList;
       
  3572     mapEntry.iParam4 = reinterpret_cast<TAny*>( EFalse );
  3463     mapEntry.iTime = scanTime;
  3573     mapEntry.iTime = scanTime;
  3464     iRequestMap.Append( mapEntry );
  3574     iRequestMap.Append( mapEntry );
  3465     
  3575 
  3466     if( IsOnlyTimedScanRequestInRequestMap( mapEntry ) || *scanTime < iScanSchedulingTimerExpiration )
  3576     if( IsOnlyTimedScanRequestInRequestMap( mapEntry ) || *scanTime < iScanSchedulingTimerExpiration )
  3467         {
  3577         {
  3468         // Scan scheduling timer needs to be set again because this request needs the results earlier
  3578         // Scan scheduling timer needs to be set again because this request needs the results earlier
  3469         UpdateScanSchedulingTimer( *scanTime, mapEntry.iRequestId );
  3579         UpdateScanSchedulingTimer( *scanTime, mapEntry.iRequestId );
  3470         }
  3580         }
  3556          self->iRequestMap[index].iFunction == EGetAvailableIaps )
  3666          self->iRequestMap[index].iFunction == EGetAvailableIaps )
  3557         {
  3667         {
  3558         DEBUG( "CWlmServer::ScanSchedulingTimerExpired() - GetAvailableIaps requested" );
  3668         DEBUG( "CWlmServer::ScanSchedulingTimerExpired() - GetAvailableIaps requested" );
  3559 
  3669 
  3560         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 );
  3561         core_type_list_c<u32_t>* iapIdList =  reinterpret_cast<core_type_list_c<u32_t>*>( self->iRequestMap[index].iParam1 );
  3671         core_type_list_c<core_iap_availability_data_s>* iapAvailabilityList =
       
  3672             reinterpret_cast<core_type_list_c<core_iap_availability_data_s>*>( self->iRequestMap[index].iParam1 );
  3562         ScanList* scanList =  reinterpret_cast<ScanList*>( self->iRequestMap[index].iParam2 );
  3673         ScanList* scanList =  reinterpret_cast<ScanList*>( self->iRequestMap[index].iParam2 );
  3563         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 );
  3564         TUint* scanTime =  reinterpret_cast<TUint*>( self->iRequestMap[index].iTime );        
  3675         TUint* scanTime =  reinterpret_cast<TUint*>( self->iRequestMap[index].iTime );        
  3565         
  3676         
  3566         // If the device is roaming OR there are not WLAN IAPs defined in the device
  3677         // If the device is roaming OR there are not WLAN IAPs defined in the device
  3577                 self->iRequestMap[index].iMessage.Complete( KErrNone );
  3688                 self->iRequestMap[index].iMessage.Complete( KErrNone );
  3578                 }
  3689                 }
  3579 
  3690 
  3580             delete iapDataList;
  3691             delete iapDataList;
  3581             iapDataList = NULL;
  3692             iapDataList = NULL;
  3582             delete iapIdList;
  3693             delete iapAvailabilityList;
  3583             iapIdList = NULL;
  3694             iapAvailabilityList = NULL;
  3584             delete scanList;
  3695             delete scanList;
  3585             scanList = NULL;
  3696             scanList = NULL;
  3586             delete iapSsidList;
  3697             delete iapSsidList;
  3587             iapSsidList = NULL;
  3698             iapSsidList = NULL;
  3588             delete scanTime;
  3699             delete scanTime;
  3627         {
  3738         {
  3628         DEBUG( "CWlmServer::ScanSchedulingTimerExpired() - starting background scan, cancel timer" );
  3739         DEBUG( "CWlmServer::ScanSchedulingTimerExpired() - starting background scan, cancel timer" );
  3629         // pass request to core
  3740         // pass request to core
  3630         core_type_list_c<core_iap_data_s>* iapDataList = reinterpret_cast<core_type_list_c<core_iap_data_s>*>( self->iRequestMap[index].iParam0 );
  3741         core_type_list_c<core_iap_data_s>* iapDataList = reinterpret_cast<core_type_list_c<core_iap_data_s>*>( self->iRequestMap[index].iParam0 );
  3631         core_type_list_c<core_ssid_entry_s>* iapSsidList = reinterpret_cast<core_type_list_c<core_ssid_entry_s>*>( self->iRequestMap[index].iParam3 );
  3742         core_type_list_c<core_ssid_entry_s>* iapSsidList = reinterpret_cast<core_type_list_c<core_ssid_entry_s>*>( self->iRequestMap[index].iParam3 );
  3632         core_type_list_c<u32_t>* iapIdList = reinterpret_cast<core_type_list_c<u32_t>*>( self->iRequestMap[index].iParam1 );
  3743         core_type_list_c<core_iap_availability_data_s>* iapAvailabilityList =
       
  3744             reinterpret_cast<core_type_list_c<core_iap_availability_data_s>*>( self->iRequestMap[index].iParam1 );
  3633         ScanList* scanList = reinterpret_cast<ScanList*>( self->iRequestMap[index].iParam2 );
  3745         ScanList* scanList = reinterpret_cast<ScanList*>( self->iRequestMap[index].iParam2 );
  3634         
  3746         
  3635         self->iCoreServer->get_available_iaps(
  3747         self->iCoreServer->get_available_iaps(
  3636             self->iRequestMap[index].iRequestId,
  3748             self->iRequestMap[index].iRequestId,
  3637             isActiveScanAllowed,
  3749             isActiveScanAllowed,
  3638             *iapDataList,
  3750             *iapDataList,
  3639             *iapIdList,
  3751             *iapAvailabilityList,
  3640             iapSsidList,
  3752             iapSsidList,
  3641             *scanList );
  3753             *scanList );
  3642         
  3754         
  3643         self->iScanSchedulingTimer->Cancel();
  3755         self->iScanSchedulingTimer->Cancel();
  3644         }
  3756         }
  3666         DEBUG( "CWlmServer::ScanSchedulingTimerExpired() - starting GetAvailableIaps, cancel timer" );
  3778         DEBUG( "CWlmServer::ScanSchedulingTimerExpired() - starting GetAvailableIaps, cancel timer" );
  3667             
  3779             
  3668         // pass request to core
  3780         // pass request to core
  3669         core_type_list_c<core_iap_data_s>* iapDataList = reinterpret_cast<core_type_list_c<core_iap_data_s>*>( self->iRequestMap[index].iParam0 );
  3781         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_ssid_entry_s>* iapSsidList = reinterpret_cast<core_type_list_c<core_ssid_entry_s>*>( self->iRequestMap[index].iParam3 );
  3782         core_type_list_c<core_ssid_entry_s>* iapSsidList = reinterpret_cast<core_type_list_c<core_ssid_entry_s>*>( self->iRequestMap[index].iParam3 );
  3671         core_type_list_c<u32_t>* iapIdList = reinterpret_cast<core_type_list_c<u32_t>*>( self->iRequestMap[index].iParam1 );
  3783         core_type_list_c<core_iap_availability_data_s>* iapAvailabilityList =
       
  3784             reinterpret_cast<core_type_list_c<core_iap_availability_data_s>*>( self->iRequestMap[index].iParam1 );
  3672         ScanList* scanList = reinterpret_cast<ScanList*>( self->iRequestMap[index].iParam2 );
  3785         ScanList* scanList = reinterpret_cast<ScanList*>( self->iRequestMap[index].iParam2 );
  3673         
  3786         
  3674         self->iCoreServer->get_available_iaps(
  3787         self->iCoreServer->get_available_iaps(
  3675             self->iRequestMap[index].iRequestId,
  3788             self->iRequestMap[index].iRequestId,
  3676             isActiveScanAllowed,
  3789             isActiveScanAllowed,
  3677             *iapDataList,
  3790             *iapDataList,
  3678             *iapIdList,
  3791             *iapAvailabilityList,
  3679             iapSsidList,
  3792             iapSsidList,
  3680             *scanList );
  3793             *scanList );
  3681         
  3794         
  3682         self->iScanSchedulingTimer->Cancel();
  3795         self->iScanSchedulingTimer->Cancel();
  3683         }
  3796         }
  4075             iScanSchedulingTimer->Cancel();
  4188             iScanSchedulingTimer->Cancel();
  4076 
  4189 
  4077             DEBUG( "CWlmServer::CancelScan() - remove entry from request map" );
  4190             DEBUG( "CWlmServer::CancelScan() - remove entry from request map" );
  4078             SRequestMapEntry entry = iRequestMap[index];
  4191             SRequestMapEntry entry = iRequestMap[index];
  4079             delete reinterpret_cast<core_type_list_c<core_iap_data_s>*>( entry.iParam0 );
  4192             delete reinterpret_cast<core_type_list_c<core_iap_data_s>*>( entry.iParam0 );
  4080             delete reinterpret_cast<core_type_list_c<u32_t>*>( entry.iParam1 );
  4193             delete reinterpret_cast<core_type_list_c<core_iap_availability_data_s>*>( entry.iParam1 );
  4081             delete reinterpret_cast<ScanList*>( entry.iParam2);
  4194             delete reinterpret_cast<ScanList*>( entry.iParam2);
  4082             delete reinterpret_cast<core_type_list_c<core_ssid_entry_s>*>( entry.iParam3 );
  4195             delete reinterpret_cast<core_type_list_c<core_ssid_entry_s>*>( entry.iParam3 );
  4083             delete reinterpret_cast<TUint*>( entry.iTime );
  4196             delete reinterpret_cast<TUint*>( entry.iTime );
  4084             iRequestMap.Remove( index );
  4197             iRequestMap.Remove( index );
  4085 
  4198 
  4112                 DEBUG( "CWlmServer::CancelScan() - just remove the entry from the request map" );
  4225                 DEBUG( "CWlmServer::CancelScan() - just remove the entry from the request map" );
  4113                 
  4226                 
  4114                 DEBUG( "CWlmServer::CancelScan() - remove entry from request map" );
  4227                 DEBUG( "CWlmServer::CancelScan() - remove entry from request map" );
  4115                 SRequestMapEntry entry = iRequestMap[index];
  4228                 SRequestMapEntry entry = iRequestMap[index];
  4116                 delete reinterpret_cast<core_type_list_c<core_iap_data_s>*>( entry.iParam0 );
  4229                 delete reinterpret_cast<core_type_list_c<core_iap_data_s>*>( entry.iParam0 );
  4117                 delete reinterpret_cast<core_type_list_c<u32_t>*>( entry.iParam1 );
  4230                 delete reinterpret_cast<core_type_list_c<core_iap_availability_data_s>*>( entry.iParam1 );
  4118                 delete reinterpret_cast<ScanList*>( entry.iParam2);
  4231                 delete reinterpret_cast<ScanList*>( entry.iParam2);
  4119                 delete reinterpret_cast<core_type_list_c<core_ssid_entry_s>*>( entry.iParam3 );
  4232                 delete reinterpret_cast<core_type_list_c<core_ssid_entry_s>*>( entry.iParam3 );
  4120                 delete reinterpret_cast<TUint*>( entry.iTime );                
  4233                 delete reinterpret_cast<TUint*>( entry.iTime );                
  4121                 iRequestMap.Remove( index );
  4234                 iRequestMap.Remove( index );
  4122                 }
  4235                 }
  5014     {   
  5127     {   
  5015     DEBUG( "CWlmServer::HandleSsidListAvailabilityL()" );
  5128     DEBUG( "CWlmServer::HandleSsidListAvailabilityL()" );
  5016 
  5129 
  5017     ScanList* scanList =
  5130     ScanList* scanList =
  5018         reinterpret_cast<ScanList*>( aMapEntry.iParam2 );
  5131         reinterpret_cast<ScanList*>( aMapEntry.iParam2 );
  5019     core_type_list_c<u32_t>* iapIdList = 
  5132     core_type_list_c<core_iap_availability_data_s>* iapAvailabilityList = 
  5020         reinterpret_cast<core_type_list_c<u32_t>*>( aMapEntry.iParam1 );
  5133         reinterpret_cast<core_type_list_c<core_iap_availability_data_s>*>( aMapEntry.iParam1 );
  5021 
  5134 
  5022     /**
  5135     /**
  5023      * Go through the IAP list and find IAPs that haven't been found
  5136      * Go through the IAP list and find IAPs that haven't been found
  5024      * during GetAvailableIaps and have an SSID list attached.  
  5137      * during GetAvailableIaps and have an SSID list attached.  
  5025      */
  5138      */
  5026     RArray<TWlanLimitedIapData> attachedIapList;
  5139     RArray<TWlanLimitedIapData> attachedIapList;
  5027     CleanupClosePushL( attachedIapList );
  5140     CleanupClosePushL( attachedIapList );
  5028     const RArray<TWlanLimitedIapData>& cachedIapList(
  5141     const RArray<TWlanLimitedIapData>& cachedIapList(
  5029         iCache->CachedIapDataList() );    
  5142         iCache->CachedIapDataList() );
  5030     core_type_list_iterator_c<u32_t> iter( *iapIdList );
  5143     core_type_list_iterator_c<core_iap_availability_data_s> iter( *iapAvailabilityList );    
  5031     for( TInt idx( 0 ); idx < cachedIapList.Count(); ++idx )
  5144     for( TInt idx( 0 ); idx < cachedIapList.Count(); ++idx )
  5032         {
  5145         {
  5033         TBool isFound( EFalse );
  5146         TBool isFound( EFalse );
  5034         for( u32_t* item = iter.first(); !isFound && item; item = iter.next() )
  5147         for( core_iap_availability_data_s* item = iter.first(); !isFound && item; item = iter.next() )
  5035             {
  5148             {
  5036             if( *item == cachedIapList[idx].iapId )
  5149             if( item->id == cachedIapList[idx].iapId )
  5037                 {                
  5150                 {                
  5038                 isFound = ETrue;
  5151                 isFound = ETrue;
  5039                 }
  5152                 }
  5040             }
  5153             }
  5041         if( !isFound )
  5154         if( !isFound )
  5078         CleanupStack::PushL( ssidList );
  5191         CleanupStack::PushL( ssidList );
  5079         iSsidListDb->ReadListL(
  5192         iSsidListDb->ReadListL(
  5080             attachedIapList[idx].iapId,
  5193             attachedIapList[idx].iapId,
  5081             *ssidList );
  5194             *ssidList );
  5082         TBool isMatch( EFalse );
  5195         TBool isMatch( EFalse );
       
  5196         TUint rcpi( 0 );
  5083         for( TInt iidx( 0 ); !isMatch && iidx < networkList.Count(); ++iidx )
  5197         for( TInt iidx( 0 ); !isMatch && iidx < networkList.Count(); ++iidx )
  5084             {
  5198             {
  5085             if( attachedIapList[idx].networkType == networkList[iidx].networkType &&
  5199             if( attachedIapList[idx].networkType == networkList[iidx].networkType &&
  5086                 ssidList->IsInList( networkList[iidx].ssid ) )
  5200                 ssidList->IsInList( networkList[iidx].ssid ) )
  5087                 {
  5201                 {
       
  5202                 rcpi = networkList[iidx].rcpi;
  5088                 isMatch = ETrue;
  5203                 isMatch = ETrue;
  5089                 }
  5204                 }
  5090             }
  5205             }
  5091 
  5206 
  5092         if( isMatch )
  5207         if( isMatch )
  5094             DEBUG( "CWlmServer::HandleSsidListAvailabilityL() - matching SSID found" );
  5209             DEBUG( "CWlmServer::HandleSsidListAvailabilityL() - matching SSID found" );
  5095                 
  5210                 
  5096             /**
  5211             /**
  5097              * A match has been found, mark the IAP as available.
  5212              * A match has been found, mark the IAP as available.
  5098              */
  5213              */
  5099             u32_t* iapId = new (ELeave) u32_t(
  5214             core_iap_availability_data_s* data = new (ELeave) core_iap_availability_data_s;
  5100                 attachedIapList[idx].iapId );
  5215             data->id = attachedIapList[idx].iapId;
  5101             iapIdList->append(
  5216             data->rcpi = rcpi;
  5102                 iapId );
  5217             core_error_e ret = iapAvailabilityList->append(
       
  5218                 data );
       
  5219             if( ret != core_error_ok )
       
  5220                 {
       
  5221                 delete data;
       
  5222                 }
       
  5223             data = NULL;
  5103             }
  5224             }
  5104         else
  5225         else
  5105             {
  5226             {
  5106             DEBUG( "CWlmServer::HandleSsidListAvailabilityL() - no matching SSIDs found for IAP" );
  5227             DEBUG( "CWlmServer::HandleSsidListAvailabilityL() - no matching SSIDs found for IAP" );
  5107             }
  5228             }