|
1 /* |
|
2 * Copyright (c) 2006-2007 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: ECom search interface definition |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef C_CNOTESSEARCHER_H |
|
22 #define C_CNOTESSEARCHER_H |
|
23 |
|
24 //System Includes |
|
25 #include <e32std.h> |
|
26 #include <d32dbms.h> |
|
27 #include <e32cmn.h> |
|
28 #include <badesca.h> |
|
29 |
|
30 //Search FW Common includes |
|
31 #include <searchcontent.h> |
|
32 #include <searchcontentsearcher.h> |
|
33 |
|
34 |
|
35 //Forwared declarations |
|
36 class CSearchCondition; |
|
37 class CSearchResult; |
|
38 class CSearchTextSearcher; |
|
39 class MSearchPluginObserver; |
|
40 class CNotesSearchPluginUtils; |
|
41 |
|
42 /** |
|
43 * This class is the searcher class for the notes |
|
44 * |
|
45 * This class searches the phonebook notes |
|
46 * |
|
47 * @lib notessearchplugin.lib |
|
48 */ |
|
49 |
|
50 class CNotesSearcher : public CActive , |
|
51 public MSearchContentSearcher |
|
52 { |
|
53 |
|
54 public: // Constructors and destructor |
|
55 /** |
|
56 * |
|
57 * First phase construction |
|
58 * |
|
59 * @return constructed CNotesSearchPlugin object. |
|
60 */ |
|
61 static CNotesSearcher* NewL(const RArray<TUid>& aContentIdArray, |
|
62 const CSearchCondition& aCondition, |
|
63 const TUid& aPluginId, |
|
64 MSearchPluginObserver& aObserver ); |
|
65 |
|
66 /** |
|
67 * Destructor. |
|
68 * |
|
69 */ |
|
70 virtual ~CNotesSearcher(); |
|
71 |
|
72 /** |
|
73 * Check if the entry exists in notes |
|
74 * |
|
75 */ |
|
76 TBool CNotesSearcher::CheckIfEntryExistsL (TInt aNoteKey); |
|
77 /** |
|
78 * Cleanup internal resource |
|
79 * |
|
80 */ |
|
81 void CleanUp(); |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 public:// from MSearchContentSearcher interface |
|
87 |
|
88 /** |
|
89 * Search FW calls this function when it no longer needs this searcher. |
|
90 * |
|
91 */ |
|
92 void Destroy(); |
|
93 |
|
94 |
|
95 /** |
|
96 * Starts the search. Progress of the search is notified through aObserver. Notice that |
|
97 * this call must be asynchronous. |
|
98 * |
|
99 */ |
|
100 void SearchL( void); |
|
101 |
|
102 /** |
|
103 * Function returning ETrue when a search is ongoing. EFalse otherwise. |
|
104 * |
|
105 * @return ETrue when a search is ongoing. EFalse otherwise. |
|
106 */ |
|
107 TBool IsSearching(); |
|
108 |
|
109 /** |
|
110 * Cancels the ongoing search. This call must complete synchronously and no calls for |
|
111 * observers must be made after this call. |
|
112 * |
|
113 */ |
|
114 void CancelSearch(); |
|
115 |
|
116 /** |
|
117 * Gets the results got so far. A call to this function must flush the |
|
118 * plugins internal buffer so that results returned by this call are not |
|
119 * given twice. |
|
120 * This is called in case the plugin fails to provide results to the framework |
|
121 * through MSearchPlugInObserver in the time defined by the engine. |
|
122 * |
|
123 * @param aResults Results of the search process. Ownership transfers to caller. |
|
124 */ |
|
125 void GetResultsL( const RPointerArray<CSearchDocumentId>& aDocumentIdArray ); |
|
126 |
|
127 |
|
128 /** |
|
129 * Gets the current search progress. Typically this is called by the framework |
|
130 * in case the plugin fails to provide results through MSearchPlugInObserver in the |
|
131 * time defined by the framework. |
|
132 * |
|
133 * @param aContentClassId The content class, whose search progress is requested. If NULL, the function should return the |
|
134 * total search progress. |
|
135 * @param aCurrentDocument The index document that is currently being searched (from the set of documents belonging to given |
|
136 * content class). |
|
137 * @param aTotalDocuments The total count of documents to be searched (from the set of documents belonging to given |
|
138 * content class). |
|
139 */ |
|
140 void GetSearchProgressL( TUid& aContentClassId, TInt& aCurrentDocument, TInt& aTotalDocuments ); |
|
141 |
|
142 /** |
|
143 * Cancels the result retrieval process. |
|
144 * |
|
145 */ |
|
146 void CancelResultsRetrieve(); |
|
147 |
|
148 protected: //from the base class CActive |
|
149 |
|
150 /** |
|
151 * From CActive |
|
152 * Handles an active object's request completion event. |
|
153 * |
|
154 * The function is called by the active scheduler when a request |
|
155 * completion event occurs, i.e. after the active scheduler's |
|
156 * WaitForAnyRequest() function completes. |
|
157 * |
|
158 * Before calling this active object's RunL() function, the active scheduler |
|
159 * has: |
|
160 * |
|
161 * 1. decided that this is the highest priority active object with |
|
162 * a completed request |
|
163 * |
|
164 * 2. marked this active object's request as complete (i.e. the request is no |
|
165 * longer outstanding) |
|
166 * |
|
167 * RunL() runs under a trap harness in the active scheduler. If it leaves, |
|
168 * then the active scheduler calls RunError() to handle the leave. |
|
169 * |
|
170 * Note that once the active scheduler's Start() function has been called, |
|
171 * all user code is run under one of the program's active object's RunL() or |
|
172 * RunError() functions. |
|
173 * |
|
174 */ |
|
175 void RunL(); |
|
176 |
|
177 /** |
|
178 * From CActive. |
|
179 * |
|
180 * Implements cancellation of an outstanding request. |
|
181 */ |
|
182 void DoCancel(); |
|
183 |
|
184 /** |
|
185 * From CActive |
|
186 * If the RunL function leaves, |
|
187 * then the active scheduler calls RunError() to handle the leave. |
|
188 * |
|
189 */ |
|
190 TInt RunError( TInt aError ); |
|
191 |
|
192 |
|
193 private: |
|
194 /** |
|
195 * Does some initialization for database |
|
196 */ |
|
197 void InitDbL(); |
|
198 |
|
199 /** |
|
200 * Does the search of the note. Called from RunL. In one RunL call |
|
201 * a limited number of note items are searched. |
|
202 * |
|
203 * @return ETrue if more note items need to be searched. EFalse otherwise. |
|
204 */ |
|
205 TBool DoActualSearchL(); |
|
206 |
|
207 /** |
|
208 * from MSearchTextSearcherObserver |
|
209 * @param aKeywordCharPos keyword position |
|
210 * |
|
211 * @return void |
|
212 */ |
|
213 void HitL( TInt aKeywordCharPos ); |
|
214 |
|
215 HBufC8* LaunchInfoL( const CSearchDocumentId& aDocumentID ); |
|
216 /** |
|
217 * Gets the content and date by key value |
|
218 * |
|
219 * @param aKey |
|
220 * @param aContentDes |
|
221 * @param aTime |
|
222 * @return void |
|
223 */ |
|
224 void GetContentAndDateByKeyL(const TInt& aKey,HBufC*& aContentDes,TTime& aTime); |
|
225 |
|
226 private: |
|
227 |
|
228 /** |
|
229 * Constructor |
|
230 * |
|
231 * |
|
232 * @param aPluginId |
|
233 */ |
|
234 CNotesSearcher( const TUid& aPluginId); |
|
235 |
|
236 /** |
|
237 * 2nd phase constructor |
|
238 * |
|
239 * @param aContentIdArray |
|
240 * @param aCondition |
|
241 */ |
|
242 void ConstructL( const RArray<TUid>& aContentIdArray, |
|
243 const CSearchCondition& aCondition, |
|
244 MSearchPluginObserver& aObserver); |
|
245 |
|
246 |
|
247 |
|
248 RPointerArray<CSearchLightResult> iSearchLightResult; |
|
249 RPointerArray<CSearchResult> iHeavyResultsArray; |
|
250 |
|
251 protected: |
|
252 |
|
253 enum TNotepadColumnType |
|
254 { |
|
255 ENotepadKey = 1, // this must be 1 (DBMS/SQL restriction) |
|
256 ENotepadUpdateTime, |
|
257 ENotepadMemo, |
|
258 ENotepadColCountPlusOne // sentinel |
|
259 }; |
|
260 |
|
261 private: //Data members |
|
262 |
|
263 /** |
|
264 * The notes plugin id |
|
265 */ |
|
266 const TUid iNotesPluginId; |
|
267 |
|
268 |
|
269 /** |
|
270 * Represents the DB status |
|
271 */ |
|
272 TBool iSDbmsUp; |
|
273 |
|
274 /** |
|
275 * Represents a session with the DBMS server |
|
276 */ |
|
277 RDbs iDbSession; |
|
278 |
|
279 /** |
|
280 * provides an interface for creating and opening a database identified by name and format. |
|
281 */ |
|
282 |
|
283 RDbNamedDatabase iNamedDataBase; // |
|
284 |
|
285 /** |
|
286 * Provides a view to a table. The view depends on the SQL query used for building the view. |
|
287 */ |
|
288 RDbView iDbView; |
|
289 |
|
290 /** |
|
291 * Counter used when reporting the status of the search. |
|
292 */ |
|
293 TInt iStatusItemCounter; |
|
294 |
|
295 /** |
|
296 * Total number of items to be searched, used when reporting the status |
|
297 * of the search.Set to KErrUnknown when the total number of items |
|
298 * is not known in advance.. |
|
299 */ |
|
300 TInt iTotalNumOfItems; |
|
301 |
|
302 |
|
303 |
|
304 /** |
|
305 * The array containg the key word hit position |
|
306 * Own |
|
307 */ |
|
308 RArray<TInt> iKeyHitPos; |
|
309 |
|
310 |
|
311 /** |
|
312 * The plugin observer |
|
313 */ |
|
314 MSearchPluginObserver* iObserver; |
|
315 |
|
316 /** |
|
317 * The Text searcher |
|
318 * Own |
|
319 */ |
|
320 CSearchTextSearcher* iTextSearcher; //own |
|
321 |
|
322 |
|
323 /** |
|
324 * The notes content |
|
325 * Own |
|
326 */ |
|
327 HBufC16* iContent; |
|
328 |
|
329 /** |
|
330 * The date format,read from the resource file |
|
331 * Own |
|
332 */ |
|
333 HBufC16* iDateFormat; |
|
334 }; |
|
335 |
|
336 |
|
337 #endif //C_CNOTESSEARCHER_H |
|
338 |
|
339 |