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