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: // Drive publishing classes for USB Mass Storage. sl@0: // RDriveMediaErrorPublisher, sl@0: // RDriveStateChangedPublisher, sl@0: // CUsbTransferPublisher, sl@0: // CUsbReadTransferPublisher, sl@0: // CUsbReadTransferPublisher. sl@0: // sl@0: // sl@0: sl@0: sl@0: sl@0: /** sl@0: @file sl@0: @internalTechnology sl@0: */ sl@0: sl@0: #ifndef DRIVEPUBLISHER_H sl@0: #define DRIVEPUBLISHER_H sl@0: sl@0: sl@0: // forward declaration sl@0: class CMassStorageDrive; sl@0: sl@0: typedef TFixedArray& TRefMsDriveList; sl@0: sl@0: typedef TFixedArray TBytesTransferedList; sl@0: sl@0: //---------------------------------------------------------------------------- sl@0: /** sl@0: @internalTechnology sl@0: sl@0: Publishes the EUsbMsDriveState_MediaError property. sl@0: */ sl@0: class RDriveMediaErrorPublisher sl@0: { sl@0: public: sl@0: RDriveMediaErrorPublisher(); sl@0: ~RDriveMediaErrorPublisher(); sl@0: sl@0: void PublishErrorL(TBool aError); sl@0: sl@0: private: sl@0: /** sl@0: Publish and subscribe property for EUsbMsDriveState_MediaError property sl@0: */ sl@0: RProperty iMediaErrorProperty; sl@0: }; sl@0: sl@0: //---------------------------------------------------------------------------- sl@0: /** sl@0: @internalTechnology sl@0: sl@0: Publishes the EUsbMsDriveState_DriveStatus property value for a drive state change. sl@0: The published drive state is mapped from the drive's mount state and drive state. sl@0: */ sl@0: sl@0: class RDriveStateChangedPublisher sl@0: { sl@0: public: sl@0: RDriveStateChangedPublisher(const TMsDriveList& aDrives, const TLunToDriveMap& aDriveMap); sl@0: ~RDriveStateChangedPublisher(); sl@0: void DriveStateChanged(); sl@0: sl@0: private: sl@0: /** sl@0: Reference to the array of drives. The index into the array is a LUN. sl@0: */ sl@0: const TMsDriveList& iDrives; sl@0: sl@0: /** sl@0: Reference to the drive map to convert LUN to Drive Number. sl@0: */ sl@0: const TLunToDriveMap& iDriveMap; sl@0: }; sl@0: sl@0: sl@0: //---------------------------------------------------------------------------- sl@0: // measure bytes transfered at the USB interface sl@0: //---------------------------------------------------------------------------- sl@0: sl@0: /** sl@0: @internalTechnology sl@0: sl@0: Base class for Read and Write publihsers. sl@0: */ sl@0: class CUsbTransferPublisher : public CBase sl@0: { sl@0: protected: sl@0: ~CUsbTransferPublisher(); sl@0: sl@0: CUsbTransferPublisher(TUsbMsDriveState_Subkey iSubKey, sl@0: const TBytesTransferedList& aBytesTransferred); sl@0: void ConstructL(); sl@0: sl@0: public: sl@0: void StartTimer(); sl@0: void StopTimer(); sl@0: void DoPublishDataTransferredEvent(); sl@0: sl@0: private: sl@0: TUint GetBytesTransferred(TLun aLun) const; sl@0: sl@0: // No of calls to wait without an data transfer from iTimer sl@0: // before stopping the publish timer. sl@0: enum {ETimerCancelDelay = 5}; sl@0: sl@0: static TInt PublishDataTransferredEvent(TAny* obj); sl@0: TBool PublishDataTransferred(); sl@0: sl@0: protected: sl@0: TUsbMsDriveState_Subkey iSubKey; sl@0: /** sl@0: Reference to the array of drives. The index into the array is a LUN. sl@0: */ sl@0: const TBytesTransferedList& iArray; sl@0: sl@0: /** sl@0: Publish and subscribe properties for tracking data transfer volume sl@0: */ sl@0: RProperty iProperty; sl@0: sl@0: private: sl@0: /** sl@0: An active object which triggers periodic updates to subscribers. sl@0: */ sl@0: CPeriodic* iTimer; sl@0: sl@0: /** sl@0: Set to ETrue when iTimer is running, EFalse otherwise sl@0: */ sl@0: TBool iTimerRunning; sl@0: sl@0: /** sl@0: Adds delay between data not being transferred and iTimer being cancelled sl@0: */ sl@0: TInt iTimerCancelCnt; sl@0: }; sl@0: sl@0: //---------------------------------------------------------------------------- sl@0: /** sl@0: @internalTechnology sl@0: sl@0: Publishes EUsbMsDriveState_KBytesWritten property values for tracking data transfer write volume. sl@0: */ sl@0: class CUsbWriteTransferPublisher: public CUsbTransferPublisher sl@0: { sl@0: public: sl@0: static CUsbWriteTransferPublisher* NewL(const TBytesTransferedList& aBytesTransferred); sl@0: sl@0: private: sl@0: CUsbWriteTransferPublisher(const TBytesTransferedList& aBytesTransferred); sl@0: }; sl@0: sl@0: //---------------------------------------------------------------------------- sl@0: /** sl@0: @internalTechnology sl@0: sl@0: Publishes EUsbMsDriveState_KBytesRead property value for tracking data transfer read volume. sl@0: */ sl@0: class CUsbReadTransferPublisher: public CUsbTransferPublisher sl@0: { sl@0: public: sl@0: static CUsbReadTransferPublisher* NewL(const TBytesTransferedList& aBytesTransferred); sl@0: sl@0: private: sl@0: CUsbReadTransferPublisher(const TBytesTransferedList& aBytesTransferred); sl@0: }; sl@0: sl@0: #endif //__DRIVEPUBLISHER_H__