2 * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #include "sclcoreimpl.h"
19 #include <app_common.h>
24 CSCLCoreImpl::CSCLCoreImpl()
26 m_event_callback = NULL;
30 m_initialized = FALSE;
33 CSCLCoreImpl::~CSCLCoreImpl()
49 CSCLCoreImpl::get_instance()
51 static CSCLCoreImpl instance;
55 void CSCLCoreImpl::init(sclwindow main_window)
57 m_core_ui.init(main_window);
60 m_connection.open_connection(m_display);
62 if (m_event_callback) {
63 m_event_callback->on_init();
69 void CSCLCoreImpl::fini()
71 if (m_event_callback) {
72 m_event_callback->on_exit();
75 m_connection.close_connection();
80 m_initialized = FALSE;
83 void CSCLCoreImpl::set_core_event_callback(ISCLCoreEventCallback *callback)
85 m_event_callback = callback;
88 ISCLCoreEventCallback* CSCLCoreImpl::get_core_event_callback()
90 ISCLCoreEventCallback* ret = m_event_callback;
94 CSCLCoreUI* CSCLCoreImpl::get_core_ui()
99 CSCLConnection* CSCLCoreImpl::get_connection()
101 return &m_connection;
104 sclchar* CSCLCoreImpl::get_uuid()
109 sclchar* CSCLCoreImpl::get_display()
114 void CSCLCoreImpl::config_reload()
116 m_connection.config_reload();
119 sclboolean CSCLCoreImpl::config_read_int(const sclchar *name, sclint &value)
121 return m_connection.config_read_int(name, value);
124 sclboolean CSCLCoreImpl::config_read_string(const sclchar *name, std::string &value)
126 return m_connection.config_read_string(name, value);
129 sclboolean CSCLCoreImpl::config_write_int(const sclchar *name, sclint value)
131 return m_connection.config_write_int(name, value);
134 sclboolean CSCLCoreImpl::config_write_string(const sclchar *name, const std::string value)
136 return m_connection.config_write_string(name, value);
139 sclboolean CSCLCoreImpl::config_erase(const sclchar *name)
141 return m_connection.config_erase(name);
144 sclboolean CSCLCoreImpl::config_flush(void)
146 return m_connection.config_flush();
149 void CSCLCoreImpl::send_imengine_event(sclint ic, const sclchar *ic_uuid, const sclint command, const sclu32 value)
151 m_connection.send_imengine_event(ic, ic_uuid, command, value);
154 void CSCLCoreImpl::reset_keyboard_ise()
156 m_connection.reset_keyboard_ise();
159 void CSCLCoreImpl::flush_keyboard_ise()
161 m_connection.flush_keyboard_ise();
164 void CSCLCoreImpl::send_key_event(sclint ic, const sclchar *ic_uuid, sclu32 keycode, sclu16 keymask)
166 m_connection.send_key_event(ic, ic_uuid, keycode, keymask);
169 void CSCLCoreImpl::forward_key_event(sclint ic, const sclchar *ic_uuid, sclu32 keycode, sclu16 keymask)
171 m_connection.forward_key_event(ic, ic_uuid, keycode, keymask);
174 void CSCLCoreImpl::commit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str)
176 m_connection.commit_string(ic, ic_uuid, str);
179 void CSCLCoreImpl::select_candidate(int index)
181 m_connection.select_candidate(index);
184 void CSCLCoreImpl::show_preedit_string(sclint ic, const sclchar *ic_uuid)
186 m_connection.show_preedit_string(ic, ic_uuid);
189 void CSCLCoreImpl::show_aux_string(void)
191 m_connection.show_aux_string();
194 void CSCLCoreImpl::show_candidate_string(void)
196 m_connection.show_candidate_string();
199 void CSCLCoreImpl::show_associate_string(void)
201 m_connection.show_associate_string();
204 void CSCLCoreImpl::hide_preedit_string(sclint ic, const sclchar *ic_uuid)
206 m_connection.hide_preedit_string(ic, ic_uuid);
209 void CSCLCoreImpl::hide_aux_string(void)
211 m_connection.hide_aux_string();
214 void CSCLCoreImpl::hide_candidate_string(void)
216 m_connection.hide_candidate_string();
219 void CSCLCoreImpl::hide_associate_string(void)
221 m_connection.hide_associate_string();
224 void CSCLCoreImpl::update_preedit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str)
226 m_connection.update_preedit_string(ic, ic_uuid, str);
229 void CSCLCoreImpl::update_preedit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str, const scim::AttributeList &attrs)
231 m_connection.update_preedit_string(ic, ic_uuid, str, attrs);
234 void CSCLCoreImpl::update_aux_string(const sclchar *str)
236 m_connection.update_aux_string(str);
239 void CSCLCoreImpl::update_input_context(sclu32 type, sclu32 value)
241 m_connection.update_input_context(type, value);
244 void CSCLCoreImpl::update_geometry(sclint x, sclint y, sclint width, sclint height)
246 m_connection.update_geometry(x, y, width, height);
249 void CSCLCoreImpl::get_surrounding_text(const sclchar* ic_uuid, sclint maxlen_before, sclint maxlen_after) const
251 m_connection.get_surrounding_text(ic_uuid, maxlen_before, maxlen_after);
254 sclint CSCLCoreImpl::get_surrounding_text(sclint maxlen_before, sclint maxlen_after, sclchar **text, int &cursor)
256 return m_connection.get_surrounding_text(maxlen_before, maxlen_after, text, cursor);
259 void CSCLCoreImpl::delete_surrounding_text(sclint offset, sclint len) const
261 m_connection.delete_surrounding_text(offset, len);
264 void CSCLCoreImpl::set_candidate_position(sclint left, sclint top)
266 m_connection.set_candidate_position(left, top);
269 void CSCLCoreImpl::enable_soft_candidate(sclboolean enable)
271 m_connection.enable_soft_candidate(enable);
274 void CSCLCoreImpl::candidate_hide(void)
276 m_connection.candidate_hide();
279 void CSCLCoreImpl::set_keyboard_ise_by_uuid(const sclchar *uuid)
281 m_connection.set_keyboard_ise_by_uuid(uuid);
284 void CSCLCoreImpl::get_keyboard_ise(const sclchar *uuid)
286 m_connection.get_keyboard_ise(uuid);
289 void CSCLCoreImpl::on_run(const sclchar *uuid, const sclchar *display)
291 LOGD("uuid : '%s', display : '%s'\n", uuid, display);
293 if (uuid && strlen(uuid) > 0) {
298 m_uuid = strdup(uuid);
306 m_display = strdup(display);
309 if (m_event_callback) {
310 m_event_callback->on_run(0, NULL);
314 void CSCLCoreImpl::run()
316 if (!m_initialized) {
324 LOGD("appid : '%s'\n", appid);
327 m_uuid = strdup(appid);
333 const char *display = getenv("DISPLAY");
334 LOGD("display env : '%s'\n", display);
335 m_display = display ? strdup(display) : strdup(":0");
338 m_core_ui.run(m_display);
341 sclwindow CSCLCoreImpl::get_main_window()
343 return m_core_ui.get_main_window();
346 int CSCLCoreImpl::get_screen_rotation_degree()
348 return m_core_ui.get_screen_rotation_degree();
351 void CSCLCoreImpl::set_keyboard_size_hints(SclSize portrait, SclSize landscape)
353 m_core_ui.set_keyboard_size_hints(portrait, landscape);
356 sclwindow CSCLCoreImpl::create_option_window()
358 return m_core_ui.create_option_window(OPTION_WINDOW_TYPE_NORMAL);
361 void CSCLCoreImpl::destroy_option_window(sclwindow window)
363 m_core_ui.destroy_option_window(window);
366 void CSCLCoreImpl::set_selection(sclint start, sclint end)
368 m_connection.set_selection(start, end);
371 void CSCLCoreImpl::send_private_command(const sclchar *command)
373 m_connection.send_private_command(command);
376 void CSCLCoreImpl::get_selection_text(sclchar **text)
378 m_connection.get_selection_text(text);
381 void CSCLCoreImpl::request_ise_hide()
383 m_connection.request_ise_hide();