sl@0: #ifndef __FDF_ACTOR_H sl@0: #define __FDF_ACTOR_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 FDFActor.h sl@0: * @internalComponent sl@0: * sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: extern RTest gtest; sl@0: sl@0: namespace NUnitTesting_USBDI sl@0: { sl@0: sl@0: /** sl@0: This class describes an observer for USB bus events reported from the acting sl@0: Function Driver Framework (Hub Driver) sl@0: */ sl@0: class MUsbBusObserver sl@0: { sl@0: public: sl@0: sl@0: /** sl@0: Called when a usb client device was connected to the host and has a bus address sl@0: @param aDeviceHandle the unique handle to the device sl@0: */ sl@0: virtual void DeviceInsertedL(TUint aDeviceHandle) = 0; sl@0: sl@0: /** sl@0: Called when a previously connected usb device has disconnected from the bus sl@0: @param aDeviceHandle the handle to the device that has just disconnected. sl@0: This handle will (after this function) now be void sl@0: */ sl@0: virtual void DeviceRemovedL(TUint aDeviceHandle) = 0; sl@0: sl@0: /** sl@0: Called when there has been a error on the bus as seen by the Hub Driver sl@0: @param aError the bus error code sl@0: */ sl@0: virtual void BusErrorL(TInt aError) = 0; sl@0: sl@0: /** sl@0: Called when the device has changed state sl@0: @param aPreviousState the previous state of the device sl@0: @param aNewState the now new observerd state of the device sl@0: @param aCompletionCode the comletion code of state change sl@0: */ sl@0: virtual void DeviceStateChangeL(RUsbDevice::TDeviceState aPreviousState,RUsbDevice::TDeviceState aNewState, sl@0: TInt aCompletionCode) = 0; sl@0: }; sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: This class represents the host side object for a USB test device. This means a device that sl@0: is connected to the bus. sl@0: */ sl@0: class CUsbTestDevice : public CActive sl@0: { sl@0: public: sl@0: /** sl@0: Construct a USB bus connected device sl@0: @param aHubDriver the USB hub driver object sl@0: @param aDeviceHandle the unique handle value to the device sl@0: @param aObserver the sl@0: */ sl@0: static CUsbTestDevice* NewL(RUsbHubDriver& aHubDriver,TUint aDeviceHandle,MUsbBusObserver& aObserver); sl@0: sl@0: /** sl@0: Destructor sl@0: */ sl@0: ~CUsbTestDevice(); sl@0: sl@0: /** sl@0: Obtain the USB specification that this device complies to sl@0: @return the usb compliance specification sl@0: */ sl@0: TUint16 DeviceSpec() const; sl@0: sl@0: /** sl@0: Obtain the Identity of the product sl@0: @return the product identity sl@0: */ sl@0: TUint16 ProductId() const; sl@0: sl@0: /** sl@0: Obtain the Identity of the vendor sl@0: @return the vendor identity sl@0: */ sl@0: TUint16 VendorId() const; sl@0: sl@0: /** sl@0: Obtain the product string for the connected device sl@0: @return the device's product string sl@0: */ sl@0: const TDesC16& Product() const; sl@0: sl@0: /** sl@0: Obtani the configuration string for the connected device sl@0: @return the device's configuration string sl@0: */ sl@0: const TDesC16& ConfigurationString() const; sl@0: sl@0: /** sl@0: Obtain the serial number of the connected device sl@0: @return the device's serial number sl@0: */ sl@0: const TDesC16& SerialNumber() const; sl@0: sl@0: /** sl@0: Obtain the manufacturer of the connected device sl@0: @return the manufacturer as string sl@0: */ sl@0: const TDesC16& Manufacturer() const; sl@0: sl@0: /** sl@0: Access the raw referrence to the USB device API object sl@0: @return a referrence to the RUsbDevice object sl@0: */ sl@0: RUsbDevice& Device(); sl@0: sl@0: /** sl@0: Access the device descriptor sl@0: @return a referrence to the device descriptor sl@0: */ sl@0: const TUsbDeviceDescriptor& DeviceDescriptor() const; sl@0: sl@0: /** sl@0: Access the configuration descriptor sl@0: @return a referrence to the configuration descriptor sl@0: */ sl@0: const TUsbConfigurationDescriptor& ConfigurationDescriptor() const; sl@0: sl@0: sl@0: protected: sl@0: sl@0: /** sl@0: Constructor, build a host side usb test object sl@0: @param aHubDriver the USB host hub driver sl@0: @param aHandle the unique handle to the usb device sl@0: @param aObserver the observer of usb host bus events sl@0: */ sl@0: CUsbTestDevice(RUsbHubDriver& aHubDriver,TUint aHandle,MUsbBusObserver& aObserver); sl@0: sl@0: /** sl@0: 2nd phase construction sl@0: */ sl@0: void ConstructL(); sl@0: sl@0: protected: // From CActive sl@0: sl@0: /** sl@0: Cancels the current asynchronous activity of this test device sl@0: */ sl@0: void DoCancel(); sl@0: sl@0: /** sl@0: */ sl@0: void RunL(); sl@0: sl@0: /** sl@0: */ sl@0: TInt RunError(TInt aError); sl@0: sl@0: private: sl@0: RUsbHubDriver& iDriver; sl@0: RUsbDevice::TDeviceState iCurrentState; sl@0: TUint iHandle; sl@0: RUsbDevice iDevice; sl@0: TUsbDeviceDescriptor iDeviceDescriptor; sl@0: TUsbConfigurationDescriptor iConfigDescriptor; sl@0: TUint16 iDeviceSpec; sl@0: TUint16 iPid; sl@0: TUint16 iVid; sl@0: sl@0: /** sl@0: The observer of events on the bus bus, noticed by the host hub driver sl@0: */ sl@0: MUsbBusObserver& iObserver; sl@0: sl@0: /** sl@0: The string for the configuration sl@0: */ sl@0: TUsbStringDescriptor* iConfigStringDesc; sl@0: TBuf8<255> iConfigStringData; sl@0: TBuf16<128> iConfigString; sl@0: sl@0: /** sl@0: The string for the manufacturer sl@0: */ sl@0: TUsbStringDescriptor* iManufacturerStringDesc; sl@0: TBuf8<255> iManufacturerStringData; sl@0: TBuf16<128> iManufacturerString; sl@0: sl@0: /** sl@0: The string for the product name sl@0: */ sl@0: TUsbStringDescriptor* iProductStringDesc; sl@0: TBuf8<255> iProductStringData; sl@0: TBuf16<128> iProductString; sl@0: sl@0: /** sl@0: The string for the serial number sl@0: */ sl@0: TUsbStringDescriptor* iSerialNumberDesc; sl@0: TBuf8<255> iSerialNumberStringData; sl@0: TBuf16<128> iSerialNumber; sl@0: }; sl@0: sl@0: /** sl@0: This class represents a minimal version of the Function driver framework. sl@0: This will usually manage more than one device but only one device can currently be supported. sl@0: The actual FDF has well defined responsibilities but this actor FDF will be controlled by the sl@0: current test case running. sl@0: */ sl@0: class CActorFDF : public CActive sl@0: { sl@0: public: sl@0: sl@0: /** sl@0: Factory construction of the acting Function Driver Framework sl@0: @param aNotifier the notifier sl@0: */ sl@0: static CActorFDF* NewL(MUsbBusObserver& aObserver); sl@0: virtual ~CActorFDF(); sl@0: sl@0: void Monitor(); sl@0: sl@0: CUsbTestDevice& DeviceL(TUint aDeviceHandle); sl@0: sl@0: private: sl@0: CActorFDF(MUsbBusObserver& aObserver); sl@0: void ConstructL(); sl@0: sl@0: private: sl@0: void DoCancel(); sl@0: void RunL(); sl@0: TInt RunError(TInt aError); sl@0: sl@0: sl@0: private: sl@0: RUsbHubDriver iDriver; sl@0: RHashMap iDevices; sl@0: RUsbHubDriver::TBusEvent iBusEvent; sl@0: MUsbBusObserver& iObserver; sl@0: RProcess iOtgUsbMan; sl@0: }; sl@0: sl@0: sl@0: } sl@0: sl@0: sl@0: #endif