sl@0: // Copyright (c) 2004-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: // Component test of Publish and Subscribe sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @internalTechnology sl@0: */ sl@0: sl@0: #ifndef __CPROPERTYWATCH_H__ sl@0: #define __CPROPERTYWATCH_H__ sl@0: sl@0: #include sl@0: #include sl@0: #include "usbmsshared.h" sl@0: sl@0: class CPropertyHandler; sl@0: class CStateMachine; sl@0: sl@0: enum sl@0: { sl@0: EUsbMsState_Read = EUsbMsDriveState_Error + 100, sl@0: EUsbMsState_Written sl@0: }; sl@0: sl@0: /** sl@0: An active object that subscribes to a specified Mass Storage property and sl@0: calls a provided handler each time the property is published. sl@0: */ sl@0: class CPropertyWatch : public CActive sl@0: { sl@0: public: sl@0: static CPropertyWatch* NewLC(TUsbMsDriveState_Subkey aSubkey, CPropertyHandler& aHandler); sl@0: sl@0: private: sl@0: CPropertyWatch(CPropertyHandler& aHandler); sl@0: void ConstructL(TUsbMsDriveState_Subkey aSubkey); sl@0: ~CPropertyWatch(); sl@0: void RunL(); sl@0: void DoCancel(); sl@0: sl@0: RProperty iProperty; sl@0: CPropertyHandler& iHandler; sl@0: }; sl@0: sl@0: /** sl@0: A property handler class that handles the change of ms drive status sl@0: */ sl@0: class CPropertyHandler : public CBase sl@0: { sl@0: public: sl@0: virtual void HandleStatusChange(RProperty& aProperty) = 0; sl@0: sl@0: protected: sl@0: CPropertyHandler(TInt aDriveNo, CStateMachine& aSm); sl@0: virtual ~CPropertyHandler(); sl@0: sl@0: protected: sl@0: TInt iDriveNo; sl@0: CStateMachine& iStateMachine; sl@0: }; sl@0: sl@0: class CMsDriveStatusHandler : public CPropertyHandler sl@0: { sl@0: public: sl@0: static CMsDriveStatusHandler* NewLC(TInt aDriveNo, CStateMachine& aSm); sl@0: void HandleStatusChange(RProperty& aProperty); sl@0: sl@0: protected: sl@0: CMsDriveStatusHandler(TInt aDriveNo, CStateMachine& aSm); sl@0: }; sl@0: sl@0: class CMsReadStatusHandler : public CPropertyHandler sl@0: { sl@0: public: sl@0: static CMsReadStatusHandler* NewLC(TInt aDriveNo, CStateMachine& aSm); sl@0: void HandleStatusChange(RProperty& aProperty); sl@0: sl@0: private: sl@0: CMsReadStatusHandler(TInt aDriveNo, CStateMachine& aSm); sl@0: }; sl@0: sl@0: class CMsWrittenStatusHandler : public CPropertyHandler sl@0: { sl@0: public: sl@0: static CMsWrittenStatusHandler* NewLC(TInt aDriveNo, CStateMachine& aSm); sl@0: void HandleStatusChange(RProperty& aProperty); sl@0: sl@0: private: sl@0: CMsWrittenStatusHandler(TInt aDriveNo, CStateMachine& aSm); sl@0: }; sl@0: sl@0: #endif // __CPROPERTYWATCH_H__ sl@0: