diff -r 7068aba64af5 -r a15c582fbf97 usbengines/usbotgwatcher/src/cusbotgstateobserver.cpp --- a/usbengines/usbotgwatcher/src/cusbotgstateobserver.cpp Fri Feb 19 23:50:33 2010 +0200 +++ b/usbengines/usbotgwatcher/src/cusbotgstateobserver.cpp Fri Mar 12 15:48:40 2010 +0200 @@ -1,20 +1,19 @@ /* -* Copyright (c) 2008-2009 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" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Implementation + * Copyright (c) 2008-2009 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" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Implementation + * + */ #include "cusbotgstateobserver.h" @@ -38,8 +37,7 @@ // void CUsbOtgStateObserver::ConstructL() { - - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgStateObserver::ConstructL" ) ); + LOG_FUNC User::LeaveIfError(iOtgState.Attach(KUidUsbManCategory, KUsbOtgStateProperty)); @@ -52,8 +50,7 @@ // CUsbOtgStateObserver* CUsbOtgStateObserver::NewL() { - - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgStateObserver::NewL" ) ); + LOG_FUNC CUsbOtgStateObserver* self = new (ELeave) CUsbOtgStateObserver(); CleanupStack::PushL(self); @@ -68,8 +65,7 @@ // CUsbOtgStateObserver::~CUsbOtgStateObserver() { - - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgStateObserver::~CUsbOtgStateObserver" ) ); + LOG_FUNC Cancel(); @@ -85,21 +81,16 @@ // TUsbOtgState CUsbOtgStateObserver::OtgState() { - - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgStateObserver::OtgState" ) ); - TInt val(0); TInt err = iOtgState.Get(val); if (KErrNone != err) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgStateObserver::StOtgState CanNotGetOtgStateProperty" ) ); - Panic(ECanNotGetOtgStateProperty); + LOG("CanNotGetOtgStateProperty" ); + Panic( ECanNotGetOtgStateProperty); } - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbOtgStateObserver::OtgState = %d" ), val )); - return (TUsbOtgState) val; } @@ -110,12 +101,13 @@ // void CUsbOtgStateObserver::SubscribeL(MUsbOtgStateObserver& aObserver) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOTGStateObserver::SubscribeL" ) ); + LOG_FUNC + // check if the same observer already exist in a list - if(KErrNotFound != iObservers.Find(&aObserver)) + if (KErrNotFound != iObservers.Find(&aObserver)) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbIdPinObserver::SubscribeL Observer already exists." ) ); - Panic(EObserverAlreadyExists); + LOG( "Observer already exists" ); + Panic( EObserverAlreadyExists); return; } iObservers.AppendL(&aObserver); @@ -134,18 +126,18 @@ // void CUsbOtgStateObserver::UnsubscribeL(MUsbOtgStateObserver& aObserver) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgStateObserver::UnsubscribeL" ) ); - + LOG_FUNC + TInt i(iObservers.Find(&aObserver)); - if(KErrNotFound == i) + if (KErrNotFound == i) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbIdPinObserver::UnsubscribeL Observer not found." ) ); - Panic(ECanNotFindOtgStateObserver); + LOG("Observer not found"); + Panic( ECanNotFindOtgStateObserver); return; } - + iObservers.Remove(i); - + if (0 == iObservers.Count()) // no observers anymore { // cancel pending request @@ -159,18 +151,20 @@ // void CUsbOtgStateObserver::RunL() { - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbOtgStateObserver::RunL iStatus = %d" ), iStatus.Int())); + LOG_FUNC + + LOG1( "iStatus = %d" , iStatus.Int()); // if error occured, tell to Observers - if(KErrNone != iStatus.Int()) + if (KErrNone != iStatus.Int()) { for (TInt i(0); i < iObservers.Count(); ++i) - { - iObservers[i]->OtgStateErrorL(iStatus.Int()); - } + { + iObservers[i]->OtgStateErrorL(iStatus.Int()); + } return; } - + // re-issue request first iOtgState.Subscribe(iStatus); SetActive(); @@ -182,12 +176,12 @@ { case EUsbOtgStateReset: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOTGStateObserver::RunL OTGState == RESET" ) ); + LOG("OTGState == RESET" ); break; } case EUsbOtgStateAIdle: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOTGStateObserver::RunL OTGState == AIdle" ) ); + LOG("OTGState == AIdle" ); for (TInt i(0); i < iObservers.Count(); ++i) { iObservers[i]->AIdleL(); @@ -196,7 +190,7 @@ } case EUsbOtgStateAHost: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOTGStateObserver::RunL OTGState == AHost" ) ); + LOG( "OTGState == AHost"); for (TInt i(0); i < iObservers.Count(); ++i) { iObservers[i]->AHostL(); @@ -205,7 +199,7 @@ } case EUsbOtgStateAPeripheral: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOTGStateObserver::RunL OTGState == APeripheral" ) ); + LOG("OTGState == APeripheral" ); for (TInt i(0); i < iObservers.Count(); ++i) { iObservers[i]->APeripheralL(); @@ -214,7 +208,7 @@ } case EUsbOtgStateAVbusError: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOTGStateObserver::RunL OTGState == AVBusError" ) ); + LOG("OTGState == AVBusError" ); for (TInt i(0); i < iObservers.Count(); ++i) { iObservers[i]->AVBusErrorL(); @@ -223,7 +217,7 @@ } case EUsbOtgStateBIdle: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOTGStateObserver::RunL OTGState == BIdle" ) ); + LOG( "OTGState == BIdle" ); for (TInt i(0); i < iObservers.Count(); ++i) { iObservers[i]->BIdleL(); @@ -232,7 +226,7 @@ } case EUsbOtgStateBPeripheral: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOTGStateObserver::RunL OTGState == BPeripheral" ) ); + LOG("OTGState == BPeripheral" ); for (TInt i(0); i < iObservers.Count(); ++i) { iObservers[i]->BPeripheralL(); @@ -241,7 +235,7 @@ } case EUsbOtgStateBHost: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOTGStateObserver::RunL OTGState == BHost" ) ); + LOG("OTGState == BHost" ); for (TInt i(0); i < iObservers.Count(); ++i) { iObservers[i]->BHostL(); @@ -250,8 +244,8 @@ } default: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOTGStateObserver::RunL WrongOtgState" ) ); - Panic(EWrongOtgState); + LOG("WrongOtgState" ); + Panic( EWrongOtgState); } } @@ -272,8 +266,9 @@ // TInt CUsbOtgStateObserver::RunError(TInt aError) { + LOG_FUNC - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbOtgStateObserver::RunError aError = %d" ), aError)); + LOG1( "aError = %d" , aError); // try to continue return KErrNone;