wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlanscanresultcache.cpp
branchRCL_3
changeset 14 13838cf40350
parent 0 c40eb8fe8501
equal deleted inserted replaced
12:af3fb27c7511 14:13838cf40350
    13 *
    13 *
    14 * Description:  Factory class for timers
    14 * Description:  Factory class for timers
    15 *
    15 *
    16 */
    16 */
    17 
    17 
       
    18 /*
       
    19 * %version: 13 %
       
    20 */
    18 
    21 
    19 #include "wlanscanresultcache.h"
    22 #include "wlanscanresultcache.h"
    20 #include "am_debug.h"
    23 #include "am_debug.h"
    21 
    24 
    22 // ============================ MEMBER FUNCTIONS ===============================
    25 // ============================ MEMBER FUNCTIONS ===============================
   117 // -----------------------------------------------------------------------------
   120 // -----------------------------------------------------------------------------
   118 // CWlanScanResultCache::UpdateAvailableNetworksList
   121 // CWlanScanResultCache::UpdateAvailableNetworksList
   119 // -----------------------------------------------------------------------------
   122 // -----------------------------------------------------------------------------
   120 //
   123 //
   121 void CWlanScanResultCache::UpdateAvailableNetworksList(
   124 void CWlanScanResultCache::UpdateAvailableNetworksList(
   122     core_type_list_c<u32_t>& aIapIdList,
   125     core_type_list_c<core_iap_availability_data_s>& aIapAvailabilityList,
   123     RArray<TWlanAvailableNetwork>& aNetworkList,
   126     RArray<TWlanAvailableNetwork>& aNetworkList,
   124     TBool& aNewIapsAvailable,
   127     TBool& aNewIapsAvailable,
   125     TBool& aOldIapsLost )
   128     TBool& aOldIapsLost )
   126     {
   129     {
   127     DEBUG( "CWlanScanResultCache::UpdateAvailableNetworksList()" ); 
   130     DEBUG( "CWlanScanResultCache::UpdateAvailableNetworksList()" ); 
   128 
   131 
   129     DEBUG1( "CWlanScanResultCache::UpdateAvailableNetworksList() - %u IAP(s) available",
   132     DEBUG1( "CWlanScanResultCache::UpdateAvailableNetworksList() - %u IAP(s) available",
   130         aIapIdList.count() );
   133         aIapAvailabilityList.count() );
   131     DEBUG1( "CWlanScanResultCache::UpdateAvailableNetworksList() - %u IAP(s) previously available",
   134     DEBUG1( "CWlanScanResultCache::UpdateAvailableNetworksList() - %u IAP(s) previously available",
   132         iAvailableIapList.Count() ); 
   135         iAvailableIapList.Count() ); 
   133     DEBUG1( "CWlanScanResultCache::UpdateAvailableNetworksList() - %u networks(s) available",
   136     DEBUG1( "CWlanScanResultCache::UpdateAvailableNetworksList() - %u networks(s) available",
   134         aNetworkList.Count() );
   137         aNetworkList.Count() );
   135     DEBUG1( "CWlanScanResultCache::UpdateAvailableNetworksList() - %u networks(s) previously available",
   138     DEBUG1( "CWlanScanResultCache::UpdateAvailableNetworksList() - %u networks(s) previously available",
   138     const TInt oldIapCount( iAvailableIapList.Count() );
   141     const TInt oldIapCount( iAvailableIapList.Count() );
   139     const TInt newNetworkCount( aNetworkList.Count() );
   142     const TInt newNetworkCount( aNetworkList.Count() );
   140     const TInt oldNetworkCount( iAvailableNetworkList.Count() );
   143     const TInt oldNetworkCount( iAvailableNetworkList.Count() );
   141     aNewIapsAvailable = EFalse;
   144     aNewIapsAvailable = EFalse;
   142     aOldIapsLost = EFalse;
   145     aOldIapsLost = EFalse;
   143     TIdentityRelation<TWlanAvailableNetwork> isEqual( CWlanScanResultCache::IsNetworkEqual );
   146     TIdentityRelation<TWlanAvailableNetwork> isNetworkEqual( CWlanScanResultCache::IsNetworkEqual );
       
   147     TIdentityRelation<TWlmAvailabilityData> isIapEqual( CWlanScanResultCache::IsIapEqual );
   144 
   148 
   145     // Iterate through previously available IAPs to find lost IAPs.    
   149     // Iterate through previously available IAPs to find lost IAPs.    
   146     TInt idx( 0 );
   150     TInt idx( 0 );
   147     //while( idx < oldIapCount && !aOldIapsLost )
   151     //while( idx < oldIapCount && !aOldIapsLost )
   148     while( idx < oldIapCount )
   152     while( idx < oldIapCount )
   149         {
   153         {
   150         const TUint32* newId = aIapIdList.first();
   154         const core_iap_availability_data_s* newIap = aIapAvailabilityList.first();
   151 
   155 
   152         while( newId )
   156         while( newIap )
   153             {
   157             {
   154             if( *newId == iAvailableIapList[idx] )
   158             if( newIap->id == iAvailableIapList[idx].iapId )
   155                 {
   159                 {
   156                 break;
   160                 break;
   157                 }
   161                 }
   158 
   162 
   159             newId = aIapIdList.next();
   163             newIap = aIapAvailabilityList.next();
   160             }
   164             }
   161 
   165 
   162         if( !newId )
   166         if( !newIap )
   163             {
   167             {
   164             DEBUG1( "CWlanScanResultCache::UpdateAvailableNetworksList() - old IAP %u has been lost",
   168             DEBUG1( "CWlanScanResultCache::UpdateAvailableNetworksList() - old IAP %u has been lost",
   165                 iAvailableIapList[idx] );
   169                 iAvailableIapList[idx] );
   166             aOldIapsLost = ETrue;
   170             aOldIapsLost = ETrue;
   167             }
   171             }
   168 
   172 
   169         ++idx;
   173         ++idx;
   170         }
   174         }
   171 
   175 
   172     // Iterate through available IAPs to find new IAPs.    
   176     // Iterate through available IAPs to find new IAPs.    
   173     const TUint32* newId = aIapIdList.first();
   177     const core_iap_availability_data_s* newIap = aIapAvailabilityList.first();
   174     //while( newId && !aNewIapsAvailable )
   178     //while( newId && !aNewIapsAvailable )
   175     while( newId )
   179     while( newIap )
   176         {
   180         {
   177         if ( iAvailableIapList.Find( *newId ) == KErrNotFound )
   181         TWlmAvailabilityData tmp;
       
   182         tmp.iapId = newIap->id;
       
   183         tmp.rcpi = newIap->rcpi;
       
   184         if ( iAvailableIapList.Find( tmp, isIapEqual ) == KErrNotFound )
   178             {
   185             {
   179             DEBUG1( "CWlanScanResultCache::UpdateAvailableNetworksList() - new IAP %u has been detected",
   186             DEBUG1( "CWlanScanResultCache::UpdateAvailableNetworksList() - new IAP %u has been detected",
   180                 *newId );
   187                 newIap->id );
   181             aNewIapsAvailable = ETrue;
   188             aNewIapsAvailable = ETrue;
   182             }
   189             }
   183 
   190         
   184         newId = aIapIdList.next();
   191         newIap = aIapAvailabilityList.next();
   185         }
   192         }
   186 
   193 
   187     // Iterate through previously available networks to find lost networks.
   194     // Iterate through previously available networks to find lost networks.
   188     idx = 0;
   195     idx = 0;
   189     //while ( idx < oldNetworkCount && !aOldIapsLost )
   196     //while ( idx < oldNetworkCount && !aOldIapsLost )
   190     while ( idx < oldNetworkCount )
   197     while ( idx < oldNetworkCount )
   191         {
   198         {
   192         if ( aNetworkList.Find( iAvailableNetworkList[idx], isEqual ) == KErrNotFound )
   199         if ( aNetworkList.Find( iAvailableNetworkList[idx], isNetworkEqual ) == KErrNotFound )
   193             {
   200             {
   194             DEBUG1S( "CWlanScanResultCache::UpdateAvailableNetworksList() - old network has been lost, SSID ",
   201             DEBUG1S( "CWlanScanResultCache::UpdateAvailableNetworksList() - old network has been lost, SSID ",
   195                 iAvailableNetworkList[idx].ssid.Length(), iAvailableNetworkList[idx].ssid.Ptr() );
   202                 iAvailableNetworkList[idx].ssid.Length(), iAvailableNetworkList[idx].ssid.Ptr() );
   196             aOldIapsLost = ETrue;
   203             aOldIapsLost = ETrue;
   197             }
   204             }
   201     // Iterate through available networks to find new networks.        
   208     // Iterate through available networks to find new networks.        
   202     idx = 0;
   209     idx = 0;
   203     //while( idx < newNetworkCount && !aNewIapsAvailable )
   210     //while( idx < newNetworkCount && !aNewIapsAvailable )
   204     while( idx < newNetworkCount )
   211     while( idx < newNetworkCount )
   205         {
   212         {
   206         if ( iAvailableNetworkList.Find( aNetworkList[idx], isEqual ) == KErrNotFound )
   213         if ( iAvailableNetworkList.Find( aNetworkList[idx], isNetworkEqual ) == KErrNotFound )
   207             {
   214             {
   208             DEBUG1S( "CWlanScanResultCache::UpdateAvailableNetworksList() - new network has been detected, SSID ",
   215             DEBUG1S( "CWlanScanResultCache::UpdateAvailableNetworksList() - new network has been detected, SSID ",
   209                 aNetworkList[idx].ssid.Length(), aNetworkList[idx].ssid.Ptr() );            
   216                 aNetworkList[idx].ssid.Length(), aNetworkList[idx].ssid.Ptr() );            
   210             aNewIapsAvailable = ETrue;
   217             aNewIapsAvailable = ETrue;
   211             }
   218             }
   215     // Update the list
   222     // Update the list
   216     iAvailableIapList.Reset();
   223     iAvailableIapList.Reset();
   217     iAvailableNetworkList.Reset();
   224     iAvailableNetworkList.Reset();
   218     iIapListTimeStamp.HomeTime();
   225     iIapListTimeStamp.HomeTime();
   219         
   226         
   220     newId = aIapIdList.first();
   227     newIap = aIapAvailabilityList.first();
   221     while( newId )
   228     while( newIap )
   222         {
   229         {
   223         iAvailableIapList.Append( *newId );
   230         TWlmAvailabilityData tmp;
   224         newId = aIapIdList.next();
   231         tmp.iapId = newIap->id;
       
   232         tmp.rcpi = newIap->rcpi;
       
   233         iAvailableIapList.Append( tmp );
       
   234         newIap = aIapAvailabilityList.next();
   225         }
   235         }
   226         
   236         
   227     idx = 0;
   237     idx = 0;
   228     while( idx < newNetworkCount )
   238     while( idx < newNetworkCount )
   229         {
   239         {
   234 
   244 
   235 // -----------------------------------------------------------------------------
   245 // -----------------------------------------------------------------------------
   236 // CWlanScanResultCache::AvailableIaps
   246 // CWlanScanResultCache::AvailableIaps
   237 // -----------------------------------------------------------------------------
   247 // -----------------------------------------------------------------------------
   238 //
   248 //
   239 RArray<TUint>* CWlanScanResultCache::AvailableIaps(
   249 RArray<TWlmAvailabilityData>* CWlanScanResultCache::AvailableIaps(
   240     RArray<TWlanLimitedIapData>& aIapList,
   250     RArray<TWlanLimitedIapData>& aIapList,
   241     TUint aCacheLifetime )
   251     TUint aCacheLifetime )
   242     {
   252     {
   243     DEBUG( "CWlanScanResultCache::AvailableIaps()" );
   253     DEBUG( "CWlanScanResultCache::AvailableIaps()" );
   244 
   254 
   382     const TWlanAvailableNetwork& aSecond )
   392     const TWlanAvailableNetwork& aSecond )
   383     {
   393     {
   384     if ( aFirst.ssid != aSecond.ssid ||
   394     if ( aFirst.ssid != aSecond.ssid ||
   385          aFirst.networkType != aSecond.networkType ||
   395          aFirst.networkType != aSecond.networkType ||
   386          aFirst.securityMode != aSecond.securityMode )
   396          aFirst.securityMode != aSecond.securityMode )
       
   397         {
       
   398         return EFalse;
       
   399         }
       
   400 
       
   401     return ETrue;
       
   402     }
       
   403 
       
   404 // -----------------------------------------------------------------------------
       
   405 // CWlanScanResultCache::IsIapEqual
       
   406 // -----------------------------------------------------------------------------
       
   407 //
       
   408 TBool CWlanScanResultCache::IsIapEqual(
       
   409     const TWlmAvailabilityData& aFirst,
       
   410     const TWlmAvailabilityData& aSecond )
       
   411     {
       
   412     if ( aFirst.iapId != aSecond.iapId )
   387         {
   413         {
   388         return EFalse;
   414         return EFalse;
   389         }
   415         }
   390 
   416 
   391     return ETrue;
   417     return ETrue;