os/kernelhwsrv/kerneltest/f32test/plugins/version_2/src/premodifier_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 // modifier_plugin.cpp
    15 // 
    16 //
    17 
    18 #include "premodifier_plugin.h"
    19 #include "plugincommon.h"
    20 
    21 /**
    22 Leaving New function for the plugin
    23 @internalComponent
    24 */
    25 CPreModifierPlugin* CPreModifierPlugin::NewL()
    26 	{
    27 	CPreModifierPlugin* self = new(ELeave) CPreModifierPlugin;
    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 CPreModifierPlugin::CPreModifierPlugin() : iInterceptsEnabled(EFalse),
    40 									 iLogging(ETrue)
    41 	{
    42 	}
    43 
    44 
    45 void CPreModifierPlugin::ConstructL()
    46 	{
    47 	}
    48 
    49 /**
    50 The destructor for the plugin
    51 @internalComponent
    52 */
    53 CPreModifierPlugin::~CPreModifierPlugin()
    54 	{
    55 	}
    56 
    57 /**
    58 Initialise the plugin.
    59 @internalComponent
    60 */
    61 void CPreModifierPlugin::InitialiseL()
    62 	{
    63 	EnableInterceptsL();
    64 	}
    65 
    66 /**
    67 Enable the plugin's intercepts.
    68 @internalComponent
    69 */
    70 void CPreModifierPlugin::EnableInterceptsL()
    71 	{
    72 	if (iInterceptsEnabled) return;
    73 
    74     User::LeaveIfError(RegisterIntercept(EFsFileRead,   		EPostIntercept));
    75     User::LeaveIfError(RegisterIntercept(EFsFileWrite, 		 	EPostIntercept));
    76 	User::LeaveIfError(RegisterIntercept(EFsFileRename,		 	EPostIntercept));
    77 	User::LeaveIfError(RegisterIntercept(EFsFileCreate,		 	EPostIntercept));
    78 	User::LeaveIfError(RegisterIntercept(EFsFileSize,  		 	EPostIntercept));
    79 	User::LeaveIfError(RegisterIntercept(EFsFileSetSize,	 	EPostIntercept));
    80 	User::LeaveIfError(RegisterIntercept(EFsFileLock,  			EPostIntercept));
    81 	User::LeaveIfError(RegisterIntercept(EFsFileUnLock,  		EPostIntercept));
    82 	User::LeaveIfError(RegisterIntercept(EFsFileOpen,			EPostIntercept));
    83 	User::LeaveIfError(RegisterIntercept(EFsFileReplace,		EPostIntercept));
    84 	User::LeaveIfError(RegisterIntercept(EFsReadFileSection,	EPostIntercept));
    85 	User::LeaveIfError(RegisterIntercept(EFsDirReadOne,  		EPostIntercept));
    86 	User::LeaveIfError(RegisterIntercept(EFsDirReadPacked,		EPostIntercept));
    87 	User::LeaveIfError(RegisterIntercept(EFsFileSubClose,       EPostIntercept));
    88 	User::LeaveIfError(RegisterIntercept(EFsDirOpen,			EPostIntercept));
    89 	User::LeaveIfError(RegisterIntercept(EFsFileTemp,			EPostIntercept));
    90 	User::LeaveIfError(RegisterIntercept(EFsDelete,				EPostIntercept));
    91 	User::LeaveIfError(RegisterIntercept(EFsReplace,			EPostIntercept));
    92 	User::LeaveIfError(RegisterIntercept(EFsRename,				EPostIntercept));
    93 	User::LeaveIfError(RegisterIntercept(EFsEntry,				EPostIntercept));
    94 	User::LeaveIfError(RegisterIntercept(EFsSetEntry,			EPostIntercept));
    95 	User::LeaveIfError(RegisterIntercept(EFsFileSeek,			EPostIntercept));
    96 
    97     _LOG(_L("Pre-Modifier Plugin: Enabled intercepts."));
    98 
    99     iInterceptsEnabled = ETrue;
   100 	}
   101 
   102 /**
   103 Disable the plugin's intercepts.
   104 @internalComponent
   105 */
   106 void CPreModifierPlugin::DisableInterceptsL()
   107 	{
   108 	if (!iInterceptsEnabled) return;
   109 
   110     User::LeaveIfError(UnregisterIntercept(EFsFileRead,    		EPostIntercept));
   111     User::LeaveIfError(UnregisterIntercept(EFsFileWrite,   		EPostIntercept));
   112     User::LeaveIfError(UnregisterIntercept(EFsFileRename,  		EPostIntercept));
   113 	User::LeaveIfError(UnregisterIntercept(EFsFileCreate,  		EPostIntercept));
   114 	User::LeaveIfError(UnregisterIntercept(EFsFileSize,    		EPostIntercept));
   115 	User::LeaveIfError(UnregisterIntercept(EFsFileSetSize, 		EPostIntercept));
   116 	User::LeaveIfError(UnregisterIntercept(EFsFileLock,    		EPostIntercept));
   117 	User::LeaveIfError(UnregisterIntercept(EFsFileUnLock,  		EPostIntercept));
   118 	User::LeaveIfError(UnregisterIntercept(EFsFileOpen,        	EPostIntercept));
   119 	User::LeaveIfError(UnregisterIntercept(EFsFileReplace,      EPostIntercept));
   120 	User::LeaveIfError(UnregisterIntercept(EFsReadFileSection,  EPostIntercept));
   121 	User::LeaveIfError(UnregisterIntercept(EFsDirReadOne,  		EPostIntercept));
   122 	User::LeaveIfError(UnregisterIntercept(EFsDirReadPacked,	EPostIntercept));
   123 	User::LeaveIfError(UnregisterIntercept(EFsFileSubClose,     EPostIntercept));
   124 	User::LeaveIfError(UnregisterIntercept(EFsDirOpen,			EPostIntercept));
   125 	User::LeaveIfError(UnregisterIntercept(EFsFileTemp,			EPostIntercept));
   126 	User::LeaveIfError(UnregisterIntercept(EFsDelete,			EPostIntercept));
   127 	User::LeaveIfError(UnregisterIntercept(EFsReplace,			EPostIntercept));
   128 	User::LeaveIfError(UnregisterIntercept(EFsRename,			EPostIntercept));
   129 	User::LeaveIfError(UnregisterIntercept(EFsEntry,			EPostIntercept));
   130 	User::LeaveIfError(UnregisterIntercept(EFsSetEntry,			EPostIntercept));
   131 	User::LeaveIfError(UnregisterIntercept(EFsFileSeek,			EPostIntercept));
   132 
   133     _LOG(_L("Pre-Modifier Plugin: Disabled intercepts."));
   134 
   135     iInterceptsEnabled = EFalse;
   136 	}
   137 
   138 /**
   139 Handle requests
   140 @internalComponent
   141 */
   142 TInt CPreModifierPlugin::DoRequestL(TFsPluginRequest& aRequest)
   143 	{
   144 	TInt err = KErrNone;
   145 
   146 	TInt function = aRequest.Function();
   147 
   148 	switch(function)
   149 		{
   150 		case EFsFileRead:
   151 			TRAP(err, FsFileReadL(aRequest));
   152 			break;
   153 
   154 		case EFsFileWrite:
   155 			TRAP(err, FsFileWriteL(aRequest));
   156 			break;
   157 
   158 		case EFsFileRename:
   159 			TRAP(err, FsFileRenameL(aRequest));
   160 			break;
   161 
   162 		case EFsFileCreate:
   163 			TRAP(err, FsFileCreateL(aRequest));
   164 			break;
   165 
   166 		case EFsFileSize:
   167 			TRAP(err, FsFileSizeL(aRequest));
   168 			break;
   169 
   170 		case EFsFileSetSize:
   171 			TRAP(err, FsFileSetSizeL(aRequest));
   172 			break;
   173 
   174 		case EFsFileLock:
   175 			TRAP(err, FsFileLockL(aRequest));
   176 			break;
   177 
   178 		case EFsFileUnLock:
   179 			TRAP(err, FsFileUnLockL(aRequest));
   180 			break;
   181 
   182 		case EFsFileSeek:
   183 			TRAP(err, FsFileSeekL(aRequest));
   184 			break;
   185 
   186 		case EFsDirReadOne:
   187 			TRAP(err,FsDirReadOneL(aRequest));
   188 			break;
   189 
   190 		case EFsDirReadPacked:
   191 			TRAP(err,FsDirReadPackedL(aRequest));
   192 			break;
   193 
   194 		case EFsFileOpen:
   195 			TRAP(err, FsFileOpenL(aRequest));
   196 			break;
   197 
   198 		case EFsFileReplace:
   199 			TRAP(err, FsFileReplaceL(aRequest));
   200 			break;
   201 
   202 		case EFsReadFileSection:
   203 			TRAP(err, FsReadFileSectionL(aRequest));
   204 			break;
   205 
   206 		case EFsFileSubClose:
   207 			TRAP(err, FsFileSubCloseL(aRequest));
   208 			break;
   209 
   210 		case EFsDirOpen:
   211 			TRAP(err, FsDirOpenL(aRequest));
   212 			break;
   213 
   214 		case EFsFileTemp:
   215 			TRAP(err, FsFileTempL(aRequest));
   216 			break;
   217 
   218 		case EFsDelete:
   219 			TRAP(err, FsDeleteL(aRequest));
   220 			break;
   221 
   222 		case EFsReplace:
   223 			TRAP(err, FsReplaceL(aRequest));
   224 			break;
   225 
   226 		case EFsRename:
   227 			TRAP(err, FsRenameL(aRequest));
   228 			break;
   229 
   230 		case EFsEntry:
   231 			TRAP(err, FsEntryL(aRequest));
   232 			break;
   233 
   234 		case EFsSetEntry:
   235 			TRAP(err, FsSetEntryL(aRequest));
   236 			break;
   237 
   238 		default:
   239 			break;
   240 		}
   241 
   242 	return err;
   243 	}
   244 
   245 
   246 /**
   247 @internalComponent
   248 */
   249 void CPreModifierPlugin::FsFileUnLockL(TFsPluginRequest& aRequest)
   250 	{
   251 	TInt length = 0;
   252 	TInt64 pos = 0;
   253 	TFileName filename;
   254 	TParse parse;
   255 
   256 	TInt err = aRequest.FileName(filename);
   257 	iLastError = err;
   258 	iLineNumber = __LINE__;
   259 	if(err!=KErrNone)
   260 		User::Leave(err); //trapped in DoRequestL
   261 
   262 	err = aRequest.Read(TFsPluginRequest::ELength, length);
   263 	iLastError = err;
   264 	iLineNumber = __LINE__;
   265 	if(err!=KErrNone)
   266 		User::Leave(err); //trapped in DoRequestL
   267 
   268 	err = aRequest.Read(TFsPluginRequest::EPosition, pos);
   269 	iLastError = err;
   270 	iLineNumber = __LINE__;
   271 	if(err!=KErrNone)
   272 		User::Leave(err); //trapped in DoRequestL
   273 	
   274     parse.Set(filename, NULL, NULL);
   275 	//TPtrC extension(parse.Ext());
   276 
   277 	_LOG4(_L("CPreModifierPlugin::FsFileUnLockL, file: %S, pos: %d, length: %d"), &filename, pos, length);
   278 	
   279 	if (aRequest.IsPostOperation())
   280 		{
   281 		_LOG(_L("CPreModifierPlugin::FsFileUnLockL, post intercept"));
   282 		}
   283 	else
   284 		{
   285 			User::Invariant();
   286 		}
   287 	}
   288 
   289 /**
   290 @internalComponent
   291 */
   292 void CPreModifierPlugin::FsFileLockL(TFsPluginRequest& aRequest)
   293 	{
   294 	TInt length = 0;
   295 	TInt64 pos = 0;
   296 	TFileName filename;
   297 	TParse parse;
   298 	
   299 	TInt err = aRequest.FileName(filename);
   300 	iLastError = err;
   301 	iLineNumber = __LINE__;
   302 	if(err!=KErrNone)
   303 		User::Leave(err); //trapped in DoRequestL
   304 
   305 	err = aRequest.Read(TFsPluginRequest::ELength, length);
   306 	iLastError = err;
   307 	iLineNumber = __LINE__;
   308 	if(err!=KErrNone)
   309 		User::Leave(err); //trapped in DoRequestL
   310 
   311 	err = aRequest.Read(TFsPluginRequest::EPosition, pos);
   312 	iLastError = err;
   313 	iLineNumber = __LINE__;
   314 	if(err!=KErrNone)
   315 		User::Leave(err); //trapped in DoRequestL
   316 
   317     parse.Set(filename, NULL, NULL);
   318 	TPtrC extension(parse.Ext());
   319 
   320 	_LOG4(_L("CPreModifierPlugin::FsFileLockL, file: %S, pos: %d, length: %d"), &filename, pos, length);
   321 	
   322 	if (aRequest.IsPostOperation())
   323 		{
   324 		_LOG(_L("CPreModifierPlugin::FsFileLockL, post intercept"));
   325 
   326 		// Request read from post interception
   327 		if (extension.CompareF(_L(".lockread")) == 0)
   328 			{
   329 			length = 10;
   330 			HBufC8* tempBuf = HBufC8::NewMaxLC(length);
   331 			TPtr8 tempBufPtr((TUint8 *)tempBuf->Des().Ptr(), length, length);		
   332 			_LOG(_L("CPreModifierPlugin::FsFileLockL , calling AdoptFromClient in post intercept"));
   333 			RFilePlugin fileplugin(aRequest);
   334 			TInt err = fileplugin.AdoptFromClient();
   335 			iLastError = err;
   336 			iLineNumber = __LINE__;
   337 			if(err!=KErrNone)
   338 				User::Leave(err); //trapped in DoRequestL
   339 			
   340 			_LOG2(_L("CPreModifierPlugin::FsFileLockL, Adopt returned %d"), err);
   341 			
   342 			err = fileplugin.Read(pos, tempBufPtr, length); 
   343 			_LOG2(_L("CPreModifierPlugin::FsFileLockL, FileRead returned %d"), err);
   344 			iLastError = err;
   345 			iLineNumber = __LINE__;
   346 			if(err!=KErrNone)
   347 				User::Leave(err); //trapped in DoRequestL
   348 			fileplugin.Close();
   349 			CleanupStack::PopAndDestroy();						          
   350 			}
   351 
   352 		// Request close from post interception
   353 		if(extension.CompareF(_L(".lockclose")) == 0)
   354 			{		
   355 			_LOG(_L("CPreModifierPlugin::FsFileLockL, file = *.lockclose post intercept "));
   356 			RFilePlugin fileplugin(aRequest);
   357 		    TInt err = fileplugin.AdoptFromClient();
   358 			_LOG2(_L("CPreModifierPlugin::FsFileLockL ,Open %d"), err);
   359 			iLastError = err;
   360 			iLineNumber = __LINE__;
   361 			if(err!=KErrNone)
   362 				User::Leave(err); //trapped in DoRequestL		
   363 			fileplugin.Close();			
   364 			_LOG(_L("CPreModifierPlugin::FsFileLockL, Close"));
   365 			}
   366 
   367 		}
   368 	else
   369 		{
   370 			User::Invariant();
   371 		}
   372 	}
   373 
   374 /**
   375 @internalComponent
   376 */
   377 void CPreModifierPlugin::FsFileSeekL(TFsPluginRequest& aRequest)
   378 	{
   379 	TFileName filename;
   380 	TParse parse;
   381 
   382 	TInt err = aRequest.FileName(filename);
   383 	iLastError = err;
   384 	iLineNumber = __LINE__;
   385 	if(err!=KErrNone)
   386 		User::Leave(err); //trapped in DoRequestL
   387 
   388     parse.Set(filename, NULL, NULL);
   389 
   390 	_LOG2(_L("CPreModifierPlugin::FsFileSeekL, file: %S"), &filename);
   391 	
   392 	if (aRequest.IsPostOperation())
   393 		{
   394 		_LOG(_L("CPreModifierPlugin::FsFileSeekL, post intercept"));
   395 		}
   396 	else
   397 		{
   398 			User::Invariant();
   399 		}
   400 	}
   401 
   402 /**
   403 @internalComponent
   404 */
   405 void CPreModifierPlugin::FsFileSizeL(TFsPluginRequest& aRequest)
   406 	{
   407 	TFileName filename;
   408 	TParse parse;
   409 
   410 	TInt err = aRequest.FileName(filename);
   411 	iLastError = err;
   412 	iLineNumber = __LINE__;
   413 	if(err!=KErrNone)
   414 		User::Leave(err); //trapped in DoRequestL
   415 
   416     parse.Set(filename, NULL, NULL);
   417 
   418 	_LOG2(_L("CPreModifierPlugin::FsFileSizeL, file: %S"), &filename);
   419 	
   420 	if (aRequest.IsPostOperation())
   421 		{
   422 		_LOG(_L("CPreModifierPlugin::FsFileSizeL, post intercept"));
   423 		}
   424 	else
   425 		{
   426 			User::Invariant();
   427 		}
   428 	}
   429 
   430 /**
   431 @internalComponent
   432 */
   433 void CPreModifierPlugin::FsFileSetSizeL(TFsPluginRequest& aRequest)
   434 	{
   435 	TFileName filename;
   436 	TParse parse;
   437 
   438 	TInt err = aRequest.FileName(filename);
   439 	iLastError = err;
   440 	iLineNumber = __LINE__;
   441 	if(err!=KErrNone)
   442 		User::Leave(err); //trapped in DoRequestL
   443 
   444     parse.Set(filename, NULL, NULL);
   445 
   446 	_LOG2(_L("CPreModifierPlugin::FsFileSetSizeL, file: %S"), &filename);
   447 	
   448 	if (aRequest.IsPostOperation())
   449 		{
   450 		_LOG(_L("CPreModifierPlugin::FsFileSetSizeL, post intercept"));
   451 		}
   452 	else
   453 		{
   454 			User::Invariant();
   455 		}
   456 	}
   457 
   458 /**
   459 @internalComponent
   460 */
   461 void CPreModifierPlugin::FsFileReadL(TFsPluginRequest& aRequest)
   462 	{
   463 	TInt length = 0;
   464 	TInt64 pos = 0;
   465 	TFileName filename;
   466 	TParse parse;
   467 
   468 	TInt err = aRequest.FileName(filename);
   469 	iLastError = err;
   470 	iLineNumber = __LINE__;
   471 	if(err!=KErrNone)
   472 		User::Leave(err); //trapped in DoRequestL
   473 
   474 	err = aRequest.Read(TFsPluginRequest::ELength, length);
   475 	iLastError = err;
   476 	iLineNumber = __LINE__;
   477 	if(err!=KErrNone)
   478 		User::Leave(err); //trapped in DoRequestL
   479 	
   480 	err = aRequest.Read(TFsPluginRequest::EPosition, pos);
   481 	iLastError = err;
   482 	iLineNumber = __LINE__;
   483 	if(err!=KErrNone)
   484 		User::Leave(err); //trapped in DoRequestL
   485 
   486     parse.Set(filename, NULL, NULL);
   487 
   488 	_LOG4(_L("CPreModifierPlugin::FsFileReadL, file: %S, pos: %d, length: %d"), &filename, pos, length);
   489 	
   490 	if (aRequest.IsPostOperation())
   491 		{
   492 		_LOG(_L("CPreModifierPlugin::FsFileReadL, post intercept"));
   493 		}
   494 	else
   495 		{
   496 		User::Invariant();
   497 		}
   498 	}
   499 
   500 
   501 /**
   502 @internalComponent
   503 */
   504 void CPreModifierPlugin::FsFileWriteL(TFsPluginRequest& aRequest)
   505 	{
   506 	TInt err = KErrNone;
   507 	TInt length = 0;
   508 	TInt64 pos = 0;
   509 	TFileName filename;
   510 	TParse parse;
   511 
   512 	TBuf<256> testfilename1;
   513 	TBuf<256> testfilename2;
   514 
   515 	//setting up test files
   516 	testfilename1.Append(iDriveToTest);
   517 	testfilename1.Append(_L(":\\Data\\test.txt"));
   518 
   519 	testfilename2.Append(iDriveToTest);
   520 	testfilename2.Append(_L(":\\Data\\createcreate3.txt"));
   521 
   522 	err = aRequest.FileName(filename);
   523 	iLastError = err;
   524 	iLineNumber = __LINE__;
   525 	if(err!=KErrNone)
   526 		User::Leave(err); //trapped in DoRequestL
   527 
   528 	err = aRequest.Read(TFsPluginRequest::ELength, length);
   529 	iLastError = err;
   530 	iLineNumber = __LINE__;
   531 	if(err!=KErrNone)
   532 		User::Leave(err); //trapped in DoRequestL
   533 	
   534 	err = aRequest.Read(TFsPluginRequest::EPosition, pos);
   535 	iLastError = err;
   536 	iLineNumber = __LINE__;
   537 	if(err!=KErrNone)
   538 		User::Leave(err); //trapped in DoRequestL
   539 
   540     parse.Set(filename, NULL, NULL);
   541 
   542 	_LOG4(_L("CPreModifierPlugin::FsFileWriteL, file: %S, pos: %d, length: %d"), &filename, pos, length);
   543 	
   544 	if (aRequest.IsPostOperation())
   545 		{
   546 		_LOG(_L("CPreModifierPlugin::FsFileWriteL, post intercept"));
   547 		}
   548 	else
   549 		{
   550 			User::Invariant();
   551 		}
   552 	}
   553 
   554 
   555 
   556 /**
   557 @internalComponent
   558 */
   559 void CPreModifierPlugin::FsFileRenameL(TFsPluginRequest& aRequest)
   560 	{
   561 	TFileName oldfilename, newfilename;
   562 	TParse parse;
   563 
   564 	oldfilename = aRequest.Src().FullName();
   565 	newfilename = aRequest.Dest().FullName();
   566 	
   567     parse.Set(oldfilename, NULL, NULL);
   568 	TPtrC extension(parse.Ext());
   569 
   570 	_LOG3(_L("CPreModifierPlugin::FsFileRenameL, old name: %S, new name: %S"), &oldfilename, &newfilename);
   571 	
   572 	if (aRequest.IsPostOperation())
   573 		{
   574 		_LOG(_L("CPreModifierPlugin::FsFileRenameL, post intercept"));
   575 
   576 		if (extension.CompareF(_L(".tst")) == 0)
   577 			{
   578 			TBuf8<32> tempBuf = (_L8("Rename Post Intercept"));
   579 			RFilePlugin fileplugin(aRequest);
   580 			TInt err = fileplugin.AdoptFromClient();
   581 			iLastError = err;
   582 			iLineNumber = __LINE__;
   583 			if(err!=KErrNone)
   584 				User::Leave(err); //trapped in DoRequestL
   585 
   586 			err = fileplugin.Write(20, tempBuf);
   587 			_LOG2(_L("CPreModifierPlugin::FsFileRenameL, FileWrite returned %d"), err);
   588 			iLastError = err;
   589 			iLineNumber = __LINE__;
   590 			if(err!=KErrNone)
   591 				User::Leave(err); //trapped in DoRequestL
   592 			fileplugin.Close();
   593 			}
   594 		}
   595 	else
   596 		{
   597 			User::Invariant();
   598 		}
   599 	}
   600 
   601 
   602 void CPreModifierPlugin::FsFileCreateL(TFsPluginRequest& aRequest)
   603 	{
   604 	TFileName filename;
   605 	TParse parse;
   606 	
   607 	filename = aRequest.Src().FullName();
   608 
   609 	TUint mode;
   610 	TInt err = aRequest.Read(TFsPluginRequest::EMode, mode);
   611 	iLastError = err;
   612 	iLineNumber = __LINE__;
   613 	if(err!=KErrNone)
   614 		User::Leave(err); //trapped in DoRequestL
   615 
   616     parse.Set(filename, NULL, NULL);
   617 	TPtrC extension(parse.Ext());
   618 
   619 	if (aRequest.IsPostOperation())
   620 		{
   621 		_LOG(_L("CPreModifierPlugin::FsFileCreateL, post intercept"));
   622 
   623 		if (extension.CompareF(_L(".tst")) == 0)
   624 			{			
   625 			RFilePlugin fileplugin(aRequest);
   626 			TInt err = fileplugin.AdoptFromClient();
   627 			iLastError = err;
   628 			iLineNumber = __LINE__;
   629 			if(err!=KErrNone)
   630 				User::Leave(err); //trapped in DoRequestL
   631 			
   632 			//write to the newly created file
   633 			TBuf8<64> wbuffer;
   634 			wbuffer.Copy(_L8("TestTestTest"));
   635 	    	err = fileplugin.Write(0, wbuffer);
   636 			_LOG2(_L("CPreModifierPlugin::FsFileCreateL, RFilePlugin::Write to the newly created file returned %d"), err);
   637 			iLastError = err;
   638 			iLineNumber = __LINE__;
   639 			if(err!=KErrNone)
   640 				User::Leave(err); //trapped in DoRequestL
   641 	
   642 			TInt length = wbuffer.Length();
   643 			HBufC8* tempBuf = HBufC8::NewMaxLC(length);
   644 			TPtr8 tempBufPtr((TUint8 *)tempBuf->Des().Ptr(), length, length);
   645 			err = fileplugin.Read(0, tempBufPtr);
   646 			_LOG2(_L("CPreModifierPlugin::FsFileCreateL, RFilePlugin::Read returned %d"), err);
   647 			iLastError = err;
   648 			iLineNumber = __LINE__;
   649 			if(err!=KErrNone)
   650 				User::Leave(err); //trapped in DoRequestL
   651 			//testing the correct thing has been written to the drive
   652 			err = wbuffer.Compare(tempBufPtr);
   653 			iLastError = err;
   654 			iLineNumber = __LINE__;
   655 			if(err!=KErrNone)
   656 				User::Leave(err); //trapped in DoRequestL
   657 	
   658 			fileplugin.Close();
   659 			CleanupStack::PopAndDestroy(); //tempBuf
   660 			}
   661 		}
   662 	else
   663 		{
   664 			User::Invariant();
   665 		}
   666 	}
   667 
   668 void CPreModifierPlugin::FsFileOpenL(TFsPluginRequest& aRequest)
   669 	{
   670 
   671 	TFileName filename;
   672 	TParse parse;
   673 	
   674 	filename = aRequest.Src().FullName();
   675 
   676 	TUint mode;
   677 	TInt err = aRequest.Read(TFsPluginRequest::EMode, mode);
   678 	iLastError = err;
   679 	iLineNumber = __LINE__;
   680 	if(err!=KErrNone)
   681 		User::Leave(err); //trapped in DoRequestL
   682 
   683 	parse.Set(filename, NULL, NULL);
   684 	TPtrC extension(parse.Ext());
   685 
   686 	_LOG2(_L("CPreModifierPlugin::FsFileOpenL, file: %S"), &filename);
   687 	
   688 	if (aRequest.IsPostOperation())
   689 		{
   690 		_LOG(_L("CPreModifierPlugin::FsFileOpenL, post intercept"));
   691 		if ((extension.CompareF(_L(".tst")) == 0) && (aRequest.Message().Int1() != 0) && (mode & EFileWrite))
   692 			{
   693 
   694 			RFilePlugin fileplugin(aRequest);
   695 			err = fileplugin.AdoptFromClient();
   696 			iLastError = err;
   697 			iLineNumber = __LINE__;
   698 			if(err!=KErrNone)
   699 				User::Leave(err); //trapped in DoRequestL
   700 
   701 			//write to the newly opened file
   702 			TBuf8<64> wbuffer;
   703 			wbuffer.Copy(_L8("TestTestTest"));
   704 			err = fileplugin.Write(0, wbuffer);
   705 			_LOG2(_L("CPreModifierPlugin::FsFileOpenL, RFilePlugin::Write to the newly opened file returned %d"), err);
   706 			iLastError = err;
   707 			iLineNumber = __LINE__;
   708 			if(err!=KErrNone)
   709 				User::Leave(err); //trapped in DoRequestL
   710 	
   711 			TInt length = wbuffer.Length();
   712 			HBufC8* tempBuf = HBufC8::NewMaxLC(length);
   713 			TPtr8 tempBufPtr((TUint8 *)tempBuf->Des().Ptr(), length, length);
   714 			err = fileplugin.Read(0, tempBufPtr);
   715 			_LOG2(_L("CPreModifierPlugin::FsFileOpenL, RFilePlugin::Read returned %d"), err);
   716 			iLastError = err;
   717 			iLineNumber = __LINE__;
   718 			if(err!=KErrNone)
   719 				User::Leave(err); //trapped in DoRequestL
   720 	
   721 			//testing the correct thing has been written to the drive
   722 			err = wbuffer.Compare(tempBufPtr);
   723 			iLastError = err;
   724 			iLineNumber = __LINE__;
   725 			if(err!=KErrNone)
   726 				User::Leave(err); //trapped in DoRequestL
   727 			
   728 			fileplugin.Close();
   729 
   730 			CleanupStack::PopAndDestroy(); //tempbuf
   731 			}
   732 		}
   733 	else
   734 		{
   735 			User::Invariant();
   736 		}
   737 	}
   738 
   739 
   740 void CPreModifierPlugin::FsFileTempL(TFsPluginRequest& aRequest)
   741 	{
   742 	TBuf<256> testfilename1;
   743 
   744 	//setting up test files
   745 	testfilename1.Append(iDriveToTest);
   746 	testfilename1.Append(_L(":\\Data\\"));
   747 
   748 	if (aRequest.IsPostOperation())
   749 		{
   750 		_LOG(_L("CPreModifierPlugin::FsFileTempL, post intercept"));
   751 
   752 		RFilePlugin fileplugin(aRequest);
   753 		TInt err = fileplugin.AdoptFromClient();
   754 		iLastError = err;
   755 		iLineNumber = __LINE__;
   756 		if(err!=KErrNone)
   757 			User::Leave(err); //trapped in DoRequestL
   758 		
   759 		//write to the newly created temp file
   760 		TBuf8<64> wbuffer;
   761 		wbuffer.Copy(_L8("TestTestTest"));
   762 		err = fileplugin.Write(0, wbuffer);
   763 		_LOG2(_L("CPreModifierPlugin::FsFileTempL, RFilePlugin::Write to the newly created temp file returned %d"), err);
   764 		iLastError = err;
   765 		iLineNumber = __LINE__;
   766 		if(err!=KErrNone)
   767 			User::Leave(err); //trapped in DoRequestL
   768 
   769 		TInt length = wbuffer.Length();
   770 		HBufC8* tempBuf = HBufC8::NewMaxLC(length);
   771 		TPtr8 tempBufPtr((TUint8 *)tempBuf->Des().Ptr(), length, length);
   772 		err = fileplugin.Read(0, tempBufPtr);
   773 		_LOG2(_L("CPreModifierPlugin::FsFileTempL, RFilePlugin::Read returned %d"), err);
   774 		iLastError = err;
   775 		iLineNumber = __LINE__;
   776 		if(err!=KErrNone)
   777 			User::Leave(err); //trapped in DoRequestL
   778 		
   779 		fileplugin.Close();
   780 
   781 		//testing the correct thing has been written to the drive
   782 		err = wbuffer.Compare(tempBufPtr);
   783 		iLastError = err;
   784 		iLineNumber = __LINE__;
   785 		if(err!=KErrNone)
   786 			User::Leave(err); //trapped in DoRequestL
   787 			
   788 		CleanupStack::PopAndDestroy();
   789 		}
   790 	else
   791 		{
   792 		User::Invariant();
   793 		}
   794 	}
   795 
   796 
   797 void CPreModifierPlugin::FsFileReplaceL(TFsPluginRequest& aRequest)
   798 	{
   799 	TFileName filename;
   800 	TParse parse;
   801 	
   802 	filename = aRequest.Src().FullName();
   803 
   804 	TUint mode;
   805 	TInt err = aRequest.Read(TFsPluginRequest::EMode, mode);
   806 	iLastError = err;
   807 	iLineNumber = __LINE__;
   808 	if(err!=KErrNone)
   809 		User::Leave(err); //trapped in DoRequestL
   810 
   811 	parse.Set(filename, NULL, NULL);
   812 	TPtrC extension(parse.Ext());
   813 
   814 	_LOG2(_L("CPreModifierPlugin::FsFileReplaceL, file: %S"), &filename);
   815 	
   816 	if (aRequest.IsPostOperation())
   817 		{
   818 		_LOG(_L("CPreModifierPlugin::FsFileReplaceL, post intercept"));
   819 		if ((extension.CompareF(_L(".tst")) == 0) && (aRequest.Message().Int1() != 0))
   820 			{
   821 			//write to the newly replaced file
   822 			TBuf8<64> wbuffer;
   823 			wbuffer.Copy(_L8("TestTestTest"));
   824 
   825 			RFilePlugin fileplugin(aRequest);
   826 			TInt err = fileplugin.AdoptFromClient();
   827 			iLastError = err;
   828 			iLineNumber = __LINE__;
   829 			if(err!=KErrNone)
   830 				User::Leave(err); //trapped in DoRequestL
   831 
   832     		err = fileplugin.Write(0, wbuffer);
   833 			_LOG2(_L("CPreModifierPlugin::FsFileReplaceL, RFilePlugin::Write to the newly created file returned %d"), err);
   834 			iLastError = err;
   835 			iLineNumber = __LINE__;
   836 			if(err!=KErrNone)
   837 				User::Leave(err); //trapped in DoRequestL
   838 
   839 			TInt length = wbuffer.Length();
   840 			HBufC8* tempBuf = HBufC8::NewMaxLC(length);
   841 			TPtr8 tempBufPtr((TUint8 *)tempBuf->Des().Ptr(), length, length);
   842 			err = fileplugin.Read(0, tempBufPtr);
   843 			_LOG2(_L("CPreModifierPlugin::FsFileReplaceL, RFilePlugin::Read returned %d"), err);
   844 			iLastError = err;
   845 			iLineNumber = __LINE__;
   846 			if(err!=KErrNone)
   847 				User::Leave(err); //trapped in DoRe
   848 
   849 			//testing the correct thing has been written to the drive
   850 			err = wbuffer.Compare(tempBufPtr);
   851 			iLastError = err;
   852 			iLineNumber = __LINE__;
   853 			if(err!=KErrNone)
   854 				User::Leave(err); //trapped in DoRequestL
   855 			
   856 			fileplugin.Close();
   857 			CleanupStack::PopAndDestroy();
   858 			}
   859 		}
   860 	else
   861 		{
   862 		User::Invariant();
   863 		}
   864 	}
   865 
   866 
   867 
   868 void CPreModifierPlugin::FsReadFileSectionL(TFsPluginRequest& aRequest)
   869 	{
   870 	TInt err = KErrNone;
   871 	TInt length = 0;
   872 	TInt64 pos = 0;
   873 	TFileName filename;
   874 	TParse parse;
   875 	TBuf<256> testfilename1;
   876 
   877 	//setting up test files
   878 	testfilename1.Append(iDriveToTest);
   879 	testfilename1.Append(_L(":\\Data\\test.txt"));
   880 
   881 	filename = aRequest.Src().FullName();
   882 
   883 	err = aRequest.Read(TFsPluginRequest::ELength, length);
   884 	iLastError = err;
   885 	iLineNumber = __LINE__;
   886 	if(err!=KErrNone)
   887 		User::Leave(err); //trapped in DoRequestL
   888 	
   889 	err = aRequest.Read(TFsPluginRequest::EPosition, pos);
   890 	iLastError = err;
   891 	iLineNumber = __LINE__;
   892 	if(err!=KErrNone)
   893 		User::Leave(err); //trapped in DoRequestL
   894 
   895     parse.Set(filename, NULL, NULL);
   896 
   897 	_LOG2(_L("CPreModifierPlugin::FsReadFileSectionL, file: %S"), &filename);
   898 	
   899 	if (aRequest.IsPostOperation())
   900 		{
   901 		_LOG(_L("CPreModifierPlugin::FsReadFileSectionL, post intercept - enter"));
   902 		RFilePlugin fileplugin2(aRequest,ETrue);
   903 		//open a second file
   904 		err = fileplugin2.Open(testfilename1, EFileWrite);
   905 		_LOG3(_L("CPreModifierPlugin::FsReadFileSectionL - RFilePlugin::Open for %S returned %d"), &testfilename1, err);
   906 		iLastError = err;
   907 		iLineNumber = __LINE__;
   908 		if(err!=KErrNone)
   909 			User::Leave(err); //trapped in DoRequestL
   910 								
   911 		TInt64 size=0;
   912 		err = fileplugin2.Size(size);
   913 		_LOG3(_L("CPreModifierPlugin::FsReadFileSectionL - RFilePlugin::Size for %S returned %d"), &testfilename1, err);
   914 		iLastError = err;
   915 		iLineNumber = __LINE__;
   916 		if(err!=KErrNone)
   917 			User::Leave(err); //trapped in DoRequestL
   918 
   919 		//close the second file
   920 		fileplugin2.Close();
   921 		_LOG(_L("CPreModifierPlugin::FsReadFileSectionL - post intercept - exit"));
   922 		}
   923 	else
   924 		{
   925 			User::Invariant();
   926 		}
   927 	}
   928 
   929 
   930 void CPreModifierPlugin::FsDeleteL(TFsPluginRequest& aRequest)
   931 	{
   932 	TInt err = KErrNone;
   933 	TFileName filename;
   934 
   935 	TBuf<256> testfilename1;
   936 
   937 	//setting up test files
   938 	testfilename1.Append(iDriveToTest);
   939 	testfilename1.Append(_L(":\\Data\\test.txt"));
   940 
   941 	filename = aRequest.Src().FullName();
   942     	
   943 	if (aRequest.IsPostOperation())
   944 		{
   945 		_LOG(_L("CPreModifierPlugin::FsDeleteL, post intercept"));
   946 
   947 		RFilePlugin fileplugin2(aRequest);
   948 		//open a second file
   949 		err = fileplugin2.Open(testfilename1, EFileWrite);
   950 		_LOG3(_L("RFilePlugin::Open for %S returned %d"), &testfilename1, err);
   951 		iLastError = err;
   952 		iLineNumber = __LINE__;
   953 		if(err!=KErrNone)
   954 			User::Leave(err); //trapped in DoRequestL
   955 								
   956 		TInt64 size=0;
   957 		err = fileplugin2.Size(size);
   958 		iLastError = err;
   959 		iLineNumber = __LINE__;
   960 		if(err!=KErrNone)
   961 			User::Leave(err); //trapped in DoRequestL
   962 
   963 		//close the second file
   964 		fileplugin2.Close();
   965 		_LOG2(_L("CPreModifierPlugin::FsDeleteL, RFilePlugin::Close to the second file returned %d"), err);
   966 		}
   967 	else
   968 		{
   969 		User::Invariant();
   970 		}
   971 	}
   972 
   973 
   974 void CPreModifierPlugin::FsReplaceL(TFsPluginRequest& aRequest)
   975 	{
   976 	TFileName oldfilename;
   977 	TFileName newfilename;
   978 
   979 	oldfilename = aRequest.Src().FullName();
   980 	newfilename = aRequest.Dest().FullName();
   981 
   982 	TBuf<256> testfilename1;
   983 
   984 	//setting up test files
   985 	testfilename1.Append(iDriveToTest);
   986 	testfilename1.Append(_L(":\\Data\\test.txt"));
   987 
   988     	
   989 	if (aRequest.IsPostOperation())
   990 		{
   991 		//STF: Is this code going to get called - the pre-operation completes early?
   992 
   993 		_LOG(_L("CPreModifierPlugin::FsReplaceL, post intercept"));
   994 		//We should check that the name has changed here.
   995 		RFilePlugin file(aRequest);
   996 		TInt err = file.AdoptFromClient();
   997 		iLastError = err;
   998 		iLineNumber = __LINE__;
   999 		if(err!=KErrNone)
  1000 			User::Leave(err); //trapped in DoRequestL
  1001 
  1002 		TInt compare = oldfilename.Compare(newfilename);
  1003 		if(compare != 0) //is equal
  1004 			{
  1005 			//User::Leave(compare);
  1006 			//It wont be equal as the name is coming from the request aint it.
  1007 			//Pointless comparison then eh?
  1008 			}
  1009 
  1010 		file.Close();
  1011 
  1012 		RFilePlugin fileplugin2(aRequest);
  1013 		//open a second file
  1014 		err = fileplugin2.Open(testfilename1, EFileWrite);
  1015 		_LOG3(_L("CPreModifierPlugin::FsReplaceL, RFilePlugin::Open for %S returned %d"), &testfilename1, err);
  1016 		iLastError = err;
  1017 		iLineNumber = __LINE__;
  1018 		if(err!=KErrNone)
  1019 			User::Leave(err); //trapped in DoRequestL
  1020 								
  1021 		TInt64 size=0;
  1022 		err =fileplugin2.Size(size);
  1023 		iLastError = err;
  1024 		iLineNumber = __LINE__;
  1025 		if(err!=KErrNone)
  1026 			User::Leave(err); //trapped in DoRequestL
  1027 
  1028 		//close the second file
  1029 		fileplugin2.Close();
  1030 		_LOG2(_L("CPreModifierPlugin::FsReplaceL, RFilePlugin::Close to the second file returned %d"), err);
  1031 		}
  1032 	else
  1033 		{
  1034 		User::Invariant();
  1035 		}
  1036 	}
  1037 
  1038 
  1039 void CPreModifierPlugin::FsRenameL(TFsPluginRequest& aRequest)
  1040 	{
  1041 	TInt err = KErrNone;
  1042 	TFileName oldfilename;
  1043 	TFileName newfilename;
  1044 
  1045 	oldfilename = aRequest.Src().FullName();
  1046 	newfilename = aRequest.Dest().FullName();
  1047 
  1048 	TBuf<256> testfilename1;
  1049 
  1050 	//setting up test files
  1051 	testfilename1.Append(iDriveToTest);
  1052 	testfilename1.Append(_L(":\\Data\\test.txt"));
  1053 
  1054 	if (aRequest.IsPostOperation())
  1055 		{
  1056 		_LOG(_L("CPreModifierPlugin::FsRenameL, post intercept"));
  1057 		RFilePlugin fileplugin2(aRequest);
  1058 		//open a second file
  1059 		err = fileplugin2.Open(testfilename1, EFileWrite);
  1060 		_LOG3(_L("CPreModifierPlugin::FsRenameL, RFilePlugin::Open for %S returned %d"), &testfilename1, err);
  1061 		iLastError = err;
  1062 		iLineNumber = __LINE__;
  1063 		if(err!=KErrNone)
  1064 			User::Leave(err); //trapped in DoRequestL
  1065 								
  1066 		TInt64 size=0;
  1067 		err = fileplugin2.Size(size);
  1068 		iLastError = err;
  1069 		iLineNumber = __LINE__;
  1070 		if(err!=KErrNone)
  1071 			User::Leave(err); //trapped in DoRequestL		
  1072 
  1073 		//close the second file
  1074 		fileplugin2.Close();
  1075 		_LOG2(_L("CPreModifierPlugin::FsRenameL, RFilePlugin::Close to the second file returned %d"), err);
  1076 		}
  1077 	else
  1078 		{
  1079 		User::Invariant();
  1080 		}
  1081 	}
  1082 
  1083 void CPreModifierPlugin::FsEntryL(TFsPluginRequest& aRequest)
  1084 	{
  1085 	TInt err = KErrNone;
  1086 	TFileName filename;
  1087 
  1088 	filename = aRequest.Src().FullName();
  1089 
  1090 	TBuf<256> testfilename1;
  1091 
  1092 	//setting up test files
  1093 	testfilename1.Append(iDriveToTest);
  1094 	testfilename1.Append(_L(":\\Data\\test.txt"));
  1095 	    	
  1096 	if (aRequest.IsPostOperation())
  1097 		{
  1098 		_LOG(_L("CPreModifierPlugin::FsEntryL, post intercept"));
  1099 		RFilePlugin fileplugin2(aRequest);
  1100 		//open a second file
  1101 		err = fileplugin2.Open(testfilename1, EFileWrite);
  1102 		_LOG3(_L("CPreModifierPlugin::FsEntryL, RFilePlugin::Open for %S returned %d"), &testfilename1, err);
  1103 		iLastError = err;
  1104 		iLineNumber = __LINE__;
  1105 		if(err!=KErrNone)
  1106 			User::Leave(err); //trapped in DoRequestL
  1107 								
  1108 		TInt64 size=0;
  1109 		err = fileplugin2.Size(size);
  1110 		iLastError = err;
  1111 		iLineNumber = __LINE__;
  1112 		if(err!=KErrNone)
  1113 			User::Leave(err); //trapped in DoRequestL
  1114 
  1115 		//close the second file
  1116 		fileplugin2.Close();
  1117 		_LOG2(_L("CPreModifierPlugin::FsEntryL, RFilePlugin::Close to the second file returned %d"), err);
  1118 		}
  1119 	else
  1120 		{
  1121 		User::Invariant();
  1122 		}
  1123 	}
  1124 
  1125 
  1126 
  1127 void CPreModifierPlugin::FsSetEntryL(TFsPluginRequest& aRequest)
  1128 	{
  1129 	TInt err = KErrNone;
  1130 	
  1131 	TBuf<256> testfilename1;
  1132 
  1133 	//setting up test files
  1134 	testfilename1.Append(iDriveToTest);
  1135 	testfilename1.Append(_L(":\\Data\\test.txt"));
  1136 		    	
  1137 	if (aRequest.IsPostOperation())
  1138 		{
  1139 		_LOG(_L("CPreModifierPlugin::FsSetEntryL, post intercept"));
  1140 		RFilePlugin fileplugin2(aRequest);
  1141 		//open a second file
  1142 		err = fileplugin2.Open(testfilename1, EFileWrite);
  1143 		_LOG3(_L("CPreModifierPlugin::FsSetEntryL, RFilePlugin::Open for %S returned %d"), &testfilename1, err);
  1144 		iLastError = err;
  1145 		iLineNumber = __LINE__;
  1146 		if(err!=KErrNone)
  1147 			User::Leave(err); //trapped in DoRequestL
  1148 								
  1149 		TInt64 size=0;
  1150 		err = fileplugin2.Size(size);
  1151 		iLastError = err;
  1152 		iLineNumber = __LINE__;
  1153 		if(err!=KErrNone)
  1154 			User::Leave(err); //trapped in DoRequestL
  1155 
  1156 		//close the second file
  1157 		fileplugin2.Close();
  1158 		_LOG2(_L("CPreModifierPlugin::FsSetEntryL, RFilePlugin::Close to the second file returned %d"), err);
  1159 		}
  1160 	else
  1161 		{
  1162 		User::Invariant();
  1163 		}
  1164 	}
  1165 
  1166 
  1167 /**
  1168 @internalComponent
  1169 */
  1170 void CPreModifierPlugin::FsFileSubCloseL(TFsPluginRequest& aRequest)
  1171 	{
  1172 	if (aRequest.IsPostOperation())
  1173 		{
  1174 		_LOG(_L("CPreModifierPlugin::FsFileSubCloseL, post intercept"));
  1175 		}
  1176 	else
  1177 		{
  1178 		User::Invariant();
  1179 		}
  1180 	}
  1181 
  1182 /**
  1183 @internalComponent
  1184 */
  1185 void CPreModifierPlugin::FsDirOpenL(TFsPluginRequest& aRequest)
  1186 	{
  1187 	if (aRequest.IsPostOperation())
  1188 		{
  1189 		_LOG(_L("CPreModifierPlugin::FsDirOpenL, post intercept"));
  1190 		}
  1191 	else
  1192 		{
  1193 		User::Invariant();
  1194 		}
  1195 	}
  1196 
  1197 void CPreModifierPlugin::FsDirReadOneL(TFsPluginRequest& aRequest)
  1198 	{
  1199 
  1200 	TFileName name;
  1201 	TInt err = aRequest.FileName(name);
  1202 	iLastError = err;
  1203 	iLineNumber = __LINE__;
  1204 	if(err!=KErrNone)
  1205 		User::Leave(err); //trapped in DoRequestL
  1206 	
  1207 	if (aRequest.IsPostOperation())
  1208 		{
  1209 		_LOG(_L("CPreModifierPlugin::FsDirReadOneL, post intercept"));
  1210 		}
  1211 	else
  1212 		{
  1213 		User::Invariant();
  1214 		}
  1215 	}
  1216 
  1217 
  1218 /**
  1219 @internalComponent
  1220 */
  1221 void CPreModifierPlugin::FsDirReadPackedL(TFsPluginRequest& aRequest)
  1222 	{
  1223 	if (aRequest.IsPostOperation())
  1224 		{
  1225 		_LOG(_L("CPreModifierPlugin::FsDirReadPackedL, post intercept"));
  1226 		}
  1227 	else
  1228 		{
  1229 		User::Invariant();
  1230 		}
  1231 	}
  1232 
  1233 
  1234 CFsPluginConn* CPreModifierPlugin::NewPluginConnL()
  1235 	{
  1236 	return new(ELeave) CPreModifierPluginConn();
  1237 	}
  1238 
  1239 //Asynchronous RPlugin::DoRequest
  1240 void CPreModifierPlugin::FsPluginDoRequestL(CFsPluginConnRequest& aRequest)
  1241 	{
  1242 	FsPluginDoControlL(aRequest);
  1243 	}
  1244 
  1245 //Synchronous RPlugin::DoControl
  1246 TInt CPreModifierPlugin::FsPluginDoControlL(CFsPluginConnRequest& aRequest)
  1247 	{
  1248 	TInt err = KErrNone;
  1249 
  1250 	//We can use this to set the drive
  1251 	//We can store this as a member of this class.
  1252 	
  1253 	TPckg<TInt> errCodeDes(iLastError);
  1254 	TPckg<TInt> errMsgDes(iLineNumber);
  1255 	
  1256 	
  1257 	TInt function = aRequest.Function();
  1258 	switch(function)
  1259 		{
  1260 		case KPluginSetDrive:
  1261 			{
  1262 			TPckg<TChar> drive(iDriveToTest);
  1263 			TRAP(err,aRequest.ReadParam1L(drive));
  1264 			break;
  1265 			}
  1266 		case KPluginGetError:
  1267 			{
  1268 			TRAP(err,aRequest.WriteParam1L(errCodeDes));
  1269 			TRAP(err,aRequest.WriteParam2L(errMsgDes));
  1270 			break;
  1271 			}
  1272 		default:
  1273 			break;
  1274 		}
  1275 
  1276 	return err;
  1277 	}
  1278 
  1279 TInt CPreModifierPluginConn::DoControl(CFsPluginConnRequest& aRequest)
  1280 	{
  1281 	return ((CPreModifierPlugin*)Plugin())->FsPluginDoControlL(aRequest);
  1282 	}
  1283 
  1284 void CPreModifierPluginConn::DoRequest(CFsPluginConnRequest& aRequest)
  1285 	{
  1286 	DoControl(aRequest);
  1287 	}
  1288 
  1289 void CPreModifierPluginConn::DoCancel(TInt /*aReqMask*/)
  1290 	{
  1291 	}
  1292 
  1293 //factory functions
  1294 
  1295 class CPreModifierPluginFactory : public CFsPluginFactory
  1296 	{
  1297 public:
  1298 	CPreModifierPluginFactory();
  1299 	virtual TInt Install();
  1300 	virtual CFsPlugin* NewPluginL();
  1301 	virtual CFsPlugin* NewPluginConnL();
  1302 	virtual TInt UniquePosition();
  1303 	};
  1304 
  1305 /**
  1306 Constructor for the plugin factory
  1307 @internalComponent
  1308 */
  1309 CPreModifierPluginFactory::CPreModifierPluginFactory()
  1310 	{
  1311 	}
  1312 
  1313 /**
  1314 Install function for the plugin factory
  1315 @internalComponent
  1316 */
  1317 TInt CPreModifierPluginFactory::Install()
  1318 	{
  1319 	SetSupportedDrives(KPluginSupportAllDrives);
  1320 	//iSupportedDrives = 1<<23;
  1321 	return(SetName(&KPreModifierPluginName));
  1322 	}
  1323 
  1324 /**
  1325 @internalComponent
  1326 */
  1327 TInt CPreModifierPluginFactory::UniquePosition()
  1328 	{
  1329 	return(KPreModifierPos);
  1330 	}
  1331 
  1332 /**
  1333 Plugin factory function
  1334 @internalComponent
  1335 */
  1336 CFsPlugin* CPreModifierPluginFactory::NewPluginL()
  1337 
  1338 	{
  1339 	return CPreModifierPlugin::NewL();
  1340 	}
  1341 
  1342 /**
  1343 Plugin factory function
  1344 @internalComponent
  1345 */
  1346 CFsPlugin* CPreModifierPluginFactory::NewPluginConnL()
  1347 
  1348 	{
  1349 	return CPreModifierPlugin::NewL();
  1350 	}
  1351 
  1352 /**
  1353 Create a new Plugin
  1354 @internalComponent
  1355 */
  1356 extern "C" {
  1357 
  1358 EXPORT_C CFsPluginFactory* CreateFileSystem()
  1359 	{
  1360 	return(new CPreModifierPluginFactory());
  1361 	}
  1362 }
  1363