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