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