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 Slot2<void, int, const String &>
56 PanelClientSlotString;
58 typedef Slot2<void, int, const WideString &>
59 PanelClientSlotWideString;
61 typedef Slot4<void, int, const String &, const String &, const Transaction &>
62 PanelClientSlotStringStringTransaction;
64 typedef Slot2<void, int, const KeyEvent &>
65 PanelClientSlotKeyEvent;
67 typedef Slot3<void, int, const WideString &, const AttributeList &>
68 PanelClientSlotStringAttrs;
71 * @brief PanelClient is used by FrontEnd to communicate with Panel daemon.
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.
79 class PanelClientImpl;
80 PanelClientImpl *m_impl;
82 PanelClient (const PanelClient &);
83 const PanelClient & operator = (const PanelClient &);
90 * @brief Open socket connection to the Panel.
92 * FrontEnd and Panel communicate with each other via the Socket created by Panel.
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.
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.
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.
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.
111 int open_connection (const String &config, const String &display);
114 * @brief Close the connection to Panel.
116 void close_connection ();
119 * @brief Return the connection id, which was returned by PanelClient::open_connection().
121 int get_connection_number () const;
124 * @brief Return whether this PanelClient has been connected to a Panel.
126 bool is_connected () const;
129 * @brief Check if there are any events available to be processed.
131 * If it returns true then FrontEnd should call
132 * PanelClient::filter_event() to process them.
134 * @return true if there are any events available.
136 bool has_pending_event () const;
139 * @brief Filter the events sent from Panel daemon.
141 * Corresponding signal will be emitted in this method.
143 * @return false if the connection is broken, otherwise return true.
145 bool filter_event ();
148 * @brief Prepare the send transation for an IC.
150 * This method should be called before any events would be sent to Panel.
152 * @param icid The id of the IC which has events to be sent to Panel.
153 * @return true if the preparation is ok.
155 bool prepare (int icid);
158 * @brief Send the transaction to Panel.
159 * @return true if sent successfully.
165 * @name Action methods to send events to Panel.
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);
202 * @name Signal connection functions.
204 * These functions are used by FrontEnds to connect their corresponding slots to
205 * this PanelClient's signals.
207 * The first parameter of each slot method is always "int context", which is the
208 * id of the input method context.
213 void reset_signal_handler (void);
216 * @brief Signal: reload configuration.
218 * slot prototype: void reload_config (int context);
220 * The context parameter is useless here.
222 Connection signal_connect_reload_config (PanelClientSlotVoid *slot);
225 * @brief Signal: exit the FrontEnd
227 * slot prototype: void exit (int context);
229 * The context parameter is useless here.
231 Connection signal_connect_exit (PanelClientSlotVoid *slot);
234 * @brief Signal: update lookup table page size
236 * slot prototype: void update_lookup_table_page_size (int context, int page_size);
238 Connection signal_connect_update_lookup_table_page_size (PanelClientSlotInt *slot);
241 * @brief Signal: lookup table page up
243 * slot prototype: void lookup_table_page_up (int context);
245 Connection signal_connect_lookup_table_page_up (PanelClientSlotVoid *slot);
248 * @brief Signal: lookup table page down
250 * slot prototype: void lookup_table_page_down (int context);
252 Connection signal_connect_lookup_table_page_down (PanelClientSlotVoid *slot);
255 * @brief Signal: reset imengine option
257 * slot prototype: void reset_option (int context);
259 Connection signal_connect_reset_option (PanelClientSlotVoid *slot);
262 * @brief Signal: trigger property
264 * slot prototype: void trigger_property (int context, const String &property);
266 Connection signal_connect_trigger_property (PanelClientSlotString *slot);
269 * @brief Signal: process helper event
271 * slot prototype: void process_helper_event (int context, const String &target_uuid, const String &helper_uuid, const Transaction &trans);
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.
277 Connection signal_connect_process_helper_event (PanelClientSlotStringStringTransaction *slot);
280 * @brief Signal: move preedit caret
282 * slot prototype: void move_preedit_caret (int context, int caret_pos);
284 Connection signal_connect_move_preedit_caret (PanelClientSlotInt *slot);
287 * @brief Signal: select aux
289 * slot prototype: void select_aux (int context, int aux_index);
291 Connection signal_connect_select_aux (PanelClientSlotInt *slot);
294 * @brief Signal: select candidate
296 * slot prototype: void select_candidate (int context, int cand_index);
298 Connection signal_connect_select_candidate (PanelClientSlotInt *slot);
301 * @brief Signal: process key event
303 * slot prototype: void process_key_event (int context, const KeyEvent &key);
305 Connection signal_connect_process_key_event (PanelClientSlotKeyEvent *slot);
308 * @brief Signal: commit string
310 * slot prototype: void commit_string (int context, const WideString &wstr);
312 Connection signal_connect_commit_string (PanelClientSlotWideString *slot);
315 * @brief Signal: forward key event
317 * slot prototype: void forward_key_event (int context, const KeyEvent &key);
319 Connection signal_connect_forward_key_event (PanelClientSlotKeyEvent *slot);
322 * @brief Signal: request help
324 * slot prototype: void request_help (int context);
326 Connection signal_connect_request_help (PanelClientSlotVoid *slot);
329 * @brief Signal: request factory menu
331 * slot prototype: void request_factory_menu (int context);
333 Connection signal_connect_request_factory_menu (PanelClientSlotVoid *slot);
336 * @brief Signal: change factory
338 * slot prototype: void change_factory (int context, const String &uuid);
340 Connection signal_connect_change_factory (PanelClientSlotString *slot);
343 * @brief Signal: reset keyboard ise
345 * slot prototype: void reset_keyboard_ise (int context);
347 Connection signal_connect_reset_keyboard_ise (PanelClientSlotVoid *slot);
350 * @brief Signal: update keyboard ise
352 * slot prototype: void update_keyboard_ise (int context);
354 Connection signal_connect_update_keyboard_ise (PanelClientSlotVoid *slot);
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);
366 #endif //__SCIM_PANEL_CLIENT_H
369 vi:ts=4:nowrap:ai:expandtab