1 /** |
1 /** |
2 * Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
33 #include <d32usbc.h> |
33 #include <d32usbc.h> |
34 #include <e32std.h> |
34 #include <e32std.h> |
35 #include <usb/usblogger.h> |
35 #include <usb/usblogger.h> |
36 #include <musbmanextensionpluginobserver.h> |
36 #include <musbmanextensionpluginobserver.h> |
37 |
37 |
38 |
|
39 |
|
40 class CUsbDeviceStateWatcher; |
38 class CUsbDeviceStateWatcher; |
41 class CUsbClassControllerBase; |
39 class CUsbClassControllerBase; |
42 class CUsbServer; |
40 class CUsbServer; |
43 class MUsbDeviceNotify; |
41 class MUsbDeviceNotify; |
44 class CPersonality; |
42 class CPersonality; |
45 class CUsbmanExtensionPlugin; |
43 class CUsbmanExtensionPlugin; |
46 class CUsbManCenRepManager; |
|
47 |
|
48 |
44 |
49 const TUid KUidUsbPlugIns = {0x101fbf21}; |
45 const TUid KUidUsbPlugIns = {0x101fbf21}; |
50 |
46 |
51 /** |
47 /** |
52 * The CUsbDevice class |
48 * The CUsbDevice class |
76 TUint8 iDeviceClass; |
72 TUint8 iDeviceClass; |
77 TUint8 iDeviceSubClass; |
73 TUint8 iDeviceSubClass; |
78 TUint8 iDeviceProtocol; |
74 TUint8 iDeviceProtocol; |
79 TUint8 iMaxPacketSize; |
75 TUint8 iMaxPacketSize; |
80 TUint16 iIdVendor; |
76 TUint16 iIdVendor; |
81 TUint16 iProductId; |
77 TUint16 iIdProduct; |
82 TUint16 iBcdDevice; |
78 TUint16 iBcdDevice; |
83 TUint8 iManufacturer; |
79 TUint8 iManufacturer; |
84 TUint8 iProduct; |
80 TUint8 iProduct; |
85 TUint8 iSerialNumber; |
81 TUint8 iSerialNumber; |
86 TUint8 iNumConfigurations; |
82 TUint8 iNumConfigurations; |
87 }; |
83 }; |
88 |
84 |
89 /** |
|
90 * See Central Repository |
|
91 */ |
|
92 class TUsbDeviceConfiguration |
|
93 { |
|
94 public: |
|
95 TUint16 iVendorId; |
|
96 HBufC* iManufacturerName; |
|
97 HBufC* iProductName; |
|
98 }; |
|
99 public: |
85 public: |
100 static CUsbDevice* NewL(CUsbServer& aUsbServer); |
86 static CUsbDevice* NewL(CUsbServer& aUsbServer); |
101 virtual ~CUsbDevice(); |
87 virtual ~CUsbDevice(); |
102 |
88 |
103 void EnumerateClassControllersL(); |
89 void EnumerateClassControllersL(); |
127 const CPersonality* GetPersonality(TInt aPersonalityId) const; |
113 const CPersonality* GetPersonality(TInt aPersonalityId) const; |
128 void ValidatePersonalitiesL(); |
114 void ValidatePersonalitiesL(); |
129 void ReadPersonalitiesL(); |
115 void ReadPersonalitiesL(); |
130 void SetDefaultPersonalityL(); |
116 void SetDefaultPersonalityL(); |
131 void LoadFallbackClassControllersL(); |
117 void LoadFallbackClassControllersL(); |
132 void ConvertUidsL(const TDesC& aStr, RArray<TUint>& aUidArray); |
|
133 |
118 |
134 public: // From CActive |
119 public: // From CActive |
135 void RunL(); |
120 void RunL(); |
136 void DoCancel(); |
121 void DoCancel(); |
137 TInt RunError(TInt aError); |
122 TInt RunError(TInt aError); |
150 void StartCurrentClassController(); |
135 void StartCurrentClassController(); |
151 void StopCurrentClassController(); |
136 void StopCurrentClassController(); |
152 |
137 |
153 private: |
138 private: |
154 void SetDeviceDescriptorL(); |
139 void SetDeviceDescriptorL(); |
|
140 void SetUsbDeviceSettingsL(TUsbDeviceDescriptor& aDeviceDescriptor); |
155 void SetUsbDeviceSettingsDefaultsL(TUsbDeviceDescriptor& aDeviceDescriptor); |
141 void SetUsbDeviceSettingsDefaultsL(TUsbDeviceDescriptor& aDeviceDescriptor); |
156 void SelectClassControllersL(); |
142 void SelectClassControllersL(); |
157 void SetCurrentPersonalityL(TInt aPersonalityId); |
143 void SetCurrentPersonalityL(TInt aPersonalityId); |
158 void SetUsbDeviceSettingsFromPersonalityL(CUsbDevice::TUsbDeviceDescriptor& aDeviceDescriptor); |
144 void SetUsbDeviceSettingsFromPersonalityL(CUsbDevice::TUsbDeviceDescriptor& aDeviceDescriptor); |
159 void ResourceFileNameL(TFileName& aFileName); |
145 void ResourceFileNameL(TFileName& aFileName); |
160 void CreateClassControllersL(const RArray<TUid>& aClassUids); |
146 void CreateClassControllersL(const RArray<TUid>& aClassUids); |
|
147 void ConvertUidsL(const TDesC& aStr, RArray<TUint>& aUidArray); |
161 TInt PowerUpAndConnect(); |
148 TInt PowerUpAndConnect(); |
162 #ifdef _DEBUG |
149 #ifdef __FLOG_ACTIVE |
163 void PrintDescriptor(CUsbDevice::TUsbDeviceDescriptor& aDeviceDescriptor); |
150 void PrintDescriptor(CUsbDevice::TUsbDeviceDescriptor& aDeviceDescriptor); |
164 #endif |
151 #endif |
165 void InstantiateExtensionPluginsL(); |
152 void InstantiateExtensionPluginsL(); |
166 private: |
153 private: |
167 RPointerArray<CUsbClassControllerBase> iSupportedClasses; |
154 RPointerArray<CUsbClassControllerBase> iSupportedClasses; |
168 RPointerArray<MUsbDeviceNotify> iObservers; |
155 RPointerArray<MUsbDeviceNotify> iObservers; |
169 RPointerArray<CUsbmanExtensionPlugin> iExtensionPlugins; |
156 RPointerArray<CUsbmanExtensionPlugin> iExtensionPlugins; |
170 TUsbDeviceState iDeviceState; |
157 TUsbDeviceState iDeviceState; |
171 TUsbServiceState iServiceState; |
158 TUsbServiceState iServiceState; |
172 TInt iLastError; |
159 TInt iLastError; |
173 RDevUsbcClient iLdd; |
160 RDevUsbcClient iLdd; |
178 RPointerArray<CPersonality> iSupportedPersonalities; |
165 RPointerArray<CPersonality> iSupportedPersonalities; |
179 RArray<TUid> iSupportedClassUids; |
166 RArray<TUid> iSupportedClassUids; |
180 TBool iPersonalityCfged; |
167 TBool iPersonalityCfged; |
181 TBool iUdcSupportsCableDetectWhenUnpowered; |
168 TBool iUdcSupportsCableDetectWhenUnpowered; |
182 HBufC16* iDefaultSerialNumber; |
169 HBufC16* iDefaultSerialNumber; |
183 CUsbManCenRepManager* iCenRepManager; // Own CenRepManager instance |
|
184 TUsbDeviceConfiguration iDeviceConfiguration; |
|
185 |
170 |
186 REComSession* iEcom; // Not to be deleted, only closed! |
171 REComSession* iEcom; // Not to be deleted, only closed! |
187 }; |
172 }; |
188 |
173 |
189 #include "CUsbDevice.inl" |
174 #include "CUsbDevice.inl" |