Added interface for delivering floating IME requests
[platform/core/uifw/isf.git] / ism / src / isf_panel_agent_manager.h
1 /**
2  * @file isf_panel_agent_manager.h
3  * @brief Defines scim::PanelAgentManager and their related types.
4  *
5  * scim::PanelAgentManager is a class used to manage PanelAgent object.
6  */
7
8 /* ISF is based on SCIM 1.4.7 and extended for supporting more mobile fitable. */
9
10 /*
11  * Smart Common Input Method
12  *
13  * Copyright (c) 2004-2005 James Su <suzhe@tsinghua.org.cn>
14  * Copyright (c) 2012-2016 Samsung Electronics Co., Ltd.
15  *
16  *
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.
21  *
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.
26  *
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
31  *
32  */
33
34 #ifndef __ISF_PANEL_AGENT_MANAGER_H
35 #define __ISF_PANEL_AGENT_MANAGER_H
36
37 #include <scim_panel_common.h>
38
39 #ifndef _OUT_
40 #define _OUT_
41 #endif
42
43 namespace scim
44 {
45
46
47 /**
48  * @brief The class to implement all socket protocol in Panel.
49  *
50  * This class acts like a stand alone SocketServer.
51  * It has its own dedicated main loop, and will be blocked when run () is called.
52  * So run () must be called within a separated thread, in order to not block
53  * the main loop of the Panel program itself.
54  *
55  * Before calling run (), the panel must hook the callback functions to the
56  * corresponding signals.
57  *
58  * Note that, there are two special signals: lock(void) and unlock(void). These
59  * two signals are used to provide a thread lock to PanelAgent, so that PanelAgent
60  * can run correctly within a multi-threading Panel program.
61  */
62 class EXAPI PanelAgentManager
63 {
64     class PanelAgentManagerImpl;
65     PanelAgentManagerImpl* m_impl;
66
67     PanelAgentManager (const PanelAgentManager&);
68     const PanelAgentManager& operator = (const PanelAgentManager&);
69
70 public:
71     PanelAgentManager ();
72     ~PanelAgentManager ();
73
74     /**
75      * @brief Initialize this PanelAgent.
76      *
77      * @param config The name of the config module to be used by Helpers.
78      * @param display The name of display, on which the Panel should run.
79      * @param resident If this is true then this PanelAgent will keep running
80      *                 even if there is no more client connected.
81      *
82      * @return true if the PanelAgent is initialized correctly and ready to run.
83      */
84     bool initialize (InfoManager* info_manager, const ConfigPointer& config, const String& display, bool resident = false);
85
86     /**
87      * @brief Check if this PanelAgent is initialized correctly and ready to run.
88      *
89      * @return true if this PanelAgent is ready to run.
90      */
91     bool valid (void) const;
92
93     /**
94      * @brief Stop this PanelAgent.
95      */
96     void stop (void);
97
98 public:
99
100     /**
101      * @brief Notice helper ISE to focus out.
102      *
103      * @param uuid The helper ISE uuid.
104      */
105     void focus_out_helper (int client, uint32 context, const String& uuid);
106
107     /**
108      * @brief Notice helper ISE to focus in.
109      *
110      * @param uuid The helper ISE uuid.
111      */
112     void focus_in_helper (int client, uint32 context, const String& uuid);
113
114     /**
115      * @brief Notice helper ISE to show window.
116      *
117      * @param uuid The helper ISE uuid.
118      */
119     void show_helper (int client, uint32 context, const String& uuid, char* data, size_t& len);
120
121     /**
122      * @brief Notice helper ISE to hide window.
123      *
124      * @param uuid The helper ISE uuid.
125      */
126     void hide_helper (int client, uint32 context, const String& uuid);
127
128     /**
129      * @brief Reset keyboard ISE.
130      *
131      * @return true if this operation is successful, otherwise return false.
132      */
133     void reset_keyboard_ise (int client, uint32 context);
134
135     /**
136      * @brief Change the factory used by the focused IMEngineInstance object.
137      *
138      * @param uuid The uuid of the new factory.
139      * @return true if the command was sent correctly.
140      */
141     void change_factory (int client, uint32 context, const String&  uuid);
142
143     /**
144      * @brief Notice Helper ISE that candidate more window is showed.
145      * @return true if the command was sent correctly.
146      */
147     void candidate_more_window_show (int client, uint32 context);
148
149     /**
150      * @brief Notice Helper ISE that candidate more window is hidden.
151      * @return true if the command was sent correctly.
152      */
153     void candidate_more_window_hide (int client, uint32 context);
154
155     /**
156      * @brief Notice Helper ISE that show candidate.
157      * @return true if the command was sent correctly.
158      */
159     void helper_candidate_show (int client, uint32 context, const String&  uuid);
160
161     /**
162      * @brief Notice Helper ISE that hide candidate.
163      * @return true if the command was sent correctly.
164      */
165     void helper_candidate_hide (int client, uint32 context, const String&  uuid);
166
167     /**
168      * @brief Update helper lookup table.
169      * @return true if the command was sent correctly.
170      */
171     void update_helper_lookup_table (int client, uint32 context, const String&  uuid, const LookupTable& table);
172
173     /**
174      * @brief Let the focused IMEngineInstance object
175      *        select a aux in current aux string.
176      *
177      * @param item The index of the selected aux.
178      * @return true if the command was sent correctly.
179      */
180     void select_aux (int client, uint32 context, uint32 item);
181
182     /**
183      * @brief Let the focused IMEngineInstance object
184      *        select a candidate in current lookup table.
185      *
186      * @param item The index of the selected candidate.
187      * @return true if the command was sent correctly.
188      */
189     void select_candidate (int client, uint32 context, uint32 item);
190
191     /**
192      * @brief Let the focused IMEngineInstance object
193      *        flip the LookupTable to previous page.
194      * @return true if the command was sent correctly.
195      */
196     void lookup_table_page_up (int client, uint32 context);
197
198     /**
199      * @brief Let the focused IMEngineInstance object
200      *        flip the LookupTable to next page.
201      * @return true if the command was sent correctly.
202      */
203     void lookup_table_page_down (int client, uint32 context);
204
205     /**
206      * @brief Let the focused IMEngineInstance object
207      *        update the page size of the LookupTable.
208      *
209      * @param size The new page size.
210      * @return true if the command was sent correctly.
211      */
212     void update_lookup_table_page_size (int client, uint32 context, uint32 size);
213
214     /**
215      * @brief Let the focused IMEngineInstance object
216      *        update candidate items layout.
217      *
218      * @param row_items The items of each row.
219      * @return true if the command was sent correctly.
220      */
221     void update_candidate_item_layout (int client, uint32 context, const std::vector<uint32>& row_items);
222
223     /**
224      * @brief Let the focused IMEngineInstance object
225      *        select a associate in current associate table.
226      *
227      * @param item The index of the selected associate.
228      * @return true if the command was sent correctly.
229      */
230     void select_associate (int client, uint32 context, uint32 item);
231
232     /**
233      * @brief Let the focused IMEngineInstance object
234      *        flip the AssociateTable to previous page.
235      * @return true if the command was sent correctly.
236      */
237     void associate_table_page_up (int client, uint32 context);
238
239     /**
240      * @brief Let the focused IMEngineInstance object
241      *        flip the AssociateTable to next page.
242      * @return true if the command was sent correctly.
243      */
244     void associate_table_page_down (int client, uint32 context);
245
246     /**
247      * @brief Let the focused IMEngineInstance object
248      *        update the page size of the AssociateTable.
249      *
250      * @param size The new page size.
251      * @return true if the command was sent correctly.
252      */
253     void update_associate_table_page_size (int client, uint32 context, uint32 size);
254
255     /**
256      * @brief Inform helper ISE to update displayed candidate number.
257      *
258      * @param size The displayed candidate number.
259      * @return true if the command was sent correctly.
260      */
261     void update_displayed_candidate_number (int client, uint32 context, uint32 size);
262
263     /**
264      * @brief Trigger a property of the focused IMEngineInstance object.
265      *
266      * @param property The property key to be triggered.
267      * @return true if the command was sent correctly.
268      */
269     void trigger_property (int client, uint32 context, const String&  property);
270
271     /**
272      * @brief Let all FrontEnds and Helpers reload configuration.
273      * @return true if the command was sent correctly.
274      */
275     void reload_config (int client);
276
277     /**
278      * @brief Let all FrontEnds, Helpers and this Panel exit.
279      * @return true if the command was sent correctly.
280      */
281     void exit (int client, uint32 context);
282
283     /**
284      * @brief Send candidate longpress event to ISE.
285      *
286      * @param type The candidate object type.
287      * @param index The candidate object index.
288      *
289      * @return none.
290      */
291     void send_longpress_event (int client, uint32 context, uint32 index);
292     void update_panel_event (int id,  uint32 contextid, int cmd, uint32 nType, uint32 nValue);
293     void update_keyboard_ise_list (int id, uint32 contextid);
294     void set_helper_mode (int client, uint32 context, const String& uuid, uint32& mode);
295     void set_helper_language (int client, uint32 context, const String& uuid, uint32& language);
296     void set_helper_imdata (int client, uint32 context, const String& uuid, const char* imdata, size_t& len);
297     void set_helper_return_key_type (int client, uint32 context, const String& uuid, uint32 type);
298     void get_helper_return_key_type (int client, uint32 context, const String& uuid, _OUT_ uint32& type);
299     void set_helper_return_key_disable (int client, uint32 context, const String& uuid, uint32 disabled);
300     void get_helper_return_key_disable (int client, uint32 context, const String& uuid, _OUT_ uint32& disabled);
301     void set_helper_layout (int client, uint32 context, const String& uuid, uint32& layout);
302     void set_helper_input_mode (int client, uint32 context, const String& uuid, uint32& mode);
303     void set_helper_input_hint (int client, uint32 context, const String& uuid, uint32& hint);
304     void set_helper_bidi_direction (int client, uint32 context, const String& uuid, uint32& direction);
305     void set_helper_caps_mode (int client, uint32 context, const String& uuid, uint32& mode);
306     void show_helper_option_window (int client, uint32 context, const String& uuid, uint32 caller_pid, uint32 ime_pid);
307     void resume_helper_option_window (int client, uint32 context, const String& uuid);
308     void set_transient_for (uint32 caller_pid, uint32 ime_pid);
309     void set_helper_keyboard_mode (int client, uint32 context, const String& uuid, uint32& mode);
310     void set_helper_prediction_hint (int client, uint32 context, const String& uuid, String& prediction_hint);
311     void set_helper_prediction_hint_data (int id, uint32 context_id, const String& uuid, String& key, String& value);
312     void set_helper_optimization_hint (int id, uint32 context_id, const String& uuid, uint32 hint);
313     void set_helper_mime_type (int client, uint32 context, const String& uuid, String& mime_type);
314     void finalize_content_helper (int client, uint32 context, const String& uuid, String& text, uint32& cursor_pos);
315     bool process_key_event (int client, uint32 context, const String& uuid, KeyEvent& key, uint32 serial, uint32 keycode);
316     bool get_helper_geometry (int client, uint32 context, String& uuid, _OUT_ struct rectinfo& info);
317     void get_helper_imdata (int client, uint32 context, String& uuid, _OUT_ char** imdata, _OUT_ size_t& len);
318     void get_helper_layout (int client, uint32 context, String& uuid, uint32& layout);
319     void get_ise_language_locale (int client, uint32 context, String& uuid, _OUT_ char** data, _OUT_ size_t& len);
320     void check_option_window (int client, uint32 context, String& uuid, _OUT_ uint32& avail);
321     void reset_ise_option (int client_id, uint32 context);
322     void reset_helper_context (int client_id, uint32 context, const String& uuid);
323     void socket_update_surrounding_text (int client, uint32 context, const String& uuid, String& text, uint32 cursor);
324     void socket_remoteinput_focus_in (int client);
325     void socket_remoteinput_focus_out (int client);
326     void socket_remoteinput_entry_metadata (int client, uint32 hint, uint32 layout, int variation, uint32 autocapital_type, int return_key_disabled, uint32 return_key_type);
327     void socket_remoteinput_surrounding_text (int client, String& text, uint32 cursor);
328     void socket_remoteinput_input_resource (int client, uint32 input_resource);
329     void socket_update_selection (int client, uint32 context, String& uuid, String text);
330     void socket_get_keyboard_ise_list (int client, uint32 context, const String& uuid, std::vector<String>& list);
331     void socket_get_candidate_ui (int client, uint32 context, const String& uuid,  int style,  int mode);
332     void socket_get_candidate_geometry (int client, uint32 context, const String& uuid, struct rectinfo& info);
333     void socket_get_keyboard_ise (int client, uint32 context, const String& uuid, String& ise_name, String& ise_uuid);
334     void socket_start_helper (int client, uint32 context, const String& ic_uuid);
335     void helper_detach_input_context (int client, uint32 context, const String& ic_uuid);
336     void helper_process_imengine_event (int client, uint32 context, const String& ic_uuid, const Transaction& nest_transaction);
337     void process_helper_event (int client, uint32 context, String target_uuid, String active_uuid, Transaction& nest_trans);
338     void socket_helper_key_event (int client, uint32 context, int cmd , KeyEvent& key);
339     void socket_helper_get_surrounding_text (int client, uint32 context_id, uint32 maxlen_before, uint32 maxlen_after);
340     void socket_helper_delete_surrounding_text (int client, uint32 context_id, uint32 offset, uint32 len);
341     void socket_helper_get_selection (int client, uint32 context_id);
342     void socket_helper_set_selection (int client, uint32 context_id, uint32 start, uint32 end);
343     void update_ise_input_context (int focused_client, uint32 focused_context, uint32 type, uint32 value);
344     void update_ise_language_locale (int focused_client, uint32 focused_context, String locale);
345     void send_private_command (int    focused_client, uint32 focused_context, String command);
346     void commit_content (int    focused_client, uint32 focused_context, String content, String description, String mime_types);
347     void helper_all_update_spot_location (int client_id, uint32 context_id, String uuid, int x, int y);
348     void helper_all_update_cursor_position (int client_id, uint32 context_id, String uuid, int cursor_pos);
349     void helper_all_update_screen (int client_id, uint32 context_id, String uuid, int screen);
350     void commit_string (int target_client, uint32  target_context, const WideString& wstr);
351     void show_preedit_string (int target_client, uint32  target_context);
352     void hide_preedit_string (int target_client, uint32  target_context);
353     void update_preedit_string (int target_client, uint32  target_context, WideString preedit, WideString commit, AttributeList& attrs, uint32 caret);
354     void update_preedit_caret (int focused_client, uint32 focused_context, uint32 caret);
355     void recapture_string (int target_client, uint32 target_context, int offset, int len, WideString preedit, WideString commit, AttributeList& attrs);
356     void helper_attach_input_context_and_update_screen (int client, std::vector < std::pair <uint32, String> >& helper_ic_index, uint32 current_screen);
357     void hide_helper_ise (int id, uint32 context);
358     bool process_input_device_event(int client, uint32 context, const String& uuid, uint32 type, const char *data, size_t len, _OUT_ uint32& result);
359     void process_key_event_done(int client, uint32 context, KeyEvent &key, uint32 ret, uint32 serial);
360     void request_ise_hide(int client, uint32 context);
361     void set_autocapital_type(int id, uint32 context_id, String uuid, int mode);
362     void update_ise_geometry(int id, uint32 context_id, uint32 x, uint32 y, uint32 width, uint32 height);
363     void remote_update_preedit_string (int target_client, uint32  target_context, const WideString str, const WideString commit, const AttributeList &attrs, uint32 caret);
364     void remote_send_key_event (int target_client, uint32  target_context, const KeyEvent &key);
365     void remote_forward_key_event (int target_client, uint32  target_context, const KeyEvent &key);
366     void remote_commit_string (int target_client, uint32  target_context, const WideString& wstr);
367     void remote_delete_surrounding_text (int client, uint32 context_id, uint32 offset, uint32 len);
368     void set_prediction_allow (int id, uint32 context_id, String uuid, int mode);
369     void send_fail_reply (int client);
370     void update_entry_metadata(int client, uint32 context_id);
371     void request_ise_reshow(int client, uint32 context_id);
372     void set_floating_mode (int client, uint32 context_id, uint32 floating_mode);
373     void set_floating_drag_enabled (int client, uint32 context_id, uint32 enabled);
374 };
375
376 /**  @} */
377
378 } /* namespace scim */
379
380 #endif /* __ISF_PANEL_AGENT_MANAGER_H */
381
382 /*
383 vi:ts=4:nowrap:ai:expandtab
384 */