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>
25 static scim::ConfigPointer _scim_config(0);
27 /* Slot functions for calling appropriate callback functions */
28 static void slot_exit(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) {
29 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
31 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
33 callback->on_ise_hide(ic, ic_uuid.c_str());
37 agent->update_ise_exit();
43 static void slot_attach_input_context(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) {
44 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
46 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
48 callback->on_attach_input_context(ic, ic_uuid.c_str());
53 static void slot_detach_input_context(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) {
54 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
56 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
58 callback->on_detach_input_context(ic, ic_uuid.c_str());
63 static void slot_reload_config(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) {
64 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
66 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
68 callback->on_reload_config(ic, ic_uuid.c_str());
73 static void slot_update_screen(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid, int screen_number) {
74 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
76 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
78 //callback->on_update_screen(ic, ic_uuid.c_str(), screen_number);
83 static void slot_update_spot_location(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid, int x, int y) {
84 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
86 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
88 callback->on_update_spot_location(ic, ic_uuid.c_str(), x, y);
93 static void slot_update_cursor_position(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid, int cursor_pos) {
94 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
96 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
98 callback->on_update_cursor_position(ic, ic_uuid.c_str(), cursor_pos);
103 static void slot_update_surrounding_text(const scim::HelperAgent *agent, int ic, const scim::String &text, int cursor) {
104 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
106 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
108 callback->on_update_surrounding_text(ic, text.c_str(), cursor);
113 static void slot_trigger_property(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid, const scim::String &property) {
114 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
116 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
118 //callback->on_trigger_property(ic, ic_uuid.c_str(), property.c_str());
123 static void slot_focus_out(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) {
124 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
126 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
128 callback->on_focus_out(ic, ic_uuid.c_str());
133 static void slot_focus_in(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) {
134 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
136 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
138 callback->on_focus_in(ic, ic_uuid.c_str());
143 static void slot_ise_show(const scim::HelperAgent *agent, int ic, char *buf, size_t &len) {
144 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
146 /* Make sure the appropriate keyboard ise was selected -> is this really necessary? */
147 //impl->set_keyboard_ise_by_uuid(impl->get_keyboard_ise_uuid().c_str());
149 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
151 /* Check if effect is enabled */
152 Ise_Context ise_context;
153 memset(&ise_context, 0x00, sizeof(ise_context));
155 if (len >= sizeof(Ise_Context)) {
156 memcpy(&ise_context, buf, sizeof(ise_context));
158 if (ise_context.imdata_size > 0) {
159 callback->on_set_imdata(buf + sizeof(ise_context), ise_context.imdata_size);
162 LOGD("\n-=-= WARNING - buf %p len %d size %d \n", buf, len, sizeof(ise_context));
164 CSCLCoreUI* ui = impl->get_core_ui();
166 ui->process_keyboard_ui_state_change(KEYBOARD_UI_STATE_WILL_SHOW);
168 callback->on_ise_show(ic, impl->get_screen_rotation_degree(), ise_context);
170 ui->process_keyboard_ui_state_change(KEYBOARD_UI_STATE_DID_SHOW);
176 static void slot_ise_hide(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) {
177 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
179 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
181 CSCLCoreUI* ui = impl->get_core_ui();
183 ui->process_keyboard_ui_state_change(KEYBOARD_UI_STATE_WILL_HIDE);
185 callback->on_ise_hide(ic, ic_uuid.c_str());
187 ui->process_keyboard_ui_state_change(KEYBOARD_UI_STATE_DID_HIDE);
193 static void slot_get_geometry(const scim::HelperAgent *agent, struct scim::rectinfo &info) {
194 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
196 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
198 callback->on_get_geometry(&(info.pos_x), &(info.pos_y), &(info.width), &(info.height));
203 static void slot_set_mode(const scim::HelperAgent *agent, scim::uint32 &mode) {
204 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
206 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
208 callback->on_set_mode(mode);
213 static void slot_set_language(const scim::HelperAgent *agent, scim::uint32 &language) {
214 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
216 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
218 callback->on_set_language(language);
223 static void slot_set_imdata(const scim::HelperAgent *agent, char *buf, size_t &len) {
224 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
226 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
228 scl32 _len = static_cast<scl32>(reinterpret_cast<size_t>(len) & 0xffffffff);
229 callback->on_set_imdata(buf, _len);
234 static void slot_get_imdata(const scim::HelperAgent *, char **buf, size_t &len) {
235 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
237 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
240 callback->on_get_imdata(buf, &_len);
246 static void slot_get_language_locale(const scim::HelperAgent *, int ic, char **locale) {
247 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
249 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
251 callback->on_get_language_locale(ic, locale);
256 static void slot_set_return_key_type(const scim::HelperAgent *agent, scim::uint32 &type) {
257 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
259 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
261 callback->on_set_return_key_type(type);
266 static void slot_get_return_key_type(const scim::HelperAgent *agent, scim::uint32 &type) {
267 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
269 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
271 callback->on_get_return_key_type(&type);
276 static void slot_set_return_key_disable(const scim::HelperAgent *agent, scim::uint32 &disabled) {
277 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
279 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
281 callback->on_set_return_key_disable(disabled);
286 static void slot_get_return_key_disable(const scim::HelperAgent *agent, scim::uint32 &disabled) {
287 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
289 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
291 callback->on_get_return_key_disable(&disabled);
296 static void slot_set_layout(const scim::HelperAgent *agent, scim::uint32 &layout) {
297 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
299 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
301 callback->on_set_layout(layout);
306 static void slot_get_layout(const scim::HelperAgent *agent, scim::uint32 &layout) {
307 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
309 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
311 callback->on_get_layout(&layout);
316 static void slot_set_caps_mode(const scim::HelperAgent *agent, scim::uint32 &mode) {
317 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
319 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
321 callback->on_set_caps_mode(mode);
326 static void slot_reset_input_context(const scim::HelperAgent *agent, int ic, const scim::String &uuid) {
327 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
329 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
331 callback->on_reset_input_context(ic, uuid.c_str());
336 static void slot_update_candidate_geometry(const scim::HelperAgent *agent, int ic, const scim::String &uuid, const scim::rectinfo &info) {
337 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
339 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
341 callback->on_update_candidate_geometry(ic, uuid.c_str(), info.pos_x, info.pos_y, info.width, info.height);
345 static void slot_update_keyboard_ise(const scim::HelperAgent *agent, int ic, const scim::String &uuid,
346 const scim::String &ise_name, const scim::String &ise_uuid) {
347 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
349 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
351 callback->on_update_keyboard_ise(ic, uuid.c_str(), ise_name.c_str(), ise_uuid.c_str());
356 static void slot_candidate_more_window_show(const scim::HelperAgent *agent, int ic, const scim::String &uuid) {
357 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
359 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
361 callback->on_candidate_more_window_show(ic, uuid.c_str());
366 static void slot_candidate_more_window_hide(const scim::HelperAgent *agent, int ic, const scim::String &uuid) {
367 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
369 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
371 callback->on_candidate_more_window_hide(ic, uuid.c_str());
376 static void slot_select_aux(const scim::HelperAgent *agent, int ic, const scim::String &uuid, int index) {
377 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
379 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
381 callback->on_select_aux(ic, uuid.c_str(), index);
386 static void slot_select_candidate(const scim::HelperAgent *agent, int ic, const scim::String &uuid, int index) {
387 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
389 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
391 callback->on_select_candidate(ic, uuid.c_str(), index);
396 static void slot_candidate_table_page_up(const scim::HelperAgent *agent, int ic, const scim::String &uuid) {
397 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
399 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
401 callback->on_candidate_table_page_up(ic, uuid.c_str());
406 static void slot_candidate_table_page_down(const scim::HelperAgent *agent, int ic, const scim::String &uuid) {
407 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
409 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
411 callback->on_candidate_table_page_down(ic, uuid.c_str());
416 static void slot_update_candidate_table_page_size(const scim::HelperAgent *, int ic, const scim::String &uuid, int page_size) {
417 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
419 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
421 callback->on_update_candidate_table_page_size(ic, uuid.c_str(), page_size);
426 static void slot_update_lookup_table(const scim::HelperAgent *, scim::LookupTable &table) {
427 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
429 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
431 SclCandidateTable lookup_table;
432 lookup_table.page_size = table.get_page_size();
433 lookup_table.current_page_start = table.get_current_page_start();
434 lookup_table.cursor_pos = table.get_cursor_pos();
435 lookup_table.cursor_visible = table.is_cursor_visible();
436 lookup_table.page_size_fixed = table.is_page_size_fixed();
437 lookup_table.candidate_labels.clear();
438 for (int page_index = 0;page_index < lookup_table.page_size;page_index++) {
439 scim::WideString label = table.get_candidate_label(page_index);
440 lookup_table.candidate_labels.push_back(scim::utf8_wcstombs(label).c_str());
443 int nCandidateSize = table.get_current_page_size();
444 for (int index = 0; index < nCandidateSize; ++index) {
445 scim::WideString candidate_str = table.get_candidate_in_current_page(index);
446 lookup_table.candidate.push_back(scim::utf8_wcstombs(candidate_str).c_str());
449 callback->on_update_lookup_table(lookup_table);
451 std::vector<scim::WideString> labels;
452 for (unsigned int loop = 0;loop < lookup_table.candidate_labels.size();loop++) {
453 labels.push_back(scim::utf8_mbstowcs(lookup_table.candidate_labels.at(loop).c_str()));
455 table.set_candidate_labels(labels);
460 static void slot_select_associate(const scim::HelperAgent *agent, int ic, const scim::String &uuid, int index) {
461 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
463 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
465 callback->on_select_associate(ic, uuid.c_str(), index);
470 static void slot_associate_table_page_up(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_associate_table_page_up(ic, uuid.c_str());
480 static void slot_associate_table_page_down(const scim::HelperAgent *agent, int ic, const scim::String &uuid) {
481 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
483 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
485 callback->on_associate_table_page_down(ic, uuid.c_str());
490 static void slot_update_associate_table_page_size(const scim::HelperAgent *, int ic, const scim::String &uuid, int page_size) {
491 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
493 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
495 callback->on_update_associate_table_page_size(ic, uuid.c_str(), page_size);
500 static void slot_show_ise_option_window(const scim::HelperAgent *agent, int ic, const scim::String &uuid) {
501 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
503 CSCLCoreUI *core_ui = impl->get_core_ui();
505 LOGD("slot_show_ise_option_window() called!!!\n");
506 core_ui->create_option_window(OPTION_WINDOW_TYPE_SETTING_APPLICATION);
511 static void slot_check_ise_option_window(const scim::HelperAgent *agent, sclu32 &avail) {
512 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
514 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
516 callback->on_check_option_window_availability(reinterpret_cast<sclboolean *>(&avail));
521 static void slot_process_key_event(const scim::HelperAgent *agent, scim::KeyEvent &key, scim::uint32 &ret) {
522 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
524 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
526 callback->on_process_key_event(key, &ret);
531 static void slot_candidate_show(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) {
532 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
534 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
536 callback->on_candidate_show(ic, ic_uuid.c_str());
541 static void slot_candidate_hide(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) {
542 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
544 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
546 callback->on_candidate_hide(ic, ic_uuid.c_str());
551 static void slot_process_input_device_event(const scim::HelperAgent *agent, scim::uint32 &type, char *data, size_t &len, scim::uint32 &ret) {
552 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
554 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
556 /* Input Device Event callback is available in versions after 1.1 */
557 if (check_interface_version(callback, 1, 1)) {
558 callback->on_process_input_device_event(type, data, len, &ret);
564 /* Internal input handler function */
565 Eina_Bool input_handler(void *data, Ecore_Fd_Handler *fd_handler)
567 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
569 scim::HelperAgent *agent = static_cast<scim::HelperAgent*>(data);
571 if (agent->has_pending_event()) {
572 if (!(agent->filter_event())) {
573 LOGD("helper_agent.filter_event() failed!!!\n");
578 LOGD("helper_agent.has_pending_event() failed!!!\n");
585 return ECORE_CALLBACK_RENEW;
588 CSCLConnectionISF::CSCLConnectionISF()
590 m_initialized = FALSE;
593 m_backend_identifier = "ISF";
596 CSCLConnectionISF::~CSCLConnectionISF()
600 sclboolean CSCLConnectionISF::init()
604 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
606 sclchar *uuid = impl->get_uuid();
608 m_helper_info.uuid = uuid;
612 if (!m_initialized) {
613 m_helper_agent.signal_connect_exit(scim::slot(slot_exit));
614 m_helper_agent.signal_connect_attach_input_context(scim::slot(slot_attach_input_context));
615 m_helper_agent.signal_connect_detach_input_context(scim::slot(slot_detach_input_context));
616 m_helper_agent.signal_connect_reload_config(scim::slot(slot_reload_config));
617 m_helper_agent.signal_connect_update_screen(scim::slot(slot_update_screen));
618 m_helper_agent.signal_connect_update_spot_location(scim::slot(slot_update_spot_location));
619 m_helper_agent.signal_connect_update_cursor_position(scim::slot(slot_update_cursor_position));
620 m_helper_agent.signal_connect_update_surrounding_text(scim::slot(slot_update_surrounding_text));
621 m_helper_agent.signal_connect_trigger_property(scim::slot(slot_trigger_property));
622 //m_helper_agent.signal_connect_process_imengine_event (slot (slot_process_imengine_event));
623 m_helper_agent.signal_connect_focus_out(scim::slot(slot_focus_out));
624 m_helper_agent.signal_connect_focus_in(scim::slot(slot_focus_in));
625 m_helper_agent.signal_connect_ise_show(scim::slot(slot_ise_show));
626 m_helper_agent.signal_connect_ise_hide(scim::slot(slot_ise_hide));
627 m_helper_agent.signal_connect_get_geometry(scim::slot(slot_get_geometry));
628 m_helper_agent.signal_connect_set_mode(scim::slot(slot_set_mode));
629 m_helper_agent.signal_connect_set_language(scim::slot(slot_set_language));
630 m_helper_agent.signal_connect_set_imdata(scim::slot(slot_set_imdata));
631 m_helper_agent.signal_connect_get_imdata(scim::slot(slot_get_imdata));
632 m_helper_agent.signal_connect_get_language_locale(scim::slot(slot_get_language_locale));
633 m_helper_agent.signal_connect_set_return_key_type(scim::slot(slot_set_return_key_type));
634 m_helper_agent.signal_connect_get_return_key_type(scim::slot(slot_get_return_key_type));
635 m_helper_agent.signal_connect_set_return_key_disable(scim::slot(slot_set_return_key_disable));
636 m_helper_agent.signal_connect_get_return_key_disable(scim::slot(slot_get_return_key_disable));
637 m_helper_agent.signal_connect_get_layout(scim::slot(slot_get_layout));
638 m_helper_agent.signal_connect_set_layout(scim::slot(slot_set_layout));
639 m_helper_agent.signal_connect_set_caps_mode(scim::slot(slot_set_caps_mode));
640 m_helper_agent.signal_connect_reset_input_context(scim::slot(slot_reset_input_context));
641 m_helper_agent.signal_connect_update_candidate_geometry(scim::slot(slot_update_candidate_geometry));
642 m_helper_agent.signal_connect_update_keyboard_ise(scim::slot(slot_update_keyboard_ise));
643 //m_helper_agent.signal_connect_update_keyboard_ise_list (slot (slot_update_keyboard_ise_list));
644 m_helper_agent.signal_connect_candidate_more_window_show(scim::slot(slot_candidate_more_window_show));
645 m_helper_agent.signal_connect_candidate_more_window_hide(scim::slot(slot_candidate_more_window_hide));
646 m_helper_agent.signal_connect_select_aux(scim::slot(slot_select_aux));
647 m_helper_agent.signal_connect_select_candidate(scim::slot(slot_select_candidate));
648 m_helper_agent.signal_connect_candidate_table_page_up(scim::slot(slot_candidate_table_page_up));
649 m_helper_agent.signal_connect_candidate_table_page_down(scim::slot(slot_candidate_table_page_down));
650 m_helper_agent.signal_connect_update_candidate_table_page_size(scim::slot(slot_update_candidate_table_page_size));
651 m_helper_agent.signal_connect_update_lookup_table(scim::slot(slot_update_lookup_table));
652 m_helper_agent.signal_connect_select_associate(scim::slot(slot_select_associate));
653 m_helper_agent.signal_connect_associate_table_page_up(scim::slot(slot_associate_table_page_up));
654 m_helper_agent.signal_connect_associate_table_page_down(scim::slot(slot_associate_table_page_down));
655 m_helper_agent.signal_connect_update_associate_table_page_size(scim::slot(slot_update_associate_table_page_size));
656 m_helper_agent.signal_connect_show_option_window(scim::slot(slot_show_ise_option_window));
657 m_helper_agent.signal_connect_check_option_window(scim::slot(slot_check_ise_option_window));
658 m_helper_agent.signal_connect_process_key_event(scim::slot(slot_process_key_event));
659 m_helper_agent.signal_connect_candidate_show(scim::slot(slot_candidate_show));
660 m_helper_agent.signal_connect_candidate_hide(scim::slot(slot_candidate_hide));
661 m_helper_agent.signal_connect_process_input_device_event(scim::slot(slot_process_input_device_event));
663 m_initialized = TRUE;
666 if (_scim_config.null()) {
667 scim::ConfigPointer config_pointer = scim::ConfigBase::get(true, "simple");
668 if (config_pointer.null()) {
669 config_pointer = new scim::DummyConfig();
671 _scim_config = config_pointer;
677 void CSCLConnectionISF::fini()
679 if (!_scim_config.null()) {
680 _scim_config.reset();
682 scim::ConfigBase::set(0);
684 m_initialized = FALSE;
687 void CSCLConnectionISF::open_connection(const sclchar *display)
690 m_helper_agent.open_connection(m_helper_info, display);
691 int fd = m_helper_agent.get_connection_number();
695 Evas_Object *main_window = NULL;
696 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
698 main_window = NATIVE_WINDOW_CAST(impl->get_main_window());
701 Ecore_X_Window xwindow = elm_win_xwindow_get(main_window);
703 snprintf(xid, 255, "%d", xwindow);
704 scim::Property prop(xid, "XID", "", "");
705 scim::PropertyList props;
706 props.push_back(prop);
707 m_helper_agent.register_properties(props);
710 m_fd_handler = ecore_main_fd_handler_add(fd, ECORE_FD_READ, input_handler, &m_helper_agent, NULL, NULL);
714 void CSCLConnectionISF::close_connection()
718 ecore_main_fd_handler_del(m_fd_handler);
721 m_helper_agent.update_ise_exit();
722 m_helper_agent.close_connection();
726 void CSCLConnectionISF::config_reload()
729 m_helper_agent.reload_config();
733 sclboolean CSCLConnectionISF::config_read_int(const sclchar *name, sclint &value)
735 sclboolean ret = FALSE;
736 if (m_initialized && _scim_config) {
737 value = _scim_config->read(name, value);
743 sclboolean CSCLConnectionISF::config_read_string(const sclchar *name, std::string &value)
745 sclboolean ret = FALSE;
746 if (m_initialized && _scim_config) {
747 value = _scim_config->read(name, value);
753 sclboolean CSCLConnectionISF::config_write_int(const sclchar *name, sclint value)
755 sclboolean ret = FALSE;
756 if (m_initialized && _scim_config) {
757 _scim_config->write(name, value);
763 sclboolean CSCLConnectionISF::config_write_string(const sclchar *name, const std::string value)
765 sclboolean ret = FALSE;
766 if (m_initialized && _scim_config) {
767 _scim_config->write(name, value);
773 sclboolean CSCLConnectionISF::config_erase(const sclchar *name)
775 sclboolean ret = FALSE;
776 if (m_initialized && _scim_config) {
777 _scim_config->erase(name);
783 sclboolean CSCLConnectionISF::config_flush(void)
785 sclboolean ret = FALSE;
786 if (m_initialized && _scim_config) {
787 _scim_config->flush();
793 void CSCLConnectionISF::send_imengine_event(sclint ic, const sclchar *ic_uuid, const sclint command, const sclu32 value)
798 uuid = scim::String(ic_uuid);
800 scim::Transaction trans;
801 trans.put_command(command);
802 trans.put_data(value);
803 m_helper_agent.send_imengine_event(ic, uuid, trans);
807 void CSCLConnectionISF::reset_keyboard_ise()
810 m_helper_agent.reset_keyboard_ise();
814 void CSCLConnectionISF::send_key_event(sclint ic, const sclchar *ic_uuid, sclu32 keycode, sclu16 keymask)
819 uuid = scim::String(ic_uuid);
821 scim::KeyEvent event;
822 event.code = keycode;
823 event.mask = keymask;
824 m_helper_agent.send_key_event(ic, uuid, event);
828 void CSCLConnectionISF::forward_key_event(sclint ic, const sclchar *ic_uuid, sclu32 keycode, sclu16 keymask)
833 uuid = scim::String(ic_uuid);
835 scim::KeyEvent event;
836 event.code = keycode;
837 event.mask = keymask;
838 m_helper_agent.forward_key_event(ic, uuid, event);
842 void CSCLConnectionISF::commit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str)
847 uuid = scim::String(ic_uuid);
849 m_helper_agent.commit_string(ic, uuid, scim::utf8_mbstowcs(str));
853 void CSCLConnectionISF::select_candidate(int index)
856 m_helper_agent.select_candidate(index);
860 void CSCLConnectionISF::show_preedit_string(sclint ic, const sclchar *ic_uuid)
865 uuid = scim::String(ic_uuid);
867 m_helper_agent.show_preedit_string(ic, uuid);
871 void CSCLConnectionISF::show_aux_string(void)
874 m_helper_agent.show_aux_string();
878 void CSCLConnectionISF::show_candidate_string(void)
881 m_helper_agent.show_candidate_string();
885 void CSCLConnectionISF::show_associate_string(void)
888 m_helper_agent.show_associate_string();
892 void CSCLConnectionISF::hide_preedit_string(sclint ic, const sclchar *ic_uuid)
897 uuid = scim::String(ic_uuid);
899 m_helper_agent.hide_preedit_string(ic, uuid);
903 void CSCLConnectionISF::hide_aux_string(void)
906 m_helper_agent.hide_aux_string();
910 void CSCLConnectionISF::hide_candidate_string(void)
913 m_helper_agent.hide_candidate_string();
917 void CSCLConnectionISF::hide_associate_string(void)
920 m_helper_agent.hide_associate_string();
924 void CSCLConnectionISF::update_preedit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str)
927 scim::AttributeList list;
930 uuid = scim::String(ic_uuid);
932 m_helper_agent.update_preedit_string(ic, uuid, scim::utf8_mbstowcs(str), list);
934 if (str && strlen(str) > 0) {
935 show_preedit_string(ic, ic_uuid);
937 hide_preedit_string(ic, ic_uuid);
942 void CSCLConnectionISF::update_preedit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str, const scim::AttributeList &attrs)
947 uuid = scim::String(ic_uuid);
949 m_helper_agent.update_preedit_string(ic, uuid, scim::utf8_mbstowcs(str), attrs);
951 if (str && strlen(str) > 0) {
952 show_preedit_string(ic, ic_uuid);
954 hide_preedit_string(ic, ic_uuid);
959 void CSCLConnectionISF::update_aux_string(const sclchar *str)
962 scim::AttributeList list;
963 m_helper_agent.update_aux_string(scim::String(str), list);
967 void CSCLConnectionISF::update_input_context(sclu32 type, sclu32 value)
970 m_helper_agent.update_input_context(type, value);
974 void CSCLConnectionISF::update_geometry(sclint x, sclint y, sclint width, sclint height)
977 m_helper_agent.update_geometry(x, y, width, height);
981 void CSCLConnectionISF::get_surrounding_text(const sclchar *ic_uuid, sclint maxlen_before, sclint maxlen_after) const
986 uuid = scim::String(ic_uuid);
988 m_helper_agent.get_surrounding_text(uuid, maxlen_before, maxlen_after);
992 sclint CSCLConnectionISF::get_surrounding_text(sclint maxlen_before, sclint maxlen_after, sclchar **text, int &cursor)
995 scim::String surrounding_text;
996 m_helper_agent.get_surrounding_text(maxlen_before, maxlen_after, surrounding_text, cursor);
999 *text = strdup(surrounding_text.c_str());
1000 if (*text == NULL) {
1008 void CSCLConnectionISF::delete_surrounding_text(sclint offset, sclint len) const
1010 if (m_initialized) {
1011 m_helper_agent.delete_surrounding_text(offset, len);
1015 void CSCLConnectionISF::set_candidate_position(sclint left, sclint top)
1017 if (m_initialized) {
1018 m_helper_agent.set_candidate_position(left, top);
1022 void CSCLConnectionISF::enable_soft_candidate(sclboolean enable)
1024 if (m_initialized) {
1026 m_helper_agent.set_candidate_style(scim::ONE_LINE_CANDIDATE, scim::SOFT_CANDIDATE_WINDOW);
1028 m_helper_agent.set_candidate_style(scim::ONE_LINE_CANDIDATE, scim::FIXED_CANDIDATE_WINDOW);
1032 void CSCLConnectionISF::candidate_hide(void)
1034 if (m_initialized) {
1035 m_helper_agent.candidate_hide();
1039 void CSCLConnectionISF::set_keyboard_ise_by_uuid(const sclchar *uuid)
1041 if (m_initialized) {
1042 m_helper_agent.set_keyboard_ise_by_uuid(uuid);
1046 void CSCLConnectionISF::get_keyboard_ise(const sclchar *uuid)
1048 if (m_initialized) {
1049 m_helper_agent.get_keyboard_ise(uuid);
1053 void CSCLConnectionISF::set_selection(sclint start, sclint end)
1055 if (m_initialized) {
1056 m_helper_agent.set_selection(start, end);
1060 void CSCLConnectionISF::send_private_command(const sclchar *command)
1062 if (m_initialized) {
1063 m_helper_agent.send_private_command(command);
1067 void CSCLConnectionISF::get_selection_text(sclchar **text)
1069 if (m_initialized) {
1070 scim::String selection_text;
1071 m_helper_agent.get_selection_text(selection_text);
1074 *text = strdup(selection_text.c_str());
1078 void CSCLConnectionISF::request_ise_hide()
1080 if (m_initialized) {
1081 m_helper_agent.request_ise_hide();
1087 void scim_module_init(void) {
1090 void scim_module_exit(void) {
1093 void scim_helper_module_run_helper(const scim::String &uuid, const scim::ConfigPointer &config, const scim::String &display) {
1094 _scim_config = config;
1095 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
1097 impl->on_run(uuid.c_str(), display.c_str());