featuremgmt/featuremgr/src/clientdll/featmgrtlsdata.cpp
changeset 0 08ec8eefde2f
child 10 fa9941cf3867
equal deleted inserted replaced
-1:000000000000 0:08ec8eefde2f
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include <featmgr/featmgr.h>
       
    20 #include "featmgrtlsdata.h"
       
    21 #include "featmgrdebug.h"
       
    22 
       
    23 // ============================= LOCAL FUNCTIONS ===============================
       
    24 
       
    25 static CFeatMgrTlsData* TlsData( )
       
    26     {
       
    27     CFeatMgrTlsData* tlsData = STATIC_CAST( CFeatMgrTlsData*, Dll::Tls() );
       
    28     _LIT( KPanicCategory, "RFeatureControl" );
       
    29     __ASSERT_ALWAYS( tlsData, User::Panic( KPanicCategory, EPanicBadHandle ) );
       
    30 
       
    31     return tlsData;
       
    32     }
       
    33     
       
    34 
       
    35 // ============================ MEMBER FUNCTIONS ===============================
       
    36 
       
    37 // -----------------------------------------------------------------------------
       
    38 // CFeatureManager::CFeatureManager()
       
    39 // -----------------------------------------------------------------------------
       
    40 //
       
    41 
       
    42 CFeatMgrTlsData::CFeatMgrTlsData() :
       
    43     iClientCount(0)
       
    44     {
       
    45     }
       
    46 
       
    47 // -----------------------------------------------------------------------------
       
    48 // CFeatureManager::ConstructL
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 void CFeatMgrTlsData::ConstructL()
       
    52     {
       
    53     // Connect to Feature Manager server
       
    54     FUNC_LOG
       
    55     TInt err( iFeatMgrClient.Connect() );
       
    56     User::LeaveIfError(err);
       
    57     }
       
    58 
       
    59 // -----------------------------------------------------------------------------
       
    60 // CFeatureManager::NewL()
       
    61 // Two-phased constructor.
       
    62 // -----------------------------------------------------------------------------
       
    63 //
       
    64 CFeatMgrTlsData* CFeatMgrTlsData::NewL()
       
    65     {
       
    66     CFeatMgrTlsData* self = new( ELeave ) CFeatMgrTlsData();
       
    67     CleanupStack::PushL( self );
       
    68     self->ConstructL();
       
    69     CleanupStack::Pop( self );
       
    70     return self;
       
    71     }
       
    72     
       
    73 // -----------------------------------------------------------------------------
       
    74 // CFeatureManager::~CFeatMgrTlsData
       
    75 // -----------------------------------------------------------------------------
       
    76 //
       
    77 CFeatMgrTlsData::~CFeatMgrTlsData()
       
    78     {
       
    79     FUNC_LOG
       
    80     iFeatMgrClient.Close();
       
    81     }
       
    82 
       
    83 // -----------------------------------------------------------------------------
       
    84 // CFeatMgrTlsData::CanBeFreed()
       
    85 // -----------------------------------------------------------------------------
       
    86 //
       
    87 TBool CFeatMgrTlsData::CanBeFreed() const
       
    88     {
       
    89 	if (iClientCount <= 0)
       
    90 	    {
       
    91 		INFO_LOG1( "FeatMgr: TLS can be freed, clients(%d)", iClientCount );
       
    92 		return ETrue;
       
    93 	    }
       
    94 	else
       
    95 	    {
       
    96 		INFO_LOG1( "FeatMgr: TLS can NOT be freed, clients(%d)", iClientCount );
       
    97 		return EFalse;
       
    98 	    }
       
    99     }
       
   100 
       
   101 // -----------------------------------------------------------------------------
       
   102 // CFeatMgrTlsData::IncreaseClientCount()
       
   103 // -----------------------------------------------------------------------------
       
   104 //
       
   105 void CFeatMgrTlsData::IncreaseClientCount()
       
   106     {
       
   107 	++iClientCount;
       
   108 	INFO_LOG1( "FeatMgr: TLS increase, clients now(%d)", iClientCount );
       
   109     }
       
   110 
       
   111 // -----------------------------------------------------------------------------
       
   112 // CFeatMgrTlsData::DecreaseClientCount()
       
   113 // -----------------------------------------------------------------------------
       
   114 //
       
   115 
       
   116 void CFeatMgrTlsData::DecreaseClientCount()
       
   117     {
       
   118 	--iClientCount;
       
   119 	INFO_LOG1( "FeatMgr: TLS decrease, clients now(%d)", iClientCount );
       
   120     }
       
   121 
       
   122 // -----------------------------------------------------------------------------
       
   123 // CFeatMgrTlsData::FeatureSupported()
       
   124 // -----------------------------------------------------------------------------
       
   125 //
       
   126 TInt CFeatMgrTlsData::FeatureSupported( TFeatureEntry& aFeature ) const
       
   127     {
       
   128     return iFeatMgrClient.FeatureSupported( aFeature );
       
   129     }
       
   130 
       
   131 // -----------------------------------------------------------------------------
       
   132 // CFeatMgrTlsData::FeaturesSupported()
       
   133 // -----------------------------------------------------------------------------
       
   134 //
       
   135 TInt CFeatMgrTlsData::FeaturesSupported( RFeatureArray& aFeatures )
       
   136     {
       
   137     return iFeatMgrClient.FeaturesSupported( aFeatures );
       
   138     }
       
   139 
       
   140 // -----------------------------------------------------------------------------
       
   141 // CFeatMgrTlsData::EnableFeature()
       
   142 // -----------------------------------------------------------------------------
       
   143 //
       
   144 TInt CFeatMgrTlsData::EnableFeature( TUid aFeature ) const
       
   145     {
       
   146     return iFeatMgrClient.EnableFeature( aFeature );
       
   147     }
       
   148 
       
   149 // -----------------------------------------------------------------------------
       
   150 // CFeatMgrTlsData::DisableFeature()
       
   151 // -----------------------------------------------------------------------------
       
   152 //
       
   153 TInt CFeatMgrTlsData::DisableFeature( TUid aFeature ) const
       
   154     {
       
   155     return iFeatMgrClient.DisableFeature( aFeature );
       
   156     }
       
   157     
       
   158 // -----------------------------------------------------------------------------
       
   159 // CFeatMgrTlsData::SetFeature()
       
   160 // -----------------------------------------------------------------------------
       
   161 //
       
   162 TInt CFeatMgrTlsData::SetFeature( TUid aFeature, TBool aEnabled, TInt aData ) const
       
   163     {
       
   164     return iFeatMgrClient.SetFeature( aFeature, aEnabled, aData );
       
   165     }
       
   166 
       
   167 // -----------------------------------------------------------------------------
       
   168 // CFeatMgrTlsData::SetFeature()
       
   169 // -----------------------------------------------------------------------------
       
   170 //
       
   171 TInt CFeatMgrTlsData::SetFeature( TUid aFeature, TInt aData ) const
       
   172     {
       
   173     return iFeatMgrClient.SetFeature( aFeature, aData );
       
   174     }
       
   175 
       
   176 // -----------------------------------------------------------------------------
       
   177 // CFeatMgrTlsData::AddFeature()
       
   178 // -----------------------------------------------------------------------------
       
   179 //
       
   180 TInt CFeatMgrTlsData::AddFeature( TFeatureEntry aFeature ) const
       
   181     {
       
   182     return iFeatMgrClient.AddFeature( aFeature );
       
   183     }
       
   184 
       
   185 // -----------------------------------------------------------------------------
       
   186 // CFeatMgrTlsData::DeleteFeature()
       
   187 // -----------------------------------------------------------------------------
       
   188 //
       
   189 TInt CFeatMgrTlsData::DeleteFeature( TUid aFeature ) const
       
   190     {
       
   191     return iFeatMgrClient.DeleteFeature( aFeature );
       
   192     }
       
   193 
       
   194 // -----------------------------------------------------------------------------
       
   195 // CFeatMgrTlsData::ListSupportedFeaturesL()
       
   196 // -----------------------------------------------------------------------------
       
   197 //
       
   198 void CFeatMgrTlsData::ListSupportedFeaturesL( RFeatureUidArray& aSupportedFeatures )
       
   199     {
       
   200     iFeatMgrClient.ListSupportedFeaturesL( aSupportedFeatures );
       
   201     }
       
   202 
       
   203 // -----------------------------------------------------------------------------
       
   204 // CFeatMgrTlsData::ReRequestNotification(TUid&, TRequestStatus&)
       
   205 // -----------------------------------------------------------------------------
       
   206 //
       
   207 TInt CFeatMgrTlsData::ReRequestNotification( TUid& aFeatUid, TRequestStatus& aStatus )
       
   208     {
       
   209     return iFeatMgrClient.ReRequestNotification( aFeatUid, aStatus );
       
   210     }
       
   211         
       
   212 
       
   213 // -----------------------------------------------------------------------------
       
   214 // CFeatMgrTlsData::RequestNotification(RFeatureUidArray&, TUid&, TRequestStatus&)
       
   215 // -----------------------------------------------------------------------------
       
   216 //
       
   217 TInt CFeatMgrTlsData::RequestNotification( RFeatureUidArray& aFeatures, TUid& aFeatUid, 
       
   218     TRequestStatus& aStatus )
       
   219     {
       
   220     return iFeatMgrClient.RequestNotification( aFeatures, aFeatUid, aStatus );
       
   221     }
       
   222         
       
   223 // -----------------------------------------------------------------------------
       
   224 // CFeatMgrTlsData::RequestNotifyCancel(RFeatureUidArray&, TRequestStatus&)
       
   225 // -----------------------------------------------------------------------------
       
   226 //
       
   227 TInt CFeatMgrTlsData::RequestNotifyCancel( TUid aFeature ) const
       
   228     {
       
   229     return iFeatMgrClient.RequestNotifyCancel( aFeature );
       
   230     }
       
   231         
       
   232 // -----------------------------------------------------------------------------
       
   233 // CFeatMgrTlsData::RequestNotifyCancelAll(RFeatureUidArray&, TRequestStatus&)
       
   234 // -----------------------------------------------------------------------------
       
   235 //
       
   236 TInt CFeatMgrTlsData::RequestNotifyCancelAll( ) const
       
   237     {
       
   238     return iFeatMgrClient.RequestNotifyCancelAll( );
       
   239     }
       
   240 
       
   241 // -----------------------------------------------------------------------------
       
   242 // CFeatMgrTlsData::DeleteClient()
       
   243 // -----------------------------------------------------------------------------
       
   244 //
       
   245 void CFeatMgrTlsData::DeleteClient()
       
   246 	{
       
   247 	CFeatMgrTlsData* tlsData = TlsData();
       
   248 
       
   249 	// Decrease the client count (self)
       
   250 	tlsData->DecreaseClientCount();
       
   251 
       
   252 	// Check if no more clients so that TLS can be freed.
       
   253 	if (tlsData->CanBeFreed())
       
   254 		{
       
   255 		delete tlsData;
       
   256 		Dll::SetTls( NULL );
       
   257 		}
       
   258     }
       
   259 
       
   260 // -----------------------------------------------------------------------------
       
   261 // CFeatMgrTlsData::SWIStart()
       
   262 // -----------------------------------------------------------------------------
       
   263 //
       
   264 TInt CFeatMgrTlsData::SWIStart( ) const
       
   265     {
       
   266     return iFeatMgrClient.SWIStart();
       
   267     }
       
   268 
       
   269 // -----------------------------------------------------------------------------
       
   270 // CFeatMgrTlsData::SWIEnd()
       
   271 // -----------------------------------------------------------------------------
       
   272 //
       
   273 TInt CFeatMgrTlsData::SWIEnd( ) const
       
   274     {
       
   275     return iFeatMgrClient.SWIEnd(); 
       
   276 	}
       
   277 
       
   278 
       
   279 // debug only API functions
       
   280 
       
   281 #ifdef EXTENDED_FEATURE_MANAGER_TEST
       
   282 // -----------------------------------------------------------------------------
       
   283 // CFeatMgrTlsData::NumberOfNotifyFeatures()
       
   284 // -----------------------------------------------------------------------------
       
   285 //
       
   286 TInt CFeatMgrTlsData::NumberOfNotifyFeatures( void ) const
       
   287     {
       
   288     return iFeatMgrClient.NumberOfNotifyFeatures();
       
   289     }
       
   290 // -----------------------------------------------------------------------------
       
   291 // CFeatMgrTlsData::CountAllocCells()
       
   292 // -----------------------------------------------------------------------------
       
   293 //
       
   294 TInt CFeatMgrTlsData::CountAllocCells( void ) const
       
   295     {
       
   296     return iFeatMgrClient.CountAllocCells();
       
   297     }
       
   298 #endif
       
   299 
       
   300 //  End of File