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