63
|
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: Predictive Contact Search Algorithm 1 main class
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#ifndef C_PCS_ALGORITHM_1
|
|
20 |
#define C_PCS_ALGORITHM_1
|
|
21 |
|
|
22 |
// INCLUDES
|
|
23 |
#include <e32cmn.h>
|
|
24 |
#include <s32mem.h>
|
|
25 |
#include <e32hashtab.h>
|
|
26 |
#include <e32property.h>
|
|
27 |
#include <bamdesca.h>
|
|
28 |
#include <centralrepository.h>
|
|
29 |
|
|
30 |
#include "PSAlgorithmInternalCRKeys.h"
|
|
31 |
#include "CPcsPlugin.h"
|
|
32 |
#include "CPsData.h"
|
|
33 |
#include "CPsClientData.h"
|
|
34 |
#include "CPcsCache.h"
|
|
35 |
#include "CPcsKeyMap.h"
|
|
36 |
#include "CPsQuery.h"
|
|
37 |
#include "CPsPattern.h"
|
|
38 |
#include "mdatastoreobserver.h"
|
|
39 |
#include "mstorelistobserver.h"
|
|
40 |
|
|
41 |
// FORWARD DECLARATION
|
|
42 |
class CPsData;
|
|
43 |
class CPsClientData;
|
|
44 |
class CPsDataPluginInterface;
|
|
45 |
class CPsQuery;
|
|
46 |
class CPcsAlgorithm1Helper;
|
|
47 |
class CPcsAlgorithm1MultiSearchHelper;
|
|
48 |
|
|
49 |
// CLASS DECLARATION
|
|
50 |
class CPcsAlgorithm1 : public CPcsPlugin,
|
|
51 |
public MDataStoreObserver,
|
|
52 |
public MStoreListObserver
|
|
53 |
{
|
|
54 |
public:
|
|
55 |
|
|
56 |
/**
|
|
57 |
* Two phase construction
|
|
58 |
*/
|
|
59 |
static CPcsAlgorithm1* NewL();
|
|
60 |
|
|
61 |
/**
|
|
62 |
* Destructor
|
|
63 |
*/
|
|
64 |
virtual ~CPcsAlgorithm1();
|
|
65 |
|
|
66 |
|
|
67 |
public:
|
|
68 |
|
|
69 |
// ------------------------ From base class CPcsPlugin ----------------
|
|
70 |
|
|
71 |
/**
|
|
72 |
* Search Function for cache
|
|
73 |
*/
|
|
74 |
void PerformSearchL(const CPsSettings& aPcsSettings,
|
|
75 |
CPsQuery& aCondition,
|
|
76 |
RPointerArray<CPsClientData>& aData,
|
|
77 |
RPointerArray<CPsPattern>& aPattern);
|
|
78 |
|
|
79 |
/**
|
|
80 |
* Search Function for input string
|
|
81 |
*/
|
|
82 |
void SearchInputL( CPsQuery& aSearchQuery,
|
|
83 |
TDesC& aSearchData,
|
|
84 |
RPointerArray<TDesC>& aMatchSet,
|
|
85 |
RArray<TPsMatchLocation>& aMatchLocation );
|
|
86 |
|
|
87 |
/**
|
|
88 |
* Performs search on a input string, and return result also as a string
|
|
89 |
*/
|
|
90 |
void SearchMatchStringL( CPsQuery& aSearchQuery,
|
|
91 |
TDesC& aSearchData,
|
|
92 |
TDes& aMatch );
|
|
93 |
|
|
94 |
/**
|
|
95 |
* Returns ETrue if this language is supported
|
|
96 |
*/
|
|
97 |
TBool IsLanguageSupportedL(const TUint32 aLanguage);
|
|
98 |
|
|
99 |
/**
|
|
100 |
* Returns supported data fields for a cache
|
|
101 |
*/
|
|
102 |
void GetDataOrderL( TDesC& aURI, RArray<TInt>& aDataOrder );
|
|
103 |
|
|
104 |
/**
|
|
105 |
* Returns supported sort order for a cache
|
|
106 |
*/
|
|
107 |
void GetSortOrderL( TDesC& aURI, RArray<TInt>& aDataOrder );
|
|
108 |
|
|
109 |
/**
|
|
110 |
* Sets the sort order for a cache
|
|
111 |
*/
|
|
112 |
void ChangeSortOrderL(TDesC& aURI, RArray<TInt>& aSortOrder);
|
|
113 |
|
|
114 |
/**
|
|
115 |
* Get the Adaptive Grid for one or more URIs
|
|
116 |
*/
|
|
117 |
void GetAdaptiveGridL( const MDesCArray& aURIs,
|
|
118 |
const TBool aCompanyName,
|
|
119 |
TDes& aAdaptiveGrid );
|
|
120 |
|
|
121 |
// --------------------------------------------------------------------
|
|
122 |
|
|
123 |
public:
|
|
124 |
|
|
125 |
// --------------- From base class MDataStoreObserver -----------------
|
|
126 |
|
|
127 |
/**
|
|
128 |
* Add a contact to the cache
|
|
129 |
*/
|
|
130 |
void AddData ( TDesC& aDataStore, CPsData* aData);
|
|
131 |
|
|
132 |
/**
|
|
133 |
* Remove a contact from the cache based on contact id
|
|
134 |
*/
|
|
135 |
void RemoveData ( TDesC& aDataStore, TInt aItemId );
|
|
136 |
|
|
137 |
/**
|
|
138 |
* Removes all the contacts from a particular datastore
|
|
139 |
*/
|
|
140 |
void RemoveAll ( TDesC& aDataStore);
|
|
141 |
|
|
142 |
/**
|
|
143 |
* Updates the caching status for a particular datastore
|
|
144 |
*/
|
|
145 |
void UpdateCachingStatus(TDesC& aDataStore, TInt aStatus);
|
|
146 |
|
|
147 |
// --------------------------------------------------------------------
|
|
148 |
|
|
149 |
public:
|
|
150 |
|
|
151 |
// ----------------- From base class MStoreListObserver ---------------
|
|
152 |
|
|
153 |
/**
|
|
154 |
* This method is called whenever any new store has been added
|
|
155 |
*/
|
|
156 |
void AddDataStore ( TDesC& aDataStore);
|
|
157 |
|
|
158 |
/**
|
|
159 |
* This method is called whenever a data store is removed
|
|
160 |
*/
|
|
161 |
void RemoveDataStore ( TDesC& aDataStore);
|
|
162 |
|
|
163 |
// --------------------------------------------------------------------
|
|
164 |
|
|
165 |
public:
|
|
166 |
|
|
167 |
/**
|
|
168 |
* Returns the array index of cache (in iPcsCache) for a datastore
|
|
169 |
*/
|
|
170 |
TInt GetCacheIndex(const TDesC& aDataStore);
|
|
171 |
|
|
172 |
/**
|
|
173 |
* Return the cache instance at a specific array index
|
|
174 |
*/
|
|
175 |
inline CPcsCache* GetCache(TInt aIndex)
|
|
176 |
{
|
|
177 |
return iPcsCache[aIndex];
|
|
178 |
}
|
|
179 |
|
|
180 |
/**
|
|
181 |
* Returns the key map instance
|
|
182 |
*/
|
|
183 |
inline CPcsKeyMap* GetKeyMap()
|
|
184 |
{
|
|
185 |
return iKeyMap;
|
|
186 |
}
|
|
187 |
|
|
188 |
|
|
189 |
private:
|
|
190 |
|
|
191 |
/**
|
|
192 |
* Constructor
|
|
193 |
*/
|
|
194 |
CPcsAlgorithm1();
|
|
195 |
|
|
196 |
/**
|
|
197 |
* 2nd phase construtor
|
|
198 |
*/
|
|
199 |
void ConstructL();
|
|
200 |
|
|
201 |
private:
|
|
202 |
|
|
203 |
/**
|
|
204 |
* Define a P&S property with given key under the internal category
|
|
205 |
* UID of PCS. Leave if definition fails for any other reason than
|
|
206 |
* key already existing.
|
|
207 |
*/
|
|
208 |
void DefinePropertyL( TPcsInternalKeyCacheStatus aPsKey );
|
|
209 |
|
|
210 |
/**
|
|
211 |
* Remove leading and trailing spaces of search query
|
|
212 |
*/
|
|
213 |
void RemoveSpacesL ( CPsQuery& aQuery );
|
|
214 |
|
|
215 |
/**
|
|
216 |
* Replace occurances of "0" in predictive mode with space
|
|
217 |
* if those are on the same button
|
|
218 |
*/
|
|
219 |
TBool ReplaceZeroWithSpaceL ( CPsQuery& aQuery );
|
|
220 |
|
|
221 |
/**
|
|
222 |
* Search function helper
|
|
223 |
*/
|
|
224 |
void DoSearchL ( const CPsSettings& aPcsSettings,
|
|
225 |
CPsQuery& aCondition,
|
|
226 |
RPointerArray<CPsData>& aSearchResults,
|
|
227 |
RPointerArray<CPsPattern>& aSearchSeqs );
|
|
228 |
|
|
229 |
/**
|
|
230 |
* Search function helper
|
|
231 |
*/
|
|
232 |
void DoSearchInputL ( CPsQuery& aQuery,
|
|
233 |
const TDesC& aData,
|
|
234 |
RPointerArray<TDesC>& aSearchSeqs,
|
|
235 |
RArray<TPsMatchLocation>& aMatchLocation );
|
|
236 |
|
|
237 |
/**
|
|
238 |
* Returns the index corresponding a URI in iDataStoreUri
|
|
239 |
*/
|
|
240 |
TInt FindStoreUri ( const TDesC& aDataStoreUri );
|
|
241 |
|
|
242 |
/**
|
|
243 |
* Function to return all cached content
|
|
244 |
*/
|
|
245 |
void GetAllContentsL ( const CPsSettings& aPcsSettings,
|
|
246 |
RPointerArray<CPsData>& aSearchResults );
|
|
247 |
|
|
248 |
/**
|
|
249 |
* Checks if search is on groups
|
|
250 |
* Return ETrue if there is a valid group URI
|
|
251 |
*/
|
|
252 |
TBool IsGroupSearchL ( CPsSettings& aSettings,
|
|
253 |
RArray<TInt>& aGroupIdArray );
|
|
254 |
|
|
255 |
/**
|
|
256 |
* Utility function to replace groups uri with that of contacts uri
|
|
257 |
*/
|
|
258 |
void ReplaceGroupsUriL ( CPsSettings& aSettings );
|
|
259 |
|
|
260 |
/**
|
|
261 |
* Filters the search results array for groups
|
|
262 |
*/
|
|
263 |
void FilterSearchResultsForGroupsL ( RArray<TInt>& aGroupContactIds,
|
|
264 |
RPointerArray<CPsData>& aSearchResults );
|
|
265 |
|
|
266 |
/**
|
|
267 |
* Get the list of contact ids that belong to a group.
|
|
268 |
*/
|
|
269 |
void GetContactsInGroupL ( TInt aGroupId,
|
|
270 |
RArray<TInt>& aGroupContactIds );
|
|
271 |
|
|
272 |
/**
|
|
273 |
* Read sort order for a data store from the central repository
|
|
274 |
* @param aURI - The data store URI for which sort order is required
|
|
275 |
* @param aSortOrder - The persisted sort order from the cenrep
|
|
276 |
*/
|
|
277 |
void ReadSortOrderFromCenRepL ( const TDesC& aURI,
|
|
278 |
RArray<TInt>& aSortOrder );
|
|
279 |
|
|
280 |
/** Write sort order for a data store to the central repository
|
|
281 |
* @param aURI - The data store URI for which sort order is to be persisted
|
|
282 |
* @param aSortOrder - The sort order to be persisted
|
|
283 |
*/
|
|
284 |
void WriteSortOrderToCenRepL ( const TDesC& aURI,
|
|
285 |
RArray<TInt>& aSortOrder );
|
|
286 |
|
|
287 |
/**
|
|
288 |
* Utility function that sets the caching error value
|
|
289 |
*/
|
|
290 |
void SetCachingError ( const TDesC& aDataStore,
|
|
291 |
TInt aError );
|
|
292 |
|
|
293 |
/**
|
|
294 |
* Write the content required by client
|
|
295 |
*/
|
|
296 |
CPsClientData* WriteClientDataL ( CPsData& aPsData );
|
|
297 |
|
|
298 |
/**
|
|
299 |
* Function to return data base URI for an internal identifier
|
|
300 |
*/
|
|
301 |
const TDesC& GetUriForIdL( TUint8 aUriId );
|
|
302 |
|
|
303 |
/**
|
|
304 |
* Inform clients about update happened on the cache
|
|
305 |
*/
|
|
306 |
void HandleCacheUpdated( TCachingStatus aStatus );
|
|
307 |
|
|
308 |
/**
|
|
309 |
* launch plugins by idle
|
|
310 |
*/
|
|
311 |
void DoLaunchPluginsL();
|
|
312 |
|
|
313 |
/**
|
|
314 |
* launch plugins
|
|
315 |
*/
|
|
316 |
static TInt DoLaunchPluginsL(TAny* aPtr);
|
|
317 |
|
|
318 |
/**
|
|
319 |
* Get the Adaptive Grid data for one or more URIs
|
|
320 |
*/
|
|
321 |
void GetAdaptiveGridFromCacheL( const MDesCArray& aURIs,
|
|
322 |
const TBool aCompanyName,
|
|
323 |
TDes& aAdaptiveGrid );
|
|
324 |
|
|
325 |
private:
|
|
326 |
|
|
327 |
/**
|
|
328 |
* Instance of contacts cache
|
|
329 |
* Own
|
|
330 |
*/
|
|
331 |
RPointerArray<CPcsCache> iPcsCache;
|
|
332 |
|
|
333 |
/**
|
|
334 |
* Instance of key map
|
|
335 |
* Own.
|
|
336 |
*/
|
|
337 |
CPcsKeyMap* iKeyMap;
|
|
338 |
|
|
339 |
/**
|
|
340 |
* Data plugin interface. Owned
|
|
341 |
*/
|
|
342 |
CPsDataPluginInterface* iPsDataPluginInterface;
|
|
343 |
|
|
344 |
/**
|
|
345 |
* Instance of algorithm helper. Owned
|
|
346 |
*/
|
|
347 |
CPcsAlgorithm1Helper* iHelper;
|
|
348 |
CPcsAlgorithm1MultiSearchHelper* iMultiSearchHelper;
|
|
349 |
|
|
350 |
/**
|
|
351 |
* Global that keeps the updated status of the caching
|
|
352 |
*/
|
|
353 |
TCachingStatus iCacheStatus;
|
|
354 |
|
|
355 |
/**
|
|
356 |
* Global that stores any error that occurs while caching
|
|
357 |
*/
|
|
358 |
TInt iCacheError;
|
|
359 |
|
|
360 |
/**
|
|
361 |
* plugin launcher, make the plugin instantiation async
|
|
362 |
*/
|
|
363 |
CIdle* iPluginLauncher;
|
|
364 |
};
|
|
365 |
|
|
366 |
|
|
367 |
#endif // C_PCS_ALGORITHM_1
|