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 char* finalized_text;
168 uint32 finalized_cursor_pos;
170 HelperAgentSignalVoid signal_exit;
171 HelperAgentSignalVoid signal_attach_input_context;
172 HelperAgentSignalVoid signal_detach_input_context;
173 HelperAgentSignalVoid signal_reload_config;
174 HelperAgentSignalInt signal_update_screen;
175 HelperAgentSignalIntInt signal_update_spot_location;
176 HelperAgentSignalInt signal_update_cursor_position;
177 HelperAgentSignalInt signal_update_surrounding_text;
178 HelperAgentSignalVoid signal_update_selection;
179 HelperAgentSignalString signal_trigger_property;
180 HelperAgentSignalTransaction signal_process_imengine_event;
181 HelperAgentSignalVoid signal_focus_out;
182 HelperAgentSignalVoid signal_focus_in;
183 HelperAgentSignalIntRawVoid signal_ise_show;
184 HelperAgentSignalVoid signal_ise_hide;
185 HelperAgentSignalVoid signal_candidate_show;
186 HelperAgentSignalVoid signal_candidate_hide;
187 HelperAgentSignalSize signal_get_geometry;
188 HelperAgentSignalUintVoid signal_set_mode;
189 HelperAgentSignalUintVoid signal_set_language;
190 HelperAgentSignalRawVoid signal_set_imdata;
191 HelperAgentSignalGetRawVoid signal_get_imdata;
192 HelperAgentSignalIntGetStringVoid signal_get_language_locale;
193 HelperAgentSignalUintVoid signal_set_return_key_type;
194 HelperAgentSignalUintVoid signal_get_return_key_type;
195 HelperAgentSignalUintVoid signal_set_return_key_disable;
196 HelperAgentSignalUintVoid signal_get_return_key_disable;
197 HelperAgentSignalUintVoid signal_set_layout;
198 HelperAgentSignalUintVoid signal_get_layout;
199 HelperAgentSignalUintVoid signal_set_caps_mode;
200 HelperAgentSignalVoid signal_reset_input_context;
201 HelperAgentSignalIntInt signal_update_candidate_ui;
202 HelperAgentSignalRect signal_update_candidate_geometry;
203 HelperAgentSignalString2 signal_update_keyboard_ise;
204 HelperAgentSignalStringVector signal_update_keyboard_ise_list;
205 HelperAgentSignalVoid signal_candidate_more_window_show;
206 HelperAgentSignalVoid signal_candidate_more_window_hide;
207 HelperAgentSignalLookupTable signal_update_lookup_table;
208 HelperAgentSignalInt signal_select_aux;
209 HelperAgentSignalInt signal_select_candidate;
210 HelperAgentSignalVoid signal_candidate_table_page_up;
211 HelperAgentSignalVoid signal_candidate_table_page_down;
212 HelperAgentSignalInt signal_update_candidate_table_page_size;
213 HelperAgentSignalUintVector signal_update_candidate_item_layout;
214 HelperAgentSignalInt signal_select_associate;
215 HelperAgentSignalVoid signal_associate_table_page_up;
216 HelperAgentSignalVoid signal_associate_table_page_down;
217 HelperAgentSignalInt signal_update_associate_table_page_size;
218 HelperAgentSignalVoid signal_reset_ise_context;
219 HelperAgentSignalUintVoid signal_turn_on_log;
220 HelperAgentSignalInt signal_update_displayed_candidate_number;
221 HelperAgentSignalInt signal_longpress_candidate;
222 HelperAgentSignalKeyEventUint signal_process_key_event;
223 HelperAgentSignalUintVoid signal_set_input_mode;
224 HelperAgentSignalUintVoid signal_set_input_hint;
225 HelperAgentSignalUintVoid signal_update_bidi_direction;
226 HelperAgentSignalVoid signal_show_option_window;
227 HelperAgentSignalVoid signal_resume_option_window;
228 HelperAgentSignalUintVoid signal_check_option_window;
229 HelperAgentSignalUintCharSizeUint signal_process_input_device_event;
230 HelperAgentSignalStringVoid signal_set_prediction_hint;
231 HelperAgentSignalStringVoid signal_set_mime_type;
232 HelperAgentSignalString signal_set_prediction_hint_data;
235 HelperAgentImpl (HelperAgent* thiz) : magic(0), magic_active(0), timeout(-1), focused_ic ((uint32) -1), thiz (thiz),
236 surrounding_text (NULL), selection_text (NULL), cursor_pos (0),
237 need_update_surrounding_text (0), need_update_selection_text (0),
238 layout (0), ise_show_flag (false), hw_keyboard_mode (false), ise_focus_flag (false),
239 finalized_text(NULL), finalized_cursor_pos(0) {
242 ~HelperAgentImpl () {
247 if (surrounding_text != NULL)
248 free (surrounding_text);
250 if (finalized_text != NULL)
251 free(finalized_text);
253 if (selection_text != NULL)
254 free (selection_text);
256 if (engine_module.valid ()) {
257 engine_module.unload ();
261 // Implementation of slot functions
263 slot_show_preedit_string (IMEngineInstanceBase *si)
265 thiz->show_preedit_string (focused_ic, "");
269 slot_show_aux_string (IMEngineInstanceBase *si)
271 thiz->show_aux_string ();
275 slot_show_lookup_table (IMEngineInstanceBase *si)
277 thiz->show_candidate_string ();
281 slot_hide_preedit_string (IMEngineInstanceBase *si)
283 thiz->hide_preedit_string (focused_ic, "");
287 slot_hide_aux_string (IMEngineInstanceBase *si)
289 thiz->hide_aux_string ();
293 slot_hide_lookup_table (IMEngineInstanceBase *si)
295 thiz->hide_candidate_string ();
299 slot_update_preedit_caret (IMEngineInstanceBase *si, int caret)
301 thiz->update_preedit_caret (caret);
305 slot_update_preedit_string (IMEngineInstanceBase *si,
306 const WideString & str,
307 const AttributeList & attrs,
310 thiz->update_preedit_string (-1, "", str, attrs, caret);
314 slot_update_preedit_string_with_commit (IMEngineInstanceBase *si,
315 const WideString & preedit,
316 const WideString & commit,
317 const AttributeList & attrs,
320 thiz->update_preedit_string (-1, "", preedit, commit, attrs, caret);
324 slot_update_aux_string (IMEngineInstanceBase *si,
325 const WideString & str,
326 const AttributeList & attrs)
328 thiz->update_aux_string (utf8_wcstombs(str), attrs);
332 slot_commit_string (IMEngineInstanceBase *si,
333 const WideString & str)
335 thiz->commit_string (-1, "", str);
339 slot_recapture_string (IMEngineInstanceBase *si,
342 const WideString & preedit,
343 const WideString & commit,
344 const AttributeList & attrs)
346 thiz->recapture_string (-1, "", offset, len, preedit, commit, attrs);
350 slot_forward_key_event (IMEngineInstanceBase *si,
351 const KeyEvent & key)
353 thiz->forward_key_event (-1, "", key);
357 slot_update_lookup_table (IMEngineInstanceBase *si,
358 const LookupTable & table)
360 thiz->update_candidate_string (table);
364 slot_register_properties (IMEngineInstanceBase *si,
365 const PropertyList & properties)
367 thiz->register_properties (properties);
371 slot_update_property (IMEngineInstanceBase *si,
372 const Property & property)
374 thiz->update_property (property);
378 slot_beep (IMEngineInstanceBase *si)
384 slot_start_helper (IMEngineInstanceBase *si,
385 const String &helper_uuid)
387 LOGW ("deprecated function");
391 slot_stop_helper (IMEngineInstanceBase *si,
392 const String &helper_uuid)
394 LOGW ("deprecated function");
398 slot_send_helper_event (IMEngineInstanceBase *si,
399 const String &helper_uuid,
400 const Transaction &trans)
402 signal_process_imengine_event (thiz, focused_ic, helper_uuid, trans);
406 slot_get_surrounding_text (IMEngineInstanceBase *si,
413 thiz->get_surrounding_text (maxlen_before, maxlen_after, _text, cursor);
414 text = utf8_mbstowcs(_text);
419 slot_delete_surrounding_text (IMEngineInstanceBase *si,
424 thiz->delete_surrounding_text (offset, len);
429 slot_get_selection (IMEngineInstanceBase *si,
433 thiz->get_selection_text (_text);
434 text = utf8_mbstowcs (_text);
439 slot_set_selection (IMEngineInstanceBase *si,
443 thiz->set_selection (start, end);
448 slot_expand_candidate (IMEngineInstanceBase *si)
450 thiz->expand_candidate ();
454 slot_contract_candidate (IMEngineInstanceBase *si)
456 thiz->contract_candidate ();
460 slot_set_candidate_style (IMEngineInstanceBase *si, ISF_CANDIDATE_PORTRAIT_LINE_T portrait_line, ISF_CANDIDATE_MODE_T mode)
462 thiz->set_candidate_style (portrait_line, mode);
466 slot_send_private_command (IMEngineInstanceBase *si,
467 const String &command)
469 thiz->send_private_command (command);
473 slot_commit_content (IMEngineInstanceBase *si,
474 const String &content,
475 const String &description,
476 const String &mime_types)
479 thiz->commit_content (content, description, mime_types);
485 si->signal_connect_show_preedit_string (
486 slot (this, &HelperAgent::HelperAgentImpl::slot_show_preedit_string));
487 si->signal_connect_show_aux_string (
488 slot (this, &HelperAgent::HelperAgentImpl::slot_show_aux_string));
489 si->signal_connect_show_lookup_table (
490 slot (this, &HelperAgent::HelperAgentImpl::slot_show_lookup_table));
492 si->signal_connect_hide_preedit_string (
493 slot (this, &HelperAgent::HelperAgentImpl::slot_hide_preedit_string));
494 si->signal_connect_hide_aux_string (
495 slot (this, &HelperAgent::HelperAgentImpl::slot_hide_aux_string));
496 si->signal_connect_hide_lookup_table (
497 slot (this, &HelperAgent::HelperAgentImpl::slot_hide_lookup_table));
499 si->signal_connect_update_preedit_caret (
500 slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_caret));
501 si->signal_connect_update_preedit_string (
502 slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_string));
503 si->signal_connect_update_preedit_string_with_commit (
504 slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_string_with_commit));
505 si->signal_connect_recapture_string (
506 slot (this, &HelperAgent::HelperAgentImpl::slot_recapture_string));
508 si->signal_connect_update_aux_string (
509 slot (this, &HelperAgent::HelperAgentImpl::slot_update_aux_string));
510 si->signal_connect_update_lookup_table (
511 slot (this, &HelperAgent::HelperAgentImpl::slot_update_lookup_table));
513 si->signal_connect_commit_string (
514 slot (this, &HelperAgent::HelperAgentImpl::slot_commit_string));
516 si->signal_connect_forward_key_event (
517 slot (this, &HelperAgent::HelperAgentImpl::slot_forward_key_event));
519 si->signal_connect_register_properties (
520 slot (this, &HelperAgent::HelperAgentImpl::slot_register_properties));
522 si->signal_connect_update_property (
523 slot (this, &HelperAgent::HelperAgentImpl::slot_update_property));
525 si->signal_connect_beep (
526 slot (this, &HelperAgent::HelperAgentImpl::slot_beep));
528 si->signal_connect_start_helper (
529 slot (this, &HelperAgent::HelperAgentImpl::slot_start_helper));
531 si->signal_connect_stop_helper (
532 slot (this, &HelperAgent::HelperAgentImpl::slot_stop_helper));
534 si->signal_connect_send_helper_event (
535 slot (this, &HelperAgent::HelperAgentImpl::slot_send_helper_event));
537 si->signal_connect_get_surrounding_text (
538 slot (this, &HelperAgent::HelperAgentImpl::slot_get_surrounding_text));
540 si->signal_connect_delete_surrounding_text (
541 slot (this, &HelperAgent::HelperAgentImpl::slot_delete_surrounding_text));
543 si->signal_connect_get_selection (
544 slot (this, &HelperAgent::HelperAgentImpl::slot_get_selection));
546 si->signal_connect_set_selection (
547 slot (this, &HelperAgent::HelperAgentImpl::slot_set_selection));
549 si->signal_connect_expand_candidate (
550 slot (this, &HelperAgent::HelperAgentImpl::slot_expand_candidate));
551 si->signal_connect_contract_candidate (
552 slot (this, &HelperAgent::HelperAgentImpl::slot_contract_candidate));
554 si->signal_connect_set_candidate_style (
555 slot (this, &HelperAgent::HelperAgentImpl::slot_set_candidate_style));
557 si->signal_connect_send_private_command (
558 slot (this, &HelperAgent::HelperAgentImpl::slot_send_private_command));
561 void process_key_event_done (KeyEvent &key, uint32 ret, uint32 serial) {
562 LOGD ("ret: %d, serial: %d", ret, serial);
563 if (socket_active.is_connected ()) {
565 send.put_command (SCIM_TRANS_CMD_REQUEST);
566 send.put_data (magic_active);
567 send.put_command (ISM_TRANS_CMD_PROCESS_KEY_EVENT_DONE);
570 send.put_data (serial);
571 send.write_to_socket (socket_active, magic_active);
575 void request_ise_hide () {
576 if (socket_active.is_connected ()) {
578 send.put_command (SCIM_TRANS_CMD_REQUEST);
579 send.put_data (magic_active);
580 send.put_command (ISM_TRANS_CMD_REQUEST_ISE_HIDE);
581 send.write_to_socket (socket_active, magic_active);
585 HelperAgentImpl () : magic (0), magic_active (0), timeout (-1), focused_ic ((uint32) -1) { }
588 static MessageQueue message_queue;
590 HelperAgent::HelperAgent ()
591 : m_impl (new HelperAgentImpl (this))
593 message_queue.create();
596 HelperAgent::~HelperAgent ()
598 message_queue.destroy();
603 * @brief Open socket connection to the Panel.
605 * @param info The information of this Helper object.
606 * @param display The display which this Helper object should run on.
608 * @return The connection socket id. -1 means failed to create
612 HelperAgent::open_connection (const HelperInfo &info,
613 const String &display)
615 if (m_impl->socket.is_connected ())
618 SocketAddress address (scim_get_default_panel_socket_address (display));
619 int timeout = m_impl->timeout = scim_get_default_socket_timeout ();
622 if (!address.valid ())
626 std::cerr << " Connecting to PanelAgent server.";
627 ISF_LOG (" Connecting to PanelAgent server.\n");
628 while (!m_impl->socket.connect (address)) {
630 scim_usleep (100000);
632 std::cerr << "m_impl->socket.connect () is failed!!!\n";
633 ISF_LOG ("m_impl->socket.connect () is failed!!!\n");
637 std::cerr << " Connected :" << i << "\n";
638 ISF_LOG (" Connected :%d\n", i);
639 LOGD ("Connection to PanelAgent succeeded, %d", i);
641 /* Let's retry 10 times when failed */
642 int open_connection_retries = 0;
643 while (!scim_socket_open_connection (magic,
648 if (++open_connection_retries > 10) {
649 m_impl->socket.close ();
650 std::cerr << "scim_socket_open_connection () is failed!!!\n";
651 ISF_LOG ("scim_socket_open_connection () is failed!!!\n");
652 ISF_SAVE_LOG ("scim_socket_open_connection failed, %d", timeout);
657 /* Retry after re-connecting the socket */
658 if (m_impl->socket.is_connected ())
661 /* This time, just retry atmost 2 seconds */
663 while (!m_impl->socket.connect (address) && ++i < 10) {
664 scim_usleep (200000);
668 ISF_LOG ("scim_socket_open_connection () is successful.\n");
669 LOGD ("scim_socket_open_connection successful");
671 m_impl->send.clear ();
672 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
673 m_impl->send.put_data (magic);
674 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_REGISTER_HELPER);
675 m_impl->send.put_data (info.uuid);
676 m_impl->send.put_data (info.name);
677 m_impl->send.put_data (info.icon);
678 m_impl->send.put_data (info.description);
679 m_impl->send.put_data (info.option);
681 if (!m_impl->send.write_to_socket (m_impl->socket, magic)) {
682 m_impl->socket.close ();
687 if (m_impl->recv.read_from_socket (m_impl->socket, timeout) &&
688 m_impl->recv.get_command (cmd) && cmd == SCIM_TRANS_CMD_REPLY &&
689 m_impl->recv.get_command (cmd) && cmd == SCIM_TRANS_CMD_OK) {
690 m_impl->magic = magic;
692 while (m_impl->recv.get_command (cmd)) {
694 case SCIM_TRANS_CMD_HELPER_ATTACH_INPUT_CONTEXT:
698 while (m_impl->recv.get_data (ic) && m_impl->recv.get_data (ic_uuid))
699 m_impl->signal_attach_input_context (this, ic, ic_uuid);
702 case SCIM_TRANS_CMD_UPDATE_SCREEN:
705 if (m_impl->recv.get_data (screen))
706 m_impl->signal_update_screen (this, (uint32) -1, String (""), (int) screen);
714 //FIXME: Attaching input context is needed for desktop environment
715 LOGW ("Attach input context and update screen failed");
718 ISF_SAVE_LOG ("Trying connect() with Helper_Active");
720 /* connect to the panel agent as the active helper client */
721 if (!m_impl->socket_active.connect (address)) return -1;
722 open_connection_retries = 0;
723 while (!scim_socket_open_connection (magic,
724 String ("Helper_Active"),
726 m_impl->socket_active,
728 if (++open_connection_retries > 10) {
729 m_impl->socket_active.close ();
730 std::cerr << "Helper_Active scim_socket_open_connection () is failed!!!\n";
731 ISF_LOG ("Helper_Active scim_socket_open_connection () is failed!!!\n");
732 ISF_SAVE_LOG ("Helper_Active scim_socket_open_connection failed, %d", timeout);
737 /* Retry after re-connecting the socket */
738 if (m_impl->socket_active.is_connected ())
739 m_impl->socket_active.close ();
741 /* This time, just retry atmost 2 seconds */
743 while (!m_impl->socket_active.connect (address) && ++i < 10) {
744 scim_usleep (200000);
748 m_impl->magic_active = magic;
750 m_impl->send.clear ();
751 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
752 m_impl->send.put_data (magic);
753 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_REGISTER_ACTIVE_HELPER);
754 m_impl->send.put_data (info.uuid);
755 m_impl->send.put_data (info.name);
756 m_impl->send.put_data (info.icon);
757 m_impl->send.put_data (info.description);
758 m_impl->send.put_data (info.option);
760 if (!m_impl->send.write_to_socket (m_impl->socket_active, magic)) {
761 ISF_SAVE_LOG ("Helper_Active write_to_socket() failed");
762 m_impl->socket_active.close ();
765 m_impl->m_config = ConfigBase::get (false, "socket");
767 return m_impl->socket.get_id ();
771 * @brief Close the socket connection to Panel.
774 HelperAgent::close_connection ()
776 m_impl->socket.close ();
777 m_impl->socket_active.close ();
778 m_impl->send.clear ();
779 m_impl->recv.clear ();
781 m_impl->magic_active = 0;
786 * @brief Get the connection id previously returned by open_connection().
788 * @return the connection id
791 HelperAgent::get_connection_number () const
793 if (m_impl->socket.is_connected ())
794 return m_impl->socket.get_id ();
799 * @brief Check whether this HelperAgent has been connected to a Panel.
801 * Return true when it is connected to panel, otherwise return false.
804 HelperAgent::is_connected () const
806 return m_impl->socket.is_connected ();
810 * @brief Check if there are any events available to be processed.
812 * If it returns true then Helper object should call
813 * HelperAgent::filter_event() to process them.
815 * @return true if there are any events available.
818 HelperAgent::has_pending_event () const
820 if (m_impl->socket.is_connected () && m_impl->socket.wait_for_data (0) > 0)
823 if (message_queue.has_pending_message())
830 * @brief Process the pending events.
832 * This function will emit the corresponding signals according
835 * @return false if the connection is broken, otherwise return true.
838 HelperAgent::filter_event ()
840 if (!m_impl->socket.is_connected ()) {
841 LOGW("Connection lost, returning false");
845 if (m_impl->recv.read_from_socket (m_impl->socket, m_impl->timeout)) {
846 message_queue.read_from_transaction(m_impl->recv);
848 while (message_queue.has_pending_message()) {
849 MessageItem *message = message_queue.get_pending_message();
850 handle_message(message);
851 message_queue.remove_message(message);
854 LOGD("read_from_socket() failed but continuing");
862 * @brief Read messages from socket buffer, and see if there is a message with the given cmd.
864 * @return false if the connection is broken, or no message available with given cmd. Otherwise return true.
867 HelperAgent::wait_for_message(int cmd, int timeout)
869 struct timeval t0 = { 0, 0 };
870 struct timeval t1 = { 0, 0 };
872 gettimeofday(&t0, NULL);
876 if (!m_impl->socket.is_connected() || !m_impl->recv.read_from_socket(m_impl->socket, timeout))
879 message_queue.read_from_transaction(m_impl->recv);
880 if (message_queue.has_pending_message_by_cmd(cmd)) {
884 gettimeofday(&t1, NULL);
885 etime = ((t1.tv_sec * 1000000 + t1.tv_usec) - (t0.tv_sec * 1000000 + t0.tv_usec)) / 1000;
886 } while (etime < timeout);
892 * @brief Process one message that is in our message queue.
894 * This function will emit the corresponding signals according
897 * @param message The message that needs to be handled.
899 * @return false if the connection is broken, otherwise return true.
902 HelperAgent::handle_message (MessageItem *message)
907 int cmd = message->get_command_ref();
908 LOGD ("HelperAgent::cmd = %d", cmd);
910 case SCIM_TRANS_CMD_EXIT:
912 MessageItemExit *subclass = static_cast<MessageItemExit*>(message);
913 ISF_SAVE_LOG ("Helper ISE received SCIM_TRANS_CMD_EXIT message");
914 m_impl->signal_exit(this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
917 case SCIM_TRANS_CMD_RELOAD_CONFIG:
919 MessageItemReloadConfig *subclass = static_cast<MessageItemReloadConfig*>(message);
920 m_impl->signal_reload_config (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
921 if (!m_impl->m_config.null())
922 m_impl->m_config->ConfigBase::reload();
925 case SCIM_TRANS_CMD_UPDATE_SCREEN:
927 MessageItemUpdateScreen *subclass = static_cast<MessageItemUpdateScreen*>(message);
928 m_impl->signal_update_screen (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
929 subclass->get_screen_ref());
932 case SCIM_TRANS_CMD_UPDATE_SPOT_LOCATION:
934 MessageItemUpdateSpotLocation *subclass = static_cast<MessageItemUpdateSpotLocation*>(message);
935 m_impl->signal_update_spot_location (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
936 subclass->get_x_ref(), subclass->get_y_ref());
939 case ISM_TRANS_CMD_UPDATE_CURSOR_POSITION:
941 MessageItemUpdateCursorPosition *subclass = static_cast<MessageItemUpdateCursorPosition*>(message);
942 m_impl->cursor_pos = subclass->get_cursor_pos_ref();
943 LOGD ("update cursor position %d", subclass->get_cursor_pos_ref());
944 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode) {
945 m_impl->signal_update_cursor_position (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
946 subclass->get_cursor_pos_ref());
948 if (!m_impl->si.null ()) m_impl->si->update_cursor_position(subclass->get_cursor_pos_ref());
951 case ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT:
953 MessageItemUpdateSurroundingText *subclass = static_cast<MessageItemUpdateSurroundingText*>(message);
954 if (m_impl->surrounding_text != NULL)
955 free (m_impl->surrounding_text);
956 m_impl->surrounding_text = strdup (subclass->get_text_ref().c_str ());
957 m_impl->cursor_pos = subclass->get_cursor_ref();
958 LOGD ("surrounding text: %s, %d", m_impl->surrounding_text, subclass->get_cursor_ref());
959 while (m_impl->need_update_surrounding_text > 0) {
960 m_impl->need_update_surrounding_text--;
961 m_impl->signal_update_surrounding_text (this, subclass->get_ic_ref(),
962 subclass->get_text_ref(), subclass->get_cursor_ref());
966 case ISM_TRANS_CMD_UPDATE_SELECTION:
968 MessageItemUpdateSelection *subclass = static_cast<MessageItemUpdateSelection*>(message);
969 if (m_impl->selection_text != NULL)
970 free (m_impl->selection_text);
972 m_impl->selection_text = strdup (subclass->get_text_ref().c_str ());
973 LOGD ("selection text: %s", m_impl->selection_text);
975 while (m_impl->need_update_selection_text > 0) {
976 m_impl->need_update_selection_text--;
977 m_impl->signal_update_selection (this, subclass->get_ic_ref(), subclass->get_text_ref());
981 case SCIM_TRANS_CMD_TRIGGER_PROPERTY:
983 MessageItemTriggerProperty *subclass = static_cast<MessageItemTriggerProperty*>(message);
984 m_impl->signal_trigger_property (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
985 subclass->get_property_ref());
986 if (!m_impl->si.null ()) m_impl->si->trigger_property(subclass->get_property_ref());
989 case SCIM_TRANS_CMD_HELPER_PROCESS_IMENGINE_EVENT:
991 MessageItemHelperProcessImengineEvent *subclass = static_cast<MessageItemHelperProcessImengineEvent*>(message);
992 m_impl->signal_process_imengine_event (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
993 subclass->get_transaction_ref());
996 case SCIM_TRANS_CMD_HELPER_ATTACH_INPUT_CONTEXT:
998 MessageItemHelperAttachInputContext *subclass = static_cast<MessageItemHelperAttachInputContext*>(message);
999 m_impl->signal_attach_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1002 case SCIM_TRANS_CMD_HELPER_DETACH_INPUT_CONTEXT:
1004 MessageItemHelperDetachInputContext *subclass = static_cast<MessageItemHelperDetachInputContext*>(message);
1005 m_impl->signal_detach_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1008 case SCIM_TRANS_CMD_FOCUS_OUT:
1010 MessageItemFocusOut *subclass = static_cast<MessageItemFocusOut*>(message);
1011 m_impl->ise_focus_flag = false;
1012 m_impl->signal_focus_out (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1013 m_impl->focused_ic = (uint32) -1;
1014 if (!m_impl->si.null ()) m_impl->si->focus_out();
1016 m_impl->ise_show_flag = false;
1019 case SCIM_TRANS_CMD_FOCUS_IN:
1021 MessageItemFocusIn *subclass = static_cast<MessageItemFocusIn*>(message);
1022 m_impl->ise_focus_flag = true;
1023 m_impl->signal_focus_in (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1024 m_impl->focused_ic = subclass->get_ic_ref();
1025 if (m_impl->finalized_text != NULL)
1026 free(m_impl->finalized_text);
1027 m_impl->finalized_text = NULL;
1028 m_impl->finalized_cursor_pos = 0;
1029 if (!m_impl->si.null ()) m_impl->si->focus_in();
1032 case ISM_TRANS_CMD_SHOW_ISE_PANEL:
1034 MessageItemShowISEPanel *subclass = static_cast<MessageItemShowISEPanel*>(message);
1035 LOGD ("Helper ISE received ISM_TRANS_CMD_SHOW_ISE_PANEL message");
1037 m_impl->signal_ise_show (this, subclass->get_ic_ref(), *(subclass->get_data_ptr()),
1038 subclass->get_len_ref());
1039 m_impl->ise_show_flag = true;
1042 case ISM_TRANS_CMD_HIDE_ISE_PANEL:
1044 MessageItemHideISEPanel *subclass = static_cast<MessageItemHideISEPanel*>(message);
1045 LOGD ("Helper ISE received ISM_TRANS_CMD_HIDE_ISE_PANEL message");
1046 m_impl->signal_ise_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1047 m_impl->ise_show_flag = false;
1050 case ISM_TRANS_CMD_GET_ACTIVE_ISE_GEOMETRY:
1052 struct rectinfo info = {0, 0, 0, 0};
1053 m_impl->signal_get_geometry (this, info);
1054 m_impl->send.clear ();
1055 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1056 m_impl->send.put_data (info.pos_x);
1057 m_impl->send.put_data (info.pos_y);
1058 m_impl->send.put_data (info.width);
1059 m_impl->send.put_data (info.height);
1060 m_impl->send.write_to_socket (m_impl->socket);
1063 case ISM_TRANS_CMD_SET_ISE_MODE:
1065 MessageItemSetISEMode *subclass = static_cast<MessageItemSetISEMode*>(message);
1066 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode) {
1067 m_impl->signal_set_mode (this, subclass->get_mode_ref());
1071 case ISM_TRANS_CMD_SET_ISE_LANGUAGE:
1073 MessageItemSetISELanguage *subclass = static_cast<MessageItemSetISELanguage*>(message);
1074 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode) {
1075 m_impl->signal_set_language (this, subclass->get_language_ref());
1079 case ISM_TRANS_CMD_SET_ISE_IMDATA:
1081 MessageItemSetISEImData *subclass = static_cast<MessageItemSetISEImData*>(message);
1082 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode) {
1083 m_impl->signal_set_imdata (this, *(subclass->get_imdata_ptr()), subclass->get_len_ref());
1085 if (!m_impl->si.null ()) m_impl->si->set_imdata(*(subclass->get_imdata_ptr()),
1086 subclass->get_len_ref());
1089 case ISM_TRANS_CMD_GET_ISE_IMDATA:
1094 m_impl->signal_get_imdata (this, &buf, len);
1095 LOGD ("send ise imdata len = %d", len);
1096 m_impl->send.clear ();
1097 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1098 m_impl->send.put_data (buf, len);
1099 m_impl->send.write_to_socket (m_impl->socket);
1104 case ISM_TRANS_CMD_GET_ISE_LANGUAGE_LOCALE:
1106 MessageItemGetISELanguageLocale *subclass = static_cast<MessageItemGetISELanguageLocale*>(message);
1108 m_impl->signal_get_language_locale (this, subclass->get_ic_ref(), &buf);
1109 m_impl->send.clear ();
1110 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1112 m_impl->send.put_data (buf, strlen (buf));
1113 m_impl->send.write_to_socket (m_impl->socket);
1118 case ISM_TRANS_CMD_SET_RETURN_KEY_TYPE:
1120 MessageItemSetReturnKeyType *subclass = static_cast<MessageItemSetReturnKeyType*>(message);
1121 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode) {
1122 m_impl->signal_set_return_key_type (this, subclass->get_type_ref());
1126 case ISM_TRANS_CMD_GET_RETURN_KEY_TYPE:
1129 m_impl->signal_get_return_key_type (this, type);
1130 m_impl->send.clear ();
1131 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1132 m_impl->send.put_data (type);
1133 m_impl->send.write_to_socket (m_impl->socket);
1136 case ISM_TRANS_CMD_SET_RETURN_KEY_DISABLE:
1138 MessageItemSetReturnKeyDisable *subclass = static_cast<MessageItemSetReturnKeyDisable*>(message);
1139 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode) {
1140 m_impl->signal_set_return_key_disable (this, subclass->get_disabled_ref());
1144 case ISM_TRANS_CMD_GET_RETURN_KEY_DISABLE:
1146 uint32 disabled = 0;
1147 m_impl->signal_get_return_key_type (this, disabled);
1148 m_impl->send.clear ();
1149 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1150 m_impl->send.put_data (disabled);
1151 m_impl->send.write_to_socket (m_impl->socket);
1154 case SCIM_TRANS_CMD_PROCESS_KEY_EVENT:
1156 MessageItemProcessKeyEvent *subclass = static_cast<MessageItemProcessKeyEvent*>(message);
1158 m_impl->signal_process_key_event(this, subclass->get_key_ref(), ret);
1160 if (!m_impl->si.null ()) {
1161 if (!(subclass->get_key_ref().get_key_string().compare("KeyRelease+XF86Back") == 0 ||
1162 subclass->get_key_ref().get_key_string().compare("XF86Back") == 0)) {
1163 ret = m_impl->si->process_key_event (subclass->get_key_ref());
1164 LOGD("imengine(%s) process key %d return %d", m_impl->si->get_factory_uuid().c_str(),
1165 subclass->get_key_ref().code, ret);
1169 m_impl->process_key_event_done (subclass->get_key_ref(), ret, subclass->get_serial_ref());
1172 case ISM_TRANS_CMD_SET_LAYOUT:
1174 MessageItemSetLayout *subclass = static_cast<MessageItemSetLayout*>(message);
1175 m_impl->layout = subclass->get_layout_ref();
1176 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode) {
1177 m_impl->signal_set_layout (this, subclass->get_layout_ref());
1179 if (!m_impl->si.null ()) m_impl->si->set_layout(subclass->get_layout_ref());
1182 case ISM_TRANS_CMD_GET_LAYOUT:
1186 m_impl->signal_get_layout (this, layout);
1187 m_impl->send.clear ();
1188 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1189 m_impl->send.put_data (layout);
1190 m_impl->send.write_to_socket (m_impl->socket);
1193 case ISM_TRANS_CMD_SET_INPUT_MODE:
1195 MessageItemSetInputMode *subclass = static_cast<MessageItemSetInputMode*>(message);
1196 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode) {
1197 m_impl->signal_set_input_mode (this, subclass->get_input_mode_ref());
1201 case ISM_TRANS_CMD_SET_CAPS_MODE:
1203 MessageItemSetCapsMode *subclass = static_cast<MessageItemSetCapsMode*>(message);
1204 m_impl->signal_set_caps_mode (this, subclass->get_mode_ref());
1207 case SCIM_TRANS_CMD_PANEL_RESET_INPUT_CONTEXT:
1209 MessageItemPanelResetInputContext *subclass = static_cast<MessageItemPanelResetInputContext*>(message);
1210 m_impl->signal_reset_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1211 if (!m_impl->si.null ()) m_impl->si->reset();
1214 case ISM_TRANS_CMD_UPDATE_CANDIDATE_UI:
1216 MessageItemUpdateCandidateUI *subclass = static_cast<MessageItemUpdateCandidateUI*>(message);
1217 m_impl->signal_update_candidate_ui (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1218 subclass->get_style_ref(), subclass->get_mode_ref());
1221 case ISM_TRANS_CMD_UPDATE_CANDIDATE_GEOMETRY:
1223 MessageItemUpdateCandidateGeometry *subclass = static_cast<MessageItemUpdateCandidateGeometry*>(message);
1224 m_impl->signal_update_candidate_geometry (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1225 subclass->get_rectinfo_ref());
1228 case ISM_TRANS_CMD_UPDATE_KEYBOARD_ISE:
1230 MessageItemUpdateKeyboardISE *subclass = static_cast<MessageItemUpdateKeyboardISE*>(message);
1231 m_impl->signal_update_keyboard_ise (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1232 subclass->get_name_ref(), subclass->get_uuid_ref());
1235 case ISM_TRANS_CMD_UPDATE_KEYBOARD_ISE_LIST:
1237 MessageItemUpdateKeyboardISEList *subclass = static_cast<MessageItemUpdateKeyboardISEList*>(message);
1238 m_impl->signal_update_keyboard_ise_list (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1239 subclass->get_list_ref());
1242 case ISM_TRANS_CMD_CANDIDATE_MORE_WINDOW_SHOW:
1244 MessageItemCandidateMoreWindowShow *subclass = static_cast<MessageItemCandidateMoreWindowShow*>(message);
1245 m_impl->signal_candidate_more_window_show (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1246 if (!m_impl->si.null ()) m_impl->si->candidate_more_window_show();
1249 case ISM_TRANS_CMD_CANDIDATE_MORE_WINDOW_HIDE:
1251 MessageItemCandidateMoreWindowHide *subclass = static_cast<MessageItemCandidateMoreWindowHide*>(message);
1252 m_impl->signal_candidate_more_window_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1253 if (!m_impl->si.null ()) m_impl->si->candidate_more_window_hide();
1256 case ISM_TRANS_CMD_SELECT_AUX:
1258 MessageItemSelectAux *subclass = static_cast<MessageItemSelectAux*>(message);
1259 m_impl->signal_select_aux (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1260 subclass->get_item_ref());
1261 if (!m_impl->si.null ()) m_impl->si->select_aux(subclass->get_item_ref());
1264 case SCIM_TRANS_CMD_SELECT_CANDIDATE: //FIXME:remove if useless
1266 MessageItemSelectCandidate *subclass = static_cast<MessageItemSelectCandidate*>(message);
1267 m_impl->signal_select_candidate (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1268 subclass->get_item_ref());
1269 if (!m_impl->si.null ()) m_impl->si->select_candidate(subclass->get_item_ref());
1272 case SCIM_TRANS_CMD_LOOKUP_TABLE_PAGE_UP: //FIXME:remove if useless
1274 MessageItemLookupTablePageUp *subclass = static_cast<MessageItemLookupTablePageUp*>(message);
1275 m_impl->signal_candidate_table_page_up (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1276 if (!m_impl->si.null ()) m_impl->si->lookup_table_page_up();
1279 case SCIM_TRANS_CMD_LOOKUP_TABLE_PAGE_DOWN: //FIXME:remove if useless
1281 MessageItemLookupTablePageDown *subclass = static_cast<MessageItemLookupTablePageDown*>(message);
1282 m_impl->signal_candidate_table_page_down (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1283 if (!m_impl->si.null ()) m_impl->si->lookup_table_page_down();
1286 case SCIM_TRANS_CMD_UPDATE_LOOKUP_TABLE_PAGE_SIZE:
1288 MessageItemUpdateLookupTablePageSize *subclass = static_cast<MessageItemUpdateLookupTablePageSize*>(message);
1289 m_impl->signal_update_candidate_table_page_size (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1290 subclass->get_size_ref());
1291 if (!m_impl->si.null ()) m_impl->si->update_lookup_table_page_size(subclass->get_size_ref());
1294 case ISM_TRANS_CMD_CANDIDATE_SHOW: //FIXME:remove if useless
1296 MessageItemCandidateShow *subclass = static_cast<MessageItemCandidateShow*>(message);
1297 m_impl->signal_candidate_show (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1300 case ISM_TRANS_CMD_CANDIDATE_HIDE: //FIXME:remove if useless
1302 MessageItemCandidateHide *subclass = static_cast<MessageItemCandidateHide*>(message);
1303 m_impl->signal_candidate_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1306 case ISM_TRANS_CMD_UPDATE_LOOKUP_TABLE: //FIXME:remove if useless
1308 MessageItemUpdateLookupTable *subclass = static_cast<MessageItemUpdateLookupTable*>(message);
1309 m_impl->signal_update_lookup_table (this, subclass->get_candidate_table_ref());
1312 case ISM_TRANS_CMD_UPDATE_CANDIDATE_ITEM_LAYOUT:
1314 MessageItemUpdateCandidateItemLayout *subclass = static_cast<MessageItemUpdateCandidateItemLayout*>(message);
1315 m_impl->signal_update_candidate_item_layout (this, subclass->get_row_items_ref());
1316 if (!m_impl->si.null ()) m_impl->si->update_candidate_item_layout(subclass->get_row_items_ref());
1319 case ISM_TRANS_CMD_SELECT_ASSOCIATE:
1321 MessageItemSelectAssociate *subclass = static_cast<MessageItemSelectAssociate*>(message);
1322 m_impl->signal_select_associate (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1323 subclass->get_item_ref());
1326 case ISM_TRANS_CMD_ASSOCIATE_TABLE_PAGE_UP:
1328 MessageItemAssociateTablePageUp *subclass = static_cast<MessageItemAssociateTablePageUp*>(message);
1329 m_impl->signal_associate_table_page_up (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1332 case ISM_TRANS_CMD_ASSOCIATE_TABLE_PAGE_DOWN:
1334 MessageItemAssociateTablePageDown *subclass = static_cast<MessageItemAssociateTablePageDown*>(message);
1335 m_impl->signal_associate_table_page_down (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1338 case ISM_TRANS_CMD_UPDATE_ASSOCIATE_TABLE_PAGE_SIZE:
1340 MessageItemUpdateAssociateTablePageSize *subclass = static_cast<MessageItemUpdateAssociateTablePageSize*>(message);
1341 m_impl->signal_update_associate_table_page_size (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1342 subclass->get_size_ref());
1345 case ISM_TRANS_CMD_RESET_ISE_CONTEXT:
1347 MessageItemResetISEContext *subclass = static_cast<MessageItemResetISEContext*>(message);
1348 m_impl->signal_reset_ise_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1349 m_impl->signal_reset_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1350 if (!m_impl->si.null ()) m_impl->si->reset();
1353 case ISM_TRANS_CMD_TURN_ON_LOG:
1355 MessageItemTurnOnLog *subclass = static_cast<MessageItemTurnOnLog*>(message);
1356 m_impl->signal_turn_on_log (this, subclass->get_state_ref());
1359 case ISM_TRANS_CMD_UPDATE_DISPLAYED_CANDIDATE:
1361 MessageItemUpdateDisplayedCandidate *subclass = static_cast<MessageItemUpdateDisplayedCandidate*>(message);
1362 m_impl->signal_update_displayed_candidate_number (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1363 subclass->get_size_ref());
1364 if (!m_impl->si.null ()) m_impl->si->update_displayed_candidate_number(subclass->get_size_ref());
1367 case ISM_TRANS_CMD_LONGPRESS_CANDIDATE:
1369 MessageItemLongpressCandidate *subclass = static_cast<MessageItemLongpressCandidate*>(message);
1370 m_impl->signal_longpress_candidate (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1371 subclass->get_index_ref());
1372 if (!m_impl->si.null ()) m_impl->si->longpress_candidate(subclass->get_index_ref());
1375 case ISM_TRANS_CMD_SET_INPUT_HINT:
1377 MessageItemSetInputHint *subclass = static_cast<MessageItemSetInputHint*>(message);
1378 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode) {
1379 m_impl->signal_set_input_hint (this, subclass->get_input_hint_ref());
1381 if (!m_impl->si.null ()) m_impl->si->set_input_hint(subclass->get_input_hint_ref());
1384 case ISM_TRANS_CMD_UPDATE_BIDI_DIRECTION:
1386 MessageItemUpdateBidiDirection *subclass = static_cast<MessageItemUpdateBidiDirection*>(message);
1387 m_impl->signal_update_bidi_direction (this, subclass->get_bidi_direction());
1388 if (!m_impl->si.null ()) m_impl->si->update_bidi_direction(subclass->get_bidi_direction());
1391 case ISM_TRANS_CMD_SHOW_ISE_OPTION_WINDOW:
1393 MessageItemShowISEOptionWindow *subclass = static_cast<MessageItemShowISEOptionWindow*>(message);
1394 m_impl->signal_show_option_window (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1397 case ISM_TRANS_CMD_RESUME_ISE_OPTION_WINDOW:
1399 MessageItemResumeISEOptionWindow *subclass = static_cast<MessageItemResumeISEOptionWindow*>(message);
1400 m_impl->signal_resume_option_window (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1403 case ISM_TRANS_CMD_CHECK_OPTION_WINDOW:
1406 m_impl->signal_check_option_window (this, avail);
1407 m_impl->send.clear ();
1408 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1409 m_impl->send.put_data (avail);
1410 m_impl->send.write_to_socket (m_impl->socket);
1413 case ISM_TRANS_CMD_PROCESS_INPUT_DEVICE_EVENT:
1415 MessageItemProcessInputDeviceEvent *subclass = static_cast<MessageItemProcessInputDeviceEvent*>(message);
1417 unsigned int ecore_event_id = find_ecore_event_from_device_type((isf_device_type_e)(subclass->get_type_ref()));
1418 m_impl->signal_process_input_device_event(this,
1419 ecore_event_id, *(subclass->get_data_ptr()), subclass->get_len_ref(), ret);
1422 case SCIM_TRANS_CMD_SET_AUTOCAPITAL_TYPE:
1424 MessageItemSetAutocapitalType *subclass = static_cast<MessageItemSetAutocapitalType*>(message);
1425 if (!m_impl->si.null ()) m_impl->si->set_autocapital_type(subclass->get_auto_capital_type_ref());
1428 case ISM_TRANS_CMD_SET_PREDICTION_ALLOW:
1430 MessageItemSetPredictionAllow *subclass = static_cast<MessageItemSetPredictionAllow*>(message);
1431 if (!m_impl->si.null ()) m_impl->si->set_prediction_allow(subclass->get_prediction_allow_ref() == 0 ? false : true);
1434 case ISM_TRANS_CMD_SET_KEYBOARD_MODE:
1436 MessageItemSetKeyboardMode *subclass = static_cast<MessageItemSetKeyboardMode*>(message);
1437 if (subclass->get_mode_ref())
1438 m_impl->hw_keyboard_mode = false;
1440 m_impl->hw_keyboard_mode = true;
1443 case ISM_TRANS_CMD_SET_PREDICTION_HINT:
1445 MessageItemSetPredictionHint *subclass = static_cast<MessageItemSetPredictionHint*>(message);
1446 m_impl->signal_set_prediction_hint (this, subclass->get_message_ref());
1449 case ISM_TRANS_CMD_SET_MIME_TYPE:
1451 MessageItemSetMimeType *subclass = static_cast<MessageItemSetMimeType*>(message);
1452 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode) {
1453 m_impl->signal_set_mime_type (this, subclass->get_mime_type_ref());
1457 case ISM_TRANS_CMD_FINALIZE_CONTENT:
1459 MessageItemFinalizeContent *subclass = static_cast<MessageItemFinalizeContent*>(message);
1461 if (m_impl->finalized_text != NULL)
1462 free(m_impl->finalized_text);
1463 m_impl->finalized_text = strdup(subclass->get_text_ref().c_str());
1464 m_impl->finalized_cursor_pos = subclass->get_cursor_pos_ref();
1468 case ISM_TRANS_CMD_SET_PREDICTION_HINT_DATA:
1470 MessageItemSetPredictionHintData *subclass = static_cast<MessageItemSetPredictionHintData*>(message);
1471 m_impl->signal_set_prediction_hint_data (this, 0, subclass->get_key_ref(), subclass->get_value_ref());
1481 * @brief Request SCIM to reload all configuration.
1483 * This function should only by used by Setup Helper to request
1484 * scim's reloading the configuration.
1485 * Deprecated: reload config message only send by socketconfig client
1486 * using socketconfig::reload instead.
1489 HelperAgent::reload_config () const
1491 LOGD ("send reload config message to isf");
1492 if (!m_impl->m_config.null())
1493 m_impl->m_config->reload();
1497 * @brief Register some properties into Panel.
1499 * This function send the request to Panel to register a list
1502 * @param properties The list of Properties to be registered into Panel.
1504 * @sa scim::Property.
1507 HelperAgent::register_properties (const PropertyList &properties) const
1509 if (m_impl->socket_active.is_connected ()) {
1510 m_impl->send.clear ();
1511 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1512 m_impl->send.put_data (m_impl->magic_active);
1513 m_impl->send.put_command (SCIM_TRANS_CMD_REGISTER_PROPERTIES);
1514 m_impl->send.put_data (properties);
1515 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1520 * @brief Update a registered property.
1522 * @param property The property to be updated.
1525 HelperAgent::update_property (const Property &property) const
1527 if (m_impl->socket_active.is_connected ()) {
1528 m_impl->send.clear ();
1529 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1530 m_impl->send.put_data (m_impl->magic_active);
1531 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PROPERTY);
1532 m_impl->send.put_data (property);
1533 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1538 * @brief Send a set of events to an IMEngineInstance.
1540 * All events should be put into a Transaction.
1541 * And the events can only be received by one IMEngineInstance object.
1543 * @param ic The handle of the Input Context to receive the events.
1544 * @param ic_uuid The UUID of the Input Context.
1545 * @param trans The Transaction object holds the events.
1548 HelperAgent::send_imengine_event (int ic,
1549 const String &ic_uuid,
1550 const Transaction &trans) const
1552 //remove if not necessary
1554 if (m_impl->socket_active.is_connected ()) {
1555 m_impl->send.clear ();
1556 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1557 m_impl->send.put_data (m_impl->magic_active);
1558 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_SEND_IMENGINE_EVENT);
1559 m_impl->send.put_data ((uint32)ic);
1560 m_impl->send.put_data (ic_uuid);
1561 m_impl->send.put_data (trans);
1562 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1565 if (!m_impl->si.null ()) m_impl->si->process_helper_event (ic_uuid, trans);
1569 * @brief Send a KeyEvent to an IMEngineInstance.
1571 * @param ic The handle of the IMEngineInstance to receive the event.
1572 * -1 means the currently focused IMEngineInstance.
1573 * @param ic_uuid The UUID of the IMEngineInstance. Empty means don't match.
1574 * @param key The KeyEvent to be sent.
1577 HelperAgent::send_key_event (int ic,
1578 const String &ic_uuid,
1579 const KeyEvent &key) const
1582 //FIXME: remove shift_mode_off, shift_mode_on, shift_mode_lock from ISE side
1583 if (key.code == SHIFT_MODE_OFF ||
1584 key.code == SHIFT_MODE_ON ||
1585 key.code == SHIFT_MODE_LOCK ||
1586 key.code == SHIFT_MODE_ENABLE ||
1587 key.code == SHIFT_MODE_DISABLE) {
1588 LOGW("FIXME ignore shift codes");
1592 if (m_impl->socket_active.is_connected ()) {
1593 m_impl->send.clear ();
1594 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1595 m_impl->send.put_data (m_impl->magic_active);
1596 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_SEND_KEY_EVENT);
1598 m_impl->send.put_data (m_impl->focused_ic);
1600 m_impl->send.put_data ((uint32)ic);
1602 m_impl->send.put_data (ic_uuid);
1603 m_impl->send.put_data (key);
1604 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1609 * @brief Forward a KeyEvent to client application directly.
1611 * @param ic The handle of the client Input Context to receive the event.
1612 * -1 means the currently focused Input Context.
1613 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1614 * Empty means don't match.
1615 * @param key The KeyEvent to be forwarded.
1618 HelperAgent::forward_key_event (int ic,
1619 const String &ic_uuid,
1620 const KeyEvent &key) const
1622 if (m_impl->socket_active.is_connected ()) {
1623 m_impl->send.clear ();
1624 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1625 m_impl->send.put_data (m_impl->magic_active);
1626 m_impl->send.put_command (SCIM_TRANS_CMD_FORWARD_KEY_EVENT);
1628 m_impl->send.put_data (m_impl->focused_ic);
1630 m_impl->send.put_data ((uint32)ic);
1632 m_impl->send.put_data (ic_uuid);
1633 m_impl->send.put_data (key);
1634 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1639 * @brief Commit a WideString to client application directly.
1641 * @param ic The handle of the client Input Context to receive the WideString.
1642 * -1 means the currently focused Input Context.
1643 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1644 * Empty means don't match.
1645 * @param wstr The WideString to be committed.
1648 HelperAgent::commit_string (int ic,
1649 const String &ic_uuid,
1650 const WideString &wstr) const
1652 if (m_impl->socket_active.is_connected ()) {
1653 m_impl->send.clear ();
1654 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1655 m_impl->send.put_data (m_impl->magic_active);
1656 m_impl->send.put_command (SCIM_TRANS_CMD_COMMIT_STRING);
1658 m_impl->send.put_data (m_impl->focused_ic);
1660 m_impl->send.put_data ((uint32)ic);
1662 m_impl->send.put_data (ic_uuid);
1663 m_impl->send.put_data (wstr);
1664 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1669 HelperAgent::commit_string (int ic,
1670 const String &ic_uuid,
1674 if (m_impl->socket_active.is_connected ()) {
1675 m_impl->send.clear ();
1676 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1677 m_impl->send.put_data (m_impl->magic_active);
1678 m_impl->send.put_command (SCIM_TRANS_CMD_COMMIT_STRING);
1680 m_impl->send.put_data (m_impl->focused_ic);
1682 m_impl->send.put_data ((uint32)ic);
1684 m_impl->send.put_data (ic_uuid);
1685 m_impl->send.put_dataw (buf, buflen);
1686 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1691 * @brief Request to show preedit string.
1693 * @param ic The handle of the client Input Context to receive the request.
1694 * -1 means the currently focused Input Context.
1695 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1696 * Empty means don't match.
1699 HelperAgent::show_preedit_string (int ic,
1700 const String &ic_uuid) const
1703 if (m_impl->socket_active.is_connected ()) {
1704 m_impl->send.clear ();
1705 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1706 m_impl->send.put_data (m_impl->magic_active);
1707 m_impl->send.put_command (SCIM_TRANS_CMD_SHOW_PREEDIT_STRING);
1708 m_impl->send.put_data ((uint32)ic);
1709 m_impl->send.put_data (ic_uuid);
1710 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1715 * @brief Request to show aux string.
1718 HelperAgent::show_aux_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 (SCIM_TRANS_CMD_SHOW_AUX_STRING);
1726 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1731 * @brief Request to show candidate string.
1734 HelperAgent::show_candidate_string (void) const
1737 if (m_impl->socket_active.is_connected ()) {
1738 m_impl->send.clear ();
1739 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1740 m_impl->send.put_data (m_impl->magic_active);
1741 m_impl->send.put_command (SCIM_TRANS_CMD_SHOW_LOOKUP_TABLE);
1742 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1747 * @brief Request to show associate string.
1750 HelperAgent::show_associate_string (void) const
1752 if (m_impl->socket_active.is_connected ()) {
1753 m_impl->send.clear ();
1754 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1755 m_impl->send.put_data (m_impl->magic_active);
1756 m_impl->send.put_command (ISM_TRANS_CMD_SHOW_ASSOCIATE_TABLE);
1757 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1762 * @brief Request to hide preedit string.
1764 * @param ic The handle of the client Input Context to receive the request.
1765 * -1 means the currently focused Input Context.
1766 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1767 * Empty means don't match.
1770 HelperAgent::hide_preedit_string (int ic,
1771 const String &ic_uuid) const
1774 if (m_impl->socket_active.is_connected ()) {
1775 m_impl->send.clear ();
1776 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1777 m_impl->send.put_data (m_impl->magic_active);
1778 m_impl->send.put_command (SCIM_TRANS_CMD_HIDE_PREEDIT_STRING);
1779 m_impl->send.put_data ((uint32)ic);
1780 m_impl->send.put_data (ic_uuid);
1781 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1786 * @brief Request to hide aux string.
1789 HelperAgent::hide_aux_string (void) const
1791 if (m_impl->socket_active.is_connected ()) {
1792 m_impl->send.clear ();
1793 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1794 m_impl->send.put_data (m_impl->magic_active);
1795 m_impl->send.put_command (SCIM_TRANS_CMD_HIDE_AUX_STRING);
1796 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1801 * @brief Request to hide candidate string.
1804 HelperAgent::hide_candidate_string (void) const
1806 if (m_impl->socket_active.is_connected ()) {
1807 m_impl->send.clear ();
1808 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1809 m_impl->send.put_data (m_impl->magic_active);
1810 m_impl->send.put_command (SCIM_TRANS_CMD_HIDE_LOOKUP_TABLE);
1811 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1816 * @brief Request to hide associate string.
1819 HelperAgent::hide_associate_string (void) const
1821 if (m_impl->socket_active.is_connected ()) {
1822 m_impl->send.clear ();
1823 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1824 m_impl->send.put_data (m_impl->magic_active);
1825 m_impl->send.put_command (ISM_TRANS_CMD_HIDE_ASSOCIATE_TABLE);
1826 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1831 * @brief Update a new WideString for preedit.
1833 * @param ic The handle of the client Input Context to receive the WideString.
1834 * -1 means the currently focused Input Context.
1835 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1836 * Empty means don't match.
1837 * @param str The WideString to be updated.
1838 * @param attrs The attribute list for preedit string.
1841 HelperAgent::update_preedit_string (int ic,
1842 const String &ic_uuid,
1843 const WideString &str,
1844 const AttributeList &attrs) const
1846 update_preedit_string (ic, ic_uuid, str, str, attrs, -1);
1850 HelperAgent::update_preedit_string (int ic,
1851 const String &ic_uuid,
1854 const AttributeList &attrs) const
1856 update_preedit_string (ic, ic_uuid, buf, buflen, attrs, -1);
1860 * @brief Update a new WideString for preedit.
1862 * @param ic The handle of the client Input Context to receive the WideString.
1863 * -1 means the currently focused Input Context.
1864 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1865 * Empty means don't match.
1866 * @param str The WideString to be updated.
1867 * @param attrs The attribute list for preedit string.
1868 * @param caret The caret position in preedit string.
1871 HelperAgent::update_preedit_string (int ic,
1872 const String &ic_uuid,
1873 const WideString &wstr,
1874 const AttributeList &attrs,
1877 update_preedit_string (ic, ic_uuid, wstr, wstr, attrs, caret);
1881 HelperAgent::update_preedit_string (int ic,
1882 const String &ic_uuid,
1885 const AttributeList &attrs,
1889 if (m_impl->socket_active.is_connected ()) {
1890 m_impl->send.clear ();
1891 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1892 m_impl->send.put_data (m_impl->magic_active);
1893 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING);
1894 m_impl->send.put_data ((uint32)ic);
1895 m_impl->send.put_data (ic_uuid);
1896 m_impl->send.put_dataw (buf, buflen);
1897 m_impl->send.put_dataw (buf, buflen);
1898 m_impl->send.put_data (attrs);
1899 m_impl->send.put_data (caret);
1900 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1905 HelperAgent::update_preedit_string (int ic,
1906 const String &ic_uuid,
1907 const WideString &preedit,
1908 const WideString &commit,
1909 const AttributeList &attrs,
1912 if (m_impl->socket_active.is_connected ()) {
1913 m_impl->send.clear ();
1914 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1915 m_impl->send.put_data (m_impl->magic_active);
1916 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING);
1917 m_impl->send.put_data ((uint32)ic);
1918 m_impl->send.put_data (ic_uuid);
1919 m_impl->send.put_data (preedit);
1920 m_impl->send.put_data (commit);
1921 m_impl->send.put_data (attrs);
1922 m_impl->send.put_data (caret);
1923 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1928 * @brief Update the preedit caret position in the preedit string.
1930 * @param caret - the new position of the preedit caret.
1933 HelperAgent::update_preedit_caret (int caret) const
1936 if (m_impl->socket_active.is_connected ()) {
1937 m_impl->send.clear ();
1938 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1939 m_impl->send.put_data (m_impl->magic_active);
1940 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_CARET);
1941 m_impl->send.put_data ((uint32)caret);
1942 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1947 * @brief Update a new string for aux.
1949 * @param str The string to be updated.
1950 * @param attrs The attribute list for aux string.
1953 HelperAgent::update_aux_string (const String &str,
1954 const AttributeList &attrs) const
1956 if (m_impl->socket_active.is_connected ()) {
1957 m_impl->send.clear ();
1958 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1959 m_impl->send.put_data (m_impl->magic_active);
1960 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_AUX_STRING);
1961 m_impl->send.put_data (str);
1962 m_impl->send.put_data (attrs);
1963 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1968 * @brief Request to update candidate.
1970 * @param table The lookup table for candidate.
1973 HelperAgent::update_candidate_string (const LookupTable &table) const
1975 if (m_impl->socket_active.is_connected ()) {
1976 m_impl->send.clear ();
1977 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1978 m_impl->send.put_data (m_impl->magic_active);
1979 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_LOOKUP_TABLE);
1980 m_impl->send.put_data (table);
1981 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1986 * @brief Request to update associate.
1988 * @param table The lookup table for associate.
1991 HelperAgent::update_associate_string (const LookupTable &table) const
1993 if (m_impl->socket_active.is_connected ()) {
1994 m_impl->send.clear ();
1995 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1996 m_impl->send.put_data (m_impl->magic_active);
1997 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ASSOCIATE_TABLE);
1998 m_impl->send.put_data (table);
1999 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2004 * @brief When the input context of ISE is changed,
2005 * ISE can call this function to notify application
2007 * @param type type of event.
2008 * @param value value of event.
2011 HelperAgent::update_input_context (uint32 type, uint32 value) const
2013 /* Update all state variables that could be queried by the client application */
2015 m_impl->signal_get_language_locale(this, -1, &buf);
2018 if (m_impl->socket_active.is_connected()) {
2019 m_impl->send.clear();
2020 m_impl->send.put_command(SCIM_TRANS_CMD_REQUEST);
2021 m_impl->send.put_data(m_impl->magic_active);
2022 m_impl->send.put_command(ISM_TRANS_CMD_UPDATE_ISE_LANGUAGE_LOCALE);
2023 m_impl->send.put_data(buf, strlen(buf));
2024 m_impl->send.write_to_socket(m_impl->socket_active, m_impl->magic_active);
2030 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 (ISM_TRANS_CMD_UPDATE_ISE_INPUT_CONTEXT);
2035 m_impl->send.put_data (type);
2036 m_impl->send.put_data (value);
2037 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2042 * @brief Request to get surrounding text asynchronously.
2044 * @param uuid The helper ISE UUID.
2045 * @param maxlen_before The max length of before.
2046 * @param maxlen_after The max length of after.
2049 HelperAgent::get_surrounding_text (const String &uuid, int maxlen_before, int maxlen_after) const
2051 if (m_impl->socket_active.is_connected () && (m_impl->need_update_surrounding_text == 0)) {
2052 m_impl->send.clear ();
2053 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2054 m_impl->send.put_data (m_impl->magic_active);
2055 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SURROUNDING_TEXT);
2056 m_impl->send.put_data (uuid);
2057 m_impl->send.put_data (maxlen_before);
2058 m_impl->send.put_data (maxlen_after);
2059 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2061 m_impl->need_update_surrounding_text++;
2065 * @brief Request to get surrounding text synchronously.
2067 * @param uuid The helper ISE UUID.
2068 * @param maxlen_before The max length of before.
2069 * @param maxlen_after The max length of after.
2070 * @param text The surrounding text.
2071 * @param cursor The cursor position.
2074 HelperAgent::get_surrounding_text (int maxlen_before, int maxlen_after, String &text, int &cursor)
2076 if (!m_impl->socket_active.is_connected ())
2079 if (!m_impl->ise_focus_flag) {
2080 if (m_impl->finalized_text) {
2081 String buffer = m_impl->finalized_text;
2082 cursor = m_impl->finalized_cursor_pos;
2083 int pos = cursor - maxlen_before;
2084 if (maxlen_before < 0) pos = 0;
2085 if (pos > (int)buffer.length()) pos = (int)buffer.length();
2086 if (pos < 0) pos = 0;
2087 size_t len = maxlen_after + (cursor - pos);
2088 if (maxlen_after < 0) len = String::npos;
2089 text = buffer.substr (pos, len);
2095 m_impl->send.clear();
2096 m_impl->send.put_command(SCIM_TRANS_CMD_REQUEST);
2097 m_impl->send.put_data(m_impl->magic_active);
2098 m_impl->send.put_command(SCIM_TRANS_CMD_GET_SURROUNDING_TEXT);
2099 m_impl->send.put_data("");
2100 m_impl->send.put_data(maxlen_before);
2101 m_impl->send.put_data(maxlen_after);
2102 m_impl->send.write_to_socket(m_impl->socket_active, m_impl->magic_active);
2103 if (m_impl->surrounding_text) {
2104 free(m_impl->surrounding_text);
2105 m_impl->surrounding_text = NULL;
2108 const int WAIT_FOR_SYNC_RESPONSE_TIMEOUT = 1000;
2109 /* Now we are waiting for the ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT message */
2110 if (wait_for_message(ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT, WAIT_FOR_SYNC_RESPONSE_TIMEOUT)) {
2111 MessageItem *message = message_queue.get_pending_message_by_cmd(ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT);
2112 handle_message(message);
2113 message_queue.remove_message(message);
2115 if (m_impl->surrounding_text) {
2116 text = m_impl->surrounding_text;
2117 cursor = m_impl->cursor_pos;
2121 if (m_impl->surrounding_text) {
2122 free(m_impl->surrounding_text);
2123 m_impl->surrounding_text = NULL;
2129 * @brief Request to delete surrounding text.
2131 * @param offset The offset for cursor position.
2132 * @param len The length for delete text.
2135 HelperAgent::delete_surrounding_text (int offset, int len) const
2137 LOGD ("offset = %d, len = %d", offset, len);
2139 if (m_impl->socket_active.is_connected ()) {
2140 m_impl->send.clear ();
2141 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2142 m_impl->send.put_data (m_impl->magic_active);
2143 m_impl->send.put_command (SCIM_TRANS_CMD_DELETE_SURROUNDING_TEXT);
2144 m_impl->send.put_data (offset);
2145 m_impl->send.put_data (len);
2146 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2151 * @brief Request to get selection text asynchronously.
2153 * @param uuid The helper ISE UUID.
2156 HelperAgent::get_selection (const String &uuid) const
2158 if (m_impl->socket_active.is_connected () && (m_impl->need_update_selection_text == 0)) {
2159 m_impl->send.clear ();
2160 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2161 m_impl->send.put_data (m_impl->magic_active);
2162 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SELECTION);
2163 m_impl->send.put_data (uuid);
2164 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2166 m_impl->need_update_selection_text++;
2170 * @brief Request to get selection text synchronously.
2172 * @param text The selection text.
2175 HelperAgent::get_selection_text (String &text)
2178 if (!m_impl->socket_active.is_connected ())
2181 m_impl->send.clear ();
2182 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2183 m_impl->send.put_data (m_impl->magic_active);
2184 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SELECTION);
2185 m_impl->send.put_data ("");
2186 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2187 if (m_impl->selection_text) {
2188 free (m_impl->selection_text);
2189 m_impl->selection_text = NULL;
2192 const int WAIT_FOR_SYNC_RESPONSE_TIMEOUT = 1000;
2193 /* Now we are waiting for the ISM_TRANS_CMD_UPDATE_SELECTION message */
2194 if (wait_for_message(ISM_TRANS_CMD_UPDATE_SELECTION, WAIT_FOR_SYNC_RESPONSE_TIMEOUT)) {
2195 MessageItem *message = message_queue.get_pending_message_by_cmd(ISM_TRANS_CMD_UPDATE_SELECTION);
2196 handle_message(message);
2197 message_queue.remove_message(message);
2198 if (m_impl->selection_text) {
2199 text = m_impl->selection_text;
2203 if (m_impl->selection_text) {
2204 free (m_impl->selection_text);
2205 m_impl->selection_text = NULL;
2210 * @brief Request to select text.
2212 * @param start The start position in text.
2213 * @param end The end position in text.
2216 HelperAgent::set_selection (int start, int end) const
2218 if (m_impl->socket_active.is_connected ()) {
2219 m_impl->send.clear ();
2220 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2221 m_impl->send.put_data (m_impl->magic_active);
2222 m_impl->send.put_command (SCIM_TRANS_CMD_SET_SELECTION);
2223 m_impl->send.put_data (start);
2224 m_impl->send.put_data (end);
2225 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2230 * @brief Send a private command to an application.
2232 * @param command The private command sent from IME.
2235 HelperAgent::send_private_command (const String &command) const
2237 if (m_impl->socket_active.is_connected ()) {
2238 m_impl->send.clear ();
2239 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2240 m_impl->send.put_data (m_impl->magic_active);
2241 m_impl->send.put_command (SCIM_TRANS_CMD_SEND_PRIVATE_COMMAND);
2242 m_impl->send.put_data (command);
2243 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2248 * @brief Commit content to an application.
2250 * @param content The content sent from IME.
2253 HelperAgent::commit_content (const String &content, const String &description, const String &mime_types) const
2256 if (m_impl->socket_active.is_connected ()) {
2257 m_impl->send.clear ();
2258 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2259 m_impl->send.put_data (m_impl->magic_active);
2260 m_impl->send.put_command (SCIM_TRANS_CMD_COMMIT_CONTENT);
2261 m_impl->send.put_data (content);
2262 m_impl->send.put_data (description);
2263 m_impl->send.put_data (mime_types);
2264 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2269 * @brief Request to get uuid list of all keyboard ISEs.
2271 * @param uuid The helper ISE UUID.
2274 HelperAgent::get_keyboard_ise_list (const String &uuid) const
2276 if (m_impl->socket_active.is_connected ()) {
2277 m_impl->send.clear ();
2278 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2279 m_impl->send.put_data (m_impl->magic_active);
2280 m_impl->send.put_command (ISM_TRANS_CMD_GET_KEYBOARD_ISE_LIST);
2281 m_impl->send.put_data (uuid);
2282 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2287 * @brief Set candidate position in screen.
2289 * @param left The x position in screen.
2290 * @param top The y position in screen.
2293 HelperAgent::set_candidate_position (int left, int top) const
2295 if (m_impl->socket_active.is_connected ()) {
2296 m_impl->send.clear ();
2297 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2298 m_impl->send.put_data (m_impl->magic_active);
2299 m_impl->send.put_command (ISM_TRANS_CMD_SET_CANDIDATE_POSITION);
2300 m_impl->send.put_data (left);
2301 m_impl->send.put_data (top);
2302 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2307 * @brief Set candidate style.
2309 * @param portrait_line - the displayed line number for portrait mode.
2310 * @param mode - candidate window mode.
2313 HelperAgent::set_candidate_style (ISF_CANDIDATE_PORTRAIT_LINE_T portrait_line,
2314 ISF_CANDIDATE_MODE_T mode) const
2316 if (m_impl->socket_active.is_connected ()) {
2317 m_impl->send.clear ();
2318 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2319 m_impl->send.put_data (m_impl->magic_active);
2320 m_impl->send.put_command (ISM_TRANS_CMD_SET_CANDIDATE_UI);
2321 m_impl->send.put_data (portrait_line);
2322 m_impl->send.put_data (mode);
2323 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2328 * @brief Request to hide candidate window.
2331 HelperAgent::candidate_hide (void) const
2333 if (m_impl->socket_active.is_connected ()) {
2334 m_impl->send.clear ();
2335 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2336 m_impl->send.put_data (m_impl->magic_active);
2337 m_impl->send.put_command (ISM_TRANS_CMD_HIDE_CANDIDATE);
2338 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2343 * @brief Request to get candidate window size and position.
2345 * @param uuid The helper ISE UUID.
2348 HelperAgent::get_candidate_window_geometry (const String &uuid) const
2350 if (m_impl->socket_active.is_connected ()) {
2351 m_impl->send.clear ();
2352 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2353 m_impl->send.put_data (m_impl->magic_active);
2354 m_impl->send.put_command (ISM_TRANS_CMD_GET_CANDIDATE_GEOMETRY);
2355 m_impl->send.put_data (uuid);
2356 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2361 * @brief Set current keyboard ISE.
2363 * @param uuid The keyboard ISE UUID.
2366 HelperAgent::set_keyboard_ise_by_uuid (const String &uuid) const
2369 IMEngineFactoryPointer factory;
2370 IMEngineModule *engine_module = NULL;
2371 static int instance_count = 1;
2373 if ((!m_impl->si.null ()) && m_impl->si->get_factory_uuid () == uuid) {
2374 ISF_SAVE_LOG ("Already in UUID: %s", uuid.c_str());
2378 if (!m_impl->si.null()) {
2379 m_impl->si->focus_out();
2383 if (m_impl->m_config.null ()) {
2384 ISF_SAVE_LOG ("config is not working");
2388 #ifdef HAVE_PKGMGR_INFO
2391 pkgmgrinfo_appinfo_h handle;
2392 ret = pkgmgrinfo_appinfo_get_appinfo(uuid.c_str(), &handle);
2393 if (ret != PMINFO_R_OK) {
2394 ISF_SAVE_LOG ("Retrieve app info failed : %s", uuid.c_str ());
2398 ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
2399 if (ret != PMINFO_R_OK) {
2400 ISF_SAVE_LOG ("Retrieve pkgid failed : %s, %p", uuid.c_str(), handle);
2401 pkgmgrinfo_appinfo_destroy_appinfo(handle);
2405 imeInfo.module_name = pkgid;
2406 pkgmgrinfo_appinfo_destroy_appinfo(handle);
2408 if (isf_db_select_ime_info_by_appid(uuid.c_str(), &imeInfo) < 1) {
2409 ISF_SAVE_LOG ("ime_info row is not available for %s", uuid.c_str());
2414 engine_module = &m_impl->engine_module;
2416 if (engine_module->valid() && imeInfo.module_name != engine_module->get_module_name()) {
2417 ISF_SAVE_LOG ("imengine module %s unloaded", engine_module->get_module_name().c_str());
2418 engine_module->unload();
2421 if (!engine_module->valid()) {
2422 if (engine_module->load (imeInfo.module_name, m_impl->m_config) == false) {
2423 ISF_SAVE_LOG ("load module %s failed", imeInfo.module_name.c_str());
2426 ISF_SAVE_LOG ("imengine module %s loaded", imeInfo.module_name.c_str());
2429 for (size_t j = 0; j < engine_module->number_of_factories (); ++j) {
2431 factory = engine_module->create_factory (j);
2432 if (factory.null () == false && factory->get_uuid () == uuid)
2440 if (factory.null()) {
2441 ISF_SAVE_LOG ("imengine uuid %s is not found", uuid.c_str());
2445 m_impl->si = factory->create_instance ("UTF-8", instance_count++);
2446 if (m_impl->si.null ()) {
2447 ISF_SAVE_LOG ("create_instance %s failed", uuid.c_str ());
2451 m_impl->attach_instance ();
2452 ISF_SAVE_LOG ("Require UUID: %s Current UUID: %s", uuid.c_str (), m_impl->si->get_factory_uuid ().c_str ());
2453 m_impl->si->set_layout (m_impl->layout);
2454 if (m_impl->focused_ic != (uint32)-1)
2455 m_impl->si->focus_in ();
2459 * @brief Request to get current keyboard ISE information.
2461 * @param uuid The helper ISE UUID.
2464 HelperAgent::get_keyboard_ise (const String &uuid) const
2466 //FIXME: maybe useless
2468 if (m_impl->socket_active.is_connected ()) {
2469 m_impl->send.clear ();
2470 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2471 m_impl->send.put_data (m_impl->magic_active);
2472 m_impl->send.put_command (ISM_TRANS_CMD_GET_KEYBOARD_ISE);
2473 m_impl->send.put_data (uuid);
2474 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2480 * @brief Update ISE window geometry.
2482 * @param x The x position in screen.
2483 * @param y The y position in screen.
2484 * @param width The ISE window width.
2485 * @param height The ISE window height.
2488 HelperAgent::update_geometry (int x, int y, int width, int height) const
2490 if (m_impl->socket_active.is_connected ()) {
2491 m_impl->send.clear ();
2492 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2493 m_impl->send.put_data (m_impl->magic_active);
2494 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ISE_GEOMETRY);
2495 m_impl->send.put_data (x);
2496 m_impl->send.put_data (y);
2497 m_impl->send.put_data (width);
2498 m_impl->send.put_data (height);
2499 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2504 * @brief Request to expand candidate window.
2507 HelperAgent::expand_candidate (void) const
2509 if (m_impl->socket_active.is_connected ()) {
2510 m_impl->send.clear ();
2511 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2512 m_impl->send.put_data (m_impl->magic_active);
2513 m_impl->send.put_command (ISM_TRANS_CMD_EXPAND_CANDIDATE);
2514 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2519 * @brief Request to contract candidate window.
2522 HelperAgent::contract_candidate (void) const
2524 if (m_impl->socket_active.is_connected ()) {
2525 m_impl->send.clear ();
2526 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2527 m_impl->send.put_data (m_impl->magic_active);
2528 m_impl->send.put_command (ISM_TRANS_CMD_CONTRACT_CANDIDATE);
2529 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2534 * @brief Send selected candidate string index number.
2537 HelperAgent::select_candidate (int index) const
2539 if (!m_impl->si.null ())
2540 m_impl->si->select_candidate (index);
2541 //FIXME: maybe useless
2544 if (m_impl->socket_active.is_connected ()) {
2545 m_impl->send.clear ();
2546 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2547 m_impl->send.put_data (m_impl->magic_active);
2548 m_impl->send.put_command (ISM_TRANS_CMD_SELECT_CANDIDATE);
2549 m_impl->send.put_data (index);
2550 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2556 * @brief Update our ISE is exiting.
2559 HelperAgent::update_ise_exit (void) const
2561 //FIXME: maybe useless
2563 if (m_impl->socket_active.is_connected ()) {
2564 m_impl->send.clear ();
2565 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2566 m_impl->send.put_data (m_impl->magic_active);
2567 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ISE_EXIT);
2568 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2574 * @brief Request to reset keyboard ISE.
2577 HelperAgent::reset_keyboard_ise (void) const
2579 //FIXME: maybe useless
2581 if (m_impl->socket_active.is_connected ()) {
2582 m_impl->send.clear ();
2583 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2584 m_impl->send.put_data (m_impl->magic_active);
2585 m_impl->send.put_command (ISM_TRANS_CMD_PANEL_RESET_KEYBOARD_ISE);
2586 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2589 if (!m_impl->si.null ()) {
2590 m_impl->si->reset ();
2595 * @brief Request to flush keyboard ISE.
2598 HelperAgent::flush_keyboard_ise (void) const
2600 if (!m_impl->si.null ()) {
2601 m_impl->si->flush ();
2606 * @brief Request panel to hide ISE.
2609 HelperAgent::request_ise_hide (void) const
2611 if (m_impl->socket_active.is_connected ()) {
2612 m_impl->send.clear ();
2613 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2614 m_impl->send.put_data (m_impl->magic_active);
2615 m_impl->send.put_command (ISM_TRANS_CMD_REQUEST_ISE_HIDE);
2616 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2624 HelperAgent::recapture_string (int ic,
2625 const String &ic_uuid,
2628 const WideString &preedit_str,
2629 const WideString &commit_str,
2630 const AttributeList &attrs) const
2632 LOGD ("offset = %d, len = %d", offset, len);
2634 if (m_impl->socket_active.is_connected ()) {
2635 m_impl->send.clear ();
2636 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2637 m_impl->send.put_data (m_impl->magic_active);
2638 m_impl->send.put_command (ISM_TRANS_CMD_RECAPTURE_STRING);
2640 m_impl->send.put_data ((uint32)ic);
2641 m_impl->send.put_data (ic_uuid);
2643 // Deleting surrounding text
2644 m_impl->send.put_data (offset);
2645 m_impl->send.put_data (len);
2647 // Update preedit text
2648 m_impl->send.put_data (preedit_str);
2651 m_impl->send.put_data (commit_str);
2653 // preedit attributes
2654 m_impl->send.put_data (attrs);
2656 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2661 * @brief Connect a slot to Helper exit signal.
2663 * This signal is used to let the Helper exit.
2665 * The prototype of the slot is:
2667 * void exit (const HelperAgent *agent, int ic, const String &ic_uuid);
2670 * - agent The pointer to the HelperAgent object which emits this signal.
2671 * - ic An opaque handle of the currently focused input context.
2672 * - ic_uuid The UUID of the IMEngineInstance associated with the focused input context.
2675 HelperAgent::signal_connect_exit (HelperAgentSlotVoid *slot)
2677 return m_impl->signal_exit.connect (slot);
2681 * @brief Connect a slot to Helper attach input context signal.
2683 * This signal is used to attach an input context to this helper.
2685 * When an input context requst to start this helper, then this
2686 * signal will be emitted as soon as the helper is started.
2688 * When an input context want to start an already started helper,
2689 * this signal will also be emitted.
2691 * Helper can send some events back to the IMEngineInstance in this
2692 * signal-slot, to inform that it has been started sccessfully.
2694 * The prototype of the slot is:
2696 * void attach_input_context (const HelperAgent *agent, int ic, const String &ic_uuid);
2699 HelperAgent::signal_connect_attach_input_context (HelperAgentSlotVoid *slot)
2701 return m_impl->signal_attach_input_context.connect (slot);
2705 * @brief Connect a slot to Helper detach input context signal.
2707 * This signal is used to detach an input context from this helper.
2709 * When an input context requst to stop this helper, then this
2710 * signal will be emitted.
2712 * Helper shouldn't send any event back to the IMEngineInstance, because
2713 * the IMEngineInstance attached to the ic should have been destroyed.
2715 * The prototype of the slot is:
2717 * void detach_input_context (const HelperAgent *agent, int ic, const String &ic_uuid);
2720 HelperAgent::signal_connect_detach_input_context (HelperAgentSlotVoid *slot)
2722 return m_impl->signal_detach_input_context.connect (slot);
2726 * @brief Connect a slot to Helper reload config signal.
2728 * This signal is used to let the Helper reload configuration.
2730 * The prototype of the slot is:
2732 * void reload_config (const HelperAgent *agent, int ic, const String &ic_uuid);
2735 HelperAgent::signal_connect_reload_config (HelperAgentSlotVoid *slot)
2737 return m_impl->signal_reload_config.connect (slot);
2741 * @brief Connect a slot to Helper update screen signal.
2743 * This signal is used to let the Helper move its GUI to another screen.
2744 * It can only be emitted when SCIM_HELPER_NEED_SCREEN_INFO is set in HelperInfo.option.
2746 * The prototype of the slot is:
2748 * void update_screen (const HelperAgent *agent, int ic, const String &ic_uuid, int screen_number);
2751 HelperAgent::signal_connect_update_screen (HelperAgentSlotInt *slot)
2753 return m_impl->signal_update_screen.connect (slot);
2757 * @brief Connect a slot to Helper update spot location signal.
2759 * This signal is used to let the Helper move its GUI according to the current spot location.
2760 * It can only be emitted when SCIM_HELPER_NEED_SPOT_LOCATION_INFO is set in HelperInfo.option.
2762 * The prototype of the slot is:
2763 * void update_spot_location (const HelperAgent *agent, int ic, const String &ic_uuid, int x, int y);
2766 HelperAgent::signal_connect_update_spot_location (HelperAgentSlotIntInt *slot)
2768 return m_impl->signal_update_spot_location.connect (slot);
2772 * @brief Connect a slot to Helper update cursor position signal.
2774 * This signal is used to let the Helper get the cursor position information.
2776 * The prototype of the slot is:
2777 * void update_cursor_position (const HelperAgent *agent, int ic, const String &ic_uuid, int cursor_pos);
2780 HelperAgent::signal_connect_update_cursor_position (HelperAgentSlotInt *slot)
2782 return m_impl->signal_update_cursor_position.connect (slot);
2786 * @brief Connect a slot to Helper update surrounding text signal.
2788 * This signal is used to let the Helper get the surrounding text.
2790 * The prototype of the slot is:
2791 * void update_surrounding_text (const HelperAgent *agent, int ic, const String &text, int cursor);
2794 HelperAgent::signal_connect_update_surrounding_text (HelperAgentSlotInt *slot)
2796 return m_impl->signal_update_surrounding_text.connect (slot);
2800 * @brief Connect a slot to Helper update selection signal.
2802 * This signal is used to let the Helper get the selection.
2804 * The prototype of the slot is:
2805 * void update_selection (const HelperAgent *agent, int ic, const String &text);
2808 HelperAgent::signal_connect_update_selection (HelperAgentSlotVoid *slot)
2810 return m_impl->signal_update_selection.connect (slot);
2814 * @brief Connect a slot to Helper trigger property signal.
2816 * This signal is used to trigger a property registered by this Helper.
2817 * A property will be triggered when user clicks on it.
2819 * The prototype of the slot is:
2820 * void trigger_property (const HelperAgent *agent, int ic, const String &ic_uuid, const String &property);
2823 HelperAgent::signal_connect_trigger_property (HelperAgentSlotString *slot)
2825 return m_impl->signal_trigger_property.connect (slot);
2829 * @brief Connect a slot to Helper process imengine event signal.
2831 * This signal is used to deliver the events sent from IMEngine to Helper.
2833 * The prototype of the slot is:
2834 * void process_imengine_event (const HelperAgent *agent, int ic, const String &ic_uuid, const Transaction &transaction);
2837 HelperAgent::signal_connect_process_imengine_event (HelperAgentSlotTransaction *slot)
2839 return m_impl->signal_process_imengine_event.connect (slot);
2843 * @brief Connect a slot to Helper focus out signal.
2845 * This signal is used to do something when input context is focus out.
2847 * The prototype of the slot is:
2848 * void focus_out (const HelperAgent *agent, int ic, const String &ic_uuid);
2851 HelperAgent::signal_connect_focus_out (HelperAgentSlotVoid *slot)
2853 return m_impl->signal_focus_out.connect (slot);
2857 * @brief Connect a slot to Helper focus in signal.
2859 * This signal is used to do something when input context is focus in.
2861 * The prototype of the slot is:
2862 * void focus_in (const HelperAgent *agent, int ic, const String &ic_uuid);
2865 HelperAgent::signal_connect_focus_in (HelperAgentSlotVoid *slot)
2867 return m_impl->signal_focus_in.connect (slot);
2871 * @brief Connect a slot to Helper show signal.
2873 * This signal is used to show Helper ISE window.
2875 * The prototype of the slot is:
2876 * void ise_show (const HelperAgent *agent, int ic, char *buf, size_t &len);
2879 HelperAgent::signal_connect_ise_show (HelperAgentSlotIntRawVoid *slot)
2881 return m_impl->signal_ise_show.connect (slot);
2885 * @brief Connect a slot to Helper hide signal.
2887 * This signal is used to hide Helper ISE window.
2889 * The prototype of the slot is:
2890 * void ise_hide (const HelperAgent *agent, int ic, const String &ic_uuid);
2893 HelperAgent::signal_connect_ise_hide (HelperAgentSlotVoid *slot)
2895 return m_impl->signal_ise_hide.connect (slot);
2899 * @brief Connect a slot to Helper get ISE window geometry signal.
2901 * This signal is used to get Helper ISE window size and position.
2903 * The prototype of the slot is:
2904 * void get_geometry (const HelperAgent *agent, struct rectinfo &info);
2907 HelperAgent::signal_connect_get_geometry (HelperAgentSlotSize *slot)
2909 return m_impl->signal_get_geometry.connect (slot);
2913 * @brief Connect a slot to Helper set mode signal.
2915 * This signal is used to set Helper ISE mode.
2917 * The prototype of the slot is:
2918 * void set_mode (const HelperAgent *agent, uint32 &mode);
2921 HelperAgent::signal_connect_set_mode (HelperAgentSlotUintVoid *slot)
2923 return m_impl->signal_set_mode.connect (slot);
2927 * @brief Connect a slot to Helper set language signal.
2929 * This signal is used to set Helper ISE language.
2931 * The prototype of the slot is:
2932 * void set_language (const HelperAgent *agent, uint32 &language);
2935 HelperAgent::signal_connect_set_language (HelperAgentSlotUintVoid *slot)
2937 return m_impl->signal_set_language.connect (slot);
2941 * @brief Connect a slot to Helper set im data signal.
2943 * This signal is used to send im data to Helper ISE.
2945 * The prototype of the slot is:
2946 * void set_imdata (const HelperAgent *agent, char *buf, size_t &len);
2949 HelperAgent::signal_connect_set_imdata (HelperAgentSlotRawVoid *slot)
2951 return m_impl->signal_set_imdata.connect (slot);
2955 * @brief Connect a slot to Helper get im data signal.
2957 * This signal is used to get im data from Helper ISE.
2959 * The prototype of the slot is:
2960 * void get_imdata (const HelperAgent *, char **buf, size_t &len);
2963 HelperAgent::signal_connect_get_imdata (HelperAgentSlotGetRawVoid *slot)
2965 return m_impl->signal_get_imdata.connect (slot);
2969 * @brief Connect a slot to Helper get language locale signal.
2971 * This signal is used to get language locale from Helper ISE.
2973 * The prototype of the slot is:
2974 * void get_language_locale (const HelperAgent *, int ic, char **locale);
2977 HelperAgent::signal_connect_get_language_locale (HelperAgentSlotIntGetStringVoid *slot)
2979 return m_impl->signal_get_language_locale.connect (slot);
2983 * @brief Connect a slot to Helper set return key type signal.
2985 * This signal is used to send return key type to Helper ISE.
2987 * The prototype of the slot is:
2988 * void set_return_key_type (const HelperAgent *agent, uint32 &type);
2991 HelperAgent::signal_connect_set_return_key_type (HelperAgentSlotUintVoid *slot)
2993 return m_impl->signal_set_return_key_type.connect (slot);
2997 * @brief Connect a slot to Helper get return key type signal.
2999 * This signal is used to get return key type from Helper ISE.
3001 * The prototype of the slot is:
3002 * void get_return_key_type (const HelperAgent *agent, uint32 &type);
3005 HelperAgent::signal_connect_get_return_key_type (HelperAgentSlotUintVoid *slot)
3007 return m_impl->signal_get_return_key_type.connect (slot);
3011 * @brief Connect a slot to Helper set return key disable signal.
3013 * This signal is used to send return key disable to Helper ISE.
3015 * The prototype of the slot is:
3016 * void set_return_key_disable (const HelperAgent *agent, uint32 &disabled);
3019 HelperAgent::signal_connect_set_return_key_disable (HelperAgentSlotUintVoid *slot)
3021 return m_impl->signal_set_return_key_disable.connect (slot);
3025 * @brief Connect a slot to Helper process key event signal.
3027 * This signal is used to send keyboard key event to Helper ISE.
3029 * The prototype of the slot is:
3030 * void process_key_event (const HelperAgent *agent, KeyEvent &key, uint32 &ret);
3033 HelperAgent::signal_connect_process_key_event (HelperAgentSlotKeyEventUint *slot)
3035 return m_impl->signal_process_key_event.connect (slot);
3039 * @brief Connect a slot to Helper get return key disable signal.
3041 * This signal is used to get return key disable from Helper ISE.
3043 * The prototype of the slot is:
3044 * void get_return_key_disable (const HelperAgent *agent, uint32 &disabled);
3047 HelperAgent::signal_connect_get_return_key_disable (HelperAgentSlotUintVoid *slot)
3049 return m_impl->signal_get_return_key_disable.connect (slot);
3053 * @brief Connect a slot to Helper set layout signal.
3055 * This signal is used to set Helper ISE layout.
3057 * The prototype of the slot is:
3058 * void set_layout (const HelperAgent *agent, uint32 &layout);
3061 HelperAgent::signal_connect_set_layout (HelperAgentSlotUintVoid *slot)
3063 return m_impl->signal_set_layout.connect (slot);
3067 * @brief Connect a slot to Helper get layout signal.
3069 * This signal is used to get Helper ISE layout.
3071 * The prototype of the slot is:
3072 * void get_layout (const HelperAgent *agent, uint32 &layout);
3075 HelperAgent::signal_connect_get_layout (HelperAgentSlotUintVoid *slot)
3077 return m_impl->signal_get_layout.connect (slot);
3081 * @brief Connect a slot to Helper set input mode signal.
3083 * This signal is used to set Helper ISE input mode.
3085 * The prototype of the slot is:
3086 * void set_input_mode (const HelperAgent *agent, uint32 &input_mode);
3089 HelperAgent::signal_connect_set_input_mode (HelperAgentSlotUintVoid *slot)
3091 return m_impl->signal_set_input_mode.connect (slot);
3095 * @brief Connect a slot to Helper set input hint signal.
3097 * This signal is used to set Helper ISE input hint.
3099 * The prototype of the slot is:
3100 * void set_input_hint (const HelperAgent *agent, uint32 &input_hint);
3103 HelperAgent::signal_connect_set_input_hint (HelperAgentSlotUintVoid *slot)
3105 return m_impl->signal_set_input_hint.connect (slot);
3109 * @brief Connect a slot to Helper set BiDi direction signal.
3111 * This signal is used to set Helper ISE BiDi direction.
3113 * The prototype of the slot is:
3114 * void update_bidi_direction (const HelperAgent *agent, uint32 &bidi_direction);
3117 HelperAgent::signal_connect_update_bidi_direction (HelperAgentSlotUintVoid *slot)
3119 return m_impl->signal_update_bidi_direction.connect (slot);
3123 * @brief Connect a slot to Helper set shift mode signal.
3125 * This signal is used to set Helper shift mode.
3127 * The prototype of the slot is:
3128 * void set_caps_mode (const HelperAgent *agent, uint32 &mode);
3131 HelperAgent::signal_connect_set_caps_mode (HelperAgentSlotUintVoid *slot)
3133 return m_impl->signal_set_caps_mode.connect (slot);
3137 * @brief Connect a slot to Helper reset input context signal.
3139 * This signal is used to reset Helper ISE input context.
3141 * The prototype of the slot is:
3142 * void reset_input_context (const HelperAgent *agent, int ic, const String &uuid);
3145 HelperAgent::signal_connect_reset_input_context (HelperAgentSlotVoid *slot)
3147 return m_impl->signal_reset_input_context.connect (slot);
3151 * @brief Connect a slot to Helper update candidate window geometry signal.
3153 * This signal is used to get candidate window size and position.
3155 * The prototype of the slot is:
3156 * void update_candidate_geometry (const HelperAgent *agent, int ic, const String &uuid, const rectinfo &info);
3159 HelperAgent::signal_connect_update_candidate_geometry (HelperAgentSlotRect *slot)
3161 return m_impl->signal_update_candidate_geometry.connect (slot);
3165 * @brief Connect a slot to Helper update keyboard ISE signal.
3167 * This signal is used to get current keyboard ISE name and uuid.
3169 * The prototype of the slot is:
3170 * void update_keyboard_ise (const HelperAgent *agent, int ic, const String &uuid,
3171 * const String &ise_name, const String &ise_uuid);
3174 HelperAgent::signal_connect_update_keyboard_ise (HelperAgentSlotString2 *slot)
3176 return m_impl->signal_update_keyboard_ise.connect (slot);
3180 * @brief Connect a slot to Helper update keyboard ISE list signal.
3182 * This signal is used to get uuid list of all keyboard ISEs.
3184 * The prototype of the slot is:
3185 * void update_keyboard_ise_list (const HelperAgent *agent, int ic, const String &uuid,
3186 * const std::vector<String> &ise_list);
3189 HelperAgent::signal_connect_update_keyboard_ise_list (HelperAgentSlotStringVector *slot)
3191 return m_impl->signal_update_keyboard_ise_list.connect (slot);
3195 * @brief Connect a slot to Helper candidate more window show signal.
3197 * This signal is used to do someting when candidate more window is showed.
3199 * The prototype of the slot is:
3200 * void candidate_more_window_show (const HelperAgent *agent, int ic, const String &uuid);
3203 HelperAgent::signal_connect_candidate_more_window_show (HelperAgentSlotVoid *slot)
3205 return m_impl->signal_candidate_more_window_show.connect (slot);
3209 * @brief Connect a slot to Helper candidate more window hide signal.
3211 * This signal is used to do someting when candidate more window is hidden.
3213 * The prototype of the slot is:
3214 * void candidate_more_window_hide (const HelperAgent *agent, int ic, const String &uuid);
3217 HelperAgent::signal_connect_candidate_more_window_hide (HelperAgentSlotVoid *slot)
3219 return m_impl->signal_candidate_more_window_hide.connect (slot);
3223 * @brief Connect a slot to Helper candidate show signal.
3225 * This signal is used to do candidate show.
3227 * The prototype of the slot is:
3228 * void candidate_show (const HelperAgent *agent, int ic, const String &uuid);
3231 HelperAgent::signal_connect_candidate_show (HelperAgentSlotVoid *slot)
3233 return m_impl->signal_candidate_show.connect (slot);
3237 * @brief Connect a slot to Helper candidate hide signal.
3239 * This signal is used to do candidate hide.
3241 * The prototype of the slot is:
3242 * void candidate_hide (const HelperAgent *agent, int ic, const String &uuid);
3245 HelperAgent::signal_connect_candidate_hide (HelperAgentSlotVoid *slot)
3247 return m_impl->signal_candidate_hide.connect (slot);
3251 * @brief Connect a slot to Helper update lookup table signal.
3253 * This signal is used to do someting when update lookup table.
3255 * The prototype of the slot is:
3256 * void update_lookup_table (const HelperAgent *agent, int ic, const String &uuid ,LookupTable &table);
3259 HelperAgent::signal_connect_update_lookup_table (HelperAgentSlotLookupTable *slot)
3261 return m_impl->signal_update_lookup_table.connect (slot);
3265 * @brief Connect a slot to Helper select aux signal.
3267 * This signal is used to do something when aux is selected.
3269 * The prototype of the slot is:
3270 * void select_aux (const HelperAgent *agent, int ic, const String &uuid, int index);
3273 HelperAgent::signal_connect_select_aux (HelperAgentSlotInt *slot)
3275 return m_impl->signal_select_aux.connect (slot);
3279 * @brief Connect a slot to Helper select candidate signal.
3281 * This signal is used to do something when candidate is selected.
3283 * The prototype of the slot is:
3284 * void select_candidate (const HelperAgent *agent, int ic, const String &uuid, int index);
3287 HelperAgent::signal_connect_select_candidate (HelperAgentSlotInt *slot)
3289 return m_impl->signal_select_candidate.connect (slot);
3293 * @brief Connect a slot to Helper candidate table page up signal.
3295 * This signal is used to do something when candidate table is paged up.
3297 * The prototype of the slot is:
3298 * void candidate_table_page_up (const HelperAgent *agent, int ic, const String &uuid);
3301 HelperAgent::signal_connect_candidate_table_page_up (HelperAgentSlotVoid *slot)
3303 return m_impl->signal_candidate_table_page_up.connect (slot);
3307 * @brief Connect a slot to Helper candidate table page down signal.
3309 * This signal is used to do something when candidate table is paged down.
3311 * The prototype of the slot is:
3312 * void candidate_table_page_down (const HelperAgent *agent, int ic, const String &uuid);
3315 HelperAgent::signal_connect_candidate_table_page_down (HelperAgentSlotVoid *slot)
3317 return m_impl->signal_candidate_table_page_down.connect (slot);
3321 * @brief Connect a slot to Helper update candidate table page size signal.
3323 * This signal is used to do something when candidate table page size is changed.
3325 * The prototype of the slot is:
3326 * void update_candidate_table_page_size (const HelperAgent *, int ic, const String &uuid, int page_size);
3329 HelperAgent::signal_connect_update_candidate_table_page_size (HelperAgentSlotInt *slot)
3331 return m_impl->signal_update_candidate_table_page_size.connect (slot);
3335 * @brief Connect a slot to Helper update candidate item layout signal.
3337 * The prototype of the slot is:
3338 * void update_candidate_item_layout (const HelperAgent *, const std::vector<uint32> &row_items);
3341 HelperAgent::signal_connect_update_candidate_item_layout (HelperAgentSlotUintVector *slot)
3343 return m_impl->signal_update_candidate_item_layout.connect (slot);
3347 * @brief Connect a slot to Helper select associate signal.
3349 * This signal is used to do something when associate is selected.
3351 * The prototype of the slot is:
3352 * void select_associate (const HelperAgent *agent, int ic, const String &uuid, int index);
3355 HelperAgent::signal_connect_select_associate (HelperAgentSlotInt *slot)
3357 return m_impl->signal_select_associate.connect (slot);
3361 * @brief Connect a slot to Helper associate table page up signal.
3363 * This signal is used to do something when associate table is paged up.
3365 * The prototype of the slot is:
3366 * void associate_table_page_up (const HelperAgent *agent, int ic, const String &uuid);
3369 HelperAgent::signal_connect_associate_table_page_up (HelperAgentSlotVoid *slot)
3371 return m_impl->signal_associate_table_page_up.connect (slot);
3375 * @brief Connect a slot to Helper associate table page down signal.
3377 * This signal is used to do something when associate table is paged down.
3379 * The prototype of the slot is:
3380 * void associate_table_page_down (const HelperAgent *agent, int ic, const String &uuid);
3383 HelperAgent::signal_connect_associate_table_page_down (HelperAgentSlotVoid *slot)
3385 return m_impl->signal_associate_table_page_down.connect (slot);
3389 * @brief Connect a slot to Helper update associate table page size signal.
3391 * This signal is used to do something when associate table page size is changed.
3393 * The prototype of the slot is:
3394 * void update_associate_table_page_size (const HelperAgent *, int ic, const String &uuid, int page_size);
3397 HelperAgent::signal_connect_update_associate_table_page_size (HelperAgentSlotInt *slot)
3399 return m_impl->signal_update_associate_table_page_size.connect (slot);
3403 * @brief Connect a slot to Helper turn on log signal.
3405 * This signal is used to turn on Helper ISE debug information.
3407 * The prototype of the slot is:
3408 * void turn_on_log (const HelperAgent *agent, uint32 &on);
3411 HelperAgent::signal_connect_turn_on_log (HelperAgentSlotUintVoid *slot)
3413 return m_impl->signal_turn_on_log.connect (slot);
3417 * @brief Connect a slot to Helper update displayed candidate number signal.
3419 * This signal is used to inform helper ISE displayed candidate number.
3421 * The prototype of the slot is:
3422 * void update_displayed_candidate_number (const HelperAgent *, int ic, const String &uuid, int number);
3425 HelperAgent::signal_connect_update_displayed_candidate_number (HelperAgentSlotInt *slot)
3427 return m_impl->signal_update_displayed_candidate_number.connect (slot);
3431 * @brief Connect a slot to Helper longpress candidate signal.
3433 * This signal is used to do something when candidate is longpress.
3435 * The prototype of the slot is:
3436 * void longpress_candidate (const HelperAgent *agent, int ic, const String &uuid, int index);
3439 HelperAgent::signal_connect_longpress_candidate (HelperAgentSlotInt *slot)
3441 return m_impl->signal_longpress_candidate.connect (slot);
3445 * @brief Connect a slot to Helper show option window.
3447 * This signal is used to do request the ISE to show option window.
3449 * The prototype of the slot is:
3450 * void show_option_window (const HelperAgent *agent, int ic, const String &uuid);
3453 HelperAgent::signal_connect_show_option_window (HelperAgentSlotVoid *slot)
3455 return m_impl->signal_show_option_window.connect (slot);
3459 * @brief Connect a slot to Helper resume option window.
3461 * This signal is used to do request the ISE to resume option window.
3463 * The prototype of the slot is:
3464 * void resume_option_window (const HelperAgent *agent, int ic, const String &uuid);
3467 HelperAgent::signal_connect_resume_option_window (HelperAgentSlotVoid *slot)
3469 return m_impl->signal_resume_option_window.connect (slot);
3473 * @brief Connect a slot to Helper check if the option is available.
3475 * This signal is used to check if the option (setting) is available from Helper ISE.
3477 * The prototype of the slot is:
3478 * void check_option_window (const HelperAgent *agent, uint32 &avail);
3481 HelperAgent::signal_connect_check_option_window (HelperAgentSlotUintVoid *slot)
3483 return m_impl->signal_check_option_window.connect (slot);
3487 * @brief Connect a slot to Helper process unconventional input device event signal.
3489 * This signal is used to send unconventional input device event to Helper ISE.
3491 * The prototype of the slot is:
3492 * void process_input_device_event (const HelperAgent *, uint32 &type, char *data, size_t &size, uint32 &ret);
3495 HelperAgent::signal_connect_process_input_device_event (HelperAgentSlotUintCharSizeUint *slot)
3497 return m_impl->signal_process_input_device_event.connect (slot);
3501 * @brief Connect a slot to Helper set prediction hint signal.
3503 * This signal is used to send prediction hint to Helper ISE.
3505 * The prototype of the slot is:
3506 * void set_prediction_hint (const HelperAgent *agent, char *prediction_hint);
3509 HelperAgent::signal_connect_set_prediction_hint (HelperAgentSlotStringVoid *slot)
3511 return m_impl->signal_set_prediction_hint.connect (slot);
3515 * @brief Connect a slot to Helper set mime type signal.
3517 * This signal is used to send mime type to Helper ISE.
3519 * The prototype of the slot is:
3520 * void set_mime_type (const HelperAgent *agent, char *mime_type);
3523 HelperAgent::signal_connect_set_mime_type (HelperAgentSlotStringVoid *slot)
3525 return m_impl->signal_set_mime_type.connect (slot);
3529 * @brief Connect a slot to Helper set prediction hint data signal.
3531 * This signal is used to send prediction hint data to Helper ISE.
3533 * The prototype of the slot is:
3534 * void set_prediction_hint_data (const HelperAgent *agent, char *key, char *value);
3537 HelperAgent::signal_connect_set_prediction_hint_data (HelperAgentSlotString *slot)
3539 return m_impl->signal_set_prediction_hint_data.connect (slot);
3542 } /* namespace scim */
3545 vi:ts=4:nowrap:ai:expandtab