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;
1571 EXPORT_API int ime_set_native_window_size(Ecore_Wl2_Window *window, int portrait_width, int portrait_height, int landscape_width, int landscape_height)
1573 ime_error_e retVal = IME_ERROR_NONE;
1575 if (!window || portrait_width < 1 || portrait_height < 1 || landscape_width < 1 || landscape_height < 1) {
1576 LOGW("IME_ERROR_INVALID_PARAMETER");
1577 return IME_ERROR_INVALID_PARAMETER;
1581 LOGW("IME_ERROR_NOT_RUNNING");
1582 return IME_ERROR_NOT_RUNNING;
1585 retVal = _check_privilege();
1586 if (retVal != IME_ERROR_NONE) return retVal;
1588 ecore_wl2_window_rotation_geometry_set(window, 0, 0, 0, portrait_width, portrait_height);
1589 ecore_wl2_window_rotation_geometry_set(window, 90, 0, 0, landscape_height, landscape_width);
1590 ecore_wl2_window_rotation_geometry_set(window, 180, 0, 0, portrait_width, portrait_height);
1591 ecore_wl2_window_rotation_geometry_set(window, 270, 0, 0, landscape_height, landscape_width);
1593 return IME_ERROR_NONE;
1597 EXPORT_API int ime_create_option_window(void)
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("IME_ERROR_NOT_RUNNING");
1608 return IME_ERROR_NOT_RUNNING;
1612 retVal = _check_privilege();
1613 if (retVal != IME_ERROR_NONE) return retVal;
1615 if (g_core.create_option_window()) {
1616 return IME_ERROR_NONE;
1618 LOGW("IME_ERROR_OPERATION_FAILED");
1619 return IME_ERROR_OPERATION_FAILED;
1624 EXPORT_API int ime_destroy_option_window(Evas_Object *window)
1626 ime_error_e retVal = IME_ERROR_NONE;
1628 if (!g_event_callback.option_window_created || !g_event_callback.option_window_destroyed) {
1629 LOGW("ime_create_option_window_cb() and ime_destroy_option_window_cb() callback functions are not set.");
1630 return IME_ERROR_NO_CALLBACK_FUNCTION;
1634 LOGW("Window pointer is null.");
1635 return IME_ERROR_INVALID_PARAMETER;
1639 LOGW("IME_ERROR_NOT_RUNNING");
1640 return IME_ERROR_NOT_RUNNING;
1644 retVal = _check_privilege();
1645 if (retVal != IME_ERROR_NONE) return retVal;
1647 g_core.destroy_option_window(window);
1649 return IME_ERROR_NONE;
1654 EXPORT_API int ime_set_imengine(const char *engine_id)
1656 ime_error_e retVal = IME_ERROR_NONE;
1659 LOGW("IME_ERROR_INVALID_PARAMETER");
1660 return IME_ERROR_INVALID_PARAMETER;
1663 retVal = _check_privilege();
1664 if (retVal != IME_ERROR_NONE) return retVal;
1666 g_core.set_keyboard_ise_by_uuid(engine_id);
1668 return IME_ERROR_NONE;
1671 EXPORT_API int ime_flush_imengine(void)
1673 ime_error_e retVal = IME_ERROR_NONE;
1676 LOGW("IME_ERROR_NOT_RUNNING");
1677 return IME_ERROR_NOT_RUNNING;
1680 retVal = _check_privilege();
1681 if (retVal != IME_ERROR_NONE) return retVal;
1683 g_core.flush_keyboard_ise();
1685 return IME_ERROR_NONE;
1688 EXPORT_API int ime_send_imengine_event(int command, unsigned int value)
1690 ime_error_e retVal = IME_ERROR_NONE;
1693 LOGW("IME_ERROR_NOT_RUNNING");
1694 return IME_ERROR_NOT_RUNNING;
1697 retVal = _check_privilege();
1698 if (retVal != IME_ERROR_NONE) return retVal;
1700 g_core.send_imengine_event(-1, NULL, command, value);
1702 return IME_ERROR_NONE;
1705 EXPORT_API int ime_reset_imengine(void)
1707 ime_error_e retVal = IME_ERROR_NONE;
1710 LOGW("IME_ERROR_NOT_RUNNING");
1711 return IME_ERROR_NOT_RUNNING;
1714 retVal = _check_privilege();
1715 if (retVal != IME_ERROR_NONE) return retVal;
1717 g_core.reset_keyboard_ise();
1719 return IME_ERROR_NONE;
1722 EXPORT_API int ime_update_input_context(unsigned int type, unsigned int value)
1724 ime_error_e retVal = IME_ERROR_NONE;
1727 LOGW("IME_ERROR_NOT_RUNNING");
1728 return IME_ERROR_NOT_RUNNING;
1731 retVal = _check_privilege();
1732 if (retVal != IME_ERROR_NONE) return retVal;
1734 g_core.update_input_context(type, value);
1736 return IME_ERROR_NONE;
1740 EXPORT_API int ime_request_hide(void)
1742 ime_error_e retVal = IME_ERROR_NONE;
1745 LOGW("IME_ERROR_NOT_RUNNING");
1746 return IME_ERROR_NOT_RUNNING;
1750 retVal = _check_privilege();
1751 if (retVal != IME_ERROR_NONE) return retVal;
1753 g_core.request_ise_hide();
1755 return IME_ERROR_NONE;
1760 EXPORT_API int ime_initialize(void)
1762 ime_error_e retVal = IME_ERROR_NONE;
1764 retVal = _check_privilege();
1765 if (retVal != IME_ERROR_NONE) return retVal;
1773 EXPORT_API int ime_prepare(void)
1775 ime_error_e retVal = IME_ERROR_NONE;
1778 LOGE("inputmethod main loop is already running.");
1779 return IME_ERROR_OPERATION_FAILED;
1782 retVal = _check_privilege();
1783 if (retVal != IME_ERROR_NONE) return retVal;
1785 g_core.set_dotnet_flag(g_from_dotnet);
1793 EXPORT_API int ime_finalize(void)
1795 ime_error_e retVal = IME_ERROR_NONE;
1797 retVal = _check_privilege();
1798 if (retVal != IME_ERROR_NONE) return retVal;
1802 memset(&g_basic_callback, 0, sizeof(ime_callback_s));
1803 memset(&g_event_callback, 0, sizeof(ime_event_callback_s));
1809 EXPORT_API int ime_select_candidate(unsigned int index)
1811 ime_error_e retVal = IME_ERROR_NONE;
1814 LOGW("IME_ERROR_NOT_RUNNING");
1815 return IME_ERROR_NOT_RUNNING;
1818 retVal = _check_privilege();
1819 if (retVal != IME_ERROR_NONE) return retVal;
1821 g_core.select_candidate(index);
1823 return IME_ERROR_NONE;
1827 EXPORT_API int ime_send_private_command(const char *command)
1829 ime_error_e retVal = IME_ERROR_NONE;
1832 LOGW("IME_ERROR_INVALID_PARAMETER");
1833 return IME_ERROR_INVALID_PARAMETER;
1837 LOGW("IME_ERROR_NOT_RUNNING");
1838 return IME_ERROR_NOT_RUNNING;
1842 retVal = _check_privilege();
1843 if (retVal != IME_ERROR_NONE) return retVal;
1845 g_core.send_private_command(command);
1847 return IME_ERROR_NONE;
1851 EXPORT_API int ime_commit_content(const char *content, const char *description, const char *mime_type)
1853 ime_error_e retVal = IME_ERROR_NONE;
1855 if (!content || !description || !mime_type) {
1856 LOGW("IME_ERROR_INVALID_PARAMETER");
1857 return IME_ERROR_INVALID_PARAMETER;
1860 retVal = _check_privilege();
1861 if (retVal != IME_ERROR_NONE) return retVal;
1864 LOGW("IME_ERROR_NOT_RUNNING");
1865 return IME_ERROR_NOT_RUNNING;
1869 SECURE_LOGI("content : '%s', description : '%s', mime_type : '%s'", content, description, mime_type);
1870 g_core.commit_content(content, description, mime_type);
1872 return IME_ERROR_NONE;
1876 EXPORT_API int ime_context_get_layout(ime_context_h context, Ecore_IMF_Input_Panel_Layout *layout)
1878 ime_error_e retVal = IME_ERROR_NONE;
1880 if (!context || !layout) {
1881 LOGW("IME_ERROR_INVALID_PARAMETER");
1882 return IME_ERROR_INVALID_PARAMETER;
1885 retVal = _check_privilege();
1886 if (retVal != IME_ERROR_NONE) return retVal;
1889 LOGW("IME_ERROR_NOT_RUNNING");
1890 return IME_ERROR_NOT_RUNNING;
1894 *layout = context->layout;
1896 return IME_ERROR_NONE;
1900 EXPORT_API int ime_context_get_layout_variation(ime_context_h context, ime_layout_variation_e *layout_variation)
1902 ime_error_e retVal = IME_ERROR_NONE;
1904 if (!context || !layout_variation) {
1905 LOGW("IME_ERROR_INVALID_PARAMETER");
1906 return IME_ERROR_INVALID_PARAMETER;
1909 retVal = _check_privilege();
1910 if (retVal != IME_ERROR_NONE) return retVal;
1913 LOGW("IME_ERROR_NOT_RUNNING");
1914 return IME_ERROR_NOT_RUNNING;
1918 *layout_variation = static_cast<ime_layout_variation_e>(context->layout_variation);
1920 return IME_ERROR_NONE;
1924 EXPORT_API int ime_context_get_cursor_position(ime_context_h context, int *cursor_pos)
1926 ime_error_e retVal = IME_ERROR_NONE;
1928 if (!context || !cursor_pos) {
1929 LOGW("IME_ERROR_INVALID_PARAMETER");
1930 return IME_ERROR_INVALID_PARAMETER;
1933 retVal = _check_privilege();
1934 if (retVal != IME_ERROR_NONE) return retVal;
1937 LOGW("IME_ERROR_NOT_RUNNING");
1938 return IME_ERROR_NOT_RUNNING;
1942 *cursor_pos = context->cursor_pos;
1944 return IME_ERROR_NONE;
1948 EXPORT_API int ime_context_get_autocapital_type(ime_context_h context, Ecore_IMF_Autocapital_Type *autocapital_type)
1950 ime_error_e retVal = IME_ERROR_NONE;
1952 if (!context || !autocapital_type) {
1953 LOGW("IME_ERROR_INVALID_PARAMETER");
1954 return IME_ERROR_INVALID_PARAMETER;
1957 retVal = _check_privilege();
1958 if (retVal != IME_ERROR_NONE) return retVal;
1961 LOGW("IME_ERROR_NOT_RUNNING");
1962 return IME_ERROR_NOT_RUNNING;
1966 *autocapital_type = context->autocapital_type;
1968 return IME_ERROR_NONE;
1972 EXPORT_API int ime_context_get_return_key_type(ime_context_h context, Ecore_IMF_Input_Panel_Return_Key_Type *return_key_type)
1974 ime_error_e retVal = IME_ERROR_NONE;
1976 if (!context || !return_key_type) {
1977 LOGW("IME_ERROR_INVALID_PARAMETER");
1978 return IME_ERROR_INVALID_PARAMETER;
1981 retVal = _check_privilege();
1982 if (retVal != IME_ERROR_NONE) return retVal;
1985 LOGW("IME_ERROR_NOT_RUNNING");
1986 return IME_ERROR_NOT_RUNNING;
1990 *return_key_type = context->return_key_type;
1992 return IME_ERROR_NONE;
1996 EXPORT_API int ime_context_get_return_key_state(ime_context_h context, bool *return_key_state)
1998 ime_error_e retVal = IME_ERROR_NONE;
2000 if (!context || !return_key_state) {
2001 LOGW("IME_ERROR_INVALID_PARAMETER");
2002 return IME_ERROR_INVALID_PARAMETER;
2005 retVal = _check_privilege();
2006 if (retVal != IME_ERROR_NONE) return retVal;
2009 LOGW("IME_ERROR_NOT_RUNNING");
2010 return IME_ERROR_NOT_RUNNING;
2014 *return_key_state = static_cast<bool>(context->return_key_disabled);
2016 return IME_ERROR_NONE;
2020 EXPORT_API int ime_context_get_prediction_mode(ime_context_h context, bool *prediction_mode)
2022 ime_error_e retVal = IME_ERROR_NONE;
2024 if (!context || !prediction_mode) {
2025 LOGW("IME_ERROR_INVALID_PARAMETER");
2026 return IME_ERROR_INVALID_PARAMETER;
2029 retVal = _check_privilege();
2030 if (retVal != IME_ERROR_NONE) return retVal;
2033 LOGW("IME_ERROR_NOT_RUNNING");
2034 return IME_ERROR_NOT_RUNNING;
2038 *prediction_mode = static_cast<bool>(context->prediction_allow);
2040 return IME_ERROR_NONE;
2044 EXPORT_API int ime_context_get_password_mode(ime_context_h context, bool *password_mode)
2046 ime_error_e retVal = IME_ERROR_NONE;
2048 if (!context || !password_mode) {
2049 LOGW("IME_ERROR_INVALID_PARAMETER");
2050 return IME_ERROR_INVALID_PARAMETER;
2053 retVal = _check_privilege();
2054 if (retVal != IME_ERROR_NONE) return retVal;
2057 LOGW("IME_ERROR_NOT_RUNNING");
2058 return IME_ERROR_NOT_RUNNING;
2062 *password_mode = static_cast<bool>(context->password_mode);
2064 return IME_ERROR_NONE;
2068 EXPORT_API int ime_context_get_input_hint(ime_context_h context, Ecore_IMF_Input_Hints *input_hint)
2070 ime_error_e retVal = IME_ERROR_NONE;
2072 if (!context || !input_hint) {
2073 LOGW("IME_ERROR_INVALID_PARAMETER");
2074 return IME_ERROR_INVALID_PARAMETER;
2077 retVal = _check_privilege();
2078 if (retVal != IME_ERROR_NONE) return retVal;
2081 LOGW("IME_ERROR_NOT_RUNNING");
2082 return IME_ERROR_NOT_RUNNING;
2086 *input_hint = context->input_hint;
2088 return IME_ERROR_NONE;
2092 EXPORT_API int ime_context_get_bidi_direction(ime_context_h context, Ecore_IMF_BiDi_Direction *bidi)
2094 ime_error_e retVal = IME_ERROR_NONE;
2096 if (!context || !bidi) {
2097 LOGW("IME_ERROR_INVALID_PARAMETER");
2098 return IME_ERROR_INVALID_PARAMETER;
2101 retVal = _check_privilege();
2102 if (retVal != IME_ERROR_NONE) return retVal;
2105 LOGW("IME_ERROR_NOT_RUNNING");
2106 return IME_ERROR_NOT_RUNNING;
2110 *bidi = context->bidi_direction;
2112 return IME_ERROR_NONE;
2116 EXPORT_API int ime_context_get_language(ime_context_h context, Ecore_IMF_Input_Panel_Lang *language)
2118 ime_error_e retVal = IME_ERROR_NONE;
2120 if (!context || !language) {
2121 LOGW("IME_ERROR_INVALID_PARAMETER");
2122 return IME_ERROR_INVALID_PARAMETER;
2125 retVal = _check_privilege();
2126 if (retVal != IME_ERROR_NONE) return retVal;
2129 LOGW("IME_ERROR_NOT_RUNNING");
2130 return IME_ERROR_NOT_RUNNING;
2134 *language = context->language;
2136 return IME_ERROR_NONE;
2141 EXPORT_API int ime_context_get_caps_mode(ime_context_h context, bool *caps_mode)
2143 ime_error_e retVal = IME_ERROR_NONE;
2145 if (!context || !caps_mode) {
2146 LOGW("IME_ERROR_INVALID_PARAMETER");
2147 return IME_ERROR_INVALID_PARAMETER;
2150 retVal = _check_privilege();
2151 if (retVal != IME_ERROR_NONE) return retVal;
2154 LOGW("IME_ERROR_NOT_RUNNING");
2155 return IME_ERROR_NOT_RUNNING;
2158 *caps_mode = static_cast<bool>(context->caps_mode);
2160 return IME_ERROR_NONE;
2164 EXPORT_API int ime_device_info_get_name(ime_device_info_h dev_info, char **dev_name)
2166 ime_error_e retVal = IME_ERROR_NONE;
2168 if (!dev_info || !dev_name) {
2169 LOGW("IME_ERROR_INVALID_PARAMETER");
2170 return IME_ERROR_INVALID_PARAMETER;
2173 retVal = _check_privilege();
2174 if (retVal != IME_ERROR_NONE) return retVal;
2177 LOGW("IME_ERROR_NOT_RUNNING");
2178 return IME_ERROR_NOT_RUNNING;
2182 if (!dev_info->dev_name)
2183 *dev_name = strdup("");
2185 *dev_name = strdup(dev_info->dev_name);
2187 return IME_ERROR_NONE;
2191 EXPORT_API int ime_device_info_get_class(ime_device_info_h dev_info, Ecore_IMF_Device_Class *dev_class)
2193 ime_error_e retVal = IME_ERROR_NONE;
2195 if (!dev_info || !dev_class) {
2196 LOGW("IME_ERROR_INVALID_PARAMETER");
2197 return IME_ERROR_INVALID_PARAMETER;
2200 retVal = _check_privilege();
2201 if (retVal != IME_ERROR_NONE) return retVal;
2204 LOGW("IME_ERROR_NOT_RUNNING");
2205 return IME_ERROR_NOT_RUNNING;
2209 *dev_class = dev_info->dev_class;
2211 return IME_ERROR_NONE;
2215 EXPORT_API int ime_device_info_get_subclass(ime_device_info_h dev_info, Ecore_IMF_Device_Subclass *dev_subclass)
2217 ime_error_e retVal = IME_ERROR_NONE;
2219 if (!dev_info || !dev_subclass) {
2220 LOGW("IME_ERROR_INVALID_PARAMETER");
2221 return IME_ERROR_INVALID_PARAMETER;
2224 retVal = _check_privilege();
2225 if (retVal != IME_ERROR_NONE) return retVal;
2228 LOGW("IME_ERROR_NOT_RUNNING");
2229 return IME_ERROR_NOT_RUNNING;
2233 *dev_subclass = dev_info->dev_subclass;
2235 return IME_ERROR_NONE;
2240 EXPORT_API int ime_event_set_process_input_device_event_cb(ime_process_input_device_event_cb callback_func, void *user_data)
2242 ime_error_e retVal = IME_ERROR_NONE;
2244 if (!callback_func) {
2245 LOGW("IME_ERROR_INVALID_PARAMETER");
2246 return IME_ERROR_INVALID_PARAMETER;
2249 retVal = _check_privilege();
2250 if (retVal != IME_ERROR_NONE) return retVal;
2252 g_event_callback.process_input_device_event = callback_func;
2253 g_event_callback.process_input_device_event_user_data = user_data;
2255 return IME_ERROR_NONE;
2258 EXPORT_API int ime_event_unset_process_input_device_event_cb(void)
2260 ime_error_e retVal = IME_ERROR_NONE;
2262 retVal = _check_privilege();
2263 if (retVal != IME_ERROR_NONE) return retVal;
2265 g_event_callback.process_input_device_event = NULL;
2266 g_event_callback.process_input_device_event_user_data = NULL;
2268 return IME_ERROR_NONE;
2271 /* Functions for Rotary input device event */
2272 EXPORT_API int ime_input_device_rotary_get_direction(ime_input_device_event_h event_handle, ime_input_device_rotary_direction_e *direction)
2274 ime_error_e retVal = IME_ERROR_NONE;
2276 if (!event_handle || !direction) {
2277 LOGW("IME_ERROR_INVALID_PARAMETER");
2278 return IME_ERROR_INVALID_PARAMETER;
2281 ime_device_event_s *device_event = static_cast<ime_device_event_s*>(event_handle);
2282 if (device_event->device_type != IME_INPUT_DEVICE_TYPE_ROTARY) {
2283 LOGW("IME_ERROR_INVALID_PARAMETER");
2284 return IME_ERROR_INVALID_PARAMETER;
2287 retVal = _check_privilege();
2288 if (retVal != IME_ERROR_NONE) return retVal;
2291 LOGW("IME_ERROR_OPERATION_FAILED");
2292 return IME_ERROR_OPERATION_FAILED;
2296 Ecore_Event_Detent_Rotate *rotary_device_event =
2297 static_cast<Ecore_Event_Detent_Rotate*>(device_event->event_data);
2298 if (rotary_device_event) {
2299 if (rotary_device_event->direction == ECORE_DETENT_DIRECTION_CLOCKWISE) {
2300 *direction = IME_INPUT_DEVICE_ROTARY_DIRECTION_CLOCKWISE;
2301 } else if (rotary_device_event->direction == ECORE_DETENT_DIRECTION_COUNTER_CLOCKWISE) {
2302 *direction = IME_INPUT_DEVICE_ROTARY_DIRECTION_COUNTER_CLOCKWISE;
2306 return IME_ERROR_NONE;
2311 EXPORT_API int ime_event_set_prediction_hint_set_cb(ime_prediction_hint_set_cb callback_func, void *user_data)
2313 ime_error_e retVal = IME_ERROR_NONE;
2315 if (!callback_func) {
2316 LOGW("IME_ERROR_INVALID_PARAMETER");
2317 return IME_ERROR_INVALID_PARAMETER;
2320 retVal = _check_privilege();
2321 if (retVal != IME_ERROR_NONE) return retVal;
2323 g_event_callback.prediction_hint_set = callback_func;
2324 g_event_callback.prediction_hint_set_user_data = user_data;
2326 return IME_ERROR_NONE;
2329 EXPORT_API int ime_event_set_mime_type_set_request_cb(ime_mime_type_set_request_cb callback_func, void *user_data)
2331 ime_error_e retVal = IME_ERROR_NONE;
2333 if (!callback_func) {
2334 LOGW("IME_ERROR_INVALID_PARAMETER");
2335 return IME_ERROR_INVALID_PARAMETER;
2338 retVal = _check_privilege();
2339 if (retVal != IME_ERROR_NONE) return retVal;
2341 g_event_callback.mime_type_set = callback_func;
2342 g_event_callback.mime_type_set_user_data = user_data;
2344 return IME_ERROR_NONE;
2347 EXPORT_API int ime_set_floating_mode(bool floating_mode)
2349 ime_error_e retVal = IME_ERROR_NONE;
2351 retVal = _check_privilege();
2352 if (retVal != IME_ERROR_NONE) return retVal;
2355 LOGW("IME_ERROR_NOT_RUNNING");
2356 return IME_ERROR_NOT_RUNNING;
2360 g_core.set_floating_mode(floating_mode);
2362 return IME_ERROR_NONE;
2366 EXPORT_API int ime_set_floating_drag_start(void)
2368 ime_error_e retVal = IME_ERROR_NONE;
2370 retVal = _check_privilege();
2371 if (retVal != IME_ERROR_NONE) return retVal;
2374 LOGW("IME_ERROR_NOT_RUNNING");
2375 return IME_ERROR_NOT_RUNNING;
2379 g_core.set_floating_drag_enabled(true);
2381 return IME_ERROR_NONE;
2385 EXPORT_API int ime_set_floating_drag_end(void)
2387 ime_error_e retVal = IME_ERROR_NONE;
2389 retVal = _check_privilege();
2390 if (retVal != IME_ERROR_NONE) return retVal;
2393 LOGW("IME_ERROR_NOT_RUNNING");
2394 return IME_ERROR_NOT_RUNNING;
2398 g_core.set_floating_drag_enabled(false);
2400 return IME_ERROR_NONE;
2405 EXPORT_API int ime_set_window_creation_defer_flag(bool flag)
2407 ime_error_e retVal = IME_ERROR_NONE;
2409 retVal = _check_privilege();
2410 if (retVal != IME_ERROR_NONE) return retVal;
2412 g_core.set_window_creation_defer_flag(flag);
2414 return IME_ERROR_NONE;
2418 EXPORT_API int ime_event_set_prediction_hint_data_set_cb(ime_prediction_hint_data_set_cb callback_func, void *user_data)
2420 ime_error_e retVal = IME_ERROR_NONE;
2422 if (!callback_func) {
2423 LOGW("IME_ERROR_INVALID_PARAMETER");
2424 return IME_ERROR_INVALID_PARAMETER;
2427 retVal = _check_privilege();
2428 if (retVal != IME_ERROR_NONE) return retVal;
2430 g_event_callback.prediction_hint_data_set = callback_func;
2431 g_event_callback.prediction_hint_data_set_user_data = user_data;
2433 return IME_ERROR_NONE;
2437 EXPORT_API int ime_event_set_optimization_hint_set_cb(ime_optimization_hint_set_cb callback_func, void *user_data)
2440 ime_error_e retVal = IME_ERROR_NONE;
2442 if (!callback_func) {
2443 LOGW("IME_ERROR_INVALID_PARAMETER");
2444 return IME_ERROR_INVALID_PARAMETER;
2447 retVal = _check_privilege();
2448 if (retVal != IME_ERROR_NONE) return retVal;
2450 g_event_callback.optimization_hint_set = callback_func;
2451 g_event_callback.optimization_hint_set_user_data = user_data;
2453 return IME_ERROR_NONE;
2456 EXPORT_API int ime_event_set_process_key_event_with_imengine_cb(ime_process_key_event_with_imengine_cb callback_func, void *user_data)
2459 ime_error_e retVal = IME_ERROR_NONE;
2461 if (!callback_func) {
2462 LOGW("IME_ERROR_INVALID_PARAMETER");
2463 return IME_ERROR_INVALID_PARAMETER;
2466 retVal = _check_privilege();
2467 if (retVal != IME_ERROR_NONE) return retVal;
2469 g_event_callback.process_key_event_with_imengine = callback_func;
2470 g_event_callback.process_key_event_with_imengine_user_data = user_data;
2472 return IME_ERROR_NONE;
2475 EXPORT_API int ime_event_set_autocapital_type_set_cb(ime_autocapital_type_set_cb callback_func, void *user_data)
2478 ime_error_e retVal = IME_ERROR_NONE;
2480 if (!callback_func) {
2481 LOGW("IME_ERROR_INVALID_PARAMETER");
2482 return IME_ERROR_INVALID_PARAMETER;
2485 retVal = _check_privilege();
2486 if (retVal != IME_ERROR_NONE) return retVal;
2488 g_event_callback.autocapital_type_set = callback_func;
2489 g_event_callback.autocapital_type_set_user_data = user_data;
2491 return IME_ERROR_NONE;
2494 EXPORT_API int ime_event_set_prediction_allow_set_cb(ime_prediction_allow_set_cb callback_func, void *user_data)
2497 ime_error_e retVal = IME_ERROR_NONE;
2499 if (!callback_func) {
2500 LOGW("IME_ERROR_INVALID_PARAMETER");
2501 return IME_ERROR_INVALID_PARAMETER;
2504 retVal = _check_privilege();
2505 if (retVal != IME_ERROR_NONE) return retVal;
2507 g_event_callback.prediction_allow_set = callback_func;
2508 g_event_callback.prediction_allow_set_user_data = user_data;
2510 return IME_ERROR_NONE;
2513 EXPORT_API int ime_event_set_trigger_property_set_cb(ime_trigger_property_set_cb callback_func, void *user_data)
2516 ime_error_e retVal = IME_ERROR_NONE;
2518 if (!callback_func) {
2519 LOGW("IME_ERROR_INVALID_PARAMETER");
2520 return IME_ERROR_INVALID_PARAMETER;
2523 retVal = _check_privilege();
2524 if (retVal != IME_ERROR_NONE) return retVal;
2526 g_event_callback.trigger_property_set = callback_func;
2527 g_event_callback.trigger_property_set_user_data = user_data;
2529 return IME_ERROR_NONE;
2532 EXPORT_API int ime_event_set_candidate_more_window_show_cb(ime_candidate_more_window_show_cb callback_func, void *user_data)
2535 ime_error_e retVal = IME_ERROR_NONE;
2537 if (!callback_func) {
2538 LOGW("IME_ERROR_INVALID_PARAMETER");
2539 return IME_ERROR_INVALID_PARAMETER;
2542 retVal = _check_privilege();
2543 if (retVal != IME_ERROR_NONE) return retVal;
2545 g_event_callback.candidate_more_window_show = callback_func;
2546 g_event_callback.candidate_more_window_show_user_data = user_data;
2548 return IME_ERROR_NONE;
2551 EXPORT_API int ime_event_set_candidate_more_window_hide_cb(ime_candidate_more_window_hide_cb callback_func, void *user_data)
2554 ime_error_e retVal = IME_ERROR_NONE;
2556 if (!callback_func) {
2557 LOGW("IME_ERROR_INVALID_PARAMETER");
2558 return IME_ERROR_INVALID_PARAMETER;
2561 retVal = _check_privilege();
2562 if (retVal != IME_ERROR_NONE) return retVal;
2564 g_event_callback.candidate_more_window_hide = callback_func;
2565 g_event_callback.candidate_more_window_hide_user_data = user_data;
2567 return IME_ERROR_NONE;
2570 EXPORT_API int ime_event_set_aux_select_cb(ime_aux_select_cb callback_func, void *user_data)
2573 ime_error_e retVal = IME_ERROR_NONE;
2575 if (!callback_func) {
2576 LOGW("IME_ERROR_INVALID_PARAMETER");
2577 return IME_ERROR_INVALID_PARAMETER;
2580 retVal = _check_privilege();
2581 if (retVal != IME_ERROR_NONE) return retVal;
2583 g_event_callback.aux_select = callback_func;
2584 g_event_callback.aux_select_user_data = user_data;
2586 return IME_ERROR_NONE;
2589 EXPORT_API int ime_event_set_candidate_select_cb(ime_candidate_select_cb callback_func, void *user_data)
2592 ime_error_e retVal = IME_ERROR_NONE;
2594 if (!callback_func) {
2595 LOGW("IME_ERROR_INVALID_PARAMETER");
2596 return IME_ERROR_INVALID_PARAMETER;
2599 retVal = _check_privilege();
2600 if (retVal != IME_ERROR_NONE) return retVal;
2602 g_event_callback.candidate_select = callback_func;
2603 g_event_callback.candidate_select_user_data = user_data;
2605 return IME_ERROR_NONE;
2608 EXPORT_API int ime_event_set_candidate_table_page_up_cb(ime_candidate_table_page_up_cb callback_func, void *user_data)
2611 ime_error_e retVal = IME_ERROR_NONE;
2613 if (!callback_func) {
2614 LOGW("IME_ERROR_INVALID_PARAMETER");
2615 return IME_ERROR_INVALID_PARAMETER;
2618 retVal = _check_privilege();
2619 if (retVal != IME_ERROR_NONE) return retVal;
2621 g_event_callback.candidate_table_page_up = callback_func;
2622 g_event_callback.candidate_table_page_up_user_data = user_data;
2624 return IME_ERROR_NONE;
2627 EXPORT_API int ime_event_set_candidate_table_page_down_cb(ime_candidate_table_page_down_cb callback_func, void *user_data)
2630 ime_error_e retVal = IME_ERROR_NONE;
2632 if (!callback_func) {
2633 LOGW("IME_ERROR_INVALID_PARAMETER");
2634 return IME_ERROR_INVALID_PARAMETER;
2637 retVal = _check_privilege();
2638 if (retVal != IME_ERROR_NONE) return retVal;
2640 g_event_callback.candidate_table_page_down = callback_func;
2641 g_event_callback.candidate_table_page_down_user_data = user_data;
2643 return IME_ERROR_NONE;
2646 EXPORT_API int ime_event_set_candidate_table_page_size_chaned_cb(ime_candidate_table_page_size_chaned_cb callback_func, void *user_data)
2649 ime_error_e retVal = IME_ERROR_NONE;
2651 if (!callback_func) {
2652 LOGW("IME_ERROR_INVALID_PARAMETER");
2653 return IME_ERROR_INVALID_PARAMETER;
2656 retVal = _check_privilege();
2657 if (retVal != IME_ERROR_NONE) return retVal;
2659 g_event_callback.candidate_table_page_size_chaned = callback_func;
2660 g_event_callback.candidate_table_page_size_chaned_user_data = user_data;
2662 return IME_ERROR_NONE;
2665 EXPORT_API int ime_event_set_candidate_item_layout_set_cb(ime_candidate_item_layout_set_cb callback_func, void *user_data)
2668 ime_error_e retVal = IME_ERROR_NONE;
2670 if (!callback_func) {
2671 LOGW("IME_ERROR_INVALID_PARAMETER");
2672 return IME_ERROR_INVALID_PARAMETER;
2675 retVal = _check_privilege();
2676 if (retVal != IME_ERROR_NONE) return retVal;
2678 g_event_callback.candidate_item_layout_set = callback_func;
2679 g_event_callback.candidate_item_layout_set_user_data = user_data;
2681 return IME_ERROR_NONE;
2684 EXPORT_API int ime_event_set_displayed_candidate_number_chaned_cb(ime_displayed_candidate_number_chaned_cb callback_func, void *user_data)
2687 ime_error_e retVal = IME_ERROR_NONE;
2689 if (!callback_func) {
2690 LOGW("IME_ERROR_INVALID_PARAMETER");
2691 return IME_ERROR_INVALID_PARAMETER;
2694 retVal = _check_privilege();
2695 if (retVal != IME_ERROR_NONE) return retVal;
2697 g_event_callback.displayed_candidate_number_chaned = callback_func;
2698 g_event_callback.displayed_candidate_number_chaned_user_data = user_data;
2700 return IME_ERROR_NONE;
2703 EXPORT_API int ime_event_set_candidate_item_long_pressed_cb(ime_candidate_item_long_pressed_cb callback_func, void *user_data)
2706 ime_error_e retVal = IME_ERROR_NONE;
2708 if (!callback_func) {
2709 LOGW("IME_ERROR_INVALID_PARAMETER");
2710 return IME_ERROR_INVALID_PARAMETER;
2713 retVal = _check_privilege();
2714 if (retVal != IME_ERROR_NONE) return retVal;
2716 g_event_callback.candidate_item_long_pressed = callback_func;
2717 g_event_callback.candidate_item_long_pressed_user_data = user_data;
2719 return IME_ERROR_NONE;
2722 EXPORT_API int ime_show_aux_string(void)
2724 ime_error_e retVal = IME_ERROR_NONE;
2726 retVal = _check_privilege();
2727 if (retVal != IME_ERROR_NONE) return retVal;
2730 LOGW("IME_ERROR_NOT_RUNNING");
2731 return IME_ERROR_NOT_RUNNING;
2734 g_core.show_aux_string();
2736 return IME_ERROR_NONE;
2739 EXPORT_API int ime_hide_aux_string(void)
2741 ime_error_e retVal = IME_ERROR_NONE;
2743 retVal = _check_privilege();
2744 if (retVal != IME_ERROR_NONE) return retVal;
2747 LOGW("IME_ERROR_NOT_RUNNING");
2748 return IME_ERROR_NOT_RUNNING;
2751 g_core.hide_aux_string();
2753 return IME_ERROR_NONE;
2756 EXPORT_API int ime_show_lookup_table(void)
2758 ime_error_e retVal = IME_ERROR_NONE;
2760 retVal = _check_privilege();
2761 if (retVal != IME_ERROR_NONE) return retVal;
2764 LOGW("IME_ERROR_NOT_RUNNING");
2765 return IME_ERROR_NOT_RUNNING;
2768 g_core.show_candidate_string();
2770 return IME_ERROR_NONE;
2773 EXPORT_API int ime_hide_lookup_table(void)
2775 ime_error_e retVal = IME_ERROR_NONE;
2777 retVal = _check_privilege();
2778 if (retVal != IME_ERROR_NONE) return retVal;
2781 LOGW("IME_ERROR_NOT_RUNNING");
2782 return IME_ERROR_NOT_RUNNING;
2785 g_core.hide_candidate_string();
2787 return IME_ERROR_NONE;
2790 EXPORT_API int ime_update_preedit_caret(int caret)
2792 ime_error_e retVal = IME_ERROR_NONE;
2795 LOGW("IME_ERROR_INVALID_PARAMETER");
2796 return IME_ERROR_INVALID_PARAMETER;
2800 LOGW("IME_ERROR_NOT_RUNNING");
2801 return IME_ERROR_NOT_RUNNING;
2804 retVal = _check_privilege();
2805 if (retVal != IME_ERROR_NONE) return retVal;
2807 g_core.update_preedit_caret(caret);
2809 return IME_ERROR_NONE;
2812 EXPORT_API int ime_update_preedit_string_with_commit(const char *preedit, const char *commit, scim::AttributeList &attrs, int caret)
2814 ime_error_e retVal = IME_ERROR_NONE;
2816 if (!preedit && !commit) {
2817 LOGW("IME_ERROR_INVALID_PARAMETER");
2818 return IME_ERROR_INVALID_PARAMETER;
2822 LOGW("IME_ERROR_NOT_RUNNING");
2823 return IME_ERROR_NOT_RUNNING;
2826 retVal = _check_privilege();
2827 if (retVal != IME_ERROR_NONE) return retVal;
2829 g_core.update_preedit_string_with_commit(preedit, commit, attrs, caret);
2831 return IME_ERROR_NONE;
2834 EXPORT_API int ime_update_aux_string(const char *str)
2836 ime_error_e retVal = IME_ERROR_NONE;
2839 LOGW("IME_ERROR_INVALID_PARAMETER");
2840 return IME_ERROR_INVALID_PARAMETER;
2844 LOGW("IME_ERROR_NOT_RUNNING");
2845 return IME_ERROR_NOT_RUNNING;
2848 retVal = _check_privilege();
2849 if (retVal != IME_ERROR_NONE) return retVal;
2851 g_core.update_aux_string(str);
2853 return IME_ERROR_NONE;
2856 EXPORT_API int ime_recapture_string(int offset, int len, const char *preedit, const char *commit, scim::AttributeList &attrs)
2858 ime_error_e retVal = IME_ERROR_NONE;
2861 LOGW("IME_ERROR_INVALID_PARAMETER");
2862 return IME_ERROR_INVALID_PARAMETER;
2866 LOGW("IME_ERROR_NOT_RUNNING");
2867 return IME_ERROR_NOT_RUNNING;
2870 retVal = _check_privilege();
2871 if (retVal != IME_ERROR_NONE) return retVal;
2873 g_core.recapture_string(offset, len, preedit, commit, attrs);
2875 return IME_ERROR_NONE;
2878 EXPORT_API int ime_update_lookup_table(scim::LookupTable &table)
2880 ime_error_e retVal = IME_ERROR_NONE;
2883 LOGW("IME_ERROR_NOT_RUNNING");
2884 return IME_ERROR_NOT_RUNNING;
2887 retVal = _check_privilege();
2888 if (retVal != IME_ERROR_NONE) return retVal;
2890 g_core.update_lookup_table(table);
2892 return IME_ERROR_NONE;
2895 EXPORT_API int ime_register_properties(scim::PropertyList &properties)
2897 ime_error_e retVal = IME_ERROR_NONE;
2900 LOGW("IME_ERROR_NOT_RUNNING");
2901 return IME_ERROR_NOT_RUNNING;
2904 retVal = _check_privilege();
2905 if (retVal != IME_ERROR_NONE) return retVal;
2907 g_core.register_properties(properties);
2909 return IME_ERROR_NONE;
2912 EXPORT_API int ime_update_property(scim::Property &property)
2914 ime_error_e retVal = IME_ERROR_NONE;
2917 LOGW("IME_ERROR_NOT_RUNNING");
2918 return IME_ERROR_NOT_RUNNING;
2921 retVal = _check_privilege();
2922 if (retVal != IME_ERROR_NONE) return retVal;
2924 g_core.update_property(property);
2926 return IME_ERROR_NONE;
2929 EXPORT_API int ime_expand_candidate(void)
2931 ime_error_e retVal = IME_ERROR_NONE;
2933 retVal = _check_privilege();
2934 if (retVal != IME_ERROR_NONE) return retVal;
2937 LOGW("IME_ERROR_NOT_RUNNING");
2938 return IME_ERROR_NOT_RUNNING;
2941 g_core.expand_candidate();
2943 return IME_ERROR_NONE;
2946 EXPORT_API int ime_contract_candidate(void)
2948 ime_error_e retVal = IME_ERROR_NONE;
2950 retVal = _check_privilege();
2951 if (retVal != IME_ERROR_NONE) return retVal;
2954 LOGW("IME_ERROR_NOT_RUNNING");
2955 return IME_ERROR_NOT_RUNNING;
2958 g_core.contract_candidate();
2960 return IME_ERROR_NONE;
2963 EXPORT_API int ime_set_candidate_style(scim::ISF_CANDIDATE_PORTRAIT_LINE_T portrait_line, scim::ISF_CANDIDATE_MODE_T mode)
2965 ime_error_e retVal = IME_ERROR_NONE;
2968 LOGW("IME_ERROR_NOT_RUNNING");
2969 return IME_ERROR_NOT_RUNNING;
2972 retVal = _check_privilege();
2973 if (retVal != IME_ERROR_NONE) return retVal;
2975 g_core.set_candidate_style(portrait_line, mode);
2977 return IME_ERROR_NONE;
2980 EXPORT_API int ime_set_engine_loader_flag(bool flag)
2982 ime_error_e retVal = IME_ERROR_NONE;
2985 LOGW("IME_ERROR_NOT_RUNNING");
2986 return IME_ERROR_NOT_RUNNING;
2989 retVal = _check_privilege();
2990 if (retVal != IME_ERROR_NONE) return retVal;
2992 g_core.set_engine_loader_flag(flag);
2994 return IME_ERROR_NONE;
2997 EXPORT_API int ime_send_key_event_processing_result(scim::KeyEvent &key, uint32_t serial, bool is_success)
2999 ime_error_e retVal = IME_ERROR_NONE;
3002 LOGW("IME_ERROR_NOT_RUNNING");
3003 return IME_ERROR_NOT_RUNNING;
3006 retVal = _check_privilege();
3007 if (retVal != IME_ERROR_NONE) return retVal;
3009 g_core.send_key_event_processing_result(key, serial, is_success);
3011 return IME_ERROR_NONE;
3015 EXPORT_API int ime_update_input_panel_event(ime_event_type_e type, unsigned int value)
3017 ime_error_e retVal = IME_ERROR_NONE;
3019 if (type < IME_EVENT_TYPE_LANGUAGE || type > IME_EVENT_TYPE_GEOMETRY) {
3020 LOGW("IME_ERROR_INVALID_PARAMETER");
3021 return IME_ERROR_INVALID_PARAMETER;
3025 LOGW("IME_ERROR_NOT_RUNNING");
3026 return IME_ERROR_NOT_RUNNING;
3030 retVal = _check_privilege();
3031 if (retVal != IME_ERROR_NONE) return retVal;
3033 g_core.update_input_context((sclu32)type, value);
3035 return IME_ERROR_NONE;
3039 EXPORT_API int ime_set_candidate_visibility_state(bool visible)
3041 ime_error_e retVal = IME_ERROR_NONE;
3044 LOGW("IME_ERROR_NOT_RUNNING");
3045 return IME_ERROR_NOT_RUNNING;
3049 retVal = _check_privilege();
3050 if (retVal != IME_ERROR_NONE) return retVal;
3053 g_core.show_candidate_string();
3055 g_core.hide_candidate_string();
3057 return IME_ERROR_NONE;