Modified to not send invalid geometry to app
[platform/core/uifw/libscl-core.git] / src / sclconnection-isf.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-isf.h"
19 #include "sclcoreimpl.h"
20 #include <Elementary.h>
21 #include <dlog.h>
22
23 #ifdef WEBSOCKET
24 #include "legacy_support/websocket.h"
25 extern CWebHelperAgentWebSocket g_websocket;
26 #endif
27
28 using namespace scl;
29
30 static scim::ConfigPointer _scim_config(0);
31
32 /* Slot functions for calling appropriate callback functions */
33 static void slot_exit(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) {
34     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
35     if (impl) {
36         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
37         if (callback) {
38             callback->on_ise_hide(ic, ic_uuid.c_str());
39             LOGD("call on_exit");
40             callback->on_exit();
41         }
42         if (agent) {
43             agent->update_ise_exit();
44         }
45     }
46     LOGD("exit");
47     elm_exit();
48 }
49
50 static void slot_attach_input_context(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) {
51     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
52     if (impl) {
53         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
54         if (callback) {
55             callback->on_attach_input_context(ic, ic_uuid.c_str());
56         }
57     }
58 }
59
60 static void slot_detach_input_context(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) {
61     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
62     if (impl) {
63         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
64         if (callback) {
65             callback->on_detach_input_context(ic, ic_uuid.c_str());
66         }
67     }
68 }
69
70 static void slot_reload_config(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) {
71     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
72     if (impl) {
73         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
74         if (callback) {
75             callback->on_reload_config(ic, ic_uuid.c_str());
76         }
77     }
78 }
79
80 static void slot_update_screen(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid, int screen_number) {
81     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
82     if (impl) {
83         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
84         if (callback) {
85             //callback->on_update_screen(ic, ic_uuid.c_str(), screen_number);
86         }
87     }
88 }
89
90 static void slot_update_spot_location(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid, int x, int y) {
91     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
92     if (impl) {
93         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
94         if (callback) {
95             callback->on_update_spot_location(ic, ic_uuid.c_str(), x, y);
96         }
97     }
98 }
99
100 static void slot_update_cursor_position(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid, int cursor_pos) {
101     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
102     if (impl) {
103         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
104         if (callback) {
105             callback->on_update_cursor_position(ic, ic_uuid.c_str(), cursor_pos);
106 #ifdef WEBSOCKET
107             g_websocket.on_update_cursor_position(ic, cursor_pos);
108 #endif
109         }
110     }
111 }
112
113 static void slot_update_surrounding_text(const scim::HelperAgent *agent, int ic, const scim::String &text, int cursor) {
114     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
115     if (impl) {
116         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
117         if (callback) {
118             callback->on_update_surrounding_text(ic, text.c_str(), cursor);
119 #ifdef WEBSOCKET
120             g_websocket.on_update_surrounding_text(ic, text.c_str(), cursor);
121 #endif
122         }
123     }
124 }
125
126 static void slot_trigger_property(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid, const scim::String &property) {
127     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
128     if (impl) {
129         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
130         if (callback) {
131             //callback->on_trigger_property(ic, ic_uuid.c_str(), property.c_str());
132         }
133     }
134 }
135
136 static void slot_focus_out(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) {
137     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
138     if (impl) {
139         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
140         if (callback) {
141             callback->on_focus_out(ic, ic_uuid.c_str());
142 #ifdef WEBSOCKET
143             g_websocket.on_focus_out(ic);
144 #endif
145         }
146     }
147 }
148
149 static void slot_focus_in(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) {
150     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
151     if (impl) {
152         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
153         if (callback) {
154             callback->on_focus_in(ic, ic_uuid.c_str());
155 #ifdef WEBSOCKET
156             g_websocket.on_focus_in(ic);
157 #endif
158         }
159     }
160 }
161
162 static void slot_ise_show(const scim::HelperAgent *agent, int ic, char *buf, size_t &len) {
163     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
164     if (impl) {
165         /* Make sure the appropriate keyboard ise was selected -> is this really necessary? */
166         //impl->set_keyboard_ise_by_uuid(impl->get_keyboard_ise_uuid().c_str());
167
168         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
169         if (callback) {
170             /* Check if effect is enabled */
171             Ise_Context ise_context;
172             memset(&ise_context, 0x00, sizeof(ise_context));
173
174             if (len >= sizeof(Ise_Context)) {
175                 memcpy(&ise_context, buf, sizeof(ise_context));
176
177                 if (ise_context.imdata_size > 0) {
178                     char imdata[1024] = {0};
179                     memcpy((void *)imdata, buf + sizeof(ise_context), ise_context.imdata_size);
180                     callback->on_set_imdata(imdata, ise_context.imdata_size);
181                 }
182
183                 if (len > (sizeof(Ise_Context) + ise_context.imdata_size))
184                     callback->on_set_mime_type(buf + sizeof(ise_context) + ise_context.imdata_size);
185             } else {
186                 LOGD("\n-=-= WARNING - buf %p len %zu size %zu\n", buf, len, sizeof(ise_context));
187             }
188             CSCLCoreUI* ui = impl->get_core_ui();
189             if (ui) {
190                 ui->process_keyboard_ui_state_change(KEYBOARD_UI_STATE_WILL_SHOW);
191             }
192             callback->on_ise_show(ic, impl->get_screen_rotation_degree(), ise_context);
193             SclSize portrait;
194             SclSize landscape;
195             ui->get_keyboard_size(&portrait, &landscape);
196             /* If the ime_set_size() API is not called and IME is shown, the app can not receive the keyboard window's geometry from ISF.
197                And the ime_set_size() API is not called unless the IME size changes.
198             */
199             ui->update_keyboard_geometry(portrait, landscape);
200             if (ui) {
201                 ui->process_keyboard_ui_state_change(KEYBOARD_UI_STATE_DID_SHOW);
202             }
203
204 #ifdef WEBSOCKET
205             g_websocket.on_set_layout(ise_context.layout);
206             g_websocket.on_update_cursor_position(ic, ise_context.cursor_pos);
207             g_websocket.on_show(ic);
208 #endif
209         }
210     }
211 }
212
213 static void slot_ise_hide(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) {
214     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
215     if (impl) {
216         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
217         if (callback) {
218             CSCLCoreUI* ui = impl->get_core_ui();
219             if (ui) {
220                 ui->process_keyboard_ui_state_change(KEYBOARD_UI_STATE_WILL_HIDE);
221             }
222             callback->on_ise_hide(ic, ic_uuid.c_str());
223             if (ui) {
224                 ui->process_keyboard_ui_state_change(KEYBOARD_UI_STATE_DID_HIDE);
225             }
226
227 #ifdef WEBSOCKET
228             g_websocket.on_hide(ic);
229 #endif
230         }
231     }
232 }
233
234 static void slot_get_geometry(const scim::HelperAgent *agent, struct scim::rectinfo &info) {
235     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
236     if (impl) {
237         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
238         if (callback) {
239             callback->on_get_geometry(&(info.pos_x), &(info.pos_y), &(info.width), &(info.height));
240         }
241     }
242 }
243
244 static void slot_set_mode(const scim::HelperAgent *agent, scim::uint32 &mode) {
245     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
246     if (impl) {
247         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
248         if (callback) {
249             callback->on_set_mode(mode);
250         }
251     }
252 }
253
254 static void slot_set_language(const scim::HelperAgent *agent, scim::uint32 &language) {
255     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
256     if (impl) {
257         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
258         if (callback) {
259             callback->on_set_language(language);
260 #ifdef WEBSOCKET
261             g_websocket.on_set_language(language);
262 #endif
263         }
264     }
265 }
266
267 static void slot_set_imdata(const scim::HelperAgent *agent, char *buf, size_t &len) {
268     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
269     if (impl) {
270         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
271         if (callback) {
272             scl32 _len = static_cast<scl32>(reinterpret_cast<size_t>(len) & 0xffffffff);
273             callback->on_set_imdata(buf, _len);
274 #ifdef WEBSOCKET
275             g_websocket.on_set_imdata(buf, len);
276 #endif
277         }
278     }
279 }
280
281 static void slot_get_imdata(const scim::HelperAgent *, char **buf, size_t &len) {
282     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
283     if (impl) {
284         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
285         if (callback) {
286             sclu32 _len = 0;
287             callback->on_get_imdata(buf, &_len);
288 #ifdef WEBSOCKET
289             g_websocket.on_get_imdata(buf, &_len);
290 #endif
291             len = _len;
292         }
293     }
294 }
295
296 static void slot_get_language_locale(const scim::HelperAgent *, int ic, char **locale) {
297     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
298     if (impl) {
299         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
300         if (callback) {
301             callback->on_get_language_locale(ic, locale);
302         }
303     }
304 }
305
306 static void slot_set_return_key_type(const scim::HelperAgent *agent, scim::uint32 &type) {
307     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
308     if (impl) {
309         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
310         if (callback) {
311             callback->on_set_return_key_type(type);
312 #ifdef WEBSOCKET
313             g_websocket.on_set_return_key_type(type);
314 #endif
315         }
316     }
317 }
318
319 static void slot_get_return_key_type(const scim::HelperAgent *agent, scim::uint32 &type) {
320     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
321     if (impl) {
322         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
323         if (callback) {
324             callback->on_get_return_key_type(&type);
325 #ifdef WEBSOCKET
326             g_websocket.on_get_return_key_type(&type);
327 #endif
328         }
329     }
330 }
331
332 static void slot_set_return_key_disable(const scim::HelperAgent *agent, scim::uint32 &disabled) {
333     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
334     if (impl) {
335         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
336         if (callback) {
337             callback->on_set_return_key_disable(disabled);
338 #ifdef WEBSOCKET
339             g_websocket.on_set_return_key_disable(disabled);
340 #endif
341         }
342     }
343 }
344
345 static void slot_get_return_key_disable(const scim::HelperAgent *agent, scim::uint32 &disabled) {
346     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
347     if (impl) {
348         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
349         if (callback) {
350             callback->on_get_return_key_disable(&disabled);
351 #ifdef WEBSOCKET
352             g_websocket.on_get_return_key_disable(&disabled);
353 #endif
354         }
355     }
356 }
357
358 static void slot_set_layout(const scim::HelperAgent *agent, scim::uint32 &layout) {
359     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
360     if (impl) {
361         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
362         if (callback) {
363             callback->on_set_layout(layout);
364 #ifdef WEBSOCKET
365             g_websocket.on_set_layout(layout);
366 #endif
367         }
368     }
369 }
370
371 static void slot_get_layout(const scim::HelperAgent *agent, scim::uint32 &layout) {
372     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
373     if (impl) {
374         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
375         if (callback) {
376             callback->on_get_layout(&layout);
377 #ifdef WEBSOCKET
378             g_websocket.on_get_layout(&layout);
379 #endif
380         }
381     }
382 }
383
384 static void slot_set_caps_mode(const scim::HelperAgent *agent, scim::uint32 &mode) {
385     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
386     if (impl) {
387         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
388         if (callback) {
389             callback->on_set_caps_mode(mode);
390         }
391     }
392 }
393
394 static void slot_reset_input_context(const scim::HelperAgent *agent, int ic, const scim::String &uuid) {
395     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
396     if (impl) {
397         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
398         if (callback) {
399             callback->on_reset_input_context(ic, uuid.c_str());
400 #ifdef WEBSOCKET
401             g_websocket.on_reset_input_context(ic);
402 #endif
403         }
404     }
405 }
406
407 static void slot_update_candidate_geometry(const scim::HelperAgent *agent, int ic, const scim::String &uuid, const scim::rectinfo &info) {
408     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
409     if (impl) {
410         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
411         if (callback) {
412             callback->on_update_candidate_geometry(ic, uuid.c_str(), info.pos_x, info.pos_y, info.width, info.height);
413         }
414     }
415 }
416 static void slot_update_keyboard_ise(const scim::HelperAgent *agent, int ic, const scim::String &uuid,
417                                                   const scim::String &ise_name, const scim::String &ise_uuid) {
418     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
419     if (impl) {
420         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
421         if (callback) {
422             callback->on_update_keyboard_ise(ic, uuid.c_str(), ise_name.c_str(), ise_uuid.c_str());
423         }
424     }
425 }
426
427 static void slot_candidate_more_window_show(const scim::HelperAgent *agent, int ic, const scim::String &uuid) {
428     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
429     if (impl) {
430         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
431         if (callback) {
432             callback->on_candidate_more_window_show(ic, uuid.c_str());
433         }
434     }
435 }
436
437 static void slot_candidate_more_window_hide(const scim::HelperAgent *agent, int ic, const scim::String &uuid) {
438     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
439     if (impl) {
440         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
441         if (callback) {
442             callback->on_candidate_more_window_hide(ic, uuid.c_str());
443         }
444     }
445 }
446
447 static void slot_select_aux(const scim::HelperAgent *agent, int ic, const scim::String &uuid, int index) {
448     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
449     if (impl) {
450         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
451         if (callback) {
452             callback->on_select_aux(ic, uuid.c_str(), index);
453         }
454     }
455 }
456
457 static void slot_select_candidate(const scim::HelperAgent *agent, int ic, const scim::String &uuid, int index) {
458     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
459     if (impl) {
460         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
461         if (callback) {
462             callback->on_select_candidate(ic, uuid.c_str(), index);
463         }
464     }
465 }
466
467 static void slot_candidate_table_page_up(const scim::HelperAgent *agent, int ic, const scim::String &uuid) {
468     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
469     if (impl) {
470         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
471         if (callback) {
472             callback->on_candidate_table_page_up(ic, uuid.c_str());
473         }
474     }
475 }
476
477 static void slot_candidate_table_page_down(const scim::HelperAgent *agent, int ic, const scim::String &uuid) {
478     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
479     if (impl) {
480         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
481         if (callback) {
482             callback->on_candidate_table_page_down(ic, uuid.c_str());
483         }
484     }
485 }
486
487 static void slot_update_candidate_table_page_size(const scim::HelperAgent *, int ic, const scim::String &uuid, int page_size) {
488     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
489     if (impl) {
490         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
491         if (callback) {
492             callback->on_update_candidate_table_page_size(ic, uuid.c_str(), page_size);
493         }
494     }
495 }
496
497 static void slot_update_lookup_table(const scim::HelperAgent *, scim::LookupTable &table) {
498     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
499     if (impl) {
500         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
501         if (callback) {
502             SclCandidateTable lookup_table;
503             lookup_table.page_size = table.get_page_size();
504             lookup_table.current_page_start = table.get_current_page_start();
505             lookup_table.cursor_pos = table.get_cursor_pos();
506             lookup_table.cursor_visible = table.is_cursor_visible();
507             lookup_table.page_size_fixed = table.is_page_size_fixed();
508             lookup_table.candidate_labels.clear();
509             for (int page_index = 0;page_index < lookup_table.page_size;page_index++) {
510                 scim::WideString label = table.get_candidate_label(page_index);
511                 lookup_table.candidate_labels.push_back(scim::utf8_wcstombs(label).c_str());
512             }
513
514             int nCandidateSize = table.get_current_page_size();
515             for (int index = 0; index < nCandidateSize; ++index) {
516                 scim::WideString candidate_str = table.get_candidate_in_current_page(index);
517                 lookup_table.candidate.push_back(scim::utf8_wcstombs(candidate_str).c_str());
518             }
519
520             callback->on_update_lookup_table(lookup_table);
521
522             std::vector<scim::WideString> labels;
523             for (unsigned int loop = 0;loop < lookup_table.candidate_labels.size();loop++) {
524                 labels.push_back(scim::utf8_mbstowcs(lookup_table.candidate_labels.at(loop).c_str()));
525             }
526             table.set_candidate_labels(labels);
527         }
528     }
529 }
530
531 static void slot_select_associate(const scim::HelperAgent *agent, int ic, const scim::String &uuid, int index) {
532     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
533     if (impl) {
534         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
535         if (callback) {
536             callback->on_select_associate(ic, uuid.c_str(), index);
537         }
538     }
539 }
540
541 static void slot_associate_table_page_up(const scim::HelperAgent *agent, int ic, const scim::String &uuid) {
542     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
543     if (impl) {
544         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
545         if (callback) {
546             callback->on_associate_table_page_up(ic, uuid.c_str());
547         }
548     }
549 }
550
551 static void slot_associate_table_page_down(const scim::HelperAgent *agent, int ic, const scim::String &uuid) {
552     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
553     if (impl) {
554         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
555         if (callback) {
556             callback->on_associate_table_page_down(ic, uuid.c_str());
557         }
558     }
559 }
560
561 static void slot_update_associate_table_page_size(const scim::HelperAgent *, int ic, const scim::String &uuid, int page_size) {
562     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
563     if (impl) {
564         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
565         if (callback) {
566             callback->on_update_associate_table_page_size(ic, uuid.c_str(), page_size);
567         }
568     }
569 }
570
571 static void slot_show_ise_option_window(const scim::HelperAgent *agent, int ic, const scim::String &uuid) {
572     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
573     if (impl) {
574         CSCLCoreUI *core_ui = impl->get_core_ui();
575         if (core_ui) {
576             LOGD("slot_show_ise_option_window() called!!!\n");
577             core_ui->create_option_window(OPTION_WINDOW_TYPE_SETTING_APPLICATION);
578         }
579     }
580 }
581
582 static void slot_resume_ise_option_window(const scim::HelperAgent *agent, int ic, const scim::String &uuid) {
583     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
584     if (impl) {
585         CSCLCoreUI *core_ui = impl->get_core_ui();
586         if (core_ui) {
587             LOGD("slot_resume_ise_option_window() called!!!\n");
588             core_ui->show_option_window(OPTION_WINDOW_TYPE_SETTING_APPLICATION);
589         }
590     }
591 }
592
593 static void slot_check_ise_option_window(const scim::HelperAgent *agent, sclu32 &avail) {
594     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
595     if (impl) {
596         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
597         if (callback) {
598             callback->on_check_option_window_availability(reinterpret_cast<sclboolean *>(&avail));
599         }
600     }
601 }
602
603 static void slot_process_key_event(const scim::HelperAgent *agent, scim::KeyEvent &key, scim::uint32 &ret) {
604     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
605     if (impl) {
606         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
607         if (callback) {
608             callback->on_process_key_event(key, &ret);
609 #ifdef WEBSOCKETweb_ret
610             g_websocket.on_process_key_event(key.code, key.mask, key.layout, &ret);
611 #endif
612         }
613     }
614 }
615
616 static void slot_process_key_event_with_keycode(const scim::HelperAgent *agent, scim::KeyEvent &key, scim::uint32 &ret, scim::uint32 keycode) {
617     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
618     if (impl) {
619         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
620         if (callback) {
621             callback->on_process_key_event_with_keycode(key, &ret, keycode);
622         }
623     }
624 }
625
626 static void slot_candidate_show(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) {
627     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
628     if (impl) {
629         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
630         if (callback) {
631             callback->on_candidate_show(ic, ic_uuid.c_str());
632         }
633     }
634 }
635
636 static void slot_candidate_hide(const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) {
637     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
638     if (impl) {
639         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
640         if (callback) {
641             callback->on_candidate_hide(ic, ic_uuid.c_str());
642         }
643     }
644 }
645
646 static void slot_process_input_device_event(const scim::HelperAgent *agent, scim::uint32 &type, char *data, size_t &len, scim::uint32 &ret) {
647     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
648     if (impl) {
649         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
650         if (callback) {
651             /* Input Device Event callback is available in versions after 1.1 */
652             if (check_interface_version(callback, 1, 1)) {
653                 callback->on_process_input_device_event(type, data, len, &ret);
654             }
655         }
656     }
657 }
658
659 static void slot_set_prediction_hint(const scim::HelperAgent *agent, const scim::String &prediction_hint) {
660     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
661     if (impl) {
662         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
663         if (callback) {
664             callback->on_set_prediction_hint(prediction_hint.c_str());
665         }
666     }
667 }
668
669 static void slot_set_mime_type(const scim::HelperAgent *agent, const scim::String &mime_type) {
670     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
671     if (impl) {
672         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
673         if (callback) {
674             callback->on_set_mime_type(mime_type.c_str());
675         }
676     }
677 }
678
679 static void slot_set_prediction_hint_data(const scim::HelperAgent *agent, int ic, const scim::String &key, const scim::String &value) {
680     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
681     if (impl) {
682         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
683         if (callback) {
684             SECURE_LOGD("key : %s, value : %s\n", key.c_str(), value.c_str());
685             callback->on_set_prediction_hint_data(key.c_str(), value.c_str());
686         }
687     }
688 }
689
690 static void slot_set_optimization_hint(const scim::HelperAgent *agent, scim::uint32 &hint) {
691     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
692     if (impl) {
693         ISCLCoreEventCallback *callback = impl->get_core_event_callback();
694         if (callback) {
695             SECURE_LOGD("hint : %d\n", hint);
696             callback->on_set_optimization_hint(hint);
697         }
698     }
699 }
700
701 /* Internal input handler function */
702 Eina_Bool input_handler(void *data, Ecore_Fd_Handler *fd_handler)
703 {
704     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
705     if (impl) {
706         scim::HelperAgent *agent = static_cast<scim::HelperAgent*>(data);
707         if (agent) {
708             if (agent->has_pending_event()) {
709                 if (!(agent->filter_event())) {
710                     LOGD("helper_agent.filter_event() failed!!!\n");
711                     impl->fini();
712                     elm_exit();
713                 }
714             } else {
715                 LOGD("helper_agent.has_pending_event() failed!!!\n");
716                 impl->fini();
717                 elm_exit();
718             }
719         }
720     }
721
722     return ECORE_CALLBACK_RENEW;
723 }
724
725 CSCLConnectionISF::CSCLConnectionISF()
726 {
727     m_initialized = FALSE;
728     m_fd_handler = NULL;
729
730     m_backend_identifier = "ISF";
731 }
732
733 CSCLConnectionISF::~CSCLConnectionISF()
734 {
735 }
736
737 sclboolean CSCLConnectionISF::init()
738 {
739     LOGD("Enter\n");
740
741     if (!m_initialized) {
742         m_helper_agent.signal_connect_exit(scim::slot(slot_exit));
743         m_helper_agent.signal_connect_attach_input_context(scim::slot(slot_attach_input_context));
744         m_helper_agent.signal_connect_detach_input_context(scim::slot(slot_detach_input_context));
745         m_helper_agent.signal_connect_reload_config(scim::slot(slot_reload_config));
746         m_helper_agent.signal_connect_update_screen(scim::slot(slot_update_screen));
747         m_helper_agent.signal_connect_update_spot_location(scim::slot(slot_update_spot_location));
748         m_helper_agent.signal_connect_update_cursor_position(scim::slot(slot_update_cursor_position));
749         m_helper_agent.signal_connect_update_surrounding_text(scim::slot(slot_update_surrounding_text));
750         m_helper_agent.signal_connect_trigger_property(scim::slot(slot_trigger_property));
751         //m_helper_agent.signal_connect_process_imengine_event (slot (slot_process_imengine_event));
752         m_helper_agent.signal_connect_focus_out(scim::slot(slot_focus_out));
753         m_helper_agent.signal_connect_focus_in(scim::slot(slot_focus_in));
754         m_helper_agent.signal_connect_ise_show(scim::slot(slot_ise_show));
755         m_helper_agent.signal_connect_ise_hide(scim::slot(slot_ise_hide));
756         m_helper_agent.signal_connect_get_geometry(scim::slot(slot_get_geometry));
757         m_helper_agent.signal_connect_set_mode(scim::slot(slot_set_mode));
758         m_helper_agent.signal_connect_set_language(scim::slot(slot_set_language));
759         m_helper_agent.signal_connect_set_imdata(scim::slot(slot_set_imdata));
760         m_helper_agent.signal_connect_get_imdata(scim::slot(slot_get_imdata));
761         m_helper_agent.signal_connect_get_language_locale(scim::slot(slot_get_language_locale));
762         m_helper_agent.signal_connect_set_return_key_type(scim::slot(slot_set_return_key_type));
763         m_helper_agent.signal_connect_get_return_key_type(scim::slot(slot_get_return_key_type));
764         m_helper_agent.signal_connect_set_return_key_disable(scim::slot(slot_set_return_key_disable));
765         m_helper_agent.signal_connect_get_return_key_disable(scim::slot(slot_get_return_key_disable));
766         m_helper_agent.signal_connect_get_layout(scim::slot(slot_get_layout));
767         m_helper_agent.signal_connect_set_layout(scim::slot(slot_set_layout));
768         m_helper_agent.signal_connect_set_caps_mode(scim::slot(slot_set_caps_mode));
769         m_helper_agent.signal_connect_reset_input_context(scim::slot(slot_reset_input_context));
770         m_helper_agent.signal_connect_update_candidate_geometry(scim::slot(slot_update_candidate_geometry));
771         m_helper_agent.signal_connect_update_keyboard_ise(scim::slot(slot_update_keyboard_ise));
772         //m_helper_agent.signal_connect_update_keyboard_ise_list (slot (slot_update_keyboard_ise_list));
773         m_helper_agent.signal_connect_candidate_more_window_show(scim::slot(slot_candidate_more_window_show));
774         m_helper_agent.signal_connect_candidate_more_window_hide(scim::slot(slot_candidate_more_window_hide));
775         m_helper_agent.signal_connect_select_aux(scim::slot(slot_select_aux));
776         m_helper_agent.signal_connect_select_candidate(scim::slot(slot_select_candidate));
777         m_helper_agent.signal_connect_candidate_table_page_up(scim::slot(slot_candidate_table_page_up));
778         m_helper_agent.signal_connect_candidate_table_page_down(scim::slot(slot_candidate_table_page_down));
779         m_helper_agent.signal_connect_update_candidate_table_page_size(scim::slot(slot_update_candidate_table_page_size));
780         m_helper_agent.signal_connect_update_lookup_table(scim::slot(slot_update_lookup_table));
781         m_helper_agent.signal_connect_select_associate(scim::slot(slot_select_associate));
782         m_helper_agent.signal_connect_associate_table_page_up(scim::slot(slot_associate_table_page_up));
783         m_helper_agent.signal_connect_associate_table_page_down(scim::slot(slot_associate_table_page_down));
784         m_helper_agent.signal_connect_update_associate_table_page_size(scim::slot(slot_update_associate_table_page_size));
785         m_helper_agent.signal_connect_show_option_window(scim::slot(slot_show_ise_option_window));
786         m_helper_agent.signal_connect_resume_option_window(scim::slot(slot_resume_ise_option_window));
787         m_helper_agent.signal_connect_check_option_window(scim::slot(slot_check_ise_option_window));
788         m_helper_agent.signal_connect_process_key_event(scim::slot(slot_process_key_event));
789         m_helper_agent.signal_connect_process_key_event_with_keycode(scim::slot(slot_process_key_event_with_keycode));
790         m_helper_agent.signal_connect_candidate_show(scim::slot(slot_candidate_show));
791         m_helper_agent.signal_connect_candidate_hide(scim::slot(slot_candidate_hide));
792         m_helper_agent.signal_connect_process_input_device_event(scim::slot(slot_process_input_device_event));
793         m_helper_agent.signal_connect_set_prediction_hint(scim::slot(slot_set_prediction_hint));
794         m_helper_agent.signal_connect_set_mime_type(scim::slot(slot_set_mime_type));
795         m_helper_agent.signal_connect_set_prediction_hint_data(scim::slot(slot_set_prediction_hint_data));
796         m_helper_agent.signal_connect_set_optimization_hint(scim::slot(slot_set_optimization_hint));
797
798         m_initialized = TRUE;
799     }
800
801     if (_scim_config.null()) {
802         scim::ConfigPointer config_pointer = scim::ConfigBase::get(true, "socket");
803         if (config_pointer.null()) {
804             config_pointer = new scim::DummyConfig();
805         }
806         _scim_config = config_pointer;
807     }
808
809     return TRUE;
810 }
811
812 void CSCLConnectionISF::fini()
813 {
814     if (!_scim_config.null()) {
815         _scim_config.reset();
816     }
817     scim::ConfigBase::set(0);
818     close_connection();
819     m_initialized = FALSE;
820 }
821
822 void CSCLConnectionISF::open_connection(const sclchar *display)
823 {
824     if (m_initialized) {
825         CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
826         if (impl) {
827             sclchar *uuid = impl->get_uuid();
828             if (uuid) {
829                 m_helper_info.uuid = uuid;
830             }
831         }
832
833         m_helper_agent.open_connection(m_helper_info, display);
834         int fd = m_helper_agent.get_connection_number();
835
836         if (fd >= 0) {
837 #ifndef WAYLAND
838             Evas_Object *main_window = NULL;
839             CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
840             if (impl) {
841                 main_window = NATIVE_WINDOW_CAST(impl->get_main_window());
842             }
843
844             Ecore_X_Window xwindow = elm_win_xwindow_get(main_window);
845             char xid[255];
846             snprintf(xid, 255, "%d", xwindow);
847             scim::Property prop(xid, "XID", "", "");
848             scim::PropertyList props;
849             props.push_back(prop);
850             m_helper_agent.register_properties(props);
851 #endif
852
853             m_fd_handler = ecore_main_fd_handler_add(fd, ECORE_FD_READ, input_handler, &m_helper_agent, NULL, NULL);
854         }
855     }
856 }
857
858 void CSCLConnectionISF::close_connection()
859 {
860     if (m_initialized) {
861         if (m_fd_handler) {
862             ecore_main_fd_handler_del(m_fd_handler);
863             m_fd_handler = NULL;
864         }
865         m_helper_agent.update_ise_exit();
866         m_helper_agent.close_connection();
867     }
868 }
869
870 void CSCLConnectionISF::config_reload()
871 {
872     if (m_initialized) {
873         m_helper_agent.reload_config();
874     }
875 }
876
877 sclboolean CSCLConnectionISF::config_read_int(const sclchar *name, sclint &value)
878 {
879     sclboolean ret = FALSE;
880     if (m_initialized && _scim_config) {
881         value = _scim_config->read(name, value);
882         ret = TRUE;
883     }
884     return ret;
885 }
886
887 sclboolean CSCLConnectionISF::config_read_string(const sclchar *name, std::string &value)
888 {
889     sclboolean ret = FALSE;
890     if (m_initialized && _scim_config) {
891         value = _scim_config->read(name, value);
892         ret = TRUE;
893     }
894     return ret;
895 }
896
897 sclboolean CSCLConnectionISF::config_write_int(const sclchar *name, sclint value)
898 {
899     sclboolean ret = FALSE;
900     if (m_initialized && _scim_config) {
901         _scim_config->write(name, value);
902         ret = TRUE;
903     }
904     return ret;
905 }
906
907 sclboolean CSCLConnectionISF::config_write_string(const sclchar *name, const std::string value)
908 {
909     sclboolean ret = FALSE;
910     if (m_initialized && _scim_config) {
911         _scim_config->write(name, value);
912         ret = TRUE;
913     }
914     return ret;
915 }
916
917 sclboolean CSCLConnectionISF::config_erase(const sclchar *name)
918 {
919     sclboolean ret = FALSE;
920     if (m_initialized && _scim_config) {
921         _scim_config->erase(name);
922         ret = TRUE;
923     }
924     return ret;
925 }
926
927 sclboolean CSCLConnectionISF::config_flush(void)
928 {
929     sclboolean ret = FALSE;
930     if (m_initialized && _scim_config) {
931         _scim_config->flush();
932         ret = TRUE;
933     }
934     return ret;
935 }
936
937 void CSCLConnectionISF::send_imengine_event(sclint ic, const sclchar *ic_uuid, const sclint command, const sclu32 value)
938 {
939     if (m_initialized) {
940         scim::String uuid;
941         if (ic_uuid) {
942             uuid = scim::String(ic_uuid);
943         }
944         scim::Transaction trans;
945         trans.put_command(command);
946         trans.put_data(value);
947         m_helper_agent.send_imengine_event(ic, uuid, trans);
948     }
949 }
950
951 void CSCLConnectionISF::reset_keyboard_ise()
952 {
953     if (m_initialized) {
954         m_helper_agent.reset_keyboard_ise();
955     }
956 }
957
958 void CSCLConnectionISF::flush_keyboard_ise()
959 {
960     if (m_initialized) {
961         m_helper_agent.flush_keyboard_ise();
962     }
963 }
964
965 void CSCLConnectionISF::send_key_event(sclint ic, const sclchar *ic_uuid, sclu32 keycode, sclu16 keymask)
966 {
967     if (m_initialized) {
968         scim::String uuid;
969         if (ic_uuid) {
970             uuid = scim::String(ic_uuid);
971         }
972         scim::KeyEvent event;
973         event.code = keycode;
974         event.mask = keymask;
975         m_helper_agent.send_key_event(ic, uuid, event);
976     }
977 }
978
979 void CSCLConnectionISF::forward_key_event(sclint ic, const sclchar *ic_uuid, sclu32 keycode, sclu16 keymask)
980 {
981     if (m_initialized) {
982         scim::String uuid;
983         if (ic_uuid) {
984             uuid = scim::String(ic_uuid);
985         }
986         scim::KeyEvent event;
987         event.code = keycode;
988         event.mask = keymask;
989         m_helper_agent.forward_key_event(ic, uuid, event);
990     }
991 }
992
993 void CSCLConnectionISF::commit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str)
994 {
995     if (m_initialized) {
996         scim::String uuid;
997         if (ic_uuid) {
998             uuid = scim::String(ic_uuid);
999         }
1000         m_helper_agent.commit_string(ic, uuid, scim::utf8_mbstowcs(str));
1001     }
1002 }
1003
1004 void CSCLConnectionISF::select_candidate(int index)
1005 {
1006     if (m_initialized) {
1007         m_helper_agent.select_candidate(index);
1008     }
1009 }
1010
1011 void CSCLConnectionISF::show_preedit_string(sclint ic, const sclchar *ic_uuid)
1012 {
1013     if (m_initialized) {
1014         scim::String uuid;
1015         if (ic_uuid) {
1016             uuid = scim::String(ic_uuid);
1017         }
1018         m_helper_agent.show_preedit_string(ic, uuid);
1019     }
1020 }
1021
1022 void CSCLConnectionISF::show_aux_string(void)
1023 {
1024     if (m_initialized) {
1025         m_helper_agent.show_aux_string();
1026     }
1027 }
1028
1029 void CSCLConnectionISF::show_candidate_string(void)
1030 {
1031     if (m_initialized) {
1032         m_helper_agent.show_candidate_string();
1033     }
1034 }
1035
1036 void CSCLConnectionISF::show_associate_string(void)
1037 {
1038     if (m_initialized) {
1039         m_helper_agent.show_associate_string();
1040     }
1041 }
1042
1043 void CSCLConnectionISF::hide_preedit_string(sclint ic, const sclchar *ic_uuid)
1044 {
1045     if (m_initialized) {
1046         scim::String uuid;
1047         if (ic_uuid) {
1048             uuid = scim::String(ic_uuid);
1049         }
1050         m_helper_agent.hide_preedit_string(ic, uuid);
1051     }
1052 }
1053
1054 void CSCLConnectionISF::hide_aux_string(void)
1055 {
1056     if (m_initialized) {
1057         m_helper_agent.hide_aux_string();
1058     }
1059 }
1060
1061 void CSCLConnectionISF::hide_candidate_string(void)
1062 {
1063     if (m_initialized) {
1064         m_helper_agent.hide_candidate_string();
1065     }
1066 }
1067
1068 void CSCLConnectionISF::hide_associate_string(void)
1069 {
1070     if (m_initialized) {
1071         m_helper_agent.hide_associate_string();
1072     }
1073 }
1074
1075 void CSCLConnectionISF::update_preedit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str)
1076 {
1077     if (m_initialized) {
1078         scim::AttributeList list;
1079         scim::String uuid;
1080         if (ic_uuid) {
1081             uuid = scim::String(ic_uuid);
1082         }
1083         m_helper_agent.update_preedit_string(ic, uuid, scim::utf8_mbstowcs(str), list);
1084
1085         if (str && strlen(str) > 0) {
1086             show_preedit_string(ic, ic_uuid);
1087         } else {
1088             hide_preedit_string(ic, ic_uuid);
1089         }
1090     }
1091 }
1092
1093 void CSCLConnectionISF::update_preedit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str, const scim::AttributeList &attrs)
1094 {
1095     if (m_initialized) {
1096         scim::String uuid;
1097         if (ic_uuid) {
1098             uuid = scim::String(ic_uuid);
1099         }
1100         m_helper_agent.update_preedit_string(ic, uuid, scim::utf8_mbstowcs(str), attrs);
1101
1102         if (str && strlen(str) > 0) {
1103             show_preedit_string(ic, ic_uuid);
1104         } else {
1105             hide_preedit_string(ic, ic_uuid);
1106         }
1107     }
1108 }
1109
1110 void CSCLConnectionISF::update_aux_string(const sclchar *str)
1111 {
1112     if (m_initialized) {
1113         scim::AttributeList list;
1114         m_helper_agent.update_aux_string(scim::String(str), list);
1115     }
1116 }
1117
1118 void CSCLConnectionISF::update_input_context(sclu32 type, sclu32 value)
1119 {
1120     if (m_initialized) {
1121         m_helper_agent.update_input_context(type, value);
1122     }
1123 }
1124
1125 void CSCLConnectionISF::update_geometry(sclint x, sclint y, sclint width, sclint height)
1126 {
1127     if (m_initialized) {
1128         m_helper_agent.update_geometry(x, y, width, height);
1129     }
1130 }
1131
1132 void CSCLConnectionISF::get_surrounding_text(const sclchar *ic_uuid, sclint maxlen_before, sclint maxlen_after) const
1133 {
1134     if (m_initialized) {
1135         scim::String uuid;
1136         if (ic_uuid) {
1137             uuid = scim::String(ic_uuid);
1138         }
1139         m_helper_agent.get_surrounding_text(uuid, maxlen_before, maxlen_after);
1140     }
1141 }
1142
1143 sclint CSCLConnectionISF::get_surrounding_text(sclint maxlen_before, sclint maxlen_after, sclchar **text, int &cursor)
1144 {
1145     if (m_initialized) {
1146         scim::String surrounding_text;
1147         m_helper_agent.get_surrounding_text(maxlen_before, maxlen_after, surrounding_text, cursor);
1148
1149         if (text) {
1150             *text = strdup(surrounding_text.c_str());
1151             if (*text == NULL) {
1152                 return -1;
1153             }
1154         }
1155     }
1156     return 0;
1157 }
1158
1159 void CSCLConnectionISF::delete_surrounding_text(sclint offset, sclint len) const
1160 {
1161     if (m_initialized) {
1162         m_helper_agent.delete_surrounding_text(offset, len);
1163     }
1164 }
1165
1166 void CSCLConnectionISF::set_candidate_position(sclint left, sclint top)
1167 {
1168     if (m_initialized) {
1169         m_helper_agent.set_candidate_position(left, top);
1170     }
1171 }
1172
1173 void CSCLConnectionISF::enable_soft_candidate(sclboolean enable)
1174 {
1175     if (m_initialized) {
1176         if (enable)
1177             m_helper_agent.set_candidate_style(scim::ONE_LINE_CANDIDATE, scim::SOFT_CANDIDATE_WINDOW);
1178         else
1179             m_helper_agent.set_candidate_style(scim::ONE_LINE_CANDIDATE, scim::FIXED_CANDIDATE_WINDOW);
1180     }
1181 }
1182
1183 void CSCLConnectionISF::candidate_hide(void)
1184 {
1185     if (m_initialized) {
1186         m_helper_agent.candidate_hide();
1187     }
1188 }
1189
1190 void CSCLConnectionISF::set_keyboard_ise_by_uuid(const sclchar *uuid)
1191 {
1192     if (m_initialized) {
1193         m_helper_agent.set_keyboard_ise_by_uuid(uuid);
1194     }
1195 }
1196
1197 void CSCLConnectionISF::get_keyboard_ise(const sclchar *uuid)
1198 {
1199     if (m_initialized) {
1200         m_helper_agent.get_keyboard_ise(uuid);
1201     }
1202 }
1203
1204 void CSCLConnectionISF::set_selection(sclint start, sclint end)
1205 {
1206     if (m_initialized) {
1207         m_helper_agent.set_selection(start, end);
1208     }
1209 }
1210
1211 void CSCLConnectionISF::send_private_command(const sclchar *command)
1212 {
1213     Eina_Bool tc_command = EINA_FALSE;
1214     CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
1215     ISCLCoreEventCallback *callback = NULL;
1216     if (impl) {
1217         callback = impl->get_core_event_callback();
1218     }
1219     if (command && callback) {
1220         if (strcmp(command, "tizen::tc::test") == 0) {
1221             static Ise_Context context;
1222             static SclCandidateTable table;
1223             static scim::KeyEvent key;
1224             static sclu32 type;
1225             static size_t len;
1226
1227             callback->on_attach_input_context(0, "");
1228             callback->on_detach_input_context(0, "");
1229             callback->on_reload_config(0, "");
1230             callback->on_update_spot_location(0, "", 0, 0);
1231             callback->on_update_cursor_position(0, "", 0);
1232             callback->on_update_surrounding_text(0, NULL, 0);
1233             callback->on_focus_out(0, "");
1234             callback->on_focus_in(0, "");
1235             callback->on_ise_show(0, 0, context);
1236             callback->on_ise_hide(0, "");
1237             callback->on_get_geometry(NULL, NULL, NULL, NULL);
1238             callback->on_set_mode(0);
1239             callback->on_set_language(0);
1240             callback->on_set_imdata(NULL, 0);
1241             callback->on_get_imdata(NULL, NULL);
1242             callback->on_get_language_locale(0, NULL);
1243             callback->on_set_return_key_type(0);
1244             callback->on_get_return_key_type(NULL);
1245             callback->on_set_return_key_disable(0);
1246             callback->on_get_return_key_disable(NULL);
1247             callback->on_set_layout(0);
1248             callback->on_get_layout(NULL);
1249             callback->on_set_caps_mode(0);
1250             callback->on_reset_input_context(0, NULL);
1251             callback->on_update_candidate_geometry(0, NULL, 0, 0, 0, 0);
1252             callback->on_update_keyboard_ise(0, NULL, NULL, NULL);
1253             callback->on_candidate_more_window_show(0, NULL);
1254             callback->on_candidate_more_window_hide(0, NULL);
1255             callback->on_select_aux(0, NULL, 0);
1256             callback->on_select_candidate(0, NULL, 0);
1257             callback->on_candidate_table_page_up(0, NULL);
1258             callback->on_candidate_table_page_down(0, NULL);
1259             callback->on_update_lookup_table(table);
1260             callback->on_update_candidate_table_page_size(0, NULL, 0);
1261             callback->on_select_associate(0, NULL, 0);
1262             callback->on_associate_table_page_up(0, NULL);
1263             callback->on_associate_table_page_down(0, NULL);
1264             callback->on_update_associate_table_page_size(0, NULL, 0);
1265             callback->on_process_key_event(key, NULL);
1266             callback->on_process_key_event_with_keycode(key, NULL, 0);
1267
1268             callback->on_set_display_language(NULL);
1269             callback->on_set_rotation_degree(0);
1270             callback->on_set_accessibility_state(FALSE);
1271
1272             callback->on_create_option_window(SCLWINDOW_INVALID, OPTION_WINDOW_TYPE_NORMAL);
1273             callback->on_destroy_option_window(SCLWINDOW_INVALID);
1274             callback->on_check_option_window_availability(NULL);
1275
1276             callback->on_candidate_show(0, "");
1277             callback->on_candidate_hide(0, "");
1278
1279             callback->on_process_input_device_event(type, NULL, len, NULL);
1280
1281             callback->on_set_prediction_hint(NULL);
1282             callback->on_set_mime_type(NULL);
1283
1284             tc_command = EINA_TRUE;
1285         }
1286     }
1287
1288     if (m_initialized && command && !tc_command) {
1289         m_helper_agent.send_private_command(command);
1290     }
1291 }
1292
1293 void CSCLConnectionISF::get_selection_text(sclchar **text)
1294 {
1295     if (m_initialized) {
1296         scim::String selection_text;
1297         m_helper_agent.get_selection_text(selection_text);
1298
1299         if (text)
1300             *text = strdup(selection_text.c_str());
1301     }
1302 }
1303
1304 void CSCLConnectionISF::request_ise_hide()
1305 {
1306     if (m_initialized) {
1307         m_helper_agent.request_ise_hide();
1308     }
1309 }
1310
1311 void CSCLConnectionISF::commit_content(const sclchar *content, const sclchar *description, const sclchar *mime_types)
1312 {
1313     if (m_initialized) {
1314         m_helper_agent.commit_content(content, description, mime_types);
1315     }
1316 }
1317
1318 extern "C"
1319 {
1320     EXAPI void scim_module_init(void) {
1321     }
1322
1323     EXAPI void scim_module_exit(void) {
1324     }
1325
1326     EXAPI void scim_helper_module_run_helper(const scim::String &uuid, const scim::ConfigPointer &config, const scim::String &display) {
1327         _scim_config = config;
1328         CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
1329         if (impl) {
1330             impl->on_run(uuid.c_str(), display.c_str());
1331         }
1332     }
1333 }