coreapplicationuis/SysAp/Src/SysApFeatureManager.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Thu, 19 Aug 2010 10:05:08 +0300
branchRCL_3
changeset 18 0818dd463d41
parent 2 7645e9ce10dc
child 19 924385140d98
permissions -rw-r--r--
Revision: 201031 Kit: 201033

/*
* Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies). 
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  CSysApFeatureManager implementation.
*
*/


// INCLUDES

#include <e32svr.h> // RDebug
#include <featmgr.h>
#include "SysApFeatureManager.h"
#include "SysAp.hrh"
#include <centralrepository.h>
#include "CoreApplicationUIsPrivateCRKeys.h"
#include <hwrmlight.h>
#include <AknUtils.h>


// ============================ MEMBER FUNCTIONS ==============================

// ----------------------------------------------------------------------------
// CSysApFeatureManager::NewL() 
// ----------------------------------------------------------------------------
CSysApFeatureManager* CSysApFeatureManager::NewL()
    {
    CSysApFeatureManager* self = new(ELeave) CSysApFeatureManager;
    CleanupStack::PushL(self);
    self->ConstructL();
    CleanupStack::Pop( self );
    return self;
    }

// ----------------------------------------------------------------------------
// CSysApFeatureManager::ConstructL() 
// ----------------------------------------------------------------------------
void CSysApFeatureManager::ConstructL()
    {
    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL()") ) );
    FeatureManager::InitializeLibL();
    iFeatMgrActive = ETrue;
    
    iSimSupported = FeatureManager::FeatureSupported( KFeatureIdSimCard );
    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: SIM card supported=%d"), iSimSupported ) );

    iOfflineModeSupported = FeatureManager::FeatureSupported( KFeatureIdOfflineMode );
    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: Offline mode supported=%d"), iOfflineModeSupported ) );
    
    iCoverDisplaySupported = FeatureManager::FeatureSupported( KFeatureIdCoverDisplay );
    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: Cover display supported=%d"), iCoverDisplaySupported ) );
    
    iGripNotSupported = FeatureManager::FeatureSupported( KFeatureIdKeypadNoSlider );
    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: iGripNotSupported=%d"), iGripNotSupported ) );
    
//    iSlideSupported = FeatureManager::FeatureSupported( KFeatureIdFfCommonSlide );
		iSlideSupported = EFalse;
    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: iSlideSupported=%d"), iSlideSupported ) );
    
    iLocationPrivacySupported = FeatureManager::FeatureSupported( KFeatureIdPrivacyFramework );
    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: Location Privacy supported=%d"), iLocationPrivacySupported ) );

    iMMCSupported = FeatureManager::FeatureSupported( KFeatureIdMmc );
    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: MMC supported=%d"), iMMCSupported ) );
        
    iMMCHotSwapSupported = FeatureManager::FeatureSupported( KFeatureIdMmcHotswap );
    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: MMC HotSwap supported=%d"), iMMCHotSwapSupported ) );
    
    iStarterExtensionsSupported = FeatureManager::FeatureSupported( KFeatureIdExtendedStartup );
    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: Starter Extensions supported=%d"), iStarterExtensionsSupported ) );

    iCameraSupported = FeatureManager::FeatureSupported( KFeatureIdCamera );
    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: Camera supported=%d"), iCameraSupported ) );

    iBtSupported = FeatureManager::FeatureSupported( KFeatureIdBt );
    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: Bluetooth supported=%d"), iBtSupported ) );

    iLockSupported = FeatureManager::FeatureSupported( KFeatureIdMmcLock );
    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: Memory card lock supported=%d"), iLockSupported ) );
    
    iEject = FeatureManager::FeatureSupported( KFeatureIdMmcEject );
    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: Memory card sw eject supported=%d"), iEject ) );
    
    iPowerSaveSupported = FeatureManager::FeatureSupported( KFeatureIdPowerSave );
    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: Power save supported=%d"), iPowerSaveSupported ) );

    iNoPowerKeySupported = FeatureManager::FeatureSupported( KFeatureIdNoPowerkey );
    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: No power key supported=%d"), iNoPowerKeySupported ) );
    
    iFmTxSupported = FeatureManager::FeatureSupported( KFeatureIdFmtx );
    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: FM TX supported=%d"), iFmTxSupported ) );

    iPenEnabled = AknLayoutUtils::PenEnabled();
    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: Pen enabled=%d"), iPenEnabled ) );
    
    iVmbxCallDivertIconSupported = FeatureManager::FeatureSupported( KFeatureIdVmbxCallDivertIcon );
    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: VMBX call divert icon supported=%d"), iVmbxCallDivertIconSupported ) );
    
    iTouchUnlockStrokeSupported = FeatureManager::FeatureSupported( KFeatureIdFfTouchUnlockStroke );
    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: Touch unlock stroke supported=%d"), iTouchUnlockStrokeSupported ) );
    
    iFmTxRdsTextSupported = FeatureManager::FeatureSupported( KFeatureIdFfFmtxRdsText );
    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: FM TX RDS-TEXT supported=%d"), iFmTxRdsTextSupported ) );
    
    iPowerKeyIsLockKey = FeatureManager::FeatureSupported( KFeatureIdFfPowerKeyAsKeyguard );
    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: Power Key as keyguard supported=%d"), iPowerKeyIsLockKey ) );

    iGanSupported = FeatureManager::FeatureSupported( KFeatureIdFfGenericAccessNetwork );
    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: GAN supported=%d"), iGanSupported ) );
    
    CRepository* repository = NULL;
    
    TRAPD( err, repository = CRepository::NewL( KCRUidCoreApplicationUIsConf ) );
    
    if ( err == KErrNone )
        {
        err = repository->Get( KCoreAppUIsSysAp, iSysApFeatures );
        if ( err != KErrNone || iSysApFeatures < 0 ) // ERROR
            {
            TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: ERROR: %d, KCoreAppUIsSysAp=%d"), err, iSysApFeatures ) );
            iSysApFeatures = 0;
            }

        TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: KCoreAppUIsSysAp=%d"), iSysApFeatures ) );

        err = repository->Get( KCoreAppUIsHotSwapMemoryCardHatch, iHatchSupported );
        if ( err != KErrNone || iHatchSupported < 0 ) // ERROR
            {
            TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: ERROR: %d, KCoreAppUIsHotSwapMemoryCardHatch=%d"), err, iHatchSupported ) );
            iHatchSupported = EFalse;
            }
            
        err = repository->Get( KCoreAppUIsLockedStateLights, iLockedStateLightsSupported );
        
        if ( err != KErrNone || iLockedStateLightsSupported < 0 ) // ERROR
            {
            TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: ERROR: %d, KCoreAppUIsLightsLocked=%d"), err, iLockedStateLightsSupported ) );
            iLockedStateLightsSupported = EFalse;
            iLockedStateLightsIntensity = KHWRMDefaultIntensity;
            }
        
        if ( iLockedStateLightsSupported ) // get intensity only if configuration is supported
            {
            err = repository->Get( KCoreAppUIsLockedStateLightsIntensity, iLockedStateLightsIntensity );
            
            if ( err != KErrNone || iLockedStateLightsIntensity < KHWRMLightMinIntensity || iLockedStateLightsIntensity > KHWRMLightMaxIntensity )
                {
                TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: ERROR: %d, KCoreAppUIsLightsLockedIntensity=%d"), err, iLockedStateLightsIntensity ) );
                iLockedStateLightsIntensity = KHWRMDefaultIntensity;
                }
            }        
        }
    else
        {
        TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: open KCRUidCoreApplicatinUIsConf failed, err=%d"), err ) );
        }        
    
    delete repository;
    }

