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();
1029 m_impl->need_update_entry_metadata = false;
1032 case SCIM_TRANS_CMD_FOCUS_IN:
1034 MessageItemFocusIn *subclass = static_cast<MessageItemFocusIn*>(message);
1035 m_impl->ise_focus_flag = true;
1037 m_impl->need_update_entry_metadata = false;
1038 m_impl->signal_focus_in (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1039 m_impl->focused_ic = subclass->get_ic_ref();
1040 if (m_impl->finalized_text != NULL)
1041 free(m_impl->finalized_text);
1042 m_impl->finalized_text = NULL;
1043 m_impl->finalized_cursor_pos = 0;
1044 if (!m_impl->si.null ()) m_impl->si->focus_in();
1047 case ISM_TRANS_CMD_SHOW_ISE_PANEL:
1049 MessageItemShowISEPanel *subclass = static_cast<MessageItemShowISEPanel*>(message);
1050 LOGD ("Helper ISE received ISM_TRANS_CMD_SHOW_ISE_PANEL message");
1052 m_impl->signal_ise_show (this, subclass->get_ic_ref(), *(subclass->get_data_ptr()),
1053 subclass->get_len_ref());
1054 m_impl->ise_show_flag = true;
1057 case ISM_TRANS_CMD_HIDE_ISE_PANEL:
1059 MessageItemHideISEPanel *subclass = static_cast<MessageItemHideISEPanel*>(message);
1060 LOGD ("Helper ISE received ISM_TRANS_CMD_HIDE_ISE_PANEL message");
1061 if (m_impl->ise_show_flag)
1062 m_impl->signal_ise_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1063 m_impl->ise_show_flag = false;
1066 case ISM_TRANS_CMD_GET_ACTIVE_ISE_GEOMETRY:
1068 struct rectinfo info = {0, 0, 0, 0};
1069 m_impl->signal_get_geometry (this, info);
1070 m_impl->send.clear ();
1071 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1072 m_impl->send.put_data (info.pos_x);
1073 m_impl->send.put_data (info.pos_y);
1074 m_impl->send.put_data (info.width);
1075 m_impl->send.put_data (info.height);
1076 m_impl->send.write_to_socket (m_impl->socket);
1079 case ISM_TRANS_CMD_SET_ISE_MODE:
1081 MessageItemSetISEMode *subclass = static_cast<MessageItemSetISEMode*>(message);
1082 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode || m_impl->need_update_entry_metadata) {
1083 m_impl->signal_set_mode (this, subclass->get_mode_ref());
1087 case ISM_TRANS_CMD_SET_ISE_LANGUAGE:
1089 MessageItemSetISELanguage *subclass = static_cast<MessageItemSetISELanguage*>(message);
1090 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode || m_impl->need_update_entry_metadata) {
1091 m_impl->signal_set_language (this, subclass->get_language_ref());
1095 case ISM_TRANS_CMD_SET_ISE_IMDATA:
1097 MessageItemSetISEImData *subclass = static_cast<MessageItemSetISEImData*>(message);
1098 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode) {
1099 m_impl->signal_set_imdata (this, *(subclass->get_imdata_ptr()), subclass->get_len_ref());
1101 if (!m_impl->si.null ()) m_impl->si->set_imdata(*(subclass->get_imdata_ptr()),
1102 subclass->get_len_ref());
1105 case ISM_TRANS_CMD_GET_ISE_IMDATA:
1110 m_impl->signal_get_imdata (this, &buf, len);
1111 LOGD ("send ise imdata len = %zu", len);
1112 m_impl->send.clear ();
1113 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1114 m_impl->send.put_data (buf, len);
1115 m_impl->send.write_to_socket (m_impl->socket);
1120 case ISM_TRANS_CMD_GET_ISE_LANGUAGE_LOCALE:
1122 MessageItemGetISELanguageLocale *subclass = static_cast<MessageItemGetISELanguageLocale*>(message);
1124 m_impl->signal_get_language_locale (this, subclass->get_ic_ref(), &buf);
1125 m_impl->send.clear ();
1126 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1128 m_impl->send.put_data (buf, strlen (buf));
1129 m_impl->send.write_to_socket (m_impl->socket);
1134 case ISM_TRANS_CMD_SET_RETURN_KEY_TYPE:
1136 MessageItemSetReturnKeyType *subclass = static_cast<MessageItemSetReturnKeyType*>(message);
1137 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode || m_impl->need_update_entry_metadata) {
1138 m_impl->signal_set_return_key_type (this, subclass->get_type_ref());
1142 case ISM_TRANS_CMD_GET_RETURN_KEY_TYPE:
1145 m_impl->signal_get_return_key_type (this, type);
1146 m_impl->send.clear ();
1147 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1148 m_impl->send.put_data (type);
1149 m_impl->send.write_to_socket (m_impl->socket);
1152 case ISM_TRANS_CMD_SET_RETURN_KEY_DISABLE:
1154 MessageItemSetReturnKeyDisable *subclass = static_cast<MessageItemSetReturnKeyDisable*>(message);
1155 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode || m_impl->need_update_entry_metadata) {
1156 m_impl->signal_set_return_key_disable (this, subclass->get_disabled_ref());
1160 case ISM_TRANS_CMD_GET_RETURN_KEY_DISABLE:
1162 uint32 disabled = 0;
1163 m_impl->signal_get_return_key_type (this, disabled);
1164 m_impl->send.clear ();
1165 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1166 m_impl->send.put_data (disabled);
1167 m_impl->send.write_to_socket (m_impl->socket);
1170 case SCIM_TRANS_CMD_PROCESS_KEY_EVENT:
1172 MessageItemProcessKeyEvent *subclass = static_cast<MessageItemProcessKeyEvent*>(message);
1174 uint32 keycode_ret = 0;
1175 m_impl->signal_process_key_event(this, subclass->get_key_ref(), ret);
1176 m_impl->signal_process_key_event_with_keycode(this, subclass->get_key_ref(), keycode_ret, subclass->get_keycode_ref());
1178 if (ret != 0 || keycode_ret != 0) {
1180 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());
1201 case ISM_TRANS_CMD_SET_LAYOUT:
1203 MessageItemSetLayout *subclass = static_cast<MessageItemSetLayout*>(message);
1204 m_impl->layout = subclass->get_layout_ref();
1205 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode || m_impl->need_update_entry_metadata) {
1206 m_impl->signal_set_layout (this, subclass->get_layout_ref());
1208 if (!m_impl->si.null ()) m_impl->si->set_layout(subclass->get_layout_ref());
1211 case ISM_TRANS_CMD_GET_LAYOUT:
1215 m_impl->signal_get_layout (this, layout);
1216 m_impl->send.clear ();
1217 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1218 m_impl->send.put_data (layout);
1219 m_impl->send.write_to_socket (m_impl->socket);
1222 case ISM_TRANS_CMD_SET_INPUT_MODE:
1224 MessageItemSetInputMode *subclass = static_cast<MessageItemSetInputMode*>(message);
1225 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode || m_impl->need_update_entry_metadata) {
1226 m_impl->signal_set_input_mode (this, subclass->get_input_mode_ref());
1230 case ISM_TRANS_CMD_SET_CAPS_MODE:
1232 MessageItemSetCapsMode *subclass = static_cast<MessageItemSetCapsMode*>(message);
1233 m_impl->signal_set_caps_mode (this, subclass->get_mode_ref());
1236 case SCIM_TRANS_CMD_PANEL_RESET_INPUT_CONTEXT:
1238 MessageItemPanelResetInputContext *subclass = static_cast<MessageItemPanelResetInputContext*>(message);
1239 m_impl->signal_reset_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1240 if (!m_impl->si.null ()) m_impl->si->reset();
1243 case ISM_TRANS_CMD_UPDATE_CANDIDATE_UI:
1245 MessageItemUpdateCandidateUI *subclass = static_cast<MessageItemUpdateCandidateUI*>(message);
1246 m_impl->signal_update_candidate_ui (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1247 subclass->get_style_ref(), subclass->get_mode_ref());
1250 case ISM_TRANS_CMD_UPDATE_CANDIDATE_GEOMETRY:
1252 MessageItemUpdateCandidateGeometry *subclass = static_cast<MessageItemUpdateCandidateGeometry*>(message);
1253 m_impl->signal_update_candidate_geometry (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1254 subclass->get_rectinfo_ref());
1257 case ISM_TRANS_CMD_UPDATE_KEYBOARD_ISE:
1259 MessageItemUpdateKeyboardISE *subclass = static_cast<MessageItemUpdateKeyboardISE*>(message);
1260 m_impl->signal_update_keyboard_ise (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1261 subclass->get_name_ref(), subclass->get_uuid_ref());
1264 case ISM_TRANS_CMD_UPDATE_KEYBOARD_ISE_LIST:
1266 MessageItemUpdateKeyboardISEList *subclass = static_cast<MessageItemUpdateKeyboardISEList*>(message);
1267 m_impl->signal_update_keyboard_ise_list (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1268 subclass->get_list_ref());
1271 case ISM_TRANS_CMD_CANDIDATE_MORE_WINDOW_SHOW:
1273 MessageItemCandidateMoreWindowShow *subclass = static_cast<MessageItemCandidateMoreWindowShow*>(message);
1274 m_impl->signal_candidate_more_window_show (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1275 if (!m_impl->si.null ()) m_impl->si->candidate_more_window_show();
1278 case ISM_TRANS_CMD_CANDIDATE_MORE_WINDOW_HIDE:
1280 MessageItemCandidateMoreWindowHide *subclass = static_cast<MessageItemCandidateMoreWindowHide*>(message);
1281 m_impl->signal_candidate_more_window_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1282 if (!m_impl->si.null ()) m_impl->si->candidate_more_window_hide();
1285 case ISM_TRANS_CMD_SELECT_AUX:
1287 MessageItemSelectAux *subclass = static_cast<MessageItemSelectAux*>(message);
1288 m_impl->signal_select_aux (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1289 subclass->get_item_ref());
1290 if (!m_impl->si.null ()) m_impl->si->select_aux(subclass->get_item_ref());
1293 case SCIM_TRANS_CMD_SELECT_CANDIDATE: //FIXME:remove if useless
1295 MessageItemSelectCandidate *subclass = static_cast<MessageItemSelectCandidate*>(message);
1296 m_impl->signal_select_candidate (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1297 subclass->get_item_ref());
1298 if (!m_impl->si.null ()) m_impl->si->select_candidate(subclass->get_item_ref());
1301 case SCIM_TRANS_CMD_LOOKUP_TABLE_PAGE_UP: //FIXME:remove if useless
1303 MessageItemLookupTablePageUp *subclass = static_cast<MessageItemLookupTablePageUp*>(message);
1304 m_impl->signal_candidate_table_page_up (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1305 if (!m_impl->si.null ()) m_impl->si->lookup_table_page_up();
1308 case SCIM_TRANS_CMD_LOOKUP_TABLE_PAGE_DOWN: //FIXME:remove if useless
1310 MessageItemLookupTablePageDown *subclass = static_cast<MessageItemLookupTablePageDown*>(message);
1311 m_impl->signal_candidate_table_page_down (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1312 if (!m_impl->si.null ()) m_impl->si->lookup_table_page_down();
1315 case SCIM_TRANS_CMD_UPDATE_LOOKUP_TABLE_PAGE_SIZE:
1317 MessageItemUpdateLookupTablePageSize *subclass = static_cast<MessageItemUpdateLookupTablePageSize*>(message);
1318 m_impl->signal_update_candidate_table_page_size (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1319 subclass->get_size_ref());
1320 if (!m_impl->si.null ()) m_impl->si->update_lookup_table_page_size(subclass->get_size_ref());
1323 case ISM_TRANS_CMD_CANDIDATE_SHOW: //FIXME:remove if useless
1325 MessageItemCandidateShow *subclass = static_cast<MessageItemCandidateShow*>(message);
1326 m_impl->signal_candidate_show (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1329 case ISM_TRANS_CMD_CANDIDATE_HIDE: //FIXME:remove if useless
1331 MessageItemCandidateHide *subclass = static_cast<MessageItemCandidateHide*>(message);
1332 m_impl->signal_candidate_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1335 case ISM_TRANS_CMD_UPDATE_LOOKUP_TABLE: //FIXME:remove if useless
1337 MessageItemUpdateLookupTable *subclass = static_cast<MessageItemUpdateLookupTable*>(message);
1338 m_impl->signal_update_lookup_table (this, subclass->get_candidate_table_ref());
1341 case ISM_TRANS_CMD_UPDATE_CANDIDATE_ITEM_LAYOUT:
1343 MessageItemUpdateCandidateItemLayout *subclass = static_cast<MessageItemUpdateCandidateItemLayout*>(message);
1344 m_impl->signal_update_candidate_item_layout (this, subclass->get_row_items_ref());
1345 if (!m_impl->si.null ()) m_impl->si->update_candidate_item_layout(subclass->get_row_items_ref());
1348 case ISM_TRANS_CMD_SELECT_ASSOCIATE:
1350 MessageItemSelectAssociate *subclass = static_cast<MessageItemSelectAssociate*>(message);
1351 m_impl->signal_select_associate (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1352 subclass->get_item_ref());
1355 case ISM_TRANS_CMD_ASSOCIATE_TABLE_PAGE_UP:
1357 MessageItemAssociateTablePageUp *subclass = static_cast<MessageItemAssociateTablePageUp*>(message);
1358 m_impl->signal_associate_table_page_up (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1361 case ISM_TRANS_CMD_ASSOCIATE_TABLE_PAGE_DOWN:
1363 MessageItemAssociateTablePageDown *subclass = static_cast<MessageItemAssociateTablePageDown*>(message);
1364 m_impl->signal_associate_table_page_down (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1367 case ISM_TRANS_CMD_UPDATE_ASSOCIATE_TABLE_PAGE_SIZE:
1369 MessageItemUpdateAssociateTablePageSize *subclass = static_cast<MessageItemUpdateAssociateTablePageSize*>(message);
1370 m_impl->signal_update_associate_table_page_size (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1371 subclass->get_size_ref());
1374 case ISM_TRANS_CMD_RESET_ISE_CONTEXT:
1376 MessageItemResetISEContext *subclass = static_cast<MessageItemResetISEContext*>(message);
1377 m_impl->signal_reset_ise_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1378 m_impl->signal_reset_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1379 if (!m_impl->si.null ()) m_impl->si->reset();
1382 case ISM_TRANS_CMD_TURN_ON_LOG:
1384 MessageItemTurnOnLog *subclass = static_cast<MessageItemTurnOnLog*>(message);
1385 m_impl->signal_turn_on_log (this, subclass->get_state_ref());
1388 case ISM_TRANS_CMD_UPDATE_DISPLAYED_CANDIDATE:
1390 MessageItemUpdateDisplayedCandidate *subclass = static_cast<MessageItemUpdateDisplayedCandidate*>(message);
1391 m_impl->signal_update_displayed_candidate_number (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1392 subclass->get_size_ref());
1393 if (!m_impl->si.null ()) m_impl->si->update_displayed_candidate_number(subclass->get_size_ref());
1396 case ISM_TRANS_CMD_LONGPRESS_CANDIDATE:
1398 MessageItemLongpressCandidate *subclass = static_cast<MessageItemLongpressCandidate*>(message);
1399 m_impl->signal_longpress_candidate (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1400 subclass->get_index_ref());
1401 if (!m_impl->si.null ()) m_impl->si->longpress_candidate(subclass->get_index_ref());
1404 case ISM_TRANS_CMD_SET_INPUT_HINT:
1406 MessageItemSetInputHint *subclass = static_cast<MessageItemSetInputHint*>(message);
1407 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode || m_impl->need_update_entry_metadata) {
1408 m_impl->signal_set_input_hint (this, subclass->get_input_hint_ref());
1410 if (!m_impl->si.null ()) m_impl->si->set_input_hint(subclass->get_input_hint_ref());
1413 case ISM_TRANS_CMD_UPDATE_BIDI_DIRECTION:
1415 MessageItemUpdateBidiDirection *subclass = static_cast<MessageItemUpdateBidiDirection*>(message);
1416 m_impl->signal_update_bidi_direction (this, subclass->get_bidi_direction());
1417 if (!m_impl->si.null ()) m_impl->si->update_bidi_direction(subclass->get_bidi_direction());
1420 case ISM_TRANS_CMD_SHOW_ISE_OPTION_WINDOW:
1422 MessageItemShowISEOptionWindow *subclass = static_cast<MessageItemShowISEOptionWindow*>(message);
1423 m_impl->signal_show_option_window (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1426 case ISM_TRANS_CMD_RESUME_ISE_OPTION_WINDOW:
1428 MessageItemResumeISEOptionWindow *subclass = static_cast<MessageItemResumeISEOptionWindow*>(message);
1429 m_impl->signal_resume_option_window (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1432 case ISM_TRANS_CMD_CHECK_OPTION_WINDOW:
1435 m_impl->signal_check_option_window (this, avail);
1436 m_impl->send.clear ();
1437 m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1438 m_impl->send.put_data (avail);
1439 m_impl->send.write_to_socket (m_impl->socket);
1442 case ISM_TRANS_CMD_PROCESS_INPUT_DEVICE_EVENT:
1444 MessageItemProcessInputDeviceEvent *subclass = static_cast<MessageItemProcessInputDeviceEvent*>(message);
1446 unsigned int ecore_event_id = find_ecore_event_from_device_type((isf_device_type_e)(subclass->get_type_ref()));
1447 char *decoded = (char*)malloc(subclass->get_len_ref());
1448 size_t decoded_size = subclass->get_len_ref();
1450 if(device_buffer_decode((const char*)*(subclass->get_data_ptr()),
1451 subclass->get_len_ref(), (char*)(decoded), &decoded_size)) {
1452 m_impl->signal_process_input_device_event(this, ecore_event_id, decoded, decoded_size, ret);
1458 case SCIM_TRANS_CMD_SET_AUTOCAPITAL_TYPE:
1460 MessageItemSetAutocapitalType *subclass = static_cast<MessageItemSetAutocapitalType*>(message);
1461 if (!m_impl->si.null ()) m_impl->si->set_autocapital_type(subclass->get_auto_capital_type_ref());
1462 m_impl->signal_set_autocapital_type(this, subclass->get_auto_capital_type_ref());
1465 case ISM_TRANS_CMD_SET_PREDICTION_ALLOW:
1467 MessageItemSetPredictionAllow *subclass = static_cast<MessageItemSetPredictionAllow*>(message);
1468 if (!m_impl->si.null ()) m_impl->si->set_prediction_allow(subclass->get_prediction_allow_ref() == 0 ? false : true);
1469 m_impl->signal_set_prediction_allow(this, subclass->get_prediction_allow_ref());
1472 case ISM_TRANS_CMD_SET_KEYBOARD_MODE:
1474 MessageItemSetKeyboardMode *subclass = static_cast<MessageItemSetKeyboardMode*>(message);
1475 if (subclass->get_mode_ref())
1476 m_impl->hw_keyboard_mode = false;
1478 m_impl->hw_keyboard_mode = true;
1481 case ISM_TRANS_CMD_SET_PREDICTION_HINT:
1483 MessageItemSetPredictionHint *subclass = static_cast<MessageItemSetPredictionHint*>(message);
1484 m_impl->signal_set_prediction_hint (this, subclass->get_message_ref());
1487 case ISM_TRANS_CMD_SET_MIME_TYPE:
1489 MessageItemSetMimeType *subclass = static_cast<MessageItemSetMimeType*>(message);
1490 if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode || m_impl->need_update_entry_metadata) {
1491 m_impl->signal_set_mime_type (this, subclass->get_mime_type_ref());
1495 case ISM_TRANS_CMD_FINALIZE_CONTENT:
1497 MessageItemFinalizeContent *subclass = static_cast<MessageItemFinalizeContent*>(message);
1499 if (m_impl->finalized_text != NULL)
1500 free(m_impl->finalized_text);
1501 m_impl->finalized_text = strdup(subclass->get_text_ref().c_str());
1502 m_impl->finalized_cursor_pos = subclass->get_cursor_pos_ref();
1506 case ISM_TRANS_CMD_SET_PREDICTION_HINT_DATA:
1508 MessageItemSetPredictionHintData *subclass = static_cast<MessageItemSetPredictionHintData*>(message);
1509 m_impl->signal_set_prediction_hint_data (this, 0, subclass->get_key_ref(), subclass->get_value_ref());
1512 case ISM_TRANS_CMD_SET_OPTIMIZATION_HINT:
1514 MessageItemSetOptimizationHint *subclass = static_cast<MessageItemSetOptimizationHint*>(message);
1515 m_impl->signal_set_optimization_hint(this, subclass->get_hint_ref());
1525 * @brief Request SCIM to reload all configuration.
1527 * This function should only by used by Setup Helper to request
1528 * scim's reloading the configuration.
1529 * Deprecated: reload config message only send by socketconfig client
1530 * using socketconfig::reload instead.
1533 HelperAgent::reload_config () const
1535 LOGD ("send reload config message to isf");
1536 if (!m_impl->m_config.null())
1537 m_impl->m_config->reload();
1541 * @brief Register some properties into Panel.
1543 * This function send the request to Panel to register a list
1546 * @param properties The list of Properties to be registered into Panel.
1548 * @sa scim::Property.
1551 HelperAgent::register_properties (const PropertyList &properties) const
1553 if (m_impl->socket_active.is_connected ()) {
1554 m_impl->send.clear ();
1555 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1556 m_impl->send.put_data (m_impl->magic_active);
1557 m_impl->send.put_command (SCIM_TRANS_CMD_REGISTER_PROPERTIES);
1558 m_impl->send.put_data (properties);
1559 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1564 * @brief Update a registered property.
1566 * @param property The property to be updated.
1569 HelperAgent::update_property (const Property &property) const
1571 if (m_impl->socket_active.is_connected ()) {
1572 m_impl->send.clear ();
1573 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1574 m_impl->send.put_data (m_impl->magic_active);
1575 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PROPERTY);
1576 m_impl->send.put_data (property);
1577 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1582 * @brief Send a set of events to an IMEngineInstance.
1584 * All events should be put into a Transaction.
1585 * And the events can only be received by one IMEngineInstance object.
1587 * @param ic The handle of the Input Context to receive the events.
1588 * @param ic_uuid The UUID of the Input Context.
1589 * @param trans The Transaction object holds the events.
1592 HelperAgent::send_imengine_event (int ic,
1593 const String &ic_uuid,
1594 const Transaction &trans) const
1596 //remove if not necessary
1598 if (m_impl->socket_active.is_connected ()) {
1599 m_impl->send.clear ();
1600 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1601 m_impl->send.put_data (m_impl->magic_active);
1602 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_SEND_IMENGINE_EVENT);
1603 m_impl->send.put_data ((uint32)ic);
1604 m_impl->send.put_data (ic_uuid);
1605 m_impl->send.put_data (trans);
1606 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1609 if (!m_impl->si.null ()) m_impl->si->process_helper_event (ic_uuid, trans);
1613 * @brief Send a KeyEvent to an IMEngineInstance.
1615 * @param ic The handle of the IMEngineInstance to receive the event.
1616 * -1 means the currently focused IMEngineInstance.
1617 * @param ic_uuid The UUID of the IMEngineInstance. Empty means don't match.
1618 * @param key The KeyEvent to be sent.
1621 HelperAgent::send_key_event (int ic,
1622 const String &ic_uuid,
1623 const KeyEvent &key) const
1626 //FIXME: remove shift_mode_off, shift_mode_on, shift_mode_lock from ISE side
1627 if (key.code == SHIFT_MODE_OFF ||
1628 key.code == SHIFT_MODE_ON ||
1629 key.code == SHIFT_MODE_LOCK ||
1630 key.code == SHIFT_MODE_ENABLE ||
1631 key.code == SHIFT_MODE_DISABLE) {
1632 LOGW("FIXME ignore shift codes");
1636 if (m_impl->socket_active.is_connected ()) {
1637 m_impl->send.clear ();
1638 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1639 m_impl->send.put_data (m_impl->magic_active);
1640 m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_SEND_KEY_EVENT);
1642 m_impl->send.put_data (m_impl->focused_ic);
1644 m_impl->send.put_data ((uint32)ic);
1646 m_impl->send.put_data (ic_uuid);
1647 m_impl->send.put_data (key);
1648 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1653 * @brief Forward a KeyEvent to client application directly.
1655 * @param ic The handle of the client Input Context to receive the event.
1656 * -1 means the currently focused Input Context.
1657 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1658 * Empty means don't match.
1659 * @param key The KeyEvent to be forwarded.
1662 HelperAgent::forward_key_event (int ic,
1663 const String &ic_uuid,
1664 const KeyEvent &key) const
1666 if (m_impl->socket_active.is_connected ()) {
1667 m_impl->send.clear ();
1668 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1669 m_impl->send.put_data (m_impl->magic_active);
1670 m_impl->send.put_command (SCIM_TRANS_CMD_FORWARD_KEY_EVENT);
1672 m_impl->send.put_data (m_impl->focused_ic);
1674 m_impl->send.put_data ((uint32)ic);
1676 m_impl->send.put_data (ic_uuid);
1677 m_impl->send.put_data (key);
1678 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1683 * @brief Commit a WideString to client application directly.
1685 * @param ic The handle of the client Input Context to receive the WideString.
1686 * -1 means the currently focused Input Context.
1687 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1688 * Empty means don't match.
1689 * @param wstr The WideString to be committed.
1692 HelperAgent::commit_string (int ic,
1693 const String &ic_uuid,
1694 const WideString &wstr) const
1696 if (m_impl->socket_active.is_connected ()) {
1697 m_impl->send.clear ();
1698 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1699 m_impl->send.put_data (m_impl->magic_active);
1700 m_impl->send.put_command (SCIM_TRANS_CMD_COMMIT_STRING);
1702 m_impl->send.put_data (m_impl->focused_ic);
1704 m_impl->send.put_data ((uint32)ic);
1706 m_impl->send.put_data (ic_uuid);
1707 m_impl->send.put_data (wstr);
1708 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1713 HelperAgent::commit_string (int ic,
1714 const String &ic_uuid,
1718 if (m_impl->socket_active.is_connected ()) {
1719 m_impl->send.clear ();
1720 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1721 m_impl->send.put_data (m_impl->magic_active);
1722 m_impl->send.put_command (SCIM_TRANS_CMD_COMMIT_STRING);
1724 m_impl->send.put_data (m_impl->focused_ic);
1726 m_impl->send.put_data ((uint32)ic);
1728 m_impl->send.put_data (ic_uuid);
1729 m_impl->send.put_dataw (buf, buflen);
1730 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1735 * @brief Request to show preedit string.
1737 * @param ic The handle of the client Input Context to receive the request.
1738 * -1 means the currently focused Input Context.
1739 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1740 * Empty means don't match.
1743 HelperAgent::show_preedit_string (int ic,
1744 const String &ic_uuid) const
1747 if (m_impl->socket_active.is_connected ()) {
1748 m_impl->send.clear ();
1749 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1750 m_impl->send.put_data (m_impl->magic_active);
1751 m_impl->send.put_command (SCIM_TRANS_CMD_SHOW_PREEDIT_STRING);
1752 m_impl->send.put_data ((uint32)ic);
1753 m_impl->send.put_data (ic_uuid);
1754 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1759 * @brief Request to show aux string.
1762 HelperAgent::show_aux_string (void) const
1765 if (m_impl->socket_active.is_connected ()) {
1766 m_impl->send.clear ();
1767 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1768 m_impl->send.put_data (m_impl->magic_active);
1769 m_impl->send.put_command (SCIM_TRANS_CMD_SHOW_AUX_STRING);
1770 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1775 * @brief Request to show candidate string.
1778 HelperAgent::show_candidate_string (void) const
1781 if (m_impl->socket_active.is_connected ()) {
1782 m_impl->send.clear ();
1783 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1784 m_impl->send.put_data (m_impl->magic_active);
1785 m_impl->send.put_command (SCIM_TRANS_CMD_SHOW_LOOKUP_TABLE);
1786 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1791 * @brief Request to show associate string.
1794 HelperAgent::show_associate_string (void) const
1796 if (m_impl->socket_active.is_connected ()) {
1797 m_impl->send.clear ();
1798 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1799 m_impl->send.put_data (m_impl->magic_active);
1800 m_impl->send.put_command (ISM_TRANS_CMD_SHOW_ASSOCIATE_TABLE);
1801 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1806 * @brief Request to hide preedit string.
1808 * @param ic The handle of the client Input Context to receive the request.
1809 * -1 means the currently focused Input Context.
1810 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1811 * Empty means don't match.
1814 HelperAgent::hide_preedit_string (int ic,
1815 const String &ic_uuid) const
1818 if (m_impl->socket_active.is_connected ()) {
1819 m_impl->send.clear ();
1820 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1821 m_impl->send.put_data (m_impl->magic_active);
1822 m_impl->send.put_command (SCIM_TRANS_CMD_HIDE_PREEDIT_STRING);
1823 m_impl->send.put_data ((uint32)ic);
1824 m_impl->send.put_data (ic_uuid);
1825 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1830 * @brief Request to hide aux string.
1833 HelperAgent::hide_aux_string (void) const
1835 if (m_impl->socket_active.is_connected ()) {
1836 m_impl->send.clear ();
1837 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1838 m_impl->send.put_data (m_impl->magic_active);
1839 m_impl->send.put_command (SCIM_TRANS_CMD_HIDE_AUX_STRING);
1840 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1845 * @brief Request to hide candidate string.
1848 HelperAgent::hide_candidate_string (void) const
1850 if (m_impl->socket_active.is_connected ()) {
1851 m_impl->send.clear ();
1852 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1853 m_impl->send.put_data (m_impl->magic_active);
1854 m_impl->send.put_command (SCIM_TRANS_CMD_HIDE_LOOKUP_TABLE);
1855 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1860 * @brief Request to hide associate string.
1863 HelperAgent::hide_associate_string (void) const
1865 if (m_impl->socket_active.is_connected ()) {
1866 m_impl->send.clear ();
1867 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1868 m_impl->send.put_data (m_impl->magic_active);
1869 m_impl->send.put_command (ISM_TRANS_CMD_HIDE_ASSOCIATE_TABLE);
1870 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1875 * @brief Update a new WideString for preedit.
1877 * @param ic The handle of the client Input Context to receive the WideString.
1878 * -1 means the currently focused Input Context.
1879 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1880 * Empty means don't match.
1881 * @param str The WideString to be updated.
1882 * @param attrs The attribute list for preedit string.
1885 HelperAgent::update_preedit_string (int ic,
1886 const String &ic_uuid,
1887 const WideString &str,
1888 const AttributeList &attrs) const
1890 update_preedit_string (ic, ic_uuid, str, str, attrs, -1);
1894 HelperAgent::update_preedit_string (int ic,
1895 const String &ic_uuid,
1898 const AttributeList &attrs) const
1900 update_preedit_string (ic, ic_uuid, buf, buflen, attrs, -1);
1904 * @brief Update a new WideString for preedit.
1906 * @param ic The handle of the client Input Context to receive the WideString.
1907 * -1 means the currently focused Input Context.
1908 * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1909 * Empty means don't match.
1910 * @param str The WideString to be updated.
1911 * @param attrs The attribute list for preedit string.
1912 * @param caret The caret position in preedit string.
1915 HelperAgent::update_preedit_string (int ic,
1916 const String &ic_uuid,
1917 const WideString &wstr,
1918 const AttributeList &attrs,
1921 update_preedit_string (ic, ic_uuid, wstr, wstr, attrs, caret);
1925 HelperAgent::update_preedit_string (int ic,
1926 const String &ic_uuid,
1929 const AttributeList &attrs,
1933 if (m_impl->socket_active.is_connected ()) {
1934 m_impl->send.clear ();
1935 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1936 m_impl->send.put_data (m_impl->magic_active);
1937 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING);
1938 m_impl->send.put_data ((uint32)ic);
1939 m_impl->send.put_data (ic_uuid);
1940 m_impl->send.put_dataw (buf, buflen);
1941 m_impl->send.put_dataw (buf, buflen);
1942 m_impl->send.put_data (attrs);
1943 m_impl->send.put_data (caret);
1944 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1949 HelperAgent::update_preedit_string (int ic,
1950 const String &ic_uuid,
1951 const WideString &preedit,
1952 const WideString &commit,
1953 const AttributeList &attrs,
1956 if (m_impl->socket_active.is_connected ()) {
1957 m_impl->send.clear ();
1958 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1959 m_impl->send.put_data (m_impl->magic_active);
1960 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING);
1961 m_impl->send.put_data ((uint32)ic);
1962 m_impl->send.put_data (ic_uuid);
1963 m_impl->send.put_data (preedit);
1964 m_impl->send.put_data (commit);
1965 m_impl->send.put_data (attrs);
1966 m_impl->send.put_data (caret);
1967 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1972 * @brief Update the preedit caret position in the preedit string.
1974 * @param caret - the new position of the preedit caret.
1977 HelperAgent::update_preedit_caret (int caret) const
1980 if (m_impl->socket_active.is_connected ()) {
1981 m_impl->send.clear ();
1982 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1983 m_impl->send.put_data (m_impl->magic_active);
1984 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_CARET);
1985 m_impl->send.put_data ((uint32)caret);
1986 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1991 * @brief Update a new string for aux.
1993 * @param str The string to be updated.
1994 * @param attrs The attribute list for aux string.
1997 HelperAgent::update_aux_string (const String &str,
1998 const AttributeList &attrs) const
2000 if (m_impl->socket_active.is_connected ()) {
2001 m_impl->send.clear ();
2002 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2003 m_impl->send.put_data (m_impl->magic_active);
2004 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_AUX_STRING);
2005 m_impl->send.put_data (str);
2006 m_impl->send.put_data (attrs);
2007 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2012 * @brief Request to update candidate.
2014 * @param table The lookup table for candidate.
2017 HelperAgent::update_candidate_string (const LookupTable &table) const
2019 if (m_impl->socket_active.is_connected ()) {
2020 m_impl->send.clear ();
2021 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2022 m_impl->send.put_data (m_impl->magic_active);
2023 m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_LOOKUP_TABLE);
2024 m_impl->send.put_data (table);
2025 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2030 * @brief Request to update associate.
2032 * @param table The lookup table for associate.
2035 HelperAgent::update_associate_string (const LookupTable &table) const
2037 if (m_impl->socket_active.is_connected ()) {
2038 m_impl->send.clear ();
2039 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2040 m_impl->send.put_data (m_impl->magic_active);
2041 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ASSOCIATE_TABLE);
2042 m_impl->send.put_data (table);
2043 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2048 * @brief When the input context of ISE is changed,
2049 * ISE can call this function to notify application
2051 * @param type type of event.
2052 * @param value value of event.
2055 HelperAgent::update_input_context (uint32 type, uint32 value) const
2057 if (type == ECORE_IMF_INPUT_PANEL_LANGUAGE_EVENT) {
2058 /* Update all state variables that could be queried by the client application */
2060 m_impl->signal_get_language_locale(this, -1, &buf);
2063 if (m_impl->socket_active.is_connected()) {
2064 m_impl->send.clear();
2065 m_impl->send.put_command(SCIM_TRANS_CMD_REQUEST);
2066 m_impl->send.put_data(m_impl->magic_active);
2067 m_impl->send.put_command(ISM_TRANS_CMD_UPDATE_ISE_LANGUAGE_LOCALE);
2068 m_impl->send.put_data(buf, strlen(buf));
2069 m_impl->send.write_to_socket(m_impl->socket_active, m_impl->magic_active);
2076 if (m_impl->socket_active.is_connected ()) {
2077 m_impl->send.clear ();
2078 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2079 m_impl->send.put_data (m_impl->magic_active);
2080 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ISE_INPUT_CONTEXT);
2081 m_impl->send.put_data (type);
2082 m_impl->send.put_data (value);
2083 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2088 * @brief Request to get surrounding text asynchronously.
2090 * @param uuid The helper ISE UUID.
2091 * @param maxlen_before The max length of before.
2092 * @param maxlen_after The max length of after.
2095 HelperAgent::get_surrounding_text (const String &uuid, int maxlen_before, int maxlen_after) const
2097 if (m_impl->socket_active.is_connected () && (m_impl->need_update_surrounding_text == 0)) {
2098 m_impl->send.clear ();
2099 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2100 m_impl->send.put_data (m_impl->magic_active);
2101 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SURROUNDING_TEXT);
2102 m_impl->send.put_data (uuid);
2103 m_impl->send.put_data (maxlen_before);
2104 m_impl->send.put_data (maxlen_after);
2105 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2107 m_impl->need_update_surrounding_text++;
2111 * @brief Request to get surrounding text synchronously.
2113 * @param uuid The helper ISE UUID.
2114 * @param maxlen_before The max length of before.
2115 * @param maxlen_after The max length of after.
2116 * @param text The surrounding text.
2117 * @param cursor The cursor position.
2120 HelperAgent::get_surrounding_text (int maxlen_before, int maxlen_after, String &text, int &cursor)
2122 if (!m_impl->socket_active.is_connected ())
2125 if (!m_impl->ise_focus_flag) {
2126 if (m_impl->finalized_text) {
2127 String buffer = m_impl->finalized_text;
2128 cursor = m_impl->finalized_cursor_pos;
2129 int pos = cursor - maxlen_before;
2130 if (maxlen_before < 0) pos = 0;
2131 if (pos > (int)buffer.length()) pos = (int)buffer.length();
2132 if (pos < 0) pos = 0;
2133 size_t len = maxlen_after + (cursor - pos);
2134 if (maxlen_after < 0) len = String::npos;
2135 text = buffer.substr (pos, len);
2141 m_impl->send.clear();
2142 m_impl->send.put_command(SCIM_TRANS_CMD_REQUEST);
2143 m_impl->send.put_data(m_impl->magic_active);
2144 m_impl->send.put_command(SCIM_TRANS_CMD_GET_SURROUNDING_TEXT);
2145 m_impl->send.put_data("");
2146 m_impl->send.put_data(maxlen_before);
2147 m_impl->send.put_data(maxlen_after);
2148 m_impl->send.write_to_socket(m_impl->socket_active, m_impl->magic_active);
2149 if (m_impl->surrounding_text) {
2150 free(m_impl->surrounding_text);
2151 m_impl->surrounding_text = NULL;
2154 const int WAIT_FOR_SYNC_RESPONSE_TIMEOUT = 1000;
2155 /* Now we are waiting for the ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT message */
2156 if (wait_for_message(ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT, WAIT_FOR_SYNC_RESPONSE_TIMEOUT)) {
2157 MessageItem *message = message_queue.get_pending_message_by_cmd(ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT);
2158 handle_message(message);
2159 message_queue.remove_message(message);
2161 if (m_impl->surrounding_text) {
2162 text = m_impl->surrounding_text;
2163 cursor = m_impl->cursor_pos;
2167 if (m_impl->surrounding_text) {
2168 free(m_impl->surrounding_text);
2169 m_impl->surrounding_text = NULL;
2172 LOGD("message_queue size : %d", message_queue.get_message_size());
2174 m_impl->send.clear ();
2175 m_impl->send.put_command(SCIM_TRANS_CMD_REQUEST);
2176 m_impl->send.put_data(m_impl->magic_active);
2177 m_impl->send.put_command(SCIM_TRANS_CMD_PING);
2178 m_impl->send.write_to_socket(m_impl->socket_active, m_impl->magic_active);
2183 * @brief Request to delete surrounding text.
2185 * @param offset The offset for cursor position.
2186 * @param len The length for delete text.
2189 HelperAgent::delete_surrounding_text (int offset, int len) const
2191 LOGD ("offset = %d, len = %d", offset, len);
2193 if (m_impl->socket_active.is_connected ()) {
2194 m_impl->send.clear ();
2195 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2196 m_impl->send.put_data (m_impl->magic_active);
2197 m_impl->send.put_command (SCIM_TRANS_CMD_DELETE_SURROUNDING_TEXT);
2198 m_impl->send.put_data (offset);
2199 m_impl->send.put_data (len);
2200 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2205 * @brief Request to get selection text asynchronously.
2207 * @param uuid The helper ISE UUID.
2210 HelperAgent::get_selection (const String &uuid) const
2212 if (m_impl->socket_active.is_connected () && (m_impl->need_update_selection_text == 0)) {
2213 m_impl->send.clear ();
2214 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2215 m_impl->send.put_data (m_impl->magic_active);
2216 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SELECTION);
2217 m_impl->send.put_data (uuid);
2218 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2220 m_impl->need_update_selection_text++;
2224 * @brief Request to get selection text synchronously.
2226 * @param text The selection text.
2229 HelperAgent::get_selection_text (String &text)
2232 if (!m_impl->socket_active.is_connected ())
2235 m_impl->send.clear ();
2236 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2237 m_impl->send.put_data (m_impl->magic_active);
2238 m_impl->send.put_command (SCIM_TRANS_CMD_GET_SELECTION);
2239 m_impl->send.put_data ("");
2240 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2241 if (m_impl->selection_text) {
2242 free (m_impl->selection_text);
2243 m_impl->selection_text = NULL;
2246 const int WAIT_FOR_SYNC_RESPONSE_TIMEOUT = 1000;
2247 /* Now we are waiting for the ISM_TRANS_CMD_UPDATE_SELECTION message */
2248 if (wait_for_message(ISM_TRANS_CMD_UPDATE_SELECTION, WAIT_FOR_SYNC_RESPONSE_TIMEOUT)) {
2249 MessageItem *message = message_queue.get_pending_message_by_cmd(ISM_TRANS_CMD_UPDATE_SELECTION);
2250 handle_message(message);
2251 message_queue.remove_message(message);
2252 if (m_impl->selection_text) {
2253 text = m_impl->selection_text;
2257 if (m_impl->selection_text) {
2258 free (m_impl->selection_text);
2259 m_impl->selection_text = NULL;
2262 LOGD("message_queue size : %d", message_queue.get_message_size());
2264 m_impl->send.clear ();
2265 m_impl->send.put_command(SCIM_TRANS_CMD_REQUEST);
2266 m_impl->send.put_data(m_impl->magic_active);
2267 m_impl->send.put_command(SCIM_TRANS_CMD_PING);
2268 m_impl->send.write_to_socket(m_impl->socket_active, m_impl->magic_active);
2272 * @brief Request to select text.
2274 * @param start The start position in text.
2275 * @param end The end position in text.
2278 HelperAgent::set_selection (int start, int end) const
2280 if (m_impl->socket_active.is_connected ()) {
2281 m_impl->send.clear ();
2282 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2283 m_impl->send.put_data (m_impl->magic_active);
2284 m_impl->send.put_command (SCIM_TRANS_CMD_SET_SELECTION);
2285 m_impl->send.put_data (start);
2286 m_impl->send.put_data (end);
2287 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2292 * @brief Send a private command to an application.
2294 * @param command The private command sent from IME.
2297 HelperAgent::send_private_command (const String &command) const
2299 if (m_impl->socket_active.is_connected ()) {
2300 m_impl->send.clear ();
2301 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2302 m_impl->send.put_data (m_impl->magic_active);
2303 m_impl->send.put_command (SCIM_TRANS_CMD_SEND_PRIVATE_COMMAND);
2304 m_impl->send.put_data (command);
2305 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2310 * @brief Commit content to an application.
2312 * @param content The content sent from IME.
2315 HelperAgent::commit_content (const String &content, const String &description, const String &mime_types) const
2318 if (m_impl->socket_active.is_connected ()) {
2319 m_impl->send.clear ();
2320 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2321 m_impl->send.put_data (m_impl->magic_active);
2322 m_impl->send.put_command (SCIM_TRANS_CMD_COMMIT_CONTENT);
2323 m_impl->send.put_data (content);
2324 m_impl->send.put_data (description);
2325 m_impl->send.put_data (mime_types);
2326 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2331 * @brief Request to get uuid list of all keyboard ISEs.
2333 * @param uuid The helper ISE UUID.
2336 HelperAgent::get_keyboard_ise_list (const String &uuid) const
2338 if (m_impl->socket_active.is_connected ()) {
2339 m_impl->send.clear ();
2340 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2341 m_impl->send.put_data (m_impl->magic_active);
2342 m_impl->send.put_command (ISM_TRANS_CMD_GET_KEYBOARD_ISE_LIST);
2343 m_impl->send.put_data (uuid);
2344 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2349 * @brief Set candidate position in screen.
2351 * @param left The x position in screen.
2352 * @param top The y position in screen.
2355 HelperAgent::set_candidate_position (int left, int top) const
2357 if (m_impl->socket_active.is_connected ()) {
2358 m_impl->send.clear ();
2359 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2360 m_impl->send.put_data (m_impl->magic_active);
2361 m_impl->send.put_command (ISM_TRANS_CMD_SET_CANDIDATE_POSITION);
2362 m_impl->send.put_data (left);
2363 m_impl->send.put_data (top);
2364 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2369 * @brief Set candidate style.
2371 * @param portrait_line - the displayed line number for portrait mode.
2372 * @param mode - candidate window mode.
2375 HelperAgent::set_candidate_style (ISF_CANDIDATE_PORTRAIT_LINE_T portrait_line,
2376 ISF_CANDIDATE_MODE_T mode) const
2378 if (m_impl->socket_active.is_connected ()) {
2379 m_impl->send.clear ();
2380 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2381 m_impl->send.put_data (m_impl->magic_active);
2382 m_impl->send.put_command (ISM_TRANS_CMD_SET_CANDIDATE_UI);
2383 m_impl->send.put_data (portrait_line);
2384 m_impl->send.put_data (mode);
2385 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2390 * @brief Request to hide candidate window.
2393 HelperAgent::candidate_hide (void) const
2395 if (m_impl->socket_active.is_connected ()) {
2396 m_impl->send.clear ();
2397 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2398 m_impl->send.put_data (m_impl->magic_active);
2399 m_impl->send.put_command (ISM_TRANS_CMD_HIDE_CANDIDATE);
2400 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2405 * @brief Request to get candidate window size and position.
2407 * @param uuid The helper ISE UUID.
2410 HelperAgent::get_candidate_window_geometry (const String &uuid) const
2412 if (m_impl->socket_active.is_connected ()) {
2413 m_impl->send.clear ();
2414 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2415 m_impl->send.put_data (m_impl->magic_active);
2416 m_impl->send.put_command (ISM_TRANS_CMD_GET_CANDIDATE_GEOMETRY);
2417 m_impl->send.put_data (uuid);
2418 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2423 * @brief Set current keyboard ISE.
2425 * @param uuid The keyboard ISE UUID.
2428 HelperAgent::set_keyboard_ise_by_uuid (const String &uuid) const
2431 IMEngineFactoryPointer factory;
2432 IMEngineModule *engine_module = NULL;
2433 static int instance_count = 1;
2435 if ((!m_impl->si.null ()) && m_impl->si->get_factory_uuid () == uuid) {
2436 ISF_SAVE_LOG ("Already in UUID: %s", uuid.c_str());
2440 if (!m_impl->si.null()) {
2441 m_impl->si->focus_out();
2445 if (m_impl->m_config.null ()) {
2446 ISF_SAVE_LOG ("config is not working");
2450 #ifdef HAVE_PKGMGR_INFO
2453 pkgmgrinfo_appinfo_h handle;
2454 ret = pkgmgrinfo_appinfo_get_appinfo(uuid.c_str(), &handle);
2455 if (ret != PMINFO_R_OK) {
2456 ISF_SAVE_LOG ("Retrieve app info failed : %s", uuid.c_str ());
2460 ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
2461 if (ret != PMINFO_R_OK) {
2462 ISF_SAVE_LOG ("Retrieve pkgid failed : %s, %p", uuid.c_str(), handle);
2463 pkgmgrinfo_appinfo_destroy_appinfo(handle);
2467 imeInfo.module_name = pkgid;
2468 pkgmgrinfo_appinfo_destroy_appinfo(handle);
2470 if (isf_db_select_ime_info_by_appid(uuid.c_str(), &imeInfo) < 1) {
2471 ISF_SAVE_LOG ("ime_info row is not available for %s", uuid.c_str());
2476 engine_module = &m_impl->engine_module;
2478 if (engine_module->valid() && imeInfo.module_name != engine_module->get_module_name()) {
2479 ISF_SAVE_LOG ("imengine module %s unloaded", engine_module->get_module_name().c_str());
2480 engine_module->unload();
2483 if (!engine_module->valid()) {
2484 if (engine_module->load (imeInfo.module_name, m_impl->m_config) == false) {
2485 ISF_SAVE_LOG ("load module %s failed", imeInfo.module_name.c_str());
2488 ISF_SAVE_LOG ("imengine module %s loaded", imeInfo.module_name.c_str());
2491 for (size_t j = 0; j < engine_module->number_of_factories (); ++j) {
2493 factory = engine_module->create_factory (j);
2494 if (factory.null () == false && factory->get_uuid () == uuid)
2502 if (factory.null()) {
2503 ISF_SAVE_LOG ("imengine uuid %s is not found", uuid.c_str());
2507 m_impl->si = factory->create_instance ("UTF-8", instance_count++);
2508 if (m_impl->si.null ()) {
2509 ISF_SAVE_LOG ("create_instance %s failed", uuid.c_str ());
2513 m_impl->attach_instance ();
2514 ISF_SAVE_LOG ("Require UUID: %s Current UUID: %s", uuid.c_str (), m_impl->si->get_factory_uuid ().c_str ());
2515 m_impl->si->set_layout (m_impl->layout);
2516 if (m_impl->focused_ic != (uint32)-1)
2517 m_impl->si->focus_in ();
2521 * @brief Request to get current keyboard ISE information.
2523 * @param uuid The helper ISE UUID.
2526 HelperAgent::get_keyboard_ise (const String &uuid) const
2528 //FIXME: maybe useless
2530 if (m_impl->socket_active.is_connected ()) {
2531 m_impl->send.clear ();
2532 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2533 m_impl->send.put_data (m_impl->magic_active);
2534 m_impl->send.put_command (ISM_TRANS_CMD_GET_KEYBOARD_ISE);
2535 m_impl->send.put_data (uuid);
2536 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2542 * @brief Update ISE window geometry.
2544 * @param x The x position in screen.
2545 * @param y The y position in screen.
2546 * @param width The ISE window width.
2547 * @param height The ISE window height.
2550 HelperAgent::update_geometry (int x, int y, int width, int height) const
2552 if (m_impl->socket_active.is_connected ()) {
2553 m_impl->send.clear ();
2554 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2555 m_impl->send.put_data (m_impl->magic_active);
2556 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ISE_GEOMETRY);
2557 m_impl->send.put_data (x);
2558 m_impl->send.put_data (y);
2559 m_impl->send.put_data (width);
2560 m_impl->send.put_data (height);
2561 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2566 * @brief Request to expand candidate window.
2569 HelperAgent::expand_candidate (void) const
2571 if (m_impl->socket_active.is_connected ()) {
2572 m_impl->send.clear ();
2573 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2574 m_impl->send.put_data (m_impl->magic_active);
2575 m_impl->send.put_command (ISM_TRANS_CMD_EXPAND_CANDIDATE);
2576 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2581 * @brief Request to contract candidate window.
2584 HelperAgent::contract_candidate (void) const
2586 if (m_impl->socket_active.is_connected ()) {
2587 m_impl->send.clear ();
2588 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2589 m_impl->send.put_data (m_impl->magic_active);
2590 m_impl->send.put_command (ISM_TRANS_CMD_CONTRACT_CANDIDATE);
2591 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2596 * @brief Send selected candidate string index number.
2599 HelperAgent::select_candidate (int index) const
2601 if (!m_impl->si.null ())
2602 m_impl->si->select_candidate (index);
2603 //FIXME: maybe useless
2606 if (m_impl->socket_active.is_connected ()) {
2607 m_impl->send.clear ();
2608 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2609 m_impl->send.put_data (m_impl->magic_active);
2610 m_impl->send.put_command (ISM_TRANS_CMD_SELECT_CANDIDATE);
2611 m_impl->send.put_data (index);
2612 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2618 * @brief Update our ISE is exiting.
2620 * The IME must call this function before terminating IME itself in On-demand mode.
2621 * If this function isn't called, IME will automatically restart.
2622 * This function only works in On-demand mode.
2626 HelperAgent::update_ise_exit (void) const
2628 if (m_impl->socket_active.is_connected ()) {
2629 m_impl->send.clear ();
2630 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2631 m_impl->send.put_data (m_impl->magic_active);
2632 m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ISE_EXIT);
2633 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2635 // The update_ise_exit must be delivered before del_client of isf_info_manager was called.
2641 * @brief Request to reset keyboard ISE.
2644 HelperAgent::reset_keyboard_ise (void) const
2646 //FIXME: maybe useless
2648 if (m_impl->socket_active.is_connected ()) {
2649 m_impl->send.clear ();
2650 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2651 m_impl->send.put_data (m_impl->magic_active);
2652 m_impl->send.put_command (ISM_TRANS_CMD_PANEL_RESET_KEYBOARD_ISE);
2653 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2656 if (!m_impl->si.null ()) {
2657 m_impl->si->reset ();
2662 * @brief Request to flush keyboard ISE.
2665 HelperAgent::flush_keyboard_ise (void) const
2667 if (!m_impl->si.null ()) {
2668 m_impl->si->flush ();
2673 * @brief Request panel to hide ISE.
2676 HelperAgent::request_ise_hide (void) const
2678 if (m_impl->socket_active.is_connected ()) {
2679 m_impl->send.clear ();
2680 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2681 m_impl->send.put_data (m_impl->magic_active);
2682 m_impl->send.put_command (ISM_TRANS_CMD_REQUEST_ISE_HIDE);
2683 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2691 HelperAgent::recapture_string (int ic,
2692 const String &ic_uuid,
2695 const WideString &preedit_str,
2696 const WideString &commit_str,
2697 const AttributeList &attrs) const
2699 LOGD ("offset = %d, len = %d", offset, len);
2701 if (m_impl->socket_active.is_connected ()) {
2702 m_impl->send.clear ();
2703 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2704 m_impl->send.put_data (m_impl->magic_active);
2705 m_impl->send.put_command (ISM_TRANS_CMD_RECAPTURE_STRING);
2707 m_impl->send.put_data ((uint32)ic);
2708 m_impl->send.put_data (ic_uuid);
2710 // Deleting surrounding text
2711 m_impl->send.put_data (offset);
2712 m_impl->send.put_data (len);
2714 // Update preedit text
2715 m_impl->send.put_data (preedit_str);
2718 m_impl->send.put_data (commit_str);
2720 // preedit attributes
2721 m_impl->send.put_data (attrs);
2723 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2728 HelperAgent::set_engine_loader_flag (bool flag)
2730 m_impl->engine_loader_flag = flag;
2734 HelperAgent::send_key_event_processing_result (KeyEvent &key,
2736 bool is_success) const
2738 int ret = is_success ? 1 : 0;
2739 m_impl->process_key_event_done (key, ret, serial);
2743 HelperAgent::set_floating_mode (bool floating_mode)
2746 if (m_impl->socket_active.is_connected ()) {
2747 m_impl->send.clear ();
2748 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2749 m_impl->send.put_data (m_impl->magic_active);
2750 m_impl->send.put_command (ISM_TRANS_CMD_SET_FLOATING_MODE);
2751 m_impl->send.put_data (floating_mode ? 1 : 0);
2752 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2757 HelperAgent::set_floating_drag_enabled (bool enabled)
2759 if (m_impl->socket_active.is_connected ()) {
2760 m_impl->send.clear ();
2761 m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2762 m_impl->send.put_data (m_impl->magic_active);
2763 m_impl->send.put_command (ISM_TRANS_CMD_SET_FLOATING_DRAG_ENABLED);
2764 m_impl->send.put_data (enabled ? 1 : 0);
2765 m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2770 * @brief Connect a slot to Helper exit signal.
2772 * This signal is used to let the Helper exit.
2774 * The prototype of the slot is:
2776 * void exit (const HelperAgent *agent, int ic, const String &ic_uuid);
2779 * - agent The pointer to the HelperAgent object which emits this signal.
2780 * - ic An opaque handle of the currently focused input context.
2781 * - ic_uuid The UUID of the IMEngineInstance associated with the focused input context.
2784 HelperAgent::signal_connect_exit (HelperAgentSlotVoid *slot)
2786 return m_impl->signal_exit.connect (slot);
2790 * @brief Connect a slot to Helper attach input context signal.
2792 * This signal is used to attach an input context to this helper.
2794 * When an input context requst to start this helper, then this
2795 * signal will be emitted as soon as the helper is started.
2797 * When an input context want to start an already started helper,
2798 * this signal will also be emitted.
2800 * Helper can send some events back to the IMEngineInstance in this
2801 * signal-slot, to inform that it has been started sccessfully.
2803 * The prototype of the slot is:
2805 * void attach_input_context (const HelperAgent *agent, int ic, const String &ic_uuid);
2808 HelperAgent::signal_connect_attach_input_context (HelperAgentSlotVoid *slot)
2810 return m_impl->signal_attach_input_context.connect (slot);
2814 * @brief Connect a slot to Helper detach input context signal.
2816 * This signal is used to detach an input context from this helper.
2818 * When an input context requst to stop this helper, then this
2819 * signal will be emitted.
2821 * Helper shouldn't send any event back to the IMEngineInstance, because
2822 * the IMEngineInstance attached to the ic should have been destroyed.
2824 * The prototype of the slot is:
2826 * void detach_input_context (const HelperAgent *agent, int ic, const String &ic_uuid);
2829 HelperAgent::signal_connect_detach_input_context (HelperAgentSlotVoid *slot)
2831 return m_impl->signal_detach_input_context.connect (slot);
2835 * @brief Connect a slot to Helper reload config signal.
2837 * This signal is used to let the Helper reload configuration.
2839 * The prototype of the slot is:
2841 * void reload_config (const HelperAgent *agent, int ic, const String &ic_uuid);
2844 HelperAgent::signal_connect_reload_config (HelperAgentSlotVoid *slot)
2846 return m_impl->signal_reload_config.connect (slot);
2850 * @brief Connect a slot to Helper update screen signal.
2852 * This signal is used to let the Helper move its GUI to another screen.
2853 * It can only be emitted when SCIM_HELPER_NEED_SCREEN_INFO is set in HelperInfo.option.
2855 * The prototype of the slot is:
2857 * void update_screen (const HelperAgent *agent, int ic, const String &ic_uuid, int screen_number);
2860 HelperAgent::signal_connect_update_screen (HelperAgentSlotInt *slot)
2862 return m_impl->signal_update_screen.connect (slot);
2866 * @brief Connect a slot to Helper update spot location signal.
2868 * This signal is used to let the Helper move its GUI according to the current spot location.
2869 * It can only be emitted when SCIM_HELPER_NEED_SPOT_LOCATION_INFO is set in HelperInfo.option.
2871 * The prototype of the slot is:
2872 * void update_spot_location (const HelperAgent *agent, int ic, const String &ic_uuid, int x, int y);
2875 HelperAgent::signal_connect_update_spot_location (HelperAgentSlotIntInt *slot)
2877 return m_impl->signal_update_spot_location.connect (slot);
2881 * @brief Connect a slot to Helper update cursor position signal.
2883 * This signal is used to let the Helper get the cursor position information.
2885 * The prototype of the slot is:
2886 * void update_cursor_position (const HelperAgent *agent, int ic, const String &ic_uuid, int cursor_pos);
2889 HelperAgent::signal_connect_update_cursor_position (HelperAgentSlotInt *slot)
2891 return m_impl->signal_update_cursor_position.connect (slot);
2895 * @brief Connect a slot to Helper update surrounding text signal.
2897 * This signal is used to let the Helper get the surrounding text.
2899 * The prototype of the slot is:
2900 * void update_surrounding_text (const HelperAgent *agent, int ic, const String &text, int cursor);
2903 HelperAgent::signal_connect_update_surrounding_text (HelperAgentSlotInt *slot)
2905 return m_impl->signal_update_surrounding_text.connect (slot);
2909 * @brief Connect a slot to Helper update selection signal.
2911 * This signal is used to let the Helper get the selection.
2913 * The prototype of the slot is:
2914 * void update_selection (const HelperAgent *agent, int ic, const String &text);
2917 HelperAgent::signal_connect_update_selection (HelperAgentSlotVoid *slot)
2919 return m_impl->signal_update_selection.connect (slot);
2923 * @brief Connect a slot to Helper trigger property signal.
2925 * This signal is used to trigger a property registered by this Helper.
2926 * A property will be triggered when user clicks on it.
2928 * The prototype of the slot is:
2929 * void trigger_property (const HelperAgent *agent, int ic, const String &ic_uuid, const String &property);
2932 HelperAgent::signal_connect_trigger_property (HelperAgentSlotString *slot)
2934 return m_impl->signal_trigger_property.connect (slot);
2938 * @brief Connect a slot to Helper process imengine event signal.
2940 * This signal is used to deliver the events sent from IMEngine to Helper.
2942 * The prototype of the slot is:
2943 * void process_imengine_event (const HelperAgent *agent, int ic, const String &ic_uuid, const Transaction &transaction);
2946 HelperAgent::signal_connect_process_imengine_event (HelperAgentSlotTransaction *slot)
2948 return m_impl->signal_process_imengine_event.connect (slot);
2952 * @brief Connect a slot to Helper focus out signal.
2954 * This signal is used to do something when input context is focus out.
2956 * The prototype of the slot is:
2957 * void focus_out (const HelperAgent *agent, int ic, const String &ic_uuid);
2960 HelperAgent::signal_connect_focus_out (HelperAgentSlotVoid *slot)
2962 return m_impl->signal_focus_out.connect (slot);
2966 * @brief Connect a slot to Helper focus in signal.
2968 * This signal is used to do something when input context is focus in.
2970 * The prototype of the slot is:
2971 * void focus_in (const HelperAgent *agent, int ic, const String &ic_uuid);
2974 HelperAgent::signal_connect_focus_in (HelperAgentSlotVoid *slot)
2976 return m_impl->signal_focus_in.connect (slot);
2980 * @brief Connect a slot to Helper show signal.
2982 * This signal is used to show Helper ISE window.
2984 * The prototype of the slot is:
2985 * void ise_show (const HelperAgent *agent, int ic, char *buf, size_t &len);
2988 HelperAgent::signal_connect_ise_show (HelperAgentSlotIntRawVoid *slot)
2990 return m_impl->signal_ise_show.connect (slot);
2994 * @brief Connect a slot to Helper hide signal.
2996 * This signal is used to hide Helper ISE window.
2998 * The prototype of the slot is:
2999 * void ise_hide (const HelperAgent *agent, int ic, const String &ic_uuid);
3002 HelperAgent::signal_connect_ise_hide (HelperAgentSlotVoid *slot)
3004 return m_impl->signal_ise_hide.connect (slot);
3008 * @brief Connect a slot to Helper get ISE window geometry signal.
3010 * This signal is used to get Helper ISE window size and position.
3012 * The prototype of the slot is:
3013 * void get_geometry (const HelperAgent *agent, struct rectinfo &info);
3016 HelperAgent::signal_connect_get_geometry (HelperAgentSlotSize *slot)
3018 return m_impl->signal_get_geometry.connect (slot);
3022 * @brief Connect a slot to Helper set mode signal.
3024 * This signal is used to set Helper ISE mode.
3026 * The prototype of the slot is:
3027 * void set_mode (const HelperAgent *agent, uint32 &mode);
3030 HelperAgent::signal_connect_set_mode (HelperAgentSlotUintVoid *slot)
3032 return m_impl->signal_set_mode.connect (slot);
3036 * @brief Connect a slot to Helper set language signal.
3038 * This signal is used to set Helper ISE language.
3040 * The prototype of the slot is:
3041 * void set_language (const HelperAgent *agent, uint32 &language);
3044 HelperAgent::signal_connect_set_language (HelperAgentSlotUintVoid *slot)
3046 return m_impl->signal_set_language.connect (slot);
3050 * @brief Connect a slot to Helper set im data signal.
3052 * This signal is used to send im data to Helper ISE.
3054 * The prototype of the slot is:
3055 * void set_imdata (const HelperAgent *agent, char *buf, size_t &len);
3058 HelperAgent::signal_connect_set_imdata (HelperAgentSlotRawVoid *slot)
3060 return m_impl->signal_set_imdata.connect (slot);
3064 * @brief Connect a slot to Helper get im data signal.
3066 * This signal is used to get im data from Helper ISE.
3068 * The prototype of the slot is:
3069 * void get_imdata (const HelperAgent *, char **buf, size_t &len);
3072 HelperAgent::signal_connect_get_imdata (HelperAgentSlotGetRawVoid *slot)
3074 return m_impl->signal_get_imdata.connect (slot);
3078 * @brief Connect a slot to Helper get language locale signal.
3080 * This signal is used to get language locale from Helper ISE.
3082 * The prototype of the slot is:
3083 * void get_language_locale (const HelperAgent *, int ic, char **locale);
3086 HelperAgent::signal_connect_get_language_locale (HelperAgentSlotIntGetStringVoid *slot)
3088 return m_impl->signal_get_language_locale.connect (slot);
3092 * @brief Connect a slot to Helper set return key type signal.
3094 * This signal is used to send return key type to Helper ISE.
3096 * The prototype of the slot is:
3097 * void set_return_key_type (const HelperAgent *agent, uint32 &type);
3100 HelperAgent::signal_connect_set_return_key_type (HelperAgentSlotUintVoid *slot)
3102 return m_impl->signal_set_return_key_type.connect (slot);
3106 * @brief Connect a slot to Helper get return key type signal.
3108 * This signal is used to get return key type from Helper ISE.
3110 * The prototype of the slot is:
3111 * void get_return_key_type (const HelperAgent *agent, uint32 &type);
3114 HelperAgent::signal_connect_get_return_key_type (HelperAgentSlotUintVoid *slot)
3116 return m_impl->signal_get_return_key_type.connect (slot);
3120 * @brief Connect a slot to Helper set return key disable signal.
3122 * This signal is used to send return key disable to Helper ISE.
3124 * The prototype of the slot is:
3125 * void set_return_key_disable (const HelperAgent *agent, uint32 &disabled);
3128 HelperAgent::signal_connect_set_return_key_disable (HelperAgentSlotUintVoid *slot)
3130 return m_impl->signal_set_return_key_disable.connect (slot);
3134 * @brief Connect a slot to Helper process key event signal.
3136 * This signal is used to send keyboard key event to Helper ISE.
3138 * The prototype of the slot is:
3139 * void process_key_event (const HelperAgent *agent, KeyEvent &key, uint32 &ret);
3142 HelperAgent::signal_connect_process_key_event (HelperAgentSlotKeyEventUint *slot)
3144 return m_impl->signal_process_key_event.connect (slot);
3148 * @brief Connect a slot to Helper process key event with keycode signal.
3150 * This signal is used to send keyboard key event with keycode to Helper ISE.
3152 * The prototype of the slot is:
3153 * void process_key_event_with_keycode (const HelperAgent *agent, KeyEvent &key, uint32 &ret, uint32 keycode);
3156 HelperAgent::signal_connect_process_key_event_with_keycode (HelperAgentSlotKeyEventUintUint *slot)
3158 return m_impl->signal_process_key_event_with_keycode.connect (slot);
3162 * @brief Connect a slot to Helper get return key disable signal.
3164 * This signal is used to get return key disable from Helper ISE.
3166 * The prototype of the slot is:
3167 * void get_return_key_disable (const HelperAgent *agent, uint32 &disabled);
3170 HelperAgent::signal_connect_get_return_key_disable (HelperAgentSlotUintVoid *slot)
3172 return m_impl->signal_get_return_key_disable.connect (slot);
3176 * @brief Connect a slot to Helper set layout signal.
3178 * This signal is used to set Helper ISE layout.
3180 * The prototype of the slot is:
3181 * void set_layout (const HelperAgent *agent, uint32 &layout);
3184 HelperAgent::signal_connect_set_layout (HelperAgentSlotUintVoid *slot)
3186 return m_impl->signal_set_layout.connect (slot);
3190 * @brief Connect a slot to Helper get layout signal.
3192 * This signal is used to get Helper ISE layout.
3194 * The prototype of the slot is:
3195 * void get_layout (const HelperAgent *agent, uint32 &layout);
3198 HelperAgent::signal_connect_get_layout (HelperAgentSlotUintVoid *slot)
3200 return m_impl->signal_get_layout.connect (slot);
3204 * @brief Connect a slot to Helper set input mode signal.
3206 * This signal is used to set Helper ISE input mode.
3208 * The prototype of the slot is:
3209 * void set_input_mode (const HelperAgent *agent, uint32 &input_mode);
3212 HelperAgent::signal_connect_set_input_mode (HelperAgentSlotUintVoid *slot)
3214 return m_impl->signal_set_input_mode.connect (slot);
3218 * @brief Connect a slot to Helper set input hint signal.
3220 * This signal is used to set Helper ISE input hint.
3222 * The prototype of the slot is:
3223 * void set_input_hint (const HelperAgent *agent, uint32 &input_hint);
3226 HelperAgent::signal_connect_set_input_hint (HelperAgentSlotUintVoid *slot)
3228 return m_impl->signal_set_input_hint.connect (slot);
3232 * @brief Connect a slot to Helper set BiDi direction signal.
3234 * This signal is used to set Helper ISE BiDi direction.
3236 * The prototype of the slot is:
3237 * void update_bidi_direction (const HelperAgent *agent, uint32 &bidi_direction);
3240 HelperAgent::signal_connect_update_bidi_direction (HelperAgentSlotUintVoid *slot)
3242 return m_impl->signal_update_bidi_direction.connect (slot);
3246 * @brief Connect a slot to Helper set shift mode signal.
3248 * This signal is used to set Helper shift mode.
3250 * The prototype of the slot is:
3251 * void set_caps_mode (const HelperAgent *agent, uint32 &mode);
3254 HelperAgent::signal_connect_set_caps_mode (HelperAgentSlotUintVoid *slot)
3256 return m_impl->signal_set_caps_mode.connect (slot);
3260 * @brief Connect a slot to Helper reset input context signal.
3262 * This signal is used to reset Helper ISE input context.
3264 * The prototype of the slot is:
3265 * void reset_input_context (const HelperAgent *agent, int ic, const String &uuid);
3268 HelperAgent::signal_connect_reset_input_context (HelperAgentSlotVoid *slot)
3270 return m_impl->signal_reset_input_context.connect (slot);
3274 * @brief Connect a slot to Helper update candidate window geometry signal.
3276 * This signal is used to get candidate window size and position.
3278 * The prototype of the slot is:
3279 * void update_candidate_geometry (const HelperAgent *agent, int ic, const String &uuid, const rectinfo &info);
3282 HelperAgent::signal_connect_update_candidate_geometry (HelperAgentSlotRect *slot)
3284 return m_impl->signal_update_candidate_geometry.connect (slot);
3288 * @brief Connect a slot to Helper update keyboard ISE signal.
3290 * This signal is used to get current keyboard ISE name and uuid.
3292 * The prototype of the slot is:
3293 * void update_keyboard_ise (const HelperAgent *agent, int ic, const String &uuid,
3294 * const String &ise_name, const String &ise_uuid);
3297 HelperAgent::signal_connect_update_keyboard_ise (HelperAgentSlotString2 *slot)
3299 return m_impl->signal_update_keyboard_ise.connect (slot);
3303 * @brief Connect a slot to Helper update keyboard ISE list signal.
3305 * This signal is used to get uuid list of all keyboard ISEs.
3307 * The prototype of the slot is:
3308 * void update_keyboard_ise_list (const HelperAgent *agent, int ic, const String &uuid,
3309 * const std::vector<String> &ise_list);
3312 HelperAgent::signal_connect_update_keyboard_ise_list (HelperAgentSlotStringVector *slot)
3314 return m_impl->signal_update_keyboard_ise_list.connect (slot);
3318 * @brief Connect a slot to Helper candidate more window show signal.
3320 * This signal is used to do someting when candidate more window is showed.
3322 * The prototype of the slot is:
3323 * void candidate_more_window_show (const HelperAgent *agent, int ic, const String &uuid);
3326 HelperAgent::signal_connect_candidate_more_window_show (HelperAgentSlotVoid *slot)
3328 return m_impl->signal_candidate_more_window_show.connect (slot);
3332 * @brief Connect a slot to Helper candidate more window hide signal.
3334 * This signal is used to do someting when candidate more window is hidden.
3336 * The prototype of the slot is:
3337 * void candidate_more_window_hide (const HelperAgent *agent, int ic, const String &uuid);
3340 HelperAgent::signal_connect_candidate_more_window_hide (HelperAgentSlotVoid *slot)
3342 return m_impl->signal_candidate_more_window_hide.connect (slot);
3346 * @brief Connect a slot to Helper candidate show signal.
3348 * This signal is used to do candidate show.
3350 * The prototype of the slot is:
3351 * void candidate_show (const HelperAgent *agent, int ic, const String &uuid);
3354 HelperAgent::signal_connect_candidate_show (HelperAgentSlotVoid *slot)
3356 return m_impl->signal_candidate_show.connect (slot);
3360 * @brief Connect a slot to Helper candidate hide signal.
3362 * This signal is used to do candidate hide.
3364 * The prototype of the slot is:
3365 * void candidate_hide (const HelperAgent *agent, int ic, const String &uuid);
3368 HelperAgent::signal_connect_candidate_hide (HelperAgentSlotVoid *slot)
3370 return m_impl->signal_candidate_hide.connect (slot);
3374 * @brief Connect a slot to Helper update lookup table signal.
3376 * This signal is used to do someting when update lookup table.
3378 * The prototype of the slot is:
3379 * void update_lookup_table (const HelperAgent *agent, int ic, const String &uuid ,LookupTable &table);
3382 HelperAgent::signal_connect_update_lookup_table (HelperAgentSlotLookupTable *slot)
3384 return m_impl->signal_update_lookup_table.connect (slot);
3388 * @brief Connect a slot to Helper select aux signal.
3390 * This signal is used to do something when aux is selected.
3392 * The prototype of the slot is:
3393 * void select_aux (const HelperAgent *agent, int ic, const String &uuid, int index);
3396 HelperAgent::signal_connect_select_aux (HelperAgentSlotInt *slot)
3398 return m_impl->signal_select_aux.connect (slot);
3402 * @brief Connect a slot to Helper select candidate signal.
3404 * This signal is used to do something when candidate is selected.
3406 * The prototype of the slot is:
3407 * void select_candidate (const HelperAgent *agent, int ic, const String &uuid, int index);
3410 HelperAgent::signal_connect_select_candidate (HelperAgentSlotInt *slot)
3412 return m_impl->signal_select_candidate.connect (slot);
3416 * @brief Connect a slot to Helper candidate table page up signal.
3418 * This signal is used to do something when candidate table is paged up.
3420 * The prototype of the slot is:
3421 * void candidate_table_page_up (const HelperAgent *agent, int ic, const String &uuid);
3424 HelperAgent::signal_connect_candidate_table_page_up (HelperAgentSlotVoid *slot)
3426 return m_impl->signal_candidate_table_page_up.connect (slot);
3430 * @brief Connect a slot to Helper candidate table page down signal.
3432 * This signal is used to do something when candidate table is paged down.
3434 * The prototype of the slot is:
3435 * void candidate_table_page_down (const HelperAgent *agent, int ic, const String &uuid);
3438 HelperAgent::signal_connect_candidate_table_page_down (HelperAgentSlotVoid *slot)
3440 return m_impl->signal_candidate_table_page_down.connect (slot);
3444 * @brief Connect a slot to Helper update candidate table page size signal.
3446 * This signal is used to do something when candidate table page size is changed.
3448 * The prototype of the slot is:
3449 * void update_candidate_table_page_size (const HelperAgent *, int ic, const String &uuid, int page_size);
3452 HelperAgent::signal_connect_update_candidate_table_page_size (HelperAgentSlotInt *slot)
3454 return m_impl->signal_update_candidate_table_page_size.connect (slot);
3458 * @brief Connect a slot to Helper update candidate item layout signal.
3460 * The prototype of the slot is:
3461 * void update_candidate_item_layout (const HelperAgent *, const std::vector<uint32> &row_items);
3464 HelperAgent::signal_connect_update_candidate_item_layout (HelperAgentSlotUintVector *slot)
3466 return m_impl->signal_update_candidate_item_layout.connect (slot);
3470 * @brief Connect a slot to Helper select associate signal.
3472 * This signal is used to do something when associate is selected.
3474 * The prototype of the slot is:
3475 * void select_associate (const HelperAgent *agent, int ic, const String &uuid, int index);
3478 HelperAgent::signal_connect_select_associate (HelperAgentSlotInt *slot)
3480 return m_impl->signal_select_associate.connect (slot);
3484 * @brief Connect a slot to Helper associate table page up signal.
3486 * This signal is used to do something when associate table is paged up.
3488 * The prototype of the slot is:
3489 * void associate_table_page_up (const HelperAgent *agent, int ic, const String &uuid);
3492 HelperAgent::signal_connect_associate_table_page_up (HelperAgentSlotVoid *slot)
3494 return m_impl->signal_associate_table_page_up.connect (slot);
3498 * @brief Connect a slot to Helper associate table page down signal.
3500 * This signal is used to do something when associate table is paged down.
3502 * The prototype of the slot is:
3503 * void associate_table_page_down (const HelperAgent *agent, int ic, const String &uuid);
3506 HelperAgent::signal_connect_associate_table_page_down (HelperAgentSlotVoid *slot)
3508 return m_impl->signal_associate_table_page_down.connect (slot);
3512 * @brief Connect a slot to Helper update associate table page size signal.
3514 * This signal is used to do something when associate table page size is changed.
3516 * The prototype of the slot is:
3517 * void update_associate_table_page_size (const HelperAgent *, int ic, const String &uuid, int page_size);
3520 HelperAgent::signal_connect_update_associate_table_page_size (HelperAgentSlotInt *slot)
3522 return m_impl->signal_update_associate_table_page_size.connect (slot);
3526 * @brief Connect a slot to Helper turn on log signal.
3528 * This signal is used to turn on Helper ISE debug information.
3530 * The prototype of the slot is:
3531 * void turn_on_log (const HelperAgent *agent, uint32 &on);
3534 HelperAgent::signal_connect_turn_on_log (HelperAgentSlotUintVoid *slot)
3536 return m_impl->signal_turn_on_log.connect (slot);
3540 * @brief Connect a slot to Helper update displayed candidate number signal.
3542 * This signal is used to inform helper ISE displayed candidate number.
3544 * The prototype of the slot is:
3545 * void update_displayed_candidate_number (const HelperAgent *, int ic, const String &uuid, int number);
3548 HelperAgent::signal_connect_update_displayed_candidate_number (HelperAgentSlotInt *slot)
3550 return m_impl->signal_update_displayed_candidate_number.connect (slot);
3554 * @brief Connect a slot to Helper longpress candidate signal.
3556 * This signal is used to do something when candidate is longpress.
3558 * The prototype of the slot is:
3559 * void longpress_candidate (const HelperAgent *agent, int ic, const String &uuid, int index);
3562 HelperAgent::signal_connect_longpress_candidate (HelperAgentSlotInt *slot)
3564 return m_impl->signal_longpress_candidate.connect (slot);
3568 * @brief Connect a slot to Helper show option window.
3570 * This signal is used to do request the ISE to show option window.
3572 * The prototype of the slot is:
3573 * void show_option_window (const HelperAgent *agent, int ic, const String &uuid);
3576 HelperAgent::signal_connect_show_option_window (HelperAgentSlotVoid *slot)
3578 return m_impl->signal_show_option_window.connect (slot);
3582 * @brief Connect a slot to Helper resume option window.
3584 * This signal is used to do request the ISE to resume option window.
3586 * The prototype of the slot is:
3587 * void resume_option_window (const HelperAgent *agent, int ic, const String &uuid);
3590 HelperAgent::signal_connect_resume_option_window (HelperAgentSlotVoid *slot)
3592 return m_impl->signal_resume_option_window.connect (slot);
3596 * @brief Connect a slot to Helper check if the option is available.
3598 * This signal is used to check if the option (setting) is available from Helper ISE.
3600 * The prototype of the slot is:
3601 * void check_option_window (const HelperAgent *agent, uint32 &avail);
3604 HelperAgent::signal_connect_check_option_window (HelperAgentSlotUintVoid *slot)
3606 return m_impl->signal_check_option_window.connect (slot);
3610 * @brief Connect a slot to Helper process unconventional input device event signal.
3612 * This signal is used to send unconventional input device event to Helper ISE.
3614 * The prototype of the slot is:
3615 * void process_input_device_event (const HelperAgent *, uint32 &type, char *data, size_t &size, uint32 &ret);
3618 HelperAgent::signal_connect_process_input_device_event (HelperAgentSlotUintCharSizeUint *slot)
3620 return m_impl->signal_process_input_device_event.connect (slot);
3624 * @brief Connect a slot to Helper set prediction hint signal.
3626 * This signal is used to send prediction hint to Helper ISE.
3628 * The prototype of the slot is:
3629 * void set_prediction_hint (const HelperAgent *agent, char *prediction_hint);
3632 HelperAgent::signal_connect_set_prediction_hint (HelperAgentSlotStringVoid *slot)
3634 return m_impl->signal_set_prediction_hint.connect (slot);
3638 * @brief Connect a slot to Helper set mime type signal.
3640 * This signal is used to send mime type to Helper ISE.
3642 * The prototype of the slot is:
3643 * void set_mime_type (const HelperAgent *agent, char *mime_type);
3646 HelperAgent::signal_connect_set_mime_type (HelperAgentSlotStringVoid *slot)
3648 return m_impl->signal_set_mime_type.connect (slot);
3652 * @brief Connect a slot to Helper set prediction hint data signal.
3654 * This signal is used to send prediction hint data to Helper ISE.
3656 * The prototype of the slot is:
3657 * void set_prediction_hint_data (const HelperAgent *agent, char *key, char *value);
3660 HelperAgent::signal_connect_set_prediction_hint_data (HelperAgentSlotString *slot)
3662 return m_impl->signal_set_prediction_hint_data.connect (slot);
3666 * @brief Connect a slot to Helper set optimization hint signal.
3668 * This signal is used to send optimization hint to Helper ISE.
3670 * The prototype of the slot is:
3671 * void set_optimization_hint (const HelperAgent *agent, uint32 &hint);
3674 HelperAgent::signal_connect_set_optimization_hint (HelperAgentSlotUintVoid *slot)
3676 return m_impl->signal_set_optimization_hint.connect (slot);
3680 * @brief Connect a slot to Helper process key event with imengine signal.
3682 * This signal is used to deliver the key event to Helper ISE.
3684 * The prototype of the slot is:
3685 * void process_key_event_with_imengine (const HelperAgent *agent, KeyEvent &key, uint32 serial);
3688 HelperAgent::signal_connect_process_key_event_with_imengine (HelperAgentSlotKeyEventUint2 *slot)
3690 return m_impl->signal_process_key_event_with_imengine.connect (slot);
3694 * @brief Connect a slot to Helper set autocapital type signal.
3696 * This signal is used to send autocapital type to imengine.
3698 * The prototype of the slot is:
3699 * void set_autocapital_type (const HelperAgent *agent, uint32 &type);
3702 HelperAgent::signal_connect_set_autocapital_type (HelperAgentSlotUintVoid *slot)
3704 return m_impl->signal_set_autocapital_type.connect (slot);
3708 * @brief Connect a slot to Helper set prediction allow signal.
3710 * This signal is used to send prediction allow to imengine.
3712 * The prototype of the slot is:
3713 * void set_prediction_allow (const HelperAgent *agent, uint32 &prediction_allow);
3716 HelperAgent::signal_connect_set_prediction_allow (HelperAgentSlotUintVoid *slot)
3718 return m_impl->signal_set_prediction_allow.connect (slot);
3721 } /* namespace scim */
3724 vi:ts=4:nowrap:ai:expandtab