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