0
|
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 |
// RUsbMsMountManager class.
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
/**
|
|
21 |
@file
|
|
22 |
@internalTechnology
|
|
23 |
*/
|
|
24 |
|
|
25 |
#ifndef CUSBMSMOUNTMANAGER_H
|
|
26 |
#define CUSBMSMONUTMANAGER_H
|
|
27 |
|
|
28 |
|
|
29 |
class RUsbHubDriver;
|
|
30 |
class TUsbInterfaceDescriptor;
|
|
31 |
class TUsbDeviceDescriptor;
|
|
32 |
class RUsbInterface;
|
|
33 |
|
|
34 |
|
|
35 |
class TUsbPrint
|
|
36 |
{
|
|
37 |
public:
|
|
38 |
TUsbPrint();
|
|
39 |
void EnableDebug() {iDebug = ETrue;}
|
|
40 |
void DisableDebug() {iDebug = EFalse;}
|
|
41 |
|
|
42 |
void PrintTree(const TUsbGenericDescriptor& aDesc,
|
|
43 |
TInt aDepth = 0);
|
|
44 |
|
|
45 |
void PrintDescriptor(const TUsbDeviceDescriptor& aDeviceDesc,
|
|
46 |
TInt aVariant = 0,
|
|
47 |
RUsbDevice* aDevice = NULL);
|
|
48 |
|
|
49 |
void PrintDescriptor(const TUsbConfigurationDescriptor& aConfigDesc,
|
|
50 |
TInt aVariant = 0,
|
|
51 |
RUsbDevice* aDevice = NULL);
|
|
52 |
|
|
53 |
void PrintDescriptor(const TUsbEndpointDescriptor& aEndpointDesc,
|
|
54 |
TInt aVariant = 0,
|
|
55 |
RUsbDevice* aDevice = NULL);
|
|
56 |
|
|
57 |
void PrintDescriptor(const TUsbStringDescriptor& aStringDesc,
|
|
58 |
TInt aVariant = 0,
|
|
59 |
RUsbDevice* aDevice = NULL);
|
|
60 |
|
|
61 |
void PrintDescriptor(const TUsbInterfaceDescriptor& aInterfaceDesc,
|
|
62 |
TInt aVariant = 0,
|
|
63 |
RUsbDevice* aDevice = NULL);
|
|
64 |
|
|
65 |
private:
|
|
66 |
void SetLanguageToPrintL(RUsbDevice& aDevice);
|
|
67 |
|
|
68 |
void PrintStringFromIndex(const TDesC& aFormatString,
|
|
69 |
TInt aIndex,
|
|
70 |
RUsbDevice* aDevice);
|
|
71 |
|
|
72 |
TBool iDebug;
|
|
73 |
};
|
|
74 |
|
|
75 |
|
|
76 |
class CDevice : public CBase
|
|
77 |
{
|
|
78 |
public:
|
|
79 |
static const TInt KMaxLun = 16;
|
|
80 |
|
|
81 |
public:
|
|
82 |
static CDevice* NewL();
|
|
83 |
~CDevice();
|
|
84 |
private:
|
|
85 |
void ConstructL();
|
|
86 |
CDevice();
|
|
87 |
|
|
88 |
public:
|
|
89 |
TToken OpenDeviceL(TUint aDeviceHandle, RUsbHubDriver& aHub);
|
|
90 |
void CloseDeviceL();
|
|
91 |
|
|
92 |
void MountLogicalUnitsL();
|
|
93 |
void DismountLogicalUnitsL();
|
|
94 |
TToken DeviceToken() const {return iDeviceToken;};
|
|
95 |
TUint DeviceHandle() const {return iDeviceHandle;};
|
|
96 |
|
|
97 |
TLun DriveMap(TDriveMap& aDriveMap) const;
|
|
98 |
TLun DeviceMap(TDeviceMap& aDeviceMap) const;
|
|
99 |
|
|
100 |
|
|
101 |
private:
|
|
102 |
TBool IsDeviceMassStorage(const TUsbInterfaceDescriptor& aInterfaceDesc,
|
|
103 |
const TUsbDeviceDescriptor& aDeviceDesc) const;
|
|
104 |
|
|
105 |
TInt GetEndpointAddress(RUsbInterface& aUsbInterface,
|
|
106 |
TInt aInterfaceSetting,
|
|
107 |
TUint8 aTransferType,
|
|
108 |
TUint8 aDirection,
|
|
109 |
TInt& aEndpointAddress) const;
|
|
110 |
|
|
111 |
|
|
112 |
|
|
113 |
private:
|
|
114 |
RUsbDevice iUsbDevice;
|
|
115 |
TUint iDeviceHandle;
|
|
116 |
|
|
117 |
RUsbHostMsDevice iUsbHostMsDevice;
|
|
118 |
|
|
119 |
TToken iDeviceToken;
|
|
120 |
TLun iNumLuns;
|
|
121 |
|
|
122 |
RExtFileSystem iExt;
|
|
123 |
|
|
124 |
// index is mapped to LUN
|
|
125 |
RArray<TDriveNumber> iLuList;
|
|
126 |
|
|
127 |
THostMassStorageConfig iMsConfig;
|
|
128 |
|
|
129 |
TUsbPrint iUsbPrint;
|
|
130 |
};
|
|
131 |
|
|
132 |
|
|
133 |
class CUsbMsMountManager : public CBase
|
|
134 |
{
|
|
135 |
public:
|
|
136 |
static CUsbMsMountManager* NewL();
|
|
137 |
~CUsbMsMountManager();
|
|
138 |
private:
|
|
139 |
void ConstructL();
|
|
140 |
CUsbMsMountManager();
|
|
141 |
|
|
142 |
public:
|
|
143 |
TInt DevicesNumber() const;
|
|
144 |
void DriveMap(TDriveMap& aDriveMap) const;
|
|
145 |
void DeviceMap(TInt aDeviceIndex, TDeviceMap& aDeviceMap) const;
|
|
146 |
|
|
147 |
|
|
148 |
public:
|
|
149 |
// adds new device entry for this device
|
|
150 |
void AddDeviceL(CDevice* aDevice);
|
|
151 |
// removes device entry for this device
|
|
152 |
CDevice* RemoveDeviceL(TUint aDeviceHandle);
|
|
153 |
|
|
154 |
void CloseAllDevicesL();
|
|
155 |
|
|
156 |
// mounts all LUNs for the device
|
|
157 |
void MountDeviceL(TUint aDeviceHandle);
|
|
158 |
// dismount all LUNs for this device
|
|
159 |
void DismountDeviceL(TUint aDeviceHandle);
|
|
160 |
// dismount all LUNs
|
|
161 |
void DismountL();
|
|
162 |
|
|
163 |
private:
|
|
164 |
TInt GetDeviceIndexL(TToken aDeviceToken) const;
|
|
165 |
TInt GetHandleIndexL(TUint aDeviceHandle) const;
|
|
166 |
|
|
167 |
private:
|
|
168 |
RPointerArray<CDevice> iDeviceList;
|
|
169 |
};
|
|
170 |
|
|
171 |
|
|
172 |
inline TInt CUsbMsMountManager::DevicesNumber() const
|
|
173 |
{
|
|
174 |
return iDeviceList.Count();
|
|
175 |
}
|
|
176 |
|
|
177 |
#endif // CUSBMSMOUNTMANAGER_H
|