19 #include <s32file.h> |
19 #include <s32file.h> |
20 #include <centralrepository.h> |
20 #include <centralrepository.h> |
21 #include "CIndexingManager.h" |
21 #include "CIndexingManager.h" |
22 #include "HarvesterServerLogger.h" |
22 #include "HarvesterServerLogger.h" |
23 #include "CBlacklistMgr.h" |
23 #include "CBlacklistMgr.h" |
24 #include "contentinfomgr.h" |
24 #include "contentinfodbupdate.h" |
25 #include "ccontentinfo.h" |
|
26 #include "OstTraceDefinitions.h" |
25 #include "OstTraceDefinitions.h" |
27 #ifdef OST_TRACE_COMPILER_IN_USE |
26 #ifdef OST_TRACE_COMPILER_IN_USE |
28 #include "cindexingmanagerTraces.h" |
27 #include "cindexingmanagerTraces.h" |
29 #endif |
28 #endif |
30 |
29 |
34 |
33 |
35 // How often harvester states are checked (in minutes) |
34 // How often harvester states are checked (in minutes) |
36 const TUint KDefaultWaitTimeInMinutes = 1; |
35 const TUint KDefaultWaitTimeInMinutes = 1; |
37 |
36 |
38 // How often harvester states are checked (in microseconds) |
37 // How often harvester states are checked (in microseconds) |
39 const TUint KDefaultWaitTime = KDefaultWaitTimeInMinutes*60*1000000; // 1 minute |
38 //const TUint KDefaultWaitTime = KDefaultWaitTimeInMinutes*60*1000000; // 1 minute |
40 |
39 |
41 // If time difference between RunL calls is less than this value (i.e system time |
40 // If time difference between RunL calls is less than this value (i.e system time |
42 // changed to past) update harvesters start and complete times. |
41 // changed to past) update harvesters start and complete times. |
43 const TInt KMinTimeDifference = 0; |
42 const TInt KMinTimeDifference = 0; |
44 |
43 |
136 // This server must be connected before passing to harvester plugins |
139 // This server must be connected before passing to harvester plugins |
137 User::LeaveIfError(iSearchSession.Connect()); |
140 User::LeaveIfError(iSearchSession.Connect()); |
138 |
141 |
139 //instantiate blacklist database |
142 //instantiate blacklist database |
140 iBlacklistMgr = CBlacklistMgr::NewL(); |
143 iBlacklistMgr = CBlacklistMgr::NewL(); |
141 //Instantiate Contentinfo manager |
144 |
142 iContentInfoMgr = CContentInfoMgr::NewL(); |
145 //Instantiate ContentInfoDbUpdate |
|
146 iContentInfodb = new ContentInfoDbUpdate(); |
143 |
147 |
144 UpdateDontloadListL(); |
148 UpdateDontloadListL(); |
145 |
149 |
146 // Load plugins |
150 // Load plugins |
147 LoadPluginsL(); |
151 LoadPluginsL(); |
148 |
152 |
149 //release the Blacklist manager as the blacklist functionality is done |
153 //release the Blacklist manager as the blacklist functionality is done |
150 delete iBlacklistMgr; |
154 delete iBlacklistMgr; |
151 //release the content info manager as all the content details of all plugins are stored |
155 //release the content info manager as all the content details of all plugins are stored |
152 delete iContentInfoMgr; |
156 delete iContentInfodb; |
153 |
157 //Start the activity manager to monitor the user activity status |
|
158 iActivityManager = CActivityManager::NewL( this ); |
|
159 if(iActivityManager) |
|
160 { |
|
161 iActivityManager->Start(); |
|
162 } |
|
163 iGaurdTimer = CGaurdTimer::NewL( this ); |
154 StartPlugins(); |
164 StartPlugins(); |
155 |
165 |
156 // Wait before running RunL |
166 // Wait before running RunL |
157 iState = EStateRunning; |
167 iState = EStateRunning; |
158 iTimer.After(iStatus, 10000000); // 10s |
168 iTimer.After(iStatus, 10000000); // 10s |
317 |
327 |
318 CIndexingPlugin::ListImplementationsL( infoArray ); |
328 CIndexingPlugin::ListImplementationsL( infoArray ); |
319 TInt count( 0 ); |
329 TInt count( 0 ); |
320 count = infoArray.Count(); |
330 count = infoArray.Count(); |
321 |
331 |
322 TInt contentcount(iContentInfoMgr->GetContentCountL() ); |
332 CImplementationInformation *info = NULL; |
323 // If the content count in the content info DB is not equal to the plugin count, reset the content info DB |
333 for(TInt i = 0; i < count; i++ ) |
324 if ( contentcount != count) |
334 { |
325 iContentInfoMgr->ResetL(); |
335 TUid uid = infoArray[i]->ImplementationUid(); |
326 |
336 if( uid.iUid == 0x2001F703) // files |
327 CContentInfo* contentinfo = CContentInfo::NewL(); |
337 { |
328 |
338 info = infoArray[i]; |
|
339 infoArray.Remove(i); |
|
340 break; |
|
341 } |
|
342 } |
|
343 // Now add file plugin at the end of the list |
|
344 infoArray.AppendL(info); |
329 for ( TInt i = 0; i < count; i++ ) |
345 for ( TInt i = 0; i < count; i++ ) |
330 { |
346 { |
331 TUid uid = infoArray[i]->ImplementationUid(); // Create the plug-ins |
347 TUid uid = infoArray[i]->ImplementationUid(); // Create the plug-ins |
332 TInt version = infoArray[i]->Version(); |
348 TInt version = infoArray[i]->Version(); |
|
349 |
333 //Update the details of the plugin in Contentinfo DB |
350 //Update the details of the plugin in Contentinfo DB |
334 UpdateContentInfoDbL( infoArray[i]->DisplayName(), contentinfo ); |
351 TBuf<255> filepath; |
|
352 filepath.Copy(infoArray[i]->OpaqueData()); |
|
353 UpdateContentInfoDbL(filepath); |
|
354 |
335 //Get the load status of the plugin. |
355 //Get the load status of the plugin. |
336 TBool pluginloadstatus = GetPluginLoadStatusL ( uid, version, infoArray[i]->DisplayName() ); |
356 TBool pluginloadstatus = GetPluginLoadStatusL ( uid, version, infoArray[i]->DisplayName() ); |
337 |
357 |
338 if ( pluginloadstatus ) |
358 if ( pluginloadstatus ) |
339 { |
359 { |
340 LoadHarvesterpluginL (uid, version, infoArray[i]->DisplayName() );//Load the harvester plugin |
360 LoadHarvesterpluginL (uid, version, infoArray[i]->DisplayName() );//Load the harvester plugin |
341 } |
361 } |
342 } |
362 } |
343 delete contentinfo; |
|
344 CleanupStack::PopAndDestroy( &infoArray ); // infoArray, results in a call to CleanupEComArray |
363 CleanupStack::PopAndDestroy( &infoArray ); // infoArray, results in a call to CleanupEComArray |
345 OstTraceFunctionExit0( CINDEXINGMANAGER_LOADPLUGINSL_EXIT ); |
364 OstTraceFunctionExit0( CINDEXINGMANAGER_LOADPLUGINSL_EXIT ); |
346 } |
365 } |
347 |
366 |
348 // ----------------------------------------------------------------------------- |
367 // ----------------------------------------------------------------------------- |
588 |
607 |
589 // ----------------------------------------------------------------------------- |
608 // ----------------------------------------------------------------------------- |
590 // CIndexingManager::UpdateContentInfoDbL() |
609 // CIndexingManager::UpdateContentInfoDbL() |
591 // ----------------------------------------------------------------------------- |
610 // ----------------------------------------------------------------------------- |
592 // |
611 // |
593 void CIndexingManager::UpdateContentInfoDbL( const TDesC& aPluginName, CContentInfo* aContentinfo) |
612 void CIndexingManager::UpdateContentInfoDbL( const TDesC& aXmlPath) |
594 { |
613 { |
595 OstTraceFunctionEntry0( CINDEXINGMANAGER_UPDATECONTENTINFODBL_ENTRY ); |
614 OstTraceFunctionEntry0( CINDEXINGMANAGER_UPDATECONTENTINFODBL_ENTRY ); |
596 TBool iscontentfound = iContentInfoMgr->FindL( aPluginName ); |
615 |
597 |
616 if(iContentInfodb) |
598 if( !iscontentfound ) |
617 iContentInfodb->UpdateDb(QString::fromUtf16(aXmlPath.Ptr(),aXmlPath.Length())); |
599 { |
618 |
600 //Add the content details to database |
|
601 aContentinfo->SetNameL( aPluginName ); |
|
602 aContentinfo->SetBlacklistStatus( KEnable ); |
|
603 aContentinfo->SetIndexStatus( KEnable ); |
|
604 iContentInfoMgr->AddL( aContentinfo ); |
|
605 |
|
606 } |
|
607 else |
|
608 { |
|
609 iContentInfoMgr->UpdateBlacklistStatusL( aPluginName , KEnable ); |
|
610 } |
|
611 OstTraceFunctionExit0( CINDEXINGMANAGER_UPDATECONTENTINFODBL_EXIT ); |
619 OstTraceFunctionExit0( CINDEXINGMANAGER_UPDATECONTENTINFODBL_EXIT ); |
612 } |
620 } |
613 |
621 |
614 // ----------------------------------------------------------------------------- |
622 // ----------------------------------------------------------------------------- |
615 // CIndexingManager::UpdateDontloadListL() |
623 // CIndexingManager::UpdateDontloadListL() |
667 // loadplugin = EFalse; |
675 // loadplugin = EFalse; |
668 |
676 |
669 if ( loadstatus ) |
677 if ( loadstatus ) |
670 { |
678 { |
671 //Found in unload list.Update the indexing and blacklist status in contentinfo DB |
679 //Found in unload list.Update the indexing and blacklist status in contentinfo DB |
672 iContentInfoMgr->UpdatePluginIndexStatusL( aPluginName , KDisable ); |
680 iContentInfodb->UpdateIndexStatus( QString::fromUtf16(aPluginName.Ptr(), aPluginName.Length()) , KDisable ); |
673 iContentInfoMgr->UpdateBlacklistStatusL( aPluginName , KDisable ); |
681 iContentInfodb->UpdateBlacklisted( QString::fromUtf16(aPluginName.Ptr(), aPluginName.Length()), KDisable ); |
674 } |
682 } |
675 if ( pluginblacklisted ) |
683 if ( pluginblacklisted ) |
676 //Update the blacklist status in content info db |
684 //Update the blacklist status in content info db |
677 iContentInfoMgr->UpdateBlacklistStatusL( aPluginName , KEnable ); |
685 iContentInfodb->UpdateBlacklisted( QString::fromUtf16(aPluginName.Ptr(), aPluginName.Length()), KEnable ); |
678 |
686 |
679 return (! (loadstatus | pluginblacklisted)); |
687 return (! (loadstatus | pluginblacklisted)); |
680 } |
688 } |
681 |
689 |
682 // ----------------------------------------------------------------------------- |
690 // ----------------------------------------------------------------------------- |
683 // CIndexingManager::GetPluginLoadStatus() |
691 // CIndexingManager::LoadHarvesterpluginL() |
684 // ----------------------------------------------------------------------------- |
692 // ----------------------------------------------------------------------------- |
685 // |
693 // |
686 void CIndexingManager::LoadHarvesterpluginL (TUid aPluginUid, TInt aVersion, const TDesC& aPluginName) |
694 void CIndexingManager::LoadHarvesterpluginL (TUid aPluginUid, TInt aVersion, const TDesC& aPluginName) |
687 { |
695 { |
688 OstTraceFunctionEntry0( CINDEXINGMANAGER_LOADHARVESTERPLUGINL_ENTRY ); |
696 OstTraceFunctionEntry0( CINDEXINGMANAGER_LOADHARVESTERPLUGINL_ENTRY ); |
697 { |
705 { |
698 // Plugin loaded succesfully. Remove it from the blacklist database |
706 // Plugin loaded succesfully. Remove it from the blacklist database |
699 iBlacklistMgr->Remove(aPluginUid); |
707 iBlacklistMgr->Remove(aPluginUid); |
700 OstTrace1( TRACE_NORMAL, CINDEXINGMANAGER_LOADHARVESTERPLUGINL, "CIndexingManager::LoadPluginsL;Plugin with uid=%x is removed from DB", aPluginUid.iUid ); |
708 OstTrace1( TRACE_NORMAL, CINDEXINGMANAGER_LOADHARVESTERPLUGINL, "CIndexingManager::LoadPluginsL;Plugin with uid=%x is removed from DB", aPluginUid.iUid ); |
701 CPIXLOGSTRING2("CIndexingManager::LoadHarvesterpluginL(): Plugin with uid = %x is removed from database", aPluginUid.iUid); |
709 CPIXLOGSTRING2("CIndexingManager::LoadHarvesterpluginL(): Plugin with uid = %x is removed from database", aPluginUid.iUid); |
702 iContentInfoMgr->UpdateBlacklistStatusL( aPluginName , KDisable ); |
710 iContentInfodb->UpdateBlacklisted( QString::fromUtf16(aPluginName.Ptr(), aPluginName.Length()) , KDisable );// new implementation |
703 CleanupStack::PushL( plugin ); |
711 CleanupStack::PushL( plugin ); |
704 plugin->SetObserver( *this ); |
712 plugin->SetObserver( *this ); |
705 plugin->SetSearchSession( iSearchSession ); |
713 plugin->SetSearchSession( iSearchSession ); |
706 iPluginArray.AppendL( plugin ); // and add them to array |
714 iPluginArray.AppendL( plugin ); // and add them to array |
707 CleanupStack::Pop( plugin ); |
715 CleanupStack::Pop( plugin ); |
708 OstTrace1( TRACE_NORMAL, DUP2_CINDEXINGMANAGER_LOADHARVESTERPLUGINL, "CIndexingManager::LoadPluginsL;Plugin with uid=%x is loaded successfully", aPluginUid.iUid ); |
716 OstTrace1( TRACE_NORMAL, DUP2_CINDEXINGMANAGER_LOADHARVESTERPLUGINL, "CIndexingManager::LoadPluginsL;Plugin with uid=%x is loaded successfully", aPluginUid.iUid ); |
709 CPIXLOGSTRING2("CIndexingManager::LoadHarvesterpluginL(): Plugin with uid = %x is loaded succesfully", aPluginUid.iUid); |
717 CPIXLOGSTRING2("CIndexingManager::LoadHarvesterpluginL(): Plugin with uid = %x is loaded succesfully", aPluginUid.iUid); |
710 } |
718 } |
711 OstTraceFunctionExit0( CINDEXINGMANAGER_LOADHARVESTERPLUGINL_EXIT ); |
719 OstTraceFunctionExit0( CINDEXINGMANAGER_LOADHARVESTERPLUGINL_EXIT ); |
712 } |
720 } |
|
721 |
|
722 // ----------------------------------------------------------------------------- |
|
723 // CIndexingManager::ActivityChanged() |
|
724 // ----------------------------------------------------------------------------- |
|
725 // |
|
726 void CIndexingManager::ActivityChanged(const TBool aActive) |
|
727 { |
|
728 //User is Inactive,so continue with harvesting |
|
729 if(aActive) |
|
730 { |
|
731 if( iGaurdTimer->IsActive()) |
|
732 iGaurdTimer->Cancel(); |
|
733 |
|
734 for (TInt i = 0; i < iPluginArray.Count(); i++) |
|
735 { |
|
736 iPluginArray[i]->ResumePluginL(); |
|
737 OstTrace0( TRACE_NORMAL, CINDEXINGMANAGER_ACTIVITYCHANGED, "CIndexingManager::ResumePluginsL" ); |
|
738 |
|
739 } |
|
740 } |
|
741 else |
|
742 { |
|
743 //call pause on all the plugins and restart the gaurd timer |
|
744 for (TInt i = 0; i < iPluginArray.Count(); i++) |
|
745 { |
|
746 iPluginArray[i]->PausePluginL(); |
|
747 OstTrace0( TRACE_NORMAL, DUP1_CINDEXINGMANAGER_ACTIVITYCHANGED, "CIndexingManager::PausePluginsL" ); |
|
748 |
|
749 } |
|
750 iGaurdTimer->StartgaurdTimer(); |
|
751 } |
|
752 |
|
753 } |
|
754 |
|
755 // ----------------------------------------------------------------------------- |
|
756 // CIndexingManager::HandleGaurdTimerL() |
|
757 // ----------------------------------------------------------------------------- |
|
758 // |
|
759 void CIndexingManager::HandleGaurdTimerL() |
|
760 { |
|
761 OstTraceFunctionEntry0( CINDEXINGMANAGER_HANDLEGAURDTIMERL_ENTRY ); |
|
762 //On gaurd timer expiry, check for the current useractive state, |
|
763 //and update the status accordingly |
|
764 TBool isActive = iActivityManager->IsActive(); |
|
765 if ( isActive ) |
|
766 { |
|
767 for (TInt i = 0; i < iPluginArray.Count(); i++) |
|
768 { |
|
769 TRAPD(err, iPluginArray[i]->ResumePluginL()); |
|
770 OstTrace0( TRACE_NORMAL, CINDEXINGMANAGER_HANDLEGAURDTIMERL, "CIndexingManager::ResumePluginsL" ); |
|
771 |
|
772 if (err != KErrNone) |
|
773 { |
|
774 // Failed to start the plugin |
|
775 } |
|
776 } |
|
777 } |
|
778 else |
|
779 { |
|
780 // Start timer |
|
781 iGaurdTimer->StartgaurdTimer(); |
|
782 } |
|
783 OstTraceFunctionExit0( CINDEXINGMANAGER_HANDLEGAURDTIMERL_EXIT ); |
|
784 } |