wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlanmgmtimpl.cpp
changeset 39 3d23268b50f6
parent 36 1c425781161e
equal deleted inserted replaced
36:1c425781161e 39:3d23268b50f6
    14 * Description:  Implementation of wlan management API
    14 * Description:  Implementation of wlan management API
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 /*
    18 /*
    19 * %version: 32 %
    19 * %version: 34 %
    20 */
    20 */
    21 
    21 
    22 // INCLUDE FILES
    22 // INCLUDE FILES
    23 #include <e32std.h>
    23 #include <e32std.h>
    24 #include <ecom/implementationproxy.h>
    24 #include <ecom/implementationproxy.h>
   399     aAvailableIaps.Reset();
   399     aAvailableIaps.Reset();
   400 
   400 
   401     iCacheLifetime = KWlanMgmtDefaultCacheLifetime;
   401     iCacheLifetime = KWlanMgmtDefaultCacheLifetime;
   402     iMaxDelay = KWlanMgmtDefaultMaxDelay;
   402     iMaxDelay = KWlanMgmtDefaultMaxDelay;
   403 
   403 
   404 	TInt ret = iServer.GetAvailableIaps( iaps, iCacheLifetime, iMaxDelay );
   404 	TInt ret = iServer.GetAvailableIaps( iaps, iCacheLifetime, iMaxDelay, ETrue );
   405 	if ( ret != KErrNone )
   405 	if ( ret != KErrNone )
   406 		{
   406 		{
   407 		return ret;
   407 		return ret;
   408 		}   
   408 		}   
   409     for ( TUint idx( 0 ); idx < iaps.count; ++idx )
   409     for ( TUint idx( 0 ); idx < iaps.count; ++idx )
   410         {
   410         {
   411         aAvailableIaps.Append( iaps.iaps[idx] );
   411         aAvailableIaps.Append( iaps.iaps[idx].iapId );
   412         }
   412         }
   413 
   413 
   414     return KErrNone;
   414     return KErrNone;
   415     }
   415     }
   416 
   416 
   682 // CWlanMgmtImpl::ActivateExtendedNotificationsL
   682 // CWlanMgmtImpl::ActivateExtendedNotificationsL
   683 // ---------------------------------------------------------
   683 // ---------------------------------------------------------
   684 //
   684 //
   685 void CWlanMgmtImpl::ActivateExtendedNotificationsL(
   685 void CWlanMgmtImpl::ActivateExtendedNotificationsL(
   686     MWlanMgmtNotifications& aCallback,
   686     MWlanMgmtNotifications& aCallback,
   687     TUint aCallbackInterfaceVersion = KWlanCallbackInterfaceVersion )
   687     TUint aCallbackInterfaceVersion )
   688     {
   688     {
   689     TraceDump( INFO_LEVEL, ( _L( "CWlanMgmtImpl::ActivateExtendedNotificationsL()" ) ) );
   689     TraceDump( INFO_LEVEL, ( _L( "CWlanMgmtImpl::ActivateExtendedNotificationsL()" ) ) );
   690     iClientNotification = &aCallback;
   690     iClientNotification = &aCallback;
   691 
   691 
   692     if( !aCallbackInterfaceVersion ||
   692     if( !aCallbackInterfaceVersion ||
   794 TInt CWlanMgmtImpl::StartAggressiveBgScan(
   794 TInt CWlanMgmtImpl::StartAggressiveBgScan(
   795     TUint aInterval )
   795     TUint aInterval )
   796     {
   796     {
   797     TraceDump( INFO_LEVEL, ( _L( "CWlanMgmtImpl::StartAggressiveBgScan()" ) ) );
   797     TraceDump( INFO_LEVEL, ( _L( "CWlanMgmtImpl::StartAggressiveBgScan()" ) ) );
   798     return iServer.StartAggressiveBgScan( aInterval );
   798     return iServer.StartAggressiveBgScan( aInterval );
       
   799     }
       
   800 
       
   801 // ---------------------------------------------------------
       
   802 // CWlanMgmtImpl::GetAvailableIaps
       
   803 // ---------------------------------------------------------
       
   804 //
       
   805 void CWlanMgmtImpl::GetAvailableIaps(
       
   806     TInt& aCacheLifetime,
       
   807     TUint& aMaxDelay,
       
   808     TBool aFilteredResults,
       
   809     TRequestStatus& aStatus,
       
   810     RArray<TWlanIapAvailabilityData>& aAvailableIaps )
       
   811     {
       
   812     TraceDump( INFO_LEVEL, ( _L( "CWlanMgmtImpl::GetAvailableIaps() (async)" ) ) );
       
   813     
       
   814     aAvailableIaps.Reset();
       
   815     
       
   816     aStatus = KRequestPending;
       
   817     iPendingAvailableIapsStatus = &aStatus;    
       
   818     iAvailableIapsRequest = new CWlanAvailableIapsRequest( *this, iServer, aAvailableIaps, aCacheLifetime, aMaxDelay, aFilteredResults );
       
   819     if ( !iAvailableIapsRequest )
       
   820         {
       
   821         User::RequestComplete( iPendingAvailableIapsStatus, KErrNoMemory );
       
   822         iPendingAvailableIapsStatus = NULL;
       
   823         return;
       
   824         }
       
   825     iAvailableIapsRequest->IssueRequest();
   799     }
   826     }
   800 
   827 
   801 // ---------------------------------------------------------
   828 // ---------------------------------------------------------
   802 // CWlanMgmtImpl::ScanComplete
   829 // CWlanMgmtImpl::ScanComplete
   803 // ---------------------------------------------------------
   830 // ---------------------------------------------------------
  1067     TInt& aCacheLifetime,
  1094     TInt& aCacheLifetime,
  1068     TUint& aMaxDelay ) :
  1095     TUint& aMaxDelay ) :
  1069     CActive( CActive::EPriorityStandard ),
  1096     CActive( CActive::EPriorityStandard ),
  1070     iCallback( aCallback ),
  1097     iCallback( aCallback ),
  1071     iServer( aServer ),
  1098     iServer( aServer ),
  1072     iPendingAvailableIaps( aAvailableIaps ),
  1099     iPendingAvailableIapIds( &aAvailableIaps ),
       
  1100     iPendingAvailableIaps( NULL ),
  1073     iAvailableIapsBuf( iAvailableIaps ),
  1101     iAvailableIapsBuf( iAvailableIaps ),
  1074     iCacheLifetimeBuf( aCacheLifetime ),
  1102     iCacheLifetimeBuf( aCacheLifetime ),
  1075     iMaxDelayBuf( aMaxDelay )
  1103     iMaxDelayBuf( aMaxDelay ),
       
  1104     iFilteredResults( ETrue )
  1076     {
  1105     {
  1077     TraceDump( INFO_LEVEL, ( _L( "CWlanAvailableIapsRequest::CWlanAvailableIapsRequest()" ) ) );
  1106     TraceDump( INFO_LEVEL, ( _L( "CWlanAvailableIapsRequest::CWlanAvailableIapsRequest()" ) ) );
  1078     CActiveScheduler::Add( this );
  1107     CActiveScheduler::Add( this );
  1079     }
  1108     }
  1080 
  1109 
       
  1110 // C++ default constructor can NOT contain any code, that
       
  1111 // might leave.
       
  1112 //
       
  1113 CWlanAvailableIapsRequest::CWlanAvailableIapsRequest(
       
  1114     CWlanMgmtImpl& aCallback, 
       
  1115     RWLMServer& aServer,
       
  1116     RArray<TWlanIapAvailabilityData>& aAvailableIaps,
       
  1117     TInt& aCacheLifetime,
       
  1118     TUint& aMaxDelay,
       
  1119     TBool aFilteredResults ) :
       
  1120     CActive( CActive::EPriorityStandard ),
       
  1121     iCallback( aCallback ),
       
  1122     iServer( aServer ),
       
  1123     iPendingAvailableIapIds( NULL ),
       
  1124     iPendingAvailableIaps( &aAvailableIaps ),
       
  1125     iAvailableIapsBuf( iAvailableIaps ),
       
  1126     iCacheLifetimeBuf( aCacheLifetime ),
       
  1127     iMaxDelayBuf( aMaxDelay ),
       
  1128     iFilteredResults( aFilteredResults )
       
  1129     {
       
  1130     TraceDump( INFO_LEVEL, ( _L( "CWlanAvailableIapsRequest::CWlanAvailableIapsRequest()" ) ) );
       
  1131     CActiveScheduler::Add( this );
       
  1132     }
       
  1133 
  1081 // Destructor
  1134 // Destructor
  1082 CWlanAvailableIapsRequest::~CWlanAvailableIapsRequest()
  1135 CWlanAvailableIapsRequest::~CWlanAvailableIapsRequest()
  1083     {
  1136     {
  1084     TraceDump( INFO_LEVEL, ( _L( "CWlanAvailableIapsRequest::CWlanAvailableIapsRequest()" ) ) );
  1137     TraceDump( INFO_LEVEL, ( _L( "CWlanAvailableIapsRequest::CWlanAvailableIapsRequest()" ) ) );
  1085     Cancel();
  1138     Cancel();
       
  1139     iPendingAvailableIapIds = NULL;
       
  1140     iPendingAvailableIaps = NULL;
  1086     }
  1141     }
  1087 
  1142 
  1088 // ---------------------------------------------------------
  1143 // ---------------------------------------------------------
  1089 // CWlanAvailableIapsRequest::IssueRequest
  1144 // CWlanAvailableIapsRequest::IssueRequest
  1090 // ---------------------------------------------------------
  1145 // ---------------------------------------------------------
  1091 //
  1146 //
  1092 void CWlanAvailableIapsRequest::IssueRequest()
  1147 void CWlanAvailableIapsRequest::IssueRequest()
  1093     {
  1148     {
  1094     TraceDump( INFO_LEVEL, ( _L( "CWlanAvailableIapsRequest::IssueRequest()" ) ) );
  1149     TraceDump( INFO_LEVEL, ( _L( "CWlanAvailableIapsRequest::IssueRequest()" ) ) );
  1095     iServer.GetAvailableIaps( iAvailableIapsBuf, iCacheLifetimeBuf, iMaxDelayBuf, iStatus );
  1150     iServer.GetAvailableIaps( iAvailableIapsBuf, iCacheLifetimeBuf, iMaxDelayBuf, iFilteredResults, iStatus );
  1096     SetActive();
  1151     SetActive();
  1097     }
  1152     }
  1098 
  1153 
  1099 // ---------------------------------------------------------
  1154 // ---------------------------------------------------------
  1100 // CWlanAvailableIapsRequest::RunL
  1155 // CWlanAvailableIapsRequest::RunL
  1101 // ---------------------------------------------------------
  1156 // ---------------------------------------------------------
  1102 //
  1157 //
  1103 void CWlanAvailableIapsRequest::RunL()
  1158 void CWlanAvailableIapsRequest::RunL()
  1104     {
  1159     {
  1105     TraceDump( INFO_LEVEL, ( _L( "CWlanAvailableIapsRequest::RunL()" ) ) );
  1160     TraceDump( INFO_LEVEL, ( _L( "CWlanAvailableIapsRequest::RunL()" ) ) );
  1106     for ( TUint idx( 0 ); idx < iAvailableIaps.count; ++idx )
  1161     if( iPendingAvailableIapIds )
  1107         {
  1162         {
  1108         iPendingAvailableIaps.Append( iAvailableIaps.iaps[idx] );
  1163         for ( TUint idx( 0 ); idx < iAvailableIaps.count; ++idx )
       
  1164             {
       
  1165             iPendingAvailableIapIds->Append( iAvailableIaps.iaps[idx].iapId );
       
  1166             }
       
  1167         }
       
  1168     else if( iPendingAvailableIaps )
       
  1169         {
       
  1170         for ( TUint idx( 0 ); idx < iAvailableIaps.count; ++idx )
       
  1171             {
       
  1172             TWlanIapAvailabilityData tmp;
       
  1173             tmp.iIapId = iAvailableIaps.iaps[idx].iapId;
       
  1174             // RCPI -> RSSI CONVERSION
       
  1175             // Note: conversion may round the result by 0.5 units
       
  1176             tmp.iRssi = ( 110 - ( iAvailableIaps.iaps[idx].rcpi / 2 ) ); 
       
  1177             iPendingAvailableIaps->Append( tmp );
       
  1178             }        
  1109         }
  1179         }
  1110     iCallback.AvailableIapsComplete( iStatus.Int() );
  1180     iCallback.AvailableIapsComplete( iStatus.Int() );
  1111     }
  1181     }
  1112 
  1182 
  1113 // ---------------------------------------------------------
  1183 // ---------------------------------------------------------