upload isf tizen beta package
[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 Slot3<void, int, int, int>
56         PanelClientSlotIntInt;
57
58 typedef Slot2<void, int, const String &>
59         PanelClientSlotString;
60
61 typedef Slot2<void, int, const WideString &>
62         PanelClientSlotWideString;
63
64 typedef Slot4<void, int, const String &, const String &, const Transaction &>
65         PanelClientSlotStringStringTransaction;
66
67 typedef Slot2<void, int, const KeyEvent &>
68         PanelClientSlotKeyEvent;
69
70 typedef Slot3<void, int, const WideString &, const AttributeList &>
71         PanelClientSlotStringAttrs;
72
73 /**
74  * @brief PanelClient is used by FrontEnd to communicate with Panel daemon.
75  *
76  * All socket communication between FrontEnd and Panel is handled by this class.
77  * FrontEnd may just register some slots to the corresponding signals to handle
78  * the events sent from Panel.
79  */
80 class PanelClient
81 {
82     class PanelClientImpl;
83     PanelClientImpl *m_impl;
84
85     PanelClient (const PanelClient &);
86     const PanelClient & operator = (const PanelClient &);
87
88 public:
89     PanelClient ();
90     ~PanelClient ();
91
92     /**
93      * @brief Open socket connection to the Panel.
94      *
95      * FrontEnd and Panel communicate with each other via the Socket created by Panel.
96      *
97      * FrontEnd can select/poll on the connection id returned by this method to see
98      * if there are any data available to be read. If any data are available,
99      * PanelClient::filter_event() should be called to process the data.
100      *
101      * If PanelClient::filter_event() returns false, then it means that the connection
102      * is broken and should be re-established by calling PanelClient::close_connection()
103      * and PanelClient::open_connection() again.
104      *
105      * This method would try to launch the panel daemon and make connection again,
106      * if the connection could not be established successfully.
107      * So this method should always success, unless the panel could not be started on
108      * the certain display.
109      *
110      * @param config  The config module name which should be used by launching the panel daemon.
111      * @param display The display name which the panel daemon should run on.
112      * @return The id of the socket connection, -1 means connection is failed.
113      */
114     int  open_connection        (const String &config, const String &display);
115
116     /**
117      * @brief Close the connection to Panel.
118      */
119     void close_connection       ();
120
121     /**
122      * @brief Return the connection id, which was returned by PanelClient::open_connection().
123      */
124     int  get_connection_number  () const;
125
126     /**
127      * @brief Return whether this PanelClient has been connected to a Panel.
128      */
129     bool is_connected           () const;
130
131     /**
132      * @brief Check if there are any events available to be processed.
133      *
134      * If it returns true then FrontEnd should call
135      * PanelClient::filter_event() to process them.
136      *
137      * @return true if there are any events available.
138      */
139     bool has_pending_event      () const;
140
141     /**
142      * @brief Filter the events sent from Panel daemon.
143      *
144      * Corresponding signal will be emitted in this method.
145      *
146      * @return false if the connection is broken, otherwise return true.
147      */
148     bool filter_event           ();
149
150     /**
151      * @brief Prepare the send transation for an IC.
152      *
153      * This method should be called before any events would be sent to Panel.
154      *
155      * @param icid The id of the IC which has events to be sent to Panel.
156      * @return true if the preparation is ok.
157      */
158     bool prepare                (int icid);
159
160     /**
161      * @brief Send the transaction to Panel.
162      * @return true if sent successfully.
163      */
164     bool send                   ();
165
166 public:
167     /**
168      * @name Action methods to send events to Panel.
169      * @{
170      */
171     void turn_on                (int icid);
172     void turn_off               (int icid);
173     void update_screen          (int icid, int screen);
174     void show_help              (int icid, const String &help);
175     void show_factory_menu      (int icid, const std::vector <PanelFactoryInfo> &menu);
176     void focus_in               (int icid, const String &uuid);
177     void focus_out              (int icid);
178     void update_factory_info    (int icid, const PanelFactoryInfo &info);
179     void update_spot_location   (int icid, int x, int y, int top_y);
180     void update_cursor_position (int icid, int cursor_pos);
181     void update_surrounding_text (int icid, const WideString &str, int cursor);
182     void show_preedit_string    (int icid);
183     void show_aux_string        (int icid);
184     void show_lookup_table      (int icid);
185     void hide_preedit_string    (int icid);
186     void hide_aux_string        (int icid);
187     void hide_lookup_table      (int icid);
188     void update_preedit_string  (int icid, const WideString &str, const AttributeList &attrs);
189     void update_preedit_caret   (int icid, int caret);
190     void update_aux_string      (int icid, const WideString &str, const AttributeList &attrs);
191     void update_lookup_table    (int icid, const LookupTable &table);
192     void register_properties    (int icid, const PropertyList &properties);
193     void update_property        (int icid, const Property &property);
194     void start_default_ise      (int icid);
195     void start_helper           (int icid, const String &helper_uuid);
196     void stop_helper            (int icid, const String &helper_uuid);
197     void send_helper_event      (int icid, const String &helper_uuid, const Transaction &trans);
198     void register_input_context (int icid, const String &uuid);
199     void remove_input_context   (int icid);
200     void reset_input_context    (int icid);
201     void turn_on_log            (int icid, uint32 isOn);
202     /** @} */
203
204 public:
205     /**
206      * @name Signal connection functions.
207      *
208      * These functions are used by FrontEnds to connect their corresponding slots to
209      * this PanelClient's signals.
210      *
211      * The first parameter of each slot method is always "int context", which is the
212      * id of the input method context.
213      *
214      * @{
215      */
216
217     void reset_signal_handler (void);
218
219     /**
220      * @brief Signal: reload configuration.
221      *
222      * slot prototype: void reload_config (int context);
223      *
224      * The context parameter is useless here.
225      */
226     Connection signal_connect_reload_config                 (PanelClientSlotVoid                    *slot);
227
228     /**
229      * @brief Signal: exit the FrontEnd
230      *
231      * slot prototype: void exit (int context);
232      *
233      * The context parameter is useless here.
234      */
235     Connection signal_connect_exit                          (PanelClientSlotVoid                    *slot);
236
237     /**
238      * @brief Signal: update lookup table page size
239      *
240      * slot prototype: void update_lookup_table_page_size (int context, int page_size);
241      */
242     Connection signal_connect_update_lookup_table_page_size (PanelClientSlotInt                     *slot);
243
244     /**
245      * @brief Signal: lookup table page up
246      *
247      * slot prototype: void lookup_table_page_up (int context);
248      */
249     Connection signal_connect_lookup_table_page_up          (PanelClientSlotVoid                    *slot);
250
251     /**
252      * @brief Signal: lookup table page down
253      *
254      * slot prototype: void lookup_table_page_down (int context);
255      */
256     Connection signal_connect_lookup_table_page_down        (PanelClientSlotVoid                    *slot);
257
258     /**
259      * @brief Signal: reset imengine option
260      *
261      * slot prototype: void reset_option (int context);
262      */
263     Connection signal_connect_reset_option                  (PanelClientSlotVoid                    *slot);
264
265     /**
266      * @brief Signal: trigger property
267      *
268      * slot prototype: void trigger_property (int context, const String &property);
269      */
270     Connection signal_connect_trigger_property              (PanelClientSlotString                  *slot);
271
272     /**
273      * @brief Signal: process helper event
274      *
275      * slot prototype: void process_helper_event (int context, const String &target_uuid, const String &helper_uuid, const Transaction &trans);
276      *
277      * - target_uuid is UUID of the IMEngineInstance object which should handle the events.
278      * - helper_uuid is UUID of the Helper which sent the events.
279      * - trans contains the events.
280      */
281     Connection signal_connect_process_helper_event          (PanelClientSlotStringStringTransaction *slot);
282
283     /**
284      * @brief Signal: move preedit caret
285      *
286      * slot prototype: void move_preedit_caret (int context, int caret_pos);
287      */
288     Connection signal_connect_move_preedit_caret            (PanelClientSlotInt                     *slot);
289
290     /**
291      * @brief Signal: select aux
292      *
293      * slot prototype: void select_aux (int context, int aux_index);
294      */
295     Connection signal_connect_select_aux                    (PanelClientSlotInt                     *slot);
296
297     /**
298      * @brief Signal: select candidate
299      *
300      * slot prototype: void select_candidate (int context, int cand_index);
301      */
302     Connection signal_connect_select_candidate              (PanelClientSlotInt                     *slot);
303
304     /**
305      * @brief Signal: process key event
306      *
307      * slot prototype: void process_key_event (int context, const KeyEvent &key);
308      */
309     Connection signal_connect_process_key_event             (PanelClientSlotKeyEvent                *slot);
310
311     /**
312      * @brief Signal: commit string
313      *
314      * slot prototype: void commit_string (int context, const WideString &wstr);
315      */
316     Connection signal_connect_commit_string                 (PanelClientSlotWideString              *slot);
317
318     /**
319      * @brief Signal: forward key event
320      *
321      * slot prototype: void forward_key_event (int context, const KeyEvent &key);
322      */
323     Connection signal_connect_forward_key_event             (PanelClientSlotKeyEvent                *slot);
324
325     /**
326      * @brief Signal: request help
327      *
328      * slot prototype: void request_help (int context);
329      */
330     Connection signal_connect_request_help                  (PanelClientSlotVoid                    *slot);
331
332     /**
333      * @brief Signal: request factory menu
334      *
335      * slot prototype: void request_factory_menu (int context);
336      */
337     Connection signal_connect_request_factory_menu          (PanelClientSlotVoid                    *slot);
338
339     /**
340      * @brief Signal: change factory
341      *
342      * slot prototype: void change_factory (int context, const String &uuid);
343      */
344     Connection signal_connect_change_factory                (PanelClientSlotString                  *slot);
345
346     /**
347      * @brief Signal: reset keyboard ise
348      *
349      * slot prototype: void reset_keyboard_ise (int context);
350      */
351     Connection signal_connect_reset_keyboard_ise            (PanelClientSlotVoid                    *slot);
352
353     /**
354      * @brief Signal: update keyboard ise
355      *
356      * slot prototype: void update_keyboard_ise (int context);
357      */
358     Connection signal_connect_update_keyboard_ise           (PanelClientSlotVoid                    *slot);
359
360     /**
361      * @brief Signal: show preedit string
362      *
363      * slot prototype: void show_preedit_string (int context);
364      */
365     Connection signal_connect_show_preedit_string           (PanelClientSlotVoid                    *slot);
366
367     /**
368      * @brief Signal: hide preedit string
369      *
370      * slot prototype: void hide_preedit_string (int context);
371      */
372     Connection signal_connect_hide_preedit_string           (PanelClientSlotVoid                    *slot);
373
374     /**
375      * @brief Signal: update preedit string
376      *
377      * slot prototype: void update_preedit_string (int context, const WideString &str, const AttributeList &attrs);
378      */
379     Connection signal_connect_update_preedit_string         (PanelClientSlotStringAttrs             *slot);
380
381     /**
382      * @brief Signal: Request to get surrounding text
383      *
384      * slot prototype: void get_surrounding text (int context, int maxlen_before, int maxlen_after);
385      */
386     Connection signal_connect_get_surrounding_text          (PanelClientSlotIntInt                  *slot);
387
388     /**
389      * @brief Signal: Delete surrounding text
390      *
391      * slot prototype: void delete_surrounding text (int context, int offset, int len);
392      */
393     Connection signal_connect_delete_surrounding_text       (PanelClientSlotIntInt                  *slot);
394
395     /** @} */
396 };
397
398 /**  @} */
399
400 } // namespace scim
401
402 #endif //__SCIM_PANEL_CLIENT_H
403
404 /*
405 vi:ts=4:nowrap:ai:expandtab
406 */
407