|
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 #ifndef C_CALENDARSEARCHER_H |
|
21 #define C_CALENDARSEARCHER_H |
|
22 |
|
23 //System Includes |
|
24 #include <e32std.h> |
|
25 #include <calsession.h> |
|
26 #include <calentryview.h> |
|
27 #include <calinstanceview.h> |
|
28 #include <calprogresscallback.h> |
|
29 |
|
30 //Search FW includes |
|
31 #include <searchcontentsearcher.h> |
|
32 #include <searchcondition.h> |
|
33 |
|
34 // FORWARD DECLARATIONS |
|
35 class CSearchTextSearcher; |
|
36 class CSearchDocumentId; |
|
37 class MSearchPluginObserver; |
|
38 class CCalDesC; |
|
39 |
|
40 /** |
|
41 * Active object handling the Calendar database search. |
|
42 * Per each RunL call, a limited number of calendar days are searched. |
|
43 * |
|
44 * @lib calendarsearchplugin.lib |
|
45 */ |
|
46 class CCalendarSearcher : public CActive, |
|
47 public MSearchContentSearcher, |
|
48 public MCalProgressCallBack |
|
49 |
|
50 { |
|
51 |
|
52 public: |
|
53 |
|
54 /** |
|
55 * Defines the state of handler |
|
56 */ |
|
57 enum TCalendarState |
|
58 { |
|
59 EIdle = 0, |
|
60 ECreatingCalendarEntryView, |
|
61 ECreatingCalendarInstanceView, |
|
62 ESearching |
|
63 }; |
|
64 |
|
65 static CCalendarSearcher* CCalendarSearcher::NewL( |
|
66 const RArray<TUid>& aContentIdArray, |
|
67 const CSearchCondition& aCondition, |
|
68 const TUid& aPluginId, |
|
69 MSearchPluginObserver& aObserver ); |
|
70 |
|
71 /** |
|
72 * Standard Destructor. |
|
73 * |
|
74 */ |
|
75 virtual ~CCalendarSearcher(); |
|
76 |
|
77 /** |
|
78 * Checck if the Entry exists in calander |
|
79 * |
|
80 * @param aId the Local Uid to be searched |
|
81 */ |
|
82 |
|
83 TBool GetIfEntryExistsL (TCalLocalUid aId); |
|
84 |
|
85 /** |
|
86 * Starts the search process. |
|
87 * |
|
88 * @param aCriteria Search criteria for the search. |
|
89 */ |
|
90 void StartSearchL(); |
|
91 |
|
92 public: //from base class MSearchContentSearcher |
|
93 |
|
94 /** |
|
95 * From MSearchContentSearcher |
|
96 * Search FW calls this function when it no longer needs this searcher. |
|
97 * |
|
98 */ |
|
99 void Destroy(); |
|
100 |
|
101 /** |
|
102 * From MSearchContentSearcher |
|
103 * Starts the search. Progress of the search is notified through aObserver. |
|
104 * Notice that this call must be asynchronous. |
|
105 * |
|
106 * @param aObserver Observer for search progress. |
|
107 */ |
|
108 void SearchL(); |
|
109 |
|
110 /** |
|
111 * From MSearchContentSearcher |
|
112 * Function returning ETrue when a search is ongoing. EFalse otherwise. |
|
113 * |
|
114 * @return ETrue when a search is ongoing. EFalse otherwise. |
|
115 */ |
|
116 TBool IsSearching(); |
|
117 |
|
118 /** |
|
119 * From MSearchContentSearcher |
|
120 * Cancels the ongoing search. This call must complete synchronously and no calls for |
|
121 * observers must be made after this call. |
|
122 * |
|
123 */ |
|
124 void CancelSearch(); |
|
125 |
|
126 /** |
|
127 * From MSearchContentSearcher |
|
128 * Gets the results indicated by the given document ids. Asynchronous. Results will be given |
|
129 * through callback in MSearchPlugInObserver given in Search request. |
|
130 * |
|
131 * @param aResults Results of the search process. Ownership transfers to caller. |
|
132 */ |
|
133 void GetResultsL( const RPointerArray<CSearchDocumentId>& aDocumentIdArray ); |
|
134 |
|
135 /** |
|
136 * From MSearchContentSearcher |
|
137 * Cancels the result retrieval process. |
|
138 * |
|
139 */ |
|
140 void CancelResultsRetrieve(); |
|
141 |
|
142 /* |
|
143 * Gets the current search progress. Typically this is called by the framework |
|
144 * in case the plugin fails to provide results through MSearchPluginObserver in the |
|
145 * time defined by the framework. |
|
146 * |
|
147 * @param aContentClassId On return contains the content class id, which is currently searched. |
|
148 * @param aCurrentDocument On return contains the index document that is currently being searched. |
|
149 * @param aTotalDocuments On return contains the total count of documents to be searched. |
|
150 */ |
|
151 void GetSearchProgressL( TUid& aContentClassId, TInt& aCurrentDocument, TInt& aTotalDocuments ); |
|
152 |
|
153 /** |
|
154 * From MSearchContentSearcher , through MSearchTextSearcherObserver |
|
155 * Is called by MSearchTextSearcherObserver when Keyword is found automatically. |
|
156 * @param aCharPos The character position of the keyword match within the original text. |
|
157 * |
|
158 */ |
|
159 void HitL( TInt aCharPos ); |
|
160 |
|
161 /** |
|
162 * Gets the information required for launching. |
|
163 * @param aDocumentID Document ID to launch. |
|
164 * |
|
165 */ |
|
166 HBufC8* LaunchInfoL( const CSearchDocumentId& aDocumentID ); |
|
167 |
|
168 /** |
|
169 * Initializes the session with Calendar Server. |
|
170 */ |
|
171 void InitializationL(); |
|
172 |
|
173 /** |
|
174 * Is called when classes related to Calendar connection are finished |
|
175 * initializing. This is called after CCalInstanceView::NewL and |
|
176 * CCalEntryView::NewL. When initialization is complete starts the search |
|
177 * automatically. |
|
178 * @param aError |
|
179 */ |
|
180 void Completed(TInt aError); |
|
181 |
|
182 /** |
|
183 * Is called when contentsearcher finishes it's operation or it is unable to |
|
184 * search further. |
|
185 * |
|
186 * @param aTotalNumOfItems |
|
187 * @param aSearchResult |
|
188 */ |
|
189 void ReportFinishedL( TInt aTotalNumOfItems, TInt aSearchResult = 0 ); |
|
190 |
|
191 protected: // New functions |
|
192 |
|
193 /** |
|
194 * Performs the second phase construction. |
|
195 * |
|
196 * @param aContentTypeUid |
|
197 */ |
|
198 void ConstructL( const RArray<TUid>& aContentIdArray, |
|
199 const CSearchCondition& aCondition, |
|
200 MSearchPluginObserver& aObserver ); |
|
201 |
|
202 /** |
|
203 * Performs the first phase of two phase construction. |
|
204 * |
|
205 * |
|
206 * @param aPluginId Plug-in's ID. |
|
207 */ |
|
208 CCalendarSearcher::CCalendarSearcher( const TUid& aPluginId ); |
|
209 |
|
210 private: // new functions |
|
211 /** |
|
212 * Handles the cleanup operation of this class. |
|
213 */ |
|
214 void Cleanup(); |
|
215 |
|
216 /** |
|
217 * Does the text search of the agenda instance. Called from RunL. In one RunL call |
|
218 * a limited number of agenda days/instances are searched. |
|
219 * |
|
220 * @return ETrue When more agenda days with instances are available. |
|
221 * EFalse otherwise. |
|
222 */ |
|
223 TBool DoActualSearchL(); |
|
224 |
|
225 /** |
|
226 * Fetches all the Calendar Entries. |
|
227 */ |
|
228 TBool FetchAllCalendarIdsL(); |
|
229 |
|
230 private: // from CActive |
|
231 /** |
|
232 * From CActive. |
|
233 * |
|
234 * Handles an active object’s request completion event. |
|
235 */ |
|
236 void RunL(); |
|
237 |
|
238 /** |
|
239 * From CActive. |
|
240 * |
|
241 * Implements cancellation of an outstanding request. |
|
242 */ |
|
243 void DoCancel(); |
|
244 |
|
245 /** |
|
246 * From CActive. |
|
247 * |
|
248 * Handles a leave occurring in the request completion event handler RunL(). |
|
249 */ |
|
250 TInt RunError(TInt aError); |
|
251 |
|
252 |
|
253 private: // from MCalProgressCallBack |
|
254 |
|
255 /* Not in use */ |
|
256 /** |
|
257 * From MCalProgressCallBack. |
|
258 * |
|
259 * progress of the search. |
|
260 */ |
|
261 void Progress(TInt /*aPercentageCompleted*/){}; |
|
262 |
|
263 /* Not in use */ |
|
264 /** |
|
265 * From MCalProgressCallBack. |
|
266 * |
|
267 * progress notification. |
|
268 */ |
|
269 /* Not in use */ |
|
270 TBool NotifyProgress(){ return 0;}; |
|
271 |
|
272 private: //Data |
|
273 |
|
274 /** |
|
275 * Search Plugin Observer |
|
276 * Own. |
|
277 */ |
|
278 MSearchPluginObserver* iObserver; |
|
279 |
|
280 /** |
|
281 * Text searcher |
|
282 * Own. |
|
283 */ |
|
284 CSearchTextSearcher* iTextSearcher; |
|
285 |
|
286 /** |
|
287 * Current document which is currently Searched. |
|
288 */ |
|
289 TInt iCurrentDocumentSearching; |
|
290 |
|
291 /** |
|
292 * Total number of documents Searched. |
|
293 */ |
|
294 TInt iTotalNumOfDocumentsSearched; |
|
295 |
|
296 /** |
|
297 * A handle to the calendar file.iSession. |
|
298 * Own. |
|
299 */ |
|
300 CCalSession* iSession; |
|
301 |
|
302 /** |
|
303 * View to the session for accessing calendar entries. |
|
304 * Own. |
|
305 */ |
|
306 CCalEntryView* iEntryView; |
|
307 |
|
308 /** |
|
309 * An instance of a calendar entry. |
|
310 * Own. |
|
311 */ |
|
312 CCalInstanceView* iInstanceView; |
|
313 |
|
314 /** |
|
315 * Array of UIDs that contain all items in the calendar DB. |
|
316 * own |
|
317 */ |
|
318 RArray<TCalLocalUid> iCalLocalUidArray; |
|
319 |
|
320 /** |
|
321 * Entry filter used in the entry view and instance view. |
|
322 * defines the rules according to which the instances are filtered. |
|
323 */ |
|
324 CalCommon::TCalViewFilter iFilter; |
|
325 |
|
326 /** |
|
327 * An instance of a calendar entry. |
|
328 * Not Own. |
|
329 */ |
|
330 CCalEntry* iEntry; |
|
331 |
|
332 /** |
|
333 * State of the calendar initialization. |
|
334 */ |
|
335 TCalendarState iCalendarState; |
|
336 |
|
337 /** |
|
338 * PlugIn Uid. |
|
339 */ |
|
340 const TUid iPluginId; |
|
341 |
|
342 /** |
|
343 * Position of the first Keyword hit for preparing snippets. |
|
344 */ |
|
345 TInt isFirstKeyWordHit; |
|
346 |
|
347 /** |
|
348 * Flag of parameter setting status. |
|
349 */ |
|
350 TBool iSetParamsDone; |
|
351 |
|
352 /** |
|
353 * Error Code of the last operation |
|
354 */ |
|
355 TInt iErrorCode; |
|
356 |
|
357 /** |
|
358 * Flag to report that searching operation has finished. |
|
359 */ |
|
360 TBool iNeedToCallReportFinishedL; |
|
361 |
|
362 /** |
|
363 * Array of CCalDesC, a mapper class. |
|
364 * Own. |
|
365 */ |
|
366 RPointerArray<CCalDesC> iCalDesCArray; |
|
367 |
|
368 /** |
|
369 * Checks wheather Search is cancelled or not. |
|
370 */ |
|
371 TBool iSearchNotCancelled; |
|
372 |
|
373 /** |
|
374 * Array of heavy Results. |
|
375 * Own. |
|
376 */ |
|
377 RPointerArray<CSearchResult> iHeavyResultsArray; |
|
378 |
|
379 /** |
|
380 * File session. |
|
381 */ |
|
382 RFs iFsSession; |
|
383 |
|
384 /** |
|
385 * Buffer to read snippet format of Date from resource file. |
|
386 * Own. |
|
387 */ |
|
388 HBufC8* iReadDateBuffer; |
|
389 |
|
390 /** |
|
391 * Buffer to read snippet format of time from resource file. |
|
392 * Own. |
|
393 */ |
|
394 HBufC8* iReadTimeBuffer; |
|
395 }; |
|
396 |
|
397 #endif // C_CALENDARSEARCHER_H |
|
398 |
|
399 // End of File |
|
400 |