|
1 /* |
|
2 * Copyright (c) 2002-2008 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: Implementation of CAknFepLanguageManager class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 // INCLUDE FILES |
|
30 #include "AknFepGlobalEnums.h" |
|
31 #include "AknFepPanic.h" |
|
32 #include "AknFepManager.h" // CAknFepManager |
|
33 #include "AknFepManagerInterface.h" |
|
34 #include "AknFepUIManagerStateInterface.h" // MAknFepUIManagerStateInterface |
|
35 #include "AknFepUiInputStateBase.h" // TAknFepInputStateBase |
|
36 #include "AknFepUiManagerBase.h" // CAknFepUIManagerBase |
|
37 #include "AknFepUIManagerJapanese.h" // CAknFepUIManagerJapanese |
|
38 #include "AknFepUiManagerWestern.h" // CAknFepUIManagerWestern |
|
39 #include "AknFepUiManagerChinese.h" // CAknFepUIManagerChinese |
|
40 #include "AknFepLanguageManager.h" // this class |
|
41 |
|
42 #include "AknFepUiManagerKorean.h" // CAknFepUIManagerKorean |
|
43 #include <uikon.hrh> // TAknEditorNumericKeymap |
|
44 #include <AknUtils.h> |
|
45 |
|
46 #include <aknfeppeninputimeplugin.h> |
|
47 #include "AknFepPluginManager.h" |
|
48 #include <peninputcmd.h> |
|
49 #include <peninputclient.h> |
|
50 |
|
51 void Cleanup( TAny* aAny ) |
|
52 { |
|
53 RImplInfoPtrArray* implArray = |
|
54 reinterpret_cast< RImplInfoPtrArray*> ( aAny ); |
|
55 implArray->ResetAndDestroy(); |
|
56 implArray->Close(); |
|
57 } |
|
58 |
|
59 /** |
|
60 * CAknFepLanguageManager |
|
61 * |
|
62 */ |
|
63 // ============================ MEMBER FUNCTIONS =============================== |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // CAknFepLanguageManager() |
|
67 // first phase construction. |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 CAknFepLanguageManager* CAknFepLanguageManager::NewL(MAknFepManagerUIInterface* aFepMan, |
|
71 CAknFepCaseManager* aCaseMan) |
|
72 { |
|
73 CAknFepLanguageManager* self = new(ELeave) CAknFepLanguageManager(aFepMan, aCaseMan); |
|
74 CleanupStack::PushL(self); |
|
75 self->ConstructL(); |
|
76 CleanupStack::Pop(); // self |
|
77 return self; |
|
78 } |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // ~CAknFepLanguageManager() |
|
82 // Destructor. |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 CAknFepLanguageManager::~CAknFepLanguageManager() |
|
86 { |
|
87 if (iUiManArray) |
|
88 { |
|
89 iUiManArray->ResetAndDestroy(); |
|
90 } |
|
91 delete iUiManArray; |
|
92 delete iCurImePlugin; |
|
93 } |
|
94 |
|
95 // ----------------------------------------------------------------------------- |
|
96 // CAknFepLanguageManager::GetFepUI() |
|
97 // get ui manager object |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 MAknFepManagerInterface* CAknFepLanguageManager::GetFepUI(TInt aMode, TWidthChar /*aCharacterWidth*/, TBool aPredictive) |
|
101 { |
|
102 MAknFepManagerInterface* uiMan = NULL; |
|
103 switch (aMode) |
|
104 { |
|
105 case EPinyin: |
|
106 case EZhuyin: |
|
107 case EStroke: |
|
108 case ECangJie: |
|
109 case EZhuyinFind: |
|
110 case EStrokeFind: |
|
111 uiMan = iUiManArray->At(EUiManChinese); |
|
112 break; |
|
113 case ELatin: |
|
114 case EHindi: |
|
115 if (iInputLanguage == ELangJapanese) |
|
116 { |
|
117 uiMan = iUiManArray->At((aPredictive)? EUiManWestern : EUiManJapanese); |
|
118 } |
|
119 else if(iInputLanguage == ELangKorean) |
|
120 { |
|
121 uiMan = iUiManArray->At(EUiManKorean); |
|
122 } |
|
123 else |
|
124 { |
|
125 uiMan = iUiManArray->At(EUiManWestern); |
|
126 } |
|
127 break; |
|
128 case ENumber: |
|
129 case ENativeNumber: |
|
130 if (iInputLanguage == ELangJapanese) |
|
131 { |
|
132 uiMan = iUiManArray->At(EUiManJapanese); |
|
133 } |
|
134 else if(iInputLanguage == ELangKorean) |
|
135 { |
|
136 uiMan = iUiManArray->At(EUiManKorean); |
|
137 } |
|
138 else |
|
139 { |
|
140 uiMan = iUiManArray->At(EUiManWestern); |
|
141 } |
|
142 break; |
|
143 case EHiragana: |
|
144 case EHiraganaKanji: |
|
145 case EKatakana: |
|
146 uiMan = iUiManArray->At(EUiManJapanese); |
|
147 break; |
|
148 case EHangul: |
|
149 uiMan = iUiManArray->At(EUiManKorean); |
|
150 break; |
|
151 default: |
|
152 AknFepPanic(EAknFepPanicNoUiManager); |
|
153 break; |
|
154 } |
|
155 return uiMan; |
|
156 } |
|
157 |
|
158 |
|
159 // ----------------------------------------------------------------------------- |
|
160 // CAknFepLanguageManager::SetInputLanguageL() |
|
161 // Set new input language. |
|
162 // ----------------------------------------------------------------------------- |
|
163 // |
|
164 void CAknFepLanguageManager::SetInputLanguageL(TInt aInputLanguage) |
|
165 { |
|
166 iInputLanguage = aInputLanguage; |
|
167 MAknFepManagerInterface* uiManager = NULL; |
|
168 TInt uiManagerId = UiManagerId(); |
|
169 uiManager = iUiManArray->At(uiManagerId); |
|
170 |
|
171 if ( !uiManager ) |
|
172 { |
|
173 // Ui manager does not exist for this language yet. We create it. |
|
174 ConstructUiManagerL(); |
|
175 uiManager = iUiManArray->At(uiManagerId); |
|
176 } |
|
177 |
|
178 uiManager->SetInputLanguageL((TLanguage)iInputLanguage); |
|
179 |
|
180 if (uiManagerId != EUiManWestern) |
|
181 { |
|
182 // Western UI manager needs to know current input language also when |
|
183 // Chinese or Japanese Ui manager is used. |
|
184 // Western UI manager needs to use English language if the |
|
185 // input language is Chinese or Japanese. |
|
186 uiManager = iUiManArray->At(EUiManWestern); |
|
187 if (uiManager) |
|
188 { |
|
189 uiManager->SetInputLanguageL((TLanguage)iInputLanguage); |
|
190 } |
|
191 } |
|
192 |
|
193 } |
|
194 |
|
195 |
|
196 // ----------------------------------------------------------------------------- |
|
197 // CAknFepLanguageManager() |
|
198 // Constructor. |
|
199 // ----------------------------------------------------------------------------- |
|
200 // |
|
201 CAknFepLanguageManager::CAknFepLanguageManager(MAknFepManagerUIInterface* aFepManager, |
|
202 CAknFepCaseManager* aCaseManager) |
|
203 |
|
204 :iInputLanguage(ELangEnglish), |
|
205 iFepManager(aFepManager), |
|
206 iCaseManager(aCaseManager), |
|
207 iPluginManager(NULL) |
|
208 { |
|
209 } |
|
210 |
|
211 // ----------------------------------------------------------------------------- |
|
212 // CAknFepLanguageManager::ConstructL() |
|
213 // Second phase construction |
|
214 // ----------------------------------------------------------------------------- |
|
215 // |
|
216 void CAknFepLanguageManager::ConstructL() |
|
217 { |
|
218 iUiManArray = new(ELeave)CArrayPtrFlat<MAknFepManagerInterface>(EUiManMax); |
|
219 |
|
220 for ( TInt ii = 0; ii < EUiManMax; ii++) |
|
221 { |
|
222 iUiManArray->AppendL(NULL); |
|
223 } |
|
224 |
|
225 // Create UI manager for English language. English exists in all variants and |
|
226 // it is default language in CAknFepLanguageManager. |
|
227 ConstructUiManagerL(); |
|
228 } |
|
229 |
|
230 void CAknFepLanguageManager::ConstructUiManagerL() |
|
231 { |
|
232 MAknFepManagerInterface* uiMan = NULL; |
|
233 TInt uiManagerId = UiManagerId(); |
|
234 iUiManArray->Delete(uiManagerId); |
|
235 switch (uiManagerId) |
|
236 { |
|
237 case EUiManWestern: |
|
238 uiMan = CAknFepUIManagerWestern::NewL(iFepManager, iCaseManager, |
|
239 (TLanguage)iInputLanguage); |
|
240 break; |
|
241 case EUiManChinese: |
|
242 uiMan = CAknFepUIManagerChinese::NewL(iFepManager, iCaseManager, |
|
243 (TLanguage)iInputLanguage); |
|
244 break; |
|
245 case EUiManJapanese: |
|
246 uiMan = CAknFepUIManagerJapanese::NewL(iFepManager, iCaseManager, |
|
247 (TLanguage)iInputLanguage); |
|
248 break; |
|
249 case EUiManKorean: |
|
250 uiMan = CAknFepUIManagerKorean::NewL(iFepManager, iCaseManager, (TLanguage)iInputLanguage); |
|
251 break; |
|
252 default: |
|
253 AknFepPanic(EAknFepPanicNoUiManager); |
|
254 break; |
|
255 } |
|
256 CleanupStack::PushL(uiMan); |
|
257 iUiManArray->InsertL(uiManagerId, uiMan); |
|
258 CleanupStack::Pop(); // uiMan |
|
259 } |
|
260 |
|
261 TInt CAknFepLanguageManager::UiManagerId() |
|
262 { |
|
263 TInt uiManagerId = EUiManWestern; |
|
264 switch (iInputLanguage) |
|
265 { |
|
266 case ELangPrcChinese: |
|
267 case ELangHongKongChinese: |
|
268 case ELangTaiwanChinese: |
|
269 uiManagerId = EUiManChinese; |
|
270 break; |
|
271 case ELangJapanese: |
|
272 uiManagerId = EUiManJapanese; |
|
273 break; |
|
274 case ELangKorean: |
|
275 uiManagerId = EUiManKorean; |
|
276 break; |
|
277 default: |
|
278 // Western UI manager is default. |
|
279 // Thai, Arabic and Hebrew uses western UI manager. |
|
280 break; |
|
281 } |
|
282 return uiManagerId; |
|
283 } |
|
284 |
|
285 // ----------------------------------------------------------------------------- |
|
286 // CAknFepLanguageManager::GetPluginInputFepUiL |
|
287 // Get plugin UI manager object. |
|
288 // (other items were commented in a header). |
|
289 // ----------------------------------------------------------------------------- |
|
290 // |
|
291 MAknFepManagerInterface* CAknFepLanguageManager::GetPluginInputFepUiL( |
|
292 TPluginInputMode aPreferedMode, |
|
293 TInt aPenInputLang, |
|
294 TInt aDisplayLang, |
|
295 RPeninputServer* aPenServer) |
|
296 { |
|
297 |
|
298 RArray<TInt> implList; |
|
299 CleanupClosePushL(implList); |
|
300 |
|
301 TPluginInputMode secondMode = EPluginInputModeItut; |
|
302 TPluginInputMode curMode = aPreferedMode; |
|
303 TInt language = aPenInputLang; |
|
304 |
|
305 //pen input language and prefered mode |
|
306 aPenServer->GetImePluginIdListL(aPenInputLang, curMode, implList); |
|
307 |
|
308 if( implList.Count() == 0 ) |
|
309 { |
|
310 //pen input language and other modes |
|
311 curMode = secondMode; |
|
312 aPenServer->GetImePluginIdListL(aPenInputLang, curMode, implList); |
|
313 } |
|
314 |
|
315 if( implList.Count() == 0 && aPenInputLang != aDisplayLang) |
|
316 { |
|
317 //display language and prefered modes |
|
318 language = aDisplayLang; |
|
319 curMode = aPreferedMode; |
|
320 aPenServer->GetImePluginIdListL(aDisplayLang, curMode, implList); |
|
321 |
|
322 if( implList.Count() == 0 ) |
|
323 { |
|
324 //display language and other modes |
|
325 curMode = secondMode; |
|
326 aPenServer->GetImePluginIdListL(aDisplayLang, curMode, implList); |
|
327 } |
|
328 } |
|
329 |
|
330 CAknFepPenInputImePlugin* pIme = NULL; |
|
331 MAknFepManagerInterface* pUi = NULL; |
|
332 TInt i; |
|
333 for(i = 0; i < implList.Count(); ++i) |
|
334 { |
|
335 pIme = ActivateImePlugin(implList[i], aPenServer); |
|
336 if( pIme ) |
|
337 { |
|
338 pUi = ActivateLayoutUiPluginL(pIme, language, curMode); |
|
339 if( pUi ) |
|
340 { |
|
341 iCurUiPlugIn = pUi; |
|
342 if( iCurImePlugin != pIme ) |
|
343 { |
|
344 //a new IME plugin created |
|
345 delete iCurImePlugin; |
|
346 iCurImePlugin = pIme; |
|
347 } |
|
348 break; |
|
349 } |
|
350 else |
|
351 { |
|
352 //Fail create UI, delete IME plugin just created |
|
353 if( iCurImePlugin != pIme ) |
|
354 { |
|
355 delete pIme; |
|
356 } |
|
357 } |
|
358 } |
|
359 } |
|
360 |
|
361 if( i == implList.Count() ) |
|
362 { |
|
363 delete iCurImePlugin; |
|
364 iCurImePlugin = NULL; |
|
365 iCurUiPlugIn = NULL; |
|
366 } |
|
367 CleanupStack::PopAndDestroy(&implList); |
|
368 |
|
369 if ( iCurUiPlugIn ) |
|
370 { |
|
371 aPenServer->SetInputLanguage( language ); |
|
372 } |
|
373 return iCurUiPlugIn; |
|
374 } |
|
375 |
|
376 TBool CAknFepLanguageManager::IsPluginInputAvaiable(TPluginInputMode aMode, |
|
377 TInt aPenInputLang, |
|
378 RPeninputServer* aPenServer) |
|
379 { |
|
380 TBool bAvail = EFalse; |
|
381 TRAP_IGNORE(bAvail = IsPluginInputAvaiableL(aMode, aPenInputLang, aPenServer)); |
|
382 return bAvail; |
|
383 } |
|
384 |
|
385 TBool CAknFepLanguageManager::IsPluginInputAvaiableL(TPluginInputMode aMode, |
|
386 TInt aPenInputLang, |
|
387 RPeninputServer* aPenServer) |
|
388 { |
|
389 RArray<TInt> implList; |
|
390 CleanupClosePushL(implList); |
|
391 |
|
392 aPenServer->GetImePluginIdListL(aPenInputLang, aMode, implList); |
|
393 TBool bAvail = implList.Count() != 0; |
|
394 CleanupStack::PopAndDestroy(&implList); |
|
395 return bAvail; |
|
396 } |
|
397 |
|
398 // ----------------------------------------------------------------------------- |
|
399 // CAknFepLanguageManager::ActivateImePlugin |
|
400 // Activate IME plugin by implemenation. |
|
401 // (other items were commented in a header). |
|
402 // ----------------------------------------------------------------------------- |
|
403 // |
|
404 CAknFepPenInputImePlugin* CAknFepLanguageManager::ActivateImePlugin( |
|
405 TInt aImeImplId, |
|
406 RPeninputServer* aPenServer) |
|
407 { |
|
408 if(iCurImePlugin && iCurImePlugin->ImeImplId() == aImeImplId) |
|
409 { |
|
410 return iCurImePlugin; |
|
411 } |
|
412 else |
|
413 { |
|
414 TUid dtor_ID_Key; |
|
415 CAknFepPenInputImePlugin* pIme = NULL; |
|
416 |
|
417 TRAP_IGNORE(pIme = REINTERPRET_CAST(CAknFepPenInputImePlugin*, |
|
418 REComSession::CreateImplementationL(TUid::Uid(aImeImplId), dtor_ID_Key, aPenServer))); |
|
419 |
|
420 if( pIme ) |
|
421 { |
|
422 pIme->iDtor_ID_Key = dtor_ID_Key; |
|
423 } |
|
424 |
|
425 return pIme; |
|
426 } |
|
427 } |
|
428 |
|
429 // ----------------------------------------------------------------------------- |
|
430 // CAknFepLanguageManager::ActivateLayoutUiPluginL |
|
431 // Activate IME plugin's UI by mode. |
|
432 // (other items were commented in a header). |
|
433 // ----------------------------------------------------------------------------- |
|
434 // |
|
435 MAknFepManagerInterface* CAknFepLanguageManager::ActivateLayoutUiPluginL( |
|
436 CAknFepPenInputImePlugin* aImePlugin, |
|
437 TInt aPenInputLang, |
|
438 TPluginInputMode aMode) |
|
439 { |
|
440 MAknFepManagerInterface* pUi = NULL; |
|
441 |
|
442 if( aImePlugin ) |
|
443 { |
|
444 pUi = aImePlugin -> GetInputMethodUiL(iFepManager, |
|
445 (TLanguage)aPenInputLang, |
|
446 aMode, |
|
447 KNullDesC8(), |
|
448 iIsSplitView); |
|
449 //set inputlanguage |
|
450 if(pUi) |
|
451 { |
|
452 pUi->SetInputLanguageL((TLanguage)aPenInputLang); |
|
453 //pUi->ActivateUI(); |
|
454 } |
|
455 } |
|
456 |
|
457 return pUi; |
|
458 } |
|
459 |
|
460 // ----------------------------------------------------------------------------- |
|
461 // CAknFepLanguageManager::SetSplitView |
|
462 // Activate IME plugin's UI by mode. |
|
463 // (other items were commented in a header). |
|
464 // ----------------------------------------------------------------------------- |
|
465 // |
|
466 void CAknFepLanguageManager::SetSplitView(TBool aIsSplitView) |
|
467 { |
|
468 iIsSplitView = aIsSplitView; |
|
469 } |
|
470 |
|
471 // End of File |