Add new interfaces to pass event to ise-engine-loader
[platform/core/uifw/libscl-core.git] / src / sclcore.h
1 /*
2  * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #ifndef __SCL_CORE_H__
19 #define __SCL_CORE_H__
20
21 //SCL_BEGIN_DECLS
22
23 #define Uses_SCIM_ATTRIBUTE
24 #define Uses_SCIM_UTILITY
25 #define Uses_SCIM_CONFIG_BASE
26 #define Uses_SCIM_OBJECT
27 #define Uses_SCIM_POINTER
28 #define Uses_SCIM_EVENT
29 #define Uses_SCIM_HELPER
30
31 #include <string>
32 #include <scim.h>
33 #include <sclcommon.h>
34 #include "sclcoretypes.h"
35 #include "sclcorecallback.h"
36
37 namespace scl
38 {
39
40 /* To use pimpl idiom */
41 class CSCLCoreImpl;
42
43 /**
44  * @brief The base class that provides features for a soft-keyboard
45  *
46  * This class implements all functions for working as a soft-based keyboard
47  */
48 class EXAPI CSCLCore
49 {
50 public:
51     CSCLCore(ISCLCoreEventCallback *callback);
52     ~CSCLCore();
53
54     /**
55      * @brief Request SCLCore to initialize its components.
56      *
57      * Note that the init() / prepare() / fini() functions are not expected to be called
58      * when using run() function, since they are called automatically inside run().
59      */
60     void init();
61
62     /**
63     * @brief Request SCLCore to prepare necessary resources.
64     */
65     void prepare();
66
67     /**
68     * @brief Request SCLCore to finalize its components.
69     */
70     void fini();
71
72     /**
73      * @brief Request SCLCore to start its main loop.
74      *
75      * As described above, init() / prepare() / fini() functions are called automatically when necessary
76      */
77     void run();
78
79     /**
80      * @brief Request ISF to reload all configuration.
81      */
82     void config_reload();
83
84     /**
85      * @brief Request ISF to read a integer value with given key name.
86      */
87     sclboolean config_read_int(const sclchar *name, sclint &value);
88
89     /**
90      * @brief Request ISF to read a string value with given key name.
91      */
92     sclboolean config_read_string(const sclchar *name, std::string &value);
93
94     /**
95      * @brief Request ISF to write a integer value with given key name.
96      */
97     sclboolean config_write_int(const sclchar *name, sclint value);
98
99     /**
100      * @brief Request ISF to write a string value with given key name.
101      */
102     sclboolean config_write_string(const sclchar *name, const std::string value);
103
104     /**
105      * @brief Request ISF to erase stored value with given key name.
106      */
107     sclboolean config_erase(const sclchar *name);
108
109     /**
110      * @brief Request ISF to permanently writes all changes.
111      */
112     sclboolean config_flush(void);
113
114     /**
115      * @brief Send an Event to IMEngine
116      *
117      * @param[in] ic The handle of the IMEngineInstance to receive the event.
118      *            -1 means the currently focused IMEngineInstance.
119      * @param[in] ic_uuid The UUID of the IMEngineInstance. NULL means don't match.
120      * @param[in] command The command to be sent.
121      * @param[in] value The value corresponding to the command.
122      */
123     void send_imengine_event(sclint ic, const sclchar *ic_uuid, const sclint command, const sclu32 value);
124
125     /**
126      * @brief Send a reset keyboard Event to IMEngine
127      */
128     void reset_keyboard_ise();
129
130     /**
131      * @brief Send a flush keyboard Event to IMEngine
132      */
133     void flush_keyboard_ise();
134
135     /**
136      * @brief Send a KeyEvent to ISF
137      *
138      * @param[in] ic The handle of the IMEngineInstance to receive the event.
139      *            -1 means the currently focused IMEngineInstance.
140      * @param[in] ic_uuid The UUID of the IMEngineInstance. NULL means don't match.
141      * @param[in] keycode The KeyEvent to be sent.
142      * @param[in] keymask The modifier key mask
143      */
144     void send_key_event(sclint ic, const sclchar *ic_uuid, sclu32 keycode, sclu16 keymask);
145
146     /**
147      * @brief Forward a KeyEvent to client application directly.
148      *
149      * @param[in] ic The handle of the client Input Context to receive the event.
150      *            -1 means the currently focused Input Context.
151      * @param[in] ic_uuid The UUID of the IMEngineInstance. NULL means don't match.
152      * @param[in] keycode The KeyEvent to be sent.
153      * @param[in] keymask The modifier key mask
154      */
155     void forward_key_event(sclint ic, const sclchar *ic_uuid, sclu32 keycode, sclu16 keymask);
156
157     /**
158      * @brief Commit a string to client application directly.
159      *
160      * @param[in] ic The handle of the client Input Context to receive the WideString.
161      *            -1 means the currently focused Input Context.
162      * @param[in] ic_uuid The UUID of the IMEngine used by the Input Context.
163      *            NULL means don't match.
164      * @param[in] str The UTF-8 string to be committed.
165      */
166     void commit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str);
167
168     void select_candidate(int index);
169     /**
170      * @brief Request to show preedit string.
171      *
172      * @param[in] ic The handle of the client Input Context to receive the request.
173      *            -1 means the currently focused Input Context.
174      * @param[in] ic_uuid The UUID of the IMEngine used by the Input Context.
175      *            NULL means don't match.
176      */
177     void show_preedit_string(sclint ic, const sclchar *ic_uuid);
178
179     /**
180      * @brief Request to show aux string.
181      */
182     void show_aux_string(void);
183
184     /**
185      * @brief Request to show candidate string.
186      */
187     void show_candidate_string(void);
188
189     /**
190      * @brief Request to show associate string.
191      */
192     void show_associate_string(void);
193
194     /**
195      * @brief Request to hide preedit string.
196      *
197      * @param[in] ic The handle of the client Input Context to receive the request.
198      *            -1 means the currently focused Input Context.
199      * @param[in] ic_uuid The UUID of the IMEngine used by the Input Context.
200      *            NULL means don't match.
201      */
202     void hide_preedit_string(sclint ic, const sclchar *ic_uuid);
203
204     /**
205      * @brief Request to hide aux string.
206      */
207     void hide_aux_string(void);
208
209     /**
210      * @brief Request to hide candidate string.
211      */
212     void hide_candidate_string(void);
213
214     /**
215      * @brief Request to hide associate string.
216      */
217     void hide_associate_string(void);
218
219     /**
220      * @brief Update a new string for preedit.
221      *
222      * @param[in] ic The handle of the client Input Context to receive the WideString.
223      *            -1 means the currently focused Input Context.
224      * @param[in] ic_uuid The UUID of the IMEngine used by the Input Context.
225      *            NULL means don't match.
226      * @param[in] str The UTF-8 string to be updated.
227      */
228     void update_preedit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str);
229
230     /**
231      * @brief Update a new string for preedit.
232      *
233      * @param[in] ic The handle of the client Input Context to receive the WideString.
234      *            -1 means the currently focused Input Context.
235      * @param[in] ic_uuid The UUID of the IMEngine used by the Input Context.
236      *            NULL means don't match.
237      * @param[in] str The UTF-8 string to be updated.
238      * @param[in] attrs The attribute list for preedit string.
239      */
240     void update_preedit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str, const scim::AttributeList &attrs);
241
242     /**
243      * @brief Update a cursor position in preedit string.
244      *
245      * @param[in] caret The cursor position in preedit.
246      */
247     void update_preedit_caret(sclint caret);
248
249     /**
250      * @brief Update a new string for aux.
251      *
252      * @param[in] str The string to be updated.
253      * @param[in] attrs The attribute list for aux string.
254      */
255     //void update_aux_string (const sclchar *str, const AttributeList &attrs) const;
256     void update_aux_string(const sclchar *str);
257
258     /**
259      * @brief Request to update candidate.
260      *
261      * @param[in] table The lookup table for candidate.
262      */
263     void update_candidate_string(const SclCandidateTable &table) const;
264
265     /**
266      * @brief Request to update associate.
267      *
268      * @param[in] table The lookup table for associate.
269      */
270     void update_associate_string(const SclCandidateTable &table) const;
271
272     /**
273      * @brief When the input context of ISE is changed,
274      *         ISE can call this function to notify application
275      *
276      * @param[in] type  type of event.
277      * @param[in] value value of event.
278      */
279     void update_input_context(sclu32 type, sclu32 value);
280
281     /**
282      * @brief When the geometry of ISE is changed,
283      *         ISE can call this function to notify application
284      *
285      * @param[in] x x position of ISE geometry.
286      * @param[in] y y position of ISE geometry.
287      * @param[in] width the width of ISE geometry.
288      * @param[in] height the height of ISE geometry.
289      */
290     void update_geometry(sclint x, sclint y, sclint width, sclint height);
291
292     /**
293      * @brief Request to get surrounding text asynchronously.
294      *
295      * @param[in] ic_uuid The helper ISE UUID.
296      * @param[in] maxlen_before The max length of before.
297      * @param[in] maxlen_after The max length of after.
298      */
299     void get_surrounding_text(const sclchar *ic_uuid, sclint maxlen_before, sclint maxlen_after) const;
300
301     /**
302      * @brief Request to delete surrounding text.
303      *
304      * @param[in] offset The offset for cursor position.
305      * @param[in] len The length for delete text.
306      */
307     void delete_surrounding_text(sclint offset, sclint len) const;
308
309     /**
310      * @brief Set candidate position in screen.
311      *
312      * @param[in] left The x position in screen.
313      * @param[in] top The y position in screen.
314      */
315     void set_candidate_position(sclint left, sclint top);
316
317     /**
318      * @brief Set soft candidate style.
319      *
320      * @param[in] enable The flag for soft candidate style.
321      */
322     void enable_soft_candidate(sclboolean enable);
323
324     /**
325      * @brief Request to hide candidate window.
326      */
327     void candidate_hide(void);
328
329     /**
330      * @brief Request to get candidate window size and position.
331      *
332      * @param[in] uuid The helper ISE UUID.
333      */
334     //void get_candidate_window_geometry (const String           &uuid) const;
335
336     /**
337      * @brief Set current keyboard ISE.
338      *
339      * @param[in] uuid The keyboard ISE UUID.
340      */
341     void set_keyboard_ise_by_uuid(const sclchar *uuid);
342
343     /**
344      * @brief Request to get current keyboard ISE information.
345      *
346      * @param[in] uuid The helper ISE UUID.
347      */
348     void get_keyboard_ise(const sclchar *uuid);
349
350     /**
351      * @brief Request to get uuid list of all keyboard ISEs.
352      *
353      * @param[in] uuid The helper ISE UUID.
354      */
355     //void get_keyboard_ise_list    (const String                &uuid) const;
356
357     /**
358      * @brief This API returns the pointer to main keyboard window
359      */
360     sclwindow get_main_window();
361
362     /**
363      * @brief This API updates the keyboard window's geometry information
364      */
365     void set_keyboard_size_hints(SclSize portrait, SclSize landscape);
366
367     /**
368      * @brief Requests to create an option window
369      */
370     sclwindow create_option_window();
371
372     /**
373      * @brief Requests to destroy an option window
374      */
375     void destroy_option_window(sclwindow window);
376
377     /**
378      * @brief Request to select text.
379      *
380      * @param[in] start The start cursor position in text.
381      * @param[in] end The end cursor position in text.
382      */
383     void set_selection(sclint start, sclint end);
384
385     /**
386      * @brief Send a private command to its connected editor.
387      *
388      * @param[in] command a command to be sent.
389      */
390     void send_private_command(const sclchar *command);
391
392     /**
393      * @brief Request to get surrounding text synchronously.
394      *
395      * @param[in] maxlen_before The max length of before.
396      * @param[in] maxlen_after The max length of after.
397      * @param[out] text The surrounding text.
398      * @param[out] cursor The cursor position.
399      *
400      * @return 0 on success, otherwise a negative error value
401      */
402     sclint get_surrounding_text(sclint maxlen_before, sclint maxlen_after, sclchar **text, int &cursor) const;
403
404     /**
405      * @brief Get the selected text.
406      *
407      * @param[out] text The selection text.
408      */
409     void get_selection_text(sclchar **text) const;
410
411     /**
412      * @brief Request to hide ISE.
413      */
414     void request_ise_hide() const;
415
416     /**
417      * @brief Commit a content URI to its connected editor.
418      *
419      * @param[in] content a content URL to be sent.
420      * @param[in] description a content description.
421      * @param[in] mime_types a MIME type string.
422      */
423     void commit_content(const sclchar *content, const sclchar *description, const sclchar *mime_types);
424
425     /**
426      * @brief Request to update preedit string with commit.
427      */
428     void update_preedit_string_with_commit(const sclchar *preedit, const sclchar *commit, const scim::AttributeList &attrs, sclint caret);
429
430     /**
431      * @brief Request to update recapture string.
432      */
433     void recapture_string(sclint offset, sclint len, const sclchar *preedit, const sclchar *commit, const scim::AttributeList &attrs);
434
435     /**
436      * @brief Request to update lookup table.
437      */
438     void update_lookup_table(const scim::LookupTable &table);
439
440     /**
441      * @brief Request to register properties.
442      */
443     void register_properties(const scim::PropertyList &properties);
444
445     /**
446      * @brief Request to update property.
447      */
448     void update_property(const scim::Property &property);
449
450     /**
451      * @brief Request to expand candidate.
452      */
453     void expand_candidate(void);
454
455     /**
456      * @brief Request to contract candidate.
457      */
458     void contract_candidate(void);
459
460     /**
461      * @brief Request to set candidate style.
462      */
463     void set_candidate_style(scim::ISF_CANDIDATE_PORTRAIT_LINE_T portrait_line, scim::ISF_CANDIDATE_MODE_T mode);
464
465     /**
466      * @brief Request to set floating mode.
467      *
468      * @param[in] floating_mode Floating mode or not
469      */
470     void set_floating_mode(sclboolean floating_mode);
471
472     /**
473      * @brief Request to allow the user to move floating ISE.
474      */
475     void set_floating_drag_enabled(sclboolean enabled);
476
477     /**
478      * @brief Request to defer creating window until the window object gets accessed.
479      */
480     void set_window_creation_defer_flag(sclboolean flag);
481
482
483 private:
484     CSCLCoreImpl *m_impl;
485 };
486
487 }
488
489 //SCL_END_DECLS
490
491 #endif //__SCL_CORE_H__