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 callback->on_ise_show(ic, impl->get_screen_rotation_degree(), ise_context);
169 static void slot_ise_hide(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) {
170 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
172 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
174 callback->on_ise_hide(ic, ic_uuid.c_str());
179 static void slot_get_geometry(const scim::HelperAgent *agent, struct scim::rectinfo &info) {
180 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
182 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
184 callback->on_get_geometry(&(info.pos_x), &(info.pos_y), &(info.width), &(info.height));
189 static void slot_set_mode(const scim::HelperAgent *agent, scim::uint32 &mode) {
190 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
192 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
194 callback->on_set_mode(mode);
199 static void slot_set_language(const scim::HelperAgent *agent, scim::uint32 &language) {
200 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
202 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
204 callback->on_set_language(language);
209 static void slot_set_imdata(const scim::HelperAgent *agent, char *buf, size_t &len) {
210 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
212 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
214 scl32 _len = static_cast<scl32>(reinterpret_cast<size_t>(len) & 0xffffffff);
215 callback->on_set_imdata(buf, _len);
220 static void slot_get_imdata(const scim::HelperAgent *, char **buf, size_t &len) {
221 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
223 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
226 callback->on_get_imdata(buf, &_len);
232 static void slot_get_language_locale(const scim::HelperAgent *, int ic, char **locale) {
233 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
235 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
237 callback->on_get_language_locale(ic, locale);
242 static void slot_set_return_key_type(const scim::HelperAgent *agent, scim::uint32 &type) {
243 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
245 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
247 callback->on_set_return_key_type(type);
252 static void slot_get_return_key_type(const scim::HelperAgent *agent, scim::uint32 &type) {
253 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
255 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
257 callback->on_get_return_key_type(&type);
262 static void slot_set_return_key_disable(const scim::HelperAgent *agent, scim::uint32 &disabled) {
263 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
265 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
267 callback->on_set_return_key_disable(disabled);
272 static void slot_get_return_key_disable(const scim::HelperAgent *agent, scim::uint32 &disabled) {
273 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
275 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
277 callback->on_get_return_key_disable(&disabled);
282 static void slot_set_layout(const scim::HelperAgent *agent, scim::uint32 &layout) {
283 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
285 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
287 callback->on_set_layout(layout);
292 static void slot_get_layout(const scim::HelperAgent *agent, scim::uint32 &layout) {
293 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
295 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
297 callback->on_get_layout(&layout);
302 static void slot_set_caps_mode(const scim::HelperAgent *agent, scim::uint32 &mode) {
303 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
305 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
307 callback->on_set_caps_mode(mode);
312 static void slot_reset_input_context(const scim::HelperAgent *agent, int ic, const scim::String &uuid) {
313 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
315 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
317 callback->on_reset_input_context(ic, uuid.c_str());
322 static void slot_update_candidate_geometry(const scim::HelperAgent *agent, int ic, const scim::String &uuid, const scim::rectinfo &info) {
323 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
325 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
327 callback->on_update_candidate_geometry(ic, uuid.c_str(), info.pos_x, info.pos_y, info.width, info.height);
331 static void slot_update_keyboard_ise(const scim::HelperAgent *agent, int ic, const scim::String &uuid,
332 const scim::String &ise_name, const scim::String &ise_uuid) {
333 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
335 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
337 callback->on_update_keyboard_ise(ic, uuid.c_str(), ise_name.c_str(), ise_uuid.c_str());
342 static void slot_candidate_more_window_show(const scim::HelperAgent *agent, int ic, const scim::String &uuid) {
343 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
345 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
347 callback->on_candidate_more_window_show(ic, uuid.c_str());
352 static void slot_candidate_more_window_hide(const scim::HelperAgent *agent, int ic, const scim::String &uuid) {
353 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
355 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
357 callback->on_candidate_more_window_hide(ic, uuid.c_str());
362 static void slot_select_aux(const scim::HelperAgent *agent, int ic, const scim::String &uuid, int index) {
363 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
365 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
367 callback->on_select_aux(ic, uuid.c_str(), index);
372 static void slot_select_candidate(const scim::HelperAgent *agent, int ic, const scim::String &uuid, int index) {
373 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
375 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
377 callback->on_select_candidate(ic, uuid.c_str(), index);
382 static void slot_candidate_table_page_up(const scim::HelperAgent *agent, int ic, const scim::String &uuid) {
383 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
385 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
387 callback->on_candidate_table_page_up(ic, uuid.c_str());
392 static void slot_candidate_table_page_down(const scim::HelperAgent *agent, int ic, const scim::String &uuid) {
393 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
395 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
397 callback->on_candidate_table_page_down(ic, uuid.c_str());
402 static void slot_update_candidate_table_page_size(const scim::HelperAgent *, int ic, const scim::String &uuid, int page_size) {
403 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
405 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
407 callback->on_update_candidate_table_page_size(ic, uuid.c_str(), page_size);
412 static void slot_update_lookup_table(const scim::HelperAgent *, scim::LookupTable &table) {
413 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
415 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
417 SclCandidateTable lookup_table;
418 lookup_table.page_size = table.get_page_size();
419 lookup_table.current_page_start = table.get_current_page_start();
420 lookup_table.cursor_pos = table.get_cursor_pos();
421 lookup_table.cursor_visible = table.is_cursor_visible();
422 lookup_table.page_size_fixed = table.is_page_size_fixed();
423 lookup_table.candidate_labels.clear();
424 for (int page_index = 0;page_index < lookup_table.page_size;page_index++) {
425 scim::WideString label = table.get_candidate_label(page_index);
426 lookup_table.candidate_labels.push_back(scim::utf8_wcstombs(label).c_str());
429 int nCandidateSize = table.get_current_page_size();
430 for (int index = 0; index < nCandidateSize; ++index) {
431 scim::WideString candidate_str = table.get_candidate_in_current_page(index);
432 lookup_table.candidate.push_back(scim::utf8_wcstombs(candidate_str).c_str());
435 callback->on_update_lookup_table(lookup_table);
437 std::vector<scim::WideString> labels;
438 for (unsigned int loop = 0;loop < lookup_table.candidate_labels.size();loop++) {
439 labels.push_back(scim::utf8_mbstowcs(lookup_table.candidate_labels.at(loop).c_str()));
441 table.set_candidate_labels(labels);
446 static void slot_select_associate(const scim::HelperAgent *agent, int ic, const scim::String &uuid, int index) {
447 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
449 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
451 callback->on_select_associate(ic, uuid.c_str(), index);
456 static void slot_associate_table_page_up(const scim::HelperAgent *agent, int ic, const scim::String &uuid) {
457 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
459 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
461 callback->on_associate_table_page_up(ic, uuid.c_str());
466 static void slot_associate_table_page_down(const scim::HelperAgent *agent, int ic, const scim::String &uuid) {
467 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
469 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
471 callback->on_associate_table_page_down(ic, uuid.c_str());
476 static void slot_update_associate_table_page_size(const scim::HelperAgent *, int ic, const scim::String &uuid, int page_size) {
477 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
479 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
481 callback->on_update_associate_table_page_size(ic, uuid.c_str(), page_size);
486 static void slot_show_ise_option_window(const scim::HelperAgent *agent, int ic, const scim::String &uuid) {
487 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
489 CSCLCoreUI *core_ui = impl->get_core_ui();
491 LOGD("slot_show_ise_option_window() called!!!\n");
492 core_ui->create_option_window(OPTION_WINDOW_TYPE_SETTING_APPLICATION);
497 static void slot_check_ise_option_window(const scim::HelperAgent *agent, sclu32 &avail) {
498 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
500 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
502 callback->on_check_option_window_availability(reinterpret_cast<sclboolean *>(&avail));
507 static void slot_process_key_event(const scim::HelperAgent *agent, scim::KeyEvent &key, scim::uint32 &ret) {
508 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
510 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
512 callback->on_process_key_event(key, &ret);
517 static void slot_candidate_show(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) {
518 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
520 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
522 callback->on_candidate_show(ic, ic_uuid.c_str());
527 static void slot_candidate_hide(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) {
528 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
530 ISCLCoreEventCallback *callback = impl->get_core_event_callback();
532 callback->on_candidate_hide(ic, ic_uuid.c_str());
537 /* Internal input handler function */
538 Eina_Bool input_handler(void *data, Ecore_Fd_Handler *fd_handler)
540 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
542 scim::HelperAgent *agent = static_cast<scim::HelperAgent*>(data);
544 if (agent->has_pending_event()) {
545 if (!(agent->filter_event())) {
546 LOGD("helper_agent.filter_event() failed!!!\n");
551 LOGD("helper_agent.has_pending_event() failed!!!\n");
558 return ECORE_CALLBACK_RENEW;
561 CSCLConnectionISF::CSCLConnectionISF()
563 m_initialized = FALSE;
566 m_backend_identifier = "ISF";
569 CSCLConnectionISF::~CSCLConnectionISF()
573 sclboolean CSCLConnectionISF::init()
577 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
579 sclchar *uuid = impl->get_uuid();
581 m_helper_info.uuid = uuid;
585 if (!m_initialized) {
586 m_helper_agent.signal_connect_exit(scim::slot(slot_exit));
587 m_helper_agent.signal_connect_attach_input_context(scim::slot(slot_attach_input_context));
588 m_helper_agent.signal_connect_detach_input_context(scim::slot(slot_detach_input_context));
589 m_helper_agent.signal_connect_reload_config(scim::slot(slot_reload_config));
590 m_helper_agent.signal_connect_update_screen(scim::slot(slot_update_screen));
591 m_helper_agent.signal_connect_update_spot_location(scim::slot(slot_update_spot_location));
592 m_helper_agent.signal_connect_update_cursor_position(scim::slot(slot_update_cursor_position));
593 m_helper_agent.signal_connect_update_surrounding_text(scim::slot(slot_update_surrounding_text));
594 m_helper_agent.signal_connect_trigger_property(scim::slot(slot_trigger_property));
595 //m_helper_agent.signal_connect_process_imengine_event (slot (slot_process_imengine_event));
596 m_helper_agent.signal_connect_focus_out(scim::slot(slot_focus_out));
597 m_helper_agent.signal_connect_focus_in(scim::slot(slot_focus_in));
598 m_helper_agent.signal_connect_ise_show(scim::slot(slot_ise_show));
599 m_helper_agent.signal_connect_ise_hide(scim::slot(slot_ise_hide));
600 m_helper_agent.signal_connect_get_geometry(scim::slot(slot_get_geometry));
601 m_helper_agent.signal_connect_set_mode(scim::slot(slot_set_mode));
602 m_helper_agent.signal_connect_set_language(scim::slot(slot_set_language));
603 m_helper_agent.signal_connect_set_imdata(scim::slot(slot_set_imdata));
604 m_helper_agent.signal_connect_get_imdata(scim::slot(slot_get_imdata));
605 m_helper_agent.signal_connect_get_language_locale(scim::slot(slot_get_language_locale));
606 m_helper_agent.signal_connect_set_return_key_type(scim::slot(slot_set_return_key_type));
607 m_helper_agent.signal_connect_get_return_key_type(scim::slot(slot_get_return_key_type));
608 m_helper_agent.signal_connect_set_return_key_disable(scim::slot(slot_set_return_key_disable));
609 m_helper_agent.signal_connect_get_return_key_disable(scim::slot(slot_get_return_key_disable));
610 m_helper_agent.signal_connect_get_layout(scim::slot(slot_get_layout));
611 m_helper_agent.signal_connect_set_layout(scim::slot(slot_set_layout));
612 m_helper_agent.signal_connect_set_caps_mode(scim::slot(slot_set_caps_mode));
613 m_helper_agent.signal_connect_reset_input_context(scim::slot(slot_reset_input_context));
614 m_helper_agent.signal_connect_update_candidate_geometry(scim::slot(slot_update_candidate_geometry));
615 m_helper_agent.signal_connect_update_keyboard_ise(scim::slot(slot_update_keyboard_ise));
616 //m_helper_agent.signal_connect_update_keyboard_ise_list (slot (slot_update_keyboard_ise_list));
617 m_helper_agent.signal_connect_candidate_more_window_show(scim::slot(slot_candidate_more_window_show));
618 m_helper_agent.signal_connect_candidate_more_window_hide(scim::slot(slot_candidate_more_window_hide));
619 m_helper_agent.signal_connect_select_aux(scim::slot(slot_select_aux));
620 m_helper_agent.signal_connect_select_candidate(scim::slot(slot_select_candidate));
621 m_helper_agent.signal_connect_candidate_table_page_up(scim::slot(slot_candidate_table_page_up));
622 m_helper_agent.signal_connect_candidate_table_page_down(scim::slot(slot_candidate_table_page_down));
623 m_helper_agent.signal_connect_update_candidate_table_page_size(scim::slot(slot_update_candidate_table_page_size));
624 m_helper_agent.signal_connect_update_lookup_table(scim::slot(slot_update_lookup_table));
625 m_helper_agent.signal_connect_select_associate(scim::slot(slot_select_associate));
626 m_helper_agent.signal_connect_associate_table_page_up(scim::slot(slot_associate_table_page_up));
627 m_helper_agent.signal_connect_associate_table_page_down(scim::slot(slot_associate_table_page_down));
628 m_helper_agent.signal_connect_update_associate_table_page_size(scim::slot(slot_update_associate_table_page_size));
629 m_helper_agent.signal_connect_show_option_window(scim::slot(slot_show_ise_option_window));
630 m_helper_agent.signal_connect_check_option_window(scim::slot(slot_check_ise_option_window));
631 m_helper_agent.signal_connect_process_key_event(scim::slot(slot_process_key_event));
632 m_helper_agent.signal_connect_candidate_show(scim::slot(slot_candidate_show));
633 m_helper_agent.signal_connect_candidate_hide(scim::slot(slot_candidate_hide));
635 m_initialized = TRUE;
641 void CSCLConnectionISF::fini()
644 m_initialized = FALSE;
647 void CSCLConnectionISF::open_connection(const sclchar *display)
650 m_helper_agent.open_connection(m_helper_info, display);
651 int fd = m_helper_agent.get_connection_number();
655 Evas_Object *main_window = NULL;
656 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
658 main_window = NATIVE_WINDOW_CAST(impl->get_main_window());
661 Ecore_X_Window xwindow = elm_win_xwindow_get(main_window);
663 snprintf(xid, 255, "%d", xwindow);
664 scim::Property prop(xid, "XID", "", "");
665 scim::PropertyList props;
666 props.push_back(prop);
667 m_helper_agent.register_properties(props);
670 m_fd_handler = ecore_main_fd_handler_add(fd, ECORE_FD_READ, input_handler, &m_helper_agent, NULL, NULL);
674 void CSCLConnectionISF::close_connection()
678 ecore_main_fd_handler_del(m_fd_handler);
681 m_helper_agent.update_ise_exit();
682 m_helper_agent.close_connection();
686 void CSCLConnectionISF::config_reload()
689 m_helper_agent.reload_config();
693 sclboolean CSCLConnectionISF::config_read_int(const sclchar *name, sclint &value)
695 sclboolean ret = FALSE;
696 if (m_initialized && _scim_config) {
697 value = _scim_config->read(name, value);
703 sclboolean CSCLConnectionISF::config_read_string(const sclchar *name, std::string &value)
705 sclboolean ret = FALSE;
706 if (m_initialized && _scim_config) {
707 value = _scim_config->read(name, value);
713 sclboolean CSCLConnectionISF::config_write_int(const sclchar *name, sclint value)
715 sclboolean ret = FALSE;
716 if (m_initialized && _scim_config) {
717 _scim_config->write(name, value);
723 sclboolean CSCLConnectionISF::config_write_string(const sclchar *name, const std::string value)
725 sclboolean ret = FALSE;
726 if (m_initialized && _scim_config) {
727 _scim_config->write(name, value);
733 sclboolean CSCLConnectionISF::config_erase(const sclchar *name)
735 sclboolean ret = FALSE;
736 if (m_initialized && _scim_config) {
737 _scim_config->erase(name);
743 sclboolean CSCLConnectionISF::config_flush(void)
745 sclboolean ret = FALSE;
746 if (m_initialized && _scim_config) {
747 _scim_config->flush();
753 void CSCLConnectionISF::send_imengine_event(sclint ic, const sclchar *ic_uuid, const sclint command, const sclu32 value)
758 uuid = scim::String(ic_uuid);
760 scim::Transaction trans;
761 trans.put_command(command);
762 trans.put_data(value);
763 m_helper_agent.send_imengine_event(ic, uuid, trans);
767 void CSCLConnectionISF::reset_keyboard_ise()
770 m_helper_agent.reset_keyboard_ise();
774 void CSCLConnectionISF::send_key_event(sclint ic, const sclchar *ic_uuid, sclu32 keycode, sclu16 keymask)
779 uuid = scim::String(ic_uuid);
781 scim::KeyEvent event;
782 event.code = keycode;
783 event.mask = keymask;
784 m_helper_agent.send_key_event(ic, uuid, event);
788 void CSCLConnectionISF::forward_key_event(sclint ic, const sclchar *ic_uuid, sclu32 keycode, sclu16 keymask)
793 uuid = scim::String(ic_uuid);
795 scim::KeyEvent event;
796 event.code = keycode;
797 event.mask = keymask;
798 m_helper_agent.forward_key_event(ic, uuid, event);
802 void CSCLConnectionISF::commit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str)
807 uuid = scim::String(ic_uuid);
809 m_helper_agent.commit_string(ic, uuid, scim::utf8_mbstowcs(str));
813 void CSCLConnectionISF::select_candidate(int index)
816 m_helper_agent.select_candidate(index);
820 void CSCLConnectionISF::show_preedit_string(sclint ic, const sclchar *ic_uuid)
825 uuid = scim::String(ic_uuid);
827 m_helper_agent.show_preedit_string(ic, uuid);
831 void CSCLConnectionISF::show_aux_string(void)
834 m_helper_agent.show_aux_string();
838 void CSCLConnectionISF::show_candidate_string(void)
841 m_helper_agent.show_candidate_string();
845 void CSCLConnectionISF::show_associate_string(void)
848 m_helper_agent.show_associate_string();
852 void CSCLConnectionISF::hide_preedit_string(sclint ic, const sclchar *ic_uuid)
857 uuid = scim::String(ic_uuid);
859 m_helper_agent.hide_preedit_string(ic, uuid);
863 void CSCLConnectionISF::hide_aux_string(void)
866 m_helper_agent.hide_aux_string();
870 void CSCLConnectionISF::hide_candidate_string(void)
873 m_helper_agent.hide_candidate_string();
877 void CSCLConnectionISF::hide_associate_string(void)
880 m_helper_agent.hide_associate_string();
884 void CSCLConnectionISF::update_preedit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str)
887 scim::AttributeList list;
890 uuid = scim::String(ic_uuid);
892 m_helper_agent.update_preedit_string(ic, uuid, scim::utf8_mbstowcs(str), list);
894 if (str && strlen(str) > 0) {
895 show_preedit_string(ic, ic_uuid);
897 hide_preedit_string(ic, ic_uuid);
902 void CSCLConnectionISF::update_preedit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str, const scim::AttributeList &attrs)
907 uuid = scim::String(ic_uuid);
909 m_helper_agent.update_preedit_string(ic, uuid, scim::utf8_mbstowcs(str), attrs);
911 if (str && strlen(str) > 0) {
912 show_preedit_string(ic, ic_uuid);
914 hide_preedit_string(ic, ic_uuid);
919 void CSCLConnectionISF::update_aux_string(const sclchar *str)
922 scim::AttributeList list;
923 m_helper_agent.update_aux_string(scim::String(str), list);
927 void CSCLConnectionISF::update_input_context(sclu32 type, sclu32 value)
930 m_helper_agent.update_input_context(type, value);
934 void CSCLConnectionISF::update_geometry(sclint x, sclint y, sclint width, sclint height)
937 m_helper_agent.update_geometry(x, y, width, height);
941 void CSCLConnectionISF::get_surrounding_text(const sclchar *ic_uuid, sclint maxlen_before, sclint maxlen_after) const
946 uuid = scim::String(ic_uuid);
948 m_helper_agent.get_surrounding_text(uuid, maxlen_before, maxlen_after);
952 sclint CSCLConnectionISF::get_surrounding_text(sclint maxlen_before, sclint maxlen_after, sclchar **text, int &cursor)
955 scim::String surrounding_text;
956 m_helper_agent.get_surrounding_text(maxlen_before, maxlen_after, surrounding_text, cursor);
959 *text = strdup(surrounding_text.c_str());
968 void CSCLConnectionISF::delete_surrounding_text(sclint offset, sclint len) const
971 m_helper_agent.delete_surrounding_text(offset, len);
975 void CSCLConnectionISF::set_candidate_position(sclint left, sclint top)
978 m_helper_agent.set_candidate_position(left, top);
982 void CSCLConnectionISF::enable_soft_candidate(sclboolean enable)
986 m_helper_agent.set_candidate_style(scim::ONE_LINE_CANDIDATE, scim::SOFT_CANDIDATE_WINDOW);
988 m_helper_agent.set_candidate_style(scim::ONE_LINE_CANDIDATE, scim::FIXED_CANDIDATE_WINDOW);
992 void CSCLConnectionISF::candidate_hide(void)
995 m_helper_agent.candidate_hide();
999 void CSCLConnectionISF::set_keyboard_ise_by_uuid(const sclchar *uuid)
1001 if (m_initialized) {
1002 m_helper_agent.set_keyboard_ise_by_uuid(uuid);
1006 void CSCLConnectionISF::get_keyboard_ise(const sclchar *uuid)
1008 if (m_initialized) {
1009 m_helper_agent.get_keyboard_ise(uuid);
1013 void CSCLConnectionISF::set_selection(sclint start, sclint end)
1015 if (m_initialized) {
1016 m_helper_agent.set_selection(start, end);
1020 void CSCLConnectionISF::send_private_command(const sclchar *command)
1022 if (m_initialized) {
1023 m_helper_agent.send_private_command(command);
1027 void CSCLConnectionISF::get_selection_text(sclchar **text)
1029 if (m_initialized) {
1030 scim::String selection_text;
1031 m_helper_agent.get_selection(selection_text);
1034 *text = strdup(selection_text.c_str());
1040 void scim_module_init(void) {
1043 void scim_module_exit(void) {
1046 void scim_helper_module_run_helper(const scim::String &uuid, const scim::ConfigPointer &config, const scim::String &display) {
1047 _scim_config = config;
1048 CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
1050 impl->on_run(uuid.c_str(), display.c_str());