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 "ise-tutorial-mode.h"
46 #include "modeindicator.h"
47 #include "w-input-smartreply.h"
48 #include "ise-floating-mode.h"
50 #define EDJ_FILE RESDIR"/edje/mobile/customised_ctxpopup.edj"
52 #define EXIT_ISE_ON_HIDE 0
53 #define DEFER_ISE_CREATION 0
55 #define CANDIDATE_WINDOW_HEIGHT 84
63 static cbhm_h cbhm_handle;
64 static sclu32 cbhm_sel_type = 0;
65 static sclboolean g_set_mime_type = FALSE;
68 int g_imdata_state = 0;
71 bool number_tutorial_enable = true;
72 bool symbol_tutorial_enable = false;
75 extern emoticon_group_t current_emoticon_group;
76 extern std::vector <int> emoticon_list_recent;
78 extern CONFIG_VALUES g_config_values;
79 static sclboolean g_need_send_shift_event = FALSE;
81 extern void set_ise_imdata(const char * buf, size_t &len);
82 static void init_recent_used_punctuation();
83 static void update_recent_used_punctuation(const char *key_value);
84 static void set_ime_size(bool floating_mode, ISE_CANDIDATE_REQUEST candidate_req);
85 static sclboolean g_punctuation_popup_opened = FALSE;
86 static sclboolean g_popup_opened = FALSE;
87 static vector<string> g_recent_used_punctuation;
88 static const int MAX_DEFAULT_PUNCTUATION = 6;
89 static string g_default_punctuation[MAX_DEFAULT_PUNCTUATION] = {"-", "@", "'", "!", "?", ","};
90 static string g_current_punctuation[MAX_DEFAULT_PUNCTUATION-1] = {"RCENT1", "RCENT2", "RCENT3", "RCENT4", "RCENT5"};
91 static vector<string> g_softcandidate_string;
92 static bool g_softcandidate_show = false;
93 static bool g_input_panel_show = false;
94 static bool g_smartreply_reply_exist = false;
95 static unsigned int g_smartreply_size = 0;
96 static bool g_caps_mode_pending = false;
97 static bool g_floating_mode = false;
98 static bool g_candidate_more_view = false;
99 static bool g_ise_created = false;
101 static bool g_autofill_exist = false;
102 static int g_autofill_hint = 0;
103 static string g_autofill_string;
104 static vector<string> g_lookup_table_strings;
105 static vector<string> g_smartreply_strings;
107 static Ecore_Timer *guideline_timer = NULL;
110 static Ecore_Timer *exit_timer = NULL;
113 static string g_app_id;
114 static string g_resource_id;
116 #define SOFT_CANDIDATE_DELETE_TIME (100.0/1000)
117 static Ecore_Timer *g_softcandidate_hide_timer = NULL;
119 extern sclboolean g_setting_window_open_status;
122 static int g_ic_smartreply = -1;
124 KEYBOARD_STATE g_keyboard_state = {
127 ISE_LAYOUT_STYLE_NORMAL,
137 #define ISE_LAYOUT_NUMBERONLY_VARIATION_MAX 4
138 /*static const sclchar *_ise_numberonly_variation_name[ISE_LAYOUT_NUMBERONLY_VARIATION_MAX] = {
139 "DEFAULT", "SIG", "DEC", "SIGDEC"
142 #define SIG_DEC_SIZE 2
143 static scluint _click_count = 0;
144 static const char *_sig_dec[SIG_DEC_SIZE] = {".", "-"};
145 static scluint _sig_dec_event[SIG_DEC_SIZE] = {'.', '-'};
146 static Ecore_Timer *_commit_timer = NULL;
148 static sclu32 _context_layout = ISE_LAYOUT_STYLE_NORMAL;
149 static sclu32 _context_layout_variation = 0;
151 Candidate *g_candidate = NULL;
153 class CandidateEventListener: public EventListener
156 void on_event(const EventDesc &desc)
158 const MultiEventDesc &multidesc = dynamic_cast<const MultiEventDesc &>(desc);
159 switch (multidesc.type) {
160 case MultiEventDesc::CANDIDATE_ITEM_MOUSE_DOWN:
161 if (g_autofill_exist) {
162 if (multidesc.index == 0) {
163 char *text = autofill_get_string((Ecore_IMF_Input_Hints)g_autofill_hint);
165 ise_send_string(text);
168 } else if (multidesc.index < (int)g_smartreply_size + 1) {
169 ise_send_string(g_softcandidate_string[multidesc.index].c_str());
171 ime_select_candidate(multidesc.index - g_smartreply_size - 1);
174 if (multidesc.index < (int)g_smartreply_size)
175 ise_send_string(g_softcandidate_string[multidesc.index].c_str());
177 ime_select_candidate(multidesc.index - g_smartreply_size);
180 case MultiEventDesc::CANDIDATE_MORE_VIEW_SHOW:
181 // when more parts shows, click on the candidate will
182 // not affect the key click event
183 g_candidate_more_view = true;
184 if (!g_input_panel_show)
185 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_SHOW);
187 g_ui->disable_input_events(TRUE);
189 case MultiEventDesc::CANDIDATE_MORE_VIEW_HIDE:
190 g_candidate_more_view = false;
191 if (!g_input_panel_show)
192 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_SHOW);
194 g_ui->disable_input_events(FALSE);
200 static CandidateEventListener g_candidate_event_listener;
202 static ISELanguageManager _language_manager;
203 #define MVK_Shift_L 0xffe1
204 #define MVK_Caps_Lock 0xffe5
205 #define MVK_Shift_Off 0xffe1
206 #define MVK_Shift_On 0xffe2
207 #define MVK_Shift_Lock 0xffe6
208 #define MVK_Shift_Enable 0x9fe7
209 #define MVK_Shift_Disable 0x9fe8
210 #define MVK_space 0x020
212 #define CM_KEY_LIST_SIZE 5
213 #define USER_KEYSTRING_OPTION "OPTION"
214 #define USER_KEYSTRING_EMOTICON "EMOTICON_LAYOUT"
215 #define USER_KEYSTRING_CLIPBOARD "CLIPBOARD"
216 #define USER_KEYSTRING_VOICE "STT_3X4"
217 #define USER_KEYSTRING_FLOATING "FLOATING"
219 #define USER_VOICE_LANGUAGE "LANGUAGE"
221 static sclboolean _cm_popup_opened = FALSE;
222 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};
223 static scluint _current_cm_key_id = 0;
224 Evas_Object* _guide_popup_window = NULL;
227 * This callback class will receive all response events from SCL
228 * So you should perform desired tasks in this class.
230 class CUIEventCallback : public ISCLUIEventCallback
233 SCLEventReturnType on_event_key_clicked(SclUIEventDesc event_desc);
234 SCLEventReturnType on_event_drag_state_changed(SclUIEventDesc event_desc);
235 SCLEventReturnType on_event_notification(SCLUINotiType noti_type, SclNotiDesc *etc_info);
238 static CUIEventCallback callback;
240 static void update_candidate_table()
242 g_softcandidate_string.clear();
243 vector<string>::iterator iter;
245 // add autofill string
246 if (g_autofill_exist)
247 g_softcandidate_string.push_back(g_autofill_string);
249 // add lookup table string(s)
250 iter = g_lookup_table_strings.begin();
251 for (; iter != g_lookup_table_strings.end(); ++iter)
253 g_softcandidate_string.push_back(string(iter->c_str()));
256 ise_update_table(g_softcandidate_string);
259 static void _input_smartreply_notify_cb(void *user_data)
261 g_smartreply_strings.clear();
264 if (input_smartreply_is_enabled()) {
265 /* Append newly added smartreply list */
266 int len = input_smartreply_get_reply_num();
268 for (int i = 0; i < len; i++) {
270 char *reply = (char *)"";
271 reply = input_smartreply_get_nth_item(i, &type);
274 SECURE_LOGD("SmartReply = [%d] %s", i, reply);
277 g_smartreply_strings.push_back(string(candidate));
281 g_ic_smartreply = g_ic;
282 g_smartreply_reply_exist = true;
284 ise_app_candidate_show();
285 g_softcandidate_string = g_smartreply_strings;
286 ise_update_table(g_softcandidate_string);
292 check_ic_temporary(int ic)
294 if ((ic & 0xFFFF) == 0) {
300 static void _reset_shift_state(void)
303 /* Reset all shift state variables */
304 SCLShiftState old_shift_state = g_ui->get_shift_state();
305 SCLShiftState new_shift_state = SCL_SHIFT_STATE_OFF;
306 if (old_shift_state != new_shift_state) {
307 g_need_send_shift_event = true;
308 g_ui->set_shift_state(new_shift_state);
310 LOGD("Shift state changed from (%d) to (%d)\n", (int)old_shift_state, (int)new_shift_state);
314 static void set_caps_mode(sclboolean mode) {
315 LOGD("mode : %d\n", mode);
317 if (g_ui->get_shift_state() != SCL_SHIFT_STATE_LOCK) {
318 g_ui->set_shift_state(mode ? SCL_SHIFT_STATE_ON : SCL_SHIFT_STATE_OFF);
319 g_ui->set_autocapital_shift_state(!mode);
324 static void _reset_multitap_state(bool skip_commit = false)
326 LOGD("g_keyboard_state.prev_modifier : %d", g_keyboard_state.prev_modifier);
327 if (g_keyboard_state.prev_modifier == KEY_MODIFIER_MULTITAP_START ||
328 g_keyboard_state.prev_modifier == KEY_MODIFIER_MULTITAP_REPEAT) {
330 ise_send_string(g_keyboard_state.multitap_value.c_str());
332 ise_update_preedit_string("");
334 g_keyboard_state.multitap_value = "";
335 g_keyboard_state.prev_modifier = KEY_MODIFIER_NONE;
336 if (g_caps_mode_pending) {
337 g_caps_mode_pending = false;
338 set_caps_mode(g_keyboard_state.caps_mode);
342 static void ise_set_cm_private_key(scluint cm_key_id)
344 if (cm_key_id >= CM_KEY_LIST_SIZE || g_ui == NULL) {
345 LOGE("cm_key_id=%d\n", cm_key_id);
349 if (strcmp(_cm_key_list[cm_key_id], USER_KEYSTRING_EMOTICON) == 0) {
350 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
351 const_cast<sclchar*>("icon/54x54/icon_emotion_nor.png"),
352 const_cast<sclchar*>("icon/54x54/icon_emotion_press.png"),
353 const_cast<sclchar*>("icon/54x54/icon_emotion_dim.png")};
354 g_ui->set_private_key("CM_KEY", const_cast<sclchar*>(" "), imagelabel, NULL, 0, const_cast<sclchar*>(USER_KEYSTRING_EMOTICON), TRUE);
355 } else if (strcmp(_cm_key_list[cm_key_id], USER_KEYSTRING_OPTION) == 0) {
356 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
357 const_cast<sclchar*>("icon/54x54/icon_setting_nor.png"),
358 const_cast<sclchar*>("icon/54x54/icon_setting_press.png"),
359 const_cast<sclchar*>("icon/54x54/icon_setting_dim.png")};
360 g_ui->set_private_key("CM_KEY", const_cast<sclchar*>(" "), imagelabel, NULL, 0, const_cast<sclchar*>(USER_KEYSTRING_OPTION), TRUE);
361 } else if (strcmp(_cm_key_list[cm_key_id], USER_KEYSTRING_CLIPBOARD) == 0) {
362 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
363 const_cast<sclchar*>("icon/54x54/icon_clipboard_nor.png"),
364 const_cast<sclchar*>("icon/54x54/icon_clipboard_press.png"),
365 const_cast<sclchar*>("icon/54x54/icon_clipboard_dim.png")};
366 g_ui->set_private_key("CM_KEY", const_cast<sclchar*>(" "), imagelabel, NULL, 0, const_cast<sclchar*>(USER_KEYSTRING_CLIPBOARD), TRUE);
367 } else if (strcmp(_cm_key_list[cm_key_id], USER_KEYSTRING_VOICE) == 0) {
368 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
369 const_cast<sclchar*>("icon/54x54/icon_mic_nor.png"),
370 const_cast<sclchar*>("icon/54x54/icon_mic_press.png"),
371 const_cast<sclchar*>("icon/54x54/icon_mic_dim.png")};
372 g_ui->set_private_key("CM_KEY", const_cast<sclchar*>(" "), imagelabel, NULL, 0, const_cast<sclchar*>(USER_KEYSTRING_VOICE), TRUE);
373 } else if (strcmp(_cm_key_list[cm_key_id], USER_KEYSTRING_FLOATING) == 0) {
374 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
375 const_cast<sclchar*>("icon/54x54/icon_floating_keypad_nor.png"),
376 const_cast<sclchar*>("icon/54x54/icon_floating_keypad_press.png"),
377 const_cast<sclchar*>("icon/54x54/icon_floating_keypad_dim.png")};
378 g_ui->set_private_key("CM_KEY", const_cast<sclchar*>(" "), imagelabel, NULL, 0, const_cast<sclchar*>(USER_KEYSTRING_FLOATING), TRUE);
382 static void ise_update_space_key(void)
385 LOGE("g_ui = NULL\n");
389 scluint num = _language_manager.get_enabled_languages_num();
390 LOGD("language number: %d\n", num);
392 LANGUAGE_INFO *info = _language_manager.get_language_info(_language_manager.get_current_language());
393 if (info && info->enabled) {
395 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
396 const_cast<sclchar*>("w_sip_3x4_btn_ic_space_no_arrow.png"),
397 const_cast<sclchar*>("w_sip_3x4_btn_ic_space_no_arrow.png"),
398 const_cast<sclchar*>("w_sip_3x4_btn_ic_space_no_arrow.png")};
399 g_ui->set_private_key("SPACE_KEY", const_cast<sclchar*>(info->display_name.c_str()), imagelabel, NULL, 0, const_cast<sclchar*>("Space"), TRUE);
401 g_ui->enable_button("SPACE_ARROW_LEFT", false);
402 g_ui->enable_button("SPACE_ARROW_RIGHT", false);
407 g_ui->unset_private_key("SPACE_KEY");
409 g_ui->enable_button("SPACE_ARROW_LEFT", true);
410 g_ui->enable_button("SPACE_ARROW_RIGHT", true);
415 static scluint ise_get_cm_key_id(const sclchar *key_value)
417 for (int i = 0; i < CM_KEY_LIST_SIZE; ++i) {
418 if (0 == strcmp (key_value, _cm_key_list[i]))
424 static bool ise_is_emoticons_disabled(void)
427 sclu32 current_layout = g_keyboard_state.layout;
428 LOGD("layout=%d\n", current_layout);
430 if ((current_layout == ISE_LAYOUT_STYLE_NORMAL) ||
431 (current_layout == ISE_LAYOUT_STYLE_NUMBER) ||
432 (current_layout == ISE_LAYOUT_STYLE_EMOTICON))
435 if (g_imdata_state & IMDATA_ACTION_DISABLE_EMOTICONS)
441 static Eina_Bool softcandidate_hide_timer_callback(void *data)
444 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_HIDE);
448 g_softcandidate_show = false;
450 return ECORE_CALLBACK_CANCEL;
453 static void delete_softcandidate_hide_timer(void)
455 if (g_softcandidate_hide_timer) {
456 ecore_timer_del(g_softcandidate_hide_timer);
457 g_softcandidate_hide_timer = NULL;
461 static void add_softcandidate_hide_timer(void)
463 delete_softcandidate_hide_timer();
464 g_softcandidate_hide_timer = ecore_timer_add(SOFT_CANDIDATE_DELETE_TIME, softcandidate_hide_timer_callback, NULL);
467 static void create_softcandidate(void)
470 g_candidate = CandidateFactory::make_candidate(CANDIDATE_MULTILINE, ime_get_main_window());
472 g_candidate->add_event_listener(&g_candidate_event_listener);
478 * Send the given string to input framework
481 ise_send_string(const sclchar *key_value)
484 if (!check_ic_temporary(g_keyboard_state.ic)) {
485 ic = g_keyboard_state.ic;
487 ime_commit_string(key_value);
488 LOGD("ic : %x, %s\n", ic, key_value);
492 * Send the preedit string to input framework
495 ise_update_preedit_string(const sclchar *str, const sclboolean underline)
498 Eina_List *attr_list = NULL;
499 ime_preedit_attribute *preedit_attr;
501 if (!check_ic_temporary(g_keyboard_state.ic)) {
502 ic = g_keyboard_state.ic;
505 /* Count UTF-8 string length */
507 const sclchar *s = str;
508 while (*s) len += (*s++ & 0xc0) != 0x80;
510 preedit_attr = (ime_preedit_attribute *)calloc(1, sizeof(ime_preedit_attribute));
512 preedit_attr->start = 0;
513 preedit_attr->length = len;
514 preedit_attr->type = IME_ATTR_FONTSTYLE;
515 preedit_attr->value = IME_ATTR_FONTSTYLE_UNDERLINE;
516 attr_list = eina_list_append(attr_list, (void *)preedit_attr);
519 ime_update_preedit_string(str, attr_list);
521 ime_update_preedit_string(str, NULL);
523 LOGD("ic : %x, %s\n", ic, str);
527 * Send the given event to input framework
530 ise_send_event(sclulong key_event, sclulong key_mask)
533 if (!check_ic_temporary(g_keyboard_state.ic)) {
534 ic = g_keyboard_state.ic;
536 ime_send_key_event((ime_key_code_e)key_event, IME_KEY_MASK_PRESSED, false);
537 ime_send_key_event((ime_key_code_e)key_event, IME_KEY_MASK_RELEASED, false);
539 LOGD("ic : %x, %x\n", ic, key_event);
543 * Forward the given event to input framework
546 ise_forward_key_event(sclulong key_event)
549 if (!check_ic_temporary(g_keyboard_state.ic)) {
550 ic = g_keyboard_state.ic;
552 ime_send_key_event((ime_key_code_e)key_event, IME_KEY_MASK_PRESSED, true);
553 ime_send_key_event((ime_key_code_e)key_event, IME_KEY_MASK_RELEASED, true);
555 LOGD("ic : %x, %x\n", ic, key_event);
559 * @brief Delete commit timer.
563 static void delete_commit_timer(void)
565 if (_commit_timer != NULL) {
566 ecore_timer_del(_commit_timer);
567 _commit_timer = NULL;
572 * @brief Callback function for commit timer.
574 * @param data Data to pass when it is called.
576 * @return ECORE_CALLBACK_CANCEL
578 static Eina_Bool commit_timeout(void *data)
580 if (_commit_timer != NULL) {
581 ime_hide_preedit_string();
582 ise_forward_key_event(_sig_dec_event[(_click_count-1)%SIG_DEC_SIZE]);
585 _commit_timer = NULL;
586 return ECORE_CALLBACK_CANCEL;
590 on_input_mode_changed(const sclchar *key_value, sclulong key_event, sclint key_type)
592 sclboolean ret = FALSE;
596 SECURE_LOGD("key_value : %s\n", key_value);
597 if (strcmp(key_value, "CUR_LANG") == 0) {
598 g_keyboard_state.disable_force_latin = TRUE;
599 ret = _language_manager.select_current_language();
601 if (strcmp(key_value, "NEXT_LANG") == 0) {
602 g_keyboard_state.disable_force_latin = TRUE;
603 ret = _language_manager.select_next_language();
607 const sclchar *cur_lang = _language_manager.get_current_language();
609 LANGUAGE_INFO *info = _language_manager.get_language_info(cur_lang);
611 if (info->accepts_caps_mode) {
612 ise_send_event(MVK_Shift_Enable, KEY_MASK_NULL);
613 set_caps_mode(g_keyboard_state.caps_mode);
615 ise_send_event(MVK_Shift_Disable, KEY_MASK_NULL);
616 g_ui->set_shift_state(SCL_SHIFT_STATE_OFF);
620 if (is_emoticon_show()) {
621 ise_destroy_emoticon_layout();
624 if (!strcmp(key_value, USER_KEYSTRING_EMOTICON)) {
625 ise_init_emoticon_list();
627 current_emoticon_group = EMOTICON_GROUP_1;
629 if (emoticon_list_recent.size() == 0)
630 current_emoticon_group = EMOTICON_GROUP_1;
632 current_emoticon_group = EMOTICON_GROUP_RECENTLY_USED;
634 SCLRotation rotation = g_ui->get_rotation();
635 ise_show_emoticon_layout(current_emoticon_group, ROTATION_TO_DEGREE(rotation), false, ime_get_main_window());
643 static void show_cbhm()
649 ret = cbhm_selection_type_set(cbhm_handle, static_cast<cbhm_sel_type_e>(cbhm_sel_type));
651 ret = cbhm_selection_type_set(cbhm_handle, CBHM_SEL_TYPE_TEXT);
653 if (ret != CBHM_ERROR_NONE)
654 LOGW("Failed to set selection type in cbhm. error : %d\n", ret);
656 ret = cbhm_show(cbhm_handle);
657 if (ret != CBHM_ERROR_NONE)
658 LOGW("cbhm show error : %d\n", ret);
664 SCLEventReturnType CUIEventCallback::on_event_notification(SCLUINotiType noti_type, SclNotiDesc *etc_info)
666 SCLEventReturnType ret = SCL_EVENT_PASS_ON;
667 LOGD("noti type: %d, g_need_send_shift_event: %d\n", noti_type, g_need_send_shift_event);
669 if (noti_type == SCL_UINOTITYPE_SHIFT_STATE_CHANGE) {
670 if (g_need_send_shift_event) {
671 const sclchar *cur_lang = _language_manager.get_current_language();
673 LANGUAGE_INFO *info = _language_manager.get_language_info(cur_lang);
674 SclNotiShiftStateChangeDesc *desc = static_cast<SclNotiShiftStateChangeDesc*>(etc_info);
676 if (info->accepts_caps_mode) {
677 LOGD("shift state: %d\n", desc->shift_state);
678 if (desc->shift_state == SCL_SHIFT_STATE_OFF) {
679 ise_send_event(MVK_Shift_Off, KEY_MASK_NULL);
680 } else if (desc->shift_state == SCL_SHIFT_STATE_ON) {
681 ise_send_event(MVK_Shift_On, KEY_MASK_NULL);
682 } else if (desc->shift_state == SCL_SHIFT_STATE_LOCK) {
683 ise_send_event(MVK_Shift_Lock, KEY_MASK_NULL);
685 ret = SCL_EVENT_PASS_ON;
689 g_need_send_shift_event = FALSE;
691 } else if (noti_type == SCL_UINOTITYPE_POPUP_OPENING) {
692 vector<string>::reverse_iterator iter = g_recent_used_punctuation.rbegin();
694 for (; iter != g_recent_used_punctuation.rend(); ++iter)
697 g_ui->set_string_substitution(g_current_punctuation[punc_pos].c_str(), iter->c_str());
700 SclNotiPopupOpeningDesc *openingDesc = (SclNotiPopupOpeningDesc *)etc_info;
701 if (g_ui && 0 == strcmp(openingDesc->input_mode, "CM_POPUP")) {
702 if (ise_is_emoticons_disabled())
703 g_ui->enable_button("EMOTICON_KEY", false);
705 g_ui->enable_button("EMOTICON_KEY", true);
707 } else if (noti_type == SCL_UINOTITYPE_POPUP_OPENED) {
708 g_popup_opened = TRUE;
709 SclNotiPopupOpenedDesc *openedDesc = (SclNotiPopupOpenedDesc *)etc_info;
710 if (0 == strcmp(openedDesc->input_mode, "PUNCTUATION_POPUP")) {
711 g_punctuation_popup_opened = TRUE;
712 } else if (0 == strcmp(openedDesc->input_mode, "CM_POPUP")) {
713 _cm_popup_opened = TRUE;
715 } else if (noti_type == SCL_UINOTITYPE_POPUP_CLOSED) {
716 g_popup_opened = FALSE;
717 SclNotiPopupClosedDesc *closedDesc = (SclNotiPopupClosedDesc *)etc_info;
718 if (closedDesc && closedDesc->input_mode) {
719 if (0 == strcmp(closedDesc->input_mode, "PUNCTUATION_POPUP")) {
720 g_punctuation_popup_opened = FALSE;
721 } else if (0 == strcmp(closedDesc->input_mode, "CM_POPUP")) {
722 _cm_popup_opened = FALSE;
725 } else if (noti_type == SCL_UINOTITYPE_INPUT_MODE_CHANGE) {
726 SclNotiInputModeChangeDesc *desc = static_cast<SclNotiInputModeChangeDesc*>(etc_info);
728 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_NONE);
730 if (strcmp(g_ui->get_input_mode(), "STT_3X4") == 0 &&
731 strcmp(desc->input_mode, "STT_3X4") != 0) {
734 if (strcmp(g_ui->get_input_mode(), "STT_3X4") != 0 &&
735 strcmp(desc->input_mode, "STT_3X4") == 0) {
736 ise_show_stt_mode(NATIVE_WINDOW_CAST(ime_get_main_window()));
744 void ise_destory_guideline_popup()
746 if (_guide_popup_window != NULL) {
747 evas_object_del(_guide_popup_window);
748 _guide_popup_window = NULL;
752 void _guideline_popup_dismissed_cb(void *data, Evas_Object *obj, void *event_info)
754 evas_object_smart_callback_del(obj, "dismissed", _guideline_popup_dismissed_cb);
755 evas_object_del(obj);
758 if (_guide_popup_window != NULL) {
759 evas_object_del(_guide_popup_window);
760 _guide_popup_window = NULL;
763 g_config_values.first_guideset = TRUE;
764 write_ise_config_values();
767 Evas_Object *open_message_popup(Evas_Object *parentWnd)
769 static Evas_Object *msg_window = NULL;
771 evas_object_del(msg_window);
774 msg_window = elm_win_add(parentWnd, "MCFMessagePopup", ELM_WIN_UTILITY);
777 elm_win_borderless_set(msg_window, EINA_TRUE);
778 elm_win_alpha_set(msg_window, EINA_TRUE);
779 elm_win_title_set(msg_window, "ISF Popup");
780 elm_win_screen_size_get(msg_window, NULL, NULL, &w, &h);
781 elm_win_prop_focus_skip_set(msg_window, TRUE);
782 int rots[4] = {0, 90, 180, 270};
783 elm_win_wm_rotation_available_rotations_set(msg_window, rots, 4);
784 evas_object_resize(msg_window, w, h);
787 int rots[4] = { 0, 90, 180, 270 };
788 elm_win_wm_rotation_available_rotations_set(msg_window, rots, 4);
789 evas_object_show(msg_window);
793 void ise_show_help_popup(sclulong keyEvent)
795 char buf[2048] = {0, };
799 SclRectangle rectangle = {0};
802 g_ui->get_screen_resolution(&scr_w, &scr_h);
804 if (keyEvent == MVK_space) {
805 g_ui->get_button_geometry("SPACE_KEY", &rectangle);
807 g_ui->get_button_geometry("CM_KEY", &rectangle);
811 _guide_popup_window = open_message_popup(NATIVE_WINDOW_CAST(ime_get_main_window()));
813 Elm_Theme *theme = elm_theme_new();
814 elm_theme_ref_set(theme, NULL);
815 elm_theme_extension_add(theme, EDJ_FILE);
817 Evas_Object *ctxpopup = elm_ctxpopup_add(_guide_popup_window);
818 elm_object_theme_set(ctxpopup, theme);
820 int rotation = elm_win_rotation_get(NATIVE_WINDOW_CAST(ime_get_main_window()));
821 if (rotation == 0 || rotation == 180) {
822 elm_object_style_set(ctxpopup, "customised_guideline_popup");
824 elm_object_style_set(ctxpopup, "customised_guideline_popup_landscape");
827 evas_object_smart_callback_add(ctxpopup, "dismissed", _guideline_popup_dismissed_cb, (void *)keyEvent);
828 elm_ctxpopup_direction_priority_set(ctxpopup, ELM_CTXPOPUP_DIRECTION_UP,
829 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
830 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
831 ELM_CTXPOPUP_DIRECTION_UNKNOWN);
833 Evas_Object* text = elm_label_add(ctxpopup);
835 if (keyEvent == MVK_space) {
836 snprintf(buf, sizeof(buf), "<font_style=Regular font_size=%d align=left wrap=mixed color=#000000>%s</>", font_size,
837 dgettext(PACKAGE, "IDS_IME_BODY_SWIPE_THE_SPACE_BAR_LEFT_OR_RIGHT_TO_CHANGE_BETWEEN_LANGUAGES"));
839 snprintf(buf, sizeof(buf), "<font_style=Regular font_size=%d align=left wrap=mixed color=#000000>%s</>", font_size,
840 dgettext(PACKAGE, "IDS_IME_BODY_TAP_AND_HOLD_THIS_KEY_TO_SEE_THE_SYMBOL_LIST_SELECT_ONE_TO_USE_IT_AS_A_SHORTCUT"));
842 elm_object_text_set(text, buf);
843 elm_object_content_set(ctxpopup, text);
844 Evas_Coord x, y, w, h;
845 evas_object_geometry_get(NATIVE_WINDOW_CAST(ime_get_main_window()), &x, &y, &w, &h);
847 if (rotation == 0 || rotation == 180) {
848 elm_label_wrap_width_set(text, (scr_w * 4) / 5);
849 evas_object_size_hint_min_set(ctxpopup, ELM_SCALE_SIZE(scr_w), ELM_SCALE_SIZE(50));
850 evas_object_size_hint_max_set(ctxpopup, ELM_SCALE_SIZE(scr_w), ELM_SCALE_SIZE(600));
851 evas_object_move(ctxpopup, rectangle.x + rectangle.width / 2,
852 (scr_h - h) + rectangle.y - ELM_SCALE_SIZE(5));
854 elm_label_wrap_width_set(text, (scr_h * 4) / 5);
855 evas_object_size_hint_min_set(ctxpopup, ELM_SCALE_SIZE(scr_h), ELM_SCALE_SIZE(50));
856 evas_object_size_hint_max_set(ctxpopup, ELM_SCALE_SIZE(scr_h), ELM_SCALE_SIZE(600));
857 evas_object_move(ctxpopup, rectangle.x + rectangle.width / 2,
858 (scr_w - h)+ rectangle.y - ELM_SCALE_SIZE(5));
860 elm_label_line_wrap_set(text, ELM_WRAP_MIXED);
861 evas_object_show(text);
863 evas_object_layer_set(_guide_popup_window, EVAS_LAYER_MAX);
864 evas_object_show(_guide_popup_window);
865 evas_object_layer_set(ctxpopup, EVAS_LAYER_MAX);
866 evas_object_show(ctxpopup);
869 SCLEventReturnType CUIEventCallback::on_event_drag_state_changed(SclUIEventDesc event_desc)
871 if (event_desc.event_type == EVENT_TYPE_MOVE) {
872 if (event_desc.key_event == MVK_space) {
873 SclRectangle rectangle = {0};
874 g_ui->get_button_geometry("SPACE_KEY", &rectangle);
875 ise_show_space_flick_language_change_popup(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
877 } else if (event_desc.event_type == EVENT_TYPE_RELEASE) {
878 if (event_desc.key_event == MVK_space) {
879 ise_destroy_space_flick_language_change_popup();
883 ime_set_floating_drag_end();
884 } else if (event_desc.event_type == EVENT_TYPE_PRESS) {
886 if ((!g_config_values.first_guideset) && (event_desc.key_type == KEY_TYPE_MODECHANGE)) {
887 ise_show_help_popup(event_desc.key_event);
888 return SCL_EVENT_PASS_ON;
891 if (g_floating_mode && event_desc.mouse_current_point.y <= FLOATING_TITLE_BAR_HEIGHT
892 && event_desc.mouse_current_point.y >= 0)
893 ime_set_floating_drag_start();
895 return SCL_EVENT_PASS_ON;
898 static void launch_option()
900 app_control_h app_control;
901 int ret = app_control_create(&app_control);
902 if (ret != APP_CONTROL_ERROR_NONE) {
903 LOGW("app_control_create returned %d\n", ret);
907 ret = app_control_set_operation(app_control, APP_CONTROL_OPERATION_DEFAULT);
908 if (ret != APP_CONTROL_ERROR_NONE) {
909 LOGW("app_control_set_operation returned %d\n", ret);
913 ret = app_control_set_app_id(app_control, "org.tizen.ise-default-setting");
914 if (ret != APP_CONTROL_ERROR_NONE) {
915 LOGW("app_control_set_app_id returned %d\n", ret);
919 ret = app_control_send_launch_request(app_control, NULL, NULL);
920 if (ret != APP_CONTROL_ERROR_NONE) {
926 app_control_destroy(app_control);
929 SCLEventReturnType CUIEventCallback::on_event_key_clicked(SclUIEventDesc event_desc)
931 SCLEventReturnType ret = SCL_EVENT_PASS_ON;
933 if (event_desc.key_modifier == KEY_MODIFIER_MULTITAP_START) {
934 if (!g_keyboard_state.multitap_value.empty()) {
935 ise_send_string(g_keyboard_state.multitap_value.c_str());
937 ise_update_preedit_string(event_desc.key_value);
938 g_keyboard_state.multitap_value = event_desc.key_value;
939 } else if (event_desc.key_modifier == KEY_MODIFIER_MULTITAP_REPEAT) {
940 ise_update_preedit_string(event_desc.key_value);
941 g_keyboard_state.multitap_value = event_desc.key_value;
943 _reset_multitap_state();
945 g_keyboard_state.prev_modifier = event_desc.key_modifier;
948 switch (event_desc.key_type) {
949 case KEY_TYPE_STRING: {
950 if (event_desc.key_modifier != KEY_MODIFIER_MULTITAP_START &&
951 event_desc.key_modifier != KEY_MODIFIER_MULTITAP_REPEAT) {
952 if (event_desc.key_event) {
953 ise_forward_key_event(event_desc.key_event);
955 ise_send_string(event_desc.key_value);
958 if (!g_popup_opened) {
959 const sclchar *input_mode = g_ui->get_input_mode();
960 if (input_mode && ((0 == strcmp(input_mode, "SYM_QTY_1")) || (0 == strcmp(input_mode, "SYM_QTY_2")))) {
961 update_recent_used_punctuation(event_desc.key_value);
963 } else if (g_punctuation_popup_opened) {
964 update_recent_used_punctuation(event_desc.key_value);
968 case KEY_TYPE_CHAR: {
969 sclboolean need_forward = FALSE;
970 // FIXME : Should decide when to forward key events
971 const sclchar *input_mode = g_ui->get_input_mode();
973 if (strcmp(input_mode, "SYM_QTY_1") == 0 ||
974 strcmp(input_mode, "SYM_QTY_2") == 0 ||
975 strcmp(input_mode, "PHONE_3X4") == 0 ||
976 strcmp(input_mode, "IPv6_3X4_123") == 0 ||
977 strcmp(input_mode, "IPv6_3X4_ABC") == 0 ||
978 strcmp(input_mode, "NUMONLY_3X4") == 0 ||
979 strcmp(input_mode, "NUMONLY_3X4_SIG") == 0 ||
980 strcmp(input_mode, "NUMONLY_3X4_DEC") == 0 ||
981 strcmp(input_mode, "NUMONLY_3X4_SIGDEC") == 0 ||
982 strcmp(input_mode, "DATETIME_3X4") == 0) {
986 if (input_mode && strcmp (input_mode, "NUMONLY_3X4_SIGDEC") == 0 &&
987 strcmp(event_desc.key_value, ".") == 0) {
988 ime_update_preedit_string(_sig_dec[_click_count%SIG_DEC_SIZE], NULL);
989 ime_show_preedit_string();
990 delete_commit_timer();
991 _commit_timer = ecore_timer_add(1.0, commit_timeout, NULL);
993 } else if (event_desc.key_event) {
994 commit_timeout(NULL);
996 ise_forward_key_event(event_desc.key_event);
998 if (_cm_popup_opened) {
999 static sclchar current_cm_symbol[2] = {'\0'};
1000 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
1001 const_cast<sclchar*>(" "),
1002 const_cast<sclchar*>(" "),
1003 const_cast<sclchar*>(" ")};
1004 if (event_desc.key_value) {
1005 current_cm_symbol[0] = event_desc.key_value[0];
1006 current_cm_symbol[1] = '\0';
1008 g_ui->set_private_key("CM_KEY",
1009 const_cast<sclchar*>(current_cm_symbol),
1010 imagelabel, NULL, 0,
1011 const_cast<sclchar*>(current_cm_symbol), TRUE);
1013 _cm_popup_opened = FALSE;
1014 _current_cm_key_id = -1;
1019 *change the keyboard mode of GLM from QWERTY to KEYPAD
1020 *ensure the Number keypad won't be affected
1023 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_NUMBER) {
1024 ime_send_key_event(IME_KEY_Print, IME_KEY_MASK_CONTROL, false);
1026 ime_send_key_event(IME_KEY_Select, IME_KEY_MASK_CONTROL, false);
1029 ise_send_event(event_desc.key_event, KEY_MASK_NULL);
1033 if ((strcmp(input_mode, "SYM_QTY_1") == 0) || (0 == strcmp(input_mode, "SYM_QTY_2"))) {
1034 update_recent_used_punctuation(event_desc.key_value);
1039 case KEY_TYPE_CONTROL: {
1040 commit_timeout(NULL);
1042 const char *long_shift = "LongShift";
1043 const char *caps_lock = "CapsLock";
1044 const char *delete_all = "DeleteAll";
1045 const char *hide_panel = "Hide";
1046 if (strncmp(event_desc.key_value, long_shift, strlen(long_shift)) == 0) {
1047 LOGD("shift key is longpress\n");
1048 g_ui->set_shift_state(SCL_SHIFT_STATE_ON);
1049 g_need_send_shift_event = TRUE;
1050 //ise_send_event (MVK_Shift_Lock, KEY_MASK_NULL);
1051 } else if (strncmp(event_desc.key_value, caps_lock, strlen(caps_lock)) == 0) {
1052 if (g_ui->get_shift_state() != SCL_SHIFT_STATE_LOCK) {
1053 g_ui->set_shift_state(SCL_SHIFT_STATE_LOCK);
1054 ise_send_event(MVK_Shift_Lock, KEY_MASK_NULL);
1056 g_ui->set_shift_state(SCL_SHIFT_STATE_OFF);
1057 ise_send_event(MVK_Shift_Off, KEY_MASK_NULL);
1059 //g_need_send_shift_event = TRUE;
1060 } else if (strncmp(event_desc.key_value, delete_all, strlen(delete_all)) == 0) {
1061 ime_delete_surrounding_text((INT_MAX / 2) * -1, INT_MAX);
1062 } else if (strncmp(event_desc.key_value, hide_panel, strlen(hide_panel)) == 0) {
1065 } else if (event_desc.key_event) {
1066 ise_send_event(event_desc.key_event, KEY_MASK_NULL);
1067 if (event_desc.key_event == MVK_Shift_L) {
1068 g_need_send_shift_event = TRUE;
1073 case KEY_TYPE_MODECHANGE:
1075 if (!g_config_values.first_guideset) {
1079 if (strcmp(event_desc.key_value, USER_VOICE_LANGUAGE) == 0) {
1080 if (!g_setting_window_open_status) {
1081 ise_hide_stt_mode();
1083 hide_indicator_window();
1085 create_setting_window();
1087 } else if (strcmp(event_desc.key_value, USER_KEYSTRING_VOICE) == 0) {
1088 g_keyboard_state.layout = ISE_LAYOUT_STYLE_VOICE;
1089 g_ui->set_input_mode("STT_3X4");
1091 } else if (strcmp(event_desc.key_value, USER_KEYSTRING_OPTION) == 0) {
1094 ret = SCL_EVENT_DONE;
1095 } else if (strcmp(event_desc.key_value, USER_KEYSTRING_CLIPBOARD) == 0) {
1098 ret = SCL_EVENT_DONE;
1099 } else if (strcmp(event_desc.key_value, USER_KEYSTRING_FLOATING) == 0) {
1100 if (g_floating_mode)
1101 g_config_values.floating_mode = false;
1103 g_config_values.floating_mode = true;
1104 write_ise_config_values();
1106 ret = SCL_EVENT_DONE;
1107 } else if (on_input_mode_changed(event_desc.key_value, event_desc.key_event, event_desc.key_type)) {
1108 ret = SCL_EVENT_DONE;
1110 if (_cm_popup_opened) {
1111 if (strcmp(event_desc.key_value, USER_KEYSTRING_EMOTICON) == 0 ||
1112 strcmp(event_desc.key_value, USER_KEYSTRING_VOICE) == 0 ||
1113 strcmp(event_desc.key_value, USER_KEYSTRING_FLOATING) == 0) {
1114 scluint id = ise_get_cm_key_id(event_desc.key_value);
1115 if (id != _current_cm_key_id) {
1116 _current_cm_key_id = id;
1117 ise_set_cm_private_key(_current_cm_key_id);
1120 _cm_popup_opened = FALSE;
1122 if (strlen(event_desc.key_value) == 1) {
1123 const char allowed_chars_in_modechange[] = {
1124 ',', '?', '!', '`', '~'
1126 const int allowed_chars_in_modechange_num =
1127 sizeof(allowed_chars_in_modechange) / sizeof(char);
1128 for (unsigned int loop = 0;loop < sizeof(allowed_chars_in_modechange_num);loop++) {
1129 if (*(event_desc.key_value) == allowed_chars_in_modechange[loop]) {
1130 ise_send_string(event_desc.key_value);
1136 if (strcmp(event_desc.key_value, USER_KEYSTRING_OPTION) == 0) {
1137 //open_option_window(NULL, ROTATION_TO_DEGREE(g_ui->get_rotation()));
1140 ret = SCL_EVENT_DONE;
1141 } else if (strcmp(event_desc.key_value, USER_KEYSTRING_CLIPBOARD) == 0) {
1143 ret = SCL_EVENT_DONE;
1144 } else if (strcmp(event_desc.key_value, "Cancel") == 0) {
1145 ret = SCL_EVENT_DONE;
1146 if (strcmp(g_ui->get_input_mode(), "STT_3X4") == 0 ) {
1147 g_keyboard_state.need_reset = TRUE;
1148 voice_result_string_flush();
1149 ise_set_layout(g_keyboard_state.layout, g_keyboard_state.layout_variation);
1150 if (g_keyboard_state.visible_state)
1151 ise_show(g_keyboard_state.ic);
1153 ise_send_event(IME_KEY_Cancel, KEY_MASK_NULL);
1155 } else if (strcmp(event_desc.key_value, "Done") == 0) {
1156 ret = SCL_EVENT_DONE;
1157 ise_send_event(IME_KEY_Return, KEY_MASK_NULL);
1160 const sclchar *input_mode = g_ui->get_input_mode();
1161 if ((NULL != input_mode) && (!strcmp(input_mode, "EMOTICON_LAYOUT"))) {
1162 if (is_emoticon_show()) {
1163 ise_destroy_emoticon_layout();
1166 emoticon_group_t group_id = EMOTICON_GROUP_1;
1167 if (current_emoticon_group < EMOTICON_GROUP_3)
1168 group_id = (emoticon_group_t)(current_emoticon_group + 1);
1170 const int BUF_LEN = 16;
1171 char buf[BUF_LEN] = {0};
1172 snprintf(buf, BUF_LEN, "%d/3", group_id);
1173 g_ui->set_private_key("EMOTICON_GROUP_ID", buf, NULL, NULL, 0, const_cast<sclchar*>("EMOTICON_GROUP_NEXT"), TRUE);
1175 emoticon_group_t group_id = ise_get_emoticon_group_id(event_desc.key_value);
1177 if ((group_id >= 0) && (group_id < MAX_EMOTICON_GROUP)) {
1178 SCLRotation rotation = g_ui->get_rotation();
1179 ise_show_emoticon_layout(group_id, ROTATION_TO_DEGREE(rotation), false, ime_get_main_window());
1183 if (_cm_popup_opened) {
1184 if (strcmp(event_desc.key_value, USER_KEYSTRING_OPTION) == 0 ||
1185 strcmp(event_desc.key_value, USER_KEYSTRING_CLIPBOARD) == 0) {
1186 scluint id = ise_get_cm_key_id(event_desc.key_value);
1187 if (id != _current_cm_key_id) {
1188 _current_cm_key_id = id;
1189 ise_set_cm_private_key(_current_cm_key_id);
1192 _cm_popup_opened = FALSE;
1204 ise_set_layout(sclu32 layout, sclu32 layout_variation)
1206 /* Check if the layoutIdx is in the valid range */
1207 if (layout < ISE_LAYOUT_STYLE_MAX) {
1208 if (g_keyboard_state.layout != layout ||
1209 g_keyboard_state.layout_variation != layout_variation) {
1210 g_keyboard_state.need_reset = TRUE;
1212 g_keyboard_state.layout = layout;
1213 g_keyboard_state.layout_variation = layout_variation;
1214 LOGD("layout:%d, variation:%d\n", g_keyboard_state.layout, g_keyboard_state.layout_variation);
1222 _reset_multitap_state(true);
1223 _language_manager.reset_language(g_config_values.selected_language.c_str());
1227 ise_reset_input_context()
1230 _reset_multitap_state(true);
1231 g_keyboard_state.disable_force_latin = FALSE;
1232 _language_manager.reset_language(g_config_values.selected_language.c_str());
1236 ise_focus_in(int ic)
1238 LOGD("ic : %x , %x , g_ic : %x , %x, g_focused_ic : %x , %x\n", ic, check_ic_temporary(ic),
1239 g_keyboard_state.ic, check_ic_temporary(g_keyboard_state.ic),
1240 g_keyboard_state.focused_ic, check_ic_temporary(g_keyboard_state.focused_ic));
1241 if (check_ic_temporary(g_keyboard_state.ic) && !check_ic_temporary(ic)) {
1242 g_keyboard_state.ic = ic;
1244 g_keyboard_state.focused_ic = ic;
1247 static void save_autofill_data()
1252 if (g_autofill_hint == 0)
1255 ime_get_surrounding_text(-1, -1, &text, &cursor);
1256 SECURE_LOGD("surrounding text : %s\n", text);
1259 autofill_save_string((Ecore_IMF_Input_Hints)g_autofill_hint, text);
1265 ise_focus_out(int ic)
1267 g_keyboard_state.focused_ic = 0;
1268 _reset_multitap_state(true);
1270 save_autofill_data();
1273 bool ise_is_guideline_popup_enable_layout(void)
1276 switch (_context_layout)
1278 case ISE_LAYOUT_STYLE_PHONENUMBER:
1279 case ISE_LAYOUT_STYLE_IP:
1280 case ISE_LAYOUT_STYLE_MONTH:
1281 case ISE_LAYOUT_STYLE_NUMBERONLY:
1282 case ISE_LAYOUT_STYLE_HEX:
1283 case ISE_LAYOUT_STYLE_TERMINAL:
1284 case ISE_LAYOUT_STYLE_DATETIME:
1285 case ISE_LAYOUT_STYLE_PASSWORD:
1296 static Eina_Bool popup_guideline_timer_cb(void *data)
1298 if ((!g_config_values.first_guidechange) && (_language_manager.get_enabled_languages_num() > 1)) {
1299 ise_show_help_popup(MVK_space);
1300 g_config_values.first_guidechange = TRUE;
1301 write_ise_config_values();
1304 guideline_timer = NULL;
1305 return ECORE_CALLBACK_CANCEL;
1309 #if EXIT_ISE_ON_HIDE
1310 static Eina_Bool exit_timer_cb(void *data)
1312 if (exit_timer) ecore_timer_del(exit_timer);
1315 return ECORE_CALLBACK_CANCEL;
1322 #if EXIT_ISE_ON_HIDE
1323 if (exit_timer) ecore_timer_del(exit_timer);
1326 sclboolean reset_inputmode = FALSE;
1327 g_input_panel_show = true;
1330 read_ise_config_values();
1332 _language_manager.set_enabled_languages(g_config_values.enabled_languages);
1333 const sclchar *cur_lang = _language_manager.get_current_language();
1336 ise_check_wearable_candidate();
1338 *Clear the personalized data
1340 if (g_config_values.dataclear) {
1341 ime_send_key_event(IME_KEY_Clear, IME_KEY_MASK_CONTROL, false);
1342 g_config_values.dataclear = FALSE;
1345 LOGD("ic : %x , %x , g_ic : %x , %x, g_focused_ic : %x , %x\n", ic, check_ic_temporary(ic),
1346 g_keyboard_state.ic, check_ic_temporary(g_keyboard_state.ic),
1347 g_keyboard_state.focused_ic, check_ic_temporary(g_keyboard_state.focused_ic));
1349 if (check_ic_temporary(ic) && !check_ic_temporary(g_keyboard_state.focused_ic)) {
1350 ic = g_keyboard_state.focused_ic;
1353 if (!check_ic_temporary(ic) && check_ic_temporary(g_keyboard_state.focused_ic)) {
1354 g_keyboard_state.focused_ic = ic;
1357 if (ic == g_keyboard_state.focused_ic) {
1358 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_PHONENUMBER ||
1359 g_keyboard_state.layout == ISE_LAYOUT_STYLE_IP ||
1360 g_keyboard_state.layout == ISE_LAYOUT_STYLE_MONTH ||
1361 g_keyboard_state.layout == ISE_LAYOUT_STYLE_NUMBERONLY) {
1362 ime_set_imengine(DEFAULT_KEYBOARD_ISE_UUID);
1366 /* Reset input mode if the input context value has changed */
1367 if (ic != g_keyboard_state.ic) {
1368 /* Do not reset input mode if STT's setting window was opened */
1369 if (g_setting_window_open_status && strcmp(g_ui->get_input_mode(), "STT_3X4") == 0) {
1370 LOGD("Setting window was opened while using STT, skip resetting input mode");
1372 reset_inputmode = TRUE;
1376 g_keyboard_state.ic = ic;
1377 /* Reset input mode if the current language is not the selected language */
1379 if (g_config_values.selected_language.compare(cur_lang) != 0) {
1380 reset_inputmode = TRUE;
1384 /* No matter what, just reset the inputmode if it needs to */
1385 if (g_keyboard_state.need_reset) {
1386 /* Do not reset input mode if STT's setting window was opened */
1387 if (g_setting_window_open_status && strcmp(g_ui->get_input_mode(), "STT_3X4") == 0) {
1388 LOGD("Setting window was opened while using STT, skip resetting input mode");
1390 reset_inputmode = TRUE;
1393 g_keyboard_state.need_reset = FALSE;
1395 /* If the current layout requires latin language and current our language is not latin, enable the primary latin */
1396 sclboolean force_primary_latin = FALSE;
1397 LANGUAGE_INFO *info = _language_manager.get_language_info(g_config_values.selected_language.c_str());
1399 if (g_ise_default_values[g_keyboard_state.layout].force_latin && !(info->is_latin_language)) {
1400 if (!g_keyboard_state.disable_force_latin) {
1401 force_primary_latin = TRUE;
1405 if (force_primary_latin) {
1406 /* If there is enabled latin-based language, select it */
1407 sclboolean selected = FALSE;
1408 for (scluint loop = 0;!selected && loop < _language_manager.get_languages_num();loop++) {
1409 LANGUAGE_INFO *info = _language_manager.get_language_info(loop);
1411 if (info->enabled && info->is_latin_language) {
1412 selected = _language_manager.select_language(info->name.c_str());
1413 if (selected) force_primary_latin = FALSE;
1418 _language_manager.set_language_enabled_temporarily(PRIMARY_LATIN_LANGUAGE, TRUE);
1422 if (reset_inputmode) {
1423 ise_reset_context();
1425 bool filename_layout = false;
1427 /* Turn the shift state off if we need to reset our input mode, only when auto-capitalization is not set */
1428 if (!(g_keyboard_state.caps_mode)) {
1429 g_ui->set_shift_state(SCL_SHIFT_STATE_OFF);
1431 if (g_keyboard_state.layout < ISE_LAYOUT_STYLE_MAX) {
1432 sclu32 layout_index = g_keyboard_state.layout;
1433 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_NUMBERONLY &&
1434 g_keyboard_state.layout_variation > 0 &&
1435 g_keyboard_state.layout_variation < ISE_LAYOUT_NUMBERONLY_VARIATION_MAX) {
1436 layout_index = ISE_LAYOUT_STYLE_NUMBERONLY_SIG + g_keyboard_state.layout_variation - 1;
1437 } else if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_PASSWORD && g_keyboard_state.layout_variation > 0) {
1438 layout_index = ISE_LAYOUT_STYLE_PASSWD_3X4;
1441 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_NORMAL &&
1442 g_keyboard_state.layout_variation == ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL_VARIATION_FILENAME)
1443 filename_layout = true;
1445 filename_layout = false;
1447 g_ui->enable_button("exclamation", !filename_layout);
1448 g_ui->enable_button("question", !filename_layout);
1449 g_ui->enable_button("divide", !filename_layout);
1450 g_ui->enable_button("multiply", !filename_layout);
1451 g_ui->enable_button("colon", !filename_layout);
1452 g_ui->enable_button("quotation", !filename_layout);
1454 g_ui->enable_button("CM_KEY", !access("/home", X_OK));
1456 LOGD("new layout index : %d\n", layout_index);
1457 /* If this layout requires specific input mode, set it */
1458 if (strlen(g_ise_default_values[layout_index].input_mode) > 0) {
1459 g_ui->set_input_mode(g_ise_default_values[layout_index].input_mode);
1460 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_NONE);
1462 if (force_primary_latin) {
1463 _language_manager.select_language(PRIMARY_LATIN_LANGUAGE, TRUE);
1465 if (!(_language_manager.select_language(g_config_values.selected_language.c_str()))) {
1466 _language_manager.select_language(PRIMARY_LATIN_LANGUAGE);
1470 g_ui->set_cur_sublayout(g_ise_default_values[layout_index].sublayout_name);
1471 if (is_emoticon_show()) {
1472 ise_destroy_emoticon_layout();
1475 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_EMOTICON) {
1476 ise_init_emoticon_list();
1478 current_emoticon_group = EMOTICON_GROUP_1;
1480 if (emoticon_list_recent.size() == 0)
1481 current_emoticon_group = EMOTICON_GROUP_1;
1483 current_emoticon_group = EMOTICON_GROUP_RECENTLY_USED;
1485 SCLRotation rotation = g_ui->get_rotation();
1486 ise_show_emoticon_layout(current_emoticon_group, ROTATION_TO_DEGREE(rotation), false, ime_get_main_window());
1492 if (info->accepts_caps_mode) {
1493 // FIXME this if condition means the AC is off
1494 if (g_keyboard_state.layout != ISE_LAYOUT_STYLE_NORMAL) {
1495 g_ui->set_autocapital_shift_state(TRUE);
1496 g_ui->set_shift_state(SCL_SHIFT_STATE_OFF);
1498 ise_send_event(MVK_Shift_Enable, KEY_MASK_NULL);
1499 // Auto Capital is supported only in normal layout
1500 if (g_keyboard_state.caps_mode) {
1501 g_ui->set_autocapital_shift_state(FALSE);
1505 g_ui->set_autocapital_shift_state(TRUE);
1506 ise_send_event(MVK_Shift_Disable, KEY_MASK_NULL);
1507 g_ui->set_shift_state(SCL_SHIFT_STATE_OFF);
1510 g_ui->set_autocapital_shift_state(TRUE);
1513 // Update CM key button
1514 if (_current_cm_key_id < CM_KEY_LIST_SIZE) {
1515 if (strcmp(_cm_key_list[_current_cm_key_id], USER_KEYSTRING_EMOTICON) == 0) {
1516 if (ise_is_emoticons_disabled())
1517 ise_set_cm_private_key(ise_get_cm_key_id(USER_KEYSTRING_OPTION));
1519 ise_set_cm_private_key(_current_cm_key_id);
1523 // Update space key button
1524 ise_update_space_key();
1527 g_ui->disable_input_events(FALSE);
1529 g_ui->enable_button("CM_KEY", false);
1533 if (ise_is_guideline_popup_enable_layout()) {
1534 guideline_timer = ecore_timer_add(0.1, popup_guideline_timer_cb, NULL);
1539 if (g_config_values.floating_mode != g_floating_mode)
1540 g_floating_mode = g_config_values.floating_mode;
1542 if (g_candidate && g_candidate->get_visible())
1543 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_SHOW);
1545 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_NONE);
1548 g_keyboard_state.visible_state = TRUE;
1552 switch (_context_layout) {
1553 case ISE_LAYOUT_STYLE_PHONENUMBER:
1554 case ISE_LAYOUT_STYLE_IP:
1555 case ISE_LAYOUT_STYLE_MONTH:
1556 case ISE_LAYOUT_STYLE_NUMBERONLY:
1557 case ISE_LAYOUT_STYLE_DATETIME:
1558 case ISE_LAYOUT_STYLE_TERMINAL:
1561 case ISE_LAYOUT_STYLE_EMAIL:
1562 case ISE_LAYOUT_STYLE_URL:
1565 case ISE_LAYOUT_STYLE_PASSWORD:
1566 if (_context_layout == ISE_LAYOUT_STYLE_PASSWORD &&
1567 _context_layout_variation == ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD_VARIATION_NUMBERONLY)
1580 g_ui->get_screen_resolution(&width, &height);
1582 create_indicator_window(width, height);
1583 destroy_indicator_dots();
1586 switch (g_keyboard_state.layout) {
1587 case ISE_LAYOUT_STYLE_NUMBER:
1590 case ISE_LAYOUT_STYLE_HEX:
1593 case ISE_LAYOUT_STYLE_EMOTICON:
1596 case ISE_LAYOUT_STYLE_VOICE:
1597 if (_context_layout == ISE_LAYOUT_STYLE_EMAIL ||
1598 _context_layout == ISE_LAYOUT_STYLE_URL)
1607 create_indicator_dots(dot_num, focus_dot);
1608 show_indicator_window();
1610 hide_indicator_window();
1614 if (g_setting_window_open_status) {
1615 ise_show_stt_mode(NATIVE_WINDOW_CAST(ime_get_main_window()));
1617 g_setting_window_open_status = FALSE;
1619 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_VOICE) {
1620 ise_show_stt_mode(NATIVE_WINDOW_CAST(ime_get_main_window()));
1625 * Sets screen rotation
1628 ise_set_screen_rotation(int degree)
1631 g_ui->set_rotation(DEGREE_TO_SCLROTATION(degree));
1635 g_candidate->rotate(degree);
1636 if (g_softcandidate_show) {
1637 g_candidate->update(g_softcandidate_string);
1643 ise_set_accessibility_state(bool state)
1646 g_ui->enable_tts(state);
1654 /* There's no need to update screen when hiding */
1655 g_ui->set_update_pending(TRUE);
1656 g_ui->disable_input_events(TRUE);
1659 _language_manager.reset_language(g_config_values.selected_language.c_str());
1662 delete_commit_timer();
1663 ise_destory_guideline_popup();
1665 g_keyboard_state.visible_state = FALSE;
1667 _reset_shift_state();
1668 _reset_multitap_state(true);
1670 /* If we were in STT mode, try to reset input mode on our next show event */
1671 if (g_ui && strcmp(g_ui->get_input_mode(), "STT_3X4") == 0 ) {
1672 g_keyboard_state.need_reset = TRUE;
1673 ise_hide_stt_mode();
1676 g_input_panel_show = false;
1677 if (g_softcandidate_show && g_candidate)
1678 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_SHOW);
1680 hide_indicator_window();
1682 #if EXIT_ISE_ON_HIDE
1683 if (exit_timer) ecore_timer_del(exit_timer);
1684 exit_timer = ecore_timer_add(1.0, exit_timer_cb, NULL);
1688 static void ise_keypad_mode_changed_cb(const char *key, void *user_data)
1690 read_ise_keypad_mode();
1693 static void ise_enabled_languages_changed_cb(const char *key, void *user_data)
1695 read_ise_enabled_languages();
1698 static void ise_selected_language_changed_cb(const char *key, void *user_data)
1700 read_ise_selected_language();
1703 static void ise_autocapital_mode_changed_cb(const char *key, void *user_data)
1705 read_ise_autocapital_mode();
1708 static void ise_autopunctuate_mode_changed_cb(const char *key, void *user_data)
1710 read_ise_autopunctuation_mode();
1713 static void ise_sound_mode_changed_cb(const char *key, void *user_data)
1715 read_ise_sound_mode();
1717 g_ui->enable_sound(g_config_values.sound_on);
1720 static void ise_vibration_mode_changed_cb(const char *key, void *user_data)
1722 read_ise_vibration_mode();
1724 g_ui->enable_vibration(g_config_values.vibration_on);
1727 static void ise_character_preview_mode_changed_cb(const char *key, void *user_data)
1729 read_ise_character_preview_mode();
1731 g_ui->enable_magnifier(g_config_values.preview_on);
1734 static void ise_setting_guide_popup_changed_cb(const char *key, void *user_data)
1736 read_ise_setting_guide_popup_mode();
1739 static void ise_language_guide_popup_changed_cb(const char *key, void *user_data)
1741 read_ise_language_guide_popup_mode();
1744 static void ise_floating_mode_changed_cb(const char *key, void *user_data)
1746 read_ise_floating_mode();
1747 g_floating_mode = g_config_values.floating_mode;
1749 ime_set_floating_mode(g_floating_mode);
1750 if (g_candidate && g_floating_mode != g_candidate->get_floating_mode()) {
1751 delete_softcandidate_hide_timer();
1755 create_softcandidate();
1756 if (g_candidate && g_candidate->get_visible()) {
1757 g_softcandidate_show = true;
1758 g_candidate->show();
1759 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_SHOW);
1763 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_NONE);
1775 bindtextdomain(PACKAGE, LOCALEDIR);
1776 textdomain(PACKAGE);
1778 /* Set scl_parser_type
1779 * default type is text xml
1780 * use command: export sclres_type="sclres_binary" to enable use binary resource
1781 * please make sure there is sclresource.bin in resource folder
1782 * Or you can use `xml2binary $resource_dir` to generate the sclresource.bin
1783 * xml2binary is in the libscl-ui-devel package
1785 SCLParserType scl_parser_type = SCL_PARSER_TYPE_XML;
1786 char* sclres_type = getenv("sclres_type");
1787 if (sclres_type != NULL && 0 == strcmp("sclres_binary", sclres_type)) {
1788 scl_parser_type = SCL_PARSER_TYPE_BINARY_XML;
1790 scl_parser_type = SCL_PARSER_TYPE_XML;
1794 if (ime_get_main_window()) {
1795 g_ise_created = true;
1797 sclboolean succeeded = FALSE;
1799 const sclchar *entry_path = MAIN_ENTRY_XML_PATH;
1802 CSCLUtils *utils = CSCLUtils::get_instance();
1804 utils->get_screen_resolution(&nwidth, &nheight);
1806 _language_manager.set_resource_file_path(entry_path);
1807 const sclchar *resource_file_path = _language_manager.get_resource_file_path();
1809 if (resource_file_path) {
1810 if (strlen(resource_file_path) > 0) {
1811 succeeded = g_ui->init(ime_get_main_window(), scl_parser_type, resource_file_path);
1815 g_ui->init(ime_get_main_window(), scl_parser_type, MAIN_ENTRY_XML_PATH);
1818 g_ui->set_longkey_duration(elm_config_longpress_timeout_get() * 1000);
1820 /* Default ISE callback */
1821 g_ui->set_ui_event_callback(&callback);
1823 /* Accumulated customized ISE callbacks, depending on the input modes */
1824 for (scluint loop = 0;loop < _language_manager.get_languages_num();loop++) {
1825 LANGUAGE_INFO *language = _language_manager.get_language_info(loop);
1827 for (scluint inner_loop = 0;inner_loop < language->input_modes.size();inner_loop++) {
1828 INPUT_MODE_INFO &info = language->input_modes.at(inner_loop);
1829 LOGD("Registering callback for input mode %s : %p\n", info.name.c_str(), language->callback);
1830 g_ui->set_ui_event_callback(language->callback, info.name.c_str());
1835 read_ise_config_values();
1836 _language_manager.set_enabled_languages(g_config_values.enabled_languages);
1837 _language_manager.select_language(g_config_values.selected_language.c_str());
1838 vconf_set_bool(VCONFKEY_AUTOCAPITAL_ALLOW_BOOL, g_config_values.auto_capitalise);
1839 vconf_set_bool(VCONFKEY_AUTOPERIOD_ALLOW_BOOL, g_config_values.auto_punctuate);
1840 g_ui->enable_sound(g_config_values.sound_on);
1841 g_ui->enable_vibration(g_config_values.vibration_on);
1842 g_ui->enable_magnifier(g_config_values.preview_on);
1844 g_ui->enable_highlight_ui(TRUE);
1846 g_floating_mode = g_config_values.floating_mode;
1847 ime_set_floating_mode(g_floating_mode);
1850 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_NONE);
1854 preference_is_existing(ISE_CONFIG_KEYPAD_MODE, &exist);
1856 write_ise_config_values();
1858 if (preference_set_changed_cb(ISE_CONFIG_KEYPAD_MODE, ise_keypad_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1859 LOGW("Faild to set ise_keypad_mode_changed_cb()");
1860 if (preference_set_changed_cb(ISE_CONFIG_ENABLED_LANGUAGES, ise_enabled_languages_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1861 LOGW("Faild to set ise_enabled_languages_changed_cb()");
1862 if (preference_set_changed_cb(ISE_CONFIG_SELECTED_LANGUAGE, ise_selected_language_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1863 LOGW("Faild to set ise_selected_language_changed_cb()");
1864 if (preference_set_changed_cb(ISE_CONFIG_AUTO_CAPITALISE, ise_autocapital_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1865 LOGW("Faild to set ise_autocapital_mode_changed_cb()");
1866 if (preference_set_changed_cb(ISE_CONFIG_AUTO_PUNCTUATE, ise_autopunctuate_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1867 LOGW("Faild to set ise_autopunctuate_mode_changed_cb()");
1868 if (preference_set_changed_cb(ISE_CONFIG_SOUND_ON, ise_sound_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1869 LOGW("Faild to set ise_sound_mode_changed_cb()");
1870 if (preference_set_changed_cb(ISE_CONFIG_VIBRATION_ON, ise_vibration_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1871 LOGW("Faild to set ise_vibration_mode_changed_cb()");
1872 if (preference_set_changed_cb(ISE_CONFIG_PREVIEW_ON, ise_character_preview_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1873 LOGW("Faild to set ise_character_preview_mode_changed_cb()");
1874 if (preference_set_changed_cb(ISE_CONFIG_FIRST_GUIDELINE_POPUP_FOR_SETTING, ise_setting_guide_popup_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1875 LOGW("Faild to set ise_setting_guide_popup_changed_cb()");
1876 if (preference_set_changed_cb(ISE_CONFIG_FIRST_GUIDELINE_POPUP_FOR_LANGUAGE_CHANGE, ise_language_guide_popup_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1877 LOGW("Faild to set ise_language_guide_popup_changed_cb()");
1878 if (preference_set_changed_cb(ISE_CONFIG_FLOATING_MODE, ise_floating_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1879 LOGW("Faild to set ise_floating_mode_changed_cb()");
1881 init_recent_used_punctuation();
1887 ise_hide_stt_mode();
1890 LOGD("calling g_ui->fini()\n");
1892 LOGD("deleting g_ui\n");
1903 destroy_indicator_window();
1906 /* This is necessary. If this is not called, 3rd party IME might have auto period input regardless its settings */
1907 vconf_set_bool(VCONFKEY_AUTOPERIOD_ALLOW_BOOL, false);
1909 #if EXIT_ISE_ON_HIDE
1910 if (exit_timer) ecore_timer_del(exit_timer);
1916 ise_app_candidate_show()
1919 if (!g_softcandidate_show) {
1924 delete_softcandidate_hide_timer();
1926 create_softcandidate();
1928 g_softcandidate_show = true;
1930 g_candidate->show();
1931 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_SHOW);
1936 ise_app_candidate_hide()
1940 if (!g_candidate || !g_softcandidate_show) {
1941 LOGD("No candidate\n");
1945 if (g_ic_smartreply != -1 || g_autofill_exist)
1948 add_softcandidate_hide_timer();
1952 void ise_check_wearable_candidate() {
1953 if (!g_config_values.prediction_on) {
1954 ise_app_candidate_hide();
1955 } else if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_PHONENUMBER ||
1956 g_keyboard_state.layout == ISE_LAYOUT_STYLE_VOICE ||
1957 g_keyboard_state.layout == ISE_LAYOUT_STYLE_IP ||
1958 g_keyboard_state.layout == ISE_LAYOUT_STYLE_MONTH ||
1959 g_keyboard_state.layout == ISE_LAYOUT_STYLE_NUMBERONLY ||
1960 g_keyboard_state.layout == ISE_LAYOUT_STYLE_PASSWD_3X4||
1961 g_keyboard_state.layout == ISE_LAYOUT_STYLE_PASSWORD) {
1962 ise_app_candidate_hide();
1964 g_softcandidate_show = true;
1965 ise_app_candidate_show();
1970 // when it is the time to auto_cap, the
1971 // ise_set_caps_mode is called.
1972 // -------------------------------------------------------
1973 // For example: [How are you. Fine.], the
1974 // auto-capital process is as below:
1975 // Note: "["<--this is the beginning,
1976 // "|"<--this is the cursor position
1977 // 1) call ise_set_caps_mode, auto_cap = on
1980 // 2) call ise_set_caps_mode, auto_cap = off
1983 // 3) input: "w are you. "
1984 // result: [How are you. |
1985 // 4) call ise_set_caps_mode, auto_cap = on
1987 // result: [How are you. F
1989 // result: [How are you. Fine.|
1990 // --------------------------------------------------------
1991 // If we want to change the auto_cap, eg,
1992 // if we want to input [How Are you.]
1993 // Note the "Are" is not use auto-capital rule.
1995 // ise_send_event(MVK_Shift_On, SclCoreKeyMask_Null);
1996 // when we are want to input "A"
1997 // following input still has the auto_cap rule.
1999 ise_set_caps_mode(unsigned int mode)
2001 LOGD("caps_mode : %d\n", mode);
2003 g_keyboard_state.caps_mode = TRUE;
2005 g_keyboard_state.caps_mode = FALSE;
2007 g_caps_mode_pending = false;
2008 const sclchar *cur_lang = _language_manager.get_current_language();
2010 LANGUAGE_INFO *info = _language_manager.get_language_info(cur_lang);
2012 if (info->accepts_caps_mode) {
2013 /* If we are inputting multitap character, do not manipulate shift mode */
2014 if (g_keyboard_state.prev_modifier != KEY_MODIFIER_MULTITAP_START &&
2015 g_keyboard_state.prev_modifier != KEY_MODIFIER_MULTITAP_REPEAT) {
2016 set_caps_mode(g_keyboard_state.caps_mode);
2018 g_caps_mode_pending = true;
2019 LOGD("Currently composing multitap string, skipping caps request");
2027 ise_update_cursor_position(int position)
2029 LOGD("cursor position : %d\n", position);
2030 if (g_ui && g_keyboard_state.layout == ISE_LAYOUT_STYLE_URL) {
2033 g_ui->set_string_substitution("www.", ".com");
2035 g_ui->unset_string_substitution("www.");
2041 void ise_set_return_key_type(unsigned int type)
2043 const int BUF_LEN = 256;
2044 char buf[BUF_LEN] = {0};
2048 LOGD("return key type : %d\n", type);
2051 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE:
2052 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_DONE);
2054 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_GO:
2055 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_GO);
2057 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_JOIN:
2058 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_JOIN);
2060 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_LOGIN:
2061 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_LOGIN);
2063 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT:
2064 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_NEXT);
2066 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH:
2067 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_SEARCH);
2069 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEND:
2070 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_SEND);
2072 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SIGNIN:
2073 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_SIGNIN);
2075 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT:
2078 LOGW("Unknown return key type : %d\n", type);
2079 type = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
2083 if (type == ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT) {
2084 g_ui->unset_private_key("Enter");
2087 if (type == ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH) {
2088 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
2089 const_cast<sclchar*>("w_sip_3x4_btn_ic_search.png"),
2090 const_cast<sclchar*>("w_sip_3x4_btn_ic_search_p.png"),
2091 const_cast<sclchar*>("w_sip_3x4_btn_ic_search_d.png")};
2092 g_ui->set_private_key("Enter", const_cast<sclchar*>(""), imagelabel, NULL, 0, const_cast<sclchar*>("Enter"), TRUE);
2097 static sclchar *imagelabel[SCL_BUTTON_STATE_MAX] = {
2098 const_cast<sclchar*>(" "), const_cast<sclchar*>(" "), const_cast<sclchar*>(" ")
2101 g_ui->set_private_key("Enter", buf, imagelabel, NULL, 0, const_cast<sclchar*>("Enter"), TRUE);
2102 LOGD("return key lable : %s\n", buf);
2106 void ise_set_return_key_disable(unsigned int disabled)
2108 LOGD("enable : %d\n", !disabled);
2111 g_ui->enable_button("Done", !disabled);
2114 g_ui->enable_button("Enter", !disabled);
2118 void ise_get_language_locale(char **locale)
2120 LANGUAGE_INFO *info = _language_manager.get_current_language_info();
2122 if (!(info->locale_string.empty())) {
2123 *locale = strdup(info->locale_string.c_str());
2128 void ise_update_table(const vector<string> &vec_str)
2130 if (!g_candidate || !g_softcandidate_show)
2131 create_softcandidate();
2134 g_candidate->update(vec_str);
2138 void ise_process_key_event(scim::KeyEvent& key, sclu32 &ret)
2140 Eina_Bool back_key_pressed = EINA_FALSE;
2141 Eina_Bool back_key_released = EINA_FALSE;
2143 if (key.get_key_string().compare("XF86Back") == 0) {
2144 back_key_pressed = EINA_TRUE;
2145 } else if (key.get_key_string().compare("KeyRelease+XF86Back") == 0) {
2146 back_key_released = EINA_TRUE;
2149 if (back_key_pressed || back_key_released) {
2150 if (g_popup_opened == TRUE) {
2151 if (back_key_released) {
2152 g_ui->close_all_popups();
2162 if (!g_candidate->soft_candidate_flag()) {
2164 if (key.dev_name.compare("ime") != 0) {
2165 ret = (sclu32)g_ui->process_key_event(key.get_key_string().c_str());
2170 ret = g_candidate->soft_candidate_handle_key_event(key.get_key_string().c_str());
2174 /* Process this key event if it was not generated by ime */
2175 if (key.dev_name.compare("ime") != 0) {
2176 ret = (sclu32)g_ui->process_key_event(key.get_key_string().c_str());
2182 /* Process this key event if it was not generated by ime */
2183 if (key.dev_name.compare("ime") != 0) {
2184 ret = (sclu32)g_ui->process_key_event(key.get_key_string().c_str());
2190 static void init_recent_used_punctuation()
2192 if (g_recent_used_punctuation.empty())
2194 g_recent_used_punctuation.push_back("#");
2195 g_recent_used_punctuation.push_back("$");
2196 g_recent_used_punctuation.push_back("%");
2197 g_recent_used_punctuation.push_back("^");
2198 g_recent_used_punctuation.push_back("&");
2202 static void update_recent_used_punctuation(const char * key_value)
2204 if (NULL == key_value)
2208 for (int i = 0; i < 10; ++i)
2211 snprintf(buf, sizeof(buf), "%d", i);
2212 if (strcmp(key_value, buf) == 0)
2217 string strKey = string(key_value);
2218 for (int i = 0; i < MAX_DEFAULT_PUNCTUATION; ++i)
2220 if (0 == strKey.compare(g_default_punctuation[i].c_str()))
2225 vector<string>::iterator iter = g_recent_used_punctuation.begin();
2226 for (; iter != g_recent_used_punctuation.end(); ++iter)
2228 if (0 == strKey.compare(iter->c_str()))
2233 if (iter != g_recent_used_punctuation.end())
2235 g_recent_used_punctuation.erase(iter);
2237 g_recent_used_punctuation.push_back(strKey);
2238 if (g_recent_used_punctuation.size() > MAX_DEFAULT_PUNCTUATION-1)
2240 g_recent_used_punctuation.erase(g_recent_used_punctuation.begin());
2244 static void set_ime_size(bool floating_mode, ISE_CANDIDATE_REQUEST candidate_req)
2249 SclSize size_portrait = g_ui->get_input_mode_size(g_ui->get_input_mode(), DISPLAYMODE_PORTRAIT);
2250 SclSize size_landscape = g_ui->get_input_mode_size(g_ui->get_input_mode(), DISPLAYMODE_LANDSCAPE);
2252 if (floating_mode) {
2253 size_portrait.width *= FLOATING_SCALE_RATE;
2254 size_portrait.height *= FLOATING_SCALE_RATE;
2255 size_landscape.width *= FLOATING_SCALE_RATE;
2256 size_landscape.height *= FLOATING_SCALE_RATE;
2257 switch (candidate_req) {
2258 case ISE_CANDIDATE_REQ_NONE:
2259 if (g_candidate && g_candidate->get_visible()) {
2260 g_ui->set_custom_starting_coordinates(0, FLOATING_TITLE_BAR_HEIGHT + g_candidate->get_height());
2261 size_portrait.height += g_candidate->get_height();
2262 size_landscape.height += g_candidate->get_height();
2264 g_ui->set_custom_starting_coordinates(0, FLOATING_TITLE_BAR_HEIGHT);
2267 case ISE_CANDIDATE_REQ_SHOW:
2268 g_ui->set_custom_starting_coordinates(0, FLOATING_TITLE_BAR_HEIGHT + g_candidate->get_height());
2269 if (g_input_panel_show || g_candidate_more_view) {
2270 size_portrait.height += g_candidate->get_height();
2271 size_landscape.height += g_candidate->get_height();
2273 size_portrait.height = g_candidate->get_height();
2274 size_landscape.height = g_candidate->get_height();
2277 case ISE_CANDIDATE_REQ_HIDE:
2278 g_ui->set_custom_starting_coordinates(0, FLOATING_TITLE_BAR_HEIGHT);
2283 if (g_ui->get_custom_scale_rate_x() != FLOATING_SCALE_RATE || g_ui->get_custom_scale_rate_y() != FLOATING_SCALE_RATE)
2284 g_ui->set_custom_scale_rate(FLOATING_SCALE_RATE, FLOATING_SCALE_RATE);
2286 ime_set_size(size_portrait.width, size_portrait.height + FLOATING_TITLE_BAR_HEIGHT,
2287 size_landscape.width, size_landscape.height + FLOATING_TITLE_BAR_HEIGHT);
2290 ise_destroy_move_handler();
2291 int rotation = elm_win_rotation_get(NATIVE_WINDOW_CAST(ime_get_main_window()));
2292 int handler_width = (rotation == 0 || rotation == 180) ? size_portrait.width : size_landscape.width;
2293 ise_show_move_handler(handler_width, FLOATING_TITLE_BAR_HEIGHT);
2296 switch (candidate_req) {
2297 case ISE_CANDIDATE_REQ_NONE:
2298 if (g_candidate && g_candidate->get_visible()) {
2299 g_ui->set_custom_starting_coordinates(0, g_candidate->get_height());
2300 size_portrait.height += g_candidate->get_height();
2301 size_landscape.height += g_candidate->get_height();
2303 g_ui->set_custom_starting_coordinates(0, 0);
2306 case ISE_CANDIDATE_REQ_SHOW:
2307 g_ui->set_custom_starting_coordinates(0, g_candidate->get_height());
2308 if (g_input_panel_show || g_candidate_more_view) {
2309 size_portrait.height += g_candidate->get_height();
2310 size_landscape.height += g_candidate->get_height();
2312 size_portrait.height = g_candidate->get_height();
2313 size_landscape.height = g_candidate->get_height();
2316 case ISE_CANDIDATE_REQ_HIDE:
2317 g_ui->set_custom_starting_coordinates(0, 0);
2322 if (g_ui->get_custom_scale_rate_x() != 1.0 || g_ui->get_custom_scale_rate_y() != 1.0)
2323 g_ui->set_custom_scale_rate(1.0, 1.0);
2325 ime_set_size(size_portrait.width, size_portrait.height, size_landscape.width, size_landscape.height);
2328 ise_destroy_move_handler();
2333 static void ime_app_create_cb(void *user_data)
2335 #if !(DEFER_ISE_CREATION)
2338 elm_app_name_set(PACKAGE);
2341 cbhm_open_service(&cbhm_handle);
2345 static void ime_app_exit_cb(void *user_data)
2351 cbhm_close_service(cbhm_handle);
2356 static void show_autofill_data(Ecore_IMF_Input_Hints input_hints)
2358 g_autofill_exist = false;
2359 char *text = autofill_get_string(input_hints);
2362 g_autofill_string = string(text);
2365 g_autofill_string = string("");
2367 SECURE_LOGD("autofill string : %s", g_autofill_string.c_str());
2369 if (g_autofill_string.length() > 0) {
2370 g_autofill_exist = true;
2372 ise_app_candidate_show();
2373 update_candidate_table();
2377 static void ime_app_show_cb(int ic, ime_context_h ime_ctx, void *user_data)
2379 Ise_Context iseContext;
2380 bool return_key_state, prediction_allow, password_mode, caps_mode;
2381 ime_layout_variation_e layout_variation;
2386 ime_context_get_layout(ime_ctx, &iseContext.layout);
2388 ime_context_get_layout_variation(ime_ctx, &layout_variation);
2389 iseContext.layout_variation = (int)layout_variation;
2391 ime_context_get_cursor_position(ime_ctx, &iseContext.cursor_pos);
2392 ime_context_get_autocapital_type(ime_ctx, &iseContext.autocapital_type);
2393 ime_context_get_return_key_type(ime_ctx, &iseContext.return_key_type);
2394 ime_context_get_return_key_state(ime_ctx, &return_key_state);
2396 ime_context_get_prediction_mode(ime_ctx, &prediction_allow);
2397 iseContext.prediction_allow = prediction_allow;
2399 ime_context_get_password_mode(ime_ctx, &password_mode);
2400 iseContext.password_mode = password_mode;
2402 ime_context_get_input_hint(ime_ctx, &iseContext.input_hint);
2403 ime_context_get_bidi_direction(ime_ctx, &iseContext.bidi_direction);
2404 ime_context_get_language(ime_ctx, &iseContext.language);
2405 ime_context_get_caps_mode(ime_ctx, &caps_mode);
2406 iseContext.caps_mode = caps_mode;
2408 iseContext.return_key_disabled = return_key_state;
2412 g_autofill_hint = iseContext.input_hint & ECORE_IMF_INPUT_HINT_AUTOFILL_MASK;
2414 LOGD("input hint : %x, autofill hint : %x\n", iseContext.input_hint, g_autofill_hint);
2416 if (g_autofill_hint == 0) {
2417 switch (iseContext.layout) {
2418 case ECORE_IMF_INPUT_PANEL_LAYOUT_EMAIL:
2419 g_autofill_hint = ECORE_IMF_INPUT_HINT_AUTOFILL_EMAIL_ADDRESS;
2421 case ECORE_IMF_INPUT_PANEL_LAYOUT_PHONENUMBER:
2422 g_autofill_hint = ECORE_IMF_INPUT_HINT_AUTOFILL_PHONE;
2429 // show autofill data
2430 show_autofill_data((Ecore_IMF_Input_Hints)g_autofill_hint);
2432 //g_ise_common->set_keyboard_ise_by_uuid(KEYBD_ISE_UUID);
2434 /* Don't update screen until all the information is correctly set */
2436 g_ui->set_update_pending(TRUE);
2438 ise_reset_context(); // reset ISE
2440 /*if (context.language == ECORE_IMF_INPUT_PANEL_LANG_ALPHABET) {
2441 ise_explictly_set_language(PRIMARY_LATIN_LANGUAGE_INDEX);
2444 _context_layout = iseContext.layout;
2445 _context_layout_variation = iseContext.layout_variation;
2446 ise_set_layout(iseContext.layout, iseContext.layout_variation);
2448 ise_set_return_key_type(iseContext.return_key_type);
2449 ise_set_return_key_disable(iseContext.return_key_disabled);
2451 ise_set_caps_mode(iseContext.caps_mode);
2452 ise_update_cursor_position(iseContext.cursor_pos);
2456 /* Now we update the whole screen */
2458 g_ui->set_update_pending(FALSE);
2461 static void ime_app_hide_cb(int ic, void *user_data)
2466 g_set_mime_type = FALSE;
2468 g_ic_smartreply = -1;
2471 static void ime_app_return_key_type_set_cb(Ecore_IMF_Input_Panel_Return_Key_Type type, void *user_data)
2473 LOGD("return key type : %d\n", type);
2474 ise_set_return_key_type(type);
2476 if (g_keyboard_state.visible_state)
2477 ise_show(g_keyboard_state.ic);
2480 static void ime_app_return_key_state_set_cb(bool disabled, void *user_data)
2482 LOGD("return key disabled : %d\n", disabled);
2483 ise_set_return_key_disable(disabled);
2486 static void ime_app_input_context_reset_cb(void *user_data)
2488 ise_reset_input_context();
2491 static void ime_app_cursor_position_updated_cb(int cursor_pos, void *user_data)
2493 LOGD("cursor position : %d\n", cursor_pos);
2494 ise_update_cursor_position(cursor_pos);
2497 static void ime_app_language_requested_cb(void *user_data, char **lang_code)
2499 ise_get_language_locale(lang_code);
2502 static void ime_app_surrounding_text_updated_cb(int context_id, const char *text, int cursor_pos, void *user_data)
2504 SECURE_LOGD("surrounding text:%s, cursor=%d\n", text, cursor_pos);
2505 ime_delete_surrounding_text(-cursor_pos, strlen(text));
2508 static void ime_app_focus_in_cb(int context_id, void *user_data)
2511 ise_focus_in(context_id);
2512 if (!g_smartreply_reply_exist && g_softcandidate_show) {
2514 ise_app_candidate_hide();
2515 g_candidate->hide();
2520 static void ime_app_focus_out_cb(int context_id, void *user_data)
2523 ise_focus_out(context_id);
2526 g_set_mime_type = FALSE;
2528 g_smartreply_reply_exist = false;
2529 g_smartreply_size = 0;
2530 input_smartreply_deinit();
2531 g_ic_smartreply = -1;
2533 g_autofill_exist = false;
2534 g_autofill_hint = 0;
2536 g_app_id = string("");
2537 g_resource_id = string("");
2539 g_autofill_string = string("");
2540 g_smartreply_strings.clear();
2541 g_lookup_table_strings.clear();
2542 g_softcandidate_string.clear();
2545 static void ime_app_layout_set_cb(Ecore_IMF_Input_Panel_Layout layout, void *user_data)
2547 LOGD("layout=%d\n", layout);
2548 /* Check if the layoutIdx is in the valid range */
2549 if ((ISE_LAYOUT)layout < ISE_LAYOUT_STYLE_MAX) {
2550 if (g_keyboard_state.layout != layout) {
2551 g_keyboard_state.need_reset = TRUE;
2553 g_keyboard_state.layout = layout;
2554 _context_layout = layout;
2555 _context_layout_variation = 0;
2557 if (g_keyboard_state.visible_state)
2558 ise_show(g_keyboard_state.ic);
2561 static void ime_app_rotation_degree_changed_cb(int degree, void *user_data)
2563 ise_set_screen_rotation(degree);
2565 LOGD("degree=%d\n", degree);
2567 if (g_floating_mode) {
2569 ise_destroy_move_handler();
2570 if (degree == 0 || degree == 180) {
2571 SclSize size_portrait = g_ui->get_input_mode_size(g_ui->get_input_mode(), DISPLAYMODE_PORTRAIT);
2572 handler_width = size_portrait.width * FLOATING_SCALE_RATE;
2574 SclSize size_landscape = g_ui->get_input_mode_size(g_ui->get_input_mode(), DISPLAYMODE_LANDSCAPE);
2575 handler_width = size_landscape.width * FLOATING_SCALE_RATE;
2577 ise_show_move_handler(handler_width, FLOATING_TITLE_BAR_HEIGHT);
2580 if (is_emoticon_show()) {
2581 ise_destroy_emoticon_layout();
2583 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_VOICE) {
2584 ise_hide_stt_mode();
2586 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_EMOTICON) {
2587 ise_show_emoticon_layout(current_emoticon_group, degree, false, ime_get_main_window());
2589 const sclchar *input_mode = g_ui->get_input_mode();
2591 if (!(strcmp(input_mode, "EMOTICON_LAYOUT")))
2592 ise_show_emoticon_layout(current_emoticon_group, degree, false, ime_get_main_window());
2593 else if (!(strcmp(input_mode, "STT_3X4")))
2594 ise_show_stt_mode(NATIVE_WINDOW_CAST(ime_get_main_window()));
2599 static void ime_app_accessibility_state_changed_cb(bool state, void *user_data)
2601 LOGD("state=%d\n", state);
2602 ise_set_accessibility_state(state);
2605 static void ime_app_imdata_set_cb(void *data, unsigned int data_length, void *user_data)
2609 size_t _len = data_length;
2610 set_ise_imdata((sclchar *)data, _len);
2613 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)
2615 scim::KeyEvent key(keycode, keymask);
2617 char *dev_name = NULL;
2618 Ecore_IMF_Device_Class dev_class;
2619 Ecore_IMF_Device_Subclass dev_subclass;
2621 if (ime_device_info_get_name(dev_info, &dev_name) == IME_ERROR_NONE) {
2622 key.dev_name = dev_name;
2625 if (ime_device_info_get_class(dev_info, &dev_class) == IME_ERROR_NONE) {
2626 key.dev_class = dev_class;
2629 if (ime_device_info_get_subclass(dev_info, &dev_subclass) == IME_ERROR_NONE) {
2630 key.dev_subclass = dev_subclass;
2633 if (g_keyboard_state.visible_state)
2634 ise_process_key_event(key, ret);
2644 static void ime_app_caps_mode_changed_cb(int mode, void *user_data)
2646 ise_set_caps_mode(mode);
2649 static void ime_app_candidate_show_cb(int context_id, void *user_data)
2652 ise_check_wearable_candidate();
2654 ise_app_candidate_show();
2658 static void ime_app_candidate_hide_cb(int context_id, void *user_data)
2661 ise_check_wearable_candidate();
2663 ise_app_candidate_hide();
2667 static void ime_app_lookup_table_changed_cb(Eina_List *list, void *user_data)
2669 vector<string> candidate_strings;
2674 g_lookup_table_strings.clear();
2677 EINA_LIST_FOREACH(list, l, data) {
2678 candidate = (char *)data;
2680 g_lookup_table_strings.push_back(string(candidate));
2681 candidate_strings.push_back(string(candidate));
2686 if (g_smartreply_reply_exist) {
2687 if (candidate_strings[0] == "#" && candidate_strings[1] == "$") {
2690 ime_get_surrounding_text(0, 0, &text, &cursor);
2699 update_candidate_table();
2703 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)
2705 if (device_type == IME_INPUT_DEVICE_TYPE_ROTARY) {
2706 ime_input_device_rotary_direction_e direction;
2707 if (IME_ERROR_NONE == ime_input_device_rotary_get_direction(device_event, &direction)) {
2708 sclu32 new_layout = g_keyboard_state.layout;
2709 if (direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_CLOCKWISE) {
2710 LOGD("CLOCKWISE\n");
2711 switch (g_keyboard_state.layout) {
2712 case ISE_LAYOUT_STYLE_NORMAL:
2713 case ISE_LAYOUT_STYLE_EMAIL:
2714 case ISE_LAYOUT_STYLE_URL:
2715 case ISE_LAYOUT_STYLE_PASSWORD:
2716 if (_context_layout == ISE_LAYOUT_STYLE_PASSWORD &&
2717 _context_layout_variation == ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD_VARIATION_NUMBERONLY)
2718 ; // PASSWORD NUMBER ONLY, do nothing
2720 new_layout = ISE_LAYOUT_STYLE_NUMBER;
2722 case ISE_LAYOUT_STYLE_NUMBER:
2723 new_layout = ISE_LAYOUT_STYLE_HEX;
2725 case ISE_LAYOUT_STYLE_HEX:
2726 if (_context_layout == ISE_LAYOUT_STYLE_EMAIL ||
2727 _context_layout == ISE_LAYOUT_STYLE_URL)
2728 new_layout = ISE_LAYOUT_STYLE_VOICE;
2729 else if (_context_layout == ISE_LAYOUT_STYLE_PASSWORD)
2730 new_layout = _context_layout;
2732 new_layout = ISE_LAYOUT_STYLE_EMOTICON;
2734 case ISE_LAYOUT_STYLE_EMOTICON:
2735 if (_context_layout == ISE_LAYOUT_STYLE_EMAIL ||
2736 _context_layout == ISE_LAYOUT_STYLE_URL ||
2737 _context_layout == ISE_LAYOUT_STYLE_PASSWORD)
2738 new_layout = _context_layout;
2740 new_layout = ISE_LAYOUT_STYLE_VOICE;
2742 case ISE_LAYOUT_STYLE_VOICE:
2743 new_layout = ISE_LAYOUT_STYLE_NORMAL;
2748 } else if (direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_COUNTER_CLOCKWISE) {
2749 LOGD("COUNTER_CLOCKWISE\n");
2750 switch (g_keyboard_state.layout) {
2751 case ISE_LAYOUT_STYLE_NORMAL:
2752 case ISE_LAYOUT_STYLE_EMAIL:
2753 case ISE_LAYOUT_STYLE_URL:
2754 case ISE_LAYOUT_STYLE_PASSWORD:
2755 if (_context_layout == ISE_LAYOUT_STYLE_PASSWORD &&
2756 _context_layout_variation == ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD_VARIATION_NUMBERONLY)
2757 ; // PASSWORD NUMBER ONLY, do nothing
2758 else if (_context_layout == ISE_LAYOUT_STYLE_PASSWORD)
2759 new_layout = ISE_LAYOUT_STYLE_HEX;
2761 new_layout = ISE_LAYOUT_STYLE_VOICE;
2763 case ISE_LAYOUT_STYLE_NUMBER:
2764 if (_context_layout == ISE_LAYOUT_STYLE_EMAIL ||
2765 _context_layout == ISE_LAYOUT_STYLE_URL ||
2766 _context_layout == ISE_LAYOUT_STYLE_PASSWORD)
2767 new_layout = _context_layout;
2769 new_layout = ISE_LAYOUT_STYLE_NORMAL;
2771 case ISE_LAYOUT_STYLE_HEX:
2772 new_layout = ISE_LAYOUT_STYLE_NUMBER;
2774 case ISE_LAYOUT_STYLE_EMOTICON:
2775 new_layout = ISE_LAYOUT_STYLE_HEX;
2777 case ISE_LAYOUT_STYLE_VOICE:
2778 if (_context_layout == ISE_LAYOUT_STYLE_EMAIL ||
2779 _context_layout == ISE_LAYOUT_STYLE_URL)
2780 new_layout = ISE_LAYOUT_STYLE_HEX;
2782 new_layout = ISE_LAYOUT_STYLE_EMOTICON;
2789 if (check_is_tutorial_show()) {
2790 if ((direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_COUNTER_CLOCKWISE && number_tutorial_enable) ||
2791 (direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_CLOCKWISE && symbol_tutorial_enable)) {
2792 new_layout = g_keyboard_state.layout;
2793 } else if (direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_COUNTER_CLOCKWISE && symbol_tutorial_enable) {
2794 ise_destroy_tutorial_mode_popup();
2795 symbol_tutorial_enable = false;
2796 new_layout = ISE_LAYOUT_STYLE_HEX;
2797 } else if (direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_CLOCKWISE && number_tutorial_enable) {
2798 ise_destroy_tutorial_mode_popup();
2799 new_layout = ISE_LAYOUT_STYLE_NUMBER;
2800 symbol_tutorial_enable = true;
2801 number_tutorial_enable = false;
2804 if ((new_layout == ISE_LAYOUT_STYLE_HEX && symbol_tutorial_enable) ||
2805 (new_layout == ISE_LAYOUT_STYLE_NUMBER && number_tutorial_enable)) {
2806 ise_show_tutorial_mode_popup(new_layout);
2807 new_layout = g_keyboard_state.layout;
2811 if (new_layout != g_keyboard_state.layout && new_layout < ISE_LAYOUT_STYLE_MAX) {
2812 g_keyboard_state.need_reset = TRUE;
2813 g_keyboard_state.layout = new_layout;
2815 if (g_keyboard_state.visible_state) {
2816 _reset_multitap_state();
2817 _language_manager.reset_language(g_config_values.selected_language.c_str());
2818 ise_show(g_keyboard_state.ic);
2826 static void ime_app_prediction_hint_set_cb(const char *prediction_hint, void *user_data)
2828 char *sender = (char *)"mms";
2829 char *caller_id = (char *)"mms";
2830 char *hint = (char *)prediction_hint;
2832 if (!prediction_hint) return;
2833 SECURE_LOGD("prediction hint : %s\n", prediction_hint);
2835 if (strlen(prediction_hint) > 0) {
2836 input_smartreply_init(caller_id, sender, hint);
2837 input_smartreply_set_notify(_input_smartreply_notify_cb, NULL);
2839 if (input_smartreply_is_enabled()) {
2840 g_smartreply_size = 0;
2841 g_smartreply_reply_exist = false;
2843 input_smartreply_get_reply_async();
2848 static void ime_app_mime_type_set_request_cb(const char *mime_types, void *user_data)
2850 LOGD("mime type : %s\n", mime_types);
2853 g_set_mime_type = TRUE;
2855 string str(mime_types), text_key = "text/", image_key = "image/";
2857 if (str.find(text_key) != string::npos)
2858 cbhm_sel_type |= CBHM_SEL_TYPE_TEXT;
2860 if (str.find(image_key) != string::npos)
2861 cbhm_sel_type |= CBHM_SEL_TYPE_IMAGE;
2863 LOGD("cbhm_sel_type=0x%x", cbhm_sel_type);
2867 static void ime_app_prediction_hint_data_set_cb(const char *key, const char *value, void *user_data)
2869 SECURE_LOGD("key : %s, value : %s\n", key, value);
2871 if (string(key) == "appid")
2872 g_app_id = string(value ? value : "");
2873 else if (string(key) == "res_id")
2874 g_resource_id = string(value ? value : "");
2880 EXPORTED void ime_app_main(int argc, char **argv)
2882 ime_callback_s basic_callback = {
2889 ime_event_set_focus_in_cb(ime_app_focus_in_cb, NULL);
2890 ime_event_set_focus_out_cb(ime_app_focus_out_cb, NULL);
2891 ime_event_set_rotation_degree_changed_cb(ime_app_rotation_degree_changed_cb, NULL);
2892 ime_event_set_accessibility_state_changed_cb(ime_app_accessibility_state_changed_cb, NULL);
2893 ime_event_set_layout_set_cb(ime_app_layout_set_cb, NULL);
2894 ime_event_set_caps_mode_changed_cb(ime_app_caps_mode_changed_cb, NULL);
2895 ime_event_set_cursor_position_updated_cb(ime_app_cursor_position_updated_cb, NULL);
2896 ime_event_set_surrounding_text_updated_cb(ime_app_surrounding_text_updated_cb, NULL);
2897 ime_event_set_return_key_type_set_cb(ime_app_return_key_type_set_cb, NULL);
2898 ime_event_set_return_key_state_set_cb(ime_app_return_key_state_set_cb, NULL);
2899 ime_event_set_imdata_set_cb(ime_app_imdata_set_cb, NULL);
2900 ime_event_set_process_key_event_cb(ime_app_process_key_event_cb, NULL);
2902 ime_event_set_candidate_show_cb(ime_app_candidate_show_cb, NULL);
2903 ime_event_set_candidate_hide_cb(ime_app_candidate_hide_cb, NULL);
2904 ime_event_set_lookup_table_changed_cb(ime_app_lookup_table_changed_cb, NULL);
2907 ime_event_set_process_input_device_event_cb(ime_app_process_input_device_event_cb, NULL);
2910 ime_event_set_input_context_reset_cb(ime_app_input_context_reset_cb, NULL);
2911 ime_event_set_language_requested_cb(ime_app_language_requested_cb, NULL);
2913 ime_event_set_prediction_hint_set_cb(ime_app_prediction_hint_set_cb, NULL);
2914 ime_event_set_mime_type_set_request_cb(ime_app_mime_type_set_request_cb, NULL);
2915 ime_event_set_prediction_hint_data_set_cb(ime_app_prediction_hint_data_set_cb, NULL);
2917 #if DEFER_ISE_CREATION
2918 ime_set_window_creation_defer_flag(TRUE);
2921 ime_run(&basic_callback, NULL);
2927 EXPORTED int main(int argc, char *argv[])
2929 ime_app_main(argc, argv);