usbmgmt/usbmgr/device/classdrivers/acm/classimplementation/ecacm/src/ActiveReader.cpp
changeset 0 c9bc50fca66e
child 29 59aa7d6e3e0f
equal deleted inserted replaced
-1:000000000000 0:c9bc50fca66e
       
     1 /*
       
     2 * Copyright (c) 1997-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 #include <e32std.h>
       
    19 #include <d32usbc.h>
       
    20 #include "ActiveReader.h"
       
    21 #include "AcmConstants.h"
       
    22 #include "AcmPanic.h"
       
    23 #include "ReadObserver.h"
       
    24 #include "AcmUtils.h"
       
    25 #include <usb/usblogger.h>
       
    26 
       
    27 #ifdef __FLOG_ACTIVE
       
    28 _LIT8(KLogComponent, "ECACM");
       
    29 #endif
       
    30 
       
    31 CActiveReader::CActiveReader(MReadObserver& aParent, RDevUsbcClient& aLdd, TEndpointNumber aEndpoint)
       
    32  :	CActive(KEcacmAOPriority), 
       
    33 	iParent(aParent),
       
    34 	iLdd(aLdd),
       
    35 	iEndpoint(aEndpoint)
       
    36 /**
       
    37  * Constructor.
       
    38  *
       
    39  * @param aParent The object that will be notified when read requests 
       
    40  * complete.
       
    41  * @param aLdd The LDD handle to be used for posting read requests.
       
    42  * @param aEndpoint The endpoint to read from.
       
    43  */
       
    44 	{
       
    45 	CActiveScheduler::Add(this);
       
    46 	}
       
    47 
       
    48 CActiveReader::~CActiveReader()
       
    49 /**
       
    50  * Destructor.
       
    51  */
       
    52 	{
       
    53 	LOG_FUNC
       
    54 
       
    55 	Cancel();
       
    56 	}
       
    57 
       
    58 CActiveReader* CActiveReader::NewL(MReadObserver& aParent, 
       
    59 								   RDevUsbcClient& aLdd,
       
    60 								   TEndpointNumber aEndpoint)
       
    61 /**
       
    62  * Standard two phase constructor.
       
    63  *
       
    64  * @param aParent The object that will be notified when read requests 
       
    65  * complete.
       
    66  * @param aLdd The LDD handle to be used for posting read requests.
       
    67  * @param aEndpoint The endpoint to read from.
       
    68  * @return Ownership of a new CActiveReader object.
       
    69  */
       
    70 	{
       
    71 	LOG_STATIC_FUNC_ENTRY
       
    72 
       
    73 	CActiveReader* self = new(ELeave) CActiveReader(aParent, aLdd, aEndpoint);
       
    74 	return self;
       
    75 	}
       
    76 
       
    77 void CActiveReader::Read(TDes8& aDes, TInt aLen)
       
    78 /**
       
    79  * Read the given length of data from the LDD.
       
    80  *
       
    81  * @param aDes A descriptor into which to read.
       
    82  * @param aLen The length to read.
       
    83  */
       
    84 	{
       
    85 	LOG_FUNC
       
    86 
       
    87 	iLdd.Read(iStatus, iEndpoint, aDes, aLen); 
       
    88 	SetActive();
       
    89 	}
       
    90 
       
    91 void CActiveReader::DoCancel()
       
    92 /**
       
    93  * Cancel an outstanding read.
       
    94  */
       
    95 	{
       
    96 	LOG_FUNC
       
    97 
       
    98 	iLdd.ReadCancel(iEndpoint);
       
    99 	}
       
   100 
       
   101 void CActiveReader::RunL()
       
   102 /**
       
   103  * This function will be called when the read completes. It notifies the 
       
   104  * parent class of the completion.
       
   105  */
       
   106 	{
       
   107 	LOG_LINE
       
   108 	LOGTEXT2(_L8(">>CActiveReader::RunL iStatus=%d"), iStatus.Int());
       
   109 
       
   110 	iParent.ReadCompleted(iStatus.Int());
       
   111 
       
   112 	LOGTEXT(_L8("<<CActiveReader::RunL"));
       
   113 	}
       
   114 
       
   115 //
       
   116 // End of file