upload isf tizen beta package
[framework/uifw/isf.git] / ism / src / scim_panel_client.cpp
1 /** @file scim_panel_client.cpp
2  *  @brief Implementation of class PanelClient.
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) 2005 James Su <suzhe@tsinghua.org.cn>
11  *
12  *
13  * This library is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU Lesser General Public
15  * License as published by the Free Software Foundation; either
16  * version 2 of the License, or (at your option) any later version.
17  *
18  * This library is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU Lesser General Public License for more details.
22  *
23  * You should have received a copy of the GNU Lesser General Public
24  * License along with this program; if not, write to the
25  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
26  * Boston, MA  02111-1307  USA
27  *
28  * $Id: scim_panel_client.cpp,v 1.6 2005/06/26 16:35:33 suzhe Exp $
29  *
30  */
31
32 #define Uses_SCIM_TRANSACTION
33 #define Uses_SCIM_TRANS_COMMANDS
34 #define Uses_SCIM_PANEL_CLIENT
35 #define Uses_SCIM_SOCKET
36 #define Uses_SCIM_EVENT
37
38 #include "scim_private.h"
39 #include "scim.h"
40
41 namespace scim {
42
43 typedef Signal1<void, int>
44         PanelClientSignalVoid;
45
46 typedef Signal2<void, int, int>
47         PanelClientSignalInt;
48
49 typedef Signal3<void, int, int, int>
50         PanelClientSignalIntInt;
51
52 typedef Signal2<void, int, const String &>
53         PanelClientSignalString;
54
55 typedef Signal2<void, int, const WideString &>
56         PanelClientSignalWideString;
57
58 typedef Signal4<void, int, const String &, const String &, const Transaction &>
59         PanelClientSignalStringStringTransaction;
60
61 typedef Signal2<void, int, const KeyEvent &>
62         PanelClientSignalKeyEvent;
63
64 typedef Signal3<void, int, const WideString &, const AttributeList &>
65         PanelClientSignalStringAttrs;
66
67 class PanelClient::PanelClientImpl
68 {
69     SocketClient                                m_socket;
70     int                                         m_socket_timeout;
71     uint32                                      m_socket_magic_key;
72     Transaction                                 m_send_trans;
73     int                                         m_current_icid;
74     int                                         m_send_refcount;
75
76     PanelClientSignalVoid                       m_signal_reload_config;
77     PanelClientSignalVoid                       m_signal_exit;
78     PanelClientSignalInt                        m_signal_update_lookup_table_page_size;
79     PanelClientSignalVoid                       m_signal_lookup_table_page_up;
80     PanelClientSignalVoid                       m_signal_lookup_table_page_down;
81     PanelClientSignalVoid                       m_signal_reset_option;
82     PanelClientSignalString                     m_signal_trigger_property;
83     PanelClientSignalStringStringTransaction    m_signal_process_helper_event;
84     PanelClientSignalInt                        m_signal_move_preedit_caret;
85     PanelClientSignalInt                        m_signal_select_aux;
86     PanelClientSignalInt                        m_signal_select_candidate;
87     PanelClientSignalKeyEvent                   m_signal_process_key_event;
88     PanelClientSignalWideString                 m_signal_commit_string;
89     PanelClientSignalKeyEvent                   m_signal_forward_key_event;
90     PanelClientSignalVoid                       m_signal_request_help;
91     PanelClientSignalVoid                       m_signal_request_factory_menu;
92     PanelClientSignalString                     m_signal_change_factory;
93     PanelClientSignalVoid                       m_signal_reset_keyboard_ise;
94     PanelClientSignalVoid                       m_signal_update_keyboard_ise;
95     PanelClientSignalVoid                       m_signal_show_preedit_string;
96     PanelClientSignalVoid                       m_signal_hide_preedit_string;
97     PanelClientSignalStringAttrs                m_signal_update_preedit_string;
98     PanelClientSignalIntInt                     m_signal_get_surrounding_text;
99     PanelClientSignalIntInt                     m_signal_delete_surrounding_text;
100
101 public:
102     PanelClientImpl ()
103         : m_socket_timeout (scim_get_default_socket_timeout ()),
104           m_socket_magic_key (0),
105           m_current_icid (-1),
106           m_send_refcount (0)
107     {
108     }
109
110     int  open_connection        (const String &config, const String &display)
111     {
112         String panel_address = scim_get_default_panel_socket_address (display);
113         SocketAddress addr (panel_address);
114
115         if (m_socket.is_connected ()) close_connection ();
116
117         bool ret;
118         int  i, count = 0;
119
120         /* Try three times. */
121         while (1) {
122             ret = m_socket.connect (addr);
123             if (ret == false) {
124                 scim_usleep (100000);
125                 launch_panel (config, display);
126                 std::cerr << " Re-connecting to PanelAgent server.";
127                 ISF_SYSLOG (" Re-connecting to PanelAgent server.\n");
128                 for (i = 0; i < 200; ++i) {
129                     if (m_socket.connect (addr)) {
130                         ret = true;
131                         break;
132                     }
133                     std::cerr << ".";
134                     scim_usleep (200000);
135                 }
136                 std::cerr << " Connected :" << i << "\n";
137                 ISF_SYSLOG ("  Connected :%d\n", i);
138                 if (m_socket.connect (addr) == false && count >= 2)
139                     break;
140             }
141
142             if (ret && scim_socket_open_connection (m_socket_magic_key, String ("FrontEnd"), String ("Panel"), m_socket, m_socket_timeout)) {
143                 ISF_SYSLOG (" PID=%d connect to PanelAgent (%s), connected:%d.\n", getpid (), panel_address.c_str (), count);
144                 break;
145             } else {
146                 std::cerr << " PID=" << getpid () << " cannot connect to PanelAgent (" << panel_address << "), connected:" << count << ".\n";
147                 ISF_SYSLOG (" PID=%d cannot connect to PanelAgent (%s), connected:%d.\n", getpid (), panel_address.c_str (), count);
148             }
149
150             m_socket.close ();
151
152             if (count++ >= 400) break;
153
154             scim_usleep (300000);
155         }
156
157         return m_socket.get_id ();
158     }
159
160     void close_connection       ()
161     {
162         m_socket.close ();
163         m_socket_magic_key = 0;
164     }
165
166     int  get_connection_number  () const
167     {
168         return m_socket.get_id ();
169     }
170
171     bool is_connected           () const
172     {
173         return m_socket.is_connected ();
174     }
175
176     bool has_pending_event      () const
177     {
178         return m_socket.is_connected () && m_socket.wait_for_data (0) > 0;
179     }
180
181     bool filter_event           ()
182     {
183         Transaction recv;
184
185         if (!m_socket.is_connected () || !recv.read_from_socket (m_socket, m_socket_timeout))
186             return false;
187
188         int cmd;
189         uint32 context = (uint32)(-1);
190
191         if (!recv.get_command (cmd) || cmd != SCIM_TRANS_CMD_REPLY)
192             return true;
193
194         /* No context id available, so there will be some global command. */
195         if (recv.get_data_type () == SCIM_TRANS_DATA_COMMAND) {
196             while (recv.get_command (cmd)) {
197                 switch (cmd) {
198                     case SCIM_TRANS_CMD_RELOAD_CONFIG:
199                         m_signal_reload_config ((int)context);
200                         break;
201                     case SCIM_TRANS_CMD_EXIT:
202                         m_signal_exit ((int)context);
203                         break;
204                     default:
205                         break;
206                 }
207             }
208             return true;
209         }
210
211         /* Now for context related command. */
212         if (!recv.get_data (context))
213             return true;
214
215         while (recv.get_command (cmd)) {
216             switch (cmd) {
217                 case SCIM_TRANS_CMD_UPDATE_LOOKUP_TABLE_PAGE_SIZE:
218                     {
219                         uint32 size;
220                         if (recv.get_data (size))
221                             m_signal_update_lookup_table_page_size ((int) context, (int) size);
222                     }
223                     break;
224                 case SCIM_TRANS_CMD_LOOKUP_TABLE_PAGE_UP:
225                     {
226                         m_signal_lookup_table_page_up ((int) context);
227                     }
228                     break;
229                 case SCIM_TRANS_CMD_LOOKUP_TABLE_PAGE_DOWN:
230                     {
231                         m_signal_lookup_table_page_down ((int) context);
232                     }
233                     break;
234                 case ISM_TRANS_CMD_RESET_ISE_OPTION:
235                     {
236                         m_signal_reset_option ((int) context);
237                     }
238                     break;
239                 case SCIM_TRANS_CMD_TRIGGER_PROPERTY:
240                     {
241                         String property;
242                         if (recv.get_data (property))
243                             m_signal_trigger_property ((int) context, property);
244                     }
245                     break;
246                 case SCIM_TRANS_CMD_PROCESS_HELPER_EVENT:
247                     {
248                         String target_uuid;
249                         String helper_uuid;
250                         Transaction trans;
251                         if (recv.get_data (target_uuid) && recv.get_data (helper_uuid) && recv.get_data (trans))
252                             m_signal_process_helper_event ((int) context, target_uuid, helper_uuid, trans);
253                     }
254                     break;
255                 case SCIM_TRANS_CMD_MOVE_PREEDIT_CARET:
256                     {
257                         uint32 caret;
258                         if (recv.get_data (caret))
259                             m_signal_move_preedit_caret ((int) context, (int) caret);
260                     }
261                     break;
262                 case ISM_TRANS_CMD_SELECT_AUX:
263                     {
264                         uint32 item;
265                         if (recv.get_data (item))
266                             m_signal_select_aux ((int) context, (int) item);
267                     }
268                     break;
269                 case SCIM_TRANS_CMD_SELECT_CANDIDATE:
270                     {
271                         uint32 item;
272                         if (recv.get_data (item))
273                             m_signal_select_candidate ((int) context, (int) item);
274                     }
275                     break;
276                 case SCIM_TRANS_CMD_PROCESS_KEY_EVENT:
277                     {
278                         KeyEvent key;
279                         if (recv.get_data (key))
280                             m_signal_process_key_event ((int) context, key);
281                     }
282                     break;
283                 case SCIM_TRANS_CMD_COMMIT_STRING:
284                     {
285                         WideString wstr;
286                         if (recv.get_data (wstr))
287                             m_signal_commit_string ((int) context, wstr);
288                     }
289                     break;
290                 case SCIM_TRANS_CMD_FORWARD_KEY_EVENT:
291                     {
292                         KeyEvent key;
293                         if (recv.get_data (key))
294                             m_signal_forward_key_event ((int) context, key);
295                     }
296                     break;
297                 case SCIM_TRANS_CMD_PANEL_REQUEST_HELP:
298                     {
299                         m_signal_request_help ((int) context);
300                     }
301                     break;
302                 case SCIM_TRANS_CMD_PANEL_REQUEST_FACTORY_MENU:
303                     {
304                         m_signal_request_factory_menu ((int) context);
305                     }
306                     break;
307                 case SCIM_TRANS_CMD_PANEL_CHANGE_FACTORY:
308                     {
309                         String sfid;
310                         if (recv.get_data (sfid))
311                             m_signal_change_factory ((int) context, sfid);
312                     }
313                     break;
314                 case ISM_TRANS_CMD_PANEL_REQUEST_RESET_ISE:
315                     {
316                         m_signal_reset_keyboard_ise ((int) context);
317                     }
318                     break;
319                 case ISM_TRANS_CMD_PANEL_UPDATE_KEYBOARD_ISE:
320                     {
321                         m_signal_update_keyboard_ise ((int) context);
322                     }
323                     break;
324                 case SCIM_TRANS_CMD_SHOW_PREEDIT_STRING:
325                     {
326                         m_signal_show_preedit_string ((int) context);
327                     }
328                     break;
329                 case SCIM_TRANS_CMD_HIDE_PREEDIT_STRING:
330                     {
331                         m_signal_hide_preedit_string ((int) context);
332                     }
333                     break;
334                 case SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING:
335                     {
336                         WideString wstr;
337                         AttributeList attrs;
338                         if (recv.get_data (wstr) && recv.get_data (attrs))
339                             m_signal_update_preedit_string ((int) context, wstr, attrs);
340                     }
341                     break;
342                 case ISM_TRANS_CMD_TURN_ON_LOG:
343                     {
344                         printf ("<%s:%d>receive ISM_TRANS_CMD_TURN_ON_LOG\n", __FUNCTION__, __LINE__);
345                         uint32 isOn;
346                         if (recv.get_data (isOn)) {
347                             if (isOn) {
348                                 printf ("<%s:%d>turn on log\n", __FUNCTION__, __LINE__);
349                                 DebugOutput::enable_debug (SCIM_DEBUG_AllMask);
350                                 DebugOutput::set_verbose_level (7);
351                             } else {
352                                 printf ("<%s:%d>turn off log\n", __FUNCTION__, __LINE__);
353                                 DebugOutput::disable_debug (SCIM_DEBUG_AllMask);
354                                 DebugOutput::set_verbose_level (0);
355                             }
356                         }
357                     }
358                     break;
359                 case SCIM_TRANS_CMD_GET_SURROUNDING_TEXT:
360                     {
361                         uint32 maxlen_before;
362                         uint32 maxlen_after;
363                         if (recv.get_data (maxlen_before) && recv.get_data (maxlen_after))
364                             m_signal_get_surrounding_text ((int) context, (int)maxlen_before, (int)maxlen_after);
365                     }
366                     break;
367                 case SCIM_TRANS_CMD_DELETE_SURROUNDING_TEXT:
368                     {
369                         uint32 offset;
370                         uint32 len;
371                         if (recv.get_data (offset) && recv.get_data (len))
372                             m_signal_delete_surrounding_text ((int) context, (int)offset, (int)len);
373                     }
374                     break;
375                 default:
376                     break;
377             }
378         }
379         return true;
380     }
381
382     bool prepare                (int icid)
383     {
384         if (!m_socket.is_connected ()) return false;
385
386         int cmd;
387         uint32 data;
388
389         if (m_send_refcount <= 0) {
390             m_current_icid = icid;
391             m_send_trans.clear ();
392             m_send_trans.put_command (SCIM_TRANS_CMD_REQUEST);
393             m_send_trans.put_data (m_socket_magic_key);
394             m_send_trans.put_data ((uint32) icid);
395
396             if (m_send_trans.get_command (cmd) &&
397                 m_send_trans.get_data (data) &&
398                 m_send_trans.get_data (data))
399                 m_send_refcount = 0;
400             else
401                 return false;
402         }
403
404         if (m_current_icid == icid) {
405             m_send_refcount ++;
406             return true;
407         }
408         return false;
409     }
410
411     bool send                   ()
412     {
413         if (!m_socket.is_connected ()) return false;
414
415         if (m_send_refcount <= 0) return false;
416
417         m_send_refcount --;
418
419         if (m_send_refcount > 0) return false;
420
421         if (m_send_trans.get_data_type () != SCIM_TRANS_DATA_UNKNOWN)
422             return m_send_trans.write_to_socket (m_socket, 0x4d494353);
423
424         return false;
425     }
426
427 public:
428     void turn_on                (int icid)
429     {
430         if (m_send_refcount > 0 && m_current_icid == icid)
431             m_send_trans.put_command (SCIM_TRANS_CMD_PANEL_TURN_ON);
432     }
433     void turn_off               (int icid)
434     {
435         if (m_send_refcount > 0 && m_current_icid == icid)
436             m_send_trans.put_command (SCIM_TRANS_CMD_PANEL_TURN_OFF);
437     }
438     void update_screen          (int icid, int screen)
439     {
440         if (m_send_refcount > 0 && m_current_icid == icid) {
441             m_send_trans.put_command (SCIM_TRANS_CMD_UPDATE_SCREEN);
442             m_send_trans.put_data ((uint32) screen);
443         }
444     }
445     void show_help              (int icid, const String &help)
446     {
447         if (m_send_refcount > 0 && m_current_icid == icid) {
448             m_send_trans.put_command (SCIM_TRANS_CMD_PANEL_SHOW_HELP);
449             m_send_trans.put_data (help);
450         }
451     }
452     void show_factory_menu      (int icid, const std::vector <PanelFactoryInfo> &menu)
453     {
454         if (m_send_refcount > 0 && m_current_icid == icid) {
455             m_send_trans.put_command (SCIM_TRANS_CMD_PANEL_SHOW_FACTORY_MENU);
456             for (size_t i = 0; i < menu.size (); ++ i) {
457                 m_send_trans.put_data (menu [i].uuid);
458                 m_send_trans.put_data (menu [i].name);
459                 m_send_trans.put_data (menu [i].lang);
460                 m_send_trans.put_data (menu [i].icon);
461             }
462         }
463     }
464     void focus_in               (int icid, const String &uuid)
465     {
466         if (m_send_refcount > 0 && m_current_icid == icid) {
467             m_send_trans.put_command (SCIM_TRANS_CMD_FOCUS_IN);
468             m_send_trans.put_data (uuid);
469         }
470     }
471     void focus_out              (int icid)
472     {
473         if (m_send_refcount > 0 && m_current_icid == icid)
474             m_send_trans.put_command (SCIM_TRANS_CMD_FOCUS_OUT);
475     }
476     void update_factory_info    (int icid, const PanelFactoryInfo &info)
477     {
478         if (m_send_refcount > 0 && m_current_icid == icid) {
479             m_send_trans.put_command (SCIM_TRANS_CMD_PANEL_UPDATE_FACTORY_INFO);
480             m_send_trans.put_data (info.uuid);
481             m_send_trans.put_data (info.name);
482             m_send_trans.put_data (info.lang);
483             m_send_trans.put_data (info.icon);
484         }
485     }
486     void update_spot_location   (int icid, int x, int y, int top_y)
487     {
488         if (m_send_refcount > 0 && m_current_icid == icid) {
489             m_send_trans.put_command (SCIM_TRANS_CMD_UPDATE_SPOT_LOCATION);
490             m_send_trans.put_data ((uint32) x);
491             m_send_trans.put_data ((uint32) y);
492             m_send_trans.put_data ((uint32) top_y);
493         }
494     }
495     void update_cursor_position (int icid, int cursor_pos)
496     {
497         if (m_send_refcount > 0 && m_current_icid == icid) {
498             m_send_trans.put_command (ISM_TRANS_CMD_UPDATE_CURSOR_POSITION);
499             m_send_trans.put_data ((uint32) cursor_pos);
500         }
501     }
502     void update_surrounding_text (int icid, const WideString &str, int cursor)
503     {
504         if (m_send_refcount > 0 && m_current_icid == icid) {
505             m_send_trans.put_command (ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT);
506             m_send_trans.put_data (utf8_wcstombs (str));
507             m_send_trans.put_data ((uint32) cursor);
508         }
509     }
510     void show_preedit_string    (int icid)
511     {
512         if (m_send_refcount > 0 && m_current_icid == icid)
513             m_send_trans.put_command (SCIM_TRANS_CMD_SHOW_PREEDIT_STRING);
514     }
515     void show_aux_string        (int icid)
516     {
517         if (m_send_refcount > 0 && m_current_icid == icid)
518             m_send_trans.put_command (SCIM_TRANS_CMD_SHOW_AUX_STRING);
519     }
520     void show_lookup_table      (int icid)
521     {
522         if (m_send_refcount > 0 && m_current_icid == icid)
523             m_send_trans.put_command (SCIM_TRANS_CMD_SHOW_LOOKUP_TABLE);
524     }
525     void hide_preedit_string    (int icid)
526     {
527         if (m_send_refcount > 0 && m_current_icid == icid)
528             m_send_trans.put_command (SCIM_TRANS_CMD_HIDE_PREEDIT_STRING);
529     }
530     void hide_aux_string        (int icid)
531     {
532         if (m_send_refcount > 0 && m_current_icid == icid)
533             m_send_trans.put_command (SCIM_TRANS_CMD_HIDE_AUX_STRING);
534     }
535     void hide_lookup_table      (int icid)
536     {
537         if (m_send_refcount > 0 && m_current_icid == icid)
538             m_send_trans.put_command (SCIM_TRANS_CMD_HIDE_LOOKUP_TABLE);
539     }
540     void update_preedit_string  (int icid, const WideString &str, const AttributeList &attrs)
541     {
542         if (m_send_refcount > 0 && m_current_icid == icid) {
543             m_send_trans.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING);
544             m_send_trans.put_data (utf8_wcstombs (str));
545             m_send_trans.put_data (attrs);
546         }
547     }
548     void update_preedit_caret   (int icid, int caret)
549     {
550         if (m_send_refcount > 0 && m_current_icid == icid) {
551             m_send_trans.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_CARET);
552             m_send_trans.put_data ((uint32) caret);
553         }
554     }
555     void update_aux_string      (int icid, const WideString &str, const AttributeList &attrs)
556     {
557         if (m_send_refcount > 0 && m_current_icid == icid) {
558             m_send_trans.put_command (SCIM_TRANS_CMD_UPDATE_AUX_STRING);
559             m_send_trans.put_data (utf8_wcstombs (str));
560             m_send_trans.put_data (attrs);
561         }
562     }
563     void update_lookup_table    (int icid, const LookupTable &table)
564     {
565         if (m_send_refcount > 0 && m_current_icid == icid) {
566             m_send_trans.put_command (SCIM_TRANS_CMD_UPDATE_LOOKUP_TABLE);
567             m_send_trans.put_data (table);
568         }
569     }
570     void register_properties    (int icid, const PropertyList &properties)
571     {
572         if (m_send_refcount > 0 && m_current_icid == icid) {
573             m_send_trans.put_command (SCIM_TRANS_CMD_REGISTER_PROPERTIES);
574             m_send_trans.put_data (properties);
575         }
576     }
577     void update_property        (int icid, const Property &property)
578     {
579         if (m_send_refcount > 0 && m_current_icid == icid) {
580             m_send_trans.put_command (SCIM_TRANS_CMD_UPDATE_PROPERTY);
581             m_send_trans.put_data (property);
582         }
583     }
584     void start_default_ise      (int icid)
585     {
586         if (m_send_refcount > 0 && m_current_icid == icid) {
587             m_send_trans.put_command (ISM_TRANS_CMD_PANEL_START_DEFAULT_ISE);
588         }
589     }
590     void start_helper           (int icid, const String &helper_uuid)
591     {
592         if (m_send_refcount > 0 && m_current_icid == icid) {
593             m_send_trans.put_command (SCIM_TRANS_CMD_START_HELPER);
594             m_send_trans.put_data (helper_uuid);
595         }
596     }
597
598     void stop_helper            (int icid, const String &helper_uuid)
599     {
600         if (m_send_refcount > 0 && m_current_icid == icid) {
601             m_send_trans.put_command (SCIM_TRANS_CMD_STOP_HELPER);
602             m_send_trans.put_data (helper_uuid);
603         }
604     }
605     void send_helper_event      (int icid, const String &helper_uuid, const Transaction &trans)
606     {
607         if (m_send_refcount > 0 && m_current_icid == icid) {
608             m_send_trans.put_command (SCIM_TRANS_CMD_SEND_HELPER_EVENT);
609             m_send_trans.put_data (helper_uuid);
610             m_send_trans.put_data (trans);
611         }
612     }
613     void register_input_context (int icid, const String &uuid)
614     {
615         if (m_send_refcount > 0 && m_current_icid == icid) {
616             m_send_trans.put_command (SCIM_TRANS_CMD_PANEL_REGISTER_INPUT_CONTEXT);
617             m_send_trans.put_data (uuid);
618         }
619     }
620     void remove_input_context   (int icid)
621     {
622         if (m_send_refcount > 0 && m_current_icid == icid)
623             m_send_trans.put_command (SCIM_TRANS_CMD_PANEL_REMOVE_INPUT_CONTEXT);
624     }
625     void reset_input_context    (int icid)
626     {
627         if (m_send_refcount > 0 && m_current_icid == icid)
628             m_send_trans.put_command (SCIM_TRANS_CMD_PANEL_RESET_INPUT_CONTEXT);
629     }
630     void turn_on_log            (int icid, uint32 isOn)
631     {
632         m_send_trans.put_command (ISM_TRANS_CMD_TURN_ON_LOG);
633         m_send_trans.put_data (isOn);
634     }
635
636 public:
637     void reset_signal_handler                               (void)
638     {
639         m_signal_reload_config.reset();
640         m_signal_exit.reset();
641         m_signal_update_lookup_table_page_size.reset();
642         m_signal_lookup_table_page_up.reset();
643         m_signal_lookup_table_page_down.reset();
644         m_signal_reset_option.reset();
645         m_signal_trigger_property.reset();
646         m_signal_process_helper_event.reset();
647         m_signal_move_preedit_caret.reset();
648         m_signal_select_aux.reset();
649         m_signal_select_candidate.reset();
650         m_signal_process_key_event.reset();
651         m_signal_commit_string.reset();
652         m_signal_forward_key_event.reset();
653         m_signal_request_help.reset();
654         m_signal_request_factory_menu.reset();
655         m_signal_change_factory.reset();
656         m_signal_reset_keyboard_ise.reset();
657         m_signal_update_keyboard_ise.reset();
658         m_signal_show_preedit_string.reset();
659         m_signal_hide_preedit_string.reset();
660         m_signal_update_preedit_string.reset();
661         m_signal_get_surrounding_text.reset();
662         m_signal_delete_surrounding_text.reset();
663     }
664
665     Connection signal_connect_reload_config                 (PanelClientSlotVoid                    *slot)
666     {
667         return m_signal_reload_config.connect (slot);
668     }
669     Connection signal_connect_exit                          (PanelClientSlotVoid                    *slot)
670     {
671         return m_signal_exit.connect (slot);
672     }
673     Connection signal_connect_update_lookup_table_page_size (PanelClientSlotInt                     *slot)
674     {
675         return m_signal_update_lookup_table_page_size.connect (slot);
676     }
677     Connection signal_connect_lookup_table_page_up          (PanelClientSlotVoid                    *slot)
678     {
679         return m_signal_lookup_table_page_up.connect (slot);
680     }
681     Connection signal_connect_lookup_table_page_down        (PanelClientSlotVoid                    *slot)
682     {
683         return m_signal_lookup_table_page_down.connect (slot);
684     }
685     Connection signal_connect_reset_option                  (PanelClientSlotVoid                    *slot)
686     {
687         return m_signal_reset_option.connect (slot);
688     }
689     Connection signal_connect_trigger_property              (PanelClientSlotString                  *slot)
690     {
691         return m_signal_trigger_property.connect (slot);
692     }
693     Connection signal_connect_process_helper_event          (PanelClientSlotStringStringTransaction *slot)
694     {
695         return m_signal_process_helper_event.connect (slot);
696     }
697     Connection signal_connect_move_preedit_caret            (PanelClientSlotInt                     *slot)
698     {
699         return m_signal_move_preedit_caret.connect (slot);
700     }
701     Connection signal_connect_select_aux                    (PanelClientSlotInt                     *slot)
702     {
703         return m_signal_select_aux.connect (slot);
704     }
705     Connection signal_connect_select_candidate              (PanelClientSlotInt                     *slot)
706     {
707         return m_signal_select_candidate.connect (slot);
708     }
709     Connection signal_connect_process_key_event             (PanelClientSlotKeyEvent                *slot)
710     {
711         return m_signal_process_key_event.connect (slot);
712     }
713     Connection signal_connect_commit_string                 (PanelClientSlotWideString              *slot)
714     {
715         return m_signal_commit_string.connect (slot);
716     }
717     Connection signal_connect_forward_key_event             (PanelClientSlotKeyEvent                *slot)
718     {
719         return m_signal_forward_key_event.connect (slot);
720     }
721     Connection signal_connect_request_help                  (PanelClientSlotVoid                    *slot)
722     {
723         return m_signal_request_help.connect (slot);
724     }
725     Connection signal_connect_request_factory_menu          (PanelClientSlotVoid                    *slot)
726     {
727         return m_signal_request_factory_menu.connect (slot);
728     }
729     Connection signal_connect_change_factory                (PanelClientSlotString                  *slot)
730     {
731         return m_signal_change_factory.connect (slot);
732     }
733
734     Connection signal_connect_reset_keyboard_ise            (PanelClientSlotVoid                    *slot)
735     {
736         return m_signal_reset_keyboard_ise.connect (slot);
737     }
738
739     Connection signal_connect_update_keyboard_ise           (PanelClientSlotVoid                    *slot)
740     {
741         return m_signal_update_keyboard_ise.connect (slot);
742     }
743
744     Connection signal_connect_show_preedit_string           (PanelClientSlotVoid                    *slot)
745     {
746         return m_signal_show_preedit_string.connect (slot);
747     }
748
749     Connection signal_connect_hide_preedit_string           (PanelClientSlotVoid                    *slot)
750     {
751         return m_signal_hide_preedit_string.connect (slot);
752     }
753
754     Connection signal_connect_update_preedit_string         (PanelClientSlotStringAttrs             *slot)
755     {
756         return m_signal_update_preedit_string.connect (slot);
757     }
758
759     Connection signal_connect_get_surrounding_text          (PanelClientSlotIntInt                  *slot)
760     {
761         return m_signal_get_surrounding_text.connect (slot);
762     }
763
764     Connection signal_connect_delete_surrounding_text       (PanelClientSlotIntInt                  *slot)
765     {
766         return m_signal_delete_surrounding_text.connect (slot);
767     }
768
769 private:
770     void launch_panel (const String &config, const String &display) const
771     {
772         scim_launch_panel (true, config, display, NULL);
773     }
774 };
775
776 PanelClient::PanelClient ()
777     : m_impl (new PanelClientImpl ())
778 {
779 }
780
781 PanelClient::~PanelClient ()
782 {
783     delete m_impl;
784 }
785
786 int
787 PanelClient::open_connection (const String &config, const String &display)
788 {
789     return m_impl->open_connection (config, display);
790 }
791
792 void
793 PanelClient::close_connection ()
794 {
795     m_impl->close_connection ();
796 }
797
798 int
799 PanelClient::get_connection_number () const
800 {
801     return m_impl->get_connection_number ();
802 }
803
804 bool
805 PanelClient::is_connected () const
806 {
807     return m_impl->is_connected ();
808 }
809
810 bool
811 PanelClient::has_pending_event () const
812 {
813     return m_impl->has_pending_event ();
814 }
815
816 bool
817 PanelClient::filter_event ()
818 {
819     return m_impl->filter_event ();
820 }
821
822 bool
823 PanelClient::prepare (int icid)
824 {
825     return m_impl->prepare (icid);
826 }
827
828 bool
829 PanelClient::send ()
830 {
831     return m_impl->send ();
832 }
833
834 void
835 PanelClient::turn_on                (int icid)
836 {
837     m_impl->turn_on (icid);
838 }
839 void
840 PanelClient::turn_off               (int icid)
841 {
842     m_impl->turn_off (icid);
843 }
844 void
845 PanelClient::update_screen          (int icid, int screen)
846 {
847     m_impl->update_screen (icid, screen);
848 }
849 void
850 PanelClient::show_help              (int icid, const String &help)
851 {
852     m_impl->show_help (icid, help);
853 }
854 void
855 PanelClient::show_factory_menu      (int icid, const std::vector <PanelFactoryInfo> &menu)
856 {
857     m_impl->show_factory_menu (icid, menu);
858 }
859 void
860 PanelClient::focus_in               (int icid, const String &uuid)
861 {
862     m_impl->focus_in (icid, uuid);
863 }
864 void
865 PanelClient::focus_out              (int icid)
866 {
867     m_impl->focus_out (icid);
868 }
869 void
870 PanelClient::update_factory_info    (int icid, const PanelFactoryInfo &info)
871 {
872     m_impl->update_factory_info (icid, info);
873 }
874 void
875 PanelClient::update_spot_location   (int icid, int x, int y, int top_y)
876 {
877     m_impl->update_spot_location (icid, x, y, top_y);
878 }
879 void
880 PanelClient::update_cursor_position (int icid, int cursor_pos)
881 {
882     m_impl->update_cursor_position (icid, cursor_pos);
883 }
884 void
885 PanelClient::update_surrounding_text (int icid, const WideString &str, int cursor)
886 {
887     m_impl->update_surrounding_text (icid, str, cursor);
888 }
889 void
890 PanelClient::show_preedit_string    (int icid)
891 {
892     m_impl->show_preedit_string (icid);
893 }
894 void
895 PanelClient::show_aux_string        (int icid)
896 {
897     m_impl->show_aux_string (icid);
898 }
899 void
900 PanelClient::show_lookup_table      (int icid)
901 {
902     m_impl->show_lookup_table (icid);
903 }
904 void
905 PanelClient::hide_preedit_string    (int icid)
906 {
907     m_impl->hide_preedit_string (icid);
908 }
909 void
910 PanelClient::hide_aux_string        (int icid)
911 {
912     m_impl->hide_aux_string (icid);
913 }
914 void
915 PanelClient::hide_lookup_table      (int icid)
916 {
917     m_impl->hide_lookup_table (icid);
918 }
919 void
920 PanelClient::update_preedit_string  (int icid, const WideString &str, const AttributeList &attrs)
921 {
922     m_impl->update_preedit_string (icid, str, attrs);
923 }
924 void
925 PanelClient::update_preedit_caret   (int icid, int caret)
926 {
927     m_impl->update_preedit_caret (icid, caret);
928 }
929 void
930 PanelClient::update_aux_string      (int icid, const WideString &str, const AttributeList &attrs)
931 {
932     m_impl->update_aux_string (icid, str, attrs);
933 }
934 void
935 PanelClient::update_lookup_table    (int icid, const LookupTable &table)
936 {
937     m_impl->update_lookup_table (icid, table);
938 }
939 void
940 PanelClient::register_properties    (int icid, const PropertyList &properties)
941 {
942     m_impl->register_properties (icid, properties);
943 }
944 void
945 PanelClient::update_property        (int icid, const Property &property)
946 {
947     m_impl->update_property (icid, property);
948 }
949 void
950 PanelClient::start_default_ise      (int icid)
951 {
952     m_impl->start_default_ise (icid);
953 }
954 void
955 PanelClient::start_helper           (int icid, const String &helper_uuid)
956 {
957     m_impl->start_helper (icid, helper_uuid);
958 }
959
960 void
961 PanelClient::stop_helper            (int icid, const String &helper_uuid)
962 {
963     m_impl->stop_helper (icid, helper_uuid);
964 }
965 void
966 PanelClient::send_helper_event      (int icid, const String &helper_uuid, const Transaction &trans)
967 {
968     m_impl->send_helper_event (icid, helper_uuid, trans);
969 }
970 void
971 PanelClient::register_input_context (int icid, const String &uuid)
972 {
973     m_impl->register_input_context (icid, uuid);
974 }
975 void
976 PanelClient::remove_input_context   (int icid)
977 {
978     m_impl->remove_input_context (icid);
979 }
980 void
981 PanelClient::reset_input_context    (int icid)
982 {
983     m_impl->reset_input_context (icid);
984 }
985
986 void
987 PanelClient::turn_on_log            (int icid, uint32 isOn)
988 {
989     m_impl->turn_on_log (icid, isOn);
990 }
991
992 void
993 PanelClient::reset_signal_handler                         (void)
994 {
995     m_impl->reset_signal_handler ();
996 }
997
998 Connection
999 PanelClient::signal_connect_reload_config                 (PanelClientSlotVoid                    *slot)
1000 {
1001     return m_impl->signal_connect_reload_config (slot);
1002 }
1003 Connection
1004 PanelClient::signal_connect_exit                          (PanelClientSlotVoid                    *slot)
1005 {
1006     return m_impl->signal_connect_exit (slot);
1007 }
1008 Connection
1009 PanelClient::signal_connect_update_lookup_table_page_size (PanelClientSlotInt                     *slot)
1010 {
1011     return m_impl->signal_connect_update_lookup_table_page_size (slot);
1012 }
1013 Connection
1014 PanelClient::signal_connect_lookup_table_page_up          (PanelClientSlotVoid                    *slot)
1015 {
1016     return m_impl->signal_connect_lookup_table_page_up (slot);
1017 }
1018 Connection
1019 PanelClient::signal_connect_lookup_table_page_down        (PanelClientSlotVoid                    *slot)
1020 {
1021     return m_impl->signal_connect_lookup_table_page_down (slot);
1022 }
1023 Connection
1024 PanelClient::signal_connect_reset_option                  (PanelClientSlotVoid                    *slot)
1025 {
1026     return m_impl->signal_connect_reset_option (slot);
1027 }
1028 Connection
1029 PanelClient::signal_connect_trigger_property              (PanelClientSlotString                  *slot)
1030 {
1031     return m_impl->signal_connect_trigger_property (slot);
1032 }
1033 Connection
1034 PanelClient::signal_connect_process_helper_event          (PanelClientSlotStringStringTransaction *slot)
1035 {
1036     return m_impl->signal_connect_process_helper_event (slot);
1037 }
1038 Connection
1039 PanelClient::signal_connect_move_preedit_caret            (PanelClientSlotInt                     *slot)
1040 {
1041     return m_impl->signal_connect_move_preedit_caret (slot);
1042 }
1043 Connection
1044 PanelClient::signal_connect_select_aux                    (PanelClientSlotInt                     *slot)
1045 {
1046     return m_impl->signal_connect_select_aux (slot);
1047 }
1048 Connection
1049 PanelClient::signal_connect_select_candidate              (PanelClientSlotInt                     *slot)
1050 {
1051     return m_impl->signal_connect_select_candidate (slot);
1052 }
1053 Connection
1054 PanelClient::signal_connect_process_key_event             (PanelClientSlotKeyEvent                *slot)
1055 {
1056     return m_impl->signal_connect_process_key_event (slot);
1057 }
1058 Connection
1059 PanelClient::signal_connect_commit_string                 (PanelClientSlotWideString              *slot)
1060 {
1061     return m_impl->signal_connect_commit_string (slot);
1062 }
1063 Connection
1064 PanelClient::signal_connect_forward_key_event             (PanelClientSlotKeyEvent                *slot)
1065 {
1066     return m_impl->signal_connect_forward_key_event (slot);
1067 }
1068 Connection
1069 PanelClient::signal_connect_request_help                  (PanelClientSlotVoid                    *slot)
1070 {
1071     return m_impl->signal_connect_request_help (slot);
1072 }
1073 Connection
1074 PanelClient::signal_connect_request_factory_menu          (PanelClientSlotVoid                    *slot)
1075 {
1076     return m_impl->signal_connect_request_factory_menu (slot);
1077 }
1078 Connection
1079 PanelClient::signal_connect_change_factory                (PanelClientSlotString                  *slot)
1080 {
1081     return m_impl->signal_connect_change_factory (slot);
1082 }
1083
1084 Connection
1085 PanelClient::signal_connect_reset_keyboard_ise            (PanelClientSlotVoid                    *slot)
1086 {
1087     return m_impl->signal_connect_reset_keyboard_ise (slot);
1088 }
1089
1090 Connection
1091 PanelClient::signal_connect_update_keyboard_ise           (PanelClientSlotVoid                    *slot)
1092 {
1093     return m_impl->signal_connect_update_keyboard_ise (slot);
1094 }
1095
1096 Connection
1097 PanelClient::signal_connect_show_preedit_string           (PanelClientSlotVoid                    *slot)
1098 {
1099     return m_impl->signal_connect_show_preedit_string (slot);
1100 }
1101
1102 Connection
1103 PanelClient::signal_connect_hide_preedit_string           (PanelClientSlotVoid                    *slot)
1104 {
1105     return m_impl->signal_connect_hide_preedit_string (slot);
1106 }
1107
1108 Connection
1109 PanelClient::signal_connect_update_preedit_string         (PanelClientSlotStringAttrs             *slot)
1110 {
1111     return m_impl->signal_connect_update_preedit_string (slot);
1112 }
1113
1114 Connection
1115 PanelClient::signal_connect_get_surrounding_text          (PanelClientSlotIntInt                  *slot)
1116 {
1117     return m_impl->signal_connect_get_surrounding_text (slot);
1118 }
1119
1120 Connection
1121 PanelClient::signal_connect_delete_surrounding_text       (PanelClientSlotIntInt                  *slot)
1122 {
1123     return m_impl->signal_connect_delete_surrounding_text (slot);
1124 }
1125
1126 } /* namespace scim */
1127
1128 /*
1129 vi:ts=4:nowrap:ai:expandtab
1130 */
1131