--- a/usbmgmt/usbmgr/usbman/server/SRC/CPersonality.cpp Fri Jun 25 13:07:44 2010 +0800
+++ b/usbmgmt/usbmgr/usbman/server/SRC/CPersonality.cpp Fri Jun 25 13:19:39 2010 +0800
@@ -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"
@@ -21,13 +21,26 @@
@internalAll
*/
+#include <usb/usblogger.h>
#include "CPersonality.h"
-#include <usb/usblogger.h>
#ifdef __FLOG_ACTIVE
_LIT8(KLogComponent, "USBSVR");
#endif
+// 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.
*
@@ -45,20 +58,12 @@
}
/**
- * 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();
+ iDescription = HBufC::NewL(KUsbStringDescStringMaxSize);
}
/**
@@ -74,61 +79,38 @@
CPersonality::~CPersonality()
{
LOG_FUNC
-
- iClassUids.Close();
- delete iManufacturer;
- delete iProduct;
+ iPersonalityConfigs.ResetAndDestroy();
delete iDescription;
- delete iDetailedDescription;
- }
-
-/**
- * @return the index of the first match or KErrNotFound
- */
-TInt CPersonality::ClassSupported(TUid aClassUid) const
- {
- TIdentityRelation<TUid> relation(CPersonality::Compare);
- return iClassUids.Find(aClassUid, relation);
- }
-
-/**
- * @return KErrNone or system wide error code
- */
-TInt CPersonality::AddSupportedClasses(TUid aClassUid)
- {
- return iClassUids.Append(aClassUid);
}
/**
- * Sets personality id
+ * @return supported class uids
*/
-void CPersonality::SetId(TInt aId)
- {
- iId = aId;
- }
+const RArray<CPersonalityConfigurations::TUsbClasses>& CPersonality::SupportedClasses() const
+ {
+ //we only support configuration 0 now
+ __ASSERT_DEBUG( iPersonalityConfigs.Count() != 0, _USB_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
+ __ASSERT_DEBUG( iPersonalityConfigs.Count() != 0, _USB_PANIC(KUsbPersonalityPanicCategory, EPersonalityConfigsArrayEmpty) );
+ const RArray<CPersonalityConfigurations::TUsbClasses> &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 +124,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 +138,117 @@
{
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()
+ {
+ LOG_FUNC
+ iClasses.Close();
+ }