First public contribution.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
25 #include <e32property.h> // RProperty
26 #include "usbmsshared.h" // TUsbMsBytesTransferred
27 #include <d32usbcsc.h>
30 typedef TUint TUsbDeviceState;
32 //-----------------------------------------------------------------------------
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.
37 class CFileSystemDescriptor : public CBase
40 ~CFileSystemDescriptor();
41 static CFileSystemDescriptor* NewL(const TDesC& aFsName, const TDesC& aPrimaryExtName, TBool aDrvSynch);
43 TPtrC FsName() const {return iFsName;}
44 TPtrC PrimaryExtName() const {return iPrimaryExtName;}
45 TBool DriveIsSynch() const {return iDriveSynch;}
48 CFileSystemDescriptor() {}
49 CFileSystemDescriptor(const CFileSystemDescriptor&);
50 CFileSystemDescriptor& operator=(const CFileSystemDescriptor&);
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
61 //-----------------------------------------------------------------------------
62 class PropertyHandlers
65 typedef void(*THandler)(RProperty&);
66 static TBuf8<16> allDrivesStatus;
67 static TUsbMsBytesTransferred iKBytesRead;
68 static TUsbMsBytesTransferred iKBytesWritten;
69 static TInt iMediaError;
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);
78 //-----------------------------------------------------------------------------
80 An active object that tracks changes to the KUsbMsDriveState properties
82 class CPropertyWatch : public CActive
85 static CPropertyWatch* NewLC(TUsbMsDriveState_Subkey aSubkey, PropertyHandlers::THandler aHandler);
87 CPropertyWatch(PropertyHandlers::THandler aHandler);
88 void ConstructL(TUsbMsDriveState_Subkey aSubkey);
94 PropertyHandlers::THandler iHandler;
97 //-----------------------------------------------------------------------------
99 An active object that tracks changes to the KUsbMsDriveState properties
101 class CUsbWatch : public CActive
104 static CUsbWatch* NewLC(TAny* aUsb);
106 CUsbWatch(TAny* aUsb);
113 TUsbDeviceState iUsbDeviceState;
114 TBool iWasConfigured;
117 //-----------------------------------------------------------------------------
118 class CMessageKeyProcessor : public CActive
121 static CMessageKeyProcessor* NewLC(CConsoleBase* aConsole);
122 static CMessageKeyProcessor* NewL(CConsoleBase* aConsole);
123 ~CMessageKeyProcessor();
127 void RequestCharacter();
129 // Defined as pure virtual by CActive;
130 // implementation provided by this class.
132 // Service completed request.
133 // Defined as pure virtual by CActive;
134 // implementation provided by this class,
136 // Called from RunL() to handle the completed request
137 void ProcessKeyPress(TChar aChar);
140 CMessageKeyProcessor(CConsoleBase* aConsole);
142 #ifndef USB_BOOT_LOADER
143 void MakePassword(TMediaPassword &aPassword);
145 CConsoleBase* iConsole; // A console for reading from