diff -r d3e8e7d462dd -r f92a4f87e424 usbmgmt/usbmgr/usbman/server/SRC/CPersonality.cpp --- a/usbmgmt/usbmgr/usbman/server/SRC/CPersonality.cpp Thu Jul 15 20:42:20 2010 +0300 +++ b/usbmgmt/usbmgr/usbman/server/SRC/CPersonality.cpp Tue Aug 31 17:01:47 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -22,43 +22,50 @@ */ #include "CPersonality.h" -#include + +#include "OstTraceDefinitions.h" +#ifdef OST_TRACE_COMPILER_IN_USE +#include "CPersonalityTraces.h" +#endif -#ifdef __FLOG_ACTIVE -_LIT8(KLogComponent, "USBSVR"); +// Panic category only used in debug builds +#ifdef _DEBUG +_LIT(KUsbPersonalityPanicCategory, "CUsbPersonality"); #endif /** + * Panic codes for the USB Personality Class + */ +enum TUsbPersonalityPanic + { + EPersonalityConfigsArrayEmpty, + }; + +/** * Factory method. Constructs a CPersonality object. * * @return a pointer to CPersonality object. */ CPersonality* CPersonality::NewL() { - LOG_STATIC_FUNC_ENTRY + OstTraceFunctionEntry0( CPERSONALITY_NEWL_ENTRY ); CPersonality* self = new(ELeave) CPersonality; CleanupStack::PushL(self); self->ConstructL(); CleanupStack::Pop(self); + OstTraceFunctionExit0( CPERSONALITY_NEWL_EXIT ); return self; } /** - * Allocates max amount of memory for each of 3 strings + * Allocates max amount of memory for description string */ void CPersonality::ConstructL() { - LOG_FUNC - - iManufacturer = HBufC::NewLC(KUsbStringDescStringMaxSize); - CleanupStack::Pop(); - iProduct = HBufC::NewLC(KUsbStringDescStringMaxSize); - CleanupStack::Pop(); - iDescription = HBufC::NewLC(KUsbStringDescStringMaxSize); - CleanupStack::Pop(); - iDetailedDescription = HBufC::NewLC(KUsbStringDescStringMaxSize); - CleanupStack::Pop(); + OstTraceFunctionEntry0( CPERSONALITY_CONSTRUCTL_ENTRY ); + iDescription = HBufC::NewL(KUsbStringDescStringMaxSize); + OstTraceFunctionExit0( CPERSONALITY_CONSTRUCTL_EXIT ); } /** @@ -73,62 +80,49 @@ */ CPersonality::~CPersonality() { - LOG_FUNC - - iClassUids.Close(); - delete iManufacturer; - delete iProduct; + OstTraceFunctionEntry0( CPERSONALITY_CPERSONALITY_DES_ENTRY ); + + iPersonalityConfigs.ResetAndDestroy(); delete iDescription; - delete iDetailedDescription; - } - -/** - * @return the index of the first match or KErrNotFound - */ -TInt CPersonality::ClassSupported(TUid aClassUid) const - { - TIdentityRelation relation(CPersonality::Compare); - return iClassUids.Find(aClassUid, relation); - } - -/** - * @return KErrNone or system wide error code - */ -TInt CPersonality::AddSupportedClasses(TUid aClassUid) - { - return iClassUids.Append(aClassUid); + OstTraceFunctionExit0( CPERSONALITY_CPERSONALITY_DES_EXIT ); } /** - * Sets personality id + * @return supported class uids */ -void CPersonality::SetId(TInt aId) - { - iId = aId; - } +const RArray& CPersonality::SupportedClasses() const + { + //we only support configuration 0 now + if(iPersonalityConfigs.Count() == 0) + { + OstTrace1( TRACE_FATAL, CPERSONALITY_SUPPORTEDCLASSES, "CPersonality::SupportedClasses;Panic error=%d", EPersonalityConfigsArrayEmpty ); + __ASSERT_DEBUG( EFalse, User::Panic(KUsbPersonalityPanicCategory, EPersonalityConfigsArrayEmpty) ); + } + return iPersonalityConfigs[0]->Classes(); + } /** - * Sets manufacturer textual description - */ -void CPersonality::SetManufacturer(const TDesC* aManufacturer) + * @return ETrue if this class is supported + * otherwise return EFalse + */ +TBool CPersonality::ClassSupported(TUid aClassUid) const { - iManufacturer->Des().Copy(*aManufacturer); - } - -/** - * Sets product textual description - */ -void CPersonality::SetProduct(const TDesC* aProduct) - { - iProduct->Des().Copy(*aProduct); - } - -/** - * Sets personality textual description - */ -void CPersonality::SetDescription(const TDesC* aDescription) - { - iDescription->Des().Copy((*aDescription).Left(KUsbStringDescStringMaxSize-1)); + //we only support configuration 0 now + if(iPersonalityConfigs.Count() == 0) + { + OstTrace1( TRACE_FATAL, CPERSONALITY_CLASSSUPPORTED, "CPersonality::ClassSupported;Panic error=%d", EPersonalityConfigsArrayEmpty ); + __ASSERT_DEBUG( EFalse, User::Panic(KUsbPersonalityPanicCategory, EPersonalityConfigsArrayEmpty) ); + } + const RArray &classes = iPersonalityConfigs[0]->Classes(); + TInt classesCount = classes.Count(); + for(TInt classesIndex = 0; classesIndex < classesCount; ++classesIndex) + { + if(aClassUid == classes[classesIndex].iClassUid) + { + return ETrue; + } + } + return EFalse; } /** @@ -142,14 +136,6 @@ }; /** - * Sets detailed personality textual description - */ -void CPersonality::SetDetailedDescription(const TDesC* aDetailedDescription) - { - iDetailedDescription->Des().Copy((*aDetailedDescription).Left(KUsbStringDescStringMaxSize-1)); - } - -/** * Sets version */ void CPersonality::SetVersion(TInt aVersion) @@ -164,3 +150,118 @@ { iProperty = aProperty; } + +/** + * Sets DeviceClass + */ +void CPersonality::SetDeviceClass(TUint8 aDeviceClass) + { + iDeviceClass = aDeviceClass; + } + +/** + * Sets DeviceSubClass + */ +void CPersonality::SetDeviceSubClass(TUint8 aDeviceSubClass) + { + iDeviceSubClass = aDeviceSubClass; + } + +/** + * Sets DeviceProtocol + */ +void CPersonality::SetDeviceProtocol(TUint8 aDeviceProtocol) + { + iDeviceProtocol = aDeviceProtocol; + } + +/** + * Sets NumConfigurations + */ +void CPersonality::SetNumConfigurations(TUint8 aNumConfigurations) + { + iNumConfigurations = aNumConfigurations; + } + +/** + * Sets ProductId + */ +void CPersonality::SetProductId(TUint16 aProductId) + { + iProductId = aProductId; + } + +/** + * Sets FeatureId + */ +void CPersonality::SetFeatureId(TInt aFeatureId) + { + iFeatureId = aFeatureId; + } + +/** + * Sets BcdDevice + */ +void CPersonality::SetBcdDevice(TUint16 aBcdDevice) + { + iBcdDevice = aBcdDevice; + } + +/** + * Sets personality id + */ +void CPersonality::SetPersonalityId(TInt aPersonalityId) + { + iPersonalityId = aPersonalityId; + } + +/** + * Sets Description + */ +void CPersonality::SetDescription(const TDesC* aDescription) + { + iDescription->Des().Copy((*aDescription).Left(KUsbStringDescStringMaxSize-1)); + } + +/** + * Append PersonalityConfig + */ +void CPersonality::AppendPersonalityConfigsL(const CPersonalityConfigurations *aPersonalityConfig ) + { + iPersonalityConfigs.AppendL(aPersonalityConfig); + } + +/** + * Sets personality id + */ +void CPersonalityConfigurations::SetPersonalityId(TInt aPersonalityId) + { + iPersonalityId = aPersonalityId; + } + +/** + * Sets Config Id + */ +void CPersonalityConfigurations::SetConfigId(TInt aConfigId) + { + iConfigId = aConfigId; + } + + +/** + * Append PersonalityConfig + */ +void CPersonalityConfigurations::AppendClassesL(const TUsbClasses &aClasses ) + { + iClasses.AppendL(aClasses); + } + +/** + * De-Constructor + */ +CPersonalityConfigurations::~CPersonalityConfigurations() + { + OstTraceFunctionEntry0( CPERSONALITYCONFIGURATIONS_CPERSONALITYCONFIGURATIONS_DES_ENTRY ); + iClasses.Close(); + OstTraceFunctionExit0( CPERSONALITYCONFIGURATIONS_CPERSONALITYCONFIGURATIONS_DES_EXIT ); + }