usbmgmt/usbmgr/usbman/server/SRC/CPersonality.cpp
branchRCL_3
changeset 16 012cc2ee6408
parent 15 f92a4f87e424
--- a/usbmgmt/usbmgr/usbman/server/SRC/CPersonality.cpp	Tue Aug 31 17:01:47 2010 +0300
+++ b/usbmgmt/usbmgr/usbman/server/SRC/CPersonality.cpp	Wed Sep 01 12:35:00 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2004-2009 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,50 +22,43 @@
 */
 
 #include "CPersonality.h"
-
-#include "OstTraceDefinitions.h"
-#ifdef OST_TRACE_COMPILER_IN_USE
-#include "CPersonalityTraces.h"
-#endif
+#include <usb/usblogger.h>
 
-// Panic category only used in debug builds
-#ifdef _DEBUG
-_LIT(KUsbPersonalityPanicCategory, "CUsbPersonality");
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "USBSVR");
 #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()
 	{
-	OstTraceFunctionEntry0( CPERSONALITY_NEWL_ENTRY );
+	LOG_STATIC_FUNC_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 description string
+ * Allocates max amount of memory for each of 3 strings
  */	
 void CPersonality::ConstructL()
 	{
-	OstTraceFunctionEntry0( CPERSONALITY_CONSTRUCTL_ENTRY );
-	iDescription	= HBufC::NewL(KUsbStringDescStringMaxSize);
-	OstTraceFunctionExit0( CPERSONALITY_CONSTRUCTL_EXIT );
+	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();
 	}
 	
 /**
@@ -80,49 +73,62 @@
  */
 CPersonality::~CPersonality()
 	{
-	OstTraceFunctionEntry0( CPERSONALITY_CPERSONALITY_DES_ENTRY );
-	
-	iPersonalityConfigs.ResetAndDestroy();
+	LOG_FUNC
+
+	iClassUids.Close();
+	delete iManufacturer;
+	delete iProduct;
 	delete iDescription;
-	OstTraceFunctionExit0( CPERSONALITY_CPERSONALITY_DES_EXIT );
+	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);
 	}
 
 /**
- * @return supported class uids
+ * Sets personality id
  */
-const RArray<CPersonalityConfigurations::TUsbClasses>& 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();
-    }
+void CPersonality::SetId(TInt aId)
+	{
+	iId = aId;
+	}
 
 /**
- * @return ETrue if this class is supported  
- * otherwise return EFalse
- */
-TBool CPersonality::ClassSupported(TUid aClassUid) const
+ * Sets manufacturer textual description
+ */	
+void CPersonality::SetManufacturer(const TDesC* aManufacturer)
 	{
-    //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<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;
+	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));
 	}
 
 /**
@@ -136,6 +142,14 @@
 	};
 
 /**
+ * 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)
@@ -150,118 +164,3 @@
 	{
 	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 );
-    }