usbmgmt/usbmgr/device/classdrivers/acm/classimplementation/ecacm/src/acmserver.cpp
branchRCL_3
changeset 16 012cc2ee6408
parent 15 f92a4f87e424
equal deleted inserted replaced
15:f92a4f87e424 16:012cc2ee6408
     1 /*
     1 /*
     2 * Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2007-2009 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".
    19 /**
    19 /**
    20  @file
    20  @file
    21  @internalComponent
    21  @internalComponent
    22 */
    22 */
    23 
    23 
       
    24 #include <usb/usblogger.h>
    24 #include "acmserver.h"
    25 #include "acmserver.h"
    25 #include "acmsession.h"
    26 #include "acmsession.h"
    26 #include "acmserversecuritypolicy.h"
    27 #include "acmserversecuritypolicy.h"
    27 #include "acmserverconsts.h"
    28 #include "acmserverconsts.h"
    28 #include "OstTraceDefinitions.h"
    29 
    29 #ifdef OST_TRACE_COMPILER_IN_USE
    30 #ifdef __FLOG_ACTIVE
    30 #include "acmserverTraces.h"
    31 _LIT8(KLogComponent, "ECACM");
    31 #endif
    32 #endif
    32 
       
    33 
    33 
    34 CAcmServer* CAcmServer::NewL(MAcmController& aAcmController)
    34 CAcmServer* CAcmServer::NewL(MAcmController& aAcmController)
    35 	{
    35 	{
    36 	OstTraceFunctionEntry0( CACMSERVER_NEWL_ENTRY );
    36 	LOG_STATIC_FUNC_ENTRY
    37 
    37 
    38 	CAcmServer* self = new(ELeave) CAcmServer(aAcmController);
    38 	CAcmServer* self = new(ELeave) CAcmServer(aAcmController);
    39 	CleanupStack::PushL(self);
    39 	CleanupStack::PushL(self);
    40 	TInt err = self->Start(KAcmServerName);
    40 	TInt err = self->Start(KAcmServerName);
    41 	// KErrAlreadyExists is a success case (c.f. transient server boilerplate
    41 	// KErrAlreadyExists is a success case (c.f. transient server boilerplate
    42 	// code).
    42 	// code).
    43 	if ( err != KErrAlreadyExists )
    43 	if ( err != KErrAlreadyExists )
    44 		{
    44 		{
    45 		if (err < 0)
    45 		LEAVEIFERRORL(err);
    46 			{
       
    47 			OstTrace1( TRACE_ERROR, CACMSERVER_NEWL, "CAcmServer::NewL;err=%d", err );
       
    48 			User::Leave(err);
       
    49 			}
       
    50 		}
    46 		}
    51 	CleanupStack::Pop(self);
    47 	CleanupStack::Pop(self);
    52 	OstTraceFunctionExit0( CACMSERVER_NEWL_EXIT );
       
    53 	return self;
    48 	return self;
    54 	}
    49 	}
    55 
    50 
    56 CAcmServer::~CAcmServer()
    51 CAcmServer::~CAcmServer()
    57 	{
    52 	{
    58 	OstTraceFunctionEntry0( CACMSERVER_CACMSERVER_DES_ENTRY );
    53 	LOG_FUNC
    59 	OstTraceFunctionExit0( CACMSERVER_CACMSERVER_DES_EXIT );
       
    60 	}
    54 	}
    61 
    55 
    62 CAcmServer::CAcmServer(MAcmController& aAcmController)
    56 CAcmServer::CAcmServer(MAcmController& aAcmController)
    63  :	CPolicyServer(CActive::EPriorityStandard, KAcmServerPolicy),
    57  :	CPolicyServer(CActive::EPriorityStandard, KAcmServerPolicy),
    64  	iAcmController(aAcmController)
    58  	iAcmController(aAcmController)
    65  	{
    59  	{
    66 	OstTraceFunctionEntry0( CACMSERVER_CACMSERVER_CONS_ENTRY );
       
    67 	OstTraceFunctionExit0( CACMSERVER_CACMSERVER_CONS_EXIT );
       
    68 	}
    60 	}
    69 
    61 
    70 CSession2* CAcmServer::NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const
    62 CSession2* CAcmServer::NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const
    71 	{
    63 	{
    72 	OstTraceFunctionEntry0( CACMSERVER_NEWSESSIONL_ENTRY );
    64 	LOG_FUNC
       
    65 
    73 	//Validate session as coming from UsbSvr
    66 	//Validate session as coming from UsbSvr
    74 	static _LIT_SECURITY_POLICY_S0(KSidPolicy, 0x101fe1db);
    67 	static _LIT_SECURITY_POLICY_S0(KSidPolicy, 0x101fe1db);
    75 	TBool auth = KSidPolicy.CheckPolicy(aMessage);
    68 	TBool auth = KSidPolicy.CheckPolicy(aMessage);
    76 	if(!auth)
    69 	if(!auth)
    77 		{
    70 		{
    78 		OstTrace1( TRACE_ERROR, CACMSERVER_NEWSESSIONL_DUP1, 
    71 		LEAVEIFERRORL(KErrPermissionDenied);
    79 							"CAcmServer::NewSessionL;KErrPermissionDenied=%d", 
       
    80 							KErrPermissionDenied );
       
    81 		User::Leave(KErrPermissionDenied);
       
    82 		}
    72 		}
    83 
    73 
    84 	// Version number check...
    74 	// Version number check...
    85 	TVersion v(	KAcmSrvMajorVersionNumber,
    75 	TVersion v(	KAcmSrvMajorVersionNumber,
    86 				KAcmSrvMinorVersionNumber,
    76 				KAcmSrvMinorVersionNumber,
    87 				KAcmSrvBuildNumber);
    77 				KAcmSrvBuildNumber);
    88 
    78 
    89 	if ( !User::QueryVersionSupported(v, aVersion) )
    79 	if ( !User::QueryVersionSupported(v, aVersion) )
    90 		{
    80 		{
    91 		OstTrace1( TRACE_ERROR, CACMSERVER_NEWSESSIONL_DUP2, 
    81 		LEAVEIFERRORL(KErrNotSupported);
    92 							"CAcmServer::NewSessionL;KErrNotSupported=%d", 
       
    93 							KErrNotSupported );
       
    94 		User::Leave(KErrNotSupported);
       
    95 		}
    82 		}
    96 
    83 
    97 	CAcmSession* sess = CAcmSession::NewL(iAcmController);
    84 	CAcmSession* sess = CAcmSession::NewL(iAcmController);
    98 	OstTraceExt1( TRACE_NORMAL, CACMSERVER_NEWSESSIONL, "CAcmServer::NewSessionL;sess=%p", sess );
    85 	LOGTEXT2(_L8("\tsess = 0x%08x"), sess);
    99 	OstTraceFunctionExit0( CACMSERVER_NEWSESSIONL_EXIT );
       
   100 	return sess;
    86 	return sess;
   101 	}
    87 	}