sl@0: // Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: sl@0: sl@0: // INCLUDE FILES sl@0: #include sl@0: #include "featmgrtlsdata.h" sl@0: #include "featmgrdebug.h" sl@0: sl@0: // ============================= LOCAL FUNCTIONS =============================== sl@0: sl@0: static CFeatMgrTlsData* TlsData( ) sl@0: { sl@0: CFeatMgrTlsData* tlsData = STATIC_CAST( CFeatMgrTlsData*, Dll::Tls() ); sl@0: _LIT( KPanicCategory, "RFeatureControl" ); sl@0: __ASSERT_ALWAYS( tlsData, User::Panic( KPanicCategory, EPanicBadHandle ) ); sl@0: sl@0: return tlsData; sl@0: } sl@0: sl@0: sl@0: EXPORT_C TInt GetClientCount( ) sl@0: { sl@0: CFeatMgrTlsData* tlsData = STATIC_CAST( CFeatMgrTlsData*, Dll::Tls() ); sl@0: if (tlsData) sl@0: { sl@0: return tlsData->ClientCount(); sl@0: } sl@0: else sl@0: { sl@0: return 0; sl@0: } sl@0: } sl@0: sl@0: // ============================ MEMBER FUNCTIONS =============================== sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CFeatureManager::CFeatureManager() sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: sl@0: CFeatMgrTlsData::CFeatMgrTlsData() : sl@0: iClientCount(0) sl@0: { sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CFeatureManager::ConstructL sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CFeatMgrTlsData::ConstructL() sl@0: { sl@0: // Connect to Feature Manager server sl@0: FUNC_LOG sl@0: TInt err( iFeatMgrClient.Connect() ); sl@0: User::LeaveIfError(err); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CFeatureManager::NewL() sl@0: // Two-phased constructor. sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: CFeatMgrTlsData* CFeatMgrTlsData::NewL() sl@0: { sl@0: CFeatMgrTlsData* self = new( ELeave ) CFeatMgrTlsData(); sl@0: CleanupStack::PushL( self ); sl@0: self->ConstructL(); sl@0: CleanupStack::Pop( self ); sl@0: return self; sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CFeatureManager::~CFeatMgrTlsData sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: CFeatMgrTlsData::~CFeatMgrTlsData() sl@0: { sl@0: FUNC_LOG sl@0: iFeatMgrClient.Close(); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CFeatMgrTlsData::CanBeFreed() sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: TBool CFeatMgrTlsData::CanBeFreed() const sl@0: { sl@0: if (iClientCount <= 0) sl@0: { sl@0: INFO_LOG1( "FeatMgr: TLS can be freed, clients(%d)", iClientCount ); sl@0: return ETrue; sl@0: } sl@0: else sl@0: { sl@0: INFO_LOG1( "FeatMgr: TLS can NOT be freed, clients(%d)", iClientCount ); sl@0: return EFalse; sl@0: } sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CFeatMgrTlsData::IncreaseClientCount() sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CFeatMgrTlsData::IncreaseClientCount() sl@0: { sl@0: ++iClientCount; sl@0: INFO_LOG1( "FeatMgr: TLS increase, clients now(%d)", iClientCount ); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CFeatMgrTlsData::DecreaseClientCount() sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: sl@0: void CFeatMgrTlsData::DecreaseClientCount() sl@0: { sl@0: --iClientCount; sl@0: INFO_LOG1( "FeatMgr: TLS decrease, clients now(%d)", iClientCount ); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CFeatMgrTlsData::ClientCount() sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: TInt CFeatMgrTlsData::ClientCount() sl@0: { sl@0: return iClientCount; sl@0: } sl@0: // ----------------------------------------------------------------------------- sl@0: // CFeatMgrTlsData::FeatureSupported() sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: TInt CFeatMgrTlsData::FeatureSupported( TFeatureEntry& aFeature ) const sl@0: { sl@0: return iFeatMgrClient.FeatureSupported( aFeature ); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CFeatMgrTlsData::FeaturesSupported() sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: TInt CFeatMgrTlsData::FeaturesSupported( RFeatureArray& aFeatures ) sl@0: { sl@0: return iFeatMgrClient.FeaturesSupported( aFeatures ); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CFeatMgrTlsData::EnableFeature() sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: TInt CFeatMgrTlsData::EnableFeature( TUid aFeature ) const sl@0: { sl@0: return iFeatMgrClient.EnableFeature( aFeature ); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CFeatMgrTlsData::DisableFeature() sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: TInt CFeatMgrTlsData::DisableFeature( TUid aFeature ) const sl@0: { sl@0: return iFeatMgrClient.DisableFeature( aFeature ); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CFeatMgrTlsData::SetFeature() sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: TInt CFeatMgrTlsData::SetFeature( TUid aFeature, TBool aEnabled, TInt aData ) const sl@0: { sl@0: return iFeatMgrClient.SetFeature( aFeature, aEnabled, aData ); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CFeatMgrTlsData::SetFeature() sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: TInt CFeatMgrTlsData::SetFeature( TUid aFeature, TInt aData ) const sl@0: { sl@0: return iFeatMgrClient.SetFeature( aFeature, aData ); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CFeatMgrTlsData::AddFeature() sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: TInt CFeatMgrTlsData::AddFeature( TFeatureEntry aFeature ) const sl@0: { sl@0: return iFeatMgrClient.AddFeature( aFeature ); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CFeatMgrTlsData::DeleteFeature() sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: TInt CFeatMgrTlsData::DeleteFeature( TUid aFeature ) const sl@0: { sl@0: return iFeatMgrClient.DeleteFeature( aFeature ); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CFeatMgrTlsData::ListSupportedFeaturesL() sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CFeatMgrTlsData::ListSupportedFeaturesL( RFeatureUidArray& aSupportedFeatures ) sl@0: { sl@0: iFeatMgrClient.ListSupportedFeaturesL( aSupportedFeatures ); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CFeatMgrTlsData::ReRequestNotification(TUid&, TRequestStatus&) sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CFeatMgrTlsData::ReRequestNotification( TUid& aFeatUid, TRequestStatus& aStatus ) sl@0: { sl@0: iFeatMgrClient.ReRequestNotification( aFeatUid, aStatus ); sl@0: } sl@0: sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CFeatMgrTlsData::RequestNotification(RFeatureUidArray&, TUid&, TRequestStatus&) sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: TInt CFeatMgrTlsData::RequestNotification( RFeatureUidArray& aFeatures, TUid& aFeatUid, sl@0: TRequestStatus& aStatus ) sl@0: { sl@0: return iFeatMgrClient.RequestNotification( aFeatures, aFeatUid, aStatus ); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CFeatMgrTlsData::RequestNotifyCancel(RFeatureUidArray&, TRequestStatus&) sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: TInt CFeatMgrTlsData::RequestNotifyCancel( TUid aFeature ) const sl@0: { sl@0: return iFeatMgrClient.RequestNotifyCancel( aFeature ); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CFeatMgrTlsData::RequestNotifyCancelAll(RFeatureUidArray&, TRequestStatus&) sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: TInt CFeatMgrTlsData::RequestNotifyCancelAll( ) const sl@0: { sl@0: return iFeatMgrClient.RequestNotifyCancelAll( ); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CFeatMgrTlsData::DeleteClient() sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: void CFeatMgrTlsData::DeleteClient() sl@0: { sl@0: CFeatMgrTlsData* tlsData = TlsData(); sl@0: sl@0: // Decrease the client count (self) sl@0: tlsData->DecreaseClientCount(); sl@0: sl@0: // Check if no more clients so that TLS can be freed. sl@0: if (tlsData->CanBeFreed()) sl@0: { sl@0: delete tlsData; sl@0: Dll::SetTls( NULL ); sl@0: } sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CFeatMgrTlsData::SWIStart() sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: TInt CFeatMgrTlsData::SWIStart( ) const sl@0: { sl@0: return iFeatMgrClient.SWIStart(); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CFeatMgrTlsData::SWIEnd() sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: TInt CFeatMgrTlsData::SWIEnd( ) const sl@0: { sl@0: return iFeatMgrClient.SWIEnd(); sl@0: } sl@0: sl@0: ///////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: // debug only API functions sl@0: #ifdef EXTENDED_FEATURE_MANAGER_TEST sl@0: sl@0: #pragma BullseyeCoverage off sl@0: sl@0: /** sl@0: */ sl@0: void CFeatMgrTlsData::ResourceMark() sl@0: { sl@0: iFeatMgrClient.ResourceMark(); sl@0: } sl@0: sl@0: /** sl@0: */ sl@0: void CFeatMgrTlsData::ResourceCheck() sl@0: { sl@0: iFeatMgrClient.ResourceCheck(); sl@0: } sl@0: sl@0: /** sl@0: */ sl@0: TInt CFeatMgrTlsData::ResourceCount() sl@0: { sl@0: return iFeatMgrClient.ResourceCount(); sl@0: } sl@0: sl@0: /** sl@0: */ sl@0: void CFeatMgrTlsData::SetHeapFailure(TInt aAllocFailType, TInt aRate) sl@0: { sl@0: iFeatMgrClient.SetHeapFailure(aAllocFailType, aRate); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------------- sl@0: // CFeatMgrTlsData::NumberOfNotifyFeatures() sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: TInt CFeatMgrTlsData::NumberOfNotifyFeatures( void ) const sl@0: { sl@0: return iFeatMgrClient.NumberOfNotifyFeatures(); sl@0: } sl@0: // ----------------------------------------------------------------------------- sl@0: // CFeatMgrTlsData::CountAllocCells() sl@0: // ----------------------------------------------------------------------------- sl@0: // sl@0: TInt CFeatMgrTlsData::CountAllocCells( void ) const sl@0: { sl@0: return iFeatMgrClient.CountAllocCells(); sl@0: } sl@0: sl@0: #pragma BullseyeCoverage on sl@0: sl@0: #endif sl@0: sl@0: // End of File