|
1 /* |
|
2 * Copyright (c) 2002 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: |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 |
|
22 #include "AknInputLanguageInfo.h" |
|
23 #include "ptiInputLanguageInfo.h" |
|
24 |
|
25 // CONSTANTS |
|
26 const TInt KInputLanguageArrayGranularity = 10; |
|
27 |
|
28 // CLASS IMPLEMENTATION |
|
29 |
|
30 CT9InputLanguageInfo::CT9InputLanguageInfo() |
|
31 {} |
|
32 |
|
33 |
|
34 CT9InputLanguageInfo* CT9InputLanguageInfo::NewL() |
|
35 { |
|
36 CT9InputLanguageInfo* self = new(ELeave)CT9InputLanguageInfo(); |
|
37 CleanupStack::PushL(self); |
|
38 self->ConstructL(); |
|
39 CleanupStack::Pop(); //self |
|
40 return self; |
|
41 } |
|
42 |
|
43 void CT9InputLanguageInfo::ConstructL() |
|
44 { |
|
45 // This implementation uses english dictionary by default |
|
46 iPtiEngineInterface = CPtiEngine::NewL(); |
|
47 iPtiEngineInterface->ActivateLanguageL(ELangEnglish); |
|
48 } |
|
49 |
|
50 EXPORT_C CT9InputLanguageInfo::~CT9InputLanguageInfo() |
|
51 { |
|
52 if(iPtiEngineInterface) |
|
53 { |
|
54 TRAP_IGNORE( iPtiEngineInterface->CloseCurrentLanguageL()); |
|
55 } |
|
56 delete iPtiEngineInterface; |
|
57 } |
|
58 |
|
59 |
|
60 EXPORT_C void CT9InputLanguageInfo::AppendAvailableLanguagesL( CAknInputLanguageList* aList ) |
|
61 { |
|
62 TAknInputLanguageCapabilities capabilityFilter; |
|
63 capabilityFilter.SetAllCapabilities(); |
|
64 // Implemented by calling the more generic method with all filtering off: |
|
65 AppendLanguagesL( aList, NULL, capabilityFilter ); |
|
66 } |
|
67 |
|
68 EXPORT_C void CT9InputLanguageInfo::AppendLanguagesL( |
|
69 CAknInputLanguageList* aList, |
|
70 CArrayFix<TInt>* aLanguageCodeList, |
|
71 TAknInputLanguageCapabilities& aCapabilityFilter) |
|
72 { |
|
73 // Provide new arrays for the call |
|
74 CArrayFixFlat<TInt>* langCodes = new (ELeave) CArrayFixFlat<TInt>( KInputLanguageArrayGranularity ); |
|
75 CleanupStack::PushL( langCodes ); |
|
76 |
|
77 iPtiEngineInterface->GetAvailableLanguagesL( langCodes ); |
|
78 |
|
79 TInt count = langCodes->Count(); |
|
80 |
|
81 // Loop over the codes, appending them into the existing array; |
|
82 for ( TInt index = 0; index < count; ++index ) |
|
83 { |
|
84 TLanguage langCode = (TLanguage)langCodes->At(index); |
|
85 |
|
86 // Filter by language code if array exists |
|
87 if ( !( aLanguageCodeList && !IsInLanguageCodeList(aLanguageCodeList, langCode ) ) ) |
|
88 { |
|
89 TBool chineseLanguage = (langCode == ELangTaiwanChinese || langCode == ELangHongKongChinese || langCode == ELangPrcChinese); |
|
90 |
|
91 // Temporary solution for Chinese variants. |
|
92 // All Chinese languages are shown in the input language list. |
|
93 // In western functionality we strip out secondary languages. |
|
94 if ( chineseLanguage || !(!aLanguageCodeList && 0) ) // missing secondary language functionality |
|
95 { |
|
96 TAknInputLanguageCapabilities capabilities = LanguageCapabilitiesFromLanguage( langCode ); |
|
97 // Test is passed if the filter has no support at all (no filtering to be done) |
|
98 // or there is a filter, but the language supports it |
|
99 if ( !aCapabilityFilter.HasAnySupport() || (capabilities.FilteredCapabilities( aCapabilityFilter )).HasAnySupport() ) |
|
100 { |
|
101 CAknInputLanguageItem* inputItem = CAknInputLanguageItem::NewL( langCode, LanguageName(langCode), capabilities ); |
|
102 CleanupStack::PushL( inputItem ); |
|
103 aList->AppendL( inputItem ); // Takes full ownership |
|
104 CleanupStack::Pop(); // inputItem |
|
105 } |
|
106 } |
|
107 } |
|
108 } |
|
109 |
|
110 CleanupStack::PopAndDestroy(1); // langcodes |
|
111 } |
|
112 |
|
113 TBool CT9InputLanguageInfo::IsInLanguageCodeList( CArrayFix<TInt>* aLanguageList, TLanguage aLanguageCode ) |
|
114 { |
|
115 TBool retVal = EFalse; |
|
116 |
|
117 TInt index; |
|
118 TInt count = aLanguageList->Count(); |
|
119 for (index = 0; index < count; ++index ) |
|
120 { |
|
121 TInt language = aLanguageList->At( index ); |
|
122 language &= 0x03FF; |
|
123 if (language == ELangOther) |
|
124 { |
|
125 language = ELangEnglish; |
|
126 } |
|
127 if (language == aLanguageCode) |
|
128 { |
|
129 retVal = ETrue; |
|
130 break; |
|
131 } |
|
132 } |
|
133 return retVal; |
|
134 } |
|
135 |
|
136 |
|
137 EXPORT_C TAknInputLanguageCapabilities CT9InputLanguageInfo::LanguageCapabilitiesFromLanguage( TLanguage aLanguageId ) |
|
138 { |
|
139 // essentially this is to map the capabilities to the non-t9 defined ones: |
|
140 |
|
141 MPtiLanguage* lang = iPtiEngineInterface->GetLanguage(aLanguageId); |
|
142 |
|
143 TAknInputLanguageCapabilities returnCapabilities; |
|
144 |
|
145 if ( lang ) |
|
146 { |
|
147 returnCapabilities.AssignCapability( TAknInputLanguageCapabilities::EMultitap, ETrue ); |
|
148 |
|
149 if (!lang->HasInputMode(EPtiEngineMultitapping)) |
|
150 { |
|
151 returnCapabilities.AssignCapability( TAknInputLanguageCapabilities::EMultitap, EFalse ); |
|
152 } |
|
153 |
|
154 if (lang->HasInputMode(EPtiEnginePredictive)) |
|
155 { |
|
156 returnCapabilities.AssignCapability( TAknInputLanguageCapabilities::EPredictive, ETrue ); |
|
157 } |
|
158 } |
|
159 else |
|
160 { |
|
161 returnCapabilities.AssignCapability( TAknInputLanguageCapabilities::EMultitap, EFalse ); |
|
162 } |
|
163 |
|
164 return returnCapabilities; |
|
165 } |
|
166 |
|
167 EXPORT_C TAknLanguageName CT9InputLanguageInfo::LanguageName( TLanguage aLanguageCode ) const |
|
168 { |
|
169 MPtiLanguage* lang = iPtiEngineInterface->GetLanguage(aLanguageCode); |
|
170 return lang->LocalizedName(); |
|
171 } |
|
172 |
|
173 EXPORT_C TLanguage CT9InputLanguageInfo::UrlLanguage() const |
|
174 { |
|
175 // English returned for default implementation |
|
176 return ELangEnglish; |
|
177 } |
|
178 |
|
179 // |
|
180 // Class CAknInputLanguageInfoFactory |
|
181 // |
|
182 |
|
183 EXPORT_C CAknInputLanguageInfo* AknInputLanguageInfoFactory::CreateInputLanguageInfoL() |
|
184 { |
|
185 CAknInputLanguageInfo* info = CT9InputLanguageInfo::NewL(); |
|
186 return info; |
|
187 } |
|
188 |
|
189 // End of File |