os/kernelhwsrv/kerneltest/f32test/shostmassstorage/testclient/usbtestmsclient/inc/drivepublisher.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 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
// CUsbTransferPublisher,
sl@0
    18
// CUsbReadTransferPublisher,
sl@0
    19
// CUsbReadTransferPublisher.
sl@0
    20
// 
sl@0
    21
//
sl@0
    22
sl@0
    23
sl@0
    24
sl@0
    25
/**
sl@0
    26
 @file
sl@0
    27
 @internalTechnology
sl@0
    28
*/
sl@0
    29
sl@0
    30
#ifndef DRIVEPUBLISHER_H
sl@0
    31
#define DRIVEPUBLISHER_H
sl@0
    32
sl@0
    33
sl@0
    34
// forward declaration
sl@0
    35
class CMassStorageDrive;
sl@0
    36
sl@0
    37
typedef TFixedArray<CMassStorageDrive*, KUsbMsMaxDrives>& TRefMsDriveList;
sl@0
    38
sl@0
    39
typedef TFixedArray<TInt64, KUsbMsMaxDrives> TBytesTransferedList;
sl@0
    40
sl@0
    41
//----------------------------------------------------------------------------
sl@0
    42
/**
sl@0
    43
@internalTechnology
sl@0
    44
sl@0
    45
Publishes the EUsbMsDriveState_MediaError property.
sl@0
    46
*/
sl@0
    47
class RDriveMediaErrorPublisher
sl@0
    48
{
sl@0
    49
public:
sl@0
    50
	RDriveMediaErrorPublisher();
sl@0
    51
	~RDriveMediaErrorPublisher();
sl@0
    52
sl@0
    53
	void PublishErrorL(TBool aError);
sl@0
    54
sl@0
    55
private:
sl@0
    56
	/**
sl@0
    57
	Publish and subscribe property for EUsbMsDriveState_MediaError property
sl@0
    58
	*/
sl@0
    59
	RProperty iMediaErrorProperty;
sl@0
    60
};
sl@0
    61
sl@0
    62
//----------------------------------------------------------------------------
sl@0
    63
/**
sl@0
    64
@internalTechnology
sl@0
    65
sl@0
    66
Publishes the EUsbMsDriveState_DriveStatus property value for a drive state change.
sl@0
    67
The published drive state is mapped from the drive's mount state and drive state.
sl@0
    68
*/
sl@0
    69
sl@0
    70
class RDriveStateChangedPublisher
sl@0
    71
{
sl@0
    72
public:
sl@0
    73
	RDriveStateChangedPublisher(const TMsDriveList& aDrives, const TLunToDriveMap& aDriveMap);
sl@0
    74
	~RDriveStateChangedPublisher();
sl@0
    75
	void DriveStateChanged();
sl@0
    76
sl@0
    77
private:
sl@0
    78
	/**
sl@0
    79
	Reference to the array of drives. The index into the array is a LUN.
sl@0
    80
	*/
sl@0
    81
	const TMsDriveList& iDrives;
sl@0
    82
sl@0
    83
	/**
sl@0
    84
	Reference to the drive map to convert LUN to Drive Number.
sl@0
    85
	*/
sl@0
    86
	const TLunToDriveMap& iDriveMap;
sl@0
    87
};
sl@0
    88
sl@0
    89
sl@0
    90
//----------------------------------------------------------------------------
sl@0
    91
// measure bytes transfered at the USB interface
sl@0
    92
//----------------------------------------------------------------------------
sl@0
    93
sl@0
    94
/**
sl@0
    95
@internalTechnology
sl@0
    96
sl@0
    97
Base class for Read and Write publihsers.
sl@0
    98
*/
sl@0
    99
class CUsbTransferPublisher : public CBase
sl@0
   100
{
sl@0
   101
protected:
sl@0
   102
	~CUsbTransferPublisher();
sl@0
   103
sl@0
   104
	CUsbTransferPublisher(TUsbMsDriveState_Subkey iSubKey,
sl@0
   105
						  const TBytesTransferedList& aBytesTransferred);
sl@0
   106
	void ConstructL();
sl@0
   107
sl@0
   108
public:
sl@0
   109
	void StartTimer();
sl@0
   110
	void StopTimer();
sl@0
   111
	void DoPublishDataTransferredEvent();
sl@0
   112
sl@0
   113
private:
sl@0
   114
	TUint GetBytesTransferred(TLun aLun) const;
sl@0
   115
sl@0
   116
	// No of calls to wait without an data transfer from iTimer
sl@0
   117
	// before stopping the publish timer.
sl@0
   118
	enum {ETimerCancelDelay = 5};
sl@0
   119
sl@0
   120
	static TInt PublishDataTransferredEvent(TAny* obj);
sl@0
   121
	TBool PublishDataTransferred();
sl@0
   122
sl@0
   123
protected:
sl@0
   124
	TUsbMsDriveState_Subkey iSubKey;
sl@0
   125
	/**
sl@0
   126
	Reference to the array of drives. The index into the array is a LUN.
sl@0
   127
	*/
sl@0
   128
	const TBytesTransferedList& iArray;
sl@0
   129
sl@0
   130
	/**
sl@0
   131
	Publish and subscribe properties for tracking data transfer volume
sl@0
   132
	*/
sl@0
   133
	RProperty iProperty;
sl@0
   134
sl@0
   135
private:
sl@0
   136
	/**
sl@0
   137
	An active object which triggers periodic updates to subscribers.
sl@0
   138
	*/
sl@0
   139
	CPeriodic* iTimer;
sl@0
   140
sl@0
   141
	/**
sl@0
   142
	Set to ETrue when iTimer is running, EFalse otherwise
sl@0
   143
	*/
sl@0
   144
	TBool iTimerRunning;
sl@0
   145
sl@0
   146
	/**
sl@0
   147
	Adds delay between data not being transferred and iTimer being cancelled
sl@0
   148
	*/
sl@0
   149
	TInt iTimerCancelCnt;
sl@0
   150
};
sl@0
   151
sl@0
   152
//----------------------------------------------------------------------------
sl@0
   153
/**
sl@0
   154
@internalTechnology
sl@0
   155
sl@0
   156
Publishes EUsbMsDriveState_KBytesWritten property values for tracking data transfer write volume.
sl@0
   157
*/
sl@0
   158
class CUsbWriteTransferPublisher: public CUsbTransferPublisher
sl@0
   159
{
sl@0
   160
public:
sl@0
   161
	static CUsbWriteTransferPublisher* NewL(const TBytesTransferedList& aBytesTransferred);
sl@0
   162
sl@0
   163
private:
sl@0
   164
	CUsbWriteTransferPublisher(const TBytesTransferedList& aBytesTransferred);
sl@0
   165
};
sl@0
   166
sl@0
   167
//----------------------------------------------------------------------------
sl@0
   168
/**
sl@0
   169
@internalTechnology
sl@0
   170
sl@0
   171
Publishes EUsbMsDriveState_KBytesRead property value for tracking data transfer read volume.
sl@0
   172
*/
sl@0
   173
class CUsbReadTransferPublisher: public CUsbTransferPublisher
sl@0
   174
{
sl@0
   175
public:
sl@0
   176
	static CUsbReadTransferPublisher* NewL(const TBytesTransferedList& aBytesTransferred);
sl@0
   177
sl@0
   178
private:
sl@0
   179
	CUsbReadTransferPublisher(const TBytesTransferedList& aBytesTransferred);
sl@0
   180
};
sl@0
   181
sl@0
   182
#endif //__DRIVEPUBLISHER_H__