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