Add synchronous API to get surrounding text
[platform/core/uifw/libscl-core.git] / src / sclcore.cpp
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 #include "sclcore.h"
19 #include "sclcoreimpl.h"
20
21 using namespace scl;
22
23 CSCLCore::CSCLCore(ISCLCoreEventCallback *callback)
24 {
25     m_impl = CSCLCoreImpl::get_instance();
26
27     if (m_impl) {
28         m_impl->set_core_event_callback(callback);
29     }
30 }
31
32 CSCLCore::~CSCLCore()
33 {
34     m_impl = NULL;
35 }
36
37 void CSCLCore::run()
38 {
39     if (m_impl) {
40         m_impl->run();
41     }
42 }
43
44 void CSCLCore::config_reload()
45 {
46     if (m_impl) {
47         m_impl->config_reload();
48     }
49 }
50
51 sclboolean CSCLCore::config_read_int(const sclchar *name, sclint &value)
52 {
53     sclboolean ret = FALSE;
54     if (m_impl) {
55         ret = m_impl->config_read_int(name, value);
56     }
57     return ret;
58 }
59
60 sclboolean CSCLCore::config_read_string(const sclchar *name, std::string &value)
61 {
62     sclboolean ret = FALSE;
63     if (m_impl) {
64         ret = m_impl->config_read_string(name, value);
65     }
66     return ret;
67 }
68
69 sclboolean CSCLCore::config_write_int(const sclchar *name, sclint value)
70 {
71     sclboolean ret = FALSE;
72     if (m_impl) {
73         ret = m_impl->config_write_int(name, value);
74     }
75     return ret;
76 }
77
78 sclboolean CSCLCore::config_write_string(const sclchar *name, const std::string value)
79 {
80     sclboolean ret = FALSE;
81     if (m_impl) {
82         ret = m_impl->config_write_string(name, value);
83     }
84     return ret;
85 }
86
87 sclboolean CSCLCore::config_erase(const sclchar *name)
88 {
89     sclboolean ret = FALSE;
90     if (m_impl) {
91         ret = m_impl->config_erase(name);
92     }
93     return ret;
94 }
95
96 sclboolean CSCLCore::config_flush(void)
97 {
98     sclboolean ret = FALSE;
99     if (m_impl) {
100         ret = m_impl->config_flush();
101     }
102     return ret;
103 }
104
105 void CSCLCore::send_imengine_event(sclint ic, const sclchar *ic_uuid, const sclint command, const sclu32 value)
106 {
107     if (m_impl) {
108         m_impl->send_imengine_event(ic, ic_uuid, command, value);
109     }
110 }
111
112 void CSCLCore::reset_keyboard_ise()
113 {
114     if (m_impl) {
115         m_impl->reset_keyboard_ise();
116     }
117 }
118
119 void CSCLCore::send_key_event(sclint ic, const sclchar *ic_uuid, sclu32 keycode, sclu16 keymask)
120 {
121     if (m_impl) {
122         m_impl->send_key_event(ic, ic_uuid, keycode, keymask);
123     }
124 }
125
126 void CSCLCore::forward_key_event(sclint ic, const sclchar *ic_uuid, sclu32 keycode, sclu16 keymask)
127 {
128     if (m_impl) {
129         m_impl->forward_key_event(ic, ic_uuid, keycode, keymask);
130     }
131 }
132
133 void CSCLCore::commit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str)
134 {
135     if (m_impl) {
136         m_impl->commit_string(ic, ic_uuid, str);
137     }
138 }
139
140 void CSCLCore::select_candidate(int index)
141 {
142     if (m_impl) {
143         m_impl->select_candidate(index);
144     }
145 }
146
147 void CSCLCore::show_preedit_string(sclint ic, const sclchar *ic_uuid)
148 {
149     if (m_impl) {
150         m_impl->show_preedit_string(ic, ic_uuid);
151     }
152 }
153
154 void CSCLCore::show_aux_string(void)
155 {
156     if (m_impl) {
157         m_impl->show_aux_string();
158     }
159 }
160
161 void CSCLCore::show_candidate_string(void)
162 {
163     if (m_impl) {
164         m_impl->show_candidate_string();
165     }
166 }
167
168 void CSCLCore::show_associate_string(void)
169 {
170     if (m_impl) {
171         m_impl->show_associate_string();
172     }
173 }
174
175 void CSCLCore::hide_preedit_string(sclint ic, const sclchar *ic_uuid)
176 {
177     if (m_impl) {
178         m_impl->hide_preedit_string(ic, ic_uuid);
179     }
180 }
181
182 void CSCLCore::hide_aux_string(void)
183 {
184     if (m_impl) {
185         m_impl->hide_aux_string();
186     }
187 }
188
189 void CSCLCore::hide_candidate_string(void)
190 {
191     if (m_impl) {
192         m_impl->hide_candidate_string();
193     }
194 }
195
196 void CSCLCore::hide_associate_string(void)
197 {
198     if (m_impl) {
199         m_impl->hide_associate_string();
200     }
201 }
202
203 void CSCLCore::update_preedit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str)
204 {
205     if (m_impl) {
206         m_impl->update_preedit_string(ic, ic_uuid, str);
207     }
208 }
209
210 void CSCLCore::update_preedit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str, const scim::AttributeList &attrs)
211 {
212     if (m_impl) {
213         m_impl->update_preedit_string(ic, ic_uuid, str, attrs);
214     }
215 }
216
217 void CSCLCore::update_aux_string(const sclchar *str)
218 {
219     if (m_impl) {
220         m_impl->update_aux_string(str);
221     }
222 }
223
224 void CSCLCore::update_input_context(sclu32 type, sclu32 value)
225 {
226     if (m_impl) {
227         m_impl->update_input_context(type, value);
228     }
229 }
230
231 void CSCLCore::update_geometry(sclint x, sclint y, sclint width, sclint height)
232 {
233     if (m_impl) {
234         m_impl->update_geometry(x, y, width, height);
235     }
236 }
237
238 void CSCLCore::get_surrounding_text(const sclchar *ic_uuid, sclint maxlen_before, sclint maxlen_after) const
239 {
240     if (m_impl) {
241         m_impl->get_surrounding_text(ic_uuid, maxlen_before, maxlen_after);
242     }
243 }
244
245 void CSCLCore::get_surrounding_text(sclint maxlen_before, sclint maxlen_after, sclchar **text, int &cursor) const
246 {
247     if (m_impl) {
248         m_impl->get_surrounding_text(maxlen_before, maxlen_after, text, cursor);
249     }
250 }
251
252 void CSCLCore::delete_surrounding_text(sclint offset, sclint len) const
253 {
254     if (m_impl) {
255         m_impl->delete_surrounding_text(offset, len);
256     }
257 }
258
259 void CSCLCore::set_candidate_position(sclint left, sclint top)
260 {
261     if (m_impl) {
262         m_impl->set_candidate_position(left, top);
263     }
264 }
265
266 void CSCLCore::enable_soft_candidate(sclboolean enable)
267 {
268     if (m_impl) {
269         m_impl->enable_soft_candidate(enable);
270     }
271 }
272
273 void CSCLCore::candidate_hide(void)
274 {
275     if (m_impl) {
276         m_impl->candidate_hide();
277     }
278 }
279
280 void CSCLCore::set_keyboard_ise_by_uuid(const sclchar *uuid)
281 {
282     if (m_impl) {
283         m_impl->set_keyboard_ise_by_uuid(uuid);
284     }
285 }
286
287 void CSCLCore::get_keyboard_ise(const sclchar *uuid)
288 {
289     if (m_impl) {
290         m_impl->get_keyboard_ise(uuid);
291     }
292 }
293
294 sclwindow CSCLCore::get_main_window()
295 {
296     sclwindow ret = SCLWINDOW_INVALID;
297     if (m_impl) {
298         ret = m_impl->get_main_window();
299     }
300     return ret;
301 }
302
303 void CSCLCore::set_keyboard_size_hints(SclSize portrait, SclSize landscape)
304 {
305     if (m_impl) {
306         m_impl->set_keyboard_size_hints(portrait, landscape);
307     }
308 }
309
310 sclwindow CSCLCore::create_option_window()
311 {
312     sclwindow ret = SCLWINDOW_INVALID;
313     if (m_impl) {
314         ret = m_impl->create_option_window();
315     }
316     return ret;
317 }
318
319 void CSCLCore::destroy_option_window(sclwindow window)
320 {
321     if (m_impl) {
322         m_impl->destroy_option_window(window);
323     }
324 }
325
326 void CSCLCore::set_selection(sclint start, sclint end)
327 {
328     if (m_impl) {
329         m_impl->set_selection(start, end);
330     }
331 }
332
333 void CSCLCore::send_private_command(const sclchar *command)
334 {
335     if (m_impl) {
336         m_impl->send_private_command(command);
337     }
338 }