Support ise-engine-loader feature
[platform/core/uifw/isf.git] / ism / src / scim_helper.cpp
1 /** @file scim_helper.cpp
2  *  @brief Implementation of class HelperAgent.
3  */
4
5 /* ISF is based on SCIM 1.4.7 and extended for supporting more mobile fitable. */
6
7 /*
8  * Smart Common Input Method
9  *
10  * Copyright (c) 2004-2005 James Su <suzhe@tsinghua.org.cn>
11  * Copyright (c) 2012-2015 Samsung Electronics Co., Ltd.
12  *
13  *
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.
18  *
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.
23  *
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
28  *
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 ()
36  *
37  * $Id: scim_helper.cpp,v 1.13 2005/05/24 12:22:51 suzhe Exp $
38  *
39  */
40
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
48
49 #include <string.h>
50 #include <unistd.h>
51 #include <sys/time.h>
52 #include <Ecore_IMF.h>
53
54 #include "scim_private.h"
55 #include "scim.h"
56 #include <scim_panel_common.h>
57 #include "isf_query_utility.h"
58 #include <dlog.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"
66
67 #ifdef LOG_TAG
68 # undef LOG_TAG
69 #endif
70 #define LOG_TAG             "SCIM_HELPER"
71
72
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
79
80 namespace scim {
81
82 typedef Signal3<void, const HelperAgent *, int, const String &>
83         HelperAgentSignalVoid;
84
85 typedef Signal4<void, const HelperAgent *, int, const String &, const String &>
86         HelperAgentSignalString;
87
88 typedef Signal4<void, const HelperAgent *, int, const String &, const std::vector<String> &>
89         HelperAgentSignalStringVector;
90
91 typedef Signal5<void, const HelperAgent *, int, const String &, const String &, const String &>
92         HelperAgentSignalString2;
93
94 typedef Signal4<void, const HelperAgent *, int, const String &, int>
95         HelperAgentSignalInt;
96
97 typedef Signal5<void, const HelperAgent *, int, const String &, int, int>
98         HelperAgentSignalIntInt;
99
100 typedef Signal4<void, const HelperAgent *, int, const String &, const Transaction &>
101         HelperAgentSignalTransaction;
102
103 typedef Signal4<void, const HelperAgent *, int, const String &, const rectinfo &>
104         HelperAgentSignalRect;
105
106 typedef Signal2<void, const HelperAgent *, struct rectinfo &>
107         HelperAgentSignalSize;
108
109 typedef Signal2<void, const HelperAgent *, uint32 &>
110         HelperAgentSignalUintVoid;
111
112 typedef Signal3<void, const HelperAgent *, int, uint32 &>
113         HelperAgentSignalIntUint;
114
115 typedef Signal3 <void, const HelperAgent *, char *, size_t &>
116         HelperAgentSignalRawVoid;
117
118 typedef Signal3 <void, const HelperAgent *, char **, size_t &>
119         HelperAgentSignalGetRawVoid;
120
121 typedef Signal4 <void, const HelperAgent *, int, char *, size_t &>
122         HelperAgentSignalIntRawVoid;
123
124 typedef Signal3 <void, const HelperAgent *, int, char **>
125         HelperAgentSignalIntGetStringVoid;
126
127 typedef Signal2<void, const HelperAgent *, const std::vector<uint32> &>
128         HelperAgentSignalUintVector;
129
130 typedef Signal2<void, const HelperAgent *, LookupTable &>
131         HelperAgentSignalLookupTable;
132
133 typedef Signal3<void, const HelperAgent *, KeyEvent &, uint32 &>
134         HelperAgentSignalKeyEventUint;
135
136 typedef Signal4<void, const HelperAgent *, KeyEvent &, uint32 &, uint32>
137         HelperAgentSignalKeyEventUintUint;
138
139 typedef Signal5<void, const HelperAgent *, uint32 &, char *, size_t &, uint32 &>
140         HelperAgentSignalUintCharSizeUint;
141
142 typedef Signal2<void, const HelperAgent *, const String &>
143         HelperAgentSignalStringVoid;
144
145 class HelperAgent::HelperAgentImpl
146 {
147 public:
148     SocketClient socket;
149     SocketClient socket_active;
150     Transaction  recv;
151     Transaction  send;
152     uint32       magic;
153     uint32       magic_active;
154     int          timeout;
155     uint32       focused_ic;
156
157     HelperAgent* thiz;
158     IMEngineInstancePointer si;
159     ConfigPointer m_config;
160     IMEngineModule engine_module;
161
162     char* surrounding_text;
163     char* selection_text;
164     uint32 cursor_pos;
165     int need_update_surrounding_text;
166     int need_update_selection_text;
167     uint32 layout;
168     bool ise_show_flag;
169     bool need_update_entry_metadata;
170     bool ise_focus_flag;
171     char* finalized_text;
172     uint32 finalized_cursor_pos;
173
174     HelperAgentSignalVoid           signal_exit;
175     HelperAgentSignalVoid           signal_attach_input_context;
176     HelperAgentSignalVoid           signal_detach_input_context;
177     HelperAgentSignalVoid           signal_reload_config;
178     HelperAgentSignalInt            signal_update_screen;
179     HelperAgentSignalIntInt         signal_update_spot_location;
180     HelperAgentSignalInt            signal_update_cursor_position;
181     HelperAgentSignalInt            signal_update_surrounding_text;
182     HelperAgentSignalVoid           signal_update_selection;
183     HelperAgentSignalString         signal_trigger_property;
184     HelperAgentSignalTransaction    signal_process_imengine_event;
185     HelperAgentSignalVoid           signal_focus_out;
186     HelperAgentSignalVoid           signal_focus_in;
187     HelperAgentSignalIntRawVoid     signal_ise_show;
188     HelperAgentSignalVoid           signal_ise_hide;
189     HelperAgentSignalVoid           signal_candidate_show;
190     HelperAgentSignalVoid           signal_candidate_hide;
191     HelperAgentSignalSize           signal_get_geometry;
192     HelperAgentSignalUintVoid       signal_set_mode;
193     HelperAgentSignalUintVoid       signal_set_language;
194     HelperAgentSignalRawVoid        signal_set_imdata;
195     HelperAgentSignalGetRawVoid     signal_get_imdata;
196     HelperAgentSignalIntGetStringVoid   signal_get_language_locale;
197     HelperAgentSignalUintVoid           signal_set_return_key_type;
198     HelperAgentSignalUintVoid           signal_get_return_key_type;
199     HelperAgentSignalUintVoid           signal_set_return_key_disable;
200     HelperAgentSignalUintVoid           signal_get_return_key_disable;
201     HelperAgentSignalUintVoid           signal_set_layout;
202     HelperAgentSignalUintVoid           signal_get_layout;
203     HelperAgentSignalUintVoid           signal_set_caps_mode;
204     HelperAgentSignalVoid               signal_reset_input_context;
205     HelperAgentSignalIntInt             signal_update_candidate_ui;
206     HelperAgentSignalRect               signal_update_candidate_geometry;
207     HelperAgentSignalString2            signal_update_keyboard_ise;
208     HelperAgentSignalStringVector       signal_update_keyboard_ise_list;
209     HelperAgentSignalVoid               signal_candidate_more_window_show;
210     HelperAgentSignalVoid               signal_candidate_more_window_hide;
211     HelperAgentSignalLookupTable        signal_update_lookup_table;
212     HelperAgentSignalInt                signal_select_aux;
213     HelperAgentSignalInt                signal_select_candidate;
214     HelperAgentSignalVoid               signal_candidate_table_page_up;
215     HelperAgentSignalVoid               signal_candidate_table_page_down;
216     HelperAgentSignalInt                signal_update_candidate_table_page_size;
217     HelperAgentSignalUintVector         signal_update_candidate_item_layout;
218     HelperAgentSignalInt                signal_select_associate;
219     HelperAgentSignalVoid               signal_associate_table_page_up;
220     HelperAgentSignalVoid               signal_associate_table_page_down;
221     HelperAgentSignalInt                signal_update_associate_table_page_size;
222     HelperAgentSignalVoid               signal_reset_ise_context;
223     HelperAgentSignalUintVoid           signal_turn_on_log;
224     HelperAgentSignalInt                signal_update_displayed_candidate_number;
225     HelperAgentSignalInt                signal_longpress_candidate;
226     HelperAgentSignalKeyEventUint       signal_process_key_event;
227     HelperAgentSignalKeyEventUintUint   signal_process_key_event_with_keycode;
228     HelperAgentSignalUintVoid           signal_set_input_mode;
229     HelperAgentSignalUintVoid           signal_set_input_hint;
230     HelperAgentSignalUintVoid           signal_update_bidi_direction;
231     HelperAgentSignalVoid               signal_show_option_window;
232     HelperAgentSignalVoid               signal_resume_option_window;
233     HelperAgentSignalUintVoid           signal_check_option_window;
234     HelperAgentSignalUintCharSizeUint   signal_process_input_device_event;
235     HelperAgentSignalStringVoid         signal_set_prediction_hint;
236     HelperAgentSignalStringVoid         signal_set_mime_type;
237     HelperAgentSignalString             signal_set_prediction_hint_data;
238     HelperAgentSignalUintVoid           signal_set_optimization_hint;
239     HelperAgentSignalKeyEventUint       signal_process_key_event_with_imengine;
240     HelperAgentSignalUintVoid           signal_set_autocapital_type;
241     HelperAgentSignalUintVoid           signal_set_prediction_allow;
242
243 public:
244     HelperAgentImpl (HelperAgent* thiz) : magic(0), magic_active(0), timeout(-1), focused_ic ((uint32) -1), thiz (thiz),
245         surrounding_text (NULL), selection_text (NULL), cursor_pos (0),
246         need_update_surrounding_text (0), need_update_selection_text (0),
247         layout (0), ise_show_flag (false), need_update_entry_metadata (true), ise_focus_flag (false),
248         finalized_text(NULL), finalized_cursor_pos(0) {
249     }
250
251     ~HelperAgentImpl () {
252         if (!si.null ()) {
253             si.reset ();
254         }
255
256         if (surrounding_text != NULL)
257             free (surrounding_text);
258
259         if (finalized_text != NULL)
260             free(finalized_text);
261
262         if (selection_text != NULL)
263             free (selection_text);
264
265         if (engine_module.valid ()) {
266             engine_module.unload ();
267         }
268     }
269
270     // Implementation of slot functions
271     void
272     slot_show_preedit_string (IMEngineInstanceBase *si)
273     {
274         thiz->show_preedit_string (focused_ic, "");
275     }
276
277     void
278     slot_show_aux_string (IMEngineInstanceBase *si)
279     {
280         thiz->show_aux_string ();
281     }
282
283     void
284     slot_show_lookup_table (IMEngineInstanceBase *si)
285     {
286         thiz->show_candidate_string ();
287     }
288
289     void
290     slot_hide_preedit_string (IMEngineInstanceBase *si)
291     {
292         thiz->hide_preedit_string (focused_ic, "");
293     }
294
295     void
296     slot_hide_aux_string (IMEngineInstanceBase *si)
297     {
298         thiz->hide_aux_string ();
299     }
300
301     void
302     slot_hide_lookup_table (IMEngineInstanceBase *si)
303     {
304         thiz->hide_candidate_string ();
305     }
306
307     void
308     slot_update_preedit_caret (IMEngineInstanceBase *si, int caret)
309     {
310         thiz->update_preedit_caret (caret);
311     }
312
313     void
314     slot_update_preedit_string (IMEngineInstanceBase *si,
315                                 const WideString & str,
316                                 const AttributeList & attrs,
317                                 int caret)
318     {
319         thiz->update_preedit_string (-1, "", str, attrs, caret);
320     }
321
322     void
323     slot_update_preedit_string_with_commit (IMEngineInstanceBase *si,
324                                             const WideString & preedit,
325                                             const WideString & commit,
326                                             const AttributeList & attrs,
327                                             int caret)
328     {
329         thiz->update_preedit_string (-1, "", preedit, commit, attrs, caret);
330     }
331
332     void
333     slot_update_aux_string (IMEngineInstanceBase *si,
334                             const WideString & str,
335                             const AttributeList & attrs)
336     {
337         thiz->update_aux_string (utf8_wcstombs(str), attrs);
338     }
339
340     void
341     slot_commit_string (IMEngineInstanceBase *si,
342                         const WideString & str)
343     {
344         thiz->commit_string (-1, "", str);
345     }
346
347     void
348     slot_recapture_string (IMEngineInstanceBase *si,
349                            int                   offset,
350                            int                   len,
351                            const WideString & preedit,
352                            const WideString & commit,
353                            const AttributeList & attrs)
354     {
355         thiz->recapture_string (-1, "", offset, len, preedit, commit, attrs);
356     }
357
358     void
359     slot_forward_key_event (IMEngineInstanceBase *si,
360                             const KeyEvent & key)
361     {
362         thiz->forward_key_event (-1, "", key);
363     }
364
365     void
366     slot_update_lookup_table (IMEngineInstanceBase *si,
367                               const LookupTable & table)
368     {
369         thiz->update_candidate_string (table);
370     }
371
372     void
373     slot_register_properties (IMEngineInstanceBase *si,
374                               const PropertyList & properties)
375     {
376         thiz->register_properties (properties);
377     }
378
379     void
380     slot_update_property (IMEngineInstanceBase *si,
381                           const Property & property)
382     {
383         thiz->update_property (property);
384     }
385
386     void
387     slot_beep (IMEngineInstanceBase *si)
388     {
389         //FIXME
390     }
391
392     void
393     slot_start_helper (IMEngineInstanceBase *si,
394                        const String &helper_uuid)
395     {
396         LOGW ("deprecated function");
397     }
398
399     void
400     slot_stop_helper (IMEngineInstanceBase *si,
401                       const String &helper_uuid)
402     {
403         LOGW ("deprecated function");
404     }
405
406     void
407     slot_send_helper_event (IMEngineInstanceBase *si,
408                             const String      &helper_uuid,
409                             const Transaction &trans)
410     {
411         signal_process_imengine_event (thiz, focused_ic, helper_uuid, trans);
412     }
413
414     bool
415     slot_get_surrounding_text (IMEngineInstanceBase *si,
416                                WideString            &text,
417                                int                   &cursor,
418                                int                    maxlen_before,
419                                int                    maxlen_after)
420     {
421         String _text;
422         thiz->get_surrounding_text (maxlen_before, maxlen_after, _text, cursor);
423         text = utf8_mbstowcs(_text);
424         return true;
425     }
426
427     bool
428     slot_delete_surrounding_text (IMEngineInstanceBase *si,
429                                   int                   offset,
430                                   int                   len)
431     {
432
433         thiz->delete_surrounding_text (offset, len);
434         return true;
435     }
436
437     bool
438     slot_get_selection (IMEngineInstanceBase *si,
439                         WideString            &text)
440     {
441         String _text;
442         thiz->get_selection_text (_text);
443         text = utf8_mbstowcs (_text);
444         return true;
445     }
446
447     bool
448     slot_set_selection (IMEngineInstanceBase *si,
449                         int              start,
450                         int              end)
451     {
452         thiz->set_selection (start, end);
453         return true;
454     }
455
456     void
457     slot_expand_candidate (IMEngineInstanceBase *si)
458     {
459         thiz->expand_candidate ();
460     }
461
462     void
463     slot_contract_candidate (IMEngineInstanceBase *si)
464     {
465         thiz->contract_candidate ();
466     }
467
468     void
469     slot_set_candidate_style (IMEngineInstanceBase *si, ISF_CANDIDATE_PORTRAIT_LINE_T portrait_line, ISF_CANDIDATE_MODE_T mode)
470     {
471         thiz->set_candidate_style (portrait_line, mode);
472     }
473
474     void
475     slot_send_private_command (IMEngineInstanceBase *si,
476                                const String &command)
477     {
478         thiz->send_private_command (command);
479     }
480
481     void
482     slot_commit_content (IMEngineInstanceBase *si,
483                          const String &content,
484                          const String &description,
485                          const String &mime_types)
486     {
487         LOGD ("");
488         thiz->commit_content (content, description, mime_types);
489     }
490
491     void
492     attach_instance ()
493     {
494         si->signal_connect_show_preedit_string (
495             slot (this, &HelperAgent::HelperAgentImpl::slot_show_preedit_string));
496         si->signal_connect_show_aux_string (
497             slot (this, &HelperAgent::HelperAgentImpl::slot_show_aux_string));
498         si->signal_connect_show_lookup_table (
499             slot (this, &HelperAgent::HelperAgentImpl::slot_show_lookup_table));
500
501         si->signal_connect_hide_preedit_string (
502             slot (this, &HelperAgent::HelperAgentImpl::slot_hide_preedit_string));
503         si->signal_connect_hide_aux_string (
504             slot (this, &HelperAgent::HelperAgentImpl::slot_hide_aux_string));
505         si->signal_connect_hide_lookup_table (
506             slot (this, &HelperAgent::HelperAgentImpl::slot_hide_lookup_table));
507
508         si->signal_connect_update_preedit_caret (
509             slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_caret));
510         si->signal_connect_update_preedit_string (
511             slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_string));
512         si->signal_connect_update_preedit_string_with_commit (
513             slot (this, &HelperAgent::HelperAgentImpl::slot_update_preedit_string_with_commit));
514         si->signal_connect_recapture_string (
515             slot (this, &HelperAgent::HelperAgentImpl::slot_recapture_string));
516
517         si->signal_connect_update_aux_string (
518             slot (this, &HelperAgent::HelperAgentImpl::slot_update_aux_string));
519         si->signal_connect_update_lookup_table (
520             slot (this, &HelperAgent::HelperAgentImpl::slot_update_lookup_table));
521
522         si->signal_connect_commit_string (
523             slot (this, &HelperAgent::HelperAgentImpl::slot_commit_string));
524
525         si->signal_connect_forward_key_event (
526             slot (this, &HelperAgent::HelperAgentImpl::slot_forward_key_event));
527
528         si->signal_connect_register_properties (
529             slot (this, &HelperAgent::HelperAgentImpl::slot_register_properties));
530
531         si->signal_connect_update_property (
532             slot (this, &HelperAgent::HelperAgentImpl::slot_update_property));
533
534         si->signal_connect_beep (
535             slot (this, &HelperAgent::HelperAgentImpl::slot_beep));
536
537         si->signal_connect_start_helper (
538             slot (this, &HelperAgent::HelperAgentImpl::slot_start_helper));
539
540         si->signal_connect_stop_helper (
541             slot (this, &HelperAgent::HelperAgentImpl::slot_stop_helper));
542
543         si->signal_connect_send_helper_event (
544             slot (this, &HelperAgent::HelperAgentImpl::slot_send_helper_event));
545
546         si->signal_connect_get_surrounding_text (
547             slot (this, &HelperAgent::HelperAgentImpl::slot_get_surrounding_text));
548
549         si->signal_connect_delete_surrounding_text (
550             slot (this, &HelperAgent::HelperAgentImpl::slot_delete_surrounding_text));
551
552         si->signal_connect_get_selection (
553             slot (this, &HelperAgent::HelperAgentImpl::slot_get_selection));
554
555         si->signal_connect_set_selection (
556             slot (this, &HelperAgent::HelperAgentImpl::slot_set_selection));
557
558         si->signal_connect_expand_candidate (
559             slot (this, &HelperAgent::HelperAgentImpl::slot_expand_candidate));
560         si->signal_connect_contract_candidate (
561             slot (this, &HelperAgent::HelperAgentImpl::slot_contract_candidate));
562
563         si->signal_connect_set_candidate_style (
564             slot (this, &HelperAgent::HelperAgentImpl::slot_set_candidate_style));
565
566         si->signal_connect_send_private_command (
567             slot (this, &HelperAgent::HelperAgentImpl::slot_send_private_command));
568     }
569 public:
570     void process_key_event_done (KeyEvent &key, uint32 ret, uint32 serial) {
571         LOGD ("ret: %d, serial: %d", ret, serial);
572         if (socket_active.is_connected ()) {
573             send.clear ();
574             send.put_command (SCIM_TRANS_CMD_REQUEST);
575             send.put_data (magic_active);
576             send.put_command (ISM_TRANS_CMD_PROCESS_KEY_EVENT_DONE);
577             send.put_data (key);
578             send.put_data (ret);
579             send.put_data (serial);
580             send.write_to_socket (socket_active, magic_active);
581         }
582     }
583
584     void request_ise_hide () {
585         if (socket_active.is_connected ()) {
586             send.clear ();
587             send.put_command (SCIM_TRANS_CMD_REQUEST);
588             send.put_data (magic_active);
589             send.put_command (ISM_TRANS_CMD_REQUEST_ISE_HIDE);
590             send.write_to_socket (socket_active, magic_active);
591         }
592     }
593 private:
594     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), need_update_entry_metadata (true), ise_focus_flag (false), finalized_text (NULL), finalized_cursor_pos (0) { }
595 };
596
597 static MessageQueue message_queue;
598
599 HelperAgent::HelperAgent ()
600     : m_impl (new HelperAgentImpl (this))
601 {
602     message_queue.create();
603 }
604
605 HelperAgent::~HelperAgent ()
606 {
607     message_queue.destroy();
608     delete m_impl;
609 }
610
611 /**
612  * @brief Open socket connection to the Panel.
613  *
614  * @param info The information of this Helper object.
615  * @param display The display which this Helper object should run on.
616  *
617  * @return The connection socket id. -1 means failed to create
618  *         the connection.
619  */
620 int
621 HelperAgent::open_connection (const HelperInfo &info,
622                               const String     &display)
623 {
624     if (m_impl->socket.is_connected ())
625         close_connection ();
626
627     SocketAddress address (scim_get_default_panel_socket_address (display));
628     int timeout = m_impl->timeout = scim_get_default_socket_timeout ();
629     uint32 magic;
630
631     if (!address.valid ())
632         return -1;
633
634     int i = 0;
635     std::cerr << " Connecting to PanelAgent server.";
636     ISF_LOG (" Connecting to PanelAgent server.\n");
637     while (!m_impl->socket.connect (address)) {
638         std::cerr << ".";
639         scim_usleep (100000);
640         if (++i == 200) {
641             std::cerr << "m_impl->socket.connect () is failed!!!\n";
642             ISF_LOG ("m_impl->socket.connect () is failed!!!\n");
643             return -1;
644         }
645     }
646     std::cerr << " Connected :" << i << "\n";
647     ISF_LOG ("  Connected :%d\n", i);
648     LOGD ("Connection to PanelAgent succeeded, %d", i);
649
650     /* Let's retry 10 times when failed */
651     int open_connection_retries = 0;
652     while (!scim_socket_open_connection (magic,
653                                       String ("Helper"),
654                                       String ("Panel"),
655                                       m_impl->socket,
656                                       timeout)) {
657         if (++open_connection_retries > 10) {
658             m_impl->socket.close ();
659             std::cerr << "scim_socket_open_connection () is failed!!!\n";
660             ISF_LOG ("scim_socket_open_connection () is failed!!!\n");
661             ISF_SAVE_LOG ("scim_socket_open_connection failed, %d", timeout);
662
663             return -1;
664         }
665
666         /* Retry after re-connecting the socket */
667         if (m_impl->socket.is_connected ())
668             close_connection ();
669
670         /* This time, just retry atmost 2 seconds */
671         i = 0;
672         while (!m_impl->socket.connect (address) && ++i < 10) {
673             scim_usleep (200000);
674         }
675     }
676
677     ISF_LOG ("scim_socket_open_connection () is successful.\n");
678     LOGD ("scim_socket_open_connection successful");
679
680     m_impl->send.clear ();
681     m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
682     m_impl->send.put_data (magic);
683     m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_REGISTER_HELPER);
684     m_impl->send.put_data (info.uuid);
685     m_impl->send.put_data (info.name);
686     m_impl->send.put_data (info.icon);
687     m_impl->send.put_data (info.description);
688     m_impl->send.put_data (info.option);
689
690     if (!m_impl->send.write_to_socket (m_impl->socket, magic)) {
691         m_impl->socket.close ();
692         return -1;
693     }
694
695     int cmd;
696     if (m_impl->recv.read_from_socket (m_impl->socket, timeout) &&
697         m_impl->recv.get_command (cmd) && cmd == SCIM_TRANS_CMD_REPLY &&
698         m_impl->recv.get_command (cmd) && cmd == SCIM_TRANS_CMD_OK) {
699         m_impl->magic = magic;
700
701         while (m_impl->recv.get_command (cmd)) {
702             switch (cmd) {
703                 case SCIM_TRANS_CMD_HELPER_ATTACH_INPUT_CONTEXT:
704                 {
705                     uint32 ic;
706                     String ic_uuid;
707                     while (m_impl->recv.get_data (ic) && m_impl->recv.get_data (ic_uuid))
708                         m_impl->signal_attach_input_context (this, ic, ic_uuid);
709                     break;
710                 }
711                 case SCIM_TRANS_CMD_UPDATE_SCREEN:
712                 {
713                     uint32 screen;
714                     if (m_impl->recv.get_data (screen))
715                         m_impl->signal_update_screen (this, (uint32) -1, String (""), (int) screen);
716                     break;
717                 }
718                 default:
719                     break;
720             }
721         }
722     } else {
723         //FIXME: Attaching input context is needed for desktop environment
724         LOGW ("Attach input context and update screen failed");
725     }
726
727     ISF_SAVE_LOG ("Trying connect() with Helper_Active");
728
729     /* connect to the panel agent as the active helper client */
730     if (!m_impl->socket_active.connect (address)) return -1;
731     open_connection_retries = 0;
732     while (!scim_socket_open_connection (magic,
733                                       String ("Helper_Active"),
734                                       String ("Panel"),
735                                       m_impl->socket_active,
736                                       timeout)) {
737         if (++open_connection_retries > 10) {
738             m_impl->socket_active.close ();
739             std::cerr << "Helper_Active scim_socket_open_connection () is failed!!!\n";
740             ISF_LOG ("Helper_Active scim_socket_open_connection () is failed!!!\n");
741             ISF_SAVE_LOG ("Helper_Active scim_socket_open_connection failed, %d", timeout);
742
743             return -1;
744         }
745
746         /* Retry after re-connecting the socket */
747         if (m_impl->socket_active.is_connected ())
748             m_impl->socket_active.close ();
749
750         /* This time, just retry atmost 2 seconds */
751         i = 0;
752         while (!m_impl->socket_active.connect (address) && ++i < 10) {
753             scim_usleep (200000);
754         }
755     }
756
757     m_impl->magic_active = magic;
758
759     m_impl->send.clear ();
760     m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
761     m_impl->send.put_data (magic);
762     m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_REGISTER_ACTIVE_HELPER);
763     m_impl->send.put_data (info.uuid);
764     m_impl->send.put_data (info.name);
765     m_impl->send.put_data (info.icon);
766     m_impl->send.put_data (info.description);
767     m_impl->send.put_data (info.option);
768
769     if (!m_impl->send.write_to_socket (m_impl->socket_active, magic)) {
770         ISF_SAVE_LOG ("Helper_Active write_to_socket() failed");
771         m_impl->socket_active.close ();
772         return -1;
773     }
774     m_impl->m_config = ConfigBase::get (false, "socket");
775
776     return m_impl->socket.get_id ();
777 }
778
779 /**
780  * @brief Close the socket connection to Panel.
781  */
782 void
783 HelperAgent::close_connection ()
784 {
785     m_impl->socket.close ();
786     m_impl->socket_active.close ();
787     m_impl->send.clear ();
788     m_impl->recv.clear ();
789     m_impl->magic        = 0;
790     m_impl->magic_active = 0;
791     m_impl->timeout      = 0;
792 }
793
794 /**
795  * @brief Get the connection id previously returned by open_connection().
796  *
797  * @return the connection id
798  */
799 int
800 HelperAgent::get_connection_number () const
801 {
802     if (m_impl->socket.is_connected ())
803         return m_impl->socket.get_id ();
804     return -1;
805 }
806
807 /**
808  * @brief Check whether this HelperAgent has been connected to a Panel.
809  *
810  * Return true when it is connected to panel, otherwise return false.
811  */
812 bool
813 HelperAgent::is_connected () const
814 {
815     return m_impl->socket.is_connected ();
816 }
817
818 /**
819  * @brief Check if there are any events available to be processed.
820  *
821  * If it returns true then Helper object should call
822  * HelperAgent::filter_event() to process them.
823  *
824  * @return true if there are any events available.
825  */
826 bool
827 HelperAgent::has_pending_event () const
828 {
829     if (m_impl->socket.is_connected () && m_impl->socket.wait_for_data (0) > 0)
830         return true;
831
832     if (message_queue.has_pending_message())
833         return true;
834
835     return false;
836 }
837
838 /**
839  * @brief Process the pending events.
840  *
841  * This function will emit the corresponding signals according
842  * to the events.
843  *
844  * @return false if the connection is broken, otherwise return true.
845  */
846 bool
847 HelperAgent::filter_event ()
848 {
849     if (!m_impl->socket.is_connected ()) {
850         LOGW("Connection lost, returning false");
851         return false;
852     }
853
854     if (m_impl->recv.read_from_socket (m_impl->socket, m_impl->timeout)) {
855         message_queue.read_from_transaction(m_impl->recv);
856
857         while (message_queue.has_pending_message()) {
858             MessageItem *message = message_queue.get_pending_message();
859             handle_message(message);
860             message_queue.remove_message(message);
861         }
862     } else {
863         LOGD("read_from_socket() failed but continuing");
864     }
865
866     return true;
867 }
868
869
870 /**
871  * @brief Read messages from socket buffer, and see if there is a message with the given cmd.
872  *
873  * @return false if the connection is broken, or no message available with given cmd. Otherwise return true.
874  */
875 bool
876 HelperAgent::wait_for_message(int cmd, int timeout)
877 {
878     struct timeval t0 = { 0, 0 };
879     struct timeval t1 = { 0, 0 };
880     struct timeval t2 = { 0, 0 };
881
882     gettimeofday(&t0, NULL);
883
884     do {
885         if (!m_impl->socket.is_connected() || !m_impl->recv.read_from_socket(m_impl->socket, timeout))
886             return false;
887
888         message_queue.read_from_transaction(m_impl->recv);
889         if (message_queue.has_pending_message_by_cmd(cmd)) {
890             return true;
891         }
892
893         gettimeofday(&t1, NULL);
894         timersub(&t1, &t0, &t2);
895     } while (t2.tv_sec < timeout);
896
897     return false;
898 }
899
900 /**
901  * @brief Process one message that is in our message queue.
902  *
903  * This function will emit the corresponding signals according
904  * to the events.
905  *
906  * @param message The message that needs to be handled.
907  *
908  * @return false if the connection is broken, otherwise return true.
909  */
910 bool
911 HelperAgent::handle_message (MessageItem *message)
912 {
913     if (!message)
914         return false;
915
916     int cmd = message->get_command_ref();
917     LOGD ("HelperAgent::cmd = %d", cmd);
918     switch (cmd) {
919         case SCIM_TRANS_CMD_EXIT:
920         {
921             MessageItemExit *subclass = static_cast<MessageItemExit*>(message);
922             ISF_SAVE_LOG ("Helper ISE received SCIM_TRANS_CMD_EXIT message");
923             m_impl->signal_exit(this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
924             break;
925         }
926         case SCIM_TRANS_CMD_RELOAD_CONFIG:
927         {
928             MessageItemReloadConfig *subclass = static_cast<MessageItemReloadConfig*>(message);
929             m_impl->signal_reload_config (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
930             if (!m_impl->m_config.null())
931                 m_impl->m_config->ConfigBase::reload();
932             break;
933         }
934         case SCIM_TRANS_CMD_UPDATE_SCREEN:
935         {
936             MessageItemUpdateScreen *subclass = static_cast<MessageItemUpdateScreen*>(message);
937             m_impl->signal_update_screen (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
938                 subclass->get_screen_ref());
939             break;
940         }
941         case SCIM_TRANS_CMD_UPDATE_SPOT_LOCATION:
942         {
943             MessageItemUpdateSpotLocation *subclass = static_cast<MessageItemUpdateSpotLocation*>(message);
944             m_impl->signal_update_spot_location (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
945                 subclass->get_x_ref(), subclass->get_y_ref());
946             break;
947         }
948         case ISM_TRANS_CMD_UPDATE_CURSOR_POSITION:
949         {
950             MessageItemUpdateCursorPosition *subclass = static_cast<MessageItemUpdateCursorPosition*>(message);
951             m_impl->cursor_pos = subclass->get_cursor_pos_ref();
952             LOGD ("update cursor position %d", subclass->get_cursor_pos_ref());
953             if (m_impl->ise_show_flag || m_impl->need_update_entry_metadata) {
954                 m_impl->signal_update_cursor_position (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
955                     subclass->get_cursor_pos_ref());
956             }
957             if (!m_impl->si.null ()) m_impl->si->update_cursor_position(subclass->get_cursor_pos_ref());
958             break;
959         }
960         case ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT:
961         {
962             MessageItemUpdateSurroundingText *subclass = static_cast<MessageItemUpdateSurroundingText*>(message);
963             if (m_impl->surrounding_text != NULL)
964                 free (m_impl->surrounding_text);
965             m_impl->surrounding_text = strdup (subclass->get_text_ref().c_str ());
966             m_impl->cursor_pos = subclass->get_cursor_ref();
967             SECURE_LOGD ("surrounding text: %s, %d", m_impl->surrounding_text, subclass->get_cursor_ref());
968             while (m_impl->need_update_surrounding_text > 0) {
969                 m_impl->need_update_surrounding_text--;
970                 m_impl->signal_update_surrounding_text (this, subclass->get_ic_ref(),
971                     subclass->get_text_ref(), subclass->get_cursor_ref());
972             }
973             break;
974         }
975         case ISM_TRANS_CMD_UPDATE_SELECTION:
976         {
977             MessageItemUpdateSelection *subclass = static_cast<MessageItemUpdateSelection*>(message);
978             if (m_impl->selection_text != NULL)
979                 free (m_impl->selection_text);
980
981             m_impl->selection_text = strdup (subclass->get_text_ref().c_str ());
982             SECURE_LOGD ("selection text: %s", m_impl->selection_text);
983
984             while (m_impl->need_update_selection_text > 0) {
985                 m_impl->need_update_selection_text--;
986                 m_impl->signal_update_selection (this, subclass->get_ic_ref(), subclass->get_text_ref());
987             }
988             break;
989         }
990         case SCIM_TRANS_CMD_TRIGGER_PROPERTY:
991         {
992             MessageItemTriggerProperty *subclass = static_cast<MessageItemTriggerProperty*>(message);
993             m_impl->signal_trigger_property (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
994                 subclass->get_property_ref());
995             if (!m_impl->si.null ()) m_impl->si->trigger_property(subclass->get_property_ref());
996             break;
997         }
998         case SCIM_TRANS_CMD_HELPER_PROCESS_IMENGINE_EVENT:
999         {
1000             MessageItemHelperProcessImengineEvent *subclass = static_cast<MessageItemHelperProcessImengineEvent*>(message);
1001             m_impl->signal_process_imengine_event (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1002                 subclass->get_transaction_ref());
1003             break;
1004         }
1005         case SCIM_TRANS_CMD_HELPER_ATTACH_INPUT_CONTEXT:
1006         {
1007             MessageItemHelperAttachInputContext *subclass = static_cast<MessageItemHelperAttachInputContext*>(message);
1008             m_impl->signal_attach_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1009             break;
1010         }
1011         case SCIM_TRANS_CMD_HELPER_DETACH_INPUT_CONTEXT:
1012         {
1013             MessageItemHelperDetachInputContext *subclass = static_cast<MessageItemHelperDetachInputContext*>(message);
1014             m_impl->signal_detach_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1015             break;
1016         }
1017         case SCIM_TRANS_CMD_FOCUS_OUT:
1018         {
1019             MessageItemFocusOut *subclass = static_cast<MessageItemFocusOut*>(message);
1020             m_impl->ise_focus_flag = false;
1021             m_impl->signal_focus_out (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1022             m_impl->focused_ic = (uint32) -1;
1023             if (!m_impl->si.null ()) m_impl->si->focus_out();
1024             if (!_TV)
1025                 m_impl->ise_show_flag = false;
1026             break;
1027         }
1028         case SCIM_TRANS_CMD_FOCUS_IN:
1029         {
1030             MessageItemFocusIn *subclass = static_cast<MessageItemFocusIn*>(message);
1031             m_impl->ise_focus_flag = true;
1032             if (_WEARABLE)
1033                 m_impl->need_update_entry_metadata = false;
1034             m_impl->signal_focus_in (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1035             m_impl->focused_ic = subclass->get_ic_ref();
1036             if (m_impl->finalized_text != NULL)
1037                 free(m_impl->finalized_text);
1038             m_impl->finalized_text = NULL;
1039             m_impl->finalized_cursor_pos = 0;
1040             if (!m_impl->si.null ()) m_impl->si->focus_in();
1041             break;
1042         }
1043         case ISM_TRANS_CMD_SHOW_ISE_PANEL:
1044         {
1045             MessageItemShowISEPanel *subclass = static_cast<MessageItemShowISEPanel*>(message);
1046             LOGD ("Helper ISE received ISM_TRANS_CMD_SHOW_ISE_PANEL message");
1047
1048             m_impl->signal_ise_show (this, subclass->get_ic_ref(), *(subclass->get_data_ptr()),
1049                 subclass->get_len_ref());
1050             m_impl->ise_show_flag = true;
1051             break;
1052         }
1053         case ISM_TRANS_CMD_HIDE_ISE_PANEL:
1054         {
1055             MessageItemHideISEPanel *subclass = static_cast<MessageItemHideISEPanel*>(message);
1056             LOGD ("Helper ISE received ISM_TRANS_CMD_HIDE_ISE_PANEL message");
1057             m_impl->signal_ise_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1058             m_impl->ise_show_flag = false;
1059             break;
1060         }
1061         case ISM_TRANS_CMD_GET_ACTIVE_ISE_GEOMETRY:
1062         {
1063             struct rectinfo info = {0, 0, 0, 0};
1064             m_impl->signal_get_geometry (this, info);
1065             m_impl->send.clear ();
1066             m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1067             m_impl->send.put_data (info.pos_x);
1068             m_impl->send.put_data (info.pos_y);
1069             m_impl->send.put_data (info.width);
1070             m_impl->send.put_data (info.height);
1071             m_impl->send.write_to_socket (m_impl->socket);
1072             break;
1073         }
1074         case ISM_TRANS_CMD_SET_ISE_MODE:
1075         {
1076             MessageItemSetISEMode *subclass = static_cast<MessageItemSetISEMode*>(message);
1077             if (m_impl->ise_show_flag || m_impl->need_update_entry_metadata) {
1078                 m_impl->signal_set_mode (this, subclass->get_mode_ref());
1079             }
1080             break;
1081         }
1082         case ISM_TRANS_CMD_SET_ISE_LANGUAGE:
1083         {
1084             MessageItemSetISELanguage *subclass = static_cast<MessageItemSetISELanguage*>(message);
1085             if (m_impl->ise_show_flag || m_impl->need_update_entry_metadata) {
1086                 m_impl->signal_set_language (this, subclass->get_language_ref());
1087             }
1088             break;
1089         }
1090         case ISM_TRANS_CMD_SET_ISE_IMDATA:
1091         {
1092             MessageItemSetISEImData *subclass = static_cast<MessageItemSetISEImData*>(message);
1093             if (m_impl->ise_show_flag || m_impl->need_update_entry_metadata) {
1094                 m_impl->signal_set_imdata (this, *(subclass->get_imdata_ptr()), subclass->get_len_ref());
1095             }
1096             if (!m_impl->si.null ()) m_impl->si->set_imdata(*(subclass->get_imdata_ptr()),
1097                 subclass->get_len_ref());
1098             break;
1099         }
1100         case ISM_TRANS_CMD_GET_ISE_IMDATA:
1101         {
1102             char   *buf = NULL;
1103             size_t  len = 0;
1104
1105             m_impl->signal_get_imdata (this, &buf, len);
1106             LOGD ("send ise imdata len = %zu", len);
1107             m_impl->send.clear ();
1108             m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1109             m_impl->send.put_data (buf, len);
1110             m_impl->send.write_to_socket (m_impl->socket);
1111             if (NULL != buf)
1112                 free(buf);
1113             break;
1114         }
1115         case ISM_TRANS_CMD_GET_ISE_LANGUAGE_LOCALE:
1116         {
1117             MessageItemGetISELanguageLocale *subclass = static_cast<MessageItemGetISELanguageLocale*>(message);
1118             char *buf = NULL;
1119             m_impl->signal_get_language_locale (this, subclass->get_ic_ref(), &buf);
1120             m_impl->send.clear ();
1121             m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1122             if (buf != NULL)
1123                 m_impl->send.put_data (buf, strlen (buf));
1124             m_impl->send.write_to_socket (m_impl->socket);
1125             if (NULL != buf)
1126                 free(buf);
1127             break;
1128         }
1129         case ISM_TRANS_CMD_SET_RETURN_KEY_TYPE:
1130         {
1131             MessageItemSetReturnKeyType *subclass = static_cast<MessageItemSetReturnKeyType*>(message);
1132             if (m_impl->ise_show_flag || m_impl->need_update_entry_metadata) {
1133                 m_impl->signal_set_return_key_type (this, subclass->get_type_ref());
1134             }
1135             break;
1136         }
1137         case ISM_TRANS_CMD_GET_RETURN_KEY_TYPE:
1138         {
1139             uint32 type = 0;
1140             m_impl->signal_get_return_key_type (this, type);
1141             m_impl->send.clear ();
1142             m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1143             m_impl->send.put_data (type);
1144             m_impl->send.write_to_socket (m_impl->socket);
1145             break;
1146         }
1147         case ISM_TRANS_CMD_SET_RETURN_KEY_DISABLE:
1148         {
1149             MessageItemSetReturnKeyDisable *subclass = static_cast<MessageItemSetReturnKeyDisable*>(message);
1150             if (m_impl->ise_show_flag || m_impl->need_update_entry_metadata) {
1151                 m_impl->signal_set_return_key_disable (this, subclass->get_disabled_ref());
1152             }
1153             break;
1154         }
1155         case ISM_TRANS_CMD_GET_RETURN_KEY_DISABLE:
1156         {
1157             uint32 disabled = 0;
1158             m_impl->signal_get_return_key_type (this, disabled);
1159             m_impl->send.clear ();
1160             m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1161             m_impl->send.put_data (disabled);
1162             m_impl->send.write_to_socket (m_impl->socket);
1163             break;
1164         }
1165         case SCIM_TRANS_CMD_PROCESS_KEY_EVENT:
1166         {
1167             MessageItemProcessKeyEvent *subclass = static_cast<MessageItemProcessKeyEvent*>(message);
1168             uint32 ret = 0;
1169             uint32 keycode_ret = 0;
1170             m_impl->signal_process_key_event(this, subclass->get_key_ref(), ret);
1171             m_impl->signal_process_key_event_with_keycode(this, subclass->get_key_ref(), keycode_ret, subclass->get_keycode_ref());
1172             if (ret == 0 && keycode_ret == 0) {
1173                 if (!m_impl->si.null ()) {
1174                     if (!(subclass->get_key_ref().get_key_string().compare("KeyRelease+XF86Back") == 0 ||
1175                           subclass->get_key_ref().get_key_string().compare("XF86Back") == 0)) {
1176                         ret = m_impl->si->process_key_event (subclass->get_key_ref());
1177                         SECURE_LOGD ("imengine(%s) process key %d return %d", m_impl->si->get_factory_uuid().c_str(),
1178                             subclass->get_key_ref().code, ret);
1179                     }
1180                 } else {
1181                     if (!(subclass->get_key_ref().get_key_string().compare("KeyRelease+XF86Back") == 0 ||
1182                           subclass->get_key_ref().get_key_string().compare("XF86Back") == 0)) {
1183                         m_impl->signal_process_key_event_with_imengine(this, subclass->get_key_ref(), ret);
1184                         SECURE_LOGD ("imengine process key %d return %d", subclass->get_key_ref().code, ret);
1185                     }
1186                 }
1187             }
1188             if (ret != keycode_ret)
1189                 ret = 1;
1190             m_impl->process_key_event_done (subclass->get_key_ref(), ret, subclass->get_serial_ref());
1191             break;
1192         }
1193         case ISM_TRANS_CMD_SET_LAYOUT:
1194         {
1195             MessageItemSetLayout *subclass = static_cast<MessageItemSetLayout*>(message);
1196             m_impl->layout = subclass->get_layout_ref();
1197             if (m_impl->ise_show_flag || m_impl->need_update_entry_metadata) {
1198                 m_impl->signal_set_layout (this, subclass->get_layout_ref());
1199             }
1200             if (!m_impl->si.null ()) m_impl->si->set_layout(subclass->get_layout_ref());
1201             break;
1202         }
1203         case ISM_TRANS_CMD_GET_LAYOUT:
1204         {
1205             uint32 layout = 0;
1206
1207             m_impl->signal_get_layout (this, layout);
1208             m_impl->send.clear ();
1209             m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1210             m_impl->send.put_data (layout);
1211             m_impl->send.write_to_socket (m_impl->socket);
1212             break;
1213         }
1214         case ISM_TRANS_CMD_SET_INPUT_MODE:
1215         {
1216             MessageItemSetInputMode *subclass = static_cast<MessageItemSetInputMode*>(message);
1217             if (m_impl->ise_show_flag || m_impl->need_update_entry_metadata) {
1218                 m_impl->signal_set_input_mode (this, subclass->get_input_mode_ref());
1219             }
1220             break;
1221         }
1222         case ISM_TRANS_CMD_SET_CAPS_MODE:
1223         {
1224             MessageItemSetCapsMode *subclass = static_cast<MessageItemSetCapsMode*>(message);
1225             m_impl->signal_set_caps_mode (this, subclass->get_mode_ref());
1226             break;
1227         }
1228         case SCIM_TRANS_CMD_PANEL_RESET_INPUT_CONTEXT:
1229         {
1230             MessageItemPanelResetInputContext *subclass = static_cast<MessageItemPanelResetInputContext*>(message);
1231             m_impl->signal_reset_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1232             if (!m_impl->si.null ()) m_impl->si->reset();
1233             break;
1234         }
1235         case ISM_TRANS_CMD_UPDATE_CANDIDATE_UI:
1236         {
1237             MessageItemUpdateCandidateUI *subclass = static_cast<MessageItemUpdateCandidateUI*>(message);
1238             m_impl->signal_update_candidate_ui (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1239                 subclass->get_style_ref(), subclass->get_mode_ref());
1240             break;
1241         }
1242         case ISM_TRANS_CMD_UPDATE_CANDIDATE_GEOMETRY:
1243         {
1244             MessageItemUpdateCandidateGeometry *subclass = static_cast<MessageItemUpdateCandidateGeometry*>(message);
1245             m_impl->signal_update_candidate_geometry (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1246                 subclass->get_rectinfo_ref());
1247             break;
1248         }
1249         case ISM_TRANS_CMD_UPDATE_KEYBOARD_ISE:
1250         {
1251             MessageItemUpdateKeyboardISE *subclass = static_cast<MessageItemUpdateKeyboardISE*>(message);
1252             m_impl->signal_update_keyboard_ise (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1253                 subclass->get_name_ref(), subclass->get_uuid_ref());
1254             break;
1255         }
1256         case ISM_TRANS_CMD_UPDATE_KEYBOARD_ISE_LIST:
1257         {
1258             MessageItemUpdateKeyboardISEList *subclass = static_cast<MessageItemUpdateKeyboardISEList*>(message);
1259             m_impl->signal_update_keyboard_ise_list (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1260                 subclass->get_list_ref());
1261             break;
1262         }
1263         case ISM_TRANS_CMD_CANDIDATE_MORE_WINDOW_SHOW:
1264         {
1265             MessageItemCandidateMoreWindowShow *subclass = static_cast<MessageItemCandidateMoreWindowShow*>(message);
1266             m_impl->signal_candidate_more_window_show (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1267             if (!m_impl->si.null ()) m_impl->si->candidate_more_window_show();
1268             break;
1269         }
1270         case ISM_TRANS_CMD_CANDIDATE_MORE_WINDOW_HIDE:
1271         {
1272             MessageItemCandidateMoreWindowHide *subclass = static_cast<MessageItemCandidateMoreWindowHide*>(message);
1273             m_impl->signal_candidate_more_window_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1274             if (!m_impl->si.null ()) m_impl->si->candidate_more_window_hide();
1275             break;
1276         }
1277         case ISM_TRANS_CMD_SELECT_AUX:
1278         {
1279             MessageItemSelectAux *subclass = static_cast<MessageItemSelectAux*>(message);
1280             m_impl->signal_select_aux (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1281                 subclass->get_item_ref());
1282             if (!m_impl->si.null ()) m_impl->si->select_aux(subclass->get_item_ref());
1283             break;
1284         }
1285         case SCIM_TRANS_CMD_SELECT_CANDIDATE: //FIXME:remove if useless
1286         {
1287             MessageItemSelectCandidate *subclass = static_cast<MessageItemSelectCandidate*>(message);
1288             m_impl->signal_select_candidate (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_candidate(subclass->get_item_ref());
1291             break;
1292         }
1293         case SCIM_TRANS_CMD_LOOKUP_TABLE_PAGE_UP: //FIXME:remove if useless
1294         {
1295             MessageItemLookupTablePageUp *subclass = static_cast<MessageItemLookupTablePageUp*>(message);
1296             m_impl->signal_candidate_table_page_up (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1297             if (!m_impl->si.null ()) m_impl->si->lookup_table_page_up();
1298             break;
1299         }
1300         case SCIM_TRANS_CMD_LOOKUP_TABLE_PAGE_DOWN: //FIXME:remove if useless
1301         {
1302             MessageItemLookupTablePageDown *subclass = static_cast<MessageItemLookupTablePageDown*>(message);
1303             m_impl->signal_candidate_table_page_down (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1304             if (!m_impl->si.null ()) m_impl->si->lookup_table_page_down();
1305             break;
1306         }
1307         case SCIM_TRANS_CMD_UPDATE_LOOKUP_TABLE_PAGE_SIZE:
1308         {
1309             MessageItemUpdateLookupTablePageSize *subclass = static_cast<MessageItemUpdateLookupTablePageSize*>(message);
1310             m_impl->signal_update_candidate_table_page_size (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1311                 subclass->get_size_ref());
1312             if (!m_impl->si.null ()) m_impl->si->update_lookup_table_page_size(subclass->get_size_ref());
1313             break;
1314         }
1315         case ISM_TRANS_CMD_CANDIDATE_SHOW: //FIXME:remove if useless
1316         {
1317             MessageItemCandidateShow *subclass = static_cast<MessageItemCandidateShow*>(message);
1318             m_impl->signal_candidate_show (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1319             break;
1320         }
1321         case ISM_TRANS_CMD_CANDIDATE_HIDE: //FIXME:remove if useless
1322         {
1323             MessageItemCandidateHide *subclass = static_cast<MessageItemCandidateHide*>(message);
1324             m_impl->signal_candidate_hide (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1325             break;
1326         }
1327         case ISM_TRANS_CMD_UPDATE_LOOKUP_TABLE: //FIXME:remove if useless
1328         {
1329             MessageItemUpdateLookupTable *subclass = static_cast<MessageItemUpdateLookupTable*>(message);
1330             m_impl->signal_update_lookup_table (this, subclass->get_candidate_table_ref());
1331             break;
1332         }
1333         case ISM_TRANS_CMD_UPDATE_CANDIDATE_ITEM_LAYOUT:
1334         {
1335             MessageItemUpdateCandidateItemLayout *subclass = static_cast<MessageItemUpdateCandidateItemLayout*>(message);
1336             m_impl->signal_update_candidate_item_layout (this, subclass->get_row_items_ref());
1337             if (!m_impl->si.null ()) m_impl->si->update_candidate_item_layout(subclass->get_row_items_ref());
1338             break;
1339         }
1340         case ISM_TRANS_CMD_SELECT_ASSOCIATE:
1341         {
1342             MessageItemSelectAssociate *subclass = static_cast<MessageItemSelectAssociate*>(message);
1343             m_impl->signal_select_associate (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1344                 subclass->get_item_ref());
1345             break;
1346         }
1347         case ISM_TRANS_CMD_ASSOCIATE_TABLE_PAGE_UP:
1348         {
1349             MessageItemAssociateTablePageUp *subclass = static_cast<MessageItemAssociateTablePageUp*>(message);
1350             m_impl->signal_associate_table_page_up (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1351             break;
1352         }
1353         case ISM_TRANS_CMD_ASSOCIATE_TABLE_PAGE_DOWN:
1354         {
1355             MessageItemAssociateTablePageDown *subclass = static_cast<MessageItemAssociateTablePageDown*>(message);
1356             m_impl->signal_associate_table_page_down (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1357             break;
1358         }
1359         case ISM_TRANS_CMD_UPDATE_ASSOCIATE_TABLE_PAGE_SIZE:
1360         {
1361             MessageItemUpdateAssociateTablePageSize *subclass = static_cast<MessageItemUpdateAssociateTablePageSize*>(message);
1362             m_impl->signal_update_associate_table_page_size (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1363                 subclass->get_size_ref());
1364             break;
1365         }
1366         case ISM_TRANS_CMD_RESET_ISE_CONTEXT:
1367         {
1368             MessageItemResetISEContext *subclass = static_cast<MessageItemResetISEContext*>(message);
1369             m_impl->signal_reset_ise_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1370             m_impl->signal_reset_input_context (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1371             if (!m_impl->si.null ()) m_impl->si->reset();
1372             break;
1373         }
1374         case ISM_TRANS_CMD_TURN_ON_LOG:
1375         {
1376             MessageItemTurnOnLog *subclass = static_cast<MessageItemTurnOnLog*>(message);
1377             m_impl->signal_turn_on_log (this, subclass->get_state_ref());
1378             break;
1379         }
1380         case ISM_TRANS_CMD_UPDATE_DISPLAYED_CANDIDATE:
1381         {
1382             MessageItemUpdateDisplayedCandidate *subclass = static_cast<MessageItemUpdateDisplayedCandidate*>(message);
1383             m_impl->signal_update_displayed_candidate_number (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1384                 subclass->get_size_ref());
1385             if (!m_impl->si.null ()) m_impl->si->update_displayed_candidate_number(subclass->get_size_ref());
1386             break;
1387         }
1388         case ISM_TRANS_CMD_LONGPRESS_CANDIDATE:
1389         {
1390             MessageItemLongpressCandidate *subclass = static_cast<MessageItemLongpressCandidate*>(message);
1391             m_impl->signal_longpress_candidate (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref(),
1392                 subclass->get_index_ref());
1393             if (!m_impl->si.null ()) m_impl->si->longpress_candidate(subclass->get_index_ref());
1394             break;
1395         }
1396         case ISM_TRANS_CMD_SET_INPUT_HINT:
1397         {
1398             MessageItemSetInputHint *subclass = static_cast<MessageItemSetInputHint*>(message);
1399             if (m_impl->ise_show_flag || m_impl->need_update_entry_metadata) {
1400                 m_impl->signal_set_input_hint (this, subclass->get_input_hint_ref());
1401             }
1402             if (!m_impl->si.null ()) m_impl->si->set_input_hint(subclass->get_input_hint_ref());
1403             break;
1404         }
1405         case ISM_TRANS_CMD_UPDATE_BIDI_DIRECTION:
1406         {
1407             MessageItemUpdateBidiDirection *subclass = static_cast<MessageItemUpdateBidiDirection*>(message);
1408             m_impl->signal_update_bidi_direction (this, subclass->get_bidi_direction());
1409             if (!m_impl->si.null ()) m_impl->si->update_bidi_direction(subclass->get_bidi_direction());
1410             break;
1411         }
1412         case ISM_TRANS_CMD_SHOW_ISE_OPTION_WINDOW:
1413         {
1414             MessageItemShowISEOptionWindow *subclass = static_cast<MessageItemShowISEOptionWindow*>(message);
1415             m_impl->signal_show_option_window (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1416             break;
1417         }
1418         case ISM_TRANS_CMD_RESUME_ISE_OPTION_WINDOW:
1419         {
1420             MessageItemResumeISEOptionWindow *subclass = static_cast<MessageItemResumeISEOptionWindow*>(message);
1421             m_impl->signal_resume_option_window (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
1422             break;
1423         }
1424         case ISM_TRANS_CMD_CHECK_OPTION_WINDOW:
1425         {
1426             uint32 avail = 0;
1427             m_impl->signal_check_option_window (this, avail);
1428             m_impl->send.clear ();
1429             m_impl->send.put_command (SCIM_TRANS_CMD_REPLY);
1430             m_impl->send.put_data (avail);
1431             m_impl->send.write_to_socket (m_impl->socket);
1432             break;
1433         }
1434         case ISM_TRANS_CMD_PROCESS_INPUT_DEVICE_EVENT:
1435         {
1436             MessageItemProcessInputDeviceEvent *subclass = static_cast<MessageItemProcessInputDeviceEvent*>(message);
1437             uint32 ret = 0;
1438             unsigned int ecore_event_id = find_ecore_event_from_device_type((isf_device_type_e)(subclass->get_type_ref()));
1439             char *decoded = (char*)malloc(subclass->get_len_ref());
1440             size_t decoded_size = subclass->get_len_ref();
1441             if (decoded) {
1442                 if(device_buffer_decode((const char*)*(subclass->get_data_ptr()),
1443                     subclass->get_len_ref(), (char*)(decoded), &decoded_size)) {
1444                     m_impl->signal_process_input_device_event(this, ecore_event_id, decoded, decoded_size, ret);
1445                 }
1446                 free(decoded);
1447             }
1448             break;
1449         }
1450         case SCIM_TRANS_CMD_SET_AUTOCAPITAL_TYPE:
1451         {
1452             MessageItemSetAutocapitalType *subclass = static_cast<MessageItemSetAutocapitalType*>(message);
1453             if (!m_impl->si.null ()) m_impl->si->set_autocapital_type(subclass->get_auto_capital_type_ref());
1454             m_impl->signal_set_autocapital_type(this, subclass->get_auto_capital_type_ref());
1455             break;
1456         }
1457         case ISM_TRANS_CMD_SET_PREDICTION_ALLOW:
1458         {
1459             MessageItemSetPredictionAllow *subclass = static_cast<MessageItemSetPredictionAllow*>(message);
1460             if (!m_impl->si.null ()) m_impl->si->set_prediction_allow(subclass->get_prediction_allow_ref() == 0 ? false : true);
1461             m_impl->signal_set_prediction_allow(this, subclass->get_prediction_allow_ref());
1462             break;
1463         }
1464         case ISM_TRANS_CMD_SET_KEYBOARD_MODE:
1465         {
1466             MessageItemSetKeyboardMode *subclass = static_cast<MessageItemSetKeyboardMode*>(message);
1467             if (subclass->get_mode_ref())
1468                 m_impl->need_update_entry_metadata = false;
1469             else
1470                 m_impl->need_update_entry_metadata = true;
1471             break;
1472         }
1473         case ISM_TRANS_CMD_SET_PREDICTION_HINT:
1474         {
1475             MessageItemSetPredictionHint *subclass = static_cast<MessageItemSetPredictionHint*>(message);
1476             m_impl->signal_set_prediction_hint (this, subclass->get_message_ref());
1477             break;
1478         }
1479         case ISM_TRANS_CMD_SET_MIME_TYPE:
1480         {
1481             MessageItemSetMimeType *subclass = static_cast<MessageItemSetMimeType*>(message);
1482             if (m_impl->ise_show_flag || m_impl->need_update_entry_metadata) {
1483                 m_impl->signal_set_mime_type (this, subclass->get_mime_type_ref());
1484             }
1485             break;
1486         }
1487         case ISM_TRANS_CMD_FINALIZE_CONTENT:
1488         {
1489             MessageItemFinalizeContent *subclass = static_cast<MessageItemFinalizeContent*>(message);
1490             if (m_impl) {
1491                 if (m_impl->finalized_text != NULL)
1492                     free(m_impl->finalized_text);
1493                 m_impl->finalized_text = strdup(subclass->get_text_ref().c_str());
1494                 m_impl->finalized_cursor_pos = subclass->get_cursor_pos_ref();
1495             }
1496             break;
1497         }
1498         case ISM_TRANS_CMD_SET_PREDICTION_HINT_DATA:
1499         {
1500             MessageItemSetPredictionHintData *subclass = static_cast<MessageItemSetPredictionHintData*>(message);
1501             m_impl->signal_set_prediction_hint_data (this, 0, subclass->get_key_ref(), subclass->get_value_ref());
1502             break;
1503         }
1504         case ISM_TRANS_CMD_SET_OPTIMIZATION_HINT:
1505         {
1506             MessageItemSetOptimizationHint *subclass = static_cast<MessageItemSetOptimizationHint*>(message);
1507             m_impl->signal_set_optimization_hint(this, subclass->get_hint_ref());
1508             break;
1509         }
1510         default:
1511             break;
1512     }
1513     return true;
1514 }
1515
1516 /**
1517  * @brief Request SCIM to reload all configuration.
1518  *
1519  * This function should only by used by Setup Helper to request
1520  * scim's reloading the configuration.
1521  * Deprecated: reload config message only send by socketconfig client
1522  * using socketconfig::reload instead.
1523  */
1524 void
1525 HelperAgent::reload_config () const
1526 {
1527     LOGD ("send reload config message to isf");
1528     if (!m_impl->m_config.null())
1529         m_impl->m_config->reload();
1530 }
1531
1532 /**
1533  * @brief Register some properties into Panel.
1534  *
1535  * This function send the request to Panel to register a list
1536  * of Properties.
1537  *
1538  * @param properties The list of Properties to be registered into Panel.
1539  *
1540  * @sa scim::Property.
1541  */
1542 void
1543 HelperAgent::register_properties (const PropertyList &properties) const
1544 {
1545     if (m_impl->socket_active.is_connected ()) {
1546         m_impl->send.clear ();
1547         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1548         m_impl->send.put_data (m_impl->magic_active);
1549         m_impl->send.put_command (SCIM_TRANS_CMD_REGISTER_PROPERTIES);
1550         m_impl->send.put_data (properties);
1551         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1552     }
1553 }
1554
1555 /**
1556  * @brief Update a registered property.
1557  *
1558  * @param property The property to be updated.
1559  */
1560 void
1561 HelperAgent::update_property (const Property &property) const
1562 {
1563     if (m_impl->socket_active.is_connected ()) {
1564         m_impl->send.clear ();
1565         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1566         m_impl->send.put_data (m_impl->magic_active);
1567         m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PROPERTY);
1568         m_impl->send.put_data (property);
1569         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1570     }
1571 }
1572
1573 /**
1574  * @brief Send a set of events to an IMEngineInstance.
1575  *
1576  * All events should be put into a Transaction.
1577  * And the events can only be received by one IMEngineInstance object.
1578  *
1579  * @param ic The handle of the Input Context to receive the events.
1580  * @param ic_uuid The UUID of the Input Context.
1581  * @param trans The Transaction object holds the events.
1582  */
1583 void
1584 HelperAgent::send_imengine_event (int                ic,
1585                                   const String      &ic_uuid,
1586                                   const Transaction &trans) const
1587 {
1588 //remove if not necessary
1589 #if 0
1590     if (m_impl->socket_active.is_connected ()) {
1591         m_impl->send.clear ();
1592         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1593         m_impl->send.put_data (m_impl->magic_active);
1594         m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_SEND_IMENGINE_EVENT);
1595         m_impl->send.put_data ((uint32)ic);
1596         m_impl->send.put_data (ic_uuid);
1597         m_impl->send.put_data (trans);
1598         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1599     }
1600 #endif
1601     if (!m_impl->si.null ()) m_impl->si->process_helper_event (ic_uuid, trans);
1602 }
1603
1604 /**
1605  * @brief Send a KeyEvent to an IMEngineInstance.
1606  *
1607  * @param ic The handle of the IMEngineInstance to receive the event.
1608  *        -1 means the currently focused IMEngineInstance.
1609  * @param ic_uuid The UUID of the IMEngineInstance. Empty means don't match.
1610  * @param key The KeyEvent to be sent.
1611  */
1612 void
1613 HelperAgent::send_key_event (int            ic,
1614                              const String   &ic_uuid,
1615                              const KeyEvent &key) const
1616 {
1617
1618     //FIXME: remove shift_mode_off, shift_mode_on, shift_mode_lock from ISE side
1619     if (key.code == SHIFT_MODE_OFF ||
1620         key.code == SHIFT_MODE_ON ||
1621         key.code == SHIFT_MODE_LOCK ||
1622         key.code == SHIFT_MODE_ENABLE ||
1623         key.code == SHIFT_MODE_DISABLE) {
1624         LOGW("FIXME ignore shift codes");
1625         return;
1626     }
1627
1628     if (m_impl->socket_active.is_connected ()) {
1629         m_impl->send.clear ();
1630         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1631         m_impl->send.put_data (m_impl->magic_active);
1632         m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_SEND_KEY_EVENT);
1633         if (ic == -1) {
1634             m_impl->send.put_data (m_impl->focused_ic);
1635         } else {
1636             m_impl->send.put_data ((uint32)ic);
1637         }
1638         m_impl->send.put_data (ic_uuid);
1639         m_impl->send.put_data (key);
1640         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1641     }
1642 }
1643
1644 /**
1645  * @brief Forward a KeyEvent to client application directly.
1646  *
1647  * @param ic The handle of the client Input Context to receive the event.
1648  *        -1 means the currently focused Input Context.
1649  * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1650  *        Empty means don't match.
1651  * @param key The KeyEvent to be forwarded.
1652  */
1653 void
1654 HelperAgent::forward_key_event (int            ic,
1655                                 const String   &ic_uuid,
1656                                 const KeyEvent &key) const
1657 {
1658     if (m_impl->socket_active.is_connected ()) {
1659         m_impl->send.clear ();
1660         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1661         m_impl->send.put_data (m_impl->magic_active);
1662         m_impl->send.put_command (SCIM_TRANS_CMD_FORWARD_KEY_EVENT);
1663         if (ic == -1) {
1664             m_impl->send.put_data (m_impl->focused_ic);
1665         } else {
1666             m_impl->send.put_data ((uint32)ic);
1667         }
1668         m_impl->send.put_data (ic_uuid);
1669         m_impl->send.put_data (key);
1670         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1671     }
1672 }
1673
1674 /**
1675  * @brief Commit a WideString to client application directly.
1676  *
1677  * @param ic The handle of the client Input Context to receive the WideString.
1678  *        -1 means the currently focused Input Context.
1679  * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1680  *        Empty means don't match.
1681  * @param wstr The WideString to be committed.
1682  */
1683 void
1684 HelperAgent::commit_string (int               ic,
1685                             const String     &ic_uuid,
1686                             const WideString &wstr) const
1687 {
1688     if (m_impl->socket_active.is_connected ()) {
1689         m_impl->send.clear ();
1690         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1691         m_impl->send.put_data (m_impl->magic_active);
1692         m_impl->send.put_command (SCIM_TRANS_CMD_COMMIT_STRING);
1693         if (ic == -1) {
1694             m_impl->send.put_data (m_impl->focused_ic);
1695         } else {
1696             m_impl->send.put_data ((uint32)ic);
1697         }
1698         m_impl->send.put_data (ic_uuid);
1699         m_impl->send.put_data (wstr);
1700         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1701     }
1702 }
1703
1704 void
1705 HelperAgent::commit_string (int               ic,
1706                             const String     &ic_uuid,
1707                             const  char      *buf,
1708                             int               buflen) const
1709 {
1710     if (m_impl->socket_active.is_connected ()) {
1711         m_impl->send.clear ();
1712         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1713         m_impl->send.put_data (m_impl->magic_active);
1714         m_impl->send.put_command (SCIM_TRANS_CMD_COMMIT_STRING);
1715         if (ic == -1) {
1716             m_impl->send.put_data (m_impl->focused_ic);
1717         } else {
1718             m_impl->send.put_data ((uint32)ic);
1719         }
1720         m_impl->send.put_data (ic_uuid);
1721         m_impl->send.put_dataw (buf, buflen);
1722         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1723     }
1724 }
1725
1726 /**
1727  * @brief Request to show preedit string.
1728  *
1729  * @param ic The handle of the client Input Context to receive the request.
1730  *        -1 means the currently focused Input Context.
1731  * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1732  *        Empty means don't match.
1733  */
1734 void
1735 HelperAgent::show_preedit_string (int               ic,
1736                                   const String     &ic_uuid) const
1737 {
1738
1739     if (m_impl->socket_active.is_connected ()) {
1740         m_impl->send.clear ();
1741         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1742         m_impl->send.put_data (m_impl->magic_active);
1743         m_impl->send.put_command (SCIM_TRANS_CMD_SHOW_PREEDIT_STRING);
1744         m_impl->send.put_data ((uint32)ic);
1745         m_impl->send.put_data (ic_uuid);
1746         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1747     }
1748 }
1749
1750 /**
1751  * @brief Request to show aux string.
1752  */
1753 void
1754 HelperAgent::show_aux_string (void) const
1755 {
1756
1757     if (m_impl->socket_active.is_connected ()) {
1758         m_impl->send.clear ();
1759         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1760         m_impl->send.put_data (m_impl->magic_active);
1761         m_impl->send.put_command (SCIM_TRANS_CMD_SHOW_AUX_STRING);
1762         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1763     }
1764 }
1765
1766 /**
1767  * @brief Request to show candidate string.
1768  */
1769 void
1770 HelperAgent::show_candidate_string (void) const
1771 {
1772
1773     if (m_impl->socket_active.is_connected ()) {
1774         m_impl->send.clear ();
1775         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1776         m_impl->send.put_data (m_impl->magic_active);
1777         m_impl->send.put_command (SCIM_TRANS_CMD_SHOW_LOOKUP_TABLE);
1778         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1779     }
1780 }
1781
1782 /**
1783  * @brief Request to show associate string.
1784  */
1785 void
1786 HelperAgent::show_associate_string (void) const
1787 {
1788     if (m_impl->socket_active.is_connected ()) {
1789         m_impl->send.clear ();
1790         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1791         m_impl->send.put_data (m_impl->magic_active);
1792         m_impl->send.put_command (ISM_TRANS_CMD_SHOW_ASSOCIATE_TABLE);
1793         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1794     }
1795 }
1796
1797 /**
1798  * @brief Request to hide preedit string.
1799  *
1800  * @param ic The handle of the client Input Context to receive the request.
1801  *        -1 means the currently focused Input Context.
1802  * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1803  *        Empty means don't match.
1804  */
1805 void
1806 HelperAgent::hide_preedit_string (int               ic,
1807                                   const String     &ic_uuid) const
1808 {
1809
1810     if (m_impl->socket_active.is_connected ()) {
1811         m_impl->send.clear ();
1812         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1813         m_impl->send.put_data (m_impl->magic_active);
1814         m_impl->send.put_command (SCIM_TRANS_CMD_HIDE_PREEDIT_STRING);
1815         m_impl->send.put_data ((uint32)ic);
1816         m_impl->send.put_data (ic_uuid);
1817         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1818     }
1819 }
1820
1821 /**
1822  * @brief Request to hide aux string.
1823  */
1824 void
1825 HelperAgent::hide_aux_string (void) const
1826 {
1827     if (m_impl->socket_active.is_connected ()) {
1828         m_impl->send.clear ();
1829         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1830         m_impl->send.put_data (m_impl->magic_active);
1831         m_impl->send.put_command (SCIM_TRANS_CMD_HIDE_AUX_STRING);
1832         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1833     }
1834 }
1835
1836 /**
1837  * @brief Request to hide candidate string.
1838  */
1839 void
1840 HelperAgent::hide_candidate_string (void) const
1841 {
1842     if (m_impl->socket_active.is_connected ()) {
1843         m_impl->send.clear ();
1844         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1845         m_impl->send.put_data (m_impl->magic_active);
1846         m_impl->send.put_command (SCIM_TRANS_CMD_HIDE_LOOKUP_TABLE);
1847         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1848     }
1849 }
1850
1851 /**
1852  * @brief Request to hide associate string.
1853  */
1854 void
1855 HelperAgent::hide_associate_string (void) const
1856 {
1857     if (m_impl->socket_active.is_connected ()) {
1858         m_impl->send.clear ();
1859         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1860         m_impl->send.put_data (m_impl->magic_active);
1861         m_impl->send.put_command (ISM_TRANS_CMD_HIDE_ASSOCIATE_TABLE);
1862         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1863     }
1864 }
1865
1866 /**
1867  * @brief Update a new WideString for preedit.
1868  *
1869  * @param ic The handle of the client Input Context to receive the WideString.
1870  *        -1 means the currently focused Input Context.
1871  * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1872  *        Empty means don't match.
1873  * @param str The WideString to be updated.
1874  * @param attrs The attribute list for preedit string.
1875  */
1876 void
1877 HelperAgent::update_preedit_string (int                  ic,
1878                                     const String        &ic_uuid,
1879                                     const WideString    &str,
1880                                     const AttributeList &attrs) const
1881 {
1882     update_preedit_string (ic, ic_uuid, str, str, attrs, -1);
1883 }
1884
1885 void
1886 HelperAgent::update_preedit_string (int                  ic,
1887                                     const String        &ic_uuid,
1888                                     const char         *buf,
1889                                     int                 buflen,
1890                                     const AttributeList &attrs) const
1891 {
1892     update_preedit_string (ic, ic_uuid, buf, buflen, attrs, -1);
1893 }
1894
1895 /**
1896  * @brief Update a new WideString for preedit.
1897  *
1898  * @param ic The handle of the client Input Context to receive the WideString.
1899  *        -1 means the currently focused Input Context.
1900  * @param ic_uuid The UUID of the IMEngine used by the Input Context.
1901  *        Empty means don't match.
1902  * @param str The WideString to be updated.
1903  * @param attrs The attribute list for preedit string.
1904  * @param caret The caret position in preedit string.
1905  */
1906 void
1907 HelperAgent::update_preedit_string (int                  ic,
1908                                     const String        &ic_uuid,
1909                                     const WideString    &wstr,
1910                                     const AttributeList &attrs,
1911                                     int            caret) const
1912 {
1913     update_preedit_string (ic, ic_uuid, wstr, wstr, attrs, caret);
1914 }
1915
1916 void
1917 HelperAgent::update_preedit_string (int                 ic,
1918                                     const String       &ic_uuid,
1919                                     const char         *buf,
1920                                     int                 buflen,
1921                                     const AttributeList &attrs,
1922                                     int            caret) const
1923 {
1924
1925     if (m_impl->socket_active.is_connected ()) {
1926         m_impl->send.clear ();
1927         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1928         m_impl->send.put_data (m_impl->magic_active);
1929         m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING);
1930         m_impl->send.put_data ((uint32)ic);
1931         m_impl->send.put_data (ic_uuid);
1932         m_impl->send.put_dataw (buf, buflen);
1933         m_impl->send.put_dataw (buf, buflen);
1934         m_impl->send.put_data (attrs);
1935         m_impl->send.put_data (caret);
1936         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1937     }
1938 }
1939
1940 void
1941 HelperAgent::update_preedit_string (int                  ic,
1942                                     const String        &ic_uuid,
1943                                     const WideString    &preedit,
1944                                     const WideString    &commit,
1945                                     const AttributeList &attrs,
1946                                     int                  caret) const
1947 {
1948     if (m_impl->socket_active.is_connected ()) {
1949         m_impl->send.clear ();
1950         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1951         m_impl->send.put_data (m_impl->magic_active);
1952         m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING);
1953         m_impl->send.put_data ((uint32)ic);
1954         m_impl->send.put_data (ic_uuid);
1955         m_impl->send.put_data (preedit);
1956         m_impl->send.put_data (commit);
1957         m_impl->send.put_data (attrs);
1958         m_impl->send.put_data (caret);
1959         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1960     }
1961 }
1962
1963 /**
1964  * @brief Update the preedit caret position in the preedit string.
1965  *
1966  * @param caret - the new position of the preedit caret.
1967  */
1968 void
1969 HelperAgent::update_preedit_caret (int caret) const
1970 {
1971
1972     if (m_impl->socket_active.is_connected ()) {
1973         m_impl->send.clear ();
1974         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1975         m_impl->send.put_data (m_impl->magic_active);
1976         m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_CARET);
1977         m_impl->send.put_data ((uint32)caret);
1978         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
1979     }
1980 }
1981
1982 /**
1983  * @brief Update a new string for aux.
1984  *
1985  * @param str The string to be updated.
1986  * @param attrs The attribute list for aux string.
1987  */
1988 void
1989 HelperAgent::update_aux_string (const String        &str,
1990                                 const AttributeList &attrs) const
1991 {
1992     if (m_impl->socket_active.is_connected ()) {
1993         m_impl->send.clear ();
1994         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
1995         m_impl->send.put_data (m_impl->magic_active);
1996         m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_AUX_STRING);
1997         m_impl->send.put_data (str);
1998         m_impl->send.put_data (attrs);
1999         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2000     }
2001 }
2002
2003 /**
2004  * @brief Request to update candidate.
2005  *
2006  * @param table The lookup table for candidate.
2007  */
2008 void
2009 HelperAgent::update_candidate_string (const LookupTable &table) const
2010 {
2011     if (m_impl->socket_active.is_connected ()) {
2012         m_impl->send.clear ();
2013         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2014         m_impl->send.put_data (m_impl->magic_active);
2015         m_impl->send.put_command (SCIM_TRANS_CMD_UPDATE_LOOKUP_TABLE);
2016         m_impl->send.put_data (table);
2017         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2018     }
2019 }
2020
2021 /**
2022  * @brief Request to update associate.
2023  *
2024  * @param table The lookup table for associate.
2025  */
2026 void
2027 HelperAgent::update_associate_string (const LookupTable &table) const
2028 {
2029     if (m_impl->socket_active.is_connected ()) {
2030         m_impl->send.clear ();
2031         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2032         m_impl->send.put_data (m_impl->magic_active);
2033         m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ASSOCIATE_TABLE);
2034         m_impl->send.put_data (table);
2035         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2036     }
2037 }
2038
2039 /**
2040  * @brief When the input context of ISE is changed,
2041  *         ISE can call this function to notify application
2042  *
2043  * @param type  type of event.
2044  * @param value value of event.
2045  */
2046 void
2047 HelperAgent::update_input_context (uint32 type, uint32 value) const
2048 {
2049     if (type == ECORE_IMF_INPUT_PANEL_LANGUAGE_EVENT) {
2050         /* Update all state variables that could be queried by the client application */
2051         char *buf = NULL;
2052         m_impl->signal_get_language_locale(this, -1, &buf);
2053
2054         if (buf != NULL) {
2055             if (m_impl->socket_active.is_connected()) {
2056                 m_impl->send.clear();
2057                 m_impl->send.put_command(SCIM_TRANS_CMD_REQUEST);
2058                 m_impl->send.put_data(m_impl->magic_active);
2059                 m_impl->send.put_command(ISM_TRANS_CMD_UPDATE_ISE_LANGUAGE_LOCALE);
2060                 m_impl->send.put_data(buf, strlen(buf));
2061                 m_impl->send.write_to_socket(m_impl->socket_active, m_impl->magic_active);
2062             }
2063             free(buf);
2064             buf = NULL;
2065         }
2066     }
2067
2068     if (m_impl->socket_active.is_connected ()) {
2069         m_impl->send.clear ();
2070         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2071         m_impl->send.put_data (m_impl->magic_active);
2072         m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ISE_INPUT_CONTEXT);
2073         m_impl->send.put_data (type);
2074         m_impl->send.put_data (value);
2075         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2076     }
2077 }
2078
2079 /**
2080  * @brief Request to get surrounding text asynchronously.
2081  *
2082  * @param uuid The helper ISE UUID.
2083  * @param maxlen_before The max length of before.
2084  * @param maxlen_after The max length of after.
2085  */
2086 void
2087 HelperAgent::get_surrounding_text (const String &uuid, int maxlen_before, int maxlen_after) const
2088 {
2089     if (m_impl->socket_active.is_connected () && (m_impl->need_update_surrounding_text == 0)) {
2090         m_impl->send.clear ();
2091         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2092         m_impl->send.put_data (m_impl->magic_active);
2093         m_impl->send.put_command (SCIM_TRANS_CMD_GET_SURROUNDING_TEXT);
2094         m_impl->send.put_data (uuid);
2095         m_impl->send.put_data (maxlen_before);
2096         m_impl->send.put_data (maxlen_after);
2097         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2098     }
2099     m_impl->need_update_surrounding_text++;
2100 }
2101
2102 /**
2103  * @brief Request to get surrounding text synchronously.
2104  *
2105  * @param uuid The helper ISE UUID.
2106  * @param maxlen_before The max length of before.
2107  * @param maxlen_after The max length of after.
2108  * @param text The surrounding text.
2109  * @param cursor The cursor position.
2110  */
2111 void
2112 HelperAgent::get_surrounding_text (int maxlen_before, int maxlen_after, String &text, int &cursor)
2113 {
2114     if (!m_impl->socket_active.is_connected ())
2115         return;
2116
2117     if (!m_impl->ise_focus_flag) {
2118         if (m_impl->finalized_text) {
2119             String buffer = m_impl->finalized_text;
2120             cursor = m_impl->finalized_cursor_pos;
2121             int pos = cursor - maxlen_before;
2122             if (maxlen_before < 0) pos = 0;
2123             if (pos > (int)buffer.length()) pos = (int)buffer.length();
2124             if (pos < 0) pos = 0;
2125             size_t len = maxlen_after + (cursor - pos);
2126             if (maxlen_after < 0) len = String::npos;
2127             text = buffer.substr (pos, len);
2128         } else {
2129             text.clear ();
2130             cursor = 0;
2131         }
2132     } else {
2133         m_impl->send.clear();
2134         m_impl->send.put_command(SCIM_TRANS_CMD_REQUEST);
2135         m_impl->send.put_data(m_impl->magic_active);
2136         m_impl->send.put_command(SCIM_TRANS_CMD_GET_SURROUNDING_TEXT);
2137         m_impl->send.put_data("");
2138         m_impl->send.put_data(maxlen_before);
2139         m_impl->send.put_data(maxlen_after);
2140         m_impl->send.write_to_socket(m_impl->socket_active, m_impl->magic_active);
2141         if (m_impl->surrounding_text) {
2142             free(m_impl->surrounding_text);
2143             m_impl->surrounding_text = NULL;
2144         }
2145
2146         const int WAIT_FOR_SYNC_RESPONSE_TIMEOUT = 1000;
2147         /* Now we are waiting for the ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT message */
2148         if (wait_for_message(ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT, WAIT_FOR_SYNC_RESPONSE_TIMEOUT)) {
2149             MessageItem *message = message_queue.get_pending_message_by_cmd(ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT);
2150             handle_message(message);
2151             message_queue.remove_message(message);
2152
2153             if (m_impl->surrounding_text) {
2154                 text = m_impl->surrounding_text;
2155                 cursor = m_impl->cursor_pos;
2156             }
2157         }
2158
2159         if (m_impl->surrounding_text) {
2160             free(m_impl->surrounding_text);
2161             m_impl->surrounding_text = NULL;
2162         }
2163
2164         LOGD("message_queue size : %d", message_queue.get_message_size());
2165
2166         m_impl->send.clear ();
2167         m_impl->send.put_command(SCIM_TRANS_CMD_REQUEST);
2168         m_impl->send.put_data(m_impl->magic_active);
2169         m_impl->send.put_command(SCIM_TRANS_CMD_PING);
2170         m_impl->send.write_to_socket(m_impl->socket_active, m_impl->magic_active);
2171     }
2172 }
2173
2174 /**
2175  * @brief Request to delete surrounding text.
2176  *
2177  * @param offset The offset for cursor position.
2178  * @param len The length for delete text.
2179  */
2180 void
2181 HelperAgent::delete_surrounding_text (int offset, int len) const
2182 {
2183     LOGD ("offset = %d, len = %d", offset, len);
2184
2185     if (m_impl->socket_active.is_connected ()) {
2186         m_impl->send.clear ();
2187         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2188         m_impl->send.put_data (m_impl->magic_active);
2189         m_impl->send.put_command (SCIM_TRANS_CMD_DELETE_SURROUNDING_TEXT);
2190         m_impl->send.put_data (offset);
2191         m_impl->send.put_data (len);
2192         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2193     }
2194 }
2195
2196 /**
2197  * @brief Request to get selection text asynchronously.
2198  *
2199  * @param uuid The helper ISE UUID.
2200  */
2201 void
2202 HelperAgent::get_selection (const String &uuid) const
2203 {
2204     if (m_impl->socket_active.is_connected () && (m_impl->need_update_selection_text == 0)) {
2205         m_impl->send.clear ();
2206         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2207         m_impl->send.put_data (m_impl->magic_active);
2208         m_impl->send.put_command (SCIM_TRANS_CMD_GET_SELECTION);
2209         m_impl->send.put_data (uuid);
2210         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2211     }
2212     m_impl->need_update_selection_text++;
2213 }
2214
2215 /**
2216  * @brief Request to get selection text synchronously.
2217  *
2218  * @param text The selection text.
2219  */
2220 void
2221 HelperAgent::get_selection_text (String &text)
2222 {
2223
2224     if (!m_impl->socket_active.is_connected ())
2225         return;
2226
2227     m_impl->send.clear ();
2228     m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2229     m_impl->send.put_data (m_impl->magic_active);
2230     m_impl->send.put_command (SCIM_TRANS_CMD_GET_SELECTION);
2231     m_impl->send.put_data ("");
2232     m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2233     if (m_impl->selection_text) {
2234         free (m_impl->selection_text);
2235         m_impl->selection_text = NULL;
2236     }
2237
2238     const int WAIT_FOR_SYNC_RESPONSE_TIMEOUT = 1000;
2239     /* Now we are waiting for the ISM_TRANS_CMD_UPDATE_SELECTION message */
2240     if (wait_for_message(ISM_TRANS_CMD_UPDATE_SELECTION, WAIT_FOR_SYNC_RESPONSE_TIMEOUT)) {
2241         MessageItem *message = message_queue.get_pending_message_by_cmd(ISM_TRANS_CMD_UPDATE_SELECTION);
2242         handle_message(message);
2243         message_queue.remove_message(message);
2244         if (m_impl->selection_text) {
2245             text = m_impl->selection_text;
2246         }
2247     }
2248
2249     if (m_impl->selection_text) {
2250         free (m_impl->selection_text);
2251         m_impl->selection_text = NULL;
2252     }
2253
2254     LOGD("message_queue size : %d", message_queue.get_message_size());
2255
2256     m_impl->send.clear ();
2257     m_impl->send.put_command(SCIM_TRANS_CMD_REQUEST);
2258     m_impl->send.put_data(m_impl->magic_active);
2259     m_impl->send.put_command(SCIM_TRANS_CMD_PING);
2260     m_impl->send.write_to_socket(m_impl->socket_active, m_impl->magic_active);
2261 }
2262
2263 /**
2264  * @brief Request to select text.
2265  *
2266  * @param start The start position in text.
2267  * @param end The end position in text.
2268  */
2269 void
2270 HelperAgent::set_selection (int start, int end) const
2271 {
2272     if (m_impl->socket_active.is_connected ()) {
2273         m_impl->send.clear ();
2274         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2275         m_impl->send.put_data (m_impl->magic_active);
2276         m_impl->send.put_command (SCIM_TRANS_CMD_SET_SELECTION);
2277         m_impl->send.put_data (start);
2278         m_impl->send.put_data (end);
2279         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2280     }
2281 }
2282
2283 /**
2284  * @brief Send a private command to an application.
2285  *
2286  * @param command The private command sent from IME.
2287  */
2288 void
2289 HelperAgent::send_private_command (const String &command) const
2290 {
2291     if (m_impl->socket_active.is_connected ()) {
2292         m_impl->send.clear ();
2293         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2294         m_impl->send.put_data (m_impl->magic_active);
2295         m_impl->send.put_command (SCIM_TRANS_CMD_SEND_PRIVATE_COMMAND);
2296         m_impl->send.put_data (command);
2297         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2298     }
2299 }
2300
2301 /**
2302  * @brief Commit content to an application.
2303  *
2304  * @param content The content sent from IME.
2305  */
2306 void
2307 HelperAgent::commit_content (const String &content, const String &description, const String &mime_types) const
2308 {
2309     LOGD ("");
2310     if (m_impl->socket_active.is_connected ()) {
2311         m_impl->send.clear ();
2312         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2313         m_impl->send.put_data (m_impl->magic_active);
2314         m_impl->send.put_command (SCIM_TRANS_CMD_COMMIT_CONTENT);
2315         m_impl->send.put_data (content);
2316         m_impl->send.put_data (description);
2317         m_impl->send.put_data (mime_types);
2318         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2319     }
2320 }
2321
2322 /**
2323  * @brief Request to get uuid list of all keyboard ISEs.
2324  *
2325  * @param uuid The helper ISE UUID.
2326  */
2327 void
2328 HelperAgent::get_keyboard_ise_list (const String &uuid) const
2329 {
2330     if (m_impl->socket_active.is_connected ()) {
2331         m_impl->send.clear ();
2332         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2333         m_impl->send.put_data (m_impl->magic_active);
2334         m_impl->send.put_command (ISM_TRANS_CMD_GET_KEYBOARD_ISE_LIST);
2335         m_impl->send.put_data (uuid);
2336         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2337     }
2338 }
2339
2340 /**
2341  * @brief Set candidate position in screen.
2342  *
2343  * @param left The x position in screen.
2344  * @param top The y position in screen.
2345  */
2346 void
2347 HelperAgent::set_candidate_position (int left, int top) const
2348 {
2349     if (m_impl->socket_active.is_connected ()) {
2350         m_impl->send.clear ();
2351         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2352         m_impl->send.put_data (m_impl->magic_active);
2353         m_impl->send.put_command (ISM_TRANS_CMD_SET_CANDIDATE_POSITION);
2354         m_impl->send.put_data (left);
2355         m_impl->send.put_data (top);
2356         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2357     }
2358 }
2359
2360 /**
2361  * @brief Set candidate style.
2362  *
2363  * @param portrait_line - the displayed line number for portrait mode.
2364  * @param mode          - candidate window mode.
2365  */
2366 void
2367 HelperAgent::set_candidate_style (ISF_CANDIDATE_PORTRAIT_LINE_T portrait_line,
2368                                   ISF_CANDIDATE_MODE_T          mode) const
2369 {
2370     if (m_impl->socket_active.is_connected ()) {
2371         m_impl->send.clear ();
2372         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2373         m_impl->send.put_data (m_impl->magic_active);
2374         m_impl->send.put_command (ISM_TRANS_CMD_SET_CANDIDATE_UI);
2375         m_impl->send.put_data (portrait_line);
2376         m_impl->send.put_data (mode);
2377         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2378     }
2379 }
2380
2381 /**
2382  * @brief Request to hide candidate window.
2383  */
2384 void
2385 HelperAgent::candidate_hide (void) const
2386 {
2387     if (m_impl->socket_active.is_connected ()) {
2388         m_impl->send.clear ();
2389         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2390         m_impl->send.put_data (m_impl->magic_active);
2391         m_impl->send.put_command (ISM_TRANS_CMD_HIDE_CANDIDATE);
2392         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2393     }
2394 }
2395
2396 /**
2397  * @brief Request to get candidate window size and position.
2398  *
2399  * @param uuid The helper ISE UUID.
2400  */
2401 void
2402 HelperAgent::get_candidate_window_geometry (const String &uuid) const
2403 {
2404     if (m_impl->socket_active.is_connected ()) {
2405         m_impl->send.clear ();
2406         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2407         m_impl->send.put_data (m_impl->magic_active);
2408         m_impl->send.put_command (ISM_TRANS_CMD_GET_CANDIDATE_GEOMETRY);
2409         m_impl->send.put_data (uuid);
2410         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2411     }
2412 }
2413
2414 /**
2415  * @brief Set current keyboard ISE.
2416  *
2417  * @param uuid The keyboard ISE UUID.
2418  */
2419 void
2420 HelperAgent::set_keyboard_ise_by_uuid (const String &uuid) const
2421 {
2422     ImeInfoDB imeInfo;
2423     IMEngineFactoryPointer factory;
2424     IMEngineModule *engine_module = NULL;
2425     static int instance_count = 1;
2426
2427     if ((!m_impl->si.null ()) && m_impl->si->get_factory_uuid () == uuid) {
2428         ISF_SAVE_LOG ("Already in UUID: %s", uuid.c_str());
2429         return;
2430     }
2431
2432     if (!m_impl->si.null()) {
2433         m_impl->si->focus_out();
2434         m_impl->si.reset();
2435     }
2436
2437     if (m_impl->m_config.null ()) {
2438         ISF_SAVE_LOG ("config is not working");
2439         return;
2440     }
2441
2442 #ifdef HAVE_PKGMGR_INFO
2443     int ret = 0;
2444     char *pkgid = NULL;
2445     pkgmgrinfo_appinfo_h handle;
2446     ret = pkgmgrinfo_appinfo_get_appinfo(uuid.c_str(), &handle);
2447     if (ret != PMINFO_R_OK) {
2448         ISF_SAVE_LOG ("Retrieve app info failed : %s", uuid.c_str ());
2449         return;
2450     }
2451
2452     ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
2453     if (ret != PMINFO_R_OK) {
2454         ISF_SAVE_LOG ("Retrieve pkgid failed : %s, %p", uuid.c_str(), handle);
2455         pkgmgrinfo_appinfo_destroy_appinfo(handle);
2456         return;
2457     }
2458
2459     imeInfo.module_name = pkgid;
2460     pkgmgrinfo_appinfo_destroy_appinfo(handle);
2461 #else
2462     if (isf_db_select_ime_info_by_appid(uuid.c_str(), &imeInfo) < 1) {
2463         ISF_SAVE_LOG ("ime_info row is not available for %s", uuid.c_str());
2464         return;
2465     }
2466 #endif
2467
2468     engine_module = &m_impl->engine_module;
2469
2470     if (engine_module->valid() && imeInfo.module_name != engine_module->get_module_name()) {
2471         ISF_SAVE_LOG ("imengine module %s unloaded", engine_module->get_module_name().c_str());
2472         engine_module->unload();
2473     }
2474
2475     if (!engine_module->valid()) {
2476         if (engine_module->load (imeInfo.module_name, m_impl->m_config) == false) {
2477             ISF_SAVE_LOG ("load module %s failed", imeInfo.module_name.c_str());
2478             return;
2479         }
2480         ISF_SAVE_LOG ("imengine module %s loaded", imeInfo.module_name.c_str());
2481     }
2482
2483     for (size_t j = 0; j < engine_module->number_of_factories (); ++j) {
2484         try {
2485             factory = engine_module->create_factory (j);
2486             if (factory.null () == false && factory->get_uuid () == uuid)
2487                 break;
2488         } catch (...) {
2489             factory.reset ();
2490             return;
2491         }
2492     }
2493
2494     if (factory.null()) {
2495         ISF_SAVE_LOG ("imengine uuid %s is not found", uuid.c_str());
2496         return;
2497     }
2498
2499     m_impl->si = factory->create_instance ("UTF-8", instance_count++);
2500     if (m_impl->si.null ()) {
2501         ISF_SAVE_LOG ("create_instance %s failed", uuid.c_str ());
2502         return;
2503     }
2504
2505     m_impl->attach_instance ();
2506     ISF_SAVE_LOG ("Require UUID: %s Current UUID: %s", uuid.c_str (), m_impl->si->get_factory_uuid ().c_str ());
2507     m_impl->si->set_layout (m_impl->layout);
2508     if (m_impl->focused_ic != (uint32)-1)
2509         m_impl->si->focus_in ();
2510 }
2511
2512 /**
2513  * @brief Request to get current keyboard ISE information.
2514  *
2515  * @param uuid The helper ISE UUID.
2516  */
2517 void
2518 HelperAgent::get_keyboard_ise (const String &uuid) const
2519 {
2520     //FIXME: maybe useless
2521 #if 0
2522     if (m_impl->socket_active.is_connected ()) {
2523         m_impl->send.clear ();
2524         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2525         m_impl->send.put_data (m_impl->magic_active);
2526         m_impl->send.put_command (ISM_TRANS_CMD_GET_KEYBOARD_ISE);
2527         m_impl->send.put_data (uuid);
2528         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2529     }
2530 #endif
2531 }
2532
2533 /**
2534  * @brief Update ISE window geometry.
2535  *
2536  * @param x      The x position in screen.
2537  * @param y      The y position in screen.
2538  * @param width  The ISE window width.
2539  * @param height The ISE window height.
2540  */
2541 void
2542 HelperAgent::update_geometry (int x, int y, int width, int height) const
2543 {
2544     if (m_impl->socket_active.is_connected ()) {
2545         m_impl->send.clear ();
2546         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2547         m_impl->send.put_data (m_impl->magic_active);
2548         m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ISE_GEOMETRY);
2549         m_impl->send.put_data (x);
2550         m_impl->send.put_data (y);
2551         m_impl->send.put_data (width);
2552         m_impl->send.put_data (height);
2553         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2554     }
2555 }
2556
2557 /**
2558  * @brief Request to expand candidate window.
2559  */
2560 void
2561 HelperAgent::expand_candidate (void) const
2562 {
2563     if (m_impl->socket_active.is_connected ()) {
2564         m_impl->send.clear ();
2565         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2566         m_impl->send.put_data (m_impl->magic_active);
2567         m_impl->send.put_command (ISM_TRANS_CMD_EXPAND_CANDIDATE);
2568         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2569     }
2570 }
2571
2572 /**
2573  * @brief Request to contract candidate window.
2574  */
2575 void
2576 HelperAgent::contract_candidate (void) const
2577 {
2578     if (m_impl->socket_active.is_connected ()) {
2579         m_impl->send.clear ();
2580         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2581         m_impl->send.put_data (m_impl->magic_active);
2582         m_impl->send.put_command (ISM_TRANS_CMD_CONTRACT_CANDIDATE);
2583         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2584     }
2585 }
2586
2587 /**
2588  * @brief Send selected candidate string index number.
2589  */
2590 void
2591 HelperAgent::select_candidate (int index) const
2592 {
2593     if (!m_impl->si.null ())
2594         m_impl->si->select_candidate (index);
2595     //FIXME: maybe useless
2596 #if 0
2597
2598     if (m_impl->socket_active.is_connected ()) {
2599         m_impl->send.clear ();
2600         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2601         m_impl->send.put_data (m_impl->magic_active);
2602         m_impl->send.put_command (ISM_TRANS_CMD_SELECT_CANDIDATE);
2603         m_impl->send.put_data (index);
2604         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2605     }
2606 #endif
2607 }
2608
2609 /**
2610  * @brief Update our ISE is exiting.
2611  *
2612  * The IME must call this function before terminating IME itself in On-demand mode.
2613  * If this function isn't called, IME will automatically restart.
2614  * This function only works in On-demand mode.
2615  *
2616  */
2617 void
2618 HelperAgent::update_ise_exit (void) const
2619 {
2620     if (m_impl->socket_active.is_connected ()) {
2621         m_impl->send.clear ();
2622         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2623         m_impl->send.put_data (m_impl->magic_active);
2624         m_impl->send.put_command (ISM_TRANS_CMD_UPDATE_ISE_EXIT);
2625         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2626
2627         // The update_ise_exit must be delivered before del_client of isf_info_manager was called.
2628         sync();
2629     }
2630 }
2631
2632 /**
2633  * @brief Request to reset keyboard ISE.
2634  */
2635 void
2636 HelperAgent::reset_keyboard_ise (void) const
2637 {
2638 //FIXME: maybe useless
2639 #if 0
2640     if (m_impl->socket_active.is_connected ()) {
2641         m_impl->send.clear ();
2642         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2643         m_impl->send.put_data (m_impl->magic_active);
2644         m_impl->send.put_command (ISM_TRANS_CMD_PANEL_RESET_KEYBOARD_ISE);
2645         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2646     }
2647 #endif
2648     if (!m_impl->si.null ()) {
2649         m_impl->si->reset ();
2650     }
2651 }
2652
2653 /**
2654  * @brief Request to flush keyboard ISE.
2655  */
2656 void
2657 HelperAgent::flush_keyboard_ise (void) const
2658 {
2659     if (!m_impl->si.null ()) {
2660         m_impl->si->flush ();
2661     }
2662 }
2663
2664 /**
2665  * @brief Request panel to hide ISE.
2666  */
2667 void
2668 HelperAgent::request_ise_hide (void) const
2669 {
2670     if (m_impl->socket_active.is_connected ()) {
2671         m_impl->send.clear ();
2672         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2673         m_impl->send.put_data (m_impl->magic_active);
2674         m_impl->send.put_command (ISM_TRANS_CMD_REQUEST_ISE_HIDE);
2675         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2676     }
2677 }
2678
2679 /**
2680  * @brief Recapture
2681  */
2682 void
2683 HelperAgent::recapture_string (int                  ic,
2684                                const String        &ic_uuid,
2685                                int                  offset,
2686                                int                  len,
2687                                const WideString    &preedit_str,
2688                                const WideString    &commit_str,
2689                                const AttributeList &attrs) const
2690 {
2691     LOGD ("offset = %d, len = %d", offset, len);
2692
2693     if (m_impl->socket_active.is_connected ()) {
2694         m_impl->send.clear ();
2695         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
2696         m_impl->send.put_data (m_impl->magic_active);
2697         m_impl->send.put_command (ISM_TRANS_CMD_RECAPTURE_STRING);
2698
2699         m_impl->send.put_data ((uint32)ic);
2700         m_impl->send.put_data (ic_uuid);
2701
2702         // Deleting surrounding text
2703         m_impl->send.put_data (offset);
2704         m_impl->send.put_data (len);
2705
2706         // Update preedit text
2707         m_impl->send.put_data (preedit_str);
2708
2709         // Commit
2710         m_impl->send.put_data (commit_str);
2711
2712         // preedit attributes
2713         m_impl->send.put_data (attrs);
2714
2715         m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
2716     }
2717 }
2718
2719 /**
2720  * @brief Connect a slot to Helper exit signal.
2721  *
2722  * This signal is used to let the Helper exit.
2723  *
2724  * The prototype of the slot is:
2725  *
2726  * void exit (const HelperAgent *agent, int ic, const String &ic_uuid);
2727  *
2728  * Parameters:
2729  * - agent    The pointer to the HelperAgent object which emits this signal.
2730  * - ic       An opaque handle of the currently focused input context.
2731  * - ic_uuid  The UUID of the IMEngineInstance associated with the focused input context.
2732  */
2733 Connection
2734 HelperAgent::signal_connect_exit (HelperAgentSlotVoid *slot)
2735 {
2736     return m_impl->signal_exit.connect (slot);
2737 }
2738
2739 /**
2740  * @brief Connect a slot to Helper attach input context signal.
2741  *
2742  * This signal is used to attach an input context to this helper.
2743  *
2744  * When an input context requst to start this helper, then this
2745  * signal will be emitted as soon as the helper is started.
2746  *
2747  * When an input context want to start an already started helper,
2748  * this signal will also be emitted.
2749  *
2750  * Helper can send some events back to the IMEngineInstance in this
2751  * signal-slot, to inform that it has been started sccessfully.
2752  *
2753  * The prototype of the slot is:
2754  *
2755  * void attach_input_context (const HelperAgent *agent, int ic, const String &ic_uuid);
2756  */
2757 Connection
2758 HelperAgent::signal_connect_attach_input_context (HelperAgentSlotVoid *slot)
2759 {
2760     return m_impl->signal_attach_input_context.connect (slot);
2761 }
2762
2763 /**
2764  * @brief Connect a slot to Helper detach input context signal.
2765  *
2766  * This signal is used to detach an input context from this helper.
2767  *
2768  * When an input context requst to stop this helper, then this
2769  * signal will be emitted.
2770  *
2771  * Helper shouldn't send any event back to the IMEngineInstance, because
2772  * the IMEngineInstance attached to the ic should have been destroyed.
2773  *
2774  * The prototype of the slot is:
2775  *
2776  * void detach_input_context (const HelperAgent *agent, int ic, const String &ic_uuid);
2777  */
2778 Connection
2779 HelperAgent::signal_connect_detach_input_context (HelperAgentSlotVoid *slot)
2780 {
2781     return m_impl->signal_detach_input_context.connect (slot);
2782 }
2783
2784 /**
2785  * @brief Connect a slot to Helper reload config signal.
2786  *
2787  * This signal is used to let the Helper reload configuration.
2788  *
2789  * The prototype of the slot is:
2790  *
2791  * void reload_config (const HelperAgent *agent, int ic, const String &ic_uuid);
2792  */
2793 Connection
2794 HelperAgent::signal_connect_reload_config (HelperAgentSlotVoid *slot)
2795 {
2796     return m_impl->signal_reload_config.connect (slot);
2797 }
2798
2799 /**
2800  * @brief Connect a slot to Helper update screen signal.
2801  *
2802  * This signal is used to let the Helper move its GUI to another screen.
2803  * It can only be emitted when SCIM_HELPER_NEED_SCREEN_INFO is set in HelperInfo.option.
2804  *
2805  * The prototype of the slot is:
2806  *
2807  * void update_screen (const HelperAgent *agent, int ic, const String &ic_uuid, int screen_number);
2808  */
2809 Connection
2810 HelperAgent::signal_connect_update_screen (HelperAgentSlotInt *slot)
2811 {
2812     return m_impl->signal_update_screen.connect (slot);
2813 }
2814
2815 /**
2816  * @brief Connect a slot to Helper update spot location signal.
2817  *
2818  * This signal is used to let the Helper move its GUI according to the current spot location.
2819  * It can only be emitted when SCIM_HELPER_NEED_SPOT_LOCATION_INFO is set in HelperInfo.option.
2820  *
2821  * The prototype of the slot is:
2822  * void update_spot_location (const HelperAgent *agent, int ic, const String &ic_uuid, int x, int y);
2823  */
2824 Connection
2825 HelperAgent::signal_connect_update_spot_location (HelperAgentSlotIntInt *slot)
2826 {
2827     return m_impl->signal_update_spot_location.connect (slot);
2828 }
2829
2830 /**
2831  * @brief Connect a slot to Helper update cursor position signal.
2832  *
2833  * This signal is used to let the Helper get the cursor position information.
2834  *
2835  * The prototype of the slot is:
2836  * void update_cursor_position (const HelperAgent *agent, int ic, const String &ic_uuid, int cursor_pos);
2837  */
2838 Connection
2839 HelperAgent::signal_connect_update_cursor_position (HelperAgentSlotInt *slot)
2840 {
2841     return m_impl->signal_update_cursor_position.connect (slot);
2842 }
2843
2844 /**
2845  * @brief Connect a slot to Helper update surrounding text signal.
2846  *
2847  * This signal is used to let the Helper get the surrounding text.
2848  *
2849  * The prototype of the slot is:
2850  * void update_surrounding_text (const HelperAgent *agent, int ic, const String &text, int cursor);
2851  */
2852 Connection
2853 HelperAgent::signal_connect_update_surrounding_text (HelperAgentSlotInt *slot)
2854 {
2855     return m_impl->signal_update_surrounding_text.connect (slot);
2856 }
2857
2858 /**
2859  * @brief Connect a slot to Helper update selection signal.
2860  *
2861  * This signal is used to let the Helper get the selection.
2862  *
2863  * The prototype of the slot is:
2864  * void update_selection (const HelperAgent *agent, int ic, const String &text);
2865  */
2866 Connection
2867 HelperAgent::signal_connect_update_selection (HelperAgentSlotVoid *slot)
2868 {
2869     return m_impl->signal_update_selection.connect (slot);
2870 }
2871
2872 /**
2873  * @brief Connect a slot to Helper trigger property signal.
2874  *
2875  * This signal is used to trigger a property registered by this Helper.
2876  * A property will be triggered when user clicks on it.
2877  *
2878  * The prototype of the slot is:
2879  * void trigger_property (const HelperAgent *agent, int ic, const String &ic_uuid, const String &property);
2880  */
2881 Connection
2882 HelperAgent::signal_connect_trigger_property (HelperAgentSlotString *slot)
2883 {
2884     return m_impl->signal_trigger_property.connect (slot);
2885 }
2886
2887 /**
2888  * @brief Connect a slot to Helper process imengine event signal.
2889  *
2890  * This signal is used to deliver the events sent from IMEngine to Helper.
2891  *
2892  * The prototype of the slot is:
2893  * void process_imengine_event (const HelperAgent *agent, int ic, const String &ic_uuid, const Transaction &transaction);
2894  */
2895 Connection
2896 HelperAgent::signal_connect_process_imengine_event (HelperAgentSlotTransaction *slot)
2897 {
2898     return m_impl->signal_process_imengine_event.connect (slot);
2899 }
2900
2901 /**
2902  * @brief Connect a slot to Helper focus out signal.
2903  *
2904  * This signal is used to do something when input context is focus out.
2905  *
2906  * The prototype of the slot is:
2907  * void focus_out (const HelperAgent *agent, int ic, const String &ic_uuid);
2908  */
2909 Connection
2910 HelperAgent::signal_connect_focus_out (HelperAgentSlotVoid *slot)
2911 {
2912     return m_impl->signal_focus_out.connect (slot);
2913 }
2914
2915 /**
2916  * @brief Connect a slot to Helper focus in signal.
2917  *
2918  * This signal is used to do something when input context is focus in.
2919  *
2920  * The prototype of the slot is:
2921  * void focus_in (const HelperAgent *agent, int ic, const String &ic_uuid);
2922  */
2923 Connection
2924 HelperAgent::signal_connect_focus_in (HelperAgentSlotVoid *slot)
2925 {
2926     return m_impl->signal_focus_in.connect (slot);
2927 }
2928
2929 /**
2930  * @brief Connect a slot to Helper show signal.
2931  *
2932  * This signal is used to show Helper ISE window.
2933  *
2934  * The prototype of the slot is:
2935  * void ise_show (const HelperAgent *agent, int ic, char *buf, size_t &len);
2936  */
2937 Connection
2938 HelperAgent::signal_connect_ise_show (HelperAgentSlotIntRawVoid *slot)
2939 {
2940     return m_impl->signal_ise_show.connect (slot);
2941 }
2942
2943 /**
2944  * @brief Connect a slot to Helper hide signal.
2945  *
2946  * This signal is used to hide Helper ISE window.
2947  *
2948  * The prototype of the slot is:
2949  * void ise_hide (const HelperAgent *agent, int ic, const String &ic_uuid);
2950  */
2951 Connection
2952 HelperAgent::signal_connect_ise_hide (HelperAgentSlotVoid *slot)
2953 {
2954     return m_impl->signal_ise_hide.connect (slot);
2955 }
2956
2957 /**
2958  * @brief Connect a slot to Helper get ISE window geometry signal.
2959  *
2960  * This signal is used to get Helper ISE window size and position.
2961  *
2962  * The prototype of the slot is:
2963  * void get_geometry (const HelperAgent *agent, struct rectinfo &info);
2964  */
2965 Connection
2966 HelperAgent::signal_connect_get_geometry (HelperAgentSlotSize *slot)
2967 {
2968     return m_impl->signal_get_geometry.connect (slot);
2969 }
2970
2971 /**
2972  * @brief Connect a slot to Helper set mode signal.
2973  *
2974  * This signal is used to set Helper ISE mode.
2975  *
2976  * The prototype of the slot is:
2977  * void set_mode (const HelperAgent *agent, uint32 &mode);
2978  */
2979 Connection
2980 HelperAgent::signal_connect_set_mode (HelperAgentSlotUintVoid *slot)
2981 {
2982     return m_impl->signal_set_mode.connect (slot);
2983 }
2984
2985 /**
2986  * @brief Connect a slot to Helper set language signal.
2987  *
2988  * This signal is used to set Helper ISE language.
2989  *
2990  * The prototype of the slot is:
2991  * void set_language (const HelperAgent *agent, uint32 &language);
2992  */
2993 Connection
2994 HelperAgent::signal_connect_set_language (HelperAgentSlotUintVoid *slot)
2995 {
2996     return m_impl->signal_set_language.connect (slot);
2997 }
2998
2999 /**
3000  * @brief Connect a slot to Helper set im data signal.
3001  *
3002  * This signal is used to send im data to Helper ISE.
3003  *
3004  * The prototype of the slot is:
3005  * void set_imdata (const HelperAgent *agent, char *buf, size_t &len);
3006  */
3007 Connection
3008 HelperAgent::signal_connect_set_imdata (HelperAgentSlotRawVoid *slot)
3009 {
3010     return m_impl->signal_set_imdata.connect (slot);
3011 }
3012
3013 /**
3014  * @brief Connect a slot to Helper get im data signal.
3015  *
3016  * This signal is used to get im data from Helper ISE.
3017  *
3018  * The prototype of the slot is:
3019  * void get_imdata (const HelperAgent *, char **buf, size_t &len);
3020  */
3021 Connection
3022 HelperAgent::signal_connect_get_imdata (HelperAgentSlotGetRawVoid *slot)
3023 {
3024     return m_impl->signal_get_imdata.connect (slot);
3025 }
3026
3027 /**
3028  * @brief Connect a slot to Helper get language locale signal.
3029  *
3030  * This signal is used to get language locale from Helper ISE.
3031  *
3032  * The prototype of the slot is:
3033  * void get_language_locale (const HelperAgent *, int ic, char **locale);
3034  */
3035 Connection
3036 HelperAgent::signal_connect_get_language_locale (HelperAgentSlotIntGetStringVoid *slot)
3037 {
3038     return m_impl->signal_get_language_locale.connect (slot);
3039 }
3040
3041 /**
3042  * @brief Connect a slot to Helper set return key type signal.
3043  *
3044  * This signal is used to send return key type to Helper ISE.
3045  *
3046  * The prototype of the slot is:
3047  * void set_return_key_type (const HelperAgent *agent, uint32 &type);
3048  */
3049 Connection
3050 HelperAgent::signal_connect_set_return_key_type (HelperAgentSlotUintVoid *slot)
3051 {
3052     return m_impl->signal_set_return_key_type.connect (slot);
3053 }
3054
3055 /**
3056  * @brief Connect a slot to Helper get return key type signal.
3057  *
3058  * This signal is used to get return key type from Helper ISE.
3059  *
3060  * The prototype of the slot is:
3061  * void get_return_key_type (const HelperAgent *agent, uint32 &type);
3062  */
3063 Connection
3064 HelperAgent::signal_connect_get_return_key_type (HelperAgentSlotUintVoid *slot)
3065 {
3066     return m_impl->signal_get_return_key_type.connect (slot);
3067 }
3068
3069 /**
3070  * @brief Connect a slot to Helper set return key disable signal.
3071  *
3072  * This signal is used to send return key disable to Helper ISE.
3073  *
3074  * The prototype of the slot is:
3075  * void set_return_key_disable (const HelperAgent *agent, uint32 &disabled);
3076  */
3077 Connection
3078 HelperAgent::signal_connect_set_return_key_disable (HelperAgentSlotUintVoid *slot)
3079 {
3080     return m_impl->signal_set_return_key_disable.connect (slot);
3081 }
3082
3083 /**
3084  * @brief Connect a slot to Helper process key event signal.
3085  *
3086  * This signal is used to send keyboard key event to Helper ISE.
3087  *
3088  * The prototype of the slot is:
3089  * void process_key_event (const HelperAgent *agent, KeyEvent &key, uint32 &ret);
3090  */
3091 Connection
3092 HelperAgent::signal_connect_process_key_event (HelperAgentSlotKeyEventUint *slot)
3093 {
3094     return m_impl->signal_process_key_event.connect (slot);
3095 }
3096
3097 /**
3098  * @brief Connect a slot to Helper process key event with keycode signal.
3099  *
3100  * This signal is used to send keyboard key event with keycode to Helper ISE.
3101  *
3102  * The prototype of the slot is:
3103  * void process_key_event_with_keycode (const HelperAgent *agent, KeyEvent &key, uint32 &ret, uint32 keycode);
3104  */
3105 Connection
3106 HelperAgent::signal_connect_process_key_event_with_keycode (HelperAgentSlotKeyEventUintUint *slot)
3107 {
3108     return m_impl->signal_process_key_event_with_keycode.connect (slot);
3109 }
3110
3111 /**
3112  * @brief Connect a slot to Helper get return key disable signal.
3113  *
3114  * This signal is used to get return key disable from Helper ISE.
3115  *
3116  * The prototype of the slot is:
3117  * void get_return_key_disable (const HelperAgent *agent, uint32 &disabled);
3118  */
3119 Connection
3120 HelperAgent::signal_connect_get_return_key_disable (HelperAgentSlotUintVoid *slot)
3121 {
3122     return m_impl->signal_get_return_key_disable.connect (slot);
3123 }
3124
3125 /**
3126  * @brief Connect a slot to Helper set layout signal.
3127  *
3128  * This signal is used to set Helper ISE layout.
3129  *
3130  * The prototype of the slot is:
3131  * void set_layout (const HelperAgent *agent, uint32 &layout);
3132  */
3133 Connection
3134 HelperAgent::signal_connect_set_layout (HelperAgentSlotUintVoid *slot)
3135 {
3136     return m_impl->signal_set_layout.connect (slot);
3137 }
3138
3139 /**
3140  * @brief Connect a slot to Helper get layout signal.
3141  *
3142  * This signal is used to get Helper ISE layout.
3143  *
3144  * The prototype of the slot is:
3145  * void get_layout (const HelperAgent *agent, uint32 &layout);
3146  */
3147 Connection
3148 HelperAgent::signal_connect_get_layout (HelperAgentSlotUintVoid *slot)
3149 {
3150     return m_impl->signal_get_layout.connect (slot);
3151 }
3152
3153 /**
3154  * @brief Connect a slot to Helper set input mode signal.
3155  *
3156  * This signal is used to set Helper ISE input mode.
3157  *
3158  * The prototype of the slot is:
3159  * void set_input_mode (const HelperAgent *agent, uint32 &input_mode);
3160  */
3161 Connection
3162 HelperAgent::signal_connect_set_input_mode (HelperAgentSlotUintVoid *slot)
3163 {
3164     return m_impl->signal_set_input_mode.connect (slot);
3165 }
3166
3167 /**
3168  * @brief Connect a slot to Helper set input hint signal.
3169  *
3170  * This signal is used to set Helper ISE input hint.
3171  *
3172  * The prototype of the slot is:
3173  * void set_input_hint (const HelperAgent *agent, uint32 &input_hint);
3174  */
3175 Connection
3176 HelperAgent::signal_connect_set_input_hint (HelperAgentSlotUintVoid *slot)
3177 {
3178     return m_impl->signal_set_input_hint.connect (slot);
3179 }
3180
3181 /**
3182  * @brief Connect a slot to Helper set BiDi direction signal.
3183  *
3184  * This signal is used to set Helper ISE BiDi direction.
3185  *
3186  * The prototype of the slot is:
3187  * void update_bidi_direction (const HelperAgent *agent, uint32 &bidi_direction);
3188  */
3189 Connection
3190 HelperAgent::signal_connect_update_bidi_direction (HelperAgentSlotUintVoid *slot)
3191 {
3192     return m_impl->signal_update_bidi_direction.connect (slot);
3193 }
3194
3195 /**
3196  * @brief Connect a slot to Helper set shift mode signal.
3197  *
3198  * This signal is used to set Helper shift mode.
3199  *
3200  * The prototype of the slot is:
3201  * void set_caps_mode (const HelperAgent *agent, uint32 &mode);
3202  */
3203 Connection
3204 HelperAgent::signal_connect_set_caps_mode (HelperAgentSlotUintVoid *slot)
3205 {
3206     return m_impl->signal_set_caps_mode.connect (slot);
3207 }
3208
3209 /**
3210  * @brief Connect a slot to Helper reset input context signal.
3211  *
3212  * This signal is used to reset Helper ISE input context.
3213  *
3214  * The prototype of the slot is:
3215  * void reset_input_context (const HelperAgent *agent, int ic, const String &uuid);
3216  */
3217 Connection
3218 HelperAgent::signal_connect_reset_input_context (HelperAgentSlotVoid *slot)
3219 {
3220     return m_impl->signal_reset_input_context.connect (slot);
3221 }
3222
3223 /**
3224  * @brief Connect a slot to Helper update candidate window geometry signal.
3225  *
3226  * This signal is used to get candidate window size and position.
3227  *
3228  * The prototype of the slot is:
3229  * void update_candidate_geometry (const HelperAgent *agent, int ic, const String &uuid, const rectinfo &info);
3230  */
3231 Connection
3232 HelperAgent::signal_connect_update_candidate_geometry (HelperAgentSlotRect *slot)
3233 {
3234     return m_impl->signal_update_candidate_geometry.connect (slot);
3235 }
3236
3237 /**
3238  * @brief Connect a slot to Helper update keyboard ISE signal.
3239  *
3240  * This signal is used to get current keyboard ISE name and uuid.
3241  *
3242  * The prototype of the slot is:
3243  * void update_keyboard_ise (const HelperAgent *agent, int ic, const String &uuid,
3244  *                           const String &ise_name, const String &ise_uuid);
3245  */
3246 Connection
3247 HelperAgent::signal_connect_update_keyboard_ise (HelperAgentSlotString2 *slot)
3248 {
3249     return m_impl->signal_update_keyboard_ise.connect (slot);
3250 }
3251
3252 /**
3253  * @brief Connect a slot to Helper update keyboard ISE list signal.
3254  *
3255  * This signal is used to get uuid list of all keyboard ISEs.
3256  *
3257  * The prototype of the slot is:
3258  * void update_keyboard_ise_list (const HelperAgent *agent, int ic, const String &uuid,
3259  *                                const std::vector<String> &ise_list);
3260  */
3261 Connection
3262 HelperAgent::signal_connect_update_keyboard_ise_list (HelperAgentSlotStringVector *slot)
3263 {
3264     return m_impl->signal_update_keyboard_ise_list.connect (slot);
3265 }
3266
3267 /**
3268  * @brief Connect a slot to Helper candidate more window show signal.
3269  *
3270  * This signal is used to do someting when candidate more window is showed.
3271  *
3272  * The prototype of the slot is:
3273  * void candidate_more_window_show (const HelperAgent *agent, int ic, const String &uuid);
3274  */
3275 Connection
3276 HelperAgent::signal_connect_candidate_more_window_show (HelperAgentSlotVoid *slot)
3277 {
3278     return m_impl->signal_candidate_more_window_show.connect (slot);
3279 }
3280
3281 /**
3282  * @brief Connect a slot to Helper candidate more window hide signal.
3283  *
3284  * This signal is used to do someting when candidate more window is hidden.
3285  *
3286  * The prototype of the slot is:
3287  * void candidate_more_window_hide (const HelperAgent *agent, int ic, const String &uuid);
3288  */
3289 Connection
3290 HelperAgent::signal_connect_candidate_more_window_hide (HelperAgentSlotVoid *slot)
3291 {
3292     return m_impl->signal_candidate_more_window_hide.connect (slot);
3293 }
3294
3295 /**
3296  * @brief Connect a slot to Helper candidate show signal.
3297  *
3298  * This signal is used to do candidate show.
3299  *
3300  * The prototype of the slot is:
3301  * void candidate_show (const HelperAgent *agent, int ic, const String &uuid);
3302  */
3303 Connection
3304 HelperAgent::signal_connect_candidate_show (HelperAgentSlotVoid *slot)
3305 {
3306     return m_impl->signal_candidate_show.connect (slot);
3307 }
3308
3309 /**
3310  * @brief Connect a slot to Helper candidate hide signal.
3311  *
3312  * This signal is used to do candidate hide.
3313  *
3314  * The prototype of the slot is:
3315  * void candidate_hide (const HelperAgent *agent, int ic, const String &uuid);
3316  */
3317 Connection
3318 HelperAgent::signal_connect_candidate_hide (HelperAgentSlotVoid *slot)
3319 {
3320     return m_impl->signal_candidate_hide.connect (slot);
3321 }
3322
3323 /**
3324  * @brief Connect a slot to Helper update lookup table signal.
3325  *
3326  * This signal is used to do someting when update lookup table.
3327  *
3328  * The prototype of the slot is:
3329  * void update_lookup_table (const HelperAgent *agent, int ic, const String &uuid ,LookupTable &table);
3330  */
3331 Connection
3332 HelperAgent::signal_connect_update_lookup_table (HelperAgentSlotLookupTable *slot)
3333 {
3334     return m_impl->signal_update_lookup_table.connect (slot);
3335 }
3336
3337 /**
3338  * @brief Connect a slot to Helper select aux signal.
3339  *
3340  * This signal is used to do something when aux is selected.
3341  *
3342  * The prototype of the slot is:
3343  * void select_aux (const HelperAgent *agent, int ic, const String &uuid, int index);
3344  */
3345 Connection
3346 HelperAgent::signal_connect_select_aux (HelperAgentSlotInt *slot)
3347 {
3348     return m_impl->signal_select_aux.connect (slot);
3349 }
3350
3351 /**
3352  * @brief Connect a slot to Helper select candidate signal.
3353  *
3354  * This signal is used to do something when candidate is selected.
3355  *
3356  * The prototype of the slot is:
3357  * void select_candidate (const HelperAgent *agent, int ic, const String &uuid, int index);
3358  */
3359 Connection
3360 HelperAgent::signal_connect_select_candidate (HelperAgentSlotInt *slot)
3361 {
3362     return m_impl->signal_select_candidate.connect (slot);
3363 }
3364
3365 /**
3366  * @brief Connect a slot to Helper candidate table page up signal.
3367  *
3368  * This signal is used to do something when candidate table is paged up.
3369  *
3370  * The prototype of the slot is:
3371  * void candidate_table_page_up (const HelperAgent *agent, int ic, const String &uuid);
3372  */
3373 Connection
3374 HelperAgent::signal_connect_candidate_table_page_up (HelperAgentSlotVoid *slot)
3375 {
3376     return m_impl->signal_candidate_table_page_up.connect (slot);
3377 }
3378
3379 /**
3380  * @brief Connect a slot to Helper candidate table page down signal.
3381  *
3382  * This signal is used to do something when candidate table is paged down.
3383  *
3384  * The prototype of the slot is:
3385  * void candidate_table_page_down (const HelperAgent *agent, int ic, const String &uuid);
3386  */
3387 Connection
3388 HelperAgent::signal_connect_candidate_table_page_down (HelperAgentSlotVoid *slot)
3389 {
3390     return m_impl->signal_candidate_table_page_down.connect (slot);
3391 }
3392
3393 /**
3394  * @brief Connect a slot to Helper update candidate table page size signal.
3395  *
3396  * This signal is used to do something when candidate table page size is changed.
3397  *
3398  * The prototype of the slot is:
3399  * void update_candidate_table_page_size (const HelperAgent *, int ic, const String &uuid, int page_size);
3400  */
3401 Connection
3402 HelperAgent::signal_connect_update_candidate_table_page_size (HelperAgentSlotInt *slot)
3403 {
3404     return m_impl->signal_update_candidate_table_page_size.connect (slot);
3405 }
3406
3407 /**
3408  * @brief Connect a slot to Helper update candidate item layout signal.
3409  *
3410  * The prototype of the slot is:
3411  * void update_candidate_item_layout (const HelperAgent *, const std::vector<uint32> &row_items);
3412  */
3413 Connection
3414 HelperAgent::signal_connect_update_candidate_item_layout (HelperAgentSlotUintVector *slot)
3415 {
3416     return m_impl->signal_update_candidate_item_layout.connect (slot);
3417 }
3418
3419 /**
3420  * @brief Connect a slot to Helper select associate signal.
3421  *
3422  * This signal is used to do something when associate is selected.
3423  *
3424  * The prototype of the slot is:
3425  * void select_associate (const HelperAgent *agent, int ic, const String &uuid, int index);
3426  */
3427 Connection
3428 HelperAgent::signal_connect_select_associate (HelperAgentSlotInt *slot)
3429 {
3430     return m_impl->signal_select_associate.connect (slot);
3431 }
3432
3433 /**
3434  * @brief Connect a slot to Helper associate table page up signal.
3435  *
3436  * This signal is used to do something when associate table is paged up.
3437  *
3438  * The prototype of the slot is:
3439  * void associate_table_page_up (const HelperAgent *agent, int ic, const String &uuid);
3440  */
3441 Connection
3442 HelperAgent::signal_connect_associate_table_page_up (HelperAgentSlotVoid *slot)
3443 {
3444     return m_impl->signal_associate_table_page_up.connect (slot);
3445 }
3446
3447 /**
3448  * @brief Connect a slot to Helper associate table page down signal.
3449  *
3450  * This signal is used to do something when associate table is paged down.
3451  *
3452  * The prototype of the slot is:
3453  * void associate_table_page_down (const HelperAgent *agent, int ic, const String &uuid);
3454  */
3455 Connection
3456 HelperAgent::signal_connect_associate_table_page_down (HelperAgentSlotVoid *slot)
3457 {
3458     return m_impl->signal_associate_table_page_down.connect (slot);
3459 }
3460
3461 /**
3462  * @brief Connect a slot to Helper update associate table page size signal.
3463  *
3464  * This signal is used to do something when associate table page size is changed.
3465  *
3466  * The prototype of the slot is:
3467  * void update_associate_table_page_size (const HelperAgent *, int ic, const String &uuid, int page_size);
3468  */
3469 Connection
3470 HelperAgent::signal_connect_update_associate_table_page_size (HelperAgentSlotInt *slot)
3471 {
3472     return m_impl->signal_update_associate_table_page_size.connect (slot);
3473 }
3474
3475 /**
3476  * @brief Connect a slot to Helper turn on log signal.
3477  *
3478  * This signal is used to turn on Helper ISE debug information.
3479  *
3480  * The prototype of the slot is:
3481  * void turn_on_log (const HelperAgent *agent, uint32 &on);
3482  */
3483 Connection
3484 HelperAgent::signal_connect_turn_on_log (HelperAgentSlotUintVoid *slot)
3485 {
3486     return m_impl->signal_turn_on_log.connect (slot);
3487 }
3488
3489 /**
3490  * @brief Connect a slot to Helper update displayed candidate number signal.
3491  *
3492  * This signal is used to inform helper ISE displayed candidate number.
3493  *
3494  * The prototype of the slot is:
3495  * void update_displayed_candidate_number (const HelperAgent *, int ic, const String &uuid, int number);
3496  */
3497 Connection
3498 HelperAgent::signal_connect_update_displayed_candidate_number (HelperAgentSlotInt *slot)
3499 {
3500     return m_impl->signal_update_displayed_candidate_number.connect (slot);
3501 }
3502
3503 /**
3504  * @brief Connect a slot to Helper longpress candidate signal.
3505  *
3506  * This signal is used to do something when candidate is longpress.
3507  *
3508  * The prototype of the slot is:
3509  * void longpress_candidate (const HelperAgent *agent, int ic, const String &uuid, int index);
3510  */
3511 Connection
3512 HelperAgent::signal_connect_longpress_candidate (HelperAgentSlotInt *slot)
3513 {
3514     return m_impl->signal_longpress_candidate.connect (slot);
3515 }
3516
3517 /**
3518  * @brief Connect a slot to Helper show option window.
3519  *
3520  * This signal is used to do request the ISE to show option window.
3521  *
3522  * The prototype of the slot is:
3523  * void show_option_window (const HelperAgent *agent, int ic, const String &uuid);
3524  */
3525 Connection
3526 HelperAgent::signal_connect_show_option_window (HelperAgentSlotVoid *slot)
3527 {
3528     return m_impl->signal_show_option_window.connect (slot);
3529 }
3530
3531 /**
3532  * @brief Connect a slot to Helper resume option window.
3533  *
3534  * This signal is used to do request the ISE to resume option window.
3535  *
3536  * The prototype of the slot is:
3537  * void resume_option_window (const HelperAgent *agent, int ic, const String &uuid);
3538  */
3539 Connection
3540 HelperAgent::signal_connect_resume_option_window (HelperAgentSlotVoid *slot)
3541 {
3542     return m_impl->signal_resume_option_window.connect (slot);
3543 }
3544
3545 /**
3546  * @brief Connect a slot to Helper check if the option is available.
3547  *
3548  * This signal is used to check if the option (setting) is available from Helper ISE.
3549  *
3550  * The prototype of the slot is:
3551  * void check_option_window (const HelperAgent *agent, uint32 &avail);
3552  */
3553 Connection
3554 HelperAgent::signal_connect_check_option_window (HelperAgentSlotUintVoid *slot)
3555 {
3556     return m_impl->signal_check_option_window.connect (slot);
3557 }
3558
3559 /**
3560  * @brief Connect a slot to Helper process unconventional input device event signal.
3561  *
3562  * This signal is used to send unconventional input device event to Helper ISE.
3563  *
3564  * The prototype of the slot is:
3565  * void process_input_device_event (const HelperAgent *, uint32 &type, char *data, size_t &size, uint32 &ret);
3566  */
3567 Connection
3568 HelperAgent::signal_connect_process_input_device_event (HelperAgentSlotUintCharSizeUint *slot)
3569 {
3570     return m_impl->signal_process_input_device_event.connect (slot);
3571 }
3572
3573 /**
3574  * @brief Connect a slot to Helper set prediction hint signal.
3575  *
3576  * This signal is used to send prediction hint to Helper ISE.
3577  *
3578  * The prototype of the slot is:
3579  * void set_prediction_hint (const HelperAgent *agent, char *prediction_hint);
3580  */
3581 Connection
3582 HelperAgent::signal_connect_set_prediction_hint (HelperAgentSlotStringVoid *slot)
3583 {
3584     return m_impl->signal_set_prediction_hint.connect (slot);
3585 }
3586
3587 /**
3588  * @brief Connect a slot to Helper set mime type signal.
3589  *
3590  * This signal is used to send mime type to Helper ISE.
3591  *
3592  * The prototype of the slot is:
3593  * void set_mime_type (const HelperAgent *agent, char *mime_type);
3594  */
3595 Connection
3596 HelperAgent::signal_connect_set_mime_type (HelperAgentSlotStringVoid *slot)
3597 {
3598     return m_impl->signal_set_mime_type.connect (slot);
3599 }
3600
3601 /**
3602  * @brief Connect a slot to Helper set prediction hint data signal.
3603  *
3604  * This signal is used to send prediction hint data to Helper ISE.
3605  *
3606  * The prototype of the slot is:
3607  * void set_prediction_hint_data (const HelperAgent *agent, char *key, char *value);
3608  */
3609 Connection
3610 HelperAgent::signal_connect_set_prediction_hint_data (HelperAgentSlotString *slot)
3611 {
3612     return m_impl->signal_set_prediction_hint_data.connect (slot);
3613 }
3614
3615 /**
3616  * @brief Connect a slot to Helper set optimization hint signal.
3617  *
3618  * This signal is used to send optimization hint to Helper ISE.
3619  *
3620  * The prototype of the slot is:
3621  * void set_optimization_hint (const HelperAgent *agent, uint32 &hint);
3622  */
3623 Connection
3624 HelperAgent::signal_connect_set_optimization_hint (HelperAgentSlotUintVoid *slot)
3625 {
3626     return m_impl->signal_set_optimization_hint.connect (slot);
3627 }
3628
3629 /**
3630  * @brief Connect a slot to Helper process key event with imengine signal.
3631  *
3632  * This signal is used to deliver the key event to Helper ISE.
3633  *
3634  * The prototype of the slot is:
3635  * void process_key_event_with_imengine (const HelperAgent *agent, KeyEvent &key, uint32 &ret);
3636  */
3637 Connection
3638 HelperAgent::signal_connect_process_key_event_with_imengine (HelperAgentSlotKeyEventUint *slot)
3639 {
3640     return m_impl->signal_process_key_event_with_imengine.connect (slot);
3641 }
3642
3643 /**
3644  * @brief Connect a slot to Helper set autocapital type signal.
3645  *
3646  * This signal is used to send autocapital type to imengine.
3647  *
3648  * The prototype of the slot is:
3649  * void set_autocapital_type (const HelperAgent *agent, uint32 &type);
3650  */
3651 Connection
3652 HelperAgent::signal_connect_set_autocapital_type (HelperAgentSlotUintVoid *slot)
3653 {
3654     return m_impl->signal_set_autocapital_type.connect (slot);
3655 }
3656
3657 /**
3658  * @brief Connect a slot to Helper set prediction allow signal.
3659  *
3660  * This signal is used to send prediction allow to imengine.
3661  *
3662  * The prototype of the slot is:
3663  * void set_prediction_allow (const HelperAgent *agent, uint32 &prediction_allow);
3664  */
3665 Connection
3666 HelperAgent::signal_connect_set_prediction_allow (HelperAgentSlotUintVoid *slot)
3667 {
3668     return m_impl->signal_set_prediction_allow.connect (slot);
3669 }
3670
3671 } /* namespace scim */
3672
3673 /*
3674 vi:ts=4:nowrap:ai:expandtab
3675 */
3676