26
|
1 |
// Copyright (c) 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".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// Implements a utility class which read information from Central Repository
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
#include <centralrepository.h>
|
|
19 |
#include <usb/usblogger.h>
|
|
20 |
#ifdef SYMBIAN_FEATURE_MANAGER
|
|
21 |
#include <featureuids.h>
|
|
22 |
#include <featdiscovery.h>
|
|
23 |
#endif
|
|
24 |
#include "usbmanprivatecrkeys.h"
|
|
25 |
#include "UsbSettings.h"
|
|
26 |
#include "CPersonality.h"
|
|
27 |
#include "usbmancenrepmanager.h"
|
|
28 |
#include "CUsbDevice.h"
|
29
|
29 |
#include "OstTraceDefinitions.h"
|
|
30 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
31 |
#include "usbmancenrepmanagerTraces.h"
|
|
32 |
#endif
|
26
|
33 |
|
|
34 |
|
|
35 |
_LIT(KUsbCenRepPanic, "UsbCenRep");
|
|
36 |
|
|
37 |
/**
|
|
38 |
* Panic codes for the USB Central Repository Manager
|
|
39 |
*/
|
|
40 |
enum TUsbCenRepPanic
|
|
41 |
{
|
|
42 |
ECenRepObserverNotStopped = 0,
|
|
43 |
ECenRepObserverAlreadySet,
|
|
44 |
ECenRepConfigError,
|
|
45 |
ECenRepFeatureManagerError,
|
|
46 |
};
|
|
47 |
|
|
48 |
// ---------------------------------------------------------------------------
|
|
49 |
// Private consctruction
|
|
50 |
// ---------------------------------------------------------------------------
|
|
51 |
//
|
|
52 |
CUsbManCenRepManager::CUsbManCenRepManager(CUsbDevice& aUsbDevice)
|
|
53 |
: iUsbDevice( aUsbDevice )
|
|
54 |
{
|
29
|
55 |
OstTraceFunctionEntry0( CUSBMANCENREPMANAGER_CUSBMANCENREPMANAGER_CONS_ENTRY );
|
|
56 |
OstTraceFunctionExit0( CUSBMANCENREPMANAGER_CUSBMANCENREPMANAGER_CONS_EXIT );
|
26
|
57 |
}
|
|
58 |
|
|
59 |
// ---------------------------------------------------------------------------
|
|
60 |
// The first phase construction
|
|
61 |
// ---------------------------------------------------------------------------
|
|
62 |
//
|
|
63 |
CUsbManCenRepManager* CUsbManCenRepManager::NewL(CUsbDevice& aUsbDevice)
|
|
64 |
{
|
29
|
65 |
OstTraceFunctionEntry0( CUSBMANCENREPMANAGER_NEWL_ENTRY );
|
26
|
66 |
CUsbManCenRepManager* self = new (ELeave) CUsbManCenRepManager(aUsbDevice);
|
|
67 |
CleanupStack::PushL( self );
|
|
68 |
self->ConstructL();
|
|
69 |
CleanupStack::Pop( self );
|
29
|
70 |
OstTraceFunctionExit0( CUSBMANCENREPMANAGER_NEWL_EXIT );
|
26
|
71 |
return self;
|
|
72 |
}
|
|
73 |
|
|
74 |
// ---------------------------------------------------------------------------
|
|
75 |
// The second phase construction
|
|
76 |
// ---------------------------------------------------------------------------
|
|
77 |
//
|
|
78 |
void CUsbManCenRepManager::ConstructL()
|
|
79 |
{
|
29
|
80 |
OstTraceFunctionEntry0( CUSBMANCENREPMANAGER_CONSTRUCTL_ENTRY );
|
26
|
81 |
// Open the Central Repository
|
|
82 |
iRepository = CRepository::NewL( KCRUidUSBManagerConfiguration );
|
|
83 |
CheckSignatureL();
|
29
|
84 |
OstTraceFunctionExit0( CUSBMANCENREPMANAGER_CONSTRUCTL_EXIT );
|
26
|
85 |
}
|
|
86 |
|
|
87 |
// ---------------------------------------------------------------------------
|
|
88 |
// Deconstruction
|
|
89 |
// ---------------------------------------------------------------------------
|
|
90 |
//
|
|
91 |
CUsbManCenRepManager::~CUsbManCenRepManager()
|
|
92 |
{
|
29
|
93 |
OstTraceFunctionEntry0( CUSBMANCENREPMANAGER_CUSBMANCENREPMANAGER_DES_ENTRY );
|
26
|
94 |
delete iRepository;
|
29
|
95 |
OstTraceFunctionExit0( CUSBMANCENREPMANAGER_CUSBMANCENREPMANAGER_DES_EXIT );
|
26
|
96 |
}
|
|
97 |
|
|
98 |
// ---------------------------------------------------------------------------
|
|
99 |
// Read specific Key whose value type is String
|
|
100 |
// ---------------------------------------------------------------------------
|
|
101 |
//
|
|
102 |
HBufC* CUsbManCenRepManager::ReadStringKeyLC( TUint32 aKeyId )
|
|
103 |
{
|
29
|
104 |
OstTraceFunctionEntry0( CUSBMANCENREPMANAGER_READSTRINGKEYLC_ENTRY );
|
26
|
105 |
HBufC* keyBuf = HBufC::NewLC( NCentralRepositoryConstants::KMaxUnicodeStringLength );
|
|
106 |
TPtr key = keyBuf->Des();
|
|
107 |
|
29
|
108 |
TInt err = iRepository->Get( aKeyId, key );
|
|
109 |
LEAVEIFERRORL( err, OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_READSTRINGKEYLC, "CUsbManCenRepManager::ReadStringKeyLC;Leave err=%d", err ););
|
|
110 |
OstTraceExt2( TRACE_NORMAL, CUSBMANCENREPMANAGER_READSTRINGKEYLC_DUP1, "CUsbManCenRepManager::ReadStringKeyLC;aKeyId=%x;key=%S", aKeyId, key );
|
26
|
111 |
|
29
|
112 |
OstTraceFunctionExit0( CUSBMANCENREPMANAGER_READSTRINGKEYLC_EXIT );
|
26
|
113 |
return keyBuf;
|
|
114 |
}
|
|
115 |
|
|
116 |
// ---------------------------------------------------------------------------
|
|
117 |
// Read specific Key whose value type is TInt
|
|
118 |
// ---------------------------------------------------------------------------
|
|
119 |
//
|
|
120 |
TInt CUsbManCenRepManager::ReadKeyL( TUint32 aKeyId )
|
|
121 |
{
|
29
|
122 |
OstTraceFunctionEntry0( CUSBMANCENREPMANAGER_READKEYL_ENTRY );
|
26
|
123 |
TInt key;
|
|
124 |
|
29
|
125 |
TInt err = iRepository->Get( aKeyId, key );
|
|
126 |
LEAVEIFERRORL( err, OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_READKEYL, "CUsbManCenRepManager::ReadKeyL;Leave err=%d", err ); );
|
|
127 |
OstTraceExt2( TRACE_NORMAL, CUSBMANCENREPMANAGER_READKEYL_DUP1, "CUsbManCenRepManager::ReadKeyL;LocSets: ReadKeyL id: 0x%x, val: 0x%x", aKeyId, (TInt32)key );
|
26
|
128 |
|
29
|
129 |
OstTraceFunctionExit0( CUSBMANCENREPMANAGER_READKEYL_EXIT );
|
26
|
130 |
return key;
|
|
131 |
}
|
|
132 |
|
|
133 |
// ---------------------------------------------------------------------------
|
|
134 |
// Check wheather cenrep's version is supported by cenrep manager
|
|
135 |
// ---------------------------------------------------------------------------
|
|
136 |
//
|
|
137 |
void CUsbManCenRepManager::CheckSignatureL()
|
|
138 |
{
|
29
|
139 |
OstTraceFunctionEntry0( CUSBMANCENREPMANAGER_CHECKSIGNATUREL_ENTRY );
|
26
|
140 |
iSignature = ReadKeyL( KUsbManConfigSign );
|
|
141 |
|
|
142 |
if ( iSignature < TUsbManagerSupportedVersionMin ||
|
|
143 |
iSignature > TUsbManagerSupportedVersionMax )
|
|
144 |
{
|
29
|
145 |
OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_CHECKSIGNATUREL, "CUsbManCenRepManager::CheckSignatureL;Leave reason=%d", KErrNotSupported );
|
26
|
146 |
}
|
29
|
147 |
OstTraceFunctionExit0( CUSBMANCENREPMANAGER_CHECKSIGNATUREL_EXIT );
|
26
|
148 |
}
|
|
149 |
|
|
150 |
// ---------------------------------------------------------------------------
|
|
151 |
// Read Device configuration table
|
|
152 |
// ---------------------------------------------------------------------------
|
|
153 |
//
|
|
154 |
void CUsbManCenRepManager::ReadDeviceConfigurationL(CUsbDevice::TUsbDeviceConfiguration& aDeviceConfig)
|
|
155 |
{
|
29
|
156 |
OstTraceFunctionEntry0( CUSBMANCENREPMANAGER_READDEVICECONFIGURATIONL_ENTRY );
|
26
|
157 |
//Only support version four right now.
|
29
|
158 |
if(TUsbManagerSupportedVersionFour != iSignature)
|
|
159 |
{
|
|
160 |
OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_READDEVICECONFIGURATIONL, "CUsbManCenRepManager::ReadDeviceConfigurationL;Panic error=%d", ECenRepConfigError );
|
|
161 |
__ASSERT_DEBUG( EFalse, User::Panic( KUsbCenRepPanic, ECenRepConfigError ) );
|
|
162 |
}
|
|
163 |
|
26
|
164 |
|
|
165 |
//Shall only have on device configuration setting.
|
|
166 |
TUint32 devConfigCount = ReadKeyL( KUsbManDeviceCountIndexKey );
|
29
|
167 |
if(devConfigCount != 1)
|
|
168 |
{
|
|
169 |
OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_READDEVICECONFIGURATIONL_DUP1, "CUsbManCenRepManager::ReadDeviceConfigurationL;Panic error=%d", ECenRepConfigError );
|
|
170 |
__ASSERT_DEBUG( EFalse, User::Panic( KUsbCenRepPanic, ECenRepConfigError ) );
|
|
171 |
}
|
|
172 |
|
26
|
173 |
|
|
174 |
RArray<TUint32> keyArray;
|
|
175 |
CleanupClosePushL( keyArray );
|
29
|
176 |
TInt err = iRepository->FindL( KUsbManDevicePartialKey, KUsbManConfigKeyMask, keyArray );
|
|
177 |
LEAVEIFERRORL( err, OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_READDEVICECONFIGURATIONL_DUP2, "CUsbManCenRepManager::ReadDeviceConfigurationL;Leave err=%d", err ); );
|
26
|
178 |
|
|
179 |
TInt keyCount = keyArray.Count();
|
29
|
180 |
OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_READDEVICECONFIGURATIONL_DUP3, "CUsbManCenRepManager::ReadDeviceConfigurationL;keyCount of device config = %d", keyCount );
|
26
|
181 |
|
|
182 |
//Get each extension type key value and store in iExtList array
|
|
183 |
for( TInt index = 0; index < keyCount; index++ )
|
|
184 |
{
|
|
185 |
TUint32 key = keyArray[index];
|
|
186 |
TUint32 fieldId = ( key & KUsbManConfigFieldMask );
|
29
|
187 |
OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_READDEVICECONFIGURATIONL_DUP4, "CUsbManCenRepManager::ReadDeviceConfigurationL;fieldId=%d", fieldId );
|
26
|
188 |
if( fieldId == KUsbManDeviceVendorIdKey )
|
|
189 |
{
|
|
190 |
aDeviceConfig.iVendorId = ReadKeyL( key );
|
|
191 |
}
|
|
192 |
else if( fieldId == KUsbManDeviceManufacturerNameKey )
|
|
193 |
{
|
|
194 |
HBufC* manufacturer = ReadStringKeyLC( key );
|
|
195 |
TPtr manufacturerPtr = manufacturer->Des();
|
|
196 |
aDeviceConfig.iManufacturerName->Des().Copy( manufacturerPtr );
|
|
197 |
CleanupStack::PopAndDestroy( manufacturer );
|
|
198 |
}
|
|
199 |
else if( fieldId == KUsbManDeviceProductNameKey )
|
|
200 |
{
|
|
201 |
HBufC* product = ReadStringKeyLC( key );
|
|
202 |
TPtr productName = product->Des();
|
|
203 |
aDeviceConfig.iProductName->Des().Copy( productName );
|
|
204 |
CleanupStack::PopAndDestroy( product );
|
|
205 |
}
|
|
206 |
else
|
|
207 |
{
|
29
|
208 |
OstTrace1( TRACE_FATAL, CUSBMANCENREPMANAGER_READDEVICECONFIGURATIONL_DUP5, "CUsbManCenRepManager::ReadDeviceConfigurationL;panic error=%d", ECenRepConfigError );
|
|
209 |
User::Panic( KUsbCenRepPanic, ECenRepConfigError );
|
26
|
210 |
}
|
|
211 |
}
|
|
212 |
CleanupStack::PopAndDestroy( &keyArray );
|
29
|
213 |
OstTraceFunctionExit0( CUSBMANCENREPMANAGER_READDEVICECONFIGURATIONL_EXIT );
|
26
|
214 |
}
|
|
215 |
|
|
216 |
|
|
217 |
// ---------------------------------------------------------------------------
|
|
218 |
// Read personality table
|
|
219 |
// ---------------------------------------------------------------------------
|
|
220 |
//
|
|
221 |
void CUsbManCenRepManager::ReadPersonalitiesL(RPointerArray<CPersonality>& aPersonalities)
|
|
222 |
{
|
29
|
223 |
OstTraceFunctionEntry0( CUSBMANCENREPMANAGER_READPERSONALITIESL_ENTRY );
|
26
|
224 |
|
|
225 |
//Only support version four right now.
|
29
|
226 |
if(TUsbManagerSupportedVersionFour != iSignature)
|
|
227 |
{
|
|
228 |
OstTrace1( TRACE_FATAL, CUSBMANCENREPMANAGER_READPERSONALITIESL, "CUsbManCenRepManager::ReadPersonalitiesL;ECenRepConfigError=%d", ECenRepConfigError );
|
|
229 |
__ASSERT_DEBUG( EFalse, User::Panic( KUsbCenRepPanic, ECenRepConfigError ) );
|
|
230 |
}
|
|
231 |
|
26
|
232 |
// Get the personality count.
|
|
233 |
TUint32 personalityCount = ReadKeyL( KUsbManDevicePersonalitiesCountIndexKey );
|
29
|
234 |
OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_READPERSONALITIESL_DUP3, "CUsbManCenRepManager::ReadPersonalitiesL;personalityCount=%d", personalityCount );
|
26
|
235 |
|
|
236 |
RArray<TUint32> keyArray;
|
|
237 |
CleanupClosePushL( keyArray );
|
|
238 |
|
|
239 |
|
|
240 |
// Go through all personalities and store them.
|
|
241 |
for( TInt personalityIdx = 0; personalityIdx < personalityCount; personalityIdx++ )
|
|
242 |
{
|
|
243 |
CPersonality* personality = CPersonality::NewL();
|
|
244 |
CleanupStack::PushL( personality );
|
|
245 |
|
|
246 |
// Find the keys belonging to the personality
|
|
247 |
TUint32 devicePersonalitiesKey = KUsbManDevicePersonalitiesPartialKey | ( personalityIdx << KUsbManPersonalitiesOffset );
|
29
|
248 |
TInt err = iRepository->FindL( devicePersonalitiesKey, KUsbManConfigKeyMask, keyArray );
|
|
249 |
LEAVEIFERRORL( err, OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_READPERSONALITIESL_DUP1, "CUsbManCenRepManager::ReadPersonalitiesL;Leave err=%d", err ); );
|
26
|
250 |
|
|
251 |
TInt keyCount = keyArray.Count();
|
29
|
252 |
OstTrace1( TRACE_NORMAL, DUP2_CUSBMANCENREPMANAGER_READPERSONALITIESL_DUP2, "CUsbManCenRepManager::ReadPersonalitiesL; keyCount of personality = %d", keyCount );
|
26
|
253 |
|
|
254 |
// Get each key value of the personality and store it.
|
|
255 |
for( TInt keyIdx = 0; keyIdx < keyCount; keyIdx++ )
|
|
256 |
{
|
|
257 |
TUint32 key = keyArray[keyIdx];
|
|
258 |
TUint32 fieldId = (key & KUsbManConfigFieldMask);
|
29
|
259 |
OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_READPERSONALITIESL_DUP4, "CUsbManCenRepManager::ReadPersonalitiesL;key id of personality=%d", fieldId );
|
26
|
260 |
switch( fieldId )
|
|
261 |
{
|
|
262 |
case KUsbManDevicePersonalitiesDeviceClassKey:
|
|
263 |
personality->SetDeviceClass(ReadKeyL( key ));
|
|
264 |
break;
|
|
265 |
case KUsbManDevicePersonalitiesDeviceSubClassKey:
|
|
266 |
personality->SetDeviceSubClass(ReadKeyL( key ));
|
|
267 |
break;
|
|
268 |
case KUsbManDevicePersonalitiesProtocolKey:
|
|
269 |
personality->SetDeviceProtocol(ReadKeyL( key ));
|
|
270 |
break;
|
|
271 |
case KUsbManDevicePersonalitiesNumConfigKey:
|
|
272 |
personality->SetNumConfigurations(ReadKeyL( key ));
|
|
273 |
break;
|
|
274 |
case KUsbManDevicePersonalitiesProductIdKey:
|
|
275 |
personality->SetProductId(ReadKeyL( key ));
|
|
276 |
break;
|
|
277 |
case KUsbManDevicePersonalitiesBcdDeviceKey:
|
|
278 |
personality->SetBcdDevice(ReadKeyL( key ));
|
|
279 |
break;
|
|
280 |
case KUsbManDevicePersonalitiesFeatureIdKey:
|
|
281 |
personality->SetFeatureId(ReadKeyL( key ));
|
|
282 |
break;
|
|
283 |
case KUsbManDevicePersonalitiesPersonalityIdKey:
|
|
284 |
personality->SetPersonalityId(ReadKeyL( key ));
|
|
285 |
ReadConfigurationsForPersonalityL( personality->PersonalityId(), *personality );
|
|
286 |
break;
|
|
287 |
case KUsbManDevicePersonalitiesPropertyKey:
|
|
288 |
personality->SetProperty(ReadKeyL( key ));
|
|
289 |
break;
|
|
290 |
case KUsbManDevicePersonalitiesDescriptionKey:
|
|
291 |
{
|
|
292 |
HBufC* description;
|
|
293 |
description = ReadStringKeyLC( key );
|
|
294 |
personality->SetDescription( description );
|
|
295 |
CleanupStack::PopAndDestroy( description );
|
|
296 |
break;
|
|
297 |
}
|
|
298 |
default:
|
29
|
299 |
OstTrace1( TRACE_FATAL, CUSBMANCENREPMANAGER_READPERSONALITIESL_DUP5, "CUsbManCenRepManager::ReadPersonalitiesL;Panic error=%d", ECenRepConfigError );
|
|
300 |
User::Panic( KUsbCenRepPanic, ECenRepConfigError );
|
26
|
301 |
break;
|
|
302 |
}
|
|
303 |
}
|
|
304 |
|
|
305 |
personality->SetVersion(iSignature);
|
|
306 |
|
|
307 |
//The following code is to check whether we support this personality.
|
|
308 |
if(personality->FeatureId() != KUsbManFeatureNotConfigurable)
|
|
309 |
{
|
|
310 |
if(!IsFeatureSupportedL(personality->FeatureId()))
|
|
311 |
{
|
|
312 |
CleanupStack::PopAndDestroy(personality);
|
|
313 |
continue;
|
|
314 |
}
|
|
315 |
}
|
|
316 |
|
|
317 |
//The following code is to check whether we support this personality. It will not include:
|
|
318 |
//1)the personality which contains single class which is not supported
|
|
319 |
//2)the personality which contains multiple classes which are all not supported
|
|
320 |
TBool isPersonalitySupport = EFalse;
|
|
321 |
TInt configurationCount = personality->PersonalityConfigs().Count();
|
|
322 |
for(TInt configurationIdx = 0; configurationIdx < configurationCount; ++configurationIdx)
|
|
323 |
{
|
|
324 |
const RPointerArray<CPersonalityConfigurations>& personalityConfigs = personality->PersonalityConfigs();
|
|
325 |
CPersonalityConfigurations *personalityConfigurations = personalityConfigs[configurationIdx];
|
|
326 |
TInt classesCount = personalityConfigurations->Classes().Count();
|
|
327 |
if(0 != classesCount)
|
|
328 |
{
|
|
329 |
isPersonalitySupport = ETrue;
|
|
330 |
break;
|
|
331 |
}
|
|
332 |
}
|
|
333 |
|
|
334 |
if(isPersonalitySupport)
|
|
335 |
{
|
29
|
336 |
OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_READPERSONALITIESL_DUP6, "CUsbManCenRepManager::ReadPersonalitiesL; Personality ID: %d is supported", personality->PersonalityId() );
|
26
|
337 |
aPersonalities.Append( personality );
|
|
338 |
CleanupStack::Pop( personality );
|
|
339 |
}
|
|
340 |
else
|
|
341 |
{
|
29
|
342 |
OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_READPERSONALITIESL_DUP7, "CUsbManCenRepManager::ReadPersonalitiesL;Personality ID: %d is not supported", personality->PersonalityId() );
|
26
|
343 |
CleanupStack::PopAndDestroy(personality);
|
|
344 |
}
|
|
345 |
}
|
|
346 |
CleanupStack::PopAndDestroy( &keyArray );
|
29
|
347 |
OstTraceFunctionExit0( CUSBMANCENREPMANAGER_READPERSONALITIESL_EXIT );
|
26
|
348 |
}
|
|
349 |
|
|
350 |
// ---------------------------------------------------------------------------
|
|
351 |
// Read configuration table for specific personality
|
|
352 |
// ---------------------------------------------------------------------------
|
|
353 |
//
|
|
354 |
void CUsbManCenRepManager::ReadConfigurationsForPersonalityL(TInt aPersonalityId, CPersonality& aPersonality)
|
|
355 |
{
|
29
|
356 |
OstTraceFunctionEntry0( CUSBMANCENREPMANAGER_READCONFIGURATIONSFORPERSONALITYL_ENTRY );
|
26
|
357 |
RArray<TUint32> configArray;
|
|
358 |
CleanupClosePushL(configArray);
|
|
359 |
|
|
360 |
//Only support version four right now.
|
29
|
361 |
if(TUsbManagerSupportedVersionFour != iSignature)
|
|
362 |
{
|
|
363 |
OstTrace1( TRACE_FATAL, CUSBMANCENREPMANAGER_READCONFIGURATIONSFORPERSONALITYL, "CUsbManCenRepManager::ReadConfigurationsForPersonalityL;Panic error=%d", ECenRepConfigError );
|
|
364 |
__ASSERT_DEBUG( EFalse, User::Panic( KUsbCenRepPanic, ECenRepConfigError ) );
|
|
365 |
}
|
|
366 |
|
|
367 |
TInt err = iRepository->FindEqL( KUsbManDeviceConfigurationsPartialKey, KUsbManConfigFirstEntryMask, aPersonalityId, configArray );
|
|
368 |
LEAVEIFERRORL( err, OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_READCONFIGURATIONSFORPERSONALITYL_DUP1, "CUsbManCenRepManager::ReadConfigurationsForPersonalityL;Leave err=%d", err ); );
|
26
|
369 |
|
|
370 |
// Get the configuration count.
|
|
371 |
TUint32 configCount = configArray.Count();
|
|
372 |
TUint32 totalConfigCount = ReadKeyL( KUsbManDeviceConfigurationsCountIndexKey );
|
|
373 |
|
29
|
374 |
OstTraceExt3( TRACE_NORMAL, CUSBMANCENREPMANAGER_READCONFIGURATIONSFORPERSONALITYL_DUP2,
|
|
375 |
"CUsbManCenRepManager::ReadConfigurationsForPersonalityL;aPersonalityId = %d total configCount = %d configArray.Count() = %d", aPersonalityId, totalConfigCount, configArray.Count() );
|
26
|
376 |
|
|
377 |
//This is intend to handle one special case that key 0x2ff00's value
|
|
378 |
// equal our target personality id.
|
|
379 |
if(totalConfigCount == aPersonalityId)
|
|
380 |
{
|
|
381 |
--configCount;
|
|
382 |
}
|
|
383 |
|
|
384 |
TInt keyCount = 0;
|
|
385 |
if(TUsbManagerSupportedVersionFour == iSignature)
|
|
386 |
{
|
|
387 |
keyCount = KUsbManDeviceConfigurationsKeyCountVersionFour;
|
|
388 |
}
|
|
389 |
|
|
390 |
// Go through all configurations belonging to this personality 'aPersonalityId'
|
|
391 |
for ( TInt configIdx = 0; configIdx < configCount; configIdx++ )
|
|
392 |
{
|
|
393 |
CPersonalityConfigurations* config = new ( ELeave ) CPersonalityConfigurations;
|
|
394 |
CleanupStack::PushL( config );
|
|
395 |
TUint32 key = configArray[configIdx];
|
|
396 |
|
|
397 |
// Get each key value in the configuration and store it
|
|
398 |
for ( TInt keyIdx = 0; keyIdx < keyCount; keyIdx++ )
|
|
399 |
{
|
|
400 |
TUint32 fieldId = ( (key + keyIdx ) & KUsbManConfigFieldMask );
|
|
401 |
TInt keyValue = -1;
|
29
|
402 |
OstTraceExt3( TRACE_NORMAL, CUSBMANCENREPMANAGER_READCONFIGURATIONSFORPERSONALITYL_DUP3, "CUsbManCenRepManager::ReadConfigurationsForPersonalityL;fieldId=%d;configIdx=%d;keyIdx=%d", fieldId, configIdx, keyIdx );
|
26
|
403 |
|
|
404 |
if(KUsbManDeviceConfigurationsPersonalityIdKey == fieldId)
|
|
405 |
{
|
|
406 |
TRAPD( err, keyValue = ReadKeyL( key + keyIdx ) );
|
|
407 |
if( err == KErrNone )
|
|
408 |
{
|
29
|
409 |
if(keyValue != aPersonalityId)
|
|
410 |
{
|
|
411 |
OstTrace1( TRACE_FATAL, CUSBMANCENREPMANAGER_READCONFIGURATIONSFORPERSONALITYL_DUP4, "CUsbManCenRepManager::ReadConfigurationsForPersonalityL;Panic error=%d", ECenRepConfigError );
|
|
412 |
__ASSERT_DEBUG( EFalse, User::Panic( KUsbCenRepPanic, ECenRepConfigError ) );
|
|
413 |
}
|
26
|
414 |
config->SetPersonalityId( keyValue );
|
|
415 |
}
|
|
416 |
}
|
|
417 |
else if(KUsbManDeviceConfigurationsIdKey == fieldId)
|
|
418 |
{
|
|
419 |
TRAPD( err, keyValue = ReadKeyL( key + keyIdx ) );
|
|
420 |
if( err == KErrNone )
|
|
421 |
{
|
|
422 |
config->SetConfigId(keyValue);
|
|
423 |
}
|
|
424 |
}
|
|
425 |
else if(KUsbManDeviceConfigurationsClassUidsKey == fieldId)
|
|
426 |
{
|
|
427 |
HBufC* keyValueBuf = ReadStringKeyLC( key + keyIdx );
|
|
428 |
TPtr keyPtr = keyValueBuf->Des();
|
|
429 |
|
|
430 |
RArray<TUint> classUids;
|
|
431 |
CleanupClosePushL( classUids );
|
|
432 |
|
|
433 |
iUsbDevice.ConvertUidsL( keyPtr, classUids );
|
|
434 |
TInt uidsCnt = classUids.Count();
|
|
435 |
|
|
436 |
// Get featureId of each class and store each class.
|
|
437 |
TInt featureId = KUsbManFeatureNotConfigurable;
|
|
438 |
CPersonalityConfigurations::TUsbClasses usbClass;
|
|
439 |
for ( TInt uidIdx = 0; uidIdx < uidsCnt; uidIdx++ )
|
|
440 |
{
|
|
441 |
usbClass.iClassUid = TUid::Uid( classUids[uidIdx] );
|
|
442 |
usbClass.iFeatureId = featureId; // By default
|
|
443 |
if ( IsClassConfigurableL( classUids[uidIdx], featureId ) )
|
|
444 |
{
|
|
445 |
usbClass.iFeatureId = featureId;
|
|
446 |
if(IsFeatureSupportedL(featureId))
|
|
447 |
{
|
|
448 |
config->AppendClassesL( usbClass );
|
|
449 |
}
|
|
450 |
}
|
|
451 |
else
|
|
452 |
{
|
|
453 |
config->AppendClassesL( usbClass );
|
|
454 |
}
|
|
455 |
}
|
|
456 |
|
|
457 |
CleanupStack::PopAndDestroy( &classUids ); // close uid array
|
|
458 |
CleanupStack::PopAndDestroy( keyValueBuf );
|
|
459 |
}
|
|
460 |
else
|
|
461 |
{
|
29
|
462 |
OstTrace1( TRACE_FATAL, CUSBMANCENREPMANAGER_READCONFIGURATIONSFORPERSONALITYL_DUP5, "CUsbManCenRepManager::ReadConfigurationsForPersonalityL;Panic error=%d", ECenRepConfigError );
|
|
463 |
User::Panic( KUsbCenRepPanic, ECenRepConfigError );
|
26
|
464 |
}
|
|
465 |
}
|
|
466 |
aPersonality.AppendPersonalityConfigsL( config );
|
|
467 |
|
|
468 |
CleanupStack::Pop( config );
|
|
469 |
}
|
|
470 |
|
|
471 |
CleanupStack::PopAndDestroy( &configArray );
|
29
|
472 |
OstTraceFunctionExit0( CUSBMANCENREPMANAGER_READCONFIGURATIONSFORPERSONALITYL_EXIT );
|
26
|
473 |
}
|
|
474 |
|
|
475 |
// ---------------------------------------------------------------------------
|
|
476 |
// Check the class belonging to a personality configurable or not.
|
|
477 |
// ---------------------------------------------------------------------------
|
|
478 |
//
|
|
479 |
TBool CUsbManCenRepManager::IsClassConfigurableL(TUint aClassId, TInt& aFeatureId)
|
|
480 |
{
|
29
|
481 |
OstTraceFunctionEntry0( CUSBMANCENREPMANAGER_ISCLASSCONFIGURABLEL_ENTRY );
|
26
|
482 |
TBool classConfigurable = EFalse;
|
|
483 |
RArray<TUint32> keyArray;
|
|
484 |
CleanupClosePushL(keyArray);
|
|
485 |
|
|
486 |
TInt err = iRepository->FindEqL( KUsbManDeviceConfigurableClassesPartialKey, KUsbManConfigFirstEntryMask, (TInt)aClassId, keyArray );
|
29
|
487 |
OstTraceExt2( TRACE_NORMAL, CUSBMANCENREPMANAGER_ISCLASSCONFIGURABLEL, "CUsbManCenRepManager::IsClassConfigurableL;aClassId=0x%x;err=%d", aClassId, err );
|
26
|
488 |
switch ( err )
|
|
489 |
{
|
|
490 |
case KErrNotFound:
|
|
491 |
break;
|
|
492 |
case KErrNone:
|
|
493 |
{
|
29
|
494 |
#ifdef _DEBUG
|
|
495 |
if(keyArray.Count() != 1)
|
|
496 |
{
|
|
497 |
OstTrace1( TRACE_FATAL, DUP1_CUSBMANCENREPMANAGER_ISCLASSCONFIGURABLEL_DUP1, "CUsbManCenRepManager::IsClassConfigurableL;panic error=%d", ECenRepConfigError );
|
|
498 |
User::Panic( KUsbCenRepPanic, ECenRepConfigError );
|
|
499 |
}
|
|
500 |
#endif
|
26
|
501 |
// The array size always is 1, so here using 0 as index.
|
|
502 |
aFeatureId = ReadKeyL( keyArray[0] | KUsbManDeviceConfigurableClassesFeatureIdKey );
|
|
503 |
classConfigurable = ETrue;
|
|
504 |
break;
|
|
505 |
}
|
|
506 |
default:
|
29
|
507 |
OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_ISCLASSCONFIGURABLEL_DUP2, "CUsbManCenRepManager::IsClassConfigurableL;Leave err=%d", err );
|
|
508 |
User::Leave( err );
|
26
|
509 |
break;
|
|
510 |
}
|
|
511 |
|
|
512 |
CleanupStack::PopAndDestroy( &keyArray );
|
29
|
513 |
OstTraceFunctionExit0( CUSBMANCENREPMANAGER_ISCLASSCONFIGURABLEL_EXIT );
|
26
|
514 |
return classConfigurable;
|
|
515 |
}
|
|
516 |
|
|
517 |
// ---------------------------------------------------------------------------
|
|
518 |
// Check the class belonging to a personality support or not.
|
|
519 |
// ---------------------------------------------------------------------------
|
|
520 |
//
|
|
521 |
TBool CUsbManCenRepManager::IsFeatureSupportedL(TInt aFeatureId)
|
|
522 |
{
|
29
|
523 |
OstTraceFunctionEntry0( CUSBMANCENREPMANAGER_ISFEATURESUPPORTEDL_ENTRY );
|
26
|
524 |
#ifdef SYMBIAN_FEATURE_MANAGER
|
|
525 |
if(CFeatureDiscovery::IsFeatureSupportedL(TUid::Uid(aFeatureId)))
|
|
526 |
{
|
29
|
527 |
OstTrace1( TRACE_NORMAL, DUP1_CUSBMANCENREPMANAGER_ISFEATURESUPPORTEDL_DUP1, "CUsbManCenRepManager::IsFeatureSupportedL;featureId = 0x%x supported", aFeatureId );
|
|
528 |
OstTraceFunctionExit0( CUSBMANCENREPMANAGER_ISFEATURESUPPORTEDL_EXIT );
|
26
|
529 |
return ETrue;
|
|
530 |
}
|
|
531 |
else
|
|
532 |
{
|
29
|
533 |
OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_ISFEATURESUPPORTEDL_DUP2, "CUsbManCenRepManager::IsFeatureSupportedL;featureId = 0x%x not supported", aFeatureId );
|
|
534 |
OstTraceFunctionExit0( CUSBMANCENREPMANAGER_ISFEATURESUPPORTEDL_EXIT_DUP1 );
|
26
|
535 |
return EFalse;
|
|
536 |
}
|
|
537 |
#else
|
29
|
538 |
OstTrace1( TRACE_FATAL, CUSBMANCENREPMANAGER_ISFEATURESUPPORTEDL, "CUsbManCenRepManager::IsFeatureSupportedL;panic error code=%d", ECenRepFeatureManagerError );
|
|
539 |
User::Panic( KUsbCenRepPanic, ECenRepFeatureManagerError )
|
26
|
540 |
#endif
|
|
541 |
}
|