54 _LIT(KExtensionField, "Extension"); |
54 _LIT(KExtensionField, "Extension"); |
55 _LIT(KIsFolderField, "IsFolder"); |
55 _LIT(KIsFolderField, "IsFolder"); |
56 _LIT(KMimeTypeFile, FILE_MIMETYPE); |
56 _LIT(KMimeTypeFile, FILE_MIMETYPE); |
57 _LIT(KMimeTypeFolder , FOLDER_MIMETYPE); |
57 _LIT(KMimeTypeFolder , FOLDER_MIMETYPE); |
58 _LIT(KMimeTypeField , CPIX_MIMETYPE_FIELD); |
58 _LIT(KMimeTypeField , CPIX_MIMETYPE_FIELD); |
|
59 _LIT(KManagerFileName, "FilesStore.temp"); |
59 |
60 |
60 #define CONSTANT_TO_PTR16(ptr, c) TPtrC16 ptr; ptr.Set((const TUint16*)c,User::StringLength(c) ); |
61 #define CONSTANT_TO_PTR16(ptr, c) TPtrC16 ptr; ptr.Set((const TUint16*)c,User::StringLength(c) ); |
61 |
62 |
62 /** |
63 /** |
63 * MapFileToDrive - returns the TDriveNumber that the file is located on. |
64 * MapFileToDrive - returns the TDriveNumber that the file is located on. |
219 } |
220 } |
220 } |
221 } |
221 |
222 |
222 iHarvester = CFileHarvester::NewL(*this, iFs); |
223 iHarvester = CFileHarvester::NewL(*this, iFs); |
223 iMonitor = CFileMonitor::NewL(*this, &iFs); |
224 iMonitor = CFileMonitor::NewL(*this, &iFs); |
224 iMmcMonitor = CMMCMonitor::NewL(*this, &iFs); |
225 iMmcMonitor = CMMCMonitor::NewL(*this, &iFs); |
|
226 |
|
227 // connect to file system |
|
228 User::LeaveIfError(iFs.Connect()); |
|
229 // Load the configuration |
|
230 TFileName pathWithoutDrive; |
|
231 iFs.CreatePrivatePath(EDriveC); |
|
232 iFilePath = _L("C:"); |
|
233 iFs.PrivatePath( pathWithoutDrive ); |
|
234 iFilePath.Append(pathWithoutDrive); |
|
235 iFilePath.Append(KManagerFileName); |
|
236 |
225 } |
237 } |
226 |
238 |
227 void CFilePlugin::StartPluginL() |
239 void CFilePlugin::StartPluginL() |
228 { |
240 { |
229 TInt error = KErrNone; |
241 TInt error = KErrNone; |
685 OstTraceFunctionExit0( CFILEPLUGIN_CREATECPIXDOCUMENTL_EXIT ); |
700 OstTraceFunctionExit0( CFILEPLUGIN_CREATECPIXDOCUMENTL_EXIT ); |
686 return index_item; |
701 return index_item; |
687 } |
702 } |
688 |
703 |
689 void CFilePlugin::RemoveFileDatabaseL(TDriveNumber aDrive) |
704 void CFilePlugin::RemoveFileDatabaseL(TDriveNumber aDrive) |
690 { |
705 { |
691 RFs aFs; |
|
692 User::LeaveIfError( aFs.Connect() ); |
|
693 TChar drive; |
706 TChar drive; |
694 TInt err = aFs.DriveToChar((TDriveNumber)aDrive,drive); |
707 TInt err = iFs.DriveToChar((TDriveNumber)aDrive,drive); |
695 if ( err == KErrNone ) |
708 if ( err == KErrNone ) |
696 { |
709 { |
697 TBuf<KMaxFileName> folderpath; |
710 TBuf<KMaxFileName> folderpath; |
698 folderpath.Append(drive); |
711 folderpath.Append(drive); |
699 folderpath.Append(KFilePluginColon); |
712 folderpath.Append(KFilePluginColon); |
700 folderpath.Append(KCPixSearchServerPrivateDirectory); |
713 folderpath.Append(KCPixSearchServerPrivateDirectory); |
701 folderpath.Append(KIndexingDBPath); |
714 folderpath.Append(KIndexingDBPath); |
702 folderpath.Append(KfileDBPath); |
715 folderpath.Append(KfileDBPath); |
703 CFileMan* FileMan = CFileMan::NewL(aFs); |
716 CFileMan* FileMan = CFileMan::NewL(iFs); |
704 if ( FileMan ) |
717 if ( FileMan ) |
705 FileMan->Delete( folderpath ); |
718 FileMan->Delete( folderpath ); |
706 delete FileMan; |
719 delete FileMan; |
707 } |
720 } |
708 aFs.Close(); |
|
709 } |
721 } |
710 |
722 |
711 void CFilePlugin::PausePluginL() |
723 void CFilePlugin::PausePluginL() |
712 { |
724 { |
713 OstTraceFunctionEntry0( CFILEPLUGIN_PAUSEPLUGINL_ENTRY ); |
725 OstTraceFunctionEntry0( CFILEPLUGIN_PAUSEPLUGINL_ENTRY ); |
769 CreateContentIndexItemL( entry.iUri, entry.iActionType ); |
781 CreateContentIndexItemL( entry.iUri, entry.iActionType ); |
770 CreateFolderFileIndexItemL( entry.iUri, entry.iActionType, entry.isFolder ); |
782 CreateFolderFileIndexItemL( entry.iUri, entry.iActionType, entry.isFolder ); |
771 } |
783 } |
772 iJobQueue.Remove(0); |
784 iJobQueue.Remove(0); |
773 } |
785 } |
|
786 |
|
787 if(iJobQueue.Count() <= 0) |
|
788 { |
|
789 //Check for temp file, it exists delete |
|
790 if( BaflUtils::FileExists( iFs, iFilePath )) |
|
791 BaflUtils::DeleteFile( iFs, iFilePath ); |
|
792 } |
|
793 |
774 OstTraceFunctionExit0( CFILEPLUGIN_INDEXQUEUEDITEMS_EXIT ); |
794 OstTraceFunctionExit0( CFILEPLUGIN_INDEXQUEUEDITEMS_EXIT ); |
|
795 } |
|
796 |
|
797 void CFilePlugin::LoadL() |
|
798 { |
|
799 // Open the stream |
|
800 RFile file; |
|
801 User::LeaveIfError(file.Open(iFs, iFilePath, EFileRead)); |
|
802 CleanupClosePushL(file); |
|
803 RFileReadStream rd(file); |
|
804 rd.PushL(); |
|
805 |
|
806 // Read harvester count |
|
807 TInt count = rd.ReadInt32L(); |
|
808 // Read the harvesters |
|
809 for (TInt i=0; i<count; i++) |
|
810 { |
|
811 TRecord record; |
|
812 TInt length = rd.ReadInt32L(); |
|
813 rd.ReadL(record.iUri, length); |
|
814 record.iActionType = static_cast<TCPixActionType> ( rd.ReadInt16L()); |
|
815 record.isFolder = rd.ReadInt8L(); |
|
816 AddToQueueL(record.iUri, record.iActionType, record.isFolder); |
|
817 } |
|
818 |
|
819 if( count > 0) |
|
820 IndexQueuedItems(); |
|
821 // Cleanup |
|
822 CleanupStack::PopAndDestroy(2, &file); |
|
823 } |
|
824 |
|
825 void CFilePlugin::SaveL() |
|
826 { |
|
827 if (iJobQueue.Count() <= 0) |
|
828 return; |
|
829 |
|
830 // Open the stream |
|
831 RFile file; |
|
832 User::LeaveIfError(file.Replace(iFs, iFilePath, EFileWrite)); |
|
833 CleanupClosePushL(file); |
|
834 |
|
835 RFileWriteStream wr(file); |
|
836 wr.PushL(); |
|
837 |
|
838 // Write harvester count |
|
839 wr.WriteInt32L(iJobQueue.Count()); |
|
840 |
|
841 for (TInt i=0; i<iJobQueue.Count(); i++) |
|
842 { |
|
843 wr.WriteInt32L(iJobQueue[i].iUri.Length()); |
|
844 wr.WriteL(iJobQueue[i].iUri); |
|
845 wr.WriteInt16L(iJobQueue[i].iActionType); |
|
846 wr.WriteInt8L(iJobQueue[i].isFolder); |
|
847 } |
|
848 // Commit and cleanup |
|
849 wr.CommitL(); |
|
850 CleanupStack::PopAndDestroy(2, &file); |
775 } |
851 } |
776 |
852 |
777 #ifdef __PERFORMANCE_DATA |
853 #ifdef __PERFORMANCE_DATA |
778 void CFilePlugin::UpdatePerformaceDataL(TDriveNumber aDriveNumber) |
854 void CFilePlugin::UpdatePerformaceDataL(TDriveNumber aDriveNumber) |
779 { |
855 { |