120 // Get list of pool elements specific to a pool |
189 // Get list of pool elements specific to a pool |
121 // ---------------------------------------------------------------------------- |
190 // ---------------------------------------------------------------------------- |
122 void CPcsCache::GetContactsForKeyL(TInt aKeyId, RPointerArray<CPcsPoolElement>& aData) |
191 void CPcsCache::GetContactsForKeyL(TInt aKeyId, RPointerArray<CPcsPoolElement>& aData) |
123 { |
192 { |
124 PRINT ( _L("Enter CPcsCache::GetContactsForKeyL") ); |
193 PRINT ( _L("Enter CPcsCache::GetContactsForKeyL") ); |
125 |
194 CleanupClosePushL( aData ); |
126 if ( aKeyId >= 0 && aKeyId < iKeyArr.Count() ) |
195 RPointerArray<CPcsPoolElement> arr = *keyArr[aKeyId]; |
127 { |
196 for (int i = 0; i < arr.Count(); i++) |
128 const RPointerArray<CPcsPoolElement>& arr = *iKeyArr[aKeyId]; |
197 { |
129 const TInt arrCount = arr.Count(); |
198 CPcsPoolElement* value = arr[i]; |
130 for (TInt i = 0; i < arrCount; i++) |
199 aData.AppendL(value); |
131 { |
200 } |
132 CPcsPoolElement* value = arr[i]; |
201 |
133 aData.AppendL(value); |
202 CleanupStack::Pop(); |
134 } |
|
135 } |
|
136 |
|
137 PRINT ( _L("End CPcsCache::GetContactsForKeyL") ); |
203 PRINT ( _L("End CPcsCache::GetContactsForKeyL") ); |
138 } |
204 } |
139 |
205 |
140 // ---------------------------------------------------------------------------- |
206 // ---------------------------------------------------------------------------- |
141 // CPcsCache::GetAllContentsL |
207 // CPcsCache::GetAllContentsL |
142 // Get all data elements in this cache |
208 // Get all data elements in this cache |
143 // ---------------------------------------------------------------------------- |
209 // ---------------------------------------------------------------------------- |
144 void CPcsCache::GetAllContentsL(RPointerArray<CPsData>& aData) |
210 void CPcsCache::GetAllContentsL(RPointerArray<CPsData>& aData) |
145 { |
211 { |
146 PRINT ( _L("Enter CPcsCache::GetAllContentsL") ); |
212 PRINT ( _L("Enter CPcsCache::GetAllContentsL") ); |
147 |
213 CleanupClosePushL( aData ); |
148 const TInt masterPoolCount = iMasterPool.Count(); |
214 for (int i = 0; i < masterPool.Count(); i++) |
149 for (TInt i = 0; i < masterPoolCount; i++) |
215 { |
150 { |
216 CPsData* value = masterPool[i]; |
151 CPsData* value = iMasterPool[i]; |
|
152 aData.AppendL(value); |
217 aData.AppendL(value); |
153 } |
218 } |
154 |
219 CleanupStack::Pop(); |
155 PRINT ( _L("End CPcsCache::GetAllContentsL") ); |
220 PRINT ( _L("End CPcsCache::GetAllContentsL") ); |
156 } |
221 } |
157 |
222 |
158 // ---------------------------------------------------------------------------- |
223 // ---------------------------------------------------------------------------- |
159 // CPcsCache::AddToPool |
224 // CPcsCache::AddToPool |
160 // Adds a contact to cache |
225 // Adds a contact to cache |
161 // ---------------------------------------------------------------------------- |
226 // ---------------------------------------------------------------------------- |
162 void CPcsCache::AddToPoolL(TUint64& aPoolMap, CPsData& aData) |
227 void CPcsCache::AddToPoolL(TInt& aPoolMap, CPsData& aData) |
163 { |
228 { |
164 // Temp hash to remember the location of pool elements |
229 // Temp hash to remember the location of pool elements |
165 // First TInt = Pool |
230 // First TInt = Pool |
166 // Second TInt = Location in the pool |
231 // Second TInt = Location in the pool |
167 // Required for memory optimization so that more than one pool |
232 // Required for memory optimization so that more than one pool |
168 // element doesn't get added for the same data |
233 // element doesn't get added for the same data |
169 RHashMap<TInt, TInt> elementHash; |
234 RHashMap<TInt, TInt> elementHash; |
170 CleanupClosePushL( elementHash ); |
235 TLinearOrder<CPcsPoolElement> rule(CPcsPoolElement::CompareByData); |
171 TLinearOrder<CPcsPoolElement> rule(CPcsPoolElement::CompareByDataL); |
236 |
172 |
237 // Parse thru each data element |
173 // Parse thru each data element |
238 for (int dataIndex = 0; dataIndex < aData.DataElementCount(); dataIndex++) |
174 const TInt dataElementCount = aData.DataElementCount(); |
|
175 for (TInt dataIndex = 0; dataIndex < dataElementCount; dataIndex++) |
|
176 { |
239 { |
177 // Stores first key for each word |
240 // Stores first key for each word |
178 RArray<TChar> firstCharArr; |
241 RArray<TChar> firstKey; |
179 CleanupClosePushL( firstCharArr ); |
|
180 |
242 |
181 // Recover the first character |
243 // Recover the first character |
182 if ( aData.Data(dataIndex) ) |
244 if (aData.Data(dataIndex) && aData.Data(dataIndex)->Length() != 0) |
183 { |
245 { |
184 GetFirstCharsForDataL( *aData.Data(dataIndex), firstCharArr ); |
246 // Split the data into words |
185 } |
247 CWords* words = CWords::NewLC(*aData.Data(dataIndex)); |
186 |
248 |
187 // Get the corresponding Pool IDs |
249 // Store the first numeric key for each word |
188 RArray<TInt> poolIdArr; |
250 for (int i = 0; i < words->MdcaCount(); i++) |
189 CleanupClosePushL( poolIdArr ); |
251 { |
190 GetPoolIdsForCharsL( firstCharArr, poolIdArr ); |
252 TChar firstChar; |
191 |
253 for (int j = 0; j < words->MdcaPoint(i).Length(); j++) |
192 const TInt poolIdArrCount = poolIdArr.Count(); |
254 { |
193 for (TInt poolArrIndex = 0; poolArrIndex < poolIdArrCount ; poolArrIndex++) |
255 firstChar = (words->MdcaPoint(i))[j]; |
194 { |
256 TBuf<20> word; |
195 |
257 word.Append(firstChar); |
196 TInt poolId = poolIdArr[poolArrIndex]; |
258 if (iAlgorithm->FindUtilECE()->IsChineseWord(word)) |
|
259 { |
|
260 RPointerArray<HBufC> spellList; |
|
261 if (iAlgorithm->FindUtilECE()->T9ChineseTranslationL(firstChar, spellList)) |
|
262 { |
|
263 for (int j = 0; j < spellList.Count(); j++) |
|
264 { |
|
265 firstKey.Append(keyMap->KeyForCharacter(*(spellList[j]->Ptr()))); |
|
266 } |
|
267 } |
|
268 else |
|
269 { |
|
270 firstKey.Append( keyMap->KeyForCharacter(firstChar)); |
|
271 } |
|
272 spellList.ResetAndDestroy(); |
|
273 } |
|
274 else |
|
275 { |
|
276 firstKey.Append(keyMap->KeyForCharacter(firstChar)); |
|
277 } |
|
278 } |
|
279 } |
|
280 |
|
281 CleanupStack::PopAndDestroy(words); |
|
282 } |
|
283 |
|
284 for (TInt wordIndex = 0; wordIndex < firstKey.Count(); wordIndex++) |
|
285 { |
|
286 TInt arrayIndex = keyMap->PoolIdForCharacter(firstKey[wordIndex]); |
197 |
287 |
198 CPcsPoolElement* element = NULL; |
288 CPcsPoolElement* element = NULL; |
199 |
289 |
200 // Check if an element already exists in the pool for this data |
290 // Check if an element already exists in the pool for this data |
201 TInt* loc = NULL; |
291 TInt* loc = NULL; |
202 loc = elementHash.Find(poolId); |
292 loc = elementHash.Find(arrayIndex); |
203 if (loc != NULL) |
293 if (loc != NULL) |
204 { |
294 { |
205 // Exists. Then recover ... |
295 // Exists. Then recover ... |
206 RPointerArray<CPcsPoolElement> tmpKeyMap = *(iKeyArr[poolId]); |
296 RPointerArray<CPcsPoolElement> tmpKeyMap = *(keyArr[arrayIndex]); |
207 element = tmpKeyMap[*loc]; |
297 element = tmpKeyMap[*loc]; |
208 } |
298 } |
209 |
299 |
210 if (element == NULL) // Pool element doesn't exist. Create new ... |
300 if (element == NULL) // Pool element doesn't exist. Create new ... |
211 { |
301 { |
212 element = CPcsPoolElement::NewL(aData); |
302 element = CPcsPoolElement::NewL(aData); |
213 element->ClearDataMatchAttribute(); |
303 element->ClearDataMatchAttribute(); |
214 element->SetDataMatch(dataIndex); |
304 element->SetDataMatch(dataIndex); |
215 |
305 |
216 // Insert to pool |
306 // Insert to pool |
217 iKeyArr[poolId]->InsertInOrderAllowRepeatsL(element, rule); |
307 keyArr[arrayIndex]->InsertInOrderAllowRepeatsL(element, rule); |
218 TInt index = iKeyArr[poolId]->FindInOrderL(element, rule); |
308 TInt index = keyArr[arrayIndex]->FindInOrderL(element, rule); |
219 |
309 |
220 // Set the bit for this pool |
310 // Set the bit for this pool |
221 SetPoolMap(aPoolMap, poolId); |
311 SetPoolMap(aPoolMap, arrayIndex); |
222 |
312 |
223 // Store the array index in the temp hash |
313 // Store the array index in the temp hash |
224 elementHash.InsertL(poolId, index); |
314 elementHash.InsertL(arrayIndex, index); |
225 } |
315 } |
226 else // Pool element exists. Just alter the data match attribute |
316 else // Pool element exists. Just alter the data match attribute |
227 { |
317 { |
228 element->SetDataMatch(dataIndex); |
318 element->SetDataMatch(dataIndex); |
229 |
319 |
230 // Set the bit for this pool |
320 // Set the bit for this pool |
231 SetPoolMap(aPoolMap, poolId); |
321 SetPoolMap(aPoolMap, arrayIndex); |
232 } |
322 } |
233 |
323 |
234 } // for 2 loop |
324 } // for 2 loop |
235 |
325 |
236 CleanupStack::PopAndDestroy( &poolIdArr ); // Close |
326 firstKey.Reset(); |
237 CleanupStack::PopAndDestroy( &firstCharArr ); // Close |
|
238 |
327 |
239 } // for 1 loop |
328 } // for 1 loop |
240 |
329 |
241 CleanupStack::PopAndDestroy( &elementHash ); // Close |
330 elementHash.Close(); |
242 } |
331 } |
243 |
332 |
244 // --------------------------------------------------------------------- |
333 // --------------------------------------------------------------------- |
245 // CPcsCache::AddToCacheL |
334 // CPcsCache::AddToCacheL |
246 // |
335 // |
247 // --------------------------------------------------------------------- |
336 // --------------------------------------------------------------------- |
248 void CPcsCache::AddToCacheL(CPsData& aData) |
337 void CPcsCache::AddToCacheL(CPsData& aData) |
249 { |
338 { |
250 // Protect against duplicate items getting added |
339 // Protect against duplicate items getting added |
251 if (iCacheInfo.Find(aData.Id()) != NULL) |
340 if (cacheInfo.Find(aData.Id()) != NULL) |
252 { |
341 { |
253 return; |
342 return; |
254 } |
343 } |
255 |
344 |
256 // Include this element in the pool |
345 // Include this element in the pool |
257 TUint64 poolMap = 0; |
346 TInt poolMap = 0; |
258 AddToPoolL(poolMap, aData); |
347 AddToPoolL(poolMap, aData); |
259 iCacheInfo.InsertL(aData.Id(), poolMap); |
348 cacheInfo.InsertL(aData.Id(), poolMap); |
260 |
349 |
261 // Include this element in master pool |
350 // Include this element in master pool |
262 TLinearOrder<CPsData> rule(CPcsAlgorithm2Utils::CompareDataBySortOrderL); |
351 TLinearOrder<CPsData> rule(CPcsAlgorithm2Utils::CompareDataBySortOrder); |
263 iMasterPool.InsertInOrderAllowRepeatsL(&aData, rule); |
352 masterPool.InsertInOrderAllowRepeatsL(&aData, rule); |
264 } |
353 } |
265 |
354 |
266 // --------------------------------------------------------------------- |
355 // --------------------------------------------------------------------- |
267 // CPcsCache::RemoveContactL |
356 // CPcsCache::RemoveContactL |
268 // |
357 // |
269 // --------------------------------------------------------------------- |
358 // --------------------------------------------------------------------- |
270 void CPcsCache::RemoveFromCacheL(TInt aItemId) |
359 void CPcsCache::RemoveFromCacheL(TInt aItemId) |
271 { |
360 { |
272 CPsData *data = NULL; |
361 CPsData *data = NULL; |
273 |
362 |
274 TUint64* poolMap = iCacheInfo.Find(aItemId); |
363 TInt* poolMap = cacheInfo.Find(aItemId); |
275 |
364 |
276 if (poolMap == NULL) |
365 if (poolMap == NULL) |
277 { |
366 { |
278 return; |
367 return; |
279 } |
368 } |
280 |
369 |
281 // Remove this element from pools |
370 // Remove this element from pools |
282 const TInt keyArrCount = iKeyArr.Count(); |
371 for (int keyIndex = 0; keyIndex <= keyArr.Count(); keyIndex++) |
283 for (TInt keyIndex = 0; keyIndex < keyArrCount; keyIndex++) |
|
284 { |
372 { |
285 TBool present = GetPoolMap(*poolMap, keyIndex); |
373 TBool present = GetPoolMap(*poolMap, keyIndex); |
286 |
374 |
287 if (!present) |
375 if (!present) |
288 { |
376 { |
289 continue; |
377 continue; |
290 } |
378 } |
291 |
379 |
292 const RPointerArray<CPcsPoolElement>& tmpKeyMap = *(iKeyArr[keyIndex]); |
380 RPointerArray<CPcsPoolElement> tmpKeyMap = *(keyArr[keyIndex]); |
293 |
381 for (int arrayIndex = 0; arrayIndex < tmpKeyMap.Count(); arrayIndex++) |
294 for (TInt arrayIndex = 0; arrayIndex < tmpKeyMap.Count(); arrayIndex++) |
|
295 { |
382 { |
296 CPcsPoolElement *element = tmpKeyMap[arrayIndex]; |
383 CPcsPoolElement *element = tmpKeyMap[arrayIndex]; |
297 TInt id = element->GetPsData()->Id(); |
384 TInt id = element->GetPsData()->Id(); |
298 if (id == aItemId) |
385 if (id == aItemId) |
299 { |
386 { |
300 data = element->GetPsData(); |
387 data = element->GetPsData(); |
301 delete element; |
388 delete element; |
302 iKeyArr[keyIndex]->Remove(arrayIndex); |
389 keyArr[keyIndex]->Remove(arrayIndex); |
303 } |
390 } |
304 } |
391 } |
305 } |
392 } |
306 |
393 |
307 // Remove this element from master pool |
394 // Remove this element from master pool |
308 for (TInt arrayIndex = 0; arrayIndex < iMasterPool.Count(); arrayIndex++) |
395 for (int arrayIndex = 0; arrayIndex < masterPool.Count(); arrayIndex++) |
309 { |
396 { |
310 CPsData *dataElement = iMasterPool[arrayIndex]; |
397 CPsData *dataElement = masterPool[arrayIndex]; |
311 TInt id = dataElement->Id(); |
398 TInt id = dataElement->Id(); |
312 if (id == aItemId) |
399 if (id == aItemId) |
313 { |
400 { |
314 iMasterPool.Remove(arrayIndex); |
401 masterPool.Remove(arrayIndex); |
315 } |
402 } |
316 } |
403 } |
317 |
404 |
318 // Delete data |
405 // Delete data |
319 if (data) |
406 if (data) |
321 delete data; |
408 delete data; |
322 data = NULL; |
409 data = NULL; |
323 } |
410 } |
324 |
411 |
325 // Clear up cache information |
412 // Clear up cache information |
326 iCacheInfo.Remove(aItemId); |
413 cacheInfo.Remove(aItemId); |
327 } |
414 } |
328 |
415 |
329 // --------------------------------------------------------------------- |
416 // --------------------------------------------------------------------- |
330 // CPcsCache::RemoveAllFromCacheL |
417 // CPcsCache::RemoveAllFromCacheL |
331 // |
418 // |
332 // --------------------------------------------------------------------- |
419 // --------------------------------------------------------------------- |
333 void CPcsCache::RemoveAllFromCache() |
420 void CPcsCache::RemoveAllFromCacheL() |
334 { |
421 { |
335 PRINT ( _L("Enter CPcsCache::RemoveAllFromCache") ); |
422 PRINT ( _L("Enter CPcsCache::RemoveAllFromCacheL") ); |
336 |
423 |
337 const TInt keyArrCount = iKeyArr.Count(); |
424 for (TInt i = 0; i < keyArr.Count(); i++) |
338 for ( TInt i = 0 ; i < keyArrCount ; i++ ) |
425 { |
339 { |
426 keyArr[i]->ResetAndDestroy(); |
340 iKeyArr[i]->ResetAndDestroy(); |
427 |
341 } |
428 } |
342 |
429 |
343 iMasterPool.ResetAndDestroy(); |
430 masterPool.ResetAndDestroy(); |
344 iCacheInfo.Close(); |
431 cacheInfo.Close(); |
345 |
432 |
346 PRINT ( _L("End CPcsCache::RemoveAllFromCache") ); |
433 PRINT ( _L("End CPcsCache::RemoveAllFromCacheL") ); |
347 } |
434 } |
348 |
435 |
349 // --------------------------------------------------------------------- |
436 // --------------------------------------------------------------------- |
350 // CPcsCache::SetPoolMap |
437 // CPcsCache::SetPoolMap |
351 // |
438 // |
352 // --------------------------------------------------------------------- |
439 // --------------------------------------------------------------------- |
353 void CPcsCache::SetPoolMap(TUint64& aPoolMap, TInt aArrayIndex) |
440 void CPcsCache::SetPoolMap(TInt& aPoolMap, TInt arrayIndex) |
354 { |
441 { |
355 __ASSERT_DEBUG( aArrayIndex < 64, User::Panic(_L("CPcsCache"), KErrOverflow ) ); |
442 TReal val; |
356 |
443 Math::Pow(val, 2, arrayIndex); |
357 /* Some platforms do not support 64 bits shift operations. |
444 |
358 * Split to two 32 bits operations. |
445 aPoolMap |= (TInt) val; |
359 */ |
|
360 |
|
361 TUint32 poolMapH = I64HIGH(aPoolMap); |
|
362 TUint32 poolMapL = I64LOW(aPoolMap); |
|
363 |
|
364 TUint32 valH = 0; |
|
365 TUint32 valL = 0; |
|
366 if (aArrayIndex < 32) |
|
367 { |
|
368 valL = 1 << aArrayIndex; |
|
369 } |
|
370 else |
|
371 { |
|
372 valH = 1 << (aArrayIndex-32); |
|
373 } |
|
374 |
|
375 poolMapH |= valH; |
|
376 poolMapL |= valL; |
|
377 |
|
378 aPoolMap = MAKE_TUINT64(poolMapH, poolMapL); |
|
379 } |
446 } |
380 |
447 |
381 // --------------------------------------------------------------------- |
448 // --------------------------------------------------------------------- |
382 // CPcsCache::GetPoolMap |
449 // CPcsCache::GetPoolMap |
383 // |
450 // |
384 // --------------------------------------------------------------------- |
451 // --------------------------------------------------------------------- |
385 TBool CPcsCache::GetPoolMap(TUint64& aPoolMap, TInt aArrayIndex) |
452 TBool CPcsCache::GetPoolMap(TInt& aPoolMap, TInt arrayIndex) |
386 { |
453 { |
387 __ASSERT_DEBUG( aArrayIndex < 64, User::Panic(_L("CPcsCache"), KErrOverflow ) ); |
454 TReal val; |
388 |
455 Math::Pow(val, 2, arrayIndex); |
389 /* Some platforms do not support 64 bits shift operations. |
456 |
390 * Split to two 32 bits operations. |
457 return (aPoolMap & (TInt) val); |
391 */ |
|
392 |
|
393 TUint32 poolMapH = I64HIGH(aPoolMap); |
|
394 TUint32 poolMapL = I64LOW(aPoolMap); |
|
395 |
|
396 TUint32 valH = 0; |
|
397 TUint32 valL = 0; |
|
398 if (aArrayIndex < 32) |
|
399 { |
|
400 valL = 1 << aArrayIndex; |
|
401 } |
|
402 else |
|
403 { |
|
404 valH = 1 << (aArrayIndex-32); |
|
405 } |
|
406 |
|
407 TBool ret = (poolMapH & valH) || (poolMapL & valL); |
|
408 |
|
409 return (ret); |
|
410 } |
|
411 |
|
412 // --------------------------------------------------------------------- |
|
413 // CPcsCache::GetFirstCharsForDataL |
|
414 // |
|
415 // --------------------------------------------------------------------- |
|
416 void CPcsCache::GetFirstCharsForDataL( const TDesC& aData, RArray<TChar>& aFirstChars ) const |
|
417 { |
|
418 // Split the data into words |
|
419 CWords* words = CWords::NewLC(aData); |
|
420 |
|
421 // Find indexing characters for each word |
|
422 for (TInt i = 0; i < words->MdcaCount(); i++) |
|
423 { |
|
424 TPtrC16 word = words->MdcaPoint(i); |
|
425 TBool lastCharIsChinese = EFalse; |
|
426 |
|
427 // If the word contains any Chinese characters, then it is |
|
428 // stored to cache according all the available spellings of |
|
429 // all the Chinese characters |
|
430 if ( iAlgorithm->FindUtilECE()->IsChineseWordIncluded(word) ) |
|
431 { |
|
432 const TInt wordLength = word.Length(); |
|
433 for (TInt j = 0; j < wordLength; j++) |
|
434 { |
|
435 TText curChar = word[j]; |
|
436 RPointerArray<HBufC> spellList; |
|
437 CleanupResetAndDestroyPushL( spellList ); |
|
438 if ( iAlgorithm->FindUtilECE()->DoTranslationL(curChar, spellList) ) |
|
439 { |
|
440 lastCharIsChinese = ETrue; |
|
441 // Append first char of each spelling |
|
442 const TInt spellListCount = spellList.Count(); |
|
443 for (TInt k = 0; k < spellListCount; k++) |
|
444 { |
|
445 const HBufC* spelling = spellList[k]; |
|
446 aFirstChars.AppendL( (*spelling)[0] ); |
|
447 } |
|
448 } |
|
449 else |
|
450 { |
|
451 if ( lastCharIsChinese ) |
|
452 { |
|
453 aFirstChars.AppendL( word[j] ); |
|
454 lastCharIsChinese = EFalse; |
|
455 } |
|
456 } |
|
457 CleanupStack::PopAndDestroy( &spellList ); // ResetAndDestroy |
|
458 } |
|
459 } |
|
460 |
|
461 // If the first charcter of the word is non-Chinese, then it's stored to the |
|
462 // cache according this first character. Other characters of the word may or |
|
463 // may not be Chinese. |
|
464 if ( !iAlgorithm->FindUtilECE()->IsChineseWordIncluded( word.Left(1) ) ) |
|
465 { |
|
466 aFirstChars.AppendL( word[0] ); |
|
467 } |
|
468 } |
|
469 CleanupStack::PopAndDestroy(words); |
|
470 } |
|
471 |
|
472 // --------------------------------------------------------------------- |
|
473 // CPcsCache::GetPoolIdsForCharsL |
|
474 // |
|
475 // --------------------------------------------------------------------- |
|
476 void CPcsCache::GetPoolIdsForCharsL( const RArray<TChar>& aChars, RArray<TInt>& aPoolIds ) const |
|
477 { |
|
478 // There can potentially be two pool IDs for each character. |
|
479 // Reserve memory for this upfront to prevent unnecessary reallocations. |
|
480 aPoolIds.ReserveL( aChars.Count() * 2 ); |
|
481 |
|
482 const TInt charsCount = aChars.Count() ; |
|
483 for ( TInt i = 0 ; i < charsCount ; ++i ) |
|
484 { |
|
485 TChar character = aChars[i]; |
|
486 TInt itutPoolId = iKeyMap->PoolIdForCharacter( character, EPredictiveItuT ); |
|
487 if ( itutPoolId != KErrNotFound ) |
|
488 { |
|
489 aPoolIds.AppendL( itutPoolId ); |
|
490 } |
|
491 |
|
492 TInt qwertyPoolId = iKeyMap->PoolIdForCharacter( character, EPredictiveQwerty ); |
|
493 if ( qwertyPoolId != KErrNotFound ) |
|
494 { |
|
495 aPoolIds.AppendL( qwertyPoolId ); |
|
496 } |
|
497 } |
|
498 } |
458 } |
499 |
459 |
500 // --------------------------------------------------------------------- |
460 // --------------------------------------------------------------------- |
501 // CPcsCache::GetURI |
461 // CPcsCache::GetURI |
502 // |
462 // |
643 // CPcsCache::ResortdataInPools |
599 // CPcsCache::ResortdataInPools |
644 // |
600 // |
645 // --------------------------------------------------------------------- |
601 // --------------------------------------------------------------------- |
646 void CPcsCache::ResortdataInPoolsL() |
602 void CPcsCache::ResortdataInPoolsL() |
647 { |
603 { |
648 // copy iMasterPool data into iMasterPoolBackup |
604 // copy masterPool data into masterPoolBackup |
649 const TInt masterPoolCount = iMasterPool.Count(); |
605 for (TInt i = 0; i < masterPool.Count(); i++ ) |
650 for (TInt i = 0; i < masterPoolCount; i++ ) |
606 { |
651 { |
607 masterPoolBackup.Append( masterPool[i] ); |
652 iMasterPoolBackup.Append( iMasterPool[i] ); |
|
653 } |
608 } |
654 //Now reset the key array |
609 //Now reset the key array |
655 const TInt keyArrCount = iKeyArr.Count(); |
610 for (TInt i = 0; i < keyArr.Count(); i++ ) |
656 for (TInt i = 0; i <keyArrCount; i++ ) |
611 { |
657 { |
612 keyArr[i]->ResetAndDestroy(); |
658 iKeyArr[i]->ResetAndDestroy(); |
613 } |
659 } |
614 masterPool.Reset(); |
660 iMasterPool.Reset(); |
615 cacheInfo.Close(); |
661 iCacheInfo.Close(); |
616 //now add data again from the masterPoolBackup |
662 //now add data again from the iMasterPoolBackup |
617 for (TInt i = 0; i < masterPoolBackup.Count(); i++ ) |
663 const TInt masterPoolBackupCount = iMasterPoolBackup.Count(); |
618 { |
664 for (TInt i = 0; i < masterPoolBackupCount; i++ ) |
619 CPsData* temp = static_cast<CPsData*>(masterPoolBackup[i]); |
665 { |
|
666 CPsData* temp = iMasterPoolBackup[i]; |
|
667 AddToCacheL( *temp ); |
620 AddToCacheL( *temp ); |
668 } |
621 } |
669 iMasterPoolBackup.Reset(); |
622 masterPoolBackup.Reset(); |
670 } |
623 } |
671 |
|
672 // --------------------------------------------------------------------- |
|
673 // CPcsCache::GetFirstNameIndex |
|
674 // |
|
675 // --------------------------------------------------------------------- |
|
676 TInt CPcsCache::GetFirstNameIndex() const |
|
677 { |
|
678 TInt fnIndex = KErrNotFound; |
|
679 const TInt dataFieldsCount = iDataFields.Count(); |
|
680 for ( TInt i = 0 ; i < dataFieldsCount && fnIndex == KErrNotFound ; ++i ) |
|
681 { |
|
682 if ( iDataFields[i] == R_VPBK_FIELD_TYPE_FIRSTNAME ) |
|
683 { |
|
684 fnIndex = i; |
|
685 } |
|
686 } |
|
687 return fnIndex; |
|
688 } |
|
689 |
|
690 // --------------------------------------------------------------------- |
|
691 // CPcsCache::GetLastNameIndex |
|
692 // |
|
693 // --------------------------------------------------------------------- |
|
694 TInt CPcsCache::GetLastNameIndex() const |
|
695 { |
|
696 TInt lnIndex = KErrNotFound; |
|
697 const TInt dataFieldsCount = iDataFields.Count(); |
|
698 for ( TInt i = 0 ; i < dataFieldsCount && lnIndex == KErrNotFound ; ++i ) |
|
699 { |
|
700 if ( iDataFields[i] == R_VPBK_FIELD_TYPE_LASTNAME ) |
|
701 { |
|
702 lnIndex = i; |
|
703 } |
|
704 } |
|
705 return lnIndex; |
|
706 } |
|
707 |
|
708 // End of file |
624 // End of file |