1 /** @file scim_helper.cpp
2 * @brief Implementation of class HelperAgent.
5 /* ISF is based on SCIM 1.4.7 and extended for supporting more mobile fitable. */
8 * Smart Common Input Method
10 * Copyright (c) 2004-2005 James Su <suzhe@tsinghua.org.cn>
11 * Copyright (c) 2012-2015 Samsung Electronics Co., Ltd.
14 * This library is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU Lesser General Public
16 * License as published by the Free Software Foundation; either
17 * version 2 of the License, or (at your option) any later version.
19 * This library is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License for more details.
24 * You should have received a copy of the GNU Lesser General Public
25 * License along with this program; if not, write to the
26 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
27 * Boston, MA 02111-1307 USA
29 * Modifications by Samsung Electronics Co., Ltd.
30 * 1. Add new interface APIs for keyboard ISE
31 * a. expand_candidate (), contract_candidate () and set_candidate_style ()
32 * b. set_keyboard_ise_by_uuid () and reset_keyboard_ise ()
33 * c. get_surrounding_text () and delete_surrounding_text ()
34 * d. show_preedit_string (), hide_preedit_string (), update_preedit_string () and update_preedit_caret ()
35 * e. show_candidate_string (), hide_candidate_string () and update_candidate_string ()
37 * $Id: scim_helper.cpp,v 1.13 2005/05/24 12:22:51 suzhe Exp $
41 #define Uses_SCIM_TRANSACTION
42 #define Uses_SCIM_TRANS_COMMANDS
43 #define Uses_SCIM_HELPER
44 #define Uses_SCIM_SOCKET
45 #define Uses_SCIM_EVENT
46 #define Uses_SCIM_BACKEND
47 #define Uses_SCIM_IMENGINE_MODULE
53 #include "scim_private.h"
55 #include <scim_panel_common.h>
56 #include "isf_query_utility.h"
58 #include "isf_debug.h"
59 #include "isf_message_queue.h"
60 #ifdef HAVE_PKGMGR_INFO
61 #include <pkgmgr-info.h>
62 #endif // HAVE_PKGMGR_INFO
67 #define LOG_TAG "SCIM_HELPER"
70 //FIXME: remove this definitions
71 #define SHIFT_MODE_OFF 0xffe1
72 #define SHIFT_MODE_ON 0xffe2
73 #define SHIFT_MODE_LOCK 0xffe6
74 #define SHIFT_MODE_ENABLE 0x9fe7
75 #define SHIFT_MODE_DISABLE 0x9fe8
79 typedef Signal3<void, const HelperAgent *, int, const String &>
80 HelperAgentSignalVoid;
82 typedef Signal4<void, const HelperAgent *, int, const String &, const String &>
83 HelperAgentSignalString;
85 typedef Signal4<void, const HelperAgent *, int, const String &, const std::vector<String> &>
86 HelperAgentSignalStringVector;
88 typedef Signal5<void, const HelperAgent *, int, const String &, const String &, const String &>
89 HelperAgentSignalString2;
91 typedef Signal4<void, const HelperAgent *, int, const String &, int>
94 typedef Signal5<void, const HelperAgent *, int, const String &, int, int>
95 HelperAgentSignalIntInt;
97 typedef Signal4<void, const HelperAgent *, int, const String &, const Transaction &>
98 HelperAgentSignalTransaction;
100 typedef Signal4<void, const HelperAgent *, int, const String &, const rectinfo &>
101 HelperAgentSignalRect;
103 typedef Signal2<void, const HelperAgent *, struct rectinfo &>
104 HelperAgentSignalSize;
106 typedef Signal2<void, const HelperAgent *, uint32 &>
107 HelperAgentSignalUintVoid;
109 typedef Signal3<void, const HelperAgent *, int, uint32 &>
110 HelperAgentSignalIntUint;
112 typedef Signal3 <void, const HelperAgent *, char *, size_t &>
113 HelperAgentSignalRawVoid;
115 typedef Signal3 <void, const HelperAgent *, char **, size_t &>
116 HelperAgentSignalGetRawVoid;
118 typedef Signal4 <void, const HelperAgent *, int, char *, size_t &>
119 HelperAgentSignalIntRawVoid;
121 typedef Signal3 <void, const HelperAgent *, int, char **>
122 HelperAgentSignalIntGetStringVoid;
124 typedef Signal2<void, const HelperAgent *, const std::vector<uint32> &>
125 HelperAgentSignalUintVector;
127 typedef Signal2<void, const HelperAgent *, LookupTable &>
128 HelperAgentSignalLookupTable;
130 typedef Signal3<void, const HelperAgent *, KeyEvent &, uint32 &>
131 HelperAgentSignalKeyEventUint;
133 typedef Signal5<void, const HelperAgent *, uint32 &, char *, size_t &, uint32 &>
134 HelperAgentSignalUintCharSizeUint;
136 class HelperAgent::HelperAgentImpl
140 SocketClient socket_active;
149 IMEngineInstancePointer si;
150 ConfigPointer m_config;
151 IMEngineModule engine_module;
153 char* surrounding_text;
154 char* selection_text;
156 int need_update_surrounding_text;
157 int need_update_selection_text;
161 HelperAgentSignalVoid signal_exit;
162 HelperAgentSignalVoid signal_attach_input_context;
163 HelperAgentSignalVoid signal_detach_input_context;
164 HelperAgentSignalVoid signal_reload_config;
165 HelperAgentSignalInt signal_update_screen;
166 HelperAgentSignalIntInt signal_update_spot_location;
167 HelperAgentSignalInt signal_update_cursor_position;
168 HelperAgentSignalInt signal_update_surrounding_text;
169 HelperAgentSignalVoid signal_update_selection;
170 HelperAgentSignalString signal_trigger_property;
171 HelperAgentSignalTransaction signal_process_imengine_event;
172 HelperAgentSignalVoid signal_focus_out;
173 HelperAgentSignalVoid signal_focus_in;
174 HelperAgentSignalIntRawVoid signal_ise_show;
175 HelperAgentSignalVoid signal_ise_hide;
176 HelperAgentSignalVoid signal_candidate_show;
177 HelperAgentSignalVoid signal_candidate_hide;
178 HelperAgentSignalSize signal_get_geometry;
179 HelperAgentSignalUintVoid signal_set_mode;
180 HelperAgentSignalUintVoid signal_set_language;
181 HelperAgentSignalRawVoid signal_set_imdata;
182 HelperAgentSignalGetRawVoid signal_get_imdata;
183 HelperAgentSignalIntGetStringVoid signal_get_language_locale;
184 HelperAgentSignalUintVoid signal_set_return_key_type;
185 HelperAgentSignalUintVoid signal_get_return_key_type;
186 HelperAgentSignalUintVoid signal_set_return_key_disable;
187 HelperAgentSignalUintVoid signal_get_return_key_disable;
188 HelperAgentSignalUintVoid signal_set_layout;
189 HelperAgentSignalUintVoid signal_get_layout;
190 HelperAgentSignalUintVoid signal_set_caps_mode;
191 HelperAgentSignalVoid signal_reset_input_context;
192 HelperAgentSignalIntInt signal_update_candidate_ui;
193 HelperAgentSignalRect signal_update_candidate_geometry;
194 HelperAgentSignalString2 signal_update_keyboard_ise;
195 HelperAgentSignalStringVector signal_update_keyboard_ise_list;
196 HelperAgentSignalVoid signal_candidate_more_window_show;
197 HelperAgentSignalVoid signal_candidate_more_window_hide;
198 HelperAgentSignalLookupTable signal_update_lookup_table;
199 HelperAgentSignalInt signal_select_aux;
200 HelperAgentSignalInt signal_select_candidate;
201 HelperAgentSignalVoid signal_candidate_table_page_up;
202 HelperAgentSignalVoid signal_candidate_table_page_down;
203 HelperAgentSignalInt signal_update_candidate_table_page_size;
204 HelperAgentSignalUintVector signal_update_candidate_item_layout;
205 HelperAgentSignalInt signal_select_associate;
206 HelperAgentSignalVoid signal_associate_table_page_up;
207 HelperAgentSignalVoid signal_associate_table_page_down;
208 HelperAgentSignalInt signal_update_associate_table_page_size;
209 HelperAgentSignalVoid signal_reset_ise_context;
210 HelperAgentSignalUintVoid signal_turn_on_log;
211 HelperAgentSignalInt signal_update_displayed_candidate_number;
212 HelperAgentSignalInt signal_longpress_candidate;
213 HelperAgentSignalKeyEventUint signal_process_key_event;
214 HelperAgentSignalUintVoid signal_set_input_mode;
215 HelperAgentSignalUintVoid signal_set_input_hint;
216 HelperAgentSignalUintVoid signal_update_bidi_direction;
217 HelperAgentSignalVoid signal_show_option_window;
218 HelperAgentSignalVoid signal_resume_option_window;
219 HelperAgentSignalUintVoid signal_check_option_window;
220 HelperAgentSignalUintCharSizeUint signal_process_input_device_event;
223 HelperAgentImpl (HelperAgent* thiz) : magic(0), magic_active(0), timeout(-1), focused_ic ((uint32) -1), thiz (thiz),
224 surrounding_text (NULL), selection_text (NULL), cursor_pos (0),
225 need_update_surrounding_text (0), need_update_selection_text (0),
226 layout (0), ise_show_flag (false) {
229 ~HelperAgentImpl () {
234 if (surrounding_text != NULL)
235 free (surrounding_text);
237 if (selection_text != NULL)
238 free (selection_text);
240 if (engine_module.valid ()) {
241 engine_module.unload ();
245 // Implementation of slot functions
247 slot_show_preedit_string (IMEngineInstanceBase *si)
250 thiz->show_preedit_string (focused_ic, "");
254 slot_show_aux_string (IMEngineInstanceBase *si)
257 thiz->show_aux_string ();
261 slot_show_lookup_table (IMEngineInstanceBase *si)
264 thiz->show_candidate_string ();
268 slot_hide_preedit_string (IMEngineInstanceBase *si)
271 thiz->hide_preedit_string (focused_ic, "");
275 slot_hide_aux_string (IMEngineInstanceBase *si)
278 thiz->hide_aux_string ();
282 slot_hide_lookup_table (IMEngineInstanceBase *si)
285 thiz->hide_candidate_string ();
289 slot_update_preedit_caret (IMEngineInstanceBase *si, int caret)
292 thiz->update_preedit_caret (caret);
296 slot_update_preedit_string (IMEngineInstanceBase *si,
297 const WideString & str,
298 const AttributeList & attrs,
302 thiz->update_preedit_string (-1, "", str, attrs, caret);
306 slot_update_preedit_string_with_commit (IMEngineInstanceBase *si,
307 const WideString & preedit,
308 const WideString & commit,
309 const AttributeList & attrs,
313 thiz->update_preedit_string (-1, "", preedit, commit, attrs, caret);
317 slot_update_aux_string (IMEngineInstanceBase *si,
318 const WideString & str,
319 const AttributeList & attrs)
322 thiz->update_aux_string (utf8_wcstombs(str), attrs);
326 slot_commit_string (IMEngineInstanceBase *si,
327 const WideString & str)
330 thiz->commit_string (-1, "", str);
334 slot_forward_key_event (IMEngineInstanceBase *si,
335 const KeyEvent & key)
338 thiz->forward_key_event (-1, "", key);
342 slot_update_lookup_table (IMEngineInstanceBase *si,
343 const LookupTable & table)
346 thiz->update_candidate_string (table);
350 slot_register_properties (IMEngineInstanceBase *si,
351 const PropertyList & properties)
354 thiz->register_properties (properties);
358 slot_update_property (IMEngineInstanceBase *si,
359 const Property & property)
362 thiz->update_property (property);
366 slot_beep (IMEngineInstanceBase *si)
373 slot_start_helper (IMEngineInstanceBase *si,
374 const String &helper_uuid)
376 LOGW ("deprecated function");
380 slot_stop_helper (IMEngineInstanceBase *si,
381 const String &helper_uuid)
383 LOGW ("deprecated function");
387 slot_send_helper_event (IMEngineInstanceBase *si,
388 const String &helper_uuid,
389 const Transaction &trans)
392 signal_process_imengine_event (thiz, focused_ic, helper_uuid, trans);
396 slot_get_surrounding_text (IMEngineInstanceBase *si,
404 thiz->get_surrounding_text (maxlen_before, maxlen_after, _text, cursor);
405 text = utf8_mbstowcs(_text);
410 slot_delete_surrounding_text (IMEngineInstanceBase *si,
416 thiz->delete_surrounding_text (offset, len);
421 slot_get_selection (IMEngineInstanceBase *si,
426 thiz->get_selection_text (_text);
427 text = utf8_mbstowcs (_text);
432 slot_set_selection (IMEngineInstanceBase *si,
437 thiz->set_selection (start, end);
442 slot_expand_candidate (IMEngineInstanceBase *si)
445 thiz->expand_candidate ();
449 slot_contract_candidate (IMEngineInstanceBase *si)
452 thiz->contract_candidate ();
456 slot_set_candidate_style (IMEngineInstanceBase *si, ISF_CANDIDATE_PORTRAIT_LINE_T portrait_line, ISF_CANDIDATE_MODE_T mode)
459 thiz->set_candidate_style (portrait_line, mode);
463 slot_send_private_command (IMEngineInstanceBase *si,
464 const String &command)
467 thiz->send_private_command (command);
473 si->signal_connect_show_preedit_string (
474 slot (this, &HelperAgent::HelperAgentImpl::slot_show_preedit_string));
475 si->signal_connect_show_aux_string (
476 slot (this, &HelperAgent::HelperAgentImpl::slot_show_aux_string));
477 si->signal_connect_show_lookup_table (
478 slot (this, &HelperAgent::HelperAgentImpl::slot_show_lookup_table));
480 si->signal_connect_hide_preedit_string (
481 slot (this, &HelperAgent::HelperAgentImpl::slot_hide_preedit_string));
482 si->signal_connect_hide_aux_string (
483 slot (this, &HelperAgent::HelperAgentImpl::slot_hide_aux_string));
484 si->signal_connect_hide_lookup_table (
485 slot (this, &HelperAgent::HelperAgentImpl::slot_hide_lookup_table));
487 si->signal_connect_update_preedit_caret (
488 slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_caret));
489 si->signal_connect_update_preedit_string (
490 slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_string));
491 si->signal_connect_update_preedit_string_with_commit (
492 slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_string_with_commit));
494 si->signal_connect_update_aux_string (
495 slot (this, &HelperAgent::HelperAgentImpl::slot_update_aux_string));
496 si->signal_connect_update_lookup_table (
497 slot (this, &HelperAgent::HelperAgentImpl::slot_update_lookup_table));
499 si->signal_connect_commit_string (
500 slot (this, &HelperAgent::HelperAgentImpl::slot_commit_string));
502 si->signal_connect_forward_key_event (
503 slot (this, &HelperAgent::HelperAgentImpl::slot_forward_key_event));
505 si->signal_connect_register_properties (
506 slot (this, &HelperAgent::HelperAgentImpl::slot_register_properties));
508 si->signal_connect_update_property (
509 slot (this, &HelperAgent::HelperAgentImpl::slot_update_property));
511 si->signal_connect_beep (
512 slot (this, &HelperAgent::HelperAgentImpl::slot_beep));
514 si->signal_connect_start_helper (
515 slot (this, &HelperAgent::HelperAgentImpl::slot_start_helper));
517 si->signal_connect_stop_helper (
518 slot (this, &HelperAgent::HelperAgentImpl::slot_stop_helper));
520 si->signal_connect_send_helper_event (
521 slot (this, &HelperAgent::HelperAgentImpl::slot_send_helper_event));
523 si->signal_connect_get_surrounding_text (
524 slot (this, &HelperAgent::HelperAgentImpl::slot_get_surrounding_text));
526 si->signal_connect_delete_surrounding_text (
527 slot (this, &HelperAgent::HelperAgentImpl::slot_delete_surrounding_text));
529 si->signal_connect_get_selection (
530 slot (this, &HelperAgent::HelperAgentImpl::slot_get_selection));
532 si->signal_connect_set_selection (
533 slot (this, &HelperAgent::HelperAgentImpl::slot_set_selection));
535 si->signal_connect_expand_candidate (
536 slot (this, &HelperAgent::HelperAgentImpl::slot_expand_candidate));
537 si->signal_connect_contract_candidate (
538 slot (this, &HelperAgent::HelperAgentImpl::slot_contract_candidate));
540 si->signal_connect_set_candidate_style (
541 slot (this, &HelperAgent::HelperAgentImpl::slot_set_candidate_style));
543 si->signal_connect_send_private_command (
544 slot (this, &HelperAgent::HelperAgentImpl::slot_send_private_command));
547 void process_key_event_done (KeyEvent &key, uint32 ret, uint32 serial) {
548 LOGD ("ret: %d, serial: %d", ret, serial);
549 if (socket_active.is_connected ()) {
551 send.put_command (SCIM_TRANS_CMD_REQUEST);
552 send.put_data (magic_active);
553 send.put_command (ISM_TRANS_CMD_PROCESS_KEY_EVENT_DONE);
556 send.put_data (serial);
557 send.write_to_socket (socket_active, magic_active);
561 void request_ise_hide () {
562 if (socket_active.is_connected ()) {
564 send.put_command (SCIM_TRANS_CMD_REQUEST);
565 send.put_data (magic_active);
566 send.put_command (ISM_TRANS_CMD_REQUEST_ISE_HIDE);
567 send.write_to_socket (socket_active, magic_active);
571 HelperAgentImpl () : magic (0), magic_active (0), timeout (-1), focused_ic ((uint32) -1) { }
574 static MessageQueue message_queue;
576 HelperAgent::HelperAgent ()
577 : m_impl (new HelperAgentImpl (this))
579 message_queue.create();
582 HelperAgent::~HelperAgent ()
584 message_queue.destroy();
589 * @brief Open socket connection to the Panel.
591 * @param info The information of this Helper object.
592 * @param display The display which this Helper object should run on.
594 * @return The connection socket id. -1 means failed to create
598 HelperAgent::open_connection (const HelperInfo &info,
599 const String &display)
601 if (m_impl->socket.is_connected ())
604 SocketAddress address (scim_get_default_panel_socket_address (display));
605 int timeout = m_impl->timeout = scim_get_default_socket_timeout ();
608 if (!address.valid ())
612 std::cerr << " Connecting to PanelAgent server.";
613 ISF_LOG (" Connecting to PanelAgent server.\n");
614 while (!m_impl->socket.connect (address)) {
616 scim_usleep (100000);
618 std::cerr << "m_impl->socket.connect () is failed!!!\n";
619 ISF_LOG ("m_impl->socket.connect () is failed!!!\n");
623 std::cerr << " Connected :" << i << "\n";
624 ISF_LOG (" Connected :%d\n", i);
625 LOGD ("Connection to PanelAgent succeeded, %d\n", i);
627 /* Let's retry 10 times when failed */
628 int open_connection_retries = 0;
629 while (!scim_socket_open_connection (magic,
634 if (++open_connection_retries > 10) {
635 m_impl->socket.close ();
636 std::cerr << "scim_socket_open_connection () is failed!!!\n";
637 ISF_LOG ("scim_socket_open_connection () is failed!!!\n");
638 ISF_SAVE_LOG ("scim_socket_open_connection failed, %d\n", timeout);
643 /* Retry after re-connecting the socket */
644 if (m_impl->socket.is_connected ())
647 /* This time, just retry atmost 2 seconds */
649 while (!m_impl->socket.connect (address) && ++i < 10) {
650 scim_usleep (200000);
655 ISF_LOG ("scim_socket_open_connection () is successful.\n");
656 LOGD ("scim_socket_open_connection successful\n");
658 m_impl->send.clear ();
659 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
660 m_impl->send.put_data (magic);
661 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_REGISTER_HELPER);
662 m_impl->send.put_data (info.uuid);
663 m_impl->send.put_data (info.name);
664 m_impl->send.put_data (info.icon);
665 m_impl->send.put_data (info.description);
666 m_impl->send.put_data (info.option);
668 if (!m_impl->send.write_to_socket (m_impl->socket, magic)) {
669 m_impl->socket.close ();
674 if (m_impl->recv.read_from_socket (m_impl->socket, timeout) &&
675 m_impl->recv.get_command (cmd) && cmd == SCIM_TRANS_CMD_REPLY &&
676 m_impl->recv.get_command (cmd) && cmd == SCIM_TRANS_CMD_OK) {
677 m_impl->magic = magic;
679 while (m_impl->recv.get_command (cmd)) {
681 case SCIM_TRANS_CMD_HELPER_ATTACH_INPUT_CONTEXT:
685 while (m_impl->recv.get_data (ic) && m_impl->recv.get_data (ic_uuid))
686 m_impl->signal_attach_input_context (this, ic, ic_uuid);
689 case SCIM_TRANS_CMD_UPDATE_SCREEN:
692 if (m_impl->recv.get_data (screen))
693 m_impl->signal_update_screen (this, (uint32) -1, String (""), (int) screen);
701 //FIXME: Attaching input context is needed for desktop environment
702 LOGW ("Attach input context and update screen failed");
705 ISF_SAVE_LOG ("Trying connect() with Helper_Active\n");
707 /* connect to the panel agent as the active helper client */
708 if (!m_impl->socket_active.connect (address)) return -1;
709 open_connection_retries = 0;
710 while (!scim_socket_open_connection (magic,
711 String ("Helper_Active"),
713 m_impl->socket_active,
715 if (++open_connection_retries > 10) {
716 m_impl->socket_active.close ();
717 std::cerr << "Helper_Active scim_socket_open_connection () is failed!!!\n";
718 ISF_LOG ("Helper_Active scim_socket_open_connection () is failed!!!\n");
719 ISF_SAVE_LOG ("Helper_Active scim_socket_open_connection failed, %d\n", timeout);
724 /* Retry after re-connecting the socket */
725 if (m_impl->socket_active.is_connected ())
726 m_impl->socket_active.close ();
728 /* This time, just retry atmost 2 seconds */
730 while (!m_impl->socket_active.connect (address) && ++i < 10) {
731 scim_usleep (200000);
735 m_impl->magic_active = magic;
737 m_impl->send.clear ();
738 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
739 m_impl->send.put_data (magic);
740 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_REGISTER_ACTIVE_HELPER);
741 m_impl->send.put_data (info.uuid);
742 m_impl->send.put_data (info.name);
743 m_impl->send.put_data (info.icon);
744 m_impl->send.put_data (info.description);
745 m_impl->send.put_data (info.option);
747 if (!m_impl->send.write_to_socket (m_impl->socket_active, magic)) {
748 ISF_SAVE_LOG ("Helper_Active write_to_socket() failed\n");
749 m_impl->socket_active.close ();
752 m_impl->m_config = ConfigBase::get (false, "socket");
754 return m_impl->socket.get_id ();
758 * @brief Close the socket connection to Panel.
761 HelperAgent::close_connection ()
763 m_impl->socket.close ();
764 m_impl->socket_active.close ();
765 m_impl->send.clear ();
766 m_impl->recv.clear ();
768 m_impl->magic_active = 0;
773 * @brief Get the connection id previously returned by open_connection().
775 * @return the connection id
778 HelperAgent::get_connection_number () const
780 if (m_impl->socket.is_connected ())
781 return m_impl->socket.get_id ();
786 * @brief Check whether this HelperAgent has been connected to a Panel.
788 * Return true when it is connected to panel, otherwise return false.
791 HelperAgent::is_connected () const
793 return m_impl->socket.is_connected ();
797 * @brief Check if there are any events available to be processed.
799 * If it returns true then Helper object should call
800 * HelperAgent::filter_event() to process them.
802 * @return true if there are any events available.
805 HelperAgent::has_pending_event () const
807 if (m_impl->socket.is_connected () && m_impl->socket.wait_for_data (0) > 0)
810 if (message_queue.has_pending_message())
817 * @brief Process the pending events.
819 * This function will emit the corresponding signals according
822 * @return false if the connection is broken, otherwise return true.
825 HelperAgent::filter_event ()
827 if (!m_impl->socket.is_connected ()) {
828 LOGW("Connection lost, returning false");
832 if (m_impl->recv.read_from_socket (m_impl->socket, m_impl->timeout)) {
833 message_queue.read_from_transaction(m_impl->recv);
835 while (message_queue.has_pending_message()) {
836 MessageItem *message = message_queue.get_pending_message();
837 handle_message(message);
838 message_queue.remove_message(message);
841 LOGD("read_from_socket() failed but continuing");
849 * @brief Read messages from socket buffer, and see if there is a message with the given cmd.
851 * @return false if the connection is broken, or no message available with given cmd. Otherwise return true.
854 HelperAgent::wait_for_message(int cmd, int timeout)
856 struct timeval t0 = { 0, 0 };
857 struct timeval t1 = { 0, 0 };
859 gettimeofday(&t0, NULL);
863 if (!m_impl->socket.is_connected() || !m_impl->recv.read_from_socket(m_impl->socket, timeout))
866 message_queue.read_from_transaction(m_impl->recv);
867 if (message_queue.has_pending_message_by_cmd(cmd)) {
871 gettimeofday(&t1, NULL);
872 etime = ((t1.tv_sec * 1000000 + t1.tv_usec) - (t0.tv_sec * 1000000 + t0.tv_usec)) / 1000;
873 } while (etime < timeout);
879 * @brief Process one message that is in our message queue.
881 * This function will emit the corresponding signals according
884 * @param message The message that needs to be handled.
886 * @return false if the connection is broken, otherwise return true.
889 HelperAgent::handle_message (MessageItem *message)
894 int cmd = message->get_command_ref();
895 LOGD ("HelperAgent::cmd = %d\n", cmd);
897 case SCIM_TRANS_CMD_EXIT:
899 MessageItemExit *subclass = static_cast<MessageItemExit*>(message);
900 ISF_SAVE_LOG ("Helper ISE received SCIM_TRANS_CMD_EXIT message\n");
901 m_impl->signal_exit(this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
904 case SCIM_TRANS_CMD_RELOAD_CONFIG:
906 MessageItemReloadConfig *subclass = static_cast<MessageItemReloadConfig*>(message);
907 m_impl->signal_reload_config (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
908 if (!m_impl->m_config.null())
909 m_impl->m_config->ConfigBase::reload();
912 case SCIM_TRANS_CMD_UPDATE_SCREEN:
914 MessageItemUpdateScreen *subclass = static_cast<MessageItemUpdateScreen*>(message);
915 m_impl->signal_update_screen (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
916 subclass->get_screen_ref());
919 case SCIM_TRANS_CMD_UPDATE_SPOT_LOCATION:
921 MessageItemUpdateSpotLocation *subclass = static_cast<MessageItemUpdateSpotLocation*>(message);
922 m_impl->signal_update_spot_location (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
923 subclass->get_x_ref(), subclass->get_y_ref());
926 case ISM_TRANS_CMD_UPDATE_CURSOR_POSITION:
928 MessageItemUpdateCursorPosition *subclass = static_cast<MessageItemUpdateCursorPosition*>(message);
929 m_impl->cursor_pos = subclass->get_cursor_pos_ref();
930 LOGD ("update cursor position %d", subclass->get_cursor_pos_ref());
931 if (m_impl->ise_show_flag) {
932 m_impl->signal_update_cursor_position (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
933 subclass->get_cursor_pos_ref());
934 if (!m_impl->si.null ()) m_impl->si->update_cursor_position(subclass->get_cursor_pos_ref());
938 case ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT:
940 MessageItemUpdateSurroundingText *subclass = static_cast<MessageItemUpdateSurroundingText*>(message);
941 if (m_impl->surrounding_text != NULL)
942 free (m_impl->surrounding_text);
943 m_impl->surrounding_text = strdup (subclass->get_text_ref().c_str ());
944 m_impl->cursor_pos = subclass->get_cursor_ref();
945 LOGD ("surrounding text: %s, %d", m_impl->surrounding_text, subclass->get_cursor_ref());
946 while (m_impl->need_update_surrounding_text > 0) {
947 m_impl->need_update_surrounding_text--;
948 m_impl->signal_update_surrounding_text (this, subclass->get_ic_ref(),
949 subclass->get_text_ref(), subclass->get_cursor_ref());
953 case ISM_TRANS_CMD_UPDATE_SELECTION:
955 MessageItemUpdateSelection *subclass = static_cast<MessageItemUpdateSelection*>(message);
956 if (m_impl->selection_text != NULL)
957 free (m_impl->selection_text);
959 m_impl->selection_text = strdup (subclass->get_text_ref().c_str ());
960 LOGD ("selection text: %s", m_impl->selection_text);
962 while (m_impl->need_update_selection_text > 0) {
963 m_impl->need_update_selection_text--;
964 m_impl->signal_update_selection (this, subclass->get_ic_ref(), subclass->get_text_ref());
968 case SCIM_TRANS_CMD_TRIGGER_PROPERTY:
970 MessageItemTriggerProperty *subclass = static_cast<MessageItemTriggerProperty*>(message);
971 m_impl->signal_trigger_property (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
972 subclass->get_property_ref());
973 if (!m_impl->si.null ()) m_impl->si->trigger_property(subclass->get_property_ref());
976 case SCIM_TRANS_CMD_HELPER_PROCESS_IMENGINE_EVENT:
978 MessageItemHelperProcessImengineEvent *subclass = static_cast<MessageItemHelperProcessImengineEvent*>(message);
979 m_impl->signal_process_imengine_event (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
980 subclass->get_transaction_ref());
983 case SCIM_TRANS_CMD_HELPER_ATTACH_INPUT_CONTEXT:
985 MessageItemHelperAttachInputContext *subclass = static_cast<MessageItemHelperAttachInputContext*>(message);
986 m_impl->signal_attach_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
989 case SCIM_TRANS_CMD_HELPER_DETACH_INPUT_CONTEXT:
991 MessageItemHelperDetachInputContext *subclass = static_cast<MessageItemHelperDetachInputContext*>(message);
992 m_impl->signal_detach_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
995 case SCIM_TRANS_CMD_FOCUS_OUT:
997 MessageItemFocusOut *subclass = static_cast<MessageItemFocusOut*>(message);
998 m_impl->signal_focus_out (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
999 m_impl->focused_ic = (uint32) -1;
1000 if (!m_impl->si.null ()) m_impl->si->focus_out();
1003 case SCIM_TRANS_CMD_FOCUS_IN:
1005 MessageItemFocusIn *subclass = static_cast<MessageItemFocusIn*>(message);
1006 m_impl->signal_focus_in (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1007 m_impl->focused_ic = subclass->get_ic_ref();
1008 if (!m_impl->si.null ()) m_impl->si->focus_in();
1009 m_impl->ise_show_flag = false;
1012 case ISM_TRANS_CMD_SHOW_ISE_PANEL:
1014 MessageItemShowISEPanel *subclass = static_cast<MessageItemShowISEPanel*>(message);
1015 LOGD ("Helper ISE received ISM_TRANS_CMD_SHOW_ISE_PANEL message\n");
1017 m_impl->signal_ise_show (this, subclass->get_ic_ref(), *(subclass->get_data_ptr()),
1018 subclass->get_len_ref());
1019 m_impl->ise_show_flag = true;
1022 case ISM_TRANS_CMD_HIDE_ISE_PANEL:
1024 MessageItemHideISEPanel *subclass = static_cast<MessageItemHideISEPanel*>(message);
1025 LOGD ("Helper ISE received ISM_TRANS_CMD_HIDE_ISE_PANEL message\n");
1026 m_impl->signal_ise_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1027 m_impl->ise_show_flag = false;
1030 case ISM_TRANS_CMD_GET_ACTIVE_ISE_GEOMETRY:
1032 struct rectinfo info = {0, 0, 0, 0};
1033 m_impl->signal_get_geometry (this, info);
1034 m_impl->send.clear ();
1035 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1036 m_impl->send.put_data (info.pos_x);
1037 m_impl->send.put_data (info.pos_y);
1038 m_impl->send.put_data (info.width);
1039 m_impl->send.put_data (info.height);
1040 m_impl->send.write_to_socket (m_impl->socket);
1043 case ISM_TRANS_CMD_SET_ISE_MODE:
1045 MessageItemSetISEMode *subclass = static_cast<MessageItemSetISEMode*>(message);
1046 m_impl->signal_set_mode (this, subclass->get_mode_ref());
1049 case ISM_TRANS_CMD_SET_ISE_LANGUAGE:
1051 MessageItemSetISELanguage *subclass = static_cast<MessageItemSetISELanguage*>(message);
1052 m_impl->signal_set_language (this, subclass->get_language_ref());
1055 case ISM_TRANS_CMD_SET_ISE_IMDATA:
1057 MessageItemSetISEImData *subclass = static_cast<MessageItemSetISEImData*>(message);
1058 m_impl->signal_set_imdata (this, *(subclass->get_imdata_ptr()), subclass->get_len_ref());
1059 if (!m_impl->si.null ()) m_impl->si->set_imdata(*(subclass->get_imdata_ptr()),
1060 subclass->get_len_ref());
1063 case ISM_TRANS_CMD_GET_ISE_IMDATA:
1068 m_impl->signal_get_imdata (this, &buf, len);
1069 LOGD ("send ise imdata len = %d", len);
1070 m_impl->send.clear ();
1071 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1072 m_impl->send.put_data (buf, len);
1073 m_impl->send.write_to_socket (m_impl->socket);
1078 case ISM_TRANS_CMD_GET_ISE_LANGUAGE_LOCALE:
1080 MessageItemGetISELanguageLocale *subclass = static_cast<MessageItemGetISELanguageLocale*>(message);
1082 m_impl->signal_get_language_locale (this, subclass->get_ic_ref(), &buf);
1083 m_impl->send.clear ();
1084 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1086 m_impl->send.put_data (buf, strlen (buf));
1087 m_impl->send.write_to_socket (m_impl->socket);
1092 case ISM_TRANS_CMD_SET_RETURN_KEY_TYPE:
1094 MessageItemSetReturnKeyType *subclass = static_cast<MessageItemSetReturnKeyType*>(message);
1095 if (m_impl->ise_show_flag) {
1096 m_impl->signal_set_return_key_type (this, subclass->get_type_ref());
1100 case ISM_TRANS_CMD_GET_RETURN_KEY_TYPE:
1103 m_impl->signal_get_return_key_type (this, type);
1104 m_impl->send.clear ();
1105 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1106 m_impl->send.put_data (type);
1107 m_impl->send.write_to_socket (m_impl->socket);
1110 case ISM_TRANS_CMD_SET_RETURN_KEY_DISABLE:
1112 MessageItemSetReturnKeyDisable *subclass = static_cast<MessageItemSetReturnKeyDisable*>(message);
1113 if (m_impl->ise_show_flag) {
1114 m_impl->signal_set_return_key_disable (this, subclass->get_disabled_ref());
1118 case ISM_TRANS_CMD_GET_RETURN_KEY_DISABLE:
1120 uint32 disabled = 0;
1121 m_impl->signal_get_return_key_type (this, disabled);
1122 m_impl->send.clear ();
1123 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1124 m_impl->send.put_data (disabled);
1125 m_impl->send.write_to_socket (m_impl->socket);
1128 case SCIM_TRANS_CMD_PROCESS_KEY_EVENT:
1130 MessageItemProcessKeyEvent *subclass = static_cast<MessageItemProcessKeyEvent*>(message);
1132 m_impl->signal_process_key_event(this, subclass->get_key_ref(), ret);
1134 if (!m_impl->si.null ())
1136 ret = m_impl->si->process_key_event (subclass->get_key_ref());
1137 LOGD("imengine(%s) process key %d return %d", m_impl->si->get_factory_uuid().c_str(),
1138 subclass->get_key_ref().code, ret);
1140 m_impl->process_key_event_done (subclass->get_key_ref(), ret, subclass->get_serial_ref());
1143 case ISM_TRANS_CMD_SET_LAYOUT:
1145 MessageItemSetLayout *subclass = static_cast<MessageItemSetLayout*>(message);
1146 m_impl->layout = subclass->get_layout_ref();
1147 if (m_impl->ise_show_flag) {
1148 m_impl->signal_set_layout (this, subclass->get_layout_ref());
1149 if (!m_impl->si.null ()) m_impl->si->set_layout(subclass->get_layout_ref());
1153 case ISM_TRANS_CMD_GET_LAYOUT:
1157 m_impl->signal_get_layout (this, layout);
1158 m_impl->send.clear ();
1159 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1160 m_impl->send.put_data (layout);
1161 m_impl->send.write_to_socket (m_impl->socket);
1164 case ISM_TRANS_CMD_SET_INPUT_MODE:
1166 MessageItemSetInputMode *subclass = static_cast<MessageItemSetInputMode*>(message);
1167 m_impl->signal_set_input_mode (this, subclass->get_input_mode_ref());
1170 case ISM_TRANS_CMD_SET_CAPS_MODE:
1172 MessageItemSetCapsMode *subclass = static_cast<MessageItemSetCapsMode*>(message);
1173 if (m_impl->ise_show_flag) {
1174 m_impl->signal_set_caps_mode (this, subclass->get_mode_ref());
1178 case SCIM_TRANS_CMD_PANEL_RESET_INPUT_CONTEXT:
1180 MessageItemPanelResetInputContext *subclass = static_cast<MessageItemPanelResetInputContext*>(message);
1181 m_impl->signal_reset_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1182 if (!m_impl->si.null ()) m_impl->si->reset();
1185 case ISM_TRANS_CMD_UPDATE_CANDIDATE_UI:
1187 MessageItemUpdateCandidateUI *subclass = static_cast<MessageItemUpdateCandidateUI*>(message);
1188 m_impl->signal_update_candidate_ui (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1189 subclass->get_style_ref(), subclass->get_mode_ref());
1192 case ISM_TRANS_CMD_UPDATE_CANDIDATE_GEOMETRY:
1194 MessageItemUpdateCandidateGeometry *subclass = static_cast<MessageItemUpdateCandidateGeometry*>(message);
1195 m_impl->signal_update_candidate_geometry (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1196 subclass->get_rectinfo_ref());
1199 case ISM_TRANS_CMD_UPDATE_KEYBOARD_ISE:
1201 MessageItemUpdateKeyboardISE *subclass = static_cast<MessageItemUpdateKeyboardISE*>(message);
1202 m_impl->signal_update_keyboard_ise (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1203 subclass->get_name_ref(), subclass->get_uuid_ref());
1206 case ISM_TRANS_CMD_UPDATE_KEYBOARD_ISE_LIST:
1208 MessageItemUpdateKeyboardISEList *subclass = static_cast<MessageItemUpdateKeyboardISEList*>(message);
1209 m_impl->signal_update_keyboard_ise_list (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1210 subclass->get_list_ref());
1213 case ISM_TRANS_CMD_CANDIDATE_MORE_WINDOW_SHOW:
1215 MessageItemCandidateMoreWindowShow *subclass = static_cast<MessageItemCandidateMoreWindowShow*>(message);
1216 m_impl->signal_candidate_more_window_show (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1217 if (!m_impl->si.null ()) m_impl->si->candidate_more_window_show();
1220 case ISM_TRANS_CMD_CANDIDATE_MORE_WINDOW_HIDE:
1222 MessageItemCandidateMoreWindowHide *subclass = static_cast<MessageItemCandidateMoreWindowHide*>(message);
1223 m_impl->signal_candidate_more_window_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1224 if (!m_impl->si.null ()) m_impl->si->candidate_more_window_hide();
1227 case ISM_TRANS_CMD_SELECT_AUX:
1229 MessageItemSelectAux *subclass = static_cast<MessageItemSelectAux*>(message);
1230 m_impl->signal_select_aux (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1231 subclass->get_item_ref());
1232 if (!m_impl->si.null ()) m_impl->si->select_aux(subclass->get_item_ref());
1235 case SCIM_TRANS_CMD_SELECT_CANDIDATE: //FIXME:remove if useless
1237 MessageItemSelectCandidate *subclass = static_cast<MessageItemSelectCandidate*>(message);
1238 m_impl->signal_select_candidate (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1239 subclass->get_item_ref());
1240 if (!m_impl->si.null ()) m_impl->si->select_candidate(subclass->get_item_ref());
1243 case SCIM_TRANS_CMD_LOOKUP_TABLE_PAGE_UP: //FIXME:remove if useless
1245 MessageItemLookupTablePageUp *subclass = static_cast<MessageItemLookupTablePageUp*>(message);
1246 m_impl->signal_candidate_table_page_up (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1247 if (!m_impl->si.null ()) m_impl->si->lookup_table_page_up();
1250 case SCIM_TRANS_CMD_LOOKUP_TABLE_PAGE_DOWN: //FIXME:remove if useless
1252 MessageItemLookupTablePageDown *subclass = static_cast<MessageItemLookupTablePageDown*>(message);
1253 m_impl->signal_candidate_table_page_down (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1254 if (!m_impl->si.null ()) m_impl->si->lookup_table_page_down();
1257 case SCIM_TRANS_CMD_UPDATE_LOOKUP_TABLE_PAGE_SIZE:
1259 MessageItemUpdateLookupTablePageSize *subclass = static_cast<MessageItemUpdateLookupTablePageSize*>(message);
1260 m_impl->signal_update_candidate_table_page_size (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1261 subclass->get_size_ref());
1262 if (!m_impl->si.null ()) m_impl->si->update_lookup_table_page_size(subclass->get_size_ref());
1265 case ISM_TRANS_CMD_CANDIDATE_SHOW: //FIXME:remove if useless
1267 MessageItemCandidateShow *subclass = static_cast<MessageItemCandidateShow*>(message);
1268 m_impl->signal_candidate_show (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1271 case ISM_TRANS_CMD_CANDIDATE_HIDE: //FIXME:remove if useless
1273 MessageItemCandidateHide *subclass = static_cast<MessageItemCandidateHide*>(message);
1274 m_impl->signal_candidate_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1277 case ISM_TRANS_CMD_UPDATE_LOOKUP_TABLE: //FIXME:remove if useless
1279 MessageItemUpdateLookupTable *subclass = static_cast<MessageItemUpdateLookupTable*>(message);
1280 m_impl->signal_update_lookup_table (this, subclass->get_candidate_table_ref());
1283 case ISM_TRANS_CMD_UPDATE_CANDIDATE_ITEM_LAYOUT:
1285 MessageItemUpdateCandidateItemLayout *subclass = static_cast<MessageItemUpdateCandidateItemLayout*>(message);
1286 m_impl->signal_update_candidate_item_layout (this, subclass->get_row_items_ref());
1287 if (!m_impl->si.null ()) m_impl->si->update_candidate_item_layout(subclass->get_row_items_ref());
1290 case ISM_TRANS_CMD_SELECT_ASSOCIATE:
1292 MessageItemSelectAssociate *subclass = static_cast<MessageItemSelectAssociate*>(message);
1293 m_impl->signal_select_associate (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1294 subclass->get_item_ref());
1297 case ISM_TRANS_CMD_ASSOCIATE_TABLE_PAGE_UP:
1299 MessageItemAssociateTablePageUp *subclass = static_cast<MessageItemAssociateTablePageUp*>(message);
1300 m_impl->signal_associate_table_page_up (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1303 case ISM_TRANS_CMD_ASSOCIATE_TABLE_PAGE_DOWN:
1305 MessageItemAssociateTablePageDown *subclass = static_cast<MessageItemAssociateTablePageDown*>(message);
1306 m_impl->signal_associate_table_page_down (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1309 case ISM_TRANS_CMD_UPDATE_ASSOCIATE_TABLE_PAGE_SIZE:
1311 MessageItemUpdateAssociateTablePageSize *subclass = static_cast<MessageItemUpdateAssociateTablePageSize*>(message);
1312 m_impl->signal_update_associate_table_page_size (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1313 subclass->get_size_ref());
1316 case ISM_TRANS_CMD_RESET_ISE_CONTEXT:
1318 MessageItemResetISEContext *subclass = static_cast<MessageItemResetISEContext*>(message);
1319 m_impl->signal_reset_ise_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1320 m_impl->signal_reset_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1321 if (!m_impl->si.null ()) m_impl->si->reset();
1324 case ISM_TRANS_CMD_TURN_ON_LOG:
1326 MessageItemTurnOnLog *subclass = static_cast<MessageItemTurnOnLog*>(message);
1327 m_impl->signal_turn_on_log (this, subclass->get_state_ref());
1330 case ISM_TRANS_CMD_UPDATE_DISPLAYED_CANDIDATE:
1332 MessageItemUpdateDisplayedCandidate *subclass = static_cast<MessageItemUpdateDisplayedCandidate*>(message);
1333 m_impl->signal_update_displayed_candidate_number (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1334 subclass->get_size_ref());
1335 if (!m_impl->si.null ()) m_impl->si->update_displayed_candidate_number(subclass->get_size_ref());
1338 case ISM_TRANS_CMD_LONGPRESS_CANDIDATE:
1340 MessageItemLongpressCandidate *subclass = static_cast<MessageItemLongpressCandidate*>(message);
1341 m_impl->signal_longpress_candidate (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1342 subclass->get_index_ref());
1343 if (!m_impl->si.null ()) m_impl->si->longpress_candidate(subclass->get_index_ref());
1346 case ISM_TRANS_CMD_SET_INPUT_HINT:
1348 MessageItemSetInputHint *subclass = static_cast<MessageItemSetInputHint*>(message);
1349 m_impl->signal_set_input_hint (this, subclass->get_input_hint_ref());
1350 if (!m_impl->si.null ()) m_impl->si->set_input_hint(subclass->get_input_hint_ref());
1353 case ISM_TRANS_CMD_UPDATE_BIDI_DIRECTION:
1355 MessageItemUpdateBidiDirection *subclass = static_cast<MessageItemUpdateBidiDirection*>(message);
1356 m_impl->signal_update_bidi_direction (this, subclass->get_bidi_direction());
1357 if (!m_impl->si.null ()) m_impl->si->update_bidi_direction(subclass->get_bidi_direction());
1360 case ISM_TRANS_CMD_SHOW_ISE_OPTION_WINDOW:
1362 MessageItemShowISEOptionWindow *subclass = static_cast<MessageItemShowISEOptionWindow*>(message);
1363 m_impl->signal_show_option_window (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1366 case ISM_TRANS_CMD_RESUME_ISE_OPTION_WINDOW:
1368 MessageItemResumeISEOptionWindow *subclass = static_cast<MessageItemResumeISEOptionWindow*>(message);
1369 m_impl->signal_resume_option_window (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1372 case ISM_TRANS_CMD_CHECK_OPTION_WINDOW:
1375 m_impl->signal_check_option_window (this, avail);
1376 m_impl->send.clear ();
1377 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1378 m_impl->send.put_data (avail);
1379 m_impl->send.write_to_socket (m_impl->socket);
1382 case ISM_TRANS_CMD_PROCESS_INPUT_DEVICE_EVENT:
1384 MessageItemProcessInputDeviceEvent *subclass = static_cast<MessageItemProcessInputDeviceEvent*>(message);
1386 m_impl->signal_process_input_device_event(this,
1387 subclass->get_type_ref(), *(subclass->get_data_ptr()), subclass->get_len_ref(), ret);
1388 m_impl->send.clear();
1389 m_impl->send.put_command(SCIM_TRANS_CMD_REPLY);
1390 m_impl->send.put_data(ret);
1391 m_impl->send.write_to_socket(m_impl->socket);
1394 case SCIM_TRANS_CMD_SET_AUTOCAPITAL_TYPE:
1396 MessageItemSetAutocapitalType *subclass = static_cast<MessageItemSetAutocapitalType*>(message);
1397 if (!m_impl->si.null ()) m_impl->si->set_autocapital_type(subclass->get_auto_capital_type_ref());
1400 case ISM_TRANS_CMD_SET_PREDICTION_ALLOW:
1402 MessageItemSetPredictionAllow *subclass = static_cast<MessageItemSetPredictionAllow*>(message);
1403 if (!m_impl->si.null ()) m_impl->si->set_prediction_allow(subclass->get_prediction_allow_ref() == 0 ? false : true);
1413 * @brief Request SCIM to reload all configuration.
1415 * This function should only by used by Setup Helper to request
1416 * scim's reloading the configuration.
1417 * Deprecated: reload config message only send by socketconfig client
1418 * using socketconfig::reload instead.
1421 HelperAgent::reload_config () const
1423 LOGD ("send reload config message to isf");
1424 if (!m_impl->m_config.null())
1425 m_impl->m_config->reload();
1429 * @brief Register some properties into Panel.
1431 * This function send the request to Panel to register a list
1434 * @param properties The list of Properties to be registered into Panel.
1436 * @sa scim::Property.
1439 HelperAgent::register_properties (const PropertyList &properties) const
1442 if (m_impl->socket_active.is_connected ()) {
1443 m_impl->send.clear ();
1444 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1445 m_impl->send.put_data (m_impl->magic_active);
1446 m_impl->send.put_command (SCIM_TRANS_CMD_REGISTER_PROPERTIES);
1447 m_impl->send.put_data (properties);
1448 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1453 * @brief Update a registered property.
1455 * @param property The property to be updated.
1458 HelperAgent::update_property (const Property &property) const
1461 if (m_impl->socket_active.is_connected ()) {
1462 m_impl->send.clear ();
1463 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1464 m_impl->send.put_data (m_impl->magic_active);
1465 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PROPERTY);
1466 m_impl->send.put_data (property);
1467 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1472 * @brief Send a set of events to an IMEngineInstance.
1474 * All events should be put into a Transaction.
1475 * And the events can only be received by one IMEngineInstance object.
1477 * @param ic The handle of the Input Context to receive the events.
1478 * @param ic_uuid The UUID of the Input Context.
1479 * @param trans The Transaction object holds the events.
1482 HelperAgent::send_imengine_event (int ic,
1483 const String &ic_uuid,
1484 const Transaction &trans) const
1487 //remove if not necessary
1489 if (m_impl->socket_active.is_connected ()) {
1490 m_impl->send.clear ();
1491 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1492 m_impl->send.put_data (m_impl->magic_active);
1493 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_SEND_IMENGINE_EVENT);
1494 m_impl->send.put_data ((uint32)ic);
1495 m_impl->send.put_data (ic_uuid);
1496 m_impl->send.put_data (trans);
1497 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1500 if (!m_impl->si.null ()) m_impl->si->process_helper_event (ic_uuid, trans);
1504 * @brief Send a KeyEvent to an IMEngineInstance.
1506 * @param ic The handle of the IMEngineInstance to receive the event.
1507 * -1 means the currently focused IMEngineInstance.
1508 * @param ic_uuid The UUID of the IMEngineInstance. Empty means don't match.
1509 * @param key The KeyEvent to be sent.
1512 HelperAgent::send_key_event (int ic,
1513 const String &ic_uuid,
1514 const KeyEvent &key) const
1518 //FIXME: remove shift_mode_off, shift_mode_on, shift_mode_lock from ISE side
1519 if (key.code == SHIFT_MODE_OFF ||
1520 key.code == SHIFT_MODE_ON ||
1521 key.code == SHIFT_MODE_LOCK ||
1522 key.code == SHIFT_MODE_ENABLE ||
1523 key.code == SHIFT_MODE_DISABLE) {
1524 LOGW("FIXME ignore shift codes");
1528 if (m_impl->socket_active.is_connected ()) {
1529 m_impl->send.clear ();
1530 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1531 m_impl->send.put_data (m_impl->magic_active);
1532 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_SEND_KEY_EVENT);
1534 m_impl->send.put_data (m_impl->focused_ic);
1536 m_impl->send.put_data ((uint32)ic);
1538 m_impl->send.put_data (ic_uuid);
1539 m_impl->send.put_data (key);
1540 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1545 * @brief Forward a KeyEvent to client application directly.
1547 * @param ic The handle of the client Input Context to receive the event.
1548 * -1 means the currently focused Input Context.
1549 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1550 * Empty means don't match.
1551 * @param key The KeyEvent to be forwarded.
1554 HelperAgent::forward_key_event (int ic,
1555 const String &ic_uuid,
1556 const KeyEvent &key) const
1559 if (m_impl->socket_active.is_connected ()) {
1560 m_impl->send.clear ();
1561 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1562 m_impl->send.put_data (m_impl->magic_active);
1563 m_impl->send.put_command (SCIM_TRANS_CMD_FORWARD_KEY_EVENT);
1565 m_impl->send.put_data (m_impl->focused_ic);
1567 m_impl->send.put_data ((uint32)ic);
1569 m_impl->send.put_data (ic_uuid);
1570 m_impl->send.put_data (key);
1571 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1576 * @brief Commit a WideString to client application directly.
1578 * @param ic The handle of the client Input Context to receive the WideString.
1579 * -1 means the currently focused Input Context.
1580 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1581 * Empty means don't match.
1582 * @param wstr The WideString to be committed.
1585 HelperAgent::commit_string (int ic,
1586 const String &ic_uuid,
1587 const WideString &wstr) const
1590 if (m_impl->socket_active.is_connected ()) {
1591 m_impl->send.clear ();
1592 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1593 m_impl->send.put_data (m_impl->magic_active);
1594 m_impl->send.put_command (SCIM_TRANS_CMD_COMMIT_STRING);
1596 m_impl->send.put_data (m_impl->focused_ic);
1598 m_impl->send.put_data ((uint32)ic);
1600 m_impl->send.put_data (ic_uuid);
1601 m_impl->send.put_data (wstr);
1602 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1607 HelperAgent::commit_string (int ic,
1608 const String &ic_uuid,
1613 if (m_impl->socket_active.is_connected ()) {
1614 m_impl->send.clear ();
1615 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1616 m_impl->send.put_data (m_impl->magic_active);
1617 m_impl->send.put_command (SCIM_TRANS_CMD_COMMIT_STRING);
1619 m_impl->send.put_data (m_impl->focused_ic);
1621 m_impl->send.put_data ((uint32)ic);
1623 m_impl->send.put_data (ic_uuid);
1624 m_impl->send.put_dataw (buf, buflen);
1625 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1630 * @brief Request to show preedit string.
1632 * @param ic The handle of the client Input Context to receive the request.
1633 * -1 means the currently focused Input Context.
1634 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1635 * Empty means don't match.
1638 HelperAgent::show_preedit_string (int ic,
1639 const String &ic_uuid) const
1643 if (m_impl->socket_active.is_connected ()) {
1644 m_impl->send.clear ();
1645 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1646 m_impl->send.put_data (m_impl->magic_active);
1647 m_impl->send.put_command (SCIM_TRANS_CMD_SHOW_PREEDIT_STRING);
1648 m_impl->send.put_data ((uint32)ic);
1649 m_impl->send.put_data (ic_uuid);
1650 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1655 * @brief Request to show aux string.
1658 HelperAgent::show_aux_string (void) const
1662 if (m_impl->socket_active.is_connected ()) {
1663 m_impl->send.clear ();
1664 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1665 m_impl->send.put_data (m_impl->magic_active);
1666 m_impl->send.put_command (SCIM_TRANS_CMD_SHOW_AUX_STRING);
1667 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1672 * @brief Request to show candidate string.
1675 HelperAgent::show_candidate_string (void) const
1679 if (m_impl->socket_active.is_connected ()) {
1680 m_impl->send.clear ();
1681 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1682 m_impl->send.put_data (m_impl->magic_active);
1683 m_impl->send.put_command (SCIM_TRANS_CMD_SHOW_LOOKUP_TABLE);
1684 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1689 * @brief Request to show associate string.
1692 HelperAgent::show_associate_string (void) const
1695 if (m_impl->socket_active.is_connected ()) {
1696 m_impl->send.clear ();
1697 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1698 m_impl->send.put_data (m_impl->magic_active);
1699 m_impl->send.put_command (ISM_TRANS_CMD_SHOW_ASSOCIATE_TABLE);
1700 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1705 * @brief Request to hide preedit string.
1707 * @param ic The handle of the client Input Context to receive the request.
1708 * -1 means the currently focused Input Context.
1709 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1710 * Empty means don't match.
1713 HelperAgent::hide_preedit_string (int ic,
1714 const String &ic_uuid) const
1718 if (m_impl->socket_active.is_connected ()) {
1719 m_impl->send.clear ();
1720 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1721 m_impl->send.put_data (m_impl->magic_active);
1722 m_impl->send.put_command (SCIM_TRANS_CMD_HIDE_PREEDIT_STRING);
1723 m_impl->send.put_data ((uint32)ic);
1724 m_impl->send.put_data (ic_uuid);
1725 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1730 * @brief Request to hide aux string.
1733 HelperAgent::hide_aux_string (void) const
1736 if (m_impl->socket_active.is_connected ()) {
1737 m_impl->send.clear ();
1738 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1739 m_impl->send.put_data (m_impl->magic_active);
1740 m_impl->send.put_command (SCIM_TRANS_CMD_HIDE_AUX_STRING);
1741 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1746 * @brief Request to hide candidate string.
1749 HelperAgent::hide_candidate_string (void) const
1752 if (m_impl->socket_active.is_connected ()) {
1753 m_impl->send.clear ();
1754 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1755 m_impl->send.put_data (m_impl->magic_active);
1756 m_impl->send.put_command (SCIM_TRANS_CMD_HIDE_LOOKUP_TABLE);
1757 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1762 * @brief Request to hide associate string.
1765 HelperAgent::hide_associate_string (void) const
1768 if (m_impl->socket_active.is_connected ()) {
1769 m_impl->send.clear ();
1770 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1771 m_impl->send.put_data (m_impl->magic_active);
1772 m_impl->send.put_command (ISM_TRANS_CMD_HIDE_ASSOCIATE_TABLE);
1773 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1778 * @brief Update a new WideString for preedit.
1780 * @param ic The handle of the client Input Context to receive the WideString.
1781 * -1 means the currently focused Input Context.
1782 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1783 * Empty means don't match.
1784 * @param str The WideString to be updated.
1785 * @param attrs The attribute list for preedit string.
1788 HelperAgent::update_preedit_string (int ic,
1789 const String &ic_uuid,
1790 const WideString &str,
1791 const AttributeList &attrs) const
1794 update_preedit_string (ic, ic_uuid, str, str, attrs, -1);
1798 HelperAgent::update_preedit_string (int ic,
1799 const String &ic_uuid,
1802 const AttributeList &attrs) const
1805 update_preedit_string (ic, ic_uuid, buf, buflen, attrs, -1);
1809 * @brief Update a new WideString for preedit.
1811 * @param ic The handle of the client Input Context to receive the WideString.
1812 * -1 means the currently focused Input Context.
1813 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1814 * Empty means don't match.
1815 * @param str The WideString to be updated.
1816 * @param attrs The attribute list for preedit string.
1817 * @param caret The caret position in preedit string.
1820 HelperAgent::update_preedit_string (int ic,
1821 const String &ic_uuid,
1822 const WideString &wstr,
1823 const AttributeList &attrs,
1827 update_preedit_string (ic, ic_uuid, wstr, wstr, attrs, caret);
1831 HelperAgent::update_preedit_string (int ic,
1832 const String &ic_uuid,
1835 const AttributeList &attrs,
1840 if (m_impl->socket_active.is_connected ()) {
1841 m_impl->send.clear ();
1842 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1843 m_impl->send.put_data (m_impl->magic_active);
1844 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING);
1845 m_impl->send.put_data ((uint32)ic);
1846 m_impl->send.put_data (ic_uuid);
1847 m_impl->send.put_dataw (buf, buflen);
1848 m_impl->send.put_dataw (buf, buflen);
1849 m_impl->send.put_data (attrs);
1850 m_impl->send.put_data (caret);
1851 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1856 HelperAgent::update_preedit_string (int ic,
1857 const String &ic_uuid,
1858 const WideString &preedit,
1859 const WideString &commit,
1860 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_data (preedit);
1872 m_impl->send.put_data (commit);
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 * @brief Update the preedit caret position in the preedit string.
1882 * @param caret - the new position of the preedit caret.
1885 HelperAgent::update_preedit_caret (int caret) const
1889 if (m_impl->socket_active.is_connected ()) {
1890 m_impl->send.clear ();
1891 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1892 m_impl->send.put_data (m_impl->magic_active);
1893 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_CARET);
1894 m_impl->send.put_data ((uint32)caret);
1895 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1900 * @brief Update a new string for aux.
1902 * @param str The string to be updated.
1903 * @param attrs The attribute list for aux string.
1906 HelperAgent::update_aux_string (const String &str,
1907 const AttributeList &attrs) const
1910 if (m_impl->socket_active.is_connected ()) {
1911 m_impl->send.clear ();
1912 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1913 m_impl->send.put_data (m_impl->magic_active);
1914 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_AUX_STRING);
1915 m_impl->send.put_data (str);
1916 m_impl->send.put_data (attrs);
1917 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1922 * @brief Request to update candidate.
1924 * @param table The lookup table for candidate.
1927 HelperAgent::update_candidate_string (const LookupTable &table) const
1930 if (m_impl->socket_active.is_connected ()) {
1931 m_impl->send.clear ();
1932 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1933 m_impl->send.put_data (m_impl->magic_active);
1934 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_LOOKUP_TABLE);
1935 m_impl->send.put_data (table);
1936 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1941 * @brief Request to update associate.
1943 * @param table The lookup table for associate.
1946 HelperAgent::update_associate_string (const LookupTable &table) const
1949 if (m_impl->socket_active.is_connected ()) {
1950 m_impl->send.clear ();
1951 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1952 m_impl->send.put_data (m_impl->magic_active);
1953 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ASSOCIATE_TABLE);
1954 m_impl->send.put_data (table);
1955 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1960 * @brief When the input context of ISE is changed,
1961 * ISE can call this function to notify application
1963 * @param type type of event.
1964 * @param value value of event.
1967 HelperAgent::update_input_context (uint32 type, uint32 value) const
1970 if (m_impl->socket_active.is_connected ()) {
1971 m_impl->send.clear ();
1972 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1973 m_impl->send.put_data (m_impl->magic_active);
1974 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ISE_INPUT_CONTEXT);
1975 m_impl->send.put_data (type);
1976 m_impl->send.put_data (value);
1977 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1982 * @brief Request to get surrounding text asynchronously.
1984 * @param uuid The helper ISE UUID.
1985 * @param maxlen_before The max length of before.
1986 * @param maxlen_after The max length of after.
1989 HelperAgent::get_surrounding_text (const String &uuid, int maxlen_before, int maxlen_after) const
1992 if (m_impl->socket_active.is_connected () && (m_impl->need_update_surrounding_text == 0)) {
1993 m_impl->send.clear ();
1994 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1995 m_impl->send.put_data (m_impl->magic_active);
1996 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SURROUNDING_TEXT);
1997 m_impl->send.put_data (uuid);
1998 m_impl->send.put_data (maxlen_before);
1999 m_impl->send.put_data (maxlen_after);
2000 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2002 m_impl->need_update_surrounding_text++;
2006 * @brief Request to get surrounding text synchronously.
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.
2011 * @param text The surrounding text.
2012 * @param cursor The cursor position.
2015 HelperAgent::get_surrounding_text (int maxlen_before, int maxlen_after, String &text, int &cursor)
2019 if (!m_impl->socket_active.is_connected ())
2022 m_impl->send.clear ();
2023 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2024 m_impl->send.put_data (m_impl->magic_active);
2025 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SURROUNDING_TEXT);
2026 m_impl->send.put_data ("");
2027 m_impl->send.put_data (maxlen_before);
2028 m_impl->send.put_data (maxlen_after);
2029 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2030 if (m_impl->surrounding_text) {
2031 free (m_impl->surrounding_text);
2032 m_impl->surrounding_text = NULL;
2035 const int WAIT_FOR_SYNC_RESPONSE_TIMEOUT = 1000;
2036 /* Now we are waiting for the ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT message */
2037 if (wait_for_message(ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT, WAIT_FOR_SYNC_RESPONSE_TIMEOUT)) {
2038 MessageItem *message = message_queue.get_pending_message_by_cmd(ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT);
2039 handle_message(message);
2040 message_queue.remove_message(message);
2042 if (m_impl->surrounding_text) {
2043 text = m_impl->surrounding_text;
2044 cursor = m_impl->cursor_pos;
2048 if (m_impl->surrounding_text) {
2049 free (m_impl->surrounding_text);
2050 m_impl->surrounding_text = NULL;
2055 * @brief Request to delete surrounding text.
2057 * @param offset The offset for cursor position.
2058 * @param len The length for delete text.
2061 HelperAgent::delete_surrounding_text (int offset, int len) const
2063 LOGD ("offset = %d, len = %d", offset, len);
2065 if (m_impl->socket_active.is_connected ()) {
2066 m_impl->send.clear ();
2067 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2068 m_impl->send.put_data (m_impl->magic_active);
2069 m_impl->send.put_command (SCIM_TRANS_CMD_DELETE_SURROUNDING_TEXT);
2070 m_impl->send.put_data (offset);
2071 m_impl->send.put_data (len);
2072 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2077 * @brief Request to get selection text asynchronously.
2079 * @param uuid The helper ISE UUID.
2082 HelperAgent::get_selection (const String &uuid) const
2085 if (m_impl->socket_active.is_connected () && (m_impl->need_update_selection_text == 0)) {
2086 m_impl->send.clear ();
2087 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2088 m_impl->send.put_data (m_impl->magic_active);
2089 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SELECTION);
2090 m_impl->send.put_data (uuid);
2091 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2093 m_impl->need_update_selection_text++;
2097 * @brief Request to get selection text synchronously.
2099 * @param text The selection text.
2102 HelperAgent::get_selection_text (String &text)
2106 if (!m_impl->socket_active.is_connected ())
2109 m_impl->send.clear ();
2110 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2111 m_impl->send.put_data (m_impl->magic_active);
2112 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SELECTION);
2113 m_impl->send.put_data ("");
2114 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2115 if (m_impl->selection_text) {
2116 free (m_impl->selection_text);
2117 m_impl->selection_text = NULL;
2120 const int WAIT_FOR_SYNC_RESPONSE_TIMEOUT = 1000;
2121 /* Now we are waiting for the ISM_TRANS_CMD_UPDATE_SELECTION message */
2122 if (wait_for_message(ISM_TRANS_CMD_UPDATE_SELECTION, WAIT_FOR_SYNC_RESPONSE_TIMEOUT)) {
2123 MessageItem *message = message_queue.get_pending_message_by_cmd(ISM_TRANS_CMD_UPDATE_SELECTION);
2124 handle_message(message);
2125 message_queue.remove_message(message);
2126 if (m_impl->selection_text) {
2127 text = m_impl->selection_text;
2131 if (m_impl->selection_text) {
2132 free (m_impl->selection_text);
2133 m_impl->selection_text = NULL;
2138 * @brief Request to select text.
2140 * @param start The start position in text.
2141 * @param end The end position in text.
2144 HelperAgent::set_selection (int start, int end) const
2147 if (m_impl->socket_active.is_connected ()) {
2148 m_impl->send.clear ();
2149 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2150 m_impl->send.put_data (m_impl->magic_active);
2151 m_impl->send.put_command (SCIM_TRANS_CMD_SET_SELECTION);
2152 m_impl->send.put_data (start);
2153 m_impl->send.put_data (end);
2154 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2159 * @brief Send a private command to an application.
2161 * @param command The private command sent from IME.
2164 HelperAgent::send_private_command (const String &command) const
2167 if (m_impl->socket_active.is_connected ()) {
2168 m_impl->send.clear ();
2169 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2170 m_impl->send.put_data (m_impl->magic_active);
2171 m_impl->send.put_command (SCIM_TRANS_CMD_SEND_PRIVATE_COMMAND);
2172 m_impl->send.put_data (command);
2173 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2178 * @brief Request to get uuid list of all keyboard ISEs.
2180 * @param uuid The helper ISE UUID.
2183 HelperAgent::get_keyboard_ise_list (const String &uuid) const
2186 if (m_impl->socket_active.is_connected ()) {
2187 m_impl->send.clear ();
2188 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2189 m_impl->send.put_data (m_impl->magic_active);
2190 m_impl->send.put_command (ISM_TRANS_CMD_GET_KEYBOARD_ISE_LIST);
2191 m_impl->send.put_data (uuid);
2192 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2197 * @brief Set candidate position in screen.
2199 * @param left The x position in screen.
2200 * @param top The y position in screen.
2203 HelperAgent::set_candidate_position (int left, int top) const
2206 if (m_impl->socket_active.is_connected ()) {
2207 m_impl->send.clear ();
2208 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2209 m_impl->send.put_data (m_impl->magic_active);
2210 m_impl->send.put_command (ISM_TRANS_CMD_SET_CANDIDATE_POSITION);
2211 m_impl->send.put_data (left);
2212 m_impl->send.put_data (top);
2213 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2218 * @brief Set candidate style.
2220 * @param portrait_line - the displayed line number for portrait mode.
2221 * @param mode - candidate window mode.
2224 HelperAgent::set_candidate_style (ISF_CANDIDATE_PORTRAIT_LINE_T portrait_line,
2225 ISF_CANDIDATE_MODE_T mode) const
2228 if (m_impl->socket_active.is_connected ()) {
2229 m_impl->send.clear ();
2230 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2231 m_impl->send.put_data (m_impl->magic_active);
2232 m_impl->send.put_command (ISM_TRANS_CMD_SET_CANDIDATE_UI);
2233 m_impl->send.put_data (portrait_line);
2234 m_impl->send.put_data (mode);
2235 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2240 * @brief Request to hide candidate window.
2243 HelperAgent::candidate_hide (void) const
2246 if (m_impl->socket_active.is_connected ()) {
2247 m_impl->send.clear ();
2248 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2249 m_impl->send.put_data (m_impl->magic_active);
2250 m_impl->send.put_command (ISM_TRANS_CMD_HIDE_CANDIDATE);
2251 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2256 * @brief Request to get candidate window size and position.
2258 * @param uuid The helper ISE UUID.
2261 HelperAgent::get_candidate_window_geometry (const String &uuid) const
2264 if (m_impl->socket_active.is_connected ()) {
2265 m_impl->send.clear ();
2266 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2267 m_impl->send.put_data (m_impl->magic_active);
2268 m_impl->send.put_command (ISM_TRANS_CMD_GET_CANDIDATE_GEOMETRY);
2269 m_impl->send.put_data (uuid);
2270 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2275 * @brief Set current keyboard ISE.
2277 * @param uuid The keyboard ISE UUID.
2280 HelperAgent::set_keyboard_ise_by_uuid (const String &uuid) const
2284 IMEngineFactoryPointer factory;
2285 IMEngineModule *engine_module = NULL;
2286 static int instance_count = 1;
2288 if ((!m_impl->si.null ()) && m_impl->si->get_factory_uuid () == uuid) {
2289 LOGD ("Already in UUID: %s\n", uuid.c_str());
2293 if (!m_impl->si.null()) {
2294 m_impl->si->focus_out();
2298 if (m_impl->m_config.null ()) {
2299 LOGW ("config is not working");
2303 #ifdef HAVE_PKGMGR_INFO
2306 pkgmgrinfo_appinfo_h handle;
2307 ret = pkgmgrinfo_appinfo_get_appinfo(uuid.c_str(), &handle);
2308 if (ret != PMINFO_R_OK) {
2309 LOGW("Retrieve app info failed : %s", uuid.c_str ());
2313 ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
2314 if (ret != PMINFO_R_OK) {
2315 LOGW("Retrieve pkgid failed : %s, %p", uuid.c_str(), handle);
2316 pkgmgrinfo_appinfo_destroy_appinfo(handle);
2320 imeInfo.module_name = pkgid;
2321 pkgmgrinfo_appinfo_destroy_appinfo(handle);
2323 if (isf_db_select_ime_info_by_appid(uuid.c_str(), &imeInfo) < 1) {
2324 LOGW("ime_info row is not available for %s", uuid.c_str());
2329 engine_module = &m_impl->engine_module;
2331 if (engine_module->valid() && imeInfo.module_name != engine_module->get_module_name()) {
2332 LOGD ("imengine module %s unloaded", engine_module->get_module_name().c_str());
2333 engine_module->unload();
2336 if (!engine_module->valid()) {
2337 if (engine_module->load (imeInfo.module_name, m_impl->m_config) == false) {
2338 LOGW ("load module %s failed", imeInfo.module_name.c_str());
2341 LOGD ("imengine module %s loaded", imeInfo.module_name.c_str());
2344 for (size_t j = 0; j < engine_module->number_of_factories (); ++j) {
2347 factory = engine_module->create_factory (j);
2348 if (factory.null () == false && factory->get_uuid () == uuid)
2356 if (factory.null()) {
2357 LOGW ("imengine uuid %s is not found", uuid.c_str());
2361 m_impl->si = factory->create_instance ("UTF-8", instance_count++);
2362 if (m_impl->si.null ()) {
2363 LOGE ("create_instance %s failed",uuid.c_str ());
2367 m_impl->attach_instance ();
2368 LOGD ("Require UUID: %s Current UUID: %s", uuid.c_str (), m_impl->si->get_factory_uuid ().c_str ());
2369 m_impl->si->set_layout (m_impl->layout);
2370 if(m_impl->focused_ic != (uint32)-1)
2371 m_impl->si->focus_in ();
2375 * @brief Request to get current keyboard ISE information.
2377 * @param uuid The helper ISE UUID.
2380 HelperAgent::get_keyboard_ise (const String &uuid) const
2383 //FIXME: maybe useless
2385 if (m_impl->socket_active.is_connected ()) {
2386 m_impl->send.clear ();
2387 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2388 m_impl->send.put_data (m_impl->magic_active);
2389 m_impl->send.put_command (ISM_TRANS_CMD_GET_KEYBOARD_ISE);
2390 m_impl->send.put_data (uuid);
2391 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2397 * @brief Update ISE window geometry.
2399 * @param x The x position in screen.
2400 * @param y The y position in screen.
2401 * @param width The ISE window width.
2402 * @param height The ISE window height.
2405 HelperAgent::update_geometry (int x, int y, int width, int height) const
2408 if (m_impl->socket_active.is_connected ()) {
2409 m_impl->send.clear ();
2410 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2411 m_impl->send.put_data (m_impl->magic_active);
2412 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ISE_GEOMETRY);
2413 m_impl->send.put_data (x);
2414 m_impl->send.put_data (y);
2415 m_impl->send.put_data (width);
2416 m_impl->send.put_data (height);
2417 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2422 * @brief Request to expand candidate window.
2425 HelperAgent::expand_candidate (void) const
2428 if (m_impl->socket_active.is_connected ()) {
2429 m_impl->send.clear ();
2430 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2431 m_impl->send.put_data (m_impl->magic_active);
2432 m_impl->send.put_command (ISM_TRANS_CMD_EXPAND_CANDIDATE);
2433 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2438 * @brief Request to contract candidate window.
2441 HelperAgent::contract_candidate (void) const
2444 if (m_impl->socket_active.is_connected ()) {
2445 m_impl->send.clear ();
2446 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2447 m_impl->send.put_data (m_impl->magic_active);
2448 m_impl->send.put_command (ISM_TRANS_CMD_CONTRACT_CANDIDATE);
2449 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2454 * @brief Send selected candidate string index number.
2457 HelperAgent::select_candidate (int index) const
2460 if (!m_impl->si.null ())
2461 m_impl->si->select_candidate (index);
2462 //FIXME: maybe useless
2465 if (m_impl->socket_active.is_connected ()) {
2466 m_impl->send.clear ();
2467 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2468 m_impl->send.put_data (m_impl->magic_active);
2469 m_impl->send.put_command (ISM_TRANS_CMD_SELECT_CANDIDATE);
2470 m_impl->send.put_data (index);
2471 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2477 * @brief Update our ISE is exiting.
2480 HelperAgent::update_ise_exit (void) const
2483 //FIXME: maybe useless
2485 if (m_impl->socket_active.is_connected ()) {
2486 m_impl->send.clear ();
2487 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2488 m_impl->send.put_data (m_impl->magic_active);
2489 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ISE_EXIT);
2490 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2496 * @brief Request to reset keyboard ISE.
2499 HelperAgent::reset_keyboard_ise (void) const
2502 //FIXME: maybe useless
2504 if (m_impl->socket_active.is_connected ()) {
2505 m_impl->send.clear ();
2506 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2507 m_impl->send.put_data (m_impl->magic_active);
2508 m_impl->send.put_command (ISM_TRANS_CMD_PANEL_RESET_KEYBOARD_ISE);
2509 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2512 if (!m_impl->si.null ()) {
2513 m_impl->si->reset ();
2518 * @brief Request to flush keyboard ISE.
2521 HelperAgent::flush_keyboard_ise (void) const
2524 if (!m_impl->si.null ()) {
2525 m_impl->si->flush ();
2530 * @brief Request panel to hide ISE.
2533 HelperAgent::request_ise_hide (void) const
2536 if (m_impl->socket_active.is_connected ()) {
2537 m_impl->send.clear ();
2538 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2539 m_impl->send.put_data (m_impl->magic_active);
2540 m_impl->send.put_command (ISM_TRANS_CMD_REQUEST_ISE_HIDE);
2541 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2546 * @brief Connect a slot to Helper exit signal.
2548 * This signal is used to let the Helper exit.
2550 * The prototype of the slot is:
2552 * void exit (const HelperAgent *agent, int ic, const String &ic_uuid);
2555 * - agent The pointer to the HelperAgent object which emits this signal.
2556 * - ic An opaque handle of the currently focused input context.
2557 * - ic_uuid The UUID of the IMEngineInstance associated with the focused input context.
2560 HelperAgent::signal_connect_exit (HelperAgentSlotVoid *slot)
2562 return m_impl->signal_exit.connect (slot);
2566 * @brief Connect a slot to Helper attach input context signal.
2568 * This signal is used to attach an input context to this helper.
2570 * When an input context requst to start this helper, then this
2571 * signal will be emitted as soon as the helper is started.
2573 * When an input context want to start an already started helper,
2574 * this signal will also be emitted.
2576 * Helper can send some events back to the IMEngineInstance in this
2577 * signal-slot, to inform that it has been started sccessfully.
2579 * The prototype of the slot is:
2581 * void attach_input_context (const HelperAgent *agent, int ic, const String &ic_uuid);
2584 HelperAgent::signal_connect_attach_input_context (HelperAgentSlotVoid *slot)
2586 return m_impl->signal_attach_input_context.connect (slot);
2590 * @brief Connect a slot to Helper detach input context signal.
2592 * This signal is used to detach an input context from this helper.
2594 * When an input context requst to stop this helper, then this
2595 * signal will be emitted.
2597 * Helper shouldn't send any event back to the IMEngineInstance, because
2598 * the IMEngineInstance attached to the ic should have been destroyed.
2600 * The prototype of the slot is:
2602 * void detach_input_context (const HelperAgent *agent, int ic, const String &ic_uuid);
2605 HelperAgent::signal_connect_detach_input_context (HelperAgentSlotVoid *slot)
2607 return m_impl->signal_detach_input_context.connect (slot);
2611 * @brief Connect a slot to Helper reload config signal.
2613 * This signal is used to let the Helper reload configuration.
2615 * The prototype of the slot is:
2617 * void reload_config (const HelperAgent *agent, int ic, const String &ic_uuid);
2620 HelperAgent::signal_connect_reload_config (HelperAgentSlotVoid *slot)
2622 return m_impl->signal_reload_config.connect (slot);
2626 * @brief Connect a slot to Helper update screen signal.
2628 * This signal is used to let the Helper move its GUI to another screen.
2629 * It can only be emitted when SCIM_HELPER_NEED_SCREEN_INFO is set in HelperInfo.option.
2631 * The prototype of the slot is:
2633 * void update_screen (const HelperAgent *agent, int ic, const String &ic_uuid, int screen_number);
2636 HelperAgent::signal_connect_update_screen (HelperAgentSlotInt *slot)
2638 return m_impl->signal_update_screen.connect (slot);
2642 * @brief Connect a slot to Helper update spot location signal.
2644 * This signal is used to let the Helper move its GUI according to the current spot location.
2645 * It can only be emitted when SCIM_HELPER_NEED_SPOT_LOCATION_INFO is set in HelperInfo.option.
2647 * The prototype of the slot is:
2648 * void update_spot_location (const HelperAgent *agent, int ic, const String &ic_uuid, int x, int y);
2651 HelperAgent::signal_connect_update_spot_location (HelperAgentSlotIntInt *slot)
2653 return m_impl->signal_update_spot_location.connect (slot);
2657 * @brief Connect a slot to Helper update cursor position signal.
2659 * This signal is used to let the Helper get the cursor position information.
2661 * The prototype of the slot is:
2662 * void update_cursor_position (const HelperAgent *agent, int ic, const String &ic_uuid, int cursor_pos);
2665 HelperAgent::signal_connect_update_cursor_position (HelperAgentSlotInt *slot)
2667 return m_impl->signal_update_cursor_position.connect (slot);
2671 * @brief Connect a slot to Helper update surrounding text signal.
2673 * This signal is used to let the Helper get the surrounding text.
2675 * The prototype of the slot is:
2676 * void update_surrounding_text (const HelperAgent *agent, int ic, const String &text, int cursor);
2679 HelperAgent::signal_connect_update_surrounding_text (HelperAgentSlotInt *slot)
2681 return m_impl->signal_update_surrounding_text.connect (slot);
2685 * @brief Connect a slot to Helper update selection signal.
2687 * This signal is used to let the Helper get the selection.
2689 * The prototype of the slot is:
2690 * void update_selection (const HelperAgent *agent, int ic, const String &text);
2693 HelperAgent::signal_connect_update_selection (HelperAgentSlotVoid *slot)
2695 return m_impl->signal_update_selection.connect (slot);
2699 * @brief Connect a slot to Helper trigger property signal.
2701 * This signal is used to trigger a property registered by this Helper.
2702 * A property will be triggered when user clicks on it.
2704 * The prototype of the slot is:
2705 * void trigger_property (const HelperAgent *agent, int ic, const String &ic_uuid, const String &property);
2708 HelperAgent::signal_connect_trigger_property (HelperAgentSlotString *slot)
2710 return m_impl->signal_trigger_property.connect (slot);
2714 * @brief Connect a slot to Helper process imengine event signal.
2716 * This signal is used to deliver the events sent from IMEngine to Helper.
2718 * The prototype of the slot is:
2719 * void process_imengine_event (const HelperAgent *agent, int ic, const String &ic_uuid, const Transaction &transaction);
2722 HelperAgent::signal_connect_process_imengine_event (HelperAgentSlotTransaction *slot)
2724 return m_impl->signal_process_imengine_event.connect (slot);
2728 * @brief Connect a slot to Helper focus out signal.
2730 * This signal is used to do something when input context is focus out.
2732 * The prototype of the slot is:
2733 * void focus_out (const HelperAgent *agent, int ic, const String &ic_uuid);
2736 HelperAgent::signal_connect_focus_out (HelperAgentSlotVoid *slot)
2738 return m_impl->signal_focus_out.connect (slot);
2742 * @brief Connect a slot to Helper focus in signal.
2744 * This signal is used to do something when input context is focus in.
2746 * The prototype of the slot is:
2747 * void focus_in (const HelperAgent *agent, int ic, const String &ic_uuid);
2750 HelperAgent::signal_connect_focus_in (HelperAgentSlotVoid *slot)
2752 return m_impl->signal_focus_in.connect (slot);
2756 * @brief Connect a slot to Helper show signal.
2758 * This signal is used to show Helper ISE window.
2760 * The prototype of the slot is:
2761 * void ise_show (const HelperAgent *agent, int ic, char *buf, size_t &len);
2764 HelperAgent::signal_connect_ise_show (HelperAgentSlotIntRawVoid *slot)
2766 return m_impl->signal_ise_show.connect (slot);
2770 * @brief Connect a slot to Helper hide signal.
2772 * This signal is used to hide Helper ISE window.
2774 * The prototype of the slot is:
2775 * void ise_hide (const HelperAgent *agent, int ic, const String &ic_uuid);
2778 HelperAgent::signal_connect_ise_hide (HelperAgentSlotVoid *slot)
2780 return m_impl->signal_ise_hide.connect (slot);
2784 * @brief Connect a slot to Helper get ISE window geometry signal.
2786 * This signal is used to get Helper ISE window size and position.
2788 * The prototype of the slot is:
2789 * void get_geometry (const HelperAgent *agent, struct rectinfo &info);
2792 HelperAgent::signal_connect_get_geometry (HelperAgentSlotSize *slot)
2794 return m_impl->signal_get_geometry.connect (slot);
2798 * @brief Connect a slot to Helper set mode signal.
2800 * This signal is used to set Helper ISE mode.
2802 * The prototype of the slot is:
2803 * void set_mode (const HelperAgent *agent, uint32 &mode);
2806 HelperAgent::signal_connect_set_mode (HelperAgentSlotUintVoid *slot)
2808 return m_impl->signal_set_mode.connect (slot);
2812 * @brief Connect a slot to Helper set language signal.
2814 * This signal is used to set Helper ISE language.
2816 * The prototype of the slot is:
2817 * void set_language (const HelperAgent *agent, uint32 &language);
2820 HelperAgent::signal_connect_set_language (HelperAgentSlotUintVoid *slot)
2822 return m_impl->signal_set_language.connect (slot);
2826 * @brief Connect a slot to Helper set im data signal.
2828 * This signal is used to send im data to Helper ISE.
2830 * The prototype of the slot is:
2831 * void set_imdata (const HelperAgent *agent, char *buf, size_t &len);
2834 HelperAgent::signal_connect_set_imdata (HelperAgentSlotRawVoid *slot)
2836 return m_impl->signal_set_imdata.connect (slot);
2840 * @brief Connect a slot to Helper get im data signal.
2842 * This signal is used to get im data from Helper ISE.
2844 * The prototype of the slot is:
2845 * void get_imdata (const HelperAgent *, char **buf, size_t &len);
2848 HelperAgent::signal_connect_get_imdata (HelperAgentSlotGetRawVoid *slot)
2850 return m_impl->signal_get_imdata.connect (slot);
2854 * @brief Connect a slot to Helper get language locale signal.
2856 * This signal is used to get language locale from Helper ISE.
2858 * The prototype of the slot is:
2859 * void get_language_locale (const HelperAgent *, int ic, char **locale);
2862 HelperAgent::signal_connect_get_language_locale (HelperAgentSlotIntGetStringVoid *slot)
2864 return m_impl->signal_get_language_locale.connect (slot);
2868 * @brief Connect a slot to Helper set return key type signal.
2870 * This signal is used to send return key type to Helper ISE.
2872 * The prototype of the slot is:
2873 * void set_return_key_type (const HelperAgent *agent, uint32 &type);
2876 HelperAgent::signal_connect_set_return_key_type (HelperAgentSlotUintVoid *slot)
2878 return m_impl->signal_set_return_key_type.connect (slot);
2882 * @brief Connect a slot to Helper get return key type signal.
2884 * This signal is used to get return key type from Helper ISE.
2886 * The prototype of the slot is:
2887 * void get_return_key_type (const HelperAgent *agent, uint32 &type);
2890 HelperAgent::signal_connect_get_return_key_type (HelperAgentSlotUintVoid *slot)
2892 return m_impl->signal_get_return_key_type.connect (slot);
2896 * @brief Connect a slot to Helper set return key disable signal.
2898 * This signal is used to send return key disable to Helper ISE.
2900 * The prototype of the slot is:
2901 * void set_return_key_disable (const HelperAgent *agent, uint32 &disabled);
2904 HelperAgent::signal_connect_set_return_key_disable (HelperAgentSlotUintVoid *slot)
2906 return m_impl->signal_set_return_key_disable.connect (slot);
2910 * @brief Connect a slot to Helper process key event signal.
2912 * This signal is used to send keyboard key event to Helper ISE.
2914 * The prototype of the slot is:
2915 * void process_key_event (const HelperAgent *agent, KeyEvent &key, uint32 &ret);
2918 HelperAgent::signal_connect_process_key_event (HelperAgentSlotKeyEventUint *slot)
2920 return m_impl->signal_process_key_event.connect (slot);
2924 * @brief Connect a slot to Helper get return key disable signal.
2926 * This signal is used to get return key disable from Helper ISE.
2928 * The prototype of the slot is:
2929 * void get_return_key_disable (const HelperAgent *agent, uint32 &disabled);
2932 HelperAgent::signal_connect_get_return_key_disable (HelperAgentSlotUintVoid *slot)
2934 return m_impl->signal_get_return_key_disable.connect (slot);
2938 * @brief Connect a slot to Helper set layout signal.
2940 * This signal is used to set Helper ISE layout.
2942 * The prototype of the slot is:
2943 * void set_layout (const HelperAgent *agent, uint32 &layout);
2946 HelperAgent::signal_connect_set_layout (HelperAgentSlotUintVoid *slot)
2948 return m_impl->signal_set_layout.connect (slot);
2952 * @brief Connect a slot to Helper get layout signal.
2954 * This signal is used to get Helper ISE layout.
2956 * The prototype of the slot is:
2957 * void get_layout (const HelperAgent *agent, uint32 &layout);
2960 HelperAgent::signal_connect_get_layout (HelperAgentSlotUintVoid *slot)
2962 return m_impl->signal_get_layout.connect (slot);
2966 * @brief Connect a slot to Helper set input mode signal.
2968 * This signal is used to set Helper ISE input mode.
2970 * The prototype of the slot is:
2971 * void set_input_mode (const HelperAgent *agent, uint32 &input_mode);
2974 HelperAgent::signal_connect_set_input_mode (HelperAgentSlotUintVoid *slot)
2976 return m_impl->signal_set_input_mode.connect (slot);
2980 * @brief Connect a slot to Helper set input hint signal.
2982 * This signal is used to set Helper ISE input hint.
2984 * The prototype of the slot is:
2985 * void set_input_hint (const HelperAgent *agent, uint32 &input_hint);
2988 HelperAgent::signal_connect_set_input_hint (HelperAgentSlotUintVoid *slot)
2990 return m_impl->signal_set_input_hint.connect (slot);
2994 * @brief Connect a slot to Helper set BiDi direction signal.
2996 * This signal is used to set Helper ISE BiDi direction.
2998 * The prototype of the slot is:
2999 * void update_bidi_direction (const HelperAgent *agent, uint32 &bidi_direction);
3002 HelperAgent::signal_connect_update_bidi_direction (HelperAgentSlotUintVoid *slot)
3004 return m_impl->signal_update_bidi_direction.connect (slot);
3008 * @brief Connect a slot to Helper set shift mode signal.
3010 * This signal is used to set Helper shift mode.
3012 * The prototype of the slot is:
3013 * void set_caps_mode (const HelperAgent *agent, uint32 &mode);
3016 HelperAgent::signal_connect_set_caps_mode (HelperAgentSlotUintVoid *slot)
3018 return m_impl->signal_set_caps_mode.connect (slot);
3022 * @brief Connect a slot to Helper reset input context signal.
3024 * This signal is used to reset Helper ISE input context.
3026 * The prototype of the slot is:
3027 * void reset_input_context (const HelperAgent *agent, int ic, const String &uuid);
3030 HelperAgent::signal_connect_reset_input_context (HelperAgentSlotVoid *slot)
3032 return m_impl->signal_reset_input_context.connect (slot);
3036 * @brief Connect a slot to Helper update candidate window geometry signal.
3038 * This signal is used to get candidate window size and position.
3040 * The prototype of the slot is:
3041 * void update_candidate_geometry (const HelperAgent *agent, int ic, const String &uuid, const rectinfo &info);
3044 HelperAgent::signal_connect_update_candidate_geometry (HelperAgentSlotRect *slot)
3046 return m_impl->signal_update_candidate_geometry.connect (slot);
3050 * @brief Connect a slot to Helper update keyboard ISE signal.
3052 * This signal is used to get current keyboard ISE name and uuid.
3054 * The prototype of the slot is:
3055 * void update_keyboard_ise (const HelperAgent *agent, int ic, const String &uuid,
3056 * const String &ise_name, const String &ise_uuid);
3059 HelperAgent::signal_connect_update_keyboard_ise (HelperAgentSlotString2 *slot)
3061 return m_impl->signal_update_keyboard_ise.connect (slot);
3065 * @brief Connect a slot to Helper update keyboard ISE list signal.
3067 * This signal is used to get uuid list of all keyboard ISEs.
3069 * The prototype of the slot is:
3070 * void update_keyboard_ise_list (const HelperAgent *agent, int ic, const String &uuid,
3071 * const std::vector<String> &ise_list);
3074 HelperAgent::signal_connect_update_keyboard_ise_list (HelperAgentSlotStringVector *slot)
3076 return m_impl->signal_update_keyboard_ise_list.connect (slot);
3080 * @brief Connect a slot to Helper candidate more window show signal.
3082 * This signal is used to do someting when candidate more window is showed.
3084 * The prototype of the slot is:
3085 * void candidate_more_window_show (const HelperAgent *agent, int ic, const String &uuid);
3088 HelperAgent::signal_connect_candidate_more_window_show (HelperAgentSlotVoid *slot)
3090 return m_impl->signal_candidate_more_window_show.connect (slot);
3094 * @brief Connect a slot to Helper candidate more window hide signal.
3096 * This signal is used to do someting when candidate more window is hidden.
3098 * The prototype of the slot is:
3099 * void candidate_more_window_hide (const HelperAgent *agent, int ic, const String &uuid);
3102 HelperAgent::signal_connect_candidate_more_window_hide (HelperAgentSlotVoid *slot)
3104 return m_impl->signal_candidate_more_window_hide.connect (slot);
3108 * @brief Connect a slot to Helper candidate show signal.
3110 * This signal is used to do candidate show.
3112 * The prototype of the slot is:
3113 * void candidate_show (const HelperAgent *agent, int ic, const String &uuid);
3116 HelperAgent::signal_connect_candidate_show (HelperAgentSlotVoid *slot)
3118 return m_impl->signal_candidate_show.connect (slot);
3122 * @brief Connect a slot to Helper candidate hide signal.
3124 * This signal is used to do candidate hide.
3126 * The prototype of the slot is:
3127 * void candidate_hide (const HelperAgent *agent, int ic, const String &uuid);
3130 HelperAgent::signal_connect_candidate_hide (HelperAgentSlotVoid *slot)
3132 return m_impl->signal_candidate_hide.connect (slot);
3136 * @brief Connect a slot to Helper update lookup table signal.
3138 * This signal is used to do someting when update lookup table.
3140 * The prototype of the slot is:
3141 * void update_lookup_table (const HelperAgent *agent, int ic, const String &uuid ,LookupTable &table);
3144 HelperAgent::signal_connect_update_lookup_table (HelperAgentSlotLookupTable *slot)
3146 return m_impl->signal_update_lookup_table.connect (slot);
3150 * @brief Connect a slot to Helper select aux signal.
3152 * This signal is used to do something when aux is selected.
3154 * The prototype of the slot is:
3155 * void select_aux (const HelperAgent *agent, int ic, const String &uuid, int index);
3158 HelperAgent::signal_connect_select_aux (HelperAgentSlotInt *slot)
3160 return m_impl->signal_select_aux.connect (slot);
3164 * @brief Connect a slot to Helper select candidate signal.
3166 * This signal is used to do something when candidate is selected.
3168 * The prototype of the slot is:
3169 * void select_candidate (const HelperAgent *agent, int ic, const String &uuid, int index);
3172 HelperAgent::signal_connect_select_candidate (HelperAgentSlotInt *slot)
3174 return m_impl->signal_select_candidate.connect (slot);
3178 * @brief Connect a slot to Helper candidate table page up signal.
3180 * This signal is used to do something when candidate table is paged up.
3182 * The prototype of the slot is:
3183 * void candidate_table_page_up (const HelperAgent *agent, int ic, const String &uuid);
3186 HelperAgent::signal_connect_candidate_table_page_up (HelperAgentSlotVoid *slot)
3188 return m_impl->signal_candidate_table_page_up.connect (slot);
3192 * @brief Connect a slot to Helper candidate table page down signal.
3194 * This signal is used to do something when candidate table is paged down.
3196 * The prototype of the slot is:
3197 * void candidate_table_page_down (const HelperAgent *agent, int ic, const String &uuid);
3200 HelperAgent::signal_connect_candidate_table_page_down (HelperAgentSlotVoid *slot)
3202 return m_impl->signal_candidate_table_page_down.connect (slot);
3206 * @brief Connect a slot to Helper update candidate table page size signal.
3208 * This signal is used to do something when candidate table page size is changed.
3210 * The prototype of the slot is:
3211 * void update_candidate_table_page_size (const HelperAgent *, int ic, const String &uuid, int page_size);
3214 HelperAgent::signal_connect_update_candidate_table_page_size (HelperAgentSlotInt *slot)
3216 return m_impl->signal_update_candidate_table_page_size.connect (slot);
3220 * @brief Connect a slot to Helper update candidate item layout signal.
3222 * The prototype of the slot is:
3223 * void update_candidate_item_layout (const HelperAgent *, const std::vector<uint32> &row_items);
3226 HelperAgent::signal_connect_update_candidate_item_layout (HelperAgentSlotUintVector *slot)
3228 return m_impl->signal_update_candidate_item_layout.connect (slot);
3232 * @brief Connect a slot to Helper select associate signal.
3234 * This signal is used to do something when associate is selected.
3236 * The prototype of the slot is:
3237 * void select_associate (const HelperAgent *agent, int ic, const String &uuid, int index);
3240 HelperAgent::signal_connect_select_associate (HelperAgentSlotInt *slot)
3242 return m_impl->signal_select_associate.connect (slot);
3246 * @brief Connect a slot to Helper associate table page up signal.
3248 * This signal is used to do something when associate table is paged up.
3250 * The prototype of the slot is:
3251 * void associate_table_page_up (const HelperAgent *agent, int ic, const String &uuid);
3254 HelperAgent::signal_connect_associate_table_page_up (HelperAgentSlotVoid *slot)
3256 return m_impl->signal_associate_table_page_up.connect (slot);
3260 * @brief Connect a slot to Helper associate table page down signal.
3262 * This signal is used to do something when associate table is paged down.
3264 * The prototype of the slot is:
3265 * void associate_table_page_down (const HelperAgent *agent, int ic, const String &uuid);
3268 HelperAgent::signal_connect_associate_table_page_down (HelperAgentSlotVoid *slot)
3270 return m_impl->signal_associate_table_page_down.connect (slot);
3274 * @brief Connect a slot to Helper update associate table page size signal.
3276 * This signal is used to do something when associate table page size is changed.
3278 * The prototype of the slot is:
3279 * void update_associate_table_page_size (const HelperAgent *, int ic, const String &uuid, int page_size);
3282 HelperAgent::signal_connect_update_associate_table_page_size (HelperAgentSlotInt *slot)
3284 return m_impl->signal_update_associate_table_page_size.connect (slot);
3288 * @brief Connect a slot to Helper turn on log signal.
3290 * This signal is used to turn on Helper ISE debug information.
3292 * The prototype of the slot is:
3293 * void turn_on_log (const HelperAgent *agent, uint32 &on);
3296 HelperAgent::signal_connect_turn_on_log (HelperAgentSlotUintVoid *slot)
3298 return m_impl->signal_turn_on_log.connect (slot);
3302 * @brief Connect a slot to Helper update displayed candidate number signal.
3304 * This signal is used to inform helper ISE displayed candidate number.
3306 * The prototype of the slot is:
3307 * void update_displayed_candidate_number (const HelperAgent *, int ic, const String &uuid, int number);
3310 HelperAgent::signal_connect_update_displayed_candidate_number (HelperAgentSlotInt *slot)
3312 return m_impl->signal_update_displayed_candidate_number.connect (slot);
3316 * @brief Connect a slot to Helper longpress candidate signal.
3318 * This signal is used to do something when candidate is longpress.
3320 * The prototype of the slot is:
3321 * void longpress_candidate (const HelperAgent *agent, int ic, const String &uuid, int index);
3324 HelperAgent::signal_connect_longpress_candidate (HelperAgentSlotInt *slot)
3326 return m_impl->signal_longpress_candidate.connect (slot);
3330 * @brief Connect a slot to Helper show option window.
3332 * This signal is used to do request the ISE to show option window.
3334 * The prototype of the slot is:
3335 * void show_option_window (const HelperAgent *agent, int ic, const String &uuid);
3338 HelperAgent::signal_connect_show_option_window (HelperAgentSlotVoid *slot)
3340 return m_impl->signal_show_option_window.connect (slot);
3344 * @brief Connect a slot to Helper resume option window.
3346 * This signal is used to do request the ISE to resume option window.
3348 * The prototype of the slot is:
3349 * void resume_option_window (const HelperAgent *agent, int ic, const String &uuid);
3352 HelperAgent::signal_connect_resume_option_window (HelperAgentSlotVoid *slot)
3354 return m_impl->signal_resume_option_window.connect (slot);
3358 * @brief Connect a slot to Helper check if the option is available.
3360 * This signal is used to check if the option (setting) is available from Helper ISE.
3362 * The prototype of the slot is:
3363 * void check_option_window (const HelperAgent *agent, uint32 &avail);
3366 HelperAgent::signal_connect_check_option_window (HelperAgentSlotUintVoid *slot)
3368 return m_impl->signal_check_option_window.connect (slot);
3372 * @brief Connect a slot to Helper process unconventional input device event signal.
3374 * This signal is used to send unconventional input device event to Helper ISE.
3376 * The prototype of the slot is:
3377 * void process_input_device_event (const HelperAgent *, uint32 &type, char *data, size_t &size, uint32 &ret);
3380 HelperAgent::signal_connect_process_input_device_event (HelperAgentSlotUintCharSizeUint *slot)
3382 return m_impl->signal_process_input_device_event.connect (slot);
3385 } /* namespace scim */
3388 vi:ts=4:nowrap:ai:expandtab