harvester/monitorplugins/mdsfileserverplugin/src/mdsfileserverplugin.cpp
branchRCL_3
changeset 8 6752808b2036
parent 3 b73a2e62868f
child 14 646a02f170b9
equal deleted inserted replaced
3:b73a2e62868f 8:6752808b2036
    48     TRAP_IGNORE( DisableL() );
    48     TRAP_IGNORE( DisableL() );
    49     iFsSession.Close();
    49     iFsSession.Close();
    50     
    50     
    51     iCreatedFiles.ResetAndDestroy();
    51     iCreatedFiles.ResetAndDestroy();
    52     iCreatedFiles.Close();
    52     iCreatedFiles.Close();
       
    53     
       
    54     iModifiedFiles.ResetAndDestroy();
       
    55     iModifiedFiles.Close();
    53   
    56   
    54     iPaths.ResetAndDestroy();
    57     iPaths.ResetAndDestroy();
    55     iPaths.Close();
    58     iPaths.Close();
    56     
    59     
    57     iIgnorePaths.ResetAndDestroy();
    60     iIgnorePaths.ResetAndDestroy();
   179 		}
   182 		}
   180 	
   183 	
   181 	TInt function = aRequest.Function();
   184 	TInt function = aRequest.Function();
   182 	
   185 	
   183 	iFileName.Zero();
   186 	iFileName.Zero();
       
   187     iNewFileName.Zero();
   184 	
   188 	
   185 #ifdef _DEBUG_EVENTS
   189 #ifdef _DEBUG_EVENTS
   186     PrintDebugEvents( function );
   190     PrintDebugEvents( function );
   187 #endif
   191 #endif
   188     
   192     
   196 #endif
   200 #endif
   197         return KErrNone;
   201         return KErrNone;
   198         }
   202         }
   199     
   203     
   200     const TBool formatFunction = function == EFsFormatOpen || function == EFsFormatSubClose;
   204     const TBool formatFunction = function == EFsFormatOpen || function == EFsFormatSubClose;
   201     iNewFileName.Zero();
       
   202         
   205         
   203     WRITELOG1( "----- CMdsFileServerPlugin::DoRequestL() - plugin function: %d -----", function );
   206     WRITELOG1( "----- CMdsFileServerPlugin::DoRequestL() - plugin function: %d -----", function );
   204 
   207 
   205 	if ( !formatFunction )
   208 	if ( !formatFunction )
   206 		{
   209 		{
   372             WRITELOG1( "CMdsFileServerPlugin::DoRequestL() - EFsFileRename, new file: %S", &iNewFileName );
   375             WRITELOG1( "CMdsFileServerPlugin::DoRequestL() - EFsFileRename, new file: %S", &iNewFileName );
   373             fileEventType = EMdsFileRenamed;
   376             fileEventType = EMdsFileRenamed;
   374             break;
   377             break;
   375 
   378 
   376         case EFsFileSetModified:
   379         case EFsFileSetModified:
       
   380         
       
   381             WRITELOG( "CMdsFileServerPlugin::DoRequestL() - EFsFileSetModified" );
       
   382             iModifiedFiles.Append( iFileName.AllocL() );
       
   383             fileEventType = EMdsFileModified;
       
   384             break;
       
   385 
   377         case EFsSetEntry:
   386         case EFsSetEntry:
   378             WRITELOG( "CMdsFileServerPlugin::DoRequestL() - EFsFileSetModified" );
   387             {
       
   388             WRITELOG( "CMdsFileServerPlugin::DoRequestL() - EFsSetEntry" );
       
   389 
       
   390             TBool found = EFalse;
       
   391 
       
   392             for ( TInt i = iModifiedFiles.Count(); --i >= 0; )
       
   393                     {
       
   394                     if ( MdsUtils::Compare( iFileName, *(iModifiedFiles[i]) ) == 0 )
       
   395                       {
       
   396                         delete iModifiedFiles[i];
       
   397                         iModifiedFiles.Remove( i );
       
   398                         found = ETrue;
       
   399                         }
       
   400                     }
       
   401             
       
   402             if( iModifiedFiles.Count() == 0 )
       
   403                 {
       
   404                 iModifiedFiles.GranularCompress();
       
   405                 }
       
   406             
       
   407             if ( found )
       
   408                 {
       
   409                 return KErrNone;
       
   410                 }
       
   411             
   379             fileEventType = EMdsFileModified;
   412             fileEventType = EMdsFileModified;
   380             break;
   413             }
   381 
   414             break;            
       
   415             
   382         case EFsFileReplace:
   416         case EFsFileReplace:
   383         case EFsReplace:
   417         case EFsReplace:
   384             WRITELOG1( "CMdsFileServerPlugin::DoRequestL() - EFsReplace/EFsFileReplace, new file: %S", &iNewFileName );
   418             WRITELOG1( "CMdsFileServerPlugin::DoRequestL() - EFsReplace/EFsFileReplace, new file: %S", &iNewFileName );
   385             fileEventType = EMdsFileReplaced;
   419             fileEventType = EMdsFileReplaced;
   386             break;
   420             break;
   541     iPlugin.AddConnection();
   575     iPlugin.AddConnection();
   542     }
   576     }
   543 
   577 
   544 
   578 
   545 /**
   579 /**
   546 * The destructor for the test virus scanner hook.
   580 * The destructor.
   547 * @internalComponent
   581 * @internalComponent
   548 */
   582 */
   549 CMdsFileServerPluginConn::~CMdsFileServerPluginConn()
   583 CMdsFileServerPluginConn::~CMdsFileServerPluginConn()
   550     {
   584     {
   551     WRITELOG( "CMdsFileServerPluginConn::~CMdsFileServerPluginConn()" );
   585     WRITELOG( "CMdsFileServerPluginConn::~CMdsFileServerPluginConn()" );
   732     TMdsFSPStatus& status = pckg();
   766     TMdsFSPStatus& status = pckg();
   733     
   767     
   734     if ( status.iFileName.Length() > 0 )
   768     if ( status.iFileName.Length() > 0 )
   735         {
   769         {
   736         // check if already exists
   770         // check if already exists
   737         for ( TInt i = iPaths.Count(); --i >= 0; )
   771         const TInt count( iPaths.Count() );
       
   772         for ( TInt i = count; --i >= 0; )
   738             {
   773             {
   739             TDesC* tf = iPaths[i];
   774             TDesC* tf = iPaths[i];
   740             if ( MdsUtils::Compare( status.iFileName, *tf ) == 0 )
   775             if ( MdsUtils::Compare( status.iFileName, *tf ) == 0 )
   741                 {
   776                 {
   742                 return KErrNone;
   777                 return KErrNone;
   777     
   812     
   778     TMdsFSPStatus& status = pckg();
   813     TMdsFSPStatus& status = pckg();
   779     
   814     
   780     if ( status.iFileName.Length() > 0 )
   815     if ( status.iFileName.Length() > 0 )
   781         {
   816         {
   782         // check if already exist
   817         for ( TInt i = iPaths.Count(); --i >= 0; )
   783         if ( iPaths.Count() > 0 )
   818             {
   784             {
   819             TDesC* tf = iPaths[i];
   785             for ( TInt i = iPaths.Count(); --i >= 0; )
   820             if ( MdsUtils::Compare( status.iFileName, *tf ) == 0 )
   786                 {
   821                 {
   787                 TDesC* tf = iPaths[i];
   822                 WRITELOG1( "CMdsFileServerPlugin::RemoveNotificationPath() - remove path: %S", &status.iFileName );
   788                 if ( MdsUtils::Compare( status.iFileName, *tf ) == 0 )
   823                 delete tf;
   789                     {
   824                 tf = NULL;
   790                     WRITELOG1( "CMdsFileServerPlugin::RemoveNotificationPath() - remove path: %S", &status.iFileName );
   825                 iPaths.Remove( i );
   791                     delete tf;
       
   792                     tf = NULL;
       
   793                     iPaths.Remove( i );
       
   794                     }
       
   795                 }
   826                 }
   796             }
   827             }
       
   828         iPaths.Compress();
   797         }
   829         }
   798     else
   830     else
   799         {
   831         {
   800         err = KErrNotFound;
   832         err = KErrNotFound;
   801         }
   833         }
   880                 delete tf;
   912                 delete tf;
   881                 tf = NULL;
   913                 tf = NULL;
   882                 iIgnorePaths.Remove( i );
   914                 iIgnorePaths.Remove( i );
   883                 }
   915                 }
   884             }
   916             }
       
   917         iIgnorePaths.Compress();
   885         }
   918         }
   886     else
   919     else
   887         {
   920         {
   888         err = KErrNotFound;
   921         err = KErrNotFound;
   889         }
   922         }