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