usbmgmt/usbmgr/device/classdrivers/acm/classimplementation/ecacm/src/ActiveDataAvailableNotifier.cpp
branchRCL_3
changeset 15 f92a4f87e424
parent 0 c9bc50fca66e
child 16 012cc2ee6408
equal deleted inserted replaced
14:d3e8e7d462dd 15:f92a4f87e424
     1 /*
     1 /*
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2007-2010 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".
    20 #include "ActiveDataAvailableNotifier.h"
    20 #include "ActiveDataAvailableNotifier.h"
    21 #include "AcmConstants.h"
    21 #include "AcmConstants.h"
    22 #include "AcmPanic.h"
    22 #include "AcmPanic.h"
    23 #include "AcmUtils.h"
    23 #include "AcmUtils.h"
    24 #include "NotifyDataAvailableObserver.h"
    24 #include "NotifyDataAvailableObserver.h"
    25 #include <usb/usblogger.h>
    25 #include "OstTraceDefinitions.h"
       
    26 #ifdef OST_TRACE_COMPILER_IN_USE
       
    27 #include "ActiveDataAvailableNotifierTraces.h"
       
    28 #endif
    26 
    29 
    27 #ifdef __FLOG_ACTIVE
    30 
    28 _LIT8(KLogComponent, "ECACM");
       
    29 #endif
       
    30 
    31 
    31 CActiveDataAvailableNotifier::CActiveDataAvailableNotifier(
    32 CActiveDataAvailableNotifier::CActiveDataAvailableNotifier(
    32 								MNotifyDataAvailableObserver& aParent, 
    33 								MNotifyDataAvailableObserver& aParent, 
    33 								RDevUsbcClient& aLdd,
    34 								RDevUsbcClient& aLdd,
    34 								TEndpointNumber aEndpoint)
    35 								TEndpointNumber aEndpoint)
    44  * arrives at the LDD.
    45  * arrives at the LDD.
    45  * @param aLdd The LDD handle to be used for posting read requests.
    46  * @param aLdd The LDD handle to be used for posting read requests.
    46  * @param aEndpoint The endpoint to read from.
    47  * @param aEndpoint The endpoint to read from.
    47  */
    48  */
    48 	{
    49 	{
       
    50 	OstTraceFunctionEntry0( CACTIVEDATAAVAILABLENOTIFIER_CACTIVEDATAAVAILABLENOTIFIER_CONS_ENTRY );
    49 	CActiveScheduler::Add(this);
    51 	CActiveScheduler::Add(this);
       
    52 	OstTraceFunctionExit0( CACTIVEDATAAVAILABLENOTIFIER_CACTIVEDATAAVAILABLENOTIFIER_CONS_EXIT );
    50 	}
    53 	}
    51 
    54 
    52 CActiveDataAvailableNotifier::~CActiveDataAvailableNotifier()
    55 CActiveDataAvailableNotifier::~CActiveDataAvailableNotifier()
    53 /**
    56 /**
    54  * Destructor.
    57  * Destructor.
    55  */
    58  */
    56 	{
    59 	{
    57 	LOG_FUNC
    60 	OstTraceFunctionEntry0( CACTIVEDATAAVAILABLENOTIFIER_CACTIVEDATAAVAILABLENOTIFIER_DES_ENTRY );
    58 
       
    59 	Cancel();
    61 	Cancel();
       
    62 	OstTraceFunctionExit0( CACTIVEDATAAVAILABLENOTIFIER_CACTIVEDATAAVAILABLENOTIFIER_DES_EXIT );
    60 	}
    63 	}
    61 
    64 
    62 CActiveDataAvailableNotifier* CActiveDataAvailableNotifier::NewL(
    65 CActiveDataAvailableNotifier* CActiveDataAvailableNotifier::NewL(
    63 								MNotifyDataAvailableObserver& aParent, 
    66 								MNotifyDataAvailableObserver& aParent, 
    64 								RDevUsbcClient& aLdd,
    67 								RDevUsbcClient& aLdd,
    72  * @param aLdd The LDD handle to be used for posting read requests.
    75  * @param aLdd The LDD handle to be used for posting read requests.
    73  * @param aEndpoint The endpoint to read from.
    76  * @param aEndpoint The endpoint to read from.
    74  * @return Ownership of a new CActiveReadOneOrMoreReader object.
    77  * @return Ownership of a new CActiveReadOneOrMoreReader object.
    75  */
    78  */
    76 	{
    79 	{
    77 	LOG_STATIC_FUNC_ENTRY
    80 	OstTraceFunctionEntry0( CACTIVEDATAAVAILABLENOTIFIER_NEWL_ENTRY );
    78 
       
    79 	CActiveDataAvailableNotifier* self = 
    81 	CActiveDataAvailableNotifier* self = 
    80 		new(ELeave) CActiveDataAvailableNotifier(aParent, aLdd, aEndpoint);
    82 		new(ELeave) CActiveDataAvailableNotifier(aParent, aLdd, aEndpoint);
       
    83 	OstTraceFunctionExit0( CACTIVEDATAAVAILABLENOTIFIER_NEWL_EXIT );
    81 	return self;
    84 	return self;
    82 	}
    85 	}
    83 
    86 
    84 void CActiveDataAvailableNotifier::NotifyDataAvailable()
    87 void CActiveDataAvailableNotifier::NotifyDataAvailable()
    85 /**
    88 /**
    86  * When incoming data arrives at the LDD notify the caller.
    89  * When incoming data arrives at the LDD notify the caller.
    87  */
    90  */
    88 	{
    91 	{
    89 	LOGTEXT(_L8(">>CActiveDataAvailableNotifier::NotifyDataAvailable"));
    92 	OstTraceFunctionEntry0( CACTIVEDATAAVAILABLENOTIFIER_NOTIFYDATAAVAILABLE_ENTRY );
    90 
       
    91 	iLdd.ReadOneOrMore(iStatus, iEndpoint, iUnusedBuf, 0);
    93 	iLdd.ReadOneOrMore(iStatus, iEndpoint, iUnusedBuf, 0);
    92 	SetActive();
    94 	SetActive();
    93 
    95 	OstTraceFunctionExit0( CACTIVEDATAAVAILABLENOTIFIER_NOTIFYDATAAVAILABLE_EXIT );
    94 	LOGTEXT(_L8("<<CActiveDataAvailableNotifier::NotifyDataAvailable"));
       
    95 	}
    96 	}
    96 
    97 
    97 void CActiveDataAvailableNotifier::DoCancel()
    98 void CActiveDataAvailableNotifier::DoCancel()
    98 /**
    99 /**
    99  * Cancel an outstanding request.
   100  * Cancel an outstanding request.
   100  */
   101  */
   101 	{
   102 	{
   102 	LOG_FUNC
   103 	OstTraceFunctionEntry0( CACTIVEDATAAVAILABLENOTIFIER_DOCANCEL_ENTRY );
   103 
       
   104 	iLdd.ReadCancel(iEndpoint);
   104 	iLdd.ReadCancel(iEndpoint);
       
   105 	OstTraceFunctionExit0( CACTIVEDATAAVAILABLENOTIFIER_DOCANCEL_EXIT );
   105 	}
   106 	}
   106 
   107 
   107 void CActiveDataAvailableNotifier::RunL()
   108 void CActiveDataAvailableNotifier::RunL()
   108 /**
   109 /**
   109  * This function will be called when the zero byte ReadOneOrMore() call on the LDD
   110  * This function will be called when the zero byte ReadOneOrMore() call on the LDD
   112  * NotifyDataAvailable() is called again, otherwise the parent is notified.
   113  * NotifyDataAvailable() is called again, otherwise the parent is notified.
   113  * We also have to be careful about getting into an infinite loop if the cable has 
   114  * We also have to be careful about getting into an infinite loop if the cable has 
   114  * been detached.
   115  * been detached.
   115  */
   116  */
   116 	{
   117 	{
   117 	LOG_LINE
   118 	OstTraceFunctionEntry0( CACTIVEDATAAVAILABLENOTIFIER_RUNL_ENTRY );
   118 	LOG_FUNC
   119 	OstTrace1( TRACE_NORMAL, CACTIVEDATAAVAILABLENOTIFIER_RUNL, "CActiveDataAvailableNotifier::RunL;iStatus=%d", iStatus.Int() );
   119 	LOGTEXT2(_L8("\tiStatus = %d"), iStatus.Int());
       
   120 	
       
   121 	TBool complete = EFalse;
   120 	TBool complete = EFalse;
   122 	TInt completeErr = KErrNone;
   121 	TInt completeErr = KErrNone;
   123 
   122 
   124 	TInt recBufSize;
   123 	TInt recBufSize;
   125 	TInt err = iLdd.QueryReceiveBuffer(iEndpoint, recBufSize);
   124 	TInt err = iLdd.QueryReceiveBuffer(iEndpoint, recBufSize);
   160 
   159 
   161 	if ( complete )
   160 	if ( complete )
   162 		{
   161 		{
   163 		iParent.NotifyDataAvailableCompleted(completeErr);
   162 		iParent.NotifyDataAvailableCompleted(completeErr);
   164 		}
   163 		}
       
   164 	OstTraceFunctionExit0( CACTIVEDATAAVAILABLENOTIFIER_RUNL_EXIT );
   165 	}
   165 	}
   166 
   166 
   167 //
   167 //
   168 // End of file
   168 // End of file