26 namespace NUnitTesting_USBDI |
30 namespace NUnitTesting_USBDI |
27 { |
31 { |
28 |
32 |
29 CUsbClientStateWatcher* CUsbClientStateWatcher::NewL(RDevUsbcClient& aClientDriver,MUsbClientStateObserver& aStateObserver) |
33 CUsbClientStateWatcher* CUsbClientStateWatcher::NewL(RDevUsbcClient& aClientDriver,MUsbClientStateObserver& aStateObserver) |
30 { |
34 { |
|
35 OstTraceFunctionEntryExt( CUSBCLIENTSTATEWATCHER_NEWL_ENTRY, 0 ); |
31 CUsbClientStateWatcher* self = new (ELeave) CUsbClientStateWatcher(aClientDriver,aStateObserver); |
36 CUsbClientStateWatcher* self = new (ELeave) CUsbClientStateWatcher(aClientDriver,aStateObserver); |
32 CleanupStack::PushL(self); |
37 CleanupStack::PushL(self); |
33 self->ConstructL(); |
38 self->ConstructL(); |
34 CleanupStack::Pop(self); |
39 CleanupStack::Pop(self); |
|
40 OstTraceFunctionExit1( CUSBCLIENTSTATEWATCHER_NEWL_EXIT, ( TUint )( self ) ); |
35 return self; |
41 return self; |
36 } |
42 } |
37 |
43 |
38 |
44 |
39 CUsbClientStateWatcher::CUsbClientStateWatcher(RDevUsbcClient& aClientDriver,MUsbClientStateObserver& aStateObserver) |
45 CUsbClientStateWatcher::CUsbClientStateWatcher(RDevUsbcClient& aClientDriver,MUsbClientStateObserver& aStateObserver) |
40 : CActive(EPriorityUserInput), |
46 : CActive(EPriorityUserInput), |
41 iClientDriver(aClientDriver), |
47 iClientDriver(aClientDriver), |
42 iStateObserver(aStateObserver) |
48 iStateObserver(aStateObserver) |
43 { |
49 { |
|
50 OstTraceFunctionEntryExt( CUSBCLIENTSTATEWATCHER_CUSBCLIENTSTATEWATCHER_ENTRY, this ); |
44 CActiveScheduler::Add(this); |
51 CActiveScheduler::Add(this); |
|
52 OstTraceFunctionExit1( CUSBCLIENTSTATEWATCHER_CUSBCLIENTSTATEWATCHER_EXIT, this ); |
45 } |
53 } |
46 |
54 |
47 |
55 |
48 CUsbClientStateWatcher::~CUsbClientStateWatcher() |
56 CUsbClientStateWatcher::~CUsbClientStateWatcher() |
49 { |
57 { |
50 LOG_FUNC |
58 OstTraceFunctionEntry1( CUSBCLIENTSTATEWATCHER_CUSBCLIENTSTATEWATCHER_ENTRY_DUP01, this ); |
51 Cancel(); |
59 Cancel(); |
|
60 OstTraceFunctionExit1( CUSBCLIENTSTATEWATCHER_CUSBCLIENTSTATEWATCHER_EXIT_DUP01, this ); |
52 } |
61 } |
53 |
62 |
54 |
63 |
55 void CUsbClientStateWatcher::ConstructL() |
64 void CUsbClientStateWatcher::ConstructL() |
56 { |
65 { |
57 RDebug::Printf("<Client State Watcher> Watching state of device"); |
66 OstTraceFunctionEntry1( CUSBCLIENTSTATEWATCHER_CONSTRUCTL_ENTRY, this ); |
|
67 OstTrace0(TRACE_NORMAL, CUSBCLIENTSTATEWATCHER_CONSTRUCTL, "<Client State Watcher> Watching state of device"); |
58 iClientDriver.AlternateDeviceStatusNotify(iStatus,iState); |
68 iClientDriver.AlternateDeviceStatusNotify(iStatus,iState); |
59 SetActive(); |
69 SetActive(); |
|
70 OstTraceFunctionExit1( CUSBCLIENTSTATEWATCHER_CONSTRUCTL_EXIT, this ); |
60 } |
71 } |
61 |
72 |
62 |
73 |
63 void CUsbClientStateWatcher::DoCancel() |
74 void CUsbClientStateWatcher::DoCancel() |
64 { |
75 { |
|
76 OstTraceFunctionEntry1( CUSBCLIENTSTATEWATCHER_DOCANCEL_ENTRY, this ); |
65 // Cancel device status notification |
77 // Cancel device status notification |
66 iClientDriver.AlternateDeviceStatusNotifyCancel(); |
78 iClientDriver.AlternateDeviceStatusNotifyCancel(); |
|
79 OstTraceFunctionExit1( CUSBCLIENTSTATEWATCHER_DOCANCEL_EXIT, this ); |
67 } |
80 } |
68 |
81 |
69 void CUsbClientStateWatcher::RunL() |
82 void CUsbClientStateWatcher::RunL() |
70 { |
83 { |
|
84 OstTraceFunctionEntry1( CUSBCLIENTSTATEWATCHER_RUNL_ENTRY, this ); |
71 // Retrieve the asynchronous completion code |
85 // Retrieve the asynchronous completion code |
72 TInt completionCode(iStatus.Int()); |
86 TInt completionCode(iStatus.Int()); |
73 |
87 |
74 if(iState & KUsbAlternateSetting) |
88 if(iState & KUsbAlternateSetting) |
75 { |
89 { |
81 if(completionCode == KErrNone) |
95 if(completionCode == KErrNone) |
82 { |
96 { |
83 switch(iState) |
97 switch(iState) |
84 { |
98 { |
85 case EUsbcDeviceStateUndefined: |
99 case EUsbcDeviceStateUndefined: |
86 RDebug::Printf("<Client State> Not attached"); |
100 OstTrace0(TRACE_NORMAL, CUSBCLIENTSTATEWATCHER_RUNL, "<Client State> Not attached"); |
87 break; |
101 break; |
88 |
102 |
89 case EUsbcDeviceStateAttached: |
103 case EUsbcDeviceStateAttached: |
90 RDebug::Printf("<Client State> Attached to host but not powered"); |
104 OstTrace0(TRACE_NORMAL, CUSBCLIENTSTATEWATCHER_RUNL_DUP01, "<Client State> Attached to host but not powered"); |
91 break; |
105 break; |
92 |
106 |
93 case EUsbcDeviceStatePowered: |
107 case EUsbcDeviceStatePowered: |
94 RDebug::Printf("<Client State> Attached and powered but no reset"); |
108 OstTrace0(TRACE_NORMAL, CUSBCLIENTSTATEWATCHER_RUNL_DUP02, "<Client State> Attached and powered but no reset"); |
95 break; |
109 break; |
96 |
110 |
97 case EUsbcDeviceStateDefault: |
111 case EUsbcDeviceStateDefault: |
98 RDebug::Printf("<Client State> Reset but not addressed"); |
112 OstTrace0(TRACE_NORMAL, CUSBCLIENTSTATEWATCHER_RUNL_DUP03, "<Client State> Reset but not addressed"); |
99 break; |
113 break; |
100 |
114 |
101 case EUsbcDeviceStateAddress: |
115 case EUsbcDeviceStateAddress: |
102 RDebug::Printf("<Client State> Addressed but not configured"); |
116 OstTrace0(TRACE_NORMAL, CUSBCLIENTSTATEWATCHER_RUNL_DUP04, "<Client State> Addressed but not configured"); |
103 break; |
117 break; |
104 |
118 |
105 case EUsbcDeviceStateConfigured: |
119 case EUsbcDeviceStateConfigured: |
106 RDebug::Printf("<Client State> Fully configured"); |
120 OstTrace0(TRACE_NORMAL, CUSBCLIENTSTATEWATCHER_RUNL_DUP05, "<Client State> Fully configured"); |
107 break; |
121 break; |
108 |
122 |
109 case EUsbcDeviceStateSuspended: |
123 case EUsbcDeviceStateSuspended: |
110 RDebug::Printf("<Client State> Suspended"); |
124 OstTrace0(TRACE_NORMAL, CUSBCLIENTSTATEWATCHER_RUNL_DUP06, "<Client State> Suspended"); |
111 break; |
125 break; |
112 |
126 |
113 case EUsbcNoState: //follow through |
127 case EUsbcNoState: //follow through |
114 default: |
128 default: |
115 RDebug::Printf("<Client State> Not specified"); |
129 OstTrace0(TRACE_NORMAL, CUSBCLIENTSTATEWATCHER_RUNL_DUP07, "<Client State> Not specified"); |
116 break; |
130 break; |
117 } |
131 } |
118 } |
132 } |
119 else |
133 else |
120 { |
134 { |
121 RDebug::Printf("<Client State> Notification error %d",completionCode); |
135 OstTrace1(TRACE_NORMAL, CUSBCLIENTSTATEWATCHER_RUNL_DUP08, "<Client State> Notification error %d",completionCode); |
122 } |
136 } |
123 |
137 |
124 // Device state change |
138 // Device state change |
125 iStateObserver.StateChangeL(static_cast<TUsbcDeviceState>(iState),completionCode); |
139 iStateObserver.StateChangeL(static_cast<TUsbcDeviceState>(iState),completionCode); |
126 } |
140 } |
127 |
141 |
128 // Keep asking to be informed for status notifications |
142 // Keep asking to be informed for status notifications |
129 iClientDriver.AlternateDeviceStatusNotify(iStatus,iState); |
143 iClientDriver.AlternateDeviceStatusNotify(iStatus,iState); |
130 SetActive(); |
144 SetActive(); |
|
145 OstTraceFunctionExit1( CUSBCLIENTSTATEWATCHER_RUNL_EXIT, this ); |
131 } |
146 } |
132 |
147 |
133 |
148 |
134 TInt CUsbClientStateWatcher::RunError(TInt aError) |
149 TInt CUsbClientStateWatcher::RunError(TInt aError) |
135 { |
150 { |
|
151 OstTraceFunctionEntryExt( CUSBCLIENTSTATEWATCHER_RUNERROR_ENTRY, this ); |
136 aError = KErrNone; |
152 aError = KErrNone; |
|
153 OstTraceFunctionExitExt( CUSBCLIENTSTATEWATCHER_RUNERROR_EXIT, this, aError ); |
137 return aError; |
154 return aError; |
138 } |
155 } |
139 |
156 |
140 |
157 |
141 |
158 |
143 |
160 |
144 |
161 |
145 CAlternateInterfaceSelectionWatcher* CAlternateInterfaceSelectionWatcher::NewL( |
162 CAlternateInterfaceSelectionWatcher* CAlternateInterfaceSelectionWatcher::NewL( |
146 RDevUsbcClient& aClientDriver,MAlternateSettingObserver& aObserver) |
163 RDevUsbcClient& aClientDriver,MAlternateSettingObserver& aObserver) |
147 { |
164 { |
|
165 OstTraceFunctionEntryExt( CALTERNATEINTERFACESELECTIONWATCHER_NEWL_ENTRY, 0 ); |
148 CAlternateInterfaceSelectionWatcher* self = new (ELeave) CAlternateInterfaceSelectionWatcher(aClientDriver,aObserver); |
166 CAlternateInterfaceSelectionWatcher* self = new (ELeave) CAlternateInterfaceSelectionWatcher(aClientDriver,aObserver); |
149 CleanupStack::PushL(self); |
167 CleanupStack::PushL(self); |
150 self->ConstructL(); |
168 self->ConstructL(); |
151 CleanupStack::Pop(self); |
169 CleanupStack::Pop(self); |
|
170 OstTraceFunctionExit1( CALTERNATEINTERFACESELECTIONWATCHER_NEWL_EXIT, ( TUint )( self ) ); |
152 return self; |
171 return self; |
153 } |
172 } |
154 |
173 |
155 |
174 |
156 CAlternateInterfaceSelectionWatcher::CAlternateInterfaceSelectionWatcher( |
175 CAlternateInterfaceSelectionWatcher::CAlternateInterfaceSelectionWatcher( |
157 RDevUsbcClient& aClientDriver,MAlternateSettingObserver& aObserver) |
176 RDevUsbcClient& aClientDriver,MAlternateSettingObserver& aObserver) |
158 : CActive(EPriorityUserInput), |
177 : CActive(EPriorityUserInput), |
159 iClientDriver(aClientDriver), |
178 iClientDriver(aClientDriver), |
160 iObserver(aObserver) |
179 iObserver(aObserver) |
161 { |
180 { |
|
181 OstTraceFunctionEntryExt( CALTERNATEINTERFACESELECTIONWATCHER_CALTERNATEINTERFACESELECTIONWATCHER_ENTRY, this ); |
162 CActiveScheduler::Add(this); |
182 CActiveScheduler::Add(this); |
|
183 OstTraceFunctionExit1( CALTERNATEINTERFACESELECTIONWATCHER_CALTERNATEINTERFACESELECTIONWATCHER_EXIT, this ); |
163 } |
184 } |
164 |
185 |
165 |
186 |
166 CAlternateInterfaceSelectionWatcher::~CAlternateInterfaceSelectionWatcher() |
187 CAlternateInterfaceSelectionWatcher::~CAlternateInterfaceSelectionWatcher() |
167 { |
188 { |
168 LOG_FUNC |
189 OstTraceFunctionEntry1( CALTERNATEINTERFACESELECTIONWATCHER_CALTERNATEINTERFACESELECTIONWATCHER_ENTRY_DUP01, this ); |
169 |
190 |
170 Cancel(); |
191 Cancel(); |
|
192 OstTraceFunctionExit1( CALTERNATEINTERFACESELECTIONWATCHER_CALTERNATEINTERFACESELECTIONWATCHER_EXIT_DUP01, this ); |
171 } |
193 } |
172 |
194 |
173 |
195 |
174 void CAlternateInterfaceSelectionWatcher::ConstructL() |
196 void CAlternateInterfaceSelectionWatcher::ConstructL() |
175 { |
197 { |
176 LOG_FUNC |
198 OstTraceFunctionEntry1( CALTERNATEINTERFACESELECTIONWATCHER_CONSTRUCTL_ENTRY, this ); |
177 |
199 |
178 iClientDriver.AlternateDeviceStatusNotify(iStatus,iState); |
200 iClientDriver.AlternateDeviceStatusNotify(iStatus,iState); |
179 SetActive(); |
201 SetActive(); |
|
202 OstTraceFunctionExit1( CALTERNATEINTERFACESELECTIONWATCHER_CONSTRUCTL_EXIT, this ); |
180 } |
203 } |
181 |
204 |
182 |
205 |
183 void CAlternateInterfaceSelectionWatcher::DoCancel() |
206 void CAlternateInterfaceSelectionWatcher::DoCancel() |
184 { |
207 { |
185 LOG_FUNC |
208 OstTraceFunctionEntry1( CALTERNATEINTERFACESELECTIONWATCHER_DOCANCEL_ENTRY, this ); |
186 |
209 |
187 iClientDriver.AlternateDeviceStatusNotifyCancel(); |
210 iClientDriver.AlternateDeviceStatusNotifyCancel(); |
|
211 OstTraceFunctionExit1( CALTERNATEINTERFACESELECTIONWATCHER_DOCANCEL_EXIT, this ); |
188 } |
212 } |
189 |
213 |
190 |
214 |
191 void CAlternateInterfaceSelectionWatcher::RunL() |
215 void CAlternateInterfaceSelectionWatcher::RunL() |
192 { |
216 { |
193 LOG_FUNC |
217 OstTraceFunctionEntry1( CALTERNATEINTERFACESELECTIONWATCHER_RUNL_ENTRY, this ); |
194 |
218 |
195 TInt completionCode(iStatus.Int()); |
219 TInt completionCode(iStatus.Int()); |
196 |
220 |
197 if(iState & KUsbAlternateSetting) |
221 if(iState & KUsbAlternateSetting) |
198 { |
222 { |
199 iObserver.AlternateInterfaceSelectedL(iState & (~KUsbAlternateSetting)); |
223 iObserver.AlternateInterfaceSelectedL(iState & (~KUsbAlternateSetting)); |
200 } |
224 } |
201 // Keep asking to be informed for status notifications |
225 // Keep asking to be informed for status notifications |
202 iClientDriver.AlternateDeviceStatusNotify(iStatus,iState); |
226 iClientDriver.AlternateDeviceStatusNotify(iStatus,iState); |
203 SetActive(); |
227 SetActive(); |
|
228 OstTraceFunctionExit1( CALTERNATEINTERFACESELECTIONWATCHER_RUNL_EXIT, this ); |
204 } |
229 } |
205 |
230 |
206 |
231 |
207 TInt CAlternateInterfaceSelectionWatcher::RunError(TInt aError) |
232 TInt CAlternateInterfaceSelectionWatcher::RunError(TInt aError) |
208 { |
233 { |
209 LOG_FUNC |
234 OstTraceFunctionEntryExt( CALTERNATEINTERFACESELECTIONWATCHER_RUNERROR_ENTRY, this ); |
210 |
235 |
|
236 OstTraceFunctionExitExt( CALTERNATEINTERFACESELECTIONWATCHER_RUNERROR_EXIT, this, KErrNone ); |
211 return KErrNone; |
237 return KErrNone; |
212 } |
238 } |
213 |
239 |
214 |
240 |
215 |
241 |