70 // CIndexingManager::CIndexingManager() |
70 // CIndexingManager::CIndexingManager() |
71 // ----------------------------------------------------------------------------- |
71 // ----------------------------------------------------------------------------- |
72 // |
72 // |
73 CIndexingManager::CIndexingManager() |
73 CIndexingManager::CIndexingManager() |
74 : CActive(CActive::EPriorityStandard), |
74 : CActive(CActive::EPriorityStandard), |
75 iState(EStateNone), iPreviousRun(0) |
75 iState(EStateNone), iPreviousRun(0), |
|
76 iHarvestState(EFalse) |
76 { |
77 { |
77 CActiveScheduler::Add(this); |
78 CActiveScheduler::Add(this); |
78 } |
79 } |
79 |
80 |
80 // ----------------------------------------------------------------------------- |
81 // ----------------------------------------------------------------------------- |
100 // Close search server connection |
101 // Close search server connection |
101 iSearchSession.Close(); |
102 iSearchSession.Close(); |
102 |
103 |
103 // Close file system connection |
104 // Close file system connection |
104 iFs.Close(); |
105 iFs.Close(); |
105 |
106 if(iBlacklistMgr) |
106 delete iBlacklistMgr; |
107 { |
107 |
108 delete iBlacklistMgr; |
108 delete iContentInfodb; |
109 iBlacklistMgr = NULL; |
109 |
110 } |
|
111 if(iContentInfodb) |
|
112 { |
|
113 delete iContentInfodb; |
|
114 iContentInfodb = NULL; |
|
115 } |
110 delete iActivityManager; |
116 delete iActivityManager; |
111 |
117 delete iStateObserver; |
112 delete iGaurdTimer; |
118 delete iGaurdTimer; |
113 } |
119 } |
114 |
120 |
115 // ----------------------------------------------------------------------------- |
121 // ----------------------------------------------------------------------------- |
116 // CIndexingManager::ConstructL() |
122 // CIndexingManager::ConstructL() |
150 // Load plugins |
156 // Load plugins |
151 LoadPluginsL(); |
157 LoadPluginsL(); |
152 |
158 |
153 //release the Blacklist manager as the blacklist functionality is done |
159 //release the Blacklist manager as the blacklist functionality is done |
154 delete iBlacklistMgr; |
160 delete iBlacklistMgr; |
|
161 iBlacklistMgr = NULL; |
155 //release the content info manager as all the content details of all plugins are stored |
162 //release the content info manager as all the content details of all plugins are stored |
156 delete iContentInfodb; |
163 delete iContentInfodb; |
|
164 iContentInfodb = NULL; |
|
165 |
157 //Start the activity manager to monitor the user activity status |
166 //Start the activity manager to monitor the user activity status |
158 iActivityManager = CActivityManager::NewL( this ); |
167 iActivityManager = CActivityManager::NewL( this ); |
159 if(iActivityManager) |
168 if(iActivityManager) |
160 { |
169 { |
161 iActivityManager->Start(); |
170 iActivityManager->Start(); |
162 } |
171 } |
163 iGaurdTimer = CGaurdTimer::NewL( this ); |
172 iGaurdTimer = CGaurdTimer::NewL( this ); |
|
173 iStateObserver = CPiXStateObserver::NewL(this, &iFs); |
|
174 if(iStateObserver) |
|
175 { |
|
176 //iStateObserver->StartMonitoringL(); |
|
177 } |
164 StartPlugins(); |
178 StartPlugins(); |
165 |
179 |
166 // Wait before running RunL |
180 // Wait before running RunL |
167 iState = EStateRunning; |
181 iState = EStateRunning; |
168 iTimer.After(iStatus, 10000000); // 10s |
182 iTimer.After(iStatus, 10000000); // 10s |
717 CPIXLOGSTRING2("CIndexingManager::LoadHarvesterpluginL(): Plugin with uid = %x is loaded succesfully", aPluginUid.iUid); |
731 CPIXLOGSTRING2("CIndexingManager::LoadHarvesterpluginL(): Plugin with uid = %x is loaded succesfully", aPluginUid.iUid); |
718 } |
732 } |
719 OstTraceFunctionExit0( CINDEXINGMANAGER_LOADHARVESTERPLUGINL_EXIT ); |
733 OstTraceFunctionExit0( CINDEXINGMANAGER_LOADHARVESTERPLUGINL_EXIT ); |
720 } |
734 } |
721 |
735 |
722 // ----------------------------------------------------------------------------- |
736 void CIndexingManager::PausePluginsL() |
723 // CIndexingManager::ActivityChanged() |
|
724 // ----------------------------------------------------------------------------- |
|
725 // |
|
726 void CIndexingManager::ActivityChanged(const TBool aActive) |
|
727 { |
737 { |
728 //User is Inactive,so continue with harvesting |
738 if(!iGaurdTimer->IsActive()) |
729 if(aActive) |
739 iGaurdTimer->StartgaurdTimer(); |
730 { |
740 |
|
741 for (TInt i = 0; i < iPluginArray.Count(); i++) |
|
742 { |
|
743 iPluginArray[i]->PausePluginL(); |
|
744 OstTrace0( TRACE_NORMAL, DUP1_CINDEXINGMANAGER_ACTIVITYCHANGED, "CIndexingManager::PausePluginsL" ); |
|
745 |
|
746 } |
|
747 } |
|
748 |
|
749 void CIndexingManager::ResumePluginsL() |
|
750 { |
|
751 if( !iHarvestState ) |
|
752 { |
731 if( iGaurdTimer->IsActive()) |
753 if( iGaurdTimer->IsActive()) |
732 iGaurdTimer->Cancel(); |
754 iGaurdTimer->Cancel(); |
733 |
755 |
734 for (TInt i = 0; i < iPluginArray.Count(); i++) |
756 for (TInt i = 0; i < iPluginArray.Count(); i++) |
735 { |
757 { |
736 iPluginArray[i]->ResumePluginL(); |
758 iPluginArray[i]->ResumePluginL(); |
737 OstTrace0( TRACE_NORMAL, CINDEXINGMANAGER_ACTIVITYCHANGED, "CIndexingManager::ResumePluginsL" ); |
759 OstTrace0( TRACE_NORMAL, CINDEXINGMANAGER_ACTIVITYCHANGED, "CIndexingManager::ResumePluginsL" ); |
738 |
760 |
739 } |
761 } |
740 } |
762 } |
|
763 } |
|
764 // ----------------------------------------------------------------------------- |
|
765 // CIndexingManager::ActivityChanged() |
|
766 // ----------------------------------------------------------------------------- |
|
767 // |
|
768 void CIndexingManager::ActivityChangedL(const TBool aActive) |
|
769 { |
|
770 //User is Inactive,so continue with harvesting |
|
771 if(aActive) |
|
772 { |
|
773 ResumePluginsL(); |
|
774 } |
741 else |
775 else |
742 { |
776 { |
743 //call pause on all the plugins and restart the gaurd timer |
777 //call pause on all the plugins and restart the gaurd timer |
744 for (TInt i = 0; i < iPluginArray.Count(); i++) |
778 PausePluginsL(); |
745 { |
|
746 iPluginArray[i]->PausePluginL(); |
|
747 OstTrace0( TRACE_NORMAL, DUP1_CINDEXINGMANAGER_ACTIVITYCHANGED, "CIndexingManager::PausePluginsL" ); |
|
748 |
|
749 } |
|
750 iGaurdTimer->StartgaurdTimer(); |
|
751 } |
779 } |
752 |
780 |
753 } |
781 } |
754 |
782 |
|
783 void CIndexingManager::HandleStateObserverChangeL(const TBool aActive) |
|
784 { |
|
785 if (aActive) |
|
786 { |
|
787 iHarvestState = ETrue; |
|
788 PausePluginsL(); |
|
789 } |
|
790 else |
|
791 { |
|
792 iHarvestState = EFalse; |
|
793 ResumePluginsL(); |
|
794 } |
|
795 } |
|
796 |
755 // ----------------------------------------------------------------------------- |
797 // ----------------------------------------------------------------------------- |
756 // CIndexingManager::HandleGaurdTimerL() |
798 // CIndexingManager::HandleGaurdTimerL() |
757 // ----------------------------------------------------------------------------- |
799 // ----------------------------------------------------------------------------- |
758 // |
800 // |
759 void CIndexingManager::HandleGaurdTimerL() |
801 void CIndexingManager::HandleGaurdTimerL() |
760 { |
802 { |
761 OstTraceFunctionEntry0( CINDEXINGMANAGER_HANDLEGAURDTIMERL_ENTRY ); |
803 OstTraceFunctionEntry0( CINDEXINGMANAGER_HANDLEGAURDTIMERL_ENTRY ); |
762 //On gaurd timer expiry, check for the current useractive state, |
804 //On gaurd timer expiry, Call save on all plugins to store |
763 //and update the status accordingly |
805 //data to temporary file |
764 TBool isActive = iActivityManager->IsActive(); |
806 |
765 if ( isActive ) |
807 // Start timer |
766 { |
808 for(TInt i = 0; i < iPluginArray.Count(); i++) |
767 for (TInt i = 0; i < iPluginArray.Count(); i++) |
809 { |
768 { |
810 iPluginArray[i]->SaveL(); |
769 TRAPD(err, iPluginArray[i]->ResumePluginL()); |
811 } |
770 OstTrace0( TRACE_NORMAL, CINDEXINGMANAGER_HANDLEGAURDTIMERL, "CIndexingManager::ResumePluginsL" ); |
812 |
771 |
813 if(!iGaurdTimer->IsActive()) |
772 if (err != KErrNone) |
|
773 { |
|
774 // Failed to start the plugin |
|
775 } |
|
776 } |
|
777 } |
|
778 else |
|
779 { |
|
780 // Start timer |
|
781 iGaurdTimer->StartgaurdTimer(); |
814 iGaurdTimer->StartgaurdTimer(); |
782 } |
815 |
783 OstTraceFunctionExit0( CINDEXINGMANAGER_HANDLEGAURDTIMERL_EXIT ); |
816 OstTraceFunctionExit0( CINDEXINGMANAGER_HANDLEGAURDTIMERL_EXIT ); |
784 } |
817 } |