os/kernelhwsrv/kerneltest/f32test/plugins/version_2/src/template_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 "template_plugin.h"
    17 #include <f32pluginutils.h>
    18 
    19 /**
    20 Leaving New function for the plugin
    21 @internalComponent
    22 */
    23 CTemplatePlugin* CTemplatePlugin::NewL()
    24 	{
    25 	CTemplatePlugin* self = new(ELeave) CTemplatePlugin;
    26     CleanupStack::PushL(self);
    27     self->ConstructL();
    28     CleanupStack::Pop();
    29 	return self;
    30 	}
    31 
    32 
    33 /**
    34 Constructor for the plugin
    35 @internalComponent
    36 */
    37 CTemplatePlugin::CTemplatePlugin() : iInterceptsEnabled(EFalse),
    38 									 iLogging(ETrue)
    39 	{
    40 	}
    41 
    42 
    43 void CTemplatePlugin::ConstructL()
    44 	{
    45 	}
    46 
    47 /**
    48 The destructor for the plugin
    49 @internalComponent
    50 */
    51 CTemplatePlugin::~CTemplatePlugin()
    52 	{
    53 	iFs.Close();
    54 	}
    55 
    56 /**
    57 Initialise the plugin.
    58 @internalComponent
    59 */
    60 void CTemplatePlugin::InitialiseL()
    61 	{
    62 	User::LeaveIfError(iFs.Connect());
    63 	CleanupClosePushL(iFs);
    64 
    65 	_LOG(_L("CTemplatePlugin InitialiseL"));
    66 	EnableInterceptsL();
    67 	
    68 	CleanupStack::Pop(); // iFs
    69 	}
    70 
    71 /**
    72 Enable the plugin's intercepts.
    73 @internalComponent
    74 */
    75 void CTemplatePlugin::EnableInterceptsL()
    76 	{
    77 	if (iInterceptsEnabled) return;
    78 	
    79 	User::LeaveIfError(RegisterIntercept(EFsFileRead,		EPrePostIntercept));
    80 	User::LeaveIfError(RegisterIntercept(EFsFileWrite,		EPrePostIntercept));
    81 	User::LeaveIfError(RegisterIntercept(EFsDirOpen,		EPrePostIntercept));
    82 	User::LeaveIfError(RegisterIntercept(EFsFileLock,		EPrePostIntercept));
    83 	User::LeaveIfError(RegisterIntercept(EFsFileUnLock,		EPrePostIntercept));
    84 	User::LeaveIfError(RegisterIntercept(EFsFileSeek,		EPrePostIntercept));
    85 	User::LeaveIfError(RegisterIntercept(EFsFileSize,		EPrePostIntercept));
    86 	User::LeaveIfError(RegisterIntercept(EFsFileSetSize,	EPrePostIntercept));
    87 	User::LeaveIfError(RegisterIntercept(EFsDirReadOne,		EPrePostIntercept));
    88 	User::LeaveIfError(RegisterIntercept(EFsDirReadPacked,	EPrePostIntercept));
    89 	User::LeaveIfError(RegisterIntercept(EFsFileOpen,	EPrePostIntercept));
    90 	User::LeaveIfError(RegisterIntercept(EFsFileCreate,	EPrePostIntercept));
    91 	User::LeaveIfError(RegisterIntercept(EFsFileReplace,EPrePostIntercept));
    92 	User::LeaveIfError(RegisterIntercept(EFsFileRename,	EPrePostIntercept));
    93    	User::LeaveIfError(RegisterIntercept(EFsReadFileSection,EPrePostIntercept));
    94 	User::LeaveIfError(RegisterIntercept(EFsFileSubClose,        EPrePostIntercept)); 
    95 
    96 	_LOG(_L("Template Plugin: Enabled intercepts."));
    97     
    98 	iInterceptsEnabled = ETrue;
    99 	}
   100 
   101 /**
   102 Disable the plugin's intercepts.
   103 @internalComponent
   104 */
   105 void CTemplatePlugin::DisableInterceptsL()
   106 	{
   107 	if (!iInterceptsEnabled) return;
   108 	
   109 	User::LeaveIfError(UnregisterIntercept(EFsFileRead,		EPrePostIntercept));
   110 	User::LeaveIfError(UnregisterIntercept(EFsFileRename,	EPrePostIntercept));
   111 	User::LeaveIfError(UnregisterIntercept(EFsFileWrite,	EPrePostIntercept));
   112 	User::LeaveIfError(UnregisterIntercept(EFsDirOpen,		EPrePostIntercept));
   113 	User::LeaveIfError(UnregisterIntercept(EFsFileLock,		EPrePostIntercept));
   114 	User::LeaveIfError(UnregisterIntercept(EFsFileUnLock,	EPrePostIntercept));
   115 	User::LeaveIfError(UnregisterIntercept(EFsFileSeek,		EPrePostIntercept));
   116 	User::LeaveIfError(UnregisterIntercept(EFsFileSize,		EPrePostIntercept));
   117 	User::LeaveIfError(UnregisterIntercept(EFsFileSetSize,	EPrePostIntercept));
   118 	User::LeaveIfError(UnregisterIntercept(EFsFileCreate,	EPrePostIntercept));
   119 	User::LeaveIfError(UnregisterIntercept(EFsFileOpen, 	EPrePostIntercept));
   120 	User::LeaveIfError(UnregisterIntercept(EFsFileReplace, 	EPrePostIntercept));
   121 	User::LeaveIfError(UnregisterIntercept(EFsFileSubClose, EPrePostIntercept));
   122 	User::LeaveIfError(UnregisterIntercept(EFsReadFileSection,EPrePostIntercept));
   123 	User::LeaveIfError(UnregisterIntercept(EFsDirReadOne,	EPrePostIntercept));
   124 	User::LeaveIfError(UnregisterIntercept(EFsDirReadPacked,EPrePostIntercept));
   125 
   126 
   127 	_LOG(_L("Template Plugin: Disabled intercepts."));
   128     
   129 	iInterceptsEnabled = EFalse;
   130 	}
   131 
   132 /**
   133 Handle requests
   134 @internalComponent
   135 */
   136 TInt CTemplatePlugin::DoRequestL(TFsPluginRequest& aRequest)
   137 	{
   138 	TInt err = KErrNone;
   139 
   140 	TInt function = aRequest.Function();
   141 
   142 	if (aRequest.IsPostOperation())
   143 		{
   144 		_LOG2(_L("CTemplatePlugin post intercept for function %d"), function);
   145 		}
   146 	else
   147 		{
   148 		_LOG2(_L("CTemplatePlugin pre intercept for function %d"), function);
   149 		}
   150 
   151 	return err;
   152 	}
   153 
   154 
   155 CFsPluginConn* CTemplatePlugin::NewPluginConnL()
   156 	{
   157 	return new(ELeave) CTemplatePluginConn();
   158 	}
   159 
   160 //Synchronous RPlugin::DoControl
   161 TInt CTemplatePlugin::FsPluginDoControlL(CFsPluginConnRequest& /*aRequest*/)
   162 	{
   163 	/*TInt function = aRequest.Function();
   164 
   165 	switch(function)
   166 		{
   167 		default:
   168 			break;
   169 		}
   170 	*/
   171 	return KErrNone;
   172 	}
   173 
   174 
   175 TInt CTemplatePluginConn::DoControl(CFsPluginConnRequest& aRequest)
   176 	{
   177 	return ((CTemplatePlugin*)Plugin())->FsPluginDoControlL(aRequest);
   178 	}
   179 
   180 void CTemplatePluginConn::DoRequest(CFsPluginConnRequest& aRequest)
   181 	{
   182 	DoControl(aRequest);
   183 	}
   184 
   185 void CTemplatePluginConn::DoCancel(TInt /*aReqMask*/)
   186 	{
   187 	}
   188 
   189 
   190 
   191 
   192 
   193 //factory functions
   194 
   195 class CTemplatePluginFactory : public CFsPluginFactory
   196 	{
   197 public:
   198 	CTemplatePluginFactory();
   199 	virtual TInt Install();			
   200 	virtual CFsPlugin* NewPluginL();
   201 	virtual CFsPlugin* NewPluginConnL();
   202 	virtual TInt UniquePosition();
   203 	};
   204 
   205 /**
   206 Constructor for the plugin factory
   207 @internalComponent
   208 */
   209 CTemplatePluginFactory::CTemplatePluginFactory()
   210 	{
   211 	}
   212 
   213 /**
   214 Install function for the plugin factory
   215 @internalComponent
   216 */
   217 TInt CTemplatePluginFactory::Install()
   218 	{
   219 	SetSupportedDrives(KPluginSupportAllDrives);
   220 	return(SetName(&KTemplatePluginName));
   221 	}
   222 
   223 /**
   224 @internalComponent
   225 */
   226 TInt CTemplatePluginFactory::UniquePosition()
   227 	{
   228 	return(KTemplatePos);
   229 	}
   230 
   231 /**
   232 Plugin factory function
   233 @internalComponent
   234 */
   235 CFsPlugin* CTemplatePluginFactory::NewPluginL()
   236 
   237 	{
   238 	return CTemplatePlugin::NewL();
   239 	}
   240 
   241 /**
   242 Plugin factory function
   243 @internalComponent
   244 */
   245 CFsPlugin* CTemplatePluginFactory::NewPluginConnL()
   246 
   247 	{
   248 	return CTemplatePlugin::NewL();
   249 	}
   250 
   251 /**
   252 Create a new Plugin
   253 @internalComponent
   254 */
   255 extern "C" {
   256 
   257 EXPORT_C CFsPluginFactory* CreateFileSystem()
   258 	{
   259 	return(new CTemplatePluginFactory());
   260 	}
   261 }
   262