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