162 User::LeaveIfError(err); |
163 User::LeaveIfError(err); |
163 } |
164 } |
164 } |
165 } |
165 |
166 |
166 // ---------------------------------------------------------------------------- |
167 // ---------------------------------------------------------------------------- |
167 // CPcsAlgorithm2::RemoveSpacesL |
|
168 // Remove leading and trailing spaces of search query |
|
169 // ---------------------------------------------------------------------------- |
|
170 void CPcsAlgorithm2::RemoveSpacesL(CPsQuery& aQuery) |
|
171 { |
|
172 PRINT ( _L("Enter CPcsAlgorithm2::RemoveSpacesL") ); |
|
173 |
|
174 // Remove all leading " " |
|
175 while ( aQuery.Count() > 0 ) |
|
176 { |
|
177 CPsQueryItem& item = aQuery.GetItemAtL(0); // First |
|
178 if ( !item.Character().IsSpace() ) |
|
179 { |
|
180 break; |
|
181 } |
|
182 aQuery.Remove(0); |
|
183 } |
|
184 |
|
185 // Remove all trailing " " |
|
186 while ( aQuery.Count() > 0 ) |
|
187 { |
|
188 CPsQueryItem& item = aQuery.GetItemAtL(aQuery.Count()-1); // Last |
|
189 if ( !item.Character().IsSpace() ) |
|
190 { |
|
191 break; |
|
192 } |
|
193 aQuery.Remove(aQuery.Count()-1); |
|
194 } |
|
195 |
|
196 PRINT ( _L("End CPcsAlgorithm2::RemoveSpacesL") ); |
|
197 } |
|
198 |
|
199 // ---------------------------------------------------------------------------- |
|
200 // CPcsAlgorithm2::ReplaceZeroWithSpaceL |
168 // CPcsAlgorithm2::ReplaceZeroWithSpaceL |
201 // Replace first occurance of '0' in a sequence of '0's in ITU-T with space |
169 // Replace first occurance of '0' in a sequence of '0's in ITU-T with space |
202 // ---------------------------------------------------------------------------- |
170 // ---------------------------------------------------------------------------- |
203 TBool CPcsAlgorithm2::ReplaceZeroWithSpaceL(CPsQuery& aQuery) |
171 TBool CPcsAlgorithm2::ReplaceZeroWithSpaceL(CPsQuery& aQuery) |
204 { |
172 { |
205 PRINT ( _L("Enter CPcsAlgorithm2::ReplaceZeroWithSpaceL") ); |
173 TChar space(KSpace); // ascii value for space |
206 |
174 |
207 //PRINTQUERY ( _L("CPcsAlgorithm2::ReplaceZeroWithSpaceL (BEFORE): "), aQuery ); |
175 TBool queryModified = EFalse; |
208 |
176 |
209 TBool queryModified = EFalse; |
177 // Skip initial zeros in query |
210 |
178 TInt index = 0; |
211 /* In phones like E52 and E55, where the "0" and the " " characters are on |
179 for (index = 0; index < aQuery.Count() |
212 * the same key, the "0"s have to be considered as possible separators. |
180 && aQuery.GetItemAtL(index).Character().GetNumericValue() == 0; ++index) |
213 * |
181 { |
214 * In phones like N97 and E72, where the "0" and the " " characters are on |
182 } |
215 * different keys, the "0"s must not be considered as possible separators. |
183 |
216 */ |
184 if (aQuery.KeyboardModeL() != EQwerty) |
217 |
185 { |
218 // Skip initial "0"s, they are not replaced into spaces |
186 for (TInt beg = index; beg < aQuery.Count(); ++beg) |
219 TInt skipIndex = 0; |
187 { |
220 while ( (skipIndex < aQuery.Count()) && |
188 CPsQueryItem& item = aQuery.GetItemAtL(beg); |
221 (aQuery.GetItemAtL(skipIndex).Character().GetNumericValue() == 0) ) |
189 |
222 { |
190 if (item.Character().GetNumericValue() == 0 && item.Mode()== EItut) |
223 skipIndex++; |
191 { |
224 } |
192 if (beg != 0) |
225 |
193 { |
226 // Replace remaining "0"s into spaces in case they are entered with a keyboard |
194 CPsQueryItem& item1 = aQuery.GetItemAtL(beg - 1); |
227 // that has "0" and " " on the same key. |
195 if (item1.Character().GetNumericValue() != 0 |
228 const TInt queryCount = aQuery.Count(); |
196 && !item1.Character().IsSpace()) |
229 for ( TInt index = skipIndex; index < queryCount; index++ ) |
197 { |
230 { |
198 item.SetCharacter(space); |
231 CPsQueryItem& item = aQuery.GetItemAtL(index); |
199 queryModified = ETrue; |
232 |
200 } |
233 if ( iKeyMap->GetSpaceAndZeroOnSameKey( item.Mode() ) && |
201 } |
234 item.Character().GetNumericValue() == 0 ) |
202 else |
235 { |
203 { |
236 item.SetCharacter(KSpace); |
204 item.SetCharacter(space); |
237 queryModified = ETrue; |
205 queryModified = ETrue; |
238 } |
206 } |
239 } |
207 } |
240 |
208 } |
241 //PRINTQUERY ( _L("CPcsAlgorithm2::ReplaceZeroWithSpaceL (AFTER): "), aQuery ); |
209 } |
242 |
210 |
243 PRINT1 ( _L("CPcsAlgorithm2::ReplaceZeroWithSpaceL: Query modified (0=not, 1=yes): %d"), queryModified ); |
211 return queryModified; |
244 |
|
245 PRINT ( _L("End CPcsAlgorithm2::ReplaceZeroWithSpaceL") ); |
|
246 |
|
247 return queryModified; |
|
248 } |
212 } |
249 |
213 |
250 // ---------------------------------------------------------------------------- |
214 // ---------------------------------------------------------------------------- |
251 // CPcsAlgorithm2::PerformSearchL |
215 // CPcsAlgorithm2::PerformSearchL |
252 // Search function for cache |
216 // Search function for cache |
253 // ---------------------------------------------------------------------------- |
217 // ---------------------------------------------------------------------------- |
254 void CPcsAlgorithm2::PerformSearchL(const CPsSettings& aSettings, |
218 void CPcsAlgorithm2::PerformSearchL(const CPsSettings& aSettings, CPsQuery& aQuery, |
255 CPsQuery& aQuery, |
|
256 RPointerArray<CPsClientData>& aSearchResults, |
219 RPointerArray<CPsClientData>& aSearchResults, |
257 RPointerArray<CPsPattern>& aSearchSeqs) |
220 RPointerArray<CPsPattern>& aSearchSeqs) |
258 { |
221 { |
259 PRINT ( _L("Enter CPcsAlgorithm2::PerformSearchL") ); |
222 PRINT ( _L("Enter CPcsAlgorithm2::PerformSearchL") ); |
260 |
223 |
261 //__LATENCY_MARK ( _L("CPcsAlgorithm2::PerformSearchL") ); |
224 __LATENCY_MARK ( _L("CPcsAlgorithm2::PerformSearchL") ); |
262 |
225 |
263 // Check aSettings |
226 // Get the current language |
264 RPointerArray<TDesC> searchUris; |
227 TLanguage lang = User::Language(); |
265 CleanupResetAndDestroyPushL( searchUris ); |
228 |
266 aSettings.SearchUrisL(searchUris); |
229 // Check if the language is supported and the keyboard mode is not qwerty. |
267 |
|
268 if ( searchUris.Count() <= 0) |
|
269 { |
|
270 PRINT ( _L("searchUris.Count() <= 0, Leave from CPcsAlgorithm2::PerformSearchL") ); |
|
271 User::Leave(KErrArgument); |
|
272 } |
|
273 CleanupStack::PopAndDestroy( &searchUris ); // ResetAndDestroy |
|
274 |
230 |
275 // Local arrays to hold the search results |
231 // Local arrays to hold the search results |
276 RPointerArray<CPsData> tempSearchResults; |
232 RPointerArray<CPsData> tempSearchResults; |
277 CleanupClosePushL( tempSearchResults ); |
|
278 RPointerArray<CPsData> tempSearchResults1; |
233 RPointerArray<CPsData> tempSearchResults1; |
279 CleanupClosePushL( tempSearchResults1 ); |
|
280 |
234 |
281 // -------------------- Perform the basic search -------------------------- |
235 // -------------------- Perform the basic search -------------------------- |
282 |
236 |
283 RemoveSpacesL(aQuery); |
|
284 PRINTQUERY ( _L("CPcsAlgorithm2::PerformSearchL: 1st search query: "), aQuery ); |
|
285 DoSearchL(aSettings, aQuery, tempSearchResults, aSearchSeqs); |
237 DoSearchL(aSettings, aQuery, tempSearchResults, aSearchSeqs); |
286 |
238 |
287 // ------------------------------------------------------------------------ |
239 // ------------------------------------------------------------------------ |
288 |
240 |
289 // ---- Perform new search after "0" replacement if query is not empty ---- |
241 // ------------------- Perform advanced search if needed ------------------ |
290 /* Examples: |
242 // Substitute "0" with space |
291 * - If the original search string is "Abc0" then we will search again with "Abc". |
|
292 * - If the original search string is "00" then we will not search again. |
|
293 */ |
|
294 TBool queryModified = ReplaceZeroWithSpaceL(aQuery); |
243 TBool queryModified = ReplaceZeroWithSpaceL(aQuery); |
295 RemoveSpacesL(aQuery); |
244 |
296 // Perform query again if query got modified. |
245 // If query got modified and the search query translated to more than 1 query |
|
246 // perform a multi search again |
297 if (queryModified) |
247 if (queryModified) |
298 { |
248 { |
299 PRINTQUERY ( _L("CPcsAlgorithm2::PerformSearchL: 2nd search query: "), aQuery ); |
249 // Split query |
300 DoSearchL(aSettings, aQuery, tempSearchResults1, aSearchSeqs); |
250 RPointerArray<CPsQuery> queryList = iMultiSearchHelper->MultiQueryL(aQuery); |
301 |
251 |
|
252 // Perform seach again |
|
253 if (queryList.Count() > 1) |
|
254 { |
|
255 DoSearchL(aSettings, aQuery, tempSearchResults1, aSearchSeqs); |
|
256 } |
302 |
257 |
303 // Sort rule |
258 // Sort rule |
304 TLinearOrder<CPsData> rule(CPcsAlgorithm2Utils::CompareDataBySortOrderL); |
259 TLinearOrder<CPsData> rule(CPcsAlgorithm2Utils::CompareDataBySortOrder); |
305 |
260 |
306 // Avoid duplicates and add new results |
261 // Avoid duplicates and add new results |
307 TIdentityRelation<CPsData> identityRule(CPsData::CompareById); |
262 TIdentityRelation<CPsData> identityRule(CPsData::CompareById); |
308 const TInt tempSearchResults1Count = tempSearchResults1.Count(); |
|
309 if (aSettings.GetSortType() != EAlphabetical) |
263 if (aSettings.GetSortType() != EAlphabetical) |
310 { |
264 { |
311 TInt insertPos = 0; |
265 TInt insertPos = 0; |
312 for (TInt i = 0; i < tempSearchResults1Count; i++) |
266 for (int i = 0; i < tempSearchResults1.Count(); i++) |
313 { |
267 { |
314 if (tempSearchResults.Find(tempSearchResults1[i], |
268 if (tempSearchResults.Find(tempSearchResults1[i], |
315 identityRule) == KErrNotFound) |
269 identityRule) == KErrNotFound) |
316 { |
270 { |
317 tempSearchResults.Insert(tempSearchResults1[i], insertPos); |
271 tempSearchResults.Insert(tempSearchResults1[i], insertPos); |
318 insertPos++; |
272 insertPos++; |
319 } |
273 } |
|
274 |
320 } |
275 } |
|
276 |
321 } |
277 } |
322 else |
278 else |
323 { |
279 { |
324 for (TInt i = 0; i < tempSearchResults1Count; i++) |
280 |
|
281 for (int i = 0; i < tempSearchResults1.Count(); i++) |
325 { |
282 { |
326 if (tempSearchResults.Find(tempSearchResults1[i], |
283 if (tempSearchResults.Find(tempSearchResults1[i], |
327 identityRule) == KErrNotFound) |
284 identityRule) == KErrNotFound) |
328 { |
285 { |
329 tempSearchResults.InsertInOrderAllowRepeats(tempSearchResults1[i], |
286 tempSearchResults.InsertInOrderAllowRepeats(tempSearchResults1[i], |
330 rule); |
287 rule); |
331 } |
288 } |
332 } |
289 } |
333 } |
290 } |
|
291 |
|
292 queryList.ResetAndDestroy(); |
334 } |
293 } |
335 // ------------------------------------------------------------------------ |
294 // ------------------------------------------------------------------------ |
336 |
295 |
337 // ---------------------- Write result objects to the stream -------------- |
296 // ---------------------- Write result objects to the stream -------------- |
338 // Truncate the result set if required |
297 // Truncate the result set if required |
339 TInt maxNumToDisplay = aSettings.MaxResults(); |
298 TInt numToDisplay = aSettings.MaxResults(); |
340 TInt resultSetCount = tempSearchResults.Count(); |
299 TInt resultSet = tempSearchResults.Count(); |
341 TInt numToDisplay = 0; |
300 |
342 if ( maxNumToDisplay == -1 ) |
301 if (resultSet > numToDisplay && numToDisplay != -1) |
343 { |
302 { |
344 numToDisplay = resultSetCount; |
303 // Copy the top N contents from tempSearchResults to the results stream |
|
304 for (int i = 0; i < numToDisplay; i++) |
|
305 { |
|
306 aSearchResults.Append(WriteClientDataL(*(tempSearchResults[i]))); |
|
307 } |
|
308 |
345 } |
309 } |
346 else |
310 else |
347 { |
311 { |
348 numToDisplay = Min( maxNumToDisplay, resultSetCount ); |
312 // Copy all the contents from tempSearchResults to the results stream |
349 } |
313 for (int i = 0; i < resultSet; i++) |
350 |
314 { |
351 // Copy desired number of results from tempSearchResults to the results stream |
315 aSearchResults.Append(WriteClientDataL(*(tempSearchResults[i]))); |
352 for (TInt i = 0; i < numToDisplay; i++) |
316 } |
353 { |
|
354 aSearchResults.Append(WriteClientDataL(*(tempSearchResults[i]))); |
|
355 } |
317 } |
356 // ------------------------------------------------------------------------ |
318 // ------------------------------------------------------------------------ |
357 |
319 |
358 // Cleanup local results array |
320 // Cleanup local results array |
359 CleanupStack::PopAndDestroy( &tempSearchResults1 ); // Close, don't destroy |
321 tempSearchResults.Reset(); // Don't destroy |
360 CleanupStack::PopAndDestroy( &tempSearchResults ); // Close, don't destroy |
322 tempSearchResults1.Reset(); // Don't destroy |
361 |
323 |
362 // __LATENCY_MARKEND ( _L("CPcsAlgorithm2::PerformSearchL") ); |
324 __LATENCY_MARKEND ( _L("CPcsAlgorithm2::PerformSearchL") ); |
363 |
325 |
364 PRINT ( _L("End CPcsAlgorithm2::PerformSearchL") ); |
326 PRINT ( _L("End CPcsAlgorithm2::PerformSearchL") ); |
365 } |
327 } |
366 |
328 |
367 // ---------------------------------------------------------------------------- |
329 // ---------------------------------------------------------------------------- |
368 // CPcsAlgorithm2::SearchInputL |
330 // CPcsAlgorithm2::SearchInputL |
369 // Search function for input string |
331 // Search function for input string |
370 // ---------------------------------------------------------------------------- |
332 // ---------------------------------------------------------------------------- |
371 void CPcsAlgorithm2::SearchInputL(CPsQuery& aQuery, |
333 void CPcsAlgorithm2::SearchInputL(CPsQuery& aQuery, TDesC& aData, |
372 TDesC& aData, |
|
373 RPointerArray<TDesC>& aMatchSet, |
334 RPointerArray<TDesC>& aMatchSet, |
374 RArray<TPsMatchLocation>& aMatchLocation) |
335 RArray<TPsMatchLocation>& aMatchLocation) |
375 { |
336 { |
376 // __LATENCY_MARK ( _L("CPcsAlgorithm2::SearchInputL: ") ); |
|
377 PRINT ( _L("Enter CPcsAlgorithm2::SearchInputL") ); |
337 PRINT ( _L("Enter CPcsAlgorithm2::SearchInputL") ); |
378 |
338 |
|
339 // Get the current language |
|
340 TLanguage lang = User::Language(); |
|
341 |
|
342 // Check if the language is supported and the keyboard mode is not qwerty. |
|
343 |
379 // Print input query for debug |
344 // Print input query for debug |
380 PRINTQUERY ( _L("CPcsAlgorithm2::SearchInputL: Search query: "), aQuery ); |
345 aQuery.PrintQuery(); |
381 |
346 |
382 // Print received search data |
347 // Print received search data |
383 PRINT1 ( _L("Search data received = %S"), &aData); |
348 PRINT1 ( _L("Search data received = %S"), &aData); |
384 |
349 |
385 |
|
386 // -------------------- Perform the basic search -------------------------- |
350 // -------------------- Perform the basic search -------------------------- |
387 |
351 |
388 RemoveSpacesL(aQuery); |
|
389 DoSearchInputL(aQuery, aData, aMatchSet, aMatchLocation); |
352 DoSearchInputL(aQuery, aData, aMatchSet, aMatchLocation); |
390 |
353 |
391 // ------------------------------------------------------------------------ |
354 // ------------------------------------------------------------------------ |
392 |
355 |
393 // ---- Perform new search after "0" replacement if query is not empty ---- |
356 // ------------------- Perform advanced search if needed ------------------ |
394 /* Examples: |
357 // Substitute "0" with space |
395 * - If the original search string is "Abc0" then we will search again with "Abc". |
|
396 * - If the original search string is "00" then we will not search again. |
|
397 */ |
|
398 TBool queryModified = ReplaceZeroWithSpaceL(aQuery); |
358 TBool queryModified = ReplaceZeroWithSpaceL(aQuery); |
399 RemoveSpacesL(aQuery); |
359 |
400 // If query got modified and the search query still contains something |
360 // If query got modified and the search query translated to more than 1 query |
401 // perform a multi search again |
361 // perform a multi search again |
402 if (queryModified && aQuery.Count() > 0 && aMatchSet.Count() == 0 && aMatchLocation.Count() == 0 ) |
362 if (queryModified) |
403 { |
363 { |
404 DoSearchInputL(aQuery, aData, aMatchSet, aMatchLocation); |
364 RPointerArray<CPsQuery> queryList = iMultiSearchHelper->MultiQueryL(aQuery); |
|
365 |
|
366 if (queryList.Count() > 1) |
|
367 { |
|
368 DoSearchInputL(aQuery, aData, aMatchSet, aMatchLocation); |
|
369 } |
|
370 |
|
371 queryList.ResetAndDestroy(); |
405 } |
372 } |
406 // ------------------------------------------------------------------------ |
373 // ------------------------------------------------------------------------ |
407 |
|
408 // --- Remove overlapping items from aMatchLocation --- |
|
409 TInt i = 0; |
|
410 TBool incrementFirstCursor; |
|
411 while ( i < aMatchLocation.Count() ) |
|
412 { |
|
413 incrementFirstCursor = ETrue; |
|
414 TInt j = i+1; |
|
415 while ( j < aMatchLocation.Count() ) |
|
416 { |
|
417 if ( CPcsAlgorithm2Utils::MatchesOverlap( aMatchLocation[j], aMatchLocation[i] ) ) |
|
418 { |
|
419 // Remove match location item with smallest length if 2 items have same index |
|
420 if ( aMatchLocation[j].length <= aMatchLocation[i].length ) |
|
421 { |
|
422 aMatchLocation.Remove(j); |
|
423 continue; // Do not increment j |
|
424 } |
|
425 else |
|
426 { |
|
427 aMatchLocation.Remove(i); |
|
428 incrementFirstCursor = EFalse; // Do not increment i |
|
429 break; |
|
430 } |
|
431 } |
|
432 j++; |
|
433 } |
|
434 if ( incrementFirstCursor ) |
|
435 { |
|
436 i++; |
|
437 } |
|
438 } |
|
439 |
|
440 // --- Remove from aMatchSet items which no longer have corresponding item in aMatchLocation --- |
|
441 HBufC* dataUpper = HBufC::NewLC(aData.Length()); |
|
442 dataUpper->Des().Copy(aData); |
|
443 dataUpper->Des().UpperCase(); // Get uppercase, as aMatchSet is in upper case |
|
444 |
|
445 TInt k = 0; |
|
446 while ( k < aMatchSet.Count() ) |
|
447 { |
|
448 TBool keepMatch = EFalse; |
|
449 TInt startCursor = -1; |
|
450 |
|
451 TInt offsetCursor; |
|
452 while ( KErrNotFound != (offsetCursor = dataUpper->Mid(startCursor + 1).Find(*aMatchSet[k])) ) |
|
453 { |
|
454 // startCursor = index of match item *aMatchSet[k] into search string aData |
|
455 startCursor = offsetCursor + startCursor + 1; |
|
456 const TInt matchLocationCount = aMatchLocation.Count(); |
|
457 for ( TInt i = 0; i < matchLocationCount; i++ ) |
|
458 { |
|
459 // If match item was found in the location list, then keep it |
|
460 if ( (aMatchLocation[i].index == startCursor) && |
|
461 (aMatchLocation[i].length == aMatchSet[k]->Length()) ) |
|
462 { |
|
463 keepMatch = ETrue; |
|
464 break; |
|
465 } |
|
466 } |
|
467 } |
|
468 |
|
469 if ( keepMatch ) |
|
470 { |
|
471 k++; |
|
472 } |
|
473 else |
|
474 { |
|
475 aMatchSet.Remove(k); // Do not increment k |
|
476 } |
|
477 } |
|
478 CleanupStack::PopAndDestroy( dataUpper ); |
|
479 // --- Remove items End --- |
|
480 |
374 |
481 // Sort match set |
375 // Sort match set |
482 iHelper->SortSearchSeqsL(aMatchSet); |
376 iHelper->SortSearchSeqsL(aMatchSet); |
483 |
377 |
484 PRINT ( _L("End CPcsAlgorithm2::SearchInputL") ); |
378 PRINT ( _L("End CPcsAlgorithm2::SearchInputL") ); |
485 //__LATENCY_MARKEND ( _L("CPcsAlgorithm2::SearchInputL") ); |
|
486 } |
379 } |
487 |
380 |
488 // ---------------------------------------------------------------------------- |
381 // ---------------------------------------------------------------------------- |
489 // CPcsAlgorithm2::SearchMatchStringL |
382 // CPcsAlgorithm2::SearchMatchStringL |
490 // Search function for input string, result also as string |
383 // Search function for input string, result also as string |
491 // ---------------------------------------------------------------------------- |
384 // ---------------------------------------------------------------------------- |
492 void CPcsAlgorithm2::SearchMatchStringL( CPsQuery& aSearchQuery, |
385 void CPcsAlgorithm2::SearchMatchStringL( CPsQuery& /*aSearchQuery*/, |
493 TDesC& aSearchData, |
386 TDesC& /*aSearchData*/, |
494 TDes& aMatch ) |
387 TDes& /*aMatch*/ ) |
495 { |
388 { |
496 PRINT ( _L("Enter CPcsAlgorithm2::SearchMatchStringL") ); |
389 //NOT IMPLEMENTED YET |
497 |
|
498 __LATENCY_MARK ( _L("CPcsAlgorithm2::SearchMatchStringL") ); |
|
499 |
|
500 RemoveSpacesL(aSearchQuery); |
|
501 // ---------------------- Perform the initial search ---------------------- |
|
502 iMultiSearchHelper->LookupMatchL( aSearchQuery, aSearchData, aMatch ); |
|
503 PRINTQUERY ( _L("CPcsAlgorithm2::SearchMatchStringL: 1st search: "), aSearchQuery ); |
|
504 PRINT1 ( _L("CPcsAlgorithm2::SearchMatchStringL: 1st search: Search Data: %S"), &aSearchData ); |
|
505 PRINT1 ( _L("CPcsAlgorithm2::SearchMatchStringL: 1st search: Result: %S"), &aMatch ); |
|
506 // ------------------------------------------------------------------------ |
|
507 |
|
508 // ---- Perform new search after "0" replacement if query is not empty ---- |
|
509 /* Examples: |
|
510 * - If the original search string is "Abc0" then we will search again with "Abc". |
|
511 * - If the original search string is "00" then we will not search again. |
|
512 */ |
|
513 if ( aMatch.Length() <= 0 ) |
|
514 { |
|
515 TBool isQueryModified = ReplaceZeroWithSpaceL(aSearchQuery); |
|
516 RemoveSpacesL(aSearchQuery); |
|
517 if ( isQueryModified && (aSearchQuery.Count() > 0) ) |
|
518 { |
|
519 iMultiSearchHelper->LookupMatchL( aSearchQuery, aSearchData, aMatch ); |
|
520 PRINTQUERY ( _L("CPcsAlgorithm2::SearchMatchStringL: 2nd search: "), aSearchQuery ); |
|
521 PRINT1 ( _L("CPcsAlgorithm2::SearchMatchStringL: 2nd search: Search Data: %S"), &aSearchData ); |
|
522 PRINT1 ( _L("CPcsAlgorithm2::SearchMatchStringL: 2nd search: Result: %S"), &aMatch ); |
|
523 } |
|
524 } |
|
525 __LATENCY_MARKEND ( _L("CPcsAlgorithm2::SearchMatchStringL") ); |
|
526 |
|
527 PRINT ( _L("End CPcsAlgorithm2::SearchMatchStringL") ); |
|
528 } |
390 } |
529 |
391 |
530 // ---------------------------------------------------------------------------- |
392 // ---------------------------------------------------------------------------- |
531 // CPcsAlgorithm2::DoSearchL |
393 // CPcsAlgorithm2::DoSearchL |
532 // Search function helper |
394 // Search function helper |
533 // ---------------------------------------------------------------------------- |
395 // ---------------------------------------------------------------------------- |
534 void CPcsAlgorithm2::DoSearchL( const CPsSettings& aSettings, |
396 void CPcsAlgorithm2::DoSearchL(const CPsSettings& aSettings, CPsQuery& aQuery, |
535 CPsQuery& aQuery, |
397 RPointerArray<CPsData>& searchResults, |
536 RPointerArray<CPsData>& aSearchResults, |
398 RPointerArray<CPsPattern>& searchSeqs) |
537 RPointerArray<CPsPattern>& aSearchSeqs ) |
|
538 { |
399 { |
539 PRINT ( _L("Enter CPcsAlgorithm2::DoSearchL") ); |
400 PRINT ( _L("Enter CPcsAlgorithm2::DoSearchL") ); |
540 |
401 |
541 //__LATENCY_MARK ( _L("CPcsAlgorithm2::DoSearchL") ); |
402 // Print query for debug |
542 |
403 aQuery.PrintQuery(); |
|
404 |
543 // -(0)----------------- Check if group search is required --------------- |
405 // -(0)----------------- Check if group search is required --------------- |
544 RArray<TInt> contactsInGroup; |
406 RArray<TInt> contactsInGroup; |
545 CleanupClosePushL( contactsInGroup ); |
|
546 RArray<TInt> groupIdArray; |
407 RArray<TInt> groupIdArray; |
547 CleanupClosePushL( groupIdArray ); |
|
548 |
408 |
549 // Create a new settings instance |
409 // Create a new settings instance |
550 CPsSettings* tempSettings = aSettings.CloneL(); |
410 CPsSettings *tempSettings = aSettings.CloneL(); |
551 CleanupStack::PushL( tempSettings ); |
|
552 |
411 |
553 TBool isGroupSearch = IsGroupSearchL(*tempSettings, groupIdArray); |
412 TBool isGroupSearch = IsGroupSearchL(*tempSettings, groupIdArray); |
554 |
413 |
555 if (isGroupSearch) |
414 if (isGroupSearch) |
556 { |
415 { |
559 |
418 |
560 // List of contacts in this group |
419 // List of contacts in this group |
561 GetContactsInGroupL(groupIdArray[0], contactsInGroup); |
420 GetContactsInGroupL(groupIdArray[0], contactsInGroup); |
562 } |
421 } |
563 |
422 |
|
423 groupIdArray.Close(); |
|
424 |
564 // ----------------------------------------------------------------------- |
425 // ----------------------------------------------------------------------- |
565 |
426 |
566 |
427 |
567 // Extract query list. |
428 // Extract query list. |
568 RPointerArray<CPsQuery> queryList = iMultiSearchHelper->MultiQueryL(aQuery); |
429 RPointerArray<CPsQuery> queryList = iMultiSearchHelper->MultiQueryL(aQuery); |
569 CleanupResetAndDestroyPushL( queryList ); |
430 |
570 |
431 // -(1)--------------------- No query return all contacts ---------------- |
571 // (1)-------------------- No query return all contacts ------------------- |
|
572 if (queryList.Count() == 0) |
432 if (queryList.Count() == 0) |
573 { |
433 { |
574 GetAllContentsL(*tempSettings, aSearchResults); |
434 GetAllContentsL(*tempSettings, searchResults); |
575 |
435 |
576 if (isGroupSearch) |
436 if (isGroupSearch) |
577 { |
437 { |
578 FilterSearchResultsForGroupsL(contactsInGroup, aSearchResults); |
438 FilterSearchResultsForGroupsL(contactsInGroup, searchResults); |
579 } |
439 } |
580 } |
440 } |
581 // ------------------------------------------------------------------------ |
441 // ------------------------------------------------------------------------ |
582 |
442 |
583 // (2)-------------------- Perform a single query search ------------------ |
443 |
584 else if (queryList.Count() == 1) |
444 // -(2)------------------------ Perform a single query search ------------- |
585 { |
445 if (queryList.Count() == 1) |
|
446 { |
|
447 TInt mode = aQuery.KeyboardModeL(); |
|
448 |
586 CPsQuery* query = queryList[0]; |
449 CPsQuery* query = queryList[0]; |
587 |
450 |
588 // Search results |
451 iFindUtilECE->SetKeyboardMode(mode); |
589 iHelper->SearchSingleL(*tempSettings, *query, isGroupSearch, |
452 |
590 contactsInGroup, aSearchResults, aSearchSeqs); |
453 switch (mode) |
|
454 { |
|
455 case EItut: |
|
456 |
|
457 PRINT ( _L("Query received is in ITU-T mode") ); |
|
458 |
|
459 // Search results |
|
460 iHelper->SearchITUL(*tempSettings, *query, isGroupSearch, |
|
461 contactsInGroup, searchResults, searchSeqs); |
|
462 |
|
463 break; |
|
464 |
|
465 case EQwerty: |
|
466 |
|
467 PRINT ( _L("Query received is in QWERTY mode") ); |
|
468 |
|
469 // Search results |
|
470 iHelper->SearchQWERTYL(*tempSettings, *query, isGroupSearch, |
|
471 contactsInGroup, searchResults, searchSeqs); |
|
472 |
|
473 break; |
|
474 |
|
475 case EModeUndefined: |
|
476 |
|
477 PRINT ( _L("Query received is in Mixed mode. Keyboard swap happened.") ); |
|
478 |
|
479 // Search results |
|
480 iHelper->SearchMixedL(*tempSettings, *query, isGroupSearch, |
|
481 contactsInGroup, searchResults, searchSeqs); |
|
482 |
|
483 break; |
|
484 } |
|
485 |
591 } |
486 } |
592 // ------------------------------------------------------------------------ |
487 // ------------------------------------------------------------------------ |
593 |
488 |
594 // (3)-------------------- Perform a multi query search ------------------- |
489 |
595 else // multiple query |
490 // -(3)---------------------------- Perform a multi query search ---------- |
|
491 if (queryList.Count() > 1) // multiple query |
596 { |
492 { |
597 PRINT ( _L("Query received is in multiple. Performing a multi search.") ); |
493 PRINT ( _L("Query received is in multiple. Performing a multi search.") ); |
|
494 |
|
495 TInt mode = aQuery.KeyboardModeL(); |
|
496 iFindUtilECE->SetKeyboardMode(mode); |
|
497 |
|
498 for (int i = 0; i < queryList.Count(); i++) |
|
499 { |
|
500 TPtrC queryPtr = queryList[i]->QueryAsStringLC(); |
|
501 PRINT2 ( _L("Received Query, index = %d; value = %S"), i, &queryPtr ); |
|
502 CleanupStack::PopAndDestroy(); |
|
503 } |
598 |
504 |
599 // Search results |
505 // Search results |
600 iMultiSearchHelper->SearchMultiL(*tempSettings, queryList, isGroupSearch, |
506 iMultiSearchHelper->SearchMultiL(*tempSettings, queryList, isGroupSearch, |
601 contactsInGroup, aSearchResults, aSearchSeqs); |
507 contactsInGroup, searchResults, searchSeqs, |
|
508 mode); |
602 } |
509 } |
603 // ------------------------------------------------------------------------- |
510 // ------------------------------------------------------------------------- |
604 |
511 |
605 // Cleanup |
512 // Cleanup |
606 |
513 delete tempSettings; |
607 CleanupStack::PopAndDestroy( &queryList ); // ResetAndDestroy |
514 tempSettings = NULL; |
608 CleanupStack::PopAndDestroy( tempSettings ); |
515 |
609 CleanupStack::PopAndDestroy( &groupIdArray ); // Close |
516 groupIdArray.Close(); |
610 CleanupStack::PopAndDestroy( &contactsInGroup ); // Close |
517 contactsInGroup.Close(); |
611 |
518 queryList.ResetAndDestroy(); |
612 //__LATENCY_MARKEND ( _L("CPcsAlgorithm2::DoSearchL") ); |
|
613 |
519 |
614 PRINT ( _L("End CPcsAlgorithm2::DoSearchL") ); |
520 PRINT ( _L("End CPcsAlgorithm2::DoSearchL") ); |
615 } |
521 } |
616 |
522 |
617 // ---------------------------------------------------------------------------- |
523 // ---------------------------------------------------------------------------- |
618 // CPcsAlgorithm2::DoSearchInputL |
524 // CPcsAlgorithm2::DoSearchInputL |
619 // Search function helper |
525 // Search function helper |
620 // ---------------------------------------------------------------------------- |
526 // ---------------------------------------------------------------------------- |
621 void CPcsAlgorithm2::DoSearchInputL(CPsQuery& aQuery, |
527 void CPcsAlgorithm2::DoSearchInputL(CPsQuery& aQuery, TDesC& aData, |
622 const TDesC& aData, |
|
623 RPointerArray<TDesC>& aMatchSet, |
528 RPointerArray<TDesC>& aMatchSet, |
624 RArray<TPsMatchLocation>& aMatchLocation) |
529 RArray<TPsMatchLocation>& aMatchLocation) |
625 { |
530 { |
626 |
531 |
627 //__LATENCY_MARK ( _L("CPcsAlgorithm2::SearchInputL: ") ); |
|
628 PRINT ( _L("Enter CPcsAlgorithm2::DoSearchInputL") ); |
532 PRINT ( _L("Enter CPcsAlgorithm2::DoSearchInputL") ); |
629 |
533 |
630 // Check if any seperator is there in the query |
534 // Check if any seperator is there in the query |
631 RPointerArray<CPsQuery> queryList = iMultiSearchHelper->MultiQueryL(aQuery); |
535 RPointerArray<CPsQuery> queryList = iMultiSearchHelper->MultiQueryL(aQuery); |
632 CleanupResetAndDestroyPushL( queryList ); |
|
633 |
536 |
634 // No query |
537 // No query |
635 if (queryList.Count() == 0) |
538 if (queryList.Count() == 0) |
636 { |
539 { |
637 PRINT ( _L("Query received is empty") ); |
540 PRINT ( _L("Query received is empty") ); |
638 CleanupStack::PopAndDestroy( &queryList ); // ResetAndDestroy |
541 return; |
639 return; |
542 } |
640 } |
543 |
|
544 RPointerArray<HBufC> convertedQuery; |
|
545 iMultiSearchHelper->ConvertQueryToListL(queryList, convertedQuery); |
641 |
546 |
642 // Single query |
547 // Single query |
643 if (queryList.Count() == 1) |
548 if (queryList.Count() == 1) |
644 { |
549 { |
645 iHelper->SearchMatchSeqL(aQuery, aData, aMatchSet, aMatchLocation); |
550 iHelper->SearchMatchSeqL(convertedQuery[0], aData, aMatchSet, aQuery, |
|
551 aMatchLocation); |
|
552 |
646 } |
553 } |
647 |
554 |
648 if (queryList.Count() > 1) // multiple query |
555 if (queryList.Count() > 1) // multiple query |
649 { |
556 { |
650 PRINT ( _L("Query received is in multiple. Performing a multi search.") ); |
557 PRINT ( _L("Query received is in multiple. Performing a multi search.") ); |
651 |
558 |
|
559 for (int i = 0; i < queryList.Count(); i++) |
|
560 { |
|
561 TPtrC queryPtr = queryList[i]->QueryAsStringLC(); |
|
562 PRINT2 ( _L("Rceived Query, index = %d; value = %S"), i, &queryPtr ); |
|
563 CleanupStack::PopAndDestroy(); |
|
564 } |
|
565 |
652 // Search results |
566 // Search results |
653 iMultiSearchHelper->SearchMatchSeqMultiL(queryList, |
567 iMultiSearchHelper->SearchMatchSeqMultiL(queryList, aData, aMatchSet, |
654 aData, |
|
655 aMatchSet, |
|
656 aMatchLocation); |
568 aMatchLocation); |
|
569 |
657 } |
570 } |
658 |
571 |
659 // Delete all the query elements |
572 // Delete all the query elements |
660 CleanupStack::PopAndDestroy( &queryList ); // ResetAndDestroy |
573 queryList.ResetAndDestroy(); |
|
574 convertedQuery.ResetAndDestroy(); |
|
575 |
661 PRINT ( _L("End CPcsAlgorithm2::DoSearchInputL") ); |
576 PRINT ( _L("End CPcsAlgorithm2::DoSearchInputL") ); |
662 //__LATENCY_MARKEND ( _L("CPcsAlgorithm2::SearchInputL") ); |
|
663 |
|
664 } |
577 } |
665 |
578 |
666 // ---------------------------------------------------------------------------- |
579 // ---------------------------------------------------------------------------- |
667 // CPcsAlgorithm2::AddData |
580 // CPcsAlgorithm2::AddData |
668 // Add a data element to the pool |
581 // Add a data element to the pool |
907 return; |
820 return; |
908 } |
821 } |
909 |
822 |
910 // If not a cache update event, then this event is related to the initial |
823 // If not a cache update event, then this event is related to the initial |
911 // cache construction. |
824 // cache construction. |
912 |
825 TInt index = FindStoreUri(aDataStore); |
913 // Check if any error occurred and update the cache error |
826 iPcsCache[index]->UpdateCacheStatus(aStatus); |
914 if ( aStatus < 0 ) |
827 |
915 { |
828 // Check if any error occurred |
|
829 // If so, update the cache status, Set the property and return |
|
830 if (aStatus < 0) |
|
831 { |
916 SetCachingError(aDataStore, aStatus); |
832 SetCachingError(aDataStore, aStatus); |
917 } |
833 //return; |
918 else |
834 } |
919 { |
835 |
920 TInt index = FindStoreUri(aDataStore); |
836 //store the index for firstname and lastname |
921 iPcsCache[index]->UpdateCacheStatus(aStatus); |
837 if (aStatus == ECachingComplete) |
922 } |
838 { |
923 |
839 RArray<TInt> dataFields; |
924 TCachingStatus status = ECachingNotStarted; |
840 iPcsCache[index]->GetDataFields(dataFields); |
925 TUint countNotStarted = 0; |
841 |
926 TUint countInProgress = 0; |
842 for (int i = 0; i < dataFields.Count(); i++) |
927 TUint countCompleted = 0; |
843 { |
928 TUint countCompletedWithErrors = 0; |
844 if (dataFields[i] == R_VPBK_FIELD_TYPE_FIRSTNAME) |
929 TInt cacheCount = iPcsCache.Count(); |
845 { |
930 for ( TInt i = 0; i < cacheCount; i++ ) |
846 iFirstNameIndex = i; |
931 { |
847 } |
932 PRINT3 ( _L("CPcsAlgorithm2::UpdateCachingStatus: URI[%d]=%S, cache status=%d"), |
848 else if (dataFields[i] == R_VPBK_FIELD_TYPE_LASTNAME) |
933 i, &iPcsCache[i]->GetURI(), iPcsCache[i]->GetCacheStatus() ); |
849 { |
934 |
850 iLastNameIndex = i; |
935 switch ( iPcsCache[i]->GetCacheStatus() ) |
851 } |
936 { |
852 } |
937 case ECachingNotStarted: |
853 } |
938 { |
854 |
939 countNotStarted++; |
855 // No error occurred |
940 break; |
856 TCachingStatus status = ECachingComplete; |
941 } |
857 TBool atLeastOneStoreCachingCompleteWithErrors(EFalse); |
942 case ECachingInProgress: |
858 for (TInt i = 0; i < iPcsCache.Count(); i++) |
943 { |
859 { |
944 countInProgress++; |
860 if (iPcsCache[i]->GetCacheStatus() == ECachingComplete) |
945 break; |
861 { |
946 } |
862 continue; |
947 case ECachingComplete: |
863 } |
948 { |
864 else if (iPcsCache[i]->GetCacheStatus() == ECachingCompleteWithErrors) |
949 countCompleted++; |
865 { |
950 break; |
866 atLeastOneStoreCachingCompleteWithErrors = ETrue; |
951 } |
867 continue; |
952 case ECachingCompleteWithErrors: |
868 } |
953 { |
869 else |
954 countCompletedWithErrors++; |
870 { |
955 break; |
871 status = ECachingInProgress; |
956 } |
872 break; |
957 default: |
873 } |
958 { |
874 } |
959 // Default completed state |
875 |
960 countCompleted++; |
876 if (status == ECachingComplete) |
961 break; |
877 { |
962 } |
878 // See if any error occurred while caching |
963 } |
879 // If so, change the status to ECachingCompleteWithErrors |
964 } |
880 if ((iCacheError != KErrNone) || (atLeastOneStoreCachingCompleteWithErrors)) |
965 |
881 { |
966 // Calculate cumulative status according to single caches statuses |
882 status = ECachingCompleteWithErrors; |
967 if ( countCompleted > 0 && ( countCompleted + countNotStarted ) == cacheCount ) |
883 } |
968 { |
884 } |
969 // If at least one caching is finished |
|
970 // set status to ECachingComplete or ECachingCompleteWithErrors |
|
971 // according to iCacheError |
|
972 status = ( iCacheError == KErrNone ) ? ECachingComplete : ECachingCompleteWithErrors; |
|
973 } |
|
974 else if ( countInProgress > 0 ) |
|
975 { |
|
976 // Else if at least one caching is in progress, |
|
977 // set status to ECachingInProgress |
|
978 status = ECachingInProgress; |
|
979 } |
|
980 else if ( countCompletedWithErrors > 0 ) |
|
981 { |
|
982 // Else if at least one caching is completed with errors, |
|
983 //set status to ECachingCompleteWithErrors |
|
984 status = ECachingCompleteWithErrors; |
|
985 } |
|
986 else |
|
987 { |
|
988 // countNotStarted == cacheCount |
|
989 // status is set to default ECachingNotStarted |
|
990 } |
|
991 |
|
992 PRINT1 ( _L("CPcsAlgorithm2::UpdateCachingStatus: Cumulative caching status is %d"), |
|
993 status ); |
|
994 |
885 |
995 // Check if status changed |
886 // Check if status changed |
996 if ( status != iCacheStatus ) |
887 if (status != iCacheStatus) |
997 { |
888 { |
998 PRINT2 ( _L("CPcsAlgorithm2::UpdateCachingStatus: Cumulative caching changed: %d -> %d"), |
|
999 iCacheStatus, status ); |
|
1000 |
|
1001 iCacheStatus = status; |
889 iCacheStatus = status; |
1002 RProperty::Set(KPcsInternalUidCacheStatus, EPsKeyCacheStatus, iCacheStatus ); |
890 RProperty::Set(KPcsInternalUidCacheStatus, EPsKeyCacheStatus, iCacheStatus ); |
1003 } |
891 } |
1004 |
892 |
1005 PRINT( _L("End CPcsAlgorithm2::UpdateCachingStatus") ); |
893 PRINT ( _L("End CPcsAlgorithm2::UpdateCachingStatus") ); |
1006 } |
894 } |
1007 |
|
1008 |
895 |
1009 // ---------------------------------------------------------------------------- |
896 // ---------------------------------------------------------------------------- |
1010 // CPcsAlgorithm2::SetCachingError |
897 // CPcsAlgorithm2::SetCachingError |
1011 // Updates cachinge error |
898 // Updates cachinge error |
1012 // ---------------------------------------------------------------------------- |
899 // ---------------------------------------------------------------------------- |
1013 void CPcsAlgorithm2::SetCachingError(const TDesC& aDataStore, TInt aError) |
900 void CPcsAlgorithm2::SetCachingError(TDesC& aDataStore, TInt aError) |
1014 { |
901 { |
1015 PRINT2 ( _L("SetCachingError::URI %S ERROR %d"), &aDataStore, aError ); |
902 PRINT2 ( _L("SetCachingError::URI %S ERROR %d"), &aDataStore, aError ); |
1016 |
903 |
1017 iCacheError = aError; |
904 iCacheError = aError; |
1018 RProperty::Set( KPcsInternalUidCacheStatus, EPsKeyCacheError, iCacheError ); |
905 RProperty::Set( KPcsInternalUidCacheStatus, EPsKeyCacheError, iCacheError ); |
1023 // Returns all the contents of a store |
910 // Returns all the contents of a store |
1024 // ---------------------------------------------------------------------------- |
911 // ---------------------------------------------------------------------------- |
1025 void CPcsAlgorithm2::GetAllContentsL(const CPsSettings& aSettings, |
912 void CPcsAlgorithm2::GetAllContentsL(const CPsSettings& aSettings, |
1026 RPointerArray<CPsData>& aResults) |
913 RPointerArray<CPsData>& aResults) |
1027 { |
914 { |
1028 //__LATENCY_MARK ( _L("CPcsAlgorithm2::GetAllContentsL") ); |
915 __LATENCY_MARK ( _L("CPcsAlgorithm2::GetAllContentsL") ); |
1029 |
916 |
1030 PRINT ( _L("Enter CPcsAlgorithm2::GetAllContentsL") ); |
917 PRINT ( _L("Enter CPcsAlgorithm2::GetAllContentsL") ); |
|
918 |
|
919 // Get the data stores |
|
920 RPointerArray<TDesC> aDataStores; |
|
921 aSettings.SearchUrisL(aDataStores); |
1031 |
922 |
1032 // To hold array of results from different data stores |
923 // To hold array of results from different data stores |
1033 typedef RPointerArray<CPsData> CPSDATA_R_PTR_ARRAY; |
924 typedef RPointerArray<CPsData> CPSDATA_R_PTR_ARRAY; |
1034 RPointerArray<CPSDATA_R_PTR_ARRAY> searchResultsArr; |
925 RPointerArray<CPSDATA_R_PTR_ARRAY> iSearchResultsArr; |
1035 CleanupResetAndDestroyPushL( searchResultsArr ); |
|
1036 // TODO: Here's still a potential memory leak if a leave happens. The child |
|
1037 // arrays of searchResultsArr are not Reset in that case. The CPsData objects |
|
1038 // may leak as well. Handling this safely is somewhat complicated because some of |
|
1039 // the CPsData objects may already be transferred to ownership of aResults array |
|
1040 // at the time the leave happens, and those items must not be deleted. |
|
1041 |
|
1042 // Get the data stores |
|
1043 RPointerArray<TDesC> dataStores; |
|
1044 CleanupResetAndDestroyPushL( dataStores ); |
|
1045 aSettings.SearchUrisL(dataStores); |
|
1046 |
926 |
1047 // Get all contacts for each data store |
927 // Get all contacts for each data store |
1048 const TInt dataStoresCount = dataStores.Count(); |
928 for (int dsIndex = 0; dsIndex < aDataStores.Count(); dsIndex++) |
1049 for (TInt dsIndex = 0; dsIndex < dataStoresCount; dsIndex++) |
|
1050 { |
929 { |
1051 RPointerArray<CPsData> *temp = new (ELeave) RPointerArray<CPsData> (); |
930 RPointerArray<CPsData> *temp = new (ELeave) RPointerArray<CPsData> (); |
1052 searchResultsArr.Append(temp); |
931 iSearchResultsArr.Append(temp); |
1053 |
932 |
1054 TInt arrayIndex = GetCacheIndex(*(dataStores[dsIndex])); |
933 TInt arrayIndex = GetCacheIndex(*(aDataStores[dsIndex])); |
1055 if (arrayIndex < 0) |
934 if (arrayIndex < 0) |
1056 { |
935 { |
1057 continue; |
936 continue; |
1058 } |
937 } |
1059 |
938 |
1060 CPcsCache* cache = GetCache(arrayIndex); |
939 CPcsCache* cache = GetCache(arrayIndex); |
1061 |
940 |
1062 cache->GetAllContentsL(*(searchResultsArr[dsIndex])); |
941 cache->GetAllContentsL(*(iSearchResultsArr[dsIndex])); |
1063 } |
942 } |
1064 |
943 |
1065 CleanupStack::PopAndDestroy( &dataStores ); // ResetAndDestroy |
944 aDataStores.ResetAndDestroy(); |
1066 |
945 |
1067 // Merge the results from different data stores |
946 // Merge the results from different data stores |
1068 CPcsAlgorithm2Utils::FormCompleteSearchResultsL(searchResultsArr, aResults); |
947 CPcsAlgorithm2Utils::FormCompleteSearchResultsL(iSearchResultsArr, aResults); |
1069 |
948 |
1070 // Cleanup the local arrays |
949 // Cleanup the local arrays |
1071 const TInt seaerchResultsArrCount = searchResultsArr.Count(); |
950 for (TInt i = 0; i < iSearchResultsArr.Count(); i++) |
1072 for (TInt i = 0; i < seaerchResultsArrCount; i++) |
951 { |
1073 { |
952 iSearchResultsArr[i]->Reset(); |
1074 searchResultsArr[i]->Reset(); |
953 delete iSearchResultsArr[i]; |
1075 } |
954 iSearchResultsArr[i] = NULL; |
1076 |
955 } |
1077 CleanupStack::PopAndDestroy( &searchResultsArr ); // ResetAndDestroy |
956 |
|
957 iSearchResultsArr.Reset(); |
1078 |
958 |
1079 PRINT1 ( _L("Number of results = %d"), aResults.Count() ); |
959 PRINT1 ( _L("Number of results = %d"), aResults.Count() ); |
1080 |
960 |
1081 PRINT ( _L("End CPcsAlgorithm2::GetAllContentsL") ); |
961 PRINT ( _L("End CPcsAlgorithm2::GetAllContentsL") ); |
1082 |
962 |
1083 //__LATENCY_MARKEND ( _L("CPcsAlgorithm2::GetAllContentsL") ); |
963 __LATENCY_MARKEND ( _L("CPcsAlgorithm2::GetAllContentsL") ); |
1084 } |
964 } |
1085 |
965 |
1086 // ---------------------------------------------------------------------------- |
966 // ---------------------------------------------------------------------------- |
1087 // CPcsAlgorithm2::IsGroupSearchL |
967 // CPcsAlgorithm2::IsGroupSearchL |
1088 // Checks if a group search is required |
968 // Checks if a group search is required |