sl@0: /* 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: Implements a thread per device functionality sl@0: */ sl@0: sl@0: /** @file sl@0: @internalTechnology sl@0: */ sl@0: sl@0: #ifndef CUSBMASSSTORAGEDEVICETHREAD_H sl@0: #define CUSBMASSSTORAGEDEVICETHREAD_H sl@0: sl@0: sl@0: class TDeviceHandler sl@0: { sl@0: public: sl@0: TDeviceHandler(CUsbHostMsDevice& aDevice); sl@0: void HandleMessageL(const RMessage2& aMessage); sl@0: sl@0: private: sl@0: CUsbHostMsDevice& iDevice; sl@0: }; sl@0: sl@0: sl@0: class TLogicalUnitHandler sl@0: { sl@0: public: sl@0: TLogicalUnitHandler(CUsbHostMsLogicalUnit& aLu); sl@0: void HandleMessageL(const RMessage2& aMessage); sl@0: sl@0: private: sl@0: CUsbHostMsLogicalUnit& iLu; sl@0: }; sl@0: sl@0: class CUsbHostMsSession; sl@0: sl@0: class CUsbHostMsDeviceThread : public CActive sl@0: { sl@0: public: sl@0: static const TInt KMaxNumMessage = 32; sl@0: sl@0: static CUsbHostMsDeviceThread* NewL(CUsbHostMsSession& aUsbHostMsSession, TUint aToken); sl@0: ~CUsbHostMsDeviceThread(); sl@0: sl@0: private: sl@0: CUsbHostMsDeviceThread(CUsbHostMsSession& aUsbHostMsSession, TUint aToken); sl@0: sl@0: public: sl@0: static TInt Entry(TAny* aPtr); sl@0: TInt QueueMsg(const RMessage2& aMsg); sl@0: void Lock(); sl@0: void Unlock(); sl@0: sl@0: sl@0: private: sl@0: void Start(); sl@0: sl@0: void RunL(); sl@0: void DoCancel(); sl@0: TInt RunError(TInt aError); sl@0: sl@0: void HandleMessage(const RMessage2& aMessage); sl@0: sl@0: void UnRegisterInterfaceL(const RMessage2& aMessage); sl@0: sl@0: private: sl@0: static void DoStartServerL(TAny* aPtr); sl@0: sl@0: void RegisterInterfaceL(const RMessage2& aMessage); sl@0: void InitialiseInterfaceL(const RMessage2& aMessage); sl@0: void GetNumLunL(const RMessage2& aMessage); sl@0: void RegisterLogicalUnitL(const RMessage2& aMessage); sl@0: TInt Shutdown(); sl@0: sl@0: private: sl@0: CUsbHostMsSession& iUsbHostMsSession; sl@0: sl@0: CUsbHostMsDevice* iUsbHostMsDevice; sl@0: sl@0: RMessage2 iRMessage2[KMaxNumMessage]; sl@0: RMutex iMutex; sl@0: sl@0: TInt iQueueIndex; sl@0: TInt iDequeueIndex; sl@0: TBool iQueueFull; sl@0: }; sl@0: sl@0: sl@0: inline void CUsbHostMsDeviceThread::Lock() sl@0: { sl@0: iMutex.Wait(); sl@0: } sl@0: sl@0: sl@0: inline void CUsbHostMsDeviceThread::Unlock() sl@0: { sl@0: iMutex.Signal(); sl@0: } sl@0: sl@0: sl@0: #endif // CUSBMASSSTORAGEDEVICETHREAD_H