usbmgmt/usbmgr/device/classdrivers/ncm/classcontroller/src/ncmconnectionmanagerhelper.cpp
branchRCL_3
changeset 15 f92a4f87e424
equal deleted inserted replaced
14:d3e8e7d462dd 15:f92a4f87e424
       
     1 /*
       
     2 * Copyright (c) 2010 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  * @internalComponent
       
    21  */
       
    22 
       
    23 #include <e32debug.h>
       
    24 
       
    25 #include "ncmconnectionmanagerhelper.h"
       
    26 #include "ncmiapconnectionobserver.h"
       
    27 #include "ncmconnectionmanager.h"
       
    28 
       
    29 // For OST tracing
       
    30 #include "OstTraceDefinitions.h"
       
    31 #ifdef OST_TRACE_COMPILER_IN_USE
       
    32 #include "ncmconnectionmanagerhelperTraces.h"
       
    33 #endif
       
    34 
       
    35 /**
       
    36  * Constructor.
       
    37  * @param aObserver The object which is interested in the IAP connection completion
       
    38  * @param aConnection The reference of the NCM connection to be used
       
    39  */
       
    40 CNcmConnectionManHelper::CNcmConnectionManHelper(MNcmConnectionObserver& aObserver,
       
    41         RConnection& aConnection)
       
    42     : CActive(CActive::EPriorityStandard)
       
    43 	, iObserver(aObserver)
       
    44 	, iConnection(aConnection) 
       
    45 	{
       
    46 	OstTraceFunctionEntryExt( CNCMCONNECTIONMANHELPER_CNCMCONNECTIONMANHELPER_ENTRY, this );
       
    47 	CActiveScheduler::Add(this);		
       
    48 	OstTraceFunctionExit1( CNCMCONNECTIONMANHELPER_CNCMCONNECTIONMANHELPER_EXIT, this );
       
    49 	}
       
    50 
       
    51 
       
    52 /**
       
    53  * Destructor.
       
    54  */
       
    55 CNcmConnectionManHelper::~CNcmConnectionManHelper()
       
    56 	{	
       
    57 	OstTraceFunctionEntry1( CNCMCONNECTIONMANHELPER_CNCMCONNECTIONMANHELPER_ENTRY_DESTRUCTOR, this );
       
    58 	if (IsActive())
       
    59 	    {
       
    60 	    Cancel();
       
    61 	    }
       
    62 	else
       
    63 	    {
       
    64 	    Stop();
       
    65 	    }
       
    66 	OstTraceFunctionExit1( CNCMCONNECTIONMANHELPER_CNCMCONNECTIONMANHELPER_ENTRY_DESTRUCTOR_EXIT, this );
       
    67 	}
       
    68 
       
    69 /**
       
    70  * Start the connection.
       
    71  * @param aPref NCM connect preference
       
    72  */
       
    73 void CNcmConnectionManHelper::Start(TConnPref& aPref)
       
    74 	{	
       
    75 	OstTraceFunctionEntryExt( CNCMCONNECTIONMANHELPER_START_ENTRY, this );
       
    76 	if (!IsActive())
       
    77 		{
       
    78 		iConnection.Start(aPref, iStatus);
       
    79 		SetActive();
       
    80 		}
       
    81 	OstTraceFunctionExit1( CNCMCONNECTIONMANHELPER_START_EXIT, this );
       
    82 	}
       
    83 
       
    84 /**
       
    85  * Stop the connection.
       
    86  */
       
    87 void CNcmConnectionManHelper::Stop()
       
    88 	{
       
    89     OstTraceFunctionEntry1( CNCMCONNECTIONMANHELPER_STOP_ENTRY, this );
       
    90    
       
    91 	TInt err = iConnection.Stop(RConnection::EStopAuthoritative);
       
    92 	OstTrace1( TRACE_NORMAL, CNCMCONNECTIONMANHELPER_STOP_RETURN_CODE, "Return code from Stop() is:;err=%d", err );
       
    93 	OstTraceFunctionExit1( CNCMCONNECTIONMANHELPER_STOP_EXIT, this );
       
    94 	}
       
    95 /**
       
    96  * Implements cancellation of an outstanding request.
       
    97  */
       
    98 void CNcmConnectionManHelper::DoCancel()
       
    99 	{
       
   100     OstTraceFunctionEntry0( CNCMCONNECTIONMANHELPER_DOCANCEL_ENTRY );
       
   101 
       
   102 	TInt err = iConnection.Stop(RConnection::EStopAuthoritative);
       
   103 
       
   104     OstTrace1( TRACE_NORMAL, CNCMCONNECTIONMANHELPER_DOCNCEL, "Return code from Stop() is:;err=%d", err );
       
   105 	OstTraceFunctionExit0( CNCMCONNECTIONMANHELPER_DOCANCEL_EXIT );
       
   106 	}
       
   107 
       
   108 /**
       
   109  * Called when connection completed.
       
   110  */
       
   111 void CNcmConnectionManHelper::RunL()
       
   112 	{	
       
   113 	OstTraceFunctionEntry0( CNCMCONNECTIONMANHELPER_RUNL_ENTRY );
       
   114 	iObserver.MicoHandleConnectionComplete(iStatus.Int());
       
   115 	OstTraceFunctionExit0( CNCMCONNECTIONMANHELPER_RUNL_EXIT );
       
   116 	}