author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:15:33 +0300 | |
branch | RCL_3 |
changeset 85 | 38bb213f60ba |
parent 74 | 6b5524b4f673 |
permissions | -rw-r--r-- |
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 |
// INCLUDES |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
19 |
#include <VPbkEng.rsg> |
63 | 20 |
#include <PtiEngine.h> |
21 |
#include <centralrepository.h> |
|
22 |
#include <AknFepInternalCRKeys.h> |
|
23 |
||
24 |
#include "CPcsAlgorithm2.h" |
|
25 |
#include "CPcsAlgorithm2Helper.h" |
|
26 |
#include "CPcsAlgorithm2MultiSearchHelper.h" |
|
27 |
#include "CPcsAlgorithm2Utils.h" |
|
28 |
#include "CPcsDebug.h" |
|
29 |
#include "CPcsCache.h" |
|
30 |
#include "CPcsKeyMap.h" |
|
31 |
#include "CPsData.h" |
|
32 |
#include "CWords.h" |
|
33 |
#include "CPsQuery.h" |
|
34 |
#include "CPsDataPluginInterface.h" |
|
35 |
#include "CPcsDefs.h" |
|
36 |
#include "FindUtilChineseECE.h" |
|
37 |
||
38 |
||
39 |
// ============================== MEMBER FUNCTIONS ============================ |
|
40 |
||
41 |
// ---------------------------------------------------------------------------- |
|
42 |
// CPcsAlgorithm2::NewL |
|
43 |
// Two Phase Construction |
|
44 |
// ---------------------------------------------------------------------------- |
|
45 |
CPcsAlgorithm2* CPcsAlgorithm2::NewL() |
|
46 |
{ |
|
47 |
PRINT ( _L("Enter CPcsAlgorithm2::NewL") ); |
|
48 |
||
49 |
CPcsAlgorithm2* self = new (ELeave) CPcsAlgorithm2(); |
|
50 |
CleanupStack::PushL(self); |
|
51 |
self->ConstructL(); |
|
52 |
CleanupStack::Pop(self); |
|
53 |
||
54 |
PRINT ( _L("End CPcsAlgorithm2::NewL") ); |
|
55 |
||
56 |
return self; |
|
57 |
} |
|
58 |
||
59 |
// ---------------------------------------------------------------------------- |
|
60 |
// CPcsAlgorithm2::CPcsAlgorithm2 |
|
61 |
// Two Phase Construction |
|
62 |
// ---------------------------------------------------------------------------- |
|
63 |
CPcsAlgorithm2::CPcsAlgorithm2() |
|
64 |
{ |
|
65 |
PRINT ( _L("Enter CPcsAlgorithm2::CPcsAlgorithm2") ); |
|
66 |
PRINT ( _L("End CPcsAlgorithm2::CPcsAlgorithm2") ); |
|
67 |
} |
|
68 |
||
69 |
// ---------------------------------------------------------------------------- |
|
70 |
// CPcsAlgorithm2::ConstructL |
|
71 |
// Two Phase Construction |
|
72 |
// ---------------------------------------------------------------------------- |
|
73 |
void CPcsAlgorithm2::ConstructL() |
|
74 |
{ |
|
75 |
PRINT ( _L("Enter CPcsAlgorithm2::ConstructL") ); |
|
76 |
||
77 |
iCacheStatus = ECachingNotStarted; // Starting status |
|
78 |
iCacheError = KErrNone; // No error |
|
79 |
iCacheCount = 0; // No data |
|
80 |
||
81 |
iFindUtilECE = CFindUtilChineseECE::NewL(this); |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
82 |
iFindUtil = CFindUtil::NewL(); |
63 | 83 |
|
84 |
iPluginLauncher = CIdle::NewL( CActive::EPriorityStandard ); |
|
85 |
||
86 |
// Define cache status property used to inform clients about the caching status. |
|
87 |
DefinePropertyL( EPsKeyCacheStatus ); |
|
88 |
||
89 |
// Define cache error property used to inform client about the errors. |
|
90 |
DefinePropertyL( EPsKeyCacheError ); |
|
91 |
||
92 |
// Define properties for notifying about cache updates |
|
93 |
DefinePropertyL( EPsKeyContactRemovedCounter ); |
|
94 |
DefinePropertyL( EPsKeyContactModifiedCounter ); |
|
95 |
DefinePropertyL( EPsKeyContactAddedCounter ); |
|
96 |
||
97 |
// Initialize key map and pti engine |
|
98 |
TInt keyMapErr = KErrNone; |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
99 |
TRAP( keyMapErr, iKeyMap = CPcsKeyMap::NewL( this )); |
63 | 100 |
if (keyMapErr != KErrNone) |
101 |
{ |
|
102 |
PRINT ( _L("**********************************************.")); |
|
103 |
PRINT1 ( _L("CPcsAlgorithm2::ConstructL() KeyMap construction error. The keymap crashed with error code %d."), keyMapErr ); |
|
104 |
PRINT ( _L("Please check the keypad/language for which keymap got crashed.") ); |
|
105 |
PRINT ( _L("**********************************************.")); |
|
106 |
} |
|
107 |
||
108 |
// Initialize helpers |
|
109 |
iHelper = CPcsAlgorithm2Helper::NewL(this); |
|
110 |
iMultiSearchHelper = CPcsAlgorithm2MultiSearchHelper::NewL(this); |
|
111 |
||
112 |
if(!iPluginLauncher->IsActive()) |
|
113 |
{ |
|
114 |
iPluginLauncher->Start(TCallBack(CPcsAlgorithm2::DoLaunchPluginsL, this)); |
|
115 |
} |
|
116 |
||
117 |
PRINT ( _L("End CPcsAlgorithm2::ConstructL") ); |
|
118 |
} |
|
119 |
||
120 |
// ---------------------------------------------------------------------------- |
|
121 |
// CPcsAlgorithm2::~CPcsAlgorithm2 |
|
122 |
// Destructor |
|
123 |
// ---------------------------------------------------------------------------- |
|
124 |
CPcsAlgorithm2::~CPcsAlgorithm2() |
|
125 |
{ |
|
126 |
PRINT ( _L("Enter CPcsAlgorithm2::~CPcsAlgorithm2") ); |
|
127 |
||
128 |
// Clear TLS |
|
129 |
Dll::SetTls(NULL); |
|
130 |
||
131 |
// Cleanup cache |
|
132 |
iPcsCache.ResetAndDestroy(); |
|
133 |
||
134 |
// Cleanup adapters interface and key handling |
|
135 |
delete iKeyMap; |
|
136 |
delete iPsDataPluginInterface; |
|
137 |
||
138 |
// Cleanup helpers |
|
139 |
delete iHelper; |
|
140 |
delete iMultiSearchHelper; |
|
141 |
||
142 |
delete iFindUtilECE; |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
143 |
delete iFindUtil; |
63 | 144 |
|
145 |
delete iPluginLauncher; |
|
146 |
||
147 |
PRINT ( _L("End CPcsAlgorithm2::~CPcsAlgorithm2") ); |
|
148 |
} |
|
149 |
||
150 |
// ---------------------------------------------------------------------------- |
|
151 |
// CPcsAlgorithm2::DefinePropertyL |
|
152 |
// Define a P&S property with given key under the internal category |
|
153 |
// UID of PCS. Leave if definition fails for any other reason than |
|
154 |
// key already existing. |
|
155 |
// ---------------------------------------------------------------------------- |
|
156 |
void CPcsAlgorithm2::DefinePropertyL( TPcsInternalKeyCacheStatus aPsKey ) |
|
157 |
{ |
|
158 |
TInt err = RProperty::Define( KPcsInternalUidCacheStatus, |
|
159 |
aPsKey, |
|
160 |
RProperty::EInt ); |
|
161 |
if ( err != KErrAlreadyExists ) |
|
162 |
{ |
|
163 |
User::LeaveIfError(err); |
|
164 |
} |
|
165 |
} |
|
166 |
||
167 |
// ---------------------------------------------------------------------------- |
|
168 |
// CPcsAlgorithm2::ReplaceZeroWithSpaceL |
|
169 |
// Replace first occurance of '0' in a sequence of '0's in ITU-T with space |
|
170 |
// ---------------------------------------------------------------------------- |
|
171 |
TBool CPcsAlgorithm2::ReplaceZeroWithSpaceL(CPsQuery& aQuery) |
|
172 |
{ |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
173 |
TChar space(KSpace); // ascii value for space |
63 | 174 |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
175 |
TBool queryModified = EFalse; |
63 | 176 |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
177 |
// Skip initial zeros in query |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
178 |
TInt index = 0; |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
179 |
for (index = 0; index < aQuery.Count() |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
180 |
&& aQuery.GetItemAtL(index).Character().GetNumericValue() == 0; ++index) |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
181 |
{ |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
182 |
} |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
183 |
|
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
184 |
if (aQuery.KeyboardModeL() != EQwerty) |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
185 |
{ |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
186 |
for (TInt beg = index; beg < aQuery.Count(); ++beg) |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
187 |
{ |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
188 |
CPsQueryItem& item = aQuery.GetItemAtL(beg); |
63 | 189 |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
190 |
if (item.Character().GetNumericValue() == 0 && item.Mode()== EItut) |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
191 |
{ |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
192 |
if (beg != 0) |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
193 |
{ |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
194 |
CPsQueryItem& item1 = aQuery.GetItemAtL(beg - 1); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
195 |
if (item1.Character().GetNumericValue() != 0 |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
196 |
&& !item1.Character().IsSpace()) |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
197 |
{ |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
198 |
item.SetCharacter(space); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
199 |
queryModified = ETrue; |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
200 |
} |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
201 |
} |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
202 |
else |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
203 |
{ |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
204 |
item.SetCharacter(space); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
205 |
queryModified = ETrue; |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
206 |
} |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
207 |
} |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
208 |
} |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
209 |
} |
63 | 210 |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
211 |
return queryModified; |
63 | 212 |
} |
213 |
||
214 |
// ---------------------------------------------------------------------------- |
|
215 |
// CPcsAlgorithm2::PerformSearchL |
|
216 |
// Search function for cache |
|
217 |
// ---------------------------------------------------------------------------- |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
218 |
void CPcsAlgorithm2::PerformSearchL(const CPsSettings& aSettings, CPsQuery& aQuery, |
63 | 219 |
RPointerArray<CPsClientData>& aSearchResults, |
220 |
RPointerArray<CPsPattern>& aSearchSeqs) |
|
221 |
{ |
|
222 |
PRINT ( _L("Enter CPcsAlgorithm2::PerformSearchL") ); |
|
223 |
||
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
224 |
__LATENCY_MARK ( _L("CPcsAlgorithm2::PerformSearchL") ); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
225 |
|
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
226 |
// Get the current language |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
227 |
TLanguage lang = User::Language(); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
228 |
|
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
229 |
// Check if the language is supported and the keyboard mode is not qwerty. |
63 | 230 |
|
231 |
// Local arrays to hold the search results |
|
232 |
RPointerArray<CPsData> tempSearchResults; |
|
233 |
RPointerArray<CPsData> tempSearchResults1; |
|
234 |
||
235 |
// -------------------- Perform the basic search -------------------------- |
|
236 |
||
237 |
DoSearchL(aSettings, aQuery, tempSearchResults, aSearchSeqs); |
|
238 |
||
239 |
// ------------------------------------------------------------------------ |
|
240 |
||
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
241 |
// ------------------- Perform advanced search if needed ------------------ |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
242 |
// Substitute "0" with space |
63 | 243 |
TBool queryModified = ReplaceZeroWithSpaceL(aQuery); |
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
244 |
|
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
245 |
// If query got modified and the search query translated to more than 1 query |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
246 |
// perform a multi search again |
63 | 247 |
if (queryModified) |
248 |
{ |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
249 |
// Split query |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
250 |
RPointerArray<CPsQuery> queryList = iMultiSearchHelper->MultiQueryL(aQuery); |
63 | 251 |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
252 |
// Perform seach again |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
253 |
if (queryList.Count() > 1) |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
254 |
{ |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
255 |
DoSearchL(aSettings, aQuery, tempSearchResults1, aSearchSeqs); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
256 |
} |
63 | 257 |
|
258 |
// Sort rule |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
259 |
TLinearOrder<CPsData> rule(CPcsAlgorithm2Utils::CompareDataBySortOrder); |
63 | 260 |
|
261 |
// Avoid duplicates and add new results |
|
262 |
TIdentityRelation<CPsData> identityRule(CPsData::CompareById); |
|
263 |
if (aSettings.GetSortType() != EAlphabetical) |
|
264 |
{ |
|
265 |
TInt insertPos = 0; |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
266 |
for (int i = 0; i < tempSearchResults1.Count(); i++) |
63 | 267 |
{ |
268 |
if (tempSearchResults.Find(tempSearchResults1[i], |
|
269 |
identityRule) == KErrNotFound) |
|
270 |
{ |
|
271 |
tempSearchResults.Insert(tempSearchResults1[i], insertPos); |
|
272 |
insertPos++; |
|
273 |
} |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
274 |
|
63 | 275 |
} |
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
276 |
|
63 | 277 |
} |
278 |
else |
|
279 |
{ |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
280 |
|
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
281 |
for (int i = 0; i < tempSearchResults1.Count(); i++) |
63 | 282 |
{ |
283 |
if (tempSearchResults.Find(tempSearchResults1[i], |
|
284 |
identityRule) == KErrNotFound) |
|
285 |
{ |
|
286 |
tempSearchResults.InsertInOrderAllowRepeats(tempSearchResults1[i], |
|
287 |
rule); |
|
288 |
} |
|
289 |
} |
|
290 |
} |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
291 |
|
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
292 |
queryList.ResetAndDestroy(); |
63 | 293 |
} |
294 |
// ------------------------------------------------------------------------ |
|
295 |
||
296 |
// ---------------------- Write result objects to the stream -------------- |
|
297 |
// Truncate the result set if required |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
298 |
TInt numToDisplay = aSettings.MaxResults(); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
299 |
TInt resultSet = tempSearchResults.Count(); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
300 |
|
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
301 |
if (resultSet > numToDisplay && numToDisplay != -1) |
63 | 302 |
{ |
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
303 |
// Copy the top N contents from tempSearchResults to the results stream |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
304 |
for (int i = 0; i < numToDisplay; i++) |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
305 |
{ |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
306 |
aSearchResults.Append(WriteClientDataL(*(tempSearchResults[i]))); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
307 |
} |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
308 |
|
63 | 309 |
} |
310 |
else |
|
311 |
{ |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
312 |
// Copy all the contents from tempSearchResults to the results stream |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
313 |
for (int i = 0; i < resultSet; i++) |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
314 |
{ |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
315 |
aSearchResults.Append(WriteClientDataL(*(tempSearchResults[i]))); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
316 |
} |
63 | 317 |
} |
318 |
// ------------------------------------------------------------------------ |
|
319 |
||
320 |
// Cleanup local results array |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
321 |
tempSearchResults.Reset(); // Don't destroy |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
322 |
tempSearchResults1.Reset(); // Don't destroy |
63 | 323 |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
324 |
__LATENCY_MARKEND ( _L("CPcsAlgorithm2::PerformSearchL") ); |
63 | 325 |
|
326 |
PRINT ( _L("End CPcsAlgorithm2::PerformSearchL") ); |
|
327 |
} |
|
328 |
||
329 |
// ---------------------------------------------------------------------------- |
|
330 |
// CPcsAlgorithm2::SearchInputL |
|
331 |
// Search function for input string |
|
332 |
// ---------------------------------------------------------------------------- |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
333 |
void CPcsAlgorithm2::SearchInputL(CPsQuery& aQuery, TDesC& aData, |
63 | 334 |
RPointerArray<TDesC>& aMatchSet, |
335 |
RArray<TPsMatchLocation>& aMatchLocation) |
|
336 |
{ |
|
337 |
PRINT ( _L("Enter CPcsAlgorithm2::SearchInputL") ); |
|
338 |
||
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
339 |
// Get the current language |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
340 |
TLanguage lang = User::Language(); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
341 |
|
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
342 |
// Check if the language is supported and the keyboard mode is not qwerty. |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
343 |
|
63 | 344 |
// Print input query for debug |
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
345 |
aQuery.PrintQuery(); |
63 | 346 |
|
347 |
// Print received search data |
|
348 |
PRINT1 ( _L("Search data received = %S"), &aData); |
|
349 |
||
350 |
// -------------------- Perform the basic search -------------------------- |
|
351 |
||
352 |
DoSearchInputL(aQuery, aData, aMatchSet, aMatchLocation); |
|
353 |
||
354 |
// ------------------------------------------------------------------------ |
|
355 |
||
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
356 |
// ------------------- Perform advanced search if needed ------------------ |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
357 |
// Substitute "0" with space |
63 | 358 |
TBool queryModified = ReplaceZeroWithSpaceL(aQuery); |
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
359 |
|
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
360 |
// If query got modified and the search query translated to more than 1 query |
63 | 361 |
// perform a multi search again |
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
362 |
if (queryModified) |
63 | 363 |
{ |
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
364 |
RPointerArray<CPsQuery> queryList = iMultiSearchHelper->MultiQueryL(aQuery); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
365 |
|
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
366 |
if (queryList.Count() > 1) |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
367 |
{ |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
368 |
DoSearchInputL(aQuery, aData, aMatchSet, aMatchLocation); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
369 |
} |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
370 |
|
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
371 |
queryList.ResetAndDestroy(); |
63 | 372 |
} |
373 |
// ------------------------------------------------------------------------ |
|
374 |
||
375 |
// Sort match set |
|
376 |
iHelper->SortSearchSeqsL(aMatchSet); |
|
377 |
||
378 |
PRINT ( _L("End CPcsAlgorithm2::SearchInputL") ); |
|
379 |
} |
|
380 |
||
381 |
// ---------------------------------------------------------------------------- |
|
382 |
// CPcsAlgorithm2::SearchMatchStringL |
|
383 |
// Search function for input string, result also as string |
|
384 |
// ---------------------------------------------------------------------------- |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
385 |
void CPcsAlgorithm2::SearchMatchStringL( CPsQuery& /*aSearchQuery*/, |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
386 |
TDesC& /*aSearchData*/, |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
387 |
TDes& /*aMatch*/ ) |
63 | 388 |
{ |
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
389 |
//NOT IMPLEMENTED YET |
63 | 390 |
} |
391 |
||
392 |
// ---------------------------------------------------------------------------- |
|
393 |
// CPcsAlgorithm2::DoSearchL |
|
394 |
// Search function helper |
|
395 |
// ---------------------------------------------------------------------------- |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
396 |
void CPcsAlgorithm2::DoSearchL(const CPsSettings& aSettings, CPsQuery& aQuery, |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
397 |
RPointerArray<CPsData>& searchResults, |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
398 |
RPointerArray<CPsPattern>& searchSeqs) |
63 | 399 |
{ |
400 |
PRINT ( _L("Enter CPcsAlgorithm2::DoSearchL") ); |
|
401 |
||
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
402 |
// Print query for debug |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
403 |
aQuery.PrintQuery(); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
404 |
|
63 | 405 |
// -(0)----------------- Check if group search is required --------------- |
406 |
RArray<TInt> contactsInGroup; |
|
407 |
RArray<TInt> groupIdArray; |
|
408 |
||
409 |
// Create a new settings instance |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
410 |
CPsSettings *tempSettings = aSettings.CloneL(); |
63 | 411 |
|
412 |
TBool isGroupSearch = IsGroupSearchL(*tempSettings, groupIdArray); |
|
413 |
||
414 |
if (isGroupSearch) |
|
415 |
{ |
|
416 |
// Replace groups URI with contacts DB URI in new search settings |
|
417 |
ReplaceGroupsUriL(*tempSettings); |
|
418 |
||
419 |
// List of contacts in this group |
|
420 |
GetContactsInGroupL(groupIdArray[0], contactsInGroup); |
|
421 |
} |
|
422 |
||
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
423 |
groupIdArray.Close(); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
424 |
|
63 | 425 |
// ----------------------------------------------------------------------- |
426 |
||
427 |
||
428 |
// Extract query list. |
|
429 |
RPointerArray<CPsQuery> queryList = iMultiSearchHelper->MultiQueryL(aQuery); |
|
430 |
||
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
431 |
// -(1)--------------------- No query return all contacts ---------------- |
63 | 432 |
if (queryList.Count() == 0) |
433 |
{ |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
434 |
GetAllContentsL(*tempSettings, searchResults); |
63 | 435 |
|
436 |
if (isGroupSearch) |
|
437 |
{ |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
438 |
FilterSearchResultsForGroupsL(contactsInGroup, searchResults); |
63 | 439 |
} |
440 |
} |
|
441 |
// ------------------------------------------------------------------------ |
|
442 |
||
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
443 |
|
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
444 |
// -(2)------------------------ Perform a single query search ------------- |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
445 |
if (queryList.Count() == 1) |
63 | 446 |
{ |
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
447 |
TInt mode = aQuery.KeyboardModeL(); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
448 |
|
63 | 449 |
CPsQuery* query = queryList[0]; |
450 |
||
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
451 |
iFindUtilECE->SetKeyboardMode(mode); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
452 |
|
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
453 |
switch (mode) |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
454 |
{ |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
455 |
case EItut: |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
456 |
|
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
457 |
PRINT ( _L("Query received is in ITU-T mode") ); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
458 |
|
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
459 |
// Search results |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
460 |
iHelper->SearchITUL(*tempSettings, *query, isGroupSearch, |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
461 |
contactsInGroup, searchResults, searchSeqs); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
462 |
|
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
463 |
break; |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
464 |
|
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
465 |
case EQwerty: |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
466 |
|
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
467 |
PRINT ( _L("Query received is in QWERTY mode") ); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
468 |
|
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
469 |
// Search results |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
470 |
iHelper->SearchQWERTYL(*tempSettings, *query, isGroupSearch, |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
471 |
contactsInGroup, searchResults, searchSeqs); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
472 |
|
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
473 |
break; |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
474 |
|
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
475 |
case EModeUndefined: |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
476 |
|
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
477 |
PRINT ( _L("Query received is in Mixed mode. Keyboard swap happened.") ); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
478 |
|
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
479 |
// Search results |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
480 |
iHelper->SearchMixedL(*tempSettings, *query, isGroupSearch, |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
481 |
contactsInGroup, searchResults, searchSeqs); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
482 |
|
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
483 |
break; |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
484 |
} |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
485 |
|
63 | 486 |
} |
487 |
// ------------------------------------------------------------------------ |
|
488 |
||
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
489 |
|
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
490 |
// -(3)---------------------------- Perform a multi query search ---------- |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
491 |
if (queryList.Count() > 1) // multiple query |
63 | 492 |
{ |
493 |
PRINT ( _L("Query received is in multiple. Performing a multi search.") ); |
|
494 |
||
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
495 |
TInt mode = aQuery.KeyboardModeL(); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
496 |
iFindUtilECE->SetKeyboardMode(mode); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
497 |
|
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
498 |
for (int i = 0; i < queryList.Count(); i++) |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
499 |
{ |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
500 |
TPtrC queryPtr = queryList[i]->QueryAsStringLC(); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
501 |
PRINT2 ( _L("Received Query, index = %d; value = %S"), i, &queryPtr ); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
502 |
CleanupStack::PopAndDestroy(); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
503 |
} |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
504 |
|
63 | 505 |
// Search results |
506 |
iMultiSearchHelper->SearchMultiL(*tempSettings, queryList, isGroupSearch, |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
507 |
contactsInGroup, searchResults, searchSeqs, |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
508 |
mode); |
63 | 509 |
} |
510 |
// ------------------------------------------------------------------------- |
|
511 |
||
512 |
// Cleanup |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
513 |
delete tempSettings; |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
514 |
tempSettings = NULL; |
63 | 515 |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
516 |
groupIdArray.Close(); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
517 |
contactsInGroup.Close(); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
518 |
queryList.ResetAndDestroy(); |
63 | 519 |
|
520 |
PRINT ( _L("End CPcsAlgorithm2::DoSearchL") ); |
|
521 |
} |
|
522 |
||
523 |
// ---------------------------------------------------------------------------- |
|
524 |
// CPcsAlgorithm2::DoSearchInputL |
|
525 |
// Search function helper |
|
526 |
// ---------------------------------------------------------------------------- |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
527 |
void CPcsAlgorithm2::DoSearchInputL(CPsQuery& aQuery, TDesC& aData, |
63 | 528 |
RPointerArray<TDesC>& aMatchSet, |
529 |
RArray<TPsMatchLocation>& aMatchLocation) |
|
530 |
{ |
|
531 |
||
532 |
PRINT ( _L("Enter CPcsAlgorithm2::DoSearchInputL") ); |
|
533 |
||
534 |
// Check if any seperator is there in the query |
|
535 |
RPointerArray<CPsQuery> queryList = iMultiSearchHelper->MultiQueryL(aQuery); |
|
536 |
||
537 |
// No query |
|
538 |
if (queryList.Count() == 0) |
|
539 |
{ |
|
540 |
PRINT ( _L("Query received is empty") ); |
|
541 |
return; |
|
542 |
} |
|
543 |
||
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
544 |
RPointerArray<HBufC> convertedQuery; |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
545 |
iMultiSearchHelper->ConvertQueryToListL(queryList, convertedQuery); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
546 |
|
63 | 547 |
// Single query |
548 |
if (queryList.Count() == 1) |
|
549 |
{ |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
550 |
iHelper->SearchMatchSeqL(convertedQuery[0], aData, aMatchSet, aQuery, |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
551 |
aMatchLocation); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
552 |
|
63 | 553 |
} |
554 |
||
555 |
if (queryList.Count() > 1) // multiple query |
|
556 |
{ |
|
557 |
PRINT ( _L("Query received is in multiple. Performing a multi search.") ); |
|
558 |
||
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
559 |
for (int i = 0; i < queryList.Count(); i++) |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
560 |
{ |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
561 |
TPtrC queryPtr = queryList[i]->QueryAsStringLC(); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
562 |
PRINT2 ( _L("Rceived Query, index = %d; value = %S"), i, &queryPtr ); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
563 |
CleanupStack::PopAndDestroy(); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
564 |
} |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
565 |
|
63 | 566 |
// Search results |
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
567 |
iMultiSearchHelper->SearchMatchSeqMultiL(queryList, aData, aMatchSet, |
63 | 568 |
aMatchLocation); |
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
569 |
|
63 | 570 |
} |
571 |
||
572 |
// Delete all the query elements |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
573 |
queryList.ResetAndDestroy(); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
574 |
convertedQuery.ResetAndDestroy(); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
575 |
|
63 | 576 |
PRINT ( _L("End CPcsAlgorithm2::DoSearchInputL") ); |
577 |
} |
|
578 |
||
579 |
// ---------------------------------------------------------------------------- |
|
580 |
// CPcsAlgorithm2::AddData |
|
581 |
// Add a data element to the pool |
|
582 |
// ---------------------------------------------------------------------------- |
|
583 |
void CPcsAlgorithm2::AddData(TDesC& aDataStore, CPsData* aData) |
|
584 |
{ |
|
585 |
TInt arrayIndex = GetCacheIndex(aDataStore); |
|
586 |
||
587 |
if (arrayIndex < 0) |
|
588 |
return; |
|
589 |
||
590 |
CPcsCache* cache = iPcsCache[arrayIndex]; |
|
591 |
||
592 |
// Fill the data store index |
|
593 |
TInt dataStoreIndex = FindStoreUri(aDataStore); |
|
594 |
if (dataStoreIndex >= 0) |
|
595 |
{ |
|
596 |
aData->SetUriId(dataStoreIndex); |
|
597 |
} |
|
598 |
else |
|
599 |
{ |
|
600 |
PRINT(_L("CPcsAlgorithm2::AddDataL Unknown data store")); |
|
601 |
return; |
|
602 |
} |
|
603 |
TRAPD(err, cache->AddToCacheL(*aData)); |
|
604 |
||
605 |
if (err != KErrNone) |
|
606 |
{ |
|
607 |
SetCachingError(aDataStore, err); |
|
608 |
} |
|
609 |
} |
|
610 |
||
611 |
// ---------------------------------------------------------------------------- |
|
612 |
// CPcsAlgorithm2::RemoveData |
|
613 |
// Remove a data element from the pool |
|
614 |
// ---------------------------------------------------------------------------- |
|
615 |
void CPcsAlgorithm2::RemoveData(TDesC &aDataStore, TInt aItemId) |
|
616 |
{ |
|
617 |
TInt arrayIndex = GetCacheIndex(aDataStore); |
|
618 |
||
619 |
if (arrayIndex < 0) |
|
620 |
return; |
|
621 |
||
622 |
CPcsCache* cache = iPcsCache[arrayIndex]; |
|
623 |
TRAPD(err, cache->RemoveFromCacheL(aItemId)); |
|
624 |
||
625 |
if (err != KErrNone) |
|
626 |
{ |
|
627 |
SetCachingError(aDataStore, err); |
|
628 |
} |
|
629 |
} |
|
630 |
||
631 |
// --------------------------------------------------------------------- |
|
632 |
// CPcsAlgorithm2::RemoveAll |
|
633 |
// Remove all the contacts from a datastore |
|
634 |
// --------------------------------------------------------------------- |
|
635 |
void CPcsAlgorithm2::RemoveAll(TDesC& aDataStore) |
|
636 |
{ |
|
637 |
TInt dataStoreIndex = GetCacheIndex(aDataStore); |
|
638 |
||
639 |
if (dataStoreIndex < 0) |
|
640 |
return; |
|
641 |
||
642 |
CPcsCache* cache = iPcsCache[dataStoreIndex]; |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
643 |
TRAPD(err, cache->RemoveAllFromCacheL()); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
644 |
|
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
645 |
if (err != KErrNone) |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
646 |
{ |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
647 |
SetCachingError(aDataStore, err); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
648 |
} |
63 | 649 |
} |
650 |
||
651 |
// ---------------------------------------------------------------------------- |
|
652 |
// CPcsAlgorithm2::GetCacheIndex |
|
653 |
// Return the cache index for a data store |
|
654 |
// ---------------------------------------------------------------------------- |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
655 |
TInt CPcsAlgorithm2::GetCacheIndex(TDesC& aDataStore) |
63 | 656 |
{ |
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
657 |
for (int i = 0; i < iPcsCache.Count(); i++) |
63 | 658 |
{ |
659 |
CPcsCache* cache = iPcsCache[i]; |
|
660 |
||
661 |
if (cache->GetURI().CompareC(aDataStore) == 0) |
|
662 |
return i; |
|
663 |
} |
|
664 |
||
665 |
return -1; |
|
666 |
} |
|
667 |
||
668 |
// ---------------------------------------------------------------------------- |
|
669 |
// CPcsAlgorithm2::AddDataStore |
|
670 |
// Adds a new store |
|
671 |
// ---------------------------------------------------------------------------- |
|
672 |
void CPcsAlgorithm2::AddDataStore(TDesC& aDataStore) |
|
673 |
{ |
|
674 |
// Check if the datastore cache already exists |
|
675 |
TInt index = GetCacheIndex(aDataStore); |
|
676 |
if (index != -1) |
|
677 |
{ |
|
678 |
// Already exists |
|
679 |
return; |
|
680 |
} |
|
681 |
||
682 |
// Create a new cache |
|
683 |
CPcsCache* cache = NULL; |
|
684 |
TRAPD(err, cache = CPcsCache::NewL( this, aDataStore, *iKeyMap, iCacheCount)); |
|
685 |
if (err != KErrNone) |
|
686 |
{ |
|
687 |
SetCachingError(aDataStore, err); |
|
688 |
return; |
|
689 |
} |
|
690 |
||
691 |
// Increment the cachecount |
|
692 |
iCacheCount++; |
|
693 |
||
694 |
RArray<TInt> dataFields; |
|
695 |
TRAP(err, iPsDataPluginInterface->GetSupportedDataFieldsL(cache->GetURI(), dataFields)); |
|
696 |
if (err != KErrNone) |
|
697 |
{ |
|
698 |
SetCachingError(aDataStore, err); |
|
699 |
return; |
|
700 |
} |
|
701 |
cache->SetDataFields(dataFields); |
|
702 |
||
703 |
// Check if sort order is persisted already |
|
704 |
RArray<TInt> sortOrder; |
|
705 |
TRAP(err, ReadSortOrderFromCenRepL(*(cache->GetUri()), sortOrder)); |
|
706 |
if (err != KErrNone) |
|
707 |
{ |
|
708 |
SetCachingError(aDataStore, err); |
|
709 |
return; |
|
710 |
} |
|
711 |
||
712 |
if (sortOrder.Count() == 0) |
|
713 |
{ |
|
714 |
cache->SetSortOrder(dataFields); // Initial sort order |
|
715 |
} |
|
716 |
else |
|
717 |
{ |
|
718 |
cache->SetSortOrder(sortOrder); // Persisted sort order |
|
719 |
} |
|
720 |
||
721 |
sortOrder.Close(); |
|
722 |
dataFields.Close(); |
|
723 |
||
724 |
iPcsCache.Append(cache); |
|
725 |
||
726 |
TRAP(err, iPsDataPluginInterface->RequestForDataL(aDataStore)); |
|
727 |
if (err != KErrNone) |
|
728 |
{ |
|
729 |
SetCachingError(aDataStore, err); |
|
730 |
UpdateCachingStatus(aDataStore, ECachingCompleteWithErrors); |
|
731 |
return; |
|
732 |
} |
|
733 |
} |
|
734 |
||
735 |
// ---------------------------------------------------------------------------- |
|
736 |
// CPcsAlgorithm2::RemoveDataStore |
|
737 |
// Removes an existing data store |
|
738 |
// ---------------------------------------------------------------------------- |
|
739 |
void CPcsAlgorithm2::RemoveDataStore(TDesC& aDataStore) |
|
740 |
{ |
|
741 |
for (int i = 0; i < iPcsCache.Count(); i++) |
|
742 |
{ |
|
743 |
CPcsCache* cache = iPcsCache[i]; |
|
744 |
||
745 |
if (cache->GetURI().CompareC(aDataStore) == 0) |
|
746 |
{ |
|
747 |
delete iPcsCache[i]; |
|
748 |
iPcsCache.Remove(i); |
|
749 |
iCacheCount--; |
|
750 |
} |
|
751 |
} |
|
752 |
} |
|
753 |
||
754 |
// ---------------------------------------------------------------------------- |
|
755 |
// CPcsAlgorithm2::IsLanguageSupportedL |
|
756 |
// Returns ETrue if this language is supported |
|
757 |
// ---------------------------------------------------------------------------- |
|
758 |
TBool CPcsAlgorithm2::IsLanguageSupportedL(TUint32 aLang) |
|
759 |
{ |
|
760 |
return iKeyMap->IsLanguageSupportedL(aLang); |
|
761 |
} |
|
762 |
||
763 |
// ---------------------------------------------------------------------------- |
|
764 |
// CPcsAlgorithm2::GetUriForIdL |
|
765 |
// Get the URI string for this internal id |
|
766 |
// ---------------------------------------------------------------------------- |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
767 |
TDesC& CPcsAlgorithm2::GetUriForIdL(TUint8 aUriId) |
63 | 768 |
{ |
769 |
TBool found = EFalse; |
|
770 |
TInt i = 0; |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
771 |
|
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
772 |
for (i = 0; i < iPcsCache.Count(); i++) |
63 | 773 |
{ |
774 |
if (iPcsCache[i]->GetUriId() == aUriId) |
|
775 |
{ |
|
776 |
found = ETrue; |
|
777 |
break; |
|
778 |
} |
|
779 |
} |
|
780 |
||
781 |
if (!found) |
|
782 |
{ |
|
783 |
User::Leave(KErrNotFound); |
|
784 |
} |
|
785 |
||
786 |
return *(iPcsCache[i]->GetUri()); |
|
787 |
} |
|
788 |
||
789 |
// ---------------------------------------------------------------------------- |
|
790 |
// CPcsAlgorithm2::FindStoreUri |
|
791 |
// Checks if this store exists |
|
792 |
// ---------------------------------------------------------------------------- |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
793 |
TInt CPcsAlgorithm2::FindStoreUri(TDesC& aDataStore) |
63 | 794 |
{ |
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
795 |
for (int i = 0; i < iPcsCache.Count(); i++) |
63 | 796 |
{ |
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
797 |
if (aDataStore.CompareC(*(iPcsCache[i]->GetUri())) == 0) |
63 | 798 |
{ |
799 |
return i; |
|
800 |
} |
|
801 |
} |
|
802 |
||
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
803 |
return -1; |
63 | 804 |
} |
805 |
||
806 |
// ---------------------------------------------------------------------------- |
|
807 |
// CPcsAlgorithm2::UpdateCachingStatus |
|
808 |
// Update caching status |
|
809 |
// ---------------------------------------------------------------------------- |
|
810 |
void CPcsAlgorithm2::UpdateCachingStatus(TDesC& aDataStore, TInt aStatus) |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
811 |
{ |
63 | 812 |
PRINT ( _L("Enter CPcsAlgorithm2::UpdateCachingStatus") ); |
813 |
||
814 |
// Handle data store update events |
|
815 |
if ( aStatus == ECacheUpdateContactRemoved || |
|
816 |
aStatus == ECacheUpdateContactModified || |
|
817 |
aStatus == ECacheUpdateContactAdded ) |
|
818 |
{ |
|
819 |
HandleCacheUpdated( static_cast<TCachingStatus>(aStatus) ); |
|
820 |
return; |
|
821 |
} |
|
822 |
||
823 |
// If not a cache update event, then this event is related to the initial |
|
824 |
// cache construction. |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
825 |
TInt index = FindStoreUri(aDataStore); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
826 |
iPcsCache[index]->UpdateCacheStatus(aStatus); |
63 | 827 |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
828 |
// Check if any error occurred |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
829 |
// If so, update the cache status, Set the property and return |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
830 |
if (aStatus < 0) |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
831 |
{ |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
832 |
SetCachingError(aDataStore, aStatus); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
833 |
//return; |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
834 |
} |
63 | 835 |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
836 |
//store the index for firstname and lastname |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
837 |
if (aStatus == ECachingComplete) |
63 | 838 |
{ |
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
839 |
RArray<TInt> dataFields; |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
840 |
iPcsCache[index]->GetDataFields(dataFields); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
841 |
|
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
842 |
for (int i = 0; i < dataFields.Count(); i++) |
63 | 843 |
{ |
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
844 |
if (dataFields[i] == R_VPBK_FIELD_TYPE_FIRSTNAME) |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
845 |
{ |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
846 |
iFirstNameIndex = i; |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
847 |
} |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
848 |
else if (dataFields[i] == R_VPBK_FIELD_TYPE_LASTNAME) |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
849 |
{ |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
850 |
iLastNameIndex = i; |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
851 |
} |
63 | 852 |
} |
853 |
} |
|
854 |
||
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
855 |
// No error occurred |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
856 |
TCachingStatus status = ECachingComplete; |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
857 |
TBool atLeastOneStoreCachingCompleteWithErrors(EFalse); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
858 |
for (TInt i = 0; i < iPcsCache.Count(); i++) |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
859 |
{ |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
860 |
if (iPcsCache[i]->GetCacheStatus() == ECachingComplete) |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
861 |
{ |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
862 |
continue; |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
863 |
} |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
864 |
else if (iPcsCache[i]->GetCacheStatus() == ECachingCompleteWithErrors) |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
865 |
{ |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
866 |
atLeastOneStoreCachingCompleteWithErrors = ETrue; |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
867 |
continue; |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
868 |
} |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
869 |
else |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
870 |
{ |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
871 |
status = ECachingInProgress; |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
872 |
break; |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
873 |
} |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
874 |
} |
63 | 875 |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
876 |
if (status == ECachingComplete) |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
877 |
{ |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
878 |
// See if any error occurred while caching |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
879 |
// If so, change the status to ECachingCompleteWithErrors |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
880 |
if ((iCacheError != KErrNone) || (atLeastOneStoreCachingCompleteWithErrors)) |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
881 |
{ |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
882 |
status = ECachingCompleteWithErrors; |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
883 |
} |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
884 |
} |
63 | 885 |
|
886 |
// Check if status changed |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
887 |
if (status != iCacheStatus) |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
888 |
{ |
63 | 889 |
iCacheStatus = status; |
890 |
RProperty::Set(KPcsInternalUidCacheStatus, EPsKeyCacheStatus, iCacheStatus ); |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
891 |
} |
63 | 892 |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
893 |
PRINT ( _L("End CPcsAlgorithm2::UpdateCachingStatus") ); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
894 |
} |
63 | 895 |
|
896 |
// ---------------------------------------------------------------------------- |
|
897 |
// CPcsAlgorithm2::SetCachingError |
|
898 |
// Updates cachinge error |
|
899 |
// ---------------------------------------------------------------------------- |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
900 |
void CPcsAlgorithm2::SetCachingError(TDesC& aDataStore, TInt aError) |
63 | 901 |
{ |
902 |
PRINT2 ( _L("SetCachingError::URI %S ERROR %d"), &aDataStore, aError ); |
|
903 |
||
904 |
iCacheError = aError; |
|
905 |
RProperty::Set( KPcsInternalUidCacheStatus, EPsKeyCacheError, iCacheError ); |
|
906 |
} |
|
907 |
||
908 |
// ---------------------------------------------------------------------------- |
|
909 |
// CPcsAlgorithm2::GetAllContentsL |
|
910 |
// Returns all the contents of a store |
|
911 |
// ---------------------------------------------------------------------------- |
|
912 |
void CPcsAlgorithm2::GetAllContentsL(const CPsSettings& aSettings, |
|
913 |
RPointerArray<CPsData>& aResults) |
|
914 |
{ |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
915 |
__LATENCY_MARK ( _L("CPcsAlgorithm2::GetAllContentsL") ); |
63 | 916 |
|
917 |
PRINT ( _L("Enter CPcsAlgorithm2::GetAllContentsL") ); |
|
918 |
||
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
919 |
// Get the data stores |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
920 |
RPointerArray<TDesC> aDataStores; |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
921 |
aSettings.SearchUrisL(aDataStores); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
922 |
|
63 | 923 |
// To hold array of results from different data stores |
924 |
typedef RPointerArray<CPsData> CPSDATA_R_PTR_ARRAY; |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
925 |
RPointerArray<CPSDATA_R_PTR_ARRAY> iSearchResultsArr; |
63 | 926 |
|
927 |
// Get all contacts for each data store |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
928 |
for (int dsIndex = 0; dsIndex < aDataStores.Count(); dsIndex++) |
63 | 929 |
{ |
930 |
RPointerArray<CPsData> *temp = new (ELeave) RPointerArray<CPsData> (); |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
931 |
iSearchResultsArr.Append(temp); |
63 | 932 |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
933 |
TInt arrayIndex = GetCacheIndex(*(aDataStores[dsIndex])); |
63 | 934 |
if (arrayIndex < 0) |
935 |
{ |
|
936 |
continue; |
|
937 |
} |
|
938 |
||
939 |
CPcsCache* cache = GetCache(arrayIndex); |
|
940 |
||
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
941 |
cache->GetAllContentsL(*(iSearchResultsArr[dsIndex])); |
63 | 942 |
} |
943 |
||
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
944 |
aDataStores.ResetAndDestroy(); |
63 | 945 |
|
946 |
// Merge the results from different data stores |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
947 |
CPcsAlgorithm2Utils::FormCompleteSearchResultsL(iSearchResultsArr, aResults); |
63 | 948 |
|
949 |
// Cleanup the local arrays |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
950 |
for (TInt i = 0; i < iSearchResultsArr.Count(); i++) |
63 | 951 |
{ |
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
952 |
iSearchResultsArr[i]->Reset(); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
953 |
delete iSearchResultsArr[i]; |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
954 |
iSearchResultsArr[i] = NULL; |
63 | 955 |
} |
956 |
||
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
957 |
iSearchResultsArr.Reset(); |
63 | 958 |
|
959 |
PRINT1 ( _L("Number of results = %d"), aResults.Count() ); |
|
960 |
||
961 |
PRINT ( _L("End CPcsAlgorithm2::GetAllContentsL") ); |
|
962 |
||
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
963 |
__LATENCY_MARKEND ( _L("CPcsAlgorithm2::GetAllContentsL") ); |
63 | 964 |
} |
965 |
||
966 |
// ---------------------------------------------------------------------------- |
|
967 |
// CPcsAlgorithm2::IsGroupSearchL |
|
968 |
// Checks if a group search is required |
|
969 |
// ---------------------------------------------------------------------------- |
|
970 |
TBool CPcsAlgorithm2::IsGroupSearchL(CPsSettings& aSettings, |
|
971 |
RArray<TInt>& aGroupIdArray) |
|
972 |
{ |
|
973 |
PRINT ( _L("Enter CPcsAlgorithm2::IsGroupSearchL") ); |
|
974 |
||
975 |
// Get the groupIds in the seach settings |
|
976 |
aSettings.GetGroupIdsL(aGroupIdArray); |
|
977 |
||
978 |
// Get the current URIs defined in settings |
|
979 |
RPointerArray<TDesC> searchUris; |
|
980 |
aSettings.SearchUrisL(searchUris); |
|
981 |
||
982 |
if (aGroupIdArray.Count() && (searchUris.Count() > aGroupIdArray.Count())) |
|
983 |
{ |
|
984 |
// There is an error, either there are more than one groups |
|
985 |
// or the settings contain a combination of group/non-group Uris |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
986 |
searchUris.ResetAndDestroy(); |
63 | 987 |
aGroupIdArray.Close(); |
988 |
User::Leave(KErrArgument); |
|
989 |
} |
|
990 |
||
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
991 |
searchUris.ResetAndDestroy(); |
63 | 992 |
|
993 |
PRINT ( _L("End CPcsAlgorithm2::IsGroupSearchL") ); |
|
994 |
||
995 |
if (aGroupIdArray.Count() == 1) |
|
996 |
return ETrue; |
|
997 |
||
998 |
return EFalse; |
|
999 |
} |
|
1000 |
||
1001 |
// ---------------------------------------------------------------------------- |
|
1002 |
// CPcsAlgorithm2::ReplaceGroupsUriL |
|
1003 |
// Replace groups uri to contacts uri |
|
1004 |
// ---------------------------------------------------------------------------- |
|
1005 |
void CPcsAlgorithm2::ReplaceGroupsUriL(CPsSettings& aSettings) |
|
1006 |
{ |
|
1007 |
RPointerArray<TDesC> uri; |
|
1008 |
||
1009 |
// Set contacts db uri |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1010 |
HBufC* cntdb = HBufC::NewL(KBufferMaxLen); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1011 |
cntdb->Des().Copy(KVPbkDefaultCntDbURI); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1012 |
uri.Append(cntdb); |
63 | 1013 |
aSettings.SetSearchUrisL(uri); |
1014 |
||
1015 |
// Cleanup |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1016 |
uri.ResetAndDestroy(); |
63 | 1017 |
} |
1018 |
||
1019 |
// ---------------------------------------------------------------------------- |
|
1020 |
// CPcsAlgorithm2::FilterSearchResultsForGroupsL |
|
1021 |
// Filters the results that belong to a group |
|
1022 |
// ---------------------------------------------------------------------------- |
|
1023 |
void CPcsAlgorithm2::FilterSearchResultsForGroupsL(RArray<TInt>& contactsInGroup, |
|
1024 |
RPointerArray<CPsData>& aSearchResults) |
|
1025 |
{ |
|
1026 |
PRINT ( _L("Enter CPcsAlgorithm2::FilterSearchResultsForGroupsL") ); |
|
1027 |
||
1028 |
// for each search result |
|
1029 |
// Note: aSearchResults.Count() is to be checked everytime, |
|
1030 |
// since the elements are being removed dynamically. |
|
1031 |
for (TInt j = 0; j < aSearchResults.Count(); j++) |
|
1032 |
{ |
|
1033 |
TBool includeResult = EFalse; |
|
1034 |
||
1035 |
if (contactsInGroup.Find(aSearchResults[j]->Id()) != KErrNotFound) |
|
1036 |
{ |
|
1037 |
includeResult = ETrue; |
|
1038 |
} |
|
1039 |
||
1040 |
if (includeResult == EFalse) |
|
1041 |
{ |
|
1042 |
aSearchResults.Remove(j); |
|
1043 |
j--; // j is decremented, since that object is removed |
|
1044 |
} |
|
1045 |
} |
|
1046 |
||
1047 |
PRINT ( _L("End CPcsAlgorithm2::FilterSearchResultsForGroupsL") ); |
|
1048 |
} |
|
1049 |
||
1050 |
// ---------------------------------------------------------------------------- |
|
1051 |
// CPcsAlgorithm2::GetContactsInGroupL |
|
1052 |
// Recover contacts that belong to a group |
|
1053 |
// ---------------------------------------------------------------------------- |
|
1054 |
void CPcsAlgorithm2::GetContactsInGroupL(TInt aGroupId, RArray<TInt>& aGroupContactIds) |
|
1055 |
{ |
|
1056 |
// Clear results array |
|
1057 |
aGroupContactIds.Reset(); |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1058 |
|
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1059 |
// Groups URI |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1060 |
HBufC* groupURI = HBufC::NewL(50); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1061 |
groupURI->Des().Copy(KVPbkDefaultGrpDbURI); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1062 |
|
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1063 |
// Cache Index |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1064 |
TInt cacheIndex = GetCacheIndex(*groupURI); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1065 |
|
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1066 |
// Cleanup |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1067 |
delete groupURI; |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1068 |
groupURI = NULL; |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1069 |
|
63 | 1070 |
// Get the groups contact ids |
1071 |
if (cacheIndex != -1) |
|
1072 |
{ |
|
1073 |
RPointerArray<CPsData> groups; |
|
1074 |
||
1075 |
// Get all groups |
|
1076 |
iPcsCache[cacheIndex]->GetAllContentsL(groups); |
|
1077 |
||
1078 |
// Get all contacts in group |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1079 |
for (TInt i = 0; i < groups.Count(); i++) |
63 | 1080 |
{ |
1081 |
if (groups[i]->Id() == aGroupId) |
|
1082 |
{ |
|
1083 |
groups[i]->IntDataExt(aGroupContactIds); // All contacts in group |
|
1084 |
break; |
|
1085 |
} |
|
1086 |
} |
|
1087 |
||
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1088 |
groups.Reset(); |
63 | 1089 |
} |
1090 |
} |
|
1091 |
||
1092 |
// ---------------------------------------------------------------------------- |
|
1093 |
// CPcsAlgorithm2::GetDataOrderL |
|
1094 |
// |
|
1095 |
// ---------------------------------------------------------------------------- |
|
1096 |
void CPcsAlgorithm2::GetDataOrderL(TDesC& aURI, RArray<TInt>& aDataOrder) |
|
1097 |
{ |
|
1098 |
PRINT ( _L("End CPcsAlgorithm2::GetDataOrderL") ); |
|
1099 |
||
1100 |
TInt arrayIndex = -1; |
|
1101 |
||
1102 |
if (CPcsAlgorithm2Utils::IsGroupUri(aURI)) |
|
1103 |
{ |
|
1104 |
// If search in a group uri, use contacts db |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1105 |
TBuf<255> cntdb(KVPbkDefaultCntDbURI); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1106 |
arrayIndex = GetCacheIndex(cntdb); |
63 | 1107 |
} |
1108 |
else |
|
1109 |
{ |
|
1110 |
arrayIndex = GetCacheIndex(aURI); |
|
1111 |
} |
|
1112 |
||
1113 |
if (arrayIndex < 0) |
|
1114 |
{ |
|
1115 |
return; |
|
1116 |
} |
|
1117 |
||
1118 |
CPcsCache* cache = iPcsCache[arrayIndex]; |
|
1119 |
||
1120 |
aDataOrder.Reset(); |
|
1121 |
||
1122 |
// Get the data fields for this cache |
|
1123 |
cache->GetDataFields(aDataOrder); |
|
1124 |
||
1125 |
PRINT ( _L("End CPcsAlgorithm2::GetDataOrderL") ); |
|
1126 |
} |
|
1127 |
||
1128 |
// ---------------------------------------------------------------------------- |
|
1129 |
// CPcsAlgorithm2::GetSortOrderL |
|
1130 |
// |
|
1131 |
// ---------------------------------------------------------------------------- |
|
1132 |
void CPcsAlgorithm2::GetSortOrderL(TDesC& aURI, RArray<TInt>& aDataOrder) |
|
1133 |
{ |
|
1134 |
PRINT ( _L("End CPcsAlgorithm2::GetSortOrderL") ); |
|
1135 |
||
1136 |
TInt arrayIndex = -1; |
|
1137 |
||
1138 |
if (CPcsAlgorithm2Utils::IsGroupUri(aURI)) |
|
1139 |
{ |
|
1140 |
// If search in a group uri, use contacts db |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1141 |
TBuf<255> cntdb(KVPbkDefaultCntDbURI); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1142 |
arrayIndex = GetCacheIndex(cntdb); |
63 | 1143 |
} |
1144 |
else |
|
1145 |
{ |
|
1146 |
arrayIndex = GetCacheIndex(aURI); |
|
1147 |
} |
|
1148 |
||
1149 |
if (arrayIndex < 0) |
|
1150 |
{ |
|
1151 |
return; |
|
1152 |
} |
|
1153 |
||
1154 |
CPcsCache* cache = iPcsCache[arrayIndex]; |
|
1155 |
||
1156 |
aDataOrder.Reset(); |
|
1157 |
||
1158 |
// Get the data fields for this cache |
|
1159 |
cache->GetSortOrder(aDataOrder); |
|
1160 |
||
1161 |
PRINT ( _L("End CPcsAlgorithm2::GetSortOrderL") ); |
|
1162 |
} |
|
1163 |
||
1164 |
// ---------------------------------------------------------------------------- |
|
1165 |
// CPcsAlgorithm2::ChangeSortOrderL |
|
1166 |
// |
|
1167 |
// ---------------------------------------------------------------------------- |
|
1168 |
void CPcsAlgorithm2::ChangeSortOrderL(TDesC& aURI, RArray<TInt>& aSortOrder) |
|
1169 |
{ |
|
1170 |
PRINT ( _L("Enter CPcsAlgorithm2::ChangeSortOrderL.") ); |
|
1171 |
||
1172 |
PRINT ( _L("CPcsAlgorithm2::ChangeSortOrderL. Sort order change received.") ); |
|
1173 |
PRINT1 ( _L("URI = %S"), &aURI ); |
|
1174 |
||
1175 |
// If URI is search in a group URI return |
|
1176 |
if (CPcsAlgorithm2Utils::IsGroupUri(aURI)) |
|
1177 |
{ |
|
1178 |
PRINT ( _L("CPcsAlgorithm2::ChangeSortOrderL. Sort order change not supported.") ); |
|
1179 |
return; |
|
1180 |
} |
|
1181 |
||
1182 |
// Check if a cache exists |
|
1183 |
TInt arrayIndex = GetCacheIndex(aURI); |
|
1184 |
if (arrayIndex < 0) |
|
1185 |
{ |
|
1186 |
PRINT ( _L("CPcsAlgorithm2::ChangeSortOrderL. Cache for URI doesn't exist.") ); |
|
1187 |
return; |
|
1188 |
} |
|
1189 |
||
1190 |
// Cache instance for this URI |
|
1191 |
CPcsCache* cache = iPcsCache[arrayIndex]; |
|
1192 |
||
1193 |
// Check if received sort order is same as before |
|
1194 |
RArray<TInt> mySortOrder; |
|
1195 |
cache->GetSortOrder(mySortOrder); |
|
1196 |
||
1197 |
if (aSortOrder.Count() == mySortOrder.Count()) |
|
1198 |
{ |
|
1199 |
TBool same = ETrue; |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1200 |
for (int i = 0; i < mySortOrder.Count(); i++) |
63 | 1201 |
{ |
1202 |
if (mySortOrder[i] != aSortOrder[i]) |
|
1203 |
{ |
|
1204 |
same = EFalse; |
|
1205 |
break; |
|
1206 |
} |
|
1207 |
} |
|
1208 |
||
1209 |
if (same) |
|
1210 |
{ |
|
1211 |
PRINT ( _L("CPcsAlgorithm2::ChangeSortOrderL. Same sort order received. Ignoring ...") ); |
|
1212 |
PRINT ( _L("End CPcsAlgorithm2::ChangeSortOrderL.") ); |
|
1213 |
mySortOrder.Reset(); |
|
1214 |
return; |
|
1215 |
} |
|
1216 |
} |
|
1217 |
||
1218 |
mySortOrder.Reset(); |
|
1219 |
||
1220 |
PRINT ( _L("CPcsAlgorithm2::ChangeSortOrderL. New sort order received. Refreshing ...") ); |
|
1221 |
||
1222 |
// Set the new sort order on the cache |
|
1223 |
cache->SetSortOrder(aSortOrder); |
|
1224 |
||
1225 |
// Persist the changes in sort order |
|
1226 |
WriteSortOrderToCenRepL(aURI, aSortOrder); |
|
1227 |
||
1228 |
// Request for data again |
|
1229 |
TInt err = KErrNone; |
|
1230 |
TRAP(err, cache->ResortdataInPoolsL()); |
|
1231 |
if (err != KErrNone) |
|
1232 |
{ |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1233 |
PRINT ( _L("CPcsAlgorithm1::ChangeSortOrderL() Set Caching Error ") ); |
63 | 1234 |
SetCachingError(aURI, err); |
1235 |
UpdateCachingStatus(aURI, ECachingCompleteWithErrors); |
|
1236 |
return; |
|
1237 |
} |
|
1238 |
||
1239 |
PRINT ( _L("End CPcsAlgorithm2::ChangeSortOrderL.") ); |
|
1240 |
} |
|
1241 |
||
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1242 |
// ---------------------------------------------------------------------------- |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1243 |
// CPcsAlgorithm2::GetAdaptiveGridL |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1244 |
// |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1245 |
// ---------------------------------------------------------------------------- |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1246 |
void CPcsAlgorithm2::GetAdaptiveGridL( const MDesCArray& /*aURIs*/, |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1247 |
const TBool /*aCompanyName*/, |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1248 |
TDes& /*aAdaptiveGrid*/ ) |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1249 |
{ |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1250 |
//NOT IMPLEMENTED YET |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1251 |
} |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1252 |
|
63 | 1253 |
// --------------------------------------------------------------------------------- |
1254 |
// Read the persisted sort order from the central repository |
|
1255 |
// Persisted sort order is of form URI Field1 Field2 Field3 .. FieldN (space delimited) |
|
1256 |
// --------------------------------------------------------------------------------- |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1257 |
void CPcsAlgorithm2::ReadSortOrderFromCenRepL(TDesC& aURI, RArray<TInt>& aSortOrder) |
63 | 1258 |
{ |
1259 |
PRINT ( _L("Enter CPcsAlgorithm2::ReadSortOrderFromCenRepL.") ); |
|
1260 |
||
1261 |
aSortOrder.Reset(); |
|
1262 |
||
1263 |
CRepository *repository = CRepository::NewL(KCRUidPSSortOrder); |
|
1264 |
||
1265 |
// Read the sort order from cenrep |
|
1266 |
TBuf<KCRMaxLen> str; |
|
1267 |
||
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1268 |
for (TInt i(KCenrepFieldsStartKey); i < KCenrepFieldsStartKey |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1269 |
+ KCenrepNumberOfFieldsCount; i++) |
63 | 1270 |
{ |
1271 |
TInt err = repository->Get(i, str); |
|
1272 |
||
1273 |
if (KErrNone != err) |
|
1274 |
{ |
|
1275 |
break; |
|
1276 |
} |
|
1277 |
||
1278 |
if (str != KNullDesC) |
|
1279 |
{ |
|
1280 |
TLex lex(str); |
|
1281 |
||
1282 |
// Extract the URI |
|
1283 |
TPtrC token = lex.NextToken(); |
|
1284 |
||
1285 |
if (aURI.Compare(token) == 0) |
|
1286 |
{ |
|
1287 |
// Extract the sort order |
|
1288 |
token.Set(lex.NextToken()); |
|
1289 |
||
1290 |
while (token.Length() != 0) |
|
1291 |
{ |
|
1292 |
TLex lex1(token); |
|
1293 |
||
1294 |
TInt intVal; |
|
1295 |
TInt err = lex1.Val(intVal); |
|
1296 |
||
1297 |
if (KErrNone == err) |
|
1298 |
{ |
|
1299 |
aSortOrder.Append(intVal); |
|
1300 |
} |
|
1301 |
||
1302 |
// Next token |
|
1303 |
token.Set(lex.NextToken()); |
|
1304 |
} |
|
1305 |
||
1306 |
break; |
|
1307 |
} |
|
1308 |
} |
|
1309 |
||
1310 |
} |
|
1311 |
||
1312 |
delete repository; |
|
1313 |
||
1314 |
PRINT ( _L("End CPcsAlgorithm2::ReadSortOrderFromCenRepL.") ); |
|
1315 |
} |
|
1316 |
||
1317 |
// --------------------------------------------------------------------------------- |
|
1318 |
// Write the sort order into the central repository |
|
1319 |
// Persisted sort order is of form URI Field1 Field2 Field3 .. FieldN (space delimited) |
|
1320 |
// --------------------------------------------------------------------------------- |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1321 |
void CPcsAlgorithm2::WriteSortOrderToCenRepL(TDesC& aURI, RArray<TInt>& aSortOrder) |
63 | 1322 |
{ |
1323 |
PRINT ( _L("Enter CPcsAlgorithm2::WriteSortOrderToCenRepL.") ); |
|
1324 |
||
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1325 |
CRepository *repository = CRepository::NewL(KCRUidPSSortOrder); |
63 | 1326 |
|
1327 |
// Check if there an entry for this URI in cenrep |
|
1328 |
TBuf<KCRMaxLen> str; |
|
1329 |
TInt keyIndex = -1; |
|
1330 |
||
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1331 |
for (TInt i(KCenrepFieldsStartKey); i < KCenrepFieldsStartKey |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1332 |
+ KCenrepNumberOfFieldsCount; i++) |
63 | 1333 |
{ |
1334 |
TInt err = repository->Get(i, str); |
|
1335 |
||
1336 |
if (KErrNone != err) |
|
1337 |
{ |
|
1338 |
PRINT ( _L("CPcsAlgorithm2::WriteSortOrderToCenRepL. cenrep error.") ); |
|
1339 |
return; |
|
1340 |
} |
|
1341 |
||
1342 |
if (str != KNullDesC) |
|
1343 |
{ |
|
1344 |
TLex lex(str); |
|
1345 |
||
1346 |
// Extract the URI |
|
1347 |
TPtrC token = lex.NextToken(); |
|
1348 |
||
1349 |
if (aURI.Compare(token) == 0) |
|
1350 |
{ |
|
1351 |
keyIndex = i; // i has the key index for this URI |
|
1352 |
break; |
|
1353 |
} |
|
1354 |
} |
|
1355 |
} |
|
1356 |
||
1357 |
// No entry for this URI in cenrep |
|
1358 |
// Find the next free location in cenrep |
|
1359 |
if (keyIndex == -1) |
|
1360 |
{ |
|
1361 |
// Find the next free key index |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1362 |
for (TInt i(KCenrepFieldsStartKey); i < KCenrepFieldsStartKey |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1363 |
+ KCenrepNumberOfFieldsCount; i++) |
63 | 1364 |
{ |
1365 |
TInt err = repository->Get(i, str); |
|
1366 |
||
1367 |
if (KErrNone != err) |
|
1368 |
{ |
|
1369 |
PRINT ( _L("CPcsAlgorithm2::WriteSortOrderToCenRepL. cenrep error.") ); |
|
1370 |
return; |
|
1371 |
} |
|
1372 |
||
1373 |
if (str == KNullDesC) |
|
1374 |
{ |
|
1375 |
keyIndex = i; // i has the next free location |
|
1376 |
break; |
|
1377 |
} |
|
1378 |
} |
|
1379 |
} |
|
1380 |
||
1381 |
if (keyIndex == -1) |
|
1382 |
{ |
|
1383 |
PRINT ( _L("CPcsAlgorithm2::WriteSortOrderToCenRepL. Persist limit violated.") ); |
|
1384 |
return; |
|
1385 |
} |
|
1386 |
||
1387 |
// Persist the sort order |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1388 |
HBufC* str1 = HBufC::NewL(KCRMaxLen); |
63 | 1389 |
TPtr ptr(str1->Des()); |
1390 |
||
1391 |
// Append the URI |
|
1392 |
ptr.Append(aURI); |
|
1393 |
ptr.Append(KSpace); |
|
1394 |
||
1395 |
// Append the sort order fields |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1396 |
for (int j = 0; j < aSortOrder.Count(); j++) |
63 | 1397 |
{ |
1398 |
ptr.AppendNum(aSortOrder[j]); |
|
1399 |
ptr.Append(KSpace); |
|
1400 |
} |
|
1401 |
||
1402 |
// Write to persistent store |
|
1403 |
TInt err = repository->Set(keyIndex, ptr); |
|
1404 |
||
1405 |
User::LeaveIfError(err); |
|
1406 |
||
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1407 |
delete str1; |
63 | 1408 |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1409 |
delete repository; |
63 | 1410 |
|
1411 |
PRINT ( _L("End CPcsAlgorithm2::WriteSortOrderToCenRepL.") ); |
|
1412 |
} |
|
1413 |
||
1414 |
// --------------------------------------------------------------------------------- |
|
1415 |
// WriteClientDataL. |
|
1416 |
// Write the content required by client |
|
1417 |
// --------------------------------------------------------------------------------- |
|
1418 |
CPsClientData* CPcsAlgorithm2::WriteClientDataL(CPsData& aPsData) |
|
1419 |
{ |
|
1420 |
CPsClientData* clientData = CPsClientData::NewL(); |
|
1421 |
CleanupStack::PushL(clientData); |
|
1422 |
||
1423 |
// set Id |
|
1424 |
clientData->SetId(aPsData.Id()); |
|
1425 |
||
1426 |
// set Uri |
|
1427 |
clientData->SetUriL(GetUriForIdL(aPsData.UriId())); |
|
1428 |
||
1429 |
// set pointer to the each data element |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1430 |
for (TInt i = 0; i < aPsData.DataElementCount(); i++) |
63 | 1431 |
{ |
1432 |
clientData->SetDataL(i, *(aPsData.Data(i))); |
|
1433 |
} |
|
1434 |
||
1435 |
// set data extension |
|
1436 |
clientData->SetDataExtensionL(aPsData.DataExtension()); |
|
1437 |
||
1438 |
// Set the Field match |
|
1439 |
clientData->SetFieldMatch(aPsData.DataMatch()); |
|
1440 |
CleanupStack::Pop(clientData); |
|
1441 |
||
1442 |
return clientData; |
|
1443 |
} |
|
1444 |
||
1445 |
// --------------------------------------------------------------------------------- |
|
1446 |
// HandleCacheUpdated. |
|
1447 |
// --------------------------------------------------------------------------------- |
|
1448 |
void CPcsAlgorithm2::HandleCacheUpdated( TCachingStatus aStatus ) |
|
1449 |
{ |
|
1450 |
TInt psKey( KErrNotFound ); |
|
1451 |
||
1452 |
switch ( aStatus ) |
|
1453 |
{ |
|
1454 |
case ECacheUpdateContactRemoved: |
|
1455 |
psKey = EPsKeyContactRemovedCounter; |
|
1456 |
break; |
|
1457 |
||
1458 |
case ECacheUpdateContactModified: |
|
1459 |
psKey = EPsKeyContactModifiedCounter; |
|
1460 |
break; |
|
1461 |
||
1462 |
case ECacheUpdateContactAdded: |
|
1463 |
psKey = EPsKeyContactAddedCounter; |
|
1464 |
break; |
|
1465 |
||
1466 |
default: |
|
1467 |
break; |
|
1468 |
} |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1469 |
|
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1470 |
if ( psKey != KErrNotFound ) |
63 | 1471 |
{ |
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1472 |
// Increment the relevant counter in P&S by one to signal the clients about |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1473 |
// the cache update. |
63 | 1474 |
TInt counter( KErrNotFound ); |
1475 |
TInt err = RProperty::Get( KPcsInternalUidCacheStatus, psKey, counter ); |
|
1476 |
if ( !err ) |
|
1477 |
{ |
|
1478 |
counter++; |
|
1479 |
RProperty::Set( KPcsInternalUidCacheStatus, psKey, counter ); |
|
1480 |
} |
|
1481 |
} |
|
1482 |
} |
|
1483 |
||
1484 |
// --------------------------------------------------------------------------------- |
|
1485 |
// ReconstructCacheDataL. |
|
1486 |
// --------------------------------------------------------------------------------- |
|
1487 |
void CPcsAlgorithm2::ReconstructCacheDataL() |
|
1488 |
{ |
|
1489 |
PRINT ( _L("Enter CPcsAlgorithm2::ReconstructCacheDataL.") ); |
|
1490 |
||
1491 |
TInt err; |
|
1492 |
TRAP( err, iKeyMap->ReconstructKeymapL()); |
|
1493 |
if (err != KErrNone) |
|
1494 |
{ |
|
1495 |
PRINT1 ( _L("keyMap ReconstructKeymapL, err =%d"),err ); |
|
1496 |
} |
|
1497 |
||
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1498 |
for (int index = 0; index < iCacheCount; index++) |
63 | 1499 |
{ |
1500 |
CPcsCache* cache = iPcsCache[index]; |
|
1501 |
||
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1502 |
HBufC * uri = cache->GetUri(); |
63 | 1503 |
// Clear the cache |
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1504 |
TRAP(err, cache->RemoveAllFromCacheL()); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1505 |
PRINT1 ( _L("cache RemoveAllFromCacheL, err =%d"),err ); |
63 | 1506 |
|
1507 |
if (err != KErrNone) |
|
1508 |
{ |
|
1509 |
SetCachingError(*uri, err); |
|
1510 |
} |
|
1511 |
//Update the caching status as ECachingInProgress, since now the caching |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1512 |
// would be strated again |
63 | 1513 |
UpdateCachingStatus(*uri, ECachingInProgress); |
1514 |
||
1515 |
// Request for data again |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1516 |
TRAP(err, iPsDataPluginInterface->RequestForDataL(*uri)); |
63 | 1517 |
PRINT1 ( _L("iPsDataPluginInterface->RequestForDataL, err =%d"),err ); |
1518 |
||
1519 |
if (err != KErrNone) |
|
1520 |
{ |
|
1521 |
SetCachingError(*uri, err); |
|
1522 |
} |
|
1523 |
} |
|
1524 |
} |
|
1525 |
||
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1526 |
void CPcsAlgorithm2::Converter(const TDesC& aSourStr, TDes& aDestStr) |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1527 |
{ |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1528 |
if (iKeyMap) |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1529 |
{ |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1530 |
iKeyMap->GetNumericKeyString(aSourStr, aDestStr); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1531 |
} |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1532 |
} |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1533 |
|
63 | 1534 |
// --------------------------------------------------------------------------------- |
1535 |
// DoLaunchPluginsL. |
|
1536 |
// launch plugins by idle |
|
1537 |
// --------------------------------------------------------------------------------- |
|
1538 |
TInt CPcsAlgorithm2::DoLaunchPluginsL(TAny* aPtr) |
|
1539 |
{ |
|
1540 |
CPcsAlgorithm2* ptr = (CPcsAlgorithm2*) aPtr; |
|
1541 |
ptr->DoLaunchPluginsL(); |
|
1542 |
return EFalse; |
|
1543 |
} |
|
1544 |
||
1545 |
// --------------------------------------------------------------------------------- |
|
1546 |
// DoLaunchPluginsL. |
|
1547 |
// lauch plugins |
|
1548 |
// --------------------------------------------------------------------------------- |
|
1549 |
void CPcsAlgorithm2::DoLaunchPluginsL() |
|
1550 |
{ |
|
1551 |
// Initialize available data adapters |
|
1552 |
iPsDataPluginInterface = CPsDataPluginInterface::NewL(this, this); |
|
1553 |
iPsDataPluginInterface->InstantiateAllPlugInsL(); |
|
1554 |
||
1555 |
// Store the cache list in TLS |
|
1556 |
// Required to support sort order changes in a memory efficient way |
|
1557 |
// This avoids storing sort order information in the CPsData element |
|
1558 |
// and storing it in CPcsCache. Refer CPcsAlgorithm2Utils::CompareDataBySortOrder |
|
1559 |
// to see how this is being used. |
|
1560 |
User::LeaveIfError(Dll::SetTls(&iPcsCache)); |
|
1561 |
||
1562 |
// Initialize cache |
|
1563 |
RPointerArray<TDesC> dataStores; |
|
1564 |
||
1565 |
iPsDataPluginInterface->GetAllSupportedDataStoresL(dataStores); |
|
1566 |
||
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1567 |
for (int dIndex = 0; dIndex < dataStores.Count(); dIndex++) |
63 | 1568 |
{ |
1569 |
AddDataStore(*(dataStores[dIndex])); |
|
1570 |
} |
|
1571 |
||
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
1572 |
dataStores.Reset(); |
63 | 1573 |
} |
1574 |
// End of file |
|
1575 |