1 /** @file scim_helper.cpp
2 * @brief Implementation of class HelperAgent.
5 /* ISF is based on SCIM 1.4.7 and extended for supporting more mobile fitable. */
8 * Smart Common Input Method
10 * Copyright (c) 2004-2005 James Su <suzhe@tsinghua.org.cn>
11 * Copyright (c) 2012-2015 Samsung Electronics Co., Ltd.
14 * This library is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU Lesser General Public
16 * License as published by the Free Software Foundation; either
17 * version 2 of the License, or (at your option) any later version.
19 * This library is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License for more details.
24 * You should have received a copy of the GNU Lesser General Public
25 * License along with this program; if not, write to the
26 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
27 * Boston, MA 02111-1307 USA
29 * Modifications by Samsung Electronics Co., Ltd.
30 * 1. Add new interface APIs for keyboard ISE
31 * a. expand_candidate (), contract_candidate () and set_candidate_style ()
32 * b. set_keyboard_ise_by_uuid () and reset_keyboard_ise ()
33 * c. get_surrounding_text () and delete_surrounding_text ()
34 * d. show_preedit_string (), hide_preedit_string (), update_preedit_string () and update_preedit_caret ()
35 * e. show_candidate_string (), hide_candidate_string () and update_candidate_string ()
37 * $Id: scim_helper.cpp,v 1.13 2005/05/24 12:22:51 suzhe Exp $
41 #define Uses_SCIM_TRANSACTION
42 #define Uses_SCIM_TRANS_COMMANDS
43 #define Uses_SCIM_HELPER
44 #define Uses_SCIM_SOCKET
45 #define Uses_SCIM_EVENT
46 #define Uses_SCIM_BACKEND
47 #define Uses_SCIM_IMENGINE_MODULE
53 #include "scim_private.h"
55 #include <scim_panel_common.h>
56 #include "isf_query_utility.h"
58 #include "isf_debug.h"
59 #include "isf_message_queue.h"
60 #ifdef HAVE_PKGMGR_INFO
61 #include <pkgmgr-info.h>
62 #endif // HAVE_PKGMGR_INFO
67 #define LOG_TAG "SCIM_HELPER"
70 //FIXME: remove this definitions
71 #define SHIFT_MODE_OFF 0xffe1
72 #define SHIFT_MODE_ON 0xffe2
73 #define SHIFT_MODE_LOCK 0xffe6
74 #define SHIFT_MODE_ENABLE 0x9fe7
75 #define SHIFT_MODE_DISABLE 0x9fe8
79 typedef Signal3<void, const HelperAgent *, int, const String &>
80 HelperAgentSignalVoid;
82 typedef Signal4<void, const HelperAgent *, int, const String &, const String &>
83 HelperAgentSignalString;
85 typedef Signal4<void, const HelperAgent *, int, const String &, const std::vector<String> &>
86 HelperAgentSignalStringVector;
88 typedef Signal5<void, const HelperAgent *, int, const String &, const String &, const String &>
89 HelperAgentSignalString2;
91 typedef Signal4<void, const HelperAgent *, int, const String &, int>
94 typedef Signal5<void, const HelperAgent *, int, const String &, int, int>
95 HelperAgentSignalIntInt;
97 typedef Signal4<void, const HelperAgent *, int, const String &, const Transaction &>
98 HelperAgentSignalTransaction;
100 typedef Signal4<void, const HelperAgent *, int, const String &, const rectinfo &>
101 HelperAgentSignalRect;
103 typedef Signal2<void, const HelperAgent *, struct rectinfo &>
104 HelperAgentSignalSize;
106 typedef Signal2<void, const HelperAgent *, uint32 &>
107 HelperAgentSignalUintVoid;
109 typedef Signal3<void, const HelperAgent *, int, uint32 &>
110 HelperAgentSignalIntUint;
112 typedef Signal3 <void, const HelperAgent *, char *, size_t &>
113 HelperAgentSignalRawVoid;
115 typedef Signal3 <void, const HelperAgent *, char **, size_t &>
116 HelperAgentSignalGetRawVoid;
118 typedef Signal4 <void, const HelperAgent *, int, char *, size_t &>
119 HelperAgentSignalIntRawVoid;
121 typedef Signal3 <void, const HelperAgent *, int, char **>
122 HelperAgentSignalIntGetStringVoid;
124 typedef Signal2<void, const HelperAgent *, const std::vector<uint32> &>
125 HelperAgentSignalUintVector;
127 typedef Signal2<void, const HelperAgent *, LookupTable &>
128 HelperAgentSignalLookupTable;
130 typedef Signal3<void, const HelperAgent *, KeyEvent &, uint32 &>
131 HelperAgentSignalKeyEventUint;
133 typedef Signal5<void, const HelperAgent *, uint32 &, char *, size_t &, uint32 &>
134 HelperAgentSignalUintCharSizeUint;
136 class HelperAgent::HelperAgentImpl
140 SocketClient socket_active;
149 IMEngineInstancePointer si;
150 ConfigPointer m_config;
151 IMEngineModule engine_module;
153 char* surrounding_text;
154 char* selection_text;
156 int need_update_surrounding_text;
157 int need_update_selection_text;
160 bool hw_keyboard_mode;
162 HelperAgentSignalVoid signal_exit;
163 HelperAgentSignalVoid signal_attach_input_context;
164 HelperAgentSignalVoid signal_detach_input_context;
165 HelperAgentSignalVoid signal_reload_config;
166 HelperAgentSignalInt signal_update_screen;
167 HelperAgentSignalIntInt signal_update_spot_location;
168 HelperAgentSignalInt signal_update_cursor_position;
169 HelperAgentSignalInt signal_update_surrounding_text;
170 HelperAgentSignalVoid signal_update_selection;
171 HelperAgentSignalString signal_trigger_property;
172 HelperAgentSignalTransaction signal_process_imengine_event;
173 HelperAgentSignalVoid signal_focus_out;
174 HelperAgentSignalVoid signal_focus_in;
175 HelperAgentSignalIntRawVoid signal_ise_show;
176 HelperAgentSignalVoid signal_ise_hide;
177 HelperAgentSignalVoid signal_candidate_show;
178 HelperAgentSignalVoid signal_candidate_hide;
179 HelperAgentSignalSize signal_get_geometry;
180 HelperAgentSignalUintVoid signal_set_mode;
181 HelperAgentSignalUintVoid signal_set_language;
182 HelperAgentSignalRawVoid signal_set_imdata;
183 HelperAgentSignalGetRawVoid signal_get_imdata;
184 HelperAgentSignalIntGetStringVoid signal_get_language_locale;
185 HelperAgentSignalUintVoid signal_set_return_key_type;
186 HelperAgentSignalUintVoid signal_get_return_key_type;
187 HelperAgentSignalUintVoid signal_set_return_key_disable;
188 HelperAgentSignalUintVoid signal_get_return_key_disable;
189 HelperAgentSignalUintVoid signal_set_layout;
190 HelperAgentSignalUintVoid signal_get_layout;
191 HelperAgentSignalUintVoid signal_set_caps_mode;
192 HelperAgentSignalVoid signal_reset_input_context;
193 HelperAgentSignalIntInt signal_update_candidate_ui;
194 HelperAgentSignalRect signal_update_candidate_geometry;
195 HelperAgentSignalString2 signal_update_keyboard_ise;
196 HelperAgentSignalStringVector signal_update_keyboard_ise_list;
197 HelperAgentSignalVoid signal_candidate_more_window_show;
198 HelperAgentSignalVoid signal_candidate_more_window_hide;
199 HelperAgentSignalLookupTable signal_update_lookup_table;
200 HelperAgentSignalInt signal_select_aux;
201 HelperAgentSignalInt signal_select_candidate;
202 HelperAgentSignalVoid signal_candidate_table_page_up;
203 HelperAgentSignalVoid signal_candidate_table_page_down;
204 HelperAgentSignalInt signal_update_candidate_table_page_size;
205 HelperAgentSignalUintVector signal_update_candidate_item_layout;
206 HelperAgentSignalInt signal_select_associate;
207 HelperAgentSignalVoid signal_associate_table_page_up;
208 HelperAgentSignalVoid signal_associate_table_page_down;
209 HelperAgentSignalInt signal_update_associate_table_page_size;
210 HelperAgentSignalVoid signal_reset_ise_context;
211 HelperAgentSignalUintVoid signal_turn_on_log;
212 HelperAgentSignalInt signal_update_displayed_candidate_number;
213 HelperAgentSignalInt signal_longpress_candidate;
214 HelperAgentSignalKeyEventUint signal_process_key_event;
215 HelperAgentSignalUintVoid signal_set_input_mode;
216 HelperAgentSignalUintVoid signal_set_input_hint;
217 HelperAgentSignalUintVoid signal_update_bidi_direction;
218 HelperAgentSignalVoid signal_show_option_window;
219 HelperAgentSignalVoid signal_resume_option_window;
220 HelperAgentSignalUintVoid signal_check_option_window;
221 HelperAgentSignalUintCharSizeUint signal_process_input_device_event;
224 HelperAgentImpl (HelperAgent* thiz) : magic(0), magic_active(0), timeout(-1), focused_ic ((uint32) -1), thiz (thiz),
225 surrounding_text (NULL), selection_text (NULL), cursor_pos (0),
226 need_update_surrounding_text (0), need_update_selection_text (0),
227 layout (0), ise_show_flag (false), hw_keyboard_mode (false) {
230 ~HelperAgentImpl () {
235 if (surrounding_text != NULL)
236 free (surrounding_text);
238 if (selection_text != NULL)
239 free (selection_text);
241 if (engine_module.valid ()) {
242 engine_module.unload ();
246 // Implementation of slot functions
248 slot_show_preedit_string (IMEngineInstanceBase *si)
251 thiz->show_preedit_string (focused_ic, "");
255 slot_show_aux_string (IMEngineInstanceBase *si)
258 thiz->show_aux_string ();
262 slot_show_lookup_table (IMEngineInstanceBase *si)
265 thiz->show_candidate_string ();
269 slot_hide_preedit_string (IMEngineInstanceBase *si)
272 thiz->hide_preedit_string (focused_ic, "");
276 slot_hide_aux_string (IMEngineInstanceBase *si)
279 thiz->hide_aux_string ();
283 slot_hide_lookup_table (IMEngineInstanceBase *si)
286 thiz->hide_candidate_string ();
290 slot_update_preedit_caret (IMEngineInstanceBase *si, int caret)
293 thiz->update_preedit_caret (caret);
297 slot_update_preedit_string (IMEngineInstanceBase *si,
298 const WideString & str,
299 const AttributeList & attrs,
303 thiz->update_preedit_string (-1, "", str, attrs, caret);
307 slot_update_preedit_string_with_commit (IMEngineInstanceBase *si,
308 const WideString & preedit,
309 const WideString & commit,
310 const AttributeList & attrs,
314 thiz->update_preedit_string (-1, "", preedit, commit, attrs, caret);
318 slot_update_aux_string (IMEngineInstanceBase *si,
319 const WideString & str,
320 const AttributeList & attrs)
323 thiz->update_aux_string (utf8_wcstombs(str), attrs);
327 slot_commit_string (IMEngineInstanceBase *si,
328 const WideString & str)
331 thiz->commit_string (-1, "", str);
335 slot_recapture_string (IMEngineInstanceBase *si,
338 const WideString & preedit,
339 const WideString & commit,
340 const AttributeList & attrs)
343 thiz->recapture_string (-1, "", offset, len, preedit, commit, attrs);
347 slot_forward_key_event (IMEngineInstanceBase *si,
348 const KeyEvent & key)
351 thiz->forward_key_event (-1, "", key);
355 slot_update_lookup_table (IMEngineInstanceBase *si,
356 const LookupTable & table)
359 thiz->update_candidate_string (table);
363 slot_register_properties (IMEngineInstanceBase *si,
364 const PropertyList & properties)
367 thiz->register_properties (properties);
371 slot_update_property (IMEngineInstanceBase *si,
372 const Property & property)
375 thiz->update_property (property);
379 slot_beep (IMEngineInstanceBase *si)
386 slot_start_helper (IMEngineInstanceBase *si,
387 const String &helper_uuid)
389 LOGW ("deprecated function");
393 slot_stop_helper (IMEngineInstanceBase *si,
394 const String &helper_uuid)
396 LOGW ("deprecated function");
400 slot_send_helper_event (IMEngineInstanceBase *si,
401 const String &helper_uuid,
402 const Transaction &trans)
405 signal_process_imengine_event (thiz, focused_ic, helper_uuid, trans);
409 slot_get_surrounding_text (IMEngineInstanceBase *si,
417 thiz->get_surrounding_text (maxlen_before, maxlen_after, _text, cursor);
418 text = utf8_mbstowcs(_text);
423 slot_delete_surrounding_text (IMEngineInstanceBase *si,
429 thiz->delete_surrounding_text (offset, len);
434 slot_get_selection (IMEngineInstanceBase *si,
439 thiz->get_selection_text (_text);
440 text = utf8_mbstowcs (_text);
445 slot_set_selection (IMEngineInstanceBase *si,
450 thiz->set_selection (start, end);
455 slot_expand_candidate (IMEngineInstanceBase *si)
458 thiz->expand_candidate ();
462 slot_contract_candidate (IMEngineInstanceBase *si)
465 thiz->contract_candidate ();
469 slot_set_candidate_style (IMEngineInstanceBase *si, ISF_CANDIDATE_PORTRAIT_LINE_T portrait_line, ISF_CANDIDATE_MODE_T mode)
472 thiz->set_candidate_style (portrait_line, mode);
476 slot_send_private_command (IMEngineInstanceBase *si,
477 const String &command)
480 thiz->send_private_command (command);
486 si->signal_connect_show_preedit_string (
487 slot (this, &HelperAgent::HelperAgentImpl::slot_show_preedit_string));
488 si->signal_connect_show_aux_string (
489 slot (this, &HelperAgent::HelperAgentImpl::slot_show_aux_string));
490 si->signal_connect_show_lookup_table (
491 slot (this, &HelperAgent::HelperAgentImpl::slot_show_lookup_table));
493 si->signal_connect_hide_preedit_string (
494 slot (this, &HelperAgent::HelperAgentImpl::slot_hide_preedit_string));
495 si->signal_connect_hide_aux_string (
496 slot (this, &HelperAgent::HelperAgentImpl::slot_hide_aux_string));
497 si->signal_connect_hide_lookup_table (
498 slot (this, &HelperAgent::HelperAgentImpl::slot_hide_lookup_table));
500 si->signal_connect_update_preedit_caret (
501 slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_caret));
502 si->signal_connect_update_preedit_string (
503 slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_string));
504 si->signal_connect_update_preedit_string_with_commit (
505 slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_string_with_commit));
506 si->signal_connect_recapture_string (
507 slot (this, &HelperAgent::HelperAgentImpl::slot_recapture_string));
509 si->signal_connect_update_aux_string (
510 slot (this, &HelperAgent::HelperAgentImpl::slot_update_aux_string));
511 si->signal_connect_update_lookup_table (
512 slot (this, &HelperAgent::HelperAgentImpl::slot_update_lookup_table));
514 si->signal_connect_commit_string (
515 slot (this, &HelperAgent::HelperAgentImpl::slot_commit_string));
517 si->signal_connect_forward_key_event (
518 slot (this, &HelperAgent::HelperAgentImpl::slot_forward_key_event));
520 si->signal_connect_register_properties (
521 slot (this, &HelperAgent::HelperAgentImpl::slot_register_properties));
523 si->signal_connect_update_property (
524 slot (this, &HelperAgent::HelperAgentImpl::slot_update_property));
526 si->signal_connect_beep (
527 slot (this, &HelperAgent::HelperAgentImpl::slot_beep));
529 si->signal_connect_start_helper (
530 slot (this, &HelperAgent::HelperAgentImpl::slot_start_helper));
532 si->signal_connect_stop_helper (
533 slot (this, &HelperAgent::HelperAgentImpl::slot_stop_helper));
535 si->signal_connect_send_helper_event (
536 slot (this, &HelperAgent::HelperAgentImpl::slot_send_helper_event));
538 si->signal_connect_get_surrounding_text (
539 slot (this, &HelperAgent::HelperAgentImpl::slot_get_surrounding_text));
541 si->signal_connect_delete_surrounding_text (
542 slot (this, &HelperAgent::HelperAgentImpl::slot_delete_surrounding_text));
544 si->signal_connect_get_selection (
545 slot (this, &HelperAgent::HelperAgentImpl::slot_get_selection));
547 si->signal_connect_set_selection (
548 slot (this, &HelperAgent::HelperAgentImpl::slot_set_selection));
550 si->signal_connect_expand_candidate (
551 slot (this, &HelperAgent::HelperAgentImpl::slot_expand_candidate));
552 si->signal_connect_contract_candidate (
553 slot (this, &HelperAgent::HelperAgentImpl::slot_contract_candidate));
555 si->signal_connect_set_candidate_style (
556 slot (this, &HelperAgent::HelperAgentImpl::slot_set_candidate_style));
558 si->signal_connect_send_private_command (
559 slot (this, &HelperAgent::HelperAgentImpl::slot_send_private_command));
562 void process_key_event_done (KeyEvent &key, uint32 ret, uint32 serial) {
563 LOGD ("ret: %d, serial: %d", ret, serial);
564 if (socket_active.is_connected ()) {
566 send.put_command (SCIM_TRANS_CMD_REQUEST);
567 send.put_data (magic_active);
568 send.put_command (ISM_TRANS_CMD_PROCESS_KEY_EVENT_DONE);
571 send.put_data (serial);
572 send.write_to_socket (socket_active, magic_active);
576 void request_ise_hide () {
577 if (socket_active.is_connected ()) {
579 send.put_command (SCIM_TRANS_CMD_REQUEST);
580 send.put_data (magic_active);
581 send.put_command (ISM_TRANS_CMD_REQUEST_ISE_HIDE);
582 send.write_to_socket (socket_active, magic_active);
586 HelperAgentImpl () : magic (0), magic_active (0), timeout (-1), focused_ic ((uint32) -1) { }
589 static MessageQueue message_queue;
591 HelperAgent::HelperAgent ()
592 : m_impl (new HelperAgentImpl (this))
594 message_queue.create();
597 HelperAgent::~HelperAgent ()
599 message_queue.destroy();
604 * @brief Open socket connection to the Panel.
606 * @param info The information of this Helper object.
607 * @param display The display which this Helper object should run on.
609 * @return The connection socket id. -1 means failed to create
613 HelperAgent::open_connection (const HelperInfo &info,
614 const String &display)
616 if (m_impl->socket.is_connected ())
619 SocketAddress address (scim_get_default_panel_socket_address (display));
620 int timeout = m_impl->timeout = scim_get_default_socket_timeout ();
623 if (!address.valid ())
627 std::cerr << " Connecting to PanelAgent server.";
628 ISF_LOG (" Connecting to PanelAgent server.\n");
629 while (!m_impl->socket.connect (address)) {
631 scim_usleep (100000);
633 std::cerr << "m_impl->socket.connect () is failed!!!\n";
634 ISF_LOG ("m_impl->socket.connect () is failed!!!\n");
638 std::cerr << " Connected :" << i << "\n";
639 ISF_LOG (" Connected :%d\n", i);
640 LOGD ("Connection to PanelAgent succeeded, %d\n", i);
642 /* Let's retry 10 times when failed */
643 int open_connection_retries = 0;
644 while (!scim_socket_open_connection (magic,
649 if (++open_connection_retries > 10) {
650 m_impl->socket.close ();
651 std::cerr << "scim_socket_open_connection () is failed!!!\n";
652 ISF_LOG ("scim_socket_open_connection () is failed!!!\n");
653 ISF_SAVE_LOG ("scim_socket_open_connection failed, %d\n", timeout);
658 /* Retry after re-connecting the socket */
659 if (m_impl->socket.is_connected ())
662 /* This time, just retry atmost 2 seconds */
664 while (!m_impl->socket.connect (address) && ++i < 10) {
665 scim_usleep (200000);
670 ISF_LOG ("scim_socket_open_connection () is successful.\n");
671 LOGD ("scim_socket_open_connection successful\n");
673 m_impl->send.clear ();
674 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
675 m_impl->send.put_data (magic);
676 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_REGISTER_HELPER);
677 m_impl->send.put_data (info.uuid);
678 m_impl->send.put_data (info.name);
679 m_impl->send.put_data (info.icon);
680 m_impl->send.put_data (info.description);
681 m_impl->send.put_data (info.option);
683 if (!m_impl->send.write_to_socket (m_impl->socket, magic)) {
684 m_impl->socket.close ();
689 if (m_impl->recv.read_from_socket (m_impl->socket, timeout) &&
690 m_impl->recv.get_command (cmd) && cmd == SCIM_TRANS_CMD_REPLY &&
691 m_impl->recv.get_command (cmd) && cmd == SCIM_TRANS_CMD_OK) {
692 m_impl->magic = magic;
694 while (m_impl->recv.get_command (cmd)) {
696 case SCIM_TRANS_CMD_HELPER_ATTACH_INPUT_CONTEXT:
700 while (m_impl->recv.get_data (ic) && m_impl->recv.get_data (ic_uuid))
701 m_impl->signal_attach_input_context (this, ic, ic_uuid);
704 case SCIM_TRANS_CMD_UPDATE_SCREEN:
707 if (m_impl->recv.get_data (screen))
708 m_impl->signal_update_screen (this, (uint32) -1, String (""), (int) screen);
716 //FIXME: Attaching input context is needed for desktop environment
717 LOGW ("Attach input context and update screen failed");
720 ISF_SAVE_LOG ("Trying connect() with Helper_Active\n");
722 /* connect to the panel agent as the active helper client */
723 if (!m_impl->socket_active.connect (address)) return -1;
724 open_connection_retries = 0;
725 while (!scim_socket_open_connection (magic,
726 String ("Helper_Active"),
728 m_impl->socket_active,
730 if (++open_connection_retries > 10) {
731 m_impl->socket_active.close ();
732 std::cerr << "Helper_Active scim_socket_open_connection () is failed!!!\n";
733 ISF_LOG ("Helper_Active scim_socket_open_connection () is failed!!!\n");
734 ISF_SAVE_LOG ("Helper_Active scim_socket_open_connection failed, %d\n", timeout);
739 /* Retry after re-connecting the socket */
740 if (m_impl->socket_active.is_connected ())
741 m_impl->socket_active.close ();
743 /* This time, just retry atmost 2 seconds */
745 while (!m_impl->socket_active.connect (address) && ++i < 10) {
746 scim_usleep (200000);
750 m_impl->magic_active = magic;
752 m_impl->send.clear ();
753 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
754 m_impl->send.put_data (magic);
755 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_REGISTER_ACTIVE_HELPER);
756 m_impl->send.put_data (info.uuid);
757 m_impl->send.put_data (info.name);
758 m_impl->send.put_data (info.icon);
759 m_impl->send.put_data (info.description);
760 m_impl->send.put_data (info.option);
762 if (!m_impl->send.write_to_socket (m_impl->socket_active, magic)) {
763 ISF_SAVE_LOG ("Helper_Active write_to_socket() failed\n");
764 m_impl->socket_active.close ();
767 m_impl->m_config = ConfigBase::get (false, "socket");
769 return m_impl->socket.get_id ();
773 * @brief Close the socket connection to Panel.
776 HelperAgent::close_connection ()
778 m_impl->socket.close ();
779 m_impl->socket_active.close ();
780 m_impl->send.clear ();
781 m_impl->recv.clear ();
783 m_impl->magic_active = 0;
788 * @brief Get the connection id previously returned by open_connection().
790 * @return the connection id
793 HelperAgent::get_connection_number () const
795 if (m_impl->socket.is_connected ())
796 return m_impl->socket.get_id ();
801 * @brief Check whether this HelperAgent has been connected to a Panel.
803 * Return true when it is connected to panel, otherwise return false.
806 HelperAgent::is_connected () const
808 return m_impl->socket.is_connected ();
812 * @brief Check if there are any events available to be processed.
814 * If it returns true then Helper object should call
815 * HelperAgent::filter_event() to process them.
817 * @return true if there are any events available.
820 HelperAgent::has_pending_event () const
822 if (m_impl->socket.is_connected () && m_impl->socket.wait_for_data (0) > 0)
825 if (message_queue.has_pending_message())
832 * @brief Process the pending events.
834 * This function will emit the corresponding signals according
837 * @return false if the connection is broken, otherwise return true.
840 HelperAgent::filter_event ()
842 if (!m_impl->socket.is_connected ()) {
843 LOGW("Connection lost, returning false");
847 if (m_impl->recv.read_from_socket (m_impl->socket, m_impl->timeout)) {
848 message_queue.read_from_transaction(m_impl->recv);
850 while (message_queue.has_pending_message()) {
851 MessageItem *message = message_queue.get_pending_message();
852 handle_message(message);
853 message_queue.remove_message(message);
856 LOGD("read_from_socket() failed but continuing");
864 * @brief Read messages from socket buffer, and see if there is a message with the given cmd.
866 * @return false if the connection is broken, or no message available with given cmd. Otherwise return true.
869 HelperAgent::wait_for_message(int cmd, int timeout)
871 struct timeval t0 = { 0, 0 };
872 struct timeval t1 = { 0, 0 };
874 gettimeofday(&t0, NULL);
878 if (!m_impl->socket.is_connected() || !m_impl->recv.read_from_socket(m_impl->socket, timeout))
881 message_queue.read_from_transaction(m_impl->recv);
882 if (message_queue.has_pending_message_by_cmd(cmd)) {
886 gettimeofday(&t1, NULL);
887 etime = ((t1.tv_sec * 1000000 + t1.tv_usec) - (t0.tv_sec * 1000000 + t0.tv_usec)) / 1000;
888 } while (etime < timeout);
894 * @brief Process one message that is in our message queue.
896 * This function will emit the corresponding signals according
899 * @param message The message that needs to be handled.
901 * @return false if the connection is broken, otherwise return true.
904 HelperAgent::handle_message (MessageItem *message)
909 int cmd = message->get_command_ref();
910 LOGD ("HelperAgent::cmd = %d\n", cmd);
912 case SCIM_TRANS_CMD_EXIT:
914 MessageItemExit *subclass = static_cast<MessageItemExit*>(message);
915 ISF_SAVE_LOG ("Helper ISE received SCIM_TRANS_CMD_EXIT message\n");
916 m_impl->signal_exit(this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
919 case SCIM_TRANS_CMD_RELOAD_CONFIG:
921 MessageItemReloadConfig *subclass = static_cast<MessageItemReloadConfig*>(message);
922 m_impl->signal_reload_config (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
923 if (!m_impl->m_config.null())
924 m_impl->m_config->ConfigBase::reload();
927 case SCIM_TRANS_CMD_UPDATE_SCREEN:
929 MessageItemUpdateScreen *subclass = static_cast<MessageItemUpdateScreen*>(message);
930 m_impl->signal_update_screen (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
931 subclass->get_screen_ref());
934 case SCIM_TRANS_CMD_UPDATE_SPOT_LOCATION:
936 MessageItemUpdateSpotLocation *subclass = static_cast<MessageItemUpdateSpotLocation*>(message);
937 m_impl->signal_update_spot_location (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
938 subclass->get_x_ref(), subclass->get_y_ref());
941 case ISM_TRANS_CMD_UPDATE_CURSOR_POSITION:
943 MessageItemUpdateCursorPosition *subclass = static_cast<MessageItemUpdateCursorPosition*>(message);
944 m_impl->cursor_pos = subclass->get_cursor_pos_ref();
945 LOGD ("update cursor position %d", subclass->get_cursor_pos_ref());
946 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode) {
947 m_impl->signal_update_cursor_position (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
948 subclass->get_cursor_pos_ref());
949 if (!m_impl->si.null ()) m_impl->si->update_cursor_position(subclass->get_cursor_pos_ref());
953 case ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT:
955 MessageItemUpdateSurroundingText *subclass = static_cast<MessageItemUpdateSurroundingText*>(message);
956 if (m_impl->surrounding_text != NULL)
957 free (m_impl->surrounding_text);
958 m_impl->surrounding_text = strdup (subclass->get_text_ref().c_str ());
959 m_impl->cursor_pos = subclass->get_cursor_ref();
960 LOGD ("surrounding text: %s, %d", m_impl->surrounding_text, subclass->get_cursor_ref());
961 while (m_impl->need_update_surrounding_text > 0) {
962 m_impl->need_update_surrounding_text--;
963 m_impl->signal_update_surrounding_text (this, subclass->get_ic_ref(),
964 subclass->get_text_ref(), subclass->get_cursor_ref());
968 case ISM_TRANS_CMD_UPDATE_SELECTION:
970 MessageItemUpdateSelection *subclass = static_cast<MessageItemUpdateSelection*>(message);
971 if (m_impl->selection_text != NULL)
972 free (m_impl->selection_text);
974 m_impl->selection_text = strdup (subclass->get_text_ref().c_str ());
975 LOGD ("selection text: %s", m_impl->selection_text);
977 while (m_impl->need_update_selection_text > 0) {
978 m_impl->need_update_selection_text--;
979 m_impl->signal_update_selection (this, subclass->get_ic_ref(), subclass->get_text_ref());
983 case SCIM_TRANS_CMD_TRIGGER_PROPERTY:
985 MessageItemTriggerProperty *subclass = static_cast<MessageItemTriggerProperty*>(message);
986 m_impl->signal_trigger_property (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
987 subclass->get_property_ref());
988 if (!m_impl->si.null ()) m_impl->si->trigger_property(subclass->get_property_ref());
991 case SCIM_TRANS_CMD_HELPER_PROCESS_IMENGINE_EVENT:
993 MessageItemHelperProcessImengineEvent *subclass = static_cast<MessageItemHelperProcessImengineEvent*>(message);
994 m_impl->signal_process_imengine_event (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
995 subclass->get_transaction_ref());
998 case SCIM_TRANS_CMD_HELPER_ATTACH_INPUT_CONTEXT:
1000 MessageItemHelperAttachInputContext *subclass = static_cast<MessageItemHelperAttachInputContext*>(message);
1001 m_impl->signal_attach_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1004 case SCIM_TRANS_CMD_HELPER_DETACH_INPUT_CONTEXT:
1006 MessageItemHelperDetachInputContext *subclass = static_cast<MessageItemHelperDetachInputContext*>(message);
1007 m_impl->signal_detach_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1010 case SCIM_TRANS_CMD_FOCUS_OUT:
1012 MessageItemFocusOut *subclass = static_cast<MessageItemFocusOut*>(message);
1013 m_impl->signal_focus_out (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1014 m_impl->focused_ic = (uint32) -1;
1015 if (!m_impl->si.null ()) m_impl->si->focus_out();
1016 m_impl->ise_show_flag = false;
1019 case SCIM_TRANS_CMD_FOCUS_IN:
1021 MessageItemFocusIn *subclass = static_cast<MessageItemFocusIn*>(message);
1022 m_impl->signal_focus_in (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1023 m_impl->focused_ic = subclass->get_ic_ref();
1024 if (!m_impl->si.null ()) m_impl->si->focus_in();
1027 case ISM_TRANS_CMD_SHOW_ISE_PANEL:
1029 MessageItemShowISEPanel *subclass = static_cast<MessageItemShowISEPanel*>(message);
1030 LOGD ("Helper ISE received ISM_TRANS_CMD_SHOW_ISE_PANEL message\n");
1032 m_impl->signal_ise_show (this, subclass->get_ic_ref(), *(subclass->get_data_ptr()),
1033 subclass->get_len_ref());
1034 m_impl->ise_show_flag = true;
1037 case ISM_TRANS_CMD_HIDE_ISE_PANEL:
1039 MessageItemHideISEPanel *subclass = static_cast<MessageItemHideISEPanel*>(message);
1040 LOGD ("Helper ISE received ISM_TRANS_CMD_HIDE_ISE_PANEL message\n");
1041 m_impl->signal_ise_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1042 m_impl->ise_show_flag = false;
1045 case ISM_TRANS_CMD_GET_ACTIVE_ISE_GEOMETRY:
1047 struct rectinfo info = {0, 0, 0, 0};
1048 m_impl->signal_get_geometry (this, info);
1049 m_impl->send.clear ();
1050 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1051 m_impl->send.put_data (info.pos_x);
1052 m_impl->send.put_data (info.pos_y);
1053 m_impl->send.put_data (info.width);
1054 m_impl->send.put_data (info.height);
1055 m_impl->send.write_to_socket (m_impl->socket);
1058 case ISM_TRANS_CMD_SET_ISE_MODE:
1060 MessageItemSetISEMode *subclass = static_cast<MessageItemSetISEMode*>(message);
1061 m_impl->signal_set_mode (this, subclass->get_mode_ref());
1064 case ISM_TRANS_CMD_SET_ISE_LANGUAGE:
1066 MessageItemSetISELanguage *subclass = static_cast<MessageItemSetISELanguage*>(message);
1067 m_impl->signal_set_language (this, subclass->get_language_ref());
1070 case ISM_TRANS_CMD_SET_ISE_IMDATA:
1072 MessageItemSetISEImData *subclass = static_cast<MessageItemSetISEImData*>(message);
1073 m_impl->signal_set_imdata (this, *(subclass->get_imdata_ptr()), subclass->get_len_ref());
1074 if (!m_impl->si.null ()) m_impl->si->set_imdata(*(subclass->get_imdata_ptr()),
1075 subclass->get_len_ref());
1078 case ISM_TRANS_CMD_GET_ISE_IMDATA:
1083 m_impl->signal_get_imdata (this, &buf, len);
1084 LOGD ("send ise imdata len = %d", len);
1085 m_impl->send.clear ();
1086 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1087 m_impl->send.put_data (buf, len);
1088 m_impl->send.write_to_socket (m_impl->socket);
1093 case ISM_TRANS_CMD_GET_ISE_LANGUAGE_LOCALE:
1095 MessageItemGetISELanguageLocale *subclass = static_cast<MessageItemGetISELanguageLocale*>(message);
1097 m_impl->signal_get_language_locale (this, subclass->get_ic_ref(), &buf);
1098 m_impl->send.clear ();
1099 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1101 m_impl->send.put_data (buf, strlen (buf));
1102 m_impl->send.write_to_socket (m_impl->socket);
1107 case ISM_TRANS_CMD_SET_RETURN_KEY_TYPE:
1109 MessageItemSetReturnKeyType *subclass = static_cast<MessageItemSetReturnKeyType*>(message);
1110 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode) {
1111 m_impl->signal_set_return_key_type (this, subclass->get_type_ref());
1115 case ISM_TRANS_CMD_GET_RETURN_KEY_TYPE:
1118 m_impl->signal_get_return_key_type (this, type);
1119 m_impl->send.clear ();
1120 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1121 m_impl->send.put_data (type);
1122 m_impl->send.write_to_socket (m_impl->socket);
1125 case ISM_TRANS_CMD_SET_RETURN_KEY_DISABLE:
1127 MessageItemSetReturnKeyDisable *subclass = static_cast<MessageItemSetReturnKeyDisable*>(message);
1128 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode) {
1129 m_impl->signal_set_return_key_disable (this, subclass->get_disabled_ref());
1133 case ISM_TRANS_CMD_GET_RETURN_KEY_DISABLE:
1135 uint32 disabled = 0;
1136 m_impl->signal_get_return_key_type (this, disabled);
1137 m_impl->send.clear ();
1138 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1139 m_impl->send.put_data (disabled);
1140 m_impl->send.write_to_socket (m_impl->socket);
1143 case SCIM_TRANS_CMD_PROCESS_KEY_EVENT:
1145 MessageItemProcessKeyEvent *subclass = static_cast<MessageItemProcessKeyEvent*>(message);
1147 m_impl->signal_process_key_event(this, subclass->get_key_ref(), ret);
1149 if (!m_impl->si.null ())
1151 ret = m_impl->si->process_key_event (subclass->get_key_ref());
1152 LOGD("imengine(%s) process key %d return %d", m_impl->si->get_factory_uuid().c_str(),
1153 subclass->get_key_ref().code, ret);
1155 m_impl->process_key_event_done (subclass->get_key_ref(), ret, subclass->get_serial_ref());
1158 case ISM_TRANS_CMD_SET_LAYOUT:
1160 MessageItemSetLayout *subclass = static_cast<MessageItemSetLayout*>(message);
1161 m_impl->layout = subclass->get_layout_ref();
1162 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode) {
1163 m_impl->signal_set_layout (this, subclass->get_layout_ref());
1164 if (!m_impl->si.null ()) m_impl->si->set_layout(subclass->get_layout_ref());
1168 case ISM_TRANS_CMD_GET_LAYOUT:
1172 m_impl->signal_get_layout (this, layout);
1173 m_impl->send.clear ();
1174 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1175 m_impl->send.put_data (layout);
1176 m_impl->send.write_to_socket (m_impl->socket);
1179 case ISM_TRANS_CMD_SET_INPUT_MODE:
1181 MessageItemSetInputMode *subclass = static_cast<MessageItemSetInputMode*>(message);
1182 m_impl->signal_set_input_mode (this, subclass->get_input_mode_ref());
1185 case ISM_TRANS_CMD_SET_CAPS_MODE:
1187 MessageItemSetCapsMode *subclass = static_cast<MessageItemSetCapsMode*>(message);
1188 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode) {
1189 m_impl->signal_set_caps_mode (this, subclass->get_mode_ref());
1193 case SCIM_TRANS_CMD_PANEL_RESET_INPUT_CONTEXT:
1195 MessageItemPanelResetInputContext *subclass = static_cast<MessageItemPanelResetInputContext*>(message);
1196 m_impl->signal_reset_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1197 if (!m_impl->si.null ()) m_impl->si->reset();
1200 case ISM_TRANS_CMD_UPDATE_CANDIDATE_UI:
1202 MessageItemUpdateCandidateUI *subclass = static_cast<MessageItemUpdateCandidateUI*>(message);
1203 m_impl->signal_update_candidate_ui (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1204 subclass->get_style_ref(), subclass->get_mode_ref());
1207 case ISM_TRANS_CMD_UPDATE_CANDIDATE_GEOMETRY:
1209 MessageItemUpdateCandidateGeometry *subclass = static_cast<MessageItemUpdateCandidateGeometry*>(message);
1210 m_impl->signal_update_candidate_geometry (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1211 subclass->get_rectinfo_ref());
1214 case ISM_TRANS_CMD_UPDATE_KEYBOARD_ISE:
1216 MessageItemUpdateKeyboardISE *subclass = static_cast<MessageItemUpdateKeyboardISE*>(message);
1217 m_impl->signal_update_keyboard_ise (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1218 subclass->get_name_ref(), subclass->get_uuid_ref());
1221 case ISM_TRANS_CMD_UPDATE_KEYBOARD_ISE_LIST:
1223 MessageItemUpdateKeyboardISEList *subclass = static_cast<MessageItemUpdateKeyboardISEList*>(message);
1224 m_impl->signal_update_keyboard_ise_list (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1225 subclass->get_list_ref());
1228 case ISM_TRANS_CMD_CANDIDATE_MORE_WINDOW_SHOW:
1230 MessageItemCandidateMoreWindowShow *subclass = static_cast<MessageItemCandidateMoreWindowShow*>(message);
1231 m_impl->signal_candidate_more_window_show (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1232 if (!m_impl->si.null ()) m_impl->si->candidate_more_window_show();
1235 case ISM_TRANS_CMD_CANDIDATE_MORE_WINDOW_HIDE:
1237 MessageItemCandidateMoreWindowHide *subclass = static_cast<MessageItemCandidateMoreWindowHide*>(message);
1238 m_impl->signal_candidate_more_window_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1239 if (!m_impl->si.null ()) m_impl->si->candidate_more_window_hide();
1242 case ISM_TRANS_CMD_SELECT_AUX:
1244 MessageItemSelectAux *subclass = static_cast<MessageItemSelectAux*>(message);
1245 m_impl->signal_select_aux (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1246 subclass->get_item_ref());
1247 if (!m_impl->si.null ()) m_impl->si->select_aux(subclass->get_item_ref());
1250 case SCIM_TRANS_CMD_SELECT_CANDIDATE: //FIXME:remove if useless
1252 MessageItemSelectCandidate *subclass = static_cast<MessageItemSelectCandidate*>(message);
1253 m_impl->signal_select_candidate (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1254 subclass->get_item_ref());
1255 if (!m_impl->si.null ()) m_impl->si->select_candidate(subclass->get_item_ref());
1258 case SCIM_TRANS_CMD_LOOKUP_TABLE_PAGE_UP: //FIXME:remove if useless
1260 MessageItemLookupTablePageUp *subclass = static_cast<MessageItemLookupTablePageUp*>(message);
1261 m_impl->signal_candidate_table_page_up (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1262 if (!m_impl->si.null ()) m_impl->si->lookup_table_page_up();
1265 case SCIM_TRANS_CMD_LOOKUP_TABLE_PAGE_DOWN: //FIXME:remove if useless
1267 MessageItemLookupTablePageDown *subclass = static_cast<MessageItemLookupTablePageDown*>(message);
1268 m_impl->signal_candidate_table_page_down (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1269 if (!m_impl->si.null ()) m_impl->si->lookup_table_page_down();
1272 case SCIM_TRANS_CMD_UPDATE_LOOKUP_TABLE_PAGE_SIZE:
1274 MessageItemUpdateLookupTablePageSize *subclass = static_cast<MessageItemUpdateLookupTablePageSize*>(message);
1275 m_impl->signal_update_candidate_table_page_size (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1276 subclass->get_size_ref());
1277 if (!m_impl->si.null ()) m_impl->si->update_lookup_table_page_size(subclass->get_size_ref());
1280 case ISM_TRANS_CMD_CANDIDATE_SHOW: //FIXME:remove if useless
1282 MessageItemCandidateShow *subclass = static_cast<MessageItemCandidateShow*>(message);
1283 m_impl->signal_candidate_show (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1286 case ISM_TRANS_CMD_CANDIDATE_HIDE: //FIXME:remove if useless
1288 MessageItemCandidateHide *subclass = static_cast<MessageItemCandidateHide*>(message);
1289 m_impl->signal_candidate_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1292 case ISM_TRANS_CMD_UPDATE_LOOKUP_TABLE: //FIXME:remove if useless
1294 MessageItemUpdateLookupTable *subclass = static_cast<MessageItemUpdateLookupTable*>(message);
1295 m_impl->signal_update_lookup_table (this, subclass->get_candidate_table_ref());
1298 case ISM_TRANS_CMD_UPDATE_CANDIDATE_ITEM_LAYOUT:
1300 MessageItemUpdateCandidateItemLayout *subclass = static_cast<MessageItemUpdateCandidateItemLayout*>(message);
1301 m_impl->signal_update_candidate_item_layout (this, subclass->get_row_items_ref());
1302 if (!m_impl->si.null ()) m_impl->si->update_candidate_item_layout(subclass->get_row_items_ref());
1305 case ISM_TRANS_CMD_SELECT_ASSOCIATE:
1307 MessageItemSelectAssociate *subclass = static_cast<MessageItemSelectAssociate*>(message);
1308 m_impl->signal_select_associate (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1309 subclass->get_item_ref());
1312 case ISM_TRANS_CMD_ASSOCIATE_TABLE_PAGE_UP:
1314 MessageItemAssociateTablePageUp *subclass = static_cast<MessageItemAssociateTablePageUp*>(message);
1315 m_impl->signal_associate_table_page_up (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1318 case ISM_TRANS_CMD_ASSOCIATE_TABLE_PAGE_DOWN:
1320 MessageItemAssociateTablePageDown *subclass = static_cast<MessageItemAssociateTablePageDown*>(message);
1321 m_impl->signal_associate_table_page_down (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1324 case ISM_TRANS_CMD_UPDATE_ASSOCIATE_TABLE_PAGE_SIZE:
1326 MessageItemUpdateAssociateTablePageSize *subclass = static_cast<MessageItemUpdateAssociateTablePageSize*>(message);
1327 m_impl->signal_update_associate_table_page_size (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1328 subclass->get_size_ref());
1331 case ISM_TRANS_CMD_RESET_ISE_CONTEXT:
1333 MessageItemResetISEContext *subclass = static_cast<MessageItemResetISEContext*>(message);
1334 m_impl->signal_reset_ise_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1335 m_impl->signal_reset_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1336 if (!m_impl->si.null ()) m_impl->si->reset();
1339 case ISM_TRANS_CMD_TURN_ON_LOG:
1341 MessageItemTurnOnLog *subclass = static_cast<MessageItemTurnOnLog*>(message);
1342 m_impl->signal_turn_on_log (this, subclass->get_state_ref());
1345 case ISM_TRANS_CMD_UPDATE_DISPLAYED_CANDIDATE:
1347 MessageItemUpdateDisplayedCandidate *subclass = static_cast<MessageItemUpdateDisplayedCandidate*>(message);
1348 m_impl->signal_update_displayed_candidate_number (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1349 subclass->get_size_ref());
1350 if (!m_impl->si.null ()) m_impl->si->update_displayed_candidate_number(subclass->get_size_ref());
1353 case ISM_TRANS_CMD_LONGPRESS_CANDIDATE:
1355 MessageItemLongpressCandidate *subclass = static_cast<MessageItemLongpressCandidate*>(message);
1356 m_impl->signal_longpress_candidate (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1357 subclass->get_index_ref());
1358 if (!m_impl->si.null ()) m_impl->si->longpress_candidate(subclass->get_index_ref());
1361 case ISM_TRANS_CMD_SET_INPUT_HINT:
1363 MessageItemSetInputHint *subclass = static_cast<MessageItemSetInputHint*>(message);
1364 m_impl->signal_set_input_hint (this, subclass->get_input_hint_ref());
1365 if (!m_impl->si.null ()) m_impl->si->set_input_hint(subclass->get_input_hint_ref());
1368 case ISM_TRANS_CMD_UPDATE_BIDI_DIRECTION:
1370 MessageItemUpdateBidiDirection *subclass = static_cast<MessageItemUpdateBidiDirection*>(message);
1371 m_impl->signal_update_bidi_direction (this, subclass->get_bidi_direction());
1372 if (!m_impl->si.null ()) m_impl->si->update_bidi_direction(subclass->get_bidi_direction());
1375 case ISM_TRANS_CMD_SHOW_ISE_OPTION_WINDOW:
1377 MessageItemShowISEOptionWindow *subclass = static_cast<MessageItemShowISEOptionWindow*>(message);
1378 m_impl->signal_show_option_window (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1381 case ISM_TRANS_CMD_RESUME_ISE_OPTION_WINDOW:
1383 MessageItemResumeISEOptionWindow *subclass = static_cast<MessageItemResumeISEOptionWindow*>(message);
1384 m_impl->signal_resume_option_window (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1387 case ISM_TRANS_CMD_CHECK_OPTION_WINDOW:
1390 m_impl->signal_check_option_window (this, avail);
1391 m_impl->send.clear ();
1392 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1393 m_impl->send.put_data (avail);
1394 m_impl->send.write_to_socket (m_impl->socket);
1397 case ISM_TRANS_CMD_PROCESS_INPUT_DEVICE_EVENT:
1399 MessageItemProcessInputDeviceEvent *subclass = static_cast<MessageItemProcessInputDeviceEvent*>(message);
1401 m_impl->signal_process_input_device_event(this,
1402 subclass->get_type_ref(), *(subclass->get_data_ptr()), subclass->get_len_ref(), ret);
1403 m_impl->send.clear();
1404 m_impl->send.put_command(SCIM_TRANS_CMD_REPLY);
1405 m_impl->send.put_data(ret);
1406 m_impl->send.write_to_socket(m_impl->socket);
1409 case SCIM_TRANS_CMD_SET_AUTOCAPITAL_TYPE:
1411 MessageItemSetAutocapitalType *subclass = static_cast<MessageItemSetAutocapitalType*>(message);
1412 if (!m_impl->si.null ()) m_impl->si->set_autocapital_type(subclass->get_auto_capital_type_ref());
1415 case ISM_TRANS_CMD_SET_PREDICTION_ALLOW:
1417 MessageItemSetPredictionAllow *subclass = static_cast<MessageItemSetPredictionAllow*>(message);
1418 if (!m_impl->si.null ()) m_impl->si->set_prediction_allow(subclass->get_prediction_allow_ref() == 0 ? false : true);
1421 case ISM_TRANS_CMD_SET_KEYBOARD_MODE:
1423 MessageItemSetKeyboardMode *subclass = static_cast<MessageItemSetKeyboardMode*>(message);
1424 if (subclass->get_mode_ref())
1425 m_impl->hw_keyboard_mode = false;
1427 m_impl->hw_keyboard_mode = true;
1437 * @brief Request SCIM to reload all configuration.
1439 * This function should only by used by Setup Helper to request
1440 * scim's reloading the configuration.
1441 * Deprecated: reload config message only send by socketconfig client
1442 * using socketconfig::reload instead.
1445 HelperAgent::reload_config () const
1447 LOGD ("send reload config message to isf");
1448 if (!m_impl->m_config.null())
1449 m_impl->m_config->reload();
1453 * @brief Register some properties into Panel.
1455 * This function send the request to Panel to register a list
1458 * @param properties The list of Properties to be registered into Panel.
1460 * @sa scim::Property.
1463 HelperAgent::register_properties (const PropertyList &properties) const
1466 if (m_impl->socket_active.is_connected ()) {
1467 m_impl->send.clear ();
1468 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1469 m_impl->send.put_data (m_impl->magic_active);
1470 m_impl->send.put_command (SCIM_TRANS_CMD_REGISTER_PROPERTIES);
1471 m_impl->send.put_data (properties);
1472 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1477 * @brief Update a registered property.
1479 * @param property The property to be updated.
1482 HelperAgent::update_property (const Property &property) const
1485 if (m_impl->socket_active.is_connected ()) {
1486 m_impl->send.clear ();
1487 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1488 m_impl->send.put_data (m_impl->magic_active);
1489 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PROPERTY);
1490 m_impl->send.put_data (property);
1491 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1496 * @brief Send a set of events to an IMEngineInstance.
1498 * All events should be put into a Transaction.
1499 * And the events can only be received by one IMEngineInstance object.
1501 * @param ic The handle of the Input Context to receive the events.
1502 * @param ic_uuid The UUID of the Input Context.
1503 * @param trans The Transaction object holds the events.
1506 HelperAgent::send_imengine_event (int ic,
1507 const String &ic_uuid,
1508 const Transaction &trans) const
1511 //remove if not necessary
1513 if (m_impl->socket_active.is_connected ()) {
1514 m_impl->send.clear ();
1515 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1516 m_impl->send.put_data (m_impl->magic_active);
1517 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_SEND_IMENGINE_EVENT);
1518 m_impl->send.put_data ((uint32)ic);
1519 m_impl->send.put_data (ic_uuid);
1520 m_impl->send.put_data (trans);
1521 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1524 if (!m_impl->si.null ()) m_impl->si->process_helper_event (ic_uuid, trans);
1528 * @brief Send a KeyEvent to an IMEngineInstance.
1530 * @param ic The handle of the IMEngineInstance to receive the event.
1531 * -1 means the currently focused IMEngineInstance.
1532 * @param ic_uuid The UUID of the IMEngineInstance. Empty means don't match.
1533 * @param key The KeyEvent to be sent.
1536 HelperAgent::send_key_event (int ic,
1537 const String &ic_uuid,
1538 const KeyEvent &key) const
1542 //FIXME: remove shift_mode_off, shift_mode_on, shift_mode_lock from ISE side
1543 if (key.code == SHIFT_MODE_OFF ||
1544 key.code == SHIFT_MODE_ON ||
1545 key.code == SHIFT_MODE_LOCK ||
1546 key.code == SHIFT_MODE_ENABLE ||
1547 key.code == SHIFT_MODE_DISABLE) {
1548 LOGW("FIXME ignore shift codes");
1552 if (m_impl->socket_active.is_connected ()) {
1553 m_impl->send.clear ();
1554 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1555 m_impl->send.put_data (m_impl->magic_active);
1556 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_SEND_KEY_EVENT);
1558 m_impl->send.put_data (m_impl->focused_ic);
1560 m_impl->send.put_data ((uint32)ic);
1562 m_impl->send.put_data (ic_uuid);
1563 m_impl->send.put_data (key);
1564 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1569 * @brief Forward a KeyEvent to client application directly.
1571 * @param ic The handle of the client Input Context to receive the event.
1572 * -1 means the currently focused Input Context.
1573 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1574 * Empty means don't match.
1575 * @param key The KeyEvent to be forwarded.
1578 HelperAgent::forward_key_event (int ic,
1579 const String &ic_uuid,
1580 const KeyEvent &key) const
1583 if (m_impl->socket_active.is_connected ()) {
1584 m_impl->send.clear ();
1585 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1586 m_impl->send.put_data (m_impl->magic_active);
1587 m_impl->send.put_command (SCIM_TRANS_CMD_FORWARD_KEY_EVENT);
1589 m_impl->send.put_data (m_impl->focused_ic);
1591 m_impl->send.put_data ((uint32)ic);
1593 m_impl->send.put_data (ic_uuid);
1594 m_impl->send.put_data (key);
1595 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1600 * @brief Commit a WideString to client application directly.
1602 * @param ic The handle of the client Input Context to receive the WideString.
1603 * -1 means the currently focused Input Context.
1604 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1605 * Empty means don't match.
1606 * @param wstr The WideString to be committed.
1609 HelperAgent::commit_string (int ic,
1610 const String &ic_uuid,
1611 const WideString &wstr) const
1614 if (m_impl->socket_active.is_connected ()) {
1615 m_impl->send.clear ();
1616 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1617 m_impl->send.put_data (m_impl->magic_active);
1618 m_impl->send.put_command (SCIM_TRANS_CMD_COMMIT_STRING);
1620 m_impl->send.put_data (m_impl->focused_ic);
1622 m_impl->send.put_data ((uint32)ic);
1624 m_impl->send.put_data (ic_uuid);
1625 m_impl->send.put_data (wstr);
1626 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1631 HelperAgent::commit_string (int ic,
1632 const String &ic_uuid,
1637 if (m_impl->socket_active.is_connected ()) {
1638 m_impl->send.clear ();
1639 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1640 m_impl->send.put_data (m_impl->magic_active);
1641 m_impl->send.put_command (SCIM_TRANS_CMD_COMMIT_STRING);
1643 m_impl->send.put_data (m_impl->focused_ic);
1645 m_impl->send.put_data ((uint32)ic);
1647 m_impl->send.put_data (ic_uuid);
1648 m_impl->send.put_dataw (buf, buflen);
1649 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1654 * @brief Request to show preedit string.
1656 * @param ic The handle of the client Input Context to receive the request.
1657 * -1 means the currently focused Input Context.
1658 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1659 * Empty means don't match.
1662 HelperAgent::show_preedit_string (int ic,
1663 const String &ic_uuid) const
1667 if (m_impl->socket_active.is_connected ()) {
1668 m_impl->send.clear ();
1669 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1670 m_impl->send.put_data (m_impl->magic_active);
1671 m_impl->send.put_command (SCIM_TRANS_CMD_SHOW_PREEDIT_STRING);
1672 m_impl->send.put_data ((uint32)ic);
1673 m_impl->send.put_data (ic_uuid);
1674 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1679 * @brief Request to show aux string.
1682 HelperAgent::show_aux_string (void) const
1686 if (m_impl->socket_active.is_connected ()) {
1687 m_impl->send.clear ();
1688 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1689 m_impl->send.put_data (m_impl->magic_active);
1690 m_impl->send.put_command (SCIM_TRANS_CMD_SHOW_AUX_STRING);
1691 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1696 * @brief Request to show candidate string.
1699 HelperAgent::show_candidate_string (void) const
1703 if (m_impl->socket_active.is_connected ()) {
1704 m_impl->send.clear ();
1705 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1706 m_impl->send.put_data (m_impl->magic_active);
1707 m_impl->send.put_command (SCIM_TRANS_CMD_SHOW_LOOKUP_TABLE);
1708 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1713 * @brief Request to show associate string.
1716 HelperAgent::show_associate_string (void) const
1719 if (m_impl->socket_active.is_connected ()) {
1720 m_impl->send.clear ();
1721 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1722 m_impl->send.put_data (m_impl->magic_active);
1723 m_impl->send.put_command (ISM_TRANS_CMD_SHOW_ASSOCIATE_TABLE);
1724 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1729 * @brief Request to hide preedit string.
1731 * @param ic The handle of the client Input Context to receive the request.
1732 * -1 means the currently focused Input Context.
1733 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1734 * Empty means don't match.
1737 HelperAgent::hide_preedit_string (int ic,
1738 const String &ic_uuid) const
1742 if (m_impl->socket_active.is_connected ()) {
1743 m_impl->send.clear ();
1744 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1745 m_impl->send.put_data (m_impl->magic_active);
1746 m_impl->send.put_command (SCIM_TRANS_CMD_HIDE_PREEDIT_STRING);
1747 m_impl->send.put_data ((uint32)ic);
1748 m_impl->send.put_data (ic_uuid);
1749 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1754 * @brief Request to hide aux string.
1757 HelperAgent::hide_aux_string (void) const
1760 if (m_impl->socket_active.is_connected ()) {
1761 m_impl->send.clear ();
1762 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1763 m_impl->send.put_data (m_impl->magic_active);
1764 m_impl->send.put_command (SCIM_TRANS_CMD_HIDE_AUX_STRING);
1765 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1770 * @brief Request to hide candidate string.
1773 HelperAgent::hide_candidate_string (void) const
1776 if (m_impl->socket_active.is_connected ()) {
1777 m_impl->send.clear ();
1778 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1779 m_impl->send.put_data (m_impl->magic_active);
1780 m_impl->send.put_command (SCIM_TRANS_CMD_HIDE_LOOKUP_TABLE);
1781 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1786 * @brief Request to hide associate string.
1789 HelperAgent::hide_associate_string (void) const
1792 if (m_impl->socket_active.is_connected ()) {
1793 m_impl->send.clear ();
1794 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1795 m_impl->send.put_data (m_impl->magic_active);
1796 m_impl->send.put_command (ISM_TRANS_CMD_HIDE_ASSOCIATE_TABLE);
1797 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1802 * @brief Update a new WideString for preedit.
1804 * @param ic The handle of the client Input Context to receive the WideString.
1805 * -1 means the currently focused Input Context.
1806 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1807 * Empty means don't match.
1808 * @param str The WideString to be updated.
1809 * @param attrs The attribute list for preedit string.
1812 HelperAgent::update_preedit_string (int ic,
1813 const String &ic_uuid,
1814 const WideString &str,
1815 const AttributeList &attrs) const
1818 update_preedit_string (ic, ic_uuid, str, str, attrs, -1);
1822 HelperAgent::update_preedit_string (int ic,
1823 const String &ic_uuid,
1826 const AttributeList &attrs) const
1829 update_preedit_string (ic, ic_uuid, buf, buflen, attrs, -1);
1833 * @brief Update a new WideString for preedit.
1835 * @param ic The handle of the client Input Context to receive the WideString.
1836 * -1 means the currently focused Input Context.
1837 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1838 * Empty means don't match.
1839 * @param str The WideString to be updated.
1840 * @param attrs The attribute list for preedit string.
1841 * @param caret The caret position in preedit string.
1844 HelperAgent::update_preedit_string (int ic,
1845 const String &ic_uuid,
1846 const WideString &wstr,
1847 const AttributeList &attrs,
1851 update_preedit_string (ic, ic_uuid, wstr, wstr, attrs, caret);
1855 HelperAgent::update_preedit_string (int ic,
1856 const String &ic_uuid,
1859 const AttributeList &attrs,
1864 if (m_impl->socket_active.is_connected ()) {
1865 m_impl->send.clear ();
1866 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1867 m_impl->send.put_data (m_impl->magic_active);
1868 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING);
1869 m_impl->send.put_data ((uint32)ic);
1870 m_impl->send.put_data (ic_uuid);
1871 m_impl->send.put_dataw (buf, buflen);
1872 m_impl->send.put_dataw (buf, buflen);
1873 m_impl->send.put_data (attrs);
1874 m_impl->send.put_data (caret);
1875 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1880 HelperAgent::update_preedit_string (int ic,
1881 const String &ic_uuid,
1882 const WideString &preedit,
1883 const WideString &commit,
1884 const AttributeList &attrs,
1888 if (m_impl->socket_active.is_connected ()) {
1889 m_impl->send.clear ();
1890 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1891 m_impl->send.put_data (m_impl->magic_active);
1892 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING);
1893 m_impl->send.put_data ((uint32)ic);
1894 m_impl->send.put_data (ic_uuid);
1895 m_impl->send.put_data (preedit);
1896 m_impl->send.put_data (commit);
1897 m_impl->send.put_data (attrs);
1898 m_impl->send.put_data (caret);
1899 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1904 * @brief Update the preedit caret position in the preedit string.
1906 * @param caret - the new position of the preedit caret.
1909 HelperAgent::update_preedit_caret (int caret) const
1913 if (m_impl->socket_active.is_connected ()) {
1914 m_impl->send.clear ();
1915 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1916 m_impl->send.put_data (m_impl->magic_active);
1917 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_CARET);
1918 m_impl->send.put_data ((uint32)caret);
1919 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1924 * @brief Update a new string for aux.
1926 * @param str The string to be updated.
1927 * @param attrs The attribute list for aux string.
1930 HelperAgent::update_aux_string (const String &str,
1931 const AttributeList &attrs) const
1934 if (m_impl->socket_active.is_connected ()) {
1935 m_impl->send.clear ();
1936 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1937 m_impl->send.put_data (m_impl->magic_active);
1938 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_AUX_STRING);
1939 m_impl->send.put_data (str);
1940 m_impl->send.put_data (attrs);
1941 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1946 * @brief Request to update candidate.
1948 * @param table The lookup table for candidate.
1951 HelperAgent::update_candidate_string (const LookupTable &table) const
1954 if (m_impl->socket_active.is_connected ()) {
1955 m_impl->send.clear ();
1956 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1957 m_impl->send.put_data (m_impl->magic_active);
1958 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_LOOKUP_TABLE);
1959 m_impl->send.put_data (table);
1960 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1965 * @brief Request to update associate.
1967 * @param table The lookup table for associate.
1970 HelperAgent::update_associate_string (const LookupTable &table) const
1973 if (m_impl->socket_active.is_connected ()) {
1974 m_impl->send.clear ();
1975 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1976 m_impl->send.put_data (m_impl->magic_active);
1977 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ASSOCIATE_TABLE);
1978 m_impl->send.put_data (table);
1979 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1984 * @brief When the input context of ISE is changed,
1985 * ISE can call this function to notify application
1987 * @param type type of event.
1988 * @param value value of event.
1991 HelperAgent::update_input_context (uint32 type, uint32 value) const
1994 if (m_impl->socket_active.is_connected ()) {
1995 m_impl->send.clear ();
1996 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1997 m_impl->send.put_data (m_impl->magic_active);
1998 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ISE_INPUT_CONTEXT);
1999 m_impl->send.put_data (type);
2000 m_impl->send.put_data (value);
2001 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2006 * @brief Request to get surrounding text asynchronously.
2008 * @param uuid The helper ISE UUID.
2009 * @param maxlen_before The max length of before.
2010 * @param maxlen_after The max length of after.
2013 HelperAgent::get_surrounding_text (const String &uuid, int maxlen_before, int maxlen_after) const
2016 if (m_impl->socket_active.is_connected () && (m_impl->need_update_surrounding_text == 0)) {
2017 m_impl->send.clear ();
2018 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2019 m_impl->send.put_data (m_impl->magic_active);
2020 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SURROUNDING_TEXT);
2021 m_impl->send.put_data (uuid);
2022 m_impl->send.put_data (maxlen_before);
2023 m_impl->send.put_data (maxlen_after);
2024 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2026 m_impl->need_update_surrounding_text++;
2030 * @brief Request to get surrounding text synchronously.
2032 * @param uuid The helper ISE UUID.
2033 * @param maxlen_before The max length of before.
2034 * @param maxlen_after The max length of after.
2035 * @param text The surrounding text.
2036 * @param cursor The cursor position.
2039 HelperAgent::get_surrounding_text (int maxlen_before, int maxlen_after, String &text, int &cursor)
2043 if (!m_impl->socket_active.is_connected ())
2046 m_impl->send.clear ();
2047 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2048 m_impl->send.put_data (m_impl->magic_active);
2049 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SURROUNDING_TEXT);
2050 m_impl->send.put_data ("");
2051 m_impl->send.put_data (maxlen_before);
2052 m_impl->send.put_data (maxlen_after);
2053 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2054 if (m_impl->surrounding_text) {
2055 free (m_impl->surrounding_text);
2056 m_impl->surrounding_text = NULL;
2059 const int WAIT_FOR_SYNC_RESPONSE_TIMEOUT = 1000;
2060 /* Now we are waiting for the ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT message */
2061 if (wait_for_message(ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT, WAIT_FOR_SYNC_RESPONSE_TIMEOUT)) {
2062 MessageItem *message = message_queue.get_pending_message_by_cmd(ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT);
2063 handle_message(message);
2064 message_queue.remove_message(message);
2066 if (m_impl->surrounding_text) {
2067 text = m_impl->surrounding_text;
2068 cursor = m_impl->cursor_pos;
2072 if (m_impl->surrounding_text) {
2073 free (m_impl->surrounding_text);
2074 m_impl->surrounding_text = NULL;
2079 * @brief Request to delete surrounding text.
2081 * @param offset The offset for cursor position.
2082 * @param len The length for delete text.
2085 HelperAgent::delete_surrounding_text (int offset, int len) const
2087 LOGD ("offset = %d, len = %d", offset, len);
2089 if (m_impl->socket_active.is_connected ()) {
2090 m_impl->send.clear ();
2091 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2092 m_impl->send.put_data (m_impl->magic_active);
2093 m_impl->send.put_command (SCIM_TRANS_CMD_DELETE_SURROUNDING_TEXT);
2094 m_impl->send.put_data (offset);
2095 m_impl->send.put_data (len);
2096 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2101 * @brief Request to get selection text asynchronously.
2103 * @param uuid The helper ISE UUID.
2106 HelperAgent::get_selection (const String &uuid) const
2109 if (m_impl->socket_active.is_connected () && (m_impl->need_update_selection_text == 0)) {
2110 m_impl->send.clear ();
2111 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2112 m_impl->send.put_data (m_impl->magic_active);
2113 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SELECTION);
2114 m_impl->send.put_data (uuid);
2115 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2117 m_impl->need_update_selection_text++;
2121 * @brief Request to get selection text synchronously.
2123 * @param text The selection text.
2126 HelperAgent::get_selection_text (String &text)
2130 if (!m_impl->socket_active.is_connected ())
2133 m_impl->send.clear ();
2134 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2135 m_impl->send.put_data (m_impl->magic_active);
2136 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SELECTION);
2137 m_impl->send.put_data ("");
2138 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2139 if (m_impl->selection_text) {
2140 free (m_impl->selection_text);
2141 m_impl->selection_text = NULL;
2144 const int WAIT_FOR_SYNC_RESPONSE_TIMEOUT = 1000;
2145 /* Now we are waiting for the ISM_TRANS_CMD_UPDATE_SELECTION message */
2146 if (wait_for_message(ISM_TRANS_CMD_UPDATE_SELECTION, WAIT_FOR_SYNC_RESPONSE_TIMEOUT)) {
2147 MessageItem *message = message_queue.get_pending_message_by_cmd(ISM_TRANS_CMD_UPDATE_SELECTION);
2148 handle_message(message);
2149 message_queue.remove_message(message);
2150 if (m_impl->selection_text) {
2151 text = m_impl->selection_text;
2155 if (m_impl->selection_text) {
2156 free (m_impl->selection_text);
2157 m_impl->selection_text = NULL;
2162 * @brief Request to select text.
2164 * @param start The start position in text.
2165 * @param end The end position in text.
2168 HelperAgent::set_selection (int start, int end) const
2171 if (m_impl->socket_active.is_connected ()) {
2172 m_impl->send.clear ();
2173 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2174 m_impl->send.put_data (m_impl->magic_active);
2175 m_impl->send.put_command (SCIM_TRANS_CMD_SET_SELECTION);
2176 m_impl->send.put_data (start);
2177 m_impl->send.put_data (end);
2178 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2183 * @brief Send a private command to an application.
2185 * @param command The private command sent from IME.
2188 HelperAgent::send_private_command (const String &command) const
2191 if (m_impl->socket_active.is_connected ()) {
2192 m_impl->send.clear ();
2193 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2194 m_impl->send.put_data (m_impl->magic_active);
2195 m_impl->send.put_command (SCIM_TRANS_CMD_SEND_PRIVATE_COMMAND);
2196 m_impl->send.put_data (command);
2197 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2202 * @brief Request to get uuid list of all keyboard ISEs.
2204 * @param uuid The helper ISE UUID.
2207 HelperAgent::get_keyboard_ise_list (const String &uuid) const
2210 if (m_impl->socket_active.is_connected ()) {
2211 m_impl->send.clear ();
2212 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2213 m_impl->send.put_data (m_impl->magic_active);
2214 m_impl->send.put_command (ISM_TRANS_CMD_GET_KEYBOARD_ISE_LIST);
2215 m_impl->send.put_data (uuid);
2216 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2221 * @brief Set candidate position in screen.
2223 * @param left The x position in screen.
2224 * @param top The y position in screen.
2227 HelperAgent::set_candidate_position (int left, int top) const
2230 if (m_impl->socket_active.is_connected ()) {
2231 m_impl->send.clear ();
2232 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2233 m_impl->send.put_data (m_impl->magic_active);
2234 m_impl->send.put_command (ISM_TRANS_CMD_SET_CANDIDATE_POSITION);
2235 m_impl->send.put_data (left);
2236 m_impl->send.put_data (top);
2237 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2242 * @brief Set candidate style.
2244 * @param portrait_line - the displayed line number for portrait mode.
2245 * @param mode - candidate window mode.
2248 HelperAgent::set_candidate_style (ISF_CANDIDATE_PORTRAIT_LINE_T portrait_line,
2249 ISF_CANDIDATE_MODE_T mode) const
2252 if (m_impl->socket_active.is_connected ()) {
2253 m_impl->send.clear ();
2254 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2255 m_impl->send.put_data (m_impl->magic_active);
2256 m_impl->send.put_command (ISM_TRANS_CMD_SET_CANDIDATE_UI);
2257 m_impl->send.put_data (portrait_line);
2258 m_impl->send.put_data (mode);
2259 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2264 * @brief Request to hide candidate window.
2267 HelperAgent::candidate_hide (void) const
2270 if (m_impl->socket_active.is_connected ()) {
2271 m_impl->send.clear ();
2272 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2273 m_impl->send.put_data (m_impl->magic_active);
2274 m_impl->send.put_command (ISM_TRANS_CMD_HIDE_CANDIDATE);
2275 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2280 * @brief Request to get candidate window size and position.
2282 * @param uuid The helper ISE UUID.
2285 HelperAgent::get_candidate_window_geometry (const String &uuid) const
2288 if (m_impl->socket_active.is_connected ()) {
2289 m_impl->send.clear ();
2290 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2291 m_impl->send.put_data (m_impl->magic_active);
2292 m_impl->send.put_command (ISM_TRANS_CMD_GET_CANDIDATE_GEOMETRY);
2293 m_impl->send.put_data (uuid);
2294 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2299 * @brief Set current keyboard ISE.
2301 * @param uuid The keyboard ISE UUID.
2304 HelperAgent::set_keyboard_ise_by_uuid (const String &uuid) const
2308 IMEngineFactoryPointer factory;
2309 IMEngineModule *engine_module = NULL;
2310 static int instance_count = 1;
2312 if ((!m_impl->si.null ()) && m_impl->si->get_factory_uuid () == uuid) {
2313 LOGD ("Already in UUID: %s\n", uuid.c_str());
2317 if (!m_impl->si.null()) {
2318 m_impl->si->focus_out();
2322 if (m_impl->m_config.null ()) {
2323 LOGW ("config is not working");
2327 #ifdef HAVE_PKGMGR_INFO
2330 pkgmgrinfo_appinfo_h handle;
2331 ret = pkgmgrinfo_appinfo_get_appinfo(uuid.c_str(), &handle);
2332 if (ret != PMINFO_R_OK) {
2333 LOGW("Retrieve app info failed : %s", uuid.c_str ());
2337 ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
2338 if (ret != PMINFO_R_OK) {
2339 LOGW("Retrieve pkgid failed : %s, %p", uuid.c_str(), handle);
2340 pkgmgrinfo_appinfo_destroy_appinfo(handle);
2344 imeInfo.module_name = pkgid;
2345 pkgmgrinfo_appinfo_destroy_appinfo(handle);
2347 if (isf_db_select_ime_info_by_appid(uuid.c_str(), &imeInfo) < 1) {
2348 LOGW("ime_info row is not available for %s", uuid.c_str());
2353 engine_module = &m_impl->engine_module;
2355 if (engine_module->valid() && imeInfo.module_name != engine_module->get_module_name()) {
2356 LOGD ("imengine module %s unloaded", engine_module->get_module_name().c_str());
2357 engine_module->unload();
2360 if (!engine_module->valid()) {
2361 if (engine_module->load (imeInfo.module_name, m_impl->m_config) == false) {
2362 LOGW ("load module %s failed", imeInfo.module_name.c_str());
2365 LOGD ("imengine module %s loaded", imeInfo.module_name.c_str());
2368 for (size_t j = 0; j < engine_module->number_of_factories (); ++j) {
2371 factory = engine_module->create_factory (j);
2372 if (factory.null () == false && factory->get_uuid () == uuid)
2380 if (factory.null()) {
2381 LOGW ("imengine uuid %s is not found", uuid.c_str());
2385 m_impl->si = factory->create_instance ("UTF-8", instance_count++);
2386 if (m_impl->si.null ()) {
2387 LOGE ("create_instance %s failed",uuid.c_str ());
2391 m_impl->attach_instance ();
2392 LOGD ("Require UUID: %s Current UUID: %s", uuid.c_str (), m_impl->si->get_factory_uuid ().c_str ());
2393 m_impl->si->set_layout (m_impl->layout);
2394 if(m_impl->focused_ic != (uint32)-1)
2395 m_impl->si->focus_in ();
2399 * @brief Request to get current keyboard ISE information.
2401 * @param uuid The helper ISE UUID.
2404 HelperAgent::get_keyboard_ise (const String &uuid) const
2407 //FIXME: maybe useless
2409 if (m_impl->socket_active.is_connected ()) {
2410 m_impl->send.clear ();
2411 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2412 m_impl->send.put_data (m_impl->magic_active);
2413 m_impl->send.put_command (ISM_TRANS_CMD_GET_KEYBOARD_ISE);
2414 m_impl->send.put_data (uuid);
2415 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2421 * @brief Update ISE window geometry.
2423 * @param x The x position in screen.
2424 * @param y The y position in screen.
2425 * @param width The ISE window width.
2426 * @param height The ISE window height.
2429 HelperAgent::update_geometry (int x, int y, int width, int height) const
2432 if (m_impl->socket_active.is_connected ()) {
2433 m_impl->send.clear ();
2434 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2435 m_impl->send.put_data (m_impl->magic_active);
2436 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ISE_GEOMETRY);
2437 m_impl->send.put_data (x);
2438 m_impl->send.put_data (y);
2439 m_impl->send.put_data (width);
2440 m_impl->send.put_data (height);
2441 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2446 * @brief Request to expand candidate window.
2449 HelperAgent::expand_candidate (void) const
2452 if (m_impl->socket_active.is_connected ()) {
2453 m_impl->send.clear ();
2454 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2455 m_impl->send.put_data (m_impl->magic_active);
2456 m_impl->send.put_command (ISM_TRANS_CMD_EXPAND_CANDIDATE);
2457 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2462 * @brief Request to contract candidate window.
2465 HelperAgent::contract_candidate (void) const
2468 if (m_impl->socket_active.is_connected ()) {
2469 m_impl->send.clear ();
2470 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2471 m_impl->send.put_data (m_impl->magic_active);
2472 m_impl->send.put_command (ISM_TRANS_CMD_CONTRACT_CANDIDATE);
2473 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2478 * @brief Send selected candidate string index number.
2481 HelperAgent::select_candidate (int index) const
2484 if (!m_impl->si.null ())
2485 m_impl->si->select_candidate (index);
2486 //FIXME: maybe useless
2489 if (m_impl->socket_active.is_connected ()) {
2490 m_impl->send.clear ();
2491 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2492 m_impl->send.put_data (m_impl->magic_active);
2493 m_impl->send.put_command (ISM_TRANS_CMD_SELECT_CANDIDATE);
2494 m_impl->send.put_data (index);
2495 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2501 * @brief Update our ISE is exiting.
2504 HelperAgent::update_ise_exit (void) const
2507 //FIXME: maybe useless
2509 if (m_impl->socket_active.is_connected ()) {
2510 m_impl->send.clear ();
2511 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2512 m_impl->send.put_data (m_impl->magic_active);
2513 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ISE_EXIT);
2514 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2520 * @brief Request to reset keyboard ISE.
2523 HelperAgent::reset_keyboard_ise (void) const
2526 //FIXME: maybe useless
2528 if (m_impl->socket_active.is_connected ()) {
2529 m_impl->send.clear ();
2530 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2531 m_impl->send.put_data (m_impl->magic_active);
2532 m_impl->send.put_command (ISM_TRANS_CMD_PANEL_RESET_KEYBOARD_ISE);
2533 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2536 if (!m_impl->si.null ()) {
2537 m_impl->si->reset ();
2542 * @brief Request to flush keyboard ISE.
2545 HelperAgent::flush_keyboard_ise (void) const
2548 if (!m_impl->si.null ()) {
2549 m_impl->si->flush ();
2554 * @brief Request panel to hide ISE.
2557 HelperAgent::request_ise_hide (void) const
2560 if (m_impl->socket_active.is_connected ()) {
2561 m_impl->send.clear ();
2562 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2563 m_impl->send.put_data (m_impl->magic_active);
2564 m_impl->send.put_command (ISM_TRANS_CMD_REQUEST_ISE_HIDE);
2565 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2573 HelperAgent::recapture_string (int ic,
2574 const String &ic_uuid,
2577 const WideString &preedit_str,
2578 const WideString &commit_str,
2579 const AttributeList &attrs) const
2581 LOGD ("offset = %d, len = %d", offset, len);
2583 if (m_impl->socket_active.is_connected ()) {
2584 m_impl->send.clear ();
2585 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2586 m_impl->send.put_data (m_impl->magic_active);
2587 m_impl->send.put_command (ISM_TRANS_CMD_RECAPTURE_STRING);
2589 m_impl->send.put_data ((uint32)ic);
2590 m_impl->send.put_data (ic_uuid);
2592 // Deleting surrounding text
2593 m_impl->send.put_data (offset);
2594 m_impl->send.put_data (len);
2596 // Update preedit text
2597 m_impl->send.put_data (preedit_str);
2600 m_impl->send.put_data (commit_str);
2602 // preedit attributes
2603 m_impl->send.put_data (attrs);
2605 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2610 * @brief Connect a slot to Helper exit signal.
2612 * This signal is used to let the Helper exit.
2614 * The prototype of the slot is:
2616 * void exit (const HelperAgent *agent, int ic, const String &ic_uuid);
2619 * - agent The pointer to the HelperAgent object which emits this signal.
2620 * - ic An opaque handle of the currently focused input context.
2621 * - ic_uuid The UUID of the IMEngineInstance associated with the focused input context.
2624 HelperAgent::signal_connect_exit (HelperAgentSlotVoid *slot)
2626 return m_impl->signal_exit.connect (slot);
2630 * @brief Connect a slot to Helper attach input context signal.
2632 * This signal is used to attach an input context to this helper.
2634 * When an input context requst to start this helper, then this
2635 * signal will be emitted as soon as the helper is started.
2637 * When an input context want to start an already started helper,
2638 * this signal will also be emitted.
2640 * Helper can send some events back to the IMEngineInstance in this
2641 * signal-slot, to inform that it has been started sccessfully.
2643 * The prototype of the slot is:
2645 * void attach_input_context (const HelperAgent *agent, int ic, const String &ic_uuid);
2648 HelperAgent::signal_connect_attach_input_context (HelperAgentSlotVoid *slot)
2650 return m_impl->signal_attach_input_context.connect (slot);
2654 * @brief Connect a slot to Helper detach input context signal.
2656 * This signal is used to detach an input context from this helper.
2658 * When an input context requst to stop this helper, then this
2659 * signal will be emitted.
2661 * Helper shouldn't send any event back to the IMEngineInstance, because
2662 * the IMEngineInstance attached to the ic should have been destroyed.
2664 * The prototype of the slot is:
2666 * void detach_input_context (const HelperAgent *agent, int ic, const String &ic_uuid);
2669 HelperAgent::signal_connect_detach_input_context (HelperAgentSlotVoid *slot)
2671 return m_impl->signal_detach_input_context.connect (slot);
2675 * @brief Connect a slot to Helper reload config signal.
2677 * This signal is used to let the Helper reload configuration.
2679 * The prototype of the slot is:
2681 * void reload_config (const HelperAgent *agent, int ic, const String &ic_uuid);
2684 HelperAgent::signal_connect_reload_config (HelperAgentSlotVoid *slot)
2686 return m_impl->signal_reload_config.connect (slot);
2690 * @brief Connect a slot to Helper update screen signal.
2692 * This signal is used to let the Helper move its GUI to another screen.
2693 * It can only be emitted when SCIM_HELPER_NEED_SCREEN_INFO is set in HelperInfo.option.
2695 * The prototype of the slot is:
2697 * void update_screen (const HelperAgent *agent, int ic, const String &ic_uuid, int screen_number);
2700 HelperAgent::signal_connect_update_screen (HelperAgentSlotInt *slot)
2702 return m_impl->signal_update_screen.connect (slot);
2706 * @brief Connect a slot to Helper update spot location signal.
2708 * This signal is used to let the Helper move its GUI according to the current spot location.
2709 * It can only be emitted when SCIM_HELPER_NEED_SPOT_LOCATION_INFO is set in HelperInfo.option.
2711 * The prototype of the slot is:
2712 * void update_spot_location (const HelperAgent *agent, int ic, const String &ic_uuid, int x, int y);
2715 HelperAgent::signal_connect_update_spot_location (HelperAgentSlotIntInt *slot)
2717 return m_impl->signal_update_spot_location.connect (slot);
2721 * @brief Connect a slot to Helper update cursor position signal.
2723 * This signal is used to let the Helper get the cursor position information.
2725 * The prototype of the slot is:
2726 * void update_cursor_position (const HelperAgent *agent, int ic, const String &ic_uuid, int cursor_pos);
2729 HelperAgent::signal_connect_update_cursor_position (HelperAgentSlotInt *slot)
2731 return m_impl->signal_update_cursor_position.connect (slot);
2735 * @brief Connect a slot to Helper update surrounding text signal.
2737 * This signal is used to let the Helper get the surrounding text.
2739 * The prototype of the slot is:
2740 * void update_surrounding_text (const HelperAgent *agent, int ic, const String &text, int cursor);
2743 HelperAgent::signal_connect_update_surrounding_text (HelperAgentSlotInt *slot)
2745 return m_impl->signal_update_surrounding_text.connect (slot);
2749 * @brief Connect a slot to Helper update selection signal.
2751 * This signal is used to let the Helper get the selection.
2753 * The prototype of the slot is:
2754 * void update_selection (const HelperAgent *agent, int ic, const String &text);
2757 HelperAgent::signal_connect_update_selection (HelperAgentSlotVoid *slot)
2759 return m_impl->signal_update_selection.connect (slot);
2763 * @brief Connect a slot to Helper trigger property signal.
2765 * This signal is used to trigger a property registered by this Helper.
2766 * A property will be triggered when user clicks on it.
2768 * The prototype of the slot is:
2769 * void trigger_property (const HelperAgent *agent, int ic, const String &ic_uuid, const String &property);
2772 HelperAgent::signal_connect_trigger_property (HelperAgentSlotString *slot)
2774 return m_impl->signal_trigger_property.connect (slot);
2778 * @brief Connect a slot to Helper process imengine event signal.
2780 * This signal is used to deliver the events sent from IMEngine to Helper.
2782 * The prototype of the slot is:
2783 * void process_imengine_event (const HelperAgent *agent, int ic, const String &ic_uuid, const Transaction &transaction);
2786 HelperAgent::signal_connect_process_imengine_event (HelperAgentSlotTransaction *slot)
2788 return m_impl->signal_process_imengine_event.connect (slot);
2792 * @brief Connect a slot to Helper focus out signal.
2794 * This signal is used to do something when input context is focus out.
2796 * The prototype of the slot is:
2797 * void focus_out (const HelperAgent *agent, int ic, const String &ic_uuid);
2800 HelperAgent::signal_connect_focus_out (HelperAgentSlotVoid *slot)
2802 return m_impl->signal_focus_out.connect (slot);
2806 * @brief Connect a slot to Helper focus in signal.
2808 * This signal is used to do something when input context is focus in.
2810 * The prototype of the slot is:
2811 * void focus_in (const HelperAgent *agent, int ic, const String &ic_uuid);
2814 HelperAgent::signal_connect_focus_in (HelperAgentSlotVoid *slot)
2816 return m_impl->signal_focus_in.connect (slot);
2820 * @brief Connect a slot to Helper show signal.
2822 * This signal is used to show Helper ISE window.
2824 * The prototype of the slot is:
2825 * void ise_show (const HelperAgent *agent, int ic, char *buf, size_t &len);
2828 HelperAgent::signal_connect_ise_show (HelperAgentSlotIntRawVoid *slot)
2830 return m_impl->signal_ise_show.connect (slot);
2834 * @brief Connect a slot to Helper hide signal.
2836 * This signal is used to hide Helper ISE window.
2838 * The prototype of the slot is:
2839 * void ise_hide (const HelperAgent *agent, int ic, const String &ic_uuid);
2842 HelperAgent::signal_connect_ise_hide (HelperAgentSlotVoid *slot)
2844 return m_impl->signal_ise_hide.connect (slot);
2848 * @brief Connect a slot to Helper get ISE window geometry signal.
2850 * This signal is used to get Helper ISE window size and position.
2852 * The prototype of the slot is:
2853 * void get_geometry (const HelperAgent *agent, struct rectinfo &info);
2856 HelperAgent::signal_connect_get_geometry (HelperAgentSlotSize *slot)
2858 return m_impl->signal_get_geometry.connect (slot);
2862 * @brief Connect a slot to Helper set mode signal.
2864 * This signal is used to set Helper ISE mode.
2866 * The prototype of the slot is:
2867 * void set_mode (const HelperAgent *agent, uint32 &mode);
2870 HelperAgent::signal_connect_set_mode (HelperAgentSlotUintVoid *slot)
2872 return m_impl->signal_set_mode.connect (slot);
2876 * @brief Connect a slot to Helper set language signal.
2878 * This signal is used to set Helper ISE language.
2880 * The prototype of the slot is:
2881 * void set_language (const HelperAgent *agent, uint32 &language);
2884 HelperAgent::signal_connect_set_language (HelperAgentSlotUintVoid *slot)
2886 return m_impl->signal_set_language.connect (slot);
2890 * @brief Connect a slot to Helper set im data signal.
2892 * This signal is used to send im data to Helper ISE.
2894 * The prototype of the slot is:
2895 * void set_imdata (const HelperAgent *agent, char *buf, size_t &len);
2898 HelperAgent::signal_connect_set_imdata (HelperAgentSlotRawVoid *slot)
2900 return m_impl->signal_set_imdata.connect (slot);
2904 * @brief Connect a slot to Helper get im data signal.
2906 * This signal is used to get im data from Helper ISE.
2908 * The prototype of the slot is:
2909 * void get_imdata (const HelperAgent *, char **buf, size_t &len);
2912 HelperAgent::signal_connect_get_imdata (HelperAgentSlotGetRawVoid *slot)
2914 return m_impl->signal_get_imdata.connect (slot);
2918 * @brief Connect a slot to Helper get language locale signal.
2920 * This signal is used to get language locale from Helper ISE.
2922 * The prototype of the slot is:
2923 * void get_language_locale (const HelperAgent *, int ic, char **locale);
2926 HelperAgent::signal_connect_get_language_locale (HelperAgentSlotIntGetStringVoid *slot)
2928 return m_impl->signal_get_language_locale.connect (slot);
2932 * @brief Connect a slot to Helper set return key type signal.
2934 * This signal is used to send return key type to Helper ISE.
2936 * The prototype of the slot is:
2937 * void set_return_key_type (const HelperAgent *agent, uint32 &type);
2940 HelperAgent::signal_connect_set_return_key_type (HelperAgentSlotUintVoid *slot)
2942 return m_impl->signal_set_return_key_type.connect (slot);
2946 * @brief Connect a slot to Helper get return key type signal.
2948 * This signal is used to get return key type from Helper ISE.
2950 * The prototype of the slot is:
2951 * void get_return_key_type (const HelperAgent *agent, uint32 &type);
2954 HelperAgent::signal_connect_get_return_key_type (HelperAgentSlotUintVoid *slot)
2956 return m_impl->signal_get_return_key_type.connect (slot);
2960 * @brief Connect a slot to Helper set return key disable signal.
2962 * This signal is used to send return key disable to Helper ISE.
2964 * The prototype of the slot is:
2965 * void set_return_key_disable (const HelperAgent *agent, uint32 &disabled);
2968 HelperAgent::signal_connect_set_return_key_disable (HelperAgentSlotUintVoid *slot)
2970 return m_impl->signal_set_return_key_disable.connect (slot);
2974 * @brief Connect a slot to Helper process key event signal.
2976 * This signal is used to send keyboard key event to Helper ISE.
2978 * The prototype of the slot is:
2979 * void process_key_event (const HelperAgent *agent, KeyEvent &key, uint32 &ret);
2982 HelperAgent::signal_connect_process_key_event (HelperAgentSlotKeyEventUint *slot)
2984 return m_impl->signal_process_key_event.connect (slot);
2988 * @brief Connect a slot to Helper get return key disable signal.
2990 * This signal is used to get return key disable from Helper ISE.
2992 * The prototype of the slot is:
2993 * void get_return_key_disable (const HelperAgent *agent, uint32 &disabled);
2996 HelperAgent::signal_connect_get_return_key_disable (HelperAgentSlotUintVoid *slot)
2998 return m_impl->signal_get_return_key_disable.connect (slot);
3002 * @brief Connect a slot to Helper set layout signal.
3004 * This signal is used to set Helper ISE layout.
3006 * The prototype of the slot is:
3007 * void set_layout (const HelperAgent *agent, uint32 &layout);
3010 HelperAgent::signal_connect_set_layout (HelperAgentSlotUintVoid *slot)
3012 return m_impl->signal_set_layout.connect (slot);
3016 * @brief Connect a slot to Helper get layout signal.
3018 * This signal is used to get Helper ISE layout.
3020 * The prototype of the slot is:
3021 * void get_layout (const HelperAgent *agent, uint32 &layout);
3024 HelperAgent::signal_connect_get_layout (HelperAgentSlotUintVoid *slot)
3026 return m_impl->signal_get_layout.connect (slot);
3030 * @brief Connect a slot to Helper set input mode signal.
3032 * This signal is used to set Helper ISE input mode.
3034 * The prototype of the slot is:
3035 * void set_input_mode (const HelperAgent *agent, uint32 &input_mode);
3038 HelperAgent::signal_connect_set_input_mode (HelperAgentSlotUintVoid *slot)
3040 return m_impl->signal_set_input_mode.connect (slot);
3044 * @brief Connect a slot to Helper set input hint signal.
3046 * This signal is used to set Helper ISE input hint.
3048 * The prototype of the slot is:
3049 * void set_input_hint (const HelperAgent *agent, uint32 &input_hint);
3052 HelperAgent::signal_connect_set_input_hint (HelperAgentSlotUintVoid *slot)
3054 return m_impl->signal_set_input_hint.connect (slot);
3058 * @brief Connect a slot to Helper set BiDi direction signal.
3060 * This signal is used to set Helper ISE BiDi direction.
3062 * The prototype of the slot is:
3063 * void update_bidi_direction (const HelperAgent *agent, uint32 &bidi_direction);
3066 HelperAgent::signal_connect_update_bidi_direction (HelperAgentSlotUintVoid *slot)
3068 return m_impl->signal_update_bidi_direction.connect (slot);
3072 * @brief Connect a slot to Helper set shift mode signal.
3074 * This signal is used to set Helper shift mode.
3076 * The prototype of the slot is:
3077 * void set_caps_mode (const HelperAgent *agent, uint32 &mode);
3080 HelperAgent::signal_connect_set_caps_mode (HelperAgentSlotUintVoid *slot)
3082 return m_impl->signal_set_caps_mode.connect (slot);
3086 * @brief Connect a slot to Helper reset input context signal.
3088 * This signal is used to reset Helper ISE input context.
3090 * The prototype of the slot is:
3091 * void reset_input_context (const HelperAgent *agent, int ic, const String &uuid);
3094 HelperAgent::signal_connect_reset_input_context (HelperAgentSlotVoid *slot)
3096 return m_impl->signal_reset_input_context.connect (slot);
3100 * @brief Connect a slot to Helper update candidate window geometry signal.
3102 * This signal is used to get candidate window size and position.
3104 * The prototype of the slot is:
3105 * void update_candidate_geometry (const HelperAgent *agent, int ic, const String &uuid, const rectinfo &info);
3108 HelperAgent::signal_connect_update_candidate_geometry (HelperAgentSlotRect *slot)
3110 return m_impl->signal_update_candidate_geometry.connect (slot);
3114 * @brief Connect a slot to Helper update keyboard ISE signal.
3116 * This signal is used to get current keyboard ISE name and uuid.
3118 * The prototype of the slot is:
3119 * void update_keyboard_ise (const HelperAgent *agent, int ic, const String &uuid,
3120 * const String &ise_name, const String &ise_uuid);
3123 HelperAgent::signal_connect_update_keyboard_ise (HelperAgentSlotString2 *slot)
3125 return m_impl->signal_update_keyboard_ise.connect (slot);
3129 * @brief Connect a slot to Helper update keyboard ISE list signal.
3131 * This signal is used to get uuid list of all keyboard ISEs.
3133 * The prototype of the slot is:
3134 * void update_keyboard_ise_list (const HelperAgent *agent, int ic, const String &uuid,
3135 * const std::vector<String> &ise_list);
3138 HelperAgent::signal_connect_update_keyboard_ise_list (HelperAgentSlotStringVector *slot)
3140 return m_impl->signal_update_keyboard_ise_list.connect (slot);
3144 * @brief Connect a slot to Helper candidate more window show signal.
3146 * This signal is used to do someting when candidate more window is showed.
3148 * The prototype of the slot is:
3149 * void candidate_more_window_show (const HelperAgent *agent, int ic, const String &uuid);
3152 HelperAgent::signal_connect_candidate_more_window_show (HelperAgentSlotVoid *slot)
3154 return m_impl->signal_candidate_more_window_show.connect (slot);
3158 * @brief Connect a slot to Helper candidate more window hide signal.
3160 * This signal is used to do someting when candidate more window is hidden.
3162 * The prototype of the slot is:
3163 * void candidate_more_window_hide (const HelperAgent *agent, int ic, const String &uuid);
3166 HelperAgent::signal_connect_candidate_more_window_hide (HelperAgentSlotVoid *slot)
3168 return m_impl->signal_candidate_more_window_hide.connect (slot);
3172 * @brief Connect a slot to Helper candidate show signal.
3174 * This signal is used to do candidate show.
3176 * The prototype of the slot is:
3177 * void candidate_show (const HelperAgent *agent, int ic, const String &uuid);
3180 HelperAgent::signal_connect_candidate_show (HelperAgentSlotVoid *slot)
3182 return m_impl->signal_candidate_show.connect (slot);
3186 * @brief Connect a slot to Helper candidate hide signal.
3188 * This signal is used to do candidate hide.
3190 * The prototype of the slot is:
3191 * void candidate_hide (const HelperAgent *agent, int ic, const String &uuid);
3194 HelperAgent::signal_connect_candidate_hide (HelperAgentSlotVoid *slot)
3196 return m_impl->signal_candidate_hide.connect (slot);
3200 * @brief Connect a slot to Helper update lookup table signal.
3202 * This signal is used to do someting when update lookup table.
3204 * The prototype of the slot is:
3205 * void update_lookup_table (const HelperAgent *agent, int ic, const String &uuid ,LookupTable &table);
3208 HelperAgent::signal_connect_update_lookup_table (HelperAgentSlotLookupTable *slot)
3210 return m_impl->signal_update_lookup_table.connect (slot);
3214 * @brief Connect a slot to Helper select aux signal.
3216 * This signal is used to do something when aux is selected.
3218 * The prototype of the slot is:
3219 * void select_aux (const HelperAgent *agent, int ic, const String &uuid, int index);
3222 HelperAgent::signal_connect_select_aux (HelperAgentSlotInt *slot)
3224 return m_impl->signal_select_aux.connect (slot);
3228 * @brief Connect a slot to Helper select candidate signal.
3230 * This signal is used to do something when candidate is selected.
3232 * The prototype of the slot is:
3233 * void select_candidate (const HelperAgent *agent, int ic, const String &uuid, int index);
3236 HelperAgent::signal_connect_select_candidate (HelperAgentSlotInt *slot)
3238 return m_impl->signal_select_candidate.connect (slot);
3242 * @brief Connect a slot to Helper candidate table page up signal.
3244 * This signal is used to do something when candidate table is paged up.
3246 * The prototype of the slot is:
3247 * void candidate_table_page_up (const HelperAgent *agent, int ic, const String &uuid);
3250 HelperAgent::signal_connect_candidate_table_page_up (HelperAgentSlotVoid *slot)
3252 return m_impl->signal_candidate_table_page_up.connect (slot);
3256 * @brief Connect a slot to Helper candidate table page down signal.
3258 * This signal is used to do something when candidate table is paged down.
3260 * The prototype of the slot is:
3261 * void candidate_table_page_down (const HelperAgent *agent, int ic, const String &uuid);
3264 HelperAgent::signal_connect_candidate_table_page_down (HelperAgentSlotVoid *slot)
3266 return m_impl->signal_candidate_table_page_down.connect (slot);
3270 * @brief Connect a slot to Helper update candidate table page size signal.
3272 * This signal is used to do something when candidate table page size is changed.
3274 * The prototype of the slot is:
3275 * void update_candidate_table_page_size (const HelperAgent *, int ic, const String &uuid, int page_size);
3278 HelperAgent::signal_connect_update_candidate_table_page_size (HelperAgentSlotInt *slot)
3280 return m_impl->signal_update_candidate_table_page_size.connect (slot);
3284 * @brief Connect a slot to Helper update candidate item layout signal.
3286 * The prototype of the slot is:
3287 * void update_candidate_item_layout (const HelperAgent *, const std::vector<uint32> &row_items);
3290 HelperAgent::signal_connect_update_candidate_item_layout (HelperAgentSlotUintVector *slot)
3292 return m_impl->signal_update_candidate_item_layout.connect (slot);
3296 * @brief Connect a slot to Helper select associate signal.
3298 * This signal is used to do something when associate is selected.
3300 * The prototype of the slot is:
3301 * void select_associate (const HelperAgent *agent, int ic, const String &uuid, int index);
3304 HelperAgent::signal_connect_select_associate (HelperAgentSlotInt *slot)
3306 return m_impl->signal_select_associate.connect (slot);
3310 * @brief Connect a slot to Helper associate table page up signal.
3312 * This signal is used to do something when associate table is paged up.
3314 * The prototype of the slot is:
3315 * void associate_table_page_up (const HelperAgent *agent, int ic, const String &uuid);
3318 HelperAgent::signal_connect_associate_table_page_up (HelperAgentSlotVoid *slot)
3320 return m_impl->signal_associate_table_page_up.connect (slot);
3324 * @brief Connect a slot to Helper associate table page down signal.
3326 * This signal is used to do something when associate table is paged down.
3328 * The prototype of the slot is:
3329 * void associate_table_page_down (const HelperAgent *agent, int ic, const String &uuid);
3332 HelperAgent::signal_connect_associate_table_page_down (HelperAgentSlotVoid *slot)
3334 return m_impl->signal_associate_table_page_down.connect (slot);
3338 * @brief Connect a slot to Helper update associate table page size signal.
3340 * This signal is used to do something when associate table page size is changed.
3342 * The prototype of the slot is:
3343 * void update_associate_table_page_size (const HelperAgent *, int ic, const String &uuid, int page_size);
3346 HelperAgent::signal_connect_update_associate_table_page_size (HelperAgentSlotInt *slot)
3348 return m_impl->signal_update_associate_table_page_size.connect (slot);
3352 * @brief Connect a slot to Helper turn on log signal.
3354 * This signal is used to turn on Helper ISE debug information.
3356 * The prototype of the slot is:
3357 * void turn_on_log (const HelperAgent *agent, uint32 &on);
3360 HelperAgent::signal_connect_turn_on_log (HelperAgentSlotUintVoid *slot)
3362 return m_impl->signal_turn_on_log.connect (slot);
3366 * @brief Connect a slot to Helper update displayed candidate number signal.
3368 * This signal is used to inform helper ISE displayed candidate number.
3370 * The prototype of the slot is:
3371 * void update_displayed_candidate_number (const HelperAgent *, int ic, const String &uuid, int number);
3374 HelperAgent::signal_connect_update_displayed_candidate_number (HelperAgentSlotInt *slot)
3376 return m_impl->signal_update_displayed_candidate_number.connect (slot);
3380 * @brief Connect a slot to Helper longpress candidate signal.
3382 * This signal is used to do something when candidate is longpress.
3384 * The prototype of the slot is:
3385 * void longpress_candidate (const HelperAgent *agent, int ic, const String &uuid, int index);
3388 HelperAgent::signal_connect_longpress_candidate (HelperAgentSlotInt *slot)
3390 return m_impl->signal_longpress_candidate.connect (slot);
3394 * @brief Connect a slot to Helper show option window.
3396 * This signal is used to do request the ISE to show option window.
3398 * The prototype of the slot is:
3399 * void show_option_window (const HelperAgent *agent, int ic, const String &uuid);
3402 HelperAgent::signal_connect_show_option_window (HelperAgentSlotVoid *slot)
3404 return m_impl->signal_show_option_window.connect (slot);
3408 * @brief Connect a slot to Helper resume option window.
3410 * This signal is used to do request the ISE to resume option window.
3412 * The prototype of the slot is:
3413 * void resume_option_window (const HelperAgent *agent, int ic, const String &uuid);
3416 HelperAgent::signal_connect_resume_option_window (HelperAgentSlotVoid *slot)
3418 return m_impl->signal_resume_option_window.connect (slot);
3422 * @brief Connect a slot to Helper check if the option is available.
3424 * This signal is used to check if the option (setting) is available from Helper ISE.
3426 * The prototype of the slot is:
3427 * void check_option_window (const HelperAgent *agent, uint32 &avail);
3430 HelperAgent::signal_connect_check_option_window (HelperAgentSlotUintVoid *slot)
3432 return m_impl->signal_check_option_window.connect (slot);
3436 * @brief Connect a slot to Helper process unconventional input device event signal.
3438 * This signal is used to send unconventional input device event to Helper ISE.
3440 * The prototype of the slot is:
3441 * void process_input_device_event (const HelperAgent *, uint32 &type, char *data, size_t &size, uint32 &ret);
3444 HelperAgent::signal_connect_process_input_device_event (HelperAgentSlotUintCharSizeUint *slot)
3446 return m_impl->signal_process_input_device_event.connect (slot);
3449 } /* namespace scim */
3452 vi:ts=4:nowrap:ai:expandtab