sl@0: // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // f32\sfile\sf_plugin_shim.cpp sl@0: // sl@0: // sl@0: sl@0: #include "cl_std.h" sl@0: #include "sf_std.h" sl@0: sl@0: /******************************************************* sl@0: * RFsPlugin * sl@0: *******************************************************/ sl@0: sl@0: EXPORT_C RFsPlugin::RFsPlugin(TFsPluginRequest& aRequest, TBool aDirectToDrive) sl@0: : iSessionHelper(&aRequest, aDirectToDrive) sl@0: { sl@0: SetReturnedHandle(KNullHandle); sl@0: } sl@0: sl@0: EXPORT_C RFsPlugin::~RFsPlugin() sl@0: { sl@0: Close(); sl@0: } sl@0: sl@0: EXPORT_C TInt RFsPlugin::Connect() sl@0: /** sl@0: Connects a file server plugin to the file server. sl@0: sl@0: To end the file server session, use Close(). sl@0: sl@0: @return KErrNone, if successful, otherwise one of the other system-wide error codes. sl@0: */ sl@0: { sl@0: return KErrNone; sl@0: } sl@0: sl@0: EXPORT_C void RFsPlugin::Close() sl@0: /** sl@0: Closes a file server plugin session. sl@0: */ sl@0: { sl@0: SetReturnedHandle(KNullHandle); sl@0: } sl@0: sl@0: EXPORT_C TInt RFsPlugin::Delete(const TDesC& aName) sl@0: /** sl@0: Deletes a single file. sl@0: sl@0: @see RFs::Delete sl@0: */ sl@0: { sl@0: return(RFs::Delete(aName)); sl@0: } sl@0: sl@0: EXPORT_C TInt RFsPlugin::Rename(const TDesC& aOldName,const TDesC& aNewName) sl@0: /** sl@0: Renames a single file or directory. sl@0: sl@0: @see RFs::Rename sl@0: */ sl@0: { sl@0: return(RFs::Rename(aOldName, aNewName)); sl@0: } sl@0: sl@0: EXPORT_C TInt RFsPlugin::Replace(const TDesC& aOldName,const TDesC& aNewName) sl@0: /** sl@0: Replaces a single file with another. sl@0: sl@0: @see RFs::Replace sl@0: */ sl@0: { sl@0: return(RFs::Replace(aOldName, aNewName)); sl@0: } sl@0: sl@0: EXPORT_C TInt RFsPlugin::Entry(const TDesC& aName,TEntry& aEntry) const sl@0: /** sl@0: Gets the entry details for a file or directory. sl@0: sl@0: @see RFs::Entry sl@0: */ sl@0: { sl@0: return(RFs::Entry(aName, aEntry)); sl@0: } sl@0: sl@0: EXPORT_C TInt RFsPlugin::SetEntry(const TDesC& aName,const TTime& aTime,TUint aSetAttMask,TUint aClearAttMask) sl@0: /** sl@0: Sets both the attributes and the last modified date and time for a file or directory. sl@0: sl@0: @see RFs::SetEntry sl@0: */ sl@0: { sl@0: return(RFs::SetEntry(aName,aTime,aSetAttMask,aClearAttMask)); sl@0: } sl@0: sl@0: EXPORT_C TInt RFsPlugin::ReadFileSection(const TDesC& aName,TInt64 aPos,TDes8& aDes,TInt aLength) const sl@0: /** sl@0: Reads data from a file without opening it. sl@0: sl@0: The contents of the file can be accessed regardless of the file's lock state. sl@0: sl@0: @see RFs::ReadFileSection sl@0: */ sl@0: { sl@0: #ifndef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API sl@0: return(RFs::ReadFileSection(aName,I64LOW(aPos),aDes,aLength)); sl@0: #else sl@0: return(RFs::ReadFileSection(aName,aPos,aDes,aLength)); sl@0: #endif sl@0: } sl@0: sl@0: EXPORT_C TInt RFsPlugin::Volume(TVolumeInfo &aVol, TInt aDrive) const sl@0: /** sl@0: Gets volume information for a formatted device. sl@0: sl@0: @see RFs::Volume sl@0: */ sl@0: { sl@0: return (RFs::Volume(aVol, aDrive)); sl@0: } sl@0: sl@0: TInt RFsPlugin::SendReceive(TInt aFunction,const TIpcArgs& aArgs) const sl@0: { sl@0: return iSessionHelper.SendReceive(aFunction, aArgs); sl@0: } sl@0: sl@0: TInt RFs::SendReceive(TInt aFunction,const TIpcArgs& aArgs) const sl@0: { sl@0: if(Handle()) sl@0: return RSessionBase::SendReceive(aFunction, aArgs); sl@0: sl@0: return ((RFsPlugin*) this)->SendReceive(aFunction, aArgs); sl@0: } sl@0: sl@0: sl@0: /******************************************************* sl@0: * RFilePlugin * sl@0: *******************************************************/ sl@0: sl@0: EXPORT_C RFilePlugin::RFilePlugin(TFsPluginRequest& aRequest, TBool aDirectToDrive) sl@0: : iSessionHelper(&aRequest, aDirectToDrive) sl@0: { sl@0: SetHandle(KErrBadHandle); sl@0: SetSubSessionHandle(KErrBadHandle); sl@0: } sl@0: sl@0: EXPORT_C RFilePlugin::~RFilePlugin() sl@0: { sl@0: Close(); sl@0: } sl@0: sl@0: EXPORT_C TInt RFilePlugin::Open(const TDesC& aName,TUint aMode) sl@0: /** sl@0: Opens an existing file for reading or writing. sl@0: sl@0: If the file does not already exist, an error is returned. sl@0: sl@0: @see RFile::Open sl@0: */ sl@0: { sl@0: RFs fs; sl@0: fs.SetHandle(Session().Handle()); sl@0: return(CreateSubSession(fs,EFsFileOpen,TIpcArgs(&aName,aMode))); sl@0: } sl@0: sl@0: EXPORT_C void RFilePlugin::Close() sl@0: /** sl@0: Closes the file. sl@0: sl@0: @see RFile::Close sl@0: */ sl@0: { sl@0: CloseSubSession(EFsFileSubClose); sl@0: SetSubSessionHandle(KErrBadHandle); sl@0: } sl@0: sl@0: EXPORT_C TInt RFilePlugin::Create(const TDesC& aName,TUint aFileMode) sl@0: /** sl@0: Closes the file. sl@0: sl@0: @see RFile::Create sl@0: */ sl@0: { sl@0: RFs fs; sl@0: fs.SetHandle(Session().Handle()); sl@0: return(CreateSubSession(fs,EFsFileCreate,TIpcArgs(&aName,aFileMode))); sl@0: } sl@0: sl@0: EXPORT_C TInt RFilePlugin::Replace(const TDesC& aName,TUint aFileMode) sl@0: /** sl@0: Closes the file. sl@0: sl@0: @see RFile::Replace sl@0: */ sl@0: { sl@0: RFs fs; sl@0: fs.SetHandle(Session().Handle()); sl@0: return(CreateSubSession(fs,EFsFileReplace,TIpcArgs(&aName,aFileMode))); sl@0: } sl@0: sl@0: EXPORT_C TInt RFilePlugin::Temp(const TDesC& aPath,TFileName& aName,TUint aFileMode) sl@0: /** sl@0: Closes the file. sl@0: sl@0: @see RFile::Temp sl@0: */ sl@0: { sl@0: RFs fs; sl@0: fs.SetHandle(Session().Handle()); sl@0: return(CreateSubSession(fs,EFsFileTemp,TIpcArgs(&aPath,aFileMode,&aName))); sl@0: } sl@0: sl@0: EXPORT_C TInt RFilePlugin::AdoptFromClient() sl@0: /** sl@0: Closes the file. sl@0: sl@0: @see RFile::AdoptFromClient sl@0: */ sl@0: { sl@0: TFsPluginRequest* request = iSessionHelper.Request(); sl@0: if(request == NULL) sl@0: return KErrBadHandle; sl@0: sl@0: TInt clientSubSessionHandle; sl@0: TInt err = request->ClientSubSessionHandle(clientSubSessionHandle); sl@0: if (err != KErrNone) sl@0: return err; sl@0: sl@0: RFs fs; sl@0: fs.SetHandle(Session().Handle()); sl@0: err = CreateSubSession(fs,EFsFileDuplicate, TIpcArgs(clientSubSessionHandle, ETrue)); sl@0: if (err != KErrNone) sl@0: return err; sl@0: sl@0: SetSubSessionHandle(SubSessionHandle() ^ KSubSessionMangleBit); sl@0: sl@0: return err; sl@0: } sl@0: sl@0: EXPORT_C TInt RFilePlugin::TransferToClient() sl@0: /** sl@0: Closes the file. sl@0: sl@0: @see RFile::TransferToClient sl@0: */ sl@0: { sl@0: TFsPluginRequest* request = iSessionHelper.Request(); sl@0: if(request == NULL) sl@0: return KErrBadHandle; sl@0: sl@0: // This doesn't behave like a standard duplicate as we're running in the context of the sl@0: // client's session. Instead, we can simply return our subsession handle to the client. sl@0: TRAPD(err, request->Request()->WriteL(KMsgPtr3, TPckgC(SubSessionHandle()))); sl@0: sl@0: // Next we have to free up the close request reserved for our internal subsession sl@0: // otherwise two messages will be reserved for the client... sl@0: RequestAllocator::OpenSubFailed(request->Request()->Session()); sl@0: sl@0: // And now we're done - we don't bother closing, as the client now completely owns the handle sl@0: SetSubSessionHandle(KErrBadHandle); sl@0: sl@0: return err; sl@0: } sl@0: sl@0: EXPORT_C TInt RFilePlugin::Write(TInt64 aPos, const TDesC8& aDes) sl@0: /** sl@0: Writes to the file at the specified offset within the file sl@0: sl@0: @see RFile::Write sl@0: */ sl@0: { sl@0: #ifndef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API sl@0: return RFile::Write(I64LOW(aPos), aDes); sl@0: #else sl@0: return RFile64::Write(aPos, aDes); sl@0: #endif sl@0: } sl@0: sl@0: EXPORT_C TInt RFilePlugin::Write(TInt64 aPos,const TDesC8& aDes,TInt aLen) sl@0: /** sl@0: Writes the specified number of bytes to the file at the specified offset within the file. sl@0: sl@0: @see RFile::Write sl@0: */ sl@0: { sl@0: #ifndef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API sl@0: return RFile::Write(I64LOW(aPos), aDes, aLen); sl@0: #else sl@0: return RFile64::Write(aPos, aDes, aLen); sl@0: #endif sl@0: } sl@0: sl@0: EXPORT_C TInt RFilePlugin::Read(TInt64 aPos,TDes8& aDes) const sl@0: /** sl@0: Reads from the file at the specified offset within the file sl@0: sl@0: @see RFile::Read sl@0: */ sl@0: { sl@0: #ifndef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API sl@0: return RFile::Read(I64LOW(aPos), aDes); sl@0: #else sl@0: return RFile64::Read(aPos, aDes); sl@0: #endif sl@0: } sl@0: sl@0: EXPORT_C TInt RFilePlugin::Read(TInt64 aPos,TDes8& aDes,TInt aLen) const sl@0: /** sl@0: Reads the specified number of bytes of binary data from the file at a specified sl@0: offset within the file. sl@0: sl@0: @see RFile::Read sl@0: */ sl@0: { sl@0: #ifndef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API sl@0: return RFile::Read(I64LOW(aPos), aDes, aLen); sl@0: #else sl@0: return RFile64::Read(aPos, aDes, aLen); sl@0: #endif sl@0: } sl@0: sl@0: EXPORT_C TInt RFilePlugin::Size(TInt64& aSize) const sl@0: /** sl@0: Gets the current file size. sl@0: sl@0: @see RFile::Size sl@0: */ sl@0: { sl@0: #ifndef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API sl@0: TInt size = I64LOW(aSize); sl@0: TInt err = RFile::Size(size); sl@0: aSize = size; sl@0: return err; sl@0: #else sl@0: return RFile64::Size(aSize); sl@0: #endif sl@0: } sl@0: sl@0: EXPORT_C TInt RFilePlugin::SetSize(TInt64 aSize) sl@0: /** sl@0: Sets the file size. sl@0: sl@0: @see RFile::SetSize sl@0: */ sl@0: { sl@0: #ifndef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API sl@0: return RFile::SetSize(I64LOW(aSize)); sl@0: #else sl@0: return RFile64::SetSize(aSize); sl@0: #endif sl@0: } sl@0: sl@0: EXPORT_C TInt RFilePlugin::Lock(TInt64 aPos, TInt64 aLength) const sl@0: /** sl@0: Locks a region within the file as defined by a range of bytes. sl@0: sl@0: @see RFile::Lock sl@0: */ sl@0: { sl@0: #ifndef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API sl@0: return RFile::Lock(I64LOW(aPos), I64LOW(aLength)); sl@0: #else sl@0: return RFile64::Lock(aPos, aLength); sl@0: #endif sl@0: } sl@0: sl@0: EXPORT_C TInt RFilePlugin::UnLock(TInt64 aPos, TInt64 aLength) const sl@0: /** sl@0: Unlocks a region within the file as defined by a range of bytes. sl@0: sl@0: @see RFile::UnLock sl@0: */ sl@0: { sl@0: #ifndef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API sl@0: return RFile::UnLock(I64LOW(aPos), I64LOW(aLength)); sl@0: #else sl@0: return RFile64::UnLock(aPos, aLength); sl@0: #endif sl@0: } sl@0: sl@0: EXPORT_C TInt RFilePlugin::Seek(TSeek aMode,TInt64& aPos) const sl@0: /** sl@0: Sets the the current file position. sl@0: sl@0: @see RFile::Seek sl@0: */ sl@0: { sl@0: #ifndef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API sl@0: TInt position = I64LOW(aPos); sl@0: TInt err = RFile::Seek(aMode, position); sl@0: if(err != KErrNone) sl@0: return err; sl@0: aPos = position; sl@0: return KErrNone; sl@0: #else sl@0: return RFile64::Seek(aMode, aPos); sl@0: #endif sl@0: } sl@0: sl@0: EXPORT_C TInt RFilePlugin::Flush() sl@0: /** sl@0: Commits data to the storage device and flushes internal buffers without closing sl@0: the file. sl@0: sl@0: @see RFile::Flush sl@0: */ sl@0: { sl@0: return RFile::Flush(); sl@0: } sl@0: sl@0: EXPORT_C TInt RFilePlugin::Att(TUint& aVal) const sl@0: /** sl@0: Gets the file's attributes. sl@0: sl@0: @see RFile::Att sl@0: */ sl@0: { sl@0: return RFile::Att(aVal); sl@0: } sl@0: sl@0: EXPORT_C TInt RFilePlugin::SetAtt(TUint aSetAttMask,TUint aClearAttMask) sl@0: /** sl@0: Sets or clears file attributes using two bitmasks. sl@0: sl@0: @see RFile::SetAtt sl@0: */ sl@0: { sl@0: return RFile::SetAtt(aSetAttMask, aClearAttMask); sl@0: } sl@0: sl@0: EXPORT_C TInt RFilePlugin::Modified(TTime& aTime) const sl@0: /** sl@0: Gets local date and time the file was last modified, in universal time. sl@0: sl@0: @see RFile::Modified sl@0: */ sl@0: { sl@0: return RFile::Modified(aTime); sl@0: } sl@0: sl@0: EXPORT_C TInt RFilePlugin::SetModified(const TTime& aTime) sl@0: /** sl@0: Sets the date and time the file was last modified. UTC date and time should be used. sl@0: sl@0: @see RFile::SetModified sl@0: */ sl@0: { sl@0: return RFile::SetModified(aTime); sl@0: } sl@0: sl@0: EXPORT_C TInt RFilePlugin::Set(const TTime& aTime,TUint aMask,TUint aVal) sl@0: /** sl@0: Sets the file’s attributes, and the date and time it was last modified. sl@0: sl@0: @see RFile::Set sl@0: */ sl@0: { sl@0: return RFile::Set(aTime, aMask, aVal); sl@0: } sl@0: sl@0: EXPORT_C TInt RFilePlugin::ChangeMode(TFileMode aNewMode) sl@0: /** sl@0: Switches an open file's access mode between EFileShareExclusive and EFileShareReadersOnly. sl@0: sl@0: @see RFile::ChangeMode sl@0: */ sl@0: { sl@0: return RFile::ChangeMode(aNewMode); sl@0: } sl@0: sl@0: EXPORT_C TInt RFilePlugin::Rename(const TDesC& aNewName) sl@0: /** sl@0: Renames a file. sl@0: sl@0: @see RFile::Rename sl@0: */ sl@0: { sl@0: return RFile::Rename(aNewName); sl@0: } sl@0: sl@0: void RFilePlugin::SetHandle(TInt aHandle) sl@0: { sl@0: *(((TInt*) this) + 0) = aHandle; sl@0: } sl@0: sl@0: void RFilePlugin::SetSubSessionHandle(TInt aHandle) sl@0: { sl@0: *(((TInt*) this) + 1) = aHandle; sl@0: } sl@0: sl@0: TInt RFilePlugin::CreateSubSession(const RSessionBase& aSession, TInt aFunction, const TIpcArgs& aArgs) sl@0: { sl@0: TInt reply; sl@0: TInt err = iSessionHelper.CreateSubSession(aSession, aFunction, aArgs, &reply); sl@0: if(err == KErrNone) sl@0: SetSubSessionHandle(reply); sl@0: return(err); sl@0: } sl@0: sl@0: void RFilePlugin::CloseSubSession(TInt aFunction) sl@0: { sl@0: if (SubSessionHandle()) sl@0: { sl@0: SendReceive(aFunction,TIpcArgs(TIpcArgs::ENothing,TIpcArgs::ENothing,TIpcArgs::ENothing,SubSessionHandle())); sl@0: } sl@0: sl@0: SetHandle(KErrBadHandle); sl@0: SetSubSessionHandle(KErrBadHandle); sl@0: } sl@0: sl@0: TInt RFilePlugin::SendReceive(TInt aFunction,const TIpcArgs& aArgs) const sl@0: { sl@0: return iSessionHelper.SendReceive(aFunction, aArgs, ((RFilePlugin*) this)->SubSessionHandle()); sl@0: } sl@0: sl@0: TInt RFile::CreateSubSession(const RSessionBase& aSession,TInt aFunction,const TIpcArgs& aArgs) sl@0: { sl@0: if(SubSessionHandle() == KErrBadHandle) sl@0: return ((RFilePlugin*) this)->CreateSubSession(aSession, aFunction, aArgs); sl@0: sl@0: return RSubSessionBase::CreateSubSession(aSession, aFunction, aArgs); sl@0: } sl@0: sl@0: void RFile::CloseSubSession(TInt aFunction) sl@0: { sl@0: if((Session().Handle() ^ CObjectIx::ENoClose) != KErrBadHandle) sl@0: RSubSessionBase::CloseSubSession(aFunction); sl@0: else sl@0: ((RFilePlugin*) this)->CloseSubSession(aFunction); sl@0: } sl@0: sl@0: TInt RFile::SendReceive(TInt aFunction,const TIpcArgs& aArgs) const sl@0: { sl@0: if((Session().Handle() ^ CObjectIx::ENoClose) != KErrBadHandle) sl@0: return RSubSessionBase::SendReceive(aFunction, aArgs); sl@0: sl@0: return ((RFilePlugin*) this)->SendReceive(aFunction, aArgs); sl@0: } sl@0: sl@0: sl@0: /******************************************************* sl@0: * RDirPlugin * sl@0: *******************************************************/ sl@0: sl@0: EXPORT_C RDirPlugin::RDirPlugin(TFsPluginRequest& aRequest, TBool aDirectToDrive) sl@0: : iSessionHelper(&aRequest, aDirectToDrive) sl@0: { sl@0: SetHandle(KErrBadHandle); sl@0: SetSubSessionHandle(KErrBadHandle); sl@0: } sl@0: sl@0: EXPORT_C RDirPlugin::~RDirPlugin() sl@0: { sl@0: Close(); sl@0: } sl@0: sl@0: EXPORT_C TInt RDirPlugin::Open(const TDesC& aMatchName,const TUidType& aUidType) sl@0: /** sl@0: Opens a directory using the specified UID type to filter the sl@0: directory entry types that will subsequently be read. sl@0: sl@0: @see RDir::Open sl@0: */ sl@0: { sl@0: RFs fs; sl@0: fs.SetHandle(Session().Handle()); sl@0: sl@0: TPckgC pckgUid(aUidType); sl@0: return(CreateSubSession(fs,EFsDirOpen,TIpcArgs(&aMatchName,KEntryAttAllowUid,&pckgUid))); sl@0: } sl@0: sl@0: EXPORT_C TInt RDirPlugin::Open(const TDesC& aMatchName,TUint anAttMask) sl@0: /** sl@0: Opens a directory using an attribute bitmask to filter the directory entry sl@0: types that will subsequently be read. sl@0: sl@0: @see RDir::Open sl@0: */ sl@0: { sl@0: RFs fs; sl@0: fs.SetHandle(Session().Handle()); sl@0: sl@0: TUidType uidType(TUid::Null(),TUid::Null(),TUid::Null()); sl@0: TPckgC pckgUid(uidType); sl@0: return(CreateSubSession(fs,EFsDirOpen,TIpcArgs(&aMatchName,anAttMask,&pckgUid))); sl@0: } sl@0: sl@0: EXPORT_C void RDirPlugin::Close() sl@0: /** sl@0: Closes the the directory. sl@0: sl@0: @see RDir::Close sl@0: */ sl@0: { sl@0: CloseSubSession(EFsDirSubClose); sl@0: SetSubSessionHandle(KErrBadHandle); sl@0: } sl@0: sl@0: EXPORT_C TInt RDirPlugin::Read(TEntryArray& aArray) sl@0: /** sl@0: Reads all filtered directory entries into the specified array. sl@0: sl@0: @see RDir::Read sl@0: */ sl@0: { sl@0: return RDir::Read(aArray); sl@0: } sl@0: sl@0: EXPORT_C TInt RDirPlugin::Read(TEntry& aEntry) sl@0: /** sl@0: Reads all filtered directory entries into the specified array. sl@0: sl@0: @see RDir::Read sl@0: */ sl@0: { sl@0: return RDir::Read(aEntry); sl@0: } sl@0: sl@0: void RDirPlugin::SetHandle(TInt aHandle) sl@0: { sl@0: *(((TInt*) this) + 0) = aHandle; sl@0: } sl@0: sl@0: void RDirPlugin::SetSubSessionHandle(TInt aHandle) sl@0: { sl@0: *(((TInt*) this) + 1) = aHandle; sl@0: } sl@0: sl@0: TInt RDirPlugin::CreateSubSession(const RSessionBase& aSession, TInt aFunction, const TIpcArgs& aArgs) sl@0: { sl@0: TInt reply; sl@0: TInt err = iSessionHelper.CreateSubSession(aSession, aFunction, aArgs, &reply); sl@0: if(err == KErrNone) sl@0: SetSubSessionHandle(reply); sl@0: return(err); sl@0: } sl@0: sl@0: void RDirPlugin::CloseSubSession(TInt aFunction) sl@0: { sl@0: if (SubSessionHandle()) sl@0: { sl@0: SendReceive(aFunction,TIpcArgs(TIpcArgs::ENothing,TIpcArgs::ENothing,TIpcArgs::ENothing,SubSessionHandle())); sl@0: } sl@0: sl@0: SetHandle(KErrBadHandle); sl@0: SetSubSessionHandle(KErrBadHandle); sl@0: } sl@0: sl@0: TInt RDirPlugin::SendReceive(TInt aFunction,const TIpcArgs& aArgs) const sl@0: { sl@0: return iSessionHelper.SendReceive(aFunction, aArgs, ((RDirPlugin*) this)->SubSessionHandle()); sl@0: } sl@0: sl@0: TInt RDir::SendReceive(TInt aFunction,const TIpcArgs& aArgs) const sl@0: { sl@0: if((Session().Handle() ^ CObjectIx::ENoClose) != KErrBadHandle) sl@0: return RSubSessionBase::SendReceive(aFunction, aArgs); sl@0: sl@0: return ((RDirPlugin*) this)->SendReceive(aFunction, aArgs); sl@0: } sl@0: sl@0: sl@0: /******************************************************* sl@0: * TFsPluginSessionHelper * sl@0: *******************************************************/ sl@0: sl@0: TPluginSessionHelper::TPluginSessionHelper() sl@0: { memclr(this, sizeof(TPluginSessionHelper)); } sl@0: sl@0: TPluginSessionHelper::TPluginSessionHelper(TFsPluginRequest* aRequest, TBool aDirectToDrive) sl@0: : iPlugin(aRequest->Request()->iCurrentPlugin), sl@0: iSession(aRequest->Request()->Session()), sl@0: iDirectToDrive(aDirectToDrive), sl@0: iRequest(aRequest) sl@0: { sl@0: // need to initialise RLocalMessage with client session sl@0: *((RMessage2*) &iMessage) = aRequest->Message(); sl@0: iMessage.InitHandle(); // set handle to KLocalMessageHandle sl@0: memclr(iSpare, sizeof(iSpare)); sl@0: } sl@0: sl@0: TInt TPluginSessionHelper::CreateSubSession(const RSessionBase& aSession, TInt aFunction, const TIpcArgs& aArgs, TInt* aReply) sl@0: { sl@0: (void)aSession; sl@0: sl@0: // Init message sl@0: TIpcArgs args; sl@0: args.iArgs[0] = aArgs.iArgs[0]; sl@0: args.iArgs[1] = aArgs.iArgs[1]; sl@0: args.iArgs[2] = aArgs.iArgs[2]; sl@0: args.iFlags = aArgs.iFlags&((1<<(3*TIpcArgs::KBitsPerType))-1); sl@0: sl@0: TPckgBuf reply; sl@0: args.Set(3,&reply); sl@0: sl@0: // copy session pointer sl@0: RLocalMessage message = iMessage; sl@0: message.SetFunction(aFunction); sl@0: message.SetArgs(args); sl@0: sl@0: TInt err = Dispatch(aFunction, args); sl@0: if (err == KErrNone) sl@0: *aReply = reply(); sl@0: sl@0: return err; sl@0: } sl@0: sl@0: TInt TPluginSessionHelper::Dispatch(TInt aFunction, TIpcArgs& aArgs) const sl@0: { sl@0: // copy session pointer sl@0: RLocalMessage message = iMessage; sl@0: message.SetFunction(aFunction); sl@0: message.SetArgs(aArgs); sl@0: sl@0: // allocate request sl@0: CFsClientMessageRequest* newRequest; sl@0: const TOperation& oP = OperationArray[aFunction & KIpcFunctionMask]; sl@0: TInt err = RequestAllocator::GetMessageRequest(oP, message, newRequest); sl@0: if (err != KErrNone) sl@0: return err; sl@0: sl@0: newRequest->Set(message, oP, iSession); sl@0: sl@0: //This is wrong. drive number is set in TFsXxx::initialise sl@0: //newRequest->SetDrive(&TheDrives[iPlugin->Drive()]); sl@0: sl@0: newRequest->iCurrentPlugin = iPlugin; sl@0: newRequest->iOwnerPlugin = iPlugin; sl@0: newRequest->iDirectToDrive = iDirectToDrive; sl@0: sl@0: newRequest->Dispatch(); sl@0: sl@0: // NOTE : newRequest will be free'd by the File Server before completing the sl@0: // request so it's not safe to touch the request from now on... sl@0: sl@0: return(iPlugin->WaitForRequest()); sl@0: } sl@0: sl@0: TInt TPluginSessionHelper::SendReceive(TInt aFunction, const TIpcArgs& aArgs, TInt aSubSessionHandle) const sl@0: { sl@0: // Init message sl@0: TIpcArgs args; sl@0: args.iArgs[0] = aArgs.iArgs[0]; sl@0: args.iArgs[1] = aArgs.iArgs[1]; sl@0: args.iArgs[2] = aArgs.iArgs[2]; sl@0: args.iFlags = aArgs.iFlags&((1<<(3*TIpcArgs::KBitsPerType))-1); sl@0: args.iArgs[3] = aSubSessionHandle; sl@0: sl@0: return Dispatch(aFunction, args); sl@0: } sl@0: sl@0: TInt TPluginSessionHelper::SendReceive(TInt aFunction, const TIpcArgs& aArgs) const sl@0: { sl@0: // Init message sl@0: TIpcArgs args; sl@0: args.iArgs[0] = aArgs.iArgs[0]; sl@0: args.iArgs[1] = aArgs.iArgs[1]; sl@0: args.iArgs[2] = aArgs.iArgs[2]; sl@0: args.iArgs[3] = aArgs.iArgs[3]; sl@0: args.iFlags = aArgs.iFlags&((1<<(3*TIpcArgs::KBitsPerType))-1); sl@0: sl@0: return Dispatch(aFunction, args); sl@0: } sl@0: sl@0: GLDEF_C void Panic(TClientPanic aPanic) sl@0: // sl@0: // Panic the current client with a file server client side panic. sl@0: // sl@0: { sl@0: User::Panic(_L("FS_PLUGIN_CLIENT panic"),aPanic); sl@0: } sl@0: