176
|
1 |
// Copyright (c) 2002-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 |
// f32test\ext\bitproxydrive.cpp
|
|
15 |
// extension to do XOR on every byte on 32 byte boundary read or written to media subsystem in same thread
|
|
16 |
// therefore RFile::Read/Write does not have this operation carried out on it
|
|
17 |
//
|
|
18 |
//
|
|
19 |
|
|
20 |
#include <f32fsys.h>
|
|
21 |
|
|
22 |
class CBitExtProxyDrive : public CExtProxyDrive
|
|
23 |
{
|
|
24 |
public:
|
|
25 |
CBitExtProxyDrive(CMountCB* aMount, CExtProxyDriveFactory* aDevice);
|
|
26 |
~CBitExtProxyDrive();
|
|
27 |
|
|
28 |
public:
|
|
29 |
virtual TInt Initialise();
|
|
30 |
virtual TInt Dismounted();
|
|
31 |
virtual TInt Enlarge(TInt aLength);
|
|
32 |
virtual TInt ReduceSize(TInt aPos, TInt aLength);
|
|
33 |
virtual TInt Read(TInt64 aPos, TInt aLength, const TAny* aTrg, TInt aThreadHandle, TInt aOffset, TInt aFlags);
|
|
34 |
virtual TInt Read(TInt64 aPos, TInt aLength, const TAny* aTrg, TInt aThreadHandle, TInt anOffset);
|
|
35 |
virtual TInt Read(TInt64 aPos, TInt aLength, TDes8& aTrg);
|
|
36 |
virtual TInt Write(TInt64 aPos, TInt aLength,const TAny* aSrc, TInt aThreadHandle, TInt aOffset, TInt aFlags);
|
|
37 |
virtual TInt Write(TInt64 aPos, TInt aLength, const TAny* aSrc, TInt aThreadHandle, TInt anOffset);
|
|
38 |
virtual TInt Write(TInt64 aPos,const TDesC8& aSrc);
|
|
39 |
virtual TInt Caps(TDes8& anInfo);
|
|
40 |
virtual TInt Format(TFormatInfo& aInfo);
|
|
41 |
virtual TInt Format(TInt64 aPos,TInt aLength);
|
|
42 |
virtual TInt SetInfo(const RMessage2 &msg, TAny* aMessageParam2, TAny* aMessageParam3);
|
|
43 |
virtual TInt NotifyChange(TDes8 &aChanged,TRequestStatus* aStatus);
|
|
44 |
virtual void NotifyChangeCancel();
|
|
45 |
|
|
46 |
TInt SetMountInfo(const TDesC8* aMountInfo,TInt aMountInfoThreadHandle=KCurrentThreadHandle);
|
|
47 |
TInt ForceRemount(TUint aFlags = 0);
|
|
48 |
TInt Unlock(TMediaPassword& aPassword, TBool aStorePassword);
|
|
49 |
TInt Lock(TMediaPassword& aOldPassword, TMediaPassword& aNewPassword, TBool aStorePassword);
|
|
50 |
TInt Clear(TMediaPassword& aPassword);
|
|
51 |
TInt ErasePassword();
|
|
52 |
|
|
53 |
TInt GetInterface(TInt aInterfaceId,TAny*& aInterface,TAny* aInput);
|
|
54 |
|
|
55 |
private:
|
|
56 |
|
|
57 |
TBusLocalDrive iDrive;
|
|
58 |
TInt iLocalDriveNumber;
|
|
59 |
TBool iChanged;
|
|
60 |
|
|
61 |
TRequestStatus* iNotifyChangeStatus;
|
|
62 |
};
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
class CBitProxyDriveFactory : public CExtProxyDriveFactory
|
|
67 |
{
|
|
68 |
public:
|
|
69 |
CBitProxyDriveFactory();
|
|
70 |
~CBitProxyDriveFactory();
|
|
71 |
virtual TInt Install();
|
|
72 |
virtual TInt CreateProxyDrive(CProxyDrive*& aMountProxyDrive,CMountCB* aMount);
|
|
73 |
};
|
|
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
|
78 |
CBitExtProxyDrive::CBitExtProxyDrive(CMountCB* aMount, CExtProxyDriveFactory* aDevice)
|
|
79 |
: CExtProxyDrive(aMount,aDevice)
|
|
80 |
{
|
|
81 |
}
|
|
82 |
|
|
83 |
CBitExtProxyDrive::~CBitExtProxyDrive()
|
|
84 |
{
|
|
85 |
iDrive.Disconnect();
|
|
86 |
}
|
|
87 |
|
|
88 |
/**
|
|
89 |
Initialise the proxy drive.
|
|
90 |
@return system wide error code.
|
|
91 |
*/
|
|
92 |
TInt CBitExtProxyDrive::Initialise()
|
|
93 |
{
|
|
94 |
TInt r = KErrNone;
|
|
95 |
return r;
|
|
96 |
}
|
|
97 |
|
|
98 |
TInt CBitExtProxyDrive::SetInfo(const RMessage2 &msg, TAny* /*aMessageParam2*/, TAny* /*aMessageParam3*/)
|
|
99 |
{
|
|
100 |
TInt r = KErrNone;
|
|
101 |
|
|
102 |
TPckg<TInt> infoPckg(iLocalDriveNumber);
|
|
103 |
TRAP(r, msg.ReadL(2, infoPckg));
|
|
104 |
|
|
105 |
if(r != KErrNone)
|
|
106 |
{
|
|
107 |
RDebug::Print(_L("CBitExtProxyDrive::SetInfo(): cant read from the RMessage %d"), r);
|
|
108 |
return r;
|
|
109 |
}
|
|
110 |
|
|
111 |
r = iDrive.Connect(iLocalDriveNumber, iChanged);
|
|
112 |
|
|
113 |
if(r != KErrNone)
|
|
114 |
{
|
|
115 |
RDebug::Print(_L("CBitExtProxyDrive::SetInfo(): failed to connect to drive %d, r %d"), iDriveNumber, r);
|
|
116 |
return r;
|
|
117 |
}
|
|
118 |
|
|
119 |
return r;
|
|
120 |
}
|
|
121 |
|
|
122 |
TInt CBitExtProxyDrive::Dismounted()
|
|
123 |
{
|
|
124 |
TInt r = KErrNone;
|
|
125 |
return r;
|
|
126 |
}
|
|
127 |
|
|
128 |
TInt CBitExtProxyDrive::Enlarge(TInt /*aLength*/)
|
|
129 |
{
|
|
130 |
return KErrNotSupported;
|
|
131 |
}
|
|
132 |
|
|
133 |
|
|
134 |
TInt CBitExtProxyDrive::ReduceSize(TInt /*aPos*/, TInt /*aLength*/)
|
|
135 |
{
|
|
136 |
return KErrNotSupported;
|
|
137 |
}
|
|
138 |
|
|
139 |
|
|
140 |
TInt CBitExtProxyDrive::Read(TInt64 aPos, TInt aLength, const TAny* aTrg, TInt aThreadHandle, TInt aOffset)
|
|
141 |
{
|
|
142 |
TInt r = iDrive.Read(aPos, aLength, aTrg, aThreadHandle, aOffset);
|
|
143 |
return r;
|
|
144 |
}
|
|
145 |
|
|
146 |
|
|
147 |
TInt CBitExtProxyDrive::Read(TInt64 aPos, TInt aLength, const TAny* aTrg, TInt aThreadHandle, TInt aOffset, TInt aFlags)
|
|
148 |
{
|
|
149 |
TInt r = iDrive.Read(aPos, aLength, aTrg, aThreadHandle, aOffset, aFlags);
|
|
150 |
return r;
|
|
151 |
}
|
|
152 |
|
|
153 |
TInt CBitExtProxyDrive::Read(TInt64 aPos, TInt aLength, TDes8& aTrg)
|
|
154 |
{
|
|
155 |
TInt r = iDrive.Read(aPos, aLength, aTrg);
|
|
156 |
return r;
|
|
157 |
}
|
|
158 |
|
|
159 |
TInt CBitExtProxyDrive::Write(TInt64 aPos, TInt aLength, const TAny* aSrc, TInt aThreadHandle, TInt aOffset)
|
|
160 |
{
|
|
161 |
TInt r = iDrive.Write(aPos, aLength, aSrc, aThreadHandle, aOffset);
|
|
162 |
return r;
|
|
163 |
}
|
|
164 |
|
|
165 |
|
|
166 |
TInt CBitExtProxyDrive::Write(TInt64 aPos, TInt aLength, const TAny* aSrc, TInt aThreadHandle, TInt aOffset, TInt aFlags)
|
|
167 |
{
|
|
168 |
TInt r = iDrive.Write(aPos, aLength, aSrc, aThreadHandle, aOffset, aFlags);
|
|
169 |
return r;
|
|
170 |
}
|
|
171 |
|
|
172 |
TInt CBitExtProxyDrive::Write(TInt64 aPos,const TDesC8& aSrc)
|
|
173 |
{
|
|
174 |
TInt r = iDrive.Write(aPos, aSrc);
|
|
175 |
return r;
|
|
176 |
}
|
|
177 |
|
|
178 |
|
|
179 |
TInt CBitExtProxyDrive::Caps(TDes8& anInfo)
|
|
180 |
{
|
|
181 |
TLocalDriveCapsV6Buf caps;
|
|
182 |
caps.FillZ();
|
|
183 |
|
|
184 |
// TLocalDriveCapsV6& c = caps();
|
|
185 |
|
|
186 |
TInt r = iDrive.Caps(caps);
|
|
187 |
caps.SetLength( Min(caps.Length(), anInfo.MaxLength()) );
|
|
188 |
|
|
189 |
anInfo.Copy(caps);
|
|
190 |
|
|
191 |
return r;
|
|
192 |
}
|
|
193 |
|
|
194 |
|
|
195 |
|
|
196 |
TInt CBitExtProxyDrive::Format(TInt64 aPos, TInt aLength)
|
|
197 |
{
|
|
198 |
TInt r = iDrive.Format(aPos, aLength);
|
|
199 |
return r;
|
|
200 |
}
|
|
201 |
|
|
202 |
|
|
203 |
TInt CBitExtProxyDrive::Format(TFormatInfo& aInfo)
|
|
204 |
{
|
|
205 |
TInt r = iDrive.Format(aInfo);
|
|
206 |
return r;
|
|
207 |
}
|
|
208 |
|
|
209 |
|
|
210 |
TInt CBitExtProxyDrive::NotifyChange(TDes8& /*aChanged*/, TRequestStatus* aStatus)
|
|
211 |
{
|
|
212 |
// iDrive.NotifyChange(aStatus);
|
|
213 |
iNotifyChangeStatus = aStatus;
|
|
214 |
return KErrNone;
|
|
215 |
}
|
|
216 |
|
|
217 |
void CBitExtProxyDrive::NotifyChangeCancel()
|
|
218 |
{
|
|
219 |
// iDrive.NotifyChangeCancel();
|
|
220 |
if (iNotifyChangeStatus)
|
|
221 |
User::RequestComplete(iNotifyChangeStatus, KErrCancel);
|
|
222 |
}
|
|
223 |
|
|
224 |
TInt CBitExtProxyDrive::SetMountInfo(const TDesC8* aMountInfo,TInt aMountInfoThreadHandle)
|
|
225 |
{
|
|
226 |
TInt r = iDrive.SetMountInfo(aMountInfo, aMountInfoThreadHandle);
|
|
227 |
return r;
|
|
228 |
}
|
|
229 |
|
|
230 |
TInt CBitExtProxyDrive::ForceRemount(TUint aFlags)
|
|
231 |
{
|
|
232 |
TInt r = iDrive.ForceRemount(aFlags);
|
|
233 |
return r;
|
|
234 |
}
|
|
235 |
|
|
236 |
TInt CBitExtProxyDrive::Unlock(TMediaPassword& aPassword, TBool aStorePassword)
|
|
237 |
{
|
|
238 |
TInt r = iDrive.Unlock(aPassword, aStorePassword);
|
|
239 |
return r;
|
|
240 |
}
|
|
241 |
|
|
242 |
TInt CBitExtProxyDrive::Lock(TMediaPassword& aOldPassword, TMediaPassword& aNewPassword, TBool aStorePassword)
|
|
243 |
{
|
|
244 |
TInt r = iDrive.SetPassword(aOldPassword, aNewPassword, aStorePassword);
|
|
245 |
return r;
|
|
246 |
}
|
|
247 |
|
|
248 |
TInt CBitExtProxyDrive::Clear(TMediaPassword& aPassword)
|
|
249 |
{
|
|
250 |
TInt r = iDrive.Clear(aPassword);
|
|
251 |
return r;
|
|
252 |
}
|
|
253 |
|
|
254 |
TInt CBitExtProxyDrive::ErasePassword()
|
|
255 |
{
|
|
256 |
TInt r = iDrive.ErasePassword();
|
|
257 |
return r;
|
|
258 |
}
|
|
259 |
|
|
260 |
TInt CBitExtProxyDrive::GetInterface(TInt aInterfaceId, TAny*& /*aInterface*/, TAny* /*aInput*/)
|
|
261 |
{
|
|
262 |
switch(aInterfaceId)
|
|
263 |
{
|
|
264 |
case ELocalBufferSupport:
|
|
265 |
return KErrNone;
|
|
266 |
default:
|
|
267 |
return KErrNotSupported;
|
|
268 |
}
|
|
269 |
}
|
|
270 |
|
|
271 |
|
|
272 |
|
|
273 |
CBitProxyDriveFactory::CBitProxyDriveFactory()
|
|
274 |
{
|
|
275 |
}
|
|
276 |
|
|
277 |
CBitProxyDriveFactory::~CBitProxyDriveFactory()
|
|
278 |
{
|
|
279 |
}
|
|
280 |
|
|
281 |
TInt CBitProxyDriveFactory::Install()
|
|
282 |
{
|
|
283 |
_LIT(KProxyName,"bitproxydrive");
|
|
284 |
return SetName(&KProxyName);
|
|
285 |
}
|
|
286 |
|
|
287 |
TInt CBitProxyDriveFactory::CreateProxyDrive(CProxyDrive*& aMountProxyDrive,CMountCB* aMount)
|
|
288 |
{
|
|
289 |
aMountProxyDrive = new CBitExtProxyDrive(aMount,this);
|
|
290 |
return (aMountProxyDrive==NULL) ? KErrNoMemory : KErrNone;
|
|
291 |
}
|
|
292 |
|
|
293 |
|
|
294 |
extern "C" {
|
|
295 |
|
|
296 |
|
|
297 |
/*
|
|
298 |
Create the proxy drive factory object for the usbhost mass storage proxy
|
|
299 |
*/
|
|
300 |
EXPORT_C CExtProxyDriveFactory* CreateFileSystem()
|
|
301 |
{
|
|
302 |
return new CBitProxyDriveFactory();
|
|
303 |
}
|
|
304 |
}
|
|
305 |
|