0
|
1 |
// Copyright (c) 2008-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 |
// f32\sfile\sf_plugin_shim.cpp
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
#include "cl_std.h"
|
|
19 |
#include "sf_std.h"
|
|
20 |
|
|
21 |
/*******************************************************
|
|
22 |
* RFsPlugin *
|
|
23 |
*******************************************************/
|
|
24 |
|
|
25 |
EXPORT_C RFsPlugin::RFsPlugin(TFsPluginRequest& aRequest, TBool aDirectToDrive)
|
|
26 |
: iSessionHelper(&aRequest, aDirectToDrive)
|
|
27 |
{
|
|
28 |
SetReturnedHandle(KNullHandle);
|
|
29 |
}
|
|
30 |
|
|
31 |
EXPORT_C RFsPlugin::~RFsPlugin()
|
|
32 |
{
|
|
33 |
Close();
|
|
34 |
}
|
|
35 |
|
|
36 |
EXPORT_C TInt RFsPlugin::Connect()
|
|
37 |
/**
|
|
38 |
Connects a file server plugin to the file server.
|
|
39 |
|
|
40 |
To end the file server session, use Close().
|
|
41 |
|
|
42 |
@return KErrNone, if successful, otherwise one of the other system-wide error codes.
|
|
43 |
*/
|
|
44 |
{
|
|
45 |
return KErrNone;
|
|
46 |
}
|
|
47 |
|
|
48 |
EXPORT_C void RFsPlugin::Close()
|
|
49 |
/**
|
|
50 |
Closes a file server plugin session.
|
|
51 |
*/
|
|
52 |
{
|
|
53 |
SetReturnedHandle(KNullHandle);
|
|
54 |
}
|
|
55 |
|
|
56 |
EXPORT_C TInt RFsPlugin::Delete(const TDesC& aName)
|
|
57 |
/**
|
|
58 |
Deletes a single file.
|
|
59 |
|
|
60 |
@see RFs::Delete
|
|
61 |
*/
|
|
62 |
{
|
|
63 |
return(RFs::Delete(aName));
|
|
64 |
}
|
|
65 |
|
|
66 |
EXPORT_C TInt RFsPlugin::Rename(const TDesC& aOldName,const TDesC& aNewName)
|
|
67 |
/**
|
|
68 |
Renames a single file or directory.
|
|
69 |
|
|
70 |
@see RFs::Rename
|
|
71 |
*/
|
|
72 |
{
|
|
73 |
return(RFs::Rename(aOldName, aNewName));
|
|
74 |
}
|
|
75 |
|
|
76 |
EXPORT_C TInt RFsPlugin::Replace(const TDesC& aOldName,const TDesC& aNewName)
|
|
77 |
/**
|
|
78 |
Replaces a single file with another.
|
|
79 |
|
|
80 |
@see RFs::Replace
|
|
81 |
*/
|
|
82 |
{
|
|
83 |
return(RFs::Replace(aOldName, aNewName));
|
|
84 |
}
|
|
85 |
|
|
86 |
EXPORT_C TInt RFsPlugin::Entry(const TDesC& aName,TEntry& aEntry) const
|
|
87 |
/**
|
|
88 |
Gets the entry details for a file or directory.
|
|
89 |
|
|
90 |
@see RFs::Entry
|
|
91 |
*/
|
|
92 |
{
|
|
93 |
return(RFs::Entry(aName, aEntry));
|
|
94 |
}
|
|
95 |
|
|
96 |
EXPORT_C TInt RFsPlugin::SetEntry(const TDesC& aName,const TTime& aTime,TUint aSetAttMask,TUint aClearAttMask)
|
|
97 |
/**
|
|
98 |
Sets both the attributes and the last modified date and time for a file or directory.
|
|
99 |
|
|
100 |
@see RFs::SetEntry
|
|
101 |
*/
|
|
102 |
{
|
|
103 |
return(RFs::SetEntry(aName,aTime,aSetAttMask,aClearAttMask));
|
|
104 |
}
|
|
105 |
|
|
106 |
EXPORT_C TInt RFsPlugin::ReadFileSection(const TDesC& aName,TInt64 aPos,TDes8& aDes,TInt aLength) const
|
|
107 |
/**
|
|
108 |
Reads data from a file without opening it.
|
|
109 |
|
|
110 |
The contents of the file can be accessed regardless of the file's lock state.
|
|
111 |
|
|
112 |
@see RFs::ReadFileSection
|
|
113 |
*/
|
|
114 |
{
|
|
115 |
#ifndef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
|
|
116 |
return(RFs::ReadFileSection(aName,I64LOW(aPos),aDes,aLength));
|
|
117 |
#else
|
|
118 |
return(RFs::ReadFileSection(aName,aPos,aDes,aLength));
|
|
119 |
#endif
|
|
120 |
}
|
|
121 |
|
|
122 |
TInt RFsPlugin::SendReceive(TInt aFunction,const TIpcArgs& aArgs) const
|
|
123 |
{
|
|
124 |
return iSessionHelper.SendReceive(aFunction, aArgs);
|
|
125 |
}
|
|
126 |
|
|
127 |
TInt RFs::SendReceive(TInt aFunction,const TIpcArgs& aArgs) const
|
|
128 |
{
|
|
129 |
if(Handle())
|
|
130 |
return RSessionBase::SendReceive(aFunction, aArgs);
|
|
131 |
|
|
132 |
return ((RFsPlugin*) this)->SendReceive(aFunction, aArgs);
|
|
133 |
}
|
|
134 |
|
|
135 |
|
|
136 |
/*******************************************************
|
|
137 |
* RFilePlugin *
|
|
138 |
*******************************************************/
|
|
139 |
|
|
140 |
EXPORT_C RFilePlugin::RFilePlugin(TFsPluginRequest& aRequest, TBool aDirectToDrive)
|
|
141 |
: iSessionHelper(&aRequest, aDirectToDrive)
|
|
142 |
{
|
|
143 |
SetHandle(KErrBadHandle);
|
|
144 |
SetSubSessionHandle(KErrBadHandle);
|
|
145 |
}
|
|
146 |
|
|
147 |
EXPORT_C RFilePlugin::~RFilePlugin()
|
|
148 |
{
|
|
149 |
Close();
|
|
150 |
}
|
|
151 |
|
|
152 |
EXPORT_C TInt RFilePlugin::Open(const TDesC& aName,TUint aMode)
|
|
153 |
/**
|
|
154 |
Opens an existing file for reading or writing.
|
|
155 |
|
|
156 |
If the file does not already exist, an error is returned.
|
|
157 |
|
|
158 |
@see RFile::Open
|
|
159 |
*/
|
|
160 |
{
|
|
161 |
RFs fs;
|
|
162 |
fs.SetHandle(Session().Handle());
|
|
163 |
return(CreateSubSession(fs,EFsFileOpen,TIpcArgs(&aName,aMode)));
|
|
164 |
}
|
|
165 |
|
|
166 |
EXPORT_C void RFilePlugin::Close()
|
|
167 |
/**
|
|
168 |
Closes the file.
|
|
169 |
|
|
170 |
@see RFile::Close
|
|
171 |
*/
|
|
172 |
{
|
|
173 |
CloseSubSession(EFsFileSubClose);
|
|
174 |
SetSubSessionHandle(KErrBadHandle);
|
|
175 |
}
|
|
176 |
|
|
177 |
EXPORT_C TInt RFilePlugin::Create(const TDesC& aName,TUint aFileMode)
|
|
178 |
/**
|
|
179 |
Closes the file.
|
|
180 |
|
|
181 |
@see RFile::Create
|
|
182 |
*/
|
|
183 |
{
|
|
184 |
RFs fs;
|
|
185 |
fs.SetHandle(Session().Handle());
|
|
186 |
return(CreateSubSession(fs,EFsFileCreate,TIpcArgs(&aName,aFileMode)));
|
|
187 |
}
|
|
188 |
|
|
189 |
EXPORT_C TInt RFilePlugin::Replace(const TDesC& aName,TUint aFileMode)
|
|
190 |
/**
|
|
191 |
Closes the file.
|
|
192 |
|
|
193 |
@see RFile::Replace
|
|
194 |
*/
|
|
195 |
{
|
|
196 |
RFs fs;
|
|
197 |
fs.SetHandle(Session().Handle());
|
|
198 |
return(CreateSubSession(fs,EFsFileReplace,TIpcArgs(&aName,aFileMode)));
|
|
199 |
}
|
|
200 |
|
|
201 |
EXPORT_C TInt RFilePlugin::Temp(const TDesC& aPath,TFileName& aName,TUint aFileMode)
|
|
202 |
/**
|
|
203 |
Closes the file.
|
|
204 |
|
|
205 |
@see RFile::Temp
|
|
206 |
*/
|
|
207 |
{
|
|
208 |
RFs fs;
|
|
209 |
fs.SetHandle(Session().Handle());
|
|
210 |
return(CreateSubSession(fs,EFsFileTemp,TIpcArgs(&aPath,aFileMode,&aName)));
|
|
211 |
}
|
|
212 |
|
|
213 |
EXPORT_C TInt RFilePlugin::AdoptFromClient()
|
|
214 |
/**
|
|
215 |
Closes the file.
|
|
216 |
|
|
217 |
@see RFile::AdoptFromClient
|
|
218 |
*/
|
|
219 |
{
|
|
220 |
TFsPluginRequest* request = iSessionHelper.Request();
|
|
221 |
if(request == NULL)
|
|
222 |
return KErrBadHandle;
|
|
223 |
|
|
224 |
TInt clientSubSessionHandle;
|
|
225 |
TInt err = request->ClientSubSessionHandle(clientSubSessionHandle);
|
|
226 |
if (err != KErrNone)
|
|
227 |
return err;
|
|
228 |
|
|
229 |
RFs fs;
|
|
230 |
fs.SetHandle(Session().Handle());
|
|
231 |
err = CreateSubSession(fs,EFsFileDuplicate, TIpcArgs(clientSubSessionHandle, ETrue));
|
|
232 |
if (err != KErrNone)
|
|
233 |
return err;
|
|
234 |
|
|
235 |
SetSubSessionHandle(SubSessionHandle() ^ KSubSessionMangleBit);
|
|
236 |
|
|
237 |
return err;
|
|
238 |
}
|
|
239 |
|
|
240 |
EXPORT_C TInt RFilePlugin::TransferToClient()
|
|
241 |
/**
|
|
242 |
Closes the file.
|
|
243 |
|
|
244 |
@see RFile::TransferToClient
|
|
245 |
*/
|
|
246 |
{
|
|
247 |
TFsPluginRequest* request = iSessionHelper.Request();
|
|
248 |
if(request == NULL)
|
|
249 |
return KErrBadHandle;
|
|
250 |
|
|
251 |
// This doesn't behave like a standard duplicate as we're running in the context of the
|
|
252 |
// client's session. Instead, we can simply return our subsession handle to the client.
|
|
253 |
TRAPD(err, request->Request()->WriteL(KMsgPtr3, TPckgC<TInt>(SubSessionHandle())));
|
|
254 |
|
|
255 |
// Next we have to free up the close request reserved for our internal subsession
|
|
256 |
// otherwise two messages will be reserved for the client...
|
|
257 |
RequestAllocator::OpenSubFailed(request->Request()->Session());
|
|
258 |
|
|
259 |
// And now we're done - we don't bother closing, as the client now completely owns the handle
|
|
260 |
SetSubSessionHandle(KErrBadHandle);
|
|
261 |
|
|
262 |
return err;
|
|
263 |
}
|
|
264 |
|
|
265 |
EXPORT_C TInt RFilePlugin::Write(TInt64 aPos, const TDesC8& aDes)
|
|
266 |
/**
|
|
267 |
Writes to the file at the specified offset within the file
|
|
268 |
|
|
269 |
@see RFile::Write
|
|
270 |
*/
|
|
271 |
{
|
|
272 |
#ifndef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
|
|
273 |
return RFile::Write(I64LOW(aPos), aDes);
|
|
274 |
#else
|
|
275 |
return RFile64::Write(aPos, aDes);
|
|
276 |
#endif
|
|
277 |
}
|
|
278 |
|
|
279 |
EXPORT_C TInt RFilePlugin::Write(TInt64 aPos,const TDesC8& aDes,TInt aLen)
|
|
280 |
/**
|
|
281 |
Writes the specified number of bytes to the file at the specified offset within the file.
|
|
282 |
|
|
283 |
@see RFile::Write
|
|
284 |
*/
|
|
285 |
{
|
|
286 |
#ifndef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
|
|
287 |
return RFile::Write(I64LOW(aPos), aDes, aLen);
|
|
288 |
#else
|
|
289 |
return RFile64::Write(aPos, aDes, aLen);
|
|
290 |
#endif
|
|
291 |
}
|
|
292 |
|
|
293 |
EXPORT_C TInt RFilePlugin::Read(TInt64 aPos,TDes8& aDes) const
|
|
294 |
/**
|
|
295 |
Reads from the file at the specified offset within the file
|
|
296 |
|
|
297 |
@see RFile::Read
|
|
298 |
*/
|
|
299 |
{
|
|
300 |
#ifndef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
|
|
301 |
return RFile::Read(I64LOW(aPos), aDes);
|
|
302 |
#else
|
|
303 |
return RFile64::Read(aPos, aDes);
|
|
304 |
#endif
|
|
305 |
}
|
|
306 |
|
|
307 |
EXPORT_C TInt RFilePlugin::Read(TInt64 aPos,TDes8& aDes,TInt aLen) const
|
|
308 |
/**
|
|
309 |
Reads the specified number of bytes of binary data from the file at a specified
|
|
310 |
offset within the file.
|
|
311 |
|
|
312 |
@see RFile::Read
|
|
313 |
*/
|
|
314 |
{
|
|
315 |
#ifndef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
|
|
316 |
return RFile::Read(I64LOW(aPos), aDes, aLen);
|
|
317 |
#else
|
|
318 |
return RFile64::Read(aPos, aDes, aLen);
|
|
319 |
#endif
|
|
320 |
}
|
|
321 |
|
|
322 |
EXPORT_C TInt RFilePlugin::Size(TInt64& aSize) const
|
|
323 |
/**
|
|
324 |
Gets the current file size.
|
|
325 |
|
|
326 |
@see RFile::Size
|
|
327 |
*/
|
|
328 |
{
|
|
329 |
#ifndef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
|
|
330 |
TInt size = I64LOW(aSize);
|
|
331 |
TInt err = RFile::Size(size);
|
|
332 |
aSize = size;
|
|
333 |
return err;
|
|
334 |
#else
|
|
335 |
return RFile64::Size(aSize);
|
|
336 |
#endif
|
|
337 |
}
|
|
338 |
|
|
339 |
EXPORT_C TInt RFilePlugin::SetSize(TInt64 aSize)
|
|
340 |
/**
|
|
341 |
Sets the file size.
|
|
342 |
|
|
343 |
@see RFile::SetSize
|
|
344 |
*/
|
|
345 |
{
|
|
346 |
#ifndef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
|
|
347 |
return RFile::SetSize(I64LOW(aSize));
|
|
348 |
#else
|
|
349 |
return RFile64::SetSize(aSize);
|
|
350 |
#endif
|
|
351 |
}
|
|
352 |
|
|
353 |
EXPORT_C TInt RFilePlugin::Lock(TInt64 aPos, TInt64 aLength) const
|
|
354 |
/**
|
|
355 |
Locks a region within the file as defined by a range of bytes.
|
|
356 |
|
|
357 |
@see RFile::Lock
|
|
358 |
*/
|
|
359 |
{
|
|
360 |
#ifndef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
|
|
361 |
return RFile::Lock(I64LOW(aPos), I64LOW(aLength));
|
|
362 |
#else
|
|
363 |
return RFile64::Lock(aPos, aLength);
|
|
364 |
#endif
|
|
365 |
}
|
|
366 |
|
|
367 |
EXPORT_C TInt RFilePlugin::UnLock(TInt64 aPos, TInt64 aLength) const
|
|
368 |
/**
|
|
369 |
Unlocks a region within the file as defined by a range of bytes.
|
|
370 |
|
|
371 |
@see RFile::UnLock
|
|
372 |
*/
|
|
373 |
{
|
|
374 |
#ifndef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
|
|
375 |
return RFile::UnLock(I64LOW(aPos), I64LOW(aLength));
|
|
376 |
#else
|
|
377 |
return RFile64::UnLock(aPos, aLength);
|
|
378 |
#endif
|
|
379 |
}
|
|
380 |
|
|
381 |
EXPORT_C TInt RFilePlugin::Seek(TSeek aMode,TInt64& aPos) const
|
|
382 |
/**
|
|
383 |
Sets the the current file position.
|
|
384 |
|
|
385 |
@see RFile::Seek
|
|
386 |
*/
|
|
387 |
{
|
|
388 |
#ifndef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
|
|
389 |
TInt position = I64LOW(aPos);
|
|
390 |
TInt err = RFile::Seek(aMode, position);
|
|
391 |
if(err != KErrNone)
|
|
392 |
return err;
|
|
393 |
aPos = position;
|
|
394 |
return KErrNone;
|
|
395 |
#else
|
|
396 |
return RFile64::Seek(aMode, aPos);
|
|
397 |
#endif
|
|
398 |
}
|
|
399 |
|
|
400 |
EXPORT_C TInt RFilePlugin::Flush()
|
|
401 |
/**
|
|
402 |
Commits data to the storage device and flushes internal buffers without closing
|
|
403 |
the file.
|
|
404 |
|
|
405 |
@see RFile::Flush
|
|
406 |
*/
|
|
407 |
{
|
|
408 |
return RFile::Flush();
|
|
409 |
}
|
|
410 |
|
|
411 |
EXPORT_C TInt RFilePlugin::Att(TUint& aVal) const
|
|
412 |
/**
|
|
413 |
Gets the file's attributes.
|
|
414 |
|
|
415 |
@see RFile::Att
|
|
416 |
*/
|
|
417 |
{
|
|
418 |
return RFile::Att(aVal);
|
|
419 |
}
|
|
420 |
|
|
421 |
EXPORT_C TInt RFilePlugin::SetAtt(TUint aSetAttMask,TUint aClearAttMask)
|
|
422 |
/**
|
|
423 |
Sets or clears file attributes using two bitmasks.
|
|
424 |
|
|
425 |
@see RFile::SetAtt
|
|
426 |
*/
|
|
427 |
{
|
|
428 |
return RFile::SetAtt(aSetAttMask, aClearAttMask);
|
|
429 |
}
|
|
430 |
|
|
431 |
EXPORT_C TInt RFilePlugin::Modified(TTime& aTime) const
|
|
432 |
/**
|
|
433 |
Gets local date and time the file was last modified, in universal time.
|
|
434 |
|
|
435 |
@see RFile::Modified
|
|
436 |
*/
|
|
437 |
{
|
|
438 |
return RFile::Modified(aTime);
|
|
439 |
}
|
|
440 |
|
|
441 |
EXPORT_C TInt RFilePlugin::SetModified(const TTime& aTime)
|
|
442 |
/**
|
|
443 |
Sets the date and time the file was last modified. UTC date and time should be used.
|
|
444 |
|
|
445 |
@see RFile::SetModified
|
|
446 |
*/
|
|
447 |
{
|
|
448 |
return RFile::SetModified(aTime);
|
|
449 |
}
|
|
450 |
|
|
451 |
EXPORT_C TInt RFilePlugin::Set(const TTime& aTime,TUint aMask,TUint aVal)
|
|
452 |
/**
|
|
453 |
Sets the file’s attributes, and the date and time it was last modified.
|
|
454 |
|
|
455 |
@see RFile::Set
|
|
456 |
*/
|
|
457 |
{
|
|
458 |
return RFile::Set(aTime, aMask, aVal);
|
|
459 |
}
|
|
460 |
|
|
461 |
EXPORT_C TInt RFilePlugin::ChangeMode(TFileMode aNewMode)
|
|
462 |
/**
|
|
463 |
Switches an open file's access mode between EFileShareExclusive and EFileShareReadersOnly.
|
|
464 |
|
|
465 |
@see RFile::ChangeMode
|
|
466 |
*/
|
|
467 |
{
|
|
468 |
return RFile::ChangeMode(aNewMode);
|
|
469 |
}
|
|
470 |
|
|
471 |
EXPORT_C TInt RFilePlugin::Rename(const TDesC& aNewName)
|
|
472 |
/**
|
|
473 |
Renames a file.
|
|
474 |
|
|
475 |
@see RFile::Rename
|
|
476 |
*/
|
|
477 |
{
|
|
478 |
return RFile::Rename(aNewName);
|
|
479 |
}
|
|
480 |
|
|
481 |
void RFilePlugin::SetHandle(TInt aHandle)
|
|
482 |
{
|
|
483 |
*(((TInt*) this) + 0) = aHandle;
|
|
484 |
}
|
|
485 |
|
|
486 |
void RFilePlugin::SetSubSessionHandle(TInt aHandle)
|
|
487 |
{
|
|
488 |
*(((TInt*) this) + 1) = aHandle;
|
|
489 |
}
|
|
490 |
|
|
491 |
TInt RFilePlugin::CreateSubSession(const RSessionBase& aSession, TInt aFunction, const TIpcArgs& aArgs)
|
|
492 |
{
|
|
493 |
TInt reply;
|
|
494 |
TInt err = iSessionHelper.CreateSubSession(aSession, aFunction, aArgs, &reply);
|
|
495 |
if(err == KErrNone)
|
|
496 |
SetSubSessionHandle(reply);
|
|
497 |
return(err);
|
|
498 |
}
|
|
499 |
|
|
500 |
void RFilePlugin::CloseSubSession(TInt aFunction)
|
|
501 |
{
|
|
502 |
if (SubSessionHandle())
|
|
503 |
{
|
|
504 |
SendReceive(aFunction,TIpcArgs(TIpcArgs::ENothing,TIpcArgs::ENothing,TIpcArgs::ENothing,SubSessionHandle()));
|
|
505 |
}
|
|
506 |
|
|
507 |
SetHandle(KErrBadHandle);
|
|
508 |
SetSubSessionHandle(KErrBadHandle);
|
|
509 |
}
|
|
510 |
|
|
511 |
TInt RFilePlugin::SendReceive(TInt aFunction,const TIpcArgs& aArgs) const
|
|
512 |
{
|
|
513 |
return iSessionHelper.SendReceive(aFunction, aArgs, ((RFilePlugin*) this)->SubSessionHandle());
|
|
514 |
}
|
|
515 |
|
|
516 |
TInt RFile::CreateSubSession(const RSessionBase& aSession,TInt aFunction,const TIpcArgs& aArgs)
|
|
517 |
{
|
|
518 |
if(SubSessionHandle() == KErrBadHandle)
|
|
519 |
return ((RFilePlugin*) this)->CreateSubSession(aSession, aFunction, aArgs);
|
|
520 |
|
|
521 |
return RSubSessionBase::CreateSubSession(aSession, aFunction, aArgs);
|
|
522 |
}
|
|
523 |
|
|
524 |
void RFile::CloseSubSession(TInt aFunction)
|
|
525 |
{
|
|
526 |
if((Session().Handle() ^ CObjectIx::ENoClose) != KErrBadHandle)
|
|
527 |
RSubSessionBase::CloseSubSession(aFunction);
|
|
528 |
else
|
|
529 |
((RFilePlugin*) this)->CloseSubSession(aFunction);
|
|
530 |
}
|
|
531 |
|
|
532 |
TInt RFile::SendReceive(TInt aFunction,const TIpcArgs& aArgs) const
|
|
533 |
{
|
|
534 |
if((Session().Handle() ^ CObjectIx::ENoClose) != KErrBadHandle)
|
|
535 |
return RSubSessionBase::SendReceive(aFunction, aArgs);
|
|
536 |
|
|
537 |
return ((RFilePlugin*) this)->SendReceive(aFunction, aArgs);
|
|
538 |
}
|
|
539 |
|
|
540 |
|
|
541 |
/*******************************************************
|
|
542 |
* RDirPlugin *
|
|
543 |
*******************************************************/
|
|
544 |
|
|
545 |
EXPORT_C RDirPlugin::RDirPlugin(TFsPluginRequest& aRequest, TBool aDirectToDrive)
|
|
546 |
: iSessionHelper(&aRequest, aDirectToDrive)
|
|
547 |
{
|
|
548 |
SetHandle(KErrBadHandle);
|
|
549 |
SetSubSessionHandle(KErrBadHandle);
|
|
550 |
}
|
|
551 |
|
|
552 |
EXPORT_C RDirPlugin::~RDirPlugin()
|
|
553 |
{
|
|
554 |
Close();
|
|
555 |
}
|
|
556 |
|
|
557 |
EXPORT_C TInt RDirPlugin::Open(const TDesC& aMatchName,const TUidType& aUidType)
|
|
558 |
/**
|
|
559 |
Opens a directory using the specified UID type to filter the
|
|
560 |
directory entry types that will subsequently be read.
|
|
561 |
|
|
562 |
@see RDir::Open
|
|
563 |
*/
|
|
564 |
{
|
|
565 |
RFs fs;
|
|
566 |
fs.SetHandle(Session().Handle());
|
|
567 |
|
|
568 |
TPckgC<TUidType> pckgUid(aUidType);
|
|
569 |
return(CreateSubSession(fs,EFsDirOpen,TIpcArgs(&aMatchName,KEntryAttAllowUid,&pckgUid)));
|
|
570 |
}
|
|
571 |
|
|
572 |
EXPORT_C TInt RDirPlugin::Open(const TDesC& aMatchName,TUint anAttMask)
|
|
573 |
/**
|
|
574 |
Opens a directory using an attribute bitmask to filter the directory entry
|
|
575 |
types that will subsequently be read.
|
|
576 |
|
|
577 |
@see RDir::Open
|
|
578 |
*/
|
|
579 |
{
|
|
580 |
RFs fs;
|
|
581 |
fs.SetHandle(Session().Handle());
|
|
582 |
|
|
583 |
TUidType uidType(TUid::Null(),TUid::Null(),TUid::Null());
|
|
584 |
TPckgC<TUidType> pckgUid(uidType);
|
|
585 |
return(CreateSubSession(fs,EFsDirOpen,TIpcArgs(&aMatchName,anAttMask,&pckgUid)));
|
|
586 |
}
|
|
587 |
|
|
588 |
EXPORT_C void RDirPlugin::Close()
|
|
589 |
/**
|
|
590 |
Closes the the directory.
|
|
591 |
|
|
592 |
@see RDir::Close
|
|
593 |
*/
|
|
594 |
{
|
|
595 |
CloseSubSession(EFsDirSubClose);
|
|
596 |
SetSubSessionHandle(KErrBadHandle);
|
|
597 |
}
|
|
598 |
|
|
599 |
EXPORT_C TInt RDirPlugin::Read(TEntryArray& aArray)
|
|
600 |
/**
|
|
601 |
Reads all filtered directory entries into the specified array.
|
|
602 |
|
|
603 |
@see RDir::Read
|
|
604 |
*/
|
|
605 |
{
|
|
606 |
return RDir::Read(aArray);
|
|
607 |
}
|
|
608 |
|
|
609 |
EXPORT_C TInt RDirPlugin::Read(TEntry& aEntry)
|
|
610 |
/**
|
|
611 |
Reads all filtered directory entries into the specified array.
|
|
612 |
|
|
613 |
@see RDir::Read
|
|
614 |
*/
|
|
615 |
{
|
|
616 |
return RDir::Read(aEntry);
|
|
617 |
}
|
|
618 |
|
|
619 |
void RDirPlugin::SetHandle(TInt aHandle)
|
|
620 |
{
|
|
621 |
*(((TInt*) this) + 0) = aHandle;
|
|
622 |
}
|
|
623 |
|
|
624 |
void RDirPlugin::SetSubSessionHandle(TInt aHandle)
|
|
625 |
{
|
|
626 |
*(((TInt*) this) + 1) = aHandle;
|
|
627 |
}
|
|
628 |
|
|
629 |
TInt RDirPlugin::CreateSubSession(const RSessionBase& aSession, TInt aFunction, const TIpcArgs& aArgs)
|
|
630 |
{
|
|
631 |
TInt reply;
|
|
632 |
TInt err = iSessionHelper.CreateSubSession(aSession, aFunction, aArgs, &reply);
|
|
633 |
if(err == KErrNone)
|
|
634 |
SetSubSessionHandle(reply);
|
|
635 |
return(err);
|
|
636 |
}
|
|
637 |
|
|
638 |
void RDirPlugin::CloseSubSession(TInt aFunction)
|
|
639 |
{
|
|
640 |
if (SubSessionHandle())
|
|
641 |
{
|
|
642 |
SendReceive(aFunction,TIpcArgs(TIpcArgs::ENothing,TIpcArgs::ENothing,TIpcArgs::ENothing,SubSessionHandle()));
|
|
643 |
}
|
|
644 |
|
|
645 |
SetHandle(KErrBadHandle);
|
|
646 |
SetSubSessionHandle(KErrBadHandle);
|
|
647 |
}
|
|
648 |
|
|
649 |
TInt RDirPlugin::SendReceive(TInt aFunction,const TIpcArgs& aArgs) const
|
|
650 |
{
|
|
651 |
return iSessionHelper.SendReceive(aFunction, aArgs, ((RDirPlugin*) this)->SubSessionHandle());
|
|
652 |
}
|
|
653 |
|
|
654 |
TInt RDir::SendReceive(TInt aFunction,const TIpcArgs& aArgs) const
|
|
655 |
{
|
|
656 |
if((Session().Handle() ^ CObjectIx::ENoClose) != KErrBadHandle)
|
|
657 |
return RSubSessionBase::SendReceive(aFunction, aArgs);
|
|
658 |
|
|
659 |
return ((RDirPlugin*) this)->SendReceive(aFunction, aArgs);
|
|
660 |
}
|
|
661 |
|
|
662 |
|
|
663 |
/*******************************************************
|
|
664 |
* TFsPluginSessionHelper *
|
|
665 |
*******************************************************/
|
|
666 |
|
|
667 |
TPluginSessionHelper::TPluginSessionHelper()
|
|
668 |
{ memclr(this, sizeof(TPluginSessionHelper)); }
|
|
669 |
|
|
670 |
TPluginSessionHelper::TPluginSessionHelper(TFsPluginRequest* aRequest, TBool aDirectToDrive)
|
|
671 |
: iPlugin(aRequest->Request()->iCurrentPlugin),
|
|
672 |
iSession(aRequest->Request()->Session()),
|
|
673 |
iDirectToDrive(aDirectToDrive),
|
|
674 |
iRequest(aRequest)
|
|
675 |
{
|
|
676 |
// need to initialise RLocalMessage with client session
|
|
677 |
*((RMessage2*) &iMessage) = aRequest->Message();
|
|
678 |
iMessage.InitHandle(); // set handle to KLocalMessageHandle
|
|
679 |
memclr(iSpare, sizeof(iSpare));
|
|
680 |
}
|
|
681 |
|
|
682 |
TInt TPluginSessionHelper::CreateSubSession(const RSessionBase& aSession, TInt aFunction, const TIpcArgs& aArgs, TInt* aReply)
|
|
683 |
{
|
|
684 |
(void)aSession;
|
|
685 |
|
|
686 |
// Init message
|
|
687 |
TIpcArgs args;
|
|
688 |
args.iArgs[0] = aArgs.iArgs[0];
|
|
689 |
args.iArgs[1] = aArgs.iArgs[1];
|
|
690 |
args.iArgs[2] = aArgs.iArgs[2];
|
|
691 |
args.iFlags = aArgs.iFlags&((1<<(3*TIpcArgs::KBitsPerType))-1);
|
|
692 |
|
|
693 |
TPckgBuf<TInt> reply;
|
|
694 |
args.Set(3,&reply);
|
|
695 |
|
|
696 |
// copy session pointer
|
|
697 |
RLocalMessage message = iMessage;
|
|
698 |
message.SetFunction(aFunction);
|
|
699 |
message.SetArgs(args);
|
|
700 |
|
|
701 |
TInt err = Dispatch(aFunction, args);
|
|
702 |
if (err == KErrNone)
|
|
703 |
*aReply = reply();
|
|
704 |
|
|
705 |
return err;
|
|
706 |
}
|
|
707 |
|
|
708 |
TInt TPluginSessionHelper::Dispatch(TInt aFunction, TIpcArgs& aArgs) const
|
|
709 |
{
|
|
710 |
// copy session pointer
|
|
711 |
RLocalMessage message = iMessage;
|
|
712 |
message.SetFunction(aFunction);
|
|
713 |
message.SetArgs(aArgs);
|
|
714 |
|
|
715 |
// allocate request
|
|
716 |
CFsClientMessageRequest* newRequest;
|
|
717 |
const TOperation& oP = OperationArray[aFunction & KIpcFunctionMask];
|
|
718 |
TInt err = RequestAllocator::GetMessageRequest(oP, message, newRequest);
|
|
719 |
if (err != KErrNone)
|
|
720 |
return err;
|
|
721 |
|
|
722 |
newRequest->Set(message, oP, iSession);
|
|
723 |
|
|
724 |
//This is wrong. drive number is set in TFsXxx::initialise
|
|
725 |
//newRequest->SetDrive(&TheDrives[iPlugin->Drive()]);
|
|
726 |
|
|
727 |
newRequest->iCurrentPlugin = iPlugin;
|
|
728 |
newRequest->iOwnerPlugin = iPlugin;
|
|
729 |
newRequest->iDirectToDrive = iDirectToDrive;
|
|
730 |
|
|
731 |
newRequest->Dispatch();
|
|
732 |
|
|
733 |
// NOTE : newRequest will be free'd by the File Server before completing the
|
|
734 |
// request so it's not safe to touch the request from now on...
|
|
735 |
|
|
736 |
return(iPlugin->WaitForRequest());
|
|
737 |
}
|
|
738 |
|
|
739 |
TInt TPluginSessionHelper::SendReceive(TInt aFunction, const TIpcArgs& aArgs, TInt aSubSessionHandle) const
|
|
740 |
{
|
|
741 |
// Init message
|
|
742 |
TIpcArgs args;
|
|
743 |
args.iArgs[0] = aArgs.iArgs[0];
|
|
744 |
args.iArgs[1] = aArgs.iArgs[1];
|
|
745 |
args.iArgs[2] = aArgs.iArgs[2];
|
|
746 |
args.iFlags = aArgs.iFlags&((1<<(3*TIpcArgs::KBitsPerType))-1);
|
|
747 |
args.iArgs[3] = aSubSessionHandle;
|
|
748 |
|
|
749 |
return Dispatch(aFunction, args);
|
|
750 |
}
|
|
751 |
|
|
752 |
TInt TPluginSessionHelper::SendReceive(TInt aFunction, const TIpcArgs& aArgs) const
|
|
753 |
{
|
|
754 |
// Init message
|
|
755 |
TIpcArgs args;
|
|
756 |
args.iArgs[0] = aArgs.iArgs[0];
|
|
757 |
args.iArgs[1] = aArgs.iArgs[1];
|
|
758 |
args.iArgs[2] = aArgs.iArgs[2];
|
|
759 |
args.iArgs[3] = aArgs.iArgs[3];
|
|
760 |
args.iFlags = aArgs.iFlags&((1<<(3*TIpcArgs::KBitsPerType))-1);
|
|
761 |
|
|
762 |
return Dispatch(aFunction, args);
|
|
763 |
}
|
|
764 |
|
|
765 |
GLDEF_C void Panic(TClientPanic aPanic)
|
|
766 |
//
|
|
767 |
// Panic the current client with a file server client side panic.
|
|
768 |
//
|
|
769 |
{
|
|
770 |
User::Panic(_L("FS_PLUGIN_CLIENT panic"),aPanic);
|
|
771 |
}
|
|
772 |
|