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 HelperAgentSignalVoid signal_resume_option_window;
218 HelperAgentSignalUintVoid signal_check_option_window;
219 HelperAgentSignalUintCharSizeUint signal_process_input_device_event;
222 HelperAgentImpl (HelperAgent* thiz) : focused_ic ((uint32) -1), thiz (thiz),
223 surrounding_text (NULL), selection_text (NULL), cursor_pos (0),
224 need_update_surrounding_text (0), need_update_selection_text (0),
228 ~HelperAgentImpl () {
233 if (surrounding_text != NULL)
234 free (surrounding_text);
236 if (selection_text != NULL)
237 free (selection_text);
239 if (engine_module.valid ()) {
240 engine_module.unload ();
244 // Implementation of slot functions
246 slot_show_preedit_string (IMEngineInstanceBase *si)
249 thiz->show_preedit_string (focused_ic, "");
253 slot_show_aux_string (IMEngineInstanceBase *si)
256 thiz->show_aux_string ();
260 slot_show_lookup_table (IMEngineInstanceBase *si)
263 thiz->show_candidate_string ();
267 slot_hide_preedit_string (IMEngineInstanceBase *si)
270 thiz->hide_preedit_string (focused_ic, "");
274 slot_hide_aux_string (IMEngineInstanceBase *si)
277 thiz->hide_aux_string ();
281 slot_hide_lookup_table (IMEngineInstanceBase *si)
284 thiz->hide_candidate_string ();
288 slot_update_preedit_caret (IMEngineInstanceBase *si, int caret)
291 thiz->update_preedit_caret (caret);
295 slot_update_preedit_string (IMEngineInstanceBase *si,
296 const WideString & str,
297 const AttributeList & attrs,
301 thiz->update_preedit_string (-1, "", str, attrs, caret);
305 slot_update_preedit_string_with_commit (IMEngineInstanceBase *si,
306 const WideString & preedit,
307 const WideString & commit,
308 const AttributeList & attrs,
312 thiz->update_preedit_string (-1, "", preedit, commit, attrs, caret);
316 slot_update_aux_string (IMEngineInstanceBase *si,
317 const WideString & str,
318 const AttributeList & attrs)
321 thiz->update_aux_string (utf8_wcstombs(str), attrs);
325 slot_commit_string (IMEngineInstanceBase *si,
326 const WideString & str)
329 thiz->commit_string (-1, "", str);
333 slot_forward_key_event (IMEngineInstanceBase *si,
334 const KeyEvent & key)
337 thiz->forward_key_event (-1, "", key);
341 slot_update_lookup_table (IMEngineInstanceBase *si,
342 const LookupTable & table)
345 thiz->update_candidate_string (table);
349 slot_register_properties (IMEngineInstanceBase *si,
350 const PropertyList & properties)
353 thiz->register_properties (properties);
357 slot_update_property (IMEngineInstanceBase *si,
358 const Property & property)
361 thiz->update_property (property);
365 slot_beep (IMEngineInstanceBase *si)
372 slot_start_helper (IMEngineInstanceBase *si,
373 const String &helper_uuid)
375 LOGW ("deprecated function");
379 slot_stop_helper (IMEngineInstanceBase *si,
380 const String &helper_uuid)
382 LOGW ("deprecated function");
386 slot_send_helper_event (IMEngineInstanceBase *si,
387 const String &helper_uuid,
388 const Transaction &trans)
391 signal_process_imengine_event (thiz, focused_ic, helper_uuid, trans);
395 slot_get_surrounding_text (IMEngineInstanceBase *si,
403 thiz->get_surrounding_text (maxlen_before, maxlen_after, _text, cursor);
404 text = utf8_mbstowcs(_text);
409 slot_delete_surrounding_text (IMEngineInstanceBase *si,
415 thiz->delete_surrounding_text (offset, len);
420 slot_get_selection (IMEngineInstanceBase *si,
425 thiz->get_selection_text (_text);
426 text = utf8_mbstowcs (_text);
431 slot_set_selection (IMEngineInstanceBase *si,
436 thiz->set_selection (start, end);
441 slot_expand_candidate (IMEngineInstanceBase *si)
444 thiz->expand_candidate ();
448 slot_contract_candidate (IMEngineInstanceBase *si)
451 thiz->contract_candidate ();
455 slot_set_candidate_style (IMEngineInstanceBase *si, ISF_CANDIDATE_PORTRAIT_LINE_T portrait_line, ISF_CANDIDATE_MODE_T mode)
458 thiz->set_candidate_style (portrait_line, mode);
462 slot_send_private_command (IMEngineInstanceBase *si,
463 const String &command)
466 thiz->send_private_command (command);
472 si->signal_connect_show_preedit_string (
473 slot (this, &HelperAgent::HelperAgentImpl::slot_show_preedit_string));
474 si->signal_connect_show_aux_string (
475 slot (this, &HelperAgent::HelperAgentImpl::slot_show_aux_string));
476 si->signal_connect_show_lookup_table (
477 slot (this, &HelperAgent::HelperAgentImpl::slot_show_lookup_table));
479 si->signal_connect_hide_preedit_string (
480 slot (this, &HelperAgent::HelperAgentImpl::slot_hide_preedit_string));
481 si->signal_connect_hide_aux_string (
482 slot (this, &HelperAgent::HelperAgentImpl::slot_hide_aux_string));
483 si->signal_connect_hide_lookup_table (
484 slot (this, &HelperAgent::HelperAgentImpl::slot_hide_lookup_table));
486 si->signal_connect_update_preedit_caret (
487 slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_caret));
488 si->signal_connect_update_preedit_string (
489 slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_string));
490 si->signal_connect_update_preedit_string_with_commit (
491 slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_string_with_commit));
493 si->signal_connect_update_aux_string (
494 slot (this, &HelperAgent::HelperAgentImpl::slot_update_aux_string));
495 si->signal_connect_update_lookup_table (
496 slot (this, &HelperAgent::HelperAgentImpl::slot_update_lookup_table));
498 si->signal_connect_commit_string (
499 slot (this, &HelperAgent::HelperAgentImpl::slot_commit_string));
501 si->signal_connect_forward_key_event (
502 slot (this, &HelperAgent::HelperAgentImpl::slot_forward_key_event));
504 si->signal_connect_register_properties (
505 slot (this, &HelperAgent::HelperAgentImpl::slot_register_properties));
507 si->signal_connect_update_property (
508 slot (this, &HelperAgent::HelperAgentImpl::slot_update_property));
510 si->signal_connect_beep (
511 slot (this, &HelperAgent::HelperAgentImpl::slot_beep));
513 si->signal_connect_start_helper (
514 slot (this, &HelperAgent::HelperAgentImpl::slot_start_helper));
516 si->signal_connect_stop_helper (
517 slot (this, &HelperAgent::HelperAgentImpl::slot_stop_helper));
519 si->signal_connect_send_helper_event (
520 slot (this, &HelperAgent::HelperAgentImpl::slot_send_helper_event));
522 si->signal_connect_get_surrounding_text (
523 slot (this, &HelperAgent::HelperAgentImpl::slot_get_surrounding_text));
525 si->signal_connect_delete_surrounding_text (
526 slot (this, &HelperAgent::HelperAgentImpl::slot_delete_surrounding_text));
528 si->signal_connect_get_selection (
529 slot (this, &HelperAgent::HelperAgentImpl::slot_get_selection));
531 si->signal_connect_set_selection (
532 slot (this, &HelperAgent::HelperAgentImpl::slot_set_selection));
534 si->signal_connect_expand_candidate (
535 slot (this, &HelperAgent::HelperAgentImpl::slot_expand_candidate));
536 si->signal_connect_contract_candidate (
537 slot (this, &HelperAgent::HelperAgentImpl::slot_contract_candidate));
539 si->signal_connect_set_candidate_style (
540 slot (this, &HelperAgent::HelperAgentImpl::slot_set_candidate_style));
542 si->signal_connect_send_private_command (
543 slot (this, &HelperAgent::HelperAgentImpl::slot_send_private_command));
546 void process_key_event_done (KeyEvent &key, uint32 ret, uint32 serial) {
547 LOGD ("ret: %d, serial: %d", ret, serial);
548 if (socket_active.is_connected ()) {
550 send.put_command (SCIM_TRANS_CMD_REQUEST);
551 send.put_data (magic_active);
552 send.put_command (ISM_TRANS_CMD_PROCESS_KEY_EVENT_DONE);
555 send.put_data (serial);
556 send.write_to_socket (socket_active, magic_active);
560 void request_ise_hide () {
561 if (socket_active.is_connected ()) {
563 send.put_command (SCIM_TRANS_CMD_REQUEST);
564 send.put_data (magic_active);
565 send.put_command (ISM_TRANS_CMD_REQUEST_ISE_HIDE);
566 send.write_to_socket (socket_active, magic_active);
570 HelperAgentImpl () : magic (0), magic_active (0), timeout (-1), focused_ic ((uint32) -1) { }
573 static MessageQueue message_queue;
575 HelperAgent::HelperAgent ()
576 : m_impl (new HelperAgentImpl (this))
578 message_queue.create();
581 HelperAgent::~HelperAgent ()
583 message_queue.destroy();
588 * @brief Open socket connection to the Panel.
590 * @param info The information of this Helper object.
591 * @param display The display which this Helper object should run on.
593 * @return The connection socket id. -1 means failed to create
597 HelperAgent::open_connection (const HelperInfo &info,
598 const String &display)
600 if (m_impl->socket.is_connected ())
603 SocketAddress address (scim_get_default_panel_socket_address (display));
604 int timeout = m_impl->timeout = scim_get_default_socket_timeout ();
607 if (!address.valid ())
611 std::cerr << " Connecting to PanelAgent server.";
612 ISF_LOG (" Connecting to PanelAgent server.\n");
613 while (!m_impl->socket.connect (address)) {
615 scim_usleep (100000);
617 std::cerr << "m_impl->socket.connect () is failed!!!\n";
618 ISF_LOG ("m_impl->socket.connect () is failed!!!\n");
622 std::cerr << " Connected :" << i << "\n";
623 ISF_LOG (" Connected :%d\n", i);
624 LOGD ("Connection to PanelAgent succeeded, %d\n", i);
626 /* Let's retry 10 times when failed */
627 int open_connection_retries = 0;
628 while (!scim_socket_open_connection (magic,
633 if (++open_connection_retries > 10) {
634 m_impl->socket.close ();
635 std::cerr << "scim_socket_open_connection () is failed!!!\n";
636 ISF_LOG ("scim_socket_open_connection () is failed!!!\n");
637 ISF_SAVE_LOG ("scim_socket_open_connection failed, %d\n", timeout);
642 /* Retry after re-connecting the socket */
643 if (m_impl->socket.is_connected ())
646 /* This time, just retry atmost 2 seconds */
648 while (!m_impl->socket.connect (address) && ++i < 10) {
649 scim_usleep (200000);
654 ISF_LOG ("scim_socket_open_connection () is successful.\n");
655 LOGD ("scim_socket_open_connection successful\n");
657 m_impl->send.clear ();
658 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
659 m_impl->send.put_data (magic);
660 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_REGISTER_HELPER);
661 m_impl->send.put_data (info.uuid);
662 m_impl->send.put_data (info.name);
663 m_impl->send.put_data (info.icon);
664 m_impl->send.put_data (info.description);
665 m_impl->send.put_data (info.option);
667 if (!m_impl->send.write_to_socket (m_impl->socket, magic)) {
668 m_impl->socket.close ();
673 if (m_impl->recv.read_from_socket (m_impl->socket, timeout) &&
674 m_impl->recv.get_command (cmd) && cmd == SCIM_TRANS_CMD_REPLY &&
675 m_impl->recv.get_command (cmd) && cmd == SCIM_TRANS_CMD_OK) {
676 m_impl->magic = magic;
678 while (m_impl->recv.get_command (cmd)) {
680 case SCIM_TRANS_CMD_HELPER_ATTACH_INPUT_CONTEXT:
684 while (m_impl->recv.get_data (ic) && m_impl->recv.get_data (ic_uuid))
685 m_impl->signal_attach_input_context (this, ic, ic_uuid);
688 case SCIM_TRANS_CMD_UPDATE_SCREEN:
691 if (m_impl->recv.get_data (screen))
692 m_impl->signal_update_screen (this, (uint32) -1, String (""), (int) screen);
700 //FIXME: Attaching input context is needed for desktop environment
701 LOGW ("Attach input context and update screen failed");
704 ISF_SAVE_LOG ("Trying connect() with Helper_Active\n");
706 /* connect to the panel agent as the active helper client */
707 if (!m_impl->socket_active.connect (address)) return -1;
708 if (!scim_socket_open_connection (magic,
709 String ("Helper_Active"),
711 m_impl->socket_active,
713 m_impl->socket_active.close ();
714 ISF_SAVE_LOG ("Helper_Active scim_socket_open_connection() failed %d\n", timeout);
718 m_impl->magic_active = magic;
720 m_impl->send.clear ();
721 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
722 m_impl->send.put_data (magic);
723 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_REGISTER_ACTIVE_HELPER);
724 m_impl->send.put_data (info.uuid);
725 m_impl->send.put_data (info.name);
726 m_impl->send.put_data (info.icon);
727 m_impl->send.put_data (info.description);
728 m_impl->send.put_data (info.option);
730 if (!m_impl->send.write_to_socket (m_impl->socket_active, magic)) {
731 ISF_SAVE_LOG ("Helper_Active write_to_socket() failed\n");
732 m_impl->socket_active.close ();
735 m_impl->m_config = ConfigBase::get (false, "socket");
737 return m_impl->socket.get_id ();
741 * @brief Close the socket connection to Panel.
744 HelperAgent::close_connection ()
746 m_impl->socket.close ();
747 m_impl->socket_active.close ();
748 m_impl->send.clear ();
749 m_impl->recv.clear ();
751 m_impl->magic_active = 0;
756 * @brief Get the connection id previously returned by open_connection().
758 * @return the connection id
761 HelperAgent::get_connection_number () const
763 if (m_impl->socket.is_connected ())
764 return m_impl->socket.get_id ();
769 * @brief Check whether this HelperAgent has been connected to a Panel.
771 * Return true when it is connected to panel, otherwise return false.
774 HelperAgent::is_connected () const
776 return m_impl->socket.is_connected ();
780 * @brief Check if there are any events available to be processed.
782 * If it returns true then Helper object should call
783 * HelperAgent::filter_event() to process them.
785 * @return true if there are any events available.
788 HelperAgent::has_pending_event () const
790 if (m_impl->socket.is_connected () && m_impl->socket.wait_for_data (0) > 0)
793 if (message_queue.has_pending_message())
800 * @brief Process the pending events.
802 * This function will emit the corresponding signals according
805 * @return false if the connection is broken, otherwise return true.
808 HelperAgent::filter_event ()
810 if (!m_impl->socket.is_connected () || !m_impl->recv.read_from_socket (m_impl->socket, m_impl->timeout))
813 message_queue.read_from_transaction(m_impl->recv);
815 while (message_queue.has_pending_message()) {
816 MessageItem *message = message_queue.get_pending_message();
817 handle_message(message);
818 message_queue.remove_message(message);
826 * @brief Read messages from socket buffer, and see if there is a message with the given cmd.
828 * @return false if the connection is broken, or no message available with given cmd. Otherwise return true.
831 HelperAgent::wait_for_message(int cmd, int timeout)
833 struct timeval t0 = { 0, 0 };
834 struct timeval t1 = { 0, 0 };
836 gettimeofday(&t0, NULL);
840 if (!m_impl->socket.is_connected() || !m_impl->recv.read_from_socket(m_impl->socket, timeout))
843 message_queue.read_from_transaction(m_impl->recv);
844 if (message_queue.get_pending_message_by_cmd(cmd)) {
848 gettimeofday(&t1, NULL);
849 etime = ((t1.tv_sec * 1000000 + t1.tv_usec) - (t0.tv_sec * 1000000 + t0.tv_usec)) / 1000;
852 } while (etime < timeout);
858 * @brief Process one message that is in our message queue.
860 * This function will emit the corresponding signals according
863 * @param message The message that needs to be handled.
865 * @return false if the connection is broken, otherwise return true.
868 HelperAgent::handle_message (MessageItem *message)
873 int cmd = message->get_command_ref();
874 LOGD ("HelperAgent::cmd = %d\n", cmd);
876 case SCIM_TRANS_CMD_EXIT:
878 MessageItemExit *subclass = static_cast<MessageItemExit*>(message);
879 ISF_SAVE_LOG ("Helper ISE received SCIM_TRANS_CMD_EXIT message\n");
880 m_impl->signal_exit(this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
883 case SCIM_TRANS_CMD_RELOAD_CONFIG:
885 MessageItemReloadConfig *subclass = static_cast<MessageItemReloadConfig*>(message);
886 m_impl->signal_reload_config (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
887 if (!m_impl->m_config.null())
888 m_impl->m_config->ConfigBase::reload();
891 case SCIM_TRANS_CMD_UPDATE_SCREEN:
893 MessageItemUpdateScreen *subclass = static_cast<MessageItemUpdateScreen*>(message);
894 m_impl->signal_update_screen (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
895 subclass->get_screen_ref());
898 case SCIM_TRANS_CMD_UPDATE_SPOT_LOCATION:
900 MessageItemUpdateSpotLocation *subclass = static_cast<MessageItemUpdateSpotLocation*>(message);
901 m_impl->signal_update_spot_location (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
902 subclass->get_x_ref(), subclass->get_y_ref());
905 case ISM_TRANS_CMD_UPDATE_CURSOR_POSITION:
907 MessageItemUpdateCursorPosition *subclass = static_cast<MessageItemUpdateCursorPosition*>(message);
908 m_impl->cursor_pos = subclass->get_cursor_pos_ref();
909 LOGD ("update cursor position %d", subclass->get_cursor_pos_ref());
910 m_impl->signal_update_cursor_position (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
911 subclass->get_cursor_pos_ref());
912 if (!m_impl->si.null ()) m_impl->si->update_cursor_position(subclass->get_cursor_pos_ref());
915 case ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT:
917 MessageItemUpdateSurroundingText *subclass = static_cast<MessageItemUpdateSurroundingText*>(message);
918 if (m_impl->surrounding_text != NULL)
919 free (m_impl->surrounding_text);
920 m_impl->surrounding_text = strdup (subclass->get_text_ref().c_str ());
921 m_impl->cursor_pos = subclass->get_cursor_ref();
922 LOGD ("surrounding text: %s, %d", m_impl->surrounding_text, subclass->get_cursor_ref());
923 while (m_impl->need_update_surrounding_text > 0) {
924 m_impl->need_update_surrounding_text--;
925 m_impl->signal_update_surrounding_text (this, subclass->get_ic_ref(),
926 subclass->get_text_ref(), subclass->get_cursor_ref());
930 case ISM_TRANS_CMD_UPDATE_SELECTION:
932 MessageItemUpdateSelection *subclass = static_cast<MessageItemUpdateSelection*>(message);
933 if (m_impl->selection_text != NULL)
934 free (m_impl->selection_text);
936 m_impl->selection_text = strdup (subclass->get_text_ref().c_str ());
937 LOGD ("selection text: %s", m_impl->selection_text);
939 while (m_impl->need_update_selection_text > 0) {
940 m_impl->need_update_selection_text--;
941 m_impl->signal_update_selection (this, subclass->get_ic_ref(), subclass->get_text_ref());
945 case SCIM_TRANS_CMD_TRIGGER_PROPERTY:
947 MessageItemTriggerProperty *subclass = static_cast<MessageItemTriggerProperty*>(message);
948 m_impl->signal_trigger_property (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
949 subclass->get_property_ref());
950 if (!m_impl->si.null ()) m_impl->si->trigger_property(subclass->get_property_ref());
953 case SCIM_TRANS_CMD_HELPER_PROCESS_IMENGINE_EVENT:
955 MessageItemHelperProcessImengineEvent *subclass = static_cast<MessageItemHelperProcessImengineEvent*>(message);
956 m_impl->signal_process_imengine_event (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
957 subclass->get_transaction_ref());
960 case SCIM_TRANS_CMD_HELPER_ATTACH_INPUT_CONTEXT:
962 MessageItemHelperAttachInputContext *subclass = static_cast<MessageItemHelperAttachInputContext*>(message);
963 m_impl->signal_attach_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
966 case SCIM_TRANS_CMD_HELPER_DETACH_INPUT_CONTEXT:
968 MessageItemHelperDetachInputContext *subclass = static_cast<MessageItemHelperDetachInputContext*>(message);
969 m_impl->signal_detach_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
972 case SCIM_TRANS_CMD_FOCUS_OUT:
974 MessageItemFocusOut *subclass = static_cast<MessageItemFocusOut*>(message);
975 m_impl->signal_focus_out (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
976 m_impl->focused_ic = (uint32) -1;
977 if (!m_impl->si.null ()) m_impl->si->focus_out();
980 case SCIM_TRANS_CMD_FOCUS_IN:
982 MessageItemFocusIn *subclass = static_cast<MessageItemFocusIn*>(message);
983 m_impl->signal_focus_in (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
984 m_impl->focused_ic = subclass->get_ic_ref();
985 if (!m_impl->si.null ()) m_impl->si->focus_in();
988 case ISM_TRANS_CMD_SHOW_ISE_PANEL:
990 MessageItemShowISEPanel *subclass = static_cast<MessageItemShowISEPanel*>(message);
991 LOGD ("Helper ISE received ISM_TRANS_CMD_SHOW_ISE_PANEL message\n");
993 m_impl->signal_ise_show (this, subclass->get_ic_ref(), *(subclass->get_data_ptr()),
994 subclass->get_len_ref());
997 case ISM_TRANS_CMD_HIDE_ISE_PANEL:
999 MessageItemHideISEPanel *subclass = static_cast<MessageItemHideISEPanel*>(message);
1000 LOGD ("Helper ISE received ISM_TRANS_CMD_HIDE_ISE_PANEL message\n");
1001 m_impl->signal_ise_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1004 case ISM_TRANS_CMD_GET_ACTIVE_ISE_GEOMETRY:
1006 struct rectinfo info = {0, 0, 0, 0};
1007 m_impl->signal_get_geometry (this, info);
1008 m_impl->send.clear ();
1009 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1010 m_impl->send.put_data (info.pos_x);
1011 m_impl->send.put_data (info.pos_y);
1012 m_impl->send.put_data (info.width);
1013 m_impl->send.put_data (info.height);
1014 m_impl->send.write_to_socket (m_impl->socket);
1017 case ISM_TRANS_CMD_SET_ISE_MODE:
1019 MessageItemSetISEMode *subclass = static_cast<MessageItemSetISEMode*>(message);
1020 m_impl->signal_set_mode (this, subclass->get_mode_ref());
1023 case ISM_TRANS_CMD_SET_ISE_LANGUAGE:
1025 MessageItemSetISELanguage *subclass = static_cast<MessageItemSetISELanguage*>(message);
1026 m_impl->signal_set_language (this, subclass->get_language_ref());
1029 case ISM_TRANS_CMD_SET_ISE_IMDATA:
1031 MessageItemSetISEImData *subclass = static_cast<MessageItemSetISEImData*>(message);
1032 m_impl->signal_set_imdata (this, *(subclass->get_imdata_ptr()), subclass->get_len_ref());
1033 if (!m_impl->si.null ()) m_impl->si->set_imdata(*(subclass->get_imdata_ptr()),
1034 subclass->get_len_ref());
1037 case ISM_TRANS_CMD_GET_ISE_IMDATA:
1042 m_impl->signal_get_imdata (this, &buf, len);
1043 LOGD ("send ise imdata len = %d", len);
1044 m_impl->send.clear ();
1045 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1046 m_impl->send.put_data (buf, len);
1047 m_impl->send.write_to_socket (m_impl->socket);
1052 case ISM_TRANS_CMD_GET_ISE_LANGUAGE_LOCALE:
1054 MessageItemGetISELanguageLocale *subclass = static_cast<MessageItemGetISELanguageLocale*>(message);
1056 m_impl->signal_get_language_locale (this, subclass->get_ic_ref(), &buf);
1057 m_impl->send.clear ();
1058 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1060 m_impl->send.put_data (buf, strlen (buf));
1061 m_impl->send.write_to_socket (m_impl->socket);
1066 case ISM_TRANS_CMD_SET_RETURN_KEY_TYPE:
1068 MessageItemSetReturnKeyType *subclass = static_cast<MessageItemSetReturnKeyType*>(message);
1069 m_impl->signal_set_return_key_type (this, subclass->get_type_ref());
1072 case ISM_TRANS_CMD_GET_RETURN_KEY_TYPE:
1075 m_impl->signal_get_return_key_type (this, type);
1076 m_impl->send.clear ();
1077 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1078 m_impl->send.put_data (type);
1079 m_impl->send.write_to_socket (m_impl->socket);
1082 case ISM_TRANS_CMD_SET_RETURN_KEY_DISABLE:
1084 MessageItemSetReturnKeyDisable *subclass = static_cast<MessageItemSetReturnKeyDisable*>(message);
1085 m_impl->signal_set_return_key_disable (this, subclass->get_disabled_ref());
1088 case ISM_TRANS_CMD_GET_RETURN_KEY_DISABLE:
1090 uint32 disabled = 0;
1091 m_impl->signal_get_return_key_type (this, disabled);
1092 m_impl->send.clear ();
1093 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1094 m_impl->send.put_data (disabled);
1095 m_impl->send.write_to_socket (m_impl->socket);
1098 case SCIM_TRANS_CMD_PROCESS_KEY_EVENT:
1100 MessageItemProcessKeyEvent *subclass = static_cast<MessageItemProcessKeyEvent*>(message);
1102 m_impl->signal_process_key_event(this, subclass->get_key_ref(), ret);
1104 if (!m_impl->si.null ())
1106 ret = m_impl->si->process_key_event (subclass->get_key_ref());
1107 LOGD("imengine(%s) process key %d return %d", m_impl->si->get_factory_uuid().c_str(),
1108 subclass->get_key_ref().code, ret);
1110 m_impl->process_key_event_done (subclass->get_key_ref(), ret, subclass->get_serial_ref());
1113 case ISM_TRANS_CMD_SET_LAYOUT:
1115 MessageItemSetLayout *subclass = static_cast<MessageItemSetLayout*>(message);
1116 m_impl->layout = subclass->get_layout_ref();
1117 m_impl->signal_set_layout (this, subclass->get_layout_ref());
1118 if (!m_impl->si.null ()) m_impl->si->set_layout(subclass->get_layout_ref());
1121 case ISM_TRANS_CMD_GET_LAYOUT:
1125 m_impl->signal_get_layout (this, layout);
1126 m_impl->send.clear ();
1127 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1128 m_impl->send.put_data (layout);
1129 m_impl->send.write_to_socket (m_impl->socket);
1132 case ISM_TRANS_CMD_SET_INPUT_MODE:
1134 MessageItemSetInputMode *subclass = static_cast<MessageItemSetInputMode*>(message);
1135 m_impl->signal_set_input_mode (this, subclass->get_input_mode_ref());
1138 case ISM_TRANS_CMD_SET_CAPS_MODE:
1140 MessageItemSetCapsMode *subclass = static_cast<MessageItemSetCapsMode*>(message);
1141 m_impl->signal_set_caps_mode (this, subclass->get_mode_ref());
1144 case SCIM_TRANS_CMD_PANEL_RESET_INPUT_CONTEXT:
1146 MessageItemPanelResetInputContext *subclass = static_cast<MessageItemPanelResetInputContext*>(message);
1147 m_impl->signal_reset_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1148 if (!m_impl->si.null ()) m_impl->si->reset();
1151 case ISM_TRANS_CMD_UPDATE_CANDIDATE_UI:
1153 MessageItemUpdateCandidateUI *subclass = static_cast<MessageItemUpdateCandidateUI*>(message);
1154 m_impl->signal_update_candidate_ui (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1155 subclass->get_style_ref(), subclass->get_mode_ref());
1158 case ISM_TRANS_CMD_UPDATE_CANDIDATE_GEOMETRY:
1160 MessageItemUpdateCandidateGeometry *subclass = static_cast<MessageItemUpdateCandidateGeometry*>(message);
1161 m_impl->signal_update_candidate_geometry (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1162 subclass->get_rectinfo_ref());
1165 case ISM_TRANS_CMD_UPDATE_KEYBOARD_ISE:
1167 MessageItemUpdateKeyboardISE *subclass = static_cast<MessageItemUpdateKeyboardISE*>(message);
1168 m_impl->signal_update_keyboard_ise (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1169 subclass->get_name_ref(), subclass->get_uuid_ref());
1172 case ISM_TRANS_CMD_UPDATE_KEYBOARD_ISE_LIST:
1174 MessageItemUpdateKeyboardISEList *subclass = static_cast<MessageItemUpdateKeyboardISEList*>(message);
1175 m_impl->signal_update_keyboard_ise_list (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1176 subclass->get_list_ref());
1179 case ISM_TRANS_CMD_CANDIDATE_MORE_WINDOW_SHOW:
1181 MessageItemCandidateMoreWindowShow *subclass = static_cast<MessageItemCandidateMoreWindowShow*>(message);
1182 m_impl->signal_candidate_more_window_show (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1183 if (!m_impl->si.null ()) m_impl->si->candidate_more_window_show();
1186 case ISM_TRANS_CMD_CANDIDATE_MORE_WINDOW_HIDE:
1188 MessageItemCandidateMoreWindowHide *subclass = static_cast<MessageItemCandidateMoreWindowHide*>(message);
1189 m_impl->signal_candidate_more_window_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1190 if (!m_impl->si.null ()) m_impl->si->candidate_more_window_hide();
1193 case ISM_TRANS_CMD_SELECT_AUX:
1195 MessageItemSelectAux *subclass = static_cast<MessageItemSelectAux*>(message);
1196 m_impl->signal_select_aux (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1197 subclass->get_item_ref());
1198 if (!m_impl->si.null ()) m_impl->si->select_aux(subclass->get_item_ref());
1201 case SCIM_TRANS_CMD_SELECT_CANDIDATE: //FIXME:remove if useless
1203 MessageItemSelectCandidate *subclass = static_cast<MessageItemSelectCandidate*>(message);
1204 m_impl->signal_select_candidate (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1205 subclass->get_item_ref());
1206 if (!m_impl->si.null ()) m_impl->si->select_candidate(subclass->get_item_ref());
1209 case SCIM_TRANS_CMD_LOOKUP_TABLE_PAGE_UP: //FIXME:remove if useless
1211 MessageItemLookupTablePageUp *subclass = static_cast<MessageItemLookupTablePageUp*>(message);
1212 m_impl->signal_candidate_table_page_up (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1213 if (!m_impl->si.null ()) m_impl->si->lookup_table_page_up();
1216 case SCIM_TRANS_CMD_LOOKUP_TABLE_PAGE_DOWN: //FIXME:remove if useless
1218 MessageItemLookupTablePageDown *subclass = static_cast<MessageItemLookupTablePageDown*>(message);
1219 m_impl->signal_candidate_table_page_down (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1220 if (!m_impl->si.null ()) m_impl->si->lookup_table_page_down();
1223 case SCIM_TRANS_CMD_UPDATE_LOOKUP_TABLE_PAGE_SIZE:
1225 MessageItemUpdateLookupTablePageSize *subclass = static_cast<MessageItemUpdateLookupTablePageSize*>(message);
1226 m_impl->signal_update_candidate_table_page_size (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1227 subclass->get_size_ref());
1228 if (!m_impl->si.null ()) m_impl->si->update_lookup_table_page_size(subclass->get_size_ref());
1231 case ISM_TRANS_CMD_CANDIDATE_SHOW: //FIXME:remove if useless
1233 MessageItemCandidateShow *subclass = static_cast<MessageItemCandidateShow*>(message);
1234 m_impl->signal_candidate_show (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1237 case ISM_TRANS_CMD_CANDIDATE_HIDE: //FIXME:remove if useless
1239 MessageItemCandidateHide *subclass = static_cast<MessageItemCandidateHide*>(message);
1240 m_impl->signal_candidate_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1243 case ISM_TRANS_CMD_UPDATE_LOOKUP_TABLE: //FIXME:remove if useless
1245 MessageItemUpdateLookupTable *subclass = static_cast<MessageItemUpdateLookupTable*>(message);
1246 m_impl->signal_update_lookup_table (this, subclass->get_candidate_table_ref());
1249 case ISM_TRANS_CMD_UPDATE_CANDIDATE_ITEM_LAYOUT:
1251 MessageItemUpdateCandidateItemLayout *subclass = static_cast<MessageItemUpdateCandidateItemLayout*>(message);
1252 m_impl->signal_update_candidate_item_layout (this, subclass->get_row_items_ref());
1253 if (!m_impl->si.null ()) m_impl->si->update_candidate_item_layout(subclass->get_row_items_ref());
1256 case ISM_TRANS_CMD_SELECT_ASSOCIATE:
1258 MessageItemSelectAssociate *subclass = static_cast<MessageItemSelectAssociate*>(message);
1259 m_impl->signal_select_associate (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1260 subclass->get_item_ref());
1263 case ISM_TRANS_CMD_ASSOCIATE_TABLE_PAGE_UP:
1265 MessageItemAssociateTablePageUp *subclass = static_cast<MessageItemAssociateTablePageUp*>(message);
1266 m_impl->signal_associate_table_page_up (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1269 case ISM_TRANS_CMD_ASSOCIATE_TABLE_PAGE_DOWN:
1271 MessageItemAssociateTablePageDown *subclass = static_cast<MessageItemAssociateTablePageDown*>(message);
1272 m_impl->signal_associate_table_page_down (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1275 case ISM_TRANS_CMD_UPDATE_ASSOCIATE_TABLE_PAGE_SIZE:
1277 MessageItemUpdateAssociateTablePageSize *subclass = static_cast<MessageItemUpdateAssociateTablePageSize*>(message);
1278 m_impl->signal_update_associate_table_page_size (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1279 subclass->get_size_ref());
1282 case ISM_TRANS_CMD_RESET_ISE_CONTEXT:
1284 MessageItemResetISEContext *subclass = static_cast<MessageItemResetISEContext*>(message);
1285 m_impl->signal_reset_ise_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1286 m_impl->signal_reset_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1287 if (!m_impl->si.null ()) m_impl->si->reset();
1290 case ISM_TRANS_CMD_TURN_ON_LOG:
1292 MessageItemTurnOnLog *subclass = static_cast<MessageItemTurnOnLog*>(message);
1293 m_impl->signal_turn_on_log (this, subclass->get_state_ref());
1296 case ISM_TRANS_CMD_UPDATE_DISPLAYED_CANDIDATE:
1298 MessageItemUpdateDisplayedCandidate *subclass = static_cast<MessageItemUpdateDisplayedCandidate*>(message);
1299 m_impl->signal_update_displayed_candidate_number (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1300 subclass->get_size_ref());
1301 if (!m_impl->si.null ()) m_impl->si->update_displayed_candidate_number(subclass->get_size_ref());
1304 case ISM_TRANS_CMD_LONGPRESS_CANDIDATE:
1306 MessageItemLongpressCandidate *subclass = static_cast<MessageItemLongpressCandidate*>(message);
1307 m_impl->signal_longpress_candidate (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1308 subclass->get_index_ref());
1309 if (!m_impl->si.null ()) m_impl->si->longpress_candidate(subclass->get_index_ref());
1312 case ISM_TRANS_CMD_SET_INPUT_HINT:
1314 MessageItemSetInputHint *subclass = static_cast<MessageItemSetInputHint*>(message);
1315 m_impl->signal_set_input_hint (this, subclass->get_input_hint_ref());
1316 if (!m_impl->si.null ()) m_impl->si->set_input_hint(subclass->get_input_hint_ref());
1319 case ISM_TRANS_CMD_UPDATE_BIDI_DIRECTION:
1321 MessageItemUpdateBidiDirection *subclass = static_cast<MessageItemUpdateBidiDirection*>(message);
1322 m_impl->signal_update_bidi_direction (this, subclass->get_bidi_direction());
1323 if (!m_impl->si.null ()) m_impl->si->update_bidi_direction(subclass->get_bidi_direction());
1326 case ISM_TRANS_CMD_SHOW_ISE_OPTION_WINDOW:
1328 MessageItemShowISEOptionWindow *subclass = static_cast<MessageItemShowISEOptionWindow*>(message);
1329 m_impl->signal_show_option_window (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1332 case ISM_TRANS_CMD_RESUME_ISE_OPTION_WINDOW:
1334 MessageItemResumeISEOptionWindow *subclass = static_cast<MessageItemResumeISEOptionWindow*>(message);
1335 m_impl->signal_resume_option_window (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1338 case ISM_TRANS_CMD_CHECK_OPTION_WINDOW:
1341 m_impl->signal_check_option_window (this, avail);
1342 m_impl->send.clear ();
1343 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1344 m_impl->send.put_data (avail);
1345 m_impl->send.write_to_socket (m_impl->socket);
1348 case ISM_TRANS_CMD_PROCESS_INPUT_DEVICE_EVENT:
1350 MessageItemProcessInputDeviceEvent *subclass = static_cast<MessageItemProcessInputDeviceEvent*>(message);
1352 m_impl->signal_process_input_device_event(this,
1353 subclass->get_type_ref(), *(subclass->get_data_ptr()), subclass->get_len_ref(), ret);
1354 m_impl->send.clear();
1355 m_impl->send.put_command(SCIM_TRANS_CMD_REPLY);
1356 m_impl->send.put_data(ret);
1357 m_impl->send.write_to_socket(m_impl->socket);
1360 case SCIM_TRANS_CMD_SET_AUTOCAPITAL_TYPE:
1362 MessageItemSetAutocapitalType *subclass = static_cast<MessageItemSetAutocapitalType*>(message);
1363 if (!m_impl->si.null ()) m_impl->si->set_autocapital_type(subclass->get_auto_capital_type_ref());
1366 case ISM_TRANS_CMD_SET_PREDICTION_ALLOW:
1368 MessageItemSetPredictionAllow *subclass = static_cast<MessageItemSetPredictionAllow*>(message);
1369 if (!m_impl->si.null ()) m_impl->si->set_prediction_allow(subclass->get_prediction_allow_ref() == 0 ? false : true);
1379 * @brief Request SCIM to reload all configuration.
1381 * This function should only by used by Setup Helper to request
1382 * scim's reloading the configuration.
1383 * Deprecated: reload config message only send by socketconfig client
1384 * using socketconfig::reload instead.
1387 HelperAgent::reload_config () const
1389 LOGD ("send reload config message to isf");
1390 if (!m_impl->m_config.null())
1391 m_impl->m_config->reload();
1395 * @brief Register some properties into Panel.
1397 * This function send the request to Panel to register a list
1400 * @param properties The list of Properties to be registered into Panel.
1402 * @sa scim::Property.
1405 HelperAgent::register_properties (const PropertyList &properties) const
1408 if (m_impl->socket_active.is_connected ()) {
1409 m_impl->send.clear ();
1410 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1411 m_impl->send.put_data (m_impl->magic_active);
1412 m_impl->send.put_command (SCIM_TRANS_CMD_REGISTER_PROPERTIES);
1413 m_impl->send.put_data (properties);
1414 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1419 * @brief Update a registered property.
1421 * @param property The property to be updated.
1424 HelperAgent::update_property (const Property &property) const
1427 if (m_impl->socket_active.is_connected ()) {
1428 m_impl->send.clear ();
1429 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1430 m_impl->send.put_data (m_impl->magic_active);
1431 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PROPERTY);
1432 m_impl->send.put_data (property);
1433 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1438 * @brief Send a set of events to an IMEngineInstance.
1440 * All events should be put into a Transaction.
1441 * And the events can only be received by one IMEngineInstance object.
1443 * @param ic The handle of the Input Context to receive the events.
1444 * @param ic_uuid The UUID of the Input Context.
1445 * @param trans The Transaction object holds the events.
1448 HelperAgent::send_imengine_event (int ic,
1449 const String &ic_uuid,
1450 const Transaction &trans) const
1453 //remove if not necessary
1455 if (m_impl->socket_active.is_connected ()) {
1456 m_impl->send.clear ();
1457 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1458 m_impl->send.put_data (m_impl->magic_active);
1459 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_SEND_IMENGINE_EVENT);
1460 m_impl->send.put_data ((uint32)ic);
1461 m_impl->send.put_data (ic_uuid);
1462 m_impl->send.put_data (trans);
1463 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1466 if (!m_impl->si.null ()) m_impl->si->process_helper_event (ic_uuid, trans);
1470 * @brief Send a KeyEvent to an IMEngineInstance.
1472 * @param ic The handle of the IMEngineInstance to receive the event.
1473 * -1 means the currently focused IMEngineInstance.
1474 * @param ic_uuid The UUID of the IMEngineInstance. Empty means don't match.
1475 * @param key The KeyEvent to be sent.
1478 HelperAgent::send_key_event (int ic,
1479 const String &ic_uuid,
1480 const KeyEvent &key) const
1484 //FIXME: remove shift_mode_off, shift_mode_on, shift_mode_lock from ISE side
1485 if (key.code == SHIFT_MODE_OFF ||
1486 key.code == SHIFT_MODE_ON ||
1487 key.code == SHIFT_MODE_LOCK ||
1488 key.code == SHIFT_MODE_ENABLE ||
1489 key.code == SHIFT_MODE_DISABLE) {
1490 LOGW("FIXME ignore shift codes");
1496 #if ENABLE_GRAB_KEYBOARD
1497 if (!m_impl->si.null ()) {
1499 if (key.code <= 0x7F ||
1500 (key.code >= SCIM_KEY_BackSpace && key.code <= SCIM_KEY_Delete) ||
1501 (key.code >= SCIM_KEY_Home && key.code <= SCIM_KEY_Hyper_R)) {
1502 // ascii code and function keys
1508 if (ret && (!m_impl->si.null ())) {
1510 ret = m_impl->si->process_key_event (key);
1511 LOGD ("imengine(%s) process key %d return %d", m_impl->si->get_factory_uuid().c_str(), key.code, ret);
1514 if (ret == false && m_impl->socket_active.is_connected ()) {
1515 m_impl->send.clear ();
1516 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1517 m_impl->send.put_data (m_impl->magic_active);
1518 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_SEND_KEY_EVENT);
1520 m_impl->send.put_data (m_impl->focused_ic);
1522 m_impl->send.put_data ((uint32)ic);
1524 m_impl->send.put_data (ic_uuid);
1525 m_impl->send.put_data (key);
1526 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1531 * @brief Forward a KeyEvent to client application directly.
1533 * @param ic The handle of the client Input Context to receive the event.
1534 * -1 means the currently focused Input Context.
1535 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1536 * Empty means don't match.
1537 * @param key The KeyEvent to be forwarded.
1540 HelperAgent::forward_key_event (int ic,
1541 const String &ic_uuid,
1542 const KeyEvent &key) const
1545 if (m_impl->socket_active.is_connected ()) {
1546 m_impl->send.clear ();
1547 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1548 m_impl->send.put_data (m_impl->magic_active);
1549 m_impl->send.put_command (SCIM_TRANS_CMD_FORWARD_KEY_EVENT);
1551 m_impl->send.put_data (m_impl->focused_ic);
1553 m_impl->send.put_data ((uint32)ic);
1555 m_impl->send.put_data (ic_uuid);
1556 m_impl->send.put_data (key);
1557 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1562 * @brief Commit a WideString to client application directly.
1564 * @param ic The handle of the client Input Context to receive the WideString.
1565 * -1 means the currently focused Input Context.
1566 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1567 * Empty means don't match.
1568 * @param wstr The WideString to be committed.
1571 HelperAgent::commit_string (int ic,
1572 const String &ic_uuid,
1573 const WideString &wstr) const
1576 if (m_impl->socket_active.is_connected ()) {
1577 m_impl->send.clear ();
1578 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1579 m_impl->send.put_data (m_impl->magic_active);
1580 m_impl->send.put_command (SCIM_TRANS_CMD_COMMIT_STRING);
1582 m_impl->send.put_data (m_impl->focused_ic);
1584 m_impl->send.put_data ((uint32)ic);
1586 m_impl->send.put_data (ic_uuid);
1587 m_impl->send.put_data (wstr);
1588 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1593 HelperAgent::commit_string (int ic,
1594 const String &ic_uuid,
1599 if (m_impl->socket_active.is_connected ()) {
1600 m_impl->send.clear ();
1601 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1602 m_impl->send.put_data (m_impl->magic_active);
1603 m_impl->send.put_command (SCIM_TRANS_CMD_COMMIT_STRING);
1605 m_impl->send.put_data (m_impl->focused_ic);
1607 m_impl->send.put_data ((uint32)ic);
1609 m_impl->send.put_data (ic_uuid);
1610 m_impl->send.put_dataw (buf, buflen);
1611 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1616 * @brief Request to show preedit string.
1618 * @param ic The handle of the client Input Context to receive the request.
1619 * -1 means the currently focused Input Context.
1620 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1621 * Empty means don't match.
1624 HelperAgent::show_preedit_string (int ic,
1625 const String &ic_uuid) const
1629 if (m_impl->socket_active.is_connected ()) {
1630 m_impl->send.clear ();
1631 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1632 m_impl->send.put_data (m_impl->magic_active);
1633 m_impl->send.put_command (SCIM_TRANS_CMD_SHOW_PREEDIT_STRING);
1634 m_impl->send.put_data ((uint32)ic);
1635 m_impl->send.put_data (ic_uuid);
1636 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1641 * @brief Request to show aux string.
1644 HelperAgent::show_aux_string (void) const
1648 if (m_impl->socket_active.is_connected ()) {
1649 m_impl->send.clear ();
1650 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1651 m_impl->send.put_data (m_impl->magic_active);
1652 m_impl->send.put_command (SCIM_TRANS_CMD_SHOW_AUX_STRING);
1653 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1658 * @brief Request to show candidate string.
1661 HelperAgent::show_candidate_string (void) const
1665 if (m_impl->socket_active.is_connected ()) {
1666 m_impl->send.clear ();
1667 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1668 m_impl->send.put_data (m_impl->magic_active);
1669 m_impl->send.put_command (SCIM_TRANS_CMD_SHOW_LOOKUP_TABLE);
1670 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1675 * @brief Request to show associate string.
1678 HelperAgent::show_associate_string (void) const
1681 if (m_impl->socket_active.is_connected ()) {
1682 m_impl->send.clear ();
1683 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1684 m_impl->send.put_data (m_impl->magic_active);
1685 m_impl->send.put_command (ISM_TRANS_CMD_SHOW_ASSOCIATE_TABLE);
1686 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1691 * @brief Request to hide preedit string.
1693 * @param ic The handle of the client Input Context to receive the request.
1694 * -1 means the currently focused Input Context.
1695 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1696 * Empty means don't match.
1699 HelperAgent::hide_preedit_string (int ic,
1700 const String &ic_uuid) const
1704 if (m_impl->socket_active.is_connected ()) {
1705 m_impl->send.clear ();
1706 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1707 m_impl->send.put_data (m_impl->magic_active);
1708 m_impl->send.put_command (SCIM_TRANS_CMD_HIDE_PREEDIT_STRING);
1709 m_impl->send.put_data ((uint32)ic);
1710 m_impl->send.put_data (ic_uuid);
1711 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1716 * @brief Request to hide aux string.
1719 HelperAgent::hide_aux_string (void) const
1722 if (m_impl->socket_active.is_connected ()) {
1723 m_impl->send.clear ();
1724 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1725 m_impl->send.put_data (m_impl->magic_active);
1726 m_impl->send.put_command (SCIM_TRANS_CMD_HIDE_AUX_STRING);
1727 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1732 * @brief Request to hide candidate string.
1735 HelperAgent::hide_candidate_string (void) const
1738 if (m_impl->socket_active.is_connected ()) {
1739 m_impl->send.clear ();
1740 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1741 m_impl->send.put_data (m_impl->magic_active);
1742 m_impl->send.put_command (SCIM_TRANS_CMD_HIDE_LOOKUP_TABLE);
1743 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1748 * @brief Request to hide associate string.
1751 HelperAgent::hide_associate_string (void) const
1754 if (m_impl->socket_active.is_connected ()) {
1755 m_impl->send.clear ();
1756 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1757 m_impl->send.put_data (m_impl->magic_active);
1758 m_impl->send.put_command (ISM_TRANS_CMD_HIDE_ASSOCIATE_TABLE);
1759 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1764 * @brief Update a new WideString for preedit.
1766 * @param ic The handle of the client Input Context to receive the WideString.
1767 * -1 means the currently focused Input Context.
1768 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1769 * Empty means don't match.
1770 * @param str The WideString to be updated.
1771 * @param attrs The attribute list for preedit string.
1774 HelperAgent::update_preedit_string (int ic,
1775 const String &ic_uuid,
1776 const WideString &str,
1777 const AttributeList &attrs) const
1780 update_preedit_string (ic, ic_uuid, str, str, attrs, -1);
1784 HelperAgent::update_preedit_string (int ic,
1785 const String &ic_uuid,
1788 const AttributeList &attrs) const
1791 update_preedit_string (ic, ic_uuid, buf, buflen, attrs, -1);
1795 * @brief Update a new WideString for preedit.
1797 * @param ic The handle of the client Input Context to receive the WideString.
1798 * -1 means the currently focused Input Context.
1799 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1800 * Empty means don't match.
1801 * @param str The WideString to be updated.
1802 * @param attrs The attribute list for preedit string.
1803 * @param caret The caret position in preedit string.
1806 HelperAgent::update_preedit_string (int ic,
1807 const String &ic_uuid,
1808 const WideString &wstr,
1809 const AttributeList &attrs,
1813 update_preedit_string (ic, ic_uuid, wstr, wstr, attrs, caret);
1817 HelperAgent::update_preedit_string (int ic,
1818 const String &ic_uuid,
1821 const AttributeList &attrs,
1826 if (m_impl->socket_active.is_connected ()) {
1827 m_impl->send.clear ();
1828 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1829 m_impl->send.put_data (m_impl->magic_active);
1830 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING);
1831 m_impl->send.put_data ((uint32)ic);
1832 m_impl->send.put_data (ic_uuid);
1833 m_impl->send.put_dataw (buf, buflen);
1834 m_impl->send.put_dataw (buf, buflen);
1835 m_impl->send.put_data (attrs);
1836 m_impl->send.put_data (caret);
1837 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1842 HelperAgent::update_preedit_string (int ic,
1843 const String &ic_uuid,
1844 const WideString &preedit,
1845 const WideString &commit,
1846 const AttributeList &attrs,
1850 if (m_impl->socket_active.is_connected ()) {
1851 m_impl->send.clear ();
1852 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1853 m_impl->send.put_data (m_impl->magic_active);
1854 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING);
1855 m_impl->send.put_data ((uint32)ic);
1856 m_impl->send.put_data (ic_uuid);
1857 m_impl->send.put_data (preedit);
1858 m_impl->send.put_data (commit);
1859 m_impl->send.put_data (attrs);
1860 m_impl->send.put_data (caret);
1861 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1866 * @brief Update the preedit caret position in the preedit string.
1868 * @param caret - the new position of the preedit caret.
1871 HelperAgent::update_preedit_caret (int caret) const
1875 if (m_impl->socket_active.is_connected ()) {
1876 m_impl->send.clear ();
1877 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1878 m_impl->send.put_data (m_impl->magic_active);
1879 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_CARET);
1880 m_impl->send.put_data ((uint32)caret);
1881 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1886 * @brief Update a new string for aux.
1888 * @param str The string to be updated.
1889 * @param attrs The attribute list for aux string.
1892 HelperAgent::update_aux_string (const String &str,
1893 const AttributeList &attrs) const
1896 if (m_impl->socket_active.is_connected ()) {
1897 m_impl->send.clear ();
1898 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1899 m_impl->send.put_data (m_impl->magic_active);
1900 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_AUX_STRING);
1901 m_impl->send.put_data (str);
1902 m_impl->send.put_data (attrs);
1903 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1908 * @brief Request to update candidate.
1910 * @param table The lookup table for candidate.
1913 HelperAgent::update_candidate_string (const LookupTable &table) const
1916 if (m_impl->socket_active.is_connected ()) {
1917 m_impl->send.clear ();
1918 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1919 m_impl->send.put_data (m_impl->magic_active);
1920 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_LOOKUP_TABLE);
1921 m_impl->send.put_data (table);
1922 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1927 * @brief Request to update associate.
1929 * @param table The lookup table for associate.
1932 HelperAgent::update_associate_string (const LookupTable &table) const
1935 if (m_impl->socket_active.is_connected ()) {
1936 m_impl->send.clear ();
1937 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1938 m_impl->send.put_data (m_impl->magic_active);
1939 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ASSOCIATE_TABLE);
1940 m_impl->send.put_data (table);
1941 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1946 * @brief When the input context of ISE is changed,
1947 * ISE can call this function to notify application
1949 * @param type type of event.
1950 * @param value value of event.
1953 HelperAgent::update_input_context (uint32 type, uint32 value) const
1956 if (m_impl->socket_active.is_connected ()) {
1957 m_impl->send.clear ();
1958 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1959 m_impl->send.put_data (m_impl->magic_active);
1960 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ISE_INPUT_CONTEXT);
1961 m_impl->send.put_data (type);
1962 m_impl->send.put_data (value);
1963 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1968 * @brief Request to get surrounding text asynchronously.
1970 * @param uuid The helper ISE UUID.
1971 * @param maxlen_before The max length of before.
1972 * @param maxlen_after The max length of after.
1975 HelperAgent::get_surrounding_text (const String &uuid, int maxlen_before, int maxlen_after) const
1978 if (m_impl->socket_active.is_connected () && (m_impl->need_update_surrounding_text == 0)) {
1979 m_impl->send.clear ();
1980 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1981 m_impl->send.put_data (m_impl->magic_active);
1982 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SURROUNDING_TEXT);
1983 m_impl->send.put_data (uuid);
1984 m_impl->send.put_data (maxlen_before);
1985 m_impl->send.put_data (maxlen_after);
1986 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1988 m_impl->need_update_surrounding_text++;
1992 * @brief Request to get surrounding text synchronously.
1994 * @param uuid The helper ISE UUID.
1995 * @param maxlen_before The max length of before.
1996 * @param maxlen_after The max length of after.
1997 * @param text The surrounding text.
1998 * @param cursor The cursor position.
2001 HelperAgent::get_surrounding_text (int maxlen_before, int maxlen_after, String &text, int &cursor)
2005 if (!m_impl->socket_active.is_connected ())
2008 m_impl->send.clear ();
2009 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2010 m_impl->send.put_data (m_impl->magic_active);
2011 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SURROUNDING_TEXT);
2012 m_impl->send.put_data ("");
2013 m_impl->send.put_data (maxlen_before);
2014 m_impl->send.put_data (maxlen_after);
2015 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2016 if (m_impl->surrounding_text) {
2017 free (m_impl->surrounding_text);
2018 m_impl->surrounding_text = NULL;
2021 const int WAIT_FOR_SYNC_RESPONSE_TIMEOUT = 1000;
2022 /* Now we are waiting for the ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT message */
2023 if (wait_for_message(ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT, WAIT_FOR_SYNC_RESPONSE_TIMEOUT)) {
2024 MessageItem *message = message_queue.get_pending_message_by_cmd(ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT);
2025 handle_message(message);
2026 message_queue.remove_message(message);
2028 if (m_impl->surrounding_text) {
2029 text = m_impl->surrounding_text;
2030 cursor = m_impl->cursor_pos;
2034 if (m_impl->surrounding_text) {
2035 free (m_impl->surrounding_text);
2036 m_impl->surrounding_text = NULL;
2041 * @brief Request to delete surrounding text.
2043 * @param offset The offset for cursor position.
2044 * @param len The length for delete text.
2047 HelperAgent::delete_surrounding_text (int offset, int len) const
2049 LOGD ("offset = %d, len = %d", offset, len);
2051 if (m_impl->socket_active.is_connected ()) {
2052 m_impl->send.clear ();
2053 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2054 m_impl->send.put_data (m_impl->magic_active);
2055 m_impl->send.put_command (SCIM_TRANS_CMD_DELETE_SURROUNDING_TEXT);
2056 m_impl->send.put_data (offset);
2057 m_impl->send.put_data (len);
2058 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2063 * @brief Request to get selection text asynchronously.
2065 * @param uuid The helper ISE UUID.
2068 HelperAgent::get_selection (const String &uuid) const
2071 if (m_impl->socket_active.is_connected () && (m_impl->need_update_selection_text == 0)) {
2072 m_impl->send.clear ();
2073 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2074 m_impl->send.put_data (m_impl->magic_active);
2075 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SELECTION);
2076 m_impl->send.put_data (uuid);
2077 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2079 m_impl->need_update_selection_text++;
2083 * @brief Request to get selection text synchronously.
2085 * @param text The selection text.
2088 HelperAgent::get_selection_text (String &text)
2092 if (!m_impl->socket_active.is_connected ())
2095 m_impl->send.clear ();
2096 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2097 m_impl->send.put_data (m_impl->magic_active);
2098 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SELECTION);
2099 m_impl->send.put_data ("");
2100 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2101 if (m_impl->selection_text) {
2102 free (m_impl->selection_text);
2103 m_impl->selection_text = NULL;
2106 const int WAIT_FOR_SYNC_RESPONSE_TIMEOUT = 1000;
2107 /* Now we are waiting for the ISM_TRANS_CMD_UPDATE_SELECTION message */
2108 if (wait_for_message(ISM_TRANS_CMD_UPDATE_SELECTION, WAIT_FOR_SYNC_RESPONSE_TIMEOUT)) {
2109 MessageItem *message = message_queue.get_pending_message_by_cmd(ISM_TRANS_CMD_UPDATE_SELECTION);
2110 handle_message(message);
2111 message_queue.remove_message(message);
2112 if (m_impl->selection_text) {
2113 text = m_impl->selection_text;
2117 if (m_impl->selection_text) {
2118 free (m_impl->selection_text);
2119 m_impl->selection_text = NULL;
2124 * @brief Request to select text.
2126 * @param start The start position in text.
2127 * @param end The end position in text.
2130 HelperAgent::set_selection (int start, int end) const
2133 if (m_impl->socket_active.is_connected ()) {
2134 m_impl->send.clear ();
2135 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2136 m_impl->send.put_data (m_impl->magic_active);
2137 m_impl->send.put_command (SCIM_TRANS_CMD_SET_SELECTION);
2138 m_impl->send.put_data (start);
2139 m_impl->send.put_data (end);
2140 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2145 * @brief Send a private command to an application.
2147 * @param command The private command sent from IME.
2150 HelperAgent::send_private_command (const String &command) const
2153 if (m_impl->socket_active.is_connected ()) {
2154 m_impl->send.clear ();
2155 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2156 m_impl->send.put_data (m_impl->magic_active);
2157 m_impl->send.put_command (SCIM_TRANS_CMD_SEND_PRIVATE_COMMAND);
2158 m_impl->send.put_data (command);
2159 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2164 * @brief Request to get uuid list of all keyboard ISEs.
2166 * @param uuid The helper ISE UUID.
2169 HelperAgent::get_keyboard_ise_list (const String &uuid) const
2172 if (m_impl->socket_active.is_connected ()) {
2173 m_impl->send.clear ();
2174 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2175 m_impl->send.put_data (m_impl->magic_active);
2176 m_impl->send.put_command (ISM_TRANS_CMD_GET_KEYBOARD_ISE_LIST);
2177 m_impl->send.put_data (uuid);
2178 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2183 * @brief Set candidate position in screen.
2185 * @param left The x position in screen.
2186 * @param top The y position in screen.
2189 HelperAgent::set_candidate_position (int left, int top) const
2192 if (m_impl->socket_active.is_connected ()) {
2193 m_impl->send.clear ();
2194 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2195 m_impl->send.put_data (m_impl->magic_active);
2196 m_impl->send.put_command (ISM_TRANS_CMD_SET_CANDIDATE_POSITION);
2197 m_impl->send.put_data (left);
2198 m_impl->send.put_data (top);
2199 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2204 * @brief Set candidate style.
2206 * @param portrait_line - the displayed line number for portrait mode.
2207 * @param mode - candidate window mode.
2210 HelperAgent::set_candidate_style (ISF_CANDIDATE_PORTRAIT_LINE_T portrait_line,
2211 ISF_CANDIDATE_MODE_T mode) const
2214 if (m_impl->socket_active.is_connected ()) {
2215 m_impl->send.clear ();
2216 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2217 m_impl->send.put_data (m_impl->magic_active);
2218 m_impl->send.put_command (ISM_TRANS_CMD_SET_CANDIDATE_UI);
2219 m_impl->send.put_data (portrait_line);
2220 m_impl->send.put_data (mode);
2221 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2226 * @brief Request to hide candidate window.
2229 HelperAgent::candidate_hide (void) const
2232 if (m_impl->socket_active.is_connected ()) {
2233 m_impl->send.clear ();
2234 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2235 m_impl->send.put_data (m_impl->magic_active);
2236 m_impl->send.put_command (ISM_TRANS_CMD_HIDE_CANDIDATE);
2237 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2242 * @brief Request to get candidate window size and position.
2244 * @param uuid The helper ISE UUID.
2247 HelperAgent::get_candidate_window_geometry (const String &uuid) const
2250 if (m_impl->socket_active.is_connected ()) {
2251 m_impl->send.clear ();
2252 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2253 m_impl->send.put_data (m_impl->magic_active);
2254 m_impl->send.put_command (ISM_TRANS_CMD_GET_CANDIDATE_GEOMETRY);
2255 m_impl->send.put_data (uuid);
2256 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2261 * @brief Set current keyboard ISE.
2263 * @param uuid The keyboard ISE UUID.
2266 HelperAgent::set_keyboard_ise_by_uuid (const String &uuid) const
2270 IMEngineFactoryPointer factory;
2271 IMEngineModule *engine_module = NULL;
2272 static int instance_count = 1;
2274 if ((!m_impl->si.null ()) && m_impl->si->get_factory_uuid () == uuid) {
2275 LOGD ("Already in UUID: %s\n", uuid.c_str());
2279 if (!m_impl->si.null()) {
2280 m_impl->si->focus_out();
2284 if (m_impl->m_config.null ()) {
2285 LOGW ("config is not working");
2289 #ifdef HAVE_PKGMGR_INFO
2292 pkgmgrinfo_appinfo_h handle;
2293 ret = pkgmgrinfo_appinfo_get_appinfo(uuid.c_str(), &handle);
2294 if (ret != PMINFO_R_OK) {
2295 LOGW("Retrieve app info failed : %s", uuid.c_str ());
2299 ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
2300 if (ret != PMINFO_R_OK) {
2301 LOGW("Retrieve pkgid failed : %s, %p", uuid.c_str(), handle);
2302 pkgmgrinfo_appinfo_destroy_appinfo(handle);
2306 imeInfo.module_name = pkgid;
2307 pkgmgrinfo_appinfo_destroy_appinfo(handle);
2309 if (isf_db_select_ime_info_by_appid(uuid.c_str(), &imeInfo) < 1) {
2310 LOGW("ime_info row is not available for %s", uuid.c_str());
2315 engine_module = &m_impl->engine_module;
2317 if (engine_module->valid() && imeInfo.module_name != engine_module->get_module_name()) {
2318 LOGD ("imengine module %s unloaded", engine_module->get_module_name().c_str());
2319 engine_module->unload();
2322 if (!engine_module->valid()) {
2323 if (engine_module->load (imeInfo.module_name, m_impl->m_config) == false) {
2324 LOGW ("load module %s failed", imeInfo.module_name.c_str());
2327 LOGD ("imengine module %s loaded", imeInfo.module_name.c_str());
2330 for (size_t j = 0; j < engine_module->number_of_factories (); ++j) {
2333 factory = engine_module->create_factory (j);
2334 if (factory.null () == false && factory->get_uuid () == uuid)
2342 if (factory.null()) {
2343 LOGW ("imengine uuid %s is not found", uuid.c_str());
2347 m_impl->si = factory->create_instance ("UTF-8", instance_count++);
2348 if (m_impl->si.null ()) {
2349 LOGE ("create_instance %s failed",uuid.c_str ());
2353 m_impl->attach_instance ();
2354 LOGD ("Require UUID: %s Current UUID: %s", uuid.c_str (), m_impl->si->get_factory_uuid ().c_str ());
2355 m_impl->si->set_layout (m_impl->layout);
2356 if(m_impl->focused_ic != (uint32)-1)
2357 m_impl->si->focus_in ();
2361 * @brief Request to get current keyboard ISE information.
2363 * @param uuid The helper ISE UUID.
2366 HelperAgent::get_keyboard_ise (const String &uuid) const
2369 //FIXME: maybe useless
2371 if (m_impl->socket_active.is_connected ()) {
2372 m_impl->send.clear ();
2373 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2374 m_impl->send.put_data (m_impl->magic_active);
2375 m_impl->send.put_command (ISM_TRANS_CMD_GET_KEYBOARD_ISE);
2376 m_impl->send.put_data (uuid);
2377 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2383 * @brief Update ISE window geometry.
2385 * @param x The x position in screen.
2386 * @param y The y position in screen.
2387 * @param width The ISE window width.
2388 * @param height The ISE window height.
2391 HelperAgent::update_geometry (int x, int y, int width, int height) const
2394 if (m_impl->socket_active.is_connected ()) {
2395 m_impl->send.clear ();
2396 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2397 m_impl->send.put_data (m_impl->magic_active);
2398 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ISE_GEOMETRY);
2399 m_impl->send.put_data (x);
2400 m_impl->send.put_data (y);
2401 m_impl->send.put_data (width);
2402 m_impl->send.put_data (height);
2403 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2408 * @brief Request to expand candidate window.
2411 HelperAgent::expand_candidate (void) const
2414 if (m_impl->socket_active.is_connected ()) {
2415 m_impl->send.clear ();
2416 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2417 m_impl->send.put_data (m_impl->magic_active);
2418 m_impl->send.put_command (ISM_TRANS_CMD_EXPAND_CANDIDATE);
2419 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2424 * @brief Request to contract candidate window.
2427 HelperAgent::contract_candidate (void) const
2430 if (m_impl->socket_active.is_connected ()) {
2431 m_impl->send.clear ();
2432 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2433 m_impl->send.put_data (m_impl->magic_active);
2434 m_impl->send.put_command (ISM_TRANS_CMD_CONTRACT_CANDIDATE);
2435 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2440 * @brief Send selected candidate string index number.
2443 HelperAgent::select_candidate (int index) const
2446 if (!m_impl->si.null ())
2447 m_impl->si->select_candidate (index);
2448 //FIXME: maybe useless
2451 if (m_impl->socket_active.is_connected ()) {
2452 m_impl->send.clear ();
2453 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2454 m_impl->send.put_data (m_impl->magic_active);
2455 m_impl->send.put_command (ISM_TRANS_CMD_SELECT_CANDIDATE);
2456 m_impl->send.put_data (index);
2457 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2463 * @brief Update our ISE is exiting.
2466 HelperAgent::update_ise_exit (void) const
2469 //FIXME: maybe useless
2471 if (m_impl->socket_active.is_connected ()) {
2472 m_impl->send.clear ();
2473 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2474 m_impl->send.put_data (m_impl->magic_active);
2475 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ISE_EXIT);
2476 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2482 * @brief Request to reset keyboard ISE.
2485 HelperAgent::reset_keyboard_ise (void) const
2488 //FIXME: maybe useless
2490 if (m_impl->socket_active.is_connected ()) {
2491 m_impl->send.clear ();
2492 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2493 m_impl->send.put_data (m_impl->magic_active);
2494 m_impl->send.put_command (ISM_TRANS_CMD_PANEL_RESET_KEYBOARD_ISE);
2495 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2498 if (!m_impl->si.null ()) {
2499 m_impl->si->reset ();
2504 * @brief Request to flush keyboard ISE.
2507 HelperAgent::flush_keyboard_ise (void) const
2510 if (!m_impl->si.null ()) {
2511 m_impl->si->flush ();
2516 * @brief Request panel to hide ISE.
2519 HelperAgent::request_ise_hide (void) const
2522 if (m_impl->socket_active.is_connected ()) {
2523 m_impl->send.clear ();
2524 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2525 m_impl->send.put_data (m_impl->magic_active);
2526 m_impl->send.put_command (ISM_TRANS_CMD_REQUEST_ISE_HIDE);
2527 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2532 * @brief Connect a slot to Helper exit signal.
2534 * This signal is used to let the Helper exit.
2536 * The prototype of the slot is:
2538 * void exit (const HelperAgent *agent, int ic, const String &ic_uuid);
2541 * - agent The pointer to the HelperAgent object which emits this signal.
2542 * - ic An opaque handle of the currently focused input context.
2543 * - ic_uuid The UUID of the IMEngineInstance associated with the focused input context.
2546 HelperAgent::signal_connect_exit (HelperAgentSlotVoid *slot)
2548 return m_impl->signal_exit.connect (slot);
2552 * @brief Connect a slot to Helper attach input context signal.
2554 * This signal is used to attach an input context to this helper.
2556 * When an input context requst to start this helper, then this
2557 * signal will be emitted as soon as the helper is started.
2559 * When an input context want to start an already started helper,
2560 * this signal will also be emitted.
2562 * Helper can send some events back to the IMEngineInstance in this
2563 * signal-slot, to inform that it has been started sccessfully.
2565 * The prototype of the slot is:
2567 * void attach_input_context (const HelperAgent *agent, int ic, const String &ic_uuid);
2570 HelperAgent::signal_connect_attach_input_context (HelperAgentSlotVoid *slot)
2572 return m_impl->signal_attach_input_context.connect (slot);
2576 * @brief Connect a slot to Helper detach input context signal.
2578 * This signal is used to detach an input context from this helper.
2580 * When an input context requst to stop this helper, then this
2581 * signal will be emitted.
2583 * Helper shouldn't send any event back to the IMEngineInstance, because
2584 * the IMEngineInstance attached to the ic should have been destroyed.
2586 * The prototype of the slot is:
2588 * void detach_input_context (const HelperAgent *agent, int ic, const String &ic_uuid);
2591 HelperAgent::signal_connect_detach_input_context (HelperAgentSlotVoid *slot)
2593 return m_impl->signal_detach_input_context.connect (slot);
2597 * @brief Connect a slot to Helper reload config signal.
2599 * This signal is used to let the Helper reload configuration.
2601 * The prototype of the slot is:
2603 * void reload_config (const HelperAgent *agent, int ic, const String &ic_uuid);
2606 HelperAgent::signal_connect_reload_config (HelperAgentSlotVoid *slot)
2608 return m_impl->signal_reload_config.connect (slot);
2612 * @brief Connect a slot to Helper update screen signal.
2614 * This signal is used to let the Helper move its GUI to another screen.
2615 * It can only be emitted when SCIM_HELPER_NEED_SCREEN_INFO is set in HelperInfo.option.
2617 * The prototype of the slot is:
2619 * void update_screen (const HelperAgent *agent, int ic, const String &ic_uuid, int screen_number);
2622 HelperAgent::signal_connect_update_screen (HelperAgentSlotInt *slot)
2624 return m_impl->signal_update_screen.connect (slot);
2628 * @brief Connect a slot to Helper update spot location signal.
2630 * This signal is used to let the Helper move its GUI according to the current spot location.
2631 * It can only be emitted when SCIM_HELPER_NEED_SPOT_LOCATION_INFO is set in HelperInfo.option.
2633 * The prototype of the slot is:
2634 * void update_spot_location (const HelperAgent *agent, int ic, const String &ic_uuid, int x, int y);
2637 HelperAgent::signal_connect_update_spot_location (HelperAgentSlotIntInt *slot)
2639 return m_impl->signal_update_spot_location.connect (slot);
2643 * @brief Connect a slot to Helper update cursor position signal.
2645 * This signal is used to let the Helper get the cursor position information.
2647 * The prototype of the slot is:
2648 * void update_cursor_position (const HelperAgent *agent, int ic, const String &ic_uuid, int cursor_pos);
2651 HelperAgent::signal_connect_update_cursor_position (HelperAgentSlotInt *slot)
2653 return m_impl->signal_update_cursor_position.connect (slot);
2657 * @brief Connect a slot to Helper update surrounding text signal.
2659 * This signal is used to let the Helper get the surrounding text.
2661 * The prototype of the slot is:
2662 * void update_surrounding_text (const HelperAgent *agent, int ic, const String &text, int cursor);
2665 HelperAgent::signal_connect_update_surrounding_text (HelperAgentSlotInt *slot)
2667 return m_impl->signal_update_surrounding_text.connect (slot);
2671 * @brief Connect a slot to Helper update selection signal.
2673 * This signal is used to let the Helper get the selection.
2675 * The prototype of the slot is:
2676 * void update_selection (const HelperAgent *agent, int ic, const String &text);
2679 HelperAgent::signal_connect_update_selection (HelperAgentSlotVoid *slot)
2681 return m_impl->signal_update_selection.connect (slot);
2685 * @brief Connect a slot to Helper trigger property signal.
2687 * This signal is used to trigger a property registered by this Helper.
2688 * A property will be triggered when user clicks on it.
2690 * The prototype of the slot is:
2691 * void trigger_property (const HelperAgent *agent, int ic, const String &ic_uuid, const String &property);
2694 HelperAgent::signal_connect_trigger_property (HelperAgentSlotString *slot)
2696 return m_impl->signal_trigger_property.connect (slot);
2700 * @brief Connect a slot to Helper process imengine event signal.
2702 * This signal is used to deliver the events sent from IMEngine to Helper.
2704 * The prototype of the slot is:
2705 * void process_imengine_event (const HelperAgent *agent, int ic, const String &ic_uuid, const Transaction &transaction);
2708 HelperAgent::signal_connect_process_imengine_event (HelperAgentSlotTransaction *slot)
2710 return m_impl->signal_process_imengine_event.connect (slot);
2714 * @brief Connect a slot to Helper focus out signal.
2716 * This signal is used to do something when input context is focus out.
2718 * The prototype of the slot is:
2719 * void focus_out (const HelperAgent *agent, int ic, const String &ic_uuid);
2722 HelperAgent::signal_connect_focus_out (HelperAgentSlotVoid *slot)
2724 return m_impl->signal_focus_out.connect (slot);
2728 * @brief Connect a slot to Helper focus in signal.
2730 * This signal is used to do something when input context is focus in.
2732 * The prototype of the slot is:
2733 * void focus_in (const HelperAgent *agent, int ic, const String &ic_uuid);
2736 HelperAgent::signal_connect_focus_in (HelperAgentSlotVoid *slot)
2738 return m_impl->signal_focus_in.connect (slot);
2742 * @brief Connect a slot to Helper show signal.
2744 * This signal is used to show Helper ISE window.
2746 * The prototype of the slot is:
2747 * void ise_show (const HelperAgent *agent, int ic, char *buf, size_t &len);
2750 HelperAgent::signal_connect_ise_show (HelperAgentSlotIntRawVoid *slot)
2752 return m_impl->signal_ise_show.connect (slot);
2756 * @brief Connect a slot to Helper hide signal.
2758 * This signal is used to hide Helper ISE window.
2760 * The prototype of the slot is:
2761 * void ise_hide (const HelperAgent *agent, int ic, const String &ic_uuid);
2764 HelperAgent::signal_connect_ise_hide (HelperAgentSlotVoid *slot)
2766 return m_impl->signal_ise_hide.connect (slot);
2770 * @brief Connect a slot to Helper get ISE window geometry signal.
2772 * This signal is used to get Helper ISE window size and position.
2774 * The prototype of the slot is:
2775 * void get_geometry (const HelperAgent *agent, struct rectinfo &info);
2778 HelperAgent::signal_connect_get_geometry (HelperAgentSlotSize *slot)
2780 return m_impl->signal_get_geometry.connect (slot);
2784 * @brief Connect a slot to Helper set mode signal.
2786 * This signal is used to set Helper ISE mode.
2788 * The prototype of the slot is:
2789 * void set_mode (const HelperAgent *agent, uint32 &mode);
2792 HelperAgent::signal_connect_set_mode (HelperAgentSlotUintVoid *slot)
2794 return m_impl->signal_set_mode.connect (slot);
2798 * @brief Connect a slot to Helper set language signal.
2800 * This signal is used to set Helper ISE language.
2802 * The prototype of the slot is:
2803 * void set_language (const HelperAgent *agent, uint32 &language);
2806 HelperAgent::signal_connect_set_language (HelperAgentSlotUintVoid *slot)
2808 return m_impl->signal_set_language.connect (slot);
2812 * @brief Connect a slot to Helper set im data signal.
2814 * This signal is used to send im data to Helper ISE.
2816 * The prototype of the slot is:
2817 * void set_imdata (const HelperAgent *agent, char *buf, size_t &len);
2820 HelperAgent::signal_connect_set_imdata (HelperAgentSlotRawVoid *slot)
2822 return m_impl->signal_set_imdata.connect (slot);
2826 * @brief Connect a slot to Helper get im data signal.
2828 * This signal is used to get im data from Helper ISE.
2830 * The prototype of the slot is:
2831 * void get_imdata (const HelperAgent *, char **buf, size_t &len);
2834 HelperAgent::signal_connect_get_imdata (HelperAgentSlotGetRawVoid *slot)
2836 return m_impl->signal_get_imdata.connect (slot);
2840 * @brief Connect a slot to Helper get language locale signal.
2842 * This signal is used to get language locale from Helper ISE.
2844 * The prototype of the slot is:
2845 * void get_language_locale (const HelperAgent *, int ic, char **locale);
2848 HelperAgent::signal_connect_get_language_locale (HelperAgentSlotIntGetStringVoid *slot)
2850 return m_impl->signal_get_language_locale.connect (slot);
2854 * @brief Connect a slot to Helper set return key type signal.
2856 * This signal is used to send return key type to Helper ISE.
2858 * The prototype of the slot is:
2859 * void set_return_key_type (const HelperAgent *agent, uint32 &type);
2862 HelperAgent::signal_connect_set_return_key_type (HelperAgentSlotUintVoid *slot)
2864 return m_impl->signal_set_return_key_type.connect (slot);
2868 * @brief Connect a slot to Helper get return key type signal.
2870 * This signal is used to get return key type from Helper ISE.
2872 * The prototype of the slot is:
2873 * void get_return_key_type (const HelperAgent *agent, uint32 &type);
2876 HelperAgent::signal_connect_get_return_key_type (HelperAgentSlotUintVoid *slot)
2878 return m_impl->signal_get_return_key_type.connect (slot);
2882 * @brief Connect a slot to Helper set return key disable signal.
2884 * This signal is used to send return key disable to Helper ISE.
2886 * The prototype of the slot is:
2887 * void set_return_key_disable (const HelperAgent *agent, uint32 &disabled);
2890 HelperAgent::signal_connect_set_return_key_disable (HelperAgentSlotUintVoid *slot)
2892 return m_impl->signal_set_return_key_disable.connect (slot);
2896 * @brief Connect a slot to Helper process key event signal.
2898 * This signal is used to send keyboard key event to Helper ISE.
2900 * The prototype of the slot is:
2901 * void process_key_event (const HelperAgent *agent, KeyEvent &key, uint32 &ret);
2904 HelperAgent::signal_connect_process_key_event (HelperAgentSlotKeyEventUint *slot)
2906 return m_impl->signal_process_key_event.connect (slot);
2910 * @brief Connect a slot to Helper get return key disable signal.
2912 * This signal is used to get return key disable from Helper ISE.
2914 * The prototype of the slot is:
2915 * void get_return_key_disable (const HelperAgent *agent, uint32 &disabled);
2918 HelperAgent::signal_connect_get_return_key_disable (HelperAgentSlotUintVoid *slot)
2920 return m_impl->signal_get_return_key_disable.connect (slot);
2924 * @brief Connect a slot to Helper set layout signal.
2926 * This signal is used to set Helper ISE layout.
2928 * The prototype of the slot is:
2929 * void set_layout (const HelperAgent *agent, uint32 &layout);
2932 HelperAgent::signal_connect_set_layout (HelperAgentSlotUintVoid *slot)
2934 return m_impl->signal_set_layout.connect (slot);
2938 * @brief Connect a slot to Helper get layout signal.
2940 * This signal is used to get Helper ISE layout.
2942 * The prototype of the slot is:
2943 * void get_layout (const HelperAgent *agent, uint32 &layout);
2946 HelperAgent::signal_connect_get_layout (HelperAgentSlotUintVoid *slot)
2948 return m_impl->signal_get_layout.connect (slot);
2952 * @brief Connect a slot to Helper set input mode signal.
2954 * This signal is used to set Helper ISE input mode.
2956 * The prototype of the slot is:
2957 * void set_input_mode (const HelperAgent *agent, uint32 &input_mode);
2960 HelperAgent::signal_connect_set_input_mode (HelperAgentSlotUintVoid *slot)
2962 return m_impl->signal_set_input_mode.connect (slot);
2966 * @brief Connect a slot to Helper set input hint signal.
2968 * This signal is used to set Helper ISE input hint.
2970 * The prototype of the slot is:
2971 * void set_input_hint (const HelperAgent *agent, uint32 &input_hint);
2974 HelperAgent::signal_connect_set_input_hint (HelperAgentSlotUintVoid *slot)
2976 return m_impl->signal_set_input_hint.connect (slot);
2980 * @brief Connect a slot to Helper set BiDi direction signal.
2982 * This signal is used to set Helper ISE BiDi direction.
2984 * The prototype of the slot is:
2985 * void update_bidi_direction (const HelperAgent *agent, uint32 &bidi_direction);
2988 HelperAgent::signal_connect_update_bidi_direction (HelperAgentSlotUintVoid *slot)
2990 return m_impl->signal_update_bidi_direction.connect (slot);
2994 * @brief Connect a slot to Helper set shift mode signal.
2996 * This signal is used to set Helper shift mode.
2998 * The prototype of the slot is:
2999 * void set_caps_mode (const HelperAgent *agent, uint32 &mode);
3002 HelperAgent::signal_connect_set_caps_mode (HelperAgentSlotUintVoid *slot)
3004 return m_impl->signal_set_caps_mode.connect (slot);
3008 * @brief Connect a slot to Helper reset input context signal.
3010 * This signal is used to reset Helper ISE input context.
3012 * The prototype of the slot is:
3013 * void reset_input_context (const HelperAgent *agent, int ic, const String &uuid);
3016 HelperAgent::signal_connect_reset_input_context (HelperAgentSlotVoid *slot)
3018 return m_impl->signal_reset_input_context.connect (slot);
3022 * @brief Connect a slot to Helper update candidate window geometry signal.
3024 * This signal is used to get candidate window size and position.
3026 * The prototype of the slot is:
3027 * void update_candidate_geometry (const HelperAgent *agent, int ic, const String &uuid, const rectinfo &info);
3030 HelperAgent::signal_connect_update_candidate_geometry (HelperAgentSlotRect *slot)
3032 return m_impl->signal_update_candidate_geometry.connect (slot);
3036 * @brief Connect a slot to Helper update keyboard ISE signal.
3038 * This signal is used to get current keyboard ISE name and uuid.
3040 * The prototype of the slot is:
3041 * void update_keyboard_ise (const HelperAgent *agent, int ic, const String &uuid,
3042 * const String &ise_name, const String &ise_uuid);
3045 HelperAgent::signal_connect_update_keyboard_ise (HelperAgentSlotString2 *slot)
3047 return m_impl->signal_update_keyboard_ise.connect (slot);
3051 * @brief Connect a slot to Helper update keyboard ISE list signal.
3053 * This signal is used to get uuid list of all keyboard ISEs.
3055 * The prototype of the slot is:
3056 * void update_keyboard_ise_list (const HelperAgent *agent, int ic, const String &uuid,
3057 * const std::vector<String> &ise_list);
3060 HelperAgent::signal_connect_update_keyboard_ise_list (HelperAgentSlotStringVector *slot)
3062 return m_impl->signal_update_keyboard_ise_list.connect (slot);
3066 * @brief Connect a slot to Helper candidate more window show signal.
3068 * This signal is used to do someting when candidate more window is showed.
3070 * The prototype of the slot is:
3071 * void candidate_more_window_show (const HelperAgent *agent, int ic, const String &uuid);
3074 HelperAgent::signal_connect_candidate_more_window_show (HelperAgentSlotVoid *slot)
3076 return m_impl->signal_candidate_more_window_show.connect (slot);
3080 * @brief Connect a slot to Helper candidate more window hide signal.
3082 * This signal is used to do someting when candidate more window is hidden.
3084 * The prototype of the slot is:
3085 * void candidate_more_window_hide (const HelperAgent *agent, int ic, const String &uuid);
3088 HelperAgent::signal_connect_candidate_more_window_hide (HelperAgentSlotVoid *slot)
3090 return m_impl->signal_candidate_more_window_hide.connect (slot);
3094 * @brief Connect a slot to Helper candidate show signal.
3096 * This signal is used to do candidate show.
3098 * The prototype of the slot is:
3099 * void candidate_show (const HelperAgent *agent, int ic, const String &uuid);
3102 HelperAgent::signal_connect_candidate_show (HelperAgentSlotVoid *slot)
3104 return m_impl->signal_candidate_show.connect (slot);
3108 * @brief Connect a slot to Helper candidate hide signal.
3110 * This signal is used to do candidate hide.
3112 * The prototype of the slot is:
3113 * void candidate_hide (const HelperAgent *agent, int ic, const String &uuid);
3116 HelperAgent::signal_connect_candidate_hide (HelperAgentSlotVoid *slot)
3118 return m_impl->signal_candidate_hide.connect (slot);
3122 * @brief Connect a slot to Helper update lookup table signal.
3124 * This signal is used to do someting when update lookup table.
3126 * The prototype of the slot is:
3127 * void update_lookup_table (const HelperAgent *agent, int ic, const String &uuid ,LookupTable &table);
3130 HelperAgent::signal_connect_update_lookup_table (HelperAgentSlotLookupTable *slot)
3132 return m_impl->signal_update_lookup_table.connect (slot);
3136 * @brief Connect a slot to Helper select aux signal.
3138 * This signal is used to do something when aux is selected.
3140 * The prototype of the slot is:
3141 * void select_aux (const HelperAgent *agent, int ic, const String &uuid, int index);
3144 HelperAgent::signal_connect_select_aux (HelperAgentSlotInt *slot)
3146 return m_impl->signal_select_aux.connect (slot);
3150 * @brief Connect a slot to Helper select candidate signal.
3152 * This signal is used to do something when candidate is selected.
3154 * The prototype of the slot is:
3155 * void select_candidate (const HelperAgent *agent, int ic, const String &uuid, int index);
3158 HelperAgent::signal_connect_select_candidate (HelperAgentSlotInt *slot)
3160 return m_impl->signal_select_candidate.connect (slot);
3164 * @brief Connect a slot to Helper candidate table page up signal.
3166 * This signal is used to do something when candidate table is paged up.
3168 * The prototype of the slot is:
3169 * void candidate_table_page_up (const HelperAgent *agent, int ic, const String &uuid);
3172 HelperAgent::signal_connect_candidate_table_page_up (HelperAgentSlotVoid *slot)
3174 return m_impl->signal_candidate_table_page_up.connect (slot);
3178 * @brief Connect a slot to Helper candidate table page down signal.
3180 * This signal is used to do something when candidate table is paged down.
3182 * The prototype of the slot is:
3183 * void candidate_table_page_down (const HelperAgent *agent, int ic, const String &uuid);
3186 HelperAgent::signal_connect_candidate_table_page_down (HelperAgentSlotVoid *slot)
3188 return m_impl->signal_candidate_table_page_down.connect (slot);
3192 * @brief Connect a slot to Helper update candidate table page size signal.
3194 * This signal is used to do something when candidate table page size is changed.
3196 * The prototype of the slot is:
3197 * void update_candidate_table_page_size (const HelperAgent *, int ic, const String &uuid, int page_size);
3200 HelperAgent::signal_connect_update_candidate_table_page_size (HelperAgentSlotInt *slot)
3202 return m_impl->signal_update_candidate_table_page_size.connect (slot);
3206 * @brief Connect a slot to Helper update candidate item layout signal.
3208 * The prototype of the slot is:
3209 * void update_candidate_item_layout (const HelperAgent *, const std::vector<uint32> &row_items);
3212 HelperAgent::signal_connect_update_candidate_item_layout (HelperAgentSlotUintVector *slot)
3214 return m_impl->signal_update_candidate_item_layout.connect (slot);
3218 * @brief Connect a slot to Helper select associate signal.
3220 * This signal is used to do something when associate is selected.
3222 * The prototype of the slot is:
3223 * void select_associate (const HelperAgent *agent, int ic, const String &uuid, int index);
3226 HelperAgent::signal_connect_select_associate (HelperAgentSlotInt *slot)
3228 return m_impl->signal_select_associate.connect (slot);
3232 * @brief Connect a slot to Helper associate table page up signal.
3234 * This signal is used to do something when associate table is paged up.
3236 * The prototype of the slot is:
3237 * void associate_table_page_up (const HelperAgent *agent, int ic, const String &uuid);
3240 HelperAgent::signal_connect_associate_table_page_up (HelperAgentSlotVoid *slot)
3242 return m_impl->signal_associate_table_page_up.connect (slot);
3246 * @brief Connect a slot to Helper associate table page down signal.
3248 * This signal is used to do something when associate table is paged down.
3250 * The prototype of the slot is:
3251 * void associate_table_page_down (const HelperAgent *agent, int ic, const String &uuid);
3254 HelperAgent::signal_connect_associate_table_page_down (HelperAgentSlotVoid *slot)
3256 return m_impl->signal_associate_table_page_down.connect (slot);
3260 * @brief Connect a slot to Helper update associate table page size signal.
3262 * This signal is used to do something when associate table page size is changed.
3264 * The prototype of the slot is:
3265 * void update_associate_table_page_size (const HelperAgent *, int ic, const String &uuid, int page_size);
3268 HelperAgent::signal_connect_update_associate_table_page_size (HelperAgentSlotInt *slot)
3270 return m_impl->signal_update_associate_table_page_size.connect (slot);
3274 * @brief Connect a slot to Helper turn on log signal.
3276 * This signal is used to turn on Helper ISE debug information.
3278 * The prototype of the slot is:
3279 * void turn_on_log (const HelperAgent *agent, uint32 &on);
3282 HelperAgent::signal_connect_turn_on_log (HelperAgentSlotUintVoid *slot)
3284 return m_impl->signal_turn_on_log.connect (slot);
3288 * @brief Connect a slot to Helper update displayed candidate number signal.
3290 * This signal is used to inform helper ISE displayed candidate number.
3292 * The prototype of the slot is:
3293 * void update_displayed_candidate_number (const HelperAgent *, int ic, const String &uuid, int number);
3296 HelperAgent::signal_connect_update_displayed_candidate_number (HelperAgentSlotInt *slot)
3298 return m_impl->signal_update_displayed_candidate_number.connect (slot);
3302 * @brief Connect a slot to Helper longpress candidate signal.
3304 * This signal is used to do something when candidate is longpress.
3306 * The prototype of the slot is:
3307 * void longpress_candidate (const HelperAgent *agent, int ic, const String &uuid, int index);
3310 HelperAgent::signal_connect_longpress_candidate (HelperAgentSlotInt *slot)
3312 return m_impl->signal_longpress_candidate.connect (slot);
3316 * @brief Connect a slot to Helper show option window.
3318 * This signal is used to do request the ISE to show option window.
3320 * The prototype of the slot is:
3321 * void show_option_window (const HelperAgent *agent, int ic, const String &uuid);
3324 HelperAgent::signal_connect_show_option_window (HelperAgentSlotVoid *slot)
3326 return m_impl->signal_show_option_window.connect (slot);
3330 * @brief Connect a slot to Helper resume option window.
3332 * This signal is used to do request the ISE to resume option window.
3334 * The prototype of the slot is:
3335 * void resume_option_window (const HelperAgent *agent, int ic, const String &uuid);
3338 HelperAgent::signal_connect_resume_option_window (HelperAgentSlotVoid *slot)
3340 return m_impl->signal_resume_option_window.connect (slot);
3344 * @brief Connect a slot to Helper check if the option is available.
3346 * This signal is used to check if the option (setting) is available from Helper ISE.
3348 * The prototype of the slot is:
3349 * void check_option_window (const HelperAgent *agent, uint32 &avail);
3352 HelperAgent::signal_connect_check_option_window (HelperAgentSlotUintVoid *slot)
3354 return m_impl->signal_check_option_window.connect (slot);
3358 * @brief Connect a slot to Helper process unconventional input device event signal.
3360 * This signal is used to send unconventional input device event to Helper ISE.
3362 * The prototype of the slot is:
3363 * void process_input_device_event (const HelperAgent *, uint32 &type, char *data, size_t &size, uint32 &ret);
3366 HelperAgent::signal_connect_process_input_device_event (HelperAgentSlotUintCharSizeUint *slot)
3368 return m_impl->signal_process_input_device_event.connect (slot);
3371 } /* namespace scim */
3374 vi:ts=4:nowrap:ai:expandtab