35
|
1 |
/*
|
|
2 |
* Copyright (c) 2006-2010 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: Header file for class CUsbActiveMscHandler
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#ifndef C_CUSBACTIVEMSCHANDLER_H
|
|
20 |
#define C_CUSBACTIVEMSCHANDLER_H
|
|
21 |
|
|
22 |
#include <usbmsshared.h> // for P&S used in following MMC states
|
|
23 |
#include <f32file.h> // for file system dismounting and mounting
|
|
24 |
#include <usb.h>
|
|
25 |
#include <e32property.h>
|
|
26 |
#include <usbuinotif.h>
|
|
27 |
#include <cusbpersonalitynotifier.h>
|
|
28 |
#include <cusbpersonalityplugin.h>
|
|
29 |
|
|
30 |
// FORWARD DECLARATIONS
|
|
31 |
class CUsbActivePowerManager;
|
|
32 |
class CUsbMscPersonalityTimer;
|
|
33 |
class CRepository;
|
|
34 |
class CDevEncSessionBase;
|
|
35 |
|
|
36 |
/**
|
|
37 |
* Define system state categories used internally by Msc personality plugin
|
|
38 |
*/
|
|
39 |
enum TUsbGlobalSystemState
|
|
40 |
{
|
|
41 |
EUsbGSStateUnknown = -1,
|
|
42 |
EUsbGSStateCategoryNormal, //rfOn, rfOff, BTSAP
|
|
43 |
EUsbGSStateCharging
|
|
44 |
};
|
|
45 |
|
|
46 |
/**
|
|
47 |
* The file system mounted to the drive.
|
|
48 |
*/
|
|
49 |
enum TUsbFileSystem
|
|
50 |
{
|
|
51 |
EFsyNone = 0, //no file system mounted
|
|
52 |
EFsyMassStorage,
|
|
53 |
EFsyFat
|
|
54 |
};
|
|
55 |
|
|
56 |
/**
|
|
57 |
* Class to handle Mass Storage personality (= MSDC).
|
|
58 |
*
|
|
59 |
* @lib euser.lib c32.lib efsrv.lib
|
|
60 |
* @since Series 60 3.0
|
|
61 |
*/
|
|
62 |
class CUsbActiveMscHandler : public CUsbPersonalityPlugin
|
|
63 |
{
|
|
64 |
public: // Constructors and destructor
|
|
65 |
|
|
66 |
/**
|
|
67 |
* Two-phased constructor.
|
|
68 |
*
|
|
69 |
* @param aPersonalityParams Reference to container class
|
|
70 |
* @return Pointer to created object.
|
|
71 |
*/
|
|
72 |
static CUsbActiveMscHandler* NewL(TUsbPersonalityParams& aPersonalityParams);
|
|
73 |
|
|
74 |
/**
|
|
75 |
* Destructor.
|
|
76 |
*/
|
|
77 |
virtual ~CUsbActiveMscHandler();
|
|
78 |
|
|
79 |
public: // From base classes CActive
|
|
80 |
|
|
81 |
/**
|
|
82 |
* From CActive.
|
|
83 |
* Implements state machine for this class.
|
|
84 |
*
|
|
85 |
* @since Series 60 3.0
|
|
86 |
*/
|
|
87 |
void RunL();
|
|
88 |
|
|
89 |
/**
|
|
90 |
* From CActive.
|
|
91 |
* Never called in this implementation.
|
|
92 |
*
|
|
93 |
* @since Series 60 3.0
|
|
94 |
* @param aError the error returned
|
|
95 |
* @return error
|
|
96 |
*/
|
|
97 |
TInt RunError( TInt /*aError*/ );
|
|
98 |
|
|
99 |
/**
|
|
100 |
* From CActive.
|
|
101 |
* Cancel outstanding request.
|
|
102 |
*
|
|
103 |
* @since Series 60 3.0
|
|
104 |
*/
|
|
105 |
void DoCancel();
|
|
106 |
|
|
107 |
public: // From base class CUsbPersonality
|
|
108 |
|
|
109 |
/**
|
|
110 |
* From CUsbPersonality
|
|
111 |
* Confirm unload in case of personality change
|
|
112 |
* if msc state is active.
|
|
113 |
*
|
|
114 |
* @since S60 3.0
|
|
115 |
* @param aStatus Status of the ended operation.
|
|
116 |
*/
|
|
117 |
virtual void ConfirmPersonalityUnload(TRequestStatus& aStatus);
|
|
118 |
|
|
119 |
/**
|
|
120 |
* From CUsbPersonality
|
|
121 |
* Called by personality handler when personality start needs to be
|
|
122 |
* prepared.
|
|
123 |
*
|
|
124 |
* @since Series 60 3.0
|
|
125 |
* @param aStatus Status of the ended operation.
|
|
126 |
*/
|
|
127 |
virtual void PreparePersonalityStart(TRequestStatus& aStatus);
|
|
128 |
|
|
129 |
/**
|
|
130 |
* From CUsbPersonality
|
|
131 |
* Called by personality handler when personality start needs to be
|
|
132 |
* finished. Calls DoFinishPersonalityStartL() and provides error
|
|
133 |
* handling for it.
|
|
134 |
*
|
|
135 |
* @since Series 60 3.0
|
|
136 |
* @param aStatus Status of the ended operation.
|
|
137 |
*/
|
|
138 |
virtual void FinishPersonalityStart(TRequestStatus& aStatus);
|
|
139 |
|
|
140 |
/**
|
|
141 |
* From CUsbPersonality
|
|
142 |
* Called by personality handler when personality stop needs to be
|
|
143 |
* prepared. For this personality: Remounts FAT File System and
|
|
144 |
* dismounts Mass Storage File System, Switch back from offline mode.
|
|
145 |
*
|
|
146 |
* @since Series 60 3.0
|
|
147 |
* @param aStatus Status of the ended operation.
|
|
148 |
*/
|
|
149 |
virtual void PreparePersonalityStop(TRequestStatus& aStatus);
|
|
150 |
|
|
151 |
/**
|
|
152 |
* From CUsbPersonality
|
|
153 |
* Called by personality handler when personality stop needs to be
|
|
154 |
* finished. Calls DoFinishPersonalityStopL() and provides error
|
|
155 |
* handling for it.
|
|
156 |
*
|
|
157 |
* @since Series 60 3.0
|
|
158 |
* @param aStatus Status of the ended operation.
|
|
159 |
*/
|
|
160 |
virtual void FinishPersonalityStop(TRequestStatus& aStatus);
|
|
161 |
|
|
162 |
/**
|
|
163 |
* From CUsbPersonality
|
|
164 |
* State change notify
|
|
165 |
*
|
|
166 |
* @since Series 60 3.0
|
|
167 |
* @param aState state of the device
|
|
168 |
*/
|
|
169 |
virtual void StateChangeNotify( TUsbDeviceState aState );
|
|
170 |
|
|
171 |
public:
|
|
172 |
|
|
173 |
/**
|
|
174 |
* If dismount timer expires, this callback is called.
|
|
175 |
*
|
|
176 |
* @since Series 60 3.2
|
|
177 |
* @param aPtr Pointer to this class
|
|
178 |
* @return KErrNone is always returned
|
|
179 |
*/
|
|
180 |
static TInt DismountFatCallBack(TAny* aPtr);
|
|
181 |
|
|
182 |
private:
|
|
183 |
|
|
184 |
/**
|
|
185 |
* Does the forced dismount.
|
|
186 |
*
|
|
187 |
* @since Series 60 3.2
|
|
188 |
*/
|
|
189 |
void ForciblyDismountFat();
|
|
190 |
|
|
191 |
/**
|
|
192 |
* Complete owner class request if any.
|
|
193 |
*
|
|
194 |
* @since Series 60 3.2
|
|
195 |
*/
|
|
196 |
void CompleteRequest(TInt aError);
|
|
197 |
|
|
198 |
/**
|
|
199 |
* Start dismounting FAT from the drives
|
|
200 |
* Also mounts mass storage file system, when all FATs dismounted.
|
|
201 |
*
|
|
202 |
* @since Series 60 5.0
|
|
203 |
*/
|
|
204 |
void StartDismountFat();
|
|
205 |
|
|
206 |
/**
|
|
207 |
* Add mass storage file system.
|
|
208 |
*
|
|
209 |
* @return KErrNone if successful or already added
|
|
210 |
* @since Series 60 3.2
|
|
211 |
*/
|
|
212 |
TInt AddMassStorageFileSystem();
|
|
213 |
|
|
214 |
/**
|
|
215 |
* Remove mass storage file system.
|
|
216 |
*
|
|
217 |
* @since Series 60 5.0
|
|
218 |
*/
|
|
219 |
void RemoveMassStorageFileSystem();
|
|
220 |
|
|
221 |
/**
|
|
222 |
* Mount mass storage to all the drives
|
|
223 |
* The mass storage is mounted to all the drives in normal global
|
|
224 |
* system state. If device is not locked, the drives are mounted also in
|
|
225 |
* charging global system state.
|
|
226 |
*/
|
|
227 |
void MountMassStorage();
|
|
228 |
|
|
229 |
/**
|
|
230 |
* Returns drives with available MMC card.
|
|
231 |
* @param aDrivesWithMmcInserted Array to which result should be written
|
|
232 |
*/
|
|
233 |
TInt GetDrives();
|
|
234 |
|
|
235 |
/**
|
|
236 |
* Dismounts FAT File System from the drive.
|
|
237 |
* @param aDrive Drive from which dismounting should be done
|
|
238 |
*/
|
|
239 |
void DismountFat( TInt aDrive );
|
|
240 |
|
|
241 |
/**
|
|
242 |
* Mounts Mass Storage File System into the drive.
|
|
243 |
* @param aDrive Drive to which mounting should be done
|
|
244 |
* @return error
|
|
245 |
*/
|
|
246 |
TInt TryMountMassStorage( TInt aDrive );
|
|
247 |
|
|
248 |
/**
|
|
249 |
* Dismounts Mass Storage File System from the drive.
|
|
250 |
* @param aDrive The drive for the dismount
|
|
251 |
* @return error
|
|
252 |
*/
|
|
253 |
TInt TryDismountMassStorage( TInt aDrive );
|
|
254 |
|
|
255 |
/**
|
|
256 |
* Mounts FAT File System to the drive.
|
|
257 |
* @param aDrive The drive for the mount
|
|
258 |
* @return error
|
|
259 |
*/
|
|
260 |
TInt TryMountFat( TInt aDrive );
|
|
261 |
|
|
262 |
/**
|
|
263 |
* C++ constructor
|
|
264 |
*/
|
|
265 |
CUsbActiveMscHandler(TUsbPersonalityParams& aPersonalityParams);
|
|
266 |
|
|
267 |
/**
|
|
268 |
* By default Symbian 2nd phase constructor is private.
|
|
269 |
*/
|
|
270 |
void ConstructL();
|
|
271 |
|
|
272 |
/**
|
|
273 |
* Get global system state
|
|
274 |
* @return state
|
|
275 |
*/
|
|
276 |
TUsbGlobalSystemState GlobalSystemState();
|
|
277 |
|
|
278 |
/**
|
|
279 |
* Check if device is (scheduled to be) locked or not
|
|
280 |
* @return ETrue/EFalse
|
|
281 |
*/
|
|
282 |
TBool DeviceLocked();
|
|
283 |
|
|
284 |
/**
|
|
285 |
* Get Lock Time setting
|
|
286 |
* @return time
|
|
287 |
*/
|
|
288 |
TInt AutoLockTime();
|
|
289 |
|
|
290 |
/**
|
|
291 |
* Get lock status setting
|
|
292 |
* @return status
|
|
293 |
*/
|
|
294 |
TInt AutoLockStatus();
|
|
295 |
|
|
296 |
/**
|
|
297 |
* Unmount Mass storage
|
|
298 |
* This is the reverse of StartMountMassStorage.
|
|
299 |
*
|
|
300 |
* @since Series 60 5.0
|
|
301 |
*/
|
|
302 |
void UnmountMassStorage();
|
|
303 |
|
|
304 |
/**
|
|
305 |
* Get the file system mounted to the drive
|
|
306 |
*
|
|
307 |
* @param aDrive The drive which file system is required.
|
|
308 |
* @return The file system.
|
|
309 |
* @since Series 60 5.0
|
|
310 |
*/
|
|
311 |
TUsbFileSystem GetDriveFileSystem( TInt aDrive );
|
|
312 |
|
|
313 |
/**
|
|
314 |
* Tells whether device encryption is supported on device or not.
|
|
315 |
*
|
|
316 |
* @param None
|
|
317 |
* @return TBool
|
|
318 |
* @since TimeBox 9.2
|
|
319 |
*/
|
|
320 |
TBool IsDeviceEncryptionSupportedL();
|
|
321 |
|
|
322 |
/**
|
|
323 |
* Tells whether device encryption is supported on device or not.
|
|
324 |
*
|
|
325 |
* @param aDriveLetter pass in the drive that need to be checked
|
|
326 |
* @return TBool
|
|
327 |
* @since TimeBox 9.2
|
|
328 |
*/
|
|
329 |
TBool IsEncProtectionRequired(const TInt& aDriveLetter);
|
|
330 |
|
|
331 |
/**
|
|
332 |
* Dynamic load devenccommonutils.dll.
|
|
333 |
*
|
|
334 |
* @param None
|
|
335 |
* @since TimeBox9.2
|
|
336 |
*/
|
|
337 |
void LoadDevEncSessionL();
|
|
338 |
|
|
339 |
/**
|
|
340 |
* Unload devenccommonutils.dll.
|
|
341 |
*
|
|
342 |
* @param None
|
|
343 |
* @since TimeBox9.2
|
|
344 |
*/
|
|
345 |
void UnloadDevEncSession();
|
|
346 |
|
|
347 |
|
|
348 |
private: // Data
|
|
349 |
/**
|
|
350 |
* define the states of Mass Storage personality
|
|
351 |
*/
|
|
352 |
enum TUsbMscState
|
|
353 |
{
|
|
354 |
EUsbMscStateIdle,
|
|
355 |
EUsbMscStateStarting,
|
|
356 |
EUsbMscStateMounting,
|
|
357 |
EUsbMscStateFileTransfer,
|
|
358 |
EUsbMscStateStopping,
|
|
359 |
EUsbMscStateForciblyDismounting
|
|
360 |
};
|
|
361 |
|
|
362 |
/**
|
|
363 |
* state of Mass Storage Class
|
|
364 |
*/
|
|
365 |
TUsbMscState iMscState;
|
|
366 |
|
|
367 |
/**
|
|
368 |
* File server session handle
|
|
369 |
*/
|
|
370 |
RFs iFs;
|
|
371 |
|
|
372 |
/**
|
|
373 |
* Indicates whether MSFS has already been added to file server
|
|
374 |
*/
|
|
375 |
TBool iMsfsAdded;
|
|
376 |
|
|
377 |
/**
|
|
378 |
* Request to complete later
|
|
379 |
*/
|
|
380 |
TRequestStatus* iRequestStatus;
|
|
381 |
|
|
382 |
/**
|
|
383 |
* removable drives in the system
|
|
384 |
*/
|
|
385 |
RArray<TInt> iDrives;
|
|
386 |
|
|
387 |
/**
|
|
388 |
* Needed for multiple drive support
|
|
389 |
*/
|
|
390 |
TInt iDriveIndex;
|
|
391 |
|
|
392 |
/**
|
|
393 |
* Dismount timer: If expired forced dismount used.
|
|
394 |
*/
|
|
395 |
CUsbMscPersonalityTimer* iDismountFatTimer;
|
|
396 |
|
|
397 |
/**
|
|
398 |
* Packages for queries
|
|
399 |
*/
|
|
400 |
TUSBQueriesNotifierParamsPckg iQueryParams;
|
|
401 |
|
|
402 |
/**
|
|
403 |
* Dummy stores for queries and notes
|
|
404 |
*/
|
|
405 |
TBuf8<1> iDummy;
|
|
406 |
|
|
407 |
/**
|
|
408 |
* Used to get device lock settings
|
|
409 |
*/
|
|
410 |
CRepository* iRepository;
|
|
411 |
|
|
412 |
/**
|
|
413 |
* FAT has been unmounted or MSC mounted.
|
|
414 |
*/
|
|
415 |
TBool iMountChanged;
|
|
416 |
|
|
417 |
/**
|
|
418 |
* If query note shown by us
|
|
419 |
*/
|
|
420 |
TBool iIsQueryNoteShown;
|
|
421 |
|
|
422 |
/**
|
|
423 |
* Used to load devenccommonutils.dll and check the device encryption status
|
|
424 |
*/
|
|
425 |
RLibrary iLibrary;
|
|
426 |
CDevEncSessionBase* iDevEncSession;
|
|
427 |
};
|
|
428 |
|
|
429 |
#endif // USBACTIVEMSCHANDLER_H
|
|
430 |
|
|
431 |
// End of File
|