1 /* |
|
2 * Copyright (c) 2002-2007 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: Input mode plugin implementation file |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 #include "peninputimepluginjp.h" |
|
31 #include <ecom.h> |
|
32 #include <AknFepManagerInterface.h> |
|
33 #include <eikmenup.h> |
|
34 #include <avkon.hrh> |
|
35 #include <aknfepuiinterface.h> |
|
36 #include <aknfepuimenus.h> |
|
37 #include <featmgr.h> |
|
38 |
|
39 #include "peninputimepluginjpdebug.h" |
|
40 #include "pluginfepmanagerhwr.h" |
|
41 #include "pluginfepmanagervkb.h" |
|
42 #include "pluginfepmanagerbase.h" |
|
43 |
|
44 |
|
45 const TInt KInvalidImplId = 0; |
|
46 |
|
47 _LIT(KHwrImeName, "Japanese HWR"); |
|
48 _LIT(KVkbImeName, "Japanese VKB"); |
|
49 |
|
50 // Implementation of Class CPenInputImePluginJp |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // RImplInfoPtrArray cleanup function |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 void Cleanup( TAny* aAny ) |
|
57 { |
|
58 RImplInfoPtrArray* implArray = |
|
59 reinterpret_cast< RImplInfoPtrArray*> ( aAny ); |
|
60 implArray->ResetAndDestroy(); |
|
61 implArray->Close(); |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CPenInputImePluginJp::NewL |
|
66 // factory function |
|
67 // (other items were commented in a header). |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 CPenInputImePluginJp* CPenInputImePluginJp::NewL(TAny* aInitParams) |
|
71 { |
|
72 CPenInputImePluginJp* self = new(ELeave)CPenInputImePluginJp( |
|
73 static_cast<RPeninputServer*>(aInitParams)); |
|
74 CleanupStack::PushL(self); |
|
75 self->ConstructL(); |
|
76 CleanupStack::Pop(self); |
|
77 return self; |
|
78 } |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // CPenInputImePluginJp::NewLC |
|
82 // factory function |
|
83 // (other items were commented in a header). |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 CPenInputImePluginJp* CPenInputImePluginJp::NewLC(TAny* aInitParams) |
|
87 { |
|
88 CPenInputImePluginJp* self = new(ELeave) CPenInputImePluginJp( |
|
89 static_cast<RPeninputServer*>(aInitParams)); |
|
90 CleanupStack::PushL(self); |
|
91 self->ConstructL(); |
|
92 return self; |
|
93 } |
|
94 |
|
95 // ----------------------------------------------------------------------------- |
|
96 // CPenInputImePluginJp::~CPenInputImePluginJp |
|
97 // destructor |
|
98 // (other items were commented in a header). |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 CPenInputImePluginJp::~CPenInputImePluginJp() |
|
102 { |
|
103 DeActivate(); |
|
104 iUiLayoutImpIdList.Close(); |
|
105 iAllUiManagers.ResetAndDestroy(); |
|
106 REComSession::FinalClose();//cleanup ecom |
|
107 } |
|
108 |
|
109 // ----------------------------------------------------------------------------- |
|
110 // CPenInputImePluginJp::GetInputMethodUiL |
|
111 // Create layout UI interface |
|
112 // (other items were commented in a header). |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 MAknFepManagerInterface* CPenInputImePluginJp::GetInputMethodUiL( |
|
116 MAknFepManagerUIInterface* aFepManager, |
|
117 TLanguage aLanguage, |
|
118 TInt aMode, |
|
119 const TDesC8& /*aData*/, |
|
120 const TBool aIsSplitView) |
|
121 { |
|
122 iFepManager = aFepManager; |
|
123 iLanguage = aLanguage; |
|
124 CPluginFepManagerBase* fepmanager = NULL; |
|
125 |
|
126 TUid layoutId; |
|
127 TInt i; |
|
128 |
|
129 switch(aMode) |
|
130 { |
|
131 case EPluginInputModeHwr: |
|
132 layoutId.iUid = KHwrUiId; |
|
133 fepmanager = GetHwrUiL(); |
|
134 break; |
|
135 case EPluginInputModeVkb: |
|
136 layoutId.iUid = KVkbUiId; |
|
137 fepmanager = GetVkbUiL(); |
|
138 break; |
|
139 default: |
|
140 return NULL; |
|
141 } |
|
142 |
|
143 for(i = 0; i < iUiLayoutImpIdList.Count(); ++i) |
|
144 { |
|
145 if(iUiLayoutImpIdList[i] == layoutId.iUid ) |
|
146 { |
|
147 break; |
|
148 } |
|
149 } |
|
150 |
|
151 if( i < iUiLayoutImpIdList.Count() ) |
|
152 { |
|
153 iPenInputMode = aMode; |
|
154 TInt errCode = iPenInputServer->SetUiLayoutId(layoutId); |
|
155 if( errCode == KErrNone ) |
|
156 { |
|
157 fepmanager->OnInit(); |
|
158 return fepmanager; |
|
159 } |
|
160 } |
|
161 |
|
162 return NULL; |
|
163 } |
|
164 |
|
165 // ----------------------------------------------------------------------------- |
|
166 // CPenInputImePluginJp::GetInputMethodUiL |
|
167 // Create layout UI interface |
|
168 // (other items were commented in a header). |
|
169 // ----------------------------------------------------------------------------- |
|
170 // |
|
171 MAknFepManagerInterface* CPenInputImePluginJp::GetInputMethodUiL( |
|
172 MAknFepManagerUIInterface* aFepManager, |
|
173 TInt aLayoutId, |
|
174 const TDesC8& /*aData*/) |
|
175 { |
|
176 iFepManager = aFepManager; |
|
177 CPluginFepManagerBase* fepmanager = NULL; |
|
178 TInt i; |
|
179 TInt mode; |
|
180 |
|
181 if( aLayoutId == KHwrUiId) |
|
182 { |
|
183 mode = EPluginInputModeHwr; |
|
184 fepmanager = GetHwrUiL(); |
|
185 } |
|
186 else if( aLayoutId == KVkbUiId) |
|
187 { |
|
188 mode = EPluginInputModeVkb; |
|
189 fepmanager = GetVkbUiL(); |
|
190 } |
|
191 else |
|
192 { |
|
193 return NULL; |
|
194 } |
|
195 |
|
196 for(i = 0; i < iUiLayoutImpIdList.Count(); ++i) |
|
197 { |
|
198 if(iUiLayoutImpIdList[i] == aLayoutId ) |
|
199 { |
|
200 break; |
|
201 } |
|
202 } |
|
203 |
|
204 if( i < iUiLayoutImpIdList.Count() ) |
|
205 { |
|
206 iPenInputMode = mode; |
|
207 iPenInputServer->SetUiLayoutId(TUid::Uid(aLayoutId)); |
|
208 fepmanager->OnInit(); |
|
209 return fepmanager; |
|
210 } |
|
211 |
|
212 return NULL; |
|
213 } |
|
214 |
|
215 // ----------------------------------------------------------------------------- |
|
216 // CPenInputImePluginJp::Activate |
|
217 // Activate current IME plugin. |
|
218 // (other items were commented in a header). |
|
219 // ----------------------------------------------------------------------------- |
|
220 // |
|
221 void CPenInputImePluginJp::Activate() |
|
222 { |
|
223 if(iPenInputServer) |
|
224 { |
|
225 iPenInputServer->ActivateLayout(ETrue); |
|
226 } |
|
227 } |
|
228 |
|
229 // ----------------------------------------------------------------------------- |
|
230 // CPenInputImePluginJp::DeActivate |
|
231 // Deactivate current IME plugin. |
|
232 // (other items were commented in a header). |
|
233 // ----------------------------------------------------------------------------- |
|
234 // |
|
235 void CPenInputImePluginJp::DeActivate() |
|
236 { |
|
237 if (iPenInputServer && iPenInputServer->IsVisible()) |
|
238 { |
|
239 iPenInputServer->ActivateLayout(EFalse); |
|
240 } |
|
241 } |
|
242 |
|
243 // ----------------------------------------------------------------------------- |
|
244 // CPenInputImePluginJp::ImeImplId |
|
245 // Get current IME plugin implementation ID. |
|
246 // (other items were commented in a header). |
|
247 // ----------------------------------------------------------------------------- |
|
248 // |
|
249 TInt CPenInputImePluginJp::ImeImplId() |
|
250 { |
|
251 return KInputMethodImplementationId; |
|
252 } |
|
253 |
|
254 // ----------------------------------------------------------------------------- |
|
255 // CPenInputImePluginJp::LayoutUiImplId |
|
256 // Get current layout UI implementation id. |
|
257 // (other items were commented in a header). |
|
258 // ----------------------------------------------------------------------------- |
|
259 // |
|
260 TInt CPenInputImePluginJp::LayoutUiImplId() |
|
261 { |
|
262 TInt id; |
|
263 switch(iPenInputMode) |
|
264 { |
|
265 case EPluginInputModeHwr: |
|
266 id = KHwrUiId; |
|
267 break; |
|
268 case EPluginInputModeVkb: |
|
269 id = KVkbUiId; |
|
270 break; |
|
271 default: |
|
272 id = KInvalidImplId; |
|
273 break; |
|
274 } |
|
275 return id; |
|
276 } |
|
277 |
|
278 // ----------------------------------------------------------------------------- |
|
279 // CPenInputImePluginJp::SupportModes |
|
280 // Get suppored layout UI modes(VKB/HWR). |
|
281 // (other items were commented in a header). |
|
282 // ----------------------------------------------------------------------------- |
|
283 // |
|
284 TInt CPenInputImePluginJp::SupportModes(CPtiEngine* aPtiEngine, |
|
285 RArray<TImePlguinImplDetail>& aSupportList) const |
|
286 { |
|
287 TInt ret = 0; |
|
288 TRAP_IGNORE( ret = SupportModesL( aPtiEngine, aSupportList ) ); |
|
289 return ret; |
|
290 } |
|
291 |
|
292 // ----------------------------------------------------------------------------- |
|
293 // CPenInputImePluginJp::SupportModesL |
|
294 // Get suppored layout UI modes(VKB/HWR). |
|
295 // (other items were commented in a header). |
|
296 // ----------------------------------------------------------------------------- |
|
297 // |
|
298 TInt CPenInputImePluginJp::SupportModesL(CPtiEngine* /*aPtiEngine*/, |
|
299 RArray<TImePlguinImplDetail>& aSupportList) const |
|
300 { |
|
301 RImplInfoPtrArray infoArray; |
|
302 TUid id; |
|
303 id.iUid = KHwrLayoutInterfaceId; |
|
304 TBool hwr = EFalse; |
|
305 TBool vkb = EFalse; |
|
306 |
|
307 CleanupStack::PushL( TCleanupItem( Cleanup, &infoArray ) ); |
|
308 REComSession::ListImplementationsL(id, infoArray); |
|
309 |
|
310 for (TInt i = 0; i < infoArray.Count(); ++i) |
|
311 { |
|
312 if(infoArray[i]->ImplementationUid().iUid == KHwrUiId ) |
|
313 { |
|
314 hwr = ETrue; |
|
315 } |
|
316 if(infoArray[i]->ImplementationUid().iUid == KVkbUiId |
|
317 && FeatureManager::FeatureSupported(KFeatureIdVirtualKeyboardInput)) |
|
318 { |
|
319 vkb = ETrue; |
|
320 } |
|
321 } |
|
322 |
|
323 TImePlguinImplDetail detail; |
|
324 |
|
325 detail.iImplementationId = KInputMethodImplementationId; |
|
326 if( hwr ) |
|
327 { |
|
328 detail.iMode = EPluginInputModeHwr; |
|
329 detail.iMeritValue = EImeMerit_Preferred; |
|
330 detail.iDisplayName.Copy(KHwrImeName()); |
|
331 detail.iLanguage = ELangJapanese; |
|
332 aSupportList.Append(detail); |
|
333 detail.iLanguage = ELangEnglish; |
|
334 detail.iMeritValue = EImeMerit_NotUsed; |
|
335 aSupportList.Append(detail); |
|
336 } |
|
337 |
|
338 if( vkb ) |
|
339 { |
|
340 detail.iMode = EPluginInputModeVkb; |
|
341 detail.iMeritValue = EImeMerit_Preferred; |
|
342 detail.iDisplayName.Copy(KVkbImeName()); |
|
343 detail.iLanguage = ELangJapanese; |
|
344 aSupportList.Append(detail); |
|
345 detail.iLanguage = ELangEnglish; |
|
346 detail.iMeritValue = EImeMerit_NotUsed; |
|
347 aSupportList.Append(detail); |
|
348 } |
|
349 CleanupStack::PopAndDestroy(&infoArray); // infoArray |
|
350 |
|
351 return 0; |
|
352 } |
|
353 |
|
354 // ----------------------------------------------------------------------------- |
|
355 // CPenInputImePluginJp::CurrentMode |
|
356 // Get current layout UI mode. |
|
357 // (other items were commented in a header). |
|
358 // ----------------------------------------------------------------------------- |
|
359 // |
|
360 TInt CPenInputImePluginJp::CurrentMode() const |
|
361 { |
|
362 return iPenInputMode; |
|
363 } |
|
364 |
|
365 // ----------------------------------------------------------------------------- |
|
366 // CPenInputImePluginJp::HandleServerEventL |
|
367 // Handle pen input server event.. |
|
368 // (other items were commented in a header). |
|
369 // ----------------------------------------------------------------------------- |
|
370 // |
|
371 TBool CPenInputImePluginJp::HandleServerEventL(TInt aEventId, const TDesC& aData) |
|
372 { |
|
373 TBool bHandled = EFalse; |
|
374 switch( aEventId ) |
|
375 { |
|
376 case ESignalLayoutICFLengthChanged: |
|
377 GetCurrentUi()->RetrieveEditorMaxLength(); |
|
378 break; |
|
379 case ESignalCaseMode: |
|
380 { |
|
381 GetCurrentUi()->UpdateCaseMode(*(TInt*)(aData.Ptr())); |
|
382 } |
|
383 break; |
|
384 default: |
|
385 break; |
|
386 } |
|
387 |
|
388 return bHandled; |
|
389 } |
|
390 |
|
391 // ----------------------------------------------------------------------------- |
|
392 // CPenInputImePluginJp::HandleMenuCommandL |
|
393 // Handle the menu command. |
|
394 // (other items were commented in a header). |
|
395 // ----------------------------------------------------------------------------- |
|
396 // |
|
397 TBool CPenInputImePluginJp::HandleMenuCommandL(TInt aCommandId) |
|
398 { |
|
399 TBool ret = EFalse; |
|
400 switch(aCommandId) |
|
401 { |
|
402 // not handle the following command ids. |
|
403 case EPenInputJpCmdFullWidth: |
|
404 case EPenInputJpCmdHalfWidth: |
|
405 break; |
|
406 case EPenInputJpCmdConversionOn: |
|
407 case EPenInputJpCmdConversionOff: |
|
408 break; |
|
409 case EPenInputJpCmdPredictiveOn: |
|
410 case EPenInputJpCmdPredictiveOff: |
|
411 break; |
|
412 case EPenInputJpCmdSaveWord: |
|
413 case EPenInputJpCmdKutenCode: |
|
414 default: |
|
415 break; |
|
416 } |
|
417 return ret; |
|
418 } |
|
419 |
|
420 // ----------------------------------------------------------------------------- |
|
421 // CPenInputImePluginJp::DynInitMenuPaneL |
|
422 // Dynamiclly update menu items during it displays. |
|
423 // (other items were commented in a header). |
|
424 // ----------------------------------------------------------------------------- |
|
425 // |
|
426 void CPenInputImePluginJp::DynInitMenuPaneL(CAknFepUiInterfaceMenuPane* aMenuPane) |
|
427 { |
|
428 TBool dimmmenu; |
|
429 CPluginFepManagerBase* manager = GetCurrentUi(); |
|
430 if (manager) |
|
431 { |
|
432 dimmmenu = (manager->IsCharWidth())? ETrue: EFalse; |
|
433 aMenuPane->SetItemDimmed(EPenInputJpCmdFullWidth, dimmmenu); |
|
434 aMenuPane->SetItemDimmed(EPenInputJpCmdHalfWidth, !dimmmenu); |
|
435 if (iPenInputMode == EPluginInputModeHwr) |
|
436 { |
|
437 dimmmenu = (manager->IsJapaneseHwrConversion())? ETrue: EFalse; |
|
438 aMenuPane->SetItemDimmed(EPenInputJpCmdConversionOn, dimmmenu); |
|
439 aMenuPane->SetItemDimmed(EPenInputJpCmdConversionOff, !dimmmenu); |
|
440 } |
|
441 else |
|
442 { |
|
443 aMenuPane->SetItemDimmed(EPenInputJpCmdConversionOn, ETrue); |
|
444 aMenuPane->SetItemDimmed(EPenInputJpCmdConversionOff, ETrue); |
|
445 } |
|
446 dimmmenu = (manager->IsJapanesePredictive())? ETrue: EFalse; |
|
447 aMenuPane->SetItemDimmed(EPenInputJpCmdPredictiveOn, dimmmenu); |
|
448 aMenuPane->SetItemDimmed(EPenInputJpCmdPredictiveOff, !dimmmenu); |
|
449 |
|
450 aMenuPane->SetItemDimmed(EPenInputJpCmdSaveWord, EFalse); |
|
451 aMenuPane->SetItemDimmed(EPenInputJpCmdKutenCode, EFalse); |
|
452 } |
|
453 aMenuPane->SetItemDimmed(EPenInputCmdHwrTraining, ETrue); |
|
454 } |
|
455 |
|
456 |
|
457 // ----------------------------------------------------------------------------- |
|
458 // CPenInputImePluginJp::CPenInputImePluginJp |
|
459 // C++ default constructor. |
|
460 // (other items were commented in a header). |
|
461 // ----------------------------------------------------------------------------- |
|
462 // |
|
463 CPenInputImePluginJp::CPenInputImePluginJp(RPeninputServer* aHwrServer) |
|
464 : iPenInputServer(aHwrServer) |
|
465 { |
|
466 } |
|
467 |
|
468 // ----------------------------------------------------------------------------- |
|
469 // CPenInputImePluginJp::ConstructL |
|
470 // 2nd phase constructor. |
|
471 // (other items were commented in a header). |
|
472 // ----------------------------------------------------------------------------- |
|
473 // |
|
474 void CPenInputImePluginJp::ConstructL() |
|
475 { |
|
476 FindUiLayoutImplementationL(); |
|
477 //Append NULL to save HWR manager position |
|
478 iAllUiManagers.Append(NULL); |
|
479 //Append NULL to save VKB manager position |
|
480 iAllUiManagers.Append(NULL); |
|
481 } |
|
482 |
|
483 // ----------------------------------------------------------------------------- |
|
484 // CPenInputImePluginJp::FindUiLayoutImplementationL |
|
485 // Enumuate all layout UI ids. |
|
486 // (other items were commented in a header). |
|
487 // ----------------------------------------------------------------------------- |
|
488 // |
|
489 void CPenInputImePluginJp::FindUiLayoutImplementationL() |
|
490 { |
|
491 RImplInfoPtrArray infoArray; |
|
492 TUid id; |
|
493 id.iUid = KHwrLayoutInterfaceId; |
|
494 |
|
495 iUiLayoutImpIdList.Reset(); |
|
496 CleanupStack::PushL( TCleanupItem( Cleanup, &infoArray ) ); |
|
497 REComSession::ListImplementationsL(id, infoArray); |
|
498 |
|
499 for (TInt i = 0; i < infoArray.Count(); ++i) |
|
500 { |
|
501 iUiLayoutImpIdList.AppendL(infoArray[i]->ImplementationUid().iUid); |
|
502 } |
|
503 |
|
504 CleanupStack::PopAndDestroy(&infoArray); // infoArray |
|
505 } |
|
506 |
|
507 // ----------------------------------------------------------------------------- |
|
508 // CPenInputImePluginJp::GetHwrUi |
|
509 // Get HWR UI interface. |
|
510 // (other items were commented in a header). |
|
511 // ----------------------------------------------------------------------------- |
|
512 // |
|
513 CPluginFepManagerBase* CPenInputImePluginJp::GetHwrUiL() |
|
514 { |
|
515 if( !iAllUiManagers[KHwrUiIndex] ) |
|
516 { |
|
517 iAllUiManagers[KHwrUiIndex] = CPluginFepManagerHwr::NewL(*this, iPenInputServer); |
|
518 } |
|
519 |
|
520 return iAllUiManagers[KHwrUiIndex]; |
|
521 } |
|
522 |
|
523 // ----------------------------------------------------------------------------- |
|
524 // CPenInputImePluginJp::GetVkbUi |
|
525 // Get VKB UI interface. |
|
526 // (other items were commented in a header). |
|
527 // ----------------------------------------------------------------------------- |
|
528 // |
|
529 CPluginFepManagerBase* CPenInputImePluginJp::GetVkbUiL() |
|
530 { |
|
531 if( !iAllUiManagers[KVkbUiIndex] ) |
|
532 { |
|
533 iAllUiManagers[KVkbUiIndex] = CPluginFepManagerVkb::NewL(*this, iPenInputServer); |
|
534 } |
|
535 |
|
536 return iAllUiManagers[KVkbUiIndex]; |
|
537 } |
|
538 |
|
539 //End Of File |
|