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
64 #include "isf_device_event.h"
69 #define LOG_TAG "SCIM_HELPER"
72 //FIXME: remove this definitions
73 #define SHIFT_MODE_OFF 0xffe1
74 #define SHIFT_MODE_ON 0xffe2
75 #define SHIFT_MODE_LOCK 0xffe6
76 #define SHIFT_MODE_ENABLE 0x9fe7
77 #define SHIFT_MODE_DISABLE 0x9fe8
81 typedef Signal3<void, const HelperAgent *, int, const String &>
82 HelperAgentSignalVoid;
84 typedef Signal4<void, const HelperAgent *, int, const String &, const String &>
85 HelperAgentSignalString;
87 typedef Signal4<void, const HelperAgent *, int, const String &, const std::vector<String> &>
88 HelperAgentSignalStringVector;
90 typedef Signal5<void, const HelperAgent *, int, const String &, const String &, const String &>
91 HelperAgentSignalString2;
93 typedef Signal4<void, const HelperAgent *, int, const String &, int>
96 typedef Signal5<void, const HelperAgent *, int, const String &, int, int>
97 HelperAgentSignalIntInt;
99 typedef Signal4<void, const HelperAgent *, int, const String &, const Transaction &>
100 HelperAgentSignalTransaction;
102 typedef Signal4<void, const HelperAgent *, int, const String &, const rectinfo &>
103 HelperAgentSignalRect;
105 typedef Signal2<void, const HelperAgent *, struct rectinfo &>
106 HelperAgentSignalSize;
108 typedef Signal2<void, const HelperAgent *, uint32 &>
109 HelperAgentSignalUintVoid;
111 typedef Signal3<void, const HelperAgent *, int, uint32 &>
112 HelperAgentSignalIntUint;
114 typedef Signal3 <void, const HelperAgent *, char *, size_t &>
115 HelperAgentSignalRawVoid;
117 typedef Signal3 <void, const HelperAgent *, char **, size_t &>
118 HelperAgentSignalGetRawVoid;
120 typedef Signal4 <void, const HelperAgent *, int, char *, size_t &>
121 HelperAgentSignalIntRawVoid;
123 typedef Signal3 <void, const HelperAgent *, int, char **>
124 HelperAgentSignalIntGetStringVoid;
126 typedef Signal2<void, const HelperAgent *, const std::vector<uint32> &>
127 HelperAgentSignalUintVector;
129 typedef Signal2<void, const HelperAgent *, LookupTable &>
130 HelperAgentSignalLookupTable;
132 typedef Signal3<void, const HelperAgent *, KeyEvent &, uint32 &>
133 HelperAgentSignalKeyEventUint;
135 typedef Signal5<void, const HelperAgent *, uint32 &, char *, size_t &, uint32 &>
136 HelperAgentSignalUintCharSizeUint;
138 typedef Signal2<void, const HelperAgent *, const String &>
139 HelperAgentSignalStringVoid;
141 class HelperAgent::HelperAgentImpl
145 SocketClient socket_active;
154 IMEngineInstancePointer si;
155 ConfigPointer m_config;
156 IMEngineModule engine_module;
158 char* surrounding_text;
159 char* selection_text;
161 int need_update_surrounding_text;
162 int need_update_selection_text;
165 bool hw_keyboard_mode;
167 HelperAgentSignalVoid signal_exit;
168 HelperAgentSignalVoid signal_attach_input_context;
169 HelperAgentSignalVoid signal_detach_input_context;
170 HelperAgentSignalVoid signal_reload_config;
171 HelperAgentSignalInt signal_update_screen;
172 HelperAgentSignalIntInt signal_update_spot_location;
173 HelperAgentSignalInt signal_update_cursor_position;
174 HelperAgentSignalInt signal_update_surrounding_text;
175 HelperAgentSignalVoid signal_update_selection;
176 HelperAgentSignalString signal_trigger_property;
177 HelperAgentSignalTransaction signal_process_imengine_event;
178 HelperAgentSignalVoid signal_focus_out;
179 HelperAgentSignalVoid signal_focus_in;
180 HelperAgentSignalIntRawVoid signal_ise_show;
181 HelperAgentSignalVoid signal_ise_hide;
182 HelperAgentSignalVoid signal_candidate_show;
183 HelperAgentSignalVoid signal_candidate_hide;
184 HelperAgentSignalSize signal_get_geometry;
185 HelperAgentSignalUintVoid signal_set_mode;
186 HelperAgentSignalUintVoid signal_set_language;
187 HelperAgentSignalRawVoid signal_set_imdata;
188 HelperAgentSignalGetRawVoid signal_get_imdata;
189 HelperAgentSignalIntGetStringVoid signal_get_language_locale;
190 HelperAgentSignalUintVoid signal_set_return_key_type;
191 HelperAgentSignalUintVoid signal_get_return_key_type;
192 HelperAgentSignalUintVoid signal_set_return_key_disable;
193 HelperAgentSignalUintVoid signal_get_return_key_disable;
194 HelperAgentSignalUintVoid signal_set_layout;
195 HelperAgentSignalUintVoid signal_get_layout;
196 HelperAgentSignalUintVoid signal_set_caps_mode;
197 HelperAgentSignalVoid signal_reset_input_context;
198 HelperAgentSignalIntInt signal_update_candidate_ui;
199 HelperAgentSignalRect signal_update_candidate_geometry;
200 HelperAgentSignalString2 signal_update_keyboard_ise;
201 HelperAgentSignalStringVector signal_update_keyboard_ise_list;
202 HelperAgentSignalVoid signal_candidate_more_window_show;
203 HelperAgentSignalVoid signal_candidate_more_window_hide;
204 HelperAgentSignalLookupTable signal_update_lookup_table;
205 HelperAgentSignalInt signal_select_aux;
206 HelperAgentSignalInt signal_select_candidate;
207 HelperAgentSignalVoid signal_candidate_table_page_up;
208 HelperAgentSignalVoid signal_candidate_table_page_down;
209 HelperAgentSignalInt signal_update_candidate_table_page_size;
210 HelperAgentSignalUintVector signal_update_candidate_item_layout;
211 HelperAgentSignalInt signal_select_associate;
212 HelperAgentSignalVoid signal_associate_table_page_up;
213 HelperAgentSignalVoid signal_associate_table_page_down;
214 HelperAgentSignalInt signal_update_associate_table_page_size;
215 HelperAgentSignalVoid signal_reset_ise_context;
216 HelperAgentSignalUintVoid signal_turn_on_log;
217 HelperAgentSignalInt signal_update_displayed_candidate_number;
218 HelperAgentSignalInt signal_longpress_candidate;
219 HelperAgentSignalKeyEventUint signal_process_key_event;
220 HelperAgentSignalUintVoid signal_set_input_mode;
221 HelperAgentSignalUintVoid signal_set_input_hint;
222 HelperAgentSignalUintVoid signal_update_bidi_direction;
223 HelperAgentSignalVoid signal_show_option_window;
224 HelperAgentSignalVoid signal_resume_option_window;
225 HelperAgentSignalUintVoid signal_check_option_window;
226 HelperAgentSignalUintCharSizeUint signal_process_input_device_event;
227 HelperAgentSignalStringVoid signal_set_prediction_hint;
228 HelperAgentSignalStringVoid signal_set_mime_type;
231 HelperAgentImpl (HelperAgent* thiz) : magic(0), magic_active(0), timeout(-1), focused_ic ((uint32) -1), thiz (thiz),
232 surrounding_text (NULL), selection_text (NULL), cursor_pos (0),
233 need_update_surrounding_text (0), need_update_selection_text (0),
234 layout (0), ise_show_flag (false), hw_keyboard_mode (false) {
237 ~HelperAgentImpl () {
242 if (surrounding_text != NULL)
243 free (surrounding_text);
245 if (selection_text != NULL)
246 free (selection_text);
248 if (engine_module.valid ()) {
249 engine_module.unload ();
253 // Implementation of slot functions
255 slot_show_preedit_string (IMEngineInstanceBase *si)
257 thiz->show_preedit_string (focused_ic, "");
261 slot_show_aux_string (IMEngineInstanceBase *si)
263 thiz->show_aux_string ();
267 slot_show_lookup_table (IMEngineInstanceBase *si)
269 thiz->show_candidate_string ();
273 slot_hide_preedit_string (IMEngineInstanceBase *si)
275 thiz->hide_preedit_string (focused_ic, "");
279 slot_hide_aux_string (IMEngineInstanceBase *si)
281 thiz->hide_aux_string ();
285 slot_hide_lookup_table (IMEngineInstanceBase *si)
287 thiz->hide_candidate_string ();
291 slot_update_preedit_caret (IMEngineInstanceBase *si, int caret)
293 thiz->update_preedit_caret (caret);
297 slot_update_preedit_string (IMEngineInstanceBase *si,
298 const WideString & str,
299 const AttributeList & attrs,
302 thiz->update_preedit_string (-1, "", str, attrs, caret);
306 slot_update_preedit_string_with_commit (IMEngineInstanceBase *si,
307 const WideString & preedit,
308 const WideString & commit,
309 const AttributeList & attrs,
312 thiz->update_preedit_string (-1, "", preedit, commit, attrs, caret);
316 slot_update_aux_string (IMEngineInstanceBase *si,
317 const WideString & str,
318 const AttributeList & attrs)
320 thiz->update_aux_string (utf8_wcstombs(str), attrs);
324 slot_commit_string (IMEngineInstanceBase *si,
325 const WideString & str)
327 thiz->commit_string (-1, "", str);
331 slot_recapture_string (IMEngineInstanceBase *si,
334 const WideString & preedit,
335 const WideString & commit,
336 const AttributeList & attrs)
338 thiz->recapture_string (-1, "", offset, len, preedit, commit, attrs);
342 slot_forward_key_event (IMEngineInstanceBase *si,
343 const KeyEvent & key)
345 thiz->forward_key_event (-1, "", key);
349 slot_update_lookup_table (IMEngineInstanceBase *si,
350 const LookupTable & table)
352 thiz->update_candidate_string (table);
356 slot_register_properties (IMEngineInstanceBase *si,
357 const PropertyList & properties)
359 thiz->register_properties (properties);
363 slot_update_property (IMEngineInstanceBase *si,
364 const Property & property)
366 thiz->update_property (property);
370 slot_beep (IMEngineInstanceBase *si)
376 slot_start_helper (IMEngineInstanceBase *si,
377 const String &helper_uuid)
379 LOGW ("deprecated function");
383 slot_stop_helper (IMEngineInstanceBase *si,
384 const String &helper_uuid)
386 LOGW ("deprecated function");
390 slot_send_helper_event (IMEngineInstanceBase *si,
391 const String &helper_uuid,
392 const Transaction &trans)
394 signal_process_imengine_event (thiz, focused_ic, helper_uuid, trans);
398 slot_get_surrounding_text (IMEngineInstanceBase *si,
405 thiz->get_surrounding_text (maxlen_before, maxlen_after, _text, cursor);
406 text = utf8_mbstowcs(_text);
411 slot_delete_surrounding_text (IMEngineInstanceBase *si,
416 thiz->delete_surrounding_text (offset, len);
421 slot_get_selection (IMEngineInstanceBase *si,
425 thiz->get_selection_text (_text);
426 text = utf8_mbstowcs (_text);
431 slot_set_selection (IMEngineInstanceBase *si,
435 thiz->set_selection (start, end);
440 slot_expand_candidate (IMEngineInstanceBase *si)
442 thiz->expand_candidate ();
446 slot_contract_candidate (IMEngineInstanceBase *si)
448 thiz->contract_candidate ();
452 slot_set_candidate_style (IMEngineInstanceBase *si, ISF_CANDIDATE_PORTRAIT_LINE_T portrait_line, ISF_CANDIDATE_MODE_T mode)
454 thiz->set_candidate_style (portrait_line, mode);
458 slot_send_private_command (IMEngineInstanceBase *si,
459 const String &command)
461 thiz->send_private_command (command);
465 slot_commit_content (IMEngineInstanceBase *si,
466 const String &content,
467 const String &description,
468 const String &mime_types)
471 thiz->commit_content (content, description, mime_types);
477 si->signal_connect_show_preedit_string (
478 slot (this, &HelperAgent::HelperAgentImpl::slot_show_preedit_string));
479 si->signal_connect_show_aux_string (
480 slot (this, &HelperAgent::HelperAgentImpl::slot_show_aux_string));
481 si->signal_connect_show_lookup_table (
482 slot (this, &HelperAgent::HelperAgentImpl::slot_show_lookup_table));
484 si->signal_connect_hide_preedit_string (
485 slot (this, &HelperAgent::HelperAgentImpl::slot_hide_preedit_string));
486 si->signal_connect_hide_aux_string (
487 slot (this, &HelperAgent::HelperAgentImpl::slot_hide_aux_string));
488 si->signal_connect_hide_lookup_table (
489 slot (this, &HelperAgent::HelperAgentImpl::slot_hide_lookup_table));
491 si->signal_connect_update_preedit_caret (
492 slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_caret));
493 si->signal_connect_update_preedit_string (
494 slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_string));
495 si->signal_connect_update_preedit_string_with_commit (
496 slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_string_with_commit));
497 si->signal_connect_recapture_string (
498 slot (this, &HelperAgent::HelperAgentImpl::slot_recapture_string));
500 si->signal_connect_update_aux_string (
501 slot (this, &HelperAgent::HelperAgentImpl::slot_update_aux_string));
502 si->signal_connect_update_lookup_table (
503 slot (this, &HelperAgent::HelperAgentImpl::slot_update_lookup_table));
505 si->signal_connect_commit_string (
506 slot (this, &HelperAgent::HelperAgentImpl::slot_commit_string));
508 si->signal_connect_forward_key_event (
509 slot (this, &HelperAgent::HelperAgentImpl::slot_forward_key_event));
511 si->signal_connect_register_properties (
512 slot (this, &HelperAgent::HelperAgentImpl::slot_register_properties));
514 si->signal_connect_update_property (
515 slot (this, &HelperAgent::HelperAgentImpl::slot_update_property));
517 si->signal_connect_beep (
518 slot (this, &HelperAgent::HelperAgentImpl::slot_beep));
520 si->signal_connect_start_helper (
521 slot (this, &HelperAgent::HelperAgentImpl::slot_start_helper));
523 si->signal_connect_stop_helper (
524 slot (this, &HelperAgent::HelperAgentImpl::slot_stop_helper));
526 si->signal_connect_send_helper_event (
527 slot (this, &HelperAgent::HelperAgentImpl::slot_send_helper_event));
529 si->signal_connect_get_surrounding_text (
530 slot (this, &HelperAgent::HelperAgentImpl::slot_get_surrounding_text));
532 si->signal_connect_delete_surrounding_text (
533 slot (this, &HelperAgent::HelperAgentImpl::slot_delete_surrounding_text));
535 si->signal_connect_get_selection (
536 slot (this, &HelperAgent::HelperAgentImpl::slot_get_selection));
538 si->signal_connect_set_selection (
539 slot (this, &HelperAgent::HelperAgentImpl::slot_set_selection));
541 si->signal_connect_expand_candidate (
542 slot (this, &HelperAgent::HelperAgentImpl::slot_expand_candidate));
543 si->signal_connect_contract_candidate (
544 slot (this, &HelperAgent::HelperAgentImpl::slot_contract_candidate));
546 si->signal_connect_set_candidate_style (
547 slot (this, &HelperAgent::HelperAgentImpl::slot_set_candidate_style));
549 si->signal_connect_send_private_command (
550 slot (this, &HelperAgent::HelperAgentImpl::slot_send_private_command));
553 void process_key_event_done (KeyEvent &key, uint32 ret, uint32 serial) {
554 LOGD ("ret: %d, serial: %d", ret, serial);
555 if (socket_active.is_connected ()) {
557 send.put_command (SCIM_TRANS_CMD_REQUEST);
558 send.put_data (magic_active);
559 send.put_command (ISM_TRANS_CMD_PROCESS_KEY_EVENT_DONE);
562 send.put_data (serial);
563 send.write_to_socket (socket_active, magic_active);
567 void request_ise_hide () {
568 if (socket_active.is_connected ()) {
570 send.put_command (SCIM_TRANS_CMD_REQUEST);
571 send.put_data (magic_active);
572 send.put_command (ISM_TRANS_CMD_REQUEST_ISE_HIDE);
573 send.write_to_socket (socket_active, magic_active);
577 HelperAgentImpl () : magic (0), magic_active (0), timeout (-1), focused_ic ((uint32) -1) { }
580 static MessageQueue message_queue;
582 HelperAgent::HelperAgent ()
583 : m_impl (new HelperAgentImpl (this))
585 message_queue.create();
588 HelperAgent::~HelperAgent ()
590 message_queue.destroy();
595 * @brief Open socket connection to the Panel.
597 * @param info The information of this Helper object.
598 * @param display The display which this Helper object should run on.
600 * @return The connection socket id. -1 means failed to create
604 HelperAgent::open_connection (const HelperInfo &info,
605 const String &display)
607 if (m_impl->socket.is_connected ())
610 SocketAddress address (scim_get_default_panel_socket_address (display));
611 int timeout = m_impl->timeout = scim_get_default_socket_timeout ();
614 if (!address.valid ())
618 std::cerr << " Connecting to PanelAgent server.";
619 ISF_LOG (" Connecting to PanelAgent server.\n");
620 while (!m_impl->socket.connect (address)) {
622 scim_usleep (100000);
624 std::cerr << "m_impl->socket.connect () is failed!!!\n";
625 ISF_LOG ("m_impl->socket.connect () is failed!!!\n");
629 std::cerr << " Connected :" << i << "\n";
630 ISF_LOG (" Connected :%d\n", i);
631 LOGD ("Connection to PanelAgent succeeded, %d\n", i);
633 /* Let's retry 10 times when failed */
634 int open_connection_retries = 0;
635 while (!scim_socket_open_connection (magic,
640 if (++open_connection_retries > 10) {
641 m_impl->socket.close ();
642 std::cerr << "scim_socket_open_connection () is failed!!!\n";
643 ISF_LOG ("scim_socket_open_connection () is failed!!!\n");
644 ISF_SAVE_LOG ("scim_socket_open_connection failed, %d\n", timeout);
649 /* Retry after re-connecting the socket */
650 if (m_impl->socket.is_connected ())
653 /* This time, just retry atmost 2 seconds */
655 while (!m_impl->socket.connect (address) && ++i < 10) {
656 scim_usleep (200000);
660 ISF_LOG ("scim_socket_open_connection () is successful.\n");
661 LOGD ("scim_socket_open_connection successful\n");
663 m_impl->send.clear ();
664 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
665 m_impl->send.put_data (magic);
666 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_REGISTER_HELPER);
667 m_impl->send.put_data (info.uuid);
668 m_impl->send.put_data (info.name);
669 m_impl->send.put_data (info.icon);
670 m_impl->send.put_data (info.description);
671 m_impl->send.put_data (info.option);
673 if (!m_impl->send.write_to_socket (m_impl->socket, magic)) {
674 m_impl->socket.close ();
679 if (m_impl->recv.read_from_socket (m_impl->socket, timeout) &&
680 m_impl->recv.get_command (cmd) && cmd == SCIM_TRANS_CMD_REPLY &&
681 m_impl->recv.get_command (cmd) && cmd == SCIM_TRANS_CMD_OK) {
682 m_impl->magic = magic;
684 while (m_impl->recv.get_command (cmd)) {
686 case SCIM_TRANS_CMD_HELPER_ATTACH_INPUT_CONTEXT:
690 while (m_impl->recv.get_data (ic) && m_impl->recv.get_data (ic_uuid))
691 m_impl->signal_attach_input_context (this, ic, ic_uuid);
694 case SCIM_TRANS_CMD_UPDATE_SCREEN:
697 if (m_impl->recv.get_data (screen))
698 m_impl->signal_update_screen (this, (uint32) -1, String (""), (int) screen);
706 //FIXME: Attaching input context is needed for desktop environment
707 LOGW ("Attach input context and update screen failed");
710 ISF_SAVE_LOG ("Trying connect() with Helper_Active\n");
712 /* connect to the panel agent as the active helper client */
713 if (!m_impl->socket_active.connect (address)) return -1;
714 open_connection_retries = 0;
715 while (!scim_socket_open_connection (magic,
716 String ("Helper_Active"),
718 m_impl->socket_active,
720 if (++open_connection_retries > 10) {
721 m_impl->socket_active.close ();
722 std::cerr << "Helper_Active scim_socket_open_connection () is failed!!!\n";
723 ISF_LOG ("Helper_Active scim_socket_open_connection () is failed!!!\n");
724 ISF_SAVE_LOG ("Helper_Active scim_socket_open_connection failed, %d\n", timeout);
729 /* Retry after re-connecting the socket */
730 if (m_impl->socket_active.is_connected ())
731 m_impl->socket_active.close ();
733 /* This time, just retry atmost 2 seconds */
735 while (!m_impl->socket_active.connect (address) && ++i < 10) {
736 scim_usleep (200000);
740 m_impl->magic_active = magic;
742 m_impl->send.clear ();
743 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
744 m_impl->send.put_data (magic);
745 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_REGISTER_ACTIVE_HELPER);
746 m_impl->send.put_data (info.uuid);
747 m_impl->send.put_data (info.name);
748 m_impl->send.put_data (info.icon);
749 m_impl->send.put_data (info.description);
750 m_impl->send.put_data (info.option);
752 if (!m_impl->send.write_to_socket (m_impl->socket_active, magic)) {
753 ISF_SAVE_LOG ("Helper_Active write_to_socket() failed\n");
754 m_impl->socket_active.close ();
757 m_impl->m_config = ConfigBase::get (false, "socket");
759 return m_impl->socket.get_id ();
763 * @brief Close the socket connection to Panel.
766 HelperAgent::close_connection ()
768 m_impl->socket.close ();
769 m_impl->socket_active.close ();
770 m_impl->send.clear ();
771 m_impl->recv.clear ();
773 m_impl->magic_active = 0;
778 * @brief Get the connection id previously returned by open_connection().
780 * @return the connection id
783 HelperAgent::get_connection_number () const
785 if (m_impl->socket.is_connected ())
786 return m_impl->socket.get_id ();
791 * @brief Check whether this HelperAgent has been connected to a Panel.
793 * Return true when it is connected to panel, otherwise return false.
796 HelperAgent::is_connected () const
798 return m_impl->socket.is_connected ();
802 * @brief Check if there are any events available to be processed.
804 * If it returns true then Helper object should call
805 * HelperAgent::filter_event() to process them.
807 * @return true if there are any events available.
810 HelperAgent::has_pending_event () const
812 if (m_impl->socket.is_connected () && m_impl->socket.wait_for_data (0) > 0)
815 if (message_queue.has_pending_message())
822 * @brief Process the pending events.
824 * This function will emit the corresponding signals according
827 * @return false if the connection is broken, otherwise return true.
830 HelperAgent::filter_event ()
832 if (!m_impl->socket.is_connected ()) {
833 LOGW("Connection lost, returning false");
837 if (m_impl->recv.read_from_socket (m_impl->socket, m_impl->timeout)) {
838 message_queue.read_from_transaction(m_impl->recv);
840 while (message_queue.has_pending_message()) {
841 MessageItem *message = message_queue.get_pending_message();
842 handle_message(message);
843 message_queue.remove_message(message);
846 LOGD("read_from_socket() failed but continuing");
854 * @brief Read messages from socket buffer, and see if there is a message with the given cmd.
856 * @return false if the connection is broken, or no message available with given cmd. Otherwise return true.
859 HelperAgent::wait_for_message(int cmd, int timeout)
861 struct timeval t0 = { 0, 0 };
862 struct timeval t1 = { 0, 0 };
864 gettimeofday(&t0, NULL);
868 if (!m_impl->socket.is_connected() || !m_impl->recv.read_from_socket(m_impl->socket, timeout))
871 message_queue.read_from_transaction(m_impl->recv);
872 if (message_queue.has_pending_message_by_cmd(cmd)) {
876 gettimeofday(&t1, NULL);
877 etime = ((t1.tv_sec * 1000000 + t1.tv_usec) - (t0.tv_sec * 1000000 + t0.tv_usec)) / 1000;
878 } while (etime < timeout);
884 * @brief Process one message that is in our message queue.
886 * This function will emit the corresponding signals according
889 * @param message The message that needs to be handled.
891 * @return false if the connection is broken, otherwise return true.
894 HelperAgent::handle_message (MessageItem *message)
899 int cmd = message->get_command_ref();
900 LOGD ("HelperAgent::cmd = %d\n", cmd);
902 case SCIM_TRANS_CMD_EXIT:
904 MessageItemExit *subclass = static_cast<MessageItemExit*>(message);
905 ISF_SAVE_LOG ("Helper ISE received SCIM_TRANS_CMD_EXIT message\n");
906 m_impl->signal_exit(this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
909 case SCIM_TRANS_CMD_RELOAD_CONFIG:
911 MessageItemReloadConfig *subclass = static_cast<MessageItemReloadConfig*>(message);
912 m_impl->signal_reload_config (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
913 if (!m_impl->m_config.null())
914 m_impl->m_config->ConfigBase::reload();
917 case SCIM_TRANS_CMD_UPDATE_SCREEN:
919 MessageItemUpdateScreen *subclass = static_cast<MessageItemUpdateScreen*>(message);
920 m_impl->signal_update_screen (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
921 subclass->get_screen_ref());
924 case SCIM_TRANS_CMD_UPDATE_SPOT_LOCATION:
926 MessageItemUpdateSpotLocation *subclass = static_cast<MessageItemUpdateSpotLocation*>(message);
927 m_impl->signal_update_spot_location (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
928 subclass->get_x_ref(), subclass->get_y_ref());
931 case ISM_TRANS_CMD_UPDATE_CURSOR_POSITION:
933 MessageItemUpdateCursorPosition *subclass = static_cast<MessageItemUpdateCursorPosition*>(message);
934 m_impl->cursor_pos = subclass->get_cursor_pos_ref();
935 LOGD ("update cursor position %d", subclass->get_cursor_pos_ref());
936 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode) {
937 m_impl->signal_update_cursor_position (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
938 subclass->get_cursor_pos_ref());
940 if (!m_impl->si.null ()) m_impl->si->update_cursor_position(subclass->get_cursor_pos_ref());
943 case ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT:
945 MessageItemUpdateSurroundingText *subclass = static_cast<MessageItemUpdateSurroundingText*>(message);
946 if (m_impl->surrounding_text != NULL)
947 free (m_impl->surrounding_text);
948 m_impl->surrounding_text = strdup (subclass->get_text_ref().c_str ());
949 m_impl->cursor_pos = subclass->get_cursor_ref();
950 LOGD ("surrounding text: %s, %d", m_impl->surrounding_text, subclass->get_cursor_ref());
951 while (m_impl->need_update_surrounding_text > 0) {
952 m_impl->need_update_surrounding_text--;
953 m_impl->signal_update_surrounding_text (this, subclass->get_ic_ref(),
954 subclass->get_text_ref(), subclass->get_cursor_ref());
958 case ISM_TRANS_CMD_UPDATE_SELECTION:
960 MessageItemUpdateSelection *subclass = static_cast<MessageItemUpdateSelection*>(message);
961 if (m_impl->selection_text != NULL)
962 free (m_impl->selection_text);
964 m_impl->selection_text = strdup (subclass->get_text_ref().c_str ());
965 LOGD ("selection text: %s", m_impl->selection_text);
967 while (m_impl->need_update_selection_text > 0) {
968 m_impl->need_update_selection_text--;
969 m_impl->signal_update_selection (this, subclass->get_ic_ref(), subclass->get_text_ref());
973 case SCIM_TRANS_CMD_TRIGGER_PROPERTY:
975 MessageItemTriggerProperty *subclass = static_cast<MessageItemTriggerProperty*>(message);
976 m_impl->signal_trigger_property (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
977 subclass->get_property_ref());
978 if (!m_impl->si.null ()) m_impl->si->trigger_property(subclass->get_property_ref());
981 case SCIM_TRANS_CMD_HELPER_PROCESS_IMENGINE_EVENT:
983 MessageItemHelperProcessImengineEvent *subclass = static_cast<MessageItemHelperProcessImengineEvent*>(message);
984 m_impl->signal_process_imengine_event (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
985 subclass->get_transaction_ref());
988 case SCIM_TRANS_CMD_HELPER_ATTACH_INPUT_CONTEXT:
990 MessageItemHelperAttachInputContext *subclass = static_cast<MessageItemHelperAttachInputContext*>(message);
991 m_impl->signal_attach_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
994 case SCIM_TRANS_CMD_HELPER_DETACH_INPUT_CONTEXT:
996 MessageItemHelperDetachInputContext *subclass = static_cast<MessageItemHelperDetachInputContext*>(message);
997 m_impl->signal_detach_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1000 case SCIM_TRANS_CMD_FOCUS_OUT:
1002 MessageItemFocusOut *subclass = static_cast<MessageItemFocusOut*>(message);
1003 m_impl->signal_focus_out (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1004 m_impl->focused_ic = (uint32) -1;
1005 if (!m_impl->si.null ()) m_impl->si->focus_out();
1007 m_impl->ise_show_flag = false;
1010 case SCIM_TRANS_CMD_FOCUS_IN:
1012 MessageItemFocusIn *subclass = static_cast<MessageItemFocusIn*>(message);
1013 m_impl->signal_focus_in (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1014 m_impl->focused_ic = subclass->get_ic_ref();
1015 if (!m_impl->si.null ()) m_impl->si->focus_in();
1018 case ISM_TRANS_CMD_SHOW_ISE_PANEL:
1020 MessageItemShowISEPanel *subclass = static_cast<MessageItemShowISEPanel*>(message);
1021 LOGD ("Helper ISE received ISM_TRANS_CMD_SHOW_ISE_PANEL message\n");
1023 m_impl->signal_ise_show (this, subclass->get_ic_ref(), *(subclass->get_data_ptr()),
1024 subclass->get_len_ref());
1025 m_impl->ise_show_flag = true;
1028 case ISM_TRANS_CMD_HIDE_ISE_PANEL:
1030 MessageItemHideISEPanel *subclass = static_cast<MessageItemHideISEPanel*>(message);
1031 LOGD ("Helper ISE received ISM_TRANS_CMD_HIDE_ISE_PANEL message\n");
1032 m_impl->signal_ise_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1033 m_impl->ise_show_flag = false;
1036 case ISM_TRANS_CMD_GET_ACTIVE_ISE_GEOMETRY:
1038 struct rectinfo info = {0, 0, 0, 0};
1039 m_impl->signal_get_geometry (this, info);
1040 m_impl->send.clear ();
1041 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1042 m_impl->send.put_data (info.pos_x);
1043 m_impl->send.put_data (info.pos_y);
1044 m_impl->send.put_data (info.width);
1045 m_impl->send.put_data (info.height);
1046 m_impl->send.write_to_socket (m_impl->socket);
1049 case ISM_TRANS_CMD_SET_ISE_MODE:
1051 MessageItemSetISEMode *subclass = static_cast<MessageItemSetISEMode*>(message);
1052 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode) {
1053 m_impl->signal_set_mode (this, subclass->get_mode_ref());
1057 case ISM_TRANS_CMD_SET_ISE_LANGUAGE:
1059 MessageItemSetISELanguage *subclass = static_cast<MessageItemSetISELanguage*>(message);
1060 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode) {
1061 m_impl->signal_set_language (this, subclass->get_language_ref());
1065 case ISM_TRANS_CMD_SET_ISE_IMDATA:
1067 MessageItemSetISEImData *subclass = static_cast<MessageItemSetISEImData*>(message);
1068 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode) {
1069 m_impl->signal_set_imdata (this, *(subclass->get_imdata_ptr()), subclass->get_len_ref());
1071 if (!m_impl->si.null ()) m_impl->si->set_imdata(*(subclass->get_imdata_ptr()),
1072 subclass->get_len_ref());
1075 case ISM_TRANS_CMD_GET_ISE_IMDATA:
1080 m_impl->signal_get_imdata (this, &buf, len);
1081 LOGD ("send ise imdata len = %d", len);
1082 m_impl->send.clear ();
1083 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1084 m_impl->send.put_data (buf, len);
1085 m_impl->send.write_to_socket (m_impl->socket);
1090 case ISM_TRANS_CMD_GET_ISE_LANGUAGE_LOCALE:
1092 MessageItemGetISELanguageLocale *subclass = static_cast<MessageItemGetISELanguageLocale*>(message);
1094 m_impl->signal_get_language_locale (this, subclass->get_ic_ref(), &buf);
1095 m_impl->send.clear ();
1096 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1098 m_impl->send.put_data (buf, strlen (buf));
1099 m_impl->send.write_to_socket (m_impl->socket);
1104 case ISM_TRANS_CMD_SET_RETURN_KEY_TYPE:
1106 MessageItemSetReturnKeyType *subclass = static_cast<MessageItemSetReturnKeyType*>(message);
1107 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode) {
1108 m_impl->signal_set_return_key_type (this, subclass->get_type_ref());
1112 case ISM_TRANS_CMD_GET_RETURN_KEY_TYPE:
1115 m_impl->signal_get_return_key_type (this, type);
1116 m_impl->send.clear ();
1117 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1118 m_impl->send.put_data (type);
1119 m_impl->send.write_to_socket (m_impl->socket);
1122 case ISM_TRANS_CMD_SET_RETURN_KEY_DISABLE:
1124 MessageItemSetReturnKeyDisable *subclass = static_cast<MessageItemSetReturnKeyDisable*>(message);
1125 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode) {
1126 m_impl->signal_set_return_key_disable (this, subclass->get_disabled_ref());
1130 case ISM_TRANS_CMD_GET_RETURN_KEY_DISABLE:
1132 uint32 disabled = 0;
1133 m_impl->signal_get_return_key_type (this, disabled);
1134 m_impl->send.clear ();
1135 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1136 m_impl->send.put_data (disabled);
1137 m_impl->send.write_to_socket (m_impl->socket);
1140 case SCIM_TRANS_CMD_PROCESS_KEY_EVENT:
1142 MessageItemProcessKeyEvent *subclass = static_cast<MessageItemProcessKeyEvent*>(message);
1144 m_impl->signal_process_key_event(this, subclass->get_key_ref(), ret);
1146 if (!m_impl->si.null ()) {
1147 if (!(subclass->get_key_ref().get_key_string().compare("KeyRelease+XF86Back") == 0 ||
1148 subclass->get_key_ref().get_key_string().compare("XF86Back") == 0)) {
1149 ret = m_impl->si->process_key_event (subclass->get_key_ref());
1150 LOGD("imengine(%s) process key %d return %d", m_impl->si->get_factory_uuid().c_str(),
1151 subclass->get_key_ref().code, ret);
1155 m_impl->process_key_event_done (subclass->get_key_ref(), ret, subclass->get_serial_ref());
1158 case ISM_TRANS_CMD_SET_LAYOUT:
1160 MessageItemSetLayout *subclass = static_cast<MessageItemSetLayout*>(message);
1161 m_impl->layout = subclass->get_layout_ref();
1162 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode) {
1163 m_impl->signal_set_layout (this, subclass->get_layout_ref());
1165 if (!m_impl->si.null ()) m_impl->si->set_layout(subclass->get_layout_ref());
1168 case ISM_TRANS_CMD_GET_LAYOUT:
1172 m_impl->signal_get_layout (this, layout);
1173 m_impl->send.clear ();
1174 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1175 m_impl->send.put_data (layout);
1176 m_impl->send.write_to_socket (m_impl->socket);
1179 case ISM_TRANS_CMD_SET_INPUT_MODE:
1181 MessageItemSetInputMode *subclass = static_cast<MessageItemSetInputMode*>(message);
1182 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode) {
1183 m_impl->signal_set_input_mode (this, subclass->get_input_mode_ref());
1187 case ISM_TRANS_CMD_SET_CAPS_MODE:
1189 MessageItemSetCapsMode *subclass = static_cast<MessageItemSetCapsMode*>(message);
1190 m_impl->signal_set_caps_mode (this, subclass->get_mode_ref());
1193 case SCIM_TRANS_CMD_PANEL_RESET_INPUT_CONTEXT:
1195 MessageItemPanelResetInputContext *subclass = static_cast<MessageItemPanelResetInputContext*>(message);
1196 m_impl->signal_reset_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1197 if (!m_impl->si.null ()) m_impl->si->reset();
1200 case ISM_TRANS_CMD_UPDATE_CANDIDATE_UI:
1202 MessageItemUpdateCandidateUI *subclass = static_cast<MessageItemUpdateCandidateUI*>(message);
1203 m_impl->signal_update_candidate_ui (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1204 subclass->get_style_ref(), subclass->get_mode_ref());
1207 case ISM_TRANS_CMD_UPDATE_CANDIDATE_GEOMETRY:
1209 MessageItemUpdateCandidateGeometry *subclass = static_cast<MessageItemUpdateCandidateGeometry*>(message);
1210 m_impl->signal_update_candidate_geometry (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1211 subclass->get_rectinfo_ref());
1214 case ISM_TRANS_CMD_UPDATE_KEYBOARD_ISE:
1216 MessageItemUpdateKeyboardISE *subclass = static_cast<MessageItemUpdateKeyboardISE*>(message);
1217 m_impl->signal_update_keyboard_ise (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1218 subclass->get_name_ref(), subclass->get_uuid_ref());
1221 case ISM_TRANS_CMD_UPDATE_KEYBOARD_ISE_LIST:
1223 MessageItemUpdateKeyboardISEList *subclass = static_cast<MessageItemUpdateKeyboardISEList*>(message);
1224 m_impl->signal_update_keyboard_ise_list (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1225 subclass->get_list_ref());
1228 case ISM_TRANS_CMD_CANDIDATE_MORE_WINDOW_SHOW:
1230 MessageItemCandidateMoreWindowShow *subclass = static_cast<MessageItemCandidateMoreWindowShow*>(message);
1231 m_impl->signal_candidate_more_window_show (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1232 if (!m_impl->si.null ()) m_impl->si->candidate_more_window_show();
1235 case ISM_TRANS_CMD_CANDIDATE_MORE_WINDOW_HIDE:
1237 MessageItemCandidateMoreWindowHide *subclass = static_cast<MessageItemCandidateMoreWindowHide*>(message);
1238 m_impl->signal_candidate_more_window_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1239 if (!m_impl->si.null ()) m_impl->si->candidate_more_window_hide();
1242 case ISM_TRANS_CMD_SELECT_AUX:
1244 MessageItemSelectAux *subclass = static_cast<MessageItemSelectAux*>(message);
1245 m_impl->signal_select_aux (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1246 subclass->get_item_ref());
1247 if (!m_impl->si.null ()) m_impl->si->select_aux(subclass->get_item_ref());
1250 case SCIM_TRANS_CMD_SELECT_CANDIDATE: //FIXME:remove if useless
1252 MessageItemSelectCandidate *subclass = static_cast<MessageItemSelectCandidate*>(message);
1253 m_impl->signal_select_candidate (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1254 subclass->get_item_ref());
1255 if (!m_impl->si.null ()) m_impl->si->select_candidate(subclass->get_item_ref());
1258 case SCIM_TRANS_CMD_LOOKUP_TABLE_PAGE_UP: //FIXME:remove if useless
1260 MessageItemLookupTablePageUp *subclass = static_cast<MessageItemLookupTablePageUp*>(message);
1261 m_impl->signal_candidate_table_page_up (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1262 if (!m_impl->si.null ()) m_impl->si->lookup_table_page_up();
1265 case SCIM_TRANS_CMD_LOOKUP_TABLE_PAGE_DOWN: //FIXME:remove if useless
1267 MessageItemLookupTablePageDown *subclass = static_cast<MessageItemLookupTablePageDown*>(message);
1268 m_impl->signal_candidate_table_page_down (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1269 if (!m_impl->si.null ()) m_impl->si->lookup_table_page_down();
1272 case SCIM_TRANS_CMD_UPDATE_LOOKUP_TABLE_PAGE_SIZE:
1274 MessageItemUpdateLookupTablePageSize *subclass = static_cast<MessageItemUpdateLookupTablePageSize*>(message);
1275 m_impl->signal_update_candidate_table_page_size (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1276 subclass->get_size_ref());
1277 if (!m_impl->si.null ()) m_impl->si->update_lookup_table_page_size(subclass->get_size_ref());
1280 case ISM_TRANS_CMD_CANDIDATE_SHOW: //FIXME:remove if useless
1282 MessageItemCandidateShow *subclass = static_cast<MessageItemCandidateShow*>(message);
1283 m_impl->signal_candidate_show (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1286 case ISM_TRANS_CMD_CANDIDATE_HIDE: //FIXME:remove if useless
1288 MessageItemCandidateHide *subclass = static_cast<MessageItemCandidateHide*>(message);
1289 m_impl->signal_candidate_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1292 case ISM_TRANS_CMD_UPDATE_LOOKUP_TABLE: //FIXME:remove if useless
1294 MessageItemUpdateLookupTable *subclass = static_cast<MessageItemUpdateLookupTable*>(message);
1295 m_impl->signal_update_lookup_table (this, subclass->get_candidate_table_ref());
1298 case ISM_TRANS_CMD_UPDATE_CANDIDATE_ITEM_LAYOUT:
1300 MessageItemUpdateCandidateItemLayout *subclass = static_cast<MessageItemUpdateCandidateItemLayout*>(message);
1301 m_impl->signal_update_candidate_item_layout (this, subclass->get_row_items_ref());
1302 if (!m_impl->si.null ()) m_impl->si->update_candidate_item_layout(subclass->get_row_items_ref());
1305 case ISM_TRANS_CMD_SELECT_ASSOCIATE:
1307 MessageItemSelectAssociate *subclass = static_cast<MessageItemSelectAssociate*>(message);
1308 m_impl->signal_select_associate (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1309 subclass->get_item_ref());
1312 case ISM_TRANS_CMD_ASSOCIATE_TABLE_PAGE_UP:
1314 MessageItemAssociateTablePageUp *subclass = static_cast<MessageItemAssociateTablePageUp*>(message);
1315 m_impl->signal_associate_table_page_up (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1318 case ISM_TRANS_CMD_ASSOCIATE_TABLE_PAGE_DOWN:
1320 MessageItemAssociateTablePageDown *subclass = static_cast<MessageItemAssociateTablePageDown*>(message);
1321 m_impl->signal_associate_table_page_down (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1324 case ISM_TRANS_CMD_UPDATE_ASSOCIATE_TABLE_PAGE_SIZE:
1326 MessageItemUpdateAssociateTablePageSize *subclass = static_cast<MessageItemUpdateAssociateTablePageSize*>(message);
1327 m_impl->signal_update_associate_table_page_size (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1328 subclass->get_size_ref());
1331 case ISM_TRANS_CMD_RESET_ISE_CONTEXT:
1333 MessageItemResetISEContext *subclass = static_cast<MessageItemResetISEContext*>(message);
1334 m_impl->signal_reset_ise_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1335 m_impl->signal_reset_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1336 if (!m_impl->si.null ()) m_impl->si->reset();
1339 case ISM_TRANS_CMD_TURN_ON_LOG:
1341 MessageItemTurnOnLog *subclass = static_cast<MessageItemTurnOnLog*>(message);
1342 m_impl->signal_turn_on_log (this, subclass->get_state_ref());
1345 case ISM_TRANS_CMD_UPDATE_DISPLAYED_CANDIDATE:
1347 MessageItemUpdateDisplayedCandidate *subclass = static_cast<MessageItemUpdateDisplayedCandidate*>(message);
1348 m_impl->signal_update_displayed_candidate_number (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1349 subclass->get_size_ref());
1350 if (!m_impl->si.null ()) m_impl->si->update_displayed_candidate_number(subclass->get_size_ref());
1353 case ISM_TRANS_CMD_LONGPRESS_CANDIDATE:
1355 MessageItemLongpressCandidate *subclass = static_cast<MessageItemLongpressCandidate*>(message);
1356 m_impl->signal_longpress_candidate (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1357 subclass->get_index_ref());
1358 if (!m_impl->si.null ()) m_impl->si->longpress_candidate(subclass->get_index_ref());
1361 case ISM_TRANS_CMD_SET_INPUT_HINT:
1363 MessageItemSetInputHint *subclass = static_cast<MessageItemSetInputHint*>(message);
1364 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode) {
1365 m_impl->signal_set_input_hint (this, subclass->get_input_hint_ref());
1367 if (!m_impl->si.null ()) m_impl->si->set_input_hint(subclass->get_input_hint_ref());
1370 case ISM_TRANS_CMD_UPDATE_BIDI_DIRECTION:
1372 MessageItemUpdateBidiDirection *subclass = static_cast<MessageItemUpdateBidiDirection*>(message);
1373 m_impl->signal_update_bidi_direction (this, subclass->get_bidi_direction());
1374 if (!m_impl->si.null ()) m_impl->si->update_bidi_direction(subclass->get_bidi_direction());
1377 case ISM_TRANS_CMD_SHOW_ISE_OPTION_WINDOW:
1379 MessageItemShowISEOptionWindow *subclass = static_cast<MessageItemShowISEOptionWindow*>(message);
1380 m_impl->signal_show_option_window (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1383 case ISM_TRANS_CMD_RESUME_ISE_OPTION_WINDOW:
1385 MessageItemResumeISEOptionWindow *subclass = static_cast<MessageItemResumeISEOptionWindow*>(message);
1386 m_impl->signal_resume_option_window (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1389 case ISM_TRANS_CMD_CHECK_OPTION_WINDOW:
1392 m_impl->signal_check_option_window (this, avail);
1393 m_impl->send.clear ();
1394 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1395 m_impl->send.put_data (avail);
1396 m_impl->send.write_to_socket (m_impl->socket);
1399 case ISM_TRANS_CMD_PROCESS_INPUT_DEVICE_EVENT:
1401 MessageItemProcessInputDeviceEvent *subclass = static_cast<MessageItemProcessInputDeviceEvent*>(message);
1403 unsigned int ecore_event_id = find_ecore_event_from_device_type((isf_device_type_e)(subclass->get_type_ref()));
1404 m_impl->signal_process_input_device_event(this,
1405 ecore_event_id, *(subclass->get_data_ptr()), subclass->get_len_ref(), ret);
1408 case SCIM_TRANS_CMD_SET_AUTOCAPITAL_TYPE:
1410 MessageItemSetAutocapitalType *subclass = static_cast<MessageItemSetAutocapitalType*>(message);
1411 if (!m_impl->si.null ()) m_impl->si->set_autocapital_type(subclass->get_auto_capital_type_ref());
1414 case ISM_TRANS_CMD_SET_PREDICTION_ALLOW:
1416 MessageItemSetPredictionAllow *subclass = static_cast<MessageItemSetPredictionAllow*>(message);
1417 if (!m_impl->si.null ()) m_impl->si->set_prediction_allow(subclass->get_prediction_allow_ref() == 0 ? false : true);
1420 case ISM_TRANS_CMD_SET_KEYBOARD_MODE:
1422 MessageItemSetKeyboardMode *subclass = static_cast<MessageItemSetKeyboardMode*>(message);
1423 if (subclass->get_mode_ref())
1424 m_impl->hw_keyboard_mode = false;
1426 m_impl->hw_keyboard_mode = true;
1429 case ISM_TRANS_CMD_SET_PREDICTION_HINT:
1431 MessageItemSetPredictionHint *subclass = static_cast<MessageItemSetPredictionHint*>(message);
1432 m_impl->signal_set_prediction_hint (this, subclass->get_message_ref());
1435 case ISM_TRANS_CMD_SET_MIME_TYPE:
1437 MessageItemSetMimeType *subclass = static_cast<MessageItemSetMimeType*>(message);
1438 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode) {
1439 m_impl->signal_set_mime_type (this, subclass->get_mime_type_ref());
1450 * @brief Request SCIM to reload all configuration.
1452 * This function should only by used by Setup Helper to request
1453 * scim's reloading the configuration.
1454 * Deprecated: reload config message only send by socketconfig client
1455 * using socketconfig::reload instead.
1458 HelperAgent::reload_config () const
1460 LOGD ("send reload config message to isf");
1461 if (!m_impl->m_config.null())
1462 m_impl->m_config->reload();
1466 * @brief Register some properties into Panel.
1468 * This function send the request to Panel to register a list
1471 * @param properties The list of Properties to be registered into Panel.
1473 * @sa scim::Property.
1476 HelperAgent::register_properties (const PropertyList &properties) const
1478 if (m_impl->socket_active.is_connected ()) {
1479 m_impl->send.clear ();
1480 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1481 m_impl->send.put_data (m_impl->magic_active);
1482 m_impl->send.put_command (SCIM_TRANS_CMD_REGISTER_PROPERTIES);
1483 m_impl->send.put_data (properties);
1484 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1489 * @brief Update a registered property.
1491 * @param property The property to be updated.
1494 HelperAgent::update_property (const Property &property) const
1496 if (m_impl->socket_active.is_connected ()) {
1497 m_impl->send.clear ();
1498 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1499 m_impl->send.put_data (m_impl->magic_active);
1500 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PROPERTY);
1501 m_impl->send.put_data (property);
1502 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1507 * @brief Send a set of events to an IMEngineInstance.
1509 * All events should be put into a Transaction.
1510 * And the events can only be received by one IMEngineInstance object.
1512 * @param ic The handle of the Input Context to receive the events.
1513 * @param ic_uuid The UUID of the Input Context.
1514 * @param trans The Transaction object holds the events.
1517 HelperAgent::send_imengine_event (int ic,
1518 const String &ic_uuid,
1519 const Transaction &trans) const
1521 //remove if not necessary
1523 if (m_impl->socket_active.is_connected ()) {
1524 m_impl->send.clear ();
1525 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1526 m_impl->send.put_data (m_impl->magic_active);
1527 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_SEND_IMENGINE_EVENT);
1528 m_impl->send.put_data ((uint32)ic);
1529 m_impl->send.put_data (ic_uuid);
1530 m_impl->send.put_data (trans);
1531 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1534 if (!m_impl->si.null ()) m_impl->si->process_helper_event (ic_uuid, trans);
1538 * @brief Send a KeyEvent to an IMEngineInstance.
1540 * @param ic The handle of the IMEngineInstance to receive the event.
1541 * -1 means the currently focused IMEngineInstance.
1542 * @param ic_uuid The UUID of the IMEngineInstance. Empty means don't match.
1543 * @param key The KeyEvent to be sent.
1546 HelperAgent::send_key_event (int ic,
1547 const String &ic_uuid,
1548 const KeyEvent &key) const
1551 //FIXME: remove shift_mode_off, shift_mode_on, shift_mode_lock from ISE side
1552 if (key.code == SHIFT_MODE_OFF ||
1553 key.code == SHIFT_MODE_ON ||
1554 key.code == SHIFT_MODE_LOCK ||
1555 key.code == SHIFT_MODE_ENABLE ||
1556 key.code == SHIFT_MODE_DISABLE) {
1557 LOGW("FIXME ignore shift codes");
1561 if (m_impl->socket_active.is_connected ()) {
1562 m_impl->send.clear ();
1563 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1564 m_impl->send.put_data (m_impl->magic_active);
1565 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_SEND_KEY_EVENT);
1567 m_impl->send.put_data (m_impl->focused_ic);
1569 m_impl->send.put_data ((uint32)ic);
1571 m_impl->send.put_data (ic_uuid);
1572 m_impl->send.put_data (key);
1573 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1578 * @brief Forward a KeyEvent to client application directly.
1580 * @param ic The handle of the client Input Context to receive the event.
1581 * -1 means the currently focused Input Context.
1582 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1583 * Empty means don't match.
1584 * @param key The KeyEvent to be forwarded.
1587 HelperAgent::forward_key_event (int ic,
1588 const String &ic_uuid,
1589 const KeyEvent &key) const
1591 if (m_impl->socket_active.is_connected ()) {
1592 m_impl->send.clear ();
1593 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1594 m_impl->send.put_data (m_impl->magic_active);
1595 m_impl->send.put_command (SCIM_TRANS_CMD_FORWARD_KEY_EVENT);
1597 m_impl->send.put_data (m_impl->focused_ic);
1599 m_impl->send.put_data ((uint32)ic);
1601 m_impl->send.put_data (ic_uuid);
1602 m_impl->send.put_data (key);
1603 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1608 * @brief Commit a WideString to client application directly.
1610 * @param ic The handle of the client Input Context to receive the WideString.
1611 * -1 means the currently focused Input Context.
1612 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1613 * Empty means don't match.
1614 * @param wstr The WideString to be committed.
1617 HelperAgent::commit_string (int ic,
1618 const String &ic_uuid,
1619 const WideString &wstr) const
1621 if (m_impl->socket_active.is_connected ()) {
1622 m_impl->send.clear ();
1623 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1624 m_impl->send.put_data (m_impl->magic_active);
1625 m_impl->send.put_command (SCIM_TRANS_CMD_COMMIT_STRING);
1627 m_impl->send.put_data (m_impl->focused_ic);
1629 m_impl->send.put_data ((uint32)ic);
1631 m_impl->send.put_data (ic_uuid);
1632 m_impl->send.put_data (wstr);
1633 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1638 HelperAgent::commit_string (int ic,
1639 const String &ic_uuid,
1643 if (m_impl->socket_active.is_connected ()) {
1644 m_impl->send.clear ();
1645 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1646 m_impl->send.put_data (m_impl->magic_active);
1647 m_impl->send.put_command (SCIM_TRANS_CMD_COMMIT_STRING);
1649 m_impl->send.put_data (m_impl->focused_ic);
1651 m_impl->send.put_data ((uint32)ic);
1653 m_impl->send.put_data (ic_uuid);
1654 m_impl->send.put_dataw (buf, buflen);
1655 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1660 * @brief Request to show preedit string.
1662 * @param ic The handle of the client Input Context to receive the request.
1663 * -1 means the currently focused Input Context.
1664 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1665 * Empty means don't match.
1668 HelperAgent::show_preedit_string (int ic,
1669 const String &ic_uuid) const
1672 if (m_impl->socket_active.is_connected ()) {
1673 m_impl->send.clear ();
1674 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1675 m_impl->send.put_data (m_impl->magic_active);
1676 m_impl->send.put_command (SCIM_TRANS_CMD_SHOW_PREEDIT_STRING);
1677 m_impl->send.put_data ((uint32)ic);
1678 m_impl->send.put_data (ic_uuid);
1679 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1684 * @brief Request to show aux string.
1687 HelperAgent::show_aux_string (void) const
1690 if (m_impl->socket_active.is_connected ()) {
1691 m_impl->send.clear ();
1692 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1693 m_impl->send.put_data (m_impl->magic_active);
1694 m_impl->send.put_command (SCIM_TRANS_CMD_SHOW_AUX_STRING);
1695 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1700 * @brief Request to show candidate string.
1703 HelperAgent::show_candidate_string (void) const
1706 if (m_impl->socket_active.is_connected ()) {
1707 m_impl->send.clear ();
1708 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1709 m_impl->send.put_data (m_impl->magic_active);
1710 m_impl->send.put_command (SCIM_TRANS_CMD_SHOW_LOOKUP_TABLE);
1711 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1716 * @brief Request to show associate string.
1719 HelperAgent::show_associate_string (void) const
1721 if (m_impl->socket_active.is_connected ()) {
1722 m_impl->send.clear ();
1723 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1724 m_impl->send.put_data (m_impl->magic_active);
1725 m_impl->send.put_command (ISM_TRANS_CMD_SHOW_ASSOCIATE_TABLE);
1726 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1731 * @brief Request to hide preedit string.
1733 * @param ic The handle of the client Input Context to receive the request.
1734 * -1 means the currently focused Input Context.
1735 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1736 * Empty means don't match.
1739 HelperAgent::hide_preedit_string (int ic,
1740 const String &ic_uuid) const
1743 if (m_impl->socket_active.is_connected ()) {
1744 m_impl->send.clear ();
1745 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1746 m_impl->send.put_data (m_impl->magic_active);
1747 m_impl->send.put_command (SCIM_TRANS_CMD_HIDE_PREEDIT_STRING);
1748 m_impl->send.put_data ((uint32)ic);
1749 m_impl->send.put_data (ic_uuid);
1750 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1755 * @brief Request to hide aux string.
1758 HelperAgent::hide_aux_string (void) const
1760 if (m_impl->socket_active.is_connected ()) {
1761 m_impl->send.clear ();
1762 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1763 m_impl->send.put_data (m_impl->magic_active);
1764 m_impl->send.put_command (SCIM_TRANS_CMD_HIDE_AUX_STRING);
1765 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1770 * @brief Request to hide candidate string.
1773 HelperAgent::hide_candidate_string (void) const
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_LOOKUP_TABLE);
1780 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1785 * @brief Request to hide associate string.
1788 HelperAgent::hide_associate_string (void) const
1790 if (m_impl->socket_active.is_connected ()) {
1791 m_impl->send.clear ();
1792 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1793 m_impl->send.put_data (m_impl->magic_active);
1794 m_impl->send.put_command (ISM_TRANS_CMD_HIDE_ASSOCIATE_TABLE);
1795 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1800 * @brief Update a new WideString for preedit.
1802 * @param ic The handle of the client Input Context to receive the WideString.
1803 * -1 means the currently focused Input Context.
1804 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1805 * Empty means don't match.
1806 * @param str The WideString to be updated.
1807 * @param attrs The attribute list for preedit string.
1810 HelperAgent::update_preedit_string (int ic,
1811 const String &ic_uuid,
1812 const WideString &str,
1813 const AttributeList &attrs) const
1815 update_preedit_string (ic, ic_uuid, str, str, attrs, -1);
1819 HelperAgent::update_preedit_string (int ic,
1820 const String &ic_uuid,
1823 const AttributeList &attrs) const
1825 update_preedit_string (ic, ic_uuid, buf, buflen, attrs, -1);
1829 * @brief Update a new WideString for preedit.
1831 * @param ic The handle of the client Input Context to receive the WideString.
1832 * -1 means the currently focused Input Context.
1833 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1834 * Empty means don't match.
1835 * @param str The WideString to be updated.
1836 * @param attrs The attribute list for preedit string.
1837 * @param caret The caret position in preedit string.
1840 HelperAgent::update_preedit_string (int ic,
1841 const String &ic_uuid,
1842 const WideString &wstr,
1843 const AttributeList &attrs,
1846 update_preedit_string (ic, ic_uuid, wstr, wstr, attrs, caret);
1850 HelperAgent::update_preedit_string (int ic,
1851 const String &ic_uuid,
1854 const AttributeList &attrs,
1858 if (m_impl->socket_active.is_connected ()) {
1859 m_impl->send.clear ();
1860 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1861 m_impl->send.put_data (m_impl->magic_active);
1862 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING);
1863 m_impl->send.put_data ((uint32)ic);
1864 m_impl->send.put_data (ic_uuid);
1865 m_impl->send.put_dataw (buf, buflen);
1866 m_impl->send.put_dataw (buf, buflen);
1867 m_impl->send.put_data (attrs);
1868 m_impl->send.put_data (caret);
1869 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1874 HelperAgent::update_preedit_string (int ic,
1875 const String &ic_uuid,
1876 const WideString &preedit,
1877 const WideString &commit,
1878 const AttributeList &attrs,
1881 if (m_impl->socket_active.is_connected ()) {
1882 m_impl->send.clear ();
1883 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1884 m_impl->send.put_data (m_impl->magic_active);
1885 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING);
1886 m_impl->send.put_data ((uint32)ic);
1887 m_impl->send.put_data (ic_uuid);
1888 m_impl->send.put_data (preedit);
1889 m_impl->send.put_data (commit);
1890 m_impl->send.put_data (attrs);
1891 m_impl->send.put_data (caret);
1892 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1897 * @brief Update the preedit caret position in the preedit string.
1899 * @param caret - the new position of the preedit caret.
1902 HelperAgent::update_preedit_caret (int caret) const
1905 if (m_impl->socket_active.is_connected ()) {
1906 m_impl->send.clear ();
1907 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1908 m_impl->send.put_data (m_impl->magic_active);
1909 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_CARET);
1910 m_impl->send.put_data ((uint32)caret);
1911 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1916 * @brief Update a new string for aux.
1918 * @param str The string to be updated.
1919 * @param attrs The attribute list for aux string.
1922 HelperAgent::update_aux_string (const String &str,
1923 const AttributeList &attrs) const
1925 if (m_impl->socket_active.is_connected ()) {
1926 m_impl->send.clear ();
1927 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1928 m_impl->send.put_data (m_impl->magic_active);
1929 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_AUX_STRING);
1930 m_impl->send.put_data (str);
1931 m_impl->send.put_data (attrs);
1932 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1937 * @brief Request to update candidate.
1939 * @param table The lookup table for candidate.
1942 HelperAgent::update_candidate_string (const LookupTable &table) const
1944 if (m_impl->socket_active.is_connected ()) {
1945 m_impl->send.clear ();
1946 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1947 m_impl->send.put_data (m_impl->magic_active);
1948 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_LOOKUP_TABLE);
1949 m_impl->send.put_data (table);
1950 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1955 * @brief Request to update associate.
1957 * @param table The lookup table for associate.
1960 HelperAgent::update_associate_string (const LookupTable &table) const
1962 if (m_impl->socket_active.is_connected ()) {
1963 m_impl->send.clear ();
1964 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1965 m_impl->send.put_data (m_impl->magic_active);
1966 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ASSOCIATE_TABLE);
1967 m_impl->send.put_data (table);
1968 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1973 * @brief When the input context of ISE is changed,
1974 * ISE can call this function to notify application
1976 * @param type type of event.
1977 * @param value value of event.
1980 HelperAgent::update_input_context (uint32 type, uint32 value) const
1982 if (m_impl->socket_active.is_connected ()) {
1983 m_impl->send.clear ();
1984 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1985 m_impl->send.put_data (m_impl->magic_active);
1986 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ISE_INPUT_CONTEXT);
1987 m_impl->send.put_data (type);
1988 m_impl->send.put_data (value);
1989 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1994 * @brief Request to get surrounding text asynchronously.
1996 * @param uuid The helper ISE UUID.
1997 * @param maxlen_before The max length of before.
1998 * @param maxlen_after The max length of after.
2001 HelperAgent::get_surrounding_text (const String &uuid, int maxlen_before, int maxlen_after) const
2003 if (m_impl->socket_active.is_connected () && (m_impl->need_update_surrounding_text == 0)) {
2004 m_impl->send.clear ();
2005 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2006 m_impl->send.put_data (m_impl->magic_active);
2007 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SURROUNDING_TEXT);
2008 m_impl->send.put_data (uuid);
2009 m_impl->send.put_data (maxlen_before);
2010 m_impl->send.put_data (maxlen_after);
2011 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2013 m_impl->need_update_surrounding_text++;
2017 * @brief Request to get surrounding text synchronously.
2019 * @param uuid The helper ISE UUID.
2020 * @param maxlen_before The max length of before.
2021 * @param maxlen_after The max length of after.
2022 * @param text The surrounding text.
2023 * @param cursor The cursor position.
2026 HelperAgent::get_surrounding_text (int maxlen_before, int maxlen_after, String &text, int &cursor)
2028 if (!m_impl->socket_active.is_connected ())
2031 m_impl->send.clear ();
2032 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2033 m_impl->send.put_data (m_impl->magic_active);
2034 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SURROUNDING_TEXT);
2035 m_impl->send.put_data ("");
2036 m_impl->send.put_data (maxlen_before);
2037 m_impl->send.put_data (maxlen_after);
2038 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2039 if (m_impl->surrounding_text) {
2040 free (m_impl->surrounding_text);
2041 m_impl->surrounding_text = NULL;
2044 const int WAIT_FOR_SYNC_RESPONSE_TIMEOUT = 1000;
2045 /* Now we are waiting for the ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT message */
2046 if (wait_for_message(ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT, WAIT_FOR_SYNC_RESPONSE_TIMEOUT)) {
2047 MessageItem *message = message_queue.get_pending_message_by_cmd(ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT);
2048 handle_message(message);
2049 message_queue.remove_message(message);
2051 if (m_impl->surrounding_text) {
2052 text = m_impl->surrounding_text;
2053 cursor = m_impl->cursor_pos;
2057 if (m_impl->surrounding_text) {
2058 free (m_impl->surrounding_text);
2059 m_impl->surrounding_text = NULL;
2064 * @brief Request to delete surrounding text.
2066 * @param offset The offset for cursor position.
2067 * @param len The length for delete text.
2070 HelperAgent::delete_surrounding_text (int offset, int len) const
2072 LOGD ("offset = %d, len = %d", offset, len);
2074 if (m_impl->socket_active.is_connected ()) {
2075 m_impl->send.clear ();
2076 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2077 m_impl->send.put_data (m_impl->magic_active);
2078 m_impl->send.put_command (SCIM_TRANS_CMD_DELETE_SURROUNDING_TEXT);
2079 m_impl->send.put_data (offset);
2080 m_impl->send.put_data (len);
2081 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2086 * @brief Request to get selection text asynchronously.
2088 * @param uuid The helper ISE UUID.
2091 HelperAgent::get_selection (const String &uuid) const
2093 if (m_impl->socket_active.is_connected () && (m_impl->need_update_selection_text == 0)) {
2094 m_impl->send.clear ();
2095 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2096 m_impl->send.put_data (m_impl->magic_active);
2097 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SELECTION);
2098 m_impl->send.put_data (uuid);
2099 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2101 m_impl->need_update_selection_text++;
2105 * @brief Request to get selection text synchronously.
2107 * @param text The selection text.
2110 HelperAgent::get_selection_text (String &text)
2113 if (!m_impl->socket_active.is_connected ())
2116 m_impl->send.clear ();
2117 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2118 m_impl->send.put_data (m_impl->magic_active);
2119 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SELECTION);
2120 m_impl->send.put_data ("");
2121 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2122 if (m_impl->selection_text) {
2123 free (m_impl->selection_text);
2124 m_impl->selection_text = NULL;
2127 const int WAIT_FOR_SYNC_RESPONSE_TIMEOUT = 1000;
2128 /* Now we are waiting for the ISM_TRANS_CMD_UPDATE_SELECTION message */
2129 if (wait_for_message(ISM_TRANS_CMD_UPDATE_SELECTION, WAIT_FOR_SYNC_RESPONSE_TIMEOUT)) {
2130 MessageItem *message = message_queue.get_pending_message_by_cmd(ISM_TRANS_CMD_UPDATE_SELECTION);
2131 handle_message(message);
2132 message_queue.remove_message(message);
2133 if (m_impl->selection_text) {
2134 text = m_impl->selection_text;
2138 if (m_impl->selection_text) {
2139 free (m_impl->selection_text);
2140 m_impl->selection_text = NULL;
2145 * @brief Request to select text.
2147 * @param start The start position in text.
2148 * @param end The end position in text.
2151 HelperAgent::set_selection (int start, int end) const
2153 if (m_impl->socket_active.is_connected ()) {
2154 m_impl->send.clear ();
2155 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2156 m_impl->send.put_data (m_impl->magic_active);
2157 m_impl->send.put_command (SCIM_TRANS_CMD_SET_SELECTION);
2158 m_impl->send.put_data (start);
2159 m_impl->send.put_data (end);
2160 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2165 * @brief Send a private command to an application.
2167 * @param command The private command sent from IME.
2170 HelperAgent::send_private_command (const String &command) const
2172 if (m_impl->socket_active.is_connected ()) {
2173 m_impl->send.clear ();
2174 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2175 m_impl->send.put_data (m_impl->magic_active);
2176 m_impl->send.put_command (SCIM_TRANS_CMD_SEND_PRIVATE_COMMAND);
2177 m_impl->send.put_data (command);
2178 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2183 * @brief Commit content to an application.
2185 * @param content The content sent from IME.
2188 HelperAgent::commit_content (const String &content, const String &description, const String &mime_types) const
2191 if (m_impl->socket_active.is_connected ()) {
2192 m_impl->send.clear ();
2193 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2194 m_impl->send.put_data (m_impl->magic_active);
2195 m_impl->send.put_command (SCIM_TRANS_CMD_COMMIT_CONTENT);
2196 m_impl->send.put_data (content);
2197 m_impl->send.put_data (description);
2198 m_impl->send.put_data (mime_types);
2199 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2204 * @brief Request to get uuid list of all keyboard ISEs.
2206 * @param uuid The helper ISE UUID.
2209 HelperAgent::get_keyboard_ise_list (const String &uuid) const
2211 if (m_impl->socket_active.is_connected ()) {
2212 m_impl->send.clear ();
2213 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2214 m_impl->send.put_data (m_impl->magic_active);
2215 m_impl->send.put_command (ISM_TRANS_CMD_GET_KEYBOARD_ISE_LIST);
2216 m_impl->send.put_data (uuid);
2217 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2222 * @brief Set candidate position in screen.
2224 * @param left The x position in screen.
2225 * @param top The y position in screen.
2228 HelperAgent::set_candidate_position (int left, int top) const
2230 if (m_impl->socket_active.is_connected ()) {
2231 m_impl->send.clear ();
2232 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2233 m_impl->send.put_data (m_impl->magic_active);
2234 m_impl->send.put_command (ISM_TRANS_CMD_SET_CANDIDATE_POSITION);
2235 m_impl->send.put_data (left);
2236 m_impl->send.put_data (top);
2237 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2242 * @brief Set candidate style.
2244 * @param portrait_line - the displayed line number for portrait mode.
2245 * @param mode - candidate window mode.
2248 HelperAgent::set_candidate_style (ISF_CANDIDATE_PORTRAIT_LINE_T portrait_line,
2249 ISF_CANDIDATE_MODE_T mode) const
2251 if (m_impl->socket_active.is_connected ()) {
2252 m_impl->send.clear ();
2253 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2254 m_impl->send.put_data (m_impl->magic_active);
2255 m_impl->send.put_command (ISM_TRANS_CMD_SET_CANDIDATE_UI);
2256 m_impl->send.put_data (portrait_line);
2257 m_impl->send.put_data (mode);
2258 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2263 * @brief Request to hide candidate window.
2266 HelperAgent::candidate_hide (void) const
2268 if (m_impl->socket_active.is_connected ()) {
2269 m_impl->send.clear ();
2270 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2271 m_impl->send.put_data (m_impl->magic_active);
2272 m_impl->send.put_command (ISM_TRANS_CMD_HIDE_CANDIDATE);
2273 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2278 * @brief Request to get candidate window size and position.
2280 * @param uuid The helper ISE UUID.
2283 HelperAgent::get_candidate_window_geometry (const String &uuid) const
2285 if (m_impl->socket_active.is_connected ()) {
2286 m_impl->send.clear ();
2287 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2288 m_impl->send.put_data (m_impl->magic_active);
2289 m_impl->send.put_command (ISM_TRANS_CMD_GET_CANDIDATE_GEOMETRY);
2290 m_impl->send.put_data (uuid);
2291 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2296 * @brief Set current keyboard ISE.
2298 * @param uuid The keyboard ISE UUID.
2301 HelperAgent::set_keyboard_ise_by_uuid (const String &uuid) const
2304 IMEngineFactoryPointer factory;
2305 IMEngineModule *engine_module = NULL;
2306 static int instance_count = 1;
2308 if ((!m_impl->si.null ()) && m_impl->si->get_factory_uuid () == uuid) {
2309 ISF_SAVE_LOG ("Already in UUID: %s\n", uuid.c_str());
2313 if (!m_impl->si.null()) {
2314 m_impl->si->focus_out();
2318 if (m_impl->m_config.null ()) {
2319 ISF_SAVE_LOG ("config is not working");
2323 #ifdef HAVE_PKGMGR_INFO
2326 pkgmgrinfo_appinfo_h handle;
2327 ret = pkgmgrinfo_appinfo_get_appinfo(uuid.c_str(), &handle);
2328 if (ret != PMINFO_R_OK) {
2329 ISF_SAVE_LOG ("Retrieve app info failed : %s", uuid.c_str ());
2333 ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
2334 if (ret != PMINFO_R_OK) {
2335 ISF_SAVE_LOG ("Retrieve pkgid failed : %s, %p", uuid.c_str(), handle);
2336 pkgmgrinfo_appinfo_destroy_appinfo(handle);
2340 imeInfo.module_name = pkgid;
2341 pkgmgrinfo_appinfo_destroy_appinfo(handle);
2343 if (isf_db_select_ime_info_by_appid(uuid.c_str(), &imeInfo) < 1) {
2344 ISF_SAVE_LOG ("ime_info row is not available for %s", uuid.c_str());
2349 engine_module = &m_impl->engine_module;
2351 if (engine_module->valid() && imeInfo.module_name != engine_module->get_module_name()) {
2352 ISF_SAVE_LOG ("imengine module %s unloaded", engine_module->get_module_name().c_str());
2353 engine_module->unload();
2356 if (!engine_module->valid()) {
2357 if (engine_module->load (imeInfo.module_name, m_impl->m_config) == false) {
2358 ISF_SAVE_LOG ("load module %s failed", imeInfo.module_name.c_str());
2361 ISF_SAVE_LOG ("imengine module %s loaded", imeInfo.module_name.c_str());
2364 for (size_t j = 0; j < engine_module->number_of_factories (); ++j) {
2366 factory = engine_module->create_factory (j);
2367 if (factory.null () == false && factory->get_uuid () == uuid)
2375 if (factory.null()) {
2376 ISF_SAVE_LOG ("imengine uuid %s is not found", uuid.c_str());
2380 m_impl->si = factory->create_instance ("UTF-8", instance_count++);
2381 if (m_impl->si.null ()) {
2382 ISF_SAVE_LOG ("create_instance %s failed", uuid.c_str ());
2386 m_impl->attach_instance ();
2387 ISF_SAVE_LOG ("Require UUID: %s Current UUID: %s", uuid.c_str (), m_impl->si->get_factory_uuid ().c_str ());
2388 m_impl->si->set_layout (m_impl->layout);
2389 if (m_impl->focused_ic != (uint32)-1)
2390 m_impl->si->focus_in ();
2394 * @brief Request to get current keyboard ISE information.
2396 * @param uuid The helper ISE UUID.
2399 HelperAgent::get_keyboard_ise (const String &uuid) const
2401 //FIXME: maybe useless
2403 if (m_impl->socket_active.is_connected ()) {
2404 m_impl->send.clear ();
2405 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2406 m_impl->send.put_data (m_impl->magic_active);
2407 m_impl->send.put_command (ISM_TRANS_CMD_GET_KEYBOARD_ISE);
2408 m_impl->send.put_data (uuid);
2409 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2415 * @brief Update ISE window geometry.
2417 * @param x The x position in screen.
2418 * @param y The y position in screen.
2419 * @param width The ISE window width.
2420 * @param height The ISE window height.
2423 HelperAgent::update_geometry (int x, int y, int width, int height) const
2425 if (m_impl->socket_active.is_connected ()) {
2426 m_impl->send.clear ();
2427 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2428 m_impl->send.put_data (m_impl->magic_active);
2429 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ISE_GEOMETRY);
2430 m_impl->send.put_data (x);
2431 m_impl->send.put_data (y);
2432 m_impl->send.put_data (width);
2433 m_impl->send.put_data (height);
2434 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2439 * @brief Request to expand candidate window.
2442 HelperAgent::expand_candidate (void) const
2444 if (m_impl->socket_active.is_connected ()) {
2445 m_impl->send.clear ();
2446 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2447 m_impl->send.put_data (m_impl->magic_active);
2448 m_impl->send.put_command (ISM_TRANS_CMD_EXPAND_CANDIDATE);
2449 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2454 * @brief Request to contract candidate window.
2457 HelperAgent::contract_candidate (void) const
2459 if (m_impl->socket_active.is_connected ()) {
2460 m_impl->send.clear ();
2461 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2462 m_impl->send.put_data (m_impl->magic_active);
2463 m_impl->send.put_command (ISM_TRANS_CMD_CONTRACT_CANDIDATE);
2464 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2469 * @brief Send selected candidate string index number.
2472 HelperAgent::select_candidate (int index) const
2474 if (!m_impl->si.null ())
2475 m_impl->si->select_candidate (index);
2476 //FIXME: maybe useless
2479 if (m_impl->socket_active.is_connected ()) {
2480 m_impl->send.clear ();
2481 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2482 m_impl->send.put_data (m_impl->magic_active);
2483 m_impl->send.put_command (ISM_TRANS_CMD_SELECT_CANDIDATE);
2484 m_impl->send.put_data (index);
2485 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2491 * @brief Update our ISE is exiting.
2494 HelperAgent::update_ise_exit (void) const
2496 //FIXME: maybe useless
2498 if (m_impl->socket_active.is_connected ()) {
2499 m_impl->send.clear ();
2500 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2501 m_impl->send.put_data (m_impl->magic_active);
2502 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ISE_EXIT);
2503 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2509 * @brief Request to reset keyboard ISE.
2512 HelperAgent::reset_keyboard_ise (void) const
2514 //FIXME: maybe useless
2516 if (m_impl->socket_active.is_connected ()) {
2517 m_impl->send.clear ();
2518 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2519 m_impl->send.put_data (m_impl->magic_active);
2520 m_impl->send.put_command (ISM_TRANS_CMD_PANEL_RESET_KEYBOARD_ISE);
2521 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2524 if (!m_impl->si.null ()) {
2525 m_impl->si->reset ();
2530 * @brief Request to flush keyboard ISE.
2533 HelperAgent::flush_keyboard_ise (void) const
2535 if (!m_impl->si.null ()) {
2536 m_impl->si->flush ();
2541 * @brief Request panel to hide ISE.
2544 HelperAgent::request_ise_hide (void) const
2546 if (m_impl->socket_active.is_connected ()) {
2547 m_impl->send.clear ();
2548 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2549 m_impl->send.put_data (m_impl->magic_active);
2550 m_impl->send.put_command (ISM_TRANS_CMD_REQUEST_ISE_HIDE);
2551 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2559 HelperAgent::recapture_string (int ic,
2560 const String &ic_uuid,
2563 const WideString &preedit_str,
2564 const WideString &commit_str,
2565 const AttributeList &attrs) const
2567 LOGD ("offset = %d, len = %d", offset, len);
2569 if (m_impl->socket_active.is_connected ()) {
2570 m_impl->send.clear ();
2571 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2572 m_impl->send.put_data (m_impl->magic_active);
2573 m_impl->send.put_command (ISM_TRANS_CMD_RECAPTURE_STRING);
2575 m_impl->send.put_data ((uint32)ic);
2576 m_impl->send.put_data (ic_uuid);
2578 // Deleting surrounding text
2579 m_impl->send.put_data (offset);
2580 m_impl->send.put_data (len);
2582 // Update preedit text
2583 m_impl->send.put_data (preedit_str);
2586 m_impl->send.put_data (commit_str);
2588 // preedit attributes
2589 m_impl->send.put_data (attrs);
2591 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2596 * @brief Connect a slot to Helper exit signal.
2598 * This signal is used to let the Helper exit.
2600 * The prototype of the slot is:
2602 * void exit (const HelperAgent *agent, int ic, const String &ic_uuid);
2605 * - agent The pointer to the HelperAgent object which emits this signal.
2606 * - ic An opaque handle of the currently focused input context.
2607 * - ic_uuid The UUID of the IMEngineInstance associated with the focused input context.
2610 HelperAgent::signal_connect_exit (HelperAgentSlotVoid *slot)
2612 return m_impl->signal_exit.connect (slot);
2616 * @brief Connect a slot to Helper attach input context signal.
2618 * This signal is used to attach an input context to this helper.
2620 * When an input context requst to start this helper, then this
2621 * signal will be emitted as soon as the helper is started.
2623 * When an input context want to start an already started helper,
2624 * this signal will also be emitted.
2626 * Helper can send some events back to the IMEngineInstance in this
2627 * signal-slot, to inform that it has been started sccessfully.
2629 * The prototype of the slot is:
2631 * void attach_input_context (const HelperAgent *agent, int ic, const String &ic_uuid);
2634 HelperAgent::signal_connect_attach_input_context (HelperAgentSlotVoid *slot)
2636 return m_impl->signal_attach_input_context.connect (slot);
2640 * @brief Connect a slot to Helper detach input context signal.
2642 * This signal is used to detach an input context from this helper.
2644 * When an input context requst to stop this helper, then this
2645 * signal will be emitted.
2647 * Helper shouldn't send any event back to the IMEngineInstance, because
2648 * the IMEngineInstance attached to the ic should have been destroyed.
2650 * The prototype of the slot is:
2652 * void detach_input_context (const HelperAgent *agent, int ic, const String &ic_uuid);
2655 HelperAgent::signal_connect_detach_input_context (HelperAgentSlotVoid *slot)
2657 return m_impl->signal_detach_input_context.connect (slot);
2661 * @brief Connect a slot to Helper reload config signal.
2663 * This signal is used to let the Helper reload configuration.
2665 * The prototype of the slot is:
2667 * void reload_config (const HelperAgent *agent, int ic, const String &ic_uuid);
2670 HelperAgent::signal_connect_reload_config (HelperAgentSlotVoid *slot)
2672 return m_impl->signal_reload_config.connect (slot);
2676 * @brief Connect a slot to Helper update screen signal.
2678 * This signal is used to let the Helper move its GUI to another screen.
2679 * It can only be emitted when SCIM_HELPER_NEED_SCREEN_INFO is set in HelperInfo.option.
2681 * The prototype of the slot is:
2683 * void update_screen (const HelperAgent *agent, int ic, const String &ic_uuid, int screen_number);
2686 HelperAgent::signal_connect_update_screen (HelperAgentSlotInt *slot)
2688 return m_impl->signal_update_screen.connect (slot);
2692 * @brief Connect a slot to Helper update spot location signal.
2694 * This signal is used to let the Helper move its GUI according to the current spot location.
2695 * It can only be emitted when SCIM_HELPER_NEED_SPOT_LOCATION_INFO is set in HelperInfo.option.
2697 * The prototype of the slot is:
2698 * void update_spot_location (const HelperAgent *agent, int ic, const String &ic_uuid, int x, int y);
2701 HelperAgent::signal_connect_update_spot_location (HelperAgentSlotIntInt *slot)
2703 return m_impl->signal_update_spot_location.connect (slot);
2707 * @brief Connect a slot to Helper update cursor position signal.
2709 * This signal is used to let the Helper get the cursor position information.
2711 * The prototype of the slot is:
2712 * void update_cursor_position (const HelperAgent *agent, int ic, const String &ic_uuid, int cursor_pos);
2715 HelperAgent::signal_connect_update_cursor_position (HelperAgentSlotInt *slot)
2717 return m_impl->signal_update_cursor_position.connect (slot);
2721 * @brief Connect a slot to Helper update surrounding text signal.
2723 * This signal is used to let the Helper get the surrounding text.
2725 * The prototype of the slot is:
2726 * void update_surrounding_text (const HelperAgent *agent, int ic, const String &text, int cursor);
2729 HelperAgent::signal_connect_update_surrounding_text (HelperAgentSlotInt *slot)
2731 return m_impl->signal_update_surrounding_text.connect (slot);
2735 * @brief Connect a slot to Helper update selection signal.
2737 * This signal is used to let the Helper get the selection.
2739 * The prototype of the slot is:
2740 * void update_selection (const HelperAgent *agent, int ic, const String &text);
2743 HelperAgent::signal_connect_update_selection (HelperAgentSlotVoid *slot)
2745 return m_impl->signal_update_selection.connect (slot);
2749 * @brief Connect a slot to Helper trigger property signal.
2751 * This signal is used to trigger a property registered by this Helper.
2752 * A property will be triggered when user clicks on it.
2754 * The prototype of the slot is:
2755 * void trigger_property (const HelperAgent *agent, int ic, const String &ic_uuid, const String &property);
2758 HelperAgent::signal_connect_trigger_property (HelperAgentSlotString *slot)
2760 return m_impl->signal_trigger_property.connect (slot);
2764 * @brief Connect a slot to Helper process imengine event signal.
2766 * This signal is used to deliver the events sent from IMEngine to Helper.
2768 * The prototype of the slot is:
2769 * void process_imengine_event (const HelperAgent *agent, int ic, const String &ic_uuid, const Transaction &transaction);
2772 HelperAgent::signal_connect_process_imengine_event (HelperAgentSlotTransaction *slot)
2774 return m_impl->signal_process_imengine_event.connect (slot);
2778 * @brief Connect a slot to Helper focus out signal.
2780 * This signal is used to do something when input context is focus out.
2782 * The prototype of the slot is:
2783 * void focus_out (const HelperAgent *agent, int ic, const String &ic_uuid);
2786 HelperAgent::signal_connect_focus_out (HelperAgentSlotVoid *slot)
2788 return m_impl->signal_focus_out.connect (slot);
2792 * @brief Connect a slot to Helper focus in signal.
2794 * This signal is used to do something when input context is focus in.
2796 * The prototype of the slot is:
2797 * void focus_in (const HelperAgent *agent, int ic, const String &ic_uuid);
2800 HelperAgent::signal_connect_focus_in (HelperAgentSlotVoid *slot)
2802 return m_impl->signal_focus_in.connect (slot);
2806 * @brief Connect a slot to Helper show signal.
2808 * This signal is used to show Helper ISE window.
2810 * The prototype of the slot is:
2811 * void ise_show (const HelperAgent *agent, int ic, char *buf, size_t &len);
2814 HelperAgent::signal_connect_ise_show (HelperAgentSlotIntRawVoid *slot)
2816 return m_impl->signal_ise_show.connect (slot);
2820 * @brief Connect a slot to Helper hide signal.
2822 * This signal is used to hide Helper ISE window.
2824 * The prototype of the slot is:
2825 * void ise_hide (const HelperAgent *agent, int ic, const String &ic_uuid);
2828 HelperAgent::signal_connect_ise_hide (HelperAgentSlotVoid *slot)
2830 return m_impl->signal_ise_hide.connect (slot);
2834 * @brief Connect a slot to Helper get ISE window geometry signal.
2836 * This signal is used to get Helper ISE window size and position.
2838 * The prototype of the slot is:
2839 * void get_geometry (const HelperAgent *agent, struct rectinfo &info);
2842 HelperAgent::signal_connect_get_geometry (HelperAgentSlotSize *slot)
2844 return m_impl->signal_get_geometry.connect (slot);
2848 * @brief Connect a slot to Helper set mode signal.
2850 * This signal is used to set Helper ISE mode.
2852 * The prototype of the slot is:
2853 * void set_mode (const HelperAgent *agent, uint32 &mode);
2856 HelperAgent::signal_connect_set_mode (HelperAgentSlotUintVoid *slot)
2858 return m_impl->signal_set_mode.connect (slot);
2862 * @brief Connect a slot to Helper set language signal.
2864 * This signal is used to set Helper ISE language.
2866 * The prototype of the slot is:
2867 * void set_language (const HelperAgent *agent, uint32 &language);
2870 HelperAgent::signal_connect_set_language (HelperAgentSlotUintVoid *slot)
2872 return m_impl->signal_set_language.connect (slot);
2876 * @brief Connect a slot to Helper set im data signal.
2878 * This signal is used to send im data to Helper ISE.
2880 * The prototype of the slot is:
2881 * void set_imdata (const HelperAgent *agent, char *buf, size_t &len);
2884 HelperAgent::signal_connect_set_imdata (HelperAgentSlotRawVoid *slot)
2886 return m_impl->signal_set_imdata.connect (slot);
2890 * @brief Connect a slot to Helper get im data signal.
2892 * This signal is used to get im data from Helper ISE.
2894 * The prototype of the slot is:
2895 * void get_imdata (const HelperAgent *, char **buf, size_t &len);
2898 HelperAgent::signal_connect_get_imdata (HelperAgentSlotGetRawVoid *slot)
2900 return m_impl->signal_get_imdata.connect (slot);
2904 * @brief Connect a slot to Helper get language locale signal.
2906 * This signal is used to get language locale from Helper ISE.
2908 * The prototype of the slot is:
2909 * void get_language_locale (const HelperAgent *, int ic, char **locale);
2912 HelperAgent::signal_connect_get_language_locale (HelperAgentSlotIntGetStringVoid *slot)
2914 return m_impl->signal_get_language_locale.connect (slot);
2918 * @brief Connect a slot to Helper set return key type signal.
2920 * This signal is used to send return key type to Helper ISE.
2922 * The prototype of the slot is:
2923 * void set_return_key_type (const HelperAgent *agent, uint32 &type);
2926 HelperAgent::signal_connect_set_return_key_type (HelperAgentSlotUintVoid *slot)
2928 return m_impl->signal_set_return_key_type.connect (slot);
2932 * @brief Connect a slot to Helper get return key type signal.
2934 * This signal is used to get return key type from Helper ISE.
2936 * The prototype of the slot is:
2937 * void get_return_key_type (const HelperAgent *agent, uint32 &type);
2940 HelperAgent::signal_connect_get_return_key_type (HelperAgentSlotUintVoid *slot)
2942 return m_impl->signal_get_return_key_type.connect (slot);
2946 * @brief Connect a slot to Helper set return key disable signal.
2948 * This signal is used to send return key disable to Helper ISE.
2950 * The prototype of the slot is:
2951 * void set_return_key_disable (const HelperAgent *agent, uint32 &disabled);
2954 HelperAgent::signal_connect_set_return_key_disable (HelperAgentSlotUintVoid *slot)
2956 return m_impl->signal_set_return_key_disable.connect (slot);
2960 * @brief Connect a slot to Helper process key event signal.
2962 * This signal is used to send keyboard key event to Helper ISE.
2964 * The prototype of the slot is:
2965 * void process_key_event (const HelperAgent *agent, KeyEvent &key, uint32 &ret);
2968 HelperAgent::signal_connect_process_key_event (HelperAgentSlotKeyEventUint *slot)
2970 return m_impl->signal_process_key_event.connect (slot);
2974 * @brief Connect a slot to Helper get return key disable signal.
2976 * This signal is used to get return key disable from Helper ISE.
2978 * The prototype of the slot is:
2979 * void get_return_key_disable (const HelperAgent *agent, uint32 &disabled);
2982 HelperAgent::signal_connect_get_return_key_disable (HelperAgentSlotUintVoid *slot)
2984 return m_impl->signal_get_return_key_disable.connect (slot);
2988 * @brief Connect a slot to Helper set layout signal.
2990 * This signal is used to set Helper ISE layout.
2992 * The prototype of the slot is:
2993 * void set_layout (const HelperAgent *agent, uint32 &layout);
2996 HelperAgent::signal_connect_set_layout (HelperAgentSlotUintVoid *slot)
2998 return m_impl->signal_set_layout.connect (slot);
3002 * @brief Connect a slot to Helper get layout signal.
3004 * This signal is used to get Helper ISE layout.
3006 * The prototype of the slot is:
3007 * void get_layout (const HelperAgent *agent, uint32 &layout);
3010 HelperAgent::signal_connect_get_layout (HelperAgentSlotUintVoid *slot)
3012 return m_impl->signal_get_layout.connect (slot);
3016 * @brief Connect a slot to Helper set input mode signal.
3018 * This signal is used to set Helper ISE input mode.
3020 * The prototype of the slot is:
3021 * void set_input_mode (const HelperAgent *agent, uint32 &input_mode);
3024 HelperAgent::signal_connect_set_input_mode (HelperAgentSlotUintVoid *slot)
3026 return m_impl->signal_set_input_mode.connect (slot);
3030 * @brief Connect a slot to Helper set input hint signal.
3032 * This signal is used to set Helper ISE input hint.
3034 * The prototype of the slot is:
3035 * void set_input_hint (const HelperAgent *agent, uint32 &input_hint);
3038 HelperAgent::signal_connect_set_input_hint (HelperAgentSlotUintVoid *slot)
3040 return m_impl->signal_set_input_hint.connect (slot);
3044 * @brief Connect a slot to Helper set BiDi direction signal.
3046 * This signal is used to set Helper ISE BiDi direction.
3048 * The prototype of the slot is:
3049 * void update_bidi_direction (const HelperAgent *agent, uint32 &bidi_direction);
3052 HelperAgent::signal_connect_update_bidi_direction (HelperAgentSlotUintVoid *slot)
3054 return m_impl->signal_update_bidi_direction.connect (slot);
3058 * @brief Connect a slot to Helper set shift mode signal.
3060 * This signal is used to set Helper shift mode.
3062 * The prototype of the slot is:
3063 * void set_caps_mode (const HelperAgent *agent, uint32 &mode);
3066 HelperAgent::signal_connect_set_caps_mode (HelperAgentSlotUintVoid *slot)
3068 return m_impl->signal_set_caps_mode.connect (slot);
3072 * @brief Connect a slot to Helper reset input context signal.
3074 * This signal is used to reset Helper ISE input context.
3076 * The prototype of the slot is:
3077 * void reset_input_context (const HelperAgent *agent, int ic, const String &uuid);
3080 HelperAgent::signal_connect_reset_input_context (HelperAgentSlotVoid *slot)
3082 return m_impl->signal_reset_input_context.connect (slot);
3086 * @brief Connect a slot to Helper update candidate window geometry signal.
3088 * This signal is used to get candidate window size and position.
3090 * The prototype of the slot is:
3091 * void update_candidate_geometry (const HelperAgent *agent, int ic, const String &uuid, const rectinfo &info);
3094 HelperAgent::signal_connect_update_candidate_geometry (HelperAgentSlotRect *slot)
3096 return m_impl->signal_update_candidate_geometry.connect (slot);
3100 * @brief Connect a slot to Helper update keyboard ISE signal.
3102 * This signal is used to get current keyboard ISE name and uuid.
3104 * The prototype of the slot is:
3105 * void update_keyboard_ise (const HelperAgent *agent, int ic, const String &uuid,
3106 * const String &ise_name, const String &ise_uuid);
3109 HelperAgent::signal_connect_update_keyboard_ise (HelperAgentSlotString2 *slot)
3111 return m_impl->signal_update_keyboard_ise.connect (slot);
3115 * @brief Connect a slot to Helper update keyboard ISE list signal.
3117 * This signal is used to get uuid list of all keyboard ISEs.
3119 * The prototype of the slot is:
3120 * void update_keyboard_ise_list (const HelperAgent *agent, int ic, const String &uuid,
3121 * const std::vector<String> &ise_list);
3124 HelperAgent::signal_connect_update_keyboard_ise_list (HelperAgentSlotStringVector *slot)
3126 return m_impl->signal_update_keyboard_ise_list.connect (slot);
3130 * @brief Connect a slot to Helper candidate more window show signal.
3132 * This signal is used to do someting when candidate more window is showed.
3134 * The prototype of the slot is:
3135 * void candidate_more_window_show (const HelperAgent *agent, int ic, const String &uuid);
3138 HelperAgent::signal_connect_candidate_more_window_show (HelperAgentSlotVoid *slot)
3140 return m_impl->signal_candidate_more_window_show.connect (slot);
3144 * @brief Connect a slot to Helper candidate more window hide signal.
3146 * This signal is used to do someting when candidate more window is hidden.
3148 * The prototype of the slot is:
3149 * void candidate_more_window_hide (const HelperAgent *agent, int ic, const String &uuid);
3152 HelperAgent::signal_connect_candidate_more_window_hide (HelperAgentSlotVoid *slot)
3154 return m_impl->signal_candidate_more_window_hide.connect (slot);
3158 * @brief Connect a slot to Helper candidate show signal.
3160 * This signal is used to do candidate show.
3162 * The prototype of the slot is:
3163 * void candidate_show (const HelperAgent *agent, int ic, const String &uuid);
3166 HelperAgent::signal_connect_candidate_show (HelperAgentSlotVoid *slot)
3168 return m_impl->signal_candidate_show.connect (slot);
3172 * @brief Connect a slot to Helper candidate hide signal.
3174 * This signal is used to do candidate hide.
3176 * The prototype of the slot is:
3177 * void candidate_hide (const HelperAgent *agent, int ic, const String &uuid);
3180 HelperAgent::signal_connect_candidate_hide (HelperAgentSlotVoid *slot)
3182 return m_impl->signal_candidate_hide.connect (slot);
3186 * @brief Connect a slot to Helper update lookup table signal.
3188 * This signal is used to do someting when update lookup table.
3190 * The prototype of the slot is:
3191 * void update_lookup_table (const HelperAgent *agent, int ic, const String &uuid ,LookupTable &table);
3194 HelperAgent::signal_connect_update_lookup_table (HelperAgentSlotLookupTable *slot)
3196 return m_impl->signal_update_lookup_table.connect (slot);
3200 * @brief Connect a slot to Helper select aux signal.
3202 * This signal is used to do something when aux is selected.
3204 * The prototype of the slot is:
3205 * void select_aux (const HelperAgent *agent, int ic, const String &uuid, int index);
3208 HelperAgent::signal_connect_select_aux (HelperAgentSlotInt *slot)
3210 return m_impl->signal_select_aux.connect (slot);
3214 * @brief Connect a slot to Helper select candidate signal.
3216 * This signal is used to do something when candidate is selected.
3218 * The prototype of the slot is:
3219 * void select_candidate (const HelperAgent *agent, int ic, const String &uuid, int index);
3222 HelperAgent::signal_connect_select_candidate (HelperAgentSlotInt *slot)
3224 return m_impl->signal_select_candidate.connect (slot);
3228 * @brief Connect a slot to Helper candidate table page up signal.
3230 * This signal is used to do something when candidate table is paged up.
3232 * The prototype of the slot is:
3233 * void candidate_table_page_up (const HelperAgent *agent, int ic, const String &uuid);
3236 HelperAgent::signal_connect_candidate_table_page_up (HelperAgentSlotVoid *slot)
3238 return m_impl->signal_candidate_table_page_up.connect (slot);
3242 * @brief Connect a slot to Helper candidate table page down signal.
3244 * This signal is used to do something when candidate table is paged down.
3246 * The prototype of the slot is:
3247 * void candidate_table_page_down (const HelperAgent *agent, int ic, const String &uuid);
3250 HelperAgent::signal_connect_candidate_table_page_down (HelperAgentSlotVoid *slot)
3252 return m_impl->signal_candidate_table_page_down.connect (slot);
3256 * @brief Connect a slot to Helper update candidate table page size signal.
3258 * This signal is used to do something when candidate table page size is changed.
3260 * The prototype of the slot is:
3261 * void update_candidate_table_page_size (const HelperAgent *, int ic, const String &uuid, int page_size);
3264 HelperAgent::signal_connect_update_candidate_table_page_size (HelperAgentSlotInt *slot)
3266 return m_impl->signal_update_candidate_table_page_size.connect (slot);
3270 * @brief Connect a slot to Helper update candidate item layout signal.
3272 * The prototype of the slot is:
3273 * void update_candidate_item_layout (const HelperAgent *, const std::vector<uint32> &row_items);
3276 HelperAgent::signal_connect_update_candidate_item_layout (HelperAgentSlotUintVector *slot)
3278 return m_impl->signal_update_candidate_item_layout.connect (slot);
3282 * @brief Connect a slot to Helper select associate signal.
3284 * This signal is used to do something when associate is selected.
3286 * The prototype of the slot is:
3287 * void select_associate (const HelperAgent *agent, int ic, const String &uuid, int index);
3290 HelperAgent::signal_connect_select_associate (HelperAgentSlotInt *slot)
3292 return m_impl->signal_select_associate.connect (slot);
3296 * @brief Connect a slot to Helper associate table page up signal.
3298 * This signal is used to do something when associate table is paged up.
3300 * The prototype of the slot is:
3301 * void associate_table_page_up (const HelperAgent *agent, int ic, const String &uuid);
3304 HelperAgent::signal_connect_associate_table_page_up (HelperAgentSlotVoid *slot)
3306 return m_impl->signal_associate_table_page_up.connect (slot);
3310 * @brief Connect a slot to Helper associate table page down signal.
3312 * This signal is used to do something when associate table is paged down.
3314 * The prototype of the slot is:
3315 * void associate_table_page_down (const HelperAgent *agent, int ic, const String &uuid);
3318 HelperAgent::signal_connect_associate_table_page_down (HelperAgentSlotVoid *slot)
3320 return m_impl->signal_associate_table_page_down.connect (slot);
3324 * @brief Connect a slot to Helper update associate table page size signal.
3326 * This signal is used to do something when associate table page size is changed.
3328 * The prototype of the slot is:
3329 * void update_associate_table_page_size (const HelperAgent *, int ic, const String &uuid, int page_size);
3332 HelperAgent::signal_connect_update_associate_table_page_size (HelperAgentSlotInt *slot)
3334 return m_impl->signal_update_associate_table_page_size.connect (slot);
3338 * @brief Connect a slot to Helper turn on log signal.
3340 * This signal is used to turn on Helper ISE debug information.
3342 * The prototype of the slot is:
3343 * void turn_on_log (const HelperAgent *agent, uint32 &on);
3346 HelperAgent::signal_connect_turn_on_log (HelperAgentSlotUintVoid *slot)
3348 return m_impl->signal_turn_on_log.connect (slot);
3352 * @brief Connect a slot to Helper update displayed candidate number signal.
3354 * This signal is used to inform helper ISE displayed candidate number.
3356 * The prototype of the slot is:
3357 * void update_displayed_candidate_number (const HelperAgent *, int ic, const String &uuid, int number);
3360 HelperAgent::signal_connect_update_displayed_candidate_number (HelperAgentSlotInt *slot)
3362 return m_impl->signal_update_displayed_candidate_number.connect (slot);
3366 * @brief Connect a slot to Helper longpress candidate signal.
3368 * This signal is used to do something when candidate is longpress.
3370 * The prototype of the slot is:
3371 * void longpress_candidate (const HelperAgent *agent, int ic, const String &uuid, int index);
3374 HelperAgent::signal_connect_longpress_candidate (HelperAgentSlotInt *slot)
3376 return m_impl->signal_longpress_candidate.connect (slot);
3380 * @brief Connect a slot to Helper show option window.
3382 * This signal is used to do request the ISE to show option window.
3384 * The prototype of the slot is:
3385 * void show_option_window (const HelperAgent *agent, int ic, const String &uuid);
3388 HelperAgent::signal_connect_show_option_window (HelperAgentSlotVoid *slot)
3390 return m_impl->signal_show_option_window.connect (slot);
3394 * @brief Connect a slot to Helper resume option window.
3396 * This signal is used to do request the ISE to resume option window.
3398 * The prototype of the slot is:
3399 * void resume_option_window (const HelperAgent *agent, int ic, const String &uuid);
3402 HelperAgent::signal_connect_resume_option_window (HelperAgentSlotVoid *slot)
3404 return m_impl->signal_resume_option_window.connect (slot);
3408 * @brief Connect a slot to Helper check if the option is available.
3410 * This signal is used to check if the option (setting) is available from Helper ISE.
3412 * The prototype of the slot is:
3413 * void check_option_window (const HelperAgent *agent, uint32 &avail);
3416 HelperAgent::signal_connect_check_option_window (HelperAgentSlotUintVoid *slot)
3418 return m_impl->signal_check_option_window.connect (slot);
3422 * @brief Connect a slot to Helper process unconventional input device event signal.
3424 * This signal is used to send unconventional input device event to Helper ISE.
3426 * The prototype of the slot is:
3427 * void process_input_device_event (const HelperAgent *, uint32 &type, char *data, size_t &size, uint32 &ret);
3430 HelperAgent::signal_connect_process_input_device_event (HelperAgentSlotUintCharSizeUint *slot)
3432 return m_impl->signal_process_input_device_event.connect (slot);
3436 * @brief Connect a slot to Helper set prediction hint signal.
3438 * This signal is used to send prediction hint to Helper ISE.
3440 * The prototype of the slot is:
3441 * void set_prediction_hint (const HelperAgent *agent, char *prediction_hint);
3444 HelperAgent::signal_connect_set_prediction_hint (HelperAgentSlotStringVoid *slot)
3446 return m_impl->signal_set_prediction_hint.connect (slot);
3450 * @brief Connect a slot to Helper set mime type signal.
3452 * This signal is used to send mime type to Helper ISE.
3454 * The prototype of the slot is:
3455 * void set_mime_type (const HelperAgent *agent, char *mime_type);
3458 HelperAgent::signal_connect_set_mime_type (HelperAgentSlotStringVoid *slot)
3460 return m_impl->signal_set_mime_type.connect (slot);
3463 } /* namespace scim */
3466 vi:ts=4:nowrap:ai:expandtab