Update contrib.
1 // Copyright (c) 2007-2010 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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
19 #include <featmgr/featurecontrol.h>
20 #include "featmgrtlsdata.h"
21 #include "featmgrdebug.h"
24 // LOCAL CONSTANTS AND MACROS
25 _LIT( KPanicCategory, "RFeatureControl" );
27 // ============================= LOCAL FUNCTIONS ===============================
29 CFeatMgrTlsData* TlsData( )
31 CFeatMgrTlsData* tlsData = STATIC_CAST( CFeatMgrTlsData*, Dll::Tls() );
33 __ASSERT_ALWAYS( tlsData, User::Panic( KPanicCategory, EPanicBadHandle ) );
39 // ============================ MEMBER FUNCTIONS ===============================
41 // -----------------------------------------------------------------------------
42 // RFeatureControl::RFeatureControl
43 // -----------------------------------------------------------------------------
45 EXPORT_C RFeatureControl::RFeatureControl() :
46 iInitialized( EFalse ), iReserved1( 0 ), iReserved2 ( 0 )
51 // -----------------------------------------------------------------------------
52 // RFeatureControl::Connect()
53 // -----------------------------------------------------------------------------
55 EXPORT_C TInt RFeatureControl::Connect()
62 // -----------------------------------------------------------------------------
63 // RFeatureControl::Open()
64 // -----------------------------------------------------------------------------
66 EXPORT_C TInt RFeatureControl::Open()
72 CFeatMgrTlsData* tlsData = NULL;
74 TRAPD( err, tlsData = CFeatMgrTlsData::NewL() );
76 if ( err == KErrNone )
78 err = Dll::SetTls( tlsData );
82 ERROR_LOG1( "RFeatureControl::Open SetTls error %d ", err );
88 ERROR_LOG1( "RFeatureControl::Open error %d ", err );
93 // Increase the client count (self)
95 TlsData()->IncreaseClientCount();
99 // -----------------------------------------------------------------------------
100 // RFeatureControl::Close()
101 // -----------------------------------------------------------------------------
103 EXPORT_C void RFeatureControl::Close()
107 if ( Dll::Tls() && iInitialized )
109 CFeatMgrTlsData::DeleteClient();
113 // -----------------------------------------------------------------------------
114 // RFeatureControl::FeatureSupported(TUid)
115 // -----------------------------------------------------------------------------
117 EXPORT_C TInt RFeatureControl::FeatureSupported( TUid aFeature )
119 TFeatureEntry feature( aFeature );
120 TInt retVal = TlsData()->FeatureSupported( feature );
125 // -----------------------------------------------------------------------------
126 // RFeatureControl::FeatureSupported(TFeatureEntry&)
127 // -----------------------------------------------------------------------------
129 EXPORT_C TInt RFeatureControl::FeatureSupported( TFeatureEntry& aFeature )
131 return TlsData()->FeatureSupported( aFeature );
134 // -----------------------------------------------------------------------------
135 // RFeatureControl::FeaturesSupported(RFeatureArray&)
136 // -----------------------------------------------------------------------------
138 EXPORT_C TInt RFeatureControl::FeaturesSupported( RFeatureArray& aFeatures )
140 TInt err( KErrNone );
142 if( !aFeatures.Count() )
148 err = TlsData()->FeaturesSupported( aFeatures );
154 // -----------------------------------------------------------------------------
155 // RFeatureControl::EnableFeature(TUid)
156 // -----------------------------------------------------------------------------
158 EXPORT_C TInt RFeatureControl::EnableFeature( TUid aFeature )
160 return TlsData()->EnableFeature( aFeature );
163 // -----------------------------------------------------------------------------
164 // RFeatureControl::DisableFeature(TUid)
165 // -----------------------------------------------------------------------------
167 EXPORT_C TInt RFeatureControl::DisableFeature( TUid aFeature )
169 return TlsData()->DisableFeature( aFeature );
172 // -----------------------------------------------------------------------------
173 // RFeatureControl::SetFeature(TUid, TBool, TInt)
174 // -----------------------------------------------------------------------------
176 EXPORT_C TInt RFeatureControl::SetFeature( TUid aFeature, TBool aEnabled, TUint32 aData )
178 return TlsData()->SetFeature( aFeature, aEnabled, aData );
181 // -----------------------------------------------------------------------------
182 // RFeatureControl::SetFeature()
183 // -----------------------------------------------------------------------------
185 EXPORT_C TInt RFeatureControl::SetFeature( TUid aFeature, TUint32 aData )
187 return TlsData()->SetFeature( aFeature, aData );
190 // -----------------------------------------------------------------------------
191 // RFeatureControl::AddFeature()
192 // -----------------------------------------------------------------------------
194 EXPORT_C TInt RFeatureControl::AddFeature( TFeatureEntry& aFeature )
196 return TlsData()->AddFeature( aFeature );
199 // -----------------------------------------------------------------------------
200 // RFeatureControl::DeleteFeature()
201 // -----------------------------------------------------------------------------
203 EXPORT_C TInt RFeatureControl::DeleteFeature( TUid aFeature )
205 return TlsData()->DeleteFeature( aFeature );
208 // -----------------------------------------------------------------------------
209 // RFeatureControl::ListSupportedFeaturesL()
210 // -----------------------------------------------------------------------------
212 EXPORT_C TInt RFeatureControl::ListSupportedFeatures( RFeatureUidArray& aSupportedFeatures )
214 TRAPD( err, TlsData()->ListSupportedFeaturesL( aSupportedFeatures ) );
218 // -----------------------------------------------------------------------------
219 // RFeatureControl::SWIStart()
220 // -----------------------------------------------------------------------------
222 EXPORT_C TInt RFeatureControl::SWIStart()
224 return TlsData()->SWIStart( );
227 // -----------------------------------------------------------------------------
228 // RFeatureControl::SWIEnd()
229 // -----------------------------------------------------------------------------
231 EXPORT_C TInt RFeatureControl::SWIEnd()
233 return TlsData()->SWIEnd( );