19 /** |
19 /** |
20 @file |
20 @file |
21 @internalAll |
21 @internalAll |
22 */ |
22 */ |
23 |
23 |
24 #include <usb/usblogger.h> |
|
25 #include "CPersonality.h" |
24 #include "CPersonality.h" |
26 |
25 |
27 #ifdef __FLOG_ACTIVE |
26 #include "OstTraceDefinitions.h" |
28 _LIT8(KLogComponent, "USBSVR"); |
27 #ifdef OST_TRACE_COMPILER_IN_USE |
|
28 #include "CPersonalityTraces.h" |
29 #endif |
29 #endif |
30 |
30 |
31 // Panic category only used in debug builds |
31 // Panic category only used in debug builds |
32 #ifdef _DEBUG |
32 #ifdef _DEBUG |
33 _LIT(KUsbPersonalityPanicCategory, "CUsbPersonality"); |
33 _LIT(KUsbPersonalityPanicCategory, "CUsbPersonality"); |
46 * |
46 * |
47 * @return a pointer to CPersonality object. |
47 * @return a pointer to CPersonality object. |
48 */ |
48 */ |
49 CPersonality* CPersonality::NewL() |
49 CPersonality* CPersonality::NewL() |
50 { |
50 { |
51 LOG_STATIC_FUNC_ENTRY |
51 OstTraceFunctionEntry0( CPERSONALITY_NEWL_ENTRY ); |
52 |
52 |
53 CPersonality* self = new(ELeave) CPersonality; |
53 CPersonality* self = new(ELeave) CPersonality; |
54 CleanupStack::PushL(self); |
54 CleanupStack::PushL(self); |
55 self->ConstructL(); |
55 self->ConstructL(); |
56 CleanupStack::Pop(self); |
56 CleanupStack::Pop(self); |
|
57 OstTraceFunctionExit0( CPERSONALITY_NEWL_EXIT ); |
57 return self; |
58 return self; |
58 } |
59 } |
59 |
60 |
60 /** |
61 /** |
61 * Allocates max amount of memory for description string |
62 * Allocates max amount of memory for description string |
62 */ |
63 */ |
63 void CPersonality::ConstructL() |
64 void CPersonality::ConstructL() |
64 { |
65 { |
65 LOG_FUNC |
66 OstTraceFunctionEntry0( CPERSONALITY_CONSTRUCTL_ENTRY ); |
66 iDescription = HBufC::NewL(KUsbStringDescStringMaxSize); |
67 iDescription = HBufC::NewL(KUsbStringDescStringMaxSize); |
|
68 OstTraceFunctionExit0( CPERSONALITY_CONSTRUCTL_EXIT ); |
67 } |
69 } |
68 |
70 |
69 /** |
71 /** |
70 * standard constructor |
72 * standard constructor |
71 */ |
73 */ |
76 /** |
78 /** |
77 * destructor |
79 * destructor |
78 */ |
80 */ |
79 CPersonality::~CPersonality() |
81 CPersonality::~CPersonality() |
80 { |
82 { |
81 LOG_FUNC |
83 OstTraceFunctionEntry0( CPERSONALITY_CPERSONALITY_DES_ENTRY ); |
|
84 |
82 iPersonalityConfigs.ResetAndDestroy(); |
85 iPersonalityConfigs.ResetAndDestroy(); |
83 delete iDescription; |
86 delete iDescription; |
|
87 OstTraceFunctionExit0( CPERSONALITY_CPERSONALITY_DES_EXIT ); |
84 } |
88 } |
85 |
89 |
86 /** |
90 /** |
87 * @return supported class uids |
91 * @return supported class uids |
88 */ |
92 */ |
89 const RArray<CPersonalityConfigurations::TUsbClasses>& CPersonality::SupportedClasses() const |
93 const RArray<CPersonalityConfigurations::TUsbClasses>& CPersonality::SupportedClasses() const |
90 { |
94 { |
91 //we only support configuration 0 now |
95 //we only support configuration 0 now |
92 __ASSERT_DEBUG( iPersonalityConfigs.Count() != 0, _USB_PANIC(KUsbPersonalityPanicCategory, EPersonalityConfigsArrayEmpty) ); |
96 if(iPersonalityConfigs.Count() == 0) |
|
97 { |
|
98 OstTrace1( TRACE_FATAL, CPERSONALITY_SUPPORTEDCLASSES, "CPersonality::SupportedClasses;Panic error=%d", EPersonalityConfigsArrayEmpty ); |
|
99 __ASSERT_DEBUG( EFalse, User::Panic(KUsbPersonalityPanicCategory, EPersonalityConfigsArrayEmpty) ); |
|
100 } |
93 return iPersonalityConfigs[0]->Classes(); |
101 return iPersonalityConfigs[0]->Classes(); |
94 } |
102 } |
95 |
103 |
96 /** |
104 /** |
97 * @return ETrue if this class is supported |
105 * @return ETrue if this class is supported |
98 * otherwise return EFalse |
106 * otherwise return EFalse |
99 */ |
107 */ |
100 TBool CPersonality::ClassSupported(TUid aClassUid) const |
108 TBool CPersonality::ClassSupported(TUid aClassUid) const |
101 { |
109 { |
102 //we only support configuration 0 now |
110 //we only support configuration 0 now |
103 __ASSERT_DEBUG( iPersonalityConfigs.Count() != 0, _USB_PANIC(KUsbPersonalityPanicCategory, EPersonalityConfigsArrayEmpty) ); |
111 if(iPersonalityConfigs.Count() == 0) |
|
112 { |
|
113 OstTrace1( TRACE_FATAL, CPERSONALITY_CLASSSUPPORTED, "CPersonality::ClassSupported;Panic error=%d", EPersonalityConfigsArrayEmpty ); |
|
114 __ASSERT_DEBUG( EFalse, User::Panic(KUsbPersonalityPanicCategory, EPersonalityConfigsArrayEmpty) ); |
|
115 } |
104 const RArray<CPersonalityConfigurations::TUsbClasses> &classes = iPersonalityConfigs[0]->Classes(); |
116 const RArray<CPersonalityConfigurations::TUsbClasses> &classes = iPersonalityConfigs[0]->Classes(); |
105 TInt classesCount = classes.Count(); |
117 TInt classesCount = classes.Count(); |
106 for(TInt classesIndex = 0; classesIndex < classesCount; ++classesIndex) |
118 for(TInt classesIndex = 0; classesIndex < classesCount; ++classesIndex) |
107 { |
119 { |
108 if(aClassUid == classes[classesIndex].iClassUid) |
120 if(aClassUid == classes[classesIndex].iClassUid) |