usbmgmt/usbmgrtest/t_usbmanager_suite/Stub3CC/src/Stub3CC.cpp
branchRCL_3
changeset 16 012cc2ee6408
parent 15 f92a4f87e424
--- a/usbmgmt/usbmgrtest/t_usbmanager_suite/Stub3CC/src/Stub3CC.cpp	Tue Aug 31 17:01:47 2010 +0300
+++ b/usbmgmt/usbmgrtest/t_usbmanager_suite/Stub3CC/src/Stub3CC.cpp	Wed Sep 01 12:35:00 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 1997-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"
@@ -22,10 +22,11 @@
  @file
 */
 
+#include "Stub3CC.h"
 #include <usb_std.h>
 #include <es_ini.h>
 #include <d32usbc.h>
-#include "Stub3CC.h"
+#include <usb/usblogger.h>
 
 #ifdef __FLOG_ACTIVE
 _LIT8(KLogComponent, "STUB3CC");
@@ -33,11 +34,6 @@
 
 
 #include "usbmaninternalconstants.h"
-#include "OstTraceDefinitions.h"
-#ifdef OST_TRACE_COMPILER_IN_USE
-#include "Stub3CCTraces.h"
-#endif
-
  
 
 // Panic category 
@@ -166,22 +162,20 @@
  */
 void CUsbstub3ClassController::Start(TRequestStatus& aStatus)
 	{
-    OstTraceFunctionEntry0( CUSBSTUB3CLASSCONTROLLER_START_ENTRY );
-    
+	LOG_FUNC
+
 	aStatus = KRequestPending;
 	iReportStatus = &aStatus;
 	//If we are already started then just complete the request.
 	if (iState == EUsbServiceStarted)
 		{
 		User::RequestComplete(iReportStatus, KErrNone);
-		OstTraceFunctionExit0( CUSBSTUB3CLASSCONTROLLER_START_EXIT );
 		return;
 		}
 
 	if (iFailToStart)
 		{
 		User::RequestComplete(iReportStatus, KErrGeneral);
-		OstTraceFunctionExit0( CUSBSTUB3CLASSCONTROLLER_START_EXIT_DUP1 );
 		return;
 		}
 	
@@ -189,18 +183,14 @@
 	
 #ifndef __WINS__	
 	TInt ret = iLdd.Open(0);
-	OstTrace1( TRACE_NORMAL, CUSBSTUB3CLASSCONTROLLER_START, _L8("Open LDD, ret=%d"), ret );
-	
+	LOGTEXT2(_L8("Open LDD, ret=%d"), ret);
 	ret = SetUpInterface();
-	OstTrace1( TRACE_NORMAL, CUSBSTUB3CLASSCONTROLLER_START_DUP1, 
-	        _L8("SetUpInterface(), ret=%d"), ret );
-	
+	LOGTEXT2(_L8("SetUpInterface(), ret=%d"), ret);
 #endif	
 
 
 	iTimer.After(iStatus, iStartDelay*1000);  //convert from usec to msec
 	SetActive();
-	OstTraceFunctionExit0( CUSBSTUB3CLASSCONTROLLER_START_EXIT_DUP2 );
 	}
 
 /**
@@ -210,22 +200,20 @@
  */
 void CUsbstub3ClassController::Stop(TRequestStatus& aStatus)
 	{
-	OstTraceFunctionEntry0( CUSBSTUB3CLASSCONTROLLER_STOP_ENTRY );
-	
+	LOG_FUNC
+
 	aStatus = KRequestPending;
 	iReportStatus = &aStatus;
 	//If we are already idle then just complete the request.
 	if (iState == EUsbServiceIdle)
 		{
 		User::RequestComplete(iReportStatus, KErrNone);
-		OstTraceFunctionExit0( CUSBSTUB3CLASSCONTROLLER_STOP_EXIT );
 		return;
 		}
 
 	if (iFailToStop)
 		{
 		User::RequestComplete(iReportStatus, KErrGeneral);
-		OstTraceFunctionExit0( CUSBSTUB3CLASSCONTROLLER_STOP_EXIT_DUP1 );
 		return;
 		}
 
@@ -238,7 +226,6 @@
 	
 	iTimer.After(iStatus, iStopDelay*1000);  //convert from usec to msec
 	SetActive();
-	OstTraceFunctionExit0( CUSBSTUB3CLASSCONTROLLER_STOP_EXIT_DUP2 );
 	}
 
 /**
@@ -248,12 +235,10 @@
  */
 void CUsbstub3ClassController::GetDescriptorInfo(TUsbDescriptor& aDescriptorInfo) const
 	{
-    OstTraceFunctionEntry0( CUSBSTUB3CLASSCONTROLLER_GETDESCRIPTORINFO_ENTRY );
-    
+	LOG_FUNC
+
 	aDescriptorInfo.iLength = Kstub3DescriptorLength;
 	aDescriptorInfo.iNumInterfaces = Kstub3NumberOfInterfacesPerstub3Function;
-	
-	OstTraceFunctionExit0( CUSBSTUB3CLASSCONTROLLER_GETDESCRIPTORINFO_EXIT );
 	}
 
 
