sl@0: // Copyright (c) 2007-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: // sl@0: sl@0: #include "Combinational2_plugin.h" sl@0: #include "plugincommon.h" sl@0: #include sl@0: sl@0: sl@0: /** sl@0: Leaving New function for the plugin sl@0: @internalComponent sl@0: */ sl@0: CCombinational2Plugin* CCombinational2Plugin::NewL() sl@0: { sl@0: CCombinational2Plugin* self = new(ELeave) CCombinational2Plugin; sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(); sl@0: CleanupStack::Pop(); sl@0: return self; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Constructor for the plugin sl@0: @internalComponent sl@0: */ sl@0: CCombinational2Plugin::CCombinational2Plugin() : iInterceptsEnabled(EFalse), sl@0: iLogging(ETrue) sl@0: { sl@0: } sl@0: sl@0: sl@0: void CCombinational2Plugin::ConstructL() sl@0: { sl@0: } sl@0: sl@0: /** sl@0: The destructor for the plugin sl@0: @internalComponent sl@0: */ sl@0: CCombinational2Plugin::~CCombinational2Plugin() sl@0: { sl@0: } sl@0: sl@0: /** sl@0: Initialise the plugin. sl@0: @internalComponent sl@0: */ sl@0: void CCombinational2Plugin::InitialiseL() sl@0: { sl@0: _LOG(_L("CCombinational2Plugin InitialiseL")); sl@0: EnableInterceptsL(); sl@0: } sl@0: sl@0: /** sl@0: Enable the plugin's intercepts. sl@0: @internalComponent sl@0: */ sl@0: void CCombinational2Plugin::EnableInterceptsL() sl@0: { sl@0: if (iInterceptsEnabled) return; sl@0: sl@0: User::LeaveIfError(RegisterIntercept(EFsFileRead, EPrePostIntercept)); sl@0: User::LeaveIfError(RegisterIntercept(EFsFileWrite, EPrePostIntercept)); sl@0: User::LeaveIfError(RegisterIntercept(EFsDirOpen, EPrePostIntercept)); sl@0: User::LeaveIfError(RegisterIntercept(EFsFileLock, EPrePostIntercept)); sl@0: User::LeaveIfError(RegisterIntercept(EFsFileUnLock, EPrePostIntercept)); sl@0: User::LeaveIfError(RegisterIntercept(EFsFileSeek, EPrePostIntercept)); sl@0: User::LeaveIfError(RegisterIntercept(EFsFileSize, EPrePostIntercept)); sl@0: User::LeaveIfError(RegisterIntercept(EFsFileSetSize, EPrePostIntercept)); sl@0: User::LeaveIfError(RegisterIntercept(EFsDirReadOne, EPrePostIntercept)); sl@0: User::LeaveIfError(RegisterIntercept(EFsDirReadPacked, EPrePostIntercept)); sl@0: User::LeaveIfError(RegisterIntercept(EFsFileOpen, EPrePostIntercept)); sl@0: User::LeaveIfError(RegisterIntercept(EFsFileCreate, EPrePostIntercept)); sl@0: User::LeaveIfError(RegisterIntercept(EFsFileReplace, EPrePostIntercept)); sl@0: User::LeaveIfError(RegisterIntercept(EFsFileRename, EPrePostIntercept)); sl@0: User::LeaveIfError(RegisterIntercept(EFsReadFileSection,EPrePostIntercept)); sl@0: User::LeaveIfError(RegisterIntercept(EFsFileSubClose, EPrePostIntercept)); sl@0: User::LeaveIfError(RegisterIntercept(EFsEntry, EPrePostIntercept)); sl@0: User::LeaveIfError(RegisterIntercept(EFsSetEntry, EPrePostIntercept)); sl@0: sl@0: _LOG(_L("Combinational2 Plugin: Enabled intercepts.")); sl@0: sl@0: iInterceptsEnabled = ETrue; sl@0: } sl@0: sl@0: /** sl@0: Disable the plugin's intercepts. sl@0: @internalComponent sl@0: */ sl@0: void CCombinational2Plugin::DisableInterceptsL() sl@0: { sl@0: if (!iInterceptsEnabled) return; sl@0: sl@0: User::LeaveIfError(UnregisterIntercept(EFsFileRead, EPrePostIntercept)); sl@0: User::LeaveIfError(UnregisterIntercept(EFsFileRename, EPrePostIntercept)); sl@0: User::LeaveIfError(UnregisterIntercept(EFsFileWrite, EPrePostIntercept)); sl@0: User::LeaveIfError(UnregisterIntercept(EFsDirOpen, EPrePostIntercept)); sl@0: User::LeaveIfError(UnregisterIntercept(EFsFileLock, EPrePostIntercept)); sl@0: User::LeaveIfError(UnregisterIntercept(EFsFileUnLock, EPrePostIntercept)); sl@0: User::LeaveIfError(UnregisterIntercept(EFsFileSeek, EPrePostIntercept)); sl@0: User::LeaveIfError(UnregisterIntercept(EFsFileSize, EPrePostIntercept)); sl@0: User::LeaveIfError(UnregisterIntercept(EFsFileSetSize, EPrePostIntercept)); sl@0: User::LeaveIfError(UnregisterIntercept(EFsFileCreate, EPrePostIntercept)); sl@0: User::LeaveIfError(UnregisterIntercept(EFsFileOpen, EPrePostIntercept)); sl@0: User::LeaveIfError(UnregisterIntercept(EFsFileReplace, EPrePostIntercept)); sl@0: User::LeaveIfError(UnregisterIntercept(EFsFileSubClose, EPrePostIntercept)); sl@0: User::LeaveIfError(UnregisterIntercept(EFsReadFileSection, EPrePostIntercept)); sl@0: User::LeaveIfError(UnregisterIntercept(EFsDirReadOne, EPrePostIntercept)); sl@0: User::LeaveIfError(UnregisterIntercept(EFsDirReadPacked, EPrePostIntercept)); sl@0: User::LeaveIfError(UnregisterIntercept(EFsEntry, EPrePostIntercept)); sl@0: User::LeaveIfError(UnregisterIntercept(EFsSetEntry, EPrePostIntercept)); sl@0: sl@0: _LOG(_L("Combinational2 Plugin: Disabled intercepts.")); sl@0: sl@0: iInterceptsEnabled = EFalse; sl@0: } sl@0: sl@0: /* sl@0: Test second stage: - This is part of a test which is opening a different file in CombinationalPlugin1. sl@0: We need to get the entry here and make sure its for the right file. sl@0: */ sl@0: TInt CCombinational2Plugin::DoEntry(TFsPluginRequest& aRequest) sl@0: { sl@0: TInt err = KErrNone; sl@0: sl@0: if(aRequest.IsPostOperation()) //post sl@0: { sl@0: } sl@0: else // PRE sl@0: { sl@0: err = KErrNone; sl@0: TEntry entry; sl@0: sl@0: RFsPlugin fs(aRequest); sl@0: sl@0: TFileName name; sl@0: name = aRequest.Src().FullName(); //STF: Is this valid for entry? sl@0: sl@0: err = fs.Connect(); sl@0: iLastError = err; sl@0: iLineNumber = __LINE__; sl@0: if(err!=KErrNone) sl@0: return err; sl@0: sl@0: err = fs.Entry(name, entry); sl@0: iLastError = err; sl@0: iLineNumber = __LINE__; sl@0: if(err!=KErrNone) sl@0: return err; sl@0: sl@0: TPckgC e(entry); sl@0: err = aRequest.Write(TFsPluginRequest::EEntry,e); sl@0: iLastError = err; sl@0: iLineNumber = __LINE__; sl@0: if(err!=KErrNone) sl@0: return err; sl@0: sl@0: fs.Close(); sl@0: sl@0: return KErrCompletion; sl@0: } sl@0: return err; sl@0: } sl@0: sl@0: /** sl@0: Handle requests sl@0: @internalComponent sl@0: */ sl@0: TInt CCombinational2Plugin::DoRequestL(TFsPluginRequest& aRequest) sl@0: { sl@0: TInt err = KErrNone; sl@0: sl@0: TInt function = aRequest.Function(); sl@0: sl@0: switch(function) sl@0: { sl@0: case EFsEntry: sl@0: err = DoEntry(aRequest); sl@0: break; sl@0: default: sl@0: break; sl@0: } sl@0: sl@0: return err; sl@0: } sl@0: sl@0: sl@0: CFsPluginConn* CCombinational2Plugin::NewPluginConnL() sl@0: { sl@0: return new(ELeave) CCombinational2PluginConn(); sl@0: } sl@0: sl@0: sl@0: //Synchronous RPlugin::DoControl sl@0: TInt CCombinational2Plugin::FsPluginDoControlL(CFsPluginConnRequest& aRequest) sl@0: { sl@0: TInt err = KErrNone; sl@0: sl@0: TInt function = aRequest.Function(); sl@0: sl@0: TPckg errCodeDes(iLastError); sl@0: TPckg lineNumberDes(iLineNumber); sl@0: sl@0: switch(function) sl@0: { sl@0: case KPluginGetError: sl@0: { sl@0: TRAP(err,aRequest.WriteParam1L(errCodeDes)); sl@0: TRAP(err,aRequest.WriteParam2L(lineNumberDes)); sl@0: break; sl@0: } sl@0: default: sl@0: break; sl@0: } sl@0: sl@0: return err; sl@0: } sl@0: sl@0: sl@0: TInt CCombinational2PluginConn::DoControl(CFsPluginConnRequest& aRequest) sl@0: { sl@0: return ((CCombinational2Plugin*)Plugin())->FsPluginDoControlL(aRequest); sl@0: } sl@0: sl@0: void CCombinational2PluginConn::DoRequest(CFsPluginConnRequest& aRequest) sl@0: { sl@0: DoControl(aRequest); sl@0: } sl@0: sl@0: void CCombinational2PluginConn::DoCancel(TInt /*aReqMask*/) sl@0: { sl@0: } sl@0: sl@0: //factory functions sl@0: sl@0: class CCombinational2PluginFactory : public CFsPluginFactory sl@0: { sl@0: public: sl@0: CCombinational2PluginFactory(); sl@0: virtual TInt Install(); sl@0: virtual CFsPlugin* NewPluginL(); sl@0: virtual CFsPlugin* NewPluginConnL(); sl@0: virtual TInt UniquePosition(); sl@0: }; sl@0: sl@0: /** sl@0: Constructor for the plugin factory sl@0: @internalComponent sl@0: */ sl@0: CCombinational2PluginFactory::CCombinational2PluginFactory() sl@0: { sl@0: } sl@0: sl@0: /** sl@0: Install function for the plugin factory sl@0: @internalComponent sl@0: */ sl@0: TInt CCombinational2PluginFactory::Install() sl@0: { sl@0: SetSupportedDrives(KPluginSupportAllDrives); sl@0: return(SetName(&KCombinational2PluginName)); sl@0: } sl@0: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: TInt CCombinational2PluginFactory::UniquePosition() sl@0: { sl@0: return(KCombinational2Pos); sl@0: } sl@0: sl@0: /** sl@0: Plugin factory function sl@0: @internalComponent sl@0: */ sl@0: CFsPlugin* CCombinational2PluginFactory::NewPluginL() sl@0: sl@0: { sl@0: return CCombinational2Plugin::NewL(); sl@0: } sl@0: sl@0: /** sl@0: Plugin factory function sl@0: @internalComponent sl@0: */ sl@0: CFsPlugin* CCombinational2PluginFactory::NewPluginConnL() sl@0: sl@0: { sl@0: return CCombinational2Plugin::NewL(); sl@0: } sl@0: sl@0: /** sl@0: Create a new Plugin sl@0: @internalComponent sl@0: */ sl@0: extern "C" { sl@0: sl@0: EXPORT_C CFsPluginFactory* CreateFileSystem() sl@0: { sl@0: return(new CCombinational2PluginFactory()); sl@0: } sl@0: } sl@0: