sl@0: #ifndef __CONTROL_ENDPOINT_READER_H sl@0: #define __CONTROL_ENDPOINT_READER_H sl@0: sl@0: /* sl@0: * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * @file controlendpointreader.h sl@0: * @internalComponent sl@0: * sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: #include "endpointreader.h" sl@0: sl@0: namespace NUnitTesting_USBDI sl@0: { sl@0: sl@0: /** sl@0: */ sl@0: class MRequestHandler sl@0: { sl@0: public: sl@0: /** sl@0: Called when a control vendor request from the host is received and does not require data being sl@0: sent back to the host. sl@0: @param aRequest the control request value sl@0: @param aValue a parameter value for the request sl@0: @param aIndex an index parameter for the request sl@0: @param aDataReqLength the length of the data to be returned to the host sl@0: @param aPayload the data payload sent to the device by the host in a data phase sl@0: */ sl@0: sl@0: virtual TInt ProcessRequestL(TUint8 aRequest,TUint16 aValue,TUint16 aIndex,TUint16 aDataReqLength, sl@0: const TDesC8& aPayload) = 0; sl@0: }; sl@0: sl@0: sl@0: sl@0: /** sl@0: This class describes a entity that reads control requests from endpoint 0 sl@0: */ sl@0: class CControlEndpointReader : public CEndpointReader, public MEndpointDataHandler sl@0: { sl@0: public: sl@0: sl@0: /** sl@0: Constructor, build a reader of requests from endpoint zero sl@0: @param aClientDriver the channel to the USB client driver sl@0: @param aRequestHandler the handler of control requests sl@0: */ sl@0: sl@0: CControlEndpointReader(RDevUsbcClient& aClientDriver,MRequestHandler& aRequestHandler); sl@0: sl@0: /** sl@0: Destructor sl@0: */ sl@0: sl@0: virtual ~CControlEndpointReader(); sl@0: sl@0: /** sl@0: Reads requests sent by the host on endpoint 0. This includes any data from the data phase sl@0: of the transfer sl@0: */ sl@0: sl@0: void ReadRequestsL(); sl@0: sl@0: public: // From MEndpointDataHandler sl@0: sl@0: /** sl@0: Interprets the data received as a control request on endpoint 0 sl@0: @param aEndpointNumber the number of the endpoint read from sl@0: @param aData the data successfully read from the endpoint sl@0: */ sl@0: sl@0: virtual void DataReceivedFromEndpointL(TEndpointNumber aEndpointNumber,const TDesC8& aData); sl@0: sl@0: /** sl@0: Notified when an error occurs on a read from the endpoint sl@0: @param aEndpointNumber the number of the endpoint read from sl@0: @param aErrorCode the read operation completion error sl@0: */ sl@0: sl@0: void EndpointReadError(TEndpointNumber aEndpointNumber,TInt aErrorCode); sl@0: sl@0: private: sl@0: sl@0: // Flag to indicate sl@0: TBool iDeviceToHost; sl@0: TBool iDataPhase; sl@0: sl@0: /** sl@0: The request status of the entity processing requests sl@0: */ sl@0: MRequestHandler& iRequestHandler; sl@0: sl@0: /** sl@0: The fields of the control transfer request sl@0: */ sl@0: TUint8 ibRequestType; sl@0: TUint8 ibRequest; sl@0: TUint16 iwValue; sl@0: TUint16 iwIndex; sl@0: TUint16 iwLength; sl@0: }; sl@0: sl@0: } sl@0: sl@0: sl@0: #endif sl@0: sl@0: