2 * @file scim_panel_client.h
3 * @brief Defines scim::PanelClient and it's related types.
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
10 /* ISF is based on SCIM 1.4.7 and extended for supporting more mobile fitable. */
13 * Smart Common Input Method
15 * Copyright (c) 2005 James Su <suzhe@tsinghua.org.cn>
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.
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.
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
33 * $Id: scim_panel_client.h,v 1.4 2005/06/26 16:35:33 suzhe Exp $
36 #ifndef __SCIM_PANEL_CLIENT_H
37 #define __SCIM_PANEL_CLIENT_H
39 #include <scim_panel_common.h>
45 * @ingroup InputServiceFramework
49 typedef Slot1<void, int>
52 typedef Slot2<void, int, int>
55 typedef Slot3<void, int, int, int>
56 PanelClientSlotIntInt;
58 typedef Slot2<void, int, const String &>
59 PanelClientSlotString;
61 typedef Slot2<void, int, const WideString &>
62 PanelClientSlotWideString;
64 typedef Slot4<void, int, const String &, const String &, const Transaction &>
65 PanelClientSlotStringStringTransaction;
67 typedef Slot2<void, int, const KeyEvent &>
68 PanelClientSlotKeyEvent;
70 typedef Slot3<void, int, const WideString &, const AttributeList &>
71 PanelClientSlotStringAttrs;
74 * @brief PanelClient is used by FrontEnd to communicate with Panel daemon.
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.
82 class PanelClientImpl;
83 PanelClientImpl *m_impl;
85 PanelClient (const PanelClient &);
86 const PanelClient & operator = (const PanelClient &);
93 * @brief Open socket connection to the Panel.
95 * FrontEnd and Panel communicate with each other via the Socket created by Panel.
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.
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.
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.
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.
114 int open_connection (const String &config, const String &display);
117 * @brief Close the connection to Panel.
119 void close_connection ();
122 * @brief Return the connection id, which was returned by PanelClient::open_connection().
124 int get_connection_number () const;
127 * @brief Return whether this PanelClient has been connected to a Panel.
129 bool is_connected () const;
132 * @brief Check if there are any events available to be processed.
134 * If it returns true then FrontEnd should call
135 * PanelClient::filter_event() to process them.
137 * @return true if there are any events available.
139 bool has_pending_event () const;
142 * @brief Filter the events sent from Panel daemon.
144 * Corresponding signal will be emitted in this method.
146 * @return false if the connection is broken, otherwise return true.
148 bool filter_event ();
151 * @brief Prepare the send transation for an IC.
153 * This method should be called before any events would be sent to Panel.
155 * @param icid The id of the IC which has events to be sent to Panel.
156 * @return true if the preparation is ok.
158 bool prepare (int icid);
161 * @brief Send the transaction to Panel.
162 * @return true if sent successfully.
168 * @name Action methods to send events to Panel.
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);
206 * @name Signal connection functions.
208 * These functions are used by FrontEnds to connect their corresponding slots to
209 * this PanelClient's signals.
211 * The first parameter of each slot method is always "int context", which is the
212 * id of the input method context.
217 void reset_signal_handler (void);
220 * @brief Signal: reload configuration.
222 * slot prototype: void reload_config (int context);
224 * The context parameter is useless here.
226 Connection signal_connect_reload_config (PanelClientSlotVoid *slot);
229 * @brief Signal: exit the FrontEnd
231 * slot prototype: void exit (int context);
233 * The context parameter is useless here.
235 Connection signal_connect_exit (PanelClientSlotVoid *slot);
238 * @brief Signal: update lookup table page size
240 * slot prototype: void update_lookup_table_page_size (int context, int page_size);
242 Connection signal_connect_update_lookup_table_page_size (PanelClientSlotInt *slot);
245 * @brief Signal: lookup table page up
247 * slot prototype: void lookup_table_page_up (int context);
249 Connection signal_connect_lookup_table_page_up (PanelClientSlotVoid *slot);
252 * @brief Signal: lookup table page down
254 * slot prototype: void lookup_table_page_down (int context);
256 Connection signal_connect_lookup_table_page_down (PanelClientSlotVoid *slot);
259 * @brief Signal: reset imengine option
261 * slot prototype: void reset_option (int context);
263 Connection signal_connect_reset_option (PanelClientSlotVoid *slot);
266 * @brief Signal: trigger property
268 * slot prototype: void trigger_property (int context, const String &property);
270 Connection signal_connect_trigger_property (PanelClientSlotString *slot);
273 * @brief Signal: process helper event
275 * slot prototype: void process_helper_event (int context, const String &target_uuid, const String &helper_uuid, const Transaction &trans);
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.
281 Connection signal_connect_process_helper_event (PanelClientSlotStringStringTransaction *slot);
284 * @brief Signal: move preedit caret
286 * slot prototype: void move_preedit_caret (int context, int caret_pos);
288 Connection signal_connect_move_preedit_caret (PanelClientSlotInt *slot);
291 * @brief Signal: select aux
293 * slot prototype: void select_aux (int context, int aux_index);
295 Connection signal_connect_select_aux (PanelClientSlotInt *slot);
298 * @brief Signal: select candidate
300 * slot prototype: void select_candidate (int context, int cand_index);
302 Connection signal_connect_select_candidate (PanelClientSlotInt *slot);
305 * @brief Signal: process key event
307 * slot prototype: void process_key_event (int context, const KeyEvent &key);
309 Connection signal_connect_process_key_event (PanelClientSlotKeyEvent *slot);
312 * @brief Signal: commit string
314 * slot prototype: void commit_string (int context, const WideString &wstr);
316 Connection signal_connect_commit_string (PanelClientSlotWideString *slot);
319 * @brief Signal: forward key event
321 * slot prototype: void forward_key_event (int context, const KeyEvent &key);
323 Connection signal_connect_forward_key_event (PanelClientSlotKeyEvent *slot);
326 * @brief Signal: request help
328 * slot prototype: void request_help (int context);
330 Connection signal_connect_request_help (PanelClientSlotVoid *slot);
333 * @brief Signal: request factory menu
335 * slot prototype: void request_factory_menu (int context);
337 Connection signal_connect_request_factory_menu (PanelClientSlotVoid *slot);
340 * @brief Signal: change factory
342 * slot prototype: void change_factory (int context, const String &uuid);
344 Connection signal_connect_change_factory (PanelClientSlotString *slot);
347 * @brief Signal: reset keyboard ise
349 * slot prototype: void reset_keyboard_ise (int context);
351 Connection signal_connect_reset_keyboard_ise (PanelClientSlotVoid *slot);
354 * @brief Signal: update keyboard ise
356 * slot prototype: void update_keyboard_ise (int context);
358 Connection signal_connect_update_keyboard_ise (PanelClientSlotVoid *slot);
361 * @brief Signal: show preedit string
363 * slot prototype: void show_preedit_string (int context);
365 Connection signal_connect_show_preedit_string (PanelClientSlotVoid *slot);
368 * @brief Signal: hide preedit string
370 * slot prototype: void hide_preedit_string (int context);
372 Connection signal_connect_hide_preedit_string (PanelClientSlotVoid *slot);
375 * @brief Signal: update preedit string
377 * slot prototype: void update_preedit_string (int context, const WideString &str, const AttributeList &attrs);
379 Connection signal_connect_update_preedit_string (PanelClientSlotStringAttrs *slot);
382 * @brief Signal: Request to get surrounding text
384 * slot prototype: void get_surrounding text (int context, int maxlen_before, int maxlen_after);
386 Connection signal_connect_get_surrounding_text (PanelClientSlotIntInt *slot);
389 * @brief Signal: Delete surrounding text
391 * slot prototype: void delete_surrounding text (int context, int offset, int len);
393 Connection signal_connect_delete_surrounding_text (PanelClientSlotIntInt *slot);
402 #endif //__SCIM_PANEL_CLIENT_H
405 vi:ts=4:nowrap:ai:expandtab