@@ -262,14 +247,9 @@
  */
 void CUsbstub3ClassController::RunL()
 	{
-    OstTraceFunctionEntry0( CUSBSTUB3CLASSCONTROLLER_RUNL_ENTRY );
-    
-    if(iStatus != KErrNone)
-        {
-            OstTrace1( TRACE_FATAL, CUSBSTUB3CLASSCONTROLLER_RUNL, 
-                    "CUsbstub3ClassController::RunL panic with error %d", EPanicUnexpectedStatus );
-            __ASSERT_DEBUG(EFalse,User::Panic(Kstub3CcPanicCategory,EPanicUnexpectedStatus));
-        }
+	LOG_FUNC
+
+	__ASSERT_DEBUG( iStatus == KErrNone, _USB_PANIC(Kstub3CcPanicCategory, EPanicUnexpectedStatus) );
 	switch (iState)
 		{
 		case EUsbServiceStarting:
@@ -279,13 +259,10 @@
 			iState = EUsbServiceIdle;
 			break;
 		default:	
-		    OstTrace1( TRACE_FATAL, CUSBSTUB3CLASSCONTROLLER_RUNL_DUP1, 
-		             "CUsbstub3ClassController::RunL panic with error %d", EPanicUnexpectedStatus );
-		    User::Panic(Kstub3CcPanicCategory,EPanicUnexpectedStatus);
+			_USB_PANIC(Kstub3CcPanicCategory, EPanicUnexpectedState);
 		}
 	*iReportStatus = KErrNone;	
 	User::RequestComplete(iReportStatus, iStatus.Int());	
-	OstTraceFunctionExit0( CUSBSTUB3CLASSCONTROLLER_RUNL_EXIT );
 	}
 
 /**
@@ -307,10 +284,8 @@
 		case EUsbServiceStopping:
 			iState = EUsbServiceStarted;
 			break;
-		default:
-		    OstTrace1( TRACE_FATAL, CUSBSTUB3CLASSCONTROLLER_DOCANCEL, 
-		            "CUsbstub3ClassController::DoCancel panic with error %d", EPanicUnexpectedStatus );
-		    User::Panic(Kstub3CcPanicCategory,EPanicUnexpectedStatus);
+		default:	
+			_USB_PANIC(Kstub3CcPanicCategory, EPanicUnexpectedState);
 	}
 	*iReportStatus = KErrNone;		
 	User::RequestComplete(iReportStatus, KErrCancel);	
@@ -325,9 +300,7 @@
  */
 TInt CUsbstub3ClassController::RunError(TInt /*aError*/)
 	{
-    OstTrace1( TRACE_FATAL, CUSBSTUB3CLASSCONTROLLER_RUNERROR, 
-             "CUsbstub3ClassController::RunError panic with error %d", EUnusedFunction );
-    __ASSERT_DEBUG(EFalse,User::Panic(Kstub3CcPanicCategory,EUnusedFunction));
+	__ASSERT_DEBUG( EFalse, _USB_PANIC(Kstub3CcPanicCategory, EUnusedFunction) );
 	return KErrNone;
 	}
 
