|
1 /* |
|
2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <e32base.h> |
|
19 #include <e32property.h> // RProperty |
|
20 #include <usbman.h> |
|
21 |
|
22 #include "usbmsshared.h" // TUsbMsBytesTransferred |
|
23 |
|
24 /** |
|
25 Class describing a file system mounted on the drive. |
|
26 It has a limitation: full list of possible FS extensions is not supported, only the primary one. |
|
27 */ |
|
28 NONSHARABLE_CLASS(CFileSystemDescriptor) : public CBase |
|
29 { |
|
30 public: |
|
31 ~CFileSystemDescriptor(); |
|
32 static CFileSystemDescriptor* NewL(const TDesC& aFsName, const TDesC& aPrimaryExtName, TBool aDrvSynch); |
|
33 |
|
34 TPtrC FsName() const {return iFsName;} |
|
35 TPtrC PrimaryExtName() const {return iPrimaryExtName;} |
|
36 TBool DriveIsSynch() const {return iDriveSynch;} |
|
37 |
|
38 |
|
39 private: |
|
40 CFileSystemDescriptor() {} |
|
41 |
|
42 private: |
|
43 RBuf iFsName; ///< file system name |
|
44 RBuf iPrimaryExtName;///< name of the primary extension if present. Empty otherwise |
|
45 TBool iDriveSynch; ///< ETrue if the drive is synchronous |
|
46 }; |
|
47 |
|
48 |
|
49 |
|
50 /** |
|
51 A set of static objects that hold the latest properties published by Mass Storage, |
|
52 and a set of corresponding static functions that process the publish events. |
|
53 The functions are passed by pointer to, and invoked by, CPropertyWatch instances. |
|
54 */ |
|
55 NONSHARABLE_CLASS(PropertyHandlers) { |
|
56 public: |
|
57 /** The prototype for all public property handler functions */ |
|
58 typedef void(*THandler)(RProperty&); |
|
59 |
|
60 public: |
|
61 static void Read(RProperty& aProperty); |
|
62 static void Written(RProperty& aProperty); |
|
63 static void DriveStatus(RProperty& aProperty); |
|
64 private: |
|
65 static void Transferred(RProperty& aProperty, TUsbMsBytesTransferred& aReadOrWritten); |
|
66 |
|
67 public: |
|
68 static TBuf8<16> allDrivesStatus; |
|
69 static TUsbMsBytesTransferred iKBytesRead; |
|
70 static TUsbMsBytesTransferred iKBytesWritten; |
|
71 }; |
|
72 |
|
73 /** |
|
74 An active object that subscribes to a specified Mass Storage property and |
|
75 calls a provided handler each time the property is published. |
|
76 */ |
|
77 NONSHARABLE_CLASS(CPropertyWatch) : public CActive |
|
78 { |
|
79 public: |
|
80 static CPropertyWatch* NewLC(TUsbMsDriveState_Subkey aSubkey, PropertyHandlers::THandler aHandler); |
|
81 private: |
|
82 CPropertyWatch(PropertyHandlers::THandler aHandler); |
|
83 void ConstructL(TUsbMsDriveState_Subkey aSubkey); |
|
84 ~CPropertyWatch(); |
|
85 void RunL(); |
|
86 void DoCancel(); |
|
87 |
|
88 RProperty iProperty; |
|
89 PropertyHandlers::THandler iHandler; |
|
90 }; |
|
91 |
|
92 /** |
|
93 An active object that handles changes to the KUsbMsDriveState properties. |
|
94 */ |
|
95 NONSHARABLE_CLASS(CUsbWatch) : public CActive |
|
96 { |
|
97 public: |
|
98 static CUsbWatch* NewLC(RUsb& aUsb); |
|
99 private: |
|
100 CUsbWatch(RUsb& aUsb); |
|
101 void ConstructL(); |
|
102 ~CUsbWatch(); |
|
103 void RunL(); |
|
104 void DoCancel(); |
|
105 |
|
106 private: |
|
107 RUsb& iUsb; |
|
108 TUsbDeviceState iUsbDeviceState; |
|
109 TBool iIsConfigured; |
|
110 }; |
|
111 |
|
112 /** |
|
113 An active object for handling user menu selections. |
|
114 */ |
|
115 NONSHARABLE_CLASS(CMessageKeyProcessor) : public CActive |
|
116 { |
|
117 public: |
|
118 static CMessageKeyProcessor* NewLC(CConsoleBase* aConsole); |
|
119 static CMessageKeyProcessor* NewL(CConsoleBase* aConsole); |
|
120 ~CMessageKeyProcessor(); |
|
121 |
|
122 public: |
|
123 // Issue request |
|
124 void RequestCharacter(); |
|
125 // Cancel request. |
|
126 // Defined as pure virtual by CActive; |
|
127 // implementation provided by this class. |
|
128 void DoCancel(); |
|
129 // Service completed request. |
|
130 // Defined as pure virtual by CActive; |
|
131 // implementation provided by this class, |
|
132 void RunL(); |
|
133 // Called from RunL() to handle the completed request |
|
134 void ProcessKeyPress(TChar aChar); |
|
135 |
|
136 private: |
|
137 CMessageKeyProcessor(CConsoleBase* aConsole); |
|
138 void ConstructL(); |
|
139 |
|
140 private: |
|
141 CConsoleBase* iConsole; // A console for reading from |
|
142 }; |
|
143 |
|
144 |
|
145 |