// ----------------------------------------------------------------------------
// CSysApFeatureManager::CSysApFeatureManager()
// ----------------------------------------------------------------------------

CSysApFeatureManager::CSysApFeatureManager() : iFeatMgrActive( EFalse ),
                                               iSysApFeatures( 0 ),
                                               iEject( EFalse ),
                                               iLockSupported( EFalse ),
                                               iHatchSupported( EFalse ),
                                               iLockedStateLightsSupported( EFalse ),
                                               iLockedStateLightsIntensity( KHWRMDefaultIntensity ),
                                               iMMCSupported( EFalse ),
                                               iMMCHotSwapSupported( EFalse ),
                                               iOfflineModeSupported( EFalse ),
                                               iStarterExtensionsSupported( EFalse ),
                                               iLocationPrivacySupported( EFalse ),
                                               iCameraSupported( EFalse ),
                                               iBtSupported( EFalse ),
                                               iSimSupported( ETrue ),
                                               iGripNotSupported( ETrue ),
                                               iPowerSaveSupported( EFalse ),
                                               iNoPowerKeySupported( EFalse ),
                                               iFmTxSupported( EFalse ),
                                               iPenEnabled( EFalse ),
                                               iVmbxCallDivertIconSupported( EFalse ),
                                               iTouchUnlockStrokeSupported( EFalse ),
                                               iFmTxRdsTextSupported( EFalse ),
                                               iPowerKeyIsLockKey ( EFalse ),
                                               iGanSupported( EFalse )
    {
    }

