2 * @file scim_panel_agent_base.h
3 * @brief Defines scim::PanelAgentBase and their related types.
5 * scim::PanelAgentBase is a class used to write Panel daemons.
8 /* ISF is based on SCIM 1.4.7 and extended for supporting more mobile fitable. */
11 * Smart Common Input Method
13 * Copyright (c) 2004-2005 James Su <suzhe@tsinghua.org.cn>
14 * Copyright (c) 2012-2016 Samsung Electronics Co., Ltd.
17 * This library is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU Lesser General Public
19 * License as published by the Free Software Foundation; either
20 * version 2 of the License, or (at your option) any later version.
22 * This library is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU Lesser General Public License for more details.
27 * You should have received a copy of the GNU Lesser General Public
28 * License along with this program; if not, write to the
29 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
30 * Boston, MA 02111-1307 USA
34 #ifndef __ISF_PANEL_AGENT_BASE_H
35 #define __ISF_PANEL_AGENT_BASE_H
37 #include <scim_panel_common.h>
48 * @ingroup InputServiceFramework
49 * The accessory classes to help develop Panel daemons and FrontEnds
50 * which need to communicate with Panel daemons.
54 typedef struct _ISE_INFO {
63 typedef struct _HELPER_ISE_INFO {
64 std::vector<String> appid;
65 std::vector<String> label;
66 std::vector<uint32> is_enabled;
67 std::vector<uint32> is_preinstalled;
68 std::vector<uint32> has_option;
72 typedef struct DefaultIse {
76 DefaultIse () : type (TOOLBAR_KEYBOARD_MODE), uuid (""), name ("") { }
83 * @typedef typedef Pointer <PanelAgentBase> PanelAgentPointer;
85 * A smart pointer for scim::PanelAgentBase and its derived classes.
87 typedef Pointer <PanelAgentBase> PanelAgentPointer;
90 * @brief The class to implement all socket protocol in Panel.
92 * This class acts like a stand alone SocketServer.
93 * It has its own dedicated main loop, and will be blocked when run () is called.
94 * So run () must be called within a separated thread, in order to not block
95 * the main loop of the Panel program itself.
97 * Before calling run (), the panel must hook the callback functions to the
98 * corresponding signals.
100 * Note that, there are two special signals: lock(void) and unlock(void). These
101 * two signals are used to provide a thread lock to PanelAgent, so that PanelAgent
102 * can run correctly within a multi-threading Panel program.
104 class EXAPI PanelAgentBase : public ReferencedObject
106 class PanelAgentBaseImpl;
107 PanelAgentBaseImpl* m_impl;
109 PanelAgentBase (const PanelAgentBase&);
110 const PanelAgentBase& operator = (const PanelAgentBase&);
113 PanelAgentBase (const String& name);
114 virtual ~PanelAgentBase ();
117 * @brief Initialize this PanelAgent.
119 * @param config The name of the config module to be used by Helpers.
120 * @param display The name of display, on which the Panel should run.
121 * @param resident If this is true then this PanelAgent will keep running
122 * even if there is no more client connected.
124 * @return true if the PanelAgent is initialized correctly and ready to run.
126 virtual bool initialize (InfoManager* info_manager, const String& display, bool resident = false);
129 * @brief Check if this PanelAgent is initialized correctly and ready to run.
131 * @return true if this PanelAgent is ready to run.
133 virtual bool valid (void) const;
136 * @brief Stop this PanelAgent.
138 virtual void stop (void);
143 * @brief Notice helper ISE to focus out.
145 * @param uuid The helper ISE uuid.
147 virtual void focus_out_helper (int client, uint32 context, const String& uuid);
150 * @brief Notice helper ISE to focus in.
152 * @param uuid The helper ISE uuid.
154 virtual void focus_in_helper (int client, uint32 context, const String& uuid);
157 * @brief Notice helper ISE to show window.
159 * @param uuid The helper ISE uuid.
161 virtual void show_helper (int client, uint32 context, const String& uuid, char* data, size_t& len);
164 * @brief Notice helper ISE to hide window.
166 * @param uuid The helper ISE uuid.
168 virtual void hide_helper (int client, uint32 context, const String& uuid);
171 * @brief Reset keyboard ISE.
173 * @return true if this operation is successful, otherwise return false.
175 virtual void reset_keyboard_ise (int client, uint32 context);
178 * @brief Change the factory used by the focused IMEngineInstance object.
180 * @param uuid The uuid of the new factory.
181 * @return true if the command was sent correctly.
183 virtual void change_factory (int client, uint32 context, const String& uuid);
186 * @brief Notice Helper ISE that candidate more window is showed.
187 * @return true if the command was sent correctly.
189 virtual void candidate_more_window_show (int client, uint32 context);
192 * @brief Notice Helper ISE that candidate more window is hidden.
193 * @return true if the command was sent correctly.
195 virtual void candidate_more_window_hide (int client, uint32 context);
198 * @brief Notice Helper ISE that show candidate.
199 * @return true if the command was sent correctly.
201 virtual void helper_candidate_show (int client, uint32 context, const String& uuid);
204 * @brief Notice Helper ISE that hide candidate.
205 * @return true if the command was sent correctly.
207 virtual void helper_candidate_hide (int client, uint32 context, const String& uuid);
210 * @brief Update helper lookup table.
211 * @return true if the command was sent correctly.
213 virtual void update_helper_lookup_table (int client, uint32 context, const String& uuid, const LookupTable& table);
216 * @brief Let the focused IMEngineInstance object
217 * select a aux in current aux string.
219 * @param item The index of the selected aux.
220 * @return true if the command was sent correctly.
222 virtual void select_aux (int client, uint32 context, uint32 item);
225 * @brief Let the focused IMEngineInstance object
226 * select a candidate in current lookup table.
228 * @param item The index of the selected candidate.
229 * @return true if the command was sent correctly.
231 virtual void select_candidate (int client, uint32 context, uint32 item);
234 * @brief Let the focused IMEngineInstance object
235 * flip the LookupTable to previous page.
236 * @return true if the command was sent correctly.
238 virtual void lookup_table_page_up (int client, uint32 context);
241 * @brief Let the focused IMEngineInstance object
242 * flip the LookupTable to next page.
243 * @return true if the command was sent correctly.
245 virtual void lookup_table_page_down (int client, uint32 context);
248 * @brief Let the focused IMEngineInstance object
249 * update the page size of the LookupTable.
251 * @param size The new page size.
252 * @return true if the command was sent correctly.
254 virtual void update_lookup_table_page_size (int client, uint32 context, uint32 size);
257 * @brief Let the focused IMEngineInstance object
258 * update candidate items layout.
260 * @param row_items The items of each row.
261 * @return true if the command was sent correctly.
263 virtual void update_candidate_item_layout (int client, uint32 context, const std::vector<uint32>& row_items);
266 * @brief Let the focused IMEngineInstance object
267 * select a associate in current associate table.
269 * @param item The index of the selected associate.
270 * @return true if the command was sent correctly.
272 virtual void select_associate (int client, uint32 context, uint32 item);
275 * @brief Let the focused IMEngineInstance object
276 * flip the AssociateTable to previous page.
277 * @return true if the command was sent correctly.
279 virtual void associate_table_page_up (int client, uint32 context);
282 * @brief Let the focused IMEngineInstance object
283 * flip the AssociateTable to next page.
284 * @return true if the command was sent correctly.
286 virtual void associate_table_page_down (int client, uint32 context);
289 * @brief Let the focused IMEngineInstance object
290 * update the page size of the AssociateTable.
292 * @param size The new page size.
293 * @return true if the command was sent correctly.
295 virtual void update_associate_table_page_size (int client, uint32 context, uint32 size);
298 * @brief Inform helper ISE to update displayed candidate number.
300 * @param size The displayed candidate number.
301 * @return true if the command was sent correctly.
303 virtual void update_displayed_candidate_number (int client, uint32 context, uint32 size);
306 * @brief Trigger a property of the focused IMEngineInstance object.
308 * @param property The property key to be triggered.
309 * @return true if the command was sent correctly.
311 virtual void trigger_property (int client, uint32 context, const String& property);
314 * @brief Let all FrontEnds and Helpers reload configuration.
315 * @return true if the command was sent correctly.
317 virtual void reload_config (int client);
320 * @brief Let all FrontEnds, Helpers and this Panel exit.
321 * @return true if the command was sent correctly.
323 virtual void exit (int client, uint32 context);
326 * @brief Send candidate longpress event to ISE.
328 * @param index The candidate object index.
332 virtual void send_longpress_event (int client, uint32 context, uint32 index);
335 * @brief update_panel_event.
341 virtual void update_panel_event (int client, uint32 context, int cmd, uint32 nType, uint32 nValue);
344 * @brief update_keyboard_ise_list.
350 virtual void update_keyboard_ise_list (int client, uint32 context);
353 * @brief set_helper_mode.
359 virtual void set_helper_mode (int client, uint32 context, const String& uuid, uint32& mode);
362 * @brief set_helper_language.
368 virtual void set_helper_language (int client, uint32 context, const String& uuid, uint32& language);
371 * @brief set_helper_imdata.
377 virtual void set_helper_imdata (int client, uint32 context, const String& uuid, const char* imdata, size_t& len);
380 * @brief set_helper_return_key_type.
386 virtual void set_helper_return_key_type (int client, uint32 context, const String& uuid, uint32 type);
389 * @brief get_helper_return_key_type.
395 virtual void get_helper_return_key_type (int client, uint32 context, const String& uuid, _OUT_ uint32& type);
398 * @brief set_helper_return_key_disable.
404 virtual void set_helper_return_key_disable (int client, uint32 context, const String& uuid, uint32 disabled);
407 * @brief get_helper_return_key_disable.
413 virtual void get_helper_return_key_disable (int client, uint32 context, const String& uuid, _OUT_ uint32& disabled);
416 * @brief set_helper_layout.
422 virtual void set_helper_layout (int client, uint32 context, const String& uuid, uint32& layout);
425 * @brief set_helper_input_mode.
431 virtual void set_helper_input_mode (int client, uint32 context, const String& uuid, uint32& mode);
434 * @brief set_helper_input_hint.
440 virtual void set_helper_input_hint (int client, uint32 context, const String& uuid, uint32& hint);
443 * @brief set_helper_bidi_direction.
449 virtual void set_helper_bidi_direction (int client, uint32 context, const String& uuid, uint32& direction);
452 * @brief set_helper_caps_mode.
458 virtual void set_helper_caps_mode (int client, uint32 context, const String& uuid, uint32& mode);
461 * @brief show_helper_option_window.
467 virtual void show_helper_option_window (int client, uint32 context, const String& uuid);
470 * @brief resume_helper_option_window.
476 virtual void resume_helper_option_window (int client, uint32 context, const String& uuid);
479 * @brief set_helper_keyboard_mode.
485 virtual void set_helper_keyboard_mode (int client, uint32 context, const String& uuid, uint32& mode);
488 * @brief set_helper_prediction_hint.
494 virtual void set_helper_prediction_hint (int client, uint32 context, const String& uuid, String& prediction_hint);
497 * @brief set_helper_mime_type.
503 virtual void set_helper_mime_type (int client, uint32 context, const String& uuid, String& mime_type);
506 * @brief process_key_event.
512 virtual bool process_key_event (int client, uint32 context, const String& uuid, KeyEvent& key, uint32 serial);
515 * @brief get_helper_geometry.
521 virtual bool get_helper_geometry (int client, uint32 context, String& uuid, _OUT_ struct rectinfo& info);
524 * @brief get_helper_imdata.
530 virtual void get_helper_imdata (int client, uint32 context, String& uuid, _OUT_ char** imdata, _OUT_ size_t& len);
533 * @brief get_helper_layout.
539 virtual void get_helper_layout (int client, uint32 context, String& uuid, uint32& layout);
542 * @brief get_ise_language_locale.
548 virtual void get_ise_language_locale (int client, uint32 context, String& uuid, _OUT_ char** data, _OUT_ size_t& len);
551 * @brief check_option_window.
557 virtual void check_option_window (int client, uint32 context, String& uuid, _OUT_ uint32& avail);
560 * @brief reset_ise_option.
566 virtual void reset_ise_option (int client, uint32 context);
569 * @brief reset_helper_context.
575 virtual void reset_helper_context (int client, uint32 context, const String& uuid);
578 * @brief socket_update_surrounding_text.
584 virtual void socket_update_surrounding_text (int client, uint32 context, const String& uuid, String& text, uint32 cursor);
587 * @brief socket_remoteinput_focus_in.
593 virtual void socket_remoteinput_focus_in (int client);
596 * @brief socket_remoteinput_focus_out.
602 virtual void socket_remoteinput_focus_out (int client);
605 * @brief socket_remoteinput_entry_metadata.
611 virtual void socket_remoteinput_entry_metadata (int client, uint32 hint, uint32 layout, int variation, uint32 autocapital_type, int return_key_disabled);
614 * @brief socket_remoteinput_surrounding_text.
620 virtual void socket_remoteinput_surrounding_text (int client, String& text, uint32 cursor);
623 * @brief socket_remoteinput_input_resource.
629 virtual void socket_remoteinput_input_resource (int client, uint32 input_resource);
632 * @brief socket_update_selection.
638 virtual void socket_update_selection (int client, uint32 context, String& uuid, String text);
641 * @brief socket_get_keyboard_ise_list.
647 virtual void socket_get_keyboard_ise_list (int client, uint32 context, const String& uuid, std::vector<String>& list);
650 * @brief socket_get_candidate_ui.
656 virtual void socket_get_candidate_ui (int client, uint32 context, const String& uuid, int style, int mode);
659 * @brief socket_get_candidate_geometry.
665 virtual void socket_get_candidate_geometry (int client, uint32 context, const String& uuid, struct rectinfo& info);
668 * @brief socket_get_keyboard_ise.
674 virtual void socket_get_keyboard_ise (int client, uint32 context, const String& uuid, String& ise_name, String& ise_uuid);
677 * @brief socket_start_helper.
683 virtual void socket_start_helper (int client, uint32 context, const String& ic_uuid);
686 * @brief helper_detach_input_context.
692 virtual void helper_detach_input_context (int client, uint32 context, const String& ic_uuid);
695 * @brief helper_process_imengine_event.
701 virtual void helper_process_imengine_event (int client, uint32 context, const String& ic_uuid, const Transaction& nest_transaction);
704 * @brief process_helper_event.
710 virtual void process_helper_event (int client, uint32 context, String target_uuid, String active_uuid, Transaction& nest_trans);
713 * @brief socket_helper_key_event.
719 virtual void socket_helper_key_event (int client, uint32 context, int cmd , KeyEvent& key);
722 * @brief socket_helper_get_surrounding_text.
728 virtual void socket_helper_get_surrounding_text (int client, uint32 context, uint32 maxlen_before, uint32 maxlen_after);
731 * @brief socket_helper_delete_surrounding_text.
737 virtual void socket_helper_delete_surrounding_text (int client, uint32 context, uint32 offset, uint32 len);
740 * @brief socket_helper_get_selection.
746 virtual void socket_helper_get_selection (int client, uint32 context);
749 * @brief socket_helper_set_selection.
755 virtual void socket_helper_set_selection (int client, uint32 context, uint32 start, uint32 end);
758 * @brief update_ise_input_context.
764 virtual void update_ise_input_context (int client, uint32 context, uint32 type, uint32 value);
767 * @brief send_private_command.
773 virtual void send_private_command (int client, uint32 context, const String& command);
776 * @brief helper_all_update_spot_location.
782 virtual void helper_all_update_spot_location (int client, uint32 context, String uuid, int x, int y);
785 * @brief helper_all_update_cursor_position.
791 virtual void helper_all_update_cursor_position (int client, uint32 context, String uuid, int cursor_pos);
794 * @brief helper_all_update_screen.
800 virtual void helper_all_update_screen (int client, uint32 context, String uuid, int screen);
803 * @brief commit_string.
809 virtual void commit_string (int client, uint32 context, const WideString& wstr);
812 * @brief show_preedit_string.
818 virtual void show_preedit_string (int client, uint32 context);
821 * @brief hide_preedit_string.
827 virtual void hide_preedit_string (int client, uint32 context);
830 * @brief update_preedit_string.
836 virtual void update_preedit_string (int client, uint32 context, WideString preedit, WideString commit, AttributeList& attrs, uint32 caret);
839 * @brief update_preedit_caret.
845 virtual void update_preedit_caret (int client, uint32 context, uint32 caret);
848 * @brief recapture_string.
854 virtual void recapture_string (int client, uint32 context, int offset, int len, WideString preedit, WideString commit, AttributeList& attrs);
857 * @brief attach_input_context and update_screen.
863 virtual void helper_attach_input_context_and_update_screen (int client, std::vector < std::pair <uint32, String> >& helper_ic_index, uint32 current_screen);
866 * @brief hide_helper_ise.
872 virtual void hide_helper_ise (int client, uint32 context);
875 * @brief process_input_device_event.
881 virtual bool process_input_device_event (int client, uint32 context, const String& uuid, uint32 type, const char *data, size_t len, _OUT_ uint32& result);
884 * @brief process_key_event_done.
890 virtual void process_key_event_done (int client, uint32 context, KeyEvent &key, uint32 ret, uint32 serial);
893 * @brief request_ise_hide.
899 virtual void request_ise_hide (int client, uint32 context);
902 * @brief set_autocapital_type.
908 virtual void set_autocapital_type (int client, uint32 context, String uuid, int mode);
911 * @brief update_ise_geometry.
917 virtual void update_ise_geometry (int client, uint32 context, uint32 x, uint32 y, uint32 width, uint32 height);
920 * @brief remote_update_preedit_string.
927 virtual void remote_update_preedit_string (int client, uint32 context, const WideString str, const WideString commit, const AttributeList &attrs, uint32 caret);
930 * @brief remote_send_key_event.
936 virtual void remote_send_key_event (int client, uint32 context, const KeyEvent &key);
939 * @brief remote_forward_key_event.
945 virtual void remote_forward_key_event (int client, uint32 context, const KeyEvent &key);
948 * @brief remote_commit_string.
954 virtual void remote_commit_string (int client, uint32 context, const WideString& wstr);
957 * @brief remote_delete_surrounding_text.
963 virtual void remote_delete_surrounding_text (int client, uint32 context, uint32 offset, uint32 len);
966 * @brief set_prediction_allow.
972 virtual void set_prediction_allow (int client, uint32 context, String uuid, int mode);
975 * @brief send_fail_reply.
981 virtual void send_fail_reply (int client);
984 * @brief commit_content.
990 virtual void commit_content (int client, uint32 context, const String& content, const String& description, const String& mime_types);
995 } /* namespace scim */
997 #endif /* __ISF_PANEL_AGENT_BASE_H */
1000 vi:ts=4:nowrap:ai:expandtab