2 * Copyright (c) 2012 - 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.
19 #include <sys/types.h>
25 #include <Ecore_IMF.h>
26 #include <Elementary.h>
29 #include <inputmethod.h>
30 #include <inputmethod_internal.h>
31 #include <app_control.h>
32 #include <app_preference.h>
33 #include <ode/internal-encryption.h>
41 #include "languages.h"
42 #include "candidate-factory.h"
43 #include "ise-emoticon-mode.h"
44 #include "ise-stt-mode.h"
45 #include "ise-stt-option.h"
46 #include "ise-language-change.h"
47 #include "ise-tutorial-mode.h"
48 #include "modeindicator.h"
49 #include "w-input-smartreply.h"
50 #include "ise-floating-mode.h"
53 #define EDJ_FILE RESDIR"/edje/mobile/customised_ctxpopup.edj"
55 #define EXIT_ISE_ON_HIDE 0
56 #define DEFER_ISE_CREATION 0
58 #define CANDIDATE_WINDOW_HEIGHT 84
64 CSCLUI* get_ui() { return g_ui; }
67 static cbhm_h cbhm_handle;
68 static sclu32 cbhm_sel_type = 0;
69 static sclboolean g_set_mime_type = FALSE;
72 int g_imdata_state = 0;
74 extern emoticon_group_t current_emoticon_group;
75 extern std::vector <int> emoticon_list_recent;
77 static sclboolean g_need_send_shift_event = FALSE;
79 extern void set_ise_imdata(const char * buf, size_t &len);
80 static void init_recent_used_punctuation();
81 static void update_recent_used_punctuation(const char *key_value);
82 static void set_ime_size(bool floating_mode, ISE_CANDIDATE_REQUEST candidate_req);
83 static sclboolean g_punctuation_popup_opened = FALSE;
84 static sclboolean g_popup_opened = FALSE;
85 static vector<string> g_recent_used_punctuation;
86 static const int MAX_DEFAULT_PUNCTUATION = 6;
87 static string g_default_punctuation[MAX_DEFAULT_PUNCTUATION] = {"-", "@", "'", "!", "?", ","};
88 static string g_current_punctuation[MAX_DEFAULT_PUNCTUATION-1] = {"RCENT1", "RCENT2", "RCENT3", "RCENT4", "RCENT5"};
89 static vector<string> g_softcandidate_string;
90 static bool g_softcandidate_show = false;
91 static bool g_input_panel_show = false;
92 static bool g_smartreply_reply_exist = false;
93 static unsigned int g_smartreply_size = 0;
94 static bool g_caps_mode_pending = false;
95 static bool g_floating_mode = false;
96 static bool g_candidate_more_view = false;
97 static bool g_ise_created = false;
99 static bool g_autofill_exist = false;
100 static int g_autofill_hint = 0;
101 static string g_autofill_string;
102 static vector<string> g_lookup_table_strings;
103 static vector<string> g_smartreply_strings;
105 static Ecore_Timer *exit_timer = NULL;
108 static string g_app_id;
109 static string g_resource_id;
111 #define SOFT_CANDIDATE_DELETE_TIME (100.0/1000)
112 static Ecore_Timer *g_softcandidate_hide_timer = NULL;
114 extern sclboolean g_setting_window_open_status;
117 static int g_ic_smartreply = -1;
119 KEYBOARD_STATE g_keyboard_state = {
122 ISE_LAYOUT_STYLE_NORMAL,
131 KEYBOARD_STATE* get_keyboard_state() {
132 return &g_keyboard_state;
135 #define ISE_LAYOUT_NUMBERONLY_VARIATION_MAX 4
136 /*static const sclchar *_ise_numberonly_variation_name[ISE_LAYOUT_NUMBERONLY_VARIATION_MAX] = {
137 "DEFAULT", "SIG", "DEC", "SIGDEC"
140 #define SIG_DEC_SIZE 2
141 static scluint _click_count = 0;
142 static const char *_sig_dec[SIG_DEC_SIZE] = {".", "-"};
143 static scluint _sig_dec_event[SIG_DEC_SIZE] = {'.', '-'};
144 static Ecore_Timer *_commit_timer = NULL;
146 static sclu32 _context_layout = ISE_LAYOUT_STYLE_NORMAL;
147 static sclu32 _context_layout_variation = 0;
149 Candidate *g_candidate = NULL;
150 Candidate* get_candidate() {
154 static ISELanguageManager _language_manager;
156 class CandidateEventListener: public EventListener
159 void on_event(const EventDesc &desc)
161 CSCLUI *ui = get_ui();
162 const MultiEventDesc &multidesc = dynamic_cast<const MultiEventDesc &>(desc);
163 LANGUAGE_INFO *info = _language_manager.get_language_info(_language_manager.get_current_language());
165 switch (multidesc.type) {
166 case MultiEventDesc::CANDIDATE_ITEM_MOUSE_DOWN:
167 if (g_autofill_exist) {
168 if (multidesc.index == 0) {
169 char *text = autofill_get_string(g_app_id.c_str(), g_resource_id.c_str(), (Ecore_IMF_Input_Hints)g_autofill_hint);
171 ise_send_string(text);
174 } else if (multidesc.index < (int)g_smartreply_size + 1) {
175 ise_send_string(g_softcandidate_string[multidesc.index].c_str());
177 if (info && info->load_in_ime)
178 ime_select_candidate(multidesc.index - g_smartreply_size - 1);
180 engine_loader_select_candidate(multidesc.index - g_smartreply_size - 1);
183 if (multidesc.index < (int)g_smartreply_size)
184 ise_send_string(g_softcandidate_string[multidesc.index].c_str());
186 if (info && info->load_in_ime)
187 ime_select_candidate(multidesc.index - g_smartreply_size);
189 engine_loader_select_candidate(multidesc.index - g_smartreply_size);
193 case MultiEventDesc::CANDIDATE_MORE_VIEW_SHOW:
194 // when more parts shows, click on the candidate will
195 // not affect the key click event
196 g_candidate_more_view = true;
197 if (!g_input_panel_show)
198 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_SHOW);
200 ui->disable_input_events(TRUE);
202 case MultiEventDesc::CANDIDATE_MORE_VIEW_HIDE:
203 g_candidate_more_view = false;
204 if (!g_input_panel_show)
205 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_SHOW);
207 ui->disable_input_events(FALSE);
213 static CandidateEventListener g_candidate_event_listener;
215 #define MVK_Shift_L 0xffe1
216 #define MVK_Caps_Lock 0xffe5
217 #define MVK_Shift_Off 0xffe1
218 #define MVK_Shift_On 0xffe2
219 #define MVK_Shift_Lock 0xffe6
220 #define MVK_Shift_Enable 0x9fe7
221 #define MVK_Shift_Disable 0x9fe8
222 #define MVK_space 0x020
223 #define MVK_Done 0xff0d
225 #define CM_KEY_LIST_SIZE 5
226 #define MULTITAP_TIMEOUT 3.0
227 #define USER_KEYSTRING_OPTION "OPTION"
228 #define USER_KEYSTRING_EMOTICON "EMOTICON_LAYOUT"
229 #define USER_KEYSTRING_CLIPBOARD "CLIPBOARD"
230 #define USER_KEYSTRING_VOICE "STT_3X4"
231 #define USER_KEYSTRING_FLOATING "FLOATING"
233 #define USER_VOICE_LANGUAGE "LANGUAGE"
235 static sclboolean _cm_popup_opened = FALSE;
236 static const char *_cm_key_list[CM_KEY_LIST_SIZE] = {USER_KEYSTRING_OPTION, USER_KEYSTRING_EMOTICON, USER_KEYSTRING_CLIPBOARD, USER_KEYSTRING_VOICE, USER_KEYSTRING_FLOATING};
237 static scluint _current_cm_key_id = 0;
238 Evas_Object* _guide_popup_setting = NULL;
239 Evas_Object* _guide_popup_space = NULL;
242 * This callback class will receive all response events from SCL
243 * So you should perform desired tasks in this class.
245 class CUIEventCallback : public ISCLUIEventCallback
248 Ecore_Timer* word_timer = NULL;
249 static Eina_Bool _multi_tap_timer_cb(void *data)
252 ise_send_event(MVK_Done, KEY_MASK_NULL);
253 return ECORE_CALLBACK_CANCEL;
255 SCLEventReturnType on_event_key_clicked(SclUIEventDesc event_desc);
256 SCLEventReturnType on_event_drag_state_changed(SclUIEventDesc event_desc);
257 SCLEventReturnType on_event_notification(SCLUINotiType noti_type, SclNotiDesc *etc_info);
260 static CUIEventCallback callback;
262 static void update_candidate_table()
264 g_softcandidate_string.clear();
265 vector<string>::iterator iter;
267 // add autofill string
268 if (g_autofill_exist)
269 g_softcandidate_string.push_back(g_autofill_string);
271 // add lookup table string(s)
272 iter = g_lookup_table_strings.begin();
273 for (; iter != g_lookup_table_strings.end(); ++iter)
275 g_softcandidate_string.push_back(string(iter->c_str()));
278 ise_update_table(g_softcandidate_string);
281 static void _input_smartreply_notify_cb(void *user_data)
283 g_smartreply_strings.clear();
284 char *candidate = NULL;
286 if (input_smartreply_is_enabled()) {
287 /* Append newly added smartreply list */
288 int len = input_smartreply_get_reply_num();
290 for (int i = 0; i < len; i++) {
292 char *reply = (char *)"";
293 reply = input_smartreply_get_nth_item(i, &type);
296 SECURE_LOGD("SmartReply = [%d] %s", i, reply);
299 g_smartreply_strings.push_back(string(candidate));
305 g_ic_smartreply = g_ic;
306 g_smartreply_reply_exist = true;
308 ise_app_candidate_show();
309 g_softcandidate_string = g_smartreply_strings;
310 ise_update_table(g_softcandidate_string);
316 check_ic_temporary(int ic)
318 if ((ic & 0xFFFF) == 0) {
324 static void _reset_shift_state(void)
326 CSCLUI *ui = get_ui();
328 /* Reset all shift state variables */
329 SCLShiftState old_shift_state = ui->get_shift_state();
330 SCLShiftState new_shift_state = SCL_SHIFT_STATE_OFF;
331 if (old_shift_state != new_shift_state) {
332 g_need_send_shift_event = true;
333 ui->set_shift_state(new_shift_state);
335 LOGD("Shift state changed from (%d) to (%d)\n", (int)old_shift_state, (int)new_shift_state);
339 static void set_caps_mode(sclboolean mode) {
340 CSCLUI *ui = get_ui();
341 LOGD("mode : %d\n", mode);
343 if (ui->get_shift_state() != SCL_SHIFT_STATE_LOCK) {
344 ui->set_shift_state(mode ? SCL_SHIFT_STATE_ON : SCL_SHIFT_STATE_OFF);
345 ui->set_autocapital_shift_state(!mode);
347 bool load_in_ime = false;
348 const sclchar *cur_lang = _language_manager.get_current_language();
350 LANGUAGE_INFO *info = _language_manager.get_language_info(cur_lang);
352 load_in_ime = info->load_in_ime;
356 ime_send_imengine_event(mode ? MVK_Shift_On : MVK_Shift_Off, 0);
358 engine_loader_send_imengine_event(mode ? MVK_Shift_On : MVK_Shift_Off, 0);
363 static void _reset_multitap_state(bool skip_commit = false)
365 KEYBOARD_STATE *keyboard_state = get_keyboard_state();
366 if (!keyboard_state) return;
368 LOGD("keyboard_state.prev_modifier : %d", keyboard_state->prev_modifier);
369 if (keyboard_state->prev_modifier == KEY_MODIFIER_MULTITAP_START ||
370 keyboard_state->prev_modifier == KEY_MODIFIER_MULTITAP_REPEAT) {
372 ise_send_string(keyboard_state->multitap_value.c_str());
374 ise_update_preedit_string("");
376 keyboard_state->multitap_value = "";
377 keyboard_state->prev_modifier = KEY_MODIFIER_NONE;
378 if (g_caps_mode_pending) {
379 g_caps_mode_pending = false;
380 set_caps_mode(keyboard_state->caps_mode);
384 static void ise_set_cm_private_key(scluint cm_key_id)
386 CSCLUI *ui = get_ui();
387 if (cm_key_id >= CM_KEY_LIST_SIZE || ui == NULL) {
388 LOGE("cm_key_id=%d\n", cm_key_id);
392 if (strcmp(_cm_key_list[cm_key_id], USER_KEYSTRING_EMOTICON) == 0) {
393 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
394 const_cast<sclchar*>("icon/54x54/icon_emotion_nor.png"),
395 const_cast<sclchar*>("icon/54x54/icon_emotion_press.png"),
396 const_cast<sclchar*>("icon/54x54/icon_emotion_dim.png")};
397 ui->set_private_key("CM_KEY", const_cast<sclchar*>(" "), imagelabel, NULL, 0, const_cast<sclchar*>(USER_KEYSTRING_EMOTICON), TRUE);
398 } else if (strcmp(_cm_key_list[cm_key_id], USER_KEYSTRING_OPTION) == 0) {
399 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
400 const_cast<sclchar*>("icon/54x54/icon_setting_nor.png"),
401 const_cast<sclchar*>("icon/54x54/icon_setting_press.png"),
402 const_cast<sclchar*>("icon/54x54/icon_setting_dim.png")};
403 ui->set_private_key("CM_KEY", const_cast<sclchar*>(" "), imagelabel, NULL, 0, const_cast<sclchar*>(USER_KEYSTRING_OPTION), TRUE);
404 } else if (strcmp(_cm_key_list[cm_key_id], USER_KEYSTRING_CLIPBOARD) == 0) {
405 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
406 const_cast<sclchar*>("icon/54x54/icon_clipboard_nor.png"),
407 const_cast<sclchar*>("icon/54x54/icon_clipboard_press.png"),
408 const_cast<sclchar*>("icon/54x54/icon_clipboard_dim.png")};
409 ui->set_private_key("CM_KEY", const_cast<sclchar*>(" "), imagelabel, NULL, 0, const_cast<sclchar*>(USER_KEYSTRING_CLIPBOARD), TRUE);
410 } else if (strcmp(_cm_key_list[cm_key_id], USER_KEYSTRING_VOICE) == 0) {
411 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
412 const_cast<sclchar*>("icon/54x54/icon_mic_nor.png"),
413 const_cast<sclchar*>("icon/54x54/icon_mic_press.png"),
414 const_cast<sclchar*>("icon/54x54/icon_mic_dim.png")};
415 ui->set_private_key("CM_KEY", const_cast<sclchar*>(" "), imagelabel, NULL, 0, const_cast<sclchar*>(USER_KEYSTRING_VOICE), TRUE);
416 } else if (strcmp(_cm_key_list[cm_key_id], USER_KEYSTRING_FLOATING) == 0) {
417 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
418 const_cast<sclchar*>("icon/54x54/icon_floating_keypad_nor.png"),
419 const_cast<sclchar*>("icon/54x54/icon_floating_keypad_press.png"),
420 const_cast<sclchar*>("icon/54x54/icon_floating_keypad_dim.png")};
421 ui->set_private_key("CM_KEY", const_cast<sclchar*>(" "), imagelabel, NULL, 0, const_cast<sclchar*>(USER_KEYSTRING_FLOATING), TRUE);
425 static void ise_update_space_key(void)
427 CSCLUI *ui = get_ui();
433 scluint num = _language_manager.get_enabled_languages_num();
434 LOGD("language number: %d\n", num);
436 LANGUAGE_INFO *info = _language_manager.get_language_info(_language_manager.get_current_language());
437 if (info && info->enabled) {
439 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
440 const_cast<sclchar*>("w_sip_3x4_btn_ic_space_no_arrow.png"),
441 const_cast<sclchar*>("w_sip_3x4_btn_ic_space_no_arrow.png"),
442 const_cast<sclchar*>("w_sip_3x4_btn_ic_space_no_arrow.png")};
443 ui->set_private_key("SPACE_KEY", const_cast<sclchar*>(info->display_name.c_str()), imagelabel, NULL, 0, const_cast<sclchar*>("Space"), TRUE);
445 ui->enable_button("SPACE_ARROW_LEFT", false);
446 ui->enable_button("SPACE_ARROW_RIGHT", false);
451 ui->unset_private_key("SPACE_KEY");
453 ui->enable_button("SPACE_ARROW_LEFT", true);
454 ui->enable_button("SPACE_ARROW_RIGHT", true);
459 static scluint ise_get_cm_key_id(const sclchar *key_value)
461 for (int i = 0; i < CM_KEY_LIST_SIZE; ++i) {
462 if (0 == strcmp (key_value, _cm_key_list[i]))
468 static bool ise_is_emoticons_disabled(void)
472 KEYBOARD_STATE *keyboard_state = get_keyboard_state();
473 if (!keyboard_state) return ret;
475 sclu32 current_layout = keyboard_state->layout;
476 LOGD("layout=%d\n", current_layout);
478 if ((current_layout == ISE_LAYOUT_STYLE_NORMAL) ||
479 (current_layout == ISE_LAYOUT_STYLE_NUMBER) ||
480 (current_layout == ISE_LAYOUT_STYLE_EMOTICON))
483 if (g_imdata_state & IMDATA_ACTION_DISABLE_EMOTICONS)
489 static Eina_Bool softcandidate_hide_timer_callback(void *data)
492 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_HIDE);
494 Candidate *candidate = get_candidate();
497 g_softcandidate_show = false;
499 return ECORE_CALLBACK_CANCEL;
502 static void delete_softcandidate_hide_timer(void)
504 if (g_softcandidate_hide_timer) {
505 ecore_timer_del(g_softcandidate_hide_timer);
506 g_softcandidate_hide_timer = NULL;
510 static void add_softcandidate_hide_timer(void)
512 delete_softcandidate_hide_timer();
513 g_softcandidate_hide_timer = ecore_timer_add(SOFT_CANDIDATE_DELETE_TIME, softcandidate_hide_timer_callback, NULL);
516 static void create_softcandidate(void)
519 g_candidate = CandidateFactory::make_candidate(CANDIDATE_MULTILINE, ime_get_main_window());
521 g_candidate->add_event_listener(&g_candidate_event_listener);
527 * Send the given string to input framework
530 ise_send_string(const sclchar *key_value)
533 KEYBOARD_STATE *keyboard_state = get_keyboard_state();
534 if (keyboard_state && !check_ic_temporary(keyboard_state->ic)) {
535 ic = keyboard_state->ic;
537 ime_commit_string(key_value);
538 LOGD("ic : %x, %s\n", ic, key_value);
542 * Send the preedit string to input framework
545 ise_update_preedit_string(const sclchar *str, const sclboolean underline)
548 Eina_List *attr_list = NULL;
549 ime_preedit_attribute *preedit_attr;
551 KEYBOARD_STATE *keyboard_state = get_keyboard_state();
552 if (keyboard_state && !check_ic_temporary(keyboard_state->ic)) {
553 ic = keyboard_state->ic;
556 /* Count UTF-8 string length */
558 const sclchar *s = str;
559 while (*s) len += (*s++ & 0xc0) != 0x80;
561 preedit_attr = (ime_preedit_attribute *)calloc(1, sizeof(ime_preedit_attribute));
563 preedit_attr->start = 0;
564 preedit_attr->length = len;
565 preedit_attr->type = IME_ATTR_FONTSTYLE;
566 preedit_attr->value = IME_ATTR_FONTSTYLE_UNDERLINE;
567 attr_list = eina_list_append(attr_list, (void *)preedit_attr);
570 ime_update_preedit_string(str, attr_list);
572 ime_update_preedit_string(str, NULL);
574 LOGD("ic : %x, %s\n", ic, str);
578 * Send the given event to input framework
581 ise_send_event(sclulong key_event, sclulong key_mask)
584 KEYBOARD_STATE *keyboard_state = get_keyboard_state();
585 if (keyboard_state && !check_ic_temporary(keyboard_state->ic)) {
586 ic = keyboard_state->ic;
588 ime_send_key_event((ime_key_code_e)key_event, IME_KEY_MASK_PRESSED, false);
589 ime_send_key_event((ime_key_code_e)key_event, IME_KEY_MASK_RELEASED, false);
591 LOGD("ic : %x, %lx\n", (unsigned int)ic, key_event);
595 * Forward the given event to input framework
598 ise_forward_key_event(sclulong key_event)
601 KEYBOARD_STATE *keyboard_state = get_keyboard_state();
602 if (!check_ic_temporary(keyboard_state->ic)) {
603 ic = keyboard_state->ic;
605 ime_send_key_event((ime_key_code_e)key_event, IME_KEY_MASK_PRESSED, true);
606 ime_send_key_event((ime_key_code_e)key_event, IME_KEY_MASK_RELEASED, true);
608 LOGD("ic : %x, %lx\n", (unsigned int)ic, key_event);
612 * @brief Delete commit timer.
616 static void delete_commit_timer(void)
618 if (_commit_timer != NULL) {
619 ecore_timer_del(_commit_timer);
620 _commit_timer = NULL;
625 * @brief Callback function for commit timer.
627 * @param data Data to pass when it is called.
629 * @return ECORE_CALLBACK_CANCEL
631 static Eina_Bool commit_timeout(void *data)
633 if (_commit_timer != NULL) {
634 ime_hide_preedit_string();
635 ise_forward_key_event(_sig_dec_event[(_click_count-1)%SIG_DEC_SIZE]);
638 _commit_timer = NULL;
639 return ECORE_CALLBACK_CANCEL;
643 on_input_mode_changed(const sclchar *key_value, sclulong key_event, sclint key_type)
645 sclboolean ret = FALSE;
647 CSCLUI *ui = get_ui();
648 KEYBOARD_STATE *keyboard_state = get_keyboard_state();
649 if (ui && keyboard_state) {
651 SECURE_LOGD("key_value : %s\n", key_value);
652 if (strcmp(key_value, "CUR_LANG") == 0) {
653 keyboard_state->disable_force_latin = TRUE;
654 ret = _language_manager.select_current_language();
656 if (strcmp(key_value, "NEXT_LANG") == 0) {
657 keyboard_state->disable_force_latin = TRUE;
658 ret = _language_manager.select_next_language();
662 const sclchar *cur_lang = _language_manager.get_current_language();
664 LANGUAGE_INFO *info = _language_manager.get_language_info(cur_lang);
666 if (info->accepts_caps_mode) {
667 if (info->load_in_ime)
668 ime_send_imengine_event(MVK_Shift_Enable, 0);
670 engine_loader_send_imengine_event(MVK_Shift_Enable, 0);
672 set_caps_mode(keyboard_state->caps_mode);
674 if (info->load_in_ime)
675 ime_send_imengine_event(MVK_Shift_Disable, 0);
677 engine_loader_send_imengine_event(MVK_Shift_Disable, 0);
679 ui->set_shift_state(SCL_SHIFT_STATE_OFF);
683 if (is_emoticon_show()) {
684 ise_destroy_emoticon_layout();
687 if (!strcmp(key_value, USER_KEYSTRING_EMOTICON)) {
688 ise_init_emoticon_list();
690 current_emoticon_group = EMOTICON_GROUP_1;
692 if (emoticon_list_recent.size() == 0)
693 current_emoticon_group = EMOTICON_GROUP_1;
695 current_emoticon_group = EMOTICON_GROUP_RECENTLY_USED;
697 SCLRotation rotation = ui->get_rotation();
698 ise_show_emoticon_layout(current_emoticon_group, ROTATION_TO_DEGREE(rotation), false, ime_get_main_window());
706 static void show_cbhm()
712 ret = cbhm_selection_type_set(cbhm_handle, static_cast<cbhm_sel_type_e>(cbhm_sel_type));
714 ret = cbhm_selection_type_set(cbhm_handle, CBHM_SEL_TYPE_TEXT);
716 if (ret != CBHM_ERROR_NONE)
717 LOGW("Failed to set selection type in cbhm. error : %d\n", ret);
719 ret = cbhm_show(cbhm_handle);
720 if (ret != CBHM_ERROR_NONE)
721 LOGW("cbhm show error : %d\n", ret);
727 SCLEventReturnType CUIEventCallback::on_event_notification(SCLUINotiType noti_type, SclNotiDesc *etc_info)
729 CSCLUI *ui = get_ui();
730 SCLEventReturnType ret = SCL_EVENT_PASS_ON;
731 LOGD("noti type: %d, g_need_send_shift_event: %d\n", noti_type, g_need_send_shift_event);
733 if (noti_type == SCL_UINOTITYPE_SHIFT_STATE_CHANGE) {
734 if (g_need_send_shift_event) {
735 const sclchar *cur_lang = _language_manager.get_current_language();
737 LANGUAGE_INFO *info = _language_manager.get_language_info(cur_lang);
738 SclNotiShiftStateChangeDesc *desc = static_cast<SclNotiShiftStateChangeDesc*>(etc_info);
740 if (info->accepts_caps_mode) {
741 LOGD("shift state: %d\n", desc->shift_state);
742 if (desc->shift_state == SCL_SHIFT_STATE_OFF) {
743 if (info->load_in_ime)
744 ime_send_imengine_event(MVK_Shift_Off, 0);
746 engine_loader_send_imengine_event(MVK_Shift_Off, 0);
747 } else if (desc->shift_state == SCL_SHIFT_STATE_ON) {
748 if (info->load_in_ime)
749 ime_send_imengine_event(MVK_Shift_On, 0);
751 engine_loader_send_imengine_event(MVK_Shift_On, 0);
752 } else if (desc->shift_state == SCL_SHIFT_STATE_LOCK) {
753 if (info->load_in_ime)
754 ime_send_imengine_event(MVK_Shift_Lock, 0);
756 engine_loader_send_imengine_event(MVK_Shift_Lock, 0);
758 ret = SCL_EVENT_PASS_ON;
762 g_need_send_shift_event = FALSE;
764 } else if (noti_type == SCL_UINOTITYPE_POPUP_OPENING) {
765 vector<string>::reverse_iterator iter = g_recent_used_punctuation.rbegin();
767 for (; iter != g_recent_used_punctuation.rend(); ++iter)
770 ui->set_string_substitution(g_current_punctuation[punc_pos].c_str(), iter->c_str());
773 SclNotiPopupOpeningDesc *openingDesc = (SclNotiPopupOpeningDesc *)etc_info;
774 if (ui && 0 == strcmp(openingDesc->input_mode, "CM_POPUP")) {
775 if (ise_is_emoticons_disabled())
776 ui->enable_button("EMOTICON_KEY", false);
778 ui->enable_button("EMOTICON_KEY", true);
780 } else if (noti_type == SCL_UINOTITYPE_POPUP_OPENED) {
781 g_popup_opened = TRUE;
782 SclNotiPopupOpenedDesc *openedDesc = (SclNotiPopupOpenedDesc *)etc_info;
783 if (0 == strcmp(openedDesc->input_mode, "PUNCTUATION_POPUP")) {
784 g_punctuation_popup_opened = TRUE;
785 } else if (0 == strcmp(openedDesc->input_mode, "CM_POPUP")) {
786 _cm_popup_opened = TRUE;
788 } else if (noti_type == SCL_UINOTITYPE_POPUP_CLOSED) {
789 g_popup_opened = FALSE;
790 SclNotiPopupClosedDesc *closedDesc = (SclNotiPopupClosedDesc *)etc_info;
791 if (closedDesc && closedDesc->input_mode) {
792 if (0 == strcmp(closedDesc->input_mode, "PUNCTUATION_POPUP")) {
793 g_punctuation_popup_opened = FALSE;
794 } else if (0 == strcmp(closedDesc->input_mode, "CM_POPUP")) {
795 _cm_popup_opened = FALSE;
798 } else if (noti_type == SCL_UINOTITYPE_INPUT_MODE_CHANGE) {
799 SclNotiInputModeChangeDesc *desc = static_cast<SclNotiInputModeChangeDesc*>(etc_info);
801 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_NONE);
803 const char *input_mode = ui->get_input_mode();
805 if (strcmp(input_mode, "STT_3X4") == 0 &&
806 strcmp(desc->input_mode, "STT_3X4") != 0) {
809 if (strcmp(input_mode, "STT_3X4") != 0 &&
810 strcmp(desc->input_mode, "STT_3X4") == 0) {
811 ise_show_stt_mode(NATIVE_WINDOW_CAST(ime_get_main_window()));
820 void ise_destory_popup_setting()
822 if (_guide_popup_setting != NULL) {
823 LOGD("destroy setting popup iter\n");
824 evas_object_del(_guide_popup_setting);
825 _guide_popup_setting = NULL;
826 CONFIG_VALUES *config_values = get_config_values();
828 config_values->first_guideset = TRUE;
830 write_ise_config_values();
834 void ise_destory_popup_space()
836 if (_guide_popup_space != NULL) {
837 LOGD("destroy space popup iter\n");
838 evas_object_del(_guide_popup_space);
839 _guide_popup_setting = NULL;
840 CONFIG_VALUES *config_values = get_config_values();
842 config_values->first_guidechange = TRUE;
844 write_ise_config_values();
848 Evas_Object *open_message_popup(Evas_Object *parentWnd)
850 static Evas_Object *msg_window = NULL;
852 evas_object_del(msg_window);
855 msg_window = elm_win_add(parentWnd, "MCFMessagePopup", ELM_WIN_UTILITY);
858 elm_win_borderless_set(msg_window, EINA_TRUE);
859 elm_win_alpha_set(msg_window, EINA_TRUE);
860 elm_win_title_set(msg_window, "ISF Popup");
861 elm_win_screen_size_get(msg_window, NULL, NULL, &w, &h);
862 elm_win_prop_focus_skip_set(msg_window, TRUE);
863 int rots[4] = {0, 90, 180, 270};
864 elm_win_wm_rotation_available_rotations_set(msg_window, rots, 4);
865 evas_object_resize(msg_window, w, h);
868 int rots[4] = { 0, 90, 180, 270 };
869 elm_win_wm_rotation_available_rotations_set(msg_window, rots, 4);
870 evas_object_show(msg_window);
874 void _guideline_popup_setting_cb(void *data, Evas_Object *obj, void *event_info)
876 evas_object_smart_callback_del(obj, "dismissed", _guideline_popup_setting_cb);
877 evas_object_del(obj);
879 ise_destory_popup_setting();
880 CONFIG_VALUES *config_values = get_config_values();
882 config_values->first_guideset = TRUE;
884 write_ise_config_values();
887 void _guideline_popup_space_cb(void *data, Evas_Object *obj, void *event_info)
889 evas_object_smart_callback_del(obj, "dismissed", _guideline_popup_space_cb);
890 evas_object_del(obj);
892 ise_destory_popup_space();
893 CONFIG_VALUES *config_values = get_config_values();
895 config_values->first_guidechange = TRUE;
897 write_ise_config_values();
900 void ise_show_help_popup(sclulong keyEvent)
902 char buf[2048] = {0, };
906 SclRectangle rectangle = {0};
907 Evas_Object *ctxpopup = NULL;
908 Elm_Theme *theme = NULL;
910 CSCLUI *ui = get_ui();
912 ui->get_screen_resolution(&scr_w, &scr_h);
914 if (keyEvent == MVK_space) {
915 CONFIG_VALUES *config_values = get_config_values();
917 config_values->first_guidechange = TRUE;
919 write_ise_config_values();
920 ui->get_button_geometry("SPACE_KEY", &rectangle);
921 _guide_popup_space = open_message_popup(NATIVE_WINDOW_CAST(ime_get_main_window()));
923 theme = elm_theme_new();
924 elm_theme_ref_set(theme, NULL);
925 elm_theme_extension_add(theme, EDJ_FILE);
927 ctxpopup = elm_ctxpopup_add(_guide_popup_space);
928 elm_object_theme_set(ctxpopup, theme);
929 evas_object_smart_callback_add(ctxpopup, "dismissed", _guideline_popup_space_cb, (void *)keyEvent);
931 CONFIG_VALUES *config_values = get_config_values();
933 config_values->first_guideset = TRUE;
935 write_ise_config_values();
936 ui->get_button_geometry("CM_KEY", &rectangle);
937 _guide_popup_setting = open_message_popup(NATIVE_WINDOW_CAST(ime_get_main_window()));
938 theme = elm_theme_new();
939 elm_theme_ref_set(theme, NULL);
940 elm_theme_extension_add(theme, EDJ_FILE);
941 ctxpopup = elm_ctxpopup_add(_guide_popup_setting);
942 elm_object_theme_set(ctxpopup, theme);
943 evas_object_smart_callback_add(ctxpopup, "dismissed", _guideline_popup_setting_cb, (void *)keyEvent);
947 int rotation = elm_win_rotation_get(NATIVE_WINDOW_CAST(ime_get_main_window()));
948 if (rotation == 0 || rotation == 180) {
949 elm_object_style_set(ctxpopup, "customised_guideline_popup");
951 elm_object_style_set(ctxpopup, "customised_guideline_popup_landscape");
954 elm_ctxpopup_direction_priority_set(ctxpopup, ELM_CTXPOPUP_DIRECTION_UP,
955 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
956 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
957 ELM_CTXPOPUP_DIRECTION_UNKNOWN);
959 Evas_Object* text = elm_label_add(ctxpopup);
961 if (keyEvent == MVK_space) {
962 snprintf(buf, sizeof(buf), "<font_style=Regular font_size=%d align=left wrap=mixed color=#000000>%s</>", font_size,
963 dgettext(PACKAGE, "IDS_IME_BODY_SWIPE_THE_SPACE_BAR_LEFT_OR_RIGHT_TO_CHANGE_BETWEEN_LANGUAGES"));
965 snprintf(buf, sizeof(buf), "<font_style=Regular font_size=%d align=left wrap=mixed color=#000000>%s</>", font_size,
966 dgettext(PACKAGE, "IDS_IME_BODY_TAP_AND_HOLD_THIS_KEY_TO_SEE_THE_SYMBOL_LIST_SELECT_ONE_TO_USE_IT_AS_A_SHORTCUT"));
968 elm_object_text_set(text, buf);
969 elm_object_content_set(ctxpopup, text);
970 Evas_Coord x, y, w, h;
971 evas_object_geometry_get(NATIVE_WINDOW_CAST(ime_get_main_window()), &x, &y, &w, &h);
973 if (rotation == 0 || rotation == 180) {
974 elm_label_wrap_width_set(text, (scr_w * 4) / 5);
975 evas_object_size_hint_min_set(ctxpopup, ELM_SCALE_SIZE(scr_w), ELM_SCALE_SIZE(50));
976 evas_object_size_hint_max_set(ctxpopup, ELM_SCALE_SIZE(scr_w), ELM_SCALE_SIZE(600));
977 evas_object_move(ctxpopup, rectangle.x + rectangle.width / 2,
978 (scr_h - h) + rectangle.y - ELM_SCALE_SIZE(5));
980 elm_label_wrap_width_set(text, (scr_h * 4) / 5);
981 evas_object_size_hint_min_set(ctxpopup, ELM_SCALE_SIZE(scr_h), ELM_SCALE_SIZE(50));
982 evas_object_size_hint_max_set(ctxpopup, ELM_SCALE_SIZE(scr_h), ELM_SCALE_SIZE(600));
983 evas_object_move(ctxpopup, rectangle.x + rectangle.width / 2,
984 (scr_w - h)+ rectangle.y - ELM_SCALE_SIZE(5));
986 elm_label_line_wrap_set(text, ELM_WRAP_MIXED);
987 evas_object_show(text);
989 if (keyEvent == MVK_space) {
990 evas_object_layer_set(_guide_popup_space, EVAS_LAYER_MAX);
991 evas_object_show(_guide_popup_space);
993 evas_object_layer_set(_guide_popup_setting, EVAS_LAYER_MAX);
994 evas_object_show(_guide_popup_setting);
997 evas_object_layer_set(ctxpopup, EVAS_LAYER_MAX);
998 evas_object_show(ctxpopup);
1001 SCLEventReturnType CUIEventCallback::on_event_drag_state_changed(SclUIEventDesc event_desc)
1003 LOGD("button %s is clicked\n", event_desc.key_value);
1004 if (event_desc.event_type == EVENT_TYPE_MOVE) {
1005 if (event_desc.key_event == MVK_space) {
1006 SclRectangle rectangle = {0};
1007 CSCLUI *ui = get_ui();
1008 if (ui) ui->get_button_geometry("SPACE_KEY", &rectangle);
1009 ise_show_space_flick_language_change_popup(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
1011 } else if (event_desc.event_type == EVENT_TYPE_RELEASE) {
1012 if (event_desc.key_event == MVK_space) {
1013 ise_destroy_space_flick_language_change_popup();
1016 if (g_floating_mode)
1017 ime_set_floating_drag_end();
1018 } else if (event_desc.event_type == EVENT_TYPE_PRESS) {
1020 CONFIG_VALUES *config_values = get_config_values();
1022 if (config_values && (!config_values->first_guideset) && event_desc.key_value && (strncmp(event_desc.key_value, "OPTION", strlen(event_desc.key_value)) == 0)) {
1023 ise_show_help_popup(event_desc.key_event);//show help popup in on_event_drag_state_changed other than on_event_key_clicked for fixing help popup show delay issue
1024 LOGD("setting popup show\n");
1025 return SCL_EVENT_PASS_ON;
1027 ise_destory_popup_setting();//destory popup manually in case of abnormal situation
1030 if (g_floating_mode && event_desc.mouse_current_point.y <= FLOATING_TITLE_BAR_HEIGHT
1031 && event_desc.mouse_current_point.y >= 0)
1032 ime_set_floating_drag_start();
1034 return SCL_EVENT_PASS_ON;
1037 static void launch_option()
1039 app_control_h app_control;
1040 int ret = app_control_create(&app_control);
1041 if (ret != APP_CONTROL_ERROR_NONE) {
1042 LOGW("app_control_create returned %d\n", ret);
1046 ret = app_control_set_operation(app_control, APP_CONTROL_OPERATION_DEFAULT);
1047 if (ret != APP_CONTROL_ERROR_NONE) {
1048 LOGW("app_control_set_operation returned %d\n", ret);
1052 ret = app_control_set_app_id(app_control, "org.tizen.ise-default-setting");
1053 if (ret != APP_CONTROL_ERROR_NONE) {
1054 LOGW("app_control_set_app_id returned %d\n", ret);
1058 app_control_add_extra_data(app_control, "caller", "ise-default");
1059 app_control_set_launch_mode(app_control, APP_CONTROL_LAUNCH_MODE_GROUP);
1061 ret = app_control_send_launch_request(app_control, NULL, NULL);
1062 if (ret != APP_CONTROL_ERROR_NONE) {
1068 app_control_destroy(app_control);
1071 SCLEventReturnType CUIEventCallback::on_event_key_clicked(SclUIEventDesc event_desc)
1073 SCLEventReturnType ret = SCL_EVENT_PASS_ON;
1074 if (word_timer != NULL) {
1075 ecore_timer_del(word_timer);
1079 KEYBOARD_STATE *keyboard_state = get_keyboard_state();
1080 if (!keyboard_state) return ret;
1082 if (event_desc.key_modifier == KEY_MODIFIER_MULTITAP_START) {
1083 if (!keyboard_state->multitap_value.empty()) {
1084 ise_send_string(keyboard_state->multitap_value.c_str());
1086 ise_update_preedit_string(event_desc.key_value);
1087 keyboard_state->multitap_value = event_desc.key_value;
1088 } else if (event_desc.key_modifier == KEY_MODIFIER_MULTITAP_REPEAT) {
1089 ise_update_preedit_string(event_desc.key_value);
1090 keyboard_state->multitap_value = event_desc.key_value;
1092 _reset_multitap_state();
1094 keyboard_state->prev_modifier = event_desc.key_modifier;
1096 CSCLUI *ui = get_ui();
1098 switch (event_desc.key_type) {
1099 case KEY_TYPE_STRING: {
1100 if (event_desc.key_modifier != KEY_MODIFIER_MULTITAP_START &&
1101 event_desc.key_modifier != KEY_MODIFIER_MULTITAP_REPEAT) {
1102 if (event_desc.key_event) {
1103 ise_forward_key_event(event_desc.key_event);
1105 ise_send_string(event_desc.key_value);
1108 if (!g_popup_opened) {
1109 const sclchar *input_mode = ui->get_input_mode();
1110 if (input_mode && ((0 == strcmp(input_mode, "SYM_QTY_1")) || (0 == strcmp(input_mode, "SYM_QTY_2")))) {
1111 update_recent_used_punctuation(event_desc.key_value);
1113 } else if (g_punctuation_popup_opened) {
1114 update_recent_used_punctuation(event_desc.key_value);
1118 case KEY_TYPE_CHAR: {
1119 sclboolean need_forward = FALSE;
1120 // FIXME : Should decide when to forward key events
1121 const sclchar *input_mode = ui->get_input_mode();
1123 if (strcmp(input_mode, "SYM_QTY_1") == 0 ||
1124 strcmp(input_mode, "SYM_QTY_2") == 0 ||
1125 strcmp(input_mode, "PHONE_3X4") == 0 ||
1126 strcmp(input_mode, "IPv6_3X4_123") == 0 ||
1127 strcmp(input_mode, "IPv6_3X4_ABC") == 0 ||
1128 strcmp(input_mode, "NUMONLY_3X4") == 0 ||
1129 strcmp(input_mode, "NUMONLY_3X4_SIG") == 0 ||
1130 strcmp(input_mode, "NUMONLY_3X4_DEC") == 0 ||
1131 strcmp(input_mode, "NUMONLY_3X4_SIGDEC") == 0 ||
1132 strcmp(input_mode, "DATETIME_3X4") == 0) {
1133 need_forward = TRUE;
1136 if (input_mode && strcmp (input_mode, "NUMONLY_3X4_SIGDEC") == 0 &&
1137 strcmp(event_desc.key_value, ".") == 0) {
1138 ime_update_preedit_string(_sig_dec[_click_count%SIG_DEC_SIZE], NULL);
1139 ime_show_preedit_string();
1140 delete_commit_timer();
1141 _commit_timer = ecore_timer_add(1.0, commit_timeout, NULL);
1143 } else if (event_desc.key_event) {
1144 commit_timeout(NULL);
1146 ise_forward_key_event(event_desc.key_event);
1148 if (_cm_popup_opened) {
1149 static sclchar current_cm_symbol[2] = {'\0'};
1150 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
1151 const_cast<sclchar*>(" "),
1152 const_cast<sclchar*>(" "),
1153 const_cast<sclchar*>(" ")};
1154 if (event_desc.key_value) {
1155 current_cm_symbol[0] = event_desc.key_value[0];
1156 current_cm_symbol[1] = '\0';
1158 ui->set_private_key("CM_KEY",
1159 const_cast<sclchar*>(current_cm_symbol),
1160 imagelabel, NULL, 0,
1161 const_cast<sclchar*>(current_cm_symbol), TRUE);
1163 _cm_popup_opened = FALSE;
1164 _current_cm_key_id = -1;
1169 *change the keyboard mode of GLM from QWERTY to KEYPAD
1170 *ensure the Number keypad won't be affected
1173 if (keyboard_state->layout == ISE_LAYOUT_STYLE_NUMBER) {
1174 ime_send_key_event(IME_KEY_Print, IME_KEY_MASK_CONTROL, false);
1176 if (word_timer == NULL && (!get_candidate() || !g_softcandidate_show)) {
1177 word_timer = ecore_timer_add(MULTITAP_TIMEOUT, _multi_tap_timer_cb, NULL);
1179 ime_send_key_event(IME_KEY_Select, IME_KEY_MASK_CONTROL, false);
1182 ise_send_event(event_desc.key_event, KEY_MASK_NULL);
1186 if ((strcmp(input_mode, "SYM_QTY_1") == 0) || (0 == strcmp(input_mode, "SYM_QTY_2"))) {
1187 update_recent_used_punctuation(event_desc.key_value);
1192 case KEY_TYPE_CONTROL: {
1193 commit_timeout(NULL);
1195 const char *long_shift = "LongShift";
1196 const char *caps_lock = "CapsLock";
1197 const char *delete_all = "DeleteAll";
1198 const char *hide_panel = "Hide";
1199 if (strncmp(event_desc.key_value, long_shift, strlen(long_shift)) == 0) {
1200 LOGD("shift key is longpress\n");
1201 ui->set_shift_state(SCL_SHIFT_STATE_ON);
1202 g_need_send_shift_event = TRUE;
1203 //ise_send_event (MVK_Shift_Lock, KEY_MASK_NULL);
1204 } else if (strncmp(event_desc.key_value, caps_lock, strlen(caps_lock)) == 0) {
1205 bool load_in_ime = false;
1206 const sclchar *cur_lang = _language_manager.get_current_language();
1208 LANGUAGE_INFO *info = _language_manager.get_language_info(cur_lang);
1210 load_in_ime = info->load_in_ime;
1213 if (ui->get_shift_state() != SCL_SHIFT_STATE_LOCK) {
1214 ui->set_shift_state(SCL_SHIFT_STATE_LOCK);
1216 ime_send_imengine_event(MVK_Shift_Lock, 0);
1218 engine_loader_send_imengine_event(MVK_Shift_Lock, 0);
1220 ui->set_shift_state(SCL_SHIFT_STATE_OFF);
1222 ime_send_imengine_event(MVK_Shift_Off, 0);
1224 engine_loader_send_imengine_event(MVK_Shift_Off, 0);
1226 //g_need_send_shift_event = TRUE;
1227 } else if (strncmp(event_desc.key_value, delete_all, strlen(delete_all)) == 0) {
1228 ime_delete_surrounding_text((INT_MAX / 2) * -1, INT_MAX);
1229 } else if (strncmp(event_desc.key_value, hide_panel, strlen(hide_panel)) == 0) {
1232 } else if (event_desc.key_event) {
1233 if (keyboard_state->layout == ISE_LAYOUT_STYLE_VOICE) {
1237 if (event_desc.key_event == MVK_Done) {
1239 //commit the preedit string first
1240 ise_send_event(event_desc.key_event, KEY_MASK_NULL);
1243 ise_send_event(event_desc.key_event, KEY_MASK_NULL);
1244 if (event_desc.key_event == MVK_Shift_L) {
1245 g_need_send_shift_event = TRUE;
1250 case KEY_TYPE_MODECHANGE:
1252 if (_guide_popup_setting != NULL) {//popup is showing
1256 if (strcmp(event_desc.key_value, USER_VOICE_LANGUAGE) == 0) {
1257 if (!g_setting_window_open_status) {
1258 ise_hide_stt_mode();
1260 hide_indicator_window();
1262 create_setting_window();
1264 } else if (strcmp(event_desc.key_value, USER_KEYSTRING_VOICE) == 0) {
1265 keyboard_state->layout = ISE_LAYOUT_STYLE_VOICE;
1266 ui->set_input_mode("STT_3X4");
1268 } else if (strcmp(event_desc.key_value, USER_KEYSTRING_OPTION) == 0) {
1271 ret = SCL_EVENT_DONE;
1272 } else if (strcmp(event_desc.key_value, USER_KEYSTRING_CLIPBOARD) == 0) {
1275 ret = SCL_EVENT_DONE;
1276 } else if (strcmp(event_desc.key_value, USER_KEYSTRING_FLOATING) == 0) {
1277 CONFIG_VALUES *config_values = get_config_values();
1279 if (g_floating_mode) {
1280 if (config_values) {
1281 config_values->floating_mode = false;
1284 if (config_values) {
1285 config_values->floating_mode = true;
1288 write_ise_config_values();
1290 ret = SCL_EVENT_DONE;
1291 } else if (on_input_mode_changed(event_desc.key_value, event_desc.key_event, event_desc.key_type)) {
1292 ret = SCL_EVENT_DONE;
1294 if (_cm_popup_opened) {
1295 if (strcmp(event_desc.key_value, USER_KEYSTRING_EMOTICON) == 0 ||
1296 strcmp(event_desc.key_value, USER_KEYSTRING_VOICE) == 0 ||
1297 strcmp(event_desc.key_value, USER_KEYSTRING_FLOATING) == 0) {
1298 scluint id = ise_get_cm_key_id(event_desc.key_value);
1299 if (id != _current_cm_key_id) {
1300 _current_cm_key_id = id;
1301 ise_set_cm_private_key(_current_cm_key_id);
1304 _cm_popup_opened = FALSE;
1306 if (strlen(event_desc.key_value) == 1) {
1307 const char allowed_chars_in_modechange[] = {
1308 ',', '?', '!', '`', '~'
1310 const int allowed_chars_in_modechange_num =
1311 sizeof(allowed_chars_in_modechange) / sizeof(char);
1312 for (unsigned int loop = 0;loop < sizeof(allowed_chars_in_modechange_num);loop++) {
1313 if (*(event_desc.key_value) == allowed_chars_in_modechange[loop]) {
1314 ise_send_string(event_desc.key_value);
1320 if (strcmp(event_desc.key_value, USER_KEYSTRING_OPTION) == 0) {
1321 //open_option_window(NULL, ROTATION_TO_DEGREE(ui->get_rotation()));
1324 ret = SCL_EVENT_DONE;
1325 } else if (strcmp(event_desc.key_value, USER_KEYSTRING_CLIPBOARD) == 0) {
1327 ret = SCL_EVENT_DONE;
1328 } else if (strcmp(event_desc.key_value, "Cancel") == 0) {
1329 ret = SCL_EVENT_DONE;
1330 const sclchar *input_mode = ui->get_input_mode();
1331 if (input_mode && strcmp(input_mode, "STT_3X4") == 0 ) {
1332 keyboard_state->need_reset = TRUE;
1333 voice_result_string_flush();
1334 ise_set_layout(keyboard_state->layout, keyboard_state->layout_variation);
1335 if (keyboard_state->visible_state)
1336 ise_show(keyboard_state->ic);
1338 ise_send_event(IME_KEY_Cancel, KEY_MASK_NULL);
1340 } else if (strcmp(event_desc.key_value, "Done") == 0) {
1341 ret = SCL_EVENT_DONE;
1342 ise_send_event(IME_KEY_Return, KEY_MASK_NULL);
1345 const sclchar *input_mode = ui->get_input_mode();
1346 if ((NULL != input_mode) && (!strcmp(input_mode, "EMOTICON_LAYOUT"))) {
1347 if (is_emoticon_show()) {
1348 ise_destroy_emoticon_layout();
1351 emoticon_group_t group_id = EMOTICON_GROUP_1;
1352 if (current_emoticon_group < EMOTICON_GROUP_3)
1353 group_id = (emoticon_group_t)(current_emoticon_group + 1);
1355 ise_set_emoticon_label(group_id);
1357 emoticon_group_t group_id = ise_get_emoticon_group_id(event_desc.key_value);
1359 if ((group_id >= 0) && (group_id < MAX_EMOTICON_GROUP)) {
1360 SCLRotation rotation = ui->get_rotation();
1361 ise_show_emoticon_layout(group_id, ROTATION_TO_DEGREE(rotation), false, ime_get_main_window());
1365 if (_cm_popup_opened) {
1366 if (strcmp(event_desc.key_value, USER_KEYSTRING_OPTION) == 0 ||
1367 strcmp(event_desc.key_value, USER_KEYSTRING_CLIPBOARD) == 0) {
1368 scluint id = ise_get_cm_key_id(event_desc.key_value);
1369 if (id != _current_cm_key_id) {
1370 _current_cm_key_id = id;
1371 ise_set_cm_private_key(_current_cm_key_id);
1374 _cm_popup_opened = FALSE;
1386 ise_set_layout(sclu32 layout, sclu32 layout_variation)
1388 /* Check if the layoutIdx is in the valid range */
1389 KEYBOARD_STATE *keyboard_state = get_keyboard_state();
1390 if (layout < ISE_LAYOUT_STYLE_MAX) {
1391 if (keyboard_state->layout != layout ||
1392 keyboard_state->layout_variation != layout_variation) {
1393 keyboard_state->need_reset = TRUE;
1395 keyboard_state->layout = layout;
1396 keyboard_state->layout_variation = layout_variation;
1397 LOGD("layout:%d, variation:%d\n", keyboard_state->layout, keyboard_state->layout_variation);
1405 _reset_multitap_state(true);
1406 CONFIG_VALUES *config_values = get_config_values();
1407 if (config_values) {
1408 _language_manager.reset_language(config_values->selected_language.c_str());
1413 ise_reset_input_context()
1416 _reset_multitap_state(true);
1417 KEYBOARD_STATE *keyboard_state = get_keyboard_state();
1418 if (keyboard_state) keyboard_state->disable_force_latin = FALSE;
1419 CONFIG_VALUES *config_values = get_config_values();
1420 if (config_values) {
1421 _language_manager.reset_language(config_values->selected_language.c_str());
1426 ise_focus_in(int ic)
1428 KEYBOARD_STATE *keyboard_state = get_keyboard_state();
1429 if (!keyboard_state) return;
1431 LOGD("ic : %x , %x , g_ic : %x , %x, g_focused_ic : %x , %x\n", ic, check_ic_temporary(ic),
1432 keyboard_state->ic, check_ic_temporary(keyboard_state->ic),
1433 keyboard_state->focused_ic, check_ic_temporary(keyboard_state->focused_ic));
1434 if (check_ic_temporary(keyboard_state->ic) && !check_ic_temporary(ic)) {
1435 keyboard_state->ic = ic;
1437 keyboard_state->focused_ic = ic;
1440 static void save_autofill_data()
1445 if (g_autofill_hint == 0)
1448 ime_get_surrounding_text(-1, -1, &text, &cursor);
1449 SECURE_LOGD("surrounding text : %s\n", text);
1452 autofill_save_string(g_app_id.c_str(), g_resource_id.c_str(), (Ecore_IMF_Input_Hints)g_autofill_hint, text);
1458 ise_focus_out(int ic)
1460 KEYBOARD_STATE *keyboard_state = get_keyboard_state();
1461 if (keyboard_state) keyboard_state->focused_ic = 0;
1462 _reset_multitap_state(true);
1464 save_autofill_data();
1467 bool ise_is_guideline_popup_enable_layout(void)
1470 switch (_context_layout)
1472 case ISE_LAYOUT_STYLE_PHONENUMBER:
1473 case ISE_LAYOUT_STYLE_IP:
1474 case ISE_LAYOUT_STYLE_MONTH:
1475 case ISE_LAYOUT_STYLE_NUMBERONLY:
1476 case ISE_LAYOUT_STYLE_HEX:
1477 case ISE_LAYOUT_STYLE_TERMINAL:
1478 case ISE_LAYOUT_STYLE_DATETIME:
1479 case ISE_LAYOUT_STYLE_PASSWORD:
1489 #if EXIT_ISE_ON_HIDE
1490 static Eina_Bool exit_timer_cb(void *data)
1492 if (exit_timer) ecore_timer_del(exit_timer);
1495 return ECORE_CALLBACK_CANCEL;
1502 CONFIG_VALUES *config_values = get_config_values();
1503 #if EXIT_ISE_ON_HIDE
1504 if (exit_timer) ecore_timer_del(exit_timer);
1507 sclboolean reset_inputmode = FALSE;
1508 g_input_panel_show = true;
1510 CSCLUI *ui = get_ui();
1511 KEYBOARD_STATE *keyboard_state = get_keyboard_state();
1512 if (ui && keyboard_state) {
1513 read_ise_config_values();
1515 if (config_values) {
1516 _language_manager.set_enabled_languages(config_values->enabled_languages);
1518 const sclchar *cur_lang = _language_manager.get_current_language();
1521 ise_check_wearable_candidate();
1523 *Clear the personalized data
1525 if (config_values && config_values->dataclear) {
1526 ime_send_key_event(IME_KEY_Clear, IME_KEY_MASK_CONTROL, false);
1527 config_values->dataclear = FALSE;
1530 LOGD("ic : %x , %x , g_ic : %x , %x, g_focused_ic : %x , %x\n", ic, check_ic_temporary(ic),
1531 keyboard_state->ic, check_ic_temporary(keyboard_state->ic),
1532 keyboard_state->focused_ic, check_ic_temporary(keyboard_state->focused_ic));
1534 if (check_ic_temporary(ic) && !check_ic_temporary(keyboard_state->focused_ic)) {
1535 ic = keyboard_state->focused_ic;
1538 if (!check_ic_temporary(ic) && check_ic_temporary(keyboard_state->focused_ic)) {
1539 keyboard_state->focused_ic = ic;
1542 if (ic == keyboard_state->focused_ic) {
1543 if (keyboard_state->layout == ISE_LAYOUT_STYLE_PHONENUMBER ||
1544 keyboard_state->layout == ISE_LAYOUT_STYLE_IP ||
1545 keyboard_state->layout == ISE_LAYOUT_STYLE_MONTH ||
1546 keyboard_state->layout == ISE_LAYOUT_STYLE_NUMBERONLY) {
1547 ime_set_engine_loader_flag(true);
1548 engine_loader_set_imengine(DEFAULT_KEYBOARD_ISE_UUID, DEFAULT_KEYBOARD_ISE_PKGID);
1552 const char *input_mode = ui->get_input_mode();
1554 /* Reset input mode if the input context value has changed */
1555 if (ic != keyboard_state->ic) {
1556 /* Do not reset input mode if STT's setting window was opened */
1557 if (g_setting_window_open_status && input_mode && strcmp(input_mode, "STT_3X4") == 0) {
1558 LOGD("Setting window was opened while using STT, skip resetting input mode");
1560 reset_inputmode = TRUE;
1564 keyboard_state->ic = ic;
1565 /* Reset input mode if the current language is not the selected language */
1567 if (config_values && config_values->selected_language.compare(cur_lang) != 0) {
1568 reset_inputmode = TRUE;
1572 /* No matter what, just reset the inputmode if it needs to */
1573 if (keyboard_state->need_reset) {
1574 /* Do not reset input mode if STT's setting window was opened */
1575 if (g_setting_window_open_status && input_mode && strcmp(input_mode, "STT_3X4") == 0) {
1576 LOGD("Setting window was opened while using STT, skip resetting input mode");
1578 reset_inputmode = TRUE;
1581 keyboard_state->need_reset = FALSE;
1583 /* If the current layout requires latin language and current our language is not latin, enable the primary latin */
1584 sclboolean force_primary_latin = FALSE;
1585 LANGUAGE_INFO *info =
1586 (config_values ? _language_manager.get_language_info(config_values->selected_language.c_str()) : NULL);
1588 if (g_ise_default_values[keyboard_state->layout].force_latin && !(info->is_latin_language)) {
1589 if (!keyboard_state->disable_force_latin) {
1590 force_primary_latin = TRUE;
1594 if (force_primary_latin) {
1595 /* If there is enabled latin-based language, select it */
1596 sclboolean selected = FALSE;
1597 for (scluint loop = 0;!selected && loop < _language_manager.get_languages_num();loop++) {
1598 LANGUAGE_INFO *info = _language_manager.get_language_info(loop);
1600 if (info->enabled && info->is_latin_language) {
1601 selected = _language_manager.select_language(info->name.c_str());
1602 if (selected) force_primary_latin = FALSE;
1607 _language_manager.set_language_enabled_temporarily(PRIMARY_LATIN_LANGUAGE, TRUE);
1611 if (reset_inputmode) {
1612 ise_reset_context();
1614 bool filename_layout = false;
1616 /* Turn the shift state off if we need to reset our input mode, only when auto-capitalization is not set */
1617 if (!(keyboard_state->caps_mode)) {
1618 ui->set_shift_state(SCL_SHIFT_STATE_OFF);
1620 if (keyboard_state->layout < ISE_LAYOUT_STYLE_MAX) {
1621 sclu32 layout_index = keyboard_state->layout;
1622 if (keyboard_state->layout == ISE_LAYOUT_STYLE_NUMBERONLY &&
1623 keyboard_state->layout_variation > 0 &&
1624 keyboard_state->layout_variation < ISE_LAYOUT_NUMBERONLY_VARIATION_MAX) {
1625 layout_index = ISE_LAYOUT_STYLE_NUMBERONLY_SIG + keyboard_state->layout_variation - 1;
1626 } else if (keyboard_state->layout == ISE_LAYOUT_STYLE_PASSWORD && keyboard_state->layout_variation > 0) {
1627 layout_index = ISE_LAYOUT_STYLE_PASSWD_3X4;
1630 if (keyboard_state->layout == ISE_LAYOUT_STYLE_NORMAL &&
1631 keyboard_state->layout_variation == ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL_VARIATION_FILENAME)
1632 filename_layout = true;
1634 filename_layout = false;
1636 ui->enable_button("exclamation", !filename_layout);
1637 ui->enable_button("question", !filename_layout);
1638 ui->enable_button("divide", !filename_layout);
1639 ui->enable_button("multiply", !filename_layout);
1640 ui->enable_button("colon", !filename_layout);
1641 ui->enable_button("quotation", !filename_layout);
1643 ui->enable_button("CM_KEY", !access("/home", X_OK));
1645 LOGD("new layout index : %d\n", layout_index);
1646 /* If this layout requires specific input mode, set it */
1647 if (strlen(g_ise_default_values[layout_index].input_mode) > 0) {
1648 ui->set_input_mode(g_ise_default_values[layout_index].input_mode);
1649 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_NONE);
1651 if (force_primary_latin) {
1652 _language_manager.select_language(PRIMARY_LATIN_LANGUAGE, TRUE);
1653 } else if (config_values) {
1654 if (!(_language_manager.select_language(config_values->selected_language.c_str()))) {
1655 _language_manager.select_language(PRIMARY_LATIN_LANGUAGE);
1659 ui->set_cur_sublayout(g_ise_default_values[layout_index].sublayout_name);
1660 if (is_emoticon_show()) {
1661 ise_destroy_emoticon_layout();
1664 if (keyboard_state->layout == ISE_LAYOUT_STYLE_EMOTICON) {
1665 ise_init_emoticon_list();
1667 current_emoticon_group = EMOTICON_GROUP_1;
1668 ise_set_emoticon_label(1);
1670 if (emoticon_list_recent.size() == 0)
1671 current_emoticon_group = EMOTICON_GROUP_1;
1673 current_emoticon_group = EMOTICON_GROUP_RECENTLY_USED;
1675 SCLRotation rotation = ui->get_rotation();
1676 ise_show_emoticon_layout(current_emoticon_group, ROTATION_TO_DEGREE(rotation), false, ime_get_main_window());
1682 if (info->accepts_caps_mode) {
1683 // FIXME this if condition means the AC is off
1684 if (keyboard_state->layout != ISE_LAYOUT_STYLE_NORMAL) {
1685 ui->set_autocapital_shift_state(TRUE);
1686 ui->set_shift_state(SCL_SHIFT_STATE_OFF);
1688 ise_send_event(MVK_Shift_Enable, KEY_MASK_NULL);
1689 // Auto Capital is supported only in normal layout
1690 if (keyboard_state->caps_mode) {
1691 ui->set_autocapital_shift_state(FALSE);
1695 ui->set_autocapital_shift_state(TRUE);
1696 ise_send_event(MVK_Shift_Disable, KEY_MASK_NULL);
1697 ui->set_shift_state(SCL_SHIFT_STATE_OFF);
1700 ui->set_autocapital_shift_state(TRUE);
1703 // Update CM key button
1704 if (_current_cm_key_id < CM_KEY_LIST_SIZE) {
1705 if (strcmp(_cm_key_list[_current_cm_key_id], USER_KEYSTRING_EMOTICON) == 0) {
1706 if (ise_is_emoticons_disabled())
1707 ise_set_cm_private_key(ise_get_cm_key_id(USER_KEYSTRING_OPTION));
1709 ise_set_cm_private_key(_current_cm_key_id);
1713 // Update space key button
1714 ise_update_space_key();
1717 ui->disable_input_events(FALSE);
1719 ui->enable_button("CM_KEY", false);
1723 if (ise_is_guideline_popup_enable_layout()) {
1724 if ((config_values && config_values->first_guidechange) && (_language_manager.get_enabled_languages_num() > 1)) {
1725 ise_show_help_popup(MVK_space);
1726 LOGD("space popup show\n");
1728 ise_destory_popup_space();
1734 if (config_values && config_values->floating_mode != g_floating_mode)
1735 g_floating_mode = config_values->floating_mode;
1737 Candidate *candidate = get_candidate();
1738 if (candidate && candidate->get_visible())
1739 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_SHOW);
1741 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_NONE);
1744 keyboard_state->visible_state = TRUE;
1748 switch (_context_layout) {
1749 case ISE_LAYOUT_STYLE_PHONENUMBER:
1750 case ISE_LAYOUT_STYLE_IP:
1751 case ISE_LAYOUT_STYLE_MONTH:
1752 case ISE_LAYOUT_STYLE_NUMBERONLY:
1753 case ISE_LAYOUT_STYLE_DATETIME:
1754 case ISE_LAYOUT_STYLE_TERMINAL:
1757 case ISE_LAYOUT_STYLE_EMAIL:
1758 case ISE_LAYOUT_STYLE_URL:
1761 case ISE_LAYOUT_STYLE_PASSWORD:
1762 if (_context_layout == ISE_LAYOUT_STYLE_PASSWORD &&
1763 _context_layout_variation == ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD_VARIATION_NUMBERONLY)
1776 ui->get_screen_resolution(&width, &height);
1778 create_indicator_window(width, height);
1779 destroy_indicator_dots();
1782 switch (keyboard_state->layout) {
1783 case ISE_LAYOUT_STYLE_NUMBER:
1786 case ISE_LAYOUT_STYLE_HEX:
1789 case ISE_LAYOUT_STYLE_EMOTICON:
1792 case ISE_LAYOUT_STYLE_VOICE:
1793 if (_context_layout == ISE_LAYOUT_STYLE_EMAIL ||
1794 _context_layout == ISE_LAYOUT_STYLE_URL)
1803 create_indicator_dots(dot_num, focus_dot);
1804 show_indicator_window();
1806 hide_indicator_window();
1808 if (keyboard_state->layout == ISE_LAYOUT_STYLE_NORMAL && config_values && config_values->number_tutorial_enable) {
1809 ise_show_tutorial_mode_popup(keyboard_state->layout);
1810 config_values->number_tutorial_enable = false;
1811 write_ise_config_values();
1815 if (g_setting_window_open_status) {
1816 ise_show_stt_mode(NATIVE_WINDOW_CAST(ime_get_main_window()));
1818 g_setting_window_open_status = FALSE;
1820 if (keyboard_state->layout == ISE_LAYOUT_STYLE_VOICE) {
1821 ise_show_stt_mode(NATIVE_WINDOW_CAST(ime_get_main_window()));
1826 * Sets screen rotation
1829 ise_set_screen_rotation(int degree)
1831 CSCLUI *ui = get_ui();
1833 ui->set_rotation(DEGREE_TO_SCLROTATION(degree));
1836 Candidate *candidate = get_candidate();
1838 candidate->rotate(degree);
1839 if (g_softcandidate_show) {
1840 candidate->update(g_softcandidate_string);
1846 ise_set_accessibility_state(bool state)
1848 CSCLUI *ui = get_ui();
1850 ui->enable_tts(state);
1857 KEYBOARD_STATE *keyboard_state = get_keyboard_state();
1858 CSCLUI *ui = get_ui();
1860 /* There's no need to update screen when hiding */
1861 ui->set_update_pending(TRUE);
1862 ui->disable_input_events(TRUE);
1865 CONFIG_VALUES *config_values = get_config_values();
1866 if (config_values) {
1867 _language_manager.reset_language(config_values->selected_language.c_str());
1871 delete_commit_timer();
1872 ise_destory_popup_space();
1873 ise_destory_popup_setting();
1875 if (keyboard_state) keyboard_state->visible_state = FALSE;
1877 _reset_shift_state();
1878 _reset_multitap_state(true);
1880 /* If we were in STT mode, try to reset input mode on our next show event */
1881 if (ui && keyboard_state) {
1882 const char *inputmode = ui->get_input_mode();
1883 if (inputmode && strcmp(inputmode, "STT_3X4") == 0 ) {
1884 keyboard_state->need_reset = TRUE;
1885 ise_hide_stt_mode();
1889 g_input_panel_show = false;
1890 if (g_softcandidate_show && get_candidate())
1891 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_SHOW);
1893 hide_indicator_window();
1894 if (check_is_tutorial_show()) {
1895 ise_destroy_tutorial_mode_popup();
1898 #if EXIT_ISE_ON_HIDE
1899 if (exit_timer) ecore_timer_del(exit_timer);
1900 exit_timer = ecore_timer_add(1.0, exit_timer_cb, NULL);
1904 static void ise_keypad_mode_changed_cb(const char *key, void *user_data)
1906 read_ise_keypad_mode();
1909 static void ise_enabled_languages_changed_cb(const char *key, void *user_data)
1911 read_ise_enabled_languages();
1914 static void ise_selected_language_changed_cb(const char *key, void *user_data)
1916 read_ise_selected_language();
1919 static void ise_autocapital_mode_changed_cb(const char *key, void *user_data)
1921 read_ise_autocapital_mode();
1924 static void ise_autopunctuate_mode_changed_cb(const char *key, void *user_data)
1926 read_ise_autopunctuation_mode();
1929 static void ise_sound_mode_changed_cb(const char *key, void *user_data)
1931 read_ise_sound_mode();
1933 CONFIG_VALUES *config_values = get_config_values();
1934 CSCLUI *ui = get_ui();
1935 if (config_values && ui) {
1936 ui->enable_sound(config_values->sound_on);
1940 static void ise_vibration_mode_changed_cb(const char *key, void *user_data)
1942 read_ise_vibration_mode();
1944 CONFIG_VALUES *config_values = get_config_values();
1945 CSCLUI *ui = get_ui();
1946 if (config_values && ui) {
1947 ui->enable_vibration(config_values->vibration_on);
1951 static void ise_character_preview_mode_changed_cb(const char *key, void *user_data)
1953 read_ise_character_preview_mode();
1955 CONFIG_VALUES *config_values = get_config_values();
1956 CSCLUI *ui = get_ui();
1957 if (config_values && ui) {
1958 ui->enable_magnifier(config_values->preview_on);
1962 static void ise_setting_guide_popup_changed_cb(const char *key, void *user_data)
1964 read_ise_setting_guide_popup_mode();
1967 static void ise_language_guide_popup_changed_cb(const char *key, void *user_data)
1969 read_ise_language_guide_popup_mode();
1972 static void ise_floating_mode_changed_cb(const char *key, void *user_data)
1974 read_ise_floating_mode();
1975 CONFIG_VALUES *config_values = get_config_values();
1976 if (config_values) {
1977 g_floating_mode = config_values->floating_mode;
1980 ime_set_floating_mode(g_floating_mode);
1981 if (g_candidate && g_floating_mode != g_candidate->get_floating_mode()) {
1982 delete_softcandidate_hide_timer();
1986 create_softcandidate();
1987 if (g_candidate && g_candidate->get_visible()) {
1988 g_softcandidate_show = true;
1989 g_candidate->show();
1990 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_SHOW);
1994 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_NONE);
1997 static void register_preference_changed_callback(void)
1999 if (preference_set_changed_cb(ISE_CONFIG_KEYPAD_MODE, ise_keypad_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
2000 LOGW("Failed to set ise_keypad_mode_changed_cb()");
2002 if (preference_set_changed_cb(ISE_CONFIG_ENABLED_LANGUAGES, ise_enabled_languages_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
2003 LOGW("Failed to set ise_enabled_languages_changed_cb()");
2005 if (preference_set_changed_cb(ISE_CONFIG_SELECTED_LANGUAGE, ise_selected_language_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
2006 LOGW("Failed to set ise_selected_language_changed_cb()");
2008 if (preference_set_changed_cb(ISE_CONFIG_AUTO_CAPITALISE, ise_autocapital_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
2009 LOGW("Failed to set ise_autocapital_mode_changed_cb()");
2011 if (preference_set_changed_cb(ISE_CONFIG_AUTO_PUNCTUATE, ise_autopunctuate_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
2012 LOGW("Failed to set ise_autopunctuate_mode_changed_cb()");
2014 if (preference_set_changed_cb(ISE_CONFIG_SOUND_ON, ise_sound_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
2015 LOGW("Failed to set ise_sound_mode_changed_cb()");
2017 if (preference_set_changed_cb(ISE_CONFIG_VIBRATION_ON, ise_vibration_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
2018 LOGW("Failed to set ise_vibration_mode_changed_cb()");
2020 if (preference_set_changed_cb(ISE_CONFIG_PREVIEW_ON, ise_character_preview_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
2021 LOGW("Failed to set ise_character_preview_mode_changed_cb()");
2023 if (preference_set_changed_cb(ISE_CONFIG_FIRST_GUIDELINE_POPUP_FOR_SETTING, ise_setting_guide_popup_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
2024 LOGW("Failed to set ise_setting_guide_popup_changed_cb()");
2026 if (preference_set_changed_cb(ISE_CONFIG_FIRST_GUIDELINE_POPUP_FOR_LANGUAGE_CHANGE, ise_language_guide_popup_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
2027 LOGW("Failed to set ise_language_guide_popup_changed_cb()");
2029 if (preference_set_changed_cb(ISE_CONFIG_FLOATING_MODE, ise_floating_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
2030 LOGW("Failed to set ise_floating_mode_changed_cb()");
2033 static void ise_mount_changed_cb(void *user_data)
2035 register_preference_changed_callback();
2043 CONFIG_VALUES *config_values = get_config_values();
2049 bindtextdomain(PACKAGE, LOCALEDIR);
2050 textdomain(PACKAGE);
2052 /* Set scl_parser_type
2053 * default type is text xml
2054 * use command: export sclres_type="sclres_binary" to enable use binary resource
2055 * please make sure there is sclresource.bin in resource folder
2056 * Or you can use `xml2binary $resource_dir` to generate the sclresource.bin
2057 * xml2binary is in the libscl-ui-devel package
2059 SCLParserType scl_parser_type = SCL_PARSER_TYPE_XML;
2060 char* sclres_type = getenv("sclres_type");
2061 if (sclres_type != NULL && 0 == strcmp("sclres_binary", sclres_type)) {
2062 scl_parser_type = SCL_PARSER_TYPE_BINARY_XML;
2064 scl_parser_type = SCL_PARSER_TYPE_XML;
2068 if (ime_get_main_window()) {
2069 g_ise_created = true;
2071 sclboolean succeeded = FALSE;
2073 const sclchar *entry_path = MAIN_ENTRY_XML_PATH;
2076 CSCLUtils *utils = CSCLUtils::get_instance();
2078 utils->get_screen_resolution(&nwidth, &nheight);
2080 _language_manager.set_resource_file_path(entry_path);
2081 const sclchar *resource_file_path = _language_manager.get_resource_file_path();
2083 if (resource_file_path) {
2084 if (strlen(resource_file_path) > 0) {
2085 succeeded = g_ui->init(ime_get_main_window(), scl_parser_type, resource_file_path);
2089 g_ui->init(ime_get_main_window(), scl_parser_type, MAIN_ENTRY_XML_PATH);
2092 g_ui->set_longkey_duration(elm_config_longpress_timeout_get() * 1000);
2094 /* Default ISE callback */
2095 g_ui->set_ui_event_callback(&callback);
2097 /* Accumulated customized ISE callbacks, depending on the input modes */
2098 for (scluint loop = 0;loop < _language_manager.get_languages_num();loop++) {
2099 LANGUAGE_INFO *language = _language_manager.get_language_info(loop);
2101 for (scluint inner_loop = 0;inner_loop < language->input_modes.size();inner_loop++) {
2102 INPUT_MODE_INFO &info = language->input_modes.at(inner_loop);
2103 LOGD("Registering callback for input mode %s : %p\n", info.name.c_str(), language->callback);
2104 g_ui->set_ui_event_callback(language->callback, info.name.c_str());
2109 read_ise_config_values();
2110 if (config_values) {
2111 _language_manager.set_enabled_languages(config_values->enabled_languages);
2112 _language_manager.select_language(config_values->selected_language.c_str());
2113 vconf_set_bool(VCONFKEY_AUTOCAPITAL_ALLOW_BOOL, config_values->auto_capitalise);
2114 vconf_set_bool(VCONFKEY_AUTOPERIOD_ALLOW_BOOL, config_values->auto_punctuate);
2115 g_ui->enable_sound(config_values->sound_on);
2116 g_ui->enable_vibration(config_values->vibration_on);
2117 g_ui->enable_magnifier(config_values->preview_on);
2118 g_floating_mode = config_values->floating_mode;
2121 g_ui->enable_highlight_ui(TRUE);
2123 ime_set_floating_mode(g_floating_mode);
2126 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_NONE);
2130 preference_is_existing(ISE_CONFIG_KEYPAD_MODE, &exist);
2132 write_ise_config_values();
2135 if (ode_internal_encryption_get_state(&state) == ODE_ERROR_NONE) {
2136 if (state == ODE_STATE_ENCRYPTED) {
2137 if (ode_internal_encryption_set_mount_event_cb(ise_mount_changed_cb, NULL) != ODE_ERROR_NONE)
2138 LOGW("Failed to set mount_event_cb()");
2139 } else if (state == ODE_STATE_UNENCRYPTED) {
2140 register_preference_changed_callback();
2143 LOGW("Failed to get encryption_state");
2146 init_recent_used_punctuation();
2152 ise_hide_stt_mode();
2154 CSCLUI *ui = get_ui();
2156 LOGD("calling ui->fini()\n");
2158 LOGD("deleting ui\n");
2169 destroy_indicator_window();
2172 /* This is necessary. If this is not called, 3rd party IME might have auto period input regardless its settings */
2173 vconf_set_bool(VCONFKEY_AUTOPERIOD_ALLOW_BOOL, false);
2175 #if EXIT_ISE_ON_HIDE
2176 if (exit_timer) ecore_timer_del(exit_timer);
2182 ise_app_candidate_show()
2185 if (!g_softcandidate_show) {
2190 delete_softcandidate_hide_timer();
2192 create_softcandidate();
2194 g_softcandidate_show = true;
2195 Candidate *candidate = get_candidate();
2198 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_SHOW);
2203 ise_app_candidate_hide()
2207 Candidate *candidate = get_candidate();
2208 if (!candidate || !g_softcandidate_show) {
2209 LOGD("No candidate\n");
2213 if (g_ic_smartreply != -1 || g_autofill_exist)
2216 add_softcandidate_hide_timer();
2220 void ise_check_wearable_candidate()
2222 CONFIG_VALUES *config_values = get_config_values();
2223 if (!config_values) return;
2225 KEYBOARD_STATE *keyboard_state = get_keyboard_state();
2226 if (!keyboard_state) return;
2228 if (!config_values->prediction_on) {
2229 ise_app_candidate_hide();
2230 } else if (keyboard_state->layout == ISE_LAYOUT_STYLE_PHONENUMBER ||
2231 keyboard_state->layout == ISE_LAYOUT_STYLE_VOICE ||
2232 keyboard_state->layout == ISE_LAYOUT_STYLE_IP ||
2233 keyboard_state->layout == ISE_LAYOUT_STYLE_MONTH ||
2234 keyboard_state->layout == ISE_LAYOUT_STYLE_NUMBERONLY ||
2235 keyboard_state->layout == ISE_LAYOUT_STYLE_PASSWD_3X4||
2236 keyboard_state->layout == ISE_LAYOUT_STYLE_PASSWORD) {
2237 ise_app_candidate_hide();
2239 g_softcandidate_show = true;
2240 ise_app_candidate_show();
2244 void ise_set_emoticon_label(int group_id)
2246 const int BUF_LEN = 16;
2247 char buf[BUF_LEN] = {0};
2248 snprintf(buf, BUF_LEN, "%d/3", group_id);
2249 CSCLUI *ui = get_ui();
2250 if (ui) ui->set_private_key("EMOTICON_GROUP_ID", buf, NULL, NULL, 0, const_cast<sclchar*>("EMOTICON_GROUP_NEXT"), TRUE);
2254 // when it is the time to auto_cap, the
2255 // ise_set_caps_mode is called.
2256 // -------------------------------------------------------
2257 // For example: [How are you. Fine.], the
2258 // auto-capital process is as below:
2259 // Note: "["<--this is the beginning,
2260 // "|"<--this is the cursor position
2261 // 1) call ise_set_caps_mode, auto_cap = on
2264 // 2) call ise_set_caps_mode, auto_cap = off
2267 // 3) input: "w are you. "
2268 // result: [How are you. |
2269 // 4) call ise_set_caps_mode, auto_cap = on
2271 // result: [How are you. F
2273 // result: [How are you. Fine.|
2274 // --------------------------------------------------------
2275 // If we want to change the auto_cap, eg,
2276 // if we want to input [How Are you.]
2277 // Note the "Are" is not use auto-capital rule.
2279 // ise_send_event(MVK_Shift_On, SclCoreKeyMask_Null);
2280 // when we are want to input "A"
2281 // following input still has the auto_cap rule.
2283 ise_set_caps_mode(unsigned int mode)
2285 KEYBOARD_STATE *keyboard_state = get_keyboard_state();
2286 if (!keyboard_state) return;
2288 LOGD("caps_mode : %d\n", mode);
2290 keyboard_state->caps_mode = TRUE;
2292 keyboard_state->caps_mode = FALSE;
2294 g_caps_mode_pending = false;
2295 const sclchar *cur_lang = _language_manager.get_current_language();
2297 LANGUAGE_INFO *info = _language_manager.get_language_info(cur_lang);
2299 if (info->accepts_caps_mode) {
2300 /* If we are inputting multitap character, do not manipulate shift mode */
2301 if (keyboard_state->prev_modifier != KEY_MODIFIER_MULTITAP_START &&
2302 keyboard_state->prev_modifier != KEY_MODIFIER_MULTITAP_REPEAT) {
2303 set_caps_mode(keyboard_state->caps_mode);
2305 g_caps_mode_pending = true;
2306 LOGD("Currently composing multitap string, skipping caps request");
2314 ise_update_cursor_position(int position)
2316 KEYBOARD_STATE *keyboard_state = get_keyboard_state();
2317 if (!keyboard_state) return;
2319 LOGD("cursor position : %d\n", position);
2320 CSCLUI *ui = get_ui();
2321 if (ui && keyboard_state->layout == ISE_LAYOUT_STYLE_URL) {
2324 ui->set_string_substitution("www.", ".com");
2326 ui->unset_string_substitution("www.");
2332 void ise_set_return_key_type(unsigned int type)
2334 const int BUF_LEN = 256;
2335 char buf[BUF_LEN] = {0};
2337 CSCLUI *ui = get_ui();
2340 LOGD("return key type : %d\n", type);
2343 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE:
2344 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_DONE);
2346 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_GO:
2347 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_GO);
2349 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_JOIN:
2350 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_JOIN);
2352 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_LOGIN:
2353 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_LOGIN);
2355 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT:
2356 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_NEXT);
2358 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH:
2359 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_SEARCH);
2361 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEND:
2362 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_SEND);
2364 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SIGNIN:
2365 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_SIGNIN);
2367 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT:
2370 LOGW("Unknown return key type : %d\n", type);
2371 type = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
2375 if (type == ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT) {
2376 ui->unset_private_key("Enter");
2378 ui->unset_private_key("Done");
2382 if (type == ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH) {
2383 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
2384 const_cast<sclchar*>("w_sip_3x4_btn_ic_search.png"),
2385 const_cast<sclchar*>("w_sip_3x4_btn_ic_search_p.png"),
2386 const_cast<sclchar*>("w_sip_3x4_btn_ic_search_d.png")};
2387 ui->set_private_key("Enter", const_cast<sclchar*>(""), imagelabel, NULL, 0, const_cast<sclchar*>("Enter"), TRUE);
2393 ui->set_private_key("Done", buf, NULL, NULL, 0, const_cast<sclchar*>("Done"), TRUE);
2395 static sclchar *imagelabel[SCL_BUTTON_STATE_MAX] = {
2396 const_cast<sclchar*>(" "), const_cast<sclchar*>(" "), const_cast<sclchar*>(" ")
2399 ui->set_private_key("Enter", buf, imagelabel, NULL, 0, const_cast<sclchar*>("Enter"), TRUE);
2401 LOGD("return key label : %s\n", buf);
2405 void ise_set_return_key_disable(unsigned int disabled)
2407 CSCLUI *ui = get_ui();
2408 LOGD("enable : %d\n", !disabled);
2411 ui->enable_button("Done", !disabled);
2414 ui->enable_button("Enter", !disabled);
2418 void ise_get_language_locale(char **locale)
2420 LANGUAGE_INFO *info = _language_manager.get_current_language_info();
2422 if (!(info->locale_string.empty())) {
2423 *locale = strdup(info->locale_string.c_str());
2428 void ise_update_table(const vector<string> &vec_str)
2430 Candidate *candidate = get_candidate();
2431 if (!candidate || !g_softcandidate_show)
2432 create_softcandidate();
2435 candidate->update(vec_str);
2439 void ise_process_key_event(scim::KeyEvent& key, sclu32 &ret)
2441 Eina_Bool back_key_pressed = EINA_FALSE;
2442 Eina_Bool back_key_released = EINA_FALSE;
2444 if (key.get_key_string().compare("XF86Back") == 0) {
2445 back_key_pressed = EINA_TRUE;
2446 } else if (key.get_key_string().compare("KeyRelease+XF86Back") == 0) {
2447 back_key_released = EINA_TRUE;
2450 if (back_key_pressed || back_key_released) {
2451 if (g_popup_opened == TRUE) {
2452 if (back_key_released) {
2453 CSCLUI *ui = get_ui();
2454 if (ui) ui->close_all_popups();
2462 CSCLUI *ui = get_ui();
2464 Candidate *candidate = get_candidate();
2466 if (!candidate->soft_candidate_flag()) {
2468 if (key.dev_name.compare("ime") != 0) {
2469 ret = (sclu32)ui->process_key_event(key.get_key_string().c_str());
2474 ret = candidate->soft_candidate_handle_key_event(key.get_key_string().c_str());
2478 /* Process this key event if it was not generated by ime */
2479 if (key.dev_name.compare("ime") != 0) {
2480 ret = (sclu32)ui->process_key_event(key.get_key_string().c_str());
2486 /* Process this key event if it was not generated by ime */
2487 if (key.dev_name.compare("ime") != 0) {
2488 ret = (sclu32)ui->process_key_event(key.get_key_string().c_str());
2494 static void init_recent_used_punctuation()
2496 if (g_recent_used_punctuation.empty())
2498 g_recent_used_punctuation.push_back("#");
2499 g_recent_used_punctuation.push_back("$");
2500 g_recent_used_punctuation.push_back("%");
2501 g_recent_used_punctuation.push_back("^");
2502 g_recent_used_punctuation.push_back("&");
2506 static void update_recent_used_punctuation(const char * key_value)
2508 if (NULL == key_value)
2512 for (int i = 0; i < 10; ++i)
2515 snprintf(buf, sizeof(buf), "%d", i);
2516 if (strcmp(key_value, buf) == 0)
2521 string strKey = string(key_value);
2522 for (int i = 0; i < MAX_DEFAULT_PUNCTUATION; ++i)
2524 if (0 == strKey.compare(g_default_punctuation[i].c_str()))
2529 vector<string>::iterator iter = g_recent_used_punctuation.begin();
2530 for (; iter != g_recent_used_punctuation.end(); ++iter)
2532 if (0 == strKey.compare(iter->c_str()))
2537 if (iter != g_recent_used_punctuation.end())
2539 g_recent_used_punctuation.erase(iter);
2541 g_recent_used_punctuation.push_back(strKey);
2542 if (g_recent_used_punctuation.size() > MAX_DEFAULT_PUNCTUATION-1)
2544 g_recent_used_punctuation.erase(g_recent_used_punctuation.begin());
2548 static void set_ime_size(bool floating_mode, ISE_CANDIDATE_REQUEST candidate_req)
2550 CSCLUI *ui = get_ui();
2554 Candidate *candidate = get_candidate();
2556 const char *input_mode = ui->get_input_mode();
2560 SclSize size_portrait = ui->get_input_mode_size(input_mode, DISPLAYMODE_PORTRAIT);
2561 SclSize size_landscape = ui->get_input_mode_size(input_mode, DISPLAYMODE_LANDSCAPE);
2563 if (floating_mode) {
2564 size_portrait.width *= FLOATING_SCALE_RATE;
2565 size_portrait.height *= FLOATING_SCALE_RATE;
2566 size_landscape.width *= FLOATING_SCALE_RATE;
2567 size_landscape.height *= FLOATING_SCALE_RATE;
2568 switch (candidate_req) {
2569 case ISE_CANDIDATE_REQ_NONE:
2570 if (candidate && candidate->get_visible()) {
2571 ui->set_custom_starting_coordinates(0, FLOATING_TITLE_BAR_HEIGHT + candidate->get_height());
2572 size_portrait.height += candidate->get_height();
2573 size_landscape.height += candidate->get_height();
2575 ui->set_custom_starting_coordinates(0, FLOATING_TITLE_BAR_HEIGHT);
2578 case ISE_CANDIDATE_REQ_SHOW:
2579 ui->set_custom_starting_coordinates(0, FLOATING_TITLE_BAR_HEIGHT + candidate->get_height());
2580 if (g_input_panel_show || g_candidate_more_view) {
2581 size_portrait.height += candidate->get_height();
2582 size_landscape.height += candidate->get_height();
2584 size_portrait.height = candidate->get_height();
2585 size_landscape.height = candidate->get_height();
2588 case ISE_CANDIDATE_REQ_HIDE:
2589 ui->set_custom_starting_coordinates(0, FLOATING_TITLE_BAR_HEIGHT);
2594 if (ui->get_custom_scale_rate_x() != FLOATING_SCALE_RATE || ui->get_custom_scale_rate_y() != FLOATING_SCALE_RATE)
2595 ui->set_custom_scale_rate(FLOATING_SCALE_RATE, FLOATING_SCALE_RATE);
2597 ime_set_size(size_portrait.width, size_portrait.height + FLOATING_TITLE_BAR_HEIGHT,
2598 size_landscape.width, size_landscape.height + FLOATING_TITLE_BAR_HEIGHT);
2600 #if defined(_MOBILE) || defined(_COMMON)
2601 ise_destroy_move_handler();
2602 int rotation = elm_win_rotation_get(NATIVE_WINDOW_CAST(ime_get_main_window()));
2603 int handler_width = (rotation == 0 || rotation == 180) ? size_portrait.width : size_landscape.width;
2604 ise_show_move_handler(handler_width, FLOATING_TITLE_BAR_HEIGHT);
2607 switch (candidate_req) {
2608 case ISE_CANDIDATE_REQ_NONE:
2609 if (candidate && candidate->get_visible()) {
2610 ui->set_custom_starting_coordinates(0, candidate->get_height());
2611 size_portrait.height += candidate->get_height();
2612 size_landscape.height += candidate->get_height();
2614 ui->set_custom_starting_coordinates(0, 0);
2617 case ISE_CANDIDATE_REQ_SHOW:
2618 ui->set_custom_starting_coordinates(0, candidate->get_height());
2619 if (g_input_panel_show || g_candidate_more_view) {
2620 size_portrait.height += candidate->get_height();
2621 size_landscape.height += candidate->get_height();
2623 size_portrait.height = candidate->get_height();
2624 size_landscape.height = candidate->get_height();
2627 case ISE_CANDIDATE_REQ_HIDE:
2628 ui->set_custom_starting_coordinates(0, 0);
2633 if (ui->get_custom_scale_rate_x() != 1.0 || ui->get_custom_scale_rate_y() != 1.0)
2634 ui->set_custom_scale_rate(1.0, 1.0);
2636 ime_set_size(size_portrait.width, size_portrait.height, size_landscape.width, size_landscape.height);
2638 #if defined(_MOBILE) || defined(_COMMON)
2639 ise_destroy_move_handler();
2644 static void ime_app_create_cb(void *user_data)
2646 if (!engine_loader_dbus_init(NULL))
2647 LOGE("Failed to initialize dbus");
2649 #if !(DEFER_ISE_CREATION)
2652 elm_app_name_set(PACKAGE);
2654 char *elm_scale = getenv("ELM_SCALE");
2655 LOGD("ELM_SCALE : %s", elm_scale);
2658 elm_app_base_scale_set(atof(elm_scale));
2661 cbhm_open_service(&cbhm_handle);
2665 static void ime_app_exit_cb(void *user_data)
2670 if (!engine_loader_dbus_shutdown())
2671 LOGE("Failed to finalize dbus");
2674 cbhm_close_service(cbhm_handle);
2679 static void show_autofill_data(Ecore_IMF_Input_Hints input_hints)
2681 g_autofill_exist = false;
2682 char *text = autofill_get_string(g_app_id.c_str(), g_resource_id.c_str(), input_hints);
2685 g_autofill_string = string(text);
2688 g_autofill_string = string("");
2690 SECURE_LOGD("autofill string : %s", g_autofill_string.c_str());
2692 if (g_autofill_string.length() > 0) {
2693 g_autofill_exist = true;
2695 ise_app_candidate_show();
2696 update_candidate_table();
2700 static void ime_app_show_cb(int ic, ime_context_h ime_ctx, void *user_data)
2702 Ise_Context iseContext;
2703 bool return_key_state, prediction_allow, password_mode, caps_mode;
2704 ime_layout_variation_e layout_variation;
2709 ime_context_get_layout(ime_ctx, &iseContext.layout);
2711 ime_context_get_layout_variation(ime_ctx, &layout_variation);
2712 iseContext.layout_variation = (int)layout_variation;
2714 ime_context_get_cursor_position(ime_ctx, &iseContext.cursor_pos);
2715 ime_context_get_autocapital_type(ime_ctx, &iseContext.autocapital_type);
2716 ime_context_get_return_key_type(ime_ctx, &iseContext.return_key_type);
2717 ime_context_get_return_key_state(ime_ctx, &return_key_state);
2719 ime_context_get_prediction_mode(ime_ctx, &prediction_allow);
2720 iseContext.prediction_allow = prediction_allow;
2722 ime_context_get_password_mode(ime_ctx, &password_mode);
2723 iseContext.password_mode = password_mode;
2725 ime_context_get_input_hint(ime_ctx, &iseContext.input_hint);
2726 ime_context_get_bidi_direction(ime_ctx, &iseContext.bidi_direction);
2727 ime_context_get_language(ime_ctx, &iseContext.language);
2728 ime_context_get_caps_mode(ime_ctx, &caps_mode);
2729 iseContext.caps_mode = caps_mode;
2731 iseContext.return_key_disabled = return_key_state;
2733 engine_loader_set_input_hint((uint32_t)iseContext.input_hint);
2734 engine_loader_update_bidi_direction((uint32_t)iseContext.bidi_direction);
2738 g_autofill_hint = iseContext.input_hint & ECORE_IMF_INPUT_HINT_AUTOFILL_MASK;
2740 LOGD("input hint : %x, autofill hint : %x\n", iseContext.input_hint, g_autofill_hint);
2742 // show autofill data
2743 show_autofill_data((Ecore_IMF_Input_Hints)g_autofill_hint);
2745 //g_ise_common->set_keyboard_ise_by_uuid(KEYBD_ISE_UUID);
2747 /* Don't update screen until all the information is correctly set */
2748 CSCLUI *ui = get_ui();
2750 ui->set_update_pending(TRUE);
2752 ise_reset_context(); // reset ISE
2754 /*if (context.language == ECORE_IMF_INPUT_PANEL_LANG_ALPHABET) {
2755 ise_explictly_set_language(PRIMARY_LATIN_LANGUAGE_INDEX);
2758 _context_layout = iseContext.layout;
2759 _context_layout_variation = iseContext.layout_variation;
2760 ise_set_layout(iseContext.layout, iseContext.layout_variation);
2762 ise_set_return_key_type(iseContext.return_key_type);
2763 ise_set_return_key_disable(iseContext.return_key_disabled);
2765 ise_set_caps_mode(iseContext.caps_mode);
2766 ise_update_cursor_position(iseContext.cursor_pos);
2770 /* Now we update the whole screen */
2772 ui->set_update_pending(FALSE);
2775 static void ime_app_hide_cb(int ic, void *user_data)
2780 g_set_mime_type = FALSE;
2782 g_ic_smartreply = -1;
2785 static void ime_app_return_key_type_set_cb(Ecore_IMF_Input_Panel_Return_Key_Type type, void *user_data)
2787 KEYBOARD_STATE *keyboard_state = get_keyboard_state();
2788 if (!keyboard_state) return;
2790 LOGD("return key type : %d\n", type);
2791 ise_set_return_key_type(type);
2793 if (keyboard_state->visible_state)
2794 ise_show(keyboard_state->ic);
2797 static void ime_app_return_key_state_set_cb(bool disabled, void *user_data)
2799 LOGD("return key disabled : %d\n", disabled);
2800 ise_set_return_key_disable(disabled);
2803 static void ime_app_language_set_cb(Ecore_IMF_Input_Panel_Lang language, void *user_data)
2805 LOGD("language : %d\n", language);
2808 static void ime_app_input_context_reset_cb(void *user_data)
2810 ise_reset_input_context();
2811 engine_loader_reset_input_context();
2814 static void ime_app_cursor_position_updated_cb(int cursor_pos, void *user_data)
2816 LOGD("cursor position : %d\n", cursor_pos);
2817 ise_update_cursor_position(cursor_pos);
2818 engine_loader_update_cursor_position(cursor_pos);
2821 static void ime_app_language_requested_cb(void *user_data, char **lang_code)
2823 ise_get_language_locale(lang_code);
2826 static void ime_app_surrounding_text_updated_cb(int context_id, const char *text, int cursor_pos, void *user_data)
2828 SECURE_LOGD("surrounding text:%s, cursor=%d\n", text, cursor_pos);
2829 ime_delete_surrounding_text(-cursor_pos, strlen(text));
2832 static void ime_app_focus_in_cb(int context_id, void *user_data)
2835 ise_focus_in(context_id);
2836 Candidate *candidate = get_candidate();
2837 if (!g_smartreply_reply_exist && g_softcandidate_show) {
2839 ise_app_candidate_hide();
2844 engine_loader_focus_in();
2847 static void ime_app_focus_out_cb(int context_id, void *user_data)
2850 ise_focus_out(context_id);
2853 g_set_mime_type = FALSE;
2855 g_smartreply_reply_exist = false;
2856 g_smartreply_size = 0;
2857 input_smartreply_deinit();
2858 g_ic_smartreply = -1;
2860 g_autofill_exist = false;
2861 g_autofill_hint = 0;
2863 g_app_id = string("");
2864 g_resource_id = string("");
2866 g_autofill_string = string("");
2867 g_smartreply_strings.clear();
2868 g_lookup_table_strings.clear();
2869 g_softcandidate_string.clear();
2871 engine_loader_focus_out();
2874 static void ime_app_layout_set_cb(Ecore_IMF_Input_Panel_Layout layout, void *user_data)
2876 KEYBOARD_STATE *keyboard_state = get_keyboard_state();
2877 if (!keyboard_state) return;
2879 LOGD("layout=%d\n", layout);
2880 /* Check if the layoutIdx is in the valid range */
2881 if (static_cast<int>(layout) < static_cast<int>(ISE_LAYOUT_STYLE_MAX)) {
2882 if (keyboard_state->layout != layout) {
2883 keyboard_state->need_reset = TRUE;
2885 keyboard_state->layout = layout;
2886 _context_layout = layout;
2887 _context_layout_variation = 0;
2889 if (keyboard_state->visible_state)
2890 ise_show(keyboard_state->ic);
2892 engine_loader_set_layout(static_cast<uint32_t>(layout));
2895 static void ime_app_rotation_degree_changed_cb(int degree, void *user_data)
2897 KEYBOARD_STATE *keyboard_state = get_keyboard_state();
2898 if (!keyboard_state) return;
2900 CSCLUI *ui = get_ui();
2901 ise_set_screen_rotation(degree);
2903 LOGD("degree=%d\n", degree);
2904 #if defined(_MOBILE) || defined(_COMMON)
2905 if (ui && g_floating_mode) {
2907 ise_destroy_move_handler();
2908 if (degree == 0 || degree == 180) {
2909 SclSize size_portrait = ui->get_input_mode_size(ui->get_input_mode(), DISPLAYMODE_PORTRAIT);
2910 handler_width = size_portrait.width * FLOATING_SCALE_RATE;
2912 SclSize size_landscape = ui->get_input_mode_size(ui->get_input_mode(), DISPLAYMODE_LANDSCAPE);
2913 handler_width = size_landscape.width * FLOATING_SCALE_RATE;
2915 ise_show_move_handler(handler_width, FLOATING_TITLE_BAR_HEIGHT);
2918 if (is_emoticon_show()) {
2919 ise_destroy_emoticon_layout();
2921 if (keyboard_state->layout == ISE_LAYOUT_STYLE_VOICE) {
2922 ise_hide_stt_mode();
2924 if (keyboard_state->layout == ISE_LAYOUT_STYLE_EMOTICON) {
2925 ise_show_emoticon_layout(current_emoticon_group, degree, false, ime_get_main_window());
2927 const sclchar *input_mode = ui->get_input_mode();
2929 if (!(strcmp(input_mode, "EMOTICON_LAYOUT")))
2930 ise_show_emoticon_layout(current_emoticon_group, degree, false, ime_get_main_window());
2931 else if (!(strcmp(input_mode, "STT_3X4")))
2932 ise_show_stt_mode(NATIVE_WINDOW_CAST(ime_get_main_window()));
2937 static void ime_app_accessibility_state_changed_cb(bool state, void *user_data)
2939 LOGD("state=%d\n", state);
2940 ise_set_accessibility_state(state);
2943 static void ime_app_imdata_set_cb(void *data, unsigned int data_length, void *user_data)
2947 size_t _len = data_length;
2948 set_ise_imdata((sclchar *)data, _len);
2949 engine_loader_set_imdata((const char*)data, (uint32_t)data_length);
2952 static bool ime_app_process_key_event_cb(ime_key_code_e keycode, ime_key_mask_e keymask, ime_device_info_h dev_info, void *user_data)
2954 KEYBOARD_STATE *keyboard_state = get_keyboard_state();
2955 if (!keyboard_state) return FALSE;
2957 scim::KeyEvent key(keycode, keymask);
2959 char *dev_name = NULL;
2960 Ecore_IMF_Device_Class dev_class;
2961 Ecore_IMF_Device_Subclass dev_subclass;
2963 if (ime_device_info_get_name(dev_info, &dev_name) == IME_ERROR_NONE) {
2964 key.dev_name = dev_name;
2967 if (ime_device_info_get_class(dev_info, &dev_class) == IME_ERROR_NONE) {
2968 key.dev_class = dev_class;
2971 if (ime_device_info_get_subclass(dev_info, &dev_subclass) == IME_ERROR_NONE) {
2972 key.dev_subclass = dev_subclass;
2975 if (keyboard_state->visible_state)
2976 ise_process_key_event(key, ret);
2986 static bool ime_app_process_key_event_with_imengine_cb(scim::KeyEvent &key, void *user_data)
2989 LANGUAGE_INFO *info = _language_manager.get_language_info(_language_manager.get_current_language());
2990 if (info && info->need_surrounding_text)
2991 ret = engine_loader_process_key_event(key, true);
2993 ret = engine_loader_process_key_event(key, false);
2998 static void ime_app_caps_mode_changed_cb(int mode, void *user_data)
3000 ise_set_caps_mode(mode);
3003 static void ime_app_candidate_show_cb(int context_id, void *user_data)
3006 ise_check_wearable_candidate();
3008 ise_app_candidate_show();
3012 static void ime_app_candidate_hide_cb(int context_id, void *user_data)
3015 ise_check_wearable_candidate();
3017 ise_app_candidate_hide();
3021 static void ime_app_lookup_table_changed_cb(Eina_List *list, void *user_data)
3023 vector<string> candidate_strings;
3028 g_lookup_table_strings.clear();
3031 EINA_LIST_FOREACH(list, l, data) {
3032 candidate = (char *)data;
3034 g_lookup_table_strings.push_back(string(candidate));
3035 candidate_strings.push_back(string(candidate));
3040 if (g_smartreply_reply_exist) {
3041 if (candidate_strings[0] == "#" && candidate_strings[1] == "$") {
3044 ime_get_surrounding_text(0, 0, &text, &cursor);
3053 update_candidate_table();
3057 static void ime_app_process_input_device_event_cb(ime_input_device_type_e device_type, ime_input_device_event_h device_event, void *user_data)
3059 KEYBOARD_STATE *keyboard_state = get_keyboard_state();
3060 if (!keyboard_state) return;
3062 if (device_type == IME_INPUT_DEVICE_TYPE_ROTARY) {
3063 ime_input_device_rotary_direction_e direction;
3064 if (IME_ERROR_NONE == ime_input_device_rotary_get_direction(device_event, &direction)) {
3065 sclu32 new_layout = keyboard_state->layout;
3066 if (direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_CLOCKWISE) {
3067 LOGD("CLOCKWISE\n");
3068 switch (keyboard_state->layout) {
3069 case ISE_LAYOUT_STYLE_NORMAL:
3070 case ISE_LAYOUT_STYLE_EMAIL:
3071 case ISE_LAYOUT_STYLE_URL:
3072 case ISE_LAYOUT_STYLE_PASSWORD:
3073 if (_context_layout == ISE_LAYOUT_STYLE_PASSWORD &&
3074 _context_layout_variation == ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD_VARIATION_NUMBERONLY)
3075 ; // PASSWORD NUMBER ONLY, do nothing
3077 new_layout = ISE_LAYOUT_STYLE_NUMBER;
3079 case ISE_LAYOUT_STYLE_NUMBER:
3080 new_layout = ISE_LAYOUT_STYLE_HEX;
3082 case ISE_LAYOUT_STYLE_HEX:
3083 if (_context_layout == ISE_LAYOUT_STYLE_EMAIL ||
3084 _context_layout == ISE_LAYOUT_STYLE_URL)
3085 new_layout = ISE_LAYOUT_STYLE_VOICE;
3086 else if (_context_layout == ISE_LAYOUT_STYLE_PASSWORD)
3087 new_layout = _context_layout;
3089 new_layout = ISE_LAYOUT_STYLE_EMOTICON;
3091 case ISE_LAYOUT_STYLE_EMOTICON:
3092 if (_context_layout == ISE_LAYOUT_STYLE_EMAIL ||
3093 _context_layout == ISE_LAYOUT_STYLE_URL ||
3094 _context_layout == ISE_LAYOUT_STYLE_PASSWORD)
3095 new_layout = _context_layout;
3097 new_layout = ISE_LAYOUT_STYLE_VOICE;
3099 case ISE_LAYOUT_STYLE_VOICE:
3100 new_layout = ISE_LAYOUT_STYLE_NORMAL;
3105 } else if (direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_COUNTER_CLOCKWISE) {
3106 LOGD("COUNTER_CLOCKWISE\n");
3107 switch (keyboard_state->layout) {
3108 case ISE_LAYOUT_STYLE_NORMAL:
3109 case ISE_LAYOUT_STYLE_EMAIL:
3110 case ISE_LAYOUT_STYLE_URL:
3111 case ISE_LAYOUT_STYLE_PASSWORD:
3112 if (_context_layout == ISE_LAYOUT_STYLE_PASSWORD &&
3113 _context_layout_variation == ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD_VARIATION_NUMBERONLY)
3114 ; // PASSWORD NUMBER ONLY, do nothing
3115 else if (_context_layout == ISE_LAYOUT_STYLE_PASSWORD)
3116 new_layout = ISE_LAYOUT_STYLE_HEX;
3118 new_layout = ISE_LAYOUT_STYLE_VOICE;
3120 case ISE_LAYOUT_STYLE_NUMBER:
3121 if (_context_layout == ISE_LAYOUT_STYLE_EMAIL ||
3122 _context_layout == ISE_LAYOUT_STYLE_URL ||
3123 _context_layout == ISE_LAYOUT_STYLE_PASSWORD)
3124 new_layout = _context_layout;
3126 new_layout = ISE_LAYOUT_STYLE_NORMAL;
3128 case ISE_LAYOUT_STYLE_HEX:
3129 new_layout = ISE_LAYOUT_STYLE_NUMBER;
3131 case ISE_LAYOUT_STYLE_EMOTICON:
3132 new_layout = ISE_LAYOUT_STYLE_HEX;
3134 case ISE_LAYOUT_STYLE_VOICE:
3135 if (_context_layout == ISE_LAYOUT_STYLE_EMAIL ||
3136 _context_layout == ISE_LAYOUT_STYLE_URL)
3137 new_layout = ISE_LAYOUT_STYLE_HEX;
3139 new_layout = ISE_LAYOUT_STYLE_EMOTICON;
3146 CONFIG_VALUES *config_values = get_config_values();
3147 if (check_is_tutorial_show() && config_values) {
3148 read_ise_config_values();
3149 if ((direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_COUNTER_CLOCKWISE && !config_values->number_tutorial_enable && !config_values->symbol_tutorial_enable) ||
3150 (direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_CLOCKWISE && config_values->symbol_tutorial_enable)) {
3151 new_layout = keyboard_state->layout;
3152 } else if (direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_COUNTER_CLOCKWISE && config_values->symbol_tutorial_enable) {
3153 ise_destroy_tutorial_mode_popup();
3154 config_values->symbol_tutorial_enable = false;
3155 write_ise_config_values();
3156 } else if (direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_CLOCKWISE && !config_values->number_tutorial_enable) {
3157 ise_destroy_tutorial_mode_popup();
3158 new_layout = ISE_LAYOUT_STYLE_NUMBER;
3159 if (!config_values->symbol_tutorial_enable) {
3160 ise_show_tutorial_mode_popup(new_layout);
3161 config_values->symbol_tutorial_enable = true;
3162 write_ise_config_values();
3167 if (new_layout != keyboard_state->layout && new_layout < ISE_LAYOUT_STYLE_MAX) {
3168 keyboard_state->need_reset = TRUE;
3169 keyboard_state->layout = new_layout;
3171 if (keyboard_state->visible_state) {
3172 _reset_multitap_state();
3173 if (config_values) {
3174 _language_manager.reset_language(config_values->selected_language.c_str());
3176 ise_show(keyboard_state->ic);
3184 static void ime_app_prediction_hint_set_cb(const char *prediction_hint, void *user_data)
3186 char *sender = (char *)"mms";
3187 char *caller_id = (char *)"mms";
3188 char *hint = (char *)prediction_hint;
3190 if (!prediction_hint) return;
3191 SECURE_LOGD("prediction hint : %s\n", prediction_hint);
3193 if (strlen(prediction_hint) > 0) {
3194 input_smartreply_init(caller_id, sender, hint);
3195 input_smartreply_set_notify(_input_smartreply_notify_cb, NULL);
3197 if (input_smartreply_is_enabled()) {
3198 g_smartreply_size = 0;
3199 g_smartreply_reply_exist = false;
3201 input_smartreply_get_reply_async();
3206 static void ime_app_mime_type_set_request_cb(const char *mime_types, void *user_data)
3208 LOGD("mime type : %s\n", mime_types);
3211 g_set_mime_type = TRUE;
3213 string str(mime_types), text_key = "text/", image_key = "image/";
3215 if (str.find(text_key) != string::npos)
3216 cbhm_sel_type |= CBHM_SEL_TYPE_TEXT;
3218 if (str.find(image_key) != string::npos)
3219 cbhm_sel_type |= CBHM_SEL_TYPE_IMAGE;
3221 LOGD("cbhm_sel_type=0x%x", cbhm_sel_type);
3225 static void ime_app_prediction_hint_data_set_cb(const char *key, const char *value, void *user_data)
3227 SECURE_LOGD("key : %s, value : %s\n", key, value);
3229 if (string(key) == "appid")
3230 g_app_id = string(value ? value : "");
3231 else if (string(key) == "res_id")
3232 g_resource_id = string(value ? value : "");
3235 static void ime_app_autocapital_type_set_cb(uint32_t type, void *user_data)
3237 LOGD("autocapital type : %u\n", type);
3238 engine_loader_set_autocapital_type(type);
3241 static void ime_app_prediction_allow_set_cb(uint32_t prediction_allow, void *user_data)
3243 LOGD("prediction allow : %u\n", prediction_allow);
3244 engine_loader_set_prediction_allow(prediction_allow);
3247 static void ime_app_trigger_property_set_cb(const char *property, void *user_data)
3249 LOGD("trigger property : %s\n", property);
3250 engine_loader_trigger_property(property);
3253 static void ime_app_candidate_more_window_show_cb(void *user_data)
3256 engine_loader_show_candidate_more_window();
3259 static void ime_app_candidate_more_window_hide_cb(void *user_data)
3262 engine_loader_hide_candidate_more_window();
3265 static void ime_app_aux_select_cb(uint32_t item, void *user_data)
3267 LOGD("aux select : %u\n", item);
3268 engine_loader_select_aux(item);
3271 static void ime_app_candidate_select_cb(uint32_t item, void *user_data)
3273 LOGD("candidate select : %u\n", item);
3274 engine_loader_select_candidate(item);
3277 static void ime_app_candidate_table_page_up_cb(void *user_data)
3280 engine_loader_candidate_table_page_up();
3283 static void ime_app_candidate_table_page_down_cb(void *user_data)
3286 engine_loader_candidate_table_page_down();
3289 static void ime_app_candidate_table_page_size_chaned_cb(uint32_t size, void *user_data)
3291 LOGD("candidate page size : %u\n", size);
3292 engine_loader_change_candidate_page_size(size);
3295 static void ime_app_candidate_item_layout_set_cb(vector<uint32_t> item, void *user_data)
3297 LOGD("item layout size : %zu", item.size());
3298 engine_loader_set_candidate_item_layout(item);
3301 static void ime_app_displayed_candidate_number_chaned_cb(uint32_t page_num, void *user_data)
3303 LOGD("candidate number changed : %u\n", page_num);
3304 engine_loader_change_candidate_number(page_num);
3307 static void ime_app_candidate_item_long_pressed_cb(uint32_t index, void *user_data)
3309 LOGD("candidate item : %u\n", index);
3310 engine_loader_long_press_candidate_item(index);
3316 EXPORTED void ime_app_main(int argc, char **argv)
3318 ime_callback_s basic_callback = {
3325 ime_event_set_focus_in_cb(ime_app_focus_in_cb, NULL);
3326 ime_event_set_focus_out_cb(ime_app_focus_out_cb, NULL);
3327 ime_event_set_rotation_degree_changed_cb(ime_app_rotation_degree_changed_cb, NULL);
3328 ime_event_set_accessibility_state_changed_cb(ime_app_accessibility_state_changed_cb, NULL);
3329 ime_event_set_layout_set_cb(ime_app_layout_set_cb, NULL);
3330 ime_event_set_caps_mode_changed_cb(ime_app_caps_mode_changed_cb, NULL);
3331 ime_event_set_cursor_position_updated_cb(ime_app_cursor_position_updated_cb, NULL);
3332 ime_event_set_surrounding_text_updated_cb(ime_app_surrounding_text_updated_cb, NULL);
3333 ime_event_set_return_key_type_set_cb(ime_app_return_key_type_set_cb, NULL);
3334 ime_event_set_return_key_state_set_cb(ime_app_return_key_state_set_cb, NULL);
3335 ime_event_set_language_set_cb(ime_app_language_set_cb, NULL);
3336 ime_event_set_imdata_set_cb(ime_app_imdata_set_cb, NULL);
3337 ime_event_set_process_key_event_cb(ime_app_process_key_event_cb, NULL);
3338 ime_event_set_process_key_event_with_imengine_cb(ime_app_process_key_event_with_imengine_cb, NULL);
3340 ime_event_set_candidate_show_cb(ime_app_candidate_show_cb, NULL);
3341 ime_event_set_candidate_hide_cb(ime_app_candidate_hide_cb, NULL);
3342 ime_event_set_lookup_table_changed_cb(ime_app_lookup_table_changed_cb, NULL);
3345 ime_event_set_process_input_device_event_cb(ime_app_process_input_device_event_cb, NULL);
3348 ime_event_set_input_context_reset_cb(ime_app_input_context_reset_cb, NULL);
3349 ime_event_set_language_requested_cb(ime_app_language_requested_cb, NULL);
3351 ime_event_set_prediction_hint_set_cb(ime_app_prediction_hint_set_cb, NULL);
3352 ime_event_set_mime_type_set_request_cb(ime_app_mime_type_set_request_cb, NULL);
3353 ime_event_set_prediction_hint_data_set_cb(ime_app_prediction_hint_data_set_cb, NULL);
3355 ime_event_set_autocapital_type_set_cb(ime_app_autocapital_type_set_cb, NULL);
3356 ime_event_set_prediction_allow_set_cb(ime_app_prediction_allow_set_cb, NULL);
3357 ime_event_set_trigger_property_set_cb(ime_app_trigger_property_set_cb, NULL);
3358 ime_event_set_candidate_more_window_show_cb(ime_app_candidate_more_window_show_cb, NULL);
3359 ime_event_set_candidate_more_window_hide_cb(ime_app_candidate_more_window_hide_cb, NULL);
3360 ime_event_set_aux_select_cb(ime_app_aux_select_cb, NULL);
3361 ime_event_set_candidate_select_cb(ime_app_candidate_select_cb, NULL);
3362 ime_event_set_candidate_table_page_up_cb(ime_app_candidate_table_page_up_cb, NULL);
3363 ime_event_set_candidate_table_page_down_cb(ime_app_candidate_table_page_down_cb, NULL);
3364 ime_event_set_candidate_table_page_size_chaned_cb(ime_app_candidate_table_page_size_chaned_cb, NULL);
3365 ime_event_set_candidate_item_layout_set_cb(ime_app_candidate_item_layout_set_cb, NULL);
3366 ime_event_set_displayed_candidate_number_chaned_cb(ime_app_displayed_candidate_number_chaned_cb, NULL);
3367 ime_event_set_candidate_item_long_pressed_cb(ime_app_candidate_item_long_pressed_cb, NULL);
3369 #if DEFER_ISE_CREATION
3370 ime_set_window_creation_defer_flag(TRUE);
3373 ime_run(&basic_callback, NULL);
3379 EXPORTED int main(int argc, char *argv[])
3381 ime_app_main(argc, argv);