|
1 /* |
|
2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: MuiuFlagger implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <e32base.h> |
|
23 #include <featmgr.h> // Feature Manager |
|
24 #include <centralrepository.h> // CRepository |
|
25 #include "MuiuFlagger.h" // CMuiuFlags |
|
26 |
|
27 |
|
28 // EXTERNAL DATA STRUCTURES |
|
29 // EXTERNAL FUNCTION PROTOTYPES |
|
30 // CONSTANTS |
|
31 const TInt KMuiuFlaggerMaxFlags = 64; |
|
32 _LIT( KMuiuFlaggerPanic, "MuiuFlagger" ); |
|
33 |
|
34 // MACROS |
|
35 // LOCAL CONSTANTS AND MACROS |
|
36 // MODULE DATA STRUCTURES |
|
37 // LOCAL FUNCTION PROTOTYPES |
|
38 // FORWARD DECLARATIONS |
|
39 |
|
40 // ============================ MEMBER FUNCTIONS ============================== |
|
41 |
|
42 |
|
43 // ------------------------------ CONSTRUCTORS -------------------------------- |
|
44 |
|
45 |
|
46 // ---------------------------------------------------------------------------- |
|
47 // CMuiuFlags::CMuiuFlags() |
|
48 // ---------------------------------------------------------------------------- |
|
49 // |
|
50 CMuiuFlags::CMuiuFlags() |
|
51 { |
|
52 } |
|
53 |
|
54 // ---------------------------------------------------------------------------- |
|
55 // CMuiuFlags::~CMuiuFlags() |
|
56 // ---------------------------------------------------------------------------- |
|
57 // |
|
58 EXPORT_C CMuiuFlags::~CMuiuFlags() |
|
59 { |
|
60 } |
|
61 |
|
62 // ---------------------------------------------------------------------------- |
|
63 // CMuiuFlags::NewL() |
|
64 // ---------------------------------------------------------------------------- |
|
65 // |
|
66 EXPORT_C CMuiuFlags* CMuiuFlags::NewL( |
|
67 const TMuiuGlobalFeatureArray* aGlobalFeatures, |
|
68 const TMuiuLocalFeatureArray* aLocalFeatures, |
|
69 const TMuiuFlagArray* aFlags ) |
|
70 { |
|
71 CMuiuFlags* self = NewLC( aGlobalFeatures, aLocalFeatures, aFlags ); |
|
72 CleanupStack::Pop( self ); |
|
73 |
|
74 return self; |
|
75 } |
|
76 |
|
77 // ---------------------------------------------------------------------------- |
|
78 // CMuiuFlags::NewLC() |
|
79 // ---------------------------------------------------------------------------- |
|
80 // |
|
81 EXPORT_C CMuiuFlags* CMuiuFlags::NewLC( |
|
82 const TMuiuGlobalFeatureArray* aGlobalFeatures, |
|
83 const TMuiuLocalFeatureArray* aLocalFeatures, |
|
84 const TMuiuFlagArray* aFlags ) |
|
85 { |
|
86 CMuiuFlags* self = new ( ELeave ) CMuiuFlags(); |
|
87 |
|
88 CleanupStack::PushL( self ); |
|
89 self->ConstructL( aGlobalFeatures, aLocalFeatures, aFlags ); |
|
90 |
|
91 return self; |
|
92 } |
|
93 |
|
94 |
|
95 // ---------------------------------------------------------------------------- |
|
96 // CMuiuFlags::ConstructL() |
|
97 // ---------------------------------------------------------------------------- |
|
98 // |
|
99 void CMuiuFlags::ConstructL( |
|
100 const TMuiuGlobalFeatureArray* aGlobalFeatures, |
|
101 const TMuiuLocalFeatureArray* aLocalFeatures, |
|
102 const TMuiuFlagArray* aFlags ) |
|
103 { |
|
104 if ( aGlobalFeatures ) |
|
105 { |
|
106 PrepareGlobalFeaturesL( *aGlobalFeatures ); |
|
107 } |
|
108 |
|
109 // Local features |
|
110 if ( aLocalFeatures ) |
|
111 { |
|
112 PrepareLocalFeaturesL( *aLocalFeatures ); |
|
113 } |
|
114 |
|
115 // Normal flags |
|
116 if ( aFlags ) |
|
117 { |
|
118 PrepareGeneralFlags( *aFlags ); |
|
119 } |
|
120 } |
|
121 |
|
122 |
|
123 // ----------------------------- FLAG HANDLERS -------------------------------- |
|
124 |
|
125 |
|
126 // ---------------------------------------------------------------------------- |
|
127 // CMuiuFlags::PrepareGlobalFeaturesL() |
|
128 // ---------------------------------------------------------------------------- |
|
129 // |
|
130 void CMuiuFlags::PrepareGlobalFeaturesL( |
|
131 const TMuiuGlobalFeatureArray& aGlobalFeatures ) |
|
132 { |
|
133 TUint64 feature = aGlobalFeatures.Count(); |
|
134 |
|
135 // Compare the number of given features against the maximum number |
|
136 // of featureflags possible. Panic if the number of flags has been |
|
137 // exceeded. |
|
138 __ASSERT_ALWAYS( |
|
139 feature <= KMuiuFlaggerMaxFlags, |
|
140 User::Panic( KMuiuFlaggerPanic, KErrOverflow ) ); |
|
141 |
|
142 FeatureManager::InitializeLibL(); |
|
143 |
|
144 // Check all the features in array from feature manager and set |
|
145 // the flags in the same order as in the array |
|
146 while ( feature-- > 0 ) |
|
147 { |
|
148 ChangeGF( feature, |
|
149 FeatureManager::FeatureSupported( |
|
150 aGlobalFeatures[feature] ) ); |
|
151 } |
|
152 |
|
153 FeatureManager::UnInitializeLib(); |
|
154 } |
|
155 |
|
156 // ---------------------------------------------------------------------------- |
|
157 // CMuiuFlags::PrepareLocalFeaturesL() |
|
158 // ---------------------------------------------------------------------------- |
|
159 // |
|
160 void CMuiuFlags::PrepareLocalFeaturesL( |
|
161 const TMuiuLocalFeatureArray& aLocalFeatures ) |
|
162 { |
|
163 TUint64 feature = aLocalFeatures.Count(); |
|
164 |
|
165 // Compare the number of given features against the maximum number |
|
166 // of featureflags possible. Panic if the number of flags has been |
|
167 // exceeded. |
|
168 __ASSERT_ALWAYS( |
|
169 feature <= KMuiuFlaggerMaxFlags, |
|
170 User::Panic( KMuiuFlaggerPanic, KErrOverflow ) ); |
|
171 |
|
172 TInt value = 0; |
|
173 |
|
174 // Get Next CenRep session |
|
175 while ( feature-- > 0 ) |
|
176 { |
|
177 // Create temporary structure for the feature |
|
178 TMuiuLocalFeatureItem localFeature = aLocalFeatures[feature]; |
|
179 |
|
180 // Create the connection |
|
181 CRepository* cenrep = |
|
182 CRepository::NewLC( localFeature.iUid ); |
|
183 |
|
184 // Get the value from repository |
|
185 User::LeaveIfError( |
|
186 cenrep->Get( localFeature.iKeyId, value ) ); |
|
187 |
|
188 // Define the feature flag |
|
189 if ( !localFeature.iIsFlag ) |
|
190 { |
|
191 // The value in iFlag is actually an index, so roll on to right |
|
192 // and mask the other flags |
|
193 ChangeLF( feature, ( value >> localFeature.iFlag ) & 0x01 ); |
|
194 } |
|
195 else |
|
196 { |
|
197 // The value in iFlag is a real flag, so do the normal |
|
198 // and -operation and check if the bit is on |
|
199 ChangeLF( feature, ( value & localFeature.iFlag ) > 0 ); |
|
200 } |
|
201 |
|
202 // Destroy the object |
|
203 CleanupStack::PopAndDestroy( cenrep ); |
|
204 cenrep = NULL; |
|
205 } |
|
206 } |
|
207 |
|
208 |
|
209 // ---------------------------------------------------------------------------- |
|
210 // CMuiuFlags::PrepareGeneralFlags() |
|
211 // ---------------------------------------------------------------------------- |
|
212 // |
|
213 void CMuiuFlags::PrepareGeneralFlags( |
|
214 const TMuiuFlagArray& aFlags ) |
|
215 { |
|
216 TUint64 feature = aFlags.Count(); |
|
217 |
|
218 // Compare the number of given features against the maximum number |
|
219 // of featureflags possible. Panic if the number of flags has been |
|
220 // exceeded. |
|
221 __ASSERT_ALWAYS( |
|
222 feature <= KMuiuFlaggerMaxFlags, |
|
223 User::Panic( KMuiuFlaggerPanic, KErrOverflow ) ); |
|
224 |
|
225 // Check all the flags in array and set the flags in the |
|
226 // same order as in the array |
|
227 while ( feature-- > 0 ) |
|
228 { |
|
229 ChangeFlag( feature, |
|
230 FeatureManager::FeatureSupported( |
|
231 aFlags[feature] ) ); |
|
232 } |
|
233 } |
|
234 |
|
235 |
|
236 // End of File |
|
237 |
|
238 |