Git init
[framework/uifw/isf.git] / ism / src / scim_panel_client.h
1 /**
2  * @file scim_panel_client.h
3  * @brief Defines scim::PanelClient and it's related types.
4  *
5  * scim::PanelClient is a class used to connect with a Panel daemon.
6  * It acts like a Socket Client and handles all socket communication
7  * issues.
8  */
9
10 /* ISF is based on SCIM 1.4.7 and extended for supporting more mobile fitable. */
11
12 /*
13  * Smart Common Input Method
14  *
15  * Copyright (c) 2005 James Su <suzhe@tsinghua.org.cn>
16  *
17  *
18  * This library is free software; you can redistribute it and/or
19  * modify it under the terms of the GNU Lesser General Public
20  * License as published by the Free Software Foundation; either
21  * version 2 of the License, or (at your option) any later version.
22  *
23  * This library is distributed in the hope that it will be useful,
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26  * GNU Lesser General Public License for more details.
27  *
28  * You should have received a copy of the GNU Lesser General Public
29  * License along with this program; if not, write to the
30  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
31  * Boston, MA  02111-1307  USA
32  *
33  * $Id: scim_panel_client.h,v 1.4 2005/06/26 16:35:33 suzhe Exp $
34  */
35
36 #ifndef __SCIM_PANEL_CLIENT_H
37 #define __SCIM_PANEL_CLIENT_H
38
39 #include <scim_panel_common.h>
40
41 namespace scim {
42
43 /**
44  * @addtogroup Panel
45  * @ingroup InputServiceFramework
46  * @{
47  */
48
49 typedef Slot1<void, int>
50         PanelClientSlotVoid;
51
52 typedef Slot2<void, int, int>
53         PanelClientSlotInt;
54
55 typedef Slot2<void, int, const String &>
56         PanelClientSlotString;
57
58 typedef Slot2<void, int, const WideString &>
59         PanelClientSlotWideString;
60
61 typedef Slot4<void, int, const String &, const String &, const Transaction &>
62         PanelClientSlotStringStringTransaction;
63
64 typedef Slot2<void, int, const KeyEvent &>
65         PanelClientSlotKeyEvent;
66
67 typedef Slot3<void, int, const WideString &, const AttributeList &>
68         PanelClientSlotStringAttrs;
69
70 /**
71  * @brief PanelClient is used by FrontEnd to communicate with Panel daemon.
72  *
73  * All socket communication between FrontEnd and Panel is handled by this class.
74  * FrontEnd may just register some slots to the corresponding signals to handle
75  * the events sent from Panel.
76  */
77 class PanelClient
78 {
79     class PanelClientImpl;
80     PanelClientImpl *m_impl;
81
82     PanelClient (const PanelClient &);
83     const PanelClient & operator = (const PanelClient &);
84
85 public:
86     PanelClient ();
87     ~PanelClient ();
88
89     /**
90      * @brief Open socket connection to the Panel.
91      *
92      * FrontEnd and Panel communicate with each other via the Socket created by Panel.
93      *
94      * FrontEnd can select/poll on the connection id returned by this method to see
95      * if there are any data available to be read. If any data are available,
96      * PanelClient::filter_event() should be called to process the data.
97      *
98      * If PanelClient::filter_event() returns false, then it means that the connection
99      * is broken and should be re-established by calling PanelClient::close_connection()
100      * and PanelClient::open_connection() again.
101      *
102      * This method would try to launch the panel daemon and make connection again,
103      * if the connection could not be established successfully.
104      * So this method should always success, unless the panel could not be started on
105      * the certain display.
106      *
107      * @param config  The config module name which should be used by launching the panel daemon.
108      * @param display The display name which the panel daemon should run on.
109      * @return The id of the socket connection, -1 means connection is failed.
110      */
111     int  open_connection        (const String &config, const String &display);
112
113     /**
114      * @brief Close the connection to Panel.
115      */
116     void close_connection       ();
117
118     /**
119      * @brief Return the connection id, which was returned by PanelClient::open_connection().
120      */
121     int  get_connection_number  () const;
122
123     /**
124      * @brief Return whether this PanelClient has been connected to a Panel.
125      */
126     bool is_connected           () const;
127
128     /**
129      * @brief Check if there are any events available to be processed.
130      *
131      * If it returns true then FrontEnd should call
132      * PanelClient::filter_event() to process them.
133      *
134      * @return true if there are any events available.
135      */
136     bool has_pending_event      () const;
137
138     /**
139      * @brief Filter the events sent from Panel daemon.
140      *
141      * Corresponding signal will be emitted in this method.
142      *
143      * @return false if the connection is broken, otherwise return true.
144      */
145     bool filter_event           ();
146
147     /**
148      * @brief Prepare the send transation for an IC.
149      *
150      * This method should be called before any events would be sent to Panel.
151      *
152      * @param icid The id of the IC which has events to be sent to Panel.
153      * @return true if the preparation is ok.
154      */
155     bool prepare                (int icid);
156
157     /**
158      * @brief Send the transaction to Panel.
159      * @return true if sent successfully.
160      */
161     bool send                   ();
162
163 public:
164     /**
165      * @name Action methods to send events to Panel.
166      * @{
167      */
168     void turn_on                (int icid);
169     void turn_off               (int icid);
170     void update_screen          (int icid, int screen);
171     void show_help              (int icid, const String &help);
172     void show_factory_menu      (int icid, const std::vector <PanelFactoryInfo> &menu);
173     void focus_in               (int icid, const String &uuid);
174     void focus_out              (int icid);
175     void update_factory_info    (int icid, const PanelFactoryInfo &info);
176     void update_spot_location   (int icid, int x, int y, int top_y);
177     void update_cursor_position (int icid, int cursor_pos);
178     void show_preedit_string    (int icid);
179     void show_aux_string        (int icid);
180     void show_lookup_table      (int icid);
181     void hide_preedit_string    (int icid);
182     void hide_aux_string        (int icid);
183     void hide_lookup_table      (int icid);
184     void update_preedit_string  (int icid, const WideString &str, const AttributeList &attrs);
185     void update_preedit_caret   (int icid, int caret);
186     void update_aux_string      (int icid, const WideString &str, const AttributeList &attrs);
187     void update_lookup_table    (int icid, const LookupTable &table);
188     void register_properties    (int icid, const PropertyList &properties);
189     void update_property        (int icid, const Property &property);
190     void start_default_ise      (int icid);
191     void start_helper           (int icid, const String &helper_uuid);
192     void stop_helper            (int icid, const String &helper_uuid);
193     void send_helper_event      (int icid, const String &helper_uuid, const Transaction &trans);
194     void register_input_context (int icid, const String &uuid);
195     void remove_input_context   (int icid);
196     void reset_input_context    (int icid);
197     void turn_on_log            (int icid, uint32 isOn);
198     /** @} */
199
200 public:
201     /**
202      * @name Signal connection functions.
203      *
204      * These functions are used by FrontEnds to connect their corresponding slots to
205      * this PanelClient's signals.
206      *
207      * The first parameter of each slot method is always "int context", which is the
208      * id of the input method context.
209      *
210      * @{
211      */
212
213     void reset_signal_handler (void);
214
215     /**
216      * @brief Signal: reload configuration.
217      *
218      * slot prototype: void reload_config (int context);
219      *
220      * The context parameter is useless here.
221      */
222     Connection signal_connect_reload_config                 (PanelClientSlotVoid                    *slot);
223
224     /**
225      * @brief Signal: exit the FrontEnd
226      *
227      * slot prototype: void exit (int context);
228      *
229      * The context parameter is useless here.
230      */
231     Connection signal_connect_exit                          (PanelClientSlotVoid                    *slot);
232
233     /**
234      * @brief Signal: update lookup table page size
235      *
236      * slot prototype: void update_lookup_table_page_size (int context, int page_size);
237      */
238     Connection signal_connect_update_lookup_table_page_size (PanelClientSlotInt                     *slot);
239
240     /**
241      * @brief Signal: lookup table page up
242      *
243      * slot prototype: void lookup_table_page_up (int context);
244      */
245     Connection signal_connect_lookup_table_page_up          (PanelClientSlotVoid                    *slot);
246
247     /**
248      * @brief Signal: lookup table page down
249      *
250      * slot prototype: void lookup_table_page_down (int context);
251      */
252     Connection signal_connect_lookup_table_page_down        (PanelClientSlotVoid                    *slot);
253
254     /**
255      * @brief Signal: reset imengine option
256      *
257      * slot prototype: void reset_option (int context);
258      */
259     Connection signal_connect_reset_option                  (PanelClientSlotVoid                    *slot);
260
261     /**
262      * @brief Signal: trigger property
263      *
264      * slot prototype: void trigger_property (int context, const String &property);
265      */
266     Connection signal_connect_trigger_property              (PanelClientSlotString                  *slot);
267
268     /**
269      * @brief Signal: process helper event
270      *
271      * slot prototype: void process_helper_event (int context, const String &target_uuid, const String &helper_uuid, const Transaction &trans);
272      *
273      * - target_uuid is UUID of the IMEngineInstance object which should handle the events.
274      * - helper_uuid is UUID of the Helper which sent the events.
275      * - trans contains the events.
276      */
277     Connection signal_connect_process_helper_event          (PanelClientSlotStringStringTransaction *slot);
278
279     /**
280      * @brief Signal: move preedit caret
281      *
282      * slot prototype: void move_preedit_caret (int context, int caret_pos);
283      */
284     Connection signal_connect_move_preedit_caret            (PanelClientSlotInt                     *slot);
285
286     /**
287      * @brief Signal: select aux
288      *
289      * slot prototype: void select_aux (int context, int aux_index);
290      */
291     Connection signal_connect_select_aux                    (PanelClientSlotInt                     *slot);
292
293     /**
294      * @brief Signal: select candidate
295      *
296      * slot prototype: void select_candidate (int context, int cand_index);
297      */
298     Connection signal_connect_select_candidate              (PanelClientSlotInt                     *slot);
299
300     /**
301      * @brief Signal: process key event
302      *
303      * slot prototype: void process_key_event (int context, const KeyEvent &key);
304      */
305     Connection signal_connect_process_key_event             (PanelClientSlotKeyEvent                *slot);
306
307     /**
308      * @brief Signal: commit string
309      *
310      * slot prototype: void commit_string (int context, const WideString &wstr);
311      */
312     Connection signal_connect_commit_string                 (PanelClientSlotWideString              *slot);
313
314     /**
315      * @brief Signal: forward key event
316      *
317      * slot prototype: void forward_key_event (int context, const KeyEvent &key);
318      */
319     Connection signal_connect_forward_key_event             (PanelClientSlotKeyEvent                *slot);
320
321     /**
322      * @brief Signal: request help
323      *
324      * slot prototype: void request_help (int context);
325      */
326     Connection signal_connect_request_help                  (PanelClientSlotVoid                    *slot);
327
328     /**
329      * @brief Signal: request factory menu
330      *
331      * slot prototype: void request_factory_menu (int context);
332      */
333     Connection signal_connect_request_factory_menu          (PanelClientSlotVoid                    *slot);
334
335     /**
336      * @brief Signal: change factory
337      *
338      * slot prototype: void change_factory (int context, const String &uuid);
339      */
340     Connection signal_connect_change_factory                (PanelClientSlotString                  *slot);
341
342     /**
343      * @brief Signal: reset keyboard ise
344      *
345      * slot prototype: void reset_keyboard_ise (int context);
346      */
347     Connection signal_connect_reset_keyboard_ise            (PanelClientSlotVoid                    *slot);
348
349     /**
350      * @brief Signal: update keyboard ise
351      *
352      * slot prototype: void update_keyboard_ise (int context);
353      */
354     Connection signal_connect_update_keyboard_ise           (PanelClientSlotVoid                    *slot);
355
356     Connection signal_connect_show_preedit_string           (PanelClientSlotVoid                    *slot);
357     Connection signal_connect_hide_preedit_string           (PanelClientSlotVoid                    *slot);
358     Connection signal_connect_update_preedit_string         (PanelClientSlotStringAttrs             *slot);
359     /** @} */
360 };
361
362 /**  @} */
363
364 } // namespace scim
365
366 #endif //__SCIM_PANEL_CLIENT_H
367
368 /*
369 vi:ts=4:nowrap:ai:expandtab
370 */
371