1 /* |
1 /* |
2 * Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
8 * |
8 * |
9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: Offers functionality for querying whether a feature is |
14 * Description: |
15 * supported in the current environment. |
|
16 * |
15 * |
17 */ |
16 */ |
18 |
17 |
19 |
18 |
20 #ifndef FEATUREDISCOVERY_H |
19 |
21 #define FEATUREDISCOVERY_H |
20 #ifndef FEATDISCOVERY_H |
|
21 #define FEATDISCOVERY_H |
22 |
22 |
23 // INCLUDES |
23 // INCLUDES |
24 #include <e32std.h> |
24 #include <e32base.h> |
25 |
25 |
|
26 class CFeatureDiscoveryImpl; |
26 |
27 |
27 /** |
28 /** |
28 * Class used to query which features are suppported in the environment. |
29 Wrapper class used for multiple feature queries. |
29 * Feature Discovery API provides methods which are used to query which |
30 @publishedAll |
30 * features are supported in the environment. A feature is a functionality that |
31 @released |
31 * can be optionally left out of some product configurations. Features often |
|
32 * depend on the underlying hardware. For example, MMC support or USB support |
|
33 * can be features. The API consist of the CFeatureDiscovery class which is |
|
34 * used together with feature IDs defined in the featureinfo.h file. |
|
35 * |
|
36 * |
|
37 * Usage: |
|
38 * |
|
39 * @code |
|
40 * #include <FeatDiscovery.h> |
|
41 * #include <featureinfo.h> // for feature definitions |
|
42 * |
|
43 * // If querying only one feature, it is more efficient to use the class |
|
44 * // via the static method, IsFeatureSupportedL(). |
|
45 * // When querying more than one feature, it is more efficient to use the |
|
46 * // class by creating an instance and calling the IsSupported() method. |
|
47 * |
|
48 * // Static way of using the class: |
|
49 * TBool isSupported = CFeatureDiscovery::IsFeatureSupportedL(KFeatureIdUsb); |
|
50 * |
|
51 * // Dynamic way of using the class using NewL(): |
|
52 * |
|
53 * // Call NewL() to create an instance of CFeatureDiscovery. |
|
54 * CFeatureDiscovery* testA = CFeatureDiscovery::NewL(); |
|
55 * |
|
56 * // Call the exported IsSupported() method to query whether features |
|
57 * // are supported in the current environment or not. |
|
58 * TBool usbSupported = testA->IsSupported(KFeatureIdUsb); |
|
59 * TBool mmcSupported = testA->IsSupported(KFeatureIdMmc); |
|
60 * |
|
61 * // Delete the created instance of CFeatureDiscovery. |
|
62 * delete testA; |
|
63 * |
|
64 * // Dynamic way of using the class using NewLC(): |
|
65 * |
|
66 * // Call NewLC() to create an instance of CFeatureDiscovery. |
|
67 * // The method leaves the instance of the object on the cleanup stack. |
|
68 * CFeatureDiscovery* testB = CFeatureDiscovery::NewLC(); |
|
69 * |
|
70 * // Call the exported IsSupported() method to query whether features |
|
71 * // are supported in the current environment or not. |
|
72 * TBool wcdmaSupported = testB->IsSupported(KFeatureIdProtocolWcdma); |
|
73 * TBool gsmSupported = testB->IsSupported(KFeatureIdProtocolGsm); |
|
74 * |
|
75 * // Pop and delete the created instance of CFeatureDiscovery. |
|
76 * CleanupStack::PopAndDestroy(); |
|
77 * @endcode |
|
78 * |
|
79 * @lib featdiscovery.lib |
|
80 * @since S60 2.8 |
|
81 */ |
32 */ |
82 |
33 |
|
34 class TFeatureSet |
|
35 { |
|
36 public: |
|
37 |
|
38 /** |
|
39 Constructor |
|
40 */ |
|
41 IMPORT_C TFeatureSet(); |
|
42 |
|
43 /** |
|
44 Destructor |
|
45 */ |
|
46 IMPORT_C ~TFeatureSet(); |
|
47 |
|
48 /** |
|
49 Method to add features before querying support statuses. This |
|
50 method must be called to initialize feature array before querying |
|
51 support statuses from server with FeaturesSupported(L) and finally |
|
52 check the status with a call to IsFeatureSupported or AreAllFeaturesSupported. |
|
53 |
|
54 @return KErrNone if feature addition succeded. |
|
55 Otherwise one of the Symbian OS error codes |
|
56 */ |
|
57 IMPORT_C TInt Append( TUid aFeature ); |
|
58 |
|
59 /** |
|
60 Method to check feature's support status. |
|
61 |
|
62 @param aFeature is the feature UID of the feature that is queried. |
|
63 @return a TBool indicating whether the feature is supported (ETrue) |
|
64 or not (EFalse). If the feature does not exist, the return value is |
|
65 EFalse. |
|
66 */ |
|
67 IMPORT_C TBool IsFeatureSupported( TUid aFeature ) const; |
|
68 |
|
69 /** |
|
70 Method to check whether all features queried are supported. |
|
71 |
|
72 @return ETrue if all features queried are supported or no features have been queried. |
|
73 Otherwise EFalse. |
|
74 */ |
|
75 IMPORT_C TBool AreAllFeaturesSupported() const; |
|
76 |
|
77 public: // For CFeatureDiscoveryImpl internal use |
|
78 |
|
79 // Count number of features in TFeatureStat array. |
|
80 TInt Count(); |
|
81 |
|
82 // Return id of feature in requested index from TFeatureStat array. |
|
83 TUid FeatureId( TInt aIndex ) const; |
|
84 |
|
85 // Reset TFeatureStat array. |
|
86 void Reset(); |
|
87 |
|
88 // Append feature and status object into TFeatureStat array |
|
89 TInt Append( TUid aFeature, TBool aSupported ); |
|
90 |
|
91 private: |
|
92 struct TFeatureStat |
|
93 { |
|
94 TUid iFeatureID; |
|
95 TBool iSupported; |
|
96 }; |
|
97 |
|
98 private: |
|
99 // Feature id, status array |
|
100 RArray<TFeatureStat> iStatus; |
|
101 |
|
102 // Counter for checking feature count before and after query |
|
103 TInt iCount; |
|
104 |
|
105 // Reserved for future use. |
|
106 TUint32 iReserved; |
|
107 }; |
|
108 |
|
109 /** |
|
110 The feature discovery API provides methods which are used to query which |
|
111 features are supported in the environment. |
|
112 |
|
113 @publishedAll |
|
114 @released |
|
115 */ |
83 class CFeatureDiscovery : public CBase |
116 class CFeatureDiscovery : public CBase |
84 { |
117 { |
85 public: |
118 public: |
86 |
119 |
87 /** |
120 /** |
88 * This is a two-phase constructor method that is used to create |
121 This is a two-phase constructor method that is used to create |
89 * a new instance of the CFeatureDiscovery class. |
122 a new instance of the CFeatureDiscovery class. |
90 * |
123 |
91 * @return a pointer to a new instance of the CFeatureDiscovery class. |
124 @return a pointer to a new instance of the CFeatureDiscovery class. |
92 * |
125 |
93 * @leave One of the Symbian OS error codes |
126 @leave Any One of the Symbian OS system-wide error codes |
94 */ |
127 */ |
95 IMPORT_C static CFeatureDiscovery* NewL(); |
128 IMPORT_C static CFeatureDiscovery* NewL(); |
96 |
129 |
97 /** |
130 /** |
98 * This is a two-phase constructor method that is used to create |
131 This is a two-phase constructor method that is used to create |
99 * a new instance of the CFeatureDiscovery class. This method leaves |
132 a new instance of the CFeatureDiscovery class. This method leaves |
100 * the instance of the object on the cleanup stack. |
133 the instance of the object on the cleanup stack. |
101 * |
134 |
102 * @return a pointer to a new instance of the CFeatureDiscovery class. |
135 @return a pointer to a new instance of the CFeatureDiscovery class. |
103 * |
136 |
104 * @leave One of the Symbian OS error codes |
137 @leave Any One of the Symbian OS system-wide error codes |
105 */ |
138 */ |
106 IMPORT_C static CFeatureDiscovery* NewLC(); |
139 IMPORT_C static CFeatureDiscovery* NewLC(); |
107 |
140 |
108 /** |
141 /** |
109 * Destructor. |
142 Destructor. |
110 */ |
143 */ |
111 virtual ~CFeatureDiscovery(); |
144 virtual ~CFeatureDiscovery(); |
112 |
145 |
113 /** |
146 /** |
114 * Static way to fetch information whether a certain feature is |
147 Static method to query the supported status of a feature on the |
115 * supported in the current envinronment. There is no need to create |
148 device. |
116 * an instance of the class when using this method. |
149 |
117 * |
150 @deprecated Use IsFeatureSupportedL(TUid aFeature) instead. |
118 * @param aFeature is the feature ID of the feature that is queried. |
151 |
119 * @return a TBool indicating whether the feature is supported (ETrue) |
152 @param aFeature is the feature ID of the feature that is queried. |
120 * or not (EFalse). If the feature does not exist, the return value is |
153 @return a TBool indicating whether the feature is supported (ETrue) |
121 * EFalse. |
154 or not (EFalse). If the feature does not exist, the return value is |
122 * |
155 EFalse. |
123 * @leave One of the Symbian OS error codes. |
156 |
124 */ |
157 @leave Any One of the Symbian OS system-wide error codes |
125 IMPORT_C static TBool IsFeatureSupportedL(TInt aFeature); |
158 */ |
126 |
159 IMPORT_C static TBool IsFeatureSupportedL( TInt aFeature ); |
127 /** |
160 |
128 * Dynamic way to fetch information whether a certain feature is |
161 /** |
129 * supported in the current environment. Before calling the method |
162 Dynamic method to query the supported status of a feature on the |
130 * an instance of the CFeatureDiscovery class need to be created by |
163 device. Before calling the method an instance of the CFeatureDiscovery |
131 * using one of the factory methods, NewL() or NewLC(). The created |
164 class must be created by using one of the factory methods, |
132 * instance must be deleted after use. |
165 NewL() or NewLC(). The created instance must be deleted after use. |
133 * |
166 |
134 * @param aFeature is the feature ID of the feature that is queried. |
167 @deprecated Use IsSupported(TUid aFeature) instead. |
135 * @return a TBool indicating whether the feature is supported (ETrue) |
168 |
136 * or not (EFalse). If the feature does not exist, the return value is |
169 @param aFeature is the feature ID of the feature that is queried. |
137 * EFalse. |
170 @return a TBool indicating whether the feature is supported (ETrue) |
138 */ |
171 or not (EFalse). If the feature does not exist, the return value is |
139 IMPORT_C TBool IsSupported(TInt aFeature) const ; |
172 EFalse. |
|
173 */ |
|
174 IMPORT_C TBool IsSupported( TInt aFeature ) const ; |
|
175 |
|
176 /** |
|
177 Static method to query the supported status of a feature on the device. |
|
178 |
|
179 @param aFeature is the feature UID of the feature that is queried. |
|
180 @return a TBool indicating whether the feature is supported (ETrue) |
|
181 or not (EFalse). If the feature does not exist, the return value is |
|
182 EFalse. |
|
183 |
|
184 @leave Any One of the Symbian OS system-wide error codes |
|
185 */ |
|
186 IMPORT_C static TBool IsFeatureSupportedL( TUid aFeature ); |
|
187 |
|
188 /** |
|
189 Dynamic method to query the supported status of a feature on the device. |
|
190 |
|
191 Before calling the method an instance of the CFeatureDiscovery class must |
|
192 be created by using one of the factory methods, NewL() or NewLC(). |
|
193 The created instance must be deleted after use. |
|
194 |
|
195 @param aFeature is the feature UID of the feature that is queried. |
|
196 @return a TBool indicating whether the feature is supported (ETrue) |
|
197 or not (EFalse). If the feature does not exist, the return value is |
|
198 EFalse. |
|
199 */ |
|
200 IMPORT_C TBool IsSupported( TUid aFeature ) const ; |
|
201 |
|
202 /** |
|
203 Static method to query the supported status of a set of features |
|
204 on the device. |
|
205 |
|
206 @param aFeatures is the wrapper class for feature array queried. |
|
207 |
|
208 @leave Any One of the Symbian OS system-wide error codes |
|
209 */ |
|
210 IMPORT_C static void FeaturesSupportedL( TFeatureSet& aFeatures ); |
|
211 |
|
212 /** |
|
213 Dynamic method to query the supported status of a set of features |
|
214 on the device. Before calling the method an instance of the |
|
215 CFeatureDiscovery class need to be created by using one of the |
|
216 factory methods, NewL() or NewLC(). The created instance must be |
|
217 deleted after use. |
|
218 |
|
219 @param aFeatures is the wrapper class for feature array queried. |
|
220 @return KErrNone if status query succeeded. |
|
221 Otherwise one of the Symbian OS error codes |
|
222 */ |
|
223 IMPORT_C TInt FeaturesSupported( TFeatureSet& aFeatures ) const; |
140 |
224 |
141 private: |
225 private: |
142 |
226 |
143 /** |
227 /** |
144 * C++ default constructor. |
228 C++ default constructor. |
145 */ |
229 */ |
146 CFeatureDiscovery(); |
230 CFeatureDiscovery(); |
147 |
231 |
148 /** |
232 /** |
149 * By default Symbian OS constructor is private. |
233 By default Symbian OS constructor is private. |
150 */ |
234 */ |
151 void ConstructL(); |
235 void ConstructL(); |
|
236 |
|
237 private: |
|
238 |
|
239 // Feature discovery implementation class |
|
240 CFeatureDiscoveryImpl* iImpl; |
152 } ; |
241 } ; |
153 |
242 |
154 |
243 /** |
155 #endif // FEATUREDISCOVERY_H |
244 Usage: |
156 |
245 |
157 // EOF |
246 @code |
|
247 #include <featdiscovery.h> |
|
248 #include <featureinfo.h> // for feature definitions |
|
249 |
|
250 // replace <featureUIDx> with a real UID ) |
|
251 |
|
252 // If querying only one feature, it is more efficient to use the class |
|
253 // via the static method, IsFeatureSupportedL(). |
|
254 // When querying more than one feature, it is more efficient to use the |
|
255 // class by creating an instance and calling the IsSupported() method. |
|
256 |
|
257 // Static way of using the class: |
|
258 TBool isSupported = CFeatureDiscovery::IsFeatureSupportedL(<featureUIDx>); |
|
259 |
|
260 // Dynamic way of using the class using NewL(): |
|
261 |
|
262 // Call NewL() to create an instance of CFeatureDiscovery. |
|
263 CFeatureDiscovery* testA = CFeatureDiscovery::NewL(); |
|
264 |
|
265 // Call the exported IsSupported() method to query whether features |
|
266 // are supported in the current environment or not. |
|
267 TBool usbSupported = testA->IsSupported(<featureUIDx>); |
|
268 TBool mmcSupported = testA->IsSupported(<featureUIDx>); |
|
269 |
|
270 // Delete the created instance of CFeatureDiscovery. |
|
271 delete testA; |
|
272 |
|
273 // Dynamic way of using the class using NewLC(): |
|
274 |
|
275 // Call NewLC() to create an instance of CFeatureDiscovery. |
|
276 // The method leaves the instance of the object on the cleanup stack. |
|
277 CFeatureDiscovery* testB = CFeatureDiscovery::NewLC(); |
|
278 |
|
279 // Call the exported IsSupported() method to query whether features |
|
280 // are supported in the current environment or not. |
|
281 TBool wcdmaSupported = testB->IsSupported(<featureUIDx>); |
|
282 TBool gsmSupported = testB->IsSupported(<featureUIDx>); |
|
283 |
|
284 // Dynamic way of using multiple feature query. This is preferred |
|
285 // way to fetch support statuses if there are several features to be |
|
286 // queried, because it involves less inter-process communication. |
|
287 |
|
288 TFeatureSet featset; |
|
289 User::LeaveIfError( featset.Append( <featureUIDx> ) ); |
|
290 User::LeaveIfError( featset.Append( <featureUIDx> ) ); |
|
291 TInt err = testB->FeaturesSupported( featset ); |
|
292 if(!err) |
|
293 { |
|
294 TBool uid1Supported = featset.IsFeatureSupported(<featureUIDx>); |
|
295 TBool uid2Supported = featset.IsFeatureSupported(<featureUIDx>); |
|
296 // ... or whether all QUERIED features are supported |
|
297 TBool allSupported = featset.AreAllFeaturesSupported(); |
|
298 } |
|
299 // featset cleans array up in destructor on scope exit |
|
300 |
|
301 // Pop and delete the created instance of CFeatureDiscovery. |
|
302 CleanupStack::PopAndDestroy(); |
|
303 @endcode |
|
304 */ |
|
305 #endif // FEATDISCOVERY_H |
|
306 |
|
307 // End of File |