usbengines/usbotgwatcher/src/cusbvbusobserver.cpp
branchRCL_3
changeset 20 a15c582fbf97
parent 13 7068aba64af5
child 21 ff9df6630274
--- a/usbengines/usbotgwatcher/src/cusbvbusobserver.cpp	Fri Feb 19 23:50:33 2010 +0200
+++ b/usbengines/usbotgwatcher/src/cusbvbusobserver.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 <usbotgdefs.h>
 
@@ -40,8 +39,7 @@
 //
 void CUsbVBusObserver::ConstructL()
     {
-
-        FLOG( _L( "[USBOTGWATCHER]\tCUsbVBusObserver::ConstructL" ) );
+    LOG_FUNC
 
     User::LeaveIfError(iVBus.Attach(KUidUsbManCategory,
             KUsbOtgVBusPoweredProperty));
@@ -54,8 +52,7 @@
 //
 CUsbVBusObserver* CUsbVBusObserver::NewL()
     {
-
-        FLOG( _L( "[USBOTGWATCHER]\tCUsbVBusObserver::NewL" ) );
+    LOG_FUNC
 
     CUsbVBusObserver* self = new (ELeave) CUsbVBusObserver();
     CleanupStack::PushL(self);
@@ -70,8 +67,7 @@
 //
 CUsbVBusObserver::~CUsbVBusObserver()
     {
-
-        FLOG( _L( "[USBOTGWATCHER]\tCUsbVBusObserver::~CUsbVBusObserver" ) );
+    LOG_FUNC
 
     Cancel();
 
@@ -88,20 +84,16 @@
 CUsbVBusObserver::TState CUsbVBusObserver::VBus() /* not const, because for some reason RProperty::Get is not const */
     {
 
-    FLOG( _L( "[USBOTGWATCHER]\tCUsbVBusObserver::VBus" ) );
-
     TInt val(0);
 
     TInt err = iVBus.Get(val);
 
     if (KErrNone != err)
         {
-        FLOG( _L( "[USBOTGWATCHER]\tCUsbVBusObserver::VBus CanNotGetVBusProperty" ) );
-        Panic(ECanNotGetVBusProperty);
+        LOG("CanNotGetVBusProperty" )
+        Panic( ECanNotGetVBusProperty);
         }
 
-    FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbVBusObserver::VBus = %d" ), val ));
-
     return (0 == val ? EVBusDown : EVBusUp);
     }
 
@@ -111,18 +103,18 @@
 //
 void CUsbVBusObserver::SubscribeL(MUsbVBusObserver& aObserver)
     {
-    FLOG( _L( "[USBOTGWATCHER]\tCUsbVBusObserver::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]\tCUsbVBusObserver::SubscribeL Observer already exists." ) );
-        Panic(EObserverAlreadyExists);
+        LOG( "Observer already exists" );
+        Panic( EObserverAlreadyExists);
         return;
         }
 
     iObservers.AppendL(&aObserver);
-    
+
     if (KFirst == iObservers.Count()) // first item
         {
         iVBus.Subscribe(iStatus);
@@ -136,18 +128,18 @@
 //
 void CUsbVBusObserver::UnsubscribeL(MUsbVBusObserver& aObserver)
     {
-    FLOG( _L( "[USBOTGWATCHER]\tCUsbVBusObserver::UnsubscribeL" ) );
-    
+    LOG_FUNC
+
     TInt i(iObservers.Find(&aObserver));
-    if(KErrNotFound == i)
+    if (KErrNotFound == i)
         {
-        FLOG( _L( "[USBOTGWATCHER]\tCUsbVBusObserver::UnsubscribeL Observer not found." ) );
-        Panic(ECanNotFindVBusObserver);
+        LOG("Observer not found" );
+        Panic( ECanNotFindVBusObserver);
         return;
         }
-    
+
     iObservers.Remove(i);
-    
+
     if (0 == iObservers.Count()) // no observers anymore
         {
         // cancel pending request, if any
@@ -161,17 +153,19 @@
 //
 void CUsbVBusObserver::RunL()
     {
-        FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbVBusObserver::RunL iStatus = %d" ), iStatus.Int()));
+    LOG_FUNC
+
+    LOG1( "iStatus = %d" , iStatus.Int());
 
-        // if error occured, tell to Observers
-        if(KErrNone != iStatus.Int()) 
+    // if error occured, tell to Observers
+    if (KErrNone != iStatus.Int())
+        {
+        for (TInt i(0); i < iObservers.Count(); ++i)
             {
-            for (TInt i(0); i < iObservers.Count(); ++i)
-                 {
-                 iObservers[i]->VBusObserverErrorL(iStatus.Int());
-                 }
-            return;
+            iObservers[i]->VBusObserverErrorL(iStatus.Int());
             }
+        return;
+        }
 
     // re-issue request first
     iVBus.Subscribe(iStatus);
@@ -185,7 +179,7 @@
         {
         case EVBusUp:
             {
-                FLOG(_L( "[USBOTGWATCHER]\tCUsbVBusObserver::RunL VBus UP"));
+            LOG("VBus UP");
 
             for (TInt i(0); i < iObservers.Count(); ++i)
                 {
@@ -197,7 +191,7 @@
 
         case EVBusDown:
             {
-                FLOG(_L( "[USBOTGWATCHER]\tCUsbVBusObserver::RunL VBus DOWN"));
+            LOG("VBus DOWN");
 
             for (TInt i(0); i < iObservers.Count(); ++i)
                 {
@@ -209,8 +203,8 @@
 
         default:
             {
-                FLOG(_L( "[USBOTGWATCHER]\tCUsbIdPinObserver::RunL WrongVBusState"));
-            Panic(EWrongVBusState);
+            LOG("WrongVBusState");
+            Panic( EWrongVBusState);
             }
         }
 
@@ -231,8 +225,9 @@
 //
 TInt CUsbVBusObserver::RunError(TInt aError)
     {
+    LOG_FUNC
 
-        FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbVBusObserver::RunError aError = %d" ), aError));
+    LOG1( "aError = %d" , aError);
 
     // try to continue	
     return KErrNone;