os/kernelhwsrv/kerneltest/f32test/shostmassstorage/testclient/usbtestmsclient/inc/drivepublisher.h
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/f32test/shostmassstorage/testclient/usbtestmsclient/inc/drivepublisher.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,182 @@
1.4 +// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// Drive publishing classes for USB Mass Storage.
1.18 +// RDriveMediaErrorPublisher,
1.19 +// RDriveStateChangedPublisher,
1.20 +// CUsbTransferPublisher,
1.21 +// CUsbReadTransferPublisher,
1.22 +// CUsbReadTransferPublisher.
1.23 +//
1.24 +//
1.25 +
1.26 +
1.27 +
1.28 +/**
1.29 + @file
1.30 + @internalTechnology
1.31 +*/
1.32 +
1.33 +#ifndef DRIVEPUBLISHER_H
1.34 +#define DRIVEPUBLISHER_H
1.35 +
1.36 +
1.37 +// forward declaration
1.38 +class CMassStorageDrive;
1.39 +
1.40 +typedef TFixedArray<CMassStorageDrive*, KUsbMsMaxDrives>& TRefMsDriveList;
1.41 +
1.42 +typedef TFixedArray<TInt64, KUsbMsMaxDrives> TBytesTransferedList;
1.43 +
1.44 +//----------------------------------------------------------------------------
1.45 +/**
1.46 +@internalTechnology
1.47 +
1.48 +Publishes the EUsbMsDriveState_MediaError property.
1.49 +*/
1.50 +class RDriveMediaErrorPublisher
1.51 +{
1.52 +public:
1.53 + RDriveMediaErrorPublisher();
1.54 + ~RDriveMediaErrorPublisher();
1.55 +
1.56 + void PublishErrorL(TBool aError);
1.57 +
1.58 +private:
1.59 + /**
1.60 + Publish and subscribe property for EUsbMsDriveState_MediaError property
1.61 + */
1.62 + RProperty iMediaErrorProperty;
1.63 +};
1.64 +
1.65 +//----------------------------------------------------------------------------
1.66 +/**
1.67 +@internalTechnology
1.68 +
1.69 +Publishes the EUsbMsDriveState_DriveStatus property value for a drive state change.
1.70 +The published drive state is mapped from the drive's mount state and drive state.
1.71 +*/
1.72 +
1.73 +class RDriveStateChangedPublisher
1.74 +{
1.75 +public:
1.76 + RDriveStateChangedPublisher(const TMsDriveList& aDrives, const TLunToDriveMap& aDriveMap);
1.77 + ~RDriveStateChangedPublisher();
1.78 + void DriveStateChanged();
1.79 +
1.80 +private:
1.81 + /**
1.82 + Reference to the array of drives. The index into the array is a LUN.
1.83 + */
1.84 + const TMsDriveList& iDrives;
1.85 +
1.86 + /**
1.87 + Reference to the drive map to convert LUN to Drive Number.
1.88 + */
1.89 + const TLunToDriveMap& iDriveMap;
1.90 +};
1.91 +
1.92 +
1.93 +//----------------------------------------------------------------------------
1.94 +// measure bytes transfered at the USB interface
1.95 +//----------------------------------------------------------------------------
1.96 +
1.97 +/**
1.98 +@internalTechnology
1.99 +
1.100 +Base class for Read and Write publihsers.
1.101 +*/
1.102 +class CUsbTransferPublisher : public CBase
1.103 +{
1.104 +protected:
1.105 + ~CUsbTransferPublisher();
1.106 +
1.107 + CUsbTransferPublisher(TUsbMsDriveState_Subkey iSubKey,
1.108 + const TBytesTransferedList& aBytesTransferred);
1.109 + void ConstructL();
1.110 +
1.111 +public:
1.112 + void StartTimer();
1.113 + void StopTimer();
1.114 + void DoPublishDataTransferredEvent();
1.115 +
1.116 +private:
1.117 + TUint GetBytesTransferred(TLun aLun) const;
1.118 +
1.119 + // No of calls to wait without an data transfer from iTimer
1.120 + // before stopping the publish timer.
1.121 + enum {ETimerCancelDelay = 5};
1.122 +
1.123 + static TInt PublishDataTransferredEvent(TAny* obj);
1.124 + TBool PublishDataTransferred();
1.125 +
1.126 +protected:
1.127 + TUsbMsDriveState_Subkey iSubKey;
1.128 + /**
1.129 + Reference to the array of drives. The index into the array is a LUN.
1.130 + */
1.131 + const TBytesTransferedList& iArray;
1.132 +
1.133 + /**
1.134 + Publish and subscribe properties for tracking data transfer volume
1.135 + */
1.136 + RProperty iProperty;
1.137 +
1.138 +private:
1.139 + /**
1.140 + An active object which triggers periodic updates to subscribers.
1.141 + */
1.142 + CPeriodic* iTimer;
1.143 +
1.144 + /**
1.145 + Set to ETrue when iTimer is running, EFalse otherwise
1.146 + */
1.147 + TBool iTimerRunning;
1.148 +
1.149 + /**
1.150 + Adds delay between data not being transferred and iTimer being cancelled
1.151 + */
1.152 + TInt iTimerCancelCnt;
1.153 +};
1.154 +
1.155 +//----------------------------------------------------------------------------
1.156 +/**
1.157 +@internalTechnology
1.158 +
1.159 +Publishes EUsbMsDriveState_KBytesWritten property values for tracking data transfer write volume.
1.160 +*/
1.161 +class CUsbWriteTransferPublisher: public CUsbTransferPublisher
1.162 +{
1.163 +public:
1.164 + static CUsbWriteTransferPublisher* NewL(const TBytesTransferedList& aBytesTransferred);
1.165 +
1.166 +private:
1.167 + CUsbWriteTransferPublisher(const TBytesTransferedList& aBytesTransferred);
1.168 +};
1.169 +
1.170 +//----------------------------------------------------------------------------
1.171 +/**
1.172 +@internalTechnology
1.173 +
1.174 +Publishes EUsbMsDriveState_KBytesRead property value for tracking data transfer read volume.
1.175 +*/
1.176 +class CUsbReadTransferPublisher: public CUsbTransferPublisher
1.177 +{
1.178 +public:
1.179 + static CUsbReadTransferPublisher* NewL(const TBytesTransferedList& aBytesTransferred);
1.180 +
1.181 +private:
1.182 + CUsbReadTransferPublisher(const TBytesTransferedList& aBytesTransferred);
1.183 +};
1.184 +
1.185 +#endif //__DRIVEPUBLISHER_H__