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
66 static cbhm_h cbhm_handle;
67 static sclu32 cbhm_sel_type = 0;
68 static sclboolean g_set_mime_type = FALSE;
71 int g_imdata_state = 0;
73 extern emoticon_group_t current_emoticon_group;
74 extern std::vector <int> emoticon_list_recent;
76 extern CONFIG_VALUES g_config_values;
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,
132 #define ISE_LAYOUT_NUMBERONLY_VARIATION_MAX 4
133 /*static const sclchar *_ise_numberonly_variation_name[ISE_LAYOUT_NUMBERONLY_VARIATION_MAX] = {
134 "DEFAULT", "SIG", "DEC", "SIGDEC"
137 #define SIG_DEC_SIZE 2
138 static scluint _click_count = 0;
139 static const char *_sig_dec[SIG_DEC_SIZE] = {".", "-"};
140 static scluint _sig_dec_event[SIG_DEC_SIZE] = {'.', '-'};
141 static Ecore_Timer *_commit_timer = NULL;
143 static sclu32 _context_layout = ISE_LAYOUT_STYLE_NORMAL;
144 static sclu32 _context_layout_variation = 0;
146 Candidate *g_candidate = NULL;
148 static ISELanguageManager _language_manager;
150 class CandidateEventListener: public EventListener
153 void on_event(const EventDesc &desc)
155 const MultiEventDesc &multidesc = dynamic_cast<const MultiEventDesc &>(desc);
156 LANGUAGE_INFO *info = _language_manager.get_language_info(_language_manager.get_current_language());
158 switch (multidesc.type) {
159 case MultiEventDesc::CANDIDATE_ITEM_MOUSE_DOWN:
160 if (g_autofill_exist) {
161 if (multidesc.index == 0) {
162 char *text = autofill_get_string(g_app_id.c_str(), g_resource_id.c_str(), (Ecore_IMF_Input_Hints)g_autofill_hint);
164 ise_send_string(text);
167 } else if (multidesc.index < (int)g_smartreply_size + 1) {
168 ise_send_string(g_softcandidate_string[multidesc.index].c_str());
170 if (info && info->load_in_ime)
171 ime_select_candidate(multidesc.index - g_smartreply_size - 1);
173 engine_loader_select_candidate(multidesc.index - g_smartreply_size - 1);
176 if (multidesc.index < (int)g_smartreply_size)
177 ise_send_string(g_softcandidate_string[multidesc.index].c_str());
179 if (info && info->load_in_ime)
180 ime_select_candidate(multidesc.index - g_smartreply_size);
182 engine_loader_select_candidate(multidesc.index - g_smartreply_size);
186 case MultiEventDesc::CANDIDATE_MORE_VIEW_SHOW:
187 // when more parts shows, click on the candidate will
188 // not affect the key click event
189 g_candidate_more_view = true;
190 if (!g_input_panel_show)
191 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_SHOW);
193 g_ui->disable_input_events(TRUE);
195 case MultiEventDesc::CANDIDATE_MORE_VIEW_HIDE:
196 g_candidate_more_view = false;
197 if (!g_input_panel_show)
198 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_SHOW);
200 g_ui->disable_input_events(FALSE);
206 static CandidateEventListener g_candidate_event_listener;
208 #define MVK_Shift_L 0xffe1
209 #define MVK_Caps_Lock 0xffe5
210 #define MVK_Shift_Off 0xffe1
211 #define MVK_Shift_On 0xffe2
212 #define MVK_Shift_Lock 0xffe6
213 #define MVK_Shift_Enable 0x9fe7
214 #define MVK_Shift_Disable 0x9fe8
215 #define MVK_space 0x020
216 #define MVK_Done 0xff0d
218 #define CM_KEY_LIST_SIZE 5
219 #define MULTITAP_TIMEOUT 3.0
220 #define USER_KEYSTRING_OPTION "OPTION"
221 #define USER_KEYSTRING_EMOTICON "EMOTICON_LAYOUT"
222 #define USER_KEYSTRING_CLIPBOARD "CLIPBOARD"
223 #define USER_KEYSTRING_VOICE "STT_3X4"
224 #define USER_KEYSTRING_FLOATING "FLOATING"
226 #define USER_VOICE_LANGUAGE "LANGUAGE"
228 static sclboolean _cm_popup_opened = FALSE;
229 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};
230 static scluint _current_cm_key_id = 0;
231 Evas_Object* _guide_popup_setting = NULL;
232 Evas_Object* _guide_popup_space = NULL;
235 * This callback class will receive all response events from SCL
236 * So you should perform desired tasks in this class.
238 class CUIEventCallback : public ISCLUIEventCallback
241 Ecore_Timer* word_timer = NULL;
242 static Eina_Bool _multi_tap_timer_cb(void *data)
245 ise_send_event(MVK_Done, KEY_MASK_NULL);
246 return ECORE_CALLBACK_CANCEL;
248 SCLEventReturnType on_event_key_clicked(SclUIEventDesc event_desc);
249 SCLEventReturnType on_event_drag_state_changed(SclUIEventDesc event_desc);
250 SCLEventReturnType on_event_notification(SCLUINotiType noti_type, SclNotiDesc *etc_info);
253 static CUIEventCallback callback;
255 static void update_candidate_table()
257 g_softcandidate_string.clear();
258 vector<string>::iterator iter;
260 // add autofill string
261 if (g_autofill_exist)
262 g_softcandidate_string.push_back(g_autofill_string);
264 // add lookup table string(s)
265 iter = g_lookup_table_strings.begin();
266 for (; iter != g_lookup_table_strings.end(); ++iter)
268 g_softcandidate_string.push_back(string(iter->c_str()));
271 ise_update_table(g_softcandidate_string);
274 static void _input_smartreply_notify_cb(void *user_data)
276 g_smartreply_strings.clear();
277 char *candidate = NULL;
279 if (input_smartreply_is_enabled()) {
280 /* Append newly added smartreply list */
281 int len = input_smartreply_get_reply_num();
283 for (int i = 0; i < len; i++) {
285 char *reply = (char *)"";
286 reply = input_smartreply_get_nth_item(i, &type);
289 SECURE_LOGD("SmartReply = [%d] %s", i, reply);
292 g_smartreply_strings.push_back(string(candidate));
298 g_ic_smartreply = g_ic;
299 g_smartreply_reply_exist = true;
301 ise_app_candidate_show();
302 g_softcandidate_string = g_smartreply_strings;
303 ise_update_table(g_softcandidate_string);
309 check_ic_temporary(int ic)
311 if ((ic & 0xFFFF) == 0) {
317 static void _reset_shift_state(void)
320 /* Reset all shift state variables */
321 SCLShiftState old_shift_state = g_ui->get_shift_state();
322 SCLShiftState new_shift_state = SCL_SHIFT_STATE_OFF;
323 if (old_shift_state != new_shift_state) {
324 g_need_send_shift_event = true;
325 g_ui->set_shift_state(new_shift_state);
327 LOGD("Shift state changed from (%d) to (%d)\n", (int)old_shift_state, (int)new_shift_state);
331 static void set_caps_mode(sclboolean mode) {
332 LOGD("mode : %d\n", mode);
334 if (g_ui->get_shift_state() != SCL_SHIFT_STATE_LOCK) {
335 g_ui->set_shift_state(mode ? SCL_SHIFT_STATE_ON : SCL_SHIFT_STATE_OFF);
336 g_ui->set_autocapital_shift_state(!mode);
338 bool load_in_ime = false;
339 const sclchar *cur_lang = _language_manager.get_current_language();
341 LANGUAGE_INFO *info = _language_manager.get_language_info(cur_lang);
343 load_in_ime = info->load_in_ime;
347 ime_send_imengine_event(mode ? MVK_Shift_On : MVK_Shift_Off, 0);
349 engine_loader_send_imengine_event(mode ? MVK_Shift_On : MVK_Shift_Off, 0);
354 static void _reset_multitap_state(bool skip_commit = false)
356 LOGD("g_keyboard_state.prev_modifier : %d", g_keyboard_state.prev_modifier);
357 if (g_keyboard_state.prev_modifier == KEY_MODIFIER_MULTITAP_START ||
358 g_keyboard_state.prev_modifier == KEY_MODIFIER_MULTITAP_REPEAT) {
360 ise_send_string(g_keyboard_state.multitap_value.c_str());
362 ise_update_preedit_string("");
364 g_keyboard_state.multitap_value = "";
365 g_keyboard_state.prev_modifier = KEY_MODIFIER_NONE;
366 if (g_caps_mode_pending) {
367 g_caps_mode_pending = false;
368 set_caps_mode(g_keyboard_state.caps_mode);
372 static void ise_set_cm_private_key(scluint cm_key_id)
374 if (cm_key_id >= CM_KEY_LIST_SIZE || g_ui == NULL) {
375 LOGE("cm_key_id=%d\n", cm_key_id);
379 if (strcmp(_cm_key_list[cm_key_id], USER_KEYSTRING_EMOTICON) == 0) {
380 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
381 const_cast<sclchar*>("icon/54x54/icon_emotion_nor.png"),
382 const_cast<sclchar*>("icon/54x54/icon_emotion_press.png"),
383 const_cast<sclchar*>("icon/54x54/icon_emotion_dim.png")};
384 g_ui->set_private_key("CM_KEY", const_cast<sclchar*>(" "), imagelabel, NULL, 0, const_cast<sclchar*>(USER_KEYSTRING_EMOTICON), TRUE);
385 } else if (strcmp(_cm_key_list[cm_key_id], USER_KEYSTRING_OPTION) == 0) {
386 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
387 const_cast<sclchar*>("icon/54x54/icon_setting_nor.png"),
388 const_cast<sclchar*>("icon/54x54/icon_setting_press.png"),
389 const_cast<sclchar*>("icon/54x54/icon_setting_dim.png")};
390 g_ui->set_private_key("CM_KEY", const_cast<sclchar*>(" "), imagelabel, NULL, 0, const_cast<sclchar*>(USER_KEYSTRING_OPTION), TRUE);
391 } else if (strcmp(_cm_key_list[cm_key_id], USER_KEYSTRING_CLIPBOARD) == 0) {
392 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
393 const_cast<sclchar*>("icon/54x54/icon_clipboard_nor.png"),
394 const_cast<sclchar*>("icon/54x54/icon_clipboard_press.png"),
395 const_cast<sclchar*>("icon/54x54/icon_clipboard_dim.png")};
396 g_ui->set_private_key("CM_KEY", const_cast<sclchar*>(" "), imagelabel, NULL, 0, const_cast<sclchar*>(USER_KEYSTRING_CLIPBOARD), TRUE);
397 } else if (strcmp(_cm_key_list[cm_key_id], USER_KEYSTRING_VOICE) == 0) {
398 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
399 const_cast<sclchar*>("icon/54x54/icon_mic_nor.png"),
400 const_cast<sclchar*>("icon/54x54/icon_mic_press.png"),
401 const_cast<sclchar*>("icon/54x54/icon_mic_dim.png")};
402 g_ui->set_private_key("CM_KEY", const_cast<sclchar*>(" "), imagelabel, NULL, 0, const_cast<sclchar*>(USER_KEYSTRING_VOICE), TRUE);
403 } else if (strcmp(_cm_key_list[cm_key_id], USER_KEYSTRING_FLOATING) == 0) {
404 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
405 const_cast<sclchar*>("icon/54x54/icon_floating_keypad_nor.png"),
406 const_cast<sclchar*>("icon/54x54/icon_floating_keypad_press.png"),
407 const_cast<sclchar*>("icon/54x54/icon_floating_keypad_dim.png")};
408 g_ui->set_private_key("CM_KEY", const_cast<sclchar*>(" "), imagelabel, NULL, 0, const_cast<sclchar*>(USER_KEYSTRING_FLOATING), TRUE);
412 static void ise_update_space_key(void)
415 LOGE("g_ui = NULL\n");
419 scluint num = _language_manager.get_enabled_languages_num();
420 LOGD("language number: %d\n", num);
422 LANGUAGE_INFO *info = _language_manager.get_language_info(_language_manager.get_current_language());
423 if (info && info->enabled) {
425 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
426 const_cast<sclchar*>("w_sip_3x4_btn_ic_space_no_arrow.png"),
427 const_cast<sclchar*>("w_sip_3x4_btn_ic_space_no_arrow.png"),
428 const_cast<sclchar*>("w_sip_3x4_btn_ic_space_no_arrow.png")};
429 g_ui->set_private_key("SPACE_KEY", const_cast<sclchar*>(info->display_name.c_str()), imagelabel, NULL, 0, const_cast<sclchar*>("Space"), TRUE);
431 g_ui->enable_button("SPACE_ARROW_LEFT", false);
432 g_ui->enable_button("SPACE_ARROW_RIGHT", false);
437 g_ui->unset_private_key("SPACE_KEY");
439 g_ui->enable_button("SPACE_ARROW_LEFT", true);
440 g_ui->enable_button("SPACE_ARROW_RIGHT", true);
445 static scluint ise_get_cm_key_id(const sclchar *key_value)
447 for (int i = 0; i < CM_KEY_LIST_SIZE; ++i) {
448 if (0 == strcmp (key_value, _cm_key_list[i]))
454 static bool ise_is_emoticons_disabled(void)
457 sclu32 current_layout = g_keyboard_state.layout;
458 LOGD("layout=%d\n", current_layout);
460 if ((current_layout == ISE_LAYOUT_STYLE_NORMAL) ||
461 (current_layout == ISE_LAYOUT_STYLE_NUMBER) ||
462 (current_layout == ISE_LAYOUT_STYLE_EMOTICON))
465 if (g_imdata_state & IMDATA_ACTION_DISABLE_EMOTICONS)
471 static Eina_Bool softcandidate_hide_timer_callback(void *data)
474 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_HIDE);
478 g_softcandidate_show = false;
480 return ECORE_CALLBACK_CANCEL;
483 static void delete_softcandidate_hide_timer(void)
485 if (g_softcandidate_hide_timer) {
486 ecore_timer_del(g_softcandidate_hide_timer);
487 g_softcandidate_hide_timer = NULL;
491 static void add_softcandidate_hide_timer(void)
493 delete_softcandidate_hide_timer();
494 g_softcandidate_hide_timer = ecore_timer_add(SOFT_CANDIDATE_DELETE_TIME, softcandidate_hide_timer_callback, NULL);
497 static void create_softcandidate(void)
500 g_candidate = CandidateFactory::make_candidate(CANDIDATE_MULTILINE, ime_get_main_window());
502 g_candidate->add_event_listener(&g_candidate_event_listener);
508 * Send the given string to input framework
511 ise_send_string(const sclchar *key_value)
514 if (!check_ic_temporary(g_keyboard_state.ic)) {
515 ic = g_keyboard_state.ic;
517 ime_commit_string(key_value);
518 LOGD("ic : %x, %s\n", ic, key_value);
522 * Send the preedit string to input framework
525 ise_update_preedit_string(const sclchar *str, const sclboolean underline)
528 Eina_List *attr_list = NULL;
529 ime_preedit_attribute *preedit_attr;
531 if (!check_ic_temporary(g_keyboard_state.ic)) {
532 ic = g_keyboard_state.ic;
535 /* Count UTF-8 string length */
537 const sclchar *s = str;
538 while (*s) len += (*s++ & 0xc0) != 0x80;
540 preedit_attr = (ime_preedit_attribute *)calloc(1, sizeof(ime_preedit_attribute));
542 preedit_attr->start = 0;
543 preedit_attr->length = len;
544 preedit_attr->type = IME_ATTR_FONTSTYLE;
545 preedit_attr->value = IME_ATTR_FONTSTYLE_UNDERLINE;
546 attr_list = eina_list_append(attr_list, (void *)preedit_attr);
549 ime_update_preedit_string(str, attr_list);
551 ime_update_preedit_string(str, NULL);
553 LOGD("ic : %x, %s\n", ic, str);
557 * Send the given event to input framework
560 ise_send_event(sclulong key_event, sclulong key_mask)
563 if (!check_ic_temporary(g_keyboard_state.ic)) {
564 ic = g_keyboard_state.ic;
566 ime_send_key_event((ime_key_code_e)key_event, IME_KEY_MASK_PRESSED, false);
567 ime_send_key_event((ime_key_code_e)key_event, IME_KEY_MASK_RELEASED, false);
569 LOGD("ic : %x, %lx\n", (unsigned int)ic, key_event);
573 * Forward the given event to input framework
576 ise_forward_key_event(sclulong key_event)
579 if (!check_ic_temporary(g_keyboard_state.ic)) {
580 ic = g_keyboard_state.ic;
582 ime_send_key_event((ime_key_code_e)key_event, IME_KEY_MASK_PRESSED, true);
583 ime_send_key_event((ime_key_code_e)key_event, IME_KEY_MASK_RELEASED, true);
585 LOGD("ic : %x, %lx\n", (unsigned int)ic, key_event);
589 * @brief Delete commit timer.
593 static void delete_commit_timer(void)
595 if (_commit_timer != NULL) {
596 ecore_timer_del(_commit_timer);
597 _commit_timer = NULL;
602 * @brief Callback function for commit timer.
604 * @param data Data to pass when it is called.
606 * @return ECORE_CALLBACK_CANCEL
608 static Eina_Bool commit_timeout(void *data)
610 if (_commit_timer != NULL) {
611 ime_hide_preedit_string();
612 ise_forward_key_event(_sig_dec_event[(_click_count-1)%SIG_DEC_SIZE]);
615 _commit_timer = NULL;
616 return ECORE_CALLBACK_CANCEL;
620 on_input_mode_changed(const sclchar *key_value, sclulong key_event, sclint key_type)
622 sclboolean ret = FALSE;
626 SECURE_LOGD("key_value : %s\n", key_value);
627 if (strcmp(key_value, "CUR_LANG") == 0) {
628 g_keyboard_state.disable_force_latin = TRUE;
629 ret = _language_manager.select_current_language();
631 if (strcmp(key_value, "NEXT_LANG") == 0) {
632 g_keyboard_state.disable_force_latin = TRUE;
633 ret = _language_manager.select_next_language();
637 const sclchar *cur_lang = _language_manager.get_current_language();
639 LANGUAGE_INFO *info = _language_manager.get_language_info(cur_lang);
641 if (info->accepts_caps_mode) {
642 if (info->load_in_ime)
643 ime_send_imengine_event(MVK_Shift_Enable, 0);
645 engine_loader_send_imengine_event(MVK_Shift_Enable, 0);
647 set_caps_mode(g_keyboard_state.caps_mode);
649 if (info->load_in_ime)
650 ime_send_imengine_event(MVK_Shift_Disable, 0);
652 engine_loader_send_imengine_event(MVK_Shift_Disable, 0);
654 g_ui->set_shift_state(SCL_SHIFT_STATE_OFF);
658 if (is_emoticon_show()) {
659 ise_destroy_emoticon_layout();
662 if (!strcmp(key_value, USER_KEYSTRING_EMOTICON)) {
663 ise_init_emoticon_list();
665 current_emoticon_group = EMOTICON_GROUP_1;
667 if (emoticon_list_recent.size() == 0)
668 current_emoticon_group = EMOTICON_GROUP_1;
670 current_emoticon_group = EMOTICON_GROUP_RECENTLY_USED;
672 SCLRotation rotation = g_ui->get_rotation();
673 ise_show_emoticon_layout(current_emoticon_group, ROTATION_TO_DEGREE(rotation), false, ime_get_main_window());
681 static void show_cbhm()
687 ret = cbhm_selection_type_set(cbhm_handle, static_cast<cbhm_sel_type_e>(cbhm_sel_type));
689 ret = cbhm_selection_type_set(cbhm_handle, CBHM_SEL_TYPE_TEXT);
691 if (ret != CBHM_ERROR_NONE)
692 LOGW("Failed to set selection type in cbhm. error : %d\n", ret);
694 ret = cbhm_show(cbhm_handle);
695 if (ret != CBHM_ERROR_NONE)
696 LOGW("cbhm show error : %d\n", ret);
702 SCLEventReturnType CUIEventCallback::on_event_notification(SCLUINotiType noti_type, SclNotiDesc *etc_info)
704 SCLEventReturnType ret = SCL_EVENT_PASS_ON;
705 LOGD("noti type: %d, g_need_send_shift_event: %d\n", noti_type, g_need_send_shift_event);
707 if (noti_type == SCL_UINOTITYPE_SHIFT_STATE_CHANGE) {
708 if (g_need_send_shift_event) {
709 const sclchar *cur_lang = _language_manager.get_current_language();
711 LANGUAGE_INFO *info = _language_manager.get_language_info(cur_lang);
712 SclNotiShiftStateChangeDesc *desc = static_cast<SclNotiShiftStateChangeDesc*>(etc_info);
714 if (info->accepts_caps_mode) {
715 LOGD("shift state: %d\n", desc->shift_state);
716 if (desc->shift_state == SCL_SHIFT_STATE_OFF) {
717 if (info->load_in_ime)
718 ime_send_imengine_event(MVK_Shift_Off, 0);
720 engine_loader_send_imengine_event(MVK_Shift_Off, 0);
721 } else if (desc->shift_state == SCL_SHIFT_STATE_ON) {
722 if (info->load_in_ime)
723 ime_send_imengine_event(MVK_Shift_On, 0);
725 engine_loader_send_imengine_event(MVK_Shift_On, 0);
726 } else if (desc->shift_state == SCL_SHIFT_STATE_LOCK) {
727 if (info->load_in_ime)
728 ime_send_imengine_event(MVK_Shift_Lock, 0);
730 engine_loader_send_imengine_event(MVK_Shift_Lock, 0);
732 ret = SCL_EVENT_PASS_ON;
736 g_need_send_shift_event = FALSE;
738 } else if (noti_type == SCL_UINOTITYPE_POPUP_OPENING) {
739 vector<string>::reverse_iterator iter = g_recent_used_punctuation.rbegin();
741 for (; iter != g_recent_used_punctuation.rend(); ++iter)
744 g_ui->set_string_substitution(g_current_punctuation[punc_pos].c_str(), iter->c_str());
747 SclNotiPopupOpeningDesc *openingDesc = (SclNotiPopupOpeningDesc *)etc_info;
748 if (g_ui && 0 == strcmp(openingDesc->input_mode, "CM_POPUP")) {
749 if (ise_is_emoticons_disabled())
750 g_ui->enable_button("EMOTICON_KEY", false);
752 g_ui->enable_button("EMOTICON_KEY", true);
754 } else if (noti_type == SCL_UINOTITYPE_POPUP_OPENED) {
755 g_popup_opened = TRUE;
756 SclNotiPopupOpenedDesc *openedDesc = (SclNotiPopupOpenedDesc *)etc_info;
757 if (0 == strcmp(openedDesc->input_mode, "PUNCTUATION_POPUP")) {
758 g_punctuation_popup_opened = TRUE;
759 } else if (0 == strcmp(openedDesc->input_mode, "CM_POPUP")) {
760 _cm_popup_opened = TRUE;
762 } else if (noti_type == SCL_UINOTITYPE_POPUP_CLOSED) {
763 g_popup_opened = FALSE;
764 SclNotiPopupClosedDesc *closedDesc = (SclNotiPopupClosedDesc *)etc_info;
765 if (closedDesc && closedDesc->input_mode) {
766 if (0 == strcmp(closedDesc->input_mode, "PUNCTUATION_POPUP")) {
767 g_punctuation_popup_opened = FALSE;
768 } else if (0 == strcmp(closedDesc->input_mode, "CM_POPUP")) {
769 _cm_popup_opened = FALSE;
772 } else if (noti_type == SCL_UINOTITYPE_INPUT_MODE_CHANGE) {
773 SclNotiInputModeChangeDesc *desc = static_cast<SclNotiInputModeChangeDesc*>(etc_info);
775 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_NONE);
777 const char *input_mode = g_ui->get_input_mode();
779 if (strcmp(input_mode, "STT_3X4") == 0 &&
780 strcmp(desc->input_mode, "STT_3X4") != 0) {
783 if (strcmp(input_mode, "STT_3X4") != 0 &&
784 strcmp(desc->input_mode, "STT_3X4") == 0) {
785 ise_show_stt_mode(NATIVE_WINDOW_CAST(ime_get_main_window()));
794 void ise_destory_popup_setting()
796 if (_guide_popup_setting != NULL) {
797 LOGD("destroy setting popup iter\n");
798 evas_object_del(_guide_popup_setting);
799 _guide_popup_setting = NULL;
800 g_config_values.first_guideset = TRUE;
801 write_ise_config_values();
805 void ise_destory_popup_space()
807 if (_guide_popup_space != NULL) {
808 LOGD("destroy space popup iter\n");
809 evas_object_del(_guide_popup_space);
810 _guide_popup_setting = NULL;
811 g_config_values.first_guidechange = TRUE;
812 write_ise_config_values();
816 Evas_Object *open_message_popup(Evas_Object *parentWnd)
818 static Evas_Object *msg_window = NULL;
820 evas_object_del(msg_window);
823 msg_window = elm_win_add(parentWnd, "MCFMessagePopup", ELM_WIN_UTILITY);
826 elm_win_borderless_set(msg_window, EINA_TRUE);
827 elm_win_alpha_set(msg_window, EINA_TRUE);
828 elm_win_title_set(msg_window, "ISF Popup");
829 elm_win_screen_size_get(msg_window, NULL, NULL, &w, &h);
830 elm_win_prop_focus_skip_set(msg_window, TRUE);
831 int rots[4] = {0, 90, 180, 270};
832 elm_win_wm_rotation_available_rotations_set(msg_window, rots, 4);
833 evas_object_resize(msg_window, w, h);
836 int rots[4] = { 0, 90, 180, 270 };
837 elm_win_wm_rotation_available_rotations_set(msg_window, rots, 4);
838 evas_object_show(msg_window);
842 void _guideline_popup_setting_cb(void *data, Evas_Object *obj, void *event_info)
844 evas_object_smart_callback_del(obj, "dismissed", _guideline_popup_setting_cb);
845 evas_object_del(obj);
847 ise_destory_popup_setting();
848 g_config_values.first_guideset = TRUE;
849 write_ise_config_values();
852 void _guideline_popup_space_cb(void *data, Evas_Object *obj, void *event_info)
854 evas_object_smart_callback_del(obj, "dismissed", _guideline_popup_space_cb);
855 evas_object_del(obj);
857 ise_destory_popup_space();
858 g_config_values.first_guidechange = TRUE;
859 write_ise_config_values();
862 void ise_show_help_popup(sclulong keyEvent)
864 char buf[2048] = {0, };
868 SclRectangle rectangle = {0};
869 Evas_Object *ctxpopup = NULL;
870 Elm_Theme *theme = NULL;
873 g_ui->get_screen_resolution(&scr_w, &scr_h);
875 if (keyEvent == MVK_space) {
876 g_config_values.first_guidechange = TRUE;
877 write_ise_config_values();
878 g_ui->get_button_geometry("SPACE_KEY", &rectangle);
879 _guide_popup_space = open_message_popup(NATIVE_WINDOW_CAST(ime_get_main_window()));
881 theme = elm_theme_new();
882 elm_theme_ref_set(theme, NULL);
883 elm_theme_extension_add(theme, EDJ_FILE);
885 ctxpopup = elm_ctxpopup_add(_guide_popup_space);
886 elm_object_theme_set(ctxpopup, theme);
887 evas_object_smart_callback_add(ctxpopup, "dismissed", _guideline_popup_space_cb, (void *)keyEvent);
889 g_config_values.first_guideset = TRUE;
890 write_ise_config_values();
891 g_ui->get_button_geometry("CM_KEY", &rectangle);
892 _guide_popup_setting = open_message_popup(NATIVE_WINDOW_CAST(ime_get_main_window()));
893 theme = elm_theme_new();
894 elm_theme_ref_set(theme, NULL);
895 elm_theme_extension_add(theme, EDJ_FILE);
896 ctxpopup = elm_ctxpopup_add(_guide_popup_setting);
897 elm_object_theme_set(ctxpopup, theme);
898 evas_object_smart_callback_add(ctxpopup, "dismissed", _guideline_popup_setting_cb, (void *)keyEvent);
902 int rotation = elm_win_rotation_get(NATIVE_WINDOW_CAST(ime_get_main_window()));
903 if (rotation == 0 || rotation == 180) {
904 elm_object_style_set(ctxpopup, "customised_guideline_popup");
906 elm_object_style_set(ctxpopup, "customised_guideline_popup_landscape");
909 elm_ctxpopup_direction_priority_set(ctxpopup, ELM_CTXPOPUP_DIRECTION_UP,
910 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
911 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
912 ELM_CTXPOPUP_DIRECTION_UNKNOWN);
914 Evas_Object* text = elm_label_add(ctxpopup);
916 if (keyEvent == MVK_space) {
917 snprintf(buf, sizeof(buf), "<font_style=Regular font_size=%d align=left wrap=mixed color=#000000>%s</>", font_size,
918 dgettext(PACKAGE, "IDS_IME_BODY_SWIPE_THE_SPACE_BAR_LEFT_OR_RIGHT_TO_CHANGE_BETWEEN_LANGUAGES"));
920 snprintf(buf, sizeof(buf), "<font_style=Regular font_size=%d align=left wrap=mixed color=#000000>%s</>", font_size,
921 dgettext(PACKAGE, "IDS_IME_BODY_TAP_AND_HOLD_THIS_KEY_TO_SEE_THE_SYMBOL_LIST_SELECT_ONE_TO_USE_IT_AS_A_SHORTCUT"));
923 elm_object_text_set(text, buf);
924 elm_object_content_set(ctxpopup, text);
925 Evas_Coord x, y, w, h;
926 evas_object_geometry_get(NATIVE_WINDOW_CAST(ime_get_main_window()), &x, &y, &w, &h);
928 if (rotation == 0 || rotation == 180) {
929 elm_label_wrap_width_set(text, (scr_w * 4) / 5);
930 evas_object_size_hint_min_set(ctxpopup, ELM_SCALE_SIZE(scr_w), ELM_SCALE_SIZE(50));
931 evas_object_size_hint_max_set(ctxpopup, ELM_SCALE_SIZE(scr_w), ELM_SCALE_SIZE(600));
932 evas_object_move(ctxpopup, rectangle.x + rectangle.width / 2,
933 (scr_h - h) + rectangle.y - ELM_SCALE_SIZE(5));
935 elm_label_wrap_width_set(text, (scr_h * 4) / 5);
936 evas_object_size_hint_min_set(ctxpopup, ELM_SCALE_SIZE(scr_h), ELM_SCALE_SIZE(50));
937 evas_object_size_hint_max_set(ctxpopup, ELM_SCALE_SIZE(scr_h), ELM_SCALE_SIZE(600));
938 evas_object_move(ctxpopup, rectangle.x + rectangle.width / 2,
939 (scr_w - h)+ rectangle.y - ELM_SCALE_SIZE(5));
941 elm_label_line_wrap_set(text, ELM_WRAP_MIXED);
942 evas_object_show(text);
944 if (keyEvent == MVK_space) {
945 evas_object_layer_set(_guide_popup_space, EVAS_LAYER_MAX);
946 evas_object_show(_guide_popup_space);
948 evas_object_layer_set(_guide_popup_setting, EVAS_LAYER_MAX);
949 evas_object_show(_guide_popup_setting);
952 evas_object_layer_set(ctxpopup, EVAS_LAYER_MAX);
953 evas_object_show(ctxpopup);
956 SCLEventReturnType CUIEventCallback::on_event_drag_state_changed(SclUIEventDesc event_desc)
958 LOGD("button %s is clicked\n", event_desc.key_value);
959 if (event_desc.event_type == EVENT_TYPE_MOVE) {
960 if (event_desc.key_event == MVK_space) {
961 SclRectangle rectangle = {0};
962 g_ui->get_button_geometry("SPACE_KEY", &rectangle);
963 ise_show_space_flick_language_change_popup(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
965 } else if (event_desc.event_type == EVENT_TYPE_RELEASE) {
966 if (event_desc.key_event == MVK_space) {
967 ise_destroy_space_flick_language_change_popup();
971 ime_set_floating_drag_end();
972 } else if (event_desc.event_type == EVENT_TYPE_PRESS) {
974 if ((!g_config_values.first_guideset) && event_desc.key_value && (strncmp(event_desc.key_value, "OPTION", strlen(event_desc.key_value)) == 0)) {
975 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
976 LOGD("setting popup show\n");
977 return SCL_EVENT_PASS_ON;
979 ise_destory_popup_setting();//destory popup manually in case of abnormal situation
982 if (g_floating_mode && event_desc.mouse_current_point.y <= FLOATING_TITLE_BAR_HEIGHT
983 && event_desc.mouse_current_point.y >= 0)
984 ime_set_floating_drag_start();
986 return SCL_EVENT_PASS_ON;
989 static void launch_option()
991 app_control_h app_control;
992 int ret = app_control_create(&app_control);
993 if (ret != APP_CONTROL_ERROR_NONE) {
994 LOGW("app_control_create returned %d\n", ret);
998 ret = app_control_set_operation(app_control, APP_CONTROL_OPERATION_DEFAULT);
999 if (ret != APP_CONTROL_ERROR_NONE) {
1000 LOGW("app_control_set_operation returned %d\n", ret);
1004 ret = app_control_set_app_id(app_control, "org.tizen.ise-default-setting");
1005 if (ret != APP_CONTROL_ERROR_NONE) {
1006 LOGW("app_control_set_app_id returned %d\n", ret);
1010 app_control_add_extra_data(app_control, "caller", "ise-default");
1011 app_control_set_launch_mode(app_control, APP_CONTROL_LAUNCH_MODE_GROUP);
1013 ret = app_control_send_launch_request(app_control, NULL, NULL);
1014 if (ret != APP_CONTROL_ERROR_NONE) {
1020 app_control_destroy(app_control);
1023 SCLEventReturnType CUIEventCallback::on_event_key_clicked(SclUIEventDesc event_desc)
1025 SCLEventReturnType ret = SCL_EVENT_PASS_ON;
1026 if (word_timer != NULL) {
1027 ecore_timer_del(word_timer);
1030 if (event_desc.key_modifier == KEY_MODIFIER_MULTITAP_START) {
1031 if (!g_keyboard_state.multitap_value.empty()) {
1032 ise_send_string(g_keyboard_state.multitap_value.c_str());
1034 ise_update_preedit_string(event_desc.key_value);
1035 g_keyboard_state.multitap_value = event_desc.key_value;
1036 } else if (event_desc.key_modifier == KEY_MODIFIER_MULTITAP_REPEAT) {
1037 ise_update_preedit_string(event_desc.key_value);
1038 g_keyboard_state.multitap_value = event_desc.key_value;
1040 _reset_multitap_state();
1042 g_keyboard_state.prev_modifier = event_desc.key_modifier;
1045 switch (event_desc.key_type) {
1046 case KEY_TYPE_STRING: {
1047 if (event_desc.key_modifier != KEY_MODIFIER_MULTITAP_START &&
1048 event_desc.key_modifier != KEY_MODIFIER_MULTITAP_REPEAT) {
1049 if (event_desc.key_event) {
1050 ise_forward_key_event(event_desc.key_event);
1052 ise_send_string(event_desc.key_value);
1055 if (!g_popup_opened) {
1056 const sclchar *input_mode = g_ui->get_input_mode();
1057 if (input_mode && ((0 == strcmp(input_mode, "SYM_QTY_1")) || (0 == strcmp(input_mode, "SYM_QTY_2")))) {
1058 update_recent_used_punctuation(event_desc.key_value);
1060 } else if (g_punctuation_popup_opened) {
1061 update_recent_used_punctuation(event_desc.key_value);
1065 case KEY_TYPE_CHAR: {
1066 sclboolean need_forward = FALSE;
1067 // FIXME : Should decide when to forward key events
1068 const sclchar *input_mode = g_ui->get_input_mode();
1070 if (strcmp(input_mode, "SYM_QTY_1") == 0 ||
1071 strcmp(input_mode, "SYM_QTY_2") == 0 ||
1072 strcmp(input_mode, "PHONE_3X4") == 0 ||
1073 strcmp(input_mode, "IPv6_3X4_123") == 0 ||
1074 strcmp(input_mode, "IPv6_3X4_ABC") == 0 ||
1075 strcmp(input_mode, "NUMONLY_3X4") == 0 ||
1076 strcmp(input_mode, "NUMONLY_3X4_SIG") == 0 ||
1077 strcmp(input_mode, "NUMONLY_3X4_DEC") == 0 ||
1078 strcmp(input_mode, "NUMONLY_3X4_SIGDEC") == 0 ||
1079 strcmp(input_mode, "DATETIME_3X4") == 0) {
1080 need_forward = TRUE;
1083 if (input_mode && strcmp (input_mode, "NUMONLY_3X4_SIGDEC") == 0 &&
1084 strcmp(event_desc.key_value, ".") == 0) {
1085 ime_update_preedit_string(_sig_dec[_click_count%SIG_DEC_SIZE], NULL);
1086 ime_show_preedit_string();
1087 delete_commit_timer();
1088 _commit_timer = ecore_timer_add(1.0, commit_timeout, NULL);
1090 } else if (event_desc.key_event) {
1091 commit_timeout(NULL);
1093 ise_forward_key_event(event_desc.key_event);
1095 if (_cm_popup_opened) {
1096 static sclchar current_cm_symbol[2] = {'\0'};
1097 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
1098 const_cast<sclchar*>(" "),
1099 const_cast<sclchar*>(" "),
1100 const_cast<sclchar*>(" ")};
1101 if (event_desc.key_value) {
1102 current_cm_symbol[0] = event_desc.key_value[0];
1103 current_cm_symbol[1] = '\0';
1105 g_ui->set_private_key("CM_KEY",
1106 const_cast<sclchar*>(current_cm_symbol),
1107 imagelabel, NULL, 0,
1108 const_cast<sclchar*>(current_cm_symbol), TRUE);
1110 _cm_popup_opened = FALSE;
1111 _current_cm_key_id = -1;
1116 *change the keyboard mode of GLM from QWERTY to KEYPAD
1117 *ensure the Number keypad won't be affected
1120 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_NUMBER) {
1121 ime_send_key_event(IME_KEY_Print, IME_KEY_MASK_CONTROL, false);
1123 if (word_timer == NULL && (!g_candidate || !g_softcandidate_show)) {
1124 word_timer = ecore_timer_add(MULTITAP_TIMEOUT, _multi_tap_timer_cb, NULL);
1126 ime_send_key_event(IME_KEY_Select, IME_KEY_MASK_CONTROL, false);
1129 ise_send_event(event_desc.key_event, KEY_MASK_NULL);
1133 if ((strcmp(input_mode, "SYM_QTY_1") == 0) || (0 == strcmp(input_mode, "SYM_QTY_2"))) {
1134 update_recent_used_punctuation(event_desc.key_value);
1139 case KEY_TYPE_CONTROL: {
1140 commit_timeout(NULL);
1142 const char *long_shift = "LongShift";
1143 const char *caps_lock = "CapsLock";
1144 const char *delete_all = "DeleteAll";
1145 const char *hide_panel = "Hide";
1146 if (strncmp(event_desc.key_value, long_shift, strlen(long_shift)) == 0) {
1147 LOGD("shift key is longpress\n");
1148 g_ui->set_shift_state(SCL_SHIFT_STATE_ON);
1149 g_need_send_shift_event = TRUE;
1150 //ise_send_event (MVK_Shift_Lock, KEY_MASK_NULL);
1151 } else if (strncmp(event_desc.key_value, caps_lock, strlen(caps_lock)) == 0) {
1152 bool load_in_ime = false;
1153 const sclchar *cur_lang = _language_manager.get_current_language();
1155 LANGUAGE_INFO *info = _language_manager.get_language_info(cur_lang);
1157 load_in_ime = info->load_in_ime;
1160 if (g_ui->get_shift_state() != SCL_SHIFT_STATE_LOCK) {
1161 g_ui->set_shift_state(SCL_SHIFT_STATE_LOCK);
1163 ime_send_imengine_event(MVK_Shift_Lock, 0);
1165 engine_loader_send_imengine_event(MVK_Shift_Lock, 0);
1167 g_ui->set_shift_state(SCL_SHIFT_STATE_OFF);
1169 ime_send_imengine_event(MVK_Shift_Off, 0);
1171 engine_loader_send_imengine_event(MVK_Shift_Off, 0);
1173 //g_need_send_shift_event = TRUE;
1174 } else if (strncmp(event_desc.key_value, delete_all, strlen(delete_all)) == 0) {
1175 ime_delete_surrounding_text((INT_MAX / 2) * -1, INT_MAX);
1176 } else if (strncmp(event_desc.key_value, hide_panel, strlen(hide_panel)) == 0) {
1179 } else if (event_desc.key_event) {
1180 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_VOICE) {
1184 if (event_desc.key_event == MVK_Done) {
1186 //commit the preedit string first
1187 ise_send_event(event_desc.key_event, KEY_MASK_NULL);
1190 ise_send_event(event_desc.key_event, KEY_MASK_NULL);
1191 if (event_desc.key_event == MVK_Shift_L) {
1192 g_need_send_shift_event = TRUE;
1197 case KEY_TYPE_MODECHANGE:
1199 if (_guide_popup_setting != NULL) {//popup is showing
1203 if (strcmp(event_desc.key_value, USER_VOICE_LANGUAGE) == 0) {
1204 if (!g_setting_window_open_status) {
1205 ise_hide_stt_mode();
1207 hide_indicator_window();
1209 create_setting_window();
1211 } else if (strcmp(event_desc.key_value, USER_KEYSTRING_VOICE) == 0) {
1212 g_keyboard_state.layout = ISE_LAYOUT_STYLE_VOICE;
1213 g_ui->set_input_mode("STT_3X4");
1215 } else if (strcmp(event_desc.key_value, USER_KEYSTRING_OPTION) == 0) {
1218 ret = SCL_EVENT_DONE;
1219 } else if (strcmp(event_desc.key_value, USER_KEYSTRING_CLIPBOARD) == 0) {
1222 ret = SCL_EVENT_DONE;
1223 } else if (strcmp(event_desc.key_value, USER_KEYSTRING_FLOATING) == 0) {
1224 if (g_floating_mode)
1225 g_config_values.floating_mode = false;
1227 g_config_values.floating_mode = true;
1228 write_ise_config_values();
1230 ret = SCL_EVENT_DONE;
1231 } else if (on_input_mode_changed(event_desc.key_value, event_desc.key_event, event_desc.key_type)) {
1232 ret = SCL_EVENT_DONE;
1234 if (_cm_popup_opened) {
1235 if (strcmp(event_desc.key_value, USER_KEYSTRING_EMOTICON) == 0 ||
1236 strcmp(event_desc.key_value, USER_KEYSTRING_VOICE) == 0 ||
1237 strcmp(event_desc.key_value, USER_KEYSTRING_FLOATING) == 0) {
1238 scluint id = ise_get_cm_key_id(event_desc.key_value);
1239 if (id != _current_cm_key_id) {
1240 _current_cm_key_id = id;
1241 ise_set_cm_private_key(_current_cm_key_id);
1244 _cm_popup_opened = FALSE;
1246 if (strlen(event_desc.key_value) == 1) {
1247 const char allowed_chars_in_modechange[] = {
1248 ',', '?', '!', '`', '~'
1250 const int allowed_chars_in_modechange_num =
1251 sizeof(allowed_chars_in_modechange) / sizeof(char);
1252 for (unsigned int loop = 0;loop < sizeof(allowed_chars_in_modechange_num);loop++) {
1253 if (*(event_desc.key_value) == allowed_chars_in_modechange[loop]) {
1254 ise_send_string(event_desc.key_value);
1260 if (strcmp(event_desc.key_value, USER_KEYSTRING_OPTION) == 0) {
1261 //open_option_window(NULL, ROTATION_TO_DEGREE(g_ui->get_rotation()));
1264 ret = SCL_EVENT_DONE;
1265 } else if (strcmp(event_desc.key_value, USER_KEYSTRING_CLIPBOARD) == 0) {
1267 ret = SCL_EVENT_DONE;
1268 } else if (strcmp(event_desc.key_value, "Cancel") == 0) {
1269 ret = SCL_EVENT_DONE;
1270 const sclchar *input_mode = g_ui->get_input_mode();
1271 if (input_mode && strcmp(input_mode, "STT_3X4") == 0 ) {
1272 g_keyboard_state.need_reset = TRUE;
1273 voice_result_string_flush();
1274 ise_set_layout(g_keyboard_state.layout, g_keyboard_state.layout_variation);
1275 if (g_keyboard_state.visible_state)
1276 ise_show(g_keyboard_state.ic);
1278 ise_send_event(IME_KEY_Cancel, KEY_MASK_NULL);
1280 } else if (strcmp(event_desc.key_value, "Done") == 0) {
1281 ret = SCL_EVENT_DONE;
1282 ise_send_event(IME_KEY_Return, KEY_MASK_NULL);
1285 const sclchar *input_mode = g_ui->get_input_mode();
1286 if ((NULL != input_mode) && (!strcmp(input_mode, "EMOTICON_LAYOUT"))) {
1287 if (is_emoticon_show()) {
1288 ise_destroy_emoticon_layout();
1291 emoticon_group_t group_id = EMOTICON_GROUP_1;
1292 if (current_emoticon_group < EMOTICON_GROUP_3)
1293 group_id = (emoticon_group_t)(current_emoticon_group + 1);
1295 ise_set_emoticon_label(group_id);
1297 emoticon_group_t group_id = ise_get_emoticon_group_id(event_desc.key_value);
1299 if ((group_id >= 0) && (group_id < MAX_EMOTICON_GROUP)) {
1300 SCLRotation rotation = g_ui->get_rotation();
1301 ise_show_emoticon_layout(group_id, ROTATION_TO_DEGREE(rotation), false, ime_get_main_window());
1305 if (_cm_popup_opened) {
1306 if (strcmp(event_desc.key_value, USER_KEYSTRING_OPTION) == 0 ||
1307 strcmp(event_desc.key_value, USER_KEYSTRING_CLIPBOARD) == 0) {
1308 scluint id = ise_get_cm_key_id(event_desc.key_value);
1309 if (id != _current_cm_key_id) {
1310 _current_cm_key_id = id;
1311 ise_set_cm_private_key(_current_cm_key_id);
1314 _cm_popup_opened = FALSE;
1326 ise_set_layout(sclu32 layout, sclu32 layout_variation)
1328 /* Check if the layoutIdx is in the valid range */
1329 if (layout < ISE_LAYOUT_STYLE_MAX) {
1330 if (g_keyboard_state.layout != layout ||
1331 g_keyboard_state.layout_variation != layout_variation) {
1332 g_keyboard_state.need_reset = TRUE;
1334 g_keyboard_state.layout = layout;
1335 g_keyboard_state.layout_variation = layout_variation;
1336 LOGD("layout:%d, variation:%d\n", g_keyboard_state.layout, g_keyboard_state.layout_variation);
1344 _reset_multitap_state(true);
1345 _language_manager.reset_language(g_config_values.selected_language.c_str());
1349 ise_reset_input_context()
1352 _reset_multitap_state(true);
1353 g_keyboard_state.disable_force_latin = FALSE;
1354 _language_manager.reset_language(g_config_values.selected_language.c_str());
1358 ise_focus_in(int ic)
1360 LOGD("ic : %x , %x , g_ic : %x , %x, g_focused_ic : %x , %x\n", ic, check_ic_temporary(ic),
1361 g_keyboard_state.ic, check_ic_temporary(g_keyboard_state.ic),
1362 g_keyboard_state.focused_ic, check_ic_temporary(g_keyboard_state.focused_ic));
1363 if (check_ic_temporary(g_keyboard_state.ic) && !check_ic_temporary(ic)) {
1364 g_keyboard_state.ic = ic;
1366 g_keyboard_state.focused_ic = ic;
1369 static void save_autofill_data()
1374 if (g_autofill_hint == 0)
1377 ime_get_surrounding_text(-1, -1, &text, &cursor);
1378 SECURE_LOGD("surrounding text : %s\n", text);
1381 autofill_save_string(g_app_id.c_str(), g_resource_id.c_str(), (Ecore_IMF_Input_Hints)g_autofill_hint, text);
1387 ise_focus_out(int ic)
1389 g_keyboard_state.focused_ic = 0;
1390 _reset_multitap_state(true);
1392 save_autofill_data();
1395 bool ise_is_guideline_popup_enable_layout(void)
1398 switch (_context_layout)
1400 case ISE_LAYOUT_STYLE_PHONENUMBER:
1401 case ISE_LAYOUT_STYLE_IP:
1402 case ISE_LAYOUT_STYLE_MONTH:
1403 case ISE_LAYOUT_STYLE_NUMBERONLY:
1404 case ISE_LAYOUT_STYLE_HEX:
1405 case ISE_LAYOUT_STYLE_TERMINAL:
1406 case ISE_LAYOUT_STYLE_DATETIME:
1407 case ISE_LAYOUT_STYLE_PASSWORD:
1417 #if EXIT_ISE_ON_HIDE
1418 static Eina_Bool exit_timer_cb(void *data)
1420 if (exit_timer) ecore_timer_del(exit_timer);
1423 return ECORE_CALLBACK_CANCEL;
1430 #if EXIT_ISE_ON_HIDE
1431 if (exit_timer) ecore_timer_del(exit_timer);
1434 sclboolean reset_inputmode = FALSE;
1435 g_input_panel_show = true;
1438 read_ise_config_values();
1440 _language_manager.set_enabled_languages(g_config_values.enabled_languages);
1441 const sclchar *cur_lang = _language_manager.get_current_language();
1444 ise_check_wearable_candidate();
1446 *Clear the personalized data
1448 if (g_config_values.dataclear) {
1449 ime_send_key_event(IME_KEY_Clear, IME_KEY_MASK_CONTROL, false);
1450 g_config_values.dataclear = FALSE;
1453 LOGD("ic : %x , %x , g_ic : %x , %x, g_focused_ic : %x , %x\n", ic, check_ic_temporary(ic),
1454 g_keyboard_state.ic, check_ic_temporary(g_keyboard_state.ic),
1455 g_keyboard_state.focused_ic, check_ic_temporary(g_keyboard_state.focused_ic));
1457 if (check_ic_temporary(ic) && !check_ic_temporary(g_keyboard_state.focused_ic)) {
1458 ic = g_keyboard_state.focused_ic;
1461 if (!check_ic_temporary(ic) && check_ic_temporary(g_keyboard_state.focused_ic)) {
1462 g_keyboard_state.focused_ic = ic;
1465 if (ic == g_keyboard_state.focused_ic) {
1466 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_PHONENUMBER ||
1467 g_keyboard_state.layout == ISE_LAYOUT_STYLE_IP ||
1468 g_keyboard_state.layout == ISE_LAYOUT_STYLE_MONTH ||
1469 g_keyboard_state.layout == ISE_LAYOUT_STYLE_NUMBERONLY) {
1470 ime_set_engine_loader_flag(true);
1471 engine_loader_set_imengine(DEFAULT_KEYBOARD_ISE_UUID, DEFAULT_KEYBOARD_ISE_PKGID);
1475 const char *input_mode = g_ui->get_input_mode();
1477 /* Reset input mode if the input context value has changed */
1478 if (ic != g_keyboard_state.ic) {
1479 /* Do not reset input mode if STT's setting window was opened */
1480 if (g_setting_window_open_status && input_mode && strcmp(input_mode, "STT_3X4") == 0) {
1481 LOGD("Setting window was opened while using STT, skip resetting input mode");
1483 reset_inputmode = TRUE;
1487 g_keyboard_state.ic = ic;
1488 /* Reset input mode if the current language is not the selected language */
1490 if (g_config_values.selected_language.compare(cur_lang) != 0) {
1491 reset_inputmode = TRUE;
1495 /* No matter what, just reset the inputmode if it needs to */
1496 if (g_keyboard_state.need_reset) {
1497 /* Do not reset input mode if STT's setting window was opened */
1498 if (g_setting_window_open_status && input_mode && strcmp(input_mode, "STT_3X4") == 0) {
1499 LOGD("Setting window was opened while using STT, skip resetting input mode");
1501 reset_inputmode = TRUE;
1504 g_keyboard_state.need_reset = FALSE;
1506 /* If the current layout requires latin language and current our language is not latin, enable the primary latin */
1507 sclboolean force_primary_latin = FALSE;
1508 LANGUAGE_INFO *info = _language_manager.get_language_info(g_config_values.selected_language.c_str());
1510 if (g_ise_default_values[g_keyboard_state.layout].force_latin && !(info->is_latin_language)) {
1511 if (!g_keyboard_state.disable_force_latin) {
1512 force_primary_latin = TRUE;
1516 if (force_primary_latin) {
1517 /* If there is enabled latin-based language, select it */
1518 sclboolean selected = FALSE;
1519 for (scluint loop = 0;!selected && loop < _language_manager.get_languages_num();loop++) {
1520 LANGUAGE_INFO *info = _language_manager.get_language_info(loop);
1522 if (info->enabled && info->is_latin_language) {
1523 selected = _language_manager.select_language(info->name.c_str());
1524 if (selected) force_primary_latin = FALSE;
1529 _language_manager.set_language_enabled_temporarily(PRIMARY_LATIN_LANGUAGE, TRUE);
1533 if (reset_inputmode) {
1534 ise_reset_context();
1536 bool filename_layout = false;
1538 /* Turn the shift state off if we need to reset our input mode, only when auto-capitalization is not set */
1539 if (!(g_keyboard_state.caps_mode)) {
1540 g_ui->set_shift_state(SCL_SHIFT_STATE_OFF);
1542 if (g_keyboard_state.layout < ISE_LAYOUT_STYLE_MAX) {
1543 sclu32 layout_index = g_keyboard_state.layout;
1544 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_NUMBERONLY &&
1545 g_keyboard_state.layout_variation > 0 &&
1546 g_keyboard_state.layout_variation < ISE_LAYOUT_NUMBERONLY_VARIATION_MAX) {
1547 layout_index = ISE_LAYOUT_STYLE_NUMBERONLY_SIG + g_keyboard_state.layout_variation - 1;
1548 } else if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_PASSWORD && g_keyboard_state.layout_variation > 0) {
1549 layout_index = ISE_LAYOUT_STYLE_PASSWD_3X4;
1552 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_NORMAL &&
1553 g_keyboard_state.layout_variation == ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL_VARIATION_FILENAME)
1554 filename_layout = true;
1556 filename_layout = false;
1558 g_ui->enable_button("exclamation", !filename_layout);
1559 g_ui->enable_button("question", !filename_layout);
1560 g_ui->enable_button("divide", !filename_layout);
1561 g_ui->enable_button("multiply", !filename_layout);
1562 g_ui->enable_button("colon", !filename_layout);
1563 g_ui->enable_button("quotation", !filename_layout);
1565 g_ui->enable_button("CM_KEY", !access("/home", X_OK));
1567 LOGD("new layout index : %d\n", layout_index);
1568 /* If this layout requires specific input mode, set it */
1569 if (strlen(g_ise_default_values[layout_index].input_mode) > 0) {
1570 g_ui->set_input_mode(g_ise_default_values[layout_index].input_mode);
1571 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_NONE);
1573 if (force_primary_latin) {
1574 _language_manager.select_language(PRIMARY_LATIN_LANGUAGE, TRUE);
1576 if (!(_language_manager.select_language(g_config_values.selected_language.c_str()))) {
1577 _language_manager.select_language(PRIMARY_LATIN_LANGUAGE);
1581 g_ui->set_cur_sublayout(g_ise_default_values[layout_index].sublayout_name);
1582 if (is_emoticon_show()) {
1583 ise_destroy_emoticon_layout();
1586 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_EMOTICON) {
1587 ise_init_emoticon_list();
1589 current_emoticon_group = EMOTICON_GROUP_1;
1590 ise_set_emoticon_label(1);
1592 if (emoticon_list_recent.size() == 0)
1593 current_emoticon_group = EMOTICON_GROUP_1;
1595 current_emoticon_group = EMOTICON_GROUP_RECENTLY_USED;
1597 SCLRotation rotation = g_ui->get_rotation();
1598 ise_show_emoticon_layout(current_emoticon_group, ROTATION_TO_DEGREE(rotation), false, ime_get_main_window());
1604 if (info->accepts_caps_mode) {
1605 // FIXME this if condition means the AC is off
1606 if (g_keyboard_state.layout != ISE_LAYOUT_STYLE_NORMAL) {
1607 g_ui->set_autocapital_shift_state(TRUE);
1608 g_ui->set_shift_state(SCL_SHIFT_STATE_OFF);
1610 ise_send_event(MVK_Shift_Enable, KEY_MASK_NULL);
1611 // Auto Capital is supported only in normal layout
1612 if (g_keyboard_state.caps_mode) {
1613 g_ui->set_autocapital_shift_state(FALSE);
1617 g_ui->set_autocapital_shift_state(TRUE);
1618 ise_send_event(MVK_Shift_Disable, KEY_MASK_NULL);
1619 g_ui->set_shift_state(SCL_SHIFT_STATE_OFF);
1622 g_ui->set_autocapital_shift_state(TRUE);
1625 // Update CM key button
1626 if (_current_cm_key_id < CM_KEY_LIST_SIZE) {
1627 if (strcmp(_cm_key_list[_current_cm_key_id], USER_KEYSTRING_EMOTICON) == 0) {
1628 if (ise_is_emoticons_disabled())
1629 ise_set_cm_private_key(ise_get_cm_key_id(USER_KEYSTRING_OPTION));
1631 ise_set_cm_private_key(_current_cm_key_id);
1635 // Update space key button
1636 ise_update_space_key();
1639 g_ui->disable_input_events(FALSE);
1641 g_ui->enable_button("CM_KEY", false);
1645 if (ise_is_guideline_popup_enable_layout()) {
1646 if ((!g_config_values.first_guidechange) && (_language_manager.get_enabled_languages_num() > 1)) {
1647 ise_show_help_popup(MVK_space);
1648 LOGD("space popup show\n");
1650 ise_destory_popup_space();
1656 if (g_config_values.floating_mode != g_floating_mode)
1657 g_floating_mode = g_config_values.floating_mode;
1659 if (g_candidate && g_candidate->get_visible())
1660 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_SHOW);
1662 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_NONE);
1665 g_keyboard_state.visible_state = TRUE;
1669 switch (_context_layout) {
1670 case ISE_LAYOUT_STYLE_PHONENUMBER:
1671 case ISE_LAYOUT_STYLE_IP:
1672 case ISE_LAYOUT_STYLE_MONTH:
1673 case ISE_LAYOUT_STYLE_NUMBERONLY:
1674 case ISE_LAYOUT_STYLE_DATETIME:
1675 case ISE_LAYOUT_STYLE_TERMINAL:
1678 case ISE_LAYOUT_STYLE_EMAIL:
1679 case ISE_LAYOUT_STYLE_URL:
1682 case ISE_LAYOUT_STYLE_PASSWORD:
1683 if (_context_layout == ISE_LAYOUT_STYLE_PASSWORD &&
1684 _context_layout_variation == ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD_VARIATION_NUMBERONLY)
1697 g_ui->get_screen_resolution(&width, &height);
1699 create_indicator_window(width, height);
1700 destroy_indicator_dots();
1703 switch (g_keyboard_state.layout) {
1704 case ISE_LAYOUT_STYLE_NUMBER:
1707 case ISE_LAYOUT_STYLE_HEX:
1710 case ISE_LAYOUT_STYLE_EMOTICON:
1713 case ISE_LAYOUT_STYLE_VOICE:
1714 if (_context_layout == ISE_LAYOUT_STYLE_EMAIL ||
1715 _context_layout == ISE_LAYOUT_STYLE_URL)
1724 create_indicator_dots(dot_num, focus_dot);
1725 show_indicator_window();
1727 hide_indicator_window();
1729 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_NORMAL && g_config_values.number_tutorial_enable) {
1730 ise_show_tutorial_mode_popup(g_keyboard_state.layout);
1731 g_config_values.number_tutorial_enable = false;
1732 write_ise_config_values();
1736 if (g_setting_window_open_status) {
1737 ise_show_stt_mode(NATIVE_WINDOW_CAST(ime_get_main_window()));
1739 g_setting_window_open_status = FALSE;
1741 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_VOICE) {
1742 ise_show_stt_mode(NATIVE_WINDOW_CAST(ime_get_main_window()));
1747 * Sets screen rotation
1750 ise_set_screen_rotation(int degree)
1753 g_ui->set_rotation(DEGREE_TO_SCLROTATION(degree));
1757 g_candidate->rotate(degree);
1758 if (g_softcandidate_show) {
1759 g_candidate->update(g_softcandidate_string);
1765 ise_set_accessibility_state(bool state)
1768 g_ui->enable_tts(state);
1776 /* There's no need to update screen when hiding */
1777 g_ui->set_update_pending(TRUE);
1778 g_ui->disable_input_events(TRUE);
1781 _language_manager.reset_language(g_config_values.selected_language.c_str());
1784 delete_commit_timer();
1785 ise_destory_popup_space();
1786 ise_destory_popup_setting();
1788 g_keyboard_state.visible_state = FALSE;
1790 _reset_shift_state();
1791 _reset_multitap_state(true);
1793 /* If we were in STT mode, try to reset input mode on our next show event */
1795 const char *inputmode = g_ui->get_input_mode();
1796 if (inputmode && strcmp(inputmode, "STT_3X4") == 0 ) {
1797 g_keyboard_state.need_reset = TRUE;
1798 ise_hide_stt_mode();
1802 g_input_panel_show = false;
1803 if (g_softcandidate_show && g_candidate)
1804 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_SHOW);
1806 hide_indicator_window();
1807 if (check_is_tutorial_show()) {
1808 ise_destroy_tutorial_mode_popup();
1811 #if EXIT_ISE_ON_HIDE
1812 if (exit_timer) ecore_timer_del(exit_timer);
1813 exit_timer = ecore_timer_add(1.0, exit_timer_cb, NULL);
1817 static void ise_keypad_mode_changed_cb(const char *key, void *user_data)
1819 read_ise_keypad_mode();
1822 static void ise_enabled_languages_changed_cb(const char *key, void *user_data)
1824 read_ise_enabled_languages();
1827 static void ise_selected_language_changed_cb(const char *key, void *user_data)
1829 read_ise_selected_language();
1832 static void ise_autocapital_mode_changed_cb(const char *key, void *user_data)
1834 read_ise_autocapital_mode();
1837 static void ise_autopunctuate_mode_changed_cb(const char *key, void *user_data)
1839 read_ise_autopunctuation_mode();
1842 static void ise_sound_mode_changed_cb(const char *key, void *user_data)
1844 read_ise_sound_mode();
1846 g_ui->enable_sound(g_config_values.sound_on);
1849 static void ise_vibration_mode_changed_cb(const char *key, void *user_data)
1851 read_ise_vibration_mode();
1853 g_ui->enable_vibration(g_config_values.vibration_on);
1856 static void ise_character_preview_mode_changed_cb(const char *key, void *user_data)
1858 read_ise_character_preview_mode();
1860 g_ui->enable_magnifier(g_config_values.preview_on);
1863 static void ise_setting_guide_popup_changed_cb(const char *key, void *user_data)
1865 read_ise_setting_guide_popup_mode();
1868 static void ise_language_guide_popup_changed_cb(const char *key, void *user_data)
1870 read_ise_language_guide_popup_mode();
1873 static void ise_floating_mode_changed_cb(const char *key, void *user_data)
1875 read_ise_floating_mode();
1876 g_floating_mode = g_config_values.floating_mode;
1878 ime_set_floating_mode(g_floating_mode);
1879 if (g_candidate && g_floating_mode != g_candidate->get_floating_mode()) {
1880 delete_softcandidate_hide_timer();
1884 create_softcandidate();
1885 if (g_candidate && g_candidate->get_visible()) {
1886 g_softcandidate_show = true;
1887 g_candidate->show();
1888 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_SHOW);
1892 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_NONE);
1895 static void register_preference_changed_callback(void)
1897 if (preference_set_changed_cb(ISE_CONFIG_KEYPAD_MODE, ise_keypad_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1898 LOGW("Failed to set ise_keypad_mode_changed_cb()");
1900 if (preference_set_changed_cb(ISE_CONFIG_ENABLED_LANGUAGES, ise_enabled_languages_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1901 LOGW("Failed to set ise_enabled_languages_changed_cb()");
1903 if (preference_set_changed_cb(ISE_CONFIG_SELECTED_LANGUAGE, ise_selected_language_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1904 LOGW("Failed to set ise_selected_language_changed_cb()");
1906 if (preference_set_changed_cb(ISE_CONFIG_AUTO_CAPITALISE, ise_autocapital_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1907 LOGW("Failed to set ise_autocapital_mode_changed_cb()");
1909 if (preference_set_changed_cb(ISE_CONFIG_AUTO_PUNCTUATE, ise_autopunctuate_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1910 LOGW("Failed to set ise_autopunctuate_mode_changed_cb()");
1912 if (preference_set_changed_cb(ISE_CONFIG_SOUND_ON, ise_sound_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1913 LOGW("Failed to set ise_sound_mode_changed_cb()");
1915 if (preference_set_changed_cb(ISE_CONFIG_VIBRATION_ON, ise_vibration_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1916 LOGW("Failed to set ise_vibration_mode_changed_cb()");
1918 if (preference_set_changed_cb(ISE_CONFIG_PREVIEW_ON, ise_character_preview_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1919 LOGW("Failed to set ise_character_preview_mode_changed_cb()");
1921 if (preference_set_changed_cb(ISE_CONFIG_FIRST_GUIDELINE_POPUP_FOR_SETTING, ise_setting_guide_popup_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1922 LOGW("Failed to set ise_setting_guide_popup_changed_cb()");
1924 if (preference_set_changed_cb(ISE_CONFIG_FIRST_GUIDELINE_POPUP_FOR_LANGUAGE_CHANGE, ise_language_guide_popup_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1925 LOGW("Failed to set ise_language_guide_popup_changed_cb()");
1927 if (preference_set_changed_cb(ISE_CONFIG_FLOATING_MODE, ise_floating_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1928 LOGW("Failed to set ise_floating_mode_changed_cb()");
1931 static void ise_mount_changed_cb(void *user_data)
1933 register_preference_changed_callback();
1945 bindtextdomain(PACKAGE, LOCALEDIR);
1946 textdomain(PACKAGE);
1948 /* Set scl_parser_type
1949 * default type is text xml
1950 * use command: export sclres_type="sclres_binary" to enable use binary resource
1951 * please make sure there is sclresource.bin in resource folder
1952 * Or you can use `xml2binary $resource_dir` to generate the sclresource.bin
1953 * xml2binary is in the libscl-ui-devel package
1955 SCLParserType scl_parser_type = SCL_PARSER_TYPE_XML;
1956 char* sclres_type = getenv("sclres_type");
1957 if (sclres_type != NULL && 0 == strcmp("sclres_binary", sclres_type)) {
1958 scl_parser_type = SCL_PARSER_TYPE_BINARY_XML;
1960 scl_parser_type = SCL_PARSER_TYPE_XML;
1964 if (ime_get_main_window()) {
1965 g_ise_created = true;
1967 sclboolean succeeded = FALSE;
1969 const sclchar *entry_path = MAIN_ENTRY_XML_PATH;
1972 CSCLUtils *utils = CSCLUtils::get_instance();
1974 utils->get_screen_resolution(&nwidth, &nheight);
1976 _language_manager.set_resource_file_path(entry_path);
1977 const sclchar *resource_file_path = _language_manager.get_resource_file_path();
1979 if (resource_file_path) {
1980 if (strlen(resource_file_path) > 0) {
1981 succeeded = g_ui->init(ime_get_main_window(), scl_parser_type, resource_file_path);
1985 g_ui->init(ime_get_main_window(), scl_parser_type, MAIN_ENTRY_XML_PATH);
1988 g_ui->set_longkey_duration(elm_config_longpress_timeout_get() * 1000);
1990 /* Default ISE callback */
1991 g_ui->set_ui_event_callback(&callback);
1993 /* Accumulated customized ISE callbacks, depending on the input modes */
1994 for (scluint loop = 0;loop < _language_manager.get_languages_num();loop++) {
1995 LANGUAGE_INFO *language = _language_manager.get_language_info(loop);
1997 for (scluint inner_loop = 0;inner_loop < language->input_modes.size();inner_loop++) {
1998 INPUT_MODE_INFO &info = language->input_modes.at(inner_loop);
1999 LOGD("Registering callback for input mode %s : %p\n", info.name.c_str(), language->callback);
2000 g_ui->set_ui_event_callback(language->callback, info.name.c_str());
2005 read_ise_config_values();
2006 _language_manager.set_enabled_languages(g_config_values.enabled_languages);
2007 _language_manager.select_language(g_config_values.selected_language.c_str());
2008 vconf_set_bool(VCONFKEY_AUTOCAPITAL_ALLOW_BOOL, g_config_values.auto_capitalise);
2009 vconf_set_bool(VCONFKEY_AUTOPERIOD_ALLOW_BOOL, g_config_values.auto_punctuate);
2010 g_ui->enable_sound(g_config_values.sound_on);
2011 g_ui->enable_vibration(g_config_values.vibration_on);
2012 g_ui->enable_magnifier(g_config_values.preview_on);
2014 g_ui->enable_highlight_ui(TRUE);
2016 g_floating_mode = g_config_values.floating_mode;
2017 ime_set_floating_mode(g_floating_mode);
2020 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_NONE);
2024 preference_is_existing(ISE_CONFIG_KEYPAD_MODE, &exist);
2026 write_ise_config_values();
2029 if (ode_internal_encryption_get_state(&state) == ODE_ERROR_NONE) {
2030 if (state == ODE_STATE_ENCRYPTED) {
2031 if (ode_internal_encryption_set_mount_event_cb(ise_mount_changed_cb, NULL) != ODE_ERROR_NONE)
2032 LOGW("Failed to set mount_event_cb()");
2033 } else if (state == ODE_STATE_UNENCRYPTED) {
2034 register_preference_changed_callback();
2037 LOGW("Failed to get encryption_state");
2040 init_recent_used_punctuation();
2046 ise_hide_stt_mode();
2049 LOGD("calling g_ui->fini()\n");
2051 LOGD("deleting g_ui\n");
2062 destroy_indicator_window();
2065 /* This is necessary. If this is not called, 3rd party IME might have auto period input regardless its settings */
2066 vconf_set_bool(VCONFKEY_AUTOPERIOD_ALLOW_BOOL, false);
2068 #if EXIT_ISE_ON_HIDE
2069 if (exit_timer) ecore_timer_del(exit_timer);
2075 ise_app_candidate_show()
2078 if (!g_softcandidate_show) {
2083 delete_softcandidate_hide_timer();
2085 create_softcandidate();
2087 g_softcandidate_show = true;
2089 g_candidate->show();
2090 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_SHOW);
2095 ise_app_candidate_hide()
2099 if (!g_candidate || !g_softcandidate_show) {
2100 LOGD("No candidate\n");
2104 if (g_ic_smartreply != -1 || g_autofill_exist)
2107 add_softcandidate_hide_timer();
2111 void ise_check_wearable_candidate()
2113 if (!g_config_values.prediction_on) {
2114 ise_app_candidate_hide();
2115 } else if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_PHONENUMBER ||
2116 g_keyboard_state.layout == ISE_LAYOUT_STYLE_VOICE ||
2117 g_keyboard_state.layout == ISE_LAYOUT_STYLE_IP ||
2118 g_keyboard_state.layout == ISE_LAYOUT_STYLE_MONTH ||
2119 g_keyboard_state.layout == ISE_LAYOUT_STYLE_NUMBERONLY ||
2120 g_keyboard_state.layout == ISE_LAYOUT_STYLE_PASSWD_3X4||
2121 g_keyboard_state.layout == ISE_LAYOUT_STYLE_PASSWORD) {
2122 ise_app_candidate_hide();
2124 g_softcandidate_show = true;
2125 ise_app_candidate_show();
2129 void ise_set_emoticon_label(int group_id)
2131 const int BUF_LEN = 16;
2132 char buf[BUF_LEN] = {0};
2133 snprintf(buf, BUF_LEN, "%d/3", group_id);
2134 g_ui->set_private_key("EMOTICON_GROUP_ID", buf, NULL, NULL, 0, const_cast<sclchar*>("EMOTICON_GROUP_NEXT"), TRUE);
2138 // when it is the time to auto_cap, the
2139 // ise_set_caps_mode is called.
2140 // -------------------------------------------------------
2141 // For example: [How are you. Fine.], the
2142 // auto-capital process is as below:
2143 // Note: "["<--this is the beginning,
2144 // "|"<--this is the cursor position
2145 // 1) call ise_set_caps_mode, auto_cap = on
2148 // 2) call ise_set_caps_mode, auto_cap = off
2151 // 3) input: "w are you. "
2152 // result: [How are you. |
2153 // 4) call ise_set_caps_mode, auto_cap = on
2155 // result: [How are you. F
2157 // result: [How are you. Fine.|
2158 // --------------------------------------------------------
2159 // If we want to change the auto_cap, eg,
2160 // if we want to input [How Are you.]
2161 // Note the "Are" is not use auto-capital rule.
2163 // ise_send_event(MVK_Shift_On, SclCoreKeyMask_Null);
2164 // when we are want to input "A"
2165 // following input still has the auto_cap rule.
2167 ise_set_caps_mode(unsigned int mode)
2169 LOGD("caps_mode : %d\n", mode);
2171 g_keyboard_state.caps_mode = TRUE;
2173 g_keyboard_state.caps_mode = FALSE;
2175 g_caps_mode_pending = false;
2176 const sclchar *cur_lang = _language_manager.get_current_language();
2178 LANGUAGE_INFO *info = _language_manager.get_language_info(cur_lang);
2180 if (info->accepts_caps_mode) {
2181 /* If we are inputting multitap character, do not manipulate shift mode */
2182 if (g_keyboard_state.prev_modifier != KEY_MODIFIER_MULTITAP_START &&
2183 g_keyboard_state.prev_modifier != KEY_MODIFIER_MULTITAP_REPEAT) {
2184 set_caps_mode(g_keyboard_state.caps_mode);
2186 g_caps_mode_pending = true;
2187 LOGD("Currently composing multitap string, skipping caps request");
2195 ise_update_cursor_position(int position)
2197 LOGD("cursor position : %d\n", position);
2198 if (g_ui && g_keyboard_state.layout == ISE_LAYOUT_STYLE_URL) {
2201 g_ui->set_string_substitution("www.", ".com");
2203 g_ui->unset_string_substitution("www.");
2209 void ise_set_return_key_type(unsigned int type)
2211 const int BUF_LEN = 256;
2212 char buf[BUF_LEN] = {0};
2216 LOGD("return key type : %d\n", type);
2219 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE:
2220 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_DONE);
2222 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_GO:
2223 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_GO);
2225 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_JOIN:
2226 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_JOIN);
2228 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_LOGIN:
2229 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_LOGIN);
2231 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT:
2232 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_NEXT);
2234 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH:
2235 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_SEARCH);
2237 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEND:
2238 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_SEND);
2240 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SIGNIN:
2241 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_SIGNIN);
2243 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT:
2246 LOGW("Unknown return key type : %d\n", type);
2247 type = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
2251 if (type == ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT) {
2252 g_ui->unset_private_key("Enter");
2254 g_ui->unset_private_key("Done");
2258 if (type == ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH) {
2259 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
2260 const_cast<sclchar*>("w_sip_3x4_btn_ic_search.png"),
2261 const_cast<sclchar*>("w_sip_3x4_btn_ic_search_p.png"),
2262 const_cast<sclchar*>("w_sip_3x4_btn_ic_search_d.png")};
2263 g_ui->set_private_key("Enter", const_cast<sclchar*>(""), imagelabel, NULL, 0, const_cast<sclchar*>("Enter"), TRUE);
2269 g_ui->set_private_key("Done", buf, NULL, NULL, 0, const_cast<sclchar*>("Done"), TRUE);
2271 static sclchar *imagelabel[SCL_BUTTON_STATE_MAX] = {
2272 const_cast<sclchar*>(" "), const_cast<sclchar*>(" "), const_cast<sclchar*>(" ")
2275 g_ui->set_private_key("Enter", buf, imagelabel, NULL, 0, const_cast<sclchar*>("Enter"), TRUE);
2277 LOGD("return key label : %s\n", buf);
2281 void ise_set_return_key_disable(unsigned int disabled)
2283 LOGD("enable : %d\n", !disabled);
2286 g_ui->enable_button("Done", !disabled);
2289 g_ui->enable_button("Enter", !disabled);
2293 void ise_get_language_locale(char **locale)
2295 LANGUAGE_INFO *info = _language_manager.get_current_language_info();
2297 if (!(info->locale_string.empty())) {
2298 *locale = strdup(info->locale_string.c_str());
2303 void ise_update_table(const vector<string> &vec_str)
2305 if (!g_candidate || !g_softcandidate_show)
2306 create_softcandidate();
2309 g_candidate->update(vec_str);
2313 void ise_process_key_event(scim::KeyEvent& key, sclu32 &ret)
2315 Eina_Bool back_key_pressed = EINA_FALSE;
2316 Eina_Bool back_key_released = EINA_FALSE;
2318 if (key.get_key_string().compare("XF86Back") == 0) {
2319 back_key_pressed = EINA_TRUE;
2320 } else if (key.get_key_string().compare("KeyRelease+XF86Back") == 0) {
2321 back_key_released = EINA_TRUE;
2324 if (back_key_pressed || back_key_released) {
2325 if (g_popup_opened == TRUE) {
2326 if (back_key_released) {
2327 g_ui->close_all_popups();
2337 if (!g_candidate->soft_candidate_flag()) {
2339 if (key.dev_name.compare("ime") != 0) {
2340 ret = (sclu32)g_ui->process_key_event(key.get_key_string().c_str());
2345 ret = g_candidate->soft_candidate_handle_key_event(key.get_key_string().c_str());
2349 /* Process this key event if it was not generated by ime */
2350 if (key.dev_name.compare("ime") != 0) {
2351 ret = (sclu32)g_ui->process_key_event(key.get_key_string().c_str());
2357 /* Process this key event if it was not generated by ime */
2358 if (key.dev_name.compare("ime") != 0) {
2359 ret = (sclu32)g_ui->process_key_event(key.get_key_string().c_str());
2365 static void init_recent_used_punctuation()
2367 if (g_recent_used_punctuation.empty())
2369 g_recent_used_punctuation.push_back("#");
2370 g_recent_used_punctuation.push_back("$");
2371 g_recent_used_punctuation.push_back("%");
2372 g_recent_used_punctuation.push_back("^");
2373 g_recent_used_punctuation.push_back("&");
2377 static void update_recent_used_punctuation(const char * key_value)
2379 if (NULL == key_value)
2383 for (int i = 0; i < 10; ++i)
2386 snprintf(buf, sizeof(buf), "%d", i);
2387 if (strcmp(key_value, buf) == 0)
2392 string strKey = string(key_value);
2393 for (int i = 0; i < MAX_DEFAULT_PUNCTUATION; ++i)
2395 if (0 == strKey.compare(g_default_punctuation[i].c_str()))
2400 vector<string>::iterator iter = g_recent_used_punctuation.begin();
2401 for (; iter != g_recent_used_punctuation.end(); ++iter)
2403 if (0 == strKey.compare(iter->c_str()))
2408 if (iter != g_recent_used_punctuation.end())
2410 g_recent_used_punctuation.erase(iter);
2412 g_recent_used_punctuation.push_back(strKey);
2413 if (g_recent_used_punctuation.size() > MAX_DEFAULT_PUNCTUATION-1)
2415 g_recent_used_punctuation.erase(g_recent_used_punctuation.begin());
2419 static void set_ime_size(bool floating_mode, ISE_CANDIDATE_REQUEST candidate_req)
2424 const char *input_mode = g_ui->get_input_mode();
2428 SclSize size_portrait = g_ui->get_input_mode_size(input_mode, DISPLAYMODE_PORTRAIT);
2429 SclSize size_landscape = g_ui->get_input_mode_size(input_mode, DISPLAYMODE_LANDSCAPE);
2431 if (floating_mode) {
2432 size_portrait.width *= FLOATING_SCALE_RATE;
2433 size_portrait.height *= FLOATING_SCALE_RATE;
2434 size_landscape.width *= FLOATING_SCALE_RATE;
2435 size_landscape.height *= FLOATING_SCALE_RATE;
2436 switch (candidate_req) {
2437 case ISE_CANDIDATE_REQ_NONE:
2438 if (g_candidate && g_candidate->get_visible()) {
2439 g_ui->set_custom_starting_coordinates(0, FLOATING_TITLE_BAR_HEIGHT + g_candidate->get_height());
2440 size_portrait.height += g_candidate->get_height();
2441 size_landscape.height += g_candidate->get_height();
2443 g_ui->set_custom_starting_coordinates(0, FLOATING_TITLE_BAR_HEIGHT);
2446 case ISE_CANDIDATE_REQ_SHOW:
2447 g_ui->set_custom_starting_coordinates(0, FLOATING_TITLE_BAR_HEIGHT + g_candidate->get_height());
2448 if (g_input_panel_show || g_candidate_more_view) {
2449 size_portrait.height += g_candidate->get_height();
2450 size_landscape.height += g_candidate->get_height();
2452 size_portrait.height = g_candidate->get_height();
2453 size_landscape.height = g_candidate->get_height();
2456 case ISE_CANDIDATE_REQ_HIDE:
2457 g_ui->set_custom_starting_coordinates(0, FLOATING_TITLE_BAR_HEIGHT);
2462 if (g_ui->get_custom_scale_rate_x() != FLOATING_SCALE_RATE || g_ui->get_custom_scale_rate_y() != FLOATING_SCALE_RATE)
2463 g_ui->set_custom_scale_rate(FLOATING_SCALE_RATE, FLOATING_SCALE_RATE);
2465 ime_set_size(size_portrait.width, size_portrait.height + FLOATING_TITLE_BAR_HEIGHT,
2466 size_landscape.width, size_landscape.height + FLOATING_TITLE_BAR_HEIGHT);
2468 #if defined(_MOBILE) || defined(_COMMON)
2469 ise_destroy_move_handler();
2470 int rotation = elm_win_rotation_get(NATIVE_WINDOW_CAST(ime_get_main_window()));
2471 int handler_width = (rotation == 0 || rotation == 180) ? size_portrait.width : size_landscape.width;
2472 ise_show_move_handler(handler_width, FLOATING_TITLE_BAR_HEIGHT);
2475 switch (candidate_req) {
2476 case ISE_CANDIDATE_REQ_NONE:
2477 if (g_candidate && g_candidate->get_visible()) {
2478 g_ui->set_custom_starting_coordinates(0, g_candidate->get_height());
2479 size_portrait.height += g_candidate->get_height();
2480 size_landscape.height += g_candidate->get_height();
2482 g_ui->set_custom_starting_coordinates(0, 0);
2485 case ISE_CANDIDATE_REQ_SHOW:
2486 g_ui->set_custom_starting_coordinates(0, g_candidate->get_height());
2487 if (g_input_panel_show || g_candidate_more_view) {
2488 size_portrait.height += g_candidate->get_height();
2489 size_landscape.height += g_candidate->get_height();
2491 size_portrait.height = g_candidate->get_height();
2492 size_landscape.height = g_candidate->get_height();
2495 case ISE_CANDIDATE_REQ_HIDE:
2496 g_ui->set_custom_starting_coordinates(0, 0);
2501 if (g_ui->get_custom_scale_rate_x() != 1.0 || g_ui->get_custom_scale_rate_y() != 1.0)
2502 g_ui->set_custom_scale_rate(1.0, 1.0);
2504 ime_set_size(size_portrait.width, size_portrait.height, size_landscape.width, size_landscape.height);
2506 #if defined(_MOBILE) || defined(_COMMON)
2507 ise_destroy_move_handler();
2512 static void ime_app_create_cb(void *user_data)
2514 if (!engine_loader_dbus_init(NULL))
2515 LOGE("Failed to initialize dbus");
2517 #if !(DEFER_ISE_CREATION)
2520 elm_app_name_set(PACKAGE);
2522 char *elm_scale = getenv("ELM_SCALE");
2523 LOGD("ELM_SCALE : %s", elm_scale);
2526 elm_app_base_scale_set(atof(elm_scale));
2529 cbhm_open_service(&cbhm_handle);
2533 static void ime_app_exit_cb(void *user_data)
2538 if (!engine_loader_dbus_shutdown())
2539 LOGE("Failed to finalize dbus");
2542 cbhm_close_service(cbhm_handle);
2547 static void show_autofill_data(Ecore_IMF_Input_Hints input_hints)
2549 g_autofill_exist = false;
2550 char *text = autofill_get_string(g_app_id.c_str(), g_resource_id.c_str(), input_hints);
2553 g_autofill_string = string(text);
2556 g_autofill_string = string("");
2558 SECURE_LOGD("autofill string : %s", g_autofill_string.c_str());
2560 if (g_autofill_string.length() > 0) {
2561 g_autofill_exist = true;
2563 ise_app_candidate_show();
2564 update_candidate_table();
2568 static void ime_app_show_cb(int ic, ime_context_h ime_ctx, void *user_data)
2570 Ise_Context iseContext;
2571 bool return_key_state, prediction_allow, password_mode, caps_mode;
2572 ime_layout_variation_e layout_variation;
2577 ime_context_get_layout(ime_ctx, &iseContext.layout);
2579 ime_context_get_layout_variation(ime_ctx, &layout_variation);
2580 iseContext.layout_variation = (int)layout_variation;
2582 ime_context_get_cursor_position(ime_ctx, &iseContext.cursor_pos);
2583 ime_context_get_autocapital_type(ime_ctx, &iseContext.autocapital_type);
2584 ime_context_get_return_key_type(ime_ctx, &iseContext.return_key_type);
2585 ime_context_get_return_key_state(ime_ctx, &return_key_state);
2587 ime_context_get_prediction_mode(ime_ctx, &prediction_allow);
2588 iseContext.prediction_allow = prediction_allow;
2590 ime_context_get_password_mode(ime_ctx, &password_mode);
2591 iseContext.password_mode = password_mode;
2593 ime_context_get_input_hint(ime_ctx, &iseContext.input_hint);
2594 ime_context_get_bidi_direction(ime_ctx, &iseContext.bidi_direction);
2595 ime_context_get_language(ime_ctx, &iseContext.language);
2596 ime_context_get_caps_mode(ime_ctx, &caps_mode);
2597 iseContext.caps_mode = caps_mode;
2599 iseContext.return_key_disabled = return_key_state;
2601 engine_loader_set_input_hint((uint32_t)iseContext.input_hint);
2602 engine_loader_update_bidi_direction((uint32_t)iseContext.bidi_direction);
2606 g_autofill_hint = iseContext.input_hint & ECORE_IMF_INPUT_HINT_AUTOFILL_MASK;
2608 LOGD("input hint : %x, autofill hint : %x\n", iseContext.input_hint, g_autofill_hint);
2610 // show autofill data
2611 show_autofill_data((Ecore_IMF_Input_Hints)g_autofill_hint);
2613 //g_ise_common->set_keyboard_ise_by_uuid(KEYBD_ISE_UUID);
2615 /* Don't update screen until all the information is correctly set */
2617 g_ui->set_update_pending(TRUE);
2619 ise_reset_context(); // reset ISE
2621 /*if (context.language == ECORE_IMF_INPUT_PANEL_LANG_ALPHABET) {
2622 ise_explictly_set_language(PRIMARY_LATIN_LANGUAGE_INDEX);
2625 _context_layout = iseContext.layout;
2626 _context_layout_variation = iseContext.layout_variation;
2627 ise_set_layout(iseContext.layout, iseContext.layout_variation);
2629 ise_set_return_key_type(iseContext.return_key_type);
2630 ise_set_return_key_disable(iseContext.return_key_disabled);
2632 ise_set_caps_mode(iseContext.caps_mode);
2633 ise_update_cursor_position(iseContext.cursor_pos);
2637 /* Now we update the whole screen */
2639 g_ui->set_update_pending(FALSE);
2642 static void ime_app_hide_cb(int ic, void *user_data)
2647 g_set_mime_type = FALSE;
2649 g_ic_smartreply = -1;
2652 static void ime_app_return_key_type_set_cb(Ecore_IMF_Input_Panel_Return_Key_Type type, void *user_data)
2654 LOGD("return key type : %d\n", type);
2655 ise_set_return_key_type(type);
2657 if (g_keyboard_state.visible_state)
2658 ise_show(g_keyboard_state.ic);
2661 static void ime_app_return_key_state_set_cb(bool disabled, void *user_data)
2663 LOGD("return key disabled : %d\n", disabled);
2664 ise_set_return_key_disable(disabled);
2667 static void ime_app_language_set_cb(Ecore_IMF_Input_Panel_Lang language, void *user_data)
2669 LOGD("language : %d\n", language);
2672 static void ime_app_input_context_reset_cb(void *user_data)
2674 ise_reset_input_context();
2675 engine_loader_reset_input_context();
2678 static void ime_app_cursor_position_updated_cb(int cursor_pos, void *user_data)
2680 LOGD("cursor position : %d\n", cursor_pos);
2681 ise_update_cursor_position(cursor_pos);
2682 engine_loader_update_cursor_position(cursor_pos);
2685 static void ime_app_language_requested_cb(void *user_data, char **lang_code)
2687 ise_get_language_locale(lang_code);
2690 static void ime_app_surrounding_text_updated_cb(int context_id, const char *text, int cursor_pos, void *user_data)
2692 SECURE_LOGD("surrounding text:%s, cursor=%d\n", text, cursor_pos);
2693 ime_delete_surrounding_text(-cursor_pos, strlen(text));
2696 static void ime_app_focus_in_cb(int context_id, void *user_data)
2699 ise_focus_in(context_id);
2700 if (!g_smartreply_reply_exist && g_softcandidate_show) {
2702 ise_app_candidate_hide();
2703 g_candidate->hide();
2707 engine_loader_focus_in();
2710 static void ime_app_focus_out_cb(int context_id, void *user_data)
2713 ise_focus_out(context_id);
2716 g_set_mime_type = FALSE;
2718 g_smartreply_reply_exist = false;
2719 g_smartreply_size = 0;
2720 input_smartreply_deinit();
2721 g_ic_smartreply = -1;
2723 g_autofill_exist = false;
2724 g_autofill_hint = 0;
2726 g_app_id = string("");
2727 g_resource_id = string("");
2729 g_autofill_string = string("");
2730 g_smartreply_strings.clear();
2731 g_lookup_table_strings.clear();
2732 g_softcandidate_string.clear();
2734 engine_loader_focus_out();
2737 static void ime_app_layout_set_cb(Ecore_IMF_Input_Panel_Layout layout, void *user_data)
2739 LOGD("layout=%d\n", layout);
2740 /* Check if the layoutIdx is in the valid range */
2741 if (static_cast<int>(layout) < static_cast<int>(ISE_LAYOUT_STYLE_MAX)) {
2742 if (g_keyboard_state.layout != layout) {
2743 g_keyboard_state.need_reset = TRUE;
2745 g_keyboard_state.layout = layout;
2746 _context_layout = layout;
2747 _context_layout_variation = 0;
2749 if (g_keyboard_state.visible_state)
2750 ise_show(g_keyboard_state.ic);
2752 engine_loader_set_layout(static_cast<uint32_t>(layout));
2755 static void ime_app_rotation_degree_changed_cb(int degree, void *user_data)
2757 ise_set_screen_rotation(degree);
2759 LOGD("degree=%d\n", degree);
2761 if (g_floating_mode) {
2763 ise_destroy_move_handler();
2764 if (degree == 0 || degree == 180) {
2765 SclSize size_portrait = g_ui->get_input_mode_size(g_ui->get_input_mode(), DISPLAYMODE_PORTRAIT);
2766 handler_width = size_portrait.width * FLOATING_SCALE_RATE;
2768 SclSize size_landscape = g_ui->get_input_mode_size(g_ui->get_input_mode(), DISPLAYMODE_LANDSCAPE);
2769 handler_width = size_landscape.width * FLOATING_SCALE_RATE;
2771 ise_show_move_handler(handler_width, FLOATING_TITLE_BAR_HEIGHT);
2774 if (is_emoticon_show()) {
2775 ise_destroy_emoticon_layout();
2777 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_VOICE) {
2778 ise_hide_stt_mode();
2780 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_EMOTICON) {
2781 ise_show_emoticon_layout(current_emoticon_group, degree, false, ime_get_main_window());
2783 const sclchar *input_mode = g_ui->get_input_mode();
2785 if (!(strcmp(input_mode, "EMOTICON_LAYOUT")))
2786 ise_show_emoticon_layout(current_emoticon_group, degree, false, ime_get_main_window());
2787 else if (!(strcmp(input_mode, "STT_3X4")))
2788 ise_show_stt_mode(NATIVE_WINDOW_CAST(ime_get_main_window()));
2793 static void ime_app_accessibility_state_changed_cb(bool state, void *user_data)
2795 LOGD("state=%d\n", state);
2796 ise_set_accessibility_state(state);
2799 static void ime_app_imdata_set_cb(void *data, unsigned int data_length, void *user_data)
2803 size_t _len = data_length;
2804 set_ise_imdata((sclchar *)data, _len);
2805 engine_loader_set_imdata((const char*)data, (uint32_t)data_length);
2808 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)
2810 scim::KeyEvent key(keycode, keymask);
2812 char *dev_name = NULL;
2813 Ecore_IMF_Device_Class dev_class;
2814 Ecore_IMF_Device_Subclass dev_subclass;
2816 if (ime_device_info_get_name(dev_info, &dev_name) == IME_ERROR_NONE) {
2817 key.dev_name = dev_name;
2820 if (ime_device_info_get_class(dev_info, &dev_class) == IME_ERROR_NONE) {
2821 key.dev_class = dev_class;
2824 if (ime_device_info_get_subclass(dev_info, &dev_subclass) == IME_ERROR_NONE) {
2825 key.dev_subclass = dev_subclass;
2828 if (g_keyboard_state.visible_state)
2829 ise_process_key_event(key, ret);
2839 static bool ime_app_process_key_event_with_imengine_cb(scim::KeyEvent &key, void *user_data)
2842 LANGUAGE_INFO *info = _language_manager.get_language_info(_language_manager.get_current_language());
2843 if (info && info->need_surrounding_text)
2844 ret = engine_loader_process_key_event(key, true);
2846 ret = engine_loader_process_key_event(key, false);
2851 static void ime_app_caps_mode_changed_cb(int mode, void *user_data)
2853 ise_set_caps_mode(mode);
2856 static void ime_app_candidate_show_cb(int context_id, void *user_data)
2859 ise_check_wearable_candidate();
2861 ise_app_candidate_show();
2865 static void ime_app_candidate_hide_cb(int context_id, void *user_data)
2868 ise_check_wearable_candidate();
2870 ise_app_candidate_hide();
2874 static void ime_app_lookup_table_changed_cb(Eina_List *list, void *user_data)
2876 vector<string> candidate_strings;
2881 g_lookup_table_strings.clear();
2884 EINA_LIST_FOREACH(list, l, data) {
2885 candidate = (char *)data;
2887 g_lookup_table_strings.push_back(string(candidate));
2888 candidate_strings.push_back(string(candidate));
2893 if (g_smartreply_reply_exist) {
2894 if (candidate_strings[0] == "#" && candidate_strings[1] == "$") {
2897 ime_get_surrounding_text(0, 0, &text, &cursor);
2906 update_candidate_table();
2910 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)
2912 if (device_type == IME_INPUT_DEVICE_TYPE_ROTARY) {
2913 ime_input_device_rotary_direction_e direction;
2914 if (IME_ERROR_NONE == ime_input_device_rotary_get_direction(device_event, &direction)) {
2915 sclu32 new_layout = g_keyboard_state.layout;
2916 if (direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_CLOCKWISE) {
2917 LOGD("CLOCKWISE\n");
2918 switch (g_keyboard_state.layout) {
2919 case ISE_LAYOUT_STYLE_NORMAL:
2920 case ISE_LAYOUT_STYLE_EMAIL:
2921 case ISE_LAYOUT_STYLE_URL:
2922 case ISE_LAYOUT_STYLE_PASSWORD:
2923 if (_context_layout == ISE_LAYOUT_STYLE_PASSWORD &&
2924 _context_layout_variation == ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD_VARIATION_NUMBERONLY)
2925 ; // PASSWORD NUMBER ONLY, do nothing
2927 new_layout = ISE_LAYOUT_STYLE_NUMBER;
2929 case ISE_LAYOUT_STYLE_NUMBER:
2930 new_layout = ISE_LAYOUT_STYLE_HEX;
2932 case ISE_LAYOUT_STYLE_HEX:
2933 if (_context_layout == ISE_LAYOUT_STYLE_EMAIL ||
2934 _context_layout == ISE_LAYOUT_STYLE_URL)
2935 new_layout = ISE_LAYOUT_STYLE_VOICE;
2936 else if (_context_layout == ISE_LAYOUT_STYLE_PASSWORD)
2937 new_layout = _context_layout;
2939 new_layout = ISE_LAYOUT_STYLE_EMOTICON;
2941 case ISE_LAYOUT_STYLE_EMOTICON:
2942 if (_context_layout == ISE_LAYOUT_STYLE_EMAIL ||
2943 _context_layout == ISE_LAYOUT_STYLE_URL ||
2944 _context_layout == ISE_LAYOUT_STYLE_PASSWORD)
2945 new_layout = _context_layout;
2947 new_layout = ISE_LAYOUT_STYLE_VOICE;
2949 case ISE_LAYOUT_STYLE_VOICE:
2950 new_layout = ISE_LAYOUT_STYLE_NORMAL;
2955 } else if (direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_COUNTER_CLOCKWISE) {
2956 LOGD("COUNTER_CLOCKWISE\n");
2957 switch (g_keyboard_state.layout) {
2958 case ISE_LAYOUT_STYLE_NORMAL:
2959 case ISE_LAYOUT_STYLE_EMAIL:
2960 case ISE_LAYOUT_STYLE_URL:
2961 case ISE_LAYOUT_STYLE_PASSWORD:
2962 if (_context_layout == ISE_LAYOUT_STYLE_PASSWORD &&
2963 _context_layout_variation == ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD_VARIATION_NUMBERONLY)
2964 ; // PASSWORD NUMBER ONLY, do nothing
2965 else if (_context_layout == ISE_LAYOUT_STYLE_PASSWORD)
2966 new_layout = ISE_LAYOUT_STYLE_HEX;
2968 new_layout = ISE_LAYOUT_STYLE_VOICE;
2970 case ISE_LAYOUT_STYLE_NUMBER:
2971 if (_context_layout == ISE_LAYOUT_STYLE_EMAIL ||
2972 _context_layout == ISE_LAYOUT_STYLE_URL ||
2973 _context_layout == ISE_LAYOUT_STYLE_PASSWORD)
2974 new_layout = _context_layout;
2976 new_layout = ISE_LAYOUT_STYLE_NORMAL;
2978 case ISE_LAYOUT_STYLE_HEX:
2979 new_layout = ISE_LAYOUT_STYLE_NUMBER;
2981 case ISE_LAYOUT_STYLE_EMOTICON:
2982 new_layout = ISE_LAYOUT_STYLE_HEX;
2984 case ISE_LAYOUT_STYLE_VOICE:
2985 if (_context_layout == ISE_LAYOUT_STYLE_EMAIL ||
2986 _context_layout == ISE_LAYOUT_STYLE_URL)
2987 new_layout = ISE_LAYOUT_STYLE_HEX;
2989 new_layout = ISE_LAYOUT_STYLE_EMOTICON;
2996 if (check_is_tutorial_show()) {
2997 read_ise_config_values();
2998 if ((direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_COUNTER_CLOCKWISE && !g_config_values.number_tutorial_enable && !g_config_values.symbol_tutorial_enable) ||
2999 (direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_CLOCKWISE && g_config_values.symbol_tutorial_enable)) {
3000 new_layout = g_keyboard_state.layout;
3001 } else if (direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_COUNTER_CLOCKWISE && g_config_values.symbol_tutorial_enable) {
3002 ise_destroy_tutorial_mode_popup();
3003 g_config_values.symbol_tutorial_enable = false;
3004 write_ise_config_values();
3005 } else if (direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_CLOCKWISE && !g_config_values.number_tutorial_enable) {
3006 ise_destroy_tutorial_mode_popup();
3007 new_layout = ISE_LAYOUT_STYLE_NUMBER;
3008 if (!g_config_values.symbol_tutorial_enable) {
3009 ise_show_tutorial_mode_popup(new_layout);
3010 g_config_values.symbol_tutorial_enable = true;
3011 write_ise_config_values();
3016 if (new_layout != g_keyboard_state.layout && new_layout < ISE_LAYOUT_STYLE_MAX) {
3017 g_keyboard_state.need_reset = TRUE;
3018 g_keyboard_state.layout = new_layout;
3020 if (g_keyboard_state.visible_state) {
3021 _reset_multitap_state();
3022 _language_manager.reset_language(g_config_values.selected_language.c_str());
3023 ise_show(g_keyboard_state.ic);
3031 static void ime_app_prediction_hint_set_cb(const char *prediction_hint, void *user_data)
3033 char *sender = (char *)"mms";
3034 char *caller_id = (char *)"mms";
3035 char *hint = (char *)prediction_hint;
3037 if (!prediction_hint) return;
3038 SECURE_LOGD("prediction hint : %s\n", prediction_hint);
3040 if (strlen(prediction_hint) > 0) {
3041 input_smartreply_init(caller_id, sender, hint);
3042 input_smartreply_set_notify(_input_smartreply_notify_cb, NULL);
3044 if (input_smartreply_is_enabled()) {
3045 g_smartreply_size = 0;
3046 g_smartreply_reply_exist = false;
3048 input_smartreply_get_reply_async();
3053 static void ime_app_mime_type_set_request_cb(const char *mime_types, void *user_data)
3055 LOGD("mime type : %s\n", mime_types);
3058 g_set_mime_type = TRUE;
3060 string str(mime_types), text_key = "text/", image_key = "image/";
3062 if (str.find(text_key) != string::npos)
3063 cbhm_sel_type |= CBHM_SEL_TYPE_TEXT;
3065 if (str.find(image_key) != string::npos)
3066 cbhm_sel_type |= CBHM_SEL_TYPE_IMAGE;
3068 LOGD("cbhm_sel_type=0x%x", cbhm_sel_type);
3072 static void ime_app_prediction_hint_data_set_cb(const char *key, const char *value, void *user_data)
3074 SECURE_LOGD("key : %s, value : %s\n", key, value);
3076 if (string(key) == "appid")
3077 g_app_id = string(value ? value : "");
3078 else if (string(key) == "res_id")
3079 g_resource_id = string(value ? value : "");
3082 static void ime_app_autocapital_type_set_cb(uint32_t type, void *user_data)
3084 LOGD("autocapital type : %u\n", type);
3085 engine_loader_set_autocapital_type(type);
3088 static void ime_app_prediction_allow_set_cb(uint32_t prediction_allow, void *user_data)
3090 LOGD("prediction allow : %u\n", prediction_allow);
3091 engine_loader_set_prediction_allow(prediction_allow);
3094 static void ime_app_trigger_property_set_cb(const char *property, void *user_data)
3096 LOGD("trigger property : %s\n", property);
3097 engine_loader_trigger_property(property);
3100 static void ime_app_candidate_more_window_show_cb(void *user_data)
3103 engine_loader_show_candidate_more_window();
3106 static void ime_app_candidate_more_window_hide_cb(void *user_data)
3109 engine_loader_hide_candidate_more_window();
3112 static void ime_app_aux_select_cb(uint32_t item, void *user_data)
3114 LOGD("aux select : %u\n", item);
3115 engine_loader_select_aux(item);
3118 static void ime_app_candidate_select_cb(uint32_t item, void *user_data)
3120 LOGD("candidate select : %u\n", item);
3121 engine_loader_select_candidate(item);
3124 static void ime_app_candidate_table_page_up_cb(void *user_data)
3127 engine_loader_candidate_table_page_up();
3130 static void ime_app_candidate_table_page_down_cb(void *user_data)
3133 engine_loader_candidate_table_page_down();
3136 static void ime_app_candidate_table_page_size_chaned_cb(uint32_t size, void *user_data)
3138 LOGD("candidate page size : %u\n", size);
3139 engine_loader_change_candidate_page_size(size);
3142 static void ime_app_candidate_item_layout_set_cb(vector<uint32_t> item, void *user_data)
3144 LOGD("item layout size : %zu", item.size());
3145 engine_loader_set_candidate_item_layout(item);
3148 static void ime_app_displayed_candidate_number_chaned_cb(uint32_t page_num, void *user_data)
3150 LOGD("candidate number changed : %u\n", page_num);
3151 engine_loader_change_candidate_number(page_num);
3154 static void ime_app_candidate_item_long_pressed_cb(uint32_t index, void *user_data)
3156 LOGD("candidate item : %u\n", index);
3157 engine_loader_long_press_candidate_item(index);
3163 EXPORTED void ime_app_main(int argc, char **argv)
3165 ime_callback_s basic_callback = {
3172 ime_event_set_focus_in_cb(ime_app_focus_in_cb, NULL);
3173 ime_event_set_focus_out_cb(ime_app_focus_out_cb, NULL);
3174 ime_event_set_rotation_degree_changed_cb(ime_app_rotation_degree_changed_cb, NULL);
3175 ime_event_set_accessibility_state_changed_cb(ime_app_accessibility_state_changed_cb, NULL);
3176 ime_event_set_layout_set_cb(ime_app_layout_set_cb, NULL);
3177 ime_event_set_caps_mode_changed_cb(ime_app_caps_mode_changed_cb, NULL);
3178 ime_event_set_cursor_position_updated_cb(ime_app_cursor_position_updated_cb, NULL);
3179 ime_event_set_surrounding_text_updated_cb(ime_app_surrounding_text_updated_cb, NULL);
3180 ime_event_set_return_key_type_set_cb(ime_app_return_key_type_set_cb, NULL);
3181 ime_event_set_return_key_state_set_cb(ime_app_return_key_state_set_cb, NULL);
3182 ime_event_set_language_set_cb(ime_app_language_set_cb, NULL);
3183 ime_event_set_imdata_set_cb(ime_app_imdata_set_cb, NULL);
3184 ime_event_set_process_key_event_cb(ime_app_process_key_event_cb, NULL);
3185 ime_event_set_process_key_event_with_imengine_cb(ime_app_process_key_event_with_imengine_cb, NULL);
3187 ime_event_set_candidate_show_cb(ime_app_candidate_show_cb, NULL);
3188 ime_event_set_candidate_hide_cb(ime_app_candidate_hide_cb, NULL);
3189 ime_event_set_lookup_table_changed_cb(ime_app_lookup_table_changed_cb, NULL);
3192 ime_event_set_process_input_device_event_cb(ime_app_process_input_device_event_cb, NULL);
3195 ime_event_set_input_context_reset_cb(ime_app_input_context_reset_cb, NULL);
3196 ime_event_set_language_requested_cb(ime_app_language_requested_cb, NULL);
3198 ime_event_set_prediction_hint_set_cb(ime_app_prediction_hint_set_cb, NULL);
3199 ime_event_set_mime_type_set_request_cb(ime_app_mime_type_set_request_cb, NULL);
3200 ime_event_set_prediction_hint_data_set_cb(ime_app_prediction_hint_data_set_cb, NULL);
3202 ime_event_set_autocapital_type_set_cb(ime_app_autocapital_type_set_cb, NULL);
3203 ime_event_set_prediction_allow_set_cb(ime_app_prediction_allow_set_cb, NULL);
3204 ime_event_set_trigger_property_set_cb(ime_app_trigger_property_set_cb, NULL);
3205 ime_event_set_candidate_more_window_show_cb(ime_app_candidate_more_window_show_cb, NULL);
3206 ime_event_set_candidate_more_window_hide_cb(ime_app_candidate_more_window_hide_cb, NULL);
3207 ime_event_set_aux_select_cb(ime_app_aux_select_cb, NULL);
3208 ime_event_set_candidate_select_cb(ime_app_candidate_select_cb, NULL);
3209 ime_event_set_candidate_table_page_up_cb(ime_app_candidate_table_page_up_cb, NULL);
3210 ime_event_set_candidate_table_page_down_cb(ime_app_candidate_table_page_down_cb, NULL);
3211 ime_event_set_candidate_table_page_size_chaned_cb(ime_app_candidate_table_page_size_chaned_cb, NULL);
3212 ime_event_set_candidate_item_layout_set_cb(ime_app_candidate_item_layout_set_cb, NULL);
3213 ime_event_set_displayed_candidate_number_chaned_cb(ime_app_displayed_candidate_number_chaned_cb, NULL);
3214 ime_event_set_candidate_item_long_pressed_cb(ime_app_candidate_item_long_pressed_cb, NULL);
3216 #if DEFER_ISE_CREATION
3217 ime_set_window_creation_defer_flag(TRUE);
3220 ime_run(&basic_callback, NULL);
3226 EXPORTED int main(int argc, char *argv[])
3228 ime_app_main(argc, argv);