1 /** @file scim_helper.cpp
2 * @brief Implementation of class HelperAgent.
5 /* ISF is based on SCIM 1.4.7 and extended for supporting more mobile fitable. */
8 * Smart Common Input Method
10 * Copyright (c) 2004-2005 James Su <suzhe@tsinghua.org.cn>
11 * Copyright (c) 2012-2015 Samsung Electronics Co., Ltd.
14 * This library is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU Lesser General Public
16 * License as published by the Free Software Foundation; either
17 * version 2 of the License, or (at your option) any later version.
19 * This library is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License for more details.
24 * You should have received a copy of the GNU Lesser General Public
25 * License along with this program; if not, write to the
26 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
27 * Boston, MA 02111-1307 USA
29 * Modifications by Samsung Electronics Co., Ltd.
30 * 1. Add new interface APIs for keyboard ISE
31 * a. expand_candidate (), contract_candidate () and set_candidate_style ()
32 * b. set_keyboard_ise_by_uuid () and reset_keyboard_ise ()
33 * c. get_surrounding_text () and delete_surrounding_text ()
34 * d. show_preedit_string (), hide_preedit_string (), update_preedit_string () and update_preedit_caret ()
35 * e. show_candidate_string (), hide_candidate_string () and update_candidate_string ()
37 * $Id: scim_helper.cpp,v 1.13 2005/05/24 12:22:51 suzhe Exp $
41 #define Uses_SCIM_TRANSACTION
42 #define Uses_SCIM_TRANS_COMMANDS
43 #define Uses_SCIM_HELPER
44 #define Uses_SCIM_SOCKET
45 #define Uses_SCIM_EVENT
46 #define Uses_SCIM_BACKEND
47 #define Uses_SCIM_IMENGINE_MODULE
53 #include "scim_private.h"
55 #include <scim_panel_common.h>
56 #include "isf_query_utility.h"
58 #include "isf_debug.h"
59 #include "isf_message_queue.h"
60 #ifdef HAVE_PKGMGR_INFO
61 #include <pkgmgr-info.h>
62 #endif // HAVE_PKGMGR_INFO
67 #define LOG_TAG "SCIM_HELPER"
70 //FIXME: remove this definitions
71 #define SHIFT_MODE_OFF 0xffe1
72 #define SHIFT_MODE_ON 0xffe2
73 #define SHIFT_MODE_LOCK 0xffe6
74 #define SHIFT_MODE_ENABLE 0x9fe7
75 #define SHIFT_MODE_DISABLE 0x9fe8
79 typedef Signal3<void, const HelperAgent *, int, const String &>
80 HelperAgentSignalVoid;
82 typedef Signal4<void, const HelperAgent *, int, const String &, const String &>
83 HelperAgentSignalString;
85 typedef Signal4<void, const HelperAgent *, int, const String &, const std::vector<String> &>
86 HelperAgentSignalStringVector;
88 typedef Signal5<void, const HelperAgent *, int, const String &, const String &, const String &>
89 HelperAgentSignalString2;
91 typedef Signal4<void, const HelperAgent *, int, const String &, int>
94 typedef Signal5<void, const HelperAgent *, int, const String &, int, int>
95 HelperAgentSignalIntInt;
97 typedef Signal4<void, const HelperAgent *, int, const String &, const Transaction &>
98 HelperAgentSignalTransaction;
100 typedef Signal4<void, const HelperAgent *, int, const String &, const rectinfo &>
101 HelperAgentSignalRect;
103 typedef Signal2<void, const HelperAgent *, struct rectinfo &>
104 HelperAgentSignalSize;
106 typedef Signal2<void, const HelperAgent *, uint32 &>
107 HelperAgentSignalUintVoid;
109 typedef Signal3<void, const HelperAgent *, int, uint32 &>
110 HelperAgentSignalIntUint;
112 typedef Signal3 <void, const HelperAgent *, char *, size_t &>
113 HelperAgentSignalRawVoid;
115 typedef Signal3 <void, const HelperAgent *, char **, size_t &>
116 HelperAgentSignalGetRawVoid;
118 typedef Signal4 <void, const HelperAgent *, int, char *, size_t &>
119 HelperAgentSignalIntRawVoid;
121 typedef Signal3 <void, const HelperAgent *, int, char **>
122 HelperAgentSignalIntGetStringVoid;
124 typedef Signal2<void, const HelperAgent *, const std::vector<uint32> &>
125 HelperAgentSignalUintVector;
127 typedef Signal2<void, const HelperAgent *, LookupTable &>
128 HelperAgentSignalLookupTable;
130 typedef Signal3<void, const HelperAgent *, KeyEvent &, uint32 &>
131 HelperAgentSignalKeyEventUint;
133 typedef Signal5<void, const HelperAgent *, uint32 &, char *, size_t &, uint32 &>
134 HelperAgentSignalUintCharSizeUint;
136 class HelperAgent::HelperAgentImpl
140 SocketClient socket_active;
149 IMEngineInstancePointer si;
150 ConfigPointer m_config;
151 IMEngineModule engine_module;
153 char* surrounding_text;
154 char* selection_text;
156 int need_update_surrounding_text;
157 int need_update_selection_text;
160 HelperAgentSignalVoid signal_exit;
161 HelperAgentSignalVoid signal_attach_input_context;
162 HelperAgentSignalVoid signal_detach_input_context;
163 HelperAgentSignalVoid signal_reload_config;
164 HelperAgentSignalInt signal_update_screen;
165 HelperAgentSignalIntInt signal_update_spot_location;
166 HelperAgentSignalInt signal_update_cursor_position;
167 HelperAgentSignalInt signal_update_surrounding_text;
168 HelperAgentSignalVoid signal_update_selection;
169 HelperAgentSignalString signal_trigger_property;
170 HelperAgentSignalTransaction signal_process_imengine_event;
171 HelperAgentSignalVoid signal_focus_out;
172 HelperAgentSignalVoid signal_focus_in;
173 HelperAgentSignalIntRawVoid signal_ise_show;
174 HelperAgentSignalVoid signal_ise_hide;
175 HelperAgentSignalVoid signal_candidate_show;
176 HelperAgentSignalVoid signal_candidate_hide;
177 HelperAgentSignalSize signal_get_geometry;
178 HelperAgentSignalUintVoid signal_set_mode;
179 HelperAgentSignalUintVoid signal_set_language;
180 HelperAgentSignalRawVoid signal_set_imdata;
181 HelperAgentSignalGetRawVoid signal_get_imdata;
182 HelperAgentSignalIntGetStringVoid signal_get_language_locale;
183 HelperAgentSignalUintVoid signal_set_return_key_type;
184 HelperAgentSignalUintVoid signal_get_return_key_type;
185 HelperAgentSignalUintVoid signal_set_return_key_disable;
186 HelperAgentSignalUintVoid signal_get_return_key_disable;
187 HelperAgentSignalUintVoid signal_set_layout;
188 HelperAgentSignalUintVoid signal_get_layout;
189 HelperAgentSignalUintVoid signal_set_caps_mode;
190 HelperAgentSignalVoid signal_reset_input_context;
191 HelperAgentSignalIntInt signal_update_candidate_ui;
192 HelperAgentSignalRect signal_update_candidate_geometry;
193 HelperAgentSignalString2 signal_update_keyboard_ise;
194 HelperAgentSignalStringVector signal_update_keyboard_ise_list;
195 HelperAgentSignalVoid signal_candidate_more_window_show;
196 HelperAgentSignalVoid signal_candidate_more_window_hide;
197 HelperAgentSignalLookupTable signal_update_lookup_table;
198 HelperAgentSignalInt signal_select_aux;
199 HelperAgentSignalInt signal_select_candidate;
200 HelperAgentSignalVoid signal_candidate_table_page_up;
201 HelperAgentSignalVoid signal_candidate_table_page_down;
202 HelperAgentSignalInt signal_update_candidate_table_page_size;
203 HelperAgentSignalUintVector signal_update_candidate_item_layout;
204 HelperAgentSignalInt signal_select_associate;
205 HelperAgentSignalVoid signal_associate_table_page_up;
206 HelperAgentSignalVoid signal_associate_table_page_down;
207 HelperAgentSignalInt signal_update_associate_table_page_size;
208 HelperAgentSignalVoid signal_reset_ise_context;
209 HelperAgentSignalUintVoid signal_turn_on_log;
210 HelperAgentSignalInt signal_update_displayed_candidate_number;
211 HelperAgentSignalInt signal_longpress_candidate;
212 HelperAgentSignalKeyEventUint signal_process_key_event;
213 HelperAgentSignalUintVoid signal_set_input_mode;
214 HelperAgentSignalUintVoid signal_set_input_hint;
215 HelperAgentSignalUintVoid signal_update_bidi_direction;
216 HelperAgentSignalVoid signal_show_option_window;
217 HelperAgentSignalUintVoid signal_check_option_window;
218 HelperAgentSignalUintCharSizeUint signal_process_input_device_event;
221 HelperAgentImpl (HelperAgent* thiz) : focused_ic ((uint32) -1), thiz (thiz),
222 surrounding_text (NULL), selection_text (NULL), cursor_pos (0),
223 need_update_surrounding_text (0), need_update_selection_text (0),
227 ~HelperAgentImpl () {
232 if (surrounding_text != NULL)
233 free (surrounding_text);
235 if (selection_text != NULL)
236 free (selection_text);
238 if (engine_module.valid ()) {
239 engine_module.unload ();
243 // Implementation of slot functions
245 slot_show_preedit_string (IMEngineInstanceBase *si)
248 thiz->show_preedit_string (focused_ic, "");
252 slot_show_aux_string (IMEngineInstanceBase *si)
255 thiz->show_aux_string ();
259 slot_show_lookup_table (IMEngineInstanceBase *si)
262 thiz->show_candidate_string ();
266 slot_hide_preedit_string (IMEngineInstanceBase *si)
269 thiz->hide_preedit_string (focused_ic, "");
273 slot_hide_aux_string (IMEngineInstanceBase *si)
276 thiz->hide_aux_string ();
280 slot_hide_lookup_table (IMEngineInstanceBase *si)
283 thiz->hide_candidate_string ();
287 slot_update_preedit_caret (IMEngineInstanceBase *si, int caret)
290 thiz->update_preedit_caret (caret);
294 slot_update_preedit_string (IMEngineInstanceBase *si,
295 const WideString & str,
296 const AttributeList & attrs,
300 thiz->update_preedit_string (-1, "", str, attrs, caret);
304 slot_update_preedit_string_with_commit (IMEngineInstanceBase *si,
305 const WideString & preedit,
306 const WideString & commit,
307 const AttributeList & attrs,
311 thiz->update_preedit_string (-1, "", preedit, commit, attrs, caret);
315 slot_update_aux_string (IMEngineInstanceBase *si,
316 const WideString & str,
317 const AttributeList & attrs)
320 thiz->update_aux_string (utf8_wcstombs(str), attrs);
324 slot_commit_string (IMEngineInstanceBase *si,
325 const WideString & str)
328 thiz->commit_string (-1, "", str);
332 slot_forward_key_event (IMEngineInstanceBase *si,
333 const KeyEvent & key)
336 thiz->forward_key_event (-1, "", key);
340 slot_update_lookup_table (IMEngineInstanceBase *si,
341 const LookupTable & table)
344 thiz->update_candidate_string (table);
348 slot_register_properties (IMEngineInstanceBase *si,
349 const PropertyList & properties)
352 thiz->register_properties (properties);
356 slot_update_property (IMEngineInstanceBase *si,
357 const Property & property)
360 thiz->update_property (property);
364 slot_beep (IMEngineInstanceBase *si)
371 slot_start_helper (IMEngineInstanceBase *si,
372 const String &helper_uuid)
374 LOGW ("deprecated function");
378 slot_stop_helper (IMEngineInstanceBase *si,
379 const String &helper_uuid)
381 LOGW ("deprecated function");
385 slot_send_helper_event (IMEngineInstanceBase *si,
386 const String &helper_uuid,
387 const Transaction &trans)
390 signal_process_imengine_event (thiz, focused_ic, helper_uuid, trans);
394 slot_get_surrounding_text (IMEngineInstanceBase *si,
402 thiz->get_surrounding_text (maxlen_before, maxlen_after, _text, cursor);
403 text = utf8_mbstowcs(_text);
408 slot_delete_surrounding_text (IMEngineInstanceBase *si,
414 thiz->delete_surrounding_text (offset, len);
419 slot_get_selection (IMEngineInstanceBase *si,
424 thiz->get_selection_text (_text);
425 text = utf8_mbstowcs (_text);
430 slot_set_selection (IMEngineInstanceBase *si,
435 thiz->set_selection (start, end);
440 slot_expand_candidate (IMEngineInstanceBase *si)
443 thiz->expand_candidate ();
447 slot_contract_candidate (IMEngineInstanceBase *si)
450 thiz->contract_candidate ();
454 slot_set_candidate_style (IMEngineInstanceBase *si, ISF_CANDIDATE_PORTRAIT_LINE_T portrait_line, ISF_CANDIDATE_MODE_T mode)
457 thiz->set_candidate_style (portrait_line, mode);
461 slot_send_private_command (IMEngineInstanceBase *si,
462 const String &command)
465 thiz->send_private_command (command);
471 si->signal_connect_show_preedit_string (
472 slot (this, &HelperAgent::HelperAgentImpl::slot_show_preedit_string));
473 si->signal_connect_show_aux_string (
474 slot (this, &HelperAgent::HelperAgentImpl::slot_show_aux_string));
475 si->signal_connect_show_lookup_table (
476 slot (this, &HelperAgent::HelperAgentImpl::slot_show_lookup_table));
478 si->signal_connect_hide_preedit_string (
479 slot (this, &HelperAgent::HelperAgentImpl::slot_hide_preedit_string));
480 si->signal_connect_hide_aux_string (
481 slot (this, &HelperAgent::HelperAgentImpl::slot_hide_aux_string));
482 si->signal_connect_hide_lookup_table (
483 slot (this, &HelperAgent::HelperAgentImpl::slot_hide_lookup_table));
485 si->signal_connect_update_preedit_caret (
486 slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_caret));
487 si->signal_connect_update_preedit_string (
488 slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_string));
489 si->signal_connect_update_preedit_string_with_commit (
490 slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_string_with_commit));
492 si->signal_connect_update_aux_string (
493 slot (this, &HelperAgent::HelperAgentImpl::slot_update_aux_string));
494 si->signal_connect_update_lookup_table (
495 slot (this, &HelperAgent::HelperAgentImpl::slot_update_lookup_table));
497 si->signal_connect_commit_string (
498 slot (this, &HelperAgent::HelperAgentImpl::slot_commit_string));
500 si->signal_connect_forward_key_event (
501 slot (this, &HelperAgent::HelperAgentImpl::slot_forward_key_event));
503 si->signal_connect_register_properties (
504 slot (this, &HelperAgent::HelperAgentImpl::slot_register_properties));
506 si->signal_connect_update_property (
507 slot (this, &HelperAgent::HelperAgentImpl::slot_update_property));
509 si->signal_connect_beep (
510 slot (this, &HelperAgent::HelperAgentImpl::slot_beep));
512 si->signal_connect_start_helper (
513 slot (this, &HelperAgent::HelperAgentImpl::slot_start_helper));
515 si->signal_connect_stop_helper (
516 slot (this, &HelperAgent::HelperAgentImpl::slot_stop_helper));
518 si->signal_connect_send_helper_event (
519 slot (this, &HelperAgent::HelperAgentImpl::slot_send_helper_event));
521 si->signal_connect_get_surrounding_text (
522 slot (this, &HelperAgent::HelperAgentImpl::slot_get_surrounding_text));
524 si->signal_connect_delete_surrounding_text (
525 slot (this, &HelperAgent::HelperAgentImpl::slot_delete_surrounding_text));
527 si->signal_connect_get_selection (
528 slot (this, &HelperAgent::HelperAgentImpl::slot_get_selection));
530 si->signal_connect_set_selection (
531 slot (this, &HelperAgent::HelperAgentImpl::slot_set_selection));
533 si->signal_connect_expand_candidate (
534 slot (this, &HelperAgent::HelperAgentImpl::slot_expand_candidate));
535 si->signal_connect_contract_candidate (
536 slot (this, &HelperAgent::HelperAgentImpl::slot_contract_candidate));
538 si->signal_connect_set_candidate_style (
539 slot (this, &HelperAgent::HelperAgentImpl::slot_set_candidate_style));
541 si->signal_connect_send_private_command (
542 slot (this, &HelperAgent::HelperAgentImpl::slot_send_private_command));
545 void process_key_event_done (KeyEvent &key, uint32 ret, uint32 serial) {
546 LOGD ("ret: %d, serial: %d", ret, serial);
547 if (socket_active.is_connected ()) {
549 send.put_command (SCIM_TRANS_CMD_REQUEST);
550 send.put_data (magic_active);
551 send.put_command (ISM_TRANS_CMD_PROCESS_KEY_EVENT_DONE);
554 send.put_data (serial);
555 send.write_to_socket (socket_active, magic_active);
559 void request_ise_hide () {
560 if (socket_active.is_connected ()) {
562 send.put_command (SCIM_TRANS_CMD_REQUEST);
563 send.put_data (magic_active);
564 send.put_command (ISM_TRANS_CMD_REQUEST_ISE_HIDE);
565 send.write_to_socket (socket_active, magic_active);
569 HelperAgentImpl () : magic (0), magic_active (0), timeout (-1), focused_ic ((uint32) -1) { }
572 static MessageQueue message_queue;
574 HelperAgent::HelperAgent ()
575 : m_impl (new HelperAgentImpl (this))
577 message_queue.create();
580 HelperAgent::~HelperAgent ()
582 message_queue.destroy();
587 * @brief Open socket connection to the Panel.
589 * @param info The information of this Helper object.
590 * @param display The display which this Helper object should run on.
592 * @return The connection socket id. -1 means failed to create
596 HelperAgent::open_connection (const HelperInfo &info,
597 const String &display)
599 if (m_impl->socket.is_connected ())
602 SocketAddress address (scim_get_default_panel_socket_address (display));
603 int timeout = m_impl->timeout = scim_get_default_socket_timeout ();
606 if (!address.valid ())
610 std::cerr << " Connecting to PanelAgent server.";
611 ISF_LOG (" Connecting to PanelAgent server.\n");
612 while (!m_impl->socket.connect (address)) {
614 scim_usleep (100000);
616 std::cerr << "m_impl->socket.connect () is failed!!!\n";
617 ISF_LOG ("m_impl->socket.connect () is failed!!!\n");
621 std::cerr << " Connected :" << i << "\n";
622 ISF_LOG (" Connected :%d\n", i);
623 LOGD ("Connection to PanelAgent succeeded, %d\n", i);
625 /* Let's retry 10 times when failed */
626 int open_connection_retries = 0;
627 while (!scim_socket_open_connection (magic,
632 if (++open_connection_retries > 10) {
633 m_impl->socket.close ();
634 std::cerr << "scim_socket_open_connection () is failed!!!\n";
635 ISF_LOG ("scim_socket_open_connection () is failed!!!\n");
636 ISF_SAVE_LOG ("scim_socket_open_connection failed, %d\n", timeout);
641 /* Retry after re-connecting the socket */
642 if (m_impl->socket.is_connected ())
645 /* This time, just retry atmost 2 seconds */
647 while (!m_impl->socket.connect (address) && ++i < 10) {
648 scim_usleep (200000);
653 ISF_LOG ("scim_socket_open_connection () is successful.\n");
654 LOGD ("scim_socket_open_connection successful\n");
656 m_impl->send.clear ();
657 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
658 m_impl->send.put_data (magic);
659 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_REGISTER_HELPER);
660 m_impl->send.put_data (info.uuid);
661 m_impl->send.put_data (info.name);
662 m_impl->send.put_data (info.icon);
663 m_impl->send.put_data (info.description);
664 m_impl->send.put_data (info.option);
666 if (!m_impl->send.write_to_socket (m_impl->socket, magic)) {
667 m_impl->socket.close ();
672 if (m_impl->recv.read_from_socket (m_impl->socket, timeout) &&
673 m_impl->recv.get_command (cmd) && cmd == SCIM_TRANS_CMD_REPLY &&
674 m_impl->recv.get_command (cmd) && cmd == SCIM_TRANS_CMD_OK) {
675 m_impl->magic = magic;
677 while (m_impl->recv.get_command (cmd)) {
679 case SCIM_TRANS_CMD_HELPER_ATTACH_INPUT_CONTEXT:
683 while (m_impl->recv.get_data (ic) && m_impl->recv.get_data (ic_uuid))
684 m_impl->signal_attach_input_context (this, ic, ic_uuid);
687 case SCIM_TRANS_CMD_UPDATE_SCREEN:
690 if (m_impl->recv.get_data (screen))
691 m_impl->signal_update_screen (this, (uint32) -1, String (""), (int) screen);
699 //FIXME: Attaching input context is needed for desktop environment
700 LOGW ("Attach input context and update screen failed");
703 ISF_SAVE_LOG ("Trying connect() with Helper_Active\n");
705 /* connect to the panel agent as the active helper client */
706 if (!m_impl->socket_active.connect (address)) return -1;
707 if (!scim_socket_open_connection (magic,
708 String ("Helper_Active"),
710 m_impl->socket_active,
712 m_impl->socket_active.close ();
713 ISF_SAVE_LOG ("Helper_Active scim_socket_open_connection() failed %d\n", timeout);
717 m_impl->magic_active = magic;
719 m_impl->send.clear ();
720 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
721 m_impl->send.put_data (magic);
722 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_REGISTER_ACTIVE_HELPER);
723 m_impl->send.put_data (info.uuid);
724 m_impl->send.put_data (info.name);
725 m_impl->send.put_data (info.icon);
726 m_impl->send.put_data (info.description);
727 m_impl->send.put_data (info.option);
729 if (!m_impl->send.write_to_socket (m_impl->socket_active, magic)) {
730 ISF_SAVE_LOG ("Helper_Active write_to_socket() failed\n");
731 m_impl->socket_active.close ();
734 m_impl->m_config = ConfigBase::get (false, "socket");
736 return m_impl->socket.get_id ();
740 * @brief Close the socket connection to Panel.
743 HelperAgent::close_connection ()
745 m_impl->socket.close ();
746 m_impl->socket_active.close ();
747 m_impl->send.clear ();
748 m_impl->recv.clear ();
750 m_impl->magic_active = 0;
755 * @brief Get the connection id previously returned by open_connection().
757 * @return the connection id
760 HelperAgent::get_connection_number () const
762 if (m_impl->socket.is_connected ())
763 return m_impl->socket.get_id ();
768 * @brief Check whether this HelperAgent has been connected to a Panel.
770 * Return true when it is connected to panel, otherwise return false.
773 HelperAgent::is_connected () const
775 return m_impl->socket.is_connected ();
779 * @brief Check if there are any events available to be processed.
781 * If it returns true then Helper object should call
782 * HelperAgent::filter_event() to process them.
784 * @return true if there are any events available.
787 HelperAgent::has_pending_event () const
789 if (m_impl->socket.is_connected () && m_impl->socket.wait_for_data (0) > 0)
792 if (message_queue.has_pending_message())
799 * @brief Process the pending events.
801 * This function will emit the corresponding signals according
804 * @return false if the connection is broken, otherwise return true.
807 HelperAgent::filter_event ()
809 if (!m_impl->socket.is_connected () || !m_impl->recv.read_from_socket (m_impl->socket, m_impl->timeout))
812 message_queue.read_from_transaction(m_impl->recv);
814 while (message_queue.has_pending_message()) {
815 MessageItem *message = message_queue.get_pending_message();
816 handle_message(message);
817 message_queue.remove_message(message);
825 * @brief Read messages from socket buffer, and see if there is a message with the given cmd.
827 * @return false if the connection is broken, or no message available with given cmd. Otherwise return true.
830 HelperAgent::wait_for_message(int cmd, int timeout)
832 struct timeval t0 = { 0, 0 };
833 struct timeval t1 = { 0, 0 };
835 gettimeofday(&t0, NULL);
839 if (!m_impl->socket.is_connected() || !m_impl->recv.read_from_socket(m_impl->socket, timeout))
842 message_queue.read_from_transaction(m_impl->recv);
843 if (message_queue.get_pending_message_by_cmd(cmd)) {
847 gettimeofday(&t1, NULL);
848 etime = ((t1.tv_sec * 1000000 + t1.tv_usec) - (t0.tv_sec * 1000000 + t0.tv_usec)) / 1000;
851 } while (etime < timeout);
857 * @brief Process one message that is in our message queue.
859 * This function will emit the corresponding signals according
862 * @param message The message that needs to be handled.
864 * @return false if the connection is broken, otherwise return true.
867 HelperAgent::handle_message (MessageItem *message)
872 int cmd = message->get_command_ref();
873 LOGD ("HelperAgent::cmd = %d\n", cmd);
875 case SCIM_TRANS_CMD_EXIT:
877 MessageItemExit *subclass = static_cast<MessageItemExit*>(message);
878 ISF_SAVE_LOG ("Helper ISE received SCIM_TRANS_CMD_EXIT message\n");
879 m_impl->signal_exit(this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
882 case SCIM_TRANS_CMD_RELOAD_CONFIG:
884 MessageItemReloadConfig *subclass = static_cast<MessageItemReloadConfig*>(message);
885 m_impl->signal_reload_config (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
886 if (!m_impl->m_config.null())
887 m_impl->m_config->ConfigBase::reload();
890 case SCIM_TRANS_CMD_UPDATE_SCREEN:
892 MessageItemUpdateScreen *subclass = static_cast<MessageItemUpdateScreen*>(message);
893 m_impl->signal_update_screen (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
894 subclass->get_screen_ref());
897 case SCIM_TRANS_CMD_UPDATE_SPOT_LOCATION:
899 MessageItemUpdateSpotLocation *subclass = static_cast<MessageItemUpdateSpotLocation*>(message);
900 m_impl->signal_update_spot_location (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
901 subclass->get_x_ref(), subclass->get_y_ref());
904 case ISM_TRANS_CMD_UPDATE_CURSOR_POSITION:
906 MessageItemUpdateCursorPosition *subclass = static_cast<MessageItemUpdateCursorPosition*>(message);
907 m_impl->cursor_pos = subclass->get_cursor_pos_ref();
908 LOGD ("update cursor position %d", subclass->get_cursor_pos_ref());
909 m_impl->signal_update_cursor_position (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
910 subclass->get_cursor_pos_ref());
911 if (!m_impl->si.null ()) m_impl->si->update_cursor_position(subclass->get_cursor_pos_ref());
914 case ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT:
916 MessageItemUpdateSurroundingText *subclass = static_cast<MessageItemUpdateSurroundingText*>(message);
917 if (m_impl->surrounding_text != NULL)
918 free (m_impl->surrounding_text);
919 m_impl->surrounding_text = strdup (subclass->get_text_ref().c_str ());
920 m_impl->cursor_pos = subclass->get_cursor_ref();
921 LOGD ("surrounding text: %s, %d", m_impl->surrounding_text, subclass->get_cursor_ref());
922 while (m_impl->need_update_surrounding_text > 0) {
923 m_impl->need_update_surrounding_text--;
924 m_impl->signal_update_surrounding_text (this, subclass->get_ic_ref(),
925 subclass->get_text_ref(), subclass->get_cursor_ref());
929 case ISM_TRANS_CMD_UPDATE_SELECTION:
931 MessageItemUpdateSelection *subclass = static_cast<MessageItemUpdateSelection*>(message);
932 if (m_impl->selection_text != NULL)
933 free (m_impl->selection_text);
935 m_impl->selection_text = strdup (subclass->get_text_ref().c_str ());
936 LOGD ("selection text: %s", m_impl->selection_text);
938 while (m_impl->need_update_selection_text > 0) {
939 m_impl->need_update_selection_text--;
940 m_impl->signal_update_selection (this, subclass->get_ic_ref(), subclass->get_text_ref());
944 case SCIM_TRANS_CMD_TRIGGER_PROPERTY:
946 MessageItemTriggerProperty *subclass = static_cast<MessageItemTriggerProperty*>(message);
947 m_impl->signal_trigger_property (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
948 subclass->get_property_ref());
949 if (!m_impl->si.null ()) m_impl->si->trigger_property(subclass->get_property_ref());
952 case SCIM_TRANS_CMD_HELPER_PROCESS_IMENGINE_EVENT:
954 MessageItemHelperProcessImengineEvent *subclass = static_cast<MessageItemHelperProcessImengineEvent*>(message);
955 m_impl->signal_process_imengine_event (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
956 subclass->get_transaction_ref());
959 case SCIM_TRANS_CMD_HELPER_ATTACH_INPUT_CONTEXT:
961 MessageItemHelperAttachInputContext *subclass = static_cast<MessageItemHelperAttachInputContext*>(message);
962 m_impl->signal_attach_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
965 case SCIM_TRANS_CMD_HELPER_DETACH_INPUT_CONTEXT:
967 MessageItemHelperDetachInputContext *subclass = static_cast<MessageItemHelperDetachInputContext*>(message);
968 m_impl->signal_detach_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
971 case SCIM_TRANS_CMD_FOCUS_OUT:
973 MessageItemFocusOut *subclass = static_cast<MessageItemFocusOut*>(message);
974 m_impl->signal_focus_out (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
975 m_impl->focused_ic = (uint32) -1;
976 if (!m_impl->si.null ()) m_impl->si->focus_out();
979 case SCIM_TRANS_CMD_FOCUS_IN:
981 MessageItemFocusIn *subclass = static_cast<MessageItemFocusIn*>(message);
982 m_impl->signal_focus_in (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
983 m_impl->focused_ic = subclass->get_ic_ref();
984 if (!m_impl->si.null ()) m_impl->si->focus_in();
987 case ISM_TRANS_CMD_SHOW_ISE_PANEL:
989 MessageItemShowISEPanel *subclass = static_cast<MessageItemShowISEPanel*>(message);
990 LOGD ("Helper ISE received ISM_TRANS_CMD_SHOW_ISE_PANEL message\n");
992 m_impl->signal_ise_show (this, subclass->get_ic_ref(), *(subclass->get_data_ptr()),
993 subclass->get_len_ref());
996 case ISM_TRANS_CMD_HIDE_ISE_PANEL:
998 MessageItemHideISEPanel *subclass = static_cast<MessageItemHideISEPanel*>(message);
999 LOGD ("Helper ISE received ISM_TRANS_CMD_HIDE_ISE_PANEL message\n");
1000 m_impl->signal_ise_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1003 case ISM_TRANS_CMD_GET_ACTIVE_ISE_GEOMETRY:
1005 struct rectinfo info = {0, 0, 0, 0};
1006 m_impl->signal_get_geometry (this, info);
1007 m_impl->send.clear ();
1008 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1009 m_impl->send.put_data (info.pos_x);
1010 m_impl->send.put_data (info.pos_y);
1011 m_impl->send.put_data (info.width);
1012 m_impl->send.put_data (info.height);
1013 m_impl->send.write_to_socket (m_impl->socket);
1016 case ISM_TRANS_CMD_SET_ISE_MODE:
1018 MessageItemSetISEMode *subclass = static_cast<MessageItemSetISEMode*>(message);
1019 m_impl->signal_set_mode (this, subclass->get_mode_ref());
1022 case ISM_TRANS_CMD_SET_ISE_LANGUAGE:
1024 MessageItemSetISELanguage *subclass = static_cast<MessageItemSetISELanguage*>(message);
1025 m_impl->signal_set_language (this, subclass->get_language_ref());
1028 case ISM_TRANS_CMD_SET_ISE_IMDATA:
1030 MessageItemSetISEImData *subclass = static_cast<MessageItemSetISEImData*>(message);
1031 m_impl->signal_set_imdata (this, *(subclass->get_imdata_ptr()), subclass->get_len_ref());
1032 if (!m_impl->si.null ()) m_impl->si->set_imdata(*(subclass->get_imdata_ptr()),
1033 subclass->get_len_ref());
1036 case ISM_TRANS_CMD_GET_ISE_IMDATA:
1041 m_impl->signal_get_imdata (this, &buf, len);
1042 LOGD ("send ise imdata len = %d", len);
1043 m_impl->send.clear ();
1044 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1045 m_impl->send.put_data (buf, len);
1046 m_impl->send.write_to_socket (m_impl->socket);
1051 case ISM_TRANS_CMD_GET_ISE_LANGUAGE_LOCALE:
1053 MessageItemGetISELanguageLocale *subclass = static_cast<MessageItemGetISELanguageLocale*>(message);
1055 m_impl->signal_get_language_locale (this, subclass->get_ic_ref(), &buf);
1056 m_impl->send.clear ();
1057 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1059 m_impl->send.put_data (buf, strlen (buf));
1060 m_impl->send.write_to_socket (m_impl->socket);
1065 case ISM_TRANS_CMD_SET_RETURN_KEY_TYPE:
1067 MessageItemSetReturnKeyType *subclass = static_cast<MessageItemSetReturnKeyType*>(message);
1068 m_impl->signal_set_return_key_type (this, subclass->get_type_ref());
1071 case ISM_TRANS_CMD_GET_RETURN_KEY_TYPE:
1074 m_impl->signal_get_return_key_type (this, type);
1075 m_impl->send.clear ();
1076 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1077 m_impl->send.put_data (type);
1078 m_impl->send.write_to_socket (m_impl->socket);
1081 case ISM_TRANS_CMD_SET_RETURN_KEY_DISABLE:
1083 MessageItemSetReturnKeyDisable *subclass = static_cast<MessageItemSetReturnKeyDisable*>(message);
1084 m_impl->signal_set_return_key_disable (this, subclass->get_disabled_ref());
1087 case ISM_TRANS_CMD_GET_RETURN_KEY_DISABLE:
1089 uint32 disabled = 0;
1090 m_impl->signal_get_return_key_type (this, disabled);
1091 m_impl->send.clear ();
1092 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1093 m_impl->send.put_data (disabled);
1094 m_impl->send.write_to_socket (m_impl->socket);
1097 case SCIM_TRANS_CMD_PROCESS_KEY_EVENT:
1099 MessageItemProcessKeyEvent *subclass = static_cast<MessageItemProcessKeyEvent*>(message);
1101 m_impl->signal_process_key_event(this, subclass->get_key_ref(), ret);
1103 if (!m_impl->si.null ())
1105 ret = m_impl->si->process_key_event (subclass->get_key_ref());
1106 LOGD("imengine(%s) process key %d return %d", m_impl->si->get_factory_uuid().c_str(),
1107 subclass->get_key_ref().code, ret);
1109 m_impl->process_key_event_done (subclass->get_key_ref(), ret, subclass->get_serial_ref());
1112 case ISM_TRANS_CMD_SET_LAYOUT:
1114 MessageItemSetLayout *subclass = static_cast<MessageItemSetLayout*>(message);
1115 m_impl->layout = subclass->get_layout_ref();
1116 m_impl->signal_set_layout (this, subclass->get_layout_ref());
1117 if (!m_impl->si.null ()) m_impl->si->set_layout(subclass->get_layout_ref());
1120 case ISM_TRANS_CMD_GET_LAYOUT:
1124 m_impl->signal_get_layout (this, layout);
1125 m_impl->send.clear ();
1126 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1127 m_impl->send.put_data (layout);
1128 m_impl->send.write_to_socket (m_impl->socket);
1131 case ISM_TRANS_CMD_SET_INPUT_MODE:
1133 MessageItemSetInputMode *subclass = static_cast<MessageItemSetInputMode*>(message);
1134 m_impl->signal_set_input_mode (this, subclass->get_input_mode_ref());
1137 case ISM_TRANS_CMD_SET_CAPS_MODE:
1139 MessageItemSetCapsMode *subclass = static_cast<MessageItemSetCapsMode*>(message);
1140 m_impl->signal_set_caps_mode (this, subclass->get_mode_ref());
1143 case SCIM_TRANS_CMD_PANEL_RESET_INPUT_CONTEXT:
1145 MessageItemPanelResetInputContext *subclass = static_cast<MessageItemPanelResetInputContext*>(message);
1146 m_impl->signal_reset_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1147 if (!m_impl->si.null ()) m_impl->si->reset();
1150 case ISM_TRANS_CMD_UPDATE_CANDIDATE_UI:
1152 MessageItemUpdateCandidateUI *subclass = static_cast<MessageItemUpdateCandidateUI*>(message);
1153 m_impl->signal_update_candidate_ui (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1154 subclass->get_style_ref(), subclass->get_mode_ref());
1157 case ISM_TRANS_CMD_UPDATE_CANDIDATE_GEOMETRY:
1159 MessageItemUpdateCandidateGeometry *subclass = static_cast<MessageItemUpdateCandidateGeometry*>(message);
1160 m_impl->signal_update_candidate_geometry (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1161 subclass->get_rectinfo_ref());
1164 case ISM_TRANS_CMD_UPDATE_KEYBOARD_ISE:
1166 MessageItemUpdateKeyboardISE *subclass = static_cast<MessageItemUpdateKeyboardISE*>(message);
1167 m_impl->signal_update_keyboard_ise (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1168 subclass->get_name_ref(), subclass->get_uuid_ref());
1171 case ISM_TRANS_CMD_UPDATE_KEYBOARD_ISE_LIST:
1173 MessageItemUpdateKeyboardISEList *subclass = static_cast<MessageItemUpdateKeyboardISEList*>(message);
1174 m_impl->signal_update_keyboard_ise_list (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1175 subclass->get_list_ref());
1178 case ISM_TRANS_CMD_CANDIDATE_MORE_WINDOW_SHOW:
1180 MessageItemCandidateMoreWindowShow *subclass = static_cast<MessageItemCandidateMoreWindowShow*>(message);
1181 m_impl->signal_candidate_more_window_show (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1182 if (!m_impl->si.null ()) m_impl->si->candidate_more_window_show();
1185 case ISM_TRANS_CMD_CANDIDATE_MORE_WINDOW_HIDE:
1187 MessageItemCandidateMoreWindowHide *subclass = static_cast<MessageItemCandidateMoreWindowHide*>(message);
1188 m_impl->signal_candidate_more_window_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1189 if (!m_impl->si.null ()) m_impl->si->candidate_more_window_hide();
1192 case ISM_TRANS_CMD_SELECT_AUX:
1194 MessageItemSelectAux *subclass = static_cast<MessageItemSelectAux*>(message);
1195 m_impl->signal_select_aux (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1196 subclass->get_item_ref());
1197 if (!m_impl->si.null ()) m_impl->si->select_aux(subclass->get_item_ref());
1200 case SCIM_TRANS_CMD_SELECT_CANDIDATE: //FIXME:remove if useless
1202 MessageItemSelectCandidate *subclass = static_cast<MessageItemSelectCandidate*>(message);
1203 m_impl->signal_select_candidate (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1204 subclass->get_item_ref());
1205 if (!m_impl->si.null ()) m_impl->si->select_candidate(subclass->get_item_ref());
1208 case SCIM_TRANS_CMD_LOOKUP_TABLE_PAGE_UP: //FIXME:remove if useless
1210 MessageItemLookupTablePageUp *subclass = static_cast<MessageItemLookupTablePageUp*>(message);
1211 m_impl->signal_candidate_table_page_up (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1212 if (!m_impl->si.null ()) m_impl->si->lookup_table_page_up();
1215 case SCIM_TRANS_CMD_LOOKUP_TABLE_PAGE_DOWN: //FIXME:remove if useless
1217 MessageItemLookupTablePageDown *subclass = static_cast<MessageItemLookupTablePageDown*>(message);
1218 m_impl->signal_candidate_table_page_down (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1219 if (!m_impl->si.null ()) m_impl->si->lookup_table_page_down();
1222 case SCIM_TRANS_CMD_UPDATE_LOOKUP_TABLE_PAGE_SIZE:
1224 MessageItemUpdateLookupTablePageSize *subclass = static_cast<MessageItemUpdateLookupTablePageSize*>(message);
1225 m_impl->signal_update_candidate_table_page_size (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1226 subclass->get_size_ref());
1227 if (!m_impl->si.null ()) m_impl->si->update_lookup_table_page_size(subclass->get_size_ref());
1230 case ISM_TRANS_CMD_CANDIDATE_SHOW: //FIXME:remove if useless
1232 MessageItemCandidateShow *subclass = static_cast<MessageItemCandidateShow*>(message);
1233 m_impl->signal_candidate_show (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1236 case ISM_TRANS_CMD_CANDIDATE_HIDE: //FIXME:remove if useless
1238 MessageItemCandidateHide *subclass = static_cast<MessageItemCandidateHide*>(message);
1239 m_impl->signal_candidate_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1242 case ISM_TRANS_CMD_UPDATE_LOOKUP_TABLE: //FIXME:remove if useless
1244 MessageItemUpdateLookupTable *subclass = static_cast<MessageItemUpdateLookupTable*>(message);
1245 m_impl->signal_update_lookup_table (this, subclass->get_candidate_table_ref());
1248 case ISM_TRANS_CMD_UPDATE_CANDIDATE_ITEM_LAYOUT:
1250 MessageItemUpdateCandidateItemLayout *subclass = static_cast<MessageItemUpdateCandidateItemLayout*>(message);
1251 m_impl->signal_update_candidate_item_layout (this, subclass->get_row_items_ref());
1252 if (!m_impl->si.null ()) m_impl->si->update_candidate_item_layout(subclass->get_row_items_ref());
1255 case ISM_TRANS_CMD_SELECT_ASSOCIATE:
1257 MessageItemSelectAssociate *subclass = static_cast<MessageItemSelectAssociate*>(message);
1258 m_impl->signal_select_associate (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1259 subclass->get_item_ref());
1262 case ISM_TRANS_CMD_ASSOCIATE_TABLE_PAGE_UP:
1264 MessageItemAssociateTablePageUp *subclass = static_cast<MessageItemAssociateTablePageUp*>(message);
1265 m_impl->signal_associate_table_page_up (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1268 case ISM_TRANS_CMD_ASSOCIATE_TABLE_PAGE_DOWN:
1270 MessageItemAssociateTablePageDown *subclass = static_cast<MessageItemAssociateTablePageDown*>(message);
1271 m_impl->signal_associate_table_page_down (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1274 case ISM_TRANS_CMD_UPDATE_ASSOCIATE_TABLE_PAGE_SIZE:
1276 MessageItemUpdateAssociateTablePageSize *subclass = static_cast<MessageItemUpdateAssociateTablePageSize*>(message);
1277 m_impl->signal_update_associate_table_page_size (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1278 subclass->get_size_ref());
1281 case ISM_TRANS_CMD_RESET_ISE_CONTEXT:
1283 MessageItemResetISEContext *subclass = static_cast<MessageItemResetISEContext*>(message);
1284 m_impl->signal_reset_ise_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1285 m_impl->signal_reset_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1286 if (!m_impl->si.null ()) m_impl->si->reset();
1289 case ISM_TRANS_CMD_TURN_ON_LOG:
1291 MessageItemTurnOnLog *subclass = static_cast<MessageItemTurnOnLog*>(message);
1292 m_impl->signal_turn_on_log (this, subclass->get_state_ref());
1295 case ISM_TRANS_CMD_UPDATE_DISPLAYED_CANDIDATE:
1297 MessageItemUpdateDisplayedCandidate *subclass = static_cast<MessageItemUpdateDisplayedCandidate*>(message);
1298 m_impl->signal_update_displayed_candidate_number (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1299 subclass->get_size_ref());
1300 if (!m_impl->si.null ()) m_impl->si->update_displayed_candidate_number(subclass->get_size_ref());
1303 case ISM_TRANS_CMD_LONGPRESS_CANDIDATE:
1305 MessageItemLongpressCandidate *subclass = static_cast<MessageItemLongpressCandidate*>(message);
1306 m_impl->signal_longpress_candidate (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1307 subclass->get_index_ref());
1308 if (!m_impl->si.null ()) m_impl->si->longpress_candidate(subclass->get_index_ref());
1311 case ISM_TRANS_CMD_SET_INPUT_HINT:
1313 MessageItemSetInputHint *subclass = static_cast<MessageItemSetInputHint*>(message);
1314 m_impl->signal_set_input_hint (this, subclass->get_input_hint_ref());
1315 if (!m_impl->si.null ()) m_impl->si->set_input_hint(subclass->get_input_hint_ref());
1318 case ISM_TRANS_CMD_UPDATE_BIDI_DIRECTION:
1320 MessageItemUpdateBidiDirection *subclass = static_cast<MessageItemUpdateBidiDirection*>(message);
1321 m_impl->signal_update_bidi_direction (this, subclass->get_bidi_direction());
1322 if (!m_impl->si.null ()) m_impl->si->update_bidi_direction(subclass->get_bidi_direction());
1325 case ISM_TRANS_CMD_SHOW_ISE_OPTION_WINDOW:
1327 MessageItemShowISEOptionWindow *subclass = static_cast<MessageItemShowISEOptionWindow*>(message);
1328 m_impl->signal_show_option_window (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1331 case ISM_TRANS_CMD_CHECK_OPTION_WINDOW:
1334 m_impl->signal_check_option_window (this, avail);
1335 m_impl->send.clear ();
1336 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1337 m_impl->send.put_data (avail);
1338 m_impl->send.write_to_socket (m_impl->socket);
1341 case ISM_TRANS_CMD_PROCESS_INPUT_DEVICE_EVENT:
1343 MessageItemProcessInputDeviceEvent *subclass = static_cast<MessageItemProcessInputDeviceEvent*>(message);
1345 m_impl->signal_process_input_device_event(this,
1346 subclass->get_type_ref(), *(subclass->get_data_ptr()), subclass->get_len_ref(), ret);
1347 m_impl->send.clear();
1348 m_impl->send.put_command(SCIM_TRANS_CMD_REPLY);
1349 m_impl->send.put_data(ret);
1350 m_impl->send.write_to_socket(m_impl->socket);
1353 case SCIM_TRANS_CMD_SET_AUTOCAPITAL_TYPE:
1355 MessageItemSetAutocapitalType *subclass = static_cast<MessageItemSetAutocapitalType*>(message);
1356 if (!m_impl->si.null ()) m_impl->si->set_autocapital_type(subclass->get_auto_capital_type_ref());
1359 case ISM_TRANS_CMD_SET_PREDICTION_ALLOW:
1361 MessageItemSetPredictionAllow *subclass = static_cast<MessageItemSetPredictionAllow*>(message);
1362 if (!m_impl->si.null ()) m_impl->si->set_prediction_allow(subclass->get_prediction_allow_ref() == 0 ? false : true);
1372 * @brief Request SCIM to reload all configuration.
1374 * This function should only by used by Setup Helper to request
1375 * scim's reloading the configuration.
1376 * Deprecated: reload config message only send by socketconfig client
1377 * using socketconfig::reload instead.
1380 HelperAgent::reload_config () const
1382 LOGD ("send reload config message to isf");
1383 if (!m_impl->m_config.null())
1384 m_impl->m_config->reload();
1388 * @brief Register some properties into Panel.
1390 * This function send the request to Panel to register a list
1393 * @param properties The list of Properties to be registered into Panel.
1395 * @sa scim::Property.
1398 HelperAgent::register_properties (const PropertyList &properties) const
1401 if (m_impl->socket_active.is_connected ()) {
1402 m_impl->send.clear ();
1403 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1404 m_impl->send.put_data (m_impl->magic_active);
1405 m_impl->send.put_command (SCIM_TRANS_CMD_REGISTER_PROPERTIES);
1406 m_impl->send.put_data (properties);
1407 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1412 * @brief Update a registered property.
1414 * @param property The property to be updated.
1417 HelperAgent::update_property (const Property &property) const
1420 if (m_impl->socket_active.is_connected ()) {
1421 m_impl->send.clear ();
1422 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1423 m_impl->send.put_data (m_impl->magic_active);
1424 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PROPERTY);
1425 m_impl->send.put_data (property);
1426 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1431 * @brief Send a set of events to an IMEngineInstance.
1433 * All events should be put into a Transaction.
1434 * And the events can only be received by one IMEngineInstance object.
1436 * @param ic The handle of the Input Context to receive the events.
1437 * @param ic_uuid The UUID of the Input Context.
1438 * @param trans The Transaction object holds the events.
1441 HelperAgent::send_imengine_event (int ic,
1442 const String &ic_uuid,
1443 const Transaction &trans) const
1446 //remove if not necessary
1448 if (m_impl->socket_active.is_connected ()) {
1449 m_impl->send.clear ();
1450 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1451 m_impl->send.put_data (m_impl->magic_active);
1452 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_SEND_IMENGINE_EVENT);
1453 m_impl->send.put_data ((uint32)ic);
1454 m_impl->send.put_data (ic_uuid);
1455 m_impl->send.put_data (trans);
1456 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1459 if (!m_impl->si.null ()) m_impl->si->process_helper_event (ic_uuid, trans);
1463 * @brief Send a KeyEvent to an IMEngineInstance.
1465 * @param ic The handle of the IMEngineInstance to receive the event.
1466 * -1 means the currently focused IMEngineInstance.
1467 * @param ic_uuid The UUID of the IMEngineInstance. Empty means don't match.
1468 * @param key The KeyEvent to be sent.
1471 HelperAgent::send_key_event (int ic,
1472 const String &ic_uuid,
1473 const KeyEvent &key) const
1477 //FIXME: remove shift_mode_off, shift_mode_on, shift_mode_lock from ISE side
1478 if (key.code == SHIFT_MODE_OFF ||
1479 key.code == SHIFT_MODE_ON ||
1480 key.code == SHIFT_MODE_LOCK ||
1481 key.code == SHIFT_MODE_ENABLE ||
1482 key.code == SHIFT_MODE_DISABLE) {
1483 LOGW("FIXME ignore shift codes");
1489 #if ENABLE_GRAB_KEYBOARD
1490 if (!m_impl->si.null ()) {
1492 if (key.code <= 0x7F ||
1493 (key.code >= SCIM_KEY_BackSpace && key.code <= SCIM_KEY_Delete) ||
1494 (key.code >= SCIM_KEY_Home && key.code <= SCIM_KEY_Hyper_R)) {
1495 // ascii code and function keys
1501 if (ret && (!m_impl->si.null ())) {
1503 ret = m_impl->si->process_key_event (key);
1504 LOGD ("imengine(%s) process key %d return %d", m_impl->si->get_factory_uuid().c_str(), key.code, ret);
1507 if (ret == false && m_impl->socket_active.is_connected ()) {
1508 m_impl->send.clear ();
1509 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1510 m_impl->send.put_data (m_impl->magic_active);
1511 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_SEND_KEY_EVENT);
1513 m_impl->send.put_data (m_impl->focused_ic);
1515 m_impl->send.put_data ((uint32)ic);
1517 m_impl->send.put_data (ic_uuid);
1518 m_impl->send.put_data (key);
1519 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1524 * @brief Forward a KeyEvent to client application directly.
1526 * @param ic The handle of the client Input Context to receive the event.
1527 * -1 means the currently focused Input Context.
1528 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1529 * Empty means don't match.
1530 * @param key The KeyEvent to be forwarded.
1533 HelperAgent::forward_key_event (int ic,
1534 const String &ic_uuid,
1535 const KeyEvent &key) const
1538 if (m_impl->socket_active.is_connected ()) {
1539 m_impl->send.clear ();
1540 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1541 m_impl->send.put_data (m_impl->magic_active);
1542 m_impl->send.put_command (SCIM_TRANS_CMD_FORWARD_KEY_EVENT);
1544 m_impl->send.put_data (m_impl->focused_ic);
1546 m_impl->send.put_data ((uint32)ic);
1548 m_impl->send.put_data (ic_uuid);
1549 m_impl->send.put_data (key);
1550 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1555 * @brief Commit a WideString to client application directly.
1557 * @param ic The handle of the client Input Context to receive the WideString.
1558 * -1 means the currently focused Input Context.
1559 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1560 * Empty means don't match.
1561 * @param wstr The WideString to be committed.
1564 HelperAgent::commit_string (int ic,
1565 const String &ic_uuid,
1566 const WideString &wstr) const
1569 if (m_impl->socket_active.is_connected ()) {
1570 m_impl->send.clear ();
1571 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1572 m_impl->send.put_data (m_impl->magic_active);
1573 m_impl->send.put_command (SCIM_TRANS_CMD_COMMIT_STRING);
1575 m_impl->send.put_data (m_impl->focused_ic);
1577 m_impl->send.put_data ((uint32)ic);
1579 m_impl->send.put_data (ic_uuid);
1580 m_impl->send.put_data (wstr);
1581 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1586 HelperAgent::commit_string (int ic,
1587 const String &ic_uuid,
1592 if (m_impl->socket_active.is_connected ()) {
1593 m_impl->send.clear ();
1594 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1595 m_impl->send.put_data (m_impl->magic_active);
1596 m_impl->send.put_command (SCIM_TRANS_CMD_COMMIT_STRING);
1598 m_impl->send.put_data (m_impl->focused_ic);
1600 m_impl->send.put_data ((uint32)ic);
1602 m_impl->send.put_data (ic_uuid);
1603 m_impl->send.put_dataw (buf, buflen);
1604 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1609 * @brief Request to show preedit string.
1611 * @param ic The handle of the client Input Context to receive the request.
1612 * -1 means the currently focused Input Context.
1613 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1614 * Empty means don't match.
1617 HelperAgent::show_preedit_string (int ic,
1618 const String &ic_uuid) const
1622 if (m_impl->socket_active.is_connected ()) {
1623 m_impl->send.clear ();
1624 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1625 m_impl->send.put_data (m_impl->magic_active);
1626 m_impl->send.put_command (SCIM_TRANS_CMD_SHOW_PREEDIT_STRING);
1627 m_impl->send.put_data ((uint32)ic);
1628 m_impl->send.put_data (ic_uuid);
1629 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1634 * @brief Request to show aux string.
1637 HelperAgent::show_aux_string (void) const
1641 if (m_impl->socket_active.is_connected ()) {
1642 m_impl->send.clear ();
1643 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1644 m_impl->send.put_data (m_impl->magic_active);
1645 m_impl->send.put_command (SCIM_TRANS_CMD_SHOW_AUX_STRING);
1646 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1651 * @brief Request to show candidate string.
1654 HelperAgent::show_candidate_string (void) const
1658 if (m_impl->socket_active.is_connected ()) {
1659 m_impl->send.clear ();
1660 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1661 m_impl->send.put_data (m_impl->magic_active);
1662 m_impl->send.put_command (SCIM_TRANS_CMD_SHOW_LOOKUP_TABLE);
1663 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1668 * @brief Request to show associate string.
1671 HelperAgent::show_associate_string (void) const
1674 if (m_impl->socket_active.is_connected ()) {
1675 m_impl->send.clear ();
1676 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1677 m_impl->send.put_data (m_impl->magic_active);
1678 m_impl->send.put_command (ISM_TRANS_CMD_SHOW_ASSOCIATE_TABLE);
1679 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1684 * @brief Request to hide preedit string.
1686 * @param ic The handle of the client Input Context to receive the request.
1687 * -1 means the currently focused Input Context.
1688 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1689 * Empty means don't match.
1692 HelperAgent::hide_preedit_string (int ic,
1693 const String &ic_uuid) const
1697 if (m_impl->socket_active.is_connected ()) {
1698 m_impl->send.clear ();
1699 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1700 m_impl->send.put_data (m_impl->magic_active);
1701 m_impl->send.put_command (SCIM_TRANS_CMD_HIDE_PREEDIT_STRING);
1702 m_impl->send.put_data ((uint32)ic);
1703 m_impl->send.put_data (ic_uuid);
1704 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1709 * @brief Request to hide aux string.
1712 HelperAgent::hide_aux_string (void) const
1715 if (m_impl->socket_active.is_connected ()) {
1716 m_impl->send.clear ();
1717 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1718 m_impl->send.put_data (m_impl->magic_active);
1719 m_impl->send.put_command (SCIM_TRANS_CMD_HIDE_AUX_STRING);
1720 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1725 * @brief Request to hide candidate string.
1728 HelperAgent::hide_candidate_string (void) const
1731 if (m_impl->socket_active.is_connected ()) {
1732 m_impl->send.clear ();
1733 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1734 m_impl->send.put_data (m_impl->magic_active);
1735 m_impl->send.put_command (SCIM_TRANS_CMD_HIDE_LOOKUP_TABLE);
1736 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1741 * @brief Request to hide associate string.
1744 HelperAgent::hide_associate_string (void) const
1747 if (m_impl->socket_active.is_connected ()) {
1748 m_impl->send.clear ();
1749 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1750 m_impl->send.put_data (m_impl->magic_active);
1751 m_impl->send.put_command (ISM_TRANS_CMD_HIDE_ASSOCIATE_TABLE);
1752 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1757 * @brief Update a new WideString for preedit.
1759 * @param ic The handle of the client Input Context to receive the WideString.
1760 * -1 means the currently focused Input Context.
1761 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1762 * Empty means don't match.
1763 * @param str The WideString to be updated.
1764 * @param attrs The attribute list for preedit string.
1767 HelperAgent::update_preedit_string (int ic,
1768 const String &ic_uuid,
1769 const WideString &str,
1770 const AttributeList &attrs) const
1773 update_preedit_string (ic, ic_uuid, str, str, attrs, -1);
1777 HelperAgent::update_preedit_string (int ic,
1778 const String &ic_uuid,
1781 const AttributeList &attrs) const
1784 update_preedit_string (ic, ic_uuid, buf, buflen, attrs, -1);
1788 * @brief Update a new WideString for preedit.
1790 * @param ic The handle of the client Input Context to receive the WideString.
1791 * -1 means the currently focused Input Context.
1792 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1793 * Empty means don't match.
1794 * @param str The WideString to be updated.
1795 * @param attrs The attribute list for preedit string.
1796 * @param caret The caret position in preedit string.
1799 HelperAgent::update_preedit_string (int ic,
1800 const String &ic_uuid,
1801 const WideString &wstr,
1802 const AttributeList &attrs,
1806 update_preedit_string (ic, ic_uuid, wstr, wstr, attrs, caret);
1810 HelperAgent::update_preedit_string (int ic,
1811 const String &ic_uuid,
1814 const AttributeList &attrs,
1819 if (m_impl->socket_active.is_connected ()) {
1820 m_impl->send.clear ();
1821 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1822 m_impl->send.put_data (m_impl->magic_active);
1823 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING);
1824 m_impl->send.put_data ((uint32)ic);
1825 m_impl->send.put_data (ic_uuid);
1826 m_impl->send.put_dataw (buf, buflen);
1827 m_impl->send.put_dataw (buf, buflen);
1828 m_impl->send.put_data (attrs);
1829 m_impl->send.put_data (caret);
1830 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1835 HelperAgent::update_preedit_string (int ic,
1836 const String &ic_uuid,
1837 const WideString &preedit,
1838 const WideString &commit,
1839 const AttributeList &attrs,
1843 if (m_impl->socket_active.is_connected ()) {
1844 m_impl->send.clear ();
1845 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1846 m_impl->send.put_data (m_impl->magic_active);
1847 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING);
1848 m_impl->send.put_data ((uint32)ic);
1849 m_impl->send.put_data (ic_uuid);
1850 m_impl->send.put_data (preedit);
1851 m_impl->send.put_data (commit);
1852 m_impl->send.put_data (attrs);
1853 m_impl->send.put_data (caret);
1854 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1859 * @brief Update the preedit caret position in the preedit string.
1861 * @param caret - the new position of the preedit caret.
1864 HelperAgent::update_preedit_caret (int caret) const
1868 if (m_impl->socket_active.is_connected ()) {
1869 m_impl->send.clear ();
1870 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1871 m_impl->send.put_data (m_impl->magic_active);
1872 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_CARET);
1873 m_impl->send.put_data ((uint32)caret);
1874 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1879 * @brief Update a new string for aux.
1881 * @param str The string to be updated.
1882 * @param attrs The attribute list for aux string.
1885 HelperAgent::update_aux_string (const String &str,
1886 const AttributeList &attrs) const
1889 if (m_impl->socket_active.is_connected ()) {
1890 m_impl->send.clear ();
1891 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1892 m_impl->send.put_data (m_impl->magic_active);
1893 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_AUX_STRING);
1894 m_impl->send.put_data (str);
1895 m_impl->send.put_data (attrs);
1896 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1901 * @brief Request to update candidate.
1903 * @param table The lookup table for candidate.
1906 HelperAgent::update_candidate_string (const LookupTable &table) const
1909 if (m_impl->socket_active.is_connected ()) {
1910 m_impl->send.clear ();
1911 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1912 m_impl->send.put_data (m_impl->magic_active);
1913 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_LOOKUP_TABLE);
1914 m_impl->send.put_data (table);
1915 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1920 * @brief Request to update associate.
1922 * @param table The lookup table for associate.
1925 HelperAgent::update_associate_string (const LookupTable &table) const
1928 if (m_impl->socket_active.is_connected ()) {
1929 m_impl->send.clear ();
1930 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1931 m_impl->send.put_data (m_impl->magic_active);
1932 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ASSOCIATE_TABLE);
1933 m_impl->send.put_data (table);
1934 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1939 * @brief When the input context of ISE is changed,
1940 * ISE can call this function to notify application
1942 * @param type type of event.
1943 * @param value value of event.
1946 HelperAgent::update_input_context (uint32 type, uint32 value) const
1949 if (m_impl->socket_active.is_connected ()) {
1950 m_impl->send.clear ();
1951 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1952 m_impl->send.put_data (m_impl->magic_active);
1953 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ISE_INPUT_CONTEXT);
1954 m_impl->send.put_data (type);
1955 m_impl->send.put_data (value);
1956 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1961 * @brief Request to get surrounding text asynchronously.
1963 * @param uuid The helper ISE UUID.
1964 * @param maxlen_before The max length of before.
1965 * @param maxlen_after The max length of after.
1968 HelperAgent::get_surrounding_text (const String &uuid, int maxlen_before, int maxlen_after) const
1971 if (m_impl->socket_active.is_connected () && (m_impl->need_update_surrounding_text == 0)) {
1972 m_impl->send.clear ();
1973 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1974 m_impl->send.put_data (m_impl->magic_active);
1975 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SURROUNDING_TEXT);
1976 m_impl->send.put_data (uuid);
1977 m_impl->send.put_data (maxlen_before);
1978 m_impl->send.put_data (maxlen_after);
1979 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1981 m_impl->need_update_surrounding_text++;
1985 * @brief Request to get surrounding text synchronously.
1987 * @param uuid The helper ISE UUID.
1988 * @param maxlen_before The max length of before.
1989 * @param maxlen_after The max length of after.
1990 * @param text The surrounding text.
1991 * @param cursor The cursor position.
1994 HelperAgent::get_surrounding_text (int maxlen_before, int maxlen_after, String &text, int &cursor)
1998 if (!m_impl->socket_active.is_connected ())
2001 m_impl->send.clear ();
2002 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2003 m_impl->send.put_data (m_impl->magic_active);
2004 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SURROUNDING_TEXT);
2005 m_impl->send.put_data ("");
2006 m_impl->send.put_data (maxlen_before);
2007 m_impl->send.put_data (maxlen_after);
2008 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2009 if (m_impl->surrounding_text) {
2010 free (m_impl->surrounding_text);
2011 m_impl->surrounding_text = NULL;
2014 const int WAIT_FOR_SYNC_RESPONSE_TIMEOUT = 1000;
2015 /* Now we are waiting for the ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT message */
2016 if (wait_for_message(ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT, WAIT_FOR_SYNC_RESPONSE_TIMEOUT)) {
2017 MessageItem *message = message_queue.get_pending_message_by_cmd(ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT);
2018 handle_message(message);
2019 message_queue.remove_message(message);
2021 if (m_impl->surrounding_text) {
2022 text = m_impl->surrounding_text;
2023 cursor = m_impl->cursor_pos;
2027 if (m_impl->surrounding_text) {
2028 free (m_impl->surrounding_text);
2029 m_impl->surrounding_text = NULL;
2034 * @brief Request to delete surrounding text.
2036 * @param offset The offset for cursor position.
2037 * @param len The length for delete text.
2040 HelperAgent::delete_surrounding_text (int offset, int len) const
2042 LOGD ("offset = %d, len = %d", offset, len);
2044 if (m_impl->socket_active.is_connected ()) {
2045 m_impl->send.clear ();
2046 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2047 m_impl->send.put_data (m_impl->magic_active);
2048 m_impl->send.put_command (SCIM_TRANS_CMD_DELETE_SURROUNDING_TEXT);
2049 m_impl->send.put_data (offset);
2050 m_impl->send.put_data (len);
2051 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2056 * @brief Request to get selection text asynchronously.
2058 * @param uuid The helper ISE UUID.
2061 HelperAgent::get_selection (const String &uuid) const
2064 if (m_impl->socket_active.is_connected () && (m_impl->need_update_selection_text == 0)) {
2065 m_impl->send.clear ();
2066 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2067 m_impl->send.put_data (m_impl->magic_active);
2068 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SELECTION);
2069 m_impl->send.put_data (uuid);
2070 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2072 m_impl->need_update_selection_text++;
2076 * @brief Request to get selection text synchronously.
2078 * @param text The selection text.
2081 HelperAgent::get_selection_text (String &text)
2085 if (!m_impl->socket_active.is_connected ())
2088 m_impl->send.clear ();
2089 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2090 m_impl->send.put_data (m_impl->magic_active);
2091 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SELECTION);
2092 m_impl->send.put_data ("");
2093 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2094 if (m_impl->selection_text) {
2095 free (m_impl->selection_text);
2096 m_impl->selection_text = NULL;
2099 const int WAIT_FOR_SYNC_RESPONSE_TIMEOUT = 1000;
2100 /* Now we are waiting for the ISM_TRANS_CMD_UPDATE_SELECTION message */
2101 if (wait_for_message(ISM_TRANS_CMD_UPDATE_SELECTION, WAIT_FOR_SYNC_RESPONSE_TIMEOUT)) {
2102 MessageItem *message = message_queue.get_pending_message_by_cmd(ISM_TRANS_CMD_UPDATE_SELECTION);
2103 handle_message(message);
2104 message_queue.remove_message(message);
2105 if (m_impl->selection_text) {
2106 text = m_impl->selection_text;
2110 if (m_impl->selection_text) {
2111 free (m_impl->selection_text);
2112 m_impl->selection_text = NULL;
2117 * @brief Request to select text.
2119 * @param start The start position in text.
2120 * @param end The end position in text.
2123 HelperAgent::set_selection (int start, int end) const
2126 if (m_impl->socket_active.is_connected ()) {
2127 m_impl->send.clear ();
2128 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2129 m_impl->send.put_data (m_impl->magic_active);
2130 m_impl->send.put_command (SCIM_TRANS_CMD_SET_SELECTION);
2131 m_impl->send.put_data (start);
2132 m_impl->send.put_data (end);
2133 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2138 * @brief Send a private command to an application.
2140 * @param command The private command sent from IME.
2143 HelperAgent::send_private_command (const String &command) const
2146 if (m_impl->socket_active.is_connected ()) {
2147 m_impl->send.clear ();
2148 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2149 m_impl->send.put_data (m_impl->magic_active);
2150 m_impl->send.put_command (SCIM_TRANS_CMD_SEND_PRIVATE_COMMAND);
2151 m_impl->send.put_data (command);
2152 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2157 * @brief Request to get uuid list of all keyboard ISEs.
2159 * @param uuid The helper ISE UUID.
2162 HelperAgent::get_keyboard_ise_list (const String &uuid) const
2165 if (m_impl->socket_active.is_connected ()) {
2166 m_impl->send.clear ();
2167 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2168 m_impl->send.put_data (m_impl->magic_active);
2169 m_impl->send.put_command (ISM_TRANS_CMD_GET_KEYBOARD_ISE_LIST);
2170 m_impl->send.put_data (uuid);
2171 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2176 * @brief Set candidate position in screen.
2178 * @param left The x position in screen.
2179 * @param top The y position in screen.
2182 HelperAgent::set_candidate_position (int left, int top) const
2185 if (m_impl->socket_active.is_connected ()) {
2186 m_impl->send.clear ();
2187 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2188 m_impl->send.put_data (m_impl->magic_active);
2189 m_impl->send.put_command (ISM_TRANS_CMD_SET_CANDIDATE_POSITION);
2190 m_impl->send.put_data (left);
2191 m_impl->send.put_data (top);
2192 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2197 * @brief Set candidate style.
2199 * @param portrait_line - the displayed line number for portrait mode.
2200 * @param mode - candidate window mode.
2203 HelperAgent::set_candidate_style (ISF_CANDIDATE_PORTRAIT_LINE_T portrait_line,
2204 ISF_CANDIDATE_MODE_T mode) const
2207 if (m_impl->socket_active.is_connected ()) {
2208 m_impl->send.clear ();
2209 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2210 m_impl->send.put_data (m_impl->magic_active);
2211 m_impl->send.put_command (ISM_TRANS_CMD_SET_CANDIDATE_UI);
2212 m_impl->send.put_data (portrait_line);
2213 m_impl->send.put_data (mode);
2214 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2219 * @brief Request to hide candidate window.
2222 HelperAgent::candidate_hide (void) const
2225 if (m_impl->socket_active.is_connected ()) {
2226 m_impl->send.clear ();
2227 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2228 m_impl->send.put_data (m_impl->magic_active);
2229 m_impl->send.put_command (ISM_TRANS_CMD_HIDE_CANDIDATE);
2230 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2235 * @brief Request to get candidate window size and position.
2237 * @param uuid The helper ISE UUID.
2240 HelperAgent::get_candidate_window_geometry (const String &uuid) const
2243 if (m_impl->socket_active.is_connected ()) {
2244 m_impl->send.clear ();
2245 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2246 m_impl->send.put_data (m_impl->magic_active);
2247 m_impl->send.put_command (ISM_TRANS_CMD_GET_CANDIDATE_GEOMETRY);
2248 m_impl->send.put_data (uuid);
2249 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2254 * @brief Set current keyboard ISE.
2256 * @param uuid The keyboard ISE UUID.
2259 HelperAgent::set_keyboard_ise_by_uuid (const String &uuid) const
2263 IMEngineFactoryPointer factory;
2264 IMEngineModule *engine_module = NULL;
2265 static int instance_count = 1;
2267 if ((!m_impl->si.null ()) && m_impl->si->get_factory_uuid () == uuid) {
2268 LOGD ("Already in UUID: %s\n", uuid.c_str());
2272 if (!m_impl->si.null()) {
2273 m_impl->si->focus_out();
2277 if (m_impl->m_config.null ()) {
2278 LOGW ("config is not working");
2282 #ifdef HAVE_PKGMGR_INFO
2285 pkgmgrinfo_appinfo_h handle;
2286 ret = pkgmgrinfo_appinfo_get_appinfo(uuid.c_str(), &handle);
2287 if (ret != PMINFO_R_OK) {
2288 LOGW("Retrieve app info failed : %s", uuid.c_str ());
2292 ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
2293 if (ret != PMINFO_R_OK) {
2294 LOGW("Retrieve pkgid failed : %s, %p", uuid.c_str(), handle);
2295 pkgmgrinfo_appinfo_destroy_appinfo(handle);
2299 imeInfo.module_name = pkgid;
2300 pkgmgrinfo_appinfo_destroy_appinfo(handle);
2302 if (isf_db_select_ime_info_by_appid(uuid.c_str(), &imeInfo) < 1) {
2303 LOGW("ime_info row is not available for %s", uuid.c_str());
2308 engine_module = &m_impl->engine_module;
2310 if (engine_module->valid() && imeInfo.module_name != engine_module->get_module_name()) {
2311 LOGD ("imengine module %s unloaded", engine_module->get_module_name().c_str());
2312 engine_module->unload();
2315 if (!engine_module->valid()) {
2316 if (engine_module->load (imeInfo.module_name, m_impl->m_config) == false) {
2317 LOGW ("load module %s failed", imeInfo.module_name.c_str());
2320 LOGD ("imengine module %s loaded", imeInfo.module_name.c_str());
2323 for (size_t j = 0; j < engine_module->number_of_factories (); ++j) {
2326 factory = engine_module->create_factory (j);
2327 if (factory.null () == false && factory->get_uuid () == uuid)
2335 if (factory.null()) {
2336 LOGW ("imengine uuid %s is not found", uuid.c_str());
2340 m_impl->si = factory->create_instance ("UTF-8", instance_count++);
2341 if (m_impl->si.null ()) {
2342 LOGE ("create_instance %s failed",uuid.c_str ());
2346 m_impl->attach_instance ();
2347 LOGD ("Require UUID: %s Current UUID: %s", uuid.c_str (), m_impl->si->get_factory_uuid ().c_str ());
2348 m_impl->si->set_layout (m_impl->layout);
2349 if(m_impl->focused_ic != (uint32)-1)
2350 m_impl->si->focus_in ();
2354 * @brief Request to get current keyboard ISE information.
2356 * @param uuid The helper ISE UUID.
2359 HelperAgent::get_keyboard_ise (const String &uuid) const
2362 //FIXME: maybe useless
2364 if (m_impl->socket_active.is_connected ()) {
2365 m_impl->send.clear ();
2366 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2367 m_impl->send.put_data (m_impl->magic_active);
2368 m_impl->send.put_command (ISM_TRANS_CMD_GET_KEYBOARD_ISE);
2369 m_impl->send.put_data (uuid);
2370 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2376 * @brief Update ISE window geometry.
2378 * @param x The x position in screen.
2379 * @param y The y position in screen.
2380 * @param width The ISE window width.
2381 * @param height The ISE window height.
2384 HelperAgent::update_geometry (int x, int y, int width, int height) const
2387 if (m_impl->socket_active.is_connected ()) {
2388 m_impl->send.clear ();
2389 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2390 m_impl->send.put_data (m_impl->magic_active);
2391 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ISE_GEOMETRY);
2392 m_impl->send.put_data (x);
2393 m_impl->send.put_data (y);
2394 m_impl->send.put_data (width);
2395 m_impl->send.put_data (height);
2396 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2401 * @brief Request to expand candidate window.
2404 HelperAgent::expand_candidate (void) const
2407 if (m_impl->socket_active.is_connected ()) {
2408 m_impl->send.clear ();
2409 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2410 m_impl->send.put_data (m_impl->magic_active);
2411 m_impl->send.put_command (ISM_TRANS_CMD_EXPAND_CANDIDATE);
2412 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2417 * @brief Request to contract candidate window.
2420 HelperAgent::contract_candidate (void) const
2423 if (m_impl->socket_active.is_connected ()) {
2424 m_impl->send.clear ();
2425 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2426 m_impl->send.put_data (m_impl->magic_active);
2427 m_impl->send.put_command (ISM_TRANS_CMD_CONTRACT_CANDIDATE);
2428 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2433 * @brief Send selected candidate string index number.
2436 HelperAgent::select_candidate (int index) const
2439 if (!m_impl->si.null ())
2440 m_impl->si->select_candidate (index);
2441 //FIXME: maybe useless
2444 if (m_impl->socket_active.is_connected ()) {
2445 m_impl->send.clear ();
2446 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2447 m_impl->send.put_data (m_impl->magic_active);
2448 m_impl->send.put_command (ISM_TRANS_CMD_SELECT_CANDIDATE);
2449 m_impl->send.put_data (index);
2450 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2456 * @brief Update our ISE is exiting.
2459 HelperAgent::update_ise_exit (void) const
2462 //FIXME: maybe useless
2464 if (m_impl->socket_active.is_connected ()) {
2465 m_impl->send.clear ();
2466 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2467 m_impl->send.put_data (m_impl->magic_active);
2468 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ISE_EXIT);
2469 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2475 * @brief Request to reset keyboard ISE.
2478 HelperAgent::reset_keyboard_ise (void) const
2481 //FIXME: maybe useless
2483 if (m_impl->socket_active.is_connected ()) {
2484 m_impl->send.clear ();
2485 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2486 m_impl->send.put_data (m_impl->magic_active);
2487 m_impl->send.put_command (ISM_TRANS_CMD_PANEL_RESET_KEYBOARD_ISE);
2488 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2491 if (!m_impl->si.null ()) {
2492 m_impl->si->reset ();
2497 * @brief Request to flush keyboard ISE.
2500 HelperAgent::flush_keyboard_ise (void) const
2503 if (!m_impl->si.null ()) {
2504 m_impl->si->flush ();
2509 * @brief Request panel to hide ISE.
2512 HelperAgent::request_ise_hide (void) const
2515 if (m_impl->socket_active.is_connected ()) {
2516 m_impl->send.clear ();
2517 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2518 m_impl->send.put_data (m_impl->magic_active);
2519 m_impl->send.put_command (ISM_TRANS_CMD_REQUEST_ISE_HIDE);
2520 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2525 * @brief Connect a slot to Helper exit signal.
2527 * This signal is used to let the Helper exit.
2529 * The prototype of the slot is:
2531 * void exit (const HelperAgent *agent, int ic, const String &ic_uuid);
2534 * - agent The pointer to the HelperAgent object which emits this signal.
2535 * - ic An opaque handle of the currently focused input context.
2536 * - ic_uuid The UUID of the IMEngineInstance associated with the focused input context.
2539 HelperAgent::signal_connect_exit (HelperAgentSlotVoid *slot)
2541 return m_impl->signal_exit.connect (slot);
2545 * @brief Connect a slot to Helper attach input context signal.
2547 * This signal is used to attach an input context to this helper.
2549 * When an input context requst to start this helper, then this
2550 * signal will be emitted as soon as the helper is started.
2552 * When an input context want to start an already started helper,
2553 * this signal will also be emitted.
2555 * Helper can send some events back to the IMEngineInstance in this
2556 * signal-slot, to inform that it has been started sccessfully.
2558 * The prototype of the slot is:
2560 * void attach_input_context (const HelperAgent *agent, int ic, const String &ic_uuid);
2563 HelperAgent::signal_connect_attach_input_context (HelperAgentSlotVoid *slot)
2565 return m_impl->signal_attach_input_context.connect (slot);
2569 * @brief Connect a slot to Helper detach input context signal.
2571 * This signal is used to detach an input context from this helper.
2573 * When an input context requst to stop this helper, then this
2574 * signal will be emitted.
2576 * Helper shouldn't send any event back to the IMEngineInstance, because
2577 * the IMEngineInstance attached to the ic should have been destroyed.
2579 * The prototype of the slot is:
2581 * void detach_input_context (const HelperAgent *agent, int ic, const String &ic_uuid);
2584 HelperAgent::signal_connect_detach_input_context (HelperAgentSlotVoid *slot)
2586 return m_impl->signal_detach_input_context.connect (slot);
2590 * @brief Connect a slot to Helper reload config signal.
2592 * This signal is used to let the Helper reload configuration.
2594 * The prototype of the slot is:
2596 * void reload_config (const HelperAgent *agent, int ic, const String &ic_uuid);
2599 HelperAgent::signal_connect_reload_config (HelperAgentSlotVoid *slot)
2601 return m_impl->signal_reload_config.connect (slot);
2605 * @brief Connect a slot to Helper update screen signal.
2607 * This signal is used to let the Helper move its GUI to another screen.
2608 * It can only be emitted when SCIM_HELPER_NEED_SCREEN_INFO is set in HelperInfo.option.
2610 * The prototype of the slot is:
2612 * void update_screen (const HelperAgent *agent, int ic, const String &ic_uuid, int screen_number);
2615 HelperAgent::signal_connect_update_screen (HelperAgentSlotInt *slot)
2617 return m_impl->signal_update_screen.connect (slot);
2621 * @brief Connect a slot to Helper update spot location signal.
2623 * This signal is used to let the Helper move its GUI according to the current spot location.
2624 * It can only be emitted when SCIM_HELPER_NEED_SPOT_LOCATION_INFO is set in HelperInfo.option.
2626 * The prototype of the slot is:
2627 * void update_spot_location (const HelperAgent *agent, int ic, const String &ic_uuid, int x, int y);
2630 HelperAgent::signal_connect_update_spot_location (HelperAgentSlotIntInt *slot)
2632 return m_impl->signal_update_spot_location.connect (slot);
2636 * @brief Connect a slot to Helper update cursor position signal.
2638 * This signal is used to let the Helper get the cursor position information.
2640 * The prototype of the slot is:
2641 * void update_cursor_position (const HelperAgent *agent, int ic, const String &ic_uuid, int cursor_pos);
2644 HelperAgent::signal_connect_update_cursor_position (HelperAgentSlotInt *slot)
2646 return m_impl->signal_update_cursor_position.connect (slot);
2650 * @brief Connect a slot to Helper update surrounding text signal.
2652 * This signal is used to let the Helper get the surrounding text.
2654 * The prototype of the slot is:
2655 * void update_surrounding_text (const HelperAgent *agent, int ic, const String &text, int cursor);
2658 HelperAgent::signal_connect_update_surrounding_text (HelperAgentSlotInt *slot)
2660 return m_impl->signal_update_surrounding_text.connect (slot);
2664 * @brief Connect a slot to Helper update selection signal.
2666 * This signal is used to let the Helper get the selection.
2668 * The prototype of the slot is:
2669 * void update_selection (const HelperAgent *agent, int ic, const String &text);
2672 HelperAgent::signal_connect_update_selection (HelperAgentSlotVoid *slot)
2674 return m_impl->signal_update_selection.connect (slot);
2678 * @brief Connect a slot to Helper trigger property signal.
2680 * This signal is used to trigger a property registered by this Helper.
2681 * A property will be triggered when user clicks on it.
2683 * The prototype of the slot is:
2684 * void trigger_property (const HelperAgent *agent, int ic, const String &ic_uuid, const String &property);
2687 HelperAgent::signal_connect_trigger_property (HelperAgentSlotString *slot)
2689 return m_impl->signal_trigger_property.connect (slot);
2693 * @brief Connect a slot to Helper process imengine event signal.
2695 * This signal is used to deliver the events sent from IMEngine to Helper.
2697 * The prototype of the slot is:
2698 * void process_imengine_event (const HelperAgent *agent, int ic, const String &ic_uuid, const Transaction &transaction);
2701 HelperAgent::signal_connect_process_imengine_event (HelperAgentSlotTransaction *slot)
2703 return m_impl->signal_process_imengine_event.connect (slot);
2707 * @brief Connect a slot to Helper focus out signal.
2709 * This signal is used to do something when input context is focus out.
2711 * The prototype of the slot is:
2712 * void focus_out (const HelperAgent *agent, int ic, const String &ic_uuid);
2715 HelperAgent::signal_connect_focus_out (HelperAgentSlotVoid *slot)
2717 return m_impl->signal_focus_out.connect (slot);
2721 * @brief Connect a slot to Helper focus in signal.
2723 * This signal is used to do something when input context is focus in.
2725 * The prototype of the slot is:
2726 * void focus_in (const HelperAgent *agent, int ic, const String &ic_uuid);
2729 HelperAgent::signal_connect_focus_in (HelperAgentSlotVoid *slot)
2731 return m_impl->signal_focus_in.connect (slot);
2735 * @brief Connect a slot to Helper show signal.
2737 * This signal is used to show Helper ISE window.
2739 * The prototype of the slot is:
2740 * void ise_show (const HelperAgent *agent, int ic, char *buf, size_t &len);
2743 HelperAgent::signal_connect_ise_show (HelperAgentSlotIntRawVoid *slot)
2745 return m_impl->signal_ise_show.connect (slot);
2749 * @brief Connect a slot to Helper hide signal.
2751 * This signal is used to hide Helper ISE window.
2753 * The prototype of the slot is:
2754 * void ise_hide (const HelperAgent *agent, int ic, const String &ic_uuid);
2757 HelperAgent::signal_connect_ise_hide (HelperAgentSlotVoid *slot)
2759 return m_impl->signal_ise_hide.connect (slot);
2763 * @brief Connect a slot to Helper get ISE window geometry signal.
2765 * This signal is used to get Helper ISE window size and position.
2767 * The prototype of the slot is:
2768 * void get_geometry (const HelperAgent *agent, struct rectinfo &info);
2771 HelperAgent::signal_connect_get_geometry (HelperAgentSlotSize *slot)
2773 return m_impl->signal_get_geometry.connect (slot);
2777 * @brief Connect a slot to Helper set mode signal.
2779 * This signal is used to set Helper ISE mode.
2781 * The prototype of the slot is:
2782 * void set_mode (const HelperAgent *agent, uint32 &mode);
2785 HelperAgent::signal_connect_set_mode (HelperAgentSlotUintVoid *slot)
2787 return m_impl->signal_set_mode.connect (slot);
2791 * @brief Connect a slot to Helper set language signal.
2793 * This signal is used to set Helper ISE language.
2795 * The prototype of the slot is:
2796 * void set_language (const HelperAgent *agent, uint32 &language);
2799 HelperAgent::signal_connect_set_language (HelperAgentSlotUintVoid *slot)
2801 return m_impl->signal_set_language.connect (slot);
2805 * @brief Connect a slot to Helper set im data signal.
2807 * This signal is used to send im data to Helper ISE.
2809 * The prototype of the slot is:
2810 * void set_imdata (const HelperAgent *agent, char *buf, size_t &len);
2813 HelperAgent::signal_connect_set_imdata (HelperAgentSlotRawVoid *slot)
2815 return m_impl->signal_set_imdata.connect (slot);
2819 * @brief Connect a slot to Helper get im data signal.
2821 * This signal is used to get im data from Helper ISE.
2823 * The prototype of the slot is:
2824 * void get_imdata (const HelperAgent *, char **buf, size_t &len);
2827 HelperAgent::signal_connect_get_imdata (HelperAgentSlotGetRawVoid *slot)
2829 return m_impl->signal_get_imdata.connect (slot);
2833 * @brief Connect a slot to Helper get language locale signal.
2835 * This signal is used to get language locale from Helper ISE.
2837 * The prototype of the slot is:
2838 * void get_language_locale (const HelperAgent *, int ic, char **locale);
2841 HelperAgent::signal_connect_get_language_locale (HelperAgentSlotIntGetStringVoid *slot)
2843 return m_impl->signal_get_language_locale.connect (slot);
2847 * @brief Connect a slot to Helper set return key type signal.
2849 * This signal is used to send return key type to Helper ISE.
2851 * The prototype of the slot is:
2852 * void set_return_key_type (const HelperAgent *agent, uint32 &type);
2855 HelperAgent::signal_connect_set_return_key_type (HelperAgentSlotUintVoid *slot)
2857 return m_impl->signal_set_return_key_type.connect (slot);
2861 * @brief Connect a slot to Helper get return key type signal.
2863 * This signal is used to get return key type from Helper ISE.
2865 * The prototype of the slot is:
2866 * void get_return_key_type (const HelperAgent *agent, uint32 &type);
2869 HelperAgent::signal_connect_get_return_key_type (HelperAgentSlotUintVoid *slot)
2871 return m_impl->signal_get_return_key_type.connect (slot);
2875 * @brief Connect a slot to Helper set return key disable signal.
2877 * This signal is used to send return key disable to Helper ISE.
2879 * The prototype of the slot is:
2880 * void set_return_key_disable (const HelperAgent *agent, uint32 &disabled);
2883 HelperAgent::signal_connect_set_return_key_disable (HelperAgentSlotUintVoid *slot)
2885 return m_impl->signal_set_return_key_disable.connect (slot);
2889 * @brief Connect a slot to Helper process key event signal.
2891 * This signal is used to send keyboard key event to Helper ISE.
2893 * The prototype of the slot is:
2894 * void process_key_event (const HelperAgent *agent, KeyEvent &key, uint32 &ret);
2897 HelperAgent::signal_connect_process_key_event (HelperAgentSlotKeyEventUint *slot)
2899 return m_impl->signal_process_key_event.connect (slot);
2903 * @brief Connect a slot to Helper get return key disable signal.
2905 * This signal is used to get return key disable from Helper ISE.
2907 * The prototype of the slot is:
2908 * void get_return_key_disable (const HelperAgent *agent, uint32 &disabled);
2911 HelperAgent::signal_connect_get_return_key_disable (HelperAgentSlotUintVoid *slot)
2913 return m_impl->signal_get_return_key_disable.connect (slot);
2917 * @brief Connect a slot to Helper set layout signal.
2919 * This signal is used to set Helper ISE layout.
2921 * The prototype of the slot is:
2922 * void set_layout (const HelperAgent *agent, uint32 &layout);
2925 HelperAgent::signal_connect_set_layout (HelperAgentSlotUintVoid *slot)
2927 return m_impl->signal_set_layout.connect (slot);
2931 * @brief Connect a slot to Helper get layout signal.
2933 * This signal is used to get Helper ISE layout.
2935 * The prototype of the slot is:
2936 * void get_layout (const HelperAgent *agent, uint32 &layout);
2939 HelperAgent::signal_connect_get_layout (HelperAgentSlotUintVoid *slot)
2941 return m_impl->signal_get_layout.connect (slot);
2945 * @brief Connect a slot to Helper set input mode signal.
2947 * This signal is used to set Helper ISE input mode.
2949 * The prototype of the slot is:
2950 * void set_input_mode (const HelperAgent *agent, uint32 &input_mode);
2953 HelperAgent::signal_connect_set_input_mode (HelperAgentSlotUintVoid *slot)
2955 return m_impl->signal_set_input_mode.connect (slot);
2959 * @brief Connect a slot to Helper set input hint signal.
2961 * This signal is used to set Helper ISE input hint.
2963 * The prototype of the slot is:
2964 * void set_input_hint (const HelperAgent *agent, uint32 &input_hint);
2967 HelperAgent::signal_connect_set_input_hint (HelperAgentSlotUintVoid *slot)
2969 return m_impl->signal_set_input_hint.connect (slot);
2973 * @brief Connect a slot to Helper set BiDi direction signal.
2975 * This signal is used to set Helper ISE BiDi direction.
2977 * The prototype of the slot is:
2978 * void update_bidi_direction (const HelperAgent *agent, uint32 &bidi_direction);
2981 HelperAgent::signal_connect_update_bidi_direction (HelperAgentSlotUintVoid *slot)
2983 return m_impl->signal_update_bidi_direction.connect (slot);
2987 * @brief Connect a slot to Helper set shift mode signal.
2989 * This signal is used to set Helper shift mode.
2991 * The prototype of the slot is:
2992 * void set_caps_mode (const HelperAgent *agent, uint32 &mode);
2995 HelperAgent::signal_connect_set_caps_mode (HelperAgentSlotUintVoid *slot)
2997 return m_impl->signal_set_caps_mode.connect (slot);
3001 * @brief Connect a slot to Helper reset input context signal.
3003 * This signal is used to reset Helper ISE input context.
3005 * The prototype of the slot is:
3006 * void reset_input_context (const HelperAgent *agent, int ic, const String &uuid);
3009 HelperAgent::signal_connect_reset_input_context (HelperAgentSlotVoid *slot)
3011 return m_impl->signal_reset_input_context.connect (slot);
3015 * @brief Connect a slot to Helper update candidate window geometry signal.
3017 * This signal is used to get candidate window size and position.
3019 * The prototype of the slot is:
3020 * void update_candidate_geometry (const HelperAgent *agent, int ic, const String &uuid, const rectinfo &info);
3023 HelperAgent::signal_connect_update_candidate_geometry (HelperAgentSlotRect *slot)
3025 return m_impl->signal_update_candidate_geometry.connect (slot);
3029 * @brief Connect a slot to Helper update keyboard ISE signal.
3031 * This signal is used to get current keyboard ISE name and uuid.
3033 * The prototype of the slot is:
3034 * void update_keyboard_ise (const HelperAgent *agent, int ic, const String &uuid,
3035 * const String &ise_name, const String &ise_uuid);
3038 HelperAgent::signal_connect_update_keyboard_ise (HelperAgentSlotString2 *slot)
3040 return m_impl->signal_update_keyboard_ise.connect (slot);
3044 * @brief Connect a slot to Helper update keyboard ISE list signal.
3046 * This signal is used to get uuid list of all keyboard ISEs.
3048 * The prototype of the slot is:
3049 * void update_keyboard_ise_list (const HelperAgent *agent, int ic, const String &uuid,
3050 * const std::vector<String> &ise_list);
3053 HelperAgent::signal_connect_update_keyboard_ise_list (HelperAgentSlotStringVector *slot)
3055 return m_impl->signal_update_keyboard_ise_list.connect (slot);
3059 * @brief Connect a slot to Helper candidate more window show signal.
3061 * This signal is used to do someting when candidate more window is showed.
3063 * The prototype of the slot is:
3064 * void candidate_more_window_show (const HelperAgent *agent, int ic, const String &uuid);
3067 HelperAgent::signal_connect_candidate_more_window_show (HelperAgentSlotVoid *slot)
3069 return m_impl->signal_candidate_more_window_show.connect (slot);
3073 * @brief Connect a slot to Helper candidate more window hide signal.
3075 * This signal is used to do someting when candidate more window is hidden.
3077 * The prototype of the slot is:
3078 * void candidate_more_window_hide (const HelperAgent *agent, int ic, const String &uuid);
3081 HelperAgent::signal_connect_candidate_more_window_hide (HelperAgentSlotVoid *slot)
3083 return m_impl->signal_candidate_more_window_hide.connect (slot);
3087 * @brief Connect a slot to Helper candidate show signal.
3089 * This signal is used to do candidate show.
3091 * The prototype of the slot is:
3092 * void candidate_show (const HelperAgent *agent, int ic, const String &uuid);
3095 HelperAgent::signal_connect_candidate_show (HelperAgentSlotVoid *slot)
3097 return m_impl->signal_candidate_show.connect (slot);
3101 * @brief Connect a slot to Helper candidate hide signal.
3103 * This signal is used to do candidate hide.
3105 * The prototype of the slot is:
3106 * void candidate_hide (const HelperAgent *agent, int ic, const String &uuid);
3109 HelperAgent::signal_connect_candidate_hide (HelperAgentSlotVoid *slot)
3111 return m_impl->signal_candidate_hide.connect (slot);
3115 * @brief Connect a slot to Helper update lookup table signal.
3117 * This signal is used to do someting when update lookup table.
3119 * The prototype of the slot is:
3120 * void update_lookup_table (const HelperAgent *agent, int ic, const String &uuid ,LookupTable &table);
3123 HelperAgent::signal_connect_update_lookup_table (HelperAgentSlotLookupTable *slot)
3125 return m_impl->signal_update_lookup_table.connect (slot);
3129 * @brief Connect a slot to Helper select aux signal.
3131 * This signal is used to do something when aux is selected.
3133 * The prototype of the slot is:
3134 * void select_aux (const HelperAgent *agent, int ic, const String &uuid, int index);
3137 HelperAgent::signal_connect_select_aux (HelperAgentSlotInt *slot)
3139 return m_impl->signal_select_aux.connect (slot);
3143 * @brief Connect a slot to Helper select candidate signal.
3145 * This signal is used to do something when candidate is selected.
3147 * The prototype of the slot is:
3148 * void select_candidate (const HelperAgent *agent, int ic, const String &uuid, int index);
3151 HelperAgent::signal_connect_select_candidate (HelperAgentSlotInt *slot)
3153 return m_impl->signal_select_candidate.connect (slot);
3157 * @brief Connect a slot to Helper candidate table page up signal.
3159 * This signal is used to do something when candidate table is paged up.
3161 * The prototype of the slot is:
3162 * void candidate_table_page_up (const HelperAgent *agent, int ic, const String &uuid);
3165 HelperAgent::signal_connect_candidate_table_page_up (HelperAgentSlotVoid *slot)
3167 return m_impl->signal_candidate_table_page_up.connect (slot);
3171 * @brief Connect a slot to Helper candidate table page down signal.
3173 * This signal is used to do something when candidate table is paged down.
3175 * The prototype of the slot is:
3176 * void candidate_table_page_down (const HelperAgent *agent, int ic, const String &uuid);
3179 HelperAgent::signal_connect_candidate_table_page_down (HelperAgentSlotVoid *slot)
3181 return m_impl->signal_candidate_table_page_down.connect (slot);
3185 * @brief Connect a slot to Helper update candidate table page size signal.
3187 * This signal is used to do something when candidate table page size is changed.
3189 * The prototype of the slot is:
3190 * void update_candidate_table_page_size (const HelperAgent *, int ic, const String &uuid, int page_size);
3193 HelperAgent::signal_connect_update_candidate_table_page_size (HelperAgentSlotInt *slot)
3195 return m_impl->signal_update_candidate_table_page_size.connect (slot);
3199 * @brief Connect a slot to Helper update candidate item layout signal.
3201 * The prototype of the slot is:
3202 * void update_candidate_item_layout (const HelperAgent *, const std::vector<uint32> &row_items);
3205 HelperAgent::signal_connect_update_candidate_item_layout (HelperAgentSlotUintVector *slot)
3207 return m_impl->signal_update_candidate_item_layout.connect (slot);
3211 * @brief Connect a slot to Helper select associate signal.
3213 * This signal is used to do something when associate is selected.
3215 * The prototype of the slot is:
3216 * void select_associate (const HelperAgent *agent, int ic, const String &uuid, int index);
3219 HelperAgent::signal_connect_select_associate (HelperAgentSlotInt *slot)
3221 return m_impl->signal_select_associate.connect (slot);
3225 * @brief Connect a slot to Helper associate table page up signal.
3227 * This signal is used to do something when associate table is paged up.
3229 * The prototype of the slot is:
3230 * void associate_table_page_up (const HelperAgent *agent, int ic, const String &uuid);
3233 HelperAgent::signal_connect_associate_table_page_up (HelperAgentSlotVoid *slot)
3235 return m_impl->signal_associate_table_page_up.connect (slot);
3239 * @brief Connect a slot to Helper associate table page down signal.
3241 * This signal is used to do something when associate table is paged down.
3243 * The prototype of the slot is:
3244 * void associate_table_page_down (const HelperAgent *agent, int ic, const String &uuid);
3247 HelperAgent::signal_connect_associate_table_page_down (HelperAgentSlotVoid *slot)
3249 return m_impl->signal_associate_table_page_down.connect (slot);
3253 * @brief Connect a slot to Helper update associate table page size signal.
3255 * This signal is used to do something when associate table page size is changed.
3257 * The prototype of the slot is:
3258 * void update_associate_table_page_size (const HelperAgent *, int ic, const String &uuid, int page_size);
3261 HelperAgent::signal_connect_update_associate_table_page_size (HelperAgentSlotInt *slot)
3263 return m_impl->signal_update_associate_table_page_size.connect (slot);
3267 * @brief Connect a slot to Helper turn on log signal.
3269 * This signal is used to turn on Helper ISE debug information.
3271 * The prototype of the slot is:
3272 * void turn_on_log (const HelperAgent *agent, uint32 &on);
3275 HelperAgent::signal_connect_turn_on_log (HelperAgentSlotUintVoid *slot)
3277 return m_impl->signal_turn_on_log.connect (slot);
3281 * @brief Connect a slot to Helper update displayed candidate number signal.
3283 * This signal is used to inform helper ISE displayed candidate number.
3285 * The prototype of the slot is:
3286 * void update_displayed_candidate_number (const HelperAgent *, int ic, const String &uuid, int number);
3289 HelperAgent::signal_connect_update_displayed_candidate_number (HelperAgentSlotInt *slot)
3291 return m_impl->signal_update_displayed_candidate_number.connect (slot);
3295 * @brief Connect a slot to Helper longpress candidate signal.
3297 * This signal is used to do something when candidate is longpress.
3299 * The prototype of the slot is:
3300 * void longpress_candidate (const HelperAgent *agent, int ic, const String &uuid, int index);
3303 HelperAgent::signal_connect_longpress_candidate (HelperAgentSlotInt *slot)
3305 return m_impl->signal_longpress_candidate.connect (slot);
3309 * @brief Connect a slot to Helper show option window.
3311 * This signal is used to do request the ISE to show option window.
3313 * The prototype of the slot is:
3314 * void show_option_window (const HelperAgent *agent, int ic, const String &uuid);
3317 HelperAgent::signal_connect_show_option_window (HelperAgentSlotVoid *slot)
3319 return m_impl->signal_show_option_window.connect (slot);
3323 * @brief Connect a slot to Helper check if the option is available.
3325 * This signal is used to check if the option (setting) is available from Helper ISE.
3327 * The prototype of the slot is:
3328 * void check_option_window (const HelperAgent *agent, uint32 &avail);
3331 HelperAgent::signal_connect_check_option_window (HelperAgentSlotUintVoid *slot)
3333 return m_impl->signal_check_option_window.connect (slot);
3337 * @brief Connect a slot to Helper process unconventional input device event signal.
3339 * This signal is used to send unconventional input device event to Helper ISE.
3341 * The prototype of the slot is:
3342 * void process_input_device_event (const HelperAgent *, uint32 &type, char *data, size_t &size, uint32 &ret);
3345 HelperAgent::signal_connect_process_input_device_event (HelperAgentSlotUintCharSizeUint *slot)
3347 return m_impl->signal_process_input_device_event.connect (slot);
3350 } /* namespace scim */
3353 vi:ts=4:nowrap:ai:expandtab