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;
161 HelperAgentSignalVoid signal_exit;
162 HelperAgentSignalVoid signal_attach_input_context;
163 HelperAgentSignalVoid signal_detach_input_context;
164 HelperAgentSignalVoid signal_reload_config;
165 HelperAgentSignalInt signal_update_screen;
166 HelperAgentSignalIntInt signal_update_spot_location;
167 HelperAgentSignalInt signal_update_cursor_position;
168 HelperAgentSignalInt signal_update_surrounding_text;
169 HelperAgentSignalVoid signal_update_selection;
170 HelperAgentSignalString signal_trigger_property;
171 HelperAgentSignalTransaction signal_process_imengine_event;
172 HelperAgentSignalVoid signal_focus_out;
173 HelperAgentSignalVoid signal_focus_in;
174 HelperAgentSignalIntRawVoid signal_ise_show;
175 HelperAgentSignalVoid signal_ise_hide;
176 HelperAgentSignalVoid signal_candidate_show;
177 HelperAgentSignalVoid signal_candidate_hide;
178 HelperAgentSignalSize signal_get_geometry;
179 HelperAgentSignalUintVoid signal_set_mode;
180 HelperAgentSignalUintVoid signal_set_language;
181 HelperAgentSignalRawVoid signal_set_imdata;
182 HelperAgentSignalGetRawVoid signal_get_imdata;
183 HelperAgentSignalIntGetStringVoid signal_get_language_locale;
184 HelperAgentSignalUintVoid signal_set_return_key_type;
185 HelperAgentSignalUintVoid signal_get_return_key_type;
186 HelperAgentSignalUintVoid signal_set_return_key_disable;
187 HelperAgentSignalUintVoid signal_get_return_key_disable;
188 HelperAgentSignalUintVoid signal_set_layout;
189 HelperAgentSignalUintVoid signal_get_layout;
190 HelperAgentSignalUintVoid signal_set_caps_mode;
191 HelperAgentSignalVoid signal_reset_input_context;
192 HelperAgentSignalIntInt signal_update_candidate_ui;
193 HelperAgentSignalRect signal_update_candidate_geometry;
194 HelperAgentSignalString2 signal_update_keyboard_ise;
195 HelperAgentSignalStringVector signal_update_keyboard_ise_list;
196 HelperAgentSignalVoid signal_candidate_more_window_show;
197 HelperAgentSignalVoid signal_candidate_more_window_hide;
198 HelperAgentSignalLookupTable signal_update_lookup_table;
199 HelperAgentSignalInt signal_select_aux;
200 HelperAgentSignalInt signal_select_candidate;
201 HelperAgentSignalVoid signal_candidate_table_page_up;
202 HelperAgentSignalVoid signal_candidate_table_page_down;
203 HelperAgentSignalInt signal_update_candidate_table_page_size;
204 HelperAgentSignalUintVector signal_update_candidate_item_layout;
205 HelperAgentSignalInt signal_select_associate;
206 HelperAgentSignalVoid signal_associate_table_page_up;
207 HelperAgentSignalVoid signal_associate_table_page_down;
208 HelperAgentSignalInt signal_update_associate_table_page_size;
209 HelperAgentSignalVoid signal_reset_ise_context;
210 HelperAgentSignalUintVoid signal_turn_on_log;
211 HelperAgentSignalInt signal_update_displayed_candidate_number;
212 HelperAgentSignalInt signal_longpress_candidate;
213 HelperAgentSignalKeyEventUint signal_process_key_event;
214 HelperAgentSignalUintVoid signal_set_input_mode;
215 HelperAgentSignalUintVoid signal_set_input_hint;
216 HelperAgentSignalUintVoid signal_update_bidi_direction;
217 HelperAgentSignalVoid signal_show_option_window;
218 HelperAgentSignalVoid signal_resume_option_window;
219 HelperAgentSignalUintVoid signal_check_option_window;
220 HelperAgentSignalUintCharSizeUint signal_process_input_device_event;
223 HelperAgentImpl (HelperAgent* thiz) : magic(0), magic_active(0), timeout(-1), focused_ic ((uint32) -1), thiz (thiz),
224 surrounding_text (NULL), selection_text (NULL), cursor_pos (0),
225 need_update_surrounding_text (0), need_update_selection_text (0),
226 layout (0), ise_show_flag (false) {
229 ~HelperAgentImpl () {
234 if (surrounding_text != NULL)
235 free (surrounding_text);
237 if (selection_text != NULL)
238 free (selection_text);
240 if (engine_module.valid ()) {
241 engine_module.unload ();
245 // Implementation of slot functions
247 slot_show_preedit_string (IMEngineInstanceBase *si)
250 thiz->show_preedit_string (focused_ic, "");
254 slot_show_aux_string (IMEngineInstanceBase *si)
257 thiz->show_aux_string ();
261 slot_show_lookup_table (IMEngineInstanceBase *si)
264 thiz->show_candidate_string ();
268 slot_hide_preedit_string (IMEngineInstanceBase *si)
271 thiz->hide_preedit_string (focused_ic, "");
275 slot_hide_aux_string (IMEngineInstanceBase *si)
278 thiz->hide_aux_string ();
282 slot_hide_lookup_table (IMEngineInstanceBase *si)
285 thiz->hide_candidate_string ();
289 slot_update_preedit_caret (IMEngineInstanceBase *si, int caret)
292 thiz->update_preedit_caret (caret);
296 slot_update_preedit_string (IMEngineInstanceBase *si,
297 const WideString & str,
298 const AttributeList & attrs,
302 thiz->update_preedit_string (-1, "", str, attrs, caret);
306 slot_update_preedit_string_with_commit (IMEngineInstanceBase *si,
307 const WideString & preedit,
308 const WideString & commit,
309 const AttributeList & attrs,
313 thiz->update_preedit_string (-1, "", preedit, commit, attrs, caret);
317 slot_update_aux_string (IMEngineInstanceBase *si,
318 const WideString & str,
319 const AttributeList & attrs)
322 thiz->update_aux_string (utf8_wcstombs(str), attrs);
326 slot_commit_string (IMEngineInstanceBase *si,
327 const WideString & str)
330 thiz->commit_string (-1, "", str);
334 slot_recapture_string (IMEngineInstanceBase *si,
337 const WideString & preedit,
338 const WideString & commit,
339 const AttributeList & attrs)
342 thiz->recapture_string (-1, "", offset, len, preedit, commit, attrs);
346 slot_forward_key_event (IMEngineInstanceBase *si,
347 const KeyEvent & key)
350 thiz->forward_key_event (-1, "", key);
354 slot_update_lookup_table (IMEngineInstanceBase *si,
355 const LookupTable & table)
358 thiz->update_candidate_string (table);
362 slot_register_properties (IMEngineInstanceBase *si,
363 const PropertyList & properties)
366 thiz->register_properties (properties);
370 slot_update_property (IMEngineInstanceBase *si,
371 const Property & property)
374 thiz->update_property (property);
378 slot_beep (IMEngineInstanceBase *si)
385 slot_start_helper (IMEngineInstanceBase *si,
386 const String &helper_uuid)
388 LOGW ("deprecated function");
392 slot_stop_helper (IMEngineInstanceBase *si,
393 const String &helper_uuid)
395 LOGW ("deprecated function");
399 slot_send_helper_event (IMEngineInstanceBase *si,
400 const String &helper_uuid,
401 const Transaction &trans)
404 signal_process_imengine_event (thiz, focused_ic, helper_uuid, trans);
408 slot_get_surrounding_text (IMEngineInstanceBase *si,
416 thiz->get_surrounding_text (maxlen_before, maxlen_after, _text, cursor);
417 text = utf8_mbstowcs(_text);
422 slot_delete_surrounding_text (IMEngineInstanceBase *si,
428 thiz->delete_surrounding_text (offset, len);
433 slot_get_selection (IMEngineInstanceBase *si,
438 thiz->get_selection_text (_text);
439 text = utf8_mbstowcs (_text);
444 slot_set_selection (IMEngineInstanceBase *si,
449 thiz->set_selection (start, end);
454 slot_expand_candidate (IMEngineInstanceBase *si)
457 thiz->expand_candidate ();
461 slot_contract_candidate (IMEngineInstanceBase *si)
464 thiz->contract_candidate ();
468 slot_set_candidate_style (IMEngineInstanceBase *si, ISF_CANDIDATE_PORTRAIT_LINE_T portrait_line, ISF_CANDIDATE_MODE_T mode)
471 thiz->set_candidate_style (portrait_line, mode);
475 slot_send_private_command (IMEngineInstanceBase *si,
476 const String &command)
479 thiz->send_private_command (command);
485 si->signal_connect_show_preedit_string (
486 slot (this, &HelperAgent::HelperAgentImpl::slot_show_preedit_string));
487 si->signal_connect_show_aux_string (
488 slot (this, &HelperAgent::HelperAgentImpl::slot_show_aux_string));
489 si->signal_connect_show_lookup_table (
490 slot (this, &HelperAgent::HelperAgentImpl::slot_show_lookup_table));
492 si->signal_connect_hide_preedit_string (
493 slot (this, &HelperAgent::HelperAgentImpl::slot_hide_preedit_string));
494 si->signal_connect_hide_aux_string (
495 slot (this, &HelperAgent::HelperAgentImpl::slot_hide_aux_string));
496 si->signal_connect_hide_lookup_table (
497 slot (this, &HelperAgent::HelperAgentImpl::slot_hide_lookup_table));
499 si->signal_connect_update_preedit_caret (
500 slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_caret));
501 si->signal_connect_update_preedit_string (
502 slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_string));
503 si->signal_connect_update_preedit_string_with_commit (
504 slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_string_with_commit));
505 si->signal_connect_recapture_string (
506 slot (this, &HelperAgent::HelperAgentImpl::slot_recapture_string));
508 si->signal_connect_update_aux_string (
509 slot (this, &HelperAgent::HelperAgentImpl::slot_update_aux_string));
510 si->signal_connect_update_lookup_table (
511 slot (this, &HelperAgent::HelperAgentImpl::slot_update_lookup_table));
513 si->signal_connect_commit_string (
514 slot (this, &HelperAgent::HelperAgentImpl::slot_commit_string));
516 si->signal_connect_forward_key_event (
517 slot (this, &HelperAgent::HelperAgentImpl::slot_forward_key_event));
519 si->signal_connect_register_properties (
520 slot (this, &HelperAgent::HelperAgentImpl::slot_register_properties));
522 si->signal_connect_update_property (
523 slot (this, &HelperAgent::HelperAgentImpl::slot_update_property));
525 si->signal_connect_beep (
526 slot (this, &HelperAgent::HelperAgentImpl::slot_beep));
528 si->signal_connect_start_helper (
529 slot (this, &HelperAgent::HelperAgentImpl::slot_start_helper));
531 si->signal_connect_stop_helper (
532 slot (this, &HelperAgent::HelperAgentImpl::slot_stop_helper));
534 si->signal_connect_send_helper_event (
535 slot (this, &HelperAgent::HelperAgentImpl::slot_send_helper_event));
537 si->signal_connect_get_surrounding_text (
538 slot (this, &HelperAgent::HelperAgentImpl::slot_get_surrounding_text));
540 si->signal_connect_delete_surrounding_text (
541 slot (this, &HelperAgent::HelperAgentImpl::slot_delete_surrounding_text));
543 si->signal_connect_get_selection (
544 slot (this, &HelperAgent::HelperAgentImpl::slot_get_selection));
546 si->signal_connect_set_selection (
547 slot (this, &HelperAgent::HelperAgentImpl::slot_set_selection));
549 si->signal_connect_expand_candidate (
550 slot (this, &HelperAgent::HelperAgentImpl::slot_expand_candidate));
551 si->signal_connect_contract_candidate (
552 slot (this, &HelperAgent::HelperAgentImpl::slot_contract_candidate));
554 si->signal_connect_set_candidate_style (
555 slot (this, &HelperAgent::HelperAgentImpl::slot_set_candidate_style));
557 si->signal_connect_send_private_command (
558 slot (this, &HelperAgent::HelperAgentImpl::slot_send_private_command));
561 void process_key_event_done (KeyEvent &key, uint32 ret, uint32 serial) {
562 LOGD ("ret: %d, serial: %d", ret, serial);
563 if (socket_active.is_connected ()) {
565 send.put_command (SCIM_TRANS_CMD_REQUEST);
566 send.put_data (magic_active);
567 send.put_command (ISM_TRANS_CMD_PROCESS_KEY_EVENT_DONE);
570 send.put_data (serial);
571 send.write_to_socket (socket_active, magic_active);
575 void request_ise_hide () {
576 if (socket_active.is_connected ()) {
578 send.put_command (SCIM_TRANS_CMD_REQUEST);
579 send.put_data (magic_active);
580 send.put_command (ISM_TRANS_CMD_REQUEST_ISE_HIDE);
581 send.write_to_socket (socket_active, magic_active);
585 HelperAgentImpl () : magic (0), magic_active (0), timeout (-1), focused_ic ((uint32) -1) { }
588 static MessageQueue message_queue;
590 HelperAgent::HelperAgent ()
591 : m_impl (new HelperAgentImpl (this))
593 message_queue.create();
596 HelperAgent::~HelperAgent ()
598 message_queue.destroy();
603 * @brief Open socket connection to the Panel.
605 * @param info The information of this Helper object.
606 * @param display The display which this Helper object should run on.
608 * @return The connection socket id. -1 means failed to create
612 HelperAgent::open_connection (const HelperInfo &info,
613 const String &display)
615 if (m_impl->socket.is_connected ())
618 SocketAddress address (scim_get_default_panel_socket_address (display));
619 int timeout = m_impl->timeout = scim_get_default_socket_timeout ();
622 if (!address.valid ())
626 std::cerr << " Connecting to PanelAgent server.";
627 ISF_LOG (" Connecting to PanelAgent server.\n");
628 while (!m_impl->socket.connect (address)) {
630 scim_usleep (100000);
632 std::cerr << "m_impl->socket.connect () is failed!!!\n";
633 ISF_LOG ("m_impl->socket.connect () is failed!!!\n");
637 std::cerr << " Connected :" << i << "\n";
638 ISF_LOG (" Connected :%d\n", i);
639 LOGD ("Connection to PanelAgent succeeded, %d\n", i);
641 /* Let's retry 10 times when failed */
642 int open_connection_retries = 0;
643 while (!scim_socket_open_connection (magic,
648 if (++open_connection_retries > 10) {
649 m_impl->socket.close ();
650 std::cerr << "scim_socket_open_connection () is failed!!!\n";
651 ISF_LOG ("scim_socket_open_connection () is failed!!!\n");
652 ISF_SAVE_LOG ("scim_socket_open_connection failed, %d\n", timeout);
657 /* Retry after re-connecting the socket */
658 if (m_impl->socket.is_connected ())
661 /* This time, just retry atmost 2 seconds */
663 while (!m_impl->socket.connect (address) && ++i < 10) {
664 scim_usleep (200000);
669 ISF_LOG ("scim_socket_open_connection () is successful.\n");
670 LOGD ("scim_socket_open_connection successful\n");
672 m_impl->send.clear ();
673 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
674 m_impl->send.put_data (magic);
675 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_REGISTER_HELPER);
676 m_impl->send.put_data (info.uuid);
677 m_impl->send.put_data (info.name);
678 m_impl->send.put_data (info.icon);
679 m_impl->send.put_data (info.description);
680 m_impl->send.put_data (info.option);
682 if (!m_impl->send.write_to_socket (m_impl->socket, magic)) {
683 m_impl->socket.close ();
688 if (m_impl->recv.read_from_socket (m_impl->socket, timeout) &&
689 m_impl->recv.get_command (cmd) && cmd == SCIM_TRANS_CMD_REPLY &&
690 m_impl->recv.get_command (cmd) && cmd == SCIM_TRANS_CMD_OK) {
691 m_impl->magic = magic;
693 while (m_impl->recv.get_command (cmd)) {
695 case SCIM_TRANS_CMD_HELPER_ATTACH_INPUT_CONTEXT:
699 while (m_impl->recv.get_data (ic) && m_impl->recv.get_data (ic_uuid))
700 m_impl->signal_attach_input_context (this, ic, ic_uuid);
703 case SCIM_TRANS_CMD_UPDATE_SCREEN:
706 if (m_impl->recv.get_data (screen))
707 m_impl->signal_update_screen (this, (uint32) -1, String (""), (int) screen);
715 //FIXME: Attaching input context is needed for desktop environment
716 LOGW ("Attach input context and update screen failed");
719 ISF_SAVE_LOG ("Trying connect() with Helper_Active\n");
721 /* connect to the panel agent as the active helper client */
722 if (!m_impl->socket_active.connect (address)) return -1;
723 open_connection_retries = 0;
724 while (!scim_socket_open_connection (magic,
725 String ("Helper_Active"),
727 m_impl->socket_active,
729 if (++open_connection_retries > 10) {
730 m_impl->socket_active.close ();
731 std::cerr << "Helper_Active scim_socket_open_connection () is failed!!!\n";
732 ISF_LOG ("Helper_Active scim_socket_open_connection () is failed!!!\n");
733 ISF_SAVE_LOG ("Helper_Active scim_socket_open_connection failed, %d\n", timeout);
738 /* Retry after re-connecting the socket */
739 if (m_impl->socket_active.is_connected ())
740 m_impl->socket_active.close ();
742 /* This time, just retry atmost 2 seconds */
744 while (!m_impl->socket_active.connect (address) && ++i < 10) {
745 scim_usleep (200000);
749 m_impl->magic_active = magic;
751 m_impl->send.clear ();
752 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
753 m_impl->send.put_data (magic);
754 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_REGISTER_ACTIVE_HELPER);
755 m_impl->send.put_data (info.uuid);
756 m_impl->send.put_data (info.name);
757 m_impl->send.put_data (info.icon);
758 m_impl->send.put_data (info.description);
759 m_impl->send.put_data (info.option);
761 if (!m_impl->send.write_to_socket (m_impl->socket_active, magic)) {
762 ISF_SAVE_LOG ("Helper_Active write_to_socket() failed\n");
763 m_impl->socket_active.close ();
766 m_impl->m_config = ConfigBase::get (false, "socket");
768 return m_impl->socket.get_id ();
772 * @brief Close the socket connection to Panel.
775 HelperAgent::close_connection ()
777 m_impl->socket.close ();
778 m_impl->socket_active.close ();
779 m_impl->send.clear ();
780 m_impl->recv.clear ();
782 m_impl->magic_active = 0;
787 * @brief Get the connection id previously returned by open_connection().
789 * @return the connection id
792 HelperAgent::get_connection_number () const
794 if (m_impl->socket.is_connected ())
795 return m_impl->socket.get_id ();
800 * @brief Check whether this HelperAgent has been connected to a Panel.
802 * Return true when it is connected to panel, otherwise return false.
805 HelperAgent::is_connected () const
807 return m_impl->socket.is_connected ();
811 * @brief Check if there are any events available to be processed.
813 * If it returns true then Helper object should call
814 * HelperAgent::filter_event() to process them.
816 * @return true if there are any events available.
819 HelperAgent::has_pending_event () const
821 if (m_impl->socket.is_connected () && m_impl->socket.wait_for_data (0) > 0)
824 if (message_queue.has_pending_message())
831 * @brief Process the pending events.
833 * This function will emit the corresponding signals according
836 * @return false if the connection is broken, otherwise return true.
839 HelperAgent::filter_event ()
841 if (!m_impl->socket.is_connected ()) {
842 LOGW("Connection lost, returning false");
846 if (m_impl->recv.read_from_socket (m_impl->socket, m_impl->timeout)) {
847 message_queue.read_from_transaction(m_impl->recv);
849 while (message_queue.has_pending_message()) {
850 MessageItem *message = message_queue.get_pending_message();
851 handle_message(message);
852 message_queue.remove_message(message);
855 LOGD("read_from_socket() failed but continuing");
863 * @brief Read messages from socket buffer, and see if there is a message with the given cmd.
865 * @return false if the connection is broken, or no message available with given cmd. Otherwise return true.
868 HelperAgent::wait_for_message(int cmd, int timeout)
870 struct timeval t0 = { 0, 0 };
871 struct timeval t1 = { 0, 0 };
873 gettimeofday(&t0, NULL);
877 if (!m_impl->socket.is_connected() || !m_impl->recv.read_from_socket(m_impl->socket, timeout))
880 message_queue.read_from_transaction(m_impl->recv);
881 if (message_queue.has_pending_message_by_cmd(cmd)) {
885 gettimeofday(&t1, NULL);
886 etime = ((t1.tv_sec * 1000000 + t1.tv_usec) - (t0.tv_sec * 1000000 + t0.tv_usec)) / 1000;
887 } while (etime < timeout);
893 * @brief Process one message that is in our message queue.
895 * This function will emit the corresponding signals according
898 * @param message The message that needs to be handled.
900 * @return false if the connection is broken, otherwise return true.
903 HelperAgent::handle_message (MessageItem *message)
908 int cmd = message->get_command_ref();
909 LOGD ("HelperAgent::cmd = %d\n", cmd);
911 case SCIM_TRANS_CMD_EXIT:
913 MessageItemExit *subclass = static_cast<MessageItemExit*>(message);
914 ISF_SAVE_LOG ("Helper ISE received SCIM_TRANS_CMD_EXIT message\n");
915 m_impl->signal_exit(this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
918 case SCIM_TRANS_CMD_RELOAD_CONFIG:
920 MessageItemReloadConfig *subclass = static_cast<MessageItemReloadConfig*>(message);
921 m_impl->signal_reload_config (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
922 if (!m_impl->m_config.null())
923 m_impl->m_config->ConfigBase::reload();
926 case SCIM_TRANS_CMD_UPDATE_SCREEN:
928 MessageItemUpdateScreen *subclass = static_cast<MessageItemUpdateScreen*>(message);
929 m_impl->signal_update_screen (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
930 subclass->get_screen_ref());
933 case SCIM_TRANS_CMD_UPDATE_SPOT_LOCATION:
935 MessageItemUpdateSpotLocation *subclass = static_cast<MessageItemUpdateSpotLocation*>(message);
936 m_impl->signal_update_spot_location (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
937 subclass->get_x_ref(), subclass->get_y_ref());
940 case ISM_TRANS_CMD_UPDATE_CURSOR_POSITION:
942 MessageItemUpdateCursorPosition *subclass = static_cast<MessageItemUpdateCursorPosition*>(message);
943 m_impl->cursor_pos = subclass->get_cursor_pos_ref();
944 LOGD ("update cursor position %d", subclass->get_cursor_pos_ref());
945 if (m_impl->ise_show_flag) {
946 m_impl->signal_update_cursor_position (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
947 subclass->get_cursor_pos_ref());
948 if (!m_impl->si.null ()) m_impl->si->update_cursor_position(subclass->get_cursor_pos_ref());
952 case ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT:
954 MessageItemUpdateSurroundingText *subclass = static_cast<MessageItemUpdateSurroundingText*>(message);
955 if (m_impl->surrounding_text != NULL)
956 free (m_impl->surrounding_text);
957 m_impl->surrounding_text = strdup (subclass->get_text_ref().c_str ());
958 m_impl->cursor_pos = subclass->get_cursor_ref();
959 LOGD ("surrounding text: %s, %d", m_impl->surrounding_text, subclass->get_cursor_ref());
960 while (m_impl->need_update_surrounding_text > 0) {
961 m_impl->need_update_surrounding_text--;
962 m_impl->signal_update_surrounding_text (this, subclass->get_ic_ref(),
963 subclass->get_text_ref(), subclass->get_cursor_ref());
967 case ISM_TRANS_CMD_UPDATE_SELECTION:
969 MessageItemUpdateSelection *subclass = static_cast<MessageItemUpdateSelection*>(message);
970 if (m_impl->selection_text != NULL)
971 free (m_impl->selection_text);
973 m_impl->selection_text = strdup (subclass->get_text_ref().c_str ());
974 LOGD ("selection text: %s", m_impl->selection_text);
976 while (m_impl->need_update_selection_text > 0) {
977 m_impl->need_update_selection_text--;
978 m_impl->signal_update_selection (this, subclass->get_ic_ref(), subclass->get_text_ref());
982 case SCIM_TRANS_CMD_TRIGGER_PROPERTY:
984 MessageItemTriggerProperty *subclass = static_cast<MessageItemTriggerProperty*>(message);
985 m_impl->signal_trigger_property (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
986 subclass->get_property_ref());
987 if (!m_impl->si.null ()) m_impl->si->trigger_property(subclass->get_property_ref());
990 case SCIM_TRANS_CMD_HELPER_PROCESS_IMENGINE_EVENT:
992 MessageItemHelperProcessImengineEvent *subclass = static_cast<MessageItemHelperProcessImengineEvent*>(message);
993 m_impl->signal_process_imengine_event (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
994 subclass->get_transaction_ref());
997 case SCIM_TRANS_CMD_HELPER_ATTACH_INPUT_CONTEXT:
999 MessageItemHelperAttachInputContext *subclass = static_cast<MessageItemHelperAttachInputContext*>(message);
1000 m_impl->signal_attach_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1003 case SCIM_TRANS_CMD_HELPER_DETACH_INPUT_CONTEXT:
1005 MessageItemHelperDetachInputContext *subclass = static_cast<MessageItemHelperDetachInputContext*>(message);
1006 m_impl->signal_detach_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1009 case SCIM_TRANS_CMD_FOCUS_OUT:
1011 MessageItemFocusOut *subclass = static_cast<MessageItemFocusOut*>(message);
1012 m_impl->signal_focus_out (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1013 m_impl->focused_ic = (uint32) -1;
1014 if (!m_impl->si.null ()) m_impl->si->focus_out();
1017 case SCIM_TRANS_CMD_FOCUS_IN:
1019 MessageItemFocusIn *subclass = static_cast<MessageItemFocusIn*>(message);
1020 m_impl->signal_focus_in (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1021 m_impl->focused_ic = subclass->get_ic_ref();
1022 if (!m_impl->si.null ()) m_impl->si->focus_in();
1023 m_impl->ise_show_flag = false;
1026 case ISM_TRANS_CMD_SHOW_ISE_PANEL:
1028 MessageItemShowISEPanel *subclass = static_cast<MessageItemShowISEPanel*>(message);
1029 LOGD ("Helper ISE received ISM_TRANS_CMD_SHOW_ISE_PANEL message\n");
1031 m_impl->signal_ise_show (this, subclass->get_ic_ref(), *(subclass->get_data_ptr()),
1032 subclass->get_len_ref());
1033 m_impl->ise_show_flag = true;
1036 case ISM_TRANS_CMD_HIDE_ISE_PANEL:
1038 MessageItemHideISEPanel *subclass = static_cast<MessageItemHideISEPanel*>(message);
1039 LOGD ("Helper ISE received ISM_TRANS_CMD_HIDE_ISE_PANEL message\n");
1040 m_impl->signal_ise_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1041 m_impl->ise_show_flag = false;
1044 case ISM_TRANS_CMD_GET_ACTIVE_ISE_GEOMETRY:
1046 struct rectinfo info = {0, 0, 0, 0};
1047 m_impl->signal_get_geometry (this, info);
1048 m_impl->send.clear ();
1049 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1050 m_impl->send.put_data (info.pos_x);
1051 m_impl->send.put_data (info.pos_y);
1052 m_impl->send.put_data (info.width);
1053 m_impl->send.put_data (info.height);
1054 m_impl->send.write_to_socket (m_impl->socket);
1057 case ISM_TRANS_CMD_SET_ISE_MODE:
1059 MessageItemSetISEMode *subclass = static_cast<MessageItemSetISEMode*>(message);
1060 m_impl->signal_set_mode (this, subclass->get_mode_ref());
1063 case ISM_TRANS_CMD_SET_ISE_LANGUAGE:
1065 MessageItemSetISELanguage *subclass = static_cast<MessageItemSetISELanguage*>(message);
1066 m_impl->signal_set_language (this, subclass->get_language_ref());
1069 case ISM_TRANS_CMD_SET_ISE_IMDATA:
1071 MessageItemSetISEImData *subclass = static_cast<MessageItemSetISEImData*>(message);
1072 m_impl->signal_set_imdata (this, *(subclass->get_imdata_ptr()), subclass->get_len_ref());
1073 if (!m_impl->si.null ()) m_impl->si->set_imdata(*(subclass->get_imdata_ptr()),
1074 subclass->get_len_ref());
1077 case ISM_TRANS_CMD_GET_ISE_IMDATA:
1082 m_impl->signal_get_imdata (this, &buf, len);
1083 LOGD ("send ise imdata len = %d", len);
1084 m_impl->send.clear ();
1085 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1086 m_impl->send.put_data (buf, len);
1087 m_impl->send.write_to_socket (m_impl->socket);
1092 case ISM_TRANS_CMD_GET_ISE_LANGUAGE_LOCALE:
1094 MessageItemGetISELanguageLocale *subclass = static_cast<MessageItemGetISELanguageLocale*>(message);
1096 m_impl->signal_get_language_locale (this, subclass->get_ic_ref(), &buf);
1097 m_impl->send.clear ();
1098 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1100 m_impl->send.put_data (buf, strlen (buf));
1101 m_impl->send.write_to_socket (m_impl->socket);
1106 case ISM_TRANS_CMD_SET_RETURN_KEY_TYPE:
1108 MessageItemSetReturnKeyType *subclass = static_cast<MessageItemSetReturnKeyType*>(message);
1109 if (m_impl->ise_show_flag) {
1110 m_impl->signal_set_return_key_type (this, subclass->get_type_ref());
1114 case ISM_TRANS_CMD_GET_RETURN_KEY_TYPE:
1117 m_impl->signal_get_return_key_type (this, type);
1118 m_impl->send.clear ();
1119 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1120 m_impl->send.put_data (type);
1121 m_impl->send.write_to_socket (m_impl->socket);
1124 case ISM_TRANS_CMD_SET_RETURN_KEY_DISABLE:
1126 MessageItemSetReturnKeyDisable *subclass = static_cast<MessageItemSetReturnKeyDisable*>(message);
1127 if (m_impl->ise_show_flag) {
1128 m_impl->signal_set_return_key_disable (this, subclass->get_disabled_ref());
1132 case ISM_TRANS_CMD_GET_RETURN_KEY_DISABLE:
1134 uint32 disabled = 0;
1135 m_impl->signal_get_return_key_type (this, disabled);
1136 m_impl->send.clear ();
1137 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1138 m_impl->send.put_data (disabled);
1139 m_impl->send.write_to_socket (m_impl->socket);
1142 case SCIM_TRANS_CMD_PROCESS_KEY_EVENT:
1144 MessageItemProcessKeyEvent *subclass = static_cast<MessageItemProcessKeyEvent*>(message);
1146 m_impl->signal_process_key_event(this, subclass->get_key_ref(), ret);
1148 if (!m_impl->si.null ())
1150 ret = m_impl->si->process_key_event (subclass->get_key_ref());
1151 LOGD("imengine(%s) process key %d return %d", m_impl->si->get_factory_uuid().c_str(),
1152 subclass->get_key_ref().code, ret);
1154 m_impl->process_key_event_done (subclass->get_key_ref(), ret, subclass->get_serial_ref());
1157 case ISM_TRANS_CMD_SET_LAYOUT:
1159 MessageItemSetLayout *subclass = static_cast<MessageItemSetLayout*>(message);
1160 m_impl->layout = subclass->get_layout_ref();
1161 if (m_impl->ise_show_flag) {
1162 m_impl->signal_set_layout (this, subclass->get_layout_ref());
1163 if (!m_impl->si.null ()) m_impl->si->set_layout(subclass->get_layout_ref());
1167 case ISM_TRANS_CMD_GET_LAYOUT:
1171 m_impl->signal_get_layout (this, layout);
1172 m_impl->send.clear ();
1173 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1174 m_impl->send.put_data (layout);
1175 m_impl->send.write_to_socket (m_impl->socket);
1178 case ISM_TRANS_CMD_SET_INPUT_MODE:
1180 MessageItemSetInputMode *subclass = static_cast<MessageItemSetInputMode*>(message);
1181 m_impl->signal_set_input_mode (this, subclass->get_input_mode_ref());
1184 case ISM_TRANS_CMD_SET_CAPS_MODE:
1186 MessageItemSetCapsMode *subclass = static_cast<MessageItemSetCapsMode*>(message);
1187 if (m_impl->ise_show_flag) {
1188 m_impl->signal_set_caps_mode (this, subclass->get_mode_ref());
1192 case SCIM_TRANS_CMD_PANEL_RESET_INPUT_CONTEXT:
1194 MessageItemPanelResetInputContext *subclass = static_cast<MessageItemPanelResetInputContext*>(message);
1195 m_impl->signal_reset_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1196 if (!m_impl->si.null ()) m_impl->si->reset();
1199 case ISM_TRANS_CMD_UPDATE_CANDIDATE_UI:
1201 MessageItemUpdateCandidateUI *subclass = static_cast<MessageItemUpdateCandidateUI*>(message);
1202 m_impl->signal_update_candidate_ui (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1203 subclass->get_style_ref(), subclass->get_mode_ref());
1206 case ISM_TRANS_CMD_UPDATE_CANDIDATE_GEOMETRY:
1208 MessageItemUpdateCandidateGeometry *subclass = static_cast<MessageItemUpdateCandidateGeometry*>(message);
1209 m_impl->signal_update_candidate_geometry (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1210 subclass->get_rectinfo_ref());
1213 case ISM_TRANS_CMD_UPDATE_KEYBOARD_ISE:
1215 MessageItemUpdateKeyboardISE *subclass = static_cast<MessageItemUpdateKeyboardISE*>(message);
1216 m_impl->signal_update_keyboard_ise (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1217 subclass->get_name_ref(), subclass->get_uuid_ref());
1220 case ISM_TRANS_CMD_UPDATE_KEYBOARD_ISE_LIST:
1222 MessageItemUpdateKeyboardISEList *subclass = static_cast<MessageItemUpdateKeyboardISEList*>(message);
1223 m_impl->signal_update_keyboard_ise_list (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1224 subclass->get_list_ref());
1227 case ISM_TRANS_CMD_CANDIDATE_MORE_WINDOW_SHOW:
1229 MessageItemCandidateMoreWindowShow *subclass = static_cast<MessageItemCandidateMoreWindowShow*>(message);
1230 m_impl->signal_candidate_more_window_show (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1231 if (!m_impl->si.null ()) m_impl->si->candidate_more_window_show();
1234 case ISM_TRANS_CMD_CANDIDATE_MORE_WINDOW_HIDE:
1236 MessageItemCandidateMoreWindowHide *subclass = static_cast<MessageItemCandidateMoreWindowHide*>(message);
1237 m_impl->signal_candidate_more_window_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1238 if (!m_impl->si.null ()) m_impl->si->candidate_more_window_hide();
1241 case ISM_TRANS_CMD_SELECT_AUX:
1243 MessageItemSelectAux *subclass = static_cast<MessageItemSelectAux*>(message);
1244 m_impl->signal_select_aux (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1245 subclass->get_item_ref());
1246 if (!m_impl->si.null ()) m_impl->si->select_aux(subclass->get_item_ref());
1249 case SCIM_TRANS_CMD_SELECT_CANDIDATE: //FIXME:remove if useless
1251 MessageItemSelectCandidate *subclass = static_cast<MessageItemSelectCandidate*>(message);
1252 m_impl->signal_select_candidate (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1253 subclass->get_item_ref());
1254 if (!m_impl->si.null ()) m_impl->si->select_candidate(subclass->get_item_ref());
1257 case SCIM_TRANS_CMD_LOOKUP_TABLE_PAGE_UP: //FIXME:remove if useless
1259 MessageItemLookupTablePageUp *subclass = static_cast<MessageItemLookupTablePageUp*>(message);
1260 m_impl->signal_candidate_table_page_up (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1261 if (!m_impl->si.null ()) m_impl->si->lookup_table_page_up();
1264 case SCIM_TRANS_CMD_LOOKUP_TABLE_PAGE_DOWN: //FIXME:remove if useless
1266 MessageItemLookupTablePageDown *subclass = static_cast<MessageItemLookupTablePageDown*>(message);
1267 m_impl->signal_candidate_table_page_down (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1268 if (!m_impl->si.null ()) m_impl->si->lookup_table_page_down();
1271 case SCIM_TRANS_CMD_UPDATE_LOOKUP_TABLE_PAGE_SIZE:
1273 MessageItemUpdateLookupTablePageSize *subclass = static_cast<MessageItemUpdateLookupTablePageSize*>(message);
1274 m_impl->signal_update_candidate_table_page_size (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1275 subclass->get_size_ref());
1276 if (!m_impl->si.null ()) m_impl->si->update_lookup_table_page_size(subclass->get_size_ref());
1279 case ISM_TRANS_CMD_CANDIDATE_SHOW: //FIXME:remove if useless
1281 MessageItemCandidateShow *subclass = static_cast<MessageItemCandidateShow*>(message);
1282 m_impl->signal_candidate_show (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1285 case ISM_TRANS_CMD_CANDIDATE_HIDE: //FIXME:remove if useless
1287 MessageItemCandidateHide *subclass = static_cast<MessageItemCandidateHide*>(message);
1288 m_impl->signal_candidate_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1291 case ISM_TRANS_CMD_UPDATE_LOOKUP_TABLE: //FIXME:remove if useless
1293 MessageItemUpdateLookupTable *subclass = static_cast<MessageItemUpdateLookupTable*>(message);
1294 m_impl->signal_update_lookup_table (this, subclass->get_candidate_table_ref());
1297 case ISM_TRANS_CMD_UPDATE_CANDIDATE_ITEM_LAYOUT:
1299 MessageItemUpdateCandidateItemLayout *subclass = static_cast<MessageItemUpdateCandidateItemLayout*>(message);
1300 m_impl->signal_update_candidate_item_layout (this, subclass->get_row_items_ref());
1301 if (!m_impl->si.null ()) m_impl->si->update_candidate_item_layout(subclass->get_row_items_ref());
1304 case ISM_TRANS_CMD_SELECT_ASSOCIATE:
1306 MessageItemSelectAssociate *subclass = static_cast<MessageItemSelectAssociate*>(message);
1307 m_impl->signal_select_associate (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1308 subclass->get_item_ref());
1311 case ISM_TRANS_CMD_ASSOCIATE_TABLE_PAGE_UP:
1313 MessageItemAssociateTablePageUp *subclass = static_cast<MessageItemAssociateTablePageUp*>(message);
1314 m_impl->signal_associate_table_page_up (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1317 case ISM_TRANS_CMD_ASSOCIATE_TABLE_PAGE_DOWN:
1319 MessageItemAssociateTablePageDown *subclass = static_cast<MessageItemAssociateTablePageDown*>(message);
1320 m_impl->signal_associate_table_page_down (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1323 case ISM_TRANS_CMD_UPDATE_ASSOCIATE_TABLE_PAGE_SIZE:
1325 MessageItemUpdateAssociateTablePageSize *subclass = static_cast<MessageItemUpdateAssociateTablePageSize*>(message);
1326 m_impl->signal_update_associate_table_page_size (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1327 subclass->get_size_ref());
1330 case ISM_TRANS_CMD_RESET_ISE_CONTEXT:
1332 MessageItemResetISEContext *subclass = static_cast<MessageItemResetISEContext*>(message);
1333 m_impl->signal_reset_ise_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1334 m_impl->signal_reset_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1335 if (!m_impl->si.null ()) m_impl->si->reset();
1338 case ISM_TRANS_CMD_TURN_ON_LOG:
1340 MessageItemTurnOnLog *subclass = static_cast<MessageItemTurnOnLog*>(message);
1341 m_impl->signal_turn_on_log (this, subclass->get_state_ref());
1344 case ISM_TRANS_CMD_UPDATE_DISPLAYED_CANDIDATE:
1346 MessageItemUpdateDisplayedCandidate *subclass = static_cast<MessageItemUpdateDisplayedCandidate*>(message);
1347 m_impl->signal_update_displayed_candidate_number (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1348 subclass->get_size_ref());
1349 if (!m_impl->si.null ()) m_impl->si->update_displayed_candidate_number(subclass->get_size_ref());
1352 case ISM_TRANS_CMD_LONGPRESS_CANDIDATE:
1354 MessageItemLongpressCandidate *subclass = static_cast<MessageItemLongpressCandidate*>(message);
1355 m_impl->signal_longpress_candidate (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1356 subclass->get_index_ref());
1357 if (!m_impl->si.null ()) m_impl->si->longpress_candidate(subclass->get_index_ref());
1360 case ISM_TRANS_CMD_SET_INPUT_HINT:
1362 MessageItemSetInputHint *subclass = static_cast<MessageItemSetInputHint*>(message);
1363 m_impl->signal_set_input_hint (this, subclass->get_input_hint_ref());
1364 if (!m_impl->si.null ()) m_impl->si->set_input_hint(subclass->get_input_hint_ref());
1367 case ISM_TRANS_CMD_UPDATE_BIDI_DIRECTION:
1369 MessageItemUpdateBidiDirection *subclass = static_cast<MessageItemUpdateBidiDirection*>(message);
1370 m_impl->signal_update_bidi_direction (this, subclass->get_bidi_direction());
1371 if (!m_impl->si.null ()) m_impl->si->update_bidi_direction(subclass->get_bidi_direction());
1374 case ISM_TRANS_CMD_SHOW_ISE_OPTION_WINDOW:
1376 MessageItemShowISEOptionWindow *subclass = static_cast<MessageItemShowISEOptionWindow*>(message);
1377 m_impl->signal_show_option_window (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1380 case ISM_TRANS_CMD_RESUME_ISE_OPTION_WINDOW:
1382 MessageItemResumeISEOptionWindow *subclass = static_cast<MessageItemResumeISEOptionWindow*>(message);
1383 m_impl->signal_resume_option_window (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1386 case ISM_TRANS_CMD_CHECK_OPTION_WINDOW:
1389 m_impl->signal_check_option_window (this, avail);
1390 m_impl->send.clear ();
1391 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1392 m_impl->send.put_data (avail);
1393 m_impl->send.write_to_socket (m_impl->socket);
1396 case ISM_TRANS_CMD_PROCESS_INPUT_DEVICE_EVENT:
1398 MessageItemProcessInputDeviceEvent *subclass = static_cast<MessageItemProcessInputDeviceEvent*>(message);
1400 m_impl->signal_process_input_device_event(this,
1401 subclass->get_type_ref(), *(subclass->get_data_ptr()), subclass->get_len_ref(), ret);
1402 m_impl->send.clear();
1403 m_impl->send.put_command(SCIM_TRANS_CMD_REPLY);
1404 m_impl->send.put_data(ret);
1405 m_impl->send.write_to_socket(m_impl->socket);
1408 case SCIM_TRANS_CMD_SET_AUTOCAPITAL_TYPE:
1410 MessageItemSetAutocapitalType *subclass = static_cast<MessageItemSetAutocapitalType*>(message);
1411 if (!m_impl->si.null ()) m_impl->si->set_autocapital_type(subclass->get_auto_capital_type_ref());
1414 case ISM_TRANS_CMD_SET_PREDICTION_ALLOW:
1416 MessageItemSetPredictionAllow *subclass = static_cast<MessageItemSetPredictionAllow*>(message);
1417 if (!m_impl->si.null ()) m_impl->si->set_prediction_allow(subclass->get_prediction_allow_ref() == 0 ? false : true);
1427 * @brief Request SCIM to reload all configuration.
1429 * This function should only by used by Setup Helper to request
1430 * scim's reloading the configuration.
1431 * Deprecated: reload config message only send by socketconfig client
1432 * using socketconfig::reload instead.
1435 HelperAgent::reload_config () const
1437 LOGD ("send reload config message to isf");
1438 if (!m_impl->m_config.null())
1439 m_impl->m_config->reload();
1443 * @brief Register some properties into Panel.
1445 * This function send the request to Panel to register a list
1448 * @param properties The list of Properties to be registered into Panel.
1450 * @sa scim::Property.
1453 HelperAgent::register_properties (const PropertyList &properties) const
1456 if (m_impl->socket_active.is_connected ()) {
1457 m_impl->send.clear ();
1458 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1459 m_impl->send.put_data (m_impl->magic_active);
1460 m_impl->send.put_command (SCIM_TRANS_CMD_REGISTER_PROPERTIES);
1461 m_impl->send.put_data (properties);
1462 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1467 * @brief Update a registered property.
1469 * @param property The property to be updated.
1472 HelperAgent::update_property (const Property &property) const
1475 if (m_impl->socket_active.is_connected ()) {
1476 m_impl->send.clear ();
1477 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1478 m_impl->send.put_data (m_impl->magic_active);
1479 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PROPERTY);
1480 m_impl->send.put_data (property);
1481 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1486 * @brief Send a set of events to an IMEngineInstance.
1488 * All events should be put into a Transaction.
1489 * And the events can only be received by one IMEngineInstance object.
1491 * @param ic The handle of the Input Context to receive the events.
1492 * @param ic_uuid The UUID of the Input Context.
1493 * @param trans The Transaction object holds the events.
1496 HelperAgent::send_imengine_event (int ic,
1497 const String &ic_uuid,
1498 const Transaction &trans) const
1501 //remove if not necessary
1503 if (m_impl->socket_active.is_connected ()) {
1504 m_impl->send.clear ();
1505 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1506 m_impl->send.put_data (m_impl->magic_active);
1507 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_SEND_IMENGINE_EVENT);
1508 m_impl->send.put_data ((uint32)ic);
1509 m_impl->send.put_data (ic_uuid);
1510 m_impl->send.put_data (trans);
1511 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1514 if (!m_impl->si.null ()) m_impl->si->process_helper_event (ic_uuid, trans);
1518 * @brief Send a KeyEvent to an IMEngineInstance.
1520 * @param ic The handle of the IMEngineInstance to receive the event.
1521 * -1 means the currently focused IMEngineInstance.
1522 * @param ic_uuid The UUID of the IMEngineInstance. Empty means don't match.
1523 * @param key The KeyEvent to be sent.
1526 HelperAgent::send_key_event (int ic,
1527 const String &ic_uuid,
1528 const KeyEvent &key) const
1532 //FIXME: remove shift_mode_off, shift_mode_on, shift_mode_lock from ISE side
1533 if (key.code == SHIFT_MODE_OFF ||
1534 key.code == SHIFT_MODE_ON ||
1535 key.code == SHIFT_MODE_LOCK ||
1536 key.code == SHIFT_MODE_ENABLE ||
1537 key.code == SHIFT_MODE_DISABLE) {
1538 LOGW("FIXME ignore shift codes");
1542 if (m_impl->socket_active.is_connected ()) {
1543 m_impl->send.clear ();
1544 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1545 m_impl->send.put_data (m_impl->magic_active);
1546 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_SEND_KEY_EVENT);
1548 m_impl->send.put_data (m_impl->focused_ic);
1550 m_impl->send.put_data ((uint32)ic);
1552 m_impl->send.put_data (ic_uuid);
1553 m_impl->send.put_data (key);
1554 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1559 * @brief Forward a KeyEvent to client application directly.
1561 * @param ic The handle of the client Input Context to receive the event.
1562 * -1 means the currently focused Input Context.
1563 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1564 * Empty means don't match.
1565 * @param key The KeyEvent to be forwarded.
1568 HelperAgent::forward_key_event (int ic,
1569 const String &ic_uuid,
1570 const KeyEvent &key) const
1573 if (m_impl->socket_active.is_connected ()) {
1574 m_impl->send.clear ();
1575 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1576 m_impl->send.put_data (m_impl->magic_active);
1577 m_impl->send.put_command (SCIM_TRANS_CMD_FORWARD_KEY_EVENT);
1579 m_impl->send.put_data (m_impl->focused_ic);
1581 m_impl->send.put_data ((uint32)ic);
1583 m_impl->send.put_data (ic_uuid);
1584 m_impl->send.put_data (key);
1585 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1590 * @brief Commit a WideString to client application directly.
1592 * @param ic The handle of the client Input Context to receive the WideString.
1593 * -1 means the currently focused Input Context.
1594 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1595 * Empty means don't match.
1596 * @param wstr The WideString to be committed.
1599 HelperAgent::commit_string (int ic,
1600 const String &ic_uuid,
1601 const WideString &wstr) const
1604 if (m_impl->socket_active.is_connected ()) {
1605 m_impl->send.clear ();
1606 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1607 m_impl->send.put_data (m_impl->magic_active);
1608 m_impl->send.put_command (SCIM_TRANS_CMD_COMMIT_STRING);
1610 m_impl->send.put_data (m_impl->focused_ic);
1612 m_impl->send.put_data ((uint32)ic);
1614 m_impl->send.put_data (ic_uuid);
1615 m_impl->send.put_data (wstr);
1616 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1621 HelperAgent::commit_string (int ic,
1622 const String &ic_uuid,
1627 if (m_impl->socket_active.is_connected ()) {
1628 m_impl->send.clear ();
1629 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1630 m_impl->send.put_data (m_impl->magic_active);
1631 m_impl->send.put_command (SCIM_TRANS_CMD_COMMIT_STRING);
1633 m_impl->send.put_data (m_impl->focused_ic);
1635 m_impl->send.put_data ((uint32)ic);
1637 m_impl->send.put_data (ic_uuid);
1638 m_impl->send.put_dataw (buf, buflen);
1639 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1644 * @brief Request to show preedit string.
1646 * @param ic The handle of the client Input Context to receive the request.
1647 * -1 means the currently focused Input Context.
1648 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1649 * Empty means don't match.
1652 HelperAgent::show_preedit_string (int ic,
1653 const String &ic_uuid) const
1657 if (m_impl->socket_active.is_connected ()) {
1658 m_impl->send.clear ();
1659 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1660 m_impl->send.put_data (m_impl->magic_active);
1661 m_impl->send.put_command (SCIM_TRANS_CMD_SHOW_PREEDIT_STRING);
1662 m_impl->send.put_data ((uint32)ic);
1663 m_impl->send.put_data (ic_uuid);
1664 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1669 * @brief Request to show aux string.
1672 HelperAgent::show_aux_string (void) const
1676 if (m_impl->socket_active.is_connected ()) {
1677 m_impl->send.clear ();
1678 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1679 m_impl->send.put_data (m_impl->magic_active);
1680 m_impl->send.put_command (SCIM_TRANS_CMD_SHOW_AUX_STRING);
1681 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1686 * @brief Request to show candidate string.
1689 HelperAgent::show_candidate_string (void) const
1693 if (m_impl->socket_active.is_connected ()) {
1694 m_impl->send.clear ();
1695 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1696 m_impl->send.put_data (m_impl->magic_active);
1697 m_impl->send.put_command (SCIM_TRANS_CMD_SHOW_LOOKUP_TABLE);
1698 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1703 * @brief Request to show associate string.
1706 HelperAgent::show_associate_string (void) const
1709 if (m_impl->socket_active.is_connected ()) {
1710 m_impl->send.clear ();
1711 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1712 m_impl->send.put_data (m_impl->magic_active);
1713 m_impl->send.put_command (ISM_TRANS_CMD_SHOW_ASSOCIATE_TABLE);
1714 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1719 * @brief Request to hide preedit string.
1721 * @param ic The handle of the client Input Context to receive the request.
1722 * -1 means the currently focused Input Context.
1723 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1724 * Empty means don't match.
1727 HelperAgent::hide_preedit_string (int ic,
1728 const String &ic_uuid) const
1732 if (m_impl->socket_active.is_connected ()) {
1733 m_impl->send.clear ();
1734 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1735 m_impl->send.put_data (m_impl->magic_active);
1736 m_impl->send.put_command (SCIM_TRANS_CMD_HIDE_PREEDIT_STRING);
1737 m_impl->send.put_data ((uint32)ic);
1738 m_impl->send.put_data (ic_uuid);
1739 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1744 * @brief Request to hide aux string.
1747 HelperAgent::hide_aux_string (void) const
1750 if (m_impl->socket_active.is_connected ()) {
1751 m_impl->send.clear ();
1752 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1753 m_impl->send.put_data (m_impl->magic_active);
1754 m_impl->send.put_command (SCIM_TRANS_CMD_HIDE_AUX_STRING);
1755 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1760 * @brief Request to hide candidate string.
1763 HelperAgent::hide_candidate_string (void) const
1766 if (m_impl->socket_active.is_connected ()) {
1767 m_impl->send.clear ();
1768 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1769 m_impl->send.put_data (m_impl->magic_active);
1770 m_impl->send.put_command (SCIM_TRANS_CMD_HIDE_LOOKUP_TABLE);
1771 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1776 * @brief Request to hide associate string.
1779 HelperAgent::hide_associate_string (void) const
1782 if (m_impl->socket_active.is_connected ()) {
1783 m_impl->send.clear ();
1784 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1785 m_impl->send.put_data (m_impl->magic_active);
1786 m_impl->send.put_command (ISM_TRANS_CMD_HIDE_ASSOCIATE_TABLE);
1787 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1792 * @brief Update a new WideString for preedit.
1794 * @param ic The handle of the client Input Context to receive the WideString.
1795 * -1 means the currently focused Input Context.
1796 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1797 * Empty means don't match.
1798 * @param str The WideString to be updated.
1799 * @param attrs The attribute list for preedit string.
1802 HelperAgent::update_preedit_string (int ic,
1803 const String &ic_uuid,
1804 const WideString &str,
1805 const AttributeList &attrs) const
1808 update_preedit_string (ic, ic_uuid, str, str, attrs, -1);
1812 HelperAgent::update_preedit_string (int ic,
1813 const String &ic_uuid,
1816 const AttributeList &attrs) const
1819 update_preedit_string (ic, ic_uuid, buf, buflen, attrs, -1);
1823 * @brief Update a new WideString for preedit.
1825 * @param ic The handle of the client Input Context to receive the WideString.
1826 * -1 means the currently focused Input Context.
1827 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1828 * Empty means don't match.
1829 * @param str The WideString to be updated.
1830 * @param attrs The attribute list for preedit string.
1831 * @param caret The caret position in preedit string.
1834 HelperAgent::update_preedit_string (int ic,
1835 const String &ic_uuid,
1836 const WideString &wstr,
1837 const AttributeList &attrs,
1841 update_preedit_string (ic, ic_uuid, wstr, wstr, attrs, caret);
1845 HelperAgent::update_preedit_string (int ic,
1846 const String &ic_uuid,
1849 const AttributeList &attrs,
1854 if (m_impl->socket_active.is_connected ()) {
1855 m_impl->send.clear ();
1856 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1857 m_impl->send.put_data (m_impl->magic_active);
1858 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING);
1859 m_impl->send.put_data ((uint32)ic);
1860 m_impl->send.put_data (ic_uuid);
1861 m_impl->send.put_dataw (buf, buflen);
1862 m_impl->send.put_dataw (buf, buflen);
1863 m_impl->send.put_data (attrs);
1864 m_impl->send.put_data (caret);
1865 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1870 HelperAgent::update_preedit_string (int ic,
1871 const String &ic_uuid,
1872 const WideString &preedit,
1873 const WideString &commit,
1874 const AttributeList &attrs,
1878 if (m_impl->socket_active.is_connected ()) {
1879 m_impl->send.clear ();
1880 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1881 m_impl->send.put_data (m_impl->magic_active);
1882 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING);
1883 m_impl->send.put_data ((uint32)ic);
1884 m_impl->send.put_data (ic_uuid);
1885 m_impl->send.put_data (preedit);
1886 m_impl->send.put_data (commit);
1887 m_impl->send.put_data (attrs);
1888 m_impl->send.put_data (caret);
1889 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1894 * @brief Update the preedit caret position in the preedit string.
1896 * @param caret - the new position of the preedit caret.
1899 HelperAgent::update_preedit_caret (int caret) const
1903 if (m_impl->socket_active.is_connected ()) {
1904 m_impl->send.clear ();
1905 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1906 m_impl->send.put_data (m_impl->magic_active);
1907 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_CARET);
1908 m_impl->send.put_data ((uint32)caret);
1909 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1914 * @brief Update a new string for aux.
1916 * @param str The string to be updated.
1917 * @param attrs The attribute list for aux string.
1920 HelperAgent::update_aux_string (const String &str,
1921 const AttributeList &attrs) const
1924 if (m_impl->socket_active.is_connected ()) {
1925 m_impl->send.clear ();
1926 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1927 m_impl->send.put_data (m_impl->magic_active);
1928 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_AUX_STRING);
1929 m_impl->send.put_data (str);
1930 m_impl->send.put_data (attrs);
1931 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1936 * @brief Request to update candidate.
1938 * @param table The lookup table for candidate.
1941 HelperAgent::update_candidate_string (const LookupTable &table) const
1944 if (m_impl->socket_active.is_connected ()) {
1945 m_impl->send.clear ();
1946 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1947 m_impl->send.put_data (m_impl->magic_active);
1948 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_LOOKUP_TABLE);
1949 m_impl->send.put_data (table);
1950 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1955 * @brief Request to update associate.
1957 * @param table The lookup table for associate.
1960 HelperAgent::update_associate_string (const LookupTable &table) const
1963 if (m_impl->socket_active.is_connected ()) {
1964 m_impl->send.clear ();
1965 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1966 m_impl->send.put_data (m_impl->magic_active);
1967 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ASSOCIATE_TABLE);
1968 m_impl->send.put_data (table);
1969 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1974 * @brief When the input context of ISE is changed,
1975 * ISE can call this function to notify application
1977 * @param type type of event.
1978 * @param value value of event.
1981 HelperAgent::update_input_context (uint32 type, uint32 value) const
1984 if (m_impl->socket_active.is_connected ()) {
1985 m_impl->send.clear ();
1986 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1987 m_impl->send.put_data (m_impl->magic_active);
1988 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ISE_INPUT_CONTEXT);
1989 m_impl->send.put_data (type);
1990 m_impl->send.put_data (value);
1991 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1996 * @brief Request to get surrounding text asynchronously.
1998 * @param uuid The helper ISE UUID.
1999 * @param maxlen_before The max length of before.
2000 * @param maxlen_after The max length of after.
2003 HelperAgent::get_surrounding_text (const String &uuid, int maxlen_before, int maxlen_after) const
2006 if (m_impl->socket_active.is_connected () && (m_impl->need_update_surrounding_text == 0)) {
2007 m_impl->send.clear ();
2008 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2009 m_impl->send.put_data (m_impl->magic_active);
2010 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SURROUNDING_TEXT);
2011 m_impl->send.put_data (uuid);
2012 m_impl->send.put_data (maxlen_before);
2013 m_impl->send.put_data (maxlen_after);
2014 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2016 m_impl->need_update_surrounding_text++;
2020 * @brief Request to get surrounding text synchronously.
2022 * @param uuid The helper ISE UUID.
2023 * @param maxlen_before The max length of before.
2024 * @param maxlen_after The max length of after.
2025 * @param text The surrounding text.
2026 * @param cursor The cursor position.
2029 HelperAgent::get_surrounding_text (int maxlen_before, int maxlen_after, String &text, int &cursor)
2033 if (!m_impl->socket_active.is_connected ())
2036 m_impl->send.clear ();
2037 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2038 m_impl->send.put_data (m_impl->magic_active);
2039 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SURROUNDING_TEXT);
2040 m_impl->send.put_data ("");
2041 m_impl->send.put_data (maxlen_before);
2042 m_impl->send.put_data (maxlen_after);
2043 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2044 if (m_impl->surrounding_text) {
2045 free (m_impl->surrounding_text);
2046 m_impl->surrounding_text = NULL;
2049 const int WAIT_FOR_SYNC_RESPONSE_TIMEOUT = 1000;
2050 /* Now we are waiting for the ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT message */
2051 if (wait_for_message(ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT, WAIT_FOR_SYNC_RESPONSE_TIMEOUT)) {
2052 MessageItem *message = message_queue.get_pending_message_by_cmd(ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT);
2053 handle_message(message);
2054 message_queue.remove_message(message);
2056 if (m_impl->surrounding_text) {
2057 text = m_impl->surrounding_text;
2058 cursor = m_impl->cursor_pos;
2062 if (m_impl->surrounding_text) {
2063 free (m_impl->surrounding_text);
2064 m_impl->surrounding_text = NULL;
2069 * @brief Request to delete surrounding text.
2071 * @param offset The offset for cursor position.
2072 * @param len The length for delete text.
2075 HelperAgent::delete_surrounding_text (int offset, int len) const
2077 LOGD ("offset = %d, len = %d", offset, len);
2079 if (m_impl->socket_active.is_connected ()) {
2080 m_impl->send.clear ();
2081 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2082 m_impl->send.put_data (m_impl->magic_active);
2083 m_impl->send.put_command (SCIM_TRANS_CMD_DELETE_SURROUNDING_TEXT);
2084 m_impl->send.put_data (offset);
2085 m_impl->send.put_data (len);
2086 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2091 * @brief Request to get selection text asynchronously.
2093 * @param uuid The helper ISE UUID.
2096 HelperAgent::get_selection (const String &uuid) const
2099 if (m_impl->socket_active.is_connected () && (m_impl->need_update_selection_text == 0)) {
2100 m_impl->send.clear ();
2101 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2102 m_impl->send.put_data (m_impl->magic_active);
2103 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SELECTION);
2104 m_impl->send.put_data (uuid);
2105 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2107 m_impl->need_update_selection_text++;
2111 * @brief Request to get selection text synchronously.
2113 * @param text The selection text.
2116 HelperAgent::get_selection_text (String &text)
2120 if (!m_impl->socket_active.is_connected ())
2123 m_impl->send.clear ();
2124 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2125 m_impl->send.put_data (m_impl->magic_active);
2126 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SELECTION);
2127 m_impl->send.put_data ("");
2128 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2129 if (m_impl->selection_text) {
2130 free (m_impl->selection_text);
2131 m_impl->selection_text = NULL;
2134 const int WAIT_FOR_SYNC_RESPONSE_TIMEOUT = 1000;
2135 /* Now we are waiting for the ISM_TRANS_CMD_UPDATE_SELECTION message */
2136 if (wait_for_message(ISM_TRANS_CMD_UPDATE_SELECTION, WAIT_FOR_SYNC_RESPONSE_TIMEOUT)) {
2137 MessageItem *message = message_queue.get_pending_message_by_cmd(ISM_TRANS_CMD_UPDATE_SELECTION);
2138 handle_message(message);
2139 message_queue.remove_message(message);
2140 if (m_impl->selection_text) {
2141 text = m_impl->selection_text;
2145 if (m_impl->selection_text) {
2146 free (m_impl->selection_text);
2147 m_impl->selection_text = NULL;
2152 * @brief Request to select text.
2154 * @param start The start position in text.
2155 * @param end The end position in text.
2158 HelperAgent::set_selection (int start, int end) const
2161 if (m_impl->socket_active.is_connected ()) {
2162 m_impl->send.clear ();
2163 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2164 m_impl->send.put_data (m_impl->magic_active);
2165 m_impl->send.put_command (SCIM_TRANS_CMD_SET_SELECTION);
2166 m_impl->send.put_data (start);
2167 m_impl->send.put_data (end);
2168 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2173 * @brief Send a private command to an application.
2175 * @param command The private command sent from IME.
2178 HelperAgent::send_private_command (const String &command) const
2181 if (m_impl->socket_active.is_connected ()) {
2182 m_impl->send.clear ();
2183 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2184 m_impl->send.put_data (m_impl->magic_active);
2185 m_impl->send.put_command (SCIM_TRANS_CMD_SEND_PRIVATE_COMMAND);
2186 m_impl->send.put_data (command);
2187 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2192 * @brief Request to get uuid list of all keyboard ISEs.
2194 * @param uuid The helper ISE UUID.
2197 HelperAgent::get_keyboard_ise_list (const String &uuid) const
2200 if (m_impl->socket_active.is_connected ()) {
2201 m_impl->send.clear ();
2202 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2203 m_impl->send.put_data (m_impl->magic_active);
2204 m_impl->send.put_command (ISM_TRANS_CMD_GET_KEYBOARD_ISE_LIST);
2205 m_impl->send.put_data (uuid);
2206 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2211 * @brief Set candidate position in screen.
2213 * @param left The x position in screen.
2214 * @param top The y position in screen.
2217 HelperAgent::set_candidate_position (int left, int top) const
2220 if (m_impl->socket_active.is_connected ()) {
2221 m_impl->send.clear ();
2222 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2223 m_impl->send.put_data (m_impl->magic_active);
2224 m_impl->send.put_command (ISM_TRANS_CMD_SET_CANDIDATE_POSITION);
2225 m_impl->send.put_data (left);
2226 m_impl->send.put_data (top);
2227 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2232 * @brief Set candidate style.
2234 * @param portrait_line - the displayed line number for portrait mode.
2235 * @param mode - candidate window mode.
2238 HelperAgent::set_candidate_style (ISF_CANDIDATE_PORTRAIT_LINE_T portrait_line,
2239 ISF_CANDIDATE_MODE_T mode) const
2242 if (m_impl->socket_active.is_connected ()) {
2243 m_impl->send.clear ();
2244 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2245 m_impl->send.put_data (m_impl->magic_active);
2246 m_impl->send.put_command (ISM_TRANS_CMD_SET_CANDIDATE_UI);
2247 m_impl->send.put_data (portrait_line);
2248 m_impl->send.put_data (mode);
2249 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2254 * @brief Request to hide candidate window.
2257 HelperAgent::candidate_hide (void) const
2260 if (m_impl->socket_active.is_connected ()) {
2261 m_impl->send.clear ();
2262 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2263 m_impl->send.put_data (m_impl->magic_active);
2264 m_impl->send.put_command (ISM_TRANS_CMD_HIDE_CANDIDATE);
2265 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2270 * @brief Request to get candidate window size and position.
2272 * @param uuid The helper ISE UUID.
2275 HelperAgent::get_candidate_window_geometry (const String &uuid) const
2278 if (m_impl->socket_active.is_connected ()) {
2279 m_impl->send.clear ();
2280 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2281 m_impl->send.put_data (m_impl->magic_active);
2282 m_impl->send.put_command (ISM_TRANS_CMD_GET_CANDIDATE_GEOMETRY);
2283 m_impl->send.put_data (uuid);
2284 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2289 * @brief Set current keyboard ISE.
2291 * @param uuid The keyboard ISE UUID.
2294 HelperAgent::set_keyboard_ise_by_uuid (const String &uuid) const
2298 IMEngineFactoryPointer factory;
2299 IMEngineModule *engine_module = NULL;
2300 static int instance_count = 1;
2302 if ((!m_impl->si.null ()) && m_impl->si->get_factory_uuid () == uuid) {
2303 LOGD ("Already in UUID: %s\n", uuid.c_str());
2307 if (!m_impl->si.null()) {
2308 m_impl->si->focus_out();
2312 if (m_impl->m_config.null ()) {
2313 LOGW ("config is not working");
2317 #ifdef HAVE_PKGMGR_INFO
2320 pkgmgrinfo_appinfo_h handle;
2321 ret = pkgmgrinfo_appinfo_get_appinfo(uuid.c_str(), &handle);
2322 if (ret != PMINFO_R_OK) {
2323 LOGW("Retrieve app info failed : %s", uuid.c_str ());
2327 ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
2328 if (ret != PMINFO_R_OK) {
2329 LOGW("Retrieve pkgid failed : %s, %p", uuid.c_str(), handle);
2330 pkgmgrinfo_appinfo_destroy_appinfo(handle);
2334 imeInfo.module_name = pkgid;
2335 pkgmgrinfo_appinfo_destroy_appinfo(handle);
2337 if (isf_db_select_ime_info_by_appid(uuid.c_str(), &imeInfo) < 1) {
2338 LOGW("ime_info row is not available for %s", uuid.c_str());
2343 engine_module = &m_impl->engine_module;
2345 if (engine_module->valid() && imeInfo.module_name != engine_module->get_module_name()) {
2346 LOGD ("imengine module %s unloaded", engine_module->get_module_name().c_str());
2347 engine_module->unload();
2350 if (!engine_module->valid()) {
2351 if (engine_module->load (imeInfo.module_name, m_impl->m_config) == false) {
2352 LOGW ("load module %s failed", imeInfo.module_name.c_str());
2355 LOGD ("imengine module %s loaded", imeInfo.module_name.c_str());
2358 for (size_t j = 0; j < engine_module->number_of_factories (); ++j) {
2361 factory = engine_module->create_factory (j);
2362 if (factory.null () == false && factory->get_uuid () == uuid)
2370 if (factory.null()) {
2371 LOGW ("imengine uuid %s is not found", uuid.c_str());
2375 m_impl->si = factory->create_instance ("UTF-8", instance_count++);
2376 if (m_impl->si.null ()) {
2377 LOGE ("create_instance %s failed",uuid.c_str ());
2381 m_impl->attach_instance ();
2382 LOGD ("Require UUID: %s Current UUID: %s", uuid.c_str (), m_impl->si->get_factory_uuid ().c_str ());
2383 m_impl->si->set_layout (m_impl->layout);
2384 if(m_impl->focused_ic != (uint32)-1)
2385 m_impl->si->focus_in ();
2389 * @brief Request to get current keyboard ISE information.
2391 * @param uuid The helper ISE UUID.
2394 HelperAgent::get_keyboard_ise (const String &uuid) const
2397 //FIXME: maybe useless
2399 if (m_impl->socket_active.is_connected ()) {
2400 m_impl->send.clear ();
2401 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2402 m_impl->send.put_data (m_impl->magic_active);
2403 m_impl->send.put_command (ISM_TRANS_CMD_GET_KEYBOARD_ISE);
2404 m_impl->send.put_data (uuid);
2405 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2411 * @brief Update ISE window geometry.
2413 * @param x The x position in screen.
2414 * @param y The y position in screen.
2415 * @param width The ISE window width.
2416 * @param height The ISE window height.
2419 HelperAgent::update_geometry (int x, int y, int width, int height) const
2422 if (m_impl->socket_active.is_connected ()) {
2423 m_impl->send.clear ();
2424 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2425 m_impl->send.put_data (m_impl->magic_active);
2426 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ISE_GEOMETRY);
2427 m_impl->send.put_data (x);
2428 m_impl->send.put_data (y);
2429 m_impl->send.put_data (width);
2430 m_impl->send.put_data (height);
2431 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2436 * @brief Request to expand candidate window.
2439 HelperAgent::expand_candidate (void) const
2442 if (m_impl->socket_active.is_connected ()) {
2443 m_impl->send.clear ();
2444 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2445 m_impl->send.put_data (m_impl->magic_active);
2446 m_impl->send.put_command (ISM_TRANS_CMD_EXPAND_CANDIDATE);
2447 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2452 * @brief Request to contract candidate window.
2455 HelperAgent::contract_candidate (void) const
2458 if (m_impl->socket_active.is_connected ()) {
2459 m_impl->send.clear ();
2460 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2461 m_impl->send.put_data (m_impl->magic_active);
2462 m_impl->send.put_command (ISM_TRANS_CMD_CONTRACT_CANDIDATE);
2463 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2468 * @brief Send selected candidate string index number.
2471 HelperAgent::select_candidate (int index) const
2474 if (!m_impl->si.null ())
2475 m_impl->si->select_candidate (index);
2476 //FIXME: maybe useless
2479 if (m_impl->socket_active.is_connected ()) {
2480 m_impl->send.clear ();
2481 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2482 m_impl->send.put_data (m_impl->magic_active);
2483 m_impl->send.put_command (ISM_TRANS_CMD_SELECT_CANDIDATE);
2484 m_impl->send.put_data (index);
2485 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2491 * @brief Update our ISE is exiting.
2494 HelperAgent::update_ise_exit (void) const
2497 //FIXME: maybe useless
2499 if (m_impl->socket_active.is_connected ()) {
2500 m_impl->send.clear ();
2501 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2502 m_impl->send.put_data (m_impl->magic_active);
2503 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ISE_EXIT);
2504 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2510 * @brief Request to reset keyboard ISE.
2513 HelperAgent::reset_keyboard_ise (void) const
2516 //FIXME: maybe useless
2518 if (m_impl->socket_active.is_connected ()) {
2519 m_impl->send.clear ();
2520 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2521 m_impl->send.put_data (m_impl->magic_active);
2522 m_impl->send.put_command (ISM_TRANS_CMD_PANEL_RESET_KEYBOARD_ISE);
2523 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2526 if (!m_impl->si.null ()) {
2527 m_impl->si->reset ();
2532 * @brief Request to flush keyboard ISE.
2535 HelperAgent::flush_keyboard_ise (void) const
2538 if (!m_impl->si.null ()) {
2539 m_impl->si->flush ();
2544 * @brief Request panel to hide ISE.
2547 HelperAgent::request_ise_hide (void) const
2550 if (m_impl->socket_active.is_connected ()) {
2551 m_impl->send.clear ();
2552 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2553 m_impl->send.put_data (m_impl->magic_active);
2554 m_impl->send.put_command (ISM_TRANS_CMD_REQUEST_ISE_HIDE);
2555 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2563 HelperAgent::recapture_string (int ic,
2564 const String &ic_uuid,
2567 const WideString &preedit_str,
2568 const WideString &commit_str,
2569 const AttributeList &attrs) const
2571 LOGD ("offset = %d, len = %d", offset, len);
2573 if (m_impl->socket_active.is_connected ()) {
2574 m_impl->send.clear ();
2575 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2576 m_impl->send.put_data (m_impl->magic_active);
2577 m_impl->send.put_command (ISM_TRANS_CMD_RECAPTURE_STRING);
2579 m_impl->send.put_data ((uint32)ic);
2580 m_impl->send.put_data (ic_uuid);
2582 // Deleting surrounding text
2583 m_impl->send.put_data (offset);
2584 m_impl->send.put_data (len);
2586 // Update preedit text
2587 m_impl->send.put_data (preedit_str);
2590 m_impl->send.put_data (commit_str);
2592 // preedit attributes
2593 m_impl->send.put_data (attrs);
2595 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2600 * @brief Connect a slot to Helper exit signal.
2602 * This signal is used to let the Helper exit.
2604 * The prototype of the slot is:
2606 * void exit (const HelperAgent *agent, int ic, const String &ic_uuid);
2609 * - agent The pointer to the HelperAgent object which emits this signal.
2610 * - ic An opaque handle of the currently focused input context.
2611 * - ic_uuid The UUID of the IMEngineInstance associated with the focused input context.
2614 HelperAgent::signal_connect_exit (HelperAgentSlotVoid *slot)
2616 return m_impl->signal_exit.connect (slot);
2620 * @brief Connect a slot to Helper attach input context signal.
2622 * This signal is used to attach an input context to this helper.
2624 * When an input context requst to start this helper, then this
2625 * signal will be emitted as soon as the helper is started.
2627 * When an input context want to start an already started helper,
2628 * this signal will also be emitted.
2630 * Helper can send some events back to the IMEngineInstance in this
2631 * signal-slot, to inform that it has been started sccessfully.
2633 * The prototype of the slot is:
2635 * void attach_input_context (const HelperAgent *agent, int ic, const String &ic_uuid);
2638 HelperAgent::signal_connect_attach_input_context (HelperAgentSlotVoid *slot)
2640 return m_impl->signal_attach_input_context.connect (slot);
2644 * @brief Connect a slot to Helper detach input context signal.
2646 * This signal is used to detach an input context from this helper.
2648 * When an input context requst to stop this helper, then this
2649 * signal will be emitted.
2651 * Helper shouldn't send any event back to the IMEngineInstance, because
2652 * the IMEngineInstance attached to the ic should have been destroyed.
2654 * The prototype of the slot is:
2656 * void detach_input_context (const HelperAgent *agent, int ic, const String &ic_uuid);
2659 HelperAgent::signal_connect_detach_input_context (HelperAgentSlotVoid *slot)
2661 return m_impl->signal_detach_input_context.connect (slot);
2665 * @brief Connect a slot to Helper reload config signal.
2667 * This signal is used to let the Helper reload configuration.
2669 * The prototype of the slot is:
2671 * void reload_config (const HelperAgent *agent, int ic, const String &ic_uuid);
2674 HelperAgent::signal_connect_reload_config (HelperAgentSlotVoid *slot)
2676 return m_impl->signal_reload_config.connect (slot);
2680 * @brief Connect a slot to Helper update screen signal.
2682 * This signal is used to let the Helper move its GUI to another screen.
2683 * It can only be emitted when SCIM_HELPER_NEED_SCREEN_INFO is set in HelperInfo.option.
2685 * The prototype of the slot is:
2687 * void update_screen (const HelperAgent *agent, int ic, const String &ic_uuid, int screen_number);
2690 HelperAgent::signal_connect_update_screen (HelperAgentSlotInt *slot)
2692 return m_impl->signal_update_screen.connect (slot);
2696 * @brief Connect a slot to Helper update spot location signal.
2698 * This signal is used to let the Helper move its GUI according to the current spot location.
2699 * It can only be emitted when SCIM_HELPER_NEED_SPOT_LOCATION_INFO is set in HelperInfo.option.
2701 * The prototype of the slot is:
2702 * void update_spot_location (const HelperAgent *agent, int ic, const String &ic_uuid, int x, int y);
2705 HelperAgent::signal_connect_update_spot_location (HelperAgentSlotIntInt *slot)
2707 return m_impl->signal_update_spot_location.connect (slot);
2711 * @brief Connect a slot to Helper update cursor position signal.
2713 * This signal is used to let the Helper get the cursor position information.
2715 * The prototype of the slot is:
2716 * void update_cursor_position (const HelperAgent *agent, int ic, const String &ic_uuid, int cursor_pos);
2719 HelperAgent::signal_connect_update_cursor_position (HelperAgentSlotInt *slot)
2721 return m_impl->signal_update_cursor_position.connect (slot);
2725 * @brief Connect a slot to Helper update surrounding text signal.
2727 * This signal is used to let the Helper get the surrounding text.
2729 * The prototype of the slot is:
2730 * void update_surrounding_text (const HelperAgent *agent, int ic, const String &text, int cursor);
2733 HelperAgent::signal_connect_update_surrounding_text (HelperAgentSlotInt *slot)
2735 return m_impl->signal_update_surrounding_text.connect (slot);
2739 * @brief Connect a slot to Helper update selection signal.
2741 * This signal is used to let the Helper get the selection.
2743 * The prototype of the slot is:
2744 * void update_selection (const HelperAgent *agent, int ic, const String &text);
2747 HelperAgent::signal_connect_update_selection (HelperAgentSlotVoid *slot)
2749 return m_impl->signal_update_selection.connect (slot);
2753 * @brief Connect a slot to Helper trigger property signal.
2755 * This signal is used to trigger a property registered by this Helper.
2756 * A property will be triggered when user clicks on it.
2758 * The prototype of the slot is:
2759 * void trigger_property (const HelperAgent *agent, int ic, const String &ic_uuid, const String &property);
2762 HelperAgent::signal_connect_trigger_property (HelperAgentSlotString *slot)
2764 return m_impl->signal_trigger_property.connect (slot);
2768 * @brief Connect a slot to Helper process imengine event signal.
2770 * This signal is used to deliver the events sent from IMEngine to Helper.
2772 * The prototype of the slot is:
2773 * void process_imengine_event (const HelperAgent *agent, int ic, const String &ic_uuid, const Transaction &transaction);
2776 HelperAgent::signal_connect_process_imengine_event (HelperAgentSlotTransaction *slot)
2778 return m_impl->signal_process_imengine_event.connect (slot);
2782 * @brief Connect a slot to Helper focus out signal.
2784 * This signal is used to do something when input context is focus out.
2786 * The prototype of the slot is:
2787 * void focus_out (const HelperAgent *agent, int ic, const String &ic_uuid);
2790 HelperAgent::signal_connect_focus_out (HelperAgentSlotVoid *slot)
2792 return m_impl->signal_focus_out.connect (slot);
2796 * @brief Connect a slot to Helper focus in signal.
2798 * This signal is used to do something when input context is focus in.
2800 * The prototype of the slot is:
2801 * void focus_in (const HelperAgent *agent, int ic, const String &ic_uuid);
2804 HelperAgent::signal_connect_focus_in (HelperAgentSlotVoid *slot)
2806 return m_impl->signal_focus_in.connect (slot);
2810 * @brief Connect a slot to Helper show signal.
2812 * This signal is used to show Helper ISE window.
2814 * The prototype of the slot is:
2815 * void ise_show (const HelperAgent *agent, int ic, char *buf, size_t &len);
2818 HelperAgent::signal_connect_ise_show (HelperAgentSlotIntRawVoid *slot)
2820 return m_impl->signal_ise_show.connect (slot);
2824 * @brief Connect a slot to Helper hide signal.
2826 * This signal is used to hide Helper ISE window.
2828 * The prototype of the slot is:
2829 * void ise_hide (const HelperAgent *agent, int ic, const String &ic_uuid);
2832 HelperAgent::signal_connect_ise_hide (HelperAgentSlotVoid *slot)
2834 return m_impl->signal_ise_hide.connect (slot);
2838 * @brief Connect a slot to Helper get ISE window geometry signal.
2840 * This signal is used to get Helper ISE window size and position.
2842 * The prototype of the slot is:
2843 * void get_geometry (const HelperAgent *agent, struct rectinfo &info);
2846 HelperAgent::signal_connect_get_geometry (HelperAgentSlotSize *slot)
2848 return m_impl->signal_get_geometry.connect (slot);
2852 * @brief Connect a slot to Helper set mode signal.
2854 * This signal is used to set Helper ISE mode.
2856 * The prototype of the slot is:
2857 * void set_mode (const HelperAgent *agent, uint32 &mode);
2860 HelperAgent::signal_connect_set_mode (HelperAgentSlotUintVoid *slot)
2862 return m_impl->signal_set_mode.connect (slot);
2866 * @brief Connect a slot to Helper set language signal.
2868 * This signal is used to set Helper ISE language.
2870 * The prototype of the slot is:
2871 * void set_language (const HelperAgent *agent, uint32 &language);
2874 HelperAgent::signal_connect_set_language (HelperAgentSlotUintVoid *slot)
2876 return m_impl->signal_set_language.connect (slot);
2880 * @brief Connect a slot to Helper set im data signal.
2882 * This signal is used to send im data to Helper ISE.
2884 * The prototype of the slot is:
2885 * void set_imdata (const HelperAgent *agent, char *buf, size_t &len);
2888 HelperAgent::signal_connect_set_imdata (HelperAgentSlotRawVoid *slot)
2890 return m_impl->signal_set_imdata.connect (slot);
2894 * @brief Connect a slot to Helper get im data signal.
2896 * This signal is used to get im data from Helper ISE.
2898 * The prototype of the slot is:
2899 * void get_imdata (const HelperAgent *, char **buf, size_t &len);
2902 HelperAgent::signal_connect_get_imdata (HelperAgentSlotGetRawVoid *slot)
2904 return m_impl->signal_get_imdata.connect (slot);
2908 * @brief Connect a slot to Helper get language locale signal.
2910 * This signal is used to get language locale from Helper ISE.
2912 * The prototype of the slot is:
2913 * void get_language_locale (const HelperAgent *, int ic, char **locale);
2916 HelperAgent::signal_connect_get_language_locale (HelperAgentSlotIntGetStringVoid *slot)
2918 return m_impl->signal_get_language_locale.connect (slot);
2922 * @brief Connect a slot to Helper set return key type signal.
2924 * This signal is used to send return key type to Helper ISE.
2926 * The prototype of the slot is:
2927 * void set_return_key_type (const HelperAgent *agent, uint32 &type);
2930 HelperAgent::signal_connect_set_return_key_type (HelperAgentSlotUintVoid *slot)
2932 return m_impl->signal_set_return_key_type.connect (slot);
2936 * @brief Connect a slot to Helper get return key type signal.
2938 * This signal is used to get return key type from Helper ISE.
2940 * The prototype of the slot is:
2941 * void get_return_key_type (const HelperAgent *agent, uint32 &type);
2944 HelperAgent::signal_connect_get_return_key_type (HelperAgentSlotUintVoid *slot)
2946 return m_impl->signal_get_return_key_type.connect (slot);
2950 * @brief Connect a slot to Helper set return key disable signal.
2952 * This signal is used to send return key disable to Helper ISE.
2954 * The prototype of the slot is:
2955 * void set_return_key_disable (const HelperAgent *agent, uint32 &disabled);
2958 HelperAgent::signal_connect_set_return_key_disable (HelperAgentSlotUintVoid *slot)
2960 return m_impl->signal_set_return_key_disable.connect (slot);
2964 * @brief Connect a slot to Helper process key event signal.
2966 * This signal is used to send keyboard key event to Helper ISE.
2968 * The prototype of the slot is:
2969 * void process_key_event (const HelperAgent *agent, KeyEvent &key, uint32 &ret);
2972 HelperAgent::signal_connect_process_key_event (HelperAgentSlotKeyEventUint *slot)
2974 return m_impl->signal_process_key_event.connect (slot);
2978 * @brief Connect a slot to Helper get return key disable signal.
2980 * This signal is used to get return key disable from Helper ISE.
2982 * The prototype of the slot is:
2983 * void get_return_key_disable (const HelperAgent *agent, uint32 &disabled);
2986 HelperAgent::signal_connect_get_return_key_disable (HelperAgentSlotUintVoid *slot)
2988 return m_impl->signal_get_return_key_disable.connect (slot);
2992 * @brief Connect a slot to Helper set layout signal.
2994 * This signal is used to set Helper ISE layout.
2996 * The prototype of the slot is:
2997 * void set_layout (const HelperAgent *agent, uint32 &layout);
3000 HelperAgent::signal_connect_set_layout (HelperAgentSlotUintVoid *slot)
3002 return m_impl->signal_set_layout.connect (slot);
3006 * @brief Connect a slot to Helper get layout signal.
3008 * This signal is used to get Helper ISE layout.
3010 * The prototype of the slot is:
3011 * void get_layout (const HelperAgent *agent, uint32 &layout);
3014 HelperAgent::signal_connect_get_layout (HelperAgentSlotUintVoid *slot)
3016 return m_impl->signal_get_layout.connect (slot);
3020 * @brief Connect a slot to Helper set input mode signal.
3022 * This signal is used to set Helper ISE input mode.
3024 * The prototype of the slot is:
3025 * void set_input_mode (const HelperAgent *agent, uint32 &input_mode);
3028 HelperAgent::signal_connect_set_input_mode (HelperAgentSlotUintVoid *slot)
3030 return m_impl->signal_set_input_mode.connect (slot);
3034 * @brief Connect a slot to Helper set input hint signal.
3036 * This signal is used to set Helper ISE input hint.
3038 * The prototype of the slot is:
3039 * void set_input_hint (const HelperAgent *agent, uint32 &input_hint);
3042 HelperAgent::signal_connect_set_input_hint (HelperAgentSlotUintVoid *slot)
3044 return m_impl->signal_set_input_hint.connect (slot);
3048 * @brief Connect a slot to Helper set BiDi direction signal.
3050 * This signal is used to set Helper ISE BiDi direction.
3052 * The prototype of the slot is:
3053 * void update_bidi_direction (const HelperAgent *agent, uint32 &bidi_direction);
3056 HelperAgent::signal_connect_update_bidi_direction (HelperAgentSlotUintVoid *slot)
3058 return m_impl->signal_update_bidi_direction.connect (slot);
3062 * @brief Connect a slot to Helper set shift mode signal.
3064 * This signal is used to set Helper shift mode.
3066 * The prototype of the slot is:
3067 * void set_caps_mode (const HelperAgent *agent, uint32 &mode);
3070 HelperAgent::signal_connect_set_caps_mode (HelperAgentSlotUintVoid *slot)
3072 return m_impl->signal_set_caps_mode.connect (slot);
3076 * @brief Connect a slot to Helper reset input context signal.
3078 * This signal is used to reset Helper ISE input context.
3080 * The prototype of the slot is:
3081 * void reset_input_context (const HelperAgent *agent, int ic, const String &uuid);
3084 HelperAgent::signal_connect_reset_input_context (HelperAgentSlotVoid *slot)
3086 return m_impl->signal_reset_input_context.connect (slot);
3090 * @brief Connect a slot to Helper update candidate window geometry signal.
3092 * This signal is used to get candidate window size and position.
3094 * The prototype of the slot is:
3095 * void update_candidate_geometry (const HelperAgent *agent, int ic, const String &uuid, const rectinfo &info);
3098 HelperAgent::signal_connect_update_candidate_geometry (HelperAgentSlotRect *slot)
3100 return m_impl->signal_update_candidate_geometry.connect (slot);
3104 * @brief Connect a slot to Helper update keyboard ISE signal.
3106 * This signal is used to get current keyboard ISE name and uuid.
3108 * The prototype of the slot is:
3109 * void update_keyboard_ise (const HelperAgent *agent, int ic, const String &uuid,
3110 * const String &ise_name, const String &ise_uuid);
3113 HelperAgent::signal_connect_update_keyboard_ise (HelperAgentSlotString2 *slot)
3115 return m_impl->signal_update_keyboard_ise.connect (slot);
3119 * @brief Connect a slot to Helper update keyboard ISE list signal.
3121 * This signal is used to get uuid list of all keyboard ISEs.
3123 * The prototype of the slot is:
3124 * void update_keyboard_ise_list (const HelperAgent *agent, int ic, const String &uuid,
3125 * const std::vector<String> &ise_list);
3128 HelperAgent::signal_connect_update_keyboard_ise_list (HelperAgentSlotStringVector *slot)
3130 return m_impl->signal_update_keyboard_ise_list.connect (slot);
3134 * @brief Connect a slot to Helper candidate more window show signal.
3136 * This signal is used to do someting when candidate more window is showed.
3138 * The prototype of the slot is:
3139 * void candidate_more_window_show (const HelperAgent *agent, int ic, const String &uuid);
3142 HelperAgent::signal_connect_candidate_more_window_show (HelperAgentSlotVoid *slot)
3144 return m_impl->signal_candidate_more_window_show.connect (slot);
3148 * @brief Connect a slot to Helper candidate more window hide signal.
3150 * This signal is used to do someting when candidate more window is hidden.
3152 * The prototype of the slot is:
3153 * void candidate_more_window_hide (const HelperAgent *agent, int ic, const String &uuid);
3156 HelperAgent::signal_connect_candidate_more_window_hide (HelperAgentSlotVoid *slot)
3158 return m_impl->signal_candidate_more_window_hide.connect (slot);
3162 * @brief Connect a slot to Helper candidate show signal.
3164 * This signal is used to do candidate show.
3166 * The prototype of the slot is:
3167 * void candidate_show (const HelperAgent *agent, int ic, const String &uuid);
3170 HelperAgent::signal_connect_candidate_show (HelperAgentSlotVoid *slot)
3172 return m_impl->signal_candidate_show.connect (slot);
3176 * @brief Connect a slot to Helper candidate hide signal.
3178 * This signal is used to do candidate hide.
3180 * The prototype of the slot is:
3181 * void candidate_hide (const HelperAgent *agent, int ic, const String &uuid);
3184 HelperAgent::signal_connect_candidate_hide (HelperAgentSlotVoid *slot)
3186 return m_impl->signal_candidate_hide.connect (slot);
3190 * @brief Connect a slot to Helper update lookup table signal.
3192 * This signal is used to do someting when update lookup table.
3194 * The prototype of the slot is:
3195 * void update_lookup_table (const HelperAgent *agent, int ic, const String &uuid ,LookupTable &table);
3198 HelperAgent::signal_connect_update_lookup_table (HelperAgentSlotLookupTable *slot)
3200 return m_impl->signal_update_lookup_table.connect (slot);
3204 * @brief Connect a slot to Helper select aux signal.
3206 * This signal is used to do something when aux is selected.
3208 * The prototype of the slot is:
3209 * void select_aux (const HelperAgent *agent, int ic, const String &uuid, int index);
3212 HelperAgent::signal_connect_select_aux (HelperAgentSlotInt *slot)
3214 return m_impl->signal_select_aux.connect (slot);
3218 * @brief Connect a slot to Helper select candidate signal.
3220 * This signal is used to do something when candidate is selected.
3222 * The prototype of the slot is:
3223 * void select_candidate (const HelperAgent *agent, int ic, const String &uuid, int index);
3226 HelperAgent::signal_connect_select_candidate (HelperAgentSlotInt *slot)
3228 return m_impl->signal_select_candidate.connect (slot);
3232 * @brief Connect a slot to Helper candidate table page up signal.
3234 * This signal is used to do something when candidate table is paged up.
3236 * The prototype of the slot is:
3237 * void candidate_table_page_up (const HelperAgent *agent, int ic, const String &uuid);
3240 HelperAgent::signal_connect_candidate_table_page_up (HelperAgentSlotVoid *slot)
3242 return m_impl->signal_candidate_table_page_up.connect (slot);
3246 * @brief Connect a slot to Helper candidate table page down signal.
3248 * This signal is used to do something when candidate table is paged down.
3250 * The prototype of the slot is:
3251 * void candidate_table_page_down (const HelperAgent *agent, int ic, const String &uuid);
3254 HelperAgent::signal_connect_candidate_table_page_down (HelperAgentSlotVoid *slot)
3256 return m_impl->signal_candidate_table_page_down.connect (slot);
3260 * @brief Connect a slot to Helper update candidate table page size signal.
3262 * This signal is used to do something when candidate table page size is changed.
3264 * The prototype of the slot is:
3265 * void update_candidate_table_page_size (const HelperAgent *, int ic, const String &uuid, int page_size);
3268 HelperAgent::signal_connect_update_candidate_table_page_size (HelperAgentSlotInt *slot)
3270 return m_impl->signal_update_candidate_table_page_size.connect (slot);
3274 * @brief Connect a slot to Helper update candidate item layout signal.
3276 * The prototype of the slot is:
3277 * void update_candidate_item_layout (const HelperAgent *, const std::vector<uint32> &row_items);
3280 HelperAgent::signal_connect_update_candidate_item_layout (HelperAgentSlotUintVector *slot)
3282 return m_impl->signal_update_candidate_item_layout.connect (slot);
3286 * @brief Connect a slot to Helper select associate signal.
3288 * This signal is used to do something when associate is selected.
3290 * The prototype of the slot is:
3291 * void select_associate (const HelperAgent *agent, int ic, const String &uuid, int index);
3294 HelperAgent::signal_connect_select_associate (HelperAgentSlotInt *slot)
3296 return m_impl->signal_select_associate.connect (slot);
3300 * @brief Connect a slot to Helper associate table page up signal.
3302 * This signal is used to do something when associate table is paged up.
3304 * The prototype of the slot is:
3305 * void associate_table_page_up (const HelperAgent *agent, int ic, const String &uuid);
3308 HelperAgent::signal_connect_associate_table_page_up (HelperAgentSlotVoid *slot)
3310 return m_impl->signal_associate_table_page_up.connect (slot);
3314 * @brief Connect a slot to Helper associate table page down signal.
3316 * This signal is used to do something when associate table is paged down.
3318 * The prototype of the slot is:
3319 * void associate_table_page_down (const HelperAgent *agent, int ic, const String &uuid);
3322 HelperAgent::signal_connect_associate_table_page_down (HelperAgentSlotVoid *slot)
3324 return m_impl->signal_associate_table_page_down.connect (slot);
3328 * @brief Connect a slot to Helper update associate table page size signal.
3330 * This signal is used to do something when associate table page size is changed.
3332 * The prototype of the slot is:
3333 * void update_associate_table_page_size (const HelperAgent *, int ic, const String &uuid, int page_size);
3336 HelperAgent::signal_connect_update_associate_table_page_size (HelperAgentSlotInt *slot)
3338 return m_impl->signal_update_associate_table_page_size.connect (slot);
3342 * @brief Connect a slot to Helper turn on log signal.
3344 * This signal is used to turn on Helper ISE debug information.
3346 * The prototype of the slot is:
3347 * void turn_on_log (const HelperAgent *agent, uint32 &on);
3350 HelperAgent::signal_connect_turn_on_log (HelperAgentSlotUintVoid *slot)
3352 return m_impl->signal_turn_on_log.connect (slot);
3356 * @brief Connect a slot to Helper update displayed candidate number signal.
3358 * This signal is used to inform helper ISE displayed candidate number.
3360 * The prototype of the slot is:
3361 * void update_displayed_candidate_number (const HelperAgent *, int ic, const String &uuid, int number);
3364 HelperAgent::signal_connect_update_displayed_candidate_number (HelperAgentSlotInt *slot)
3366 return m_impl->signal_update_displayed_candidate_number.connect (slot);
3370 * @brief Connect a slot to Helper longpress candidate signal.
3372 * This signal is used to do something when candidate is longpress.
3374 * The prototype of the slot is:
3375 * void longpress_candidate (const HelperAgent *agent, int ic, const String &uuid, int index);
3378 HelperAgent::signal_connect_longpress_candidate (HelperAgentSlotInt *slot)
3380 return m_impl->signal_longpress_candidate.connect (slot);
3384 * @brief Connect a slot to Helper show option window.
3386 * This signal is used to do request the ISE to show option window.
3388 * The prototype of the slot is:
3389 * void show_option_window (const HelperAgent *agent, int ic, const String &uuid);
3392 HelperAgent::signal_connect_show_option_window (HelperAgentSlotVoid *slot)
3394 return m_impl->signal_show_option_window.connect (slot);
3398 * @brief Connect a slot to Helper resume option window.
3400 * This signal is used to do request the ISE to resume option window.
3402 * The prototype of the slot is:
3403 * void resume_option_window (const HelperAgent *agent, int ic, const String &uuid);
3406 HelperAgent::signal_connect_resume_option_window (HelperAgentSlotVoid *slot)
3408 return m_impl->signal_resume_option_window.connect (slot);
3412 * @brief Connect a slot to Helper check if the option is available.
3414 * This signal is used to check if the option (setting) is available from Helper ISE.
3416 * The prototype of the slot is:
3417 * void check_option_window (const HelperAgent *agent, uint32 &avail);
3420 HelperAgent::signal_connect_check_option_window (HelperAgentSlotUintVoid *slot)
3422 return m_impl->signal_check_option_window.connect (slot);
3426 * @brief Connect a slot to Helper process unconventional input device event signal.
3428 * This signal is used to send unconventional input device event to Helper ISE.
3430 * The prototype of the slot is:
3431 * void process_input_device_event (const HelperAgent *, uint32 &type, char *data, size_t &size, uint32 &ret);
3434 HelperAgent::signal_connect_process_input_device_event (HelperAgentSlotUintCharSizeUint *slot)
3436 return m_impl->signal_process_input_device_event.connect (slot);
3439 } /* namespace scim */
3442 vi:ts=4:nowrap:ai:expandtab