|
1 /* |
|
2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalComponent |
|
21 */ |
|
22 |
|
23 #ifndef FDF_H |
|
24 #define FDF_H |
|
25 |
|
26 #include <e32base.h> |
|
27 #include "activewaitforbusevent.h" |
|
28 #include "activewaitforecomevent.h" |
|
29 #include <ecom/ecom.h> |
|
30 #include "deviceproxy.h" |
|
31 #include "fdcproxy.h" |
|
32 |
|
33 class CFdfSession; |
|
34 class CEventQueue; |
|
35 |
|
36 NONSHARABLE_CLASS(CFdf) : public CBase, public MBusEventObserver, public MEComEventObserver |
|
37 { |
|
38 private: // types used internally |
|
39 struct TInterfaceInfo |
|
40 { |
|
41 // This odd NewL either: leaves safely, or passes ownership of the new |
|
42 // TInterfaceInfo to aInterfaces. |
|
43 static TInterfaceInfo* NewL(RPointerArray<TInterfaceInfo>& aInterfaces); |
|
44 |
|
45 TUint8 iNumber; |
|
46 TUint8 iClass; |
|
47 TUint8 iSubclass; |
|
48 TUint8 iProtocol; |
|
49 |
|
50 TBool iClaimed; |
|
51 }; |
|
52 |
|
53 |
|
54 enum TDeviceSearchKeys |
|
55 { |
|
56 EVendorProductDevice = 0, |
|
57 EVendorProduct = 1, |
|
58 EVendorDevicesubclassDeviceprotocol = 2, |
|
59 EVendorDevicesubclass = 3, |
|
60 EDeviceclassDevicesubclassDeviceprotocol = 4, |
|
61 EDeviceclassDevicesubclass = 5, |
|
62 EMaxDeviceSearchKey = 6 |
|
63 }; |
|
64 |
|
65 |
|
66 enum TInterfaceSearchKeys |
|
67 { |
|
68 EVendorProductDeviceConfigurationvalueInterfacenumber = 0, |
|
69 EVendorProductConfigurationValueInterfacenumber = 1, |
|
70 EVendorInterfacesubclassInterfaceprotocol = 2, |
|
71 EVendorInterfacesubclass = 3, |
|
72 EInterfaceclassInterfacesubclassInterfaceprotocol = 4, |
|
73 EInterfaceclassInterfacesubclass = 5, |
|
74 EMaxInterfaceSearchKey = 6, |
|
75 }; |
|
76 |
|
77 public: |
|
78 static CFdf* NewL(); |
|
79 ~CFdf(); |
|
80 |
|
81 public: // called by CFdfSession |
|
82 TBool GetDeviceEvent(TDeviceEvent& aEvent); |
|
83 TBool GetDevmonEvent(TInt& aEvent); |
|
84 |
|
85 public: // called by CFdfServer |
|
86 void SetSession(CFdfSession* aSession); |
|
87 |
|
88 public: // called by event queue |
|
89 CFdfSession* Session(); |
|
90 |
|
91 public: // invoked indirectly by USBMAN |
|
92 void EnableDriverLoading(); |
|
93 void DisableDriverLoading(); |
|
94 |
|
95 public: // called by CFdcProxy |
|
96 TUint32 TokenForInterface(TUint8 aInterface); |
|
97 void GetSerialNumberStringDescriptorL(TUint aDeviceId, TUint32 aLangId, TName& aString) const; |
|
98 |
|
99 public: // called by CFdcProxy and CFdfSession |
|
100 void GetManufacturerStringDescriptorL(TUint aDeviceId, TUint32 aLangId, TName& aString) const; |
|
101 void GetProductStringDescriptorL(TUint aDeviceId, TUint32 aLangId, TName& aString) const; |
|
102 const RArray<TUint>& GetSupportedLanguagesL(TUint aDeviceId) const; |
|
103 void GetOtgDeviceDescriptorL(TInt aDeviceId, TOtgDescriptor& aDescriptor) const; |
|
104 |
|
105 private: |
|
106 CFdf(); |
|
107 void ConstructL(); |
|
108 |
|
109 private: |
|
110 void MbeoBusEvent(); // from MBusEventObserver |
|
111 void EComEventReceived(); // from MEComEventObserver |
|
112 void HandleEComEventReceivedL(); |
|
113 |
|
114 private: // utility |
|
115 void CreateFunctionDriverProxiesL(); |
|
116 CDeviceProxy* DeviceProxyL(TUint aDeviceId) const; |
|
117 void TellFdcsOfDeviceDetachment(TUint aDeviceId); |
|
118 void ParseL(TUsbGenericDescriptor& aDesc); |
|
119 |
|
120 // Top-level handlers of MBusEventObserver events (calls to MbeoBusEvent) |
|
121 void HandleDeviceAttachment(TUint aDeviceId); |
|
122 void HandleDeviceDetachment(TUint aDeviceId); |
|
123 void HandleDevmonEvent(TInt aEvent); |
|
124 |
|
125 // Second-level handler of device attachment. Performs the first step: |
|
126 // *actual* device attachment at the FDF level. |
|
127 void HandleDeviceAttachmentL(TUint aDeviceId, CDeviceProxy*& aDevice); |
|
128 |
|
129 // Second-level handler of device attachment. Performs the second step: |
|
130 // driver loading. |
|
131 void DoDriverLoading(CDeviceProxy& aDevice); |
|
132 void DoDriverLoadingL(CDeviceProxy& aDevice); |
|
133 |
|
134 // Utilities for driver loading. |
|
135 |
|
136 void FindDriversForInterfacesUsingSpecificKeyL(CDeviceProxy& aDevice, |
|
137 TInt& aCollectedErr, |
|
138 TBool& aAnySuccess, |
|
139 RArray<TUint>& aInterfacesNumberArray, |
|
140 TInterfaceSearchKeys aKey); |
|
141 |
|
142 void FindDriverForInterfaceUsingSpecificKey(CDeviceProxy& aDevice, |
|
143 TInt& aCollectedErr, |
|
144 TBool& aAnySuccess, |
|
145 RArray<TUint>& aInterfacesGivenToFdc, |
|
146 const TDesC8& aSearchKey); |
|
147 TBool SearchForADeviceFunctionDriverL(CDeviceProxy& aDevice, TBool& aAnySuccess, TInt& aCollectedErr); |
|
148 void SearchForInterfaceFunctionDriversL(CDeviceProxy& aDevice, TBool& aAnySuccess, TInt& aCollectedErr); |
|
149 void FormatDeviceSearchKey(TDes8& aSearchKey, TDeviceSearchKeys aSearchKeys); |
|
150 void FormatInterfaceSearchKey(TDes8& aSearchKey, TInterfaceSearchKeys aSearchKeys, const TInterfaceInfo& aIfInfo); |
|
151 TUint UnclaimedInterfaceCount() const; |
|
152 void AppendInterfaceNumberToArrayL(CDeviceProxy& aDevice, RArray<TUint>& aArray, TUint aInterfaceNo) const; |
|
153 void SetFailureStatus(TInt aUnclaimedInterfaces, TInt aInterfaceCount, TBool aAnySuccess, TBool aCollectedErr, CDeviceProxy& aDevice); |
|
154 TBool FindMultipleFDs(const TDesC8& aSearchKey,TSglQueIter<CFdcProxy>& aFdcIter); |
|
155 void RebuildUnClaimedInterfacesArrayL(CDeviceProxy& aDevice, RArray<TUint>& aArray, TUint aOffset = 0); |
|
156 private: // unowned |
|
157 CFdfSession* iSession; |
|
158 |
|
159 private: // owned |
|
160 TUsbDeviceDescriptor iDD; |
|
161 TUsbConfigurationDescriptor iCD; |
|
162 TBool iDriverLoadingEnabled; |
|
163 CEventQueue* iEventQueue; |
|
164 |
|
165 TBool iDeviceDetachedTooEarly; |
|
166 |
|
167 RImplInfoPtrArray iImplInfoArray; |
|
168 |
|
169 // Our session on (and data from) the USBDI thunk. |
|
170 RUsbHubDriver iHubDriver; |
|
171 CActiveWaitForBusEvent* iActiveWaitForBusEvent; |
|
172 CActiveWaitForEComEvent* iActiveWaitForEComEvent; |
|
173 RUsbHubDriver::TBusEvent iBusEvent; |
|
174 |
|
175 // Our collections of attached devices and of Function Driver Controllers. |
|
176 TSglQue<CDeviceProxy> iDevices; |
|
177 TSglQue<CFdcProxy> iFunctionDrivers; |
|
178 |
|
179 // Used while offering interfaces to FDCs. |
|
180 RPointerArray<TInterfaceInfo> iInterfaces; |
|
181 CDeviceProxy* iCurrentDevice; // iCurrentDevice is not owned by CFdf |
|
182 }; |
|
183 |
|
184 #endif // FDF_H |