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 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);
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 serial)
554 if (g_event_callback.process_key_event_with_imengine) {
555 g_event_callback.process_key_event_with_imengine(key, serial, g_event_callback.process_key_event_with_imengine_user_data);
559 void CCoreEventCallback::on_set_autocapital_type(sclu32 type)
561 if (g_event_callback.autocapital_type_set) {
562 g_event_callback.autocapital_type_set(type, g_event_callback.autocapital_type_set_user_data);
566 void CCoreEventCallback::on_set_prediction_allow(sclu32 prediction_allow)
568 if (g_event_callback.prediction_allow_set) {
569 g_event_callback.prediction_allow_set(prediction_allow, g_event_callback.prediction_allow_set_user_data);
573 void CCoreEventCallback::on_trigger_property(const sclchar *property)
575 if (g_event_callback.trigger_property_set) {
576 g_event_callback.trigger_property_set(property, g_event_callback.trigger_property_set_user_data);
580 void CCoreEventCallback::on_candidate_more_window_show(sclint ic, const sclchar *uuid)
582 if (g_event_callback.candidate_more_window_show) {
583 g_event_callback.candidate_more_window_show(g_event_callback.candidate_more_window_show_user_data);
587 void CCoreEventCallback::on_candidate_more_window_hide(sclint ic, const sclchar *uuid)
589 if (g_event_callback.candidate_more_window_hide) {
590 g_event_callback.candidate_more_window_hide(g_event_callback.candidate_more_window_hide_user_data);
594 void CCoreEventCallback::on_select_aux(sclint ic, const sclchar *uuid, sclint index)
596 if (g_event_callback.aux_select) {
597 g_event_callback.aux_select((uint32_t)index, g_event_callback.aux_select_user_data);
601 void CCoreEventCallback::on_select_candidate(sclint ic, const sclchar *uuid, sclint index)
603 if (g_event_callback.candidate_select) {
604 g_event_callback.candidate_select((uint32_t)index, g_event_callback.candidate_select_user_data);
608 void CCoreEventCallback::on_candidate_table_page_up(sclint ic, const sclchar *uuid)
610 if (g_event_callback.candidate_table_page_up) {
611 g_event_callback.candidate_table_page_up(g_event_callback.candidate_table_page_up_user_data);
615 void CCoreEventCallback::on_candidate_table_page_down(sclint ic, const sclchar *uuid)
617 if (g_event_callback.candidate_table_page_down) {
618 g_event_callback.candidate_table_page_down(g_event_callback.candidate_table_page_down_user_data);
622 void CCoreEventCallback::on_update_candidate_table_page_size(sclint ic, const sclchar *uuid, sclint page_size)
624 if (g_event_callback.candidate_table_page_size_chaned) {
625 g_event_callback.candidate_table_page_size_chaned((uint32_t)page_size, g_event_callback.candidate_table_page_size_chaned_user_data);
629 void CCoreEventCallback::on_update_candidate_item_layout(const std::vector<sclu32> item)
631 if (g_event_callback.candidate_item_layout_set) {
632 g_event_callback.candidate_item_layout_set(item, g_event_callback.candidate_item_layout_set_user_data);
636 void CCoreEventCallback::on_update_displayed_candidate_number(sclu32 size)
638 if (g_event_callback.displayed_candidate_number_chaned) {
639 g_event_callback.displayed_candidate_number_chaned(size, g_event_callback.displayed_candidate_number_chaned_user_data);
643 void CCoreEventCallback::on_longpress_candidate(sclu32 index)
645 if (g_event_callback.candidate_item_long_pressed) {
646 g_event_callback.candidate_item_long_pressed(index, g_event_callback.candidate_item_long_pressed_user_data);
650 void ime_privilege_cache_init()
652 g_permission_allowed = false;
653 g_checked_privilege = false;
657 ime_error_e _check_privilege()
660 ime_error_e ret = IME_ERROR_NONE;
662 if (g_checked_privilege) {
663 return g_permission_allowed ? IME_ERROR_NONE : IME_ERROR_PERMISSION_DENIED;
666 if (inputmethod_cynara_initialize() == false) {
668 g_permission_allowed = false;
669 g_checked_privilege = true;
670 LOGE("inputmethod_cynara_initialize () == false");
672 return IME_ERROR_PERMISSION_DENIED;
675 snprintf(uid, 16, "%d", getuid());
676 if (check_privilege(uid, IME_PRIVILEGE) == false) {
677 LOGE("check_privilege(uid, IME_PRIVILEGE) == false. uid : %s", uid); //LCOV_EXCL_LINE
678 ret = IME_ERROR_PERMISSION_DENIED;
681 g_permission_allowed = (ret == IME_ERROR_NONE);
682 g_checked_privilege = true;
684 inputmethod_cynara_finish();
690 bool g_from_dotnet = false;
691 EXPORT_API int ime_set_dotnet_flag(bool set)
693 ime_error_e retVal = IME_ERROR_NONE;
695 retVal = _check_privilege();
696 if (retVal != IME_ERROR_NONE) return retVal;
704 EXPORT_API int ime_run(ime_callback_s *basic_cb, void *user_data)
706 ime_error_e retVal = IME_ERROR_NONE;
710 LOGE("inputmethod main loop is already running.");
711 return IME_ERROR_OPERATION_FAILED;
716 LOGE("basic callbacks pointer is null.");
717 return IME_ERROR_INVALID_PARAMETER;
720 retVal = _check_privilege();
721 if (retVal != IME_ERROR_NONE) return retVal;
723 g_basic_callback = *basic_cb;
725 if (!g_basic_callback.create || !g_basic_callback.terminate ||
726 !g_basic_callback.show || !g_basic_callback.hide) {
727 LOGE("mandatory callback functions are not set");
728 memset(&g_basic_callback, 0, sizeof(ime_callback_s));
729 memset(&g_event_callback, 0, sizeof(ime_event_callback_s));
730 return IME_ERROR_NO_CALLBACK_FUNCTION;
734 g_user_data = user_data;
738 LOGD("ime_run is called from dotnet");
739 return IME_ERROR_NONE;
745 LOGW("exception is thrown from g_core.run()\n");
748 memset(&g_basic_callback, 0, sizeof(ime_callback_s));
749 memset(&g_event_callback, 0, sizeof(ime_event_callback_s));
753 return IME_ERROR_NONE;
757 EXPORT_API int ime_event_set_focus_in_cb(ime_focus_in_cb callback_func, void *user_data)
759 ime_error_e retVal = IME_ERROR_NONE;
761 if (!callback_func) {
762 LOGW("IME_ERROR_INVALID_PARAMETER");
763 return IME_ERROR_INVALID_PARAMETER;
766 retVal = _check_privilege();
767 if (retVal != IME_ERROR_NONE) return retVal;
769 g_event_callback.focus_in = callback_func;
770 g_event_callback.focus_in_user_data = user_data;
772 return IME_ERROR_NONE;
775 EXPORT_API int ime_event_set_focus_out_cb(ime_focus_out_cb callback_func, void *user_data)
777 ime_error_e retVal = IME_ERROR_NONE;
779 if (!callback_func) {
780 LOGW("IME_ERROR_INVALID_PARAMETER");
781 return IME_ERROR_INVALID_PARAMETER;
784 retVal = _check_privilege();
785 if (retVal != IME_ERROR_NONE) return retVal;
787 g_event_callback.focus_out = callback_func;
788 g_event_callback.focus_out_user_data = user_data;
790 return IME_ERROR_NONE;
793 EXPORT_API int ime_event_set_surrounding_text_updated_cb(ime_surrounding_text_updated_cb callback_func, void *user_data)
795 ime_error_e retVal = IME_ERROR_NONE;
797 if (!callback_func) {
798 LOGW("IME_ERROR_INVALID_PARAMETER");
799 return IME_ERROR_INVALID_PARAMETER;
802 retVal = _check_privilege();
803 if (retVal != IME_ERROR_NONE) return retVal;
805 g_event_callback.surrounding_text_updated = callback_func;
806 g_event_callback.surrounding_text_updated_user_data = user_data;
808 return IME_ERROR_NONE;
811 EXPORT_API int ime_event_set_input_context_reset_cb(ime_input_context_reset_cb callback_func, void *user_data)
813 ime_error_e retVal = IME_ERROR_NONE;
815 if (!callback_func) {
816 LOGW("IME_ERROR_INVALID_PARAMETER");
817 return IME_ERROR_INVALID_PARAMETER;
820 retVal = _check_privilege();
821 if (retVal != IME_ERROR_NONE) return retVal;
823 g_event_callback.input_context_reset = callback_func;
824 g_event_callback.input_context_reset_user_data = user_data;
826 return IME_ERROR_NONE;
829 EXPORT_API int ime_event_set_cursor_position_updated_cb(ime_cursor_position_updated_cb callback_func, void *user_data)
831 ime_error_e retVal = IME_ERROR_NONE;
833 if (!callback_func) {
834 LOGW("IME_ERROR_INVALID_PARAMETER");
835 return IME_ERROR_INVALID_PARAMETER;
838 retVal = _check_privilege();
839 if (retVal != IME_ERROR_NONE) return retVal;
841 g_event_callback.cursor_position_updated = callback_func;
842 g_event_callback.cursor_position_updated_user_data = user_data;
844 return IME_ERROR_NONE;
847 EXPORT_API int ime_event_set_language_requested_cb(ime_language_requested_cb callback_func, void *user_data)
849 ime_error_e retVal = IME_ERROR_NONE;
851 if (!callback_func) {
852 LOGW("IME_ERROR_INVALID_PARAMETER");
853 return IME_ERROR_INVALID_PARAMETER;
856 retVal = _check_privilege();
857 if (retVal != IME_ERROR_NONE) return retVal;
859 g_event_callback.language_requested = callback_func;
860 g_event_callback.language_requested_user_data = user_data;
862 return IME_ERROR_NONE;
865 EXPORT_API int ime_event_set_language_set_cb(ime_language_set_cb callback_func, void *user_data)
867 ime_error_e retVal = IME_ERROR_NONE;
869 if (!callback_func) {
870 LOGW("IME_ERROR_INVALID_PARAMETER");
871 return IME_ERROR_INVALID_PARAMETER;
874 retVal = _check_privilege();
875 if (retVal != IME_ERROR_NONE) return retVal;
877 g_event_callback.language_set = callback_func;
878 g_event_callback.language_set_user_data = user_data;
880 return IME_ERROR_NONE;
883 EXPORT_API int ime_event_set_imdata_set_cb(ime_imdata_set_cb callback_func, void *user_data)
885 ime_error_e retVal = IME_ERROR_NONE;
887 if (!callback_func) {
888 LOGW("IME_ERROR_INVALID_PARAMETER");
889 return IME_ERROR_INVALID_PARAMETER;
892 retVal = _check_privilege();
893 if (retVal != IME_ERROR_NONE) return retVal;
895 g_event_callback.imdata_set = callback_func;
896 g_event_callback.imdata_set_user_data = user_data;
898 return IME_ERROR_NONE;
901 EXPORT_API int ime_event_set_imdata_requested_cb(ime_imdata_requested_cb callback_func, void *user_data)
903 ime_error_e retVal = IME_ERROR_NONE;
905 if (!callback_func) {
906 LOGW("IME_ERROR_INVALID_PARAMETER");
907 return IME_ERROR_INVALID_PARAMETER;
910 retVal = _check_privilege();
911 if (retVal != IME_ERROR_NONE) return retVal;
913 g_event_callback.imdata_requested = callback_func;
914 g_event_callback.imdata_requested_user_data = user_data;
916 return IME_ERROR_NONE;
919 EXPORT_API int ime_event_set_layout_set_cb(ime_layout_set_cb callback_func, void *user_data)
921 ime_error_e retVal = IME_ERROR_NONE;
923 if (!callback_func) {
924 LOGW("IME_ERROR_INVALID_PARAMETER");
925 return IME_ERROR_INVALID_PARAMETER;
928 retVal = _check_privilege();
929 if (retVal != IME_ERROR_NONE) return retVal;
931 g_event_callback.layout_set = callback_func;
932 g_event_callback.layout_set_user_data = user_data;
934 return IME_ERROR_NONE;
937 EXPORT_API int ime_event_set_return_key_type_set_cb(ime_return_key_type_set_cb callback_func, void *user_data)
939 ime_error_e retVal = IME_ERROR_NONE;
941 if (!callback_func) {
942 LOGW("IME_ERROR_INVALID_PARAMETER");
943 return IME_ERROR_INVALID_PARAMETER;
946 retVal = _check_privilege();
947 if (retVal != IME_ERROR_NONE) return retVal;
949 g_event_callback.return_key_type_set = callback_func;
950 g_event_callback.return_key_type_set_user_data = user_data;
952 return IME_ERROR_NONE;
955 EXPORT_API int ime_event_set_return_key_state_set_cb(ime_return_key_state_set_cb callback_func, void *user_data)
957 ime_error_e retVal = IME_ERROR_NONE;
959 if (!callback_func) {
960 LOGW("IME_ERROR_INVALID_PARAMETER");
961 return IME_ERROR_INVALID_PARAMETER;
964 retVal = _check_privilege();
965 if (retVal != IME_ERROR_NONE) return retVal;
967 g_event_callback.return_key_state_set = callback_func;
968 g_event_callback.return_key_state_set_user_data = user_data;
970 return IME_ERROR_NONE;
973 EXPORT_API int ime_event_set_geometry_requested_cb(ime_geometry_requested_cb callback_func, void *user_data)
975 ime_error_e retVal = IME_ERROR_NONE;
977 if (!callback_func) {
978 LOGW("IME_ERROR_INVALID_PARAMETER");
979 return IME_ERROR_INVALID_PARAMETER;
982 retVal = _check_privilege();
983 if (retVal != IME_ERROR_NONE) return retVal;
985 g_event_callback.geometry_requested = callback_func;
986 g_event_callback.geometry_requested_user_data = user_data;
988 return IME_ERROR_NONE;
991 EXPORT_API int ime_event_set_process_key_event_cb(ime_process_key_event_cb callback_func, void *user_data)
993 ime_error_e retVal = IME_ERROR_NONE;
995 if (!callback_func) {
996 LOGW("IME_ERROR_INVALID_PARAMETER");
997 return IME_ERROR_INVALID_PARAMETER;
1000 retVal = _check_privilege();
1001 if (retVal != IME_ERROR_NONE) return retVal;
1003 g_event_callback.process_key_event = callback_func;
1004 g_event_callback.process_key_event_user_data = user_data;
1006 return IME_ERROR_NONE;
1009 EXPORT_API int ime_event_set_process_key_event_with_keycode_cb(ime_process_key_event_with_keycode_cb callback_func, void *user_data)
1011 ime_error_e retVal = IME_ERROR_NONE;
1013 if (!callback_func) {
1014 LOGW("IME_ERROR_INVALID_PARAMETER");
1015 return IME_ERROR_INVALID_PARAMETER;
1018 retVal = _check_privilege();
1019 if (retVal != IME_ERROR_NONE) return retVal;
1021 g_event_callback.process_key_event_with_keycode = callback_func;
1022 g_event_callback.process_key_event_with_keycode_user_data = user_data;
1024 return IME_ERROR_NONE;
1027 EXPORT_API int ime_event_set_display_language_changed_cb(ime_display_language_changed_cb callback_func, void *user_data)
1029 ime_error_e retVal = IME_ERROR_NONE;
1031 if (!callback_func) {
1032 LOGW("IME_ERROR_INVALID_PARAMETER");
1033 return IME_ERROR_INVALID_PARAMETER;
1036 retVal = _check_privilege();
1037 if (retVal != IME_ERROR_NONE) return retVal;
1039 g_event_callback.display_language_changed = callback_func;
1040 g_event_callback.display_language_changed_user_data = user_data;
1042 return IME_ERROR_NONE;
1045 EXPORT_API int ime_event_set_rotation_degree_changed_cb(ime_rotation_degree_changed_cb callback_func, void *user_data)
1047 ime_error_e retVal = IME_ERROR_NONE;
1049 if (!callback_func) {
1050 LOGW("IME_ERROR_INVALID_PARAMETER");
1051 return IME_ERROR_INVALID_PARAMETER;
1054 retVal = _check_privilege();
1055 if (retVal != IME_ERROR_NONE) return retVal;
1057 g_event_callback.rotation_degree_changed = callback_func;
1058 g_event_callback.rotation_degree_changed_user_data = user_data;
1060 return IME_ERROR_NONE;
1063 EXPORT_API int ime_event_set_accessibility_state_changed_cb(ime_accessibility_state_changed_cb callback_func, void *user_data)
1065 ime_error_e retVal = IME_ERROR_NONE;
1067 if (!callback_func) {
1068 LOGW("IME_ERROR_INVALID_PARAMETER");
1069 return IME_ERROR_INVALID_PARAMETER;
1072 retVal = _check_privilege();
1073 if (retVal != IME_ERROR_NONE) return retVal;
1075 g_event_callback.accessibility_state_changed = callback_func;
1076 g_event_callback.accessibility_state_changed_user_data = user_data;
1078 return IME_ERROR_NONE;
1081 EXPORT_API int ime_event_set_option_window_created_cb(ime_option_window_created_cb callback_func, void *user_data)
1083 ime_error_e retVal = IME_ERROR_NONE;
1085 if (!callback_func) {
1086 LOGW("IME_ERROR_INVALID_PARAMETER");
1087 return IME_ERROR_INVALID_PARAMETER;
1090 retVal = _check_privilege();
1091 if (retVal != IME_ERROR_NONE) return retVal;
1093 g_event_callback.option_window_created = callback_func;
1094 g_event_callback.option_window_created_user_data = user_data;
1096 return IME_ERROR_NONE;
1099 EXPORT_API int ime_event_set_option_window_destroyed_cb(ime_option_window_destroyed_cb callback_func, void *user_data)
1101 ime_error_e retVal = IME_ERROR_NONE;
1103 if (!callback_func) {
1104 LOGW("IME_ERROR_INVALID_PARAMETER");
1105 return IME_ERROR_INVALID_PARAMETER;
1108 retVal = _check_privilege();
1109 if (retVal != IME_ERROR_NONE) return retVal;
1111 g_event_callback.option_window_destroyed = callback_func;
1112 g_event_callback.option_window_destroyed_user_data = user_data;
1114 return IME_ERROR_NONE;
1118 EXPORT_API int ime_event_set_caps_mode_changed_cb(ime_caps_mode_changed_cb callback_func, void *user_data)
1120 ime_error_e retVal = IME_ERROR_NONE;
1122 if (!callback_func) {
1123 LOGW("IME_ERROR_INVALID_PARAMETER");
1124 return IME_ERROR_INVALID_PARAMETER;
1127 retVal = _check_privilege();
1128 if (retVal != IME_ERROR_NONE) return retVal;
1130 g_event_callback.caps_mode_changed = callback_func;
1131 g_event_callback.caps_mode_changed_user_data = user_data;
1133 return IME_ERROR_NONE;
1136 EXPORT_API int ime_event_set_candidate_show_cb(ime_candidate_show_cb callback_func, void *user_data)
1138 ime_error_e retVal = IME_ERROR_NONE;
1140 if (!callback_func) {
1141 LOGW("IME_ERROR_INVALID_PARAMETER");
1142 return IME_ERROR_INVALID_PARAMETER;
1145 retVal = _check_privilege();
1146 if (retVal != IME_ERROR_NONE) return retVal;
1148 g_event_callback.candidate_show = callback_func;
1149 g_event_callback.candidate_show_user_data = user_data;
1151 return IME_ERROR_NONE;
1154 EXPORT_API int ime_event_set_candidate_hide_cb(ime_candidate_hide_cb callback_func, void *user_data)
1156 ime_error_e retVal = IME_ERROR_NONE;
1158 if (!callback_func) {
1159 LOGW("IME_ERROR_INVALID_PARAMETER");
1160 return IME_ERROR_INVALID_PARAMETER;
1163 retVal = _check_privilege();
1164 if (retVal != IME_ERROR_NONE) return retVal;
1166 g_event_callback.candidate_hide = callback_func;
1167 g_event_callback.candidate_hide_user_data = user_data;
1169 return IME_ERROR_NONE;
1172 EXPORT_API int ime_event_set_lookup_table_changed_cb(ime_lookup_table_changed_cb callback_func, void *user_data)
1174 ime_error_e retVal = IME_ERROR_NONE;
1176 if (!callback_func) {
1177 LOGW("IME_ERROR_INVALID_PARAMETER");
1178 return IME_ERROR_INVALID_PARAMETER;
1181 retVal = _check_privilege();
1182 if (retVal != IME_ERROR_NONE) return retVal;
1184 g_event_callback.lookup_table_changed = callback_func;
1185 g_event_callback.lookup_table_changed_user_data = user_data;
1187 return IME_ERROR_NONE;
1191 EXPORT_API int ime_send_key_event(ime_key_code_e keycode, ime_key_mask_e keymask, bool forward_key)
1193 ime_error_e retVal = IME_ERROR_NONE;
1196 LOGW("IME_ERROR_NOT_RUNNING");
1197 return IME_ERROR_NOT_RUNNING;
1201 retVal = _check_privilege();
1202 if (retVal != IME_ERROR_NONE) return retVal;
1205 g_core.forward_key_event(-1, NULL, (sclu32)keycode, (sclu16)keymask);
1207 g_core.send_key_event(-1, NULL, (sclu32)keycode, (sclu16)keymask);
1210 return IME_ERROR_NONE;
1213 EXPORT_API int ime_commit_string(const char *str)
1215 ime_error_e retVal = IME_ERROR_NONE;
1218 LOGW("IME_ERROR_INVALID_PARAMETER");
1219 return IME_ERROR_INVALID_PARAMETER;
1223 LOGW("IME_ERROR_NOT_RUNNING");
1224 return IME_ERROR_NOT_RUNNING;
1228 retVal = _check_privilege();
1229 if (retVal != IME_ERROR_NONE) return retVal;
1231 SECURE_LOGI("commit string : %s", str);
1232 g_core.commit_string(-1, NULL, str);
1234 return IME_ERROR_NONE;
1238 EXPORT_API int ime_show_preedit_string(void)
1240 ime_error_e retVal = IME_ERROR_NONE;
1243 LOGW("IME_ERROR_NOT_RUNNING");
1244 return IME_ERROR_NOT_RUNNING;
1248 retVal = _check_privilege();
1249 if (retVal != IME_ERROR_NONE) return retVal;
1251 g_core.show_preedit_string(-1, NULL);
1253 return IME_ERROR_NONE;
1257 EXPORT_API int ime_hide_preedit_string(void)
1259 ime_error_e retVal = IME_ERROR_NONE;
1262 LOGW("IME_ERROR_NOT_RUNNING");
1263 return IME_ERROR_NOT_RUNNING;
1267 retVal = _check_privilege();
1268 if (retVal != IME_ERROR_NONE) return retVal;
1270 g_core.hide_preedit_string(-1, NULL);
1272 return IME_ERROR_NONE;
1276 EXPORT_API int ime_update_preedit_string(const char *str, Eina_List *attrs)
1278 ime_error_e retVal = IME_ERROR_NONE;
1281 LOGW("IME_ERROR_INVALID_PARAMETER");
1282 return IME_ERROR_INVALID_PARAMETER;
1286 LOGW("IME_ERROR_NOT_RUNNING");
1287 return IME_ERROR_NOT_RUNNING;
1291 retVal = _check_privilege();
1292 if (retVal != IME_ERROR_NONE) return retVal;
1294 scim::AttributeList attrv;
1296 ime_preedit_attribute *attr = NULL;
1299 EINA_LIST_FREE(attrs, data) {
1300 attr = (ime_preedit_attribute *)data;
1302 attrv.push_back(scim::Attribute(attr->start, attr->length, (scim::AttributeType)attr->type, attr->value));
1308 SECURE_LOGI("preedit string : '%s'", str);
1309 g_core.update_preedit_string(-1, NULL, str, attrv);
1311 return IME_ERROR_NONE;
1315 EXPORT_API int ime_request_surrounding_text(int maxlen_before, int maxlen_after)
1317 ime_error_e retVal = IME_ERROR_NONE;
1319 if (!g_event_callback.surrounding_text_updated) {
1320 LOGW("IME_ERROR_NO_CALLBACK_FUNCTION");
1321 return IME_ERROR_NO_CALLBACK_FUNCTION;
1325 LOGW("IME_ERROR_NOT_RUNNING");
1326 return IME_ERROR_NOT_RUNNING;
1330 retVal = _check_privilege();
1331 if (retVal != IME_ERROR_NONE) return retVal;
1333 g_core.get_surrounding_text(NULL, maxlen_before, maxlen_after);
1335 return IME_ERROR_NONE;
1339 EXPORT_API int ime_delete_surrounding_text(int offset, int len)
1341 ime_error_e retVal = IME_ERROR_NONE;
1344 LOGW("IME_ERROR_INVALID_PARAMETER");
1345 return IME_ERROR_INVALID_PARAMETER;
1349 LOGW("IME_ERROR_NOT_RUNNING");
1350 return IME_ERROR_NOT_RUNNING;
1354 retVal = _check_privilege();
1355 if (retVal != IME_ERROR_NONE) return retVal;
1357 LOGI("offset: %d, len : %d", offset, len);
1358 g_core.delete_surrounding_text(offset, len);
1360 return IME_ERROR_NONE;
1364 EXPORT_API int ime_get_surrounding_text(int maxlen_before, int maxlen_after, char **text, int *cursor_pos)
1366 ime_error_e retVal = IME_ERROR_NONE;
1368 if (!text || !cursor_pos) {
1369 LOGW("IME_ERROR_INVALID_PARAMETER");
1370 return IME_ERROR_INVALID_PARAMETER;
1374 LOGW("IME_ERROR_NOT_RUNNING");
1375 return IME_ERROR_NOT_RUNNING;
1379 retVal = _check_privilege();
1380 if (retVal != IME_ERROR_NONE) return retVal;
1384 int ret = g_core.get_surrounding_text(maxlen_before, maxlen_after, text, cursor);
1386 LOGW("IME_ERROR_OUR_OF_MEMORY");
1387 return IME_ERROR_OUT_OF_MEMORY;
1391 *cursor_pos = cursor;
1393 return IME_ERROR_NONE;
1397 EXPORT_API int ime_set_selection(int start, int end)
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("start: %d, end : %d", start, end);
1416 g_core.set_selection(start, end);
1418 return IME_ERROR_NONE;
1422 EXPORT_API int ime_get_selected_text(char **text)
1424 ime_error_e retVal = IME_ERROR_NONE;
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;
1440 g_core.get_selection_text(text);
1442 return IME_ERROR_NONE;
1446 EXPORT_API Evas_Object* ime_get_main_window(void)
1448 ime_error_e retVal = IME_ERROR_NONE;
1450 Evas_Object *win = NULL;
1452 retVal = _check_privilege();
1453 if (retVal != IME_ERROR_NONE) {
1455 LOGE("_check_privilege returned %d.", retVal);
1456 set_last_result(retVal);
1462 set_last_result(IME_ERROR_NOT_RUNNING);
1463 LOGW("IME_ERROR_NOT_RUNNING");
1468 win = static_cast<Evas_Object*>(g_core.get_main_window());
1470 set_last_result(IME_ERROR_NONE);
1472 set_last_result(IME_ERROR_OPERATION_FAILED);
1473 LOGW("IME_ERROR_OPERATION_FAILED");
1480 EXPORT_API int ime_set_size(int portrait_width, int portrait_height, int landscape_width, int landscape_height)
1482 ime_error_e retVal = IME_ERROR_NONE;
1484 SclSize portrait_size, landscape_size;
1486 if (portrait_width < 1 || portrait_height < 1 || landscape_width < 1 || landscape_height < 1) {
1487 LOGW("IME_ERROR_INVALID_PARAMETER");
1488 return IME_ERROR_INVALID_PARAMETER;
1492 LOGW("IME_ERROR_NOT_RUNNING");
1493 return IME_ERROR_NOT_RUNNING;
1497 retVal = _check_privilege();
1498 if (retVal != IME_ERROR_NONE) return retVal;
1500 portrait_size.width = portrait_width;
1501 portrait_size.height = portrait_height;
1503 landscape_size.width = landscape_width;
1504 landscape_size.height = landscape_height;
1506 g_core.set_keyboard_size_hints(portrait_size, landscape_size);
1508 return IME_ERROR_NONE;
1512 EXPORT_API int ime_create_option_window(void)
1514 ime_error_e retVal = IME_ERROR_NONE;
1516 if (!g_event_callback.option_window_created || !g_event_callback.option_window_destroyed) {
1517 LOGW("ime_create_option_window_cb() and ime_destroy_option_window_cb() callback functions are not set.");
1518 return IME_ERROR_NO_CALLBACK_FUNCTION;
1522 LOGW("IME_ERROR_NOT_RUNNING");
1523 return IME_ERROR_NOT_RUNNING;
1527 retVal = _check_privilege();
1528 if (retVal != IME_ERROR_NONE) return retVal;
1530 if (g_core.create_option_window()) {
1531 return IME_ERROR_NONE;
1533 LOGW("IME_ERROR_OPERATION_FAILED");
1534 return IME_ERROR_OPERATION_FAILED;
1539 EXPORT_API int ime_destroy_option_window(Evas_Object *window)
1541 ime_error_e retVal = IME_ERROR_NONE;
1543 if (!g_event_callback.option_window_created || !g_event_callback.option_window_destroyed) {
1544 LOGW("ime_create_option_window_cb() and ime_destroy_option_window_cb() callback functions are not set.");
1545 return IME_ERROR_NO_CALLBACK_FUNCTION;
1549 LOGW("Window pointer is null.");
1550 return IME_ERROR_INVALID_PARAMETER;
1554 LOGW("IME_ERROR_NOT_RUNNING");
1555 return IME_ERROR_NOT_RUNNING;
1559 retVal = _check_privilege();
1560 if (retVal != IME_ERROR_NONE) return retVal;
1562 g_core.destroy_option_window(window);
1564 return IME_ERROR_NONE;
1569 EXPORT_API int ime_set_imengine(const char *engine_id)
1571 ime_error_e retVal = IME_ERROR_NONE;
1574 LOGW("IME_ERROR_INVALID_PARAMETER");
1575 return IME_ERROR_INVALID_PARAMETER;
1578 retVal = _check_privilege();
1579 if (retVal != IME_ERROR_NONE) return retVal;
1581 g_core.set_keyboard_ise_by_uuid(engine_id);
1583 return IME_ERROR_NONE;
1586 EXPORT_API int ime_flush_imengine(void)
1588 ime_error_e retVal = IME_ERROR_NONE;
1591 LOGW("IME_ERROR_NOT_RUNNING");
1592 return IME_ERROR_NOT_RUNNING;
1595 retVal = _check_privilege();
1596 if (retVal != IME_ERROR_NONE) return retVal;
1598 g_core.flush_keyboard_ise();
1600 return IME_ERROR_NONE;
1603 EXPORT_API int ime_send_imengine_event(int command, unsigned int value)
1605 ime_error_e retVal = IME_ERROR_NONE;
1608 LOGW("IME_ERROR_NOT_RUNNING");
1609 return IME_ERROR_NOT_RUNNING;
1612 retVal = _check_privilege();
1613 if (retVal != IME_ERROR_NONE) return retVal;
1615 g_core.send_imengine_event(-1, NULL, command, value);
1617 return IME_ERROR_NONE;
1620 EXPORT_API int ime_reset_imengine(void)
1622 ime_error_e retVal = IME_ERROR_NONE;
1625 LOGW("IME_ERROR_NOT_RUNNING");
1626 return IME_ERROR_NOT_RUNNING;
1629 retVal = _check_privilege();
1630 if (retVal != IME_ERROR_NONE) return retVal;
1632 g_core.reset_keyboard_ise();
1634 return IME_ERROR_NONE;
1637 EXPORT_API int ime_update_input_context(unsigned int type, unsigned int value)
1639 ime_error_e retVal = IME_ERROR_NONE;
1642 LOGW("IME_ERROR_NOT_RUNNING");
1643 return IME_ERROR_NOT_RUNNING;
1646 retVal = _check_privilege();
1647 if (retVal != IME_ERROR_NONE) return retVal;
1649 g_core.update_input_context(type, value);
1651 return IME_ERROR_NONE;
1655 EXPORT_API int ime_request_hide(void)
1657 ime_error_e retVal = IME_ERROR_NONE;
1660 LOGW("IME_ERROR_NOT_RUNNING");
1661 return IME_ERROR_NOT_RUNNING;
1665 retVal = _check_privilege();
1666 if (retVal != IME_ERROR_NONE) return retVal;
1668 g_core.request_ise_hide();
1670 return IME_ERROR_NONE;
1675 EXPORT_API int ime_initialize(void)
1677 ime_error_e retVal = IME_ERROR_NONE;
1679 retVal = _check_privilege();
1680 if (retVal != IME_ERROR_NONE) return retVal;
1688 EXPORT_API int ime_prepare(void)
1690 ime_error_e retVal = IME_ERROR_NONE;
1693 LOGE("inputmethod main loop is already running.");
1694 return IME_ERROR_OPERATION_FAILED;
1697 retVal = _check_privilege();
1698 if (retVal != IME_ERROR_NONE) return retVal;
1707 EXPORT_API int ime_finalize(void)
1709 ime_error_e retVal = IME_ERROR_NONE;
1711 retVal = _check_privilege();
1712 if (retVal != IME_ERROR_NONE) return retVal;
1716 memset(&g_basic_callback, 0, sizeof(ime_callback_s));
1717 memset(&g_event_callback, 0, sizeof(ime_event_callback_s));
1723 EXPORT_API int ime_select_candidate(unsigned int index)
1725 ime_error_e retVal = IME_ERROR_NONE;
1728 LOGW("IME_ERROR_NOT_RUNNING");
1729 return IME_ERROR_NOT_RUNNING;
1732 retVal = _check_privilege();
1733 if (retVal != IME_ERROR_NONE) return retVal;
1735 g_core.select_candidate(index);
1737 return IME_ERROR_NONE;
1741 EXPORT_API int ime_send_private_command(const char *command)
1743 ime_error_e retVal = IME_ERROR_NONE;
1746 LOGW("IME_ERROR_INVALID_PARAMETER");
1747 return IME_ERROR_INVALID_PARAMETER;
1751 LOGW("IME_ERROR_NOT_RUNNING");
1752 return IME_ERROR_NOT_RUNNING;
1756 retVal = _check_privilege();
1757 if (retVal != IME_ERROR_NONE) return retVal;
1759 g_core.send_private_command(command);
1761 return IME_ERROR_NONE;
1765 EXPORT_API int ime_commit_content(const char *content, const char *description, const char *mime_type)
1767 ime_error_e retVal = IME_ERROR_NONE;
1769 if (!content || !description || !mime_type) {
1770 LOGW("IME_ERROR_INVALID_PARAMETER");
1771 return IME_ERROR_INVALID_PARAMETER;
1774 retVal = _check_privilege();
1775 if (retVal != IME_ERROR_NONE) return retVal;
1778 LOGW("IME_ERROR_NOT_RUNNING");
1779 return IME_ERROR_NOT_RUNNING;
1783 LOGI("content : '%s', description : '%s', mime_type : '%s'", content, description, mime_type);
1784 g_core.commit_content(content, description, mime_type);
1786 return IME_ERROR_NONE;
1790 EXPORT_API int ime_context_get_layout(ime_context_h context, Ecore_IMF_Input_Panel_Layout *layout)
1792 ime_error_e retVal = IME_ERROR_NONE;
1794 if (!context || !layout) {
1795 LOGW("IME_ERROR_INVALID_PARAMETER");
1796 return IME_ERROR_INVALID_PARAMETER;
1799 retVal = _check_privilege();
1800 if (retVal != IME_ERROR_NONE) return retVal;
1803 LOGW("IME_ERROR_NOT_RUNNING");
1804 return IME_ERROR_NOT_RUNNING;
1808 *layout = context->layout;
1810 return IME_ERROR_NONE;
1814 EXPORT_API int ime_context_get_layout_variation(ime_context_h context, ime_layout_variation_e *layout_variation)
1816 ime_error_e retVal = IME_ERROR_NONE;
1818 if (!context || !layout_variation) {
1819 LOGW("IME_ERROR_INVALID_PARAMETER");
1820 return IME_ERROR_INVALID_PARAMETER;
1823 retVal = _check_privilege();
1824 if (retVal != IME_ERROR_NONE) return retVal;
1827 LOGW("IME_ERROR_NOT_RUNNING");
1828 return IME_ERROR_NOT_RUNNING;
1832 *layout_variation = static_cast<ime_layout_variation_e>(context->layout_variation);
1834 return IME_ERROR_NONE;
1838 EXPORT_API int ime_context_get_cursor_position(ime_context_h context, int *cursor_pos)
1840 ime_error_e retVal = IME_ERROR_NONE;
1842 if (!context || !cursor_pos) {
1843 LOGW("IME_ERROR_INVALID_PARAMETER");
1844 return IME_ERROR_INVALID_PARAMETER;
1847 retVal = _check_privilege();
1848 if (retVal != IME_ERROR_NONE) return retVal;
1851 LOGW("IME_ERROR_NOT_RUNNING");
1852 return IME_ERROR_NOT_RUNNING;
1856 *cursor_pos = context->cursor_pos;
1858 return IME_ERROR_NONE;
1862 EXPORT_API int ime_context_get_autocapital_type(ime_context_h context, Ecore_IMF_Autocapital_Type *autocapital_type)
1864 ime_error_e retVal = IME_ERROR_NONE;
1866 if (!context || !autocapital_type) {
1867 LOGW("IME_ERROR_INVALID_PARAMETER");
1868 return IME_ERROR_INVALID_PARAMETER;
1871 retVal = _check_privilege();
1872 if (retVal != IME_ERROR_NONE) return retVal;
1875 LOGW("IME_ERROR_NOT_RUNNING");
1876 return IME_ERROR_NOT_RUNNING;
1880 *autocapital_type = context->autocapital_type;
1882 return IME_ERROR_NONE;
1886 EXPORT_API int ime_context_get_return_key_type(ime_context_h context, Ecore_IMF_Input_Panel_Return_Key_Type *return_key_type)
1888 ime_error_e retVal = IME_ERROR_NONE;
1890 if (!context || !return_key_type) {
1891 LOGW("IME_ERROR_INVALID_PARAMETER");
1892 return IME_ERROR_INVALID_PARAMETER;
1895 retVal = _check_privilege();
1896 if (retVal != IME_ERROR_NONE) return retVal;
1899 LOGW("IME_ERROR_NOT_RUNNING");
1900 return IME_ERROR_NOT_RUNNING;
1904 *return_key_type = context->return_key_type;
1906 return IME_ERROR_NONE;
1910 EXPORT_API int ime_context_get_return_key_state(ime_context_h context, bool *return_key_state)
1912 ime_error_e retVal = IME_ERROR_NONE;
1914 if (!context || !return_key_state) {
1915 LOGW("IME_ERROR_INVALID_PARAMETER");
1916 return IME_ERROR_INVALID_PARAMETER;
1919 retVal = _check_privilege();
1920 if (retVal != IME_ERROR_NONE) return retVal;
1923 LOGW("IME_ERROR_NOT_RUNNING");
1924 return IME_ERROR_NOT_RUNNING;
1928 *return_key_state = static_cast<bool>(context->return_key_disabled);
1930 return IME_ERROR_NONE;
1934 EXPORT_API int ime_context_get_prediction_mode(ime_context_h context, bool *prediction_mode)
1936 ime_error_e retVal = IME_ERROR_NONE;
1938 if (!context || !prediction_mode) {
1939 LOGW("IME_ERROR_INVALID_PARAMETER");
1940 return IME_ERROR_INVALID_PARAMETER;
1943 retVal = _check_privilege();
1944 if (retVal != IME_ERROR_NONE) return retVal;
1947 LOGW("IME_ERROR_NOT_RUNNING");
1948 return IME_ERROR_NOT_RUNNING;
1952 *prediction_mode = static_cast<bool>(context->prediction_allow);
1954 return IME_ERROR_NONE;
1958 EXPORT_API int ime_context_get_password_mode(ime_context_h context, bool *password_mode)
1960 ime_error_e retVal = IME_ERROR_NONE;
1962 if (!context || !password_mode) {
1963 LOGW("IME_ERROR_INVALID_PARAMETER");
1964 return IME_ERROR_INVALID_PARAMETER;
1967 retVal = _check_privilege();
1968 if (retVal != IME_ERROR_NONE) return retVal;
1971 LOGW("IME_ERROR_NOT_RUNNING");
1972 return IME_ERROR_NOT_RUNNING;
1976 *password_mode = static_cast<bool>(context->password_mode);
1978 return IME_ERROR_NONE;
1982 EXPORT_API int ime_context_get_input_hint(ime_context_h context, Ecore_IMF_Input_Hints *input_hint)
1984 ime_error_e retVal = IME_ERROR_NONE;
1986 if (!context || !input_hint) {
1987 LOGW("IME_ERROR_INVALID_PARAMETER");
1988 return IME_ERROR_INVALID_PARAMETER;
1991 retVal = _check_privilege();
1992 if (retVal != IME_ERROR_NONE) return retVal;
1995 LOGW("IME_ERROR_NOT_RUNNING");
1996 return IME_ERROR_NOT_RUNNING;
2000 *input_hint = context->input_hint;
2002 return IME_ERROR_NONE;
2006 EXPORT_API int ime_context_get_bidi_direction(ime_context_h context, Ecore_IMF_BiDi_Direction *bidi)
2008 ime_error_e retVal = IME_ERROR_NONE;
2010 if (!context || !bidi) {
2011 LOGW("IME_ERROR_INVALID_PARAMETER");
2012 return IME_ERROR_INVALID_PARAMETER;
2015 retVal = _check_privilege();
2016 if (retVal != IME_ERROR_NONE) return retVal;
2019 LOGW("IME_ERROR_NOT_RUNNING");
2020 return IME_ERROR_NOT_RUNNING;
2024 *bidi = context->bidi_direction;
2026 return IME_ERROR_NONE;
2030 EXPORT_API int ime_context_get_language(ime_context_h context, Ecore_IMF_Input_Panel_Lang *language)
2032 ime_error_e retVal = IME_ERROR_NONE;
2034 if (!context || !language) {
2035 LOGW("IME_ERROR_INVALID_PARAMETER");
2036 return IME_ERROR_INVALID_PARAMETER;
2039 retVal = _check_privilege();
2040 if (retVal != IME_ERROR_NONE) return retVal;
2043 LOGW("IME_ERROR_NOT_RUNNING");
2044 return IME_ERROR_NOT_RUNNING;
2048 *language = context->language;
2050 return IME_ERROR_NONE;
2055 EXPORT_API int ime_context_get_caps_mode(ime_context_h context, bool *caps_mode)
2057 ime_error_e retVal = IME_ERROR_NONE;
2059 if (!context || !caps_mode) {
2060 LOGW("IME_ERROR_INVALID_PARAMETER");
2061 return IME_ERROR_INVALID_PARAMETER;
2064 retVal = _check_privilege();
2065 if (retVal != IME_ERROR_NONE) return retVal;
2068 LOGW("IME_ERROR_NOT_RUNNING");
2069 return IME_ERROR_NOT_RUNNING;
2072 *caps_mode = static_cast<bool>(context->caps_mode);
2074 return IME_ERROR_NONE;
2078 EXPORT_API int ime_device_info_get_name(ime_device_info_h dev_info, char **dev_name)
2080 ime_error_e retVal = IME_ERROR_NONE;
2082 if (!dev_info || !dev_name) {
2083 LOGW("IME_ERROR_INVALID_PARAMETER");
2084 return IME_ERROR_INVALID_PARAMETER;
2087 retVal = _check_privilege();
2088 if (retVal != IME_ERROR_NONE) return retVal;
2091 LOGW("IME_ERROR_NOT_RUNNING");
2092 return IME_ERROR_NOT_RUNNING;
2096 if (!dev_info->dev_name)
2097 *dev_name = strdup("");
2099 *dev_name = strdup(dev_info->dev_name);
2101 return IME_ERROR_NONE;
2105 EXPORT_API int ime_device_info_get_class(ime_device_info_h dev_info, Ecore_IMF_Device_Class *dev_class)
2107 ime_error_e retVal = IME_ERROR_NONE;
2109 if (!dev_info || !dev_class) {
2110 LOGW("IME_ERROR_INVALID_PARAMETER");
2111 return IME_ERROR_INVALID_PARAMETER;
2114 retVal = _check_privilege();
2115 if (retVal != IME_ERROR_NONE) return retVal;
2118 LOGW("IME_ERROR_NOT_RUNNING");
2119 return IME_ERROR_NOT_RUNNING;
2123 *dev_class = dev_info->dev_class;
2125 return IME_ERROR_NONE;
2129 EXPORT_API int ime_device_info_get_subclass(ime_device_info_h dev_info, Ecore_IMF_Device_Subclass *dev_subclass)
2131 ime_error_e retVal = IME_ERROR_NONE;
2133 if (!dev_info || !dev_subclass) {
2134 LOGW("IME_ERROR_INVALID_PARAMETER");
2135 return IME_ERROR_INVALID_PARAMETER;
2138 retVal = _check_privilege();
2139 if (retVal != IME_ERROR_NONE) return retVal;
2142 LOGW("IME_ERROR_NOT_RUNNING");
2143 return IME_ERROR_NOT_RUNNING;
2147 *dev_subclass = dev_info->dev_subclass;
2149 return IME_ERROR_NONE;
2154 EXPORT_API int ime_event_set_process_input_device_event_cb(ime_process_input_device_event_cb callback_func, void *user_data)
2156 ime_error_e retVal = IME_ERROR_NONE;
2158 if (!callback_func) {
2159 LOGW("IME_ERROR_INVALID_PARAMETER");
2160 return IME_ERROR_INVALID_PARAMETER;
2163 retVal = _check_privilege();
2164 if (retVal != IME_ERROR_NONE) return retVal;
2166 g_event_callback.process_input_device_event = callback_func;
2167 g_event_callback.process_input_device_event_user_data = user_data;
2169 return IME_ERROR_NONE;
2172 EXPORT_API int ime_event_unset_process_input_device_event_cb(void)
2174 ime_error_e retVal = IME_ERROR_NONE;
2176 retVal = _check_privilege();
2177 if (retVal != IME_ERROR_NONE) return retVal;
2179 g_event_callback.process_input_device_event = NULL;
2180 g_event_callback.process_input_device_event_user_data = NULL;
2182 return IME_ERROR_NONE;
2185 /* Functions for Rotary input device event */
2186 EXPORT_API int ime_input_device_rotary_get_direction(ime_input_device_event_h event_handle, ime_input_device_rotary_direction_e *direction)
2188 ime_error_e retVal = IME_ERROR_NONE;
2190 if (!event_handle || !direction) {
2191 LOGW("IME_ERROR_INVALID_PARAMETER");
2192 return IME_ERROR_INVALID_PARAMETER;
2195 ime_device_event_s *device_event = static_cast<ime_device_event_s*>(event_handle);
2196 if (device_event->device_type != IME_INPUT_DEVICE_TYPE_ROTARY) {
2197 LOGW("IME_ERROR_INVALID_PARAMETER");
2198 return IME_ERROR_INVALID_PARAMETER;
2201 retVal = _check_privilege();
2202 if (retVal != IME_ERROR_NONE) return retVal;
2205 LOGW("IME_ERROR_OPERATION_FAILED");
2206 return IME_ERROR_OPERATION_FAILED;
2210 Ecore_Event_Detent_Rotate *rotary_device_event =
2211 static_cast<Ecore_Event_Detent_Rotate*>(device_event->event_data);
2212 if (rotary_device_event) {
2213 if (rotary_device_event->direction == ECORE_DETENT_DIRECTION_CLOCKWISE) {
2214 *direction = IME_INPUT_DEVICE_ROTARY_DIRECTION_CLOCKWISE;
2215 } else if (rotary_device_event->direction == ECORE_DETENT_DIRECTION_COUNTER_CLOCKWISE) {
2216 *direction = IME_INPUT_DEVICE_ROTARY_DIRECTION_COUNTER_CLOCKWISE;
2220 return IME_ERROR_NONE;
2225 EXPORT_API int ime_event_set_prediction_hint_set_cb(ime_prediction_hint_set_cb callback_func, void *user_data)
2227 ime_error_e retVal = IME_ERROR_NONE;
2229 if (!callback_func) {
2230 LOGW("IME_ERROR_INVALID_PARAMETER");
2231 return IME_ERROR_INVALID_PARAMETER;
2234 retVal = _check_privilege();
2235 if (retVal != IME_ERROR_NONE) return retVal;
2237 g_event_callback.prediction_hint_set = callback_func;
2238 g_event_callback.prediction_hint_set_user_data = user_data;
2240 return IME_ERROR_NONE;
2243 EXPORT_API int ime_event_set_mime_type_set_request_cb(ime_mime_type_set_request_cb callback_func, void *user_data)
2245 ime_error_e retVal = IME_ERROR_NONE;
2247 if (!callback_func) {
2248 LOGW("IME_ERROR_INVALID_PARAMETER");
2249 return IME_ERROR_INVALID_PARAMETER;
2252 retVal = _check_privilege();
2253 if (retVal != IME_ERROR_NONE) return retVal;
2255 g_event_callback.mime_type_set = callback_func;
2256 g_event_callback.mime_type_set_user_data = user_data;
2258 return IME_ERROR_NONE;
2261 EXPORT_API int ime_set_floating_mode(bool floating_mode)
2263 ime_error_e retVal = IME_ERROR_NONE;
2265 retVal = _check_privilege();
2266 if (retVal != IME_ERROR_NONE) return retVal;
2269 LOGW("IME_ERROR_NOT_RUNNING");
2270 return IME_ERROR_NOT_RUNNING;
2274 g_core.set_floating_mode(floating_mode);
2276 return IME_ERROR_NONE;
2280 EXPORT_API int ime_set_floating_drag_start(void)
2282 ime_error_e retVal = IME_ERROR_NONE;
2284 retVal = _check_privilege();
2285 if (retVal != IME_ERROR_NONE) return retVal;
2288 LOGW("IME_ERROR_NOT_RUNNING");
2289 return IME_ERROR_NOT_RUNNING;
2293 g_core.set_floating_drag_enabled(true);
2295 return IME_ERROR_NONE;
2299 EXPORT_API int ime_set_floating_drag_end(void)
2301 ime_error_e retVal = IME_ERROR_NONE;
2303 retVal = _check_privilege();
2304 if (retVal != IME_ERROR_NONE) return retVal;
2307 LOGW("IME_ERROR_NOT_RUNNING");
2308 return IME_ERROR_NOT_RUNNING;
2312 g_core.set_floating_drag_enabled(false);
2314 return IME_ERROR_NONE;
2319 EXPORT_API int ime_set_window_creation_defer_flag(bool flag)
2321 ime_error_e retVal = IME_ERROR_NONE;
2323 retVal = _check_privilege();
2324 if (retVal != IME_ERROR_NONE) return retVal;
2326 g_core.set_window_creation_defer_flag(flag);
2328 return IME_ERROR_NONE;
2332 EXPORT_API int ime_event_set_prediction_hint_data_set_cb(ime_prediction_hint_data_set_cb callback_func, void *user_data)
2334 ime_error_e retVal = IME_ERROR_NONE;
2336 if (!callback_func) {
2337 LOGW("IME_ERROR_INVALID_PARAMETER");
2338 return IME_ERROR_INVALID_PARAMETER;
2341 retVal = _check_privilege();
2342 if (retVal != IME_ERROR_NONE) return retVal;
2344 g_event_callback.prediction_hint_data_set = callback_func;
2345 g_event_callback.prediction_hint_data_set_user_data = user_data;
2347 return IME_ERROR_NONE;
2351 EXPORT_API int ime_event_set_optimization_hint_set_cb(ime_optimization_hint_set_cb callback_func, void *user_data)
2354 ime_error_e retVal = IME_ERROR_NONE;
2356 if (!callback_func) {
2357 LOGW("IME_ERROR_INVALID_PARAMETER");
2358 return IME_ERROR_INVALID_PARAMETER;
2362 retVal = _check_privilege();
2363 if (retVal != IME_ERROR_NONE) return retVal;
2366 g_event_callback.optimization_hint_set = callback_func;
2367 g_event_callback.optimization_hint_set_user_data = user_data;
2369 return IME_ERROR_NONE;
2372 EXPORT_API int ime_event_set_process_key_event_with_imengine_cb(ime_process_key_event_with_imengine_cb callback_func, void *user_data)
2375 ime_error_e retVal = IME_ERROR_NONE;
2377 if (!callback_func) {
2378 LOGW("IME_ERROR_INVALID_PARAMETER");
2379 return IME_ERROR_INVALID_PARAMETER;
2382 retVal = _check_privilege();
2383 if (retVal != IME_ERROR_NONE) return retVal;
2385 g_event_callback.process_key_event_with_imengine = callback_func;
2386 g_event_callback.process_key_event_with_imengine_user_data = user_data;
2388 return IME_ERROR_NONE;
2391 EXPORT_API int ime_event_set_autocapital_type_set_cb(ime_autocapital_type_set_cb callback_func, void *user_data)
2394 ime_error_e retVal = IME_ERROR_NONE;
2396 if (!callback_func) {
2397 LOGW("IME_ERROR_INVALID_PARAMETER");
2398 return IME_ERROR_INVALID_PARAMETER;
2401 retVal = _check_privilege();
2402 if (retVal != IME_ERROR_NONE) return retVal;
2404 g_event_callback.autocapital_type_set = callback_func;
2405 g_event_callback.autocapital_type_set_user_data = user_data;
2407 return IME_ERROR_NONE;
2410 EXPORT_API int ime_event_set_prediction_allow_set_cb(ime_prediction_allow_set_cb callback_func, void *user_data)
2413 ime_error_e retVal = IME_ERROR_NONE;
2415 if (!callback_func) {
2416 LOGW("IME_ERROR_INVALID_PARAMETER");
2417 return IME_ERROR_INVALID_PARAMETER;
2420 retVal = _check_privilege();
2421 if (retVal != IME_ERROR_NONE) return retVal;
2423 g_event_callback.prediction_allow_set = callback_func;
2424 g_event_callback.prediction_allow_set_user_data = user_data;
2426 return IME_ERROR_NONE;
2429 EXPORT_API int ime_event_set_trigger_property_set_cb(ime_trigger_property_set_cb callback_func, void *user_data)
2432 ime_error_e retVal = IME_ERROR_NONE;
2434 if (!callback_func) {
2435 LOGW("IME_ERROR_INVALID_PARAMETER");
2436 return IME_ERROR_INVALID_PARAMETER;
2439 retVal = _check_privilege();
2440 if (retVal != IME_ERROR_NONE) return retVal;
2442 g_event_callback.trigger_property_set = callback_func;
2443 g_event_callback.trigger_property_set_user_data = user_data;
2445 return IME_ERROR_NONE;
2448 EXPORT_API int ime_event_set_candidate_more_window_show_cb(ime_candidate_more_window_show_cb callback_func, void *user_data)
2451 ime_error_e retVal = IME_ERROR_NONE;
2453 if (!callback_func) {
2454 LOGW("IME_ERROR_INVALID_PARAMETER");
2455 return IME_ERROR_INVALID_PARAMETER;
2458 retVal = _check_privilege();
2459 if (retVal != IME_ERROR_NONE) return retVal;
2461 g_event_callback.candidate_more_window_show = callback_func;
2462 g_event_callback.candidate_more_window_show_user_data = user_data;
2464 return IME_ERROR_NONE;
2467 EXPORT_API int ime_event_set_candidate_more_window_hide_cb(ime_candidate_more_window_hide_cb callback_func, void *user_data)
2470 ime_error_e retVal = IME_ERROR_NONE;
2472 if (!callback_func) {
2473 LOGW("IME_ERROR_INVALID_PARAMETER");
2474 return IME_ERROR_INVALID_PARAMETER;
2477 retVal = _check_privilege();
2478 if (retVal != IME_ERROR_NONE) return retVal;
2480 g_event_callback.candidate_more_window_hide = callback_func;
2481 g_event_callback.candidate_more_window_hide_user_data = user_data;
2483 return IME_ERROR_NONE;
2486 EXPORT_API int ime_event_set_aux_select_cb(ime_aux_select_cb callback_func, void *user_data)
2489 ime_error_e retVal = IME_ERROR_NONE;
2491 if (!callback_func) {
2492 LOGW("IME_ERROR_INVALID_PARAMETER");
2493 return IME_ERROR_INVALID_PARAMETER;
2496 retVal = _check_privilege();
2497 if (retVal != IME_ERROR_NONE) return retVal;
2499 g_event_callback.aux_select = callback_func;
2500 g_event_callback.aux_select_user_data = user_data;
2502 return IME_ERROR_NONE;
2505 EXPORT_API int ime_event_set_candidate_select_cb(ime_candidate_select_cb callback_func, void *user_data)
2508 ime_error_e retVal = IME_ERROR_NONE;
2510 if (!callback_func) {
2511 LOGW("IME_ERROR_INVALID_PARAMETER");
2512 return IME_ERROR_INVALID_PARAMETER;
2515 retVal = _check_privilege();
2516 if (retVal != IME_ERROR_NONE) return retVal;
2518 g_event_callback.candidate_select = callback_func;
2519 g_event_callback.candidate_select_user_data = user_data;
2521 return IME_ERROR_NONE;
2524 EXPORT_API int ime_event_set_candidate_table_page_up_cb(ime_candidate_table_page_up_cb callback_func, void *user_data)
2527 ime_error_e retVal = IME_ERROR_NONE;
2529 if (!callback_func) {
2530 LOGW("IME_ERROR_INVALID_PARAMETER");
2531 return IME_ERROR_INVALID_PARAMETER;
2534 retVal = _check_privilege();
2535 if (retVal != IME_ERROR_NONE) return retVal;
2537 g_event_callback.candidate_table_page_up = callback_func;
2538 g_event_callback.candidate_table_page_up_user_data = user_data;
2540 return IME_ERROR_NONE;
2543 EXPORT_API int ime_event_set_candidate_table_page_down_cb(ime_candidate_table_page_down_cb callback_func, void *user_data)
2546 ime_error_e retVal = IME_ERROR_NONE;
2548 if (!callback_func) {
2549 LOGW("IME_ERROR_INVALID_PARAMETER");
2550 return IME_ERROR_INVALID_PARAMETER;
2553 retVal = _check_privilege();
2554 if (retVal != IME_ERROR_NONE) return retVal;
2556 g_event_callback.candidate_table_page_down = callback_func;
2557 g_event_callback.candidate_table_page_down_user_data = user_data;
2559 return IME_ERROR_NONE;
2562 EXPORT_API int ime_event_set_candidate_table_page_size_chaned_cb(ime_candidate_table_page_size_chaned_cb callback_func, void *user_data)
2565 ime_error_e retVal = IME_ERROR_NONE;
2567 if (!callback_func) {
2568 LOGW("IME_ERROR_INVALID_PARAMETER");
2569 return IME_ERROR_INVALID_PARAMETER;
2572 retVal = _check_privilege();
2573 if (retVal != IME_ERROR_NONE) return retVal;
2575 g_event_callback.candidate_table_page_size_chaned = callback_func;
2576 g_event_callback.candidate_table_page_size_chaned_user_data = user_data;
2578 return IME_ERROR_NONE;
2581 EXPORT_API int ime_event_set_candidate_item_layout_set_cb(ime_candidate_item_layout_set_cb callback_func, void *user_data)
2584 ime_error_e retVal = IME_ERROR_NONE;
2586 if (!callback_func) {
2587 LOGW("IME_ERROR_INVALID_PARAMETER");
2588 return IME_ERROR_INVALID_PARAMETER;
2591 retVal = _check_privilege();
2592 if (retVal != IME_ERROR_NONE) return retVal;
2594 g_event_callback.candidate_item_layout_set = callback_func;
2595 g_event_callback.candidate_item_layout_set_user_data = user_data;
2597 return IME_ERROR_NONE;
2600 EXPORT_API int ime_event_set_displayed_candidate_number_chaned_cb(ime_displayed_candidate_number_chaned_cb callback_func, void *user_data)
2603 ime_error_e retVal = IME_ERROR_NONE;
2605 if (!callback_func) {
2606 LOGW("IME_ERROR_INVALID_PARAMETER");
2607 return IME_ERROR_INVALID_PARAMETER;
2610 retVal = _check_privilege();
2611 if (retVal != IME_ERROR_NONE) return retVal;
2613 g_event_callback.displayed_candidate_number_chaned = callback_func;
2614 g_event_callback.displayed_candidate_number_chaned_user_data = user_data;
2616 return IME_ERROR_NONE;
2619 EXPORT_API int ime_event_set_candidate_item_long_pressed_cb(ime_candidate_item_long_pressed_cb callback_func, void *user_data)
2622 ime_error_e retVal = IME_ERROR_NONE;
2624 if (!callback_func) {
2625 LOGW("IME_ERROR_INVALID_PARAMETER");
2626 return IME_ERROR_INVALID_PARAMETER;
2629 retVal = _check_privilege();
2630 if (retVal != IME_ERROR_NONE) return retVal;
2632 g_event_callback.candidate_item_long_pressed = callback_func;
2633 g_event_callback.candidate_item_long_pressed_user_data = user_data;
2635 return IME_ERROR_NONE;
2638 EXPORT_API int ime_show_aux_string(void)
2640 ime_error_e retVal = IME_ERROR_NONE;
2642 retVal = _check_privilege();
2643 if (retVal != IME_ERROR_NONE) return retVal;
2646 LOGW("IME_ERROR_NOT_RUNNING");
2647 return IME_ERROR_NOT_RUNNING;
2650 g_core.show_aux_string();
2652 return IME_ERROR_NONE;
2655 EXPORT_API int ime_hide_aux_string(void)
2657 ime_error_e retVal = IME_ERROR_NONE;
2659 retVal = _check_privilege();
2660 if (retVal != IME_ERROR_NONE) return retVal;
2663 LOGW("IME_ERROR_NOT_RUNNING");
2664 return IME_ERROR_NOT_RUNNING;
2667 g_core.hide_aux_string();
2669 return IME_ERROR_NONE;
2672 EXPORT_API int ime_show_lookup_table(void)
2674 ime_error_e retVal = IME_ERROR_NONE;
2676 retVal = _check_privilege();
2677 if (retVal != IME_ERROR_NONE) return retVal;
2680 LOGW("IME_ERROR_NOT_RUNNING");
2681 return IME_ERROR_NOT_RUNNING;
2684 g_core.show_candidate_string();
2686 return IME_ERROR_NONE;
2689 EXPORT_API int ime_hide_lookup_table(void)
2691 ime_error_e retVal = IME_ERROR_NONE;
2693 retVal = _check_privilege();
2694 if (retVal != IME_ERROR_NONE) return retVal;
2697 LOGW("IME_ERROR_NOT_RUNNING");
2698 return IME_ERROR_NOT_RUNNING;
2701 g_core.hide_candidate_string();
2703 return IME_ERROR_NONE;
2706 EXPORT_API int ime_update_preedit_caret(int caret)
2708 ime_error_e retVal = IME_ERROR_NONE;
2711 LOGW("IME_ERROR_INVALID_PARAMETER");
2712 return IME_ERROR_INVALID_PARAMETER;
2716 LOGW("IME_ERROR_NOT_RUNNING");
2717 return IME_ERROR_NOT_RUNNING;
2720 retVal = _check_privilege();
2721 if (retVal != IME_ERROR_NONE) return retVal;
2723 g_core.update_preedit_caret(caret);
2725 return IME_ERROR_NONE;
2728 EXPORT_API int ime_update_preedit_string_with_commit(const char *preedit, const char *commit, scim::AttributeList &attrs, int caret)
2730 ime_error_e retVal = IME_ERROR_NONE;
2732 if (!preedit && !commit) {
2733 LOGW("IME_ERROR_INVALID_PARAMETER");
2734 return IME_ERROR_INVALID_PARAMETER;
2738 LOGW("IME_ERROR_NOT_RUNNING");
2739 return IME_ERROR_NOT_RUNNING;
2742 retVal = _check_privilege();
2743 if (retVal != IME_ERROR_NONE) return retVal;
2745 g_core.update_preedit_string_with_commit(preedit, commit, attrs, caret);
2747 return IME_ERROR_NONE;
2750 EXPORT_API int ime_update_aux_string(const char *str)
2752 ime_error_e retVal = IME_ERROR_NONE;
2755 LOGW("IME_ERROR_INVALID_PARAMETER");
2756 return IME_ERROR_INVALID_PARAMETER;
2760 LOGW("IME_ERROR_NOT_RUNNING");
2761 return IME_ERROR_NOT_RUNNING;
2764 retVal = _check_privilege();
2765 if (retVal != IME_ERROR_NONE) return retVal;
2767 g_core.update_aux_string(str);
2769 return IME_ERROR_NONE;
2772 EXPORT_API int ime_recapture_string(int offset, int len, const char *preedit, const char *commit, scim::AttributeList &attrs)
2774 ime_error_e retVal = IME_ERROR_NONE;
2777 LOGW("IME_ERROR_INVALID_PARAMETER");
2778 return IME_ERROR_INVALID_PARAMETER;
2782 LOGW("IME_ERROR_NOT_RUNNING");
2783 return IME_ERROR_NOT_RUNNING;
2786 retVal = _check_privilege();
2787 if (retVal != IME_ERROR_NONE) return retVal;
2789 g_core.recapture_string(offset, len, preedit, commit, attrs);
2791 return IME_ERROR_NONE;
2794 EXPORT_API int ime_update_lookup_table(scim::LookupTable &table)
2796 ime_error_e retVal = IME_ERROR_NONE;
2799 LOGW("IME_ERROR_NOT_RUNNING");
2800 return IME_ERROR_NOT_RUNNING;
2803 retVal = _check_privilege();
2804 if (retVal != IME_ERROR_NONE) return retVal;
2806 g_core.update_lookup_table(table);
2808 return IME_ERROR_NONE;
2811 EXPORT_API int ime_register_properties(scim::PropertyList &properties)
2813 ime_error_e retVal = IME_ERROR_NONE;
2816 LOGW("IME_ERROR_NOT_RUNNING");
2817 return IME_ERROR_NOT_RUNNING;
2820 retVal = _check_privilege();
2821 if (retVal != IME_ERROR_NONE) return retVal;
2823 g_core.register_properties(properties);
2825 return IME_ERROR_NONE;
2828 EXPORT_API int ime_update_property(scim::Property &property)
2830 ime_error_e retVal = IME_ERROR_NONE;
2833 LOGW("IME_ERROR_NOT_RUNNING");
2834 return IME_ERROR_NOT_RUNNING;
2837 retVal = _check_privilege();
2838 if (retVal != IME_ERROR_NONE) return retVal;
2840 g_core.update_property(property);
2842 return IME_ERROR_NONE;
2845 EXPORT_API int ime_expand_candidate(void)
2847 ime_error_e retVal = IME_ERROR_NONE;
2849 retVal = _check_privilege();
2850 if (retVal != IME_ERROR_NONE) return retVal;
2853 LOGW("IME_ERROR_NOT_RUNNING");
2854 return IME_ERROR_NOT_RUNNING;
2857 g_core.expand_candidate();
2859 return IME_ERROR_NONE;
2862 EXPORT_API int ime_contract_candidate(void)
2864 ime_error_e retVal = IME_ERROR_NONE;
2866 retVal = _check_privilege();
2867 if (retVal != IME_ERROR_NONE) return retVal;
2870 LOGW("IME_ERROR_NOT_RUNNING");
2871 return IME_ERROR_NOT_RUNNING;
2874 g_core.contract_candidate();
2876 return IME_ERROR_NONE;
2879 EXPORT_API int ime_set_candidate_style(scim::ISF_CANDIDATE_PORTRAIT_LINE_T portrait_line, scim::ISF_CANDIDATE_MODE_T mode)
2881 ime_error_e retVal = IME_ERROR_NONE;
2884 LOGW("IME_ERROR_NOT_RUNNING");
2885 return IME_ERROR_NOT_RUNNING;
2888 retVal = _check_privilege();
2889 if (retVal != IME_ERROR_NONE) return retVal;
2891 g_core.set_candidate_style(portrait_line, mode);
2893 return IME_ERROR_NONE;
2896 EXPORT_API int ime_set_engine_loader_flag(bool flag)
2898 ime_error_e retVal = IME_ERROR_NONE;
2901 LOGW("IME_ERROR_NOT_RUNNING");
2902 return IME_ERROR_NOT_RUNNING;
2905 retVal = _check_privilege();
2906 if (retVal != IME_ERROR_NONE) return retVal;
2908 g_core.set_engine_loader_flag(flag);
2910 return IME_ERROR_NONE;
2913 EXPORT_API int ime_send_key_event_processing_result(scim::KeyEvent &key, uint32_t serial, bool is_success)
2915 ime_error_e retVal = IME_ERROR_NONE;
2918 LOGW("IME_ERROR_NOT_RUNNING");
2919 return IME_ERROR_NOT_RUNNING;
2922 retVal = _check_privilege();
2923 if (retVal != IME_ERROR_NONE) return retVal;
2925 g_core.send_key_event_processing_result(key, serial, is_success);
2927 return IME_ERROR_NONE;
2931 EXPORT_API int ime_update_input_panel_event(ime_event_type_e type, unsigned int value)
2933 ime_error_e retVal = IME_ERROR_NONE;
2935 if (type < IME_EVENT_TYPE_LANGUAGE || type > IME_EVENT_TYPE_GEOMETRY) {
2936 LOGW("IME_ERROR_INVALID_PARAMETER");
2937 return IME_ERROR_INVALID_PARAMETER;
2941 LOGW("IME_ERROR_NOT_RUNNING");
2942 return IME_ERROR_NOT_RUNNING;
2946 retVal = _check_privilege();
2947 if (retVal != IME_ERROR_NONE) return retVal;
2949 g_core.update_input_context((sclu32)type, value);
2951 return IME_ERROR_NONE;
2955 EXPORT_API int ime_set_candidate_visibility_state(bool visible)
2957 ime_error_e retVal = IME_ERROR_NONE;
2960 LOGW("IME_ERROR_NOT_RUNNING");
2961 return IME_ERROR_NOT_RUNNING;
2965 retVal = _check_privilege();
2966 if (retVal != IME_ERROR_NONE) return retVal;
2969 g_core.show_candidate_string();
2971 g_core.hide_candidate_string();
2973 return IME_ERROR_NONE;