diff -r 3d9964be03bc -r 25c602fd1f26 usbmgmt/usbmgr/usbman/server/SRC/CUsbDevice.cpp --- a/usbmgmt/usbmgr/usbman/server/SRC/CUsbDevice.cpp Wed Sep 15 14:10:49 2010 +0300 +++ b/usbmgmt/usbmgr/usbman/server/SRC/CUsbDevice.cpp Wed Oct 13 16:35:28 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -31,6 +31,7 @@ #include #include "UsbUtils.h" #include +#include "musbdevicenotifyinternal.h" #ifdef USE_DUMMY_CLASS_CONTROLLER #include "CUsbDummyClassController.h" @@ -74,6 +75,7 @@ EUidArrayNotEmpty, }; +const TInt KUsbThermalInterfaceImplementationID = 0x10286a9c; CUsbDevice* CUsbDevice::NewL(CUsbServer& aUsbServer) /** @@ -117,6 +119,7 @@ // we don't want to call ResetAndDestroy, because we don't own // the observers themselves. iObservers.Reset(); + iThermalObservers.Reset(); #ifndef __WINS__ LOGTEXT2(_L8("about to delete device state watcher @ %08x"), (TUint32) iDeviceStateWatcher); @@ -260,9 +263,29 @@ LOGTEXT(_L8("<GetInterface(TUid::Uid(KUsbThermalInterfaceImplementationID)); + if(res != NULL) + { + LOGTEXT(_L8("<< UsbThermal Monitor plugin Found")); + MUsbThermalPluginInterface* tif = static_cast(res); + + // register ourself as an observer of thermal infor. + tif->RegisterThermalObserver(*this); + break; + } + } + } + void CUsbDevice::EnumerateClassControllersL() /** * Loads all USB class controllers at startup. @@ -353,7 +376,7 @@ } } -void CUsbDevice::RegisterObserverL(MUsbDeviceNotify& aObserver) +void CUsbDevice::RegisterObserverL(MUsbDeviceNotifyInternal& aObserver) /** * Register an observer of the device. * Presently, the device supports watching state. @@ -363,11 +386,11 @@ { LOG_FUNC - LEAVEIFERRORL(iObservers.Append(&aObserver)); + LEAVEIFERRORL(iThermalObservers.Append(&aObserver)); } -void CUsbDevice::DeRegisterObserver(MUsbDeviceNotify& aObserver) +void CUsbDevice::DeRegisterObserver(MUsbDeviceNotifyInternal& aObserver) /** * De-registers an existing device observer. * @@ -376,10 +399,10 @@ { LOG_FUNC - TInt index = iObservers.Find(&aObserver); + TInt index = iThermalObservers.Find(&aObserver); if (index >= 0) - iObservers.Remove(index); + iThermalObservers.Remove(index); } @@ -403,6 +426,9 @@ iLastError = KErrNone; StartCurrentClassController(); + + StartThermalMonitoring(); + } void CUsbDevice::Stop() @@ -434,11 +460,18 @@ // Change state straight away in case any of the clients check it TUsbServiceState oldState = iServiceState; iServiceState = aState; - TUint length = iObservers.Count(); + TUint length = iThermalObservers.Count(); for (TUint i = 0; i < length; i++) { - iObservers[i]->UsbServiceStateChange(LastError(), oldState, + iThermalObservers[i]->UsbServiceStateChange(LastError(), oldState, + iServiceState); + } + + length = iObservers.Count(); + for (TUint j = 0; j < length; j++) + { + iObservers[j]->UsbServiceStateChange(LastError(), oldState, iServiceState); } @@ -506,11 +539,17 @@ // Change state straight away in case any of the clients check it TUsbDeviceState oldState = iDeviceState; iDeviceState = state; - TUint length = iObservers.Count(); - + + TUint length = iThermalObservers.Count(); for (TUint i = 0; i < length; i++) { - iObservers[i]->UsbDeviceStateChange(LastError(), oldState, iDeviceState); + iThermalObservers[i]->UsbDeviceStateChange(LastError(), oldState, iDeviceState); + } + + length = iObservers.Count(); + for (TUint j = 0; j < length; j++) + { + iObservers[j]->UsbDeviceStateChange(LastError(), oldState, iDeviceState); } } } @@ -1078,7 +1117,10 @@ iLastError = KErrNone; StartCurrentClassController(); - } + + StartThermalMonitoring(); + + } TInt CUsbDevice::CurrentPersonalityId() const /** @@ -1551,5 +1593,25 @@ */ { LOGTEXT2(_L8("CUsbDevice::MuepoDoRegisterStateObserverL aObserver = 0x%08x"),&aObserver); - RegisterObserverL(aObserver); + + // Don't use RegisterObserverL() interface anymore, because + // aObserver is MUsbDeviceNotify + LEAVEIFERRORL(iObservers.Append(&aObserver)); } + +void CUsbDevice::UsbThermalStateChange(TInt aLastError, TInt aValue) + { + LOG_FUNC + + TUint length = iThermalObservers.Count(); + LOGTEXT2(_L8("CUsbDevice::UsbThermalStateChange found %d observers"),length); + if( length == 0) + { + return; + } + + for (TUint i = 0; i < length; i++) + { + iThermalObservers[i]->UsbThermalStateChange(aLastError, aValue); + } + }