18 |
18 |
19 /** |
19 /** |
20 @file |
20 @file |
21 */ |
21 */ |
22 |
22 |
|
23 #include <usbstates.h> |
|
24 #include <usberrors.h> |
|
25 #include <usb/usbshared.h> |
23 #include <usb/usblogger.h> |
26 #include <usb/usblogger.h> |
|
27 |
24 #include "CUsbSession.h" |
28 #include "CUsbSession.h" |
25 #include "CUsbDevice.h" |
29 #include "CUsbDevice.h" |
26 #include "CUsbServer.h" |
30 #include "CUsbServer.h" |
27 |
31 |
28 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
32 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
29 #include "CUsbOtg.h" |
33 #include "CUsbOtg.h" |
30 #include "cusbhost.h" |
34 #include "cusbhost.h" |
31 #endif // SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
35 #endif // SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
32 |
36 |
33 #include <usbstates.h> |
|
34 #include <usberrors.h> |
|
35 |
|
36 #include <usb/usbshared.h> |
|
37 #include "CPersonality.h" |
37 #include "CPersonality.h" |
38 #include "rusb.h" |
38 #include "rusb.h" |
39 #include "UsbSettings.h" |
39 #include "UsbSettings.h" |
40 |
40 #include "OstTraceDefinitions.h" |
41 #ifdef __FLOG_ACTIVE |
41 #ifdef OST_TRACE_COMPILER_IN_USE |
42 _LIT8(KLogComponent, "USBSVR"); |
42 #include "CUsbSessionTraces.h" |
43 #endif |
43 #endif |
|
44 |
|
45 |
44 |
46 |
45 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
47 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
46 CUsbSession* CUsbSession::iCtlSession = NULL; |
48 CUsbSession* CUsbSession::iCtlSession = NULL; |
47 #endif // SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
49 #endif // SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
48 |
50 |
73 * @param aServer Service the session will be a member of |
75 * @param aServer Service the session will be a member of |
74 */ |
76 */ |
75 CUsbSession::CUsbSession(CUsbServer* aServer) |
77 CUsbSession::CUsbSession(CUsbServer* aServer) |
76 : iUsbServer(aServer) |
78 : iUsbServer(aServer) |
77 { |
79 { |
78 LOG_FUNC |
80 OstTraceFunctionEntry0( CUSBSESSION_CUSBSESSION_CONS_ENTRY ); |
79 |
81 |
80 iUsbServer->IncrementSessionCount(); |
82 iUsbServer->IncrementSessionCount(); |
|
83 OstTraceFunctionExit0( CUSBSESSION_CUSBSESSION_CONS_EXIT ); |
81 } |
84 } |
82 |
85 |
83 |
86 |
84 /** |
87 /** |
85 * Destructor. |
88 * Destructor. |
86 */ |
89 */ |
87 CUsbSession::~CUsbSession() |
90 CUsbSession::~CUsbSession() |
88 { |
91 { |
89 LOG_FUNC |
92 OstTraceFunctionEntry0( CUSBSESSION_CUSBSESSION_DES_ENTRY ); |
90 |
93 |
91 LOGTEXT2(_L8("About to Device().DeRegisterObserver(%08x"),this); |
94 OstTrace1( TRACE_NORMAL, CUSBSESSION_CUSBSESSION, "CUsbSession::~CUsbSession;About to Device().DeRegisterObserver(%08x)", this ); |
92 iUsbServer->Device().DeRegisterObserver(*this); |
95 iUsbServer->Device().DeRegisterObserver(*this); |
93 |
96 |
94 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
97 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
95 #ifndef __OVER_DUMMYUSBDI__ |
98 #ifndef __OVER_DUMMYUSBDI__ |
96 LOGTEXT2(_L8("About to Otg().DeRegisterObserver(%08x"),this); |
99 OstTrace1( TRACE_NORMAL, CUSBSESSION_CUSBSESSION_DUP1, "CUsbSession::~CUsbSession;About to Otg().DeRegisterObserver(%08x)", this ); |
97 iUsbServer->Otg().DeRegisterObserver(*this); |
100 iUsbServer->Otg().DeRegisterObserver(*this); |
98 #endif |
101 #endif |
99 |
102 |
100 LOGTEXT2(_L8("About to Host().DeRegisterObserver(%08x"),this); |
103 OstTrace1( TRACE_NORMAL, CUSBSESSION_CUSBSESSION_DUP2, "CUsbSession::~CUsbSession;About to Host().DeRegisterObserver(%08x)", this ); |
101 iUsbServer->Host().DeregisterObserver(*this); |
104 iUsbServer->Host().DeregisterObserver(*this); |
102 |
105 |
103 if ( iCtlSession && (iCtlSession == this) ) |
106 if ( iCtlSession && (iCtlSession == this) ) |
104 { |
107 { |
105 iCtlSession = NULL; |
108 iCtlSession = NULL; |
106 } |
109 } |
107 #endif // SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
110 #endif // SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
108 |
111 |
109 LOGTEXT(_L8("About to iUsbServer->DecrementSessionCount()")); |
112 OstTrace0( TRACE_NORMAL, CUSBSESSION_CUSBSESSION_DUP3, "CUsbSession::~CUsbSession;About to iUsbServer->DecrementSessionCount()" ); |
110 iUsbServer->DecrementSessionCount(); |
113 iUsbServer->DecrementSessionCount(); |
|
114 OstTraceFunctionExit0( CUSBSESSION_CUSBSESSION_DES_EXIT ); |
111 } |
115 } |
112 |
116 |
113 |
117 |
114 /** |
118 /** |
115 * Called when a message is received from the client. |
119 * Called when a message is received from the client. |
116 * |
120 * |
117 * @param aMessage Message received from the client |
121 * @param aMessage Message received from the client |
118 */ |
122 */ |
119 void CUsbSession::ServiceL(const RMessage2& aMessage) |
123 void CUsbSession::ServiceL(const RMessage2& aMessage) |
120 { |
124 { |
121 LOG_FUNC |
125 OstTraceFunctionEntry0( CUSBSESSION_SERVICEL_ENTRY ); |
122 |
126 |
123 DispatchMessageL(aMessage); |
127 DispatchMessageL(aMessage); |
|
128 OstTraceFunctionExit0( CUSBSESSION_SERVICEL_EXIT ); |
124 } |
129 } |
125 |
130 |
126 /** |
131 /** |
127 * Handles 2nd Phase Construction. Implementation of the virtual method defined in CSession2 and called from |
132 * Handles 2nd Phase Construction. Implementation of the virtual method defined in CSession2 and called from |
128 * CServer2::DoConnectL() which executes when the client makes a connection request through CServer2::Connect(). If |
133 * CServer2::DoConnectL() which executes when the client makes a connection request through CServer2::Connect(). If |
129 * a Leave occurs at any point the CUsbSession object is cleaned up in CServer2::DoConnect(). |
134 * a Leave occurs at any point the CUsbSession object is cleaned up in CServer2::DoConnect(). |
130 */ |
135 */ |
131 void CUsbSession::CreateL() |
136 void CUsbSession::CreateL() |
132 { |
137 { |
133 LOG_FUNC |
138 OstTraceFunctionEntry0( CUSBSESSION_CREATEL_ENTRY ); |
134 |
139 |
135 // This code originally existed in the typical non-virtual ConstructL() method. |
140 // This code originally existed in the typical non-virtual ConstructL() method. |
136 // However it was moved to this method for minor optimisation reasons [three less |
141 // However it was moved to this method for minor optimisation reasons [three less |
137 // function calls and several lines less code in the NewL() method]. |
142 // function calls and several lines less code in the NewL() method]. |
138 |
143 |
139 iPersonalityCfged = iUsbServer->Device().isPersonalityCfged(); |
144 iPersonalityCfged = iUsbServer->Device().isPersonalityCfged(); |
140 |
145 |
141 LOGTEXT(_L8("Registering Device Observer\n")); |
146 OstTrace0( TRACE_NORMAL, CUSBSESSION_CREATEL, "CUsbSession::CreateL;Registering Device Observer" ); |
142 iUsbServer->Device().RegisterObserverL(*this); |
147 iUsbServer->Device().RegisterObserverL(*this); |
143 |
148 |
144 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
149 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
145 #ifndef __OVER_DUMMYUSBDI__ |
150 #ifndef __OVER_DUMMYUSBDI__ |
146 LOGTEXT(_L8("Registering OTG Observer\n")); |
151 OstTrace0( TRACE_NORMAL, CUSBSESSION_CREATEL_DUP1, "CUsbSession::CreateL;Registering OTG Observer" ); |
147 iUsbServer->Otg().RegisterObserverL(*this); |
152 iUsbServer->Otg().RegisterObserverL(*this); |
148 #endif |
153 #endif |
149 |
154 |
150 LOGTEXT(_L8("Registering HOST Observer\n")); |
155 OstTrace0( TRACE_NORMAL, CUSBSESSION_CREATEL_DUP2, "CUsbSession::CreateL;Registering HOST Observer" ); |
151 iUsbServer->Host().RegisterObserverL(*this); |
156 iUsbServer->Host().RegisterObserverL(*this); |
152 #endif // SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
157 #endif // SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
|
158 OstTraceFunctionExit0( CUSBSESSION_CREATEL_EXIT ); |
153 } |
159 } |
154 |
160 |
155 /** |
161 /** |
156 * Called by CUsbDevice when the service state changes. |
162 * Called by CUsbDevice when the service state changes. |
157 * CUsbSession is an observer of the device. |
163 * CUsbSession is an observer of the device. |
161 * @param aNewState The device's new and current service state |
167 * @param aNewState The device's new and current service state |
162 */ |
168 */ |
163 void CUsbSession::UsbServiceStateChange(TInt aLastError, TUsbServiceState aOldState, |
169 void CUsbSession::UsbServiceStateChange(TInt aLastError, TUsbServiceState aOldState, |
164 TUsbServiceState aNewState) |
170 TUsbServiceState aNewState) |
165 { |
171 { |
166 LOG_FUNC |
172 OstTraceFunctionEntry0( CUSBSESSION_USBSERVICESTATECHANGE_ENTRY ); |
167 LOGTEXT3(_L8(" aOldState=0x%X, aNewState=0x%X"), aOldState, aNewState); |
173 OstTraceExt2( TRACE_NORMAL, CUSBSESSION_USBSERVICESTATECHANGE, "CUsbSession::UsbServiceStateChange;aOldState=0x%X, aNewState=0x%X", aOldState, aNewState ); |
168 (void) aOldState; // a-void build warning in UREL |
174 (void) aOldState; // a-void build warning in UREL |
169 |
175 |
170 // Note that it's possible to have both a start and a stop outstanding! |
176 // Note that it's possible to have both a start and a stop outstanding! |
171 |
177 |
172 if (iStartOutstanding) |
178 if (iStartOutstanding) |
197 * @param aNewState The state we've moved to |
204 * @param aNewState The state we've moved to |
198 */ |
205 */ |
199 void CUsbSession::HandleServiceStateChangeWhileStarting(TInt aLastError, |
206 void CUsbSession::HandleServiceStateChangeWhileStarting(TInt aLastError, |
200 TUsbServiceState aNewState) |
207 TUsbServiceState aNewState) |
201 { |
208 { |
202 LOG_FUNC |
209 OstTraceFunctionEntry0( CUSBSESSION_HANDLESERVICESTATECHANGEWHILESTARTING_ENTRY ); |
203 |
210 |
204 switch (aNewState) |
211 switch (aNewState) |
205 { |
212 { |
206 case EUsbServiceStarted: |
213 case EUsbServiceStarted: |
207 LOGTEXT(_L8(" Completing Start successfully")); |
214 OstTrace0( TRACE_NORMAL, CUSBSESSION_HANDLESERVICESTATECHANGEWHILESTARTING, "CUsbSession::HandleServiceStateChangeWhileStarting Completing Start successfully" ); |
208 |
215 |
209 // If the user has tried to cancel the start, they're too late! |
216 // If the user has tried to cancel the start, they're too late! |
210 if (iCancelOutstanding) |
217 if (iCancelOutstanding) |
211 { |
218 { |
212 LOGTEXT(_L8(" Completing cancel request with KErrNone")); |
219 OstTrace0( TRACE_NORMAL, CUSBSESSION_HANDLESERVICESTATECHANGEWHILESTARTING_DUP1, "CUsbSession::HandleServiceStateChangeWhileStarting Completing cancel request with KErrNone" ); |
213 iCancelOutstanding = EFalse; |
220 iCancelOutstanding = EFalse; |
214 iCancelMessage.Complete(KErrNone); |
221 iCancelMessage.Complete(KErrNone); |
215 } |
222 } |
216 |
223 |
217 iStartMessage.Complete(KErrNone); |
224 iStartMessage.Complete(KErrNone); |
218 iStartOutstanding = EFalse; |
225 iStartOutstanding = EFalse; |
219 break; |
226 break; |
220 |
227 |
221 case EUsbServiceIdle: |
228 case EUsbServiceIdle: |
222 LOGTEXT2(_L8(" Completing Start with error=%d"), aLastError); |
229 OstTrace1( TRACE_NORMAL, CUSBSESSION_HANDLESERVICESTATECHANGEWHILESTARTING_DUP2, "CUsbSession::HandleServiceStateChangeWhileStarting; Completing Start with error=%d", aLastError ); |
223 |
230 |
224 // If there hasn't actually been an error, but we're in an unexpected |
231 // If there hasn't actually been an error, but we're in an unexpected |
225 // state now, that means that this client cancelled the request, or |
232 // state now, that means that this client cancelled the request, or |
226 // another client stopped the service. |
233 // another client stopped the service. |
227 if (aLastError == KErrNone) |
234 if (aLastError == KErrNone) |
228 { |
235 { |
229 // If there's a cancel outstanding, then that message succeeded, but |
236 // If there's a cancel outstanding, then that message succeeded, but |
230 // the start message should be completed with KErrCancel. |
237 // the start message should be completed with KErrCancel. |
231 if (iCancelOutstanding) |
238 if (iCancelOutstanding) |
232 { |
239 { |
233 LOGTEXT(_L8(" Completing original message with KErrCancel")); |
240 OstTrace0( TRACE_NORMAL, CUSBSESSION_HANDLESERVICESTATECHANGEWHILESTARTING_DUP3, "CUsbSession::HandleServiceStateChangeWhileStarting Completing original message with KErrCancel" ); |
234 iCancelOutstanding = EFalse; |
241 iCancelOutstanding = EFalse; |
235 iCancelMessage.Complete(KErrNone); |
242 iCancelMessage.Complete(KErrNone); |
236 iStartMessage.Complete(KErrCancel); |
243 iStartMessage.Complete(KErrCancel); |
237 } |
244 } |
238 else |
245 else |
267 * @param aNewState The state we've moved to |
275 * @param aNewState The state we've moved to |
268 */ |
276 */ |
269 void CUsbSession::HandleServiceStateChangeWhileStopping(TInt aLastError, |
277 void CUsbSession::HandleServiceStateChangeWhileStopping(TInt aLastError, |
270 TUsbServiceState aNewState) |
278 TUsbServiceState aNewState) |
271 { |
279 { |
272 LOG_FUNC |
280 OstTraceFunctionEntry0( CUSBSESSION_HANDLESERVICESTATECHANGEWHILESTOPPING_ENTRY ); |
273 |
281 |
274 switch (aNewState) |
282 switch (aNewState) |
275 { |
283 { |
276 case EUsbServiceStarted: |
284 case EUsbServiceStarted: |
277 LOGTEXT2(_L8(" Completing Stop with error=%d"), aLastError); |
285 OstTrace1( TRACE_NORMAL, CUSBSESSION_HANDLESERVICESTATECHANGEWHILESTOPPING, "CUsbSession::HandleServiceStateChangeWhileStopping; Completing Stop with error=%d", aLastError ); |
278 |
286 |
279 // If there hasn't actually been an error, but we're in an unexpected |
287 // If there hasn't actually been an error, but we're in an unexpected |
280 // state now, that means that this client cancelled the request, or |
288 // state now, that means that this client cancelled the request, or |
281 // another client has started the service. |
289 // another client has started the service. |
282 if (aLastError == KErrNone) |
290 if (aLastError == KErrNone) |
283 { |
291 { |
284 // If there's a cancel outstanding, then that message succeeded, but |
292 // If there's a cancel outstanding, then that message succeeded, but |
285 // the stop message should be completed with KErrCancel. |
293 // the stop message should be completed with KErrCancel. |
286 if (iCancelOutstanding) |
294 if (iCancelOutstanding) |
287 { |
295 { |
288 LOGTEXT(_L8(" Completing original message with KErrCancel")); |
296 OstTrace0( TRACE_NORMAL, CUSBSESSION_HANDLESERVICESTATECHANGEWHILESTOPPING_DUP1, "CUsbSession::HandleServiceStateChangeWhileStopping; Completing original message with KErrCancel" ); |
289 iCancelOutstanding = EFalse; |
297 iCancelOutstanding = EFalse; |
290 iCancelMessage.Complete(KErrNone); |
298 iCancelMessage.Complete(KErrNone); |
291 iStopMessage.Complete(KErrCancel); |
299 iStopMessage.Complete(KErrCancel); |
292 } |
300 } |
293 else |
301 else |
309 |
317 |
310 iStopOutstanding = EFalse; |
318 iStopOutstanding = EFalse; |
311 break; |
319 break; |
312 |
320 |
313 case EUsbServiceIdle: |
321 case EUsbServiceIdle: |
314 LOGTEXT(_L8(" Completing Stop with KErrNone")); |
322 OstTrace0( TRACE_NORMAL, CUSBSESSION_HANDLESERVICESTATECHANGEWHILESTOPPING_DUP2, "CUsbSession::HandleServiceStateChangeWhileStopping Completing Stop with KErrNone" ); |
315 |
323 |
316 // If the user has tried to cancel the stop, they're too late! |
324 // If the user has tried to cancel the stop, they're too late! |
317 if (iCancelOutstanding) |
325 if (iCancelOutstanding) |
318 { |
326 { |
319 LOGTEXT(_L8(" Completing cancel request with KErrNone")); |
327 OstTrace0( TRACE_NORMAL, CUSBSESSION_HANDLESERVICESTATECHANGEWHILESTOPPING_DUP3, "CUsbSession::HandleServiceStateChangeWhileStopping Completing cancel request with KErrNone" ); |
320 iCancelOutstanding = EFalse; |
328 iCancelOutstanding = EFalse; |
321 iCancelMessage.Complete(KErrNone); |
329 iCancelMessage.Complete(KErrNone); |
322 } |
330 } |
323 |
331 |
324 iStopMessage.Complete(KErrNone); |
332 iStopMessage.Complete(KErrNone); |
403 if (addToQueue) |
411 if (addToQueue) |
404 { |
412 { |
405 // add event to head of queue |
413 // add event to head of queue |
406 iDeviceStateQueue[iDevStateQueueHead] = aNewState; |
414 iDeviceStateQueue[iDevStateQueueHead] = aNewState; |
407 iDevStateQueueHead = (iDevStateQueueHead + 1) % KDeviceStatesQueueSize; |
415 iDevStateQueueHead = (iDevStateQueueHead + 1) % KDeviceStatesQueueSize; |
408 LOGTEXT3(_L8("+++ addqueue (%d, %d)"), iDevStateQueueHead, |
416 OstTraceExt2( TRACE_NORMAL, CUSBSESSION_USBDEVICESTATECHANGE_DUP1, "CUsbSession::UsbDeviceStateChange;+++ addqueue (%d, %d)", iDevStateQueueHead, iDevStateQueueTail ); |
409 iDevStateQueueTail); |
|
410 } |
417 } |
411 |
418 |
412 // UsbDeviceDequeueEvent() will read from queue when RegisterObserver() |
419 // UsbDeviceDequeueEvent() will read from queue when RegisterObserver() |
413 // is next called. |
420 // is next called. |
414 } |
421 } |
|
422 OstTraceFunctionExit0( CUSBSESSION_USBDEVICESTATECHANGE_EXIT ); |
415 } |
423 } |
416 |
424 |
417 /** |
425 /** |
418 * Dequeues an event and completes the observer's request with it. |
426 * Dequeues an event and completes the observer's request with it. |
419 */ |
427 */ |
420 void CUsbSession::UsbDeviceDequeueEvent() |
428 void CUsbSession::UsbDeviceDequeueEvent() |
421 { |
429 { |
422 LOG_FUNC |
430 OstTraceFunctionEntry0( CUSBSESSION_USBDEVICEDEQUEUEEVENT_ENTRY ); |
423 |
431 |
424 // Work our way through the queue, until we reach the end |
432 // Work our way through the queue, until we reach the end |
425 // OR we find an event the current observer wants. |
433 // OR we find an event the current observer wants. |
426 while ((iDeviceObserverOutstanding) && (iDevStateQueueHead != iDevStateQueueTail)) |
434 while ((iDeviceObserverOutstanding) && (iDevStateQueueHead != iDevStateQueueTail)) |
427 { |
435 { |
438 { |
446 { |
439 TPckg<TUint32> pckg(newState); |
447 TPckg<TUint32> pckg(newState); |
440 |
448 |
441 iNotifiedDevState = newState; |
449 iNotifiedDevState = newState; |
442 |
450 |
443 LOGTEXT3(_L8(">>> dequeued event #%d (0x%x)"), iDevStateQueueTail, newState); |
451 OstTraceExt2( TRACE_NORMAL, CUSBSESSION_USBDEVICEDEQUEUEEVENT, "CUsbSession::UsbDeviceDequeueEvent;dequeued event #%d (0x%x)", iDevStateQueueTail, newState ); |
444 |
452 |
445 iDeviceObserverOutstanding = EFalse; |
453 iDeviceObserverOutstanding = EFalse; |
446 const TInt err = iDeviceObserverMessage.Write(1, pckg); |
454 const TInt err = iDeviceObserverMessage.Write(1, pckg); |
447 iDeviceObserverMessage.Complete(err); |
455 iDeviceObserverMessage.Complete(err); |
448 break; |
456 break; |
449 } |
457 } |
450 } |
458 } |
|
459 OstTraceFunctionExit0( CUSBSESSION_USBDEVICEDEQUEUEEVENT_EXIT ); |
451 } |
460 } |
452 |
461 |
453 /** |
462 /** |
454 * Handles the request (in the form of a the message) received from the client |
463 * Handles the request (in the form of a the message) received from the client |
455 * |
464 * |
456 * @internalComponent |
465 * @internalComponent |
457 * @param aMessage The received message |
466 * @param aMessage The received message |
458 */ |
467 */ |
459 void CUsbSession::DispatchMessageL(const RMessage2& aMessage) |
468 void CUsbSession::DispatchMessageL(const RMessage2& aMessage) |
460 { |
469 { |
461 LOG_FUNC |
470 OstTraceFunctionEntry0( CUSBSESSION_DISPATCHMESSAGEL_ENTRY ); |
462 |
471 |
463 TBool complete = ETrue; |
472 TBool complete = ETrue; |
464 TInt ret = KErrNone; |
473 TInt ret = KErrNone; |
465 |
474 |
466 LOGTEXT2(_L8("CUsbSession::DispatchMessageL(): func# %d"), aMessage.Function()); |
475 OstTrace1( TRACE_NORMAL, CUSBSESSION_DISPATCHMESSAGEL, "CUsbSession::DispatchMessageL;func#=%d", aMessage.Function() ); |
467 |
476 |
468 switch (aMessage.Function()) |
477 switch (aMessage.Function()) |
469 { |
478 { |
470 case EUsbStart: |
479 case EUsbStart: |
471 ret = StartDeviceL(aMessage, complete); |
480 ret = StartDeviceL(aMessage, complete); |
527 |
536 |
528 #ifdef _DEBUG |
537 #ifdef _DEBUG |
529 // Heap failure debug APIs. |
538 // Heap failure debug APIs. |
530 |
539 |
531 case EUsbDbgMarkHeap: |
540 case EUsbDbgMarkHeap: |
532 LOGTEXT(_L8("Marking heap")); |
541 OstTrace0( TRACE_NORMAL, CUSBSESSION_DISPATCHMESSAGEL_DUP1, "CUsbSession::DispatchMessageL;Marking heap" ); |
533 __UHEAP_MARK; |
542 __UHEAP_MARK; |
534 break; |
543 break; |
535 case EUsbDbgCheckHeap: |
544 case EUsbDbgCheckHeap: |
536 LOGTEXT2(_L8("Checking heap (expecting %d cells)"), aMessage.Int0()); |
545 OstTrace1( TRACE_NORMAL, CUSBSESSION_DISPATCHMESSAGEL_DUP2, "CUsbSession::DispatchMessageL;Checking heap (expecting %d cells)", aMessage.Int0() ); |
537 __UHEAP_CHECK(aMessage.Int0()); |
546 __UHEAP_CHECK(aMessage.Int0()); |
538 break; |
547 break; |
539 case EUsbDbgMarkEnd: |
548 case EUsbDbgMarkEnd: |
540 LOGTEXT2(_L8("End of marking heap (expecting %d cells)"), aMessage.Int0()); |
549 OstTrace1( TRACE_NORMAL, CUSBSESSION_DISPATCHMESSAGEL_DUP3, "CUsbSession::DispatchMessageL;End of marking heap (expecting %d cells)", aMessage.Int0() ); |
541 __UHEAP_MARKENDC(aMessage.Int0()); |
550 __UHEAP_MARKENDC(aMessage.Int0()); |
542 break; |
551 break; |
543 case EUsbDbgFailNext: |
552 case EUsbDbgFailNext: |
544 { |
553 { |
545 LOGTEXT2(_L8("Simulating failure after %d allocation(s)"), aMessage.Int0()); |
554 OstTrace1( TRACE_NORMAL, CUSBSESSION_DISPATCHMESSAGEL_DUP4, "CUsbSession::DispatchMessageL;Simulating failure after %d allocation(s)", aMessage.Int0() ); |
546 if (aMessage.Int0() == 0) |
555 if (aMessage.Int0() == 0) |
547 __UHEAP_RESET; |
556 __UHEAP_RESET; |
548 else |
557 else |
549 __UHEAP_FAILNEXT(aMessage.Int0()); |
558 __UHEAP_FAILNEXT(aMessage.Int0()); |
550 } |
559 } |
551 break; |
560 break; |
552 case EUsbDbgAlloc: |
561 case EUsbDbgAlloc: |
553 { |
562 { |
554 ret = KErrNone; |
563 ret = KErrNone; |
555 #ifdef _DEBUG |
564 #ifdef _DEBUG |
556 LOGTEXT(_L8("\tallocate on the heap")); |
565 OstTrace0( TRACE_NORMAL, CUSBSESSION_DISPATCHMESSAGEL_DUP5, "CUsbSession::DispatchMessageL;allocate on the heap" ); |
557 TInt* x = NULL; |
566 TInt* x = NULL; |
558 TRAP(ret, x = new(ELeave) TInt); |
567 TRAP(ret, x = new(ELeave) TInt); |
559 delete x; |
568 delete x; |
560 #endif // _DEBUG |
569 #endif // _DEBUG |
561 } |
570 } |
724 * @param aComplete Whether the request is complete or not |
737 * @param aComplete Whether the request is complete or not |
725 * @return Any error that occurred or KErrNone |
738 * @return Any error that occurred or KErrNone |
726 */ |
739 */ |
727 TInt CUsbSession::StopDeviceL(const RMessage2& aMessage, TBool& aComplete) |
740 TInt CUsbSession::StopDeviceL(const RMessage2& aMessage, TBool& aComplete) |
728 { |
741 { |
729 LOG_FUNC |
742 OstTraceFunctionEntry0( CUSBSESSION_STOPDEVICEL_ENTRY ); |
730 |
743 |
731 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
744 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
732 // Only 'control' session is allowed to stop USB support |
745 // Only 'control' session is allowed to stop USB support |
733 if ( !iSessionCtlMode ) |
746 if ( !iSessionCtlMode ) |
734 { |
747 { |
|
748 OstTraceFunctionExit0( CUSBSESSION_STOPDEVICEL_EXIT ); |
735 return KErrAccessDenied; |
749 return KErrAccessDenied; |
736 } |
750 } |
737 #endif |
751 #endif |
738 |
752 |
739 if (iStopOutstanding) |
753 if (iStopOutstanding) |
740 { |
754 { |
|
755 OstTraceFunctionExit0( CUSBSESSION_STOPDEVICEL_EXIT_DUP1 ); |
741 return KErrInUse; |
756 return KErrInUse; |
742 } |
757 } |
743 |
758 |
744 #ifndef __OVER_DUMMYUSBDI__ |
759 #ifndef __OVER_DUMMYUSBDI__ |
745 |
760 |
820 * @param aComplete Whether the message is complete or not |
839 * @param aComplete Whether the message is complete or not |
821 * @return KErrNone on success, otherwise standard error codes |
840 * @return KErrNone on success, otherwise standard error codes |
822 */ |
841 */ |
823 TInt CUsbSession::StopCancel(const RMessage2& aMessage, TBool& aComplete) |
842 TInt CUsbSession::StopCancel(const RMessage2& aMessage, TBool& aComplete) |
824 { |
843 { |
825 LOG_FUNC |
844 OstTraceFunctionEntry0( CUSBSESSION_STOPCANCEL_ENTRY ); |
826 |
|
827 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
845 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
828 // Only 'control' session is allowed to cancel outstaning stop request |
846 // Only 'control' session is allowed to cancel outstaning stop request |
829 if ( !iSessionCtlMode ) |
847 if ( !iSessionCtlMode ) |
830 { |
848 { |
|
849 OstTraceFunctionExit0( CUSBSESSION_STOPCANCEL_EXIT ); |
831 return KErrAccessDenied; |
850 return KErrAccessDenied; |
832 } |
851 } |
833 #endif |
852 #endif |
834 |
853 |
835 if (!iStopOutstanding) |
854 if (!iStopOutstanding) |
836 { |
855 { |
|
856 OstTraceFunctionExit0( CUSBSESSION_STOPCANCEL_EXIT_DUP1 ); |
837 return KErrNone; |
857 return KErrNone; |
838 } |
858 } |
839 |
859 |
840 aComplete = EFalse; |
860 aComplete = EFalse; |
841 iCancelMessage = aMessage; |
861 iCancelMessage = aMessage; |
875 |
897 |
876 if (iObserverQueueEvents == EFalse) |
898 if (iObserverQueueEvents == EFalse) |
877 { |
899 { |
878 // This is the first observer after c'tor or DeregisterObserver(), |
900 // This is the first observer after c'tor or DeregisterObserver(), |
879 // so zap the device event queue. |
901 // so zap the device event queue. |
880 LOGTEXT(_L8(" Reset Device Event Queue")); |
902 OstTrace0( TRACE_NORMAL, CUSBSESSION_REGISTERDEVICEOBSERVER, "CUsbSession::RegisterDeviceObserver Reset Device Event Queue" ); |
881 iDevStateQueueHead = 0; |
903 iDevStateQueueHead = 0; |
882 iDevStateQueueTail = 0; |
904 iDevStateQueueTail = 0; |
883 iObserverQueueEvents = ETrue; |
905 iObserverQueueEvents = ETrue; |
884 } |
906 } |
885 else if (iDevStateQueueHead != iDevStateQueueTail) |
907 else if (iDevStateQueueHead != iDevStateQueueTail) |
886 { |
908 { |
887 // event(s) queued, we can de-queue one now |
909 // event(s) queued, we can de-queue one now |
888 UsbDeviceDequeueEvent(); |
910 UsbDeviceDequeueEvent(); |
889 } |
911 } |
890 |
912 |
|
913 OstTraceFunctionExit0( CUSBSESSION_REGISTERDEVICEOBSERVER_EXIT_DUP1 ); |
891 return KErrNone; |
914 return KErrNone; |
892 } |
915 } |
893 |
916 |
894 /** |
917 /** |
895 * Client request to observe the service (for state changes) |
918 * Client request to observe the service (for state changes) |
1010 * @param aComplete set to true to complete the request |
1039 * @param aComplete set to true to complete the request |
1011 * @return Any error that occurred or KErrNone |
1040 * @return Any error that occurred or KErrNone |
1012 */ |
1041 */ |
1013 TInt CUsbSession::TryStartDeviceL(const RMessage2& aMessage, TBool& aComplete) |
1042 TInt CUsbSession::TryStartDeviceL(const RMessage2& aMessage, TBool& aComplete) |
1014 { |
1043 { |
1015 LOG_FUNC |
1044 OstTraceFunctionEntry0( CUSBSESSION_TRYSTARTDEVICEL_ENTRY ); |
1016 |
1045 |
1017 #ifndef __OVER_DUMMYUSBDI__ |
1046 #ifndef __OVER_DUMMYUSBDI__ |
1018 |
1047 |
1019 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
1048 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
1020 // Only 'control' session is allowed to start USB support |
1049 // Only 'control' session is allowed to start USB support |
1021 if ( !iSessionCtlMode ) |
1050 if ( !iSessionCtlMode ) |
1022 { |
1051 { |
|
1052 OstTraceFunctionExit0( CUSBSESSION_TRYSTARTDEVICEL_EXIT ); |
1023 return KErrAccessDenied; |
1053 return KErrAccessDenied; |
1024 } |
1054 } |
1025 #endif |
1055 #endif |
1026 |
1056 |
1027 if (!iPersonalityCfged) |
1057 if (!iPersonalityCfged) |
1028 { |
1058 { |
|
1059 OstTraceFunctionExit0( CUSBSESSION_TRYSTARTDEVICEL_EXIT_DUP1 ); |
1029 return KErrNotSupported; |
1060 return KErrNotSupported; |
1030 } |
1061 } |
1031 |
1062 |
1032 if (iStartOutstanding || iStopOutstanding) |
1063 if (iStartOutstanding || iStopOutstanding) |
1033 { |
1064 { |
|
1065 OstTraceFunctionExit0( CUSBSESSION_TRYSTARTDEVICEL_EXIT_DUP2 ); |
1034 return KErrServerBusy; |
1066 return KErrServerBusy; |
1035 } |
1067 } |
1036 |
1068 |
1037 // Obtains the curent service state |
1069 // Obtains the curent service state |
1038 TUsbServiceState state = iUsbServer->Device().ServiceState(); |
1070 TUsbServiceState state = iUsbServer->Device().ServiceState(); |
1104 * @param aComplete Whether the request is complete or not |
1140 * @param aComplete Whether the request is complete or not |
1105 * @return Any error that occurred or KErrNone |
1141 * @return Any error that occurred or KErrNone |
1106 */ |
1142 */ |
1107 TInt CUsbSession::TryStopDeviceL(const RMessage2& aMessage, TBool& aComplete) |
1143 TInt CUsbSession::TryStopDeviceL(const RMessage2& aMessage, TBool& aComplete) |
1108 { |
1144 { |
1109 LOG_FUNC |
1145 OstTraceFunctionEntry0( CUSBSESSION_TRYSTOPDEVICEL_ENTRY ); |
1110 |
1146 |
1111 #ifndef __OVER_DUMMYUSBDI__ |
1147 #ifndef __OVER_DUMMYUSBDI__ |
1112 |
1148 |
1113 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
1149 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
1114 // Only 'control' session is allowed to stop USB support |
1150 // Only 'control' session is allowed to stop USB support |
1115 if ( !iSessionCtlMode ) |
1151 if ( !iSessionCtlMode ) |
1116 { |
1152 { |
|
1153 OstTraceFunctionExit0( CUSBSESSION_TRYSTOPDEVICEL_EXIT ); |
1117 return KErrAccessDenied; |
1154 return KErrAccessDenied; |
1118 } |
1155 } |
1119 #endif |
1156 #endif |
1120 |
1157 |
1121 if (!iPersonalityCfged) |
1158 if (!iPersonalityCfged) |
1122 { |
1159 { |
|
1160 OstTraceFunctionExit0( CUSBSESSION_TRYSTOPDEVICEL_EXIT_DUP1 ); |
1123 return KErrNotSupported; |
1161 return KErrNotSupported; |
1124 } |
1162 } |
1125 |
1163 |
1126 if (iStartOutstanding || iStopOutstanding) |
1164 if (iStartOutstanding || iStopOutstanding) |
1127 { |
1165 { |
|
1166 OstTraceFunctionExit0( CUSBSESSION_TRYSTOPDEVICEL_EXIT_DUP2 ); |
1128 return KErrServerBusy; |
1167 return KErrServerBusy; |
1129 } |
1168 } |
1130 |
1169 |
1131 // Obtains the curent service state |
1170 // Obtains the curent service state |
1132 TUsbServiceState state = iUsbServer->Device().ServiceState(); |
1171 TUsbServiceState state = iUsbServer->Device().ServiceState(); |
1152 iStopMessage = aMessage; |
1191 iStopMessage = aMessage; |
1153 iStopOutstanding = ETrue; |
1192 iStopOutstanding = ETrue; |
1154 } |
1193 } |
1155 else if (state == EUsbServiceStarting) |
1194 else if (state == EUsbServiceStarting) |
1156 { |
1195 { |
|
1196 OstTraceFunctionExit0( CUSBSESSION_TRYSTOPDEVICEL_EXIT_DUP3 ); |
1157 return KErrServerBusy; |
1197 return KErrServerBusy; |
1158 } |
1198 } |
1159 else if (state == EUsbServiceStopping) |
1199 else if (state == EUsbServiceStopping) |
1160 { |
1200 { |
1161 aComplete = EFalse; |
1201 aComplete = EFalse; |
1162 iStopMessage = aMessage; |
1202 iStopMessage = aMessage; |
1163 iStopOutstanding = ETrue; |
1203 iStopOutstanding = ETrue; |
1164 } |
1204 } |
1165 |
1205 |
|
1206 OstTraceFunctionExit0( CUSBSESSION_TRYSTOPDEVICEL_EXIT_DUP4 ); |
1166 return KErrNone; |
1207 return KErrNone; |
1167 |
1208 |
1168 #else |
1209 #else |
1169 // pretend that the server is in Started state |
1210 // pretend that the server is in Started state |
1170 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
1211 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
1171 iUsbServer->Host().Stop(); |
1212 iUsbServer->Host().Stop(); |
1172 #endif |
1213 #endif |
1173 aMessage.IsNull(); |
1214 aMessage.IsNull(); |
1174 aComplete = ETrue; |
1215 aComplete = ETrue; |
1175 iStopOutstanding = EFalse; |
1216 iStopOutstanding = EFalse; |
|
1217 OstTraceFunctionExit0( CUSBSESSION_TRYSTOPDEVICEL_EXIT_DUP5 ); |
1176 return KErrNone; |
1218 return KErrNone; |
1177 #endif |
1219 #endif |
1178 } |
1220 } |
1179 |
1221 |
1180 /** |
1222 /** |
1222 * @param aMessage Message received from the client |
1266 * @param aMessage Message received from the client |
1223 * @return Any error that occurred or KErrNone |
1267 * @return Any error that occurred or KErrNone |
1224 */ |
1268 */ |
1225 TInt CUsbSession::GetCurrentPersonalityId(const RMessage2& aMessage) |
1269 TInt CUsbSession::GetCurrentPersonalityId(const RMessage2& aMessage) |
1226 { |
1270 { |
1227 LOG_FUNC |
1271 OstTraceFunctionEntry0( CUSBSESSION_GETCURRENTPERSONALITYID_ENTRY ); |
1228 |
1272 |
1229 if (!iPersonalityCfged) |
1273 if (!iPersonalityCfged) |
1230 { |
1274 { |
|
1275 OstTraceFunctionExit0( CUSBSESSION_GETCURRENTPERSONALITYID_EXIT ); |
1231 return KErrNotSupported; |
1276 return KErrNotSupported; |
1232 } |
1277 } |
1233 |
1278 |
1234 TInt currentPersonalityId = iUsbServer->Device().CurrentPersonalityId(); |
1279 TInt currentPersonalityId = iUsbServer->Device().CurrentPersonalityId(); |
1235 LOGTEXT2(_L8("\tcurrentPersonalityId = %d"), currentPersonalityId); |
1280 OstTrace1( TRACE_NORMAL, CUSBSESSION_GETCURRENTPERSONALITYID, "CUsbSession::GetCurrentPersonalityId;currentPersonalityId=%d", currentPersonalityId ); |
1236 TPckgC<TInt> pckg(currentPersonalityId); |
1281 TPckgC<TInt> pckg(currentPersonalityId); |
1237 return aMessage.Write(0, pckg); |
1282 return aMessage.Write(0, pckg); |
1238 } |
1283 } |
1239 |
1284 |
1240 /** |
1285 /** |
1261 // Gets all class uids for the given personality |
1307 // Gets all class uids for the given personality |
1262 const RPointerArray<CPersonality>& personalities = iUsbServer->Device().Personalities(); |
1308 const RPointerArray<CPersonality>& personalities = iUsbServer->Device().Personalities(); |
1263 TInt personalityCount = personalities.Count(); |
1309 TInt personalityCount = personalities.Count(); |
1264 for (TInt i = 0; i < personalityCount; i++) |
1310 for (TInt i = 0; i < personalityCount; i++) |
1265 { |
1311 { |
1266 __ASSERT_ALWAYS(personalities[i] != NULL, _USB_PANIC(KUsbSvrPncCat, ENullPersonalityPointer)); |
1312 if(personalities[i] == NULL) |
|
1313 { |
|
1314 OstTrace1( TRACE_NORMAL, CUSBSESSION_GETSUPPORTEDCLASSES, "CUsbSession::GetSupportedClasses;ENullPersonalityPointer=%d", ENullPersonalityPointer ); |
|
1315 User::Panic(KUsbSvrPncCat, ENullPersonalityPointer); |
|
1316 } |
1267 if (aMessage.Int0() == personalities[i]->PersonalityId()) |
1317 if (aMessage.Int0() == personalities[i]->PersonalityId()) |
1268 { |
1318 { |
1269 classUids[0] = personalities[i]->SupportedClasses().Count(); |
1319 classUids[0] = personalities[i]->SupportedClasses().Count(); |
1270 for (TInt j = 1; j <= classUids[0]; j++) |
1320 for (TInt j = 1; j <= classUids[0]; j++) |
1271 { |
1321 { |
1272 if (j < KUsbMaxSupportedClasses + 1) |
1322 if (j < KUsbMaxSupportedClasses + 1) |
1273 { |
1323 { |
1274 classUids[j] = personalities[i]->SupportedClasses()[j - 1].iClassUid.iUid; |
1324 classUids[j] = personalities[i]->SupportedClasses()[j - 1].iClassUid.iUid; |
1275 LOGTEXT3(_L8("\tclassUids[%d] = %d"), j, classUids[j]); |
1325 OstTrace1( TRACE_NORMAL, CUSBSESSION_GETSUPPORTEDCLASSES_DUP1, "CUsbSession::GetSupportedClasses;classUids[%d] = ", j ); |
|
1326 OstTrace1( TRACE_NORMAL, CUSBSESSION_GETSUPPORTEDCLASSES_DUP2, "%d", classUids[j] ); |
1276 } |
1327 } |
1277 else |
1328 else |
1278 { |
1329 { |
|
1330 OstTraceFunctionExit0( CUSBSESSION_GETSUPPORTEDCLASSES_EXIT_DUP1 ); |
1279 return KErrTooBig; |
1331 return KErrTooBig; |
1280 } |
1332 } |
1281 } |
1333 } |
1282 break; |
1334 break; |
1283 } |
1335 } |
1284 } |
1336 } |
1285 |
1337 |
1286 if (classUids[0] == 0) |
1338 if (classUids[0] == 0) |
1287 { |
1339 { |
1288 // No supported classes are found |
1340 // No supported classes are found |
|
1341 OstTraceFunctionExit0( CUSBSESSION_GETSUPPORTEDCLASSES_EXIT_DUP2 ); |
1289 return KErrNotSupported; |
1342 return KErrNotSupported; |
1290 } |
1343 } |
1291 |
1344 |
1292 TInt ret; |
1345 TInt ret; |
1293 HBufC8* buf = NULL; |
1346 HBufC8* buf = NULL; |
1310 * @param aMessage Message received from the client |
1364 * @param aMessage Message received from the client |
1311 * @return Any error that occurred or KErrNone |
1365 * @return Any error that occurred or KErrNone |
1312 */ |
1366 */ |
1313 TInt CUsbSession::GetPersonalityIds(const RMessage2& aMessage) |
1367 TInt CUsbSession::GetPersonalityIds(const RMessage2& aMessage) |
1314 { |
1368 { |
1315 LOG_FUNC |
1369 OstTraceFunctionEntry0( CUSBSESSION_GETPERSONALITYIDS_ENTRY ); |
1316 |
1370 |
1317 if (!iPersonalityCfged) |
1371 if (!iPersonalityCfged) |
1318 { |
1372 { |
|
1373 OstTraceFunctionExit0( CUSBSESSION_GETPERSONALITYIDS_EXIT ); |
1319 return KErrNotSupported; |
1374 return KErrNotSupported; |
1320 } |
1375 } |
1321 |
1376 |
1322 // +1 for the size of actual personality id count |
1377 // +1 for the size of actual personality id count |
1323 TInt personalityIds[KUsbMaxSupportedPersonalities + 1]; |
1378 TInt personalityIds[KUsbMaxSupportedPersonalities + 1]; |
1324 |
1379 |
1325 const RPointerArray<CPersonality>& personalities = iUsbServer->Device().Personalities(); |
1380 const RPointerArray<CPersonality>& personalities = iUsbServer->Device().Personalities(); |
1326 TInt personalityCount = personalities.Count(); |
1381 TInt personalityCount = personalities.Count(); |
1327 for (TInt i = 0; i < personalityCount; ++i) |
1382 for (TInt i = 0; i < personalityCount; ++i) |
1328 { |
1383 { |
1329 __ASSERT_ALWAYS(personalities[i] != NULL, _USB_PANIC(KUsbSvrPncCat, ENullPersonalityPointer)); |
1384 if(personalities[i] == NULL) |
|
1385 { |
|
1386 OstTrace1( TRACE_NORMAL, CUSBSESSION_GETPERSONALITYIDS, "CUsbSession::GetPersonalityIds;Panic reason=%d", ENullPersonalityPointer ); |
|
1387 User::Panic(KUsbSvrPncCat, ENullPersonalityPointer); |
|
1388 } |
1330 personalityIds[i + 1] = personalities[i]->PersonalityId(); |
1389 personalityIds[i + 1] = personalities[i]->PersonalityId(); |
1331 } |
1390 } |
1332 personalityIds[0] = personalityCount; |
1391 personalityIds[0] = personalityCount; |
1333 |
1392 |
1334 TInt ret; |
1393 TInt ret; |
1439 * @param aMessage Message received from the client |
1504 * @param aMessage Message received from the client |
1440 * @return Any error that occurred or KErrNone |
1505 * @return Any error that occurred or KErrNone |
1441 */ |
1506 */ |
1442 TInt CUsbSession::SetCtlSessionMode(const RMessage2& aMessage) |
1507 TInt CUsbSession::SetCtlSessionMode(const RMessage2& aMessage) |
1443 { |
1508 { |
1444 LOG_FUNC |
1509 OstTraceFunctionEntry0( CUSBSESSION_SETCTLSESSIONMODE_ENTRY ); |
1445 |
1510 |
1446 TInt ret = KErrNone; |
1511 TInt ret = KErrNone; |
1447 |
1512 |
1448 TBool value = (TBool)aMessage.Int0(); |
1513 TBool value = (TBool)aMessage.Int0(); |
1449 LOGTEXT2(_L8("\tSetting = %d"), static_cast<TInt>(value)); |
1514 OstTrace1( TRACE_NORMAL, CUSBSESSION_SETCTLSESSIONMODE, "CUsbSession::SetCtlSessionMode;Setting = %d", static_cast<TInt>(value) ); |
1450 |
1515 |
1451 // Verify if this is the same session which set the value before |
1516 // Verify if this is the same session which set the value before |
1452 if ( iCtlSession && (iCtlSession != this) ) |
1517 if ( iCtlSession && (iCtlSession != this) ) |
1453 { |
1518 { |
1454 ret = KErrAccessDenied; |
1519 ret = KErrAccessDenied; |
1639 * @param aMessage Message received from the client |
1712 * @param aMessage Message received from the client |
1640 * @return Any error that occurred or KErrNone |
1713 * @return Any error that occurred or KErrNone |
1641 */ |
1714 */ |
1642 TInt CUsbSession::GetSupportedLanguagesL(const RMessage2& aMessage) |
1715 TInt CUsbSession::GetSupportedLanguagesL(const RMessage2& aMessage) |
1643 { |
1716 { |
1644 LOG_FUNC |
1717 OstTraceFunctionEntry0( CUSBSESSION_GETSUPPORTEDLANGUAGESL_ENTRY ); |
1645 |
|
1646 |
1718 |
1647 const TUint deviceId = aMessage.Int0(); |
1719 const TUint deviceId = aMessage.Int0(); |
1648 LOGTEXT2(_L8("\tdeviceId = %d"), deviceId); |
1720 OstTrace1( TRACE_NORMAL, CUSBSESSION_GETSUPPORTEDLANGUAGESL, "CUsbSession::GetSupportedLanguagesL;deviceId=%d", deviceId ); |
1649 |
1721 |
1650 RArray<TUint> langIds; |
1722 RArray<TUint> langIds; |
1651 CleanupClosePushL(langIds); |
1723 CleanupClosePushL(langIds); |
1652 TInt ret = iUsbServer->Host().GetSupportedLanguages(deviceId,langIds); |
1724 TInt ret = iUsbServer->Host().GetSupportedLanguages(deviceId,langIds); |
1653 |
1725 |
1654 if (ret == KErrNone) |
1726 if (ret == KErrNone) |
1655 { |
1727 { |
1656 const TUint count = langIds.Count(); |
1728 const TUint count = langIds.Count(); |
1657 LOGTEXT2(_L8("\tcount = %d"), count); |
1729 OstTrace1( TRACE_NORMAL, CUSBSESSION_GETSUPPORTEDLANGUAGESL_DUP1, "CUsbSession::GetSupportedLanguagesL;count=%d", count ); |
1658 |
1730 |
1659 // Set error code if there is no languages or there are too many |
1731 // Set error code if there is no languages or there are too many |
1660 if ( count == 0 ) |
1732 if ( count == 0 ) |
1661 { |
1733 { |
1662 ret = KErrNotSupported; |
1734 ret = KErrNotSupported; |
1678 |
1750 |
1679 // Save all received language Ids |
1751 // Save all received language Ids |
1680 for ( TUint ii = 0 ; ii < count; ++ii ) |
1752 for ( TUint ii = 0 ; ii < count; ++ii ) |
1681 { |
1753 { |
1682 buf.Append((TUint8*)&(langIds[ii]), sizeof(TUint)); |
1754 buf.Append((TUint8*)&(langIds[ii]), sizeof(TUint)); |
1683 LOGTEXT3(_L8("Append langID[%d] = %d"),ii,langIds[ii]); |
1755 OstTraceExt2( TRACE_NORMAL, CUSBSESSION_GETSUPPORTEDLANGUAGESL_DUP2, "CUsbSession::GetSupportedLanguagesL;Append langID[%d] = %d", ii, langIds[ii] ); |
1684 } |
1756 } |
1685 |
1757 |
1686 // Write back to the client. |
1758 // Write back to the client. |
1687 ret = aMessage.Write(1, buf); |
1759 ret = aMessage.Write(1, buf); |
1688 CleanupStack::PopAndDestroy(&buf); |
1760 CleanupStack::PopAndDestroy(&buf); |
1689 } |
1761 } |
1690 } |
1762 } |
1691 |
1763 |
1692 CleanupStack::PopAndDestroy(); |
1764 CleanupStack::PopAndDestroy(); |
1693 |
1765 |
|
1766 OstTraceFunctionExit0( CUSBSESSION_GETSUPPORTEDLANGUAGESL_EXIT ); |
1694 return ret; |
1767 return ret; |
1695 } |
1768 } |
1696 |
1769 |
1697 /** |
1770 /** |
1698 * Requests a manufacturer string descriptor of connected device. |
1771 * Requests a manufacturer string descriptor of connected device. |
1701 * @param aMessage Message received from the client |
1774 * @param aMessage Message received from the client |
1702 * @return Any error that occurred or KErrNone |
1775 * @return Any error that occurred or KErrNone |
1703 */ |
1776 */ |
1704 TInt CUsbSession::GetManufacturerStringDescriptor(const RMessage2& aMessage) |
1777 TInt CUsbSession::GetManufacturerStringDescriptor(const RMessage2& aMessage) |
1705 { |
1778 { |
1706 LOG_FUNC |
1779 OstTraceFunctionEntry0( CUSBSESSION_GETMANUFACTURERSTRINGDESCRIPTOR_ENTRY ); |
1707 |
1780 |
1708 const TUint deviceId = aMessage.Int0(); |
1781 const TUint deviceId = aMessage.Int0(); |
1709 const TUint langId = aMessage.Int1(); |
1782 const TUint langId = aMessage.Int1(); |
1710 LOGTEXT3(_L8("\tdeviceId = %d, langId = %d"), deviceId, langId); |
1783 OstTraceExt2( TRACE_NORMAL, CUSBSESSION_GETMANUFACTURERSTRINGDESCRIPTOR, "CUsbSession::GetManufacturerStringDescriptor;langId=%d;deviceId=%d", langId, deviceId ); |
1711 |
1784 |
1712 TName string; |
1785 TName string; |
1713 TInt ret = iUsbServer->Host().GetManufacturerStringDescriptor(deviceId,langId,string); |
1786 TInt ret = iUsbServer->Host().GetManufacturerStringDescriptor(deviceId,langId,string); |
1714 if (ret == KErrNone) |
1787 if (ret == KErrNone) |
1715 { |
1788 { |
1716 LOGTEXT2(_L("\tstring = \"%S\""), &string); |
1789 OstTraceExt1( TRACE_NORMAL, CUSBSESSION_GETMANUFACTURERSTRINGDESCRIPTOR_DUP1, "CUsbSession::GetManufacturerStringDescriptor;string = \"%S\"", string ); |
1717 ret = aMessage.Write(2, string); |
1790 ret = aMessage.Write(2, string); |
1718 } |
1791 } |
1719 |
1792 |
|
1793 OstTraceFunctionExit0( CUSBSESSION_GETMANUFACTURERSTRINGDESCRIPTOR_EXIT ); |
1720 return ret; |
1794 return ret; |
1721 } |
1795 } |
1722 |
1796 |
1723 /** |
1797 /** |
1724 * Requests a product string descriptor of connected device. |
1798 * Requests a product string descriptor of connected device. |
1727 * @param aMessage Message received from the client |
1801 * @param aMessage Message received from the client |
1728 * @return Any error that occurred or KErrNone |
1802 * @return Any error that occurred or KErrNone |
1729 */ |
1803 */ |
1730 TInt CUsbSession::GetProductStringDescriptor(const RMessage2& aMessage) |
1804 TInt CUsbSession::GetProductStringDescriptor(const RMessage2& aMessage) |
1731 { |
1805 { |
1732 LOG_FUNC |
1806 OstTraceFunctionEntry0( CUSBSESSION_GETPRODUCTSTRINGDESCRIPTOR_ENTRY ); |
1733 |
1807 |
1734 const TUint deviceId = aMessage.Int0(); |
1808 const TUint deviceId = aMessage.Int0(); |
1735 const TUint langId = aMessage.Int1(); |
1809 const TUint langId = aMessage.Int1(); |
1736 LOGTEXT3(_L8("\tdeviceId = %d, langId = %d"), deviceId, langId); |
1810 OstTraceExt2( TRACE_NORMAL, CUSBSESSION_GETPRODUCTSTRINGDESCRIPTOR, "CUsbSession::GetProductStringDescriptor;deviceId=%d;langId=%d", deviceId, langId ); |
1737 |
1811 |
1738 TName string; |
1812 TName string; |
1739 TInt ret = iUsbServer->Host().GetProductStringDescriptor(deviceId,langId,string); |
1813 TInt ret = iUsbServer->Host().GetProductStringDescriptor(deviceId,langId,string); |
1740 if (ret == KErrNone) |
1814 if (ret == KErrNone) |
1741 { |
1815 { |
1742 LOGTEXT2(_L("\tstring = \"%S\""), &string); |
1816 OstTraceExt1( TRACE_NORMAL, CUSBSESSION_GETPRODUCTSTRINGDESCRIPTOR_DUP1, "CUsbSession::GetProductStringDescriptor;string = \"%S\"", string ); |
1743 ret = aMessage.Write(2, string); |
1817 ret = aMessage.Write(2, string); |
1744 } |
1818 } |
1745 |
1819 |
|
1820 OstTraceFunctionExit0( CUSBSESSION_GETPRODUCTSTRINGDESCRIPTOR_EXIT ); |
1746 return ret; |
1821 return ret; |
1747 } |
1822 } |
1748 |
1823 |
1749 /** |
1824 /** |
1750 * Requests a OTG descriptor of connected device. |
1825 * Requests a OTG descriptor of connected device. |
1753 * @param aMessage Message received from the client |
1828 * @param aMessage Message received from the client |
1754 * @return Any error that occurred or KErrNone |
1829 * @return Any error that occurred or KErrNone |
1755 */ |
1830 */ |
1756 TInt CUsbSession::GetOtgDescriptor(const RMessage2& aMessage) |
1831 TInt CUsbSession::GetOtgDescriptor(const RMessage2& aMessage) |
1757 { |
1832 { |
1758 LOG_FUNC |
1833 OstTraceFunctionEntry0( CUSBSESSION_GETOTGDESCRIPTOR_ENTRY ); |
1759 |
1834 |
1760 const TUint deviceId = aMessage.Int0(); |
1835 const TUint deviceId = aMessage.Int0(); |
1761 LOGTEXT2(_L8("\tdeviceId = %d"), deviceId); |
1836 OstTrace1( TRACE_NORMAL, CUSBSESSION_GETOTGDESCRIPTOR, "CUsbSession::GetOtgDescriptor;deviceId=%d", deviceId ); |
1762 |
1837 |
1763 TOtgDescriptor otgDescriptor; |
1838 TOtgDescriptor otgDescriptor; |
1764 TInt ret = iUsbServer->Host().GetOtgDescriptor(deviceId, otgDescriptor); |
1839 TInt ret = iUsbServer->Host().GetOtgDescriptor(deviceId, otgDescriptor); |
1765 if (ret == KErrNone) |
1840 if (ret == KErrNone) |
1766 { |
1841 { |
1767 TPckg<TOtgDescriptor> buf(otgDescriptor); |
1842 TPckg<TOtgDescriptor> buf(otgDescriptor); |
1768 ret = aMessage.Write(1, buf); |
1843 ret = aMessage.Write(1, buf); |
1769 } |
1844 } |
1770 |
1845 |
|
1846 OstTraceFunctionExit0( CUSBSESSION_GETOTGDESCRIPTOR_EXIT ); |
1771 return ret; |
1847 return ret; |
1772 } |
1848 } |
1773 |
1849 |
1774 /** |
1850 /** |
1775 * Client request to observe the host (for state changes). |
1851 * Client request to observe the host (for state changes). |
1798 |
1875 |
1799 if (iHostEventObserverQueueEvents == EFalse) |
1876 if (iHostEventObserverQueueEvents == EFalse) |
1800 { |
1877 { |
1801 // This is the first observer after c'tor or DeregisterObserver(), |
1878 // This is the first observer after c'tor or DeregisterObserver(), |
1802 // so zap the device event queue. |
1879 // so zap the device event queue. |
1803 LOGTEXT(_L8(" Reset OTG Host State Queue")); |
1880 OstTrace0( TRACE_NORMAL, CUSBSESSION_REGISTERHOSTOBSERVER, "CUsbSession::RegisterHostObserver; Reset OTG Host State Queue" ); |
1804 iHostEventQueueHead = 0; |
1881 iHostEventQueueHead = 0; |
1805 iHostEventQueueTail = 0; |
1882 iHostEventQueueTail = 0; |
1806 iHostEventObserverQueueEvents = ETrue; |
1883 iHostEventObserverQueueEvents = ETrue; |
1807 } |
1884 } |
1808 else if (iHostEventQueueHead != iHostEventQueueTail) |
1885 else if (iHostEventQueueHead != iHostEventQueueTail) |
1809 { |
1886 { |
1810 // event(s) queued, we can de-queue one now |
1887 // event(s) queued, we can de-queue one now |
1811 UsbHostEventDequeue(); |
1888 UsbHostEventDequeue(); |
1812 } |
1889 } |
1813 |
1890 |
|
1891 OstTraceFunctionExit0( CUSBSESSION_REGISTERHOSTOBSERVER_EXIT_DUP1 ); |
1814 return KErrNone; |
1892 return KErrNone; |
1815 } |
1893 } |
1816 |
1894 |
1817 /** |
1895 /** |
1818 * Deregister the client as an observer of host state changes. |
1896 * Deregister the client as an observer of host state changes. |
1820 * @internalComponent |
1898 * @internalComponent |
1821 * @return Always KErrNone |
1899 * @return Always KErrNone |
1822 */ |
1900 */ |
1823 TInt CUsbSession::DeRegisterHostObserver() |
1901 TInt CUsbSession::DeRegisterHostObserver() |
1824 { |
1902 { |
1825 LOG_FUNC |
1903 OstTraceFunctionEntry0( CUSBSESSION_DEREGISTERHOSTOBSERVER_ENTRY ); |
1826 |
|
1827 |
1904 |
1828 if (!iHostEventObserverQueueEvents) |
1905 if (!iHostEventObserverQueueEvents) |
1829 { |
1906 { |
1830 //Never register |
1907 //Never register |
1831 LOGTEXT(_L8("iHostEventObserverQueueEvents is FALSE!")); |
1908 OstTrace0( TRACE_NORMAL, CUSBSESSION_DEREGISTERHOSTOBSERVER, "CUsbSession::DeRegisterHostObserver;iHostEventObserverQueueEvents is FALSE!" ); |
|
1909 OstTraceFunctionExit0( CUSBSESSION_DEREGISTERHOSTOBSERVER_EXIT ); |
1832 return KErrNone; |
1910 return KErrNone; |
1833 } |
1911 } |
1834 |
1912 |
1835 if (iHostEventObserverOutstanding) |
1913 if (iHostEventObserverOutstanding) |
1836 { |
1914 { |
1837 iHostEventObserverOutstanding = EFalse; |
1915 iHostEventObserverOutstanding = EFalse; |
1838 iHostEventObserverMessage.Complete(KErrCancel); |
1916 iHostEventObserverMessage.Complete(KErrCancel); |
1839 LOGTEXT(_L8("iHostEventObserverMessage.Complete(KErrCancel);")); |
1917 OstTrace0( TRACE_NORMAL, CUSBSESSION_DEREGISTERHOSTOBSERVER_DUP1, "CUsbSession::DeRegisterHostObserver;iHostEventObserverMessage.Complete(KErrCancel);" ); |
1840 } |
1918 } |
1841 |
1919 |
1842 // client doesn't need events queuing any more |
1920 // client doesn't need events queuing any more |
1843 iHostEventObserverQueueEvents = EFalse; |
1921 iHostEventObserverQueueEvents = EFalse; |
1844 //Reset OTG Host State Queue |
1922 //Reset OTG Host State Queue |
1845 iHostEventQueueHead = 0; |
1923 iHostEventQueueHead = 0; |
1846 iHostEventQueueTail = 0; |
1924 iHostEventQueueTail = 0; |
1847 |
1925 |
|
1926 OstTraceFunctionExit0( CUSBSESSION_DEREGISTERHOSTOBSERVER_EXIT_DUP1 ); |
1848 return KErrNone; |
1927 return KErrNone; |
1849 } |
1928 } |
1850 |
1929 |
1851 /** |
1930 /** |
1852 * Client request to observe both OTG and HOST (for events and errors). |
1931 * Client request to observe both OTG and HOST (for events and errors). |
1941 else if (iMsgObserverQueueEvents) |
2024 else if (iMsgObserverQueueEvents) |
1942 { |
2025 { |
1943 // add event to head of queue |
2026 // add event to head of queue |
1944 iMsgQueue[iMsgQueueHead] = aMessage; |
2027 iMsgQueue[iMsgQueueHead] = aMessage; |
1945 iMsgQueueHead = (iMsgQueueHead + 1) % KOtgHostMessageQueueSize; |
2028 iMsgQueueHead = (iMsgQueueHead + 1) % KOtgHostMessageQueueSize; |
1946 LOGTEXT3(_L8("+++ CUsbSession::UsbOtgMessage() addqueue (%d, %d)"), iMsgQueueHead, |
2029 OstTraceExt2( TRACE_NORMAL, CUSBSESSION_USBOTGHOSTMESSAGE, "CUsbSession::UsbOtgHostMessage; addqueue (%d, %d)", iMsgQueueHead, iMsgQueueTail ); |
1947 iMsgQueueTail); |
|
1948 |
2030 |
1949 // UsbMsgDequeueEvent() will read from queue when RegisterMsgObserver() |
2031 // UsbMsgDequeueEvent() will read from queue when RegisterMsgObserver() |
1950 // is next called. |
2032 // is next called. |
1951 } |
2033 } |
|
2034 OstTraceFunctionExit0( CUSBSESSION_USBOTGHOSTMESSAGE_EXIT ); |
1952 } |
2035 } |
1953 |
2036 |
1954 /** |
2037 /** |
1955 * Called by CUsbHost when it state change. CUsbSession is an observer of |
2038 * Called by CUsbHost when it state change. CUsbSession is an observer of |
1956 * the device. If the client has an Observer outstanding then complete it, |
2039 * the device. If the client has an Observer outstanding then complete it, |
1960 * @param aDevInfo The information about the device being attached or detached |
2043 * @param aDevInfo The information about the device being attached or detached |
1961 * along with the status of Function Driver loading |
2044 * along with the status of Function Driver loading |
1962 */ |
2045 */ |
1963 void CUsbSession::UsbHostEvent(TDeviceEventInformation& aDevInfo) |
2046 void CUsbSession::UsbHostEvent(TDeviceEventInformation& aDevInfo) |
1964 { |
2047 { |
1965 LOG_FUNC |
2048 OstTraceFunctionEntry0( CUSBSESSION_USBHOSTEVENT_ENTRY ); |
1966 |
2049 |
1967 // can we bypass the queue? |
2050 // can we bypass the queue? |
1968 if ((iHostEventObserverOutstanding) && (iHostEventQueueHead == iHostEventQueueTail)) |
2051 if ((iHostEventObserverOutstanding) && (iHostEventQueueHead == iHostEventQueueTail)) |
1969 { |
2052 { |
1970 iNotifiedHostState = aDevInfo; |
2053 iNotifiedHostState = aDevInfo; |
1971 iHostEventObserverOutstanding = EFalse; |
2054 iHostEventObserverOutstanding = EFalse; |
1972 |
2055 |
1973 LOGTEXT(_L8("CUsbSession::UsbHostEvent() detected outstanding request")); |
2056 OstTrace0( TRACE_NORMAL, CUSBSESSION_USBHOSTEVENT, "CUsbSession::UsbHostEvent detected outstanding request" ); |
1974 |
2057 |
1975 TPckg<TDeviceEventInformation> info(aDevInfo); |
2058 TPckg<TDeviceEventInformation> info(aDevInfo); |
1976 const TInt err = iHostEventObserverMessage.Write(0, info); |
2059 const TInt err = iHostEventObserverMessage.Write(0, info); |
1977 iHostEventObserverMessage.Complete(err); |
2060 iHostEventObserverMessage.Complete(err); |
1978 LOGTEXT2(_L8("CUsbSession::UsbHostEvent() detects outstanding request: request is compeleted with %d"), err); |
2061 OstTrace1( TRACE_NORMAL, CUSBSESSION_USBHOSTEVENT_DUP1, "CUsbSession::UsbHostEvent; detects outstanding request: request is compeleted with %d", err ); |
1979 } |
2062 } |
1980 else if (iHostEventObserverQueueEvents) |
2063 else if (iHostEventObserverQueueEvents) |
1981 { |
2064 { |
1982 // add dev info to head of queue |
2065 // add dev info to head of queue |
1983 iHostStateQueue[iHostEventQueueHead] = aDevInfo; |
2066 iHostStateQueue[iHostEventQueueHead] = aDevInfo; |
1984 iHostEventQueueHead = (iHostEventQueueHead + 1) % KDeviceStatesQueueSize; |
2067 iHostEventQueueHead = (iHostEventQueueHead + 1) % KDeviceStatesQueueSize; |
1985 LOGTEXT3(_L8("+++ CUsbSession::UsbHostEvent() addqueue (%d, %d)"), iHostEventQueueHead, |
2068 OstTraceExt2( TRACE_NORMAL, CUSBSESSION_USBHOSTEVENT_DUP2, "CUsbSession::UsbHostEvent; addqueue (%d, %d)", iHostEventQueueHead, iHostEventQueueTail ); |
1986 iHostEventQueueTail); |
|
1987 |
2069 |
1988 // UsbHostStateDequeueEvent() will read from queue when RegisterHostObserver() |
2070 // UsbHostStateDequeueEvent() will read from queue when RegisterHostObserver() |
1989 // is next called. |
2071 // is next called. |
1990 } |
2072 } |
|
2073 OstTraceFunctionExit0( CUSBSESSION_USBHOSTEVENT_EXIT ); |
1991 } |
2074 } |
1992 |
2075 |
1993 /** |
2076 /** |
1994 * Dequeues an event and completes the observer's request with it. |
2077 * Dequeues an event and completes the observer's request with it. |
1995 */ |
2078 */ |
1996 void CUsbSession::UsbMsgDequeue() |
2079 void CUsbSession::UsbMsgDequeue() |
1997 { |
2080 { |
1998 LOG_FUNC |
2081 OstTraceFunctionEntry0( CUSBSESSION_USBMSGDEQUEUE_ENTRY ); |
1999 |
2082 |
2000 // Work our way through the queue, until we reach the end |
2083 // Work our way through the queue, until we reach the end |
2001 // OR we find an event the current observer wants. |
2084 // OR we find an event the current observer wants. |
2002 if ((iMsgObserverOutstanding) && (iMsgQueueHead != iMsgQueueTail)) |
2085 if ((iMsgObserverOutstanding) && (iMsgQueueHead != iMsgQueueTail)) |
2003 { |
2086 { |
2007 iMsgQueueTail = (iMsgQueueTail + 1) % KOtgHostMessageQueueSize; |
2090 iMsgQueueTail = (iMsgQueueTail + 1) % KOtgHostMessageQueueSize; |
2008 |
2091 |
2009 TPckg<TUint32> pckg(newMsg); |
2092 TPckg<TUint32> pckg(newMsg); |
2010 iNotifiedMsg = newMsg; |
2093 iNotifiedMsg = newMsg; |
2011 |
2094 |
2012 LOGTEXT3(_L8(">>> dequeued event #%d (0x%x)"), iMsgQueueTail, newMsg); |
2095 OstTraceExt2( TRACE_NORMAL, CUSBSESSION_USBMSGDEQUEUE, "CUsbSession::UsbMsgDequeue;dequeued event #%d (0x%x)", iMsgQueueTail, newMsg ); |
2013 |
2096 |
2014 iMsgObserverOutstanding = EFalse; |
2097 iMsgObserverOutstanding = EFalse; |
2015 const TInt err = iMsgObserverMessage.Write(0, pckg); |
2098 const TInt err = iMsgObserverMessage.Write(0, pckg); |
2016 iMsgObserverMessage.Complete(err); |
2099 iMsgObserverMessage.Complete(err); |
2017 } |
2100 } |
|
2101 OstTraceFunctionExit0( CUSBSESSION_USBMSGDEQUEUE_EXIT ); |
2018 } |
2102 } |
2019 |
2103 |
2020 /** |
2104 /** |
2021 * Dequeues an event and completes the observer's request with it. |
2105 * Dequeues an event and completes the observer's request with it. |
2022 */ |
2106 */ |
2023 void CUsbSession::UsbHostEventDequeue() |
2107 void CUsbSession::UsbHostEventDequeue() |
2024 { |
2108 { |
2025 LOG_FUNC |
2109 OstTraceFunctionEntry0( CUSBSESSION_USBHOSTEVENTDEQUEUE_ENTRY ); |
2026 |
2110 |
2027 // Work our way through the queue, until we reach the end |
2111 // Work our way through the queue, until we reach the end |
2028 // OR we find an event the current observer wants. |
2112 // OR we find an event the current observer wants. |
2029 if ((iHostEventObserverOutstanding) && (iHostEventQueueHead != iHostEventQueueTail)) |
2113 if ((iHostEventObserverOutstanding) && (iHostEventQueueHead != iHostEventQueueTail)) |
2030 { |
2114 { |
2034 iNotifiedHostState = newDevInfo; |
2118 iNotifiedHostState = newDevInfo; |
2035 |
2119 |
2036 // advance tail towards the head |
2120 // advance tail towards the head |
2037 iHostEventQueueTail = (iHostEventQueueTail + 1) % KDeviceStatesQueueSize; |
2121 iHostEventQueueTail = (iHostEventQueueTail + 1) % KDeviceStatesQueueSize; |
2038 |
2122 |
2039 LOGTEXT3(_L8(">>> CUsbSession::UsbHostStateDequeueEvent() dequeued event #%d (0x%x)"), iHostEventQueueTail, newDevInfo.iEventType); |
2123 OstTraceExt2( TRACE_NORMAL, CUSBSESSION_USBHOSTEVENTDEQUEUE, "CUsbSession::UsbHostEventDequeue; dequeued event #%d (0x%x)", iHostEventQueueTail, newDevInfo.iEventType ); |
2040 |
2124 |
2041 TPckg<TDeviceEventInformation> info(newDevInfo); |
2125 TPckg<TDeviceEventInformation> info(newDevInfo); |
2042 iHostEventObserverOutstanding = EFalse; |
2126 iHostEventObserverOutstanding = EFalse; |
2043 const TInt err = iHostEventObserverMessage.Write(0, info); |
2127 const TInt err = iHostEventObserverMessage.Write(0, info); |
2044 iHostEventObserverMessage.Complete(err); |
2128 iHostEventObserverMessage.Complete(err); |
2045 |
2129 |
2046 LOGTEXT2(_L8("CUsbSession::UsbHostStateDequeueEvent() detects outstanding request: request is compeleted with %d"), err); |
2130 OstTrace1( TRACE_NORMAL, CUSBSESSION_USBHOSTEVENTDEQUEUE_DUP1, "CUsbSession::UsbHostStateDequeueEvent() detects outstanding request: request is compeleted with %d", err ); |
2047 } |
2131 } |
|
2132 OstTraceFunctionExit0( CUSBSESSION_USBHOSTEVENTDEQUEUE_EXIT ); |
2048 } |
2133 } |
2049 |
2134 |
2050 TInt CUsbSession::RequestSession() |
2135 TInt CUsbSession::RequestSession() |
2051 { |
2136 { |
2052 return DoRequestSession(); |
2137 return DoRequestSession(); |