Update contrib.
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Drive publishing classes for USB Mass Storage.
15 // RDriveMediaErrorPublisher,
16 // RDriveStateChangedPublisher,
17 // CDriveTransferPublisher,
18 // CDriveWriteTransferPublisher,
19 // CDriveReadTransferPublisher,
20 // CUsbTransferPublisher,
21 // CUsbReadTransferPublisher,
22 // CUsbReadTransferPublisher.
31 #ifndef __DRIVEPUBLISHER_H__
32 #define __DRIVEPUBLISHER_H__
34 #include <e32base.h> // C Class Definitions, Cleanup Stack
35 #include <e32def.h> // T Type Definitions
36 #include <e32property.h>
37 #include "usbmsshared.h" // Publish and subscribe property definitions
39 //#define USB_TRANSFER_PUBLISHER
40 #ifdef MSDC_MULTITHREADED
41 // Bytes transferred can be measured at the USB interface or the drive interface.
42 // Since read/write to the drive is performed by background threads we must publish
43 // the bytes transferred at the USB interface.
44 #ifndef USB_TRANSFER_PUBLISHER
45 #define USB_TRANSFER_PUBLISHER
49 // forward declaration
50 class CMassStorageDrive;
53 typedef TFixedArray<CMassStorageDrive*, KUsbMsMaxDrives>& TRefMsDriveList;
54 typedef const RArray<TInt>& TRefDriveMap;
56 typedef TFixedArray<TInt64, KUsbMsMaxDrives>& TRefBytesTransferedList;
58 //----------------------------------------------------------------------------
62 Publishes the EUsbMsDriveState_MediaError property.
64 class RDriveMediaErrorPublisher
67 RDriveMediaErrorPublisher();
68 ~RDriveMediaErrorPublisher();
70 void PublishError(TBool aError);
74 Publish and subscribe property for EUsbMsDriveState_MediaError property
76 RProperty iMediaErrorProperty;
79 //----------------------------------------------------------------------------
83 Publishes the EUsbMsDriveState_DriveStatus property value for a drive state change.
84 The published drive state is mapped from the drive's mount state and drive state.
87 class RDriveStateChangedPublisher
90 RDriveStateChangedPublisher(TRefMsDriveList aDrives, TRefDriveMap aDriveMap);
91 ~RDriveStateChangedPublisher();
92 void DriveStateChanged();
96 Reference to the array of drives. The index into the array is a LUN.
98 TRefMsDriveList iDrives;
101 Reference to the drive map to convert LUN to Drive Number.
103 TRefDriveMap iDriveMap;
106 #ifndef USB_TRANSFER_PUBLISHER
107 //----------------------------------------------------------------------------
108 // measure transfer of bytes at the drive interface
109 //----------------------------------------------------------------------------
114 Base class for Read and Write publihsers.
116 class CDriveTransferPublisher : public CBase
119 ~CDriveTransferPublisher();
121 CDriveTransferPublisher(TUsbMsDriveState_Subkey iSubKey,
122 TRefMsDriveList aDrives);
128 void DoPublishDataTransferredEvent();
131 virtual TUint GetBytesTransferred(TUint aLun) const = 0;
133 // No of calls to wait without an data transfer from iTimer
134 // before stopping the publish timer.
135 enum {ETimerCancelDelay = 5};
137 static TInt PublishDataTransferredEvent(TAny* obj);
138 TBool PublishDataTransferred();
141 TUsbMsDriveState_Subkey iSubKey;
143 Reference to the array of drives. The index into the array is a LUN.
145 TRefMsDriveList iDrives;
148 Publish and subscribe properties for tracking data transfer volume
154 An active object which triggers periodic updates to subscribers.
159 Set to ETrue when iTimer is running, EFalse otherwise
164 Adds delay between data not being transferred and iTimer being cancelled
166 TInt iTimerCancelCnt;
169 //----------------------------------------------------------------------------
173 Publishes EUsbMsDriveState_KBytesWritten property values for tracking data transfer write volume.
175 class CDriveWriteTransferPublisher: public CDriveTransferPublisher
178 static CDriveWriteTransferPublisher* NewL(TRefMsDriveList aDrives);
181 CDriveWriteTransferPublisher(TRefMsDriveList aDrives);
183 TUint GetBytesTransferred(TUint aLun) const;
187 //----------------------------------------------------------------------------
191 Publishes EUsbMsDriveState_KBytesRead property value for tracking data transfer read volume.
193 class CDriveReadTransferPublisher: public CDriveTransferPublisher
196 static CDriveReadTransferPublisher* NewL(TRefMsDriveList aDrives);
199 CDriveReadTransferPublisher(TRefMsDriveList aDrives);
201 TUint GetBytesTransferred(TUint aLun) const;
205 //----------------------------------------------------------------------------
206 // measure bytes transfered at the USB interface
207 //----------------------------------------------------------------------------
212 Base class for Read and Write publihsers.
214 class CUsbTransferPublisher : public CBase
217 ~CUsbTransferPublisher();
219 CUsbTransferPublisher(TUsbMsDriveState_Subkey iSubKey,
220 TRefBytesTransferedList aBytesTransferred);
226 void DoPublishDataTransferredEvent();
229 TUint GetBytesTransferred(TUint aLun) const;
231 // No of calls to wait without an data transfer from iTimer
232 // before stopping the publish timer.
233 enum {ETimerCancelDelay = 5};
235 static TInt PublishDataTransferredEvent(TAny* obj);
236 TBool PublishDataTransferred();
239 TUsbMsDriveState_Subkey iSubKey;
241 Reference to the array of drives. The index into the array is a LUN.
243 TRefBytesTransferedList iArray;
246 Publish and subscribe properties for tracking data transfer volume
252 An active object which triggers periodic updates to subscribers.
257 Set to ETrue when iTimer is running, EFalse otherwise
262 Adds delay between data not being transferred and iTimer being cancelled
264 TInt iTimerCancelCnt;
267 //----------------------------------------------------------------------------
271 Publishes EUsbMsDriveState_KBytesWritten property values for tracking data transfer write volume.
273 class CUsbWriteTransferPublisher: public CUsbTransferPublisher
276 static CUsbWriteTransferPublisher* NewL(TRefBytesTransferedList aBytesTransferred);
279 CUsbWriteTransferPublisher(TRefBytesTransferedList aBytesTransferred);
282 //----------------------------------------------------------------------------
286 Publishes EUsbMsDriveState_KBytesRead property value for tracking data transfer read volume.
288 class CUsbReadTransferPublisher: public CUsbTransferPublisher
291 static CUsbReadTransferPublisher* NewL(TRefBytesTransferedList aBytesTransferred);
294 CUsbReadTransferPublisher(TRefBytesTransferedList aBytesTransferred);
298 #endif //__DRIVEPUBLISHER_H__