2 * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <sys/types.h>
25 #include <Ecore_IMF.h>
26 #include <Elementary.h>
29 #include <inputmethod.h>
30 #include <inputmethod_internal.h>
31 #include <app_control.h>
32 #include <app_preference.h>
33 #include <ode/internal-encryption.h>
41 #include "languages.h"
42 #include "candidate-factory.h"
43 #include "ise-emoticon-mode.h"
44 #include "ise-stt-mode.h"
45 #include "ise-stt-option.h"
46 #include "ise-language-change.h"
47 #include "ise-tutorial-mode.h"
48 #include "modeindicator.h"
49 #include "w-input-smartreply.h"
50 #include "ise-floating-mode.h"
52 #define EDJ_FILE RESDIR"/edje/mobile/customised_ctxpopup.edj"
54 #define EXIT_ISE_ON_HIDE 0
55 #define DEFER_ISE_CREATION 0
57 #define CANDIDATE_WINDOW_HEIGHT 84
65 static cbhm_h cbhm_handle;
66 static sclu32 cbhm_sel_type = 0;
67 static sclboolean g_set_mime_type = FALSE;
70 int g_imdata_state = 0;
72 extern emoticon_group_t current_emoticon_group;
73 extern std::vector <int> emoticon_list_recent;
75 extern CONFIG_VALUES g_config_values;
76 static sclboolean g_need_send_shift_event = FALSE;
78 extern void set_ise_imdata(const char * buf, size_t &len);
79 static void init_recent_used_punctuation();
80 static void update_recent_used_punctuation(const char *key_value);
81 static void set_ime_size(bool floating_mode, ISE_CANDIDATE_REQUEST candidate_req);
82 static sclboolean g_punctuation_popup_opened = FALSE;
83 static sclboolean g_popup_opened = FALSE;
84 static vector<string> g_recent_used_punctuation;
85 static const int MAX_DEFAULT_PUNCTUATION = 6;
86 static string g_default_punctuation[MAX_DEFAULT_PUNCTUATION] = {"-", "@", "'", "!", "?", ","};
87 static string g_current_punctuation[MAX_DEFAULT_PUNCTUATION-1] = {"RCENT1", "RCENT2", "RCENT3", "RCENT4", "RCENT5"};
88 static vector<string> g_softcandidate_string;
89 static bool g_softcandidate_show = false;
90 static bool g_input_panel_show = false;
91 static bool g_smartreply_reply_exist = false;
92 static unsigned int g_smartreply_size = 0;
93 static bool g_caps_mode_pending = false;
94 static bool g_floating_mode = false;
95 static bool g_candidate_more_view = false;
96 static bool g_ise_created = false;
98 static bool g_autofill_exist = false;
99 static int g_autofill_hint = 0;
100 static string g_autofill_string;
101 static vector<string> g_lookup_table_strings;
102 static vector<string> g_smartreply_strings;
104 static Ecore_Timer *exit_timer = NULL;
107 static string g_app_id;
108 static string g_resource_id;
110 #define SOFT_CANDIDATE_DELETE_TIME (100.0/1000)
111 static Ecore_Timer *g_softcandidate_hide_timer = NULL;
113 extern sclboolean g_setting_window_open_status;
116 static int g_ic_smartreply = -1;
118 KEYBOARD_STATE g_keyboard_state = {
121 ISE_LAYOUT_STYLE_NORMAL,
131 #define ISE_LAYOUT_NUMBERONLY_VARIATION_MAX 4
132 /*static const sclchar *_ise_numberonly_variation_name[ISE_LAYOUT_NUMBERONLY_VARIATION_MAX] = {
133 "DEFAULT", "SIG", "DEC", "SIGDEC"
136 #define SIG_DEC_SIZE 2
137 static scluint _click_count = 0;
138 static const char *_sig_dec[SIG_DEC_SIZE] = {".", "-"};
139 static scluint _sig_dec_event[SIG_DEC_SIZE] = {'.', '-'};
140 static Ecore_Timer *_commit_timer = NULL;
142 static sclu32 _context_layout = ISE_LAYOUT_STYLE_NORMAL;
143 static sclu32 _context_layout_variation = 0;
145 Candidate *g_candidate = NULL;
147 class CandidateEventListener: public EventListener
150 void on_event(const EventDesc &desc)
152 const MultiEventDesc &multidesc = dynamic_cast<const MultiEventDesc &>(desc);
153 switch (multidesc.type) {
154 case MultiEventDesc::CANDIDATE_ITEM_MOUSE_DOWN:
155 if (g_autofill_exist) {
156 if (multidesc.index == 0) {
157 char *text = autofill_get_string(g_app_id.c_str(), g_resource_id.c_str(), (Ecore_IMF_Input_Hints)g_autofill_hint);
159 ise_send_string(text);
162 } else if (multidesc.index < (int)g_smartreply_size + 1) {
163 ise_send_string(g_softcandidate_string[multidesc.index].c_str());
165 ime_select_candidate(multidesc.index - g_smartreply_size - 1);
168 if (multidesc.index < (int)g_smartreply_size)
169 ise_send_string(g_softcandidate_string[multidesc.index].c_str());
171 ime_select_candidate(multidesc.index - g_smartreply_size);
174 case MultiEventDesc::CANDIDATE_MORE_VIEW_SHOW:
175 // when more parts shows, click on the candidate will
176 // not affect the key click event
177 g_candidate_more_view = true;
178 if (!g_input_panel_show)
179 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_SHOW);
181 g_ui->disable_input_events(TRUE);
183 case MultiEventDesc::CANDIDATE_MORE_VIEW_HIDE:
184 g_candidate_more_view = false;
185 if (!g_input_panel_show)
186 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_SHOW);
188 g_ui->disable_input_events(FALSE);
194 static CandidateEventListener g_candidate_event_listener;
196 static ISELanguageManager _language_manager;
197 #define MVK_Shift_L 0xffe1
198 #define MVK_Caps_Lock 0xffe5
199 #define MVK_Shift_Off 0xffe1
200 #define MVK_Shift_On 0xffe2
201 #define MVK_Shift_Lock 0xffe6
202 #define MVK_Shift_Enable 0x9fe7
203 #define MVK_Shift_Disable 0x9fe8
204 #define MVK_space 0x020
205 #define MVK_Done 0xff0d
207 #define CM_KEY_LIST_SIZE 5
208 #define MULTITAP_TIMEOUT 3.0
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_setting = NULL;
221 Evas_Object* _guide_popup_space = NULL;
224 * This callback class will receive all response events from SCL
225 * So you should perform desired tasks in this class.
227 class CUIEventCallback : public ISCLUIEventCallback
230 Ecore_Timer* word_timer = NULL;
231 static Eina_Bool _multi_tap_timer_cb(void *data)
234 ise_send_event(MVK_Done, KEY_MASK_NULL);
235 return ECORE_CALLBACK_CANCEL;
237 SCLEventReturnType on_event_key_clicked(SclUIEventDesc event_desc);
238 SCLEventReturnType on_event_drag_state_changed(SclUIEventDesc event_desc);
239 SCLEventReturnType on_event_notification(SCLUINotiType noti_type, SclNotiDesc *etc_info);
242 static CUIEventCallback callback;
244 static void update_candidate_table()
246 g_softcandidate_string.clear();
247 vector<string>::iterator iter;
249 // add autofill string
250 if (g_autofill_exist)
251 g_softcandidate_string.push_back(g_autofill_string);
253 // add lookup table string(s)
254 iter = g_lookup_table_strings.begin();
255 for (; iter != g_lookup_table_strings.end(); ++iter)
257 g_softcandidate_string.push_back(string(iter->c_str()));
260 ise_update_table(g_softcandidate_string);
263 static void _input_smartreply_notify_cb(void *user_data)
265 g_smartreply_strings.clear();
266 char *candidate = NULL;
268 if (input_smartreply_is_enabled()) {
269 /* Append newly added smartreply list */
270 int len = input_smartreply_get_reply_num();
272 for (int i = 0; i < len; i++) {
274 char *reply = (char *)"";
275 reply = input_smartreply_get_nth_item(i, &type);
278 SECURE_LOGD("SmartReply = [%d] %s", i, reply);
281 g_smartreply_strings.push_back(string(candidate));
287 g_ic_smartreply = g_ic;
288 g_smartreply_reply_exist = true;
290 ise_app_candidate_show();
291 g_softcandidate_string = g_smartreply_strings;
292 ise_update_table(g_softcandidate_string);
298 check_ic_temporary(int ic)
300 if ((ic & 0xFFFF) == 0) {
306 static void _reset_shift_state(void)
309 /* Reset all shift state variables */
310 SCLShiftState old_shift_state = g_ui->get_shift_state();
311 SCLShiftState new_shift_state = SCL_SHIFT_STATE_OFF;
312 if (old_shift_state != new_shift_state) {
313 g_need_send_shift_event = true;
314 g_ui->set_shift_state(new_shift_state);
316 LOGD("Shift state changed from (%d) to (%d)\n", (int)old_shift_state, (int)new_shift_state);
320 static void set_caps_mode(sclboolean mode) {
321 LOGD("mode : %d\n", mode);
323 if (g_ui->get_shift_state() != SCL_SHIFT_STATE_LOCK) {
324 g_ui->set_shift_state(mode ? SCL_SHIFT_STATE_ON : SCL_SHIFT_STATE_OFF);
325 g_ui->set_autocapital_shift_state(!mode);
327 ise_send_event(MVK_Shift_On, KEY_MASK_NULL);
329 ise_send_event(MVK_Shift_Off, KEY_MASK_NULL);
335 static void _reset_multitap_state(bool skip_commit = false)
337 LOGD("g_keyboard_state.prev_modifier : %d", g_keyboard_state.prev_modifier);
338 if (g_keyboard_state.prev_modifier == KEY_MODIFIER_MULTITAP_START ||
339 g_keyboard_state.prev_modifier == KEY_MODIFIER_MULTITAP_REPEAT) {
341 ise_send_string(g_keyboard_state.multitap_value.c_str());
343 ise_update_preedit_string("");
345 g_keyboard_state.multitap_value = "";
346 g_keyboard_state.prev_modifier = KEY_MODIFIER_NONE;
347 if (g_caps_mode_pending) {
348 g_caps_mode_pending = false;
349 set_caps_mode(g_keyboard_state.caps_mode);
353 static void ise_set_cm_private_key(scluint cm_key_id)
355 if (cm_key_id >= CM_KEY_LIST_SIZE || g_ui == NULL) {
356 LOGE("cm_key_id=%d\n", cm_key_id);
360 if (strcmp(_cm_key_list[cm_key_id], USER_KEYSTRING_EMOTICON) == 0) {
361 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
362 const_cast<sclchar*>("icon/54x54/icon_emotion_nor.png"),
363 const_cast<sclchar*>("icon/54x54/icon_emotion_press.png"),
364 const_cast<sclchar*>("icon/54x54/icon_emotion_dim.png")};
365 g_ui->set_private_key("CM_KEY", const_cast<sclchar*>(" "), imagelabel, NULL, 0, const_cast<sclchar*>(USER_KEYSTRING_EMOTICON), TRUE);
366 } else if (strcmp(_cm_key_list[cm_key_id], USER_KEYSTRING_OPTION) == 0) {
367 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
368 const_cast<sclchar*>("icon/54x54/icon_setting_nor.png"),
369 const_cast<sclchar*>("icon/54x54/icon_setting_press.png"),
370 const_cast<sclchar*>("icon/54x54/icon_setting_dim.png")};
371 g_ui->set_private_key("CM_KEY", const_cast<sclchar*>(" "), imagelabel, NULL, 0, const_cast<sclchar*>(USER_KEYSTRING_OPTION), TRUE);
372 } else if (strcmp(_cm_key_list[cm_key_id], USER_KEYSTRING_CLIPBOARD) == 0) {
373 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
374 const_cast<sclchar*>("icon/54x54/icon_clipboard_nor.png"),
375 const_cast<sclchar*>("icon/54x54/icon_clipboard_press.png"),
376 const_cast<sclchar*>("icon/54x54/icon_clipboard_dim.png")};
377 g_ui->set_private_key("CM_KEY", const_cast<sclchar*>(" "), imagelabel, NULL, 0, const_cast<sclchar*>(USER_KEYSTRING_CLIPBOARD), TRUE);
378 } else if (strcmp(_cm_key_list[cm_key_id], USER_KEYSTRING_VOICE) == 0) {
379 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
380 const_cast<sclchar*>("icon/54x54/icon_mic_nor.png"),
381 const_cast<sclchar*>("icon/54x54/icon_mic_press.png"),
382 const_cast<sclchar*>("icon/54x54/icon_mic_dim.png")};
383 g_ui->set_private_key("CM_KEY", const_cast<sclchar*>(" "), imagelabel, NULL, 0, const_cast<sclchar*>(USER_KEYSTRING_VOICE), TRUE);
384 } else if (strcmp(_cm_key_list[cm_key_id], USER_KEYSTRING_FLOATING) == 0) {
385 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
386 const_cast<sclchar*>("icon/54x54/icon_floating_keypad_nor.png"),
387 const_cast<sclchar*>("icon/54x54/icon_floating_keypad_press.png"),
388 const_cast<sclchar*>("icon/54x54/icon_floating_keypad_dim.png")};
389 g_ui->set_private_key("CM_KEY", const_cast<sclchar*>(" "), imagelabel, NULL, 0, const_cast<sclchar*>(USER_KEYSTRING_FLOATING), TRUE);
393 static void ise_update_space_key(void)
396 LOGE("g_ui = NULL\n");
400 scluint num = _language_manager.get_enabled_languages_num();
401 LOGD("language number: %d\n", num);
403 LANGUAGE_INFO *info = _language_manager.get_language_info(_language_manager.get_current_language());
404 if (info && info->enabled) {
406 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
407 const_cast<sclchar*>("w_sip_3x4_btn_ic_space_no_arrow.png"),
408 const_cast<sclchar*>("w_sip_3x4_btn_ic_space_no_arrow.png"),
409 const_cast<sclchar*>("w_sip_3x4_btn_ic_space_no_arrow.png")};
410 g_ui->set_private_key("SPACE_KEY", const_cast<sclchar*>(info->display_name.c_str()), imagelabel, NULL, 0, const_cast<sclchar*>("Space"), TRUE);
412 g_ui->enable_button("SPACE_ARROW_LEFT", false);
413 g_ui->enable_button("SPACE_ARROW_RIGHT", false);
418 g_ui->unset_private_key("SPACE_KEY");
420 g_ui->enable_button("SPACE_ARROW_LEFT", true);
421 g_ui->enable_button("SPACE_ARROW_RIGHT", true);
426 static scluint ise_get_cm_key_id(const sclchar *key_value)
428 for (int i = 0; i < CM_KEY_LIST_SIZE; ++i) {
429 if (0 == strcmp (key_value, _cm_key_list[i]))
435 static bool ise_is_emoticons_disabled(void)
438 sclu32 current_layout = g_keyboard_state.layout;
439 LOGD("layout=%d\n", current_layout);
441 if ((current_layout == ISE_LAYOUT_STYLE_NORMAL) ||
442 (current_layout == ISE_LAYOUT_STYLE_NUMBER) ||
443 (current_layout == ISE_LAYOUT_STYLE_EMOTICON))
446 if (g_imdata_state & IMDATA_ACTION_DISABLE_EMOTICONS)
452 static Eina_Bool softcandidate_hide_timer_callback(void *data)
455 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_HIDE);
459 g_softcandidate_show = false;
461 return ECORE_CALLBACK_CANCEL;
464 static void delete_softcandidate_hide_timer(void)
466 if (g_softcandidate_hide_timer) {
467 ecore_timer_del(g_softcandidate_hide_timer);
468 g_softcandidate_hide_timer = NULL;
472 static void add_softcandidate_hide_timer(void)
474 delete_softcandidate_hide_timer();
475 g_softcandidate_hide_timer = ecore_timer_add(SOFT_CANDIDATE_DELETE_TIME, softcandidate_hide_timer_callback, NULL);
478 static void create_softcandidate(void)
481 g_candidate = CandidateFactory::make_candidate(CANDIDATE_MULTILINE, ime_get_main_window());
483 g_candidate->add_event_listener(&g_candidate_event_listener);
489 * Send the given string to input framework
492 ise_send_string(const sclchar *key_value)
495 if (!check_ic_temporary(g_keyboard_state.ic)) {
496 ic = g_keyboard_state.ic;
498 ime_commit_string(key_value);
499 LOGD("ic : %x, %s\n", ic, key_value);
503 * Send the preedit string to input framework
506 ise_update_preedit_string(const sclchar *str, const sclboolean underline)
509 Eina_List *attr_list = NULL;
510 ime_preedit_attribute *preedit_attr;
512 if (!check_ic_temporary(g_keyboard_state.ic)) {
513 ic = g_keyboard_state.ic;
516 /* Count UTF-8 string length */
518 const sclchar *s = str;
519 while (*s) len += (*s++ & 0xc0) != 0x80;
521 preedit_attr = (ime_preedit_attribute *)calloc(1, sizeof(ime_preedit_attribute));
523 preedit_attr->start = 0;
524 preedit_attr->length = len;
525 preedit_attr->type = IME_ATTR_FONTSTYLE;
526 preedit_attr->value = IME_ATTR_FONTSTYLE_UNDERLINE;
527 attr_list = eina_list_append(attr_list, (void *)preedit_attr);
530 ime_update_preedit_string(str, attr_list);
532 ime_update_preedit_string(str, NULL);
534 LOGD("ic : %x, %s\n", ic, str);
538 * Send the given event to input framework
541 ise_send_event(sclulong key_event, sclulong key_mask)
544 if (!check_ic_temporary(g_keyboard_state.ic)) {
545 ic = g_keyboard_state.ic;
547 ime_send_key_event((ime_key_code_e)key_event, IME_KEY_MASK_PRESSED, false);
548 ime_send_key_event((ime_key_code_e)key_event, IME_KEY_MASK_RELEASED, false);
550 LOGD("ic : %x, %lx\n", (unsigned int)ic, key_event);
554 * Forward the given event to input framework
557 ise_forward_key_event(sclulong key_event)
560 if (!check_ic_temporary(g_keyboard_state.ic)) {
561 ic = g_keyboard_state.ic;
563 ime_send_key_event((ime_key_code_e)key_event, IME_KEY_MASK_PRESSED, true);
564 ime_send_key_event((ime_key_code_e)key_event, IME_KEY_MASK_RELEASED, true);
566 LOGD("ic : %x, %lx\n", (unsigned int)ic, key_event);
570 * @brief Delete commit timer.
574 static void delete_commit_timer(void)
576 if (_commit_timer != NULL) {
577 ecore_timer_del(_commit_timer);
578 _commit_timer = NULL;
583 * @brief Callback function for commit timer.
585 * @param data Data to pass when it is called.
587 * @return ECORE_CALLBACK_CANCEL
589 static Eina_Bool commit_timeout(void *data)
591 if (_commit_timer != NULL) {
592 ime_hide_preedit_string();
593 ise_forward_key_event(_sig_dec_event[(_click_count-1)%SIG_DEC_SIZE]);
596 _commit_timer = NULL;
597 return ECORE_CALLBACK_CANCEL;
601 on_input_mode_changed(const sclchar *key_value, sclulong key_event, sclint key_type)
603 sclboolean ret = FALSE;
607 SECURE_LOGD("key_value : %s\n", key_value);
608 if (strcmp(key_value, "CUR_LANG") == 0) {
609 g_keyboard_state.disable_force_latin = TRUE;
610 ret = _language_manager.select_current_language();
612 if (strcmp(key_value, "NEXT_LANG") == 0) {
613 g_keyboard_state.disable_force_latin = TRUE;
614 ret = _language_manager.select_next_language();
618 const sclchar *cur_lang = _language_manager.get_current_language();
620 LANGUAGE_INFO *info = _language_manager.get_language_info(cur_lang);
622 if (info->accepts_caps_mode) {
623 ise_send_event(MVK_Shift_Enable, KEY_MASK_NULL);
624 set_caps_mode(g_keyboard_state.caps_mode);
626 ise_send_event(MVK_Shift_Disable, KEY_MASK_NULL);
627 g_ui->set_shift_state(SCL_SHIFT_STATE_OFF);
631 if (is_emoticon_show()) {
632 ise_destroy_emoticon_layout();
635 if (!strcmp(key_value, USER_KEYSTRING_EMOTICON)) {
636 ise_init_emoticon_list();
638 current_emoticon_group = EMOTICON_GROUP_1;
640 if (emoticon_list_recent.size() == 0)
641 current_emoticon_group = EMOTICON_GROUP_1;
643 current_emoticon_group = EMOTICON_GROUP_RECENTLY_USED;
645 SCLRotation rotation = g_ui->get_rotation();
646 ise_show_emoticon_layout(current_emoticon_group, ROTATION_TO_DEGREE(rotation), false, ime_get_main_window());
654 static void show_cbhm()
660 ret = cbhm_selection_type_set(cbhm_handle, static_cast<cbhm_sel_type_e>(cbhm_sel_type));
662 ret = cbhm_selection_type_set(cbhm_handle, CBHM_SEL_TYPE_TEXT);
664 if (ret != CBHM_ERROR_NONE)
665 LOGW("Failed to set selection type in cbhm. error : %d\n", ret);
667 ret = cbhm_show(cbhm_handle);
668 if (ret != CBHM_ERROR_NONE)
669 LOGW("cbhm show error : %d\n", ret);
675 SCLEventReturnType CUIEventCallback::on_event_notification(SCLUINotiType noti_type, SclNotiDesc *etc_info)
677 SCLEventReturnType ret = SCL_EVENT_PASS_ON;
678 LOGD("noti type: %d, g_need_send_shift_event: %d\n", noti_type, g_need_send_shift_event);
680 if (noti_type == SCL_UINOTITYPE_SHIFT_STATE_CHANGE) {
681 if (g_need_send_shift_event) {
682 const sclchar *cur_lang = _language_manager.get_current_language();
684 LANGUAGE_INFO *info = _language_manager.get_language_info(cur_lang);
685 SclNotiShiftStateChangeDesc *desc = static_cast<SclNotiShiftStateChangeDesc*>(etc_info);
687 if (info->accepts_caps_mode) {
688 LOGD("shift state: %d\n", desc->shift_state);
689 if (desc->shift_state == SCL_SHIFT_STATE_OFF) {
690 ise_send_event(MVK_Shift_Off, KEY_MASK_NULL);
691 } else if (desc->shift_state == SCL_SHIFT_STATE_ON) {
692 ise_send_event(MVK_Shift_On, KEY_MASK_NULL);
693 } else if (desc->shift_state == SCL_SHIFT_STATE_LOCK) {
694 ise_send_event(MVK_Shift_Lock, KEY_MASK_NULL);
696 ret = SCL_EVENT_PASS_ON;
700 g_need_send_shift_event = FALSE;
702 } else if (noti_type == SCL_UINOTITYPE_POPUP_OPENING) {
703 vector<string>::reverse_iterator iter = g_recent_used_punctuation.rbegin();
705 for (; iter != g_recent_used_punctuation.rend(); ++iter)
708 g_ui->set_string_substitution(g_current_punctuation[punc_pos].c_str(), iter->c_str());
711 SclNotiPopupOpeningDesc *openingDesc = (SclNotiPopupOpeningDesc *)etc_info;
712 if (g_ui && 0 == strcmp(openingDesc->input_mode, "CM_POPUP")) {
713 if (ise_is_emoticons_disabled())
714 g_ui->enable_button("EMOTICON_KEY", false);
716 g_ui->enable_button("EMOTICON_KEY", true);
718 } else if (noti_type == SCL_UINOTITYPE_POPUP_OPENED) {
719 g_popup_opened = TRUE;
720 SclNotiPopupOpenedDesc *openedDesc = (SclNotiPopupOpenedDesc *)etc_info;
721 if (0 == strcmp(openedDesc->input_mode, "PUNCTUATION_POPUP")) {
722 g_punctuation_popup_opened = TRUE;
723 } else if (0 == strcmp(openedDesc->input_mode, "CM_POPUP")) {
724 _cm_popup_opened = TRUE;
726 } else if (noti_type == SCL_UINOTITYPE_POPUP_CLOSED) {
727 g_popup_opened = FALSE;
728 SclNotiPopupClosedDesc *closedDesc = (SclNotiPopupClosedDesc *)etc_info;
729 if (closedDesc && closedDesc->input_mode) {
730 if (0 == strcmp(closedDesc->input_mode, "PUNCTUATION_POPUP")) {
731 g_punctuation_popup_opened = FALSE;
732 } else if (0 == strcmp(closedDesc->input_mode, "CM_POPUP")) {
733 _cm_popup_opened = FALSE;
736 } else if (noti_type == SCL_UINOTITYPE_INPUT_MODE_CHANGE) {
737 SclNotiInputModeChangeDesc *desc = static_cast<SclNotiInputModeChangeDesc*>(etc_info);
739 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_NONE);
741 const char *input_mode = g_ui->get_input_mode();
743 if (strcmp(input_mode, "STT_3X4") == 0 &&
744 strcmp(desc->input_mode, "STT_3X4") != 0) {
747 if (strcmp(input_mode, "STT_3X4") != 0 &&
748 strcmp(desc->input_mode, "STT_3X4") == 0) {
749 ise_show_stt_mode(NATIVE_WINDOW_CAST(ime_get_main_window()));
758 void ise_destory_popup_setting()
760 if (_guide_popup_setting != NULL) {
761 LOGD("destroy setting popup iter\n");
762 evas_object_del(_guide_popup_setting);
763 _guide_popup_setting = NULL;
764 g_config_values.first_guideset = TRUE;
765 write_ise_config_values();
769 void ise_destory_popup_space()
771 if (_guide_popup_space != NULL) {
772 LOGD("destroy space popup iter\n");
773 evas_object_del(_guide_popup_space);
774 _guide_popup_setting = NULL;
775 g_config_values.first_guidechange = TRUE;
776 write_ise_config_values();
780 Evas_Object *open_message_popup(Evas_Object *parentWnd)
782 static Evas_Object *msg_window = NULL;
784 evas_object_del(msg_window);
787 msg_window = elm_win_add(parentWnd, "MCFMessagePopup", ELM_WIN_UTILITY);
790 elm_win_borderless_set(msg_window, EINA_TRUE);
791 elm_win_alpha_set(msg_window, EINA_TRUE);
792 elm_win_title_set(msg_window, "ISF Popup");
793 elm_win_screen_size_get(msg_window, NULL, NULL, &w, &h);
794 elm_win_prop_focus_skip_set(msg_window, TRUE);
795 int rots[4] = {0, 90, 180, 270};
796 elm_win_wm_rotation_available_rotations_set(msg_window, rots, 4);
797 evas_object_resize(msg_window, w, h);
800 int rots[4] = { 0, 90, 180, 270 };
801 elm_win_wm_rotation_available_rotations_set(msg_window, rots, 4);
802 evas_object_show(msg_window);
806 void _guideline_popup_setting_cb(void *data, Evas_Object *obj, void *event_info)
808 evas_object_smart_callback_del(obj, "dismissed", _guideline_popup_setting_cb);
809 evas_object_del(obj);
811 ise_destory_popup_setting();
812 g_config_values.first_guideset = TRUE;
813 write_ise_config_values();
816 void _guideline_popup_space_cb(void *data, Evas_Object *obj, void *event_info)
818 evas_object_smart_callback_del(obj, "dismissed", _guideline_popup_space_cb);
819 evas_object_del(obj);
821 ise_destory_popup_space();
822 g_config_values.first_guidechange = TRUE;
823 write_ise_config_values();
826 void ise_show_help_popup(sclulong keyEvent)
828 char buf[2048] = {0, };
832 SclRectangle rectangle = {0};
833 Evas_Object *ctxpopup = NULL;
834 Elm_Theme *theme = NULL;
837 g_ui->get_screen_resolution(&scr_w, &scr_h);
839 if (keyEvent == MVK_space) {
840 g_config_values.first_guidechange = TRUE;
841 write_ise_config_values();
842 g_ui->get_button_geometry("SPACE_KEY", &rectangle);
843 _guide_popup_space = open_message_popup(NATIVE_WINDOW_CAST(ime_get_main_window()));
845 theme = elm_theme_new();
846 elm_theme_ref_set(theme, NULL);
847 elm_theme_extension_add(theme, EDJ_FILE);
849 ctxpopup = elm_ctxpopup_add(_guide_popup_space);
850 elm_object_theme_set(ctxpopup, theme);
851 evas_object_smart_callback_add(ctxpopup, "dismissed", _guideline_popup_space_cb, (void *)keyEvent);
853 g_config_values.first_guideset = TRUE;
854 write_ise_config_values();
855 g_ui->get_button_geometry("CM_KEY", &rectangle);
856 _guide_popup_setting = open_message_popup(NATIVE_WINDOW_CAST(ime_get_main_window()));
857 theme = elm_theme_new();
858 elm_theme_ref_set(theme, NULL);
859 elm_theme_extension_add(theme, EDJ_FILE);
860 ctxpopup = elm_ctxpopup_add(_guide_popup_setting);
861 elm_object_theme_set(ctxpopup, theme);
862 evas_object_smart_callback_add(ctxpopup, "dismissed", _guideline_popup_setting_cb, (void *)keyEvent);
866 int rotation = elm_win_rotation_get(NATIVE_WINDOW_CAST(ime_get_main_window()));
867 if (rotation == 0 || rotation == 180) {
868 elm_object_style_set(ctxpopup, "customised_guideline_popup");
870 elm_object_style_set(ctxpopup, "customised_guideline_popup_landscape");
873 elm_ctxpopup_direction_priority_set(ctxpopup, ELM_CTXPOPUP_DIRECTION_UP,
874 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
875 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
876 ELM_CTXPOPUP_DIRECTION_UNKNOWN);
878 Evas_Object* text = elm_label_add(ctxpopup);
880 if (keyEvent == MVK_space) {
881 snprintf(buf, sizeof(buf), "<font_style=Regular font_size=%d align=left wrap=mixed color=#000000>%s</>", font_size,
882 dgettext(PACKAGE, "IDS_IME_BODY_SWIPE_THE_SPACE_BAR_LEFT_OR_RIGHT_TO_CHANGE_BETWEEN_LANGUAGES"));
884 snprintf(buf, sizeof(buf), "<font_style=Regular font_size=%d align=left wrap=mixed color=#000000>%s</>", font_size,
885 dgettext(PACKAGE, "IDS_IME_BODY_TAP_AND_HOLD_THIS_KEY_TO_SEE_THE_SYMBOL_LIST_SELECT_ONE_TO_USE_IT_AS_A_SHORTCUT"));
887 elm_object_text_set(text, buf);
888 elm_object_content_set(ctxpopup, text);
889 Evas_Coord x, y, w, h;
890 evas_object_geometry_get(NATIVE_WINDOW_CAST(ime_get_main_window()), &x, &y, &w, &h);
892 if (rotation == 0 || rotation == 180) {
893 elm_label_wrap_width_set(text, (scr_w * 4) / 5);
894 evas_object_size_hint_min_set(ctxpopup, ELM_SCALE_SIZE(scr_w), ELM_SCALE_SIZE(50));
895 evas_object_size_hint_max_set(ctxpopup, ELM_SCALE_SIZE(scr_w), ELM_SCALE_SIZE(600));
896 evas_object_move(ctxpopup, rectangle.x + rectangle.width / 2,
897 (scr_h - h) + rectangle.y - ELM_SCALE_SIZE(5));
899 elm_label_wrap_width_set(text, (scr_h * 4) / 5);
900 evas_object_size_hint_min_set(ctxpopup, ELM_SCALE_SIZE(scr_h), ELM_SCALE_SIZE(50));
901 evas_object_size_hint_max_set(ctxpopup, ELM_SCALE_SIZE(scr_h), ELM_SCALE_SIZE(600));
902 evas_object_move(ctxpopup, rectangle.x + rectangle.width / 2,
903 (scr_w - h)+ rectangle.y - ELM_SCALE_SIZE(5));
905 elm_label_line_wrap_set(text, ELM_WRAP_MIXED);
906 evas_object_show(text);
908 if (keyEvent == MVK_space) {
909 evas_object_layer_set(_guide_popup_space, EVAS_LAYER_MAX);
910 evas_object_show(_guide_popup_space);
912 evas_object_layer_set(_guide_popup_setting, EVAS_LAYER_MAX);
913 evas_object_show(_guide_popup_setting);
916 evas_object_layer_set(ctxpopup, EVAS_LAYER_MAX);
917 evas_object_show(ctxpopup);
920 SCLEventReturnType CUIEventCallback::on_event_drag_state_changed(SclUIEventDesc event_desc)
922 LOGD("button %s is clicked\n", event_desc.key_value);
923 if (event_desc.event_type == EVENT_TYPE_MOVE) {
924 if (event_desc.key_event == MVK_space) {
925 SclRectangle rectangle = {0};
926 g_ui->get_button_geometry("SPACE_KEY", &rectangle);
927 ise_show_space_flick_language_change_popup(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
929 } else if (event_desc.event_type == EVENT_TYPE_RELEASE) {
930 if (event_desc.key_event == MVK_space) {
931 ise_destroy_space_flick_language_change_popup();
935 ime_set_floating_drag_end();
936 } else if (event_desc.event_type == EVENT_TYPE_PRESS) {
938 if ((!g_config_values.first_guideset) && (strncmp(event_desc.key_value, "OPTION", strlen(event_desc.key_value)) == 0)) {
939 ise_show_help_popup(event_desc.key_event);//show help popup in on_event_drag_state_changed other than on_event_key_clicked for fixing help popup show delay issue
940 LOGD("setting popup show\n");
941 return SCL_EVENT_PASS_ON;
943 ise_destory_popup_setting();//destory popup manually in case of abormal situation
946 if (g_floating_mode && event_desc.mouse_current_point.y <= FLOATING_TITLE_BAR_HEIGHT
947 && event_desc.mouse_current_point.y >= 0)
948 ime_set_floating_drag_start();
950 return SCL_EVENT_PASS_ON;
953 static void launch_option()
955 app_control_h app_control;
956 int ret = app_control_create(&app_control);
957 if (ret != APP_CONTROL_ERROR_NONE) {
958 LOGW("app_control_create returned %d\n", ret);
962 ret = app_control_set_operation(app_control, APP_CONTROL_OPERATION_DEFAULT);
963 if (ret != APP_CONTROL_ERROR_NONE) {
964 LOGW("app_control_set_operation returned %d\n", ret);
968 ret = app_control_set_app_id(app_control, "org.tizen.ise-default-setting");
969 if (ret != APP_CONTROL_ERROR_NONE) {
970 LOGW("app_control_set_app_id returned %d\n", ret);
974 app_control_add_extra_data(app_control, "caller", "ise-default");
975 app_control_set_launch_mode(app_control, APP_CONTROL_LAUNCH_MODE_GROUP);
977 ret = app_control_send_launch_request(app_control, NULL, NULL);
978 if (ret != APP_CONTROL_ERROR_NONE) {
984 app_control_destroy(app_control);
987 SCLEventReturnType CUIEventCallback::on_event_key_clicked(SclUIEventDesc event_desc)
989 SCLEventReturnType ret = SCL_EVENT_PASS_ON;
990 if (word_timer != NULL) {
991 ecore_timer_del(word_timer);
994 if (event_desc.key_modifier == KEY_MODIFIER_MULTITAP_START) {
995 if (!g_keyboard_state.multitap_value.empty()) {
996 ise_send_string(g_keyboard_state.multitap_value.c_str());
998 ise_update_preedit_string(event_desc.key_value);
999 g_keyboard_state.multitap_value = event_desc.key_value;
1000 } else if (event_desc.key_modifier == KEY_MODIFIER_MULTITAP_REPEAT) {
1001 ise_update_preedit_string(event_desc.key_value);
1002 g_keyboard_state.multitap_value = event_desc.key_value;
1004 _reset_multitap_state();
1006 g_keyboard_state.prev_modifier = event_desc.key_modifier;
1009 switch (event_desc.key_type) {
1010 case KEY_TYPE_STRING: {
1011 if (event_desc.key_modifier != KEY_MODIFIER_MULTITAP_START &&
1012 event_desc.key_modifier != KEY_MODIFIER_MULTITAP_REPEAT) {
1013 if (event_desc.key_event) {
1014 ise_forward_key_event(event_desc.key_event);
1016 ise_send_string(event_desc.key_value);
1019 if (!g_popup_opened) {
1020 const sclchar *input_mode = g_ui->get_input_mode();
1021 if (input_mode && ((0 == strcmp(input_mode, "SYM_QTY_1")) || (0 == strcmp(input_mode, "SYM_QTY_2")))) {
1022 update_recent_used_punctuation(event_desc.key_value);
1024 } else if (g_punctuation_popup_opened) {
1025 update_recent_used_punctuation(event_desc.key_value);
1029 case KEY_TYPE_CHAR: {
1030 sclboolean need_forward = FALSE;
1031 // FIXME : Should decide when to forward key events
1032 const sclchar *input_mode = g_ui->get_input_mode();
1034 if (strcmp(input_mode, "SYM_QTY_1") == 0 ||
1035 strcmp(input_mode, "SYM_QTY_2") == 0 ||
1036 strcmp(input_mode, "PHONE_3X4") == 0 ||
1037 strcmp(input_mode, "IPv6_3X4_123") == 0 ||
1038 strcmp(input_mode, "IPv6_3X4_ABC") == 0 ||
1039 strcmp(input_mode, "NUMONLY_3X4") == 0 ||
1040 strcmp(input_mode, "NUMONLY_3X4_SIG") == 0 ||
1041 strcmp(input_mode, "NUMONLY_3X4_DEC") == 0 ||
1042 strcmp(input_mode, "NUMONLY_3X4_SIGDEC") == 0 ||
1043 strcmp(input_mode, "DATETIME_3X4") == 0) {
1044 need_forward = TRUE;
1047 if (input_mode && strcmp (input_mode, "NUMONLY_3X4_SIGDEC") == 0 &&
1048 strcmp(event_desc.key_value, ".") == 0) {
1049 ime_update_preedit_string(_sig_dec[_click_count%SIG_DEC_SIZE], NULL);
1050 ime_show_preedit_string();
1051 delete_commit_timer();
1052 _commit_timer = ecore_timer_add(1.0, commit_timeout, NULL);
1054 } else if (event_desc.key_event) {
1055 commit_timeout(NULL);
1057 ise_forward_key_event(event_desc.key_event);
1059 if (_cm_popup_opened) {
1060 static sclchar current_cm_symbol[2] = {'\0'};
1061 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
1062 const_cast<sclchar*>(" "),
1063 const_cast<sclchar*>(" "),
1064 const_cast<sclchar*>(" ")};
1065 if (event_desc.key_value) {
1066 current_cm_symbol[0] = event_desc.key_value[0];
1067 current_cm_symbol[1] = '\0';
1069 g_ui->set_private_key("CM_KEY",
1070 const_cast<sclchar*>(current_cm_symbol),
1071 imagelabel, NULL, 0,
1072 const_cast<sclchar*>(current_cm_symbol), TRUE);
1074 _cm_popup_opened = FALSE;
1075 _current_cm_key_id = -1;
1080 *change the keyboard mode of GLM from QWERTY to KEYPAD
1081 *ensure the Number keypad won't be affected
1084 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_NUMBER) {
1085 ime_send_key_event(IME_KEY_Print, IME_KEY_MASK_CONTROL, false);
1087 if (word_timer == NULL && (!g_candidate || !g_softcandidate_show)) {
1088 word_timer = ecore_timer_add(MULTITAP_TIMEOUT, _multi_tap_timer_cb, NULL);
1090 ime_send_key_event(IME_KEY_Select, IME_KEY_MASK_CONTROL, false);
1093 ise_send_event(event_desc.key_event, KEY_MASK_NULL);
1097 if ((strcmp(input_mode, "SYM_QTY_1") == 0) || (0 == strcmp(input_mode, "SYM_QTY_2"))) {
1098 update_recent_used_punctuation(event_desc.key_value);
1103 case KEY_TYPE_CONTROL: {
1104 commit_timeout(NULL);
1106 const char *long_shift = "LongShift";
1107 const char *caps_lock = "CapsLock";
1108 const char *delete_all = "DeleteAll";
1109 const char *hide_panel = "Hide";
1110 if (strncmp(event_desc.key_value, long_shift, strlen(long_shift)) == 0) {
1111 LOGD("shift key is longpress\n");
1112 g_ui->set_shift_state(SCL_SHIFT_STATE_ON);
1113 g_need_send_shift_event = TRUE;
1114 //ise_send_event (MVK_Shift_Lock, KEY_MASK_NULL);
1115 } else if (strncmp(event_desc.key_value, caps_lock, strlen(caps_lock)) == 0) {
1116 if (g_ui->get_shift_state() != SCL_SHIFT_STATE_LOCK) {
1117 g_ui->set_shift_state(SCL_SHIFT_STATE_LOCK);
1118 ise_send_event(MVK_Shift_Lock, KEY_MASK_NULL);
1120 g_ui->set_shift_state(SCL_SHIFT_STATE_OFF);
1121 ise_send_event(MVK_Shift_Off, KEY_MASK_NULL);
1123 //g_need_send_shift_event = TRUE;
1124 } else if (strncmp(event_desc.key_value, delete_all, strlen(delete_all)) == 0) {
1125 ime_delete_surrounding_text((INT_MAX / 2) * -1, INT_MAX);
1126 } else if (strncmp(event_desc.key_value, hide_panel, strlen(hide_panel)) == 0) {
1129 } else if (event_desc.key_event) {
1130 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_VOICE) {
1134 if (event_desc.key_event == MVK_Done) {
1136 //commit the preedit string first
1137 ise_send_event(event_desc.key_event, KEY_MASK_NULL);
1140 ise_send_event(event_desc.key_event, KEY_MASK_NULL);
1141 if (event_desc.key_event == MVK_Shift_L) {
1142 g_need_send_shift_event = TRUE;
1147 case KEY_TYPE_MODECHANGE:
1149 if (_guide_popup_setting != NULL) {//popup is showing
1153 if (strcmp(event_desc.key_value, USER_VOICE_LANGUAGE) == 0) {
1154 if (!g_setting_window_open_status) {
1155 ise_hide_stt_mode();
1157 hide_indicator_window();
1159 create_setting_window();
1161 } else if (strcmp(event_desc.key_value, USER_KEYSTRING_VOICE) == 0) {
1162 g_keyboard_state.layout = ISE_LAYOUT_STYLE_VOICE;
1163 g_ui->set_input_mode("STT_3X4");
1165 } else if (strcmp(event_desc.key_value, USER_KEYSTRING_OPTION) == 0) {
1168 ret = SCL_EVENT_DONE;
1169 } else if (strcmp(event_desc.key_value, USER_KEYSTRING_CLIPBOARD) == 0) {
1172 ret = SCL_EVENT_DONE;
1173 } else if (strcmp(event_desc.key_value, USER_KEYSTRING_FLOATING) == 0) {
1174 if (g_floating_mode)
1175 g_config_values.floating_mode = false;
1177 g_config_values.floating_mode = true;
1178 write_ise_config_values();
1180 ret = SCL_EVENT_DONE;
1181 } else if (on_input_mode_changed(event_desc.key_value, event_desc.key_event, event_desc.key_type)) {
1182 ret = SCL_EVENT_DONE;
1184 if (_cm_popup_opened) {
1185 if (strcmp(event_desc.key_value, USER_KEYSTRING_EMOTICON) == 0 ||
1186 strcmp(event_desc.key_value, USER_KEYSTRING_VOICE) == 0 ||
1187 strcmp(event_desc.key_value, USER_KEYSTRING_FLOATING) == 0) {
1188 scluint id = ise_get_cm_key_id(event_desc.key_value);
1189 if (id != _current_cm_key_id) {
1190 _current_cm_key_id = id;
1191 ise_set_cm_private_key(_current_cm_key_id);
1194 _cm_popup_opened = FALSE;
1196 if (strlen(event_desc.key_value) == 1) {
1197 const char allowed_chars_in_modechange[] = {
1198 ',', '?', '!', '`', '~'
1200 const int allowed_chars_in_modechange_num =
1201 sizeof(allowed_chars_in_modechange) / sizeof(char);
1202 for (unsigned int loop = 0;loop < sizeof(allowed_chars_in_modechange_num);loop++) {
1203 if (*(event_desc.key_value) == allowed_chars_in_modechange[loop]) {
1204 ise_send_string(event_desc.key_value);
1210 if (strcmp(event_desc.key_value, USER_KEYSTRING_OPTION) == 0) {
1211 //open_option_window(NULL, ROTATION_TO_DEGREE(g_ui->get_rotation()));
1214 ret = SCL_EVENT_DONE;
1215 } else if (strcmp(event_desc.key_value, USER_KEYSTRING_CLIPBOARD) == 0) {
1217 ret = SCL_EVENT_DONE;
1218 } else if (strcmp(event_desc.key_value, "Cancel") == 0) {
1219 ret = SCL_EVENT_DONE;
1220 const sclchar *input_mode = g_ui->get_input_mode();
1221 if (input_mode && strcmp(input_mode, "STT_3X4") == 0 ) {
1222 g_keyboard_state.need_reset = TRUE;
1223 voice_result_string_flush();
1224 ise_set_layout(g_keyboard_state.layout, g_keyboard_state.layout_variation);
1225 if (g_keyboard_state.visible_state)
1226 ise_show(g_keyboard_state.ic);
1228 ise_send_event(IME_KEY_Cancel, KEY_MASK_NULL);
1230 } else if (strcmp(event_desc.key_value, "Done") == 0) {
1231 ret = SCL_EVENT_DONE;
1232 ise_send_event(IME_KEY_Return, KEY_MASK_NULL);
1235 const sclchar *input_mode = g_ui->get_input_mode();
1236 if ((NULL != input_mode) && (!strcmp(input_mode, "EMOTICON_LAYOUT"))) {
1237 if (is_emoticon_show()) {
1238 ise_destroy_emoticon_layout();
1241 emoticon_group_t group_id = EMOTICON_GROUP_1;
1242 if (current_emoticon_group < EMOTICON_GROUP_3)
1243 group_id = (emoticon_group_t)(current_emoticon_group + 1);
1245 ise_set_emoticon_label(group_id);
1247 emoticon_group_t group_id = ise_get_emoticon_group_id(event_desc.key_value);
1249 if ((group_id >= 0) && (group_id < MAX_EMOTICON_GROUP)) {
1250 SCLRotation rotation = g_ui->get_rotation();
1251 ise_show_emoticon_layout(group_id, ROTATION_TO_DEGREE(rotation), false, ime_get_main_window());
1255 if (_cm_popup_opened) {
1256 if (strcmp(event_desc.key_value, USER_KEYSTRING_OPTION) == 0 ||
1257 strcmp(event_desc.key_value, USER_KEYSTRING_CLIPBOARD) == 0) {
1258 scluint id = ise_get_cm_key_id(event_desc.key_value);
1259 if (id != _current_cm_key_id) {
1260 _current_cm_key_id = id;
1261 ise_set_cm_private_key(_current_cm_key_id);
1264 _cm_popup_opened = FALSE;
1276 ise_set_layout(sclu32 layout, sclu32 layout_variation)
1278 /* Check if the layoutIdx is in the valid range */
1279 if (layout < ISE_LAYOUT_STYLE_MAX) {
1280 if (g_keyboard_state.layout != layout ||
1281 g_keyboard_state.layout_variation != layout_variation) {
1282 g_keyboard_state.need_reset = TRUE;
1284 g_keyboard_state.layout = layout;
1285 g_keyboard_state.layout_variation = layout_variation;
1286 LOGD("layout:%d, variation:%d\n", g_keyboard_state.layout, g_keyboard_state.layout_variation);
1294 _reset_multitap_state(true);
1295 _language_manager.reset_language(g_config_values.selected_language.c_str());
1299 ise_reset_input_context()
1302 _reset_multitap_state(true);
1303 g_keyboard_state.disable_force_latin = FALSE;
1304 _language_manager.reset_language(g_config_values.selected_language.c_str());
1308 ise_focus_in(int ic)
1310 LOGD("ic : %x , %x , g_ic : %x , %x, g_focused_ic : %x , %x\n", ic, check_ic_temporary(ic),
1311 g_keyboard_state.ic, check_ic_temporary(g_keyboard_state.ic),
1312 g_keyboard_state.focused_ic, check_ic_temporary(g_keyboard_state.focused_ic));
1313 if (check_ic_temporary(g_keyboard_state.ic) && !check_ic_temporary(ic)) {
1314 g_keyboard_state.ic = ic;
1316 g_keyboard_state.focused_ic = ic;
1319 static void save_autofill_data()
1324 if (g_autofill_hint == 0)
1327 ime_get_surrounding_text(-1, -1, &text, &cursor);
1328 SECURE_LOGD("surrounding text : %s\n", text);
1331 autofill_save_string(g_app_id.c_str(), g_resource_id.c_str(), (Ecore_IMF_Input_Hints)g_autofill_hint, text);
1337 ise_focus_out(int ic)
1339 g_keyboard_state.focused_ic = 0;
1340 _reset_multitap_state(true);
1342 save_autofill_data();
1345 bool ise_is_guideline_popup_enable_layout(void)
1348 switch (_context_layout)
1350 case ISE_LAYOUT_STYLE_PHONENUMBER:
1351 case ISE_LAYOUT_STYLE_IP:
1352 case ISE_LAYOUT_STYLE_MONTH:
1353 case ISE_LAYOUT_STYLE_NUMBERONLY:
1354 case ISE_LAYOUT_STYLE_HEX:
1355 case ISE_LAYOUT_STYLE_TERMINAL:
1356 case ISE_LAYOUT_STYLE_DATETIME:
1357 case ISE_LAYOUT_STYLE_PASSWORD:
1367 #if EXIT_ISE_ON_HIDE
1368 static Eina_Bool exit_timer_cb(void *data)
1370 if (exit_timer) ecore_timer_del(exit_timer);
1373 return ECORE_CALLBACK_CANCEL;
1380 #if EXIT_ISE_ON_HIDE
1381 if (exit_timer) ecore_timer_del(exit_timer);
1384 sclboolean reset_inputmode = FALSE;
1385 g_input_panel_show = true;
1388 read_ise_config_values();
1390 _language_manager.set_enabled_languages(g_config_values.enabled_languages);
1391 const sclchar *cur_lang = _language_manager.get_current_language();
1394 ise_check_wearable_candidate();
1396 *Clear the personalized data
1398 if (g_config_values.dataclear) {
1399 ime_send_key_event(IME_KEY_Clear, IME_KEY_MASK_CONTROL, false);
1400 g_config_values.dataclear = FALSE;
1403 LOGD("ic : %x , %x , g_ic : %x , %x, g_focused_ic : %x , %x\n", ic, check_ic_temporary(ic),
1404 g_keyboard_state.ic, check_ic_temporary(g_keyboard_state.ic),
1405 g_keyboard_state.focused_ic, check_ic_temporary(g_keyboard_state.focused_ic));
1407 if (check_ic_temporary(ic) && !check_ic_temporary(g_keyboard_state.focused_ic)) {
1408 ic = g_keyboard_state.focused_ic;
1411 if (!check_ic_temporary(ic) && check_ic_temporary(g_keyboard_state.focused_ic)) {
1412 g_keyboard_state.focused_ic = ic;
1415 if (ic == g_keyboard_state.focused_ic) {
1416 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_PHONENUMBER ||
1417 g_keyboard_state.layout == ISE_LAYOUT_STYLE_IP ||
1418 g_keyboard_state.layout == ISE_LAYOUT_STYLE_MONTH ||
1419 g_keyboard_state.layout == ISE_LAYOUT_STYLE_NUMBERONLY) {
1420 ime_set_imengine(DEFAULT_KEYBOARD_ISE_UUID);
1424 const char *input_mode = g_ui->get_input_mode();
1426 /* Reset input mode if the input context value has changed */
1427 if (ic != g_keyboard_state.ic) {
1428 /* Do not reset input mode if STT's setting window was opened */
1429 if (g_setting_window_open_status && input_mode && strcmp(input_mode, "STT_3X4") == 0) {
1430 LOGD("Setting window was opened while using STT, skip resetting input mode");
1432 reset_inputmode = TRUE;
1436 g_keyboard_state.ic = ic;
1437 /* Reset input mode if the current language is not the selected language */
1439 if (g_config_values.selected_language.compare(cur_lang) != 0) {
1440 reset_inputmode = TRUE;
1444 /* No matter what, just reset the inputmode if it needs to */
1445 if (g_keyboard_state.need_reset) {
1446 /* Do not reset input mode if STT's setting window was opened */
1447 if (g_setting_window_open_status && input_mode && strcmp(input_mode, "STT_3X4") == 0) {
1448 LOGD("Setting window was opened while using STT, skip resetting input mode");
1450 reset_inputmode = TRUE;
1453 g_keyboard_state.need_reset = FALSE;
1455 /* If the current layout requires latin language and current our language is not latin, enable the primary latin */
1456 sclboolean force_primary_latin = FALSE;
1457 LANGUAGE_INFO *info = _language_manager.get_language_info(g_config_values.selected_language.c_str());
1459 if (g_ise_default_values[g_keyboard_state.layout].force_latin && !(info->is_latin_language)) {
1460 if (!g_keyboard_state.disable_force_latin) {
1461 force_primary_latin = TRUE;
1465 if (force_primary_latin) {
1466 /* If there is enabled latin-based language, select it */
1467 sclboolean selected = FALSE;
1468 for (scluint loop = 0;!selected && loop < _language_manager.get_languages_num();loop++) {
1469 LANGUAGE_INFO *info = _language_manager.get_language_info(loop);
1471 if (info->enabled && info->is_latin_language) {
1472 selected = _language_manager.select_language(info->name.c_str());
1473 if (selected) force_primary_latin = FALSE;
1478 _language_manager.set_language_enabled_temporarily(PRIMARY_LATIN_LANGUAGE, TRUE);
1482 if (reset_inputmode) {
1483 ise_reset_context();
1485 bool filename_layout = false;
1487 /* Turn the shift state off if we need to reset our input mode, only when auto-capitalization is not set */
1488 if (!(g_keyboard_state.caps_mode)) {
1489 g_ui->set_shift_state(SCL_SHIFT_STATE_OFF);
1491 if (g_keyboard_state.layout < ISE_LAYOUT_STYLE_MAX) {
1492 sclu32 layout_index = g_keyboard_state.layout;
1493 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_NUMBERONLY &&
1494 g_keyboard_state.layout_variation > 0 &&
1495 g_keyboard_state.layout_variation < ISE_LAYOUT_NUMBERONLY_VARIATION_MAX) {
1496 layout_index = ISE_LAYOUT_STYLE_NUMBERONLY_SIG + g_keyboard_state.layout_variation - 1;
1497 } else if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_PASSWORD && g_keyboard_state.layout_variation > 0) {
1498 layout_index = ISE_LAYOUT_STYLE_PASSWD_3X4;
1501 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_NORMAL &&
1502 g_keyboard_state.layout_variation == ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL_VARIATION_FILENAME)
1503 filename_layout = true;
1505 filename_layout = false;
1507 g_ui->enable_button("exclamation", !filename_layout);
1508 g_ui->enable_button("question", !filename_layout);
1509 g_ui->enable_button("divide", !filename_layout);
1510 g_ui->enable_button("multiply", !filename_layout);
1511 g_ui->enable_button("colon", !filename_layout);
1512 g_ui->enable_button("quotation", !filename_layout);
1514 g_ui->enable_button("CM_KEY", !access("/home", X_OK));
1516 LOGD("new layout index : %d\n", layout_index);
1517 /* If this layout requires specific input mode, set it */
1518 if (strlen(g_ise_default_values[layout_index].input_mode) > 0) {
1519 g_ui->set_input_mode(g_ise_default_values[layout_index].input_mode);
1520 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_NONE);
1522 if (force_primary_latin) {
1523 _language_manager.select_language(PRIMARY_LATIN_LANGUAGE, TRUE);
1525 if (!(_language_manager.select_language(g_config_values.selected_language.c_str()))) {
1526 _language_manager.select_language(PRIMARY_LATIN_LANGUAGE);
1530 g_ui->set_cur_sublayout(g_ise_default_values[layout_index].sublayout_name);
1531 if (is_emoticon_show()) {
1532 ise_destroy_emoticon_layout();
1535 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_EMOTICON) {
1536 ise_init_emoticon_list();
1538 current_emoticon_group = EMOTICON_GROUP_1;
1539 ise_set_emoticon_label(1);
1541 if (emoticon_list_recent.size() == 0)
1542 current_emoticon_group = EMOTICON_GROUP_1;
1544 current_emoticon_group = EMOTICON_GROUP_RECENTLY_USED;
1546 SCLRotation rotation = g_ui->get_rotation();
1547 ise_show_emoticon_layout(current_emoticon_group, ROTATION_TO_DEGREE(rotation), false, ime_get_main_window());
1553 if (info->accepts_caps_mode) {
1554 // FIXME this if condition means the AC is off
1555 if (g_keyboard_state.layout != ISE_LAYOUT_STYLE_NORMAL) {
1556 g_ui->set_autocapital_shift_state(TRUE);
1557 g_ui->set_shift_state(SCL_SHIFT_STATE_OFF);
1559 ise_send_event(MVK_Shift_Enable, KEY_MASK_NULL);
1560 // Auto Capital is supported only in normal layout
1561 if (g_keyboard_state.caps_mode) {
1562 g_ui->set_autocapital_shift_state(FALSE);
1566 g_ui->set_autocapital_shift_state(TRUE);
1567 ise_send_event(MVK_Shift_Disable, KEY_MASK_NULL);
1568 g_ui->set_shift_state(SCL_SHIFT_STATE_OFF);
1571 g_ui->set_autocapital_shift_state(TRUE);
1574 // Update CM key button
1575 if (_current_cm_key_id < CM_KEY_LIST_SIZE) {
1576 if (strcmp(_cm_key_list[_current_cm_key_id], USER_KEYSTRING_EMOTICON) == 0) {
1577 if (ise_is_emoticons_disabled())
1578 ise_set_cm_private_key(ise_get_cm_key_id(USER_KEYSTRING_OPTION));
1580 ise_set_cm_private_key(_current_cm_key_id);
1584 // Update space key button
1585 ise_update_space_key();
1588 g_ui->disable_input_events(FALSE);
1590 g_ui->enable_button("CM_KEY", false);
1594 if (ise_is_guideline_popup_enable_layout()) {
1595 if ((!g_config_values.first_guidechange) && (_language_manager.get_enabled_languages_num() > 1)) {
1596 ise_show_help_popup(MVK_space);
1597 LOGD("space popup show\n");
1599 ise_destory_popup_space();
1605 if (g_config_values.floating_mode != g_floating_mode)
1606 g_floating_mode = g_config_values.floating_mode;
1608 if (g_candidate && g_candidate->get_visible())
1609 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_SHOW);
1611 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_NONE);
1614 g_keyboard_state.visible_state = TRUE;
1618 switch (_context_layout) {
1619 case ISE_LAYOUT_STYLE_PHONENUMBER:
1620 case ISE_LAYOUT_STYLE_IP:
1621 case ISE_LAYOUT_STYLE_MONTH:
1622 case ISE_LAYOUT_STYLE_NUMBERONLY:
1623 case ISE_LAYOUT_STYLE_DATETIME:
1624 case ISE_LAYOUT_STYLE_TERMINAL:
1627 case ISE_LAYOUT_STYLE_EMAIL:
1628 case ISE_LAYOUT_STYLE_URL:
1631 case ISE_LAYOUT_STYLE_PASSWORD:
1632 if (_context_layout == ISE_LAYOUT_STYLE_PASSWORD &&
1633 _context_layout_variation == ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD_VARIATION_NUMBERONLY)
1646 g_ui->get_screen_resolution(&width, &height);
1648 create_indicator_window(width, height);
1649 destroy_indicator_dots();
1652 switch (g_keyboard_state.layout) {
1653 case ISE_LAYOUT_STYLE_NUMBER:
1656 case ISE_LAYOUT_STYLE_HEX:
1659 case ISE_LAYOUT_STYLE_EMOTICON:
1662 case ISE_LAYOUT_STYLE_VOICE:
1663 if (_context_layout == ISE_LAYOUT_STYLE_EMAIL ||
1664 _context_layout == ISE_LAYOUT_STYLE_URL)
1673 create_indicator_dots(dot_num, focus_dot);
1674 show_indicator_window();
1676 hide_indicator_window();
1678 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_NORMAL && g_config_values.number_tutorial_enable) {
1679 ise_show_tutorial_mode_popup(g_keyboard_state.layout);
1680 g_config_values.number_tutorial_enable = false;
1681 write_ise_config_values();
1685 if (g_setting_window_open_status) {
1686 ise_show_stt_mode(NATIVE_WINDOW_CAST(ime_get_main_window()));
1688 g_setting_window_open_status = FALSE;
1690 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_VOICE) {
1691 ise_show_stt_mode(NATIVE_WINDOW_CAST(ime_get_main_window()));
1696 * Sets screen rotation
1699 ise_set_screen_rotation(int degree)
1702 g_ui->set_rotation(DEGREE_TO_SCLROTATION(degree));
1706 g_candidate->rotate(degree);
1707 if (g_softcandidate_show) {
1708 g_candidate->update(g_softcandidate_string);
1714 ise_set_accessibility_state(bool state)
1717 g_ui->enable_tts(state);
1725 /* There's no need to update screen when hiding */
1726 g_ui->set_update_pending(TRUE);
1727 g_ui->disable_input_events(TRUE);
1730 _language_manager.reset_language(g_config_values.selected_language.c_str());
1733 delete_commit_timer();
1734 ise_destory_popup_space();
1735 ise_destory_popup_setting();
1737 g_keyboard_state.visible_state = FALSE;
1739 _reset_shift_state();
1740 _reset_multitap_state(true);
1742 /* If we were in STT mode, try to reset input mode on our next show event */
1744 const char *inputmode = g_ui->get_input_mode();
1745 if (inputmode && strcmp(inputmode, "STT_3X4") == 0 ) {
1746 g_keyboard_state.need_reset = TRUE;
1747 ise_hide_stt_mode();
1751 g_input_panel_show = false;
1752 if (g_softcandidate_show && g_candidate)
1753 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_SHOW);
1755 hide_indicator_window();
1756 if (check_is_tutorial_show()) {
1757 ise_destroy_tutorial_mode_popup();
1760 #if EXIT_ISE_ON_HIDE
1761 if (exit_timer) ecore_timer_del(exit_timer);
1762 exit_timer = ecore_timer_add(1.0, exit_timer_cb, NULL);
1766 static void ise_keypad_mode_changed_cb(const char *key, void *user_data)
1768 read_ise_keypad_mode();
1771 static void ise_enabled_languages_changed_cb(const char *key, void *user_data)
1773 read_ise_enabled_languages();
1776 static void ise_selected_language_changed_cb(const char *key, void *user_data)
1778 read_ise_selected_language();
1781 static void ise_autocapital_mode_changed_cb(const char *key, void *user_data)
1783 read_ise_autocapital_mode();
1786 static void ise_autopunctuate_mode_changed_cb(const char *key, void *user_data)
1788 read_ise_autopunctuation_mode();
1791 static void ise_sound_mode_changed_cb(const char *key, void *user_data)
1793 read_ise_sound_mode();
1795 g_ui->enable_sound(g_config_values.sound_on);
1798 static void ise_vibration_mode_changed_cb(const char *key, void *user_data)
1800 read_ise_vibration_mode();
1802 g_ui->enable_vibration(g_config_values.vibration_on);
1805 static void ise_character_preview_mode_changed_cb(const char *key, void *user_data)
1807 read_ise_character_preview_mode();
1809 g_ui->enable_magnifier(g_config_values.preview_on);
1812 static void ise_setting_guide_popup_changed_cb(const char *key, void *user_data)
1814 read_ise_setting_guide_popup_mode();
1817 static void ise_language_guide_popup_changed_cb(const char *key, void *user_data)
1819 read_ise_language_guide_popup_mode();
1822 static void ise_floating_mode_changed_cb(const char *key, void *user_data)
1824 read_ise_floating_mode();
1825 g_floating_mode = g_config_values.floating_mode;
1827 ime_set_floating_mode(g_floating_mode);
1828 if (g_candidate && g_floating_mode != g_candidate->get_floating_mode()) {
1829 delete_softcandidate_hide_timer();
1833 create_softcandidate();
1834 if (g_candidate && g_candidate->get_visible()) {
1835 g_softcandidate_show = true;
1836 g_candidate->show();
1837 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_SHOW);
1841 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_NONE);
1844 static void register_preference_changed_callback(void)
1846 if (preference_set_changed_cb(ISE_CONFIG_KEYPAD_MODE, ise_keypad_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1847 LOGW("Failed to set ise_keypad_mode_changed_cb()");
1849 if (preference_set_changed_cb(ISE_CONFIG_ENABLED_LANGUAGES, ise_enabled_languages_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1850 LOGW("Failed to set ise_enabled_languages_changed_cb()");
1852 if (preference_set_changed_cb(ISE_CONFIG_SELECTED_LANGUAGE, ise_selected_language_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1853 LOGW("Failed to set ise_selected_language_changed_cb()");
1855 if (preference_set_changed_cb(ISE_CONFIG_AUTO_CAPITALISE, ise_autocapital_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1856 LOGW("Failed to set ise_autocapital_mode_changed_cb()");
1858 if (preference_set_changed_cb(ISE_CONFIG_AUTO_PUNCTUATE, ise_autopunctuate_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1859 LOGW("Failed to set ise_autopunctuate_mode_changed_cb()");
1861 if (preference_set_changed_cb(ISE_CONFIG_SOUND_ON, ise_sound_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1862 LOGW("Failed to set ise_sound_mode_changed_cb()");
1864 if (preference_set_changed_cb(ISE_CONFIG_VIBRATION_ON, ise_vibration_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1865 LOGW("Failed to set ise_vibration_mode_changed_cb()");
1867 if (preference_set_changed_cb(ISE_CONFIG_PREVIEW_ON, ise_character_preview_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1868 LOGW("Failed to set ise_character_preview_mode_changed_cb()");
1870 if (preference_set_changed_cb(ISE_CONFIG_FIRST_GUIDELINE_POPUP_FOR_SETTING, ise_setting_guide_popup_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1871 LOGW("Failed to set ise_setting_guide_popup_changed_cb()");
1873 if (preference_set_changed_cb(ISE_CONFIG_FIRST_GUIDELINE_POPUP_FOR_LANGUAGE_CHANGE, ise_language_guide_popup_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1874 LOGW("Failed to set ise_language_guide_popup_changed_cb()");
1876 if (preference_set_changed_cb(ISE_CONFIG_FLOATING_MODE, ise_floating_mode_changed_cb, NULL) != PREFERENCE_ERROR_NONE)
1877 LOGW("Failed to set ise_floating_mode_changed_cb()");
1880 static void ise_mount_changed_cb(void *user_data)
1882 register_preference_changed_callback();
1894 bindtextdomain(PACKAGE, LOCALEDIR);
1895 textdomain(PACKAGE);
1897 /* Set scl_parser_type
1898 * default type is text xml
1899 * use command: export sclres_type="sclres_binary" to enable use binary resource
1900 * please make sure there is sclresource.bin in resource folder
1901 * Or you can use `xml2binary $resource_dir` to generate the sclresource.bin
1902 * xml2binary is in the libscl-ui-devel package
1904 SCLParserType scl_parser_type = SCL_PARSER_TYPE_XML;
1905 char* sclres_type = getenv("sclres_type");
1906 if (sclres_type != NULL && 0 == strcmp("sclres_binary", sclres_type)) {
1907 scl_parser_type = SCL_PARSER_TYPE_BINARY_XML;
1909 scl_parser_type = SCL_PARSER_TYPE_XML;
1913 if (ime_get_main_window()) {
1914 g_ise_created = true;
1916 sclboolean succeeded = FALSE;
1918 const sclchar *entry_path = MAIN_ENTRY_XML_PATH;
1921 CSCLUtils *utils = CSCLUtils::get_instance();
1923 utils->get_screen_resolution(&nwidth, &nheight);
1925 _language_manager.set_resource_file_path(entry_path);
1926 const sclchar *resource_file_path = _language_manager.get_resource_file_path();
1928 if (resource_file_path) {
1929 if (strlen(resource_file_path) > 0) {
1930 succeeded = g_ui->init(ime_get_main_window(), scl_parser_type, resource_file_path);
1934 g_ui->init(ime_get_main_window(), scl_parser_type, MAIN_ENTRY_XML_PATH);
1937 g_ui->set_longkey_duration(elm_config_longpress_timeout_get() * 1000);
1939 /* Default ISE callback */
1940 g_ui->set_ui_event_callback(&callback);
1942 /* Accumulated customized ISE callbacks, depending on the input modes */
1943 for (scluint loop = 0;loop < _language_manager.get_languages_num();loop++) {
1944 LANGUAGE_INFO *language = _language_manager.get_language_info(loop);
1946 for (scluint inner_loop = 0;inner_loop < language->input_modes.size();inner_loop++) {
1947 INPUT_MODE_INFO &info = language->input_modes.at(inner_loop);
1948 LOGD("Registering callback for input mode %s : %p\n", info.name.c_str(), language->callback);
1949 g_ui->set_ui_event_callback(language->callback, info.name.c_str());
1954 read_ise_config_values();
1955 _language_manager.set_enabled_languages(g_config_values.enabled_languages);
1956 _language_manager.select_language(g_config_values.selected_language.c_str());
1957 vconf_set_bool(VCONFKEY_AUTOCAPITAL_ALLOW_BOOL, g_config_values.auto_capitalise);
1958 vconf_set_bool(VCONFKEY_AUTOPERIOD_ALLOW_BOOL, g_config_values.auto_punctuate);
1959 g_ui->enable_sound(g_config_values.sound_on);
1960 g_ui->enable_vibration(g_config_values.vibration_on);
1961 g_ui->enable_magnifier(g_config_values.preview_on);
1963 g_ui->enable_highlight_ui(TRUE);
1965 g_floating_mode = g_config_values.floating_mode;
1966 ime_set_floating_mode(g_floating_mode);
1969 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_NONE);
1973 preference_is_existing(ISE_CONFIG_KEYPAD_MODE, &exist);
1975 write_ise_config_values();
1978 if (ode_internal_encryption_get_state(&state) == ODE_ERROR_NONE) {
1979 if (state == ODE_STATE_ENCRYPTED) {
1980 if (ode_internal_encryption_set_mount_event_cb(ise_mount_changed_cb, NULL) != ODE_ERROR_NONE)
1981 LOGW("Failed to set mount_event_cb()");
1982 } else if (state == ODE_STATE_UNENCRYPTED) {
1983 register_preference_changed_callback();
1986 LOGW("Failed to get encryption_state");
1989 init_recent_used_punctuation();
1995 ise_hide_stt_mode();
1998 LOGD("calling g_ui->fini()\n");
2000 LOGD("deleting g_ui\n");
2011 destroy_indicator_window();
2014 /* This is necessary. If this is not called, 3rd party IME might have auto period input regardless its settings */
2015 vconf_set_bool(VCONFKEY_AUTOPERIOD_ALLOW_BOOL, false);
2017 #if EXIT_ISE_ON_HIDE
2018 if (exit_timer) ecore_timer_del(exit_timer);
2024 ise_app_candidate_show()
2027 if (!g_softcandidate_show) {
2032 delete_softcandidate_hide_timer();
2034 create_softcandidate();
2036 g_softcandidate_show = true;
2038 g_candidate->show();
2039 set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_SHOW);
2044 ise_app_candidate_hide()
2048 if (!g_candidate || !g_softcandidate_show) {
2049 LOGD("No candidate\n");
2053 if (g_ic_smartreply != -1 || g_autofill_exist)
2056 add_softcandidate_hide_timer();
2060 void ise_check_wearable_candidate()
2062 if (!g_config_values.prediction_on) {
2063 ise_app_candidate_hide();
2064 } else if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_PHONENUMBER ||
2065 g_keyboard_state.layout == ISE_LAYOUT_STYLE_VOICE ||
2066 g_keyboard_state.layout == ISE_LAYOUT_STYLE_IP ||
2067 g_keyboard_state.layout == ISE_LAYOUT_STYLE_MONTH ||
2068 g_keyboard_state.layout == ISE_LAYOUT_STYLE_NUMBERONLY ||
2069 g_keyboard_state.layout == ISE_LAYOUT_STYLE_PASSWD_3X4||
2070 g_keyboard_state.layout == ISE_LAYOUT_STYLE_PASSWORD) {
2071 ise_app_candidate_hide();
2073 g_softcandidate_show = true;
2074 ise_app_candidate_show();
2078 void ise_set_emoticon_label(int group_id)
2080 const int BUF_LEN = 16;
2081 char buf[BUF_LEN] = {0};
2082 snprintf(buf, BUF_LEN, "%d/3", group_id);
2083 g_ui->set_private_key("EMOTICON_GROUP_ID", buf, NULL, NULL, 0, const_cast<sclchar*>("EMOTICON_GROUP_NEXT"), TRUE);
2087 // when it is the time to auto_cap, the
2088 // ise_set_caps_mode is called.
2089 // -------------------------------------------------------
2090 // For example: [How are you. Fine.], the
2091 // auto-capital process is as below:
2092 // Note: "["<--this is the beginning,
2093 // "|"<--this is the cursor position
2094 // 1) call ise_set_caps_mode, auto_cap = on
2097 // 2) call ise_set_caps_mode, auto_cap = off
2100 // 3) input: "w are you. "
2101 // result: [How are you. |
2102 // 4) call ise_set_caps_mode, auto_cap = on
2104 // result: [How are you. F
2106 // result: [How are you. Fine.|
2107 // --------------------------------------------------------
2108 // If we want to change the auto_cap, eg,
2109 // if we want to input [How Are you.]
2110 // Note the "Are" is not use auto-capital rule.
2112 // ise_send_event(MVK_Shift_On, SclCoreKeyMask_Null);
2113 // when we are want to input "A"
2114 // following input still has the auto_cap rule.
2116 ise_set_caps_mode(unsigned int mode)
2118 LOGD("caps_mode : %d\n", mode);
2120 g_keyboard_state.caps_mode = TRUE;
2122 g_keyboard_state.caps_mode = FALSE;
2124 g_caps_mode_pending = false;
2125 const sclchar *cur_lang = _language_manager.get_current_language();
2127 LANGUAGE_INFO *info = _language_manager.get_language_info(cur_lang);
2129 if (info->accepts_caps_mode) {
2130 /* If we are inputting multitap character, do not manipulate shift mode */
2131 if (g_keyboard_state.prev_modifier != KEY_MODIFIER_MULTITAP_START &&
2132 g_keyboard_state.prev_modifier != KEY_MODIFIER_MULTITAP_REPEAT) {
2133 set_caps_mode(g_keyboard_state.caps_mode);
2135 g_caps_mode_pending = true;
2136 LOGD("Currently composing multitap string, skipping caps request");
2144 ise_update_cursor_position(int position)
2146 LOGD("cursor position : %d\n", position);
2147 if (g_ui && g_keyboard_state.layout == ISE_LAYOUT_STYLE_URL) {
2150 g_ui->set_string_substitution("www.", ".com");
2152 g_ui->unset_string_substitution("www.");
2158 void ise_set_return_key_type(unsigned int type)
2160 const int BUF_LEN = 256;
2161 char buf[BUF_LEN] = {0};
2165 LOGD("return key type : %d\n", type);
2168 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE:
2169 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_DONE);
2171 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_GO:
2172 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_GO);
2174 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_JOIN:
2175 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_JOIN);
2177 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_LOGIN:
2178 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_LOGIN);
2180 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT:
2181 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_NEXT);
2183 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH:
2184 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_SEARCH);
2186 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEND:
2187 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_SEND);
2189 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SIGNIN:
2190 snprintf(buf, BUF_LEN, ISE_RETURN_KEY_LABEL_SIGNIN);
2192 case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT:
2195 LOGW("Unknown return key type : %d\n", type);
2196 type = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
2200 if (type == ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT) {
2201 g_ui->unset_private_key("Enter");
2203 g_ui->unset_private_key("Done");
2207 if (type == ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH) {
2208 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
2209 const_cast<sclchar*>("w_sip_3x4_btn_ic_search.png"),
2210 const_cast<sclchar*>("w_sip_3x4_btn_ic_search_p.png"),
2211 const_cast<sclchar*>("w_sip_3x4_btn_ic_search_d.png")};
2212 g_ui->set_private_key("Enter", const_cast<sclchar*>(""), imagelabel, NULL, 0, const_cast<sclchar*>("Enter"), TRUE);
2218 g_ui->set_private_key("Done", buf, NULL, NULL, 0, const_cast<sclchar*>("Done"), TRUE);
2220 static sclchar *imagelabel[SCL_BUTTON_STATE_MAX] = {
2221 const_cast<sclchar*>(" "), const_cast<sclchar*>(" "), const_cast<sclchar*>(" ")
2224 g_ui->set_private_key("Enter", buf, imagelabel, NULL, 0, const_cast<sclchar*>("Enter"), TRUE);
2226 LOGD("return key lable : %s\n", buf);
2230 void ise_set_return_key_disable(unsigned int disabled)
2232 LOGD("enable : %d\n", !disabled);
2235 g_ui->enable_button("Done", !disabled);
2238 g_ui->enable_button("Enter", !disabled);
2242 void ise_get_language_locale(char **locale)
2244 LANGUAGE_INFO *info = _language_manager.get_current_language_info();
2246 if (!(info->locale_string.empty())) {
2247 *locale = strdup(info->locale_string.c_str());
2252 void ise_update_table(const vector<string> &vec_str)
2254 if (!g_candidate || !g_softcandidate_show)
2255 create_softcandidate();
2258 g_candidate->update(vec_str);
2262 void ise_process_key_event(scim::KeyEvent& key, sclu32 &ret)
2264 Eina_Bool back_key_pressed = EINA_FALSE;
2265 Eina_Bool back_key_released = EINA_FALSE;
2267 if (key.get_key_string().compare("XF86Back") == 0) {
2268 back_key_pressed = EINA_TRUE;
2269 } else if (key.get_key_string().compare("KeyRelease+XF86Back") == 0) {
2270 back_key_released = EINA_TRUE;
2273 if (back_key_pressed || back_key_released) {
2274 if (g_popup_opened == TRUE) {
2275 if (back_key_released) {
2276 g_ui->close_all_popups();
2286 if (!g_candidate->soft_candidate_flag()) {
2288 if (key.dev_name.compare("ime") != 0) {
2289 ret = (sclu32)g_ui->process_key_event(key.get_key_string().c_str());
2294 ret = g_candidate->soft_candidate_handle_key_event(key.get_key_string().c_str());
2298 /* Process this key event if it was not generated by ime */
2299 if (key.dev_name.compare("ime") != 0) {
2300 ret = (sclu32)g_ui->process_key_event(key.get_key_string().c_str());
2306 /* Process this key event if it was not generated by ime */
2307 if (key.dev_name.compare("ime") != 0) {
2308 ret = (sclu32)g_ui->process_key_event(key.get_key_string().c_str());
2314 static void init_recent_used_punctuation()
2316 if (g_recent_used_punctuation.empty())
2318 g_recent_used_punctuation.push_back("#");
2319 g_recent_used_punctuation.push_back("$");
2320 g_recent_used_punctuation.push_back("%");
2321 g_recent_used_punctuation.push_back("^");
2322 g_recent_used_punctuation.push_back("&");
2326 static void update_recent_used_punctuation(const char * key_value)
2328 if (NULL == key_value)
2332 for (int i = 0; i < 10; ++i)
2335 snprintf(buf, sizeof(buf), "%d", i);
2336 if (strcmp(key_value, buf) == 0)
2341 string strKey = string(key_value);
2342 for (int i = 0; i < MAX_DEFAULT_PUNCTUATION; ++i)
2344 if (0 == strKey.compare(g_default_punctuation[i].c_str()))
2349 vector<string>::iterator iter = g_recent_used_punctuation.begin();
2350 for (; iter != g_recent_used_punctuation.end(); ++iter)
2352 if (0 == strKey.compare(iter->c_str()))
2357 if (iter != g_recent_used_punctuation.end())
2359 g_recent_used_punctuation.erase(iter);
2361 g_recent_used_punctuation.push_back(strKey);
2362 if (g_recent_used_punctuation.size() > MAX_DEFAULT_PUNCTUATION-1)
2364 g_recent_used_punctuation.erase(g_recent_used_punctuation.begin());
2368 static void set_ime_size(bool floating_mode, ISE_CANDIDATE_REQUEST candidate_req)
2373 const char *input_mode = g_ui->get_input_mode();
2377 SclSize size_portrait = g_ui->get_input_mode_size(input_mode, DISPLAYMODE_PORTRAIT);
2378 SclSize size_landscape = g_ui->get_input_mode_size(input_mode, DISPLAYMODE_LANDSCAPE);
2380 if (floating_mode) {
2381 size_portrait.width *= FLOATING_SCALE_RATE;
2382 size_portrait.height *= FLOATING_SCALE_RATE;
2383 size_landscape.width *= FLOATING_SCALE_RATE;
2384 size_landscape.height *= FLOATING_SCALE_RATE;
2385 switch (candidate_req) {
2386 case ISE_CANDIDATE_REQ_NONE:
2387 if (g_candidate && g_candidate->get_visible()) {
2388 g_ui->set_custom_starting_coordinates(0, FLOATING_TITLE_BAR_HEIGHT + g_candidate->get_height());
2389 size_portrait.height += g_candidate->get_height();
2390 size_landscape.height += g_candidate->get_height();
2392 g_ui->set_custom_starting_coordinates(0, FLOATING_TITLE_BAR_HEIGHT);
2395 case ISE_CANDIDATE_REQ_SHOW:
2396 g_ui->set_custom_starting_coordinates(0, FLOATING_TITLE_BAR_HEIGHT + g_candidate->get_height());
2397 if (g_input_panel_show || g_candidate_more_view) {
2398 size_portrait.height += g_candidate->get_height();
2399 size_landscape.height += g_candidate->get_height();
2401 size_portrait.height = g_candidate->get_height();
2402 size_landscape.height = g_candidate->get_height();
2405 case ISE_CANDIDATE_REQ_HIDE:
2406 g_ui->set_custom_starting_coordinates(0, FLOATING_TITLE_BAR_HEIGHT);
2411 if (g_ui->get_custom_scale_rate_x() != FLOATING_SCALE_RATE || g_ui->get_custom_scale_rate_y() != FLOATING_SCALE_RATE)
2412 g_ui->set_custom_scale_rate(FLOATING_SCALE_RATE, FLOATING_SCALE_RATE);
2414 ime_set_size(size_portrait.width, size_portrait.height + FLOATING_TITLE_BAR_HEIGHT,
2415 size_landscape.width, size_landscape.height + FLOATING_TITLE_BAR_HEIGHT);
2418 ise_destroy_move_handler();
2419 int rotation = elm_win_rotation_get(NATIVE_WINDOW_CAST(ime_get_main_window()));
2420 int handler_width = (rotation == 0 || rotation == 180) ? size_portrait.width : size_landscape.width;
2421 ise_show_move_handler(handler_width, FLOATING_TITLE_BAR_HEIGHT);
2424 switch (candidate_req) {
2425 case ISE_CANDIDATE_REQ_NONE:
2426 if (g_candidate && g_candidate->get_visible()) {
2427 g_ui->set_custom_starting_coordinates(0, g_candidate->get_height());
2428 size_portrait.height += g_candidate->get_height();
2429 size_landscape.height += g_candidate->get_height();
2431 g_ui->set_custom_starting_coordinates(0, 0);
2434 case ISE_CANDIDATE_REQ_SHOW:
2435 g_ui->set_custom_starting_coordinates(0, g_candidate->get_height());
2436 if (g_input_panel_show || g_candidate_more_view) {
2437 size_portrait.height += g_candidate->get_height();
2438 size_landscape.height += g_candidate->get_height();
2440 size_portrait.height = g_candidate->get_height();
2441 size_landscape.height = g_candidate->get_height();
2444 case ISE_CANDIDATE_REQ_HIDE:
2445 g_ui->set_custom_starting_coordinates(0, 0);
2450 if (g_ui->get_custom_scale_rate_x() != 1.0 || g_ui->get_custom_scale_rate_y() != 1.0)
2451 g_ui->set_custom_scale_rate(1.0, 1.0);
2453 ime_set_size(size_portrait.width, size_portrait.height, size_landscape.width, size_landscape.height);
2456 ise_destroy_move_handler();
2461 static void ime_app_create_cb(void *user_data)
2463 #if !(DEFER_ISE_CREATION)
2466 elm_app_name_set(PACKAGE);
2469 cbhm_open_service(&cbhm_handle);
2473 static void ime_app_exit_cb(void *user_data)
2479 cbhm_close_service(cbhm_handle);
2484 static void show_autofill_data(Ecore_IMF_Input_Hints input_hints)
2486 g_autofill_exist = false;
2487 char *text = autofill_get_string(g_app_id.c_str(), g_resource_id.c_str(), input_hints);
2490 g_autofill_string = string(text);
2493 g_autofill_string = string("");
2495 SECURE_LOGD("autofill string : %s", g_autofill_string.c_str());
2497 if (g_autofill_string.length() > 0) {
2498 g_autofill_exist = true;
2500 ise_app_candidate_show();
2501 update_candidate_table();
2505 static void ime_app_show_cb(int ic, ime_context_h ime_ctx, void *user_data)
2507 Ise_Context iseContext;
2508 bool return_key_state, prediction_allow, password_mode, caps_mode;
2509 ime_layout_variation_e layout_variation;
2514 ime_context_get_layout(ime_ctx, &iseContext.layout);
2516 ime_context_get_layout_variation(ime_ctx, &layout_variation);
2517 iseContext.layout_variation = (int)layout_variation;
2519 ime_context_get_cursor_position(ime_ctx, &iseContext.cursor_pos);
2520 ime_context_get_autocapital_type(ime_ctx, &iseContext.autocapital_type);
2521 ime_context_get_return_key_type(ime_ctx, &iseContext.return_key_type);
2522 ime_context_get_return_key_state(ime_ctx, &return_key_state);
2524 ime_context_get_prediction_mode(ime_ctx, &prediction_allow);
2525 iseContext.prediction_allow = prediction_allow;
2527 ime_context_get_password_mode(ime_ctx, &password_mode);
2528 iseContext.password_mode = password_mode;
2530 ime_context_get_input_hint(ime_ctx, &iseContext.input_hint);
2531 ime_context_get_bidi_direction(ime_ctx, &iseContext.bidi_direction);
2532 ime_context_get_language(ime_ctx, &iseContext.language);
2533 ime_context_get_caps_mode(ime_ctx, &caps_mode);
2534 iseContext.caps_mode = caps_mode;
2536 iseContext.return_key_disabled = return_key_state;
2540 g_autofill_hint = iseContext.input_hint & ECORE_IMF_INPUT_HINT_AUTOFILL_MASK;
2542 LOGD("input hint : %x, autofill hint : %x\n", iseContext.input_hint, g_autofill_hint);
2544 if (g_autofill_hint == 0) {
2545 switch (iseContext.layout) {
2546 case ECORE_IMF_INPUT_PANEL_LAYOUT_EMAIL:
2547 g_autofill_hint = ECORE_IMF_INPUT_HINT_AUTOFILL_EMAIL_ADDRESS;
2549 case ECORE_IMF_INPUT_PANEL_LAYOUT_PHONENUMBER:
2550 g_autofill_hint = ECORE_IMF_INPUT_HINT_AUTOFILL_PHONE;
2557 // show autofill data
2558 show_autofill_data((Ecore_IMF_Input_Hints)g_autofill_hint);
2560 //g_ise_common->set_keyboard_ise_by_uuid(KEYBD_ISE_UUID);
2562 /* Don't update screen until all the information is correctly set */
2564 g_ui->set_update_pending(TRUE);
2566 ise_reset_context(); // reset ISE
2568 /*if (context.language == ECORE_IMF_INPUT_PANEL_LANG_ALPHABET) {
2569 ise_explictly_set_language(PRIMARY_LATIN_LANGUAGE_INDEX);
2572 _context_layout = iseContext.layout;
2573 _context_layout_variation = iseContext.layout_variation;
2574 ise_set_layout(iseContext.layout, iseContext.layout_variation);
2576 ise_set_return_key_type(iseContext.return_key_type);
2577 ise_set_return_key_disable(iseContext.return_key_disabled);
2579 ise_set_caps_mode(iseContext.caps_mode);
2580 ise_update_cursor_position(iseContext.cursor_pos);
2584 /* Now we update the whole screen */
2586 g_ui->set_update_pending(FALSE);
2589 static void ime_app_hide_cb(int ic, void *user_data)
2594 g_set_mime_type = FALSE;
2596 g_ic_smartreply = -1;
2599 static void ime_app_return_key_type_set_cb(Ecore_IMF_Input_Panel_Return_Key_Type type, void *user_data)
2601 LOGD("return key type : %d\n", type);
2602 ise_set_return_key_type(type);
2604 if (g_keyboard_state.visible_state)
2605 ise_show(g_keyboard_state.ic);
2608 static void ime_app_return_key_state_set_cb(bool disabled, void *user_data)
2610 LOGD("return key disabled : %d\n", disabled);
2611 ise_set_return_key_disable(disabled);
2614 static void ime_app_input_context_reset_cb(void *user_data)
2616 ise_reset_input_context();
2619 static void ime_app_cursor_position_updated_cb(int cursor_pos, void *user_data)
2621 LOGD("cursor position : %d\n", cursor_pos);
2622 ise_update_cursor_position(cursor_pos);
2625 static void ime_app_language_requested_cb(void *user_data, char **lang_code)
2627 ise_get_language_locale(lang_code);
2630 static void ime_app_surrounding_text_updated_cb(int context_id, const char *text, int cursor_pos, void *user_data)
2632 SECURE_LOGD("surrounding text:%s, cursor=%d\n", text, cursor_pos);
2633 ime_delete_surrounding_text(-cursor_pos, strlen(text));
2636 static void ime_app_focus_in_cb(int context_id, void *user_data)
2639 ise_focus_in(context_id);
2640 if (!g_smartreply_reply_exist && g_softcandidate_show) {
2642 ise_app_candidate_hide();
2643 g_candidate->hide();
2648 static void ime_app_focus_out_cb(int context_id, void *user_data)
2651 ise_focus_out(context_id);
2654 g_set_mime_type = FALSE;
2656 g_smartreply_reply_exist = false;
2657 g_smartreply_size = 0;
2658 input_smartreply_deinit();
2659 g_ic_smartreply = -1;
2661 g_autofill_exist = false;
2662 g_autofill_hint = 0;
2664 g_app_id = string("");
2665 g_resource_id = string("");
2667 g_autofill_string = string("");
2668 g_smartreply_strings.clear();
2669 g_lookup_table_strings.clear();
2670 g_softcandidate_string.clear();
2673 static void ime_app_layout_set_cb(Ecore_IMF_Input_Panel_Layout layout, void *user_data)
2675 LOGD("layout=%d\n", layout);
2676 /* Check if the layoutIdx is in the valid range */
2677 if (static_cast<int>(layout) < static_cast<int>(ISE_LAYOUT_STYLE_MAX)) {
2678 if (g_keyboard_state.layout != layout) {
2679 g_keyboard_state.need_reset = TRUE;
2681 g_keyboard_state.layout = layout;
2682 _context_layout = layout;
2683 _context_layout_variation = 0;
2685 if (g_keyboard_state.visible_state)
2686 ise_show(g_keyboard_state.ic);
2689 static void ime_app_rotation_degree_changed_cb(int degree, void *user_data)
2691 ise_set_screen_rotation(degree);
2693 LOGD("degree=%d\n", degree);
2695 if (g_floating_mode) {
2697 ise_destroy_move_handler();
2698 if (degree == 0 || degree == 180) {
2699 SclSize size_portrait = g_ui->get_input_mode_size(g_ui->get_input_mode(), DISPLAYMODE_PORTRAIT);
2700 handler_width = size_portrait.width * FLOATING_SCALE_RATE;
2702 SclSize size_landscape = g_ui->get_input_mode_size(g_ui->get_input_mode(), DISPLAYMODE_LANDSCAPE);
2703 handler_width = size_landscape.width * FLOATING_SCALE_RATE;
2705 ise_show_move_handler(handler_width, FLOATING_TITLE_BAR_HEIGHT);
2708 if (is_emoticon_show()) {
2709 ise_destroy_emoticon_layout();
2711 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_VOICE) {
2712 ise_hide_stt_mode();
2714 if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_EMOTICON) {
2715 ise_show_emoticon_layout(current_emoticon_group, degree, false, ime_get_main_window());
2717 const sclchar *input_mode = g_ui->get_input_mode();
2719 if (!(strcmp(input_mode, "EMOTICON_LAYOUT")))
2720 ise_show_emoticon_layout(current_emoticon_group, degree, false, ime_get_main_window());
2721 else if (!(strcmp(input_mode, "STT_3X4")))
2722 ise_show_stt_mode(NATIVE_WINDOW_CAST(ime_get_main_window()));
2727 static void ime_app_accessibility_state_changed_cb(bool state, void *user_data)
2729 LOGD("state=%d\n", state);
2730 ise_set_accessibility_state(state);
2733 static void ime_app_imdata_set_cb(void *data, unsigned int data_length, void *user_data)
2737 size_t _len = data_length;
2738 set_ise_imdata((sclchar *)data, _len);
2741 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)
2743 scim::KeyEvent key(keycode, keymask);
2745 char *dev_name = NULL;
2746 Ecore_IMF_Device_Class dev_class;
2747 Ecore_IMF_Device_Subclass dev_subclass;
2749 if (ime_device_info_get_name(dev_info, &dev_name) == IME_ERROR_NONE) {
2750 key.dev_name = dev_name;
2753 if (ime_device_info_get_class(dev_info, &dev_class) == IME_ERROR_NONE) {
2754 key.dev_class = dev_class;
2757 if (ime_device_info_get_subclass(dev_info, &dev_subclass) == IME_ERROR_NONE) {
2758 key.dev_subclass = dev_subclass;
2761 if (g_keyboard_state.visible_state)
2762 ise_process_key_event(key, ret);
2772 static void ime_app_caps_mode_changed_cb(int mode, void *user_data)
2774 ise_set_caps_mode(mode);
2777 static void ime_app_candidate_show_cb(int context_id, void *user_data)
2780 ise_check_wearable_candidate();
2782 ise_app_candidate_show();
2786 static void ime_app_candidate_hide_cb(int context_id, void *user_data)
2789 ise_check_wearable_candidate();
2791 ise_app_candidate_hide();
2795 static void ime_app_lookup_table_changed_cb(Eina_List *list, void *user_data)
2797 vector<string> candidate_strings;
2802 g_lookup_table_strings.clear();
2805 EINA_LIST_FOREACH(list, l, data) {
2806 candidate = (char *)data;
2808 g_lookup_table_strings.push_back(string(candidate));
2809 candidate_strings.push_back(string(candidate));
2814 if (g_smartreply_reply_exist) {
2815 if (candidate_strings[0] == "#" && candidate_strings[1] == "$") {
2818 ime_get_surrounding_text(0, 0, &text, &cursor);
2827 update_candidate_table();
2831 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)
2833 if (device_type == IME_INPUT_DEVICE_TYPE_ROTARY) {
2834 ime_input_device_rotary_direction_e direction;
2835 if (IME_ERROR_NONE == ime_input_device_rotary_get_direction(device_event, &direction)) {
2836 sclu32 new_layout = g_keyboard_state.layout;
2837 if (direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_CLOCKWISE) {
2838 LOGD("CLOCKWISE\n");
2839 switch (g_keyboard_state.layout) {
2840 case ISE_LAYOUT_STYLE_NORMAL:
2841 case ISE_LAYOUT_STYLE_EMAIL:
2842 case ISE_LAYOUT_STYLE_URL:
2843 case ISE_LAYOUT_STYLE_PASSWORD:
2844 if (_context_layout == ISE_LAYOUT_STYLE_PASSWORD &&
2845 _context_layout_variation == ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD_VARIATION_NUMBERONLY)
2846 ; // PASSWORD NUMBER ONLY, do nothing
2848 new_layout = ISE_LAYOUT_STYLE_NUMBER;
2850 case ISE_LAYOUT_STYLE_NUMBER:
2851 new_layout = ISE_LAYOUT_STYLE_HEX;
2853 case ISE_LAYOUT_STYLE_HEX:
2854 if (_context_layout == ISE_LAYOUT_STYLE_EMAIL ||
2855 _context_layout == ISE_LAYOUT_STYLE_URL)
2856 new_layout = ISE_LAYOUT_STYLE_VOICE;
2857 else if (_context_layout == ISE_LAYOUT_STYLE_PASSWORD)
2858 new_layout = _context_layout;
2860 new_layout = ISE_LAYOUT_STYLE_EMOTICON;
2862 case ISE_LAYOUT_STYLE_EMOTICON:
2863 if (_context_layout == ISE_LAYOUT_STYLE_EMAIL ||
2864 _context_layout == ISE_LAYOUT_STYLE_URL ||
2865 _context_layout == ISE_LAYOUT_STYLE_PASSWORD)
2866 new_layout = _context_layout;
2868 new_layout = ISE_LAYOUT_STYLE_VOICE;
2870 case ISE_LAYOUT_STYLE_VOICE:
2871 new_layout = ISE_LAYOUT_STYLE_NORMAL;
2876 } else if (direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_COUNTER_CLOCKWISE) {
2877 LOGD("COUNTER_CLOCKWISE\n");
2878 switch (g_keyboard_state.layout) {
2879 case ISE_LAYOUT_STYLE_NORMAL:
2880 case ISE_LAYOUT_STYLE_EMAIL:
2881 case ISE_LAYOUT_STYLE_URL:
2882 case ISE_LAYOUT_STYLE_PASSWORD:
2883 if (_context_layout == ISE_LAYOUT_STYLE_PASSWORD &&
2884 _context_layout_variation == ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD_VARIATION_NUMBERONLY)
2885 ; // PASSWORD NUMBER ONLY, do nothing
2886 else if (_context_layout == ISE_LAYOUT_STYLE_PASSWORD)
2887 new_layout = ISE_LAYOUT_STYLE_HEX;
2889 new_layout = ISE_LAYOUT_STYLE_VOICE;
2891 case ISE_LAYOUT_STYLE_NUMBER:
2892 if (_context_layout == ISE_LAYOUT_STYLE_EMAIL ||
2893 _context_layout == ISE_LAYOUT_STYLE_URL ||
2894 _context_layout == ISE_LAYOUT_STYLE_PASSWORD)
2895 new_layout = _context_layout;
2897 new_layout = ISE_LAYOUT_STYLE_NORMAL;
2899 case ISE_LAYOUT_STYLE_HEX:
2900 new_layout = ISE_LAYOUT_STYLE_NUMBER;
2902 case ISE_LAYOUT_STYLE_EMOTICON:
2903 new_layout = ISE_LAYOUT_STYLE_HEX;
2905 case ISE_LAYOUT_STYLE_VOICE:
2906 if (_context_layout == ISE_LAYOUT_STYLE_EMAIL ||
2907 _context_layout == ISE_LAYOUT_STYLE_URL)
2908 new_layout = ISE_LAYOUT_STYLE_HEX;
2910 new_layout = ISE_LAYOUT_STYLE_EMOTICON;
2917 if (check_is_tutorial_show()) {
2918 read_ise_config_values();
2919 if ((direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_COUNTER_CLOCKWISE && !g_config_values.number_tutorial_enable && !g_config_values.symbol_tutorial_enable) ||
2920 (direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_CLOCKWISE && g_config_values.symbol_tutorial_enable)) {
2921 new_layout = g_keyboard_state.layout;
2922 } else if (direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_COUNTER_CLOCKWISE && g_config_values.symbol_tutorial_enable) {
2923 ise_destroy_tutorial_mode_popup();
2924 g_config_values.symbol_tutorial_enable = false;
2925 write_ise_config_values();
2926 } else if (direction == IME_INPUT_DEVICE_ROTARY_DIRECTION_CLOCKWISE && !g_config_values.number_tutorial_enable) {
2927 ise_destroy_tutorial_mode_popup();
2928 new_layout = ISE_LAYOUT_STYLE_NUMBER;
2929 if (!g_config_values.symbol_tutorial_enable) {
2930 ise_show_tutorial_mode_popup(new_layout);
2931 g_config_values.symbol_tutorial_enable = true;
2932 write_ise_config_values();
2937 if (new_layout != g_keyboard_state.layout && new_layout < ISE_LAYOUT_STYLE_MAX) {
2938 g_keyboard_state.need_reset = TRUE;
2939 g_keyboard_state.layout = new_layout;
2941 if (g_keyboard_state.visible_state) {
2942 _reset_multitap_state();
2943 _language_manager.reset_language(g_config_values.selected_language.c_str());
2944 ise_show(g_keyboard_state.ic);
2952 static void ime_app_prediction_hint_set_cb(const char *prediction_hint, void *user_data)
2954 char *sender = (char *)"mms";
2955 char *caller_id = (char *)"mms";
2956 char *hint = (char *)prediction_hint;
2958 if (!prediction_hint) return;
2959 SECURE_LOGD("prediction hint : %s\n", prediction_hint);
2961 if (strlen(prediction_hint) > 0) {
2962 input_smartreply_init(caller_id, sender, hint);
2963 input_smartreply_set_notify(_input_smartreply_notify_cb, NULL);
2965 if (input_smartreply_is_enabled()) {
2966 g_smartreply_size = 0;
2967 g_smartreply_reply_exist = false;
2969 input_smartreply_get_reply_async();
2974 static void ime_app_mime_type_set_request_cb(const char *mime_types, void *user_data)
2976 LOGD("mime type : %s\n", mime_types);
2979 g_set_mime_type = TRUE;
2981 string str(mime_types), text_key = "text/", image_key = "image/";
2983 if (str.find(text_key) != string::npos)
2984 cbhm_sel_type |= CBHM_SEL_TYPE_TEXT;
2986 if (str.find(image_key) != string::npos)
2987 cbhm_sel_type |= CBHM_SEL_TYPE_IMAGE;
2989 LOGD("cbhm_sel_type=0x%x", cbhm_sel_type);
2993 static void ime_app_prediction_hint_data_set_cb(const char *key, const char *value, void *user_data)
2995 SECURE_LOGD("key : %s, value : %s\n", key, value);
2997 if (string(key) == "appid")
2998 g_app_id = string(value ? value : "");
2999 else if (string(key) == "res_id")
3000 g_resource_id = string(value ? value : "");
3006 EXPORTED void ime_app_main(int argc, char **argv)
3008 ime_callback_s basic_callback = {
3015 ime_event_set_focus_in_cb(ime_app_focus_in_cb, NULL);
3016 ime_event_set_focus_out_cb(ime_app_focus_out_cb, NULL);
3017 ime_event_set_rotation_degree_changed_cb(ime_app_rotation_degree_changed_cb, NULL);
3018 ime_event_set_accessibility_state_changed_cb(ime_app_accessibility_state_changed_cb, NULL);
3019 ime_event_set_layout_set_cb(ime_app_layout_set_cb, NULL);
3020 ime_event_set_caps_mode_changed_cb(ime_app_caps_mode_changed_cb, NULL);
3021 ime_event_set_cursor_position_updated_cb(ime_app_cursor_position_updated_cb, NULL);
3022 ime_event_set_surrounding_text_updated_cb(ime_app_surrounding_text_updated_cb, NULL);
3023 ime_event_set_return_key_type_set_cb(ime_app_return_key_type_set_cb, NULL);
3024 ime_event_set_return_key_state_set_cb(ime_app_return_key_state_set_cb, NULL);
3025 ime_event_set_imdata_set_cb(ime_app_imdata_set_cb, NULL);
3026 ime_event_set_process_key_event_cb(ime_app_process_key_event_cb, NULL);
3028 ime_event_set_candidate_show_cb(ime_app_candidate_show_cb, NULL);
3029 ime_event_set_candidate_hide_cb(ime_app_candidate_hide_cb, NULL);
3030 ime_event_set_lookup_table_changed_cb(ime_app_lookup_table_changed_cb, NULL);
3033 ime_event_set_process_input_device_event_cb(ime_app_process_input_device_event_cb, NULL);
3036 ime_event_set_input_context_reset_cb(ime_app_input_context_reset_cb, NULL);
3037 ime_event_set_language_requested_cb(ime_app_language_requested_cb, NULL);
3039 ime_event_set_prediction_hint_set_cb(ime_app_prediction_hint_set_cb, NULL);
3040 ime_event_set_mime_type_set_request_cb(ime_app_mime_type_set_request_cb, NULL);
3041 ime_event_set_prediction_hint_data_set_cb(ime_app_prediction_hint_data_set_cb, NULL);
3043 #if DEFER_ISE_CREATION
3044 ime_set_window_creation_defer_flag(TRUE);
3047 ime_run(&basic_callback, NULL);
3053 EXPORTED int main(int argc, char *argv[])
3055 ime_app_main(argc, argv);