2 * Copyright (c) 2015-2021 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
24 #include <privilege_checker_private.h>
25 #include "inputmethod_private.h"
26 #include <inputmethod.h>
27 #include "inputmethod_internal.h"
34 #define LOG_TAG "INPUTMETHOD"
38 class CCoreEventCallback : public ISCLCoreEventCallback
41 void on_run(int argc, char **argv);
43 void on_update_cursor_position(sclint ic, const sclchar *ic_uuid, sclint cursor_pos);
44 void on_update_surrounding_text(sclint ic, const sclchar *text, sclint cursor);
45 void on_focus_out(sclint ic, const sclchar *ic_uuid);
46 void on_focus_in(sclint ic, const sclchar *ic_uuid);
47 void on_ise_show(sclint ic, const int degree, Ise_Context &context);
48 void on_ise_hide(sclint ic, const sclchar *ic_uuid);
49 void on_get_geometry(sclu32 *pos_x, sclu32 *pos_y, sclu32 *width, sclu32 *height);
50 void on_set_language(sclu32 language);
51 void on_set_imdata(sclchar *buf, sclu32 len);
52 void on_get_imdata(sclchar **buf, sclu32 *len);
53 void on_get_language_locale(sclint ic, sclchar **locale);
54 void on_set_return_key_type(sclu32 type);
55 void on_set_return_key_disable(sclu32 disabled);
56 void on_set_layout(sclu32 layout);
57 void on_reset_input_context(sclint ic, const sclchar *uuid);
58 void on_process_key_event(scim::KeyEvent &key, sclu32 *ret);
59 void on_process_key_event_with_keycode(scim::KeyEvent &key, sclu32 *ret, sclu32 keycode);
60 void on_set_display_language(const sclchar *language);
61 void on_set_rotation_degree(sclint degree);
62 void on_set_accessibility_state(sclboolean state);
63 void on_create_option_window(sclwindow window, SCLOptionWindowType type);
64 void on_destroy_option_window(sclwindow window);
65 void on_check_option_window_availability(sclboolean *ret);
66 void on_set_caps_mode(sclu32 mode);
67 void on_candidate_show(sclint ic, const sclchar *ic_uuid);
68 void on_candidate_hide(sclint ic, const sclchar *ic_uuid);
69 void on_update_lookup_table(SclCandidateTable &table);
70 void on_process_input_device_event(sclu32 &type, sclchar *data, size_t &len, sclu32 *ret);
71 void on_set_prediction_hint(const sclchar *prediction_hint);
72 void on_set_mime_type(const sclchar *mime_type);
73 void on_set_prediction_hint_data(const sclchar *key, const sclchar *value);
74 void on_set_optimization_hint(sclu32 hint);
75 void on_process_key_event_with_imengine(scim::KeyEvent &key, sclu32 serial);
76 void on_set_autocapital_type(sclu32 type);
77 void on_set_prediction_allow(sclu32 prediction_allow);
78 void on_trigger_property(const sclchar *property);
79 void on_candidate_more_window_show(sclint ic, const sclchar *uuid);
80 void on_candidate_more_window_hide(sclint ic, const sclchar *uuid);
81 void on_select_aux(sclint ic, const sclchar *uuid, sclint index);
82 void on_select_candidate(sclint ic, const sclchar *uuid, sclint index);
83 void on_candidate_table_page_up(sclint ic, const sclchar *uuid);
84 void on_candidate_table_page_down(sclint ic, const sclchar *uuid);
85 void on_update_candidate_table_page_size(sclint ic, const sclchar *uuid, sclint page_size);
86 void on_update_candidate_item_layout(const std::vector<sclu32> item);
87 void on_update_displayed_candidate_number(sclu32 size);
88 void on_longpress_candidate(sclu32 index);
89 void on_set_input_hint(sclu32 input_hint);
94 ime_focus_in_cb focus_in; /**< Called when an edit field has focus */
95 ime_focus_out_cb focus_out; /**< Called when an edit field loses focus */
96 ime_surrounding_text_updated_cb surrounding_text_updated; /**< Called when an edit field responds to a request with the surrounding text */
97 ime_input_context_reset_cb input_context_reset; /**< Called to reset the input context of an edit field */
98 ime_cursor_position_updated_cb cursor_position_updated; /**< Called when the position of the cursor in an edit field changes */
99 ime_language_requested_cb language_requested; /**< Called when an edit field requests the language from the input panel */
100 ime_language_set_cb language_set; /**< Called to set the preferred language to the input panel */
101 ime_imdata_set_cb imdata_set; /**< Called to set the application specific data to deliver to the input panel */
102 ime_imdata_requested_cb imdata_requested; /**< Called when an associated text input UI control requests the application specific data from the input panel */
103 ime_layout_set_cb layout_set; /**< Called when an edit field requests the input panel to set its layout */
104 ime_return_key_type_set_cb return_key_type_set; /**< Called when an edit field requests the input panel to set the "return" key label */
105 ime_return_key_state_set_cb return_key_state_set; /**< Called when an edit field requests the input panel to enable or disable the "return" key state */
106 ime_geometry_requested_cb geometry_requested; /**< Called when an edit field requests the position and size from the input panel */
107 ime_process_key_event_cb process_key_event; /**< Called when the key event is received from the external keyboard devices */
108 ime_process_key_event_with_keycode_cb process_key_event_with_keycode; /**< Called when the key event is received from the external keyboard devices */
109 ime_display_language_changed_cb display_language_changed; /**< Called when the system display language is changed */
110 ime_rotation_degree_changed_cb rotation_degree_changed; /**< Called when the device is rotated */
111 ime_accessibility_state_changed_cb accessibility_state_changed; /**< Called when Accessibility in Settings application is on or off */
112 ime_option_window_created_cb option_window_created; /**< Called to create the option window */
113 ime_option_window_destroyed_cb option_window_destroyed; /**< Called to destroy the option window */
114 ime_caps_mode_changed_cb caps_mode_changed;
115 ime_candidate_show_cb candidate_show;
116 ime_candidate_hide_cb candidate_hide;
117 ime_lookup_table_changed_cb lookup_table_changed;
118 ime_process_input_device_event_cb process_input_device_event; /**< Called when the event is received from the unconventional input devices */
119 ime_prediction_hint_set_cb prediction_hint_set;
120 ime_mime_type_set_request_cb mime_type_set;
121 ime_prediction_hint_data_set_cb prediction_hint_data_set;
122 ime_optimization_hint_set_cb optimization_hint_set;
123 ime_process_key_event_with_imengine_cb process_key_event_with_imengine;
124 ime_autocapital_type_set_cb autocapital_type_set;
125 ime_prediction_allow_set_cb prediction_allow_set;
126 ime_trigger_property_set_cb trigger_property_set;
127 ime_candidate_more_window_show_cb candidate_more_window_show;
128 ime_candidate_more_window_hide_cb candidate_more_window_hide;
129 ime_aux_select_cb aux_select;
130 ime_candidate_select_cb candidate_select;
131 ime_candidate_table_page_up_cb candidate_table_page_up;
132 ime_candidate_table_page_down_cb candidate_table_page_down;
133 ime_candidate_table_page_size_chaned_cb candidate_table_page_size_chaned;
134 ime_candidate_item_layout_set_cb candidate_item_layout_set;
135 ime_displayed_candidate_number_chaned_cb displayed_candidate_number_chaned;
136 ime_candidate_item_long_pressed_cb candidate_item_long_pressed;
137 ime_input_hint_set_cb input_hint_set; /**< Called when an edit field requests the input panel to set its input hint */
138 void *focus_in_user_data;
139 void *focus_out_user_data;
140 void *surrounding_text_updated_user_data;
141 void *input_context_reset_user_data;
142 void *cursor_position_updated_user_data;
143 void *language_requested_user_data;
144 void *language_set_user_data;
145 void *imdata_set_user_data;
146 void *imdata_requested_user_data;
147 void *layout_set_user_data;
148 void *return_key_type_set_user_data;
149 void *return_key_state_set_user_data;
150 void *geometry_requested_user_data;
151 void *process_key_event_user_data;
152 void *process_key_event_with_keycode_user_data;
153 void *display_language_changed_user_data;
154 void *rotation_degree_changed_user_data;
155 void *accessibility_state_changed_user_data;
156 void *option_window_created_user_data;
157 void *option_window_destroyed_user_data;
158 void *caps_mode_changed_user_data;
159 void *candidate_show_user_data;
160 void *candidate_hide_user_data;
161 void *lookup_table_changed_user_data;
162 void *process_input_device_event_user_data;
163 void *prediction_hint_set_user_data;
164 void *mime_type_set_user_data;
165 void *prediction_hint_data_set_user_data;
166 void *optimization_hint_set_user_data;
167 void *process_key_event_with_imengine_user_data;
168 void *autocapital_type_set_user_data;
169 void *prediction_allow_set_user_data;
170 void *trigger_property_set_user_data;
171 void *candidate_more_window_show_user_data;
172 void *candidate_more_window_hide_user_data;
173 void *aux_select_user_data;
174 void *candidate_select_user_data;
175 void *candidate_table_page_up_user_data;
176 void *candidate_table_page_down_user_data;
177 void *candidate_table_page_size_chaned_user_data;
178 void *candidate_item_layout_set_user_data;
179 void *displayed_candidate_number_chaned_user_data;
180 void *candidate_item_long_pressed_user_data;
181 void *input_hint_set_user_data;
182 } ime_event_callback_s;
185 ime_input_device_type_e device_type;
187 } ime_device_event_s;
189 static ime_callback_s g_basic_callback = {NULL};
190 static ime_event_callback_s g_event_callback = {NULL};
191 static void *g_user_data = NULL;
192 static bool g_running = false;
194 static CCoreEventCallback g_core_event_callback;
195 CSCLCore g_core(&g_core_event_callback);
197 static bool g_checked_privilege = false;
198 static bool g_permission_allowed = false;
201 extern void ime_app_main(int argc, char **argv);
205 void CCoreEventCallback::on_init()
207 if (g_basic_callback.create) {
208 g_basic_callback.create(g_user_data);
212 void CCoreEventCallback::on_run(int argc, char **argv)
215 ime_app_main(argc, argv);
218 void CCoreEventCallback::on_exit()
221 if (g_basic_callback.terminate) {
222 g_basic_callback.terminate(g_user_data);
226 void CCoreEventCallback::on_update_cursor_position(sclint ic, const sclchar *ic_uuid, sclint cursor_pos)
228 if (g_event_callback.cursor_position_updated) {
229 g_event_callback.cursor_position_updated(cursor_pos, g_event_callback.cursor_position_updated_user_data);
233 void CCoreEventCallback::on_update_surrounding_text(sclint ic, const sclchar *text, sclint cursor)
235 if (g_event_callback.surrounding_text_updated) {
236 g_event_callback.surrounding_text_updated(ic, text, cursor, g_event_callback.surrounding_text_updated_user_data);
240 void CCoreEventCallback::on_focus_out(sclint ic, const sclchar *ic_uuid)
242 if (g_event_callback.focus_out) {
243 g_event_callback.focus_out(ic, g_event_callback.focus_out_user_data);
247 void CCoreEventCallback::on_focus_in(sclint ic, const sclchar *ic_uuid)
249 if (g_event_callback.focus_in) {
250 g_event_callback.focus_in(ic, g_event_callback.focus_in_user_data);
254 void CCoreEventCallback::on_ise_show(sclint ic, const int degree, Ise_Context &context)
256 if (g_basic_callback.show) {
257 struct _ime_context input_context;
259 memset(&input_context, 0, sizeof(struct _ime_context));
260 input_context.layout = context.layout;
261 input_context.layout_variation = context.layout_variation;
262 input_context.cursor_pos = context.cursor_pos;
263 input_context.autocapital_type = context.autocapital_type;
264 input_context.return_key_type = context.return_key_type;
265 input_context.return_key_disabled = context.return_key_disabled;
266 input_context.prediction_allow = context.prediction_allow;
267 input_context.password_mode = context.password_mode;
268 input_context.imdata_size = context.imdata_size;
269 input_context.input_hint = context.input_hint;
270 input_context.bidi_direction = context.bidi_direction;
271 input_context.language = context.language;
272 input_context.client_window = context.client_window;
273 input_context.caps_mode = context.caps_mode;
275 g_basic_callback.show(ic, static_cast<ime_context_h>(&input_context), g_user_data);
279 void CCoreEventCallback::on_ise_hide(sclint ic, const sclchar *ic_uuid)
281 if (g_basic_callback.hide) {
282 g_basic_callback.hide(ic, g_user_data);
286 void CCoreEventCallback::on_get_geometry(sclu32 *pos_x, sclu32 *pos_y, sclu32 *width, sclu32 *height)
288 int geometry_pos_x = 0;
289 int geometry_pos_y = 0;
290 int geometry_width = 0;
291 int geometry_height = 0;
293 if (g_event_callback.geometry_requested) {
294 g_event_callback.geometry_requested(g_event_callback.geometry_requested_user_data, &geometry_pos_x, &geometry_pos_y, &geometry_width, &geometry_height);
298 *pos_x = geometry_pos_x;
301 *pos_y = geometry_pos_y;
304 *width = geometry_width;
307 *height = geometry_height;
310 void CCoreEventCallback::on_set_language(sclu32 language)
312 if (g_event_callback.language_set) {
313 g_event_callback.language_set((Ecore_IMF_Input_Panel_Lang)language, g_event_callback.language_set_user_data);
317 void CCoreEventCallback::on_set_imdata(sclchar *buf, sclu32 len)
319 if (g_event_callback.imdata_set) {
320 g_event_callback.imdata_set((void *)buf, len, g_event_callback.imdata_set_user_data);
324 void CCoreEventCallback::on_get_imdata(sclchar **buf, sclu32 *len)
326 if (g_event_callback.imdata_requested) {
327 g_event_callback.imdata_requested(g_event_callback.imdata_set_user_data, (void **)buf, len);
331 void CCoreEventCallback::on_get_language_locale(sclint ic, sclchar **locale)
333 if (g_event_callback.language_requested) {
334 g_event_callback.language_requested(g_event_callback.language_requested_user_data, locale);
338 void CCoreEventCallback::on_set_return_key_type(sclu32 type)
340 if (g_event_callback.return_key_type_set) {
341 g_event_callback.return_key_type_set((Ecore_IMF_Input_Panel_Return_Key_Type)type, g_event_callback.return_key_type_set_user_data);
345 void CCoreEventCallback::on_set_return_key_disable(sclu32 disabled)
347 bool return_key_disabled = !!disabled;
349 if (g_event_callback.return_key_state_set) {
350 g_event_callback.return_key_state_set(return_key_disabled, g_event_callback.return_key_state_set_user_data);
354 void CCoreEventCallback::on_set_layout(sclu32 layout)
356 if (g_event_callback.layout_set) {
357 g_event_callback.layout_set(static_cast<Ecore_IMF_Input_Panel_Layout>(layout), g_event_callback.layout_set_user_data);
361 void CCoreEventCallback::on_set_input_hint(sclu32 input_hint)
363 if (g_event_callback.input_hint_set) {
364 g_event_callback.input_hint_set(static_cast<Ecore_IMF_Input_Hints>(input_hint), g_event_callback.input_hint_set_user_data);
368 void CCoreEventCallback::on_reset_input_context(sclint ic, const sclchar *uuid)
370 if (g_event_callback.input_context_reset) {
371 g_event_callback.input_context_reset(g_event_callback.input_context_reset_user_data);
375 void CCoreEventCallback::on_process_key_event(scim::KeyEvent &key, sclu32 *ret)
377 if (g_event_callback.process_key_event) {
378 struct _ime_device_info dev_info = {key.dev_name.c_str(),
379 static_cast<Ecore_IMF_Device_Class>(key.dev_class), static_cast<Ecore_IMF_Device_Subclass>(key.dev_subclass)};
380 bool processed = g_event_callback.process_key_event(static_cast<ime_key_code_e>(key.code), static_cast<ime_key_mask_e>(key.mask),
381 static_cast<ime_device_info_h>(&dev_info), g_event_callback.process_key_event_user_data);
396 void CCoreEventCallback::on_process_key_event_with_keycode(scim::KeyEvent &key, sclu32 *ret, sclu32 keycode)
398 if (g_event_callback.process_key_event_with_keycode) {
399 struct _ime_device_info dev_info = {key.dev_name.c_str(),
400 static_cast<Ecore_IMF_Device_Class>(key.dev_class), static_cast<Ecore_IMF_Device_Subclass>(key.dev_subclass)};
401 bool processed = g_event_callback.process_key_event_with_keycode(keycode, static_cast<ime_key_code_e>(key.code), static_cast<ime_key_mask_e>(key.mask),
402 static_cast<ime_device_info_h>(&dev_info), g_event_callback.process_key_event_user_data);
417 void CCoreEventCallback::on_set_display_language(const sclchar *language)
419 if (g_event_callback.display_language_changed) {
420 g_event_callback.display_language_changed(language, g_event_callback.display_language_changed_user_data);
424 void CCoreEventCallback::on_set_rotation_degree(sclint degree)
426 if (g_event_callback.rotation_degree_changed) {
427 g_event_callback.rotation_degree_changed(degree, g_event_callback.rotation_degree_changed_user_data);
431 void CCoreEventCallback::on_set_accessibility_state(sclboolean state)
433 if (g_event_callback.accessibility_state_changed) {
434 g_event_callback.accessibility_state_changed(state, g_event_callback.accessibility_state_changed_user_data);
438 void CCoreEventCallback::on_create_option_window(sclwindow window, SCLOptionWindowType type)
440 if (g_event_callback.option_window_created) {
441 g_event_callback.option_window_created(static_cast<Evas_Object*>(window), static_cast<ime_option_window_type_e>(type), g_event_callback.option_window_created_user_data);
445 void CCoreEventCallback::on_destroy_option_window(sclwindow window)
447 if (g_event_callback.option_window_destroyed) {
448 g_event_callback.option_window_destroyed(static_cast<Evas_Object*>(window), g_event_callback.option_window_destroyed_user_data);
452 void CCoreEventCallback::on_check_option_window_availability(sclboolean *ret)
455 if (g_event_callback.option_window_created) // Instead of each 3rd party keyboard, inputmethod will reply the availability of the option (setting).
462 void CCoreEventCallback::on_set_caps_mode(sclu32 mode)
464 if (g_event_callback.caps_mode_changed) {
465 g_event_callback.caps_mode_changed(mode, g_event_callback.caps_mode_changed_user_data);
469 void CCoreEventCallback::on_candidate_show(sclint ic, const sclchar *ic_uuid)
471 if (g_event_callback.candidate_show) {
472 g_event_callback.candidate_show(ic, g_event_callback.candidate_show_user_data);
476 void CCoreEventCallback::on_candidate_hide(sclint ic, const sclchar *ic_uuid)
478 if (g_event_callback.candidate_hide) {
479 g_event_callback.candidate_hide(ic, g_event_callback.candidate_hide_user_data);
483 void CCoreEventCallback::on_update_lookup_table(SclCandidateTable &table)
485 Eina_List *string_list = NULL;
487 if (g_event_callback.lookup_table_changed) {
488 vector<string>::iterator iter = table.candidate.begin();
489 for (; iter != table.candidate.end(); ++iter) {
490 string_list = eina_list_append(string_list, iter->c_str());
493 g_event_callback.lookup_table_changed(string_list, g_event_callback.lookup_table_changed_user_data);
497 void CCoreEventCallback::on_process_input_device_event(sclu32 &type, sclchar *data, size_t &len, sclu32 *ret)
501 ime_input_device_type_e device_type;
502 } ime_device_type_conv_table;
504 ime_device_type_conv_table conv_table[] = {
505 { ECORE_EVENT_DETENT_ROTATE , IME_INPUT_DEVICE_TYPE_ROTARY },
508 ime_input_device_type_e device_type = IME_INPUT_DEVICE_TYPE_UNKNOWN;
509 for (unsigned int loop = 0; loop < sizeof(conv_table) / sizeof(ime_device_type_conv_table); loop++) {
510 if ((unsigned int)(conv_table[loop].ecore_event_id) == type) {
511 device_type = conv_table[loop].device_type;
515 if (g_event_callback.process_input_device_event) {
516 ime_device_event_s device_event;
517 device_event.device_type = device_type;
518 device_event.event_data = static_cast<void*>(data);
519 void *input_data = static_cast<void*>(&device_event);
520 void *user_data = g_event_callback.process_input_device_event_user_data;
522 g_event_callback.process_input_device_event(device_type, input_data, user_data);
534 void CCoreEventCallback::on_set_prediction_hint(const sclchar *prediction_hint)
536 if (g_event_callback.prediction_hint_set) {
537 g_event_callback.prediction_hint_set(prediction_hint, g_event_callback.prediction_hint_set_user_data);
541 void CCoreEventCallback::on_set_mime_type(const sclchar *mime_type)
543 if (g_event_callback.mime_type_set) {
544 g_event_callback.mime_type_set(mime_type, g_event_callback.mime_type_set_user_data);
548 void CCoreEventCallback::on_set_prediction_hint_data(const sclchar *key, const sclchar *value)
550 if (g_event_callback.prediction_hint_data_set) {
551 g_event_callback.prediction_hint_data_set(key, value, g_event_callback.prediction_hint_data_set_user_data);
555 void CCoreEventCallback::on_set_optimization_hint(sclu32 hint)
557 if (g_event_callback.optimization_hint_set) {
558 g_event_callback.optimization_hint_set((ime_optimization_hint_e)hint, g_event_callback.optimization_hint_set_user_data);
562 void CCoreEventCallback::on_process_key_event_with_imengine(scim::KeyEvent &key, sclu32 serial)
564 if (g_event_callback.process_key_event_with_imengine) {
565 g_event_callback.process_key_event_with_imengine(key, serial, g_event_callback.process_key_event_with_imengine_user_data);
569 void CCoreEventCallback::on_set_autocapital_type(sclu32 type)
571 if (g_event_callback.autocapital_type_set) {
572 g_event_callback.autocapital_type_set(type, g_event_callback.autocapital_type_set_user_data);
576 void CCoreEventCallback::on_set_prediction_allow(sclu32 prediction_allow)
578 if (g_event_callback.prediction_allow_set) {
579 g_event_callback.prediction_allow_set(prediction_allow, g_event_callback.prediction_allow_set_user_data);
583 void CCoreEventCallback::on_trigger_property(const sclchar *property)
585 if (g_event_callback.trigger_property_set) {
586 g_event_callback.trigger_property_set(property, g_event_callback.trigger_property_set_user_data);
590 void CCoreEventCallback::on_candidate_more_window_show(sclint ic, const sclchar *uuid)
592 if (g_event_callback.candidate_more_window_show) {
593 g_event_callback.candidate_more_window_show(g_event_callback.candidate_more_window_show_user_data);
597 void CCoreEventCallback::on_candidate_more_window_hide(sclint ic, const sclchar *uuid)
599 if (g_event_callback.candidate_more_window_hide) {
600 g_event_callback.candidate_more_window_hide(g_event_callback.candidate_more_window_hide_user_data);
604 void CCoreEventCallback::on_select_aux(sclint ic, const sclchar *uuid, sclint index)
606 if (g_event_callback.aux_select) {
607 g_event_callback.aux_select((uint32_t)index, g_event_callback.aux_select_user_data);
611 void CCoreEventCallback::on_select_candidate(sclint ic, const sclchar *uuid, sclint index)
613 if (g_event_callback.candidate_select) {
614 g_event_callback.candidate_select((uint32_t)index, g_event_callback.candidate_select_user_data);
618 void CCoreEventCallback::on_candidate_table_page_up(sclint ic, const sclchar *uuid)
620 if (g_event_callback.candidate_table_page_up) {
621 g_event_callback.candidate_table_page_up(g_event_callback.candidate_table_page_up_user_data);
625 void CCoreEventCallback::on_candidate_table_page_down(sclint ic, const sclchar *uuid)
627 if (g_event_callback.candidate_table_page_down) {
628 g_event_callback.candidate_table_page_down(g_event_callback.candidate_table_page_down_user_data);
632 void CCoreEventCallback::on_update_candidate_table_page_size(sclint ic, const sclchar *uuid, sclint page_size)
634 if (g_event_callback.candidate_table_page_size_chaned) {
635 g_event_callback.candidate_table_page_size_chaned((uint32_t)page_size, g_event_callback.candidate_table_page_size_chaned_user_data);
639 void CCoreEventCallback::on_update_candidate_item_layout(const std::vector<sclu32> item)
641 if (g_event_callback.candidate_item_layout_set) {
642 g_event_callback.candidate_item_layout_set(item, g_event_callback.candidate_item_layout_set_user_data);
646 void CCoreEventCallback::on_update_displayed_candidate_number(sclu32 size)
648 if (g_event_callback.displayed_candidate_number_chaned) {
649 g_event_callback.displayed_candidate_number_chaned(size, g_event_callback.displayed_candidate_number_chaned_user_data);
653 void CCoreEventCallback::on_longpress_candidate(sclu32 index)
655 if (g_event_callback.candidate_item_long_pressed) {
656 g_event_callback.candidate_item_long_pressed(index, g_event_callback.candidate_item_long_pressed_user_data);
660 void ime_privilege_cache_init()
662 g_permission_allowed = false;
663 g_checked_privilege = false;
667 ime_error_e _check_privilege()
670 ime_error_e ret = IME_ERROR_NONE;
672 if (g_checked_privilege) {
673 return g_permission_allowed ? IME_ERROR_NONE : IME_ERROR_PERMISSION_DENIED;
676 if (inputmethod_cynara_initialize() == false) {
678 g_permission_allowed = false;
679 g_checked_privilege = true;
680 LOGE("inputmethod_cynara_initialize () == false");
682 return IME_ERROR_PERMISSION_DENIED;
685 snprintf(uid, 16, "%d", getuid());
686 if (check_privilege(uid, IME_PRIVILEGE) == false) {
687 LOGE("check_privilege(uid, IME_PRIVILEGE) == false. uid : %s", uid); //LCOV_EXCL_LINE
688 ret = IME_ERROR_PERMISSION_DENIED;
691 g_permission_allowed = (ret == IME_ERROR_NONE);
692 g_checked_privilege = true;
694 inputmethod_cynara_finish();
700 bool g_from_dotnet = false;
701 EXPORT_API int ime_set_dotnet_flag(bool set)
703 ime_error_e retVal = IME_ERROR_NONE;
705 retVal = _check_privilege();
706 if (retVal != IME_ERROR_NONE) return retVal;
714 EXPORT_API int ime_run(ime_callback_s *basic_cb, void *user_data)
716 ime_error_e retVal = IME_ERROR_NONE;
720 LOGE("inputmethod main loop is already running.");
721 return IME_ERROR_OPERATION_FAILED;
726 LOGE("basic callbacks pointer is null.");
727 return IME_ERROR_INVALID_PARAMETER;
730 retVal = _check_privilege();
731 if (retVal != IME_ERROR_NONE) return retVal;
733 g_basic_callback = *basic_cb;
735 if (!g_basic_callback.create || !g_basic_callback.terminate ||
736 !g_basic_callback.show || !g_basic_callback.hide) {
737 LOGE("mandatory callback functions are not set");
738 memset(&g_basic_callback, 0, sizeof(ime_callback_s));
739 memset(&g_event_callback, 0, sizeof(ime_event_callback_s));
740 return IME_ERROR_NO_CALLBACK_FUNCTION;
744 g_user_data = user_data;
748 LOGD("ime_run is called from dotnet");
749 return IME_ERROR_NONE;
755 LOGW("exception is thrown from g_core.run()\n");
758 memset(&g_basic_callback, 0, sizeof(ime_callback_s));
759 memset(&g_event_callback, 0, sizeof(ime_event_callback_s));
763 return IME_ERROR_NONE;
767 EXPORT_API int ime_event_set_focus_in_cb(ime_focus_in_cb callback_func, void *user_data)
769 ime_error_e retVal = IME_ERROR_NONE;
771 if (!callback_func) {
772 LOGW("IME_ERROR_INVALID_PARAMETER");
773 return IME_ERROR_INVALID_PARAMETER;
776 retVal = _check_privilege();
777 if (retVal != IME_ERROR_NONE) return retVal;
779 g_event_callback.focus_in = callback_func;
780 g_event_callback.focus_in_user_data = user_data;
782 return IME_ERROR_NONE;
785 EXPORT_API int ime_event_set_focus_out_cb(ime_focus_out_cb callback_func, void *user_data)
787 ime_error_e retVal = IME_ERROR_NONE;
789 if (!callback_func) {
790 LOGW("IME_ERROR_INVALID_PARAMETER");
791 return IME_ERROR_INVALID_PARAMETER;
794 retVal = _check_privilege();
795 if (retVal != IME_ERROR_NONE) return retVal;
797 g_event_callback.focus_out = callback_func;
798 g_event_callback.focus_out_user_data = user_data;
800 return IME_ERROR_NONE;
803 EXPORT_API int ime_event_set_surrounding_text_updated_cb(ime_surrounding_text_updated_cb callback_func, void *user_data)
805 ime_error_e retVal = IME_ERROR_NONE;
807 if (!callback_func) {
808 LOGW("IME_ERROR_INVALID_PARAMETER");
809 return IME_ERROR_INVALID_PARAMETER;
812 retVal = _check_privilege();
813 if (retVal != IME_ERROR_NONE) return retVal;
815 g_event_callback.surrounding_text_updated = callback_func;
816 g_event_callback.surrounding_text_updated_user_data = user_data;
818 return IME_ERROR_NONE;
821 EXPORT_API int ime_event_set_input_context_reset_cb(ime_input_context_reset_cb callback_func, void *user_data)
823 ime_error_e retVal = IME_ERROR_NONE;
825 if (!callback_func) {
826 LOGW("IME_ERROR_INVALID_PARAMETER");
827 return IME_ERROR_INVALID_PARAMETER;
830 retVal = _check_privilege();
831 if (retVal != IME_ERROR_NONE) return retVal;
833 g_event_callback.input_context_reset = callback_func;
834 g_event_callback.input_context_reset_user_data = user_data;
836 return IME_ERROR_NONE;
839 EXPORT_API int ime_event_set_cursor_position_updated_cb(ime_cursor_position_updated_cb callback_func, void *user_data)
841 ime_error_e retVal = IME_ERROR_NONE;
843 if (!callback_func) {
844 LOGW("IME_ERROR_INVALID_PARAMETER");
845 return IME_ERROR_INVALID_PARAMETER;
848 retVal = _check_privilege();
849 if (retVal != IME_ERROR_NONE) return retVal;
851 g_event_callback.cursor_position_updated = callback_func;
852 g_event_callback.cursor_position_updated_user_data = user_data;
854 return IME_ERROR_NONE;
857 EXPORT_API int ime_event_set_language_requested_cb(ime_language_requested_cb callback_func, void *user_data)
859 ime_error_e retVal = IME_ERROR_NONE;
861 if (!callback_func) {
862 LOGW("IME_ERROR_INVALID_PARAMETER");
863 return IME_ERROR_INVALID_PARAMETER;
866 retVal = _check_privilege();
867 if (retVal != IME_ERROR_NONE) return retVal;
869 g_event_callback.language_requested = callback_func;
870 g_event_callback.language_requested_user_data = user_data;
872 return IME_ERROR_NONE;
875 EXPORT_API int ime_event_set_language_set_cb(ime_language_set_cb callback_func, void *user_data)
877 ime_error_e retVal = IME_ERROR_NONE;
879 if (!callback_func) {
880 LOGW("IME_ERROR_INVALID_PARAMETER");
881 return IME_ERROR_INVALID_PARAMETER;
884 retVal = _check_privilege();
885 if (retVal != IME_ERROR_NONE) return retVal;
887 g_event_callback.language_set = callback_func;
888 g_event_callback.language_set_user_data = user_data;
890 return IME_ERROR_NONE;
893 EXPORT_API int ime_event_set_imdata_set_cb(ime_imdata_set_cb callback_func, void *user_data)
895 ime_error_e retVal = IME_ERROR_NONE;
897 if (!callback_func) {
898 LOGW("IME_ERROR_INVALID_PARAMETER");
899 return IME_ERROR_INVALID_PARAMETER;
902 retVal = _check_privilege();
903 if (retVal != IME_ERROR_NONE) return retVal;
905 g_event_callback.imdata_set = callback_func;
906 g_event_callback.imdata_set_user_data = user_data;
908 return IME_ERROR_NONE;
911 EXPORT_API int ime_event_set_imdata_requested_cb(ime_imdata_requested_cb callback_func, void *user_data)
913 ime_error_e retVal = IME_ERROR_NONE;
915 if (!callback_func) {
916 LOGW("IME_ERROR_INVALID_PARAMETER");
917 return IME_ERROR_INVALID_PARAMETER;
920 retVal = _check_privilege();
921 if (retVal != IME_ERROR_NONE) return retVal;
923 g_event_callback.imdata_requested = callback_func;
924 g_event_callback.imdata_requested_user_data = user_data;
926 return IME_ERROR_NONE;
929 EXPORT_API int ime_event_set_layout_set_cb(ime_layout_set_cb callback_func, void *user_data)
931 ime_error_e retVal = IME_ERROR_NONE;
933 if (!callback_func) {
934 LOGW("IME_ERROR_INVALID_PARAMETER");
935 return IME_ERROR_INVALID_PARAMETER;
938 retVal = _check_privilege();
939 if (retVal != IME_ERROR_NONE) return retVal;
941 g_event_callback.layout_set = callback_func;
942 g_event_callback.layout_set_user_data = user_data;
944 return IME_ERROR_NONE;
947 EXPORT_API int ime_event_set_return_key_type_set_cb(ime_return_key_type_set_cb callback_func, void *user_data)
949 ime_error_e retVal = IME_ERROR_NONE;
951 if (!callback_func) {
952 LOGW("IME_ERROR_INVALID_PARAMETER");
953 return IME_ERROR_INVALID_PARAMETER;
956 retVal = _check_privilege();
957 if (retVal != IME_ERROR_NONE) return retVal;
959 g_event_callback.return_key_type_set = callback_func;
960 g_event_callback.return_key_type_set_user_data = user_data;
962 return IME_ERROR_NONE;
965 EXPORT_API int ime_event_set_return_key_state_set_cb(ime_return_key_state_set_cb callback_func, void *user_data)
967 ime_error_e retVal = IME_ERROR_NONE;
969 if (!callback_func) {
970 LOGW("IME_ERROR_INVALID_PARAMETER");
971 return IME_ERROR_INVALID_PARAMETER;
974 retVal = _check_privilege();
975 if (retVal != IME_ERROR_NONE) return retVal;
977 g_event_callback.return_key_state_set = callback_func;
978 g_event_callback.return_key_state_set_user_data = user_data;
980 return IME_ERROR_NONE;
983 EXPORT_API int ime_event_set_geometry_requested_cb(ime_geometry_requested_cb callback_func, void *user_data)
985 ime_error_e retVal = IME_ERROR_NONE;
987 if (!callback_func) {
988 LOGW("IME_ERROR_INVALID_PARAMETER");
989 return IME_ERROR_INVALID_PARAMETER;
992 retVal = _check_privilege();
993 if (retVal != IME_ERROR_NONE) return retVal;
995 g_event_callback.geometry_requested = callback_func;
996 g_event_callback.geometry_requested_user_data = user_data;
998 return IME_ERROR_NONE;
1001 EXPORT_API int ime_event_set_process_key_event_cb(ime_process_key_event_cb callback_func, void *user_data)
1003 ime_error_e retVal = IME_ERROR_NONE;
1005 if (!callback_func) {
1006 LOGW("IME_ERROR_INVALID_PARAMETER");
1007 return IME_ERROR_INVALID_PARAMETER;
1010 retVal = _check_privilege();
1011 if (retVal != IME_ERROR_NONE) return retVal;
1013 g_event_callback.process_key_event = callback_func;
1014 g_event_callback.process_key_event_user_data = user_data;
1016 return IME_ERROR_NONE;
1019 EXPORT_API int ime_event_set_process_key_event_with_keycode_cb(ime_process_key_event_with_keycode_cb callback_func, void *user_data)
1021 ime_error_e retVal = IME_ERROR_NONE;
1023 if (!callback_func) {
1024 LOGW("IME_ERROR_INVALID_PARAMETER");
1025 return IME_ERROR_INVALID_PARAMETER;
1028 retVal = _check_privilege();
1029 if (retVal != IME_ERROR_NONE) return retVal;
1031 g_event_callback.process_key_event_with_keycode = callback_func;
1032 g_event_callback.process_key_event_with_keycode_user_data = user_data;
1034 return IME_ERROR_NONE;
1037 EXPORT_API int ime_event_set_display_language_changed_cb(ime_display_language_changed_cb callback_func, void *user_data)
1039 ime_error_e retVal = IME_ERROR_NONE;
1041 if (!callback_func) {
1042 LOGW("IME_ERROR_INVALID_PARAMETER");
1043 return IME_ERROR_INVALID_PARAMETER;
1046 retVal = _check_privilege();
1047 if (retVal != IME_ERROR_NONE) return retVal;
1049 g_event_callback.display_language_changed = callback_func;
1050 g_event_callback.display_language_changed_user_data = user_data;
1052 return IME_ERROR_NONE;
1055 EXPORT_API int ime_event_set_rotation_degree_changed_cb(ime_rotation_degree_changed_cb callback_func, void *user_data)
1057 ime_error_e retVal = IME_ERROR_NONE;
1059 if (!callback_func) {
1060 LOGW("IME_ERROR_INVALID_PARAMETER");
1061 return IME_ERROR_INVALID_PARAMETER;
1064 retVal = _check_privilege();
1065 if (retVal != IME_ERROR_NONE) return retVal;
1067 g_event_callback.rotation_degree_changed = callback_func;
1068 g_event_callback.rotation_degree_changed_user_data = user_data;
1070 return IME_ERROR_NONE;
1073 EXPORT_API int ime_event_set_accessibility_state_changed_cb(ime_accessibility_state_changed_cb callback_func, void *user_data)
1075 ime_error_e retVal = IME_ERROR_NONE;
1077 if (!callback_func) {
1078 LOGW("IME_ERROR_INVALID_PARAMETER");
1079 return IME_ERROR_INVALID_PARAMETER;
1082 retVal = _check_privilege();
1083 if (retVal != IME_ERROR_NONE) return retVal;
1085 g_event_callback.accessibility_state_changed = callback_func;
1086 g_event_callback.accessibility_state_changed_user_data = user_data;
1088 return IME_ERROR_NONE;
1091 EXPORT_API int ime_event_set_option_window_created_cb(ime_option_window_created_cb callback_func, void *user_data)
1093 ime_error_e retVal = IME_ERROR_NONE;
1095 if (!callback_func) {
1096 LOGW("IME_ERROR_INVALID_PARAMETER");
1097 return IME_ERROR_INVALID_PARAMETER;
1100 retVal = _check_privilege();
1101 if (retVal != IME_ERROR_NONE) return retVal;
1103 g_event_callback.option_window_created = callback_func;
1104 g_event_callback.option_window_created_user_data = user_data;
1106 return IME_ERROR_NONE;
1109 EXPORT_API int ime_event_set_option_window_destroyed_cb(ime_option_window_destroyed_cb callback_func, void *user_data)
1111 ime_error_e retVal = IME_ERROR_NONE;
1113 if (!callback_func) {
1114 LOGW("IME_ERROR_INVALID_PARAMETER");
1115 return IME_ERROR_INVALID_PARAMETER;
1118 retVal = _check_privilege();
1119 if (retVal != IME_ERROR_NONE) return retVal;
1121 g_event_callback.option_window_destroyed = callback_func;
1122 g_event_callback.option_window_destroyed_user_data = user_data;
1124 return IME_ERROR_NONE;
1127 EXPORT_API int ime_event_set_input_hint_set_cb(ime_input_hint_set_cb callback_func, void *user_data)
1129 ime_error_e retVal = IME_ERROR_NONE;
1131 if (!callback_func) {
1132 LOGW("IME_ERROR_INVALID_PARAMETER");
1133 return IME_ERROR_INVALID_PARAMETER;
1136 retVal = _check_privilege();
1137 if (retVal != IME_ERROR_NONE) return retVal;
1139 g_event_callback.input_hint_set = callback_func;
1140 g_event_callback.input_hint_set_user_data = user_data;
1142 return IME_ERROR_NONE;
1145 EXPORT_API int ime_event_unset_input_hint_set_cb(void)
1147 ime_error_e retVal = IME_ERROR_NONE;
1149 retVal = _check_privilege();
1150 if (retVal != IME_ERROR_NONE) return retVal;
1152 g_event_callback.input_hint_set = NULL;
1153 g_event_callback.input_hint_set_user_data = NULL;
1155 return IME_ERROR_NONE;
1159 EXPORT_API int ime_event_set_caps_mode_changed_cb(ime_caps_mode_changed_cb callback_func, void *user_data)
1161 ime_error_e retVal = IME_ERROR_NONE;
1163 if (!callback_func) {
1164 LOGW("IME_ERROR_INVALID_PARAMETER");
1165 return IME_ERROR_INVALID_PARAMETER;
1168 retVal = _check_privilege();
1169 if (retVal != IME_ERROR_NONE) return retVal;
1171 g_event_callback.caps_mode_changed = callback_func;
1172 g_event_callback.caps_mode_changed_user_data = user_data;
1174 return IME_ERROR_NONE;
1177 EXPORT_API int ime_event_set_candidate_show_cb(ime_candidate_show_cb callback_func, void *user_data)
1179 ime_error_e retVal = IME_ERROR_NONE;
1181 if (!callback_func) {
1182 LOGW("IME_ERROR_INVALID_PARAMETER");
1183 return IME_ERROR_INVALID_PARAMETER;
1186 retVal = _check_privilege();
1187 if (retVal != IME_ERROR_NONE) return retVal;
1189 g_event_callback.candidate_show = callback_func;
1190 g_event_callback.candidate_show_user_data = user_data;
1192 return IME_ERROR_NONE;
1195 EXPORT_API int ime_event_set_candidate_hide_cb(ime_candidate_hide_cb callback_func, void *user_data)
1197 ime_error_e retVal = IME_ERROR_NONE;
1199 if (!callback_func) {
1200 LOGW("IME_ERROR_INVALID_PARAMETER");
1201 return IME_ERROR_INVALID_PARAMETER;
1204 retVal = _check_privilege();
1205 if (retVal != IME_ERROR_NONE) return retVal;
1207 g_event_callback.candidate_hide = callback_func;
1208 g_event_callback.candidate_hide_user_data = user_data;
1210 return IME_ERROR_NONE;
1213 EXPORT_API int ime_event_set_lookup_table_changed_cb(ime_lookup_table_changed_cb callback_func, void *user_data)
1215 ime_error_e retVal = IME_ERROR_NONE;
1217 if (!callback_func) {
1218 LOGW("IME_ERROR_INVALID_PARAMETER");
1219 return IME_ERROR_INVALID_PARAMETER;
1222 retVal = _check_privilege();
1223 if (retVal != IME_ERROR_NONE) return retVal;
1225 g_event_callback.lookup_table_changed = callback_func;
1226 g_event_callback.lookup_table_changed_user_data = user_data;
1228 return IME_ERROR_NONE;
1232 EXPORT_API int ime_send_key_event(ime_key_code_e keycode, ime_key_mask_e keymask, bool forward_key)
1234 ime_error_e retVal = IME_ERROR_NONE;
1237 LOGW("IME_ERROR_NOT_RUNNING");
1238 return IME_ERROR_NOT_RUNNING;
1242 retVal = _check_privilege();
1243 if (retVal != IME_ERROR_NONE) return retVal;
1246 g_core.forward_key_event(-1, NULL, (sclu32)keycode, (sclu16)keymask);
1248 g_core.send_key_event(-1, NULL, (sclu32)keycode, (sclu16)keymask);
1251 return IME_ERROR_NONE;
1254 EXPORT_API int ime_commit_string(const char *str)
1256 ime_error_e retVal = IME_ERROR_NONE;
1259 LOGW("IME_ERROR_INVALID_PARAMETER");
1260 return IME_ERROR_INVALID_PARAMETER;
1264 LOGW("IME_ERROR_NOT_RUNNING");
1265 return IME_ERROR_NOT_RUNNING;
1269 retVal = _check_privilege();
1270 if (retVal != IME_ERROR_NONE) return retVal;
1272 SECURE_LOGI("commit string : %s", str);
1273 g_core.commit_string(-1, NULL, str);
1275 return IME_ERROR_NONE;
1279 EXPORT_API int ime_show_preedit_string(void)
1281 ime_error_e retVal = IME_ERROR_NONE;
1284 LOGW("IME_ERROR_NOT_RUNNING");
1285 return IME_ERROR_NOT_RUNNING;
1289 retVal = _check_privilege();
1290 if (retVal != IME_ERROR_NONE) return retVal;
1292 g_core.show_preedit_string(-1, NULL);
1294 return IME_ERROR_NONE;
1298 EXPORT_API int ime_hide_preedit_string(void)
1300 ime_error_e retVal = IME_ERROR_NONE;
1303 LOGW("IME_ERROR_NOT_RUNNING");
1304 return IME_ERROR_NOT_RUNNING;
1308 retVal = _check_privilege();
1309 if (retVal != IME_ERROR_NONE) return retVal;
1311 g_core.hide_preedit_string(-1, NULL);
1313 return IME_ERROR_NONE;
1317 EXPORT_API int ime_update_preedit_string(const char *str, Eina_List *attrs)
1319 ime_error_e retVal = IME_ERROR_NONE;
1322 LOGW("IME_ERROR_INVALID_PARAMETER");
1323 return IME_ERROR_INVALID_PARAMETER;
1327 LOGW("IME_ERROR_NOT_RUNNING");
1328 return IME_ERROR_NOT_RUNNING;
1332 retVal = _check_privilege();
1333 if (retVal != IME_ERROR_NONE) return retVal;
1335 scim::AttributeList attrv;
1337 ime_preedit_attribute *attr = NULL;
1340 EINA_LIST_FREE(attrs, data) {
1341 attr = (ime_preedit_attribute *)data;
1343 attrv.push_back(scim::Attribute(attr->start, attr->length, (scim::AttributeType)attr->type, attr->value));
1349 SECURE_LOGI("preedit string : '%s'", str);
1350 g_core.update_preedit_string(-1, NULL, str, attrv);
1352 return IME_ERROR_NONE;
1356 EXPORT_API int ime_update_preedit_cursor(unsigned int pos)
1358 ime_error_e retVal = IME_ERROR_NONE;
1361 LOGW("IME_ERROR_NOT_RUNNING");
1362 return IME_ERROR_NOT_RUNNING;
1365 retVal = _check_privilege();
1366 if (retVal != IME_ERROR_NONE) return retVal;
1368 g_core.update_preedit_caret(pos);
1370 return IME_ERROR_NONE;
1373 EXPORT_API int ime_request_surrounding_text(int maxlen_before, int maxlen_after)
1375 ime_error_e retVal = IME_ERROR_NONE;
1377 if (!g_event_callback.surrounding_text_updated) {
1378 LOGW("IME_ERROR_NO_CALLBACK_FUNCTION");
1379 return IME_ERROR_NO_CALLBACK_FUNCTION;
1383 LOGW("IME_ERROR_NOT_RUNNING");
1384 return IME_ERROR_NOT_RUNNING;
1388 retVal = _check_privilege();
1389 if (retVal != IME_ERROR_NONE) return retVal;
1391 g_core.get_surrounding_text(NULL, maxlen_before, maxlen_after);
1393 return IME_ERROR_NONE;
1397 EXPORT_API int ime_delete_surrounding_text(int offset, int len)
1399 ime_error_e retVal = IME_ERROR_NONE;
1402 LOGW("IME_ERROR_INVALID_PARAMETER");
1403 return IME_ERROR_INVALID_PARAMETER;
1407 LOGW("IME_ERROR_NOT_RUNNING");
1408 return IME_ERROR_NOT_RUNNING;
1412 retVal = _check_privilege();
1413 if (retVal != IME_ERROR_NONE) return retVal;
1415 LOGI("offset: %d, len : %d", offset, len);
1416 g_core.delete_surrounding_text(offset, len);
1418 return IME_ERROR_NONE;
1422 EXPORT_API int ime_get_surrounding_text(int maxlen_before, int maxlen_after, char **text, int *cursor_pos)
1424 ime_error_e retVal = IME_ERROR_NONE;
1426 if (!text || !cursor_pos) {
1427 LOGW("IME_ERROR_INVALID_PARAMETER");
1428 return IME_ERROR_INVALID_PARAMETER;
1432 LOGW("IME_ERROR_NOT_RUNNING");
1433 return IME_ERROR_NOT_RUNNING;
1437 retVal = _check_privilege();
1438 if (retVal != IME_ERROR_NONE) return retVal;
1442 int ret = g_core.get_surrounding_text(maxlen_before, maxlen_after, text, cursor);
1444 LOGW("IME_ERROR_OUR_OF_MEMORY");
1445 return IME_ERROR_OUT_OF_MEMORY;
1449 *cursor_pos = cursor;
1451 return IME_ERROR_NONE;
1455 EXPORT_API int ime_set_selection(int start, int end)
1457 ime_error_e retVal = IME_ERROR_NONE;
1460 LOGW("IME_ERROR_INVALID_PARAMETER");
1461 return IME_ERROR_INVALID_PARAMETER;
1465 LOGW("IME_ERROR_NOT_RUNNING");
1466 return IME_ERROR_NOT_RUNNING;
1470 retVal = _check_privilege();
1471 if (retVal != IME_ERROR_NONE) return retVal;
1473 SECURE_LOGI("start: %d, end : %d", start, end);
1474 g_core.set_selection(start, end);
1476 return IME_ERROR_NONE;
1480 EXPORT_API int ime_get_selected_text(char **text)
1482 ime_error_e retVal = IME_ERROR_NONE;
1485 LOGW("IME_ERROR_INVALID_PARAMETER");
1486 return IME_ERROR_INVALID_PARAMETER;
1490 LOGW("IME_ERROR_NOT_RUNNING");
1491 return IME_ERROR_NOT_RUNNING;
1495 retVal = _check_privilege();
1496 if (retVal != IME_ERROR_NONE) return retVal;
1498 g_core.get_selection_text(text);
1500 return IME_ERROR_NONE;
1504 EXPORT_API Evas_Object* ime_get_main_window(void)
1506 ime_error_e retVal = IME_ERROR_NONE;
1508 Evas_Object *win = NULL;
1510 retVal = _check_privilege();
1511 if (retVal != IME_ERROR_NONE) {
1513 LOGE("_check_privilege returned %d.", retVal);
1514 set_last_result(retVal);
1520 set_last_result(IME_ERROR_NOT_RUNNING);
1521 LOGW("IME_ERROR_NOT_RUNNING");
1526 win = static_cast<Evas_Object*>(g_core.get_main_window());
1528 set_last_result(IME_ERROR_NONE);
1530 set_last_result(IME_ERROR_OPERATION_FAILED);
1531 LOGW("IME_ERROR_OPERATION_FAILED");
1538 EXPORT_API int ime_set_size(int portrait_width, int portrait_height, int landscape_width, int landscape_height)
1540 ime_error_e retVal = IME_ERROR_NONE;
1542 SclSize portrait_size, landscape_size;
1544 if (portrait_width < 1 || portrait_height < 1 || landscape_width < 1 || landscape_height < 1) {
1545 LOGW("IME_ERROR_INVALID_PARAMETER");
1546 return IME_ERROR_INVALID_PARAMETER;
1550 LOGW("IME_ERROR_NOT_RUNNING");
1551 return IME_ERROR_NOT_RUNNING;
1555 retVal = _check_privilege();
1556 if (retVal != IME_ERROR_NONE) return retVal;
1558 portrait_size.width = portrait_width;
1559 portrait_size.height = portrait_height;
1561 landscape_size.width = landscape_width;
1562 landscape_size.height = landscape_height;
1564 g_core.set_keyboard_size_hints(portrait_size, landscape_size);
1566 return IME_ERROR_NONE;
1570 EXPORT_API int ime_create_option_window(void)
1572 ime_error_e retVal = IME_ERROR_NONE;
1574 if (!g_event_callback.option_window_created || !g_event_callback.option_window_destroyed) {
1575 LOGW("ime_create_option_window_cb() and ime_destroy_option_window_cb() callback functions are not set.");
1576 return IME_ERROR_NO_CALLBACK_FUNCTION;
1580 LOGW("IME_ERROR_NOT_RUNNING");
1581 return IME_ERROR_NOT_RUNNING;
1585 retVal = _check_privilege();
1586 if (retVal != IME_ERROR_NONE) return retVal;
1588 if (g_core.create_option_window()) {
1589 return IME_ERROR_NONE;
1591 LOGW("IME_ERROR_OPERATION_FAILED");
1592 return IME_ERROR_OPERATION_FAILED;
1597 EXPORT_API int ime_destroy_option_window(Evas_Object *window)
1599 ime_error_e retVal = IME_ERROR_NONE;
1601 if (!g_event_callback.option_window_created || !g_event_callback.option_window_destroyed) {
1602 LOGW("ime_create_option_window_cb() and ime_destroy_option_window_cb() callback functions are not set.");
1603 return IME_ERROR_NO_CALLBACK_FUNCTION;
1607 LOGW("Window pointer is null.");
1608 return IME_ERROR_INVALID_PARAMETER;
1612 LOGW("IME_ERROR_NOT_RUNNING");
1613 return IME_ERROR_NOT_RUNNING;
1617 retVal = _check_privilege();
1618 if (retVal != IME_ERROR_NONE) return retVal;
1620 g_core.destroy_option_window(window);
1622 return IME_ERROR_NONE;
1627 EXPORT_API int ime_set_imengine(const char *engine_id)
1629 ime_error_e retVal = IME_ERROR_NONE;
1632 LOGW("IME_ERROR_INVALID_PARAMETER");
1633 return IME_ERROR_INVALID_PARAMETER;
1636 retVal = _check_privilege();
1637 if (retVal != IME_ERROR_NONE) return retVal;
1639 g_core.set_keyboard_ise_by_uuid(engine_id);
1641 return IME_ERROR_NONE;
1644 EXPORT_API int ime_flush_imengine(void)
1646 ime_error_e retVal = IME_ERROR_NONE;
1649 LOGW("IME_ERROR_NOT_RUNNING");
1650 return IME_ERROR_NOT_RUNNING;
1653 retVal = _check_privilege();
1654 if (retVal != IME_ERROR_NONE) return retVal;
1656 g_core.flush_keyboard_ise();
1658 return IME_ERROR_NONE;
1661 EXPORT_API int ime_send_imengine_event(int command, unsigned int value)
1663 ime_error_e retVal = IME_ERROR_NONE;
1666 LOGW("IME_ERROR_NOT_RUNNING");
1667 return IME_ERROR_NOT_RUNNING;
1670 retVal = _check_privilege();
1671 if (retVal != IME_ERROR_NONE) return retVal;
1673 g_core.send_imengine_event(-1, NULL, command, value);
1675 return IME_ERROR_NONE;
1678 EXPORT_API int ime_reset_imengine(void)
1680 ime_error_e retVal = IME_ERROR_NONE;
1683 LOGW("IME_ERROR_NOT_RUNNING");
1684 return IME_ERROR_NOT_RUNNING;
1687 retVal = _check_privilege();
1688 if (retVal != IME_ERROR_NONE) return retVal;
1690 g_core.reset_keyboard_ise();
1692 return IME_ERROR_NONE;
1695 EXPORT_API int ime_update_input_context(unsigned int type, unsigned int value)
1697 ime_error_e retVal = IME_ERROR_NONE;
1700 LOGW("IME_ERROR_NOT_RUNNING");
1701 return IME_ERROR_NOT_RUNNING;
1704 retVal = _check_privilege();
1705 if (retVal != IME_ERROR_NONE) return retVal;
1707 g_core.update_input_context(type, value);
1709 return IME_ERROR_NONE;
1713 EXPORT_API int ime_request_hide(void)
1715 ime_error_e retVal = IME_ERROR_NONE;
1718 LOGW("IME_ERROR_NOT_RUNNING");
1719 return IME_ERROR_NOT_RUNNING;
1723 retVal = _check_privilege();
1724 if (retVal != IME_ERROR_NONE) return retVal;
1726 g_core.request_ise_hide();
1728 return IME_ERROR_NONE;
1733 EXPORT_API int ime_initialize(void)
1735 ime_error_e retVal = IME_ERROR_NONE;
1737 retVal = _check_privilege();
1738 if (retVal != IME_ERROR_NONE) return retVal;
1746 EXPORT_API int ime_prepare(void)
1748 ime_error_e retVal = IME_ERROR_NONE;
1751 LOGE("inputmethod main loop is already running.");
1752 return IME_ERROR_OPERATION_FAILED;
1755 retVal = _check_privilege();
1756 if (retVal != IME_ERROR_NONE) return retVal;
1765 EXPORT_API int ime_finalize(void)
1767 ime_error_e retVal = IME_ERROR_NONE;
1769 retVal = _check_privilege();
1770 if (retVal != IME_ERROR_NONE) return retVal;
1774 memset(&g_basic_callback, 0, sizeof(ime_callback_s));
1775 memset(&g_event_callback, 0, sizeof(ime_event_callback_s));
1781 EXPORT_API int ime_select_candidate(unsigned int index)
1783 ime_error_e retVal = IME_ERROR_NONE;
1786 LOGW("IME_ERROR_NOT_RUNNING");
1787 return IME_ERROR_NOT_RUNNING;
1790 retVal = _check_privilege();
1791 if (retVal != IME_ERROR_NONE) return retVal;
1793 g_core.select_candidate(index);
1795 return IME_ERROR_NONE;
1799 EXPORT_API int ime_send_private_command(const char *command)
1801 ime_error_e retVal = IME_ERROR_NONE;
1804 LOGW("IME_ERROR_INVALID_PARAMETER");
1805 return IME_ERROR_INVALID_PARAMETER;
1809 LOGW("IME_ERROR_NOT_RUNNING");
1810 return IME_ERROR_NOT_RUNNING;
1814 retVal = _check_privilege();
1815 if (retVal != IME_ERROR_NONE) return retVal;
1817 g_core.send_private_command(command);
1819 return IME_ERROR_NONE;
1823 EXPORT_API int ime_commit_content(const char *content, const char *description, const char *mime_type)
1825 ime_error_e retVal = IME_ERROR_NONE;
1827 if (!content || !description || !mime_type) {
1828 LOGW("IME_ERROR_INVALID_PARAMETER");
1829 return IME_ERROR_INVALID_PARAMETER;
1832 retVal = _check_privilege();
1833 if (retVal != IME_ERROR_NONE) return retVal;
1836 LOGW("IME_ERROR_NOT_RUNNING");
1837 return IME_ERROR_NOT_RUNNING;
1841 SECURE_LOGI("content : '%s', description : '%s', mime_type : '%s'", content, description, mime_type);
1842 g_core.commit_content(content, description, mime_type);
1844 return IME_ERROR_NONE;
1848 EXPORT_API int ime_context_get_layout(ime_context_h context, Ecore_IMF_Input_Panel_Layout *layout)
1850 ime_error_e retVal = IME_ERROR_NONE;
1852 if (!context || !layout) {
1853 LOGW("IME_ERROR_INVALID_PARAMETER");
1854 return IME_ERROR_INVALID_PARAMETER;
1857 retVal = _check_privilege();
1858 if (retVal != IME_ERROR_NONE) return retVal;
1861 LOGW("IME_ERROR_NOT_RUNNING");
1862 return IME_ERROR_NOT_RUNNING;
1866 *layout = context->layout;
1868 return IME_ERROR_NONE;
1872 EXPORT_API int ime_context_get_layout_variation(ime_context_h context, ime_layout_variation_e *layout_variation)
1874 ime_error_e retVal = IME_ERROR_NONE;
1876 if (!context || !layout_variation) {
1877 LOGW("IME_ERROR_INVALID_PARAMETER");
1878 return IME_ERROR_INVALID_PARAMETER;
1881 retVal = _check_privilege();
1882 if (retVal != IME_ERROR_NONE) return retVal;
1885 LOGW("IME_ERROR_NOT_RUNNING");
1886 return IME_ERROR_NOT_RUNNING;
1890 *layout_variation = static_cast<ime_layout_variation_e>(context->layout_variation);
1892 return IME_ERROR_NONE;
1896 EXPORT_API int ime_context_get_cursor_position(ime_context_h context, int *cursor_pos)
1898 ime_error_e retVal = IME_ERROR_NONE;
1900 if (!context || !cursor_pos) {
1901 LOGW("IME_ERROR_INVALID_PARAMETER");
1902 return IME_ERROR_INVALID_PARAMETER;
1905 retVal = _check_privilege();
1906 if (retVal != IME_ERROR_NONE) return retVal;
1909 LOGW("IME_ERROR_NOT_RUNNING");
1910 return IME_ERROR_NOT_RUNNING;
1914 *cursor_pos = context->cursor_pos;
1916 return IME_ERROR_NONE;
1920 EXPORT_API int ime_context_get_autocapital_type(ime_context_h context, Ecore_IMF_Autocapital_Type *autocapital_type)
1922 ime_error_e retVal = IME_ERROR_NONE;
1924 if (!context || !autocapital_type) {
1925 LOGW("IME_ERROR_INVALID_PARAMETER");
1926 return IME_ERROR_INVALID_PARAMETER;
1929 retVal = _check_privilege();
1930 if (retVal != IME_ERROR_NONE) return retVal;
1933 LOGW("IME_ERROR_NOT_RUNNING");
1934 return IME_ERROR_NOT_RUNNING;
1938 *autocapital_type = context->autocapital_type;
1940 return IME_ERROR_NONE;
1944 EXPORT_API int ime_context_get_return_key_type(ime_context_h context, Ecore_IMF_Input_Panel_Return_Key_Type *return_key_type)
1946 ime_error_e retVal = IME_ERROR_NONE;
1948 if (!context || !return_key_type) {
1949 LOGW("IME_ERROR_INVALID_PARAMETER");
1950 return IME_ERROR_INVALID_PARAMETER;
1953 retVal = _check_privilege();
1954 if (retVal != IME_ERROR_NONE) return retVal;
1957 LOGW("IME_ERROR_NOT_RUNNING");
1958 return IME_ERROR_NOT_RUNNING;
1962 *return_key_type = context->return_key_type;
1964 return IME_ERROR_NONE;
1968 EXPORT_API int ime_context_get_return_key_state(ime_context_h context, bool *return_key_state)
1970 ime_error_e retVal = IME_ERROR_NONE;
1972 if (!context || !return_key_state) {
1973 LOGW("IME_ERROR_INVALID_PARAMETER");
1974 return IME_ERROR_INVALID_PARAMETER;
1977 retVal = _check_privilege();
1978 if (retVal != IME_ERROR_NONE) return retVal;
1981 LOGW("IME_ERROR_NOT_RUNNING");
1982 return IME_ERROR_NOT_RUNNING;
1986 *return_key_state = static_cast<bool>(context->return_key_disabled);
1988 return IME_ERROR_NONE;
1992 EXPORT_API int ime_context_get_prediction_mode(ime_context_h context, bool *prediction_mode)
1994 ime_error_e retVal = IME_ERROR_NONE;
1996 if (!context || !prediction_mode) {
1997 LOGW("IME_ERROR_INVALID_PARAMETER");
1998 return IME_ERROR_INVALID_PARAMETER;
2001 retVal = _check_privilege();
2002 if (retVal != IME_ERROR_NONE) return retVal;
2005 LOGW("IME_ERROR_NOT_RUNNING");
2006 return IME_ERROR_NOT_RUNNING;
2010 *prediction_mode = static_cast<bool>(context->prediction_allow);
2012 return IME_ERROR_NONE;
2016 EXPORT_API int ime_context_get_password_mode(ime_context_h context, bool *password_mode)
2018 ime_error_e retVal = IME_ERROR_NONE;
2020 if (!context || !password_mode) {
2021 LOGW("IME_ERROR_INVALID_PARAMETER");
2022 return IME_ERROR_INVALID_PARAMETER;
2025 retVal = _check_privilege();
2026 if (retVal != IME_ERROR_NONE) return retVal;
2029 LOGW("IME_ERROR_NOT_RUNNING");
2030 return IME_ERROR_NOT_RUNNING;
2034 *password_mode = static_cast<bool>(context->password_mode);
2036 return IME_ERROR_NONE;
2040 EXPORT_API int ime_context_get_input_hint(ime_context_h context, Ecore_IMF_Input_Hints *input_hint)
2042 ime_error_e retVal = IME_ERROR_NONE;
2044 if (!context || !input_hint) {
2045 LOGW("IME_ERROR_INVALID_PARAMETER");
2046 return IME_ERROR_INVALID_PARAMETER;
2049 retVal = _check_privilege();
2050 if (retVal != IME_ERROR_NONE) return retVal;
2053 LOGW("IME_ERROR_NOT_RUNNING");
2054 return IME_ERROR_NOT_RUNNING;
2058 *input_hint = context->input_hint;
2060 return IME_ERROR_NONE;
2064 EXPORT_API int ime_context_get_bidi_direction(ime_context_h context, Ecore_IMF_BiDi_Direction *bidi)
2066 ime_error_e retVal = IME_ERROR_NONE;
2068 if (!context || !bidi) {
2069 LOGW("IME_ERROR_INVALID_PARAMETER");
2070 return IME_ERROR_INVALID_PARAMETER;
2073 retVal = _check_privilege();
2074 if (retVal != IME_ERROR_NONE) return retVal;
2077 LOGW("IME_ERROR_NOT_RUNNING");
2078 return IME_ERROR_NOT_RUNNING;
2082 *bidi = context->bidi_direction;
2084 return IME_ERROR_NONE;
2088 EXPORT_API int ime_context_get_language(ime_context_h context, Ecore_IMF_Input_Panel_Lang *language)
2090 ime_error_e retVal = IME_ERROR_NONE;
2092 if (!context || !language) {
2093 LOGW("IME_ERROR_INVALID_PARAMETER");
2094 return IME_ERROR_INVALID_PARAMETER;
2097 retVal = _check_privilege();
2098 if (retVal != IME_ERROR_NONE) return retVal;
2101 LOGW("IME_ERROR_NOT_RUNNING");
2102 return IME_ERROR_NOT_RUNNING;
2106 *language = context->language;
2108 return IME_ERROR_NONE;
2113 EXPORT_API int ime_context_get_caps_mode(ime_context_h context, bool *caps_mode)
2115 ime_error_e retVal = IME_ERROR_NONE;
2117 if (!context || !caps_mode) {
2118 LOGW("IME_ERROR_INVALID_PARAMETER");
2119 return IME_ERROR_INVALID_PARAMETER;
2122 retVal = _check_privilege();
2123 if (retVal != IME_ERROR_NONE) return retVal;
2126 LOGW("IME_ERROR_NOT_RUNNING");
2127 return IME_ERROR_NOT_RUNNING;
2130 *caps_mode = static_cast<bool>(context->caps_mode);
2132 return IME_ERROR_NONE;
2136 EXPORT_API int ime_device_info_get_name(ime_device_info_h dev_info, char **dev_name)
2138 ime_error_e retVal = IME_ERROR_NONE;
2140 if (!dev_info || !dev_name) {
2141 LOGW("IME_ERROR_INVALID_PARAMETER");
2142 return IME_ERROR_INVALID_PARAMETER;
2145 retVal = _check_privilege();
2146 if (retVal != IME_ERROR_NONE) return retVal;
2149 LOGW("IME_ERROR_NOT_RUNNING");
2150 return IME_ERROR_NOT_RUNNING;
2154 if (!dev_info->dev_name)
2155 *dev_name = strdup("");
2157 *dev_name = strdup(dev_info->dev_name);
2159 return IME_ERROR_NONE;
2163 EXPORT_API int ime_device_info_get_class(ime_device_info_h dev_info, Ecore_IMF_Device_Class *dev_class)
2165 ime_error_e retVal = IME_ERROR_NONE;
2167 if (!dev_info || !dev_class) {
2168 LOGW("IME_ERROR_INVALID_PARAMETER");
2169 return IME_ERROR_INVALID_PARAMETER;
2172 retVal = _check_privilege();
2173 if (retVal != IME_ERROR_NONE) return retVal;
2176 LOGW("IME_ERROR_NOT_RUNNING");
2177 return IME_ERROR_NOT_RUNNING;
2181 *dev_class = dev_info->dev_class;
2183 return IME_ERROR_NONE;
2187 EXPORT_API int ime_device_info_get_subclass(ime_device_info_h dev_info, Ecore_IMF_Device_Subclass *dev_subclass)
2189 ime_error_e retVal = IME_ERROR_NONE;
2191 if (!dev_info || !dev_subclass) {
2192 LOGW("IME_ERROR_INVALID_PARAMETER");
2193 return IME_ERROR_INVALID_PARAMETER;
2196 retVal = _check_privilege();
2197 if (retVal != IME_ERROR_NONE) return retVal;
2200 LOGW("IME_ERROR_NOT_RUNNING");
2201 return IME_ERROR_NOT_RUNNING;
2205 *dev_subclass = dev_info->dev_subclass;
2207 return IME_ERROR_NONE;
2212 EXPORT_API int ime_event_set_process_input_device_event_cb(ime_process_input_device_event_cb callback_func, void *user_data)
2214 ime_error_e retVal = IME_ERROR_NONE;
2216 if (!callback_func) {
2217 LOGW("IME_ERROR_INVALID_PARAMETER");
2218 return IME_ERROR_INVALID_PARAMETER;
2221 retVal = _check_privilege();
2222 if (retVal != IME_ERROR_NONE) return retVal;
2224 g_event_callback.process_input_device_event = callback_func;
2225 g_event_callback.process_input_device_event_user_data = user_data;
2227 return IME_ERROR_NONE;
2230 EXPORT_API int ime_event_unset_process_input_device_event_cb(void)
2232 ime_error_e retVal = IME_ERROR_NONE;
2234 retVal = _check_privilege();
2235 if (retVal != IME_ERROR_NONE) return retVal;
2237 g_event_callback.process_input_device_event = NULL;
2238 g_event_callback.process_input_device_event_user_data = NULL;
2240 return IME_ERROR_NONE;
2243 /* Functions for Rotary input device event */
2244 EXPORT_API int ime_input_device_rotary_get_direction(ime_input_device_event_h event_handle, ime_input_device_rotary_direction_e *direction)
2246 ime_error_e retVal = IME_ERROR_NONE;
2248 if (!event_handle || !direction) {
2249 LOGW("IME_ERROR_INVALID_PARAMETER");
2250 return IME_ERROR_INVALID_PARAMETER;
2253 ime_device_event_s *device_event = static_cast<ime_device_event_s*>(event_handle);
2254 if (device_event->device_type != IME_INPUT_DEVICE_TYPE_ROTARY) {
2255 LOGW("IME_ERROR_INVALID_PARAMETER");
2256 return IME_ERROR_INVALID_PARAMETER;
2259 retVal = _check_privilege();
2260 if (retVal != IME_ERROR_NONE) return retVal;
2263 LOGW("IME_ERROR_OPERATION_FAILED");
2264 return IME_ERROR_OPERATION_FAILED;
2268 Ecore_Event_Detent_Rotate *rotary_device_event =
2269 static_cast<Ecore_Event_Detent_Rotate*>(device_event->event_data);
2270 if (rotary_device_event) {
2271 if (rotary_device_event->direction == ECORE_DETENT_DIRECTION_CLOCKWISE) {
2272 *direction = IME_INPUT_DEVICE_ROTARY_DIRECTION_CLOCKWISE;
2273 } else if (rotary_device_event->direction == ECORE_DETENT_DIRECTION_COUNTER_CLOCKWISE) {
2274 *direction = IME_INPUT_DEVICE_ROTARY_DIRECTION_COUNTER_CLOCKWISE;
2278 return IME_ERROR_NONE;
2283 EXPORT_API int ime_event_set_prediction_hint_set_cb(ime_prediction_hint_set_cb callback_func, void *user_data)
2285 ime_error_e retVal = IME_ERROR_NONE;
2287 if (!callback_func) {
2288 LOGW("IME_ERROR_INVALID_PARAMETER");
2289 return IME_ERROR_INVALID_PARAMETER;
2292 retVal = _check_privilege();
2293 if (retVal != IME_ERROR_NONE) return retVal;
2295 g_event_callback.prediction_hint_set = callback_func;
2296 g_event_callback.prediction_hint_set_user_data = user_data;
2298 return IME_ERROR_NONE;
2301 EXPORT_API int ime_event_set_mime_type_set_request_cb(ime_mime_type_set_request_cb callback_func, void *user_data)
2303 ime_error_e retVal = IME_ERROR_NONE;
2305 if (!callback_func) {
2306 LOGW("IME_ERROR_INVALID_PARAMETER");
2307 return IME_ERROR_INVALID_PARAMETER;
2310 retVal = _check_privilege();
2311 if (retVal != IME_ERROR_NONE) return retVal;
2313 g_event_callback.mime_type_set = callback_func;
2314 g_event_callback.mime_type_set_user_data = user_data;
2316 return IME_ERROR_NONE;
2319 EXPORT_API int ime_set_floating_mode(bool floating_mode)
2321 ime_error_e retVal = IME_ERROR_NONE;
2323 retVal = _check_privilege();
2324 if (retVal != IME_ERROR_NONE) return retVal;
2327 LOGW("IME_ERROR_NOT_RUNNING");
2328 return IME_ERROR_NOT_RUNNING;
2332 g_core.set_floating_mode(floating_mode);
2334 return IME_ERROR_NONE;
2338 EXPORT_API int ime_set_floating_drag_start(void)
2340 ime_error_e retVal = IME_ERROR_NONE;
2342 retVal = _check_privilege();
2343 if (retVal != IME_ERROR_NONE) return retVal;
2346 LOGW("IME_ERROR_NOT_RUNNING");
2347 return IME_ERROR_NOT_RUNNING;
2351 g_core.set_floating_drag_enabled(true);
2353 return IME_ERROR_NONE;
2357 EXPORT_API int ime_set_floating_drag_end(void)
2359 ime_error_e retVal = IME_ERROR_NONE;
2361 retVal = _check_privilege();
2362 if (retVal != IME_ERROR_NONE) return retVal;
2365 LOGW("IME_ERROR_NOT_RUNNING");
2366 return IME_ERROR_NOT_RUNNING;
2370 g_core.set_floating_drag_enabled(false);
2372 return IME_ERROR_NONE;
2377 EXPORT_API int ime_set_window_creation_defer_flag(bool flag)
2379 ime_error_e retVal = IME_ERROR_NONE;
2381 retVal = _check_privilege();
2382 if (retVal != IME_ERROR_NONE) return retVal;
2384 g_core.set_window_creation_defer_flag(flag);
2386 return IME_ERROR_NONE;
2390 EXPORT_API int ime_event_set_prediction_hint_data_set_cb(ime_prediction_hint_data_set_cb callback_func, void *user_data)
2392 ime_error_e retVal = IME_ERROR_NONE;
2394 if (!callback_func) {
2395 LOGW("IME_ERROR_INVALID_PARAMETER");
2396 return IME_ERROR_INVALID_PARAMETER;
2399 retVal = _check_privilege();
2400 if (retVal != IME_ERROR_NONE) return retVal;
2402 g_event_callback.prediction_hint_data_set = callback_func;
2403 g_event_callback.prediction_hint_data_set_user_data = user_data;
2405 return IME_ERROR_NONE;
2409 EXPORT_API int ime_event_set_optimization_hint_set_cb(ime_optimization_hint_set_cb callback_func, void *user_data)
2412 ime_error_e retVal = IME_ERROR_NONE;
2414 if (!callback_func) {
2415 LOGW("IME_ERROR_INVALID_PARAMETER");
2416 return IME_ERROR_INVALID_PARAMETER;
2419 retVal = _check_privilege();
2420 if (retVal != IME_ERROR_NONE) return retVal;
2422 g_event_callback.optimization_hint_set = callback_func;
2423 g_event_callback.optimization_hint_set_user_data = user_data;
2425 return IME_ERROR_NONE;
2428 EXPORT_API int ime_event_set_process_key_event_with_imengine_cb(ime_process_key_event_with_imengine_cb callback_func, void *user_data)
2431 ime_error_e retVal = IME_ERROR_NONE;
2433 if (!callback_func) {
2434 LOGW("IME_ERROR_INVALID_PARAMETER");
2435 return IME_ERROR_INVALID_PARAMETER;
2438 retVal = _check_privilege();
2439 if (retVal != IME_ERROR_NONE) return retVal;
2441 g_event_callback.process_key_event_with_imengine = callback_func;
2442 g_event_callback.process_key_event_with_imengine_user_data = user_data;
2444 return IME_ERROR_NONE;
2447 EXPORT_API int ime_event_set_autocapital_type_set_cb(ime_autocapital_type_set_cb callback_func, void *user_data)
2450 ime_error_e retVal = IME_ERROR_NONE;
2452 if (!callback_func) {
2453 LOGW("IME_ERROR_INVALID_PARAMETER");
2454 return IME_ERROR_INVALID_PARAMETER;
2457 retVal = _check_privilege();
2458 if (retVal != IME_ERROR_NONE) return retVal;
2460 g_event_callback.autocapital_type_set = callback_func;
2461 g_event_callback.autocapital_type_set_user_data = user_data;
2463 return IME_ERROR_NONE;
2466 EXPORT_API int ime_event_set_prediction_allow_set_cb(ime_prediction_allow_set_cb callback_func, void *user_data)
2469 ime_error_e retVal = IME_ERROR_NONE;
2471 if (!callback_func) {
2472 LOGW("IME_ERROR_INVALID_PARAMETER");
2473 return IME_ERROR_INVALID_PARAMETER;
2476 retVal = _check_privilege();
2477 if (retVal != IME_ERROR_NONE) return retVal;
2479 g_event_callback.prediction_allow_set = callback_func;
2480 g_event_callback.prediction_allow_set_user_data = user_data;
2482 return IME_ERROR_NONE;
2485 EXPORT_API int ime_event_set_trigger_property_set_cb(ime_trigger_property_set_cb callback_func, void *user_data)
2488 ime_error_e retVal = IME_ERROR_NONE;
2490 if (!callback_func) {
2491 LOGW("IME_ERROR_INVALID_PARAMETER");
2492 return IME_ERROR_INVALID_PARAMETER;
2495 retVal = _check_privilege();
2496 if (retVal != IME_ERROR_NONE) return retVal;
2498 g_event_callback.trigger_property_set = callback_func;
2499 g_event_callback.trigger_property_set_user_data = user_data;
2501 return IME_ERROR_NONE;
2504 EXPORT_API int ime_event_set_candidate_more_window_show_cb(ime_candidate_more_window_show_cb callback_func, void *user_data)
2507 ime_error_e retVal = IME_ERROR_NONE;
2509 if (!callback_func) {
2510 LOGW("IME_ERROR_INVALID_PARAMETER");
2511 return IME_ERROR_INVALID_PARAMETER;
2514 retVal = _check_privilege();
2515 if (retVal != IME_ERROR_NONE) return retVal;
2517 g_event_callback.candidate_more_window_show = callback_func;
2518 g_event_callback.candidate_more_window_show_user_data = user_data;
2520 return IME_ERROR_NONE;
2523 EXPORT_API int ime_event_set_candidate_more_window_hide_cb(ime_candidate_more_window_hide_cb callback_func, void *user_data)
2526 ime_error_e retVal = IME_ERROR_NONE;
2528 if (!callback_func) {
2529 LOGW("IME_ERROR_INVALID_PARAMETER");
2530 return IME_ERROR_INVALID_PARAMETER;
2533 retVal = _check_privilege();
2534 if (retVal != IME_ERROR_NONE) return retVal;
2536 g_event_callback.candidate_more_window_hide = callback_func;
2537 g_event_callback.candidate_more_window_hide_user_data = user_data;
2539 return IME_ERROR_NONE;
2542 EXPORT_API int ime_event_set_aux_select_cb(ime_aux_select_cb callback_func, void *user_data)
2545 ime_error_e retVal = IME_ERROR_NONE;
2547 if (!callback_func) {
2548 LOGW("IME_ERROR_INVALID_PARAMETER");
2549 return IME_ERROR_INVALID_PARAMETER;
2552 retVal = _check_privilege();
2553 if (retVal != IME_ERROR_NONE) return retVal;
2555 g_event_callback.aux_select = callback_func;
2556 g_event_callback.aux_select_user_data = user_data;
2558 return IME_ERROR_NONE;
2561 EXPORT_API int ime_event_set_candidate_select_cb(ime_candidate_select_cb callback_func, void *user_data)
2564 ime_error_e retVal = IME_ERROR_NONE;
2566 if (!callback_func) {
2567 LOGW("IME_ERROR_INVALID_PARAMETER");
2568 return IME_ERROR_INVALID_PARAMETER;
2571 retVal = _check_privilege();
2572 if (retVal != IME_ERROR_NONE) return retVal;
2574 g_event_callback.candidate_select = callback_func;
2575 g_event_callback.candidate_select_user_data = user_data;
2577 return IME_ERROR_NONE;
2580 EXPORT_API int ime_event_set_candidate_table_page_up_cb(ime_candidate_table_page_up_cb callback_func, void *user_data)
2583 ime_error_e retVal = IME_ERROR_NONE;
2585 if (!callback_func) {
2586 LOGW("IME_ERROR_INVALID_PARAMETER");
2587 return IME_ERROR_INVALID_PARAMETER;
2590 retVal = _check_privilege();
2591 if (retVal != IME_ERROR_NONE) return retVal;
2593 g_event_callback.candidate_table_page_up = callback_func;
2594 g_event_callback.candidate_table_page_up_user_data = user_data;
2596 return IME_ERROR_NONE;
2599 EXPORT_API int ime_event_set_candidate_table_page_down_cb(ime_candidate_table_page_down_cb callback_func, void *user_data)
2602 ime_error_e retVal = IME_ERROR_NONE;
2604 if (!callback_func) {
2605 LOGW("IME_ERROR_INVALID_PARAMETER");
2606 return IME_ERROR_INVALID_PARAMETER;
2609 retVal = _check_privilege();
2610 if (retVal != IME_ERROR_NONE) return retVal;
2612 g_event_callback.candidate_table_page_down = callback_func;
2613 g_event_callback.candidate_table_page_down_user_data = user_data;
2615 return IME_ERROR_NONE;
2618 EXPORT_API int ime_event_set_candidate_table_page_size_chaned_cb(ime_candidate_table_page_size_chaned_cb callback_func, void *user_data)
2621 ime_error_e retVal = IME_ERROR_NONE;
2623 if (!callback_func) {
2624 LOGW("IME_ERROR_INVALID_PARAMETER");
2625 return IME_ERROR_INVALID_PARAMETER;
2628 retVal = _check_privilege();
2629 if (retVal != IME_ERROR_NONE) return retVal;
2631 g_event_callback.candidate_table_page_size_chaned = callback_func;
2632 g_event_callback.candidate_table_page_size_chaned_user_data = user_data;
2634 return IME_ERROR_NONE;
2637 EXPORT_API int ime_event_set_candidate_item_layout_set_cb(ime_candidate_item_layout_set_cb callback_func, void *user_data)
2640 ime_error_e retVal = IME_ERROR_NONE;
2642 if (!callback_func) {
2643 LOGW("IME_ERROR_INVALID_PARAMETER");
2644 return IME_ERROR_INVALID_PARAMETER;
2647 retVal = _check_privilege();
2648 if (retVal != IME_ERROR_NONE) return retVal;
2650 g_event_callback.candidate_item_layout_set = callback_func;
2651 g_event_callback.candidate_item_layout_set_user_data = user_data;
2653 return IME_ERROR_NONE;
2656 EXPORT_API int ime_event_set_displayed_candidate_number_chaned_cb(ime_displayed_candidate_number_chaned_cb callback_func, void *user_data)
2659 ime_error_e retVal = IME_ERROR_NONE;
2661 if (!callback_func) {
2662 LOGW("IME_ERROR_INVALID_PARAMETER");
2663 return IME_ERROR_INVALID_PARAMETER;
2666 retVal = _check_privilege();
2667 if (retVal != IME_ERROR_NONE) return retVal;
2669 g_event_callback.displayed_candidate_number_chaned = callback_func;
2670 g_event_callback.displayed_candidate_number_chaned_user_data = user_data;
2672 return IME_ERROR_NONE;
2675 EXPORT_API int ime_event_set_candidate_item_long_pressed_cb(ime_candidate_item_long_pressed_cb callback_func, void *user_data)
2678 ime_error_e retVal = IME_ERROR_NONE;
2680 if (!callback_func) {
2681 LOGW("IME_ERROR_INVALID_PARAMETER");
2682 return IME_ERROR_INVALID_PARAMETER;
2685 retVal = _check_privilege();
2686 if (retVal != IME_ERROR_NONE) return retVal;
2688 g_event_callback.candidate_item_long_pressed = callback_func;
2689 g_event_callback.candidate_item_long_pressed_user_data = user_data;
2691 return IME_ERROR_NONE;
2694 EXPORT_API int ime_show_aux_string(void)
2696 ime_error_e retVal = IME_ERROR_NONE;
2698 retVal = _check_privilege();
2699 if (retVal != IME_ERROR_NONE) return retVal;
2702 LOGW("IME_ERROR_NOT_RUNNING");
2703 return IME_ERROR_NOT_RUNNING;
2706 g_core.show_aux_string();
2708 return IME_ERROR_NONE;
2711 EXPORT_API int ime_hide_aux_string(void)
2713 ime_error_e retVal = IME_ERROR_NONE;
2715 retVal = _check_privilege();
2716 if (retVal != IME_ERROR_NONE) return retVal;
2719 LOGW("IME_ERROR_NOT_RUNNING");
2720 return IME_ERROR_NOT_RUNNING;
2723 g_core.hide_aux_string();
2725 return IME_ERROR_NONE;
2728 EXPORT_API int ime_show_lookup_table(void)
2730 ime_error_e retVal = IME_ERROR_NONE;
2732 retVal = _check_privilege();
2733 if (retVal != IME_ERROR_NONE) return retVal;
2736 LOGW("IME_ERROR_NOT_RUNNING");
2737 return IME_ERROR_NOT_RUNNING;
2740 g_core.show_candidate_string();
2742 return IME_ERROR_NONE;
2745 EXPORT_API int ime_hide_lookup_table(void)
2747 ime_error_e retVal = IME_ERROR_NONE;
2749 retVal = _check_privilege();
2750 if (retVal != IME_ERROR_NONE) return retVal;
2753 LOGW("IME_ERROR_NOT_RUNNING");
2754 return IME_ERROR_NOT_RUNNING;
2757 g_core.hide_candidate_string();
2759 return IME_ERROR_NONE;
2762 EXPORT_API int ime_update_preedit_caret(int caret)
2764 ime_error_e retVal = IME_ERROR_NONE;
2767 LOGW("IME_ERROR_INVALID_PARAMETER");
2768 return IME_ERROR_INVALID_PARAMETER;
2772 LOGW("IME_ERROR_NOT_RUNNING");
2773 return IME_ERROR_NOT_RUNNING;
2776 retVal = _check_privilege();
2777 if (retVal != IME_ERROR_NONE) return retVal;
2779 g_core.update_preedit_caret(caret);
2781 return IME_ERROR_NONE;
2784 EXPORT_API int ime_update_preedit_string_with_commit(const char *preedit, const char *commit, scim::AttributeList &attrs, int caret)
2786 ime_error_e retVal = IME_ERROR_NONE;
2788 if (!preedit && !commit) {
2789 LOGW("IME_ERROR_INVALID_PARAMETER");
2790 return IME_ERROR_INVALID_PARAMETER;
2794 LOGW("IME_ERROR_NOT_RUNNING");
2795 return IME_ERROR_NOT_RUNNING;
2798 retVal = _check_privilege();
2799 if (retVal != IME_ERROR_NONE) return retVal;
2801 g_core.update_preedit_string_with_commit(preedit, commit, attrs, caret);
2803 return IME_ERROR_NONE;
2806 EXPORT_API int ime_update_aux_string(const char *str)
2808 ime_error_e retVal = IME_ERROR_NONE;
2811 LOGW("IME_ERROR_INVALID_PARAMETER");
2812 return IME_ERROR_INVALID_PARAMETER;
2816 LOGW("IME_ERROR_NOT_RUNNING");
2817 return IME_ERROR_NOT_RUNNING;
2820 retVal = _check_privilege();
2821 if (retVal != IME_ERROR_NONE) return retVal;
2823 g_core.update_aux_string(str);
2825 return IME_ERROR_NONE;
2828 EXPORT_API int ime_recapture_string(int offset, int len, const char *preedit, const char *commit, scim::AttributeList &attrs)
2830 ime_error_e retVal = IME_ERROR_NONE;
2833 LOGW("IME_ERROR_INVALID_PARAMETER");
2834 return IME_ERROR_INVALID_PARAMETER;
2838 LOGW("IME_ERROR_NOT_RUNNING");
2839 return IME_ERROR_NOT_RUNNING;
2842 retVal = _check_privilege();
2843 if (retVal != IME_ERROR_NONE) return retVal;
2845 g_core.recapture_string(offset, len, preedit, commit, attrs);
2847 return IME_ERROR_NONE;
2850 EXPORT_API int ime_update_lookup_table(scim::LookupTable &table)
2852 ime_error_e retVal = IME_ERROR_NONE;
2855 LOGW("IME_ERROR_NOT_RUNNING");
2856 return IME_ERROR_NOT_RUNNING;
2859 retVal = _check_privilege();
2860 if (retVal != IME_ERROR_NONE) return retVal;
2862 g_core.update_lookup_table(table);
2864 return IME_ERROR_NONE;
2867 EXPORT_API int ime_register_properties(scim::PropertyList &properties)
2869 ime_error_e retVal = IME_ERROR_NONE;
2872 LOGW("IME_ERROR_NOT_RUNNING");
2873 return IME_ERROR_NOT_RUNNING;
2876 retVal = _check_privilege();
2877 if (retVal != IME_ERROR_NONE) return retVal;
2879 g_core.register_properties(properties);
2881 return IME_ERROR_NONE;
2884 EXPORT_API int ime_update_property(scim::Property &property)
2886 ime_error_e retVal = IME_ERROR_NONE;
2889 LOGW("IME_ERROR_NOT_RUNNING");
2890 return IME_ERROR_NOT_RUNNING;
2893 retVal = _check_privilege();
2894 if (retVal != IME_ERROR_NONE) return retVal;
2896 g_core.update_property(property);
2898 return IME_ERROR_NONE;
2901 EXPORT_API int ime_expand_candidate(void)
2903 ime_error_e retVal = IME_ERROR_NONE;
2905 retVal = _check_privilege();
2906 if (retVal != IME_ERROR_NONE) return retVal;
2909 LOGW("IME_ERROR_NOT_RUNNING");
2910 return IME_ERROR_NOT_RUNNING;
2913 g_core.expand_candidate();
2915 return IME_ERROR_NONE;
2918 EXPORT_API int ime_contract_candidate(void)
2920 ime_error_e retVal = IME_ERROR_NONE;
2922 retVal = _check_privilege();
2923 if (retVal != IME_ERROR_NONE) return retVal;
2926 LOGW("IME_ERROR_NOT_RUNNING");
2927 return IME_ERROR_NOT_RUNNING;
2930 g_core.contract_candidate();
2932 return IME_ERROR_NONE;
2935 EXPORT_API int ime_set_candidate_style(scim::ISF_CANDIDATE_PORTRAIT_LINE_T portrait_line, scim::ISF_CANDIDATE_MODE_T mode)
2937 ime_error_e retVal = IME_ERROR_NONE;
2940 LOGW("IME_ERROR_NOT_RUNNING");
2941 return IME_ERROR_NOT_RUNNING;
2944 retVal = _check_privilege();
2945 if (retVal != IME_ERROR_NONE) return retVal;
2947 g_core.set_candidate_style(portrait_line, mode);
2949 return IME_ERROR_NONE;
2952 EXPORT_API int ime_set_engine_loader_flag(bool flag)
2954 ime_error_e retVal = IME_ERROR_NONE;
2957 LOGW("IME_ERROR_NOT_RUNNING");
2958 return IME_ERROR_NOT_RUNNING;
2961 retVal = _check_privilege();
2962 if (retVal != IME_ERROR_NONE) return retVal;
2964 g_core.set_engine_loader_flag(flag);
2966 return IME_ERROR_NONE;
2969 EXPORT_API int ime_send_key_event_processing_result(scim::KeyEvent &key, uint32_t serial, bool is_success)
2971 ime_error_e retVal = IME_ERROR_NONE;
2974 LOGW("IME_ERROR_NOT_RUNNING");
2975 return IME_ERROR_NOT_RUNNING;
2978 retVal = _check_privilege();
2979 if (retVal != IME_ERROR_NONE) return retVal;
2981 g_core.send_key_event_processing_result(key, serial, is_success);
2983 return IME_ERROR_NONE;
2987 EXPORT_API int ime_update_input_panel_event(ime_event_type_e type, unsigned int value)
2989 ime_error_e retVal = IME_ERROR_NONE;
2991 if (type < IME_EVENT_TYPE_LANGUAGE || type > IME_EVENT_TYPE_GEOMETRY) {
2992 LOGW("IME_ERROR_INVALID_PARAMETER");
2993 return IME_ERROR_INVALID_PARAMETER;
2997 LOGW("IME_ERROR_NOT_RUNNING");
2998 return IME_ERROR_NOT_RUNNING;
3002 retVal = _check_privilege();
3003 if (retVal != IME_ERROR_NONE) return retVal;
3005 g_core.update_input_context((sclu32)type, value);
3007 return IME_ERROR_NONE;
3011 EXPORT_API int ime_set_candidate_visibility_state(bool visible)
3013 ime_error_e retVal = IME_ERROR_NONE;
3016 LOGW("IME_ERROR_NOT_RUNNING");
3017 return IME_ERROR_NOT_RUNNING;
3021 retVal = _check_privilege();
3022 if (retVal != IME_ERROR_NONE) return retVal;
3025 g_core.show_candidate_string();
3027 g_core.hide_candidate_string();
3029 return IME_ERROR_NONE;