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
52 #include <Ecore_IMF.h>
54 #include "scim_private.h"
56 #include <scim_panel_common.h>
57 #include "isf_query_utility.h"
59 #include "isf_debug.h"
60 #include "isf_message_queue.h"
61 #include "tizen_profile.h"
62 #ifdef HAVE_PKGMGR_INFO
63 #include <pkgmgr-info.h>
64 #endif // HAVE_PKGMGR_INFO
65 #include "isf_device_event.h"
70 #define LOG_TAG "SCIM_HELPER"
73 //FIXME: remove this definitions
74 #define SHIFT_MODE_OFF 0xffe1
75 #define SHIFT_MODE_ON 0xffe2
76 #define SHIFT_MODE_LOCK 0xffe6
77 #define SHIFT_MODE_ENABLE 0x9fe7
78 #define SHIFT_MODE_DISABLE 0x9fe8
82 typedef Signal3<void, const HelperAgent *, int, const String &>
83 HelperAgentSignalVoid;
85 typedef Signal4<void, const HelperAgent *, int, const String &, const String &>
86 HelperAgentSignalString;
88 typedef Signal4<void, const HelperAgent *, int, const String &, const std::vector<String> &>
89 HelperAgentSignalStringVector;
91 typedef Signal5<void, const HelperAgent *, int, const String &, const String &, const String &>
92 HelperAgentSignalString2;
94 typedef Signal4<void, const HelperAgent *, int, const String &, int>
97 typedef Signal5<void, const HelperAgent *, int, const String &, int, int>
98 HelperAgentSignalIntInt;
100 typedef Signal4<void, const HelperAgent *, int, const String &, const Transaction &>
101 HelperAgentSignalTransaction;
103 typedef Signal4<void, const HelperAgent *, int, const String &, const rectinfo &>
104 HelperAgentSignalRect;
106 typedef Signal2<void, const HelperAgent *, struct rectinfo &>
107 HelperAgentSignalSize;
109 typedef Signal2<void, const HelperAgent *, uint32 &>
110 HelperAgentSignalUintVoid;
112 typedef Signal3<void, const HelperAgent *, int, uint32 &>
113 HelperAgentSignalIntUint;
115 typedef Signal3 <void, const HelperAgent *, char *, size_t &>
116 HelperAgentSignalRawVoid;
118 typedef Signal3 <void, const HelperAgent *, char **, size_t &>
119 HelperAgentSignalGetRawVoid;
121 typedef Signal4 <void, const HelperAgent *, int, char *, size_t &>
122 HelperAgentSignalIntRawVoid;
124 typedef Signal3 <void, const HelperAgent *, int, char **>
125 HelperAgentSignalIntGetStringVoid;
127 typedef Signal2<void, const HelperAgent *, const std::vector<uint32> &>
128 HelperAgentSignalUintVector;
130 typedef Signal2<void, const HelperAgent *, LookupTable &>
131 HelperAgentSignalLookupTable;
133 typedef Signal3<void, const HelperAgent *, KeyEvent &, uint32 &>
134 HelperAgentSignalKeyEventUint;
136 typedef Signal4<void, const HelperAgent *, KeyEvent &, uint32 &, uint32>
137 HelperAgentSignalKeyEventUintUint;
139 typedef Signal5<void, const HelperAgent *, uint32 &, char *, size_t &, uint32 &>
140 HelperAgentSignalUintCharSizeUint;
142 typedef Signal2<void, const HelperAgent *, const String &>
143 HelperAgentSignalStringVoid;
145 class HelperAgent::HelperAgentImpl
149 SocketClient socket_active;
158 IMEngineInstancePointer si;
159 ConfigPointer m_config;
160 IMEngineModule engine_module;
162 char* surrounding_text;
163 char* selection_text;
165 int need_update_surrounding_text;
166 int need_update_selection_text;
169 bool hw_keyboard_mode;
170 bool need_update_entry_metadata;
172 char* finalized_text;
173 uint32 finalized_cursor_pos;
174 bool engine_loader_flag;
176 HelperAgentSignalVoid signal_exit;
177 HelperAgentSignalVoid signal_attach_input_context;
178 HelperAgentSignalVoid signal_detach_input_context;
179 HelperAgentSignalVoid signal_reload_config;
180 HelperAgentSignalInt signal_update_screen;
181 HelperAgentSignalIntInt signal_update_spot_location;
182 HelperAgentSignalInt signal_update_cursor_position;
183 HelperAgentSignalInt signal_update_surrounding_text;
184 HelperAgentSignalVoid signal_update_selection;
185 HelperAgentSignalString signal_trigger_property;
186 HelperAgentSignalTransaction signal_process_imengine_event;
187 HelperAgentSignalVoid signal_focus_out;
188 HelperAgentSignalVoid signal_focus_in;
189 HelperAgentSignalIntRawVoid signal_ise_show;
190 HelperAgentSignalVoid signal_ise_hide;
191 HelperAgentSignalVoid signal_candidate_show;
192 HelperAgentSignalVoid signal_candidate_hide;
193 HelperAgentSignalSize signal_get_geometry;
194 HelperAgentSignalUintVoid signal_set_mode;
195 HelperAgentSignalUintVoid signal_set_language;
196 HelperAgentSignalRawVoid signal_set_imdata;
197 HelperAgentSignalGetRawVoid signal_get_imdata;
198 HelperAgentSignalIntGetStringVoid signal_get_language_locale;
199 HelperAgentSignalUintVoid signal_set_return_key_type;
200 HelperAgentSignalUintVoid signal_get_return_key_type;
201 HelperAgentSignalUintVoid signal_set_return_key_disable;
202 HelperAgentSignalUintVoid signal_get_return_key_disable;
203 HelperAgentSignalUintVoid signal_set_layout;
204 HelperAgentSignalUintVoid signal_get_layout;
205 HelperAgentSignalUintVoid signal_set_caps_mode;
206 HelperAgentSignalVoid signal_reset_input_context;
207 HelperAgentSignalIntInt signal_update_candidate_ui;
208 HelperAgentSignalRect signal_update_candidate_geometry;
209 HelperAgentSignalString2 signal_update_keyboard_ise;
210 HelperAgentSignalStringVector signal_update_keyboard_ise_list;
211 HelperAgentSignalVoid signal_candidate_more_window_show;
212 HelperAgentSignalVoid signal_candidate_more_window_hide;
213 HelperAgentSignalLookupTable signal_update_lookup_table;
214 HelperAgentSignalInt signal_select_aux;
215 HelperAgentSignalInt signal_select_candidate;
216 HelperAgentSignalVoid signal_candidate_table_page_up;
217 HelperAgentSignalVoid signal_candidate_table_page_down;
218 HelperAgentSignalInt signal_update_candidate_table_page_size;
219 HelperAgentSignalUintVector signal_update_candidate_item_layout;
220 HelperAgentSignalInt signal_select_associate;
221 HelperAgentSignalVoid signal_associate_table_page_up;
222 HelperAgentSignalVoid signal_associate_table_page_down;
223 HelperAgentSignalInt signal_update_associate_table_page_size;
224 HelperAgentSignalVoid signal_reset_ise_context;
225 HelperAgentSignalUintVoid signal_turn_on_log;
226 HelperAgentSignalInt signal_update_displayed_candidate_number;
227 HelperAgentSignalInt signal_longpress_candidate;
228 HelperAgentSignalKeyEventUint signal_process_key_event;
229 HelperAgentSignalKeyEventUintUint signal_process_key_event_with_keycode;
230 HelperAgentSignalUintVoid signal_set_input_mode;
231 HelperAgentSignalUintVoid signal_set_input_hint;
232 HelperAgentSignalUintVoid signal_update_bidi_direction;
233 HelperAgentSignalVoid signal_show_option_window;
234 HelperAgentSignalVoid signal_resume_option_window;
235 HelperAgentSignalUintVoid signal_check_option_window;
236 HelperAgentSignalUintCharSizeUint signal_process_input_device_event;
237 HelperAgentSignalStringVoid signal_set_prediction_hint;
238 HelperAgentSignalStringVoid signal_set_mime_type;
239 HelperAgentSignalString signal_set_prediction_hint_data;
240 HelperAgentSignalUintVoid signal_set_optimization_hint;
241 HelperAgentSignalKeyEventUint signal_process_key_event_with_imengine;
242 HelperAgentSignalUintVoid signal_set_autocapital_type;
243 HelperAgentSignalUintVoid signal_set_prediction_allow;
246 HelperAgentImpl (HelperAgent* thiz) : magic(0), magic_active(0), timeout(-1), focused_ic ((uint32) -1), thiz (thiz),
247 surrounding_text (NULL), selection_text (NULL), cursor_pos (0),
248 need_update_surrounding_text (0), need_update_selection_text (0),
249 layout (0), ise_show_flag (false), hw_keyboard_mode (false), need_update_entry_metadata (false), ise_focus_flag (false),
250 finalized_text(NULL), finalized_cursor_pos(0), engine_loader_flag(false) {
253 ~HelperAgentImpl () {
258 if (surrounding_text != NULL)
259 free (surrounding_text);
261 if (finalized_text != NULL)
262 free(finalized_text);
264 if (selection_text != NULL)
265 free (selection_text);
267 if (engine_module.valid ()) {
268 engine_module.unload ();
272 // Implementation of slot functions
274 slot_show_preedit_string (IMEngineInstanceBase *si)
276 thiz->show_preedit_string (focused_ic, "");
280 slot_show_aux_string (IMEngineInstanceBase *si)
282 thiz->show_aux_string ();
286 slot_show_lookup_table (IMEngineInstanceBase *si)
288 thiz->show_candidate_string ();
292 slot_hide_preedit_string (IMEngineInstanceBase *si)
294 thiz->hide_preedit_string (focused_ic, "");
298 slot_hide_aux_string (IMEngineInstanceBase *si)
300 thiz->hide_aux_string ();
304 slot_hide_lookup_table (IMEngineInstanceBase *si)
306 thiz->hide_candidate_string ();
310 slot_update_preedit_caret (IMEngineInstanceBase *si, int caret)
312 thiz->update_preedit_caret (caret);
316 slot_update_preedit_string (IMEngineInstanceBase *si,
317 const WideString & str,
318 const AttributeList & attrs,
321 thiz->update_preedit_string (-1, "", str, attrs, caret);
325 slot_update_preedit_string_with_commit (IMEngineInstanceBase *si,
326 const WideString & preedit,
327 const WideString & commit,
328 const AttributeList & attrs,
331 thiz->update_preedit_string (-1, "", preedit, commit, attrs, caret);
335 slot_update_aux_string (IMEngineInstanceBase *si,
336 const WideString & str,
337 const AttributeList & attrs)
339 thiz->update_aux_string (utf8_wcstombs(str), attrs);
343 slot_commit_string (IMEngineInstanceBase *si,
344 const WideString & str)
346 thiz->commit_string (-1, "", str);
350 slot_recapture_string (IMEngineInstanceBase *si,
353 const WideString & preedit,
354 const WideString & commit,
355 const AttributeList & attrs)
357 thiz->recapture_string (-1, "", offset, len, preedit, commit, attrs);
361 slot_forward_key_event (IMEngineInstanceBase *si,
362 const KeyEvent & key)
364 thiz->forward_key_event (-1, "", key);
368 slot_update_lookup_table (IMEngineInstanceBase *si,
369 const LookupTable & table)
371 thiz->update_candidate_string (table);
375 slot_register_properties (IMEngineInstanceBase *si,
376 const PropertyList & properties)
378 thiz->register_properties (properties);
382 slot_update_property (IMEngineInstanceBase *si,
383 const Property & property)
385 thiz->update_property (property);
389 slot_beep (IMEngineInstanceBase *si)
395 slot_start_helper (IMEngineInstanceBase *si,
396 const String &helper_uuid)
398 LOGW ("deprecated function");
402 slot_stop_helper (IMEngineInstanceBase *si,
403 const String &helper_uuid)
405 LOGW ("deprecated function");
409 slot_send_helper_event (IMEngineInstanceBase *si,
410 const String &helper_uuid,
411 const Transaction &trans)
413 signal_process_imengine_event (thiz, focused_ic, helper_uuid, trans);
417 slot_get_surrounding_text (IMEngineInstanceBase *si,
424 thiz->get_surrounding_text (maxlen_before, maxlen_after, _text, cursor);
425 text = utf8_mbstowcs(_text);
430 slot_delete_surrounding_text (IMEngineInstanceBase *si,
435 thiz->delete_surrounding_text (offset, len);
440 slot_get_selection (IMEngineInstanceBase *si,
444 thiz->get_selection_text (_text);
445 text = utf8_mbstowcs (_text);
450 slot_set_selection (IMEngineInstanceBase *si,
454 thiz->set_selection (start, end);
459 slot_expand_candidate (IMEngineInstanceBase *si)
461 thiz->expand_candidate ();
465 slot_contract_candidate (IMEngineInstanceBase *si)
467 thiz->contract_candidate ();
471 slot_set_candidate_style (IMEngineInstanceBase *si, ISF_CANDIDATE_PORTRAIT_LINE_T portrait_line, ISF_CANDIDATE_MODE_T mode)
473 thiz->set_candidate_style (portrait_line, mode);
477 slot_send_private_command (IMEngineInstanceBase *si,
478 const String &command)
480 thiz->send_private_command (command);
484 slot_commit_content (IMEngineInstanceBase *si,
485 const String &content,
486 const String &description,
487 const String &mime_types)
490 thiz->commit_content (content, description, mime_types);
496 si->signal_connect_show_preedit_string (
497 slot (this, &HelperAgent::HelperAgentImpl::slot_show_preedit_string));
498 si->signal_connect_show_aux_string (
499 slot (this, &HelperAgent::HelperAgentImpl::slot_show_aux_string));
500 si->signal_connect_show_lookup_table (
501 slot (this, &HelperAgent::HelperAgentImpl::slot_show_lookup_table));
503 si->signal_connect_hide_preedit_string (
504 slot (this, &HelperAgent::HelperAgentImpl::slot_hide_preedit_string));
505 si->signal_connect_hide_aux_string (
506 slot (this, &HelperAgent::HelperAgentImpl::slot_hide_aux_string));
507 si->signal_connect_hide_lookup_table (
508 slot (this, &HelperAgent::HelperAgentImpl::slot_hide_lookup_table));
510 si->signal_connect_update_preedit_caret (
511 slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_caret));
512 si->signal_connect_update_preedit_string (
513 slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_string));
514 si->signal_connect_update_preedit_string_with_commit (
515 slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_string_with_commit));
516 si->signal_connect_recapture_string (
517 slot (this, &HelperAgent::HelperAgentImpl::slot_recapture_string));
519 si->signal_connect_update_aux_string (
520 slot (this, &HelperAgent::HelperAgentImpl::slot_update_aux_string));
521 si->signal_connect_update_lookup_table (
522 slot (this, &HelperAgent::HelperAgentImpl::slot_update_lookup_table));
524 si->signal_connect_commit_string (
525 slot (this, &HelperAgent::HelperAgentImpl::slot_commit_string));
527 si->signal_connect_forward_key_event (
528 slot (this, &HelperAgent::HelperAgentImpl::slot_forward_key_event));
530 si->signal_connect_register_properties (
531 slot (this, &HelperAgent::HelperAgentImpl::slot_register_properties));
533 si->signal_connect_update_property (
534 slot (this, &HelperAgent::HelperAgentImpl::slot_update_property));
536 si->signal_connect_beep (
537 slot (this, &HelperAgent::HelperAgentImpl::slot_beep));
539 si->signal_connect_start_helper (
540 slot (this, &HelperAgent::HelperAgentImpl::slot_start_helper));
542 si->signal_connect_stop_helper (
543 slot (this, &HelperAgent::HelperAgentImpl::slot_stop_helper));
545 si->signal_connect_send_helper_event (
546 slot (this, &HelperAgent::HelperAgentImpl::slot_send_helper_event));
548 si->signal_connect_get_surrounding_text (
549 slot (this, &HelperAgent::HelperAgentImpl::slot_get_surrounding_text));
551 si->signal_connect_delete_surrounding_text (
552 slot (this, &HelperAgent::HelperAgentImpl::slot_delete_surrounding_text));
554 si->signal_connect_get_selection (
555 slot (this, &HelperAgent::HelperAgentImpl::slot_get_selection));
557 si->signal_connect_set_selection (
558 slot (this, &HelperAgent::HelperAgentImpl::slot_set_selection));
560 si->signal_connect_expand_candidate (
561 slot (this, &HelperAgent::HelperAgentImpl::slot_expand_candidate));
562 si->signal_connect_contract_candidate (
563 slot (this, &HelperAgent::HelperAgentImpl::slot_contract_candidate));
565 si->signal_connect_set_candidate_style (
566 slot (this, &HelperAgent::HelperAgentImpl::slot_set_candidate_style));
568 si->signal_connect_send_private_command (
569 slot (this, &HelperAgent::HelperAgentImpl::slot_send_private_command));
572 void process_key_event_done (KeyEvent &key, uint32 ret, uint32 serial) {
573 LOGD ("ret: %d, serial: %d", ret, serial);
574 if (socket_active.is_connected ()) {
576 send.put_command (SCIM_TRANS_CMD_REQUEST);
577 send.put_data (magic_active);
578 send.put_command (ISM_TRANS_CMD_PROCESS_KEY_EVENT_DONE);
581 send.put_data (serial);
582 send.write_to_socket (socket_active, magic_active);
586 void request_ise_hide () {
587 if (socket_active.is_connected ()) {
589 send.put_command (SCIM_TRANS_CMD_REQUEST);
590 send.put_data (magic_active);
591 send.put_command (ISM_TRANS_CMD_REQUEST_ISE_HIDE);
592 send.write_to_socket (socket_active, magic_active);
596 HelperAgentImpl () : magic (0), magic_active (0), timeout (-1), focused_ic ((uint32) -1), thiz (NULL), surrounding_text (NULL), selection_text (NULL), cursor_pos (0), need_update_surrounding_text (0), need_update_selection_text (0), layout (0), ise_show_flag (false), hw_keyboard_mode (false), need_update_entry_metadata (false), ise_focus_flag (false), finalized_text (NULL), finalized_cursor_pos (0), engine_loader_flag (false) { }
599 static MessageQueue message_queue;
601 HelperAgent::HelperAgent ()
602 : m_impl (new HelperAgentImpl (this))
604 message_queue.create();
607 HelperAgent::~HelperAgent ()
609 message_queue.destroy();
614 * @brief Open socket connection to the Panel.
616 * @param info The information of this Helper object.
617 * @param display The display which this Helper object should run on.
619 * @return The connection socket id. -1 means failed to create
623 HelperAgent::open_connection (const HelperInfo &info,
624 const String &display)
626 if (m_impl->socket.is_connected ())
629 SocketAddress address (scim_get_default_panel_socket_address (display));
630 int timeout = m_impl->timeout = scim_get_default_socket_timeout ();
633 if (!address.valid ())
637 std::cerr << " Connecting to PanelAgent server.";
638 ISF_LOG (" Connecting to PanelAgent server.\n");
639 while (!m_impl->socket.connect (address)) {
641 scim_usleep (100000);
643 std::cerr << "m_impl->socket.connect () is failed!!!\n";
644 ISF_LOG ("m_impl->socket.connect () is failed!!!\n");
648 std::cerr << " Connected :" << i << "\n";
649 ISF_LOG (" Connected :%d\n", i);
650 LOGD ("Connection to PanelAgent succeeded, %d", i);
652 /* Let's retry 10 times when failed */
653 int open_connection_retries = 0;
654 while (!scim_socket_open_connection (magic,
659 if (++open_connection_retries > 10) {
660 m_impl->socket.close ();
661 std::cerr << "scim_socket_open_connection () is failed!!!\n";
662 ISF_LOG ("scim_socket_open_connection () is failed!!!\n");
663 ISF_SAVE_LOG ("scim_socket_open_connection failed, %d", timeout);
668 /* Retry after re-connecting the socket */
669 if (m_impl->socket.is_connected ())
672 /* This time, just retry atmost 2 seconds */
674 while (!m_impl->socket.connect (address) && ++i < 10) {
675 scim_usleep (200000);
679 ISF_LOG ("scim_socket_open_connection () is successful.\n");
680 LOGD ("scim_socket_open_connection successful");
682 m_impl->send.clear ();
683 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
684 m_impl->send.put_data (magic);
685 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_REGISTER_HELPER);
686 m_impl->send.put_data (info.uuid);
687 m_impl->send.put_data (info.name);
688 m_impl->send.put_data (info.icon);
689 m_impl->send.put_data (info.description);
690 m_impl->send.put_data (info.option);
692 if (!m_impl->send.write_to_socket (m_impl->socket, magic)) {
693 m_impl->socket.close ();
698 if (m_impl->recv.read_from_socket (m_impl->socket, timeout) &&
699 m_impl->recv.get_command (cmd) && cmd == SCIM_TRANS_CMD_REPLY &&
700 m_impl->recv.get_command (cmd) && cmd == SCIM_TRANS_CMD_OK) {
701 m_impl->magic = magic;
703 while (m_impl->recv.get_command (cmd)) {
705 case SCIM_TRANS_CMD_HELPER_ATTACH_INPUT_CONTEXT:
709 while (m_impl->recv.get_data (ic) && m_impl->recv.get_data (ic_uuid))
710 m_impl->signal_attach_input_context (this, ic, ic_uuid);
713 case SCIM_TRANS_CMD_UPDATE_SCREEN:
716 if (m_impl->recv.get_data (screen))
717 m_impl->signal_update_screen (this, (uint32) -1, String (""), (int) screen);
725 //FIXME: Attaching input context is needed for desktop environment
726 LOGW ("Attach input context and update screen failed");
729 ISF_SAVE_LOG ("Trying connect() with Helper_Active");
731 /* connect to the panel agent as the active helper client */
732 if (!m_impl->socket_active.connect (address)) return -1;
733 open_connection_retries = 0;
734 while (!scim_socket_open_connection (magic,
735 String ("Helper_Active"),
737 m_impl->socket_active,
739 if (++open_connection_retries > 10) {
740 m_impl->socket_active.close ();
741 std::cerr << "Helper_Active scim_socket_open_connection () is failed!!!\n";
742 ISF_LOG ("Helper_Active scim_socket_open_connection () is failed!!!\n");
743 ISF_SAVE_LOG ("Helper_Active scim_socket_open_connection failed, %d", timeout);
748 /* Retry after re-connecting the socket */
749 if (m_impl->socket_active.is_connected ())
750 m_impl->socket_active.close ();
752 /* This time, just retry atmost 2 seconds */
754 while (!m_impl->socket_active.connect (address) && ++i < 10) {
755 scim_usleep (200000);
759 m_impl->magic_active = magic;
761 m_impl->send.clear ();
762 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
763 m_impl->send.put_data (magic);
764 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_REGISTER_ACTIVE_HELPER);
765 m_impl->send.put_data (info.uuid);
766 m_impl->send.put_data (info.name);
767 m_impl->send.put_data (info.icon);
768 m_impl->send.put_data (info.description);
769 m_impl->send.put_data (info.option);
771 if (!m_impl->send.write_to_socket (m_impl->socket_active, magic)) {
772 ISF_SAVE_LOG ("Helper_Active write_to_socket() failed");
773 m_impl->socket_active.close ();
776 m_impl->m_config = ConfigBase::get (false, "socket");
778 return m_impl->socket.get_id ();
782 * @brief Close the socket connection to Panel.
785 HelperAgent::close_connection ()
787 m_impl->socket.close ();
788 m_impl->socket_active.close ();
789 m_impl->send.clear ();
790 m_impl->recv.clear ();
792 m_impl->magic_active = 0;
797 * @brief Get the connection id previously returned by open_connection().
799 * @return the connection id
802 HelperAgent::get_connection_number () const
804 if (m_impl->socket.is_connected ())
805 return m_impl->socket.get_id ();
810 * @brief Check whether this HelperAgent has been connected to a Panel.
812 * Return true when it is connected to panel, otherwise return false.
815 HelperAgent::is_connected () const
817 return m_impl->socket.is_connected ();
821 * @brief Check if there are any events available to be processed.
823 * If it returns true then Helper object should call
824 * HelperAgent::filter_event() to process them.
826 * @return true if there are any events available.
829 HelperAgent::has_pending_event () const
831 if (m_impl->socket.is_connected () && m_impl->socket.wait_for_data (0) > 0)
834 if (message_queue.has_pending_message())
841 * @brief Process the pending events.
843 * This function will emit the corresponding signals according
846 * @return false if the connection is broken, otherwise return true.
849 HelperAgent::filter_event ()
851 if (!m_impl->socket.is_connected ()) {
852 LOGW("Connection lost, returning false");
856 if (m_impl->recv.read_from_socket (m_impl->socket, m_impl->timeout)) {
857 message_queue.read_from_transaction(m_impl->recv);
859 while (message_queue.has_pending_message()) {
860 MessageItem *message = message_queue.get_pending_message();
861 handle_message(message);
862 message_queue.remove_message(message);
865 LOGD("read_from_socket() failed but continuing");
873 * @brief Read messages from socket buffer, and see if there is a message with the given cmd.
875 * @return false if the connection is broken, or no message available with given cmd. Otherwise return true.
878 HelperAgent::wait_for_message(int cmd, int timeout)
880 struct timeval t0 = { 0, 0 };
881 struct timeval t1 = { 0, 0 };
882 struct timeval t2 = { 0, 0 };
884 gettimeofday(&t0, NULL);
887 if (!m_impl->socket.is_connected() || !m_impl->recv.read_from_socket(m_impl->socket, timeout))
890 message_queue.read_from_transaction(m_impl->recv);
891 if (message_queue.has_pending_message_by_cmd(cmd)) {
895 gettimeofday(&t1, NULL);
896 timersub(&t1, &t0, &t2);
897 } while (t2.tv_sec < timeout);
903 * @brief Process one message that is in our message queue.
905 * This function will emit the corresponding signals according
908 * @param message The message that needs to be handled.
910 * @return false if the connection is broken, otherwise return true.
913 HelperAgent::handle_message (MessageItem *message)
918 int cmd = message->get_command_ref();
919 LOGD ("HelperAgent::cmd = %d", cmd);
921 case SCIM_TRANS_CMD_EXIT:
923 MessageItemExit *subclass = static_cast<MessageItemExit*>(message);
924 ISF_SAVE_LOG ("Helper ISE received SCIM_TRANS_CMD_EXIT message");
925 m_impl->signal_exit(this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
928 case SCIM_TRANS_CMD_RELOAD_CONFIG:
930 MessageItemReloadConfig *subclass = static_cast<MessageItemReloadConfig*>(message);
931 m_impl->signal_reload_config (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
932 if (!m_impl->m_config.null())
933 m_impl->m_config->ConfigBase::reload();
936 case SCIM_TRANS_CMD_UPDATE_SCREEN:
938 MessageItemUpdateScreen *subclass = static_cast<MessageItemUpdateScreen*>(message);
939 m_impl->signal_update_screen (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
940 subclass->get_screen_ref());
943 case SCIM_TRANS_CMD_UPDATE_SPOT_LOCATION:
945 MessageItemUpdateSpotLocation *subclass = static_cast<MessageItemUpdateSpotLocation*>(message);
946 m_impl->signal_update_spot_location (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
947 subclass->get_x_ref(), subclass->get_y_ref());
950 case ISM_TRANS_CMD_UPDATE_CURSOR_POSITION:
952 MessageItemUpdateCursorPosition *subclass = static_cast<MessageItemUpdateCursorPosition*>(message);
953 m_impl->cursor_pos = subclass->get_cursor_pos_ref();
954 LOGD ("update cursor position %d", subclass->get_cursor_pos_ref());
955 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode || m_impl->need_update_entry_metadata) {
956 m_impl->signal_update_cursor_position (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
957 subclass->get_cursor_pos_ref());
959 if (!m_impl->si.null ()) m_impl->si->update_cursor_position(subclass->get_cursor_pos_ref());
962 case ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT:
964 MessageItemUpdateSurroundingText *subclass = static_cast<MessageItemUpdateSurroundingText*>(message);
965 if (m_impl->surrounding_text != NULL)
966 free (m_impl->surrounding_text);
967 m_impl->surrounding_text = strdup (subclass->get_text_ref().c_str ());
968 m_impl->cursor_pos = subclass->get_cursor_ref();
969 SECURE_LOGD ("surrounding text: %s, %d", m_impl->surrounding_text, subclass->get_cursor_ref());
970 while (m_impl->need_update_surrounding_text > 0) {
971 m_impl->need_update_surrounding_text--;
972 m_impl->signal_update_surrounding_text (this, subclass->get_ic_ref(),
973 subclass->get_text_ref(), subclass->get_cursor_ref());
977 case ISM_TRANS_CMD_UPDATE_SELECTION:
979 MessageItemUpdateSelection *subclass = static_cast<MessageItemUpdateSelection*>(message);
980 if (m_impl->selection_text != NULL)
981 free (m_impl->selection_text);
983 m_impl->selection_text = strdup (subclass->get_text_ref().c_str ());
984 SECURE_LOGD ("selection text: %s", m_impl->selection_text);
986 while (m_impl->need_update_selection_text > 0) {
987 m_impl->need_update_selection_text--;
988 m_impl->signal_update_selection (this, subclass->get_ic_ref(), subclass->get_text_ref());
992 case SCIM_TRANS_CMD_TRIGGER_PROPERTY:
994 MessageItemTriggerProperty *subclass = static_cast<MessageItemTriggerProperty*>(message);
995 m_impl->signal_trigger_property (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
996 subclass->get_property_ref());
997 if (!m_impl->si.null ()) m_impl->si->trigger_property(subclass->get_property_ref());
1000 case SCIM_TRANS_CMD_HELPER_PROCESS_IMENGINE_EVENT:
1002 MessageItemHelperProcessImengineEvent *subclass = static_cast<MessageItemHelperProcessImengineEvent*>(message);
1003 m_impl->signal_process_imengine_event (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1004 subclass->get_transaction_ref());
1007 case SCIM_TRANS_CMD_HELPER_ATTACH_INPUT_CONTEXT:
1009 MessageItemHelperAttachInputContext *subclass = static_cast<MessageItemHelperAttachInputContext*>(message);
1010 m_impl->signal_attach_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1013 case SCIM_TRANS_CMD_HELPER_DETACH_INPUT_CONTEXT:
1015 MessageItemHelperDetachInputContext *subclass = static_cast<MessageItemHelperDetachInputContext*>(message);
1016 m_impl->signal_detach_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1019 case SCIM_TRANS_CMD_FOCUS_OUT:
1021 MessageItemFocusOut *subclass = static_cast<MessageItemFocusOut*>(message);
1022 m_impl->ise_focus_flag = false;
1023 m_impl->signal_focus_out (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1024 m_impl->focused_ic = (uint32) -1;
1025 if (!m_impl->si.null ()) m_impl->si->focus_out();
1027 m_impl->ise_show_flag = false;
1028 m_impl->need_update_entry_metadata = false;
1031 case SCIM_TRANS_CMD_FOCUS_IN:
1033 MessageItemFocusIn *subclass = static_cast<MessageItemFocusIn*>(message);
1034 m_impl->ise_focus_flag = true;
1036 m_impl->need_update_entry_metadata = false;
1037 m_impl->signal_focus_in (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1038 m_impl->focused_ic = subclass->get_ic_ref();
1039 if (m_impl->finalized_text != NULL)
1040 free(m_impl->finalized_text);
1041 m_impl->finalized_text = NULL;
1042 m_impl->finalized_cursor_pos = 0;
1043 if (!m_impl->si.null ()) m_impl->si->focus_in();
1046 case ISM_TRANS_CMD_SHOW_ISE_PANEL:
1048 MessageItemShowISEPanel *subclass = static_cast<MessageItemShowISEPanel*>(message);
1049 LOGD ("Helper ISE received ISM_TRANS_CMD_SHOW_ISE_PANEL message");
1051 m_impl->signal_ise_show (this, subclass->get_ic_ref(), *(subclass->get_data_ptr()),
1052 subclass->get_len_ref());
1053 m_impl->ise_show_flag = true;
1056 case ISM_TRANS_CMD_HIDE_ISE_PANEL:
1058 MessageItemHideISEPanel *subclass = static_cast<MessageItemHideISEPanel*>(message);
1059 LOGD ("Helper ISE received ISM_TRANS_CMD_HIDE_ISE_PANEL message");
1060 if (m_impl->ise_show_flag)
1061 m_impl->signal_ise_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1062 m_impl->ise_show_flag = false;
1065 case ISM_TRANS_CMD_GET_ACTIVE_ISE_GEOMETRY:
1067 struct rectinfo info = {0, 0, 0, 0};
1068 m_impl->signal_get_geometry (this, info);
1069 m_impl->send.clear ();
1070 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1071 m_impl->send.put_data (info.pos_x);
1072 m_impl->send.put_data (info.pos_y);
1073 m_impl->send.put_data (info.width);
1074 m_impl->send.put_data (info.height);
1075 m_impl->send.write_to_socket (m_impl->socket);
1078 case ISM_TRANS_CMD_SET_ISE_MODE:
1080 MessageItemSetISEMode *subclass = static_cast<MessageItemSetISEMode*>(message);
1081 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode || m_impl->need_update_entry_metadata) {
1082 m_impl->signal_set_mode (this, subclass->get_mode_ref());
1086 case ISM_TRANS_CMD_SET_ISE_LANGUAGE:
1088 MessageItemSetISELanguage *subclass = static_cast<MessageItemSetISELanguage*>(message);
1089 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode || m_impl->need_update_entry_metadata) {
1090 m_impl->signal_set_language (this, subclass->get_language_ref());
1094 case ISM_TRANS_CMD_SET_ISE_IMDATA:
1096 MessageItemSetISEImData *subclass = static_cast<MessageItemSetISEImData*>(message);
1097 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode) {
1098 m_impl->signal_set_imdata (this, *(subclass->get_imdata_ptr()), subclass->get_len_ref());
1100 if (!m_impl->si.null ()) m_impl->si->set_imdata(*(subclass->get_imdata_ptr()),
1101 subclass->get_len_ref());
1104 case ISM_TRANS_CMD_GET_ISE_IMDATA:
1109 m_impl->signal_get_imdata (this, &buf, len);
1110 LOGD ("send ise imdata len = %zu", len);
1111 m_impl->send.clear ();
1112 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1113 m_impl->send.put_data (buf, len);
1114 m_impl->send.write_to_socket (m_impl->socket);
1119 case ISM_TRANS_CMD_GET_ISE_LANGUAGE_LOCALE:
1121 MessageItemGetISELanguageLocale *subclass = static_cast<MessageItemGetISELanguageLocale*>(message);
1123 m_impl->signal_get_language_locale (this, subclass->get_ic_ref(), &buf);
1124 m_impl->send.clear ();
1125 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1127 m_impl->send.put_data (buf, strlen (buf));
1128 m_impl->send.write_to_socket (m_impl->socket);
1133 case ISM_TRANS_CMD_SET_RETURN_KEY_TYPE:
1135 MessageItemSetReturnKeyType *subclass = static_cast<MessageItemSetReturnKeyType*>(message);
1136 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode || m_impl->need_update_entry_metadata) {
1137 m_impl->signal_set_return_key_type (this, subclass->get_type_ref());
1141 case ISM_TRANS_CMD_GET_RETURN_KEY_TYPE:
1144 m_impl->signal_get_return_key_type (this, type);
1145 m_impl->send.clear ();
1146 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1147 m_impl->send.put_data (type);
1148 m_impl->send.write_to_socket (m_impl->socket);
1151 case ISM_TRANS_CMD_SET_RETURN_KEY_DISABLE:
1153 MessageItemSetReturnKeyDisable *subclass = static_cast<MessageItemSetReturnKeyDisable*>(message);
1154 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode || m_impl->need_update_entry_metadata) {
1155 m_impl->signal_set_return_key_disable (this, subclass->get_disabled_ref());
1159 case ISM_TRANS_CMD_GET_RETURN_KEY_DISABLE:
1161 uint32 disabled = 0;
1162 m_impl->signal_get_return_key_type (this, disabled);
1163 m_impl->send.clear ();
1164 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1165 m_impl->send.put_data (disabled);
1166 m_impl->send.write_to_socket (m_impl->socket);
1169 case SCIM_TRANS_CMD_PROCESS_KEY_EVENT:
1171 MessageItemProcessKeyEvent *subclass = static_cast<MessageItemProcessKeyEvent*>(message);
1173 uint32 keycode_ret = 0;
1174 m_impl->signal_process_key_event(this, subclass->get_key_ref(), ret);
1175 m_impl->signal_process_key_event_with_keycode(this, subclass->get_key_ref(), keycode_ret, subclass->get_keycode_ref());
1176 if (ret == 0 && keycode_ret == 0) {
1177 if (!(subclass->get_key_ref().get_key_string().compare("KeyRelease+XF86Back") == 0 ||
1178 subclass->get_key_ref().get_key_string().compare("XF86Back") == 0)) {
1179 if (m_impl->engine_loader_flag) {
1180 m_impl->signal_process_key_event_with_imengine(this, subclass->get_key_ref(), ret);
1181 SECURE_LOGD ("imengine process key %d return %d", subclass->get_key_ref().code, ret);
1183 if (!m_impl->si.null ()) {
1184 ret = m_impl->si->process_key_event (subclass->get_key_ref());
1185 SECURE_LOGD ("imengine(%s) process key %d return %d", m_impl->si->get_factory_uuid().c_str(),
1186 subclass->get_key_ref().code, ret);
1191 if (ret != keycode_ret)
1193 m_impl->process_key_event_done (subclass->get_key_ref(), ret, subclass->get_serial_ref());
1196 case ISM_TRANS_CMD_SET_LAYOUT:
1198 MessageItemSetLayout *subclass = static_cast<MessageItemSetLayout*>(message);
1199 m_impl->layout = subclass->get_layout_ref();
1200 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode || m_impl->need_update_entry_metadata) {
1201 m_impl->signal_set_layout (this, subclass->get_layout_ref());
1203 if (!m_impl->si.null ()) m_impl->si->set_layout(subclass->get_layout_ref());
1206 case ISM_TRANS_CMD_GET_LAYOUT:
1210 m_impl->signal_get_layout (this, layout);
1211 m_impl->send.clear ();
1212 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1213 m_impl->send.put_data (layout);
1214 m_impl->send.write_to_socket (m_impl->socket);
1217 case ISM_TRANS_CMD_SET_INPUT_MODE:
1219 MessageItemSetInputMode *subclass = static_cast<MessageItemSetInputMode*>(message);
1220 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode || m_impl->need_update_entry_metadata) {
1221 m_impl->signal_set_input_mode (this, subclass->get_input_mode_ref());
1225 case ISM_TRANS_CMD_SET_CAPS_MODE:
1227 MessageItemSetCapsMode *subclass = static_cast<MessageItemSetCapsMode*>(message);
1228 m_impl->signal_set_caps_mode (this, subclass->get_mode_ref());
1231 case SCIM_TRANS_CMD_PANEL_RESET_INPUT_CONTEXT:
1233 MessageItemPanelResetInputContext *subclass = static_cast<MessageItemPanelResetInputContext*>(message);
1234 m_impl->signal_reset_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1235 if (!m_impl->si.null ()) m_impl->si->reset();
1238 case ISM_TRANS_CMD_UPDATE_CANDIDATE_UI:
1240 MessageItemUpdateCandidateUI *subclass = static_cast<MessageItemUpdateCandidateUI*>(message);
1241 m_impl->signal_update_candidate_ui (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1242 subclass->get_style_ref(), subclass->get_mode_ref());
1245 case ISM_TRANS_CMD_UPDATE_CANDIDATE_GEOMETRY:
1247 MessageItemUpdateCandidateGeometry *subclass = static_cast<MessageItemUpdateCandidateGeometry*>(message);
1248 m_impl->signal_update_candidate_geometry (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1249 subclass->get_rectinfo_ref());
1252 case ISM_TRANS_CMD_UPDATE_KEYBOARD_ISE:
1254 MessageItemUpdateKeyboardISE *subclass = static_cast<MessageItemUpdateKeyboardISE*>(message);
1255 m_impl->signal_update_keyboard_ise (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1256 subclass->get_name_ref(), subclass->get_uuid_ref());
1259 case ISM_TRANS_CMD_UPDATE_KEYBOARD_ISE_LIST:
1261 MessageItemUpdateKeyboardISEList *subclass = static_cast<MessageItemUpdateKeyboardISEList*>(message);
1262 m_impl->signal_update_keyboard_ise_list (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1263 subclass->get_list_ref());
1266 case ISM_TRANS_CMD_CANDIDATE_MORE_WINDOW_SHOW:
1268 MessageItemCandidateMoreWindowShow *subclass = static_cast<MessageItemCandidateMoreWindowShow*>(message);
1269 m_impl->signal_candidate_more_window_show (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1270 if (!m_impl->si.null ()) m_impl->si->candidate_more_window_show();
1273 case ISM_TRANS_CMD_CANDIDATE_MORE_WINDOW_HIDE:
1275 MessageItemCandidateMoreWindowHide *subclass = static_cast<MessageItemCandidateMoreWindowHide*>(message);
1276 m_impl->signal_candidate_more_window_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1277 if (!m_impl->si.null ()) m_impl->si->candidate_more_window_hide();
1280 case ISM_TRANS_CMD_SELECT_AUX:
1282 MessageItemSelectAux *subclass = static_cast<MessageItemSelectAux*>(message);
1283 m_impl->signal_select_aux (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1284 subclass->get_item_ref());
1285 if (!m_impl->si.null ()) m_impl->si->select_aux(subclass->get_item_ref());
1288 case SCIM_TRANS_CMD_SELECT_CANDIDATE: //FIXME:remove if useless
1290 MessageItemSelectCandidate *subclass = static_cast<MessageItemSelectCandidate*>(message);
1291 m_impl->signal_select_candidate (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1292 subclass->get_item_ref());
1293 if (!m_impl->si.null ()) m_impl->si->select_candidate(subclass->get_item_ref());
1296 case SCIM_TRANS_CMD_LOOKUP_TABLE_PAGE_UP: //FIXME:remove if useless
1298 MessageItemLookupTablePageUp *subclass = static_cast<MessageItemLookupTablePageUp*>(message);
1299 m_impl->signal_candidate_table_page_up (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1300 if (!m_impl->si.null ()) m_impl->si->lookup_table_page_up();
1303 case SCIM_TRANS_CMD_LOOKUP_TABLE_PAGE_DOWN: //FIXME:remove if useless
1305 MessageItemLookupTablePageDown *subclass = static_cast<MessageItemLookupTablePageDown*>(message);
1306 m_impl->signal_candidate_table_page_down (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1307 if (!m_impl->si.null ()) m_impl->si->lookup_table_page_down();
1310 case SCIM_TRANS_CMD_UPDATE_LOOKUP_TABLE_PAGE_SIZE:
1312 MessageItemUpdateLookupTablePageSize *subclass = static_cast<MessageItemUpdateLookupTablePageSize*>(message);
1313 m_impl->signal_update_candidate_table_page_size (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1314 subclass->get_size_ref());
1315 if (!m_impl->si.null ()) m_impl->si->update_lookup_table_page_size(subclass->get_size_ref());
1318 case ISM_TRANS_CMD_CANDIDATE_SHOW: //FIXME:remove if useless
1320 MessageItemCandidateShow *subclass = static_cast<MessageItemCandidateShow*>(message);
1321 m_impl->signal_candidate_show (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1324 case ISM_TRANS_CMD_CANDIDATE_HIDE: //FIXME:remove if useless
1326 MessageItemCandidateHide *subclass = static_cast<MessageItemCandidateHide*>(message);
1327 m_impl->signal_candidate_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1330 case ISM_TRANS_CMD_UPDATE_LOOKUP_TABLE: //FIXME:remove if useless
1332 MessageItemUpdateLookupTable *subclass = static_cast<MessageItemUpdateLookupTable*>(message);
1333 m_impl->signal_update_lookup_table (this, subclass->get_candidate_table_ref());
1336 case ISM_TRANS_CMD_UPDATE_CANDIDATE_ITEM_LAYOUT:
1338 MessageItemUpdateCandidateItemLayout *subclass = static_cast<MessageItemUpdateCandidateItemLayout*>(message);
1339 m_impl->signal_update_candidate_item_layout (this, subclass->get_row_items_ref());
1340 if (!m_impl->si.null ()) m_impl->si->update_candidate_item_layout(subclass->get_row_items_ref());
1343 case ISM_TRANS_CMD_SELECT_ASSOCIATE:
1345 MessageItemSelectAssociate *subclass = static_cast<MessageItemSelectAssociate*>(message);
1346 m_impl->signal_select_associate (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1347 subclass->get_item_ref());
1350 case ISM_TRANS_CMD_ASSOCIATE_TABLE_PAGE_UP:
1352 MessageItemAssociateTablePageUp *subclass = static_cast<MessageItemAssociateTablePageUp*>(message);
1353 m_impl->signal_associate_table_page_up (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1356 case ISM_TRANS_CMD_ASSOCIATE_TABLE_PAGE_DOWN:
1358 MessageItemAssociateTablePageDown *subclass = static_cast<MessageItemAssociateTablePageDown*>(message);
1359 m_impl->signal_associate_table_page_down (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1362 case ISM_TRANS_CMD_UPDATE_ASSOCIATE_TABLE_PAGE_SIZE:
1364 MessageItemUpdateAssociateTablePageSize *subclass = static_cast<MessageItemUpdateAssociateTablePageSize*>(message);
1365 m_impl->signal_update_associate_table_page_size (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1366 subclass->get_size_ref());
1369 case ISM_TRANS_CMD_RESET_ISE_CONTEXT:
1371 MessageItemResetISEContext *subclass = static_cast<MessageItemResetISEContext*>(message);
1372 m_impl->signal_reset_ise_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1373 m_impl->signal_reset_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1374 if (!m_impl->si.null ()) m_impl->si->reset();
1377 case ISM_TRANS_CMD_TURN_ON_LOG:
1379 MessageItemTurnOnLog *subclass = static_cast<MessageItemTurnOnLog*>(message);
1380 m_impl->signal_turn_on_log (this, subclass->get_state_ref());
1383 case ISM_TRANS_CMD_UPDATE_DISPLAYED_CANDIDATE:
1385 MessageItemUpdateDisplayedCandidate *subclass = static_cast<MessageItemUpdateDisplayedCandidate*>(message);
1386 m_impl->signal_update_displayed_candidate_number (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1387 subclass->get_size_ref());
1388 if (!m_impl->si.null ()) m_impl->si->update_displayed_candidate_number(subclass->get_size_ref());
1391 case ISM_TRANS_CMD_LONGPRESS_CANDIDATE:
1393 MessageItemLongpressCandidate *subclass = static_cast<MessageItemLongpressCandidate*>(message);
1394 m_impl->signal_longpress_candidate (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1395 subclass->get_index_ref());
1396 if (!m_impl->si.null ()) m_impl->si->longpress_candidate(subclass->get_index_ref());
1399 case ISM_TRANS_CMD_SET_INPUT_HINT:
1401 MessageItemSetInputHint *subclass = static_cast<MessageItemSetInputHint*>(message);
1402 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode || m_impl->need_update_entry_metadata) {
1403 m_impl->signal_set_input_hint (this, subclass->get_input_hint_ref());
1405 if (!m_impl->si.null ()) m_impl->si->set_input_hint(subclass->get_input_hint_ref());
1408 case ISM_TRANS_CMD_UPDATE_BIDI_DIRECTION:
1410 MessageItemUpdateBidiDirection *subclass = static_cast<MessageItemUpdateBidiDirection*>(message);
1411 m_impl->signal_update_bidi_direction (this, subclass->get_bidi_direction());
1412 if (!m_impl->si.null ()) m_impl->si->update_bidi_direction(subclass->get_bidi_direction());
1415 case ISM_TRANS_CMD_SHOW_ISE_OPTION_WINDOW:
1417 MessageItemShowISEOptionWindow *subclass = static_cast<MessageItemShowISEOptionWindow*>(message);
1418 m_impl->signal_show_option_window (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1421 case ISM_TRANS_CMD_RESUME_ISE_OPTION_WINDOW:
1423 MessageItemResumeISEOptionWindow *subclass = static_cast<MessageItemResumeISEOptionWindow*>(message);
1424 m_impl->signal_resume_option_window (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1427 case ISM_TRANS_CMD_CHECK_OPTION_WINDOW:
1430 m_impl->signal_check_option_window (this, avail);
1431 m_impl->send.clear ();
1432 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1433 m_impl->send.put_data (avail);
1434 m_impl->send.write_to_socket (m_impl->socket);
1437 case ISM_TRANS_CMD_PROCESS_INPUT_DEVICE_EVENT:
1439 MessageItemProcessInputDeviceEvent *subclass = static_cast<MessageItemProcessInputDeviceEvent*>(message);
1441 unsigned int ecore_event_id = find_ecore_event_from_device_type((isf_device_type_e)(subclass->get_type_ref()));
1442 char *decoded = (char*)malloc(subclass->get_len_ref());
1443 size_t decoded_size = subclass->get_len_ref();
1445 if(device_buffer_decode((const char*)*(subclass->get_data_ptr()),
1446 subclass->get_len_ref(), (char*)(decoded), &decoded_size)) {
1447 m_impl->signal_process_input_device_event(this, ecore_event_id, decoded, decoded_size, ret);
1453 case SCIM_TRANS_CMD_SET_AUTOCAPITAL_TYPE:
1455 MessageItemSetAutocapitalType *subclass = static_cast<MessageItemSetAutocapitalType*>(message);
1456 if (!m_impl->si.null ()) m_impl->si->set_autocapital_type(subclass->get_auto_capital_type_ref());
1457 m_impl->signal_set_autocapital_type(this, subclass->get_auto_capital_type_ref());
1460 case ISM_TRANS_CMD_SET_PREDICTION_ALLOW:
1462 MessageItemSetPredictionAllow *subclass = static_cast<MessageItemSetPredictionAllow*>(message);
1463 if (!m_impl->si.null ()) m_impl->si->set_prediction_allow(subclass->get_prediction_allow_ref() == 0 ? false : true);
1464 m_impl->signal_set_prediction_allow(this, subclass->get_prediction_allow_ref());
1467 case ISM_TRANS_CMD_SET_KEYBOARD_MODE:
1469 MessageItemSetKeyboardMode *subclass = static_cast<MessageItemSetKeyboardMode*>(message);
1470 if (subclass->get_mode_ref())
1471 m_impl->hw_keyboard_mode = false;
1473 m_impl->hw_keyboard_mode = true;
1476 case ISM_TRANS_CMD_SET_PREDICTION_HINT:
1478 MessageItemSetPredictionHint *subclass = static_cast<MessageItemSetPredictionHint*>(message);
1479 m_impl->signal_set_prediction_hint (this, subclass->get_message_ref());
1482 case ISM_TRANS_CMD_SET_MIME_TYPE:
1484 MessageItemSetMimeType *subclass = static_cast<MessageItemSetMimeType*>(message);
1485 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode || m_impl->need_update_entry_metadata) {
1486 m_impl->signal_set_mime_type (this, subclass->get_mime_type_ref());
1490 case ISM_TRANS_CMD_FINALIZE_CONTENT:
1492 MessageItemFinalizeContent *subclass = static_cast<MessageItemFinalizeContent*>(message);
1494 if (m_impl->finalized_text != NULL)
1495 free(m_impl->finalized_text);
1496 m_impl->finalized_text = strdup(subclass->get_text_ref().c_str());
1497 m_impl->finalized_cursor_pos = subclass->get_cursor_pos_ref();
1501 case ISM_TRANS_CMD_SET_PREDICTION_HINT_DATA:
1503 MessageItemSetPredictionHintData *subclass = static_cast<MessageItemSetPredictionHintData*>(message);
1504 m_impl->signal_set_prediction_hint_data (this, 0, subclass->get_key_ref(), subclass->get_value_ref());
1507 case ISM_TRANS_CMD_SET_OPTIMIZATION_HINT:
1509 MessageItemSetOptimizationHint *subclass = static_cast<MessageItemSetOptimizationHint*>(message);
1510 m_impl->signal_set_optimization_hint(this, subclass->get_hint_ref());
1520 * @brief Request SCIM to reload all configuration.
1522 * This function should only by used by Setup Helper to request
1523 * scim's reloading the configuration.
1524 * Deprecated: reload config message only send by socketconfig client
1525 * using socketconfig::reload instead.
1528 HelperAgent::reload_config () const
1530 LOGD ("send reload config message to isf");
1531 if (!m_impl->m_config.null())
1532 m_impl->m_config->reload();
1536 * @brief Register some properties into Panel.
1538 * This function send the request to Panel to register a list
1541 * @param properties The list of Properties to be registered into Panel.
1543 * @sa scim::Property.
1546 HelperAgent::register_properties (const PropertyList &properties) const
1548 if (m_impl->socket_active.is_connected ()) {
1549 m_impl->send.clear ();
1550 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1551 m_impl->send.put_data (m_impl->magic_active);
1552 m_impl->send.put_command (SCIM_TRANS_CMD_REGISTER_PROPERTIES);
1553 m_impl->send.put_data (properties);
1554 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1559 * @brief Update a registered property.
1561 * @param property The property to be updated.
1564 HelperAgent::update_property (const Property &property) const
1566 if (m_impl->socket_active.is_connected ()) {
1567 m_impl->send.clear ();
1568 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1569 m_impl->send.put_data (m_impl->magic_active);
1570 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PROPERTY);
1571 m_impl->send.put_data (property);
1572 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1577 * @brief Send a set of events to an IMEngineInstance.
1579 * All events should be put into a Transaction.
1580 * And the events can only be received by one IMEngineInstance object.
1582 * @param ic The handle of the Input Context to receive the events.
1583 * @param ic_uuid The UUID of the Input Context.
1584 * @param trans The Transaction object holds the events.
1587 HelperAgent::send_imengine_event (int ic,
1588 const String &ic_uuid,
1589 const Transaction &trans) const
1591 //remove if not necessary
1593 if (m_impl->socket_active.is_connected ()) {
1594 m_impl->send.clear ();
1595 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1596 m_impl->send.put_data (m_impl->magic_active);
1597 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_SEND_IMENGINE_EVENT);
1598 m_impl->send.put_data ((uint32)ic);
1599 m_impl->send.put_data (ic_uuid);
1600 m_impl->send.put_data (trans);
1601 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1604 if (!m_impl->si.null ()) m_impl->si->process_helper_event (ic_uuid, trans);
1608 * @brief Send a KeyEvent to an IMEngineInstance.
1610 * @param ic The handle of the IMEngineInstance to receive the event.
1611 * -1 means the currently focused IMEngineInstance.
1612 * @param ic_uuid The UUID of the IMEngineInstance. Empty means don't match.
1613 * @param key The KeyEvent to be sent.
1616 HelperAgent::send_key_event (int ic,
1617 const String &ic_uuid,
1618 const KeyEvent &key) const
1621 //FIXME: remove shift_mode_off, shift_mode_on, shift_mode_lock from ISE side
1622 if (key.code == SHIFT_MODE_OFF ||
1623 key.code == SHIFT_MODE_ON ||
1624 key.code == SHIFT_MODE_LOCK ||
1625 key.code == SHIFT_MODE_ENABLE ||
1626 key.code == SHIFT_MODE_DISABLE) {
1627 LOGW("FIXME ignore shift codes");
1631 if (m_impl->socket_active.is_connected ()) {
1632 m_impl->send.clear ();
1633 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1634 m_impl->send.put_data (m_impl->magic_active);
1635 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_SEND_KEY_EVENT);
1637 m_impl->send.put_data (m_impl->focused_ic);
1639 m_impl->send.put_data ((uint32)ic);
1641 m_impl->send.put_data (ic_uuid);
1642 m_impl->send.put_data (key);
1643 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1648 * @brief Forward a KeyEvent to client application directly.
1650 * @param ic The handle of the client Input Context to receive the event.
1651 * -1 means the currently focused Input Context.
1652 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1653 * Empty means don't match.
1654 * @param key The KeyEvent to be forwarded.
1657 HelperAgent::forward_key_event (int ic,
1658 const String &ic_uuid,
1659 const KeyEvent &key) const
1661 if (m_impl->socket_active.is_connected ()) {
1662 m_impl->send.clear ();
1663 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1664 m_impl->send.put_data (m_impl->magic_active);
1665 m_impl->send.put_command (SCIM_TRANS_CMD_FORWARD_KEY_EVENT);
1667 m_impl->send.put_data (m_impl->focused_ic);
1669 m_impl->send.put_data ((uint32)ic);
1671 m_impl->send.put_data (ic_uuid);
1672 m_impl->send.put_data (key);
1673 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1678 * @brief Commit a WideString to client application directly.
1680 * @param ic The handle of the client Input Context to receive the WideString.
1681 * -1 means the currently focused Input Context.
1682 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1683 * Empty means don't match.
1684 * @param wstr The WideString to be committed.
1687 HelperAgent::commit_string (int ic,
1688 const String &ic_uuid,
1689 const WideString &wstr) const
1691 if (m_impl->socket_active.is_connected ()) {
1692 m_impl->send.clear ();
1693 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1694 m_impl->send.put_data (m_impl->magic_active);
1695 m_impl->send.put_command (SCIM_TRANS_CMD_COMMIT_STRING);
1697 m_impl->send.put_data (m_impl->focused_ic);
1699 m_impl->send.put_data ((uint32)ic);
1701 m_impl->send.put_data (ic_uuid);
1702 m_impl->send.put_data (wstr);
1703 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1708 HelperAgent::commit_string (int ic,
1709 const String &ic_uuid,
1713 if (m_impl->socket_active.is_connected ()) {
1714 m_impl->send.clear ();
1715 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1716 m_impl->send.put_data (m_impl->magic_active);
1717 m_impl->send.put_command (SCIM_TRANS_CMD_COMMIT_STRING);
1719 m_impl->send.put_data (m_impl->focused_ic);
1721 m_impl->send.put_data ((uint32)ic);
1723 m_impl->send.put_data (ic_uuid);
1724 m_impl->send.put_dataw (buf, buflen);
1725 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1730 * @brief Request to show preedit string.
1732 * @param ic The handle of the client Input Context to receive the request.
1733 * -1 means the currently focused Input Context.
1734 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1735 * Empty means don't match.
1738 HelperAgent::show_preedit_string (int ic,
1739 const String &ic_uuid) const
1742 if (m_impl->socket_active.is_connected ()) {
1743 m_impl->send.clear ();
1744 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1745 m_impl->send.put_data (m_impl->magic_active);
1746 m_impl->send.put_command (SCIM_TRANS_CMD_SHOW_PREEDIT_STRING);
1747 m_impl->send.put_data ((uint32)ic);
1748 m_impl->send.put_data (ic_uuid);
1749 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1754 * @brief Request to show aux string.
1757 HelperAgent::show_aux_string (void) const
1760 if (m_impl->socket_active.is_connected ()) {
1761 m_impl->send.clear ();
1762 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1763 m_impl->send.put_data (m_impl->magic_active);
1764 m_impl->send.put_command (SCIM_TRANS_CMD_SHOW_AUX_STRING);
1765 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1770 * @brief Request to show candidate string.
1773 HelperAgent::show_candidate_string (void) const
1776 if (m_impl->socket_active.is_connected ()) {
1777 m_impl->send.clear ();
1778 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1779 m_impl->send.put_data (m_impl->magic_active);
1780 m_impl->send.put_command (SCIM_TRANS_CMD_SHOW_LOOKUP_TABLE);
1781 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1786 * @brief Request to show associate string.
1789 HelperAgent::show_associate_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 (ISM_TRANS_CMD_SHOW_ASSOCIATE_TABLE);
1796 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1801 * @brief Request to hide preedit string.
1803 * @param ic The handle of the client Input Context to receive the request.
1804 * -1 means the currently focused Input Context.
1805 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1806 * Empty means don't match.
1809 HelperAgent::hide_preedit_string (int ic,
1810 const String &ic_uuid) const
1813 if (m_impl->socket_active.is_connected ()) {
1814 m_impl->send.clear ();
1815 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1816 m_impl->send.put_data (m_impl->magic_active);
1817 m_impl->send.put_command (SCIM_TRANS_CMD_HIDE_PREEDIT_STRING);
1818 m_impl->send.put_data ((uint32)ic);
1819 m_impl->send.put_data (ic_uuid);
1820 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1825 * @brief Request to hide aux string.
1828 HelperAgent::hide_aux_string (void) const
1830 if (m_impl->socket_active.is_connected ()) {
1831 m_impl->send.clear ();
1832 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1833 m_impl->send.put_data (m_impl->magic_active);
1834 m_impl->send.put_command (SCIM_TRANS_CMD_HIDE_AUX_STRING);
1835 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1840 * @brief Request to hide candidate string.
1843 HelperAgent::hide_candidate_string (void) const
1845 if (m_impl->socket_active.is_connected ()) {
1846 m_impl->send.clear ();
1847 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1848 m_impl->send.put_data (m_impl->magic_active);
1849 m_impl->send.put_command (SCIM_TRANS_CMD_HIDE_LOOKUP_TABLE);
1850 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1855 * @brief Request to hide associate string.
1858 HelperAgent::hide_associate_string (void) const
1860 if (m_impl->socket_active.is_connected ()) {
1861 m_impl->send.clear ();
1862 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1863 m_impl->send.put_data (m_impl->magic_active);
1864 m_impl->send.put_command (ISM_TRANS_CMD_HIDE_ASSOCIATE_TABLE);
1865 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1870 * @brief Update a new WideString for preedit.
1872 * @param ic The handle of the client Input Context to receive the WideString.
1873 * -1 means the currently focused Input Context.
1874 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1875 * Empty means don't match.
1876 * @param str The WideString to be updated.
1877 * @param attrs The attribute list for preedit string.
1880 HelperAgent::update_preedit_string (int ic,
1881 const String &ic_uuid,
1882 const WideString &str,
1883 const AttributeList &attrs) const
1885 update_preedit_string (ic, ic_uuid, str, str, attrs, -1);
1889 HelperAgent::update_preedit_string (int ic,
1890 const String &ic_uuid,
1893 const AttributeList &attrs) const
1895 update_preedit_string (ic, ic_uuid, buf, buflen, attrs, -1);
1899 * @brief Update a new WideString for preedit.
1901 * @param ic The handle of the client Input Context to receive the WideString.
1902 * -1 means the currently focused Input Context.
1903 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1904 * Empty means don't match.
1905 * @param str The WideString to be updated.
1906 * @param attrs The attribute list for preedit string.
1907 * @param caret The caret position in preedit string.
1910 HelperAgent::update_preedit_string (int ic,
1911 const String &ic_uuid,
1912 const WideString &wstr,
1913 const AttributeList &attrs,
1916 update_preedit_string (ic, ic_uuid, wstr, wstr, attrs, caret);
1920 HelperAgent::update_preedit_string (int ic,
1921 const String &ic_uuid,
1924 const AttributeList &attrs,
1928 if (m_impl->socket_active.is_connected ()) {
1929 m_impl->send.clear ();
1930 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1931 m_impl->send.put_data (m_impl->magic_active);
1932 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING);
1933 m_impl->send.put_data ((uint32)ic);
1934 m_impl->send.put_data (ic_uuid);
1935 m_impl->send.put_dataw (buf, buflen);
1936 m_impl->send.put_dataw (buf, buflen);
1937 m_impl->send.put_data (attrs);
1938 m_impl->send.put_data (caret);
1939 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1944 HelperAgent::update_preedit_string (int ic,
1945 const String &ic_uuid,
1946 const WideString &preedit,
1947 const WideString &commit,
1948 const AttributeList &attrs,
1951 if (m_impl->socket_active.is_connected ()) {
1952 m_impl->send.clear ();
1953 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1954 m_impl->send.put_data (m_impl->magic_active);
1955 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING);
1956 m_impl->send.put_data ((uint32)ic);
1957 m_impl->send.put_data (ic_uuid);
1958 m_impl->send.put_data (preedit);
1959 m_impl->send.put_data (commit);
1960 m_impl->send.put_data (attrs);
1961 m_impl->send.put_data (caret);
1962 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1967 * @brief Update the preedit caret position in the preedit string.
1969 * @param caret - the new position of the preedit caret.
1972 HelperAgent::update_preedit_caret (int caret) 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_PREEDIT_CARET);
1980 m_impl->send.put_data ((uint32)caret);
1981 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1986 * @brief Update a new string for aux.
1988 * @param str The string to be updated.
1989 * @param attrs The attribute list for aux string.
1992 HelperAgent::update_aux_string (const String &str,
1993 const AttributeList &attrs) const
1995 if (m_impl->socket_active.is_connected ()) {
1996 m_impl->send.clear ();
1997 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1998 m_impl->send.put_data (m_impl->magic_active);
1999 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_AUX_STRING);
2000 m_impl->send.put_data (str);
2001 m_impl->send.put_data (attrs);
2002 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2007 * @brief Request to update candidate.
2009 * @param table The lookup table for candidate.
2012 HelperAgent::update_candidate_string (const LookupTable &table) const
2014 if (m_impl->socket_active.is_connected ()) {
2015 m_impl->send.clear ();
2016 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2017 m_impl->send.put_data (m_impl->magic_active);
2018 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_LOOKUP_TABLE);
2019 m_impl->send.put_data (table);
2020 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2025 * @brief Request to update associate.
2027 * @param table The lookup table for associate.
2030 HelperAgent::update_associate_string (const LookupTable &table) const
2032 if (m_impl->socket_active.is_connected ()) {
2033 m_impl->send.clear ();
2034 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2035 m_impl->send.put_data (m_impl->magic_active);
2036 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ASSOCIATE_TABLE);
2037 m_impl->send.put_data (table);
2038 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2043 * @brief When the input context of ISE is changed,
2044 * ISE can call this function to notify application
2046 * @param type type of event.
2047 * @param value value of event.
2050 HelperAgent::update_input_context (uint32 type, uint32 value) const
2052 if (type == ECORE_IMF_INPUT_PANEL_LANGUAGE_EVENT) {
2053 /* Update all state variables that could be queried by the client application */
2055 m_impl->signal_get_language_locale(this, -1, &buf);
2058 if (m_impl->socket_active.is_connected()) {
2059 m_impl->send.clear();
2060 m_impl->send.put_command(SCIM_TRANS_CMD_REQUEST);
2061 m_impl->send.put_data(m_impl->magic_active);
2062 m_impl->send.put_command(ISM_TRANS_CMD_UPDATE_ISE_LANGUAGE_LOCALE);
2063 m_impl->send.put_data(buf, strlen(buf));
2064 m_impl->send.write_to_socket(m_impl->socket_active, m_impl->magic_active);
2071 if (m_impl->socket_active.is_connected ()) {
2072 m_impl->send.clear ();
2073 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2074 m_impl->send.put_data (m_impl->magic_active);
2075 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ISE_INPUT_CONTEXT);
2076 m_impl->send.put_data (type);
2077 m_impl->send.put_data (value);
2078 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2083 * @brief Request to get surrounding text asynchronously.
2085 * @param uuid The helper ISE UUID.
2086 * @param maxlen_before The max length of before.
2087 * @param maxlen_after The max length of after.
2090 HelperAgent::get_surrounding_text (const String &uuid, int maxlen_before, int maxlen_after) const
2092 if (m_impl->socket_active.is_connected () && (m_impl->need_update_surrounding_text == 0)) {
2093 m_impl->send.clear ();
2094 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2095 m_impl->send.put_data (m_impl->magic_active);
2096 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SURROUNDING_TEXT);
2097 m_impl->send.put_data (uuid);
2098 m_impl->send.put_data (maxlen_before);
2099 m_impl->send.put_data (maxlen_after);
2100 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2102 m_impl->need_update_surrounding_text++;
2106 * @brief Request to get surrounding text synchronously.
2108 * @param uuid The helper ISE UUID.
2109 * @param maxlen_before The max length of before.
2110 * @param maxlen_after The max length of after.
2111 * @param text The surrounding text.
2112 * @param cursor The cursor position.
2115 HelperAgent::get_surrounding_text (int maxlen_before, int maxlen_after, String &text, int &cursor)
2117 if (!m_impl->socket_active.is_connected ())
2120 if (!m_impl->ise_focus_flag) {
2121 if (m_impl->finalized_text) {
2122 String buffer = m_impl->finalized_text;
2123 cursor = m_impl->finalized_cursor_pos;
2124 int pos = cursor - maxlen_before;
2125 if (maxlen_before < 0) pos = 0;
2126 if (pos > (int)buffer.length()) pos = (int)buffer.length();
2127 if (pos < 0) pos = 0;
2128 size_t len = maxlen_after + (cursor - pos);
2129 if (maxlen_after < 0) len = String::npos;
2130 text = buffer.substr (pos, len);
2136 m_impl->send.clear();
2137 m_impl->send.put_command(SCIM_TRANS_CMD_REQUEST);
2138 m_impl->send.put_data(m_impl->magic_active);
2139 m_impl->send.put_command(SCIM_TRANS_CMD_GET_SURROUNDING_TEXT);
2140 m_impl->send.put_data("");
2141 m_impl->send.put_data(maxlen_before);
2142 m_impl->send.put_data(maxlen_after);
2143 m_impl->send.write_to_socket(m_impl->socket_active, m_impl->magic_active);
2144 if (m_impl->surrounding_text) {
2145 free(m_impl->surrounding_text);
2146 m_impl->surrounding_text = NULL;
2149 const int WAIT_FOR_SYNC_RESPONSE_TIMEOUT = 1000;
2150 /* Now we are waiting for the ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT message */
2151 if (wait_for_message(ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT, WAIT_FOR_SYNC_RESPONSE_TIMEOUT)) {
2152 MessageItem *message = message_queue.get_pending_message_by_cmd(ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT);
2153 handle_message(message);
2154 message_queue.remove_message(message);
2156 if (m_impl->surrounding_text) {
2157 text = m_impl->surrounding_text;
2158 cursor = m_impl->cursor_pos;
2162 if (m_impl->surrounding_text) {
2163 free(m_impl->surrounding_text);
2164 m_impl->surrounding_text = NULL;
2167 LOGD("message_queue size : %d", message_queue.get_message_size());
2169 m_impl->send.clear ();
2170 m_impl->send.put_command(SCIM_TRANS_CMD_REQUEST);
2171 m_impl->send.put_data(m_impl->magic_active);
2172 m_impl->send.put_command(SCIM_TRANS_CMD_PING);
2173 m_impl->send.write_to_socket(m_impl->socket_active, m_impl->magic_active);
2178 * @brief Request to delete surrounding text.
2180 * @param offset The offset for cursor position.
2181 * @param len The length for delete text.
2184 HelperAgent::delete_surrounding_text (int offset, int len) const
2186 LOGD ("offset = %d, len = %d", offset, len);
2188 if (m_impl->socket_active.is_connected ()) {
2189 m_impl->send.clear ();
2190 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2191 m_impl->send.put_data (m_impl->magic_active);
2192 m_impl->send.put_command (SCIM_TRANS_CMD_DELETE_SURROUNDING_TEXT);
2193 m_impl->send.put_data (offset);
2194 m_impl->send.put_data (len);
2195 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2200 * @brief Request to get selection text asynchronously.
2202 * @param uuid The helper ISE UUID.
2205 HelperAgent::get_selection (const String &uuid) const
2207 if (m_impl->socket_active.is_connected () && (m_impl->need_update_selection_text == 0)) {
2208 m_impl->send.clear ();
2209 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2210 m_impl->send.put_data (m_impl->magic_active);
2211 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SELECTION);
2212 m_impl->send.put_data (uuid);
2213 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2215 m_impl->need_update_selection_text++;
2219 * @brief Request to get selection text synchronously.
2221 * @param text The selection text.
2224 HelperAgent::get_selection_text (String &text)
2227 if (!m_impl->socket_active.is_connected ())
2230 m_impl->send.clear ();
2231 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2232 m_impl->send.put_data (m_impl->magic_active);
2233 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SELECTION);
2234 m_impl->send.put_data ("");
2235 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2236 if (m_impl->selection_text) {
2237 free (m_impl->selection_text);
2238 m_impl->selection_text = NULL;
2241 const int WAIT_FOR_SYNC_RESPONSE_TIMEOUT = 1000;
2242 /* Now we are waiting for the ISM_TRANS_CMD_UPDATE_SELECTION message */
2243 if (wait_for_message(ISM_TRANS_CMD_UPDATE_SELECTION, WAIT_FOR_SYNC_RESPONSE_TIMEOUT)) {
2244 MessageItem *message = message_queue.get_pending_message_by_cmd(ISM_TRANS_CMD_UPDATE_SELECTION);
2245 handle_message(message);
2246 message_queue.remove_message(message);
2247 if (m_impl->selection_text) {
2248 text = m_impl->selection_text;
2252 if (m_impl->selection_text) {
2253 free (m_impl->selection_text);
2254 m_impl->selection_text = NULL;
2257 LOGD("message_queue size : %d", message_queue.get_message_size());
2259 m_impl->send.clear ();
2260 m_impl->send.put_command(SCIM_TRANS_CMD_REQUEST);
2261 m_impl->send.put_data(m_impl->magic_active);
2262 m_impl->send.put_command(SCIM_TRANS_CMD_PING);
2263 m_impl->send.write_to_socket(m_impl->socket_active, m_impl->magic_active);
2267 * @brief Request to select text.
2269 * @param start The start position in text.
2270 * @param end The end position in text.
2273 HelperAgent::set_selection (int start, int end) const
2275 if (m_impl->socket_active.is_connected ()) {
2276 m_impl->send.clear ();
2277 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2278 m_impl->send.put_data (m_impl->magic_active);
2279 m_impl->send.put_command (SCIM_TRANS_CMD_SET_SELECTION);
2280 m_impl->send.put_data (start);
2281 m_impl->send.put_data (end);
2282 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2287 * @brief Send a private command to an application.
2289 * @param command The private command sent from IME.
2292 HelperAgent::send_private_command (const String &command) const
2294 if (m_impl->socket_active.is_connected ()) {
2295 m_impl->send.clear ();
2296 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2297 m_impl->send.put_data (m_impl->magic_active);
2298 m_impl->send.put_command (SCIM_TRANS_CMD_SEND_PRIVATE_COMMAND);
2299 m_impl->send.put_data (command);
2300 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2305 * @brief Commit content to an application.
2307 * @param content The content sent from IME.
2310 HelperAgent::commit_content (const String &content, const String &description, const String &mime_types) const
2313 if (m_impl->socket_active.is_connected ()) {
2314 m_impl->send.clear ();
2315 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2316 m_impl->send.put_data (m_impl->magic_active);
2317 m_impl->send.put_command (SCIM_TRANS_CMD_COMMIT_CONTENT);
2318 m_impl->send.put_data (content);
2319 m_impl->send.put_data (description);
2320 m_impl->send.put_data (mime_types);
2321 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2326 * @brief Request to get uuid list of all keyboard ISEs.
2328 * @param uuid The helper ISE UUID.
2331 HelperAgent::get_keyboard_ise_list (const String &uuid) 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_GET_KEYBOARD_ISE_LIST);
2338 m_impl->send.put_data (uuid);
2339 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2344 * @brief Set candidate position in screen.
2346 * @param left The x position in screen.
2347 * @param top The y position in screen.
2350 HelperAgent::set_candidate_position (int left, int top) const
2352 if (m_impl->socket_active.is_connected ()) {
2353 m_impl->send.clear ();
2354 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2355 m_impl->send.put_data (m_impl->magic_active);
2356 m_impl->send.put_command (ISM_TRANS_CMD_SET_CANDIDATE_POSITION);
2357 m_impl->send.put_data (left);
2358 m_impl->send.put_data (top);
2359 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2364 * @brief Set candidate style.
2366 * @param portrait_line - the displayed line number for portrait mode.
2367 * @param mode - candidate window mode.
2370 HelperAgent::set_candidate_style (ISF_CANDIDATE_PORTRAIT_LINE_T portrait_line,
2371 ISF_CANDIDATE_MODE_T mode) const
2373 if (m_impl->socket_active.is_connected ()) {
2374 m_impl->send.clear ();
2375 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2376 m_impl->send.put_data (m_impl->magic_active);
2377 m_impl->send.put_command (ISM_TRANS_CMD_SET_CANDIDATE_UI);
2378 m_impl->send.put_data (portrait_line);
2379 m_impl->send.put_data (mode);
2380 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2385 * @brief Request to hide candidate window.
2388 HelperAgent::candidate_hide (void) const
2390 if (m_impl->socket_active.is_connected ()) {
2391 m_impl->send.clear ();
2392 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2393 m_impl->send.put_data (m_impl->magic_active);
2394 m_impl->send.put_command (ISM_TRANS_CMD_HIDE_CANDIDATE);
2395 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2400 * @brief Request to get candidate window size and position.
2402 * @param uuid The helper ISE UUID.
2405 HelperAgent::get_candidate_window_geometry (const String &uuid) const
2407 if (m_impl->socket_active.is_connected ()) {
2408 m_impl->send.clear ();
2409 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2410 m_impl->send.put_data (m_impl->magic_active);
2411 m_impl->send.put_command (ISM_TRANS_CMD_GET_CANDIDATE_GEOMETRY);
2412 m_impl->send.put_data (uuid);
2413 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2418 * @brief Set current keyboard ISE.
2420 * @param uuid The keyboard ISE UUID.
2423 HelperAgent::set_keyboard_ise_by_uuid (const String &uuid) const
2426 IMEngineFactoryPointer factory;
2427 IMEngineModule *engine_module = NULL;
2428 static int instance_count = 1;
2430 if ((!m_impl->si.null ()) && m_impl->si->get_factory_uuid () == uuid) {
2431 ISF_SAVE_LOG ("Already in UUID: %s", uuid.c_str());
2435 if (!m_impl->si.null()) {
2436 m_impl->si->focus_out();
2440 if (m_impl->m_config.null ()) {
2441 ISF_SAVE_LOG ("config is not working");
2445 #ifdef HAVE_PKGMGR_INFO
2448 pkgmgrinfo_appinfo_h handle;
2449 ret = pkgmgrinfo_appinfo_get_appinfo(uuid.c_str(), &handle);
2450 if (ret != PMINFO_R_OK) {
2451 ISF_SAVE_LOG ("Retrieve app info failed : %s", uuid.c_str ());
2455 ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
2456 if (ret != PMINFO_R_OK) {
2457 ISF_SAVE_LOG ("Retrieve pkgid failed : %s, %p", uuid.c_str(), handle);
2458 pkgmgrinfo_appinfo_destroy_appinfo(handle);
2462 imeInfo.module_name = pkgid;
2463 pkgmgrinfo_appinfo_destroy_appinfo(handle);
2465 if (isf_db_select_ime_info_by_appid(uuid.c_str(), &imeInfo) < 1) {
2466 ISF_SAVE_LOG ("ime_info row is not available for %s", uuid.c_str());
2471 engine_module = &m_impl->engine_module;
2473 if (engine_module->valid() && imeInfo.module_name != engine_module->get_module_name()) {
2474 ISF_SAVE_LOG ("imengine module %s unloaded", engine_module->get_module_name().c_str());
2475 engine_module->unload();
2478 if (!engine_module->valid()) {
2479 if (engine_module->load (imeInfo.module_name, m_impl->m_config) == false) {
2480 ISF_SAVE_LOG ("load module %s failed", imeInfo.module_name.c_str());
2483 ISF_SAVE_LOG ("imengine module %s loaded", imeInfo.module_name.c_str());
2486 for (size_t j = 0; j < engine_module->number_of_factories (); ++j) {
2488 factory = engine_module->create_factory (j);
2489 if (factory.null () == false && factory->get_uuid () == uuid)
2497 if (factory.null()) {
2498 ISF_SAVE_LOG ("imengine uuid %s is not found", uuid.c_str());
2502 m_impl->si = factory->create_instance ("UTF-8", instance_count++);
2503 if (m_impl->si.null ()) {
2504 ISF_SAVE_LOG ("create_instance %s failed", uuid.c_str ());
2508 m_impl->attach_instance ();
2509 ISF_SAVE_LOG ("Require UUID: %s Current UUID: %s", uuid.c_str (), m_impl->si->get_factory_uuid ().c_str ());
2510 m_impl->si->set_layout (m_impl->layout);
2511 if (m_impl->focused_ic != (uint32)-1)
2512 m_impl->si->focus_in ();
2516 * @brief Request to get current keyboard ISE information.
2518 * @param uuid The helper ISE UUID.
2521 HelperAgent::get_keyboard_ise (const String &uuid) const
2523 //FIXME: maybe useless
2525 if (m_impl->socket_active.is_connected ()) {
2526 m_impl->send.clear ();
2527 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2528 m_impl->send.put_data (m_impl->magic_active);
2529 m_impl->send.put_command (ISM_TRANS_CMD_GET_KEYBOARD_ISE);
2530 m_impl->send.put_data (uuid);
2531 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2537 * @brief Update ISE window geometry.
2539 * @param x The x position in screen.
2540 * @param y The y position in screen.
2541 * @param width The ISE window width.
2542 * @param height The ISE window height.
2545 HelperAgent::update_geometry (int x, int y, int width, int height) const
2547 if (m_impl->socket_active.is_connected ()) {
2548 m_impl->send.clear ();
2549 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2550 m_impl->send.put_data (m_impl->magic_active);
2551 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ISE_GEOMETRY);
2552 m_impl->send.put_data (x);
2553 m_impl->send.put_data (y);
2554 m_impl->send.put_data (width);
2555 m_impl->send.put_data (height);
2556 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2561 * @brief Request to expand candidate window.
2564 HelperAgent::expand_candidate (void) const
2566 if (m_impl->socket_active.is_connected ()) {
2567 m_impl->send.clear ();
2568 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2569 m_impl->send.put_data (m_impl->magic_active);
2570 m_impl->send.put_command (ISM_TRANS_CMD_EXPAND_CANDIDATE);
2571 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2576 * @brief Request to contract candidate window.
2579 HelperAgent::contract_candidate (void) const
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_CONTRACT_CANDIDATE);
2586 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2591 * @brief Send selected candidate string index number.
2594 HelperAgent::select_candidate (int index) const
2596 if (!m_impl->si.null ())
2597 m_impl->si->select_candidate (index);
2598 //FIXME: maybe useless
2601 if (m_impl->socket_active.is_connected ()) {
2602 m_impl->send.clear ();
2603 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2604 m_impl->send.put_data (m_impl->magic_active);
2605 m_impl->send.put_command (ISM_TRANS_CMD_SELECT_CANDIDATE);
2606 m_impl->send.put_data (index);
2607 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2613 * @brief Update our ISE is exiting.
2615 * The IME must call this function before terminating IME itself in On-demand mode.
2616 * If this function isn't called, IME will automatically restart.
2617 * This function only works in On-demand mode.
2621 HelperAgent::update_ise_exit (void) const
2623 if (m_impl->socket_active.is_connected ()) {
2624 m_impl->send.clear ();
2625 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2626 m_impl->send.put_data (m_impl->magic_active);
2627 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ISE_EXIT);
2628 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2630 // The update_ise_exit must be delivered before del_client of isf_info_manager was called.
2636 * @brief Request to reset keyboard ISE.
2639 HelperAgent::reset_keyboard_ise (void) const
2641 //FIXME: maybe useless
2643 if (m_impl->socket_active.is_connected ()) {
2644 m_impl->send.clear ();
2645 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2646 m_impl->send.put_data (m_impl->magic_active);
2647 m_impl->send.put_command (ISM_TRANS_CMD_PANEL_RESET_KEYBOARD_ISE);
2648 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2651 if (!m_impl->si.null ()) {
2652 m_impl->si->reset ();
2657 * @brief Request to flush keyboard ISE.
2660 HelperAgent::flush_keyboard_ise (void) const
2662 if (!m_impl->si.null ()) {
2663 m_impl->si->flush ();
2668 * @brief Request panel to hide ISE.
2671 HelperAgent::request_ise_hide (void) const
2673 if (m_impl->socket_active.is_connected ()) {
2674 m_impl->send.clear ();
2675 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2676 m_impl->send.put_data (m_impl->magic_active);
2677 m_impl->send.put_command (ISM_TRANS_CMD_REQUEST_ISE_HIDE);
2678 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2686 HelperAgent::recapture_string (int ic,
2687 const String &ic_uuid,
2690 const WideString &preedit_str,
2691 const WideString &commit_str,
2692 const AttributeList &attrs) const
2694 LOGD ("offset = %d, len = %d", offset, len);
2696 if (m_impl->socket_active.is_connected ()) {
2697 m_impl->send.clear ();
2698 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2699 m_impl->send.put_data (m_impl->magic_active);
2700 m_impl->send.put_command (ISM_TRANS_CMD_RECAPTURE_STRING);
2702 m_impl->send.put_data ((uint32)ic);
2703 m_impl->send.put_data (ic_uuid);
2705 // Deleting surrounding text
2706 m_impl->send.put_data (offset);
2707 m_impl->send.put_data (len);
2709 // Update preedit text
2710 m_impl->send.put_data (preedit_str);
2713 m_impl->send.put_data (commit_str);
2715 // preedit attributes
2716 m_impl->send.put_data (attrs);
2718 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2723 HelperAgent::set_engine_loader_flag (bool flag)
2725 m_impl->engine_loader_flag = flag;
2729 * @brief Connect a slot to Helper exit signal.
2731 * This signal is used to let the Helper exit.
2733 * The prototype of the slot is:
2735 * void exit (const HelperAgent *agent, int ic, const String &ic_uuid);
2738 * - agent The pointer to the HelperAgent object which emits this signal.
2739 * - ic An opaque handle of the currently focused input context.
2740 * - ic_uuid The UUID of the IMEngineInstance associated with the focused input context.
2743 HelperAgent::signal_connect_exit (HelperAgentSlotVoid *slot)
2745 return m_impl->signal_exit.connect (slot);
2749 * @brief Connect a slot to Helper attach input context signal.
2751 * This signal is used to attach an input context to this helper.
2753 * When an input context requst to start this helper, then this
2754 * signal will be emitted as soon as the helper is started.
2756 * When an input context want to start an already started helper,
2757 * this signal will also be emitted.
2759 * Helper can send some events back to the IMEngineInstance in this
2760 * signal-slot, to inform that it has been started sccessfully.
2762 * The prototype of the slot is:
2764 * void attach_input_context (const HelperAgent *agent, int ic, const String &ic_uuid);
2767 HelperAgent::signal_connect_attach_input_context (HelperAgentSlotVoid *slot)
2769 return m_impl->signal_attach_input_context.connect (slot);
2773 * @brief Connect a slot to Helper detach input context signal.
2775 * This signal is used to detach an input context from this helper.
2777 * When an input context requst to stop this helper, then this
2778 * signal will be emitted.
2780 * Helper shouldn't send any event back to the IMEngineInstance, because
2781 * the IMEngineInstance attached to the ic should have been destroyed.
2783 * The prototype of the slot is:
2785 * void detach_input_context (const HelperAgent *agent, int ic, const String &ic_uuid);
2788 HelperAgent::signal_connect_detach_input_context (HelperAgentSlotVoid *slot)
2790 return m_impl->signal_detach_input_context.connect (slot);
2794 * @brief Connect a slot to Helper reload config signal.
2796 * This signal is used to let the Helper reload configuration.
2798 * The prototype of the slot is:
2800 * void reload_config (const HelperAgent *agent, int ic, const String &ic_uuid);
2803 HelperAgent::signal_connect_reload_config (HelperAgentSlotVoid *slot)
2805 return m_impl->signal_reload_config.connect (slot);
2809 * @brief Connect a slot to Helper update screen signal.
2811 * This signal is used to let the Helper move its GUI to another screen.
2812 * It can only be emitted when SCIM_HELPER_NEED_SCREEN_INFO is set in HelperInfo.option.
2814 * The prototype of the slot is:
2816 * void update_screen (const HelperAgent *agent, int ic, const String &ic_uuid, int screen_number);
2819 HelperAgent::signal_connect_update_screen (HelperAgentSlotInt *slot)
2821 return m_impl->signal_update_screen.connect (slot);
2825 * @brief Connect a slot to Helper update spot location signal.
2827 * This signal is used to let the Helper move its GUI according to the current spot location.
2828 * It can only be emitted when SCIM_HELPER_NEED_SPOT_LOCATION_INFO is set in HelperInfo.option.
2830 * The prototype of the slot is:
2831 * void update_spot_location (const HelperAgent *agent, int ic, const String &ic_uuid, int x, int y);
2834 HelperAgent::signal_connect_update_spot_location (HelperAgentSlotIntInt *slot)
2836 return m_impl->signal_update_spot_location.connect (slot);
2840 * @brief Connect a slot to Helper update cursor position signal.
2842 * This signal is used to let the Helper get the cursor position information.
2844 * The prototype of the slot is:
2845 * void update_cursor_position (const HelperAgent *agent, int ic, const String &ic_uuid, int cursor_pos);
2848 HelperAgent::signal_connect_update_cursor_position (HelperAgentSlotInt *slot)
2850 return m_impl->signal_update_cursor_position.connect (slot);
2854 * @brief Connect a slot to Helper update surrounding text signal.
2856 * This signal is used to let the Helper get the surrounding text.
2858 * The prototype of the slot is:
2859 * void update_surrounding_text (const HelperAgent *agent, int ic, const String &text, int cursor);
2862 HelperAgent::signal_connect_update_surrounding_text (HelperAgentSlotInt *slot)
2864 return m_impl->signal_update_surrounding_text.connect (slot);
2868 * @brief Connect a slot to Helper update selection signal.
2870 * This signal is used to let the Helper get the selection.
2872 * The prototype of the slot is:
2873 * void update_selection (const HelperAgent *agent, int ic, const String &text);
2876 HelperAgent::signal_connect_update_selection (HelperAgentSlotVoid *slot)
2878 return m_impl->signal_update_selection.connect (slot);
2882 * @brief Connect a slot to Helper trigger property signal.
2884 * This signal is used to trigger a property registered by this Helper.
2885 * A property will be triggered when user clicks on it.
2887 * The prototype of the slot is:
2888 * void trigger_property (const HelperAgent *agent, int ic, const String &ic_uuid, const String &property);
2891 HelperAgent::signal_connect_trigger_property (HelperAgentSlotString *slot)
2893 return m_impl->signal_trigger_property.connect (slot);
2897 * @brief Connect a slot to Helper process imengine event signal.
2899 * This signal is used to deliver the events sent from IMEngine to Helper.
2901 * The prototype of the slot is:
2902 * void process_imengine_event (const HelperAgent *agent, int ic, const String &ic_uuid, const Transaction &transaction);
2905 HelperAgent::signal_connect_process_imengine_event (HelperAgentSlotTransaction *slot)
2907 return m_impl->signal_process_imengine_event.connect (slot);
2911 * @brief Connect a slot to Helper focus out signal.
2913 * This signal is used to do something when input context is focus out.
2915 * The prototype of the slot is:
2916 * void focus_out (const HelperAgent *agent, int ic, const String &ic_uuid);
2919 HelperAgent::signal_connect_focus_out (HelperAgentSlotVoid *slot)
2921 return m_impl->signal_focus_out.connect (slot);
2925 * @brief Connect a slot to Helper focus in signal.
2927 * This signal is used to do something when input context is focus in.
2929 * The prototype of the slot is:
2930 * void focus_in (const HelperAgent *agent, int ic, const String &ic_uuid);
2933 HelperAgent::signal_connect_focus_in (HelperAgentSlotVoid *slot)
2935 return m_impl->signal_focus_in.connect (slot);
2939 * @brief Connect a slot to Helper show signal.
2941 * This signal is used to show Helper ISE window.
2943 * The prototype of the slot is:
2944 * void ise_show (const HelperAgent *agent, int ic, char *buf, size_t &len);
2947 HelperAgent::signal_connect_ise_show (HelperAgentSlotIntRawVoid *slot)
2949 return m_impl->signal_ise_show.connect (slot);
2953 * @brief Connect a slot to Helper hide signal.
2955 * This signal is used to hide Helper ISE window.
2957 * The prototype of the slot is:
2958 * void ise_hide (const HelperAgent *agent, int ic, const String &ic_uuid);
2961 HelperAgent::signal_connect_ise_hide (HelperAgentSlotVoid *slot)
2963 return m_impl->signal_ise_hide.connect (slot);
2967 * @brief Connect a slot to Helper get ISE window geometry signal.
2969 * This signal is used to get Helper ISE window size and position.
2971 * The prototype of the slot is:
2972 * void get_geometry (const HelperAgent *agent, struct rectinfo &info);
2975 HelperAgent::signal_connect_get_geometry (HelperAgentSlotSize *slot)
2977 return m_impl->signal_get_geometry.connect (slot);
2981 * @brief Connect a slot to Helper set mode signal.
2983 * This signal is used to set Helper ISE mode.
2985 * The prototype of the slot is:
2986 * void set_mode (const HelperAgent *agent, uint32 &mode);
2989 HelperAgent::signal_connect_set_mode (HelperAgentSlotUintVoid *slot)
2991 return m_impl->signal_set_mode.connect (slot);
2995 * @brief Connect a slot to Helper set language signal.
2997 * This signal is used to set Helper ISE language.
2999 * The prototype of the slot is:
3000 * void set_language (const HelperAgent *agent, uint32 &language);
3003 HelperAgent::signal_connect_set_language (HelperAgentSlotUintVoid *slot)
3005 return m_impl->signal_set_language.connect (slot);
3009 * @brief Connect a slot to Helper set im data signal.
3011 * This signal is used to send im data to Helper ISE.
3013 * The prototype of the slot is:
3014 * void set_imdata (const HelperAgent *agent, char *buf, size_t &len);
3017 HelperAgent::signal_connect_set_imdata (HelperAgentSlotRawVoid *slot)
3019 return m_impl->signal_set_imdata.connect (slot);
3023 * @brief Connect a slot to Helper get im data signal.
3025 * This signal is used to get im data from Helper ISE.
3027 * The prototype of the slot is:
3028 * void get_imdata (const HelperAgent *, char **buf, size_t &len);
3031 HelperAgent::signal_connect_get_imdata (HelperAgentSlotGetRawVoid *slot)
3033 return m_impl->signal_get_imdata.connect (slot);
3037 * @brief Connect a slot to Helper get language locale signal.
3039 * This signal is used to get language locale from Helper ISE.
3041 * The prototype of the slot is:
3042 * void get_language_locale (const HelperAgent *, int ic, char **locale);
3045 HelperAgent::signal_connect_get_language_locale (HelperAgentSlotIntGetStringVoid *slot)
3047 return m_impl->signal_get_language_locale.connect (slot);
3051 * @brief Connect a slot to Helper set return key type signal.
3053 * This signal is used to send return key type to Helper ISE.
3055 * The prototype of the slot is:
3056 * void set_return_key_type (const HelperAgent *agent, uint32 &type);
3059 HelperAgent::signal_connect_set_return_key_type (HelperAgentSlotUintVoid *slot)
3061 return m_impl->signal_set_return_key_type.connect (slot);
3065 * @brief Connect a slot to Helper get return key type signal.
3067 * This signal is used to get return key type from Helper ISE.
3069 * The prototype of the slot is:
3070 * void get_return_key_type (const HelperAgent *agent, uint32 &type);
3073 HelperAgent::signal_connect_get_return_key_type (HelperAgentSlotUintVoid *slot)
3075 return m_impl->signal_get_return_key_type.connect (slot);
3079 * @brief Connect a slot to Helper set return key disable signal.
3081 * This signal is used to send return key disable to Helper ISE.
3083 * The prototype of the slot is:
3084 * void set_return_key_disable (const HelperAgent *agent, uint32 &disabled);
3087 HelperAgent::signal_connect_set_return_key_disable (HelperAgentSlotUintVoid *slot)
3089 return m_impl->signal_set_return_key_disable.connect (slot);
3093 * @brief Connect a slot to Helper process key event signal.
3095 * This signal is used to send keyboard key event to Helper ISE.
3097 * The prototype of the slot is:
3098 * void process_key_event (const HelperAgent *agent, KeyEvent &key, uint32 &ret);
3101 HelperAgent::signal_connect_process_key_event (HelperAgentSlotKeyEventUint *slot)
3103 return m_impl->signal_process_key_event.connect (slot);
3107 * @brief Connect a slot to Helper process key event with keycode signal.
3109 * This signal is used to send keyboard key event with keycode to Helper ISE.
3111 * The prototype of the slot is:
3112 * void process_key_event_with_keycode (const HelperAgent *agent, KeyEvent &key, uint32 &ret, uint32 keycode);
3115 HelperAgent::signal_connect_process_key_event_with_keycode (HelperAgentSlotKeyEventUintUint *slot)
3117 return m_impl->signal_process_key_event_with_keycode.connect (slot);
3121 * @brief Connect a slot to Helper get return key disable signal.
3123 * This signal is used to get return key disable from Helper ISE.
3125 * The prototype of the slot is:
3126 * void get_return_key_disable (const HelperAgent *agent, uint32 &disabled);
3129 HelperAgent::signal_connect_get_return_key_disable (HelperAgentSlotUintVoid *slot)
3131 return m_impl->signal_get_return_key_disable.connect (slot);
3135 * @brief Connect a slot to Helper set layout signal.
3137 * This signal is used to set Helper ISE layout.
3139 * The prototype of the slot is:
3140 * void set_layout (const HelperAgent *agent, uint32 &layout);
3143 HelperAgent::signal_connect_set_layout (HelperAgentSlotUintVoid *slot)
3145 return m_impl->signal_set_layout.connect (slot);
3149 * @brief Connect a slot to Helper get layout signal.
3151 * This signal is used to get Helper ISE layout.
3153 * The prototype of the slot is:
3154 * void get_layout (const HelperAgent *agent, uint32 &layout);
3157 HelperAgent::signal_connect_get_layout (HelperAgentSlotUintVoid *slot)
3159 return m_impl->signal_get_layout.connect (slot);
3163 * @brief Connect a slot to Helper set input mode signal.
3165 * This signal is used to set Helper ISE input mode.
3167 * The prototype of the slot is:
3168 * void set_input_mode (const HelperAgent *agent, uint32 &input_mode);
3171 HelperAgent::signal_connect_set_input_mode (HelperAgentSlotUintVoid *slot)
3173 return m_impl->signal_set_input_mode.connect (slot);
3177 * @brief Connect a slot to Helper set input hint signal.
3179 * This signal is used to set Helper ISE input hint.
3181 * The prototype of the slot is:
3182 * void set_input_hint (const HelperAgent *agent, uint32 &input_hint);
3185 HelperAgent::signal_connect_set_input_hint (HelperAgentSlotUintVoid *slot)
3187 return m_impl->signal_set_input_hint.connect (slot);
3191 * @brief Connect a slot to Helper set BiDi direction signal.
3193 * This signal is used to set Helper ISE BiDi direction.
3195 * The prototype of the slot is:
3196 * void update_bidi_direction (const HelperAgent *agent, uint32 &bidi_direction);
3199 HelperAgent::signal_connect_update_bidi_direction (HelperAgentSlotUintVoid *slot)
3201 return m_impl->signal_update_bidi_direction.connect (slot);
3205 * @brief Connect a slot to Helper set shift mode signal.
3207 * This signal is used to set Helper shift mode.
3209 * The prototype of the slot is:
3210 * void set_caps_mode (const HelperAgent *agent, uint32 &mode);
3213 HelperAgent::signal_connect_set_caps_mode (HelperAgentSlotUintVoid *slot)
3215 return m_impl->signal_set_caps_mode.connect (slot);
3219 * @brief Connect a slot to Helper reset input context signal.
3221 * This signal is used to reset Helper ISE input context.
3223 * The prototype of the slot is:
3224 * void reset_input_context (const HelperAgent *agent, int ic, const String &uuid);
3227 HelperAgent::signal_connect_reset_input_context (HelperAgentSlotVoid *slot)
3229 return m_impl->signal_reset_input_context.connect (slot);
3233 * @brief Connect a slot to Helper update candidate window geometry signal.
3235 * This signal is used to get candidate window size and position.
3237 * The prototype of the slot is:
3238 * void update_candidate_geometry (const HelperAgent *agent, int ic, const String &uuid, const rectinfo &info);
3241 HelperAgent::signal_connect_update_candidate_geometry (HelperAgentSlotRect *slot)
3243 return m_impl->signal_update_candidate_geometry.connect (slot);
3247 * @brief Connect a slot to Helper update keyboard ISE signal.
3249 * This signal is used to get current keyboard ISE name and uuid.
3251 * The prototype of the slot is:
3252 * void update_keyboard_ise (const HelperAgent *agent, int ic, const String &uuid,
3253 * const String &ise_name, const String &ise_uuid);
3256 HelperAgent::signal_connect_update_keyboard_ise (HelperAgentSlotString2 *slot)
3258 return m_impl->signal_update_keyboard_ise.connect (slot);
3262 * @brief Connect a slot to Helper update keyboard ISE list signal.
3264 * This signal is used to get uuid list of all keyboard ISEs.
3266 * The prototype of the slot is:
3267 * void update_keyboard_ise_list (const HelperAgent *agent, int ic, const String &uuid,
3268 * const std::vector<String> &ise_list);
3271 HelperAgent::signal_connect_update_keyboard_ise_list (HelperAgentSlotStringVector *slot)
3273 return m_impl->signal_update_keyboard_ise_list.connect (slot);
3277 * @brief Connect a slot to Helper candidate more window show signal.
3279 * This signal is used to do someting when candidate more window is showed.
3281 * The prototype of the slot is:
3282 * void candidate_more_window_show (const HelperAgent *agent, int ic, const String &uuid);
3285 HelperAgent::signal_connect_candidate_more_window_show (HelperAgentSlotVoid *slot)
3287 return m_impl->signal_candidate_more_window_show.connect (slot);
3291 * @brief Connect a slot to Helper candidate more window hide signal.
3293 * This signal is used to do someting when candidate more window is hidden.
3295 * The prototype of the slot is:
3296 * void candidate_more_window_hide (const HelperAgent *agent, int ic, const String &uuid);
3299 HelperAgent::signal_connect_candidate_more_window_hide (HelperAgentSlotVoid *slot)
3301 return m_impl->signal_candidate_more_window_hide.connect (slot);
3305 * @brief Connect a slot to Helper candidate show signal.
3307 * This signal is used to do candidate show.
3309 * The prototype of the slot is:
3310 * void candidate_show (const HelperAgent *agent, int ic, const String &uuid);
3313 HelperAgent::signal_connect_candidate_show (HelperAgentSlotVoid *slot)
3315 return m_impl->signal_candidate_show.connect (slot);
3319 * @brief Connect a slot to Helper candidate hide signal.
3321 * This signal is used to do candidate hide.
3323 * The prototype of the slot is:
3324 * void candidate_hide (const HelperAgent *agent, int ic, const String &uuid);
3327 HelperAgent::signal_connect_candidate_hide (HelperAgentSlotVoid *slot)
3329 return m_impl->signal_candidate_hide.connect (slot);
3333 * @brief Connect a slot to Helper update lookup table signal.
3335 * This signal is used to do someting when update lookup table.
3337 * The prototype of the slot is:
3338 * void update_lookup_table (const HelperAgent *agent, int ic, const String &uuid ,LookupTable &table);
3341 HelperAgent::signal_connect_update_lookup_table (HelperAgentSlotLookupTable *slot)
3343 return m_impl->signal_update_lookup_table.connect (slot);
3347 * @brief Connect a slot to Helper select aux signal.
3349 * This signal is used to do something when aux is selected.
3351 * The prototype of the slot is:
3352 * void select_aux (const HelperAgent *agent, int ic, const String &uuid, int index);
3355 HelperAgent::signal_connect_select_aux (HelperAgentSlotInt *slot)
3357 return m_impl->signal_select_aux.connect (slot);
3361 * @brief Connect a slot to Helper select candidate signal.
3363 * This signal is used to do something when candidate is selected.
3365 * The prototype of the slot is:
3366 * void select_candidate (const HelperAgent *agent, int ic, const String &uuid, int index);
3369 HelperAgent::signal_connect_select_candidate (HelperAgentSlotInt *slot)
3371 return m_impl->signal_select_candidate.connect (slot);
3375 * @brief Connect a slot to Helper candidate table page up signal.
3377 * This signal is used to do something when candidate table is paged up.
3379 * The prototype of the slot is:
3380 * void candidate_table_page_up (const HelperAgent *agent, int ic, const String &uuid);
3383 HelperAgent::signal_connect_candidate_table_page_up (HelperAgentSlotVoid *slot)
3385 return m_impl->signal_candidate_table_page_up.connect (slot);
3389 * @brief Connect a slot to Helper candidate table page down signal.
3391 * This signal is used to do something when candidate table is paged down.
3393 * The prototype of the slot is:
3394 * void candidate_table_page_down (const HelperAgent *agent, int ic, const String &uuid);
3397 HelperAgent::signal_connect_candidate_table_page_down (HelperAgentSlotVoid *slot)
3399 return m_impl->signal_candidate_table_page_down.connect (slot);
3403 * @brief Connect a slot to Helper update candidate table page size signal.
3405 * This signal is used to do something when candidate table page size is changed.
3407 * The prototype of the slot is:
3408 * void update_candidate_table_page_size (const HelperAgent *, int ic, const String &uuid, int page_size);
3411 HelperAgent::signal_connect_update_candidate_table_page_size (HelperAgentSlotInt *slot)
3413 return m_impl->signal_update_candidate_table_page_size.connect (slot);
3417 * @brief Connect a slot to Helper update candidate item layout signal.
3419 * The prototype of the slot is:
3420 * void update_candidate_item_layout (const HelperAgent *, const std::vector<uint32> &row_items);
3423 HelperAgent::signal_connect_update_candidate_item_layout (HelperAgentSlotUintVector *slot)
3425 return m_impl->signal_update_candidate_item_layout.connect (slot);
3429 * @brief Connect a slot to Helper select associate signal.
3431 * This signal is used to do something when associate is selected.
3433 * The prototype of the slot is:
3434 * void select_associate (const HelperAgent *agent, int ic, const String &uuid, int index);
3437 HelperAgent::signal_connect_select_associate (HelperAgentSlotInt *slot)
3439 return m_impl->signal_select_associate.connect (slot);
3443 * @brief Connect a slot to Helper associate table page up signal.
3445 * This signal is used to do something when associate table is paged up.
3447 * The prototype of the slot is:
3448 * void associate_table_page_up (const HelperAgent *agent, int ic, const String &uuid);
3451 HelperAgent::signal_connect_associate_table_page_up (HelperAgentSlotVoid *slot)
3453 return m_impl->signal_associate_table_page_up.connect (slot);
3457 * @brief Connect a slot to Helper associate table page down signal.
3459 * This signal is used to do something when associate table is paged down.
3461 * The prototype of the slot is:
3462 * void associate_table_page_down (const HelperAgent *agent, int ic, const String &uuid);
3465 HelperAgent::signal_connect_associate_table_page_down (HelperAgentSlotVoid *slot)
3467 return m_impl->signal_associate_table_page_down.connect (slot);
3471 * @brief Connect a slot to Helper update associate table page size signal.
3473 * This signal is used to do something when associate table page size is changed.
3475 * The prototype of the slot is:
3476 * void update_associate_table_page_size (const HelperAgent *, int ic, const String &uuid, int page_size);
3479 HelperAgent::signal_connect_update_associate_table_page_size (HelperAgentSlotInt *slot)
3481 return m_impl->signal_update_associate_table_page_size.connect (slot);
3485 * @brief Connect a slot to Helper turn on log signal.
3487 * This signal is used to turn on Helper ISE debug information.
3489 * The prototype of the slot is:
3490 * void turn_on_log (const HelperAgent *agent, uint32 &on);
3493 HelperAgent::signal_connect_turn_on_log (HelperAgentSlotUintVoid *slot)
3495 return m_impl->signal_turn_on_log.connect (slot);
3499 * @brief Connect a slot to Helper update displayed candidate number signal.
3501 * This signal is used to inform helper ISE displayed candidate number.
3503 * The prototype of the slot is:
3504 * void update_displayed_candidate_number (const HelperAgent *, int ic, const String &uuid, int number);
3507 HelperAgent::signal_connect_update_displayed_candidate_number (HelperAgentSlotInt *slot)
3509 return m_impl->signal_update_displayed_candidate_number.connect (slot);
3513 * @brief Connect a slot to Helper longpress candidate signal.
3515 * This signal is used to do something when candidate is longpress.
3517 * The prototype of the slot is:
3518 * void longpress_candidate (const HelperAgent *agent, int ic, const String &uuid, int index);
3521 HelperAgent::signal_connect_longpress_candidate (HelperAgentSlotInt *slot)
3523 return m_impl->signal_longpress_candidate.connect (slot);
3527 * @brief Connect a slot to Helper show option window.
3529 * This signal is used to do request the ISE to show option window.
3531 * The prototype of the slot is:
3532 * void show_option_window (const HelperAgent *agent, int ic, const String &uuid);
3535 HelperAgent::signal_connect_show_option_window (HelperAgentSlotVoid *slot)
3537 return m_impl->signal_show_option_window.connect (slot);
3541 * @brief Connect a slot to Helper resume option window.
3543 * This signal is used to do request the ISE to resume option window.
3545 * The prototype of the slot is:
3546 * void resume_option_window (const HelperAgent *agent, int ic, const String &uuid);
3549 HelperAgent::signal_connect_resume_option_window (HelperAgentSlotVoid *slot)
3551 return m_impl->signal_resume_option_window.connect (slot);
3555 * @brief Connect a slot to Helper check if the option is available.
3557 * This signal is used to check if the option (setting) is available from Helper ISE.
3559 * The prototype of the slot is:
3560 * void check_option_window (const HelperAgent *agent, uint32 &avail);
3563 HelperAgent::signal_connect_check_option_window (HelperAgentSlotUintVoid *slot)
3565 return m_impl->signal_check_option_window.connect (slot);
3569 * @brief Connect a slot to Helper process unconventional input device event signal.
3571 * This signal is used to send unconventional input device event to Helper ISE.
3573 * The prototype of the slot is:
3574 * void process_input_device_event (const HelperAgent *, uint32 &type, char *data, size_t &size, uint32 &ret);
3577 HelperAgent::signal_connect_process_input_device_event (HelperAgentSlotUintCharSizeUint *slot)
3579 return m_impl->signal_process_input_device_event.connect (slot);
3583 * @brief Connect a slot to Helper set prediction hint signal.
3585 * This signal is used to send prediction hint to Helper ISE.
3587 * The prototype of the slot is:
3588 * void set_prediction_hint (const HelperAgent *agent, char *prediction_hint);
3591 HelperAgent::signal_connect_set_prediction_hint (HelperAgentSlotStringVoid *slot)
3593 return m_impl->signal_set_prediction_hint.connect (slot);
3597 * @brief Connect a slot to Helper set mime type signal.
3599 * This signal is used to send mime type to Helper ISE.
3601 * The prototype of the slot is:
3602 * void set_mime_type (const HelperAgent *agent, char *mime_type);
3605 HelperAgent::signal_connect_set_mime_type (HelperAgentSlotStringVoid *slot)
3607 return m_impl->signal_set_mime_type.connect (slot);
3611 * @brief Connect a slot to Helper set prediction hint data signal.
3613 * This signal is used to send prediction hint data to Helper ISE.
3615 * The prototype of the slot is:
3616 * void set_prediction_hint_data (const HelperAgent *agent, char *key, char *value);
3619 HelperAgent::signal_connect_set_prediction_hint_data (HelperAgentSlotString *slot)
3621 return m_impl->signal_set_prediction_hint_data.connect (slot);
3625 * @brief Connect a slot to Helper set optimization hint signal.
3627 * This signal is used to send optimization hint to Helper ISE.
3629 * The prototype of the slot is:
3630 * void set_optimization_hint (const HelperAgent *agent, uint32 &hint);
3633 HelperAgent::signal_connect_set_optimization_hint (HelperAgentSlotUintVoid *slot)
3635 return m_impl->signal_set_optimization_hint.connect (slot);
3639 * @brief Connect a slot to Helper process key event with imengine signal.
3641 * This signal is used to deliver the key event to Helper ISE.
3643 * The prototype of the slot is:
3644 * void process_key_event_with_imengine (const HelperAgent *agent, KeyEvent &key, uint32 &ret);
3647 HelperAgent::signal_connect_process_key_event_with_imengine (HelperAgentSlotKeyEventUint *slot)
3649 return m_impl->signal_process_key_event_with_imengine.connect (slot);
3653 * @brief Connect a slot to Helper set autocapital type signal.
3655 * This signal is used to send autocapital type to imengine.
3657 * The prototype of the slot is:
3658 * void set_autocapital_type (const HelperAgent *agent, uint32 &type);
3661 HelperAgent::signal_connect_set_autocapital_type (HelperAgentSlotUintVoid *slot)
3663 return m_impl->signal_set_autocapital_type.connect (slot);
3667 * @brief Connect a slot to Helper set prediction allow signal.
3669 * This signal is used to send prediction allow to imengine.
3671 * The prototype of the slot is:
3672 * void set_prediction_allow (const HelperAgent *agent, uint32 &prediction_allow);
3675 HelperAgent::signal_connect_set_prediction_allow (HelperAgentSlotUintVoid *slot)
3677 return m_impl->signal_set_prediction_allow.connect (slot);
3680 } /* namespace scim */
3683 vi:ts=4:nowrap:ai:expandtab