@@ -337,34 +310,25 @@
  * endpoint and, if found, configuring the interface.
  */
 	{
-    OstTraceFunctionEntry0( CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_ENTRY );
-    
+	LOG_FUNC
+
 	TUsbDeviceCaps dCaps;
 	TInt ret = iLdd.DeviceCaps(dCaps);
-	OstTrace0( TRACE_NORMAL, CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE,
-	        _L8("\tchecking result of DeviceCaps"));
-	
+	LOGTEXT(_L8("\tchecking result of DeviceCaps"));
 	if ( ret )
 		{
-        OstTrace1( TRACE_ERROR, CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_DUP1, 
-                _L8("<<CCdcControlInterface::SetUpInterface ret=%d"), ret );
-        
-		OstTraceFunctionExit0( CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_EXIT );
+		LOGTEXT2(_L8("<<CCdcControlInterface::SetUpInterface ret=%d"), ret);
 		return ret;
 		}
 
 	const TUint KRequiredNumberOfEndpoints = 1; // in addition to endpoint 0.
 
 	const TUint totalEndpoints = static_cast<TUint>(dCaps().iTotalEndpoints);
-	OstTrace1( TRACE_NORMAL, CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_DUP2, 
-	        _L8("\tiTotalEndpoints = %d"), totalEndpoints );
-	
+	LOGTEXT2(_L8("\tiTotalEndpoints = %d"), totalEndpoints);
 	if ( totalEndpoints < KRequiredNumberOfEndpoints )
 		{
-        OstTrace1( TRACE_ERROR, CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_DUP3, 
-                _L8("<<CCdcControlInterface::SetUpInterface ret=%d"), KErrGeneral );
-        
-		OstTraceFunctionExit0( CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_EXIT_DUP1 );
+		LOGTEXT2(_L8("<<CCdcControlInterface::SetUpInterface ret=%d"), 
+			KErrGeneral);
 		return KErrGeneral;
 		}
 	
@@ -372,15 +336,10 @@
 	TUsbcEndpointData data[KUsbcMaxEndpoints];
 	TPtr8 dataptr(reinterpret_cast<TUint8*>(data), sizeof(data), sizeof(data));
 	ret = iLdd.EndpointCaps(dataptr);
-	OstTrace0( TRACE_NORMAL, CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_DUP4,
-	        _L8("\tchecking result of EndpointCaps"));
-	
+	LOGTEXT(_L8("\tchecking result of EndpointCaps"));
 	if ( ret )
 		{
-        OstTrace1( TRACE_ERROR, CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_DUP5, 
-                _L8("<<CCdcControlInterface::SetUpInterface ret=%d"), ret );
-        
-		OstTraceFunctionExit0( CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_EXIT_DUP2 );
+		LOGTEXT2(_L8("<<CCdcControlInterface::SetUpInterface ret=%d"), ret);
 		return ret;
 		}
 
@@ -390,13 +349,7 @@
 	for ( TUint i = 0 ; i < totalEndpoints ; i++ )
 		{
 		const TUsbcEndpointCaps* caps = &data[i].iCaps;
-		if(!caps)
-		    {
-                OstTrace1( TRACE_FATAL, CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_DUP6, 
-                        "CUsbstub3ClassController::SetUpInterface panic with error %d", 
-                        EPanicUnexpectedStatus );
-                __ASSERT_DEBUG(EFalse,User::Panic(Kstub3CcPanicCategory,EPanicUnexpectedStatus));
-		    }
+		__ASSERT_DEBUG(caps,_USB_PANIC(Kstub3CcPanicCategory, EPanicUnexpectedStatus));
 
 		if (data[i].iInUse)
 			{
@@ -422,14 +375,11 @@
 			break;
 			}
 		}
-	OstTrace0( TRACE_NORMAL, CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_DUP7, _L8("\tchecking epFound"));
-	
+	LOGTEXT(_L8("\tchecking epFound"));
 	if ( !epFound )
 		{
-        OstTrace1( TRACE_ERROR, CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_DUP8, 
-                _L8("<<CCdcControlInterface::SetUpInterface ret=%d"), KErrGeneral);
-        
-		OstTraceFunctionExit0( CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_EXIT_DUP3 );
+		LOGTEXT2(_L8("<<CCdcControlInterface::SetUpInterface ret=%d"), 
+			KErrGeneral);
 		return KErrGeneral;
 		}
 
@@ -441,16 +391,11 @@
 	ifc().iClass.iSubClassNum = 0x02; // Table 16- Abstract Control Model
 	ifc().iClass.iProtocolNum = 0x01; // Table 17- Hayes compatible
 
-	OstTrace0( TRACE_NORMAL, CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_DUP9,
-	        _L8("\tabout to call SetInterface"));
-	
+	LOGTEXT(_L8("\tabout to call SetInterface"));
 	// Zero effectively indicates that alternate interfaces are not used.
 	ret = iLdd.SetInterface(0, ifc);
 
-	OstTrace1( TRACE_NORMAL, CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_DUP10, 
-	        _L8("<<CCdcControlInterface::SetUpInterface ret=%d"), ret );
-	
-	OstTraceFunctionExit0( CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_EXIT_DUP4 );
+	LOGTEXT2(_L8("<<CCdcControlInterface::SetUpInterface ret=%d"), ret);
 	return ret;
 	}