equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 1997-2010 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". |
29 #include "CUsbServer.h" |
29 #include "CUsbServer.h" |
30 #include <cusbclasscontrollerbase.h> |
30 #include <cusbclasscontrollerbase.h> |
31 #include <cusbclasscontrollerplugin.h> |
31 #include <cusbclasscontrollerplugin.h> |
32 #include "UsbUtils.h" |
32 #include "UsbUtils.h" |
33 #include <cusbmanextensionplugin.h> |
33 #include <cusbmanextensionplugin.h> |
|
34 #include "musbdevicenotifyinternal.h" |
34 |
35 |
35 #ifdef USE_DUMMY_CLASS_CONTROLLER |
36 #ifdef USE_DUMMY_CLASS_CONTROLLER |
36 #include "CUsbDummyClassController.h" |
37 #include "CUsbDummyClassController.h" |
37 #endif |
38 #endif |
38 |
39 |
72 EResourceFileNotFound, |
73 EResourceFileNotFound, |
73 /** ConvertUidsL called with an array that is not empty */ |
74 /** ConvertUidsL called with an array that is not empty */ |
74 EUidArrayNotEmpty, |
75 EUidArrayNotEmpty, |
75 }; |
76 }; |
76 |
77 |
|
78 const TInt KUsbThermalInterfaceImplementationID = 0x10286a9c; |
77 |
79 |
78 CUsbDevice* CUsbDevice::NewL(CUsbServer& aUsbServer) |
80 CUsbDevice* CUsbDevice::NewL(CUsbServer& aUsbServer) |
79 /** |
81 /** |
80 * Constructs a CUsbDevice object. |
82 * Constructs a CUsbDevice object. |
81 * |
83 * |
115 |
117 |
116 // Free any memory allocated to the list of observers. Note that |
118 // Free any memory allocated to the list of observers. Note that |
117 // we don't want to call ResetAndDestroy, because we don't own |
119 // we don't want to call ResetAndDestroy, because we don't own |
118 // the observers themselves. |
120 // the observers themselves. |
119 iObservers.Reset(); |
121 iObservers.Reset(); |
|
122 iThermalObservers.Reset(); |
120 |
123 |
121 #ifndef __WINS__ |
124 #ifndef __WINS__ |
122 LOGTEXT2(_L8("about to delete device state watcher @ %08x"), (TUint32) iDeviceStateWatcher); |
125 LOGTEXT2(_L8("about to delete device state watcher @ %08x"), (TUint32) iDeviceStateWatcher); |
123 delete iDeviceStateWatcher; |
126 delete iDeviceStateWatcher; |
124 LOGTEXT(_L8("deleted device state watcher")); |
127 LOGTEXT(_L8("deleted device state watcher")); |
258 CleanupStack::PopAndDestroy(&implementations); |
261 CleanupStack::PopAndDestroy(&implementations); |
259 |
262 |
260 LOGTEXT(_L8("<<CUsbDevice::InstantiateExtensionPluginsL")); |
263 LOGTEXT(_L8("<<CUsbDevice::InstantiateExtensionPluginsL")); |
261 } |
264 } |
262 |
265 |
263 |
266 void CUsbDevice::StartThermalMonitoring() |
264 |
267 { |
265 |
268 LOG_FUNC |
|
269 |
|
270 // Perform checking for usb thermal plugin to see |
|
271 // whether there is a implemetation that match the thermal plug-in req. |
|
272 for (TInt i=0; i<iExtensionPlugins.Count(); i++) |
|
273 { |
|
274 CUsbmanExtensionPlugin* plugin = iExtensionPlugins[i]; |
|
275 |
|
276 TAny* res = plugin->GetInterface(TUid::Uid(KUsbThermalInterfaceImplementationID)); |
|
277 if(res != NULL) |
|
278 { |
|
279 LOGTEXT(_L8("<< UsbThermal Monitor plugin Found")); |
|
280 MUsbThermalPluginInterface* tif = static_cast<MUsbThermalPluginInterface*>(res); |
|
281 |
|
282 // register ourself as an observer of thermal infor. |
|
283 tif->RegisterThermalObserver(*this); |
|
284 break; |
|
285 } |
|
286 } |
|
287 } |
|
288 |
266 void CUsbDevice::EnumerateClassControllersL() |
289 void CUsbDevice::EnumerateClassControllersL() |
267 /** |
290 /** |
268 * Loads all USB class controllers at startup. |
291 * Loads all USB class controllers at startup. |
269 * |
292 * |
270 */ |
293 */ |
351 delete aClassController; |
374 delete aClassController; |
352 LEAVEL(rc); |
375 LEAVEL(rc); |
353 } |
376 } |
354 } |
377 } |
355 |
378 |
356 void CUsbDevice::RegisterObserverL(MUsbDeviceNotify& aObserver) |
379 void CUsbDevice::RegisterObserverL(MUsbDeviceNotifyInternal& aObserver) |
357 /** |
380 /** |
358 * Register an observer of the device. |
381 * Register an observer of the device. |
359 * Presently, the device supports watching state. |
382 * Presently, the device supports watching state. |
360 * |
383 * |
361 * @param aObserver New Observer of the device |
384 * @param aObserver New Observer of the device |
362 */ |
385 */ |
363 { |
386 { |
364 LOG_FUNC |
387 LOG_FUNC |
365 |
388 |
366 LEAVEIFERRORL(iObservers.Append(&aObserver)); |
389 LEAVEIFERRORL(iThermalObservers.Append(&aObserver)); |
367 } |
390 } |
368 |
391 |
369 |
392 |
370 void CUsbDevice::DeRegisterObserver(MUsbDeviceNotify& aObserver) |
393 void CUsbDevice::DeRegisterObserver(MUsbDeviceNotifyInternal& aObserver) |
371 /** |
394 /** |
372 * De-registers an existing device observer. |
395 * De-registers an existing device observer. |
373 * |
396 * |
374 * @param aObserver The existing device observer to be de-registered |
397 * @param aObserver The existing device observer to be de-registered |
375 */ |
398 */ |
376 { |
399 { |
377 LOG_FUNC |
400 LOG_FUNC |
378 |
401 |
379 TInt index = iObservers.Find(&aObserver); |
402 TInt index = iThermalObservers.Find(&aObserver); |
380 |
403 |
381 if (index >= 0) |
404 if (index >= 0) |
382 iObservers.Remove(index); |
405 iThermalObservers.Remove(index); |
383 } |
406 } |
384 |
407 |
385 |
408 |
386 void CUsbDevice::StartL() |
409 void CUsbDevice::StartL() |
387 /** |
410 /** |
401 LEAVEL(err); |
424 LEAVEL(err); |
402 } |
425 } |
403 |
426 |
404 iLastError = KErrNone; |
427 iLastError = KErrNone; |
405 StartCurrentClassController(); |
428 StartCurrentClassController(); |
|
429 |
|
430 StartThermalMonitoring(); |
|
431 |
406 } |
432 } |
407 |
433 |
408 void CUsbDevice::Stop() |
434 void CUsbDevice::Stop() |
409 /** |
435 /** |
410 * Stop the USB device and all its associated USB classes. |
436 * Stop the USB device and all its associated USB classes. |
432 if (iServiceState != aState) |
458 if (iServiceState != aState) |
433 { |
459 { |
434 // Change state straight away in case any of the clients check it |
460 // Change state straight away in case any of the clients check it |
435 TUsbServiceState oldState = iServiceState; |
461 TUsbServiceState oldState = iServiceState; |
436 iServiceState = aState; |
462 iServiceState = aState; |
437 TUint length = iObservers.Count(); |
463 |
438 |
464 TUint length = iThermalObservers.Count(); |
439 for (TUint i = 0; i < length; i++) |
465 for (TUint i = 0; i < length; i++) |
440 { |
466 { |
441 iObservers[i]->UsbServiceStateChange(LastError(), oldState, |
467 iThermalObservers[i]->UsbServiceStateChange(LastError(), oldState, |
|
468 iServiceState); |
|
469 } |
|
470 |
|
471 length = iObservers.Count(); |
|
472 for (TUint j = 0; j < length; j++) |
|
473 { |
|
474 iObservers[j]->UsbServiceStateChange(LastError(), oldState, |
442 iServiceState); |
475 iServiceState); |
443 } |
476 } |
444 |
477 |
445 if (iServiceState == EUsbServiceIdle) |
478 if (iServiceState == EUsbServiceIdle) |
446 iUsbServer.LaunchShutdownTimerIfNoSessions(); |
479 iUsbServer.LaunchShutdownTimerIfNoSessions(); |
504 } |
537 } |
505 #endif // __WINS__ |
538 #endif // __WINS__ |
506 // Change state straight away in case any of the clients check it |
539 // Change state straight away in case any of the clients check it |
507 TUsbDeviceState oldState = iDeviceState; |
540 TUsbDeviceState oldState = iDeviceState; |
508 iDeviceState = state; |
541 iDeviceState = state; |
509 TUint length = iObservers.Count(); |
542 |
510 |
543 TUint length = iThermalObservers.Count(); |
511 for (TUint i = 0; i < length; i++) |
544 for (TUint i = 0; i < length; i++) |
512 { |
545 { |
513 iObservers[i]->UsbDeviceStateChange(LastError(), oldState, iDeviceState); |
546 iThermalObservers[i]->UsbDeviceStateChange(LastError(), oldState, iDeviceState); |
|
547 } |
|
548 |
|
549 length = iObservers.Count(); |
|
550 for (TUint j = 0; j < length; j++) |
|
551 { |
|
552 iObservers[j]->UsbDeviceStateChange(LastError(), oldState, iDeviceState); |
514 } |
553 } |
515 } |
554 } |
516 } |
555 } |
517 |
556 |
518 /** |
557 /** |
1076 LEAVEL(err); |
1115 LEAVEL(err); |
1077 } |
1116 } |
1078 |
1117 |
1079 iLastError = KErrNone; |
1118 iLastError = KErrNone; |
1080 StartCurrentClassController(); |
1119 StartCurrentClassController(); |
1081 } |
1120 |
|
1121 StartThermalMonitoring(); |
|
1122 |
|
1123 } |
1082 |
1124 |
1083 TInt CUsbDevice::CurrentPersonalityId() const |
1125 TInt CUsbDevice::CurrentPersonalityId() const |
1084 /** |
1126 /** |
1085 * @return the current personality id |
1127 * @return the current personality id |
1086 */ |
1128 */ |
1549 * |
1591 * |
1550 * @param aObserver New Observer of the device |
1592 * @param aObserver New Observer of the device |
1551 */ |
1593 */ |
1552 { |
1594 { |
1553 LOGTEXT2(_L8("CUsbDevice::MuepoDoRegisterStateObserverL aObserver = 0x%08x"),&aObserver); |
1595 LOGTEXT2(_L8("CUsbDevice::MuepoDoRegisterStateObserverL aObserver = 0x%08x"),&aObserver); |
1554 RegisterObserverL(aObserver); |
1596 |
1555 } |
1597 // Don't use RegisterObserverL() interface anymore, because |
|
1598 // aObserver is MUsbDeviceNotify |
|
1599 LEAVEIFERRORL(iObservers.Append(&aObserver)); |
|
1600 } |
|
1601 |
|
1602 void CUsbDevice::UsbThermalStateChange(TInt aLastError, TInt aValue) |
|
1603 { |
|
1604 LOG_FUNC |
|
1605 |
|
1606 TUint length = iThermalObservers.Count(); |
|
1607 LOGTEXT2(_L8("CUsbDevice::UsbThermalStateChange found %d observers"),length); |
|
1608 if( length == 0) |
|
1609 { |
|
1610 return; |
|
1611 } |
|
1612 |
|
1613 for (TUint i = 0; i < length; i++) |
|
1614 { |
|
1615 iThermalObservers[i]->UsbThermalStateChange(aLastError, aValue); |
|
1616 } |
|
1617 } |