os/kernelhwsrv/kerneltest/f32test/plugins/version_2/src/combinational2_plugin.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #include "Combinational2_plugin.h"
    17 #include "plugincommon.h"
    18 #include <f32pluginutils.h>
    19 
    20 
    21 /**
    22 Leaving New function for the plugin
    23 @internalComponent
    24 */
    25 CCombinational2Plugin* CCombinational2Plugin::NewL()
    26 	{
    27 	CCombinational2Plugin* self = new(ELeave) CCombinational2Plugin;
    28     CleanupStack::PushL(self);
    29     self->ConstructL();
    30     CleanupStack::Pop();
    31 	return self;
    32 	}
    33 
    34 
    35 /**
    36 Constructor for the plugin
    37 @internalComponent
    38 */
    39 CCombinational2Plugin::CCombinational2Plugin() : iInterceptsEnabled(EFalse),
    40 									 iLogging(ETrue)
    41 	{
    42 	}
    43 
    44 
    45 void CCombinational2Plugin::ConstructL()
    46 	{
    47 	}
    48 
    49 /**
    50 The destructor for the plugin
    51 @internalComponent
    52 */
    53 CCombinational2Plugin::~CCombinational2Plugin()
    54 	{
    55 	}
    56 
    57 /**
    58 Initialise the plugin.
    59 @internalComponent
    60 */
    61 void CCombinational2Plugin::InitialiseL()
    62 	{
    63 	_LOG(_L("CCombinational2Plugin InitialiseL"));
    64 	EnableInterceptsL();
    65 	}
    66 
    67 /**
    68 Enable the plugin's intercepts.
    69 @internalComponent
    70 */
    71 void CCombinational2Plugin::EnableInterceptsL()
    72 	{
    73 	if (iInterceptsEnabled) return;
    74 	
    75 	User::LeaveIfError(RegisterIntercept(EFsFileRead,		EPrePostIntercept));
    76 	User::LeaveIfError(RegisterIntercept(EFsFileWrite,		EPrePostIntercept));
    77 	User::LeaveIfError(RegisterIntercept(EFsDirOpen,		EPrePostIntercept));
    78 	User::LeaveIfError(RegisterIntercept(EFsFileLock,		EPrePostIntercept));
    79 	User::LeaveIfError(RegisterIntercept(EFsFileUnLock,		EPrePostIntercept));
    80 	User::LeaveIfError(RegisterIntercept(EFsFileSeek,		EPrePostIntercept));
    81 	User::LeaveIfError(RegisterIntercept(EFsFileSize,		EPrePostIntercept));
    82 	User::LeaveIfError(RegisterIntercept(EFsFileSetSize,	EPrePostIntercept));
    83 	User::LeaveIfError(RegisterIntercept(EFsDirReadOne,		EPrePostIntercept));
    84 	User::LeaveIfError(RegisterIntercept(EFsDirReadPacked,	EPrePostIntercept));
    85 	User::LeaveIfError(RegisterIntercept(EFsFileOpen,		EPrePostIntercept));
    86 	User::LeaveIfError(RegisterIntercept(EFsFileCreate,		EPrePostIntercept));
    87 	User::LeaveIfError(RegisterIntercept(EFsFileReplace,	EPrePostIntercept));
    88 	User::LeaveIfError(RegisterIntercept(EFsFileRename,		EPrePostIntercept));
    89    	User::LeaveIfError(RegisterIntercept(EFsReadFileSection,EPrePostIntercept));
    90 	User::LeaveIfError(RegisterIntercept(EFsFileSubClose,   EPrePostIntercept));
    91 	User::LeaveIfError(RegisterIntercept(EFsEntry,        	EPrePostIntercept));
    92 	User::LeaveIfError(RegisterIntercept(EFsSetEntry,      	EPrePostIntercept));
    93 
    94 	_LOG(_L("Combinational2 Plugin: Enabled intercepts."));
    95     
    96 	iInterceptsEnabled = ETrue;
    97 	}
    98 
    99 /**
   100 Disable the plugin's intercepts.
   101 @internalComponent
   102 */
   103 void CCombinational2Plugin::DisableInterceptsL()
   104 	{
   105 	if (!iInterceptsEnabled) return;
   106 	
   107 	User::LeaveIfError(UnregisterIntercept(EFsFileRead,			EPrePostIntercept));
   108 	User::LeaveIfError(UnregisterIntercept(EFsFileRename,		EPrePostIntercept));
   109 	User::LeaveIfError(UnregisterIntercept(EFsFileWrite,		EPrePostIntercept));
   110 	User::LeaveIfError(UnregisterIntercept(EFsDirOpen,			EPrePostIntercept));
   111 	User::LeaveIfError(UnregisterIntercept(EFsFileLock,			EPrePostIntercept));
   112 	User::LeaveIfError(UnregisterIntercept(EFsFileUnLock,		EPrePostIntercept));
   113 	User::LeaveIfError(UnregisterIntercept(EFsFileSeek,			EPrePostIntercept));
   114 	User::LeaveIfError(UnregisterIntercept(EFsFileSize,			EPrePostIntercept));
   115 	User::LeaveIfError(UnregisterIntercept(EFsFileSetSize,		EPrePostIntercept));
   116 	User::LeaveIfError(UnregisterIntercept(EFsFileCreate,		EPrePostIntercept));
   117 	User::LeaveIfError(UnregisterIntercept(EFsFileOpen, 		EPrePostIntercept));
   118 	User::LeaveIfError(UnregisterIntercept(EFsFileReplace, 		EPrePostIntercept));
   119 	User::LeaveIfError(UnregisterIntercept(EFsFileSubClose, 	EPrePostIntercept));
   120 	User::LeaveIfError(UnregisterIntercept(EFsReadFileSection,	EPrePostIntercept));
   121 	User::LeaveIfError(UnregisterIntercept(EFsDirReadOne,		EPrePostIntercept));
   122 	User::LeaveIfError(UnregisterIntercept(EFsDirReadPacked,	EPrePostIntercept));
   123 	User::LeaveIfError(UnregisterIntercept(EFsEntry,        	EPrePostIntercept));
   124 	User::LeaveIfError(UnregisterIntercept(EFsSetEntry,      	EPrePostIntercept));
   125 	
   126 	_LOG(_L("Combinational2 Plugin: Disabled intercepts."));
   127     
   128 	iInterceptsEnabled = EFalse;
   129 	}
   130 
   131 /*
   132 	Test second stage: - This is part of a test which is opening a different file in CombinationalPlugin1.
   133 			We need to get the entry here and make sure its for the right file.
   134 */
   135 TInt CCombinational2Plugin::DoEntry(TFsPluginRequest& aRequest)
   136 	{
   137 	TInt err = KErrNone;
   138 	
   139 	if(aRequest.IsPostOperation()) //post
   140 		{
   141 		}
   142 	else // PRE
   143 		{
   144 		err = KErrNone;
   145 		TEntry entry;
   146 
   147 		RFsPlugin fs(aRequest);
   148 
   149 		TFileName name;
   150 		name = aRequest.Src().FullName();	//STF: Is this valid for entry?
   151 
   152 		err = fs.Connect();
   153 		iLastError = err;
   154 		iLineNumber = __LINE__;
   155 		if(err!=KErrNone)
   156 			return err;
   157 		
   158 		err = fs.Entry(name, entry);
   159 		iLastError = err;
   160 		iLineNumber = __LINE__;
   161 		if(err!=KErrNone)
   162 			return err;
   163 		
   164 		TPckgC<TEntry> e(entry);
   165 		err = aRequest.Write(TFsPluginRequest::EEntry,e);
   166 		iLastError = err;
   167 		iLineNumber = __LINE__;
   168 		if(err!=KErrNone)
   169 			return err;
   170 		
   171 		fs.Close();
   172 		
   173 		return KErrCompletion;
   174 		}
   175 	return err;
   176 	}
   177 
   178 /**
   179 Handle requests
   180 @internalComponent
   181 */
   182 TInt CCombinational2Plugin::DoRequestL(TFsPluginRequest& aRequest)
   183 	{
   184 	TInt err = KErrNone;
   185 
   186 	TInt function = aRequest.Function();
   187 	
   188 	switch(function)
   189 		{
   190 		case EFsEntry:
   191 			err = DoEntry(aRequest);
   192 			break;
   193 		default:
   194 			break;
   195 		}
   196 
   197 	return err;
   198 	}
   199 
   200 
   201 CFsPluginConn* CCombinational2Plugin::NewPluginConnL()
   202 	{
   203 	return new(ELeave) CCombinational2PluginConn();
   204 	}
   205 
   206 
   207 //Synchronous RPlugin::DoControl
   208 TInt CCombinational2Plugin::FsPluginDoControlL(CFsPluginConnRequest& aRequest)
   209 	{	
   210 	TInt err = KErrNone;
   211 
   212 	TInt function = aRequest.Function();
   213 
   214 	TPckg<TInt> errCodeDes(iLastError);
   215 	TPckg<TInt> lineNumberDes(iLineNumber);
   216 	
   217 	switch(function)
   218 		{
   219 		case KPluginGetError:
   220 			{
   221 			TRAP(err,aRequest.WriteParam1L(errCodeDes));
   222 			TRAP(err,aRequest.WriteParam2L(lineNumberDes));
   223 			break;
   224 			}
   225 		default:
   226 			break;
   227 		}
   228 
   229 	return err;
   230 	}
   231 
   232 
   233 TInt CCombinational2PluginConn::DoControl(CFsPluginConnRequest& aRequest)
   234 	{
   235 	return ((CCombinational2Plugin*)Plugin())->FsPluginDoControlL(aRequest);
   236 	}
   237 
   238 void CCombinational2PluginConn::DoRequest(CFsPluginConnRequest& aRequest)
   239 	{
   240 	DoControl(aRequest);
   241 	}
   242 
   243 void CCombinational2PluginConn::DoCancel(TInt /*aReqMask*/)
   244 	{
   245 	}
   246 
   247 //factory functions
   248 
   249 class CCombinational2PluginFactory : public CFsPluginFactory
   250 	{
   251 public:
   252 	CCombinational2PluginFactory();
   253 	virtual TInt Install();			
   254 	virtual CFsPlugin* NewPluginL();
   255 	virtual CFsPlugin* NewPluginConnL();
   256 	virtual TInt UniquePosition();
   257 	};
   258 
   259 /**
   260 Constructor for the plugin factory
   261 @internalComponent
   262 */
   263 CCombinational2PluginFactory::CCombinational2PluginFactory()
   264 	{
   265 	}
   266 
   267 /**
   268 Install function for the plugin factory
   269 @internalComponent
   270 */
   271 TInt CCombinational2PluginFactory::Install()
   272 	{
   273 	SetSupportedDrives(KPluginSupportAllDrives);
   274 	return(SetName(&KCombinational2PluginName));
   275 	}
   276 
   277 /**
   278 @internalComponent
   279 */
   280 TInt CCombinational2PluginFactory::UniquePosition()
   281 	{
   282 	return(KCombinational2Pos);
   283 	}
   284 
   285 /**
   286 Plugin factory function
   287 @internalComponent
   288 */
   289 CFsPlugin* CCombinational2PluginFactory::NewPluginL()
   290 
   291 	{
   292 	return CCombinational2Plugin::NewL();
   293 	}
   294 
   295 /**
   296 Plugin factory function
   297 @internalComponent
   298 */
   299 CFsPlugin* CCombinational2PluginFactory::NewPluginConnL()
   300 
   301 	{
   302 	return CCombinational2Plugin::NewL();
   303 	}
   304 
   305 /**
   306 Create a new Plugin
   307 @internalComponent
   308 */
   309 extern "C" {
   310 
   311 EXPORT_C CFsPluginFactory* CreateFileSystem()
   312 	{
   313 	return(new CCombinational2PluginFactory());
   314 	}
   315 }
   316