wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlmserver.cpp
branchRCL_3
changeset 5 51a71243e562
parent 3 6524e815f76f
child 6 e0f767079796
equal deleted inserted replaced
3:6524e815f76f 5:51a71243e562
    14 * Description:  Server class of wlan engine
    14 * Description:  Server class of wlan engine
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 /*
    18 /*
    19 * %version: 97 %
    19 * %version: 99 %
    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>
   145     iRequestTriggeringScanning( 0 ),
   145     iRequestTriggeringScanning( 0 ),
   146     iCoreHandlingScanRequest( EFalse ),
   146     iCoreHandlingScanRequest( EFalse ),
   147     iPowerSaveMode( EWlanPowerSaveAutomatic ),
   147     iPowerSaveMode( EWlanPowerSaveAutomatic ),
   148     iPowerSaveEnabled( EFalse ),
   148     iPowerSaveEnabled( EFalse ),
   149     iSsidListDb( NULL ),
   149     iSsidListDb( NULL ),
   150     iShowBrokenPowerSaveNote( ETrue ),
       
   151     iBrokenPowerSaveNotifierWaiter( NULL ),
       
   152     iBgScanProvider( NULL ),
   150     iBgScanProvider( NULL ),
   153     iTimerServices( NULL ),
   151     iTimerServices( NULL ),
   154     iAggressiveScanningAfterLinkLoss( EFalse )
   152     iAggressiveScanningAfterLinkLoss( EFalse )
   155     {
   153     {
   156     }
   154     }
   232         callback, CActive::EPriorityStandard );
   230         callback, CActive::EPriorityStandard );
   233 
   231 
   234     // Create SSID list storage.
   232     // Create SSID list storage.
   235     iSsidListDb = CWlanSsidListDb::NewL();
   233     iSsidListDb = CWlanSsidListDb::NewL();
   236     
   234     
   237     // Initialise Broken Power Save Note handling
       
   238     TCallBack cb( HandleBrokenPowerSaveNoteClosed, this );
       
   239     iBrokenPowerSaveNotifierWaiter = CWlanCbWaiter::NewL( cb );
       
   240     
       
   241     iTimerServices = CWlanTimerServices::NewL();
   235     iTimerServices = CWlanTimerServices::NewL();
   242     
   236     
   243     iBgScanProvider = CWlanBgScan::NewL( static_cast<MWlanScanResultProvider&>( *this ), *iTimerServices );
   237     iBgScanProvider = CWlanBgScan::NewL( static_cast<MWlanScanResultProvider&>( *this ), *iTimerServices );
   244     
   238     
   245     // Initialize Platform interface and publish mac address
   239     // Initialize Platform interface and publish mac address
   293     delete iPlatform;
   287     delete iPlatform;
   294     iRequestMap.Close();
   288     iRequestMap.Close();
   295     delete iCoreAsynchCb;
   289     delete iCoreAsynchCb;
   296     delete iScanSchedulingTimer;
   290     delete iScanSchedulingTimer;
   297     delete iSsidListDb;
   291     delete iSsidListDb;
   298     delete iBrokenPowerSaveNotifierWaiter;
       
   299     iBrokenPowerSaveNotifier.Close();
       
   300 
       
   301     if ( iEapolClient )
   292     if ( iEapolClient )
   302         {
   293         {
   303         delete iEapolClient;
   294         delete iEapolClient;
   304         iEapolClient = NULL;
   295         iEapolClient = NULL;
   305         }
   296         }
  1263         iapList.Close();
  1254         iapList.Close();
  1264 
  1255 
  1265         return;
  1256         return;
  1266         }
  1257         }
  1267 
  1258 
  1268     /**
       
  1269      * If maxDelay is not infinite, background scanning isn't enabled
       
  1270      * and there are no WLAN IAPs defined, scanning isn't needed at all.
       
  1271      */
       
  1272     if ( maxDelayPckg() != KWlmInfiniteScanDelay &&
       
  1273          !iBgScanProvider->IsBgScanEnabled() &&
       
  1274          !iapList.Count() )
       
  1275         {
       
  1276         DEBUG( "CWlmServer::GetAvailableIaps() - no WLAN IAPs defined, skipping scanning" );
       
  1277 
       
  1278         TWlmAvailableIaps tmp = { 0 };
       
  1279         TPckg<TWlmAvailableIaps> outPckg( tmp );
       
  1280         aMessage.Write( 0, outPckg );
       
  1281         aMessage.Complete( KErrNone );
       
  1282         iapList.Close();
       
  1283 
       
  1284         return;
       
  1285         }
       
  1286 
       
  1287     // Create list for WLAN IAP data
  1259     // Create list for WLAN IAP data
  1288     core_type_list_c<core_iap_data_s>* iapDataList = new core_type_list_c<core_iap_data_s>;
  1260     core_type_list_c<core_iap_data_s>* iapDataList = new core_type_list_c<core_iap_data_s>;
  1289     if( iapDataList == NULL )
  1261     if( iapDataList == NULL )
  1290         {
  1262         {
  1291         DEBUG( "CWlmServer::GetAvailableIaps() - unable to instance core_iap_data_s list" );
  1263         DEBUG( "CWlmServer::GetAvailableIaps() - unable to instance core_iap_data_s list" );
  1542         DEBUG1( "CWlmServer::UpdateWlanSettings() - update_device_settings() failed with %u",
  1514         DEBUG1( "CWlmServer::UpdateWlanSettings() - update_device_settings() failed with %u",
  1543             ret );
  1515             ret );
  1544 
  1516 
  1545         return TWlanConversionUtil::ConvertErrorCode( ret );
  1517         return TWlanConversionUtil::ConvertErrorCode( ret );
  1546         }
  1518         }
  1547     
       
  1548     // Store show broken power save note value
       
  1549     iShowBrokenPowerSaveNote = settings.showBrokenPowerSaveNote;
       
  1550     
       
  1551     DEBUG( "CWlmServer::UpdateWlanSettings() - returning" );
  1519     DEBUG( "CWlmServer::UpdateWlanSettings() - returning" );
  1552 
  1520 
  1553     return KErrNone;
  1521     return KErrNone;
  1554     }
  1522     }
  1555 
  1523 
  1831                         }
  1799                         }
  1832                     
  1800                     
  1833                     // if background scan is on, this call will cause a background scan
  1801                     // if background scan is on, this call will cause a background scan
  1834 					// when the background scan is completed, the icon is updated
  1802 					// when the background scan is completed, the icon is updated
  1835                     iBgScanProvider->NotConnected();
  1803                     iBgScanProvider->NotConnected();
  1836                     
       
  1837                     if ( iBrokenPowerSaveNotifierWaiter->IsActive() )
       
  1838                         {
       
  1839                         // cancelling the notifier will cause the iBrokenPowerSaveNotifierWaiter
       
  1840                         // to be cancelled as well
       
  1841                         iBrokenPowerSaveNotifier.CancelNotifier( KUidWlanPowerSaveTestNote );
       
  1842                         }
       
  1843                     break;
  1804                     break;
  1844                 case EWlanStateInfrastructure:
  1805                 case EWlanStateInfrastructure:
  1845                     DEBUG( "CWlmServer::notify() - STATE: EWlanStateInfrastructure" );
  1806                     DEBUG( "CWlmServer::notify() - STATE: EWlanStateInfrastructure" );
  1846                     iIsRoaming = EFalse;
  1807                     iIsRoaming = EFalse;
  1847                     SetIconState( EWlmIconStatusConnected );
  1808                     SetIconState( EWlmIconStatusConnected );
  1900             DEBUG( "CWlmServer::notify() - STATE: EWlmNotifyAcTrafficModeChanged<ind>" );
  1861             DEBUG( "CWlmServer::notify() - STATE: EWlmNotifyAcTrafficModeChanged<ind>" );
  1901             break;
  1862             break;
  1902         case EWlmNotifyAcTrafficStatusChanged:
  1863         case EWlmNotifyAcTrafficStatusChanged:
  1903             DEBUG( "CWlmServer::notify() - STATE: EWlmNotifyAcTrafficStatusChanged<ind>" );
  1864             DEBUG( "CWlmServer::notify() - STATE: EWlmNotifyAcTrafficStatusChanged<ind>" );
  1904             break;
  1865             break;
  1905         case EWlmNotifyBrokenPowerSaveTestFailed:
       
  1906             DEBUG( "CWlmServer::notify() - STATE: EWlmNotifyBrokenPowerSaveTestFailed<ind>" );
       
  1907             
       
  1908             DEBUG1( "CWlmServer::notify() - iShowBrokenPowerSaveNote: %d",
       
  1909                     static_cast<TInt>( iShowBrokenPowerSaveNote ) );
       
  1910             
       
  1911             if ( iShowBrokenPowerSaveNote )
       
  1912                 {
       
  1913                 if ( !iBrokenPowerSaveNotifierWaiter->IsActive() )
       
  1914                     {
       
  1915                     TInt err = iBrokenPowerSaveNotifier.Connect();
       
  1916                     DEBUG1( "CWlmServer::notify() - iNotifier.Connect() returned %d", err );
       
  1917                     if ( err == KErrNone )
       
  1918                         {
       
  1919                         iBrokenPowerSaveNotifier.StartNotifierAndGetResponse( iBrokenPowerSaveNotifierWaiter->RequestStatus(),
       
  1920                                         KUidWlanPowerSaveTestNote, KNullDesC8(), iBrokenPowerSaveNotifierReply );
       
  1921 
       
  1922                         iBrokenPowerSaveNotifierWaiter->IssueRequest();
       
  1923                         }
       
  1924                     }
       
  1925 #ifdef _DEBUG
       
  1926                 else
       
  1927                     {
       
  1928                     DEBUG( "CWlmServer::notify() - Notifier already active on the screen" );
       
  1929                     }
       
  1930 #endif
       
  1931                 }
       
  1932             break;    
       
  1933         default:
  1866         default:
  1934             break;
  1867             break;
  1935         }
  1868         }
  1936     }
       
  1937 
       
  1938 // ---------------------------------------------------------
       
  1939 // CWlmServer::BrokenPowerSaveNoteClosed
       
  1940 // ---------------------------------------------------------
       
  1941 //
       
  1942 TInt CWlmServer::HandleBrokenPowerSaveNoteClosed(
       
  1943     TAny *aThisPtr )
       
  1944     {
       
  1945     DEBUG( "CWlmServer::HandleBrokenPowerSaveNoteClosed()" );
       
  1946     
       
  1947     CWlmServer* self = static_cast<CWlmServer*>( aThisPtr );
       
  1948 
       
  1949     ASSERT( self );
       
  1950     ASSERT( self->iBrokenPowerSaveNotifierWaiter );
       
  1951 
       
  1952     // close the notifier
       
  1953     self->iBrokenPowerSaveNotifier.Close();
       
  1954     
       
  1955     // check the request's completion status
       
  1956     TInt err = self->iBrokenPowerSaveNotifierWaiter->RequestStatus().Int();
       
  1957     switch ( err )
       
  1958         {
       
  1959         case KErrNotFound:
       
  1960             {
       
  1961             DEBUG( "CWlmServer::HandleBrokenPowerSaveNoteClosed() - Notifier not found, returning" );
       
  1962             return err;   
       
  1963             }
       
  1964         case KErrCancel:
       
  1965             {
       
  1966             DEBUG( "CWlmServer::HandleBrokenPowerSaveNoteClosed() - Notifier cancelled, returning" );
       
  1967             return err;        
       
  1968             }
       
  1969         default:
       
  1970             {
       
  1971             // flow through            
       
  1972             }
       
  1973         }
       
  1974     
       
  1975     self->iShowBrokenPowerSaveNote = self->iBrokenPowerSaveNotifierReply() ? EFalse : ETrue;
       
  1976 
       
  1977     // re-use err variable
       
  1978     TRAP( err, self->StoreWlanCenRepKeyValueL( KWlanShowBrokenPowerSaveNote, self->iShowBrokenPowerSaveNote ) );
       
  1979     if ( err != KErrNone )
       
  1980         {
       
  1981         DEBUG1( "CWlmServer::HandleBrokenPowerSaveNoteClosed() - failed to update CenRep, error code %d", err );
       
  1982         return err;
       
  1983         }
       
  1984     
       
  1985     DEBUG1( "CWlmServer::HandleBrokenPowerSaveNoteClosed() - iShowBrokenPowerSaveNote value (%d) stored to CenRep",
       
  1986             static_cast<TInt>( self->iShowBrokenPowerSaveNote ) );
       
  1987         
       
  1988     return err;
       
  1989     }
  1869     }
  1990 
  1870 
  1991 // ---------------------------------------------------------
  1871 // ---------------------------------------------------------
  1992 // CWlmServer::NotifyChangedPsmSrvMode
  1872 // CWlmServer::NotifyChangedPsmSrvMode
  1993 // ---------------------------------------------------------
  1873 // ---------------------------------------------------------
  3623         
  3503         
  3624         DEBUG( "CWlmServer::ScanSchedulingTimerExpired() - message completed with empty scan results" );
  3504         DEBUG( "CWlmServer::ScanSchedulingTimerExpired() - message completed with empty scan results" );
  3625         return KErrNone;        
  3505         return KErrNone;        
  3626         }
  3506         }
  3627     
  3507     
  3628     // If roaming is ongoing, scanning is not started for GetAvailableIaps. 
  3508     // If the command is GetAvailableIaps
  3629     if ( self->iRequestMap[index].iRequestId >= KWlanExtCmdBase && 
  3509     if ( self->iRequestMap[index].iRequestId >= KWlanExtCmdBase && 
  3630          self->iRequestMap[index].iFunction == EGetAvailableIaps && 
  3510          self->iRequestMap[index].iFunction == EGetAvailableIaps )
  3631          self->IsRoaming() )
  3511         {
  3632         {
  3512         DEBUG( "CWlmServer::ScanSchedulingTimerExpired() - GetAvailableIaps requested" );
  3633         DEBUG( "CWlmServer::ScanSchedulingTimerExpired() - GetAvailableIaps, roam in progress, returning empty iap list" );
       
  3634 
  3513 
  3635         core_type_list_c<core_iap_data_s>* iapDataList = reinterpret_cast<core_type_list_c<core_iap_data_s>*>( self->iRequestMap[index].iParam0 );
  3514         core_type_list_c<core_iap_data_s>* iapDataList = reinterpret_cast<core_type_list_c<core_iap_data_s>*>( self->iRequestMap[index].iParam0 );
  3636         core_type_list_c<u32_t>* iapIdList =  reinterpret_cast<core_type_list_c<u32_t>*>( self->iRequestMap[index].iParam1 );
  3515         core_type_list_c<u32_t>* iapIdList =  reinterpret_cast<core_type_list_c<u32_t>*>( self->iRequestMap[index].iParam1 );
  3637         ScanList* scanList =  reinterpret_cast<ScanList*>( self->iRequestMap[index].iParam2 );
  3516         ScanList* scanList =  reinterpret_cast<ScanList*>( self->iRequestMap[index].iParam2 );
  3638         core_type_list_c<core_ssid_entry_s>* iapSsidList =  reinterpret_cast<core_type_list_c<core_ssid_entry_s>*>( self->iRequestMap[index].iParam3 );
  3517         core_type_list_c<core_ssid_entry_s>* iapSsidList =  reinterpret_cast<core_type_list_c<core_ssid_entry_s>*>( self->iRequestMap[index].iParam3 );
  3639         TTime* scanTime =  reinterpret_cast<TTime*>( self->iRequestMap[index].iTime );        
  3518         TTime* scanTime =  reinterpret_cast<TTime*>( self->iRequestMap[index].iTime );        
  3640         
  3519         
  3641         // Only the triggering request is completed and then scan scheduling timer is set again 
  3520         // If the device is roaming OR there are not WLAN IAPs defined in the device
  3642         if( self->IsSessionActive( self->iRequestMap[index] ) )
  3521         // --> return empty list
  3643             {
  3522         if( self->IsRoaming() || iapDataList->count() == 0 )
  3644             TWlmAvailableIaps tmp = { 0 };
  3523             {
  3645             TPckg<TWlmAvailableIaps> outPckg( tmp );
  3524             DEBUG( "CWlmServer::ScanSchedulingTimerExpired() - Device is roaming or no IAPs defined, returning empty list" );
  3646             self->iRequestMap[index].iMessage.Write( 0, outPckg );
  3525             // Only the triggering request is completed and then scan scheduling timer is set again 
  3647             self->iRequestMap[index].iMessage.Complete( KErrNone );
  3526             if( self->IsSessionActive( self->iRequestMap[index] ) )
  3648             }
  3527                 {
  3649 
  3528                 TWlmAvailableIaps tmp = { 0 };
  3650         delete iapDataList;
  3529                 TPckg<TWlmAvailableIaps> outPckg( tmp );
  3651         iapDataList = NULL;
  3530                 self->iRequestMap[index].iMessage.Write( 0, outPckg );
  3652         delete iapIdList;
  3531                 self->iRequestMap[index].iMessage.Complete( KErrNone );
  3653         iapIdList = NULL;
  3532                 }
  3654         delete scanList;
  3533 
  3655         scanList = NULL;
  3534             delete iapDataList;
  3656         delete iapSsidList;
  3535             iapDataList = NULL;
  3657         iapSsidList = NULL;
  3536             delete iapIdList;
  3658         delete scanTime;
  3537             iapIdList = NULL;
  3659         scanTime = NULL;
  3538             delete scanList;
       
  3539             scanList = NULL;
       
  3540             delete iapSsidList;
       
  3541             iapSsidList = NULL;
       
  3542             delete scanTime;
       
  3543             scanTime = NULL;
  3660         
  3544         
  3661         self->iRequestMap.Remove( index );
  3545             self->iRequestMap.Remove( index );
  3662 
  3546 
  3663         if( self->FindNextTimedScanSchedulingRequest( indexNextScan ) )
  3547             if( self->FindNextTimedScanSchedulingRequest( indexNextScan ) )
  3664             {
  3548                 {
  3665             TTime* nextScanTime = reinterpret_cast<TTime*>( self->iRequestMap[indexNextScan].iTime );
  3549                 TTime* nextScanTime = reinterpret_cast<TTime*>( self->iRequestMap[indexNextScan].iTime );
  3666             self->UpdateScanSchedulingTimer( *nextScanTime, self->iRequestMap[indexNextScan].iRequestId );
  3550                 self->UpdateScanSchedulingTimer( *nextScanTime, self->iRequestMap[indexNextScan].iRequestId );
  3667             }
  3551                 }
  3668         
  3552         
  3669         DEBUG( "CWlmServer::ScanSchedulingTimerExpired() - message completed with empty iap list" );
  3553             DEBUG( "CWlmServer::ScanSchedulingTimerExpired() - message completed with empty iap list" );
  3670         return KErrNone;        
  3554             return KErrNone;        
       
  3555             }
  3671         }
  3556         }
  3672 
  3557 
  3673     // If triggering request is background scan and WLAN connection exist, background scan is skipped
  3558     // If triggering request is background scan and WLAN connection exist, background scan is skipped
  3674     if( self->iRequestMap[index].iRequestId == KWlanIntCmdBackgroundScan && 
  3559     if( self->iRequestMap[index].iRequestId == KWlanIntCmdBackgroundScan && 
  3675     	self->iConnectionState != EWlanStateNotConnected )
  3560     	self->iConnectionState != EWlanStateNotConnected )