os/kernelhwsrv/kerneltest/e32utils/usbmsapp/usbmsapp.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2004-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
//
sl@0
    15
sl@0
    16
/**
sl@0
    17
 @file
sl@0
    18
 @internalComponent
sl@0
    19
*/
sl@0
    20
sl@0
    21
#ifndef USBMSAPP_H
sl@0
    22
#define USBMSAPP_H
sl@0
    23
sl@0
    24
#include <e32base.h>
sl@0
    25
#include <e32property.h>		// RProperty
sl@0
    26
#include "usbmsshared.h"		// TUsbMsBytesTransferred
sl@0
    27
#include <d32usbcsc.h>
sl@0
    28
#include <d32usbc.h>
sl@0
    29
sl@0
    30
typedef TUint TUsbDeviceState;
sl@0
    31
sl@0
    32
//-----------------------------------------------------------------------------
sl@0
    33
/**
sl@0
    34
    Class describing a file system mounted on the drive.
sl@0
    35
    It has a limitation: full list of possible FS extensions is not supported, only the primary one.
sl@0
    36
*/
sl@0
    37
class CFileSystemDescriptor : public CBase
sl@0
    38
    {
sl@0
    39
 public:
sl@0
    40
    ~CFileSystemDescriptor();    
sl@0
    41
    static CFileSystemDescriptor* NewL(const TDesC& aFsName, const TDesC& aPrimaryExtName, TBool aDrvSynch);
sl@0
    42
sl@0
    43
    TPtrC FsName() const            {return iFsName;}
sl@0
    44
    TPtrC PrimaryExtName() const    {return iPrimaryExtName;}
sl@0
    45
    TBool DriveIsSynch() const      {return iDriveSynch;}
sl@0
    46
sl@0
    47
 private:
sl@0
    48
    CFileSystemDescriptor() {}
sl@0
    49
    CFileSystemDescriptor(const CFileSystemDescriptor&);
sl@0
    50
    CFileSystemDescriptor& operator=(const CFileSystemDescriptor&);
sl@0
    51
 
sl@0
    52
 private:   
sl@0
    53
sl@0
    54
    RBuf    iFsName;        ///< file system name
sl@0
    55
    RBuf    iPrimaryExtName;///< name of the primary extension if present. Empty otherwise
sl@0
    56
    TBool   iDriveSynch;    ///< ETrue if the drive is synchronous
sl@0
    57
sl@0
    58
    };
sl@0
    59
    
sl@0
    60
sl@0
    61
//-----------------------------------------------------------------------------
sl@0
    62
class PropertyHandlers
sl@0
    63
	{
sl@0
    64
public:
sl@0
    65
	typedef void(*THandler)(RProperty&);
sl@0
    66
	static TBuf8<16> allDrivesStatus;
sl@0
    67
	static TUsbMsBytesTransferred iKBytesRead;
sl@0
    68
	static TUsbMsBytesTransferred iKBytesWritten;
sl@0
    69
	static TInt iMediaError;
sl@0
    70
sl@0
    71
	static void Transferred(RProperty& aProperty, TUsbMsBytesTransferred& aReadOrWritten);
sl@0
    72
	static void Read(RProperty& aProperty);
sl@0
    73
	static void Written(RProperty& aProperty);
sl@0
    74
	static void DriveStatus(RProperty& aProperty);
sl@0
    75
	static void MediaError(RProperty& aProperty);
sl@0
    76
	};
sl@0
    77
sl@0
    78
//-----------------------------------------------------------------------------
sl@0
    79
/**
sl@0
    80
An active object that tracks changes to the KUsbMsDriveState properties
sl@0
    81
*/
sl@0
    82
class CPropertyWatch : public CActive
sl@0
    83
	{
sl@0
    84
public:
sl@0
    85
	static CPropertyWatch* NewLC(TUsbMsDriveState_Subkey aSubkey, PropertyHandlers::THandler aHandler);
sl@0
    86
private:
sl@0
    87
	CPropertyWatch(PropertyHandlers::THandler aHandler);
sl@0
    88
	void ConstructL(TUsbMsDriveState_Subkey aSubkey);
sl@0
    89
	~CPropertyWatch();
sl@0
    90
	void RunL();
sl@0
    91
	void DoCancel();
sl@0
    92
	
sl@0
    93
	RProperty iProperty;
sl@0
    94
	PropertyHandlers::THandler iHandler;
sl@0
    95
	};
sl@0
    96
sl@0
    97
//-----------------------------------------------------------------------------
sl@0
    98
/**
sl@0
    99
An active object that tracks changes to the KUsbMsDriveState properties
sl@0
   100
*/
sl@0
   101
class CUsbWatch : public CActive
sl@0
   102
	{
sl@0
   103
public:
sl@0
   104
	static CUsbWatch* NewLC(TAny* aUsb);
sl@0
   105
private:
sl@0
   106
	CUsbWatch(TAny* aUsb);
sl@0
   107
	void ConstructL();
sl@0
   108
	~CUsbWatch();
sl@0
   109
	void RunL();
sl@0
   110
	void DoCancel();
sl@0
   111
sl@0
   112
	TAny* iUsb;
sl@0
   113
	TUsbDeviceState iUsbDeviceState;
sl@0
   114
	TBool iWasConfigured;
sl@0
   115
	};
sl@0
   116
sl@0
   117
//-----------------------------------------------------------------------------
sl@0
   118
class CMessageKeyProcessor : public CActive
sl@0
   119
	{
sl@0
   120
public:
sl@0
   121
	static CMessageKeyProcessor* NewLC(CConsoleBase* aConsole);
sl@0
   122
	static CMessageKeyProcessor* NewL(CConsoleBase* aConsole);
sl@0
   123
	~CMessageKeyProcessor();
sl@0
   124
sl@0
   125
public:
sl@0
   126
	// Issue request
sl@0
   127
	void RequestCharacter();
sl@0
   128
	// Cancel request.
sl@0
   129
	// Defined as pure virtual by CActive;
sl@0
   130
	// implementation provided by this class.
sl@0
   131
	void DoCancel();
sl@0
   132
	// Service completed request.
sl@0
   133
	// Defined as pure virtual by CActive;
sl@0
   134
	// implementation provided by this class,
sl@0
   135
	void RunL();
sl@0
   136
	// Called from RunL() to handle the completed request
sl@0
   137
	void ProcessKeyPress(TChar aChar);
sl@0
   138
sl@0
   139
private:
sl@0
   140
	CMessageKeyProcessor(CConsoleBase* aConsole);
sl@0
   141
	void ConstructL();
sl@0
   142
#ifndef USB_BOOT_LOADER
sl@0
   143
	void MakePassword(TMediaPassword &aPassword);
sl@0
   144
#endif
sl@0
   145
	CConsoleBase* iConsole; // A console for reading from
sl@0
   146
	};
sl@0
   147
sl@0
   148
sl@0
   149
sl@0
   150
sl@0
   151
sl@0
   152
sl@0
   153
#endif // USBMSAPP_H