usbmgmt/usbmgr/device/classdrivers/acm/classimplementation/acmserver/src/acmserverimpl.cpp
changeset 0 c9bc50fca66e
child 29 59aa7d6e3e0f
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 *
       
    16 */
       
    17 
       
    18 /**
       
    19  @file
       
    20 */
       
    21 
       
    22 #include <e32base.h>
       
    23 #include "acmserverimpl.h"
       
    24 #include <usb/usblogger.h>
       
    25 #include <acminterface.h>
       
    26 
       
    27 #ifdef __FLOG_ACTIVE
       
    28 _LIT8(KLogComponent, "ACMSVRCLI");
       
    29 #endif
       
    30 
       
    31 /** Constructor */
       
    32 CAcmServerImpl::CAcmServerImpl() 
       
    33 	{
       
    34 	LOG_FUNC
       
    35 	}
       
    36 	   
       
    37 /** Destructor */
       
    38 CAcmServerImpl::~CAcmServerImpl()
       
    39 	{
       
    40 	LOG_FUNC
       
    41 
       
    42 	iCommServ.Close();
       
    43 	iAcmServerClient.Close();
       
    44 	}
       
    45 
       
    46 /**
       
    47 2-phase construction.
       
    48 @return Ownership of a new CAcmServerImpl.
       
    49 */
       
    50 CAcmServerImpl* CAcmServerImpl::NewL()
       
    51 	{
       
    52 	LOG_STATIC_FUNC_ENTRY
       
    53 
       
    54 	CAcmServerImpl* self = new(ELeave) CAcmServerImpl;
       
    55 	CleanupStack::PushL(self);
       
    56 	self->ConstructL();
       
    57 	CleanupStack::Pop(self);
       
    58 	return self;
       
    59 	}
       
    60 
       
    61 void CAcmServerImpl::ConstructL()
       
    62 	{
       
    63 	LOG_FUNC
       
    64 
       
    65 	// In order to connect a session, the ECACM CSY must be loaded (it 
       
    66 	// contains the server).
       
    67 	LEAVEIFERRORL(iCommServ.Connect());
       
    68 	LEAVEIFERRORL(iCommServ.LoadCommModule(KAcmCsyName));
       
    69 	// NB RCommServ::Close undoes LoadCommModule.
       
    70 	LEAVEIFERRORL(iAcmServerClient.Connect());
       
    71 	// iCommServ is eventually cleaned up in our destructor. It must be held 
       
    72 	// open at least as long as our session on the ACM server, otherwise 
       
    73 	// there's a risk the ACM server will be pulled from under our feet.
       
    74 	}
       
    75 
       
    76 TInt CAcmServerImpl::CreateFunctions(const TUint aNoAcms, const TUint8 aProtocolNum, const TDesC& aAcmControlIfcName, const TDesC& aAcmDataIfcName)
       
    77 	{
       
    78 	LOG_FUNC
       
    79 
       
    80 	return iAcmServerClient.CreateFunctions(aNoAcms, aProtocolNum, aAcmControlIfcName, aAcmDataIfcName);
       
    81 	}
       
    82 
       
    83 TInt CAcmServerImpl::DestroyFunctions(const TUint aNoAcms)
       
    84 	{
       
    85 	LOG_FUNC
       
    86 	LOGTEXT2(_L8("\taNoAcms = %d"), aNoAcms);
       
    87 
       
    88 	return iAcmServerClient.DestroyFunctions(aNoAcms);
       
    89 	}