sl@0: // Copyright (c) 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: // sl@0: sl@0: sl@0: #ifndef CUSBOTG_H sl@0: #define CUSBOTG_H sl@0: sl@0: class CUsbOtgEventWatcher; sl@0: class CRequestSessionWatcher; sl@0: sl@0: class MUsbRequestSessionObserver sl@0: { sl@0: public: sl@0: virtual void BusRequestL() = 0; sl@0: }; sl@0: sl@0: sl@0: class ROtgStateChangeNotifier sl@0: { sl@0: public: sl@0: ROtgStateChangeNotifier(); sl@0: ~ROtgStateChangeNotifier(); sl@0: sl@0: void Register(const RMessage2& aMessage); sl@0: void DoNotifyL(); sl@0: void DoCancelL(); sl@0: sl@0: private: sl@0: void CompleteNotifierL(TInt); sl@0: sl@0: private: sl@0: /** Notification service */ sl@0: RMessage2 iMessage; sl@0: /** Flag to indicate that media change notification is active */ sl@0: TBool iRegistered; sl@0: }; sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: class CUsbOtg: public CBase, sl@0: public MUsbRequestSessionObserver sl@0: { sl@0: public: sl@0: enum TOtgState {KOtgStateStart, sl@0: KOtgStateAPlugInserted, sl@0: KOtgStateSessionOpen, sl@0: KOtgStateSessionClose}; sl@0: sl@0: sl@0: public: sl@0: static CUsbOtg* NewL(); sl@0: ~CUsbOtg(); sl@0: protected: sl@0: CUsbOtg(); sl@0: void ConstructL(); sl@0: sl@0: public: sl@0: sl@0: // MUsbRequestSessionObserver sl@0: void BusRequestL(); sl@0: sl@0: void HandleUsbOtgEvent(RUsbOtgDriver::TOtgEvent aEvent); sl@0: sl@0: TBool DeviceInserted(); sl@0: void NotifyChange(const RMessage2& aMessage); sl@0: void NotifyChangeCancel(); sl@0: TInt BusDrop(); sl@0: sl@0: private: sl@0: void StartL(); sl@0: void Stop(); sl@0: sl@0: sl@0: private: sl@0: TOtgState iOtgState; sl@0: RUsbOtgDriver iUsbOtgDriver; sl@0: sl@0: CUsbOtgEventWatcher* iOtgEventWatcher; sl@0: sl@0: CRequestSessionWatcher* iRequestSessionWatcher; sl@0: sl@0: ROtgStateChangeNotifier iNotifier; sl@0: }; sl@0: sl@0: #endif