os/kernelhwsrv/kerneltest/f32test/plugins/version_2/src/combinational2_plugin.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/f32test/plugins/version_2/src/combinational2_plugin.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,316 @@
     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 "Combinational2_plugin.h"
    1.20 +#include "plugincommon.h"
    1.21 +#include <f32pluginutils.h>
    1.22 +
    1.23 +
    1.24 +/**
    1.25 +Leaving New function for the plugin
    1.26 +@internalComponent
    1.27 +*/
    1.28 +CCombinational2Plugin* CCombinational2Plugin::NewL()
    1.29 +	{
    1.30 +	CCombinational2Plugin* self = new(ELeave) CCombinational2Plugin;
    1.31 +    CleanupStack::PushL(self);
    1.32 +    self->ConstructL();
    1.33 +    CleanupStack::Pop();
    1.34 +	return self;
    1.35 +	}
    1.36 +
    1.37 +
    1.38 +/**
    1.39 +Constructor for the plugin
    1.40 +@internalComponent
    1.41 +*/
    1.42 +CCombinational2Plugin::CCombinational2Plugin() : iInterceptsEnabled(EFalse),
    1.43 +									 iLogging(ETrue)
    1.44 +	{
    1.45 +	}
    1.46 +
    1.47 +
    1.48 +void CCombinational2Plugin::ConstructL()
    1.49 +	{
    1.50 +	}
    1.51 +
    1.52 +/**
    1.53 +The destructor for the plugin
    1.54 +@internalComponent
    1.55 +*/
    1.56 +CCombinational2Plugin::~CCombinational2Plugin()
    1.57 +	{
    1.58 +	}
    1.59 +
    1.60 +/**
    1.61 +Initialise the plugin.
    1.62 +@internalComponent
    1.63 +*/
    1.64 +void CCombinational2Plugin::InitialiseL()
    1.65 +	{
    1.66 +	_LOG(_L("CCombinational2Plugin InitialiseL"));
    1.67 +	EnableInterceptsL();
    1.68 +	}
    1.69 +
    1.70 +/**
    1.71 +Enable the plugin's intercepts.
    1.72 +@internalComponent
    1.73 +*/
    1.74 +void CCombinational2Plugin::EnableInterceptsL()
    1.75 +	{
    1.76 +	if (iInterceptsEnabled) return;
    1.77 +	
    1.78 +	User::LeaveIfError(RegisterIntercept(EFsFileRead,		EPrePostIntercept));
    1.79 +	User::LeaveIfError(RegisterIntercept(EFsFileWrite,		EPrePostIntercept));
    1.80 +	User::LeaveIfError(RegisterIntercept(EFsDirOpen,		EPrePostIntercept));
    1.81 +	User::LeaveIfError(RegisterIntercept(EFsFileLock,		EPrePostIntercept));
    1.82 +	User::LeaveIfError(RegisterIntercept(EFsFileUnLock,		EPrePostIntercept));
    1.83 +	User::LeaveIfError(RegisterIntercept(EFsFileSeek,		EPrePostIntercept));
    1.84 +	User::LeaveIfError(RegisterIntercept(EFsFileSize,		EPrePostIntercept));
    1.85 +	User::LeaveIfError(RegisterIntercept(EFsFileSetSize,	EPrePostIntercept));
    1.86 +	User::LeaveIfError(RegisterIntercept(EFsDirReadOne,		EPrePostIntercept));
    1.87 +	User::LeaveIfError(RegisterIntercept(EFsDirReadPacked,	EPrePostIntercept));
    1.88 +	User::LeaveIfError(RegisterIntercept(EFsFileOpen,		EPrePostIntercept));
    1.89 +	User::LeaveIfError(RegisterIntercept(EFsFileCreate,		EPrePostIntercept));
    1.90 +	User::LeaveIfError(RegisterIntercept(EFsFileReplace,	EPrePostIntercept));
    1.91 +	User::LeaveIfError(RegisterIntercept(EFsFileRename,		EPrePostIntercept));
    1.92 +   	User::LeaveIfError(RegisterIntercept(EFsReadFileSection,EPrePostIntercept));
    1.93 +	User::LeaveIfError(RegisterIntercept(EFsFileSubClose,   EPrePostIntercept));
    1.94 +	User::LeaveIfError(RegisterIntercept(EFsEntry,        	EPrePostIntercept));
    1.95 +	User::LeaveIfError(RegisterIntercept(EFsSetEntry,      	EPrePostIntercept));
    1.96 +
    1.97 +	_LOG(_L("Combinational2 Plugin: Enabled intercepts."));
    1.98 +    
    1.99 +	iInterceptsEnabled = ETrue;
   1.100 +	}
   1.101 +
   1.102 +/**
   1.103 +Disable the plugin's intercepts.
   1.104 +@internalComponent
   1.105 +*/
   1.106 +void CCombinational2Plugin::DisableInterceptsL()
   1.107 +	{
   1.108 +	if (!iInterceptsEnabled) return;
   1.109 +	
   1.110 +	User::LeaveIfError(UnregisterIntercept(EFsFileRead,			EPrePostIntercept));
   1.111 +	User::LeaveIfError(UnregisterIntercept(EFsFileRename,		EPrePostIntercept));
   1.112 +	User::LeaveIfError(UnregisterIntercept(EFsFileWrite,		EPrePostIntercept));
   1.113 +	User::LeaveIfError(UnregisterIntercept(EFsDirOpen,			EPrePostIntercept));
   1.114 +	User::LeaveIfError(UnregisterIntercept(EFsFileLock,			EPrePostIntercept));
   1.115 +	User::LeaveIfError(UnregisterIntercept(EFsFileUnLock,		EPrePostIntercept));
   1.116 +	User::LeaveIfError(UnregisterIntercept(EFsFileSeek,			EPrePostIntercept));
   1.117 +	User::LeaveIfError(UnregisterIntercept(EFsFileSize,			EPrePostIntercept));
   1.118 +	User::LeaveIfError(UnregisterIntercept(EFsFileSetSize,		EPrePostIntercept));
   1.119 +	User::LeaveIfError(UnregisterIntercept(EFsFileCreate,		EPrePostIntercept));
   1.120 +	User::LeaveIfError(UnregisterIntercept(EFsFileOpen, 		EPrePostIntercept));
   1.121 +	User::LeaveIfError(UnregisterIntercept(EFsFileReplace, 		EPrePostIntercept));
   1.122 +	User::LeaveIfError(UnregisterIntercept(EFsFileSubClose, 	EPrePostIntercept));
   1.123 +	User::LeaveIfError(UnregisterIntercept(EFsReadFileSection,	EPrePostIntercept));
   1.124 +	User::LeaveIfError(UnregisterIntercept(EFsDirReadOne,		EPrePostIntercept));
   1.125 +	User::LeaveIfError(UnregisterIntercept(EFsDirReadPacked,	EPrePostIntercept));
   1.126 +	User::LeaveIfError(UnregisterIntercept(EFsEntry,        	EPrePostIntercept));
   1.127 +	User::LeaveIfError(UnregisterIntercept(EFsSetEntry,      	EPrePostIntercept));
   1.128 +	
   1.129 +	_LOG(_L("Combinational2 Plugin: Disabled intercepts."));
   1.130 +    
   1.131 +	iInterceptsEnabled = EFalse;
   1.132 +	}
   1.133 +
   1.134 +/*
   1.135 +	Test second stage: - This is part of a test which is opening a different file in CombinationalPlugin1.
   1.136 +			We need to get the entry here and make sure its for the right file.
   1.137 +*/
   1.138 +TInt CCombinational2Plugin::DoEntry(TFsPluginRequest& aRequest)
   1.139 +	{
   1.140 +	TInt err = KErrNone;
   1.141 +	
   1.142 +	if(aRequest.IsPostOperation()) //post
   1.143 +		{
   1.144 +		}
   1.145 +	else // PRE
   1.146 +		{
   1.147 +		err = KErrNone;
   1.148 +		TEntry entry;
   1.149 +
   1.150 +		RFsPlugin fs(aRequest);
   1.151 +
   1.152 +		TFileName name;
   1.153 +		name = aRequest.Src().FullName();	//STF: Is this valid for entry?
   1.154 +
   1.155 +		err = fs.Connect();
   1.156 +		iLastError = err;
   1.157 +		iLineNumber = __LINE__;
   1.158 +		if(err!=KErrNone)
   1.159 +			return err;
   1.160 +		
   1.161 +		err = fs.Entry(name, entry);
   1.162 +		iLastError = err;
   1.163 +		iLineNumber = __LINE__;
   1.164 +		if(err!=KErrNone)
   1.165 +			return err;
   1.166 +		
   1.167 +		TPckgC<TEntry> e(entry);
   1.168 +		err = aRequest.Write(TFsPluginRequest::EEntry,e);
   1.169 +		iLastError = err;
   1.170 +		iLineNumber = __LINE__;
   1.171 +		if(err!=KErrNone)
   1.172 +			return err;
   1.173 +		
   1.174 +		fs.Close();
   1.175 +		
   1.176 +		return KErrCompletion;
   1.177 +		}
   1.178 +	return err;
   1.179 +	}
   1.180 +
   1.181 +/**
   1.182 +Handle requests
   1.183 +@internalComponent
   1.184 +*/
   1.185 +TInt CCombinational2Plugin::DoRequestL(TFsPluginRequest& aRequest)
   1.186 +	{
   1.187 +	TInt err = KErrNone;
   1.188 +
   1.189 +	TInt function = aRequest.Function();
   1.190 +	
   1.191 +	switch(function)
   1.192 +		{
   1.193 +		case EFsEntry:
   1.194 +			err = DoEntry(aRequest);
   1.195 +			break;
   1.196 +		default:
   1.197 +			break;
   1.198 +		}
   1.199 +
   1.200 +	return err;
   1.201 +	}
   1.202 +
   1.203 +
   1.204 +CFsPluginConn* CCombinational2Plugin::NewPluginConnL()
   1.205 +	{
   1.206 +	return new(ELeave) CCombinational2PluginConn();
   1.207 +	}
   1.208 +
   1.209 +
   1.210 +//Synchronous RPlugin::DoControl
   1.211 +TInt CCombinational2Plugin::FsPluginDoControlL(CFsPluginConnRequest& aRequest)
   1.212 +	{	
   1.213 +	TInt err = KErrNone;
   1.214 +
   1.215 +	TInt function = aRequest.Function();
   1.216 +
   1.217 +	TPckg<TInt> errCodeDes(iLastError);
   1.218 +	TPckg<TInt> lineNumberDes(iLineNumber);
   1.219 +	
   1.220 +	switch(function)
   1.221 +		{
   1.222 +		case KPluginGetError:
   1.223 +			{
   1.224 +			TRAP(err,aRequest.WriteParam1L(errCodeDes));
   1.225 +			TRAP(err,aRequest.WriteParam2L(lineNumberDes));
   1.226 +			break;
   1.227 +			}
   1.228 +		default:
   1.229 +			break;
   1.230 +		}
   1.231 +
   1.232 +	return err;
   1.233 +	}
   1.234 +
   1.235 +
   1.236 +TInt CCombinational2PluginConn::DoControl(CFsPluginConnRequest& aRequest)
   1.237 +	{
   1.238 +	return ((CCombinational2Plugin*)Plugin())->FsPluginDoControlL(aRequest);
   1.239 +	}
   1.240 +
   1.241 +void CCombinational2PluginConn::DoRequest(CFsPluginConnRequest& aRequest)
   1.242 +	{
   1.243 +	DoControl(aRequest);
   1.244 +	}
   1.245 +
   1.246 +void CCombinational2PluginConn::DoCancel(TInt /*aReqMask*/)
   1.247 +	{
   1.248 +	}
   1.249 +
   1.250 +//factory functions
   1.251 +
   1.252 +class CCombinational2PluginFactory : public CFsPluginFactory
   1.253 +	{
   1.254 +public:
   1.255 +	CCombinational2PluginFactory();
   1.256 +	virtual TInt Install();			
   1.257 +	virtual CFsPlugin* NewPluginL();
   1.258 +	virtual CFsPlugin* NewPluginConnL();
   1.259 +	virtual TInt UniquePosition();
   1.260 +	};
   1.261 +
   1.262 +/**
   1.263 +Constructor for the plugin factory
   1.264 +@internalComponent
   1.265 +*/
   1.266 +CCombinational2PluginFactory::CCombinational2PluginFactory()
   1.267 +	{
   1.268 +	}
   1.269 +
   1.270 +/**
   1.271 +Install function for the plugin factory
   1.272 +@internalComponent
   1.273 +*/
   1.274 +TInt CCombinational2PluginFactory::Install()
   1.275 +	{
   1.276 +	SetSupportedDrives(KPluginSupportAllDrives);
   1.277 +	return(SetName(&KCombinational2PluginName));
   1.278 +	}
   1.279 +
   1.280 +/**
   1.281 +@internalComponent
   1.282 +*/
   1.283 +TInt CCombinational2PluginFactory::UniquePosition()
   1.284 +	{
   1.285 +	return(KCombinational2Pos);
   1.286 +	}
   1.287 +
   1.288 +/**
   1.289 +Plugin factory function
   1.290 +@internalComponent
   1.291 +*/
   1.292 +CFsPlugin* CCombinational2PluginFactory::NewPluginL()
   1.293 +
   1.294 +	{
   1.295 +	return CCombinational2Plugin::NewL();
   1.296 +	}
   1.297 +
   1.298 +/**
   1.299 +Plugin factory function
   1.300 +@internalComponent
   1.301 +*/
   1.302 +CFsPlugin* CCombinational2PluginFactory::NewPluginConnL()
   1.303 +
   1.304 +	{
   1.305 +	return CCombinational2Plugin::NewL();
   1.306 +	}
   1.307 +
   1.308 +/**
   1.309 +Create a new Plugin
   1.310 +@internalComponent
   1.311 +*/
   1.312 +extern "C" {
   1.313 +
   1.314 +EXPORT_C CFsPluginFactory* CreateFileSystem()
   1.315 +	{
   1.316 +	return(new CCombinational2PluginFactory());
   1.317 +	}
   1.318 +}
   1.319 +