1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/f32test/plugins/version_2/src/template_plugin.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,262 @@
1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#include "template_plugin.h"
1.20 +#include <f32pluginutils.h>
1.21 +
1.22 +/**
1.23 +Leaving New function for the plugin
1.24 +@internalComponent
1.25 +*/
1.26 +CTemplatePlugin* CTemplatePlugin::NewL()
1.27 + {
1.28 + CTemplatePlugin* self = new(ELeave) CTemplatePlugin;
1.29 + CleanupStack::PushL(self);
1.30 + self->ConstructL();
1.31 + CleanupStack::Pop();
1.32 + return self;
1.33 + }
1.34 +
1.35 +
1.36 +/**
1.37 +Constructor for the plugin
1.38 +@internalComponent
1.39 +*/
1.40 +CTemplatePlugin::CTemplatePlugin() : iInterceptsEnabled(EFalse),
1.41 + iLogging(ETrue)
1.42 + {
1.43 + }
1.44 +
1.45 +
1.46 +void CTemplatePlugin::ConstructL()
1.47 + {
1.48 + }
1.49 +
1.50 +/**
1.51 +The destructor for the plugin
1.52 +@internalComponent
1.53 +*/
1.54 +CTemplatePlugin::~CTemplatePlugin()
1.55 + {
1.56 + iFs.Close();
1.57 + }
1.58 +
1.59 +/**
1.60 +Initialise the plugin.
1.61 +@internalComponent
1.62 +*/
1.63 +void CTemplatePlugin::InitialiseL()
1.64 + {
1.65 + User::LeaveIfError(iFs.Connect());
1.66 + CleanupClosePushL(iFs);
1.67 +
1.68 + _LOG(_L("CTemplatePlugin InitialiseL"));
1.69 + EnableInterceptsL();
1.70 +
1.71 + CleanupStack::Pop(); // iFs
1.72 + }
1.73 +
1.74 +/**
1.75 +Enable the plugin's intercepts.
1.76 +@internalComponent
1.77 +*/
1.78 +void CTemplatePlugin::EnableInterceptsL()
1.79 + {
1.80 + if (iInterceptsEnabled) return;
1.81 +
1.82 + User::LeaveIfError(RegisterIntercept(EFsFileRead, EPrePostIntercept));
1.83 + User::LeaveIfError(RegisterIntercept(EFsFileWrite, EPrePostIntercept));
1.84 + User::LeaveIfError(RegisterIntercept(EFsDirOpen, EPrePostIntercept));
1.85 + User::LeaveIfError(RegisterIntercept(EFsFileLock, EPrePostIntercept));
1.86 + User::LeaveIfError(RegisterIntercept(EFsFileUnLock, EPrePostIntercept));
1.87 + User::LeaveIfError(RegisterIntercept(EFsFileSeek, EPrePostIntercept));
1.88 + User::LeaveIfError(RegisterIntercept(EFsFileSize, EPrePostIntercept));
1.89 + User::LeaveIfError(RegisterIntercept(EFsFileSetSize, EPrePostIntercept));
1.90 + User::LeaveIfError(RegisterIntercept(EFsDirReadOne, EPrePostIntercept));
1.91 + User::LeaveIfError(RegisterIntercept(EFsDirReadPacked, EPrePostIntercept));
1.92 + User::LeaveIfError(RegisterIntercept(EFsFileOpen, EPrePostIntercept));
1.93 + User::LeaveIfError(RegisterIntercept(EFsFileCreate, EPrePostIntercept));
1.94 + User::LeaveIfError(RegisterIntercept(EFsFileReplace,EPrePostIntercept));
1.95 + User::LeaveIfError(RegisterIntercept(EFsFileRename, EPrePostIntercept));
1.96 + User::LeaveIfError(RegisterIntercept(EFsReadFileSection,EPrePostIntercept));
1.97 + User::LeaveIfError(RegisterIntercept(EFsFileSubClose, EPrePostIntercept));
1.98 +
1.99 + _LOG(_L("Template Plugin: Enabled intercepts."));
1.100 +
1.101 + iInterceptsEnabled = ETrue;
1.102 + }
1.103 +
1.104 +/**
1.105 +Disable the plugin's intercepts.
1.106 +@internalComponent
1.107 +*/
1.108 +void CTemplatePlugin::DisableInterceptsL()
1.109 + {
1.110 + if (!iInterceptsEnabled) return;
1.111 +
1.112 + User::LeaveIfError(UnregisterIntercept(EFsFileRead, EPrePostIntercept));
1.113 + User::LeaveIfError(UnregisterIntercept(EFsFileRename, EPrePostIntercept));
1.114 + User::LeaveIfError(UnregisterIntercept(EFsFileWrite, EPrePostIntercept));
1.115 + User::LeaveIfError(UnregisterIntercept(EFsDirOpen, EPrePostIntercept));
1.116 + User::LeaveIfError(UnregisterIntercept(EFsFileLock, EPrePostIntercept));
1.117 + User::LeaveIfError(UnregisterIntercept(EFsFileUnLock, EPrePostIntercept));
1.118 + User::LeaveIfError(UnregisterIntercept(EFsFileSeek, EPrePostIntercept));
1.119 + User::LeaveIfError(UnregisterIntercept(EFsFileSize, EPrePostIntercept));
1.120 + User::LeaveIfError(UnregisterIntercept(EFsFileSetSize, EPrePostIntercept));
1.121 + User::LeaveIfError(UnregisterIntercept(EFsFileCreate, EPrePostIntercept));
1.122 + User::LeaveIfError(UnregisterIntercept(EFsFileOpen, EPrePostIntercept));
1.123 + User::LeaveIfError(UnregisterIntercept(EFsFileReplace, EPrePostIntercept));
1.124 + User::LeaveIfError(UnregisterIntercept(EFsFileSubClose, EPrePostIntercept));
1.125 + User::LeaveIfError(UnregisterIntercept(EFsReadFileSection,EPrePostIntercept));
1.126 + User::LeaveIfError(UnregisterIntercept(EFsDirReadOne, EPrePostIntercept));
1.127 + User::LeaveIfError(UnregisterIntercept(EFsDirReadPacked,EPrePostIntercept));
1.128 +
1.129 +
1.130 + _LOG(_L("Template Plugin: Disabled intercepts."));
1.131 +
1.132 + iInterceptsEnabled = EFalse;
1.133 + }
1.134 +
1.135 +/**
1.136 +Handle requests
1.137 +@internalComponent
1.138 +*/
1.139 +TInt CTemplatePlugin::DoRequestL(TFsPluginRequest& aRequest)
1.140 + {
1.141 + TInt err = KErrNone;
1.142 +
1.143 + TInt function = aRequest.Function();
1.144 +
1.145 + if (aRequest.IsPostOperation())
1.146 + {
1.147 + _LOG2(_L("CTemplatePlugin post intercept for function %d"), function);
1.148 + }
1.149 + else
1.150 + {
1.151 + _LOG2(_L("CTemplatePlugin pre intercept for function %d"), function);
1.152 + }
1.153 +
1.154 + return err;
1.155 + }
1.156 +
1.157 +
1.158 +CFsPluginConn* CTemplatePlugin::NewPluginConnL()
1.159 + {
1.160 + return new(ELeave) CTemplatePluginConn();
1.161 + }
1.162 +
1.163 +//Synchronous RPlugin::DoControl
1.164 +TInt CTemplatePlugin::FsPluginDoControlL(CFsPluginConnRequest& /*aRequest*/)
1.165 + {
1.166 + /*TInt function = aRequest.Function();
1.167 +
1.168 + switch(function)
1.169 + {
1.170 + default:
1.171 + break;
1.172 + }
1.173 + */
1.174 + return KErrNone;
1.175 + }
1.176 +
1.177 +
1.178 +TInt CTemplatePluginConn::DoControl(CFsPluginConnRequest& aRequest)
1.179 + {
1.180 + return ((CTemplatePlugin*)Plugin())->FsPluginDoControlL(aRequest);
1.181 + }
1.182 +
1.183 +void CTemplatePluginConn::DoRequest(CFsPluginConnRequest& aRequest)
1.184 + {
1.185 + DoControl(aRequest);
1.186 + }
1.187 +
1.188 +void CTemplatePluginConn::DoCancel(TInt /*aReqMask*/)
1.189 + {
1.190 + }
1.191 +
1.192 +
1.193 +
1.194 +
1.195 +
1.196 +//factory functions
1.197 +
1.198 +class CTemplatePluginFactory : public CFsPluginFactory
1.199 + {
1.200 +public:
1.201 + CTemplatePluginFactory();
1.202 + virtual TInt Install();
1.203 + virtual CFsPlugin* NewPluginL();
1.204 + virtual CFsPlugin* NewPluginConnL();
1.205 + virtual TInt UniquePosition();
1.206 + };
1.207 +
1.208 +/**
1.209 +Constructor for the plugin factory
1.210 +@internalComponent
1.211 +*/
1.212 +CTemplatePluginFactory::CTemplatePluginFactory()
1.213 + {
1.214 + }
1.215 +
1.216 +/**
1.217 +Install function for the plugin factory
1.218 +@internalComponent
1.219 +*/
1.220 +TInt CTemplatePluginFactory::Install()
1.221 + {
1.222 + SetSupportedDrives(KPluginSupportAllDrives);
1.223 + return(SetName(&KTemplatePluginName));
1.224 + }
1.225 +
1.226 +/**
1.227 +@internalComponent
1.228 +*/
1.229 +TInt CTemplatePluginFactory::UniquePosition()
1.230 + {
1.231 + return(KTemplatePos);
1.232 + }
1.233 +
1.234 +/**
1.235 +Plugin factory function
1.236 +@internalComponent
1.237 +*/
1.238 +CFsPlugin* CTemplatePluginFactory::NewPluginL()
1.239 +
1.240 + {
1.241 + return CTemplatePlugin::NewL();
1.242 + }
1.243 +
1.244 +/**
1.245 +Plugin factory function
1.246 +@internalComponent
1.247 +*/
1.248 +CFsPlugin* CTemplatePluginFactory::NewPluginConnL()
1.249 +
1.250 + {
1.251 + return CTemplatePlugin::NewL();
1.252 + }
1.253 +
1.254 +/**
1.255 +Create a new Plugin
1.256 +@internalComponent
1.257 +*/
1.258 +extern "C" {
1.259 +
1.260 +EXPORT_C CFsPluginFactory* CreateFileSystem()
1.261 + {
1.262 + return(new CTemplatePluginFactory());
1.263 + }
1.264 +}
1.265 +