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"
61 #include <pkgmgr-info.h>
62 #endif // HAVE_PKGMGR_INFO
67 #define LOG_TAG "SCIM_HELPER"
70 //FIXME: remove this definitions
71 #define SHIFT_MODE_OFF 0xffe1
72 #define SHIFT_MODE_ON 0xffe2
73 #define SHIFT_MODE_LOCK 0xffe6
74 #define SHIFT_MODE_ENABLE 0x9fe7
75 #define SHIFT_MODE_DISABLE 0x9fe8
79 typedef Signal3<void, const HelperAgent *, int, const String &>
80 HelperAgentSignalVoid;
82 typedef Signal4<void, const HelperAgent *, int, const String &, const String &>
83 HelperAgentSignalString;
85 typedef Signal4<void, const HelperAgent *, int, const String &, const std::vector<String> &>
86 HelperAgentSignalStringVector;
88 typedef Signal5<void, const HelperAgent *, int, const String &, const String &, const String &>
89 HelperAgentSignalString2;
91 typedef Signal4<void, const HelperAgent *, int, const String &, int>
94 typedef Signal5<void, const HelperAgent *, int, const String &, int, int>
95 HelperAgentSignalIntInt;
97 typedef Signal4<void, const HelperAgent *, int, const String &, const Transaction &>
98 HelperAgentSignalTransaction;
100 typedef Signal4<void, const HelperAgent *, int, const String &, const rectinfo &>
101 HelperAgentSignalRect;
103 typedef Signal2<void, const HelperAgent *, struct rectinfo &>
104 HelperAgentSignalSize;
106 typedef Signal2<void, const HelperAgent *, uint32 &>
107 HelperAgentSignalUintVoid;
109 typedef Signal3<void, const HelperAgent *, int, uint32 &>
110 HelperAgentSignalIntUint;
112 typedef Signal3 <void, const HelperAgent *, char *, size_t &>
113 HelperAgentSignalRawVoid;
115 typedef Signal3 <void, const HelperAgent *, char **, size_t &>
116 HelperAgentSignalGetRawVoid;
118 typedef Signal4 <void, const HelperAgent *, int, char *, size_t &>
119 HelperAgentSignalIntRawVoid;
121 typedef Signal3 <void, const HelperAgent *, int, char **>
122 HelperAgentSignalIntGetStringVoid;
124 typedef Signal2<void, const HelperAgent *, const std::vector<uint32> &>
125 HelperAgentSignalUintVector;
127 typedef Signal2<void, const HelperAgent *, LookupTable &>
128 HelperAgentSignalLookupTable;
130 typedef Signal3<void, const HelperAgent *, KeyEvent &, uint32 &>
131 HelperAgentSignalKeyEventUint;
133 typedef Signal5<void, const HelperAgent *, uint32 &, char *, size_t &, uint32 &>
134 HelperAgentSignalUintCharSizeUint;
136 class HelperAgent::HelperAgentImpl
140 SocketClient socket_active;
149 IMEngineInstancePointer si;
150 ConfigPointer m_config;
151 IMEngineModule engine_module;
153 char* surrounding_text;
154 char* selection_text;
156 int need_update_surrounding_text;
157 int need_update_selection_text;
160 HelperAgentSignalVoid signal_exit;
161 HelperAgentSignalVoid signal_attach_input_context;
162 HelperAgentSignalVoid signal_detach_input_context;
163 HelperAgentSignalVoid signal_reload_config;
164 HelperAgentSignalInt signal_update_screen;
165 HelperAgentSignalIntInt signal_update_spot_location;
166 HelperAgentSignalInt signal_update_cursor_position;
167 HelperAgentSignalInt signal_update_surrounding_text;
168 HelperAgentSignalVoid signal_update_selection;
169 HelperAgentSignalString signal_trigger_property;
170 HelperAgentSignalTransaction signal_process_imengine_event;
171 HelperAgentSignalVoid signal_focus_out;
172 HelperAgentSignalVoid signal_focus_in;
173 HelperAgentSignalIntRawVoid signal_ise_show;
174 HelperAgentSignalVoid signal_ise_hide;
175 HelperAgentSignalVoid signal_candidate_show;
176 HelperAgentSignalVoid signal_candidate_hide;
177 HelperAgentSignalSize signal_get_geometry;
178 HelperAgentSignalUintVoid signal_set_mode;
179 HelperAgentSignalUintVoid signal_set_language;
180 HelperAgentSignalRawVoid signal_set_imdata;
181 HelperAgentSignalGetRawVoid signal_get_imdata;
182 HelperAgentSignalIntGetStringVoid signal_get_language_locale;
183 HelperAgentSignalUintVoid signal_set_return_key_type;
184 HelperAgentSignalUintVoid signal_get_return_key_type;
185 HelperAgentSignalUintVoid signal_set_return_key_disable;
186 HelperAgentSignalUintVoid signal_get_return_key_disable;
187 HelperAgentSignalUintVoid signal_set_layout;
188 HelperAgentSignalUintVoid signal_get_layout;
189 HelperAgentSignalUintVoid signal_set_caps_mode;
190 HelperAgentSignalVoid signal_reset_input_context;
191 HelperAgentSignalIntInt signal_update_candidate_ui;
192 HelperAgentSignalRect signal_update_candidate_geometry;
193 HelperAgentSignalString2 signal_update_keyboard_ise;
194 HelperAgentSignalStringVector signal_update_keyboard_ise_list;
195 HelperAgentSignalVoid signal_candidate_more_window_show;
196 HelperAgentSignalVoid signal_candidate_more_window_hide;
197 HelperAgentSignalLookupTable signal_update_lookup_table;
198 HelperAgentSignalInt signal_select_aux;
199 HelperAgentSignalInt signal_select_candidate;
200 HelperAgentSignalVoid signal_candidate_table_page_up;
201 HelperAgentSignalVoid signal_candidate_table_page_down;
202 HelperAgentSignalInt signal_update_candidate_table_page_size;
203 HelperAgentSignalUintVector signal_update_candidate_item_layout;
204 HelperAgentSignalInt signal_select_associate;
205 HelperAgentSignalVoid signal_associate_table_page_up;
206 HelperAgentSignalVoid signal_associate_table_page_down;
207 HelperAgentSignalInt signal_update_associate_table_page_size;
208 HelperAgentSignalVoid signal_reset_ise_context;
209 HelperAgentSignalUintVoid signal_turn_on_log;
210 HelperAgentSignalInt signal_update_displayed_candidate_number;
211 HelperAgentSignalInt signal_longpress_candidate;
212 HelperAgentSignalKeyEventUint signal_process_key_event;
213 HelperAgentSignalUintVoid signal_set_input_mode;
214 HelperAgentSignalUintVoid signal_set_input_hint;
215 HelperAgentSignalUintVoid signal_update_bidi_direction;
216 HelperAgentSignalVoid signal_show_option_window;
217 HelperAgentSignalUintVoid signal_check_option_window;
218 HelperAgentSignalUintCharSizeUint signal_process_input_device_event;
221 HelperAgentImpl (HelperAgent* thiz) : focused_ic ((uint32) -1), thiz (thiz),
222 surrounding_text (NULL), selection_text (NULL), cursor_pos (0),
223 need_update_surrounding_text (0), need_update_selection_text (0),
227 ~HelperAgentImpl () {
232 if (surrounding_text != NULL)
233 free (surrounding_text);
235 if (selection_text != NULL)
236 free (selection_text);
238 if (engine_module.valid ()) {
239 engine_module.unload ();
243 // Implementation of slot functions
245 slot_show_preedit_string (IMEngineInstanceBase *si)
248 thiz->show_preedit_string (focused_ic, "");
252 slot_show_aux_string (IMEngineInstanceBase *si)
255 thiz->show_aux_string ();
259 slot_show_lookup_table (IMEngineInstanceBase *si)
262 thiz->show_candidate_string ();
266 slot_hide_preedit_string (IMEngineInstanceBase *si)
269 thiz->hide_preedit_string (focused_ic, "");
273 slot_hide_aux_string (IMEngineInstanceBase *si)
276 thiz->hide_aux_string ();
280 slot_hide_lookup_table (IMEngineInstanceBase *si)
283 thiz->hide_candidate_string ();
287 slot_update_preedit_caret (IMEngineInstanceBase *si, int caret)
290 thiz->update_preedit_caret (caret);
294 slot_update_preedit_string (IMEngineInstanceBase *si,
295 const WideString & str,
296 const AttributeList & attrs,
300 thiz->update_preedit_string (-1, "", str, attrs, caret);
304 slot_update_preedit_string_with_commit (IMEngineInstanceBase *si,
305 const WideString & preedit,
306 const WideString & commit,
307 const AttributeList & attrs,
311 thiz->update_preedit_string (-1, "", preedit, commit, attrs, caret);
315 slot_update_aux_string (IMEngineInstanceBase *si,
316 const WideString & str,
317 const AttributeList & attrs)
320 thiz->update_aux_string (utf8_wcstombs(str), attrs);
324 slot_commit_string (IMEngineInstanceBase *si,
325 const WideString & str)
328 thiz->commit_string (-1, "", str);
332 slot_forward_key_event (IMEngineInstanceBase *si,
333 const KeyEvent & key)
336 thiz->forward_key_event (-1, "", key);
340 slot_update_lookup_table (IMEngineInstanceBase *si,
341 const LookupTable & table)
344 thiz->update_candidate_string (table);
348 slot_register_properties (IMEngineInstanceBase *si,
349 const PropertyList & properties)
352 thiz->register_properties (properties);
356 slot_update_property (IMEngineInstanceBase *si,
357 const Property & property)
360 thiz->update_property (property);
364 slot_beep (IMEngineInstanceBase *si)
371 slot_start_helper (IMEngineInstanceBase *si,
372 const String &helper_uuid)
374 LOGW ("deprecated function");
378 slot_stop_helper (IMEngineInstanceBase *si,
379 const String &helper_uuid)
381 LOGW ("deprecated function");
385 slot_send_helper_event (IMEngineInstanceBase *si,
386 const String &helper_uuid,
387 const Transaction &trans)
390 signal_process_imengine_event (thiz, focused_ic, helper_uuid, trans);
394 slot_get_surrounding_text (IMEngineInstanceBase *si,
402 thiz->get_surrounding_text (maxlen_before, maxlen_after, _text, cursor);
403 text = utf8_mbstowcs(_text);
408 slot_delete_surrounding_text (IMEngineInstanceBase *si,
414 thiz->delete_surrounding_text (offset, len);
419 slot_get_selection (IMEngineInstanceBase *si,
424 thiz->get_selection_text (_text);
425 text = utf8_mbstowcs (_text);
430 slot_set_selection (IMEngineInstanceBase *si,
435 thiz->set_selection (start, end);
440 slot_expand_candidate (IMEngineInstanceBase *si)
443 thiz->expand_candidate ();
447 slot_contract_candidate (IMEngineInstanceBase *si)
450 thiz->contract_candidate ();
454 slot_set_candidate_style (IMEngineInstanceBase *si, ISF_CANDIDATE_PORTRAIT_LINE_T portrait_line, ISF_CANDIDATE_MODE_T mode)
457 thiz->set_candidate_style (portrait_line, mode);
461 slot_send_private_command (IMEngineInstanceBase *si,
462 const String &command)
465 thiz->send_private_command (command);
471 si->signal_connect_show_preedit_string (
472 slot (this, &HelperAgent::HelperAgentImpl::slot_show_preedit_string));
473 si->signal_connect_show_aux_string (
474 slot (this, &HelperAgent::HelperAgentImpl::slot_show_aux_string));
475 si->signal_connect_show_lookup_table (
476 slot (this, &HelperAgent::HelperAgentImpl::slot_show_lookup_table));
478 si->signal_connect_hide_preedit_string (
479 slot (this, &HelperAgent::HelperAgentImpl::slot_hide_preedit_string));
480 si->signal_connect_hide_aux_string (
481 slot (this, &HelperAgent::HelperAgentImpl::slot_hide_aux_string));
482 si->signal_connect_hide_lookup_table (
483 slot (this, &HelperAgent::HelperAgentImpl::slot_hide_lookup_table));
485 si->signal_connect_update_preedit_caret (
486 slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_caret));
487 si->signal_connect_update_preedit_string (
488 slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_string));
489 si->signal_connect_update_preedit_string_with_commit (
490 slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_string_with_commit));
492 si->signal_connect_update_aux_string (
493 slot (this, &HelperAgent::HelperAgentImpl::slot_update_aux_string));
494 si->signal_connect_update_lookup_table (
495 slot (this, &HelperAgent::HelperAgentImpl::slot_update_lookup_table));
497 si->signal_connect_commit_string (
498 slot (this, &HelperAgent::HelperAgentImpl::slot_commit_string));
500 si->signal_connect_forward_key_event (
501 slot (this, &HelperAgent::HelperAgentImpl::slot_forward_key_event));
503 si->signal_connect_register_properties (
504 slot (this, &HelperAgent::HelperAgentImpl::slot_register_properties));
506 si->signal_connect_update_property (
507 slot (this, &HelperAgent::HelperAgentImpl::slot_update_property));
509 si->signal_connect_beep (
510 slot (this, &HelperAgent::HelperAgentImpl::slot_beep));
512 si->signal_connect_start_helper (
513 slot (this, &HelperAgent::HelperAgentImpl::slot_start_helper));
515 si->signal_connect_stop_helper (
516 slot (this, &HelperAgent::HelperAgentImpl::slot_stop_helper));
518 si->signal_connect_send_helper_event (
519 slot (this, &HelperAgent::HelperAgentImpl::slot_send_helper_event));
521 si->signal_connect_get_surrounding_text (
522 slot (this, &HelperAgent::HelperAgentImpl::slot_get_surrounding_text));
524 si->signal_connect_delete_surrounding_text (
525 slot (this, &HelperAgent::HelperAgentImpl::slot_delete_surrounding_text));
527 si->signal_connect_get_selection (
528 slot (this, &HelperAgent::HelperAgentImpl::slot_get_selection));
530 si->signal_connect_set_selection (
531 slot (this, &HelperAgent::HelperAgentImpl::slot_set_selection));
533 si->signal_connect_expand_candidate (
534 slot (this, &HelperAgent::HelperAgentImpl::slot_expand_candidate));
535 si->signal_connect_contract_candidate (
536 slot (this, &HelperAgent::HelperAgentImpl::slot_contract_candidate));
538 si->signal_connect_set_candidate_style (
539 slot (this, &HelperAgent::HelperAgentImpl::slot_set_candidate_style));
541 si->signal_connect_send_private_command (
542 slot (this, &HelperAgent::HelperAgentImpl::slot_send_private_command));
545 void process_key_event_done (KeyEvent &key, uint32 ret, uint32 serial) {
546 LOGD ("ret: %d, serial: %d", ret, serial);
547 if (socket_active.is_connected ()) {
549 send.put_command (SCIM_TRANS_CMD_REQUEST);
550 send.put_data (magic_active);
551 send.put_command (ISM_TRANS_CMD_PROCESS_KEY_EVENT_DONE);
554 send.put_data (serial);
555 send.write_to_socket (socket_active, magic_active);
559 void request_ise_hide () {
560 if (socket_active.is_connected ()) {
562 send.put_command (SCIM_TRANS_CMD_REQUEST);
563 send.put_data (magic_active);
564 send.put_command (ISM_TRANS_CMD_REQUEST_ISE_HIDE);
565 send.write_to_socket (socket_active, magic_active);
569 HelperAgentImpl () : magic (0), magic_active (0), timeout (-1), focused_ic ((uint32) -1) { }
572 static MessageQueue message_queue;
574 HelperAgent::HelperAgent ()
575 : m_impl (new HelperAgentImpl (this))
577 message_queue.create();
580 HelperAgent::~HelperAgent ()
582 message_queue.destroy();
587 * @brief Open socket connection to the Panel.
589 * @param info The information of this Helper object.
590 * @param display The display which this Helper object should run on.
592 * @return The connection socket id. -1 means failed to create
596 HelperAgent::open_connection (const HelperInfo &info,
597 const String &display)
599 if (m_impl->socket.is_connected ())
602 SocketAddress address (scim_get_default_panel_socket_address (display));
603 int timeout = m_impl->timeout = scim_get_default_socket_timeout ();
606 if (!address.valid ())
610 std::cerr << " Connecting to PanelAgent server.";
611 ISF_LOG (" Connecting to PanelAgent server.\n");
612 while (!m_impl->socket.connect (address)) {
614 scim_usleep (100000);
616 std::cerr << "m_impl->socket.connect () is failed!!!\n";
617 ISF_LOG ("m_impl->socket.connect () is failed!!!\n");
621 std::cerr << " Connected :" << i << "\n";
622 ISF_LOG (" Connected :%d\n", i);
623 LOGD ("Connection to PanelAgent succeeded, %d\n", i);
625 /* Let's retry 10 times when failed */
626 int open_connection_retries = 0;
627 while (!scim_socket_open_connection (magic,
632 if (++open_connection_retries > 10) {
633 m_impl->socket.close ();
634 std::cerr << "scim_socket_open_connection () is failed!!!\n";
635 ISF_LOG ("scim_socket_open_connection () is failed!!!\n");
636 ISF_SAVE_LOG ("scim_socket_open_connection failed, %d\n", timeout);
641 /* Retry after re-connecting the socket */
642 if (m_impl->socket.is_connected ())
645 /* This time, just retry atmost 2 seconds */
647 while (!m_impl->socket.connect (address) && ++i < 10) {
648 scim_usleep (200000);
653 ISF_LOG ("scim_socket_open_connection () is successful.\n");
654 LOGD ("scim_socket_open_connection successful\n");
656 m_impl->send.clear ();
657 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
658 m_impl->send.put_data (magic);
659 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_REGISTER_HELPER);
660 m_impl->send.put_data (info.uuid);
661 m_impl->send.put_data (info.name);
662 m_impl->send.put_data (info.icon);
663 m_impl->send.put_data (info.description);
664 m_impl->send.put_data (info.option);
666 if (!m_impl->send.write_to_socket (m_impl->socket, magic)) {
667 m_impl->socket.close ();
672 if (m_impl->recv.read_from_socket (m_impl->socket, timeout) &&
673 m_impl->recv.get_command (cmd) && cmd == SCIM_TRANS_CMD_REPLY &&
674 m_impl->recv.get_command (cmd) && cmd == SCIM_TRANS_CMD_OK) {
675 m_impl->magic = magic;
677 while (m_impl->recv.get_command (cmd)) {
679 case SCIM_TRANS_CMD_HELPER_ATTACH_INPUT_CONTEXT:
683 while (m_impl->recv.get_data (ic) && m_impl->recv.get_data (ic_uuid))
684 m_impl->signal_attach_input_context (this, ic, ic_uuid);
687 case SCIM_TRANS_CMD_UPDATE_SCREEN:
690 if (m_impl->recv.get_data (screen))
691 m_impl->signal_update_screen (this, (uint32) -1, String (""), (int) screen);
699 //FIXME: Attaching input context is needed for desktop environment
700 LOGW ("Attach input context and update screen failed");
703 ISF_SAVE_LOG ("Trying connect() with Helper_Active\n");
705 /* connect to the panel agent as the active helper client */
706 if (!m_impl->socket_active.connect (address)) return -1;
707 if (!scim_socket_open_connection (magic,
708 String ("Helper_Active"),
710 m_impl->socket_active,
712 m_impl->socket_active.close ();
713 ISF_SAVE_LOG ("Helper_Active scim_socket_open_connection() failed %d\n", timeout);
717 m_impl->magic_active = magic;
719 m_impl->send.clear ();
720 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
721 m_impl->send.put_data (magic);
722 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_REGISTER_ACTIVE_HELPER);
723 m_impl->send.put_data (info.uuid);
724 m_impl->send.put_data (info.name);
725 m_impl->send.put_data (info.icon);
726 m_impl->send.put_data (info.description);
727 m_impl->send.put_data (info.option);
729 if (!m_impl->send.write_to_socket (m_impl->socket_active, magic)) {
730 ISF_SAVE_LOG ("Helper_Active write_to_socket() failed\n");
731 m_impl->socket_active.close ();
734 m_impl->m_config = ConfigBase::get (false, "socket");
736 return m_impl->socket.get_id ();
740 * @brief Close the socket connection to Panel.
743 HelperAgent::close_connection ()
745 m_impl->socket.close ();
746 m_impl->socket_active.close ();
747 m_impl->send.clear ();
748 m_impl->recv.clear ();
750 m_impl->magic_active = 0;
755 * @brief Get the connection id previously returned by open_connection().
757 * @return the connection id
760 HelperAgent::get_connection_number () const
762 if (m_impl->socket.is_connected ())
763 return m_impl->socket.get_id ();
768 * @brief Check whether this HelperAgent has been connected to a Panel.
770 * Return true when it is connected to panel, otherwise return false.
773 HelperAgent::is_connected () const
775 return m_impl->socket.is_connected ();
779 * @brief Check if there are any events available to be processed.
781 * If it returns true then Helper object should call
782 * HelperAgent::filter_event() to process them.
784 * @return true if there are any events available.
787 HelperAgent::has_pending_event () const
789 if (m_impl->socket.is_connected () && m_impl->socket.wait_for_data (0) > 0)
792 if (message_queue.has_pending_message())
799 * @brief Process the pending events.
801 * This function will emit the corresponding signals according
804 * @return false if the connection is broken, otherwise return true.
807 HelperAgent::filter_event ()
809 if (!m_impl->socket.is_connected () || !m_impl->recv.read_from_socket (m_impl->socket, m_impl->timeout))
812 message_queue.read_from_transaction(m_impl->recv);
814 while (message_queue.has_pending_message()) {
815 MessageItem *message = message_queue.get_pending_message();
816 handle_message(message);
817 message_queue.remove_message(message);
825 * @brief Read messages from socket buffer, and see if there is a message with the given cmd.
827 * @return false if the connection is broken, or no message available with given cmd. Otherwise return true.
830 HelperAgent::wait_for_message(int cmd, int timeout)
832 struct timeval t0 = { 0, 0 };
833 struct timeval t1 = { 0, 0 };
835 gettimeofday(&t0, NULL);
839 if (!m_impl->socket.is_connected() || !m_impl->recv.read_from_socket(m_impl->socket, timeout))
842 message_queue.read_from_transaction(m_impl->recv);
843 if (message_queue.get_pending_message_by_cmd(cmd)) {
847 gettimeofday(&t1, NULL);
848 etime = ((t1.tv_sec * 1000000 + t1.tv_usec) - (t0.tv_sec * 1000000 + t0.tv_usec)) / 1000;
851 } while (etime < timeout);
857 * @brief Process one message that is in our message queue.
859 * This function will emit the corresponding signals according
862 * @param message The message that needs to be handled.
864 * @return false if the connection is broken, otherwise return true.
867 HelperAgent::handle_message (MessageItem *message)
872 int cmd = message->get_command_ref();
873 LOGD ("HelperAgent::cmd = %d\n", cmd);
875 case SCIM_TRANS_CMD_EXIT:
877 MessageItemExit *subclass = static_cast<MessageItemExit*>(message);
878 ISF_SAVE_LOG ("Helper ISE received SCIM_TRANS_CMD_EXIT message\n");
879 m_impl->signal_exit(this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
882 case SCIM_TRANS_CMD_RELOAD_CONFIG:
884 MessageItemReloadConfig *subclass = static_cast<MessageItemReloadConfig*>(message);
885 m_impl->signal_reload_config (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
886 if (!m_impl->m_config.null())
887 m_impl->m_config->ConfigBase::reload();
890 case SCIM_TRANS_CMD_UPDATE_SCREEN:
892 MessageItemUpdateScreen *subclass = static_cast<MessageItemUpdateScreen*>(message);
893 m_impl->signal_update_screen (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
894 subclass->get_screen_ref());
897 case SCIM_TRANS_CMD_UPDATE_SPOT_LOCATION:
899 MessageItemUpdateSpotLocation *subclass = static_cast<MessageItemUpdateSpotLocation*>(message);
900 m_impl->signal_update_spot_location (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
901 subclass->get_x_ref(), subclass->get_y_ref());
904 case ISM_TRANS_CMD_UPDATE_CURSOR_POSITION:
906 MessageItemUpdateCursorPosition *subclass = static_cast<MessageItemUpdateCursorPosition*>(message);
907 m_impl->cursor_pos = subclass->get_cursor_pos_ref();
908 LOGD ("update cursor position %d", subclass->get_cursor_pos_ref());
909 m_impl->signal_update_cursor_position (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
910 subclass->get_cursor_pos_ref());
911 if (!m_impl->si.null ()) m_impl->si->update_cursor_position(subclass->get_cursor_pos_ref());
914 case ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT:
916 MessageItemUpdateSurroundingText *subclass = static_cast<MessageItemUpdateSurroundingText*>(message);
917 if (m_impl->surrounding_text != NULL)
918 free (m_impl->surrounding_text);
919 m_impl->surrounding_text = strdup (subclass->get_text_ref().c_str ());
920 m_impl->cursor_pos = subclass->get_cursor_ref();
921 LOGD ("surrounding text: %s, %d", m_impl->surrounding_text, subclass->get_cursor_ref());
922 while (m_impl->need_update_surrounding_text > 0) {
923 m_impl->need_update_surrounding_text--;
924 m_impl->signal_update_surrounding_text (this, subclass->get_ic_ref(),
925 subclass->get_text_ref(), subclass->get_cursor_ref());
929 case ISM_TRANS_CMD_UPDATE_SELECTION:
931 MessageItemUpdateSelection *subclass = static_cast<MessageItemUpdateSelection*>(message);
932 if (m_impl->selection_text != NULL)
933 free (m_impl->selection_text);
935 m_impl->selection_text = strdup (subclass->get_text_ref().c_str ());
936 LOGD ("selection text: %s", m_impl->selection_text);
938 while (m_impl->need_update_selection_text > 0) {
939 m_impl->need_update_selection_text--;
940 m_impl->signal_update_selection (this, subclass->get_ic_ref(), subclass->get_text_ref());
944 case SCIM_TRANS_CMD_TRIGGER_PROPERTY:
946 MessageItemTriggerProperty *subclass = static_cast<MessageItemTriggerProperty*>(message);
947 m_impl->signal_trigger_property (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
948 subclass->get_property_ref());
949 if (!m_impl->si.null ()) m_impl->si->trigger_property(subclass->get_property_ref());
952 case SCIM_TRANS_CMD_HELPER_PROCESS_IMENGINE_EVENT:
954 MessageItemHelperProcessImengineEvent *subclass = static_cast<MessageItemHelperProcessImengineEvent*>(message);
955 m_impl->signal_process_imengine_event (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
956 subclass->get_transaction_ref());
959 case SCIM_TRANS_CMD_HELPER_ATTACH_INPUT_CONTEXT:
961 MessageItemHelperAttachInputContext *subclass = static_cast<MessageItemHelperAttachInputContext*>(message);
962 m_impl->signal_attach_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
965 case SCIM_TRANS_CMD_HELPER_DETACH_INPUT_CONTEXT:
967 MessageItemHelperDetachInputContext *subclass = static_cast<MessageItemHelperDetachInputContext*>(message);
968 m_impl->signal_detach_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
971 case SCIM_TRANS_CMD_FOCUS_OUT:
973 MessageItemFocusOut *subclass = static_cast<MessageItemFocusOut*>(message);
974 m_impl->signal_focus_out (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
975 m_impl->focused_ic = (uint32) -1;
976 if (!m_impl->si.null ()) m_impl->si->focus_out();
979 case SCIM_TRANS_CMD_FOCUS_IN:
981 MessageItemFocusIn *subclass = static_cast<MessageItemFocusIn*>(message);
982 m_impl->signal_focus_in (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
983 m_impl->focused_ic = subclass->get_ic_ref();
984 if (!m_impl->si.null ()) m_impl->si->focus_in();
987 case ISM_TRANS_CMD_SHOW_ISE_PANEL:
989 MessageItemShowISEPanel *subclass = static_cast<MessageItemShowISEPanel*>(message);
990 LOGD ("Helper ISE received ISM_TRANS_CMD_SHOW_ISE_PANEL message\n");
992 m_impl->signal_ise_show (this, subclass->get_ic_ref(), *(subclass->get_data_ptr()),
993 subclass->get_len_ref());
996 case ISM_TRANS_CMD_HIDE_ISE_PANEL:
998 MessageItemHideISEPanel *subclass = static_cast<MessageItemHideISEPanel*>(message);
999 LOGD ("Helper ISE received ISM_TRANS_CMD_HIDE_ISE_PANEL message\n");
1000 m_impl->signal_ise_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1003 case ISM_TRANS_CMD_GET_ACTIVE_ISE_GEOMETRY:
1005 struct rectinfo info = {0, 0, 0, 0};
1006 m_impl->signal_get_geometry (this, info);
1007 m_impl->send.clear ();
1008 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1009 m_impl->send.put_data (info.pos_x);
1010 m_impl->send.put_data (info.pos_y);
1011 m_impl->send.put_data (info.width);
1012 m_impl->send.put_data (info.height);
1013 m_impl->send.write_to_socket (m_impl->socket);
1016 case ISM_TRANS_CMD_SET_ISE_MODE:
1018 MessageItemSetISEMode *subclass = static_cast<MessageItemSetISEMode*>(message);
1019 m_impl->signal_set_mode (this, subclass->get_mode_ref());
1022 case ISM_TRANS_CMD_SET_ISE_LANGUAGE:
1024 MessageItemSetISELanguage *subclass = static_cast<MessageItemSetISELanguage*>(message);
1025 m_impl->signal_set_language (this, subclass->get_language_ref());
1028 case ISM_TRANS_CMD_SET_ISE_IMDATA:
1030 MessageItemSetISEImData *subclass = static_cast<MessageItemSetISEImData*>(message);
1031 m_impl->signal_set_imdata (this, *(subclass->get_imdata_ptr()), subclass->get_len_ref());
1032 if (!m_impl->si.null ()) m_impl->si->set_imdata(*(subclass->get_imdata_ptr()),
1033 subclass->get_len_ref());
1036 case ISM_TRANS_CMD_GET_ISE_IMDATA:
1041 m_impl->signal_get_imdata (this, &buf, len);
1042 LOGD ("send ise imdata len = %d", len);
1043 m_impl->send.clear ();
1044 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1045 m_impl->send.put_data (buf, len);
1046 m_impl->send.write_to_socket (m_impl->socket);
1051 case ISM_TRANS_CMD_GET_ISE_LANGUAGE_LOCALE:
1053 MessageItemGetISELanguageLocale *subclass = static_cast<MessageItemGetISELanguageLocale*>(message);
1055 m_impl->signal_get_language_locale (this, subclass->get_ic_ref(), &buf);
1056 m_impl->send.clear ();
1057 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1059 m_impl->send.put_data (buf, strlen (buf));
1060 m_impl->send.write_to_socket (m_impl->socket);
1065 case ISM_TRANS_CMD_SET_RETURN_KEY_TYPE:
1067 MessageItemSetReturnKeyType *subclass = static_cast<MessageItemSetReturnKeyType*>(message);
1068 m_impl->signal_set_return_key_type (this, subclass->get_type_ref());
1071 case ISM_TRANS_CMD_GET_RETURN_KEY_TYPE:
1074 m_impl->signal_get_return_key_type (this, type);
1075 m_impl->send.clear ();
1076 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1077 m_impl->send.put_data (type);
1078 m_impl->send.write_to_socket (m_impl->socket);
1081 case ISM_TRANS_CMD_SET_RETURN_KEY_DISABLE:
1083 MessageItemSetReturnKeyDisable *subclass = static_cast<MessageItemSetReturnKeyDisable*>(message);
1084 m_impl->signal_set_return_key_disable (this, subclass->get_disabled_ref());
1087 case ISM_TRANS_CMD_GET_RETURN_KEY_DISABLE:
1089 uint32 disabled = 0;
1090 m_impl->signal_get_return_key_type (this, disabled);
1091 m_impl->send.clear ();
1092 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1093 m_impl->send.put_data (disabled);
1094 m_impl->send.write_to_socket (m_impl->socket);
1097 case SCIM_TRANS_CMD_PROCESS_KEY_EVENT:
1099 MessageItemProcessKeyEvent *subclass = static_cast<MessageItemProcessKeyEvent*>(message);
1101 m_impl->signal_process_key_event(this, subclass->get_key_ref(), ret);
1103 if (!m_impl->si.null ())
1105 ret = m_impl->si->process_key_event (subclass->get_key_ref());
1106 LOGD("imengine(%s) process key %d return %d", m_impl->si->get_factory_uuid().c_str(),
1107 subclass->get_key_ref().code, ret);
1109 m_impl->process_key_event_done (subclass->get_key_ref(), ret, subclass->get_serial_ref());
1112 case ISM_TRANS_CMD_SET_LAYOUT:
1114 MessageItemSetLayout *subclass = static_cast<MessageItemSetLayout*>(message);
1115 m_impl->layout = subclass->get_layout_ref();
1116 m_impl->signal_set_layout (this, subclass->get_layout_ref());
1117 if (!m_impl->si.null ()) m_impl->si->set_layout(subclass->get_layout_ref());
1120 case ISM_TRANS_CMD_GET_LAYOUT:
1124 m_impl->signal_get_layout (this, layout);
1125 m_impl->send.clear ();
1126 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1127 m_impl->send.put_data (layout);
1128 m_impl->send.write_to_socket (m_impl->socket);
1131 case ISM_TRANS_CMD_SET_INPUT_MODE:
1133 MessageItemSetInputMode *subclass = static_cast<MessageItemSetInputMode*>(message);
1134 m_impl->signal_set_input_mode (this, subclass->get_input_mode_ref());
1137 case ISM_TRANS_CMD_SET_CAPS_MODE:
1139 MessageItemSetCapsMode *subclass = static_cast<MessageItemSetCapsMode*>(message);
1140 m_impl->signal_set_caps_mode (this, subclass->get_mode_ref());
1143 case SCIM_TRANS_CMD_PANEL_RESET_INPUT_CONTEXT:
1145 MessageItemPanelResetInputContext *subclass = static_cast<MessageItemPanelResetInputContext*>(message);
1146 m_impl->signal_reset_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1147 if (!m_impl->si.null ()) m_impl->si->reset();
1150 case ISM_TRANS_CMD_UPDATE_CANDIDATE_UI:
1152 MessageItemUpdateCandidateUI *subclass = static_cast<MessageItemUpdateCandidateUI*>(message);
1153 m_impl->signal_update_candidate_ui (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1154 subclass->get_style_ref(), subclass->get_mode_ref());
1157 case ISM_TRANS_CMD_UPDATE_CANDIDATE_GEOMETRY:
1159 MessageItemUpdateCandidateGeometry *subclass = static_cast<MessageItemUpdateCandidateGeometry*>(message);
1160 m_impl->signal_update_candidate_geometry (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1161 subclass->get_rectinfo_ref());
1164 case ISM_TRANS_CMD_UPDATE_KEYBOARD_ISE:
1166 MessageItemUpdateKeyboardISE *subclass = static_cast<MessageItemUpdateKeyboardISE*>(message);
1167 m_impl->signal_update_keyboard_ise (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1168 subclass->get_name_ref(), subclass->get_uuid_ref());
1171 case ISM_TRANS_CMD_UPDATE_KEYBOARD_ISE_LIST:
1173 MessageItemUpdateKeyboardISEList *subclass = static_cast<MessageItemUpdateKeyboardISEList*>(message);
1174 m_impl->signal_update_keyboard_ise_list (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1175 subclass->get_list_ref());
1178 case ISM_TRANS_CMD_CANDIDATE_MORE_WINDOW_SHOW:
1180 MessageItemCandidateMoreWindowShow *subclass = static_cast<MessageItemCandidateMoreWindowShow*>(message);
1181 m_impl->signal_candidate_more_window_show (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1182 if (!m_impl->si.null ()) m_impl->si->candidate_more_window_show();
1185 case ISM_TRANS_CMD_CANDIDATE_MORE_WINDOW_HIDE:
1187 MessageItemCandidateMoreWindowHide *subclass = static_cast<MessageItemCandidateMoreWindowHide*>(message);
1188 m_impl->signal_candidate_more_window_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1189 if (!m_impl->si.null ()) m_impl->si->candidate_more_window_hide();
1192 case ISM_TRANS_CMD_SELECT_AUX:
1194 MessageItemSelectAux *subclass = static_cast<MessageItemSelectAux*>(message);
1195 m_impl->signal_select_aux (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1196 subclass->get_item_ref());
1197 if (!m_impl->si.null ()) m_impl->si->select_aux(subclass->get_item_ref());
1200 case SCIM_TRANS_CMD_SELECT_CANDIDATE: //FIXME:remove if useless
1202 MessageItemSelectCandidate *subclass = static_cast<MessageItemSelectCandidate*>(message);
1203 m_impl->signal_select_candidate (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1204 subclass->get_item_ref());
1205 if (!m_impl->si.null ()) m_impl->si->select_candidate(subclass->get_item_ref());
1208 case SCIM_TRANS_CMD_LOOKUP_TABLE_PAGE_UP: //FIXME:remove if useless
1210 MessageItemLookupTablePageUp *subclass = static_cast<MessageItemLookupTablePageUp*>(message);
1211 m_impl->signal_candidate_table_page_up (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1212 if (!m_impl->si.null ()) m_impl->si->lookup_table_page_up();
1215 case SCIM_TRANS_CMD_LOOKUP_TABLE_PAGE_DOWN: //FIXME:remove if useless
1217 MessageItemLookupTablePageDown *subclass = static_cast<MessageItemLookupTablePageDown*>(message);
1218 m_impl->signal_candidate_table_page_down (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1219 if (!m_impl->si.null ()) m_impl->si->lookup_table_page_down();
1222 case SCIM_TRANS_CMD_UPDATE_LOOKUP_TABLE_PAGE_SIZE:
1224 MessageItemUpdateLookupTablePageSize *subclass = static_cast<MessageItemUpdateLookupTablePageSize*>(message);
1225 m_impl->signal_update_candidate_table_page_size (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1226 subclass->get_size_ref());
1227 if (!m_impl->si.null ()) m_impl->si->update_lookup_table_page_size(subclass->get_size_ref());
1230 case ISM_TRANS_CMD_CANDIDATE_SHOW: //FIXME:remove if useless
1232 MessageItemCandidateShow *subclass = static_cast<MessageItemCandidateShow*>(message);
1233 m_impl->signal_candidate_show (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1236 case ISM_TRANS_CMD_CANDIDATE_HIDE: //FIXME:remove if useless
1238 MessageItemCandidateHide *subclass = static_cast<MessageItemCandidateHide*>(message);
1239 m_impl->signal_candidate_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1242 case ISM_TRANS_CMD_UPDATE_LOOKUP_TABLE: //FIXME:remove if useless
1244 MessageItemUpdateLookupTable *subclass = static_cast<MessageItemUpdateLookupTable*>(message);
1245 m_impl->signal_update_lookup_table (this, subclass->get_candidate_table_ref());
1248 case ISM_TRANS_CMD_UPDATE_CANDIDATE_ITEM_LAYOUT:
1250 MessageItemUpdateCandidateItemLayout *subclass = static_cast<MessageItemUpdateCandidateItemLayout*>(message);
1251 m_impl->signal_update_candidate_item_layout (this, subclass->get_row_items_ref());
1252 if (!m_impl->si.null ()) m_impl->si->update_candidate_item_layout(subclass->get_row_items_ref());
1255 case ISM_TRANS_CMD_SELECT_ASSOCIATE:
1257 MessageItemSelectAssociate *subclass = static_cast<MessageItemSelectAssociate*>(message);
1258 m_impl->signal_select_associate (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1259 subclass->get_item_ref());
1262 case ISM_TRANS_CMD_ASSOCIATE_TABLE_PAGE_UP:
1264 MessageItemAssociateTablePageUp *subclass = static_cast<MessageItemAssociateTablePageUp*>(message);
1265 m_impl->signal_associate_table_page_up (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1268 case ISM_TRANS_CMD_ASSOCIATE_TABLE_PAGE_DOWN:
1270 MessageItemAssociateTablePageDown *subclass = static_cast<MessageItemAssociateTablePageDown*>(message);
1271 m_impl->signal_associate_table_page_down (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1274 case ISM_TRANS_CMD_UPDATE_ASSOCIATE_TABLE_PAGE_SIZE:
1276 MessageItemUpdateAssociateTablePageSize *subclass = static_cast<MessageItemUpdateAssociateTablePageSize*>(message);
1277 m_impl->signal_update_associate_table_page_size (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1278 subclass->get_size_ref());
1281 case ISM_TRANS_CMD_RESET_ISE_CONTEXT:
1283 MessageItemResetISEContext *subclass = static_cast<MessageItemResetISEContext*>(message);
1284 m_impl->signal_reset_ise_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1285 m_impl->signal_reset_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1286 if (!m_impl->si.null ()) m_impl->si->reset();
1289 case ISM_TRANS_CMD_TURN_ON_LOG:
1291 MessageItemTurnOnLog *subclass = static_cast<MessageItemTurnOnLog*>(message);
1292 m_impl->signal_turn_on_log (this, subclass->get_state_ref());
1295 case ISM_TRANS_CMD_UPDATE_DISPLAYED_CANDIDATE:
1297 MessageItemUpdateDisplayedCandidate *subclass = static_cast<MessageItemUpdateDisplayedCandidate*>(message);
1298 m_impl->signal_update_displayed_candidate_number (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1299 subclass->get_size_ref());
1300 if (!m_impl->si.null ()) m_impl->si->update_displayed_candidate_number(subclass->get_size_ref());
1303 case ISM_TRANS_CMD_LONGPRESS_CANDIDATE:
1305 MessageItemLongpressCandidate *subclass = static_cast<MessageItemLongpressCandidate*>(message);
1306 m_impl->signal_longpress_candidate (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1307 subclass->get_index_ref());
1308 if (!m_impl->si.null ()) m_impl->si->longpress_candidate(subclass->get_index_ref());
1311 case ISM_TRANS_CMD_SET_INPUT_HINT:
1313 MessageItemSetInputHint *subclass = static_cast<MessageItemSetInputHint*>(message);
1314 m_impl->signal_set_input_hint (this, subclass->get_input_hint_ref());
1315 if (!m_impl->si.null ()) m_impl->si->set_input_hint(subclass->get_input_hint_ref());
1318 case ISM_TRANS_CMD_UPDATE_BIDI_DIRECTION:
1320 MessageItemUpdateBidiDirection *subclass = static_cast<MessageItemUpdateBidiDirection*>(message);
1321 m_impl->signal_update_bidi_direction (this, subclass->get_bidi_direction());
1322 if (!m_impl->si.null ()) m_impl->si->update_bidi_direction(subclass->get_bidi_direction());
1325 case ISM_TRANS_CMD_SHOW_ISE_OPTION_WINDOW:
1327 MessageItemShowISEOptionWindow *subclass = static_cast<MessageItemShowISEOptionWindow*>(message);
1328 m_impl->signal_show_option_window (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1331 case ISM_TRANS_CMD_CHECK_OPTION_WINDOW:
1334 m_impl->signal_check_option_window (this, avail);
1335 m_impl->send.clear ();
1336 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1337 m_impl->send.put_data (avail);
1338 m_impl->send.write_to_socket (m_impl->socket);
1341 case ISM_TRANS_CMD_PROCESS_INPUT_DEVICE_EVENT:
1343 MessageItemProcessInputDeviceEvent *subclass = static_cast<MessageItemProcessInputDeviceEvent*>(message);
1345 m_impl->signal_process_input_device_event(this,
1346 subclass->get_type_ref(), *(subclass->get_data_ptr()), subclass->get_len_ref(), ret);
1347 m_impl->send.clear();
1348 m_impl->send.put_command(SCIM_TRANS_CMD_REPLY);
1349 m_impl->send.put_data(ret);
1350 m_impl->send.write_to_socket(m_impl->socket);
1353 case SCIM_TRANS_CMD_SET_AUTOCAPITAL_TYPE:
1355 MessageItemSetAutocapitalType *subclass = static_cast<MessageItemSetAutocapitalType*>(message);
1356 if (!m_impl->si.null ()) m_impl->si->set_autocapital_type(subclass->get_auto_capital_type_ref());
1366 * @brief Request SCIM to reload all configuration.
1368 * This function should only by used by Setup Helper to request
1369 * scim's reloading the configuration.
1372 HelperAgent::reload_config () const
1375 #if 0 //reload config message only send by socketconfig client
1376 if (m_impl->socket_active.is_connected ()) {
1377 m_impl->send.clear ();
1378 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1379 m_impl->send.put_data (m_impl->magic_active);
1380 m_impl->send.put_command (SCIM_TRANS_CMD_RELOAD_CONFIG);
1381 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1384 if (!m_impl->m_config.null())
1385 m_impl->m_config->reload();
1389 * @brief Register some properties into Panel.
1391 * This function send the request to Panel to register a list
1394 * @param properties The list of Properties to be registered into Panel.
1396 * @sa scim::Property.
1399 HelperAgent::register_properties (const PropertyList &properties) const
1402 if (m_impl->socket_active.is_connected ()) {
1403 m_impl->send.clear ();
1404 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1405 m_impl->send.put_data (m_impl->magic_active);
1406 m_impl->send.put_command (SCIM_TRANS_CMD_REGISTER_PROPERTIES);
1407 m_impl->send.put_data (properties);
1408 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1413 * @brief Update a registered property.
1415 * @param property The property to be updated.
1418 HelperAgent::update_property (const Property &property) const
1421 if (m_impl->socket_active.is_connected ()) {
1422 m_impl->send.clear ();
1423 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1424 m_impl->send.put_data (m_impl->magic_active);
1425 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PROPERTY);
1426 m_impl->send.put_data (property);
1427 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1432 * @brief Send a set of events to an IMEngineInstance.
1434 * All events should be put into a Transaction.
1435 * And the events can only be received by one IMEngineInstance object.
1437 * @param ic The handle of the Input Context to receive the events.
1438 * @param ic_uuid The UUID of the Input Context.
1439 * @param trans The Transaction object holds the events.
1442 HelperAgent::send_imengine_event (int ic,
1443 const String &ic_uuid,
1444 const Transaction &trans) const
1447 //remove if not necessary
1449 if (m_impl->socket_active.is_connected ()) {
1450 m_impl->send.clear ();
1451 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1452 m_impl->send.put_data (m_impl->magic_active);
1453 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_SEND_IMENGINE_EVENT);
1454 m_impl->send.put_data ((uint32)ic);
1455 m_impl->send.put_data (ic_uuid);
1456 m_impl->send.put_data (trans);
1457 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1460 if (!m_impl->si.null ()) m_impl->si->process_helper_event (ic_uuid, trans);
1464 * @brief Send a KeyEvent to an IMEngineInstance.
1466 * @param ic The handle of the IMEngineInstance to receive the event.
1467 * -1 means the currently focused IMEngineInstance.
1468 * @param ic_uuid The UUID of the IMEngineInstance. Empty means don't match.
1469 * @param key The KeyEvent to be sent.
1472 HelperAgent::send_key_event (int ic,
1473 const String &ic_uuid,
1474 const KeyEvent &key) const
1478 //FIXME: remove shift_mode_off, shift_mode_on, shift_mode_lock from ISE side
1479 if (key.code == SHIFT_MODE_OFF ||
1480 key.code == SHIFT_MODE_ON ||
1481 key.code == SHIFT_MODE_LOCK ||
1482 key.code == SHIFT_MODE_ENABLE ||
1483 key.code == SHIFT_MODE_DISABLE) {
1484 LOGW("FIXME ignore shift codes");
1490 #if ENABLE_GRAB_KEYBOARD
1491 if (!m_impl->si.null ()) {
1493 if (key.code <= 0x7F ||
1494 (key.code >= SCIM_KEY_BackSpace && key.code <= SCIM_KEY_Delete) ||
1495 (key.code >= SCIM_KEY_Home && key.code <= SCIM_KEY_Hyper_R)) {
1496 // ascii code and function keys
1502 if (ret && (!m_impl->si.null ())) {
1504 ret = m_impl->si->process_key_event (key);
1505 LOGD ("imengine(%s) process key %d return %d", m_impl->si->get_factory_uuid().c_str(), key.code, ret);
1508 if (ret == false && m_impl->socket_active.is_connected ()) {
1509 m_impl->send.clear ();
1510 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1511 m_impl->send.put_data (m_impl->magic_active);
1512 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_SEND_KEY_EVENT);
1514 m_impl->send.put_data (m_impl->focused_ic);
1516 m_impl->send.put_data ((uint32)ic);
1518 m_impl->send.put_data (ic_uuid);
1519 m_impl->send.put_data (key);
1520 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1525 * @brief Forward a KeyEvent to client application directly.
1527 * @param ic The handle of the client Input Context to receive the event.
1528 * -1 means the currently focused Input Context.
1529 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1530 * Empty means don't match.
1531 * @param key The KeyEvent to be forwarded.
1534 HelperAgent::forward_key_event (int ic,
1535 const String &ic_uuid,
1536 const KeyEvent &key) const
1539 if (m_impl->socket_active.is_connected ()) {
1540 m_impl->send.clear ();
1541 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1542 m_impl->send.put_data (m_impl->magic_active);
1543 m_impl->send.put_command (SCIM_TRANS_CMD_FORWARD_KEY_EVENT);
1545 m_impl->send.put_data (m_impl->focused_ic);
1547 m_impl->send.put_data ((uint32)ic);
1549 m_impl->send.put_data (ic_uuid);
1550 m_impl->send.put_data (key);
1551 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1556 * @brief Commit a WideString to client application directly.
1558 * @param ic The handle of the client Input Context to receive the WideString.
1559 * -1 means the currently focused Input Context.
1560 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1561 * Empty means don't match.
1562 * @param wstr The WideString to be committed.
1565 HelperAgent::commit_string (int ic,
1566 const String &ic_uuid,
1567 const WideString &wstr) const
1570 if (m_impl->socket_active.is_connected ()) {
1571 m_impl->send.clear ();
1572 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1573 m_impl->send.put_data (m_impl->magic_active);
1574 m_impl->send.put_command (SCIM_TRANS_CMD_COMMIT_STRING);
1576 m_impl->send.put_data (m_impl->focused_ic);
1578 m_impl->send.put_data ((uint32)ic);
1580 m_impl->send.put_data (ic_uuid);
1581 m_impl->send.put_data (wstr);
1582 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1587 HelperAgent::commit_string (int ic,
1588 const String &ic_uuid,
1593 if (m_impl->socket_active.is_connected ()) {
1594 m_impl->send.clear ();
1595 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1596 m_impl->send.put_data (m_impl->magic_active);
1597 m_impl->send.put_command (SCIM_TRANS_CMD_COMMIT_STRING);
1599 m_impl->send.put_data (m_impl->focused_ic);
1601 m_impl->send.put_data ((uint32)ic);
1603 m_impl->send.put_data (ic_uuid);
1604 m_impl->send.put_dataw (buf, buflen);
1605 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1610 * @brief Request to show preedit string.
1612 * @param ic The handle of the client Input Context to receive the request.
1613 * -1 means the currently focused Input Context.
1614 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1615 * Empty means don't match.
1618 HelperAgent::show_preedit_string (int ic,
1619 const String &ic_uuid) const
1623 if (m_impl->socket_active.is_connected ()) {
1624 m_impl->send.clear ();
1625 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1626 m_impl->send.put_data (m_impl->magic_active);
1627 m_impl->send.put_command (SCIM_TRANS_CMD_SHOW_PREEDIT_STRING);
1628 m_impl->send.put_data ((uint32)ic);
1629 m_impl->send.put_data (ic_uuid);
1630 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1635 * @brief Request to show aux string.
1638 HelperAgent::show_aux_string (void) const
1642 if (m_impl->socket_active.is_connected ()) {
1643 m_impl->send.clear ();
1644 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1645 m_impl->send.put_data (m_impl->magic_active);
1646 m_impl->send.put_command (SCIM_TRANS_CMD_SHOW_AUX_STRING);
1647 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1652 * @brief Request to show candidate string.
1655 HelperAgent::show_candidate_string (void) const
1659 if (m_impl->socket_active.is_connected ()) {
1660 m_impl->send.clear ();
1661 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1662 m_impl->send.put_data (m_impl->magic_active);
1663 m_impl->send.put_command (SCIM_TRANS_CMD_SHOW_LOOKUP_TABLE);
1664 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1669 * @brief Request to show associate string.
1672 HelperAgent::show_associate_string (void) const
1675 if (m_impl->socket_active.is_connected ()) {
1676 m_impl->send.clear ();
1677 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1678 m_impl->send.put_data (m_impl->magic_active);
1679 m_impl->send.put_command (ISM_TRANS_CMD_SHOW_ASSOCIATE_TABLE);
1680 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1685 * @brief Request to hide preedit string.
1687 * @param ic The handle of the client Input Context to receive the request.
1688 * -1 means the currently focused Input Context.
1689 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1690 * Empty means don't match.
1693 HelperAgent::hide_preedit_string (int ic,
1694 const String &ic_uuid) const
1698 if (m_impl->socket_active.is_connected ()) {
1699 m_impl->send.clear ();
1700 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1701 m_impl->send.put_data (m_impl->magic_active);
1702 m_impl->send.put_command (SCIM_TRANS_CMD_HIDE_PREEDIT_STRING);
1703 m_impl->send.put_data ((uint32)ic);
1704 m_impl->send.put_data (ic_uuid);
1705 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1710 * @brief Request to hide aux string.
1713 HelperAgent::hide_aux_string (void) const
1716 if (m_impl->socket_active.is_connected ()) {
1717 m_impl->send.clear ();
1718 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1719 m_impl->send.put_data (m_impl->magic_active);
1720 m_impl->send.put_command (SCIM_TRANS_CMD_HIDE_AUX_STRING);
1721 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1726 * @brief Request to hide candidate string.
1729 HelperAgent::hide_candidate_string (void) const
1732 if (m_impl->socket_active.is_connected ()) {
1733 m_impl->send.clear ();
1734 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1735 m_impl->send.put_data (m_impl->magic_active);
1736 m_impl->send.put_command (SCIM_TRANS_CMD_HIDE_LOOKUP_TABLE);
1737 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1742 * @brief Request to hide associate string.
1745 HelperAgent::hide_associate_string (void) const
1748 if (m_impl->socket_active.is_connected ()) {
1749 m_impl->send.clear ();
1750 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1751 m_impl->send.put_data (m_impl->magic_active);
1752 m_impl->send.put_command (ISM_TRANS_CMD_HIDE_ASSOCIATE_TABLE);
1753 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1758 * @brief Update a new WideString for preedit.
1760 * @param ic The handle of the client Input Context to receive the WideString.
1761 * -1 means the currently focused Input Context.
1762 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1763 * Empty means don't match.
1764 * @param str The WideString to be updated.
1765 * @param attrs The attribute list for preedit string.
1768 HelperAgent::update_preedit_string (int ic,
1769 const String &ic_uuid,
1770 const WideString &str,
1771 const AttributeList &attrs) const
1774 update_preedit_string (ic, ic_uuid, str, str, attrs, -1);
1778 HelperAgent::update_preedit_string (int ic,
1779 const String &ic_uuid,
1782 const AttributeList &attrs) const
1785 update_preedit_string (ic, ic_uuid, buf, buflen, attrs, -1);
1789 * @brief Update a new WideString for preedit.
1791 * @param ic The handle of the client Input Context to receive the WideString.
1792 * -1 means the currently focused Input Context.
1793 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1794 * Empty means don't match.
1795 * @param str The WideString to be updated.
1796 * @param attrs The attribute list for preedit string.
1797 * @param caret The caret position in preedit string.
1800 HelperAgent::update_preedit_string (int ic,
1801 const String &ic_uuid,
1802 const WideString &wstr,
1803 const AttributeList &attrs,
1807 update_preedit_string (ic, ic_uuid, wstr, wstr, attrs, caret);
1811 HelperAgent::update_preedit_string (int ic,
1812 const String &ic_uuid,
1815 const AttributeList &attrs,
1820 if (m_impl->socket_active.is_connected ()) {
1821 m_impl->send.clear ();
1822 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1823 m_impl->send.put_data (m_impl->magic_active);
1824 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING);
1825 m_impl->send.put_data ((uint32)ic);
1826 m_impl->send.put_data (ic_uuid);
1827 m_impl->send.put_dataw (buf, buflen);
1828 m_impl->send.put_dataw (buf, buflen);
1829 m_impl->send.put_data (attrs);
1830 m_impl->send.put_data (caret);
1831 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1836 HelperAgent::update_preedit_string (int ic,
1837 const String &ic_uuid,
1838 const WideString &preedit,
1839 const WideString &commit,
1840 const AttributeList &attrs,
1844 if (m_impl->socket_active.is_connected ()) {
1845 m_impl->send.clear ();
1846 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1847 m_impl->send.put_data (m_impl->magic_active);
1848 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING);
1849 m_impl->send.put_data ((uint32)ic);
1850 m_impl->send.put_data (ic_uuid);
1851 m_impl->send.put_data (preedit);
1852 m_impl->send.put_data (commit);
1853 m_impl->send.put_data (attrs);
1854 m_impl->send.put_data (caret);
1855 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1860 * @brief Update the preedit caret position in the preedit string.
1862 * @param caret - the new position of the preedit caret.
1865 HelperAgent::update_preedit_caret (int caret) const
1869 if (m_impl->socket_active.is_connected ()) {
1870 m_impl->send.clear ();
1871 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1872 m_impl->send.put_data (m_impl->magic_active);
1873 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_CARET);
1874 m_impl->send.put_data ((uint32)caret);
1875 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1880 * @brief Update a new string for aux.
1882 * @param str The string to be updated.
1883 * @param attrs The attribute list for aux string.
1886 HelperAgent::update_aux_string (const String &str,
1887 const AttributeList &attrs) const
1890 if (m_impl->socket_active.is_connected ()) {
1891 m_impl->send.clear ();
1892 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1893 m_impl->send.put_data (m_impl->magic_active);
1894 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_AUX_STRING);
1895 m_impl->send.put_data (str);
1896 m_impl->send.put_data (attrs);
1897 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1902 * @brief Request to update candidate.
1904 * @param table The lookup table for candidate.
1907 HelperAgent::update_candidate_string (const LookupTable &table) 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_LOOKUP_TABLE);
1915 m_impl->send.put_data (table);
1916 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1921 * @brief Request to update associate.
1923 * @param table The lookup table for associate.
1926 HelperAgent::update_associate_string (const LookupTable &table) const
1929 if (m_impl->socket_active.is_connected ()) {
1930 m_impl->send.clear ();
1931 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1932 m_impl->send.put_data (m_impl->magic_active);
1933 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ASSOCIATE_TABLE);
1934 m_impl->send.put_data (table);
1935 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1940 * @brief When the input context of ISE is changed,
1941 * ISE can call this function to notify application
1943 * @param type type of event.
1944 * @param value value of event.
1947 HelperAgent::update_input_context (uint32 type, uint32 value) const
1950 if (m_impl->socket_active.is_connected ()) {
1951 m_impl->send.clear ();
1952 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1953 m_impl->send.put_data (m_impl->magic_active);
1954 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ISE_INPUT_CONTEXT);
1955 m_impl->send.put_data (type);
1956 m_impl->send.put_data (value);
1957 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1962 * @brief Request to get surrounding text asynchronously.
1964 * @param uuid The helper ISE UUID.
1965 * @param maxlen_before The max length of before.
1966 * @param maxlen_after The max length of after.
1969 HelperAgent::get_surrounding_text (const String &uuid, int maxlen_before, int maxlen_after) const
1972 if (m_impl->socket_active.is_connected () && (m_impl->need_update_surrounding_text == 0)) {
1973 m_impl->send.clear ();
1974 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1975 m_impl->send.put_data (m_impl->magic_active);
1976 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SURROUNDING_TEXT);
1977 m_impl->send.put_data (uuid);
1978 m_impl->send.put_data (maxlen_before);
1979 m_impl->send.put_data (maxlen_after);
1980 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1982 m_impl->need_update_surrounding_text++;
1986 * @brief Request to get surrounding text synchronously.
1988 * @param uuid The helper ISE UUID.
1989 * @param maxlen_before The max length of before.
1990 * @param maxlen_after The max length of after.
1991 * @param text The surrounding text.
1992 * @param cursor The cursor position.
1995 HelperAgent::get_surrounding_text (int maxlen_before, int maxlen_after, String &text, int &cursor)
1999 if (!m_impl->socket_active.is_connected ())
2002 m_impl->send.clear ();
2003 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2004 m_impl->send.put_data (m_impl->magic_active);
2005 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SURROUNDING_TEXT);
2006 m_impl->send.put_data ("");
2007 m_impl->send.put_data (maxlen_before);
2008 m_impl->send.put_data (maxlen_after);
2009 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2010 if (m_impl->surrounding_text) {
2011 free (m_impl->surrounding_text);
2012 m_impl->surrounding_text = NULL;
2015 const int WAIT_FOR_SYNC_RESPONSE_TIMEOUT = 1000;
2016 /* Now we are waiting for the ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT message */
2017 if (wait_for_message(ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT, WAIT_FOR_SYNC_RESPONSE_TIMEOUT)) {
2018 MessageItem *message = message_queue.get_pending_message_by_cmd(ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT);
2019 handle_message(message);
2020 message_queue.remove_message(message);
2022 if (m_impl->surrounding_text) {
2023 text = m_impl->surrounding_text;
2024 cursor = m_impl->cursor_pos;
2028 if (m_impl->surrounding_text) {
2029 free (m_impl->surrounding_text);
2030 m_impl->surrounding_text = NULL;
2035 * @brief Request to delete surrounding text.
2037 * @param offset The offset for cursor position.
2038 * @param len The length for delete text.
2041 HelperAgent::delete_surrounding_text (int offset, int len) const
2043 LOGD ("offset = %d, len = %d", offset, len);
2045 if (m_impl->socket_active.is_connected ()) {
2046 m_impl->send.clear ();
2047 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2048 m_impl->send.put_data (m_impl->magic_active);
2049 m_impl->send.put_command (SCIM_TRANS_CMD_DELETE_SURROUNDING_TEXT);
2050 m_impl->send.put_data (offset);
2051 m_impl->send.put_data (len);
2052 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2057 * @brief Request to get selection text asynchronously.
2059 * @param uuid The helper ISE UUID.
2062 HelperAgent::get_selection (const String &uuid) const
2065 if (m_impl->socket_active.is_connected () && (m_impl->need_update_selection_text == 0)) {
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_GET_SELECTION);
2070 m_impl->send.put_data (uuid);
2071 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2073 m_impl->need_update_selection_text++;
2077 * @brief Request to get selection text synchronously.
2079 * @param text The selection text.
2082 HelperAgent::get_selection_text (String &text)
2086 if (!m_impl->socket_active.is_connected ())
2089 m_impl->send.clear ();
2090 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2091 m_impl->send.put_data (m_impl->magic_active);
2092 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SELECTION);
2093 m_impl->send.put_data ("");
2094 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2095 if (m_impl->selection_text) {
2096 free (m_impl->selection_text);
2097 m_impl->selection_text = NULL;
2100 const int WAIT_FOR_SYNC_RESPONSE_TIMEOUT = 1000;
2101 /* Now we are waiting for the ISM_TRANS_CMD_UPDATE_SELECTION message */
2102 if (wait_for_message(ISM_TRANS_CMD_UPDATE_SELECTION, WAIT_FOR_SYNC_RESPONSE_TIMEOUT)) {
2103 MessageItem *message = message_queue.get_pending_message_by_cmd(ISM_TRANS_CMD_UPDATE_SELECTION);
2104 handle_message(message);
2105 message_queue.remove_message(message);
2106 if (m_impl->selection_text) {
2107 text = m_impl->selection_text;
2111 if (m_impl->selection_text) {
2112 free (m_impl->selection_text);
2113 m_impl->selection_text = NULL;
2118 * @brief Request to select text.
2120 * @param start The start position in text.
2121 * @param end The end position in text.
2124 HelperAgent::set_selection (int start, int end) const
2127 if (m_impl->socket_active.is_connected ()) {
2128 m_impl->send.clear ();
2129 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2130 m_impl->send.put_data (m_impl->magic_active);
2131 m_impl->send.put_command (SCIM_TRANS_CMD_SET_SELECTION);
2132 m_impl->send.put_data (start);
2133 m_impl->send.put_data (end);
2134 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2139 * @brief Send a private command to an application.
2141 * @param command The private command sent from IME.
2144 HelperAgent::send_private_command (const String &command) 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_SEND_PRIVATE_COMMAND);
2152 m_impl->send.put_data (command);
2153 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2158 * @brief Request to get uuid list of all keyboard ISEs.
2160 * @param uuid The helper ISE UUID.
2163 HelperAgent::get_keyboard_ise_list (const String &uuid) const
2166 if (m_impl->socket_active.is_connected ()) {
2167 m_impl->send.clear ();
2168 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2169 m_impl->send.put_data (m_impl->magic_active);
2170 m_impl->send.put_command (ISM_TRANS_CMD_GET_KEYBOARD_ISE_LIST);
2171 m_impl->send.put_data (uuid);
2172 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2177 * @brief Set candidate position in screen.
2179 * @param left The x position in screen.
2180 * @param top The y position in screen.
2183 HelperAgent::set_candidate_position (int left, int top) 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_SET_CANDIDATE_POSITION);
2191 m_impl->send.put_data (left);
2192 m_impl->send.put_data (top);
2193 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2198 * @brief Set candidate style.
2200 * @param portrait_line - the displayed line number for portrait mode.
2201 * @param mode - candidate window mode.
2204 HelperAgent::set_candidate_style (ISF_CANDIDATE_PORTRAIT_LINE_T portrait_line,
2205 ISF_CANDIDATE_MODE_T mode) const
2208 if (m_impl->socket_active.is_connected ()) {
2209 m_impl->send.clear ();
2210 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2211 m_impl->send.put_data (m_impl->magic_active);
2212 m_impl->send.put_command (ISM_TRANS_CMD_SET_CANDIDATE_UI);
2213 m_impl->send.put_data (portrait_line);
2214 m_impl->send.put_data (mode);
2215 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2220 * @brief Request to hide candidate window.
2223 HelperAgent::candidate_hide (void) const
2226 if (m_impl->socket_active.is_connected ()) {
2227 m_impl->send.clear ();
2228 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2229 m_impl->send.put_data (m_impl->magic_active);
2230 m_impl->send.put_command (ISM_TRANS_CMD_HIDE_CANDIDATE);
2231 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2236 * @brief Request to get candidate window size and position.
2238 * @param uuid The helper ISE UUID.
2241 HelperAgent::get_candidate_window_geometry (const String &uuid) const
2244 if (m_impl->socket_active.is_connected ()) {
2245 m_impl->send.clear ();
2246 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2247 m_impl->send.put_data (m_impl->magic_active);
2248 m_impl->send.put_command (ISM_TRANS_CMD_GET_CANDIDATE_GEOMETRY);
2249 m_impl->send.put_data (uuid);
2250 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2255 * @brief Set current keyboard ISE.
2257 * @param uuid The keyboard ISE UUID.
2260 HelperAgent::set_keyboard_ise_by_uuid (const String &uuid) const
2264 IMEngineFactoryPointer factory;
2265 IMEngineModule *engine_module = NULL;
2266 static int instance_count = 1;
2268 if ((!m_impl->si.null ()) && m_impl->si->get_factory_uuid () == uuid) {
2269 LOGD ("Already in UUID: %s\n", uuid.c_str());
2273 if (!m_impl->si.null()) {
2274 m_impl->si->focus_out();
2278 if (m_impl->m_config.null ()) {
2279 LOGW ("config is not working");
2283 #if HAVE_PKGMGR_INFO
2286 pkgmgrinfo_appinfo_h handle;
2287 ret = pkgmgrinfo_appinfo_get_appinfo(uuid.c_str(), &handle);
2288 if (ret != PMINFO_R_OK) {
2289 LOGW("Retrieve app info failed : %s", uuid.c_str ());
2293 ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
2294 if (ret != PMINFO_R_OK) {
2295 LOGW("Retrieve pkgid failed : %s, %p", uuid.c_str(), handle);
2296 pkgmgrinfo_appinfo_destroy_appinfo(handle);
2300 imeInfo.module_name = pkgid;
2301 pkgmgrinfo_appinfo_destroy_appinfo(handle);
2303 if (isf_db_select_ime_info_by_appid(uuid.c_str(), &imeInfo) < 1) {
2304 LOGW("ime_info row is not available for %s", uuid.c_str());
2309 engine_module = &m_impl->engine_module;
2311 if (engine_module->valid() && imeInfo.module_name != engine_module->get_module_name()) {
2312 LOGD ("imengine module %s unloaded", engine_module->get_module_name().c_str());
2313 engine_module->unload();
2316 if (!engine_module->valid()) {
2317 if (engine_module->load (imeInfo.module_name, m_impl->m_config) == false) {
2318 LOGW ("load module %s failed", imeInfo.module_name.c_str());
2321 LOGD ("imengine module %s loaded", imeInfo.module_name.c_str());
2324 for (size_t j = 0; j < engine_module->number_of_factories (); ++j) {
2327 factory = engine_module->create_factory (j);
2328 if (factory.null () == false && factory->get_uuid () == uuid)
2336 if (factory.null()) {
2337 LOGW ("imengine uuid %s is not found", uuid.c_str());
2341 m_impl->si = factory->create_instance ("UTF-8", instance_count++);
2342 if (m_impl->si.null ()) {
2343 LOGE ("create_instance %s failed",uuid.c_str ());
2347 m_impl->attach_instance ();
2348 LOGD ("Require UUID: %s Current UUID: %s", uuid.c_str (), m_impl->si->get_factory_uuid ().c_str ());
2349 m_impl->si->set_layout (m_impl->layout);
2350 if(m_impl->focused_ic != (uint32)-1)
2351 m_impl->si->focus_in ();
2355 * @brief Request to get current keyboard ISE information.
2357 * @param uuid The helper ISE UUID.
2360 HelperAgent::get_keyboard_ise (const String &uuid) const
2363 //FIXME: maybe useless
2365 if (m_impl->socket_active.is_connected ()) {
2366 m_impl->send.clear ();
2367 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2368 m_impl->send.put_data (m_impl->magic_active);
2369 m_impl->send.put_command (ISM_TRANS_CMD_GET_KEYBOARD_ISE);
2370 m_impl->send.put_data (uuid);
2371 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2377 * @brief Update ISE window geometry.
2379 * @param x The x position in screen.
2380 * @param y The y position in screen.
2381 * @param width The ISE window width.
2382 * @param height The ISE window height.
2385 HelperAgent::update_geometry (int x, int y, int width, int height) const
2388 if (m_impl->socket_active.is_connected ()) {
2389 m_impl->send.clear ();
2390 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2391 m_impl->send.put_data (m_impl->magic_active);
2392 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ISE_GEOMETRY);
2393 m_impl->send.put_data (x);
2394 m_impl->send.put_data (y);
2395 m_impl->send.put_data (width);
2396 m_impl->send.put_data (height);
2397 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2402 * @brief Request to expand candidate window.
2405 HelperAgent::expand_candidate (void) 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_EXPAND_CANDIDATE);
2413 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2418 * @brief Request to contract candidate window.
2421 HelperAgent::contract_candidate (void) const
2424 if (m_impl->socket_active.is_connected ()) {
2425 m_impl->send.clear ();
2426 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2427 m_impl->send.put_data (m_impl->magic_active);
2428 m_impl->send.put_command (ISM_TRANS_CMD_CONTRACT_CANDIDATE);
2429 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2434 * @brief Send selected candidate string index number.
2437 HelperAgent::select_candidate (int index) const
2440 if (!m_impl->si.null ())
2441 m_impl->si->select_candidate (index);
2442 //FIXME: maybe useless
2445 if (m_impl->socket_active.is_connected ()) {
2446 m_impl->send.clear ();
2447 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2448 m_impl->send.put_data (m_impl->magic_active);
2449 m_impl->send.put_command (ISM_TRANS_CMD_SELECT_CANDIDATE);
2450 m_impl->send.put_data (index);
2451 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2457 * @brief Update our ISE is exiting.
2460 HelperAgent::update_ise_exit (void) const
2463 //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_UPDATE_ISE_EXIT);
2470 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2476 * @brief Request to reset keyboard ISE.
2479 HelperAgent::reset_keyboard_ise (void) const
2482 //FIXME: maybe useless
2484 if (m_impl->socket_active.is_connected ()) {
2485 m_impl->send.clear ();
2486 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2487 m_impl->send.put_data (m_impl->magic_active);
2488 m_impl->send.put_command (ISM_TRANS_CMD_PANEL_RESET_KEYBOARD_ISE);
2489 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2492 if (!m_impl->si.null ()) {
2493 m_impl->si->reset ();
2498 * @brief Request panel to hide ISE.
2501 HelperAgent::request_ise_hide (void) const
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_REQUEST_ISE_HIDE);
2509 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2514 * @brief Connect a slot to Helper exit signal.
2516 * This signal is used to let the Helper exit.
2518 * The prototype of the slot is:
2520 * void exit (const HelperAgent *agent, int ic, const String &ic_uuid);
2523 * - agent The pointer to the HelperAgent object which emits this signal.
2524 * - ic An opaque handle of the currently focused input context.
2525 * - ic_uuid The UUID of the IMEngineInstance associated with the focused input context.
2528 HelperAgent::signal_connect_exit (HelperAgentSlotVoid *slot)
2530 return m_impl->signal_exit.connect (slot);
2534 * @brief Connect a slot to Helper attach input context signal.
2536 * This signal is used to attach an input context to this helper.
2538 * When an input context requst to start this helper, then this
2539 * signal will be emitted as soon as the helper is started.
2541 * When an input context want to start an already started helper,
2542 * this signal will also be emitted.
2544 * Helper can send some events back to the IMEngineInstance in this
2545 * signal-slot, to inform that it has been started sccessfully.
2547 * The prototype of the slot is:
2549 * void attach_input_context (const HelperAgent *agent, int ic, const String &ic_uuid);
2552 HelperAgent::signal_connect_attach_input_context (HelperAgentSlotVoid *slot)
2554 return m_impl->signal_attach_input_context.connect (slot);
2558 * @brief Connect a slot to Helper detach input context signal.
2560 * This signal is used to detach an input context from this helper.
2562 * When an input context requst to stop this helper, then this
2563 * signal will be emitted.
2565 * Helper shouldn't send any event back to the IMEngineInstance, because
2566 * the IMEngineInstance attached to the ic should have been destroyed.
2568 * The prototype of the slot is:
2570 * void detach_input_context (const HelperAgent *agent, int ic, const String &ic_uuid);
2573 HelperAgent::signal_connect_detach_input_context (HelperAgentSlotVoid *slot)
2575 return m_impl->signal_detach_input_context.connect (slot);
2579 * @brief Connect a slot to Helper reload config signal.
2581 * This signal is used to let the Helper reload configuration.
2583 * The prototype of the slot is:
2585 * void reload_config (const HelperAgent *agent, int ic, const String &ic_uuid);
2588 HelperAgent::signal_connect_reload_config (HelperAgentSlotVoid *slot)
2590 return m_impl->signal_reload_config.connect (slot);
2594 * @brief Connect a slot to Helper update screen signal.
2596 * This signal is used to let the Helper move its GUI to another screen.
2597 * It can only be emitted when SCIM_HELPER_NEED_SCREEN_INFO is set in HelperInfo.option.
2599 * The prototype of the slot is:
2601 * void update_screen (const HelperAgent *agent, int ic, const String &ic_uuid, int screen_number);
2604 HelperAgent::signal_connect_update_screen (HelperAgentSlotInt *slot)
2606 return m_impl->signal_update_screen.connect (slot);
2610 * @brief Connect a slot to Helper update spot location signal.
2612 * This signal is used to let the Helper move its GUI according to the current spot location.
2613 * It can only be emitted when SCIM_HELPER_NEED_SPOT_LOCATION_INFO is set in HelperInfo.option.
2615 * The prototype of the slot is:
2616 * void update_spot_location (const HelperAgent *agent, int ic, const String &ic_uuid, int x, int y);
2619 HelperAgent::signal_connect_update_spot_location (HelperAgentSlotIntInt *slot)
2621 return m_impl->signal_update_spot_location.connect (slot);
2625 * @brief Connect a slot to Helper update cursor position signal.
2627 * This signal is used to let the Helper get the cursor position information.
2629 * The prototype of the slot is:
2630 * void update_cursor_position (const HelperAgent *agent, int ic, const String &ic_uuid, int cursor_pos);
2633 HelperAgent::signal_connect_update_cursor_position (HelperAgentSlotInt *slot)
2635 return m_impl->signal_update_cursor_position.connect (slot);
2639 * @brief Connect a slot to Helper update surrounding text signal.
2641 * This signal is used to let the Helper get the surrounding text.
2643 * The prototype of the slot is:
2644 * void update_surrounding_text (const HelperAgent *agent, int ic, const String &text, int cursor);
2647 HelperAgent::signal_connect_update_surrounding_text (HelperAgentSlotInt *slot)
2649 return m_impl->signal_update_surrounding_text.connect (slot);
2653 * @brief Connect a slot to Helper update selection signal.
2655 * This signal is used to let the Helper get the selection.
2657 * The prototype of the slot is:
2658 * void update_selection (const HelperAgent *agent, int ic, const String &text);
2661 HelperAgent::signal_connect_update_selection (HelperAgentSlotVoid *slot)
2663 return m_impl->signal_update_selection.connect (slot);
2667 * @brief Connect a slot to Helper trigger property signal.
2669 * This signal is used to trigger a property registered by this Helper.
2670 * A property will be triggered when user clicks on it.
2672 * The prototype of the slot is:
2673 * void trigger_property (const HelperAgent *agent, int ic, const String &ic_uuid, const String &property);
2676 HelperAgent::signal_connect_trigger_property (HelperAgentSlotString *slot)
2678 return m_impl->signal_trigger_property.connect (slot);
2682 * @brief Connect a slot to Helper process imengine event signal.
2684 * This signal is used to deliver the events sent from IMEngine to Helper.
2686 * The prototype of the slot is:
2687 * void process_imengine_event (const HelperAgent *agent, int ic, const String &ic_uuid, const Transaction &transaction);
2690 HelperAgent::signal_connect_process_imengine_event (HelperAgentSlotTransaction *slot)
2692 return m_impl->signal_process_imengine_event.connect (slot);
2696 * @brief Connect a slot to Helper focus out signal.
2698 * This signal is used to do something when input context is focus out.
2700 * The prototype of the slot is:
2701 * void focus_out (const HelperAgent *agent, int ic, const String &ic_uuid);
2704 HelperAgent::signal_connect_focus_out (HelperAgentSlotVoid *slot)
2706 return m_impl->signal_focus_out.connect (slot);
2710 * @brief Connect a slot to Helper focus in signal.
2712 * This signal is used to do something when input context is focus in.
2714 * The prototype of the slot is:
2715 * void focus_in (const HelperAgent *agent, int ic, const String &ic_uuid);
2718 HelperAgent::signal_connect_focus_in (HelperAgentSlotVoid *slot)
2720 return m_impl->signal_focus_in.connect (slot);
2724 * @brief Connect a slot to Helper show signal.
2726 * This signal is used to show Helper ISE window.
2728 * The prototype of the slot is:
2729 * void ise_show (const HelperAgent *agent, int ic, char *buf, size_t &len);
2732 HelperAgent::signal_connect_ise_show (HelperAgentSlotIntRawVoid *slot)
2734 return m_impl->signal_ise_show.connect (slot);
2738 * @brief Connect a slot to Helper hide signal.
2740 * This signal is used to hide Helper ISE window.
2742 * The prototype of the slot is:
2743 * void ise_hide (const HelperAgent *agent, int ic, const String &ic_uuid);
2746 HelperAgent::signal_connect_ise_hide (HelperAgentSlotVoid *slot)
2748 return m_impl->signal_ise_hide.connect (slot);
2752 * @brief Connect a slot to Helper get ISE window geometry signal.
2754 * This signal is used to get Helper ISE window size and position.
2756 * The prototype of the slot is:
2757 * void get_geometry (const HelperAgent *agent, struct rectinfo &info);
2760 HelperAgent::signal_connect_get_geometry (HelperAgentSlotSize *slot)
2762 return m_impl->signal_get_geometry.connect (slot);
2766 * @brief Connect a slot to Helper set mode signal.
2768 * This signal is used to set Helper ISE mode.
2770 * The prototype of the slot is:
2771 * void set_mode (const HelperAgent *agent, uint32 &mode);
2774 HelperAgent::signal_connect_set_mode (HelperAgentSlotUintVoid *slot)
2776 return m_impl->signal_set_mode.connect (slot);
2780 * @brief Connect a slot to Helper set language signal.
2782 * This signal is used to set Helper ISE language.
2784 * The prototype of the slot is:
2785 * void set_language (const HelperAgent *agent, uint32 &language);
2788 HelperAgent::signal_connect_set_language (HelperAgentSlotUintVoid *slot)
2790 return m_impl->signal_set_language.connect (slot);
2794 * @brief Connect a slot to Helper set im data signal.
2796 * This signal is used to send im data to Helper ISE.
2798 * The prototype of the slot is:
2799 * void set_imdata (const HelperAgent *agent, char *buf, size_t &len);
2802 HelperAgent::signal_connect_set_imdata (HelperAgentSlotRawVoid *slot)
2804 return m_impl->signal_set_imdata.connect (slot);
2808 * @brief Connect a slot to Helper get im data signal.
2810 * This signal is used to get im data from Helper ISE.
2812 * The prototype of the slot is:
2813 * void get_imdata (const HelperAgent *, char **buf, size_t &len);
2816 HelperAgent::signal_connect_get_imdata (HelperAgentSlotGetRawVoid *slot)
2818 return m_impl->signal_get_imdata.connect (slot);
2822 * @brief Connect a slot to Helper get language locale signal.
2824 * This signal is used to get language locale from Helper ISE.
2826 * The prototype of the slot is:
2827 * void get_language_locale (const HelperAgent *, int ic, char **locale);
2830 HelperAgent::signal_connect_get_language_locale (HelperAgentSlotIntGetStringVoid *slot)
2832 return m_impl->signal_get_language_locale.connect (slot);
2836 * @brief Connect a slot to Helper set return key type signal.
2838 * This signal is used to send return key type to Helper ISE.
2840 * The prototype of the slot is:
2841 * void set_return_key_type (const HelperAgent *agent, uint32 &type);
2844 HelperAgent::signal_connect_set_return_key_type (HelperAgentSlotUintVoid *slot)
2846 return m_impl->signal_set_return_key_type.connect (slot);
2850 * @brief Connect a slot to Helper get return key type signal.
2852 * This signal is used to get return key type from Helper ISE.
2854 * The prototype of the slot is:
2855 * void get_return_key_type (const HelperAgent *agent, uint32 &type);
2858 HelperAgent::signal_connect_get_return_key_type (HelperAgentSlotUintVoid *slot)
2860 return m_impl->signal_get_return_key_type.connect (slot);
2864 * @brief Connect a slot to Helper set return key disable signal.
2866 * This signal is used to send return key disable to Helper ISE.
2868 * The prototype of the slot is:
2869 * void set_return_key_disable (const HelperAgent *agent, uint32 &disabled);
2872 HelperAgent::signal_connect_set_return_key_disable (HelperAgentSlotUintVoid *slot)
2874 return m_impl->signal_set_return_key_disable.connect (slot);
2878 * @brief Connect a slot to Helper process key event signal.
2880 * This signal is used to send keyboard key event to Helper ISE.
2882 * The prototype of the slot is:
2883 * void process_key_event (const HelperAgent *agent, KeyEvent &key, uint32 &ret);
2886 HelperAgent::signal_connect_process_key_event (HelperAgentSlotKeyEventUint *slot)
2888 return m_impl->signal_process_key_event.connect (slot);
2892 * @brief Connect a slot to Helper get return key disable signal.
2894 * This signal is used to get return key disable from Helper ISE.
2896 * The prototype of the slot is:
2897 * void get_return_key_disable (const HelperAgent *agent, uint32 &disabled);
2900 HelperAgent::signal_connect_get_return_key_disable (HelperAgentSlotUintVoid *slot)
2902 return m_impl->signal_get_return_key_disable.connect (slot);
2906 * @brief Connect a slot to Helper set layout signal.
2908 * This signal is used to set Helper ISE layout.
2910 * The prototype of the slot is:
2911 * void set_layout (const HelperAgent *agent, uint32 &layout);
2914 HelperAgent::signal_connect_set_layout (HelperAgentSlotUintVoid *slot)
2916 return m_impl->signal_set_layout.connect (slot);
2920 * @brief Connect a slot to Helper get layout signal.
2922 * This signal is used to get Helper ISE layout.
2924 * The prototype of the slot is:
2925 * void get_layout (const HelperAgent *agent, uint32 &layout);
2928 HelperAgent::signal_connect_get_layout (HelperAgentSlotUintVoid *slot)
2930 return m_impl->signal_get_layout.connect (slot);
2934 * @brief Connect a slot to Helper set input mode signal.
2936 * This signal is used to set Helper ISE input mode.
2938 * The prototype of the slot is:
2939 * void set_input_mode (const HelperAgent *agent, uint32 &input_mode);
2942 HelperAgent::signal_connect_set_input_mode (HelperAgentSlotUintVoid *slot)
2944 return m_impl->signal_set_input_mode.connect (slot);
2948 * @brief Connect a slot to Helper set input hint signal.
2950 * This signal is used to set Helper ISE input hint.
2952 * The prototype of the slot is:
2953 * void set_input_hint (const HelperAgent *agent, uint32 &input_hint);
2956 HelperAgent::signal_connect_set_input_hint (HelperAgentSlotUintVoid *slot)
2958 return m_impl->signal_set_input_hint.connect (slot);
2962 * @brief Connect a slot to Helper set BiDi direction signal.
2964 * This signal is used to set Helper ISE BiDi direction.
2966 * The prototype of the slot is:
2967 * void update_bidi_direction (const HelperAgent *agent, uint32 &bidi_direction);
2970 HelperAgent::signal_connect_update_bidi_direction (HelperAgentSlotUintVoid *slot)
2972 return m_impl->signal_update_bidi_direction.connect (slot);
2976 * @brief Connect a slot to Helper set shift mode signal.
2978 * This signal is used to set Helper shift mode.
2980 * The prototype of the slot is:
2981 * void set_caps_mode (const HelperAgent *agent, uint32 &mode);
2984 HelperAgent::signal_connect_set_caps_mode (HelperAgentSlotUintVoid *slot)
2986 return m_impl->signal_set_caps_mode.connect (slot);
2990 * @brief Connect a slot to Helper reset input context signal.
2992 * This signal is used to reset Helper ISE input context.
2994 * The prototype of the slot is:
2995 * void reset_input_context (const HelperAgent *agent, int ic, const String &uuid);
2998 HelperAgent::signal_connect_reset_input_context (HelperAgentSlotVoid *slot)
3000 return m_impl->signal_reset_input_context.connect (slot);
3004 * @brief Connect a slot to Helper update candidate window geometry signal.
3006 * This signal is used to get candidate window size and position.
3008 * The prototype of the slot is:
3009 * void update_candidate_geometry (const HelperAgent *agent, int ic, const String &uuid, const rectinfo &info);
3012 HelperAgent::signal_connect_update_candidate_geometry (HelperAgentSlotRect *slot)
3014 return m_impl->signal_update_candidate_geometry.connect (slot);
3018 * @brief Connect a slot to Helper update keyboard ISE signal.
3020 * This signal is used to get current keyboard ISE name and uuid.
3022 * The prototype of the slot is:
3023 * void update_keyboard_ise (const HelperAgent *agent, int ic, const String &uuid,
3024 * const String &ise_name, const String &ise_uuid);
3027 HelperAgent::signal_connect_update_keyboard_ise (HelperAgentSlotString2 *slot)
3029 return m_impl->signal_update_keyboard_ise.connect (slot);
3033 * @brief Connect a slot to Helper update keyboard ISE list signal.
3035 * This signal is used to get uuid list of all keyboard ISEs.
3037 * The prototype of the slot is:
3038 * void update_keyboard_ise_list (const HelperAgent *agent, int ic, const String &uuid,
3039 * const std::vector<String> &ise_list);
3042 HelperAgent::signal_connect_update_keyboard_ise_list (HelperAgentSlotStringVector *slot)
3044 return m_impl->signal_update_keyboard_ise_list.connect (slot);
3048 * @brief Connect a slot to Helper candidate more window show signal.
3050 * This signal is used to do someting when candidate more window is showed.
3052 * The prototype of the slot is:
3053 * void candidate_more_window_show (const HelperAgent *agent, int ic, const String &uuid);
3056 HelperAgent::signal_connect_candidate_more_window_show (HelperAgentSlotVoid *slot)
3058 return m_impl->signal_candidate_more_window_show.connect (slot);
3062 * @brief Connect a slot to Helper candidate more window hide signal.
3064 * This signal is used to do someting when candidate more window is hidden.
3066 * The prototype of the slot is:
3067 * void candidate_more_window_hide (const HelperAgent *agent, int ic, const String &uuid);
3070 HelperAgent::signal_connect_candidate_more_window_hide (HelperAgentSlotVoid *slot)
3072 return m_impl->signal_candidate_more_window_hide.connect (slot);
3076 * @brief Connect a slot to Helper candidate show signal.
3078 * This signal is used to do candidate show.
3080 * The prototype of the slot is:
3081 * void candidate_show (const HelperAgent *agent, int ic, const String &uuid);
3084 HelperAgent::signal_connect_candidate_show (HelperAgentSlotVoid *slot)
3086 return m_impl->signal_candidate_show.connect (slot);
3090 * @brief Connect a slot to Helper candidate hide signal.
3092 * This signal is used to do candidate hide.
3094 * The prototype of the slot is:
3095 * void candidate_hide (const HelperAgent *agent, int ic, const String &uuid);
3098 HelperAgent::signal_connect_candidate_hide (HelperAgentSlotVoid *slot)
3100 return m_impl->signal_candidate_hide.connect (slot);
3104 * @brief Connect a slot to Helper update lookup table signal.
3106 * This signal is used to do someting when update lookup table.
3108 * The prototype of the slot is:
3109 * void update_lookup_table (const HelperAgent *agent, int ic, const String &uuid ,LookupTable &table);
3112 HelperAgent::signal_connect_update_lookup_table (HelperAgentSlotLookupTable *slot)
3114 return m_impl->signal_update_lookup_table.connect (slot);
3118 * @brief Connect a slot to Helper select aux signal.
3120 * This signal is used to do something when aux is selected.
3122 * The prototype of the slot is:
3123 * void select_aux (const HelperAgent *agent, int ic, const String &uuid, int index);
3126 HelperAgent::signal_connect_select_aux (HelperAgentSlotInt *slot)
3128 return m_impl->signal_select_aux.connect (slot);
3132 * @brief Connect a slot to Helper select candidate signal.
3134 * This signal is used to do something when candidate is selected.
3136 * The prototype of the slot is:
3137 * void select_candidate (const HelperAgent *agent, int ic, const String &uuid, int index);
3140 HelperAgent::signal_connect_select_candidate (HelperAgentSlotInt *slot)
3142 return m_impl->signal_select_candidate.connect (slot);
3146 * @brief Connect a slot to Helper candidate table page up signal.
3148 * This signal is used to do something when candidate table is paged up.
3150 * The prototype of the slot is:
3151 * void candidate_table_page_up (const HelperAgent *agent, int ic, const String &uuid);
3154 HelperAgent::signal_connect_candidate_table_page_up (HelperAgentSlotVoid *slot)
3156 return m_impl->signal_candidate_table_page_up.connect (slot);
3160 * @brief Connect a slot to Helper candidate table page down signal.
3162 * This signal is used to do something when candidate table is paged down.
3164 * The prototype of the slot is:
3165 * void candidate_table_page_down (const HelperAgent *agent, int ic, const String &uuid);
3168 HelperAgent::signal_connect_candidate_table_page_down (HelperAgentSlotVoid *slot)
3170 return m_impl->signal_candidate_table_page_down.connect (slot);
3174 * @brief Connect a slot to Helper update candidate table page size signal.
3176 * This signal is used to do something when candidate table page size is changed.
3178 * The prototype of the slot is:
3179 * void update_candidate_table_page_size (const HelperAgent *, int ic, const String &uuid, int page_size);
3182 HelperAgent::signal_connect_update_candidate_table_page_size (HelperAgentSlotInt *slot)
3184 return m_impl->signal_update_candidate_table_page_size.connect (slot);
3188 * @brief Connect a slot to Helper update candidate item layout signal.
3190 * The prototype of the slot is:
3191 * void update_candidate_item_layout (const HelperAgent *, const std::vector<uint32> &row_items);
3194 HelperAgent::signal_connect_update_candidate_item_layout (HelperAgentSlotUintVector *slot)
3196 return m_impl->signal_update_candidate_item_layout.connect (slot);
3200 * @brief Connect a slot to Helper select associate signal.
3202 * This signal is used to do something when associate is selected.
3204 * The prototype of the slot is:
3205 * void select_associate (const HelperAgent *agent, int ic, const String &uuid, int index);
3208 HelperAgent::signal_connect_select_associate (HelperAgentSlotInt *slot)
3210 return m_impl->signal_select_associate.connect (slot);
3214 * @brief Connect a slot to Helper associate table page up signal.
3216 * This signal is used to do something when associate table is paged up.
3218 * The prototype of the slot is:
3219 * void associate_table_page_up (const HelperAgent *agent, int ic, const String &uuid);
3222 HelperAgent::signal_connect_associate_table_page_up (HelperAgentSlotVoid *slot)
3224 return m_impl->signal_associate_table_page_up.connect (slot);
3228 * @brief Connect a slot to Helper associate table page down signal.
3230 * This signal is used to do something when associate table is paged down.
3232 * The prototype of the slot is:
3233 * void associate_table_page_down (const HelperAgent *agent, int ic, const String &uuid);
3236 HelperAgent::signal_connect_associate_table_page_down (HelperAgentSlotVoid *slot)
3238 return m_impl->signal_associate_table_page_down.connect (slot);
3242 * @brief Connect a slot to Helper update associate table page size signal.
3244 * This signal is used to do something when associate table page size is changed.
3246 * The prototype of the slot is:
3247 * void update_associate_table_page_size (const HelperAgent *, int ic, const String &uuid, int page_size);
3250 HelperAgent::signal_connect_update_associate_table_page_size (HelperAgentSlotInt *slot)
3252 return m_impl->signal_update_associate_table_page_size.connect (slot);
3256 * @brief Connect a slot to Helper turn on log signal.
3258 * This signal is used to turn on Helper ISE debug information.
3260 * The prototype of the slot is:
3261 * void turn_on_log (const HelperAgent *agent, uint32 &on);
3264 HelperAgent::signal_connect_turn_on_log (HelperAgentSlotUintVoid *slot)
3266 return m_impl->signal_turn_on_log.connect (slot);
3270 * @brief Connect a slot to Helper update displayed candidate number signal.
3272 * This signal is used to inform helper ISE displayed candidate number.
3274 * The prototype of the slot is:
3275 * void update_displayed_candidate_number (const HelperAgent *, int ic, const String &uuid, int number);
3278 HelperAgent::signal_connect_update_displayed_candidate_number (HelperAgentSlotInt *slot)
3280 return m_impl->signal_update_displayed_candidate_number.connect (slot);
3284 * @brief Connect a slot to Helper longpress candidate signal.
3286 * This signal is used to do something when candidate is longpress.
3288 * The prototype of the slot is:
3289 * void longpress_candidate (const HelperAgent *agent, int ic, const String &uuid, int index);
3292 HelperAgent::signal_connect_longpress_candidate (HelperAgentSlotInt *slot)
3294 return m_impl->signal_longpress_candidate.connect (slot);
3298 * @brief Connect a slot to Helper show option window.
3300 * This signal is used to do request the ISE to show option window.
3302 * The prototype of the slot is:
3303 * void show_option_window (const HelperAgent *agent, int ic, const String &uuid);
3306 HelperAgent::signal_connect_show_option_window (HelperAgentSlotVoid *slot)
3308 return m_impl->signal_show_option_window.connect (slot);
3312 * @brief Connect a slot to Helper check if the option is available.
3314 * This signal is used to check if the option (setting) is available from Helper ISE.
3316 * The prototype of the slot is:
3317 * void check_option_window (const HelperAgent *agent, uint32 &avail);
3320 HelperAgent::signal_connect_check_option_window (HelperAgentSlotUintVoid *slot)
3322 return m_impl->signal_check_option_window.connect (slot);
3326 * @brief Connect a slot to Helper process unconventional input device event signal.
3328 * This signal is used to send unconventional input device event to Helper ISE.
3330 * The prototype of the slot is:
3331 * void process_input_device_event (const HelperAgent *, uint32 &type, char *data, size_t &size, uint32 &ret);
3334 HelperAgent::signal_connect_process_input_device_event (HelperAgentSlotUintCharSizeUint *slot)
3336 return m_impl->signal_process_input_device_event.connect (slot);
3339 } /* namespace scim */
3342 vi:ts=4:nowrap:ai:expandtab