2 * Copyright (c) 2014 - 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.
18 #include "sclconnection-isf.h"
19 #include "sclcoreimpl.h"
20 #include <Elementary.h>
24 #include "legacy_support/websocket.h"
25 extern CWebHelperAgentWebSocket g_websocket;
30 static scim::ConfigPointer _scim_config(0);
32 /* Slot functions for calling appropriate callback functions */
33 static void slot_exit(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) {
34 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
36 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
38 callback->on_ise_hide(ic, ic_uuid.c_str());
43 agent->update_ise_exit();
50 static void slot_attach_input_context(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) {
51 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
53 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
55 callback->on_attach_input_context(ic, ic_uuid.c_str());
60 static void slot_detach_input_context(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) {
61 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
63 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
65 callback->on_detach_input_context(ic, ic_uuid.c_str());
70 static void slot_reload_config(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) {
71 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
73 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
75 callback->on_reload_config(ic, ic_uuid.c_str());
80 static void slot_update_screen(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid, int screen_number) {
81 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
83 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
85 //callback->on_update_screen(ic, ic_uuid.c_str(), screen_number);
90 static void slot_update_spot_location(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid, int x, int y) {
91 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
93 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
95 callback->on_update_spot_location(ic, ic_uuid.c_str(), x, y);
100 static void slot_update_cursor_position(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid, int cursor_pos) {
101 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
103 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
105 callback->on_update_cursor_position(ic, ic_uuid.c_str(), cursor_pos);
107 g_websocket.on_update_cursor_position(ic, cursor_pos);
113 static void slot_update_surrounding_text(const scim::HelperAgent *agent, int ic, const scim::String &text, int cursor) {
114 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
116 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
118 callback->on_update_surrounding_text(ic, text.c_str(), cursor);
120 g_websocket.on_update_surrounding_text(ic, text.c_str(), cursor);
126 static void slot_trigger_property(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid, const scim::String &property) {
127 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
129 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
131 //callback->on_trigger_property(ic, ic_uuid.c_str(), property.c_str());
136 static void slot_focus_out(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) {
137 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
139 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
141 callback->on_focus_out(ic, ic_uuid.c_str());
143 g_websocket.on_focus_out(ic);
149 static void slot_focus_in(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) {
150 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
152 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
154 callback->on_focus_in(ic, ic_uuid.c_str());
156 g_websocket.on_focus_in(ic);
162 static void slot_ise_show(const scim::HelperAgent *agent, int ic, char *buf, size_t &len) {
163 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
165 /* Make sure the appropriate keyboard ise was selected -> is this really necessary? */
166 //impl->set_keyboard_ise_by_uuid(impl->get_keyboard_ise_uuid().c_str());
168 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
170 /* Check if effect is enabled */
171 Ise_Context ise_context;
172 memset(&ise_context, 0x00, sizeof(ise_context));
174 if (len >= sizeof(Ise_Context)) {
175 memcpy(&ise_context, buf, sizeof(ise_context));
177 if (ise_context.imdata_size > 0) {
178 char imdata[1024] = {0};
179 memcpy((void *)imdata, buf + sizeof(ise_context), ise_context.imdata_size);
180 callback->on_set_imdata(imdata, ise_context.imdata_size);
183 if (len > (sizeof(Ise_Context) + ise_context.imdata_size))
184 callback->on_set_mime_type(buf + sizeof(ise_context) + ise_context.imdata_size);
186 LOGD("\n-=-= WARNING - buf %p len %zu size %zu\n", buf, len, sizeof(ise_context));
188 CSCLCoreUI* ui = impl->get_core_ui();
190 ui->process_keyboard_ui_state_change(KEYBOARD_UI_STATE_WILL_SHOW);
192 callback->on_ise_show(ic, impl->get_screen_rotation_degree(), ise_context);
194 ui->process_keyboard_ui_state_change(KEYBOARD_UI_STATE_DID_SHOW);
198 g_websocket.on_set_layout(ise_context.layout);
199 g_websocket.on_update_cursor_position(ic, ise_context.cursor_pos);
200 g_websocket.on_show(ic);
206 static void slot_ise_hide(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) {
207 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
209 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
211 CSCLCoreUI* ui = impl->get_core_ui();
213 ui->process_keyboard_ui_state_change(KEYBOARD_UI_STATE_WILL_HIDE);
215 callback->on_ise_hide(ic, ic_uuid.c_str());
217 ui->process_keyboard_ui_state_change(KEYBOARD_UI_STATE_DID_HIDE);
221 g_websocket.on_hide(ic);
227 static void slot_get_geometry(const scim::HelperAgent *agent, struct scim::rectinfo &info) {
228 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
230 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
232 callback->on_get_geometry(&(info.pos_x), &(info.pos_y), &(info.width), &(info.height));
237 static void slot_set_mode(const scim::HelperAgent *agent, scim::uint32 &mode) {
238 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
240 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
242 callback->on_set_mode(mode);
247 static void slot_set_language(const scim::HelperAgent *agent, scim::uint32 &language) {
248 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
250 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
252 callback->on_set_language(language);
254 g_websocket.on_set_language(language);
260 static void slot_set_imdata(const scim::HelperAgent *agent, char *buf, size_t &len) {
261 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
263 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
265 scl32 _len = static_cast<scl32>(reinterpret_cast<size_t>(len) & 0xffffffff);
266 callback->on_set_imdata(buf, _len);
268 g_websocket.on_set_imdata(buf, len);
274 static void slot_get_imdata(const scim::HelperAgent *, char **buf, size_t &len) {
275 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
277 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
280 callback->on_get_imdata(buf, &_len);
282 g_websocket.on_get_imdata(buf, &_len);
289 static void slot_get_language_locale(const scim::HelperAgent *, int ic, char **locale) {
290 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
292 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
294 callback->on_get_language_locale(ic, locale);
299 static void slot_set_return_key_type(const scim::HelperAgent *agent, scim::uint32 &type) {
300 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
302 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
304 callback->on_set_return_key_type(type);
306 g_websocket.on_set_return_key_type(type);
312 static void slot_get_return_key_type(const scim::HelperAgent *agent, scim::uint32 &type) {
313 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
315 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
317 callback->on_get_return_key_type(&type);
319 g_websocket.on_get_return_key_type(&type);
325 static void slot_set_return_key_disable(const scim::HelperAgent *agent, scim::uint32 &disabled) {
326 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
328 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
330 callback->on_set_return_key_disable(disabled);
332 g_websocket.on_set_return_key_disable(disabled);
338 static void slot_get_return_key_disable(const scim::HelperAgent *agent, scim::uint32 &disabled) {
339 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
341 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
343 callback->on_get_return_key_disable(&disabled);
345 g_websocket.on_get_return_key_disable(&disabled);
351 static void slot_set_layout(const scim::HelperAgent *agent, scim::uint32 &layout) {
352 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
354 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
356 callback->on_set_layout(layout);
358 g_websocket.on_set_layout(layout);
364 static void slot_get_layout(const scim::HelperAgent *agent, scim::uint32 &layout) {
365 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
367 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
369 callback->on_get_layout(&layout);
371 g_websocket.on_get_layout(&layout);
377 static void slot_set_caps_mode(const scim::HelperAgent *agent, scim::uint32 &mode) {
378 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
380 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
382 callback->on_set_caps_mode(mode);
387 static void slot_reset_input_context(const scim::HelperAgent *agent, int ic, const scim::String &uuid) {
388 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
390 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
392 callback->on_reset_input_context(ic, uuid.c_str());
394 g_websocket.on_reset_input_context(ic);
400 static void slot_update_candidate_geometry(const scim::HelperAgent *agent, int ic, const scim::String &uuid, const scim::rectinfo &info) {
401 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
403 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
405 callback->on_update_candidate_geometry(ic, uuid.c_str(), info.pos_x, info.pos_y, info.width, info.height);
409 static void slot_update_keyboard_ise(const scim::HelperAgent *agent, int ic, const scim::String &uuid,
410 const scim::String &ise_name, const scim::String &ise_uuid) {
411 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
413 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
415 callback->on_update_keyboard_ise(ic, uuid.c_str(), ise_name.c_str(), ise_uuid.c_str());
420 static void slot_candidate_more_window_show(const scim::HelperAgent *agent, int ic, const scim::String &uuid) {
421 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
423 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
425 callback->on_candidate_more_window_show(ic, uuid.c_str());
430 static void slot_candidate_more_window_hide(const scim::HelperAgent *agent, int ic, const scim::String &uuid) {
431 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
433 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
435 callback->on_candidate_more_window_hide(ic, uuid.c_str());
440 static void slot_select_aux(const scim::HelperAgent *agent, int ic, const scim::String &uuid, int index) {
441 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
443 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
445 callback->on_select_aux(ic, uuid.c_str(), index);
450 static void slot_select_candidate(const scim::HelperAgent *agent, int ic, const scim::String &uuid, int index) {
451 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
453 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
455 callback->on_select_candidate(ic, uuid.c_str(), index);
460 static void slot_candidate_table_page_up(const scim::HelperAgent *agent, int ic, const scim::String &uuid) {
461 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
463 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
465 callback->on_candidate_table_page_up(ic, uuid.c_str());
470 static void slot_candidate_table_page_down(const scim::HelperAgent *agent, int ic, const scim::String &uuid) {
471 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
473 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
475 callback->on_candidate_table_page_down(ic, uuid.c_str());
480 static void slot_update_candidate_table_page_size(const scim::HelperAgent *, int ic, const scim::String &uuid, int page_size) {
481 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
483 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
485 callback->on_update_candidate_table_page_size(ic, uuid.c_str(), page_size);
490 static void slot_update_lookup_table(const scim::HelperAgent *, scim::LookupTable &table) {
491 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
493 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
495 SclCandidateTable lookup_table;
496 lookup_table.page_size = table.get_page_size();
497 lookup_table.current_page_start = table.get_current_page_start();
498 lookup_table.cursor_pos = table.get_cursor_pos();
499 lookup_table.cursor_visible = table.is_cursor_visible();
500 lookup_table.page_size_fixed = table.is_page_size_fixed();
501 lookup_table.candidate_labels.clear();
502 for (int page_index = 0;page_index < lookup_table.page_size;page_index++) {
503 scim::WideString label = table.get_candidate_label(page_index);
504 lookup_table.candidate_labels.push_back(scim::utf8_wcstombs(label).c_str());
507 int nCandidateSize = table.get_current_page_size();
508 for (int index = 0; index < nCandidateSize; ++index) {
509 scim::WideString candidate_str = table.get_candidate_in_current_page(index);
510 lookup_table.candidate.push_back(scim::utf8_wcstombs(candidate_str).c_str());
513 callback->on_update_lookup_table(lookup_table);
515 std::vector<scim::WideString> labels;
516 for (unsigned int loop = 0;loop < lookup_table.candidate_labels.size();loop++) {
517 labels.push_back(scim::utf8_mbstowcs(lookup_table.candidate_labels.at(loop).c_str()));
519 table.set_candidate_labels(labels);
524 static void slot_select_associate(const scim::HelperAgent *agent, int ic, const scim::String &uuid, int index) {
525 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
527 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
529 callback->on_select_associate(ic, uuid.c_str(), index);
534 static void slot_associate_table_page_up(const scim::HelperAgent *agent, int ic, const scim::String &uuid) {
535 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
537 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
539 callback->on_associate_table_page_up(ic, uuid.c_str());
544 static void slot_associate_table_page_down(const scim::HelperAgent *agent, int ic, const scim::String &uuid) {
545 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
547 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
549 callback->on_associate_table_page_down(ic, uuid.c_str());
554 static void slot_update_associate_table_page_size(const scim::HelperAgent *, int ic, const scim::String &uuid, int page_size) {
555 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
557 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
559 callback->on_update_associate_table_page_size(ic, uuid.c_str(), page_size);
564 static void slot_show_ise_option_window(const scim::HelperAgent *agent, int ic, const scim::String &uuid) {
565 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
567 CSCLCoreUI *core_ui = impl->get_core_ui();
569 LOGD("slot_show_ise_option_window() called!!!\n");
570 core_ui->create_option_window(OPTION_WINDOW_TYPE_SETTING_APPLICATION);
575 static void slot_resume_ise_option_window(const scim::HelperAgent *agent, int ic, const scim::String &uuid) {
576 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
578 CSCLCoreUI *core_ui = impl->get_core_ui();
580 LOGD("slot_resume_ise_option_window() called!!!\n");
581 core_ui->show_option_window(OPTION_WINDOW_TYPE_SETTING_APPLICATION);
586 static void slot_check_ise_option_window(const scim::HelperAgent *agent, sclu32 &avail) {
587 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
589 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
591 callback->on_check_option_window_availability(reinterpret_cast<sclboolean *>(&avail));
596 static void slot_process_key_event(const scim::HelperAgent *agent, scim::KeyEvent &key, scim::uint32 &ret) {
597 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
599 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
601 callback->on_process_key_event(key, &ret);
602 #ifdef WEBSOCKETweb_ret
603 g_websocket.on_process_key_event(key.code, key.mask, key.layout, &ret);
609 static void slot_candidate_show(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) {
610 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
612 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
614 callback->on_candidate_show(ic, ic_uuid.c_str());
619 static void slot_candidate_hide(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) {
620 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
622 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
624 callback->on_candidate_hide(ic, ic_uuid.c_str());
629 static void slot_process_input_device_event(const scim::HelperAgent *agent, scim::uint32 &type, char *data, size_t &len, scim::uint32 &ret) {
630 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
632 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
634 /* Input Device Event callback is available in versions after 1.1 */
635 if (check_interface_version(callback, 1, 1)) {
636 callback->on_process_input_device_event(type, data, len, &ret);
642 static void slot_set_prediction_hint(const scim::HelperAgent *agent, const scim::String &prediction_hint) {
643 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
645 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
647 callback->on_set_prediction_hint(prediction_hint.c_str());
652 static void slot_set_mime_type(const scim::HelperAgent *agent, const scim::String &mime_type) {
653 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
655 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
657 callback->on_set_mime_type(mime_type.c_str());
662 static void slot_set_prediction_hint_data(const scim::HelperAgent *agent, int ic, const scim::String &key, const scim::String &value) {
663 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
665 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
667 SECURE_LOGD("key : %s, value : %s\n", key.c_str(), value.c_str());
668 callback->on_set_prediction_hint_data(key.c_str(), value.c_str());
673 static void slot_set_optimization_hint(const scim::HelperAgent *agent, scim::uint32 &hint) {
674 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
676 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
678 SECURE_LOGD("hint : %d\n", hint);
679 callback->on_set_optimization_hint(hint);
684 /* Internal input handler function */
685 Eina_Bool input_handler(void *data, Ecore_Fd_Handler *fd_handler)
687 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
689 scim::HelperAgent *agent = static_cast<scim::HelperAgent*>(data);
691 if (agent->has_pending_event()) {
692 if (!(agent->filter_event())) {
693 LOGD("helper_agent.filter_event() failed!!!\n");
698 LOGD("helper_agent.has_pending_event() failed!!!\n");
705 return ECORE_CALLBACK_RENEW;
708 CSCLConnectionISF::CSCLConnectionISF()
710 m_initialized = FALSE;
713 m_backend_identifier = "ISF";
716 CSCLConnectionISF::~CSCLConnectionISF()
720 sclboolean CSCLConnectionISF::init()
724 if (!m_initialized) {
725 m_helper_agent.signal_connect_exit(scim::slot(slot_exit));
726 m_helper_agent.signal_connect_attach_input_context(scim::slot(slot_attach_input_context));
727 m_helper_agent.signal_connect_detach_input_context(scim::slot(slot_detach_input_context));
728 m_helper_agent.signal_connect_reload_config(scim::slot(slot_reload_config));
729 m_helper_agent.signal_connect_update_screen(scim::slot(slot_update_screen));
730 m_helper_agent.signal_connect_update_spot_location(scim::slot(slot_update_spot_location));
731 m_helper_agent.signal_connect_update_cursor_position(scim::slot(slot_update_cursor_position));
732 m_helper_agent.signal_connect_update_surrounding_text(scim::slot(slot_update_surrounding_text));
733 m_helper_agent.signal_connect_trigger_property(scim::slot(slot_trigger_property));
734 //m_helper_agent.signal_connect_process_imengine_event (slot (slot_process_imengine_event));
735 m_helper_agent.signal_connect_focus_out(scim::slot(slot_focus_out));
736 m_helper_agent.signal_connect_focus_in(scim::slot(slot_focus_in));
737 m_helper_agent.signal_connect_ise_show(scim::slot(slot_ise_show));
738 m_helper_agent.signal_connect_ise_hide(scim::slot(slot_ise_hide));
739 m_helper_agent.signal_connect_get_geometry(scim::slot(slot_get_geometry));
740 m_helper_agent.signal_connect_set_mode(scim::slot(slot_set_mode));
741 m_helper_agent.signal_connect_set_language(scim::slot(slot_set_language));
742 m_helper_agent.signal_connect_set_imdata(scim::slot(slot_set_imdata));
743 m_helper_agent.signal_connect_get_imdata(scim::slot(slot_get_imdata));
744 m_helper_agent.signal_connect_get_language_locale(scim::slot(slot_get_language_locale));
745 m_helper_agent.signal_connect_set_return_key_type(scim::slot(slot_set_return_key_type));
746 m_helper_agent.signal_connect_get_return_key_type(scim::slot(slot_get_return_key_type));
747 m_helper_agent.signal_connect_set_return_key_disable(scim::slot(slot_set_return_key_disable));
748 m_helper_agent.signal_connect_get_return_key_disable(scim::slot(slot_get_return_key_disable));
749 m_helper_agent.signal_connect_get_layout(scim::slot(slot_get_layout));
750 m_helper_agent.signal_connect_set_layout(scim::slot(slot_set_layout));
751 m_helper_agent.signal_connect_set_caps_mode(scim::slot(slot_set_caps_mode));
752 m_helper_agent.signal_connect_reset_input_context(scim::slot(slot_reset_input_context));
753 m_helper_agent.signal_connect_update_candidate_geometry(scim::slot(slot_update_candidate_geometry));
754 m_helper_agent.signal_connect_update_keyboard_ise(scim::slot(slot_update_keyboard_ise));
755 //m_helper_agent.signal_connect_update_keyboard_ise_list (slot (slot_update_keyboard_ise_list));
756 m_helper_agent.signal_connect_candidate_more_window_show(scim::slot(slot_candidate_more_window_show));
757 m_helper_agent.signal_connect_candidate_more_window_hide(scim::slot(slot_candidate_more_window_hide));
758 m_helper_agent.signal_connect_select_aux(scim::slot(slot_select_aux));
759 m_helper_agent.signal_connect_select_candidate(scim::slot(slot_select_candidate));
760 m_helper_agent.signal_connect_candidate_table_page_up(scim::slot(slot_candidate_table_page_up));
761 m_helper_agent.signal_connect_candidate_table_page_down(scim::slot(slot_candidate_table_page_down));
762 m_helper_agent.signal_connect_update_candidate_table_page_size(scim::slot(slot_update_candidate_table_page_size));
763 m_helper_agent.signal_connect_update_lookup_table(scim::slot(slot_update_lookup_table));
764 m_helper_agent.signal_connect_select_associate(scim::slot(slot_select_associate));
765 m_helper_agent.signal_connect_associate_table_page_up(scim::slot(slot_associate_table_page_up));
766 m_helper_agent.signal_connect_associate_table_page_down(scim::slot(slot_associate_table_page_down));
767 m_helper_agent.signal_connect_update_associate_table_page_size(scim::slot(slot_update_associate_table_page_size));
768 m_helper_agent.signal_connect_show_option_window(scim::slot(slot_show_ise_option_window));
769 m_helper_agent.signal_connect_resume_option_window(scim::slot(slot_resume_ise_option_window));
770 m_helper_agent.signal_connect_check_option_window(scim::slot(slot_check_ise_option_window));
771 m_helper_agent.signal_connect_process_key_event(scim::slot(slot_process_key_event));
772 m_helper_agent.signal_connect_candidate_show(scim::slot(slot_candidate_show));
773 m_helper_agent.signal_connect_candidate_hide(scim::slot(slot_candidate_hide));
774 m_helper_agent.signal_connect_process_input_device_event(scim::slot(slot_process_input_device_event));
775 m_helper_agent.signal_connect_set_prediction_hint(scim::slot(slot_set_prediction_hint));
776 m_helper_agent.signal_connect_set_mime_type(scim::slot(slot_set_mime_type));
777 m_helper_agent.signal_connect_set_prediction_hint_data(scim::slot(slot_set_prediction_hint_data));
778 m_helper_agent.signal_connect_set_optimization_hint(scim::slot(slot_set_optimization_hint));
780 m_initialized = TRUE;
783 if (_scim_config.null()) {
784 scim::ConfigPointer config_pointer = scim::ConfigBase::get(true, "socket");
785 if (config_pointer.null()) {
786 config_pointer = new scim::DummyConfig();
788 _scim_config = config_pointer;
794 void CSCLConnectionISF::fini()
796 if (!_scim_config.null()) {
797 _scim_config.reset();
799 scim::ConfigBase::set(0);
801 m_initialized = FALSE;
804 void CSCLConnectionISF::open_connection(const sclchar *display)
807 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
809 sclchar *uuid = impl->get_uuid();
811 m_helper_info.uuid = uuid;
815 m_helper_agent.open_connection(m_helper_info, display);
816 int fd = m_helper_agent.get_connection_number();
820 Evas_Object *main_window = NULL;
821 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
823 main_window = NATIVE_WINDOW_CAST(impl->get_main_window());
826 Ecore_X_Window xwindow = elm_win_xwindow_get(main_window);
828 snprintf(xid, 255, "%d", xwindow);
829 scim::Property prop(xid, "XID", "", "");
830 scim::PropertyList props;
831 props.push_back(prop);
832 m_helper_agent.register_properties(props);
835 m_fd_handler = ecore_main_fd_handler_add(fd, ECORE_FD_READ, input_handler, &m_helper_agent, NULL, NULL);
840 void CSCLConnectionISF::close_connection()
844 ecore_main_fd_handler_del(m_fd_handler);
847 m_helper_agent.update_ise_exit();
848 m_helper_agent.close_connection();
852 void CSCLConnectionISF::config_reload()
855 m_helper_agent.reload_config();
859 sclboolean CSCLConnectionISF::config_read_int(const sclchar *name, sclint &value)
861 sclboolean ret = FALSE;
862 if (m_initialized && _scim_config) {
863 value = _scim_config->read(name, value);
869 sclboolean CSCLConnectionISF::config_read_string(const sclchar *name, std::string &value)
871 sclboolean ret = FALSE;
872 if (m_initialized && _scim_config) {
873 value = _scim_config->read(name, value);
879 sclboolean CSCLConnectionISF::config_write_int(const sclchar *name, sclint value)
881 sclboolean ret = FALSE;
882 if (m_initialized && _scim_config) {
883 _scim_config->write(name, value);
889 sclboolean CSCLConnectionISF::config_write_string(const sclchar *name, const std::string value)
891 sclboolean ret = FALSE;
892 if (m_initialized && _scim_config) {
893 _scim_config->write(name, value);
899 sclboolean CSCLConnectionISF::config_erase(const sclchar *name)
901 sclboolean ret = FALSE;
902 if (m_initialized && _scim_config) {
903 _scim_config->erase(name);
909 sclboolean CSCLConnectionISF::config_flush(void)
911 sclboolean ret = FALSE;
912 if (m_initialized && _scim_config) {
913 _scim_config->flush();
919 void CSCLConnectionISF::send_imengine_event(sclint ic, const sclchar *ic_uuid, const sclint command, const sclu32 value)
924 uuid = scim::String(ic_uuid);
926 scim::Transaction trans;
927 trans.put_command(command);
928 trans.put_data(value);
929 m_helper_agent.send_imengine_event(ic, uuid, trans);
933 void CSCLConnectionISF::reset_keyboard_ise()
936 m_helper_agent.reset_keyboard_ise();
940 void CSCLConnectionISF::flush_keyboard_ise()
943 m_helper_agent.flush_keyboard_ise();
947 void CSCLConnectionISF::send_key_event(sclint ic, const sclchar *ic_uuid, sclu32 keycode, sclu16 keymask)
952 uuid = scim::String(ic_uuid);
954 scim::KeyEvent event;
955 event.code = keycode;
956 event.mask = keymask;
957 m_helper_agent.send_key_event(ic, uuid, event);
961 void CSCLConnectionISF::forward_key_event(sclint ic, const sclchar *ic_uuid, sclu32 keycode, sclu16 keymask)
966 uuid = scim::String(ic_uuid);
968 scim::KeyEvent event;
969 event.code = keycode;
970 event.mask = keymask;
971 m_helper_agent.forward_key_event(ic, uuid, event);
975 void CSCLConnectionISF::commit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str)
980 uuid = scim::String(ic_uuid);
982 m_helper_agent.commit_string(ic, uuid, scim::utf8_mbstowcs(str));
986 void CSCLConnectionISF::select_candidate(int index)
989 m_helper_agent.select_candidate(index);
993 void CSCLConnectionISF::show_preedit_string(sclint ic, const sclchar *ic_uuid)
998 uuid = scim::String(ic_uuid);
1000 m_helper_agent.show_preedit_string(ic, uuid);
1004 void CSCLConnectionISF::show_aux_string(void)
1006 if (m_initialized) {
1007 m_helper_agent.show_aux_string();
1011 void CSCLConnectionISF::show_candidate_string(void)
1013 if (m_initialized) {
1014 m_helper_agent.show_candidate_string();
1018 void CSCLConnectionISF::show_associate_string(void)
1020 if (m_initialized) {
1021 m_helper_agent.show_associate_string();
1025 void CSCLConnectionISF::hide_preedit_string(sclint ic, const sclchar *ic_uuid)
1027 if (m_initialized) {
1030 uuid = scim::String(ic_uuid);
1032 m_helper_agent.hide_preedit_string(ic, uuid);
1036 void CSCLConnectionISF::hide_aux_string(void)
1038 if (m_initialized) {
1039 m_helper_agent.hide_aux_string();
1043 void CSCLConnectionISF::hide_candidate_string(void)
1045 if (m_initialized) {
1046 m_helper_agent.hide_candidate_string();
1050 void CSCLConnectionISF::hide_associate_string(void)
1052 if (m_initialized) {
1053 m_helper_agent.hide_associate_string();
1057 void CSCLConnectionISF::update_preedit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str)
1059 if (m_initialized) {
1060 scim::AttributeList list;
1063 uuid = scim::String(ic_uuid);
1065 m_helper_agent.update_preedit_string(ic, uuid, scim::utf8_mbstowcs(str), list);
1067 if (str && strlen(str) > 0) {
1068 show_preedit_string(ic, ic_uuid);
1070 hide_preedit_string(ic, ic_uuid);
1075 void CSCLConnectionISF::update_preedit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str, const scim::AttributeList &attrs)
1077 if (m_initialized) {
1080 uuid = scim::String(ic_uuid);
1082 m_helper_agent.update_preedit_string(ic, uuid, scim::utf8_mbstowcs(str), attrs);
1084 if (str && strlen(str) > 0) {
1085 show_preedit_string(ic, ic_uuid);
1087 hide_preedit_string(ic, ic_uuid);
1092 void CSCLConnectionISF::update_aux_string(const sclchar *str)
1094 if (m_initialized) {
1095 scim::AttributeList list;
1096 m_helper_agent.update_aux_string(scim::String(str), list);
1100 void CSCLConnectionISF::update_input_context(sclu32 type, sclu32 value)
1102 if (m_initialized) {
1103 m_helper_agent.update_input_context(type, value);
1107 void CSCLConnectionISF::update_geometry(sclint x, sclint y, sclint width, sclint height)
1109 if (m_initialized) {
1110 m_helper_agent.update_geometry(x, y, width, height);
1114 void CSCLConnectionISF::get_surrounding_text(const sclchar *ic_uuid, sclint maxlen_before, sclint maxlen_after) const
1116 if (m_initialized) {
1119 uuid = scim::String(ic_uuid);
1121 m_helper_agent.get_surrounding_text(uuid, maxlen_before, maxlen_after);
1125 sclint CSCLConnectionISF::get_surrounding_text(sclint maxlen_before, sclint maxlen_after, sclchar **text, int &cursor)
1127 if (m_initialized) {
1128 scim::String surrounding_text;
1129 m_helper_agent.get_surrounding_text(maxlen_before, maxlen_after, surrounding_text, cursor);
1132 *text = strdup(surrounding_text.c_str());
1133 if (*text == NULL) {
1141 void CSCLConnectionISF::delete_surrounding_text(sclint offset, sclint len) const
1143 if (m_initialized) {
1144 m_helper_agent.delete_surrounding_text(offset, len);
1148 void CSCLConnectionISF::set_candidate_position(sclint left, sclint top)
1150 if (m_initialized) {
1151 m_helper_agent.set_candidate_position(left, top);
1155 void CSCLConnectionISF::enable_soft_candidate(sclboolean enable)
1157 if (m_initialized) {
1159 m_helper_agent.set_candidate_style(scim::ONE_LINE_CANDIDATE, scim::SOFT_CANDIDATE_WINDOW);
1161 m_helper_agent.set_candidate_style(scim::ONE_LINE_CANDIDATE, scim::FIXED_CANDIDATE_WINDOW);
1165 void CSCLConnectionISF::candidate_hide(void)
1167 if (m_initialized) {
1168 m_helper_agent.candidate_hide();
1172 void CSCLConnectionISF::set_keyboard_ise_by_uuid(const sclchar *uuid)
1174 if (m_initialized) {
1175 m_helper_agent.set_keyboard_ise_by_uuid(uuid);
1179 void CSCLConnectionISF::get_keyboard_ise(const sclchar *uuid)
1181 if (m_initialized) {
1182 m_helper_agent.get_keyboard_ise(uuid);
1186 void CSCLConnectionISF::set_selection(sclint start, sclint end)
1188 if (m_initialized) {
1189 m_helper_agent.set_selection(start, end);
1193 void CSCLConnectionISF::send_private_command(const sclchar *command)
1195 Eina_Bool tc_command = EINA_FALSE;
1196 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
1197 ISCLCoreEventCallback *callback = NULL;
1199 callback = impl->get_core_event_callback();
1201 if (command && callback) {
1202 if (strcmp(command, "tizen::tc::test") == 0) {
1203 static Ise_Context context;
1204 static SclCandidateTable table;
1205 static scim::KeyEvent key;
1209 callback->on_attach_input_context(0, "");
1210 callback->on_detach_input_context(0, "");
1211 callback->on_reload_config(0, "");
1212 callback->on_update_spot_location(0, "", 0, 0);
1213 callback->on_update_cursor_position(0, "", 0);
1214 callback->on_update_surrounding_text(0, NULL, 0);
1215 callback->on_focus_out(0, "");
1216 callback->on_focus_in(0, "");
1217 callback->on_ise_show(0, 0, context);
1218 callback->on_ise_hide(0, "");
1219 callback->on_get_geometry(NULL, NULL, NULL, NULL);
1220 callback->on_set_mode(0);
1221 callback->on_set_language(0);
1222 callback->on_set_imdata(NULL, 0);
1223 callback->on_get_imdata(NULL, NULL);
1224 callback->on_get_language_locale(0, NULL);
1225 callback->on_set_return_key_type(0);
1226 callback->on_get_return_key_type(NULL);
1227 callback->on_set_return_key_disable(0);
1228 callback->on_get_return_key_disable(NULL);
1229 callback->on_set_layout(0);
1230 callback->on_get_layout(NULL);
1231 callback->on_set_caps_mode(0);
1232 callback->on_reset_input_context(0, NULL);
1233 callback->on_update_candidate_geometry(0, NULL, 0, 0, 0, 0);
1234 callback->on_update_keyboard_ise(0, NULL, NULL, NULL);
1235 callback->on_candidate_more_window_show(0, NULL);
1236 callback->on_candidate_more_window_hide(0, NULL);
1237 callback->on_select_aux(0, NULL, 0);
1238 callback->on_select_candidate(0, NULL, 0);
1239 callback->on_candidate_table_page_up(0, NULL);
1240 callback->on_candidate_table_page_down(0, NULL);
1241 callback->on_update_lookup_table(table);
1242 callback->on_update_candidate_table_page_size(0, NULL, 0);
1243 callback->on_select_associate(0, NULL, 0);
1244 callback->on_associate_table_page_up(0, NULL);
1245 callback->on_associate_table_page_down(0, NULL);
1246 callback->on_update_associate_table_page_size(0, NULL, 0);
1247 callback->on_process_key_event(key, NULL);
1249 callback->on_set_display_language(NULL);
1250 callback->on_set_rotation_degree(0);
1251 callback->on_set_accessibility_state(FALSE);
1253 callback->on_create_option_window(SCLWINDOW_INVALID, OPTION_WINDOW_TYPE_NORMAL);
1254 callback->on_destroy_option_window(SCLWINDOW_INVALID);
1255 callback->on_check_option_window_availability(NULL);
1257 callback->on_candidate_show(0, "");
1258 callback->on_candidate_hide(0, "");
1260 callback->on_process_input_device_event(type, NULL, len, NULL);
1262 callback->on_set_prediction_hint(NULL);
1263 callback->on_set_mime_type(NULL);
1265 tc_command = EINA_TRUE;
1269 if (m_initialized && command && !tc_command) {
1270 m_helper_agent.send_private_command(command);
1274 void CSCLConnectionISF::get_selection_text(sclchar **text)
1276 if (m_initialized) {
1277 scim::String selection_text;
1278 m_helper_agent.get_selection_text(selection_text);
1281 *text = strdup(selection_text.c_str());
1285 void CSCLConnectionISF::request_ise_hide()
1287 if (m_initialized) {
1288 m_helper_agent.request_ise_hide();
1292 void CSCLConnectionISF::commit_content(const sclchar *content, const sclchar *description, const sclchar *mime_types)
1294 if (m_initialized) {
1295 m_helper_agent.commit_content(content, description, mime_types);
1301 EXAPI void scim_module_init(void) {
1304 EXAPI void scim_module_exit(void) {
1307 EXAPI void scim_helper_module_run_helper(const scim::String &uuid, const scim::ConfigPointer &config, const scim::String &display) {
1308 _scim_config = config;
1309 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
1311 impl->on_run(uuid.c_str(), display.c_str());