diff -r 367228f82b66 -r 7a8855317cbd harvesterplugins/file/src/cfileplugin.cpp --- a/harvesterplugins/file/src/cfileplugin.cpp Tue Oct 05 13:32:14 2010 +0530 +++ b/harvesterplugins/file/src/cfileplugin.cpp Fri Oct 15 11:45:38 2010 +0530 @@ -56,6 +56,7 @@ _LIT(KMimeTypeFile, FILE_MIMETYPE); _LIT(KMimeTypeFolder , FOLDER_MIMETYPE); _LIT(KMimeTypeField , CPIX_MIMETYPE_FIELD); +_LIT(KManagerFileName, "FilesStore.temp"); #define CONSTANT_TO_PTR16(ptr, c) TPtrC16 ptr; ptr.Set((const TUint16*)c,User::StringLength(c) ); @@ -221,7 +222,18 @@ iHarvester = CFileHarvester::NewL(*this, iFs); iMonitor = CFileMonitor::NewL(*this, &iFs); - iMmcMonitor = CMMCMonitor::NewL(*this, &iFs); + iMmcMonitor = CMMCMonitor::NewL(*this, &iFs); + + // connect to file system + User::LeaveIfError(iFs.Connect()); + // Load the configuration + TFileName pathWithoutDrive; + iFs.CreatePrivatePath(EDriveC); + iFilePath = _L("C:"); + iFs.PrivatePath( pathWithoutDrive ); + iFilePath.Append(pathWithoutDrive); + iFilePath.Append(KManagerFileName); + } void CFilePlugin::StartPluginL() @@ -266,6 +278,9 @@ } } } + + if( BaflUtils::FileExists(iFs,iFilePath) ) + LoadL(); } void CFilePlugin::MountL(TDriveNumber aMedia, TBool aForceReharvest) @@ -687,11 +702,9 @@ } void CFilePlugin::RemoveFileDatabaseL(TDriveNumber aDrive) - { - RFs aFs; - User::LeaveIfError( aFs.Connect() ); + { TChar drive; - TInt err = aFs.DriveToChar((TDriveNumber)aDrive,drive); + TInt err = iFs.DriveToChar((TDriveNumber)aDrive,drive); if ( err == KErrNone ) { TBuf folderpath; @@ -700,12 +713,11 @@ folderpath.Append(KCPixSearchServerPrivateDirectory); folderpath.Append(KIndexingDBPath); folderpath.Append(KfileDBPath); - CFileMan* FileMan = CFileMan::NewL(aFs); + CFileMan* FileMan = CFileMan::NewL(iFs); if ( FileMan ) FileMan->Delete( folderpath ); delete FileMan; } - aFs.Close(); } void CFilePlugin::PausePluginL() @@ -771,9 +783,73 @@ } iJobQueue.Remove(0); } + + if(iJobQueue.Count() <= 0) + { + //Check for temp file, it exists delete + if( BaflUtils::FileExists( iFs, iFilePath )) + BaflUtils::DeleteFile( iFs, iFilePath ); + } + OstTraceFunctionExit0( CFILEPLUGIN_INDEXQUEUEDITEMS_EXIT ); } +void CFilePlugin::LoadL() + { + // Open the stream + RFile file; + User::LeaveIfError(file.Open(iFs, iFilePath, EFileRead)); + CleanupClosePushL(file); + RFileReadStream rd(file); + rd.PushL(); + + // Read harvester count + TInt count = rd.ReadInt32L(); + // Read the harvesters + for (TInt i=0; i ( rd.ReadInt16L()); + record.isFolder = rd.ReadInt8L(); + AddToQueueL(record.iUri, record.iActionType, record.isFolder); + } + + if( count > 0) + IndexQueuedItems(); + // Cleanup + CleanupStack::PopAndDestroy(2, &file); + } + +void CFilePlugin::SaveL() + { + if (iJobQueue.Count() <= 0) + return; + + // Open the stream + RFile file; + User::LeaveIfError(file.Replace(iFs, iFilePath, EFileWrite)); + CleanupClosePushL(file); + + RFileWriteStream wr(file); + wr.PushL(); + + // Write harvester count + wr.WriteInt32L(iJobQueue.Count()); + + for (TInt i=0; i