2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FUi_InputConnectionImpl.cpp
20 * @brief This is the implementation file for the _InputConnectionImpl class.
23 #include <Elementary.h>
24 #include <FBaseDataType.h>
25 #include <FBaseSysLog.h>
26 #include <FUiInputConnection.h>
28 #include "FUi_BidiUtils.h"
29 #include "FUi_Control.h"
30 #include "FUi_ControlImpl.h"
31 #include "FUi_ControlManager.h"
32 #include "FUi_CoordinateSystemUtils.h"
33 #include "FUi_EcoreEvas.h"
34 #include "FUi_EcoreEvasMgr.h"
35 #include "FUi_InputConnectionImpl.h"
36 #include "FUi_InputConnectionUtils.h"
37 #include "FUi_UiEventManager.h"
38 #include "FUiAnim_EflNode.h"
39 #include "FUiAnim_VisualElement.h"
40 #include "FUi_Window.h"
41 #include "FUiAnim_EflLayer.h"
42 #include "FUiAnim_RootVisualElement.h"
44 using namespace Tizen::Base;
45 using namespace Tizen::Graphics;
46 using namespace Tizen::Locales;
47 using namespace Tizen::Ui;
48 using namespace Tizen::Ui::Animations;
52 const int LANGUAGE_CODE_START = 0;
53 const int LANGUAGE_CODE_MAX = 2;
54 const int LANGUAGE_IM_DATA_LENGTH = 10;
57 OnInputPanelShowStateEvent(void* pData, Ecore_IMF_Context* pContext, int value)
59 SysTryReturnVoidResult(NID_UI, pData != null, E_INVALID_ARG, "[E_INVALID_ARG] OnInputPanelShowStateEvent pData is null ");
60 SysTryReturnVoidResult(NID_UI, pContext != null, E_INVALID_ARG, "[E_INVALID_ARG] OnInputPanelShowStateEvent pContext is null ");
62 SysLog(NID_UI_CTRL, "[InputConnection] OnInputPanelShowStateEvent is called.[ctx=0x%x, showState=%d]\n", pContext, value);
64 _InputConnectionImpl* pImpl = static_cast<_InputConnectionImpl*>(pData);
65 IInputConnectionEventListener* pListener = pImpl->GetInputConnectionListener();
66 IInputConnectionEventListenerF* pListenerF = pImpl->GetInputConnectionListenerF();
67 InputConnection* pInputConnection = pImpl->GetInputConnection();
71 Ecore_IMF_Input_Panel_State ecoreInputPanelShowState = static_cast<Ecore_IMF_Input_Panel_State>(value);
72 InputPanelShowState inputPanelState = INPUT_PANEL_SHOW_STATE_HIDE;
74 switch (ecoreInputPanelShowState)
76 case ECORE_IMF_INPUT_PANEL_STATE_SHOW:
77 inputPanelState = INPUT_PANEL_SHOW_STATE_SHOW;
79 case ECORE_IMF_INPUT_PANEL_STATE_HIDE:
80 inputPanelState = INPUT_PANEL_SHOW_STATE_HIDE;
82 case ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW:
88 r = pImpl->SetInputPanelShowState(inputPanelState);
89 SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] This instance is not constructed.");
93 pListener->OnInputConnectionPanelShowStateChanged(*pInputConnection, inputPanelState);
97 pListenerF->OnInputConnectionPanelShowStateChanged(*pInputConnection, inputPanelState);
99 SetLastResult(E_SUCCESS);
105 OnInputPanelLanguageEvent(void* pData, Ecore_IMF_Context* pContext, int value)
107 SysTryReturnVoidResult(NID_UI, pData != null, E_INVALID_ARG, "[E_INVALID_ARG] OnInputPanelLanguageEvent pData is null ");
108 SysTryReturnVoidResult(NID_UI, pContext != null, E_INVALID_ARG, "[E_INVALID_ARG] OnInputPanelLanguageEvent pContext is null ");
110 _InputConnectionImpl* pImpl = static_cast<_InputConnectionImpl*>(pData);
111 IInputConnectionEventListener* pListener = pImpl->GetInputConnectionListener();
112 IInputConnectionEventListenerF* pListenerF = pImpl->GetInputConnectionListenerF();
113 InputConnection* pInputConnection = pImpl->GetInputConnection();
115 char* pLocale = null;
116 ecore_imf_context_input_panel_language_locale_get(pContext, &pLocale);
117 String tempBuffer(pLocale);
119 tempBuffer.SubString(LANGUAGE_CODE_START, LANGUAGE_CODE_MAX, language);
120 LanguageCode newLanguageCode = Locale::TwoLetterLanguageCodeStringToLanguageCode(language);
124 pListener->OnInputConnectionPanelLanguageChanged(*pInputConnection, newLanguageCode);
128 pListenerF->OnInputConnectionPanelLanguageChanged(*pInputConnection, newLanguageCode);
135 SetLastResult(E_SUCCESS);
141 OnInputPanelSizeChangedEvent(void* pData, Ecore_IMF_Context* pContext, int value)
143 SysTryReturnVoidResult(NID_UI, pData != null, E_INVALID_ARG, "[E_INVALID_ARG] OnInputPanelSizeChangedEvent pData is null ");
144 SysTryReturnVoidResult(NID_UI, pContext != null, E_INVALID_ARG, "[E_INVALID_ARG] OnInputPanelSizeChangedEvent pContext is null ");
146 _InputConnectionImpl* pImpl = static_cast<_InputConnectionImpl*>(pData);
147 IInputConnectionEventListener* pListener = pImpl->GetInputConnectionListener();
148 IInputConnectionEventListenerF* pListenerF = pImpl->GetInputConnectionListenerF();
149 InputConnection* pInputConnection = pImpl->GetInputConnection();
151 Rectangle bounds = pImpl->GetInputPanelBounds();
153 SysLog(NID_UI_CTRL, "[InputConnection] OnInputPanelSizeChangedEvent is called.[ctx=0x%x][x = %d, y = %d, width = %d, height = %d]\n", pContext, bounds.x, bounds.y, bounds.width, bounds.height);
157 pListener->OnInputConnectionPanelBoundsChanged(*pInputConnection, bounds);
161 pListenerF->OnInputConnectionPanelBoundsChanged(*pInputConnection, _CoordinateSystemUtils::ConvertToFloat(bounds));
164 SetLastResult(E_SUCCESS);
170 OnInputPanelPredictionModeEvent(void* pData, Ecore_IMF_Context* pContext, int value)
172 SysTryReturnVoidResult(NID_UI, pData != null, E_INVALID_ARG, "[E_INVALID_ARG] OnInputPanelPredictionModeEvent pData is null ");
173 SysTryReturnVoidResult(NID_UI, pContext != null, E_INVALID_ARG, "[E_INVALID_ARG] OnInputPanelPredictionModeEvent pContext is null ");
175 _InputConnectionImpl* pImpl = static_cast<_InputConnectionImpl*>(pData);
176 IInputConnectionEventListener* pListener = pImpl->GetInputConnectionListener();
177 IInputConnectionEventListenerF* pListenerF = pImpl->GetInputConnectionListenerF();
178 InputConnection* pInputConnection = pImpl->GetInputConnection();
182 pListener->OnInputConnectionTextPredictionShowStateChanged(*pInputConnection, static_cast<bool>(value));
186 pListenerF->OnInputConnectionTextPredictionShowStateChanged(*pInputConnection, static_cast<bool>(value));
188 SetLastResult(E_SUCCESS);
194 OnInputPanelPredictionSizeChangedEvent(void* pData, Ecore_IMF_Context* pContext, int value)
196 SysTryReturnVoidResult(NID_UI, pData != null, E_INVALID_ARG, "[E_INVALID_ARG] OnInputPanelPredictionSizeChangedEvent pData is null ");
197 SysTryReturnVoidResult(NID_UI, pContext != null, E_INVALID_ARG, "[E_INVALID_ARG] OnInputPanelPredictionSizeChangedEvent pContext is null ");
199 _InputConnectionImpl* pImpl = static_cast<_InputConnectionImpl*>(pData);
200 IInputConnectionEventListener* pListener = pImpl->GetInputConnectionListener();
201 IInputConnectionEventListenerF* pListenerF = pImpl->GetInputConnectionListenerF();
202 InputConnection* pInputConnection = pImpl->GetInputConnection();
204 Rectangle bounds = pImpl->GetPredictionBounds();
208 pListener->OnInputConnectionTextPredictionBoundsChanged(*pInputConnection, bounds);
212 pListenerF->OnInputConnectionTextPredictionBoundsChanged(*pInputConnection, _CoordinateSystemUtils::ConvertToFloat(bounds));
214 SetLastResult(E_SUCCESS);
220 OnRetrieveSurrounding(void* pData, Ecore_IMF_Context* pContext, char** pText, int* pCursorPostion)
222 SysTryReturn(NID_UI, pData != null, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] OnRetrieveSurrounding pData == null.");
223 SysTryReturn(NID_UI, pContext != null, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] OnRetrieveSurrounding pContext is null ");
225 _InputConnectionImpl* pImpl = static_cast<_InputConnectionImpl*>(pData);
226 IInputConnectionProvider* pProvider = pImpl->GetInputConnectionProvider();
228 InputConnection* pInputConnection = pImpl->GetInputConnection();
230 char* pSurroundingText = null;
233 pProvider->GetPreviousText(*pInputConnection, string, *pCursorPostion);
235 int len = wcstombs(0, static_cast<const wchar_t*>(string.GetPointer()), 0);
236 //SysTryReturn(NID_BASE, len != -1, null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid string.");
240 return ECORE_CALLBACK_PASS_ON;
246 return ECORE_CALLBACK_DONE;
248 //This memory will be released by ECORE IMF
249 pSurroundingText = (char*)malloc(len+1);
250 SysTryReturn(NID_UI, pSurroundingText, EINA_FALSE, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] OnRetrieveSurrounding pSurroundingText == null.");
252 len = wcstombs(pSurroundingText, static_cast<const wchar_t*>(string.GetPointer()), len);
253 pSurroundingText[len] = null;
254 *pText = pSurroundingText;
256 SetLastResult(E_SUCCESS);
258 return ECORE_CALLBACK_PASS_ON;
262 OnCommitTextEcoreEvent(void* pData, Ecore_IMF_Context* pContext, void* pEventInfo)
264 SysTryReturnVoidResult(NID_UI, pData != null, E_INVALID_ARG, "[E_INVALID_ARG] OnCommitTextEcoreEvent pData is null ");
265 SysTryReturnVoidResult(NID_UI, pEventInfo != null, E_INVALID_ARG, "[E_INVALID_ARG] OnCommitTextEcoreEvent pEventInfo is null ");
267 _InputConnectionImpl* pImpl = static_cast<_InputConnectionImpl*>(pData);
268 IInputConnectionEventListener* pListener = pImpl->GetInputConnectionListener();
269 IInputConnectionEventListenerF* pListenerF = pImpl->GetInputConnectionListenerF();
271 String commitText(static_cast<char*>(pEventInfo));
272 InputConnection* pInputConnection = pImpl->GetInputConnection();
276 pListener->OnInputConnectionTextCommitted(*pInputConnection, commitText);
280 pListenerF->OnInputConnectionTextCommitted(*pInputConnection, commitText);
283 SetLastResult(E_SUCCESS);
289 OnComposeTextEcoreEvent(void* pData, Ecore_IMF_Context* pContext, void* pEventInfo)
291 SysTryReturnVoidResult(NID_UI, pData != null, E_INVALID_ARG, "[E_INVALID_ARG] OnComposeTextEcoreEvent pData is null ");
292 //SysTryReturnVoidResult(NID_UI, pEventInfo != null, E_INVALID_ARG, "[E_INVALID_ARG] OnComposeTextEcoreEvent pEventInfo is null ");
294 _InputConnectionImpl* pImpl = static_cast<_InputConnectionImpl*>(pData);
295 IInputConnectionEventListener* pListener = pImpl->GetInputConnectionListener();
296 IInputConnectionEventListenerF* pListenerF = pImpl->GetInputConnectionListenerF();
298 int cursorPosition = 0;
300 ecore_imf_context_preedit_string_get(pContext, &pText, &cursorPosition);
301 String composingText(pText);
307 InputConnection* pInputConnection = pImpl->GetInputConnection();
311 pListener->OnInputConnectionComposingTextChanged(*pInputConnection, composingText, cursorPosition);
315 pListenerF->OnInputConnectionComposingTextChanged(*pInputConnection, composingText, cursorPosition);
318 SetLastResult(E_SUCCESS);
324 OnDeleteSurroundingTextEcoreEvent(void* pData, Ecore_IMF_Context* pContext, void* pEventInfo)
326 SysTryReturnVoidResult(NID_UI, pData != null, E_INVALID_ARG, "[E_INVALID_ARG] OnDeleteSurroundingTextEcoreEvent pData is null ");
327 SysTryReturnVoidResult(NID_UI, pEventInfo != null, E_INVALID_ARG, "[E_INVALID_ARG] OnDeleteSurroundingTextEcoreEvent pEventInfo is null ");
329 _InputConnectionImpl* pImpl = static_cast<_InputConnectionImpl*>(pData);
330 IInputConnectionProvider* pProvider = pImpl->GetInputConnectionProvider();
331 Ecore_IMF_Event_Delete_Surrounding* pEvent = static_cast<Ecore_IMF_Event_Delete_Surrounding*>(pEventInfo);
333 InputConnection* pInputConnection = pImpl->GetInputConnection();
334 pProvider->DeleteSurroundingText(*pInputConnection, pEvent->offset, pEvent->n_chars);
336 SetLastResult(E_SUCCESS);
343 OnUSBKeyboardEcoreEvent(void* pData, int eventType, void* pEventInfo)
345 return ECORE_CALLBACK_PASS_ON;
351 namespace Tizen { namespace Ui {
353 _InputConnectionImpl::_InputConnectionImpl(InputConnection* pInputConnection)
360 , __pInputConnection(pInputConnection)
361 , __inputPanelAction(INPUT_PANEL_ACTION_ENTER)
362 , __inputPanelState(INPUT_PANEL_SHOW_STATE_HIDE)
363 , __inputPanelStyle(INPUT_PANEL_STYLE_NORMAL)
364 , __pUSBEventHandler(null)
365 , __IsKeyEventSkipped(false)
366 , __passwordMode(false)
371 _InputConnectionImpl::~_InputConnectionImpl(void)
373 __pInputConnection = null;
379 RemoveInputPanelCallback();
380 RemoveEcoreEventCallback();
381 RemoveEvasObjectEventCallback();
382 ecore_imf_context_focus_out(__pContext);
383 ecore_imf_context_del(__pContext);
384 ecore_imf_shutdown();
389 _InputConnectionImpl*
390 _InputConnectionImpl::CreateInputConnectionImplN(InputConnection* pInputConnection)
394 _InputConnectionImpl* pImpl = new (std::nothrow) _InputConnectionImpl(pInputConnection);
395 SysTryReturn(NID_UI, pImpl, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
402 _InputConnectionImpl::Initialize(const _Control& control, const IInputConnectionEventListener& listener, const IInputConnectionProvider& provider)
404 result r = E_SUCCESS;
406 __controlHandle = control.GetHandle();
408 __pListener = const_cast<IInputConnectionEventListener*>(&listener);
410 __pProvider = const_cast<IInputConnectionProvider*>(&provider);
413 const char* pId = ecore_imf_context_default_id_get();
414 SysTryReturnResult(NID_UI, pId != null, E_SYSTEM, "A system error occurred.");
417 __pContext = (Ecore_IMF_Context*)ecore_imf_context_add(pId);
418 SysTryReturnResult(NID_UI, __pContext, E_SYSTEM, "A system error occurred.");
420 AddInputPanelCallback();
421 AddEcoreEventCallback();
422 AddEvasObjectEventCallback();
429 _InputConnectionImpl::Initialize(const _Control& control, const IInputConnectionEventListenerF& listener, const IInputConnectionProvider& provider)
431 result r = E_SUCCESS;
433 __controlHandle = control.GetHandle();
436 __pListenerF = const_cast<IInputConnectionEventListenerF*>(&listener);
437 __pProvider = const_cast<IInputConnectionProvider*>(&provider);
440 const char* pId = ecore_imf_context_default_id_get();
441 SysTryReturnResult(NID_UI, pId != null, E_SYSTEM, "A system error occurred.");
444 __pContext = (Ecore_IMF_Context*)ecore_imf_context_add(pId);
445 SysTryReturnResult(NID_UI, __pContext, E_SYSTEM, "A system error occurred.");
447 AddInputPanelCallback();
448 AddEcoreEventCallback();
449 AddEvasObjectEventCallback();
456 _InputConnectionImpl::BindInputMethod(void)
458 result r = E_SUCCESS;
460 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
462 _Control* pControl = _ControlManager::GetInstance()->GetObject(__controlHandle);
464 _Window* pWindow = pControl->GetRootWindow();
467 _RootVisualElement* pRootVE = pWindow->GetRootVisualElement();
468 _EflLayer* pLayer = static_cast<_EflLayer*>(pRootVE->GetNativeLayer());
472 ecore_imf_context_client_window_set(__pContext, (void*)ecore_evas_window_get(pLayer->GetEcoreEvas()));
473 ecore_imf_context_client_canvas_set(__pContext, pLayer->GetEvas());
474 ecore_imf_context_input_panel_enabled_set(__pContext, EINA_FALSE);
478 ecore_imf_context_focus_in(__pContext);
481 SysLog(NID_UI_CTRL, "[InputConnection] BindInputMethod is called.[ctx=0x%x]\n", __pContext);
487 _InputConnectionImpl::UnbindInputMethod(void)
489 result r = E_SUCCESS;
491 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
493 ecore_imf_context_focus_out(__pContext);
495 SysLog(NID_UI_CTRL, "[InputConnection] UnbindInputMethod is called.[ctx=0x%x]\n", __pContext);
503 _InputConnectionImpl::ShowInputPanel(void)
505 result r = E_SUCCESS;
507 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
508 SysTryReturnResult(NID_UI, __IsBounded, E_INVALID_STATE, "This is not a bind state");
510 ecore_imf_context_input_panel_show(__pContext);
511 __inputPanelState = INPUT_PANEL_SHOW_STATE_SHOW;
513 SysLog(NID_UI_CTRL, "[InputConnection] ShowInputPanel is called.[ctx=0x%x]\n", __pContext);
519 _InputConnectionImpl::HideInputPanel(void)
521 result r = E_SUCCESS;
523 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
524 SysTryReturnResult(NID_UI, __IsBounded, E_INVALID_STATE, "This is not a bind state");
526 ecore_imf_context_input_panel_hide(__pContext);
527 __inputPanelState = INPUT_PANEL_SHOW_STATE_HIDE;
529 SysLog(NID_UI_CTRL, "[InputConnection] HideInputPanel is called.[ctx=0x%x]\n", __pContext);
535 _InputConnectionImpl::SetInputPanelStyle(InputPanelStyle style)
537 result r = E_SUCCESS;
539 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
541 __inputPanelStyle = style;
543 Ecore_IMF_Input_Panel_Layout ecorePanelLayout = ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL;
547 case INPUT_PANEL_STYLE_NORMAL:
548 ecorePanelLayout = ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL;
549 if (__passwordMode == true)
551 ecorePanelLayout = ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD;
554 case INPUT_PANEL_STYLE_NUMBER:
555 ecorePanelLayout = ECORE_IMF_INPUT_PANEL_LAYOUT_NUMBER;
557 case INPUT_PANEL_STYLE_EMAIL:
558 ecorePanelLayout = ECORE_IMF_INPUT_PANEL_LAYOUT_EMAIL;
560 case INPUT_PANEL_STYLE_URL:
561 ecorePanelLayout = ECORE_IMF_INPUT_PANEL_LAYOUT_URL;
563 case INPUT_PANEL_STYLE_PHONE_NUMBER:
564 ecorePanelLayout = ECORE_IMF_INPUT_PANEL_LAYOUT_PHONENUMBER;
566 case INPUT_PANEL_STYLE_IP:
567 ecorePanelLayout = ECORE_IMF_INPUT_PANEL_LAYOUT_IP;
569 case INPUT_PANEL_STYLE_NUMBER_ONLY:
570 ecorePanelLayout = ECORE_IMF_INPUT_PANEL_LAYOUT_NUMBERONLY;
576 ecore_imf_context_input_panel_layout_set(__pContext, ecorePanelLayout);
581 _InputConnectionImpl::GetInputPanelStyle(void) const
585 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
587 Ecore_IMF_Input_Panel_Layout ecorePanelLayout = ecore_imf_context_input_panel_layout_get(__pContext);
588 InputPanelStyle inputPanelStyle = INPUT_PANEL_STYLE_NORMAL;
590 switch (ecorePanelLayout)
592 case ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL:
593 inputPanelStyle = INPUT_PANEL_STYLE_NORMAL;
595 case ECORE_IMF_INPUT_PANEL_LAYOUT_NUMBER:
596 inputPanelStyle = INPUT_PANEL_STYLE_NUMBER;
598 case ECORE_IMF_INPUT_PANEL_LAYOUT_EMAIL:
599 inputPanelStyle = INPUT_PANEL_STYLE_EMAIL;
601 case ECORE_IMF_INPUT_PANEL_LAYOUT_URL:
602 inputPanelStyle = INPUT_PANEL_STYLE_URL;
604 case ECORE_IMF_INPUT_PANEL_LAYOUT_PHONENUMBER:
605 inputPanelStyle = INPUT_PANEL_STYLE_PHONE_NUMBER;
607 case ECORE_IMF_INPUT_PANEL_LAYOUT_IP:
608 inputPanelStyle = INPUT_PANEL_STYLE_IP;
610 case ECORE_IMF_INPUT_PANEL_LAYOUT_NUMBERONLY:
611 inputPanelStyle = INPUT_PANEL_STYLE_NUMBER_ONLY;
617 return inputPanelStyle;
621 _InputConnectionImpl::SetAutoCapitalizationMode(AutoCapitalizationMode autoCapitalizationMode)
623 result r = E_SUCCESS;
625 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
627 Ecore_IMF_Autocapital_Type ecoreAutoCapitalization = ECORE_IMF_AUTOCAPITAL_TYPE_SENTENCE;
629 switch (autoCapitalizationMode)
631 case AUTO_CAPITALIZATION_MODE_NONE:
632 ecoreAutoCapitalization = ECORE_IMF_AUTOCAPITAL_TYPE_NONE;
634 case AUTO_CAPITALIZATION_MODE_WORD:
635 ecoreAutoCapitalization = ECORE_IMF_AUTOCAPITAL_TYPE_WORD;
637 case AUTO_CAPITALIZATION_MODE_SENTENCE:
638 ecoreAutoCapitalization = ECORE_IMF_AUTOCAPITAL_TYPE_SENTENCE;
640 case AUTO_CAPITALIZATION_MODE_ALL:
641 ecoreAutoCapitalization =ECORE_IMF_AUTOCAPITAL_TYPE_ALLCHARACTER;
647 ecore_imf_context_autocapital_type_set(__pContext, ecoreAutoCapitalization);
651 AutoCapitalizationMode
652 _InputConnectionImpl::GetAutoCapitalizationMode(void) const
656 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
658 Ecore_IMF_Autocapital_Type ecoreAutoCapitalization = ecore_imf_context_autocapital_type_get(__pContext);
659 AutoCapitalizationMode autoCapitalizationMode = AUTO_CAPITALIZATION_MODE_SENTENCE;
661 switch (ecoreAutoCapitalization)
663 case ECORE_IMF_AUTOCAPITAL_TYPE_NONE:
664 autoCapitalizationMode = AUTO_CAPITALIZATION_MODE_NONE;
666 case ECORE_IMF_AUTOCAPITAL_TYPE_WORD:
667 autoCapitalizationMode = AUTO_CAPITALIZATION_MODE_WORD;
669 case ECORE_IMF_AUTOCAPITAL_TYPE_SENTENCE:
670 autoCapitalizationMode = AUTO_CAPITALIZATION_MODE_SENTENCE;
672 case ECORE_IMF_AUTOCAPITAL_TYPE_ALLCHARACTER:
673 autoCapitalizationMode = AUTO_CAPITALIZATION_MODE_ALL;
679 return autoCapitalizationMode;
683 _InputConnectionImpl::GetInputPanelShowState(void) const
687 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
689 return __inputPanelState;
693 _InputConnectionImpl::SetInputPanelShowState(InputPanelShowState state)
695 result r = E_SUCCESS;
697 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
699 __inputPanelState = state;
704 _InputConnectionImpl::FinishTextComposition(void)
706 result r = E_SUCCESS;
708 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
709 SysTryReturnResult(NID_UI, __IsBounded, E_INVALID_STATE, "This is not a bind state");
711 ecore_imf_context_reset(__pContext);
716 _InputConnectionImpl::SetInputPanelAction(InputPanelAction inputPanelAction)
718 result r = E_SUCCESS;
720 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
722 __inputPanelAction = inputPanelAction;
723 Ecore_IMF_Input_Panel_Return_Key_Type ecorePanelAction = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
725 switch (inputPanelAction)
727 case INPUT_PANEL_ACTION_GO:
728 ecorePanelAction = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_GO;
730 case INPUT_PANEL_ACTION_NEXT:
731 ecorePanelAction = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT;
733 case INPUT_PANEL_ACTION_SEND:
734 ecorePanelAction = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEND;
736 case INPUT_PANEL_ACTION_SEARCH:
737 ecorePanelAction = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH;
739 case INPUT_PANEL_ACTION_LOGIN:
740 ecorePanelAction = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_LOGIN;
742 case INPUT_PANEL_ACTION_SIGN_IN:
743 ecorePanelAction = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SIGNIN;
745 case INPUT_PANEL_ACTION_JOIN:
746 ecorePanelAction = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_JOIN;
748 case INPUT_PANEL_ACTION_DONE:
749 ecorePanelAction = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE;
751 case INPUT_PANEL_ACTION_ENTER:
752 ecorePanelAction = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
758 ecore_imf_context_input_panel_return_key_type_set(__pContext, ecorePanelAction);
764 _InputConnectionImpl::GetInputPanelAction(void) const
768 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
770 Ecore_IMF_Input_Panel_Return_Key_Type ecorePanelAction = ecore_imf_context_input_panel_return_key_type_get(__pContext);
771 InputPanelAction inputPanelAction = INPUT_PANEL_ACTION_ENTER;
773 switch (ecorePanelAction)
775 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_GO:
776 inputPanelAction = INPUT_PANEL_ACTION_GO;
778 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT:
779 inputPanelAction = INPUT_PANEL_ACTION_NEXT;
781 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEND:
782 inputPanelAction = INPUT_PANEL_ACTION_SEND;
784 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH:
785 inputPanelAction = INPUT_PANEL_ACTION_SEARCH;
787 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_LOGIN:
788 inputPanelAction = INPUT_PANEL_ACTION_LOGIN;
790 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SIGNIN:
791 inputPanelAction = INPUT_PANEL_ACTION_SIGN_IN;
793 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_JOIN:
794 inputPanelAction = INPUT_PANEL_ACTION_JOIN;
796 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE:
797 inputPanelAction = INPUT_PANEL_ACTION_DONE;
799 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT:
800 inputPanelAction = INPUT_PANEL_ACTION_ENTER;
806 return inputPanelAction;
810 _InputConnectionImpl::SetInputPanelActionEnabled(bool enable)
812 result r = E_SUCCESS;
814 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
816 ecore_imf_context_input_panel_return_key_disabled_set(__pContext, (!enable ? EINA_TRUE : EINA_FALSE));
821 _InputConnectionImpl::IsInputPanelActionEnabled(void) const
825 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
827 Eina_Bool enabled = ecore_imf_context_input_panel_return_key_disabled_get(__pContext);
829 return static_cast<bool>(!enabled);
833 _InputConnectionImpl::SetCursorPosition(int position)
835 result r = E_SUCCESS;
837 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
838 SysTryReturnResult(NID_UI, position >= 0, E_INVALID_ARG, "The input parameter is invalid.");
839 SysTryReturnResult(NID_UI, __IsBounded, E_INVALID_STATE, "This is not a bind state");
841 ecore_imf_context_cursor_position_set(__pContext, position);
846 _InputConnectionImpl::SetCursorBounds(const Rectangle& rect)
848 result r = E_SUCCESS;
850 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
852 SysTryReturnResult(NID_UI, (rect.width > 0)&&(rect.height > 0), E_INVALID_ARG, "The input parameter is invalid.");
853 SysTryReturnResult(NID_UI, __IsBounded, E_INVALID_STATE, "This is not a bind state");
856 Rectangle cursorRectangle;
857 cursorRectangle = rect;
859 const _Control* pControl = _ControlManager::GetInstance()->GetObject(__controlHandle);
863 Rectangle absoluteControlRectangle;
864 absoluteControlRectangle = pControl->GetAbsoluteBounds(true);
865 cursorRectangle.x += absoluteControlRectangle.x;
866 cursorRectangle.y += absoluteControlRectangle.y;
869 Rectangle physicalRect = _CoordinateSystemUtils::Transform(cursorRectangle);
871 ecore_imf_context_cursor_location_set(__pContext, physicalRect.x, physicalRect.y, physicalRect.width, physicalRect.height);
876 _InputConnectionImpl::SetCursorBounds(const FloatRectangle& rect)
878 result r = E_SUCCESS;
880 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
882 SysTryReturnResult(NID_UI, (rect.width > 0)&&(rect.height > 0), E_INVALID_ARG, "The input parameter is invalid.");
883 SysTryReturnResult(NID_UI, __IsBounded, E_INVALID_STATE, "This is not a bind state");
886 FloatRectangle cursorRectangle;
887 cursorRectangle = rect;
889 const _Control* pControl = _ControlManager::GetInstance()->GetObject(__controlHandle);
893 FloatRectangle absoluteControlRectangle;
894 absoluteControlRectangle = pControl->GetAbsoluteBoundsF(true);
895 cursorRectangle.x += absoluteControlRectangle.x;
896 cursorRectangle.y += absoluteControlRectangle.y;
899 FloatRectangle physicalFloatRect = _CoordinateSystemUtils::Transform(cursorRectangle);
900 Rectangle physicalRect = _CoordinateSystemUtils::ConvertToInteger(physicalFloatRect);
902 ecore_imf_context_cursor_location_set(__pContext, physicalRect.x, physicalRect.y, physicalRect.width, physicalRect.height);
907 _InputConnectionImpl::GetInputPanelBounds(void) const
911 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
918 ecore_imf_context_input_panel_geometry_get(__pContext, &x, &y, &w, &h);
919 return Rectangle(x, y, w, h);
923 _InputConnectionImpl::GetInputPanelBoundsF(void) const
927 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
934 ecore_imf_context_input_panel_geometry_get(__pContext, &x, &y, &w, &h);
935 FloatRectangle inputPanelFloatRect;
936 inputPanelFloatRect.x = _CoordinateSystemUtils::ConvertToFloat(x);
937 inputPanelFloatRect.y = _CoordinateSystemUtils::ConvertToFloat(y);
938 inputPanelFloatRect.width = _CoordinateSystemUtils::ConvertToFloat(w);
939 inputPanelFloatRect.height = _CoordinateSystemUtils::ConvertToFloat(h);
941 return inputPanelFloatRect;
945 _InputConnectionImpl::GetPredictionBounds(void) const
949 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
956 ecore_imf_context_candidate_panel_geometry_get(__pContext, &x, &y, &w, &h);
957 return Rectangle(x, y, w, h);
961 _InputConnectionImpl::GetPredictionBoundsF(void) const
965 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
972 ecore_imf_context_candidate_panel_geometry_get(__pContext, &x, &y, &w, &h);
973 FloatRectangle inputPredictionFloatRect;
974 inputPredictionFloatRect.x = _CoordinateSystemUtils::ConvertToFloat(x);
975 inputPredictionFloatRect.y = _CoordinateSystemUtils::ConvertToFloat(y);
976 inputPredictionFloatRect.width = _CoordinateSystemUtils::ConvertToFloat(w);
977 inputPredictionFloatRect.height = _CoordinateSystemUtils::ConvertToFloat(h);
979 return inputPredictionFloatRect;
983 _InputConnectionImpl::SetTextPredictionEnabled(bool enable)
985 result r = E_SUCCESS;
987 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
989 ecore_imf_context_prediction_allow_set(__pContext, (enable ? EINA_TRUE : EINA_FALSE));
995 _InputConnectionImpl::IsTextPredictionEnabled(void) const
999 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
1001 Eina_Bool enabled = ecore_imf_context_prediction_allow_get(__pContext);
1003 return static_cast<bool>(enabled);
1007 _InputConnectionImpl::SetCapsLockEnabled(bool enable)
1009 result r = E_SUCCESS;
1011 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
1013 ecore_imf_context_input_panel_caps_lock_mode_set(__pContext, (enable ? EINA_TRUE : EINA_FALSE));
1019 _InputConnectionImpl::IsCapsLockEnabled(void) const
1023 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
1025 Eina_Bool enabled = ecore_imf_context_input_panel_caps_lock_mode_get(__pContext);
1027 return static_cast<bool>(enabled);
1031 _InputConnectionImpl::SetPasswordMode(bool enable)
1033 result r = E_SUCCESS;
1035 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
1037 __passwordMode = true;
1038 ecore_imf_context_input_panel_layout_set(__pContext, ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD);
1044 _InputConnectionImpl::IsPasswordMode(void) const
1046 return __passwordMode;
1050 _InputConnectionImpl::SetInputPanelLanguage(LanguageCode languageCode)
1052 result r = E_SUCCESS;
1054 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
1056 String language(L"");
1057 language = _BidiUtils::ConvertLanguageCountryCodeString(languageCode);
1058 if (language == String(L""))
1060 const char* pLanguage = "lang=en_US";
1061 ecore_imf_context_input_panel_imdata_set(__pContext, pLanguage, LANGUAGE_IM_DATA_LENGTH);
1066 char* pLanguage = null;
1067 int len = wcstombs(0, static_cast<const wchar_t*>(language.GetPointer()), 0);
1068 pLanguage = (char*)malloc(len+1);
1069 SysTryReturn(NID_UI, pLanguage, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] pLanguage is null.");
1071 len = wcstombs(pLanguage, static_cast<const wchar_t*>(language.GetPointer()), len);
1072 pLanguage[len] = null;
1074 ecore_imf_context_input_panel_imdata_set(__pContext, pLanguage, LANGUAGE_IM_DATA_LENGTH);
1082 _InputConnectionImpl::GetInputPanelLanguage(void) const
1084 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
1088 char* pLocale = null;
1090 ecore_imf_context_input_panel_language_locale_get(__pContext, &pLocale);
1092 String tempBuffer(pLocale);
1094 tempBuffer.SubString(LANGUAGE_CODE_START, LANGUAGE_CODE_MAX, language);
1101 return Locale::TwoLetterLanguageCodeStringToLanguageCode(language);
1105 _InputConnectionImpl::SendOpaqueCommand(const String& command)
1107 SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use.");
1109 char* pCommand = null;
1112 length = wcstombs(0, static_cast<const wchar_t*>(command.GetPointer()), 0);
1113 SysTryReturnVoidResult(NID_UI, length != -1, E_OUT_OF_MEMORY, "A system error occurred.");
1115 pCommand = (char*)malloc(length+1);
1116 SysTryReturnVoidResult(NID_UI, pCommand, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
1118 length = wcstombs(pCommand, static_cast<const wchar_t*>(command.GetPointer()), length);
1119 pCommand[length] = null;
1121 ecore_imf_context_input_panel_imdata_set(__pContext, pCommand, length);
1127 _InputConnectionImpl::GetInputConnection(void) const
1129 return __pInputConnection;
1132 IInputConnectionEventListener*
1133 _InputConnectionImpl::GetInputConnectionListener(void) const
1138 IInputConnectionEventListenerF*
1139 _InputConnectionImpl::GetInputConnectionListenerF(void) const
1141 return __pListenerF;
1144 IInputConnectionProvider*
1145 _InputConnectionImpl::GetInputConnectionProvider(void) const
1151 _InputConnectionImpl::CheckContextEvent(Ecore_IMF_Event_Type type, void* pEventInfo)
1155 if (type == ECORE_IMF_EVENT_KEY_DOWN)
1157 Evas_Event_Key_Down* pDownEvent = static_cast<Evas_Event_Key_Down*>(pEventInfo);
1158 SysTryReturn(NID_UI, pDownEvent != null, false, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1159 Ecore_IMF_Event_Key_Down ecoreEvent;
1160 ecore_imf_evas_event_key_down_wrap(pDownEvent, &ecoreEvent);
1161 if (ecore_imf_context_filter_event(__pContext, type, (Ecore_IMF_Event*)&ecoreEvent) == EINA_TRUE)
1166 else if (type == ECORE_IMF_EVENT_KEY_UP)
1168 Evas_Event_Key_Up* pUpEvent = static_cast<Evas_Event_Key_Up*>(pEventInfo);
1169 SysTryReturn(NID_UI, pUpEvent != null, false, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1170 Ecore_IMF_Event_Key_Up ecoreEvent;
1171 ecore_imf_evas_event_key_up_wrap(pUpEvent, &ecoreEvent);
1172 if (ecore_imf_context_filter_event(__pContext, type, (Ecore_IMF_Event*)&ecoreEvent) == EINA_TRUE)
1181 _InputConnectionImpl::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
1183 if (__IsKeyEventSkipped)
1188 _KeyCode keyCode = keyInfo.GetKeyCode();
1189 if (keyCode == _KEY_OEM_1)
1194 Ecore_Event_Key* pEvent = static_cast<Ecore_Event_Key*>(keyInfo.GetUserData());
1195 SysTryReturn(NID_UI, pEvent, false, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1197 Ecore_IMF_Event_Key_Down* pKeyDown = (Ecore_IMF_Event_Key_Down*)malloc(sizeof(Ecore_IMF_Event_Key_Down));
1198 SysTryReturn(NID_UI, pKeyDown, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
1200 pKeyDown->keyname = pEvent->keyname;
1202 //need to check with SLP
1203 int modifiers = ECORE_IMF_KEYBOARD_MODIFIER_NONE;
1205 if (pEvent->modifiers & ECORE_EVENT_MODIFIER_SHIFT)
1207 modifiers |= ECORE_IMF_KEYBOARD_MODIFIER_SHIFT;
1209 if (pEvent->modifiers & ECORE_EVENT_MODIFIER_CTRL)
1211 modifiers |= ECORE_IMF_KEYBOARD_MODIFIER_CTRL;
1213 if (pEvent->modifiers & ECORE_EVENT_MODIFIER_ALT)
1215 modifiers |= ECORE_IMF_KEYBOARD_MODIFIER_ALT;
1217 if (pEvent->modifiers & ECORE_EVENT_MODIFIER_WIN)
1219 modifiers |= ECORE_IMF_KEYBOARD_MODIFIER_WIN;
1221 pKeyDown->modifiers = static_cast<Ecore_IMF_Keyboard_Modifiers>(modifiers);
1223 int locks = ECORE_IMF_KEYBOARD_LOCK_NONE;
1224 if (pEvent->modifiers & ECORE_EVENT_LOCK_SCROLL)
1226 locks |= ECORE_IMF_KEYBOARD_LOCK_SCROLL;
1228 if (pEvent->modifiers & ECORE_EVENT_LOCK_NUM)
1230 locks |= ECORE_IMF_KEYBOARD_LOCK_NUM;
1232 if (pEvent->modifiers & ECORE_EVENT_LOCK_CAPS)
1234 locks |= ECORE_IMF_KEYBOARD_LOCK_CAPS;
1236 pKeyDown->locks = static_cast<Ecore_IMF_Keyboard_Locks>(locks);
1238 pKeyDown->key = pEvent->key;
1239 pKeyDown->string = pEvent->string;
1240 pKeyDown->compose = pEvent->compose;
1241 pKeyDown->timestamp = pEvent->timestamp;
1243 const _Control* pControl = _ControlManager::GetInstance()->GetObject(__controlHandle);
1245 if (&source == pControl)
1247 if(CheckUSBKeyboardStatus() && pKeyDown->string)//usb keyboard exist
1249 const char* key = const_cast<char*>(pKeyDown->string);
1250 if(FilterKeyOnUSBMode(GetInputPanelStyle(), key, true) == E_SUCCESS)
1257 if (ecore_imf_context_filter_event(__pContext, ECORE_IMF_EVENT_KEY_DOWN, (Ecore_IMF_Event*)pKeyDown) == EINA_TRUE)
1265 if ((pEvent->modifiers & ECORE_EVENT_MODIFIER_CTRL) || (pEvent->modifiers & ECORE_IMF_KEYBOARD_MODIFIER_ALT) || (pEvent->modifiers & ECORE_IMF_KEYBOARD_MODIFIER_WIN))
1270 if (!pEvent->compose)
1275 InputConnection* pInputConnection = GetInputConnection();
1276 String commitText(pEvent->compose);
1277 wchar_t commitChar= '\0';
1278 commitText.GetCharAt(0, commitChar);
1279 IInputConnectionEventListener* pListener = GetInputConnectionListener();
1280 IInputConnectionEventListenerF* pListenerF = GetInputConnectionListenerF();
1281 if (Character::IsAlphaNumeric(commitChar))
1285 pListener->OnInputConnectionTextCommitted( *pInputConnection, commitText);
1289 pListenerF->OnInputConnectionTextCommitted( *pInputConnection, commitText);
1292 if (commitText == L" " || commitText == L"\t")
1296 pListener->OnInputConnectionTextCommitted( *pInputConnection, commitText);
1300 pListenerF->OnInputConnectionTextCommitted( *pInputConnection, commitText);
1303 if (commitText == L"\n" || commitText == L"\r")
1307 pListener->OnInputConnectionTextCommitted( *pInputConnection, commitText);
1311 pListenerF->OnInputConnectionTextCommitted( *pInputConnection, commitText);
1314 if ( (commitChar >= 0x21 && commitChar <= 0x2F) || (commitChar >= 0x3A && commitChar <= 0x40) ||
1315 (commitChar >= 0x5B && commitChar <= 0x60) || (commitChar >= 0x7B && commitChar<= 0x7E) )
1319 pListener->OnInputConnectionTextCommitted( *pInputConnection, commitText);
1323 pListenerF->OnInputConnectionTextCommitted( *pInputConnection, commitText);
1335 SetLastResult(E_SUCCESS);
1341 _InputConnectionImpl::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
1343 if (__IsKeyEventSkipped)
1348 _KeyCode keyCode = keyInfo.GetKeyCode();
1349 if (keyCode == _KEY_OEM_1)
1354 Ecore_Event_Key* pEvent = static_cast<Ecore_Event_Key*>(keyInfo.GetUserData());
1355 SysTryReturn(NID_UI, pEvent, false, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1357 Ecore_IMF_Event_Key_Up* pKeyUp = (Ecore_IMF_Event_Key_Up*)malloc(sizeof(Ecore_IMF_Event_Key_Up));
1358 SysTryReturn(NID_UI, pKeyUp, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
1360 pKeyUp->keyname = pEvent->keyname;
1362 //need to check with SLP
1363 int modifiers = ECORE_IMF_KEYBOARD_MODIFIER_NONE;
1365 if (pEvent->modifiers & ECORE_EVENT_MODIFIER_SHIFT)
1367 modifiers |= ECORE_IMF_KEYBOARD_MODIFIER_SHIFT;
1369 if (pEvent->modifiers & ECORE_EVENT_MODIFIER_CTRL)
1371 modifiers |= ECORE_IMF_KEYBOARD_MODIFIER_CTRL;
1373 if (pEvent->modifiers & ECORE_EVENT_MODIFIER_ALT)
1375 modifiers |= ECORE_IMF_KEYBOARD_MODIFIER_ALT;
1377 if (pEvent->modifiers & ECORE_EVENT_MODIFIER_WIN)
1379 modifiers |= ECORE_IMF_KEYBOARD_MODIFIER_WIN;
1381 pKeyUp->modifiers = static_cast<Ecore_IMF_Keyboard_Modifiers>(modifiers);
1383 int locks = ECORE_IMF_KEYBOARD_LOCK_NONE;
1384 if (pEvent->modifiers & ECORE_EVENT_LOCK_SCROLL)
1386 locks |= ECORE_IMF_KEYBOARD_LOCK_SCROLL;
1388 if (pEvent->modifiers & ECORE_EVENT_LOCK_NUM)
1390 locks |= ECORE_IMF_KEYBOARD_LOCK_NUM;
1392 if (pEvent->modifiers & ECORE_EVENT_LOCK_CAPS)
1394 locks |= ECORE_IMF_KEYBOARD_LOCK_CAPS;
1396 pKeyUp->locks = static_cast<Ecore_IMF_Keyboard_Locks>(locks);
1398 pKeyUp->key = pEvent->key;
1399 pKeyUp->string = pEvent->string;
1400 pKeyUp->compose = pEvent->compose;
1401 pKeyUp->timestamp = pEvent->timestamp;
1403 const _Control* pControl = _ControlManager::GetInstance()->GetObject(__controlHandle);
1405 if (&source == pControl)
1407 if(CheckUSBKeyboardStatus() && pKeyUp->string)//usb keyboard exist
1409 const char* key = const_cast<char*>(pKeyUp->string);
1410 if(FilterKeyOnUSBMode(GetInputPanelStyle(), key) == E_SUCCESS)
1417 if (ecore_imf_context_filter_event(__pContext, ECORE_IMF_EVENT_KEY_UP, (Ecore_IMF_Event*)pKeyUp) == EINA_TRUE)
1427 SetLastResult(E_SUCCESS);
1433 _InputConnectionImpl::AddInputPanelCallback(void)
1435 ecore_imf_context_input_panel_event_callback_add(__pContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, OnInputPanelShowStateEvent, this);
1436 ecore_imf_context_input_panel_event_callback_add(__pContext, ECORE_IMF_INPUT_PANEL_LANGUAGE_EVENT, OnInputPanelLanguageEvent, this);
1437 ecore_imf_context_input_panel_event_callback_add(__pContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, OnInputPanelSizeChangedEvent, this);
1438 ecore_imf_context_input_panel_event_callback_add(__pContext, ECORE_IMF_CANDIDATE_PANEL_STATE_EVENT, OnInputPanelPredictionModeEvent, this);
1439 ecore_imf_context_input_panel_event_callback_add(__pContext, ECORE_IMF_CANDIDATE_PANEL_GEOMETRY_EVENT, OnInputPanelPredictionSizeChangedEvent, this);
1440 ecore_imf_context_retrieve_surrounding_callback_set(__pContext, OnRetrieveSurrounding, this);
1446 _InputConnectionImpl::AddEcoreEventCallback(void)
1448 ecore_imf_context_event_callback_add(__pContext, ECORE_IMF_CALLBACK_COMMIT, OnCommitTextEcoreEvent, this);
1449 ecore_imf_context_event_callback_add(__pContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, OnComposeTextEcoreEvent, this);
1450 ecore_imf_context_event_callback_add(__pContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, OnDeleteSurroundingTextEcoreEvent, this);
1453 //Internal USB Check
1454 Ecore_X_Window rootWindow = ecore_x_window_root_first_get();
1455 ecore_x_event_mask_set(rootWindow, ECORE_X_EVENT_MASK_WINDOW_PROPERTY);
1456 __pUSBEventHandler = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROPERTY, OnUSBKeyboardEcoreEvent, this);
1462 _InputConnectionImpl::AddEvasObjectEventCallback(void)
1464 result r = _UiEventManager::GetInstance()->AddTargetPostKeyEventListener(*this);
1465 SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1471 _InputConnectionImpl::RemoveInputPanelCallback(void)
1473 ecore_imf_context_input_panel_event_callback_del(__pContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, OnInputPanelShowStateEvent);
1474 ecore_imf_context_input_panel_event_callback_del(__pContext, ECORE_IMF_INPUT_PANEL_LANGUAGE_EVENT, OnInputPanelLanguageEvent);
1475 ecore_imf_context_input_panel_event_callback_del(__pContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, OnInputPanelSizeChangedEvent);
1476 ecore_imf_context_input_panel_event_callback_del(__pContext, ECORE_IMF_CANDIDATE_PANEL_STATE_EVENT, OnInputPanelPredictionModeEvent);
1477 ecore_imf_context_input_panel_event_callback_del(__pContext, ECORE_IMF_CANDIDATE_PANEL_GEOMETRY_EVENT, OnInputPanelPredictionSizeChangedEvent);
1483 _InputConnectionImpl::RemoveEcoreEventCallback(void)
1485 ecore_imf_context_event_callback_del(__pContext, ECORE_IMF_CALLBACK_COMMIT, OnCommitTextEcoreEvent);
1486 ecore_imf_context_event_callback_del(__pContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, OnComposeTextEcoreEvent);
1487 ecore_imf_context_event_callback_del(__pContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, OnDeleteSurroundingTextEcoreEvent);
1490 //Internal USB Check Release
1491 if (__pUSBEventHandler)
1493 ecore_event_handler_del(__pUSBEventHandler);
1494 __pUSBEventHandler = null;
1501 _InputConnectionImpl::RemoveEvasObjectEventCallback(void)
1503 result r = _UiEventManager::GetInstance()->RemoveTargetPostKeyEventListener(*this);
1504 SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1509 _InputConnectionImpl*
1510 _InputConnectionImpl::GetInstance(InputConnection& inputConnection)
1512 return inputConnection.__pInputConnectionImpl;
1514 const _InputConnectionImpl*
1515 _InputConnectionImpl::GetInstance(const InputConnection& inputConnection)
1517 return inputConnection.__pInputConnectionImpl;
1521 _InputConnectionImpl::CheckUSBKeyboardStatus(void)
1523 return _InputConnectionUtils::CheckUSBKeyboardStatus();
1527 _InputConnectionImpl::FilterKeyOnUSBMode(InputPanelStyle style, const char* key, bool commit)
1529 if(!(style == INPUT_PANEL_STYLE_NUMBER_ONLY || style == INPUT_PANEL_STYLE_PHONE_NUMBER || style == INPUT_PANEL_STYLE_IP))
1531 return E_INVALID_ARG;
1534 SysTryReturn(NID_UI, key, E_INVALID_ARG, E_INVALID_ARG, "key is null");
1536 char TempKey[20] = {0,};
1537 const char keyOnNumOnlyStyle[10] = { 0x30/*0*/, 0x31/*1*/, 0x32/*2*/, 0x33/*3*/, 0x34/*4*/, 0x35/*5*/, 0x36/*6*/, 0x37/*7*/, 0x38/*8*/, 0x39/*9*/};
1538 const char keyOnPhoneNumStyle[14] = { 0x30/*0*/, 0x31/*1*/, 0x32/*2*/, 0x33/*3*/, 0x34/*4*/, 0x35/*5*/, 0x36/*6*/, 0x37/*7*/, 0x38/*8*/, 0x39/*9*/,
1539 0x2a/***/, 0x2b/*+*/, 0x23/*#*/, 0x70/*p*/};
1540 const char keyOnIPStyle[18] = { 0x30/*0*/, 0x31/*1*/, 0x32/*2*/, 0x33/*3*/, 0x34/*4*/, 0x35/*5*/, 0x36/*6*/, 0x37/*7*/, 0x38/*8*/, 0x39/*9*/,
1541 0x3a/*:*/, 0x2e/*.*/, 0x61/*a*/, 0x62/*b*/, 0x63/*c*/, 0x64/*d*/, 0x65/*e*/, 0x66/*f*/};
1542 bool isExist = false;
1545 if(style == INPUT_PANEL_STYLE_NUMBER_ONLY)
1548 memcpy(TempKey, keyOnNumOnlyStyle, keyCount*sizeof(char));
1550 else if(style == INPUT_PANEL_STYLE_PHONE_NUMBER)
1553 memcpy(TempKey, keyOnPhoneNumStyle, keyCount*sizeof(char));
1555 else if(style == INPUT_PANEL_STYLE_IP)
1558 memcpy(TempKey, keyOnIPStyle, keyCount*sizeof(char));
1561 for (int i = 0; i < keyCount ; i++)
1563 if(TempKey[i] == key[0])
1570 if (isExist == true && commit == true)
1572 String commitText(key);
1573 if (commitText.GetLength() > 1)
1577 InputConnection* pInputConnection = GetInputConnection();
1578 IInputConnectionEventListener* pListener = GetInputConnectionListener();
1579 IInputConnectionEventListenerF* pListenerF = GetInputConnectionListenerF();
1582 pListener->OnInputConnectionTextCommitted( *pInputConnection, commitText);
1586 pListenerF->OnInputConnectionTextCommitted( *pInputConnection, commitText);
1594 _InputConnectionImpl::SetKeyEventSkipped(bool enabled)
1596 __IsKeyEventSkipped = enabled;