2 * @file scim_panel_agent.h
3 * @brief Defines scim::PanelAgent and their related types.
5 * scim::PanelAgent is a class used to write Panel daemons.
6 * It acts like a Socket Server and handles all socket clients
10 /* ISF is based on SCIM 1.4.7 and extended for supporting more mobile fitable. */
13 * Smart Common Input Method
15 * Copyright (c) 2004-2005 James Su <suzhe@tsinghua.org.cn>
16 * Copyright (c) 2012-2015 Samsung Electronics Co., Ltd.
19 * This library is free software; you can redistribute it and/or
20 * modify it under the terms of the GNU Lesser General Public
21 * License as published by the Free Software Foundation; either
22 * version 2 of the License, or (at your option) any later version.
24 * This library is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU Lesser General Public License for more details.
29 * You should have received a copy of the GNU Lesser General Public
30 * License along with this program; if not, write to the
31 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
32 * Boston, MA 02111-1307 USA
34 * Modifications by Samsung Electronics Co., Ltd.
36 * a. m_signal_set_keyboard_ise and m_signal_get_keyboard_ise
37 * b. m_signal_focus_in and m_signal_focus_out
38 * c. m_signal_expand_candidate, m_signal_contract_candidate and m_signal_set_candidate_ui
39 * d. m_signal_get_ise_list, m_signal_get_keyboard_ise_list, m_signal_update_ise_geometry and m_signal_get_ise_information
40 * e. m_signal_set_active_ise_by_uuid and m_signal_get_ise_info_by_uuid
41 * f. m_signal_accept_connection, m_signal_close_connection and m_signal_exit
42 * 2. Add new interface APIs in PanelClient class
43 * a. get_helper_manager_id (), has_helper_manager_pending_event () and filter_helper_manager_event ()
44 * b. update_candidate_panel_event (), update_input_panel_event () and select_aux ()
45 * c. candidate_more_window_show () and candidate_more_window_hide ()
46 * d. update_displayed_candidate_number () and update_candidate_item_layout ()
47 * e. stop_helper (), send_longpress_event () and update_ise_list ()
48 * f. filter_event (), filter_exception_event () and get_server_id ()
49 * 3. Donot use thread to receive message
50 * 4. Monitor socket frontend for self-recovery function
52 * $Id: scim_panel_agent.h,v 1.2 2005/06/11 14:50:31 suzhe Exp $
55 #ifndef __ISF_PANEL_AGENT_BASE_H
56 #define __ISF_PANEL_AGENT_BASE_H
58 #include <scim_panel_common.h>
69 * @ingroup InputServiceFramework
70 * The accessory classes to help develop Panel daemons and FrontEnds
71 * which need to communicate with Panel daemons.
75 typedef struct _ISE_INFO {
84 typedef struct _HELPER_ISE_INFO {
85 std::vector<String> appid;
86 std::vector<String> label;
87 std::vector<uint32> is_enabled;
88 std::vector<uint32> is_preinstalled;
89 std::vector<uint32> has_option;
93 typedef struct DefaultIse {
97 DefaultIse () : type (TOOLBAR_KEYBOARD_MODE), uuid (""), name ("") { }
101 class PanelAgentBase;
104 * @typedef typedef Pointer <PanelAgentBase> PanelAgentPointer;
106 * A smart pointer for scim::PanelAgentBase and its derived classes.
108 typedef Pointer <PanelAgentBase> PanelAgentPointer;
111 * @brief The class to implement all socket protocol in Panel.
113 * This class acts like a stand alone SocketServer.
114 * It has its own dedicated main loop, and will be blocked when run () is called.
115 * So run () must be called within a separated thread, in order to not block
116 * the main loop of the Panel program itself.
118 * Before calling run (), the panel must hook the callback functions to the
119 * corresponding signals.
121 * Note that, there are two special signals: lock(void) and unlock(void). These
122 * two signals are used to provide a thread lock to PanelAgent, so that PanelAgent
123 * can run correctly within a multi-threading Panel program.
125 class EXAPI PanelAgentBase : public ReferencedObject
127 class PanelAgentBaseImpl;
128 PanelAgentBaseImpl* m_impl;
130 PanelAgentBase (const PanelAgentBase&);
131 const PanelAgentBase& operator = (const PanelAgentBase&);
134 PanelAgentBase (const String& name);
135 virtual ~PanelAgentBase ();
138 * @brief Initialize this PanelAgent.
140 * @param config The name of the config module to be used by Helpers.
141 * @param display The name of display, on which the Panel should run.
142 * @param resident If this is true then this PanelAgent will keep running
143 * even if there is no more client connected.
145 * @return true if the PanelAgent is initialized correctly and ready to run.
147 virtual bool initialize (InfoManager* info_manager, const String& display, bool resident = false);
150 * @brief Check if this PanelAgent is initialized correctly and ready to run.
152 * @return true if this PanelAgent is ready to run.
154 virtual bool valid (void) const;
157 * @brief Stop this PanelAgent.
159 virtual void stop (void);
164 * @brief Notice helper ISE to focus out.
166 * @param uuid The helper ISE uuid.
168 virtual void focus_out_helper (int client, uint32 context, const String& uuid);
171 * @brief Notice helper ISE to focus in.
173 * @param uuid The helper ISE uuid.
175 virtual void focus_in_helper (int client, uint32 context, const String& uuid);
178 * @brief Notice helper ISE to show window.
180 * @param uuid The helper ISE uuid.
182 virtual void show_helper (int client, uint32 context, const String& uuid, char* data, size_t& len);
185 * @brief Notice helper ISE to hide window.
187 * @param uuid The helper ISE uuid.
189 virtual void hide_helper (int client, uint32 context, const String& uuid);
192 * @brief Reset keyboard ISE.
194 * @return true if this operation is successful, otherwise return false.
196 virtual void reset_keyboard_ise (int client, uint32 context);
199 * @brief Change the factory used by the focused IMEngineInstance object.
201 * @param uuid The uuid of the new factory.
202 * @return true if the command was sent correctly.
204 virtual void change_factory (int client, uint32 context, const String& uuid);
207 * @brief Notice Helper ISE that candidate more window is showed.
208 * @return true if the command was sent correctly.
210 virtual void candidate_more_window_show (int client, uint32 context);
213 * @brief Notice Helper ISE that candidate more window is hidden.
214 * @return true if the command was sent correctly.
216 virtual void candidate_more_window_hide (int client, uint32 context);
219 * @brief Notice Helper ISE that show candidate.
220 * @return true if the command was sent correctly.
222 virtual void helper_candidate_show (int client, uint32 context, const String& uuid);
225 * @brief Notice Helper ISE that hide candidate.
226 * @return true if the command was sent correctly.
228 virtual void helper_candidate_hide (int client, uint32 context, const String& uuid);
231 * @brief Update helper lookup table.
232 * @return true if the command was sent correctly.
234 virtual void update_helper_lookup_table (int client, uint32 context, const String& uuid, const LookupTable& table);
237 * @brief Let the focused IMEngineInstance object
238 * select a aux in current aux string.
240 * @param item The index of the selected aux.
241 * @return true if the command was sent correctly.
243 virtual void select_aux (int client, uint32 context, uint32 item);
246 * @brief Let the focused IMEngineInstance object
247 * select a candidate in current lookup table.
249 * @param item The index of the selected candidate.
250 * @return true if the command was sent correctly.
252 virtual void select_candidate (int client, uint32 context, uint32 item);
255 * @brief Let the focused IMEngineInstance object
256 * flip the LookupTable to previous page.
257 * @return true if the command was sent correctly.
259 virtual void lookup_table_page_up (int client, uint32 context);
262 * @brief Let the focused IMEngineInstance object
263 * flip the LookupTable to next page.
264 * @return true if the command was sent correctly.
266 virtual void lookup_table_page_down (int client, uint32 context);
269 * @brief Let the focused IMEngineInstance object
270 * update the page size of the LookupTable.
272 * @param size The new page size.
273 * @return true if the command was sent correctly.
275 virtual void update_lookup_table_page_size (int client, uint32 context, uint32 size);
278 * @brief Let the focused IMEngineInstance object
279 * update candidate items layout.
281 * @param row_items The items of each row.
282 * @return true if the command was sent correctly.
284 virtual void update_candidate_item_layout (int client, uint32 context, const std::vector<uint32>& row_items);
287 * @brief Let the focused IMEngineInstance object
288 * select a associate in current associate table.
290 * @param item The index of the selected associate.
291 * @return true if the command was sent correctly.
293 virtual void select_associate (int client, uint32 context, uint32 item);
296 * @brief Let the focused IMEngineInstance object
297 * flip the AssociateTable to previous page.
298 * @return true if the command was sent correctly.
300 virtual void associate_table_page_up (int client, uint32 context);
303 * @brief Let the focused IMEngineInstance object
304 * flip the AssociateTable to next page.
305 * @return true if the command was sent correctly.
307 virtual void associate_table_page_down (int client, uint32 context);
310 * @brief Let the focused IMEngineInstance object
311 * update the page size of the AssociateTable.
313 * @param size The new page size.
314 * @return true if the command was sent correctly.
316 virtual void update_associate_table_page_size (int client, uint32 context, uint32 size);
319 * @brief Inform helper ISE to update displayed candidate number.
321 * @param size The displayed candidate number.
322 * @return true if the command was sent correctly.
324 virtual void update_displayed_candidate_number (int client, uint32 context, uint32 size);
327 * @brief Trigger a property of the focused IMEngineInstance object.
329 * @param property The property key to be triggered.
330 * @return true if the command was sent correctly.
332 virtual void trigger_property (int client, uint32 context, const String& property);
335 * @brief Let all FrontEnds and Helpers reload configuration.
336 * @return true if the command was sent correctly.
338 virtual void reload_config (int client);
341 * @brief Let all FrontEnds, Helpers and this Panel exit.
342 * @return true if the command was sent correctly.
344 virtual void exit (int client, uint32 context);
347 * @brief Send candidate longpress event to ISE.
349 * @param index The candidate object index.
353 virtual void send_longpress_event (int client, uint32 context, uint32 index);
356 * @brief update_panel_event.
362 virtual void update_panel_event (int client, uint32 context, int cmd, uint32 nType, uint32 nValue);
365 * @brief update_keyboard_ise_list.
371 virtual void update_keyboard_ise_list (int client, uint32 context);
374 * @brief set_helper_mode.
380 virtual void set_helper_mode (int client, uint32 context, const String& uuid, uint32& mode);
383 * @brief set_helper_language.
389 virtual void set_helper_language (int client, uint32 context, const String& uuid, uint32& language);
392 * @brief set_helper_imdata.
398 virtual void set_helper_imdata (int client, uint32 context, const String& uuid, const char* imdata, size_t& len);
401 * @brief set_helper_return_key_type.
407 virtual void set_helper_return_key_type (int client, uint32 context, const String& uuid, uint32 type);
410 * @brief get_helper_return_key_type.
416 virtual void get_helper_return_key_type (int client, uint32 context, const String& uuid, _OUT_ uint32& type);
419 * @brief set_helper_return_key_disable.
425 virtual void set_helper_return_key_disable (int client, uint32 context, const String& uuid, uint32 disabled);
428 * @brief get_helper_return_key_disable.
434 virtual void get_helper_return_key_disable (int client, uint32 context, const String& uuid, _OUT_ uint32& disabled);
437 * @brief set_helper_layout.
443 virtual void set_helper_layout (int client, uint32 context, const String& uuid, uint32& layout);
446 * @brief set_helper_input_mode.
452 virtual void set_helper_input_mode (int client, uint32 context, const String& uuid, uint32& mode);
455 * @brief set_helper_input_hint.
461 virtual void set_helper_input_hint (int client, uint32 context, const String& uuid, uint32& hint);
464 * @brief set_helper_bidi_direction.
470 virtual void set_helper_bidi_direction (int client, uint32 context, const String& uuid, uint32& direction);
473 * @brief set_helper_caps_mode.
479 virtual void set_helper_caps_mode (int client, uint32 context, const String& uuid, uint32& mode);
482 * @brief show_helper_option_window.
488 virtual void show_helper_option_window (int client, uint32 context, const String& uuid);
491 * @brief process_key_event.
497 virtual bool process_key_event (int client, uint32 context, const String& uuid, KeyEvent& key, _OUT_ uint32& result);
500 * @brief get_helper_geometry.
506 virtual bool get_helper_geometry (int client, uint32 context, String& uuid, _OUT_ struct rectinfo& info);
509 * @brief get_helper_imdata.
515 virtual void get_helper_imdata (int client, uint32 context, String& uuid, _OUT_ char** imdata, _OUT_ size_t& len);
518 * @brief get_helper_layout.
524 virtual void get_helper_layout (int client, uint32 context, String& uuid, uint32& layout);
527 * @brief get_ise_language_locale.
533 virtual void get_ise_language_locale (int client, uint32 context, String& uuid, _OUT_ char* data, _OUT_ size_t& len);
536 * @brief check_option_window.
542 virtual void check_option_window (int client, uint32 context, String& uuid, _OUT_ uint32& avail);
545 * @brief reset_ise_option.
551 virtual void reset_ise_option (int client, uint32 context);
554 * @brief reset_helper_context.
560 virtual void reset_helper_context (int client, uint32 context, const String& uuid);
563 * @brief socket_update_surrounding_text.
569 virtual void socket_update_surrounding_text (int client, uint32 context, String& uuid, String text, uint32 cursor);
572 * @brief socket_update_selection.
578 virtual void socket_update_selection (int client, uint32 context, String& uuid, String text);
581 * @brief socket_get_keyboard_ise_list.
587 virtual void socket_get_keyboard_ise_list (int client, uint32 context, const String& uuid, std::vector<String>& list);
590 * @brief socket_get_candidate_ui.
596 virtual void socket_get_candidate_ui (int client, uint32 context, const String& uuid, int style, int mode);
599 * @brief socket_get_candidate_geometry.
605 virtual void socket_get_candidate_geometry (int client, uint32 context, const String& uuid, struct rectinfo& info);
608 * @brief socket_get_keyboard_ise.
614 virtual void socket_get_keyboard_ise (int client, uint32 context, const String& uuid, String& ise_name, String& ise_uuid);
617 * @brief socket_start_helper.
623 virtual void socket_start_helper (int client, uint32 context, const String& ic_uuid);
626 * @brief helper_detach_input_context.
632 virtual void helper_detach_input_context (int client, uint32 context, const String& ic_uuid);
635 * @brief helper_process_imengine_event.
641 virtual void helper_process_imengine_event (int client, uint32 context, const String& ic_uuid, const Transaction& nest_transaction);
644 * @brief process_helper_event.
650 virtual void process_helper_event (int client, uint32 context, String target_uuid, String active_uuid, Transaction& nest_trans);
653 * @brief socket_helper_key_event.
659 virtual void socket_helper_key_event (int client, uint32 context, int cmd , KeyEvent& key);
662 * @brief socket_helper_get_surrounding_text.
668 virtual void socket_helper_get_surrounding_text (int client, uint32 context, uint32 maxlen_before, uint32 maxlen_after);
671 * @brief socket_helper_delete_surrounding_text.
677 virtual void socket_helper_delete_surrounding_text (int client, uint32 context, uint32 offset, uint32 len);
680 * @brief socket_helper_get_selection.
686 virtual void socket_helper_get_selection (int client, uint32 context);
689 * @brief socket_helper_set_selection.
695 virtual void socket_helper_set_selection (int client, uint32 context, uint32 start, uint32 end);
698 * @brief update_ise_input_context.
704 virtual void update_ise_input_context (int client, uint32 context, uint32 type, uint32 value);
707 * @brief send_private_command.
713 virtual void send_private_command (int client, uint32 context, String command);
716 * @brief helper_all_update_spot_location.
722 virtual void helper_all_update_spot_location (int client, uint32 context, String uuid, int x, int y);
725 * @brief helper_all_update_cursor_position.
731 virtual void helper_all_update_cursor_position (int client, uint32 context, String uuid, int cursor_pos);
734 * @brief helper_all_update_screen.
740 virtual void helper_all_update_screen (int client, uint32 context, String uuid, int screen);
743 * @brief commit_string.
749 virtual void commit_string (int client, uint32 context,const WideString& wstr);
752 * @brief show_preedit_string.
758 virtual void show_preedit_string (int client, uint32 context);
761 * @brief hide_preedit_string.
767 virtual void hide_preedit_string (int client, uint32 context);
770 * @brief update_preedit_string.
776 virtual void update_preedit_string (int client, uint32 context, WideString wstr, AttributeList& attrs, uint32 caret);
779 * @brief update_preedit_caret.
785 virtual void update_preedit_caret (int client, uint32 context, uint32 caret);
788 * @brief attach_input_context and update_screen.
794 virtual void helper_attach_input_context_and_update_screen (int client, std::vector < std::pair <uint32, String> >& helper_ic_index, uint32 current_screen);
800 } /* namespace scim */
802 #endif /* __SCIM_PANEL_AGENT_H */
805 vi:ts=4:nowrap:ai:expandtab