|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CINDEXINGMANAGER_H |
|
19 #define CINDEXINGMANAGER_H |
|
20 |
|
21 #include <CIndexingPlugin.h> |
|
22 #include <MIndexingPluginObserver.h> |
|
23 #include <RSearchServerSession.h> |
|
24 |
|
25 const TInt KFilePluginBaseAppClassMaxLen = 64; |
|
26 //Forward Declaration |
|
27 class CBlacklistMgr; |
|
28 |
|
29 class CIndexingManager : public CActive, public MIndexingService |
|
30 { |
|
31 public: |
|
32 static CIndexingManager* NewL(); |
|
33 virtual ~CIndexingManager(); |
|
34 |
|
35 protected: |
|
36 /* |
|
37 * From CActive |
|
38 */ |
|
39 void DoCancel(); |
|
40 void RunL(); |
|
41 |
|
42 protected: |
|
43 /** |
|
44 * derived from MIndexingService |
|
45 * A callback from CIndexingPlugin, called when it wants to schedule a harvesting event |
|
46 * |
|
47 * @param aQualifiedBaseAppClass database to harvest |
|
48 * @param aMedia the media to be harvested |
|
49 * @param aForceReharvest force the aQualifiedBaseAppClass to be re-harvested. |
|
50 */ |
|
51 void AddHarvestingQueue(CIndexingPlugin* aPlugin, const TDesC& aQualifiedBaseAppClass, TBool aForceReharvest = EFalse); |
|
52 |
|
53 /** |
|
54 * |
|
55 * derived from MIndexingService |
|
56 * A callback from CIndexingPlugin, called when it wants to unschedule a harvesting event |
|
57 * |
|
58 * @param aQualifiedBaseAppClass database to harvest |
|
59 * @param aMedia the media to be harvested |
|
60 */ |
|
61 void RemoveHarvestingQueue(CIndexingPlugin* aPlugin, const TDesC& aQualifiedBaseAppClass); |
|
62 |
|
63 /** |
|
64 * derived from MIndexingService |
|
65 * A callback from CIndexingPlugin, called when it has ended harvesting |
|
66 * |
|
67 * @param aPlugin the plugin object that calls this function |
|
68 * @param aQualifiedBaseAppClass database to harvest |
|
69 * @param aError KErrNone if harvesting completed successfully otherwise systemwide errorcodes |
|
70 */ |
|
71 void HarvestingCompleted(CIndexingPlugin* aPlugin, const TDesC& aQualifiedBaseAppClass, TInt aError); |
|
72 |
|
73 private: |
|
74 |
|
75 /** |
|
76 * LoadPluginsL loads all plugins |
|
77 */ |
|
78 void LoadPluginsL(); |
|
79 |
|
80 /** |
|
81 * StartPlugins starts all loaded plugins |
|
82 */ |
|
83 void StartPlugins(); |
|
84 |
|
85 /** |
|
86 * Loading the state of the Plugins |
|
87 */ |
|
88 TInt Internalize(); |
|
89 /** |
|
90 * saving the state of the Plugins |
|
91 */ |
|
92 TInt Externalize(); |
|
93 /** |
|
94 * Loading the state of the Plugins |
|
95 */ |
|
96 void LoadL(); |
|
97 /** |
|
98 * saving the state of the Plugins |
|
99 */ |
|
100 void SaveL(); |
|
101 |
|
102 private: |
|
103 CIndexingManager(); |
|
104 void ConstructL(); |
|
105 |
|
106 private: |
|
107 enum THarvesterStatus |
|
108 { |
|
109 EHarvesterStatusWaiting = 0, // A Plugin has requested this item to be harvested |
|
110 EHarvesterStatusHibernate, // A plugin has requested for this item not to be harvested |
|
111 EHarvesterStatusRunning // This item is being harvested |
|
112 }; |
|
113 |
|
114 /* |
|
115 * Class to hold the details of a harvester plugin |
|
116 */ |
|
117 class THarvesterRecord |
|
118 { |
|
119 public: |
|
120 /* |
|
121 * Default constructor |
|
122 */ |
|
123 THarvesterRecord() |
|
124 { |
|
125 iPlugin = NULL; |
|
126 iError = KErrNone; |
|
127 iStatus = EHarvesterStatusHibernate; |
|
128 iLastStart = TTime(0); |
|
129 iLastComplete = TTime(0); |
|
130 } |
|
131 THarvesterRecord(CIndexingPlugin* aPlugin, const TDesC& aQualifiedBaseAppClass) |
|
132 { |
|
133 iPlugin = aPlugin; |
|
134 iQualifiedBaseAppClass = aQualifiedBaseAppClass; |
|
135 iError = KErrNone; |
|
136 iStatus = EHarvesterStatusWaiting; |
|
137 iLastStart = TTime(0); // Never started |
|
138 iLastComplete = TTime(0); // Never complete |
|
139 } |
|
140 public: |
|
141 /* |
|
142 * Pointer to hold a harvester plugin |
|
143 */ |
|
144 CIndexingPlugin* iPlugin; |
|
145 /* |
|
146 * Variable to hold the error code of plugin harvesting process |
|
147 */ |
|
148 TInt iError; |
|
149 /* |
|
150 * status[waiting/hibernate/running] a harvester plugin |
|
151 */ |
|
152 THarvesterStatus iStatus; |
|
153 /* |
|
154 * Time before starting the harvesting of a plugin |
|
155 */ |
|
156 TTime iLastStart; |
|
157 /* |
|
158 * Time after completing the harvesting of a plugin |
|
159 */ |
|
160 TTime iLastComplete; |
|
161 /* |
|
162 * Base app class of a harvester plugin |
|
163 */ |
|
164 TBuf<KFilePluginBaseAppClassMaxLen> iQualifiedBaseAppClass; |
|
165 }; |
|
166 |
|
167 private: |
|
168 enum TState |
|
169 { |
|
170 EStateNone = 0, // Initial state |
|
171 EStateCancelling, // Indexing manager is cancelled |
|
172 EStateRunning // Indexing manager is running |
|
173 }; |
|
174 |
|
175 private: |
|
176 /* List of plugins currently loaded */ |
|
177 RPointerArray<CIndexingPlugin> iPluginArray; |
|
178 |
|
179 /* List of harvester events */ |
|
180 RArray<THarvesterRecord> iHarvesterArray; |
|
181 TBool iHarvesterArrayChanged; |
|
182 |
|
183 /* Timer event */ |
|
184 RTimer iTimer; |
|
185 |
|
186 /* Manager state */ |
|
187 TState iState; |
|
188 |
|
189 /* Search Server session is passed to harvester plugins */ |
|
190 RSearchServerSession iSearchSession; |
|
191 |
|
192 /* Path to the manager state */ |
|
193 TFileName iManagerFilePath; |
|
194 |
|
195 /* File server connection */ |
|
196 RFs iFs; |
|
197 |
|
198 /* Time of previous RunL call */ |
|
199 TTime iPreviousRun; |
|
200 /* Database to maintain blacklisted plugins.Owned */ |
|
201 CBlacklistMgr* iBlacklistMgr; |
|
202 }; |
|
203 |
|
204 #endif // CINDEXINGMANAGER_H |