|
1 /* |
|
2 * Copyright (c) 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: This is the client side interface declaration for the |
|
15 * predictive search server. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef __CPSREQUESTHANDLER_H__ |
|
21 #define __CPSREQUESTHANDLER_H__ |
|
22 |
|
23 // INCLUDE FILES |
|
24 |
|
25 // SYSTEM INCLUDES |
|
26 #include <e32base.h> |
|
27 #include <e32svr.h> |
|
28 #include <s32mem.h> |
|
29 #include <e32property.h> |
|
30 #include <mvpbkContactLink.h> |
|
31 #include <CVPbkContactManager.h> |
|
32 #include <CVPbkContactStoreUriArray.h> |
|
33 #include <tvpbkcontactstoreuriptr.h> |
|
34 #include <MVPbkContactStoreList.h> |
|
35 #include <MVPbkContactStore.h> |
|
36 #include <CVPbkContactIdConverter.h> |
|
37 #include <vpbkcontactstoreuris.h> |
|
38 #include <badesca.H> |
|
39 |
|
40 // USER INCLUDES |
|
41 #include <CPcsDefs.h> |
|
42 #include <CPsClientData.h> |
|
43 #include <CPsQuery.h> |
|
44 #include <CPsSettings.h> |
|
45 #include <CPsPattern.h> |
|
46 #include <RPsSession.h> |
|
47 |
|
48 // FORWARD DECLARATIONS |
|
49 class MPsResultsObserver; |
|
50 class CPsPropertyHandler; |
|
51 |
|
52 |
|
53 // CLASS DECLARATION |
|
54 /** |
|
55 * CPSRequestHandler |
|
56 * An instance of the request handler object for the Predicitve Search application |
|
57 * |
|
58 * @lib PsServerClientAPI.lib |
|
59 * @since S60 v3.2 |
|
60 */ |
|
61 class CPSRequestHandler : public CActive |
|
62 { |
|
63 |
|
64 public: // Constructors and destructors |
|
65 |
|
66 /** |
|
67 * NewL. |
|
68 * Two-phased constructor. |
|
69 * Creates a CPSRequestHandler object using two phase construction, |
|
70 * and return a pointer to the created object. |
|
71 * |
|
72 * @return A pointer to the created instance of CPSRequestHandler. |
|
73 */ |
|
74 IMPORT_C static CPSRequestHandler* NewL(); |
|
75 |
|
76 /** |
|
77 * NewLC. |
|
78 * Two-phased constructor. |
|
79 * Creates a CPSRequestHandler object using two phase construction, |
|
80 * and return a pointer to the created object. |
|
81 * |
|
82 * @return A pointer to the created instance of CPSRequestHandler. |
|
83 */ |
|
84 IMPORT_C static CPSRequestHandler* NewLC(); |
|
85 |
|
86 /** |
|
87 * ~CPSRequestHandler. |
|
88 * Destructor. |
|
89 * Destroys the object and release all memory objects. |
|
90 */ |
|
91 virtual ~CPSRequestHandler(); |
|
92 |
|
93 public: // New functions |
|
94 |
|
95 /** |
|
96 * Version. |
|
97 * Returns the predictive search server version. |
|
98 * |
|
99 * @return The current version of predictive search server. |
|
100 */ |
|
101 IMPORT_C TVersion Version() const; |
|
102 |
|
103 /** |
|
104 * AddObserver. |
|
105 * |
|
106 * @param aObserver The object to be used to handle updates |
|
107 * from the server. |
|
108 */ |
|
109 IMPORT_C void AddObserverL ( MPsResultsObserver* aObserver ); |
|
110 |
|
111 /** |
|
112 * RemoveObserverL. |
|
113 * |
|
114 * @param aObserver The object used to handle updates from the server. |
|
115 * @return KErrNone if removed. |
|
116 * KErrNotFound if observer not added already. |
|
117 */ |
|
118 IMPORT_C TInt RemoveObserver ( MPsResultsObserver* aObserver ); |
|
119 |
|
120 /** |
|
121 * SetSearchSettingsL. |
|
122 * Set the databases and fields to be included in search. |
|
123 * Databases ids are mapped to virtual phone book URLs. |
|
124 * Fields to be searched are mapped to virutal phonebook identifiers. |
|
125 * |
|
126 * @param aSettings Holds the search settings. |
|
127 */ |
|
128 IMPORT_C void SetSearchSettingsL(const CPsSettings& aSettings); |
|
129 |
|
130 /** |
|
131 * GetAllContentsL. |
|
132 * Sends a request to the predictive search server to get all cached contents. |
|
133 * This is a asynchronous request. |
|
134 */ |
|
135 IMPORT_C void GetAllContentsL(); |
|
136 |
|
137 /** |
|
138 * SearchL. |
|
139 * Sends a request to the predictive search server. |
|
140 * This is a asynchronous request. |
|
141 * |
|
142 * @param aSearchQuery The input search query.(Length of aSearchQuery <= KPsQueryMaxLen) |
|
143 * @param aStatus Holds the completion status of search request. |
|
144 */ |
|
145 IMPORT_C void SearchL(const CPsQuery& aSearchQuery); |
|
146 |
|
147 /** |
|
148 * SearchL. |
|
149 * Sends a request to the predictive search server. |
|
150 * This is a asynchronous request. It considers bookmarked contacts |
|
151 * while sending the results back to the client |
|
152 * |
|
153 * @param aSearchQuery The input search query.(Length of aSearchQuery <= KPsQueryMaxLen) |
|
154 * @param aMarkedContacts Array of marked contacts |
|
155 * @param aContactManager Contact manager instance |
|
156 */ |
|
157 IMPORT_C void SearchL(const CPsQuery& aSearchQuery, |
|
158 RPointerArray<CPsClientData>& aMarkedContacts, |
|
159 CVPbkContactManager* aContactManager); |
|
160 |
|
161 /** |
|
162 * CancelSearch. |
|
163 * Cancels ongoing search. |
|
164 */ |
|
165 IMPORT_C void CancelSearch(); |
|
166 |
|
167 /** |
|
168 * LookupL. |
|
169 * Sends a request to the predictive search server. |
|
170 * Does a predictive search in aSearchData for aSearchQuery and return |
|
171 * the matches. |
|
172 * This is a synchronous request. |
|
173 * |
|
174 * @param aSearchQuery The input search query.(Length of aSearchQuery <= KPsQueryMaxLen) |
|
175 * @param aSearchData The input data to be searched. |
|
176 * @param aMatchSet The list of matches. |
|
177 * @param aMatchLocation The list matched index and length of match |
|
178 */ |
|
179 IMPORT_C void LookupL(const CPsQuery& aSearchQuery, |
|
180 const TDesC& aSearchData, |
|
181 CDesCArray& aMatchSet, |
|
182 RArray<TPsMatchLocation>& aMatchLocation); |
|
183 |
|
184 /** |
|
185 * LookupMatchL. |
|
186 * Sends a request to the predictive search server. |
|
187 * Does a predictive search in aSearchData for aSearchQuery and return |
|
188 * the match string in aMatch. |
|
189 * If there is no full match aMatch will be empty (Length()==0) |
|
190 * This is a synchronous request. |
|
191 * |
|
192 * @param aSearchQuery The input search query.(Length of aSearchQuery <= KPsQueryMaxLen) |
|
193 * @param aSearchData The input data to be searched. |
|
194 * @param aMatch The matched result |
|
195 */ |
|
196 IMPORT_C void LookupMatchL(const CPsQuery& aSearchQuery, |
|
197 const TDesC& aSearchData, |
|
198 TDes& aMatch ); |
|
199 |
|
200 /** |
|
201 * IsLanguageSupportedL. |
|
202 * Checks if the language variant is supported by |
|
203 * the predictive search engine. |
|
204 * This is a synchronous request. |
|
205 * |
|
206 * @param aLanguage The language which has to be checked |
|
207 * @return ETrue if the language specified is supported by PS engine |
|
208 * EFalse otherwise |
|
209 * |
|
210 */ |
|
211 IMPORT_C TBool IsLanguageSupportedL(const TLanguage aLanguage); |
|
212 |
|
213 /** |
|
214 * GetCachingStatusL |
|
215 * Gets the status of the caching synchronously |
|
216 * |
|
217 * @param aResultsBuffer Pointer to the result buffer. |
|
218 */ |
|
219 IMPORT_C TInt GetCachingStatusL(TCachingStatus& aStatus); |
|
220 |
|
221 /** |
|
222 * ConvertToVpbkLinkLC. |
|
223 * Extract the VPBK contact link associated with the search result. |
|
224 * This is a synchronous request. |
|
225 * |
|
226 * @param aSearchResult PS result for which contact link is required. |
|
227 * @param aContactManager An instance of contact manager used for link extraction. |
|
228 * @return The contact link. |
|
229 */ |
|
230 IMPORT_C MVPbkContactLink* ConvertToVpbkLinkLC( const CPsClientData& aSearchResult, |
|
231 CVPbkContactManager& aContactManager ); |
|
232 |
|
233 /** |
|
234 * GetDataOrderL. |
|
235 * This function returns the list of supported data fields (mapped to VPbk identifiers) |
|
236 * supported by a datastore. |
|
237 * This is a synchronous request. |
|
238 * |
|
239 * @param aDataStore The data store URI. |
|
240 * @param aDataOrder This array has the field identifiers returned from the server. |
|
241 */ |
|
242 IMPORT_C void GetDataOrderL(const TDesC& aDataStore, RArray<TInt>& aDataOrder); |
|
243 |
|
244 /** |
|
245 * GetSortOrderL. |
|
246 * This function returns the sort order of data fields (mapped to VPbk identifiers) |
|
247 * set on a datastore. |
|
248 * This is a synchronous request. |
|
249 * |
|
250 * @param aDataStore The data store URI. |
|
251 * @param aSortOrder This array has the field identifiers returned from the server. |
|
252 */ |
|
253 IMPORT_C void GetSortOrderL(const TDesC& aDataStore, RArray<TInt>& aSortOrder); |
|
254 |
|
255 /** |
|
256 * ChangeSortOrderL. |
|
257 * This function sets the sort order of data fields (mapped to VPbk identifiers) |
|
258 * on a datastore. |
|
259 * This is a synchronous request. |
|
260 * |
|
261 * @param aDataStore The data store URI. |
|
262 * @param aSortOrder This array has the field identifiers to be set for this store. |
|
263 */ |
|
264 IMPORT_C void ChangeSortOrderL(const TDesC& aDataStore, RArray<TInt>& aSortOrder); |
|
265 |
|
266 /** |
|
267 * ShutdownServerL |
|
268 * Shuts down the predictive search engine. |
|
269 * |
|
270 * CAUTION: Shutdown of predictive search server shouldn't be done for each |
|
271 * session. It should be done only when the search engine needs to be |
|
272 * completely shutdown. |
|
273 */ |
|
274 IMPORT_C void ShutdownServerL(); |
|
275 |
|
276 protected: // Functions from base classes |
|
277 |
|
278 /** |
|
279 * From CActive, RunL. |
|
280 * Callback function. |
|
281 * Invoked to handle responses from the server. |
|
282 */ |
|
283 void RunL(); |
|
284 |
|
285 /** |
|
286 * From CActive, DoCancel. |
|
287 * Cancels any outstanding operation. |
|
288 */ |
|
289 void DoCancel(); |
|
290 |
|
291 public: |
|
292 |
|
293 /** |
|
294 * CPsPropertyHandler is internal class to make it access |
|
295 * to CPsRequestHandler class |
|
296 */ |
|
297 friend class CPsPropertyHandler; |
|
298 |
|
299 private: // Constructors and destructors |
|
300 |
|
301 /** |
|
302 * CPSRequestHandler. |
|
303 * Performs the first phase of two phase construction. |
|
304 */ |
|
305 CPSRequestHandler(); |
|
306 |
|
307 /** |
|
308 * ConstructL. |
|
309 * Performs the second phase construction of a |
|
310 * CPSRequestHandler object. |
|
311 */ |
|
312 void ConstructL(); |
|
313 |
|
314 private: // Internal data handlers |
|
315 |
|
316 /** |
|
317 * ParseResultsL. |
|
318 * Parses the results buffer and converts them to data elements. |
|
319 */ |
|
320 void HandleSearchResultsL(); |
|
321 |
|
322 /** |
|
323 * HandleBufferOverFlowL. |
|
324 * Handles internal buffer overflow event. |
|
325 */ |
|
326 void HandleBufferOverFlowL(); |
|
327 |
|
328 /** |
|
329 * HandleErrorL. |
|
330 * Handles error events. |
|
331 */ |
|
332 void HandleErrorL(TInt aErrorCode); |
|
333 |
|
334 /** |
|
335 * AddMarkedContacts |
|
336 * Filters the bookmark results and adds them to final search result set |
|
337 */ |
|
338 TInt AddMarkedContactsL(RPointerArray<CPsClientData>& searchResults); |
|
339 |
|
340 /** |
|
341 * RunSearchFromBufferL |
|
342 * Runs search if search query buffer ( iPendingSearchQueryBuffer ) is not empty |
|
343 */ |
|
344 void RunSearchFromBufferL(); |
|
345 |
|
346 private: // Data |
|
347 |
|
348 /** |
|
349 * iSession, the predictive search server session. |
|
350 */ |
|
351 RPsSession iSession; |
|
352 |
|
353 /** |
|
354 * iObservers, observers which handles updates from the server. |
|
355 */ |
|
356 RPointerArray<MPsResultsObserver> iObservers; |
|
357 |
|
358 /** |
|
359 * iSearchQueryBuffer, the buffer that holds the search query. |
|
360 */ |
|
361 HBufC8* iSearchQueryBuffer; |
|
362 |
|
363 /** |
|
364 * iPendingSearchQueryBuffer, the buffer that holds the pending search query. |
|
365 */ |
|
366 HBufC8* iPendingSearchQueryBuffer; |
|
367 |
|
368 /** |
|
369 * iSearchDataBuffer, the buffer that holds the search data. |
|
370 */ |
|
371 HBufC8* iSearchDataBuffer; |
|
372 |
|
373 /** |
|
374 * iSearchResultsBuffer, the buffer that holds the search results. |
|
375 */ |
|
376 HBufC8* iSearchResultsBuffer; |
|
377 |
|
378 /** |
|
379 * iConverter, instance of contact id converter |
|
380 */ |
|
381 CVPbkContactIdConverter* iConverter; |
|
382 |
|
383 /** |
|
384 * iPropertyHandler, the handler to property which is asynchronously monitored |
|
385 */ |
|
386 CPsPropertyHandler* iPropertyHandler; |
|
387 |
|
388 /** |
|
389 * Not Owned |
|
390 * iBookMarkContactManager, contact manager reference received from the client |
|
391 * To be used only for handling marked contacts. |
|
392 */ |
|
393 CVPbkContactManager* iBookMarkContactManager; |
|
394 |
|
395 /** |
|
396 * iMarkedContacts, stores the bookmarked contacts if any, sent by the client |
|
397 */ |
|
398 RPointerArray<CPsClientData> iMarkedContacts; |
|
399 |
|
400 /** |
|
401 * ETrue, if search request was cancelled |
|
402 */ |
|
403 TBool iSearchRequestCancelled; |
|
404 |
|
405 }; |
|
406 |
|
407 |
|
408 #endif //__CPSREQUESTHANDLER_H__ |
|
409 |
|
410 // End of File |