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>
32 #include <ode/internal-encryption.h>
40 #include "languages.h"
41 #include "candidate-factory.h"
42 #include "ise-emoticon-mode.h"
43 #include "ise-stt-mode.h"
44 #include "ise-stt-option.h"
45 #include "ise-language-change.h"
46 #include "ise-tutorial-mode.h"
47 #include "modeindicator.h"
48 #include "w-input-smartreply.h"
49 #include "ise-floating-mode.h"
51 #define EDJ_FILE RESDIR"/edje/mobile/customised_ctxpopup.edj"
53 #define EXIT_ISE_ON_HIDE 0
54 #define DEFER_ISE_CREATION 0
56 #define CANDIDATE_WINDOW_HEIGHT 84
64 static cbhm_h cbhm_handle;
65 static sclu32 cbhm_sel_type = 0;
66 static sclboolean g_set_mime_type = FALSE;
69 int g_imdata_state = 0;
71 extern emoticon_group_t current_emoticon_group;
72 extern std::vector <int> emoticon_list_recent;
74 extern CONFIG_VALUES g_config_values;
75 static sclboolean g_need_send_shift_event = FALSE;
77 extern void set_ise_imdata(const char * buf, size_t &len);
78 static void init_recent_used_punctuation();
79 static void update_recent_used_punctuation(const char *key_value);
80 static void set_ime_size(bool floating_mode, ISE_CANDIDATE_REQUEST candidate_req);
81 static sclboolean g_punctuation_popup_opened = FALSE;
82 static sclboolean g_popup_opened = FALSE;
83 static vector<string> g_recent_used_punctuation;
84 static const int MAX_DEFAULT_PUNCTUATION = 6;
85 static string g_default_punctuation[MAX_DEFAULT_PUNCTUATION] = {"-", "@", "'", "!", "?", ","};
86 static string g_current_punctuation[MAX_DEFAULT_PUNCTUATION-1] = {"RCENT1", "RCENT2", "RCENT3", "RCENT4", "RCENT5"};
87 static vector<string> g_softcandidate_string;
88 static bool g_softcandidate_show = false;
89 static bool g_input_panel_show = false;
90 static bool g_smartreply_reply_exist = false;
91 static unsigned int g_smartreply_size = 0;
92 static bool g_caps_mode_pending = false;
93 static bool g_floating_mode = false;
94 static bool g_candidate_more_view = false;
95 static bool g_ise_created = false;
97 static bool g_autofill_exist = false;
98 static int g_autofill_hint = 0;
99 static string g_autofill_string;
100 static vector<string> g_lookup_table_strings;
101 static vector<string> g_smartreply_strings;
103 static Ecore_Timer *guideline_timer = NULL;
106 static Ecore_Timer *exit_timer = NULL;
109 static string g_app_id;
110 static string g_resource_id;
112 #define SOFT_CANDIDATE_DELETE_TIME (100.0/1000)
113 static Ecore_Timer *g_softcandidate_hide_timer = NULL;
115 extern sclboolean g_setting_window_open_status;
118 static int g_ic_smartreply = -1;
120 KEYBOARD_STATE g_keyboard_state = {
123 ISE_LAYOUT_STYLE_NORMAL,
133 #define ISE_LAYOUT_NUMBERONLY_VARIATION_MAX 4
134 /*static const sclchar *_ise_numberonly_variation_name[ISE_LAYOUT_NUMBERONLY_VARIATION_MAX] = {
135 "DEFAULT", "SIG", "DEC", "SIGDEC"
138 #define SIG_DEC_SIZE 2
139 static scluint _click_count = 0;
140 static const char *_sig_dec[SIG_DEC_SIZE] = {".", "-"};
141 static scluint _sig_dec_event[SIG_DEC_SIZE] = {'.', '-'};
142 static Ecore_Timer *_commit_timer = NULL;
144 static sclu32 _context_layout = ISE_LAYOUT_STYLE_NORMAL;
145 static sclu32 _context_layout_variation = 0;
147 Candidate *g_candidate = NULL;
149 class CandidateEventListener: public EventListener
152 void on_event(const EventDesc &desc)
154 const MultiEventDesc &multidesc = dynamic_cast<const MultiEventDesc &>(desc);
155 switch (multidesc.type) {
156 case MultiEventDesc::CANDIDATE_ITEM_MOUSE_DOWN:
157 if (g_autofill_exist) {
158 if (multidesc.index == 0) {
159 char *text = autofill_get_string((Ecore_IMF_Input_Hints)g_autofill_hint);
161 ise_send_string(text);
164 } else if (multidesc.index < (int)g_smartreply_size + 1) {
165 ise_send_string(g_softcandidate_string[multidesc.index].c_str());
167 ime_select_candidate(multidesc.index - g_smartreply_size - 1);
170 if (multidesc.index < (int)g_smartreply_size)
171 ise_send_string(g_softcandidate_string[multidesc.index].c_str());
173 ime_select_candidate(multidesc.index - g_smartreply_size);
176 case MultiEventDesc::CANDIDATE_MORE_VIEW_SHOW:
177 // when more parts shows, click on the candidate will
178 // not affect the key click event
179 g_candidate_more_view = true;
180 if (!g_input_panel_show)
181 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_SHOW);
183 g_ui->disable_input_events(TRUE);
185 case MultiEventDesc::CANDIDATE_MORE_VIEW_HIDE:
186 g_candidate_more_view = false;
187 if (!g_input_panel_show)
188 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_SHOW);
190 g_ui->disable_input_events(FALSE);
196 static CandidateEventListener g_candidate_event_listener;
198 static ISELanguageManager _language_manager;
199 #define MVK_Shift_L 0xffe1
200 #define MVK_Caps_Lock 0xffe5
201 #define MVK_Shift_Off 0xffe1
202 #define MVK_Shift_On 0xffe2
203 #define MVK_Shift_Lock 0xffe6
204 #define MVK_Shift_Enable 0x9fe7
205 #define MVK_Shift_Disable 0x9fe8
206 #define MVK_space 0x020
208 #define CM_KEY_LIST_SIZE 5
209 #define USER_KEYSTRING_OPTION "OPTION"
210 #define USER_KEYSTRING_EMOTICON "EMOTICON_LAYOUT"
211 #define USER_KEYSTRING_CLIPBOARD "CLIPBOARD"
212 #define USER_KEYSTRING_VOICE "STT_3X4"
213 #define USER_KEYSTRING_FLOATING "FLOATING"
215 #define USER_VOICE_LANGUAGE "LANGUAGE"
217 static sclboolean _cm_popup_opened = FALSE;
218 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};
219 static scluint _current_cm_key_id = 0;
220 Evas_Object* _guide_popup_window = NULL;
223 * This callback class will receive all response events from SCL
224 * So you should perform desired tasks in this class.
226 class CUIEventCallback : public ISCLUIEventCallback
229 SCLEventReturnType on_event_key_clicked(SclUIEventDesc event_desc);
230 SCLEventReturnType on_event_drag_state_changed(SclUIEventDesc event_desc);
231 SCLEventReturnType on_event_notification(SCLUINotiType noti_type, SclNotiDesc *etc_info);
234 static CUIEventCallback callback;
236 static void update_candidate_table()
238 g_softcandidate_string.clear();
239 vector<string>::iterator iter;
241 // add autofill string
242 if (g_autofill_exist)
243 g_softcandidate_string.push_back(g_autofill_string);
245 // add lookup table string(s)
246 iter = g_lookup_table_strings.begin();
247 for (; iter != g_lookup_table_strings.end(); ++iter)
249 g_softcandidate_string.push_back(string(iter->c_str()));
252 ise_update_table(g_softcandidate_string);
255 static void _input_smartreply_notify_cb(void *user_data)
257 g_smartreply_strings.clear();
260 if (input_smartreply_is_enabled()) {
261 /* Append newly added smartreply list */
262 int len = input_smartreply_get_reply_num();
264 for (int i = 0; i < len; i++) {
266 char *reply = (char *)"";
267 reply = input_smartreply_get_nth_item(i, &type);
270 SECURE_LOGD("SmartReply = [%d] %s", i, reply);
273 g_smartreply_strings.push_back(string(candidate));
277 g_ic_smartreply = g_ic;
278 g_smartreply_reply_exist = true;
280 ise_app_candidate_show();
281 g_softcandidate_string = g_smartreply_strings;
282 ise_update_table(g_softcandidate_string);
288 check_ic_temporary(int ic)
290 if ((ic & 0xFFFF) == 0) {
296 static void _reset_shift_state(void)
299 /* Reset all shift state variables */
300 SCLShiftState old_shift_state = g_ui->get_shift_state();
301 SCLShiftState new_shift_state = SCL_SHIFT_STATE_OFF;
302 if (old_shift_state != new_shift_state) {
303 g_need_send_shift_event = true;
304 g_ui->set_shift_state(new_shift_state);
306 LOGD("Shift state changed from (%d) to (%d)\n", (int)old_shift_state, (int)new_shift_state);
310 static void set_caps_mode(sclboolean mode) {
311 LOGD("mode : %d\n", mode);
313 if (g_ui->get_shift_state() != SCL_SHIFT_STATE_LOCK) {
314 g_ui->set_shift_state(mode ? SCL_SHIFT_STATE_ON : SCL_SHIFT_STATE_OFF);
315 g_ui->set_autocapital_shift_state(!mode);
320 static void _reset_multitap_state(bool skip_commit = false)
322 LOGD("g_keyboard_state.prev_modifier : %d", g_keyboard_state.prev_modifier);
323 if (g_keyboard_state.prev_modifier == KEY_MODIFIER_MULTITAP_START ||
324 g_keyboard_state.prev_modifier == KEY_MODIFIER_MULTITAP_REPEAT) {
326 ise_send_string(g_keyboard_state.multitap_value.c_str());
328 ise_update_preedit_string("");
330 g_keyboard_state.multitap_value = "";
331 g_keyboard_state.prev_modifier = KEY_MODIFIER_NONE;
332 if (g_caps_mode_pending) {
333 g_caps_mode_pending = false;
334 set_caps_mode(g_keyboard_state.caps_mode);
338 static void ise_set_cm_private_key(scluint cm_key_id)
340 if (cm_key_id >= CM_KEY_LIST_SIZE || g_ui == NULL) {
341 LOGE("cm_key_id=%d\n", cm_key_id);
345 if (strcmp(_cm_key_list[cm_key_id], USER_KEYSTRING_EMOTICON) == 0) {
346 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
347 const_cast<sclchar*>("icon/54x54/icon_emotion_nor.png"),
348 const_cast<sclchar*>("icon/54x54/icon_emotion_press.png"),
349 const_cast<sclchar*>("icon/54x54/icon_emotion_dim.png")};
350 g_ui->set_private_key("CM_KEY", const_cast<sclchar*>(" "), imagelabel, NULL, 0, const_cast<sclchar*>(USER_KEYSTRING_EMOTICON), TRUE);
351 } else if (strcmp(_cm_key_list[cm_key_id], USER_KEYSTRING_OPTION) == 0) {
352 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
353 const_cast<sclchar*>("icon/54x54/icon_setting_nor.png"),
354 const_cast<sclchar*>("icon/54x54/icon_setting_press.png"),
355 const_cast<sclchar*>("icon/54x54/icon_setting_dim.png")};
356 g_ui->set_private_key("CM_KEY", const_cast<sclchar*>(" "), imagelabel, NULL, 0, const_cast<sclchar*>(USER_KEYSTRING_OPTION), TRUE);
357 } else if (strcmp(_cm_key_list[cm_key_id], USER_KEYSTRING_CLIPBOARD) == 0) {
358 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
359 const_cast<sclchar*>("icon/54x54/icon_clipboard_nor.png"),
360 const_cast<sclchar*>("icon/54x54/icon_clipboard_press.png"),
361 const_cast<sclchar*>("icon/54x54/icon_clipboard_dim.png")};
362 g_ui->set_private_key("CM_KEY", const_cast<sclchar*>(" "), imagelabel, NULL, 0, const_cast<sclchar*>(USER_KEYSTRING_CLIPBOARD), TRUE);
363 } else if (strcmp(_cm_key_list[cm_key_id], USER_KEYSTRING_VOICE) == 0) {
364 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
365 const_cast<sclchar*>("icon/54x54/icon_mic_nor.png"),
366 const_cast<sclchar*>("icon/54x54/icon_mic_press.png"),
367 const_cast<sclchar*>("icon/54x54/icon_mic_dim.png")};
368 g_ui->set_private_key("CM_KEY", const_cast<sclchar*>(" "), imagelabel, NULL, 0, const_cast<sclchar*>(USER_KEYSTRING_VOICE), TRUE);
369 } else if (strcmp(_cm_key_list[cm_key_id], USER_KEYSTRING_FLOATING) == 0) {
370 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
371 const_cast<sclchar*>("icon/54x54/icon_floating_keypad_nor.png"),
372 const_cast<sclchar*>("icon/54x54/icon_floating_keypad_press.png"),
373 const_cast<sclchar*>("icon/54x54/icon_floating_keypad_dim.png")};
374 g_ui->set_private_key("CM_KEY", const_cast<sclchar*>(" "), imagelabel, NULL, 0, const_cast<sclchar*>(USER_KEYSTRING_FLOATING), TRUE);
378 static void ise_update_space_key(void)
381 LOGE("g_ui = NULL\n");
385 scluint num = _language_manager.get_enabled_languages_num();
386 LOGD("language number: %d\n", num);
388 LANGUAGE_INFO *info = _language_manager.get_language_info(_language_manager.get_current_language());
389 if (info && info->enabled) {
391 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
392 const_cast<sclchar*>("w_sip_3x4_btn_ic_space_no_arrow.png"),
393 const_cast<sclchar*>("w_sip_3x4_btn_ic_space_no_arrow.png"),
394 const_cast<sclchar*>("w_sip_3x4_btn_ic_space_no_arrow.png")};
395 g_ui->set_private_key("SPACE_KEY", const_cast<sclchar*>(info->display_name.c_str()), imagelabel, NULL, 0, const_cast<sclchar*>("Space"), TRUE);
397 g_ui->enable_button("SPACE_ARROW_LEFT", false);
398 g_ui->enable_button("SPACE_ARROW_RIGHT", false);
403 g_ui->unset_private_key("SPACE_KEY");
405 g_ui->enable_button("SPACE_ARROW_LEFT", true);
406 g_ui->enable_button("SPACE_ARROW_RIGHT", true);
411 static scluint ise_get_cm_key_id(const sclchar *key_value)
413 for (int i = 0; i < CM_KEY_LIST_SIZE; ++i) {
414 if (0 == strcmp (key_value, _cm_key_list[i]))
420 static bool ise_is_emoticons_disabled(void)
423 sclu32 current_layout = g_keyboard_state.layout;
424 LOGD("layout=%d\n", current_layout);
426 if ((current_layout == ISE_LAYOUT_STYLE_NORMAL) ||
427 (current_layout == ISE_LAYOUT_STYLE_NUMBER) ||
428 (current_layout == ISE_LAYOUT_STYLE_EMOTICON))
431 if (g_imdata_state & IMDATA_ACTION_DISABLE_EMOTICONS)
437 static Eina_Bool softcandidate_hide_timer_callback(void *data)
440 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_HIDE);
444 g_softcandidate_show = false;
446 return ECORE_CALLBACK_CANCEL;
449 static void delete_softcandidate_hide_timer(void)
451 if (g_softcandidate_hide_timer) {
452 ecore_timer_del(g_softcandidate_hide_timer);
453 g_softcandidate_hide_timer = NULL;
457 static void add_softcandidate_hide_timer(void)
459 delete_softcandidate_hide_timer();
460 g_softcandidate_hide_timer = ecore_timer_add(SOFT_CANDIDATE_DELETE_TIME, softcandidate_hide_timer_callback, NULL);
463 static void create_softcandidate(void)
466 g_candidate = CandidateFactory::make_candidate(CANDIDATE_MULTILINE, ime_get_main_window());
468 g_candidate->add_event_listener(&g_candidate_event_listener);
474 * Send the given string to input framework
477 ise_send_string(const sclchar *key_value)
480 if (!check_ic_temporary(g_keyboard_state.ic)) {
481 ic = g_keyboard_state.ic;
483 ime_commit_string(key_value);
484 LOGD("ic : %x, %s\n", ic, key_value);
488 * Send the preedit string to input framework
491 ise_update_preedit_string(const sclchar *str, const sclboolean underline)
494 Eina_List *attr_list = NULL;
495 ime_preedit_attribute *preedit_attr;
497 if (!check_ic_temporary(g_keyboard_state.ic)) {
498 ic = g_keyboard_state.ic;
501 /* Count UTF-8 string length */
503 const sclchar *s = str;
504 while (*s) len += (*s++ & 0xc0) != 0x80;
506 preedit_attr = (ime_preedit_attribute *)calloc(1, sizeof(ime_preedit_attribute));
508 preedit_attr->start = 0;
509 preedit_attr->length = len;
510 preedit_attr->type = IME_ATTR_FONTSTYLE;
511 preedit_attr->value = IME_ATTR_FONTSTYLE_UNDERLINE;
512 attr_list = eina_list_append(attr_list, (void *)preedit_attr);
515 ime_update_preedit_string(str, attr_list);
517 ime_update_preedit_string(str, NULL);
519 LOGD("ic : %x, %s\n", ic, str);
523 * Send the given event to input framework
526 ise_send_event(sclulong key_event, sclulong key_mask)
529 if (!check_ic_temporary(g_keyboard_state.ic)) {
530 ic = g_keyboard_state.ic;
532 ime_send_key_event((ime_key_code_e)key_event, IME_KEY_MASK_PRESSED, false);
533 ime_send_key_event((ime_key_code_e)key_event, IME_KEY_MASK_RELEASED, false);
535 LOGD("ic : %x, %x\n", ic, key_event);
539 * Forward the given event to input framework
542 ise_forward_key_event(sclulong key_event)
545 if (!check_ic_temporary(g_keyboard_state.ic)) {
546 ic = g_keyboard_state.ic;
548 ime_send_key_event((ime_key_code_e)key_event, IME_KEY_MASK_PRESSED, true);
549 ime_send_key_event((ime_key_code_e)key_event, IME_KEY_MASK_RELEASED, true);
551 LOGD("ic : %x, %x\n", ic, key_event);
555 * @brief Delete commit timer.
559 static void delete_commit_timer(void)
561 if (_commit_timer != NULL) {
562 ecore_timer_del(_commit_timer);
563 _commit_timer = NULL;
568 * @brief Callback function for commit timer.
570 * @param data Data to pass when it is called.
572 * @return ECORE_CALLBACK_CANCEL
574 static Eina_Bool commit_timeout(void *data)
576 if (_commit_timer != NULL) {
577 ime_hide_preedit_string();
578 ise_forward_key_event(_sig_dec_event[(_click_count-1)%SIG_DEC_SIZE]);
581 _commit_timer = NULL;
582 return ECORE_CALLBACK_CANCEL;
586 on_input_mode_changed(const sclchar *key_value, sclulong key_event, sclint key_type)
588 sclboolean ret = FALSE;
592 SECURE_LOGD("key_value : %s\n", key_value);
593 if (strcmp(key_value, "CUR_LANG") == 0) {
594 g_keyboard_state.disable_force_latin = TRUE;
595 ret = _language_manager.select_current_language();
597 if (strcmp(key_value, "NEXT_LANG") == 0) {
598 g_keyboard_state.disable_force_latin = TRUE;
599 ret = _language_manager.select_next_language();
603 const sclchar *cur_lang = _language_manager.get_current_language();
605 LANGUAGE_INFO *info = _language_manager.get_language_info(cur_lang);
607 if (info->accepts_caps_mode) {
608 ise_send_event(MVK_Shift_Enable, KEY_MASK_NULL);
609 set_caps_mode(g_keyboard_state.caps_mode);
611 ise_send_event(MVK_Shift_Disable, KEY_MASK_NULL);
612 g_ui->set_shift_state(SCL_SHIFT_STATE_OFF);
616 if (is_emoticon_show()) {
617 ise_destroy_emoticon_layout();
620 if (!strcmp(key_value, USER_KEYSTRING_EMOTICON)) {
621 ise_init_emoticon_list();
623 current_emoticon_group = EMOTICON_GROUP_1;
625 if (emoticon_list_recent.size() == 0)
626 current_emoticon_group = EMOTICON_GROUP_1;
628 current_emoticon_group = EMOTICON_GROUP_RECENTLY_USED;
630 SCLRotation rotation = g_ui->get_rotation();
631 ise_show_emoticon_layout(current_emoticon_group, ROTATION_TO_DEGREE(rotation), false, ime_get_main_window());
639 static void show_cbhm()
645 ret = cbhm_selection_type_set(cbhm_handle, static_cast<cbhm_sel_type_e>(cbhm_sel_type));
647 ret = cbhm_selection_type_set(cbhm_handle, CBHM_SEL_TYPE_TEXT);
649 if (ret != CBHM_ERROR_NONE)
650 LOGW("Failed to set selection type in cbhm. error : %d\n", ret);
652 ret = cbhm_show(cbhm_handle);
653 if (ret != CBHM_ERROR_NONE)
654 LOGW("cbhm show error : %d\n", ret);
660 SCLEventReturnType CUIEventCallback::on_event_notification(SCLUINotiType noti_type, SclNotiDesc *etc_info)
662 SCLEventReturnType ret = SCL_EVENT_PASS_ON;
663 LOGD("noti type: %d, g_need_send_shift_event: %d\n", noti_type, g_need_send_shift_event);
665 if (noti_type == SCL_UINOTITYPE_SHIFT_STATE_CHANGE) {
666 if (g_need_send_shift_event) {
667 const sclchar *cur_lang = _language_manager.get_current_language();
669 LANGUAGE_INFO *info = _language_manager.get_language_info(cur_lang);
670 SclNotiShiftStateChangeDesc *desc = static_cast<SclNotiShiftStateChangeDesc*>(etc_info);
672 if (info->accepts_caps_mode) {
673 LOGD("shift state: %d\n", desc->shift_state);
674 if (desc->shift_state == SCL_SHIFT_STATE_OFF) {
675 ise_send_event(MVK_Shift_Off, KEY_MASK_NULL);
676 } else if (desc->shift_state == SCL_SHIFT_STATE_ON) {
677 ise_send_event(MVK_Shift_On, KEY_MASK_NULL);
678 } else if (desc->shift_state == SCL_SHIFT_STATE_LOCK) {
679 ise_send_event(MVK_Shift_Lock, KEY_MASK_NULL);
681 ret = SCL_EVENT_PASS_ON;
685 g_need_send_shift_event = FALSE;
687 } else if (noti_type == SCL_UINOTITYPE_POPUP_OPENING) {
688 vector<string>::reverse_iterator iter = g_recent_used_punctuation.rbegin();
690 for (; iter != g_recent_used_punctuation.rend(); ++iter)
693 g_ui->set_string_substitution(g_current_punctuation[punc_pos].c_str(), iter->c_str());
696 SclNotiPopupOpeningDesc *openingDesc = (SclNotiPopupOpeningDesc *)etc_info;
697 if (g_ui && 0 == strcmp(openingDesc->input_mode, "CM_POPUP")) {
698 if (ise_is_emoticons_disabled())
699 g_ui->enable_button("EMOTICON_KEY", false);
701 g_ui->enable_button("EMOTICON_KEY", true);
703 } else if (noti_type == SCL_UINOTITYPE_POPUP_OPENED) {
704 g_popup_opened = TRUE;
705 SclNotiPopupOpenedDesc *openedDesc = (SclNotiPopupOpenedDesc *)etc_info;
706 if (0 == strcmp(openedDesc->input_mode, "PUNCTUATION_POPUP")) {
707 g_punctuation_popup_opened = TRUE;
708 } else if (0 == strcmp(openedDesc->input_mode, "CM_POPUP")) {
709 _cm_popup_opened = TRUE;
711 } else if (noti_type == SCL_UINOTITYPE_POPUP_CLOSED) {
712 g_popup_opened = FALSE;
713 SclNotiPopupClosedDesc *closedDesc = (SclNotiPopupClosedDesc *)etc_info;
714 if (closedDesc && closedDesc->input_mode) {
715 if (0 == strcmp(closedDesc->input_mode, "PUNCTUATION_POPUP")) {
716 g_punctuation_popup_opened = FALSE;
717 } else if (0 == strcmp(closedDesc->input_mode, "CM_POPUP")) {
718 _cm_popup_opened = FALSE;
721 } else if (noti_type == SCL_UINOTITYPE_INPUT_MODE_CHANGE) {
722 SclNotiInputModeChangeDesc *desc = static_cast<SclNotiInputModeChangeDesc*>(etc_info);
724 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_NONE);
726 if (strcmp(g_ui->get_input_mode(), "STT_3X4") == 0 &&
727 strcmp(desc->input_mode, "STT_3X4") != 0) {
730 if (strcmp(g_ui->get_input_mode(), "STT_3X4") != 0 &&
731 strcmp(desc->input_mode, "STT_3X4") == 0) {
732 ise_show_stt_mode(NATIVE_WINDOW_CAST(ime_get_main_window()));
740 void ise_destory_guideline_popup()
742 if (_guide_popup_window != NULL) {
743 evas_object_del(_guide_popup_window);
744 _guide_popup_window = NULL;
748 void _guideline_popup_dismissed_cb(void *data, Evas_Object *obj, void *event_info)
750 evas_object_smart_callback_del(obj, "dismissed", _guideline_popup_dismissed_cb);
751 evas_object_del(obj);
754 if (_guide_popup_window != NULL) {
755 evas_object_del(_guide_popup_window);
756 _guide_popup_window = NULL;
759 g_config_values.first_guideset = TRUE;
760 write_ise_config_values();
763 Evas_Object *open_message_popup(Evas_Object *parentWnd)
765 static Evas_Object *msg_window = NULL;
767 evas_object_del(msg_window);
770 msg_window = elm_win_add(parentWnd, "MCFMessagePopup", ELM_WIN_UTILITY);
773 elm_win_borderless_set(msg_window, EINA_TRUE);
774 elm_win_alpha_set(msg_window, EINA_TRUE);
775 elm_win_title_set(msg_window, "ISF Popup");
776 elm_win_screen_size_get(msg_window, NULL, NULL, &w, &h);
777 elm_win_prop_focus_skip_set(msg_window, TRUE);
778 int rots[4] = {0, 90, 180, 270};
779 elm_win_wm_rotation_available_rotations_set(msg_window, rots, 4);
780 evas_object_resize(msg_window, w, h);
783 int rots[4] = { 0, 90, 180, 270 };
784 elm_win_wm_rotation_available_rotations_set(msg_window, rots, 4);
785 evas_object_show(msg_window);
789 void ise_show_help_popup(sclulong keyEvent)
791 char buf[2048] = {0, };
795 SclRectangle rectangle = {0};
798 g_ui->get_screen_resolution(&scr_w, &scr_h);
800 if (keyEvent == MVK_space) {
801 g_ui->get_button_geometry("SPACE_KEY", &rectangle);
803 g_ui->get_button_geometry("CM_KEY", &rectangle);
807 _guide_popup_window = open_message_popup(NATIVE_WINDOW_CAST(ime_get_main_window()));
809 Elm_Theme *theme = elm_theme_new();
810 elm_theme_ref_set(theme, NULL);
811 elm_theme_extension_add(theme, EDJ_FILE);
813 Evas_Object *ctxpopup = elm_ctxpopup_add(_guide_popup_window);
814 elm_object_theme_set(ctxpopup, theme);
816 int rotation = elm_win_rotation_get(NATIVE_WINDOW_CAST(ime_get_main_window()));
817 if (rotation == 0 || rotation == 180) {
818 elm_object_style_set(ctxpopup, "customised_guideline_popup");
820 elm_object_style_set(ctxpopup, "customised_guideline_popup_landscape");
823 evas_object_smart_callback_add(ctxpopup, "dismissed", _guideline_popup_dismissed_cb, (void *)keyEvent);
824 elm_ctxpopup_direction_priority_set(ctxpopup, ELM_CTXPOPUP_DIRECTION_UP,
825 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
826 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
827 ELM_CTXPOPUP_DIRECTION_UNKNOWN);
829 Evas_Object* text = elm_label_add(ctxpopup);
831 if (keyEvent == MVK_space) {
832 snprintf(buf, sizeof(buf), "<font_style=Regular font_size=%d align=left wrap=mixed color=#000000>%s</>", font_size,
833 dgettext(PACKAGE, "IDS_IME_BODY_SWIPE_THE_SPACE_BAR_LEFT_OR_RIGHT_TO_CHANGE_BETWEEN_LANGUAGES"));
835 snprintf(buf, sizeof(buf), "<font_style=Regular font_size=%d align=left wrap=mixed color=#000000>%s</>", font_size,
836 dgettext(PACKAGE, "IDS_IME_BODY_TAP_AND_HOLD_THIS_KEY_TO_SEE_THE_SYMBOL_LIST_SELECT_ONE_TO_USE_IT_AS_A_SHORTCUT"));
838 elm_object_text_set(text, buf);
839 elm_object_content_set(ctxpopup, text);
840 Evas_Coord x, y, w, h;
841 evas_object_geometry_get(NATIVE_WINDOW_CAST(ime_get_main_window()), &x, &y, &w, &h);
843 if (rotation == 0 || rotation == 180) {
844 elm_label_wrap_width_set(text, (scr_w * 4) / 5);
845 evas_object_size_hint_min_set(ctxpopup, ELM_SCALE_SIZE(scr_w), ELM_SCALE_SIZE(50));
846 evas_object_size_hint_max_set(ctxpopup, ELM_SCALE_SIZE(scr_w), ELM_SCALE_SIZE(600));
847 evas_object_move(ctxpopup, rectangle.x + rectangle.width / 2,
848 (scr_h - h) + rectangle.y - ELM_SCALE_SIZE(5));
850 elm_label_wrap_width_set(text, (scr_h * 4) / 5);
851 evas_object_size_hint_min_set(ctxpopup, ELM_SCALE_SIZE(scr_h), ELM_SCALE_SIZE(50));
852 evas_object_size_hint_max_set(ctxpopup, ELM_SCALE_SIZE(scr_h), ELM_SCALE_SIZE(600));
853 evas_object_move(ctxpopup, rectangle.x + rectangle.width / 2,
854 (scr_w - h)+ rectangle.y - ELM_SCALE_SIZE(5));
856 elm_label_line_wrap_set(text, ELM_WRAP_MIXED);
857 evas_object_show(text);
859 evas_object_layer_set(_guide_popup_window, EVAS_LAYER_MAX);
860 evas_object_show(_guide_popup_window);
861 evas_object_layer_set(ctxpopup, EVAS_LAYER_MAX);
862 evas_object_show(ctxpopup);
865 SCLEventReturnType CUIEventCallback::on_event_drag_state_changed(SclUIEventDesc event_desc)
867 if (event_desc.event_type == EVENT_TYPE_MOVE) {
868 if (event_desc.key_event == MVK_space) {
869 SclRectangle rectangle = {0};
870 g_ui->get_button_geometry("SPACE_KEY", &rectangle);
871 ise_show_space_flick_language_change_popup(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
873 } else if (event_desc.event_type == EVENT_TYPE_RELEASE) {
874 if (event_desc.key_event == MVK_space) {
875 ise_destroy_space_flick_language_change_popup();
879 ime_set_floating_drag_end();
880 } else if (event_desc.event_type == EVENT_TYPE_PRESS) {
882 if ((!g_config_values.first_guideset) && (event_desc.key_type == KEY_TYPE_MODECHANGE)) {
883 ise_show_help_popup(event_desc.key_event);
884 return SCL_EVENT_PASS_ON;
887 if (g_floating_mode && event_desc.mouse_current_point.y <= FLOATING_TITLE_BAR_HEIGHT
888 && event_desc.mouse_current_point.y >= 0)
889 ime_set_floating_drag_start();
891 return SCL_EVENT_PASS_ON;
894 static void launch_option()
896 app_control_h app_control;
897 int ret = app_control_create(&app_control);
898 if (ret != APP_CONTROL_ERROR_NONE) {
899 LOGW("app_control_create returned %d\n", ret);
903 ret = app_control_set_operation(app_control, APP_CONTROL_OPERATION_DEFAULT);
904 if (ret != APP_CONTROL_ERROR_NONE) {
905 LOGW("app_control_set_operation returned %d\n", ret);
909 ret = app_control_set_app_id(app_control, "org.tizen.ise-default-setting");
910 if (ret != APP_CONTROL_ERROR_NONE) {
911 LOGW("app_control_set_app_id returned %d\n", ret);
915 ret = app_control_send_launch_request(app_control, NULL, NULL);
916 if (ret != APP_CONTROL_ERROR_NONE) {
922 app_control_destroy(app_control);
925 SCLEventReturnType CUIEventCallback::on_event_key_clicked(SclUIEventDesc event_desc)
927 SCLEventReturnType ret = SCL_EVENT_PASS_ON;
929 if (event_desc.key_modifier == KEY_MODIFIER_MULTITAP_START) {
930 if (!g_keyboard_state.multitap_value.empty()) {
931 ise_send_string(g_keyboard_state.multitap_value.c_str());
933 ise_update_preedit_string(event_desc.key_value);
934 g_keyboard_state.multitap_value = event_desc.key_value;
935 } else if (event_desc.key_modifier == KEY_MODIFIER_MULTITAP_REPEAT) {
936 ise_update_preedit_string(event_desc.key_value);
937 g_keyboard_state.multitap_value = event_desc.key_value;
939 _reset_multitap_state();
941 g_keyboard_state.prev_modifier = event_desc.key_modifier;
944 switch (event_desc.key_type) {
945 case KEY_TYPE_STRING: {
946 if (event_desc.key_modifier != KEY_MODIFIER_MULTITAP_START &&
947 event_desc.key_modifier != KEY_MODIFIER_MULTITAP_REPEAT) {
948 if (event_desc.key_event) {
949 ise_forward_key_event(event_desc.key_event);
951 ise_send_string(event_desc.key_value);
954 if (!g_popup_opened) {
955 const sclchar *input_mode = g_ui->get_input_mode();
956 if (input_mode && ((0 == strcmp(input_mode, "SYM_QTY_1")) || (0 == strcmp(input_mode, "SYM_QTY_2")))) {
957 update_recent_used_punctuation(event_desc.key_value);
959 } else if (g_punctuation_popup_opened) {
960 update_recent_used_punctuation(event_desc.key_value);
964 case KEY_TYPE_CHAR: {
965 sclboolean need_forward = FALSE;
966 // FIXME : Should decide when to forward key events
967 const sclchar *input_mode = g_ui->get_input_mode();
969 if (strcmp(input_mode, "SYM_QTY_1") == 0 ||
970 strcmp(input_mode, "SYM_QTY_2") == 0 ||
971 strcmp(input_mode, "PHONE_3X4") == 0 ||
972 strcmp(input_mode, "IPv6_3X4_123") == 0 ||
973 strcmp(input_mode, "IPv6_3X4_ABC") == 0 ||
974 strcmp(input_mode, "NUMONLY_3X4") == 0 ||
975 strcmp(input_mode, "NUMONLY_3X4_SIG") == 0 ||
976 strcmp(input_mode, "NUMONLY_3X4_DEC") == 0 ||
977 strcmp(input_mode, "NUMONLY_3X4_SIGDEC") == 0 ||
978 strcmp(input_mode, "DATETIME_3X4") == 0) {
982 if (input_mode && strcmp (input_mode, "NUMONLY_3X4_SIGDEC") == 0 &&
983 strcmp(event_desc.key_value, ".") == 0) {
984 ime_update_preedit_string(_sig_dec[_click_count%SIG_DEC_SIZE], NULL);
985 ime_show_preedit_string();
986 delete_commit_timer();
987 _commit_timer = ecore_timer_add(1.0, commit_timeout, NULL);
989 } else if (event_desc.key_event) {
990 commit_timeout(NULL);
992 ise_forward_key_event(event_desc.key_event);
994 if (_cm_popup_opened) {
995 static sclchar current_cm_symbol[2] = {'\0'};
996 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
997 const_cast<sclchar*>(" "),
998 const_cast<sclchar*>(" "),
999 const_cast<sclchar*>(" ")};
1000 if (event_desc.key_value) {
1001 current_cm_symbol[0] = event_desc.key_value[0];
1002 current_cm_symbol[1] = '\0';
1004 g_ui->set_private_key("CM_KEY",
1005 const_cast<sclchar*>(current_cm_symbol),
1006 imagelabel, NULL, 0,
1007 const_cast<sclchar*>(current_cm_symbol), TRUE);
1009 _cm_popup_opened = FALSE;
1010 _current_cm_key_id = -1;
1015 *change the keyboard mode of GLM from QWERTY to KEYPAD
1016 *ensure the Number keypad won't be affected
1019 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_NUMBER) {
1020 ime_send_key_event(IME_KEY_Print, IME_KEY_MASK_CONTROL, false);
1022 ime_send_key_event(IME_KEY_Select, IME_KEY_MASK_CONTROL, false);
1025 ise_send_event(event_desc.key_event, KEY_MASK_NULL);
1029 if ((strcmp(input_mode, "SYM_QTY_1") == 0) || (0 == strcmp(input_mode, "SYM_QTY_2"))) {
1030 update_recent_used_punctuation(event_desc.key_value);
1035 case KEY_TYPE_CONTROL: {
1036 commit_timeout(NULL);
1038 const char *long_shift = "LongShift";
1039 const char *caps_lock = "CapsLock";
1040 const char *delete_all = "DeleteAll";
1041 const char *hide_panel = "Hide";
1042 if (strncmp(event_desc.key_value, long_shift, strlen(long_shift)) == 0) {
1043 LOGD("shift key is longpress\n");
1044 g_ui->set_shift_state(SCL_SHIFT_STATE_ON);
1045 g_need_send_shift_event = TRUE;
1046 //ise_send_event (MVK_Shift_Lock, KEY_MASK_NULL);
1047 } else if (strncmp(event_desc.key_value, caps_lock, strlen(caps_lock)) == 0) {
1048 if (g_ui->get_shift_state() != SCL_SHIFT_STATE_LOCK) {
1049 g_ui->set_shift_state(SCL_SHIFT_STATE_LOCK);
1050 ise_send_event(MVK_Shift_Lock, KEY_MASK_NULL);
1052 g_ui->set_shift_state(SCL_SHIFT_STATE_OFF);
1053 ise_send_event(MVK_Shift_Off, KEY_MASK_NULL);
1055 //g_need_send_shift_event = TRUE;
1056 } else if (strncmp(event_desc.key_value, delete_all, strlen(delete_all)) == 0) {
1057 ime_delete_surrounding_text((INT_MAX / 2) * -1, INT_MAX);
1058 } else if (strncmp(event_desc.key_value, hide_panel, strlen(hide_panel)) == 0) {
1061 } else if (event_desc.key_event) {
1062 ise_send_event(event_desc.key_event, KEY_MASK_NULL);
1063 if (event_desc.key_event == MVK_Shift_L) {
1064 g_need_send_shift_event = TRUE;
1069 case KEY_TYPE_MODECHANGE:
1071 if (!g_config_values.first_guideset) {
1075 if (strcmp(event_desc.key_value, USER_VOICE_LANGUAGE) == 0) {
1076 if (!g_setting_window_open_status) {
1077 ise_hide_stt_mode();
1079 hide_indicator_window();
1081 create_setting_window();
1083 } else if (strcmp(event_desc.key_value, USER_KEYSTRING_VOICE) == 0) {
1084 g_keyboard_state.layout = ISE_LAYOUT_STYLE_VOICE;
1085 g_ui->set_input_mode("STT_3X4");
1087 } else if (strcmp(event_desc.key_value, USER_KEYSTRING_OPTION) == 0) {
1090 ret = SCL_EVENT_DONE;
1091 } else if (strcmp(event_desc.key_value, USER_KEYSTRING_CLIPBOARD) == 0) {
1094 ret = SCL_EVENT_DONE;
1095 } else if (strcmp(event_desc.key_value, USER_KEYSTRING_FLOATING) == 0) {
1096 if (g_floating_mode)
1097 g_config_values.floating_mode = false;
1099 g_config_values.floating_mode = true;
1100 write_ise_config_values();
1102 ret = SCL_EVENT_DONE;
1103 } else if (on_input_mode_changed(event_desc.key_value, event_desc.key_event, event_desc.key_type)) {
1104 ret = SCL_EVENT_DONE;
1106 if (_cm_popup_opened) {
1107 if (strcmp(event_desc.key_value, USER_KEYSTRING_EMOTICON) == 0 ||
1108 strcmp(event_desc.key_value, USER_KEYSTRING_VOICE) == 0 ||
1109 strcmp(event_desc.key_value, USER_KEYSTRING_FLOATING) == 0) {
1110 scluint id = ise_get_cm_key_id(event_desc.key_value);
1111 if (id != _current_cm_key_id) {
1112 _current_cm_key_id = id;
1113 ise_set_cm_private_key(_current_cm_key_id);
1116 _cm_popup_opened = FALSE;
1118 if (strlen(event_desc.key_value) == 1) {
1119 const char allowed_chars_in_modechange[] = {
1120 ',', '?', '!', '`', '~'
1122 const int allowed_chars_in_modechange_num =
1123 sizeof(allowed_chars_in_modechange) / sizeof(char);
1124 for (unsigned int loop = 0;loop < sizeof(allowed_chars_in_modechange_num);loop++) {
1125 if (*(event_desc.key_value) == allowed_chars_in_modechange[loop]) {
1126 ise_send_string(event_desc.key_value);
1132 if (strcmp(event_desc.key_value, USER_KEYSTRING_OPTION) == 0) {
1133 //open_option_window(NULL, ROTATION_TO_DEGREE(g_ui->get_rotation()));
1136 ret = SCL_EVENT_DONE;
1137 } else if (strcmp(event_desc.key_value, USER_KEYSTRING_CLIPBOARD) == 0) {
1139 ret = SCL_EVENT_DONE;
1140 } else if (strcmp(event_desc.key_value, "Cancel") == 0) {
1141 ret = SCL_EVENT_DONE;
1142 if (strcmp(g_ui->get_input_mode(), "STT_3X4") == 0 ) {
1143 g_keyboard_state.need_reset = TRUE;
1144 voice_result_string_flush();
1145 ise_set_layout(g_keyboard_state.layout, g_keyboard_state.layout_variation);
1146 if (g_keyboard_state.visible_state)
1147 ise_show(g_keyboard_state.ic);
1149 ise_send_event(IME_KEY_Cancel, KEY_MASK_NULL);
1151 } else if (strcmp(event_desc.key_value, "Done") == 0) {
1152 ret = SCL_EVENT_DONE;
1153 ise_send_event(IME_KEY_Return, KEY_MASK_NULL);
1156 const sclchar *input_mode = g_ui->get_input_mode();
1157 if ((NULL != input_mode) && (!strcmp(input_mode, "EMOTICON_LAYOUT"))) {
1158 if (is_emoticon_show()) {
1159 ise_destroy_emoticon_layout();
1162 emoticon_group_t group_id = EMOTICON_GROUP_1;
1163 if (current_emoticon_group < EMOTICON_GROUP_3)
1164 group_id = (emoticon_group_t)(current_emoticon_group + 1);
1166 const int BUF_LEN = 16;
1167 char buf[BUF_LEN] = {0};
1168 snprintf(buf, BUF_LEN, "%d/3", group_id);
1169 g_ui->set_private_key("EMOTICON_GROUP_ID", buf, NULL, NULL, 0, const_cast<sclchar*>("EMOTICON_GROUP_NEXT"), TRUE);
1171 emoticon_group_t group_id = ise_get_emoticon_group_id(event_desc.key_value);
1173 if ((group_id >= 0) && (group_id < MAX_EMOTICON_GROUP)) {
1174 SCLRotation rotation = g_ui->get_rotation();
1175 ise_show_emoticon_layout(group_id, ROTATION_TO_DEGREE(rotation), false, ime_get_main_window());
1179 if (_cm_popup_opened) {
1180 if (strcmp(event_desc.key_value, USER_KEYSTRING_OPTION) == 0 ||
1181 strcmp(event_desc.key_value, USER_KEYSTRING_CLIPBOARD) == 0) {
1182 scluint id = ise_get_cm_key_id(event_desc.key_value);
1183 if (id != _current_cm_key_id) {
1184 _current_cm_key_id = id;
1185 ise_set_cm_private_key(_current_cm_key_id);
1188 _cm_popup_opened = FALSE;
1200 ise_set_layout(sclu32 layout, sclu32 layout_variation)
1202 /* Check if the layoutIdx is in the valid range */
1203 if (layout < ISE_LAYOUT_STYLE_MAX) {
1204 if (g_keyboard_state.layout != layout ||
1205 g_keyboard_state.layout_variation != layout_variation) {
1206 g_keyboard_state.need_reset = TRUE;
1208 g_keyboard_state.layout = layout;
1209 g_keyboard_state.layout_variation = layout_variation;
1210 LOGD("layout:%d, variation:%d\n", g_keyboard_state.layout, g_keyboard_state.layout_variation);
1218 _reset_multitap_state(true);
1219 _language_manager.reset_language(g_config_values.selected_language.c_str());
1223 ise_reset_input_context()
1226 _reset_multitap_state(true);
1227 g_keyboard_state.disable_force_latin = FALSE;
1228 _language_manager.reset_language(g_config_values.selected_language.c_str());
1232 ise_focus_in(int ic)
1234 LOGD("ic : %x , %x , g_ic : %x , %x, g_focused_ic : %x , %x\n", ic, check_ic_temporary(ic),
1235 g_keyboard_state.ic, check_ic_temporary(g_keyboard_state.ic),
1236 g_keyboard_state.focused_ic, check_ic_temporary(g_keyboard_state.focused_ic));
1237 if (check_ic_temporary(g_keyboard_state.ic) && !check_ic_temporary(ic)) {
1238 g_keyboard_state.ic = ic;
1240 g_keyboard_state.focused_ic = ic;
1243 static void save_autofill_data()
1248 if (g_autofill_hint == 0)
1251 ime_get_surrounding_text(-1, -1, &text, &cursor);
1252 SECURE_LOGD("surrounding text : %s\n", text);
1255 autofill_save_string((Ecore_IMF_Input_Hints)g_autofill_hint, text);
1261 ise_focus_out(int ic)
1263 g_keyboard_state.focused_ic = 0;
1264 _reset_multitap_state(true);
1266 save_autofill_data();
1269 bool ise_is_guideline_popup_enable_layout(void)
1272 switch (_context_layout)
1274 case ISE_LAYOUT_STYLE_PHONENUMBER:
1275 case ISE_LAYOUT_STYLE_IP:
1276 case ISE_LAYOUT_STYLE_MONTH:
1277 case ISE_LAYOUT_STYLE_NUMBERONLY:
1278 case ISE_LAYOUT_STYLE_HEX:
1279 case ISE_LAYOUT_STYLE_TERMINAL:
1280 case ISE_LAYOUT_STYLE_DATETIME:
1281 case ISE_LAYOUT_STYLE_PASSWORD:
1292 static Eina_Bool popup_guideline_timer_cb(void *data)
1294 if ((!g_config_values.first_guidechange) && (_language_manager.get_enabled_languages_num() > 1)) {
1295 ise_show_help_popup(MVK_space);
1296 g_config_values.first_guidechange = TRUE;
1297 write_ise_config_values();
1300 guideline_timer = NULL;
1301 return ECORE_CALLBACK_CANCEL;
1305 #if EXIT_ISE_ON_HIDE
1306 static Eina_Bool exit_timer_cb(void *data)
1308 if (exit_timer) ecore_timer_del(exit_timer);
1311 return ECORE_CALLBACK_CANCEL;
1318 #if EXIT_ISE_ON_HIDE
1319 if (exit_timer) ecore_timer_del(exit_timer);
1322 sclboolean reset_inputmode = FALSE;
1323 g_input_panel_show = true;
1326 read_ise_config_values();
1328 _language_manager.set_enabled_languages(g_config_values.enabled_languages);
1329 const sclchar *cur_lang = _language_manager.get_current_language();
1332 ise_check_wearable_candidate();
1334 *Clear the personalized data
1336 if (g_config_values.dataclear) {
1337 ime_send_key_event(IME_KEY_Clear, IME_KEY_MASK_CONTROL, false);
1338 g_config_values.dataclear = FALSE;
1341 LOGD("ic : %x , %x , g_ic : %x , %x, g_focused_ic : %x , %x\n", ic, check_ic_temporary(ic),
1342 g_keyboard_state.ic, check_ic_temporary(g_keyboard_state.ic),
1343 g_keyboard_state.focused_ic, check_ic_temporary(g_keyboard_state.focused_ic));
1345 if (check_ic_temporary(ic) && !check_ic_temporary(g_keyboard_state.focused_ic)) {
1346 ic = g_keyboard_state.focused_ic;
1349 if (!check_ic_temporary(ic) && check_ic_temporary(g_keyboard_state.focused_ic)) {
1350 g_keyboard_state.focused_ic = ic;
1353 if (ic == g_keyboard_state.focused_ic) {
1354 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_PHONENUMBER ||
1355 g_keyboard_state.layout == ISE_LAYOUT_STYLE_IP ||
1356 g_keyboard_state.layout == ISE_LAYOUT_STYLE_MONTH ||
1357 g_keyboard_state.layout == ISE_LAYOUT_STYLE_NUMBERONLY) {
1358 ime_set_imengine(DEFAULT_KEYBOARD_ISE_UUID);
1362 /* Reset input mode if the input context value has changed */
1363 if (ic != g_keyboard_state.ic) {
1364 /* Do not reset input mode if STT's setting window was opened */
1365 if (g_setting_window_open_status && strcmp(g_ui->get_input_mode(), "STT_3X4") == 0) {
1366 LOGD("Setting window was opened while using STT, skip resetting input mode");
1368 reset_inputmode = TRUE;
1372 g_keyboard_state.ic = ic;
1373 /* Reset input mode if the current language is not the selected language */
1375 if (g_config_values.selected_language.compare(cur_lang) != 0) {
1376 reset_inputmode = TRUE;
1380 /* No matter what, just reset the inputmode if it needs to */
1381 if (g_keyboard_state.need_reset) {
1382 /* Do not reset input mode if STT's setting window was opened */
1383 if (g_setting_window_open_status && strcmp(g_ui->get_input_mode(), "STT_3X4") == 0) {
1384 LOGD("Setting window was opened while using STT, skip resetting input mode");
1386 reset_inputmode = TRUE;
1389 g_keyboard_state.need_reset = FALSE;
1391 /* If the current layout requires latin language and current our language is not latin, enable the primary latin */
1392 sclboolean force_primary_latin = FALSE;
1393 LANGUAGE_INFO *info = _language_manager.get_language_info(g_config_values.selected_language.c_str());
1395 if (g_ise_default_values[g_keyboard_state.layout].force_latin && !(info->is_latin_language)) {
1396 if (!g_keyboard_state.disable_force_latin) {
1397 force_primary_latin = TRUE;
1401 if (force_primary_latin) {
1402 /* If there is enabled latin-based language, select it */
1403 sclboolean selected = FALSE;
1404 for (scluint loop = 0;!selected && loop < _language_manager.get_languages_num();loop++) {
1405 LANGUAGE_INFO *info = _language_manager.get_language_info(loop);
1407 if (info->enabled && info->is_latin_language) {
1408 selected = _language_manager.select_language(info->name.c_str());
1409 if (selected) force_primary_latin = FALSE;
1414 _language_manager.set_language_enabled_temporarily(PRIMARY_LATIN_LANGUAGE, TRUE);
1418 if (reset_inputmode) {
1419 ise_reset_context();
1421 bool filename_layout = false;
1423 /* Turn the shift state off if we need to reset our input mode, only when auto-capitalization is not set */
1424 if (!(g_keyboard_state.caps_mode)) {
1425 g_ui->set_shift_state(SCL_SHIFT_STATE_OFF);
1427 if (g_keyboard_state.layout < ISE_LAYOUT_STYLE_MAX) {
1428 sclu32 layout_index = g_keyboard_state.layout;
1429 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_NUMBERONLY &&
1430 g_keyboard_state.layout_variation > 0 &&
1431 g_keyboard_state.layout_variation < ISE_LAYOUT_NUMBERONLY_VARIATION_MAX) {
1432 layout_index = ISE_LAYOUT_STYLE_NUMBERONLY_SIG + g_keyboard_state.layout_variation - 1;
1433 } else if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_PASSWORD && g_keyboard_state.layout_variation > 0) {
1434 layout_index = ISE_LAYOUT_STYLE_PASSWD_3X4;
1437 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_NORMAL &&
1438 g_keyboard_state.layout_variation == ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL_VARIATION_FILENAME)
1439 filename_layout = true;
1441 filename_layout = false;
1443 g_ui->enable_button("exclamation", !filename_layout);
1444 g_ui->enable_button("question", !filename_layout);
1445 g_ui->enable_button("divide", !filename_layout);
1446 g_ui->enable_button("multiply", !filename_layout);
1447 g_ui->enable_button("colon", !filename_layout);
1448 g_ui->enable_button("quotation", !filename_layout);
1450 g_ui->enable_button("CM_KEY", !access("/home", X_OK));
1452 LOGD("new layout index : %d\n", layout_index);
1453 /* If this layout requires specific input mode, set it */
1454 if (strlen(g_ise_default_values[layout_index].input_mode) > 0) {
1455 g_ui->set_input_mode(g_ise_default_values[layout_index].input_mode);
1456 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_NONE);
1458 if (force_primary_latin) {
1459 _language_manager.select_language(PRIMARY_LATIN_LANGUAGE, TRUE);
1461 if (!(_language_manager.select_language(g_config_values.selected_language.c_str()))) {
1462 _language_manager.select_language(PRIMARY_LATIN_LANGUAGE);
1466 g_ui->set_cur_sublayout(g_ise_default_values[layout_index].sublayout_name);
1467 if (is_emoticon_show()) {
1468 ise_destroy_emoticon_layout();
1471 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_EMOTICON) {
1472 ise_init_emoticon_list();
1474 current_emoticon_group = EMOTICON_GROUP_1;
1476 if (emoticon_list_recent.size() == 0)
1477 current_emoticon_group = EMOTICON_GROUP_1;
1479 current_emoticon_group = EMOTICON_GROUP_RECENTLY_USED;
1481 SCLRotation rotation = g_ui->get_rotation();
1482 ise_show_emoticon_layout(current_emoticon_group, ROTATION_TO_DEGREE(rotation), false, ime_get_main_window());
1488 if (info->accepts_caps_mode) {
1489 // FIXME this if condition means the AC is off
1490 if (g_keyboard_state.layout != ISE_LAYOUT_STYLE_NORMAL) {
1491 g_ui->set_autocapital_shift_state(TRUE);
1492 g_ui->set_shift_state(SCL_SHIFT_STATE_OFF);
1494 ise_send_event(MVK_Shift_Enable, KEY_MASK_NULL);
1495 // Auto Capital is supported only in normal layout
1496 if (g_keyboard_state.caps_mode) {
1497 g_ui->set_autocapital_shift_state(FALSE);
1501 g_ui->set_autocapital_shift_state(TRUE);
1502 ise_send_event(MVK_Shift_Disable, KEY_MASK_NULL);
1503 g_ui->set_shift_state(SCL_SHIFT_STATE_OFF);
1506 g_ui->set_autocapital_shift_state(TRUE);
1509 // Update CM key button
1510 if (_current_cm_key_id < CM_KEY_LIST_SIZE) {
1511 if (strcmp(_cm_key_list[_current_cm_key_id], USER_KEYSTRING_EMOTICON) == 0) {
1512 if (ise_is_emoticons_disabled())
1513 ise_set_cm_private_key(ise_get_cm_key_id(USER_KEYSTRING_OPTION));
1515 ise_set_cm_private_key(_current_cm_key_id);
1519 // Update space key button
1520 ise_update_space_key();
1523 g_ui->disable_input_events(FALSE);
1525 g_ui->enable_button("CM_KEY", false);
1529 if (ise_is_guideline_popup_enable_layout()) {
1530 guideline_timer = ecore_timer_add(0.1, popup_guideline_timer_cb, NULL);
1535 if (g_config_values.floating_mode != g_floating_mode)
1536 g_floating_mode = g_config_values.floating_mode;
1538 if (g_candidate && g_candidate->get_visible())
1539 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_SHOW);
1541 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_NONE);
1544 g_keyboard_state.visible_state = TRUE;
1548 switch (_context_layout) {
1549 case ISE_LAYOUT_STYLE_PHONENUMBER:
1550 case ISE_LAYOUT_STYLE_IP:
1551 case ISE_LAYOUT_STYLE_MONTH:
1552 case ISE_LAYOUT_STYLE_NUMBERONLY:
1553 case ISE_LAYOUT_STYLE_DATETIME:
1554 case ISE_LAYOUT_STYLE_TERMINAL:
1557 case ISE_LAYOUT_STYLE_EMAIL:
1558 case ISE_LAYOUT_STYLE_URL:
1561 case ISE_LAYOUT_STYLE_PASSWORD:
1562 if (_context_layout == ISE_LAYOUT_STYLE_PASSWORD &&
1563 _context_layout_variation == ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD_VARIATION_NUMBERONLY)
1576 g_ui->get_screen_resolution(&width, &height);
1578 create_indicator_window(width, height);
1579 destroy_indicator_dots();
1582 switch (g_keyboard_state.layout) {
1583 case ISE_LAYOUT_STYLE_NUMBER:
1586 case ISE_LAYOUT_STYLE_HEX:
1589 case ISE_LAYOUT_STYLE_EMOTICON:
1592 case ISE_LAYOUT_STYLE_VOICE:
1593 if (_context_layout == ISE_LAYOUT_STYLE_EMAIL ||
1594 _context_layout == ISE_LAYOUT_STYLE_URL)
1603 create_indicator_dots(dot_num, focus_dot);
1604 show_indicator_window();
1606 hide_indicator_window();
1608 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_NORMAL && g_config_values.number_tutorial_enable) {
1609 ise_show_tutorial_mode_popup(g_keyboard_state.layout);
1610 g_config_values.number_tutorial_enable = false;
1611 write_ise_config_values();
1615 if (g_setting_window_open_status) {
1616 ise_show_stt_mode(NATIVE_WINDOW_CAST(ime_get_main_window()));
1618 g_setting_window_open_status = FALSE;
1620 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_VOICE) {
1621 ise_show_stt_mode(NATIVE_WINDOW_CAST(ime_get_main_window()));
1626 * Sets screen rotation
1629 ise_set_screen_rotation(int degree)
1632 g_ui->set_rotation(DEGREE_TO_SCLROTATION(degree));
1636 g_candidate->rotate(degree);
1637 if (g_softcandidate_show) {
1638 g_candidate->update(g_softcandidate_string);
1644 ise_set_accessibility_state(bool state)
1647 g_ui->enable_tts(state);
1655 /* There's no need to update screen when hiding */
1656 g_ui->set_update_pending(TRUE);
1657 g_ui->disable_input_events(TRUE);
1660 _language_manager.reset_language(g_config_values.selected_language.c_str());
1663 delete_commit_timer();
1664 ise_destory_guideline_popup();
1666 g_keyboard_state.visible_state = FALSE;
1668 _reset_shift_state();
1669 _reset_multitap_state(true);
1671 /* If we were in STT mode, try to reset input mode on our next show event */
1672 if (g_ui && strcmp(g_ui->get_input_mode(), "STT_3X4") == 0 ) {
1673 g_keyboard_state.need_reset = TRUE;
1674 ise_hide_stt_mode();
1677 g_input_panel_show = false;
1678 if (g_softcandidate_show && g_candidate)
1679 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_SHOW);
1681 hide_indicator_window();
1682 if (check_is_tutorial_show()) {
1683 ise_destroy_tutorial_mode_popup();
1686 #if EXIT_ISE_ON_HIDE
1687 if (exit_timer) ecore_timer_del(exit_timer);
1688 exit_timer = ecore_timer_add(1.0, exit_timer_cb, NULL);
1692 static void ise_keypad_mode_changed_cb(const char *key, void *user_data)
1694 read_ise_keypad_mode();
1697 static void ise_enabled_languages_changed_cb(const char *key, void *user_data)
1699 read_ise_enabled_languages();
1702 static void ise_selected_language_changed_cb(const char *key, void *user_data)
1704 read_ise_selected_language();
1707 static void ise_autocapital_mode_changed_cb(const char *key, void *user_data)
1709 read_ise_autocapital_mode();
1712 static void ise_autopunctuate_mode_changed_cb(const char *key, void *user_data)
1714 read_ise_autopunctuation_mode();
1717 static void ise_sound_mode_changed_cb(const char *key, void *user_data)
1719 read_ise_sound_mode();
1721 g_ui->enable_sound(g_config_values.sound_on);
1724 static void ise_vibration_mode_changed_cb(const char *key, void *user_data)
1726 read_ise_vibration_mode();
1728 g_ui->enable_vibration(g_config_values.vibration_on);
1731 static void ise_character_preview_mode_changed_cb(const char *key, void *user_data)
1733 read_ise_character_preview_mode();
1735 g_ui->enable_magnifier(g_config_values.preview_on);
1738 static void ise_setting_guide_popup_changed_cb(const char *key, void *user_data)
1740 read_ise_setting_guide_popup_mode();
1743 static void ise_language_guide_popup_changed_cb(const char *key, void *user_data)
1745 read_ise_language_guide_popup_mode();
1748 static void ise_floating_mode_changed_cb(const char *key, void *user_data)
1750 read_ise_floating_mode();
1751 g_floating_mode = g_config_values.floating_mode;
1753 ime_set_floating_mode(g_floating_mode);
1754 if (g_candidate && g_floating_mode != g_candidate->get_floating_mode()) {
1755 delete_softcandidate_hide_timer();
1759 create_softcandidate();
1760 if (g_candidate && g_candidate->get_visible()) {
1761 g_softcandidate_show = true;
1762 g_candidate->show();
1763 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_SHOW);
1767 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_NONE);
1770 static void register_preference_changed_callback(void)
1772 if (preference_set_changed_cb(ISE_CONFIG_KEYPAD_MODE, ise_keypad_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1773 LOGW("Failed to set ise_keypad_mode_changed_cb()");
1775 if (preference_set_changed_cb(ISE_CONFIG_ENABLED_LANGUAGES, ise_enabled_languages_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1776 LOGW("Failed to set ise_enabled_languages_changed_cb()");
1778 if (preference_set_changed_cb(ISE_CONFIG_SELECTED_LANGUAGE, ise_selected_language_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1779 LOGW("Failed to set ise_selected_language_changed_cb()");
1781 if (preference_set_changed_cb(ISE_CONFIG_AUTO_CAPITALISE, ise_autocapital_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1782 LOGW("Failed to set ise_autocapital_mode_changed_cb()");
1784 if (preference_set_changed_cb(ISE_CONFIG_AUTO_PUNCTUATE, ise_autopunctuate_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1785 LOGW("Failed to set ise_autopunctuate_mode_changed_cb()");
1787 if (preference_set_changed_cb(ISE_CONFIG_SOUND_ON, ise_sound_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1788 LOGW("Failed to set ise_sound_mode_changed_cb()");
1790 if (preference_set_changed_cb(ISE_CONFIG_VIBRATION_ON, ise_vibration_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1791 LOGW("Failed to set ise_vibration_mode_changed_cb()");
1793 if (preference_set_changed_cb(ISE_CONFIG_PREVIEW_ON, ise_character_preview_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1794 LOGW("Failed to set ise_character_preview_mode_changed_cb()");
1796 if (preference_set_changed_cb(ISE_CONFIG_FIRST_GUIDELINE_POPUP_FOR_SETTING, ise_setting_guide_popup_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1797 LOGW("Failed to set ise_setting_guide_popup_changed_cb()");
1799 if (preference_set_changed_cb(ISE_CONFIG_FIRST_GUIDELINE_POPUP_FOR_LANGUAGE_CHANGE, ise_language_guide_popup_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1800 LOGW("Failed to set ise_language_guide_popup_changed_cb()");
1802 if (preference_set_changed_cb(ISE_CONFIG_FLOATING_MODE, ise_floating_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1803 LOGW("Failed to set ise_floating_mode_changed_cb()");
1806 static void ise_mount_changed_cb(void *user_data)
1808 register_preference_changed_callback();
1820 bindtextdomain(PACKAGE, LOCALEDIR);
1821 textdomain(PACKAGE);
1823 /* Set scl_parser_type
1824 * default type is text xml
1825 * use command: export sclres_type="sclres_binary" to enable use binary resource
1826 * please make sure there is sclresource.bin in resource folder
1827 * Or you can use `xml2binary $resource_dir` to generate the sclresource.bin
1828 * xml2binary is in the libscl-ui-devel package
1830 SCLParserType scl_parser_type = SCL_PARSER_TYPE_XML;
1831 char* sclres_type = getenv("sclres_type");
1832 if (sclres_type != NULL && 0 == strcmp("sclres_binary", sclres_type)) {
1833 scl_parser_type = SCL_PARSER_TYPE_BINARY_XML;
1835 scl_parser_type = SCL_PARSER_TYPE_XML;
1839 if (ime_get_main_window()) {
1840 g_ise_created = true;
1842 sclboolean succeeded = FALSE;
1844 const sclchar *entry_path = MAIN_ENTRY_XML_PATH;
1847 CSCLUtils *utils = CSCLUtils::get_instance();
1849 utils->get_screen_resolution(&nwidth, &nheight);
1851 _language_manager.set_resource_file_path(entry_path);
1852 const sclchar *resource_file_path = _language_manager.get_resource_file_path();
1854 if (resource_file_path) {
1855 if (strlen(resource_file_path) > 0) {
1856 succeeded = g_ui->init(ime_get_main_window(), scl_parser_type, resource_file_path);
1860 g_ui->init(ime_get_main_window(), scl_parser_type, MAIN_ENTRY_XML_PATH);
1863 g_ui->set_longkey_duration(elm_config_longpress_timeout_get() * 1000);
1865 /* Default ISE callback */
1866 g_ui->set_ui_event_callback(&callback);
1868 /* Accumulated customized ISE callbacks, depending on the input modes */
1869 for (scluint loop = 0;loop < _language_manager.get_languages_num();loop++) {
1870 LANGUAGE_INFO *language = _language_manager.get_language_info(loop);
1872 for (scluint inner_loop = 0;inner_loop < language->input_modes.size();inner_loop++) {
1873 INPUT_MODE_INFO &info = language->input_modes.at(inner_loop);
1874 LOGD("Registering callback for input mode %s : %p\n", info.name.c_str(), language->callback);
1875 g_ui->set_ui_event_callback(language->callback, info.name.c_str());
1880 read_ise_config_values();
1881 _language_manager.set_enabled_languages(g_config_values.enabled_languages);
1882 _language_manager.select_language(g_config_values.selected_language.c_str());
1883 vconf_set_bool(VCONFKEY_AUTOCAPITAL_ALLOW_BOOL, g_config_values.auto_capitalise);
1884 vconf_set_bool(VCONFKEY_AUTOPERIOD_ALLOW_BOOL, g_config_values.auto_punctuate);
1885 g_ui->enable_sound(g_config_values.sound_on);
1886 g_ui->enable_vibration(g_config_values.vibration_on);
1887 g_ui->enable_magnifier(g_config_values.preview_on);
1889 g_ui->enable_highlight_ui(TRUE);
1891 g_floating_mode = g_config_values.floating_mode;
1892 ime_set_floating_mode(g_floating_mode);
1895 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_NONE);
1899 preference_is_existing(ISE_CONFIG_KEYPAD_MODE, &exist);
1901 write_ise_config_values();
1904 if (ode_internal_encryption_get_state(&state) == ODE_ERROR_NONE) {
1905 if (state == ODE_STATE_ENCRYPTED) {
1906 if (ode_internal_encryption_set_mount_event_cb(ise_mount_changed_cb, NULL) != ODE_ERROR_NONE)
1907 LOGW("Failed to set mount_event_cb()");
1908 } else if (state == ODE_STATE_UNENCRYPTED) {
1909 register_preference_changed_callback();
1912 LOGW("Failed to get encryption_state");
1915 init_recent_used_punctuation();
1921 ise_hide_stt_mode();
1924 LOGD("calling g_ui->fini()\n");
1926 LOGD("deleting g_ui\n");
1937 destroy_indicator_window();
1940 /* This is necessary. If this is not called, 3rd party IME might have auto period input regardless its settings */
1941 vconf_set_bool(VCONFKEY_AUTOPERIOD_ALLOW_BOOL, false);
1943 #if EXIT_ISE_ON_HIDE
1944 if (exit_timer) ecore_timer_del(exit_timer);
1950 ise_app_candidate_show()
1953 if (!g_softcandidate_show) {
1958 delete_softcandidate_hide_timer();
1960 create_softcandidate();
1962 g_softcandidate_show = true;
1964 g_candidate->show();
1965 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_SHOW);
1970 ise_app_candidate_hide()
1974 if (!g_candidate || !g_softcandidate_show) {
1975 LOGD("No candidate\n");
1979 if (g_ic_smartreply != -1 || g_autofill_exist)
1982 add_softcandidate_hide_timer();
1986 void ise_check_wearable_candidate() {
1987 if (!g_config_values.prediction_on) {
1988 ise_app_candidate_hide();
1989 } else if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_PHONENUMBER ||
1990 g_keyboard_state.layout == ISE_LAYOUT_STYLE_VOICE ||
1991 g_keyboard_state.layout == ISE_LAYOUT_STYLE_IP ||
1992 g_keyboard_state.layout == ISE_LAYOUT_STYLE_MONTH ||
1993 g_keyboard_state.layout == ISE_LAYOUT_STYLE_NUMBERONLY ||
1994 g_keyboard_state.layout == ISE_LAYOUT_STYLE_PASSWD_3X4||
1995 g_keyboard_state.layout == ISE_LAYOUT_STYLE_PASSWORD) {
1996 ise_app_candidate_hide();
1998 g_softcandidate_show = true;
1999 ise_app_candidate_show();
2004 // when it is the time to auto_cap, the
2005 // ise_set_caps_mode is called.
2006 // -------------------------------------------------------
2007 // For example: [How are you. Fine.], the
2008 // auto-capital process is as below:
2009 // Note: "["<--this is the beginning,
2010 // "|"<--this is the cursor position
2011 // 1) call ise_set_caps_mode, auto_cap = on
2014 // 2) call ise_set_caps_mode, auto_cap = off
2017 // 3) input: "w are you. "
2018 // result: [How are you. |
2019 // 4) call ise_set_caps_mode, auto_cap = on
2021 // result: [How are you. F
2023 // result: [How are you. Fine.|
2024 // --------------------------------------------------------
2025 // If we want to change the auto_cap, eg,
2026 // if we want to input [How Are you.]
2027 // Note the "Are" is not use auto-capital rule.
2029 // ise_send_event(MVK_Shift_On, SclCoreKeyMask_Null);
2030 // when we are want to input "A"
2031 // following input still has the auto_cap rule.
2033 ise_set_caps_mode(unsigned int mode)
2035 LOGD("caps_mode : %d\n", mode);
2037 g_keyboard_state.caps_mode = TRUE;
2039 g_keyboard_state.caps_mode = FALSE;
2041 g_caps_mode_pending = false;
2042 const sclchar *cur_lang = _language_manager.get_current_language();
2044 LANGUAGE_INFO *info = _language_manager.get_language_info(cur_lang);
2046 if (info->accepts_caps_mode) {
2047 /* If we are inputting multitap character, do not manipulate shift mode */
2048 if (g_keyboard_state.prev_modifier != KEY_MODIFIER_MULTITAP_START &&
2049 g_keyboard_state.prev_modifier != KEY_MODIFIER_MULTITAP_REPEAT) {
2050 set_caps_mode(g_keyboard_state.caps_mode);
2052 g_caps_mode_pending = true;
2053 LOGD("Currently composing multitap string, skipping caps request");
2061 ise_update_cursor_position(int position)
2063 LOGD("cursor position : %d\n", position);
2064 if (g_ui && g_keyboard_state.layout == ISE_LAYOUT_STYLE_URL) {
2067 g_ui->set_string_substitution("www.", ".com");
2069 g_ui->unset_string_substitution("www.");
2075 void ise_set_return_key_type(unsigned int type)
2077 const int BUF_LEN = 256;
2078 char buf[BUF_LEN] = {0};
2082 LOGD("return key type : %d\n", type);
2085 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE:
2086 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_DONE);
2088 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_GO:
2089 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_GO);
2091 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_JOIN:
2092 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_JOIN);
2094 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_LOGIN:
2095 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_LOGIN);
2097 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT:
2098 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_NEXT);
2100 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH:
2101 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_SEARCH);
2103 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEND:
2104 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_SEND);
2106 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SIGNIN:
2107 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_SIGNIN);
2109 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT:
2112 LOGW("Unknown return key type : %d\n", type);
2113 type = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
2117 if (type == ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT) {
2118 g_ui->unset_private_key("Enter");
2121 if (type == ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH) {
2122 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
2123 const_cast<sclchar*>("w_sip_3x4_btn_ic_search.png"),
2124 const_cast<sclchar*>("w_sip_3x4_btn_ic_search_p.png"),
2125 const_cast<sclchar*>("w_sip_3x4_btn_ic_search_d.png")};
2126 g_ui->set_private_key("Enter", const_cast<sclchar*>(""), imagelabel, NULL, 0, const_cast<sclchar*>("Enter"), TRUE);
2131 static sclchar *imagelabel[SCL_BUTTON_STATE_MAX] = {
2132 const_cast<sclchar*>(" "), const_cast<sclchar*>(" "), const_cast<sclchar*>(" ")
2135 g_ui->set_private_key("Enter", buf, imagelabel, NULL, 0, const_cast<sclchar*>("Enter"), TRUE);
2136 LOGD("return key lable : %s\n", buf);
2140 void ise_set_return_key_disable(unsigned int disabled)
2142 LOGD("enable : %d\n", !disabled);
2145 g_ui->enable_button("Done", !disabled);
2148 g_ui->enable_button("Enter", !disabled);
2152 void ise_get_language_locale(char **locale)
2154 LANGUAGE_INFO *info = _language_manager.get_current_language_info();
2156 if (!(info->locale_string.empty())) {
2157 *locale = strdup(info->locale_string.c_str());
2162 void ise_update_table(const vector<string> &vec_str)
2164 if (!g_candidate || !g_softcandidate_show)
2165 create_softcandidate();
2168 g_candidate->update(vec_str);
2172 void ise_process_key_event(scim::KeyEvent& key, sclu32 &ret)
2174 Eina_Bool back_key_pressed = EINA_FALSE;
2175 Eina_Bool back_key_released = EINA_FALSE;
2177 if (key.get_key_string().compare("XF86Back") == 0) {
2178 back_key_pressed = EINA_TRUE;
2179 } else if (key.get_key_string().compare("KeyRelease+XF86Back") == 0) {
2180 back_key_released = EINA_TRUE;
2183 if (back_key_pressed || back_key_released) {
2184 if (g_popup_opened == TRUE) {
2185 if (back_key_released) {
2186 g_ui->close_all_popups();
2196 if (!g_candidate->soft_candidate_flag()) {
2198 if (key.dev_name.compare("ime") != 0) {
2199 ret = (sclu32)g_ui->process_key_event(key.get_key_string().c_str());
2204 ret = g_candidate->soft_candidate_handle_key_event(key.get_key_string().c_str());
2208 /* Process this key event if it was not generated by ime */
2209 if (key.dev_name.compare("ime") != 0) {
2210 ret = (sclu32)g_ui->process_key_event(key.get_key_string().c_str());
2216 /* Process this key event if it was not generated by ime */
2217 if (key.dev_name.compare("ime") != 0) {
2218 ret = (sclu32)g_ui->process_key_event(key.get_key_string().c_str());
2224 static void init_recent_used_punctuation()
2226 if (g_recent_used_punctuation.empty())
2228 g_recent_used_punctuation.push_back("#");
2229 g_recent_used_punctuation.push_back("$");
2230 g_recent_used_punctuation.push_back("%");
2231 g_recent_used_punctuation.push_back("^");
2232 g_recent_used_punctuation.push_back("&");
2236 static void update_recent_used_punctuation(const char * key_value)
2238 if (NULL == key_value)
2242 for (int i = 0; i < 10; ++i)
2245 snprintf(buf, sizeof(buf), "%d", i);
2246 if (strcmp(key_value, buf) == 0)
2251 string strKey = string(key_value);
2252 for (int i = 0; i < MAX_DEFAULT_PUNCTUATION; ++i)
2254 if (0 == strKey.compare(g_default_punctuation[i].c_str()))
2259 vector<string>::iterator iter = g_recent_used_punctuation.begin();
2260 for (; iter != g_recent_used_punctuation.end(); ++iter)
2262 if (0 == strKey.compare(iter->c_str()))
2267 if (iter != g_recent_used_punctuation.end())
2269 g_recent_used_punctuation.erase(iter);
2271 g_recent_used_punctuation.push_back(strKey);
2272 if (g_recent_used_punctuation.size() > MAX_DEFAULT_PUNCTUATION-1)
2274 g_recent_used_punctuation.erase(g_recent_used_punctuation.begin());
2278 static void set_ime_size(bool floating_mode, ISE_CANDIDATE_REQUEST candidate_req)
2283 SclSize size_portrait = g_ui->get_input_mode_size(g_ui->get_input_mode(), DISPLAYMODE_PORTRAIT);
2284 SclSize size_landscape = g_ui->get_input_mode_size(g_ui->get_input_mode(), DISPLAYMODE_LANDSCAPE);
2286 if (floating_mode) {
2287 size_portrait.width *= FLOATING_SCALE_RATE;
2288 size_portrait.height *= FLOATING_SCALE_RATE;
2289 size_landscape.width *= FLOATING_SCALE_RATE;
2290 size_landscape.height *= FLOATING_SCALE_RATE;
2291 switch (candidate_req) {
2292 case ISE_CANDIDATE_REQ_NONE:
2293 if (g_candidate && g_candidate->get_visible()) {
2294 g_ui->set_custom_starting_coordinates(0, FLOATING_TITLE_BAR_HEIGHT + g_candidate->get_height());
2295 size_portrait.height += g_candidate->get_height();
2296 size_landscape.height += g_candidate->get_height();
2298 g_ui->set_custom_starting_coordinates(0, FLOATING_TITLE_BAR_HEIGHT);
2301 case ISE_CANDIDATE_REQ_SHOW:
2302 g_ui->set_custom_starting_coordinates(0, FLOATING_TITLE_BAR_HEIGHT + g_candidate->get_height());
2303 if (g_input_panel_show || g_candidate_more_view) {
2304 size_portrait.height += g_candidate->get_height();
2305 size_landscape.height += g_candidate->get_height();
2307 size_portrait.height = g_candidate->get_height();
2308 size_landscape.height = g_candidate->get_height();
2311 case ISE_CANDIDATE_REQ_HIDE:
2312 g_ui->set_custom_starting_coordinates(0, FLOATING_TITLE_BAR_HEIGHT);
2317 if (g_ui->get_custom_scale_rate_x() != FLOATING_SCALE_RATE || g_ui->get_custom_scale_rate_y() != FLOATING_SCALE_RATE)
2318 g_ui->set_custom_scale_rate(FLOATING_SCALE_RATE, FLOATING_SCALE_RATE);
2320 ime_set_size(size_portrait.width, size_portrait.height + FLOATING_TITLE_BAR_HEIGHT,
2321 size_landscape.width, size_landscape.height + FLOATING_TITLE_BAR_HEIGHT);
2324 ise_destroy_move_handler();
2325 int rotation = elm_win_rotation_get(NATIVE_WINDOW_CAST(ime_get_main_window()));
2326 int handler_width = (rotation == 0 || rotation == 180) ? size_portrait.width : size_landscape.width;
2327 ise_show_move_handler(handler_width, FLOATING_TITLE_BAR_HEIGHT);
2330 switch (candidate_req) {
2331 case ISE_CANDIDATE_REQ_NONE:
2332 if (g_candidate && g_candidate->get_visible()) {
2333 g_ui->set_custom_starting_coordinates(0, g_candidate->get_height());
2334 size_portrait.height += g_candidate->get_height();
2335 size_landscape.height += g_candidate->get_height();
2337 g_ui->set_custom_starting_coordinates(0, 0);
2340 case ISE_CANDIDATE_REQ_SHOW:
2341 g_ui->set_custom_starting_coordinates(0, g_candidate->get_height());
2342 if (g_input_panel_show || g_candidate_more_view) {
2343 size_portrait.height += g_candidate->get_height();
2344 size_landscape.height += g_candidate->get_height();
2346 size_portrait.height = g_candidate->get_height();
2347 size_landscape.height = g_candidate->get_height();
2350 case ISE_CANDIDATE_REQ_HIDE:
2351 g_ui->set_custom_starting_coordinates(0, 0);
2356 if (g_ui->get_custom_scale_rate_x() != 1.0 || g_ui->get_custom_scale_rate_y() != 1.0)
2357 g_ui->set_custom_scale_rate(1.0, 1.0);
2359 ime_set_size(size_portrait.width, size_portrait.height, size_landscape.width, size_landscape.height);
2362 ise_destroy_move_handler();
2367 static void ime_app_create_cb(void *user_data)
2369 #if !(DEFER_ISE_CREATION)
2372 elm_app_name_set(PACKAGE);
2375 cbhm_open_service(&cbhm_handle);
2379 static void ime_app_exit_cb(void *user_data)
2385 cbhm_close_service(cbhm_handle);
2390 static void show_autofill_data(Ecore_IMF_Input_Hints input_hints)
2392 g_autofill_exist = false;
2393 char *text = autofill_get_string(input_hints);
2396 g_autofill_string = string(text);
2399 g_autofill_string = string("");
2401 SECURE_LOGD("autofill string : %s", g_autofill_string.c_str());
2403 if (g_autofill_string.length() > 0) {
2404 g_autofill_exist = true;
2406 ise_app_candidate_show();
2407 update_candidate_table();
2411 static void ime_app_show_cb(int ic, ime_context_h ime_ctx, void *user_data)
2413 Ise_Context iseContext;
2414 bool return_key_state, prediction_allow, password_mode, caps_mode;
2415 ime_layout_variation_e layout_variation;
2420 ime_context_get_layout(ime_ctx, &iseContext.layout);
2422 ime_context_get_layout_variation(ime_ctx, &layout_variation);
2423 iseContext.layout_variation = (int)layout_variation;
2425 ime_context_get_cursor_position(ime_ctx, &iseContext.cursor_pos);
2426 ime_context_get_autocapital_type(ime_ctx, &iseContext.autocapital_type);
2427 ime_context_get_return_key_type(ime_ctx, &iseContext.return_key_type);
2428 ime_context_get_return_key_state(ime_ctx, &return_key_state);
2430 ime_context_get_prediction_mode(ime_ctx, &prediction_allow);
2431 iseContext.prediction_allow = prediction_allow;
2433 ime_context_get_password_mode(ime_ctx, &password_mode);
2434 iseContext.password_mode = password_mode;
2436 ime_context_get_input_hint(ime_ctx, &iseContext.input_hint);
2437 ime_context_get_bidi_direction(ime_ctx, &iseContext.bidi_direction);
2438 ime_context_get_language(ime_ctx, &iseContext.language);
2439 ime_context_get_caps_mode(ime_ctx, &caps_mode);
2440 iseContext.caps_mode = caps_mode;
2442 iseContext.return_key_disabled = return_key_state;
2446 g_autofill_hint = iseContext.input_hint & ECORE_IMF_INPUT_HINT_AUTOFILL_MASK;
2448 LOGD("input hint : %x, autofill hint : %x\n", iseContext.input_hint, g_autofill_hint);
2450 if (g_autofill_hint == 0) {
2451 switch (iseContext.layout) {
2452 case ECORE_IMF_INPUT_PANEL_LAYOUT_EMAIL:
2453 g_autofill_hint = ECORE_IMF_INPUT_HINT_AUTOFILL_EMAIL_ADDRESS;
2455 case ECORE_IMF_INPUT_PANEL_LAYOUT_PHONENUMBER:
2456 g_autofill_hint = ECORE_IMF_INPUT_HINT_AUTOFILL_PHONE;
2463 // show autofill data
2464 show_autofill_data((Ecore_IMF_Input_Hints)g_autofill_hint);
2466 //g_ise_common->set_keyboard_ise_by_uuid(KEYBD_ISE_UUID);
2468 /* Don't update screen until all the information is correctly set */
2470 g_ui->set_update_pending(TRUE);
2472 ise_reset_context(); // reset ISE
2474 /*if (context.language == ECORE_IMF_INPUT_PANEL_LANG_ALPHABET) {
2475 ise_explictly_set_language(PRIMARY_LATIN_LANGUAGE_INDEX);
2478 _context_layout = iseContext.layout;
2479 _context_layout_variation = iseContext.layout_variation;
2480 ise_set_layout(iseContext.layout, iseContext.layout_variation);
2482 ise_set_return_key_type(iseContext.return_key_type);
2483 ise_set_return_key_disable(iseContext.return_key_disabled);
2485 ise_set_caps_mode(iseContext.caps_mode);
2486 ise_update_cursor_position(iseContext.cursor_pos);
2490 /* Now we update the whole screen */
2492 g_ui->set_update_pending(FALSE);
2495 static void ime_app_hide_cb(int ic, void *user_data)
2500 g_set_mime_type = FALSE;
2502 g_ic_smartreply = -1;
2505 static void ime_app_return_key_type_set_cb(Ecore_IMF_Input_Panel_Return_Key_Type type, void *user_data)
2507 LOGD("return key type : %d\n", type);
2508 ise_set_return_key_type(type);
2510 if (g_keyboard_state.visible_state)
2511 ise_show(g_keyboard_state.ic);
2514 static void ime_app_return_key_state_set_cb(bool disabled, void *user_data)
2516 LOGD("return key disabled : %d\n", disabled);
2517 ise_set_return_key_disable(disabled);
2520 static void ime_app_input_context_reset_cb(void *user_data)
2522 ise_reset_input_context();
2525 static void ime_app_cursor_position_updated_cb(int cursor_pos, void *user_data)
2527 LOGD("cursor position : %d\n", cursor_pos);
2528 ise_update_cursor_position(cursor_pos);
2531 static void ime_app_language_requested_cb(void *user_data, char **lang_code)
2533 ise_get_language_locale(lang_code);
2536 static void ime_app_surrounding_text_updated_cb(int context_id, const char *text, int cursor_pos, void *user_data)
2538 SECURE_LOGD("surrounding text:%s, cursor=%d\n", text, cursor_pos);
2539 ime_delete_surrounding_text(-cursor_pos, strlen(text));
2542 static void ime_app_focus_in_cb(int context_id, void *user_data)
2545 ise_focus_in(context_id);
2546 if (!g_smartreply_reply_exist && g_softcandidate_show) {
2548 ise_app_candidate_hide();
2549 g_candidate->hide();
2554 static void ime_app_focus_out_cb(int context_id, void *user_data)
2557 ise_focus_out(context_id);
2560 g_set_mime_type = FALSE;
2562 g_smartreply_reply_exist = false;
2563 g_smartreply_size = 0;
2564 input_smartreply_deinit();
2565 g_ic_smartreply = -1;
2567 g_autofill_exist = false;
2568 g_autofill_hint = 0;
2570 g_app_id = string("");
2571 g_resource_id = string("");
2573 g_autofill_string = string("");
2574 g_smartreply_strings.clear();
2575 g_lookup_table_strings.clear();
2576 g_softcandidate_string.clear();
2579 static void ime_app_layout_set_cb(Ecore_IMF_Input_Panel_Layout layout, void *user_data)
2581 LOGD("layout=%d\n", layout);
2582 /* Check if the layoutIdx is in the valid range */
2583 if ((ISE_LAYOUT)layout < ISE_LAYOUT_STYLE_MAX) {
2584 if (g_keyboard_state.layout != layout) {
2585 g_keyboard_state.need_reset = TRUE;
2587 g_keyboard_state.layout = layout;
2588 _context_layout = layout;
2589 _context_layout_variation = 0;
2591 if (g_keyboard_state.visible_state)
2592 ise_show(g_keyboard_state.ic);
2595 static void ime_app_rotation_degree_changed_cb(int degree, void *user_data)
2597 ise_set_screen_rotation(degree);
2599 LOGD("degree=%d\n", degree);
2601 if (g_floating_mode) {
2603 ise_destroy_move_handler();
2604 if (degree == 0 || degree == 180) {
2605 SclSize size_portrait = g_ui->get_input_mode_size(g_ui->get_input_mode(), DISPLAYMODE_PORTRAIT);
2606 handler_width = size_portrait.width * FLOATING_SCALE_RATE;
2608 SclSize size_landscape = g_ui->get_input_mode_size(g_ui->get_input_mode(), DISPLAYMODE_LANDSCAPE);
2609 handler_width = size_landscape.width * FLOATING_SCALE_RATE;
2611 ise_show_move_handler(handler_width, FLOATING_TITLE_BAR_HEIGHT);
2614 if (is_emoticon_show()) {
2615 ise_destroy_emoticon_layout();
2617 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_VOICE) {
2618 ise_hide_stt_mode();
2620 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_EMOTICON) {
2621 ise_show_emoticon_layout(current_emoticon_group, degree, false, ime_get_main_window());
2623 const sclchar *input_mode = g_ui->get_input_mode();
2625 if (!(strcmp(input_mode, "EMOTICON_LAYOUT")))
2626 ise_show_emoticon_layout(current_emoticon_group, degree, false, ime_get_main_window());
2627 else if (!(strcmp(input_mode, "STT_3X4")))
2628 ise_show_stt_mode(NATIVE_WINDOW_CAST(ime_get_main_window()));
2633 static void ime_app_accessibility_state_changed_cb(bool state, void *user_data)
2635 LOGD("state=%d\n", state);
2636 ise_set_accessibility_state(state);
2639 static void ime_app_imdata_set_cb(void *data, unsigned int data_length, void *user_data)
2643 size_t _len = data_length;
2644 set_ise_imdata((sclchar *)data, _len);
2647 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)
2649 scim::KeyEvent key(keycode, keymask);
2651 char *dev_name = NULL;
2652 Ecore_IMF_Device_Class dev_class;
2653 Ecore_IMF_Device_Subclass dev_subclass;
2655 if (ime_device_info_get_name(dev_info, &dev_name) == IME_ERROR_NONE) {
2656 key.dev_name = dev_name;
2659 if (ime_device_info_get_class(dev_info, &dev_class) == IME_ERROR_NONE) {
2660 key.dev_class = dev_class;
2663 if (ime_device_info_get_subclass(dev_info, &dev_subclass) == IME_ERROR_NONE) {
2664 key.dev_subclass = dev_subclass;
2667 if (g_keyboard_state.visible_state)
2668 ise_process_key_event(key, ret);
2678 static void ime_app_caps_mode_changed_cb(int mode, void *user_data)
2680 ise_set_caps_mode(mode);
2683 static void ime_app_candidate_show_cb(int context_id, void *user_data)
2686 ise_check_wearable_candidate();
2688 ise_app_candidate_show();
2692 static void ime_app_candidate_hide_cb(int context_id, void *user_data)
2695 ise_check_wearable_candidate();
2697 ise_app_candidate_hide();
2701 static void ime_app_lookup_table_changed_cb(Eina_List *list, void *user_data)
2703 vector<string> candidate_strings;
2708 g_lookup_table_strings.clear();
2711 EINA_LIST_FOREACH(list, l, data) {
2712 candidate = (char *)data;
2714 g_lookup_table_strings.push_back(string(candidate));
2715 candidate_strings.push_back(string(candidate));
2720 if (g_smartreply_reply_exist) {
2721 if (candidate_strings[0] == "#" && candidate_strings[1] == "$") {
2724 ime_get_surrounding_text(0, 0, &text, &cursor);
2733 update_candidate_table();
2737 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)
2739 if (device_type == IME_INPUT_DEVICE_TYPE_ROTARY) {
2740 ime_input_device_rotary_direction_e direction;
2741 if (IME_ERROR_NONE == ime_input_device_rotary_get_direction(device_event, &direction)) {
2742 sclu32 new_layout = g_keyboard_state.layout;
2743 if (direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_CLOCKWISE) {
2744 LOGD("CLOCKWISE\n");
2745 switch (g_keyboard_state.layout) {
2746 case ISE_LAYOUT_STYLE_NORMAL:
2747 case ISE_LAYOUT_STYLE_EMAIL:
2748 case ISE_LAYOUT_STYLE_URL:
2749 case ISE_LAYOUT_STYLE_PASSWORD:
2750 if (_context_layout == ISE_LAYOUT_STYLE_PASSWORD &&
2751 _context_layout_variation == ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD_VARIATION_NUMBERONLY)
2752 ; // PASSWORD NUMBER ONLY, do nothing
2754 new_layout = ISE_LAYOUT_STYLE_NUMBER;
2756 case ISE_LAYOUT_STYLE_NUMBER:
2757 new_layout = ISE_LAYOUT_STYLE_HEX;
2759 case ISE_LAYOUT_STYLE_HEX:
2760 if (_context_layout == ISE_LAYOUT_STYLE_EMAIL ||
2761 _context_layout == ISE_LAYOUT_STYLE_URL)
2762 new_layout = ISE_LAYOUT_STYLE_VOICE;
2763 else if (_context_layout == ISE_LAYOUT_STYLE_PASSWORD)
2764 new_layout = _context_layout;
2766 new_layout = ISE_LAYOUT_STYLE_EMOTICON;
2768 case ISE_LAYOUT_STYLE_EMOTICON:
2769 if (_context_layout == ISE_LAYOUT_STYLE_EMAIL ||
2770 _context_layout == ISE_LAYOUT_STYLE_URL ||
2771 _context_layout == ISE_LAYOUT_STYLE_PASSWORD)
2772 new_layout = _context_layout;
2774 new_layout = ISE_LAYOUT_STYLE_VOICE;
2776 case ISE_LAYOUT_STYLE_VOICE:
2777 new_layout = ISE_LAYOUT_STYLE_NORMAL;
2782 } else if (direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_COUNTER_CLOCKWISE) {
2783 LOGD("COUNTER_CLOCKWISE\n");
2784 switch (g_keyboard_state.layout) {
2785 case ISE_LAYOUT_STYLE_NORMAL:
2786 case ISE_LAYOUT_STYLE_EMAIL:
2787 case ISE_LAYOUT_STYLE_URL:
2788 case ISE_LAYOUT_STYLE_PASSWORD:
2789 if (_context_layout == ISE_LAYOUT_STYLE_PASSWORD &&
2790 _context_layout_variation == ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD_VARIATION_NUMBERONLY)
2791 ; // PASSWORD NUMBER ONLY, do nothing
2792 else if (_context_layout == ISE_LAYOUT_STYLE_PASSWORD)
2793 new_layout = ISE_LAYOUT_STYLE_HEX;
2795 new_layout = ISE_LAYOUT_STYLE_VOICE;
2797 case ISE_LAYOUT_STYLE_NUMBER:
2798 if (_context_layout == ISE_LAYOUT_STYLE_EMAIL ||
2799 _context_layout == ISE_LAYOUT_STYLE_URL ||
2800 _context_layout == ISE_LAYOUT_STYLE_PASSWORD)
2801 new_layout = _context_layout;
2803 new_layout = ISE_LAYOUT_STYLE_NORMAL;
2805 case ISE_LAYOUT_STYLE_HEX:
2806 new_layout = ISE_LAYOUT_STYLE_NUMBER;
2808 case ISE_LAYOUT_STYLE_EMOTICON:
2809 new_layout = ISE_LAYOUT_STYLE_HEX;
2811 case ISE_LAYOUT_STYLE_VOICE:
2812 if (_context_layout == ISE_LAYOUT_STYLE_EMAIL ||
2813 _context_layout == ISE_LAYOUT_STYLE_URL)
2814 new_layout = ISE_LAYOUT_STYLE_HEX;
2816 new_layout = ISE_LAYOUT_STYLE_EMOTICON;
2823 if (check_is_tutorial_show()) {
2824 read_ise_config_values();
2825 if ((direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_COUNTER_CLOCKWISE && !g_config_values.number_tutorial_enable && !g_config_values.symbol_tutorial_enable) ||
2826 (direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_CLOCKWISE && g_config_values.symbol_tutorial_enable)) {
2827 new_layout = g_keyboard_state.layout;
2828 } else if (direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_COUNTER_CLOCKWISE && g_config_values.symbol_tutorial_enable) {
2829 ise_destroy_tutorial_mode_popup();
2830 g_config_values.symbol_tutorial_enable = false;
2831 write_ise_config_values();
2832 } else if (direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_CLOCKWISE && !g_config_values.number_tutorial_enable) {
2833 ise_destroy_tutorial_mode_popup();
2834 new_layout = ISE_LAYOUT_STYLE_NUMBER;
2835 if (!g_config_values.symbol_tutorial_enable) {
2836 ise_show_tutorial_mode_popup(new_layout);
2837 g_config_values.symbol_tutorial_enable = true;
2838 write_ise_config_values();
2843 if (new_layout != g_keyboard_state.layout && new_layout < ISE_LAYOUT_STYLE_MAX) {
2844 g_keyboard_state.need_reset = TRUE;
2845 g_keyboard_state.layout = new_layout;
2847 if (g_keyboard_state.visible_state) {
2848 _reset_multitap_state();
2849 _language_manager.reset_language(g_config_values.selected_language.c_str());
2850 ise_show(g_keyboard_state.ic);
2858 static void ime_app_prediction_hint_set_cb(const char *prediction_hint, void *user_data)
2860 char *sender = (char *)"mms";
2861 char *caller_id = (char *)"mms";
2862 char *hint = (char *)prediction_hint;
2864 if (!prediction_hint) return;
2865 SECURE_LOGD("prediction hint : %s\n", prediction_hint);
2867 if (strlen(prediction_hint) > 0) {
2868 input_smartreply_init(caller_id, sender, hint);
2869 input_smartreply_set_notify(_input_smartreply_notify_cb, NULL);
2871 if (input_smartreply_is_enabled()) {
2872 g_smartreply_size = 0;
2873 g_smartreply_reply_exist = false;
2875 input_smartreply_get_reply_async();
2880 static void ime_app_mime_type_set_request_cb(const char *mime_types, void *user_data)
2882 LOGD("mime type : %s\n", mime_types);
2885 g_set_mime_type = TRUE;
2887 string str(mime_types), text_key = "text/", image_key = "image/";
2889 if (str.find(text_key) != string::npos)
2890 cbhm_sel_type |= CBHM_SEL_TYPE_TEXT;
2892 if (str.find(image_key) != string::npos)
2893 cbhm_sel_type |= CBHM_SEL_TYPE_IMAGE;
2895 LOGD("cbhm_sel_type=0x%x", cbhm_sel_type);
2899 static void ime_app_prediction_hint_data_set_cb(const char *key, const char *value, void *user_data)
2901 SECURE_LOGD("key : %s, value : %s\n", key, value);
2903 if (string(key) == "appid")
2904 g_app_id = string(value ? value : "");
2905 else if (string(key) == "res_id")
2906 g_resource_id = string(value ? value : "");
2912 EXPORTED void ime_app_main(int argc, char **argv)
2914 ime_callback_s basic_callback = {
2921 ime_event_set_focus_in_cb(ime_app_focus_in_cb, NULL);
2922 ime_event_set_focus_out_cb(ime_app_focus_out_cb, NULL);
2923 ime_event_set_rotation_degree_changed_cb(ime_app_rotation_degree_changed_cb, NULL);
2924 ime_event_set_accessibility_state_changed_cb(ime_app_accessibility_state_changed_cb, NULL);
2925 ime_event_set_layout_set_cb(ime_app_layout_set_cb, NULL);
2926 ime_event_set_caps_mode_changed_cb(ime_app_caps_mode_changed_cb, NULL);
2927 ime_event_set_cursor_position_updated_cb(ime_app_cursor_position_updated_cb, NULL);
2928 ime_event_set_surrounding_text_updated_cb(ime_app_surrounding_text_updated_cb, NULL);
2929 ime_event_set_return_key_type_set_cb(ime_app_return_key_type_set_cb, NULL);
2930 ime_event_set_return_key_state_set_cb(ime_app_return_key_state_set_cb, NULL);
2931 ime_event_set_imdata_set_cb(ime_app_imdata_set_cb, NULL);
2932 ime_event_set_process_key_event_cb(ime_app_process_key_event_cb, NULL);
2934 ime_event_set_candidate_show_cb(ime_app_candidate_show_cb, NULL);
2935 ime_event_set_candidate_hide_cb(ime_app_candidate_hide_cb, NULL);
2936 ime_event_set_lookup_table_changed_cb(ime_app_lookup_table_changed_cb, NULL);
2939 ime_event_set_process_input_device_event_cb(ime_app_process_input_device_event_cb, NULL);
2942 ime_event_set_input_context_reset_cb(ime_app_input_context_reset_cb, NULL);
2943 ime_event_set_language_requested_cb(ime_app_language_requested_cb, NULL);
2945 ime_event_set_prediction_hint_set_cb(ime_app_prediction_hint_set_cb, NULL);
2946 ime_event_set_mime_type_set_request_cb(ime_app_mime_type_set_request_cb, NULL);
2947 ime_event_set_prediction_hint_data_set_cb(ime_app_prediction_hint_data_set_cb, NULL);
2949 #if DEFER_ISE_CREATION
2950 ime_set_window_creation_defer_flag(TRUE);
2953 ime_run(&basic_callback, NULL);
2959 EXPORTED int main(int argc, char *argv[])
2961 ime_app_main(argc, argv);