usbmgmt/usbmgr/device/classdrivers/acm/classimplementation/ecacm/src/acmsession.cpp
changeset 0 c9bc50fca66e
child 15 f92a4f87e424
equal deleted inserted replaced
-1:000000000000 0:c9bc50fca66e
       
     1 /*
       
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 * ACM session.
       
    16 *
       
    17 */
       
    18 
       
    19 /**
       
    20  @file
       
    21  @internalComponent
       
    22 */
       
    23 
       
    24 #include "acmserverconsts.h"
       
    25 #include "acmsession.h"
       
    26 #include "AcmPortFactory.h"
       
    27 #include <usb/usblogger.h>
       
    28 
       
    29 #ifdef __FLOG_ACTIVE
       
    30 _LIT8(KLogComponent, "ECACM");
       
    31 #endif
       
    32 
       
    33 CAcmSession* CAcmSession::NewL(MAcmController& aAcmController)
       
    34 	{
       
    35 	LOG_STATIC_FUNC_ENTRY
       
    36 
       
    37 	CAcmSession* self = new(ELeave) CAcmSession(aAcmController);
       
    38 	return self;
       
    39 	}
       
    40 
       
    41 CAcmSession::CAcmSession(MAcmController& aAcmController)
       
    42  :	iAcmController(aAcmController)
       
    43 	{
       
    44 	LOG_FUNC
       
    45 	}
       
    46 
       
    47 CAcmSession::~CAcmSession()
       
    48 	{
       
    49 	LOG_FUNC
       
    50 	}
       
    51 	
       
    52 void CAcmSession::CreateFunctionsL(const RMessage2& aMessage)
       
    53 	{
       
    54 	LOG_FUNC
       
    55 
       
    56 	RBuf acmControlIfcName, acmDataIfcName;
       
    57 
       
    58 	TInt size = aMessage.GetDesLengthL(2);
       
    59 	acmControlIfcName.CreateL(size);
       
    60 	acmControlIfcName.CleanupClosePushL();
       
    61 	aMessage.ReadL(2, acmControlIfcName);
       
    62 
       
    63 	size = aMessage.GetDesLengthL(3);
       
    64 	acmDataIfcName.CreateL(size);
       
    65 	acmDataIfcName.CleanupClosePushL();
       
    66 	aMessage.ReadL(3, acmDataIfcName);
       
    67 
       
    68 	LOGTEXT5(_L("\taNoAcms = %d, aProtocolNum = %d, Control Ifc Name = %S, Data Ifc Name = %S"),
       
    69 			aMessage.Int0(), aMessage.Int1(), &acmControlIfcName, &acmDataIfcName);
       
    70 
       
    71 	LEAVEIFERRORL(iAcmController.CreateFunctions(aMessage.Int0(), aMessage.Int1(), acmControlIfcName, acmDataIfcName));
       
    72 
       
    73 	CleanupStack::PopAndDestroy(2);
       
    74 	}
       
    75 
       
    76 void CAcmSession::ServiceL(const RMessage2& aMessage)
       
    77 	{
       
    78 	LOG_FUNC
       
    79 	LOGTEXT2(_L8("\taMessage.Function() = %d"), aMessage.Function());
       
    80 
       
    81 	switch ( aMessage.Function() )
       
    82 		{
       
    83 	case EAcmCreateAcmFunctions:
       
    84 		{
       
    85 		TRAPD (err, CreateFunctionsL(aMessage));
       
    86 		aMessage.Complete(err);
       
    87 		break;
       
    88 		}
       
    89 
       
    90 	case EAcmDestroyAcmFunctions:
       
    91 		{
       
    92 		iAcmController.DestroyFunctions(aMessage.Int0());
       
    93 		aMessage.Complete(KErrNone);
       
    94 		break;
       
    95 		}
       
    96 		
       
    97 	default:
       
    98 		// Unknown function, panic the user
       
    99 		aMessage.Panic(KAcmSrvPanic, EAcmBadAcmMessage);
       
   100 		break;
       
   101 		}
       
   102 	}