usbmgmt/usbmgr/usbman/server/SRC/usbmancenrepmanager.cpp
changeset 36 1a2a19ee918d
parent 31 4bea936937d0
child 48 21625e5de155
equal deleted inserted replaced
31:4bea936937d0 36:1a2a19ee918d
    24 #include "usbmanprivatecrkeys.h"
    24 #include "usbmanprivatecrkeys.h"
    25 #include "UsbSettings.h"
    25 #include "UsbSettings.h"
    26 #include "CPersonality.h"
    26 #include "CPersonality.h"
    27 #include "usbmancenrepmanager.h"
    27 #include "usbmancenrepmanager.h"
    28 #include "CUsbDevice.h"
    28 #include "CUsbDevice.h"
    29 
    29 #include "OstTraceDefinitions.h"
    30 
    30 #ifdef OST_TRACE_COMPILER_IN_USE
    31 #ifdef __FLOG_ACTIVE
    31 #include "usbmancenrepmanagerTraces.h"
    32 _LIT8(KLogComponent, "USBSVR");
       
    33 #endif
    32 #endif
       
    33 
    34  
    34  
    35 _LIT(KUsbCenRepPanic, "UsbCenRep");
    35 _LIT(KUsbCenRepPanic, "UsbCenRep");
    36 
    36 
    37 /**
    37 /**
    38  * Panic codes for the USB Central Repository Manager
    38  * Panic codes for the USB Central Repository Manager
    50 // ---------------------------------------------------------------------------
    50 // ---------------------------------------------------------------------------
    51 //
    51 //
    52 CUsbManCenRepManager::CUsbManCenRepManager(CUsbDevice& aUsbDevice)
    52 CUsbManCenRepManager::CUsbManCenRepManager(CUsbDevice& aUsbDevice)
    53   : iUsbDevice( aUsbDevice )
    53   : iUsbDevice( aUsbDevice )
    54 	{
    54 	{
    55     LOG_FUNC
    55     OstTraceFunctionEntry0( CUSBMANCENREPMANAGER_CUSBMANCENREPMANAGER_CONS_ENTRY );
       
    56 	OstTraceFunctionExit0( CUSBMANCENREPMANAGER_CUSBMANCENREPMANAGER_CONS_EXIT );
    56 	}
    57 	}
    57 
    58 
    58 // ---------------------------------------------------------------------------
    59 // ---------------------------------------------------------------------------
    59 // The first phase construction   
    60 // The first phase construction   
    60 // ---------------------------------------------------------------------------
    61 // ---------------------------------------------------------------------------
    61 //
    62 //
    62 CUsbManCenRepManager* CUsbManCenRepManager::NewL(CUsbDevice& aUsbDevice)
    63 CUsbManCenRepManager* CUsbManCenRepManager::NewL(CUsbDevice& aUsbDevice)
    63     {
    64     {
    64     LOG_STATIC_FUNC_ENTRY
    65     OstTraceFunctionEntry0( CUSBMANCENREPMANAGER_NEWL_ENTRY );
    65     CUsbManCenRepManager* self = new (ELeave) CUsbManCenRepManager(aUsbDevice);
    66     CUsbManCenRepManager* self = new (ELeave) CUsbManCenRepManager(aUsbDevice);
    66     CleanupStack::PushL( self );
    67     CleanupStack::PushL( self );
    67     self->ConstructL();
    68     self->ConstructL();
    68     CleanupStack::Pop( self );
    69     CleanupStack::Pop( self );
       
    70     OstTraceFunctionExit0( CUSBMANCENREPMANAGER_NEWL_EXIT );
    69     return self;
    71     return self;
    70     }
    72     }
    71 
    73 
    72 // ---------------------------------------------------------------------------
    74 // ---------------------------------------------------------------------------
    73 // The second phase construction   
    75 // The second phase construction   
    74 // ---------------------------------------------------------------------------
    76 // ---------------------------------------------------------------------------
    75 //
    77 //
    76 void CUsbManCenRepManager::ConstructL()
    78 void CUsbManCenRepManager::ConstructL()
    77     {
    79     {
    78     LOG_FUNC
    80     OstTraceFunctionEntry0( CUSBMANCENREPMANAGER_CONSTRUCTL_ENTRY );
    79     // Open the Central Repository
    81     // Open the Central Repository
    80     iRepository = CRepository::NewL( KCRUidUSBManagerConfiguration );
    82     iRepository = CRepository::NewL( KCRUidUSBManagerConfiguration );
    81     CheckSignatureL();
    83     CheckSignatureL();
       
    84     OstTraceFunctionExit0( CUSBMANCENREPMANAGER_CONSTRUCTL_EXIT );
    82     }
    85     }
    83 
    86 
    84 // ---------------------------------------------------------------------------
    87 // ---------------------------------------------------------------------------
    85 // Deconstruction   
    88 // Deconstruction   
    86 // ---------------------------------------------------------------------------
    89 // ---------------------------------------------------------------------------
    87 //
    90 //
    88 CUsbManCenRepManager::~CUsbManCenRepManager()
    91 CUsbManCenRepManager::~CUsbManCenRepManager()
    89 	{
    92 	{
    90     LOG_FUNC
    93     OstTraceFunctionEntry0( CUSBMANCENREPMANAGER_CUSBMANCENREPMANAGER_DES_ENTRY );
    91     delete iRepository;
    94     delete iRepository;
       
    95 	OstTraceFunctionExit0( CUSBMANCENREPMANAGER_CUSBMANCENREPMANAGER_DES_EXIT );
    92 	}
    96 	}
    93 
    97 
    94 // ---------------------------------------------------------------------------
    98 // ---------------------------------------------------------------------------
    95 // Read specific Key whose value type is String   
    99 // Read specific Key whose value type is String   
    96 // ---------------------------------------------------------------------------
   100 // ---------------------------------------------------------------------------
    97 //
   101 //
    98 HBufC* CUsbManCenRepManager::ReadStringKeyLC( TUint32 aKeyId )
   102 HBufC* CUsbManCenRepManager::ReadStringKeyLC( TUint32 aKeyId )
    99 	{
   103 	{
   100     LOG_FUNC
   104     OstTraceFunctionEntry0( CUSBMANCENREPMANAGER_READSTRINGKEYLC_ENTRY );
   101     HBufC* keyBuf = HBufC::NewLC( NCentralRepositoryConstants::KMaxUnicodeStringLength );
   105     HBufC* keyBuf = HBufC::NewLC( NCentralRepositoryConstants::KMaxUnicodeStringLength );
   102     TPtr key = keyBuf->Des();
   106     TPtr key = keyBuf->Des();
   103 
   107 
   104     LEAVEIFERRORL( iRepository->Get( aKeyId, key ) );
   108     TInt err = iRepository->Get( aKeyId, key );
   105 	LOGTEXT3(_L("LocSets: ReadStringKeyLC id: %x, val: %S"), aKeyId, &key ); 
   109     LEAVEIFERRORL( err, OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_READSTRINGKEYLC, "CUsbManCenRepManager::ReadStringKeyLC;Leave err=%d", err ););
   106 
   110 	OstTraceExt2( TRACE_NORMAL, CUSBMANCENREPMANAGER_READSTRINGKEYLC_DUP1, "CUsbManCenRepManager::ReadStringKeyLC;aKeyId=%x;key=%S", aKeyId, key );
       
   111 
       
   112     OstTraceFunctionExit0( CUSBMANCENREPMANAGER_READSTRINGKEYLC_EXIT );
   107     return keyBuf;
   113     return keyBuf;
   108     }
   114     }
   109 
   115 
   110 // ---------------------------------------------------------------------------
   116 // ---------------------------------------------------------------------------
   111 // Read specific Key whose value type is TInt   
   117 // Read specific Key whose value type is TInt   
   112 // ---------------------------------------------------------------------------
   118 // ---------------------------------------------------------------------------
   113 //
   119 //
   114 TInt CUsbManCenRepManager::ReadKeyL( TUint32 aKeyId )
   120 TInt CUsbManCenRepManager::ReadKeyL( TUint32 aKeyId )
   115     {
   121     {
   116     LOG_FUNC
   122     OstTraceFunctionEntry0( CUSBMANCENREPMANAGER_READKEYL_ENTRY );
   117     TInt key;
   123     TInt key;
   118     
   124     
   119     LEAVEIFERRORL( iRepository->Get( aKeyId, key ) );
   125     TInt err = iRepository->Get( aKeyId, key );
   120     LOGTEXT3(_L("LocSets: ReadKeyL id: 0x%x, val: 0x%x"), aKeyId, key); 
   126     LEAVEIFERRORL( err, OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_READKEYL, "CUsbManCenRepManager::ReadKeyL;Leave err=%d", err ); );
   121 
   127     OstTraceExt2( TRACE_NORMAL, CUSBMANCENREPMANAGER_READKEYL_DUP1, "CUsbManCenRepManager::ReadKeyL;LocSets: ReadKeyL id: 0x%x, val: 0x%x", aKeyId, (TInt32)key );
       
   128 
       
   129     OstTraceFunctionExit0( CUSBMANCENREPMANAGER_READKEYL_EXIT );
   122     return key;
   130     return key;
   123     }
   131     }
   124 
   132 
   125 // ---------------------------------------------------------------------------
   133 // ---------------------------------------------------------------------------
   126 // Check wheather cenrep's version is supported by cenrep manager 
   134 // Check wheather cenrep's version is supported by cenrep manager 
   127 // ---------------------------------------------------------------------------
   135 // ---------------------------------------------------------------------------
   128 //
   136 //
   129 void CUsbManCenRepManager::CheckSignatureL()
   137 void CUsbManCenRepManager::CheckSignatureL()
   130     {
   138     {
   131     LOG_FUNC
   139     OstTraceFunctionEntry0( CUSBMANCENREPMANAGER_CHECKSIGNATUREL_ENTRY );
   132     iSignature = ReadKeyL( KUsbManConfigSign );
   140     iSignature = ReadKeyL( KUsbManConfigSign );
   133     
   141     
   134     if ( iSignature < TUsbManagerSupportedVersionMin ||
   142     if ( iSignature < TUsbManagerSupportedVersionMin ||
   135             iSignature > TUsbManagerSupportedVersionMax )
   143             iSignature > TUsbManagerSupportedVersionMax )
   136         {
   144         {
   137         LEAVEL(KErrNotSupported);
   145         OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_CHECKSIGNATUREL, "CUsbManCenRepManager::CheckSignatureL;Leave reason=%d", KErrNotSupported );
   138         }    
   146         }    
       
   147     OstTraceFunctionExit0( CUSBMANCENREPMANAGER_CHECKSIGNATUREL_EXIT );
   139     }
   148     }
   140 
   149 
   141 // ---------------------------------------------------------------------------
   150 // ---------------------------------------------------------------------------
   142 // Read Device configuration table 
   151 // Read Device configuration table 
   143 // ---------------------------------------------------------------------------
   152 // ---------------------------------------------------------------------------
   144 //
   153 //
   145 void CUsbManCenRepManager::ReadDeviceConfigurationL(CUsbDevice::TUsbDeviceConfiguration& aDeviceConfig)
   154 void CUsbManCenRepManager::ReadDeviceConfigurationL(CUsbDevice::TUsbDeviceConfiguration& aDeviceConfig)
   146     {
   155     {
   147     LOG_FUNC
   156     OstTraceFunctionEntry0( CUSBMANCENREPMANAGER_READDEVICECONFIGURATIONL_ENTRY );
   148     //Only support version four right now.
   157     //Only support version four right now.
   149     __ASSERT_DEBUG( ( TUsbManagerSupportedVersionFour == iSignature ), _USB_PANIC( KUsbCenRepPanic, ECenRepConfigError ) );
   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     
   150     
   164     
   151     //Shall only have on device configuration setting.
   165     //Shall only have on device configuration setting.
   152     TUint32 devConfigCount = ReadKeyL( KUsbManDeviceCountIndexKey );
   166     TUint32 devConfigCount = ReadKeyL( KUsbManDeviceCountIndexKey );
   153     __ASSERT_DEBUG( ( devConfigCount == 1 ), _USB_PANIC( KUsbCenRepPanic, ECenRepConfigError ) );
   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     
   154         
   173         
   155     RArray<TUint32> keyArray;
   174     RArray<TUint32> keyArray;
   156     CleanupClosePushL( keyArray );
   175     CleanupClosePushL( keyArray );
   157     LEAVEIFERRORL( iRepository->FindL( KUsbManDevicePartialKey, KUsbManConfigKeyMask, keyArray ) );
   176     TInt err = iRepository->FindL( KUsbManDevicePartialKey, KUsbManConfigKeyMask, keyArray );
       
   177     LEAVEIFERRORL( err, OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_READDEVICECONFIGURATIONL_DUP2, "CUsbManCenRepManager::ReadDeviceConfigurationL;Leave err=%d", err ); );
   158     
   178     
   159     TInt keyCount = keyArray.Count();
   179     TInt keyCount = keyArray.Count();
   160     LOGTEXT2( _L("CUsbManCenRepManager::ReadDeviceConfigurationL keyCount of device config = %d"), keyCount );
   180     OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_READDEVICECONFIGURATIONL_DUP3, "CUsbManCenRepManager::ReadDeviceConfigurationL;keyCount of device config = %d", keyCount );
   161     
   181     
   162     //Get each extension type key value and store in iExtList array
   182     //Get each extension type key value and store in iExtList array
   163     for( TInt index = 0; index < keyCount; index++ )
   183     for( TInt index = 0; index < keyCount; index++ )
   164         {
   184         {
   165         TUint32 key = keyArray[index];
   185         TUint32 key = keyArray[index];
   166         TUint32 fieldId = ( key & KUsbManConfigFieldMask );
   186         TUint32 fieldId = ( key & KUsbManConfigFieldMask );
   167         LOGTEXT2( _L("CUsbManCenRepManager::ReadDeviceConfigurationL fieldId = %d"), fieldId );
   187         OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_READDEVICECONFIGURATIONL_DUP4, "CUsbManCenRepManager::ReadDeviceConfigurationL;fieldId=%d", fieldId );
   168         if( fieldId == KUsbManDeviceVendorIdKey )
   188         if( fieldId == KUsbManDeviceVendorIdKey )
   169             {
   189             {
   170             aDeviceConfig.iVendorId = ReadKeyL( key );
   190             aDeviceConfig.iVendorId = ReadKeyL( key );
   171             }
   191             }
   172         else if( fieldId == KUsbManDeviceManufacturerNameKey )
   192         else if( fieldId == KUsbManDeviceManufacturerNameKey )
   183             aDeviceConfig.iProductName->Des().Copy( productName ); 
   203             aDeviceConfig.iProductName->Des().Copy( productName ); 
   184             CleanupStack::PopAndDestroy( product );
   204             CleanupStack::PopAndDestroy( product );
   185             }
   205             }
   186         else
   206         else
   187             {
   207             {
   188             _USB_PANIC( KUsbCenRepPanic, ECenRepConfigError );
   208             OstTrace1( TRACE_FATAL, CUSBMANCENREPMANAGER_READDEVICECONFIGURATIONL_DUP5, "CUsbManCenRepManager::ReadDeviceConfigurationL;panic error=%d", ECenRepConfigError );
       
   209             User::Panic( KUsbCenRepPanic, ECenRepConfigError );
   189             }
   210             }
   190         }
   211         }
   191     CleanupStack::PopAndDestroy( &keyArray );  
   212     CleanupStack::PopAndDestroy( &keyArray );  
       
   213     OstTraceFunctionExit0( CUSBMANCENREPMANAGER_READDEVICECONFIGURATIONL_EXIT );
   192     }
   214     }
   193 
   215 
   194 
   216 
   195 // ---------------------------------------------------------------------------
   217 // ---------------------------------------------------------------------------
   196 // Read personality table 
   218 // Read personality table 
   197 // ---------------------------------------------------------------------------
   219 // ---------------------------------------------------------------------------
   198 //
   220 //
   199 void CUsbManCenRepManager::ReadPersonalitiesL(RPointerArray<CPersonality>& aPersonalities)
   221 void CUsbManCenRepManager::ReadPersonalitiesL(RPointerArray<CPersonality>& aPersonalities)
   200 	{
   222 	{
   201 	LOG_FUNC
   223 	OstTraceFunctionEntry0( CUSBMANCENREPMANAGER_READPERSONALITIESL_ENTRY );
   202     
   224     
   203 	//Only support version four right now.
   225 	//Only support version four right now.
   204 	__ASSERT_DEBUG( ( TUsbManagerSupportedVersionFour == iSignature ), _USB_PANIC( KUsbCenRepPanic, ECenRepConfigError ) );
   226 	if(TUsbManagerSupportedVersionFour != iSignature)
   205 	
   227 	    {
       
   228         OstTrace1( TRACE_FATAL, CUSBMANCENREPMANAGER_READPERSONALITIESL, "CUsbManCenRepManager::ReadPersonalitiesL;ECenRepConfigError=%d", ECenRepConfigError );
       
   229         __ASSERT_DEBUG( EFalse, User::Panic( KUsbCenRepPanic, ECenRepConfigError ) );
       
   230 	    }
       
   231 
   206 	// Get the personality count.
   232 	// Get the personality count.
   207 	TUint32 personalityCount = ReadKeyL( KUsbManDevicePersonalitiesCountIndexKey );
   233 	TUint32 personalityCount = ReadKeyL( KUsbManDevicePersonalitiesCountIndexKey );
   208 	LOGTEXT2( _L("CUsbManCenRepManager::ReadPersonalitiesL personalityCount = %d"), personalityCount );
   234 	OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_READPERSONALITIESL_DUP3, "CUsbManCenRepManager::ReadPersonalitiesL;personalityCount=%d", personalityCount );
   209 	
   235 	
   210 	RArray<TUint32> keyArray;
   236 	RArray<TUint32> keyArray;
   211 	CleanupClosePushL( keyArray ); 
   237 	CleanupClosePushL( keyArray ); 
   212 	
   238 	
   213 
   239 
   217         CPersonality* personality = CPersonality::NewL();
   243         CPersonality* personality = CPersonality::NewL();
   218         CleanupStack::PushL( personality );
   244         CleanupStack::PushL( personality );
   219         
   245         
   220         // Find the keys belonging to the personality
   246         // Find the keys belonging to the personality
   221         TUint32 devicePersonalitiesKey = KUsbManDevicePersonalitiesPartialKey | ( personalityIdx << KUsbManPersonalitiesOffset );
   247         TUint32 devicePersonalitiesKey = KUsbManDevicePersonalitiesPartialKey | ( personalityIdx << KUsbManPersonalitiesOffset );
   222         LEAVEIFERRORL( iRepository->FindL( devicePersonalitiesKey, KUsbManConfigKeyMask, keyArray ) );
   248         TInt err = iRepository->FindL( devicePersonalitiesKey, KUsbManConfigKeyMask, keyArray );
       
   249         LEAVEIFERRORL( err, OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_READPERSONALITIESL_DUP1, "CUsbManCenRepManager::ReadPersonalitiesL;Leave err=%d", err ); );
   223         
   250         
   224         TInt keyCount = keyArray.Count();
   251         TInt keyCount = keyArray.Count();
   225         LOGTEXT2( _L("CUsbManCenRepManager::ReadPersonalitiesL keyCount of personality = %d"), keyCount );
   252         OstTrace1( TRACE_NORMAL, DUP2_CUSBMANCENREPMANAGER_READPERSONALITIESL_DUP2, "CUsbManCenRepManager::ReadPersonalitiesL; keyCount of personality = %d", keyCount );
   226         
   253         
   227         // Get each key value of the personality and store it.
   254         // Get each key value of the personality and store it.
   228         for( TInt keyIdx = 0; keyIdx < keyCount; keyIdx++ )
   255         for( TInt keyIdx = 0; keyIdx < keyCount; keyIdx++ )
   229             {
   256             {
   230             TUint32 key = keyArray[keyIdx];
   257             TUint32 key = keyArray[keyIdx];
   231             TUint32 fieldId = (key & KUsbManConfigFieldMask);
   258             TUint32 fieldId = (key & KUsbManConfigFieldMask);
   232             LOGTEXT2( _L("CUsbManCenRepManager::ReadPersonalitiesL key id of personality = %d"), fieldId );
   259             OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_READPERSONALITIESL_DUP4, "CUsbManCenRepManager::ReadPersonalitiesL;key id of personality=%d", fieldId );
   233             switch( fieldId )
   260             switch( fieldId )
   234                 {
   261                 {
   235                 case KUsbManDevicePersonalitiesDeviceClassKey:
   262                 case KUsbManDevicePersonalitiesDeviceClassKey:
   236                     personality->SetDeviceClass(ReadKeyL( key ));
   263                     personality->SetDeviceClass(ReadKeyL( key ));
   237                     break;
   264                     break;
   267                     personality->SetDescription( description );
   294                     personality->SetDescription( description );
   268                     CleanupStack::PopAndDestroy( description );
   295                     CleanupStack::PopAndDestroy( description );
   269                     break;
   296                     break;
   270                     }
   297                     }
   271                 default:
   298                 default:
   272                     _USB_PANIC( KUsbCenRepPanic, ECenRepConfigError );
   299                     OstTrace1( TRACE_FATAL, CUSBMANCENREPMANAGER_READPERSONALITIESL_DUP5, "CUsbManCenRepManager::ReadPersonalitiesL;Panic error=%d", ECenRepConfigError );
       
   300                     User::Panic( KUsbCenRepPanic, ECenRepConfigError );
   273                     break;
   301                     break;
   274                 }
   302                 }
   275             }
   303             }
   276         
   304         
   277         personality->SetVersion(iSignature);
   305         personality->SetVersion(iSignature);
   303                 }
   331                 }
   304             }
   332             }
   305        
   333        
   306         if(isPersonalitySupport)
   334         if(isPersonalitySupport)
   307             {
   335             {
   308             LOGTEXT2( _L("CUsbManCenRepManager::ReadPersonalitiesL Personality ID: %d is supported"), personality->PersonalityId() );
   336             OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_READPERSONALITIESL_DUP6, "CUsbManCenRepManager::ReadPersonalitiesL; Personality ID: %d is supported", personality->PersonalityId() );
   309             aPersonalities.Append( personality );
   337             aPersonalities.Append( personality );
   310             CleanupStack::Pop( personality );
   338             CleanupStack::Pop( personality );
   311             }
   339             }
   312         else
   340         else
   313             {
   341             {
   314             LOGTEXT2( _L("CUsbManCenRepManager::ReadPersonalitiesL Personality ID: %d is not supported"), personality->PersonalityId() );
   342             OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_READPERSONALITIESL_DUP7, "CUsbManCenRepManager::ReadPersonalitiesL;Personality ID: %d is not supported", personality->PersonalityId() );
   315             CleanupStack::PopAndDestroy(personality);
   343             CleanupStack::PopAndDestroy(personality);
   316             }
   344             }
   317         }
   345         }
   318     CleanupStack::PopAndDestroy( &keyArray );  	
   346     CleanupStack::PopAndDestroy( &keyArray );  	
       
   347     OstTraceFunctionExit0( CUSBMANCENREPMANAGER_READPERSONALITIESL_EXIT );
   319     }
   348     }
   320 
   349 
   321 // ---------------------------------------------------------------------------
   350 // ---------------------------------------------------------------------------
   322 // Read configuration table for specific personality
   351 // Read configuration table for specific personality
   323 // ---------------------------------------------------------------------------
   352 // ---------------------------------------------------------------------------
   324 //
   353 //
   325 void CUsbManCenRepManager::ReadConfigurationsForPersonalityL(TInt aPersonalityId, CPersonality& aPersonality)
   354 void CUsbManCenRepManager::ReadConfigurationsForPersonalityL(TInt aPersonalityId, CPersonality& aPersonality)
   326     {
   355     {
   327     LOG_FUNC
   356     OstTraceFunctionEntry0( CUSBMANCENREPMANAGER_READCONFIGURATIONSFORPERSONALITYL_ENTRY );
   328     RArray<TUint32> configArray;
   357     RArray<TUint32> configArray;
   329     CleanupClosePushL(configArray);
   358     CleanupClosePushL(configArray);
   330  
   359  
   331     //Only support version four right now.
   360     //Only support version four right now.
   332     __ASSERT_DEBUG( ( TUsbManagerSupportedVersionFour == iSignature ), _USB_PANIC( KUsbCenRepPanic, ECenRepConfigError ) );
   361     if(TUsbManagerSupportedVersionFour != iSignature)
   333     
   362         {
   334     LEAVEIFERRORL( iRepository->FindEqL( KUsbManDeviceConfigurationsPartialKey, KUsbManConfigFirstEntryMask, aPersonalityId, configArray ) );
   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 ); );
   335     
   369     
   336     // Get the configuration count.
   370     // Get the configuration count.
   337     TUint32 configCount = configArray.Count();
   371     TUint32 configCount = configArray.Count();
   338     TUint32 totalConfigCount = ReadKeyL( KUsbManDeviceConfigurationsCountIndexKey );
   372     TUint32 totalConfigCount = ReadKeyL( KUsbManDeviceConfigurationsCountIndexKey );
   339 
   373 
   340     LOGTEXT4( _L("ReadConfigurationsForPersonalityL: aPersonalityId = %d total configCount = %d configArray.Count() = %d"), aPersonalityId, totalConfigCount, configArray.Count());
   374     OstTraceExt3( TRACE_NORMAL, CUSBMANCENREPMANAGER_READCONFIGURATIONSFORPERSONALITYL_DUP2, 
       
   375             "CUsbManCenRepManager::ReadConfigurationsForPersonalityL;aPersonalityId = %d total configCount = %d configArray.Count() = %d", aPersonalityId, totalConfigCount, configArray.Count() );
   341     
   376     
   342     //This is intend to handle one special case that key 0x2ff00's value
   377     //This is intend to handle one special case that key 0x2ff00's value
   343     // equal our target personality id.
   378     // equal our target personality id.
   344     if(totalConfigCount == aPersonalityId)
   379     if(totalConfigCount == aPersonalityId)
   345         {
   380         {
   362         // Get each key value in the configuration and store it
   397         // Get each key value in the configuration and store it
   363         for ( TInt keyIdx = 0; keyIdx < keyCount; keyIdx++ )
   398         for ( TInt keyIdx = 0; keyIdx < keyCount; keyIdx++ )
   364             {
   399             {
   365             TUint32 fieldId = ( (key + keyIdx ) & KUsbManConfigFieldMask );
   400             TUint32 fieldId = ( (key + keyIdx ) & KUsbManConfigFieldMask );
   366             TInt keyValue = -1;
   401             TInt keyValue = -1;
   367             LOGTEXT4( _L("ReadConfigurationsForPersonalityL fieldId = %d configIdx = %d keyIdx = %d"), fieldId, configIdx, keyIdx );
   402             OstTraceExt3( TRACE_NORMAL, CUSBMANCENREPMANAGER_READCONFIGURATIONSFORPERSONALITYL_DUP3, "CUsbManCenRepManager::ReadConfigurationsForPersonalityL;fieldId=%d;configIdx=%d;keyIdx=%d", fieldId, configIdx, keyIdx );
   368             
   403             
   369             if(KUsbManDeviceConfigurationsPersonalityIdKey == fieldId)
   404             if(KUsbManDeviceConfigurationsPersonalityIdKey == fieldId)
   370                 {
   405                 {
   371                 TRAPD( err, keyValue = ReadKeyL( key + keyIdx ) );
   406                 TRAPD( err, keyValue = ReadKeyL( key + keyIdx ) );
   372                 if( err == KErrNone )
   407                 if( err == KErrNone )
   373                     {
   408                     {
   374                     __ASSERT_DEBUG( ( keyValue == aPersonalityId ), _USB_PANIC( KUsbCenRepPanic, ECenRepConfigError ) );
   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                         }
   375                     config->SetPersonalityId( keyValue );
   414                     config->SetPersonalityId( keyValue );
   376                     }
   415                     }
   377                 }
   416                 }
   378             else if(KUsbManDeviceConfigurationsIdKey == fieldId)
   417             else if(KUsbManDeviceConfigurationsIdKey == fieldId)
   379                 {
   418                 {
   418                 CleanupStack::PopAndDestroy( &classUids ); // close uid array 
   457                 CleanupStack::PopAndDestroy( &classUids ); // close uid array 
   419                 CleanupStack::PopAndDestroy( keyValueBuf );
   458                 CleanupStack::PopAndDestroy( keyValueBuf );
   420                 }
   459                 }
   421             else
   460             else
   422                 {
   461                 {
   423                 _USB_PANIC( KUsbCenRepPanic, ECenRepConfigError );
   462                 OstTrace1( TRACE_FATAL, CUSBMANCENREPMANAGER_READCONFIGURATIONSFORPERSONALITYL_DUP5, "CUsbManCenRepManager::ReadConfigurationsForPersonalityL;Panic error=%d", ECenRepConfigError );
       
   463                 User::Panic( KUsbCenRepPanic, ECenRepConfigError );
   424                 }
   464                 }
   425             }
   465             }
   426         aPersonality.AppendPersonalityConfigsL( config );
   466         aPersonality.AppendPersonalityConfigsL( config );
   427 
   467 
   428         CleanupStack::Pop( config );
   468         CleanupStack::Pop( config );
   429         }
   469         }
   430 
   470 
   431     CleanupStack::PopAndDestroy( &configArray );     
   471     CleanupStack::PopAndDestroy( &configArray );     
       
   472     OstTraceFunctionExit0( CUSBMANCENREPMANAGER_READCONFIGURATIONSFORPERSONALITYL_EXIT );
   432     }
   473     }
   433 
   474 
   434 // ---------------------------------------------------------------------------
   475 // ---------------------------------------------------------------------------
   435 // Check the class belonging to a personality configurable or not.
   476 // Check the class belonging to a personality configurable or not.
   436 // ---------------------------------------------------------------------------
   477 // ---------------------------------------------------------------------------
   437 //
   478 //
   438 TBool CUsbManCenRepManager::IsClassConfigurableL(TUint aClassId, TInt& aFeatureId)
   479 TBool CUsbManCenRepManager::IsClassConfigurableL(TUint aClassId, TInt& aFeatureId)
   439     {
   480     {
   440     LOG_FUNC
   481     OstTraceFunctionEntry0( CUSBMANCENREPMANAGER_ISCLASSCONFIGURABLEL_ENTRY );
   441     TBool classConfigurable = EFalse;
   482     TBool classConfigurable = EFalse;
   442     RArray<TUint32> keyArray;
   483     RArray<TUint32> keyArray;
   443     CleanupClosePushL(keyArray);
   484     CleanupClosePushL(keyArray);
   444     
   485     
   445     TInt err = iRepository->FindEqL( KUsbManDeviceConfigurableClassesPartialKey, KUsbManConfigFirstEntryMask, (TInt)aClassId, keyArray );
   486     TInt err = iRepository->FindEqL( KUsbManDeviceConfigurableClassesPartialKey, KUsbManConfigFirstEntryMask, (TInt)aClassId, keyArray );
   446     LOGTEXT3( _L("CUsbManCenRepManager::IsClassConfigurableL: aClassId = 0x%x err = %d "), aClassId, err);
   487     OstTraceExt2( TRACE_NORMAL, CUSBMANCENREPMANAGER_ISCLASSCONFIGURABLEL, "CUsbManCenRepManager::IsClassConfigurableL;aClassId=0x%x;err=%d", aClassId, err );
   447     switch ( err )
   488     switch ( err )
   448         {
   489         {
   449         case KErrNotFound:
   490         case KErrNotFound:
   450             break;
   491             break;
   451         case KErrNone:
   492         case KErrNone:
   452             {
   493             {
   453             __ASSERT_DEBUG( ( keyArray.Count() == 1 ), _USB_PANIC( KUsbCenRepPanic, ECenRepConfigError ) );
   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
   454             // The array size always is 1, so here using 0 as index.
   501             // The array size always is 1, so here using 0 as index.
   455             aFeatureId = ReadKeyL( keyArray[0] | KUsbManDeviceConfigurableClassesFeatureIdKey );
   502             aFeatureId = ReadKeyL( keyArray[0] | KUsbManDeviceConfigurableClassesFeatureIdKey );
   456             classConfigurable = ETrue;
   503             classConfigurable = ETrue;
   457             break;
   504             break;
   458             }
   505             }
   459         default:
   506         default:
   460             LEAVEL( err );
   507             OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_ISCLASSCONFIGURABLEL_DUP2, "CUsbManCenRepManager::IsClassConfigurableL;Leave err=%d", err );
       
   508             User::Leave( err );
   461             break;
   509             break;
   462         }    
   510         }    
   463     
   511     
   464     CleanupStack::PopAndDestroy( &keyArray );     
   512     CleanupStack::PopAndDestroy( &keyArray );     
       
   513     OstTraceFunctionExit0( CUSBMANCENREPMANAGER_ISCLASSCONFIGURABLEL_EXIT );
   465     return classConfigurable;
   514     return classConfigurable;
   466     }
   515     }
   467 
   516 
   468 // ---------------------------------------------------------------------------
   517 // ---------------------------------------------------------------------------
   469 // Check the class belonging to a personality support or not.
   518 // Check the class belonging to a personality support or not.
   470 // ---------------------------------------------------------------------------
   519 // ---------------------------------------------------------------------------
   471 //
   520 //
   472 TBool CUsbManCenRepManager::IsFeatureSupportedL(TInt aFeatureId)
   521 TBool CUsbManCenRepManager::IsFeatureSupportedL(TInt aFeatureId)
   473     {
   522     {
   474     LOG_FUNC
   523     OstTraceFunctionEntry0( CUSBMANCENREPMANAGER_ISFEATURESUPPORTEDL_ENTRY );
   475 #ifdef SYMBIAN_FEATURE_MANAGER
   524 #ifdef SYMBIAN_FEATURE_MANAGER
   476     if(CFeatureDiscovery::IsFeatureSupportedL(TUid::Uid(aFeatureId)))
   525     if(CFeatureDiscovery::IsFeatureSupportedL(TUid::Uid(aFeatureId)))
   477         {
   526         {
   478         LOGTEXT2( _L("CUsbManCenRepManager::IsFeatureSupportedL featureId = 0x%x supported"), aFeatureId );
   527         OstTrace1( TRACE_NORMAL, DUP1_CUSBMANCENREPMANAGER_ISFEATURESUPPORTEDL_DUP1, "CUsbManCenRepManager::IsFeatureSupportedL;featureId = 0x%x supported", aFeatureId );
       
   528         OstTraceFunctionExit0( CUSBMANCENREPMANAGER_ISFEATURESUPPORTEDL_EXIT );
   479         return ETrue;
   529         return ETrue;
   480         }
   530         }
   481     else
   531     else
   482         {
   532         {
   483         LOGTEXT2( _L("CUsbManCenRepManager::IsFeatureSupportedL featureId = 0x%x not supported"), aFeatureId );
   533         OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_ISFEATURESUPPORTEDL_DUP2, "CUsbManCenRepManager::IsFeatureSupportedL;featureId = 0x%x not supported", aFeatureId );
       
   534         OstTraceFunctionExit0( CUSBMANCENREPMANAGER_ISFEATURESUPPORTEDL_EXIT_DUP1 );
   484         return EFalse;
   535         return EFalse;
   485         }
   536         }
   486 #else
   537 #else
   487     _USB_PANIC( KUsbCenRepPanic, ECenRepFeatureManagerError )
   538     OstTrace1( TRACE_FATAL, CUSBMANCENREPMANAGER_ISFEATURESUPPORTEDL, "CUsbManCenRepManager::IsFeatureSupportedL;panic error code=%d", ECenRepFeatureManagerError );
       
   539     User::Panic( KUsbCenRepPanic, ECenRepFeatureManagerError )
   488 #endif    
   540 #endif    
   489     }
   541     }