usbmgmt/usbmgr/device/classdrivers/acm/classimplementation/ecacm/src/acmsession.cpp
branchRCL_3
changeset 15 f92a4f87e424
parent 0 c9bc50fca66e
child 16 012cc2ee6408
equal deleted inserted replaced
14:d3e8e7d462dd 15:f92a4f87e424
     1 /*
     1 /*
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2005-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".
    22 */
    22 */
    23 
    23 
    24 #include "acmserverconsts.h"
    24 #include "acmserverconsts.h"
    25 #include "acmsession.h"
    25 #include "acmsession.h"
    26 #include "AcmPortFactory.h"
    26 #include "AcmPortFactory.h"
    27 #include <usb/usblogger.h>
    27 #include "OstTraceDefinitions.h"
       
    28 #ifdef OST_TRACE_COMPILER_IN_USE
       
    29 #include "acmsessionTraces.h"
       
    30 #endif
    28 
    31 
    29 #ifdef __FLOG_ACTIVE
       
    30 _LIT8(KLogComponent, "ECACM");
       
    31 #endif
       
    32 
    32 
    33 CAcmSession* CAcmSession::NewL(MAcmController& aAcmController)
    33 CAcmSession* CAcmSession::NewL(MAcmController& aAcmController)
    34 	{
    34 	{
    35 	LOG_STATIC_FUNC_ENTRY
    35 	OstTraceFunctionEntry0( CACMSESSION_NEWL_ENTRY );
    36 
       
    37 	CAcmSession* self = new(ELeave) CAcmSession(aAcmController);
    36 	CAcmSession* self = new(ELeave) CAcmSession(aAcmController);
       
    37 	OstTraceFunctionExit0( CACMSESSION_NEWL_EXIT );
    38 	return self;
    38 	return self;
    39 	}
    39 	}
    40 
    40 
    41 CAcmSession::CAcmSession(MAcmController& aAcmController)
    41 CAcmSession::CAcmSession(MAcmController& aAcmController)
    42  :	iAcmController(aAcmController)
    42  :	iAcmController(aAcmController)
    43 	{
    43 	{
    44 	LOG_FUNC
    44 	OstTraceFunctionEntry0( CACMSESSION_CACMSESSION_CONS_ENTRY );
       
    45 	OstTraceFunctionExit0( CACMSESSION_CACMSESSION_CONS_EXIT );
    45 	}
    46 	}
    46 
    47 
    47 CAcmSession::~CAcmSession()
    48 CAcmSession::~CAcmSession()
    48 	{
    49 	{
    49 	LOG_FUNC
    50 	OstTraceFunctionEntry0( CACMSESSION_CACMSESSION_DES_ENTRY );	
       
    51 	OstTraceFunctionExit0( CACMSESSION_CACMSESSION_DES_EXIT );
    50 	}
    52 	}
    51 	
    53 	
    52 void CAcmSession::CreateFunctionsL(const RMessage2& aMessage)
    54 void CAcmSession::CreateFunctionsL(const RMessage2& aMessage)
    53 	{
    55 	{
    54 	LOG_FUNC
    56 	OstTraceFunctionEntry0( CACMSESSION_CREATEFUNCTIONSL_ENTRY );
    55 
       
    56 	RBuf acmControlIfcName, acmDataIfcName;
    57 	RBuf acmControlIfcName, acmDataIfcName;
    57 
       
    58 	TInt size = aMessage.GetDesLengthL(2);
    58 	TInt size = aMessage.GetDesLengthL(2);
    59 	acmControlIfcName.CreateL(size);
    59 	acmControlIfcName.CreateL(size);
    60 	acmControlIfcName.CleanupClosePushL();
    60 	acmControlIfcName.CleanupClosePushL();
    61 	aMessage.ReadL(2, acmControlIfcName);
    61 	aMessage.ReadL(2, acmControlIfcName);
    62 
    62 
    63 	size = aMessage.GetDesLengthL(3);
    63 	size = aMessage.GetDesLengthL(3);
    64 	acmDataIfcName.CreateL(size);
    64 	acmDataIfcName.CreateL(size);
    65 	acmDataIfcName.CleanupClosePushL();
    65 	acmDataIfcName.CleanupClosePushL();
    66 	aMessage.ReadL(3, acmDataIfcName);
    66 	aMessage.ReadL(3, acmDataIfcName);
    67 
    67 
    68 	LOGTEXT5(_L("\taNoAcms = %d, aProtocolNum = %d, Control Ifc Name = %S, Data Ifc Name = %S"),
    68 	OstTraceExt4( TRACE_DUMP, CACMSESSION_CREATEFUNCTIONSL, 
    69 			aMessage.Int0(), aMessage.Int1(), &acmControlIfcName, &acmDataIfcName);
    69 			"CAcmSession::CreateFunctionsL;\taNoAcms = %d, aProtocolNum = %d, "
       
    70 			"Control Ifc Name = %S, Data Ifc Name = %S", 
       
    71 			aMessage.Int0(), aMessage.Int1(), acmControlIfcName, acmDataIfcName );
       
    72 	
    70 
    73 
    71 	LEAVEIFERRORL(iAcmController.CreateFunctions(aMessage.Int0(), aMessage.Int1(), acmControlIfcName, acmDataIfcName));
    74 	TInt err = iAcmController.CreateFunctions(aMessage.Int0(), aMessage.Int1(), acmControlIfcName, acmDataIfcName);
       
    75 	if (err < 0)
       
    76 		{
       
    77 		OstTrace1( TRACE_NORMAL, CACMSESSION_CREATEFUNCTIONSL_DUP1, "CAcmSession::CreateFunctionsL;err=%d", err );
       
    78 		User::Leave(err);
       
    79 		}
    72 
    80 
    73 	CleanupStack::PopAndDestroy(2);
    81 	CleanupStack::PopAndDestroy(2);
       
    82 	OstTraceFunctionExit0( CACMSESSION_CREATEFUNCTIONSL_EXIT );
    74 	}
    83 	}
    75 
    84 
    76 void CAcmSession::ServiceL(const RMessage2& aMessage)
    85 void CAcmSession::ServiceL(const RMessage2& aMessage)
    77 	{
    86 	{
    78 	LOG_FUNC
    87 	OstTraceFunctionEntry0( CACMSESSION_SERVICEL_ENTRY );
    79 	LOGTEXT2(_L8("\taMessage.Function() = %d"), aMessage.Function());
    88 	OstTrace1( TRACE_NORMAL, CACMSESSION_SERVICEL, "CAcmSession::ServiceL;aMessage.Function()=%d", aMessage.Function() );
    80 
       
    81 	switch ( aMessage.Function() )
    89 	switch ( aMessage.Function() )
    82 		{
    90 		{
    83 	case EAcmCreateAcmFunctions:
    91 	case EAcmCreateAcmFunctions:
    84 		{
    92 		{
    85 		TRAPD (err, CreateFunctionsL(aMessage));
    93 		TRAPD (err, CreateFunctionsL(aMessage));
    97 	default:
   105 	default:
    98 		// Unknown function, panic the user
   106 		// Unknown function, panic the user
    99 		aMessage.Panic(KAcmSrvPanic, EAcmBadAcmMessage);
   107 		aMessage.Panic(KAcmSrvPanic, EAcmBadAcmMessage);
   100 		break;
   108 		break;
   101 		}
   109 		}
       
   110 	OstTraceFunctionExit0( CACMSESSION_SERVICEL_EXIT );
   102 	}
   111 	}