usbmgmt/usbmgr/device/classdrivers/acm/classimplementation/acmserver/src/acmserverimpl.cpp
branchRCL_3
changeset 43 012cc2ee6408
parent 42 f92a4f87e424
equal deleted inserted replaced
42:f92a4f87e424 43:012cc2ee6408
     1 /*
     1 /*
     2 * Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2005-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".
    18 /**
    18 /**
    19  @file
    19  @file
    20 */
    20 */
    21 
    21 
    22 #include <e32base.h>
    22 #include <e32base.h>
       
    23 #include "acmserverimpl.h"
       
    24 #include <usb/usblogger.h>
    23 #include <acminterface.h>
    25 #include <acminterface.h>
    24 #include "acmserverimpl.h"
    26 
    25 #include "OstTraceDefinitions.h"
    27 #ifdef __FLOG_ACTIVE
    26 #ifdef OST_TRACE_COMPILER_IN_USE
    28 _LIT8(KLogComponent, "ACMSVRCLI");
    27 #include "acmserverimplTraces.h"
       
    28 #endif
    29 #endif
    29 
    30 
    30 /** Constructor */
    31 /** Constructor */
    31 CAcmServerImpl::CAcmServerImpl() 
    32 CAcmServerImpl::CAcmServerImpl() 
    32 	{
    33 	{
    33 	OstTraceFunctionEntry0( CACMSERVERIMPL_CACMSERVERIMPL_CONS_ENTRY );
    34 	LOG_FUNC
    34 	
       
    35 	OstTraceFunctionExit0( CACMSERVERIMPL_CACMSERVERIMPL_CONS_EXIT );
       
    36 	}
    35 	}
    37 	   
    36 	   
    38 /** Destructor */
    37 /** Destructor */
    39 CAcmServerImpl::~CAcmServerImpl()
    38 CAcmServerImpl::~CAcmServerImpl()
    40 	{
    39 	{
    41 	OstTraceFunctionEntry0( CACMSERVERIMPL_CACMSERVERIMPL_DES_ENTRY);
    40 	LOG_FUNC
    42 	
    41 
    43 	iCommServ.Close();
    42 	iCommServ.Close();
    44 	iAcmServerClient.Close();
    43 	iAcmServerClient.Close();
    45 	OstTraceFunctionExit0( CACMSERVERIMPL_CACMSERVERIMPL_ENTRY_DES_EXIT );
       
    46 	}
    44 	}
    47 
    45 
    48 /**
    46 /**
    49 2-phase construction.
    47 2-phase construction.
    50 @return Ownership of a new CAcmServerImpl.
    48 @return Ownership of a new CAcmServerImpl.
    51 */
    49 */
    52 CAcmServerImpl* CAcmServerImpl::NewL()
    50 CAcmServerImpl* CAcmServerImpl::NewL()
    53 	{
    51 	{
    54 	OstTraceFunctionEntry0( CACMSERVERIMPL_NEWL_ENTRY );
    52 	LOG_STATIC_FUNC_ENTRY
    55 	
    53 
    56 	CAcmServerImpl* self = new(ELeave) CAcmServerImpl;
    54 	CAcmServerImpl* self = new(ELeave) CAcmServerImpl;
    57 	CleanupStack::PushL(self);
    55 	CleanupStack::PushL(self);
    58 	self->ConstructL();
    56 	self->ConstructL();
    59 	CleanupStack::Pop(self);
    57 	CleanupStack::Pop(self);
    60 	OstTraceFunctionExit0( CACMSERVERIMPL_NEWL_EXIT );
       
    61 	return self;
    58 	return self;
    62 	}
    59 	}
    63 
    60 
    64 void CAcmServerImpl::ConstructL()
    61 void CAcmServerImpl::ConstructL()
    65 	{
    62 	{
    66 	OstTraceFunctionEntry0( CACMSERVERIMPL_CONSTRUCTL_ENTRY );
    63 	LOG_FUNC
    67 	
       
    68 
    64 
    69 	// In order to connect a session, the ECACM CSY must be loaded (it 
    65 	// In order to connect a session, the ECACM CSY must be loaded (it 
    70 	// contains the server).
    66 	// contains the server).
    71 	TInt	err;
    67 	LEAVEIFERRORL(iCommServ.Connect());
    72 	err = iCommServ.Connect();
    68 	LEAVEIFERRORL(iCommServ.LoadCommModule(KAcmCsyName));
    73 	if (err < 0)
       
    74 		{
       
    75 		OstTrace1( TRACE_ERROR, CACMSERVERIMPL_CONSTRUCTL, "CAcmServerImpl::ConstructL;err=%d", err );
       
    76 		User::Leave(err);
       
    77 		}
       
    78 	
       
    79 	err = iCommServ.LoadCommModule(KAcmCsyName);
       
    80 	if (err < 0)
       
    81 		{
       
    82 		OstTrace1( TRACE_ERROR, CACMSERVERIMPL_CONSTRUCTL_DUP1, "CAcmServerImpl::ConstructL;err=%d", err );
       
    83 		User::Leave(err);
       
    84 		}
       
    85 
       
    86 	// NB RCommServ::Close undoes LoadCommModule.
    69 	// NB RCommServ::Close undoes LoadCommModule.
    87 	err = iAcmServerClient.Connect();
    70 	LEAVEIFERRORL(iAcmServerClient.Connect());
    88 	if (err < 0)
       
    89 		{
       
    90 		OstTrace1( TRACE_ERROR, CACMSERVERIMPL_CONSTRUCTL_DUP2, "CAcmServerImpl::ConstructL;err=%d", err );
       
    91 		User::Leave(err);
       
    92 		}
       
    93 
       
    94 	// iCommServ is eventually cleaned up in our destructor. It must be held 
    71 	// iCommServ is eventually cleaned up in our destructor. It must be held 
    95 	// open at least as long as our session on the ACM server, otherwise 
    72 	// open at least as long as our session on the ACM server, otherwise 
    96 	// there's a risk the ACM server will be pulled from under our feet.
    73 	// there's a risk the ACM server will be pulled from under our feet.
    97 	OstTraceFunctionExit0( CACMSERVERIMPL_CONSTRUCTL_EXIT );
       
    98 	}
    74 	}
    99 
    75 
   100 TInt CAcmServerImpl::CreateFunctions(const TUint aNoAcms, const TUint8 aProtocolNum, const TDesC& aAcmControlIfcName, const TDesC& aAcmDataIfcName)
    76 TInt CAcmServerImpl::CreateFunctions(const TUint aNoAcms, const TUint8 aProtocolNum, const TDesC& aAcmControlIfcName, const TDesC& aAcmDataIfcName)
   101 	{
    77 	{
   102 	OstTraceFunctionEntry0( CACMSERVERIMPL_CREATEFUNCTIONS_ENTRY );
    78 	LOG_FUNC
       
    79 
   103 	return iAcmServerClient.CreateFunctions(aNoAcms, aProtocolNum, aAcmControlIfcName, aAcmDataIfcName);
    80 	return iAcmServerClient.CreateFunctions(aNoAcms, aProtocolNum, aAcmControlIfcName, aAcmDataIfcName);
   104 	}
    81 	}
   105 
    82 
   106 TInt CAcmServerImpl::DestroyFunctions(const TUint aNoAcms)
    83 TInt CAcmServerImpl::DestroyFunctions(const TUint aNoAcms)
   107 	{
    84 	{
   108 	OstTraceFunctionEntry0( CACMSERVERIMPL_DESTROYFUNCTIONS_ENTRY );
    85 	LOG_FUNC
   109 	OstTrace1( TRACE_NORMAL, CACMSERVERIMPL_DESTROYFUNCTIONS, "CAcmServerImpl::DestroyFunctions;aNoAcms=%d", aNoAcms );
    86 	LOGTEXT2(_L8("\taNoAcms = %d"), aNoAcms);
       
    87 
   110 	return iAcmServerClient.DestroyFunctions(aNoAcms);
    88 	return iAcmServerClient.DestroyFunctions(aNoAcms);
   111 	}
    89 	}