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());
42 agent->update_ise_exit();
48 static void slot_attach_input_context(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) {
49 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
51 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
53 callback->on_attach_input_context(ic, ic_uuid.c_str());
58 static void slot_detach_input_context(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) {
59 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
61 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
63 callback->on_detach_input_context(ic, ic_uuid.c_str());
68 static void slot_reload_config(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) {
69 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
71 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
73 callback->on_reload_config(ic, ic_uuid.c_str());
78 static void slot_update_screen(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid, int screen_number) {
79 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
81 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
83 //callback->on_update_screen(ic, ic_uuid.c_str(), screen_number);
88 static void slot_update_spot_location(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid, int x, int y) {
89 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
91 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
93 callback->on_update_spot_location(ic, ic_uuid.c_str(), x, y);
98 static void slot_update_cursor_position(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid, int cursor_pos) {
99 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
101 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
103 callback->on_update_cursor_position(ic, ic_uuid.c_str(), cursor_pos);
108 static void slot_update_surrounding_text(const scim::HelperAgent *agent, int ic, const scim::String &text, int cursor) {
109 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
111 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
113 callback->on_update_surrounding_text(ic, text.c_str(), cursor);
118 static void slot_trigger_property(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid, const scim::String &property) {
119 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
121 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
123 //callback->on_trigger_property(ic, ic_uuid.c_str(), property.c_str());
128 static void slot_focus_out(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) {
129 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
131 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
133 callback->on_focus_out(ic, ic_uuid.c_str());
138 static void slot_focus_in(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) {
139 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
141 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
143 callback->on_focus_in(ic, ic_uuid.c_str());
148 static void slot_ise_show(const scim::HelperAgent *agent, int ic, char *buf, size_t &len) {
149 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
151 /* Make sure the appropriate keyboard ise was selected -> is this really necessary? */
152 //impl->set_keyboard_ise_by_uuid(impl->get_keyboard_ise_uuid().c_str());
154 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
156 /* Check if effect is enabled */
157 Ise_Context ise_context;
158 memset(&ise_context, 0x00, sizeof(ise_context));
160 if (len >= sizeof(Ise_Context)) {
161 memcpy(&ise_context, buf, sizeof(ise_context));
163 if (ise_context.imdata_size > 0) {
164 callback->on_set_imdata(buf + sizeof(ise_context), ise_context.imdata_size);
167 LOGD("\n-=-= WARNING - buf %p len %d size %d \n", buf, len, sizeof(ise_context));
169 CSCLCoreUI* ui = impl->get_core_ui();
171 ui->process_keyboard_ui_state_change(KEYBOARD_UI_STATE_WILL_SHOW);
173 callback->on_ise_show(ic, impl->get_screen_rotation_degree(), ise_context);
175 ui->process_keyboard_ui_state_change(KEYBOARD_UI_STATE_DID_SHOW);
179 g_websocket.on_show(ic);
185 static void slot_ise_hide(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) {
186 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
188 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
190 CSCLCoreUI* ui = impl->get_core_ui();
192 ui->process_keyboard_ui_state_change(KEYBOARD_UI_STATE_WILL_HIDE);
194 callback->on_ise_hide(ic, ic_uuid.c_str());
196 ui->process_keyboard_ui_state_change(KEYBOARD_UI_STATE_DID_HIDE);
200 g_websocket.on_hide(ic);
206 static void slot_get_geometry(const scim::HelperAgent *agent, struct scim::rectinfo &info) {
207 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
209 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
211 callback->on_get_geometry(&(info.pos_x), &(info.pos_y), &(info.width), &(info.height));
216 static void slot_set_mode(const scim::HelperAgent *agent, scim::uint32 &mode) {
217 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
219 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
221 callback->on_set_mode(mode);
226 static void slot_set_language(const scim::HelperAgent *agent, scim::uint32 &language) {
227 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
229 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
231 callback->on_set_language(language);
236 static void slot_set_imdata(const scim::HelperAgent *agent, char *buf, size_t &len) {
237 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
239 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
241 scl32 _len = static_cast<scl32>(reinterpret_cast<size_t>(len) & 0xffffffff);
242 callback->on_set_imdata(buf, _len);
247 static void slot_get_imdata(const scim::HelperAgent *, char **buf, size_t &len) {
248 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
250 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
253 callback->on_get_imdata(buf, &_len);
259 static void slot_get_language_locale(const scim::HelperAgent *, int ic, char **locale) {
260 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
262 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
264 callback->on_get_language_locale(ic, locale);
269 static void slot_set_return_key_type(const scim::HelperAgent *agent, scim::uint32 &type) {
270 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
272 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
274 callback->on_set_return_key_type(type);
279 static void slot_get_return_key_type(const scim::HelperAgent *agent, scim::uint32 &type) {
280 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
282 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
284 callback->on_get_return_key_type(&type);
289 static void slot_set_return_key_disable(const scim::HelperAgent *agent, scim::uint32 &disabled) {
290 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
292 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
294 callback->on_set_return_key_disable(disabled);
299 static void slot_get_return_key_disable(const scim::HelperAgent *agent, scim::uint32 &disabled) {
300 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
302 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
304 callback->on_get_return_key_disable(&disabled);
309 static void slot_set_layout(const scim::HelperAgent *agent, scim::uint32 &layout) {
310 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
312 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
314 callback->on_set_layout(layout);
319 static void slot_get_layout(const scim::HelperAgent *agent, scim::uint32 &layout) {
320 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
322 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
324 callback->on_get_layout(&layout);
329 static void slot_set_caps_mode(const scim::HelperAgent *agent, scim::uint32 &mode) {
330 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
332 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
334 callback->on_set_caps_mode(mode);
339 static void slot_reset_input_context(const scim::HelperAgent *agent, int ic, const scim::String &uuid) {
340 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
342 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
344 callback->on_reset_input_context(ic, uuid.c_str());
349 static void slot_update_candidate_geometry(const scim::HelperAgent *agent, int ic, const scim::String &uuid, const scim::rectinfo &info) {
350 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
352 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
354 callback->on_update_candidate_geometry(ic, uuid.c_str(), info.pos_x, info.pos_y, info.width, info.height);
358 static void slot_update_keyboard_ise(const scim::HelperAgent *agent, int ic, const scim::String &uuid,
359 const scim::String &ise_name, const scim::String &ise_uuid) {
360 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
362 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
364 callback->on_update_keyboard_ise(ic, uuid.c_str(), ise_name.c_str(), ise_uuid.c_str());
369 static void slot_candidate_more_window_show(const scim::HelperAgent *agent, int ic, const scim::String &uuid) {
370 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
372 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
374 callback->on_candidate_more_window_show(ic, uuid.c_str());
379 static void slot_candidate_more_window_hide(const scim::HelperAgent *agent, int ic, const scim::String &uuid) {
380 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
382 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
384 callback->on_candidate_more_window_hide(ic, uuid.c_str());
389 static void slot_select_aux(const scim::HelperAgent *agent, int ic, const scim::String &uuid, int index) {
390 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
392 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
394 callback->on_select_aux(ic, uuid.c_str(), index);
399 static void slot_select_candidate(const scim::HelperAgent *agent, int ic, const scim::String &uuid, int index) {
400 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
402 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
404 callback->on_select_candidate(ic, uuid.c_str(), index);
409 static void slot_candidate_table_page_up(const scim::HelperAgent *agent, int ic, const scim::String &uuid) {
410 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
412 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
414 callback->on_candidate_table_page_up(ic, uuid.c_str());
419 static void slot_candidate_table_page_down(const scim::HelperAgent *agent, int ic, const scim::String &uuid) {
420 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
422 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
424 callback->on_candidate_table_page_down(ic, uuid.c_str());
429 static void slot_update_candidate_table_page_size(const scim::HelperAgent *, int ic, const scim::String &uuid, int page_size) {
430 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
432 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
434 callback->on_update_candidate_table_page_size(ic, uuid.c_str(), page_size);
439 static void slot_update_lookup_table(const scim::HelperAgent *, scim::LookupTable &table) {
440 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
442 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
444 SclCandidateTable lookup_table;
445 lookup_table.page_size = table.get_page_size();
446 lookup_table.current_page_start = table.get_current_page_start();
447 lookup_table.cursor_pos = table.get_cursor_pos();
448 lookup_table.cursor_visible = table.is_cursor_visible();
449 lookup_table.page_size_fixed = table.is_page_size_fixed();
450 lookup_table.candidate_labels.clear();
451 for (int page_index = 0;page_index < lookup_table.page_size;page_index++) {
452 scim::WideString label = table.get_candidate_label(page_index);
453 lookup_table.candidate_labels.push_back(scim::utf8_wcstombs(label).c_str());
456 int nCandidateSize = table.get_current_page_size();
457 for (int index = 0; index < nCandidateSize; ++index) {
458 scim::WideString candidate_str = table.get_candidate_in_current_page(index);
459 lookup_table.candidate.push_back(scim::utf8_wcstombs(candidate_str).c_str());
462 callback->on_update_lookup_table(lookup_table);
464 std::vector<scim::WideString> labels;
465 for (unsigned int loop = 0;loop < lookup_table.candidate_labels.size();loop++) {
466 labels.push_back(scim::utf8_mbstowcs(lookup_table.candidate_labels.at(loop).c_str()));
468 table.set_candidate_labels(labels);
473 static void slot_select_associate(const scim::HelperAgent *agent, int ic, const scim::String &uuid, int index) {
474 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
476 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
478 callback->on_select_associate(ic, uuid.c_str(), index);
483 static void slot_associate_table_page_up(const scim::HelperAgent *agent, int ic, const scim::String &uuid) {
484 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
486 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
488 callback->on_associate_table_page_up(ic, uuid.c_str());
493 static void slot_associate_table_page_down(const scim::HelperAgent *agent, int ic, const scim::String &uuid) {
494 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
496 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
498 callback->on_associate_table_page_down(ic, uuid.c_str());
503 static void slot_update_associate_table_page_size(const scim::HelperAgent *, int ic, const scim::String &uuid, int page_size) {
504 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
506 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
508 callback->on_update_associate_table_page_size(ic, uuid.c_str(), page_size);
513 static void slot_show_ise_option_window(const scim::HelperAgent *agent, int ic, const scim::String &uuid) {
514 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
516 CSCLCoreUI *core_ui = impl->get_core_ui();
518 LOGD("slot_show_ise_option_window() called!!!\n");
519 core_ui->create_option_window(OPTION_WINDOW_TYPE_SETTING_APPLICATION);
524 static void slot_check_ise_option_window(const scim::HelperAgent *agent, sclu32 &avail) {
525 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
527 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
529 callback->on_check_option_window_availability(reinterpret_cast<sclboolean *>(&avail));
534 static void slot_process_key_event(const scim::HelperAgent *agent, scim::KeyEvent &key, scim::uint32 &ret) {
535 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
537 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
539 callback->on_process_key_event(key, &ret);
544 static void slot_candidate_show(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) {
545 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
547 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
549 callback->on_candidate_show(ic, ic_uuid.c_str());
554 static void slot_candidate_hide(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) {
555 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
557 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
559 callback->on_candidate_hide(ic, ic_uuid.c_str());
564 static void slot_process_input_device_event(const scim::HelperAgent *agent, scim::uint32 &type, char *data, size_t &len, scim::uint32 &ret) {
565 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
567 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
569 /* Input Device Event callback is available in versions after 1.1 */
570 if (check_interface_version(callback, 1, 1)) {
571 callback->on_process_input_device_event(type, data, len, &ret);
577 /* Internal input handler function */
578 Eina_Bool input_handler(void *data, Ecore_Fd_Handler *fd_handler)
580 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
582 scim::HelperAgent *agent = static_cast<scim::HelperAgent*>(data);
584 if (agent->has_pending_event()) {
585 if (!(agent->filter_event())) {
586 LOGD("helper_agent.filter_event() failed!!!\n");
591 LOGD("helper_agent.has_pending_event() failed!!!\n");
598 return ECORE_CALLBACK_RENEW;
601 CSCLConnectionISF::CSCLConnectionISF()
603 m_initialized = FALSE;
606 m_backend_identifier = "ISF";
609 CSCLConnectionISF::~CSCLConnectionISF()
613 sclboolean CSCLConnectionISF::init()
617 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
619 sclchar *uuid = impl->get_uuid();
621 m_helper_info.uuid = uuid;
625 if (!m_initialized) {
626 m_helper_agent.signal_connect_exit(scim::slot(slot_exit));
627 m_helper_agent.signal_connect_attach_input_context(scim::slot(slot_attach_input_context));
628 m_helper_agent.signal_connect_detach_input_context(scim::slot(slot_detach_input_context));
629 m_helper_agent.signal_connect_reload_config(scim::slot(slot_reload_config));
630 m_helper_agent.signal_connect_update_screen(scim::slot(slot_update_screen));
631 m_helper_agent.signal_connect_update_spot_location(scim::slot(slot_update_spot_location));
632 m_helper_agent.signal_connect_update_cursor_position(scim::slot(slot_update_cursor_position));
633 m_helper_agent.signal_connect_update_surrounding_text(scim::slot(slot_update_surrounding_text));
634 m_helper_agent.signal_connect_trigger_property(scim::slot(slot_trigger_property));
635 //m_helper_agent.signal_connect_process_imengine_event (slot (slot_process_imengine_event));
636 m_helper_agent.signal_connect_focus_out(scim::slot(slot_focus_out));
637 m_helper_agent.signal_connect_focus_in(scim::slot(slot_focus_in));
638 m_helper_agent.signal_connect_ise_show(scim::slot(slot_ise_show));
639 m_helper_agent.signal_connect_ise_hide(scim::slot(slot_ise_hide));
640 m_helper_agent.signal_connect_get_geometry(scim::slot(slot_get_geometry));
641 m_helper_agent.signal_connect_set_mode(scim::slot(slot_set_mode));
642 m_helper_agent.signal_connect_set_language(scim::slot(slot_set_language));
643 m_helper_agent.signal_connect_set_imdata(scim::slot(slot_set_imdata));
644 m_helper_agent.signal_connect_get_imdata(scim::slot(slot_get_imdata));
645 m_helper_agent.signal_connect_get_language_locale(scim::slot(slot_get_language_locale));
646 m_helper_agent.signal_connect_set_return_key_type(scim::slot(slot_set_return_key_type));
647 m_helper_agent.signal_connect_get_return_key_type(scim::slot(slot_get_return_key_type));
648 m_helper_agent.signal_connect_set_return_key_disable(scim::slot(slot_set_return_key_disable));
649 m_helper_agent.signal_connect_get_return_key_disable(scim::slot(slot_get_return_key_disable));
650 m_helper_agent.signal_connect_get_layout(scim::slot(slot_get_layout));
651 m_helper_agent.signal_connect_set_layout(scim::slot(slot_set_layout));
652 m_helper_agent.signal_connect_set_caps_mode(scim::slot(slot_set_caps_mode));
653 m_helper_agent.signal_connect_reset_input_context(scim::slot(slot_reset_input_context));
654 m_helper_agent.signal_connect_update_candidate_geometry(scim::slot(slot_update_candidate_geometry));
655 m_helper_agent.signal_connect_update_keyboard_ise(scim::slot(slot_update_keyboard_ise));
656 //m_helper_agent.signal_connect_update_keyboard_ise_list (slot (slot_update_keyboard_ise_list));
657 m_helper_agent.signal_connect_candidate_more_window_show(scim::slot(slot_candidate_more_window_show));
658 m_helper_agent.signal_connect_candidate_more_window_hide(scim::slot(slot_candidate_more_window_hide));
659 m_helper_agent.signal_connect_select_aux(scim::slot(slot_select_aux));
660 m_helper_agent.signal_connect_select_candidate(scim::slot(slot_select_candidate));
661 m_helper_agent.signal_connect_candidate_table_page_up(scim::slot(slot_candidate_table_page_up));
662 m_helper_agent.signal_connect_candidate_table_page_down(scim::slot(slot_candidate_table_page_down));
663 m_helper_agent.signal_connect_update_candidate_table_page_size(scim::slot(slot_update_candidate_table_page_size));
664 m_helper_agent.signal_connect_update_lookup_table(scim::slot(slot_update_lookup_table));
665 m_helper_agent.signal_connect_select_associate(scim::slot(slot_select_associate));
666 m_helper_agent.signal_connect_associate_table_page_up(scim::slot(slot_associate_table_page_up));
667 m_helper_agent.signal_connect_associate_table_page_down(scim::slot(slot_associate_table_page_down));
668 m_helper_agent.signal_connect_update_associate_table_page_size(scim::slot(slot_update_associate_table_page_size));
669 m_helper_agent.signal_connect_show_option_window(scim::slot(slot_show_ise_option_window));
670 m_helper_agent.signal_connect_check_option_window(scim::slot(slot_check_ise_option_window));
671 m_helper_agent.signal_connect_process_key_event(scim::slot(slot_process_key_event));
672 m_helper_agent.signal_connect_candidate_show(scim::slot(slot_candidate_show));
673 m_helper_agent.signal_connect_candidate_hide(scim::slot(slot_candidate_hide));
674 m_helper_agent.signal_connect_process_input_device_event(scim::slot(slot_process_input_device_event));
676 m_initialized = TRUE;
679 if (_scim_config.null()) {
680 scim::ConfigPointer config_pointer = scim::ConfigBase::get(true, "socket");
681 if (config_pointer.null()) {
682 config_pointer = new scim::DummyConfig();
684 _scim_config = config_pointer;
690 void CSCLConnectionISF::fini()
692 if (!_scim_config.null()) {
693 _scim_config.reset();
695 scim::ConfigBase::set(0);
697 m_initialized = FALSE;
700 void CSCLConnectionISF::open_connection(const sclchar *display)
703 m_helper_agent.open_connection(m_helper_info, display);
704 int fd = m_helper_agent.get_connection_number();
708 Evas_Object *main_window = NULL;
709 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
711 main_window = NATIVE_WINDOW_CAST(impl->get_main_window());
714 Ecore_X_Window xwindow = elm_win_xwindow_get(main_window);
716 snprintf(xid, 255, "%d", xwindow);
717 scim::Property prop(xid, "XID", "", "");
718 scim::PropertyList props;
719 props.push_back(prop);
720 m_helper_agent.register_properties(props);
723 m_fd_handler = ecore_main_fd_handler_add(fd, ECORE_FD_READ, input_handler, &m_helper_agent, NULL, NULL);
727 void CSCLConnectionISF::close_connection()
731 ecore_main_fd_handler_del(m_fd_handler);
734 m_helper_agent.update_ise_exit();
735 m_helper_agent.close_connection();
739 void CSCLConnectionISF::config_reload()
742 m_helper_agent.reload_config();
746 sclboolean CSCLConnectionISF::config_read_int(const sclchar *name, sclint &value)
748 sclboolean ret = FALSE;
749 if (m_initialized && _scim_config) {
750 value = _scim_config->read(name, value);
756 sclboolean CSCLConnectionISF::config_read_string(const sclchar *name, std::string &value)
758 sclboolean ret = FALSE;
759 if (m_initialized && _scim_config) {
760 value = _scim_config->read(name, value);
766 sclboolean CSCLConnectionISF::config_write_int(const sclchar *name, sclint value)
768 sclboolean ret = FALSE;
769 if (m_initialized && _scim_config) {
770 _scim_config->write(name, value);
776 sclboolean CSCLConnectionISF::config_write_string(const sclchar *name, const std::string value)
778 sclboolean ret = FALSE;
779 if (m_initialized && _scim_config) {
780 _scim_config->write(name, value);
786 sclboolean CSCLConnectionISF::config_erase(const sclchar *name)
788 sclboolean ret = FALSE;
789 if (m_initialized && _scim_config) {
790 _scim_config->erase(name);
796 sclboolean CSCLConnectionISF::config_flush(void)
798 sclboolean ret = FALSE;
799 if (m_initialized && _scim_config) {
800 _scim_config->flush();
806 void CSCLConnectionISF::send_imengine_event(sclint ic, const sclchar *ic_uuid, const sclint command, const sclu32 value)
811 uuid = scim::String(ic_uuid);
813 scim::Transaction trans;
814 trans.put_command(command);
815 trans.put_data(value);
816 m_helper_agent.send_imengine_event(ic, uuid, trans);
820 void CSCLConnectionISF::reset_keyboard_ise()
823 m_helper_agent.reset_keyboard_ise();
827 void CSCLConnectionISF::flush_keyboard_ise()
830 m_helper_agent.flush_keyboard_ise();
834 void CSCLConnectionISF::send_key_event(sclint ic, const sclchar *ic_uuid, sclu32 keycode, sclu16 keymask)
839 uuid = scim::String(ic_uuid);
841 scim::KeyEvent event;
842 event.code = keycode;
843 event.mask = keymask;
844 m_helper_agent.send_key_event(ic, uuid, event);
848 void CSCLConnectionISF::forward_key_event(sclint ic, const sclchar *ic_uuid, sclu32 keycode, sclu16 keymask)
853 uuid = scim::String(ic_uuid);
855 scim::KeyEvent event;
856 event.code = keycode;
857 event.mask = keymask;
858 m_helper_agent.forward_key_event(ic, uuid, event);
862 void CSCLConnectionISF::commit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str)
867 uuid = scim::String(ic_uuid);
869 m_helper_agent.commit_string(ic, uuid, scim::utf8_mbstowcs(str));
873 void CSCLConnectionISF::select_candidate(int index)
876 m_helper_agent.select_candidate(index);
880 void CSCLConnectionISF::show_preedit_string(sclint ic, const sclchar *ic_uuid)
885 uuid = scim::String(ic_uuid);
887 m_helper_agent.show_preedit_string(ic, uuid);
891 void CSCLConnectionISF::show_aux_string(void)
894 m_helper_agent.show_aux_string();
898 void CSCLConnectionISF::show_candidate_string(void)
901 m_helper_agent.show_candidate_string();
905 void CSCLConnectionISF::show_associate_string(void)
908 m_helper_agent.show_associate_string();
912 void CSCLConnectionISF::hide_preedit_string(sclint ic, const sclchar *ic_uuid)
917 uuid = scim::String(ic_uuid);
919 m_helper_agent.hide_preedit_string(ic, uuid);
923 void CSCLConnectionISF::hide_aux_string(void)
926 m_helper_agent.hide_aux_string();
930 void CSCLConnectionISF::hide_candidate_string(void)
933 m_helper_agent.hide_candidate_string();
937 void CSCLConnectionISF::hide_associate_string(void)
940 m_helper_agent.hide_associate_string();
944 void CSCLConnectionISF::update_preedit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str)
947 scim::AttributeList list;
950 uuid = scim::String(ic_uuid);
952 m_helper_agent.update_preedit_string(ic, uuid, scim::utf8_mbstowcs(str), list);
954 if (str && strlen(str) > 0) {
955 show_preedit_string(ic, ic_uuid);
957 hide_preedit_string(ic, ic_uuid);
962 void CSCLConnectionISF::update_preedit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str, const scim::AttributeList &attrs)
967 uuid = scim::String(ic_uuid);
969 m_helper_agent.update_preedit_string(ic, uuid, scim::utf8_mbstowcs(str), attrs);
971 if (str && strlen(str) > 0) {
972 show_preedit_string(ic, ic_uuid);
974 hide_preedit_string(ic, ic_uuid);
979 void CSCLConnectionISF::update_aux_string(const sclchar *str)
982 scim::AttributeList list;
983 m_helper_agent.update_aux_string(scim::String(str), list);
987 void CSCLConnectionISF::update_input_context(sclu32 type, sclu32 value)
990 m_helper_agent.update_input_context(type, value);
994 void CSCLConnectionISF::update_geometry(sclint x, sclint y, sclint width, sclint height)
997 m_helper_agent.update_geometry(x, y, width, height);
1001 void CSCLConnectionISF::get_surrounding_text(const sclchar *ic_uuid, sclint maxlen_before, sclint maxlen_after) const
1003 if (m_initialized) {
1006 uuid = scim::String(ic_uuid);
1008 m_helper_agent.get_surrounding_text(uuid, maxlen_before, maxlen_after);
1012 sclint CSCLConnectionISF::get_surrounding_text(sclint maxlen_before, sclint maxlen_after, sclchar **text, int &cursor)
1014 if (m_initialized) {
1015 scim::String surrounding_text;
1016 m_helper_agent.get_surrounding_text(maxlen_before, maxlen_after, surrounding_text, cursor);
1019 *text = strdup(surrounding_text.c_str());
1020 if (*text == NULL) {
1028 void CSCLConnectionISF::delete_surrounding_text(sclint offset, sclint len) const
1030 if (m_initialized) {
1031 m_helper_agent.delete_surrounding_text(offset, len);
1035 void CSCLConnectionISF::set_candidate_position(sclint left, sclint top)
1037 if (m_initialized) {
1038 m_helper_agent.set_candidate_position(left, top);
1042 void CSCLConnectionISF::enable_soft_candidate(sclboolean enable)
1044 if (m_initialized) {
1046 m_helper_agent.set_candidate_style(scim::ONE_LINE_CANDIDATE, scim::SOFT_CANDIDATE_WINDOW);
1048 m_helper_agent.set_candidate_style(scim::ONE_LINE_CANDIDATE, scim::FIXED_CANDIDATE_WINDOW);
1052 void CSCLConnectionISF::candidate_hide(void)
1054 if (m_initialized) {
1055 m_helper_agent.candidate_hide();
1059 void CSCLConnectionISF::set_keyboard_ise_by_uuid(const sclchar *uuid)
1061 if (m_initialized) {
1062 m_helper_agent.set_keyboard_ise_by_uuid(uuid);
1066 void CSCLConnectionISF::get_keyboard_ise(const sclchar *uuid)
1068 if (m_initialized) {
1069 m_helper_agent.get_keyboard_ise(uuid);
1073 void CSCLConnectionISF::set_selection(sclint start, sclint end)
1075 if (m_initialized) {
1076 m_helper_agent.set_selection(start, end);
1080 void CSCLConnectionISF::send_private_command(const sclchar *command)
1082 if (m_initialized) {
1083 m_helper_agent.send_private_command(command);
1087 void CSCLConnectionISF::get_selection_text(sclchar **text)
1089 if (m_initialized) {
1090 scim::String selection_text;
1091 m_helper_agent.get_selection_text(selection_text);
1094 *text = strdup(selection_text.c_str());
1098 void CSCLConnectionISF::request_ise_hide()
1100 if (m_initialized) {
1101 m_helper_agent.request_ise_hide();
1107 void scim_module_init(void) {
1110 void scim_module_exit(void) {
1113 void scim_helper_module_run_helper(const scim::String &uuid, const scim::ConfigPointer &config, const scim::String &display) {
1114 _scim_config = config;
1115 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
1117 impl->on_run(uuid.c_str(), display.c_str());