1 /** @file scim_helper.cpp
2 * @brief Implementation of class HelperAgent.
5 /* ISF is based on SCIM 1.4.7 and extended for supporting more mobile fitable. */
8 * Smart Common Input Method
10 * Copyright (c) 2004-2005 James Su <suzhe@tsinghua.org.cn>
11 * Copyright (c) 2012-2015 Samsung Electronics Co., Ltd.
14 * This library is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU Lesser General Public
16 * License as published by the Free Software Foundation; either
17 * version 2 of the License, or (at your option) any later version.
19 * This library is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License for more details.
24 * You should have received a copy of the GNU Lesser General Public
25 * License along with this program; if not, write to the
26 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
27 * Boston, MA 02111-1307 USA
29 * Modifications by Samsung Electronics Co., Ltd.
30 * 1. Add new interface APIs for keyboard ISE
31 * a. expand_candidate (), contract_candidate () and set_candidate_style ()
32 * b. set_keyboard_ise_by_uuid () and reset_keyboard_ise ()
33 * c. get_surrounding_text () and delete_surrounding_text ()
34 * d. show_preedit_string (), hide_preedit_string (), update_preedit_string () and update_preedit_caret ()
35 * e. show_candidate_string (), hide_candidate_string () and update_candidate_string ()
37 * $Id: scim_helper.cpp,v 1.13 2005/05/24 12:22:51 suzhe Exp $
41 #define Uses_SCIM_TRANSACTION
42 #define Uses_SCIM_TRANS_COMMANDS
43 #define Uses_SCIM_HELPER
44 #define Uses_SCIM_SOCKET
45 #define Uses_SCIM_EVENT
46 #define Uses_SCIM_BACKEND
47 #define Uses_SCIM_IMENGINE_MODULE
53 #include "scim_private.h"
55 #include <scim_panel_common.h>
56 #include "isf_query_utility.h"
58 #include "isf_debug.h"
59 #include "isf_message_queue.h"
60 #ifdef HAVE_PKGMGR_INFO
61 #include <pkgmgr-info.h>
62 #endif // HAVE_PKGMGR_INFO
67 #define LOG_TAG "SCIM_HELPER"
70 //FIXME: remove this definitions
71 #define SHIFT_MODE_OFF 0xffe1
72 #define SHIFT_MODE_ON 0xffe2
73 #define SHIFT_MODE_LOCK 0xffe6
74 #define SHIFT_MODE_ENABLE 0x9fe7
75 #define SHIFT_MODE_DISABLE 0x9fe8
79 typedef Signal3<void, const HelperAgent *, int, const String &>
80 HelperAgentSignalVoid;
82 typedef Signal4<void, const HelperAgent *, int, const String &, const String &>
83 HelperAgentSignalString;
85 typedef Signal4<void, const HelperAgent *, int, const String &, const std::vector<String> &>
86 HelperAgentSignalStringVector;
88 typedef Signal5<void, const HelperAgent *, int, const String &, const String &, const String &>
89 HelperAgentSignalString2;
91 typedef Signal4<void, const HelperAgent *, int, const String &, int>
94 typedef Signal5<void, const HelperAgent *, int, const String &, int, int>
95 HelperAgentSignalIntInt;
97 typedef Signal4<void, const HelperAgent *, int, const String &, const Transaction &>
98 HelperAgentSignalTransaction;
100 typedef Signal4<void, const HelperAgent *, int, const String &, const rectinfo &>
101 HelperAgentSignalRect;
103 typedef Signal2<void, const HelperAgent *, struct rectinfo &>
104 HelperAgentSignalSize;
106 typedef Signal2<void, const HelperAgent *, uint32 &>
107 HelperAgentSignalUintVoid;
109 typedef Signal3<void, const HelperAgent *, int, uint32 &>
110 HelperAgentSignalIntUint;
112 typedef Signal3 <void, const HelperAgent *, char *, size_t &>
113 HelperAgentSignalRawVoid;
115 typedef Signal3 <void, const HelperAgent *, char **, size_t &>
116 HelperAgentSignalGetRawVoid;
118 typedef Signal4 <void, const HelperAgent *, int, char *, size_t &>
119 HelperAgentSignalIntRawVoid;
121 typedef Signal3 <void, const HelperAgent *, int, char **>
122 HelperAgentSignalIntGetStringVoid;
124 typedef Signal2<void, const HelperAgent *, const std::vector<uint32> &>
125 HelperAgentSignalUintVector;
127 typedef Signal2<void, const HelperAgent *, LookupTable &>
128 HelperAgentSignalLookupTable;
130 typedef Signal3<void, const HelperAgent *, KeyEvent &, uint32 &>
131 HelperAgentSignalKeyEventUint;
133 typedef Signal5<void, const HelperAgent *, uint32 &, char *, size_t &, uint32 &>
134 HelperAgentSignalUintCharSizeUint;
136 class HelperAgent::HelperAgentImpl
140 SocketClient socket_active;
149 IMEngineInstancePointer si;
150 ConfigPointer m_config;
151 IMEngineModule engine_module;
153 char* surrounding_text;
154 char* selection_text;
156 int need_update_surrounding_text;
157 int need_update_selection_text;
160 HelperAgentSignalVoid signal_exit;
161 HelperAgentSignalVoid signal_attach_input_context;
162 HelperAgentSignalVoid signal_detach_input_context;
163 HelperAgentSignalVoid signal_reload_config;
164 HelperAgentSignalInt signal_update_screen;
165 HelperAgentSignalIntInt signal_update_spot_location;
166 HelperAgentSignalInt signal_update_cursor_position;
167 HelperAgentSignalInt signal_update_surrounding_text;
168 HelperAgentSignalVoid signal_update_selection;
169 HelperAgentSignalString signal_trigger_property;
170 HelperAgentSignalTransaction signal_process_imengine_event;
171 HelperAgentSignalVoid signal_focus_out;
172 HelperAgentSignalVoid signal_focus_in;
173 HelperAgentSignalIntRawVoid signal_ise_show;
174 HelperAgentSignalVoid signal_ise_hide;
175 HelperAgentSignalVoid signal_candidate_show;
176 HelperAgentSignalVoid signal_candidate_hide;
177 HelperAgentSignalSize signal_get_geometry;
178 HelperAgentSignalUintVoid signal_set_mode;
179 HelperAgentSignalUintVoid signal_set_language;
180 HelperAgentSignalRawVoid signal_set_imdata;
181 HelperAgentSignalGetRawVoid signal_get_imdata;
182 HelperAgentSignalIntGetStringVoid signal_get_language_locale;
183 HelperAgentSignalUintVoid signal_set_return_key_type;
184 HelperAgentSignalUintVoid signal_get_return_key_type;
185 HelperAgentSignalUintVoid signal_set_return_key_disable;
186 HelperAgentSignalUintVoid signal_get_return_key_disable;
187 HelperAgentSignalUintVoid signal_set_layout;
188 HelperAgentSignalUintVoid signal_get_layout;
189 HelperAgentSignalUintVoid signal_set_caps_mode;
190 HelperAgentSignalVoid signal_reset_input_context;
191 HelperAgentSignalIntInt signal_update_candidate_ui;
192 HelperAgentSignalRect signal_update_candidate_geometry;
193 HelperAgentSignalString2 signal_update_keyboard_ise;
194 HelperAgentSignalStringVector signal_update_keyboard_ise_list;
195 HelperAgentSignalVoid signal_candidate_more_window_show;
196 HelperAgentSignalVoid signal_candidate_more_window_hide;
197 HelperAgentSignalLookupTable signal_update_lookup_table;
198 HelperAgentSignalInt signal_select_aux;
199 HelperAgentSignalInt signal_select_candidate;
200 HelperAgentSignalVoid signal_candidate_table_page_up;
201 HelperAgentSignalVoid signal_candidate_table_page_down;
202 HelperAgentSignalInt signal_update_candidate_table_page_size;
203 HelperAgentSignalUintVector signal_update_candidate_item_layout;
204 HelperAgentSignalInt signal_select_associate;
205 HelperAgentSignalVoid signal_associate_table_page_up;
206 HelperAgentSignalVoid signal_associate_table_page_down;
207 HelperAgentSignalInt signal_update_associate_table_page_size;
208 HelperAgentSignalVoid signal_reset_ise_context;
209 HelperAgentSignalUintVoid signal_turn_on_log;
210 HelperAgentSignalInt signal_update_displayed_candidate_number;
211 HelperAgentSignalInt signal_longpress_candidate;
212 HelperAgentSignalKeyEventUint signal_process_key_event;
213 HelperAgentSignalUintVoid signal_set_input_mode;
214 HelperAgentSignalUintVoid signal_set_input_hint;
215 HelperAgentSignalUintVoid signal_update_bidi_direction;
216 HelperAgentSignalVoid signal_show_option_window;
217 HelperAgentSignalVoid signal_resume_option_window;
218 HelperAgentSignalUintVoid signal_check_option_window;
219 HelperAgentSignalUintCharSizeUint signal_process_input_device_event;
222 HelperAgentImpl (HelperAgent* thiz) : focused_ic ((uint32) -1), thiz (thiz),
223 surrounding_text (NULL), selection_text (NULL), cursor_pos (0),
224 need_update_surrounding_text (0), need_update_selection_text (0),
228 ~HelperAgentImpl () {
233 if (surrounding_text != NULL)
234 free (surrounding_text);
236 if (selection_text != NULL)
237 free (selection_text);
239 if (engine_module.valid ()) {
240 engine_module.unload ();
244 // Implementation of slot functions
246 slot_show_preedit_string (IMEngineInstanceBase *si)
249 thiz->show_preedit_string (focused_ic, "");
253 slot_show_aux_string (IMEngineInstanceBase *si)
256 thiz->show_aux_string ();
260 slot_show_lookup_table (IMEngineInstanceBase *si)
263 thiz->show_candidate_string ();
267 slot_hide_preedit_string (IMEngineInstanceBase *si)
270 thiz->hide_preedit_string (focused_ic, "");
274 slot_hide_aux_string (IMEngineInstanceBase *si)
277 thiz->hide_aux_string ();
281 slot_hide_lookup_table (IMEngineInstanceBase *si)
284 thiz->hide_candidate_string ();
288 slot_update_preedit_caret (IMEngineInstanceBase *si, int caret)
291 thiz->update_preedit_caret (caret);
295 slot_update_preedit_string (IMEngineInstanceBase *si,
296 const WideString & str,
297 const AttributeList & attrs,
301 thiz->update_preedit_string (-1, "", str, attrs, caret);
305 slot_update_preedit_string_with_commit (IMEngineInstanceBase *si,
306 const WideString & preedit,
307 const WideString & commit,
308 const AttributeList & attrs,
312 thiz->update_preedit_string (-1, "", preedit, commit, attrs, caret);
316 slot_update_aux_string (IMEngineInstanceBase *si,
317 const WideString & str,
318 const AttributeList & attrs)
321 thiz->update_aux_string (utf8_wcstombs(str), attrs);
325 slot_commit_string (IMEngineInstanceBase *si,
326 const WideString & str)
329 thiz->commit_string (-1, "", str);
333 slot_forward_key_event (IMEngineInstanceBase *si,
334 const KeyEvent & key)
337 thiz->forward_key_event (-1, "", key);
341 slot_update_lookup_table (IMEngineInstanceBase *si,
342 const LookupTable & table)
345 thiz->update_candidate_string (table);
349 slot_register_properties (IMEngineInstanceBase *si,
350 const PropertyList & properties)
353 thiz->register_properties (properties);
357 slot_update_property (IMEngineInstanceBase *si,
358 const Property & property)
361 thiz->update_property (property);
365 slot_beep (IMEngineInstanceBase *si)
372 slot_start_helper (IMEngineInstanceBase *si,
373 const String &helper_uuid)
375 LOGW ("deprecated function");
379 slot_stop_helper (IMEngineInstanceBase *si,
380 const String &helper_uuid)
382 LOGW ("deprecated function");
386 slot_send_helper_event (IMEngineInstanceBase *si,
387 const String &helper_uuid,
388 const Transaction &trans)
391 signal_process_imengine_event (thiz, focused_ic, helper_uuid, trans);
395 slot_get_surrounding_text (IMEngineInstanceBase *si,
403 thiz->get_surrounding_text (maxlen_before, maxlen_after, _text, cursor);
404 text = utf8_mbstowcs(_text);
409 slot_delete_surrounding_text (IMEngineInstanceBase *si,
415 thiz->delete_surrounding_text (offset, len);
420 slot_get_selection (IMEngineInstanceBase *si,
425 thiz->get_selection_text (_text);
426 text = utf8_mbstowcs (_text);
431 slot_set_selection (IMEngineInstanceBase *si,
436 thiz->set_selection (start, end);
441 slot_expand_candidate (IMEngineInstanceBase *si)
444 thiz->expand_candidate ();
448 slot_contract_candidate (IMEngineInstanceBase *si)
451 thiz->contract_candidate ();
455 slot_set_candidate_style (IMEngineInstanceBase *si, ISF_CANDIDATE_PORTRAIT_LINE_T portrait_line, ISF_CANDIDATE_MODE_T mode)
458 thiz->set_candidate_style (portrait_line, mode);
462 slot_send_private_command (IMEngineInstanceBase *si,
463 const String &command)
466 thiz->send_private_command (command);
472 si->signal_connect_show_preedit_string (
473 slot (this, &HelperAgent::HelperAgentImpl::slot_show_preedit_string));
474 si->signal_connect_show_aux_string (
475 slot (this, &HelperAgent::HelperAgentImpl::slot_show_aux_string));
476 si->signal_connect_show_lookup_table (
477 slot (this, &HelperAgent::HelperAgentImpl::slot_show_lookup_table));
479 si->signal_connect_hide_preedit_string (
480 slot (this, &HelperAgent::HelperAgentImpl::slot_hide_preedit_string));
481 si->signal_connect_hide_aux_string (
482 slot (this, &HelperAgent::HelperAgentImpl::slot_hide_aux_string));
483 si->signal_connect_hide_lookup_table (
484 slot (this, &HelperAgent::HelperAgentImpl::slot_hide_lookup_table));
486 si->signal_connect_update_preedit_caret (
487 slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_caret));
488 si->signal_connect_update_preedit_string (
489 slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_string));
490 si->signal_connect_update_preedit_string_with_commit (
491 slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_string_with_commit));
493 si->signal_connect_update_aux_string (
494 slot (this, &HelperAgent::HelperAgentImpl::slot_update_aux_string));
495 si->signal_connect_update_lookup_table (
496 slot (this, &HelperAgent::HelperAgentImpl::slot_update_lookup_table));
498 si->signal_connect_commit_string (
499 slot (this, &HelperAgent::HelperAgentImpl::slot_commit_string));
501 si->signal_connect_forward_key_event (
502 slot (this, &HelperAgent::HelperAgentImpl::slot_forward_key_event));
504 si->signal_connect_register_properties (
505 slot (this, &HelperAgent::HelperAgentImpl::slot_register_properties));
507 si->signal_connect_update_property (
508 slot (this, &HelperAgent::HelperAgentImpl::slot_update_property));
510 si->signal_connect_beep (
511 slot (this, &HelperAgent::HelperAgentImpl::slot_beep));
513 si->signal_connect_start_helper (
514 slot (this, &HelperAgent::HelperAgentImpl::slot_start_helper));
516 si->signal_connect_stop_helper (
517 slot (this, &HelperAgent::HelperAgentImpl::slot_stop_helper));
519 si->signal_connect_send_helper_event (
520 slot (this, &HelperAgent::HelperAgentImpl::slot_send_helper_event));
522 si->signal_connect_get_surrounding_text (
523 slot (this, &HelperAgent::HelperAgentImpl::slot_get_surrounding_text));
525 si->signal_connect_delete_surrounding_text (
526 slot (this, &HelperAgent::HelperAgentImpl::slot_delete_surrounding_text));
528 si->signal_connect_get_selection (
529 slot (this, &HelperAgent::HelperAgentImpl::slot_get_selection));
531 si->signal_connect_set_selection (
532 slot (this, &HelperAgent::HelperAgentImpl::slot_set_selection));
534 si->signal_connect_expand_candidate (
535 slot (this, &HelperAgent::HelperAgentImpl::slot_expand_candidate));
536 si->signal_connect_contract_candidate (
537 slot (this, &HelperAgent::HelperAgentImpl::slot_contract_candidate));
539 si->signal_connect_set_candidate_style (
540 slot (this, &HelperAgent::HelperAgentImpl::slot_set_candidate_style));
542 si->signal_connect_send_private_command (
543 slot (this, &HelperAgent::HelperAgentImpl::slot_send_private_command));
546 void process_key_event_done (KeyEvent &key, uint32 ret, uint32 serial) {
547 LOGD ("ret: %d, serial: %d", ret, serial);
548 if (socket_active.is_connected ()) {
550 send.put_command (SCIM_TRANS_CMD_REQUEST);
551 send.put_data (magic_active);
552 send.put_command (ISM_TRANS_CMD_PROCESS_KEY_EVENT_DONE);
555 send.put_data (serial);
556 send.write_to_socket (socket_active, magic_active);
560 void request_ise_hide () {
561 if (socket_active.is_connected ()) {
563 send.put_command (SCIM_TRANS_CMD_REQUEST);
564 send.put_data (magic_active);
565 send.put_command (ISM_TRANS_CMD_REQUEST_ISE_HIDE);
566 send.write_to_socket (socket_active, magic_active);
570 HelperAgentImpl () : magic (0), magic_active (0), timeout (-1), focused_ic ((uint32) -1) { }
573 static MessageQueue message_queue;
575 HelperAgent::HelperAgent ()
576 : m_impl (new HelperAgentImpl (this))
578 message_queue.create();
581 HelperAgent::~HelperAgent ()
583 message_queue.destroy();
588 * @brief Open socket connection to the Panel.
590 * @param info The information of this Helper object.
591 * @param display The display which this Helper object should run on.
593 * @return The connection socket id. -1 means failed to create
597 HelperAgent::open_connection (const HelperInfo &info,
598 const String &display)
600 if (m_impl->socket.is_connected ())
603 SocketAddress address (scim_get_default_panel_socket_address (display));
604 int timeout = m_impl->timeout = scim_get_default_socket_timeout ();
607 if (!address.valid ())
611 std::cerr << " Connecting to PanelAgent server.";
612 ISF_LOG (" Connecting to PanelAgent server.\n");
613 while (!m_impl->socket.connect (address)) {
615 scim_usleep (100000);
617 std::cerr << "m_impl->socket.connect () is failed!!!\n";
618 ISF_LOG ("m_impl->socket.connect () is failed!!!\n");
622 std::cerr << " Connected :" << i << "\n";
623 ISF_LOG (" Connected :%d\n", i);
624 LOGD ("Connection to PanelAgent succeeded, %d\n", i);
626 /* Let's retry 10 times when failed */
627 int open_connection_retries = 0;
628 while (!scim_socket_open_connection (magic,
633 if (++open_connection_retries > 10) {
634 m_impl->socket.close ();
635 std::cerr << "scim_socket_open_connection () is failed!!!\n";
636 ISF_LOG ("scim_socket_open_connection () is failed!!!\n");
637 ISF_SAVE_LOG ("scim_socket_open_connection failed, %d\n", timeout);
642 /* Retry after re-connecting the socket */
643 if (m_impl->socket.is_connected ())
646 /* This time, just retry atmost 2 seconds */
648 while (!m_impl->socket.connect (address) && ++i < 10) {
649 scim_usleep (200000);
654 ISF_LOG ("scim_socket_open_connection () is successful.\n");
655 LOGD ("scim_socket_open_connection successful\n");
657 m_impl->send.clear ();
658 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
659 m_impl->send.put_data (magic);
660 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_REGISTER_HELPER);
661 m_impl->send.put_data (info.uuid);
662 m_impl->send.put_data (info.name);
663 m_impl->send.put_data (info.icon);
664 m_impl->send.put_data (info.description);
665 m_impl->send.put_data (info.option);
667 if (!m_impl->send.write_to_socket (m_impl->socket, magic)) {
668 m_impl->socket.close ();
673 if (m_impl->recv.read_from_socket (m_impl->socket, timeout) &&
674 m_impl->recv.get_command (cmd) && cmd == SCIM_TRANS_CMD_REPLY &&
675 m_impl->recv.get_command (cmd) && cmd == SCIM_TRANS_CMD_OK) {
676 m_impl->magic = magic;
678 while (m_impl->recv.get_command (cmd)) {
680 case SCIM_TRANS_CMD_HELPER_ATTACH_INPUT_CONTEXT:
684 while (m_impl->recv.get_data (ic) && m_impl->recv.get_data (ic_uuid))
685 m_impl->signal_attach_input_context (this, ic, ic_uuid);
688 case SCIM_TRANS_CMD_UPDATE_SCREEN:
691 if (m_impl->recv.get_data (screen))
692 m_impl->signal_update_screen (this, (uint32) -1, String (""), (int) screen);
700 //FIXME: Attaching input context is needed for desktop environment
701 LOGW ("Attach input context and update screen failed");
704 ISF_SAVE_LOG ("Trying connect() with Helper_Active\n");
706 /* connect to the panel agent as the active helper client */
707 if (!m_impl->socket_active.connect (address)) return -1;
708 open_connection_retries = 0;
709 while (!scim_socket_open_connection (magic,
710 String ("Helper_Active"),
712 m_impl->socket_active,
714 if (++open_connection_retries > 10) {
715 m_impl->socket_active.close ();
716 std::cerr << "Helper_Active scim_socket_open_connection () is failed!!!\n";
717 ISF_LOG ("Helper_Active scim_socket_open_connection () is failed!!!\n");
718 ISF_SAVE_LOG ("Helper_Active scim_socket_open_connection failed, %d\n", timeout);
723 /* Retry after re-connecting the socket */
724 if (m_impl->socket_active.is_connected ())
725 m_impl->socket_active.close ();
727 /* This time, just retry atmost 2 seconds */
729 while (!m_impl->socket_active.connect (address) && ++i < 10) {
730 scim_usleep (200000);
734 m_impl->magic_active = magic;
736 m_impl->send.clear ();
737 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
738 m_impl->send.put_data (magic);
739 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_REGISTER_ACTIVE_HELPER);
740 m_impl->send.put_data (info.uuid);
741 m_impl->send.put_data (info.name);
742 m_impl->send.put_data (info.icon);
743 m_impl->send.put_data (info.description);
744 m_impl->send.put_data (info.option);
746 if (!m_impl->send.write_to_socket (m_impl->socket_active, magic)) {
747 ISF_SAVE_LOG ("Helper_Active write_to_socket() failed\n");
748 m_impl->socket_active.close ();
751 m_impl->m_config = ConfigBase::get (false, "socket");
753 return m_impl->socket.get_id ();
757 * @brief Close the socket connection to Panel.
760 HelperAgent::close_connection ()
762 m_impl->socket.close ();
763 m_impl->socket_active.close ();
764 m_impl->send.clear ();
765 m_impl->recv.clear ();
767 m_impl->magic_active = 0;
772 * @brief Get the connection id previously returned by open_connection().
774 * @return the connection id
777 HelperAgent::get_connection_number () const
779 if (m_impl->socket.is_connected ())
780 return m_impl->socket.get_id ();
785 * @brief Check whether this HelperAgent has been connected to a Panel.
787 * Return true when it is connected to panel, otherwise return false.
790 HelperAgent::is_connected () const
792 return m_impl->socket.is_connected ();
796 * @brief Check if there are any events available to be processed.
798 * If it returns true then Helper object should call
799 * HelperAgent::filter_event() to process them.
801 * @return true if there are any events available.
804 HelperAgent::has_pending_event () const
806 if (m_impl->socket.is_connected () && m_impl->socket.wait_for_data (0) > 0)
809 if (message_queue.has_pending_message())
816 * @brief Process the pending events.
818 * This function will emit the corresponding signals according
821 * @return false if the connection is broken, otherwise return true.
824 HelperAgent::filter_event ()
826 if (!m_impl->socket.is_connected ()) {
827 LOGW("Connection lost, returning false");
831 if (m_impl->recv.read_from_socket (m_impl->socket, m_impl->timeout)) {
832 message_queue.read_from_transaction(m_impl->recv);
834 while (message_queue.has_pending_message()) {
835 MessageItem *message = message_queue.get_pending_message();
836 handle_message(message);
837 message_queue.remove_message(message);
840 LOGD("read_from_socket() failed but continuing");
848 * @brief Read messages from socket buffer, and see if there is a message with the given cmd.
850 * @return false if the connection is broken, or no message available with given cmd. Otherwise return true.
853 HelperAgent::wait_for_message(int cmd, int timeout)
855 struct timeval t0 = { 0, 0 };
856 struct timeval t1 = { 0, 0 };
858 gettimeofday(&t0, NULL);
862 if (!m_impl->socket.is_connected() || !m_impl->recv.read_from_socket(m_impl->socket, timeout))
865 message_queue.read_from_transaction(m_impl->recv);
866 if (message_queue.has_pending_message_by_cmd(cmd)) {
870 gettimeofday(&t1, NULL);
871 etime = ((t1.tv_sec * 1000000 + t1.tv_usec) - (t0.tv_sec * 1000000 + t0.tv_usec)) / 1000;
872 } while (etime < timeout);
878 * @brief Process one message that is in our message queue.
880 * This function will emit the corresponding signals according
883 * @param message The message that needs to be handled.
885 * @return false if the connection is broken, otherwise return true.
888 HelperAgent::handle_message (MessageItem *message)
893 int cmd = message->get_command_ref();
894 LOGD ("HelperAgent::cmd = %d\n", cmd);
896 case SCIM_TRANS_CMD_EXIT:
898 MessageItemExit *subclass = static_cast<MessageItemExit*>(message);
899 ISF_SAVE_LOG ("Helper ISE received SCIM_TRANS_CMD_EXIT message\n");
900 m_impl->signal_exit(this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
903 case SCIM_TRANS_CMD_RELOAD_CONFIG:
905 MessageItemReloadConfig *subclass = static_cast<MessageItemReloadConfig*>(message);
906 m_impl->signal_reload_config (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
907 if (!m_impl->m_config.null())
908 m_impl->m_config->ConfigBase::reload();
911 case SCIM_TRANS_CMD_UPDATE_SCREEN:
913 MessageItemUpdateScreen *subclass = static_cast<MessageItemUpdateScreen*>(message);
914 m_impl->signal_update_screen (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
915 subclass->get_screen_ref());
918 case SCIM_TRANS_CMD_UPDATE_SPOT_LOCATION:
920 MessageItemUpdateSpotLocation *subclass = static_cast<MessageItemUpdateSpotLocation*>(message);
921 m_impl->signal_update_spot_location (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
922 subclass->get_x_ref(), subclass->get_y_ref());
925 case ISM_TRANS_CMD_UPDATE_CURSOR_POSITION:
927 MessageItemUpdateCursorPosition *subclass = static_cast<MessageItemUpdateCursorPosition*>(message);
928 m_impl->cursor_pos = subclass->get_cursor_pos_ref();
929 LOGD ("update cursor position %d", subclass->get_cursor_pos_ref());
930 m_impl->signal_update_cursor_position (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
931 subclass->get_cursor_pos_ref());
932 if (!m_impl->si.null ()) m_impl->si->update_cursor_position(subclass->get_cursor_pos_ref());
935 case ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT:
937 MessageItemUpdateSurroundingText *subclass = static_cast<MessageItemUpdateSurroundingText*>(message);
938 if (m_impl->surrounding_text != NULL)
939 free (m_impl->surrounding_text);
940 m_impl->surrounding_text = strdup (subclass->get_text_ref().c_str ());
941 m_impl->cursor_pos = subclass->get_cursor_ref();
942 LOGD ("surrounding text: %s, %d", m_impl->surrounding_text, subclass->get_cursor_ref());
943 while (m_impl->need_update_surrounding_text > 0) {
944 m_impl->need_update_surrounding_text--;
945 m_impl->signal_update_surrounding_text (this, subclass->get_ic_ref(),
946 subclass->get_text_ref(), subclass->get_cursor_ref());
950 case ISM_TRANS_CMD_UPDATE_SELECTION:
952 MessageItemUpdateSelection *subclass = static_cast<MessageItemUpdateSelection*>(message);
953 if (m_impl->selection_text != NULL)
954 free (m_impl->selection_text);
956 m_impl->selection_text = strdup (subclass->get_text_ref().c_str ());
957 LOGD ("selection text: %s", m_impl->selection_text);
959 while (m_impl->need_update_selection_text > 0) {
960 m_impl->need_update_selection_text--;
961 m_impl->signal_update_selection (this, subclass->get_ic_ref(), subclass->get_text_ref());
965 case SCIM_TRANS_CMD_TRIGGER_PROPERTY:
967 MessageItemTriggerProperty *subclass = static_cast<MessageItemTriggerProperty*>(message);
968 m_impl->signal_trigger_property (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
969 subclass->get_property_ref());
970 if (!m_impl->si.null ()) m_impl->si->trigger_property(subclass->get_property_ref());
973 case SCIM_TRANS_CMD_HELPER_PROCESS_IMENGINE_EVENT:
975 MessageItemHelperProcessImengineEvent *subclass = static_cast<MessageItemHelperProcessImengineEvent*>(message);
976 m_impl->signal_process_imengine_event (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
977 subclass->get_transaction_ref());
980 case SCIM_TRANS_CMD_HELPER_ATTACH_INPUT_CONTEXT:
982 MessageItemHelperAttachInputContext *subclass = static_cast<MessageItemHelperAttachInputContext*>(message);
983 m_impl->signal_attach_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
986 case SCIM_TRANS_CMD_HELPER_DETACH_INPUT_CONTEXT:
988 MessageItemHelperDetachInputContext *subclass = static_cast<MessageItemHelperDetachInputContext*>(message);
989 m_impl->signal_detach_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
992 case SCIM_TRANS_CMD_FOCUS_OUT:
994 MessageItemFocusOut *subclass = static_cast<MessageItemFocusOut*>(message);
995 m_impl->signal_focus_out (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
996 m_impl->focused_ic = (uint32) -1;
997 if (!m_impl->si.null ()) m_impl->si->focus_out();
1000 case SCIM_TRANS_CMD_FOCUS_IN:
1002 MessageItemFocusIn *subclass = static_cast<MessageItemFocusIn*>(message);
1003 m_impl->signal_focus_in (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1004 m_impl->focused_ic = subclass->get_ic_ref();
1005 if (!m_impl->si.null ()) m_impl->si->focus_in();
1008 case ISM_TRANS_CMD_SHOW_ISE_PANEL:
1010 MessageItemShowISEPanel *subclass = static_cast<MessageItemShowISEPanel*>(message);
1011 LOGD ("Helper ISE received ISM_TRANS_CMD_SHOW_ISE_PANEL message\n");
1013 m_impl->signal_ise_show (this, subclass->get_ic_ref(), *(subclass->get_data_ptr()),
1014 subclass->get_len_ref());
1017 case ISM_TRANS_CMD_HIDE_ISE_PANEL:
1019 MessageItemHideISEPanel *subclass = static_cast<MessageItemHideISEPanel*>(message);
1020 LOGD ("Helper ISE received ISM_TRANS_CMD_HIDE_ISE_PANEL message\n");
1021 m_impl->signal_ise_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1024 case ISM_TRANS_CMD_GET_ACTIVE_ISE_GEOMETRY:
1026 struct rectinfo info = {0, 0, 0, 0};
1027 m_impl->signal_get_geometry (this, info);
1028 m_impl->send.clear ();
1029 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1030 m_impl->send.put_data (info.pos_x);
1031 m_impl->send.put_data (info.pos_y);
1032 m_impl->send.put_data (info.width);
1033 m_impl->send.put_data (info.height);
1034 m_impl->send.write_to_socket (m_impl->socket);
1037 case ISM_TRANS_CMD_SET_ISE_MODE:
1039 MessageItemSetISEMode *subclass = static_cast<MessageItemSetISEMode*>(message);
1040 m_impl->signal_set_mode (this, subclass->get_mode_ref());
1043 case ISM_TRANS_CMD_SET_ISE_LANGUAGE:
1045 MessageItemSetISELanguage *subclass = static_cast<MessageItemSetISELanguage*>(message);
1046 m_impl->signal_set_language (this, subclass->get_language_ref());
1049 case ISM_TRANS_CMD_SET_ISE_IMDATA:
1051 MessageItemSetISEImData *subclass = static_cast<MessageItemSetISEImData*>(message);
1052 m_impl->signal_set_imdata (this, *(subclass->get_imdata_ptr()), subclass->get_len_ref());
1053 if (!m_impl->si.null ()) m_impl->si->set_imdata(*(subclass->get_imdata_ptr()),
1054 subclass->get_len_ref());
1057 case ISM_TRANS_CMD_GET_ISE_IMDATA:
1062 m_impl->signal_get_imdata (this, &buf, len);
1063 LOGD ("send ise imdata len = %d", len);
1064 m_impl->send.clear ();
1065 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1066 m_impl->send.put_data (buf, len);
1067 m_impl->send.write_to_socket (m_impl->socket);
1072 case ISM_TRANS_CMD_GET_ISE_LANGUAGE_LOCALE:
1074 MessageItemGetISELanguageLocale *subclass = static_cast<MessageItemGetISELanguageLocale*>(message);
1076 m_impl->signal_get_language_locale (this, subclass->get_ic_ref(), &buf);
1077 m_impl->send.clear ();
1078 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1080 m_impl->send.put_data (buf, strlen (buf));
1081 m_impl->send.write_to_socket (m_impl->socket);
1086 case ISM_TRANS_CMD_SET_RETURN_KEY_TYPE:
1088 MessageItemSetReturnKeyType *subclass = static_cast<MessageItemSetReturnKeyType*>(message);
1089 m_impl->signal_set_return_key_type (this, subclass->get_type_ref());
1092 case ISM_TRANS_CMD_GET_RETURN_KEY_TYPE:
1095 m_impl->signal_get_return_key_type (this, type);
1096 m_impl->send.clear ();
1097 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1098 m_impl->send.put_data (type);
1099 m_impl->send.write_to_socket (m_impl->socket);
1102 case ISM_TRANS_CMD_SET_RETURN_KEY_DISABLE:
1104 MessageItemSetReturnKeyDisable *subclass = static_cast<MessageItemSetReturnKeyDisable*>(message);
1105 m_impl->signal_set_return_key_disable (this, subclass->get_disabled_ref());
1108 case ISM_TRANS_CMD_GET_RETURN_KEY_DISABLE:
1110 uint32 disabled = 0;
1111 m_impl->signal_get_return_key_type (this, disabled);
1112 m_impl->send.clear ();
1113 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1114 m_impl->send.put_data (disabled);
1115 m_impl->send.write_to_socket (m_impl->socket);
1118 case SCIM_TRANS_CMD_PROCESS_KEY_EVENT:
1120 MessageItemProcessKeyEvent *subclass = static_cast<MessageItemProcessKeyEvent*>(message);
1122 m_impl->signal_process_key_event(this, subclass->get_key_ref(), ret);
1124 if (!m_impl->si.null ())
1126 ret = m_impl->si->process_key_event (subclass->get_key_ref());
1127 LOGD("imengine(%s) process key %d return %d", m_impl->si->get_factory_uuid().c_str(),
1128 subclass->get_key_ref().code, ret);
1130 m_impl->process_key_event_done (subclass->get_key_ref(), ret, subclass->get_serial_ref());
1133 case ISM_TRANS_CMD_SET_LAYOUT:
1135 MessageItemSetLayout *subclass = static_cast<MessageItemSetLayout*>(message);
1136 m_impl->layout = subclass->get_layout_ref();
1137 m_impl->signal_set_layout (this, subclass->get_layout_ref());
1138 if (!m_impl->si.null ()) m_impl->si->set_layout(subclass->get_layout_ref());
1141 case ISM_TRANS_CMD_GET_LAYOUT:
1145 m_impl->signal_get_layout (this, layout);
1146 m_impl->send.clear ();
1147 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1148 m_impl->send.put_data (layout);
1149 m_impl->send.write_to_socket (m_impl->socket);
1152 case ISM_TRANS_CMD_SET_INPUT_MODE:
1154 MessageItemSetInputMode *subclass = static_cast<MessageItemSetInputMode*>(message);
1155 m_impl->signal_set_input_mode (this, subclass->get_input_mode_ref());
1158 case ISM_TRANS_CMD_SET_CAPS_MODE:
1160 MessageItemSetCapsMode *subclass = static_cast<MessageItemSetCapsMode*>(message);
1161 m_impl->signal_set_caps_mode (this, subclass->get_mode_ref());
1164 case SCIM_TRANS_CMD_PANEL_RESET_INPUT_CONTEXT:
1166 MessageItemPanelResetInputContext *subclass = static_cast<MessageItemPanelResetInputContext*>(message);
1167 m_impl->signal_reset_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1168 if (!m_impl->si.null ()) m_impl->si->reset();
1171 case ISM_TRANS_CMD_UPDATE_CANDIDATE_UI:
1173 MessageItemUpdateCandidateUI *subclass = static_cast<MessageItemUpdateCandidateUI*>(message);
1174 m_impl->signal_update_candidate_ui (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1175 subclass->get_style_ref(), subclass->get_mode_ref());
1178 case ISM_TRANS_CMD_UPDATE_CANDIDATE_GEOMETRY:
1180 MessageItemUpdateCandidateGeometry *subclass = static_cast<MessageItemUpdateCandidateGeometry*>(message);
1181 m_impl->signal_update_candidate_geometry (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1182 subclass->get_rectinfo_ref());
1185 case ISM_TRANS_CMD_UPDATE_KEYBOARD_ISE:
1187 MessageItemUpdateKeyboardISE *subclass = static_cast<MessageItemUpdateKeyboardISE*>(message);
1188 m_impl->signal_update_keyboard_ise (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1189 subclass->get_name_ref(), subclass->get_uuid_ref());
1192 case ISM_TRANS_CMD_UPDATE_KEYBOARD_ISE_LIST:
1194 MessageItemUpdateKeyboardISEList *subclass = static_cast<MessageItemUpdateKeyboardISEList*>(message);
1195 m_impl->signal_update_keyboard_ise_list (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1196 subclass->get_list_ref());
1199 case ISM_TRANS_CMD_CANDIDATE_MORE_WINDOW_SHOW:
1201 MessageItemCandidateMoreWindowShow *subclass = static_cast<MessageItemCandidateMoreWindowShow*>(message);
1202 m_impl->signal_candidate_more_window_show (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1203 if (!m_impl->si.null ()) m_impl->si->candidate_more_window_show();
1206 case ISM_TRANS_CMD_CANDIDATE_MORE_WINDOW_HIDE:
1208 MessageItemCandidateMoreWindowHide *subclass = static_cast<MessageItemCandidateMoreWindowHide*>(message);
1209 m_impl->signal_candidate_more_window_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1210 if (!m_impl->si.null ()) m_impl->si->candidate_more_window_hide();
1213 case ISM_TRANS_CMD_SELECT_AUX:
1215 MessageItemSelectAux *subclass = static_cast<MessageItemSelectAux*>(message);
1216 m_impl->signal_select_aux (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1217 subclass->get_item_ref());
1218 if (!m_impl->si.null ()) m_impl->si->select_aux(subclass->get_item_ref());
1221 case SCIM_TRANS_CMD_SELECT_CANDIDATE: //FIXME:remove if useless
1223 MessageItemSelectCandidate *subclass = static_cast<MessageItemSelectCandidate*>(message);
1224 m_impl->signal_select_candidate (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1225 subclass->get_item_ref());
1226 if (!m_impl->si.null ()) m_impl->si->select_candidate(subclass->get_item_ref());
1229 case SCIM_TRANS_CMD_LOOKUP_TABLE_PAGE_UP: //FIXME:remove if useless
1231 MessageItemLookupTablePageUp *subclass = static_cast<MessageItemLookupTablePageUp*>(message);
1232 m_impl->signal_candidate_table_page_up (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1233 if (!m_impl->si.null ()) m_impl->si->lookup_table_page_up();
1236 case SCIM_TRANS_CMD_LOOKUP_TABLE_PAGE_DOWN: //FIXME:remove if useless
1238 MessageItemLookupTablePageDown *subclass = static_cast<MessageItemLookupTablePageDown*>(message);
1239 m_impl->signal_candidate_table_page_down (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1240 if (!m_impl->si.null ()) m_impl->si->lookup_table_page_down();
1243 case SCIM_TRANS_CMD_UPDATE_LOOKUP_TABLE_PAGE_SIZE:
1245 MessageItemUpdateLookupTablePageSize *subclass = static_cast<MessageItemUpdateLookupTablePageSize*>(message);
1246 m_impl->signal_update_candidate_table_page_size (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1247 subclass->get_size_ref());
1248 if (!m_impl->si.null ()) m_impl->si->update_lookup_table_page_size(subclass->get_size_ref());
1251 case ISM_TRANS_CMD_CANDIDATE_SHOW: //FIXME:remove if useless
1253 MessageItemCandidateShow *subclass = static_cast<MessageItemCandidateShow*>(message);
1254 m_impl->signal_candidate_show (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1257 case ISM_TRANS_CMD_CANDIDATE_HIDE: //FIXME:remove if useless
1259 MessageItemCandidateHide *subclass = static_cast<MessageItemCandidateHide*>(message);
1260 m_impl->signal_candidate_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1263 case ISM_TRANS_CMD_UPDATE_LOOKUP_TABLE: //FIXME:remove if useless
1265 MessageItemUpdateLookupTable *subclass = static_cast<MessageItemUpdateLookupTable*>(message);
1266 m_impl->signal_update_lookup_table (this, subclass->get_candidate_table_ref());
1269 case ISM_TRANS_CMD_UPDATE_CANDIDATE_ITEM_LAYOUT:
1271 MessageItemUpdateCandidateItemLayout *subclass = static_cast<MessageItemUpdateCandidateItemLayout*>(message);
1272 m_impl->signal_update_candidate_item_layout (this, subclass->get_row_items_ref());
1273 if (!m_impl->si.null ()) m_impl->si->update_candidate_item_layout(subclass->get_row_items_ref());
1276 case ISM_TRANS_CMD_SELECT_ASSOCIATE:
1278 MessageItemSelectAssociate *subclass = static_cast<MessageItemSelectAssociate*>(message);
1279 m_impl->signal_select_associate (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1280 subclass->get_item_ref());
1283 case ISM_TRANS_CMD_ASSOCIATE_TABLE_PAGE_UP:
1285 MessageItemAssociateTablePageUp *subclass = static_cast<MessageItemAssociateTablePageUp*>(message);
1286 m_impl->signal_associate_table_page_up (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1289 case ISM_TRANS_CMD_ASSOCIATE_TABLE_PAGE_DOWN:
1291 MessageItemAssociateTablePageDown *subclass = static_cast<MessageItemAssociateTablePageDown*>(message);
1292 m_impl->signal_associate_table_page_down (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1295 case ISM_TRANS_CMD_UPDATE_ASSOCIATE_TABLE_PAGE_SIZE:
1297 MessageItemUpdateAssociateTablePageSize *subclass = static_cast<MessageItemUpdateAssociateTablePageSize*>(message);
1298 m_impl->signal_update_associate_table_page_size (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1299 subclass->get_size_ref());
1302 case ISM_TRANS_CMD_RESET_ISE_CONTEXT:
1304 MessageItemResetISEContext *subclass = static_cast<MessageItemResetISEContext*>(message);
1305 m_impl->signal_reset_ise_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1306 m_impl->signal_reset_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1307 if (!m_impl->si.null ()) m_impl->si->reset();
1310 case ISM_TRANS_CMD_TURN_ON_LOG:
1312 MessageItemTurnOnLog *subclass = static_cast<MessageItemTurnOnLog*>(message);
1313 m_impl->signal_turn_on_log (this, subclass->get_state_ref());
1316 case ISM_TRANS_CMD_UPDATE_DISPLAYED_CANDIDATE:
1318 MessageItemUpdateDisplayedCandidate *subclass = static_cast<MessageItemUpdateDisplayedCandidate*>(message);
1319 m_impl->signal_update_displayed_candidate_number (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1320 subclass->get_size_ref());
1321 if (!m_impl->si.null ()) m_impl->si->update_displayed_candidate_number(subclass->get_size_ref());
1324 case ISM_TRANS_CMD_LONGPRESS_CANDIDATE:
1326 MessageItemLongpressCandidate *subclass = static_cast<MessageItemLongpressCandidate*>(message);
1327 m_impl->signal_longpress_candidate (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1328 subclass->get_index_ref());
1329 if (!m_impl->si.null ()) m_impl->si->longpress_candidate(subclass->get_index_ref());
1332 case ISM_TRANS_CMD_SET_INPUT_HINT:
1334 MessageItemSetInputHint *subclass = static_cast<MessageItemSetInputHint*>(message);
1335 m_impl->signal_set_input_hint (this, subclass->get_input_hint_ref());
1336 if (!m_impl->si.null ()) m_impl->si->set_input_hint(subclass->get_input_hint_ref());
1339 case ISM_TRANS_CMD_UPDATE_BIDI_DIRECTION:
1341 MessageItemUpdateBidiDirection *subclass = static_cast<MessageItemUpdateBidiDirection*>(message);
1342 m_impl->signal_update_bidi_direction (this, subclass->get_bidi_direction());
1343 if (!m_impl->si.null ()) m_impl->si->update_bidi_direction(subclass->get_bidi_direction());
1346 case ISM_TRANS_CMD_SHOW_ISE_OPTION_WINDOW:
1348 MessageItemShowISEOptionWindow *subclass = static_cast<MessageItemShowISEOptionWindow*>(message);
1349 m_impl->signal_show_option_window (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1352 case ISM_TRANS_CMD_RESUME_ISE_OPTION_WINDOW:
1354 MessageItemResumeISEOptionWindow *subclass = static_cast<MessageItemResumeISEOptionWindow*>(message);
1355 m_impl->signal_resume_option_window (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1358 case ISM_TRANS_CMD_CHECK_OPTION_WINDOW:
1361 m_impl->signal_check_option_window (this, avail);
1362 m_impl->send.clear ();
1363 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1364 m_impl->send.put_data (avail);
1365 m_impl->send.write_to_socket (m_impl->socket);
1368 case ISM_TRANS_CMD_PROCESS_INPUT_DEVICE_EVENT:
1370 MessageItemProcessInputDeviceEvent *subclass = static_cast<MessageItemProcessInputDeviceEvent*>(message);
1372 m_impl->signal_process_input_device_event(this,
1373 subclass->get_type_ref(), *(subclass->get_data_ptr()), subclass->get_len_ref(), ret);
1374 m_impl->send.clear();
1375 m_impl->send.put_command(SCIM_TRANS_CMD_REPLY);
1376 m_impl->send.put_data(ret);
1377 m_impl->send.write_to_socket(m_impl->socket);
1380 case SCIM_TRANS_CMD_SET_AUTOCAPITAL_TYPE:
1382 MessageItemSetAutocapitalType *subclass = static_cast<MessageItemSetAutocapitalType*>(message);
1383 if (!m_impl->si.null ()) m_impl->si->set_autocapital_type(subclass->get_auto_capital_type_ref());
1386 case ISM_TRANS_CMD_SET_PREDICTION_ALLOW:
1388 MessageItemSetPredictionAllow *subclass = static_cast<MessageItemSetPredictionAllow*>(message);
1389 if (!m_impl->si.null ()) m_impl->si->set_prediction_allow(subclass->get_prediction_allow_ref() == 0 ? false : true);
1399 * @brief Request SCIM to reload all configuration.
1401 * This function should only by used by Setup Helper to request
1402 * scim's reloading the configuration.
1403 * Deprecated: reload config message only send by socketconfig client
1404 * using socketconfig::reload instead.
1407 HelperAgent::reload_config () const
1409 LOGD ("send reload config message to isf");
1410 if (!m_impl->m_config.null())
1411 m_impl->m_config->reload();
1415 * @brief Register some properties into Panel.
1417 * This function send the request to Panel to register a list
1420 * @param properties The list of Properties to be registered into Panel.
1422 * @sa scim::Property.
1425 HelperAgent::register_properties (const PropertyList &properties) const
1428 if (m_impl->socket_active.is_connected ()) {
1429 m_impl->send.clear ();
1430 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1431 m_impl->send.put_data (m_impl->magic_active);
1432 m_impl->send.put_command (SCIM_TRANS_CMD_REGISTER_PROPERTIES);
1433 m_impl->send.put_data (properties);
1434 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1439 * @brief Update a registered property.
1441 * @param property The property to be updated.
1444 HelperAgent::update_property (const Property &property) const
1447 if (m_impl->socket_active.is_connected ()) {
1448 m_impl->send.clear ();
1449 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1450 m_impl->send.put_data (m_impl->magic_active);
1451 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PROPERTY);
1452 m_impl->send.put_data (property);
1453 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1458 * @brief Send a set of events to an IMEngineInstance.
1460 * All events should be put into a Transaction.
1461 * And the events can only be received by one IMEngineInstance object.
1463 * @param ic The handle of the Input Context to receive the events.
1464 * @param ic_uuid The UUID of the Input Context.
1465 * @param trans The Transaction object holds the events.
1468 HelperAgent::send_imengine_event (int ic,
1469 const String &ic_uuid,
1470 const Transaction &trans) const
1473 //remove if not necessary
1475 if (m_impl->socket_active.is_connected ()) {
1476 m_impl->send.clear ();
1477 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1478 m_impl->send.put_data (m_impl->magic_active);
1479 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_SEND_IMENGINE_EVENT);
1480 m_impl->send.put_data ((uint32)ic);
1481 m_impl->send.put_data (ic_uuid);
1482 m_impl->send.put_data (trans);
1483 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1486 if (!m_impl->si.null ()) m_impl->si->process_helper_event (ic_uuid, trans);
1490 * @brief Send a KeyEvent to an IMEngineInstance.
1492 * @param ic The handle of the IMEngineInstance to receive the event.
1493 * -1 means the currently focused IMEngineInstance.
1494 * @param ic_uuid The UUID of the IMEngineInstance. Empty means don't match.
1495 * @param key The KeyEvent to be sent.
1498 HelperAgent::send_key_event (int ic,
1499 const String &ic_uuid,
1500 const KeyEvent &key) const
1504 //FIXME: remove shift_mode_off, shift_mode_on, shift_mode_lock from ISE side
1505 if (key.code == SHIFT_MODE_OFF ||
1506 key.code == SHIFT_MODE_ON ||
1507 key.code == SHIFT_MODE_LOCK ||
1508 key.code == SHIFT_MODE_ENABLE ||
1509 key.code == SHIFT_MODE_DISABLE) {
1510 LOGW("FIXME ignore shift codes");
1516 #if ENABLE_GRAB_KEYBOARD
1517 if (!m_impl->si.null ()) {
1519 if (key.code <= 0x7F ||
1520 (key.code >= SCIM_KEY_BackSpace && key.code <= SCIM_KEY_Delete) ||
1521 (key.code >= SCIM_KEY_Home && key.code <= SCIM_KEY_Hyper_R)) {
1522 // ascii code and function keys
1528 if (ret && (!m_impl->si.null ())) {
1530 ret = m_impl->si->process_key_event (key);
1531 LOGD ("imengine(%s) process key %d return %d", m_impl->si->get_factory_uuid().c_str(), key.code, ret);
1534 if (ret == false && m_impl->socket_active.is_connected ()) {
1535 m_impl->send.clear ();
1536 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1537 m_impl->send.put_data (m_impl->magic_active);
1538 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_SEND_KEY_EVENT);
1540 m_impl->send.put_data (m_impl->focused_ic);
1542 m_impl->send.put_data ((uint32)ic);
1544 m_impl->send.put_data (ic_uuid);
1545 m_impl->send.put_data (key);
1546 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1551 * @brief Forward a KeyEvent to client application directly.
1553 * @param ic The handle of the client Input Context to receive the event.
1554 * -1 means the currently focused Input Context.
1555 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1556 * Empty means don't match.
1557 * @param key The KeyEvent to be forwarded.
1560 HelperAgent::forward_key_event (int ic,
1561 const String &ic_uuid,
1562 const KeyEvent &key) const
1565 if (m_impl->socket_active.is_connected ()) {
1566 m_impl->send.clear ();
1567 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1568 m_impl->send.put_data (m_impl->magic_active);
1569 m_impl->send.put_command (SCIM_TRANS_CMD_FORWARD_KEY_EVENT);
1571 m_impl->send.put_data (m_impl->focused_ic);
1573 m_impl->send.put_data ((uint32)ic);
1575 m_impl->send.put_data (ic_uuid);
1576 m_impl->send.put_data (key);
1577 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1582 * @brief Commit a WideString to client application directly.
1584 * @param ic The handle of the client Input Context to receive the WideString.
1585 * -1 means the currently focused Input Context.
1586 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1587 * Empty means don't match.
1588 * @param wstr The WideString to be committed.
1591 HelperAgent::commit_string (int ic,
1592 const String &ic_uuid,
1593 const WideString &wstr) const
1596 if (m_impl->socket_active.is_connected ()) {
1597 m_impl->send.clear ();
1598 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1599 m_impl->send.put_data (m_impl->magic_active);
1600 m_impl->send.put_command (SCIM_TRANS_CMD_COMMIT_STRING);
1602 m_impl->send.put_data (m_impl->focused_ic);
1604 m_impl->send.put_data ((uint32)ic);
1606 m_impl->send.put_data (ic_uuid);
1607 m_impl->send.put_data (wstr);
1608 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1613 HelperAgent::commit_string (int ic,
1614 const String &ic_uuid,
1619 if (m_impl->socket_active.is_connected ()) {
1620 m_impl->send.clear ();
1621 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1622 m_impl->send.put_data (m_impl->magic_active);
1623 m_impl->send.put_command (SCIM_TRANS_CMD_COMMIT_STRING);
1625 m_impl->send.put_data (m_impl->focused_ic);
1627 m_impl->send.put_data ((uint32)ic);
1629 m_impl->send.put_data (ic_uuid);
1630 m_impl->send.put_dataw (buf, buflen);
1631 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1636 * @brief Request to show preedit string.
1638 * @param ic The handle of the client Input Context to receive the request.
1639 * -1 means the currently focused Input Context.
1640 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1641 * Empty means don't match.
1644 HelperAgent::show_preedit_string (int ic,
1645 const String &ic_uuid) const
1649 if (m_impl->socket_active.is_connected ()) {
1650 m_impl->send.clear ();
1651 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1652 m_impl->send.put_data (m_impl->magic_active);
1653 m_impl->send.put_command (SCIM_TRANS_CMD_SHOW_PREEDIT_STRING);
1654 m_impl->send.put_data ((uint32)ic);
1655 m_impl->send.put_data (ic_uuid);
1656 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1661 * @brief Request to show aux string.
1664 HelperAgent::show_aux_string (void) const
1668 if (m_impl->socket_active.is_connected ()) {
1669 m_impl->send.clear ();
1670 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1671 m_impl->send.put_data (m_impl->magic_active);
1672 m_impl->send.put_command (SCIM_TRANS_CMD_SHOW_AUX_STRING);
1673 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1678 * @brief Request to show candidate string.
1681 HelperAgent::show_candidate_string (void) const
1685 if (m_impl->socket_active.is_connected ()) {
1686 m_impl->send.clear ();
1687 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1688 m_impl->send.put_data (m_impl->magic_active);
1689 m_impl->send.put_command (SCIM_TRANS_CMD_SHOW_LOOKUP_TABLE);
1690 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1695 * @brief Request to show associate string.
1698 HelperAgent::show_associate_string (void) const
1701 if (m_impl->socket_active.is_connected ()) {
1702 m_impl->send.clear ();
1703 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1704 m_impl->send.put_data (m_impl->magic_active);
1705 m_impl->send.put_command (ISM_TRANS_CMD_SHOW_ASSOCIATE_TABLE);
1706 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1711 * @brief Request to hide preedit string.
1713 * @param ic The handle of the client Input Context to receive the request.
1714 * -1 means the currently focused Input Context.
1715 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1716 * Empty means don't match.
1719 HelperAgent::hide_preedit_string (int ic,
1720 const String &ic_uuid) const
1724 if (m_impl->socket_active.is_connected ()) {
1725 m_impl->send.clear ();
1726 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1727 m_impl->send.put_data (m_impl->magic_active);
1728 m_impl->send.put_command (SCIM_TRANS_CMD_HIDE_PREEDIT_STRING);
1729 m_impl->send.put_data ((uint32)ic);
1730 m_impl->send.put_data (ic_uuid);
1731 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1736 * @brief Request to hide aux string.
1739 HelperAgent::hide_aux_string (void) const
1742 if (m_impl->socket_active.is_connected ()) {
1743 m_impl->send.clear ();
1744 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1745 m_impl->send.put_data (m_impl->magic_active);
1746 m_impl->send.put_command (SCIM_TRANS_CMD_HIDE_AUX_STRING);
1747 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1752 * @brief Request to hide candidate string.
1755 HelperAgent::hide_candidate_string (void) const
1758 if (m_impl->socket_active.is_connected ()) {
1759 m_impl->send.clear ();
1760 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1761 m_impl->send.put_data (m_impl->magic_active);
1762 m_impl->send.put_command (SCIM_TRANS_CMD_HIDE_LOOKUP_TABLE);
1763 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1768 * @brief Request to hide associate string.
1771 HelperAgent::hide_associate_string (void) const
1774 if (m_impl->socket_active.is_connected ()) {
1775 m_impl->send.clear ();
1776 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1777 m_impl->send.put_data (m_impl->magic_active);
1778 m_impl->send.put_command (ISM_TRANS_CMD_HIDE_ASSOCIATE_TABLE);
1779 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1784 * @brief Update a new WideString for preedit.
1786 * @param ic The handle of the client Input Context to receive the WideString.
1787 * -1 means the currently focused Input Context.
1788 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1789 * Empty means don't match.
1790 * @param str The WideString to be updated.
1791 * @param attrs The attribute list for preedit string.
1794 HelperAgent::update_preedit_string (int ic,
1795 const String &ic_uuid,
1796 const WideString &str,
1797 const AttributeList &attrs) const
1800 update_preedit_string (ic, ic_uuid, str, str, attrs, -1);
1804 HelperAgent::update_preedit_string (int ic,
1805 const String &ic_uuid,
1808 const AttributeList &attrs) const
1811 update_preedit_string (ic, ic_uuid, buf, buflen, attrs, -1);
1815 * @brief Update a new WideString for preedit.
1817 * @param ic The handle of the client Input Context to receive the WideString.
1818 * -1 means the currently focused Input Context.
1819 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1820 * Empty means don't match.
1821 * @param str The WideString to be updated.
1822 * @param attrs The attribute list for preedit string.
1823 * @param caret The caret position in preedit string.
1826 HelperAgent::update_preedit_string (int ic,
1827 const String &ic_uuid,
1828 const WideString &wstr,
1829 const AttributeList &attrs,
1833 update_preedit_string (ic, ic_uuid, wstr, wstr, attrs, caret);
1837 HelperAgent::update_preedit_string (int ic,
1838 const String &ic_uuid,
1841 const AttributeList &attrs,
1846 if (m_impl->socket_active.is_connected ()) {
1847 m_impl->send.clear ();
1848 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1849 m_impl->send.put_data (m_impl->magic_active);
1850 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING);
1851 m_impl->send.put_data ((uint32)ic);
1852 m_impl->send.put_data (ic_uuid);
1853 m_impl->send.put_dataw (buf, buflen);
1854 m_impl->send.put_dataw (buf, buflen);
1855 m_impl->send.put_data (attrs);
1856 m_impl->send.put_data (caret);
1857 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1862 HelperAgent::update_preedit_string (int ic,
1863 const String &ic_uuid,
1864 const WideString &preedit,
1865 const WideString &commit,
1866 const AttributeList &attrs,
1870 if (m_impl->socket_active.is_connected ()) {
1871 m_impl->send.clear ();
1872 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1873 m_impl->send.put_data (m_impl->magic_active);
1874 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING);
1875 m_impl->send.put_data ((uint32)ic);
1876 m_impl->send.put_data (ic_uuid);
1877 m_impl->send.put_data (preedit);
1878 m_impl->send.put_data (commit);
1879 m_impl->send.put_data (attrs);
1880 m_impl->send.put_data (caret);
1881 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1886 * @brief Update the preedit caret position in the preedit string.
1888 * @param caret - the new position of the preedit caret.
1891 HelperAgent::update_preedit_caret (int caret) const
1895 if (m_impl->socket_active.is_connected ()) {
1896 m_impl->send.clear ();
1897 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1898 m_impl->send.put_data (m_impl->magic_active);
1899 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_CARET);
1900 m_impl->send.put_data ((uint32)caret);
1901 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1906 * @brief Update a new string for aux.
1908 * @param str The string to be updated.
1909 * @param attrs The attribute list for aux string.
1912 HelperAgent::update_aux_string (const String &str,
1913 const AttributeList &attrs) const
1916 if (m_impl->socket_active.is_connected ()) {
1917 m_impl->send.clear ();
1918 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1919 m_impl->send.put_data (m_impl->magic_active);
1920 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_AUX_STRING);
1921 m_impl->send.put_data (str);
1922 m_impl->send.put_data (attrs);
1923 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1928 * @brief Request to update candidate.
1930 * @param table The lookup table for candidate.
1933 HelperAgent::update_candidate_string (const LookupTable &table) const
1936 if (m_impl->socket_active.is_connected ()) {
1937 m_impl->send.clear ();
1938 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1939 m_impl->send.put_data (m_impl->magic_active);
1940 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_LOOKUP_TABLE);
1941 m_impl->send.put_data (table);
1942 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1947 * @brief Request to update associate.
1949 * @param table The lookup table for associate.
1952 HelperAgent::update_associate_string (const LookupTable &table) const
1955 if (m_impl->socket_active.is_connected ()) {
1956 m_impl->send.clear ();
1957 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1958 m_impl->send.put_data (m_impl->magic_active);
1959 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ASSOCIATE_TABLE);
1960 m_impl->send.put_data (table);
1961 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1966 * @brief When the input context of ISE is changed,
1967 * ISE can call this function to notify application
1969 * @param type type of event.
1970 * @param value value of event.
1973 HelperAgent::update_input_context (uint32 type, uint32 value) const
1976 if (m_impl->socket_active.is_connected ()) {
1977 m_impl->send.clear ();
1978 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1979 m_impl->send.put_data (m_impl->magic_active);
1980 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ISE_INPUT_CONTEXT);
1981 m_impl->send.put_data (type);
1982 m_impl->send.put_data (value);
1983 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1988 * @brief Request to get surrounding text asynchronously.
1990 * @param uuid The helper ISE UUID.
1991 * @param maxlen_before The max length of before.
1992 * @param maxlen_after The max length of after.
1995 HelperAgent::get_surrounding_text (const String &uuid, int maxlen_before, int maxlen_after) const
1998 if (m_impl->socket_active.is_connected () && (m_impl->need_update_surrounding_text == 0)) {
1999 m_impl->send.clear ();
2000 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2001 m_impl->send.put_data (m_impl->magic_active);
2002 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SURROUNDING_TEXT);
2003 m_impl->send.put_data (uuid);
2004 m_impl->send.put_data (maxlen_before);
2005 m_impl->send.put_data (maxlen_after);
2006 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2008 m_impl->need_update_surrounding_text++;
2012 * @brief Request to get surrounding text synchronously.
2014 * @param uuid The helper ISE UUID.
2015 * @param maxlen_before The max length of before.
2016 * @param maxlen_after The max length of after.
2017 * @param text The surrounding text.
2018 * @param cursor The cursor position.
2021 HelperAgent::get_surrounding_text (int maxlen_before, int maxlen_after, String &text, int &cursor)
2025 if (!m_impl->socket_active.is_connected ())
2028 m_impl->send.clear ();
2029 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2030 m_impl->send.put_data (m_impl->magic_active);
2031 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SURROUNDING_TEXT);
2032 m_impl->send.put_data ("");
2033 m_impl->send.put_data (maxlen_before);
2034 m_impl->send.put_data (maxlen_after);
2035 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2036 if (m_impl->surrounding_text) {
2037 free (m_impl->surrounding_text);
2038 m_impl->surrounding_text = NULL;
2041 const int WAIT_FOR_SYNC_RESPONSE_TIMEOUT = 1000;
2042 /* Now we are waiting for the ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT message */
2043 if (wait_for_message(ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT, WAIT_FOR_SYNC_RESPONSE_TIMEOUT)) {
2044 MessageItem *message = message_queue.get_pending_message_by_cmd(ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT);
2045 handle_message(message);
2046 message_queue.remove_message(message);
2048 if (m_impl->surrounding_text) {
2049 text = m_impl->surrounding_text;
2050 cursor = m_impl->cursor_pos;
2054 if (m_impl->surrounding_text) {
2055 free (m_impl->surrounding_text);
2056 m_impl->surrounding_text = NULL;
2061 * @brief Request to delete surrounding text.
2063 * @param offset The offset for cursor position.
2064 * @param len The length for delete text.
2067 HelperAgent::delete_surrounding_text (int offset, int len) const
2069 LOGD ("offset = %d, len = %d", offset, len);
2071 if (m_impl->socket_active.is_connected ()) {
2072 m_impl->send.clear ();
2073 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2074 m_impl->send.put_data (m_impl->magic_active);
2075 m_impl->send.put_command (SCIM_TRANS_CMD_DELETE_SURROUNDING_TEXT);
2076 m_impl->send.put_data (offset);
2077 m_impl->send.put_data (len);
2078 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2083 * @brief Request to get selection text asynchronously.
2085 * @param uuid The helper ISE UUID.
2088 HelperAgent::get_selection (const String &uuid) const
2091 if (m_impl->socket_active.is_connected () && (m_impl->need_update_selection_text == 0)) {
2092 m_impl->send.clear ();
2093 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2094 m_impl->send.put_data (m_impl->magic_active);
2095 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SELECTION);
2096 m_impl->send.put_data (uuid);
2097 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2099 m_impl->need_update_selection_text++;
2103 * @brief Request to get selection text synchronously.
2105 * @param text The selection text.
2108 HelperAgent::get_selection_text (String &text)
2112 if (!m_impl->socket_active.is_connected ())
2115 m_impl->send.clear ();
2116 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2117 m_impl->send.put_data (m_impl->magic_active);
2118 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SELECTION);
2119 m_impl->send.put_data ("");
2120 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2121 if (m_impl->selection_text) {
2122 free (m_impl->selection_text);
2123 m_impl->selection_text = NULL;
2126 const int WAIT_FOR_SYNC_RESPONSE_TIMEOUT = 1000;
2127 /* Now we are waiting for the ISM_TRANS_CMD_UPDATE_SELECTION message */
2128 if (wait_for_message(ISM_TRANS_CMD_UPDATE_SELECTION, WAIT_FOR_SYNC_RESPONSE_TIMEOUT)) {
2129 MessageItem *message = message_queue.get_pending_message_by_cmd(ISM_TRANS_CMD_UPDATE_SELECTION);
2130 handle_message(message);
2131 message_queue.remove_message(message);
2132 if (m_impl->selection_text) {
2133 text = m_impl->selection_text;
2137 if (m_impl->selection_text) {
2138 free (m_impl->selection_text);
2139 m_impl->selection_text = NULL;
2144 * @brief Request to select text.
2146 * @param start The start position in text.
2147 * @param end The end position in text.
2150 HelperAgent::set_selection (int start, int end) const
2153 if (m_impl->socket_active.is_connected ()) {
2154 m_impl->send.clear ();
2155 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2156 m_impl->send.put_data (m_impl->magic_active);
2157 m_impl->send.put_command (SCIM_TRANS_CMD_SET_SELECTION);
2158 m_impl->send.put_data (start);
2159 m_impl->send.put_data (end);
2160 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2165 * @brief Send a private command to an application.
2167 * @param command The private command sent from IME.
2170 HelperAgent::send_private_command (const String &command) const
2173 if (m_impl->socket_active.is_connected ()) {
2174 m_impl->send.clear ();
2175 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2176 m_impl->send.put_data (m_impl->magic_active);
2177 m_impl->send.put_command (SCIM_TRANS_CMD_SEND_PRIVATE_COMMAND);
2178 m_impl->send.put_data (command);
2179 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2184 * @brief Request to get uuid list of all keyboard ISEs.
2186 * @param uuid The helper ISE UUID.
2189 HelperAgent::get_keyboard_ise_list (const String &uuid) const
2192 if (m_impl->socket_active.is_connected ()) {
2193 m_impl->send.clear ();
2194 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2195 m_impl->send.put_data (m_impl->magic_active);
2196 m_impl->send.put_command (ISM_TRANS_CMD_GET_KEYBOARD_ISE_LIST);
2197 m_impl->send.put_data (uuid);
2198 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2203 * @brief Set candidate position in screen.
2205 * @param left The x position in screen.
2206 * @param top The y position in screen.
2209 HelperAgent::set_candidate_position (int left, int top) const
2212 if (m_impl->socket_active.is_connected ()) {
2213 m_impl->send.clear ();
2214 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2215 m_impl->send.put_data (m_impl->magic_active);
2216 m_impl->send.put_command (ISM_TRANS_CMD_SET_CANDIDATE_POSITION);
2217 m_impl->send.put_data (left);
2218 m_impl->send.put_data (top);
2219 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2224 * @brief Set candidate style.
2226 * @param portrait_line - the displayed line number for portrait mode.
2227 * @param mode - candidate window mode.
2230 HelperAgent::set_candidate_style (ISF_CANDIDATE_PORTRAIT_LINE_T portrait_line,
2231 ISF_CANDIDATE_MODE_T mode) const
2234 if (m_impl->socket_active.is_connected ()) {
2235 m_impl->send.clear ();
2236 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2237 m_impl->send.put_data (m_impl->magic_active);
2238 m_impl->send.put_command (ISM_TRANS_CMD_SET_CANDIDATE_UI);
2239 m_impl->send.put_data (portrait_line);
2240 m_impl->send.put_data (mode);
2241 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2246 * @brief Request to hide candidate window.
2249 HelperAgent::candidate_hide (void) const
2252 if (m_impl->socket_active.is_connected ()) {
2253 m_impl->send.clear ();
2254 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2255 m_impl->send.put_data (m_impl->magic_active);
2256 m_impl->send.put_command (ISM_TRANS_CMD_HIDE_CANDIDATE);
2257 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2262 * @brief Request to get candidate window size and position.
2264 * @param uuid The helper ISE UUID.
2267 HelperAgent::get_candidate_window_geometry (const String &uuid) const
2270 if (m_impl->socket_active.is_connected ()) {
2271 m_impl->send.clear ();
2272 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2273 m_impl->send.put_data (m_impl->magic_active);
2274 m_impl->send.put_command (ISM_TRANS_CMD_GET_CANDIDATE_GEOMETRY);
2275 m_impl->send.put_data (uuid);
2276 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2281 * @brief Set current keyboard ISE.
2283 * @param uuid The keyboard ISE UUID.
2286 HelperAgent::set_keyboard_ise_by_uuid (const String &uuid) const
2290 IMEngineFactoryPointer factory;
2291 IMEngineModule *engine_module = NULL;
2292 static int instance_count = 1;
2294 if ((!m_impl->si.null ()) && m_impl->si->get_factory_uuid () == uuid) {
2295 LOGD ("Already in UUID: %s\n", uuid.c_str());
2299 if (!m_impl->si.null()) {
2300 m_impl->si->focus_out();
2304 if (m_impl->m_config.null ()) {
2305 LOGW ("config is not working");
2309 #ifdef HAVE_PKGMGR_INFO
2312 pkgmgrinfo_appinfo_h handle;
2313 ret = pkgmgrinfo_appinfo_get_appinfo(uuid.c_str(), &handle);
2314 if (ret != PMINFO_R_OK) {
2315 LOGW("Retrieve app info failed : %s", uuid.c_str ());
2319 ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
2320 if (ret != PMINFO_R_OK) {
2321 LOGW("Retrieve pkgid failed : %s, %p", uuid.c_str(), handle);
2322 pkgmgrinfo_appinfo_destroy_appinfo(handle);
2326 imeInfo.module_name = pkgid;
2327 pkgmgrinfo_appinfo_destroy_appinfo(handle);
2329 if (isf_db_select_ime_info_by_appid(uuid.c_str(), &imeInfo) < 1) {
2330 LOGW("ime_info row is not available for %s", uuid.c_str());
2335 engine_module = &m_impl->engine_module;
2337 if (engine_module->valid() && imeInfo.module_name != engine_module->get_module_name()) {
2338 LOGD ("imengine module %s unloaded", engine_module->get_module_name().c_str());
2339 engine_module->unload();
2342 if (!engine_module->valid()) {
2343 if (engine_module->load (imeInfo.module_name, m_impl->m_config) == false) {
2344 LOGW ("load module %s failed", imeInfo.module_name.c_str());
2347 LOGD ("imengine module %s loaded", imeInfo.module_name.c_str());
2350 for (size_t j = 0; j < engine_module->number_of_factories (); ++j) {
2353 factory = engine_module->create_factory (j);
2354 if (factory.null () == false && factory->get_uuid () == uuid)
2362 if (factory.null()) {
2363 LOGW ("imengine uuid %s is not found", uuid.c_str());
2367 m_impl->si = factory->create_instance ("UTF-8", instance_count++);
2368 if (m_impl->si.null ()) {
2369 LOGE ("create_instance %s failed",uuid.c_str ());
2373 m_impl->attach_instance ();
2374 LOGD ("Require UUID: %s Current UUID: %s", uuid.c_str (), m_impl->si->get_factory_uuid ().c_str ());
2375 m_impl->si->set_layout (m_impl->layout);
2376 if(m_impl->focused_ic != (uint32)-1)
2377 m_impl->si->focus_in ();
2381 * @brief Request to get current keyboard ISE information.
2383 * @param uuid The helper ISE UUID.
2386 HelperAgent::get_keyboard_ise (const String &uuid) const
2389 //FIXME: maybe useless
2391 if (m_impl->socket_active.is_connected ()) {
2392 m_impl->send.clear ();
2393 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2394 m_impl->send.put_data (m_impl->magic_active);
2395 m_impl->send.put_command (ISM_TRANS_CMD_GET_KEYBOARD_ISE);
2396 m_impl->send.put_data (uuid);
2397 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2403 * @brief Update ISE window geometry.
2405 * @param x The x position in screen.
2406 * @param y The y position in screen.
2407 * @param width The ISE window width.
2408 * @param height The ISE window height.
2411 HelperAgent::update_geometry (int x, int y, int width, int height) const
2414 if (m_impl->socket_active.is_connected ()) {
2415 m_impl->send.clear ();
2416 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2417 m_impl->send.put_data (m_impl->magic_active);
2418 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ISE_GEOMETRY);
2419 m_impl->send.put_data (x);
2420 m_impl->send.put_data (y);
2421 m_impl->send.put_data (width);
2422 m_impl->send.put_data (height);
2423 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2428 * @brief Request to expand candidate window.
2431 HelperAgent::expand_candidate (void) const
2434 if (m_impl->socket_active.is_connected ()) {
2435 m_impl->send.clear ();
2436 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2437 m_impl->send.put_data (m_impl->magic_active);
2438 m_impl->send.put_command (ISM_TRANS_CMD_EXPAND_CANDIDATE);
2439 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2444 * @brief Request to contract candidate window.
2447 HelperAgent::contract_candidate (void) const
2450 if (m_impl->socket_active.is_connected ()) {
2451 m_impl->send.clear ();
2452 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2453 m_impl->send.put_data (m_impl->magic_active);
2454 m_impl->send.put_command (ISM_TRANS_CMD_CONTRACT_CANDIDATE);
2455 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2460 * @brief Send selected candidate string index number.
2463 HelperAgent::select_candidate (int index) const
2466 if (!m_impl->si.null ())
2467 m_impl->si->select_candidate (index);
2468 //FIXME: maybe useless
2471 if (m_impl->socket_active.is_connected ()) {
2472 m_impl->send.clear ();
2473 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2474 m_impl->send.put_data (m_impl->magic_active);
2475 m_impl->send.put_command (ISM_TRANS_CMD_SELECT_CANDIDATE);
2476 m_impl->send.put_data (index);
2477 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2483 * @brief Update our ISE is exiting.
2486 HelperAgent::update_ise_exit (void) const
2489 //FIXME: maybe useless
2491 if (m_impl->socket_active.is_connected ()) {
2492 m_impl->send.clear ();
2493 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2494 m_impl->send.put_data (m_impl->magic_active);
2495 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ISE_EXIT);
2496 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2502 * @brief Request to reset keyboard ISE.
2505 HelperAgent::reset_keyboard_ise (void) const
2508 //FIXME: maybe useless
2510 if (m_impl->socket_active.is_connected ()) {
2511 m_impl->send.clear ();
2512 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2513 m_impl->send.put_data (m_impl->magic_active);
2514 m_impl->send.put_command (ISM_TRANS_CMD_PANEL_RESET_KEYBOARD_ISE);
2515 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2518 if (!m_impl->si.null ()) {
2519 m_impl->si->reset ();
2524 * @brief Request to flush keyboard ISE.
2527 HelperAgent::flush_keyboard_ise (void) const
2530 if (!m_impl->si.null ()) {
2531 m_impl->si->flush ();
2536 * @brief Request panel to hide ISE.
2539 HelperAgent::request_ise_hide (void) const
2542 if (m_impl->socket_active.is_connected ()) {
2543 m_impl->send.clear ();
2544 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2545 m_impl->send.put_data (m_impl->magic_active);
2546 m_impl->send.put_command (ISM_TRANS_CMD_REQUEST_ISE_HIDE);
2547 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2552 * @brief Connect a slot to Helper exit signal.
2554 * This signal is used to let the Helper exit.
2556 * The prototype of the slot is:
2558 * void exit (const HelperAgent *agent, int ic, const String &ic_uuid);
2561 * - agent The pointer to the HelperAgent object which emits this signal.
2562 * - ic An opaque handle of the currently focused input context.
2563 * - ic_uuid The UUID of the IMEngineInstance associated with the focused input context.
2566 HelperAgent::signal_connect_exit (HelperAgentSlotVoid *slot)
2568 return m_impl->signal_exit.connect (slot);
2572 * @brief Connect a slot to Helper attach input context signal.
2574 * This signal is used to attach an input context to this helper.
2576 * When an input context requst to start this helper, then this
2577 * signal will be emitted as soon as the helper is started.
2579 * When an input context want to start an already started helper,
2580 * this signal will also be emitted.
2582 * Helper can send some events back to the IMEngineInstance in this
2583 * signal-slot, to inform that it has been started sccessfully.
2585 * The prototype of the slot is:
2587 * void attach_input_context (const HelperAgent *agent, int ic, const String &ic_uuid);
2590 HelperAgent::signal_connect_attach_input_context (HelperAgentSlotVoid *slot)
2592 return m_impl->signal_attach_input_context.connect (slot);
2596 * @brief Connect a slot to Helper detach input context signal.
2598 * This signal is used to detach an input context from this helper.
2600 * When an input context requst to stop this helper, then this
2601 * signal will be emitted.
2603 * Helper shouldn't send any event back to the IMEngineInstance, because
2604 * the IMEngineInstance attached to the ic should have been destroyed.
2606 * The prototype of the slot is:
2608 * void detach_input_context (const HelperAgent *agent, int ic, const String &ic_uuid);
2611 HelperAgent::signal_connect_detach_input_context (HelperAgentSlotVoid *slot)
2613 return m_impl->signal_detach_input_context.connect (slot);
2617 * @brief Connect a slot to Helper reload config signal.
2619 * This signal is used to let the Helper reload configuration.
2621 * The prototype of the slot is:
2623 * void reload_config (const HelperAgent *agent, int ic, const String &ic_uuid);
2626 HelperAgent::signal_connect_reload_config (HelperAgentSlotVoid *slot)
2628 return m_impl->signal_reload_config.connect (slot);
2632 * @brief Connect a slot to Helper update screen signal.
2634 * This signal is used to let the Helper move its GUI to another screen.
2635 * It can only be emitted when SCIM_HELPER_NEED_SCREEN_INFO is set in HelperInfo.option.
2637 * The prototype of the slot is:
2639 * void update_screen (const HelperAgent *agent, int ic, const String &ic_uuid, int screen_number);
2642 HelperAgent::signal_connect_update_screen (HelperAgentSlotInt *slot)
2644 return m_impl->signal_update_screen.connect (slot);
2648 * @brief Connect a slot to Helper update spot location signal.
2650 * This signal is used to let the Helper move its GUI according to the current spot location.
2651 * It can only be emitted when SCIM_HELPER_NEED_SPOT_LOCATION_INFO is set in HelperInfo.option.
2653 * The prototype of the slot is:
2654 * void update_spot_location (const HelperAgent *agent, int ic, const String &ic_uuid, int x, int y);
2657 HelperAgent::signal_connect_update_spot_location (HelperAgentSlotIntInt *slot)
2659 return m_impl->signal_update_spot_location.connect (slot);
2663 * @brief Connect a slot to Helper update cursor position signal.
2665 * This signal is used to let the Helper get the cursor position information.
2667 * The prototype of the slot is:
2668 * void update_cursor_position (const HelperAgent *agent, int ic, const String &ic_uuid, int cursor_pos);
2671 HelperAgent::signal_connect_update_cursor_position (HelperAgentSlotInt *slot)
2673 return m_impl->signal_update_cursor_position.connect (slot);
2677 * @brief Connect a slot to Helper update surrounding text signal.
2679 * This signal is used to let the Helper get the surrounding text.
2681 * The prototype of the slot is:
2682 * void update_surrounding_text (const HelperAgent *agent, int ic, const String &text, int cursor);
2685 HelperAgent::signal_connect_update_surrounding_text (HelperAgentSlotInt *slot)
2687 return m_impl->signal_update_surrounding_text.connect (slot);
2691 * @brief Connect a slot to Helper update selection signal.
2693 * This signal is used to let the Helper get the selection.
2695 * The prototype of the slot is:
2696 * void update_selection (const HelperAgent *agent, int ic, const String &text);
2699 HelperAgent::signal_connect_update_selection (HelperAgentSlotVoid *slot)
2701 return m_impl->signal_update_selection.connect (slot);
2705 * @brief Connect a slot to Helper trigger property signal.
2707 * This signal is used to trigger a property registered by this Helper.
2708 * A property will be triggered when user clicks on it.
2710 * The prototype of the slot is:
2711 * void trigger_property (const HelperAgent *agent, int ic, const String &ic_uuid, const String &property);
2714 HelperAgent::signal_connect_trigger_property (HelperAgentSlotString *slot)
2716 return m_impl->signal_trigger_property.connect (slot);
2720 * @brief Connect a slot to Helper process imengine event signal.
2722 * This signal is used to deliver the events sent from IMEngine to Helper.
2724 * The prototype of the slot is:
2725 * void process_imengine_event (const HelperAgent *agent, int ic, const String &ic_uuid, const Transaction &transaction);
2728 HelperAgent::signal_connect_process_imengine_event (HelperAgentSlotTransaction *slot)
2730 return m_impl->signal_process_imengine_event.connect (slot);
2734 * @brief Connect a slot to Helper focus out signal.
2736 * This signal is used to do something when input context is focus out.
2738 * The prototype of the slot is:
2739 * void focus_out (const HelperAgent *agent, int ic, const String &ic_uuid);
2742 HelperAgent::signal_connect_focus_out (HelperAgentSlotVoid *slot)
2744 return m_impl->signal_focus_out.connect (slot);
2748 * @brief Connect a slot to Helper focus in signal.
2750 * This signal is used to do something when input context is focus in.
2752 * The prototype of the slot is:
2753 * void focus_in (const HelperAgent *agent, int ic, const String &ic_uuid);
2756 HelperAgent::signal_connect_focus_in (HelperAgentSlotVoid *slot)
2758 return m_impl->signal_focus_in.connect (slot);
2762 * @brief Connect a slot to Helper show signal.
2764 * This signal is used to show Helper ISE window.
2766 * The prototype of the slot is:
2767 * void ise_show (const HelperAgent *agent, int ic, char *buf, size_t &len);
2770 HelperAgent::signal_connect_ise_show (HelperAgentSlotIntRawVoid *slot)
2772 return m_impl->signal_ise_show.connect (slot);
2776 * @brief Connect a slot to Helper hide signal.
2778 * This signal is used to hide Helper ISE window.
2780 * The prototype of the slot is:
2781 * void ise_hide (const HelperAgent *agent, int ic, const String &ic_uuid);
2784 HelperAgent::signal_connect_ise_hide (HelperAgentSlotVoid *slot)
2786 return m_impl->signal_ise_hide.connect (slot);
2790 * @brief Connect a slot to Helper get ISE window geometry signal.
2792 * This signal is used to get Helper ISE window size and position.
2794 * The prototype of the slot is:
2795 * void get_geometry (const HelperAgent *agent, struct rectinfo &info);
2798 HelperAgent::signal_connect_get_geometry (HelperAgentSlotSize *slot)
2800 return m_impl->signal_get_geometry.connect (slot);
2804 * @brief Connect a slot to Helper set mode signal.
2806 * This signal is used to set Helper ISE mode.
2808 * The prototype of the slot is:
2809 * void set_mode (const HelperAgent *agent, uint32 &mode);
2812 HelperAgent::signal_connect_set_mode (HelperAgentSlotUintVoid *slot)
2814 return m_impl->signal_set_mode.connect (slot);
2818 * @brief Connect a slot to Helper set language signal.
2820 * This signal is used to set Helper ISE language.
2822 * The prototype of the slot is:
2823 * void set_language (const HelperAgent *agent, uint32 &language);
2826 HelperAgent::signal_connect_set_language (HelperAgentSlotUintVoid *slot)
2828 return m_impl->signal_set_language.connect (slot);
2832 * @brief Connect a slot to Helper set im data signal.
2834 * This signal is used to send im data to Helper ISE.
2836 * The prototype of the slot is:
2837 * void set_imdata (const HelperAgent *agent, char *buf, size_t &len);
2840 HelperAgent::signal_connect_set_imdata (HelperAgentSlotRawVoid *slot)
2842 return m_impl->signal_set_imdata.connect (slot);
2846 * @brief Connect a slot to Helper get im data signal.
2848 * This signal is used to get im data from Helper ISE.
2850 * The prototype of the slot is:
2851 * void get_imdata (const HelperAgent *, char **buf, size_t &len);
2854 HelperAgent::signal_connect_get_imdata (HelperAgentSlotGetRawVoid *slot)
2856 return m_impl->signal_get_imdata.connect (slot);
2860 * @brief Connect a slot to Helper get language locale signal.
2862 * This signal is used to get language locale from Helper ISE.
2864 * The prototype of the slot is:
2865 * void get_language_locale (const HelperAgent *, int ic, char **locale);
2868 HelperAgent::signal_connect_get_language_locale (HelperAgentSlotIntGetStringVoid *slot)
2870 return m_impl->signal_get_language_locale.connect (slot);
2874 * @brief Connect a slot to Helper set return key type signal.
2876 * This signal is used to send return key type to Helper ISE.
2878 * The prototype of the slot is:
2879 * void set_return_key_type (const HelperAgent *agent, uint32 &type);
2882 HelperAgent::signal_connect_set_return_key_type (HelperAgentSlotUintVoid *slot)
2884 return m_impl->signal_set_return_key_type.connect (slot);
2888 * @brief Connect a slot to Helper get return key type signal.
2890 * This signal is used to get return key type from Helper ISE.
2892 * The prototype of the slot is:
2893 * void get_return_key_type (const HelperAgent *agent, uint32 &type);
2896 HelperAgent::signal_connect_get_return_key_type (HelperAgentSlotUintVoid *slot)
2898 return m_impl->signal_get_return_key_type.connect (slot);
2902 * @brief Connect a slot to Helper set return key disable signal.
2904 * This signal is used to send return key disable to Helper ISE.
2906 * The prototype of the slot is:
2907 * void set_return_key_disable (const HelperAgent *agent, uint32 &disabled);
2910 HelperAgent::signal_connect_set_return_key_disable (HelperAgentSlotUintVoid *slot)
2912 return m_impl->signal_set_return_key_disable.connect (slot);
2916 * @brief Connect a slot to Helper process key event signal.
2918 * This signal is used to send keyboard key event to Helper ISE.
2920 * The prototype of the slot is:
2921 * void process_key_event (const HelperAgent *agent, KeyEvent &key, uint32 &ret);
2924 HelperAgent::signal_connect_process_key_event (HelperAgentSlotKeyEventUint *slot)
2926 return m_impl->signal_process_key_event.connect (slot);
2930 * @brief Connect a slot to Helper get return key disable signal.
2932 * This signal is used to get return key disable from Helper ISE.
2934 * The prototype of the slot is:
2935 * void get_return_key_disable (const HelperAgent *agent, uint32 &disabled);
2938 HelperAgent::signal_connect_get_return_key_disable (HelperAgentSlotUintVoid *slot)
2940 return m_impl->signal_get_return_key_disable.connect (slot);
2944 * @brief Connect a slot to Helper set layout signal.
2946 * This signal is used to set Helper ISE layout.
2948 * The prototype of the slot is:
2949 * void set_layout (const HelperAgent *agent, uint32 &layout);
2952 HelperAgent::signal_connect_set_layout (HelperAgentSlotUintVoid *slot)
2954 return m_impl->signal_set_layout.connect (slot);
2958 * @brief Connect a slot to Helper get layout signal.
2960 * This signal is used to get Helper ISE layout.
2962 * The prototype of the slot is:
2963 * void get_layout (const HelperAgent *agent, uint32 &layout);
2966 HelperAgent::signal_connect_get_layout (HelperAgentSlotUintVoid *slot)
2968 return m_impl->signal_get_layout.connect (slot);
2972 * @brief Connect a slot to Helper set input mode signal.
2974 * This signal is used to set Helper ISE input mode.
2976 * The prototype of the slot is:
2977 * void set_input_mode (const HelperAgent *agent, uint32 &input_mode);
2980 HelperAgent::signal_connect_set_input_mode (HelperAgentSlotUintVoid *slot)
2982 return m_impl->signal_set_input_mode.connect (slot);
2986 * @brief Connect a slot to Helper set input hint signal.
2988 * This signal is used to set Helper ISE input hint.
2990 * The prototype of the slot is:
2991 * void set_input_hint (const HelperAgent *agent, uint32 &input_hint);
2994 HelperAgent::signal_connect_set_input_hint (HelperAgentSlotUintVoid *slot)
2996 return m_impl->signal_set_input_hint.connect (slot);
3000 * @brief Connect a slot to Helper set BiDi direction signal.
3002 * This signal is used to set Helper ISE BiDi direction.
3004 * The prototype of the slot is:
3005 * void update_bidi_direction (const HelperAgent *agent, uint32 &bidi_direction);
3008 HelperAgent::signal_connect_update_bidi_direction (HelperAgentSlotUintVoid *slot)
3010 return m_impl->signal_update_bidi_direction.connect (slot);
3014 * @brief Connect a slot to Helper set shift mode signal.
3016 * This signal is used to set Helper shift mode.
3018 * The prototype of the slot is:
3019 * void set_caps_mode (const HelperAgent *agent, uint32 &mode);
3022 HelperAgent::signal_connect_set_caps_mode (HelperAgentSlotUintVoid *slot)
3024 return m_impl->signal_set_caps_mode.connect (slot);
3028 * @brief Connect a slot to Helper reset input context signal.
3030 * This signal is used to reset Helper ISE input context.
3032 * The prototype of the slot is:
3033 * void reset_input_context (const HelperAgent *agent, int ic, const String &uuid);
3036 HelperAgent::signal_connect_reset_input_context (HelperAgentSlotVoid *slot)
3038 return m_impl->signal_reset_input_context.connect (slot);
3042 * @brief Connect a slot to Helper update candidate window geometry signal.
3044 * This signal is used to get candidate window size and position.
3046 * The prototype of the slot is:
3047 * void update_candidate_geometry (const HelperAgent *agent, int ic, const String &uuid, const rectinfo &info);
3050 HelperAgent::signal_connect_update_candidate_geometry (HelperAgentSlotRect *slot)
3052 return m_impl->signal_update_candidate_geometry.connect (slot);
3056 * @brief Connect a slot to Helper update keyboard ISE signal.
3058 * This signal is used to get current keyboard ISE name and uuid.
3060 * The prototype of the slot is:
3061 * void update_keyboard_ise (const HelperAgent *agent, int ic, const String &uuid,
3062 * const String &ise_name, const String &ise_uuid);
3065 HelperAgent::signal_connect_update_keyboard_ise (HelperAgentSlotString2 *slot)
3067 return m_impl->signal_update_keyboard_ise.connect (slot);
3071 * @brief Connect a slot to Helper update keyboard ISE list signal.
3073 * This signal is used to get uuid list of all keyboard ISEs.
3075 * The prototype of the slot is:
3076 * void update_keyboard_ise_list (const HelperAgent *agent, int ic, const String &uuid,
3077 * const std::vector<String> &ise_list);
3080 HelperAgent::signal_connect_update_keyboard_ise_list (HelperAgentSlotStringVector *slot)
3082 return m_impl->signal_update_keyboard_ise_list.connect (slot);
3086 * @brief Connect a slot to Helper candidate more window show signal.
3088 * This signal is used to do someting when candidate more window is showed.
3090 * The prototype of the slot is:
3091 * void candidate_more_window_show (const HelperAgent *agent, int ic, const String &uuid);
3094 HelperAgent::signal_connect_candidate_more_window_show (HelperAgentSlotVoid *slot)
3096 return m_impl->signal_candidate_more_window_show.connect (slot);
3100 * @brief Connect a slot to Helper candidate more window hide signal.
3102 * This signal is used to do someting when candidate more window is hidden.
3104 * The prototype of the slot is:
3105 * void candidate_more_window_hide (const HelperAgent *agent, int ic, const String &uuid);
3108 HelperAgent::signal_connect_candidate_more_window_hide (HelperAgentSlotVoid *slot)
3110 return m_impl->signal_candidate_more_window_hide.connect (slot);
3114 * @brief Connect a slot to Helper candidate show signal.
3116 * This signal is used to do candidate show.
3118 * The prototype of the slot is:
3119 * void candidate_show (const HelperAgent *agent, int ic, const String &uuid);
3122 HelperAgent::signal_connect_candidate_show (HelperAgentSlotVoid *slot)
3124 return m_impl->signal_candidate_show.connect (slot);
3128 * @brief Connect a slot to Helper candidate hide signal.
3130 * This signal is used to do candidate hide.
3132 * The prototype of the slot is:
3133 * void candidate_hide (const HelperAgent *agent, int ic, const String &uuid);
3136 HelperAgent::signal_connect_candidate_hide (HelperAgentSlotVoid *slot)
3138 return m_impl->signal_candidate_hide.connect (slot);
3142 * @brief Connect a slot to Helper update lookup table signal.
3144 * This signal is used to do someting when update lookup table.
3146 * The prototype of the slot is:
3147 * void update_lookup_table (const HelperAgent *agent, int ic, const String &uuid ,LookupTable &table);
3150 HelperAgent::signal_connect_update_lookup_table (HelperAgentSlotLookupTable *slot)
3152 return m_impl->signal_update_lookup_table.connect (slot);
3156 * @brief Connect a slot to Helper select aux signal.
3158 * This signal is used to do something when aux is selected.
3160 * The prototype of the slot is:
3161 * void select_aux (const HelperAgent *agent, int ic, const String &uuid, int index);
3164 HelperAgent::signal_connect_select_aux (HelperAgentSlotInt *slot)
3166 return m_impl->signal_select_aux.connect (slot);
3170 * @brief Connect a slot to Helper select candidate signal.
3172 * This signal is used to do something when candidate is selected.
3174 * The prototype of the slot is:
3175 * void select_candidate (const HelperAgent *agent, int ic, const String &uuid, int index);
3178 HelperAgent::signal_connect_select_candidate (HelperAgentSlotInt *slot)
3180 return m_impl->signal_select_candidate.connect (slot);
3184 * @brief Connect a slot to Helper candidate table page up signal.
3186 * This signal is used to do something when candidate table is paged up.
3188 * The prototype of the slot is:
3189 * void candidate_table_page_up (const HelperAgent *agent, int ic, const String &uuid);
3192 HelperAgent::signal_connect_candidate_table_page_up (HelperAgentSlotVoid *slot)
3194 return m_impl->signal_candidate_table_page_up.connect (slot);
3198 * @brief Connect a slot to Helper candidate table page down signal.
3200 * This signal is used to do something when candidate table is paged down.
3202 * The prototype of the slot is:
3203 * void candidate_table_page_down (const HelperAgent *agent, int ic, const String &uuid);
3206 HelperAgent::signal_connect_candidate_table_page_down (HelperAgentSlotVoid *slot)
3208 return m_impl->signal_candidate_table_page_down.connect (slot);
3212 * @brief Connect a slot to Helper update candidate table page size signal.
3214 * This signal is used to do something when candidate table page size is changed.
3216 * The prototype of the slot is:
3217 * void update_candidate_table_page_size (const HelperAgent *, int ic, const String &uuid, int page_size);
3220 HelperAgent::signal_connect_update_candidate_table_page_size (HelperAgentSlotInt *slot)
3222 return m_impl->signal_update_candidate_table_page_size.connect (slot);
3226 * @brief Connect a slot to Helper update candidate item layout signal.
3228 * The prototype of the slot is:
3229 * void update_candidate_item_layout (const HelperAgent *, const std::vector<uint32> &row_items);
3232 HelperAgent::signal_connect_update_candidate_item_layout (HelperAgentSlotUintVector *slot)
3234 return m_impl->signal_update_candidate_item_layout.connect (slot);
3238 * @brief Connect a slot to Helper select associate signal.
3240 * This signal is used to do something when associate is selected.
3242 * The prototype of the slot is:
3243 * void select_associate (const HelperAgent *agent, int ic, const String &uuid, int index);
3246 HelperAgent::signal_connect_select_associate (HelperAgentSlotInt *slot)
3248 return m_impl->signal_select_associate.connect (slot);
3252 * @brief Connect a slot to Helper associate table page up signal.
3254 * This signal is used to do something when associate table is paged up.
3256 * The prototype of the slot is:
3257 * void associate_table_page_up (const HelperAgent *agent, int ic, const String &uuid);
3260 HelperAgent::signal_connect_associate_table_page_up (HelperAgentSlotVoid *slot)
3262 return m_impl->signal_associate_table_page_up.connect (slot);
3266 * @brief Connect a slot to Helper associate table page down signal.
3268 * This signal is used to do something when associate table is paged down.
3270 * The prototype of the slot is:
3271 * void associate_table_page_down (const HelperAgent *agent, int ic, const String &uuid);
3274 HelperAgent::signal_connect_associate_table_page_down (HelperAgentSlotVoid *slot)
3276 return m_impl->signal_associate_table_page_down.connect (slot);
3280 * @brief Connect a slot to Helper update associate table page size signal.
3282 * This signal is used to do something when associate table page size is changed.
3284 * The prototype of the slot is:
3285 * void update_associate_table_page_size (const HelperAgent *, int ic, const String &uuid, int page_size);
3288 HelperAgent::signal_connect_update_associate_table_page_size (HelperAgentSlotInt *slot)
3290 return m_impl->signal_update_associate_table_page_size.connect (slot);
3294 * @brief Connect a slot to Helper turn on log signal.
3296 * This signal is used to turn on Helper ISE debug information.
3298 * The prototype of the slot is:
3299 * void turn_on_log (const HelperAgent *agent, uint32 &on);
3302 HelperAgent::signal_connect_turn_on_log (HelperAgentSlotUintVoid *slot)
3304 return m_impl->signal_turn_on_log.connect (slot);
3308 * @brief Connect a slot to Helper update displayed candidate number signal.
3310 * This signal is used to inform helper ISE displayed candidate number.
3312 * The prototype of the slot is:
3313 * void update_displayed_candidate_number (const HelperAgent *, int ic, const String &uuid, int number);
3316 HelperAgent::signal_connect_update_displayed_candidate_number (HelperAgentSlotInt *slot)
3318 return m_impl->signal_update_displayed_candidate_number.connect (slot);
3322 * @brief Connect a slot to Helper longpress candidate signal.
3324 * This signal is used to do something when candidate is longpress.
3326 * The prototype of the slot is:
3327 * void longpress_candidate (const HelperAgent *agent, int ic, const String &uuid, int index);
3330 HelperAgent::signal_connect_longpress_candidate (HelperAgentSlotInt *slot)
3332 return m_impl->signal_longpress_candidate.connect (slot);
3336 * @brief Connect a slot to Helper show option window.
3338 * This signal is used to do request the ISE to show option window.
3340 * The prototype of the slot is:
3341 * void show_option_window (const HelperAgent *agent, int ic, const String &uuid);
3344 HelperAgent::signal_connect_show_option_window (HelperAgentSlotVoid *slot)
3346 return m_impl->signal_show_option_window.connect (slot);
3350 * @brief Connect a slot to Helper resume option window.
3352 * This signal is used to do request the ISE to resume option window.
3354 * The prototype of the slot is:
3355 * void resume_option_window (const HelperAgent *agent, int ic, const String &uuid);
3358 HelperAgent::signal_connect_resume_option_window (HelperAgentSlotVoid *slot)
3360 return m_impl->signal_resume_option_window.connect (slot);
3364 * @brief Connect a slot to Helper check if the option is available.
3366 * This signal is used to check if the option (setting) is available from Helper ISE.
3368 * The prototype of the slot is:
3369 * void check_option_window (const HelperAgent *agent, uint32 &avail);
3372 HelperAgent::signal_connect_check_option_window (HelperAgentSlotUintVoid *slot)
3374 return m_impl->signal_check_option_window.connect (slot);
3378 * @brief Connect a slot to Helper process unconventional input device event signal.
3380 * This signal is used to send unconventional input device event to Helper ISE.
3382 * The prototype of the slot is:
3383 * void process_input_device_event (const HelperAgent *, uint32 &type, char *data, size_t &size, uint32 &ret);
3386 HelperAgent::signal_connect_process_input_device_event (HelperAgentSlotUintCharSizeUint *slot)
3388 return m_impl->signal_process_input_device_event.connect (slot);
3391 } /* namespace scim */
3394 vi:ts=4:nowrap:ai:expandtab