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 Signal3<void, const HelperAgent *, KeyEvent &, uint32>
137 HelperAgentSignalKeyEventUint2;
139 typedef Signal4<void, const HelperAgent *, KeyEvent &, uint32 &, uint32>
140 HelperAgentSignalKeyEventUintUint;
142 typedef Signal5<void, const HelperAgent *, uint32 &, char *, size_t &, uint32 &>
143 HelperAgentSignalUintCharSizeUint;
145 typedef Signal2<void, const HelperAgent *, const String &>
146 HelperAgentSignalStringVoid;
148 class HelperAgent::HelperAgentImpl
152 SocketClient socket_active;
161 IMEngineInstancePointer si;
162 ConfigPointer m_config;
163 IMEngineModule engine_module;
165 char* surrounding_text;
166 char* selection_text;
168 int need_update_surrounding_text;
169 int need_update_selection_text;
172 bool hw_keyboard_mode;
173 bool need_update_entry_metadata;
175 char* finalized_text;
176 uint32 finalized_cursor_pos;
177 bool engine_loader_flag;
179 HelperAgentSignalVoid signal_exit;
180 HelperAgentSignalVoid signal_attach_input_context;
181 HelperAgentSignalVoid signal_detach_input_context;
182 HelperAgentSignalVoid signal_reload_config;
183 HelperAgentSignalInt signal_update_screen;
184 HelperAgentSignalIntInt signal_update_spot_location;
185 HelperAgentSignalInt signal_update_cursor_position;
186 HelperAgentSignalInt signal_update_surrounding_text;
187 HelperAgentSignalVoid signal_update_selection;
188 HelperAgentSignalString signal_trigger_property;
189 HelperAgentSignalTransaction signal_process_imengine_event;
190 HelperAgentSignalVoid signal_focus_out;
191 HelperAgentSignalVoid signal_focus_in;
192 HelperAgentSignalIntRawVoid signal_ise_show;
193 HelperAgentSignalVoid signal_ise_hide;
194 HelperAgentSignalVoid signal_candidate_show;
195 HelperAgentSignalVoid signal_candidate_hide;
196 HelperAgentSignalSize signal_get_geometry;
197 HelperAgentSignalUintVoid signal_set_mode;
198 HelperAgentSignalUintVoid signal_set_language;
199 HelperAgentSignalRawVoid signal_set_imdata;
200 HelperAgentSignalGetRawVoid signal_get_imdata;
201 HelperAgentSignalIntGetStringVoid signal_get_language_locale;
202 HelperAgentSignalUintVoid signal_set_return_key_type;
203 HelperAgentSignalUintVoid signal_get_return_key_type;
204 HelperAgentSignalUintVoid signal_set_return_key_disable;
205 HelperAgentSignalUintVoid signal_get_return_key_disable;
206 HelperAgentSignalUintVoid signal_set_layout;
207 HelperAgentSignalUintVoid signal_get_layout;
208 HelperAgentSignalUintVoid signal_set_caps_mode;
209 HelperAgentSignalVoid signal_reset_input_context;
210 HelperAgentSignalIntInt signal_update_candidate_ui;
211 HelperAgentSignalRect signal_update_candidate_geometry;
212 HelperAgentSignalString2 signal_update_keyboard_ise;
213 HelperAgentSignalStringVector signal_update_keyboard_ise_list;
214 HelperAgentSignalVoid signal_candidate_more_window_show;
215 HelperAgentSignalVoid signal_candidate_more_window_hide;
216 HelperAgentSignalLookupTable signal_update_lookup_table;
217 HelperAgentSignalInt signal_select_aux;
218 HelperAgentSignalInt signal_select_candidate;
219 HelperAgentSignalVoid signal_candidate_table_page_up;
220 HelperAgentSignalVoid signal_candidate_table_page_down;
221 HelperAgentSignalInt signal_update_candidate_table_page_size;
222 HelperAgentSignalUintVector signal_update_candidate_item_layout;
223 HelperAgentSignalInt signal_select_associate;
224 HelperAgentSignalVoid signal_associate_table_page_up;
225 HelperAgentSignalVoid signal_associate_table_page_down;
226 HelperAgentSignalInt signal_update_associate_table_page_size;
227 HelperAgentSignalVoid signal_reset_ise_context;
228 HelperAgentSignalUintVoid signal_turn_on_log;
229 HelperAgentSignalInt signal_update_displayed_candidate_number;
230 HelperAgentSignalInt signal_longpress_candidate;
231 HelperAgentSignalKeyEventUint signal_process_key_event;
232 HelperAgentSignalKeyEventUintUint signal_process_key_event_with_keycode;
233 HelperAgentSignalUintVoid signal_set_input_mode;
234 HelperAgentSignalUintVoid signal_set_input_hint;
235 HelperAgentSignalUintVoid signal_update_bidi_direction;
236 HelperAgentSignalVoid signal_show_option_window;
237 HelperAgentSignalVoid signal_resume_option_window;
238 HelperAgentSignalUintVoid signal_check_option_window;
239 HelperAgentSignalUintCharSizeUint signal_process_input_device_event;
240 HelperAgentSignalStringVoid signal_set_prediction_hint;
241 HelperAgentSignalStringVoid signal_set_mime_type;
242 HelperAgentSignalString signal_set_prediction_hint_data;
243 HelperAgentSignalUintVoid signal_set_optimization_hint;
244 HelperAgentSignalKeyEventUint2 signal_process_key_event_with_imengine;
245 HelperAgentSignalUintVoid signal_set_autocapital_type;
246 HelperAgentSignalUintVoid signal_set_prediction_allow;
249 HelperAgentImpl (HelperAgent* thiz) : magic(0), magic_active(0), timeout(-1), focused_ic ((uint32) -1), thiz (thiz),
250 surrounding_text (NULL), selection_text (NULL), cursor_pos (0),
251 need_update_surrounding_text (0), need_update_selection_text (0),
252 layout (0), ise_show_flag (false), hw_keyboard_mode (false), need_update_entry_metadata (false), ise_focus_flag (false),
253 finalized_text(NULL), finalized_cursor_pos(0), engine_loader_flag(false) {
256 ~HelperAgentImpl () {
261 if (surrounding_text != NULL)
262 free (surrounding_text);
264 if (finalized_text != NULL)
265 free(finalized_text);
267 if (selection_text != NULL)
268 free (selection_text);
270 if (engine_module.valid ()) {
271 engine_module.unload ();
275 // Implementation of slot functions
277 slot_show_preedit_string (IMEngineInstanceBase *si)
279 thiz->show_preedit_string (focused_ic, "");
283 slot_show_aux_string (IMEngineInstanceBase *si)
285 thiz->show_aux_string ();
289 slot_show_lookup_table (IMEngineInstanceBase *si)
291 thiz->show_candidate_string ();
295 slot_hide_preedit_string (IMEngineInstanceBase *si)
297 thiz->hide_preedit_string (focused_ic, "");
301 slot_hide_aux_string (IMEngineInstanceBase *si)
303 thiz->hide_aux_string ();
307 slot_hide_lookup_table (IMEngineInstanceBase *si)
309 thiz->hide_candidate_string ();
313 slot_update_preedit_caret (IMEngineInstanceBase *si, int caret)
315 thiz->update_preedit_caret (caret);
319 slot_update_preedit_string (IMEngineInstanceBase *si,
320 const WideString & str,
321 const AttributeList & attrs,
324 thiz->update_preedit_string (-1, "", str, attrs, caret);
328 slot_update_preedit_string_with_commit (IMEngineInstanceBase *si,
329 const WideString & preedit,
330 const WideString & commit,
331 const AttributeList & attrs,
334 thiz->update_preedit_string (-1, "", preedit, commit, attrs, caret);
338 slot_update_aux_string (IMEngineInstanceBase *si,
339 const WideString & str,
340 const AttributeList & attrs)
342 thiz->update_aux_string (utf8_wcstombs(str), attrs);
346 slot_commit_string (IMEngineInstanceBase *si,
347 const WideString & str)
349 thiz->commit_string (-1, "", str);
353 slot_recapture_string (IMEngineInstanceBase *si,
356 const WideString & preedit,
357 const WideString & commit,
358 const AttributeList & attrs)
360 thiz->recapture_string (-1, "", offset, len, preedit, commit, attrs);
364 slot_forward_key_event (IMEngineInstanceBase *si,
365 const KeyEvent & key)
367 thiz->forward_key_event (-1, "", key);
371 slot_update_lookup_table (IMEngineInstanceBase *si,
372 const LookupTable & table)
374 thiz->update_candidate_string (table);
378 slot_register_properties (IMEngineInstanceBase *si,
379 const PropertyList & properties)
381 thiz->register_properties (properties);
385 slot_update_property (IMEngineInstanceBase *si,
386 const Property & property)
388 thiz->update_property (property);
392 slot_beep (IMEngineInstanceBase *si)
398 slot_start_helper (IMEngineInstanceBase *si,
399 const String &helper_uuid)
401 LOGW ("deprecated function");
405 slot_stop_helper (IMEngineInstanceBase *si,
406 const String &helper_uuid)
408 LOGW ("deprecated function");
412 slot_send_helper_event (IMEngineInstanceBase *si,
413 const String &helper_uuid,
414 const Transaction &trans)
416 signal_process_imengine_event (thiz, focused_ic, helper_uuid, trans);
420 slot_get_surrounding_text (IMEngineInstanceBase *si,
427 thiz->get_surrounding_text (maxlen_before, maxlen_after, _text, cursor);
428 text = utf8_mbstowcs(_text);
433 slot_delete_surrounding_text (IMEngineInstanceBase *si,
438 thiz->delete_surrounding_text (offset, len);
443 slot_get_selection (IMEngineInstanceBase *si,
447 thiz->get_selection_text (_text);
448 text = utf8_mbstowcs (_text);
453 slot_set_selection (IMEngineInstanceBase *si,
457 thiz->set_selection (start, end);
462 slot_expand_candidate (IMEngineInstanceBase *si)
464 thiz->expand_candidate ();
468 slot_contract_candidate (IMEngineInstanceBase *si)
470 thiz->contract_candidate ();
474 slot_set_candidate_style (IMEngineInstanceBase *si, ISF_CANDIDATE_PORTRAIT_LINE_T portrait_line, ISF_CANDIDATE_MODE_T mode)
476 thiz->set_candidate_style (portrait_line, mode);
480 slot_send_private_command (IMEngineInstanceBase *si,
481 const String &command)
483 thiz->send_private_command (command);
487 slot_commit_content (IMEngineInstanceBase *si,
488 const String &content,
489 const String &description,
490 const String &mime_types)
493 thiz->commit_content (content, description, mime_types);
499 si->signal_connect_show_preedit_string (
500 slot (this, &HelperAgent::HelperAgentImpl::slot_show_preedit_string));
501 si->signal_connect_show_aux_string (
502 slot (this, &HelperAgent::HelperAgentImpl::slot_show_aux_string));
503 si->signal_connect_show_lookup_table (
504 slot (this, &HelperAgent::HelperAgentImpl::slot_show_lookup_table));
506 si->signal_connect_hide_preedit_string (
507 slot (this, &HelperAgent::HelperAgentImpl::slot_hide_preedit_string));
508 si->signal_connect_hide_aux_string (
509 slot (this, &HelperAgent::HelperAgentImpl::slot_hide_aux_string));
510 si->signal_connect_hide_lookup_table (
511 slot (this, &HelperAgent::HelperAgentImpl::slot_hide_lookup_table));
513 si->signal_connect_update_preedit_caret (
514 slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_caret));
515 si->signal_connect_update_preedit_string (
516 slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_string));
517 si->signal_connect_update_preedit_string_with_commit (
518 slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_string_with_commit));
519 si->signal_connect_recapture_string (
520 slot (this, &HelperAgent::HelperAgentImpl::slot_recapture_string));
522 si->signal_connect_update_aux_string (
523 slot (this, &HelperAgent::HelperAgentImpl::slot_update_aux_string));
524 si->signal_connect_update_lookup_table (
525 slot (this, &HelperAgent::HelperAgentImpl::slot_update_lookup_table));
527 si->signal_connect_commit_string (
528 slot (this, &HelperAgent::HelperAgentImpl::slot_commit_string));
530 si->signal_connect_forward_key_event (
531 slot (this, &HelperAgent::HelperAgentImpl::slot_forward_key_event));
533 si->signal_connect_register_properties (
534 slot (this, &HelperAgent::HelperAgentImpl::slot_register_properties));
536 si->signal_connect_update_property (
537 slot (this, &HelperAgent::HelperAgentImpl::slot_update_property));
539 si->signal_connect_beep (
540 slot (this, &HelperAgent::HelperAgentImpl::slot_beep));
542 si->signal_connect_start_helper (
543 slot (this, &HelperAgent::HelperAgentImpl::slot_start_helper));
545 si->signal_connect_stop_helper (
546 slot (this, &HelperAgent::HelperAgentImpl::slot_stop_helper));
548 si->signal_connect_send_helper_event (
549 slot (this, &HelperAgent::HelperAgentImpl::slot_send_helper_event));
551 si->signal_connect_get_surrounding_text (
552 slot (this, &HelperAgent::HelperAgentImpl::slot_get_surrounding_text));
554 si->signal_connect_delete_surrounding_text (
555 slot (this, &HelperAgent::HelperAgentImpl::slot_delete_surrounding_text));
557 si->signal_connect_get_selection (
558 slot (this, &HelperAgent::HelperAgentImpl::slot_get_selection));
560 si->signal_connect_set_selection (
561 slot (this, &HelperAgent::HelperAgentImpl::slot_set_selection));
563 si->signal_connect_expand_candidate (
564 slot (this, &HelperAgent::HelperAgentImpl::slot_expand_candidate));
565 si->signal_connect_contract_candidate (
566 slot (this, &HelperAgent::HelperAgentImpl::slot_contract_candidate));
568 si->signal_connect_set_candidate_style (
569 slot (this, &HelperAgent::HelperAgentImpl::slot_set_candidate_style));
571 si->signal_connect_send_private_command (
572 slot (this, &HelperAgent::HelperAgentImpl::slot_send_private_command));
575 void process_key_event_done (KeyEvent &key, uint32 ret, uint32 serial) {
576 LOGD ("ret: %d, serial: %d", ret, serial);
577 if (socket_active.is_connected ()) {
579 send.put_command (SCIM_TRANS_CMD_REQUEST);
580 send.put_data (magic_active);
581 send.put_command (ISM_TRANS_CMD_PROCESS_KEY_EVENT_DONE);
584 send.put_data (serial);
585 send.write_to_socket (socket_active, magic_active);
589 void request_ise_hide () {
590 if (socket_active.is_connected ()) {
592 send.put_command (SCIM_TRANS_CMD_REQUEST);
593 send.put_data (magic_active);
594 send.put_command (ISM_TRANS_CMD_REQUEST_ISE_HIDE);
595 send.write_to_socket (socket_active, magic_active);
599 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) { }
602 static MessageQueue message_queue;
604 HelperAgent::HelperAgent ()
605 : m_impl (new HelperAgentImpl (this))
607 message_queue.create();
610 HelperAgent::~HelperAgent ()
612 message_queue.destroy();
617 * @brief Open socket connection to the Panel.
619 * @param info The information of this Helper object.
620 * @param display The display which this Helper object should run on.
622 * @return The connection socket id. -1 means failed to create
626 HelperAgent::open_connection (const HelperInfo &info,
627 const String &display)
629 if (m_impl->socket.is_connected ())
632 SocketAddress address (scim_get_default_panel_socket_address (display));
633 int timeout = m_impl->timeout = scim_get_default_socket_timeout ();
636 if (!address.valid ())
640 std::cerr << " Connecting to PanelAgent server.";
641 ISF_LOG (" Connecting to PanelAgent server.\n");
642 while (!m_impl->socket.connect (address)) {
644 scim_usleep (100000);
646 std::cerr << "m_impl->socket.connect () is failed!!!\n";
647 ISF_LOG ("m_impl->socket.connect () is failed!!!\n");
651 std::cerr << " Connected :" << i << "\n";
652 ISF_LOG (" Connected :%d\n", i);
653 LOGD ("Connection to PanelAgent succeeded, %d", i);
655 /* Let's retry 10 times when failed */
656 int open_connection_retries = 0;
657 while (!scim_socket_open_connection (magic,
662 if (++open_connection_retries > 10) {
663 m_impl->socket.close ();
664 std::cerr << "scim_socket_open_connection () is failed!!!\n";
665 ISF_LOG ("scim_socket_open_connection () is failed!!!\n");
666 ISF_SAVE_LOG ("scim_socket_open_connection failed, %d", timeout);
671 /* Retry after re-connecting the socket */
672 if (m_impl->socket.is_connected ())
675 /* This time, just retry atmost 2 seconds */
677 while (!m_impl->socket.connect (address) && ++i < 10) {
678 scim_usleep (200000);
682 ISF_LOG ("scim_socket_open_connection () is successful.\n");
683 LOGD ("scim_socket_open_connection successful");
685 m_impl->send.clear ();
686 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
687 m_impl->send.put_data (magic);
688 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_REGISTER_HELPER);
689 m_impl->send.put_data (info.uuid);
690 m_impl->send.put_data (info.name);
691 m_impl->send.put_data (info.icon);
692 m_impl->send.put_data (info.description);
693 m_impl->send.put_data (info.option);
695 if (!m_impl->send.write_to_socket (m_impl->socket, magic)) {
696 m_impl->socket.close ();
701 if (m_impl->recv.read_from_socket (m_impl->socket, timeout) &&
702 m_impl->recv.get_command (cmd) && cmd == SCIM_TRANS_CMD_REPLY &&
703 m_impl->recv.get_command (cmd) && cmd == SCIM_TRANS_CMD_OK) {
704 m_impl->magic = magic;
706 while (m_impl->recv.get_command (cmd)) {
708 case SCIM_TRANS_CMD_HELPER_ATTACH_INPUT_CONTEXT:
712 while (m_impl->recv.get_data (ic) && m_impl->recv.get_data (ic_uuid))
713 m_impl->signal_attach_input_context (this, ic, ic_uuid);
716 case SCIM_TRANS_CMD_UPDATE_SCREEN:
719 if (m_impl->recv.get_data (screen))
720 m_impl->signal_update_screen (this, (uint32) -1, String (""), (int) screen);
728 //FIXME: Attaching input context is needed for desktop environment
729 LOGW ("Attach input context and update screen failed");
732 ISF_SAVE_LOG ("Trying connect() with Helper_Active");
734 /* connect to the panel agent as the active helper client */
735 if (!m_impl->socket_active.connect (address)) return -1;
736 open_connection_retries = 0;
737 while (!scim_socket_open_connection (magic,
738 String ("Helper_Active"),
740 m_impl->socket_active,
742 if (++open_connection_retries > 10) {
743 m_impl->socket_active.close ();
744 std::cerr << "Helper_Active scim_socket_open_connection () is failed!!!\n";
745 ISF_LOG ("Helper_Active scim_socket_open_connection () is failed!!!\n");
746 ISF_SAVE_LOG ("Helper_Active scim_socket_open_connection failed, %d", timeout);
751 /* Retry after re-connecting the socket */
752 if (m_impl->socket_active.is_connected ())
753 m_impl->socket_active.close ();
755 /* This time, just retry atmost 2 seconds */
757 while (!m_impl->socket_active.connect (address) && ++i < 10) {
758 scim_usleep (200000);
762 m_impl->magic_active = magic;
764 m_impl->send.clear ();
765 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
766 m_impl->send.put_data (magic);
767 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_REGISTER_ACTIVE_HELPER);
768 m_impl->send.put_data (info.uuid);
769 m_impl->send.put_data (info.name);
770 m_impl->send.put_data (info.icon);
771 m_impl->send.put_data (info.description);
772 m_impl->send.put_data (info.option);
774 if (!m_impl->send.write_to_socket (m_impl->socket_active, magic)) {
775 ISF_SAVE_LOG ("Helper_Active write_to_socket() failed");
776 m_impl->socket_active.close ();
779 m_impl->m_config = ConfigBase::get (false, "socket");
781 return m_impl->socket.get_id ();
785 * @brief Close the socket connection to Panel.
788 HelperAgent::close_connection ()
790 m_impl->socket.close ();
791 m_impl->socket_active.close ();
792 m_impl->send.clear ();
793 m_impl->recv.clear ();
795 m_impl->magic_active = 0;
800 * @brief Get the connection id previously returned by open_connection().
802 * @return the connection id
805 HelperAgent::get_connection_number () const
807 if (m_impl->socket.is_connected ())
808 return m_impl->socket.get_id ();
813 * @brief Check whether this HelperAgent has been connected to a Panel.
815 * Return true when it is connected to panel, otherwise return false.
818 HelperAgent::is_connected () const
820 return m_impl->socket.is_connected ();
824 * @brief Check if there are any events available to be processed.
826 * If it returns true then Helper object should call
827 * HelperAgent::filter_event() to process them.
829 * @return true if there are any events available.
832 HelperAgent::has_pending_event () const
834 if (m_impl->socket.is_connected () && m_impl->socket.wait_for_data (0) > 0)
837 if (message_queue.has_pending_message())
844 * @brief Process the pending events.
846 * This function will emit the corresponding signals according
849 * @return false if the connection is broken, otherwise return true.
852 HelperAgent::filter_event ()
854 if (!m_impl->socket.is_connected ()) {
855 LOGW("Connection lost, returning false");
859 if (m_impl->recv.read_from_socket (m_impl->socket, m_impl->timeout)) {
860 message_queue.read_from_transaction(m_impl->recv);
862 while (message_queue.has_pending_message()) {
863 MessageItem *message = message_queue.get_pending_message();
864 handle_message(message);
865 message_queue.remove_message(message);
868 LOGD("read_from_socket() failed but continuing");
876 * @brief Read messages from socket buffer, and see if there is a message with the given cmd.
878 * @return false if the connection is broken, or no message available with given cmd. Otherwise return true.
881 HelperAgent::wait_for_message(int cmd, int timeout)
883 struct timeval t0 = { 0, 0 };
884 struct timeval t1 = { 0, 0 };
885 struct timeval t2 = { 0, 0 };
887 gettimeofday(&t0, NULL);
890 if (!m_impl->socket.is_connected() || !m_impl->recv.read_from_socket(m_impl->socket, timeout))
893 message_queue.read_from_transaction(m_impl->recv);
894 if (message_queue.has_pending_message_by_cmd(cmd)) {
898 gettimeofday(&t1, NULL);
899 timersub(&t1, &t0, &t2);
900 } while (t2.tv_sec < timeout);
906 * @brief Process one message that is in our message queue.
908 * This function will emit the corresponding signals according
911 * @param message The message that needs to be handled.
913 * @return false if the connection is broken, otherwise return true.
916 HelperAgent::handle_message (MessageItem *message)
921 int cmd = message->get_command_ref();
922 LOGD ("HelperAgent::cmd = %d", cmd);
924 case SCIM_TRANS_CMD_EXIT:
926 MessageItemExit *subclass = static_cast<MessageItemExit*>(message);
927 ISF_SAVE_LOG ("Helper ISE received SCIM_TRANS_CMD_EXIT message");
928 m_impl->signal_exit(this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
931 case SCIM_TRANS_CMD_RELOAD_CONFIG:
933 MessageItemReloadConfig *subclass = static_cast<MessageItemReloadConfig*>(message);
934 m_impl->signal_reload_config (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
935 if (!m_impl->m_config.null())
936 m_impl->m_config->ConfigBase::reload();
939 case SCIM_TRANS_CMD_UPDATE_SCREEN:
941 MessageItemUpdateScreen *subclass = static_cast<MessageItemUpdateScreen*>(message);
942 m_impl->signal_update_screen (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
943 subclass->get_screen_ref());
946 case SCIM_TRANS_CMD_UPDATE_SPOT_LOCATION:
948 MessageItemUpdateSpotLocation *subclass = static_cast<MessageItemUpdateSpotLocation*>(message);
949 m_impl->signal_update_spot_location (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
950 subclass->get_x_ref(), subclass->get_y_ref());
953 case ISM_TRANS_CMD_UPDATE_CURSOR_POSITION:
955 MessageItemUpdateCursorPosition *subclass = static_cast<MessageItemUpdateCursorPosition*>(message);
956 m_impl->cursor_pos = subclass->get_cursor_pos_ref();
957 LOGD ("update cursor position %d", subclass->get_cursor_pos_ref());
958 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode || m_impl->need_update_entry_metadata) {
959 m_impl->signal_update_cursor_position (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
960 subclass->get_cursor_pos_ref());
962 if (!m_impl->si.null ()) m_impl->si->update_cursor_position(subclass->get_cursor_pos_ref());
965 case ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT:
967 MessageItemUpdateSurroundingText *subclass = static_cast<MessageItemUpdateSurroundingText*>(message);
968 if (m_impl->surrounding_text != NULL)
969 free (m_impl->surrounding_text);
970 m_impl->surrounding_text = strdup (subclass->get_text_ref().c_str ());
971 m_impl->cursor_pos = subclass->get_cursor_ref();
972 SECURE_LOGD ("surrounding text: %s, %d", m_impl->surrounding_text, subclass->get_cursor_ref());
973 while (m_impl->need_update_surrounding_text > 0) {
974 m_impl->need_update_surrounding_text--;
975 m_impl->signal_update_surrounding_text (this, subclass->get_ic_ref(),
976 subclass->get_text_ref(), subclass->get_cursor_ref());
980 case ISM_TRANS_CMD_UPDATE_SELECTION:
982 MessageItemUpdateSelection *subclass = static_cast<MessageItemUpdateSelection*>(message);
983 if (m_impl->selection_text != NULL)
984 free (m_impl->selection_text);
986 m_impl->selection_text = strdup (subclass->get_text_ref().c_str ());
987 SECURE_LOGD ("selection text: %s", m_impl->selection_text);
989 while (m_impl->need_update_selection_text > 0) {
990 m_impl->need_update_selection_text--;
991 m_impl->signal_update_selection (this, subclass->get_ic_ref(), subclass->get_text_ref());
995 case SCIM_TRANS_CMD_TRIGGER_PROPERTY:
997 MessageItemTriggerProperty *subclass = static_cast<MessageItemTriggerProperty*>(message);
998 m_impl->signal_trigger_property (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
999 subclass->get_property_ref());
1000 if (!m_impl->si.null ()) m_impl->si->trigger_property(subclass->get_property_ref());
1003 case SCIM_TRANS_CMD_HELPER_PROCESS_IMENGINE_EVENT:
1005 MessageItemHelperProcessImengineEvent *subclass = static_cast<MessageItemHelperProcessImengineEvent*>(message);
1006 m_impl->signal_process_imengine_event (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1007 subclass->get_transaction_ref());
1010 case SCIM_TRANS_CMD_HELPER_ATTACH_INPUT_CONTEXT:
1012 MessageItemHelperAttachInputContext *subclass = static_cast<MessageItemHelperAttachInputContext*>(message);
1013 m_impl->signal_attach_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1016 case SCIM_TRANS_CMD_HELPER_DETACH_INPUT_CONTEXT:
1018 MessageItemHelperDetachInputContext *subclass = static_cast<MessageItemHelperDetachInputContext*>(message);
1019 m_impl->signal_detach_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1022 case SCIM_TRANS_CMD_FOCUS_OUT:
1024 MessageItemFocusOut *subclass = static_cast<MessageItemFocusOut*>(message);
1025 m_impl->ise_focus_flag = false;
1026 m_impl->signal_focus_out (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1027 m_impl->focused_ic = (uint32) -1;
1028 if (!m_impl->si.null ()) m_impl->si->focus_out();
1030 m_impl->ise_show_flag = false;
1031 m_impl->need_update_entry_metadata = false;
1034 case SCIM_TRANS_CMD_FOCUS_IN:
1036 MessageItemFocusIn *subclass = static_cast<MessageItemFocusIn*>(message);
1037 m_impl->ise_focus_flag = true;
1039 m_impl->need_update_entry_metadata = false;
1040 m_impl->signal_focus_in (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1041 m_impl->focused_ic = subclass->get_ic_ref();
1042 if (m_impl->finalized_text != NULL)
1043 free(m_impl->finalized_text);
1044 m_impl->finalized_text = NULL;
1045 m_impl->finalized_cursor_pos = 0;
1046 if (!m_impl->si.null ()) m_impl->si->focus_in();
1049 case ISM_TRANS_CMD_SHOW_ISE_PANEL:
1051 MessageItemShowISEPanel *subclass = static_cast<MessageItemShowISEPanel*>(message);
1052 LOGD ("Helper ISE received ISM_TRANS_CMD_SHOW_ISE_PANEL message");
1054 m_impl->signal_ise_show (this, subclass->get_ic_ref(), *(subclass->get_data_ptr()),
1055 subclass->get_len_ref());
1056 m_impl->ise_show_flag = true;
1059 case ISM_TRANS_CMD_HIDE_ISE_PANEL:
1061 MessageItemHideISEPanel *subclass = static_cast<MessageItemHideISEPanel*>(message);
1062 LOGD ("Helper ISE received ISM_TRANS_CMD_HIDE_ISE_PANEL message");
1063 if (m_impl->ise_show_flag)
1064 m_impl->signal_ise_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1065 m_impl->ise_show_flag = false;
1068 case ISM_TRANS_CMD_GET_ACTIVE_ISE_GEOMETRY:
1070 struct rectinfo info = {0, 0, 0, 0};
1071 m_impl->signal_get_geometry (this, info);
1072 m_impl->send.clear ();
1073 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1074 m_impl->send.put_data (info.pos_x);
1075 m_impl->send.put_data (info.pos_y);
1076 m_impl->send.put_data (info.width);
1077 m_impl->send.put_data (info.height);
1078 m_impl->send.write_to_socket (m_impl->socket);
1081 case ISM_TRANS_CMD_SET_ISE_MODE:
1083 MessageItemSetISEMode *subclass = static_cast<MessageItemSetISEMode*>(message);
1084 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode || m_impl->need_update_entry_metadata) {
1085 m_impl->signal_set_mode (this, subclass->get_mode_ref());
1089 case ISM_TRANS_CMD_SET_ISE_LANGUAGE:
1091 MessageItemSetISELanguage *subclass = static_cast<MessageItemSetISELanguage*>(message);
1092 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode || m_impl->need_update_entry_metadata) {
1093 m_impl->signal_set_language (this, subclass->get_language_ref());
1097 case ISM_TRANS_CMD_SET_ISE_IMDATA:
1099 MessageItemSetISEImData *subclass = static_cast<MessageItemSetISEImData*>(message);
1100 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode) {
1101 m_impl->signal_set_imdata (this, *(subclass->get_imdata_ptr()), subclass->get_len_ref());
1103 if (!m_impl->si.null ()) m_impl->si->set_imdata(*(subclass->get_imdata_ptr()),
1104 subclass->get_len_ref());
1107 case ISM_TRANS_CMD_GET_ISE_IMDATA:
1112 m_impl->signal_get_imdata (this, &buf, len);
1113 LOGD ("send ise imdata len = %zu", len);
1114 m_impl->send.clear ();
1115 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1116 m_impl->send.put_data (buf, len);
1117 m_impl->send.write_to_socket (m_impl->socket);
1122 case ISM_TRANS_CMD_GET_ISE_LANGUAGE_LOCALE:
1124 MessageItemGetISELanguageLocale *subclass = static_cast<MessageItemGetISELanguageLocale*>(message);
1126 m_impl->signal_get_language_locale (this, subclass->get_ic_ref(), &buf);
1127 m_impl->send.clear ();
1128 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1130 m_impl->send.put_data (buf, strlen (buf));
1131 m_impl->send.write_to_socket (m_impl->socket);
1136 case ISM_TRANS_CMD_SET_RETURN_KEY_TYPE:
1138 MessageItemSetReturnKeyType *subclass = static_cast<MessageItemSetReturnKeyType*>(message);
1139 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode || m_impl->need_update_entry_metadata) {
1140 m_impl->signal_set_return_key_type (this, subclass->get_type_ref());
1144 case ISM_TRANS_CMD_GET_RETURN_KEY_TYPE:
1147 m_impl->signal_get_return_key_type (this, type);
1148 m_impl->send.clear ();
1149 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1150 m_impl->send.put_data (type);
1151 m_impl->send.write_to_socket (m_impl->socket);
1154 case ISM_TRANS_CMD_SET_RETURN_KEY_DISABLE:
1156 MessageItemSetReturnKeyDisable *subclass = static_cast<MessageItemSetReturnKeyDisable*>(message);
1157 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode || m_impl->need_update_entry_metadata) {
1158 m_impl->signal_set_return_key_disable (this, subclass->get_disabled_ref());
1162 case ISM_TRANS_CMD_GET_RETURN_KEY_DISABLE:
1164 uint32 disabled = 0;
1165 m_impl->signal_get_return_key_type (this, disabled);
1166 m_impl->send.clear ();
1167 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1168 m_impl->send.put_data (disabled);
1169 m_impl->send.write_to_socket (m_impl->socket);
1172 case SCIM_TRANS_CMD_PROCESS_KEY_EVENT:
1174 MessageItemProcessKeyEvent *subclass = static_cast<MessageItemProcessKeyEvent*>(message);
1176 uint32 keycode_ret = 0;
1177 m_impl->signal_process_key_event(this, subclass->get_key_ref(), ret);
1178 m_impl->signal_process_key_event_with_keycode(this, subclass->get_key_ref(), keycode_ret, subclass->get_keycode_ref());
1180 if (ret != 0 && keycode_ret != 0) {
1182 m_impl->process_key_event_done (subclass->get_key_ref(), ret, subclass->get_serial_ref());
1184 if (!(subclass->get_key_ref().get_key_string().compare("KeyRelease+XF86Back") == 0 ||
1185 subclass->get_key_ref().get_key_string().compare("XF86Back") == 0)) {
1186 if (m_impl->engine_loader_flag) {
1187 m_impl->signal_process_key_event_with_imengine(this, subclass->get_key_ref(), subclass->get_serial_ref());
1188 SECURE_LOGD ("imengine process key %d", subclass->get_key_ref().code);
1190 if (!m_impl->si.null ()) {
1191 ret = m_impl->si->process_key_event (subclass->get_key_ref());
1192 SECURE_LOGD ("imengine(%s) process key %d return %d", m_impl->si->get_factory_uuid().c_str(),
1193 subclass->get_key_ref().code, ret);
1195 m_impl->process_key_event_done (subclass->get_key_ref(), ret, subclass->get_serial_ref());
1198 m_impl->process_key_event_done (subclass->get_key_ref(), ret, subclass->get_serial_ref());
1202 case ISM_TRANS_CMD_SET_LAYOUT:
1204 MessageItemSetLayout *subclass = static_cast<MessageItemSetLayout*>(message);
1205 m_impl->layout = subclass->get_layout_ref();
1206 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode || m_impl->need_update_entry_metadata) {
1207 m_impl->signal_set_layout (this, subclass->get_layout_ref());
1209 if (!m_impl->si.null ()) m_impl->si->set_layout(subclass->get_layout_ref());
1212 case ISM_TRANS_CMD_GET_LAYOUT:
1216 m_impl->signal_get_layout (this, layout);
1217 m_impl->send.clear ();
1218 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1219 m_impl->send.put_data (layout);
1220 m_impl->send.write_to_socket (m_impl->socket);
1223 case ISM_TRANS_CMD_SET_INPUT_MODE:
1225 MessageItemSetInputMode *subclass = static_cast<MessageItemSetInputMode*>(message);
1226 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode || m_impl->need_update_entry_metadata) {
1227 m_impl->signal_set_input_mode (this, subclass->get_input_mode_ref());
1231 case ISM_TRANS_CMD_SET_CAPS_MODE:
1233 MessageItemSetCapsMode *subclass = static_cast<MessageItemSetCapsMode*>(message);
1234 m_impl->signal_set_caps_mode (this, subclass->get_mode_ref());
1237 case SCIM_TRANS_CMD_PANEL_RESET_INPUT_CONTEXT:
1239 MessageItemPanelResetInputContext *subclass = static_cast<MessageItemPanelResetInputContext*>(message);
1240 m_impl->signal_reset_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1241 if (!m_impl->si.null ()) m_impl->si->reset();
1244 case ISM_TRANS_CMD_UPDATE_CANDIDATE_UI:
1246 MessageItemUpdateCandidateUI *subclass = static_cast<MessageItemUpdateCandidateUI*>(message);
1247 m_impl->signal_update_candidate_ui (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1248 subclass->get_style_ref(), subclass->get_mode_ref());
1251 case ISM_TRANS_CMD_UPDATE_CANDIDATE_GEOMETRY:
1253 MessageItemUpdateCandidateGeometry *subclass = static_cast<MessageItemUpdateCandidateGeometry*>(message);
1254 m_impl->signal_update_candidate_geometry (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1255 subclass->get_rectinfo_ref());
1258 case ISM_TRANS_CMD_UPDATE_KEYBOARD_ISE:
1260 MessageItemUpdateKeyboardISE *subclass = static_cast<MessageItemUpdateKeyboardISE*>(message);
1261 m_impl->signal_update_keyboard_ise (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1262 subclass->get_name_ref(), subclass->get_uuid_ref());
1265 case ISM_TRANS_CMD_UPDATE_KEYBOARD_ISE_LIST:
1267 MessageItemUpdateKeyboardISEList *subclass = static_cast<MessageItemUpdateKeyboardISEList*>(message);
1268 m_impl->signal_update_keyboard_ise_list (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1269 subclass->get_list_ref());
1272 case ISM_TRANS_CMD_CANDIDATE_MORE_WINDOW_SHOW:
1274 MessageItemCandidateMoreWindowShow *subclass = static_cast<MessageItemCandidateMoreWindowShow*>(message);
1275 m_impl->signal_candidate_more_window_show (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1276 if (!m_impl->si.null ()) m_impl->si->candidate_more_window_show();
1279 case ISM_TRANS_CMD_CANDIDATE_MORE_WINDOW_HIDE:
1281 MessageItemCandidateMoreWindowHide *subclass = static_cast<MessageItemCandidateMoreWindowHide*>(message);
1282 m_impl->signal_candidate_more_window_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1283 if (!m_impl->si.null ()) m_impl->si->candidate_more_window_hide();
1286 case ISM_TRANS_CMD_SELECT_AUX:
1288 MessageItemSelectAux *subclass = static_cast<MessageItemSelectAux*>(message);
1289 m_impl->signal_select_aux (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1290 subclass->get_item_ref());
1291 if (!m_impl->si.null ()) m_impl->si->select_aux(subclass->get_item_ref());
1294 case SCIM_TRANS_CMD_SELECT_CANDIDATE: //FIXME:remove if useless
1296 MessageItemSelectCandidate *subclass = static_cast<MessageItemSelectCandidate*>(message);
1297 m_impl->signal_select_candidate (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1298 subclass->get_item_ref());
1299 if (!m_impl->si.null ()) m_impl->si->select_candidate(subclass->get_item_ref());
1302 case SCIM_TRANS_CMD_LOOKUP_TABLE_PAGE_UP: //FIXME:remove if useless
1304 MessageItemLookupTablePageUp *subclass = static_cast<MessageItemLookupTablePageUp*>(message);
1305 m_impl->signal_candidate_table_page_up (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1306 if (!m_impl->si.null ()) m_impl->si->lookup_table_page_up();
1309 case SCIM_TRANS_CMD_LOOKUP_TABLE_PAGE_DOWN: //FIXME:remove if useless
1311 MessageItemLookupTablePageDown *subclass = static_cast<MessageItemLookupTablePageDown*>(message);
1312 m_impl->signal_candidate_table_page_down (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1313 if (!m_impl->si.null ()) m_impl->si->lookup_table_page_down();
1316 case SCIM_TRANS_CMD_UPDATE_LOOKUP_TABLE_PAGE_SIZE:
1318 MessageItemUpdateLookupTablePageSize *subclass = static_cast<MessageItemUpdateLookupTablePageSize*>(message);
1319 m_impl->signal_update_candidate_table_page_size (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1320 subclass->get_size_ref());
1321 if (!m_impl->si.null ()) m_impl->si->update_lookup_table_page_size(subclass->get_size_ref());
1324 case ISM_TRANS_CMD_CANDIDATE_SHOW: //FIXME:remove if useless
1326 MessageItemCandidateShow *subclass = static_cast<MessageItemCandidateShow*>(message);
1327 m_impl->signal_candidate_show (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1330 case ISM_TRANS_CMD_CANDIDATE_HIDE: //FIXME:remove if useless
1332 MessageItemCandidateHide *subclass = static_cast<MessageItemCandidateHide*>(message);
1333 m_impl->signal_candidate_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1336 case ISM_TRANS_CMD_UPDATE_LOOKUP_TABLE: //FIXME:remove if useless
1338 MessageItemUpdateLookupTable *subclass = static_cast<MessageItemUpdateLookupTable*>(message);
1339 m_impl->signal_update_lookup_table (this, subclass->get_candidate_table_ref());
1342 case ISM_TRANS_CMD_UPDATE_CANDIDATE_ITEM_LAYOUT:
1344 MessageItemUpdateCandidateItemLayout *subclass = static_cast<MessageItemUpdateCandidateItemLayout*>(message);
1345 m_impl->signal_update_candidate_item_layout (this, subclass->get_row_items_ref());
1346 if (!m_impl->si.null ()) m_impl->si->update_candidate_item_layout(subclass->get_row_items_ref());
1349 case ISM_TRANS_CMD_SELECT_ASSOCIATE:
1351 MessageItemSelectAssociate *subclass = static_cast<MessageItemSelectAssociate*>(message);
1352 m_impl->signal_select_associate (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1353 subclass->get_item_ref());
1356 case ISM_TRANS_CMD_ASSOCIATE_TABLE_PAGE_UP:
1358 MessageItemAssociateTablePageUp *subclass = static_cast<MessageItemAssociateTablePageUp*>(message);
1359 m_impl->signal_associate_table_page_up (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1362 case ISM_TRANS_CMD_ASSOCIATE_TABLE_PAGE_DOWN:
1364 MessageItemAssociateTablePageDown *subclass = static_cast<MessageItemAssociateTablePageDown*>(message);
1365 m_impl->signal_associate_table_page_down (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1368 case ISM_TRANS_CMD_UPDATE_ASSOCIATE_TABLE_PAGE_SIZE:
1370 MessageItemUpdateAssociateTablePageSize *subclass = static_cast<MessageItemUpdateAssociateTablePageSize*>(message);
1371 m_impl->signal_update_associate_table_page_size (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1372 subclass->get_size_ref());
1375 case ISM_TRANS_CMD_RESET_ISE_CONTEXT:
1377 MessageItemResetISEContext *subclass = static_cast<MessageItemResetISEContext*>(message);
1378 m_impl->signal_reset_ise_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1379 m_impl->signal_reset_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1380 if (!m_impl->si.null ()) m_impl->si->reset();
1383 case ISM_TRANS_CMD_TURN_ON_LOG:
1385 MessageItemTurnOnLog *subclass = static_cast<MessageItemTurnOnLog*>(message);
1386 m_impl->signal_turn_on_log (this, subclass->get_state_ref());
1389 case ISM_TRANS_CMD_UPDATE_DISPLAYED_CANDIDATE:
1391 MessageItemUpdateDisplayedCandidate *subclass = static_cast<MessageItemUpdateDisplayedCandidate*>(message);
1392 m_impl->signal_update_displayed_candidate_number (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1393 subclass->get_size_ref());
1394 if (!m_impl->si.null ()) m_impl->si->update_displayed_candidate_number(subclass->get_size_ref());
1397 case ISM_TRANS_CMD_LONGPRESS_CANDIDATE:
1399 MessageItemLongpressCandidate *subclass = static_cast<MessageItemLongpressCandidate*>(message);
1400 m_impl->signal_longpress_candidate (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1401 subclass->get_index_ref());
1402 if (!m_impl->si.null ()) m_impl->si->longpress_candidate(subclass->get_index_ref());
1405 case ISM_TRANS_CMD_SET_INPUT_HINT:
1407 MessageItemSetInputHint *subclass = static_cast<MessageItemSetInputHint*>(message);
1408 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode || m_impl->need_update_entry_metadata) {
1409 m_impl->signal_set_input_hint (this, subclass->get_input_hint_ref());
1411 if (!m_impl->si.null ()) m_impl->si->set_input_hint(subclass->get_input_hint_ref());
1414 case ISM_TRANS_CMD_UPDATE_BIDI_DIRECTION:
1416 MessageItemUpdateBidiDirection *subclass = static_cast<MessageItemUpdateBidiDirection*>(message);
1417 m_impl->signal_update_bidi_direction (this, subclass->get_bidi_direction());
1418 if (!m_impl->si.null ()) m_impl->si->update_bidi_direction(subclass->get_bidi_direction());
1421 case ISM_TRANS_CMD_SHOW_ISE_OPTION_WINDOW:
1423 MessageItemShowISEOptionWindow *subclass = static_cast<MessageItemShowISEOptionWindow*>(message);
1424 m_impl->signal_show_option_window (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1427 case ISM_TRANS_CMD_RESUME_ISE_OPTION_WINDOW:
1429 MessageItemResumeISEOptionWindow *subclass = static_cast<MessageItemResumeISEOptionWindow*>(message);
1430 m_impl->signal_resume_option_window (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1433 case ISM_TRANS_CMD_CHECK_OPTION_WINDOW:
1436 m_impl->signal_check_option_window (this, avail);
1437 m_impl->send.clear ();
1438 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1439 m_impl->send.put_data (avail);
1440 m_impl->send.write_to_socket (m_impl->socket);
1443 case ISM_TRANS_CMD_PROCESS_INPUT_DEVICE_EVENT:
1445 MessageItemProcessInputDeviceEvent *subclass = static_cast<MessageItemProcessInputDeviceEvent*>(message);
1447 unsigned int ecore_event_id = find_ecore_event_from_device_type((isf_device_type_e)(subclass->get_type_ref()));
1448 char *decoded = (char*)malloc(subclass->get_len_ref());
1449 size_t decoded_size = subclass->get_len_ref();
1451 if(device_buffer_decode((const char*)*(subclass->get_data_ptr()),
1452 subclass->get_len_ref(), (char*)(decoded), &decoded_size)) {
1453 m_impl->signal_process_input_device_event(this, ecore_event_id, decoded, decoded_size, ret);
1459 case SCIM_TRANS_CMD_SET_AUTOCAPITAL_TYPE:
1461 MessageItemSetAutocapitalType *subclass = static_cast<MessageItemSetAutocapitalType*>(message);
1462 if (!m_impl->si.null ()) m_impl->si->set_autocapital_type(subclass->get_auto_capital_type_ref());
1463 m_impl->signal_set_autocapital_type(this, subclass->get_auto_capital_type_ref());
1466 case ISM_TRANS_CMD_SET_PREDICTION_ALLOW:
1468 MessageItemSetPredictionAllow *subclass = static_cast<MessageItemSetPredictionAllow*>(message);
1469 if (!m_impl->si.null ()) m_impl->si->set_prediction_allow(subclass->get_prediction_allow_ref() == 0 ? false : true);
1470 m_impl->signal_set_prediction_allow(this, subclass->get_prediction_allow_ref());
1473 case ISM_TRANS_CMD_SET_KEYBOARD_MODE:
1475 MessageItemSetKeyboardMode *subclass = static_cast<MessageItemSetKeyboardMode*>(message);
1476 if (subclass->get_mode_ref())
1477 m_impl->hw_keyboard_mode = false;
1479 m_impl->hw_keyboard_mode = true;
1482 case ISM_TRANS_CMD_SET_PREDICTION_HINT:
1484 MessageItemSetPredictionHint *subclass = static_cast<MessageItemSetPredictionHint*>(message);
1485 m_impl->signal_set_prediction_hint (this, subclass->get_message_ref());
1488 case ISM_TRANS_CMD_SET_MIME_TYPE:
1490 MessageItemSetMimeType *subclass = static_cast<MessageItemSetMimeType*>(message);
1491 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode || m_impl->need_update_entry_metadata) {
1492 m_impl->signal_set_mime_type (this, subclass->get_mime_type_ref());
1496 case ISM_TRANS_CMD_FINALIZE_CONTENT:
1498 MessageItemFinalizeContent *subclass = static_cast<MessageItemFinalizeContent*>(message);
1500 if (m_impl->finalized_text != NULL)
1501 free(m_impl->finalized_text);
1502 m_impl->finalized_text = strdup(subclass->get_text_ref().c_str());
1503 m_impl->finalized_cursor_pos = subclass->get_cursor_pos_ref();
1507 case ISM_TRANS_CMD_SET_PREDICTION_HINT_DATA:
1509 MessageItemSetPredictionHintData *subclass = static_cast<MessageItemSetPredictionHintData*>(message);
1510 m_impl->signal_set_prediction_hint_data (this, 0, subclass->get_key_ref(), subclass->get_value_ref());
1513 case ISM_TRANS_CMD_SET_OPTIMIZATION_HINT:
1515 MessageItemSetOptimizationHint *subclass = static_cast<MessageItemSetOptimizationHint*>(message);
1516 m_impl->signal_set_optimization_hint(this, subclass->get_hint_ref());
1526 * @brief Request SCIM to reload all configuration.
1528 * This function should only by used by Setup Helper to request
1529 * scim's reloading the configuration.
1530 * Deprecated: reload config message only send by socketconfig client
1531 * using socketconfig::reload instead.
1534 HelperAgent::reload_config () const
1536 LOGD ("send reload config message to isf");
1537 if (!m_impl->m_config.null())
1538 m_impl->m_config->reload();
1542 * @brief Register some properties into Panel.
1544 * This function send the request to Panel to register a list
1547 * @param properties The list of Properties to be registered into Panel.
1549 * @sa scim::Property.
1552 HelperAgent::register_properties (const PropertyList &properties) const
1554 if (m_impl->socket_active.is_connected ()) {
1555 m_impl->send.clear ();
1556 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1557 m_impl->send.put_data (m_impl->magic_active);
1558 m_impl->send.put_command (SCIM_TRANS_CMD_REGISTER_PROPERTIES);
1559 m_impl->send.put_data (properties);
1560 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1565 * @brief Update a registered property.
1567 * @param property The property to be updated.
1570 HelperAgent::update_property (const Property &property) const
1572 if (m_impl->socket_active.is_connected ()) {
1573 m_impl->send.clear ();
1574 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1575 m_impl->send.put_data (m_impl->magic_active);
1576 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PROPERTY);
1577 m_impl->send.put_data (property);
1578 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1583 * @brief Send a set of events to an IMEngineInstance.
1585 * All events should be put into a Transaction.
1586 * And the events can only be received by one IMEngineInstance object.
1588 * @param ic The handle of the Input Context to receive the events.
1589 * @param ic_uuid The UUID of the Input Context.
1590 * @param trans The Transaction object holds the events.
1593 HelperAgent::send_imengine_event (int ic,
1594 const String &ic_uuid,
1595 const Transaction &trans) const
1597 //remove if not necessary
1599 if (m_impl->socket_active.is_connected ()) {
1600 m_impl->send.clear ();
1601 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1602 m_impl->send.put_data (m_impl->magic_active);
1603 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_SEND_IMENGINE_EVENT);
1604 m_impl->send.put_data ((uint32)ic);
1605 m_impl->send.put_data (ic_uuid);
1606 m_impl->send.put_data (trans);
1607 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1610 if (!m_impl->si.null ()) m_impl->si->process_helper_event (ic_uuid, trans);
1614 * @brief Send a KeyEvent to an IMEngineInstance.
1616 * @param ic The handle of the IMEngineInstance to receive the event.
1617 * -1 means the currently focused IMEngineInstance.
1618 * @param ic_uuid The UUID of the IMEngineInstance. Empty means don't match.
1619 * @param key The KeyEvent to be sent.
1622 HelperAgent::send_key_event (int ic,
1623 const String &ic_uuid,
1624 const KeyEvent &key) const
1627 //FIXME: remove shift_mode_off, shift_mode_on, shift_mode_lock from ISE side
1628 if (key.code == SHIFT_MODE_OFF ||
1629 key.code == SHIFT_MODE_ON ||
1630 key.code == SHIFT_MODE_LOCK ||
1631 key.code == SHIFT_MODE_ENABLE ||
1632 key.code == SHIFT_MODE_DISABLE) {
1633 LOGW("FIXME ignore shift codes");
1637 if (m_impl->socket_active.is_connected ()) {
1638 m_impl->send.clear ();
1639 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1640 m_impl->send.put_data (m_impl->magic_active);
1641 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_SEND_KEY_EVENT);
1643 m_impl->send.put_data (m_impl->focused_ic);
1645 m_impl->send.put_data ((uint32)ic);
1647 m_impl->send.put_data (ic_uuid);
1648 m_impl->send.put_data (key);
1649 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1654 * @brief Forward a KeyEvent to client application directly.
1656 * @param ic The handle of the client Input Context to receive the event.
1657 * -1 means the currently focused Input Context.
1658 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1659 * Empty means don't match.
1660 * @param key The KeyEvent to be forwarded.
1663 HelperAgent::forward_key_event (int ic,
1664 const String &ic_uuid,
1665 const KeyEvent &key) const
1667 if (m_impl->socket_active.is_connected ()) {
1668 m_impl->send.clear ();
1669 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1670 m_impl->send.put_data (m_impl->magic_active);
1671 m_impl->send.put_command (SCIM_TRANS_CMD_FORWARD_KEY_EVENT);
1673 m_impl->send.put_data (m_impl->focused_ic);
1675 m_impl->send.put_data ((uint32)ic);
1677 m_impl->send.put_data (ic_uuid);
1678 m_impl->send.put_data (key);
1679 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1684 * @brief Commit a WideString to client application directly.
1686 * @param ic The handle of the client Input Context to receive the WideString.
1687 * -1 means the currently focused Input Context.
1688 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1689 * Empty means don't match.
1690 * @param wstr The WideString to be committed.
1693 HelperAgent::commit_string (int ic,
1694 const String &ic_uuid,
1695 const WideString &wstr) const
1697 if (m_impl->socket_active.is_connected ()) {
1698 m_impl->send.clear ();
1699 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1700 m_impl->send.put_data (m_impl->magic_active);
1701 m_impl->send.put_command (SCIM_TRANS_CMD_COMMIT_STRING);
1703 m_impl->send.put_data (m_impl->focused_ic);
1705 m_impl->send.put_data ((uint32)ic);
1707 m_impl->send.put_data (ic_uuid);
1708 m_impl->send.put_data (wstr);
1709 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1714 HelperAgent::commit_string (int ic,
1715 const String &ic_uuid,
1719 if (m_impl->socket_active.is_connected ()) {
1720 m_impl->send.clear ();
1721 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1722 m_impl->send.put_data (m_impl->magic_active);
1723 m_impl->send.put_command (SCIM_TRANS_CMD_COMMIT_STRING);
1725 m_impl->send.put_data (m_impl->focused_ic);
1727 m_impl->send.put_data ((uint32)ic);
1729 m_impl->send.put_data (ic_uuid);
1730 m_impl->send.put_dataw (buf, buflen);
1731 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1736 * @brief Request to show preedit string.
1738 * @param ic The handle of the client Input Context to receive the request.
1739 * -1 means the currently focused Input Context.
1740 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1741 * Empty means don't match.
1744 HelperAgent::show_preedit_string (int ic,
1745 const String &ic_uuid) const
1748 if (m_impl->socket_active.is_connected ()) {
1749 m_impl->send.clear ();
1750 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1751 m_impl->send.put_data (m_impl->magic_active);
1752 m_impl->send.put_command (SCIM_TRANS_CMD_SHOW_PREEDIT_STRING);
1753 m_impl->send.put_data ((uint32)ic);
1754 m_impl->send.put_data (ic_uuid);
1755 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1760 * @brief Request to show aux string.
1763 HelperAgent::show_aux_string (void) const
1766 if (m_impl->socket_active.is_connected ()) {
1767 m_impl->send.clear ();
1768 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1769 m_impl->send.put_data (m_impl->magic_active);
1770 m_impl->send.put_command (SCIM_TRANS_CMD_SHOW_AUX_STRING);
1771 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1776 * @brief Request to show candidate string.
1779 HelperAgent::show_candidate_string (void) const
1782 if (m_impl->socket_active.is_connected ()) {
1783 m_impl->send.clear ();
1784 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1785 m_impl->send.put_data (m_impl->magic_active);
1786 m_impl->send.put_command (SCIM_TRANS_CMD_SHOW_LOOKUP_TABLE);
1787 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1792 * @brief Request to show associate string.
1795 HelperAgent::show_associate_string (void) const
1797 if (m_impl->socket_active.is_connected ()) {
1798 m_impl->send.clear ();
1799 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1800 m_impl->send.put_data (m_impl->magic_active);
1801 m_impl->send.put_command (ISM_TRANS_CMD_SHOW_ASSOCIATE_TABLE);
1802 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1807 * @brief Request to hide preedit string.
1809 * @param ic The handle of the client Input Context to receive the request.
1810 * -1 means the currently focused Input Context.
1811 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1812 * Empty means don't match.
1815 HelperAgent::hide_preedit_string (int ic,
1816 const String &ic_uuid) const
1819 if (m_impl->socket_active.is_connected ()) {
1820 m_impl->send.clear ();
1821 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1822 m_impl->send.put_data (m_impl->magic_active);
1823 m_impl->send.put_command (SCIM_TRANS_CMD_HIDE_PREEDIT_STRING);
1824 m_impl->send.put_data ((uint32)ic);
1825 m_impl->send.put_data (ic_uuid);
1826 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1831 * @brief Request to hide aux string.
1834 HelperAgent::hide_aux_string (void) const
1836 if (m_impl->socket_active.is_connected ()) {
1837 m_impl->send.clear ();
1838 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1839 m_impl->send.put_data (m_impl->magic_active);
1840 m_impl->send.put_command (SCIM_TRANS_CMD_HIDE_AUX_STRING);
1841 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1846 * @brief Request to hide candidate string.
1849 HelperAgent::hide_candidate_string (void) const
1851 if (m_impl->socket_active.is_connected ()) {
1852 m_impl->send.clear ();
1853 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1854 m_impl->send.put_data (m_impl->magic_active);
1855 m_impl->send.put_command (SCIM_TRANS_CMD_HIDE_LOOKUP_TABLE);
1856 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1861 * @brief Request to hide associate string.
1864 HelperAgent::hide_associate_string (void) const
1866 if (m_impl->socket_active.is_connected ()) {
1867 m_impl->send.clear ();
1868 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1869 m_impl->send.put_data (m_impl->magic_active);
1870 m_impl->send.put_command (ISM_TRANS_CMD_HIDE_ASSOCIATE_TABLE);
1871 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1876 * @brief Update a new WideString for preedit.
1878 * @param ic The handle of the client Input Context to receive the WideString.
1879 * -1 means the currently focused Input Context.
1880 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1881 * Empty means don't match.
1882 * @param str The WideString to be updated.
1883 * @param attrs The attribute list for preedit string.
1886 HelperAgent::update_preedit_string (int ic,
1887 const String &ic_uuid,
1888 const WideString &str,
1889 const AttributeList &attrs) const
1891 update_preedit_string (ic, ic_uuid, str, str, attrs, -1);
1895 HelperAgent::update_preedit_string (int ic,
1896 const String &ic_uuid,
1899 const AttributeList &attrs) const
1901 update_preedit_string (ic, ic_uuid, buf, buflen, attrs, -1);
1905 * @brief Update a new WideString for preedit.
1907 * @param ic The handle of the client Input Context to receive the WideString.
1908 * -1 means the currently focused Input Context.
1909 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1910 * Empty means don't match.
1911 * @param str The WideString to be updated.
1912 * @param attrs The attribute list for preedit string.
1913 * @param caret The caret position in preedit string.
1916 HelperAgent::update_preedit_string (int ic,
1917 const String &ic_uuid,
1918 const WideString &wstr,
1919 const AttributeList &attrs,
1922 update_preedit_string (ic, ic_uuid, wstr, wstr, attrs, caret);
1926 HelperAgent::update_preedit_string (int ic,
1927 const String &ic_uuid,
1930 const AttributeList &attrs,
1934 if (m_impl->socket_active.is_connected ()) {
1935 m_impl->send.clear ();
1936 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1937 m_impl->send.put_data (m_impl->magic_active);
1938 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING);
1939 m_impl->send.put_data ((uint32)ic);
1940 m_impl->send.put_data (ic_uuid);
1941 m_impl->send.put_dataw (buf, buflen);
1942 m_impl->send.put_dataw (buf, buflen);
1943 m_impl->send.put_data (attrs);
1944 m_impl->send.put_data (caret);
1945 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1950 HelperAgent::update_preedit_string (int ic,
1951 const String &ic_uuid,
1952 const WideString &preedit,
1953 const WideString &commit,
1954 const AttributeList &attrs,
1957 if (m_impl->socket_active.is_connected ()) {
1958 m_impl->send.clear ();
1959 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1960 m_impl->send.put_data (m_impl->magic_active);
1961 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING);
1962 m_impl->send.put_data ((uint32)ic);
1963 m_impl->send.put_data (ic_uuid);
1964 m_impl->send.put_data (preedit);
1965 m_impl->send.put_data (commit);
1966 m_impl->send.put_data (attrs);
1967 m_impl->send.put_data (caret);
1968 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1973 * @brief Update the preedit caret position in the preedit string.
1975 * @param caret - the new position of the preedit caret.
1978 HelperAgent::update_preedit_caret (int caret) const
1981 if (m_impl->socket_active.is_connected ()) {
1982 m_impl->send.clear ();
1983 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1984 m_impl->send.put_data (m_impl->magic_active);
1985 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_CARET);
1986 m_impl->send.put_data ((uint32)caret);
1987 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1992 * @brief Update a new string for aux.
1994 * @param str The string to be updated.
1995 * @param attrs The attribute list for aux string.
1998 HelperAgent::update_aux_string (const String &str,
1999 const AttributeList &attrs) const
2001 if (m_impl->socket_active.is_connected ()) {
2002 m_impl->send.clear ();
2003 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2004 m_impl->send.put_data (m_impl->magic_active);
2005 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_AUX_STRING);
2006 m_impl->send.put_data (str);
2007 m_impl->send.put_data (attrs);
2008 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2013 * @brief Request to update candidate.
2015 * @param table The lookup table for candidate.
2018 HelperAgent::update_candidate_string (const LookupTable &table) const
2020 if (m_impl->socket_active.is_connected ()) {
2021 m_impl->send.clear ();
2022 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2023 m_impl->send.put_data (m_impl->magic_active);
2024 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_LOOKUP_TABLE);
2025 m_impl->send.put_data (table);
2026 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2031 * @brief Request to update associate.
2033 * @param table The lookup table for associate.
2036 HelperAgent::update_associate_string (const LookupTable &table) const
2038 if (m_impl->socket_active.is_connected ()) {
2039 m_impl->send.clear ();
2040 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2041 m_impl->send.put_data (m_impl->magic_active);
2042 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ASSOCIATE_TABLE);
2043 m_impl->send.put_data (table);
2044 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2049 * @brief When the input context of ISE is changed,
2050 * ISE can call this function to notify application
2052 * @param type type of event.
2053 * @param value value of event.
2056 HelperAgent::update_input_context (uint32 type, uint32 value) const
2058 if (type == ECORE_IMF_INPUT_PANEL_LANGUAGE_EVENT) {
2059 /* Update all state variables that could be queried by the client application */
2061 m_impl->signal_get_language_locale(this, -1, &buf);
2064 if (m_impl->socket_active.is_connected()) {
2065 m_impl->send.clear();
2066 m_impl->send.put_command(SCIM_TRANS_CMD_REQUEST);
2067 m_impl->send.put_data(m_impl->magic_active);
2068 m_impl->send.put_command(ISM_TRANS_CMD_UPDATE_ISE_LANGUAGE_LOCALE);
2069 m_impl->send.put_data(buf, strlen(buf));
2070 m_impl->send.write_to_socket(m_impl->socket_active, m_impl->magic_active);
2077 if (m_impl->socket_active.is_connected ()) {
2078 m_impl->send.clear ();
2079 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2080 m_impl->send.put_data (m_impl->magic_active);
2081 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ISE_INPUT_CONTEXT);
2082 m_impl->send.put_data (type);
2083 m_impl->send.put_data (value);
2084 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2089 * @brief Request to get surrounding text asynchronously.
2091 * @param uuid The helper ISE UUID.
2092 * @param maxlen_before The max length of before.
2093 * @param maxlen_after The max length of after.
2096 HelperAgent::get_surrounding_text (const String &uuid, int maxlen_before, int maxlen_after) const
2098 if (m_impl->socket_active.is_connected () && (m_impl->need_update_surrounding_text == 0)) {
2099 m_impl->send.clear ();
2100 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2101 m_impl->send.put_data (m_impl->magic_active);
2102 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SURROUNDING_TEXT);
2103 m_impl->send.put_data (uuid);
2104 m_impl->send.put_data (maxlen_before);
2105 m_impl->send.put_data (maxlen_after);
2106 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2108 m_impl->need_update_surrounding_text++;
2112 * @brief Request to get surrounding text synchronously.
2114 * @param uuid The helper ISE UUID.
2115 * @param maxlen_before The max length of before.
2116 * @param maxlen_after The max length of after.
2117 * @param text The surrounding text.
2118 * @param cursor The cursor position.
2121 HelperAgent::get_surrounding_text (int maxlen_before, int maxlen_after, String &text, int &cursor)
2123 if (!m_impl->socket_active.is_connected ())
2126 if (!m_impl->ise_focus_flag) {
2127 if (m_impl->finalized_text) {
2128 String buffer = m_impl->finalized_text;
2129 cursor = m_impl->finalized_cursor_pos;
2130 int pos = cursor - maxlen_before;
2131 if (maxlen_before < 0) pos = 0;
2132 if (pos > (int)buffer.length()) pos = (int)buffer.length();
2133 if (pos < 0) pos = 0;
2134 size_t len = maxlen_after + (cursor - pos);
2135 if (maxlen_after < 0) len = String::npos;
2136 text = buffer.substr (pos, len);
2142 m_impl->send.clear();
2143 m_impl->send.put_command(SCIM_TRANS_CMD_REQUEST);
2144 m_impl->send.put_data(m_impl->magic_active);
2145 m_impl->send.put_command(SCIM_TRANS_CMD_GET_SURROUNDING_TEXT);
2146 m_impl->send.put_data("");
2147 m_impl->send.put_data(maxlen_before);
2148 m_impl->send.put_data(maxlen_after);
2149 m_impl->send.write_to_socket(m_impl->socket_active, m_impl->magic_active);
2150 if (m_impl->surrounding_text) {
2151 free(m_impl->surrounding_text);
2152 m_impl->surrounding_text = NULL;
2155 const int WAIT_FOR_SYNC_RESPONSE_TIMEOUT = 1000;
2156 /* Now we are waiting for the ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT message */
2157 if (wait_for_message(ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT, WAIT_FOR_SYNC_RESPONSE_TIMEOUT)) {
2158 MessageItem *message = message_queue.get_pending_message_by_cmd(ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT);
2159 handle_message(message);
2160 message_queue.remove_message(message);
2162 if (m_impl->surrounding_text) {
2163 text = m_impl->surrounding_text;
2164 cursor = m_impl->cursor_pos;
2168 if (m_impl->surrounding_text) {
2169 free(m_impl->surrounding_text);
2170 m_impl->surrounding_text = NULL;
2173 LOGD("message_queue size : %d", message_queue.get_message_size());
2175 m_impl->send.clear ();
2176 m_impl->send.put_command(SCIM_TRANS_CMD_REQUEST);
2177 m_impl->send.put_data(m_impl->magic_active);
2178 m_impl->send.put_command(SCIM_TRANS_CMD_PING);
2179 m_impl->send.write_to_socket(m_impl->socket_active, m_impl->magic_active);
2184 * @brief Request to delete surrounding text.
2186 * @param offset The offset for cursor position.
2187 * @param len The length for delete text.
2190 HelperAgent::delete_surrounding_text (int offset, int len) const
2192 LOGD ("offset = %d, len = %d", offset, len);
2194 if (m_impl->socket_active.is_connected ()) {
2195 m_impl->send.clear ();
2196 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2197 m_impl->send.put_data (m_impl->magic_active);
2198 m_impl->send.put_command (SCIM_TRANS_CMD_DELETE_SURROUNDING_TEXT);
2199 m_impl->send.put_data (offset);
2200 m_impl->send.put_data (len);
2201 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2206 * @brief Request to get selection text asynchronously.
2208 * @param uuid The helper ISE UUID.
2211 HelperAgent::get_selection (const String &uuid) const
2213 if (m_impl->socket_active.is_connected () && (m_impl->need_update_selection_text == 0)) {
2214 m_impl->send.clear ();
2215 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2216 m_impl->send.put_data (m_impl->magic_active);
2217 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SELECTION);
2218 m_impl->send.put_data (uuid);
2219 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2221 m_impl->need_update_selection_text++;
2225 * @brief Request to get selection text synchronously.
2227 * @param text The selection text.
2230 HelperAgent::get_selection_text (String &text)
2233 if (!m_impl->socket_active.is_connected ())
2236 m_impl->send.clear ();
2237 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2238 m_impl->send.put_data (m_impl->magic_active);
2239 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SELECTION);
2240 m_impl->send.put_data ("");
2241 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2242 if (m_impl->selection_text) {
2243 free (m_impl->selection_text);
2244 m_impl->selection_text = NULL;
2247 const int WAIT_FOR_SYNC_RESPONSE_TIMEOUT = 1000;
2248 /* Now we are waiting for the ISM_TRANS_CMD_UPDATE_SELECTION message */
2249 if (wait_for_message(ISM_TRANS_CMD_UPDATE_SELECTION, WAIT_FOR_SYNC_RESPONSE_TIMEOUT)) {
2250 MessageItem *message = message_queue.get_pending_message_by_cmd(ISM_TRANS_CMD_UPDATE_SELECTION);
2251 handle_message(message);
2252 message_queue.remove_message(message);
2253 if (m_impl->selection_text) {
2254 text = m_impl->selection_text;
2258 if (m_impl->selection_text) {
2259 free (m_impl->selection_text);
2260 m_impl->selection_text = NULL;
2263 LOGD("message_queue size : %d", message_queue.get_message_size());
2265 m_impl->send.clear ();
2266 m_impl->send.put_command(SCIM_TRANS_CMD_REQUEST);
2267 m_impl->send.put_data(m_impl->magic_active);
2268 m_impl->send.put_command(SCIM_TRANS_CMD_PING);
2269 m_impl->send.write_to_socket(m_impl->socket_active, m_impl->magic_active);
2273 * @brief Request to select text.
2275 * @param start The start position in text.
2276 * @param end The end position in text.
2279 HelperAgent::set_selection (int start, int end) const
2281 if (m_impl->socket_active.is_connected ()) {
2282 m_impl->send.clear ();
2283 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2284 m_impl->send.put_data (m_impl->magic_active);
2285 m_impl->send.put_command (SCIM_TRANS_CMD_SET_SELECTION);
2286 m_impl->send.put_data (start);
2287 m_impl->send.put_data (end);
2288 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2293 * @brief Send a private command to an application.
2295 * @param command The private command sent from IME.
2298 HelperAgent::send_private_command (const String &command) const
2300 if (m_impl->socket_active.is_connected ()) {
2301 m_impl->send.clear ();
2302 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2303 m_impl->send.put_data (m_impl->magic_active);
2304 m_impl->send.put_command (SCIM_TRANS_CMD_SEND_PRIVATE_COMMAND);
2305 m_impl->send.put_data (command);
2306 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2311 * @brief Commit content to an application.
2313 * @param content The content sent from IME.
2316 HelperAgent::commit_content (const String &content, const String &description, const String &mime_types) const
2319 if (m_impl->socket_active.is_connected ()) {
2320 m_impl->send.clear ();
2321 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2322 m_impl->send.put_data (m_impl->magic_active);
2323 m_impl->send.put_command (SCIM_TRANS_CMD_COMMIT_CONTENT);
2324 m_impl->send.put_data (content);
2325 m_impl->send.put_data (description);
2326 m_impl->send.put_data (mime_types);
2327 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2332 * @brief Request to get uuid list of all keyboard ISEs.
2334 * @param uuid The helper ISE UUID.
2337 HelperAgent::get_keyboard_ise_list (const String &uuid) const
2339 if (m_impl->socket_active.is_connected ()) {
2340 m_impl->send.clear ();
2341 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2342 m_impl->send.put_data (m_impl->magic_active);
2343 m_impl->send.put_command (ISM_TRANS_CMD_GET_KEYBOARD_ISE_LIST);
2344 m_impl->send.put_data (uuid);
2345 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2350 * @brief Set candidate position in screen.
2352 * @param left The x position in screen.
2353 * @param top The y position in screen.
2356 HelperAgent::set_candidate_position (int left, int top) const
2358 if (m_impl->socket_active.is_connected ()) {
2359 m_impl->send.clear ();
2360 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2361 m_impl->send.put_data (m_impl->magic_active);
2362 m_impl->send.put_command (ISM_TRANS_CMD_SET_CANDIDATE_POSITION);
2363 m_impl->send.put_data (left);
2364 m_impl->send.put_data (top);
2365 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2370 * @brief Set candidate style.
2372 * @param portrait_line - the displayed line number for portrait mode.
2373 * @param mode - candidate window mode.
2376 HelperAgent::set_candidate_style (ISF_CANDIDATE_PORTRAIT_LINE_T portrait_line,
2377 ISF_CANDIDATE_MODE_T mode) const
2379 if (m_impl->socket_active.is_connected ()) {
2380 m_impl->send.clear ();
2381 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2382 m_impl->send.put_data (m_impl->magic_active);
2383 m_impl->send.put_command (ISM_TRANS_CMD_SET_CANDIDATE_UI);
2384 m_impl->send.put_data (portrait_line);
2385 m_impl->send.put_data (mode);
2386 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2391 * @brief Request to hide candidate window.
2394 HelperAgent::candidate_hide (void) const
2396 if (m_impl->socket_active.is_connected ()) {
2397 m_impl->send.clear ();
2398 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2399 m_impl->send.put_data (m_impl->magic_active);
2400 m_impl->send.put_command (ISM_TRANS_CMD_HIDE_CANDIDATE);
2401 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2406 * @brief Request to get candidate window size and position.
2408 * @param uuid The helper ISE UUID.
2411 HelperAgent::get_candidate_window_geometry (const String &uuid) const
2413 if (m_impl->socket_active.is_connected ()) {
2414 m_impl->send.clear ();
2415 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2416 m_impl->send.put_data (m_impl->magic_active);
2417 m_impl->send.put_command (ISM_TRANS_CMD_GET_CANDIDATE_GEOMETRY);
2418 m_impl->send.put_data (uuid);
2419 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2424 * @brief Set current keyboard ISE.
2426 * @param uuid The keyboard ISE UUID.
2429 HelperAgent::set_keyboard_ise_by_uuid (const String &uuid) const
2432 IMEngineFactoryPointer factory;
2433 IMEngineModule *engine_module = NULL;
2434 static int instance_count = 1;
2436 if ((!m_impl->si.null ()) && m_impl->si->get_factory_uuid () == uuid) {
2437 ISF_SAVE_LOG ("Already in UUID: %s", uuid.c_str());
2441 if (!m_impl->si.null()) {
2442 m_impl->si->focus_out();
2446 if (m_impl->m_config.null ()) {
2447 ISF_SAVE_LOG ("config is not working");
2451 #ifdef HAVE_PKGMGR_INFO
2454 pkgmgrinfo_appinfo_h handle;
2455 ret = pkgmgrinfo_appinfo_get_appinfo(uuid.c_str(), &handle);
2456 if (ret != PMINFO_R_OK) {
2457 ISF_SAVE_LOG ("Retrieve app info failed : %s", uuid.c_str ());
2461 ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
2462 if (ret != PMINFO_R_OK) {
2463 ISF_SAVE_LOG ("Retrieve pkgid failed : %s, %p", uuid.c_str(), handle);
2464 pkgmgrinfo_appinfo_destroy_appinfo(handle);
2468 imeInfo.module_name = pkgid;
2469 pkgmgrinfo_appinfo_destroy_appinfo(handle);
2471 if (isf_db_select_ime_info_by_appid(uuid.c_str(), &imeInfo) < 1) {
2472 ISF_SAVE_LOG ("ime_info row is not available for %s", uuid.c_str());
2477 engine_module = &m_impl->engine_module;
2479 if (engine_module->valid() && imeInfo.module_name != engine_module->get_module_name()) {
2480 ISF_SAVE_LOG ("imengine module %s unloaded", engine_module->get_module_name().c_str());
2481 engine_module->unload();
2484 if (!engine_module->valid()) {
2485 if (engine_module->load (imeInfo.module_name, m_impl->m_config) == false) {
2486 ISF_SAVE_LOG ("load module %s failed", imeInfo.module_name.c_str());
2489 ISF_SAVE_LOG ("imengine module %s loaded", imeInfo.module_name.c_str());
2492 for (size_t j = 0; j < engine_module->number_of_factories (); ++j) {
2494 factory = engine_module->create_factory (j);
2495 if (factory.null () == false && factory->get_uuid () == uuid)
2503 if (factory.null()) {
2504 ISF_SAVE_LOG ("imengine uuid %s is not found", uuid.c_str());
2508 m_impl->si = factory->create_instance ("UTF-8", instance_count++);
2509 if (m_impl->si.null ()) {
2510 ISF_SAVE_LOG ("create_instance %s failed", uuid.c_str ());
2514 m_impl->attach_instance ();
2515 ISF_SAVE_LOG ("Require UUID: %s Current UUID: %s", uuid.c_str (), m_impl->si->get_factory_uuid ().c_str ());
2516 m_impl->si->set_layout (m_impl->layout);
2517 if (m_impl->focused_ic != (uint32)-1)
2518 m_impl->si->focus_in ();
2522 * @brief Request to get current keyboard ISE information.
2524 * @param uuid The helper ISE UUID.
2527 HelperAgent::get_keyboard_ise (const String &uuid) const
2529 //FIXME: maybe useless
2531 if (m_impl->socket_active.is_connected ()) {
2532 m_impl->send.clear ();
2533 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2534 m_impl->send.put_data (m_impl->magic_active);
2535 m_impl->send.put_command (ISM_TRANS_CMD_GET_KEYBOARD_ISE);
2536 m_impl->send.put_data (uuid);
2537 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2543 * @brief Update ISE window geometry.
2545 * @param x The x position in screen.
2546 * @param y The y position in screen.
2547 * @param width The ISE window width.
2548 * @param height The ISE window height.
2551 HelperAgent::update_geometry (int x, int y, int width, int height) const
2553 if (m_impl->socket_active.is_connected ()) {
2554 m_impl->send.clear ();
2555 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2556 m_impl->send.put_data (m_impl->magic_active);
2557 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ISE_GEOMETRY);
2558 m_impl->send.put_data (x);
2559 m_impl->send.put_data (y);
2560 m_impl->send.put_data (width);
2561 m_impl->send.put_data (height);
2562 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2567 * @brief Request to expand candidate window.
2570 HelperAgent::expand_candidate (void) const
2572 if (m_impl->socket_active.is_connected ()) {
2573 m_impl->send.clear ();
2574 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2575 m_impl->send.put_data (m_impl->magic_active);
2576 m_impl->send.put_command (ISM_TRANS_CMD_EXPAND_CANDIDATE);
2577 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2582 * @brief Request to contract candidate window.
2585 HelperAgent::contract_candidate (void) const
2587 if (m_impl->socket_active.is_connected ()) {
2588 m_impl->send.clear ();
2589 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2590 m_impl->send.put_data (m_impl->magic_active);
2591 m_impl->send.put_command (ISM_TRANS_CMD_CONTRACT_CANDIDATE);
2592 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2597 * @brief Send selected candidate string index number.
2600 HelperAgent::select_candidate (int index) const
2602 if (!m_impl->si.null ())
2603 m_impl->si->select_candidate (index);
2604 //FIXME: maybe useless
2607 if (m_impl->socket_active.is_connected ()) {
2608 m_impl->send.clear ();
2609 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2610 m_impl->send.put_data (m_impl->magic_active);
2611 m_impl->send.put_command (ISM_TRANS_CMD_SELECT_CANDIDATE);
2612 m_impl->send.put_data (index);
2613 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2619 * @brief Update our ISE is exiting.
2621 * The IME must call this function before terminating IME itself in On-demand mode.
2622 * If this function isn't called, IME will automatically restart.
2623 * This function only works in On-demand mode.
2627 HelperAgent::update_ise_exit (void) const
2629 if (m_impl->socket_active.is_connected ()) {
2630 m_impl->send.clear ();
2631 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2632 m_impl->send.put_data (m_impl->magic_active);
2633 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ISE_EXIT);
2634 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2636 // The update_ise_exit must be delivered before del_client of isf_info_manager was called.
2642 * @brief Request to reset keyboard ISE.
2645 HelperAgent::reset_keyboard_ise (void) const
2647 //FIXME: maybe useless
2649 if (m_impl->socket_active.is_connected ()) {
2650 m_impl->send.clear ();
2651 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2652 m_impl->send.put_data (m_impl->magic_active);
2653 m_impl->send.put_command (ISM_TRANS_CMD_PANEL_RESET_KEYBOARD_ISE);
2654 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2657 if (!m_impl->si.null ()) {
2658 m_impl->si->reset ();
2663 * @brief Request to flush keyboard ISE.
2666 HelperAgent::flush_keyboard_ise (void) const
2668 if (!m_impl->si.null ()) {
2669 m_impl->si->flush ();
2674 * @brief Request panel to hide ISE.
2677 HelperAgent::request_ise_hide (void) const
2679 if (m_impl->socket_active.is_connected ()) {
2680 m_impl->send.clear ();
2681 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2682 m_impl->send.put_data (m_impl->magic_active);
2683 m_impl->send.put_command (ISM_TRANS_CMD_REQUEST_ISE_HIDE);
2684 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2692 HelperAgent::recapture_string (int ic,
2693 const String &ic_uuid,
2696 const WideString &preedit_str,
2697 const WideString &commit_str,
2698 const AttributeList &attrs) const
2700 LOGD ("offset = %d, len = %d", offset, len);
2702 if (m_impl->socket_active.is_connected ()) {
2703 m_impl->send.clear ();
2704 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2705 m_impl->send.put_data (m_impl->magic_active);
2706 m_impl->send.put_command (ISM_TRANS_CMD_RECAPTURE_STRING);
2708 m_impl->send.put_data ((uint32)ic);
2709 m_impl->send.put_data (ic_uuid);
2711 // Deleting surrounding text
2712 m_impl->send.put_data (offset);
2713 m_impl->send.put_data (len);
2715 // Update preedit text
2716 m_impl->send.put_data (preedit_str);
2719 m_impl->send.put_data (commit_str);
2721 // preedit attributes
2722 m_impl->send.put_data (attrs);
2724 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2729 HelperAgent::set_engine_loader_flag (bool flag)
2731 m_impl->engine_loader_flag = flag;
2735 HelperAgent::send_key_event_processing_result (KeyEvent &key,
2737 bool is_success) const
2739 int ret = is_success ? 1 : 0;
2740 m_impl->process_key_event_done (key, ret, serial);
2744 * @brief Connect a slot to Helper exit signal.
2746 * This signal is used to let the Helper exit.
2748 * The prototype of the slot is:
2750 * void exit (const HelperAgent *agent, int ic, const String &ic_uuid);
2753 * - agent The pointer to the HelperAgent object which emits this signal.
2754 * - ic An opaque handle of the currently focused input context.
2755 * - ic_uuid The UUID of the IMEngineInstance associated with the focused input context.
2758 HelperAgent::signal_connect_exit (HelperAgentSlotVoid *slot)
2760 return m_impl->signal_exit.connect (slot);
2764 * @brief Connect a slot to Helper attach input context signal.
2766 * This signal is used to attach an input context to this helper.
2768 * When an input context requst to start this helper, then this
2769 * signal will be emitted as soon as the helper is started.
2771 * When an input context want to start an already started helper,
2772 * this signal will also be emitted.
2774 * Helper can send some events back to the IMEngineInstance in this
2775 * signal-slot, to inform that it has been started sccessfully.
2777 * The prototype of the slot is:
2779 * void attach_input_context (const HelperAgent *agent, int ic, const String &ic_uuid);
2782 HelperAgent::signal_connect_attach_input_context (HelperAgentSlotVoid *slot)
2784 return m_impl->signal_attach_input_context.connect (slot);
2788 * @brief Connect a slot to Helper detach input context signal.
2790 * This signal is used to detach an input context from this helper.
2792 * When an input context requst to stop this helper, then this
2793 * signal will be emitted.
2795 * Helper shouldn't send any event back to the IMEngineInstance, because
2796 * the IMEngineInstance attached to the ic should have been destroyed.
2798 * The prototype of the slot is:
2800 * void detach_input_context (const HelperAgent *agent, int ic, const String &ic_uuid);
2803 HelperAgent::signal_connect_detach_input_context (HelperAgentSlotVoid *slot)
2805 return m_impl->signal_detach_input_context.connect (slot);
2809 * @brief Connect a slot to Helper reload config signal.
2811 * This signal is used to let the Helper reload configuration.
2813 * The prototype of the slot is:
2815 * void reload_config (const HelperAgent *agent, int ic, const String &ic_uuid);
2818 HelperAgent::signal_connect_reload_config (HelperAgentSlotVoid *slot)
2820 return m_impl->signal_reload_config.connect (slot);
2824 * @brief Connect a slot to Helper update screen signal.
2826 * This signal is used to let the Helper move its GUI to another screen.
2827 * It can only be emitted when SCIM_HELPER_NEED_SCREEN_INFO is set in HelperInfo.option.
2829 * The prototype of the slot is:
2831 * void update_screen (const HelperAgent *agent, int ic, const String &ic_uuid, int screen_number);
2834 HelperAgent::signal_connect_update_screen (HelperAgentSlotInt *slot)
2836 return m_impl->signal_update_screen.connect (slot);
2840 * @brief Connect a slot to Helper update spot location signal.
2842 * This signal is used to let the Helper move its GUI according to the current spot location.
2843 * It can only be emitted when SCIM_HELPER_NEED_SPOT_LOCATION_INFO is set in HelperInfo.option.
2845 * The prototype of the slot is:
2846 * void update_spot_location (const HelperAgent *agent, int ic, const String &ic_uuid, int x, int y);
2849 HelperAgent::signal_connect_update_spot_location (HelperAgentSlotIntInt *slot)
2851 return m_impl->signal_update_spot_location.connect (slot);
2855 * @brief Connect a slot to Helper update cursor position signal.
2857 * This signal is used to let the Helper get the cursor position information.
2859 * The prototype of the slot is:
2860 * void update_cursor_position (const HelperAgent *agent, int ic, const String &ic_uuid, int cursor_pos);
2863 HelperAgent::signal_connect_update_cursor_position (HelperAgentSlotInt *slot)
2865 return m_impl->signal_update_cursor_position.connect (slot);
2869 * @brief Connect a slot to Helper update surrounding text signal.
2871 * This signal is used to let the Helper get the surrounding text.
2873 * The prototype of the slot is:
2874 * void update_surrounding_text (const HelperAgent *agent, int ic, const String &text, int cursor);
2877 HelperAgent::signal_connect_update_surrounding_text (HelperAgentSlotInt *slot)
2879 return m_impl->signal_update_surrounding_text.connect (slot);
2883 * @brief Connect a slot to Helper update selection signal.
2885 * This signal is used to let the Helper get the selection.
2887 * The prototype of the slot is:
2888 * void update_selection (const HelperAgent *agent, int ic, const String &text);
2891 HelperAgent::signal_connect_update_selection (HelperAgentSlotVoid *slot)
2893 return m_impl->signal_update_selection.connect (slot);
2897 * @brief Connect a slot to Helper trigger property signal.
2899 * This signal is used to trigger a property registered by this Helper.
2900 * A property will be triggered when user clicks on it.
2902 * The prototype of the slot is:
2903 * void trigger_property (const HelperAgent *agent, int ic, const String &ic_uuid, const String &property);
2906 HelperAgent::signal_connect_trigger_property (HelperAgentSlotString *slot)
2908 return m_impl->signal_trigger_property.connect (slot);
2912 * @brief Connect a slot to Helper process imengine event signal.
2914 * This signal is used to deliver the events sent from IMEngine to Helper.
2916 * The prototype of the slot is:
2917 * void process_imengine_event (const HelperAgent *agent, int ic, const String &ic_uuid, const Transaction &transaction);
2920 HelperAgent::signal_connect_process_imengine_event (HelperAgentSlotTransaction *slot)
2922 return m_impl->signal_process_imengine_event.connect (slot);
2926 * @brief Connect a slot to Helper focus out signal.
2928 * This signal is used to do something when input context is focus out.
2930 * The prototype of the slot is:
2931 * void focus_out (const HelperAgent *agent, int ic, const String &ic_uuid);
2934 HelperAgent::signal_connect_focus_out (HelperAgentSlotVoid *slot)
2936 return m_impl->signal_focus_out.connect (slot);
2940 * @brief Connect a slot to Helper focus in signal.
2942 * This signal is used to do something when input context is focus in.
2944 * The prototype of the slot is:
2945 * void focus_in (const HelperAgent *agent, int ic, const String &ic_uuid);
2948 HelperAgent::signal_connect_focus_in (HelperAgentSlotVoid *slot)
2950 return m_impl->signal_focus_in.connect (slot);
2954 * @brief Connect a slot to Helper show signal.
2956 * This signal is used to show Helper ISE window.
2958 * The prototype of the slot is:
2959 * void ise_show (const HelperAgent *agent, int ic, char *buf, size_t &len);
2962 HelperAgent::signal_connect_ise_show (HelperAgentSlotIntRawVoid *slot)
2964 return m_impl->signal_ise_show.connect (slot);
2968 * @brief Connect a slot to Helper hide signal.
2970 * This signal is used to hide Helper ISE window.
2972 * The prototype of the slot is:
2973 * void ise_hide (const HelperAgent *agent, int ic, const String &ic_uuid);
2976 HelperAgent::signal_connect_ise_hide (HelperAgentSlotVoid *slot)
2978 return m_impl->signal_ise_hide.connect (slot);
2982 * @brief Connect a slot to Helper get ISE window geometry signal.
2984 * This signal is used to get Helper ISE window size and position.
2986 * The prototype of the slot is:
2987 * void get_geometry (const HelperAgent *agent, struct rectinfo &info);
2990 HelperAgent::signal_connect_get_geometry (HelperAgentSlotSize *slot)
2992 return m_impl->signal_get_geometry.connect (slot);
2996 * @brief Connect a slot to Helper set mode signal.
2998 * This signal is used to set Helper ISE mode.
3000 * The prototype of the slot is:
3001 * void set_mode (const HelperAgent *agent, uint32 &mode);
3004 HelperAgent::signal_connect_set_mode (HelperAgentSlotUintVoid *slot)
3006 return m_impl->signal_set_mode.connect (slot);
3010 * @brief Connect a slot to Helper set language signal.
3012 * This signal is used to set Helper ISE language.
3014 * The prototype of the slot is:
3015 * void set_language (const HelperAgent *agent, uint32 &language);
3018 HelperAgent::signal_connect_set_language (HelperAgentSlotUintVoid *slot)
3020 return m_impl->signal_set_language.connect (slot);
3024 * @brief Connect a slot to Helper set im data signal.
3026 * This signal is used to send im data to Helper ISE.
3028 * The prototype of the slot is:
3029 * void set_imdata (const HelperAgent *agent, char *buf, size_t &len);
3032 HelperAgent::signal_connect_set_imdata (HelperAgentSlotRawVoid *slot)
3034 return m_impl->signal_set_imdata.connect (slot);
3038 * @brief Connect a slot to Helper get im data signal.
3040 * This signal is used to get im data from Helper ISE.
3042 * The prototype of the slot is:
3043 * void get_imdata (const HelperAgent *, char **buf, size_t &len);
3046 HelperAgent::signal_connect_get_imdata (HelperAgentSlotGetRawVoid *slot)
3048 return m_impl->signal_get_imdata.connect (slot);
3052 * @brief Connect a slot to Helper get language locale signal.
3054 * This signal is used to get language locale from Helper ISE.
3056 * The prototype of the slot is:
3057 * void get_language_locale (const HelperAgent *, int ic, char **locale);
3060 HelperAgent::signal_connect_get_language_locale (HelperAgentSlotIntGetStringVoid *slot)
3062 return m_impl->signal_get_language_locale.connect (slot);
3066 * @brief Connect a slot to Helper set return key type signal.
3068 * This signal is used to send return key type to Helper ISE.
3070 * The prototype of the slot is:
3071 * void set_return_key_type (const HelperAgent *agent, uint32 &type);
3074 HelperAgent::signal_connect_set_return_key_type (HelperAgentSlotUintVoid *slot)
3076 return m_impl->signal_set_return_key_type.connect (slot);
3080 * @brief Connect a slot to Helper get return key type signal.
3082 * This signal is used to get return key type from Helper ISE.
3084 * The prototype of the slot is:
3085 * void get_return_key_type (const HelperAgent *agent, uint32 &type);
3088 HelperAgent::signal_connect_get_return_key_type (HelperAgentSlotUintVoid *slot)
3090 return m_impl->signal_get_return_key_type.connect (slot);
3094 * @brief Connect a slot to Helper set return key disable signal.
3096 * This signal is used to send return key disable to Helper ISE.
3098 * The prototype of the slot is:
3099 * void set_return_key_disable (const HelperAgent *agent, uint32 &disabled);
3102 HelperAgent::signal_connect_set_return_key_disable (HelperAgentSlotUintVoid *slot)
3104 return m_impl->signal_set_return_key_disable.connect (slot);
3108 * @brief Connect a slot to Helper process key event signal.
3110 * This signal is used to send keyboard key event to Helper ISE.
3112 * The prototype of the slot is:
3113 * void process_key_event (const HelperAgent *agent, KeyEvent &key, uint32 &ret);
3116 HelperAgent::signal_connect_process_key_event (HelperAgentSlotKeyEventUint *slot)
3118 return m_impl->signal_process_key_event.connect (slot);
3122 * @brief Connect a slot to Helper process key event with keycode signal.
3124 * This signal is used to send keyboard key event with keycode to Helper ISE.
3126 * The prototype of the slot is:
3127 * void process_key_event_with_keycode (const HelperAgent *agent, KeyEvent &key, uint32 &ret, uint32 keycode);
3130 HelperAgent::signal_connect_process_key_event_with_keycode (HelperAgentSlotKeyEventUintUint *slot)
3132 return m_impl->signal_process_key_event_with_keycode.connect (slot);
3136 * @brief Connect a slot to Helper get return key disable signal.
3138 * This signal is used to get return key disable from Helper ISE.
3140 * The prototype of the slot is:
3141 * void get_return_key_disable (const HelperAgent *agent, uint32 &disabled);
3144 HelperAgent::signal_connect_get_return_key_disable (HelperAgentSlotUintVoid *slot)
3146 return m_impl->signal_get_return_key_disable.connect (slot);
3150 * @brief Connect a slot to Helper set layout signal.
3152 * This signal is used to set Helper ISE layout.
3154 * The prototype of the slot is:
3155 * void set_layout (const HelperAgent *agent, uint32 &layout);
3158 HelperAgent::signal_connect_set_layout (HelperAgentSlotUintVoid *slot)
3160 return m_impl->signal_set_layout.connect (slot);
3164 * @brief Connect a slot to Helper get layout signal.
3166 * This signal is used to get Helper ISE layout.
3168 * The prototype of the slot is:
3169 * void get_layout (const HelperAgent *agent, uint32 &layout);
3172 HelperAgent::signal_connect_get_layout (HelperAgentSlotUintVoid *slot)
3174 return m_impl->signal_get_layout.connect (slot);
3178 * @brief Connect a slot to Helper set input mode signal.
3180 * This signal is used to set Helper ISE input mode.
3182 * The prototype of the slot is:
3183 * void set_input_mode (const HelperAgent *agent, uint32 &input_mode);
3186 HelperAgent::signal_connect_set_input_mode (HelperAgentSlotUintVoid *slot)
3188 return m_impl->signal_set_input_mode.connect (slot);
3192 * @brief Connect a slot to Helper set input hint signal.
3194 * This signal is used to set Helper ISE input hint.
3196 * The prototype of the slot is:
3197 * void set_input_hint (const HelperAgent *agent, uint32 &input_hint);
3200 HelperAgent::signal_connect_set_input_hint (HelperAgentSlotUintVoid *slot)
3202 return m_impl->signal_set_input_hint.connect (slot);
3206 * @brief Connect a slot to Helper set BiDi direction signal.
3208 * This signal is used to set Helper ISE BiDi direction.
3210 * The prototype of the slot is:
3211 * void update_bidi_direction (const HelperAgent *agent, uint32 &bidi_direction);
3214 HelperAgent::signal_connect_update_bidi_direction (HelperAgentSlotUintVoid *slot)
3216 return m_impl->signal_update_bidi_direction.connect (slot);
3220 * @brief Connect a slot to Helper set shift mode signal.
3222 * This signal is used to set Helper shift mode.
3224 * The prototype of the slot is:
3225 * void set_caps_mode (const HelperAgent *agent, uint32 &mode);
3228 HelperAgent::signal_connect_set_caps_mode (HelperAgentSlotUintVoid *slot)
3230 return m_impl->signal_set_caps_mode.connect (slot);
3234 * @brief Connect a slot to Helper reset input context signal.
3236 * This signal is used to reset Helper ISE input context.
3238 * The prototype of the slot is:
3239 * void reset_input_context (const HelperAgent *agent, int ic, const String &uuid);
3242 HelperAgent::signal_connect_reset_input_context (HelperAgentSlotVoid *slot)
3244 return m_impl->signal_reset_input_context.connect (slot);
3248 * @brief Connect a slot to Helper update candidate window geometry signal.
3250 * This signal is used to get candidate window size and position.
3252 * The prototype of the slot is:
3253 * void update_candidate_geometry (const HelperAgent *agent, int ic, const String &uuid, const rectinfo &info);
3256 HelperAgent::signal_connect_update_candidate_geometry (HelperAgentSlotRect *slot)
3258 return m_impl->signal_update_candidate_geometry.connect (slot);
3262 * @brief Connect a slot to Helper update keyboard ISE signal.
3264 * This signal is used to get current keyboard ISE name and uuid.
3266 * The prototype of the slot is:
3267 * void update_keyboard_ise (const HelperAgent *agent, int ic, const String &uuid,
3268 * const String &ise_name, const String &ise_uuid);
3271 HelperAgent::signal_connect_update_keyboard_ise (HelperAgentSlotString2 *slot)
3273 return m_impl->signal_update_keyboard_ise.connect (slot);
3277 * @brief Connect a slot to Helper update keyboard ISE list signal.
3279 * This signal is used to get uuid list of all keyboard ISEs.
3281 * The prototype of the slot is:
3282 * void update_keyboard_ise_list (const HelperAgent *agent, int ic, const String &uuid,
3283 * const std::vector<String> &ise_list);
3286 HelperAgent::signal_connect_update_keyboard_ise_list (HelperAgentSlotStringVector *slot)
3288 return m_impl->signal_update_keyboard_ise_list.connect (slot);
3292 * @brief Connect a slot to Helper candidate more window show signal.
3294 * This signal is used to do someting when candidate more window is showed.
3296 * The prototype of the slot is:
3297 * void candidate_more_window_show (const HelperAgent *agent, int ic, const String &uuid);
3300 HelperAgent::signal_connect_candidate_more_window_show (HelperAgentSlotVoid *slot)
3302 return m_impl->signal_candidate_more_window_show.connect (slot);
3306 * @brief Connect a slot to Helper candidate more window hide signal.
3308 * This signal is used to do someting when candidate more window is hidden.
3310 * The prototype of the slot is:
3311 * void candidate_more_window_hide (const HelperAgent *agent, int ic, const String &uuid);
3314 HelperAgent::signal_connect_candidate_more_window_hide (HelperAgentSlotVoid *slot)
3316 return m_impl->signal_candidate_more_window_hide.connect (slot);
3320 * @brief Connect a slot to Helper candidate show signal.
3322 * This signal is used to do candidate show.
3324 * The prototype of the slot is:
3325 * void candidate_show (const HelperAgent *agent, int ic, const String &uuid);
3328 HelperAgent::signal_connect_candidate_show (HelperAgentSlotVoid *slot)
3330 return m_impl->signal_candidate_show.connect (slot);
3334 * @brief Connect a slot to Helper candidate hide signal.
3336 * This signal is used to do candidate hide.
3338 * The prototype of the slot is:
3339 * void candidate_hide (const HelperAgent *agent, int ic, const String &uuid);
3342 HelperAgent::signal_connect_candidate_hide (HelperAgentSlotVoid *slot)
3344 return m_impl->signal_candidate_hide.connect (slot);
3348 * @brief Connect a slot to Helper update lookup table signal.
3350 * This signal is used to do someting when update lookup table.
3352 * The prototype of the slot is:
3353 * void update_lookup_table (const HelperAgent *agent, int ic, const String &uuid ,LookupTable &table);
3356 HelperAgent::signal_connect_update_lookup_table (HelperAgentSlotLookupTable *slot)
3358 return m_impl->signal_update_lookup_table.connect (slot);
3362 * @brief Connect a slot to Helper select aux signal.
3364 * This signal is used to do something when aux is selected.
3366 * The prototype of the slot is:
3367 * void select_aux (const HelperAgent *agent, int ic, const String &uuid, int index);
3370 HelperAgent::signal_connect_select_aux (HelperAgentSlotInt *slot)
3372 return m_impl->signal_select_aux.connect (slot);
3376 * @brief Connect a slot to Helper select candidate signal.
3378 * This signal is used to do something when candidate is selected.
3380 * The prototype of the slot is:
3381 * void select_candidate (const HelperAgent *agent, int ic, const String &uuid, int index);
3384 HelperAgent::signal_connect_select_candidate (HelperAgentSlotInt *slot)
3386 return m_impl->signal_select_candidate.connect (slot);
3390 * @brief Connect a slot to Helper candidate table page up signal.
3392 * This signal is used to do something when candidate table is paged up.
3394 * The prototype of the slot is:
3395 * void candidate_table_page_up (const HelperAgent *agent, int ic, const String &uuid);
3398 HelperAgent::signal_connect_candidate_table_page_up (HelperAgentSlotVoid *slot)
3400 return m_impl->signal_candidate_table_page_up.connect (slot);
3404 * @brief Connect a slot to Helper candidate table page down signal.
3406 * This signal is used to do something when candidate table is paged down.
3408 * The prototype of the slot is:
3409 * void candidate_table_page_down (const HelperAgent *agent, int ic, const String &uuid);
3412 HelperAgent::signal_connect_candidate_table_page_down (HelperAgentSlotVoid *slot)
3414 return m_impl->signal_candidate_table_page_down.connect (slot);
3418 * @brief Connect a slot to Helper update candidate table page size signal.
3420 * This signal is used to do something when candidate table page size is changed.
3422 * The prototype of the slot is:
3423 * void update_candidate_table_page_size (const HelperAgent *, int ic, const String &uuid, int page_size);
3426 HelperAgent::signal_connect_update_candidate_table_page_size (HelperAgentSlotInt *slot)
3428 return m_impl->signal_update_candidate_table_page_size.connect (slot);
3432 * @brief Connect a slot to Helper update candidate item layout signal.
3434 * The prototype of the slot is:
3435 * void update_candidate_item_layout (const HelperAgent *, const std::vector<uint32> &row_items);
3438 HelperAgent::signal_connect_update_candidate_item_layout (HelperAgentSlotUintVector *slot)
3440 return m_impl->signal_update_candidate_item_layout.connect (slot);
3444 * @brief Connect a slot to Helper select associate signal.
3446 * This signal is used to do something when associate is selected.
3448 * The prototype of the slot is:
3449 * void select_associate (const HelperAgent *agent, int ic, const String &uuid, int index);
3452 HelperAgent::signal_connect_select_associate (HelperAgentSlotInt *slot)
3454 return m_impl->signal_select_associate.connect (slot);
3458 * @brief Connect a slot to Helper associate table page up signal.
3460 * This signal is used to do something when associate table is paged up.
3462 * The prototype of the slot is:
3463 * void associate_table_page_up (const HelperAgent *agent, int ic, const String &uuid);
3466 HelperAgent::signal_connect_associate_table_page_up (HelperAgentSlotVoid *slot)
3468 return m_impl->signal_associate_table_page_up.connect (slot);
3472 * @brief Connect a slot to Helper associate table page down signal.
3474 * This signal is used to do something when associate table is paged down.
3476 * The prototype of the slot is:
3477 * void associate_table_page_down (const HelperAgent *agent, int ic, const String &uuid);
3480 HelperAgent::signal_connect_associate_table_page_down (HelperAgentSlotVoid *slot)
3482 return m_impl->signal_associate_table_page_down.connect (slot);
3486 * @brief Connect a slot to Helper update associate table page size signal.
3488 * This signal is used to do something when associate table page size is changed.
3490 * The prototype of the slot is:
3491 * void update_associate_table_page_size (const HelperAgent *, int ic, const String &uuid, int page_size);
3494 HelperAgent::signal_connect_update_associate_table_page_size (HelperAgentSlotInt *slot)
3496 return m_impl->signal_update_associate_table_page_size.connect (slot);
3500 * @brief Connect a slot to Helper turn on log signal.
3502 * This signal is used to turn on Helper ISE debug information.
3504 * The prototype of the slot is:
3505 * void turn_on_log (const HelperAgent *agent, uint32 &on);
3508 HelperAgent::signal_connect_turn_on_log (HelperAgentSlotUintVoid *slot)
3510 return m_impl->signal_turn_on_log.connect (slot);
3514 * @brief Connect a slot to Helper update displayed candidate number signal.
3516 * This signal is used to inform helper ISE displayed candidate number.
3518 * The prototype of the slot is:
3519 * void update_displayed_candidate_number (const HelperAgent *, int ic, const String &uuid, int number);
3522 HelperAgent::signal_connect_update_displayed_candidate_number (HelperAgentSlotInt *slot)
3524 return m_impl->signal_update_displayed_candidate_number.connect (slot);
3528 * @brief Connect a slot to Helper longpress candidate signal.
3530 * This signal is used to do something when candidate is longpress.
3532 * The prototype of the slot is:
3533 * void longpress_candidate (const HelperAgent *agent, int ic, const String &uuid, int index);
3536 HelperAgent::signal_connect_longpress_candidate (HelperAgentSlotInt *slot)
3538 return m_impl->signal_longpress_candidate.connect (slot);
3542 * @brief Connect a slot to Helper show option window.
3544 * This signal is used to do request the ISE to show option window.
3546 * The prototype of the slot is:
3547 * void show_option_window (const HelperAgent *agent, int ic, const String &uuid);
3550 HelperAgent::signal_connect_show_option_window (HelperAgentSlotVoid *slot)
3552 return m_impl->signal_show_option_window.connect (slot);
3556 * @brief Connect a slot to Helper resume option window.
3558 * This signal is used to do request the ISE to resume option window.
3560 * The prototype of the slot is:
3561 * void resume_option_window (const HelperAgent *agent, int ic, const String &uuid);
3564 HelperAgent::signal_connect_resume_option_window (HelperAgentSlotVoid *slot)
3566 return m_impl->signal_resume_option_window.connect (slot);
3570 * @brief Connect a slot to Helper check if the option is available.
3572 * This signal is used to check if the option (setting) is available from Helper ISE.
3574 * The prototype of the slot is:
3575 * void check_option_window (const HelperAgent *agent, uint32 &avail);
3578 HelperAgent::signal_connect_check_option_window (HelperAgentSlotUintVoid *slot)
3580 return m_impl->signal_check_option_window.connect (slot);
3584 * @brief Connect a slot to Helper process unconventional input device event signal.
3586 * This signal is used to send unconventional input device event to Helper ISE.
3588 * The prototype of the slot is:
3589 * void process_input_device_event (const HelperAgent *, uint32 &type, char *data, size_t &size, uint32 &ret);
3592 HelperAgent::signal_connect_process_input_device_event (HelperAgentSlotUintCharSizeUint *slot)
3594 return m_impl->signal_process_input_device_event.connect (slot);
3598 * @brief Connect a slot to Helper set prediction hint signal.
3600 * This signal is used to send prediction hint to Helper ISE.
3602 * The prototype of the slot is:
3603 * void set_prediction_hint (const HelperAgent *agent, char *prediction_hint);
3606 HelperAgent::signal_connect_set_prediction_hint (HelperAgentSlotStringVoid *slot)
3608 return m_impl->signal_set_prediction_hint.connect (slot);
3612 * @brief Connect a slot to Helper set mime type signal.
3614 * This signal is used to send mime type to Helper ISE.
3616 * The prototype of the slot is:
3617 * void set_mime_type (const HelperAgent *agent, char *mime_type);
3620 HelperAgent::signal_connect_set_mime_type (HelperAgentSlotStringVoid *slot)
3622 return m_impl->signal_set_mime_type.connect (slot);
3626 * @brief Connect a slot to Helper set prediction hint data signal.
3628 * This signal is used to send prediction hint data to Helper ISE.
3630 * The prototype of the slot is:
3631 * void set_prediction_hint_data (const HelperAgent *agent, char *key, char *value);
3634 HelperAgent::signal_connect_set_prediction_hint_data (HelperAgentSlotString *slot)
3636 return m_impl->signal_set_prediction_hint_data.connect (slot);
3640 * @brief Connect a slot to Helper set optimization hint signal.
3642 * This signal is used to send optimization hint to Helper ISE.
3644 * The prototype of the slot is:
3645 * void set_optimization_hint (const HelperAgent *agent, uint32 &hint);
3648 HelperAgent::signal_connect_set_optimization_hint (HelperAgentSlotUintVoid *slot)
3650 return m_impl->signal_set_optimization_hint.connect (slot);
3654 * @brief Connect a slot to Helper process key event with imengine signal.
3656 * This signal is used to deliver the key event to Helper ISE.
3658 * The prototype of the slot is:
3659 * void process_key_event_with_imengine (const HelperAgent *agent, KeyEvent &key, uint32 serial);
3662 HelperAgent::signal_connect_process_key_event_with_imengine (HelperAgentSlotKeyEventUint2 *slot)
3664 return m_impl->signal_process_key_event_with_imengine.connect (slot);
3668 * @brief Connect a slot to Helper set autocapital type signal.
3670 * This signal is used to send autocapital type to imengine.
3672 * The prototype of the slot is:
3673 * void set_autocapital_type (const HelperAgent *agent, uint32 &type);
3676 HelperAgent::signal_connect_set_autocapital_type (HelperAgentSlotUintVoid *slot)
3678 return m_impl->signal_set_autocapital_type.connect (slot);
3682 * @brief Connect a slot to Helper set prediction allow signal.
3684 * This signal is used to send prediction allow to imengine.
3686 * The prototype of the slot is:
3687 * void set_prediction_allow (const HelperAgent *agent, uint32 &prediction_allow);
3690 HelperAgent::signal_connect_set_prediction_allow (HelperAgentSlotUintVoid *slot)
3692 return m_impl->signal_set_prediction_allow.connect (slot);
3695 } /* namespace scim */
3698 vi:ts=4:nowrap:ai:expandtab