sl@0
|
1 |
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// Drive publishing classes for USB Mass Storage.
|
sl@0
|
15 |
// RDriveMediaErrorPublisher,
|
sl@0
|
16 |
// RDriveStateChangedPublisher,
|
sl@0
|
17 |
// CDriveTransferPublisher,
|
sl@0
|
18 |
// CDriveWriteTransferPublisher,
|
sl@0
|
19 |
// CDriveReadTransferPublisher,
|
sl@0
|
20 |
// CUsbTransferPublisher,
|
sl@0
|
21 |
// CUsbReadTransferPublisher,
|
sl@0
|
22 |
// CUsbReadTransferPublisher.
|
sl@0
|
23 |
//
|
sl@0
|
24 |
//
|
sl@0
|
25 |
|
sl@0
|
26 |
/**
|
sl@0
|
27 |
@file
|
sl@0
|
28 |
@internalTechnology
|
sl@0
|
29 |
*/
|
sl@0
|
30 |
|
sl@0
|
31 |
#ifndef __DRIVEPUBLISHER_H__
|
sl@0
|
32 |
#define __DRIVEPUBLISHER_H__
|
sl@0
|
33 |
|
sl@0
|
34 |
#include <e32base.h> // C Class Definitions, Cleanup Stack
|
sl@0
|
35 |
#include <e32def.h> // T Type Definitions
|
sl@0
|
36 |
#include <e32property.h>
|
sl@0
|
37 |
#include "usbmsshared.h" // Publish and subscribe property definitions
|
sl@0
|
38 |
|
sl@0
|
39 |
//#define USB_TRANSFER_PUBLISHER
|
sl@0
|
40 |
#ifdef MSDC_MULTITHREADED
|
sl@0
|
41 |
// Bytes transferred can be measured at the USB interface or the drive interface.
|
sl@0
|
42 |
// Since read/write to the drive is performed by background threads we must publish
|
sl@0
|
43 |
// the bytes transferred at the USB interface.
|
sl@0
|
44 |
#ifndef USB_TRANSFER_PUBLISHER
|
sl@0
|
45 |
#define USB_TRANSFER_PUBLISHER
|
sl@0
|
46 |
#endif
|
sl@0
|
47 |
#endif
|
sl@0
|
48 |
|
sl@0
|
49 |
// forward declaration
|
sl@0
|
50 |
class CMassStorageDrive;
|
sl@0
|
51 |
|
sl@0
|
52 |
// typedefs
|
sl@0
|
53 |
typedef TFixedArray<CMassStorageDrive*, KUsbMsMaxDrives>& TRefMsDriveList;
|
sl@0
|
54 |
typedef const RArray<TInt>& TRefDriveMap;
|
sl@0
|
55 |
|
sl@0
|
56 |
typedef TFixedArray<TInt64, KUsbMsMaxDrives>& TRefBytesTransferedList;
|
sl@0
|
57 |
|
sl@0
|
58 |
//----------------------------------------------------------------------------
|
sl@0
|
59 |
/**
|
sl@0
|
60 |
@internalTechnology
|
sl@0
|
61 |
|
sl@0
|
62 |
Publishes the EUsbMsDriveState_MediaError property.
|
sl@0
|
63 |
*/
|
sl@0
|
64 |
class RDriveMediaErrorPublisher
|
sl@0
|
65 |
{
|
sl@0
|
66 |
public:
|
sl@0
|
67 |
RDriveMediaErrorPublisher();
|
sl@0
|
68 |
~RDriveMediaErrorPublisher();
|
sl@0
|
69 |
|
sl@0
|
70 |
void PublishError(TBool aError);
|
sl@0
|
71 |
|
sl@0
|
72 |
private:
|
sl@0
|
73 |
/**
|
sl@0
|
74 |
Publish and subscribe property for EUsbMsDriveState_MediaError property
|
sl@0
|
75 |
*/
|
sl@0
|
76 |
RProperty iMediaErrorProperty;
|
sl@0
|
77 |
};
|
sl@0
|
78 |
|
sl@0
|
79 |
//----------------------------------------------------------------------------
|
sl@0
|
80 |
/**
|
sl@0
|
81 |
@internalTechnology
|
sl@0
|
82 |
|
sl@0
|
83 |
Publishes the EUsbMsDriveState_DriveStatus property value for a drive state change.
|
sl@0
|
84 |
The published drive state is mapped from the drive's mount state and drive state.
|
sl@0
|
85 |
*/
|
sl@0
|
86 |
|
sl@0
|
87 |
class RDriveStateChangedPublisher
|
sl@0
|
88 |
{
|
sl@0
|
89 |
public:
|
sl@0
|
90 |
RDriveStateChangedPublisher(TRefMsDriveList aDrives, TRefDriveMap aDriveMap);
|
sl@0
|
91 |
~RDriveStateChangedPublisher();
|
sl@0
|
92 |
void DriveStateChanged();
|
sl@0
|
93 |
|
sl@0
|
94 |
private:
|
sl@0
|
95 |
/**
|
sl@0
|
96 |
Reference to the array of drives. The index into the array is a LUN.
|
sl@0
|
97 |
*/
|
sl@0
|
98 |
TRefMsDriveList iDrives;
|
sl@0
|
99 |
|
sl@0
|
100 |
/**
|
sl@0
|
101 |
Reference to the drive map to convert LUN to Drive Number.
|
sl@0
|
102 |
*/
|
sl@0
|
103 |
TRefDriveMap iDriveMap;
|
sl@0
|
104 |
};
|
sl@0
|
105 |
|
sl@0
|
106 |
#ifndef USB_TRANSFER_PUBLISHER
|
sl@0
|
107 |
//----------------------------------------------------------------------------
|
sl@0
|
108 |
// measure transfer of bytes at the drive interface
|
sl@0
|
109 |
//----------------------------------------------------------------------------
|
sl@0
|
110 |
|
sl@0
|
111 |
/**
|
sl@0
|
112 |
@internalTechnology
|
sl@0
|
113 |
|
sl@0
|
114 |
Base class for Read and Write publihsers.
|
sl@0
|
115 |
*/
|
sl@0
|
116 |
class CDriveTransferPublisher : public CBase
|
sl@0
|
117 |
{
|
sl@0
|
118 |
protected:
|
sl@0
|
119 |
~CDriveTransferPublisher();
|
sl@0
|
120 |
|
sl@0
|
121 |
CDriveTransferPublisher(TUsbMsDriveState_Subkey iSubKey,
|
sl@0
|
122 |
TRefMsDriveList aDrives);
|
sl@0
|
123 |
void ConstructL();
|
sl@0
|
124 |
|
sl@0
|
125 |
public:
|
sl@0
|
126 |
void StartTimer();
|
sl@0
|
127 |
void StopTimer();
|
sl@0
|
128 |
void DoPublishDataTransferredEvent();
|
sl@0
|
129 |
|
sl@0
|
130 |
private:
|
sl@0
|
131 |
virtual TUint GetBytesTransferred(TUint aLun) const = 0;
|
sl@0
|
132 |
|
sl@0
|
133 |
// No of calls to wait without an data transfer from iTimer
|
sl@0
|
134 |
// before stopping the publish timer.
|
sl@0
|
135 |
enum {ETimerCancelDelay = 5};
|
sl@0
|
136 |
|
sl@0
|
137 |
static TInt PublishDataTransferredEvent(TAny* obj);
|
sl@0
|
138 |
TBool PublishDataTransferred();
|
sl@0
|
139 |
|
sl@0
|
140 |
protected:
|
sl@0
|
141 |
TUsbMsDriveState_Subkey iSubKey;
|
sl@0
|
142 |
/**
|
sl@0
|
143 |
Reference to the array of drives. The index into the array is a LUN.
|
sl@0
|
144 |
*/
|
sl@0
|
145 |
TRefMsDriveList iDrives;
|
sl@0
|
146 |
|
sl@0
|
147 |
/**
|
sl@0
|
148 |
Publish and subscribe properties for tracking data transfer volume
|
sl@0
|
149 |
*/
|
sl@0
|
150 |
RProperty iProperty;
|
sl@0
|
151 |
|
sl@0
|
152 |
private:
|
sl@0
|
153 |
/**
|
sl@0
|
154 |
An active object which triggers periodic updates to subscribers.
|
sl@0
|
155 |
*/
|
sl@0
|
156 |
CPeriodic* iTimer;
|
sl@0
|
157 |
|
sl@0
|
158 |
/**
|
sl@0
|
159 |
Set to ETrue when iTimer is running, EFalse otherwise
|
sl@0
|
160 |
*/
|
sl@0
|
161 |
TBool iTimerRunning;
|
sl@0
|
162 |
|
sl@0
|
163 |
/**
|
sl@0
|
164 |
Adds delay between data not being transferred and iTimer being cancelled
|
sl@0
|
165 |
*/
|
sl@0
|
166 |
TInt iTimerCancelCnt;
|
sl@0
|
167 |
};
|
sl@0
|
168 |
|
sl@0
|
169 |
//----------------------------------------------------------------------------
|
sl@0
|
170 |
/**
|
sl@0
|
171 |
@internalTechnology
|
sl@0
|
172 |
|
sl@0
|
173 |
Publishes EUsbMsDriveState_KBytesWritten property values for tracking data transfer write volume.
|
sl@0
|
174 |
*/
|
sl@0
|
175 |
class CDriveWriteTransferPublisher: public CDriveTransferPublisher
|
sl@0
|
176 |
{
|
sl@0
|
177 |
public:
|
sl@0
|
178 |
static CDriveWriteTransferPublisher* NewL(TRefMsDriveList aDrives);
|
sl@0
|
179 |
|
sl@0
|
180 |
private:
|
sl@0
|
181 |
CDriveWriteTransferPublisher(TRefMsDriveList aDrives);
|
sl@0
|
182 |
|
sl@0
|
183 |
TUint GetBytesTransferred(TUint aLun) const;
|
sl@0
|
184 |
};
|
sl@0
|
185 |
|
sl@0
|
186 |
|
sl@0
|
187 |
//----------------------------------------------------------------------------
|
sl@0
|
188 |
/**
|
sl@0
|
189 |
@internalTechnology
|
sl@0
|
190 |
|
sl@0
|
191 |
Publishes EUsbMsDriveState_KBytesRead property value for tracking data transfer read volume.
|
sl@0
|
192 |
*/
|
sl@0
|
193 |
class CDriveReadTransferPublisher: public CDriveTransferPublisher
|
sl@0
|
194 |
{
|
sl@0
|
195 |
public:
|
sl@0
|
196 |
static CDriveReadTransferPublisher* NewL(TRefMsDriveList aDrives);
|
sl@0
|
197 |
|
sl@0
|
198 |
private:
|
sl@0
|
199 |
CDriveReadTransferPublisher(TRefMsDriveList aDrives);
|
sl@0
|
200 |
|
sl@0
|
201 |
TUint GetBytesTransferred(TUint aLun) const;
|
sl@0
|
202 |
};
|
sl@0
|
203 |
|
sl@0
|
204 |
#else
|
sl@0
|
205 |
//----------------------------------------------------------------------------
|
sl@0
|
206 |
// measure bytes transfered at the USB interface
|
sl@0
|
207 |
//----------------------------------------------------------------------------
|
sl@0
|
208 |
|
sl@0
|
209 |
/**
|
sl@0
|
210 |
@internalTechnology
|
sl@0
|
211 |
|
sl@0
|
212 |
Base class for Read and Write publihsers.
|
sl@0
|
213 |
*/
|
sl@0
|
214 |
class CUsbTransferPublisher : public CBase
|
sl@0
|
215 |
{
|
sl@0
|
216 |
protected:
|
sl@0
|
217 |
~CUsbTransferPublisher();
|
sl@0
|
218 |
|
sl@0
|
219 |
CUsbTransferPublisher(TUsbMsDriveState_Subkey iSubKey,
|
sl@0
|
220 |
TRefBytesTransferedList aBytesTransferred);
|
sl@0
|
221 |
void ConstructL();
|
sl@0
|
222 |
|
sl@0
|
223 |
public:
|
sl@0
|
224 |
void StartTimer();
|
sl@0
|
225 |
void StopTimer();
|
sl@0
|
226 |
void DoPublishDataTransferredEvent();
|
sl@0
|
227 |
|
sl@0
|
228 |
private:
|
sl@0
|
229 |
TUint GetBytesTransferred(TUint aLun) const;
|
sl@0
|
230 |
|
sl@0
|
231 |
// No of calls to wait without an data transfer from iTimer
|
sl@0
|
232 |
// before stopping the publish timer.
|
sl@0
|
233 |
enum {ETimerCancelDelay = 5};
|
sl@0
|
234 |
|
sl@0
|
235 |
static TInt PublishDataTransferredEvent(TAny* obj);
|
sl@0
|
236 |
TBool PublishDataTransferred();
|
sl@0
|
237 |
|
sl@0
|
238 |
protected:
|
sl@0
|
239 |
TUsbMsDriveState_Subkey iSubKey;
|
sl@0
|
240 |
/**
|
sl@0
|
241 |
Reference to the array of drives. The index into the array is a LUN.
|
sl@0
|
242 |
*/
|
sl@0
|
243 |
TRefBytesTransferedList iArray;
|
sl@0
|
244 |
|
sl@0
|
245 |
/**
|
sl@0
|
246 |
Publish and subscribe properties for tracking data transfer volume
|
sl@0
|
247 |
*/
|
sl@0
|
248 |
RProperty iProperty;
|
sl@0
|
249 |
|
sl@0
|
250 |
private:
|
sl@0
|
251 |
/**
|
sl@0
|
252 |
An active object which triggers periodic updates to subscribers.
|
sl@0
|
253 |
*/
|
sl@0
|
254 |
CPeriodic* iTimer;
|
sl@0
|
255 |
|
sl@0
|
256 |
/**
|
sl@0
|
257 |
Set to ETrue when iTimer is running, EFalse otherwise
|
sl@0
|
258 |
*/
|
sl@0
|
259 |
TBool iTimerRunning;
|
sl@0
|
260 |
|
sl@0
|
261 |
/**
|
sl@0
|
262 |
Adds delay between data not being transferred and iTimer being cancelled
|
sl@0
|
263 |
*/
|
sl@0
|
264 |
TInt iTimerCancelCnt;
|
sl@0
|
265 |
};
|
sl@0
|
266 |
|
sl@0
|
267 |
//----------------------------------------------------------------------------
|
sl@0
|
268 |
/**
|
sl@0
|
269 |
@internalTechnology
|
sl@0
|
270 |
|
sl@0
|
271 |
Publishes EUsbMsDriveState_KBytesWritten property values for tracking data transfer write volume.
|
sl@0
|
272 |
*/
|
sl@0
|
273 |
class CUsbWriteTransferPublisher: public CUsbTransferPublisher
|
sl@0
|
274 |
{
|
sl@0
|
275 |
public:
|
sl@0
|
276 |
static CUsbWriteTransferPublisher* NewL(TRefBytesTransferedList aBytesTransferred);
|
sl@0
|
277 |
|
sl@0
|
278 |
private:
|
sl@0
|
279 |
CUsbWriteTransferPublisher(TRefBytesTransferedList aBytesTransferred);
|
sl@0
|
280 |
};
|
sl@0
|
281 |
|
sl@0
|
282 |
//----------------------------------------------------------------------------
|
sl@0
|
283 |
/**
|
sl@0
|
284 |
@internalTechnology
|
sl@0
|
285 |
|
sl@0
|
286 |
Publishes EUsbMsDriveState_KBytesRead property value for tracking data transfer read volume.
|
sl@0
|
287 |
*/
|
sl@0
|
288 |
class CUsbReadTransferPublisher: public CUsbTransferPublisher
|
sl@0
|
289 |
{
|
sl@0
|
290 |
public:
|
sl@0
|
291 |
static CUsbReadTransferPublisher* NewL(TRefBytesTransferedList aBytesTransferred);
|
sl@0
|
292 |
|
sl@0
|
293 |
private:
|
sl@0
|
294 |
CUsbReadTransferPublisher(TRefBytesTransferedList aBytesTransferred);
|
sl@0
|
295 |
};
|
sl@0
|
296 |
#endif
|
sl@0
|
297 |
|
sl@0
|
298 |
#endif //__DRIVEPUBLISHER_H__
|