2 // Open Service Platform
\r
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
\r
5 // Licensed under the Apache License, Version 2.0 (the License);
\r
6 // you may not use this file except in compliance with the License.
\r
7 // You may obtain a copy of the License at
\r
9 // http://www.apache.org/licenses/LICENSE-2.0
\r
11 // Unless required by applicable law or agreed to in writing, software
\r
12 // distributed under the License is distributed on an "AS IS" BASIS,
\r
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
14 // See the License for the specific language governing permissions and
\r
15 // limitations under the License.
\r
19 * @file FUiIme_InputServiceSignalListener.cpp
\r
20 * @brief This is the implementation file for the %_InputServiceSignalListener class.
\r
22 * This implementation file contains definition of the %_InputServiceSignalListener class.
\r
25 #include <Ecore_IMF.h>
\r
27 #include <FAppApp.h>
\r
28 #include <FBaseString.h>
\r
29 #include <FBaseSysLog.h>
\r
30 #include <FGrpRectangle.h>
\r
31 #include <FUiInputConnectionTypes.h>
\r
33 #include "FUiIme_InputMethodImpl.h"
\r
34 #include "FUiIme_InputServiceSignalListener.h"
\r
35 #include "FUiIme_ScimDataConverter.h"
\r
37 using namespace Tizen::Base;
\r
38 using namespace Tizen::Graphics;
\r
39 using namespace Tizen::Ui;
\r
41 namespace Tizen { namespace Ui { namespace Ime {
\r
43 IInputMethodProvider* _InputServiceSignalListener::__pIInputMethodProvider = null;
\r
44 IInputMethodListener* _InputServiceSignalListener::__pIInputMethodListener = null;
\r
46 _InputServiceSignalListener::_InputServiceSignalListener()
\r
50 _InputServiceSignalListener::~_InputServiceSignalListener()
\r
52 __pIInputMethodProvider = null;
\r
53 __pIInputMethodListener = null;
\r
57 _InputServiceSignalListener::SetInputMethodProvider(IInputMethodProvider* pProvider)
\r
59 __pIInputMethodProvider = pProvider;
\r
65 _InputServiceSignalListener::SetInputMethodListener(IInputMethodListener* pListener)
\r
67 __pIInputMethodListener = pListener;
\r
73 _InputServiceSignalListener::GetEnterKeyAction(const scim::HelperAgent* pHelperAgent, scim::uint32& action)
\r
75 SysTryReturnVoidResult(NID_UI_IME, __pIInputMethodProvider, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist.");
\r
77 InputPanelAction inputPanelAction = __pIInputMethodProvider->GetEnterKeyAction();
\r
78 SysTryReturnVoidResult(NID_UI_IME, (inputPanelAction >= INPUT_PANEL_ACTION_ENTER) && (inputPanelAction <= INPUT_PANEL_ACTION_DONE), E_INVALID_DATA, "[E_INVALID_DATA] A requested data is invalid.");
\r
80 switch (inputPanelAction)
\r
82 case INPUT_PANEL_ACTION_ENTER:
\r
83 action = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
\r
85 case INPUT_PANEL_ACTION_DONE:
\r
86 action = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE;
\r
88 case INPUT_PANEL_ACTION_GO:
\r
89 action = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_GO;
\r
91 case INPUT_PANEL_ACTION_JOIN:
\r
92 action = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_JOIN;
\r
94 case INPUT_PANEL_ACTION_LOGIN:
\r
95 action = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_LOGIN;
\r
97 case INPUT_PANEL_ACTION_NEXT:
\r
98 action = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT;
\r
100 case INPUT_PANEL_ACTION_SEARCH:
\r
101 action = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH;
\r
103 case INPUT_PANEL_ACTION_SEND:
\r
104 action = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEND;
\r
107 action = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
\r
115 _InputServiceSignalListener::GetInputPanelBounds(const scim::HelperAgent* pHelperAgent, struct scim::rectinfo& bounds)
\r
117 SysTryReturnVoidResult(NID_UI_IME, __pIInputMethodProvider, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist.");
\r
119 SysLog(NID_UI_IME, "The bounds of the input panel have been requested.");
\r
121 Rectangle inputPanelBounds = __pIInputMethodProvider->GetInputPanelBounds();
\r
123 _ScimDataConverter converter;
\r
124 converter.ConvertRectangle(inputPanelBounds, bounds);
\r
130 _InputServiceSignalListener::GetInputPanelStyle(const scim::HelperAgent* pHelperAgent, scim::uint32& style)
\r
132 SysTryReturnVoidResult(NID_UI_IME, __pIInputMethodProvider, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist.");
\r
134 InputPanelStyle inputPanelStyle = __pIInputMethodProvider->GetInputPanelStyle();
\r
135 SysTryReturnVoidResult(NID_UI_IME, (inputPanelStyle >= INPUT_PANEL_STYLE_NORMAL) && (inputPanelStyle <= INPUT_PANEL_STYLE_IP), E_INVALID_DATA, "[E_INVALID_DATA] A requested data is invalid.");
\r
137 switch (inputPanelStyle)
\r
139 case INPUT_PANEL_STYLE_NORMAL:
\r
140 style = ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL;
\r
142 case INPUT_PANEL_STYLE_EMAIL:
\r
143 style = ECORE_IMF_INPUT_PANEL_LAYOUT_EMAIL;
\r
145 case INPUT_PANEL_STYLE_IP:
\r
146 style = ECORE_IMF_INPUT_PANEL_LAYOUT_IP;
\r
148 case INPUT_PANEL_STYLE_NUMBER:
\r
149 style = ECORE_IMF_INPUT_PANEL_LAYOUT_NUMBERONLY;
\r
151 case INPUT_PANEL_STYLE_PHONE_NUMBER:
\r
152 style = ECORE_IMF_INPUT_PANEL_LAYOUT_PHONENUMBER;
\r
154 case INPUT_PANEL_STYLE_URL:
\r
155 style = ECORE_IMF_INPUT_PANEL_LAYOUT_URL;
\r
158 style = ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL;
\r
166 _InputServiceSignalListener::SetCapsModeEnabled(const scim::HelperAgent* pHelperAgent, scim::uint32& mode)
\r
168 SysTryReturnVoidResult(NID_UI_IME, __pIInputMethodProvider, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist.");
\r
170 bool enable = (mode != 0 ? true : false);
\r
172 __pIInputMethodProvider->SetCapsModeEnabled(enable);
\r
178 _InputServiceSignalListener::SetEnterKeyAction(const scim::HelperAgent* pHelperAgent, scim::uint32& action)
\r
180 SysTryReturnVoidResult(NID_UI_IME, __pIInputMethodProvider, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist.");
\r
181 SysTryReturnVoidResult(NID_UI_IME, action <= ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEND, E_INVALID_ARG,
\r
182 "[E_INVALID_ARG] Invalid argument(s) is used. The enter key action is beyond the scope.");
\r
184 InputPanelAction inputPanelAction;
\r
188 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT:
\r
189 inputPanelAction = INPUT_PANEL_ACTION_ENTER;
\r
191 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE:
\r
192 inputPanelAction = INPUT_PANEL_ACTION_DONE;
\r
194 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_GO:
\r
195 inputPanelAction = INPUT_PANEL_ACTION_GO;
\r
197 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_JOIN:
\r
198 inputPanelAction = INPUT_PANEL_ACTION_JOIN;
\r
200 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_LOGIN:
\r
201 inputPanelAction = INPUT_PANEL_ACTION_LOGIN;
\r
203 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT:
\r
204 inputPanelAction = INPUT_PANEL_ACTION_NEXT;
\r
206 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH:
\r
207 inputPanelAction = INPUT_PANEL_ACTION_SEARCH;
\r
209 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEND:
\r
210 inputPanelAction = INPUT_PANEL_ACTION_SEND;
\r
213 inputPanelAction = INPUT_PANEL_ACTION_ENTER;
\r
217 __pIInputMethodProvider->SetEnterKeyAction(inputPanelAction);
\r
223 _InputServiceSignalListener::SetEnterKeyActionEnabled(const scim::HelperAgent* pHelperAgent, scim::uint32& disable)
\r
225 SysTryReturnVoidResult(NID_UI_IME, __pIInputMethodProvider, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist.");
\r
227 bool enable = (disable != 0 ? false : true);
\r
229 __pIInputMethodProvider->SetEnterKeyActionEnabled(enable);
\r
235 _InputServiceSignalListener::SetInputPanelStyle(const scim::HelperAgent* pHelperAgent, scim::uint32& style)
\r
237 SysTryReturnVoidResult(NID_UI_IME, __pIInputMethodProvider, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist.");
\r
238 SysTryReturnVoidResult(NID_UI_IME, style < ECORE_IMF_INPUT_PANEL_LAYOUT_INVALID, E_INVALID_ARG,
\r
239 "[E_INVALID_ARG] Invalid argument(s) is used. The input panel style is beyond the scope.");
\r
241 InputPanelStyle inputPanelStyle;
\r
245 case ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL:
\r
246 inputPanelStyle = INPUT_PANEL_STYLE_NORMAL;
\r
248 case ECORE_IMF_INPUT_PANEL_LAYOUT_EMAIL:
\r
249 inputPanelStyle = INPUT_PANEL_STYLE_EMAIL;
\r
251 case ECORE_IMF_INPUT_PANEL_LAYOUT_IP:
\r
252 inputPanelStyle = INPUT_PANEL_STYLE_IP;
\r
254 case ECORE_IMF_INPUT_PANEL_LAYOUT_NUMBERONLY:
\r
255 inputPanelStyle = INPUT_PANEL_STYLE_NUMBER;
\r
257 case ECORE_IMF_INPUT_PANEL_LAYOUT_PHONENUMBER:
\r
258 inputPanelStyle = INPUT_PANEL_STYLE_PHONE_NUMBER;
\r
260 case ECORE_IMF_INPUT_PANEL_LAYOUT_URL:
\r
261 inputPanelStyle = INPUT_PANEL_STYLE_URL;
\r
264 inputPanelStyle = INPUT_PANEL_STYLE_NORMAL;
\r
268 __pIInputMethodProvider->SetInputPanelStyle(inputPanelStyle);
\r
274 _InputServiceSignalListener::SetLanguage(const scim::HelperAgent* pHelperAgent, scim::uint32& language)
\r
276 SysTryReturnVoidResult(NID_UI_IME, __pIInputMethodProvider, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist.");
\r
278 Tizen::Locales::LanguageCode languageCode = (language == ECORE_IMF_INPUT_PANEL_LANG_ALPHABET ? Tizen::Locales::LANGUAGE_ENG : Tizen::Locales::LANGUAGE_INVALID);
\r
280 if (languageCode == Tizen::Locales::LANGUAGE_INVALID)
\r
285 //__pIInputMethodProvider->SetLanguage(languageCode);
\r
291 _InputServiceSignalListener::HideInputPanel(const scim::HelperAgent* pHelperAgent, int inputContext, const scim::String& uuid)
\r
293 SysTryReturnVoidResult(NID_UI_IME, __pIInputMethodProvider, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist.");
\r
295 SysLog(NID_UI_IME, "Hiding the input panel has been requested.");
\r
297 __pIInputMethodProvider->HideInputPanel();
\r
303 _InputServiceSignalListener::IsEnterKeyActionEnabled(const scim::HelperAgent* pHelperAgent, scim::uint32& enable)
\r
305 SysTryReturnVoidResult(NID_UI_IME, __pIInputMethodProvider, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist.");
\r
307 enable = static_cast<scim::uint32>(__pIInputMethodProvider->IsEnterKeyActionEnabled());
\r
313 _InputServiceSignalListener::ShowInputPanel(const scim::HelperAgent* pHelperAgent, int inputContext, char* pBuffer, size_t& length)
\r
315 SysTryReturnVoidResult(NID_UI_IME, __pIInputMethodProvider, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist.");
\r
317 SysLog(NID_UI_IME, "Showing the input panel has been requested.");
\r
319 __pIInputMethodProvider->ShowInputPanel();
\r
325 _InputServiceSignalListener::OnCursorPositionChanged(const scim::HelperAgent* pHelperAgent, int inputContext, const scim::String& uuid, int position)
\r
327 SysTryReturnVoidResult(NID_UI_IME, __pIInputMethodListener, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist.");
\r
329 __pIInputMethodListener->OnCursorPositionChanged(position);
\r
335 _InputServiceSignalListener::OnSurroundingTextReceived(const scim::HelperAgent* pHelperAgent, int inputContext, const scim::String& text, int cursorPosition)
\r
337 SysTryReturnVoidResult(NID_UI_IME, __pIInputMethodListener, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The required instance does not exist.");
\r
341 _ScimDataConverter converter;
\r
342 converter.ConvertString(text, ospText);
\r
344 __pIInputMethodListener->OnSurroundingTextReceived(ospText, cursorPosition);
\r
350 _InputServiceSignalListener::OnTerminate (const scim::HelperAgent* pHelperAgent, int inputContext, const scim::String& uuid)
\r
352 Tizen::App::App::GetInstance()->Terminate();
\r
357 }}} // Tizen::Ui::Ime
\r