39 |
39 |
40 // local declarations and functions |
40 // local declarations and functions |
41 namespace { |
41 namespace { |
42 |
42 |
43 _LIT(KCPixSearchServerPrivateDirectory, "\\Private\\2001f6f7\\"); |
43 _LIT(KCPixSearchServerPrivateDirectory, "\\Private\\2001f6f7\\"); |
|
44 _LIT(KIndexingDBPath,"indexing\\indexdb"); |
44 _LIT(KPathIndexDbPath, CPIX_INDEVICE_INDEXDB); |
45 _LIT(KPathIndexDbPath, CPIX_INDEVICE_INDEXDB); |
|
46 _LIT(KfileDBPath, "\\root\\file"); |
45 _LIT(KPathFolder, "\\root\\file\\folder"); |
47 _LIT(KPathFolder, "\\root\\file\\folder"); |
46 _LIT(KPathFileContent, "\\root\\file\\content"); |
48 _LIT(KPathFileContent, "\\root\\file\\content"); |
47 _LIT(KFileBaseAppClassContent, "root file content"); |
49 _LIT(KFileBaseAppClassContent, "root file content"); |
48 _LIT(KFileBaseAppClassFolder, "root file folder"); |
50 _LIT(KFileBaseAppClassFolder, "root file folder"); |
49 _LIT(KFilePluginAtSign, "@"); |
51 _LIT(KFilePluginAtSign, "@"); |
107 } // anonymous namespace |
109 } // anonymous namespace |
108 |
110 |
109 |
111 |
110 TBool CFilePlugin::IsFileTypeMedia(const TDesC& aExt) |
112 TBool CFilePlugin::IsFileTypeMedia(const TDesC& aExt) |
111 { |
113 { |
|
114 OstTraceFunctionEntry0( CFILEPLUGIN_ISFILETYPEMEDIA_ENTRY ); |
112 |
115 |
113 const TText* KMediaExt[] = {_S("txt"),_S("pdf"), _S("jpg"),_S("mp3"), _S("jpeg"), _S("wma"), _S("3gp"), _S("mpg4"), |
116 const TText* KMediaExt[] = {_S("txt"),_S("pdf"), _S("jpg"),_S("mp3"), _S("jpeg"), _S("wma"), _S("3gp"), _S("mpg4"), |
114 _S("avi"), _S("jpf"), _S("mbm"), _S("png"), _S("gif"), _S("bmp"), _S("mp4"), _S("mpeg4"), |
117 _S("avi"), _S("jpf"), _S("mbm"), _S("png"), _S("gif"), _S("bmp"), _S("mp4"), _S("mpeg4"), |
115 _S("m4v"), _S("m4a"), _S("3gpp"), _S("3g2"), _S("aac"), _S("amr"), _S("wmv"), _S("divx"), |
118 _S("m4v"), _S("m4a"), _S("3gpp"), _S("3g2"), _S("aac"), _S("amr"), _S("wmv"), _S("divx"), |
116 _S("awb"),_S("mid"), _S("midi"), _S("spmid"), _S("rng"), _S("mxmf"), _S("wav"), |
119 _S("awb"),_S("mid"), _S("midi"), _S("spmid"), _S("rng"), _S("mxmf"), _S("wav"), |
167 { |
171 { |
168 UnMount(TDriveNumber(i), EFalse); |
172 UnMount(TDriveNumber(i), EFalse); |
169 } |
173 } |
170 delete iHarvester; |
174 delete iHarvester; |
171 delete iMonitor; |
175 delete iMonitor; |
172 delete iMmcMonitor; |
176 delete iMmcMonitor; |
173 |
177 iMountDrives.Close(); |
|
178 iJobQueue.Reset(); |
|
179 iJobQueue.Close(); |
174 TInt err = iFs.DismountPlugin(KFastFindFSPluginName); |
180 TInt err = iFs.DismountPlugin(KFastFindFSPluginName); |
175 CPIXLOGSTRING2("CFilePlugin::~CFilePlugin(), iFs.DismountPlugin: %i", err); |
181 CPIXLOGSTRING2("CFilePlugin::~CFilePlugin(), iFs.DismountPlugin: %i", err); |
176 err = iFs.RemovePlugin(KFastFindFSPluginName); |
182 err = iFs.RemovePlugin(KFastFindFSPluginName); |
177 CPIXLOGSTRING2("CFilePlugin::~CFilePlugin(), iFs.RemovePlugin: %i", err); |
183 CPIXLOGSTRING2("CFilePlugin::~CFilePlugin(), iFs.RemovePlugin: %i", err); |
178 iFs.Close(); |
184 iFs.Close(); |
179 } |
185 } |
180 |
186 |
181 void CFilePlugin::ConstructL() |
187 void CFilePlugin::ConstructL() |
182 { |
188 { |
|
189 iIndexState = ETrue; |
183 User::LeaveIfError( iFs.Connect() ); |
190 User::LeaveIfError( iFs.Connect() ); |
184 TInt err = iFs.AddPlugin(KFastFindFSPluginFile); |
191 TInt err = iFs.AddPlugin(KFastFindFSPluginFile); |
185 OstTrace1( TRACE_NORMAL, CFILEPLUGIN_CONSTRUCTL, "CFilePlugin::ConstructL;iFs.AddPlugin=%d", err ); |
192 OstTrace1( TRACE_NORMAL, CFILEPLUGIN_CONSTRUCTL, "CFilePlugin::ConstructL;iFs.AddPlugin=%d", err ); |
186 CPIXLOGSTRING2("CFilePlugin::ConstructL, iFs.AddPlugin: %i", err); |
193 CPIXLOGSTRING2("CFilePlugin::ConstructL, iFs.AddPlugin: %i", err); |
187 if ( err != KErrAlreadyExists ) |
194 if ( err != KErrAlreadyExists ) |
266 OstTraceFunctionEntry0( CFILEPLUGIN_MOUNTL_ENTRY ); |
273 OstTraceFunctionEntry0( CFILEPLUGIN_MOUNTL_ENTRY ); |
267 CPIXLOGSTRING("ENTER CFilePlugin::MountL"); |
274 CPIXLOGSTRING("ENTER CFilePlugin::MountL"); |
268 // Check if already exists |
275 // Check if already exists |
269 if (iIndexer[aMedia] && iFolderIndexer[aMedia]) |
276 if (iIndexer[aMedia] && iFolderIndexer[aMedia]) |
270 return; |
277 return; |
|
278 //remove the database incase of memory card insertion before harvesting |
|
279 if (aForceReharvest) |
|
280 { |
|
281 RemoveFileDatabaseL(aMedia); |
|
282 } |
271 |
283 |
272 // Add Notifications paths prior to opening IndexDB. |
284 // Add Notifications paths prior to opening IndexDB. |
273 AddNotificationPathsL(aMedia); |
285 AddNotificationPathsL(aMedia); |
274 |
286 |
275 // Form the baseappclass for folder |
287 // Form the baseappclass for folder |
369 // Reset the database |
381 // Reset the database |
370 iIndexer[drive]->ResetL(); |
382 iIndexer[drive]->ResetL(); |
371 iFolderIndexer[drive]->ResetL(); |
383 iFolderIndexer[drive]->ResetL(); |
372 |
384 |
373 // Start the actual harvest |
385 // Start the actual harvest |
374 iHarvester->StartL(drive); |
386 if( iIndexState ) |
|
387 { |
|
388 iHarvester->StartL(drive); |
|
389 } |
|
390 else |
|
391 { |
|
392 iMountDrives.Append(TDriveNumber(drive)); |
|
393 } |
375 CPIXLOGSTRING("END CFilePlugin::StartHarvestingL "); |
394 CPIXLOGSTRING("END CFilePlugin::StartHarvestingL "); |
376 OstTraceFunctionExit0( CFILEPLUGIN_STARTHARVESTINGL_EXIT ); |
395 OstTraceFunctionExit0( CFILEPLUGIN_STARTHARVESTINGL_EXIT ); |
377 } |
396 } |
378 |
397 |
379 void CFilePlugin::CreateContentIndexItemL(const TDesC& aFilename, TCPixActionType aActionType) |
398 void CFilePlugin::CreateContentIndexItemL(const TDesC& aFilename, TCPixActionType aActionType) |
380 { |
399 { |
|
400 OstTraceFunctionEntry0( CFILEPLUGIN_CREATECONTENTINDEXITEML_ENTRY ); |
381 TFileName lowerCaseFilename(aFilename); |
401 TFileName lowerCaseFilename(aFilename); |
382 lowerCaseFilename.LowerCase(); |
402 lowerCaseFilename.LowerCase(); |
383 |
403 |
384 OstTraceExt2( TRACE_NORMAL, DUP1_CFILEPLUGIN_CREATECONTENTINDEXITEML, "CFilePlugin::CreateContentIndexItemL;lowerCaseFilename=%S;aActionType=%d", lowerCaseFilename, aActionType ); |
404 OstTraceExt2( TRACE_NORMAL, DUP1_CFILEPLUGIN_CREATECONTENTINDEXITEML, "CFilePlugin::CreateContentIndexItemL;lowerCaseFilename=%S;aActionType=%d", lowerCaseFilename, aActionType ); |
385 CPIXLOGSTRING3("CFilePlugin::CreateFileIndexItemL lowerCaseFilename = %S aActionType = %d ", |
405 CPIXLOGSTRING3("CFilePlugin::CreateFileIndexItemL lowerCaseFilename = %S aActionType = %d ", |
392 |
412 |
393 if (!indexer) |
413 if (!indexer) |
394 { |
414 { |
395 OstTrace0( TRACE_NORMAL, DUP2_CFILEPLUGIN_CREATECONTENTINDEXITEML, "CFilePlugin::CreateFileIndexItemL(): Could not map file to drive." ); |
415 OstTrace0( TRACE_NORMAL, DUP2_CFILEPLUGIN_CREATECONTENTINDEXITEML, "CFilePlugin::CreateFileIndexItemL(): Could not map file to drive." ); |
396 CPIXLOGSTRING("CFilePlugin::CreateFileIndexItemL(): Could not map file to drive."); |
416 CPIXLOGSTRING("CFilePlugin::CreateFileIndexItemL(): Could not map file to drive."); |
|
417 OstTraceFunctionExit0( CFILEPLUGIN_CREATECONTENTINDEXITEML_EXIT ); |
397 return; |
418 return; |
398 } |
419 } |
399 |
420 OstTrace0( TRACE_NORMAL, DUP5_CFILEPLUGIN_CREATECONTENTINDEXITEML, "CFilePlugin::Indexing File content" ); |
|
421 |
400 // Index an empty item if removal action |
422 // Index an empty item if removal action |
401 if (aActionType == ECPixRemoveAction) |
423 if (aActionType == ECPixRemoveAction) |
402 { |
424 { |
403 #ifdef _DEBUG |
425 #ifdef _DEBUG |
404 TRAPD(err, indexer->DeleteL(lowerCaseFilename)); |
426 TRAPD(err, indexer->DeleteL(lowerCaseFilename)); |
434 TRAP_IGNORE( indexer->UpdateL(*index_item) ); |
456 TRAP_IGNORE( indexer->UpdateL(*index_item) ); |
435 #endif |
457 #endif |
436 } |
458 } |
437 CleanupStack::PopAndDestroy(index_item); |
459 CleanupStack::PopAndDestroy(index_item); |
438 } |
460 } |
|
461 OstTraceFunctionExit0( DUP1_CFILEPLUGIN_CREATECONTENTINDEXITEML_EXIT ); |
439 } |
462 } |
440 |
463 |
441 void CFilePlugin::CreateFolderFileIndexItemL(const TDesC& aFilename, TCPixActionType aActionType, TBool aIsDir) |
464 void CFilePlugin::CreateFolderFileIndexItemL(const TDesC& aFilename, TCPixActionType aActionType, TBool aIsDir) |
442 { |
465 { |
|
466 OstTraceFunctionEntry0( CFILEPLUGIN_CREATEFOLDERFILEINDEXITEML_ENTRY ); |
443 CSearchDocument* index_item = NULL; |
467 CSearchDocument* index_item = NULL; |
444 TBool isMediaFile = false; |
468 TBool isMediaFile = false; |
445 TFileName lowerCaseFilename(aFilename); |
469 TFileName lowerCaseFilename(aFilename); |
446 lowerCaseFilename.LowerCase(); |
470 lowerCaseFilename.LowerCase(); |
447 |
471 |
458 } |
482 } |
459 } |
483 } |
460 //Check for extension type, if media items do not index them |
484 //Check for extension type, if media items do not index them |
461 if(!isMediaFile) |
485 if(!isMediaFile) |
462 { |
486 { |
|
487 OstTrace0( TRACE_NORMAL, DUP5_CFILEPLUGIN_CREATEFOLDERFILEINDEXITEML, "CFilePlugin::Indexing File Folder" ); |
|
488 |
463 OstTraceExt2( TRACE_NORMAL, CFILEPLUGIN_CREATEFOLDERFILEINDEXITEML, "CFilePlugin::CreateFolderFileIndexItemL;lowerCaseFilename=%S;aActionType=%d", lowerCaseFilename, aActionType ); |
489 OstTraceExt2( TRACE_NORMAL, CFILEPLUGIN_CREATEFOLDERFILEINDEXITEML, "CFilePlugin::CreateFolderFileIndexItemL;lowerCaseFilename=%S;aActionType=%d", lowerCaseFilename, aActionType ); |
464 CPIXLOGSTRING3("CFilePlugin::CreateFolderFileIndexItemL lowerCaseFilename = %S aActionType = %d ", |
490 CPIXLOGSTRING3("CFilePlugin::CreateFolderFileIndexItemL lowerCaseFilename = %S aActionType = %d ", |
465 &lowerCaseFilename, aActionType); |
491 &lowerCaseFilename, aActionType); |
466 |
492 |
467 TDriveNumber drive(EDriveA); |
493 TDriveNumber drive(EDriveA); |
651 //Only content to be added to exceprt field. See appclass-hierarchy.txt |
680 //Only content to be added to exceprt field. See appclass-hierarchy.txt |
652 //Add excerpt field |
681 //Add excerpt field |
653 index_item->AddExcerptL(aFilePath); |
682 index_item->AddExcerptL(aFilePath); |
654 |
683 |
655 CleanupStack::Pop(index_item); |
684 CleanupStack::Pop(index_item); |
|
685 OstTraceFunctionExit0( CFILEPLUGIN_CREATECPIXDOCUMENTL_EXIT ); |
656 return index_item; |
686 return index_item; |
|
687 } |
|
688 |
|
689 void CFilePlugin::RemoveFileDatabaseL(TDriveNumber aDrive) |
|
690 { |
|
691 RFs aFs; |
|
692 User::LeaveIfError( aFs.Connect() ); |
|
693 TChar drive; |
|
694 TInt err = aFs.DriveToChar((TDriveNumber)aDrive,drive); |
|
695 if ( err == KErrNone ) |
|
696 { |
|
697 TBuf<KMaxFileName> folderpath; |
|
698 folderpath.Append(drive); |
|
699 folderpath.Append(KFilePluginColon); |
|
700 folderpath.Append(KCPixSearchServerPrivateDirectory); |
|
701 folderpath.Append(KIndexingDBPath); |
|
702 folderpath.Append(KfileDBPath); |
|
703 CFileMan* FileMan = CFileMan::NewL(aFs); |
|
704 if ( FileMan ) |
|
705 FileMan->Delete( folderpath ); |
|
706 delete FileMan; |
|
707 } |
|
708 aFs.Close(); |
|
709 } |
|
710 |
|
711 void CFilePlugin::PausePluginL() |
|
712 { |
|
713 OstTraceFunctionEntry0( CFILEPLUGIN_PAUSEPLUGINL_ENTRY ); |
|
714 iIndexState = EFalse; |
|
715 //iHarvester->SetHarvesterState(iIndexState); |
|
716 OstTraceFunctionExit0( CFILEPLUGIN_PAUSEPLUGINL_EXIT ); |
|
717 } |
|
718 |
|
719 void CFilePlugin::ResumePluginL() |
|
720 { |
|
721 OstTraceFunctionEntry0( CFILEPLUGIN_RESUMEPLUGINL_ENTRY ); |
|
722 iIndexState = ETrue; |
|
723 IndexQueuedItems(); |
|
724 iHarvester->ResumeRequest(); |
|
725 MountAvailableDrivesInQueue(); |
|
726 //iHarvester->SetHarvesterState(iIndexState); |
|
727 OstTraceFunctionExit0( CFILEPLUGIN_RESUMEPLUGINL_EXIT ); |
|
728 } |
|
729 |
|
730 void CFilePlugin::MountAvailableDrivesInQueue() |
|
731 { |
|
732 OstTraceFunctionEntry0( CFILEPLUGIN_MOUNTAVAILABLEDRIVESINQUEUE_ENTRY ); |
|
733 for(TInt i=0;i<iMountDrives.Count();i++) |
|
734 { |
|
735 TDriveNumber drive = iMountDrives[i]; |
|
736 iMountDrives.Remove(i); |
|
737 iHarvester->StartL(drive); |
|
738 } |
|
739 OstTraceFunctionExit0( CFILEPLUGIN_MOUNTAVAILABLEDRIVESINQUEUE_EXIT ); |
|
740 } |
|
741 |
|
742 TBool CFilePlugin::GetHarvesterState() |
|
743 { |
|
744 return iIndexState; |
|
745 } |
|
746 |
|
747 void CFilePlugin::AddToQueueL(const TDesC& aFilename, TCPixActionType aActionType, TBool aIsFolder) |
|
748 { |
|
749 OstTraceFunctionEntry0( CFILEPLUGIN_ADDTOQUEUEL_ENTRY ); |
|
750 TRecord entry; |
|
751 entry.isFolder = aIsFolder; |
|
752 entry.iUri.Copy(aFilename); |
|
753 entry.iActionType = aActionType; |
|
754 iJobQueue.AppendL(entry); |
|
755 OstTraceFunctionExit0( CFILEPLUGIN_ADDTOQUEUEL_EXIT ); |
|
756 } |
|
757 |
|
758 void CFilePlugin::IndexQueuedItems() |
|
759 { |
|
760 OstTraceFunctionEntry0( CFILEPLUGIN_INDEXQUEUEDITEMS_ENTRY ); |
|
761 while (iJobQueue.Count()>0 && GetHarvesterState()) |
|
762 { |
|
763 TRecord entry = iJobQueue[0]; |
|
764 //Let the indexer handle this object TRAP it as it can leave |
|
765 if(entry.isFolder) |
|
766 CreateFolderFileIndexItemL( entry.iUri, entry.iActionType ); |
|
767 else |
|
768 { |
|
769 CreateContentIndexItemL( entry.iUri, entry.iActionType ); |
|
770 CreateFolderFileIndexItemL( entry.iUri, entry.iActionType, entry.isFolder ); |
|
771 } |
|
772 iJobQueue.Remove(0); |
|
773 } |
|
774 OstTraceFunctionExit0( CFILEPLUGIN_INDEXQUEUEDITEMS_EXIT ); |
657 } |
775 } |
658 |
776 |
659 #ifdef __PERFORMANCE_DATA |
777 #ifdef __PERFORMANCE_DATA |
660 void CFilePlugin::UpdatePerformaceDataL(TDriveNumber aDriveNumber) |
778 void CFilePlugin::UpdatePerformaceDataL(TDriveNumber aDriveNumber) |
661 { |
779 { |