|
1 /* |
|
2 * Copyright (c) 2003-2006 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: Predective text input engine API implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <f32file.h> |
|
20 #include <barsc.h> |
|
21 #include <barsread.h> |
|
22 |
|
23 #include "PtiEngineImpl.h" |
|
24 #include "PtiDefaultCore.h" |
|
25 #include "PtiLanguage.h" |
|
26 #include <PtiEngine.rsg> |
|
27 #include "PtiUserDicEntry.h" |
|
28 #include "PtiEngine.h" |
|
29 #include "PtiKeyMappings.h" |
|
30 #include <ecom/ecom.h> |
|
31 #include <PtiHwrRecognizer.h> |
|
32 #include <PtiKeyMapData.h> |
|
33 |
|
34 #include <data_caging_path_literals.hrh> |
|
35 #ifdef RD_HINDI_PHONETIC_INPUT |
|
36 #include <Languages.hrh> |
|
37 #endif |
|
38 #include <AknUtils.h> |
|
39 #include <e32property.h> |
|
40 #include <AknFepInternalCRKeys.h> |
|
41 #include <AvkonInternalCRKeys.h> |
|
42 |
|
43 const TInt KDefaultLanguageGran = 5; |
|
44 const TInt KDefaultLangNamesGran = 40; |
|
45 const TInt KPhraseSeparator = 0x0020; |
|
46 const TInt KMaxPhraseBufferSize = 255; |
|
47 const TInt KMaxCandPages = 100; |
|
48 |
|
49 const TInt KPtiChineseHash = 0xff03; |
|
50 const TInt KPtiChineseStar = 0xff0a; |
|
51 const TInt KPtiChinesePlus = 0xff0b; |
|
52 |
|
53 const TInt KUserDictionaryMaxSize = 32768; |
|
54 |
|
55 const TInt KDirectlyAllowedScanCodesStart = 0x0021; |
|
56 const TInt KDirectlyAllowedScanCodesEnd = 0x005f; |
|
57 |
|
58 // This is needed for resource reading. |
|
59 const TInt KCCMask(0x00000fff); |
|
60 |
|
61 const TPtiKey qwertyKeys[] = |
|
62 { |
|
63 EPtiKeyQwerty1, EPtiKeyQwerty2, EPtiKeyQwerty3, EPtiKeyQwerty4, EPtiKeyQwerty5, |
|
64 EPtiKeyQwerty6, EPtiKeyQwerty7, EPtiKeyQwerty8, EPtiKeyQwerty9, EPtiKeyQwerty0, |
|
65 #if defined(__WINS__) |
|
66 (TPtiKey)EStdKeyNkpPlus, // Emulator produces different scancode for plus key than real hardware. |
|
67 #else |
|
68 EPtiKeyQwertyPlus, |
|
69 #endif |
|
70 EPtiKeyQwertyMinus, EPtiKeyQwertyComma, EPtiKeyQwertySemicolon,EPtiKeyQwertyChr,EPtiKeyQwertyLeftShift, |
|
71 EPtiKeyQwertyFullstop, EPtiKeyQwertyHash, EPtiKeyQwertySlash, EPtiKeyQwertyApostrophe, |
|
72 EPtiKeyQwertySpace, EPtiKeyQwertyA, EPtiKeyQwertyB, EPtiKeyQwertyC, EPtiKeyQwertyD, |
|
73 EPtiKeyQwertyE, EPtiKeyQwertyF, EPtiKeyQwertyG, EPtiKeyQwertyH, EPtiKeyQwertyI, |
|
74 EPtiKeyQwertyJ, EPtiKeyQwertyK, EPtiKeyQwertyL, EPtiKeyQwertyM, EPtiKeyQwertyN, |
|
75 EPtiKeyQwertyO, EPtiKeyQwertyP, EPtiKeyQwertyQ, EPtiKeyQwertyR, EPtiKeyQwertyS, |
|
76 EPtiKeyQwertyT, EPtiKeyQwertyU, EPtiKeyQwertyV, EPtiKeyQwertyW, EPtiKeyQwertyX, |
|
77 EPtiKeyQwertyY, EPtiKeyQwertyZ, EPtiKeyQwertyAtCharacter, (TPtiKey)0 |
|
78 }; |
|
79 |
|
80 |
|
81 // Currently Japanese doesn't have real qwerty keymappings data file, but |
|
82 // GetNumericModeKeysForQwertyL needs to work also for ELangJapanese. We'll handle |
|
83 // it as a hardcoded special case for now. |
|
84 const TInt KNumBindingsForNonLatinNumberLanguages = 15; |
|
85 const TInt KNumExtendedBindingsForNonLatinNumberLanguages = 22; |
|
86 const TPtiNumericKeyBinding NumericModeKeysForNonLatinNumberLanguages[] = |
|
87 { |
|
88 {'0', EPtiKeyQwerty0, EPtiCaseLower}, |
|
89 {'1', EPtiKeyQwerty1, EPtiCaseLower}, |
|
90 {'2', EPtiKeyQwerty2, EPtiCaseLower}, |
|
91 {'3', EPtiKeyQwerty3, EPtiCaseLower}, |
|
92 {'4', EPtiKeyQwerty4, EPtiCaseLower}, |
|
93 {'5', EPtiKeyQwerty5, EPtiCaseLower}, |
|
94 {'6', EPtiKeyQwerty6, EPtiCaseLower}, |
|
95 {'7', EPtiKeyQwerty7, EPtiCaseLower}, |
|
96 {'8', EPtiKeyQwerty8, EPtiCaseLower}, |
|
97 {'9', EPtiKeyQwerty9, EPtiCaseLower}, |
|
98 {'p', EPtiKeyQwertyP, EPtiCaseLower}, |
|
99 {'w', EPtiKeyQwertyW, EPtiCaseLower}, |
|
100 {'+', EPtiKeyQwertyPlus, EPtiCaseLower}, |
|
101 {'#', EPtiKeyQwerty3, EPtiCaseUpper}, |
|
102 {'*', EPtiKeyQwertyApostrophe, EPtiCaseUpper}, |
|
103 {';', EPtiKeyQwertySemicolon, EPtiCaseLower}, |
|
104 {'.', EPtiKeyQwertyFullstop, EPtiCaseLower}, |
|
105 {',', EPtiKeyQwertyComma, EPtiCaseLower}, |
|
106 {'-', EPtiKeyQwertyMinus, EPtiCaseLower}, |
|
107 {'E', EPtiKeyQwertyE, EPtiCaseUpper}, |
|
108 {'?', EPtiKeyQwertySlash, EPtiCaseUpper}, |
|
109 {'/', EPtiKeyQwertySlash, EPtiCaseLower} |
|
110 }; |
|
111 |
|
112 |
|
113 // Resource file name. |
|
114 _LIT(KCEResourceFile, "z:PtiEngine.rsc"); |
|
115 _LIT(KNumericLangName, "Numeric"); |
|
116 _LIT(KPtiDefaultUdbPath, "c:\\Predic\\"); |
|
117 _LIT(KAllowedNumericChars, "0123456789pw+#*"); |
|
118 _LIT(KAllAllowedNumericChars, "*+pw#1234567890;.,-E?/"); |
|
119 _LIT(KExtendedNumericModeChars, ";.,-E?/"); |
|
120 #ifdef _DEBUG |
|
121 _LIT(KPtiEngineImplPanic, "PtiEngineImpl"); |
|
122 #endif |
|
123 |
|
124 // CONSTANTS |
|
125 const TInt16 KStrokeHorizontalValue = 0x4e00; |
|
126 const TInt16 KStrokeVerticalValue = 0x4e28; |
|
127 const TInt16 KStrokeDownToLeftValue = 0x4e3f; |
|
128 const TInt16 KStrokeDownToRightValue = 0x4e36; |
|
129 const TInt16 KStrokeBendingValue = 0x4e5b; |
|
130 const TInt16 KStrokeQuestionValue = 0x003f; |
|
131 const TInt16 KStrokeUnicode = 0x2461; |
|
132 const TInt16 KZhuyinIndicator = 0x2462; |
|
133 |
|
134 // Local method declarations. |
|
135 LOCAL_C TInt RemapVietnameseAccentedCharacter(TUint16 aChr); |
|
136 |
|
137 // |
|
138 // CPtiEngineImpl implementation |
|
139 // |
|
140 |
|
141 // --------------------------------------------------------------------------- |
|
142 // CPtiEngineImpl::NewL |
|
143 // |
|
144 // --------------------------------------------------------------------------- |
|
145 // |
|
146 CPtiEngineImpl* CPtiEngineImpl::NewL(CPtiEngine* aFrontEnd) |
|
147 { |
|
148 CPtiEngineImpl *engine = new (ELeave) CPtiEngineImpl(); |
|
149 CleanupStack::PushL( engine ); |
|
150 engine->ConstructL(aFrontEnd); |
|
151 CleanupStack::Pop(); // engine |
|
152 return engine; |
|
153 } |
|
154 |
|
155 |
|
156 // --------------------------------------------------------------------------- |
|
157 // CPtiEngineImpl::CPtiEngineImpl |
|
158 // |
|
159 // --------------------------------------------------------------------------- |
|
160 // |
|
161 CPtiEngineImpl::CPtiEngineImpl() |
|
162 { |
|
163 } |
|
164 |
|
165 |
|
166 // --------------------------------------------------------------------------- |
|
167 // CPtiEngineImpl::~CPtiEngineImpl |
|
168 // |
|
169 // --------------------------------------------------------------------------- |
|
170 // |
|
171 CPtiEngineImpl::~CPtiEngineImpl() |
|
172 { |
|
173 iExtendedNumricSet.Close(); |
|
174 |
|
175 DetachUserDictionaries(); |
|
176 iUserDictionaries.ResetAndDestroy(); |
|
177 |
|
178 if (iCores) |
|
179 { |
|
180 iCores->ResetAndDestroy(); |
|
181 delete iCores; |
|
182 } |
|
183 if (iLanguages) |
|
184 { |
|
185 iLanguages->ResetAndDestroy(); |
|
186 delete iLanguages; |
|
187 } |
|
188 |
|
189 REComSession::FinalClose(); |
|
190 |
|
191 delete iCurrentHwrImpl; |
|
192 iImpIdList.Close(); |
|
193 } |
|
194 |
|
195 |
|
196 // --------------------------------------------------------------------------- |
|
197 // CPtiEngineImpl::ConstructL |
|
198 // |
|
199 // --------------------------------------------------------------------------- |
|
200 // |
|
201 void CPtiEngineImpl::ConstructL(CPtiEngine* aFrontEnd) |
|
202 { |
|
203 iFrontEnd = aFrontEnd; |
|
204 iLanguages = new( ELeave ) CArrayPtrFlat<CPtiCoreLanguage>( KDefaultLanguageGran ); |
|
205 iCores = new (ELeave) CArrayPtrFlat<CPtiCore>( KDefaultCoresGran ); |
|
206 TBuf<KPtiMaxWordSize > mapChars; |
|
207 mapChars.Zero(); |
|
208 iPunctuationCharacters.Zero(); |
|
209 MappingDataForKey((TPtiKey)EStdKeyFullStop,mapChars,EPtiCaseLower); |
|
210 iPunctuationCharacters.Copy(mapChars); |
|
211 MappingDataForKey((TPtiKey)EStdKeyFullStop,mapChars,EPtiCaseUpper); |
|
212 iPunctuationCharacters.Append(mapChars); |
|
213 MappingDataForKey((TPtiKey)EStdKeyFullStop,mapChars,EPtiCaseFnLower); |
|
214 iPunctuationCharacters.Append(mapChars); |
|
215 MappingDataForKey((TPtiKey)EStdKeyFullStop,mapChars,EPtiCaseFnUpper); |
|
216 iPunctuationCharacters.Append(mapChars); |
|
217 } |
|
218 |
|
219 |
|
220 // --------------------------------------------------------------------------- |
|
221 // CPtiEngineImpl::InitializeL |
|
222 // |
|
223 // --------------------------------------------------------------------------- |
|
224 // |
|
225 void CPtiEngineImpl::InitializeL(TBool aUseDefaultUserDictionary) |
|
226 { |
|
227 CPtiCore* mtCore = CPtiDefaultCore::NewL(iFrontEnd, &iTextBuffer); |
|
228 CleanupStack::PushL(mtCore); |
|
229 iCores->AppendL( mtCore ); |
|
230 CleanupStack::Pop(); // mtCore |
|
231 mtCore->InitializeL(iFrontEnd, &iTextBuffer, iLanguages, aUseDefaultUserDictionary); |
|
232 |
|
233 CPtiCoreLanguage* numLang = CreateNumericLanguageL(mtCore); |
|
234 CleanupStack::PushL(numLang); |
|
235 iLanguages->AppendL(numLang); |
|
236 CleanupStack::Pop(); // numLang |
|
237 |
|
238 LoadCoresInDefaultDirL(aUseDefaultUserDictionary); |
|
239 |
|
240 RefreshLanguageNamesL(); |
|
241 } |
|
242 |
|
243 |
|
244 // --------------------------------------------------------------------------- |
|
245 // CPtiEngineImpl::GetLanguage |
|
246 // |
|
247 // --------------------------------------------------------------------------- |
|
248 // |
|
249 MPtiLanguage* CPtiEngineImpl::GetLanguage(TInt aCode) const |
|
250 { |
|
251 const TInt count = iLanguages->Count(); |
|
252 for (TInt i = 0; i < count; i++) |
|
253 { |
|
254 if (iLanguages->At(i)->LanguageCode() == aCode) |
|
255 { |
|
256 return iLanguages->At(i); |
|
257 } |
|
258 } |
|
259 |
|
260 return NULL; |
|
261 } |
|
262 |
|
263 |
|
264 // --------------------------------------------------------------------------- |
|
265 // CPtiEngineImpl::GetAvailableLanguagesL |
|
266 // |
|
267 // --------------------------------------------------------------------------- |
|
268 // |
|
269 void CPtiEngineImpl::GetAvailableLanguagesL(CArrayFix<TInt>* aResult) |
|
270 { |
|
271 if (aResult) |
|
272 { |
|
273 aResult->Reset(); |
|
274 |
|
275 const TInt count = iLanguages->Count(); |
|
276 #ifdef RD_HINDI_PHONETIC_INPUT |
|
277 TBool isIndicPhoneticInputPresent = EFalse; |
|
278 for (TInt i = 0; i < count; i++) |
|
279 { |
|
280 if (iLanguages->At(i)->LanguageCode() == KLangHindiPhonetic) |
|
281 { |
|
282 isIndicPhoneticInputPresent = ETrue; |
|
283 } |
|
284 } |
|
285 #endif |
|
286 for (TInt i = 0; i < count; i++) |
|
287 { |
|
288 if ((iLanguages->At(i)->LanguageCode() != ELangNumeric) |
|
289 #ifdef RD_HINDI_PHONETIC_INPUT |
|
290 && (iLanguages->At(i)->LanguageCode() != KLangHindiPhonetic) |
|
291 #endif |
|
292 ) |
|
293 { |
|
294 aResult->AppendL(iLanguages->At(i)->LanguageCode()); |
|
295 #ifdef RD_HINDI_PHONETIC_INPUT |
|
296 if (iLanguages->At(i)->LanguageCode() == ELangHindi && isIndicPhoneticInputPresent) |
|
297 aResult->AppendL(KLangHindiPhonetic); |
|
298 #endif |
|
299 } |
|
300 } |
|
301 } |
|
302 } |
|
303 |
|
304 |
|
305 // --------------------------------------------------------------------------- |
|
306 // CPtiEngineImpl::CreateUserDictionaryL |
|
307 // |
|
308 // --------------------------------------------------------------------------- |
|
309 // |
|
310 TInt CPtiEngineImpl::CreateUserDictionaryL(TDesC& aFileName, CDesCArrayFlat* aWords, TPtiEngineInputMode aMode) |
|
311 { |
|
312 CPtiCore* core = CoreForInputMode( aMode ); |
|
313 if (!SupportsUserDictionaries(core)) |
|
314 { |
|
315 return KErrNotSupported; |
|
316 } |
|
317 |
|
318 CPtiUserDictionary* ud = core->CreateEmptyUserDictionaryL(KUserDictionaryMaxSize); |
|
319 CleanupStack::PushL(ud); |
|
320 ud->SetFileName( aFileName ); |
|
321 ud->SetCoreUID(core->GetCoreInfo()->Uid()); |
|
322 |
|
323 TInt error = core->AttachUserDictionary( ud ); |
|
324 if (error != KErrNone) |
|
325 { |
|
326 CleanupStack::PopAndDestroy(); // ud |
|
327 return error; |
|
328 } |
|
329 |
|
330 User::LeaveIfError(iUserDictionaries.Append(ud)); |
|
331 |
|
332 CleanupStack::Pop(); // ud |
|
333 |
|
334 for (TInt i = 0; i < aWords->Count(); i++) |
|
335 { |
|
336 TPtiUserDictionaryEntry entry(aWords->MdcaPoint(i)); |
|
337 error = core->AddUserDictionaryEntry(entry, ud); |
|
338 if (error != KErrNone) |
|
339 { |
|
340 return error; |
|
341 } |
|
342 } |
|
343 |
|
344 return KErrNone; |
|
345 } |
|
346 |
|
347 |
|
348 // --------------------------------------------------------------------------- |
|
349 // CPtiEngineImpl::AttachUserDictionaryL |
|
350 // |
|
351 // --------------------------------------------------------------------------- |
|
352 // |
|
353 MPtiUserDictionary* CPtiEngineImpl::AttachUserDictionaryL(TDesC& aFileName) |
|
354 { |
|
355 TInt coreUid = ReadUidFromUserDictionaryFileL(aFileName); |
|
356 |
|
357 CPtiUserDictionary* ud = NULL; |
|
358 CPtiCore *core = FindCoreByUid(coreUid); |
|
359 if (!SupportsUserDictionaries(core)) |
|
360 { |
|
361 return NULL; |
|
362 } |
|
363 |
|
364 ud = core->CreateEmptyUserDictionaryL(KUserDictionaryMaxSize); |
|
365 CleanupStack::PushL(ud); |
|
366 |
|
367 TRAPD(err, ud->OpenL(aFileName, KUserDictionaryMaxSize)); |
|
368 if (err == KErrCorrupt) |
|
369 { |
|
370 // Checksum didn't match or there was some other corruption. |
|
371 // Try to delete corrupted file and leave. |
|
372 RFs fsSession; |
|
373 User::LeaveIfError( fsSession.Connect() ); |
|
374 fsSession.Delete(aFileName); |
|
375 fsSession.Close(); |
|
376 User::Leave(KErrCorrupt); |
|
377 } |
|
378 User::LeaveIfError(err); |
|
379 |
|
380 TInt error = core->AttachUserDictionary( ud ); |
|
381 if (error != KErrNone) |
|
382 { |
|
383 CleanupStack::PopAndDestroy(); // ud |
|
384 return NULL; |
|
385 } |
|
386 |
|
387 User::LeaveIfError(iUserDictionaries.Append( ud )); |
|
388 CleanupStack::Pop(); // ud |
|
389 |
|
390 return ud; |
|
391 } |
|
392 |
|
393 |
|
394 // --------------------------------------------------------------------------- |
|
395 // CPtiEngineImpl::AttachDefaultUserDictionaryL |
|
396 // |
|
397 // --------------------------------------------------------------------------- |
|
398 // |
|
399 MPtiUserDictionary* CPtiEngineImpl::AttachDefaultUserDictionaryL(TUid aCoreUid, TInt aSymbolClass) |
|
400 { |
|
401 TFileName fileName; |
|
402 |
|
403 CreateUserDictName(fileName, aCoreUid, aSymbolClass); |
|
404 |
|
405 return AttachUserDictionaryL(fileName); |
|
406 } |
|
407 |
|
408 |
|
409 // --------------------------------------------------------------------------- |
|
410 // CPtiEngineImpl::DetachUserDictionary |
|
411 // |
|
412 // --------------------------------------------------------------------------- |
|
413 // |
|
414 TInt CPtiEngineImpl::DetachUserDictionary(TDesC& aFileName) |
|
415 { |
|
416 for (TInt i = 0; i < iUserDictionaries.Count(); i++) |
|
417 { |
|
418 if (!iUserDictionaries[i]->FileName().Compare(aFileName)) |
|
419 { |
|
420 CPtiCore* core = FindCoreByUid(iUserDictionaries[i]->CoreUID()); |
|
421 if (SupportsUserDictionaries(core)) |
|
422 { |
|
423 if ((core->DetachUserDictionary(iUserDictionaries[i])) || |
|
424 (iUserDictionaries[i]->UpdateFlag())) |
|
425 { |
|
426 TRAPD(err, iUserDictionaries[i]->WriteL()); |
|
427 return err; |
|
428 } |
|
429 } |
|
430 else |
|
431 { |
|
432 return KErrCorrupt; |
|
433 } |
|
434 |
|
435 delete iUserDictionaries[i]; |
|
436 iUserDictionaries.Remove(i); |
|
437 return KErrNone; |
|
438 } |
|
439 } |
|
440 |
|
441 return KErrNotFound; |
|
442 } |
|
443 |
|
444 |
|
445 // --------------------------------------------------------------------------- |
|
446 // CPtiEngineImpl::DetachUserDictionary |
|
447 // |
|
448 // --------------------------------------------------------------------------- |
|
449 // |
|
450 TInt CPtiEngineImpl::DetachUserDictionary(TInt aId) |
|
451 { |
|
452 for (TInt i = 0; i < iUserDictionaries.Count(); i++) |
|
453 { |
|
454 if (iUserDictionaries[i]->Id() == aId) |
|
455 { |
|
456 CPtiCore* core = FindCoreByUid(iUserDictionaries[i]->CoreUID()); |
|
457 if (SupportsUserDictionaries(core)) |
|
458 { |
|
459 if ((core->DetachUserDictionary(iUserDictionaries[i])) || |
|
460 (iUserDictionaries[i]->UpdateFlag())) |
|
461 { |
|
462 TRAPD(err, iUserDictionaries[i]->WriteL()); |
|
463 return err; |
|
464 } |
|
465 return KErrNone; |
|
466 } |
|
467 else |
|
468 { |
|
469 return KErrCorrupt; |
|
470 } |
|
471 } |
|
472 } |
|
473 |
|
474 return KErrNotFound; |
|
475 } |
|
476 |
|
477 |
|
478 // --------------------------------------------------------------------------- |
|
479 // CPtiEngineImpl::SetCurrentWord |
|
480 // |
|
481 // --------------------------------------------------------------------------- |
|
482 // |
|
483 TInt CPtiEngineImpl::SetCurrentWord(TPtrC aWord) |
|
484 { |
|
485 if (aWord.Length() == 0) |
|
486 { |
|
487 return KErrNone; |
|
488 } |
|
489 |
|
490 if (IsCore()) |
|
491 { |
|
492 if (aWord.Length() > iTextBuffer.MaxLength()) |
|
493 { |
|
494 return KErrTooBig; |
|
495 } |
|
496 // Predictive QWERTY (XT9) changes ----> |
|
497 // The core may choose to ignore the resetting of the input sequence. |
|
498 // We should be prepared for that and make sure that the internal |
|
499 // state of the PtiEngine is consistent with the one in the core. |
|
500 |
|
501 /* Code which was replaced: |
|
502 iTextBuffer.Copy(aWord); |
|
503 ConvertToKeySequence(aWord, iInputSequence); |
|
504 MakeCaseSequence(aWord); |
|
505 return Core()->SetCurrentInputSequence(iInputSequence); |
|
506 */ |
|
507 TInt err = 0; |
|
508 |
|
509 TRAP_IGNORE( |
|
510 { |
|
511 HBufC16* oldTextBuf = iTextBuffer.AllocLC(); |
|
512 HBufC8* oldInputSeq = iInputSequence.AllocLC(); |
|
513 HBufC8* oldCaseBuf = iCaseBuffer.AllocLC(); |
|
514 |
|
515 iTextBuffer.Copy(aWord); |
|
516 ConvertToKeySequence(aWord, iInputSequence); |
|
517 MakeCaseSequence(aWord); |
|
518 |
|
519 err = Core()->SetCurrentInputSequence(iInputSequence); |
|
520 |
|
521 // InputSequence is not incorrect, as there is mismatch present when autocompletion part is displayed |
|
522 if(err == KErrLengthMismatch /*&& !iMaxEditorLengthCrossed*/) |
|
523 { |
|
524 TInt tailLength = 0; |
|
525 TInt err = Core()->HandleCommandL( EPtiCommandGetAutoCompletionTailLength, &tailLength ); |
|
526 if(tailLength > 0) |
|
527 { |
|
528 iInputSequence.SetLength(iTextBuffer.Length() - tailLength); |
|
529 iCaseBuffer.SetLength(iTextBuffer.Length() - tailLength); |
|
530 TInt err = Core()->SetCurrentInputSequence(iInputSequence); |
|
531 } |
|
532 } |
|
533 |
|
534 // if cursor crosses max editor length or iMaxEditorLengthCrossed is |
|
535 // True, sync the iTextBuffer with last word in editor |
|
536 if ( err == KErrAbort && !iMaxEditorLengthCrossed) |
|
537 { |
|
538 // the core has ingnored resetting the sequence |
|
539 iTextBuffer.Copy( oldTextBuf->Des() ); |
|
540 iInputSequence.Copy( oldInputSeq->Des() ); |
|
541 iCaseBuffer.Copy( oldCaseBuf->Des() ); |
|
542 } |
|
543 CleanupStack::PopAndDestroy(3); //oldTextBuf,oldInputSeq,oldCaseBuf |
|
544 |
|
545 }); |
|
546 return err; |
|
547 |
|
548 // Predictive QWERTY (XT9) changes <---- |
|
549 } |
|
550 |
|
551 return KErrNoSuitableCore; |
|
552 } |
|
553 |
|
554 |
|
555 // --------------------------------------------------------------------------- |
|
556 // CPtiEngineImpl::ActivateLanguageL |
|
557 // |
|
558 // --------------------------------------------------------------------------- |
|
559 // |
|
560 TInt CPtiEngineImpl::ActivateLanguageL(TInt aEpocLanguageID, TPtiEngineInputMode aMode) |
|
561 { |
|
562 CloseCurrentLanguageL(); |
|
563 |
|
564 CPtiCoreLanguage *lang = static_cast<CPtiCoreLanguage*>(GetLanguage( aEpocLanguageID )); |
|
565 if (!lang) |
|
566 { |
|
567 return KErrLanguageNotFound; |
|
568 } |
|
569 |
|
570 iCurrentLanguage = lang; |
|
571 |
|
572 TPtiEngineInputMode newMode = aMode; |
|
573 if (aMode == EPtiEngineInputModeNone) |
|
574 { |
|
575 // Find first available mode and set it. |
|
576 for (TInt i = 1; i < EPtiEngineMaxInputModes; i++) |
|
577 { |
|
578 if (lang->HasInputMode((TPtiEngineInputMode)i)) |
|
579 { |
|
580 newMode = (TPtiEngineInputMode)i; |
|
581 break; |
|
582 } |
|
583 } |
|
584 } |
|
585 |
|
586 iInputMode = newMode; |
|
587 |
|
588 TInt err; |
|
589 for (TInt i = 0; i < iCores->Count(); i++) |
|
590 { |
|
591 if (((*iCores)[i]) && (iCurrentLanguage->HasCore((*iCores)[i]))) |
|
592 { |
|
593 err = (*iCores)[i]->OpenLanguageL(lang); |
|
594 if (err != KErrNone) |
|
595 { |
|
596 return err; |
|
597 } |
|
598 } |
|
599 } |
|
600 |
|
601 return SetInputMode( newMode ); |
|
602 } |
|
603 |
|
604 |
|
605 // --------------------------------------------------------------------------- |
|
606 // CPtiEngineImpl::CloseCurrentLanguageL |
|
607 // |
|
608 // --------------------------------------------------------------------------- |
|
609 // |
|
610 void CPtiEngineImpl::CloseCurrentLanguageL() |
|
611 { |
|
612 if (iCurrentLanguage) |
|
613 { |
|
614 for (TInt i = 0; i < iCores->Count(); i++) |
|
615 { |
|
616 if (((*iCores)[i]) && (iCurrentLanguage->HasCore((*iCores)[i]))) |
|
617 { |
|
618 (*iCores)[i]->CloseLanguageL(); |
|
619 } |
|
620 } |
|
621 |
|
622 iCurrentLanguage = NULL; |
|
623 iInputMode = EPtiEngineInputModeNone; |
|
624 } |
|
625 } |
|
626 |
|
627 |
|
628 // --------------------------------------------------------------------------- |
|
629 // CPtiEngineImpl::SetInputMode |
|
630 // |
|
631 // --------------------------------------------------------------------------- |
|
632 // |
|
633 TInt CPtiEngineImpl::SetInputMode(TPtiEngineInputMode aMode) |
|
634 { |
|
635 if (!iCurrentLanguage) |
|
636 { |
|
637 if (aMode != EPtiEngineInputModeNone) |
|
638 { |
|
639 return KErrNoActiveLanguage; |
|
640 } |
|
641 return KErrNone; |
|
642 } |
|
643 |
|
644 if (aMode != EPtiEngineNumeric) // Numeric is always allowed. |
|
645 { |
|
646 const TBool chinese = IsChinese(); |
|
647 |
|
648 if (chinese && (aMode == EPtiEngineQwerty)) |
|
649 { |
|
650 // This combination is never allowed, because Chinese |
|
651 // hase separate mode definitions for qwerty. |
|
652 return KErrNoSuitableCore; |
|
653 } |
|
654 else if (IsModeChineseQwerty(aMode) && chinese) |
|
655 { |
|
656 if (!iCurrentLanguage->HasInputMode(EPtiEngineQwerty)) |
|
657 { |
|
658 return KErrNoSuitableCore; |
|
659 } |
|
660 } |
|
661 else if (!iCurrentLanguage->HasInputMode(aMode)) |
|
662 { |
|
663 return KErrNoSuitableCore; |
|
664 } |
|
665 } |
|
666 |
|
667 iInputMode = aMode; |
|
668 |
|
669 TFileName temp; |
|
670 temp.Copy(iTextBuffer); |
|
671 return SetCurrentWord( temp ); |
|
672 } |
|
673 |
|
674 |
|
675 // --------------------------------------------------------------------------- |
|
676 // CPtiEngineImpl::CountToneMarks |
|
677 // |
|
678 // --------------------------------------------------------------------------- |
|
679 // |
|
680 TInt CPtiEngineImpl::GetNextWordCandidateListL(CDesCArray& aList) |
|
681 { |
|
682 if (IsCore()) |
|
683 { |
|
684 return Core()->GetNextWordCandidateListL( aList ); |
|
685 } |
|
686 |
|
687 if (!iCurrentLanguage) |
|
688 { |
|
689 return KErrNoActiveLanguage; |
|
690 } |
|
691 |
|
692 return KErrNoSuitableCore; |
|
693 } |
|
694 |
|
695 |
|
696 // --------------------------------------------------------------------------- |
|
697 // CPtiEngineImpl::AppendKeyPress |
|
698 // |
|
699 // --------------------------------------------------------------------------- |
|
700 // |
|
701 TPtrC CPtiEngineImpl::AppendKeyPress(TPtiKey aKey) |
|
702 { |
|
703 if (IsValidKey(aKey) && IsCore()) |
|
704 { |
|
705 // If input mode is chinese qwerty, then some key presses are |
|
706 // redirected to default core. |
|
707 if (IsModeChineseQwerty(iInputMode)) |
|
708 { |
|
709 TBool redirected = EFalse; |
|
710 TPtrC ret = RedirectKeyForChineseQwerty(aKey, redirected); |
|
711 if (redirected) |
|
712 { |
|
713 return ret; |
|
714 } |
|
715 } |
|
716 if(KeyboardType() == EPtiKeyboardHalfQwerty && aKey == EStdKeyFullStop) |
|
717 { |
|
718 iPunctuationsEntered++; |
|
719 } |
|
720 else if( KeyboardType() == EPtiKeyboard12Key && aKey == EPtiKey1 && iPunctuationsEntered == 0 ) |
|
721 { |
|
722 // iPunctuationLocation marks the start of smileys in ITU-T |
|
723 // iPunctuationsEntered is used to track the presence |
|
724 iPunctuationsEntered = 1; |
|
725 iPunctuationLocation = iTextBuffer.Length(); |
|
726 } |
|
727 if (iInputSequence.Length() < KPtiMaxWordSize) |
|
728 { |
|
729 TInt original = iTextBuffer.Length(); |
|
730 TInt handleRet = 0; |
|
731 |
|
732 TBuf<KPtiMaxWordSize> prevWordBuf; |
|
733 // To set the current word - by removing the extra suggested portion |
|
734 if(iInputMode == EPtiEngineWordCompletion) |
|
735 { |
|
736 prevWordBuf.Copy(iTextBuffer); |
|
737 if(original > iInputSequence.Length()) |
|
738 { |
|
739 original = iInputSequence.Length(); |
|
740 iTextBuffer.SetLength(original); |
|
741 SetCurrentWord(iTextBuffer); |
|
742 } |
|
743 } |
|
744 |
|
745 TInt tailLength = 0; |
|
746 TInt err = KErrLengthMismatch; |
|
747 TRAP_IGNORE(err = Core()->HandleCommandL( EPtiCommandGetAutoCompletionTailLength, &tailLength )); |
|
748 if(tailLength > 0 && !err) |
|
749 { |
|
750 if ((iTextBuffer.Length() - tailLength) > 0) |
|
751 iInputSequence.SetLength(iTextBuffer.Length() - tailLength); |
|
752 original = iInputSequence.Length(); |
|
753 } |
|
754 TInt prevInputSeqLength =iInputSequence.Length(); |
|
755 iInputSequence.Append(aKey); |
|
756 |
|
757 // If greek language, and uppercase and lowercase both mapped character is |
|
758 // same, then set text case as lower case ELangGreek |
|
759 if( ( ELangGreek ==iCurrentLanguage->LanguageCode()) && (EPtiCaseUpper == Case())) |
|
760 { |
|
761 TBuf<KMaxName> lowerCaseCharacter; |
|
762 MappingDataForKey((TPtiKey)aKey, lowerCaseCharacter, EPtiCaseLower); |
|
763 TBuf<KMaxName> uppercaseCaseCharacter; |
|
764 MappingDataForKey((TPtiKey)aKey, uppercaseCaseCharacter, EPtiCaseUpper); |
|
765 |
|
766 if( lowerCaseCharacter.Compare(uppercaseCaseCharacter) ) |
|
767 { |
|
768 iCaseBuffer.Append((TInt8)Case()); |
|
769 } |
|
770 else |
|
771 { |
|
772 iCaseBuffer.Append((TInt8)EPtiCaseLower); |
|
773 } |
|
774 } |
|
775 else |
|
776 { |
|
777 iCaseBuffer.Append((TInt8)Case()); |
|
778 } |
|
779 |
|
780 // Forward to core object |
|
781 Core()->AppendKeyPress(aKey); |
|
782 |
|
783 if(KeyboardType() == EPtiKeyboardHalfQwerty && aKey == EStdKeyFullStop) |
|
784 { |
|
785 // check if the key press was valid and resulted in Candidates |
|
786 if( iTextBuffer.Length() < iPunctuationsEntered ) |
|
787 iPunctuationsEntered --; |
|
788 } |
|
789 |
|
790 TRAP_IGNORE((handleRet = Core()->HandleCommandL(EPtiCommandVowelSeqFlag, NULL))); |
|
791 if (handleRet <= 0) |
|
792 { |
|
793 Capitalize(iTextBuffer); |
|
794 } |
|
795 |
|
796 TBuf<KPtiMaxWordSize> secondaryCandidate; |
|
797 TRAP_IGNORE((Core()->HandleCommandL(EPtiCommandGetSecondaryCandidate, (TAny*)&secondaryCandidate))); |
|
798 |
|
799 TInt doubleWide = 0; |
|
800 TRAP_IGNORE((doubleWide = Core()->HandleCommandL(EPtiCommandDoubleWideEntry, NULL))); |
|
801 |
|
802 if(iInputMode == EPtiEngineWordCompletion) |
|
803 { |
|
804 TInt inputSeqLength = iInputSequence.Length(); |
|
805 if(!prevWordBuf.CompareF(iTextBuffer)) |
|
806 { |
|
807 if( iTextBuffer.Length() >= inputSeqLength ) |
|
808 { |
|
809 if(aKey != CharacterToKey( (TUint)iTextBuffer[inputSeqLength - 1])) |
|
810 { |
|
811 iInputSequence.SetLength(inputSeqLength - 1); |
|
812 iCaseBuffer.SetLength(iCaseBuffer.Length() - 1); |
|
813 iTextBuffer.SetLength(inputSeqLength - 1); |
|
814 } |
|
815 } |
|
816 else |
|
817 { |
|
818 iInputSequence.SetLength(inputSeqLength - 1); |
|
819 iCaseBuffer.SetLength(iCaseBuffer.Length() - 1); |
|
820 } |
|
821 } |
|
822 else |
|
823 { |
|
824 if(iTextBuffer.Length() == original) |
|
825 { |
|
826 iInputSequence.SetLength(inputSeqLength - 1); |
|
827 iCaseBuffer.SetLength(iCaseBuffer.Length() - 1); |
|
828 } |
|
829 } |
|
830 } |
|
831 else if ((iTextBuffer.Length() == original) && |
|
832 (iInputMode == EPtiEngineMultitapping || |
|
833 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
834 (iInputMode == EPtiEngineInputModeZhuyinMiniQwertyFind)|| |
|
835 #endif |
|
836 iInputMode == EPtiEnginePredictive || |
|
837 iInputMode == EPtiEngineQwerty || |
|
838 // make sure that the secondary candidate length has also not increased in case of qwerty |
|
839 (iInputMode == EPtiEngineQwertyPredictive && (secondaryCandidate.Length() == original) )|| |
|
840 iInputMode == EPtiEngineHalfQwerty || |
|
841 iInputMode == EPtiEngineHalfQwertyPredictive)) |
|
842 { |
|
843 // If key press didn't increase lenght of |
|
844 // input buffer, remove key and case items from list. |
|
845 iInputSequence.SetLength(prevInputSeqLength); |
|
846 iCaseBuffer.SetLength(prevInputSeqLength); |
|
847 } |
|
848 else if (doubleWide > 0) |
|
849 { |
|
850 // Some (arabic) charaters in keymap data are handled as a special case by core |
|
851 // and they actually produce two unicode characters. |
|
852 iInputSequence.Append(aKey); |
|
853 iCaseBuffer.Append((TInt8)Case()); |
|
854 } |
|
855 else if (iTextBuffer.Length() > original + 1 && iInputMode != EPtiEngineWordCompletion && |
|
856 iInputMode != EPtiEngineQwertyPredictive && iInputMode != EPtiEngineHalfQwertyPredictive) |
|
857 { |
|
858 handleRet = 0; |
|
859 TRAP_IGNORE((handleRet = Core()->HandleCommandL(EPtiCommandQueryAndClearGetAllFlag, NULL))); |
|
860 if (handleRet > 0) |
|
861 { |
|
862 // If several characters were added into buffer as result of |
|
863 // "get all"-control character, arabic special cases, etc., then make sure that |
|
864 // iInputSequence and iCaseBuffer stay in sync. |
|
865 const TInt count = iTextBuffer.Length() - (original + 1); |
|
866 for (TInt j = 0; j < count; j++) |
|
867 { |
|
868 iInputSequence.Append(aKey); |
|
869 iCaseBuffer.Append((TInt8)Case()); |
|
870 } |
|
871 } |
|
872 } |
|
873 |
|
874 if (iInputMode == EPtiEngineQwerty) |
|
875 { |
|
876 handleRet = 0; |
|
877 TRAP_IGNORE((handleRet = Core()->HandleCommandL(EPtiCommandPollQwertyDeadKeyRootFlag, NULL))); |
|
878 |
|
879 if (handleRet > 0) |
|
880 { |
|
881 // If there was qwerty dead key waiting, but it didn't produce any accented |
|
882 // character and dead key root char was added to buffer in addition to nornal |
|
883 // character, then sync input sequence and case buffers. |
|
884 TPtiKey ktmp = (TPtiKey)iInputSequence[iInputSequence.Length() - 1]; |
|
885 iInputSequence.Append(ktmp); |
|
886 iCaseBuffer.Append(iCaseBuffer[iCaseBuffer.Length() - 1]); |
|
887 } |
|
888 } |
|
889 } |
|
890 } |
|
891 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
892 if(iInputMode == EPtiEngineInputModeZhuyinMiniQwertyFind) |
|
893 { |
|
894 if (iZhuyinSymbols.Length()==0 ||iKeyMuliTap != aKey) |
|
895 { |
|
896 iKeyMuliTap = aKey; |
|
897 iIndex = 0; |
|
898 iZhuyinSymbols.Zero(); |
|
899 TInt8 spellcount = PhoneticSpellingCount(); |
|
900 for (TInt i=1; i<=spellcount; i++) |
|
901 { |
|
902 iZhuyinSymbols.Append(Core()->GetPhoneticSpelling(i)); |
|
903 } |
|
904 } |
|
905 else if(iZhuyinSymbols.Length()>0) |
|
906 { |
|
907 iIndex++; |
|
908 if (iIndex == iZhuyinSymbols.Length()) |
|
909 { |
|
910 iIndex=0; |
|
911 } |
|
912 } |
|
913 return (iZhuyinSymbols.Ptr()+ iIndex); |
|
914 } |
|
915 #endif |
|
916 return iTextBuffer; |
|
917 } |
|
918 |
|
919 |
|
920 // --------------------------------------------------------------------------- |
|
921 // CPtiEngineImpl::DeleteKeyPress |
|
922 // |
|
923 // --------------------------------------------------------------------------- |
|
924 // |
|
925 TPtrC CPtiEngineImpl::DeleteKeyPress() |
|
926 { |
|
927 if (IsCore() && (iInputSequence.Length() > 0)) |
|
928 { |
|
929 TInt numtones = 0; |
|
930 if ((iInputMode == EPtiEnginePinyinByPhrase) || |
|
931 (iInputMode == EPtiEngineZhuyinByPhrase)|| |
|
932 (iInputMode == EPtiEnginePinyinPhraseHalfQwerty)|| |
|
933 (iInputMode == EPtiEngineZhuyinPhraseHalfQwerty)) |
|
934 { |
|
935 numtones = CountToneMarks(Core()->GetPhoneticSpelling(1)); |
|
936 } |
|
937 if(iPunctuationsEntered) |
|
938 { |
|
939 iPunctuationsEntered--; |
|
940 } |
|
941 TText tone; |
|
942 Core()->ToneMark( tone ); |
|
943 TText newtone = tone; |
|
944 Core()->DeleteKeyPress(); |
|
945 if (IsChinese()) |
|
946 { |
|
947 if ((iInputMode == EPtiEnginePinyinByPhrase) || |
|
948 (iInputMode == EPtiEngineZhuyinByPhrase)|| |
|
949 (iInputMode == EPtiEnginePinyinPhraseHalfQwerty)|| |
|
950 (iInputMode == EPtiEngineZhuyinPhraseHalfQwerty)) |
|
951 { |
|
952 if (CountToneMarks(Core()->GetPhoneticSpelling(1)) != numtones) |
|
953 { |
|
954 newtone++; |
|
955 } |
|
956 } |
|
957 else |
|
958 { |
|
959 Core()->ToneMark( newtone ); |
|
960 } |
|
961 } |
|
962 if (tone == newtone) |
|
963 { |
|
964 iInputSequence.SetLength(iInputSequence.Length() - 1); |
|
965 iCaseBuffer.SetLength(iCaseBuffer.Length() - 1); |
|
966 } |
|
967 Capitalize(iTextBuffer); |
|
968 } |
|
969 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
970 if(iInputMode == EPtiEngineInputModeZhuyinMiniQwertyFind) |
|
971 { |
|
972 iIndex = 0; |
|
973 iZhuyinSymbols.Zero(); |
|
974 } |
|
975 #endif |
|
976 return iTextBuffer; |
|
977 } |
|
978 |
|
979 |
|
980 // --------------------------------------------------------------------------- |
|
981 // CPtiEngineImpl::RedirectKeyForChineseQwerty |
|
982 // |
|
983 // --------------------------------------------------------------------------- |
|
984 // |
|
985 TPtrC CPtiEngineImpl::RedirectKeyForChineseQwerty(TPtiKey aKey, TBool& aRedirected) |
|
986 { |
|
987 aRedirected = EFalse; |
|
988 TPtiKeyboardType kbdType = KeyboardType(); |
|
989 |
|
990 switch (iInputMode) |
|
991 { |
|
992 case EPtiEnginePinyinQwerty: |
|
993 if (iCase == EPtiCaseLower && aKey == EPtiKeyQwertyApostrophe) |
|
994 { |
|
995 break; |
|
996 } |
|
997 case EPtiEnginePinyinPhraseHalfQwerty: |
|
998 if(EPtiKeyboardHalfQwerty == kbdType) |
|
999 { |
|
1000 if ((iCase == EPtiCaseLower) && ( ( ((aKey >= EPtiKeyQwertyA) |
|
1001 && (aKey <= EPtiKeyQwertyZ))|| (aKey |
|
1002 == EPtiKeyQwertySpace) ) )) |
|
1003 { |
|
1004 return TPtrC(); |
|
1005 } |
|
1006 } |
|
1007 break; |
|
1008 case EPtiEnginePinyinPhraseQwerty: |
|
1009 if(EPtiKeyboardQwerty4x10 == kbdType || |
|
1010 EPtiKeyboardQwerty3x11 == kbdType || |
|
1011 EPtiKeyboardCustomQwerty == kbdType) |
|
1012 { |
|
1013 if ((iCase == EPtiCaseLower) && |
|
1014 ( |
|
1015 ( |
|
1016 ((aKey >= EPtiKeyQwertyA) && (aKey <= EPtiKeyQwertyZ))|| |
|
1017 (aKey == EPtiKeyQwertySpace) |
|
1018 ) |
|
1019 )) |
|
1020 { |
|
1021 return TPtrC(); |
|
1022 } |
|
1023 } |
|
1024 else |
|
1025 { |
|
1026 if ((iCase == EPtiCaseLower) && |
|
1027 (((aKey >= EPtiKeyQwertyA) && (aKey <= EPtiKeyQwertyZ)) || |
|
1028 (aKey == EPtiKeyQwertyApostrophe))) |
|
1029 { |
|
1030 return TPtrC(); |
|
1031 } |
|
1032 } |
|
1033 break; |
|
1034 |
|
1035 case EPtiEngineStrokeQwerty: |
|
1036 case EPtiEngineStrokePhraseHalfQwerty: |
|
1037 case EPtiEngineStrokePhraseQwerty: |
|
1038 { |
|
1039 TPtiKeyboardType keyboardType = EPtiKeyboardNone; |
|
1040 TBool IsStokeKey = EFalse; |
|
1041 TRAP_IGNORE(keyboardType = ActiveKeyboardTypeL()); |
|
1042 if(EPtiKeyboardQwerty4x10 == keyboardType || |
|
1043 EPtiKeyboardQwerty3x11 == keyboardType ) |
|
1044 { |
|
1045 TBuf<KMaxName> lowerdata; |
|
1046 TInt StrokeUnicodePosition =0; |
|
1047 MappingDataForKey((TPtiKey)aKey, lowerdata, EPtiCaseLower); |
|
1048 if(lowerdata.Length()>0) |
|
1049 { |
|
1050 for(TInt i=0;i<lowerdata.Length();i++) |
|
1051 { |
|
1052 if(lowerdata[i]==KStrokeUnicode) |
|
1053 { |
|
1054 StrokeUnicodePosition = i + 1; |
|
1055 break; |
|
1056 } |
|
1057 } |
|
1058 } |
|
1059 if (lowerdata.Length() > StrokeUnicodePosition && iCase |
|
1060 == EPtiCaseLower) |
|
1061 { |
|
1062 if (lowerdata[StrokeUnicodePosition] |
|
1063 == KStrokeHorizontalValue |
|
1064 || lowerdata[StrokeUnicodePosition] |
|
1065 == KStrokeVerticalValue |
|
1066 || lowerdata[StrokeUnicodePosition] |
|
1067 == KStrokeDownToLeftValue |
|
1068 || lowerdata[StrokeUnicodePosition] |
|
1069 == KStrokeDownToRightValue |
|
1070 || lowerdata[StrokeUnicodePosition] |
|
1071 == KStrokeBendingValue |
|
1072 || lowerdata[StrokeUnicodePosition] |
|
1073 == KStrokeQuestionValue) |
|
1074 |
|
1075 { |
|
1076 return TPtrC(); |
|
1077 } |
|
1078 } |
|
1079 if (iCase == EPtiCaseLower && (aKey == EPtiKeyQwertySpace |
|
1080 || aKey == EPtiKeyQwertyChr || aKey |
|
1081 == EPtiKeyQwertyApostrophe)) |
|
1082 { |
|
1083 return TPtrC(); |
|
1084 } |
|
1085 if(iCase == EPtiCaseLower && aKey == EPtiKeyQwertySpace) |
|
1086 { |
|
1087 return TPtrC(); |
|
1088 } |
|
1089 } |
|
1090 else if (EPtiKeyboardHalfQwerty == keyboardType || |
|
1091 EPtiKeyboardCustomQwerty == keyboardType) |
|
1092 { |
|
1093 MPtiLanguage *lang = CurrentLanguage(); |
|
1094 RArray < TPtiNumericKeyBinding > keybinding; |
|
1095 if(lang) |
|
1096 { |
|
1097 TRAP_IGNORE(GetNumericModeKeysForQwertyL(lang->LanguageCode(), keybinding, keyboardType)); |
|
1098 TInt numericKeysCount = keybinding.Count(); |
|
1099 while ( numericKeysCount-- ) |
|
1100 { |
|
1101 TPtiNumericKeyBinding numKeyBind = keybinding[numericKeysCount]; |
|
1102 if ( (numKeyBind.iChar >= 0x31 && numKeyBind.iChar <= 0x36)&&(aKey == numKeyBind.iKey)) |
|
1103 { |
|
1104 IsStokeKey = ETrue; |
|
1105 break; |
|
1106 } |
|
1107 } |
|
1108 } |
|
1109 keybinding.Reset(); |
|
1110 if ( ( IsStokeKey || aKey == EPtiKeyQwertySpace || aKey == EPtiKeyQwertyChr || aKey == EStdKeyLeftFunc || aKey == EStdKeyFullStop ) |
|
1111 && (iCase == EPtiCaseLower)) |
|
1112 { |
|
1113 if((aKey >= EPtiKeyQwertyA && aKey <= EPtiKeyQwertyZ) || |
|
1114 (aKey >= EPtiKeyQwerty0 && aKey <= EPtiKeyQwerty9) || |
|
1115 (aKey == EPtiKeyQwertySpace) || |
|
1116 aKey == EPtiKeyQwertyChr || |
|
1117 aKey == EStdKeyLeftFunc || |
|
1118 aKey == EStdKeyFullStop ) |
|
1119 { |
|
1120 return TPtrC(); |
|
1121 } |
|
1122 } |
|
1123 } |
|
1124 else |
|
1125 { |
|
1126 if ((iCase == EPtiCaseLower) && |
|
1127 ((aKey == EPtiKeyQwertyQ) || |
|
1128 (aKey == EPtiKeyQwertyW) || |
|
1129 (aKey == EPtiKeyQwertyE) || |
|
1130 (aKey == EPtiKeyQwertyA) || |
|
1131 (aKey == EPtiKeyQwertyS) || |
|
1132 (aKey == EPtiKeyQwertyD) || |
|
1133 (aKey == EPtiKeyQwertyJ) || |
|
1134 |
|
1135 (aKey == EPtiKeyQwertyI) || |
|
1136 (aKey == EPtiKeyQwertyO) || |
|
1137 (aKey == EPtiKeyQwertyP) || |
|
1138 |
|
1139 (aKey == EPtiKeyQwertyK) || |
|
1140 (aKey == EPtiKeyQwertyL) || |
|
1141 (aKey == EPtiKeyQwertySpace) |
|
1142 )) |
|
1143 { |
|
1144 return TPtrC(); |
|
1145 } |
|
1146 } |
|
1147 } |
|
1148 break; |
|
1149 case EPtiEngineNormalCangjieQwerty: |
|
1150 case EPtiEngineEasyCangjieQwerty: |
|
1151 case EPtiEngineAdvCangjieQwerty: |
|
1152 if ((iCase == EPtiCaseLower) && |
|
1153 (aKey >= EPtiKeyQwertyA) && (aKey <= EPtiKeyQwertyY)) |
|
1154 { |
|
1155 return TPtrC(); |
|
1156 } |
|
1157 break; |
|
1158 case EPtiEngineZhuyinQwerty: |
|
1159 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
1160 case EPtiEngineInputModeZhuyinMiniQwertyFind: |
|
1161 #endif |
|
1162 case EPtiEngineZhuyinPhraseQwerty: |
|
1163 if( EPtiKeyboardHalfQwerty == kbdType || |
|
1164 EPtiKeyboardCustomQwerty == kbdType) |
|
1165 { |
|
1166 if ((iCase == EPtiCaseLower) && |
|
1167 ( |
|
1168 ( |
|
1169 ((aKey >= EPtiKeyQwertyA) && (aKey <= EPtiKeyQwertyZ))|| |
|
1170 (aKey == EPtiKeyQwertySpace) |
|
1171 ) |
|
1172 )) |
|
1173 { |
|
1174 return TPtrC(); |
|
1175 } |
|
1176 } |
|
1177 else if(EPtiKeyboardQwerty4x10 == kbdType || |
|
1178 EPtiKeyboardQwerty3x11 == kbdType ) |
|
1179 { |
|
1180 TBuf<KMaxName> lowerdata; |
|
1181 TInt i; |
|
1182 MappingDataForKey((TPtiKey) aKey, lowerdata, EPtiCaseLower); |
|
1183 if (lowerdata.Length() > 0) |
|
1184 { |
|
1185 for ( i = 0; i < lowerdata.Length(); i++) |
|
1186 { |
|
1187 if (lowerdata[i] == KZhuyinIndicator) |
|
1188 { |
|
1189 break; |
|
1190 } |
|
1191 } |
|
1192 if(i!=lowerdata.Length() && iCase == EPtiCaseLower ) |
|
1193 { |
|
1194 return TPtrC(); |
|
1195 } |
|
1196 } |
|
1197 } |
|
1198 else |
|
1199 { |
|
1200 if ((iCase == EPtiCaseLower) && |
|
1201 (aKey != EPtiKeyQwertyPlus) && |
|
1202 (aKey != EPtiKeyQwertyMinus) && |
|
1203 (aKey != EPtiKeyQwertyHash) ) |
|
1204 { |
|
1205 return TPtrC(); |
|
1206 } |
|
1207 } |
|
1208 break; |
|
1209 default: |
|
1210 return TPtrC(); |
|
1211 } |
|
1212 |
|
1213 CPtiCore* core = CoreForInputMode(EPtiEngineQwerty); |
|
1214 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
1215 //if language chinese comes here the keyboard type is halfqwerty. it means that half qwerty english input needed. |
|
1216 if(EPtiKeyboardHalfQwerty == kbdType) |
|
1217 { |
|
1218 core = CoreForInputMode(EPtiEngineHalfQwerty); |
|
1219 SetInputMode(EPtiEngineHalfQwerty); |
|
1220 } |
|
1221 //end for half qwerty |
|
1222 #endif |
|
1223 |
|
1224 if (core) |
|
1225 { |
|
1226 aRedirected = ETrue; |
|
1227 core->AppendKeyPress(aKey); |
|
1228 return iTextBuffer; |
|
1229 } |
|
1230 |
|
1231 return TPtrC(); |
|
1232 } |
|
1233 |
|
1234 |
|
1235 // --------------------------------------------------------------------------- |
|
1236 // CPtiEngineImpl::CountToneMarks |
|
1237 // |
|
1238 // --------------------------------------------------------------------------- |
|
1239 // |
|
1240 TInt CPtiEngineImpl::CountToneMarks(TPtrC aSpelling) const |
|
1241 { |
|
1242 TInt res = 0; |
|
1243 |
|
1244 for (TInt i = 0; i < aSpelling.Length(); i++) |
|
1245 { |
|
1246 if (IsToneMarkOrSeparator(aSpelling[i])) |
|
1247 { |
|
1248 res++; |
|
1249 } |
|
1250 } |
|
1251 |
|
1252 return res; |
|
1253 } |
|
1254 |
|
1255 |
|
1256 // --------------------------------------------------------------------------- |
|
1257 // CPtiEngineImpl::CreateLanguageNamesListLC |
|
1258 // |
|
1259 // --------------------------------------------------------------------------- |
|
1260 // |
|
1261 CArrayFixFlat<TPtiLangName>* CPtiEngineImpl::CreateLanguageNamesListLC() |
|
1262 { |
|
1263 CArrayFixFlat<TPtiLangName>* langNames = new( ELeave ) CArrayFixFlat<TPtiLangName>( KDefaultLangNamesGran ); |
|
1264 CleanupStack::PushL( langNames ); |
|
1265 |
|
1266 TResourceReader reader; |
|
1267 TFileName fileName; |
|
1268 |
|
1269 TParse* fp = new(ELeave) TParse(); |
|
1270 fp->Set(KCEResourceFile, &KDC_RESOURCE_FILES_DIR, NULL); |
|
1271 fileName.Copy(fp->FullName()); |
|
1272 delete fp; |
|
1273 |
|
1274 // Resource reading is done without coe or eikon env. |
|
1275 RFs fsSession; |
|
1276 User::LeaveIfError( fsSession.Connect() ); |
|
1277 CleanupClosePushL( fsSession ); |
|
1278 |
|
1279 RResourceFile rsFile; |
|
1280 rsFile.OpenL( fsSession, fileName ); |
|
1281 CleanupClosePushL( rsFile ); |
|
1282 |
|
1283 // Read language name table. |
|
1284 HBufC8* rBuffer = rsFile.AllocReadLC( R_PTI_LANGUAGE_TRANSLATIONS & KCCMask ); // Remove offset from id |
|
1285 reader.SetBuffer( rBuffer ); |
|
1286 |
|
1287 TPtiLangName name; |
|
1288 TInt count = reader.ReadInt16(); |
|
1289 |
|
1290 for (TInt i = 0; i < count; i++) |
|
1291 { |
|
1292 name.iName.Copy(reader.ReadTPtrC()); |
|
1293 name.iLanguageCode = reader.ReadInt16(); |
|
1294 langNames->AppendL(name); |
|
1295 } |
|
1296 |
|
1297 CleanupStack::PopAndDestroy(3); // rsFile, fsSession, rBuffer |
|
1298 return langNames; |
|
1299 } |
|
1300 |
|
1301 |
|
1302 // --------------------------------------------------------------------------- |
|
1303 // CPtiEngineImpl::FindLanguageName |
|
1304 // |
|
1305 // --------------------------------------------------------------------------- |
|
1306 // |
|
1307 void CPtiEngineImpl::FindLanguageName(CArrayFixFlat<TPtiLangName>*aList, TDes& aResult, TInt aLangCode) |
|
1308 { |
|
1309 for (TInt i = 0; i < aList->Count(); i++) |
|
1310 { |
|
1311 if (aList->At(i).iLanguageCode == aLangCode) |
|
1312 { |
|
1313 aResult.Copy(aList->At(i).iName); |
|
1314 return; |
|
1315 } |
|
1316 } |
|
1317 } |
|
1318 |
|
1319 |
|
1320 // --------------------------------------------------------------------------- |
|
1321 // CPtiEngineImpl::GetLocalizedLanguageName |
|
1322 // |
|
1323 // --------------------------------------------------------------------------- |
|
1324 // |
|
1325 void CPtiEngineImpl::GetLocalizedLanguageNameL(TInt aLangCode, TDes& aResult) |
|
1326 { |
|
1327 CArrayFixFlat<TPtiLangName>* nameList = CreateLanguageNamesListLC(); |
|
1328 FindLanguageName(nameList, aResult, aLangCode); |
|
1329 CleanupStack::PopAndDestroy(); // nameList |
|
1330 } |
|
1331 |
|
1332 |
|
1333 // --------------------------------------------------------------------------- |
|
1334 // CPtiEngineImpl::GetCandidateListL |
|
1335 // |
|
1336 // --------------------------------------------------------------------------- |
|
1337 // |
|
1338 TInt CPtiEngineImpl::GetCandidateListL(CDesCArray& aList) |
|
1339 { |
|
1340 if (IsCore()) |
|
1341 { |
|
1342 return Core()->GetCandidateListL( aList ); |
|
1343 } |
|
1344 |
|
1345 if (!iCurrentLanguage) |
|
1346 { |
|
1347 return KErrNoActiveLanguage; |
|
1348 } |
|
1349 |
|
1350 return KErrNoSuitableCore; |
|
1351 } |
|
1352 |
|
1353 |
|
1354 // --------------------------------------------------------------------------- |
|
1355 // CPtiEngineImpl::FirstCandidate |
|
1356 // |
|
1357 // --------------------------------------------------------------------------- |
|
1358 // |
|
1359 TPtrC CPtiEngineImpl::FirstCandidate() |
|
1360 { |
|
1361 iCandidateBuffer.Zero(); |
|
1362 if (IsCore()) |
|
1363 { |
|
1364 Core()->GetFirstCandidate(iCandidateBuffer); |
|
1365 Capitalize(iCandidateBuffer); |
|
1366 } |
|
1367 |
|
1368 iTextBuffer.Copy(iCandidateBuffer); |
|
1369 iTextBuffer.SetLength(iCandidateBuffer.Length()); |
|
1370 |
|
1371 return iCandidateBuffer; |
|
1372 } |
|
1373 |
|
1374 |
|
1375 // --------------------------------------------------------------------------- |
|
1376 // CPtiEngineImpl::NextCandidate |
|
1377 // |
|
1378 // --------------------------------------------------------------------------- |
|
1379 // |
|
1380 TPtrC CPtiEngineImpl::NextCandidate() |
|
1381 { |
|
1382 iCandidateBuffer.Zero(); |
|
1383 if (IsCore()) |
|
1384 { |
|
1385 Core()->GetNextCandidate(iCandidateBuffer); |
|
1386 Capitalize(iCandidateBuffer); |
|
1387 } |
|
1388 |
|
1389 iTextBuffer.Copy(iCandidateBuffer); |
|
1390 iTextBuffer.SetLength(iCandidateBuffer.Length()); |
|
1391 |
|
1392 return iCandidateBuffer; |
|
1393 } |
|
1394 |
|
1395 |
|
1396 // --------------------------------------------------------------------------- |
|
1397 // CPtiEngineImpl::PreviousCandidate |
|
1398 // |
|
1399 // --------------------------------------------------------------------------- |
|
1400 // |
|
1401 TPtrC CPtiEngineImpl::PreviousCandidate() |
|
1402 { |
|
1403 iCandidateBuffer.Zero(); |
|
1404 if (IsCore()) |
|
1405 { |
|
1406 Core()->GetPreviousCandidate(iCandidateBuffer); |
|
1407 Capitalize(iCandidateBuffer); |
|
1408 } |
|
1409 |
|
1410 // set to iTextBuffer |
|
1411 iTextBuffer.Copy(iCandidateBuffer); |
|
1412 iTextBuffer.SetLength(iCandidateBuffer.Length()); |
|
1413 |
|
1414 return iCandidateBuffer; |
|
1415 } |
|
1416 |
|
1417 |
|
1418 // --------------------------------------------------------------------------- |
|
1419 // CPtiEngineImpl::CoreInfo |
|
1420 // |
|
1421 // --------------------------------------------------------------------------- |
|
1422 // |
|
1423 MPtiCoreInfo* CPtiEngineImpl::CoreInfo(TPtiEngineInputMode aMode) const |
|
1424 { |
|
1425 if (IsCoreForInputMode(aMode)) |
|
1426 { |
|
1427 return iCurrentLanguage->GetCore(aMode)->GetCoreInfo(); |
|
1428 } |
|
1429 |
|
1430 return NULL; |
|
1431 } |
|
1432 |
|
1433 |
|
1434 // --------------------------------------------------------------------------- |
|
1435 // CPtiEngineImpl::NumberOfCandidates |
|
1436 // |
|
1437 // --------------------------------------------------------------------------- |
|
1438 // |
|
1439 TInt CPtiEngineImpl::NumberOfCandidates() |
|
1440 { |
|
1441 if (IsCore()) |
|
1442 { |
|
1443 TInt numberOfCandidates = Core()->NumberOfCandidates(); |
|
1444 if (iInputMode == EPtiEngineWordCompletion) |
|
1445 { |
|
1446 Capitalize(iTextBuffer); |
|
1447 } |
|
1448 |
|
1449 return numberOfCandidates ; |
|
1450 } |
|
1451 |
|
1452 return 0; |
|
1453 } |
|
1454 |
|
1455 |
|
1456 // --------------------------------------------------------------------------- |
|
1457 // CPtiEngineImpl::SetReordering |
|
1458 // |
|
1459 // --------------------------------------------------------------------------- |
|
1460 // |
|
1461 TInt CPtiEngineImpl::SetReordering(TBool aStatus) |
|
1462 { |
|
1463 if (IsCore()) |
|
1464 { |
|
1465 return Core()->SetReordering( aStatus ); |
|
1466 } |
|
1467 |
|
1468 if (!iCurrentLanguage) |
|
1469 { |
|
1470 return KErrNoActiveLanguage; |
|
1471 } |
|
1472 |
|
1473 return KErrNoSuitableCore; |
|
1474 } |
|
1475 |
|
1476 |
|
1477 // --------------------------------------------------------------------------- |
|
1478 // CPtiEngineImpl::ClearCurrentWord |
|
1479 // |
|
1480 // --------------------------------------------------------------------------- |
|
1481 // |
|
1482 void CPtiEngineImpl::ClearCurrentWord() |
|
1483 { |
|
1484 ClearBuffers(); |
|
1485 if (IsCore()) |
|
1486 { |
|
1487 Core()->ClearBuffer(); |
|
1488 } |
|
1489 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
1490 if(iInputMode == EPtiEngineInputModeZhuyinMiniQwertyFind) |
|
1491 { |
|
1492 iIndex = 0; |
|
1493 iZhuyinSymbols.Zero(); |
|
1494 } |
|
1495 #endif |
|
1496 } |
|
1497 |
|
1498 // --------------------------------------------------------------------------- |
|
1499 // CPtiEngineImpl::RemoveTrailingPunctuations |
|
1500 // |
|
1501 // --------------------------------------------------------------------------- |
|
1502 // |
|
1503 void CPtiEngineImpl::RemoveTrailingPunctuations() |
|
1504 { |
|
1505 // iTextBuffer contains the entire string |
|
1506 // iPunctuationsEntered contains the count of punct chars. |
|
1507 if(( iTextBuffer.Length()- iPunctuationsEntered ) >= 0 ) |
|
1508 { |
|
1509 // trim off the punctuation characters |
|
1510 iTextBuffer = iTextBuffer.LeftTPtr(iTextBuffer.Length()- iPunctuationsEntered); |
|
1511 } |
|
1512 iPunctuationsEntered = 0; |
|
1513 } |
|
1514 |
|
1515 // --------------------------------------------------------------------------- |
|
1516 // CPtiEngineImpl::RemoveTrailingPunctuations12Key |
|
1517 // |
|
1518 // --------------------------------------------------------------------------- |
|
1519 // |
|
1520 void CPtiEngineImpl::RemoveTrailingPunctuations12Key() |
|
1521 { |
|
1522 if(iTextBuffer.Length()>1) |
|
1523 { |
|
1524 // Trim off all punctuations starting at iPunctuationLocation |
|
1525 iTextBuffer = iTextBuffer.LeftTPtr( iPunctuationLocation ); |
|
1526 } |
|
1527 iPunctuationLocation = 0; |
|
1528 iPunctuationsEntered = 0; |
|
1529 } |
|
1530 |
|
1531 // --------------------------------------------------------------------------- |
|
1532 // CPtiEngineImpl::CommitCurrentWord |
|
1533 // |
|
1534 // --------------------------------------------------------------------------- |
|
1535 // |
|
1536 TInt CPtiEngineImpl::CommitCurrentWord() |
|
1537 { |
|
1538 if (IsCore()) |
|
1539 { |
|
1540 TInt error = KErrNone; |
|
1541 if(iPunctuationsEntered) |
|
1542 { |
|
1543 if( iInputMode == EPtiEngineHalfQwertyPredictive ) |
|
1544 { |
|
1545 // Do not commit the trailing punctuations to Dictionary. |
|
1546 RemoveTrailingPunctuations(); |
|
1547 } |
|
1548 else if( iInputMode == EPtiEnginePredictive) |
|
1549 { |
|
1550 // Do not commit smileys to Dictionary |
|
1551 RemoveTrailingPunctuations12Key(); |
|
1552 } |
|
1553 } |
|
1554 // core should take care that single char does not get added to UDB/UWD |
|
1555 error = Core()->CommitCurrentWord(); |
|
1556 |
|
1557 ClearBuffers(); |
|
1558 return error; |
|
1559 } |
|
1560 |
|
1561 if (!iCurrentLanguage) |
|
1562 { |
|
1563 return KErrNoActiveLanguage; |
|
1564 } |
|
1565 |
|
1566 return KErrNoSuitableCore; |
|
1567 } |
|
1568 |
|
1569 |
|
1570 // --------------------------------------------------------------------------- |
|
1571 // CPtiEngineImpl::AddCoreL |
|
1572 // |
|
1573 // --------------------------------------------------------------------------- |
|
1574 // |
|
1575 TInt CPtiEngineImpl::AddCoreL(const TUid aCoreUid, TBool aUseDefaultUserDictionary) |
|
1576 { |
|
1577 CPtiCore* core = CPtiCore::CreateCoreL(aCoreUid); |
|
1578 if (!core) |
|
1579 { |
|
1580 return KErrNotFound; |
|
1581 } |
|
1582 |
|
1583 CleanupStack::PushL( core ); |
|
1584 iCores->AppendL( core ); |
|
1585 CleanupStack::Pop(); // core |
|
1586 core->InitializeL(iFrontEnd, &iTextBuffer, iLanguages, aUseDefaultUserDictionary); |
|
1587 |
|
1588 return KErrNone; |
|
1589 } |
|
1590 |
|
1591 |
|
1592 // --------------------------------------------------------------------------- |
|
1593 // CPtiEngineImpl::RefreshLanguageNamesL |
|
1594 // |
|
1595 // --------------------------------------------------------------------------- |
|
1596 // |
|
1597 void CPtiEngineImpl::RefreshLanguageNamesL() |
|
1598 { |
|
1599 if (!iLanguages) |
|
1600 { |
|
1601 return; |
|
1602 } |
|
1603 |
|
1604 CArrayFixFlat<TPtiLangName>* langNames = CreateLanguageNamesListLC(); |
|
1605 |
|
1606 CPtiCoreLanguage* lang; |
|
1607 for (TInt i = 0; i < iLanguages->Count(); i++) |
|
1608 { |
|
1609 lang = iLanguages->At(i); |
|
1610 if ((!lang->LocalizedName().Length()) && (lang->LanguageCode() != ELangNumeric)) |
|
1611 { |
|
1612 FindLanguageName(langNames, lang->LocalizedNameDes(), lang->LanguageCode()); |
|
1613 } |
|
1614 // Make sure that there is a core for numeric input mode. |
|
1615 if (!lang->GetCore(EPtiEngineNumeric)) |
|
1616 { |
|
1617 lang->SetCore(FindCoreByUid(KDefaultCoreUid), EPtiEngineNumeric); |
|
1618 } |
|
1619 } |
|
1620 |
|
1621 CleanupStack::PopAndDestroy(); // langNames |
|
1622 } |
|
1623 |
|
1624 |
|
1625 |
|
1626 // --------------------------------------------------------------------------- |
|
1627 // CPtiEngineImpl::CharConversion |
|
1628 // |
|
1629 // --------------------------------------------------------------------------- |
|
1630 // |
|
1631 TInt CPtiEngineImpl::CharConversion(TPtiCharConversion aType, |
|
1632 TAny* aInput, |
|
1633 TInt aInputLength, |
|
1634 TAny* aOutput) |
|
1635 { |
|
1636 MPtiCoreInfo* info; |
|
1637 for (TInt i = 0; i < iCores->Count(); i++) |
|
1638 { |
|
1639 info = iCores->At(i)->GetCoreInfo(); |
|
1640 if ((info) && (info->CharConversions() & aType)) |
|
1641 { |
|
1642 return iCores->At(i)->Convert(aType, aInput, aInputLength, aOutput); |
|
1643 } |
|
1644 } |
|
1645 |
|
1646 return KErrNotSupported; |
|
1647 } |
|
1648 |
|
1649 |
|
1650 // --------------------------------------------------------------------------- |
|
1651 // CPtiEngineImpl::AvailableCharConversions |
|
1652 // |
|
1653 // --------------------------------------------------------------------------- |
|
1654 // |
|
1655 TUint32 CPtiEngineImpl::AvailableCharConversions() const |
|
1656 { |
|
1657 TUint32 res = 0; |
|
1658 MPtiCoreInfo* info; |
|
1659 |
|
1660 for (TInt i = 0; i < iCores->Count(); i++) |
|
1661 { |
|
1662 info = iCores->At(i)->GetCoreInfo(); |
|
1663 if (info) |
|
1664 { |
|
1665 res |= info->CharConversions(); |
|
1666 } |
|
1667 } |
|
1668 |
|
1669 return res; |
|
1670 } |
|
1671 |
|
1672 |
|
1673 // --------------------------------------------------------------------------- |
|
1674 // CPtiEngineImpl::DetachUserDictionaries |
|
1675 // |
|
1676 // --------------------------------------------------------------------------- |
|
1677 // |
|
1678 void CPtiEngineImpl::DetachUserDictionaries() |
|
1679 { |
|
1680 MPtiCore* core; |
|
1681 |
|
1682 for (TInt i = 0; i < iUserDictionaries.Count(); i++) |
|
1683 { |
|
1684 core = FindCoreByUid(iUserDictionaries[i]->CoreUID()); |
|
1685 if (core) |
|
1686 { |
|
1687 core->DetachUserDictionary(iUserDictionaries[i]); |
|
1688 } |
|
1689 } |
|
1690 } |
|
1691 |
|
1692 |
|
1693 // --------------------------------------------------------------------------- |
|
1694 // CPtiEngineImpl::FindCoreByUid |
|
1695 // |
|
1696 // --------------------------------------------------------------------------- |
|
1697 // |
|
1698 CPtiCore* CPtiEngineImpl::FindCoreByUid(TInt32 aUid) |
|
1699 { |
|
1700 for (TInt i = 0; i < iCores->Count(); i++) |
|
1701 { |
|
1702 MPtiCoreInfo* info = iCores->At(i)->GetCoreInfo(); |
|
1703 if ((info) && (info->Uid() == aUid)) |
|
1704 { |
|
1705 return iCores->At(i); |
|
1706 } |
|
1707 } |
|
1708 |
|
1709 return NULL; |
|
1710 } |
|
1711 |
|
1712 |
|
1713 // --------------------------------------------------------------------------- |
|
1714 // CPtiEngineImpl::SetExternalKeyMapL |
|
1715 // |
|
1716 // --------------------------------------------------------------------------- |
|
1717 // |
|
1718 TInt CPtiEngineImpl::SetExternalKeyMapL(TPtiEngineInputMode aMode, |
|
1719 TPtiKey aKey, |
|
1720 TDesC& aKeyMap, |
|
1721 TPtiTextCase aCase) |
|
1722 { |
|
1723 if (iCurrentLanguage || iInputMode == EPtiEngineNumeric) |
|
1724 { |
|
1725 MPtiCore *core = CoreForInputMode( aMode ); |
|
1726 if (!core) |
|
1727 { |
|
1728 return KErrNoSuitableCore; |
|
1729 } |
|
1730 |
|
1731 return core->SetExternalKeyMapL(aMode, aKey, aKeyMap, aCase); |
|
1732 } |
|
1733 |
|
1734 return KErrNoActiveLanguage; |
|
1735 } |
|
1736 |
|
1737 |
|
1738 // --------------------------------------------------------------------------- |
|
1739 // CPtiEngineImpl::ConvertToKeySequence |
|
1740 // |
|
1741 // --------------------------------------------------------------------------- |
|
1742 // |
|
1743 void CPtiEngineImpl::ConvertToKeySequence(TPtrC aIn, TDes8& aOut) |
|
1744 { |
|
1745 aOut.Zero(); |
|
1746 |
|
1747 if (!iCurrentLanguage) |
|
1748 { |
|
1749 return; |
|
1750 } |
|
1751 |
|
1752 const TBool vietnamese = iCurrentLanguage->LanguageCode() == ELangVietnamese; |
|
1753 |
|
1754 MPtiKeyMappings* map; |
|
1755 if (iInputMode == EPtiEngineQwerty || iInputMode == EPtiEngineQwertyPredictive) |
|
1756 { |
|
1757 map = iCurrentLanguage->GetQwertyKeymappings(); |
|
1758 } |
|
1759 else if( iInputMode == EPtiEngineHalfQwerty || iInputMode == EPtiEngineHalfQwertyPredictive ) |
|
1760 { |
|
1761 map = iCurrentLanguage->GetHalfQwertyKeymappings(); |
|
1762 } |
|
1763 else |
|
1764 { |
|
1765 map = iCurrentLanguage->GetKeymappings(); |
|
1766 } |
|
1767 |
|
1768 if (!map) |
|
1769 { |
|
1770 return; |
|
1771 } |
|
1772 |
|
1773 |
|
1774 TUint16 ch; |
|
1775 for (TInt i = 0; i < aIn.Length(); i++) |
|
1776 { |
|
1777 ch = (TUint16)map->KeyForCharacter(aIn[i]); |
|
1778 if (!ch && vietnamese) |
|
1779 { |
|
1780 // This may be Vietnamese tone mark or an accented character which isn't listed |
|
1781 // in keymappings. |
|
1782 ch = RemapVietnameseAccentedCharacter(aIn[i]); |
|
1783 } |
|
1784 |
|
1785 if(ch) |
|
1786 aOut.Append( ch ); |
|
1787 } |
|
1788 |
|
1789 /* Search the KeySequence in Secondary Language as well if Dual Language |
|
1790 feature is enabled */ |
|
1791 #ifdef FF_DUAL_LANGUAGE_SUPPORT |
|
1792 if(aOut.Length() == 0 && iSecondaryLanguage) |
|
1793 { |
|
1794 SearchKeySequenceInSecLang(aIn, aOut); |
|
1795 } |
|
1796 #endif // FF_DUAL_LANGUAGE_SUPPORT |
|
1797 } |
|
1798 |
|
1799 #ifdef FF_DUAL_LANGUAGE_SUPPORT |
|
1800 void CPtiEngineImpl:: SearchKeySequenceInSecLang(TPtrC aIn, TDes8& aOut) |
|
1801 { |
|
1802 MPtiKeyMappings* secLangMap = NULL; |
|
1803 const TBool vietnamese = iSecondaryLanguage->LanguageCode() == ELangVietnamese; |
|
1804 |
|
1805 if (iInputMode == EPtiEngineQwerty || iInputMode == EPtiEngineQwertyPredictive) |
|
1806 { |
|
1807 secLangMap = iSecondaryLanguage->GetQwertyKeymappings(); |
|
1808 } |
|
1809 else if( iInputMode == EPtiEngineHalfQwerty || iInputMode == EPtiEngineHalfQwertyPredictive ) |
|
1810 { |
|
1811 secLangMap = iSecondaryLanguage->GetHalfQwertyKeymappings(); |
|
1812 } |
|
1813 else |
|
1814 { |
|
1815 secLangMap = iSecondaryLanguage->GetKeymappings(); |
|
1816 } |
|
1817 |
|
1818 TUint16 ch; |
|
1819 for (TInt i = 0; i < aIn.Length(); i++) |
|
1820 { |
|
1821 ch = (TUint16)secLangMap->KeyForCharacter(aIn[i]); |
|
1822 if (!ch && vietnamese) |
|
1823 { |
|
1824 // This may be Vietnamese tone mark or an accented character which isn't listed |
|
1825 // in keymappings. |
|
1826 ch = RemapVietnameseAccentedCharacter(aIn[i]); |
|
1827 } |
|
1828 aOut.Append( ch ); |
|
1829 } |
|
1830 |
|
1831 } |
|
1832 #endif // FF_DUAL_LANGUAGE_SUPPORT |
|
1833 |
|
1834 // --------------------------------------------------------------------------- |
|
1835 // CPtiEngineImpl::GetSpelling |
|
1836 // |
|
1837 // --------------------------------------------------------------------------- |
|
1838 // |
|
1839 TInt CPtiEngineImpl::GetSpelling(TUint16 aInput, TDes& aOutput, TPtiSpelling aType) |
|
1840 { |
|
1841 TInt ret = 0; |
|
1842 for (TInt i = 0; i < iCores->Count(); i++) |
|
1843 { |
|
1844 MPtiCoreInfo* info = iCores->At(i)->GetCoreInfo(); |
|
1845 if (info && (info->Spellings() & aType ) && (info->CapsBits() |
|
1846 & EPreferedSpelling )) |
|
1847 { |
|
1848 ret = iCores->At(i)->GetSpelling(aInput, aOutput, aType); |
|
1849 if (ret == KErrNone) |
|
1850 { |
|
1851 return KErrNone; |
|
1852 } |
|
1853 } |
|
1854 } |
|
1855 |
|
1856 return KErrNotSupported; |
|
1857 } |
|
1858 |
|
1859 |
|
1860 // --------------------------------------------------------------------------- |
|
1861 // CPtiEngineImpl::CancelTimerActivity |
|
1862 // |
|
1863 // --------------------------------------------------------------------------- |
|
1864 // |
|
1865 TInt CPtiEngineImpl::CancelTimerActivity() |
|
1866 { |
|
1867 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
1868 if(iInputMode == EPtiEngineInputModeZhuyinMiniQwertyFind) |
|
1869 { |
|
1870 iIndex =0; |
|
1871 iZhuyinSymbols.Zero(); |
|
1872 } |
|
1873 #endif //RD_INTELLIGENT_TEXT_INPUT |
|
1874 if (IsCore()) |
|
1875 { |
|
1876 TInt res = Core()->CancelTimerActivity(); |
|
1877 if (Observer()) |
|
1878 { |
|
1879 Observer()->KeyTimerExpired(); |
|
1880 } |
|
1881 return res; |
|
1882 } |
|
1883 |
|
1884 return KErrNotFound; |
|
1885 } |
|
1886 |
|
1887 |
|
1888 // --------------------------------------------------------------------------- |
|
1889 // CPtiEngineImpl::CharacterToKey |
|
1890 // |
|
1891 // --------------------------------------------------------------------------- |
|
1892 // |
|
1893 TPtiKey CPtiEngineImpl::CharacterToKey(TUint16 aChar) |
|
1894 { |
|
1895 MPtiKeyMappings* map; |
|
1896 if (iInputMode == EPtiEngineQwerty |
|
1897 || iInputMode == EPtiEngineQwertyPredictive ) // Predictive QWERTY (XT9) changes |
|
1898 { |
|
1899 map = iCurrentLanguage->GetQwertyKeymappings(); |
|
1900 } |
|
1901 else if (iInputMode == EPtiEngineHalfQwerty |
|
1902 || iInputMode == EPtiEngineHalfQwertyPredictive ) |
|
1903 { |
|
1904 map = iCurrentLanguage->GetHalfQwertyKeymappings(); |
|
1905 } |
|
1906 else |
|
1907 { |
|
1908 map = iCurrentLanguage->GetKeymappings(); |
|
1909 } |
|
1910 |
|
1911 if (!map) |
|
1912 { |
|
1913 return EPtiKeyNone; |
|
1914 } |
|
1915 |
|
1916 return map->KeyForCharacter(aChar); |
|
1917 } |
|
1918 |
|
1919 |
|
1920 // --------------------------------------------------------------------------- |
|
1921 // CPtiEngineImpl::AddUserDictionaryEntry |
|
1922 // |
|
1923 // --------------------------------------------------------------------------- |
|
1924 // |
|
1925 TInt CPtiEngineImpl::AddUserDictionaryEntry(MPtiUserDictionaryEntry& aEntry) |
|
1926 { |
|
1927 CPtiUserDictionary* dict = DefaultUserDictForCore(Core()); |
|
1928 |
|
1929 if (dict) |
|
1930 { |
|
1931 return Core()->AddUserDictionaryEntry(aEntry, dict); |
|
1932 } |
|
1933 |
|
1934 if (!iCurrentLanguage) |
|
1935 { |
|
1936 return KErrNoActiveLanguage; |
|
1937 } |
|
1938 |
|
1939 return KErrNotSupported; |
|
1940 } |
|
1941 |
|
1942 |
|
1943 // --------------------------------------------------------------------------- |
|
1944 // CPtiEngineImpl::AddUserDictionaryEntry |
|
1945 // |
|
1946 // --------------------------------------------------------------------------- |
|
1947 // |
|
1948 TInt CPtiEngineImpl::AddUserDictionaryEntry(MPtiUserDictionaryEntry& aEntry, TInt aId) |
|
1949 { |
|
1950 for (TInt i = 0; i < iUserDictionaries.Count(); i++) |
|
1951 { |
|
1952 if (iUserDictionaries[i]->Id() == aId) |
|
1953 { |
|
1954 MPtiCore* core = FindCoreByUid(iUserDictionaries[i]->CoreUID()); |
|
1955 if (!core) |
|
1956 { |
|
1957 return KErrCorrupt; |
|
1958 } |
|
1959 return core->AddUserDictionaryEntry(aEntry, iUserDictionaries[i]); |
|
1960 } |
|
1961 } |
|
1962 |
|
1963 return KErrNotSupported; |
|
1964 } |
|
1965 |
|
1966 |
|
1967 // --------------------------------------------------------------------------- |
|
1968 // CPtiEngineImpl::RemoveEntryFromUserDictionary |
|
1969 // |
|
1970 // --------------------------------------------------------------------------- |
|
1971 // |
|
1972 TInt CPtiEngineImpl::RemoveEntryFromUserDictionary(MPtiUserDictionaryEntry& aEntry) |
|
1973 { |
|
1974 CPtiUserDictionary* dict = DefaultUserDictForCore(Core()); |
|
1975 |
|
1976 if (dict) |
|
1977 { |
|
1978 return Core()->RemoveUserDictionaryEntry(aEntry, dict); |
|
1979 } |
|
1980 |
|
1981 if (!iCurrentLanguage) |
|
1982 { |
|
1983 return KErrNoActiveLanguage; |
|
1984 } |
|
1985 |
|
1986 return KErrNotSupported; |
|
1987 } |
|
1988 |
|
1989 |
|
1990 // --------------------------------------------------------------------------- |
|
1991 // CPtiEngineImpl::RemoveEntryFromUserDictionary |
|
1992 // |
|
1993 // --------------------------------------------------------------------------- |
|
1994 // |
|
1995 TInt CPtiEngineImpl::RemoveEntryFromUserDictionary(MPtiUserDictionaryEntry& aEntry, TInt aId) |
|
1996 { |
|
1997 for (TInt i = 0; i < iUserDictionaries.Count(); i++) |
|
1998 { |
|
1999 if (iUserDictionaries[i]->Id() == aId) |
|
2000 { |
|
2001 MPtiCore* core = FindCoreByUid(iUserDictionaries[i]->CoreUID()); |
|
2002 if (!core) |
|
2003 { |
|
2004 return KErrCorrupt; |
|
2005 } |
|
2006 return core->RemoveUserDictionaryEntry(aEntry, iUserDictionaries[i]); |
|
2007 } |
|
2008 } |
|
2009 |
|
2010 return KErrNotSupported; |
|
2011 } |
|
2012 |
|
2013 |
|
2014 // --------------------------------------------------------------------------- |
|
2015 // CPtiEngineImpl::NumberOfEntriesInUserDictionary |
|
2016 // |
|
2017 // --------------------------------------------------------------------------- |
|
2018 // |
|
2019 TInt CPtiEngineImpl::NumberOfEntriesInUserDictionary() |
|
2020 { |
|
2021 CPtiUserDictionary* dict = DefaultUserDictForCore(Core()); |
|
2022 |
|
2023 if (dict) |
|
2024 { |
|
2025 return Core()->NumberOfEntriesInUserDictionary(dict); |
|
2026 } |
|
2027 |
|
2028 if (!iCurrentLanguage) |
|
2029 { |
|
2030 return KErrNoActiveLanguage; |
|
2031 } |
|
2032 |
|
2033 return KErrNotSupported; |
|
2034 } |
|
2035 |
|
2036 |
|
2037 // --------------------------------------------------------------------------- |
|
2038 // CPtiEngineImpl::Capitalize |
|
2039 // |
|
2040 // --------------------------------------------------------------------------- |
|
2041 // |
|
2042 void CPtiEngineImpl::Capitalize(TDes& aTextBuffer) |
|
2043 { |
|
2044 __ASSERT_DEBUG(iCurrentLanguage, User::Panic(KPtiEngineImplPanic, KErrCorrupt)); |
|
2045 |
|
2046 // Predictive QWERTY (XT9) changes ----> |
|
2047 // PtiXt9Core handles the capitalization it self, and it should not be overriden |
|
2048 // byt the PtiEngine. |
|
2049 if ( iInputMode==EPtiEngineQwertyPredictive ) |
|
2050 { |
|
2051 return; |
|
2052 } |
|
2053 // Predictive QWERTY (XT9) changes <---- |
|
2054 |
|
2055 if (aTextBuffer.Length()) |
|
2056 { |
|
2057 TBuf<KPtiMaxWordSize> temp; |
|
2058 TBuf<1> one; |
|
2059 |
|
2060 temp.Copy(aTextBuffer); |
|
2061 aTextBuffer.Zero(); |
|
2062 for (TInt i = 0; i < temp.Length(); i++) |
|
2063 { |
|
2064 one.Copy(temp.Mid(i, 1)); |
|
2065 |
|
2066 if (AllowCapitalize(one[0])) |
|
2067 { |
|
2068 if (iCaseBuffer.Length() >= i + 1) |
|
2069 { |
|
2070 if ((iCaseBuffer[i] == EPtiCaseUpper) || (iCaseBuffer[i] == EPtiCaseChrUpper) |
|
2071 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
2072 || ( iCaseBuffer[i] == EPtiCaseFnUpper ) |
|
2073 #endif |
|
2074 ) |
|
2075 { |
|
2076 one.UpperCase(); |
|
2077 } |
|
2078 else |
|
2079 { |
|
2080 one.LowerCase(); |
|
2081 } |
|
2082 } |
|
2083 else |
|
2084 { |
|
2085 if ((Case() == EPtiCaseUpper) || (Case() == EPtiCaseChrUpper)) |
|
2086 { |
|
2087 one.UpperCase(); |
|
2088 } |
|
2089 else |
|
2090 { |
|
2091 one.LowerCase(); |
|
2092 } |
|
2093 } |
|
2094 } |
|
2095 |
|
2096 aTextBuffer.Append(one); |
|
2097 } |
|
2098 } |
|
2099 } |
|
2100 |
|
2101 |
|
2102 // --------------------------------------------------------------------------- |
|
2103 // CPtiEngineImpl::CaseForMappedCharacter |
|
2104 // |
|
2105 // --------------------------------------------------------------------------- |
|
2106 // |
|
2107 TPtiTextCase CPtiEngineImpl::CaseForMappedCharacter(TChar aCharacter) |
|
2108 { |
|
2109 const static int numberOfCases = 6; |
|
2110 TPtiTextCase casesTOCheckAgainst[numberOfCases]={EPtiCaseLower, EPtiCaseUpper, EPtiCaseChrLower, EPtiCaseChrUpper, EPtiCaseFnLower, EPtiCaseFnUpper}; |
|
2111 TPtiTextCase caseCalculated = EPtiCaseLower; |
|
2112 TBuf<KDefaulCoreMaximumWordLength> mappedCharacters; |
|
2113 TBool isMappingFound = EFalse; |
|
2114 TPtiKey key = CharacterToKey(aCharacter); |
|
2115 |
|
2116 //It loops through all the key mappings to find the character in the key mappings and |
|
2117 //if the character available in the key mapping, fetches the corresponding case. |
|
2118 for(int i=0;i<numberOfCases;i++) |
|
2119 { |
|
2120 MappingDataForKey(key,mappedCharacters,casesTOCheckAgainst[i]); |
|
2121 for(int j=0; j<mappedCharacters.Length();j++) |
|
2122 { |
|
2123 if(mappedCharacters[j] == aCharacter) |
|
2124 { |
|
2125 caseCalculated = casesTOCheckAgainst[i]; |
|
2126 isMappingFound = ETrue; |
|
2127 break; |
|
2128 } |
|
2129 } |
|
2130 if(isMappingFound) |
|
2131 { |
|
2132 break; |
|
2133 } |
|
2134 } |
|
2135 //Now if there is no key mapping found for the character, then use the default TChar |
|
2136 //APIs to find the case of the character. |
|
2137 if(!isMappingFound) |
|
2138 { |
|
2139 caseCalculated = aCharacter.IsUpper()?EPtiCaseUpper:EPtiCaseLower; |
|
2140 } |
|
2141 return caseCalculated; |
|
2142 } |
|
2143 // --------------------------------------------------------------------------- |
|
2144 // CPtiEngineImpl::MakeCaseSequence |
|
2145 // |
|
2146 // --------------------------------------------------------------------------- |
|
2147 // |
|
2148 void CPtiEngineImpl::MakeCaseSequence(TPtrC aWord) |
|
2149 { |
|
2150 iCaseBuffer.Zero(); |
|
2151 for (TInt i = 0; i < aWord.Length(); i++) |
|
2152 { |
|
2153 //Find the case for the character from the mapping |
|
2154 TPtiTextCase characterCase = CaseForMappedCharacter(aWord[i]); |
|
2155 iCaseBuffer.Append(characterCase); |
|
2156 } |
|
2157 } |
|
2158 |
|
2159 |
|
2160 // --------------------------------------------------------------------------- |
|
2161 // CPtiEngineImpl::HandleCommandL |
|
2162 // |
|
2163 // --------------------------------------------------------------------------- |
|
2164 // |
|
2165 TInt CPtiEngineImpl::HandleCommandL(TPtiEngineCommand aCommand, TAny* aParams) |
|
2166 { |
|
2167 switch(aCommand) |
|
2168 { |
|
2169 case EPtiCommandSetCursorCrossedMaxLength: |
|
2170 iMaxEditorLengthCrossed = ETrue; |
|
2171 break; |
|
2172 case EPtiCommandResetCursorCrossedMaxLength: |
|
2173 iMaxEditorLengthCrossed = EFalse; |
|
2174 break; |
|
2175 |
|
2176 default: |
|
2177 break; |
|
2178 } |
|
2179 |
|
2180 if (IsCore()) |
|
2181 { |
|
2182 return Core()->HandleCommandL(aCommand, aParams); |
|
2183 } |
|
2184 |
|
2185 if (!iCurrentLanguage) |
|
2186 { |
|
2187 return KErrNoActiveLanguage; |
|
2188 } |
|
2189 |
|
2190 return KErrNoSuitableCore; |
|
2191 } |
|
2192 |
|
2193 |
|
2194 // --------------------------------------------------------------------------- |
|
2195 // CPtiEngineImpl::CandidatePage |
|
2196 // |
|
2197 // --------------------------------------------------------------------------- |
|
2198 // |
|
2199 TPtrC CPtiEngineImpl::CandidatePage() |
|
2200 { |
|
2201 if (IsCore()) |
|
2202 { |
|
2203 return Core()->GetCandidatePage(); |
|
2204 } |
|
2205 |
|
2206 return TPtrC(KNullDesC); |
|
2207 } |
|
2208 |
|
2209 |
|
2210 // --------------------------------------------------------------------------- |
|
2211 // CPtiEngineImpl::NextCandidatePage |
|
2212 // |
|
2213 // --------------------------------------------------------------------------- |
|
2214 // |
|
2215 TBool CPtiEngineImpl::NextCandidatePage() |
|
2216 { |
|
2217 if (IsCore()) |
|
2218 { |
|
2219 return Core()->NextCandidatePage(); |
|
2220 } |
|
2221 |
|
2222 return EFalse; |
|
2223 } |
|
2224 |
|
2225 |
|
2226 // --------------------------------------------------------------------------- |
|
2227 // CPtiEngineImpl::PreviousCandidatePage |
|
2228 // |
|
2229 // --------------------------------------------------------------------------- |
|
2230 // |
|
2231 TBool CPtiEngineImpl::PreviousCandidatePage() |
|
2232 { |
|
2233 if (IsCore()) |
|
2234 { |
|
2235 return Core()->PreviousCandidatePage(); |
|
2236 } |
|
2237 |
|
2238 return EFalse; |
|
2239 } |
|
2240 |
|
2241 |
|
2242 // --------------------------------------------------------------------------- |
|
2243 // CPtiEngineImpl::MoreCandidatePages |
|
2244 // |
|
2245 // --------------------------------------------------------------------------- |
|
2246 // |
|
2247 TBool CPtiEngineImpl::MoreCandidatePages() |
|
2248 { |
|
2249 if (IsCore()) |
|
2250 { |
|
2251 return Core()->MoreCandidatePages(); |
|
2252 } |
|
2253 |
|
2254 return EFalse; |
|
2255 } |
|
2256 |
|
2257 |
|
2258 // --------------------------------------------------------------------------- |
|
2259 // CPtiEngineImpl::SetCandidatePageLength |
|
2260 // |
|
2261 // --------------------------------------------------------------------------- |
|
2262 // |
|
2263 void CPtiEngineImpl::SetCandidatePageLength(TInt aLength) |
|
2264 { |
|
2265 if (IsCore()) |
|
2266 { |
|
2267 Core()->SetCandidatePageLength(aLength); |
|
2268 } |
|
2269 } |
|
2270 |
|
2271 |
|
2272 // --------------------------------------------------------------------------- |
|
2273 // CPtiEngineImpl::LoadCoresInDefaultDirL |
|
2274 // |
|
2275 // --------------------------------------------------------------------------- |
|
2276 // |
|
2277 void CPtiEngineImpl::LoadCoresInDefaultDirL(TBool aUseDefaultUserDictionary) |
|
2278 { |
|
2279 TInt i; |
|
2280 CArrayFix<TInt>* array = CPtiCore::ListCoresLC(); |
|
2281 User::LeaveIfNull(array); |
|
2282 for (i = 0; i < array->Count(); i++) |
|
2283 { |
|
2284 AddCoreL(TUid::Uid(array->At(i)), aUseDefaultUserDictionary); |
|
2285 } |
|
2286 |
|
2287 CleanupStack::PopAndDestroy(); // array |
|
2288 } |
|
2289 |
|
2290 |
|
2291 |
|
2292 // --------------------------------------------------------------------------- |
|
2293 // CPtiEngineImpl::CompositionData |
|
2294 // |
|
2295 // --------------------------------------------------------------------------- |
|
2296 // |
|
2297 MPtiEngineCompositionDataInterface* CPtiEngineImpl::CompositionData() |
|
2298 { |
|
2299 if (IsCore()) |
|
2300 { |
|
2301 return Core()->CompositionData(); |
|
2302 } |
|
2303 |
|
2304 return NULL; |
|
2305 } |
|
2306 |
|
2307 |
|
2308 // --------------------------------------------------------------------------- |
|
2309 // CPtiEngineImpl::DefaultUserDictionary |
|
2310 // |
|
2311 // --------------------------------------------------------------------------- |
|
2312 // |
|
2313 MPtiUserDictionary* CPtiEngineImpl::DefaultUserDictionary(TPtiEngineInputMode aMode) |
|
2314 { |
|
2315 return DefaultUserDictForCore(CoreForInputMode( aMode )); |
|
2316 } |
|
2317 |
|
2318 |
|
2319 // --------------------------------------------------------------------------- |
|
2320 // CPtiEngineImpl::GetUserDictionaryEntry |
|
2321 // |
|
2322 // --------------------------------------------------------------------------- |
|
2323 // |
|
2324 TInt CPtiEngineImpl::GetUserDictionaryEntry(TInt aIndex, MPtiUserDictionaryEntry& aResult) |
|
2325 { |
|
2326 CPtiUserDictionary* dict = DefaultUserDictForCore(Core()); |
|
2327 |
|
2328 if (dict) |
|
2329 { |
|
2330 return Core()->GetUserDictionaryEntry(aIndex, aResult, dict); |
|
2331 } |
|
2332 |
|
2333 if (!iCurrentLanguage) |
|
2334 { |
|
2335 return KErrNoActiveLanguage; |
|
2336 } |
|
2337 |
|
2338 return KErrNotSupported; |
|
2339 } |
|
2340 |
|
2341 |
|
2342 // --------------------------------------------------------------------------- |
|
2343 // CPtiEngineImpl::DefaultUserDictForCore |
|
2344 // |
|
2345 // --------------------------------------------------------------------------- |
|
2346 // |
|
2347 CPtiUserDictionary* CPtiEngineImpl::DefaultUserDictForCore(CPtiCore* aCore) |
|
2348 { |
|
2349 if (!SupportsUserDictionaries(aCore)) |
|
2350 { |
|
2351 return NULL; |
|
2352 } |
|
2353 |
|
2354 MPtiCoreInfo* info = aCore->GetCoreInfo(); |
|
2355 if (info) |
|
2356 { |
|
2357 for (TInt i = 0; i < iUserDictionaries.Count(); i++) |
|
2358 { |
|
2359 if ((iUserDictionaries[i]->CoreUID() == info->Uid()) && |
|
2360 (iUserDictionaries[i]->IsDefault())) |
|
2361 { |
|
2362 return iUserDictionaries[i]; |
|
2363 } |
|
2364 } |
|
2365 } |
|
2366 |
|
2367 return NULL; |
|
2368 } |
|
2369 |
|
2370 |
|
2371 // --------------------------------------------------------------------------- |
|
2372 // CPtiEngineImpl::ReadUidFromUserDictionaryFileL |
|
2373 // |
|
2374 // --------------------------------------------------------------------------- |
|
2375 // |
|
2376 TInt CPtiEngineImpl::ReadUidFromUserDictionaryFileL(const TDesC& aFileName) |
|
2377 { |
|
2378 TInt res = 0; |
|
2379 |
|
2380 RFs fsSession; |
|
2381 User::LeaveIfError( fsSession.Connect() ); |
|
2382 CleanupClosePushL( fsSession ); |
|
2383 |
|
2384 RFile file; |
|
2385 User::LeaveIfError(file.Open(fsSession, aFileName, EFileRead)); |
|
2386 CleanupClosePushL(file); |
|
2387 |
|
2388 TInt32 uidtmp[1]; |
|
2389 TPtr8 uidP((TUint8*)uidtmp, sizeof(TInt32)); |
|
2390 uidP.Set((TUint8*)uidtmp, sizeof(TInt32), sizeof(TInt32)); |
|
2391 User::LeaveIfError(file.Read(uidP, sizeof(res))); |
|
2392 res = uidtmp[0]; |
|
2393 |
|
2394 CleanupStack::PopAndDestroy(2); // fsSession, file |
|
2395 |
|
2396 return res; |
|
2397 } |
|
2398 |
|
2399 |
|
2400 // --------------------------------------------------------------------------- |
|
2401 // CPtiEngineImpl::GetPhoneticSpelling |
|
2402 // |
|
2403 // --------------------------------------------------------------------------- |
|
2404 // |
|
2405 TPtrC CPtiEngineImpl::GetPhoneticSpelling(TInt aIndex) const |
|
2406 { |
|
2407 if (IsCore()) |
|
2408 { |
|
2409 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
2410 if(iInputMode == EPtiEngineInputModeZhuyinMiniQwertyFind) |
|
2411 { |
|
2412 if(iZhuyinSymbols.Length()>0) |
|
2413 { |
|
2414 return (iZhuyinSymbols.Ptr()+ iIndex); |
|
2415 } |
|
2416 } |
|
2417 #endif |
|
2418 return Core()->GetPhoneticSpelling(aIndex); |
|
2419 } |
|
2420 |
|
2421 return TPtrC(KNullDesC); |
|
2422 } |
|
2423 |
|
2424 |
|
2425 // --------------------------------------------------------------------------- |
|
2426 // CPtiEngineImpl::PhoneticSpellingCount |
|
2427 // |
|
2428 // --------------------------------------------------------------------------- |
|
2429 // |
|
2430 TInt CPtiEngineImpl::PhoneticSpellingCount() const |
|
2431 { |
|
2432 if (IsCore()) |
|
2433 { |
|
2434 return Core()->PhoneticSpellingCount(); |
|
2435 } |
|
2436 |
|
2437 return 0; |
|
2438 } |
|
2439 |
|
2440 |
|
2441 // --------------------------------------------------------------------------- |
|
2442 // CPtiEngineImpl::SelectPhoneticSpelling |
|
2443 // |
|
2444 // --------------------------------------------------------------------------- |
|
2445 // |
|
2446 TBool CPtiEngineImpl::SelectPhoneticSpelling(TInt aIndex) |
|
2447 { |
|
2448 if (IsCore()) |
|
2449 { |
|
2450 return Core()->SelectPhoneticSpelling(aIndex); |
|
2451 } |
|
2452 |
|
2453 return EFalse; |
|
2454 } |
|
2455 |
|
2456 |
|
2457 // --------------------------------------------------------------------------- |
|
2458 // CPtiEngineImpl::SelectedPhoneticSpelling |
|
2459 // |
|
2460 // --------------------------------------------------------------------------- |
|
2461 // |
|
2462 TInt CPtiEngineImpl::SelectedPhoneticSpelling() const |
|
2463 { |
|
2464 if (IsCore()) |
|
2465 { |
|
2466 return Core()->SelectedPhoneticSpelling(); |
|
2467 } |
|
2468 |
|
2469 return -1; |
|
2470 } |
|
2471 |
|
2472 |
|
2473 // --------------------------------------------------------------------------- |
|
2474 // CPtiEngineImpl::ReadingTextL |
|
2475 // |
|
2476 // --------------------------------------------------------------------------- |
|
2477 // |
|
2478 TPtrC CPtiEngineImpl::ReadingTextL() |
|
2479 { |
|
2480 CPtiCoreLanguage* lang = NULL; |
|
2481 for (TInt i = 0; i < iLanguages->Count(); i++) |
|
2482 { |
|
2483 if (iLanguages->At(i)->LanguageCode() == ELangJapanese) |
|
2484 { |
|
2485 lang = iLanguages->At(i); |
|
2486 break; |
|
2487 } |
|
2488 } |
|
2489 |
|
2490 if (lang) |
|
2491 { |
|
2492 MPtiCore* core = lang->GetCore(EPtiEngineHiraganaKanji); |
|
2493 if (core) |
|
2494 { |
|
2495 return core->ReadingTextL(); |
|
2496 } |
|
2497 } |
|
2498 else |
|
2499 { |
|
2500 if (IsCore()) |
|
2501 { |
|
2502 return Core()->ReadingTextL(); |
|
2503 } |
|
2504 } |
|
2505 |
|
2506 return TPtrC(KNullDesC); |
|
2507 } |
|
2508 |
|
2509 |
|
2510 // --------------------------------------------------------------------------- |
|
2511 // CPtiEngineImpl::EnableToneMarks |
|
2512 // |
|
2513 // --------------------------------------------------------------------------- |
|
2514 // |
|
2515 void CPtiEngineImpl::EnableToneMarks(TBool aValue) |
|
2516 { |
|
2517 TInt ignore = 0; |
|
2518 if (IsCore()) |
|
2519 { |
|
2520 if (aValue) |
|
2521 { |
|
2522 TRAP(ignore, Core()->HandleCommandL(EPtiCommandEnableToneMarks, NULL)); |
|
2523 } |
|
2524 else |
|
2525 { |
|
2526 TRAP(ignore, Core()->HandleCommandL(EPtiCommandDisableToneMarks, NULL)); |
|
2527 } |
|
2528 } |
|
2529 } |
|
2530 |
|
2531 |
|
2532 // --------------------------------------------------------------------------- |
|
2533 // CPtiEngineImpl::ResetToneMark |
|
2534 // |
|
2535 // --------------------------------------------------------------------------- |
|
2536 // |
|
2537 void CPtiEngineImpl::ResetToneMark() |
|
2538 { |
|
2539 TInt ignore = 0; |
|
2540 if (IsCore()) |
|
2541 { |
|
2542 TRAP(ignore, Core()->HandleCommandL(EPtiCommandResetToneMark, NULL)); |
|
2543 } |
|
2544 } |
|
2545 |
|
2546 |
|
2547 // --------------------------------------------------------------------------- |
|
2548 // CPtiEngineImpl::ToneMark |
|
2549 // |
|
2550 // --------------------------------------------------------------------------- |
|
2551 // |
|
2552 TBool CPtiEngineImpl::ToneMark(TText& aToneMark) const |
|
2553 { |
|
2554 if (IsCore()) |
|
2555 { |
|
2556 return Core()->ToneMark(aToneMark); |
|
2557 } |
|
2558 |
|
2559 return EFalse; |
|
2560 } |
|
2561 |
|
2562 |
|
2563 // --------------------------------------------------------------------------- |
|
2564 // CPtiEngineImpl::IsToneMarkValidForSpelling |
|
2565 // |
|
2566 // --------------------------------------------------------------------------- |
|
2567 // |
|
2568 TBool CPtiEngineImpl::IsToneMarkValidForSpelling() const |
|
2569 { |
|
2570 if (IsCore()) |
|
2571 { |
|
2572 return Core()->IsToneMarkValidForSpelling(); |
|
2573 } |
|
2574 |
|
2575 return EFalse; |
|
2576 } |
|
2577 |
|
2578 |
|
2579 // --------------------------------------------------------------------------- |
|
2580 // CPtiEngineImpl::IncrementToneMark |
|
2581 // |
|
2582 // --------------------------------------------------------------------------- |
|
2583 // |
|
2584 TBool CPtiEngineImpl::IncrementToneMark(TBool aOverrideInvalid) |
|
2585 { |
|
2586 TInt ret = 0; |
|
2587 TInt ignore = 0; |
|
2588 |
|
2589 if (IsCore()) |
|
2590 { |
|
2591 if (aOverrideInvalid) |
|
2592 { |
|
2593 TRAP(ignore, ret = Core()->HandleCommandL(EPtiCommandIncrementToneMarkOverrideInvalid, NULL)); |
|
2594 if (ret == KErrNone) |
|
2595 { |
|
2596 return ETrue; |
|
2597 } |
|
2598 } |
|
2599 else |
|
2600 { |
|
2601 TRAP(ignore, ret = Core()->HandleCommandL(EPtiCommandIncrementToneMark, NULL)); |
|
2602 if (ret == KErrNone) |
|
2603 { |
|
2604 return ETrue; |
|
2605 } |
|
2606 } |
|
2607 } |
|
2608 |
|
2609 return EFalse; |
|
2610 } |
|
2611 |
|
2612 |
|
2613 // --------------------------------------------------------------------------- |
|
2614 // CPtiEngineImpl::SetPredictiveChineseChar |
|
2615 // |
|
2616 // --------------------------------------------------------------------------- |
|
2617 // |
|
2618 TBool CPtiEngineImpl::SetPredictiveChineseChar(const TDesC& aChar) |
|
2619 { |
|
2620 if (IsCore()) |
|
2621 { |
|
2622 return Core()->SetPredictiveChineseChar(aChar); |
|
2623 } |
|
2624 |
|
2625 return EFalse; |
|
2626 } |
|
2627 |
|
2628 |
|
2629 // --------------------------------------------------------------------------- |
|
2630 // CPtiEngineImpl::CreateNumericLanguageL |
|
2631 // |
|
2632 // --------------------------------------------------------------------------- |
|
2633 // |
|
2634 CPtiCoreLanguage* CPtiEngineImpl::CreateNumericLanguageL(CPtiCore* aCore) |
|
2635 { |
|
2636 CPtiCoreLanguage* lang = CPtiCoreLanguage::NewL(); |
|
2637 |
|
2638 lang->SetLanguageCode(ELangNumeric); |
|
2639 lang->SetCore(aCore, EPtiEngineNumeric); |
|
2640 lang->SetLocalizedName(KNumericLangName); |
|
2641 |
|
2642 return lang; |
|
2643 } |
|
2644 |
|
2645 |
|
2646 // --------------------------------------------------------------------------- |
|
2647 // CPtiEngineImpl::GetModeNameIndexL |
|
2648 // |
|
2649 // --------------------------------------------------------------------------- |
|
2650 // |
|
2651 void CPtiEngineImpl::GetModeNameIndexL(TPtiChineseVariant aVariant, RArray<TInt>& aResult) |
|
2652 { |
|
2653 TResourceReader reader; |
|
2654 TFileName fileName; |
|
2655 |
|
2656 TParse* fp = new(ELeave) TParse(); |
|
2657 fp->Set(KCEResourceFile, &KDC_RESOURCE_FILES_DIR, NULL); |
|
2658 fileName.Copy(fp->FullName()); |
|
2659 delete fp; |
|
2660 |
|
2661 // Resource reading is done without coe or eikon env. |
|
2662 RFs fsSession; |
|
2663 User::LeaveIfError( fsSession.Connect() ); |
|
2664 CleanupClosePushL( fsSession ); |
|
2665 |
|
2666 RResourceFile rsFile; |
|
2667 rsFile.OpenL( fsSession, fileName ); |
|
2668 CleanupClosePushL( rsFile ); |
|
2669 |
|
2670 TInt resId; |
|
2671 |
|
2672 switch (aVariant) |
|
2673 { |
|
2674 case EPtiChineseVariantHk: |
|
2675 resId = R_PTI_TW_INDICES; |
|
2676 break; |
|
2677 case EPtiChineseVariantTw: |
|
2678 resId = R_PTI_HK_INDICES; |
|
2679 break; |
|
2680 default: |
|
2681 resId = R_PTI_PRC_INDICES; |
|
2682 break; |
|
2683 } |
|
2684 // Read mode name index table. |
|
2685 HBufC8* rBuffer = rsFile.AllocReadLC(resId & KCCMask); // Remove offset from id |
|
2686 reader.SetBuffer( rBuffer ); |
|
2687 |
|
2688 TInt value; |
|
2689 for (TInt i = 0; i < 6; i++) |
|
2690 { |
|
2691 value = reader.ReadInt16(); |
|
2692 if (value != -1) |
|
2693 { |
|
2694 User::LeaveIfError(aResult.Append(value)); |
|
2695 } |
|
2696 } |
|
2697 |
|
2698 CleanupStack::PopAndDestroy(3); // fsSession, rsFile, rBuffer |
|
2699 } |
|
2700 |
|
2701 |
|
2702 // --------------------------------------------------------------------------- |
|
2703 // CPtiEngineImpl::IsValidKey |
|
2704 // |
|
2705 // --------------------------------------------------------------------------- |
|
2706 // |
|
2707 TBool CPtiEngineImpl::IsValidKey(TPtiKey aKey) const |
|
2708 { |
|
2709 if (iFrontEnd->IsQwertyBasedMode(iInputMode) || |
|
2710 iInputMode == EPtiEngineHalfQwerty || |
|
2711 iInputMode == EPtiEngineHalfQwertyPredictive) |
|
2712 { |
|
2713 // Japanese Qwerty modes |
|
2714 if (iCurrentLanguage->LanguageCode() == ELangJapanese) |
|
2715 { |
|
2716 if (iInputMode == EPtiEngineHiraganaKanjiQwerty || |
|
2717 iInputMode == EPtiEngineHiraganaKanjiPredictiveQwerty || |
|
2718 iInputMode == EPtiEngineKatakanaQwerty || |
|
2719 iInputMode == EPtiEngineFullWidthKatakanaQwerty || |
|
2720 iInputMode == EPtiEngineFullWidthNumericQwerty || |
|
2721 iInputMode == EPtiEngineFullWidthAlphabetQwerty || |
|
2722 iInputMode == EPtiEngineHiraganaQwerty || |
|
2723 iInputMode == EPtiEngineQwerty) |
|
2724 { |
|
2725 if (aKey == EPtiKeyQwertySpace) |
|
2726 { |
|
2727 return ETrue; |
|
2728 } |
|
2729 } |
|
2730 } |
|
2731 |
|
2732 // Scan codes from this area are ok. |
|
2733 if (aKey >= KDirectlyAllowedScanCodesStart && aKey <= KDirectlyAllowedScanCodesEnd) |
|
2734 { |
|
2735 return ETrue; |
|
2736 } |
|
2737 |
|
2738 // Also allow these |
|
2739 if (aKey == EStdKeySquareBracketLeft || |
|
2740 aKey == EPtiKeyQwertyMinus || |
|
2741 aKey == EPtiKeyQwertyComma || |
|
2742 aKey == EPtiKeyQwertySemicolon || |
|
2743 aKey == EPtiKeyQwertyFullstop || |
|
2744 aKey == EPtiKeyQwertyHash || |
|
2745 aKey == EPtiKeyQwertySlash || |
|
2746 aKey == EPtiKeyQwertyApostrophe || |
|
2747 aKey == EPtiKeyQwertySpace || |
|
2748 aKey == EPtiKeyQwertyAtCharacter || |
|
2749 aKey == EPtiKeyQwertyLeftShift |
|
2750 // ----> Half Qwerty |
|
2751 || aKey == EPtiKeyQwertyChr |
|
2752 // Half Qwerty <---- |
|
2753 ) |
|
2754 { |
|
2755 return ETrue; |
|
2756 } |
|
2757 |
|
2758 } |
|
2759 else |
|
2760 { |
|
2761 if ((aKey >= EPtiKey0 && aKey <= EPtiKey9) || |
|
2762 (aKey == EPtiKeyStar) || (aKey == EPtiKeyHash)) |
|
2763 { |
|
2764 return ETrue; |
|
2765 } |
|
2766 } |
|
2767 |
|
2768 return EFalse; |
|
2769 } |
|
2770 |
|
2771 |
|
2772 // --------------------------------------------------------------------------- |
|
2773 // CPtiEngineImpl::GetPhoneticSpellingsL |
|
2774 // |
|
2775 // --------------------------------------------------------------------------- |
|
2776 // |
|
2777 TInt CPtiEngineImpl::GetPhoneticSpellingsL(CDesCArray& aList) |
|
2778 { |
|
2779 aList.Reset(); |
|
2780 |
|
2781 if (IsCore()) |
|
2782 { |
|
2783 MPtiCore* core = Core(); |
|
2784 const TInt count = core->PhoneticSpellingCount(); |
|
2785 for (TInt i = 0; i < count; i++) |
|
2786 { |
|
2787 aList.AppendL(core->GetPhoneticSpelling(i + 1)); |
|
2788 } |
|
2789 } |
|
2790 |
|
2791 return aList.Count(); |
|
2792 } |
|
2793 |
|
2794 |
|
2795 // --------------------------------------------------------------------------- |
|
2796 // CPtiEngineImpl::GetChinesePhraseCandidatesL |
|
2797 // |
|
2798 // --------------------------------------------------------------------------- |
|
2799 // |
|
2800 TInt CPtiEngineImpl::GetChinesePhraseCandidatesL(CDesCArray& aList) |
|
2801 { |
|
2802 TBuf<KMaxPhraseBufferSize> candbuf; |
|
2803 TInt start = 0, length = 0; |
|
2804 |
|
2805 aList.Reset(); |
|
2806 |
|
2807 if (IsCore()) |
|
2808 { |
|
2809 if (iInputMode == EPtiEngineStroke) |
|
2810 { |
|
2811 TBuf<1> str; |
|
2812 for (TInt j = 0; j < KMaxCandPages; j++) |
|
2813 { |
|
2814 candbuf.Copy(Core()->GetCandidatePage()); |
|
2815 for (TInt i = 0; i < candbuf.Length(); i++) |
|
2816 { |
|
2817 str.Zero(); |
|
2818 str.Append(candbuf[i]); |
|
2819 aList.AppendL(str); |
|
2820 } |
|
2821 if (!NextCandidatePage()) |
|
2822 { |
|
2823 break; |
|
2824 } |
|
2825 |
|
2826 } |
|
2827 } |
|
2828 else |
|
2829 { |
|
2830 candbuf.Copy(Core()->GetCandidatePage()); |
|
2831 for (TInt i = 0; i < candbuf.Length(); i++) |
|
2832 { |
|
2833 if (candbuf[i] == KPhraseSeparator) |
|
2834 { |
|
2835 TPtrC segment(candbuf.Ptr() + start, length); |
|
2836 aList.AppendL(segment); |
|
2837 start += (length + 1); |
|
2838 length = 0; |
|
2839 } |
|
2840 else |
|
2841 { |
|
2842 length++; |
|
2843 } |
|
2844 } |
|
2845 if (length) |
|
2846 { |
|
2847 TPtrC segm(candbuf.Ptr() + start, length); |
|
2848 aList.AppendL(segm); |
|
2849 } |
|
2850 |
|
2851 } |
|
2852 } |
|
2853 |
|
2854 return aList.Count(); |
|
2855 } |
|
2856 |
|
2857 |
|
2858 // --------------------------------------------------------------------------- |
|
2859 // CPtiEngineImpl::SetToneMark |
|
2860 // |
|
2861 // --------------------------------------------------------------------------- |
|
2862 // |
|
2863 TBool CPtiEngineImpl::SetToneMark(TInt aToneMark) |
|
2864 { |
|
2865 if (IsCore()) |
|
2866 { |
|
2867 return Core()->SetToneMark(aToneMark); |
|
2868 } |
|
2869 |
|
2870 return EFalse; |
|
2871 } |
|
2872 |
|
2873 |
|
2874 // --------------------------------------------------------------------------- |
|
2875 // CPtiEngineImpl::GetAvailableLanguagesL |
|
2876 // |
|
2877 // --------------------------------------------------------------------------- |
|
2878 // |
|
2879 void CPtiEngineImpl::GetAvailableLanguagesL(RArray<TInt>& aResult) |
|
2880 { |
|
2881 aResult.Reset(); |
|
2882 |
|
2883 const TInt count = iLanguages->Count(); |
|
2884 for (TInt i = 0; i < count; i++) |
|
2885 { |
|
2886 if (iLanguages->At(i)->LanguageCode() != ELangNumeric) |
|
2887 { |
|
2888 aResult.AppendL(iLanguages->At(i)->LanguageCode()); |
|
2889 } |
|
2890 } |
|
2891 } |
|
2892 |
|
2893 |
|
2894 // --------------------------------------------------------------------------- |
|
2895 // CPtiEngineImpl::CreateDefaultUserDictionaryFileL |
|
2896 // |
|
2897 // --------------------------------------------------------------------------- |
|
2898 // |
|
2899 void CPtiEngineImpl::CreateDefaultUserDictionaryFileL(TUid aCoreUid, TInt aSymbolClass) |
|
2900 { |
|
2901 TFileName fileName; |
|
2902 |
|
2903 CreateUserDictName(fileName, aCoreUid, aSymbolClass); |
|
2904 |
|
2905 RFs fsSession; |
|
2906 User::LeaveIfError(fsSession.Connect()); // Start session |
|
2907 CleanupClosePushL(fsSession); |
|
2908 |
|
2909 TEntry entry; |
|
2910 TInt error; |
|
2911 error = fsSession.Entry(fileName, entry); |
|
2912 |
|
2913 if (error == KErrPathNotFound) |
|
2914 { |
|
2915 error = fsSession.MkDirAll(KPtiDefaultUdbPath); |
|
2916 User::LeaveIfError(error); |
|
2917 error = fsSession.Entry(fileName, entry); |
|
2918 } |
|
2919 |
|
2920 if (error == KErrNotFound) |
|
2921 { |
|
2922 RFile file; |
|
2923 User::LeaveIfError(file.Create(fsSession, fileName, EFileWrite)); |
|
2924 CleanupClosePushL(file); |
|
2925 |
|
2926 TInt32 uidtmp[1] = {aCoreUid.iUid}; |
|
2927 TPtr8 uidP((TUint8*)uidtmp, sizeof(TInt32)); |
|
2928 uidP.Set((TUint8*)uidtmp, sizeof(TInt32), sizeof(TInt32)); |
|
2929 User::LeaveIfError(file.Write(uidP, sizeof(TInt32))); |
|
2930 |
|
2931 TInt32 sctmp[1]; |
|
2932 sctmp[0] = aSymbolClass; |
|
2933 TPtr8 scP((TUint8*)sctmp, sizeof(TInt32)); |
|
2934 scP.Set((TUint8*)sctmp, sizeof(TInt32), sizeof(TInt32)); |
|
2935 User::LeaveIfError(file.Write(scP, sizeof(TInt32))); |
|
2936 |
|
2937 CleanupStack::PopAndDestroy(); // file |
|
2938 } |
|
2939 else if (error != KErrNone) |
|
2940 { |
|
2941 User::LeaveIfError( error ); |
|
2942 } |
|
2943 |
|
2944 CleanupStack::PopAndDestroy(); // fsSession |
|
2945 } |
|
2946 |
|
2947 |
|
2948 // --------------------------------------------------------------------------- |
|
2949 // CPtiEngineImpl::CreateUserDictName |
|
2950 // |
|
2951 // --------------------------------------------------------------------------- |
|
2952 // |
|
2953 void CPtiEngineImpl::CreateUserDictName(TDes& aResult, TUid aCoreUid, TInt aSymbolClass) |
|
2954 { |
|
2955 aResult.Zero(); |
|
2956 aResult.Append(KPtiDefaultUdbPath); |
|
2957 aResult.AppendNumUC(aCoreUid.iUid, EHex); |
|
2958 aResult.Append('_'); |
|
2959 aResult.AppendNumUC(aSymbolClass, EHex); |
|
2960 aResult.Append(_L(".dat")); |
|
2961 } |
|
2962 |
|
2963 |
|
2964 // --------------------------------------------------------------------------- |
|
2965 // CPtiEngineImpl::CreateSecondaryDataFileName |
|
2966 // |
|
2967 // --------------------------------------------------------------------------- |
|
2968 // |
|
2969 void CPtiEngineImpl::CreateSecondaryDataFileName(TDes& aResult, TUid aCoreUid, TInt aIndex) |
|
2970 { |
|
2971 aResult.Zero(); |
|
2972 aResult.Append(KPtiDefaultUdbPath); |
|
2973 aResult.AppendNumUC(aCoreUid.iUid, EHex); |
|
2974 aResult.Append('_'); |
|
2975 aResult.AppendNumUC(aIndex, EHex); |
|
2976 aResult.Append('S'); |
|
2977 aResult.Append(_L(".dat")); |
|
2978 } |
|
2979 |
|
2980 |
|
2981 // --------------------------------------------------------------------------- |
|
2982 // CPtiEngineImpl::WriteSecondaryDataFileL |
|
2983 // |
|
2984 // --------------------------------------------------------------------------- |
|
2985 // |
|
2986 void CPtiEngineImpl::WriteSecondaryDataFileL(TUid aCoreUid, TInt aIndexNumber, HBufC8* aData) |
|
2987 { |
|
2988 TFileName fileName; |
|
2989 CreateSecondaryDataFileName(fileName, aCoreUid, aIndexNumber); |
|
2990 |
|
2991 RFs fsSession; |
|
2992 RFile file; |
|
2993 User::LeaveIfError(fsSession.Connect()); // Start session |
|
2994 CleanupClosePushL(fsSession); |
|
2995 |
|
2996 TEntry entry; |
|
2997 TInt error; |
|
2998 error = fsSession.Entry(fileName, entry); |
|
2999 |
|
3000 // if path is not existent, create path and file. |
|
3001 if (error == KErrPathNotFound) |
|
3002 { |
|
3003 User::LeaveIfError(fsSession.MkDirAll(KPtiDefaultUdbPath)); |
|
3004 User::LeaveIfError(file.Create(fsSession, fileName, EFileWrite)); |
|
3005 } |
|
3006 // if path is existent and file is not extent, crate file |
|
3007 else if (error == KErrNotFound) |
|
3008 { |
|
3009 User::LeaveIfError(file.Create(fsSession, fileName, EFileWrite)); |
|
3010 } |
|
3011 // if file is already existent, open it |
|
3012 else if (error == KErrNone) |
|
3013 { |
|
3014 User::LeaveIfError(file.Open(fsSession, fileName, EFileWrite)); |
|
3015 } |
|
3016 else |
|
3017 { |
|
3018 User::Leave(error); |
|
3019 } |
|
3020 |
|
3021 CleanupClosePushL(file); |
|
3022 |
|
3023 TPtr8 dataP((TUint8*)aData->Des().Ptr(), aData->Des().MaxSize()); |
|
3024 dataP.Set((TUint8*)aData->Des().Ptr(), aData->Des().Length(), aData->Des().MaxSize()); |
|
3025 User::LeaveIfError(file.Write(dataP)); |
|
3026 |
|
3027 CleanupStack::PopAndDestroy(2); // fsSession, file |
|
3028 } |
|
3029 |
|
3030 // --------------------------------------------------------------------------- |
|
3031 // CPtiEngineImpl::ReadSecondaryDataFileL |
|
3032 // |
|
3033 // --------------------------------------------------------------------------- |
|
3034 // |
|
3035 HBufC8* CPtiEngineImpl::ReadSecondaryDataFileL(TUid aCoreUid, TInt aIndexNumber) |
|
3036 { |
|
3037 TFileName fileName; |
|
3038 CreateSecondaryDataFileName(fileName, aCoreUid, aIndexNumber); |
|
3039 |
|
3040 RFs fsSession; |
|
3041 User::LeaveIfError(fsSession.Connect()); // Start session |
|
3042 CleanupClosePushL(fsSession); |
|
3043 |
|
3044 RFile file; |
|
3045 TInt error = file.Open(fsSession, fileName, EFileRead); |
|
3046 if (error != KErrNone) |
|
3047 { |
|
3048 CleanupStack::PopAndDestroy(); // fsSession |
|
3049 return NULL; |
|
3050 } |
|
3051 |
|
3052 CleanupClosePushL(file); |
|
3053 |
|
3054 TInt size(0); |
|
3055 User::LeaveIfError(file.Size(size)); |
|
3056 |
|
3057 HBufC8* data = HBufC8::NewL(size); |
|
3058 CleanupStack::PushL(data); |
|
3059 |
|
3060 TPtr8 bufP8( data->Des() ); |
|
3061 bufP8.SetLength(size); |
|
3062 bufP8.FillZ(); |
|
3063 User::LeaveIfError(file.Read(bufP8, size)); |
|
3064 |
|
3065 CleanupStack::Pop(); // data |
|
3066 CleanupStack::PopAndDestroy(2); // fsSession, file |
|
3067 |
|
3068 return data; |
|
3069 } |
|
3070 |
|
3071 |
|
3072 // --------------------------------------------------------------------------- |
|
3073 // CPtiEngineImpl::MappingDataForKey |
|
3074 // |
|
3075 // --------------------------------------------------------------------------- |
|
3076 // |
|
3077 void CPtiEngineImpl::MappingDataForKey(TPtiKey aKey, TDes& aResult, TPtiTextCase aCase) |
|
3078 { |
|
3079 aResult.Zero(); |
|
3080 |
|
3081 if (iCurrentLanguage) |
|
3082 { |
|
3083 if( EPtiKeyboardHalfQwerty != KeyboardType() ) |
|
3084 { |
|
3085 if (aCase == EPtiCaseChrLower) |
|
3086 { |
|
3087 aCase = EPtiCaseLower; |
|
3088 } |
|
3089 else if (aCase == EPtiCaseChrUpper) |
|
3090 { |
|
3091 aCase = EPtiCaseUpper; |
|
3092 } |
|
3093 } |
|
3094 |
|
3095 |
|
3096 switch (iInputMode) |
|
3097 { |
|
3098 case EPtiEngineNumeric: |
|
3099 { |
|
3100 CPtiCoreLanguage* lang = static_cast<CPtiCoreLanguage*>(GetLanguage(ELangNumeric)); |
|
3101 if (lang) |
|
3102 { |
|
3103 CPtiKeyMappings* maps = static_cast<CPtiKeyMappings*>(lang->GetKeymappings()); |
|
3104 if (maps) |
|
3105 { |
|
3106 maps->GetDataForKey(aKey, aResult, aCase); |
|
3107 } |
|
3108 } |
|
3109 } |
|
3110 break; |
|
3111 case EPtiEngineMultitapping: |
|
3112 case EPtiEnginePredictive: |
|
3113 { |
|
3114 CPtiKeyMappings* maps = static_cast<CPtiKeyMappings*>(iCurrentLanguage->GetKeymappings()); |
|
3115 maps->GetDataForKey(aKey, aResult, aCase); |
|
3116 } |
|
3117 break; |
|
3118 // Predictive QWERTY (XT9) changes ----> |
|
3119 case EPtiEngineQwertyPredictive: // fall through |
|
3120 // Predictive QWERTY (XT9) changes <---- |
|
3121 case EPtiEngineStrokePhraseQwerty: |
|
3122 case EPtiEnginePinyinPhraseQwerty: |
|
3123 case EPtiEngineZhuyinPhraseQwerty: |
|
3124 case EPtiEngineInputModeZhuyinMiniQwertyFind: |
|
3125 case EPtiEngineNormalCangjieQwerty: |
|
3126 case EPtiEngineEasyCangjieQwerty: |
|
3127 case EPtiEngineAdvCangjieQwerty: |
|
3128 case EPtiEngineQwerty: |
|
3129 { |
|
3130 CPtiQwertyKeyMappings* maps = static_cast<CPtiQwertyKeyMappings*>(iCurrentLanguage->GetQwertyKeymappings()); |
|
3131 maps->GetDataForKey(aKey, aResult, aCase); |
|
3132 } |
|
3133 break; |
|
3134 case EPtiEnginePinyinPhraseHalfQwerty: |
|
3135 case EPtiEngineStrokePhraseHalfQwerty: |
|
3136 case EPtiEngineZhuyinPhraseHalfQwerty: |
|
3137 case EPtiEngineHalfQwerty: |
|
3138 case EPtiEngineHalfQwertyPredictive: |
|
3139 { |
|
3140 CPtiHalfQwertyKeyMappings* maps = static_cast<CPtiHalfQwertyKeyMappings*>(iCurrentLanguage->GetHalfQwertyKeymappings()); |
|
3141 maps->GetDataForKey(aKey, aResult, aCase); |
|
3142 } |
|
3143 break; |
|
3144 default: |
|
3145 break; |
|
3146 } |
|
3147 } |
|
3148 } |
|
3149 |
|
3150 |
|
3151 // --------------------------------------------------------------------------- |
|
3152 // CPtiEngineImpl::MapNumericChar |
|
3153 // |
|
3154 // --------------------------------------------------------------------------- |
|
3155 // |
|
3156 TBool CPtiEngineImpl::MapNumericChar(CPtiMappings* aMaps, TPtiNumericKeyBinding& aBinding, |
|
3157 TPtiKey aKey, TPtiTextCase aCase, TBool aUseExtendedSet, |
|
3158 TPtiEngineInputMode aMode) |
|
3159 { |
|
3160 const TInt KMaxNumCharsPerCase = 50; |
|
3161 TBuf<KMaxNumCharsPerCase> keys; |
|
3162 |
|
3163 TPtiKey convKey = aKey; |
|
3164 #if defined(__WINS__) |
|
3165 if (convKey == EStdKeyNkpPlus) |
|
3166 { |
|
3167 convKey = EPtiKeyQwertyPlus; |
|
3168 } |
|
3169 #endif |
|
3170 |
|
3171 keys.Copy(aMaps->DataForKeyLocal(convKey, aCase, aMode).Left(keys.MaxLength())); |
|
3172 |
|
3173 if (keys.Length() > 0) |
|
3174 { |
|
3175 TUint16 firstChar = keys[0]; |
|
3176 switch (firstChar) |
|
3177 { |
|
3178 case KPtiPinyinMarker: |
|
3179 case KPtiStrokeMarker: |
|
3180 case KPtiZhuyinMarker: |
|
3181 case KPtiCangjieMarker: |
|
3182 case KPtiGetAllMarker: |
|
3183 if (keys.Length() > 1) |
|
3184 { |
|
3185 firstChar = keys[1]; |
|
3186 } |
|
3187 break; |
|
3188 default: |
|
3189 break; |
|
3190 } |
|
3191 |
|
3192 // Handle Chinese versions of these characters as a special case. |
|
3193 if (firstChar == KPtiChineseHash) |
|
3194 { |
|
3195 firstChar = '#'; |
|
3196 } |
|
3197 else if (firstChar == KPtiChinesePlus) |
|
3198 { |
|
3199 firstChar = '+'; |
|
3200 } |
|
3201 else if (firstChar == KPtiChineseStar) |
|
3202 { |
|
3203 firstChar = '*'; |
|
3204 } |
|
3205 |
|
3206 TInt loc = 0; |
|
3207 if (aUseExtendedSet) |
|
3208 { |
|
3209 loc = KAllAllowedNumericChars().Locate(firstChar); |
|
3210 } |
|
3211 else |
|
3212 { |
|
3213 loc = KAllowedNumericChars().Locate(firstChar); |
|
3214 } |
|
3215 |
|
3216 if (loc != KErrNotFound) |
|
3217 { |
|
3218 aBinding.iChar = firstChar; |
|
3219 aBinding.iKey = aKey; |
|
3220 aBinding.iCase = aCase; |
|
3221 return ETrue; |
|
3222 } |
|
3223 } |
|
3224 |
|
3225 return EFalse; |
|
3226 } |
|
3227 |
|
3228 |
|
3229 // --------------------------------------------------------------------------- |
|
3230 // CPtiEngineImpl::NumericModeKeysForQwertyL |
|
3231 // |
|
3232 // --------------------------------------------------------------------------- |
|
3233 // |
|
3234 void CPtiEngineImpl::NumericModeKeysForQwertyL(TInt aLanguage, |
|
3235 RArray<TPtiNumericKeyBinding>& aResult, |
|
3236 TBool aUseExtendedSet, |
|
3237 TPtiKeyboardType aKeyboardType) |
|
3238 { |
|
3239 aResult.Reset(); |
|
3240 TPtiNumericKeyBinding bind; |
|
3241 |
|
3242 TPtiKeyboardType keyboardType = aKeyboardType; |
|
3243 if (keyboardType == EPtiKeyboardNone) |
|
3244 { |
|
3245 keyboardType = ActiveKeyboardTypeL(); |
|
3246 |
|
3247 if (keyboardType == EPtiKeyboard12Key || |
|
3248 keyboardType == EPtiKeyboardNone) |
|
3249 { |
|
3250 keyboardType = FindFirstAvailableQwertyKeyboardType(aLanguage); |
|
3251 } |
|
3252 } |
|
3253 |
|
3254 if (keyboardType == EPtiKeyboard12Key || |
|
3255 keyboardType == EPtiKeyboardNone) |
|
3256 { |
|
3257 // No qwerty data available, can't go on. |
|
3258 return; |
|
3259 } |
|
3260 |
|
3261 if (aLanguage == ELangJapanese) |
|
3262 { |
|
3263 // Japanese doesn't have qwerty keymappings file, handle it |
|
3264 // with hardcoded data. |
|
3265 TInt count = KNumBindingsForNonLatinNumberLanguages; |
|
3266 if (aUseExtendedSet) |
|
3267 { |
|
3268 count = KNumExtendedBindingsForNonLatinNumberLanguages; |
|
3269 } |
|
3270 for (TInt i = 0; i < count; i++) |
|
3271 { |
|
3272 bind = NumericModeKeysForNonLatinNumberLanguages[i]; |
|
3273 User::LeaveIfError(aResult.Append(bind)); |
|
3274 } |
|
3275 |
|
3276 return; |
|
3277 } |
|
3278 |
|
3279 TPtiEngineInputMode mode = EPtiEngineQwerty; |
|
3280 if (keyboardType == EPtiKeyboardHalfQwerty) |
|
3281 { |
|
3282 mode = EPtiEngineHalfQwerty; |
|
3283 } |
|
3284 |
|
3285 CPtiCoreLanguage *lang = static_cast<CPtiCoreLanguage*>(GetLanguage( aLanguage )); |
|
3286 if (lang) |
|
3287 { |
|
3288 CPtiMappings* mappings = NULL; |
|
3289 CPtiQwertyKeyMappings* qmappings = NULL; |
|
3290 TPtiKeyboardType origKeyb = EPtiKeyboardNone; |
|
3291 |
|
3292 if (mode == EPtiEngineHalfQwerty) |
|
3293 { |
|
3294 CPtiHalfQwertyKeyMappings* hqmappings = |
|
3295 static_cast<CPtiHalfQwertyKeyMappings*>(lang->GetHalfQwertyKeymappings()); |
|
3296 mappings = hqmappings; |
|
3297 if (hqmappings) |
|
3298 { |
|
3299 // First insert "numeric_mode_key" definitions given in keymap data file. |
|
3300 hqmappings->GetNumericModeKeysFromDataL(aResult); |
|
3301 } |
|
3302 } |
|
3303 else |
|
3304 { |
|
3305 qmappings = static_cast<CPtiQwertyKeyMappings*>(lang->GetQwertyKeymappings()); |
|
3306 mappings = qmappings; |
|
3307 if (qmappings) |
|
3308 { |
|
3309 origKeyb = qmappings->KeyboardType(); |
|
3310 qmappings->SetKeyboardType(keyboardType); |
|
3311 // First insert "numeric_mode_key" definitions given in keymap data file. |
|
3312 qmappings->GetNumericModeKeysFromDataL(aResult); |
|
3313 } |
|
3314 } |
|
3315 |
|
3316 if (mappings) |
|
3317 { |
|
3318 // if not "extended" set, filter out possible extra definitions. |
|
3319 if (!aUseExtendedSet) |
|
3320 { |
|
3321 for (TInt zz = 0; zz < aResult.Count(); zz++) |
|
3322 { |
|
3323 if (KExtendedNumericModeChars().Locate(aResult[zz].iChar) != KErrNotFound) |
|
3324 { |
|
3325 aResult.Remove(zz); |
|
3326 zz--; |
|
3327 } |
|
3328 } |
|
3329 } |
|
3330 |
|
3331 // Then use actual keymap data for remaining characters. |
|
3332 for (TInt i = 0; qwertyKeys[i] != 0; i++) |
|
3333 { |
|
3334 if (MapNumericChar(mappings, bind, qwertyKeys[i], EPtiCaseLower, aUseExtendedSet, mode)) |
|
3335 { |
|
3336 User::LeaveIfError(aResult.Append(bind)); |
|
3337 } |
|
3338 if (MapNumericChar(mappings, bind, qwertyKeys[i], EPtiCaseUpper, aUseExtendedSet, mode)) |
|
3339 { |
|
3340 User::LeaveIfError(aResult.Append(bind)); |
|
3341 } |
|
3342 if (MapNumericChar(mappings, bind, qwertyKeys[i], EPtiCaseFnLower, aUseExtendedSet, mode)) |
|
3343 { |
|
3344 User::LeaveIfError(aResult.Append(bind)); |
|
3345 } |
|
3346 if (MapNumericChar(mappings, bind, qwertyKeys[i], EPtiCaseFnUpper, aUseExtendedSet, mode)) |
|
3347 { |
|
3348 User::LeaveIfError(aResult.Append(bind)); |
|
3349 } |
|
3350 } |
|
3351 |
|
3352 if (qmappings && keyboardType != origKeyb) |
|
3353 { |
|
3354 qmappings->SetKeyboardType(origKeyb); |
|
3355 } |
|
3356 } |
|
3357 } |
|
3358 } |
|
3359 |
|
3360 |
|
3361 // --------------------------------------------------------------------------- |
|
3362 // CPtiEngineImpl::GetNumericModeKeysForQwertyL |
|
3363 // |
|
3364 // --------------------------------------------------------------------------- |
|
3365 // |
|
3366 void CPtiEngineImpl::GetNumericModeKeysForQwertyL(TInt aLanguage, |
|
3367 RArray<TPtiNumericKeyBinding>& aResult) |
|
3368 { |
|
3369 NumericModeKeysForQwertyL(aLanguage, aResult, EFalse); |
|
3370 } |
|
3371 |
|
3372 |
|
3373 // --------------------------------------------------------------------------- |
|
3374 // CPtiEngineImpl::ExtendedNumericModeKeysForQwertyL |
|
3375 // |
|
3376 // --------------------------------------------------------------------------- |
|
3377 // |
|
3378 const RArray<TPtiNumericKeyBinding>& CPtiEngineImpl::ExtendedNumericModeKeysForQwertyL(TInt aLanguage) |
|
3379 { |
|
3380 if (iExtendedNumricSetLang != aLanguage) |
|
3381 { |
|
3382 NumericModeKeysForQwertyL(aLanguage, iExtendedNumricSet, ETrue); |
|
3383 iExtendedNumricSetLang = aLanguage; |
|
3384 } |
|
3385 |
|
3386 return iExtendedNumricSet; |
|
3387 } |
|
3388 |
|
3389 |
|
3390 // --------------------------------------------------------------------------- |
|
3391 // CPtiEngineImpl::GetHwrRecognizerL |
|
3392 // (other items were commented in a header). |
|
3393 // --------------------------------------------------------------------------- |
|
3394 // |
|
3395 MPtiHwrRecognizer* CPtiEngineImpl::GetHwrRecognizerL(TLanguage aLanguage) |
|
3396 { |
|
3397 if ((iCurrentHwrImpl == NULL) || |
|
3398 (iCurrentHwrImpl->iHwrLanguagesList.Find(aLanguage) == KErrNotFound)) |
|
3399 { |
|
3400 if (iCurrentHwrImpl != NULL) |
|
3401 { |
|
3402 delete iCurrentHwrImpl; |
|
3403 iCurrentHwrImpl = NULL; |
|
3404 } |
|
3405 |
|
3406 iCurrentHwrImpl = new (ELeave) CPtiHwrRecognizer; |
|
3407 iCurrentHwrImpl->iHwrRecognizer = CHwrRecognizer::NewL(aLanguage, iCurrentHwrImpl->iHwrImpId); |
|
3408 |
|
3409 CHwrRecognizer::ListGivenAvailableLanguagesL(iCurrentHwrImpl->iHwrImpId, iCurrentHwrImpl->iHwrLanguagesList); |
|
3410 } |
|
3411 |
|
3412 if (iCurrentHwrImpl != NULL) |
|
3413 { |
|
3414 return iCurrentHwrImpl->iHwrRecognizer; |
|
3415 } |
|
3416 else |
|
3417 { |
|
3418 return NULL; |
|
3419 } |
|
3420 } |
|
3421 |
|
3422 |
|
3423 // --------------------------------------------------------------------------- |
|
3424 // CPtiEngineImpl::GetHwrRecognizerL |
|
3425 // (other items were commented in a header). |
|
3426 // --------------------------------------------------------------------------- |
|
3427 // |
|
3428 MPtiHwrRecognizer* CPtiEngineImpl::GetHwrRecognizerL(TInt aImpId) |
|
3429 { |
|
3430 if ((iCurrentHwrImpl == NULL) || |
|
3431 (iCurrentHwrImpl->iHwrImpId != TUid::Uid(aImpId))) |
|
3432 { |
|
3433 if (iCurrentHwrImpl != NULL) |
|
3434 { |
|
3435 delete iCurrentHwrImpl; |
|
3436 iCurrentHwrImpl = NULL; |
|
3437 } |
|
3438 |
|
3439 iCurrentHwrImpl = new (ELeave) CPtiHwrRecognizer; |
|
3440 iCurrentHwrImpl->iHwrRecognizer = CHwrRecognizer::NewL(aImpId); |
|
3441 iCurrentHwrImpl->iHwrImpId = TUid::Uid(aImpId); |
|
3442 |
|
3443 CHwrRecognizer::ListGivenAvailableLanguagesL(iCurrentHwrImpl->iHwrImpId, iCurrentHwrImpl->iHwrLanguagesList); |
|
3444 } |
|
3445 |
|
3446 if (iCurrentHwrImpl != NULL) |
|
3447 { |
|
3448 return iCurrentHwrImpl->iHwrRecognizer; |
|
3449 } |
|
3450 else |
|
3451 { |
|
3452 return NULL; |
|
3453 } |
|
3454 } |
|
3455 |
|
3456 |
|
3457 // --------------------------------------------------------------------------- |
|
3458 // CPtiEngineImpl::ListHwrRecognizerL |
|
3459 // (other items were commented in a header). |
|
3460 // --------------------------------------------------------------------------- |
|
3461 // |
|
3462 RArray<TUid>& CPtiEngineImpl::ListHwrRecognizerL(TLanguage aLanguage) |
|
3463 { |
|
3464 iImpIdList.Reset(); |
|
3465 |
|
3466 CHwrRecognizer* hwrRecognizer = new(ELeave)CHwrRecognizer; |
|
3467 CleanupStack::PushL(hwrRecognizer); |
|
3468 hwrRecognizer->ListImplementationsL(aLanguage, iImpIdList); |
|
3469 CleanupStack::Pop(hwrRecognizer); |
|
3470 delete hwrRecognizer; |
|
3471 |
|
3472 return iImpIdList; |
|
3473 } |
|
3474 |
|
3475 |
|
3476 // --------------------------------------------------------------------------- |
|
3477 // CPtiEngineImpl::GetHwrAvailableLanguagesL |
|
3478 // (other items were commented in a header). |
|
3479 // --------------------------------------------------------------------------- |
|
3480 // |
|
3481 void CPtiEngineImpl::GetHwrAvailableLanguagesL(RArray<TInt>& aResult) |
|
3482 { |
|
3483 CHwrRecognizer* hwrRecognizer = new(ELeave)CHwrRecognizer; |
|
3484 CleanupStack::PushL(hwrRecognizer); |
|
3485 hwrRecognizer->ListAvailableLanguagesL(aResult); |
|
3486 CleanupStack::Pop(hwrRecognizer); |
|
3487 delete hwrRecognizer; |
|
3488 } |
|
3489 |
|
3490 |
|
3491 // --------------------------------------------------------------------------- |
|
3492 // CPtiEngineImpl::GetCandidatesByInputString |
|
3493 // |
|
3494 // --------------------------------------------------------------------------- |
|
3495 // |
|
3496 EXPORT_C HBufC* CPtiEngineImpl::GetCandidatesByInputString(const TDesC& aInputString, |
|
3497 RPointerArray<HBufC>& aList, |
|
3498 const TBool aIsPredictive) |
|
3499 { |
|
3500 if (IsCore()) |
|
3501 { |
|
3502 return Core()->GetCandidatesByInputString(aInputString, aList, aIsPredictive); |
|
3503 } |
|
3504 else |
|
3505 { |
|
3506 return NULL; |
|
3507 } |
|
3508 } |
|
3509 |
|
3510 |
|
3511 // --------------------------------------------------------------------------- |
|
3512 // CPtiEngineImpl::GetCandidatesByInputString |
|
3513 // |
|
3514 // --------------------------------------------------------------------------- |
|
3515 // |
|
3516 TInt CPtiEngineImpl::SetAutoSubstitution(TBool aStatus) |
|
3517 { |
|
3518 if (IsCore()) |
|
3519 { |
|
3520 TInt err = KErrNone; |
|
3521 TInt ret = 0; |
|
3522 TRAP(err, ret = Core()->HandleCommandL(EPtiCommandSetAutoSubstitution, (TAny*)aStatus)); |
|
3523 |
|
3524 if (err != KErrNone) |
|
3525 { |
|
3526 return err; |
|
3527 } |
|
3528 |
|
3529 return ret; |
|
3530 } |
|
3531 |
|
3532 if (!iCurrentLanguage) |
|
3533 { |
|
3534 return KErrNoActiveLanguage; |
|
3535 } |
|
3536 |
|
3537 return KErrNoSuitableCore; |
|
3538 } |
|
3539 |
|
3540 |
|
3541 // --------------------------------------------------------------------------- |
|
3542 // CPtiEngineImpl::AddAutoSubstitutionEntry |
|
3543 // |
|
3544 // --------------------------------------------------------------------------- |
|
3545 // |
|
3546 TInt CPtiEngineImpl::AddAutoSubstitutionEntry(const TDesC& aShortcut, |
|
3547 const TDesC& aSubstitution) |
|
3548 { |
|
3549 if (IsCore()) |
|
3550 { |
|
3551 TPtiAutoSubstBinding bind; |
|
3552 bind.iShortcut.Copy(aShortcut.Left(bind.iShortcut.MaxLength())); |
|
3553 bind.iSubstitution.Copy(aSubstitution.Left(bind.iSubstitution.MaxLength())); |
|
3554 |
|
3555 TInt err = KErrNone; |
|
3556 TInt ret = 0; |
|
3557 TRAP(err, ret = Core()->HandleCommandL(EPtiCommandAddAutoSubstEntry, &bind)); |
|
3558 if (err != KErrNone) |
|
3559 { |
|
3560 return err; |
|
3561 } |
|
3562 |
|
3563 return ret; |
|
3564 } |
|
3565 |
|
3566 if (!iCurrentLanguage) |
|
3567 { |
|
3568 return KErrNoActiveLanguage; |
|
3569 } |
|
3570 |
|
3571 return KErrNoSuitableCore; |
|
3572 } |
|
3573 |
|
3574 |
|
3575 // --------------------------------------------------------------------------- |
|
3576 // CPtiEngineImpl::DeleteAutoSubstitutionEntry |
|
3577 // |
|
3578 // --------------------------------------------------------------------------- |
|
3579 // |
|
3580 TInt CPtiEngineImpl::DeleteAutoSubstitutionEntry(const TDesC& aShortcut) |
|
3581 { |
|
3582 if (IsCore()) |
|
3583 { |
|
3584 TPtiAutoSubstBinding bind; |
|
3585 bind.iShortcut.Copy(aShortcut.Left(bind.iShortcut.MaxLength())); |
|
3586 |
|
3587 TInt err = KErrNone; |
|
3588 TInt ret = 0; |
|
3589 |
|
3590 TRAP(err, ret = Core()->HandleCommandL(EPtiCommandDeleteAutoSubstEntry, &bind)); |
|
3591 if (err != KErrNone) |
|
3592 { |
|
3593 return err; |
|
3594 } |
|
3595 |
|
3596 return ret; |
|
3597 } |
|
3598 |
|
3599 if (!iCurrentLanguage) |
|
3600 { |
|
3601 return KErrNoActiveLanguage; |
|
3602 } |
|
3603 |
|
3604 return KErrNoSuitableCore; |
|
3605 } |
|
3606 |
|
3607 |
|
3608 // --------------------------------------------------------------------------- |
|
3609 // CPtiEngineImpl::NumberOfAutoSubstitutionEntries |
|
3610 // |
|
3611 // --------------------------------------------------------------------------- |
|
3612 // |
|
3613 TInt CPtiEngineImpl::NumberOfAutoSubstitutionEntries() const |
|
3614 { |
|
3615 if (IsCore()) |
|
3616 { |
|
3617 TInt err = KErrNone; |
|
3618 TInt ret = 0; |
|
3619 |
|
3620 TRAP(err, ret = Core()->HandleCommandL(EPtiCommandNumberOfAutoSubstEntries, NULL)); |
|
3621 if (err != KErrNone) |
|
3622 { |
|
3623 return 0; |
|
3624 } |
|
3625 |
|
3626 return ret; |
|
3627 } |
|
3628 |
|
3629 if (!iCurrentLanguage) |
|
3630 { |
|
3631 return KErrNoActiveLanguage; |
|
3632 } |
|
3633 |
|
3634 return KErrNoSuitableCore; |
|
3635 } |
|
3636 |
|
3637 |
|
3638 // --------------------------------------------------------------------------- |
|
3639 // CPtiEngineImpl::GetAutoSubstitutionEntry |
|
3640 // |
|
3641 // --------------------------------------------------------------------------- |
|
3642 // |
|
3643 TInt CPtiEngineImpl::GetAutoSubstitutionEntry(TInt aIndex, TDes& aShortcut, |
|
3644 TDes& aSubstitution) |
|
3645 { |
|
3646 if (IsCore()) |
|
3647 { |
|
3648 TPtiAutoSubstBinding bind; |
|
3649 bind.iIndex = aIndex; |
|
3650 aShortcut.Zero(); |
|
3651 aSubstitution.Zero(); |
|
3652 |
|
3653 TInt err = KErrNone; |
|
3654 TInt ret = 0; |
|
3655 |
|
3656 TRAP(err, ret = Core()->HandleCommandL(EPtiCommandGetAutoSubstEntry, &bind)); |
|
3657 |
|
3658 if (err != KErrNone) |
|
3659 { |
|
3660 return err; |
|
3661 } |
|
3662 |
|
3663 aShortcut.Copy(bind.iShortcut.Left(aShortcut.MaxLength())); |
|
3664 aSubstitution.Copy(bind.iSubstitution.Left(aSubstitution.MaxLength())); |
|
3665 |
|
3666 return ret; |
|
3667 } |
|
3668 |
|
3669 if (!iCurrentLanguage) |
|
3670 { |
|
3671 return KErrNoActiveLanguage; |
|
3672 } |
|
3673 |
|
3674 return KErrNoSuitableCore; |
|
3675 } |
|
3676 |
|
3677 |
|
3678 // --------------------------------------------------------------------------- |
|
3679 // CPtiEngineImpl::KeyboardType |
|
3680 // |
|
3681 // --------------------------------------------------------------------------- |
|
3682 // |
|
3683 TPtiKeyboardType CPtiEngineImpl::KeyboardType() const |
|
3684 { |
|
3685 /* CPtiMappings* maps = NULL; |
|
3686 |
|
3687 if (iCurrentLanguage) |
|
3688 { |
|
3689 if (iFrontEnd->IsQwertyBasedMode(iInputMode)) |
|
3690 { |
|
3691 maps = static_cast<CPtiQwertyKeyMappings *>(iCurrentLanguage->GetQwertyKeymappings()); |
|
3692 } |
|
3693 else if (iInputMode == EPtiEngineHalfQwerty || |
|
3694 iInputMode == EPtiEngineHalfQwertyPredictive) |
|
3695 { |
|
3696 maps = static_cast<CPtiQwertyKeyMappings *>(iCurrentLanguage->GetHalfQwertyKeymappings()); |
|
3697 } |
|
3698 else |
|
3699 { |
|
3700 maps = static_cast<CPtiQwertyKeyMappings *>(iCurrentLanguage->GetKeymappings()); |
|
3701 } |
|
3702 } |
|
3703 |
|
3704 if (maps) |
|
3705 { |
|
3706 return maps->KeyboardType(); |
|
3707 } |
|
3708 |
|
3709 return EPtiKeyboardNone;*/ |
|
3710 TInt keyboardLayout = 0; |
|
3711 |
|
3712 RProperty::Get(KCRUidAvkon, KAknKeyBoardLayout, keyboardLayout); |
|
3713 |
|
3714 if (keyboardLayout <= 0 || |
|
3715 keyboardLayout > EPtiKeyboardMaxLayout - 1) |
|
3716 { |
|
3717 return EPtiKeyboardNone; |
|
3718 } |
|
3719 |
|
3720 return (TPtiKeyboardType)keyboardLayout; |
|
3721 } |
|
3722 |
|
3723 |
|
3724 // --------------------------------------------------------------------------- |
|
3725 // CPtiEngine::KeyboardType |
|
3726 // |
|
3727 // --------------------------------------------------------------------------- |
|
3728 // |
|
3729 TInt CPtiEngineImpl::SetKeyboardType(TPtiKeyboardType aType) |
|
3730 { |
|
3731 if (!iCurrentLanguage) |
|
3732 { |
|
3733 return KErrNoActiveLanguage; |
|
3734 } |
|
3735 |
|
3736 switch (aType) |
|
3737 { |
|
3738 case EPtiKeyboard12Key: |
|
3739 if (iInputMode == EPtiEngineMultitapping || |
|
3740 iInputMode == EPtiEnginePredictive || |
|
3741 iInputMode == EPtiEngineWordCompletion || |
|
3742 iInputMode == EPtiEngineNumeric || |
|
3743 iInputMode == EPtiEnginePinyin || |
|
3744 iInputMode == EPtiEngineStroke || |
|
3745 iInputMode == EPtiEngineZhuyin || |
|
3746 iInputMode == EPtiEngineHiraganaKanji || |
|
3747 iInputMode == EPtiEngineHiraganaKanjiPredictive || |
|
3748 iInputMode == EPtiEngineKatakana || |
|
3749 iInputMode == EPtiEngineFullWidthKatakana || |
|
3750 iInputMode == EPtiEngineFullWidthNumeric || |
|
3751 iInputMode == EPtiEngineFullWidthAlphabet || |
|
3752 iInputMode == EPtiEngineHiragana || |
|
3753 iInputMode == EPtiEnginePinyinByPhrase || |
|
3754 #ifdef RD_HINDI_PHONETIC_INPUT |
|
3755 iInputMode == EPtiEngineInputModeIndicPhoneticMultitap || |
|
3756 #endif |
|
3757 iInputMode == EPtiEngineZhuyinByPhrase) |
|
3758 { |
|
3759 return KErrNone; |
|
3760 } |
|
3761 break; |
|
3762 |
|
3763 case EPtiKeyboardQwerty4x12: |
|
3764 case EPtiKeyboardQwerty4x10: |
|
3765 case EPtiKeyboardQwerty3x11: |
|
3766 case EPtiKeyboardCustomQwerty: |
|
3767 if (iFrontEnd->IsQwertyBasedMode(iInputMode)) |
|
3768 { |
|
3769 CPtiQwertyKeyMappings *qmaps = static_cast<CPtiQwertyKeyMappings *>(iCurrentLanguage->GetQwertyKeymappings()); |
|
3770 if (qmaps) |
|
3771 { |
|
3772 if (qmaps->SetKeyboardType(aType) == KErrNone) |
|
3773 { |
|
3774 return KErrNone; |
|
3775 } |
|
3776 } |
|
3777 } |
|
3778 break; |
|
3779 case EPtiKeyboardHalfQwerty: |
|
3780 if (iInputMode == EPtiEngineHalfQwerty || |
|
3781 iInputMode == EPtiEngineHalfQwertyPredictive || |
|
3782 iInputMode == EPtiEnginePinyinPhraseHalfQwerty) |
|
3783 { |
|
3784 return KErrNone; |
|
3785 } |
|
3786 break; |
|
3787 default: |
|
3788 break; |
|
3789 } |
|
3790 |
|
3791 return KErrNotSupported; |
|
3792 } |
|
3793 |
|
3794 |
|
3795 // --------------------------------------------------------------------------- |
|
3796 // CPtiEngineImpl::KeyboardTypesSupportedByLanguage |
|
3797 // |
|
3798 // --------------------------------------------------------------------------- |
|
3799 // |
|
3800 void CPtiEngineImpl::KeyboardTypesSupportedByLanguageL(TInt aLanguage, |
|
3801 RArray<TPtiKeyboardType>& aResult) |
|
3802 { |
|
3803 CPtiCoreLanguage* lang = NULL; |
|
3804 |
|
3805 if (iCurrentLanguage && iCurrentLanguage->LanguageCode() == aLanguage) |
|
3806 { |
|
3807 lang = iCurrentLanguage; |
|
3808 } |
|
3809 else |
|
3810 { |
|
3811 lang = static_cast<CPtiCoreLanguage*>(GetLanguage(aLanguage)); |
|
3812 } |
|
3813 |
|
3814 if (lang) |
|
3815 { |
|
3816 TInt tmpSize = 0; |
|
3817 |
|
3818 CPtiKeyMappings* maps = static_cast<CPtiKeyMappings*>(lang->GetKeymappings()); |
|
3819 if (maps && |
|
3820 maps->KeyMapData() && |
|
3821 maps->KeyMapData()->KeyData(EPtiKeyboard12Key, tmpSize)) |
|
3822 { |
|
3823 User::LeaveIfError(aResult.Append(EPtiKeyboard12Key)); |
|
3824 } |
|
3825 |
|
3826 CPtiQwertyKeyMappings* qmaps = static_cast<CPtiQwertyKeyMappings*>(lang->GetQwertyKeymappings()); |
|
3827 if (qmaps) |
|
3828 { |
|
3829 CPtiKeyMapData* mapData = maps->KeyMapData(); |
|
3830 if (mapData) |
|
3831 { |
|
3832 if (mapData->KeyData(EPtiKeyboardQwerty4x12, tmpSize)) |
|
3833 { |
|
3834 User::LeaveIfError(aResult.Append(EPtiKeyboardQwerty4x12)); |
|
3835 } |
|
3836 if (mapData->KeyData(EPtiKeyboardQwerty4x10, tmpSize)) |
|
3837 { |
|
3838 User::LeaveIfError(aResult.Append(EPtiKeyboardQwerty4x10)); |
|
3839 } |
|
3840 if (mapData->KeyData(EPtiKeyboardQwerty3x11, tmpSize)) |
|
3841 { |
|
3842 User::LeaveIfError(aResult.Append(EPtiKeyboardQwerty3x11)); |
|
3843 } |
|
3844 if (mapData->KeyData(EPtiKeyboardCustomQwerty, tmpSize)) |
|
3845 { |
|
3846 User::LeaveIfError(aResult.Append(EPtiKeyboardCustomQwerty)); |
|
3847 } |
|
3848 } |
|
3849 } |
|
3850 |
|
3851 CPtiHalfQwertyKeyMappings* hmaps = static_cast<CPtiHalfQwertyKeyMappings*>(lang->GetHalfQwertyKeymappings()); |
|
3852 if (hmaps && |
|
3853 hmaps->KeyMapData() && |
|
3854 hmaps->KeyMapData()->KeyData(EPtiKeyboardHalfQwerty, tmpSize)) |
|
3855 { |
|
3856 User::LeaveIfError(aResult.Append(EPtiKeyboardHalfQwerty)); |
|
3857 } |
|
3858 } |
|
3859 } |
|
3860 |
|
3861 |
|
3862 // --------------------------------------------------------------------------- |
|
3863 // CPtiEngineImpl::ActiveKeyboardTypeL |
|
3864 // |
|
3865 // --------------------------------------------------------------------------- |
|
3866 // |
|
3867 TPtiKeyboardType CPtiEngineImpl::ActiveKeyboardTypeL() |
|
3868 { |
|
3869 // Qwerty Keyboard layout |
|
3870 TInt keyboardLayout = 0; |
|
3871 |
|
3872 RProperty::Get(KCRUidAvkon, KAknKeyBoardLayout, keyboardLayout); |
|
3873 |
|
3874 if (keyboardLayout <= 0 || |
|
3875 keyboardLayout > EPtiKeyboardMaxLayout - 1) |
|
3876 { |
|
3877 return EPtiKeyboardNone; |
|
3878 } |
|
3879 |
|
3880 return (TPtiKeyboardType)keyboardLayout; |
|
3881 } |
|
3882 |
|
3883 |
|
3884 // --------------------------------------------------------------------------- |
|
3885 // CPtiEngineImpl::GetNumericModeKeysForQwertyL |
|
3886 // |
|
3887 // --------------------------------------------------------------------------- |
|
3888 // |
|
3889 void CPtiEngineImpl::GetNumericModeKeysForQwertyL(TInt aLanguage, |
|
3890 RArray<TPtiNumericKeyBinding>& aResult, |
|
3891 TPtiKeyboardType aKeyboardType) |
|
3892 { |
|
3893 NumericModeKeysForQwertyL(aLanguage, aResult, EFalse, aKeyboardType); |
|
3894 } |
|
3895 |
|
3896 |
|
3897 // --------------------------------------------------------------------------- |
|
3898 // CPtiEngineImpl::ExtendedNumericModeKeysForQwertyL |
|
3899 // |
|
3900 // --------------------------------------------------------------------------- |
|
3901 // |
|
3902 const RArray<TPtiNumericKeyBinding>& CPtiEngineImpl::ExtendedNumericModeKeysForQwertyL(TInt aLanguage, |
|
3903 TPtiKeyboardType aKeyboardType) |
|
3904 { |
|
3905 if (iExtendedNumricSetLang != aLanguage) |
|
3906 { |
|
3907 NumericModeKeysForQwertyL(aLanguage, iExtendedNumricSet, ETrue, aKeyboardType); |
|
3908 iExtendedNumricSetLang = aLanguage; |
|
3909 } |
|
3910 |
|
3911 return iExtendedNumricSet; |
|
3912 } |
|
3913 |
|
3914 |
|
3915 // --------------------------------------------------------------------------- |
|
3916 // CPtiEngineImpl::FindFirstAvailableQwertyKeyboardType |
|
3917 // |
|
3918 // --------------------------------------------------------------------------- |
|
3919 // |
|
3920 TPtiKeyboardType CPtiEngineImpl::FindFirstAvailableQwertyKeyboardType(TInt aLang) const |
|
3921 { |
|
3922 CPtiCoreLanguage* lang = static_cast<CPtiCoreLanguage*>(GetLanguage(aLang)); |
|
3923 |
|
3924 if (lang) |
|
3925 { |
|
3926 CPtiQwertyKeyMappings* maps = static_cast<CPtiQwertyKeyMappings*>(lang->GetQwertyKeymappings()); |
|
3927 if (maps) |
|
3928 { |
|
3929 TInt tmpSize = 0; |
|
3930 CPtiKeyMapData* mapData = maps->KeyMapData(); |
|
3931 |
|
3932 if (mapData->KeyData(EPtiKeyboardQwerty4x12, tmpSize)) |
|
3933 { |
|
3934 return EPtiKeyboardQwerty4x12; |
|
3935 } |
|
3936 if (mapData->KeyData(EPtiKeyboardQwerty4x10, tmpSize)) |
|
3937 { |
|
3938 return EPtiKeyboardQwerty4x10; |
|
3939 } |
|
3940 if (mapData->KeyData(EPtiKeyboardQwerty3x11, tmpSize)) |
|
3941 { |
|
3942 return EPtiKeyboardQwerty3x11; |
|
3943 } |
|
3944 if (mapData->KeyData(EPtiKeyboardCustomQwerty, tmpSize)) |
|
3945 { |
|
3946 return EPtiKeyboardCustomQwerty; |
|
3947 } |
|
3948 if (mapData->KeyData(EPtiKeyboardHalfQwerty, tmpSize)) |
|
3949 { |
|
3950 return EPtiKeyboardHalfQwerty; |
|
3951 } |
|
3952 } |
|
3953 } |
|
3954 |
|
3955 return EPtiKeyboardNone; |
|
3956 } |
|
3957 |
|
3958 |
|
3959 // --------------------------------------------------------------------------- |
|
3960 // CPtiEngineImpl::SetNumberCandidateStatus |
|
3961 // |
|
3962 // --------------------------------------------------------------------------- |
|
3963 // |
|
3964 TInt CPtiEngineImpl::SetNumberCandidateStatus(TBool aStatus) |
|
3965 { |
|
3966 if (Core()) |
|
3967 { |
|
3968 TInt ret = KErrNone; |
|
3969 TInt err = KErrNone; |
|
3970 |
|
3971 TRAP(err, ret = Core()->HandleCommandL(EPtiCommandSetNumberCandidateStatus, (TAny*)&aStatus)); |
|
3972 |
|
3973 if (err != KErrNone) |
|
3974 { |
|
3975 return err; |
|
3976 } |
|
3977 |
|
3978 return ret; |
|
3979 } |
|
3980 |
|
3981 |
|
3982 return KErrNoSuitableCore; |
|
3983 } |
|
3984 |
|
3985 |
|
3986 // --------------------------------------------------------------------------- |
|
3987 // CPtiEngineImpl::SetNumberCandidateStatus |
|
3988 // |
|
3989 // --------------------------------------------------------------------------- |
|
3990 // |
|
3991 TInt CPtiEngineImpl::SetMaxLengthForAutoCompletedCandidates(TInt aMaxLength) |
|
3992 { |
|
3993 if (IsCore()) |
|
3994 { |
|
3995 TInt ret = KErrNone; |
|
3996 TInt err = KErrNone; |
|
3997 |
|
3998 TRAP(err, ret = Core()->HandleCommandL(EPtiCommandSetAutoCompletionMaxLength, (TAny*)aMaxLength)); |
|
3999 |
|
4000 if (err != KErrNone) |
|
4001 { |
|
4002 return err; |
|
4003 } |
|
4004 |
|
4005 return ret; |
|
4006 } |
|
4007 |
|
4008 return KErrNoSuitableCore; |
|
4009 } |
|
4010 |
|
4011 |
|
4012 // --------------------------------------------------------------------------- |
|
4013 // CPtiEngineImpl::MarkAutoCapitalized |
|
4014 // |
|
4015 // --------------------------------------------------------------------------- |
|
4016 // |
|
4017 void CPtiEngineImpl::MarkAutoCapitalized() |
|
4018 { |
|
4019 if (IsCore()) |
|
4020 { |
|
4021 TRAP_IGNORE(Core()->HandleCommandL(EPtiCommandMarkAutoCapitalized, NULL)); |
|
4022 } |
|
4023 } |
|
4024 |
|
4025 |
|
4026 // --------------------------------------------------------------------------- |
|
4027 // CPtiEngineImpl::AddPhrase |
|
4028 // |
|
4029 // --------------------------------------------------------------------------- |
|
4030 // |
|
4031 TInt CPtiEngineImpl::AddPhrase(const TDesC& aNewPhrase) |
|
4032 { |
|
4033 if (IsCore()) |
|
4034 { |
|
4035 TInt ret = KErrNone; |
|
4036 TInt err = KErrNone; |
|
4037 |
|
4038 TRAP(err, ret = Core()->HandleCommandL(EPtiCommandAddPhrase, (TAny*)(&aNewPhrase))); |
|
4039 |
|
4040 if (err != KErrNone) |
|
4041 { |
|
4042 return err; |
|
4043 } |
|
4044 |
|
4045 return ret; |
|
4046 } |
|
4047 |
|
4048 return KErrNoSuitableCore; |
|
4049 } |
|
4050 |
|
4051 |
|
4052 // --------------------------------------------------------------------------- |
|
4053 // LOCAL METHODS |
|
4054 // |
|
4055 // --------------------------------------------------------------------------- |
|
4056 // |
|
4057 const TInt KVietKeyMarker = 0xffff; |
|
4058 const TUint16 vietnameseAccents[] = |
|
4059 { |
|
4060 KVietKeyMarker, EPtiKey2, // For key 2, a-based |
|
4061 0x00c1, 0x00c0, 0x1ea2, 0x00c3, 0x1ea0, |
|
4062 0x00e1, 0x00e0, 0x1ea3, 0x00e3, 0x1ea1, |
|
4063 0x0102, 0x1eae, 0x1eb0, 0x1eb2, 0x1eb4, 0x1eb6, |
|
4064 0x0103, 0x1eaf, 0x1eb1, 0x1eb3, 0x1eb5, 0x1eb7, |
|
4065 0x00c2, 0x1ea4, 0x1ea6, 0x1ea8, 0x1eaa, 0x1eac, |
|
4066 0x00e2, 0x1ea5, 0x1ea7, 0x1ea9, 0x1eab, 0x1ead, |
|
4067 |
|
4068 KVietKeyMarker, EPtiKey3, // For key 3, e-based |
|
4069 0x00c9, 0x00c8, 0x1eba, 0x1ebc, 0x1eb8, |
|
4070 0x00e9, 0x00e8, 0x1ebb, 0x1ebd, 0x1eb9, |
|
4071 0x00ca, 0x1ebe, 0x1ec0, 0x1ec2, 0x1ec4, 0x1ec6, |
|
4072 0x00ea, 0x1ebf, 0x1ec1, 0x1ec3, 0x1ec5, 0x1ec7, |
|
4073 |
|
4074 KVietKeyMarker, EPtiKey4, // For key 4, i-based |
|
4075 0x00cd, 0x00cc, 0x1ec8, 0x0128, 0x1eca, |
|
4076 0x00ed, 0x00ec, 0x1ec9, 0x0129, 0x1ecb, |
|
4077 |
|
4078 KVietKeyMarker, EPtiKey6, // For key 6, o-based |
|
4079 0x00d3, 0x00d2, 0x1ece, 0x00d5, 0x1ecc, |
|
4080 0x00f3, 0x00f2, 0x1ecf, 0x00f5, 0x1ecd, |
|
4081 0x00d4, 0x1ed0, 0x1ed2, 0x1ed4, 0x1ed6, 0x1ed8, |
|
4082 0x00f4, 0x1ed1, 0x1ed3, 0x1ed5, 0x1ed7, 0x1ed9, |
|
4083 0x01a0, 0x1eda, 0x1edc, 0x1ede, 0x1ee0, 0x1ee2, |
|
4084 0x01a1, 0x1edb, 0x1edd, 0x1edf, 0x1ee1, 0x1ee3, |
|
4085 0 |
|
4086 }; |
|
4087 |
|
4088 |
|
4089 // --------------------------------------------------------------------------- |
|
4090 // RemapVietnameseAccentedCharacter |
|
4091 // |
|
4092 // --------------------------------------------------------------------------- |
|
4093 // |
|
4094 LOCAL_C TInt RemapVietnameseAccentedCharacter(TUint16 aChr) |
|
4095 { |
|
4096 // Check tone marks first. |
|
4097 switch (aChr) |
|
4098 { |
|
4099 case 0x0301: |
|
4100 return EPtiKey2; |
|
4101 case 0x0300: |
|
4102 return EPtiKey3; |
|
4103 case 0x0309: |
|
4104 return EPtiKey4; |
|
4105 case 0x0303: |
|
4106 return EPtiKey5; |
|
4107 case 0x0323: |
|
4108 return EPtiKey6; |
|
4109 default: |
|
4110 break; |
|
4111 } |
|
4112 |
|
4113 TInt ret = 0; |
|
4114 |
|
4115 for (const TUint16* ptr = vietnameseAccents; *ptr != 0; ptr++) |
|
4116 { |
|
4117 if (*ptr == KVietKeyMarker) |
|
4118 { |
|
4119 ret = ptr[1]; |
|
4120 ptr++; |
|
4121 } |
|
4122 else |
|
4123 { |
|
4124 if (*ptr == aChr) |
|
4125 { |
|
4126 break; |
|
4127 } |
|
4128 } |
|
4129 } |
|
4130 |
|
4131 return ret; |
|
4132 } |
|
4133 |
|
4134 #ifdef FF_DUAL_LANGUAGE_SUPPORT |
|
4135 // --------------------------------------------------------------------------- |
|
4136 // CPtiEngineImpl::SetSecondaryInputL |
|
4137 // |
|
4138 // --------------------------------------------------------------------------- |
|
4139 // |
|
4140 TInt CPtiEngineImpl::SetSecondaryInputL(TInt aEpocLanguageID) |
|
4141 { |
|
4142 TInt err = KErrNone; |
|
4143 |
|
4144 if(iCurrentLanguage == NULL) |
|
4145 { |
|
4146 return KErrNoActiveLanguage; |
|
4147 } |
|
4148 |
|
4149 if(aEpocLanguageID == 0) |
|
4150 { |
|
4151 // Delete language object |
|
4152 iSecondaryLanguage = NULL; |
|
4153 } |
|
4154 else if(!iSecondaryLanguage || iSecondaryLanguage->LanguageCode() != aEpocLanguageID) |
|
4155 { |
|
4156 CPtiCoreLanguage *lang = static_cast<CPtiCoreLanguage*>(GetLanguage( aEpocLanguageID )); |
|
4157 if (!lang) |
|
4158 { |
|
4159 // Delete language object |
|
4160 iSecondaryLanguage = NULL; |
|
4161 return KErrLanguageNotFound; |
|
4162 } |
|
4163 iSecondaryLanguage = lang; |
|
4164 } |
|
4165 |
|
4166 TPtiEngineInputMode inputMode = EPtiEngineInputModeNone; |
|
4167 TPtiKeyboardType kbdType = KeyboardType(); |
|
4168 switch (kbdType) |
|
4169 { |
|
4170 case EPtiKeyboard12Key: |
|
4171 inputMode = EPtiEnginePredictive; |
|
4172 break; |
|
4173 case EPtiKeyboardHalfQwerty: |
|
4174 inputMode = EPtiEngineHalfQwertyPredictive; |
|
4175 break; |
|
4176 case EPtiKeyboardQwerty4x10: |
|
4177 case EPtiKeyboardQwerty3x11: |
|
4178 case EPtiKeyboardQwerty4x12: |
|
4179 case EPtiKeyboardCustomQwerty: |
|
4180 inputMode = EPtiEngineQwertyPredictive; |
|
4181 break; |
|
4182 } |
|
4183 |
|
4184 MPtiCore* core = iCurrentLanguage->GetCore(inputMode); |
|
4185 if(core) |
|
4186 err = core->HandleCommandL(EPtiCommandSetSecondaryInputLanguage, static_cast<TAny*>(iSecondaryLanguage)); |
|
4187 else |
|
4188 err = KErrNoSuitableCore; |
|
4189 |
|
4190 return err; |
|
4191 |
|
4192 } |
|
4193 #endif //FF_DUAL_LANGUAGE_SUPPORT |
|
4194 // End of file |
|
4195 |