|
1 /* |
|
2 * Copyright (c) 2005 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: Data model for GSLangPlugin. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 |
|
20 #include "GSLangModel.h" |
|
21 #include "GSLangContainer.h" |
|
22 #include "GSLangPlugin.h" |
|
23 #include <GSLangPluginRsc.rsg> |
|
24 |
|
25 #include <AknFepInternalCRKeys.h> |
|
26 #include <aknnotedialog.h> |
|
27 #include <aknradiobuttonsettingpage.h> |
|
28 #include <aknViewAppUi.h> |
|
29 #include <avkon.rsg> |
|
30 #include <CommonEngineDomainCRKeys.h> //Ui language |
|
31 #include <e32math.h> |
|
32 #include <featmgr.h> |
|
33 #include <hal.h> |
|
34 #include <PtiEngine.h> |
|
35 #include <ScreensaverInternalCRKeys.h> //double declaration of KScreenSaverPluginName |
|
36 #include <settingsinternalcrkeys.h> |
|
37 #include <startupdomaincrkeys.h> |
|
38 #include <ctsydomainpskeys.h> |
|
39 #include <languages.hrh> |
|
40 |
|
41 #include <AknFepGlobalEnums.h> //For chinese input modes |
|
42 |
|
43 // For Phonetic Input of Hindi |
|
44 #include <PtiIndicDefs.h> |
|
45 #include <sysutil.h> |
|
46 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
47 #include <AvkonInternalCRKeys.h> |
|
48 #include <StringLoader.h> |
|
49 #include <coemain.h> |
|
50 #endif |
|
51 |
|
52 #include <aknenv.h> |
|
53 #include <AknSettingCache.h> |
|
54 |
|
55 |
|
56 //CONSTANTS |
|
57 const TInt KGSDiskSpaceLimitForLanguageChange = 300000; |
|
58 |
|
59 // ================= MEMBER FUNCTIONS ======================= |
|
60 |
|
61 // ---------------------------------------------------------------------------- |
|
62 // CGSLangModel::NewL |
|
63 // |
|
64 // EPOC two-phased constructor |
|
65 // ---------------------------------------------------------------------------- |
|
66 // |
|
67 CGSLangModel* CGSLangModel::NewL( CGSLangContainer* aContainer ) |
|
68 { |
|
69 CGSLangModel* self = new( ELeave ) CGSLangModel( aContainer ); |
|
70 CleanupStack::PushL( self ); |
|
71 self->ConstructL(); |
|
72 CleanupStack::Pop( self ); |
|
73 return self; |
|
74 } |
|
75 |
|
76 |
|
77 // ---------------------------------------------------------------------------- |
|
78 // CGSLangModel::CGSLangModel |
|
79 // |
|
80 // C++ default constructor can NOT contain any code, that |
|
81 // might leave. |
|
82 // ---------------------------------------------------------------------------- |
|
83 // |
|
84 CGSLangModel::CGSLangModel( CGSLangContainer* aContainer ) |
|
85 : iContainer( aContainer ) |
|
86 { |
|
87 |
|
88 } |
|
89 |
|
90 |
|
91 // ---------------------------------------------------------------------------- |
|
92 // CGSLangModel::ConstructL |
|
93 // |
|
94 // EPOC default constructor can leave. |
|
95 // ---------------------------------------------------------------------------- |
|
96 // |
|
97 void CGSLangModel::ConstructL() |
|
98 { |
|
99 InitializeCentralRepositoriesL(); |
|
100 |
|
101 // start listening to CenRep key changes for ITL |
|
102 iNotifyHandlerForITL = CCenRepNotifyHandler::NewL( *this, |
|
103 *iAknFepRepository, |
|
104 CCenRepNotifyHandler::EIntKey, |
|
105 KAknFepInputTxtLang ); |
|
106 iNotifyHandlerForITL->StartListeningL(); |
|
107 |
|
108 // start listening to CenRep key changes for T9 on/off |
|
109 iNotifyHandlerForT9 = CCenRepNotifyHandler::NewL( *this, |
|
110 *iAknFepRepository, |
|
111 CCenRepNotifyHandler::EIntKey, |
|
112 KAknFepPredTxtFlag ); |
|
113 iNotifyHandlerForT9->StartListeningL(); |
|
114 |
|
115 if ( FeatureManager::FeatureSupported( KFeatureIdJapanese ) ) |
|
116 { |
|
117 // start listening to CenRep key changes for Japanese predictive mode |
|
118 iNotifyHandlerForJapanesePredTxt = CCenRepNotifyHandler::NewL( *this, |
|
119 *iAknFepRepository, |
|
120 CCenRepNotifyHandler::EIntKey, |
|
121 KAknFepJapanesePredTxtFlag ); |
|
122 iNotifyHandlerForJapanesePredTxt->StartListeningL(); |
|
123 } |
|
124 |
|
125 |
|
126 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
127 // start listening to CenRep key changes for T9 on/off |
|
128 iNotifyHandlerForPredExt = CCenRepNotifyHandler::NewL( *this, |
|
129 *iAknFepRepository, |
|
130 CCenRepNotifyHandler::EIntKey, |
|
131 KAknFepPredTxtFlagExtension ); |
|
132 iNotifyHandlerForPredExt->StartListeningL(); |
|
133 #endif |
|
134 |
|
135 } |
|
136 |
|
137 |
|
138 // ---------------------------------------------------------------------------- |
|
139 // CGSLangModel::~CGSLangModel |
|
140 // |
|
141 // Destructor |
|
142 // ---------------------------------------------------------------------------- |
|
143 // |
|
144 CGSLangModel::~CGSLangModel() |
|
145 { |
|
146 if ( iNotifyHandlerForITL ) |
|
147 { |
|
148 iNotifyHandlerForITL->StopListening(); |
|
149 } |
|
150 delete iNotifyHandlerForITL; |
|
151 |
|
152 if ( iNotifyHandlerForT9 ) |
|
153 { |
|
154 iNotifyHandlerForT9->StopListening(); |
|
155 } |
|
156 delete iNotifyHandlerForT9; |
|
157 |
|
158 if ( iNotifyHandlerForJapanesePredTxt ) |
|
159 { |
|
160 iNotifyHandlerForJapanesePredTxt->StopListening(); |
|
161 } |
|
162 delete iNotifyHandlerForJapanesePredTxt; |
|
163 |
|
164 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
165 if ( iNotifyHandlerForPredExt ) |
|
166 { |
|
167 iNotifyHandlerForPredExt->StopListening(); |
|
168 } |
|
169 delete iNotifyHandlerForPredExt; |
|
170 #endif |
|
171 |
|
172 |
|
173 CloseCentralRepositories(); |
|
174 } |
|
175 |
|
176 |
|
177 // ---------------------------------------------------------------------------- |
|
178 // CGSLangModel::InitializeCentralRepositoriesL |
|
179 // |
|
180 // Creating and setting keys for the Central Repository |
|
181 // ---------------------------------------------------------------------------- |
|
182 // |
|
183 void CGSLangModel::InitializeCentralRepositoriesL() |
|
184 { |
|
185 |
|
186 iPersonalizationRepository = |
|
187 CRepository::NewL( KCRUidPersonalizationSettings ); |
|
188 iLocaleRepository = CRepository::NewL( KCRUidLocaleSettings ); |
|
189 iStartupConfRepository = CRepository::NewL( KCRUidStartupConf ); |
|
190 iAknFepRepository = CRepository::NewL( KCRUidAknFep ); |
|
191 iCommonEngineRepository = CRepository::NewL( KCRUidCommonEngineKeys ); |
|
192 iScreensaverRepository = CRepository::NewL( KCRUidScreenSaver ); |
|
193 |
|
194 } |
|
195 |
|
196 // ---------------------------------------------------------------------------- |
|
197 // CGSLangModel::CloseCentralRepositoriesL |
|
198 // |
|
199 // Creating and setting keys for the Central Repository |
|
200 // ---------------------------------------------------------------------------- |
|
201 // |
|
202 void CGSLangModel::CloseCentralRepositories() |
|
203 { |
|
204 if ( iPersonalizationRepository ) |
|
205 { |
|
206 delete iPersonalizationRepository; |
|
207 iPersonalizationRepository = NULL; |
|
208 } |
|
209 if ( iLocaleRepository ) |
|
210 { |
|
211 delete iLocaleRepository; |
|
212 iLocaleRepository = NULL; |
|
213 } |
|
214 if ( iStartupConfRepository ) |
|
215 { |
|
216 delete iStartupConfRepository; |
|
217 iStartupConfRepository = NULL; |
|
218 } |
|
219 if ( iAknFepRepository ) |
|
220 { |
|
221 delete iAknFepRepository; |
|
222 iAknFepRepository = NULL; |
|
223 } |
|
224 if ( iCommonEngineRepository ) |
|
225 { |
|
226 delete iCommonEngineRepository; |
|
227 iCommonEngineRepository = NULL; |
|
228 } |
|
229 if ( iScreensaverRepository ) |
|
230 { |
|
231 delete iScreensaverRepository; |
|
232 iScreensaverRepository = NULL; |
|
233 } |
|
234 } |
|
235 |
|
236 // ================= DATA ACCESS FUNCTIONS ================== |
|
237 |
|
238 // ---------------------------------------------------------------------------- |
|
239 // CGSLangModel::GetLanguagesFromPtiL |
|
240 // |
|
241 // Utility routine to get available languages with Symbian OS codes |
|
242 // ---------------------------------------------------------------------------- |
|
243 // |
|
244 void CGSLangModel::GetLanguagesFromPtiL( |
|
245 CArrayFix<TInt>* aInstalledLangCodes, |
|
246 CArrayFix<TInt>* aSeedLanguages, |
|
247 CDesCArray* aLanguageNames ) |
|
248 { |
|
249 CPtiEngine* ptiEngine = CPtiEngine::NewL(); |
|
250 CleanupStack::PushL( ptiEngine ); |
|
251 |
|
252 CArrayFix<TInt>* languageCodeArray = aSeedLanguages; |
|
253 if ( aInstalledLangCodes ) |
|
254 { |
|
255 languageCodeArray = aInstalledLangCodes; |
|
256 } |
|
257 else |
|
258 { |
|
259 ptiEngine->GetAvailableLanguagesL( languageCodeArray ); |
|
260 } |
|
261 |
|
262 HBufC* buffer = HBufC::NewLC( KGSBufSize128 ); |
|
263 const TInt count = languageCodeArray->Count(); |
|
264 for ( TInt index = 0; index < count; ++index ) |
|
265 { |
|
266 const TInt langId = languageCodeArray->At( index ); |
|
267 |
|
268 TPtr ptrToBuffer( buffer->Des() ); |
|
269 ptiEngine->GetLocalizedLanguageName( langId & KGSLanguageMask, |
|
270 ptrToBuffer ); |
|
271 |
|
272 if ( aInstalledLangCodes ) |
|
273 { |
|
274 aSeedLanguages->AppendL( langId ); |
|
275 } |
|
276 aLanguageNames->AppendL( ptrToBuffer ); |
|
277 |
|
278 ptrToBuffer.Zero(); |
|
279 } |
|
280 |
|
281 CleanupStack::PopAndDestroy( buffer ); |
|
282 CleanupStack::PopAndDestroy( ptiEngine ); |
|
283 } |
|
284 |
|
285 |
|
286 // ----------------------------------------------------------------------------- |
|
287 // CGSLangModel::LanguageL |
|
288 // |
|
289 // |
|
290 // ----------------------------------------------------------------------------- |
|
291 // |
|
292 TInt CGSLangModel::LanguageL( TLanguage aType ) |
|
293 { |
|
294 TInt Language = KErrNone; |
|
295 |
|
296 switch ( aType ) |
|
297 { |
|
298 case EGSUiLanguage: |
|
299 { |
|
300 User::LeaveIfError( |
|
301 iCommonEngineRepository->Get( KGSDisplayTxtLang, Language ) ); |
|
302 } |
|
303 break; |
|
304 case EGSInputLanguage: |
|
305 { |
|
306 User::LeaveIfError( |
|
307 iAknFepRepository->Get( KAknFepInputTxtLang, Language ) ); |
|
308 } |
|
309 break; |
|
310 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
311 #ifdef FF_DUAL_LANGUAGE_SUPPORT |
|
312 case EGSInputLanguageSecondary: |
|
313 { |
|
314 User::LeaveIfError( |
|
315 iAknFepRepository->Get( KAknFepInputTxtLangSecondary, Language ) ); |
|
316 } |
|
317 break; |
|
318 #endif |
|
319 #endif |
|
320 default: |
|
321 break; |
|
322 } |
|
323 |
|
324 return Language; |
|
325 } |
|
326 |
|
327 |
|
328 // ----------------------------------------------------------------------------- |
|
329 // CGSLangModel::SetLanguageL |
|
330 // |
|
331 // |
|
332 // ----------------------------------------------------------------------------- |
|
333 // |
|
334 TBool CGSLangModel::SetLanguageL( TLanguage aType, TInt aLanguage ) |
|
335 { |
|
336 TBool ret = ETrue; |
|
337 |
|
338 switch( aType ) |
|
339 { |
|
340 case EGSUiLanguage: |
|
341 { |
|
342 // Never set Language code 0 to HAL |
|
343 if ( aLanguage !=0 ) |
|
344 { |
|
345 if ( HAL::Set( HAL::ELanguageIndex, aLanguage ) != KErrNone ) |
|
346 { |
|
347 ret = EFalse; |
|
348 } |
|
349 } |
|
350 |
|
351 if ( iCommonEngineRepository-> |
|
352 Set( KGSDisplayTxtLang, aLanguage ) != KErrNone ) |
|
353 { |
|
354 ret = EFalse; |
|
355 } |
|
356 |
|
357 TBool NbrModeSaved = EFalse; |
|
358 if ( aLanguage == ELangArabic || User::Language() == ELangArabic ) |
|
359 { |
|
360 //numberMode = EGSNumberModeArabicIndic; |
|
361 SetDefaultNumberMode( EGSNbrModeArabic, |
|
362 EGSNbrModeTypeArabic ); |
|
363 NbrModeSaved = ETrue; |
|
364 } |
|
365 else if ( ( aLanguage == ELangUrdu || User::Language() == ELangUrdu ) || |
|
366 ( aLanguage == ELangFarsi || User::Language() == ELangFarsi ) ) |
|
367 { |
|
368 //numberMode = EGSNumberModeEasternArabicIndic; |
|
369 SetDefaultNumberMode( EGSNbrModeLatin, |
|
370 EGSNbrModeTypeEasternArabic ); |
|
371 NbrModeSaved = ETrue; |
|
372 } |
|
373 else if ( aLanguage == ELangHindi || User::Language() == ELangHindi || |
|
374 aLanguage == ELangMarathi || User::Language() == ELangMarathi ) |
|
375 { |
|
376 //numberMode = EGSNumberModeIndic; |
|
377 SetDefaultNumberMode( EGSNbrModeLatin, |
|
378 EGSNbrModeTypeIndic ); |
|
379 NbrModeSaved = ETrue; |
|
380 } |
|
381 |
|
382 //if number mode is not set above, then set it to Latin with respective |
|
383 //number mode types. This part might be executed when Automatic is |
|
384 //selected and the SIM card does not support the language. |
|
385 if ( !NbrModeSaved ) |
|
386 { |
|
387 TInt nbrModeType = EGSNbrModeTypeIndic; |
|
388 if ( aLanguage == ELangArabic || User::Language() == ELangArabic ) |
|
389 { |
|
390 nbrModeType = EGSNbrModeTypeArabic; |
|
391 } |
|
392 else if ( ( aLanguage == ELangUrdu || User::Language() == ELangUrdu ) |
|
393 || ( aLanguage == ELangFarsi || User::Language() == ELangFarsi ) ) |
|
394 { |
|
395 nbrModeType = EGSNbrModeTypeEasternArabic; |
|
396 } |
|
397 |
|
398 //EGSNumberModeLatin is true in both cases; |
|
399 SetDefaultNumberMode( EGSNbrModeLatin, |
|
400 nbrModeType ); |
|
401 } |
|
402 } |
|
403 break; |
|
404 case EGSInputLanguage: |
|
405 { |
|
406 if( iAknFepRepository->Set( KAknFepInputTxtLang, |
|
407 aLanguage ) != KErrNone ) |
|
408 { |
|
409 ret = EFalse; |
|
410 } |
|
411 |
|
412 if(ret) |
|
413 { |
|
414 //inform all other apps about language change. |
|
415 TWsEvent event; |
|
416 event.SetType( KEikInputLanguageChange ); |
|
417 CEikonEnv::Static()->WsSession().SendEventToAllWindowGroups(event); |
|
418 CAknEnv::Static()->SettingCache().Update(KEikInputLanguageChange); |
|
419 } |
|
420 |
|
421 // See if it cannot do predictive text entry |
|
422 TBool checkEngine = EFalse; |
|
423 |
|
424 |
|
425 if (!( aLanguage == ELangPrcChinese || |
|
426 aLanguage == ELangHongKongChinese || |
|
427 aLanguage == ELangTaiwanChinese ) |
|
428 ) |
|
429 { |
|
430 if ( FeatureManager::FeatureSupported( KFeatureIdChinese ) ) |
|
431 { |
|
432 aLanguage = ELangEnglish; |
|
433 checkEngine = ETrue; |
|
434 } |
|
435 if (!CheckDictionaryFromPtiL( aLanguage, checkEngine)) |
|
436 { |
|
437 CAknNoteDialog* dlg = new (ELeave) CAknNoteDialog( ); |
|
438 dlg->ExecuteDlgLD( |
|
439 CAknNoteDialog::EShortTimeout, |
|
440 CAknNoteDialog::ENoTone, |
|
441 R_AVKON_T9_NOTE_NO_AVAILABLE ); |
|
442 |
|
443 //SetT9OnOffMode(0); |
|
444 SetPredictiveOnOff( EGSLangOther, 0 ); |
|
445 } |
|
446 } |
|
447 } |
|
448 break; |
|
449 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
450 #ifdef FF_DUAL_LANGUAGE_SUPPORT |
|
451 case EGSInputLanguageSecondary: |
|
452 { |
|
453 if( iAknFepRepository->Set( KAknFepInputTxtLangSecondary, |
|
454 aLanguage ) != KErrNone ) |
|
455 { |
|
456 ret = EFalse; |
|
457 } |
|
458 |
|
459 if(ret) |
|
460 { |
|
461 //inform all other apps about language change. |
|
462 TWsEvent event; |
|
463 event.SetType( KEikInputLanguageChange ); |
|
464 CEikonEnv::Static()->WsSession().SendEventToAllWindowGroups(event); |
|
465 CAknEnv::Static()->SettingCache().Update(KEikInputLanguageChange); |
|
466 } |
|
467 |
|
468 // Secondary input language does not need prediction |
|
469 // so we don't check for it |
|
470 } |
|
471 break; |
|
472 #endif |
|
473 #endif |
|
474 default: |
|
475 break; |
|
476 } |
|
477 |
|
478 return ret; |
|
479 } |
|
480 |
|
481 |
|
482 // ----------------------------------------------------------------------------- |
|
483 // CGSLangModel::DefaultNumberMode |
|
484 // |
|
485 // |
|
486 // ----------------------------------------------------------------------------- |
|
487 // |
|
488 TInt CGSLangModel::DefaultNumberMode( TInt aNbrModeType ) |
|
489 { |
|
490 TInt value = KGSSettingOff; |
|
491 |
|
492 switch ( aNbrModeType ) |
|
493 { |
|
494 case EGSNbrModeTypeArabic: |
|
495 case EGSNbrModeTypeEasternArabic: |
|
496 iLocaleRepository->Get( KSettingsDefaultNumberMode, value ); |
|
497 break; |
|
498 case EGSNbrModeTypeIndic: |
|
499 iLocaleRepository->Get( KSettingsIndicDefaultNumberMode, value ); |
|
500 break; |
|
501 default: |
|
502 break; |
|
503 } |
|
504 |
|
505 return value; |
|
506 } |
|
507 |
|
508 |
|
509 // ----------------------------------------------------------------------------- |
|
510 // CGSLangModel::SetDefaultNumberMode |
|
511 // |
|
512 // Set default number mode for non-latin languagues |
|
513 // ----------------------------------------------------------------------------- |
|
514 // |
|
515 void CGSLangModel::SetDefaultNumberMode( TInt aMode, TInt aNbrModeType ) |
|
516 { |
|
517 if ( aNbrModeType == EGSNbrModeTypeArabic || |
|
518 aNbrModeType == EGSNbrModeTypeEasternArabic ) |
|
519 { |
|
520 iLocaleRepository->Set( KSettingsDefaultNumberMode, aMode ); |
|
521 } |
|
522 else |
|
523 { |
|
524 iLocaleRepository->Set( KSettingsIndicDefaultNumberMode, aMode ); |
|
525 } |
|
526 |
|
527 TLocale locale; |
|
528 if ( aMode == EGSNbrModeLatin ) |
|
529 { |
|
530 locale.SetDigitType( EDigitTypeWestern ); |
|
531 } |
|
532 else |
|
533 { |
|
534 //if aMode <> EGSNbrModeLatin, then it should be either latin or arabic. However |
|
535 //as EGSNbrModeArabic and EGsNbrModeIndic both have a value = 1, we can't use |
|
536 //that constant for below comparison. Hence, need to depend on the 2nd param. |
|
537 switch ( aNbrModeType ) |
|
538 { |
|
539 case EGSNbrModeTypeArabic: |
|
540 locale.SetDigitType( EDigitTypeArabicIndic ); |
|
541 break; |
|
542 case EGSNbrModeTypeIndic: |
|
543 locale.SetDigitType( EDigitTypeDevanagari ); |
|
544 break; |
|
545 case EGSNbrModeTypeEasternArabic: |
|
546 locale.SetDigitType( EDigitTypeEasternArabicIndic ); |
|
547 break; |
|
548 default: |
|
549 break; |
|
550 } |
|
551 } |
|
552 |
|
553 locale.Set(); |
|
554 } |
|
555 |
|
556 |
|
557 // ----------------------------------------------------------------------------- |
|
558 // CGSLangModel::PredictiveOnOff |
|
559 // |
|
560 // |
|
561 // ----------------------------------------------------------------------------- |
|
562 // |
|
563 TInt CGSLangModel::PredictiveOnOff( TPredictiveType aPredictive ) |
|
564 { |
|
565 TInt onOffMode = KGSPredTxtFlagDefault; |
|
566 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
567 TInt onOffBitMask = KGSPredTxtBitMaskDefault; |
|
568 #endif |
|
569 |
|
570 switch( aPredictive ) |
|
571 { |
|
572 case EGSLangJapanese: |
|
573 { |
|
574 if( iAknFepRepository->Get( KAknFepJapanesePredTxtFlag, |
|
575 onOffMode ) != KErrNone ) |
|
576 { |
|
577 iAknFepRepository->Set( KAknFepJapanesePredTxtFlag, |
|
578 onOffMode ); |
|
579 } |
|
580 } |
|
581 break; |
|
582 case EGSLangOther: |
|
583 { |
|
584 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
585 if ( iAknFepRepository->Get( KAknFepPredTxtFlagExtension, |
|
586 onOffBitMask ) != KErrNone ) |
|
587 { |
|
588 iAknFepRepository->Set( KAknFepPredTxtFlagExtension, onOffBitMask ); |
|
589 } |
|
590 |
|
591 // Parse keyboard dependent settings for current keyboard from bitmask |
|
592 // We'll only use this function to get prediction value if we have one |
|
593 // keyboard on the device, so we can just check the current keyb. layout |
|
594 TInt keyboardLayout = 0; |
|
595 RProperty::Get(KCRUidAvkon, KAknKeyBoardLayout, keyboardLayout); |
|
596 TPtiKeyboardType layout = (TPtiKeyboardType)keyboardLayout; |
|
597 TInt predTmp = onOffBitMask; |
|
598 switch(layout) |
|
599 { |
|
600 case EPtiKeyboardNone: |
|
601 break; |
|
602 case EPtiKeyboard12Key: |
|
603 predTmp &= EKeyboardStyle12Key; |
|
604 break; |
|
605 case EPtiKeyboardHalfQwerty: |
|
606 predTmp &= EKeyboardStyleHalfQwerty; |
|
607 break; |
|
608 case EPtiKeyboardQwerty4x12: |
|
609 case EPtiKeyboardQwerty4x10: |
|
610 case EPtiKeyboardQwerty3x11: |
|
611 case EPtiKeyboardCustomQwerty: |
|
612 predTmp &= EKeyboardStyleQwerty; |
|
613 break; |
|
614 default: |
|
615 break; |
|
616 } |
|
617 onOffMode = ( predTmp ? 1 : 0); |
|
618 |
|
619 #else |
|
620 if ( iAknFepRepository->Get( KAknFepPredTxtFlag, |
|
621 onOffMode ) != KErrNone ) |
|
622 { |
|
623 iAknFepRepository->Set( KAknFepPredTxtFlag, onOffMode ); |
|
624 } |
|
625 #endif |
|
626 } |
|
627 break; |
|
628 default: |
|
629 break; |
|
630 } |
|
631 |
|
632 return onOffMode; |
|
633 } |
|
634 |
|
635 |
|
636 // ----------------------------------------------------------------------------- |
|
637 // CGSLangModel::SetPredictiveOnOff |
|
638 // |
|
639 // |
|
640 // ----------------------------------------------------------------------------- |
|
641 // |
|
642 TBool CGSLangModel::SetPredictiveOnOff( TPredictiveType aPredictive, |
|
643 TInt aMode ) |
|
644 { |
|
645 TBool ret = EFalse; |
|
646 switch( aPredictive ) |
|
647 { |
|
648 case EGSLangJapanese: |
|
649 { |
|
650 if ( iAknFepRepository->Set( KAknFepJapanesePredTxtFlag, |
|
651 aMode ) != KErrNone ) |
|
652 { |
|
653 ret = ETrue; |
|
654 } |
|
655 } |
|
656 break; |
|
657 case EGSLangOther: |
|
658 { |
|
659 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
660 TInt predFlag = 0; |
|
661 iAknFepRepository->Get(KAknFepPredTxtFlagExtension, predFlag); |
|
662 |
|
663 // Parse keyboard dependent settings for current keyboard from bitmask |
|
664 // We'll only use this function to set prediction value if we have one |
|
665 // keyboard on the device, so we can just check the current keyb. layout |
|
666 TInt keyboardLayout = 0; |
|
667 RProperty::Get(KCRUidAvkon, KAknKeyBoardLayout, keyboardLayout); |
|
668 TPtiKeyboardType layout = (TPtiKeyboardType)keyboardLayout; |
|
669 switch(layout) |
|
670 { |
|
671 case EPtiKeyboardNone: |
|
672 break; |
|
673 case EPtiKeyboard12Key: |
|
674 if ( aMode ) |
|
675 { |
|
676 predFlag |= EKeyboardStyle12Key; |
|
677 } |
|
678 else |
|
679 { |
|
680 predFlag &= ~EKeyboardStyle12Key; |
|
681 } |
|
682 break; |
|
683 case EPtiKeyboardHalfQwerty: |
|
684 if ( aMode ) |
|
685 { |
|
686 predFlag |= EKeyboardStyleHalfQwerty; |
|
687 } |
|
688 else |
|
689 { |
|
690 predFlag &= ~EKeyboardStyleHalfQwerty; |
|
691 } |
|
692 break; |
|
693 |
|
694 case EPtiKeyboardQwerty4x12: |
|
695 case EPtiKeyboardQwerty4x10: |
|
696 case EPtiKeyboardQwerty3x11: |
|
697 |
|
698 case EPtiKeyboardCustomQwerty: |
|
699 if (aMode) |
|
700 { |
|
701 predFlag |= EKeyboardStyleQwerty; |
|
702 } |
|
703 else |
|
704 { |
|
705 predFlag &= ~EKeyboardStyleQwerty; |
|
706 } |
|
707 break; |
|
708 default: |
|
709 break; |
|
710 } |
|
711 iAknFepRepository->Set(KAknFepPredTxtFlagExtension, predFlag); |
|
712 iAknFepRepository->Set(KAknFepPredTxtFlag, aMode); // For backwards compatibility |
|
713 } |
|
714 #else |
|
715 if( iAknFepRepository->Set( KAknFepPredTxtFlag, |
|
716 aMode ) != KErrNone ) |
|
717 { |
|
718 ret = ETrue; |
|
719 } |
|
720 } |
|
721 #endif |
|
722 break; |
|
723 default: |
|
724 break; |
|
725 } |
|
726 |
|
727 return ret; |
|
728 } |
|
729 |
|
730 |
|
731 // ---------------------------------------------------------------------------- |
|
732 // CGSLangModel::CheckDictionaryFromPtiL |
|
733 // |
|
734 // Checks if the selected language supports predictive text input. |
|
735 // In case this returns EFalse, the UI display's "Not available" |
|
736 // for Predictive text input. |
|
737 // ---------------------------------------------------------------------------- |
|
738 // |
|
739 TBool CGSLangModel::CheckDictionaryFromPtiL( TInt aLangCode, TBool aCheckEngine) |
|
740 { |
|
741 TBool langSupport = EFalse; |
|
742 |
|
743 if (!aCheckEngine && (FeatureManager::FeatureSupported( KFeatureIdChinese ) || |
|
744 FeatureManager::FeatureSupported( KFeatureIdJapanese ) )) |
|
745 { |
|
746 langSupport = ETrue; |
|
747 } |
|
748 else |
|
749 { |
|
750 CPtiEngine* ptiEngine = CPtiEngine::NewL(); |
|
751 CleanupStack::PushL( ptiEngine ); |
|
752 |
|
753 MPtiLanguage* ptiLang = ptiEngine->GetLanguage( aLangCode & KGSLanguageMask ); |
|
754 if ( ptiLang ) |
|
755 { |
|
756 // the check here should be based on the keyboard |
|
757 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
758 TInt keyboardLayout = 0; |
|
759 RProperty::Get(KCRUidAvkon, KAknKeyBoardLayout, keyboardLayout); |
|
760 TPtiKeyboardType layout = (TPtiKeyboardType)keyboardLayout; |
|
761 switch(layout) |
|
762 { |
|
763 case EPtiKeyboardHalfQwerty: |
|
764 langSupport = ptiLang->HasInputMode( (TPtiEngineInputMode)EPtiEngineHalfQwertyPredictive); |
|
765 break; |
|
766 case EPtiKeyboardQwerty4x12: |
|
767 case EPtiKeyboardQwerty4x10: |
|
768 case EPtiKeyboardQwerty3x11: |
|
769 case EPtiKeyboardCustomQwerty: |
|
770 langSupport = ptiLang->HasInputMode( (TPtiEngineInputMode)EPtiEngineQwertyPredictive); |
|
771 break; |
|
772 case EPtiKeyboardNone: |
|
773 case EPtiKeyboard12Key: |
|
774 langSupport = ptiLang->HasInputMode( (TPtiEngineInputMode)EPtiEnginePredictive); |
|
775 break; |
|
776 default: |
|
777 langSupport = ptiLang->HasInputMode( (TPtiEngineInputMode)EPtiEnginePredictive); |
|
778 break; |
|
779 } |
|
780 #else |
|
781 langSupport = ptiLang->HasInputMode( (TPtiEngineInputMode)EPtiEnginePredictive); |
|
782 #endif |
|
783 } |
|
784 CleanupStack::PopAndDestroy( ptiEngine ); |
|
785 ptiLang = NULL; |
|
786 } |
|
787 |
|
788 return langSupport; |
|
789 } |
|
790 |
|
791 // ---------------------------------------------------------------------------- |
|
792 // CGSLangModel::CheckT9FromPtiLForPrediction |
|
793 // |
|
794 // Checks if the selected language supports predictive text input. |
|
795 // In case this returns EFalse, the UI display's "Predictive text Not available |
|
796 // for selected language" for Predictive text input. |
|
797 // ---------------------------------------------------------------------------- |
|
798 // |
|
799 |
|
800 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
801 TBool CGSLangModel::CheckT9FromPtiLForPredictionL(TPtiEngineInputMode inputMode, TInt aLangCode) |
|
802 { |
|
803 TBool langSupport=EFalse; |
|
804 |
|
805 CPtiEngine* ptiEngine = CPtiEngine::NewL(); |
|
806 CleanupStack::PushL( ptiEngine ); |
|
807 |
|
808 MPtiLanguage* ptiLang = NULL; |
|
809 if(0 == aLangCode) |
|
810 iAknFepRepository->Get( KAknFepInputTxtLang, aLangCode ); |
|
811 if ( aLangCode == ELangPrcChinese || |
|
812 aLangCode == ELangHongKongChinese || |
|
813 aLangCode == ELangTaiwanChinese ) |
|
814 { |
|
815 aLangCode = ELangEnglish; |
|
816 } |
|
817 |
|
818 ptiLang = ptiEngine->GetLanguage( aLangCode ); |
|
819 if ( ptiLang ) |
|
820 { |
|
821 langSupport = ptiLang->HasInputMode( inputMode ); |
|
822 } |
|
823 |
|
824 CleanupStack::PopAndDestroy( ptiEngine ); |
|
825 ptiLang = NULL; |
|
826 |
|
827 return langSupport; |
|
828 } |
|
829 #endif |
|
830 |
|
831 |
|
832 // ----------------------------------------------------------------------------- |
|
833 // CGSLangModel::DefaultInputMethodL |
|
834 // |
|
835 // |
|
836 // ----------------------------------------------------------------------------- |
|
837 // |
|
838 TInt CGSLangModel::DefaultInputMethodL() |
|
839 { |
|
840 if ( FeatureManager::FeatureSupported( KFeatureIdChinese ) ) |
|
841 { |
|
842 // fetch the setting value from shared data etc. |
|
843 // return the value |
|
844 TInt MethodItem; |
|
845 User::LeaveIfError( iAknFepRepository-> |
|
846 Get( KAknFepChineseInputMode, MethodItem ) ); |
|
847 return MethodItem; |
|
848 } |
|
849 else |
|
850 { |
|
851 return KErrNotSupported; |
|
852 } |
|
853 } |
|
854 |
|
855 |
|
856 // ----------------------------------------------------------------------------- |
|
857 // CGSLangModel::SetDefaultInputMethodL |
|
858 // |
|
859 // |
|
860 // ----------------------------------------------------------------------------- |
|
861 // |
|
862 void CGSLangModel::SetDefaultInputMethodL( TInt aMethod ) |
|
863 { |
|
864 if ( FeatureManager::FeatureSupported( KFeatureIdChinese ) ) |
|
865 { |
|
866 User::LeaveIfError( |
|
867 iAknFepRepository->Set( KAknFepChineseInputMode, aMethod ) ); |
|
868 |
|
869 // See if it cannot do predictive text entry |
|
870 if( !CheckDictionaryFromPtiL( aMethod ) ) |
|
871 { |
|
872 SetPredictiveOnOff( EGSLangOther, 0 ); |
|
873 } |
|
874 } |
|
875 } |
|
876 |
|
877 |
|
878 // ----------------------------------------------------------------------------- |
|
879 // CGSLangModel::ChangePredictiveOnOffSettingL |
|
880 // |
|
881 // |
|
882 // ----------------------------------------------------------------------------- |
|
883 // |
|
884 void CGSLangModel::ChangePredictiveOnOffSettingL( TBool aShowOnOffSettingPage, |
|
885 TPredictiveType aPredictive ) |
|
886 { |
|
887 TInt currentValue = PredictiveOnOff( aPredictive ); |
|
888 TBool updateValue = ETrue; |
|
889 |
|
890 // Following code potentially changes the value of currrent value |
|
891 if ( aShowOnOffSettingPage ) |
|
892 { |
|
893 updateValue = ShowPredictiveOnOffSettingPageL( currentValue ); |
|
894 } |
|
895 else |
|
896 { |
|
897 currentValue = !PredictiveOnOff( aPredictive ); |
|
898 } |
|
899 |
|
900 if ( updateValue ) |
|
901 { |
|
902 // Treat on and off separately for clarity |
|
903 if ( currentValue ) |
|
904 { |
|
905 // See if it can do predictive text entry |
|
906 if( CheckDictionaryFromPtiL( LanguageL( EGSInputLanguage ) ) ) |
|
907 { |
|
908 SetPredictiveOnOff( aPredictive, currentValue ); |
|
909 } |
|
910 else |
|
911 { |
|
912 CAknNoteDialog* dlg = new (ELeave) CAknNoteDialog( ); |
|
913 dlg->ExecuteDlgLD( |
|
914 CAknNoteDialog::EShortTimeout, |
|
915 CAknNoteDialog::ENoTone, |
|
916 R_AVKON_T9_NOTE_NO_AVAILABLE ); |
|
917 } |
|
918 } |
|
919 else |
|
920 { |
|
921 // We are always able to turn T9 off: |
|
922 SetPredictiveOnOff( aPredictive, currentValue ); |
|
923 } |
|
924 // value should really be being updated, so update listbox |
|
925 if ( FeatureManager::FeatureSupported( KFeatureIdJapanese ) ) |
|
926 { |
|
927 // Update English Predictive list item |
|
928 if ( aPredictive == CGSLangModel::EGSLangJapanese ) |
|
929 { |
|
930 iContainer->UpdateListBoxL( EGSLangIdJPT ); |
|
931 } |
|
932 else |
|
933 { |
|
934 iContainer->UpdateListBoxL( EGSLangIdEPT ); |
|
935 } |
|
936 } |
|
937 else |
|
938 { |
|
939 //EGSLangIdT9L |
|
940 iContainer->UpdateListBoxL( iContainer->CurrentFeatureId() ); |
|
941 } |
|
942 } |
|
943 } |
|
944 |
|
945 |
|
946 // ----------------------------------------------------------------------------- |
|
947 // CGSLangModel::ShowPredictiveOnOffSettingPageL |
|
948 // |
|
949 // |
|
950 // ----------------------------------------------------------------------------- |
|
951 // |
|
952 TBool CGSLangModel::ShowPredictiveOnOffSettingPageL( TInt& aOnOffcurrent ) |
|
953 { |
|
954 // Default is to act as if the user cancelled the setting page |
|
955 TBool ret = EFalse; |
|
956 |
|
957 if ( CheckDictionaryFromPtiL( LanguageL( EGSInputLanguage ) ) ) |
|
958 { |
|
959 CDesCArrayFlat* items = |
|
960 CCoeEnv::Static()->ReadDesC16ArrayResourceL( |
|
961 R_T9_ON_OFF_SETTING_PAGE_LBX ); |
|
962 |
|
963 CleanupStack::PushL( items ); |
|
964 |
|
965 TInt dispOnOff = !aOnOffcurrent; |
|
966 |
|
967 CAknRadioButtonSettingPage* dlg = |
|
968 new ( ELeave ) CAknRadioButtonSettingPage( |
|
969 R_T9_ON_OFF_SETTING_PAGE, dispOnOff, items ); |
|
970 ret = dlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged ); |
|
971 if ( ret ) |
|
972 { |
|
973 aOnOffcurrent = !dispOnOff; |
|
974 } |
|
975 CleanupStack::PopAndDestroy( items ); |
|
976 } |
|
977 else |
|
978 { |
|
979 CAknNoteDialog* dlg = new( ELeave ) CAknNoteDialog(); |
|
980 dlg->ExecuteDlgLD( CAknNoteDialog::EShortTimeout, |
|
981 CAknNoteDialog::ENoTone, |
|
982 R_AVKON_T9_NOTE_NO_AVAILABLE ); |
|
983 } |
|
984 return ret; |
|
985 } |
|
986 |
|
987 |
|
988 // ----------------------------------------------------------------------------- |
|
989 // CGSLangModel::CheckCallStateL |
|
990 // |
|
991 // |
|
992 // ----------------------------------------------------------------------------- |
|
993 // |
|
994 TInt CGSLangModel::CheckCallStateL() |
|
995 { |
|
996 TInt callState = KErrNone; |
|
997 |
|
998 //here are open connections or not |
|
999 RProperty::Get( KPSUidCtsyCallInformation, |
|
1000 KCTsyCallState, |
|
1001 callState ); |
|
1002 return callState; |
|
1003 } |
|
1004 |
|
1005 |
|
1006 // ----------------------------------------------------------------------------- |
|
1007 // CGSLangModel::HandleNotifyInt |
|
1008 // |
|
1009 // |
|
1010 // ----------------------------------------------------------------------------- |
|
1011 // |
|
1012 void CGSLangModel::HandleNotifyInt( TUint32 aId, TInt /*aNewValue*/ ) |
|
1013 { |
|
1014 TRAP_IGNORE( HandleCenrepValueChangedL( aId ) ); |
|
1015 } |
|
1016 |
|
1017 |
|
1018 // ----------------------------------------------------------------------------- |
|
1019 // CGSLangModel::HandleCenrepValueChangedL |
|
1020 // |
|
1021 // |
|
1022 // ----------------------------------------------------------------------------- |
|
1023 // |
|
1024 void CGSLangModel::HandleCenrepValueChangedL( TUint32 aId ) |
|
1025 { |
|
1026 if ( aId == KAknFepInputTxtLang ) |
|
1027 { |
|
1028 iContainer->UpdateListBoxL( EGSLangIdITL ); |
|
1029 iContainer->UpdateListBoxL( EGSLangIdT9L ); |
|
1030 |
|
1031 TInt inputLanguage; |
|
1032 iAknFepRepository->Get( KAknFepInputTxtLang, inputLanguage ); |
|
1033 //Updating default input method based on input text language |
|
1034 //Chinese specific feature |
|
1035 TBool listboxUpdateReqd(EFalse); |
|
1036 if ( inputLanguage == ELangPrcChinese ) |
|
1037 { |
|
1038 SetDefaultInputMethodL( EPinyin ); |
|
1039 listboxUpdateReqd = ETrue; |
|
1040 } |
|
1041 else if ( inputLanguage == ELangHongKongChinese ) |
|
1042 { |
|
1043 SetDefaultInputMethodL( EStroke ); |
|
1044 listboxUpdateReqd = ETrue; |
|
1045 } |
|
1046 else if ( inputLanguage == ELangTaiwanChinese ) |
|
1047 { |
|
1048 SetDefaultInputMethodL( EZhuyin ); |
|
1049 listboxUpdateReqd = ETrue; |
|
1050 } |
|
1051 if (listboxUpdateReqd) |
|
1052 { |
|
1053 iContainer->UpdateListBoxL( EGSLangIdDIM ); |
|
1054 } |
|
1055 #ifdef RD_HINDI_PHONETIC_INPUT |
|
1056 //check if this is Hindi Phonetic - hide T9 item if it is. |
|
1057 if( inputLanguage == KLangHindiPhonetic ) |
|
1058 { |
|
1059 iContainer->SetT9ItemVisibilityL( EFalse ); |
|
1060 } |
|
1061 else |
|
1062 { |
|
1063 iContainer->SetT9ItemVisibilityL( ETrue ); |
|
1064 } |
|
1065 #endif //RD_HINDI_PHONETIC_INPUT |
|
1066 } |
|
1067 else if ( aId == KAknFepPredTxtFlag |
|
1068 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
1069 || aId == KAknFepPredTxtFlagExtension |
|
1070 #endif |
|
1071 ) |
|
1072 { |
|
1073 iContainer->UpdateListBoxL( EGSLangIdT9L ); |
|
1074 iContainer->UpdateListBoxL( EGSLangIdEPT ); |
|
1075 } |
|
1076 |
|
1077 else if ( aId == KAknFepJapanesePredTxtFlag) |
|
1078 { |
|
1079 iContainer->UpdateListBoxL( EGSLangIdJPT); |
|
1080 } |
|
1081 |
|
1082 else if ( aId == KSettingsIndicDefaultNumberMode ) |
|
1083 { |
|
1084 iContainer->UpdateListBoxL( EGSLangHindiNumberMode ); |
|
1085 } |
|
1086 } |
|
1087 |
|
1088 |
|
1089 // ---------------------------------------------------------------------------- |
|
1090 // CGSLangModel::KeypressTimeout |
|
1091 // |
|
1092 // Get Keypress timeout (means Multitap timer). |
|
1093 // ---------------------------------------------------------------------------- |
|
1094 // |
|
1095 TInt CGSLangModel::KeypressTimeout() |
|
1096 { |
|
1097 TInt msec; |
|
1098 if ( iAknFepRepository->Get( KAknFepMultiTapTimer, msec ) != KErrNone ) |
|
1099 { |
|
1100 msec = KGSMultiTapTimerDefault; |
|
1101 iAknFepRepository->Set( KAknFepMultiTapTimer, msec ); |
|
1102 } |
|
1103 |
|
1104 return msec; |
|
1105 } |
|
1106 |
|
1107 // ---------------------------------------------------------------------------- |
|
1108 // CGSLangModel::SetKeypressTimeout |
|
1109 // |
|
1110 // Writes Keypress timeout (means Multitap timer). |
|
1111 // ---------------------------------------------------------------------------- |
|
1112 // |
|
1113 TBool CGSLangModel::SetKeypressTimeout( TInt aMilliSecond ) |
|
1114 { |
|
1115 TBool ret = EFalse; |
|
1116 if ( iAknFepRepository->Set( KAknFepMultiTapTimer, aMilliSecond ) |
|
1117 == KErrNone ) |
|
1118 { |
|
1119 ret = ETrue; |
|
1120 } |
|
1121 |
|
1122 return ret; |
|
1123 } |
|
1124 |
|
1125 // ---------------------------------------------------------------------------- |
|
1126 // CGSLangModel::JapanQwertyFlags |
|
1127 // |
|
1128 // Get setting value of each apanese qwerty specific flags |
|
1129 // ---------------------------------------------------------------------------- |
|
1130 // |
|
1131 TBool CGSLangModel::JapanQwertyFlags( const TGSJapQwertyFlags aFlag ) |
|
1132 { |
|
1133 TInt value; |
|
1134 if ( iAknFepRepository->Get( KAknFepJapaneseSpecialCharFlag, value ) |
|
1135 != KErrNone ) |
|
1136 { |
|
1137 value = KGSJapaneseSpecialCharFlagDefault; |
|
1138 iAknFepRepository->Set( KAknFepJapaneseSpecialCharFlag, value ); |
|
1139 } |
|
1140 |
|
1141 return ( value&aFlag ); |
|
1142 } |
|
1143 |
|
1144 // ---------------------------------------------------------------------------- |
|
1145 // CGSLangModel::SetJapanQwertyFlags |
|
1146 // |
|
1147 // Set value of each Japanese qwerty specific flags |
|
1148 // ---------------------------------------------------------------------------- |
|
1149 // |
|
1150 TBool CGSLangModel::SetJapanQwertyFlags( const TGSJapQwertyFlags aFlag, |
|
1151 TBool aValue ) |
|
1152 { |
|
1153 TBool ret = EFalse; |
|
1154 TInt value; |
|
1155 if ( iAknFepRepository->Get( KAknFepJapaneseSpecialCharFlag, value ) |
|
1156 == KErrNone ) |
|
1157 { |
|
1158 if ( aValue ) |
|
1159 { |
|
1160 value |= aFlag; |
|
1161 } |
|
1162 else |
|
1163 { |
|
1164 value &= ~( aFlag ); |
|
1165 } |
|
1166 if ( iAknFepRepository->Set( KAknFepJapaneseSpecialCharFlag, value ) |
|
1167 == KErrNone ) |
|
1168 { |
|
1169 ret = ETrue; |
|
1170 } |
|
1171 } |
|
1172 |
|
1173 return ret; |
|
1174 } |
|
1175 |
|
1176 |
|
1177 // ---------------------------------------------------------------------------- |
|
1178 // CGSLangModel::ChiCangJieInput |
|
1179 // |
|
1180 // Get Chinese CangJie input method value |
|
1181 // ---------------------------------------------------------------------------- |
|
1182 // |
|
1183 TInt CGSLangModel::ChiCangJieInputL() |
|
1184 { |
|
1185 TInt value; |
|
1186 User::LeaveIfError( iAknFepRepository-> |
|
1187 Get( KAknFepCangJieMode, value ) ); |
|
1188 |
|
1189 return value; |
|
1190 } |
|
1191 |
|
1192 // ---------------------------------------------------------------------------- |
|
1193 // CGSLangModel::SetChiCangJieInput |
|
1194 // |
|
1195 // Set Chinese CangJie input method value |
|
1196 // ---------------------------------------------------------------------------- |
|
1197 // |
|
1198 void CGSLangModel::SetChiCangJieInputL( TInt aMode ) |
|
1199 { |
|
1200 User::LeaveIfError( |
|
1201 iAknFepRepository->Set( KAknFepCangJieMode, aMode ) ); |
|
1202 } |
|
1203 |
|
1204 |
|
1205 // ---------------------------------------------------------------------------- |
|
1206 // CGSLangModel::CheckCangjieSupportL |
|
1207 // |
|
1208 // Check if the Cangjie is supported by the language |
|
1209 // @param aLangCode i.e. Code for the language |
|
1210 // ---------------------------------------------------------------------------- |
|
1211 // |
|
1212 TBool CGSLangModel:: CheckCangjieSupportL( TInt aLangCode ) |
|
1213 { |
|
1214 TBool langSupport=EFalse; |
|
1215 CPtiEngine* ptiEngine = CPtiEngine::NewL(); |
|
1216 CleanupStack::PushL( ptiEngine ); |
|
1217 |
|
1218 MPtiLanguage* ptiLang = NULL; |
|
1219 //Check if HK variant support CangJie input mode |
|
1220 TPtiEngineInputMode inputMode = EPtiEngineNormalCangjieQwerty; |
|
1221 |
|
1222 //Chinese languages do not need a mask. |
|
1223 ptiLang = ptiEngine->GetLanguage( aLangCode ); |
|
1224 if ( ptiLang ) |
|
1225 { |
|
1226 langSupport = ptiLang->HasInputMode( inputMode ); |
|
1227 } |
|
1228 |
|
1229 CleanupStack::PopAndDestroy( ptiEngine ); |
|
1230 ptiLang = NULL; |
|
1231 return langSupport; |
|
1232 } |
|
1233 |
|
1234 // ---------------------------------------------------------------------------- |
|
1235 // CGSLangModel::PredictiveModeL |
|
1236 // |
|
1237 // Get Predictive mode value |
|
1238 // 0 --> Normal |
|
1239 // 1 --> Autocompletion |
|
1240 // ---------------------------------------------------------------------------- |
|
1241 // |
|
1242 TInt CGSLangModel::PredictiveModeL() |
|
1243 { |
|
1244 TInt value = 0; |
|
1245 #ifndef RD_INTELLIGENT_TEXT_INPUT |
|
1246 User::LeaveIfError( iAknFepRepository-> |
|
1247 Get( KAknFepAutoCompleteFlag, value ) ); |
|
1248 #endif |
|
1249 return value; |
|
1250 } |
|
1251 |
|
1252 // ---------------------------------------------------------------------------- |
|
1253 // CGSLangModel::SetPredictiveModeL |
|
1254 // |
|
1255 // Get Predictive mode value |
|
1256 // 0 --> Normal |
|
1257 // 1 --> Autocompletion |
|
1258 // ---------------------------------------------------------------------------- |
|
1259 // |
|
1260 void CGSLangModel::SetPredictiveModeL( TInt aMode ) |
|
1261 { |
|
1262 #ifndef RD_INTELLIGENT_TEXT_INPUT |
|
1263 User::LeaveIfError( iAknFepRepository-> |
|
1264 Set( KAknFepAutoCompleteFlag, aMode ) ); |
|
1265 #endif |
|
1266 } |
|
1267 |
|
1268 // ---------------------------------------------------------------------------- |
|
1269 // CGSLangModel::CheckAutoWordCompletionSupportL |
|
1270 // |
|
1271 // Checking autoword completion feature support |
|
1272 // ---------------------------------------------------------------------------- |
|
1273 // |
|
1274 TBool CGSLangModel::CheckAutoWordCompletionSupportL() |
|
1275 { |
|
1276 TBool langSupport=EFalse; |
|
1277 |
|
1278 #ifndef RD_INTELLIGENT_TEXT_INPUT |
|
1279 CPtiEngine* ptiEngine = CPtiEngine::NewL(); |
|
1280 CleanupStack::PushL( ptiEngine ); |
|
1281 |
|
1282 MPtiLanguage* ptiLang = NULL; |
|
1283 TPtiEngineInputMode inputMode = EPtiEngineWordCompletion; |
|
1284 |
|
1285 TInt aLangCode = 0; |
|
1286 User::LeaveIfError( iAknFepRepository->Get( KAknFepInputTxtLang, aLangCode ) ); |
|
1287 |
|
1288 ptiLang = ptiEngine->GetLanguage( aLangCode ); |
|
1289 if ( ptiLang ) |
|
1290 { |
|
1291 langSupport = ptiLang->HasInputMode( inputMode ); |
|
1292 } |
|
1293 |
|
1294 CleanupStack::PopAndDestroy( ptiEngine ); |
|
1295 ptiLang = NULL; |
|
1296 #endif //RD_INTELLIGENT_TEXT_INPUT |
|
1297 |
|
1298 return langSupport; |
|
1299 } |
|
1300 |
|
1301 // ---------------------------------------------------------------------------- |
|
1302 // CGSLangModel::CheckDiskSpaceL |
|
1303 // |
|
1304 // Checking if there is enough free space for language switch |
|
1305 // ---------------------------------------------------------------------------- |
|
1306 // |
|
1307 TBool CGSLangModel::CheckDiskSpaceL() |
|
1308 { |
|
1309 // Check if there is enough space in disk |
|
1310 if ( SysUtil::FFSSpaceBelowCriticalLevelL( NULL, |
|
1311 KGSDiskSpaceLimitForLanguageChange ) ) |
|
1312 { |
|
1313 return ETrue; |
|
1314 } |
|
1315 else |
|
1316 { |
|
1317 return EFalse; |
|
1318 } |
|
1319 } |
|
1320 |
|
1321 #ifdef RD_INTELLIGENT_TEXT_INPUT |
|
1322 TBool CGSLangModel::DeviceHasMultipleKeyboardsL() |
|
1323 { |
|
1324 TInt physicalKeyboards = 0; |
|
1325 User::LeaveIfError( iAknFepRepository->Get( KAknFepPhysicalKeyboards, physicalKeyboards )); |
|
1326 |
|
1327 TBool firstFound = EFalse; |
|
1328 for(TUint i = 0x01; i <= 0xF0; i = i << 1) |
|
1329 { |
|
1330 if(physicalKeyboards & i) |
|
1331 { |
|
1332 if (firstFound) |
|
1333 { |
|
1334 return ETrue; |
|
1335 } |
|
1336 else |
|
1337 { |
|
1338 firstFound = ETrue; |
|
1339 } |
|
1340 } |
|
1341 } |
|
1342 return EFalse; |
|
1343 } |
|
1344 |
|
1345 TInt CGSLangModel::PredictionBitMaskL() |
|
1346 { |
|
1347 TInt value = 0; |
|
1348 User::LeaveIfError( iAknFepRepository->Get( KAknFepPredTxtFlagExtension, value ) ); |
|
1349 return value; |
|
1350 } |
|
1351 |
|
1352 void CGSLangModel::SetPredictionBitMaskL(TInt aBitMask) |
|
1353 { |
|
1354 User::LeaveIfError( iAknFepRepository->Set( KAknFepPredTxtFlagExtension, aBitMask ) ); |
|
1355 } |
|
1356 |
|
1357 TInt CGSLangModel::PhysicalKeyboardsL() |
|
1358 { |
|
1359 TInt physicalKeyboards = 0; |
|
1360 User::LeaveIfError( iAknFepRepository->Get( KAknFepPhysicalKeyboards, physicalKeyboards )); |
|
1361 return physicalKeyboards; |
|
1362 } |
|
1363 |
|
1364 void CGSLangModel::GetSecondaryInputLanguagesL( |
|
1365 CArrayFix<TInt>* aSeedLanguages, |
|
1366 CDesCArray* aLanguageNames, |
|
1367 CCoeEnv* aCoeEnv) |
|
1368 { |
|
1369 CPtiEngine* ptiEngine = CPtiEngine::NewL(); |
|
1370 CleanupStack::PushL( ptiEngine ); |
|
1371 |
|
1372 CArrayFix<TInt>* languageCodeArray = aSeedLanguages; |
|
1373 ptiEngine->GetAvailableLanguagesL( languageCodeArray ); |
|
1374 languageCodeArray->InsertL(0,0); // No secondary input language as the first item |
|
1375 |
|
1376 TInt count = languageCodeArray->Count(); |
|
1377 for ( TInt index = 0; index < count; ++index ) |
|
1378 { |
|
1379 const TInt langCode = languageCodeArray->At(index); |
|
1380 if(langCode == ELangTaiwanChinese || |
|
1381 langCode == ELangHongKongChinese || |
|
1382 langCode == ELangPrcChinese || |
|
1383 langCode == ELangJapanese || |
|
1384 langCode == ELangKorean ) |
|
1385 { |
|
1386 languageCodeArray->Delete(index); |
|
1387 count--; |
|
1388 index--; |
|
1389 } |
|
1390 } |
|
1391 |
|
1392 HBufC* noneString = StringLoader::LoadLC( R_SECONDARY_WRITING_LANG_NONE, aCoeEnv); |
|
1393 TPtr nonePtr( noneString->Des() ); |
|
1394 aLanguageNames->AppendL(nonePtr); |
|
1395 CleanupStack::PopAndDestroy( noneString ); |
|
1396 |
|
1397 HBufC* buffer = HBufC::NewLC( KGSBufSize128 ); |
|
1398 for ( TInt index = 1; index < count; ++index ) |
|
1399 { |
|
1400 const TInt langId = languageCodeArray->At( index ); |
|
1401 |
|
1402 TPtr ptrToBuffer( buffer->Des() ); |
|
1403 ptiEngine->GetLocalizedLanguageName( langId & KGSLanguageMask, |
|
1404 ptrToBuffer ); |
|
1405 |
|
1406 aLanguageNames->AppendL( ptrToBuffer ); |
|
1407 |
|
1408 ptrToBuffer.Zero(); |
|
1409 } |
|
1410 |
|
1411 CleanupStack::PopAndDestroy( buffer ); |
|
1412 CleanupStack::PopAndDestroy( ptiEngine ); |
|
1413 } |
|
1414 #endif |
|
1415 |
|
1416 // End of File |