// ----------------------------------------------------------------------------
// CSysApFeatureManager::~CSysApFeatureManager() 
// ----------------------------------------------------------------------------

CSysApFeatureManager::~CSysApFeatureManager() 
    {
    if ( iFeatMgrActive )
        {
        FeatureManager::UnInitializeLib();    
        }
    }

// ----------------------------------------------------------------------------
// CSysApFeatureManager::FeatureVariationCheckDone() 
// ----------------------------------------------------------------------------
//
void CSysApFeatureManager::FeatureVariationCheckDone()
    {
    TRACES( RDebug::Print( _L("CSysApFeatureManager::FeatureVariationCheckDone()") ) );
    FeatureManager::UnInitializeLib();
    iFeatMgrActive = EFalse;
    }


// ----------------------------------------------------------------------------
// CSysApFeatureManager::Supported() 
// ----------------------------------------------------------------------------

TInt CSysApFeatureManager::Supported( TInt aSysApFeatureId )
    {
    return aSysApFeatureId & iSysApFeatures;
    }

// ----------------------------------------------------------------------------
// CSysApFeatureManager::EjectRequiredInPowerMenu()
// ----------------------------------------------------------------------------
TBool CSysApFeatureManager::EjectRequiredInPowerMenu()
    {
    return iEject;
    }

// ----------------------------------------------------------------------------
// CSysApFeatureManager::MemoryCardLockSupported()
// ----------------------------------------------------------------------------
TBool CSysApFeatureManager::MemoryCardLockSupported()
    {
    return iLockSupported;
    }

// ----------------------------------------------------------------------------
// CSysApFeatureManager::MemoryCardHatchSupported()
// ----------------------------------------------------------------------------
TBool CSysApFeatureManager::MemoryCardHatchSupported()
    {
    return iHatchSupported;
    }

// ----------------------------------------------------------------------------
// CSysApFeatureManager::LockedStateLightsSupported()
// ----------------------------------------------------------------------------
TBool CSysApFeatureManager::LockedStateLightsSupported()
    {
    return iLockedStateLightsSupported;
    }

// ----------------------------------------------------------------------------
// CSysApFeatureManager::LockedStateLightsIntensity()
// ----------------------------------------------------------------------------
TInt CSysApFeatureManager::LockedStateLightsIntensity()
    {
    return iLockedStateLightsIntensity;
    }

// ----------------------------------------------------------------------------
// CSysApFeatureManager::LockedStateLightsIntensity()
// ----------------------------------------------------------------------------
//  
TBool CSysApFeatureManager::MmcSupported() const
    {
    return iMMCSupported;
    }

// ----------------------------------------------------------------------------
// CSysApFeatureManager::LockedStateLightsIntensity()
// ----------------------------------------------------------------------------
//
TBool CSysApFeatureManager::MmcHotSwapSupported() const
    {
    return iMMCHotSwapSupported;
    }

// ----------------------------------------------------------------------------
// CSysApFeatureManager::OfflineModeSupported()
// ----------------------------------------------------------------------------
//
TBool CSysApFeatureManager::OfflineModeSupported() const
    {
    return iOfflineModeSupported;
    }

// ----------------------------------------------------------------------------
// CSysApFeatureManager::StarterExtensionsSupported()
// ----------------------------------------------------------------------------
//
TBool CSysApFeatureManager::StarterExtensionsSupported() const
    {
    return iStarterExtensionsSupported;
    }

