|
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/featurecontrol.h> |
|
20 #include "featmgrtlsdata.h" |
|
21 #include "featmgrdebug.h" |
|
22 #include <e32std.h> |
|
23 |
|
24 // LOCAL CONSTANTS AND MACROS |
|
25 _LIT( KPanicCategory, "RFeatureControl" ); |
|
26 |
|
27 // ============================= LOCAL FUNCTIONS =============================== |
|
28 |
|
29 static CFeatMgrTlsData* TlsData( ) |
|
30 { |
|
31 CFeatMgrTlsData* tlsData = STATIC_CAST( CFeatMgrTlsData*, Dll::Tls() ); |
|
32 |
|
33 __ASSERT_ALWAYS( tlsData, User::Panic( KPanicCategory, EPanicBadHandle ) ); |
|
34 |
|
35 return tlsData; |
|
36 } |
|
37 |
|
38 |
|
39 // ============================ MEMBER FUNCTIONS =============================== |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // RFeatureControl::RFeatureControl |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 EXPORT_C RFeatureControl::RFeatureControl() : |
|
46 iInitialized( EFalse ), iReserved1( 0 ), iReserved2 ( 0 ) |
|
47 { |
|
48 FUNC_LOG |
|
49 } |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // RFeatureControl::Connect() |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 EXPORT_C TInt RFeatureControl::Connect() |
|
56 { |
|
57 FUNC_LOG |
|
58 |
|
59 return Open(); |
|
60 } |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // RFeatureControl::Open() |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 EXPORT_C TInt RFeatureControl::Open() |
|
67 { |
|
68 FUNC_LOG |
|
69 |
|
70 if ( !Dll::Tls() ) |
|
71 { |
|
72 CFeatMgrTlsData* tlsData = NULL; |
|
73 |
|
74 TRAPD( err, tlsData = CFeatMgrTlsData::NewL() ); |
|
75 |
|
76 if ( err == KErrNone ) |
|
77 { |
|
78 Dll::SetTls( tlsData ); |
|
79 } |
|
80 else |
|
81 { |
|
82 ERROR_LOG1( "RFeatureControl::Open error %d ", err ); |
|
83 return err; |
|
84 } |
|
85 } |
|
86 |
|
87 // Increase the client count (self) |
|
88 iInitialized = ETrue; |
|
89 TlsData()->IncreaseClientCount(); |
|
90 return KErrNone; |
|
91 } |
|
92 |
|
93 // ----------------------------------------------------------------------------- |
|
94 // RFeatureControl::Close() |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 EXPORT_C void RFeatureControl::Close() |
|
98 { |
|
99 FUNC_LOG |
|
100 |
|
101 if ( Dll::Tls() && iInitialized ) |
|
102 { |
|
103 CFeatMgrTlsData::DeleteClient(); |
|
104 } |
|
105 } |
|
106 |
|
107 // ----------------------------------------------------------------------------- |
|
108 // RFeatureControl::FeatureSupported(TUid) |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 EXPORT_C TInt RFeatureControl::FeatureSupported( TUid aFeature ) |
|
112 { |
|
113 TFeatureEntry feature( aFeature ); |
|
114 TInt retVal = TlsData()->FeatureSupported( feature ); |
|
115 |
|
116 return retVal; |
|
117 } |
|
118 |
|
119 // ----------------------------------------------------------------------------- |
|
120 // RFeatureControl::FeatureSupported(TFeatureEntry&) |
|
121 // ----------------------------------------------------------------------------- |
|
122 // |
|
123 EXPORT_C TInt RFeatureControl::FeatureSupported( TFeatureEntry& aFeature ) |
|
124 { |
|
125 return TlsData()->FeatureSupported( aFeature ); |
|
126 } |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // RFeatureControl::FeaturesSupported(RFeatureArray&) |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 EXPORT_C TInt RFeatureControl::FeaturesSupported( RFeatureArray& aFeatures ) |
|
133 { |
|
134 TInt err( KErrNone ); |
|
135 |
|
136 if( !aFeatures.Count() ) |
|
137 { |
|
138 err = KErrArgument; |
|
139 } |
|
140 else |
|
141 { |
|
142 err = TlsData()->FeaturesSupported( aFeatures ); |
|
143 } |
|
144 |
|
145 return err; |
|
146 } |
|
147 |
|
148 // ----------------------------------------------------------------------------- |
|
149 // RFeatureControl::EnableFeature(TUid) |
|
150 // ----------------------------------------------------------------------------- |
|
151 // |
|
152 EXPORT_C TInt RFeatureControl::EnableFeature( TUid aFeature ) |
|
153 { |
|
154 return TlsData()->EnableFeature( aFeature ); |
|
155 } |
|
156 |
|
157 // ----------------------------------------------------------------------------- |
|
158 // RFeatureControl::DisableFeature(TUid) |
|
159 // ----------------------------------------------------------------------------- |
|
160 // |
|
161 EXPORT_C TInt RFeatureControl::DisableFeature( TUid aFeature ) |
|
162 { |
|
163 return TlsData()->DisableFeature( aFeature ); |
|
164 } |
|
165 |
|
166 // ----------------------------------------------------------------------------- |
|
167 // RFeatureControl::SetFeature(TUid, TBool, TInt) |
|
168 // ----------------------------------------------------------------------------- |
|
169 // |
|
170 EXPORT_C TInt RFeatureControl::SetFeature( TUid aFeature, TBool aEnabled, TUint32 aData ) |
|
171 { |
|
172 return TlsData()->SetFeature( aFeature, aEnabled, aData ); |
|
173 } |
|
174 |
|
175 // ----------------------------------------------------------------------------- |
|
176 // RFeatureControl::SetFeature() |
|
177 // ----------------------------------------------------------------------------- |
|
178 // |
|
179 EXPORT_C TInt RFeatureControl::SetFeature( TUid aFeature, TUint32 aData ) |
|
180 { |
|
181 return TlsData()->SetFeature( aFeature, aData ); |
|
182 } |
|
183 |
|
184 // ----------------------------------------------------------------------------- |
|
185 // RFeatureControl::AddFeature() |
|
186 // ----------------------------------------------------------------------------- |
|
187 // |
|
188 EXPORT_C TInt RFeatureControl::AddFeature( TFeatureEntry& aFeature ) |
|
189 { |
|
190 return TlsData()->AddFeature( aFeature ); |
|
191 } |
|
192 |
|
193 // ----------------------------------------------------------------------------- |
|
194 // RFeatureControl::DeleteFeature() |
|
195 // ----------------------------------------------------------------------------- |
|
196 // |
|
197 EXPORT_C TInt RFeatureControl::DeleteFeature( TUid aFeature ) |
|
198 { |
|
199 return TlsData()->DeleteFeature( aFeature ); |
|
200 } |
|
201 |
|
202 // ----------------------------------------------------------------------------- |
|
203 // RFeatureControl::ListSupportedFeaturesL() |
|
204 // ----------------------------------------------------------------------------- |
|
205 // |
|
206 EXPORT_C TInt RFeatureControl::ListSupportedFeatures( RFeatureUidArray& aSupportedFeatures ) |
|
207 { |
|
208 TRAPD( err, TlsData()->ListSupportedFeaturesL( aSupportedFeatures ) ); |
|
209 return err; |
|
210 } |
|
211 |
|
212 // ----------------------------------------------------------------------------- |
|
213 // RFeatureControl::SWIStart() |
|
214 // ----------------------------------------------------------------------------- |
|
215 // |
|
216 EXPORT_C TInt RFeatureControl::SWIStart() |
|
217 { |
|
218 return TlsData()->SWIStart( ); |
|
219 } |
|
220 |
|
221 // ----------------------------------------------------------------------------- |
|
222 // RFeatureControl::SWIEnd() |
|
223 // ----------------------------------------------------------------------------- |
|
224 // |
|
225 EXPORT_C TInt RFeatureControl::SWIEnd() |
|
226 { |
|
227 return TlsData()->SWIEnd( ); |
|
228 } |
|
229 |
|
230 |
|
231 // End of File |