harvester/monitorplugins/mdsfileserverplugin/src/mdsfileserverplugin.cpp
changeset 0 c53acadfccc6
child 3 b73a2e62868f
equal deleted inserted replaced
-1:000000000000 0:c53acadfccc6
       
     1 /*
       
     2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Monitors file creations, modifications and deletions.*
       
    15 */
       
    16 
       
    17 
       
    18 #include <f32pluginutils.h>
       
    19 #include "mdsfileserverplugin.h"
       
    20 #include "harvesterlog.h"
       
    21 #include "mdsutils.h"
       
    22 
       
    23 _LIT( KMdsFileServerPlugin, "MdsFileServerPlugin" );
       
    24 
       
    25 /* Server name */
       
    26 _LIT( KHarvesterServerName, "HarvesterServer" );
       
    27 
       
    28 const TInt KCleanQueueTreshoald( 1000 );
       
    29 
       
    30 //-----------------------------------------------------------------------------
       
    31 // CMdsFileServerPlugin implementation
       
    32 //-----------------------------------------------------------------------------
       
    33 //
       
    34 CMdsFileServerPlugin::CMdsFileServerPlugin()
       
    35 : iFormatOldMediaId( 0 ), iFormatDriveNumber( -1 ), iConnectionCount( 0 )
       
    36 	{
       
    37 	WRITELOG( "CMdsFileServerPlugin::CMdsFileServerPlugin()" );
       
    38 	}
       
    39 	
       
    40 //-----------------------------------------------------------------------------
       
    41 // 
       
    42 //-----------------------------------------------------------------------------
       
    43 //
       
    44 CMdsFileServerPlugin::~CMdsFileServerPlugin()
       
    45     {
       
    46     WRITELOG( "CMdsFileServerPlugin::~CMdsFileServerPlugin()" );
       
    47     
       
    48     TRAP_IGNORE( DisableL() );
       
    49     iFsSession.Close();
       
    50     
       
    51     iCreatedFiles.ResetAndDestroy();
       
    52     iCreatedFiles.Close();
       
    53   
       
    54     iPaths.ResetAndDestroy();
       
    55     iPaths.Close();
       
    56     
       
    57     iIgnorePaths.ResetAndDestroy();
       
    58     iIgnorePaths.Close();
       
    59         
       
    60     iQueue.ResetAndDestroy();
       
    61     iQueue.Close();
       
    62     }
       
    63     
       
    64 //-----------------------------------------------------------------------------
       
    65 // 
       
    66 //-----------------------------------------------------------------------------
       
    67 //
       
    68 CMdsFileServerPlugin* CMdsFileServerPlugin::NewL()
       
    69     {
       
    70     WRITELOG( "CMdsFileServerPlugin::NewL()" );
       
    71     return new (ELeave) CMdsFileServerPlugin;
       
    72     }
       
    73 
       
    74 //-----------------------------------------------------------------------------
       
    75 // 
       
    76 //-----------------------------------------------------------------------------
       
    77 //
       
    78 void CMdsFileServerPlugin::InitialiseL()
       
    79     {
       
    80     WRITELOG( "CMdsFileServerPlugin::InitializeL()" );
       
    81     User::LeaveIfError( iFsSession.Connect() );
       
    82     }
       
    83     
       
    84 //-----------------------------------------------------------------------------
       
    85 // 
       
    86 //-----------------------------------------------------------------------------
       
    87 //
       
    88 void CMdsFileServerPlugin::EnableL()
       
    89     {
       
    90     WRITELOG( "CMdsFileServerPlugin::EnableL()" );
       
    91     User::LeaveIfError( RegisterIntercept(EFsFileCreate, EPostIntercept) );
       
    92     User::LeaveIfError( RegisterIntercept(EFsFileRename, EPostIntercept) );
       
    93     User::LeaveIfError( RegisterIntercept(EFsRename, EPostIntercept) );
       
    94     User::LeaveIfError( RegisterIntercept(EFsDelete, EPostIntercept) );
       
    95     User::LeaveIfError( RegisterIntercept(EFsFileReplace, EPostIntercept) );
       
    96     User::LeaveIfError( RegisterIntercept(EFsReplace, EPostIntercept) );
       
    97     User::LeaveIfError( RegisterIntercept(EFsFileSetModified, EPostIntercept) );
       
    98     User::LeaveIfError( RegisterIntercept(EFsFileSubClose, EPostIntercept) );
       
    99     User::LeaveIfError( RegisterIntercept(EFsSetEntry, EPostIntercept) );
       
   100 	// format events
       
   101 	User::LeaveIfError( RegisterIntercept(EFsFormatSubClose, EPostIntercept) );
       
   102 	User::LeaveIfError( RegisterIntercept(EFsFormatOpen, EPreIntercept) );
       
   103 
       
   104 #ifdef _DEBUG_EVENTS
       
   105     RegisterDebugEventsL();
       
   106 #endif
       
   107     }
       
   108     
       
   109 //-----------------------------------------------------------------------------
       
   110 // 
       
   111 //-----------------------------------------------------------------------------
       
   112 //
       
   113 void CMdsFileServerPlugin::DisableL()
       
   114     {
       
   115     WRITELOG( "CMdsFileServerPlugin::DisableL()" );
       
   116     User::LeaveIfError( UnregisterIntercept(EFsFileCreate, EPrePostIntercept) );
       
   117     User::LeaveIfError( UnregisterIntercept(EFsFileRename, EPrePostIntercept) );
       
   118     User::LeaveIfError( UnregisterIntercept(EFsRename, EPrePostIntercept) );
       
   119     User::LeaveIfError( UnregisterIntercept(EFsDelete, EPrePostIntercept) );
       
   120     User::LeaveIfError( UnregisterIntercept(EFsFileReplace, EPrePostIntercept) );
       
   121     User::LeaveIfError( UnregisterIntercept(EFsReplace, EPrePostIntercept) );
       
   122     User::LeaveIfError( UnregisterIntercept(EFsFileSetModified, EPrePostIntercept) );
       
   123     User::LeaveIfError( UnregisterIntercept(EFsFileSubClose, EPrePostIntercept) );
       
   124     User::LeaveIfError( UnregisterIntercept(EFsSetEntry, EPrePostIntercept) );
       
   125 	// format events
       
   126 	User::LeaveIfError( UnregisterIntercept(EFsFormatSubClose, EPostIntercept) );
       
   127 	User::LeaveIfError( UnregisterIntercept(EFsFormatOpen, EPreIntercept) );
       
   128 
       
   129 #ifdef _DEBUG_EVENTS
       
   130     UnregisterDebugEventsL();
       
   131 #endif
       
   132     }
       
   133     
       
   134 //-----------------------------------------------------------------------------
       
   135 // AddConnection
       
   136 //-----------------------------------------------------------------------------
       
   137 //
       
   138 void CMdsFileServerPlugin::AddConnection()
       
   139     {
       
   140     WRITELOG( "CMdsFileServerPlugin::AddConnection()" );
       
   141     
       
   142     ++iConnectionCount;
       
   143     iPendingEvents = 0;
       
   144     }
       
   145 
       
   146 //-----------------------------------------------------------------------------
       
   147 // RemoveConnection
       
   148 //-----------------------------------------------------------------------------
       
   149 //
       
   150 void CMdsFileServerPlugin::RemoveConnection()
       
   151     {
       
   152     WRITELOG( "CMdsFileServerPlugin::RemoveConnection()" );
       
   153 
       
   154     --iConnectionCount;
       
   155 
       
   156     // remove notification request if this was last connection
       
   157     if( iConnectionCount <= 0 )
       
   158     	{
       
   159     	WRITELOG( "CMdsFileServerPlugin::RemoveConnection() last connection" );
       
   160     	
       
   161     	iNotification = NULL;
       
   162     	iPendingEvents = 0;
       
   163     	iQueue.ResetAndDestroy();
       
   164     	iQueue.Compress();
       
   165     	}
       
   166     }
       
   167 
       
   168 //-----------------------------------------------------------------------------
       
   169 // 
       
   170 //-----------------------------------------------------------------------------
       
   171 //
       
   172 TInt CMdsFileServerPlugin::DoRequestL( TFsPluginRequest& aRequest )
       
   173 	{
       
   174 	// ignore event if there is no any client listening
       
   175 	if( iConnectionCount <= 0 )
       
   176 		{
       
   177 		WRITELOG( "CMdsFileServerPlugin::DoRequestL() - no clients -> ignore event" );
       
   178 		return KErrNone;
       
   179 		}
       
   180 	
       
   181 	TInt function = aRequest.Function();
       
   182 	
       
   183 	iFileName.Zero();
       
   184 	
       
   185 #ifdef _DEBUG_EVENTS
       
   186     PrintDebugEvents( function );
       
   187 #endif
       
   188     
       
   189     if ( function == EFsFileSubClose && iCreatedFiles.Count() == 0 )
       
   190         {
       
   191 #ifdef _DEBUG_EVENTS
       
   192         if( GetName( &aRequest, iFileName ) == KErrNone && iFileName.Length() <= KMaxFileName )
       
   193             {
       
   194             WRITELOG1("Dropping subclose %S",&iFileName);
       
   195             }
       
   196 #endif
       
   197         return KErrNone;
       
   198         }
       
   199     
       
   200     const TBool formatFunction = function == EFsFormatOpen || function == EFsFormatSubClose;
       
   201     iNewFileName.Zero();
       
   202         
       
   203     WRITELOG1( "----- CMdsFileServerPlugin::DoRequestL() - plugin function: %d -----", function );
       
   204 
       
   205 	if ( !formatFunction )
       
   206 		{
       
   207 		if( GetName( &aRequest, iFileName ) != KErrNone || iFileName.Length() > KMaxFileName )
       
   208 		    {
       
   209 		    return KErrNone;
       
   210 		    }
       
   211 		else
       
   212 		    {
       
   213 		    WRITELOG1( "CMdsFileServerPlugin::DoRequestL() - fileName: %S", &iFileName );
       
   214 		    }
       
   215 		}
       
   216 
       
   217     // get process id
       
   218 	TUid processId = { 0 };
       
   219 
       
   220 	processId = aRequest.Message().SecureId();
       
   221 
       
   222 	TBool isDirectory = EFalse;
       
   223 	
       
   224     // if rename, check destination path
       
   225     if ( function == EFsRename  || function == EFsFileRename || 
       
   226     	 function == EFsReplace || function == EFsFileReplace  ||
       
   227     	 function == EFsSetEntry )
       
   228         {
       
   229         const TInt newNameErr = GetNewName( &aRequest, iNewFileName );
       
   230         if ( iNewFileName.Length() > KMaxFileName )
       
   231         	{
       
   232         	return KErrNone;
       
   233         	}
       
   234         WRITELOG2( "CMdsFileServerPlugin::DoRequestL() - newFileName: '%S' %d", &iNewFileName, newNameErr );
       
   235         if ( newNameErr == KErrNone )
       
   236             {
       
   237             if ( !CheckPath(iNewFileName) )
       
   238                 {
       
   239                 WRITELOG( "CMdsFileServerPlugin::DoRequestL() - new path not supported" );
       
   240                 if( !CheckPath(iFileName) )
       
   241                     {
       
   242                     WRITELOG( "CMdsFileServerPlugin::DoRequestL() - old path not supported" );
       
   243                     WRITELOG( "CMdsFileServerPlugin::DoRequestL() - ignore file" );
       
   244                     return KErrNone;
       
   245                     }
       
   246                 // file moved to ignored path, delete from db
       
   247                 function = EFsDelete;
       
   248                 }
       
   249             
       
   250             if ( !CheckAttribs( iNewFileName, isDirectory ) )
       
   251                 {
       
   252                 WRITELOG( "CMdsFileServerPlugin::DoRequestL() - new path attribute check failed" );
       
   253                 if( !CheckAttribs(iFileName, isDirectory) )
       
   254                     {
       
   255                     WRITELOG( "CMdsFileServerPlugin::DoRequestL() - old path attribute check failed" );
       
   256                     WRITELOG( "CMdsFileServerPlugin::DoRequestL() - ignore file" );
       
   257                     return KErrNone;
       
   258                     }
       
   259                 // file set to hidden, delete from db
       
   260                 function = EFsDelete;
       
   261                 }
       
   262             }
       
   263         else
       
   264         	{
       
   265             if ( !CheckPath(iFileName) )
       
   266                 {
       
   267                 WRITELOG( "CMdsFileServerPlugin::DoRequestL() - path not supported" );
       
   268                 return KErrNone;
       
   269                 }
       
   270 
       
   271             if ( !CheckAttribs(iFileName, isDirectory) )
       
   272                 {
       
   273                 WRITELOG( "CMdsFileServerPlugin::DoRequestL() - attribute check failed" );
       
   274                 return KErrNone;
       
   275                 }
       
   276         	}
       
   277         }
       
   278     else if ( !formatFunction )
       
   279         {
       
   280         if ( !CheckPath(iFileName) )
       
   281             {
       
   282             WRITELOG( "CMdsFileServerPlugin::DoRequestL() - path not supported" );
       
   283             return KErrNone;
       
   284             }
       
   285 
       
   286         if ( !CheckAttribs( iFileName, isDirectory ) )
       
   287             {
       
   288             WRITELOG( "CMdsFileServerPlugin::DoRequestL() - attribute check failed" );
       
   289             return KErrNone;
       
   290             }
       
   291         }
       
   292 
       
   293     TInt fileEventType = EMdsFileUnknown;
       
   294     TInt drvNumber = aRequest.DriveNumber();
       
   295     TVolumeInfo volInfo;
       
   296 
       
   297     WRITELOG1( "CMdsFileServerPlugin::DoRequestL() - drive number: %d", drvNumber );
       
   298 
       
   299     TInt err( KErrNone );
       
   300     
       
   301     switch( function )
       
   302         {
       
   303         case EFsFileCreate:
       
   304             {
       
   305 #ifdef _DEBUG            
       
   306             if (function == EFsFileCreate)            
       
   307             	WRITELOG( "CMdsFileServerPlugin::DoRequestL() - EFsFileCreate" );
       
   308             if (function == EFsFileReplace)
       
   309             	WRITELOG( "CMdsFileServerPlugin::DoRequestL() - EFsFileReplace" );
       
   310 #endif            
       
   311             
       
   312             iCreatedFiles.Append( iFileName.AllocL() );
       
   313             User::LeaveIfError( UnregisterIntercept(EFsFileSetModified, EPostIntercept) );
       
   314             return KErrNone;
       
   315             }
       
   316 
       
   317         case EFsFileSubClose:
       
   318             {
       
   319             WRITELOG( "CMdsFileServerPlugin::DoRequestL() - EFsFileSubClose" );
       
   320 
       
   321             TBool found = EFalse;
       
   322 
       
   323            	for ( TInt i = iCreatedFiles.Count(); --i >= 0; )
       
   324             		{
       
   325            			if ( MdsUtils::Compare( iFileName, *(iCreatedFiles[i]) ) == 0 )
       
   326             		  {
       
   327             			fileEventType = EMdsFileCreated;
       
   328             			delete iCreatedFiles[i];
       
   329             			iCreatedFiles.Remove( i );
       
   330             			
       
   331 						//Have to check whether file has been hidden
       
   332 						if ( CheckAttribs( iFileName, isDirectory ) )
       
   333 							{
       
   334 							found = ETrue;
       
   335 							}
       
   336     						
       
   337             			User::LeaveIfError( RegisterIntercept(EFsFileSetModified, EPostIntercept) );
       
   338             			}
       
   339             		}
       
   340            	
       
   341            	if( iCreatedFiles.Count() == 0 )
       
   342 				{
       
   343 				iCreatedFiles.GranularCompress();
       
   344 				}
       
   345             
       
   346             if ( !found )
       
   347                 {
       
   348                 return KErrNone;
       
   349                 }
       
   350             }
       
   351             break;
       
   352 
       
   353         case EFsRename:
       
   354             {
       
   355             WRITELOG1( "CMdsFileServerPlugin::DoRequestL() - EFsRename, new file: %S", &iNewFileName );
       
   356             
       
   357             if ( isDirectory )
       
   358             	{
       
   359 				WRITELOG( "CMdsFileServerPlugin::DoRequestL() - it is directory!" );			
       
   360 				fileEventType = EMdsDirRenamed;
       
   361 				AddBackslashIfNeeded( iNewFileName ); // new file name 
       
   362 				AddBackslashIfNeeded( iFileName ); // old file name
       
   363             	}
       
   364             else
       
   365             	{
       
   366             	fileEventType = EMdsFileRenamed;
       
   367             	}
       
   368             }
       
   369             break;
       
   370 
       
   371         case EFsFileRename:
       
   372             WRITELOG1( "CMdsFileServerPlugin::DoRequestL() - EFsFileRename, new file: %S", &iNewFileName );
       
   373             fileEventType = EMdsFileRenamed;
       
   374             break;
       
   375 
       
   376         case EFsFileSetModified:
       
   377         case EFsSetEntry:
       
   378             WRITELOG( "CMdsFileServerPlugin::DoRequestL() - EFsFileSetModified" );
       
   379             fileEventType = EMdsFileModified;
       
   380             break;
       
   381 
       
   382         case EFsFileReplace:
       
   383         case EFsReplace:
       
   384             WRITELOG1( "CMdsFileServerPlugin::DoRequestL() - EFsReplace/EFsFileReplace, new file: %S", &iNewFileName );
       
   385             fileEventType = EMdsFileReplaced;
       
   386             break;
       
   387 
       
   388         case EFsDelete:
       
   389             WRITELOG( "CMdsFileServerPlugin::DoRequestL() - EFsDelete" );
       
   390             fileEventType = EMdsFileDeleted;
       
   391             break;
       
   392 
       
   393 		case EFsFormatOpen:
       
   394 			WRITELOG( "CMdsFileServerPlugin::DoRequestL() - EFsFormatOpen" );
       
   395 			// get the drive letter
       
   396 			err = iFsSession.Volume( volInfo, drvNumber );
       
   397 			if( KErrNone == err )
       
   398 				{
       
   399 				iFormatOldMediaId = volInfo.iUniqueID;
       
   400 				iFormatDriveNumber = drvNumber;
       
   401 				fileEventType = EMdsDriveFormatted;
       
   402 				processId.iUid = 0;
       
   403 				}
       
   404 			else
       
   405 				{
       
   406 				iFormatDriveNumber = -1;
       
   407 				}
       
   408 			return KErrNone;
       
   409 
       
   410 		case EFsFormatSubClose:
       
   411 			WRITELOG( "CMdsFileServerPlugin::DoRequestL() - EFsFormatSubClose" );
       
   412 			if ( iFormatDriveNumber < 0 )
       
   413 				{
       
   414 				return KErrNone;
       
   415 				}
       
   416 			drvNumber = iFormatOldMediaId;
       
   417 			volInfo.iUniqueID = iFormatOldMediaId;
       
   418 			iFormatOldMediaId = 0;
       
   419 			iFormatDriveNumber = -1;
       
   420 			fileEventType = EMdsDriveFormatted;
       
   421 			if ( processId.iUid == 0 )
       
   422 				{
       
   423 				processId.iUid = 1;
       
   424 				}
       
   425 			break;
       
   426 
       
   427         default:
       
   428             WRITELOG( "CMdsFileServerPlugin::DoRequestL() - Unknown function" );
       
   429             return KErrNone;
       
   430         }
       
   431 
       
   432     if ( iNotification )
       
   433         {
       
   434         WRITELOG( "CMdsFileServerPlugin::DoRequestL() - iNotification found" );
       
   435         TMdsFSPStatusPckg clientStatusBuf;
       
   436         TMdsFSPStatus& clientStatus = clientStatusBuf();
       
   437         clientStatus.iDriveNumber = drvNumber;
       
   438         clientStatus.iDriveMediaId = volInfo.iUniqueID;
       
   439         clientStatus.iFileName.Copy( iFileName );
       
   440         clientStatus.iNewFileName.Copy( iNewFileName );
       
   441         clientStatus.iFileEventType = fileEventType;
       
   442         clientStatus.iProcessId = processId;
       
   443 
       
   444         TRAP( err, iNotification->WriteParam1L(clientStatusBuf) );
       
   445         iNotification->Complete( err );
       
   446         iNotification = NULL;
       
   447         WRITELOG( "CMdsFileServerPlugin::DoRequestL() - iNotification complete" );
       
   448         }
       
   449     else // no notification ready, put in the queue
       
   450         {
       
   451         WRITELOG( "CMdsFileServerPlugin::DoRequestL() - iNotification not found. Put in the queue" );
       
   452 
       
   453         // Check if harvester is still alive
       
   454         if( CheckHarvesterStatus() )
       
   455             {
       
   456             CMdsFSPQueueItem* queueItem = CMdsFSPQueueItem::NewL();
       
   457             CleanupStack::PushL( queueItem );
       
   458             queueItem->iDriveNumber = drvNumber;
       
   459             queueItem->iDriveMediaId = volInfo.iUniqueID;
       
   460             queueItem->iFileName = iFileName.AllocL();
       
   461             queueItem->iNewFileName = iNewFileName.AllocL();
       
   462             queueItem->iFileEventType = fileEventType;
       
   463             queueItem->iProcessId = processId;
       
   464 
       
   465             iQueue.AppendL( queueItem ); // owenership is transferred
       
   466             CleanupStack::Pop( queueItem );
       
   467             err = KErrNone;
       
   468             iPendingEvents++;
       
   469             WRITELOG( "CMdsFileServerPlugin::DoRequestL() - added to queue" );
       
   470             }
       
   471         else
       
   472             {
       
   473             WRITELOG( "CMdsFileServerPlugin::DoRequestL() - Harvester process not detected" );
       
   474             iConnectionCount = 0;
       
   475             iPendingEvents = 0;
       
   476             iQueue.ResetAndDestroy();
       
   477             iQueue.Compress();
       
   478             }
       
   479         }
       
   480     
       
   481     WRITELOG( "CMdsFileServerPlugin::DoRequestL() - return" );
       
   482     return err;
       
   483     }
       
   484 
       
   485 //-----------------------------------------------------------------------------
       
   486 // CMdsFileServerPluginConn implementation
       
   487 //-----------------------------------------------------------------------------
       
   488 class CMdsFileServerPluginConn : public CFsPluginConn
       
   489     {
       
   490     public:
       
   491         static CMdsFileServerPluginConn* NewL( CMdsFileServerPlugin& aPlugin );
       
   492         virtual ~CMdsFileServerPluginConn();
       
   493 
       
   494         virtual TInt DoControl( CFsPluginConnRequest& aRequest );
       
   495         virtual void DoRequest( CFsPluginConnRequest& aRequest );
       
   496         virtual void DoCancel( TInt aReqMask );
       
   497 
       
   498     private:
       
   499     	CMdsFileServerPluginConn( CMdsFileServerPlugin& aPlugin );
       
   500 
       
   501     	CMdsFileServerPlugin& iPlugin;
       
   502 
       
   503         RMessage2* iMessage;
       
   504     };
       
   505     
       
   506 /**
       
   507 * Leaving New function for the plugin
       
   508 * @internalComponent
       
   509 */
       
   510 CMdsFileServerPluginConn* CMdsFileServerPluginConn::NewL( 
       
   511 		CMdsFileServerPlugin& aPlugin )
       
   512     {
       
   513     WRITELOG( "CMdsFileServerPluginConn::NewL()" );
       
   514     return new (ELeave) CMdsFileServerPluginConn( aPlugin );
       
   515     }
       
   516 
       
   517 
       
   518 /**
       
   519 * Constructor for the plugin
       
   520 * @internalComponent
       
   521 */
       
   522 CMdsFileServerPluginConn::CMdsFileServerPluginConn( 
       
   523 		CMdsFileServerPlugin& aPlugin ) : 
       
   524 		iPlugin( aPlugin )
       
   525     {
       
   526     WRITELOG( "CMdsFileServerPluginConn::CMdsFileServerPluginConn()" );
       
   527     
       
   528     iPlugin.AddConnection();
       
   529     }
       
   530 
       
   531 
       
   532 /**
       
   533 * The destructor for the test virus scanner hook.
       
   534 * @internalComponent
       
   535 */
       
   536 CMdsFileServerPluginConn::~CMdsFileServerPluginConn()
       
   537     {
       
   538     WRITELOG( "CMdsFileServerPluginConn::~CMdsFileServerPluginConn()" );
       
   539     
       
   540     iPlugin.RemoveConnection();
       
   541     }
       
   542 
       
   543 //-----------------------------------------------------------------------------
       
   544 // 
       
   545 //-----------------------------------------------------------------------------
       
   546 //
       
   547 TInt CMdsFileServerPluginConn::DoControl( CFsPluginConnRequest& aRequest )
       
   548     {
       
   549     WRITELOG( "CMdsFileServerPluginConn::DoControl()" );
       
   550     TInt err = KErrNotSupported;
       
   551     
       
   552     CMdsFileServerPlugin& myPlugin = *(CMdsFileServerPlugin*)Plugin();
       
   553     
       
   554     switch( aRequest.Function() )
       
   555         {
       
   556         case EMdsFSPOpEnable:
       
   557             {
       
   558             WRITELOG( "CMdsFileServerPluginConn::DoControl() - EMdsFSPOpEnable" );
       
   559             TRAP( err, myPlugin.EnableL() );
       
   560             break;
       
   561             }
       
   562         
       
   563         case EMdsFSPOpDisable:
       
   564             {
       
   565             WRITELOG( "CMdsFileServerPluginConn::DoControl() - EMdsFSPOpDisable" );
       
   566             TRAP( err, myPlugin.DisableL() );
       
   567             break;
       
   568             }
       
   569         
       
   570         default:
       
   571             {
       
   572             WRITELOG( "CMdsFileServerPluginConn::DoControl() - Unknown Control" );
       
   573             break;            
       
   574             }
       
   575         }
       
   576 
       
   577     return err;
       
   578     }
       
   579     
       
   580 
       
   581 //-----------------------------------------------------------------------------
       
   582 // 
       
   583 //-----------------------------------------------------------------------------
       
   584 //
       
   585 void CMdsFileServerPluginConn::DoRequest( CFsPluginConnRequest& aRequest )
       
   586     {
       
   587     WRITELOG( "CMdsFileServerPluginConn::DoRequest()" );
       
   588     CMdsFileServerPlugin& myPlugin = *(CMdsFileServerPlugin*)Plugin();
       
   589     
       
   590     switch( aRequest.Function() )
       
   591         {
       
   592         case EMdsFSPOpRegisterNotification:
       
   593             {
       
   594             WRITELOG( "CMdsFileServerPluginConn::DoControl() - EMdsFSPOpRegisterNotification" );
       
   595             const TInt err = myPlugin.RegisterNotification( aRequest );
       
   596             
       
   597             if ( err != KErrNone )
       
   598                 {
       
   599                 aRequest.Complete( err );
       
   600                 }
       
   601             break;
       
   602             }
       
   603             
       
   604         case EMdsFSPOpAddNotificationPath:
       
   605             {
       
   606             WRITELOG( "CMdsFileServerPluginConn::DoControl() - EMdsFSPOpAddNotificationPath" );
       
   607             const TInt err = myPlugin.AddNotificationPath( aRequest );
       
   608             aRequest.Complete( err );
       
   609             break;
       
   610             }
       
   611             
       
   612         case EMdsFSPOpRemoveNotificationPath:
       
   613             {
       
   614             WRITELOG( "CMdsFileServerPluginConn::DoControl() - EMdsFSPOpRemoveNotificationPath" );
       
   615             const TInt err = myPlugin.RemoveNotificationPath( aRequest );
       
   616             aRequest.Complete( err );
       
   617             break;
       
   618             }
       
   619             
       
   620         case EMdsFSPOpAddIgnorePath:
       
   621             {
       
   622             WRITELOG( "CMdsFileServerPluginConn::DoControl() - EMdsFSPOpAddIgnorePath" );
       
   623             const TInt err = myPlugin.AddIgnorePath( aRequest );
       
   624             aRequest.Complete( err );
       
   625             break;
       
   626             }
       
   627             
       
   628         case EMdsFSPOpRemoveIgnorePath:
       
   629             {
       
   630             WRITELOG( "CMdsFileServerPluginConn::DoControl() - EMdsFSPOpRemoveIgnorePath" );
       
   631             const TInt err = myPlugin.RemoveIgnorePath( aRequest );
       
   632             aRequest.Complete( err );
       
   633             break;
       
   634             }
       
   635         default:
       
   636             break;
       
   637         }
       
   638     }
       
   639 
       
   640 //-----------------------------------------------------------------------------
       
   641 // 
       
   642 //-----------------------------------------------------------------------------
       
   643 //
       
   644 void CMdsFileServerPluginConn::DoCancel( TInt /*aReqMask*/ )
       
   645     {
       
   646     WRITELOG( "CMdsFileServerPluginConn::DoCancel()" );
       
   647     iRequestQue.DoCancelAll( KErrCancel );
       
   648     }
       
   649     
       
   650 //-----------------------------------------------------------------------------
       
   651 // 
       
   652 //-----------------------------------------------------------------------------
       
   653 //
       
   654 CFsPluginConn* CMdsFileServerPlugin::NewPluginConnL()
       
   655     {
       
   656     WRITELOG( "CMdsFileServerPluginConn::NewPluginConnL()" );
       
   657     return CMdsFileServerPluginConn::NewL( *this );
       
   658     }
       
   659     
       
   660 //-----------------------------------------------------------------------------
       
   661 // 
       
   662 //-----------------------------------------------------------------------------
       
   663 //
       
   664 TInt CMdsFileServerPlugin::RegisterNotification( CFsPluginConnRequest& aRequest )
       
   665     {
       
   666     WRITELOG( "CMdsFileServerPlugin::RegisterNotification()" );
       
   667     
       
   668     if ( iNotification )
       
   669         {
       
   670         return KErrInUse;
       
   671         }
       
   672     
       
   673     iNotification = &aRequest;
       
   674     
       
   675     if ( iQueue.Count() > 0 )
       
   676         {
       
   677         WRITELOG( "CMdsFileServerPlugin::RegisterNotification() - item in queue" );
       
   678         
       
   679         CMdsFSPQueueItem* queueItem = iQueue[0];
       
   680         
       
   681         TMdsFSPStatusPckg pckg;
       
   682         TMdsFSPStatus& status = pckg();
       
   683         
       
   684         queueItem->GetAsFspStatus( status );
       
   685 
       
   686         TRAPD( err, iNotification->WriteParam1L(pckg) );
       
   687         iNotification->Complete( err );
       
   688         iNotification = NULL;
       
   689         
       
   690         delete queueItem;
       
   691         queueItem = NULL;
       
   692         iQueue.Remove( 0 );
       
   693         }
       
   694     else
       
   695     	{
       
   696     	iQueue.GranularCompress();
       
   697     	}
       
   698     
       
   699     return KErrNone;
       
   700     }
       
   701     
       
   702 //-----------------------------------------------------------------------------
       
   703 // 
       
   704 //-----------------------------------------------------------------------------
       
   705 //
       
   706 TInt CMdsFileServerPlugin::AddNotificationPath( const CFsPluginConnRequest& aRequest )
       
   707     {
       
   708     WRITELOG( "CMdsFileServerPlugin::AddNotificationPath()" );
       
   709     TInt err = KErrNone;
       
   710     
       
   711     TMdsFSPStatusPckg pckg;
       
   712     TRAP( err, aRequest.ReadParam1L(pckg) );
       
   713     
       
   714     if ( err != KErrNone )
       
   715         {
       
   716         return err;
       
   717         }
       
   718     
       
   719     TMdsFSPStatus& status = pckg();
       
   720     
       
   721     if ( status.iFileName.Length() > 0 )
       
   722         {
       
   723         // check if already exists
       
   724         for ( TInt i = iPaths.Count(); --i >= 0; )
       
   725             {
       
   726             TDesC* tf = iPaths[i];
       
   727             if ( MdsUtils::Compare( status.iFileName, *tf ) == 0 )
       
   728                 {
       
   729                 return KErrNone;
       
   730                 }
       
   731             }
       
   732 
       
   733         WRITELOG1( "CMdsFileServerPlugin::AddNotificationPath() - add path: %S", &status.iFileName );
       
   734         HBufC* fn = status.iFileName.Alloc();
       
   735         if ( fn )
       
   736             {
       
   737             iPaths.Append( fn );
       
   738             }
       
   739         }
       
   740     else
       
   741         {
       
   742         err = KErrNotFound;
       
   743         }
       
   744         
       
   745     return err;
       
   746     }
       
   747     
       
   748 //-----------------------------------------------------------------------------
       
   749 // 
       
   750 //-----------------------------------------------------------------------------
       
   751 //
       
   752 TInt CMdsFileServerPlugin::RemoveNotificationPath( const CFsPluginConnRequest& aRequest )
       
   753     {
       
   754     WRITELOG( "CMdsFileServerPlugin::RemoveNotificationPath()" );
       
   755     TInt err = KErrNone;
       
   756     
       
   757     TMdsFSPStatusPckg pckg;
       
   758     TRAP( err, aRequest.ReadParam1L(pckg) );
       
   759     
       
   760     if ( err != KErrNone )
       
   761         {
       
   762         return err;
       
   763         }
       
   764     
       
   765     TMdsFSPStatus& status = pckg();
       
   766     
       
   767     if ( status.iFileName.Length() > 0 )
       
   768         {
       
   769         // check if already exist
       
   770         if ( iPaths.Count() > 0 )
       
   771             {
       
   772             for ( TInt i = iPaths.Count(); --i >= 0; )
       
   773                 {
       
   774                 TDesC* tf = iPaths[i];
       
   775                 if ( MdsUtils::Compare( status.iFileName, *tf ) == 0 )
       
   776                     {
       
   777                     WRITELOG1( "CMdsFileServerPlugin::RemoveNotificationPath() - remove path: %S", &status.iFileName );
       
   778                     delete tf;
       
   779                     tf = NULL;
       
   780                     iPaths.Remove( i );
       
   781                     }
       
   782                 }
       
   783             }
       
   784         }
       
   785     else
       
   786         {
       
   787         err = KErrNotFound;
       
   788         }
       
   789         
       
   790     return err;
       
   791     }
       
   792     
       
   793 //-----------------------------------------------------------------------------
       
   794 // 
       
   795 //-----------------------------------------------------------------------------
       
   796 //
       
   797 TInt CMdsFileServerPlugin::AddIgnorePath( const CFsPluginConnRequest& aRequest )
       
   798     {
       
   799     WRITELOG( "CMdsFileServerPlugin::AddIgnorePath()" );
       
   800     TInt err = KErrNone;
       
   801     
       
   802     TMdsFSPStatusPckg pckg;
       
   803     TRAP( err, aRequest.ReadParam1L(pckg) );
       
   804     
       
   805     if ( err != KErrNone )
       
   806         {
       
   807         return err;
       
   808         }
       
   809     
       
   810     TMdsFSPStatus& status = pckg();
       
   811     
       
   812     if ( status.iFileName.Length() > 0 )
       
   813         {
       
   814         // check if already exist
       
   815         for ( TInt i = iIgnorePaths.Count(); --i >= 0; )
       
   816             {
       
   817             TDesC* tf = iIgnorePaths[i];
       
   818             if ( MdsUtils::Compare( status.iFileName, *tf ) == 0 )
       
   819                 {
       
   820                 return KErrNone;
       
   821                 }
       
   822             }
       
   823             
       
   824         WRITELOG1( "CMdsFileServerPlugin::AddIgnorePath() - add path: %S", &status.iFileName );
       
   825         HBufC* fn = status.iFileName.Alloc();
       
   826         if ( fn )
       
   827             {
       
   828             iIgnorePaths.Append( fn ); // ownership is transferred
       
   829             }
       
   830         }
       
   831     else
       
   832         {
       
   833         err = KErrNotFound;
       
   834         }
       
   835         
       
   836     return err;
       
   837     }
       
   838     
       
   839 //-----------------------------------------------------------------------------
       
   840 // 
       
   841 //-----------------------------------------------------------------------------
       
   842 //
       
   843 TInt CMdsFileServerPlugin::RemoveIgnorePath( const CFsPluginConnRequest& aRequest )
       
   844     {
       
   845     WRITELOG( "CMdsFileServerPlugin::RemoveIgnorePath()" );
       
   846     TInt err = KErrNone;
       
   847     
       
   848     TMdsFSPStatusPckg pckg;
       
   849     TRAP( err, aRequest.ReadParam1L(pckg) );
       
   850     
       
   851     if ( err != KErrNone )
       
   852         {
       
   853         return err;
       
   854         }
       
   855     
       
   856     TMdsFSPStatus& status = pckg();
       
   857     
       
   858     if ( status.iFileName.Length() > 0 )
       
   859         {
       
   860         // check if already exist
       
   861         for ( TInt i = iIgnorePaths.Count(); --i >= 0; )
       
   862             {
       
   863             TDesC* tf = iIgnorePaths[i];
       
   864             if ( MdsUtils::Compare(status.iFileName, *tf ) == 0 )
       
   865                 {
       
   866                 WRITELOG1( "CMdsFileServerPlugin::RemoveIgnorePath() - remove path: %S", &status.iFileName );
       
   867                 delete tf;
       
   868                 tf = NULL;
       
   869                 iIgnorePaths.Remove( i );
       
   870                 }
       
   871             }
       
   872         }
       
   873     else
       
   874         {
       
   875         err = KErrNotFound;
       
   876         }
       
   877         
       
   878     return err;
       
   879     }
       
   880     
       
   881 //-----------------------------------------------------------------------------
       
   882 // CheckPath
       
   883 //-----------------------------------------------------------------------------
       
   884 //
       
   885 TBool CMdsFileServerPlugin::CheckPath( const TDesC& aFilename ) const
       
   886     {
       
   887     // check if ignored pathlist
       
   888     for ( TInt i = iIgnorePaths.Count(); --i >= 0; )
       
   889         {    
       
   890         TDesC* pathName = iIgnorePaths[i];
       
   891         if ( MdsUtils::Find( aFilename, *pathName ) != KErrNotFound )
       
   892             {
       
   893             return EFalse;
       
   894             }
       
   895         }
       
   896 
       
   897     // check if notification path
       
   898     if ( iPaths.Count() > 0 )
       
   899         {
       
   900         for ( TInt i = iPaths.Count(); --i >= 0; )
       
   901             {
       
   902             TDesC* pathName = iPaths[i];
       
   903             if ( MdsUtils::Find( aFilename, *pathName ) != KErrNotFound )
       
   904                 {
       
   905                 return ETrue;
       
   906                 }
       
   907             }
       
   908         }
       
   909     else
       
   910         {
       
   911         return ETrue;
       
   912         }
       
   913 
       
   914     return EFalse;
       
   915     }
       
   916 
       
   917 //-----------------------------------------------------------------------------
       
   918 // CheckAttribs
       
   919 //-----------------------------------------------------------------------------
       
   920 //
       
   921 TBool CMdsFileServerPlugin::CheckAttribs( const TDesC& aFilename, 
       
   922 		TBool& aIsDirectory ) const
       
   923 	{
       
   924 	// find last backslash from filename and 
       
   925     // take drive and path from filename including last backslash
       
   926     const TChar KBackslashChar( '\\' );
       
   927     TInt pos = aFilename.LocateReverse( KBackslashChar );
       
   928     if ( KErrNotFound == pos )
       
   929     	{
       
   930     	return ETrue;
       
   931     	}
       
   932     TPtrC path( aFilename.Left( pos + 1 ) );
       
   933 
       
   934     TUint att = 0;
       
   935 
       
   936     // check if path is hidden or system path
       
   937     TInt err = iFsSession.Att( path, att );
       
   938     if ( err == KErrNone )
       
   939         {
       
   940         if ( att & KEntryAttHidden || att & KEntryAttSystem )
       
   941             {
       
   942             return EFalse;
       
   943             }
       
   944         }
       
   945 
       
   946     // or is the file hidden or system file
       
   947     att = 0;
       
   948     err = iFsSession.Att( aFilename, att );
       
   949     if ( err == KErrNone )
       
   950         {
       
   951         if ( att & KEntryAttHidden || att & KEntryAttSystem )
       
   952             {
       
   953             return EFalse;
       
   954             }
       
   955         
       
   956         aIsDirectory = att & KEntryAttDir ? ETrue : EFalse;
       
   957         }
       
   958 
       
   959     return ETrue;
       
   960     }
       
   961 
       
   962 //-----------------------------------------------------------------------------
       
   963 // AddBackslashIfNeeded
       
   964 //-----------------------------------------------------------------------------
       
   965 //
       
   966 void CMdsFileServerPlugin::AddBackslashIfNeeded( TDes& aDirName ) const
       
   967 	{
       
   968 	WRITELOG1( "CMdsFileServerPlugin::AddBackslashIfNeeded() - begin, dirName: %S", &aDirName );
       
   969 
       
   970 	const TChar KBackslashChar( '\\' );
       
   971 	
       
   972 	const TInt lastChar = aDirName.Length() - 1;
       
   973 	
       
   974 	// If it is directory which not contain backslash. 
       
   975 	if ( KBackslashChar != aDirName[lastChar] )
       
   976 		{		
       
   977 		aDirName.Append( KBackslashChar );
       
   978 		}
       
   979 
       
   980 	WRITELOG1( "CMdsFileServerPlugin::AddBackslashIfNeeded() - end, dirName: %S", &aDirName );
       
   981 	}
       
   982 
       
   983 //-----------------------------------------------------------------------------
       
   984 // CheckHarvesterStatus
       
   985 //-----------------------------------------------------------------------------
       
   986 //
       
   987 TBool CMdsFileServerPlugin::CheckHarvesterStatus()
       
   988     {
       
   989     WRITELOG( "CMdsFileServerPlugin::CheckHarvesterStatus() - begin" );
       
   990 
       
   991     if( iPendingEvents <= KCleanQueueTreshoald )
       
   992         {
       
   993         WRITELOG( "CMdsFileServerPlugin::CheckHarvesterStatus() - end" );
       
   994         return ETrue;
       
   995         }
       
   996     
       
   997     TFindServer findHarvesterServer( KHarvesterServerName );
       
   998     TFullName name;
       
   999 
       
  1000     TInt result = findHarvesterServer.Next( name );
       
  1001     if ( result == KErrNone )
       
  1002         {
       
  1003         WRITELOG( "CMdsFileServerPlugin::CheckHarvesterStatus() - HarvesterServer running" );
       
  1004         WRITELOG( "CMdsFileServerPlugin::CheckHarvesterStatus() - end" );
       
  1005         
       
  1006         iPendingEvents = 0;
       
  1007         return ETrue;
       
  1008         }
       
  1009     
       
  1010     WRITELOG( "CMdsFileServerPlugin::CheckHarvesterStatus() - end" );
       
  1011     return EFalse;
       
  1012     }
       
  1013 
       
  1014 //-----------------------------------------------------------------------------
       
  1015 // CMdsFileServerPluginFactory implementation
       
  1016 //-----------------------------------------------------------------------------
       
  1017 //
       
  1018 class CMdsFileServerPluginFactory : public CFsPluginFactory
       
  1019     {
       
  1020     public:
       
  1021         CMdsFileServerPluginFactory();
       
  1022         virtual TInt Install();            
       
  1023         virtual CFsPlugin* NewPluginL();
       
  1024         virtual TInt UniquePosition();
       
  1025     };
       
  1026     
       
  1027 // Constructor for the plugin factory
       
  1028 // @internalComponent
       
  1029 CMdsFileServerPluginFactory::CMdsFileServerPluginFactory()
       
  1030     {
       
  1031     WRITELOG( "CMdsFileServerPluginFactory::CMdsFileServerPluginFactory()" );
       
  1032     }
       
  1033 
       
  1034 // Install function for the plugin factory
       
  1035 // @internalComponent
       
  1036 TInt CMdsFileServerPluginFactory::Install()
       
  1037     {
       
  1038     WRITELOG( "CMdsFileServerPluginFactory::Install()" );
       
  1039     iSupportedDrives = KPluginAutoAttach;
       
  1040     
       
  1041     return( SetName(&KMdsFileServerPlugin) );
       
  1042     }
       
  1043 
       
  1044 // @internalComponent
       
  1045 TInt CMdsFileServerPluginFactory::UniquePosition()
       
  1046     {
       
  1047     WRITELOG( "CMdsFileServerPluginFactory::UniquePosition()" );
       
  1048     return( KMdsFSPluginPosition );
       
  1049     }
       
  1050 
       
  1051 // Plugin factory function
       
  1052 // @internalComponent
       
  1053 CFsPlugin* CMdsFileServerPluginFactory::NewPluginL()
       
  1054     {
       
  1055     WRITELOG( "CMdsFileServerPluginFactory::NewPluginL()" );
       
  1056     return CMdsFileServerPlugin::NewL();
       
  1057     }
       
  1058 
       
  1059 // Create a new Plugin
       
  1060 // @internalComponent
       
  1061 extern "C"
       
  1062     {
       
  1063     EXPORT_C CFsPluginFactory* CreateFileSystem()
       
  1064         {
       
  1065         WRITELOG( "CMdsFileServerPluginFactory::CreateFileSystem" );
       
  1066         return( new CMdsFileServerPluginFactory() );
       
  1067         }
       
  1068     }
       
  1069 
       
  1070 #ifdef _DEBUG_EVENTS
       
  1071 
       
  1072 //-----------------------------------------------------------------------------
       
  1073 // 
       
  1074 //-----------------------------------------------------------------------------
       
  1075 //
       
  1076 void CMdsFileServerPlugin::RegisterDebugEventsL()
       
  1077     {
       
  1078     User::LeaveIfError( RegisterIntercept( EFsFileDuplicate, EPreIntercept) );
       
  1079     User::LeaveIfError( RegisterIntercept( EFsFileCreate, EPreIntercept) );
       
  1080     User::LeaveIfError( RegisterIntercept( EFsFileWrite, EPreIntercept) );
       
  1081     User::LeaveIfError( RegisterIntercept( EFsFileFlush, EPreIntercept) );
       
  1082     User::LeaveIfError( RegisterIntercept( EFsFileSetAtt, EPreIntercept) );
       
  1083     User::LeaveIfError( RegisterIntercept( EFsFileChangeMode, EPreIntercept) );
       
  1084     User::LeaveIfError( RegisterIntercept( EFsDelete, EPreIntercept) );
       
  1085     User::LeaveIfError( RegisterIntercept( EFsFileAdopt, EPreIntercept) );
       
  1086     User::LeaveIfError( RegisterIntercept( EFsFileLock, EPreIntercept) );
       
  1087     User::LeaveIfError( RegisterIntercept( EFsFileSize, EPreIntercept) );
       
  1088     User::LeaveIfError( RegisterIntercept( EFsFileRename, EPreIntercept) );
       
  1089     User::LeaveIfError( RegisterIntercept( EFsRename, EPreIntercept) );
       
  1090     User::LeaveIfError( RegisterIntercept( EFsFileOpen, EPreIntercept) );
       
  1091     User::LeaveIfError( RegisterIntercept( EFsFileTemp,    EPreIntercept) );
       
  1092     User::LeaveIfError( RegisterIntercept( EFsFileUnLock, EPreIntercept) );
       
  1093     User::LeaveIfError( RegisterIntercept( EFsFileSetSize, EPreIntercept) );
       
  1094     User::LeaveIfError( RegisterIntercept( EFsFileDrive, EPreIntercept) );
       
  1095     User::LeaveIfError( RegisterIntercept( EFsReplace, EPreIntercept) );
       
  1096     User::LeaveIfError( RegisterIntercept( EFsFileSubClose, EPreIntercept) );
       
  1097     User::LeaveIfError( RegisterIntercept( EFsFileRead, EPreIntercept) );
       
  1098     User::LeaveIfError( RegisterIntercept( EFsFileSeek, EPreIntercept) );
       
  1099     User::LeaveIfError( RegisterIntercept( EFsFileAtt, EPreIntercept) );
       
  1100     User::LeaveIfError( RegisterIntercept( EFsFileSet, EPreIntercept) );
       
  1101     User::LeaveIfError( RegisterIntercept( EFsFileName, EPreIntercept) );
       
  1102     User::LeaveIfError( RegisterIntercept( EFsDirOpen, EPreIntercept) );
       
  1103     }
       
  1104     
       
  1105 //-----------------------------------------------------------------------------
       
  1106 // 
       
  1107 //-----------------------------------------------------------------------------
       
  1108 //
       
  1109 void CMdsFileServerPlugin::UnregisterDebugEventsL()
       
  1110     {
       
  1111     User::LeaveIfError( UnregisterIntercept( EFsFileDuplicate, EPrePostIntercept) );
       
  1112     User::LeaveIfError( UnregisterIntercept( EFsFileCreate, EPrePostIntercept) );
       
  1113     User::LeaveIfError( UnregisterIntercept( EFsFileWrite, EPrePostIntercept) );
       
  1114     User::LeaveIfError( UnregisterIntercept( EFsFileFlush, EPrePostIntercept) );
       
  1115     User::LeaveIfError( UnregisterIntercept( EFsFileSetAtt, EPrePostIntercept) );
       
  1116     User::LeaveIfError( UnregisterIntercept( EFsFileChangeMode, EPrePostIntercept) );
       
  1117     User::LeaveIfError( UnregisterIntercept( EFsDelete, EPrePostIntercept) );
       
  1118     User::LeaveIfError( UnregisterIntercept( EFsFileAdopt, EPrePostIntercept) );
       
  1119     User::LeaveIfError( UnregisterIntercept( EFsFileLock, EPrePostIntercept) );
       
  1120     User::LeaveIfError( UnregisterIntercept( EFsFileSize, EPrePostIntercept) );
       
  1121     User::LeaveIfError( UnregisterIntercept( EFsFileRename, EPrePostIntercept) );
       
  1122     User::LeaveIfError( UnregisterIntercept( EFsRename, EPrePostIntercept) );
       
  1123     User::LeaveIfError( UnregisterIntercept( EFsFileOpen, EPrePostIntercept) );
       
  1124     User::LeaveIfError( UnregisterIntercept( EFsFileTemp, EPrePostIntercept) );
       
  1125     User::LeaveIfError( UnregisterIntercept( EFsFileUnLock, EPrePostIntercept) );
       
  1126     User::LeaveIfError( UnregisterIntercept( EFsFileSetSize, EPrePostIntercept) );
       
  1127     User::LeaveIfError( UnregisterIntercept( EFsFileDrive, EPrePostIntercept) );
       
  1128     User::LeaveIfError( UnregisterIntercept( EFsReplace, EPrePostIntercept) );
       
  1129     User::LeaveIfError( UnregisterIntercept( EFsFileSubClose, EPrePostIntercept) );
       
  1130     User::LeaveIfError( UnregisterIntercept( EFsFileRead, EPrePostIntercept) );
       
  1131     User::LeaveIfError( UnregisterIntercept( EFsFileSeek, EPrePostIntercept) );
       
  1132     User::LeaveIfError( UnregisterIntercept( EFsFileAtt, EPrePostIntercept) );
       
  1133     User::LeaveIfError( UnregisterIntercept( EFsFileSet, EPrePostIntercept) );
       
  1134     User::LeaveIfError( UnregisterIntercept( EFsFileName, EPrePostIntercept) );
       
  1135     User::LeaveIfError( UnregisterIntercept( EFsDirOpen, EPrePostIntercept) );
       
  1136     }
       
  1137     
       
  1138 //-----------------------------------------------------------------------------
       
  1139 // 
       
  1140 //-----------------------------------------------------------------------------
       
  1141 //
       
  1142 void CMdsFileServerPlugin::PrintDebugEvents( TInt aFunction )
       
  1143     {
       
  1144     switch ( aFunction )
       
  1145         {
       
  1146         case EFsFileDuplicate:
       
  1147             WRITELOG( "CMdsFileServerPlugin::PrintDebugEvents() - EFsFileDuplicate" );
       
  1148             break;
       
  1149             
       
  1150         case EFsFileCreate:
       
  1151             WRITELOG( "CMdsFileServerPlugin::PrintDebugEvents() - EFsFileCreate" );
       
  1152             break;
       
  1153         case EFsFileWrite:
       
  1154             WRITELOG( "CMdsFileServerPlugin::PrintDebugEvents() - EFsFileWrite" );
       
  1155             break;
       
  1156         case EFsFileFlush:
       
  1157             WRITELOG( "CMdsFileServerPlugin::PrintDebugEvents() - EFsFileFlush" );
       
  1158             break;
       
  1159         case EFsFileSetAtt:
       
  1160             WRITELOG( "CMdsFileServerPlugin::PrintDebugEvents() - EFsFileSetAtt" );
       
  1161             break;
       
  1162         case EFsFileChangeMode:
       
  1163             WRITELOG( "CMdsFileServerPlugin::PrintDebugEvents() - EFsFileChangeMode" );
       
  1164             break;    
       
  1165         case EFsDelete:
       
  1166             WRITELOG( "CMdsFileServerPlugin::PrintDebugEvents() - EFsDelete" );
       
  1167             break;    
       
  1168         case EFsFileAdopt:
       
  1169             WRITELOG( "CMdsFileServerPlugin::PrintDebugEvents() - EFsFileAdopt" );
       
  1170             break;    
       
  1171         case EFsFileReplace:
       
  1172             WRITELOG( "CMdsFileServerPlugin::PrintDebugEvents() - EFsFileReplace" );
       
  1173             break;    
       
  1174         case EFsFileLock:
       
  1175             WRITELOG( "CMdsFileServerPlugin::PrintDebugEvents() - EFsFileLock" );
       
  1176             break;    
       
  1177         case EFsFileSize:
       
  1178             WRITELOG( "CMdsFileServerPlugin::PrintDebugEvents() - EFsFileSize" );
       
  1179             break;    
       
  1180         case EFsFileModified:
       
  1181             WRITELOG( "CMdsFileServerPlugin::PrintDebugEvents() - EFsFileModified" );
       
  1182             break;    
       
  1183         case EFsFileRename:
       
  1184             WRITELOG( "CMdsFileServerPlugin::PrintDebugEvents() - EFsFileRename" );
       
  1185             break;    
       
  1186         case EFsRename:
       
  1187             WRITELOG( "CMdsFileServerPlugin::PrintDebugEvents() - EFsRename" );
       
  1188             break;    
       
  1189         case EFsFileOpen:
       
  1190             WRITELOG( "CMdsFileServerPlugin::PrintDebugEvents() - EFsFileOpen" );
       
  1191             break;    
       
  1192         case EFsFileTemp:
       
  1193             WRITELOG( "CMdsFileServerPlugin::PrintDebugEvents() - EFsFileTemp" );
       
  1194             break;    
       
  1195         case EFsFileUnLock:
       
  1196             WRITELOG( "CMdsFileServerPlugin::PrintDebugEvents() - EFsFileUnLock" );
       
  1197             break;    
       
  1198         case EFsFileSetSize:
       
  1199             WRITELOG( "CMdsFileServerPlugin::PrintDebugEvents() - EFsFileSetSize" );
       
  1200             break;    
       
  1201         case EFsFileSetModified:
       
  1202             WRITELOG( "CMdsFileServerPlugin::PrintDebugEvents() - EFsFileSetModified" );
       
  1203             break;
       
  1204         case EFsFileDrive:
       
  1205             WRITELOG( "CMdsFileServerPlugin::PrintDebugEvents() - EFsFileDrive" );
       
  1206             break;    
       
  1207         case EFsReplace:
       
  1208             WRITELOG( "CMdsFileServerPlugin::PrintDebugEvents() - EFsReplace" );
       
  1209             break;    
       
  1210         case EFsFileSubClose:
       
  1211             WRITELOG( "CMdsFileServerPlugin::PrintDebugEvents() - EFsFileSubClose" );
       
  1212             break;    
       
  1213         case EFsFileRead:
       
  1214             WRITELOG( "CMdsFileServerPlugin::PrintDebugEvents() - EFsFileRead" );
       
  1215             break;
       
  1216         case EFsFileSeek:
       
  1217             WRITELOG( "CMdsFileServerPlugin::PrintDebugEvents() - EFsFileSeek" );
       
  1218             break;    
       
  1219         case EFsFileAtt:
       
  1220             WRITELOG( "CMdsFileServerPlugin::PrintDebugEvents() - EFsFileAtt" );
       
  1221             break;    
       
  1222         case EFsFileSet:
       
  1223             WRITELOG( "CMdsFileServerPlugin::PrintDebugEvents() - EFsFileSet" );
       
  1224             break;    
       
  1225         case EFsFileName:
       
  1226             WRITELOG( "CMdsFileServerPlugin::PrintDebugEvents() - EFsFileName" );
       
  1227             break;    
       
  1228         case EFsDirOpen:
       
  1229             WRITELOG( "CMdsFileServerPlugin::PrintDebugEvents() - EFsDirOpen" );
       
  1230             break;    
       
  1231         default:
       
  1232         break;
       
  1233         }
       
  1234     }
       
  1235 #endif