// ----------------------------------------------------------------------------
// CSysApFeatureManager::LocationPrivacySupported()
// ----------------------------------------------------------------------------
//
TBool CSysApFeatureManager::LocationPrivacySupported() const
    {
    return iLocationPrivacySupported;
    }

// ----------------------------------------------------------------------------
// CSysApFeatureManager::CameraSupported()
// ----------------------------------------------------------------------------
//
TBool CSysApFeatureManager::CameraSupported() const
    {
    return iCameraSupported;
    }

// ----------------------------------------------------------------------------
// CSysApFeatureManager::BtSupported()
// ----------------------------------------------------------------------------
//
TBool CSysApFeatureManager::BtSupported() const
    {
    return iBtSupported;
    }

// ----------------------------------------------------------------------------
// CSysApFeatureManager::SimSupported()
// ----------------------------------------------------------------------------
//
TBool CSysApFeatureManager::SimSupported() const
    {
    return iSimSupported;
    }

// ----------------------------------------------------------------------------
// CSysApFeatureManager::GripNotSupported()
// ----------------------------------------------------------------------------
//
TBool CSysApFeatureManager::GripNotSupported() const
    {
    return iGripNotSupported;
    }

// ----------------------------------------------------------------------------
// CSysApFeatureManager::SlideSupported()
// ----------------------------------------------------------------------------
//
TBool CSysApFeatureManager::SlideSupported() const
    {
    return iSlideSupported;
    }
    
// ----------------------------------------------------------------------------
// CSysApFeatureManager::CoverDisplaySupported()
// ----------------------------------------------------------------------------
//
TBool CSysApFeatureManager::CoverDisplaySupported() const
    {
    return iCoverDisplaySupported;
    }

// ----------------------------------------------------------------------------
// CSysApFeatureManager::PowerSaveSupported()
// ----------------------------------------------------------------------------
//
TBool CSysApFeatureManager::PowerSaveSupported() const
    {
    return iPowerSaveSupported;
    }
    
// ----------------------------------------------------------------------------
// CSysApFeatureManager::NoPowerKeySupported()
// ----------------------------------------------------------------------------
//  
TBool CSysApFeatureManager::NoPowerKeySupported() const
    {
    return iNoPowerKeySupported;
    }

// ----------------------------------------------------------------------------
// CSysApFeatureManager::FmTxSupported()
// ----------------------------------------------------------------------------
//    
TBool CSysApFeatureManager::FmTxSupported() const
    {
    return iFmTxSupported;
    }

// ----------------------------------------------------------------------------
// CSysApFeatureManager::PenEnabled()
// ----------------------------------------------------------------------------
//
TBool CSysApFeatureManager::PenEnabled() const
    {
    return iPenEnabled;
    }

// ----------------------------------------------------------------------------
// CSysApFeatureManager::VmbxCallDivertIconSupported()
// ----------------------------------------------------------------------------
//     
TBool CSysApFeatureManager::VmbxCallDivertIconSupported() const
    {
    return iVmbxCallDivertIconSupported;
    }        

// ----------------------------------------------------------------------------
// CSysApFeatureManager::TouchUnlockStrokeSupported()
// ----------------------------------------------------------------------------
//     
TBool CSysApFeatureManager::TouchUnlockStrokeSupported() const
    {
    return iTouchUnlockStrokeSupported;
    }

// ----------------------------------------------------------------------------
// CSysApFeatureManager::FmTxRdsTextSupported()
// ----------------------------------------------------------------------------
//     
TBool CSysApFeatureManager::FmTxRdsTextSupported() const
    {
    return iFmTxRdsTextSupported;
    }

//-----------------------------------------------------------------------------
// CSysApFeatureManager::PowerKeyIsLockKey()
//-----------------------------------------------------------------------------
//
TBool CSysApFeatureManager::PowerKeyIsLockKey() const
    {
    return iPowerKeyIsLockKey;
    }

// ----------------------------------------------------------------------------
// CSysApFeatureManager::GanSupported()
// ----------------------------------------------------------------------------
//  
TBool CSysApFeatureManager::GanSupported() const
    {
    return iGanSupported;
    }        

// End of File