2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
24 #include <vconf-keys.h>
26 #include <system_info.h>
28 #include "w-input-selector.h"
29 #include "w-input-template.h"
30 #include "w-input-keyboard.h"
31 #include "w-input-stt-ise.h"
32 #include "w-input-emoticon.h"
33 #include "w-input-smartreply.h"
40 App_Data* app_data = NULL;
42 InputKeyboardData g_input_keyboard_data;
43 InputTypeData g_input_type_data;
44 InputTemplateData g_input_template_data;
46 static bool g_set_mimetype_in_app_service = false;
47 static bool g_set_mimetype_in_app_resume = false;
49 static Elm_Object_Item *it_empty;
50 static Elm_Object_Item *it_title;
52 static unsigned int g_smartreply_item_size = 0; /* Current Smartreply item size */
53 static unsigned int g_template_item_size = 0; /* Current Template item size */
55 Evas_Coord last_step; // 0 ~ 9 for gesture, 10~11 for rotary
57 tizen_profile_t _get_tizen_profile()
59 static tizen_profile_t profile = TIZEN_PROFILE_UNKNOWN;
60 if (__builtin_expect(profile != TIZEN_PROFILE_UNKNOWN, 1))
64 system_info_get_platform_string("http://tizen.org/feature/profile", &profileName);
69 profile = TIZEN_PROFILE_MOBILE;
73 profile = TIZEN_PROFILE_WEARABLE;
77 profile = TIZEN_PROFILE_TV;
81 profile = TIZEN_PROFILE_IVI;
83 default: // common or unknown ==> ALL ARE COMMON.
84 profile = TIZEN_PROFILE_COMMON;
91 void _init_app_data(App_Data* app_data);
92 static void _app_language_changed(app_event_info_h event_info, void *user_data);
94 Evas_Object* _create_genlist(Evas_Object* parent);
95 void _create_genlist_items(void* user_data);
96 void _create_header_items(void *user_data);
97 void _update_genlist_items(void *user_data);
98 unsigned int _update_smartreply_items(void *user_data);
99 unsigned int _update_template_items(void *user_data);
100 unsigned int _update_user_template_items(void *user_data);
101 static void _popup_close_cb(void *data, Evas_Object *obj, void *event_info);
102 static void _popup_back_cb(void *data, Evas_Object *obj, void *event_info);
103 static void input_type_deinit(void);
105 bool __compare_string(const char * src, const char * dst);
107 void _init_app_data(App_Data* app_data)
109 app_data->win_main = NULL;
110 app_data->layout_main = NULL;
111 app_data->conform = NULL;
112 app_data->naviframe = NULL;
113 app_data->genlist = NULL;
115 app_data->res_path = NULL;
118 Evas_Object* load_edj(Evas_Object* parent, const char* file, const char* group)
121 Evas_Object* content;
124 window = elm_layout_add(parent);
126 ret = elm_layout_file_set(window, file, group);
128 evas_object_del(window);
132 content = elm_layout_add(parent);
133 elm_layout_theme_set(content, "layout", "application", "default");
134 elm_object_part_content_set(window, "elm.swallow.content", content);
136 evas_object_size_hint_weight_set(window, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
141 void init_customizing_theme(void)
143 string stt_edj_path = get_resource_path();
144 string app_edj_path = get_resource_path();
147 stt_edj_path = stt_edj_path + STT_EDJ_FILE_WEARABLE;
148 app_edj_path = app_edj_path + APP_EDJ_FILE_WEARABLE;
150 stt_edj_path = stt_edj_path + STT_EDJ_FILE_TV;
151 app_edj_path = app_edj_path + APP_EDJ_FILE_TV;
153 stt_edj_path = stt_edj_path + STT_EDJ_FILE_MOBILE;
154 app_edj_path = app_edj_path + APP_EDJ_FILE_MOBILE;
157 elm_theme_extension_add(NULL, stt_edj_path.c_str());
158 elm_theme_extension_add(NULL, app_edj_path.c_str());
161 static Eina_Bool back_cb(void *data, Elm_Object_Item *it)
163 reply_to_sender_by_callback_for_back();
168 static void _stt_clicked_cb(void *data, Evas_Object * obj, void *event_info)
170 App_Data* ad = (App_Data*)data;
172 PRINTFUNC(DLOG_DEBUG, "");
177 ise_show_stt_popup(ad);
180 static void _input_smartreply_notify_cb(void *user_data)
182 ecore_main_loop_iterate();
183 _update_genlist_items((void *)app_data);
186 static void _input_template_notify_cb(void *user_data)
188 _update_genlist_items((void *)app_data);
191 static void _emoticon_clicked_cb(void *data, Evas_Object * obj, void *event_info)
193 App_Data* ad = (App_Data*)data;
195 PRINTFUNC(DLOG_DEBUG, "");
200 ise_show_emoticon_list(ad);
203 static void _keyboard_clicked_cb(void *data, Evas_Object * obj, void *event_info)
205 App_Data* ad = (App_Data *)data;
207 PRINTFUNC(DLOG_DEBUG, "");
212 input_keyboard_launch(ad->win_main, data);
215 static void __ise_smartreply_gl_sel(void *data, Evas_Object *obj, void *event_info)
217 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
220 elm_genlist_item_selected_set(item, EINA_FALSE);
222 int index = (intptr_t) elm_object_item_data_get(item);
225 char *reply = input_smartreply_get_nth_item(index, &type);
227 input_smartreply_send_feedback(reply);
228 reply_to_sender_by_callback(reply, "smartreply", NULL, NULL);
235 static void __ise_template_gl_sel(void *data, Evas_Object *obj, void *event_info)
237 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
241 elm_genlist_item_selected_set(item, EINA_FALSE);
243 index = (uintptr_t) elm_object_item_data_get(item);
244 const std::vector<TemplateData> template_list = input_template_get_list();
246 if (index < (int)template_list.size()) {
247 reply_to_sender_by_callback(gettext(template_list[index].text.c_str()), "template", NULL, NULL);
253 static void __ise_user_template_gl_sel(void *data, Evas_Object *obj, void *event_info)
255 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
259 elm_genlist_item_selected_set(item, EINA_FALSE);
261 index = (uintptr_t) elm_object_item_data_get(item);
263 if (index < (int)g_input_template_data.input_template_array_len) {
264 reply_to_sender_by_callback(g_input_template_data.input_template_array[index], "user_template", NULL, NULL);
270 static char * __ise_template_gl_text_get(void *data, Evas_Object *obj, const char *part)
272 if (!strcmp(part, "elm.text")) {
273 unsigned int index = (uintptr_t)data;
274 const std::vector<TemplateData> template_list = input_template_get_list();
276 if (index < template_list.size()) {
277 if (template_list[index].use_gettext) {
278 return strdup(gettext(template_list[index].text.c_str()));
280 Eina_Strbuf *buf = NULL;
281 const char *str = NULL;
284 buf = eina_strbuf_new();
286 eina_strbuf_append(buf, template_list[index].text.c_str());
287 eina_strbuf_replace_all(buf, "\n", "");
288 eina_strbuf_replace_all(buf, "\r", "");
290 str = eina_strbuf_string_get(buf);
293 markup = elm_entry_utf8_to_markup(str);
295 eina_strbuf_free(buf);
304 static char * __ise_user_template_gl_text_get(void *data, Evas_Object *obj, const char *part)
306 if (!strcmp(part, "elm.text")) {
307 unsigned int index = (uintptr_t)data;
308 if (index < (unsigned int)g_input_template_data.input_template_array_len) {
309 if (g_input_template_data.input_template_array[index] != NULL) {
310 return strdup(g_input_template_data.input_template_array[index]);
317 static Evas_Object * __ise_gl_2button_content_get(void *data, Evas_Object *obj, const char *part)
319 char *first_input_type = *(g_input_type_data.input_type_array + 0);
320 char *second_input_type = *(g_input_type_data.input_type_array + 1);
322 if (!strcmp(part, "elm.icon.1") || (!strcmp(part, "elm.icon.2"))) {
323 Evas_Object* btn = elm_button_add(obj);
324 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
325 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
327 Evas_Object* ic = elm_image_add(btn);
328 elm_image_resizable_set(ic, EINA_TRUE, EINA_TRUE);
329 string path = get_resource_path();
331 path = path + "wearable/";
335 path = path + "mobile/";
337 if (!strcmp(part, "elm.icon.1")) {
339 if (!strcmp(first_input_type, "input_voice")) {
340 elm_object_style_set(btn, "ime_button_stt");
341 path_ic = path + "images/w_mode_stt_ic.png";
342 evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
343 elm_atspi_accessible_name_set(btn, "IDS_IME_MBODY_VOICE_INPUT");
344 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
345 } else if (!strcmp(first_input_type, "input_emoticon")) {
346 elm_object_style_set(btn, "ime_button_emoticon");
347 path_ic = path + "images/Delta_w_mode_emoticon_ic.png";
348 evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
349 elm_atspi_accessible_name_set(btn, "IDS_COM_HEADER_EMOTICON");
350 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
351 } else if (!strcmp(first_input_type, "input_keyboard")) {
352 elm_object_style_set(btn, "ime_button_keyboard");
353 path_ic = path + "images/w_mode_keyboard_ic.png";
354 evas_object_propagate_events_set(btn, EINA_FALSE);
355 evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
356 elm_atspi_accessible_name_set(btn, "IDS_COM_OPT_KEYBOARD");
357 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
359 elm_image_file_set(ic, path_ic.c_str(), NULL);
360 elm_object_content_set(btn, ic);
361 evas_object_layer_set(btn, 32000);
362 } else if (!strcmp(part, "elm.icon.2")){
364 if (!strcmp(second_input_type, "input_voice")) {
365 elm_object_style_set(btn, "ime_button_stt");
366 path_ic = path + "images/w_mode_stt_ic.png";
367 evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
368 elm_atspi_accessible_name_set(btn, "IDS_IME_MBODY_VOICE_INPUT");
369 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
370 } else if (!strcmp(second_input_type, "input_emoticon")) {
371 elm_object_style_set(btn, "ime_button_emoticon");
372 path_ic = path + "images/Delta_w_mode_emoticon_ic.png";
373 evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
374 elm_atspi_accessible_name_set(btn, "IDS_COM_HEADER_EMOTICON");
375 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
376 } else if (!strcmp(second_input_type, "input_keyboard")) {
377 elm_object_style_set(btn, "ime_button_keyboard");
378 path_ic = path + "images/w_mode_keyboard_ic.png";
379 evas_object_propagate_events_set(btn, EINA_FALSE);
380 evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
381 elm_atspi_accessible_name_set(btn, "IDS_COM_OPT_KEYBOARD");
382 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
384 elm_image_file_set(ic, path_ic.c_str(), NULL);
385 elm_object_content_set(btn, ic);
386 evas_object_layer_set(btn, 32000);
389 } else if (!strcmp(part, "elm.icon.1.touch_area") || (!strcmp(part, "elm.icon.2.touch_area"))) {
390 Evas_Object* btn = elm_button_add(obj);
391 elm_object_style_set(btn, "touch_area");
392 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
393 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
394 string path = get_resource_path();
395 if (!strcmp(part, "elm.icon.1.touch_area")) {
396 evas_object_layer_set(btn, 32000);
397 if (!strcmp(first_input_type, "input_voice")) {
398 evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
399 elm_atspi_accessible_name_set(btn, "IDS_IME_MBODY_VOICE_INPUT");
400 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
401 } else if (!strcmp(first_input_type, "input_emoticon")) {
402 evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
403 elm_atspi_accessible_name_set(btn, "IDS_COM_HEADER_EMOTICON");
404 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
405 } else if (!strcmp(first_input_type, "input_keyboard")) {
406 evas_object_propagate_events_set(btn, EINA_FALSE);
407 evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
408 elm_atspi_accessible_name_set(btn, "IDS_COM_OPT_KEYBOARD");
409 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
411 } else if (!strcmp(part, "elm.icon.2.touch_area")){
412 evas_object_layer_set(btn, 32000);
413 if (!strcmp(second_input_type, "input_voice")) {
414 evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
415 elm_atspi_accessible_name_set(btn, "IDS_IME_MBODY_VOICE_INPUT");
416 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
417 } else if (!strcmp(second_input_type, "input_emoticon")) {
418 evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
419 elm_atspi_accessible_name_set(btn, "IDS_COM_HEADER_EMOTICON");
420 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
421 } else if (!strcmp(second_input_type, "input_keyboard")) {
422 evas_object_propagate_events_set(btn, EINA_FALSE);
423 evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
424 elm_atspi_accessible_name_set(btn, "IDS_COM_OPT_KEYBOARD");
425 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
429 } else if (!strcmp(part, "base")) {
430 Evas_Object* btn = elm_button_add(obj);
431 elm_object_style_set(btn, "ime_transparent");
437 static Evas_Object * __ise_gl_3button_content_get(void *data, Evas_Object *obj, const char *part)
439 if (!strcmp(part, "elm.icon.1") || (!strcmp(part, "elm.icon.2")) || (!strcmp(part, "elm.icon.3"))) {
440 Evas_Object* btn = elm_button_add(obj);
441 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
442 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
443 Evas_Object* ic = elm_image_add(btn);
444 elm_image_resizable_set(ic, EINA_TRUE, EINA_TRUE);
445 string path = get_resource_path();
447 path = path + "wearable/";
451 path = path + "mobile/";
453 if (!strcmp(part, "elm.icon.1")) {
454 elm_object_style_set(btn, "ime_button_stt");
455 string path_ic = path + "images/w_mode_stt_ic.png";
456 elm_image_file_set(ic, path_ic.c_str(), NULL);
457 elm_object_content_set(btn, ic);
458 evas_object_layer_set(btn, 32000);
459 evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
460 elm_atspi_accessible_name_set(btn, "IDS_IME_MBODY_VOICE_INPUT");
461 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
463 } else if (!strcmp(part, "elm.icon.2")){
464 elm_object_style_set(btn, "ime_button_emoticon");
465 string path_ic = path + "images/Delta_w_mode_emoticon_ic.png";
466 elm_image_file_set(ic, path_ic.c_str(), NULL);
467 elm_object_content_set(btn, ic);
468 evas_object_layer_set(btn, 32000);
469 evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
470 elm_atspi_accessible_name_set(btn, "IDS_COM_HEADER_EMOTICON");
471 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
473 } else if (!strcmp(part, "elm.icon.3")){
474 elm_object_style_set(btn, "ime_button_keyboard");
475 string path_ic = path + "images/w_mode_keyboard_ic.png";
476 elm_image_file_set(ic, path_ic.c_str(), NULL);
477 elm_object_content_set(btn, ic);
478 evas_object_layer_set(btn, 32000);
479 evas_object_propagate_events_set(btn, EINA_FALSE);
480 evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
481 elm_atspi_accessible_name_set(btn, "IDS_COM_OPT_KEYBOARD");
482 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
486 } else if (!strcmp(part, "elm.icon.1.touch_area") || (!strcmp(part, "elm.icon.2.touch_area")) || (!strcmp(part, "elm.icon.3.touch_area"))) {
487 Evas_Object* btn = elm_button_add(obj);
488 elm_object_style_set(btn, "touch_area");
489 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
490 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
491 string path = get_resource_path();
492 if (!strcmp(part, "elm.icon.1.touch_area")) {
493 evas_object_layer_set(btn, 32000);
494 evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
495 elm_atspi_accessible_name_set(btn, "IDS_IME_MBODY_VOICE_INPUT");
496 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
498 } else if (!strcmp(part, "elm.icon.2.touch_area")){
499 evas_object_layer_set(btn, 32000);
500 evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
501 elm_atspi_accessible_name_set(btn, "IDS_COM_HEADER_EMOTICON");
502 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
503 } else if (!strcmp(part, "elm.icon.3.touch_area")) {
504 evas_object_layer_set(btn, 32000);
505 evas_object_propagate_events_set(btn, EINA_FALSE);
506 evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
507 elm_atspi_accessible_name_set(btn, "IDS_COM_OPT_KEYBOARD");
508 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
512 } else if (!strcmp(part, "base")) {
513 Evas_Object* btn = elm_button_add(obj);
514 elm_object_style_set(btn, "ime_transparent");
520 static char * __ise_smartreply_gl_text_get(void *data, Evas_Object *obj, const char *part)
522 if(!strcmp(part, "elm.text")) {
525 index = (intptr_t)data;
529 reply = input_smartreply_get_nth_item(index, NULL);
538 static void __ise_gl_lang_changed(void *data, Evas_Object *obj, void *event_info)
540 //Update genlist items. The Item texts will be translated in the _gl_text_get().
541 elm_genlist_realized_items_update(obj);
544 static char * __ise_drawing_text_get(void *data, Evas_Object *obj, const char *part)
546 if(!strcmp(part, "elm.text")) {
547 return(strdup(gettext("WDS_IME_MBODY_DRAWING_M_EMOTICON_ABB")));
552 static Evas_Object * __ise_drawing_content_get(void *data, Evas_Object *obj, const char *part)
554 if (!strcmp(part, "elm.icon")) {
555 Evas_Object* btn = elm_button_add(obj);
556 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
557 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
558 Evas_Object* ic = elm_image_add(btn);
559 elm_image_resizable_set(ic, EINA_TRUE, EINA_TRUE);
560 string path = get_resource_path();
562 path = path + "wearable/";
566 path = path + "mobile/";
567 elm_object_style_set(btn, "ime_button_drawing");
568 string path_ic = path + "images/wi_drawing_icon.png";
569 elm_image_file_set(ic, path_ic.c_str(), NULL);
570 elm_object_content_set(btn, ic);
571 evas_object_layer_set(btn, 32000);
577 void set_source_caller_app_id(app_control_h app_control)
580 PRINTFUNC(DLOG_ERROR, "can't get app_control");
585 app_control_get_caller(app_data->source_app_control, &caller);
588 PRINTFUNC(DLOG_DEBUG, "caller = %s", caller);
589 app_control_add_extra_data(app_control, "caller_appid", caller);
594 void reply_to_sender_by_callback(const char *value, const char *type, const char *path[], const char *cursor_position)
596 PRINTFUNC(DLOG_DEBUG, "");
598 app_control_h app_control;
600 if (app_control_create(&app_control) == 0) {
604 app_control_add_extra_data(app_control, APP_CONTROL_DATA_TEXT, value);
607 app_control_add_extra_data(app_control, "reply_type", type);
610 app_control_add_extra_data_array(app_control, APP_CONTROL_DATA_PATH, path, 1);
613 if (cursor_position != NULL)
614 app_control_add_extra_data(app_control, "cursor_position_get", cursor_position);
616 set_source_caller_app_id(app_control);
618 ret = app_control_reply_to_launch_request(app_control, app_data->source_app_control, APP_CONTROL_RESULT_SUCCEEDED);
619 if (ret != APP_CONTROL_ERROR_NONE)
620 PRINTFUNC(DLOG_ERROR, "reply failed : %d", ret);
622 app_control_destroy(app_control);
623 app_control_destroy(app_data->source_app_control);
624 app_data->source_app_control = NULL;
628 void reply_to_sender_by_callback_for_back()
630 PRINTFUNC(DLOG_DEBUG, "");
632 app_control_h app_control;
634 if (app_control_create(&app_control) == 0) {
637 app_control_add_extra_data(app_control, "back_to_composer", "yes");
639 ret = app_control_reply_to_launch_request(app_control, app_data->source_app_control, APP_CONTROL_RESULT_SUCCEEDED);
640 if (ret != APP_CONTROL_ERROR_NONE)
641 PRINTFUNC(DLOG_ERROR, "reply failed : %d", ret);
643 app_control_destroy(app_control);
644 app_control_destroy(app_data->source_app_control);
645 app_data->source_app_control = NULL;
649 char* get_resource_path()
651 if (NULL == app_data->res_path) {
652 app_data->res_path = app_get_resource_path();
653 PRINTFUNC(DLOG_INFO, "set resource path = %s", app_data->res_path);
655 return (app_data->res_path);
658 char* get_shared_resource_path()
660 if (NULL == app_data->shared_res_path) {
661 app_data->shared_res_path = app_get_shared_resource_path();
662 PRINTFUNC(DLOG_INFO, "set shared resource path = %s", app_data->shared_res_path);
664 return (app_data->shared_res_path);
667 void show_gl_focus(Eina_Bool bVisible){
668 if (app_data->genlist == NULL)
671 if (bVisible == EINA_TRUE){
672 elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,enable", "elm");
673 //elm_layout_theme_set(app_data->genlist, "genlist", "base", "focus_bg");
674 //elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,show", "elm");
676 elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,disable", "elm");
677 //elm_layout_theme_set(app_data->genlist, "genlist", "base", "default");
678 //elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,hide", "elm");
682 void show_popup_toast(const char *text, bool check_img)
684 PRINTFUNC(DLOG_ERROR, "show_popup_toast");
688 popup = elm_popup_add(app_data->win_main);
689 elm_object_style_set(popup, "toast/circle");
690 elm_popup_orient_set(popup, ELM_POPUP_ORIENT_BOTTOM);
691 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
694 string path = get_resource_path();
696 path = path + "wearable/";
700 path = path + "mobile/";
701 string path_ic = path + "/images/toast_check_icon.png";
702 Evas_Object * img = elm_image_add(popup);
703 elm_image_file_set(img, path_ic.c_str(), NULL);
704 elm_object_part_content_set(popup, "toast,icon", img);
707 elm_object_part_text_set(popup, "elm.text", text);
710 eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, _popup_back_cb, NULL);
711 evas_object_smart_callback_add(popup, "dismissed", _popup_close_cb, NULL);
712 evas_object_smart_callback_add(popup, "block,clicked", _popup_back_cb, NULL);
714 elm_popup_timeout_set(popup, 2.0);
715 evas_object_show(popup);
718 static void _popup_close_cb(void *data, Evas_Object *obj, void *event_info)
721 evas_object_hide(obj);
722 evas_object_del(obj);
726 static void _popup_back_cb(void *data, Evas_Object *obj, void *event_info)
729 elm_popup_dismiss(obj);
733 void _back_to_genlist_for_selector()
735 PRINTFUNC(DLOG_DEBUG, "");
737 if (!app_data) return;
740 Evas_Object *circle_genlist = (Evas_Object *) evas_object_data_get(app_data->genlist, "circle");
741 eext_rotary_object_event_activated_set(circle_genlist, EINA_TRUE);
743 if (app_data->app_type == APP_TYPE_STT || app_data->app_type == APP_TYPE_EMOTICON || app_data->app_type == APP_TYPE_KEYBOARD){
744 PRINTFUNC(DLOG_DEBUG, "launched as STT/EMOTICON/KEYBOARD mode, So exit here.");
745 reply_to_sender_by_callback(NULL, NULL, NULL, NULL);
750 static void _item_realized(void *data, Evas_Object *obj, void *event_info) //called when list scrolled
752 PRINTFUNC(DLOG_DEBUG, "%s", __func__);
755 Evas_Object* _create_genlist(Evas_Object* navi)
757 Evas_Object* genlist = elm_genlist_add(navi);
761 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
763 Evas_Object* circle_object_genlist = eext_circle_object_genlist_add(genlist, app_data->circle_surface);
764 eext_circle_object_genlist_scroller_policy_set(circle_object_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
765 evas_object_data_set(genlist, "circle", (void *) circle_object_genlist);
766 eext_rotary_object_event_activated_set(circle_object_genlist, EINA_TRUE);
768 evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
769 evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
771 evas_object_smart_callback_add(genlist, "language,changed", __ise_gl_lang_changed, genlist);
772 evas_object_show(genlist);
774 // uxt_genlist_set_bottom_margin_enabled(genlist, EINA_TRUE);
776 show_gl_focus(EINA_FALSE);
778 const char *item_style = NULL;
780 item_style = "empty";
781 Elm_Object_Item *nf_main_item = elm_naviframe_item_push(navi,
788 elm_naviframe_item_pop_cb_set(nf_main_item, back_cb, app_data);
789 evas_object_smart_callback_add(genlist, "realized", _item_realized, NULL);
794 static void _item_position_changed_cb(void *data, Evas_Object *obj, void *event_info)
799 Evas_Object *genlist = (Evas_Object *)obj;
800 Elm_Object_Item *gen_item = (Elm_Object_Item *)data;
803 elm_scroller_region_get(genlist, NULL, &y, NULL, NULL);
805 // PRINTFUNC(DLOG_DEBUG,"y=%d",y);
807 if (250 > y && y >= 100){
808 if (last_step == 0) return;
810 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.0", "elm");
811 show_gl_focus(EINA_TRUE);
812 } else if (100 > y && y >= 50){
813 if (last_step == 1) return;
815 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.1", "elm");
816 show_gl_focus(EINA_TRUE);
817 } else if (y < 50 && y >=0){
818 if (last_step == 2) return;
820 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.9", "elm");
821 show_gl_focus(EINA_FALSE);
825 void _create_genlist_items(void* user_data)
827 App_Data* app_data = (App_Data*) user_data;
829 if (NULL == app_data->genlist) {
830 app_data->genlist = _create_genlist(app_data->naviframe);
831 if (NULL == app_data->genlist)
835 elm_genlist_clear(app_data->genlist);
837 Elm_Genlist_Item_Class * itc0 = elm_genlist_item_class_new();
838 itc0->item_style = NULL;
839 itc0->func.text_get = NULL;
840 itc0->func.content_get = NULL;
841 itc0->func.state_get = NULL;
842 itc0->func.del = NULL;
844 Elm_Genlist_Item_Class * itc1 = elm_genlist_item_class_new();
845 if (g_input_type_data.input_type_array_len == 2){
846 itc1->item_style = "2button_flat";
847 itc1->func.text_get = NULL;
848 itc1->func.content_get = __ise_gl_2button_content_get;
849 itc1->func.state_get = NULL;
850 itc1->func.del = NULL;
852 itc1->item_style = "3button_flat";
853 itc1->func.text_get = NULL;
854 itc1->func.content_get = __ise_gl_3button_content_get;
855 itc1->func.state_get = NULL;
856 itc1->func.del = NULL;
859 // dummy title for empty space
860 it_empty = elm_genlist_item_append(app_data->genlist, itc0,
862 ELM_GENLIST_ITEM_NONE,
865 if (app_data->app_type != APP_TYPE_REPLY) {
867 it_title = elm_genlist_item_append(app_data->genlist, itc1,
869 ELM_GENLIST_ITEM_NONE,
873 elm_genlist_item_select_mode_set(it_title, ELM_OBJECT_SELECT_MODE_NONE);
875 g_template_item_size = _update_template_items(app_data);
877 Elm_Object_Item *item = elm_genlist_item_next_get(it_title);
878 elm_genlist_item_show(item, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
880 evas_object_smart_callback_add(app_data->genlist, "elm,item,position,changed", _item_position_changed_cb, it_title);
882 elm_genlist_item_class_free(itc0);
883 elm_genlist_item_class_free(itc1);
886 void _create_header_items(void *user_data)
888 Elm_Genlist_Item_Class * itc0 = elm_genlist_item_class_new();
889 itc0->item_style = "title";
890 itc0->func.text_get = NULL;
891 itc0->func.content_get = NULL;
892 itc0->func.state_get = NULL;
893 itc0->func.del = NULL;
895 Elm_Genlist_Item_Class * itc1 = elm_genlist_item_class_new();
896 if (g_input_type_data.input_type_array_len == 2) {
897 itc1->item_style = "2button_flat";
898 itc1->func.text_get = NULL;
899 itc1->func.content_get = __ise_gl_2button_content_get;
900 itc1->func.state_get = NULL;
901 itc1->func.del = NULL;
903 itc1->item_style = "3button_flat";
904 itc1->func.text_get = NULL;
905 itc1->func.content_get = __ise_gl_3button_content_get;
906 itc1->func.state_get = NULL;
907 itc1->func.del = NULL;
910 // dummy title for empty space
911 it_empty = elm_genlist_item_append(app_data->genlist, itc0,
913 ELM_GENLIST_ITEM_NONE,
917 it_title = elm_genlist_item_append(app_data->genlist, itc1,
919 ELM_GENLIST_ITEM_NONE,
922 elm_genlist_item_select_mode_set(it_title, ELM_OBJECT_SELECT_MODE_NONE);
924 elm_genlist_item_class_free(itc0);
925 elm_genlist_item_class_free(itc1);
928 void _update_genlist_items(void *user_data)
930 elm_genlist_clear(app_data->genlist);
932 _create_header_items(user_data);
934 if (input_smartreply_is_enabled())
935 g_smartreply_item_size = _update_smartreply_items(user_data);
937 g_smartreply_item_size = 0;
939 g_template_item_size = _update_template_items(user_data);
941 if (g_input_template_data.input_template_array_len > 0) {
942 _update_user_template_items(user_data);
945 /* Update genlist item position */
946 Elm_Object_Item *item = elm_genlist_item_next_get(it_title);
947 elm_genlist_item_show(item, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
950 unsigned int _update_smartreply_items(void *user_data)
954 Elm_Object_Item *first;
957 unsigned int len = 0;
958 unsigned int item_size = 0;
960 app_data = (App_Data *)user_data;
962 if (app_data == NULL) {
963 PRINTFUNC(DLOG_ERROR, "Can not get app_data");
967 if (app_data->genlist == NULL) {
968 /* smartreply will update when genlist is exist only */
969 PRINTFUNC(DLOG_ERROR, "Can not get getlist");
973 /* Move to smartreply */
974 first = elm_genlist_first_item_get(app_data->genlist);
975 elm_genlist_item_next_get(first);
977 if (input_smartreply_is_enabled() == false)
980 /* Append newly added smartreply list */
981 len = input_smartreply_get_reply_num();
984 const std::vector<TemplateData> template_list = input_template_get_list();
986 Elm_Genlist_Item_Class *itc;
988 itc = elm_genlist_item_class_new();
989 itc->item_style = "1text";
990 itc->func.text_get = __ise_smartreply_gl_text_get;
991 itc->func.content_get = NULL;
992 itc->func.state_get = NULL;
993 itc->func.del = NULL;
995 for (i = 0; i < len; i++) {
996 char *reply = (char *)"hello";
1003 reply = input_smartreply_get_nth_item(i, &type);
1006 SECURE_LOGD("SmartReply = [%d]%s", i, reply);
1008 for (j = 0; j < template_list.size(); j++) {
1009 const char *template_str;
1011 if (template_list[j].use_gettext)
1012 template_str = gettext(template_list[j].text.c_str());
1014 template_str = template_list[j].text.c_str();
1016 if (!__compare_string(reply, template_str)) {
1022 if (matched == true)
1025 elm_genlist_item_append(app_data->genlist,
1027 (void *)(uintptr_t)i,
1029 ELM_GENLIST_ITEM_NONE,
1030 __ise_smartreply_gl_sel,
1035 if (item_size >= 3) {
1039 elm_genlist_item_class_free(itc);
1044 static void _drawing_item_clicked_cb(void *data, Evas_Object * obj, void *event_info)
1046 PRINTFUNC(DLOG_DEBUG, "%s", __func__);
1047 App_Data* ad = (App_Data*) data;
1051 launch_drawing_app(ad);
1054 unsigned int _update_template_items(void *user_data)
1058 Elm_Object_Item *first;
1059 Elm_Object_Item *menu;
1060 Elm_Object_Item *pos;
1063 unsigned int item_size = 0;
1065 app_data = (App_Data *)user_data;
1067 if (app_data == NULL) {
1068 PRINTFUNC(DLOG_ERROR, "Can not get app_data");
1072 if (app_data->genlist == NULL) {
1073 /* smartreply will update when genlist is exist only */
1074 PRINTFUNC(DLOG_ERROR, "Can not get getlist");
1078 first = elm_genlist_first_item_get(app_data->genlist);
1081 menu = elm_genlist_item_next_get(first);
1084 /* move to smartreply next if it need */
1085 if (input_smartreply_is_enabled()) {
1088 for (j = 0; j < g_smartreply_item_size; j++) {
1092 pos = elm_genlist_item_next_get(pos);
1096 /* Append New Template list */
1097 const std::vector<TemplateData> template_list = input_template_get_list();
1099 if (template_list.size() > 0) {
1100 Elm_Genlist_Item_Class *itc;
1102 itc = elm_genlist_item_class_new();
1104 itc->item_style = "1text";
1105 itc->func.text_get = __ise_template_gl_text_get;
1106 itc->func.content_get = NULL;
1107 itc->func.state_get = NULL;
1108 itc->func.del = NULL;
1110 for (i = 0; i < template_list.size(); i++) {
1111 pos = elm_genlist_item_append(app_data->genlist,
1113 (void *)(uintptr_t)i,
1115 ELM_GENLIST_ITEM_NONE,
1116 __ise_template_gl_sel,
1120 elm_genlist_item_class_free(itc);
1122 // drawing button (+)
1123 if (app_data->mime_type == MIME_TYPE_ALL && app_data->app_type == APP_TYPE_SELECT_MODE) {
1124 Elm_Genlist_Item_Class *itc;
1125 itc = elm_genlist_item_class_new();
1127 itc->item_style = "1text.1icon";
1128 itc->func.text_get = __ise_drawing_text_get;;
1129 itc->func.content_get = __ise_drawing_content_get;
1130 itc->func.state_get = NULL;
1131 itc->func.del = NULL;
1133 elm_genlist_item_append(app_data->genlist,
1137 ELM_GENLIST_ITEM_NONE,
1138 _drawing_item_clicked_cb,
1141 elm_genlist_item_class_free(itc);
1144 // dummy item for empty space
1145 Elm_Genlist_Item_Class * itc0 = elm_genlist_item_class_new();
1146 itc0->item_style = "title";
1147 itc0->func.text_get = NULL;
1148 itc0->func.content_get = NULL;
1149 itc0->func.state_get = NULL;
1150 itc0->func.del = NULL;
1152 if (g_input_template_data.input_template_array_len < 1) {
1153 it_empty = elm_genlist_item_append(app_data->genlist, itc0,
1155 ELM_GENLIST_ITEM_NONE,
1158 elm_genlist_item_class_free(itc0);
1164 unsigned int _update_user_template_items(void *user_data)
1168 Elm_Object_Item *first;
1171 unsigned int item_size = 0;
1173 app_data = (App_Data *)user_data;
1175 if (app_data == NULL) {
1176 PRINTFUNC(DLOG_ERROR, "Can not get app_data");
1180 if (app_data->genlist == NULL) {
1181 /* smartreply will update when genlist is exist only */
1182 PRINTFUNC(DLOG_ERROR, "Can not get getlist");
1186 first = elm_genlist_first_item_get(app_data->genlist);
1190 if (g_input_template_data.input_template_array_len > 0) {
1191 Elm_Genlist_Item_Class *itc;
1193 itc = elm_genlist_item_class_new();
1195 itc->item_style = "1text";
1196 itc->func.text_get = __ise_user_template_gl_text_get;
1197 itc->func.content_get = NULL;
1198 itc->func.state_get = NULL;
1199 itc->func.del = NULL;
1201 for (i = 0; i < (unsigned int)g_input_template_data.input_template_array_len; i++) {
1202 elm_genlist_item_append(app_data->genlist,
1204 (void *)(uintptr_t)i,
1206 ELM_GENLIST_ITEM_NONE,
1207 __ise_user_template_gl_sel,
1211 elm_genlist_item_class_free(itc);
1213 // dummy item for empty space
1214 Elm_Genlist_Item_Class * itc0 = elm_genlist_item_class_new();
1215 itc0->item_style = "title";
1216 itc0->func.text_get = NULL;
1217 itc0->func.content_get = NULL;
1218 itc0->func.state_get = NULL;
1219 itc0->func.del = NULL;
1221 it_empty = elm_genlist_item_append(app_data->genlist, itc0,
1223 ELM_GENLIST_ITEM_NONE,
1225 elm_genlist_item_class_free(itc0);
1231 bool __compare_string(const char * smart_str, const char * template_str)
1237 if(!smart_str||!template_str)
1240 src_len = strlen(smart_str);
1241 dst_len = strlen(template_str);
1243 if(smart_str[src_len-1] == '.')
1246 while(template_str[dst_len-1] == ' ')
1248 if(template_str[dst_len-1] == '.')
1251 dst_len = (dst_len > src_len)? dst_len : src_len;
1253 if(!strncmp(smart_str, template_str, (size_t)dst_len))
1259 bool _app_create(void* user_data)
1261 int width = 1000, height = 1000;
1262 // App_Data* app_data = NULL;
1263 Evas_Object* layout = NULL;
1264 Evas_Object* conform = NULL;
1265 Evas_Object* bg = NULL;
1266 Evas_Object* window = NULL;
1267 Eext_Circle_Surface *surface = NULL;
1273 _app_language_changed(NULL, NULL);
1275 app_data = (App_Data*)user_data;
1277 elm_app_base_scale_set(1.3);
1279 window = elm_win_add(NULL, PACKAGE, ELM_WIN_BASIC);
1281 init_customizing_theme();
1283 elm_win_title_set(window, PACKAGE);
1284 elm_win_borderless_set(window, EINA_TRUE);
1285 // ecore_x_window_size_get(ecore_x_window_root_first_get(), &width, &height);
1286 evas_object_resize(window, width, height);
1287 elm_win_indicator_mode_set(window, ELM_WIN_INDICATOR_SHOW);
1289 LOGE("elm_win_add() is failed.");
1293 bg = elm_bg_add(window);
1294 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1295 elm_win_resize_object_add(window, bg);
1296 evas_object_show(bg);
1298 layout = elm_layout_add(window);
1299 elm_layout_theme_set(layout, "layout", "application", "default");
1300 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1302 conform = elm_conformant_add(window);
1304 surface = eext_circle_surface_conformant_add(conform);
1306 evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1308 elm_win_resize_object_add(window, conform);
1309 elm_object_content_set(conform, layout);
1311 evas_object_show(layout);
1312 evas_object_show(conform);
1313 evas_object_show(window);
1314 app_data->win_main = window;
1315 app_data->conform = conform;
1316 app_data->layout_main = layout;
1317 app_data->circle_surface = surface;
1318 app_data->app_type = APP_TYPE_SELECT_MODE;
1320 Evas_Object *naviframe = elm_naviframe_add(layout);
1321 elm_naviframe_prev_btn_auto_pushed_set(naviframe, EINA_FALSE);
1322 eext_object_event_callback_add(naviframe, EEXT_CALLBACK_BACK, eext_naviframe_back_cb, NULL);
1323 elm_object_part_content_set(layout, "elm.swallow.content", naviframe);
1324 evas_object_show(naviframe);
1326 app_data->naviframe = naviframe;
1331 void _app_service(app_control_h service, void* user_data)
1334 char *context = NULL;
1335 char **input_type_array = NULL;
1336 int input_type_array_len = -1;
1337 bool is_extra_data_array = false;
1338 char *mime_type = NULL;
1339 char **user_template_array = NULL;
1340 int user_template_array_len = -1;
1342 app_control_clone(&(app_data->source_app_control), service);
1343 app_data->reply_type = REPLY_APP_NORMAL;
1344 app_data->mime_type = MIME_TYPE_ALL;
1346 ret = app_control_get_extra_data_array(service, "user_template", &user_template_array, &user_template_array_len);
1347 g_input_template_data.input_template_array = user_template_array;
1348 g_input_template_data.input_template_array_len = user_template_array_len;
1350 g_set_mimetype_in_app_service = false;
1352 ret = app_control_get_mime(service, &mime_type);
1353 if (ret != APP_CONTROL_ERROR_NONE) {
1354 LOGD("Fail to get mime type : %d", ret);
1357 LOGD("mime type = %s", mime_type);
1358 if (!strncmp(mime_type, "image/", strlen("image/"))) {
1359 app_data->mime_type = MIME_TYPE_IMAGE;
1360 app_data->app_type = APP_TYPE_DRAWING;
1361 g_set_mimetype_in_app_service = true;
1362 launch_drawing_app((void *)app_data);
1366 } else if (!strncmp(mime_type, "audio/", strlen("audio/"))) {
1367 app_data->mime_type = MIME_TYPE_AUDIO;
1368 app_data->app_type = APP_TYPE_STT;
1369 _stt_clicked_cb((void *)app_data, NULL, NULL);
1373 } else if (!strncmp(mime_type, "text/", strlen("text/"))) {
1374 app_data->mime_type = MIME_TYPE_TEXT;
1381 if (_TV || _MOBILE) {
1382 app_data->app_type = APP_TYPE_KEYBOARD;
1383 input_keyboard_init(service);
1384 _keyboard_clicked_cb((void *)app_data, NULL, NULL);
1388 ret = app_control_is_extra_data_array(service, APP_CONTROL_DATA_INPUT_TYPE, &is_extra_data_array);
1389 if ( is_extra_data_array == true) {
1390 ret = app_control_get_extra_data_array(service, APP_CONTROL_DATA_INPUT_TYPE, &input_type_array, &input_type_array_len);
1391 g_input_type_data.input_type_array = input_type_array;
1392 g_input_type_data.input_type_array_len = input_type_array_len;
1394 ret = app_control_get_extra_data(service, APP_CONTROL_DATA_INPUT_TYPE, &context);
1395 if (ret == APP_CONTROL_ERROR_NONE) {
1396 if (!strcmp(context, "input_voice")) {
1397 app_data->app_type = APP_TYPE_STT;
1398 _stt_clicked_cb((void *)app_data, NULL, NULL);
1400 } else if (!strcmp(context, "input_recording")) {
1401 app_data->app_type = APP_TYPE_RECORDING;
1402 _stt_clicked_cb((void *)app_data, NULL, NULL);
1404 } else if (!strcmp(context, "input_emoticon")) {
1405 app_data->app_type = APP_TYPE_EMOTICON;
1406 _emoticon_clicked_cb((void *)app_data, NULL, NULL);
1408 } else if (!strcmp(context, "input_keyboard")) {
1409 app_data->app_type = APP_TYPE_KEYBOARD;
1410 input_keyboard_init(service);
1411 _keyboard_clicked_cb((void *)app_data, NULL, NULL);
1413 } else if (!strcmp(context, "input_drawing")) {
1414 app_data->app_type = APP_TYPE_DRAWING;
1415 _drawing_item_clicked_cb((void *)app_data, NULL, NULL);
1417 } else if (!strcmp(context, "input_reply")) {
1418 app_data->app_type = APP_TYPE_REPLY;
1423 if (app_data->genlist == NULL)
1424 app_data->genlist = _create_genlist(app_data->naviframe);
1426 input_keyboard_init(service);
1428 input_smartreply_init(service);
1429 input_smartreply_set_notify(_input_smartreply_notify_cb, NULL);
1431 if (input_smartreply_is_enabled())
1432 input_smartreply_get_reply_async();
1434 input_template_init(service);
1435 input_template_set_notify(_input_template_notify_cb, NULL);
1437 _create_genlist_items(app_data);
1440 elm_win_activate(app_data->win_main);
1446 void _app_pause(void* user_data)
1448 PRINTFUNC(DLOG_DEBUG, "");
1452 void _app_resume(void* user_data)
1454 PRINTFUNC(DLOG_DEBUG, "");
1457 if (g_set_mimetype_in_app_resume) {
1458 app_control_destroy(app_data->source_app_control);
1459 app_data->source_app_control = NULL;
1463 if (g_set_mimetype_in_app_service) {
1464 g_set_mimetype_in_app_resume = true;
1468 void _app_terminate(void* user_data)
1470 App_Data* app_data = NULL;
1471 app_data = (App_Data*)user_data;
1473 if (app_data->genlist){
1474 evas_object_smart_callback_del(app_data->genlist, "elm,item,position,changed", _item_position_changed_cb);
1477 if (app_data->res_path)
1478 free(app_data->res_path);
1480 if (app_data->shared_res_path)
1481 free(app_data->shared_res_path);
1483 input_keyboard_deinit();
1484 input_smartreply_deinit();
1486 input_template_unset_notify();
1487 input_template_deinit();
1489 input_type_deinit();
1492 static int init_i18n(const char *domain, const char *dir, char *lang_str)
1494 if (setlocale(LC_ALL, "") == NULL) {
1495 PRINTFUNC(DLOG_INFO, "Some environment variable is invalid, setlocale(LC_ALL, \"\") has returns\ed a null pointer");
1496 if (setlocale(LC_ALL, lang_str) == NULL)
1499 if (bindtextdomain(domain, dir) == NULL)
1501 if (textdomain(domain) == NULL)
1508 * @brief Set language and locale.
1512 static void _app_language_changed(app_event_info_h event_info, void *user_data)
1514 char* lang_str = vconf_get_str(VCONFKEY_LANGSET);
1516 setenv("LANG", lang_str, 1);
1517 setenv("LC_MESSAGES", lang_str, 1);
1519 setenv("LANG", "en_GB.utf8", 1);
1520 setenv("LC_MESSAGES", "en_GB.utf8", 1);
1521 lang_str = strdup("en_GB.UTF-8");
1524 init_i18n(PACKAGE, LOCALEDIR, lang_str);
1527 elm_language_set(lang_str);
1532 void input_type_deinit(void)
1535 char **data_array = NULL;
1537 data_array = g_input_type_data.input_type_array;
1539 for (i = 0; i < g_input_type_data.input_type_array_len; i++) {
1540 if (*(data_array + i))
1541 free(*(data_array + i));
1545 g_input_type_data.input_type_array = NULL;
1546 g_input_type_data.input_type_array_len = 0;
1549 EXPORTED int main(int argc, char* argv[])
1551 App_Data app_data = {0, };
1552 ui_app_lifecycle_callback_s event_callback = {0, };
1553 app_event_handler_h handlers[5] = {NULL, };
1555 event_callback.create = _app_create;
1556 event_callback.terminate = _app_terminate;
1557 event_callback.pause = _app_pause;
1558 event_callback.resume = _app_resume;
1559 event_callback.app_control = _app_service;
1561 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, NULL, &app_data);
1562 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, NULL, &app_data);
1563 ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, NULL, &app_data);
1564 ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, _app_language_changed, &app_data);
1565 ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, NULL, &app_data);
1567 _init_app_data(&app_data);
1569 int ret = ui_app_main(argc, argv, &event_callback, &app_data);
1570 if (ret != APP_ERROR_NONE) {
1571 LOGD("ui_app_main() is failed. err = %d", ret);