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