1ab472341d8f1042ed90c2ae6e31c8b147d1e0d8
[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
25 #include <string>
26 #include <scim.h>
27 #include <sclcommon.h>
28 #include "sclcoretypes.h"
29 #include "sclcorecallback.h"
30
31 namespace scl
32 {
33
34 /* To use pimpl idiom */
35 class CSCLCoreImpl;
36
37 /**
38  * @brief The base class that provides features for a soft-keyboard
39  *
40  * This class implements all functions for working as a soft-based keyboard
41  */
42 class EXAPI CSCLCore
43 {
44 public:
45     CSCLCore(ISCLCoreEventCallback *callback);
46     ~CSCLCore();
47
48     void run();
49
50     /**
51      * @brief Request ISF to reload all configuration.
52      */
53     void config_reload();
54
55     /**
56      * @brief Request ISF to read a integer value with given key name.
57      */
58     sclboolean config_read_int(const sclchar *name, sclint &value);
59
60     /**
61      * @brief Request ISF to read a string value with given key name.
62      */
63     sclboolean config_read_string(const sclchar *name, std::string &value);
64
65     /**
66      * @brief Request ISF to write a integer value with given key name.
67      */
68     sclboolean config_write_int(const sclchar *name, sclint value);
69
70     /**
71      * @brief Request ISF to write a string value with given key name.
72      */
73     sclboolean config_write_string(const sclchar *name, const std::string value);
74
75     /**
76      * @brief Request ISF to erase stored value with given key name.
77      */
78     sclboolean config_erase(const sclchar *name);
79
80     /**
81      * @brief Request ISF to permanently writes all changes.
82      */
83     sclboolean config_flush(void);
84
85     /**
86      * @brief Send an Event to IMEngine
87      *
88      * @param[in] ic The handle of the IMEngineInstance to receive the event.
89      *            -1 means the currently focused IMEngineInstance.
90      * @param[in] ic_uuid The UUID of the IMEngineInstance. NULL means don't match.
91      * @param[in] command The command to be sent.
92      * @param[in] value The value corresponding to the command.
93      */
94     void send_imengine_event(sclint ic, const sclchar *ic_uuid, const sclint command, const sclu32 value);
95
96     /**
97      * @brief Send a reset keyboard Event to IMEngine
98      */
99     void reset_keyboard_ise();
100
101     /**
102      * @brief Send a flush keyboard Event to IMEngine
103      */
104     void flush_keyboard_ise();
105
106     /**
107      * @brief Send a KeyEvent to ISF
108      *
109      * @param[in] ic The handle of the IMEngineInstance to receive the event.
110      *            -1 means the currently focused IMEngineInstance.
111      * @param[in] ic_uuid The UUID of the IMEngineInstance. NULL means don't match.
112      * @param[in] keycode The KeyEvent to be sent.
113      * @param[in] keymask The modifier key mask
114      */
115     void send_key_event(sclint ic, const sclchar *ic_uuid, sclu32 keycode, sclu16 keymask);
116
117     /**
118      * @brief Forward a KeyEvent to client application directly.
119      *
120      * @param[in] ic The handle of the client Input Context to receive the event.
121      *            -1 means the currently focused Input Context.
122      * @param[in] ic_uuid The UUID of the IMEngineInstance. NULL means don't match.
123      * @param[in] keycode The KeyEvent to be sent.
124      * @param[in] keymask The modifier key mask
125      */
126     void forward_key_event(sclint ic, const sclchar *ic_uuid, sclu32 keycode, sclu16 keymask);
127
128     /**
129      * @brief Commit a string to client application directly.
130      *
131      * @param[in] ic The handle of the client Input Context to receive the WideString.
132      *            -1 means the currently focused Input Context.
133      * @param[in] ic_uuid The UUID of the IMEngine used by the Input Context.
134      *            NULL means don't match.
135      * @param[in] str The UTF-8 string to be committed.
136      */
137     void commit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str);
138
139     void select_candidate(int index);
140     /**
141      * @brief Request to show preedit string.
142      *
143      * @param[in] ic The handle of the client Input Context to receive the request.
144      *            -1 means the currently focused Input Context.
145      * @param[in] ic_uuid The UUID of the IMEngine used by the Input Context.
146      *            NULL means don't match.
147      */
148     void show_preedit_string(sclint ic, const sclchar *ic_uuid);
149
150     /**
151      * @brief Request to show aux string.
152      */
153     void show_aux_string(void);
154
155     /**
156      * @brief Request to show candidate string.
157      */
158     void show_candidate_string(void);
159
160     /**
161      * @brief Request to show associate string.
162      */
163     void show_associate_string(void);
164
165     /**
166      * @brief Request to hide preedit string.
167      *
168      * @param[in] ic The handle of the client Input Context to receive the request.
169      *            -1 means the currently focused Input Context.
170      * @param[in] ic_uuid The UUID of the IMEngine used by the Input Context.
171      *            NULL means don't match.
172      */
173     void hide_preedit_string(sclint ic, const sclchar *ic_uuid);
174
175     /**
176      * @brief Request to hide aux string.
177      */
178     void hide_aux_string(void);
179
180     /**
181      * @brief Request to hide candidate string.
182      */
183     void hide_candidate_string(void);
184
185     /**
186      * @brief Request to hide associate string.
187      */
188     void hide_associate_string(void);
189
190     /**
191      * @brief Update a new string for preedit.
192      *
193      * @param[in] ic The handle of the client Input Context to receive the WideString.
194      *            -1 means the currently focused Input Context.
195      * @param[in] ic_uuid The UUID of the IMEngine used by the Input Context.
196      *            NULL means don't match.
197      * @param[in] str The UTF-8 string to be updated.
198      */
199     void update_preedit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str);
200
201     /**
202      * @brief Update a new string for preedit.
203      *
204      * @param[in] ic The handle of the client Input Context to receive the WideString.
205      *            -1 means the currently focused Input Context.
206      * @param[in] ic_uuid The UUID of the IMEngine used by the Input Context.
207      *            NULL means don't match.
208      * @param[in] str The UTF-8 string to be updated.
209      * @param[in] attrs The attribute list for preedit string.
210      */
211     void update_preedit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str, const scim::AttributeList &attrs);
212
213     /**
214      * @brief Update a new string for aux.
215      *
216      * @param[in] str The string to be updated.
217      * @param[in] attrs The attribute list for aux string.
218      */
219     //void update_aux_string (const sclchar *str, const AttributeList &attrs) const;
220     void update_aux_string(const sclchar *str);
221
222     /**
223      * @brief Request to update candidate.
224      *
225      * @param[in] table The lookup table for candidate.
226      */
227     void update_candidate_string(const SclCandidateTable &table) const;
228
229     /**
230      * @brief Request to update associate.
231      *
232      * @param[in] table The lookup table for associate.
233      */
234     void update_associate_string(const SclCandidateTable &table) const;
235
236     /**
237      * @brief When the input context of ISE is changed,
238      *         ISE can call this function to notify application
239      *
240      * @param[in] type  type of event.
241      * @param[in] value value of event.
242      */
243     void update_input_context(sclu32 type, sclu32 value);
244
245     /**
246      * @brief When the geometry of ISE is changed,
247      *         ISE can call this function to notify application
248      *
249      * @param[in] x x position of ISE geometry.
250      * @param[in] y y position of ISE geometry.
251      * @param[in] width the width of ISE geometry.
252      * @param[in] height the height of ISE geometry.
253      */
254     void update_geometry(sclint x, sclint y, sclint width, sclint height);
255
256     /**
257      * @brief Request to get surrounding text asynchronously.
258      *
259      * @param[in] ic_uuid The helper ISE UUID.
260      * @param[in] maxlen_before The max length of before.
261      * @param[in] maxlen_after The max length of after.
262      */
263     void get_surrounding_text(const sclchar *ic_uuid, sclint maxlen_before, sclint maxlen_after) const;
264
265     /**
266      * @brief Request to delete surrounding text.
267      *
268      * @param[in] offset The offset for cursor position.
269      * @param[in] len The length for delete text.
270      */
271     void delete_surrounding_text(sclint offset, sclint len) const;
272
273     /**
274      * @brief Set candidate position in screen.
275      *
276      * @param[in] left The x position in screen.
277      * @param[in] top The y position in screen.
278      */
279     void set_candidate_position(sclint left, sclint top);
280
281     /**
282      * @brief Set soft candidate style.
283      *
284      * @param[in] enable The flag for soft candidate style.
285      */
286     void enable_soft_candidate(sclboolean enable);
287
288     /**
289      * @brief Request to hide candidate window.
290      */
291     void candidate_hide(void);
292
293     /**
294      * @brief Request to get candidate window size and position.
295      *
296      * @param[in] uuid The helper ISE UUID.
297      */
298     //void get_candidate_window_geometry (const String           &uuid) const;
299
300     /**
301      * @brief Set current keyboard ISE.
302      *
303      * @param[in] uuid The keyboard ISE UUID.
304      */
305     void set_keyboard_ise_by_uuid(const sclchar *uuid);
306
307     /**
308      * @brief Request to get current keyboard ISE information.
309      *
310      * @param[in] uuid The helper ISE UUID.
311      */
312     void get_keyboard_ise(const sclchar *uuid);
313
314     /**
315      * @brief Request to get uuid list of all keyboard ISEs.
316      *
317      * @param[in] uuid The helper ISE UUID.
318      */
319     //void get_keyboard_ise_list    (const String                &uuid) const;
320
321     /**
322      * @brief This API returns the pointer to main keyboard window
323      */
324     sclwindow get_main_window();
325
326     /**
327      * @brief This API updates the keyboard window's geometry information
328      */
329     void set_keyboard_size_hints(SclSize portrait, SclSize landscape);
330
331     /**
332      * @brief Requests to create an option window
333      */
334     sclwindow create_option_window();
335
336     /**
337      * @brief Requests to destroy an option window
338      */
339     void destroy_option_window(sclwindow window);
340
341     /**
342      * @brief Request to select text.
343      *
344      * @param[in] start The start cursor position in text.
345      * @param[in] end The end cursor position in text.
346      */
347     void set_selection(sclint start, sclint end);
348
349     /**
350      * @brief Send a private command to its connected editor.
351      *
352      * @param[in] command a command to be sent.
353      */
354     void send_private_command(const sclchar *command);
355
356     /**
357      * @brief Request to get surrounding text synchronously.
358      *
359      * @param[in] maxlen_before The max length of before.
360      * @param[in] maxlen_after The max length of after.
361      * @param[out] text The surrounding text.
362      * @param[out] cursor The cursor position.
363      *
364      * @return 0 on success, otherwise a negative error value
365      */
366     sclint get_surrounding_text(sclint maxlen_before, sclint maxlen_after, sclchar **text, int &cursor) const;
367
368     /**
369      * @brief Get the selected text.
370      *
371      * @param[out] text The surrounding text.
372      */
373     void get_selection_text(sclchar **text) const;
374
375     /**
376      * @brief Request to hide ISE.
377      */
378     void request_ise_hide() const;
379
380     /**
381      * @brief Commit a content URI to its connected editor.
382      *
383      * @param[in] content a content URL to be sent.
384      * @param[in] description a content description.
385      * @param[in] mime_types a MIME type string.
386      */
387     void commit_content(const sclchar *content, const sclchar *description, const sclchar *mime_types);
388
389     /**
390      * @brief Request to set floating mode.
391      *
392      * @param[in] floating_mode Floating mode or not
393      */
394     void set_floating_mode(sclboolean floating_mode);
395 private:
396     CSCLCoreImpl *m_impl;
397 };
398
399 }
400
401 //SCL_END_DECLS
402
403 #endif //__SCL_CORE_H__