1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/f32test/plugins/version_2/src/drivec_plugin.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,280 @@
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 "DriveC_plugin.h"
1.20 +#include <f32pluginutils.h>
1.21 +#include "plugincommon.h"
1.22 +
1.23 +/**
1.24 +Leaving New function for the plugin
1.25 +@internalComponent
1.26 +*/
1.27 +CDriveCPlugin* CDriveCPlugin::NewL()
1.28 + {
1.29 + CDriveCPlugin* self = new(ELeave) CDriveCPlugin;
1.30 + CleanupStack::PushL(self);
1.31 + self->ConstructL();
1.32 + CleanupStack::Pop();
1.33 + return self;
1.34 + }
1.35 +
1.36 +
1.37 +/**
1.38 +Constructor for the plugin
1.39 +@internalComponent
1.40 +*/
1.41 +CDriveCPlugin::CDriveCPlugin() : iInterceptsEnabled(EFalse),
1.42 + iLogging(ETrue)
1.43 + {
1.44 + }
1.45 +
1.46 +
1.47 +void CDriveCPlugin::ConstructL()
1.48 + {
1.49 + }
1.50 +
1.51 +/**
1.52 +The destructor for the plugin
1.53 +@internalComponent
1.54 +*/
1.55 +CDriveCPlugin::~CDriveCPlugin()
1.56 + {
1.57 + iFs.Close();
1.58 + }
1.59 +
1.60 +/**
1.61 +Initialise the plugin.
1.62 +@internalComponent
1.63 +*/
1.64 +void CDriveCPlugin::InitialiseL()
1.65 + {
1.66 + User::LeaveIfError(iFs.Connect());
1.67 + CleanupClosePushL(iFs);
1.68 +
1.69 + _LOG(_L("CDriveCPlugin InitialiseL"));
1.70 + EnableInterceptsL();
1.71 +
1.72 + CleanupStack::Pop(); // iFs
1.73 + }
1.74 +
1.75 +/**
1.76 +Enable the plugin's intercepts.
1.77 +@internalComponent
1.78 +*/
1.79 +void CDriveCPlugin::EnableInterceptsL()
1.80 + {
1.81 + if (iInterceptsEnabled) return;
1.82 +
1.83 + User::LeaveIfError(RegisterIntercept(EFsFileRead, EPrePostIntercept));
1.84 + User::LeaveIfError(RegisterIntercept(EFsFileWrite, EPrePostIntercept));
1.85 + User::LeaveIfError(RegisterIntercept(EFsDirOpen, EPrePostIntercept));
1.86 + User::LeaveIfError(RegisterIntercept(EFsFileLock, EPrePostIntercept));
1.87 + User::LeaveIfError(RegisterIntercept(EFsFileUnLock, EPrePostIntercept));
1.88 + User::LeaveIfError(RegisterIntercept(EFsFileSeek, EPrePostIntercept));
1.89 + User::LeaveIfError(RegisterIntercept(EFsFileSize, EPrePostIntercept));
1.90 + User::LeaveIfError(RegisterIntercept(EFsFileSetSize, EPrePostIntercept));
1.91 + User::LeaveIfError(RegisterIntercept(EFsDirReadOne, EPrePostIntercept));
1.92 + User::LeaveIfError(RegisterIntercept(EFsDirReadPacked, EPrePostIntercept));
1.93 + User::LeaveIfError(RegisterIntercept(EFsFileOpen, EPrePostIntercept));
1.94 + User::LeaveIfError(RegisterIntercept(EFsFileCreate, EPrePostIntercept));
1.95 + User::LeaveIfError(RegisterIntercept(EFsFileReplace, EPrePostIntercept));
1.96 + User::LeaveIfError(RegisterIntercept(EFsFileRename, EPrePostIntercept));
1.97 + User::LeaveIfError(RegisterIntercept(EFsReadFileSection,EPrePostIntercept));
1.98 + User::LeaveIfError(RegisterIntercept(EFsFileSubClose, EPrePostIntercept));
1.99 +
1.100 + _LOG(_L("DriveC Plugin: Enabled intercepts."));
1.101 +
1.102 + iInterceptsEnabled = ETrue;
1.103 + }
1.104 +
1.105 +/**
1.106 +Disable the plugin's intercepts.
1.107 +@internalComponent
1.108 +*/
1.109 +void CDriveCPlugin::DisableInterceptsL()
1.110 + {
1.111 + if (!iInterceptsEnabled) return;
1.112 +
1.113 + User::LeaveIfError(UnregisterIntercept(EFsFileRead, EPrePostIntercept));
1.114 + User::LeaveIfError(UnregisterIntercept(EFsFileRename, EPrePostIntercept));
1.115 + User::LeaveIfError(UnregisterIntercept(EFsFileWrite, EPrePostIntercept));
1.116 + User::LeaveIfError(UnregisterIntercept(EFsDirOpen, EPrePostIntercept));
1.117 + User::LeaveIfError(UnregisterIntercept(EFsFileLock, EPrePostIntercept));
1.118 + User::LeaveIfError(UnregisterIntercept(EFsFileUnLock, EPrePostIntercept));
1.119 + User::LeaveIfError(UnregisterIntercept(EFsFileSeek, EPrePostIntercept));
1.120 + User::LeaveIfError(UnregisterIntercept(EFsFileSize, EPrePostIntercept));
1.121 + User::LeaveIfError(UnregisterIntercept(EFsFileSetSize, EPrePostIntercept));
1.122 + User::LeaveIfError(UnregisterIntercept(EFsFileCreate, EPrePostIntercept));
1.123 + User::LeaveIfError(UnregisterIntercept(EFsFileOpen, EPrePostIntercept));
1.124 + User::LeaveIfError(UnregisterIntercept(EFsFileReplace, EPrePostIntercept));
1.125 + User::LeaveIfError(UnregisterIntercept(EFsFileSubClose, EPrePostIntercept));
1.126 + User::LeaveIfError(UnregisterIntercept(EFsReadFileSection,EPrePostIntercept));
1.127 + User::LeaveIfError(UnregisterIntercept(EFsDirReadOne, EPrePostIntercept));
1.128 + User::LeaveIfError(UnregisterIntercept(EFsDirReadPacked,EPrePostIntercept));
1.129 +
1.130 +
1.131 + _LOG(_L("DriveC Plugin: Disabled intercepts."));
1.132 +
1.133 + iInterceptsEnabled = EFalse;
1.134 + }
1.135 +
1.136 +/**
1.137 +Handle requests
1.138 +@internalComponent
1.139 +*/
1.140 +TInt CDriveCPlugin::DoRequestL(TFsPluginRequest& aRequest)
1.141 + {
1.142 + TInt err = KErrNone;
1.143 +
1.144 + TInt function = aRequest.Function();
1.145 +
1.146 + if(aRequest.DriveNumber() != 2)
1.147 + {
1.148 + iLineNumber=__LINE__;
1.149 + iLastError=KErrNotSupported;
1.150 + return KErrNotSupported;
1.151 + }
1.152 +
1.153 + if (aRequest.IsPostOperation())
1.154 + {
1.155 + _LOG2(_L("CDriveCPlugin post intercept for function %d"), function);
1.156 + }
1.157 + else
1.158 + {
1.159 + _LOG2(_L("CDriveCPlugin pre intercept for function %d"), function);
1.160 + }
1.161 +
1.162 + return err;
1.163 + }
1.164 +
1.165 +
1.166 +CFsPluginConn* CDriveCPlugin::NewPluginConnL()
1.167 + {
1.168 + return new(ELeave) CDriveCPluginConn();
1.169 + }
1.170 +
1.171 +
1.172 +//Synchronous RPlugin::DoControl
1.173 +TInt CDriveCPlugin::FsPluginDoControlL(CFsPluginConnRequest& aRequest)
1.174 + {
1.175 + TInt err = KErrNone;
1.176 +
1.177 + //We can use this to set the drive
1.178 + //We can store this as a member of this class.
1.179 + TInt function = aRequest.Function();
1.180 + TPckg<TInt> errCodeDes(iLastError);
1.181 + TPckg<TInt> lineNumberDes(iLineNumber);
1.182 +
1.183 + switch(function)
1.184 + {
1.185 + case KPluginGetError:
1.186 + {
1.187 + TRAP(err,aRequest.WriteParam1L(errCodeDes));
1.188 + TRAP(err,aRequest.WriteParam2L(lineNumberDes));
1.189 + break;
1.190 + }
1.191 + default:
1.192 + break;
1.193 + }
1.194 +
1.195 + return err;
1.196 + }
1.197 +
1.198 +
1.199 +TInt CDriveCPluginConn::DoControl(CFsPluginConnRequest& aRequest)
1.200 + {
1.201 + return ((CDriveCPlugin*)Plugin())->FsPluginDoControlL(aRequest);
1.202 + }
1.203 +
1.204 +void CDriveCPluginConn::DoRequest(CFsPluginConnRequest& aRequest)
1.205 + {
1.206 + DoControl(aRequest);
1.207 + }
1.208 +
1.209 +void CDriveCPluginConn::DoCancel(TInt /*aReqMask*/)
1.210 + {
1.211 + }
1.212 +
1.213 +//factory functions
1.214 +
1.215 +class CDriveCPluginFactory : public CFsPluginFactory
1.216 + {
1.217 +public:
1.218 + CDriveCPluginFactory();
1.219 + virtual TInt Install();
1.220 + virtual CFsPlugin* NewPluginL();
1.221 + virtual CFsPlugin* NewPluginConnL();
1.222 + virtual TInt UniquePosition();
1.223 + };
1.224 +
1.225 +/**
1.226 +Constructor for the plugin factory
1.227 +@internalComponent
1.228 +*/
1.229 +CDriveCPluginFactory::CDriveCPluginFactory()
1.230 + {
1.231 + }
1.232 +
1.233 +/**
1.234 +Install function for the plugin factory
1.235 +@internalComponent
1.236 +*/
1.237 +TInt CDriveCPluginFactory::Install()
1.238 + {
1.239 + SetSupportedDrives(1<<2);
1.240 + //iSupportedDrives = 1<<2;
1.241 + return(SetName(&KDriveCPluginName));
1.242 + }
1.243 +
1.244 +/**
1.245 +@internalComponent
1.246 +*/
1.247 +TInt CDriveCPluginFactory::UniquePosition()
1.248 + {
1.249 + return(KDriveCPos);
1.250 + }
1.251 +
1.252 +/**
1.253 +Plugin factory function
1.254 +@internalComponent
1.255 +*/
1.256 +CFsPlugin* CDriveCPluginFactory::NewPluginL()
1.257 +
1.258 + {
1.259 + return CDriveCPlugin::NewL();
1.260 + }
1.261 +
1.262 +/**
1.263 +Plugin factory function
1.264 +@internalComponent
1.265 +*/
1.266 +CFsPlugin* CDriveCPluginFactory::NewPluginConnL()
1.267 +
1.268 + {
1.269 + return CDriveCPlugin::NewL();
1.270 + }
1.271 +
1.272 +/**
1.273 +Create a new Plugin
1.274 +@internalComponent
1.275 +*/
1.276 +extern "C" {
1.277 +
1.278 +EXPORT_C CFsPluginFactory* CreateFileSystem()
1.279 + {
1.280 + return(new CDriveCPluginFactory());
1.281 + }
1.282 +}
1.283 +