*
*/
-#define Uses_SCIM_ATTRIBUTE
-
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <vconf.h>
#include <Ecore_IMF.h>
#include <Elementary.h>
-#include <scim.h>
+#include <sclui.h>
+#include <sclutils.h>
+#include <inputmethod.h>
+#include <inputmethod_internal.h>
#ifdef HAVE_CBHM
#include <cbhm.h>
#endif
-#include <sclui.h>
-#include <sclcore.h>
-#include <sclutils.h>
#include "ise.h"
#include "utils.h"
#include "ise-language-change.h"
#include "modeindicator.h"
+#define EXPORTED __attribute__((visibility("default")))
+
#define CANDIDATE_WINDOW_HEIGHT 84
using namespace scl;
#include <vector>
#endif
static CCoreEventCallback g_core_event_callback;
-CSCLCore g_core(&g_core_event_callback);
int g_imdata_state = 0;
extern emoticon_group_t current_emoticon_group;
extern sclboolean g_setting_window_open_status;
+static int g_ic = 0;
+
KEYBOARD_STATE g_keyboard_state = {
0,
0,
const MultiEventDesc &multidesc = dynamic_cast<const MultiEventDesc &>(desc);
switch (multidesc.type) {
case MultiEventDesc::CANDIDATE_ITEM_MOUSE_DOWN:
- g_core.select_candidate(multidesc.index);
+ ime_select_candidate(multidesc.index);
break;
case MultiEventDesc::CANDIDATE_MORE_VIEW_SHOW:
// when more parts shows, click on the candidate will
static void create_softcandidate(void)
{
if (!g_candidate) {
- g_candidate = CandidateFactory::make_candidate(CANDIDATE_MULTILINE, g_core.get_main_window());
+ g_candidate = CandidateFactory::make_candidate(CANDIDATE_MULTILINE, ime_get_main_window());
if (g_candidate) {
g_candidate->add_event_listener(&g_candidate_event_listener);
}
#endif
}
-void CCoreEventCallback::on_run(int argc, char **argv)
-{
- LOGD("CCoreEventCallback::on_run()\n");
- g_core.run();
-}
-
void CCoreEventCallback::on_exit()
{
::ise_hide();
ise_hide_stt_mode();
}
if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_EMOTICON) {
- ise_show_emoticon_layout(current_emoticon_group, degree, false, g_core.get_main_window());
+ ise_show_emoticon_layout(current_emoticon_group, degree, false, ime_get_main_window());
} else if (g_ui) {
const sclchar *input_mode = g_ui->get_input_mode();
if (input_mode) {
if (!(strcmp(input_mode, "EMOTICON_LAYOUT")))
- ise_show_emoticon_layout(current_emoticon_group, degree, false, g_core.get_main_window());
+ ise_show_emoticon_layout(current_emoticon_group, degree, false, ime_get_main_window());
else if (!(strcmp(input_mode, "STT_3X4")))
- ise_show_stt_mode(NATIVE_WINDOW_CAST(g_core.get_main_window()));
+ ise_show_stt_mode(NATIVE_WINDOW_CAST(ime_get_main_window()));
}
}
}
void CCoreEventCallback::on_update_surrounding_text(sclint ic, const sclchar *text, sclint cursor)
{
LOGD("surrounding text:%s, cursor=%d\n", text, cursor);
- g_core.delete_surrounding_text(-cursor, strlen(text));
+ ime_delete_surrounding_text(-cursor, strlen(text));
}
void CCoreEventCallback::on_set_return_key_type(sclu32 type)
SclSize size_landscape = g_ui->get_input_mode_size(g_ui->get_input_mode(), DISPLAYMODE_LANDSCAPE);
size_portrait.height += g_candidate->get_height();
size_landscape.height += g_candidate->get_height();
- g_core.set_keyboard_size_hints(size_portrait, size_landscape);
+ ime_set_size(size_portrait.width, size_portrait.height, size_landscape.width, size_landscape.height);
LOGD("Showing candidate , position [%d %d] size [%d %d] [%d %d]", 0, g_candidate->get_height(),
size_portrait.width, size_portrait.height, size_landscape.width, size_landscape.height);
g_ui->set_custom_starting_coordinates(0, 0);
SclSize size_portrait = g_ui->get_input_mode_size(g_ui->get_input_mode(), DISPLAYMODE_PORTRAIT);
SclSize size_landscape = g_ui->get_input_mode_size(g_ui->get_input_mode(), DISPLAYMODE_LANDSCAPE);
- g_core.set_keyboard_size_hints(size_portrait, size_landscape);
+ ime_set_size(size_portrait.width, size_portrait.height, size_landscape.width, size_landscape.height);
LOGD("Hiding candidate , position [%d %d] size [%d %d] [%d %d]", 0, 0,
size_portrait.width, size_portrait.height, size_landscape.width, size_landscape.height);
if (!check_ic_temporary(g_keyboard_state.ic)) {
ic = g_keyboard_state.ic;
}
- g_core.commit_string(ic, "", key_value);
+ ime_commit_string(key_value);
LOGD("ic : %x, %s\n", ic, key_value);
}
ise_update_preedit_string(const sclchar *str, const sclboolean underline)
{
int ic = -1;
+ Eina_List *attr_list = NULL;
+ ime_preedit_attribute *preedit_attr;
+
if (!check_ic_temporary(g_keyboard_state.ic)) {
ic = g_keyboard_state.ic;
}
int len = 0;
const sclchar *s = str;
while (*s) len += (*s++ & 0xc0) != 0x80;
- scim::Attribute attr;
- attr.set_start(0);
- attr.set_length(len);
- attr.set_type(scim::SCIM_ATTR_DECORATE);
- attr.set_value(scim::SCIM_ATTR_DECORATE_UNDERLINE);
- std::vector<scim::Attribute> underline_attribute;
- underline_attribute.push_back(attr);
- g_core.update_preedit_string(ic, "", str, underline_attribute);
+
+ preedit_attr = (ime_preedit_attribute *)calloc(1, sizeof(ime_preedit_attribute));
+ preedit_attr->start = 0;
+ preedit_attr->length = len;
+ preedit_attr->type = IME_ATTR_FONTSTYLE;
+ preedit_attr->value = IME_ATTR_FONTSTYLE_UNDERLINE;
+ attr_list = eina_list_append(attr_list, (void *)preedit_attr);
+
+ ime_update_preedit_string(str, attr_list);
} else {
- g_core.update_preedit_string(ic, "", str);
+ ime_update_preedit_string(str, NULL);
}
LOGD("ic : %x, %s\n", ic, str);
}
if (!check_ic_temporary(g_keyboard_state.ic)) {
ic = g_keyboard_state.ic;
}
- g_core.send_key_event(ic, "", key_event, KEY_MASK_NULL);
- g_core.send_key_event(ic, "", key_event, KEY_MASK_RELEASE);
+ ime_send_key_event((ime_key_code_e)key_event, IME_KEY_MASK_PRESSED, false);
+ ime_send_key_event((ime_key_code_e)key_event, IME_KEY_MASK_RELEASED, false);
+
LOGD("ic : %x, %x\n", ic, key_event);
}
if (!check_ic_temporary(g_keyboard_state.ic)) {
ic = g_keyboard_state.ic;
}
- g_core.forward_key_event(ic, "", key_event, KEY_MASK_NULL);
- g_core.forward_key_event(ic, "", key_event, KEY_MASK_RELEASE);
+ ime_send_key_event((ime_key_code_e)key_event, IME_KEY_MASK_PRESSED, true);
+ ime_send_key_event((ime_key_code_e)key_event, IME_KEY_MASK_RELEASED, true);
+
LOGD("ic : %x, %x\n", ic, key_event);
}
static Eina_Bool commit_timeout(void *data)
{
if (_commit_timer != NULL) {
- g_core.hide_preedit_string(-1, "");
+ ime_hide_preedit_string();
ise_forward_key_event(_sig_dec_event[(_click_count-1)%SIG_DEC_SIZE]);
_click_count = 0;
}
current_emoticon_group = EMOTICON_GROUP_RECENTLY_USED;
#endif
SCLRotation rotation = g_ui->get_rotation();
- ise_show_emoticon_layout(current_emoticon_group, ROTATION_TO_DEGREE(rotation), false, g_core.get_main_window());
+ ise_show_emoticon_layout(current_emoticon_group, ROTATION_TO_DEGREE(rotation), false, ime_get_main_window());
}
}
}
size_portrait.height += g_candidate->get_height();
size_landscape.height += g_candidate->get_height();
}
- g_core.set_keyboard_size_hints(size_portrait, size_landscape);
+ ime_set_size(size_portrait.width, size_portrait.height, size_landscape.width, size_landscape.height);
if (strcmp(g_ui->get_input_mode(), "STT_3X4") == 0 &&
strcmp(desc->input_mode, "STT_3X4") != 0) {
}
if (strcmp(g_ui->get_input_mode(), "STT_3X4") != 0 &&
strcmp(desc->input_mode, "STT_3X4") == 0) {
- ise_show_stt_mode(NATIVE_WINDOW_CAST(g_core.get_main_window()));
+ ise_show_stt_mode(NATIVE_WINDOW_CAST(ime_get_main_window()));
}
}
}
}
if (input_mode && strcmp (input_mode, "NUMONLY_3X4_SIGDEC") == 0 &&
strcmp(event_desc.key_value, ".") == 0) {
- g_core.update_preedit_string(-1, "", _sig_dec[_click_count%SIG_DEC_SIZE]);
- g_core.show_preedit_string(-1, "");
+ ime_update_preedit_string(_sig_dec[_click_count%SIG_DEC_SIZE], NULL);
+ ime_show_preedit_string();
delete_commit_timer();
_commit_timer = ecore_timer_add(1.0, commit_timeout, NULL);
_click_count++;
}
//g_need_send_shift_event = TRUE;
} else if (strncmp(event_desc.key_value, delete_all, strlen(delete_all)) == 0) {
- g_core.delete_surrounding_text((INT_MAX / 2) * -1, INT_MAX);
+ ime_delete_surrounding_text((INT_MAX / 2) * -1, INT_MAX);
} else if (strncmp(event_desc.key_value, hide_panel, strlen(hide_panel)) == 0) {
::ise_hide();
- g_core.request_ise_hide();
+ ime_request_hide();
} else if (event_desc.key_event) {
ise_send_event(event_desc.key_event, KEY_MASK_NULL);
if (event_desc.key_event == MVK_Shift_L) {
}
} else if (strcmp(event_desc.key_value, USER_KEYSTRING_OPTION) == 0) {
if (!option_window_is_available (OPTION_WINDOW_TYPE_NORMAL))
- g_core.create_option_window();
+ ime_create_option_window();
ret = SCL_EVENT_DONE;
} else if (strcmp(event_desc.key_value, USER_KEYSTRING_CLIPBOARD) == 0) {
show_cbhm();
if (strcmp(event_desc.key_value, USER_KEYSTRING_OPTION) == 0) {
//open_option_window(NULL, ROTATION_TO_DEGREE(g_ui->get_rotation()));
if (!option_window_is_available (OPTION_WINDOW_TYPE_NORMAL))
- g_core.create_option_window();
+ ime_create_option_window();
ret = SCL_EVENT_DONE;
} else if (strcmp(event_desc.key_value, USER_KEYSTRING_CLIPBOARD) == 0) {
show_cbhm();
#endif
if ((group_id >= 0) && (group_id < MAX_EMOTICON_GROUP)) {
SCLRotation rotation = g_ui->get_rotation();
- ise_show_emoticon_layout(group_id, ROTATION_TO_DEGREE(rotation), false, g_core.get_main_window());
+ ise_show_emoticon_layout(group_id, ROTATION_TO_DEGREE(rotation), false, ime_get_main_window());
}
}
}
g_keyboard_state.layout == ISE_LAYOUT_STYLE_IP ||
g_keyboard_state.layout == ISE_LAYOUT_STYLE_MONTH ||
g_keyboard_state.layout == ISE_LAYOUT_STYLE_NUMBERONLY) {
- g_core.set_keyboard_ise_by_uuid(DEFAULT_KEYBOARD_ISE_UUID);
+ ime_set_imengine(DEFAULT_KEYBOARD_ISE_UUID);
}
}
}
g_keyboard_state.layout == ISE_LAYOUT_STYLE_IP ||
g_keyboard_state.layout == ISE_LAYOUT_STYLE_MONTH ||
g_keyboard_state.layout == ISE_LAYOUT_STYLE_NUMBERONLY) {
- g_core.set_keyboard_ise_by_uuid(DEFAULT_KEYBOARD_ISE_UUID);
+ ime_set_imengine(DEFAULT_KEYBOARD_ISE_UUID);
}
}
g_ui->enable_button("quotation", !filename_layout);
LOGD("new layout index : %d\n", layout_index);
- const sclchar *old_input_mode = g_ui->get_input_mode();
/* If this layout requires specific input mode, set it */
if (strlen(g_ise_default_values[layout_index].input_mode) > 0) {
g_ui->set_input_mode(g_ise_default_values[layout_index].input_mode);
size_portrait.height += g_candidate->get_height();
size_landscape.height += g_candidate->get_height();
}
- g_core.set_keyboard_size_hints(size_portrait, size_landscape);
+ ime_set_size(size_portrait.width, size_portrait.height, size_landscape.width, size_landscape.height);
} else {
if (force_primary_latin) {
_language_manager.select_language(PRIMARY_LATIN_LANGUAGE, TRUE);
current_emoticon_group = EMOTICON_GROUP_RECENTLY_USED;
#endif
SCLRotation rotation = g_ui->get_rotation();
- ise_show_emoticon_layout(current_emoticon_group, ROTATION_TO_DEGREE(rotation), false, g_core.get_main_window());
- }
- // Check whether inout panel geometry is changed.
- const sclchar *new_input_mode = g_ui->get_input_mode();
- if (g_keyboard_state.visible_state && old_input_mode && new_input_mode && strcmp(old_input_mode, new_input_mode)) {
- SclSize new_portrait = g_ui->get_input_mode_size(new_input_mode, DISPLAYMODE_PORTRAIT);
- SclSize new_landscape = g_ui->get_input_mode_size(new_input_mode, DISPLAYMODE_LANDSCAPE);
- LOGD("old input mode:%s, new input mode:%s, portrait(%d, %d), landscape(%d, %d)\n",
- old_input_mode, new_input_mode, new_portrait.width, new_portrait.height, new_landscape.width, new_landscape.height);
-
- sclint width = 0;
- sclint height = 0;
- g_ui->get_screen_resolution(&width, &height);
-
- SclSize old_size = {0, 0};
- SCLRotation rotation = g_ui->get_rotation();
- if (rotation == ROTATION_90_CW || rotation == ROTATION_90_CCW) {
- old_size = g_ui->get_input_mode_size(old_input_mode, DISPLAYMODE_LANDSCAPE);
- if (old_size.width != new_landscape.width || old_size.height != new_landscape.height)
- g_core.update_geometry(0, 0, new_landscape.width, new_landscape.height);
- } else {
- old_size = g_ui->get_input_mode_size(old_input_mode, DISPLAYMODE_PORTRAIT);
- if (old_size.width != new_portrait.width || old_size.height != new_portrait.height)
- g_core.update_geometry(0, height - new_portrait.height, new_portrait.width, new_portrait.height);
- }
+ ise_show_emoticon_layout(current_emoticon_group, ROTATION_TO_DEGREE(rotation), false, ime_get_main_window());
}
}
}
#endif
if (g_setting_window_open_status) {
- ise_show_stt_mode(NATIVE_WINDOW_CAST(g_core.get_main_window()));
+ ise_show_stt_mode(NATIVE_WINDOW_CAST(ime_get_main_window()));
}
g_setting_window_open_status = FALSE;
if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_VOICE) {
- ise_show_stt_mode(NATIVE_WINDOW_CAST(g_core.get_main_window()));
+ ise_show_stt_mode(NATIVE_WINDOW_CAST(ime_get_main_window()));
}
}
}
if (g_ui) {
- if (g_core.get_main_window()) {
+ if (ime_get_main_window()) {
sclboolean succeeded = FALSE;
const sclchar *entry_path = MAIN_ENTRY_XML_PATH;
if (resource_file_path) {
if (strlen(resource_file_path) > 0) {
- succeeded = g_ui->init(g_core.get_main_window(), scl_parser_type, resource_file_path);
+ succeeded = g_ui->init(ime_get_main_window(), scl_parser_type, resource_file_path);
}
}
if (!succeeded) {
- g_ui->init(g_core.get_main_window(), scl_parser_type, MAIN_ENTRY_XML_PATH);
+ g_ui->init(ime_get_main_window(), scl_parser_type, MAIN_ENTRY_XML_PATH);
}
- g_core.enable_soft_candidate(true);
-
g_ui->set_longkey_duration(elm_config_longpress_timeout_get() * 1000);
/* Default ISE callback */
size_portrait.height += g_candidate->get_height();
size_landscape.height += g_candidate->get_height();
}
- g_core.set_keyboard_size_hints(size_portrait, size_landscape);
+ ime_set_size(size_portrait.width, size_portrait.height, size_landscape.width, size_landscape.height);
}
init_recent_used_punctuation();
}
}
}
-int main(int argc, char *argv[])
+static void ime_app_create_cb(void *user_data)
+{
+ g_core_event_callback.on_init();
+}
+
+static void ime_app_exit_cb(void *user_data)
+{
+ g_core_event_callback.on_exit();
+}
+
+static void ime_app_show_cb(int ic, ime_context_h ime_ctx, void *user_data)
+{
+ Ise_Context iseContext;
+ bool return_key_state, prediction_allow, password_mode;
+ ime_layout_variation_e layout_variation;
+
+ ime_context_get_layout(ime_ctx, &iseContext.layout);
+
+ ime_context_get_layout_variation(ime_ctx, &layout_variation);
+ iseContext.layout_variation = (int)layout_variation;
+
+ ime_context_get_cursor_position(ime_ctx, &iseContext.cursor_pos);
+ ime_context_get_autocapital_type(ime_ctx, &iseContext.autocapital_type);
+ ime_context_get_return_key_type(ime_ctx, &iseContext.return_key_type);
+ ime_context_get_return_key_state(ime_ctx, &return_key_state);
+
+ ime_context_get_prediction_mode(ime_ctx, &prediction_allow);
+ iseContext.prediction_allow = prediction_allow;
+
+ ime_context_get_password_mode(ime_ctx, &password_mode);
+ iseContext.password_mode = password_mode;
+
+ ime_context_get_input_hint(ime_ctx, &iseContext.input_hint);
+ ime_context_get_bidi_direction(ime_ctx, &iseContext.bidi_direction);
+ ime_context_get_language(ime_ctx, &iseContext.language);
+ iseContext.return_key_disabled = return_key_state;
+
+ g_ic = ic;
+
+ g_core_event_callback.on_ise_show(ic, 0, iseContext);
+}
+
+static void ime_app_hide_cb(int ic, void *user_data)
+{
+ g_core_event_callback.on_ise_hide(ic, NULL);
+}
+
+static void ime_app_return_key_type_set_cb(Ecore_IMF_Input_Panel_Return_Key_Type type, void *user_data)
+{
+ LOGD("return key type : %d\n", type);
+ g_core_event_callback.on_set_return_key_type(type);
+}
+
+static void ime_app_return_key_state_set_cb(bool disabled, void *user_data)
+{
+ LOGD("return key disabled : %d\n", disabled);
+ g_core_event_callback.on_set_return_key_disable(disabled);
+}
+
+static void ime_app_cursor_position_updated_cb(int cursor_pos, void *user_data)
+{
+ LOGD("cursor position : %d\n", cursor_pos);
+ g_core_event_callback.on_update_cursor_position(g_ic, "", cursor_pos);
+}
+
+static void ime_app_surrounding_text_updated_cb(int context_id, const char *text, int cursor_pos, void *user_data)
{
- try {
- g_core.run();
- } catch (...) {
- LOGW("Exception is thrown from g_core.run()!!!\n");
+ LOGD("cursor position : %d\n", cursor_pos);
+ g_core_event_callback.on_update_surrounding_text(context_id, text, cursor_pos);
+}
+
+static void ime_app_focus_in_cb(int context_id, void *user_data)
+{
+ g_core_event_callback.on_focus_in(context_id, NULL);
+}
+
+static void ime_app_focus_out_cb(int context_id, void *user_data)
+{
+ g_core_event_callback.on_focus_out(context_id, NULL);
+}
+
+static void ime_app_layout_set_cb(Ecore_IMF_Input_Panel_Layout layout, void *user_data)
+{
+ g_core_event_callback.on_set_layout(layout);
+}
+
+static void ime_app_option_window_created_cb(Evas_Object *window, ime_option_window_type_e type, void *user_data)
+{
+ g_core_event_callback.on_create_option_window(SCL_WINDOW_CAST(window), (SCLOptionWindowType)type);
+}
+
+static void ime_app_option_window_destroyed_cb(Evas_Object *window, void *user_data)
+{
+ g_core_event_callback.on_destroy_option_window(SCL_WINDOW_CAST(window));
+}
+
+static void ime_app_rotation_degree_changed_cb(int degree, void *user_data)
+{
+ g_core_event_callback.on_set_rotation_degree(degree);
+}
+
+static void ime_app_imdata_set_cb(void *data, unsigned int data_length, void *user_data)
+{
+ g_core_event_callback.on_set_imdata((sclchar *)data, data_length);
+}
+
+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)
+{
+ scim::KeyEvent key(keycode, keymask);
+ unsigned int ret;
+ g_core_event_callback.on_process_key_event(key, &ret);
+
+ return ret;
+}
+
+static void ime_app_caps_mode_changed_cb(int mode, void *user_data)
+{
+ g_core_event_callback.on_set_caps_mode(mode);
+}
+
+static void ime_app_candidate_show_cb(int context_id, void *user_data)
+{
+ g_core_event_callback.on_candidate_show(context_id, "");
+}
+
+static void ime_app_candidate_hide_cb(int context_id, void *user_data)
+{
+ g_core_event_callback.on_candidate_hide(context_id, "");
+}
+
+static void ime_app_lookup_table_changed_cb(Eina_List *list, void *user_data)
+{
+ vector<string> candidate_strings;
+ char *candidate;
+ void *data;
+
+ if (list) {
+ EINA_LIST_FREE(list, data) {
+ candidate = (char *)data;
+ if (candidate) {
+ candidate_strings.push_back(string(candidate));
+ free(candidate);
+ }
+ }
}
+ ise_update_table(candidate_strings);
+}
+
+#ifdef __cplusplus
+extern "C"{
+#endif
+EXPORTED void ime_app_main(int argc, char **argv)
+{
+ ime_callback_s basic_callback = {
+ ime_app_create_cb,
+ ime_app_exit_cb,
+ ime_app_show_cb,
+ ime_app_hide_cb
+ };
+
+ ime_event_set_focus_in_cb(ime_app_focus_in_cb, NULL);
+ ime_event_set_focus_out_cb(ime_app_focus_out_cb, NULL);
+ ime_event_set_rotation_degree_changed_cb(ime_app_rotation_degree_changed_cb, NULL);
+ ime_event_set_layout_set_cb(ime_app_layout_set_cb, NULL);
+ ime_event_set_caps_mode_changed_cb(ime_app_caps_mode_changed_cb, NULL);
+
+ ime_event_set_cursor_position_updated_cb(ime_app_cursor_position_updated_cb, NULL);
+ ime_event_set_surrounding_text_updated_cb(ime_app_surrounding_text_updated_cb, NULL);
+ ime_event_set_return_key_type_set_cb(ime_app_return_key_type_set_cb, NULL);
+ ime_event_set_return_key_state_set_cb(ime_app_return_key_state_set_cb, NULL);
+ ime_event_set_imdata_set_cb(ime_app_imdata_set_cb, NULL);
+ ime_event_set_option_window_created_cb(ime_app_option_window_created_cb, NULL);
+ ime_event_set_option_window_destroyed_cb(ime_app_option_window_destroyed_cb, NULL);
+ ime_event_set_process_key_event_cb(ime_app_process_key_event_cb, NULL);
+
+ ime_event_set_candidate_show_cb(ime_app_candidate_show_cb, NULL);
+ ime_event_set_candidate_hide_cb(ime_app_candidate_hide_cb, NULL);
+ ime_event_set_lookup_table_changed_cb(ime_app_lookup_table_changed_cb, NULL);
+
+ ime_run(&basic_callback, NULL);
+}
+#ifdef __cplusplus
+}
+#endif
+
+int main(int argc, char *argv[])
+{
+ ime_app_main(argc, argv);
+
return 0;
}