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>
24 #include <Ecore_IMF.h>
25 #include <Elementary.h>
28 #include <inputmethod.h>
29 #include <inputmethod_internal.h>
30 #include <app_control.h>
31 #include <app_preference.h>
39 #include "languages.h"
40 #include "candidate-factory.h"
41 #include "ise-emoticon-mode.h"
42 #include "ise-stt-mode.h"
43 #include "ise-stt-option.h"
44 #include "ise-language-change.h"
45 #include "modeindicator.h"
46 #include "w-input-smartreply.h"
47 #include "ise-floating-mode.h"
49 #define EDJ_FILE RESDIR"/edje/mobile/customised_ctxpopup.edj"
51 #define EXIT_ISE_ON_HIDE 0
52 #define DEFER_ISE_CREATION 0
54 #define CANDIDATE_WINDOW_HEIGHT 84
62 static cbhm_h cbhm_handle;
63 static sclu32 cbhm_sel_type = 0;
64 static sclboolean g_set_mime_type = FALSE;
67 int g_imdata_state = 0;
69 extern emoticon_group_t current_emoticon_group;
70 extern std::vector <int> emoticon_list_recent;
72 extern CONFIG_VALUES g_config_values;
73 static sclboolean g_need_send_shift_event = FALSE;
75 extern void set_ise_imdata(const char * buf, size_t &len);
76 static void init_recent_used_punctuation();
77 static void update_recent_used_punctuation(const char *key_value);
78 static void set_ime_size(bool floating_mode, ISE_CANDIDATE_REQUEST candidate_req);
79 static sclboolean g_punctuation_popup_opened = FALSE;
80 static sclboolean g_popup_opened = FALSE;
81 static vector<string> g_recent_used_punctuation;
82 static const int MAX_DEFAULT_PUNCTUATION = 6;
83 static string g_default_punctuation[MAX_DEFAULT_PUNCTUATION] = {"-", "@", "'", "!", "?", ","};
84 static string g_current_punctuation[MAX_DEFAULT_PUNCTUATION-1] = {"RCENT1", "RCENT2", "RCENT3", "RCENT4", "RCENT5"};
85 static vector<string> g_softcandidate_string;
86 static bool g_softcandidate_show = false;
87 static bool g_input_panel_show = false;
88 static bool g_smartreply_reply_exist = false;
89 static unsigned int g_smartreply_size = 0;
90 static bool g_caps_mode_pending = false;
91 static bool g_floating_mode = false;
92 static bool g_candidate_more_view = false;
93 static bool g_ise_created = false;
95 static bool g_autofill_exist = false;
96 static int g_autofill_hint = 0;
97 static string g_autofill_string;
98 static vector<string> g_lookup_table_strings;
99 static vector<string> g_smartreply_strings;
101 static Ecore_Timer *guideline_timer = NULL;
104 static Ecore_Timer *exit_timer = NULL;
107 static string g_app_id;
108 static string g_resource_id;
110 #define SOFT_CANDIDATE_DELETE_TIME (100.0/1000)
111 static Ecore_Timer *g_softcandidate_hide_timer = NULL;
113 extern sclboolean g_setting_window_open_status;
116 static int g_ic_smartreply = -1;
118 KEYBOARD_STATE g_keyboard_state = {
121 ISE_LAYOUT_STYLE_NORMAL,
131 #define ISE_LAYOUT_NUMBERONLY_VARIATION_MAX 4
132 /*static const sclchar *_ise_numberonly_variation_name[ISE_LAYOUT_NUMBERONLY_VARIATION_MAX] = {
133 "DEFAULT", "SIG", "DEC", "SIGDEC"
136 #define SIG_DEC_SIZE 2
137 static scluint _click_count = 0;
138 static const char *_sig_dec[SIG_DEC_SIZE] = {".", "-"};
139 static scluint _sig_dec_event[SIG_DEC_SIZE] = {'.', '-'};
140 static Ecore_Timer *_commit_timer = NULL;
142 static sclu32 _context_layout = ISE_LAYOUT_STYLE_NORMAL;
143 static sclu32 _context_layout_variation = 0;
145 Candidate *g_candidate = NULL;
147 class CandidateEventListener: public EventListener
150 void on_event(const EventDesc &desc)
152 const MultiEventDesc &multidesc = dynamic_cast<const MultiEventDesc &>(desc);
153 switch (multidesc.type) {
154 case MultiEventDesc::CANDIDATE_ITEM_MOUSE_DOWN:
155 if (g_autofill_exist) {
156 if (multidesc.index == 0) {
157 char *text = autofill_get_string((Ecore_IMF_Input_Hints)g_autofill_hint);
159 ise_send_string(text);
162 } else if (multidesc.index < (int)g_smartreply_size + 1) {
163 ise_send_string(g_softcandidate_string[multidesc.index].c_str());
165 ime_select_candidate(multidesc.index - g_smartreply_size - 1);
168 if (multidesc.index < (int)g_smartreply_size)
169 ise_send_string(g_softcandidate_string[multidesc.index].c_str());
171 ime_select_candidate(multidesc.index - g_smartreply_size);
174 case MultiEventDesc::CANDIDATE_MORE_VIEW_SHOW:
175 // when more parts shows, click on the candidate will
176 // not affect the key click event
177 g_candidate_more_view = true;
178 if (!g_input_panel_show)
179 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_SHOW);
181 g_ui->disable_input_events(TRUE);
183 case MultiEventDesc::CANDIDATE_MORE_VIEW_HIDE:
184 g_candidate_more_view = false;
185 if (!g_input_panel_show)
186 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_SHOW);
188 g_ui->disable_input_events(FALSE);
194 static CandidateEventListener g_candidate_event_listener;
196 static ISELanguageManager _language_manager;
197 #define MVK_Shift_L 0xffe1
198 #define MVK_Caps_Lock 0xffe5
199 #define MVK_Shift_Off 0xffe1
200 #define MVK_Shift_On 0xffe2
201 #define MVK_Shift_Lock 0xffe6
202 #define MVK_Shift_Enable 0x9fe7
203 #define MVK_Shift_Disable 0x9fe8
204 #define MVK_space 0x020
206 #define CM_KEY_LIST_SIZE 5
207 #define USER_KEYSTRING_OPTION "OPTION"
208 #define USER_KEYSTRING_EMOTICON "EMOTICON_LAYOUT"
209 #define USER_KEYSTRING_CLIPBOARD "CLIPBOARD"
210 #define USER_KEYSTRING_VOICE "STT_3X4"
211 #define USER_KEYSTRING_FLOATING "FLOATING"
213 #define USER_VOICE_LANGUAGE "LANGUAGE"
215 static sclboolean _cm_popup_opened = FALSE;
216 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};
217 static scluint _current_cm_key_id = 0;
218 Evas_Object* _guide_popup_window = NULL;
221 * This callback class will receive all response events from SCL
222 * So you should perform desired tasks in this class.
224 class CUIEventCallback : public ISCLUIEventCallback
227 SCLEventReturnType on_event_key_clicked(SclUIEventDesc event_desc);
228 SCLEventReturnType on_event_drag_state_changed(SclUIEventDesc event_desc);
229 SCLEventReturnType on_event_notification(SCLUINotiType noti_type, SclNotiDesc *etc_info);
232 static CUIEventCallback callback;
234 static void update_candidate_table()
236 g_softcandidate_string.clear();
237 vector<string>::iterator iter;
239 // add autofill string
240 if (g_autofill_exist)
241 g_softcandidate_string.push_back(g_autofill_string);
243 // add lookup table string(s)
244 iter = g_lookup_table_strings.begin();
245 for (; iter != g_lookup_table_strings.end(); ++iter)
247 g_softcandidate_string.push_back(string(iter->c_str()));
250 ise_update_table(g_softcandidate_string);
253 static void _input_smartreply_notify_cb(void *user_data)
255 g_smartreply_strings.clear();
258 if (input_smartreply_is_enabled()) {
259 /* Append newly added smartreply list */
260 int len = input_smartreply_get_reply_num();
262 for (int i = 0; i < len; i++) {
264 char *reply = (char *)"";
265 reply = input_smartreply_get_nth_item(i, &type);
268 SECURE_LOGD("SmartReply = [%d] %s", i, reply);
271 g_smartreply_strings.push_back(string(candidate));
275 g_ic_smartreply = g_ic;
276 g_smartreply_reply_exist = true;
278 ise_app_candidate_show();
279 g_softcandidate_string = g_smartreply_strings;
280 ise_update_table(g_softcandidate_string);
286 check_ic_temporary(int ic)
288 if ((ic & 0xFFFF) == 0) {
294 static void _reset_shift_state(void)
297 /* Reset all shift state variables */
298 SCLShiftState old_shift_state = g_ui->get_shift_state();
299 SCLShiftState new_shift_state = SCL_SHIFT_STATE_OFF;
300 if (old_shift_state != new_shift_state) {
301 g_need_send_shift_event = true;
302 g_ui->set_shift_state(new_shift_state);
304 LOGD("Shift state changed from (%d) to (%d)\n", (int)old_shift_state, (int)new_shift_state);
308 static void set_caps_mode(sclboolean mode) {
309 LOGD("mode : %d\n", mode);
311 if (g_ui->get_shift_state() != SCL_SHIFT_STATE_LOCK) {
312 g_ui->set_shift_state(mode ? SCL_SHIFT_STATE_ON : SCL_SHIFT_STATE_OFF);
313 g_ui->set_autocapital_shift_state(!mode);
318 static void _reset_multitap_state(bool skip_commit = false)
320 LOGD("g_keyboard_state.prev_modifier : %d", g_keyboard_state.prev_modifier);
321 if (g_keyboard_state.prev_modifier == KEY_MODIFIER_MULTITAP_START ||
322 g_keyboard_state.prev_modifier == KEY_MODIFIER_MULTITAP_REPEAT) {
324 ise_send_string(g_keyboard_state.multitap_value.c_str());
326 ise_update_preedit_string("");
328 g_keyboard_state.multitap_value = "";
329 g_keyboard_state.prev_modifier = KEY_MODIFIER_NONE;
330 if (g_caps_mode_pending) {
331 g_caps_mode_pending = false;
332 set_caps_mode(g_keyboard_state.caps_mode);
336 static void ise_set_cm_private_key(scluint cm_key_id)
338 if (cm_key_id >= CM_KEY_LIST_SIZE || g_ui == NULL) {
339 LOGE("cm_key_id=%d\n", cm_key_id);
343 if (strcmp(_cm_key_list[cm_key_id], USER_KEYSTRING_EMOTICON) == 0) {
344 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
345 const_cast<sclchar*>("icon/54x54/icon_emotion_nor.png"),
346 const_cast<sclchar*>("icon/54x54/icon_emotion_press.png"),
347 const_cast<sclchar*>("icon/54x54/icon_emotion_dim.png")};
348 g_ui->set_private_key("CM_KEY", const_cast<sclchar*>(" "), imagelabel, NULL, 0, const_cast<sclchar*>(USER_KEYSTRING_EMOTICON), TRUE);
349 } else if (strcmp(_cm_key_list[cm_key_id], USER_KEYSTRING_OPTION) == 0) {
350 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
351 const_cast<sclchar*>("icon/54x54/icon_setting_nor.png"),
352 const_cast<sclchar*>("icon/54x54/icon_setting_press.png"),
353 const_cast<sclchar*>("icon/54x54/icon_setting_dim.png")};
354 g_ui->set_private_key("CM_KEY", const_cast<sclchar*>(" "), imagelabel, NULL, 0, const_cast<sclchar*>(USER_KEYSTRING_OPTION), TRUE);
355 } else if (strcmp(_cm_key_list[cm_key_id], USER_KEYSTRING_CLIPBOARD) == 0) {
356 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
357 const_cast<sclchar*>("icon/54x54/icon_clipboard_nor.png"),
358 const_cast<sclchar*>("icon/54x54/icon_clipboard_press.png"),
359 const_cast<sclchar*>("icon/54x54/icon_clipboard_dim.png")};
360 g_ui->set_private_key("CM_KEY", const_cast<sclchar*>(" "), imagelabel, NULL, 0, const_cast<sclchar*>(USER_KEYSTRING_CLIPBOARD), TRUE);
361 } else if (strcmp(_cm_key_list[cm_key_id], USER_KEYSTRING_VOICE) == 0) {
362 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
363 const_cast<sclchar*>("icon/54x54/icon_mic_nor.png"),
364 const_cast<sclchar*>("icon/54x54/icon_mic_press.png"),
365 const_cast<sclchar*>("icon/54x54/icon_mic_dim.png")};
366 g_ui->set_private_key("CM_KEY", const_cast<sclchar*>(" "), imagelabel, NULL, 0, const_cast<sclchar*>(USER_KEYSTRING_VOICE), TRUE);
367 } else if (strcmp(_cm_key_list[cm_key_id], USER_KEYSTRING_FLOATING) == 0) {
368 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
369 const_cast<sclchar*>("icon/54x54/icon_floating_keypad_nor.png"),
370 const_cast<sclchar*>("icon/54x54/icon_floating_keypad_press.png"),
371 const_cast<sclchar*>("icon/54x54/icon_floating_keypad_dim.png")};
372 g_ui->set_private_key("CM_KEY", const_cast<sclchar*>(" "), imagelabel, NULL, 0, const_cast<sclchar*>(USER_KEYSTRING_FLOATING), TRUE);
376 static void ise_update_space_key(void)
379 LOGE("g_ui = NULL\n");
383 scluint num = _language_manager.get_enabled_languages_num();
384 LOGD("language number: %d\n", num);
386 LANGUAGE_INFO *info = _language_manager.get_language_info(_language_manager.get_current_language());
387 if (info && info->enabled) {
389 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
390 const_cast<sclchar*>("w_sip_3x4_btn_ic_space_no_arrow.png"),
391 const_cast<sclchar*>("w_sip_3x4_btn_ic_space_no_arrow.png"),
392 const_cast<sclchar*>("w_sip_3x4_btn_ic_space_no_arrow.png")};
393 g_ui->set_private_key("SPACE_KEY", const_cast<sclchar*>(info->display_name.c_str()), imagelabel, NULL, 0, const_cast<sclchar*>("Space"), TRUE);
395 g_ui->enable_button("SPACE_ARROW_LEFT", false);
396 g_ui->enable_button("SPACE_ARROW_RIGHT", false);
401 g_ui->unset_private_key("SPACE_KEY");
403 g_ui->enable_button("SPACE_ARROW_LEFT", true);
404 g_ui->enable_button("SPACE_ARROW_RIGHT", true);
409 static scluint ise_get_cm_key_id(const sclchar *key_value)
411 for (int i = 0; i < CM_KEY_LIST_SIZE; ++i) {
412 if (0 == strcmp (key_value, _cm_key_list[i]))
418 static bool ise_is_emoticons_disabled(void)
421 sclu32 current_layout = g_keyboard_state.layout;
422 LOGD("layout=%d\n", current_layout);
424 if ((current_layout == ISE_LAYOUT_STYLE_NORMAL) ||
425 (current_layout == ISE_LAYOUT_STYLE_NUMBER) ||
426 (current_layout == ISE_LAYOUT_STYLE_EMOTICON))
429 if (g_imdata_state & IMDATA_ACTION_DISABLE_EMOTICONS)
435 static Eina_Bool softcandidate_hide_timer_callback(void *data)
438 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_HIDE);
442 g_softcandidate_show = false;
444 return ECORE_CALLBACK_CANCEL;
447 static void delete_softcandidate_hide_timer(void)
449 if (g_softcandidate_hide_timer) {
450 ecore_timer_del(g_softcandidate_hide_timer);
451 g_softcandidate_hide_timer = NULL;
455 static void add_softcandidate_hide_timer(void)
457 delete_softcandidate_hide_timer();
458 g_softcandidate_hide_timer = ecore_timer_add(SOFT_CANDIDATE_DELETE_TIME, softcandidate_hide_timer_callback, NULL);
461 static void create_softcandidate(void)
464 g_candidate = CandidateFactory::make_candidate(CANDIDATE_MULTILINE, ime_get_main_window());
466 g_candidate->add_event_listener(&g_candidate_event_listener);
472 * Send the given string to input framework
475 ise_send_string(const sclchar *key_value)
478 if (!check_ic_temporary(g_keyboard_state.ic)) {
479 ic = g_keyboard_state.ic;
481 ime_commit_string(key_value);
482 LOGD("ic : %x, %s\n", ic, key_value);
486 * Send the preedit string to input framework
489 ise_update_preedit_string(const sclchar *str, const sclboolean underline)
492 Eina_List *attr_list = NULL;
493 ime_preedit_attribute *preedit_attr;
495 if (!check_ic_temporary(g_keyboard_state.ic)) {
496 ic = g_keyboard_state.ic;
499 /* Count UTF-8 string length */
501 const sclchar *s = str;
502 while (*s) len += (*s++ & 0xc0) != 0x80;
504 preedit_attr = (ime_preedit_attribute *)calloc(1, sizeof(ime_preedit_attribute));
506 preedit_attr->start = 0;
507 preedit_attr->length = len;
508 preedit_attr->type = IME_ATTR_FONTSTYLE;
509 preedit_attr->value = IME_ATTR_FONTSTYLE_UNDERLINE;
510 attr_list = eina_list_append(attr_list, (void *)preedit_attr);
513 ime_update_preedit_string(str, attr_list);
515 ime_update_preedit_string(str, NULL);
517 LOGD("ic : %x, %s\n", ic, str);
521 * Send the given event to input framework
524 ise_send_event(sclulong key_event, sclulong key_mask)
527 if (!check_ic_temporary(g_keyboard_state.ic)) {
528 ic = g_keyboard_state.ic;
530 ime_send_key_event((ime_key_code_e)key_event, IME_KEY_MASK_PRESSED, false);
531 ime_send_key_event((ime_key_code_e)key_event, IME_KEY_MASK_RELEASED, false);
533 LOGD("ic : %x, %x\n", ic, key_event);
537 * Forward the given event to input framework
540 ise_forward_key_event(sclulong key_event)
543 if (!check_ic_temporary(g_keyboard_state.ic)) {
544 ic = g_keyboard_state.ic;
546 ime_send_key_event((ime_key_code_e)key_event, IME_KEY_MASK_PRESSED, true);
547 ime_send_key_event((ime_key_code_e)key_event, IME_KEY_MASK_RELEASED, true);
549 LOGD("ic : %x, %x\n", ic, key_event);
553 * @brief Delete commit timer.
557 static void delete_commit_timer(void)
559 if (_commit_timer != NULL) {
560 ecore_timer_del(_commit_timer);
561 _commit_timer = NULL;
566 * @brief Callback function for commit timer.
568 * @param data Data to pass when it is called.
570 * @return ECORE_CALLBACK_CANCEL
572 static Eina_Bool commit_timeout(void *data)
574 if (_commit_timer != NULL) {
575 ime_hide_preedit_string();
576 ise_forward_key_event(_sig_dec_event[(_click_count-1)%SIG_DEC_SIZE]);
579 _commit_timer = NULL;
580 return ECORE_CALLBACK_CANCEL;
584 on_input_mode_changed(const sclchar *key_value, sclulong key_event, sclint key_type)
586 sclboolean ret = FALSE;
590 SECURE_LOGD("key_value : %s\n", key_value);
591 if (strcmp(key_value, "CUR_LANG") == 0) {
592 g_keyboard_state.disable_force_latin = TRUE;
593 ret = _language_manager.select_current_language();
595 if (strcmp(key_value, "NEXT_LANG") == 0) {
596 g_keyboard_state.disable_force_latin = TRUE;
597 ret = _language_manager.select_next_language();
601 const sclchar *cur_lang = _language_manager.get_current_language();
603 LANGUAGE_INFO *info = _language_manager.get_language_info(cur_lang);
605 if (info->accepts_caps_mode) {
606 ise_send_event(MVK_Shift_Enable, KEY_MASK_NULL);
607 set_caps_mode(g_keyboard_state.caps_mode);
609 ise_send_event(MVK_Shift_Disable, KEY_MASK_NULL);
610 g_ui->set_shift_state(SCL_SHIFT_STATE_OFF);
614 if (is_emoticon_show()) {
615 ise_destroy_emoticon_layout();
618 if (!strcmp(key_value, USER_KEYSTRING_EMOTICON)) {
619 ise_init_emoticon_list();
621 current_emoticon_group = EMOTICON_GROUP_1;
623 if (emoticon_list_recent.size() == 0)
624 current_emoticon_group = EMOTICON_GROUP_1;
626 current_emoticon_group = EMOTICON_GROUP_RECENTLY_USED;
628 SCLRotation rotation = g_ui->get_rotation();
629 ise_show_emoticon_layout(current_emoticon_group, ROTATION_TO_DEGREE(rotation), false, ime_get_main_window());
637 static void show_cbhm()
643 ret = cbhm_selection_type_set(cbhm_handle, static_cast<cbhm_sel_type_e>(cbhm_sel_type));
645 ret = cbhm_selection_type_set(cbhm_handle, CBHM_SEL_TYPE_TEXT);
647 if (ret != CBHM_ERROR_NONE)
648 LOGW("Failed to set selection type in cbhm. error : %d\n", ret);
650 ret = cbhm_show(cbhm_handle);
651 if (ret != CBHM_ERROR_NONE)
652 LOGW("cbhm show error : %d\n", ret);
658 SCLEventReturnType CUIEventCallback::on_event_notification(SCLUINotiType noti_type, SclNotiDesc *etc_info)
660 SCLEventReturnType ret = SCL_EVENT_PASS_ON;
661 LOGD("noti type: %d, g_need_send_shift_event: %d\n", noti_type, g_need_send_shift_event);
663 if (noti_type == SCL_UINOTITYPE_SHIFT_STATE_CHANGE) {
664 if (g_need_send_shift_event) {
665 const sclchar *cur_lang = _language_manager.get_current_language();
667 LANGUAGE_INFO *info = _language_manager.get_language_info(cur_lang);
668 SclNotiShiftStateChangeDesc *desc = static_cast<SclNotiShiftStateChangeDesc*>(etc_info);
670 if (info->accepts_caps_mode) {
671 LOGD("shift state: %d\n", desc->shift_state);
672 if (desc->shift_state == SCL_SHIFT_STATE_OFF) {
673 ise_send_event(MVK_Shift_Off, KEY_MASK_NULL);
674 } else if (desc->shift_state == SCL_SHIFT_STATE_ON) {
675 ise_send_event(MVK_Shift_On, KEY_MASK_NULL);
676 } else if (desc->shift_state == SCL_SHIFT_STATE_LOCK) {
677 ise_send_event(MVK_Shift_Lock, KEY_MASK_NULL);
679 ret = SCL_EVENT_PASS_ON;
683 g_need_send_shift_event = FALSE;
685 } else if (noti_type == SCL_UINOTITYPE_POPUP_OPENING) {
686 vector<string>::reverse_iterator iter = g_recent_used_punctuation.rbegin();
688 for (; iter != g_recent_used_punctuation.rend(); ++iter)
691 g_ui->set_string_substitution(g_current_punctuation[punc_pos].c_str(), iter->c_str());
694 SclNotiPopupOpeningDesc *openingDesc = (SclNotiPopupOpeningDesc *)etc_info;
695 if (g_ui && 0 == strcmp(openingDesc->input_mode, "CM_POPUP")) {
696 if (ise_is_emoticons_disabled())
697 g_ui->enable_button("EMOTICON_KEY", false);
699 g_ui->enable_button("EMOTICON_KEY", true);
701 } else if (noti_type == SCL_UINOTITYPE_POPUP_OPENED) {
702 g_popup_opened = TRUE;
703 SclNotiPopupOpenedDesc *openedDesc = (SclNotiPopupOpenedDesc *)etc_info;
704 if (0 == strcmp(openedDesc->input_mode, "PUNCTUATION_POPUP")) {
705 g_punctuation_popup_opened = TRUE;
706 } else if (0 == strcmp(openedDesc->input_mode, "CM_POPUP")) {
707 _cm_popup_opened = TRUE;
709 } else if (noti_type == SCL_UINOTITYPE_INPUT_MODE_CHANGE) {
710 SclNotiInputModeChangeDesc *desc = static_cast<SclNotiInputModeChangeDesc*>(etc_info);
712 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_NONE);
714 if (strcmp(g_ui->get_input_mode(), "STT_3X4") == 0 &&
715 strcmp(desc->input_mode, "STT_3X4") != 0) {
718 if (strcmp(g_ui->get_input_mode(), "STT_3X4") != 0 &&
719 strcmp(desc->input_mode, "STT_3X4") == 0) {
720 ise_show_stt_mode(NATIVE_WINDOW_CAST(ime_get_main_window()));
728 void ise_destory_guideline_popup()
730 if (_guide_popup_window != NULL) {
731 evas_object_del(_guide_popup_window);
732 _guide_popup_window = NULL;
736 void _guideline_popup_dismissed_cb(void *data, Evas_Object *obj, void *event_info)
738 evas_object_smart_callback_del(obj, "dismissed", _guideline_popup_dismissed_cb);
739 evas_object_del(obj);
742 if (_guide_popup_window != NULL) {
743 evas_object_del(_guide_popup_window);
744 _guide_popup_window = NULL;
747 g_config_values.first_guideset = TRUE;
748 write_ise_config_values();
751 Evas_Object *open_message_popup(Evas_Object *parentWnd)
753 static Evas_Object *msg_window = NULL;
755 evas_object_del(msg_window);
758 msg_window = elm_win_add(parentWnd, "MCFMessagePopup", ELM_WIN_UTILITY);
761 elm_win_borderless_set(msg_window, EINA_TRUE);
762 elm_win_alpha_set(msg_window, EINA_TRUE);
763 elm_win_title_set(msg_window, "ISF Popup");
764 elm_win_screen_size_get(msg_window, NULL, NULL, &w, &h);
765 elm_win_prop_focus_skip_set(msg_window, TRUE);
766 int rots[4] = {0, 90, 180, 270};
767 elm_win_wm_rotation_available_rotations_set(msg_window, rots, 4);
768 evas_object_resize(msg_window, w, h);
771 int rots[4] = { 0, 90, 180, 270 };
772 elm_win_wm_rotation_available_rotations_set(msg_window, rots, 4);
773 evas_object_show(msg_window);
777 void ise_show_help_popup(sclulong keyEvent)
779 char buf[2048] = {0, };
783 SclRectangle rectangle = {0};
786 g_ui->get_screen_resolution(&scr_w, &scr_h);
788 if (keyEvent == MVK_space) {
789 g_ui->get_button_geometry("SPACE_KEY", &rectangle);
791 g_ui->get_button_geometry("CM_KEY", &rectangle);
795 _guide_popup_window = open_message_popup(NATIVE_WINDOW_CAST(ime_get_main_window()));
797 Elm_Theme *theme = elm_theme_new();
798 elm_theme_ref_set(theme, NULL);
799 elm_theme_extension_add(theme, EDJ_FILE);
801 Evas_Object *ctxpopup = elm_ctxpopup_add(_guide_popup_window);
802 elm_object_theme_set(ctxpopup, theme);
804 int rotation = elm_win_rotation_get(NATIVE_WINDOW_CAST(ime_get_main_window()));
805 if (rotation == 0 || rotation == 180) {
806 elm_object_style_set(ctxpopup, "customised_guideline_popup");
808 elm_object_style_set(ctxpopup, "customised_guideline_popup_landscape");
811 evas_object_smart_callback_add(ctxpopup, "dismissed", _guideline_popup_dismissed_cb, (void *)keyEvent);
812 elm_ctxpopup_direction_priority_set(ctxpopup, ELM_CTXPOPUP_DIRECTION_UP,
813 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
814 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
815 ELM_CTXPOPUP_DIRECTION_UNKNOWN);
817 Evas_Object* text = elm_label_add(ctxpopup);
819 if (keyEvent == MVK_space) {
820 snprintf(buf, sizeof(buf), "<font_style=Regular font_size=%d align=left wrap=mixed color=#000000>%s</>", font_size,
821 dgettext(PACKAGE, "IDS_IME_BODY_SWIPE_THE_SPACE_BAR_LEFT_OR_RIGHT_TO_CHANGE_BETWEEN_LANGUAGES"));
823 snprintf(buf, sizeof(buf), "<font_style=Regular font_size=%d align=left wrap=mixed color=#000000>%s</>", font_size,
824 dgettext(PACKAGE, "IDS_IME_BODY_TAP_AND_HOLD_THIS_KEY_TO_SEE_THE_SYMBOL_LIST_SELECT_ONE_TO_USE_IT_AS_A_SHORTCUT"));
826 elm_object_text_set(text, buf);
827 elm_object_content_set(ctxpopup, text);
828 Evas_Coord x, y, w, h;
829 evas_object_geometry_get(NATIVE_WINDOW_CAST(ime_get_main_window()), &x, &y, &w, &h);
831 if (rotation == 0 || rotation == 180) {
832 elm_label_wrap_width_set(text, (scr_w * 4) / 5);
833 evas_object_size_hint_min_set(ctxpopup, ELM_SCALE_SIZE(scr_w), ELM_SCALE_SIZE(50));
834 evas_object_size_hint_max_set(ctxpopup, ELM_SCALE_SIZE(scr_w), ELM_SCALE_SIZE(600));
835 evas_object_move(ctxpopup, rectangle.x + rectangle.width / 2,
836 (scr_h - h) + rectangle.y - ELM_SCALE_SIZE(5));
838 elm_label_wrap_width_set(text, (scr_h * 4) / 5);
839 evas_object_size_hint_min_set(ctxpopup, ELM_SCALE_SIZE(scr_h), ELM_SCALE_SIZE(50));
840 evas_object_size_hint_max_set(ctxpopup, ELM_SCALE_SIZE(scr_h), ELM_SCALE_SIZE(600));
841 evas_object_move(ctxpopup, rectangle.x + rectangle.width / 2,
842 (scr_w - h)+ rectangle.y - ELM_SCALE_SIZE(5));
844 elm_label_line_wrap_set(text, ELM_WRAP_MIXED);
845 evas_object_show(text);
847 evas_object_layer_set(_guide_popup_window, EVAS_LAYER_MAX);
848 evas_object_show(_guide_popup_window);
849 evas_object_layer_set(ctxpopup, EVAS_LAYER_MAX);
850 evas_object_show(ctxpopup);
853 SCLEventReturnType CUIEventCallback::on_event_drag_state_changed(SclUIEventDesc event_desc)
855 if (event_desc.event_type == EVENT_TYPE_MOVE) {
856 if (event_desc.key_event == MVK_space) {
857 SclRectangle rectangle = {0};
858 g_ui->get_button_geometry("SPACE_KEY", &rectangle);
859 ise_show_space_flick_language_change_popup(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
861 } else if (event_desc.event_type == EVENT_TYPE_RELEASE) {
862 if (event_desc.key_event == MVK_space) {
863 ise_destroy_space_flick_language_change_popup();
867 ime_set_floating_drag_end();
868 } else if (event_desc.event_type == EVENT_TYPE_PRESS) {
870 if ((!g_config_values.first_guideset) && (event_desc.key_type == KEY_TYPE_MODECHANGE)) {
871 ise_show_help_popup(event_desc.key_event);
872 return SCL_EVENT_PASS_ON;
875 if (g_floating_mode && event_desc.mouse_current_point.y <= FLOATING_TITLE_BAR_HEIGHT
876 && event_desc.mouse_current_point.y >= 0)
877 ime_set_floating_drag_start();
879 return SCL_EVENT_PASS_ON;
882 static void launch_option()
884 app_control_h app_control;
885 int ret = app_control_create(&app_control);
886 if (ret != APP_CONTROL_ERROR_NONE) {
887 LOGW("app_control_create returned %d\n", ret);
891 ret = app_control_set_operation(app_control, APP_CONTROL_OPERATION_DEFAULT);
892 if (ret != APP_CONTROL_ERROR_NONE) {
893 LOGW("app_control_set_operation returned %d\n", ret);
897 ret = app_control_set_app_id(app_control, "org.tizen.ise-default-setting");
898 if (ret != APP_CONTROL_ERROR_NONE) {
899 LOGW("app_control_set_app_id returned %d\n", ret);
903 ret = app_control_send_launch_request(app_control, NULL, NULL);
904 if (ret != APP_CONTROL_ERROR_NONE) {
910 app_control_destroy(app_control);
913 SCLEventReturnType CUIEventCallback::on_event_key_clicked(SclUIEventDesc event_desc)
915 SCLEventReturnType ret = SCL_EVENT_PASS_ON;
917 if (event_desc.key_modifier == KEY_MODIFIER_MULTITAP_START) {
918 if (!g_keyboard_state.multitap_value.empty()) {
919 ise_send_string(g_keyboard_state.multitap_value.c_str());
921 ise_update_preedit_string(event_desc.key_value);
922 g_keyboard_state.multitap_value = event_desc.key_value;
923 } else if (event_desc.key_modifier == KEY_MODIFIER_MULTITAP_REPEAT) {
924 ise_update_preedit_string(event_desc.key_value);
925 g_keyboard_state.multitap_value = event_desc.key_value;
927 _reset_multitap_state();
929 g_keyboard_state.prev_modifier = event_desc.key_modifier;
932 switch (event_desc.key_type) {
933 case KEY_TYPE_STRING: {
934 if (event_desc.key_modifier != KEY_MODIFIER_MULTITAP_START &&
935 event_desc.key_modifier != KEY_MODIFIER_MULTITAP_REPEAT) {
936 if (event_desc.key_event) {
937 ise_forward_key_event(event_desc.key_event);
939 ise_send_string(event_desc.key_value);
942 if (!g_popup_opened) {
943 const sclchar *input_mode = g_ui->get_input_mode();
944 if (input_mode && ((0 == strcmp(input_mode, "SYM_QTY_1")) || (0 == strcmp(input_mode, "SYM_QTY_2")))) {
945 update_recent_used_punctuation(event_desc.key_value);
947 } else if (g_punctuation_popup_opened) {
948 update_recent_used_punctuation(event_desc.key_value);
949 g_punctuation_popup_opened = FALSE;
950 g_popup_opened = FALSE;
954 case KEY_TYPE_CHAR: {
955 sclboolean need_forward = FALSE;
956 // FIXME : Should decide when to forward key events
957 const sclchar *input_mode = g_ui->get_input_mode();
959 if (strcmp(input_mode, "SYM_QTY_1") == 0 ||
960 strcmp(input_mode, "SYM_QTY_2") == 0 ||
961 strcmp(input_mode, "PHONE_3X4") == 0 ||
962 strcmp(input_mode, "IPv6_3X4_123") == 0 ||
963 strcmp(input_mode, "IPv6_3X4_ABC") == 0 ||
964 strcmp(input_mode, "NUMONLY_3X4") == 0 ||
965 strcmp(input_mode, "NUMONLY_3X4_SIG") == 0 ||
966 strcmp(input_mode, "NUMONLY_3X4_DEC") == 0 ||
967 strcmp(input_mode, "NUMONLY_3X4_SIGDEC") == 0 ||
968 strcmp(input_mode, "DATETIME_3X4") == 0) {
972 if (input_mode && strcmp (input_mode, "NUMONLY_3X4_SIGDEC") == 0 &&
973 strcmp(event_desc.key_value, ".") == 0) {
974 ime_update_preedit_string(_sig_dec[_click_count%SIG_DEC_SIZE], NULL);
975 ime_show_preedit_string();
976 delete_commit_timer();
977 _commit_timer = ecore_timer_add(1.0, commit_timeout, NULL);
979 } else if (event_desc.key_event) {
980 commit_timeout(NULL);
982 ise_forward_key_event(event_desc.key_event);
984 if (_cm_popup_opened) {
985 static sclchar current_cm_symbol[2] = {'\0'};
986 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
987 const_cast<sclchar*>(" "),
988 const_cast<sclchar*>(" "),
989 const_cast<sclchar*>(" ")};
990 if (event_desc.key_value) {
991 current_cm_symbol[0] = event_desc.key_value[0];
992 current_cm_symbol[1] = '\0';
994 g_ui->set_private_key("CM_KEY",
995 const_cast<sclchar*>(current_cm_symbol),
997 const_cast<sclchar*>(current_cm_symbol), TRUE);
999 _cm_popup_opened = FALSE;
1000 _current_cm_key_id = -1;
1005 *change the keyboard mode of GLM from QWERTY to KEYPAD
1006 *ensure the Number keypad won't be affected
1009 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_NUMBER){
1010 ime_send_key_event(IME_KEY_Print, IME_KEY_MASK_CONTROL, false);
1012 ime_send_key_event(IME_KEY_Select, IME_KEY_MASK_CONTROL, false);
1015 ise_send_event(event_desc.key_event, KEY_MASK_NULL);
1019 if ((strcmp(input_mode, "SYM_QTY_1") == 0) || (0 == strcmp(input_mode, "SYM_QTY_2"))) {
1020 update_recent_used_punctuation(event_desc.key_value);
1025 case KEY_TYPE_CONTROL: {
1026 commit_timeout(NULL);
1028 const char *long_shift = "LongShift";
1029 const char *caps_lock = "CapsLock";
1030 const char *delete_all = "DeleteAll";
1031 const char *hide_panel = "Hide";
1032 if (strncmp(event_desc.key_value, long_shift, strlen(long_shift)) == 0) {
1033 LOGD("shift key is longpress\n");
1034 g_ui->set_shift_state(SCL_SHIFT_STATE_ON);
1035 g_need_send_shift_event = TRUE;
1036 //ise_send_event (MVK_Shift_Lock, KEY_MASK_NULL);
1037 } else if (strncmp(event_desc.key_value, caps_lock, strlen(caps_lock)) == 0) {
1038 if (g_ui->get_shift_state() != SCL_SHIFT_STATE_LOCK) {
1039 g_ui->set_shift_state(SCL_SHIFT_STATE_LOCK);
1040 ise_send_event(MVK_Shift_Lock, KEY_MASK_NULL);
1042 g_ui->set_shift_state(SCL_SHIFT_STATE_OFF);
1043 ise_send_event(MVK_Shift_Off, KEY_MASK_NULL);
1045 //g_need_send_shift_event = TRUE;
1046 } else if (strncmp(event_desc.key_value, delete_all, strlen(delete_all)) == 0) {
1047 ime_delete_surrounding_text((INT_MAX / 2) * -1, INT_MAX);
1048 } else if (strncmp(event_desc.key_value, hide_panel, strlen(hide_panel)) == 0) {
1051 } else if (event_desc.key_event) {
1052 ise_send_event(event_desc.key_event, KEY_MASK_NULL);
1053 if (event_desc.key_event == MVK_Shift_L) {
1054 g_need_send_shift_event = TRUE;
1059 case KEY_TYPE_MODECHANGE:
1061 if (!g_config_values.first_guideset) {
1065 if (strcmp(event_desc.key_value, USER_VOICE_LANGUAGE) == 0) {
1066 if (!g_setting_window_open_status) {
1067 ise_hide_stt_mode();
1069 hide_indicator_window();
1071 create_setting_window();
1073 } else if (strcmp(event_desc.key_value, USER_KEYSTRING_VOICE) == 0) {
1074 g_keyboard_state.layout = ISE_LAYOUT_STYLE_VOICE;
1075 g_ui->set_input_mode("STT_3X4");
1077 } else if (strcmp(event_desc.key_value, USER_KEYSTRING_OPTION) == 0) {
1080 ret = SCL_EVENT_DONE;
1081 } else if (strcmp(event_desc.key_value, USER_KEYSTRING_CLIPBOARD) == 0) {
1084 ret = SCL_EVENT_DONE;
1085 } else if (strcmp(event_desc.key_value, USER_KEYSTRING_FLOATING) == 0) {
1086 if (g_floating_mode)
1087 g_config_values.floating_mode = false;
1089 g_config_values.floating_mode = true;
1090 write_ise_config_values();
1092 ret = SCL_EVENT_DONE;
1093 } else if (on_input_mode_changed(event_desc.key_value, event_desc.key_event, event_desc.key_type)) {
1094 ret = SCL_EVENT_DONE;
1096 if (_cm_popup_opened) {
1097 if (strcmp(event_desc.key_value, USER_KEYSTRING_EMOTICON) == 0 ||
1098 strcmp(event_desc.key_value, USER_KEYSTRING_VOICE) == 0 ||
1099 strcmp(event_desc.key_value, USER_KEYSTRING_FLOATING) == 0) {
1100 scluint id = ise_get_cm_key_id(event_desc.key_value);
1101 if (id != _current_cm_key_id) {
1102 _current_cm_key_id = id;
1103 ise_set_cm_private_key(_current_cm_key_id);
1106 _cm_popup_opened = FALSE;
1108 if (strlen(event_desc.key_value) == 1) {
1109 const char allowed_chars_in_modechange[] = {
1110 ',', '?', '!', '`', '~'
1112 const int allowed_chars_in_modechange_num =
1113 sizeof(allowed_chars_in_modechange) / sizeof(char);
1114 for (unsigned int loop = 0;loop < sizeof(allowed_chars_in_modechange_num);loop++) {
1115 if (*(event_desc.key_value) == allowed_chars_in_modechange[loop]) {
1116 ise_send_string(event_desc.key_value);
1122 if (strcmp(event_desc.key_value, USER_KEYSTRING_OPTION) == 0) {
1123 //open_option_window(NULL, ROTATION_TO_DEGREE(g_ui->get_rotation()));
1126 ret = SCL_EVENT_DONE;
1127 } else if (strcmp(event_desc.key_value, USER_KEYSTRING_CLIPBOARD) == 0) {
1129 ret = SCL_EVENT_DONE;
1130 } else if (strcmp(event_desc.key_value, "Cancel") == 0) {
1131 ret = SCL_EVENT_DONE;
1132 if (strcmp(g_ui->get_input_mode(), "STT_3X4") == 0 ) {
1133 g_keyboard_state.need_reset = TRUE;
1134 voice_result_string_flush();
1135 ise_set_layout(g_keyboard_state.layout, g_keyboard_state.layout_variation);
1136 if (g_keyboard_state.visible_state)
1137 ise_show(g_keyboard_state.ic);
1139 ise_send_event(IME_KEY_Cancel, KEY_MASK_NULL);
1141 } else if (strcmp(event_desc.key_value, "Done") == 0) {
1142 ret = SCL_EVENT_DONE;
1143 ise_send_event(IME_KEY_Return, KEY_MASK_NULL);
1146 const sclchar *input_mode = g_ui->get_input_mode();
1147 if ((NULL != input_mode) && (!strcmp(input_mode, "EMOTICON_LAYOUT"))) {
1148 if (is_emoticon_show()) {
1149 ise_destroy_emoticon_layout();
1152 emoticon_group_t group_id = EMOTICON_GROUP_1;
1153 if (current_emoticon_group < EMOTICON_GROUP_3)
1154 group_id = (emoticon_group_t)(current_emoticon_group + 1);
1156 const int BUF_LEN = 16;
1157 char buf[BUF_LEN] = {0};
1158 snprintf(buf, BUF_LEN, "%d/3", group_id);
1159 g_ui->set_private_key("EMOTICON_GROUP_ID", buf, NULL, NULL, 0, const_cast<sclchar*>("EMOTICON_GROUP_NEXT"), TRUE);
1161 emoticon_group_t group_id = ise_get_emoticon_group_id(event_desc.key_value);
1163 if ((group_id >= 0) && (group_id < MAX_EMOTICON_GROUP)) {
1164 SCLRotation rotation = g_ui->get_rotation();
1165 ise_show_emoticon_layout(group_id, ROTATION_TO_DEGREE(rotation), false, ime_get_main_window());
1169 if (_cm_popup_opened) {
1170 if (strcmp(event_desc.key_value, USER_KEYSTRING_OPTION) == 0 ||
1171 strcmp(event_desc.key_value, USER_KEYSTRING_CLIPBOARD) == 0) {
1172 scluint id = ise_get_cm_key_id(event_desc.key_value);
1173 if (id != _current_cm_key_id) {
1174 _current_cm_key_id = id;
1175 ise_set_cm_private_key(_current_cm_key_id);
1178 _cm_popup_opened = FALSE;
1190 ise_set_layout(sclu32 layout, sclu32 layout_variation)
1192 /* Check if the layoutIdx is in the valid range */
1193 if (layout < ISE_LAYOUT_STYLE_MAX) {
1194 if (g_keyboard_state.layout != layout ||
1195 g_keyboard_state.layout_variation != layout_variation) {
1196 g_keyboard_state.need_reset = TRUE;
1198 g_keyboard_state.layout = layout;
1199 g_keyboard_state.layout_variation = layout_variation;
1200 LOGD("layout:%d, variation:%d\n", g_keyboard_state.layout, g_keyboard_state.layout_variation);
1208 _reset_multitap_state(true);
1209 _language_manager.reset_language(g_config_values.selected_language.c_str());
1213 ise_reset_input_context()
1216 _reset_multitap_state(true);
1217 g_keyboard_state.disable_force_latin = FALSE;
1218 _language_manager.reset_language(g_config_values.selected_language.c_str());
1222 ise_focus_in(int ic)
1224 LOGD("ic : %x , %x , g_ic : %x , %x, g_focused_ic : %x , %x\n", ic, check_ic_temporary(ic),
1225 g_keyboard_state.ic, check_ic_temporary(g_keyboard_state.ic),
1226 g_keyboard_state.focused_ic, check_ic_temporary(g_keyboard_state.focused_ic));
1227 if (check_ic_temporary(g_keyboard_state.ic) && !check_ic_temporary(ic)) {
1228 g_keyboard_state.ic = ic;
1230 g_keyboard_state.focused_ic = ic;
1233 static void save_autofill_data()
1238 if (g_autofill_hint == 0)
1241 ime_get_surrounding_text(-1, -1, &text, &cursor);
1242 SECURE_LOGD("surrounding text : %s\n", text);
1245 autofill_save_string((Ecore_IMF_Input_Hints)g_autofill_hint, text);
1251 ise_focus_out(int ic)
1253 g_keyboard_state.focused_ic = 0;
1254 _reset_multitap_state(true);
1256 save_autofill_data();
1259 bool ise_is_guideline_popup_enable_layout(void)
1262 switch (_context_layout)
1264 case ISE_LAYOUT_STYLE_PHONENUMBER:
1265 case ISE_LAYOUT_STYLE_IP:
1266 case ISE_LAYOUT_STYLE_MONTH:
1267 case ISE_LAYOUT_STYLE_NUMBERONLY:
1268 case ISE_LAYOUT_STYLE_HEX:
1269 case ISE_LAYOUT_STYLE_TERMINAL:
1270 case ISE_LAYOUT_STYLE_DATETIME:
1271 case ISE_LAYOUT_STYLE_PASSWORD:
1282 static Eina_Bool popup_guideline_timer_cb(void *data)
1284 if ((!g_config_values.first_guidechange) && (_language_manager.get_enabled_languages_num() > 1)) {
1285 ise_show_help_popup(MVK_space);
1286 g_config_values.first_guidechange = TRUE;
1287 write_ise_config_values();
1290 guideline_timer = NULL;
1291 return ECORE_CALLBACK_CANCEL;
1295 #if EXIT_ISE_ON_HIDE
1296 static Eina_Bool exit_timer_cb(void *data)
1298 if (exit_timer) ecore_timer_del(exit_timer);
1301 return ECORE_CALLBACK_CANCEL;
1308 #if EXIT_ISE_ON_HIDE
1309 if (exit_timer) ecore_timer_del(exit_timer);
1312 sclboolean reset_inputmode = FALSE;
1313 g_popup_opened = FALSE;
1314 g_input_panel_show = true;
1317 read_ise_config_values();
1319 _language_manager.set_enabled_languages(g_config_values.enabled_languages);
1320 const sclchar *cur_lang = _language_manager.get_current_language();
1323 if (cur_lang && !strcmp(cur_lang, "English")) {
1324 if (!g_config_values.prediction_on ||
1325 (g_keyboard_state.layout == ISE_LAYOUT_STYLE_PHONENUMBER ||
1326 g_keyboard_state.layout == ISE_LAYOUT_STYLE_VOICE ||
1327 g_keyboard_state.layout == ISE_LAYOUT_STYLE_IP ||
1328 g_keyboard_state.layout == ISE_LAYOUT_STYLE_MONTH ||
1329 g_keyboard_state.layout == ISE_LAYOUT_STYLE_NUMBERONLY ||
1330 g_keyboard_state.layout != ISE_LAYOUT_STYLE_EMAIL ||
1331 g_keyboard_state.layout == ISE_LAYOUT_STYLE_PASSWD_3X4||
1332 g_keyboard_state.layout == ISE_LAYOUT_STYLE_PASSWORD)){
1333 ise_app_candidate_hide();
1334 g_softcandidate_show = false;
1336 g_softcandidate_show = true;
1337 ise_app_candidate_show();
1340 ise_app_candidate_hide();
1341 g_softcandidate_show = false;
1344 *Clear the personalized data
1346 if (g_config_values.dataclear){
1347 ime_send_key_event(IME_KEY_Clear, IME_KEY_MASK_CONTROL, false);
1348 g_config_values.dataclear = FALSE;
1351 LOGD("ic : %x , %x , g_ic : %x , %x, g_focused_ic : %x , %x\n", ic, check_ic_temporary(ic),
1352 g_keyboard_state.ic, check_ic_temporary(g_keyboard_state.ic),
1353 g_keyboard_state.focused_ic, check_ic_temporary(g_keyboard_state.focused_ic));
1355 if (check_ic_temporary(ic) && !check_ic_temporary(g_keyboard_state.focused_ic)) {
1356 ic = g_keyboard_state.focused_ic;
1359 if (!check_ic_temporary(ic) && check_ic_temporary(g_keyboard_state.focused_ic)) {
1360 g_keyboard_state.focused_ic = ic;
1363 if (ic == g_keyboard_state.focused_ic) {
1364 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_PHONENUMBER ||
1365 g_keyboard_state.layout == ISE_LAYOUT_STYLE_IP ||
1366 g_keyboard_state.layout == ISE_LAYOUT_STYLE_MONTH ||
1367 g_keyboard_state.layout == ISE_LAYOUT_STYLE_NUMBERONLY) {
1368 ime_set_imengine(DEFAULT_KEYBOARD_ISE_UUID);
1372 /* Reset input mode if the input context value has changed */
1373 if (ic != g_keyboard_state.ic) {
1374 /* Do not reset input mode if STT's setting window was opened */
1375 if (g_setting_window_open_status && strcmp(g_ui->get_input_mode(), "STT_3X4") == 0) {
1376 LOGD("Setting window was opened while using STT, skip resetting input mode");
1378 reset_inputmode = TRUE;
1382 g_keyboard_state.ic = ic;
1383 /* Reset input mode if the current language is not the selected language */
1385 if (g_config_values.selected_language.compare(cur_lang) != 0) {
1386 reset_inputmode = TRUE;
1390 /* No matter what, just reset the inputmode if it needs to */
1391 if (g_keyboard_state.need_reset) {
1392 /* Do not reset input mode if STT's setting window was opened */
1393 if (g_setting_window_open_status && strcmp(g_ui->get_input_mode(), "STT_3X4") == 0) {
1394 LOGD("Setting window was opened while using STT, skip resetting input mode");
1396 reset_inputmode = TRUE;
1399 g_keyboard_state.need_reset = FALSE;
1401 /* If the current layout requires latin language and current our language is not latin, enable the primary latin */
1402 sclboolean force_primary_latin = FALSE;
1403 LANGUAGE_INFO *info = _language_manager.get_language_info(g_config_values.selected_language.c_str());
1405 if (g_ise_default_values[g_keyboard_state.layout].force_latin && !(info->is_latin_language)) {
1406 if (!g_keyboard_state.disable_force_latin) {
1407 force_primary_latin = TRUE;
1411 if (force_primary_latin) {
1412 /* If there is enabled latin-based language, select it */
1413 sclboolean selected = FALSE;
1414 for (scluint loop = 0;!selected && loop < _language_manager.get_languages_num();loop++) {
1415 LANGUAGE_INFO *info = _language_manager.get_language_info(loop);
1417 if (info->enabled && info->is_latin_language) {
1418 selected = _language_manager.select_language(info->name.c_str());
1419 if (selected) force_primary_latin = FALSE;
1424 _language_manager.set_language_enabled_temporarily(PRIMARY_LATIN_LANGUAGE, TRUE);
1428 if (reset_inputmode) {
1429 ise_reset_context();
1431 bool filename_layout = false;
1433 /* Turn the shift state off if we need to reset our input mode, only when auto-capitalization is not set */
1434 if (!(g_keyboard_state.caps_mode)) {
1435 g_ui->set_shift_state(SCL_SHIFT_STATE_OFF);
1437 if (g_keyboard_state.layout < ISE_LAYOUT_STYLE_MAX) {
1438 sclu32 layout_index = g_keyboard_state.layout;
1439 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_NUMBERONLY &&
1440 g_keyboard_state.layout_variation > 0 &&
1441 g_keyboard_state.layout_variation < ISE_LAYOUT_NUMBERONLY_VARIATION_MAX) {
1442 layout_index = ISE_LAYOUT_STYLE_NUMBERONLY_SIG + g_keyboard_state.layout_variation - 1;
1443 } else if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_PASSWORD && g_keyboard_state.layout_variation > 0) {
1444 layout_index = ISE_LAYOUT_STYLE_PASSWD_3X4;
1447 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_NORMAL &&
1448 g_keyboard_state.layout_variation == ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL_VARIATION_FILENAME)
1449 filename_layout = true;
1451 filename_layout = false;
1453 g_ui->enable_button("exclamation", !filename_layout);
1454 g_ui->enable_button("question", !filename_layout);
1455 g_ui->enable_button("divide", !filename_layout);
1456 g_ui->enable_button("multiply", !filename_layout);
1457 g_ui->enable_button("colon", !filename_layout);
1458 g_ui->enable_button("quotation", !filename_layout);
1460 g_ui->enable_button("CM_KEY", !access("/home", X_OK));
1462 LOGD("new layout index : %d\n", layout_index);
1463 /* If this layout requires specific input mode, set it */
1464 if (strlen(g_ise_default_values[layout_index].input_mode) > 0) {
1465 g_ui->set_input_mode(g_ise_default_values[layout_index].input_mode);
1466 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_NONE);
1468 if (force_primary_latin) {
1469 _language_manager.select_language(PRIMARY_LATIN_LANGUAGE, TRUE);
1471 if (!(_language_manager.select_language(g_config_values.selected_language.c_str()))) {
1472 _language_manager.select_language(PRIMARY_LATIN_LANGUAGE);
1476 g_ui->set_cur_sublayout(g_ise_default_values[layout_index].sublayout_name);
1477 if (is_emoticon_show()) {
1478 ise_destroy_emoticon_layout();
1481 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_EMOTICON) {
1482 ise_init_emoticon_list();
1484 current_emoticon_group = EMOTICON_GROUP_1;
1486 if (emoticon_list_recent.size() == 0)
1487 current_emoticon_group = EMOTICON_GROUP_1;
1489 current_emoticon_group = EMOTICON_GROUP_RECENTLY_USED;
1491 SCLRotation rotation = g_ui->get_rotation();
1492 ise_show_emoticon_layout(current_emoticon_group, ROTATION_TO_DEGREE(rotation), false, ime_get_main_window());
1498 if (info->accepts_caps_mode) {
1499 // FIXME this if condition means the AC is off
1500 if (g_keyboard_state.layout != ISE_LAYOUT_STYLE_NORMAL) {
1501 g_ui->set_autocapital_shift_state(TRUE);
1502 g_ui->set_shift_state(SCL_SHIFT_STATE_OFF);
1504 ise_send_event(MVK_Shift_Enable, KEY_MASK_NULL);
1505 // Auto Capital is supported only in normal layout
1506 if (g_keyboard_state.caps_mode) {
1507 g_ui->set_autocapital_shift_state(FALSE);
1511 g_ui->set_autocapital_shift_state(TRUE);
1512 ise_send_event(MVK_Shift_Disable, KEY_MASK_NULL);
1513 g_ui->set_shift_state(SCL_SHIFT_STATE_OFF);
1516 g_ui->set_autocapital_shift_state(TRUE);
1519 // Update CM key button
1520 if (_current_cm_key_id < CM_KEY_LIST_SIZE) {
1521 if (strcmp(_cm_key_list[_current_cm_key_id], USER_KEYSTRING_EMOTICON) == 0) {
1522 if (ise_is_emoticons_disabled())
1523 ise_set_cm_private_key(ise_get_cm_key_id(USER_KEYSTRING_OPTION));
1525 ise_set_cm_private_key(_current_cm_key_id);
1529 // Update space key button
1530 ise_update_space_key();
1533 g_ui->disable_input_events(FALSE);
1535 g_ui->enable_button("CM_KEY", false);
1539 if (ise_is_guideline_popup_enable_layout()) {
1540 guideline_timer = ecore_timer_add(0.1, popup_guideline_timer_cb, NULL);
1545 if (g_config_values.floating_mode != g_floating_mode)
1546 g_floating_mode = g_config_values.floating_mode;
1548 if (g_candidate && g_candidate->get_visible())
1549 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_SHOW);
1551 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_NONE);
1554 g_keyboard_state.visible_state = TRUE;
1558 switch (_context_layout) {
1559 case ISE_LAYOUT_STYLE_PHONENUMBER:
1560 case ISE_LAYOUT_STYLE_IP:
1561 case ISE_LAYOUT_STYLE_MONTH:
1562 case ISE_LAYOUT_STYLE_NUMBERONLY:
1563 case ISE_LAYOUT_STYLE_DATETIME:
1564 case ISE_LAYOUT_STYLE_TERMINAL:
1567 case ISE_LAYOUT_STYLE_EMAIL:
1568 case ISE_LAYOUT_STYLE_URL:
1571 case ISE_LAYOUT_STYLE_PASSWORD:
1572 if (_context_layout == ISE_LAYOUT_STYLE_PASSWORD &&
1573 _context_layout_variation == ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD_VARIATION_NUMBERONLY)
1586 g_ui->get_screen_resolution(&width, &height);
1588 create_indicator_window(width, height);
1589 destroy_indicator_dots();
1592 switch (g_keyboard_state.layout) {
1593 case ISE_LAYOUT_STYLE_NUMBER:
1596 case ISE_LAYOUT_STYLE_HEX:
1599 case ISE_LAYOUT_STYLE_EMOTICON:
1602 case ISE_LAYOUT_STYLE_VOICE:
1603 if (_context_layout == ISE_LAYOUT_STYLE_EMAIL ||
1604 _context_layout == ISE_LAYOUT_STYLE_URL)
1613 create_indicator_dots(dot_num, focus_dot);
1614 show_indicator_window();
1616 hide_indicator_window();
1620 if (g_setting_window_open_status) {
1621 ise_show_stt_mode(NATIVE_WINDOW_CAST(ime_get_main_window()));
1623 g_setting_window_open_status = FALSE;
1625 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_VOICE) {
1626 ise_show_stt_mode(NATIVE_WINDOW_CAST(ime_get_main_window()));
1631 * Sets screen rotation
1634 ise_set_screen_rotation(int degree)
1637 g_ui->set_rotation(DEGREE_TO_SCLROTATION(degree));
1641 g_candidate->rotate(degree);
1642 if (g_softcandidate_show) {
1643 g_candidate->update(g_softcandidate_string);
1649 ise_set_accessibility_state(bool state)
1652 g_ui->enable_tts(state);
1660 /* There's no need to update screen when hiding */
1661 g_ui->set_update_pending(TRUE);
1662 g_ui->disable_input_events(TRUE);
1665 _language_manager.reset_language(g_config_values.selected_language.c_str());
1668 delete_commit_timer();
1669 ise_destory_guideline_popup();
1671 g_keyboard_state.visible_state = FALSE;
1673 _reset_shift_state();
1674 _reset_multitap_state(true);
1676 /* If we were in STT mode, try to reset input mode on our next show event */
1677 if (g_ui && strcmp(g_ui->get_input_mode(), "STT_3X4") == 0 ) {
1678 g_keyboard_state.need_reset = TRUE;
1679 ise_hide_stt_mode();
1682 g_input_panel_show = false;
1683 if (g_softcandidate_show && g_candidate)
1684 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_SHOW);
1686 hide_indicator_window();
1688 #if EXIT_ISE_ON_HIDE
1689 if (exit_timer) ecore_timer_del(exit_timer);
1690 exit_timer = ecore_timer_add(1.0, exit_timer_cb, NULL);
1694 static void ise_keypad_mode_changed_cb(const char *key, void *user_data)
1696 read_ise_keypad_mode();
1699 static void ise_enabled_languages_changed_cb(const char *key, void *user_data)
1701 read_ise_enabled_languages();
1704 static void ise_selected_language_changed_cb(const char *key, void *user_data)
1706 read_ise_selected_language();
1709 static void ise_autocapital_mode_changed_cb(const char *key, void *user_data)
1711 read_ise_autocapital_mode();
1714 static void ise_autopunctuate_mode_changed_cb(const char *key, void *user_data)
1716 read_ise_autopunctuation_mode();
1719 static void ise_sound_mode_changed_cb(const char *key, void *user_data)
1721 read_ise_sound_mode();
1723 g_ui->enable_sound(g_config_values.sound_on);
1726 static void ise_vibration_mode_changed_cb(const char *key, void *user_data)
1728 read_ise_vibration_mode();
1730 g_ui->enable_vibration(g_config_values.vibration_on);
1733 static void ise_character_preview_mode_changed_cb(const char *key, void *user_data)
1735 read_ise_character_preview_mode();
1737 g_ui->enable_magnifier(g_config_values.preview_on);
1740 static void ise_setting_guide_popup_changed_cb(const char *key, void *user_data)
1742 read_ise_setting_guide_popup_mode();
1745 static void ise_language_guide_popup_changed_cb(const char *key, void *user_data)
1747 read_ise_language_guide_popup_mode();
1750 static void ise_floating_mode_changed_cb(const char *key, void *user_data)
1752 read_ise_floating_mode();
1753 g_floating_mode = g_config_values.floating_mode;
1755 ime_set_floating_mode(g_floating_mode);
1756 if (g_candidate && g_floating_mode != g_candidate->get_floating_mode()) {
1757 delete_softcandidate_hide_timer();
1761 create_softcandidate();
1762 if (g_candidate && g_candidate->get_visible()) {
1763 g_softcandidate_show = true;
1764 g_candidate->show();
1765 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_SHOW);
1769 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_NONE);
1781 bindtextdomain(PACKAGE, LOCALEDIR);
1782 textdomain(PACKAGE);
1784 /* Set scl_parser_type
1785 * default type is text xml
1786 * use command: export sclres_type="sclres_binary" to enable use binary resource
1787 * please make sure there is sclresource.bin in resource folder
1788 * Or you can use `xml2binary $resource_dir` to generate the sclresource.bin
1789 * xml2binary is in the libscl-ui-devel package
1791 SCLParserType scl_parser_type = SCL_PARSER_TYPE_XML;
1792 char* sclres_type = getenv("sclres_type");
1793 if (sclres_type != NULL && 0 == strcmp("sclres_binary", sclres_type)) {
1794 scl_parser_type = SCL_PARSER_TYPE_BINARY_XML;
1796 scl_parser_type = SCL_PARSER_TYPE_XML;
1800 if (ime_get_main_window()) {
1801 g_ise_created = true;
1803 sclboolean succeeded = FALSE;
1805 const sclchar *entry_path = MAIN_ENTRY_XML_PATH;
1808 CSCLUtils *utils = CSCLUtils::get_instance();
1810 utils->get_screen_resolution(&nwidth, &nheight);
1812 _language_manager.set_resource_file_path(entry_path);
1813 const sclchar *resource_file_path = _language_manager.get_resource_file_path();
1815 if (resource_file_path) {
1816 if (strlen(resource_file_path) > 0) {
1817 succeeded = g_ui->init(ime_get_main_window(), scl_parser_type, resource_file_path);
1821 g_ui->init(ime_get_main_window(), scl_parser_type, MAIN_ENTRY_XML_PATH);
1824 g_ui->set_longkey_duration(elm_config_longpress_timeout_get() * 1000);
1826 /* Default ISE callback */
1827 g_ui->set_ui_event_callback(&callback);
1829 /* Accumulated customized ISE callbacks, depending on the input modes */
1830 for (scluint loop = 0;loop < _language_manager.get_languages_num();loop++) {
1831 LANGUAGE_INFO *language = _language_manager.get_language_info(loop);
1833 for (scluint inner_loop = 0;inner_loop < language->input_modes.size();inner_loop++) {
1834 INPUT_MODE_INFO &info = language->input_modes.at(inner_loop);
1835 LOGD("Registering callback for input mode %s : %p\n", info.name.c_str(), language->callback);
1836 g_ui->set_ui_event_callback(language->callback, info.name.c_str());
1841 read_ise_config_values();
1842 _language_manager.set_enabled_languages(g_config_values.enabled_languages);
1843 _language_manager.select_language(g_config_values.selected_language.c_str());
1844 vconf_set_bool(VCONFKEY_AUTOCAPITAL_ALLOW_BOOL, g_config_values.auto_capitalise);
1845 vconf_set_bool(VCONFKEY_AUTOPERIOD_ALLOW_BOOL, g_config_values.auto_punctuate);
1846 g_ui->enable_sound(g_config_values.sound_on);
1847 g_ui->enable_vibration(g_config_values.vibration_on);
1848 g_ui->enable_magnifier(g_config_values.preview_on);
1850 g_ui->enable_highlight_ui(TRUE);
1852 g_floating_mode = g_config_values.floating_mode;
1853 ime_set_floating_mode(g_floating_mode);
1856 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_NONE);
1860 preference_is_existing(ISE_CONFIG_KEYPAD_MODE, &exist);
1862 write_ise_config_values();
1864 if (preference_set_changed_cb(ISE_CONFIG_KEYPAD_MODE, ise_keypad_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1865 LOGW("Faild to set ise_keypad_mode_changed_cb()");
1866 if (preference_set_changed_cb(ISE_CONFIG_ENABLED_LANGUAGES, ise_enabled_languages_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1867 LOGW("Faild to set ise_enabled_languages_changed_cb()");
1868 if (preference_set_changed_cb(ISE_CONFIG_SELECTED_LANGUAGE, ise_selected_language_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1869 LOGW("Faild to set ise_selected_language_changed_cb()");
1870 if (preference_set_changed_cb(ISE_CONFIG_AUTO_CAPITALISE, ise_autocapital_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1871 LOGW("Faild to set ise_autocapital_mode_changed_cb()");
1872 if (preference_set_changed_cb(ISE_CONFIG_AUTO_PUNCTUATE, ise_autopunctuate_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1873 LOGW("Faild to set ise_autopunctuate_mode_changed_cb()");
1874 if (preference_set_changed_cb(ISE_CONFIG_SOUND_ON, ise_sound_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1875 LOGW("Faild to set ise_sound_mode_changed_cb()");
1876 if (preference_set_changed_cb(ISE_CONFIG_VIBRATION_ON, ise_vibration_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1877 LOGW("Faild to set ise_vibration_mode_changed_cb()");
1878 if (preference_set_changed_cb(ISE_CONFIG_PREVIEW_ON, ise_character_preview_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1879 LOGW("Faild to set ise_character_preview_mode_changed_cb()");
1880 if (preference_set_changed_cb(ISE_CONFIG_FIRST_GUIDELINE_POPUP_FOR_SETTING, ise_setting_guide_popup_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1881 LOGW("Faild to set ise_setting_guide_popup_changed_cb()");
1882 if (preference_set_changed_cb(ISE_CONFIG_FIRST_GUIDELINE_POPUP_FOR_LANGUAGE_CHANGE, ise_language_guide_popup_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1883 LOGW("Faild to set ise_language_guide_popup_changed_cb()");
1884 if (preference_set_changed_cb(ISE_CONFIG_FLOATING_MODE, ise_floating_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1885 LOGW("Faild to set ise_floating_mode_changed_cb()");
1887 init_recent_used_punctuation();
1893 ise_hide_stt_mode();
1896 LOGD("calling g_ui->fini()\n");
1898 LOGD("deleting g_ui\n");
1909 destroy_indicator_window();
1912 /* This is necessary. If this is not called, 3rd party IME might have auto period input regardless its settings */
1913 vconf_set_bool(VCONFKEY_AUTOPERIOD_ALLOW_BOOL, false);
1915 #if EXIT_ISE_ON_HIDE
1916 if (exit_timer) ecore_timer_del(exit_timer);
1922 ise_app_candidate_show()
1925 if (!g_softcandidate_show){
1930 delete_softcandidate_hide_timer();
1932 create_softcandidate();
1934 g_softcandidate_show = true;
1936 g_candidate->show();
1937 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_SHOW);
1942 ise_app_candidate_hide()
1946 if (!g_candidate || !g_softcandidate_show) {
1947 LOGD("No candidate\n");
1951 if (g_ic_smartreply != -1 || g_autofill_exist)
1954 add_softcandidate_hide_timer();
1957 // when it is the time to auto_cap, the
1958 // ise_set_caps_mode is called.
1959 // -------------------------------------------------------
1960 // For example: [How are you. Fine.], the
1961 // auto-capital process is as below:
1962 // Note: "["<--this is the beginning,
1963 // "|"<--this is the cursor position
1964 // 1) call ise_set_caps_mode, auto_cap = on
1967 // 2) call ise_set_caps_mode, auto_cap = off
1970 // 3) input: "w are you. "
1971 // result: [How are you. |
1972 // 4) call ise_set_caps_mode, auto_cap = on
1974 // result: [How are you. F
1976 // result: [How are you. Fine.|
1977 // --------------------------------------------------------
1978 // If we want to change the auto_cap, eg,
1979 // if we want to input [How Are you.]
1980 // Note the "Are" is not use auto-capital rule.
1982 // ise_send_event(MVK_Shift_On, SclCoreKeyMask_Null);
1983 // when we are want to input "A"
1984 // following input still has the auto_cap rule.
1986 ise_set_caps_mode(unsigned int mode)
1988 LOGD("caps_mode : %d\n", mode);
1990 g_keyboard_state.caps_mode = TRUE;
1992 g_keyboard_state.caps_mode = FALSE;
1994 g_caps_mode_pending = false;
1995 const sclchar *cur_lang = _language_manager.get_current_language();
1997 LANGUAGE_INFO *info = _language_manager.get_language_info(cur_lang);
1999 if (info->accepts_caps_mode) {
2000 /* If we are inputting multitap character, do not manipulate shift mode */
2001 if (g_keyboard_state.prev_modifier != KEY_MODIFIER_MULTITAP_START &&
2002 g_keyboard_state.prev_modifier != KEY_MODIFIER_MULTITAP_REPEAT) {
2003 set_caps_mode(g_keyboard_state.caps_mode);
2005 g_caps_mode_pending = true;
2006 LOGD("Currently composing multitap string, skipping caps request");
2014 ise_update_cursor_position(int position)
2016 LOGD("cursor position : %d\n", position);
2017 if (g_ui && g_keyboard_state.layout == ISE_LAYOUT_STYLE_URL) {
2020 g_ui->set_string_substitution("www.", ".com");
2022 g_ui->unset_string_substitution("www.");
2028 void ise_set_return_key_type(unsigned int type)
2030 const int BUF_LEN = 256;
2031 char buf[BUF_LEN] = {0};
2035 LOGD("return key type : %d\n", type);
2038 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE:
2039 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_DONE);
2041 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_GO:
2042 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_GO);
2044 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_JOIN:
2045 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_JOIN);
2047 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_LOGIN:
2048 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_LOGIN);
2050 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT:
2051 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_NEXT);
2053 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH:
2054 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_SEARCH);
2056 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEND:
2057 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_SEND);
2059 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SIGNIN:
2060 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_SIGNIN);
2062 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT:
2065 LOGW("Unknown return key type : %d\n", type);
2066 type = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
2070 if (type == ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT) {
2071 g_ui->unset_private_key("Enter");
2074 if (type == ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH) {
2075 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
2076 const_cast<sclchar*>("w_sip_3x4_btn_ic_search.png"),
2077 const_cast<sclchar*>("w_sip_3x4_btn_ic_search_p.png"),
2078 const_cast<sclchar*>("w_sip_3x4_btn_ic_search_d.png")};
2079 g_ui->set_private_key("Enter", const_cast<sclchar*>(""), imagelabel, NULL, 0, const_cast<sclchar*>("Enter"), TRUE);
2084 static sclchar *imagelabel[SCL_BUTTON_STATE_MAX] = {
2085 const_cast<sclchar*>(" "), const_cast<sclchar*>(" "), const_cast<sclchar*>(" ")
2088 g_ui->set_private_key("Enter", buf, imagelabel, NULL, 0, const_cast<sclchar*>("Enter"), TRUE);
2089 LOGD("return key lable : %s\n", buf);
2093 void ise_set_return_key_disable(unsigned int disabled)
2095 LOGD("enable : %d\n", !disabled);
2098 g_ui->enable_button("Done", !disabled);
2101 g_ui->enable_button("Enter", !disabled);
2105 void ise_get_language_locale(char **locale)
2107 LANGUAGE_INFO *info = _language_manager.get_current_language_info();
2109 if (!(info->locale_string.empty())) {
2110 *locale = strdup(info->locale_string.c_str());
2115 void ise_update_table(const vector<string> &vec_str)
2117 if (!g_candidate || !g_softcandidate_show)
2118 create_softcandidate();
2121 g_candidate->update(vec_str);
2125 void ise_process_key_event(scim::KeyEvent& key, sclu32 &ret)
2127 Eina_Bool back_key_pressed = EINA_FALSE;
2128 Eina_Bool back_key_released = EINA_FALSE;
2130 if (key.get_key_string().compare("XF86Back") == 0) {
2131 back_key_pressed = EINA_TRUE;
2132 } else if (key.get_key_string().compare("KeyRelease+XF86Back") == 0) {
2133 back_key_released = EINA_TRUE;
2136 if (back_key_pressed || back_key_released) {
2137 if (g_popup_opened == TRUE) {
2138 if (back_key_released) {
2139 g_ui->close_all_popups();
2140 g_popup_opened = FALSE;
2150 if (!g_candidate->soft_candidate_flag()) {
2152 if (key.dev_name.compare("ime") != 0) {
2153 ret = (sclu32)g_ui->process_key_event(key.get_key_string().c_str());
2158 ret = g_candidate->soft_candidate_handle_key_event(key.get_key_string().c_str());
2162 /* Process this key event if it was not generated by ime */
2163 if (key.dev_name.compare("ime") != 0) {
2164 ret = (sclu32)g_ui->process_key_event(key.get_key_string().c_str());
2170 /* Process this key event if it was not generated by ime */
2171 if (key.dev_name.compare("ime") != 0) {
2172 ret = (sclu32)g_ui->process_key_event(key.get_key_string().c_str());
2178 static void init_recent_used_punctuation()
2180 if (g_recent_used_punctuation.empty())
2182 g_recent_used_punctuation.push_back("#");
2183 g_recent_used_punctuation.push_back("$");
2184 g_recent_used_punctuation.push_back("%");
2185 g_recent_used_punctuation.push_back("^");
2186 g_recent_used_punctuation.push_back("&");
2190 static void update_recent_used_punctuation(const char * key_value)
2192 if (NULL == key_value)
2196 for (int i = 0; i < 10; ++i)
2199 snprintf(buf, sizeof(buf), "%d", i);
2200 if (strcmp(key_value, buf) == 0)
2205 string strKey = string(key_value);
2206 for (int i = 0; i < MAX_DEFAULT_PUNCTUATION; ++i)
2208 if (0 == strKey.compare(g_default_punctuation[i].c_str()))
2213 vector<string>::iterator iter = g_recent_used_punctuation.begin();
2214 for (; iter != g_recent_used_punctuation.end(); ++iter)
2216 if (0 == strKey.compare(iter->c_str()))
2221 if (iter != g_recent_used_punctuation.end())
2223 g_recent_used_punctuation.erase(iter);
2225 g_recent_used_punctuation.push_back(strKey);
2226 if (g_recent_used_punctuation.size() > MAX_DEFAULT_PUNCTUATION-1)
2228 g_recent_used_punctuation.erase(g_recent_used_punctuation.begin());
2232 static void set_ime_size(bool floating_mode, ISE_CANDIDATE_REQUEST candidate_req)
2237 SclSize size_portrait = g_ui->get_input_mode_size(g_ui->get_input_mode(), DISPLAYMODE_PORTRAIT);
2238 SclSize size_landscape = g_ui->get_input_mode_size(g_ui->get_input_mode(), DISPLAYMODE_LANDSCAPE);
2240 if (floating_mode) {
2241 size_portrait.width *= FLOATING_SCALE_RATE;
2242 size_portrait.height *= FLOATING_SCALE_RATE;
2243 size_landscape.width *= FLOATING_SCALE_RATE;
2244 size_landscape.height *= FLOATING_SCALE_RATE;
2245 switch (candidate_req) {
2246 case ISE_CANDIDATE_REQ_NONE:
2247 if (g_candidate && g_candidate->get_visible()) {
2248 g_ui->set_custom_starting_coordinates(0, FLOATING_TITLE_BAR_HEIGHT + g_candidate->get_height());
2249 size_portrait.height += g_candidate->get_height();
2250 size_landscape.height += g_candidate->get_height();
2252 g_ui->set_custom_starting_coordinates(0, FLOATING_TITLE_BAR_HEIGHT);
2255 case ISE_CANDIDATE_REQ_SHOW:
2256 g_ui->set_custom_starting_coordinates(0, FLOATING_TITLE_BAR_HEIGHT + g_candidate->get_height());
2257 if (g_input_panel_show || g_candidate_more_view) {
2258 size_portrait.height += g_candidate->get_height();
2259 size_landscape.height += g_candidate->get_height();
2261 size_portrait.height = g_candidate->get_height();
2262 size_landscape.height = g_candidate->get_height();
2265 case ISE_CANDIDATE_REQ_HIDE:
2266 g_ui->set_custom_starting_coordinates(0, FLOATING_TITLE_BAR_HEIGHT);
2271 if (g_ui->get_custom_scale_rate_x() != FLOATING_SCALE_RATE || g_ui->get_custom_scale_rate_y() != FLOATING_SCALE_RATE)
2272 g_ui->set_custom_scale_rate(FLOATING_SCALE_RATE, FLOATING_SCALE_RATE);
2274 ime_set_size(size_portrait.width, size_portrait.height + FLOATING_TITLE_BAR_HEIGHT,
2275 size_landscape.width, size_landscape.height + FLOATING_TITLE_BAR_HEIGHT);
2278 ise_destroy_move_handler();
2279 int rotation = elm_win_rotation_get(NATIVE_WINDOW_CAST(ime_get_main_window()));
2280 int handler_width = (rotation == 0 || rotation == 180) ? size_portrait.width : size_landscape.width;
2281 ise_show_move_handler(handler_width, FLOATING_TITLE_BAR_HEIGHT);
2284 switch (candidate_req) {
2285 case ISE_CANDIDATE_REQ_NONE:
2286 if (g_candidate && g_candidate->get_visible()) {
2287 g_ui->set_custom_starting_coordinates(0, g_candidate->get_height());
2288 size_portrait.height += g_candidate->get_height();
2289 size_landscape.height += g_candidate->get_height();
2291 g_ui->set_custom_starting_coordinates(0, 0);
2294 case ISE_CANDIDATE_REQ_SHOW:
2295 g_ui->set_custom_starting_coordinates(0, g_candidate->get_height());
2296 if (g_input_panel_show || g_candidate_more_view) {
2297 size_portrait.height += g_candidate->get_height();
2298 size_landscape.height += g_candidate->get_height();
2300 size_portrait.height = g_candidate->get_height();
2301 size_landscape.height = g_candidate->get_height();
2304 case ISE_CANDIDATE_REQ_HIDE:
2305 g_ui->set_custom_starting_coordinates(0, 0);
2310 if (g_ui->get_custom_scale_rate_x() != 1.0 || g_ui->get_custom_scale_rate_y() != 1.0)
2311 g_ui->set_custom_scale_rate(1.0, 1.0);
2313 ime_set_size(size_portrait.width, size_portrait.height, size_landscape.width, size_landscape.height);
2316 ise_destroy_move_handler();
2321 static void ime_app_create_cb(void *user_data)
2323 #if !(DEFER_ISE_CREATION)
2326 elm_app_name_set(PACKAGE);
2329 cbhm_open_service(&cbhm_handle);
2333 static void ime_app_exit_cb(void *user_data)
2339 cbhm_close_service(cbhm_handle);
2344 static void show_autofill_data(Ecore_IMF_Input_Hints input_hints)
2346 g_autofill_exist = false;
2347 char *text = autofill_get_string(input_hints);
2350 g_autofill_string = string(text);
2353 g_autofill_string = string("");
2355 SECURE_LOGD("autofill string : %s", g_autofill_string.c_str());
2357 if (g_autofill_string.length() > 0) {
2358 g_autofill_exist = true;
2360 ise_app_candidate_show();
2361 update_candidate_table();
2365 static void ime_app_show_cb(int ic, ime_context_h ime_ctx, void *user_data)
2367 Ise_Context iseContext;
2368 bool return_key_state, prediction_allow, password_mode, caps_mode;
2369 ime_layout_variation_e layout_variation;
2374 ime_context_get_layout(ime_ctx, &iseContext.layout);
2376 ime_context_get_layout_variation(ime_ctx, &layout_variation);
2377 iseContext.layout_variation = (int)layout_variation;
2379 ime_context_get_cursor_position(ime_ctx, &iseContext.cursor_pos);
2380 ime_context_get_autocapital_type(ime_ctx, &iseContext.autocapital_type);
2381 ime_context_get_return_key_type(ime_ctx, &iseContext.return_key_type);
2382 ime_context_get_return_key_state(ime_ctx, &return_key_state);
2384 ime_context_get_prediction_mode(ime_ctx, &prediction_allow);
2385 iseContext.prediction_allow = prediction_allow;
2387 ime_context_get_password_mode(ime_ctx, &password_mode);
2388 iseContext.password_mode = password_mode;
2390 ime_context_get_input_hint(ime_ctx, &iseContext.input_hint);
2391 ime_context_get_bidi_direction(ime_ctx, &iseContext.bidi_direction);
2392 ime_context_get_language(ime_ctx, &iseContext.language);
2393 ime_context_get_caps_mode(ime_ctx, &caps_mode);
2394 iseContext.caps_mode = caps_mode;
2396 iseContext.return_key_disabled = return_key_state;
2400 g_autofill_hint = iseContext.input_hint & ECORE_IMF_INPUT_HINT_AUTOFILL_MASK;
2402 LOGD("input hint : %x, autofill hint : %x\n", iseContext.input_hint, g_autofill_hint);
2404 if (g_autofill_hint == 0) {
2405 switch (iseContext.layout) {
2406 case ECORE_IMF_INPUT_PANEL_LAYOUT_EMAIL:
2407 g_autofill_hint = ECORE_IMF_INPUT_HINT_AUTOFILL_EMAIL_ADDRESS;
2409 case ECORE_IMF_INPUT_PANEL_LAYOUT_PHONENUMBER:
2410 g_autofill_hint = ECORE_IMF_INPUT_HINT_AUTOFILL_PHONE;
2417 // show autofill data
2418 show_autofill_data((Ecore_IMF_Input_Hints)g_autofill_hint);
2420 //g_ise_common->set_keyboard_ise_by_uuid(KEYBD_ISE_UUID);
2422 /* Don't update screen until all the information is correctly set */
2424 g_ui->set_update_pending(TRUE);
2426 ise_reset_context(); // reset ISE
2428 /*if (context.language == ECORE_IMF_INPUT_PANEL_LANG_ALPHABET) {
2429 ise_explictly_set_language(PRIMARY_LATIN_LANGUAGE_INDEX);
2432 _context_layout = iseContext.layout;
2433 _context_layout_variation = iseContext.layout_variation;
2434 ise_set_layout(iseContext.layout, iseContext.layout_variation);
2436 ise_set_return_key_type(iseContext.return_key_type);
2437 ise_set_return_key_disable(iseContext.return_key_disabled);
2439 ise_set_caps_mode(iseContext.caps_mode);
2440 ise_update_cursor_position(iseContext.cursor_pos);
2444 /* Now we update the whole screen */
2446 g_ui->set_update_pending(FALSE);
2449 static void ime_app_hide_cb(int ic, void *user_data)
2454 g_set_mime_type = FALSE;
2456 g_ic_smartreply = -1;
2459 static void ime_app_return_key_type_set_cb(Ecore_IMF_Input_Panel_Return_Key_Type type, void *user_data)
2461 LOGD("return key type : %d\n", type);
2462 ise_set_return_key_type(type);
2464 if (g_keyboard_state.visible_state)
2465 ise_show(g_keyboard_state.ic);
2468 static void ime_app_return_key_state_set_cb(bool disabled, void *user_data)
2470 LOGD("return key disabled : %d\n", disabled);
2471 ise_set_return_key_disable(disabled);
2474 static void ime_app_input_context_reset_cb(void *user_data)
2476 ise_reset_input_context();
2479 static void ime_app_cursor_position_updated_cb(int cursor_pos, void *user_data)
2481 LOGD("cursor position : %d\n", cursor_pos);
2482 ise_update_cursor_position(cursor_pos);
2485 static void ime_app_language_requested_cb(void *user_data, char **lang_code)
2487 ise_get_language_locale(lang_code);
2490 static void ime_app_surrounding_text_updated_cb(int context_id, const char *text, int cursor_pos, void *user_data)
2492 SECURE_LOGD("surrounding text:%s, cursor=%d\n", text, cursor_pos);
2493 ime_delete_surrounding_text(-cursor_pos, strlen(text));
2496 static void ime_app_focus_in_cb(int context_id, void *user_data)
2499 ise_focus_in(context_id);
2500 if (!g_smartreply_reply_exist && g_softcandidate_show) {
2502 ise_app_candidate_hide();
2503 g_candidate->hide();
2508 static void ime_app_focus_out_cb(int context_id, void *user_data)
2511 ise_focus_out(context_id);
2514 g_set_mime_type = FALSE;
2516 g_smartreply_reply_exist = false;
2517 g_smartreply_size = 0;
2518 input_smartreply_deinit();
2519 g_ic_smartreply = -1;
2521 g_autofill_exist = false;
2522 g_autofill_hint = 0;
2524 g_app_id = string("");
2525 g_resource_id = string("");
2527 g_autofill_string = string("");
2528 g_smartreply_strings.clear();
2529 g_lookup_table_strings.clear();
2530 g_softcandidate_string.clear();
2533 static void ime_app_layout_set_cb(Ecore_IMF_Input_Panel_Layout layout, void *user_data)
2535 LOGD("layout=%d\n", layout);
2536 /* Check if the layoutIdx is in the valid range */
2537 if ((ISE_LAYOUT)layout < ISE_LAYOUT_STYLE_MAX) {
2538 if (g_keyboard_state.layout != layout) {
2539 g_keyboard_state.need_reset = TRUE;
2541 g_keyboard_state.layout = layout;
2542 _context_layout = layout;
2543 _context_layout_variation = 0;
2545 if (g_keyboard_state.visible_state)
2546 ise_show(g_keyboard_state.ic);
2549 static void ime_app_rotation_degree_changed_cb(int degree, void *user_data)
2551 ise_set_screen_rotation(degree);
2553 LOGD("degree=%d\n", degree);
2555 if (g_floating_mode) {
2557 ise_destroy_move_handler();
2558 if (degree == 0 || degree == 180) {
2559 SclSize size_portrait = g_ui->get_input_mode_size(g_ui->get_input_mode(), DISPLAYMODE_PORTRAIT);
2560 handler_width = size_portrait.width * FLOATING_SCALE_RATE;
2562 SclSize size_landscape = g_ui->get_input_mode_size(g_ui->get_input_mode(), DISPLAYMODE_LANDSCAPE);
2563 handler_width = size_landscape.width * FLOATING_SCALE_RATE;
2565 ise_show_move_handler(handler_width, FLOATING_TITLE_BAR_HEIGHT);
2568 if (is_emoticon_show()) {
2569 ise_destroy_emoticon_layout();
2571 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_VOICE) {
2572 ise_hide_stt_mode();
2574 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_EMOTICON) {
2575 ise_show_emoticon_layout(current_emoticon_group, degree, false, ime_get_main_window());
2577 const sclchar *input_mode = g_ui->get_input_mode();
2579 if (!(strcmp(input_mode, "EMOTICON_LAYOUT")))
2580 ise_show_emoticon_layout(current_emoticon_group, degree, false, ime_get_main_window());
2581 else if (!(strcmp(input_mode, "STT_3X4")))
2582 ise_show_stt_mode(NATIVE_WINDOW_CAST(ime_get_main_window()));
2587 static void ime_app_accessibility_state_changed_cb(bool state, void *user_data)
2589 LOGD("state=%d\n", state);
2590 ise_set_accessibility_state(state);
2593 static void ime_app_imdata_set_cb(void *data, unsigned int data_length, void *user_data)
2597 size_t _len = data_length;
2598 set_ise_imdata((sclchar *)data, _len);
2601 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)
2603 scim::KeyEvent key(keycode, keymask);
2605 char *dev_name = NULL;
2606 Ecore_IMF_Device_Class dev_class;
2607 Ecore_IMF_Device_Subclass dev_subclass;
2609 if (ime_device_info_get_name(dev_info, &dev_name) == IME_ERROR_NONE) {
2610 key.dev_name = dev_name;
2613 if (ime_device_info_get_class(dev_info, &dev_class) == IME_ERROR_NONE) {
2614 key.dev_class = dev_class;
2617 if (ime_device_info_get_subclass(dev_info, &dev_subclass) == IME_ERROR_NONE) {
2618 key.dev_subclass = dev_subclass;
2621 if (g_keyboard_state.visible_state)
2622 ise_process_key_event(key, ret);
2632 static void ime_app_caps_mode_changed_cb(int mode, void *user_data)
2634 ise_set_caps_mode(mode);
2637 static void ime_app_candidate_show_cb(int context_id, void *user_data)
2640 const sclchar *cur_lang = _language_manager.get_current_language();
2641 if (cur_lang && !strcmp(cur_lang, "English")) {
2642 if (!g_config_values.prediction_on ||
2643 (g_keyboard_state.layout == ISE_LAYOUT_STYLE_PHONENUMBER ||
2644 g_keyboard_state.layout == ISE_LAYOUT_STYLE_VOICE ||
2645 g_keyboard_state.layout == ISE_LAYOUT_STYLE_IP ||
2646 g_keyboard_state.layout == ISE_LAYOUT_STYLE_MONTH ||
2647 g_keyboard_state.layout == ISE_LAYOUT_STYLE_NUMBERONLY ||
2648 g_keyboard_state.layout == ISE_LAYOUT_STYLE_PASSWD_3X4||
2649 g_keyboard_state.layout == ISE_LAYOUT_STYLE_PASSWORD)){
2650 ise_app_candidate_hide();
2651 g_softcandidate_show = false;
2653 g_softcandidate_show = true;
2654 ise_app_candidate_show();
2657 ise_app_candidate_hide();
2658 g_softcandidate_show = false;
2661 ise_app_candidate_show();
2665 static void ime_app_candidate_hide_cb(int context_id, void *user_data)
2668 const sclchar *cur_lang = _language_manager.get_current_language();
2669 if (cur_lang && !strcmp(cur_lang, "English")) {
2670 if (!g_config_values.prediction_on ||
2671 (g_keyboard_state.layout == ISE_LAYOUT_STYLE_PHONENUMBER ||
2672 g_keyboard_state.layout == ISE_LAYOUT_STYLE_VOICE ||
2673 g_keyboard_state.layout == ISE_LAYOUT_STYLE_IP ||
2674 g_keyboard_state.layout == ISE_LAYOUT_STYLE_MONTH ||
2675 g_keyboard_state.layout == ISE_LAYOUT_STYLE_NUMBERONLY ||
2676 g_keyboard_state.layout != ISE_LAYOUT_STYLE_EMAIL ||
2677 g_keyboard_state.layout == ISE_LAYOUT_STYLE_PASSWD_3X4||
2678 g_keyboard_state.layout == ISE_LAYOUT_STYLE_PASSWORD)){
2679 ise_app_candidate_hide();
2680 g_softcandidate_show = false;
2682 g_softcandidate_show = true;
2683 ise_app_candidate_show();
2686 ise_app_candidate_hide();
2687 g_softcandidate_show = false;
2690 ise_app_candidate_hide();
2694 static void ime_app_lookup_table_changed_cb(Eina_List *list, void *user_data)
2696 vector<string> candidate_strings;
2701 g_lookup_table_strings.clear();
2704 EINA_LIST_FOREACH(list, l, data) {
2705 candidate = (char *)data;
2707 g_lookup_table_strings.push_back(string(candidate));
2708 candidate_strings.push_back(string(candidate));
2713 if (g_smartreply_reply_exist) {
2714 if (candidate_strings[0] == "#" && candidate_strings[1] == "$") {
2717 ime_get_surrounding_text(0, 0, &text, &cursor);
2726 update_candidate_table();
2730 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)
2732 if (device_type == IME_INPUT_DEVICE_TYPE_ROTARY) {
2733 ime_input_device_rotary_direction_e direction;
2734 if (IME_ERROR_NONE == ime_input_device_rotary_get_direction(device_event, &direction)) {
2735 sclu32 new_layout = g_keyboard_state.layout;
2736 if (direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_CLOCKWISE) {
2737 LOGD("CLOCKWISE\n");
2738 switch (g_keyboard_state.layout) {
2739 case ISE_LAYOUT_STYLE_NORMAL:
2740 case ISE_LAYOUT_STYLE_EMAIL:
2741 case ISE_LAYOUT_STYLE_URL:
2742 case ISE_LAYOUT_STYLE_PASSWORD:
2743 if (_context_layout == ISE_LAYOUT_STYLE_PASSWORD &&
2744 _context_layout_variation == ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD_VARIATION_NUMBERONLY)
2745 ; // PASSWORD NUMBER ONLY, do nothing
2747 new_layout = ISE_LAYOUT_STYLE_NUMBER;
2749 case ISE_LAYOUT_STYLE_NUMBER:
2750 new_layout = ISE_LAYOUT_STYLE_HEX;
2752 case ISE_LAYOUT_STYLE_HEX:
2753 if (_context_layout == ISE_LAYOUT_STYLE_EMAIL ||
2754 _context_layout == ISE_LAYOUT_STYLE_URL)
2755 new_layout = ISE_LAYOUT_STYLE_VOICE;
2756 else if (_context_layout == ISE_LAYOUT_STYLE_PASSWORD)
2757 new_layout = _context_layout;
2759 new_layout = ISE_LAYOUT_STYLE_EMOTICON;
2761 case ISE_LAYOUT_STYLE_EMOTICON:
2762 if (_context_layout == ISE_LAYOUT_STYLE_EMAIL ||
2763 _context_layout == ISE_LAYOUT_STYLE_URL ||
2764 _context_layout == ISE_LAYOUT_STYLE_PASSWORD)
2765 new_layout = _context_layout;
2767 new_layout = ISE_LAYOUT_STYLE_VOICE;
2769 case ISE_LAYOUT_STYLE_VOICE:
2770 new_layout = ISE_LAYOUT_STYLE_NORMAL;
2775 } else if (direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_COUNTER_CLOCKWISE) {
2776 LOGD("COUNTER_CLOCKWISE\n");
2777 switch (g_keyboard_state.layout) {
2778 case ISE_LAYOUT_STYLE_NORMAL:
2779 case ISE_LAYOUT_STYLE_EMAIL:
2780 case ISE_LAYOUT_STYLE_URL:
2781 case ISE_LAYOUT_STYLE_PASSWORD:
2782 if (_context_layout == ISE_LAYOUT_STYLE_PASSWORD &&
2783 _context_layout_variation == ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD_VARIATION_NUMBERONLY)
2784 ; // PASSWORD NUMBER ONLY, do nothing
2785 else if (_context_layout == ISE_LAYOUT_STYLE_PASSWORD)
2786 new_layout = ISE_LAYOUT_STYLE_HEX;
2788 new_layout = ISE_LAYOUT_STYLE_VOICE;
2790 case ISE_LAYOUT_STYLE_NUMBER:
2791 if (_context_layout == ISE_LAYOUT_STYLE_EMAIL ||
2792 _context_layout == ISE_LAYOUT_STYLE_URL ||
2793 _context_layout == ISE_LAYOUT_STYLE_PASSWORD)
2794 new_layout = _context_layout;
2796 new_layout = ISE_LAYOUT_STYLE_NORMAL;
2798 case ISE_LAYOUT_STYLE_HEX:
2799 new_layout = ISE_LAYOUT_STYLE_NUMBER;
2801 case ISE_LAYOUT_STYLE_EMOTICON:
2802 new_layout = ISE_LAYOUT_STYLE_HEX;
2804 case ISE_LAYOUT_STYLE_VOICE:
2805 if (_context_layout == ISE_LAYOUT_STYLE_EMAIL ||
2806 _context_layout == ISE_LAYOUT_STYLE_URL)
2807 new_layout = ISE_LAYOUT_STYLE_HEX;
2809 new_layout = ISE_LAYOUT_STYLE_EMOTICON;
2815 if (new_layout != g_keyboard_state.layout && new_layout < ISE_LAYOUT_STYLE_MAX) {
2816 g_keyboard_state.need_reset = TRUE;
2817 g_keyboard_state.layout = new_layout;
2819 if (g_keyboard_state.visible_state) {
2820 _reset_multitap_state();
2821 _language_manager.reset_language(g_config_values.selected_language.c_str());
2822 ise_show(g_keyboard_state.ic);
2830 static void ime_app_prediction_hint_set_cb(const char *prediction_hint, void *user_data)
2832 char *sender = (char *)"mms";
2833 char *caller_id = (char *)"mms";
2834 char *hint = (char *)prediction_hint;
2836 if (!prediction_hint) return;
2837 SECURE_LOGD("prediction hint : %s\n", prediction_hint);
2839 if (strlen(prediction_hint) > 0) {
2840 input_smartreply_init(caller_id, sender, hint);
2841 input_smartreply_set_notify(_input_smartreply_notify_cb, NULL);
2843 if (input_smartreply_is_enabled()) {
2844 g_smartreply_size = 0;
2845 g_smartreply_reply_exist = false;
2847 input_smartreply_get_reply_async();
2852 static void ime_app_mime_type_set_request_cb(const char *mime_types, void *user_data)
2854 LOGD("mime type : %s\n", mime_types);
2857 g_set_mime_type = TRUE;
2859 string str(mime_types), text_key = "text/", image_key = "image/";
2861 if (str.find(text_key) != string::npos)
2862 cbhm_sel_type |= CBHM_SEL_TYPE_TEXT;
2864 if (str.find(image_key) != string::npos)
2865 cbhm_sel_type |= CBHM_SEL_TYPE_IMAGE;
2867 LOGD("cbhm_sel_type=0x%x", cbhm_sel_type);
2871 /*static void ime_app_prediction_hint_data_set_cb(const char *key, const char *value, void *user_data)
2873 SECURE_LOGD("key : %s, value : %s\n", key, value);
2875 if (string(key) == "appid")
2876 g_app_id = string(value ? value : "");
2877 else if (string(key) == "res_id")
2878 g_resource_id = string(value ? value : "");
2884 EXPORTED void ime_app_main(int argc, char **argv)
2886 ime_callback_s basic_callback = {
2893 ime_event_set_focus_in_cb(ime_app_focus_in_cb, NULL);
2894 ime_event_set_focus_out_cb(ime_app_focus_out_cb, NULL);
2895 ime_event_set_rotation_degree_changed_cb(ime_app_rotation_degree_changed_cb, NULL);
2896 ime_event_set_accessibility_state_changed_cb(ime_app_accessibility_state_changed_cb, NULL);
2897 ime_event_set_layout_set_cb(ime_app_layout_set_cb, NULL);
2898 ime_event_set_caps_mode_changed_cb(ime_app_caps_mode_changed_cb, NULL);
2899 ime_event_set_cursor_position_updated_cb(ime_app_cursor_position_updated_cb, NULL);
2900 ime_event_set_surrounding_text_updated_cb(ime_app_surrounding_text_updated_cb, NULL);
2901 ime_event_set_return_key_type_set_cb(ime_app_return_key_type_set_cb, NULL);
2902 ime_event_set_return_key_state_set_cb(ime_app_return_key_state_set_cb, NULL);
2903 ime_event_set_imdata_set_cb(ime_app_imdata_set_cb, NULL);
2904 ime_event_set_process_key_event_cb(ime_app_process_key_event_cb, NULL);
2906 ime_event_set_candidate_show_cb(ime_app_candidate_show_cb, NULL);
2907 ime_event_set_candidate_hide_cb(ime_app_candidate_hide_cb, NULL);
2908 ime_event_set_lookup_table_changed_cb(ime_app_lookup_table_changed_cb, NULL);
2911 ime_event_set_process_input_device_event_cb(ime_app_process_input_device_event_cb, NULL);
2914 ime_event_set_input_context_reset_cb(ime_app_input_context_reset_cb, NULL);
2915 ime_event_set_language_requested_cb(ime_app_language_requested_cb, NULL);
2917 ime_event_set_prediction_hint_set_cb(ime_app_prediction_hint_set_cb, NULL);
2918 ime_event_set_mime_type_set_request_cb(ime_app_mime_type_set_request_cb, NULL);
2919 //ime_event_set_prediction_hint_data_set_cb(ime_app_prediction_hint_data_set_cb, NULL);
2921 #if DEFER_ISE_CREATION
2922 ime_set_window_creation_defer_flag(TRUE);
2925 ime_run(&basic_callback, NULL);
2931 EXPORTED int main(int argc, char *argv[])
2933 ime_app_main(argc, argv);