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 #include "tizen_profile.h"
61 #ifdef HAVE_PKGMGR_INFO
62 #include <pkgmgr-info.h>
63 #endif // HAVE_PKGMGR_INFO
68 #define LOG_TAG "SCIM_HELPER"
71 //FIXME: remove this definitions
72 #define SHIFT_MODE_OFF 0xffe1
73 #define SHIFT_MODE_ON 0xffe2
74 #define SHIFT_MODE_LOCK 0xffe6
75 #define SHIFT_MODE_ENABLE 0x9fe7
76 #define SHIFT_MODE_DISABLE 0x9fe8
80 typedef Signal3<void, const HelperAgent *, int, const String &>
81 HelperAgentSignalVoid;
83 typedef Signal4<void, const HelperAgent *, int, const String &, const String &>
84 HelperAgentSignalString;
86 typedef Signal4<void, const HelperAgent *, int, const String &, const std::vector<String> &>
87 HelperAgentSignalStringVector;
89 typedef Signal5<void, const HelperAgent *, int, const String &, const String &, const String &>
90 HelperAgentSignalString2;
92 typedef Signal4<void, const HelperAgent *, int, const String &, int>
95 typedef Signal5<void, const HelperAgent *, int, const String &, int, int>
96 HelperAgentSignalIntInt;
98 typedef Signal4<void, const HelperAgent *, int, const String &, const Transaction &>
99 HelperAgentSignalTransaction;
101 typedef Signal4<void, const HelperAgent *, int, const String &, const rectinfo &>
102 HelperAgentSignalRect;
104 typedef Signal2<void, const HelperAgent *, struct rectinfo &>
105 HelperAgentSignalSize;
107 typedef Signal2<void, const HelperAgent *, uint32 &>
108 HelperAgentSignalUintVoid;
110 typedef Signal3<void, const HelperAgent *, int, uint32 &>
111 HelperAgentSignalIntUint;
113 typedef Signal3 <void, const HelperAgent *, char *, size_t &>
114 HelperAgentSignalRawVoid;
116 typedef Signal3 <void, const HelperAgent *, char **, size_t &>
117 HelperAgentSignalGetRawVoid;
119 typedef Signal4 <void, const HelperAgent *, int, char *, size_t &>
120 HelperAgentSignalIntRawVoid;
122 typedef Signal3 <void, const HelperAgent *, int, char **>
123 HelperAgentSignalIntGetStringVoid;
125 typedef Signal2<void, const HelperAgent *, const std::vector<uint32> &>
126 HelperAgentSignalUintVector;
128 typedef Signal2<void, const HelperAgent *, LookupTable &>
129 HelperAgentSignalLookupTable;
131 typedef Signal3<void, const HelperAgent *, KeyEvent &, uint32 &>
132 HelperAgentSignalKeyEventUint;
134 typedef Signal5<void, const HelperAgent *, uint32 &, char *, size_t &, uint32 &>
135 HelperAgentSignalUintCharSizeUint;
137 typedef Signal2<void, const HelperAgent *, const String &>
138 HelperAgentSignalStringVoid;
140 class HelperAgent::HelperAgentImpl
144 SocketClient socket_active;
153 IMEngineInstancePointer si;
154 ConfigPointer m_config;
155 IMEngineModule engine_module;
157 char* surrounding_text;
158 char* selection_text;
160 int need_update_surrounding_text;
161 int need_update_selection_text;
164 bool hw_keyboard_mode;
166 HelperAgentSignalVoid signal_exit;
167 HelperAgentSignalVoid signal_attach_input_context;
168 HelperAgentSignalVoid signal_detach_input_context;
169 HelperAgentSignalVoid signal_reload_config;
170 HelperAgentSignalInt signal_update_screen;
171 HelperAgentSignalIntInt signal_update_spot_location;
172 HelperAgentSignalInt signal_update_cursor_position;
173 HelperAgentSignalInt signal_update_surrounding_text;
174 HelperAgentSignalVoid signal_update_selection;
175 HelperAgentSignalString signal_trigger_property;
176 HelperAgentSignalTransaction signal_process_imengine_event;
177 HelperAgentSignalVoid signal_focus_out;
178 HelperAgentSignalVoid signal_focus_in;
179 HelperAgentSignalIntRawVoid signal_ise_show;
180 HelperAgentSignalVoid signal_ise_hide;
181 HelperAgentSignalVoid signal_candidate_show;
182 HelperAgentSignalVoid signal_candidate_hide;
183 HelperAgentSignalSize signal_get_geometry;
184 HelperAgentSignalUintVoid signal_set_mode;
185 HelperAgentSignalUintVoid signal_set_language;
186 HelperAgentSignalRawVoid signal_set_imdata;
187 HelperAgentSignalGetRawVoid signal_get_imdata;
188 HelperAgentSignalIntGetStringVoid signal_get_language_locale;
189 HelperAgentSignalUintVoid signal_set_return_key_type;
190 HelperAgentSignalUintVoid signal_get_return_key_type;
191 HelperAgentSignalUintVoid signal_set_return_key_disable;
192 HelperAgentSignalUintVoid signal_get_return_key_disable;
193 HelperAgentSignalUintVoid signal_set_layout;
194 HelperAgentSignalUintVoid signal_get_layout;
195 HelperAgentSignalUintVoid signal_set_caps_mode;
196 HelperAgentSignalVoid signal_reset_input_context;
197 HelperAgentSignalIntInt signal_update_candidate_ui;
198 HelperAgentSignalRect signal_update_candidate_geometry;
199 HelperAgentSignalString2 signal_update_keyboard_ise;
200 HelperAgentSignalStringVector signal_update_keyboard_ise_list;
201 HelperAgentSignalVoid signal_candidate_more_window_show;
202 HelperAgentSignalVoid signal_candidate_more_window_hide;
203 HelperAgentSignalLookupTable signal_update_lookup_table;
204 HelperAgentSignalInt signal_select_aux;
205 HelperAgentSignalInt signal_select_candidate;
206 HelperAgentSignalVoid signal_candidate_table_page_up;
207 HelperAgentSignalVoid signal_candidate_table_page_down;
208 HelperAgentSignalInt signal_update_candidate_table_page_size;
209 HelperAgentSignalUintVector signal_update_candidate_item_layout;
210 HelperAgentSignalInt signal_select_associate;
211 HelperAgentSignalVoid signal_associate_table_page_up;
212 HelperAgentSignalVoid signal_associate_table_page_down;
213 HelperAgentSignalInt signal_update_associate_table_page_size;
214 HelperAgentSignalVoid signal_reset_ise_context;
215 HelperAgentSignalUintVoid signal_turn_on_log;
216 HelperAgentSignalInt signal_update_displayed_candidate_number;
217 HelperAgentSignalInt signal_longpress_candidate;
218 HelperAgentSignalKeyEventUint signal_process_key_event;
219 HelperAgentSignalUintVoid signal_set_input_mode;
220 HelperAgentSignalUintVoid signal_set_input_hint;
221 HelperAgentSignalUintVoid signal_update_bidi_direction;
222 HelperAgentSignalVoid signal_show_option_window;
223 HelperAgentSignalVoid signal_resume_option_window;
224 HelperAgentSignalUintVoid signal_check_option_window;
225 HelperAgentSignalUintCharSizeUint signal_process_input_device_event;
226 HelperAgentSignalStringVoid signal_set_prediction_hint;
229 HelperAgentImpl (HelperAgent* thiz) : magic(0), magic_active(0), timeout(-1), focused_ic ((uint32) -1), thiz (thiz),
230 surrounding_text (NULL), selection_text (NULL), cursor_pos (0),
231 need_update_surrounding_text (0), need_update_selection_text (0),
232 layout (0), ise_show_flag (false), hw_keyboard_mode (false) {
235 ~HelperAgentImpl () {
240 if (surrounding_text != NULL)
241 free (surrounding_text);
243 if (selection_text != NULL)
244 free (selection_text);
246 if (engine_module.valid ()) {
247 engine_module.unload ();
251 // Implementation of slot functions
253 slot_show_preedit_string (IMEngineInstanceBase *si)
256 thiz->show_preedit_string (focused_ic, "");
260 slot_show_aux_string (IMEngineInstanceBase *si)
263 thiz->show_aux_string ();
267 slot_show_lookup_table (IMEngineInstanceBase *si)
270 thiz->show_candidate_string ();
274 slot_hide_preedit_string (IMEngineInstanceBase *si)
277 thiz->hide_preedit_string (focused_ic, "");
281 slot_hide_aux_string (IMEngineInstanceBase *si)
284 thiz->hide_aux_string ();
288 slot_hide_lookup_table (IMEngineInstanceBase *si)
291 thiz->hide_candidate_string ();
295 slot_update_preedit_caret (IMEngineInstanceBase *si, int caret)
298 thiz->update_preedit_caret (caret);
302 slot_update_preedit_string (IMEngineInstanceBase *si,
303 const WideString & str,
304 const AttributeList & attrs,
308 thiz->update_preedit_string (-1, "", str, attrs, caret);
312 slot_update_preedit_string_with_commit (IMEngineInstanceBase *si,
313 const WideString & preedit,
314 const WideString & commit,
315 const AttributeList & attrs,
319 thiz->update_preedit_string (-1, "", preedit, commit, attrs, caret);
323 slot_update_aux_string (IMEngineInstanceBase *si,
324 const WideString & str,
325 const AttributeList & attrs)
328 thiz->update_aux_string (utf8_wcstombs(str), attrs);
332 slot_commit_string (IMEngineInstanceBase *si,
333 const WideString & str)
336 thiz->commit_string (-1, "", str);
340 slot_recapture_string (IMEngineInstanceBase *si,
343 const WideString & preedit,
344 const WideString & commit,
345 const AttributeList & attrs)
348 thiz->recapture_string (-1, "", offset, len, preedit, commit, attrs);
352 slot_forward_key_event (IMEngineInstanceBase *si,
353 const KeyEvent & key)
356 thiz->forward_key_event (-1, "", key);
360 slot_update_lookup_table (IMEngineInstanceBase *si,
361 const LookupTable & table)
364 thiz->update_candidate_string (table);
368 slot_register_properties (IMEngineInstanceBase *si,
369 const PropertyList & properties)
372 thiz->register_properties (properties);
376 slot_update_property (IMEngineInstanceBase *si,
377 const Property & property)
380 thiz->update_property (property);
384 slot_beep (IMEngineInstanceBase *si)
391 slot_start_helper (IMEngineInstanceBase *si,
392 const String &helper_uuid)
394 LOGW ("deprecated function");
398 slot_stop_helper (IMEngineInstanceBase *si,
399 const String &helper_uuid)
401 LOGW ("deprecated function");
405 slot_send_helper_event (IMEngineInstanceBase *si,
406 const String &helper_uuid,
407 const Transaction &trans)
410 signal_process_imengine_event (thiz, focused_ic, helper_uuid, trans);
414 slot_get_surrounding_text (IMEngineInstanceBase *si,
422 thiz->get_surrounding_text (maxlen_before, maxlen_after, _text, cursor);
423 text = utf8_mbstowcs(_text);
428 slot_delete_surrounding_text (IMEngineInstanceBase *si,
434 thiz->delete_surrounding_text (offset, len);
439 slot_get_selection (IMEngineInstanceBase *si,
444 thiz->get_selection_text (_text);
445 text = utf8_mbstowcs (_text);
450 slot_set_selection (IMEngineInstanceBase *si,
455 thiz->set_selection (start, end);
460 slot_expand_candidate (IMEngineInstanceBase *si)
463 thiz->expand_candidate ();
467 slot_contract_candidate (IMEngineInstanceBase *si)
470 thiz->contract_candidate ();
474 slot_set_candidate_style (IMEngineInstanceBase *si, ISF_CANDIDATE_PORTRAIT_LINE_T portrait_line, ISF_CANDIDATE_MODE_T mode)
477 thiz->set_candidate_style (portrait_line, mode);
481 slot_send_private_command (IMEngineInstanceBase *si,
482 const String &command)
485 thiz->send_private_command (command);
489 slot_commit_content (IMEngineInstanceBase *si,
490 const String &content,
491 const String &description,
492 const String &mime_types)
495 thiz->commit_content (content, description, mime_types);
501 si->signal_connect_show_preedit_string (
502 slot (this, &HelperAgent::HelperAgentImpl::slot_show_preedit_string));
503 si->signal_connect_show_aux_string (
504 slot (this, &HelperAgent::HelperAgentImpl::slot_show_aux_string));
505 si->signal_connect_show_lookup_table (
506 slot (this, &HelperAgent::HelperAgentImpl::slot_show_lookup_table));
508 si->signal_connect_hide_preedit_string (
509 slot (this, &HelperAgent::HelperAgentImpl::slot_hide_preedit_string));
510 si->signal_connect_hide_aux_string (
511 slot (this, &HelperAgent::HelperAgentImpl::slot_hide_aux_string));
512 si->signal_connect_hide_lookup_table (
513 slot (this, &HelperAgent::HelperAgentImpl::slot_hide_lookup_table));
515 si->signal_connect_update_preedit_caret (
516 slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_caret));
517 si->signal_connect_update_preedit_string (
518 slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_string));
519 si->signal_connect_update_preedit_string_with_commit (
520 slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_string_with_commit));
521 si->signal_connect_recapture_string (
522 slot (this, &HelperAgent::HelperAgentImpl::slot_recapture_string));
524 si->signal_connect_update_aux_string (
525 slot (this, &HelperAgent::HelperAgentImpl::slot_update_aux_string));
526 si->signal_connect_update_lookup_table (
527 slot (this, &HelperAgent::HelperAgentImpl::slot_update_lookup_table));
529 si->signal_connect_commit_string (
530 slot (this, &HelperAgent::HelperAgentImpl::slot_commit_string));
532 si->signal_connect_forward_key_event (
533 slot (this, &HelperAgent::HelperAgentImpl::slot_forward_key_event));
535 si->signal_connect_register_properties (
536 slot (this, &HelperAgent::HelperAgentImpl::slot_register_properties));
538 si->signal_connect_update_property (
539 slot (this, &HelperAgent::HelperAgentImpl::slot_update_property));
541 si->signal_connect_beep (
542 slot (this, &HelperAgent::HelperAgentImpl::slot_beep));
544 si->signal_connect_start_helper (
545 slot (this, &HelperAgent::HelperAgentImpl::slot_start_helper));
547 si->signal_connect_stop_helper (
548 slot (this, &HelperAgent::HelperAgentImpl::slot_stop_helper));
550 si->signal_connect_send_helper_event (
551 slot (this, &HelperAgent::HelperAgentImpl::slot_send_helper_event));
553 si->signal_connect_get_surrounding_text (
554 slot (this, &HelperAgent::HelperAgentImpl::slot_get_surrounding_text));
556 si->signal_connect_delete_surrounding_text (
557 slot (this, &HelperAgent::HelperAgentImpl::slot_delete_surrounding_text));
559 si->signal_connect_get_selection (
560 slot (this, &HelperAgent::HelperAgentImpl::slot_get_selection));
562 si->signal_connect_set_selection (
563 slot (this, &HelperAgent::HelperAgentImpl::slot_set_selection));
565 si->signal_connect_expand_candidate (
566 slot (this, &HelperAgent::HelperAgentImpl::slot_expand_candidate));
567 si->signal_connect_contract_candidate (
568 slot (this, &HelperAgent::HelperAgentImpl::slot_contract_candidate));
570 si->signal_connect_set_candidate_style (
571 slot (this, &HelperAgent::HelperAgentImpl::slot_set_candidate_style));
573 si->signal_connect_send_private_command (
574 slot (this, &HelperAgent::HelperAgentImpl::slot_send_private_command));
577 void process_key_event_done (KeyEvent &key, uint32 ret, uint32 serial) {
578 LOGD ("ret: %d, serial: %d", ret, serial);
579 if (socket_active.is_connected ()) {
581 send.put_command (SCIM_TRANS_CMD_REQUEST);
582 send.put_data (magic_active);
583 send.put_command (ISM_TRANS_CMD_PROCESS_KEY_EVENT_DONE);
586 send.put_data (serial);
587 send.write_to_socket (socket_active, magic_active);
591 void request_ise_hide () {
592 if (socket_active.is_connected ()) {
594 send.put_command (SCIM_TRANS_CMD_REQUEST);
595 send.put_data (magic_active);
596 send.put_command (ISM_TRANS_CMD_REQUEST_ISE_HIDE);
597 send.write_to_socket (socket_active, magic_active);
601 HelperAgentImpl () : magic (0), magic_active (0), timeout (-1), focused_ic ((uint32) -1) { }
604 static MessageQueue message_queue;
606 HelperAgent::HelperAgent ()
607 : m_impl (new HelperAgentImpl (this))
609 message_queue.create();
612 HelperAgent::~HelperAgent ()
614 message_queue.destroy();
619 * @brief Open socket connection to the Panel.
621 * @param info The information of this Helper object.
622 * @param display The display which this Helper object should run on.
624 * @return The connection socket id. -1 means failed to create
628 HelperAgent::open_connection (const HelperInfo &info,
629 const String &display)
631 if (m_impl->socket.is_connected ())
634 SocketAddress address (scim_get_default_panel_socket_address (display));
635 int timeout = m_impl->timeout = scim_get_default_socket_timeout ();
638 if (!address.valid ())
642 std::cerr << " Connecting to PanelAgent server.";
643 ISF_LOG (" Connecting to PanelAgent server.\n");
644 while (!m_impl->socket.connect (address)) {
646 scim_usleep (100000);
648 std::cerr << "m_impl->socket.connect () is failed!!!\n";
649 ISF_LOG ("m_impl->socket.connect () is failed!!!\n");
653 std::cerr << " Connected :" << i << "\n";
654 ISF_LOG (" Connected :%d\n", i);
655 LOGD ("Connection to PanelAgent succeeded, %d\n", i);
657 /* Let's retry 10 times when failed */
658 int open_connection_retries = 0;
659 while (!scim_socket_open_connection (magic,
664 if (++open_connection_retries > 10) {
665 m_impl->socket.close ();
666 std::cerr << "scim_socket_open_connection () is failed!!!\n";
667 ISF_LOG ("scim_socket_open_connection () is failed!!!\n");
668 ISF_SAVE_LOG ("scim_socket_open_connection failed, %d\n", timeout);
673 /* Retry after re-connecting the socket */
674 if (m_impl->socket.is_connected ())
677 /* This time, just retry atmost 2 seconds */
679 while (!m_impl->socket.connect (address) && ++i < 10) {
680 scim_usleep (200000);
684 ISF_LOG ("scim_socket_open_connection () is successful.\n");
685 LOGD ("scim_socket_open_connection successful\n");
687 m_impl->send.clear ();
688 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
689 m_impl->send.put_data (magic);
690 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_REGISTER_HELPER);
691 m_impl->send.put_data (info.uuid);
692 m_impl->send.put_data (info.name);
693 m_impl->send.put_data (info.icon);
694 m_impl->send.put_data (info.description);
695 m_impl->send.put_data (info.option);
697 if (!m_impl->send.write_to_socket (m_impl->socket, magic)) {
698 m_impl->socket.close ();
703 if (m_impl->recv.read_from_socket (m_impl->socket, timeout) &&
704 m_impl->recv.get_command (cmd) && cmd == SCIM_TRANS_CMD_REPLY &&
705 m_impl->recv.get_command (cmd) && cmd == SCIM_TRANS_CMD_OK) {
706 m_impl->magic = magic;
708 while (m_impl->recv.get_command (cmd)) {
710 case SCIM_TRANS_CMD_HELPER_ATTACH_INPUT_CONTEXT:
714 while (m_impl->recv.get_data (ic) && m_impl->recv.get_data (ic_uuid))
715 m_impl->signal_attach_input_context (this, ic, ic_uuid);
718 case SCIM_TRANS_CMD_UPDATE_SCREEN:
721 if (m_impl->recv.get_data (screen))
722 m_impl->signal_update_screen (this, (uint32) -1, String (""), (int) screen);
730 //FIXME: Attaching input context is needed for desktop environment
731 LOGW ("Attach input context and update screen failed");
734 ISF_SAVE_LOG ("Trying connect() with Helper_Active\n");
736 /* connect to the panel agent as the active helper client */
737 if (!m_impl->socket_active.connect (address)) return -1;
738 open_connection_retries = 0;
739 while (!scim_socket_open_connection (magic,
740 String ("Helper_Active"),
742 m_impl->socket_active,
744 if (++open_connection_retries > 10) {
745 m_impl->socket_active.close ();
746 std::cerr << "Helper_Active scim_socket_open_connection () is failed!!!\n";
747 ISF_LOG ("Helper_Active scim_socket_open_connection () is failed!!!\n");
748 ISF_SAVE_LOG ("Helper_Active scim_socket_open_connection failed, %d\n", timeout);
753 /* Retry after re-connecting the socket */
754 if (m_impl->socket_active.is_connected ())
755 m_impl->socket_active.close ();
757 /* This time, just retry atmost 2 seconds */
759 while (!m_impl->socket_active.connect (address) && ++i < 10) {
760 scim_usleep (200000);
764 m_impl->magic_active = magic;
766 m_impl->send.clear ();
767 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
768 m_impl->send.put_data (magic);
769 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_REGISTER_ACTIVE_HELPER);
770 m_impl->send.put_data (info.uuid);
771 m_impl->send.put_data (info.name);
772 m_impl->send.put_data (info.icon);
773 m_impl->send.put_data (info.description);
774 m_impl->send.put_data (info.option);
776 if (!m_impl->send.write_to_socket (m_impl->socket_active, magic)) {
777 ISF_SAVE_LOG ("Helper_Active write_to_socket() failed\n");
778 m_impl->socket_active.close ();
781 m_impl->m_config = ConfigBase::get (false, "socket");
783 return m_impl->socket.get_id ();
787 * @brief Close the socket connection to Panel.
790 HelperAgent::close_connection ()
792 m_impl->socket.close ();
793 m_impl->socket_active.close ();
794 m_impl->send.clear ();
795 m_impl->recv.clear ();
797 m_impl->magic_active = 0;
802 * @brief Get the connection id previously returned by open_connection().
804 * @return the connection id
807 HelperAgent::get_connection_number () const
809 if (m_impl->socket.is_connected ())
810 return m_impl->socket.get_id ();
815 * @brief Check whether this HelperAgent has been connected to a Panel.
817 * Return true when it is connected to panel, otherwise return false.
820 HelperAgent::is_connected () const
822 return m_impl->socket.is_connected ();
826 * @brief Check if there are any events available to be processed.
828 * If it returns true then Helper object should call
829 * HelperAgent::filter_event() to process them.
831 * @return true if there are any events available.
834 HelperAgent::has_pending_event () const
836 if (m_impl->socket.is_connected () && m_impl->socket.wait_for_data (0) > 0)
839 if (message_queue.has_pending_message())
846 * @brief Process the pending events.
848 * This function will emit the corresponding signals according
851 * @return false if the connection is broken, otherwise return true.
854 HelperAgent::filter_event ()
856 if (!m_impl->socket.is_connected ()) {
857 LOGW("Connection lost, returning false");
861 if (m_impl->recv.read_from_socket (m_impl->socket, m_impl->timeout)) {
862 message_queue.read_from_transaction(m_impl->recv);
864 while (message_queue.has_pending_message()) {
865 MessageItem *message = message_queue.get_pending_message();
866 handle_message(message);
867 message_queue.remove_message(message);
870 LOGD("read_from_socket() failed but continuing");
878 * @brief Read messages from socket buffer, and see if there is a message with the given cmd.
880 * @return false if the connection is broken, or no message available with given cmd. Otherwise return true.
883 HelperAgent::wait_for_message(int cmd, int timeout)
885 struct timeval t0 = { 0, 0 };
886 struct timeval t1 = { 0, 0 };
888 gettimeofday(&t0, NULL);
892 if (!m_impl->socket.is_connected() || !m_impl->recv.read_from_socket(m_impl->socket, timeout))
895 message_queue.read_from_transaction(m_impl->recv);
896 if (message_queue.has_pending_message_by_cmd(cmd)) {
900 gettimeofday(&t1, NULL);
901 etime = ((t1.tv_sec * 1000000 + t1.tv_usec) - (t0.tv_sec * 1000000 + t0.tv_usec)) / 1000;
902 } while (etime < timeout);
908 * @brief Process one message that is in our message queue.
910 * This function will emit the corresponding signals according
913 * @param message The message that needs to be handled.
915 * @return false if the connection is broken, otherwise return true.
918 HelperAgent::handle_message (MessageItem *message)
923 int cmd = message->get_command_ref();
924 LOGD ("HelperAgent::cmd = %d\n", cmd);
926 case SCIM_TRANS_CMD_EXIT:
928 MessageItemExit *subclass = static_cast<MessageItemExit*>(message);
929 ISF_SAVE_LOG ("Helper ISE received SCIM_TRANS_CMD_EXIT message\n");
930 m_impl->signal_exit(this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
933 case SCIM_TRANS_CMD_RELOAD_CONFIG:
935 MessageItemReloadConfig *subclass = static_cast<MessageItemReloadConfig*>(message);
936 m_impl->signal_reload_config (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
937 if (!m_impl->m_config.null())
938 m_impl->m_config->ConfigBase::reload();
941 case SCIM_TRANS_CMD_UPDATE_SCREEN:
943 MessageItemUpdateScreen *subclass = static_cast<MessageItemUpdateScreen*>(message);
944 m_impl->signal_update_screen (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
945 subclass->get_screen_ref());
948 case SCIM_TRANS_CMD_UPDATE_SPOT_LOCATION:
950 MessageItemUpdateSpotLocation *subclass = static_cast<MessageItemUpdateSpotLocation*>(message);
951 m_impl->signal_update_spot_location (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
952 subclass->get_x_ref(), subclass->get_y_ref());
955 case ISM_TRANS_CMD_UPDATE_CURSOR_POSITION:
957 MessageItemUpdateCursorPosition *subclass = static_cast<MessageItemUpdateCursorPosition*>(message);
958 m_impl->cursor_pos = subclass->get_cursor_pos_ref();
959 LOGD ("update cursor position %d", subclass->get_cursor_pos_ref());
960 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode) {
961 m_impl->signal_update_cursor_position (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
962 subclass->get_cursor_pos_ref());
964 if (!m_impl->si.null ()) m_impl->si->update_cursor_position(subclass->get_cursor_pos_ref());
967 case ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT:
969 MessageItemUpdateSurroundingText *subclass = static_cast<MessageItemUpdateSurroundingText*>(message);
970 if (m_impl->surrounding_text != NULL)
971 free (m_impl->surrounding_text);
972 m_impl->surrounding_text = strdup (subclass->get_text_ref().c_str ());
973 m_impl->cursor_pos = subclass->get_cursor_ref();
974 LOGD ("surrounding text: %s, %d", m_impl->surrounding_text, subclass->get_cursor_ref());
975 while (m_impl->need_update_surrounding_text > 0) {
976 m_impl->need_update_surrounding_text--;
977 m_impl->signal_update_surrounding_text (this, subclass->get_ic_ref(),
978 subclass->get_text_ref(), subclass->get_cursor_ref());
982 case ISM_TRANS_CMD_UPDATE_SELECTION:
984 MessageItemUpdateSelection *subclass = static_cast<MessageItemUpdateSelection*>(message);
985 if (m_impl->selection_text != NULL)
986 free (m_impl->selection_text);
988 m_impl->selection_text = strdup (subclass->get_text_ref().c_str ());
989 LOGD ("selection text: %s", m_impl->selection_text);
991 while (m_impl->need_update_selection_text > 0) {
992 m_impl->need_update_selection_text--;
993 m_impl->signal_update_selection (this, subclass->get_ic_ref(), subclass->get_text_ref());
997 case SCIM_TRANS_CMD_TRIGGER_PROPERTY:
999 MessageItemTriggerProperty *subclass = static_cast<MessageItemTriggerProperty*>(message);
1000 m_impl->signal_trigger_property (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1001 subclass->get_property_ref());
1002 if (!m_impl->si.null ()) m_impl->si->trigger_property(subclass->get_property_ref());
1005 case SCIM_TRANS_CMD_HELPER_PROCESS_IMENGINE_EVENT:
1007 MessageItemHelperProcessImengineEvent *subclass = static_cast<MessageItemHelperProcessImengineEvent*>(message);
1008 m_impl->signal_process_imengine_event (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1009 subclass->get_transaction_ref());
1012 case SCIM_TRANS_CMD_HELPER_ATTACH_INPUT_CONTEXT:
1014 MessageItemHelperAttachInputContext *subclass = static_cast<MessageItemHelperAttachInputContext*>(message);
1015 m_impl->signal_attach_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1018 case SCIM_TRANS_CMD_HELPER_DETACH_INPUT_CONTEXT:
1020 MessageItemHelperDetachInputContext *subclass = static_cast<MessageItemHelperDetachInputContext*>(message);
1021 m_impl->signal_detach_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1024 case SCIM_TRANS_CMD_FOCUS_OUT:
1026 MessageItemFocusOut *subclass = static_cast<MessageItemFocusOut*>(message);
1027 m_impl->signal_focus_out (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1028 m_impl->focused_ic = (uint32) -1;
1029 if (!m_impl->si.null ()) m_impl->si->focus_out();
1031 m_impl->ise_show_flag = false;
1035 case SCIM_TRANS_CMD_FOCUS_IN:
1037 MessageItemFocusIn *subclass = static_cast<MessageItemFocusIn*>(message);
1038 m_impl->signal_focus_in (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1039 m_impl->focused_ic = subclass->get_ic_ref();
1040 if (!m_impl->si.null ()) m_impl->si->focus_in();
1043 case ISM_TRANS_CMD_SHOW_ISE_PANEL:
1045 MessageItemShowISEPanel *subclass = static_cast<MessageItemShowISEPanel*>(message);
1046 LOGD ("Helper ISE received ISM_TRANS_CMD_SHOW_ISE_PANEL message\n");
1048 m_impl->signal_ise_show (this, subclass->get_ic_ref(), *(subclass->get_data_ptr()),
1049 subclass->get_len_ref());
1050 m_impl->ise_show_flag = true;
1053 case ISM_TRANS_CMD_HIDE_ISE_PANEL:
1055 MessageItemHideISEPanel *subclass = static_cast<MessageItemHideISEPanel*>(message);
1056 LOGD ("Helper ISE received ISM_TRANS_CMD_HIDE_ISE_PANEL message\n");
1057 m_impl->signal_ise_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1058 m_impl->ise_show_flag = false;
1061 case ISM_TRANS_CMD_GET_ACTIVE_ISE_GEOMETRY:
1063 struct rectinfo info = {0, 0, 0, 0};
1064 m_impl->signal_get_geometry (this, info);
1065 m_impl->send.clear ();
1066 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1067 m_impl->send.put_data (info.pos_x);
1068 m_impl->send.put_data (info.pos_y);
1069 m_impl->send.put_data (info.width);
1070 m_impl->send.put_data (info.height);
1071 m_impl->send.write_to_socket (m_impl->socket);
1074 case ISM_TRANS_CMD_SET_ISE_MODE:
1076 MessageItemSetISEMode *subclass = static_cast<MessageItemSetISEMode*>(message);
1077 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode) {
1078 m_impl->signal_set_mode (this, subclass->get_mode_ref());
1082 case ISM_TRANS_CMD_SET_ISE_LANGUAGE:
1084 MessageItemSetISELanguage *subclass = static_cast<MessageItemSetISELanguage*>(message);
1085 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode) {
1086 m_impl->signal_set_language (this, subclass->get_language_ref());
1090 case ISM_TRANS_CMD_SET_ISE_IMDATA:
1092 MessageItemSetISEImData *subclass = static_cast<MessageItemSetISEImData*>(message);
1093 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode) {
1094 m_impl->signal_set_imdata (this, *(subclass->get_imdata_ptr()), subclass->get_len_ref());
1096 if (!m_impl->si.null ()) m_impl->si->set_imdata(*(subclass->get_imdata_ptr()),
1097 subclass->get_len_ref());
1100 case ISM_TRANS_CMD_GET_ISE_IMDATA:
1105 m_impl->signal_get_imdata (this, &buf, len);
1106 LOGD ("send ise imdata len = %d", len);
1107 m_impl->send.clear ();
1108 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1109 m_impl->send.put_data (buf, len);
1110 m_impl->send.write_to_socket (m_impl->socket);
1115 case ISM_TRANS_CMD_GET_ISE_LANGUAGE_LOCALE:
1117 MessageItemGetISELanguageLocale *subclass = static_cast<MessageItemGetISELanguageLocale*>(message);
1119 m_impl->signal_get_language_locale (this, subclass->get_ic_ref(), &buf);
1120 m_impl->send.clear ();
1121 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1123 m_impl->send.put_data (buf, strlen (buf));
1124 m_impl->send.write_to_socket (m_impl->socket);
1129 case ISM_TRANS_CMD_SET_RETURN_KEY_TYPE:
1131 MessageItemSetReturnKeyType *subclass = static_cast<MessageItemSetReturnKeyType*>(message);
1132 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode) {
1133 m_impl->signal_set_return_key_type (this, subclass->get_type_ref());
1137 case ISM_TRANS_CMD_GET_RETURN_KEY_TYPE:
1140 m_impl->signal_get_return_key_type (this, type);
1141 m_impl->send.clear ();
1142 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1143 m_impl->send.put_data (type);
1144 m_impl->send.write_to_socket (m_impl->socket);
1147 case ISM_TRANS_CMD_SET_RETURN_KEY_DISABLE:
1149 MessageItemSetReturnKeyDisable *subclass = static_cast<MessageItemSetReturnKeyDisable*>(message);
1150 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode) {
1151 m_impl->signal_set_return_key_disable (this, subclass->get_disabled_ref());
1155 case ISM_TRANS_CMD_GET_RETURN_KEY_DISABLE:
1157 uint32 disabled = 0;
1158 m_impl->signal_get_return_key_type (this, disabled);
1159 m_impl->send.clear ();
1160 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1161 m_impl->send.put_data (disabled);
1162 m_impl->send.write_to_socket (m_impl->socket);
1165 case SCIM_TRANS_CMD_PROCESS_KEY_EVENT:
1167 MessageItemProcessKeyEvent *subclass = static_cast<MessageItemProcessKeyEvent*>(message);
1169 m_impl->signal_process_key_event(this, subclass->get_key_ref(), ret);
1171 if (!m_impl->si.null ()) {
1172 if (!(subclass->get_key_ref().get_key_string().compare("KeyRelease+XF86Back") == 0 ||
1173 subclass->get_key_ref().get_key_string().compare("XF86Back") == 0)) {
1174 ret = m_impl->si->process_key_event (subclass->get_key_ref());
1175 LOGD("imengine(%s) process key %d return %d", m_impl->si->get_factory_uuid().c_str(),
1176 subclass->get_key_ref().code, ret);
1180 m_impl->process_key_event_done (subclass->get_key_ref(), ret, subclass->get_serial_ref());
1183 case ISM_TRANS_CMD_SET_LAYOUT:
1185 MessageItemSetLayout *subclass = static_cast<MessageItemSetLayout*>(message);
1186 m_impl->layout = subclass->get_layout_ref();
1187 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode) {
1188 m_impl->signal_set_layout (this, subclass->get_layout_ref());
1190 if (!m_impl->si.null ()) m_impl->si->set_layout(subclass->get_layout_ref());
1193 case ISM_TRANS_CMD_GET_LAYOUT:
1197 m_impl->signal_get_layout (this, layout);
1198 m_impl->send.clear ();
1199 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1200 m_impl->send.put_data (layout);
1201 m_impl->send.write_to_socket (m_impl->socket);
1204 case ISM_TRANS_CMD_SET_INPUT_MODE:
1206 MessageItemSetInputMode *subclass = static_cast<MessageItemSetInputMode*>(message);
1207 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode) {
1208 m_impl->signal_set_input_mode (this, subclass->get_input_mode_ref());
1212 case ISM_TRANS_CMD_SET_CAPS_MODE:
1214 MessageItemSetCapsMode *subclass = static_cast<MessageItemSetCapsMode*>(message);
1215 m_impl->signal_set_caps_mode (this, subclass->get_mode_ref());
1218 case SCIM_TRANS_CMD_PANEL_RESET_INPUT_CONTEXT:
1220 MessageItemPanelResetInputContext *subclass = static_cast<MessageItemPanelResetInputContext*>(message);
1221 m_impl->signal_reset_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1222 if (!m_impl->si.null ()) m_impl->si->reset();
1225 case ISM_TRANS_CMD_UPDATE_CANDIDATE_UI:
1227 MessageItemUpdateCandidateUI *subclass = static_cast<MessageItemUpdateCandidateUI*>(message);
1228 m_impl->signal_update_candidate_ui (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1229 subclass->get_style_ref(), subclass->get_mode_ref());
1232 case ISM_TRANS_CMD_UPDATE_CANDIDATE_GEOMETRY:
1234 MessageItemUpdateCandidateGeometry *subclass = static_cast<MessageItemUpdateCandidateGeometry*>(message);
1235 m_impl->signal_update_candidate_geometry (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1236 subclass->get_rectinfo_ref());
1239 case ISM_TRANS_CMD_UPDATE_KEYBOARD_ISE:
1241 MessageItemUpdateKeyboardISE *subclass = static_cast<MessageItemUpdateKeyboardISE*>(message);
1242 m_impl->signal_update_keyboard_ise (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1243 subclass->get_name_ref(), subclass->get_uuid_ref());
1246 case ISM_TRANS_CMD_UPDATE_KEYBOARD_ISE_LIST:
1248 MessageItemUpdateKeyboardISEList *subclass = static_cast<MessageItemUpdateKeyboardISEList*>(message);
1249 m_impl->signal_update_keyboard_ise_list (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1250 subclass->get_list_ref());
1253 case ISM_TRANS_CMD_CANDIDATE_MORE_WINDOW_SHOW:
1255 MessageItemCandidateMoreWindowShow *subclass = static_cast<MessageItemCandidateMoreWindowShow*>(message);
1256 m_impl->signal_candidate_more_window_show (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1257 if (!m_impl->si.null ()) m_impl->si->candidate_more_window_show();
1260 case ISM_TRANS_CMD_CANDIDATE_MORE_WINDOW_HIDE:
1262 MessageItemCandidateMoreWindowHide *subclass = static_cast<MessageItemCandidateMoreWindowHide*>(message);
1263 m_impl->signal_candidate_more_window_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1264 if (!m_impl->si.null ()) m_impl->si->candidate_more_window_hide();
1267 case ISM_TRANS_CMD_SELECT_AUX:
1269 MessageItemSelectAux *subclass = static_cast<MessageItemSelectAux*>(message);
1270 m_impl->signal_select_aux (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1271 subclass->get_item_ref());
1272 if (!m_impl->si.null ()) m_impl->si->select_aux(subclass->get_item_ref());
1275 case SCIM_TRANS_CMD_SELECT_CANDIDATE: //FIXME:remove if useless
1277 MessageItemSelectCandidate *subclass = static_cast<MessageItemSelectCandidate*>(message);
1278 m_impl->signal_select_candidate (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1279 subclass->get_item_ref());
1280 if (!m_impl->si.null ()) m_impl->si->select_candidate(subclass->get_item_ref());
1283 case SCIM_TRANS_CMD_LOOKUP_TABLE_PAGE_UP: //FIXME:remove if useless
1285 MessageItemLookupTablePageUp *subclass = static_cast<MessageItemLookupTablePageUp*>(message);
1286 m_impl->signal_candidate_table_page_up (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1287 if (!m_impl->si.null ()) m_impl->si->lookup_table_page_up();
1290 case SCIM_TRANS_CMD_LOOKUP_TABLE_PAGE_DOWN: //FIXME:remove if useless
1292 MessageItemLookupTablePageDown *subclass = static_cast<MessageItemLookupTablePageDown*>(message);
1293 m_impl->signal_candidate_table_page_down (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1294 if (!m_impl->si.null ()) m_impl->si->lookup_table_page_down();
1297 case SCIM_TRANS_CMD_UPDATE_LOOKUP_TABLE_PAGE_SIZE:
1299 MessageItemUpdateLookupTablePageSize *subclass = static_cast<MessageItemUpdateLookupTablePageSize*>(message);
1300 m_impl->signal_update_candidate_table_page_size (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1301 subclass->get_size_ref());
1302 if (!m_impl->si.null ()) m_impl->si->update_lookup_table_page_size(subclass->get_size_ref());
1305 case ISM_TRANS_CMD_CANDIDATE_SHOW: //FIXME:remove if useless
1307 MessageItemCandidateShow *subclass = static_cast<MessageItemCandidateShow*>(message);
1308 m_impl->signal_candidate_show (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1311 case ISM_TRANS_CMD_CANDIDATE_HIDE: //FIXME:remove if useless
1313 MessageItemCandidateHide *subclass = static_cast<MessageItemCandidateHide*>(message);
1314 m_impl->signal_candidate_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1317 case ISM_TRANS_CMD_UPDATE_LOOKUP_TABLE: //FIXME:remove if useless
1319 MessageItemUpdateLookupTable *subclass = static_cast<MessageItemUpdateLookupTable*>(message);
1320 m_impl->signal_update_lookup_table (this, subclass->get_candidate_table_ref());
1323 case ISM_TRANS_CMD_UPDATE_CANDIDATE_ITEM_LAYOUT:
1325 MessageItemUpdateCandidateItemLayout *subclass = static_cast<MessageItemUpdateCandidateItemLayout*>(message);
1326 m_impl->signal_update_candidate_item_layout (this, subclass->get_row_items_ref());
1327 if (!m_impl->si.null ()) m_impl->si->update_candidate_item_layout(subclass->get_row_items_ref());
1330 case ISM_TRANS_CMD_SELECT_ASSOCIATE:
1332 MessageItemSelectAssociate *subclass = static_cast<MessageItemSelectAssociate*>(message);
1333 m_impl->signal_select_associate (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1334 subclass->get_item_ref());
1337 case ISM_TRANS_CMD_ASSOCIATE_TABLE_PAGE_UP:
1339 MessageItemAssociateTablePageUp *subclass = static_cast<MessageItemAssociateTablePageUp*>(message);
1340 m_impl->signal_associate_table_page_up (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1343 case ISM_TRANS_CMD_ASSOCIATE_TABLE_PAGE_DOWN:
1345 MessageItemAssociateTablePageDown *subclass = static_cast<MessageItemAssociateTablePageDown*>(message);
1346 m_impl->signal_associate_table_page_down (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1349 case ISM_TRANS_CMD_UPDATE_ASSOCIATE_TABLE_PAGE_SIZE:
1351 MessageItemUpdateAssociateTablePageSize *subclass = static_cast<MessageItemUpdateAssociateTablePageSize*>(message);
1352 m_impl->signal_update_associate_table_page_size (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1353 subclass->get_size_ref());
1356 case ISM_TRANS_CMD_RESET_ISE_CONTEXT:
1358 MessageItemResetISEContext *subclass = static_cast<MessageItemResetISEContext*>(message);
1359 m_impl->signal_reset_ise_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1360 m_impl->signal_reset_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1361 if (!m_impl->si.null ()) m_impl->si->reset();
1364 case ISM_TRANS_CMD_TURN_ON_LOG:
1366 MessageItemTurnOnLog *subclass = static_cast<MessageItemTurnOnLog*>(message);
1367 m_impl->signal_turn_on_log (this, subclass->get_state_ref());
1370 case ISM_TRANS_CMD_UPDATE_DISPLAYED_CANDIDATE:
1372 MessageItemUpdateDisplayedCandidate *subclass = static_cast<MessageItemUpdateDisplayedCandidate*>(message);
1373 m_impl->signal_update_displayed_candidate_number (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1374 subclass->get_size_ref());
1375 if (!m_impl->si.null ()) m_impl->si->update_displayed_candidate_number(subclass->get_size_ref());
1378 case ISM_TRANS_CMD_LONGPRESS_CANDIDATE:
1380 MessageItemLongpressCandidate *subclass = static_cast<MessageItemLongpressCandidate*>(message);
1381 m_impl->signal_longpress_candidate (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1382 subclass->get_index_ref());
1383 if (!m_impl->si.null ()) m_impl->si->longpress_candidate(subclass->get_index_ref());
1386 case ISM_TRANS_CMD_SET_INPUT_HINT:
1388 MessageItemSetInputHint *subclass = static_cast<MessageItemSetInputHint*>(message);
1389 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode) {
1390 m_impl->signal_set_input_hint (this, subclass->get_input_hint_ref());
1392 if (!m_impl->si.null ()) m_impl->si->set_input_hint(subclass->get_input_hint_ref());
1395 case ISM_TRANS_CMD_UPDATE_BIDI_DIRECTION:
1397 MessageItemUpdateBidiDirection *subclass = static_cast<MessageItemUpdateBidiDirection*>(message);
1398 m_impl->signal_update_bidi_direction (this, subclass->get_bidi_direction());
1399 if (!m_impl->si.null ()) m_impl->si->update_bidi_direction(subclass->get_bidi_direction());
1402 case ISM_TRANS_CMD_SHOW_ISE_OPTION_WINDOW:
1404 MessageItemShowISEOptionWindow *subclass = static_cast<MessageItemShowISEOptionWindow*>(message);
1405 m_impl->signal_show_option_window (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1408 case ISM_TRANS_CMD_RESUME_ISE_OPTION_WINDOW:
1410 MessageItemResumeISEOptionWindow *subclass = static_cast<MessageItemResumeISEOptionWindow*>(message);
1411 m_impl->signal_resume_option_window (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1414 case ISM_TRANS_CMD_CHECK_OPTION_WINDOW:
1417 m_impl->signal_check_option_window (this, avail);
1418 m_impl->send.clear ();
1419 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1420 m_impl->send.put_data (avail);
1421 m_impl->send.write_to_socket (m_impl->socket);
1424 case ISM_TRANS_CMD_PROCESS_INPUT_DEVICE_EVENT:
1426 MessageItemProcessInputDeviceEvent *subclass = static_cast<MessageItemProcessInputDeviceEvent*>(message);
1428 m_impl->signal_process_input_device_event(this,
1429 subclass->get_type_ref(), *(subclass->get_data_ptr()), subclass->get_len_ref(), ret);
1430 m_impl->send.clear();
1431 m_impl->send.put_command(SCIM_TRANS_CMD_REPLY);
1432 m_impl->send.put_data(ret);
1433 m_impl->send.write_to_socket(m_impl->socket);
1436 case SCIM_TRANS_CMD_SET_AUTOCAPITAL_TYPE:
1438 MessageItemSetAutocapitalType *subclass = static_cast<MessageItemSetAutocapitalType*>(message);
1439 if (!m_impl->si.null ()) m_impl->si->set_autocapital_type(subclass->get_auto_capital_type_ref());
1442 case ISM_TRANS_CMD_SET_PREDICTION_ALLOW:
1444 MessageItemSetPredictionAllow *subclass = static_cast<MessageItemSetPredictionAllow*>(message);
1445 if (!m_impl->si.null ()) m_impl->si->set_prediction_allow(subclass->get_prediction_allow_ref() == 0 ? false : true);
1448 case ISM_TRANS_CMD_SET_KEYBOARD_MODE:
1450 MessageItemSetKeyboardMode *subclass = static_cast<MessageItemSetKeyboardMode*>(message);
1451 if (subclass->get_mode_ref())
1452 m_impl->hw_keyboard_mode = false;
1454 m_impl->hw_keyboard_mode = true;
1457 case ISM_TRANS_CMD_SET_PREDICTION_HINT:
1459 MessageItemSetPredictionHint *subclass = static_cast<MessageItemSetPredictionHint*>(message);
1460 m_impl->signal_set_prediction_hint (this, subclass->get_message_ptr());
1470 * @brief Request SCIM to reload all configuration.
1472 * This function should only by used by Setup Helper to request
1473 * scim's reloading the configuration.
1474 * Deprecated: reload config message only send by socketconfig client
1475 * using socketconfig::reload instead.
1478 HelperAgent::reload_config () const
1480 LOGD ("send reload config message to isf");
1481 if (!m_impl->m_config.null())
1482 m_impl->m_config->reload();
1486 * @brief Register some properties into Panel.
1488 * This function send the request to Panel to register a list
1491 * @param properties The list of Properties to be registered into Panel.
1493 * @sa scim::Property.
1496 HelperAgent::register_properties (const PropertyList &properties) const
1499 if (m_impl->socket_active.is_connected ()) {
1500 m_impl->send.clear ();
1501 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1502 m_impl->send.put_data (m_impl->magic_active);
1503 m_impl->send.put_command (SCIM_TRANS_CMD_REGISTER_PROPERTIES);
1504 m_impl->send.put_data (properties);
1505 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1510 * @brief Update a registered property.
1512 * @param property The property to be updated.
1515 HelperAgent::update_property (const Property &property) const
1518 if (m_impl->socket_active.is_connected ()) {
1519 m_impl->send.clear ();
1520 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1521 m_impl->send.put_data (m_impl->magic_active);
1522 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PROPERTY);
1523 m_impl->send.put_data (property);
1524 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1529 * @brief Send a set of events to an IMEngineInstance.
1531 * All events should be put into a Transaction.
1532 * And the events can only be received by one IMEngineInstance object.
1534 * @param ic The handle of the Input Context to receive the events.
1535 * @param ic_uuid The UUID of the Input Context.
1536 * @param trans The Transaction object holds the events.
1539 HelperAgent::send_imengine_event (int ic,
1540 const String &ic_uuid,
1541 const Transaction &trans) const
1544 //remove if not necessary
1546 if (m_impl->socket_active.is_connected ()) {
1547 m_impl->send.clear ();
1548 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1549 m_impl->send.put_data (m_impl->magic_active);
1550 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_SEND_IMENGINE_EVENT);
1551 m_impl->send.put_data ((uint32)ic);
1552 m_impl->send.put_data (ic_uuid);
1553 m_impl->send.put_data (trans);
1554 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1557 if (!m_impl->si.null ()) m_impl->si->process_helper_event (ic_uuid, trans);
1561 * @brief Send a KeyEvent to an IMEngineInstance.
1563 * @param ic The handle of the IMEngineInstance to receive the event.
1564 * -1 means the currently focused IMEngineInstance.
1565 * @param ic_uuid The UUID of the IMEngineInstance. Empty means don't match.
1566 * @param key The KeyEvent to be sent.
1569 HelperAgent::send_key_event (int ic,
1570 const String &ic_uuid,
1571 const KeyEvent &key) const
1575 //FIXME: remove shift_mode_off, shift_mode_on, shift_mode_lock from ISE side
1576 if (key.code == SHIFT_MODE_OFF ||
1577 key.code == SHIFT_MODE_ON ||
1578 key.code == SHIFT_MODE_LOCK ||
1579 key.code == SHIFT_MODE_ENABLE ||
1580 key.code == SHIFT_MODE_DISABLE) {
1581 LOGW("FIXME ignore shift codes");
1585 if (m_impl->socket_active.is_connected ()) {
1586 m_impl->send.clear ();
1587 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1588 m_impl->send.put_data (m_impl->magic_active);
1589 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_SEND_KEY_EVENT);
1591 m_impl->send.put_data (m_impl->focused_ic);
1593 m_impl->send.put_data ((uint32)ic);
1595 m_impl->send.put_data (ic_uuid);
1596 m_impl->send.put_data (key);
1597 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1602 * @brief Forward a KeyEvent to client application directly.
1604 * @param ic The handle of the client Input Context to receive the event.
1605 * -1 means the currently focused Input Context.
1606 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1607 * Empty means don't match.
1608 * @param key The KeyEvent to be forwarded.
1611 HelperAgent::forward_key_event (int ic,
1612 const String &ic_uuid,
1613 const KeyEvent &key) const
1616 if (m_impl->socket_active.is_connected ()) {
1617 m_impl->send.clear ();
1618 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1619 m_impl->send.put_data (m_impl->magic_active);
1620 m_impl->send.put_command (SCIM_TRANS_CMD_FORWARD_KEY_EVENT);
1622 m_impl->send.put_data (m_impl->focused_ic);
1624 m_impl->send.put_data ((uint32)ic);
1626 m_impl->send.put_data (ic_uuid);
1627 m_impl->send.put_data (key);
1628 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1633 * @brief Commit a WideString to client application directly.
1635 * @param ic The handle of the client Input Context to receive the WideString.
1636 * -1 means the currently focused Input Context.
1637 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1638 * Empty means don't match.
1639 * @param wstr The WideString to be committed.
1642 HelperAgent::commit_string (int ic,
1643 const String &ic_uuid,
1644 const WideString &wstr) const
1647 if (m_impl->socket_active.is_connected ()) {
1648 m_impl->send.clear ();
1649 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1650 m_impl->send.put_data (m_impl->magic_active);
1651 m_impl->send.put_command (SCIM_TRANS_CMD_COMMIT_STRING);
1653 m_impl->send.put_data (m_impl->focused_ic);
1655 m_impl->send.put_data ((uint32)ic);
1657 m_impl->send.put_data (ic_uuid);
1658 m_impl->send.put_data (wstr);
1659 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1664 HelperAgent::commit_string (int ic,
1665 const String &ic_uuid,
1670 if (m_impl->socket_active.is_connected ()) {
1671 m_impl->send.clear ();
1672 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1673 m_impl->send.put_data (m_impl->magic_active);
1674 m_impl->send.put_command (SCIM_TRANS_CMD_COMMIT_STRING);
1676 m_impl->send.put_data (m_impl->focused_ic);
1678 m_impl->send.put_data ((uint32)ic);
1680 m_impl->send.put_data (ic_uuid);
1681 m_impl->send.put_dataw (buf, buflen);
1682 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1687 * @brief Request to show preedit string.
1689 * @param ic The handle of the client Input Context to receive the request.
1690 * -1 means the currently focused Input Context.
1691 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1692 * Empty means don't match.
1695 HelperAgent::show_preedit_string (int ic,
1696 const String &ic_uuid) const
1700 if (m_impl->socket_active.is_connected ()) {
1701 m_impl->send.clear ();
1702 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1703 m_impl->send.put_data (m_impl->magic_active);
1704 m_impl->send.put_command (SCIM_TRANS_CMD_SHOW_PREEDIT_STRING);
1705 m_impl->send.put_data ((uint32)ic);
1706 m_impl->send.put_data (ic_uuid);
1707 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1712 * @brief Request to show aux string.
1715 HelperAgent::show_aux_string (void) const
1719 if (m_impl->socket_active.is_connected ()) {
1720 m_impl->send.clear ();
1721 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1722 m_impl->send.put_data (m_impl->magic_active);
1723 m_impl->send.put_command (SCIM_TRANS_CMD_SHOW_AUX_STRING);
1724 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1729 * @brief Request to show candidate string.
1732 HelperAgent::show_candidate_string (void) const
1736 if (m_impl->socket_active.is_connected ()) {
1737 m_impl->send.clear ();
1738 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1739 m_impl->send.put_data (m_impl->magic_active);
1740 m_impl->send.put_command (SCIM_TRANS_CMD_SHOW_LOOKUP_TABLE);
1741 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1746 * @brief Request to show associate string.
1749 HelperAgent::show_associate_string (void) const
1752 if (m_impl->socket_active.is_connected ()) {
1753 m_impl->send.clear ();
1754 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1755 m_impl->send.put_data (m_impl->magic_active);
1756 m_impl->send.put_command (ISM_TRANS_CMD_SHOW_ASSOCIATE_TABLE);
1757 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1762 * @brief Request to hide preedit string.
1764 * @param ic The handle of the client Input Context to receive the request.
1765 * -1 means the currently focused Input Context.
1766 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1767 * Empty means don't match.
1770 HelperAgent::hide_preedit_string (int ic,
1771 const String &ic_uuid) const
1775 if (m_impl->socket_active.is_connected ()) {
1776 m_impl->send.clear ();
1777 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1778 m_impl->send.put_data (m_impl->magic_active);
1779 m_impl->send.put_command (SCIM_TRANS_CMD_HIDE_PREEDIT_STRING);
1780 m_impl->send.put_data ((uint32)ic);
1781 m_impl->send.put_data (ic_uuid);
1782 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1787 * @brief Request to hide aux string.
1790 HelperAgent::hide_aux_string (void) const
1793 if (m_impl->socket_active.is_connected ()) {
1794 m_impl->send.clear ();
1795 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1796 m_impl->send.put_data (m_impl->magic_active);
1797 m_impl->send.put_command (SCIM_TRANS_CMD_HIDE_AUX_STRING);
1798 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1803 * @brief Request to hide candidate string.
1806 HelperAgent::hide_candidate_string (void) const
1809 if (m_impl->socket_active.is_connected ()) {
1810 m_impl->send.clear ();
1811 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1812 m_impl->send.put_data (m_impl->magic_active);
1813 m_impl->send.put_command (SCIM_TRANS_CMD_HIDE_LOOKUP_TABLE);
1814 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1819 * @brief Request to hide associate string.
1822 HelperAgent::hide_associate_string (void) const
1825 if (m_impl->socket_active.is_connected ()) {
1826 m_impl->send.clear ();
1827 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1828 m_impl->send.put_data (m_impl->magic_active);
1829 m_impl->send.put_command (ISM_TRANS_CMD_HIDE_ASSOCIATE_TABLE);
1830 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1835 * @brief Update a new WideString for preedit.
1837 * @param ic The handle of the client Input Context to receive the WideString.
1838 * -1 means the currently focused Input Context.
1839 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1840 * Empty means don't match.
1841 * @param str The WideString to be updated.
1842 * @param attrs The attribute list for preedit string.
1845 HelperAgent::update_preedit_string (int ic,
1846 const String &ic_uuid,
1847 const WideString &str,
1848 const AttributeList &attrs) const
1851 update_preedit_string (ic, ic_uuid, str, str, attrs, -1);
1855 HelperAgent::update_preedit_string (int ic,
1856 const String &ic_uuid,
1859 const AttributeList &attrs) const
1862 update_preedit_string (ic, ic_uuid, buf, buflen, attrs, -1);
1866 * @brief Update a new WideString for preedit.
1868 * @param ic The handle of the client Input Context to receive the WideString.
1869 * -1 means the currently focused Input Context.
1870 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1871 * Empty means don't match.
1872 * @param str The WideString to be updated.
1873 * @param attrs The attribute list for preedit string.
1874 * @param caret The caret position in preedit string.
1877 HelperAgent::update_preedit_string (int ic,
1878 const String &ic_uuid,
1879 const WideString &wstr,
1880 const AttributeList &attrs,
1884 update_preedit_string (ic, ic_uuid, wstr, wstr, attrs, caret);
1888 HelperAgent::update_preedit_string (int ic,
1889 const String &ic_uuid,
1892 const AttributeList &attrs,
1897 if (m_impl->socket_active.is_connected ()) {
1898 m_impl->send.clear ();
1899 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1900 m_impl->send.put_data (m_impl->magic_active);
1901 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING);
1902 m_impl->send.put_data ((uint32)ic);
1903 m_impl->send.put_data (ic_uuid);
1904 m_impl->send.put_dataw (buf, buflen);
1905 m_impl->send.put_dataw (buf, buflen);
1906 m_impl->send.put_data (attrs);
1907 m_impl->send.put_data (caret);
1908 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1913 HelperAgent::update_preedit_string (int ic,
1914 const String &ic_uuid,
1915 const WideString &preedit,
1916 const WideString &commit,
1917 const AttributeList &attrs,
1921 if (m_impl->socket_active.is_connected ()) {
1922 m_impl->send.clear ();
1923 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1924 m_impl->send.put_data (m_impl->magic_active);
1925 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING);
1926 m_impl->send.put_data ((uint32)ic);
1927 m_impl->send.put_data (ic_uuid);
1928 m_impl->send.put_data (preedit);
1929 m_impl->send.put_data (commit);
1930 m_impl->send.put_data (attrs);
1931 m_impl->send.put_data (caret);
1932 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1937 * @brief Update the preedit caret position in the preedit string.
1939 * @param caret - the new position of the preedit caret.
1942 HelperAgent::update_preedit_caret (int caret) const
1946 if (m_impl->socket_active.is_connected ()) {
1947 m_impl->send.clear ();
1948 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1949 m_impl->send.put_data (m_impl->magic_active);
1950 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_CARET);
1951 m_impl->send.put_data ((uint32)caret);
1952 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1957 * @brief Update a new string for aux.
1959 * @param str The string to be updated.
1960 * @param attrs The attribute list for aux string.
1963 HelperAgent::update_aux_string (const String &str,
1964 const AttributeList &attrs) const
1967 if (m_impl->socket_active.is_connected ()) {
1968 m_impl->send.clear ();
1969 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1970 m_impl->send.put_data (m_impl->magic_active);
1971 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_AUX_STRING);
1972 m_impl->send.put_data (str);
1973 m_impl->send.put_data (attrs);
1974 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1979 * @brief Request to update candidate.
1981 * @param table The lookup table for candidate.
1984 HelperAgent::update_candidate_string (const LookupTable &table) const
1987 if (m_impl->socket_active.is_connected ()) {
1988 m_impl->send.clear ();
1989 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1990 m_impl->send.put_data (m_impl->magic_active);
1991 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_LOOKUP_TABLE);
1992 m_impl->send.put_data (table);
1993 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1998 * @brief Request to update associate.
2000 * @param table The lookup table for associate.
2003 HelperAgent::update_associate_string (const LookupTable &table) const
2006 if (m_impl->socket_active.is_connected ()) {
2007 m_impl->send.clear ();
2008 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2009 m_impl->send.put_data (m_impl->magic_active);
2010 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ASSOCIATE_TABLE);
2011 m_impl->send.put_data (table);
2012 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2017 * @brief When the input context of ISE is changed,
2018 * ISE can call this function to notify application
2020 * @param type type of event.
2021 * @param value value of event.
2024 HelperAgent::update_input_context (uint32 type, uint32 value) const
2027 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 (ISM_TRANS_CMD_UPDATE_ISE_INPUT_CONTEXT);
2032 m_impl->send.put_data (type);
2033 m_impl->send.put_data (value);
2034 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2039 * @brief Request to get surrounding text asynchronously.
2041 * @param uuid The helper ISE UUID.
2042 * @param maxlen_before The max length of before.
2043 * @param maxlen_after The max length of after.
2046 HelperAgent::get_surrounding_text (const String &uuid, int maxlen_before, int maxlen_after) const
2049 if (m_impl->socket_active.is_connected () && (m_impl->need_update_surrounding_text == 0)) {
2050 m_impl->send.clear ();
2051 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2052 m_impl->send.put_data (m_impl->magic_active);
2053 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SURROUNDING_TEXT);
2054 m_impl->send.put_data (uuid);
2055 m_impl->send.put_data (maxlen_before);
2056 m_impl->send.put_data (maxlen_after);
2057 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2059 m_impl->need_update_surrounding_text++;
2063 * @brief Request to get surrounding text synchronously.
2065 * @param uuid The helper ISE UUID.
2066 * @param maxlen_before The max length of before.
2067 * @param maxlen_after The max length of after.
2068 * @param text The surrounding text.
2069 * @param cursor The cursor position.
2072 HelperAgent::get_surrounding_text (int maxlen_before, int maxlen_after, String &text, int &cursor)
2076 if (!m_impl->socket_active.is_connected ())
2079 m_impl->send.clear ();
2080 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2081 m_impl->send.put_data (m_impl->magic_active);
2082 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SURROUNDING_TEXT);
2083 m_impl->send.put_data ("");
2084 m_impl->send.put_data (maxlen_before);
2085 m_impl->send.put_data (maxlen_after);
2086 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2087 if (m_impl->surrounding_text) {
2088 free (m_impl->surrounding_text);
2089 m_impl->surrounding_text = NULL;
2092 const int WAIT_FOR_SYNC_RESPONSE_TIMEOUT = 1000;
2093 /* Now we are waiting for the ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT message */
2094 if (wait_for_message(ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT, WAIT_FOR_SYNC_RESPONSE_TIMEOUT)) {
2095 MessageItem *message = message_queue.get_pending_message_by_cmd(ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT);
2096 handle_message(message);
2097 message_queue.remove_message(message);
2099 if (m_impl->surrounding_text) {
2100 text = m_impl->surrounding_text;
2101 cursor = m_impl->cursor_pos;
2105 if (m_impl->surrounding_text) {
2106 free (m_impl->surrounding_text);
2107 m_impl->surrounding_text = NULL;
2112 * @brief Request to delete surrounding text.
2114 * @param offset The offset for cursor position.
2115 * @param len The length for delete text.
2118 HelperAgent::delete_surrounding_text (int offset, int len) const
2120 LOGD ("offset = %d, len = %d", offset, len);
2122 if (m_impl->socket_active.is_connected ()) {
2123 m_impl->send.clear ();
2124 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2125 m_impl->send.put_data (m_impl->magic_active);
2126 m_impl->send.put_command (SCIM_TRANS_CMD_DELETE_SURROUNDING_TEXT);
2127 m_impl->send.put_data (offset);
2128 m_impl->send.put_data (len);
2129 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2134 * @brief Request to get selection text asynchronously.
2136 * @param uuid The helper ISE UUID.
2139 HelperAgent::get_selection (const String &uuid) const
2142 if (m_impl->socket_active.is_connected () && (m_impl->need_update_selection_text == 0)) {
2143 m_impl->send.clear ();
2144 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2145 m_impl->send.put_data (m_impl->magic_active);
2146 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SELECTION);
2147 m_impl->send.put_data (uuid);
2148 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2150 m_impl->need_update_selection_text++;
2154 * @brief Request to get selection text synchronously.
2156 * @param text The selection text.
2159 HelperAgent::get_selection_text (String &text)
2163 if (!m_impl->socket_active.is_connected ())
2166 m_impl->send.clear ();
2167 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2168 m_impl->send.put_data (m_impl->magic_active);
2169 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SELECTION);
2170 m_impl->send.put_data ("");
2171 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2172 if (m_impl->selection_text) {
2173 free (m_impl->selection_text);
2174 m_impl->selection_text = NULL;
2177 const int WAIT_FOR_SYNC_RESPONSE_TIMEOUT = 1000;
2178 /* Now we are waiting for the ISM_TRANS_CMD_UPDATE_SELECTION message */
2179 if (wait_for_message(ISM_TRANS_CMD_UPDATE_SELECTION, WAIT_FOR_SYNC_RESPONSE_TIMEOUT)) {
2180 MessageItem *message = message_queue.get_pending_message_by_cmd(ISM_TRANS_CMD_UPDATE_SELECTION);
2181 handle_message(message);
2182 message_queue.remove_message(message);
2183 if (m_impl->selection_text) {
2184 text = m_impl->selection_text;
2188 if (m_impl->selection_text) {
2189 free (m_impl->selection_text);
2190 m_impl->selection_text = NULL;
2195 * @brief Request to select text.
2197 * @param start The start position in text.
2198 * @param end The end position in text.
2201 HelperAgent::set_selection (int start, int end) const
2204 if (m_impl->socket_active.is_connected ()) {
2205 m_impl->send.clear ();
2206 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2207 m_impl->send.put_data (m_impl->magic_active);
2208 m_impl->send.put_command (SCIM_TRANS_CMD_SET_SELECTION);
2209 m_impl->send.put_data (start);
2210 m_impl->send.put_data (end);
2211 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2216 * @brief Send a private command to an application.
2218 * @param command The private command sent from IME.
2221 HelperAgent::send_private_command (const String &command) const
2224 if (m_impl->socket_active.is_connected ()) {
2225 m_impl->send.clear ();
2226 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2227 m_impl->send.put_data (m_impl->magic_active);
2228 m_impl->send.put_command (SCIM_TRANS_CMD_SEND_PRIVATE_COMMAND);
2229 m_impl->send.put_data (command);
2230 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2235 * @brief Commit content to an application.
2237 * @param content The content sent from IME.
2240 HelperAgent::commit_content (const String &content, const String &description, const String &mime_types) const
2243 if (m_impl->socket_active.is_connected ()) {
2244 m_impl->send.clear ();
2245 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2246 m_impl->send.put_data (m_impl->magic_active);
2247 m_impl->send.put_command (SCIM_TRANS_CMD_COMMIT_CONTENT);
2248 m_impl->send.put_data (content);
2249 m_impl->send.put_data (description);
2250 m_impl->send.put_data (mime_types);
2251 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2256 * @brief Request to get uuid list of all keyboard ISEs.
2258 * @param uuid The helper ISE UUID.
2261 HelperAgent::get_keyboard_ise_list (const String &uuid) const
2264 if (m_impl->socket_active.is_connected ()) {
2265 m_impl->send.clear ();
2266 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2267 m_impl->send.put_data (m_impl->magic_active);
2268 m_impl->send.put_command (ISM_TRANS_CMD_GET_KEYBOARD_ISE_LIST);
2269 m_impl->send.put_data (uuid);
2270 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2275 * @brief Set candidate position in screen.
2277 * @param left The x position in screen.
2278 * @param top The y position in screen.
2281 HelperAgent::set_candidate_position (int left, int top) const
2284 if (m_impl->socket_active.is_connected ()) {
2285 m_impl->send.clear ();
2286 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2287 m_impl->send.put_data (m_impl->magic_active);
2288 m_impl->send.put_command (ISM_TRANS_CMD_SET_CANDIDATE_POSITION);
2289 m_impl->send.put_data (left);
2290 m_impl->send.put_data (top);
2291 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2296 * @brief Set candidate style.
2298 * @param portrait_line - the displayed line number for portrait mode.
2299 * @param mode - candidate window mode.
2302 HelperAgent::set_candidate_style (ISF_CANDIDATE_PORTRAIT_LINE_T portrait_line,
2303 ISF_CANDIDATE_MODE_T mode) const
2306 if (m_impl->socket_active.is_connected ()) {
2307 m_impl->send.clear ();
2308 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2309 m_impl->send.put_data (m_impl->magic_active);
2310 m_impl->send.put_command (ISM_TRANS_CMD_SET_CANDIDATE_UI);
2311 m_impl->send.put_data (portrait_line);
2312 m_impl->send.put_data (mode);
2313 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2318 * @brief Request to hide candidate window.
2321 HelperAgent::candidate_hide (void) const
2324 if (m_impl->socket_active.is_connected ()) {
2325 m_impl->send.clear ();
2326 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2327 m_impl->send.put_data (m_impl->magic_active);
2328 m_impl->send.put_command (ISM_TRANS_CMD_HIDE_CANDIDATE);
2329 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2334 * @brief Request to get candidate window size and position.
2336 * @param uuid The helper ISE UUID.
2339 HelperAgent::get_candidate_window_geometry (const String &uuid) const
2342 if (m_impl->socket_active.is_connected ()) {
2343 m_impl->send.clear ();
2344 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2345 m_impl->send.put_data (m_impl->magic_active);
2346 m_impl->send.put_command (ISM_TRANS_CMD_GET_CANDIDATE_GEOMETRY);
2347 m_impl->send.put_data (uuid);
2348 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2353 * @brief Set current keyboard ISE.
2355 * @param uuid The keyboard ISE UUID.
2358 HelperAgent::set_keyboard_ise_by_uuid (const String &uuid) const
2362 IMEngineFactoryPointer factory;
2363 IMEngineModule *engine_module = NULL;
2364 static int instance_count = 1;
2366 if ((!m_impl->si.null ()) && m_impl->si->get_factory_uuid () == uuid) {
2367 LOGD ("Already in UUID: %s\n", uuid.c_str());
2371 if (!m_impl->si.null()) {
2372 m_impl->si->focus_out();
2376 if (m_impl->m_config.null ()) {
2377 LOGW ("config is not working");
2381 #ifdef HAVE_PKGMGR_INFO
2384 pkgmgrinfo_appinfo_h handle;
2385 ret = pkgmgrinfo_appinfo_get_appinfo(uuid.c_str(), &handle);
2386 if (ret != PMINFO_R_OK) {
2387 LOGW("Retrieve app info failed : %s", uuid.c_str ());
2391 ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
2392 if (ret != PMINFO_R_OK) {
2393 LOGW("Retrieve pkgid failed : %s, %p", uuid.c_str(), handle);
2394 pkgmgrinfo_appinfo_destroy_appinfo(handle);
2398 imeInfo.module_name = pkgid;
2399 pkgmgrinfo_appinfo_destroy_appinfo(handle);
2401 if (isf_db_select_ime_info_by_appid(uuid.c_str(), &imeInfo) < 1) {
2402 LOGW("ime_info row is not available for %s", uuid.c_str());
2407 engine_module = &m_impl->engine_module;
2409 if (engine_module->valid() && imeInfo.module_name != engine_module->get_module_name()) {
2410 LOGD ("imengine module %s unloaded", engine_module->get_module_name().c_str());
2411 engine_module->unload();
2414 if (!engine_module->valid()) {
2415 if (engine_module->load (imeInfo.module_name, m_impl->m_config) == false) {
2416 LOGW ("load module %s failed", imeInfo.module_name.c_str());
2419 LOGD ("imengine module %s loaded", imeInfo.module_name.c_str());
2422 for (size_t j = 0; j < engine_module->number_of_factories (); ++j) {
2424 factory = engine_module->create_factory (j);
2425 if (factory.null () == false && factory->get_uuid () == uuid)
2433 if (factory.null()) {
2434 LOGW ("imengine uuid %s is not found", uuid.c_str());
2438 m_impl->si = factory->create_instance ("UTF-8", instance_count++);
2439 if (m_impl->si.null ()) {
2440 LOGE ("create_instance %s failed", uuid.c_str ());
2444 m_impl->attach_instance ();
2445 LOGD ("Require UUID: %s Current UUID: %s", uuid.c_str (), m_impl->si->get_factory_uuid ().c_str ());
2446 m_impl->si->set_layout (m_impl->layout);
2447 if (m_impl->focused_ic != (uint32)-1)
2448 m_impl->si->focus_in ();
2452 * @brief Request to get current keyboard ISE information.
2454 * @param uuid The helper ISE UUID.
2457 HelperAgent::get_keyboard_ise (const String &uuid) const
2460 //FIXME: maybe useless
2462 if (m_impl->socket_active.is_connected ()) {
2463 m_impl->send.clear ();
2464 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2465 m_impl->send.put_data (m_impl->magic_active);
2466 m_impl->send.put_command (ISM_TRANS_CMD_GET_KEYBOARD_ISE);
2467 m_impl->send.put_data (uuid);
2468 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2474 * @brief Update ISE window geometry.
2476 * @param x The x position in screen.
2477 * @param y The y position in screen.
2478 * @param width The ISE window width.
2479 * @param height The ISE window height.
2482 HelperAgent::update_geometry (int x, int y, int width, int height) const
2485 if (m_impl->socket_active.is_connected ()) {
2486 m_impl->send.clear ();
2487 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2488 m_impl->send.put_data (m_impl->magic_active);
2489 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ISE_GEOMETRY);
2490 m_impl->send.put_data (x);
2491 m_impl->send.put_data (y);
2492 m_impl->send.put_data (width);
2493 m_impl->send.put_data (height);
2494 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2499 * @brief Request to expand candidate window.
2502 HelperAgent::expand_candidate (void) const
2505 if (m_impl->socket_active.is_connected ()) {
2506 m_impl->send.clear ();
2507 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2508 m_impl->send.put_data (m_impl->magic_active);
2509 m_impl->send.put_command (ISM_TRANS_CMD_EXPAND_CANDIDATE);
2510 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2515 * @brief Request to contract candidate window.
2518 HelperAgent::contract_candidate (void) const
2521 if (m_impl->socket_active.is_connected ()) {
2522 m_impl->send.clear ();
2523 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2524 m_impl->send.put_data (m_impl->magic_active);
2525 m_impl->send.put_command (ISM_TRANS_CMD_CONTRACT_CANDIDATE);
2526 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2531 * @brief Send selected candidate string index number.
2534 HelperAgent::select_candidate (int index) const
2537 if (!m_impl->si.null ())
2538 m_impl->si->select_candidate (index);
2539 //FIXME: maybe useless
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_SELECT_CANDIDATE);
2547 m_impl->send.put_data (index);
2548 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2554 * @brief Update our ISE is exiting.
2557 HelperAgent::update_ise_exit (void) const
2560 //FIXME: maybe useless
2562 if (m_impl->socket_active.is_connected ()) {
2563 m_impl->send.clear ();
2564 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2565 m_impl->send.put_data (m_impl->magic_active);
2566 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ISE_EXIT);
2567 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2573 * @brief Request to reset keyboard ISE.
2576 HelperAgent::reset_keyboard_ise (void) const
2579 //FIXME: maybe useless
2581 if (m_impl->socket_active.is_connected ()) {
2582 m_impl->send.clear ();
2583 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2584 m_impl->send.put_data (m_impl->magic_active);
2585 m_impl->send.put_command (ISM_TRANS_CMD_PANEL_RESET_KEYBOARD_ISE);
2586 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2589 if (!m_impl->si.null ()) {
2590 m_impl->si->reset ();
2595 * @brief Request to flush keyboard ISE.
2598 HelperAgent::flush_keyboard_ise (void) const
2601 if (!m_impl->si.null ()) {
2602 m_impl->si->flush ();
2607 * @brief Request panel to hide ISE.
2610 HelperAgent::request_ise_hide (void) const
2613 if (m_impl->socket_active.is_connected ()) {
2614 m_impl->send.clear ();
2615 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2616 m_impl->send.put_data (m_impl->magic_active);
2617 m_impl->send.put_command (ISM_TRANS_CMD_REQUEST_ISE_HIDE);
2618 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2626 HelperAgent::recapture_string (int ic,
2627 const String &ic_uuid,
2630 const WideString &preedit_str,
2631 const WideString &commit_str,
2632 const AttributeList &attrs) const
2634 LOGD ("offset = %d, len = %d", offset, len);
2636 if (m_impl->socket_active.is_connected ()) {
2637 m_impl->send.clear ();
2638 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2639 m_impl->send.put_data (m_impl->magic_active);
2640 m_impl->send.put_command (ISM_TRANS_CMD_RECAPTURE_STRING);
2642 m_impl->send.put_data ((uint32)ic);
2643 m_impl->send.put_data (ic_uuid);
2645 // Deleting surrounding text
2646 m_impl->send.put_data (offset);
2647 m_impl->send.put_data (len);
2649 // Update preedit text
2650 m_impl->send.put_data (preedit_str);
2653 m_impl->send.put_data (commit_str);
2655 // preedit attributes
2656 m_impl->send.put_data (attrs);
2658 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2663 * @brief Connect a slot to Helper exit signal.
2665 * This signal is used to let the Helper exit.
2667 * The prototype of the slot is:
2669 * void exit (const HelperAgent *agent, int ic, const String &ic_uuid);
2672 * - agent The pointer to the HelperAgent object which emits this signal.
2673 * - ic An opaque handle of the currently focused input context.
2674 * - ic_uuid The UUID of the IMEngineInstance associated with the focused input context.
2677 HelperAgent::signal_connect_exit (HelperAgentSlotVoid *slot)
2679 return m_impl->signal_exit.connect (slot);
2683 * @brief Connect a slot to Helper attach input context signal.
2685 * This signal is used to attach an input context to this helper.
2687 * When an input context requst to start this helper, then this
2688 * signal will be emitted as soon as the helper is started.
2690 * When an input context want to start an already started helper,
2691 * this signal will also be emitted.
2693 * Helper can send some events back to the IMEngineInstance in this
2694 * signal-slot, to inform that it has been started sccessfully.
2696 * The prototype of the slot is:
2698 * void attach_input_context (const HelperAgent *agent, int ic, const String &ic_uuid);
2701 HelperAgent::signal_connect_attach_input_context (HelperAgentSlotVoid *slot)
2703 return m_impl->signal_attach_input_context.connect (slot);
2707 * @brief Connect a slot to Helper detach input context signal.
2709 * This signal is used to detach an input context from this helper.
2711 * When an input context requst to stop this helper, then this
2712 * signal will be emitted.
2714 * Helper shouldn't send any event back to the IMEngineInstance, because
2715 * the IMEngineInstance attached to the ic should have been destroyed.
2717 * The prototype of the slot is:
2719 * void detach_input_context (const HelperAgent *agent, int ic, const String &ic_uuid);
2722 HelperAgent::signal_connect_detach_input_context (HelperAgentSlotVoid *slot)
2724 return m_impl->signal_detach_input_context.connect (slot);
2728 * @brief Connect a slot to Helper reload config signal.
2730 * This signal is used to let the Helper reload configuration.
2732 * The prototype of the slot is:
2734 * void reload_config (const HelperAgent *agent, int ic, const String &ic_uuid);
2737 HelperAgent::signal_connect_reload_config (HelperAgentSlotVoid *slot)
2739 return m_impl->signal_reload_config.connect (slot);
2743 * @brief Connect a slot to Helper update screen signal.
2745 * This signal is used to let the Helper move its GUI to another screen.
2746 * It can only be emitted when SCIM_HELPER_NEED_SCREEN_INFO is set in HelperInfo.option.
2748 * The prototype of the slot is:
2750 * void update_screen (const HelperAgent *agent, int ic, const String &ic_uuid, int screen_number);
2753 HelperAgent::signal_connect_update_screen (HelperAgentSlotInt *slot)
2755 return m_impl->signal_update_screen.connect (slot);
2759 * @brief Connect a slot to Helper update spot location signal.
2761 * This signal is used to let the Helper move its GUI according to the current spot location.
2762 * It can only be emitted when SCIM_HELPER_NEED_SPOT_LOCATION_INFO is set in HelperInfo.option.
2764 * The prototype of the slot is:
2765 * void update_spot_location (const HelperAgent *agent, int ic, const String &ic_uuid, int x, int y);
2768 HelperAgent::signal_connect_update_spot_location (HelperAgentSlotIntInt *slot)
2770 return m_impl->signal_update_spot_location.connect (slot);
2774 * @brief Connect a slot to Helper update cursor position signal.
2776 * This signal is used to let the Helper get the cursor position information.
2778 * The prototype of the slot is:
2779 * void update_cursor_position (const HelperAgent *agent, int ic, const String &ic_uuid, int cursor_pos);
2782 HelperAgent::signal_connect_update_cursor_position (HelperAgentSlotInt *slot)
2784 return m_impl->signal_update_cursor_position.connect (slot);
2788 * @brief Connect a slot to Helper update surrounding text signal.
2790 * This signal is used to let the Helper get the surrounding text.
2792 * The prototype of the slot is:
2793 * void update_surrounding_text (const HelperAgent *agent, int ic, const String &text, int cursor);
2796 HelperAgent::signal_connect_update_surrounding_text (HelperAgentSlotInt *slot)
2798 return m_impl->signal_update_surrounding_text.connect (slot);
2802 * @brief Connect a slot to Helper update selection signal.
2804 * This signal is used to let the Helper get the selection.
2806 * The prototype of the slot is:
2807 * void update_selection (const HelperAgent *agent, int ic, const String &text);
2810 HelperAgent::signal_connect_update_selection (HelperAgentSlotVoid *slot)
2812 return m_impl->signal_update_selection.connect (slot);
2816 * @brief Connect a slot to Helper trigger property signal.
2818 * This signal is used to trigger a property registered by this Helper.
2819 * A property will be triggered when user clicks on it.
2821 * The prototype of the slot is:
2822 * void trigger_property (const HelperAgent *agent, int ic, const String &ic_uuid, const String &property);
2825 HelperAgent::signal_connect_trigger_property (HelperAgentSlotString *slot)
2827 return m_impl->signal_trigger_property.connect (slot);
2831 * @brief Connect a slot to Helper process imengine event signal.
2833 * This signal is used to deliver the events sent from IMEngine to Helper.
2835 * The prototype of the slot is:
2836 * void process_imengine_event (const HelperAgent *agent, int ic, const String &ic_uuid, const Transaction &transaction);
2839 HelperAgent::signal_connect_process_imengine_event (HelperAgentSlotTransaction *slot)
2841 return m_impl->signal_process_imengine_event.connect (slot);
2845 * @brief Connect a slot to Helper focus out signal.
2847 * This signal is used to do something when input context is focus out.
2849 * The prototype of the slot is:
2850 * void focus_out (const HelperAgent *agent, int ic, const String &ic_uuid);
2853 HelperAgent::signal_connect_focus_out (HelperAgentSlotVoid *slot)
2855 return m_impl->signal_focus_out.connect (slot);
2859 * @brief Connect a slot to Helper focus in signal.
2861 * This signal is used to do something when input context is focus in.
2863 * The prototype of the slot is:
2864 * void focus_in (const HelperAgent *agent, int ic, const String &ic_uuid);
2867 HelperAgent::signal_connect_focus_in (HelperAgentSlotVoid *slot)
2869 return m_impl->signal_focus_in.connect (slot);
2873 * @brief Connect a slot to Helper show signal.
2875 * This signal is used to show Helper ISE window.
2877 * The prototype of the slot is:
2878 * void ise_show (const HelperAgent *agent, int ic, char *buf, size_t &len);
2881 HelperAgent::signal_connect_ise_show (HelperAgentSlotIntRawVoid *slot)
2883 return m_impl->signal_ise_show.connect (slot);
2887 * @brief Connect a slot to Helper hide signal.
2889 * This signal is used to hide Helper ISE window.
2891 * The prototype of the slot is:
2892 * void ise_hide (const HelperAgent *agent, int ic, const String &ic_uuid);
2895 HelperAgent::signal_connect_ise_hide (HelperAgentSlotVoid *slot)
2897 return m_impl->signal_ise_hide.connect (slot);
2901 * @brief Connect a slot to Helper get ISE window geometry signal.
2903 * This signal is used to get Helper ISE window size and position.
2905 * The prototype of the slot is:
2906 * void get_geometry (const HelperAgent *agent, struct rectinfo &info);
2909 HelperAgent::signal_connect_get_geometry (HelperAgentSlotSize *slot)
2911 return m_impl->signal_get_geometry.connect (slot);
2915 * @brief Connect a slot to Helper set mode signal.
2917 * This signal is used to set Helper ISE mode.
2919 * The prototype of the slot is:
2920 * void set_mode (const HelperAgent *agent, uint32 &mode);
2923 HelperAgent::signal_connect_set_mode (HelperAgentSlotUintVoid *slot)
2925 return m_impl->signal_set_mode.connect (slot);
2929 * @brief Connect a slot to Helper set language signal.
2931 * This signal is used to set Helper ISE language.
2933 * The prototype of the slot is:
2934 * void set_language (const HelperAgent *agent, uint32 &language);
2937 HelperAgent::signal_connect_set_language (HelperAgentSlotUintVoid *slot)
2939 return m_impl->signal_set_language.connect (slot);
2943 * @brief Connect a slot to Helper set im data signal.
2945 * This signal is used to send im data to Helper ISE.
2947 * The prototype of the slot is:
2948 * void set_imdata (const HelperAgent *agent, char *buf, size_t &len);
2951 HelperAgent::signal_connect_set_imdata (HelperAgentSlotRawVoid *slot)
2953 return m_impl->signal_set_imdata.connect (slot);
2957 * @brief Connect a slot to Helper get im data signal.
2959 * This signal is used to get im data from Helper ISE.
2961 * The prototype of the slot is:
2962 * void get_imdata (const HelperAgent *, char **buf, size_t &len);
2965 HelperAgent::signal_connect_get_imdata (HelperAgentSlotGetRawVoid *slot)
2967 return m_impl->signal_get_imdata.connect (slot);
2971 * @brief Connect a slot to Helper get language locale signal.
2973 * This signal is used to get language locale from Helper ISE.
2975 * The prototype of the slot is:
2976 * void get_language_locale (const HelperAgent *, int ic, char **locale);
2979 HelperAgent::signal_connect_get_language_locale (HelperAgentSlotIntGetStringVoid *slot)
2981 return m_impl->signal_get_language_locale.connect (slot);
2985 * @brief Connect a slot to Helper set return key type signal.
2987 * This signal is used to send return key type to Helper ISE.
2989 * The prototype of the slot is:
2990 * void set_return_key_type (const HelperAgent *agent, uint32 &type);
2993 HelperAgent::signal_connect_set_return_key_type (HelperAgentSlotUintVoid *slot)
2995 return m_impl->signal_set_return_key_type.connect (slot);
2999 * @brief Connect a slot to Helper get return key type signal.
3001 * This signal is used to get return key type from Helper ISE.
3003 * The prototype of the slot is:
3004 * void get_return_key_type (const HelperAgent *agent, uint32 &type);
3007 HelperAgent::signal_connect_get_return_key_type (HelperAgentSlotUintVoid *slot)
3009 return m_impl->signal_get_return_key_type.connect (slot);
3013 * @brief Connect a slot to Helper set return key disable signal.
3015 * This signal is used to send return key disable to Helper ISE.
3017 * The prototype of the slot is:
3018 * void set_return_key_disable (const HelperAgent *agent, uint32 &disabled);
3021 HelperAgent::signal_connect_set_return_key_disable (HelperAgentSlotUintVoid *slot)
3023 return m_impl->signal_set_return_key_disable.connect (slot);
3027 * @brief Connect a slot to Helper process key event signal.
3029 * This signal is used to send keyboard key event to Helper ISE.
3031 * The prototype of the slot is:
3032 * void process_key_event (const HelperAgent *agent, KeyEvent &key, uint32 &ret);
3035 HelperAgent::signal_connect_process_key_event (HelperAgentSlotKeyEventUint *slot)
3037 return m_impl->signal_process_key_event.connect (slot);
3041 * @brief Connect a slot to Helper get return key disable signal.
3043 * This signal is used to get return key disable from Helper ISE.
3045 * The prototype of the slot is:
3046 * void get_return_key_disable (const HelperAgent *agent, uint32 &disabled);
3049 HelperAgent::signal_connect_get_return_key_disable (HelperAgentSlotUintVoid *slot)
3051 return m_impl->signal_get_return_key_disable.connect (slot);
3055 * @brief Connect a slot to Helper set layout signal.
3057 * This signal is used to set Helper ISE layout.
3059 * The prototype of the slot is:
3060 * void set_layout (const HelperAgent *agent, uint32 &layout);
3063 HelperAgent::signal_connect_set_layout (HelperAgentSlotUintVoid *slot)
3065 return m_impl->signal_set_layout.connect (slot);
3069 * @brief Connect a slot to Helper get layout signal.
3071 * This signal is used to get Helper ISE layout.
3073 * The prototype of the slot is:
3074 * void get_layout (const HelperAgent *agent, uint32 &layout);
3077 HelperAgent::signal_connect_get_layout (HelperAgentSlotUintVoid *slot)
3079 return m_impl->signal_get_layout.connect (slot);
3083 * @brief Connect a slot to Helper set input mode signal.
3085 * This signal is used to set Helper ISE input mode.
3087 * The prototype of the slot is:
3088 * void set_input_mode (const HelperAgent *agent, uint32 &input_mode);
3091 HelperAgent::signal_connect_set_input_mode (HelperAgentSlotUintVoid *slot)
3093 return m_impl->signal_set_input_mode.connect (slot);
3097 * @brief Connect a slot to Helper set input hint signal.
3099 * This signal is used to set Helper ISE input hint.
3101 * The prototype of the slot is:
3102 * void set_input_hint (const HelperAgent *agent, uint32 &input_hint);
3105 HelperAgent::signal_connect_set_input_hint (HelperAgentSlotUintVoid *slot)
3107 return m_impl->signal_set_input_hint.connect (slot);
3111 * @brief Connect a slot to Helper set BiDi direction signal.
3113 * This signal is used to set Helper ISE BiDi direction.
3115 * The prototype of the slot is:
3116 * void update_bidi_direction (const HelperAgent *agent, uint32 &bidi_direction);
3119 HelperAgent::signal_connect_update_bidi_direction (HelperAgentSlotUintVoid *slot)
3121 return m_impl->signal_update_bidi_direction.connect (slot);
3125 * @brief Connect a slot to Helper set shift mode signal.
3127 * This signal is used to set Helper shift mode.
3129 * The prototype of the slot is:
3130 * void set_caps_mode (const HelperAgent *agent, uint32 &mode);
3133 HelperAgent::signal_connect_set_caps_mode (HelperAgentSlotUintVoid *slot)
3135 return m_impl->signal_set_caps_mode.connect (slot);
3139 * @brief Connect a slot to Helper reset input context signal.
3141 * This signal is used to reset Helper ISE input context.
3143 * The prototype of the slot is:
3144 * void reset_input_context (const HelperAgent *agent, int ic, const String &uuid);
3147 HelperAgent::signal_connect_reset_input_context (HelperAgentSlotVoid *slot)
3149 return m_impl->signal_reset_input_context.connect (slot);
3153 * @brief Connect a slot to Helper update candidate window geometry signal.
3155 * This signal is used to get candidate window size and position.
3157 * The prototype of the slot is:
3158 * void update_candidate_geometry (const HelperAgent *agent, int ic, const String &uuid, const rectinfo &info);
3161 HelperAgent::signal_connect_update_candidate_geometry (HelperAgentSlotRect *slot)
3163 return m_impl->signal_update_candidate_geometry.connect (slot);
3167 * @brief Connect a slot to Helper update keyboard ISE signal.
3169 * This signal is used to get current keyboard ISE name and uuid.
3171 * The prototype of the slot is:
3172 * void update_keyboard_ise (const HelperAgent *agent, int ic, const String &uuid,
3173 * const String &ise_name, const String &ise_uuid);
3176 HelperAgent::signal_connect_update_keyboard_ise (HelperAgentSlotString2 *slot)
3178 return m_impl->signal_update_keyboard_ise.connect (slot);
3182 * @brief Connect a slot to Helper update keyboard ISE list signal.
3184 * This signal is used to get uuid list of all keyboard ISEs.
3186 * The prototype of the slot is:
3187 * void update_keyboard_ise_list (const HelperAgent *agent, int ic, const String &uuid,
3188 * const std::vector<String> &ise_list);
3191 HelperAgent::signal_connect_update_keyboard_ise_list (HelperAgentSlotStringVector *slot)
3193 return m_impl->signal_update_keyboard_ise_list.connect (slot);
3197 * @brief Connect a slot to Helper candidate more window show signal.
3199 * This signal is used to do someting when candidate more window is showed.
3201 * The prototype of the slot is:
3202 * void candidate_more_window_show (const HelperAgent *agent, int ic, const String &uuid);
3205 HelperAgent::signal_connect_candidate_more_window_show (HelperAgentSlotVoid *slot)
3207 return m_impl->signal_candidate_more_window_show.connect (slot);
3211 * @brief Connect a slot to Helper candidate more window hide signal.
3213 * This signal is used to do someting when candidate more window is hidden.
3215 * The prototype of the slot is:
3216 * void candidate_more_window_hide (const HelperAgent *agent, int ic, const String &uuid);
3219 HelperAgent::signal_connect_candidate_more_window_hide (HelperAgentSlotVoid *slot)
3221 return m_impl->signal_candidate_more_window_hide.connect (slot);
3225 * @brief Connect a slot to Helper candidate show signal.
3227 * This signal is used to do candidate show.
3229 * The prototype of the slot is:
3230 * void candidate_show (const HelperAgent *agent, int ic, const String &uuid);
3233 HelperAgent::signal_connect_candidate_show (HelperAgentSlotVoid *slot)
3235 return m_impl->signal_candidate_show.connect (slot);
3239 * @brief Connect a slot to Helper candidate hide signal.
3241 * This signal is used to do candidate hide.
3243 * The prototype of the slot is:
3244 * void candidate_hide (const HelperAgent *agent, int ic, const String &uuid);
3247 HelperAgent::signal_connect_candidate_hide (HelperAgentSlotVoid *slot)
3249 return m_impl->signal_candidate_hide.connect (slot);
3253 * @brief Connect a slot to Helper update lookup table signal.
3255 * This signal is used to do someting when update lookup table.
3257 * The prototype of the slot is:
3258 * void update_lookup_table (const HelperAgent *agent, int ic, const String &uuid ,LookupTable &table);
3261 HelperAgent::signal_connect_update_lookup_table (HelperAgentSlotLookupTable *slot)
3263 return m_impl->signal_update_lookup_table.connect (slot);
3267 * @brief Connect a slot to Helper select aux signal.
3269 * This signal is used to do something when aux is selected.
3271 * The prototype of the slot is:
3272 * void select_aux (const HelperAgent *agent, int ic, const String &uuid, int index);
3275 HelperAgent::signal_connect_select_aux (HelperAgentSlotInt *slot)
3277 return m_impl->signal_select_aux.connect (slot);
3281 * @brief Connect a slot to Helper select candidate signal.
3283 * This signal is used to do something when candidate is selected.
3285 * The prototype of the slot is:
3286 * void select_candidate (const HelperAgent *agent, int ic, const String &uuid, int index);
3289 HelperAgent::signal_connect_select_candidate (HelperAgentSlotInt *slot)
3291 return m_impl->signal_select_candidate.connect (slot);
3295 * @brief Connect a slot to Helper candidate table page up signal.
3297 * This signal is used to do something when candidate table is paged up.
3299 * The prototype of the slot is:
3300 * void candidate_table_page_up (const HelperAgent *agent, int ic, const String &uuid);
3303 HelperAgent::signal_connect_candidate_table_page_up (HelperAgentSlotVoid *slot)
3305 return m_impl->signal_candidate_table_page_up.connect (slot);
3309 * @brief Connect a slot to Helper candidate table page down signal.
3311 * This signal is used to do something when candidate table is paged down.
3313 * The prototype of the slot is:
3314 * void candidate_table_page_down (const HelperAgent *agent, int ic, const String &uuid);
3317 HelperAgent::signal_connect_candidate_table_page_down (HelperAgentSlotVoid *slot)
3319 return m_impl->signal_candidate_table_page_down.connect (slot);
3323 * @brief Connect a slot to Helper update candidate table page size signal.
3325 * This signal is used to do something when candidate table page size is changed.
3327 * The prototype of the slot is:
3328 * void update_candidate_table_page_size (const HelperAgent *, int ic, const String &uuid, int page_size);
3331 HelperAgent::signal_connect_update_candidate_table_page_size (HelperAgentSlotInt *slot)
3333 return m_impl->signal_update_candidate_table_page_size.connect (slot);
3337 * @brief Connect a slot to Helper update candidate item layout signal.
3339 * The prototype of the slot is:
3340 * void update_candidate_item_layout (const HelperAgent *, const std::vector<uint32> &row_items);
3343 HelperAgent::signal_connect_update_candidate_item_layout (HelperAgentSlotUintVector *slot)
3345 return m_impl->signal_update_candidate_item_layout.connect (slot);
3349 * @brief Connect a slot to Helper select associate signal.
3351 * This signal is used to do something when associate is selected.
3353 * The prototype of the slot is:
3354 * void select_associate (const HelperAgent *agent, int ic, const String &uuid, int index);
3357 HelperAgent::signal_connect_select_associate (HelperAgentSlotInt *slot)
3359 return m_impl->signal_select_associate.connect (slot);
3363 * @brief Connect a slot to Helper associate table page up signal.
3365 * This signal is used to do something when associate table is paged up.
3367 * The prototype of the slot is:
3368 * void associate_table_page_up (const HelperAgent *agent, int ic, const String &uuid);
3371 HelperAgent::signal_connect_associate_table_page_up (HelperAgentSlotVoid *slot)
3373 return m_impl->signal_associate_table_page_up.connect (slot);
3377 * @brief Connect a slot to Helper associate table page down signal.
3379 * This signal is used to do something when associate table is paged down.
3381 * The prototype of the slot is:
3382 * void associate_table_page_down (const HelperAgent *agent, int ic, const String &uuid);
3385 HelperAgent::signal_connect_associate_table_page_down (HelperAgentSlotVoid *slot)
3387 return m_impl->signal_associate_table_page_down.connect (slot);
3391 * @brief Connect a slot to Helper update associate table page size signal.
3393 * This signal is used to do something when associate table page size is changed.
3395 * The prototype of the slot is:
3396 * void update_associate_table_page_size (const HelperAgent *, int ic, const String &uuid, int page_size);
3399 HelperAgent::signal_connect_update_associate_table_page_size (HelperAgentSlotInt *slot)
3401 return m_impl->signal_update_associate_table_page_size.connect (slot);
3405 * @brief Connect a slot to Helper turn on log signal.
3407 * This signal is used to turn on Helper ISE debug information.
3409 * The prototype of the slot is:
3410 * void turn_on_log (const HelperAgent *agent, uint32 &on);
3413 HelperAgent::signal_connect_turn_on_log (HelperAgentSlotUintVoid *slot)
3415 return m_impl->signal_turn_on_log.connect (slot);
3419 * @brief Connect a slot to Helper update displayed candidate number signal.
3421 * This signal is used to inform helper ISE displayed candidate number.
3423 * The prototype of the slot is:
3424 * void update_displayed_candidate_number (const HelperAgent *, int ic, const String &uuid, int number);
3427 HelperAgent::signal_connect_update_displayed_candidate_number (HelperAgentSlotInt *slot)
3429 return m_impl->signal_update_displayed_candidate_number.connect (slot);
3433 * @brief Connect a slot to Helper longpress candidate signal.
3435 * This signal is used to do something when candidate is longpress.
3437 * The prototype of the slot is:
3438 * void longpress_candidate (const HelperAgent *agent, int ic, const String &uuid, int index);
3441 HelperAgent::signal_connect_longpress_candidate (HelperAgentSlotInt *slot)
3443 return m_impl->signal_longpress_candidate.connect (slot);
3447 * @brief Connect a slot to Helper show option window.
3449 * This signal is used to do request the ISE to show option window.
3451 * The prototype of the slot is:
3452 * void show_option_window (const HelperAgent *agent, int ic, const String &uuid);
3455 HelperAgent::signal_connect_show_option_window (HelperAgentSlotVoid *slot)
3457 return m_impl->signal_show_option_window.connect (slot);
3461 * @brief Connect a slot to Helper resume option window.
3463 * This signal is used to do request the ISE to resume option window.
3465 * The prototype of the slot is:
3466 * void resume_option_window (const HelperAgent *agent, int ic, const String &uuid);
3469 HelperAgent::signal_connect_resume_option_window (HelperAgentSlotVoid *slot)
3471 return m_impl->signal_resume_option_window.connect (slot);
3475 * @brief Connect a slot to Helper check if the option is available.
3477 * This signal is used to check if the option (setting) is available from Helper ISE.
3479 * The prototype of the slot is:
3480 * void check_option_window (const HelperAgent *agent, uint32 &avail);
3483 HelperAgent::signal_connect_check_option_window (HelperAgentSlotUintVoid *slot)
3485 return m_impl->signal_check_option_window.connect (slot);
3489 * @brief Connect a slot to Helper process unconventional input device event signal.
3491 * This signal is used to send unconventional input device event to Helper ISE.
3493 * The prototype of the slot is:
3494 * void process_input_device_event (const HelperAgent *, uint32 &type, char *data, size_t &size, uint32 &ret);
3497 HelperAgent::signal_connect_process_input_device_event (HelperAgentSlotUintCharSizeUint *slot)
3499 return m_impl->signal_process_input_device_event.connect (slot);
3503 * @brief Connect a slot to Helper set prediction hint signal.
3505 * This signal is used to send prediction hint to Helper ISE.
3507 * The prototype of the slot is:
3508 * void set_prediction_hint (const HelperAgent *agent, char *prediction_hint);
3511 HelperAgent::signal_connect_set_prediction_hint (HelperAgentSlotStringVoid *slot)
3513 return m_impl->signal_set_prediction_hint.connect (slot);
3516 } /* namespace scim */
3519 vi:ts=4:nowrap:ai:expandtab