|
1 /* |
|
2 * Copyright (c) 2009, 2010 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: Helper class to handle virtual keypad text labels |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <AknUtils.h> |
|
19 #include <bautils.h> |
|
20 #include <barsread.h> |
|
21 #include <avkon.rsg> |
|
22 #include <dialer.rsg> |
|
23 #include <dialerkeypad.rsg> |
|
24 #include <e32const.h> |
|
25 #include <e32lang.h> |
|
26 #include <PtiEngine.h> |
|
27 #include <AknFepInternalCRKeys.h> |
|
28 #include <AvkonInternalCRKeys.h> |
|
29 #include <bacntf.h> |
|
30 |
|
31 #include "cdialerkeypadlabelmanager.h" |
|
32 #include "dialercommon.h" |
|
33 |
|
34 // CONSTANTS |
|
35 const TInt KKeyCount( 12 ); |
|
36 |
|
37 _LIT( KDialerButton1NumLabel, "1" ); |
|
38 _LIT( KDialerButton2NumLabel, "2" ); |
|
39 _LIT( KDialerButton3NumLabel, "3" ); |
|
40 _LIT( KDialerButton4NumLabel, "4" ); |
|
41 _LIT( KDialerButton5NumLabel, "5" ); |
|
42 _LIT( KDialerButton6NumLabel, "6" ); |
|
43 _LIT( KDialerButton7NumLabel, "7" ); |
|
44 _LIT( KDialerButton8NumLabel, "8" ); |
|
45 _LIT( KDialerButton9NumLabel, "9" ); |
|
46 _LIT( KDialerButton10NumLabel, "*+" ); |
|
47 _LIT( KDialerButton11NumLabel, "0" ); |
|
48 _LIT( KDialerButton12NumLabel, "#" ); |
|
49 |
|
50 _LIT( KDialerKeypadResourceFile, "z:\\resource\\dialerkeypad" ); |
|
51 _LIT( KDialerKeypadResourceFileExt, ".rsc" ); |
|
52 _LIT( KDialerKeypadVariantExtSeparator, "_" ); |
|
53 |
|
54 _LIT( KScriptLatin, "latin" ); |
|
55 _LIT( KScriptCyrillic, "cyrillic" ); |
|
56 _LIT( KScriptGreek, "greek" ); |
|
57 _LIT( KScriptHebrew, "hebrew" ); |
|
58 _LIT( KScriptArabic, "arabic" ); |
|
59 _LIT( KScriptFarsi, "farsi" ); |
|
60 _LIT( KScriptUrdu, "urdu" ); |
|
61 _LIT( KScriptThai, "thai" ); |
|
62 _LIT( KScriptDevanagari, "devanagari" ); |
|
63 _LIT( KScriptChnPinyin, "chn_pinyin" ); |
|
64 _LIT( KScriptChnZhuyin, "chn_zhuyin" ); |
|
65 _LIT( KScriptChnStroke, "chn_stroke" ); |
|
66 _LIT( KScriptChnCangjie, "chn_cangjie" ); |
|
67 |
|
68 enum TScript |
|
69 { |
|
70 EScriptLatin = 0, |
|
71 EScriptCyrillic, |
|
72 EScriptGreek, |
|
73 EScriptHebrew, |
|
74 EScriptArabic, |
|
75 EScriptFarsi, |
|
76 EScriptUrdu, |
|
77 EScriptThai, |
|
78 EScriptDevanagari, |
|
79 EScriptChinese, // generic value for all Chinese input modes |
|
80 EScriptChnPinyin, |
|
81 EScriptChnZhuyin, |
|
82 EScriptChnStroke, |
|
83 EScriptChnCangjie |
|
84 }; |
|
85 |
|
86 struct TLanguageScriptMapping |
|
87 { |
|
88 TLanguage iLang; |
|
89 TScript iScript; |
|
90 }; |
|
91 |
|
92 // Following table maps non-Latin languages to corresponding scripts. |
|
93 // Rest of the languages are asumed to use Latin script. |
|
94 // The data of the table has been extracted from the header |
|
95 // \sf\mw\inputmethods\textinput\peninputgenericitut\inc\peninputgenericitutdata.h |
|
96 const TLanguageScriptMapping KScriptMap[] = |
|
97 { |
|
98 {ELangRussian, EScriptCyrillic}, |
|
99 {ELangBulgarian, EScriptCyrillic}, |
|
100 {ELangUkrainian, EScriptCyrillic}, |
|
101 |
|
102 {ELangGreek, EScriptGreek}, |
|
103 {ELangCyprusGreek, EScriptGreek}, |
|
104 |
|
105 {ELangHebrew, EScriptHebrew}, |
|
106 |
|
107 {ELangArabic, EScriptArabic}, |
|
108 |
|
109 {ELangFarsi, EScriptFarsi}, |
|
110 |
|
111 {ELangUrdu, EScriptUrdu}, |
|
112 |
|
113 {ELangThai, EScriptThai}, |
|
114 |
|
115 {ELangHindi, EScriptDevanagari}, |
|
116 {ELangMarathi, EScriptDevanagari}, |
|
117 |
|
118 {ELangTaiwanChinese, EScriptChinese}, |
|
119 {ELangHongKongChinese, EScriptChinese}, |
|
120 {ELangPrcChinese, EScriptChinese} |
|
121 }; |
|
122 const TInt KScriptMapCount = sizeof( KScriptMap ) / sizeof( TLanguageScriptMapping ); |
|
123 |
|
124 // Values for Chinese adaptive search modes, as documented in AvkonInternalCRKeys.h |
|
125 enum TChinesePrcMode |
|
126 { |
|
127 EChnPrcPinyin = 0, |
|
128 EChnPrcStroke = 1 |
|
129 }; |
|
130 enum TChineseTwMode |
|
131 { |
|
132 EChnTwZhuyin = 0, |
|
133 EChnTwStroke = 1 |
|
134 }; |
|
135 enum TChineseHkMode |
|
136 { |
|
137 EChnHkStroke = 0, |
|
138 EChnHkCangjie = 1 |
|
139 }; |
|
140 |
|
141 |
|
142 // LOCAL FUNCTION DECLARATIONS |
|
143 static TScript ScriptForLang( TLanguage aLang ); |
|
144 static const TDesC& ScriptName( TScript aScriptCode ); |
|
145 static TBool ScriptCanSubstituteLatin( TScript aScript ); |
|
146 |
|
147 |
|
148 // MEMBER FUNCTION DEFINITIONS |
|
149 |
|
150 // --------------------------------------------------------------------------- |
|
151 // CDialerKeyPadLabelManager::CDialerKeyPadLabelManager |
|
152 // |
|
153 // --------------------------------------------------------------------------- |
|
154 // |
|
155 CDialerKeyPadLabelManager::CDialerKeyPadLabelManager( CCoeEnv& aCoeEnv, |
|
156 MDialerKeyPadLabelManagerCallback& aObserver ) |
|
157 : iCoeEnv( aCoeEnv ), iObserver( aObserver ) |
|
158 { |
|
159 // No implementation required |
|
160 } |
|
161 |
|
162 // --------------------------------------------------------------------------- |
|
163 // CDialerKeyPadLabelManager::~CDialerKeyPadLabelManager |
|
164 // |
|
165 // --------------------------------------------------------------------------- |
|
166 // |
|
167 CDialerKeyPadLabelManager::~CDialerKeyPadLabelManager() |
|
168 { |
|
169 delete iPtiEngine; |
|
170 |
|
171 delete iAknFepRepository; |
|
172 delete iAvkonRepository; |
|
173 |
|
174 if ( iEnvChangeNotifier ) |
|
175 { |
|
176 iEnvChangeNotifier->Cancel(); |
|
177 delete iEnvChangeNotifier; |
|
178 } |
|
179 |
|
180 delete iKeypadNumLabelArray; |
|
181 delete iKeypadFirstLabelArray; |
|
182 delete iKeypadSecondLabelArray; |
|
183 |
|
184 if ( iResourceOffset ) |
|
185 { |
|
186 iCoeEnv.DeleteResourceFile( iResourceOffset ); |
|
187 } |
|
188 } |
|
189 |
|
190 // --------------------------------------------------------------------------- |
|
191 // CDialerKeyPadLabelManager::NewLC |
|
192 // |
|
193 // --------------------------------------------------------------------------- |
|
194 // |
|
195 CDialerKeyPadLabelManager* CDialerKeyPadLabelManager::NewLC( CCoeEnv& aCoeEnv, |
|
196 MDialerKeyPadLabelManagerCallback& aObserver ) |
|
197 { |
|
198 CDialerKeyPadLabelManager* self = |
|
199 new (ELeave) CDialerKeyPadLabelManager( aCoeEnv, aObserver ); |
|
200 CleanupStack::PushL( self ); |
|
201 self->ConstructL(); |
|
202 return self; |
|
203 } |
|
204 |
|
205 // --------------------------------------------------------------------------- |
|
206 // CDialerKeyPadLabelManager::NewL |
|
207 // |
|
208 // --------------------------------------------------------------------------- |
|
209 // |
|
210 CDialerKeyPadLabelManager* CDialerKeyPadLabelManager::NewL( CCoeEnv& aCoeEnv, |
|
211 MDialerKeyPadLabelManagerCallback& aObserver ) |
|
212 { |
|
213 CDialerKeyPadLabelManager* self = |
|
214 CDialerKeyPadLabelManager::NewLC( aCoeEnv, aObserver ); |
|
215 CleanupStack::Pop( self ); |
|
216 return self; |
|
217 } |
|
218 |
|
219 // --------------------------------------------------------------------------- |
|
220 // CDialerKeyPadLabelManager::ConstructL |
|
221 // |
|
222 // --------------------------------------------------------------------------- |
|
223 // |
|
224 void CDialerKeyPadLabelManager::ConstructL() |
|
225 { |
|
226 iPtiEngine = CPtiEngine::NewL(); |
|
227 |
|
228 iAknFepRepository = CDialerCenRepWrapper::NewL( *this, KCRUidAknFep ); |
|
229 iAvkonRepository = CDialerCenRepWrapper::NewL( *this, KCRUidAvkon ); |
|
230 |
|
231 TCallBack envChangeCallback( EnvChangeCallback, this ); |
|
232 iEnvChangeNotifier = CEnvironmentChangeNotifier::NewL( |
|
233 CActive::EPriorityStandard, envChangeCallback ); |
|
234 iEnvChangeNotifier->Start(); |
|
235 |
|
236 iKeypadNumLabelArray = new ( ELeave ) CDesCArrayFlat( KKeyCount ); |
|
237 iKeypadFirstLabelArray = new ( ELeave ) CDesCArrayFlat( KKeyCount ); |
|
238 iKeypadSecondLabelArray = new ( ELeave ) CDesCArrayFlat( KKeyCount ); |
|
239 |
|
240 UpdateNumLabelsL(); |
|
241 UpdateTextLabelsL(); |
|
242 } |
|
243 |
|
244 // --------------------------------------------------------------------------- |
|
245 // CDialerKeyPadLabelManager::ButtonNumLabel |
|
246 // |
|
247 // --------------------------------------------------------------------------- |
|
248 // |
|
249 TPtrC CDialerKeyPadLabelManager::ButtonNumLabel( TInt aIndex ) const |
|
250 { |
|
251 __ASSERT_DEBUG( aIndex < iKeypadNumLabelArray->Count(), DialerPanic(EDialerPanicLabelNotFound) ); |
|
252 |
|
253 TPtrC label( KNullDesC ); |
|
254 if ( aIndex < iKeypadNumLabelArray->Count() ) |
|
255 { |
|
256 label.Set( (*iKeypadNumLabelArray)[ aIndex ] ); |
|
257 } |
|
258 return label; |
|
259 } |
|
260 |
|
261 // --------------------------------------------------------------------------- |
|
262 // CDialerKeyPadLabelManager::ButtonFirstAlphaLabel |
|
263 // |
|
264 // --------------------------------------------------------------------------- |
|
265 // |
|
266 TPtrC CDialerKeyPadLabelManager::ButtonFirstAlphaLabel( TInt aIndex ) const |
|
267 { |
|
268 __ASSERT_DEBUG( aIndex < iKeypadFirstLabelArray->Count(), DialerPanic(EDialerPanicLabelNotFound) ); |
|
269 |
|
270 TPtrC label( KNullDesC ); |
|
271 if ( aIndex < iKeypadFirstLabelArray->Count() ) |
|
272 { |
|
273 label.Set( (*iKeypadFirstLabelArray)[ aIndex ] ); |
|
274 } |
|
275 return label; |
|
276 } |
|
277 |
|
278 // --------------------------------------------------------------------------- |
|
279 // CDialerKeyPadLabelManager::ButtonSecondAlphaLabel |
|
280 // |
|
281 // --------------------------------------------------------------------------- |
|
282 // |
|
283 TPtrC CDialerKeyPadLabelManager::ButtonSecondAlphaLabel( TInt aIndex ) const |
|
284 { |
|
285 __ASSERT_DEBUG( aIndex < iKeypadSecondLabelArray->Count(), DialerPanic(EDialerPanicLabelNotFound) ); |
|
286 |
|
287 TPtrC label( KNullDesC ); |
|
288 if ( aIndex < iKeypadSecondLabelArray->Count() ) |
|
289 { |
|
290 label.Set( (*iKeypadSecondLabelArray)[ aIndex ] ); |
|
291 } |
|
292 return label; |
|
293 } |
|
294 |
|
295 // --------------------------------------------------------------------------- |
|
296 // CDialerKeyPadLabelManager::UpdateTextLabelsL |
|
297 // |
|
298 // --------------------------------------------------------------------------- |
|
299 // |
|
300 void CDialerKeyPadLabelManager::HandleRepositoryChange( |
|
301 TUid aRepository, TUint32 aId ) |
|
302 { |
|
303 if ( (aRepository == KCRUidAknFep && aId == KAknFepInputTxtLang) || |
|
304 (aRepository == KCRUidAvkon && aId == KAknAdaptiveSearchChinesePRC) || |
|
305 (aRepository == KCRUidAvkon && aId == KAknAdaptiveSearchChineseTW) || |
|
306 (aRepository == KCRUidAvkon && aId == KAknAdaptiveSearchChineseHongkong) ) |
|
307 { |
|
308 // Check if alpabet labels need to be changed |
|
309 TInt scriptToUse( EScriptLatin ); |
|
310 TRAP_IGNORE( scriptToUse = LabelScriptToUseL() ); |
|
311 if ( iLabelScriptInUse != scriptToUse ) |
|
312 { |
|
313 TRAP_IGNORE( UpdateTextLabelsL() ); |
|
314 iObserver.KeyLabelsChanged(); |
|
315 } |
|
316 } |
|
317 } |
|
318 |
|
319 // --------------------------------------------------------------------------- |
|
320 // CDialerKeyPadLabelManager::HandleEnvChange |
|
321 // |
|
322 // --------------------------------------------------------------------------- |
|
323 // |
|
324 void CDialerKeyPadLabelManager::HandleEnvChange() |
|
325 { |
|
326 if ( iEnvChangeNotifier->Change() & EChangesLocale ) |
|
327 { |
|
328 TLocale locale; |
|
329 if ( locale.DigitType() != iDigitTypeInUse ) |
|
330 { |
|
331 TRAP_IGNORE( UpdateNumLabelsL() ); |
|
332 iObserver.KeyLabelsChanged(); |
|
333 } |
|
334 } |
|
335 } |
|
336 |
|
337 // --------------------------------------------------------------------------- |
|
338 // CDialerKeyPadLabelManager::EnvChangeCallback |
|
339 // |
|
340 // --------------------------------------------------------------------------- |
|
341 // |
|
342 TInt CDialerKeyPadLabelManager::EnvChangeCallback( TAny* aSelfPtr ) |
|
343 { |
|
344 CDialerKeyPadLabelManager* self = |
|
345 static_cast< CDialerKeyPadLabelManager* >( aSelfPtr ); |
|
346 self->HandleEnvChange(); |
|
347 return KErrNone; |
|
348 } |
|
349 |
|
350 // --------------------------------------------------------------------------- |
|
351 // CDialerKeyPadLabelManager::UpdateTextLabelsL |
|
352 // |
|
353 // --------------------------------------------------------------------------- |
|
354 // |
|
355 void CDialerKeyPadLabelManager::UpdateTextLabelsL() |
|
356 { |
|
357 iKeypadFirstLabelArray->Reset(); |
|
358 iKeypadSecondLabelArray->Reset(); |
|
359 |
|
360 // Load the correct keypad resource file |
|
361 TFileName resourceName; |
|
362 GetResourceFileNameL( resourceName ); |
|
363 iResourceOffset = iCoeEnv.AddResourceFileL( resourceName ); |
|
364 |
|
365 // Read keypad labels from the resource |
|
366 TResourceReader reader; |
|
367 iCoeEnv.CreateResourceReaderLC( reader, R_DIALER_KEYPAD ); |
|
368 |
|
369 TInt16 count = reader.ReadInt16(); |
|
370 |
|
371 for ( TInt i = 0 ; i < count ; ++i ) |
|
372 { |
|
373 TPtrC firstRow = reader.ReadTPtrC(); |
|
374 iKeypadFirstLabelArray->AppendL( firstRow ); |
|
375 TPtrC secondRow = reader.ReadTPtrC(); |
|
376 iKeypadSecondLabelArray->AppendL( secondRow ); |
|
377 } |
|
378 |
|
379 CleanupStack::PopAndDestroy(); // reader |
|
380 |
|
381 // Free resource as it's not usually needed anymore. Ensure that destructor |
|
382 // won't free it again. |
|
383 iCoeEnv.DeleteResourceFile( iResourceOffset ); |
|
384 iResourceOffset = 0; |
|
385 } |
|
386 |
|
387 // --------------------------------------------------------------------------- |
|
388 // CDialerKeyPadLabelManager::UpdateNumLabelsL |
|
389 // |
|
390 // --------------------------------------------------------------------------- |
|
391 // |
|
392 void CDialerKeyPadLabelManager::UpdateNumLabelsL() |
|
393 { |
|
394 // Save digit type used. This is to allow us update number labels |
|
395 // only when digit type is changed and not on all locale changes. |
|
396 TLocale locale; |
|
397 iDigitTypeInUse = locale.DigitType(); |
|
398 |
|
399 iKeypadNumLabelArray->Reset(); |
|
400 |
|
401 // Fill number labels array |
|
402 iKeypadNumLabelArray->AppendL( KDialerButton1NumLabel ); |
|
403 iKeypadNumLabelArray->AppendL( KDialerButton2NumLabel ); |
|
404 iKeypadNumLabelArray->AppendL( KDialerButton3NumLabel ); |
|
405 iKeypadNumLabelArray->AppendL( KDialerButton4NumLabel ); |
|
406 iKeypadNumLabelArray->AppendL( KDialerButton5NumLabel ); |
|
407 iKeypadNumLabelArray->AppendL( KDialerButton6NumLabel ); |
|
408 iKeypadNumLabelArray->AppendL( KDialerButton7NumLabel ); |
|
409 iKeypadNumLabelArray->AppendL( KDialerButton8NumLabel ); |
|
410 iKeypadNumLabelArray->AppendL( KDialerButton9NumLabel ); |
|
411 iKeypadNumLabelArray->AppendL( KDialerButton10NumLabel ); |
|
412 iKeypadNumLabelArray->AppendL( KDialerButton11NumLabel ); |
|
413 iKeypadNumLabelArray->AppendL( KDialerButton12NumLabel ); |
|
414 |
|
415 // Convert num labels to current global number mode |
|
416 for ( TInt i = 0 ; i < iKeypadNumLabelArray->Count() ; ++i ) |
|
417 { |
|
418 // A bit of magic is needed to get a modifiable pointer |
|
419 // descriptor which points to string within the array. |
|
420 TPtrC roPtr = (*iKeypadNumLabelArray)[i]; |
|
421 TPtr ptr( const_cast<TUint16*>( roPtr.Ptr() ), roPtr.Length(), roPtr.Length() ); |
|
422 |
|
423 AknTextUtils::LanguageSpecificNumberConversion( ptr ); |
|
424 } |
|
425 } |
|
426 |
|
427 // --------------------------------------------------------------------------- |
|
428 // CDialerKeyPadLabelManager::GetResourceFileNameL |
|
429 // |
|
430 // --------------------------------------------------------------------------- |
|
431 // |
|
432 void CDialerKeyPadLabelManager::GetResourceFileNameL( TDes& aFileName ) |
|
433 { |
|
434 TFileName resName; |
|
435 |
|
436 iLabelScriptInUse = LabelScriptToUseL(); |
|
437 // Try to get variated resource name if necessary |
|
438 if ( iLabelScriptInUse != EScriptLatin ) |
|
439 { |
|
440 const TDesC& scriptName = ScriptName( static_cast<TScript>(iLabelScriptInUse) ); |
|
441 resName.Copy( KDialerKeypadResourceFile ); |
|
442 resName.Append( KDialerKeypadVariantExtSeparator ); |
|
443 resName.Append( scriptName ); |
|
444 resName.Append( KDialerKeypadResourceFileExt ); |
|
445 |
|
446 BaflUtils::NearestLanguageFile( iCoeEnv.FsSession(), resName ); |
|
447 if ( !BaflUtils::FileExists( iCoeEnv.FsSession(), resName ) ) |
|
448 { |
|
449 // resource not found, fall back to Latin |
|
450 iLabelScriptInUse = EScriptLatin; |
|
451 } |
|
452 } |
|
453 |
|
454 // Get the default resource name if Latin script was selected or |
|
455 // resource file for the selected script was not found. |
|
456 if ( iLabelScriptInUse == EScriptLatin ) |
|
457 { |
|
458 resName.Copy( KDialerKeypadResourceFile ); |
|
459 resName.Append( KDialerKeypadResourceFileExt ); |
|
460 BaflUtils::NearestLanguageFile( iCoeEnv.FsSession(), resName ); |
|
461 } |
|
462 |
|
463 aFileName.Copy( resName ); |
|
464 } |
|
465 |
|
466 // --------------------------------------------------------------------------- |
|
467 // CDialerKeyPadLabelManager::LabelScriptToUseL |
|
468 // |
|
469 // --------------------------------------------------------------------------- |
|
470 // |
|
471 TInt CDialerKeyPadLabelManager::LabelScriptToUseL() const |
|
472 { |
|
473 TInt lang( ELangEnglish ); |
|
474 |
|
475 // Get current input language |
|
476 TInt err = iAknFepRepository->Get( KAknFepInputTxtLang, lang ); |
|
477 __ASSERT_DEBUG( !err, DialerPanic(err) ); |
|
478 |
|
479 TInt script = ScriptForLang( static_cast<TLanguage>(lang) ); |
|
480 |
|
481 // Distinct logic is used to select labels when current input language |
|
482 // is any version of Chinese. PCS uses different algorith for Chinese. |
|
483 if ( script == EScriptChinese ) |
|
484 { |
|
485 script = ChineseScriptToUseL(); |
|
486 } |
|
487 // If current input language is written in Latin script, then we check |
|
488 // if some other script of the device could also be shown on the labels. |
|
489 // Most variated labels include Latin characters as well. |
|
490 else if ( script == EScriptLatin ) |
|
491 { |
|
492 RArray<TInt> availableLanguages; |
|
493 CleanupClosePushL( availableLanguages ); |
|
494 iPtiEngine->GetAvailableLanguagesL( availableLanguages ); |
|
495 |
|
496 // Scirpt of the current UI language is preferred option for |
|
497 // alternative script. Ensure it's considered first. |
|
498 TLanguage uiLang = User::Language(); |
|
499 TInt pos = availableLanguages.Find( uiLang ); |
|
500 if ( pos != KErrNotFound ) |
|
501 { |
|
502 availableLanguages.Remove( pos ); |
|
503 availableLanguages.InsertL( uiLang, 0 ); |
|
504 } |
|
505 |
|
506 TInt langCount = availableLanguages.Count(); |
|
507 for ( TInt i = 0 ; i < langCount ; ++i ) |
|
508 { |
|
509 TLanguage altLang = static_cast<TLanguage>( availableLanguages[i] ); |
|
510 TScript altScript = ScriptForLang( altLang ); |
|
511 if ( altScript != EScriptLatin && ScriptCanSubstituteLatin(altScript) ) |
|
512 { |
|
513 // Suitable alternative script found. Use its labels |
|
514 // instead of showing only Latin alphabets. |
|
515 script = altScript; |
|
516 i = langCount; // to break out |
|
517 } |
|
518 } |
|
519 |
|
520 CleanupStack::PopAndDestroy( &availableLanguages ); |
|
521 } |
|
522 |
|
523 return script; |
|
524 } |
|
525 |
|
526 // --------------------------------------------------------------------------- |
|
527 // CDialerKeyPadLabelManager::ChineseScriptToUseL |
|
528 // |
|
529 // --------------------------------------------------------------------------- |
|
530 // |
|
531 TInt CDialerKeyPadLabelManager::ChineseScriptToUseL() const |
|
532 { |
|
533 TInt script( EScriptLatin ); |
|
534 |
|
535 TInt lang( ELangPrcChinese ); |
|
536 TInt chnSearchMode( 0 ); |
|
537 |
|
538 TInt err = iAknFepRepository->Get( KAknFepInputTxtLang, lang ); |
|
539 __ASSERT_DEBUG( !err, DialerPanic(EDialerPanicChineseScriptError) ); |
|
540 |
|
541 switch ( lang ) |
|
542 { |
|
543 case ELangPrcChinese: |
|
544 { |
|
545 err = iAvkonRepository->Get( KAknAdaptiveSearchChinesePRC, chnSearchMode ); |
|
546 script = ( chnSearchMode == EChnPrcPinyin ? EScriptChnPinyin : EScriptChnStroke ); |
|
547 } |
|
548 break; |
|
549 case ELangTaiwanChinese: |
|
550 { |
|
551 err = iAvkonRepository->Get( KAknAdaptiveSearchChineseTW, chnSearchMode ); |
|
552 script = ( chnSearchMode == EChnTwZhuyin ? EScriptChnZhuyin : EScriptChnStroke ); |
|
553 } |
|
554 break; |
|
555 case ELangHongKongChinese: |
|
556 { |
|
557 err = iAvkonRepository->Get( KAknAdaptiveSearchChineseHongkong, chnSearchMode ); |
|
558 script = ( chnSearchMode == EChnHkStroke ? EScriptChnStroke : EScriptChnCangjie ); |
|
559 } |
|
560 break; |
|
561 default: |
|
562 { |
|
563 err = KErrUnknown; |
|
564 } |
|
565 break; |
|
566 } |
|
567 __ASSERT_DEBUG( !err, DialerPanic(EDialerPanicChineseScriptError) ); |
|
568 |
|
569 return script; |
|
570 } |
|
571 |
|
572 |
|
573 // LOCAL FUNCTION DEFINITIONS |
|
574 |
|
575 // --------------------------------------------------------------------------- |
|
576 // ScriptForLang |
|
577 // |
|
578 // --------------------------------------------------------------------------- |
|
579 // |
|
580 static TScript ScriptForLang( TLanguage aLang ) |
|
581 { |
|
582 TScript script( EScriptLatin ); |
|
583 for ( TInt i = 0 ; i < KScriptMapCount ; ++i ) |
|
584 { |
|
585 if ( aLang == KScriptMap[i].iLang ) |
|
586 { |
|
587 script = KScriptMap[i].iScript; |
|
588 i = KScriptMapCount; // to break out |
|
589 } |
|
590 } |
|
591 return script; |
|
592 } |
|
593 |
|
594 // --------------------------------------------------------------------------- |
|
595 // ScriptName |
|
596 // |
|
597 // --------------------------------------------------------------------------- |
|
598 // |
|
599 static const TDesC& ScriptName( TScript aScriptCode ) |
|
600 { |
|
601 // Convert script ID to script name |
|
602 switch ( aScriptCode ) |
|
603 { |
|
604 case EScriptLatin: |
|
605 return KScriptLatin; |
|
606 case EScriptCyrillic: |
|
607 return KScriptCyrillic; |
|
608 case EScriptGreek: |
|
609 return KScriptGreek; |
|
610 case EScriptHebrew: |
|
611 return KScriptHebrew; |
|
612 case EScriptArabic: |
|
613 return KScriptArabic; |
|
614 case EScriptFarsi: |
|
615 return KScriptFarsi; |
|
616 case EScriptUrdu: |
|
617 return KScriptUrdu; |
|
618 case EScriptThai: |
|
619 return KScriptThai; |
|
620 case EScriptDevanagari: |
|
621 return KScriptDevanagari; |
|
622 case EScriptChnPinyin: |
|
623 return KScriptChnPinyin; |
|
624 case EScriptChnZhuyin: |
|
625 return KScriptChnZhuyin; |
|
626 case EScriptChnStroke: |
|
627 return KScriptChnStroke; |
|
628 case EScriptChnCangjie: |
|
629 return KScriptChnCangjie; |
|
630 default: |
|
631 __ASSERT_DEBUG( EFalse, DialerPanic(EDialerPanicUnknownScript) ); |
|
632 } |
|
633 return KNullDesC; |
|
634 } |
|
635 |
|
636 // --------------------------------------------------------------------------- |
|
637 // ScriptCanSubstituteLatin |
|
638 // Return ETrue if labels of given script can be used instead of Latin labels |
|
639 // when current input language is written with Latin script. This requires |
|
640 // that the labels include also Latin characters and that labels don't contain |
|
641 // any characters which would only make sense in some specific input mode. |
|
642 // --------------------------------------------------------------------------- |
|
643 // |
|
644 static TBool ScriptCanSubstituteLatin( TScript aScript ) |
|
645 { |
|
646 // It would be better to figure this out from the resources but that would |
|
647 // require opening and parsing several resource files. |
|
648 return !( aScript == EScriptArabic || |
|
649 aScript == EScriptUrdu || |
|
650 aScript == EScriptFarsi || |
|
651 aScript == EScriptChinese || |
|
652 aScript == EScriptChnPinyin || |
|
653 aScript == EScriptChnZhuyin || |
|
654 aScript == EScriptChnStroke || |
|
655 aScript == EScriptChnCangjie ); |
|
656 } |
|
657 |
|
658 // end of file |
|
659 |