2 * Copyright (c) 2015 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 *ret);
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);
93 ime_focus_in_cb focus_in; /**< Called when an edit field has focus */
94 ime_focus_out_cb focus_out; /**< Called when an edit field loses focus */
95 ime_surrounding_text_updated_cb surrounding_text_updated; /**< Called when an edit field responds to a request with the surrounding text */
96 ime_input_context_reset_cb input_context_reset; /**< Called to reset the input context of an edit field */
97 ime_cursor_position_updated_cb cursor_position_updated; /**< Called when the position of the cursor in an edit field changes */
98 ime_language_requested_cb language_requested; /**< Called when an edit field requests the language from the input panel */
99 ime_language_set_cb language_set; /**< Called to set the preferred language to the input panel */
100 ime_imdata_set_cb imdata_set; /**< Called to set the application specific data to deliver to the input panel */
101 ime_imdata_requested_cb imdata_requested; /**< Called when an associated text input UI control requests the application specific data from the input panel */
102 ime_layout_set_cb layout_set; /**< Called when an edit field requests the input panel to set its layout */
103 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 */
104 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 */
105 ime_geometry_requested_cb geometry_requested; /**< Called when an edit field requests the position and size from the input panel */
106 ime_process_key_event_cb process_key_event; /**< Called when the key event is received from the external keyboard devices */
107 ime_process_key_event_with_keycode_cb process_key_event_with_keycode; /**< Called when the key event is received from the external keyboard devices */
108 ime_display_language_changed_cb display_language_changed; /**< Called when the system display language is changed */
109 ime_rotation_degree_changed_cb rotation_degree_changed; /**< Called when the device is rotated */
110 ime_accessibility_state_changed_cb accessibility_state_changed; /**< Called when Accessibility in Settings application is on or off */
111 ime_option_window_created_cb option_window_created; /**< Called to create the option window */
112 ime_option_window_destroyed_cb option_window_destroyed; /**< Called to destroy the option window */
113 ime_caps_mode_changed_cb caps_mode_changed;
114 ime_candidate_show_cb candidate_show;
115 ime_candidate_hide_cb candidate_hide;
116 ime_lookup_table_changed_cb lookup_table_changed;
117 ime_process_input_device_event_cb process_input_device_event; /**< Called when the event is received from the unconventional input devices */
118 ime_prediction_hint_set_cb prediction_hint_set;
119 ime_mime_type_set_request_cb mime_type_set;
120 ime_prediction_hint_data_set_cb prediction_hint_data_set;
121 ime_optimization_hint_set_cb optimization_hint_set;
122 ime_process_key_event_with_imengine_cb process_key_event_with_imengine;
123 ime_autocapital_type_set_cb autocapital_type_set;
124 ime_prediction_allow_set_cb prediction_allow_set;
125 ime_trigger_property_set_cb trigger_property_set;
126 ime_candidate_more_window_show_cb candidate_more_window_show;
127 ime_candidate_more_window_hide_cb candidate_more_window_hide;
128 ime_aux_select_cb aux_select;
129 ime_candidate_select_cb candidate_select;
130 ime_candidate_table_page_up_cb candidate_table_page_up;
131 ime_candidate_table_page_down_cb candidate_table_page_down;
132 ime_candidate_table_page_size_chaned_cb candidate_table_page_size_chaned;
133 ime_candidate_item_layout_set_cb candidate_item_layout_set;
134 ime_displayed_candidate_number_chaned_cb displayed_candidate_number_chaned;
135 ime_candidate_item_long_pressed_cb candidate_item_long_pressed;
136 void *focus_in_user_data;
137 void *focus_out_user_data;
138 void *surrounding_text_updated_user_data;
139 void *input_context_reset_user_data;
140 void *cursor_position_updated_user_data;
141 void *language_requested_user_data;
142 void *language_set_user_data;
143 void *imdata_set_user_data;
144 void *imdata_requested_user_data;
145 void *layout_set_user_data;
146 void *return_key_type_set_user_data;
147 void *return_key_state_set_user_data;
148 void *geometry_requested_user_data;
149 void *process_key_event_user_data;
150 void *process_key_event_with_keycode_user_data;
151 void *display_language_changed_user_data;
152 void *rotation_degree_changed_user_data;
153 void *accessibility_state_changed_user_data;
154 void *option_window_created_user_data;
155 void *option_window_destroyed_user_data;
156 void *caps_mode_changed_user_data;
157 void *candidate_show_user_data;
158 void *candidate_hide_user_data;
159 void *lookup_table_changed_user_data;
160 void *process_input_device_event_user_data;
161 void *prediction_hint_set_user_data;
162 void *mime_type_set_user_data;
163 void *prediction_hint_data_set_user_data;
164 void *optimization_hint_set_user_data;
165 void *process_key_event_with_imengine_user_data;
166 void *autocapital_type_set_user_data;
167 void *prediction_allow_set_user_data;
168 void *trigger_property_set_user_data;
169 void *candidate_more_window_show_user_data;
170 void *candidate_more_window_hide_user_data;
171 void *aux_select_user_data;
172 void *candidate_select_user_data;
173 void *candidate_table_page_up_user_data;
174 void *candidate_table_page_down_user_data;
175 void *candidate_table_page_size_chaned_user_data;
176 void *candidate_item_layout_set_user_data;
177 void *displayed_candidate_number_chaned_user_data;
178 void *candidate_item_long_pressed_user_data;
179 } ime_event_callback_s;
182 ime_input_device_type_e device_type;
184 } ime_device_event_s;
186 static ime_callback_s g_basic_callback = {NULL};
187 static ime_event_callback_s g_event_callback = {NULL};
188 static void *g_user_data = NULL;
189 static bool g_running = false;
191 static CCoreEventCallback g_core_event_callback;
192 CSCLCore g_core(&g_core_event_callback);
194 static bool g_checked_privilege = false;
195 static bool g_permission_allowed = false;
198 extern void ime_app_main(int argc, char **argv);
202 void CCoreEventCallback::on_init()
204 if (g_basic_callback.create) {
205 g_basic_callback.create(g_user_data);
209 void CCoreEventCallback::on_run(int argc, char **argv)
212 ime_app_main(argc, argv);
215 void CCoreEventCallback::on_exit()
218 if (g_basic_callback.terminate) {
219 g_basic_callback.terminate(g_user_data);
223 void CCoreEventCallback::on_update_cursor_position(sclint ic, const sclchar *ic_uuid, sclint cursor_pos)
225 if (g_event_callback.cursor_position_updated) {
226 g_event_callback.cursor_position_updated(cursor_pos, g_event_callback.cursor_position_updated_user_data);
230 void CCoreEventCallback::on_update_surrounding_text(sclint ic, const sclchar *text, sclint cursor)
232 if (g_event_callback.surrounding_text_updated) {
233 g_event_callback.surrounding_text_updated(ic, text, cursor, g_event_callback.surrounding_text_updated_user_data);
237 void CCoreEventCallback::on_focus_out(sclint ic, const sclchar *ic_uuid)
239 if (g_event_callback.focus_out) {
240 g_event_callback.focus_out(ic, g_event_callback.focus_out_user_data);
244 void CCoreEventCallback::on_focus_in(sclint ic, const sclchar *ic_uuid)
246 if (g_event_callback.focus_in) {
247 g_event_callback.focus_in(ic, g_event_callback.focus_in_user_data);
251 void CCoreEventCallback::on_ise_show(sclint ic, const int degree, Ise_Context &context)
253 if (g_basic_callback.show) {
254 struct _ime_context input_context;
256 memset(&input_context, 0, sizeof(struct _ime_context));
257 input_context.layout = context.layout;
258 input_context.layout_variation = context.layout_variation;
259 input_context.cursor_pos = context.cursor_pos;
260 input_context.autocapital_type = context.autocapital_type;
261 input_context.return_key_type = context.return_key_type;
262 input_context.return_key_disabled = context.return_key_disabled;
263 input_context.prediction_allow = context.prediction_allow;
264 input_context.password_mode = context.password_mode;
265 input_context.imdata_size = context.imdata_size;
266 input_context.input_hint = context.input_hint;
267 input_context.bidi_direction = context.bidi_direction;
268 input_context.language = context.language;
269 input_context.client_window = context.client_window;
270 input_context.caps_mode = context.caps_mode;
272 g_basic_callback.show(ic, static_cast<ime_context_h>(&input_context), g_user_data);
276 void CCoreEventCallback::on_ise_hide(sclint ic, const sclchar *ic_uuid)
278 if (g_basic_callback.hide) {
279 g_basic_callback.hide(ic, g_user_data);
283 void CCoreEventCallback::on_get_geometry(sclu32 *pos_x, sclu32 *pos_y, sclu32 *width, sclu32 *height)
285 int geometry_pos_x = 0;
286 int geometry_pos_y = 0;
287 int geometry_width = 0;
288 int geometry_height = 0;
290 if (g_event_callback.geometry_requested) {
291 g_event_callback.geometry_requested(g_event_callback.geometry_requested_user_data, &geometry_pos_x, &geometry_pos_y, &geometry_width, &geometry_height);
295 *pos_x = geometry_pos_x;
298 *pos_y = geometry_pos_y;
301 *width = geometry_width;
304 *height = geometry_height;
307 void CCoreEventCallback::on_set_language(sclu32 language)
309 if (g_event_callback.language_set) {
310 g_event_callback.language_set((Ecore_IMF_Input_Panel_Lang)language, g_event_callback.language_set_user_data);
314 void CCoreEventCallback::on_set_imdata(sclchar *buf, sclu32 len)
316 if (g_event_callback.imdata_set) {
317 g_event_callback.imdata_set((void *)buf, len, g_event_callback.imdata_set_user_data);
321 void CCoreEventCallback::on_get_imdata(sclchar **buf, sclu32 *len)
323 if (g_event_callback.imdata_requested) {
324 g_event_callback.imdata_requested(g_event_callback.imdata_set_user_data, (void **)buf, len);
328 void CCoreEventCallback::on_get_language_locale(sclint ic, sclchar **locale)
330 if (g_event_callback.language_requested) {
331 g_event_callback.language_requested(g_event_callback.language_requested_user_data, locale);
335 void CCoreEventCallback::on_set_return_key_type(sclu32 type)
337 if (g_event_callback.return_key_type_set) {
338 g_event_callback.return_key_type_set((Ecore_IMF_Input_Panel_Return_Key_Type)type, g_event_callback.return_key_type_set_user_data);
342 void CCoreEventCallback::on_set_return_key_disable(sclu32 disabled)
344 bool return_key_disabled = !!disabled;
346 if (g_event_callback.return_key_state_set) {
347 g_event_callback.return_key_state_set(return_key_disabled, g_event_callback.return_key_state_set_user_data);
351 void CCoreEventCallback::on_set_layout(sclu32 layout)
353 if (g_event_callback.layout_set) {
354 g_event_callback.layout_set(static_cast<Ecore_IMF_Input_Panel_Layout>(layout), g_event_callback.layout_set_user_data);
358 void CCoreEventCallback::on_reset_input_context(sclint ic, const sclchar *uuid)
360 if (g_event_callback.input_context_reset) {
361 g_event_callback.input_context_reset(g_event_callback.input_context_reset_user_data);
365 void CCoreEventCallback::on_process_key_event(scim::KeyEvent &key, sclu32 *ret)
367 if (g_event_callback.process_key_event) {
368 struct _ime_device_info dev_info = {key.dev_name.c_str(),
369 static_cast<Ecore_IMF_Device_Class>(key.dev_class), static_cast<Ecore_IMF_Device_Subclass>(key.dev_subclass)};
370 bool processed = g_event_callback.process_key_event(static_cast<ime_key_code_e>(key.code), static_cast<ime_key_mask_e>(key.mask),
371 static_cast<ime_device_info_h>(&dev_info), g_event_callback.process_key_event_user_data);
386 void CCoreEventCallback::on_process_key_event_with_keycode(scim::KeyEvent &key, sclu32 *ret, sclu32 keycode)
388 if (g_event_callback.process_key_event_with_keycode) {
389 struct _ime_device_info dev_info = {key.dev_name.c_str(),
390 static_cast<Ecore_IMF_Device_Class>(key.dev_class), static_cast<Ecore_IMF_Device_Subclass>(key.dev_subclass)};
391 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),
392 static_cast<ime_device_info_h>(&dev_info), g_event_callback.process_key_event_user_data);
407 void CCoreEventCallback::on_set_display_language(const sclchar *language)
409 if (g_event_callback.display_language_changed) {
410 g_event_callback.display_language_changed(language, g_event_callback.display_language_changed_user_data);
414 void CCoreEventCallback::on_set_rotation_degree(sclint degree)
416 if (g_event_callback.rotation_degree_changed) {
417 g_event_callback.rotation_degree_changed(degree, g_event_callback.rotation_degree_changed_user_data);
421 void CCoreEventCallback::on_set_accessibility_state(sclboolean state)
423 if (g_event_callback.accessibility_state_changed) {
424 g_event_callback.accessibility_state_changed(state, g_event_callback.accessibility_state_changed_user_data);
428 void CCoreEventCallback::on_create_option_window(sclwindow window, SCLOptionWindowType type)
430 if (g_event_callback.option_window_created) {
431 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);
435 void CCoreEventCallback::on_destroy_option_window(sclwindow window)
437 if (g_event_callback.option_window_destroyed) {
438 g_event_callback.option_window_destroyed(static_cast<Evas_Object*>(window), g_event_callback.option_window_destroyed_user_data);
442 void CCoreEventCallback::on_check_option_window_availability(sclboolean *ret)
445 if (g_event_callback.option_window_created) // Instead of each 3rd party keyboard, inputmethod will reply the availability of the option (setting).
452 void CCoreEventCallback::on_set_caps_mode(sclu32 mode)
454 if (g_event_callback.caps_mode_changed) {
455 g_event_callback.caps_mode_changed(mode, g_event_callback.caps_mode_changed_user_data);
459 void CCoreEventCallback::on_candidate_show(sclint ic, const sclchar *ic_uuid)
461 if (g_event_callback.candidate_show) {
462 g_event_callback.candidate_show(ic, g_event_callback.candidate_show_user_data);
466 void CCoreEventCallback::on_candidate_hide(sclint ic, const sclchar *ic_uuid)
468 if (g_event_callback.candidate_hide) {
469 g_event_callback.candidate_hide(ic, g_event_callback.candidate_hide_user_data);
473 void CCoreEventCallback::on_update_lookup_table(SclCandidateTable &table)
475 Eina_List *string_list = NULL;
477 if (g_event_callback.lookup_table_changed) {
478 vector<string>::iterator iter = table.candidate.begin();
479 for (; iter != table.candidate.end(); ++iter) {
480 string_list = eina_list_append(string_list, iter->c_str());
483 g_event_callback.lookup_table_changed(string_list, g_event_callback.lookup_table_changed_user_data);
487 void CCoreEventCallback::on_process_input_device_event(sclu32 &type, sclchar *data, size_t &len, sclu32 *ret)
491 ime_input_device_type_e device_type;
492 } ime_device_type_conv_table;
494 ime_device_type_conv_table conv_table[] = {
495 { ECORE_EVENT_DETENT_ROTATE , IME_INPUT_DEVICE_TYPE_ROTARY },
498 ime_input_device_type_e device_type = IME_INPUT_DEVICE_TYPE_UNKNOWN;
499 for (unsigned int loop = 0; loop < sizeof(conv_table) / sizeof(ime_device_type_conv_table); loop++) {
500 if ((unsigned int)(conv_table[loop].ecore_event_id) == type) {
501 device_type = conv_table[loop].device_type;
505 if (g_event_callback.process_input_device_event) {
506 ime_device_event_s device_event;
507 device_event.device_type = device_type;
508 device_event.event_data = static_cast<void*>(data);
509 void *input_data = static_cast<void*>(&device_event);
510 void *user_data = g_event_callback.process_input_device_event_user_data;
512 g_event_callback.process_input_device_event(device_type, input_data, user_data);
524 void CCoreEventCallback::on_set_prediction_hint(const sclchar *prediction_hint)
526 if (g_event_callback.prediction_hint_set) {
527 g_event_callback.prediction_hint_set(prediction_hint, g_event_callback.prediction_hint_set_user_data);
531 void CCoreEventCallback::on_set_mime_type(const sclchar *mime_type)
533 if (g_event_callback.mime_type_set) {
534 g_event_callback.mime_type_set(mime_type, g_event_callback.mime_type_set_user_data);
538 void CCoreEventCallback::on_set_prediction_hint_data(const sclchar *key, const sclchar *value)
540 if (g_event_callback.prediction_hint_data_set) {
541 g_event_callback.prediction_hint_data_set(key, value, g_event_callback.prediction_hint_data_set_user_data);
545 void CCoreEventCallback::on_set_optimization_hint(sclu32 hint)
547 if (g_event_callback.optimization_hint_set) {
548 g_event_callback.optimization_hint_set((ime_optimization_hint_e)hint, g_event_callback.optimization_hint_set_user_data);
552 void CCoreEventCallback::on_process_key_event_with_imengine(scim::KeyEvent &key, sclu32 *ret)
554 if (g_event_callback.process_key_event_with_imengine) {
555 bool processed = g_event_callback.process_key_event_with_imengine(key, g_event_callback.process_key_event_with_imengine_user_data);
558 *ret = processed ? 1 : 0;
564 void CCoreEventCallback::on_set_autocapital_type(sclu32 type)
566 if (g_event_callback.autocapital_type_set) {
567 g_event_callback.autocapital_type_set(type, g_event_callback.autocapital_type_set_user_data);
571 void CCoreEventCallback::on_set_prediction_allow(sclu32 prediction_allow)
573 if (g_event_callback.prediction_allow_set) {
574 g_event_callback.prediction_allow_set(prediction_allow, g_event_callback.prediction_allow_set_user_data);
578 void CCoreEventCallback::on_trigger_property(const sclchar *property)
580 if (g_event_callback.trigger_property_set) {
581 g_event_callback.trigger_property_set(property, g_event_callback.trigger_property_set_user_data);
585 void CCoreEventCallback::on_candidate_more_window_show(sclint ic, const sclchar *uuid)
587 if (g_event_callback.candidate_more_window_show) {
588 g_event_callback.candidate_more_window_show(g_event_callback.candidate_more_window_show_user_data);
592 void CCoreEventCallback::on_candidate_more_window_hide(sclint ic, const sclchar *uuid)
594 if (g_event_callback.candidate_more_window_hide) {
595 g_event_callback.candidate_more_window_hide(g_event_callback.candidate_more_window_hide_user_data);
599 void CCoreEventCallback::on_select_aux(sclint ic, const sclchar *uuid, sclint index)
601 if (g_event_callback.aux_select) {
602 g_event_callback.aux_select((uint32_t)index, g_event_callback.aux_select_user_data);
606 void CCoreEventCallback::on_select_candidate(sclint ic, const sclchar *uuid, sclint index)
608 if (g_event_callback.candidate_select) {
609 g_event_callback.candidate_select((uint32_t)index, g_event_callback.candidate_select_user_data);
613 void CCoreEventCallback::on_candidate_table_page_up(sclint ic, const sclchar *uuid)
615 if (g_event_callback.candidate_table_page_up) {
616 g_event_callback.candidate_table_page_up(g_event_callback.candidate_table_page_up_user_data);
620 void CCoreEventCallback::on_candidate_table_page_down(sclint ic, const sclchar *uuid)
622 if (g_event_callback.candidate_table_page_down) {
623 g_event_callback.candidate_table_page_down(g_event_callback.candidate_table_page_down_user_data);
627 void CCoreEventCallback::on_update_candidate_table_page_size(sclint ic, const sclchar *uuid, sclint page_size)
629 if (g_event_callback.candidate_table_page_size_chaned) {
630 g_event_callback.candidate_table_page_size_chaned((uint32_t)page_size, g_event_callback.candidate_table_page_size_chaned_user_data);
634 void CCoreEventCallback::on_update_candidate_item_layout(const std::vector<sclu32> item)
636 if (g_event_callback.candidate_item_layout_set) {
637 g_event_callback.candidate_item_layout_set(item, g_event_callback.candidate_item_layout_set_user_data);
641 void CCoreEventCallback::on_update_displayed_candidate_number(sclu32 size)
643 if (g_event_callback.displayed_candidate_number_chaned) {
644 g_event_callback.displayed_candidate_number_chaned(size, g_event_callback.displayed_candidate_number_chaned_user_data);
648 void CCoreEventCallback::on_longpress_candidate(sclu32 index)
650 if (g_event_callback.candidate_item_long_pressed) {
651 g_event_callback.candidate_item_long_pressed(index, g_event_callback.candidate_item_long_pressed_user_data);
655 void ime_privilege_cache_init()
657 g_permission_allowed = false;
658 g_checked_privilege = false;
662 ime_error_e _check_privilege()
665 ime_error_e ret = IME_ERROR_NONE;
667 if (g_checked_privilege) {
668 return g_permission_allowed ? IME_ERROR_NONE : IME_ERROR_PERMISSION_DENIED;
671 if (inputmethod_cynara_initialize() == false) {
673 g_permission_allowed = false;
674 g_checked_privilege = true;
675 LOGE("inputmethod_cynara_initialize () == false");
677 return IME_ERROR_PERMISSION_DENIED;
680 snprintf(uid, 16, "%d", getuid());
681 if (check_privilege(uid, IME_PRIVILEGE) == false) {
682 LOGE("check_privilege(uid, IME_PRIVILEGE) == false. uid : %s", uid); //LCOV_EXCL_LINE
683 ret = IME_ERROR_PERMISSION_DENIED;
686 g_permission_allowed = (ret == IME_ERROR_NONE);
687 g_checked_privilege = true;
689 inputmethod_cynara_finish();
695 bool g_from_dotnet = false;
696 EXPORT_API int ime_set_dotnet_flag(bool set)
698 ime_error_e retVal = IME_ERROR_NONE;
700 retVal = _check_privilege();
701 if (retVal != IME_ERROR_NONE) return retVal;
709 EXPORT_API int ime_run(ime_callback_s *basic_cb, void *user_data)
711 ime_error_e retVal = IME_ERROR_NONE;
715 LOGE("inputmethod main loop is already running.");
716 return IME_ERROR_OPERATION_FAILED;
721 LOGE("basic callbacks pointer is null.");
722 return IME_ERROR_INVALID_PARAMETER;
725 retVal = _check_privilege();
726 if (retVal != IME_ERROR_NONE) return retVal;
728 g_basic_callback = *basic_cb;
730 if (!g_basic_callback.create || !g_basic_callback.terminate ||
731 !g_basic_callback.show || !g_basic_callback.hide) {
732 LOGE("mandatory callback functions are not set");
733 memset(&g_basic_callback, 0, sizeof(ime_callback_s));
734 memset(&g_event_callback, 0, sizeof(ime_event_callback_s));
735 return IME_ERROR_NO_CALLBACK_FUNCTION;
739 g_user_data = user_data;
743 LOGD("ime_run is called from dotnet");
744 return IME_ERROR_NONE;
750 LOGW("exception is thrown from g_core.run()\n");
753 memset(&g_basic_callback, 0, sizeof(ime_callback_s));
754 memset(&g_event_callback, 0, sizeof(ime_event_callback_s));
758 return IME_ERROR_NONE;
762 EXPORT_API int ime_event_set_focus_in_cb(ime_focus_in_cb callback_func, void *user_data)
764 ime_error_e retVal = IME_ERROR_NONE;
766 if (!callback_func) {
767 LOGW("IME_ERROR_INVALID_PARAMETER");
768 return IME_ERROR_INVALID_PARAMETER;
771 retVal = _check_privilege();
772 if (retVal != IME_ERROR_NONE) return retVal;
774 g_event_callback.focus_in = callback_func;
775 g_event_callback.focus_in_user_data = user_data;
777 return IME_ERROR_NONE;
780 EXPORT_API int ime_event_set_focus_out_cb(ime_focus_out_cb callback_func, void *user_data)
782 ime_error_e retVal = IME_ERROR_NONE;
784 if (!callback_func) {
785 LOGW("IME_ERROR_INVALID_PARAMETER");
786 return IME_ERROR_INVALID_PARAMETER;
789 retVal = _check_privilege();
790 if (retVal != IME_ERROR_NONE) return retVal;
792 g_event_callback.focus_out = callback_func;
793 g_event_callback.focus_out_user_data = user_data;
795 return IME_ERROR_NONE;
798 EXPORT_API int ime_event_set_surrounding_text_updated_cb(ime_surrounding_text_updated_cb callback_func, void *user_data)
800 ime_error_e retVal = IME_ERROR_NONE;
802 if (!callback_func) {
803 LOGW("IME_ERROR_INVALID_PARAMETER");
804 return IME_ERROR_INVALID_PARAMETER;
807 retVal = _check_privilege();
808 if (retVal != IME_ERROR_NONE) return retVal;
810 g_event_callback.surrounding_text_updated = callback_func;
811 g_event_callback.surrounding_text_updated_user_data = user_data;
813 return IME_ERROR_NONE;
816 EXPORT_API int ime_event_set_input_context_reset_cb(ime_input_context_reset_cb callback_func, void *user_data)
818 ime_error_e retVal = IME_ERROR_NONE;
820 if (!callback_func) {
821 LOGW("IME_ERROR_INVALID_PARAMETER");
822 return IME_ERROR_INVALID_PARAMETER;
825 retVal = _check_privilege();
826 if (retVal != IME_ERROR_NONE) return retVal;
828 g_event_callback.input_context_reset = callback_func;
829 g_event_callback.input_context_reset_user_data = user_data;
831 return IME_ERROR_NONE;
834 EXPORT_API int ime_event_set_cursor_position_updated_cb(ime_cursor_position_updated_cb callback_func, void *user_data)
836 ime_error_e retVal = IME_ERROR_NONE;
838 if (!callback_func) {
839 LOGW("IME_ERROR_INVALID_PARAMETER");
840 return IME_ERROR_INVALID_PARAMETER;
843 retVal = _check_privilege();
844 if (retVal != IME_ERROR_NONE) return retVal;
846 g_event_callback.cursor_position_updated = callback_func;
847 g_event_callback.cursor_position_updated_user_data = user_data;
849 return IME_ERROR_NONE;
852 EXPORT_API int ime_event_set_language_requested_cb(ime_language_requested_cb callback_func, void *user_data)
854 ime_error_e retVal = IME_ERROR_NONE;
856 if (!callback_func) {
857 LOGW("IME_ERROR_INVALID_PARAMETER");
858 return IME_ERROR_INVALID_PARAMETER;
861 retVal = _check_privilege();
862 if (retVal != IME_ERROR_NONE) return retVal;
864 g_event_callback.language_requested = callback_func;
865 g_event_callback.language_requested_user_data = user_data;
867 return IME_ERROR_NONE;
870 EXPORT_API int ime_event_set_language_set_cb(ime_language_set_cb callback_func, void *user_data)
872 ime_error_e retVal = IME_ERROR_NONE;
874 if (!callback_func) {
875 LOGW("IME_ERROR_INVALID_PARAMETER");
876 return IME_ERROR_INVALID_PARAMETER;
879 retVal = _check_privilege();
880 if (retVal != IME_ERROR_NONE) return retVal;
882 g_event_callback.language_set = callback_func;
883 g_event_callback.language_set_user_data = user_data;
885 return IME_ERROR_NONE;
888 EXPORT_API int ime_event_set_imdata_set_cb(ime_imdata_set_cb callback_func, void *user_data)
890 ime_error_e retVal = IME_ERROR_NONE;
892 if (!callback_func) {
893 LOGW("IME_ERROR_INVALID_PARAMETER");
894 return IME_ERROR_INVALID_PARAMETER;
897 retVal = _check_privilege();
898 if (retVal != IME_ERROR_NONE) return retVal;
900 g_event_callback.imdata_set = callback_func;
901 g_event_callback.imdata_set_user_data = user_data;
903 return IME_ERROR_NONE;
906 EXPORT_API int ime_event_set_imdata_requested_cb(ime_imdata_requested_cb callback_func, void *user_data)
908 ime_error_e retVal = IME_ERROR_NONE;
910 if (!callback_func) {
911 LOGW("IME_ERROR_INVALID_PARAMETER");
912 return IME_ERROR_INVALID_PARAMETER;
915 retVal = _check_privilege();
916 if (retVal != IME_ERROR_NONE) return retVal;
918 g_event_callback.imdata_requested = callback_func;
919 g_event_callback.imdata_requested_user_data = user_data;
921 return IME_ERROR_NONE;
924 EXPORT_API int ime_event_set_layout_set_cb(ime_layout_set_cb callback_func, void *user_data)
926 ime_error_e retVal = IME_ERROR_NONE;
928 if (!callback_func) {
929 LOGW("IME_ERROR_INVALID_PARAMETER");
930 return IME_ERROR_INVALID_PARAMETER;
933 retVal = _check_privilege();
934 if (retVal != IME_ERROR_NONE) return retVal;
936 g_event_callback.layout_set = callback_func;
937 g_event_callback.layout_set_user_data = user_data;
939 return IME_ERROR_NONE;
942 EXPORT_API int ime_event_set_return_key_type_set_cb(ime_return_key_type_set_cb callback_func, void *user_data)
944 ime_error_e retVal = IME_ERROR_NONE;
946 if (!callback_func) {
947 LOGW("IME_ERROR_INVALID_PARAMETER");
948 return IME_ERROR_INVALID_PARAMETER;
951 retVal = _check_privilege();
952 if (retVal != IME_ERROR_NONE) return retVal;
954 g_event_callback.return_key_type_set = callback_func;
955 g_event_callback.return_key_type_set_user_data = user_data;
957 return IME_ERROR_NONE;
960 EXPORT_API int ime_event_set_return_key_state_set_cb(ime_return_key_state_set_cb callback_func, void *user_data)
962 ime_error_e retVal = IME_ERROR_NONE;
964 if (!callback_func) {
965 LOGW("IME_ERROR_INVALID_PARAMETER");
966 return IME_ERROR_INVALID_PARAMETER;
969 retVal = _check_privilege();
970 if (retVal != IME_ERROR_NONE) return retVal;
972 g_event_callback.return_key_state_set = callback_func;
973 g_event_callback.return_key_state_set_user_data = user_data;
975 return IME_ERROR_NONE;
978 EXPORT_API int ime_event_set_geometry_requested_cb(ime_geometry_requested_cb callback_func, void *user_data)
980 ime_error_e retVal = IME_ERROR_NONE;
982 if (!callback_func) {
983 LOGW("IME_ERROR_INVALID_PARAMETER");
984 return IME_ERROR_INVALID_PARAMETER;
987 retVal = _check_privilege();
988 if (retVal != IME_ERROR_NONE) return retVal;
990 g_event_callback.geometry_requested = callback_func;
991 g_event_callback.geometry_requested_user_data = user_data;
993 return IME_ERROR_NONE;
996 EXPORT_API int ime_event_set_process_key_event_cb(ime_process_key_event_cb callback_func, void *user_data)
998 ime_error_e retVal = IME_ERROR_NONE;
1000 if (!callback_func) {
1001 LOGW("IME_ERROR_INVALID_PARAMETER");
1002 return IME_ERROR_INVALID_PARAMETER;
1005 retVal = _check_privilege();
1006 if (retVal != IME_ERROR_NONE) return retVal;
1008 g_event_callback.process_key_event = callback_func;
1009 g_event_callback.process_key_event_user_data = user_data;
1011 return IME_ERROR_NONE;
1014 EXPORT_API int ime_event_set_process_key_event_with_keycode_cb(ime_process_key_event_with_keycode_cb callback_func, void *user_data)
1016 ime_error_e retVal = IME_ERROR_NONE;
1018 if (!callback_func) {
1019 LOGW("IME_ERROR_INVALID_PARAMETER");
1020 return IME_ERROR_INVALID_PARAMETER;
1023 retVal = _check_privilege();
1024 if (retVal != IME_ERROR_NONE) return retVal;
1026 g_event_callback.process_key_event_with_keycode = callback_func;
1027 g_event_callback.process_key_event_with_keycode_user_data = user_data;
1029 return IME_ERROR_NONE;
1032 EXPORT_API int ime_event_set_display_language_changed_cb(ime_display_language_changed_cb callback_func, void *user_data)
1034 ime_error_e retVal = IME_ERROR_NONE;
1036 if (!callback_func) {
1037 LOGW("IME_ERROR_INVALID_PARAMETER");
1038 return IME_ERROR_INVALID_PARAMETER;
1041 retVal = _check_privilege();
1042 if (retVal != IME_ERROR_NONE) return retVal;
1044 g_event_callback.display_language_changed = callback_func;
1045 g_event_callback.display_language_changed_user_data = user_data;
1047 return IME_ERROR_NONE;
1050 EXPORT_API int ime_event_set_rotation_degree_changed_cb(ime_rotation_degree_changed_cb callback_func, void *user_data)
1052 ime_error_e retVal = IME_ERROR_NONE;
1054 if (!callback_func) {
1055 LOGW("IME_ERROR_INVALID_PARAMETER");
1056 return IME_ERROR_INVALID_PARAMETER;
1059 retVal = _check_privilege();
1060 if (retVal != IME_ERROR_NONE) return retVal;
1062 g_event_callback.rotation_degree_changed = callback_func;
1063 g_event_callback.rotation_degree_changed_user_data = user_data;
1065 return IME_ERROR_NONE;
1068 EXPORT_API int ime_event_set_accessibility_state_changed_cb(ime_accessibility_state_changed_cb callback_func, void *user_data)
1070 ime_error_e retVal = IME_ERROR_NONE;
1072 if (!callback_func) {
1073 LOGW("IME_ERROR_INVALID_PARAMETER");
1074 return IME_ERROR_INVALID_PARAMETER;
1077 retVal = _check_privilege();
1078 if (retVal != IME_ERROR_NONE) return retVal;
1080 g_event_callback.accessibility_state_changed = callback_func;
1081 g_event_callback.accessibility_state_changed_user_data = user_data;
1083 return IME_ERROR_NONE;
1086 EXPORT_API int ime_event_set_option_window_created_cb(ime_option_window_created_cb callback_func, void *user_data)
1088 ime_error_e retVal = IME_ERROR_NONE;
1090 if (!callback_func) {
1091 LOGW("IME_ERROR_INVALID_PARAMETER");
1092 return IME_ERROR_INVALID_PARAMETER;
1095 retVal = _check_privilege();
1096 if (retVal != IME_ERROR_NONE) return retVal;
1098 g_event_callback.option_window_created = callback_func;
1099 g_event_callback.option_window_created_user_data = user_data;
1101 return IME_ERROR_NONE;
1104 EXPORT_API int ime_event_set_option_window_destroyed_cb(ime_option_window_destroyed_cb callback_func, void *user_data)
1106 ime_error_e retVal = IME_ERROR_NONE;
1108 if (!callback_func) {
1109 LOGW("IME_ERROR_INVALID_PARAMETER");
1110 return IME_ERROR_INVALID_PARAMETER;
1113 retVal = _check_privilege();
1114 if (retVal != IME_ERROR_NONE) return retVal;
1116 g_event_callback.option_window_destroyed = callback_func;
1117 g_event_callback.option_window_destroyed_user_data = user_data;
1119 return IME_ERROR_NONE;
1123 EXPORT_API int ime_event_set_caps_mode_changed_cb(ime_caps_mode_changed_cb callback_func, void *user_data)
1125 ime_error_e retVal = IME_ERROR_NONE;
1127 if (!callback_func) {
1128 LOGW("IME_ERROR_INVALID_PARAMETER");
1129 return IME_ERROR_INVALID_PARAMETER;
1132 retVal = _check_privilege();
1133 if (retVal != IME_ERROR_NONE) return retVal;
1135 g_event_callback.caps_mode_changed = callback_func;
1136 g_event_callback.caps_mode_changed_user_data = user_data;
1138 return IME_ERROR_NONE;
1141 EXPORT_API int ime_event_set_candidate_show_cb(ime_candidate_show_cb callback_func, void *user_data)
1143 ime_error_e retVal = IME_ERROR_NONE;
1145 if (!callback_func) {
1146 LOGW("IME_ERROR_INVALID_PARAMETER");
1147 return IME_ERROR_INVALID_PARAMETER;
1150 retVal = _check_privilege();
1151 if (retVal != IME_ERROR_NONE) return retVal;
1153 g_event_callback.candidate_show = callback_func;
1154 g_event_callback.candidate_show_user_data = user_data;
1156 return IME_ERROR_NONE;
1159 EXPORT_API int ime_event_set_candidate_hide_cb(ime_candidate_hide_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.candidate_hide = callback_func;
1172 g_event_callback.candidate_hide_user_data = user_data;
1174 return IME_ERROR_NONE;
1177 EXPORT_API int ime_event_set_lookup_table_changed_cb(ime_lookup_table_changed_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.lookup_table_changed = callback_func;
1190 g_event_callback.lookup_table_changed_user_data = user_data;
1192 return IME_ERROR_NONE;
1196 EXPORT_API int ime_send_key_event(ime_key_code_e keycode, ime_key_mask_e keymask, bool forward_key)
1198 ime_error_e retVal = IME_ERROR_NONE;
1201 LOGW("IME_ERROR_NOT_RUNNING");
1202 return IME_ERROR_NOT_RUNNING;
1206 retVal = _check_privilege();
1207 if (retVal != IME_ERROR_NONE) return retVal;
1210 g_core.forward_key_event(-1, NULL, (sclu32)keycode, (sclu16)keymask);
1212 g_core.send_key_event(-1, NULL, (sclu32)keycode, (sclu16)keymask);
1215 return IME_ERROR_NONE;
1218 EXPORT_API int ime_commit_string(const char *str)
1220 ime_error_e retVal = IME_ERROR_NONE;
1223 LOGW("IME_ERROR_INVALID_PARAMETER");
1224 return IME_ERROR_INVALID_PARAMETER;
1228 LOGW("IME_ERROR_NOT_RUNNING");
1229 return IME_ERROR_NOT_RUNNING;
1233 retVal = _check_privilege();
1234 if (retVal != IME_ERROR_NONE) return retVal;
1236 SECURE_LOGI("commit string : %s", str);
1237 g_core.commit_string(-1, NULL, str);
1239 return IME_ERROR_NONE;
1243 EXPORT_API int ime_show_preedit_string(void)
1245 ime_error_e retVal = IME_ERROR_NONE;
1248 LOGW("IME_ERROR_NOT_RUNNING");
1249 return IME_ERROR_NOT_RUNNING;
1253 retVal = _check_privilege();
1254 if (retVal != IME_ERROR_NONE) return retVal;
1256 g_core.show_preedit_string(-1, NULL);
1258 return IME_ERROR_NONE;
1262 EXPORT_API int ime_hide_preedit_string(void)
1264 ime_error_e retVal = IME_ERROR_NONE;
1267 LOGW("IME_ERROR_NOT_RUNNING");
1268 return IME_ERROR_NOT_RUNNING;
1272 retVal = _check_privilege();
1273 if (retVal != IME_ERROR_NONE) return retVal;
1275 g_core.hide_preedit_string(-1, NULL);
1277 return IME_ERROR_NONE;
1281 EXPORT_API int ime_update_preedit_string(const char *str, Eina_List *attrs)
1283 ime_error_e retVal = IME_ERROR_NONE;
1286 LOGW("IME_ERROR_INVALID_PARAMETER");
1287 return IME_ERROR_INVALID_PARAMETER;
1291 LOGW("IME_ERROR_NOT_RUNNING");
1292 return IME_ERROR_NOT_RUNNING;
1296 retVal = _check_privilege();
1297 if (retVal != IME_ERROR_NONE) return retVal;
1299 scim::AttributeList attrv;
1301 ime_preedit_attribute *attr = NULL;
1304 EINA_LIST_FREE(attrs, data) {
1305 attr = (ime_preedit_attribute *)data;
1307 attrv.push_back(scim::Attribute(attr->start, attr->length, (scim::AttributeType)attr->type, attr->value));
1313 SECURE_LOGI("preedit string : '%s'", str);
1314 g_core.update_preedit_string(-1, NULL, str, attrv);
1316 return IME_ERROR_NONE;
1320 EXPORT_API int ime_request_surrounding_text(int maxlen_before, int maxlen_after)
1322 ime_error_e retVal = IME_ERROR_NONE;
1324 if (!g_event_callback.surrounding_text_updated) {
1325 LOGW("IME_ERROR_NO_CALLBACK_FUNCTION");
1326 return IME_ERROR_NO_CALLBACK_FUNCTION;
1330 LOGW("IME_ERROR_NOT_RUNNING");
1331 return IME_ERROR_NOT_RUNNING;
1335 retVal = _check_privilege();
1336 if (retVal != IME_ERROR_NONE) return retVal;
1338 g_core.get_surrounding_text(NULL, maxlen_before, maxlen_after);
1340 return IME_ERROR_NONE;
1344 EXPORT_API int ime_delete_surrounding_text(int offset, int len)
1346 ime_error_e retVal = IME_ERROR_NONE;
1349 LOGW("IME_ERROR_INVALID_PARAMETER");
1350 return IME_ERROR_INVALID_PARAMETER;
1354 LOGW("IME_ERROR_NOT_RUNNING");
1355 return IME_ERROR_NOT_RUNNING;
1359 retVal = _check_privilege();
1360 if (retVal != IME_ERROR_NONE) return retVal;
1362 LOGI("offset: %d, len : %d", offset, len);
1363 g_core.delete_surrounding_text(offset, len);
1365 return IME_ERROR_NONE;
1369 EXPORT_API int ime_get_surrounding_text(int maxlen_before, int maxlen_after, char **text, int *cursor_pos)
1371 ime_error_e retVal = IME_ERROR_NONE;
1373 if (!text || !cursor_pos) {
1374 LOGW("IME_ERROR_INVALID_PARAMETER");
1375 return IME_ERROR_INVALID_PARAMETER;
1379 LOGW("IME_ERROR_NOT_RUNNING");
1380 return IME_ERROR_NOT_RUNNING;
1384 retVal = _check_privilege();
1385 if (retVal != IME_ERROR_NONE) return retVal;
1389 int ret = g_core.get_surrounding_text(maxlen_before, maxlen_after, text, cursor);
1391 LOGW("IME_ERROR_OUR_OF_MEMORY");
1392 return IME_ERROR_OUT_OF_MEMORY;
1396 *cursor_pos = cursor;
1398 return IME_ERROR_NONE;
1402 EXPORT_API int ime_set_selection(int start, int end)
1404 ime_error_e retVal = IME_ERROR_NONE;
1407 LOGW("IME_ERROR_INVALID_PARAMETER");
1408 return IME_ERROR_INVALID_PARAMETER;
1412 LOGW("IME_ERROR_NOT_RUNNING");
1413 return IME_ERROR_NOT_RUNNING;
1417 retVal = _check_privilege();
1418 if (retVal != IME_ERROR_NONE) return retVal;
1420 LOGI("start: %d, end : %d", start, end);
1421 g_core.set_selection(start, end);
1423 return IME_ERROR_NONE;
1427 EXPORT_API int ime_get_selected_text(char **text)
1429 ime_error_e retVal = IME_ERROR_NONE;
1432 LOGW("IME_ERROR_INVALID_PARAMETER");
1433 return IME_ERROR_INVALID_PARAMETER;
1437 LOGW("IME_ERROR_NOT_RUNNING");
1438 return IME_ERROR_NOT_RUNNING;
1442 retVal = _check_privilege();
1443 if (retVal != IME_ERROR_NONE) return retVal;
1445 g_core.get_selection_text(text);
1447 return IME_ERROR_NONE;
1451 EXPORT_API Evas_Object* ime_get_main_window(void)
1453 ime_error_e retVal = IME_ERROR_NONE;
1455 Evas_Object *win = NULL;
1457 retVal = _check_privilege();
1458 if (retVal != IME_ERROR_NONE) {
1460 LOGE("_check_privilege returned %d.", retVal);
1461 set_last_result(retVal);
1467 set_last_result(IME_ERROR_NOT_RUNNING);
1468 LOGW("IME_ERROR_NOT_RUNNING");
1473 win = static_cast<Evas_Object*>(g_core.get_main_window());
1475 set_last_result(IME_ERROR_NONE);
1477 set_last_result(IME_ERROR_OPERATION_FAILED);
1478 LOGW("IME_ERROR_OPERATION_FAILED");
1485 EXPORT_API int ime_set_size(int portrait_width, int portrait_height, int landscape_width, int landscape_height)
1487 ime_error_e retVal = IME_ERROR_NONE;
1489 SclSize portrait_size, landscape_size;
1491 if (portrait_width < 1 || portrait_height < 1 || landscape_width < 1 || landscape_height < 1) {
1492 LOGW("IME_ERROR_INVALID_PARAMETER");
1493 return IME_ERROR_INVALID_PARAMETER;
1497 LOGW("IME_ERROR_NOT_RUNNING");
1498 return IME_ERROR_NOT_RUNNING;
1502 retVal = _check_privilege();
1503 if (retVal != IME_ERROR_NONE) return retVal;
1505 portrait_size.width = portrait_width;
1506 portrait_size.height = portrait_height;
1508 landscape_size.width = landscape_width;
1509 landscape_size.height = landscape_height;
1511 g_core.set_keyboard_size_hints(portrait_size, landscape_size);
1513 return IME_ERROR_NONE;
1517 EXPORT_API int ime_create_option_window(void)
1519 ime_error_e retVal = IME_ERROR_NONE;
1521 if (!g_event_callback.option_window_created || !g_event_callback.option_window_destroyed) {
1522 LOGW("ime_create_option_window_cb() and ime_destroy_option_window_cb() callback functions are not set.");
1523 return IME_ERROR_NO_CALLBACK_FUNCTION;
1527 LOGW("IME_ERROR_NOT_RUNNING");
1528 return IME_ERROR_NOT_RUNNING;
1532 retVal = _check_privilege();
1533 if (retVal != IME_ERROR_NONE) return retVal;
1535 if (g_core.create_option_window()) {
1536 return IME_ERROR_NONE;
1538 LOGW("IME_ERROR_OPERATION_FAILED");
1539 return IME_ERROR_OPERATION_FAILED;
1544 EXPORT_API int ime_destroy_option_window(Evas_Object *window)
1546 ime_error_e retVal = IME_ERROR_NONE;
1548 if (!g_event_callback.option_window_created || !g_event_callback.option_window_destroyed) {
1549 LOGW("ime_create_option_window_cb() and ime_destroy_option_window_cb() callback functions are not set.");
1550 return IME_ERROR_NO_CALLBACK_FUNCTION;
1554 LOGW("Window pointer is null.");
1555 return IME_ERROR_INVALID_PARAMETER;
1559 LOGW("IME_ERROR_NOT_RUNNING");
1560 return IME_ERROR_NOT_RUNNING;
1564 retVal = _check_privilege();
1565 if (retVal != IME_ERROR_NONE) return retVal;
1567 g_core.destroy_option_window(window);
1569 return IME_ERROR_NONE;
1574 EXPORT_API int ime_set_imengine(const char *engine_id)
1576 ime_error_e retVal = IME_ERROR_NONE;
1579 LOGW("IME_ERROR_INVALID_PARAMETER");
1580 return IME_ERROR_INVALID_PARAMETER;
1583 retVal = _check_privilege();
1584 if (retVal != IME_ERROR_NONE) return retVal;
1586 g_core.set_keyboard_ise_by_uuid(engine_id);
1588 return IME_ERROR_NONE;
1591 EXPORT_API int ime_flush_imengine(void)
1593 ime_error_e retVal = IME_ERROR_NONE;
1596 LOGW("IME_ERROR_NOT_RUNNING");
1597 return IME_ERROR_NOT_RUNNING;
1600 retVal = _check_privilege();
1601 if (retVal != IME_ERROR_NONE) return retVal;
1603 g_core.flush_keyboard_ise();
1605 return IME_ERROR_NONE;
1608 EXPORT_API int ime_send_imengine_event(int command, unsigned int value)
1610 ime_error_e retVal = IME_ERROR_NONE;
1613 LOGW("IME_ERROR_NOT_RUNNING");
1614 return IME_ERROR_NOT_RUNNING;
1617 retVal = _check_privilege();
1618 if (retVal != IME_ERROR_NONE) return retVal;
1620 g_core.send_imengine_event(-1, NULL, command, value);
1622 return IME_ERROR_NONE;
1625 EXPORT_API int ime_reset_imengine(void)
1627 ime_error_e retVal = IME_ERROR_NONE;
1630 LOGW("IME_ERROR_NOT_RUNNING");
1631 return IME_ERROR_NOT_RUNNING;
1634 retVal = _check_privilege();
1635 if (retVal != IME_ERROR_NONE) return retVal;
1637 g_core.reset_keyboard_ise();
1639 return IME_ERROR_NONE;
1642 EXPORT_API int ime_update_input_context(unsigned int type, unsigned int value)
1644 ime_error_e retVal = IME_ERROR_NONE;
1647 LOGW("IME_ERROR_NOT_RUNNING");
1648 return IME_ERROR_NOT_RUNNING;
1651 retVal = _check_privilege();
1652 if (retVal != IME_ERROR_NONE) return retVal;
1654 g_core.update_input_context(type, value);
1656 return IME_ERROR_NONE;
1660 EXPORT_API int ime_request_hide(void)
1662 ime_error_e retVal = IME_ERROR_NONE;
1665 LOGW("IME_ERROR_NOT_RUNNING");
1666 return IME_ERROR_NOT_RUNNING;
1670 retVal = _check_privilege();
1671 if (retVal != IME_ERROR_NONE) return retVal;
1673 g_core.request_ise_hide();
1675 return IME_ERROR_NONE;
1680 EXPORT_API int ime_initialize(void)
1682 ime_error_e retVal = IME_ERROR_NONE;
1684 retVal = _check_privilege();
1685 if (retVal != IME_ERROR_NONE) return retVal;
1693 EXPORT_API int ime_prepare(void)
1695 ime_error_e retVal = IME_ERROR_NONE;
1698 LOGE("inputmethod main loop is already running.");
1699 return IME_ERROR_OPERATION_FAILED;
1702 retVal = _check_privilege();
1703 if (retVal != IME_ERROR_NONE) return retVal;
1712 EXPORT_API int ime_finalize(void)
1714 ime_error_e retVal = IME_ERROR_NONE;
1716 retVal = _check_privilege();
1717 if (retVal != IME_ERROR_NONE) return retVal;
1721 memset(&g_basic_callback, 0, sizeof(ime_callback_s));
1722 memset(&g_event_callback, 0, sizeof(ime_event_callback_s));
1728 EXPORT_API int ime_select_candidate(unsigned int index)
1730 ime_error_e retVal = IME_ERROR_NONE;
1733 LOGW("IME_ERROR_NOT_RUNNING");
1734 return IME_ERROR_NOT_RUNNING;
1737 retVal = _check_privilege();
1738 if (retVal != IME_ERROR_NONE) return retVal;
1740 g_core.select_candidate(index);
1742 return IME_ERROR_NONE;
1746 EXPORT_API int ime_send_private_command(const char *command)
1748 ime_error_e retVal = IME_ERROR_NONE;
1751 LOGW("IME_ERROR_INVALID_PARAMETER");
1752 return IME_ERROR_INVALID_PARAMETER;
1756 LOGW("IME_ERROR_NOT_RUNNING");
1757 return IME_ERROR_NOT_RUNNING;
1761 retVal = _check_privilege();
1762 if (retVal != IME_ERROR_NONE) return retVal;
1764 g_core.send_private_command(command);
1766 return IME_ERROR_NONE;
1770 EXPORT_API int ime_commit_content(const char *content, const char *description, const char *mime_type)
1772 ime_error_e retVal = IME_ERROR_NONE;
1774 if (!content || !description || !mime_type) {
1775 LOGW("IME_ERROR_INVALID_PARAMETER");
1776 return IME_ERROR_INVALID_PARAMETER;
1779 retVal = _check_privilege();
1780 if (retVal != IME_ERROR_NONE) return retVal;
1783 LOGW("IME_ERROR_NOT_RUNNING");
1784 return IME_ERROR_NOT_RUNNING;
1788 LOGI("content : '%s', description : '%s', mime_type : '%s'", content, description, mime_type);
1789 g_core.commit_content(content, description, mime_type);
1791 return IME_ERROR_NONE;
1795 EXPORT_API int ime_context_get_layout(ime_context_h context, Ecore_IMF_Input_Panel_Layout *layout)
1797 ime_error_e retVal = IME_ERROR_NONE;
1799 if (!context || !layout) {
1800 LOGW("IME_ERROR_INVALID_PARAMETER");
1801 return IME_ERROR_INVALID_PARAMETER;
1804 retVal = _check_privilege();
1805 if (retVal != IME_ERROR_NONE) return retVal;
1808 LOGW("IME_ERROR_NOT_RUNNING");
1809 return IME_ERROR_NOT_RUNNING;
1813 *layout = context->layout;
1815 return IME_ERROR_NONE;
1819 EXPORT_API int ime_context_get_layout_variation(ime_context_h context, ime_layout_variation_e *layout_variation)
1821 ime_error_e retVal = IME_ERROR_NONE;
1823 if (!context || !layout_variation) {
1824 LOGW("IME_ERROR_INVALID_PARAMETER");
1825 return IME_ERROR_INVALID_PARAMETER;
1828 retVal = _check_privilege();
1829 if (retVal != IME_ERROR_NONE) return retVal;
1832 LOGW("IME_ERROR_NOT_RUNNING");
1833 return IME_ERROR_NOT_RUNNING;
1837 *layout_variation = static_cast<ime_layout_variation_e>(context->layout_variation);
1839 return IME_ERROR_NONE;
1843 EXPORT_API int ime_context_get_cursor_position(ime_context_h context, int *cursor_pos)
1845 ime_error_e retVal = IME_ERROR_NONE;
1847 if (!context || !cursor_pos) {
1848 LOGW("IME_ERROR_INVALID_PARAMETER");
1849 return IME_ERROR_INVALID_PARAMETER;
1852 retVal = _check_privilege();
1853 if (retVal != IME_ERROR_NONE) return retVal;
1856 LOGW("IME_ERROR_NOT_RUNNING");
1857 return IME_ERROR_NOT_RUNNING;
1861 *cursor_pos = context->cursor_pos;
1863 return IME_ERROR_NONE;
1867 EXPORT_API int ime_context_get_autocapital_type(ime_context_h context, Ecore_IMF_Autocapital_Type *autocapital_type)
1869 ime_error_e retVal = IME_ERROR_NONE;
1871 if (!context || !autocapital_type) {
1872 LOGW("IME_ERROR_INVALID_PARAMETER");
1873 return IME_ERROR_INVALID_PARAMETER;
1876 retVal = _check_privilege();
1877 if (retVal != IME_ERROR_NONE) return retVal;
1880 LOGW("IME_ERROR_NOT_RUNNING");
1881 return IME_ERROR_NOT_RUNNING;
1885 *autocapital_type = context->autocapital_type;
1887 return IME_ERROR_NONE;
1891 EXPORT_API int ime_context_get_return_key_type(ime_context_h context, Ecore_IMF_Input_Panel_Return_Key_Type *return_key_type)
1893 ime_error_e retVal = IME_ERROR_NONE;
1895 if (!context || !return_key_type) {
1896 LOGW("IME_ERROR_INVALID_PARAMETER");
1897 return IME_ERROR_INVALID_PARAMETER;
1900 retVal = _check_privilege();
1901 if (retVal != IME_ERROR_NONE) return retVal;
1904 LOGW("IME_ERROR_NOT_RUNNING");
1905 return IME_ERROR_NOT_RUNNING;
1909 *return_key_type = context->return_key_type;
1911 return IME_ERROR_NONE;
1915 EXPORT_API int ime_context_get_return_key_state(ime_context_h context, bool *return_key_state)
1917 ime_error_e retVal = IME_ERROR_NONE;
1919 if (!context || !return_key_state) {
1920 LOGW("IME_ERROR_INVALID_PARAMETER");
1921 return IME_ERROR_INVALID_PARAMETER;
1924 retVal = _check_privilege();
1925 if (retVal != IME_ERROR_NONE) return retVal;
1928 LOGW("IME_ERROR_NOT_RUNNING");
1929 return IME_ERROR_NOT_RUNNING;
1933 *return_key_state = static_cast<bool>(context->return_key_disabled);
1935 return IME_ERROR_NONE;
1939 EXPORT_API int ime_context_get_prediction_mode(ime_context_h context, bool *prediction_mode)
1941 ime_error_e retVal = IME_ERROR_NONE;
1943 if (!context || !prediction_mode) {
1944 LOGW("IME_ERROR_INVALID_PARAMETER");
1945 return IME_ERROR_INVALID_PARAMETER;
1948 retVal = _check_privilege();
1949 if (retVal != IME_ERROR_NONE) return retVal;
1952 LOGW("IME_ERROR_NOT_RUNNING");
1953 return IME_ERROR_NOT_RUNNING;
1957 *prediction_mode = static_cast<bool>(context->prediction_allow);
1959 return IME_ERROR_NONE;
1963 EXPORT_API int ime_context_get_password_mode(ime_context_h context, bool *password_mode)
1965 ime_error_e retVal = IME_ERROR_NONE;
1967 if (!context || !password_mode) {
1968 LOGW("IME_ERROR_INVALID_PARAMETER");
1969 return IME_ERROR_INVALID_PARAMETER;
1972 retVal = _check_privilege();
1973 if (retVal != IME_ERROR_NONE) return retVal;
1976 LOGW("IME_ERROR_NOT_RUNNING");
1977 return IME_ERROR_NOT_RUNNING;
1981 *password_mode = static_cast<bool>(context->password_mode);
1983 return IME_ERROR_NONE;
1987 EXPORT_API int ime_context_get_input_hint(ime_context_h context, Ecore_IMF_Input_Hints *input_hint)
1989 ime_error_e retVal = IME_ERROR_NONE;
1991 if (!context || !input_hint) {
1992 LOGW("IME_ERROR_INVALID_PARAMETER");
1993 return IME_ERROR_INVALID_PARAMETER;
1996 retVal = _check_privilege();
1997 if (retVal != IME_ERROR_NONE) return retVal;
2000 LOGW("IME_ERROR_NOT_RUNNING");
2001 return IME_ERROR_NOT_RUNNING;
2005 *input_hint = context->input_hint;
2007 return IME_ERROR_NONE;
2011 EXPORT_API int ime_context_get_bidi_direction(ime_context_h context, Ecore_IMF_BiDi_Direction *bidi)
2013 ime_error_e retVal = IME_ERROR_NONE;
2015 if (!context || !bidi) {
2016 LOGW("IME_ERROR_INVALID_PARAMETER");
2017 return IME_ERROR_INVALID_PARAMETER;
2020 retVal = _check_privilege();
2021 if (retVal != IME_ERROR_NONE) return retVal;
2024 LOGW("IME_ERROR_NOT_RUNNING");
2025 return IME_ERROR_NOT_RUNNING;
2029 *bidi = context->bidi_direction;
2031 return IME_ERROR_NONE;
2035 EXPORT_API int ime_context_get_language(ime_context_h context, Ecore_IMF_Input_Panel_Lang *language)
2037 ime_error_e retVal = IME_ERROR_NONE;
2039 if (!context || !language) {
2040 LOGW("IME_ERROR_INVALID_PARAMETER");
2041 return IME_ERROR_INVALID_PARAMETER;
2044 retVal = _check_privilege();
2045 if (retVal != IME_ERROR_NONE) return retVal;
2048 LOGW("IME_ERROR_NOT_RUNNING");
2049 return IME_ERROR_NOT_RUNNING;
2053 *language = context->language;
2055 return IME_ERROR_NONE;
2060 EXPORT_API int ime_context_get_caps_mode(ime_context_h context, bool *caps_mode)
2062 ime_error_e retVal = IME_ERROR_NONE;
2064 if (!context || !caps_mode) {
2065 LOGW("IME_ERROR_INVALID_PARAMETER");
2066 return IME_ERROR_INVALID_PARAMETER;
2069 retVal = _check_privilege();
2070 if (retVal != IME_ERROR_NONE) return retVal;
2073 LOGW("IME_ERROR_NOT_RUNNING");
2074 return IME_ERROR_NOT_RUNNING;
2077 *caps_mode = static_cast<bool>(context->caps_mode);
2079 return IME_ERROR_NONE;
2083 EXPORT_API int ime_device_info_get_name(ime_device_info_h dev_info, char **dev_name)
2085 ime_error_e retVal = IME_ERROR_NONE;
2087 if (!dev_info || !dev_name) {
2088 LOGW("IME_ERROR_INVALID_PARAMETER");
2089 return IME_ERROR_INVALID_PARAMETER;
2092 retVal = _check_privilege();
2093 if (retVal != IME_ERROR_NONE) return retVal;
2096 LOGW("IME_ERROR_NOT_RUNNING");
2097 return IME_ERROR_NOT_RUNNING;
2101 if (!dev_info->dev_name)
2102 *dev_name = strdup("");
2104 *dev_name = strdup(dev_info->dev_name);
2106 return IME_ERROR_NONE;
2110 EXPORT_API int ime_device_info_get_class(ime_device_info_h dev_info, Ecore_IMF_Device_Class *dev_class)
2112 ime_error_e retVal = IME_ERROR_NONE;
2114 if (!dev_info || !dev_class) {
2115 LOGW("IME_ERROR_INVALID_PARAMETER");
2116 return IME_ERROR_INVALID_PARAMETER;
2119 retVal = _check_privilege();
2120 if (retVal != IME_ERROR_NONE) return retVal;
2123 LOGW("IME_ERROR_NOT_RUNNING");
2124 return IME_ERROR_NOT_RUNNING;
2128 *dev_class = dev_info->dev_class;
2130 return IME_ERROR_NONE;
2134 EXPORT_API int ime_device_info_get_subclass(ime_device_info_h dev_info, Ecore_IMF_Device_Subclass *dev_subclass)
2136 ime_error_e retVal = IME_ERROR_NONE;
2138 if (!dev_info || !dev_subclass) {
2139 LOGW("IME_ERROR_INVALID_PARAMETER");
2140 return IME_ERROR_INVALID_PARAMETER;
2143 retVal = _check_privilege();
2144 if (retVal != IME_ERROR_NONE) return retVal;
2147 LOGW("IME_ERROR_NOT_RUNNING");
2148 return IME_ERROR_NOT_RUNNING;
2152 *dev_subclass = dev_info->dev_subclass;
2154 return IME_ERROR_NONE;
2159 EXPORT_API int ime_event_set_process_input_device_event_cb(ime_process_input_device_event_cb callback_func, void *user_data)
2161 ime_error_e retVal = IME_ERROR_NONE;
2163 if (!callback_func) {
2164 LOGW("IME_ERROR_INVALID_PARAMETER");
2165 return IME_ERROR_INVALID_PARAMETER;
2168 retVal = _check_privilege();
2169 if (retVal != IME_ERROR_NONE) return retVal;
2171 g_event_callback.process_input_device_event = callback_func;
2172 g_event_callback.process_input_device_event_user_data = user_data;
2174 return IME_ERROR_NONE;
2177 EXPORT_API int ime_event_unset_process_input_device_event_cb(void)
2179 ime_error_e retVal = IME_ERROR_NONE;
2181 retVal = _check_privilege();
2182 if (retVal != IME_ERROR_NONE) return retVal;
2184 g_event_callback.process_input_device_event = NULL;
2185 g_event_callback.process_input_device_event_user_data = NULL;
2187 return IME_ERROR_NONE;
2190 /* Functions for Rotary input device event */
2191 EXPORT_API int ime_input_device_rotary_get_direction(ime_input_device_event_h event_handle, ime_input_device_rotary_direction_e *direction)
2193 ime_error_e retVal = IME_ERROR_NONE;
2195 if (!event_handle || !direction) {
2196 LOGW("IME_ERROR_INVALID_PARAMETER");
2197 return IME_ERROR_INVALID_PARAMETER;
2200 ime_device_event_s *device_event = static_cast<ime_device_event_s*>(event_handle);
2201 if (device_event->device_type != IME_INPUT_DEVICE_TYPE_ROTARY) {
2202 LOGW("IME_ERROR_INVALID_PARAMETER");
2203 return IME_ERROR_INVALID_PARAMETER;
2206 retVal = _check_privilege();
2207 if (retVal != IME_ERROR_NONE) return retVal;
2210 LOGW("IME_ERROR_OPERATION_FAILED");
2211 return IME_ERROR_OPERATION_FAILED;
2215 Ecore_Event_Detent_Rotate *rotary_device_event =
2216 static_cast<Ecore_Event_Detent_Rotate*>(device_event->event_data);
2217 if (rotary_device_event) {
2218 if (rotary_device_event->direction == ECORE_DETENT_DIRECTION_CLOCKWISE) {
2219 *direction = IME_INPUT_DEVICE_ROTARY_DIRECTION_CLOCKWISE;
2220 } else if (rotary_device_event->direction == ECORE_DETENT_DIRECTION_COUNTER_CLOCKWISE) {
2221 *direction = IME_INPUT_DEVICE_ROTARY_DIRECTION_COUNTER_CLOCKWISE;
2225 return IME_ERROR_NONE;
2230 EXPORT_API int ime_event_set_prediction_hint_set_cb(ime_prediction_hint_set_cb callback_func, void *user_data)
2232 ime_error_e retVal = IME_ERROR_NONE;
2234 if (!callback_func) {
2235 LOGW("IME_ERROR_INVALID_PARAMETER");
2236 return IME_ERROR_INVALID_PARAMETER;
2239 retVal = _check_privilege();
2240 if (retVal != IME_ERROR_NONE) return retVal;
2242 g_event_callback.prediction_hint_set = callback_func;
2243 g_event_callback.prediction_hint_set_user_data = user_data;
2245 return IME_ERROR_NONE;
2248 EXPORT_API int ime_event_set_mime_type_set_request_cb(ime_mime_type_set_request_cb callback_func, void *user_data)
2250 ime_error_e retVal = IME_ERROR_NONE;
2252 if (!callback_func) {
2253 LOGW("IME_ERROR_INVALID_PARAMETER");
2254 return IME_ERROR_INVALID_PARAMETER;
2257 retVal = _check_privilege();
2258 if (retVal != IME_ERROR_NONE) return retVal;
2260 g_event_callback.mime_type_set = callback_func;
2261 g_event_callback.mime_type_set_user_data = user_data;
2263 return IME_ERROR_NONE;
2266 EXPORT_API int ime_set_floating_mode(bool floating_mode)
2268 ime_error_e retVal = IME_ERROR_NONE;
2270 retVal = _check_privilege();
2271 if (retVal != IME_ERROR_NONE) return retVal;
2274 LOGW("IME_ERROR_NOT_RUNNING");
2275 return IME_ERROR_NOT_RUNNING;
2279 g_core.set_floating_mode(floating_mode);
2281 return IME_ERROR_NONE;
2285 EXPORT_API int ime_set_floating_drag_start(void)
2287 ime_error_e retVal = IME_ERROR_NONE;
2289 retVal = _check_privilege();
2290 if (retVal != IME_ERROR_NONE) return retVal;
2293 LOGW("IME_ERROR_NOT_RUNNING");
2294 return IME_ERROR_NOT_RUNNING;
2298 g_core.set_floating_drag_enabled(true);
2300 return IME_ERROR_NONE;
2304 EXPORT_API int ime_set_floating_drag_end(void)
2306 ime_error_e retVal = IME_ERROR_NONE;
2308 retVal = _check_privilege();
2309 if (retVal != IME_ERROR_NONE) return retVal;
2312 LOGW("IME_ERROR_NOT_RUNNING");
2313 return IME_ERROR_NOT_RUNNING;
2317 g_core.set_floating_drag_enabled(false);
2319 return IME_ERROR_NONE;
2324 EXPORT_API int ime_set_window_creation_defer_flag(bool flag)
2326 ime_error_e retVal = IME_ERROR_NONE;
2328 retVal = _check_privilege();
2329 if (retVal != IME_ERROR_NONE) return retVal;
2331 g_core.set_window_creation_defer_flag(flag);
2333 return IME_ERROR_NONE;
2337 EXPORT_API int ime_event_set_prediction_hint_data_set_cb(ime_prediction_hint_data_set_cb callback_func, void *user_data)
2339 ime_error_e retVal = IME_ERROR_NONE;
2341 if (!callback_func) {
2342 LOGW("IME_ERROR_INVALID_PARAMETER");
2343 return IME_ERROR_INVALID_PARAMETER;
2346 retVal = _check_privilege();
2347 if (retVal != IME_ERROR_NONE) return retVal;
2349 g_event_callback.prediction_hint_data_set = callback_func;
2350 g_event_callback.prediction_hint_data_set_user_data = user_data;
2352 return IME_ERROR_NONE;
2356 EXPORT_API int ime_event_set_optimization_hint_set_cb(ime_optimization_hint_set_cb callback_func, void *user_data)
2359 ime_error_e retVal = IME_ERROR_NONE;
2361 if (!callback_func) {
2362 LOGW("IME_ERROR_INVALID_PARAMETER");
2363 return IME_ERROR_INVALID_PARAMETER;
2367 retVal = _check_privilege();
2368 if (retVal != IME_ERROR_NONE) return retVal;
2371 g_event_callback.optimization_hint_set = callback_func;
2372 g_event_callback.optimization_hint_set_user_data = user_data;
2374 return IME_ERROR_NONE;
2377 EXPORT_API int ime_event_set_process_key_event_with_imengine_cb(ime_process_key_event_with_imengine_cb callback_func, void *user_data)
2380 ime_error_e retVal = IME_ERROR_NONE;
2382 if (!callback_func) {
2383 LOGW("IME_ERROR_INVALID_PARAMETER");
2384 return IME_ERROR_INVALID_PARAMETER;
2387 retVal = _check_privilege();
2388 if (retVal != IME_ERROR_NONE) return retVal;
2390 g_event_callback.process_key_event_with_imengine = callback_func;
2391 g_event_callback.process_key_event_with_imengine_user_data = user_data;
2393 return IME_ERROR_NONE;
2396 EXPORT_API int ime_event_set_autocapital_type_set_cb(ime_autocapital_type_set_cb callback_func, void *user_data)
2399 ime_error_e retVal = IME_ERROR_NONE;
2401 if (!callback_func) {
2402 LOGW("IME_ERROR_INVALID_PARAMETER");
2403 return IME_ERROR_INVALID_PARAMETER;
2406 retVal = _check_privilege();
2407 if (retVal != IME_ERROR_NONE) return retVal;
2409 g_event_callback.autocapital_type_set = callback_func;
2410 g_event_callback.autocapital_type_set_user_data = user_data;
2412 return IME_ERROR_NONE;
2415 EXPORT_API int ime_event_set_prediction_allow_set_cb(ime_prediction_allow_set_cb callback_func, void *user_data)
2418 ime_error_e retVal = IME_ERROR_NONE;
2420 if (!callback_func) {
2421 LOGW("IME_ERROR_INVALID_PARAMETER");
2422 return IME_ERROR_INVALID_PARAMETER;
2425 retVal = _check_privilege();
2426 if (retVal != IME_ERROR_NONE) return retVal;
2428 g_event_callback.prediction_allow_set = callback_func;
2429 g_event_callback.prediction_allow_set_user_data = user_data;
2431 return IME_ERROR_NONE;
2434 EXPORT_API int ime_event_set_trigger_property_set_cb(ime_trigger_property_set_cb callback_func, void *user_data)
2437 ime_error_e retVal = IME_ERROR_NONE;
2439 if (!callback_func) {
2440 LOGW("IME_ERROR_INVALID_PARAMETER");
2441 return IME_ERROR_INVALID_PARAMETER;
2444 retVal = _check_privilege();
2445 if (retVal != IME_ERROR_NONE) return retVal;
2447 g_event_callback.trigger_property_set = callback_func;
2448 g_event_callback.trigger_property_set_user_data = user_data;
2450 return IME_ERROR_NONE;
2453 EXPORT_API int ime_event_set_candidate_more_window_show_cb(ime_candidate_more_window_show_cb callback_func, void *user_data)
2456 ime_error_e retVal = IME_ERROR_NONE;
2458 if (!callback_func) {
2459 LOGW("IME_ERROR_INVALID_PARAMETER");
2460 return IME_ERROR_INVALID_PARAMETER;
2463 retVal = _check_privilege();
2464 if (retVal != IME_ERROR_NONE) return retVal;
2466 g_event_callback.candidate_more_window_show = callback_func;
2467 g_event_callback.candidate_more_window_show_user_data = user_data;
2469 return IME_ERROR_NONE;
2472 EXPORT_API int ime_event_set_candidate_more_window_hide_cb(ime_candidate_more_window_hide_cb callback_func, void *user_data)
2475 ime_error_e retVal = IME_ERROR_NONE;
2477 if (!callback_func) {
2478 LOGW("IME_ERROR_INVALID_PARAMETER");
2479 return IME_ERROR_INVALID_PARAMETER;
2482 retVal = _check_privilege();
2483 if (retVal != IME_ERROR_NONE) return retVal;
2485 g_event_callback.candidate_more_window_hide = callback_func;
2486 g_event_callback.candidate_more_window_hide_user_data = user_data;
2488 return IME_ERROR_NONE;
2491 EXPORT_API int ime_event_set_aux_select_cb(ime_aux_select_cb callback_func, void *user_data)
2494 ime_error_e retVal = IME_ERROR_NONE;
2496 if (!callback_func) {
2497 LOGW("IME_ERROR_INVALID_PARAMETER");
2498 return IME_ERROR_INVALID_PARAMETER;
2501 retVal = _check_privilege();
2502 if (retVal != IME_ERROR_NONE) return retVal;
2504 g_event_callback.aux_select = callback_func;
2505 g_event_callback.aux_select_user_data = user_data;
2507 return IME_ERROR_NONE;
2510 EXPORT_API int ime_event_set_candidate_select_cb(ime_candidate_select_cb callback_func, void *user_data)
2513 ime_error_e retVal = IME_ERROR_NONE;
2515 if (!callback_func) {
2516 LOGW("IME_ERROR_INVALID_PARAMETER");
2517 return IME_ERROR_INVALID_PARAMETER;
2520 retVal = _check_privilege();
2521 if (retVal != IME_ERROR_NONE) return retVal;
2523 g_event_callback.candidate_select = callback_func;
2524 g_event_callback.candidate_select_user_data = user_data;
2526 return IME_ERROR_NONE;
2529 EXPORT_API int ime_event_set_candidate_table_page_up_cb(ime_candidate_table_page_up_cb callback_func, void *user_data)
2532 ime_error_e retVal = IME_ERROR_NONE;
2534 if (!callback_func) {
2535 LOGW("IME_ERROR_INVALID_PARAMETER");
2536 return IME_ERROR_INVALID_PARAMETER;
2539 retVal = _check_privilege();
2540 if (retVal != IME_ERROR_NONE) return retVal;
2542 g_event_callback.candidate_table_page_up = callback_func;
2543 g_event_callback.candidate_table_page_up_user_data = user_data;
2545 return IME_ERROR_NONE;
2548 EXPORT_API int ime_event_set_candidate_table_page_down_cb(ime_candidate_table_page_down_cb callback_func, void *user_data)
2551 ime_error_e retVal = IME_ERROR_NONE;
2553 if (!callback_func) {
2554 LOGW("IME_ERROR_INVALID_PARAMETER");
2555 return IME_ERROR_INVALID_PARAMETER;
2558 retVal = _check_privilege();
2559 if (retVal != IME_ERROR_NONE) return retVal;
2561 g_event_callback.candidate_table_page_down = callback_func;
2562 g_event_callback.candidate_table_page_down_user_data = user_data;
2564 return IME_ERROR_NONE;
2567 EXPORT_API int ime_event_set_candidate_table_page_size_chaned_cb(ime_candidate_table_page_size_chaned_cb callback_func, void *user_data)
2570 ime_error_e retVal = IME_ERROR_NONE;
2572 if (!callback_func) {
2573 LOGW("IME_ERROR_INVALID_PARAMETER");
2574 return IME_ERROR_INVALID_PARAMETER;
2577 retVal = _check_privilege();
2578 if (retVal != IME_ERROR_NONE) return retVal;
2580 g_event_callback.candidate_table_page_size_chaned = callback_func;
2581 g_event_callback.candidate_table_page_size_chaned_user_data = user_data;
2583 return IME_ERROR_NONE;
2586 EXPORT_API int ime_event_set_candidate_item_layout_set_cb(ime_candidate_item_layout_set_cb callback_func, void *user_data)
2589 ime_error_e retVal = IME_ERROR_NONE;
2591 if (!callback_func) {
2592 LOGW("IME_ERROR_INVALID_PARAMETER");
2593 return IME_ERROR_INVALID_PARAMETER;
2596 retVal = _check_privilege();
2597 if (retVal != IME_ERROR_NONE) return retVal;
2599 g_event_callback.candidate_item_layout_set = callback_func;
2600 g_event_callback.candidate_item_layout_set_user_data = user_data;
2602 return IME_ERROR_NONE;
2605 EXPORT_API int ime_event_set_displayed_candidate_number_chaned_cb(ime_displayed_candidate_number_chaned_cb callback_func, void *user_data)
2608 ime_error_e retVal = IME_ERROR_NONE;
2610 if (!callback_func) {
2611 LOGW("IME_ERROR_INVALID_PARAMETER");
2612 return IME_ERROR_INVALID_PARAMETER;
2615 retVal = _check_privilege();
2616 if (retVal != IME_ERROR_NONE) return retVal;
2618 g_event_callback.displayed_candidate_number_chaned = callback_func;
2619 g_event_callback.displayed_candidate_number_chaned_user_data = user_data;
2621 return IME_ERROR_NONE;
2624 EXPORT_API int ime_event_set_candidate_item_long_pressed_cb(ime_candidate_item_long_pressed_cb callback_func, void *user_data)
2627 ime_error_e retVal = IME_ERROR_NONE;
2629 if (!callback_func) {
2630 LOGW("IME_ERROR_INVALID_PARAMETER");
2631 return IME_ERROR_INVALID_PARAMETER;
2634 retVal = _check_privilege();
2635 if (retVal != IME_ERROR_NONE) return retVal;
2637 g_event_callback.candidate_item_long_pressed = callback_func;
2638 g_event_callback.candidate_item_long_pressed_user_data = user_data;
2640 return IME_ERROR_NONE;
2643 EXPORT_API int ime_show_aux_string(void)
2645 ime_error_e retVal = IME_ERROR_NONE;
2647 retVal = _check_privilege();
2648 if (retVal != IME_ERROR_NONE) return retVal;
2651 LOGW("IME_ERROR_NOT_RUNNING");
2652 return IME_ERROR_NOT_RUNNING;
2655 g_core.show_aux_string();
2657 return IME_ERROR_NONE;
2660 EXPORT_API int ime_hide_aux_string(void)
2662 ime_error_e retVal = IME_ERROR_NONE;
2664 retVal = _check_privilege();
2665 if (retVal != IME_ERROR_NONE) return retVal;
2668 LOGW("IME_ERROR_NOT_RUNNING");
2669 return IME_ERROR_NOT_RUNNING;
2672 g_core.hide_aux_string();
2674 return IME_ERROR_NONE;
2677 EXPORT_API int ime_show_lookup_table(void)
2679 ime_error_e retVal = IME_ERROR_NONE;
2681 retVal = _check_privilege();
2682 if (retVal != IME_ERROR_NONE) return retVal;
2685 LOGW("IME_ERROR_NOT_RUNNING");
2686 return IME_ERROR_NOT_RUNNING;
2689 g_core.show_candidate_string();
2691 return IME_ERROR_NONE;
2694 EXPORT_API int ime_hide_lookup_table(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.hide_candidate_string();
2708 return IME_ERROR_NONE;
2711 EXPORT_API int ime_update_preedit_caret(int caret)
2713 ime_error_e retVal = IME_ERROR_NONE;
2716 LOGW("IME_ERROR_INVALID_PARAMETER");
2717 return IME_ERROR_INVALID_PARAMETER;
2721 LOGW("IME_ERROR_NOT_RUNNING");
2722 return IME_ERROR_NOT_RUNNING;
2725 retVal = _check_privilege();
2726 if (retVal != IME_ERROR_NONE) return retVal;
2728 g_core.update_preedit_caret(caret);
2730 return IME_ERROR_NONE;
2733 EXPORT_API int ime_update_preedit_string_with_commit(const char *preedit, const char *commit, scim::AttributeList &attrs, int caret)
2735 ime_error_e retVal = IME_ERROR_NONE;
2737 if (!preedit && !commit) {
2738 LOGW("IME_ERROR_INVALID_PARAMETER");
2739 return IME_ERROR_INVALID_PARAMETER;
2743 LOGW("IME_ERROR_NOT_RUNNING");
2744 return IME_ERROR_NOT_RUNNING;
2747 retVal = _check_privilege();
2748 if (retVal != IME_ERROR_NONE) return retVal;
2750 g_core.update_preedit_string_with_commit(preedit, commit, attrs, caret);
2752 return IME_ERROR_NONE;
2755 EXPORT_API int ime_update_aux_string(const char *str)
2757 ime_error_e retVal = IME_ERROR_NONE;
2760 LOGW("IME_ERROR_INVALID_PARAMETER");
2761 return IME_ERROR_INVALID_PARAMETER;
2765 LOGW("IME_ERROR_NOT_RUNNING");
2766 return IME_ERROR_NOT_RUNNING;
2769 retVal = _check_privilege();
2770 if (retVal != IME_ERROR_NONE) return retVal;
2772 g_core.update_aux_string(str);
2774 return IME_ERROR_NONE;
2777 EXPORT_API int ime_recapture_string(int offset, int len, const char *preedit, const char *commit, scim::AttributeList &attrs)
2779 ime_error_e retVal = IME_ERROR_NONE;
2782 LOGW("IME_ERROR_INVALID_PARAMETER");
2783 return IME_ERROR_INVALID_PARAMETER;
2787 LOGW("IME_ERROR_NOT_RUNNING");
2788 return IME_ERROR_NOT_RUNNING;
2791 retVal = _check_privilege();
2792 if (retVal != IME_ERROR_NONE) return retVal;
2794 g_core.recapture_string(offset, len, preedit, commit, attrs);
2796 return IME_ERROR_NONE;
2799 EXPORT_API int ime_update_lookup_table(scim::LookupTable &table)
2801 ime_error_e retVal = IME_ERROR_NONE;
2804 LOGW("IME_ERROR_NOT_RUNNING");
2805 return IME_ERROR_NOT_RUNNING;
2808 retVal = _check_privilege();
2809 if (retVal != IME_ERROR_NONE) return retVal;
2811 g_core.update_lookup_table(table);
2813 return IME_ERROR_NONE;
2816 EXPORT_API int ime_register_properties(scim::PropertyList &properties)
2818 ime_error_e retVal = IME_ERROR_NONE;
2821 LOGW("IME_ERROR_NOT_RUNNING");
2822 return IME_ERROR_NOT_RUNNING;
2825 retVal = _check_privilege();
2826 if (retVal != IME_ERROR_NONE) return retVal;
2828 g_core.register_properties(properties);
2830 return IME_ERROR_NONE;
2833 EXPORT_API int ime_update_property(scim::Property &property)
2835 ime_error_e retVal = IME_ERROR_NONE;
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.update_property(property);
2847 return IME_ERROR_NONE;
2850 EXPORT_API int ime_expand_candidate(void)
2852 ime_error_e retVal = IME_ERROR_NONE;
2854 retVal = _check_privilege();
2855 if (retVal != IME_ERROR_NONE) return retVal;
2858 LOGW("IME_ERROR_NOT_RUNNING");
2859 return IME_ERROR_NOT_RUNNING;
2862 g_core.expand_candidate();
2864 return IME_ERROR_NONE;
2867 EXPORT_API int ime_contract_candidate(void)
2869 ime_error_e retVal = IME_ERROR_NONE;
2871 retVal = _check_privilege();
2872 if (retVal != IME_ERROR_NONE) return retVal;
2875 LOGW("IME_ERROR_NOT_RUNNING");
2876 return IME_ERROR_NOT_RUNNING;
2879 g_core.contract_candidate();
2881 return IME_ERROR_NONE;
2884 EXPORT_API int ime_set_candidate_style(scim::ISF_CANDIDATE_PORTRAIT_LINE_T portrait_line, scim::ISF_CANDIDATE_MODE_T mode)
2886 ime_error_e retVal = IME_ERROR_NONE;
2888 if (portrait_line < 0 || mode < 0) {
2889 LOGW("IME_ERROR_INVALID_PARAMETER");
2890 return IME_ERROR_INVALID_PARAMETER;
2894 LOGW("IME_ERROR_NOT_RUNNING");
2895 return IME_ERROR_NOT_RUNNING;
2898 retVal = _check_privilege();
2899 if (retVal != IME_ERROR_NONE) return retVal;
2901 g_core.set_candidate_style(portrait_line, mode);
2903 return IME_ERROR_NONE;
2907 EXPORT_API int ime_update_input_panel_event(ime_event_type_e type, unsigned int value)
2909 ime_error_e retVal = IME_ERROR_NONE;
2911 if (type < IME_EVENT_TYPE_LANGUAGE || type > IME_EVENT_TYPE_GEOMETRY) {
2912 LOGW("IME_ERROR_INVALID_PARAMETER");
2913 return IME_ERROR_INVALID_PARAMETER;
2917 LOGW("IME_ERROR_NOT_RUNNING");
2918 return IME_ERROR_NOT_RUNNING;
2922 retVal = _check_privilege();
2923 if (retVal != IME_ERROR_NONE) return retVal;
2925 g_core.update_input_context((sclu32)type, value);
2927 return IME_ERROR_NONE;
2931 EXPORT_API int ime_set_candidate_visibility_state(bool visible)
2933 ime_error_e retVal = IME_ERROR_NONE;
2936 LOGW("IME_ERROR_NOT_RUNNING");
2937 return IME_ERROR_NOT_RUNNING;
2941 retVal = _check_privilege();
2942 if (retVal != IME_ERROR_NONE) return retVal;
2945 g_core.show_candidate_string();
2947 g_core.hide_candidate_string();
2949 return IME_ERROR_NONE;