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());
162 static Eina_Bool back_cb(void *data, Elm_Object_Item *it)
164 reply_to_sender_by_callback_for_back();
169 static void _stt_clicked_cb(void *data, Evas_Object * obj, void *event_info)
171 App_Data* ad = (App_Data*)data;
173 PRINTFUNC(DLOG_DEBUG, "");
178 ise_show_stt_popup(ad);
181 static void _input_smartreply_notify_cb(void *user_data)
183 ecore_main_loop_iterate();
184 _update_genlist_items((void *)app_data);
187 static void _input_template_notify_cb(void *user_data)
189 _update_genlist_items((void *)app_data);
192 static void _emoticon_clicked_cb(void *data, Evas_Object * obj, void *event_info)
194 App_Data* ad = (App_Data*)data;
196 PRINTFUNC(DLOG_DEBUG, "");
201 ise_show_emoticon_list(ad);
204 static void _keyboard_clicked_cb(void *data, Evas_Object * obj, void *event_info)
206 App_Data* ad = (App_Data *)data;
208 PRINTFUNC(DLOG_DEBUG, "");
213 input_keyboard_launch(ad->win_main, data);
216 static void __ise_smartreply_gl_sel(void *data, Evas_Object *obj, void *event_info)
218 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
221 elm_genlist_item_selected_set(item, EINA_FALSE);
223 int index = (intptr_t) elm_object_item_data_get(item);
226 char *reply = input_smartreply_get_nth_item(index, &type);
228 input_smartreply_send_feedback(reply);
229 reply_to_sender_by_callback(reply, "smartreply", NULL, NULL);
236 static void __ise_template_gl_sel(void *data, Evas_Object *obj, void *event_info)
238 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
242 elm_genlist_item_selected_set(item, EINA_FALSE);
244 index = (uintptr_t) elm_object_item_data_get(item);
245 const std::vector<TemplateData> template_list = input_template_get_list();
247 if (index < (int)template_list.size()) {
248 reply_to_sender_by_callback(gettext(template_list[index].text.c_str()), "template", NULL, NULL);
254 static void __ise_user_template_gl_sel(void *data, Evas_Object *obj, void *event_info)
256 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
260 elm_genlist_item_selected_set(item, EINA_FALSE);
262 index = (uintptr_t) elm_object_item_data_get(item);
264 if (index < (int)g_input_template_data.input_template_array_len) {
265 reply_to_sender_by_callback(g_input_template_data.input_template_array[index], "user_template", NULL, NULL);
271 static char * __ise_template_gl_text_get(void *data, Evas_Object *obj, const char *part)
273 if (!strcmp(part, "elm.text")) {
274 unsigned int index = (uintptr_t)data;
275 const std::vector<TemplateData> template_list = input_template_get_list();
277 if (index < template_list.size()) {
278 if (template_list[index].use_gettext) {
279 return strdup(gettext(template_list[index].text.c_str()));
281 Eina_Strbuf *buf = NULL;
282 const char *str = NULL;
285 buf = eina_strbuf_new();
287 eina_strbuf_append(buf, template_list[index].text.c_str());
288 eina_strbuf_replace_all(buf, "\n", "");
289 eina_strbuf_replace_all(buf, "\r", "");
291 str = eina_strbuf_string_get(buf);
294 markup = elm_entry_utf8_to_markup(str);
296 eina_strbuf_free(buf);
305 static char * __ise_user_template_gl_text_get(void *data, Evas_Object *obj, const char *part)
307 if (!strcmp(part, "elm.text")) {
308 unsigned int index = (uintptr_t)data;
309 if (index < (unsigned int)g_input_template_data.input_template_array_len) {
310 if (g_input_template_data.input_template_array[index] != NULL) {
311 return strdup(g_input_template_data.input_template_array[index]);
318 static Evas_Object * __ise_gl_2button_content_get(void *data, Evas_Object *obj, const char *part)
320 char *first_input_type = *(g_input_type_data.input_type_array + 0);
321 char *second_input_type = *(g_input_type_data.input_type_array + 1);
323 if (!strcmp(part, "elm.icon.1") || (!strcmp(part, "elm.icon.2"))) {
324 Evas_Object* btn = elm_button_add(obj);
325 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
326 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
328 Evas_Object* ic = elm_image_add(btn);
329 elm_image_resizable_set(ic, EINA_TRUE, EINA_TRUE);
330 string path = get_resource_path();
332 path = path + "wearable/";
336 path = path + "mobile/";
338 if (!strcmp(part, "elm.icon.1")) {
340 if (!strcmp(first_input_type, "input_voice")) {
341 elm_object_style_set(btn, "ime_button_stt");
342 path_ic = path + "images/w_mode_stt_ic.png";
343 evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
344 elm_atspi_accessible_name_set(btn, "IDS_IME_MBODY_VOICE_INPUT");
345 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
346 } else if (!strcmp(first_input_type, "input_emoticon")) {
347 elm_object_style_set(btn, "ime_button_emoticon");
348 path_ic = path + "images/Delta_w_mode_emoticon_ic.png";
349 evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
350 elm_atspi_accessible_name_set(btn, "IDS_COM_HEADER_EMOTICON");
351 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
352 } else if (!strcmp(first_input_type, "input_keyboard")) {
353 elm_object_style_set(btn, "ime_button_keyboard");
354 path_ic = path + "images/w_mode_keyboard_ic.png";
355 evas_object_propagate_events_set(btn, EINA_FALSE);
356 evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
357 elm_atspi_accessible_name_set(btn, "IDS_COM_OPT_KEYBOARD");
358 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
360 elm_image_file_set(ic, path_ic.c_str(), NULL);
361 elm_object_content_set(btn, ic);
362 evas_object_layer_set(btn, 32000);
363 } else if (!strcmp(part, "elm.icon.2")){
365 if (!strcmp(second_input_type, "input_voice")) {
366 elm_object_style_set(btn, "ime_button_stt");
367 path_ic = path + "images/w_mode_stt_ic.png";
368 evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
369 elm_atspi_accessible_name_set(btn, "IDS_IME_MBODY_VOICE_INPUT");
370 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
371 } else if (!strcmp(second_input_type, "input_emoticon")) {
372 elm_object_style_set(btn, "ime_button_emoticon");
373 path_ic = path + "images/Delta_w_mode_emoticon_ic.png";
374 evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
375 elm_atspi_accessible_name_set(btn, "IDS_COM_HEADER_EMOTICON");
376 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
377 } else if (!strcmp(second_input_type, "input_keyboard")) {
378 elm_object_style_set(btn, "ime_button_keyboard");
379 path_ic = path + "images/w_mode_keyboard_ic.png";
380 evas_object_propagate_events_set(btn, EINA_FALSE);
381 evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
382 elm_atspi_accessible_name_set(btn, "IDS_COM_OPT_KEYBOARD");
383 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
385 elm_image_file_set(ic, path_ic.c_str(), NULL);
386 elm_object_content_set(btn, ic);
387 evas_object_layer_set(btn, 32000);
390 } else if (!strcmp(part, "elm.icon.1.touch_area") || (!strcmp(part, "elm.icon.2.touch_area"))) {
391 Evas_Object* btn = elm_button_add(obj);
392 elm_object_style_set(btn, "touch_area");
393 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
394 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
395 string path = get_resource_path();
396 if (!strcmp(part, "elm.icon.1.touch_area")) {
397 evas_object_layer_set(btn, 32000);
398 if (!strcmp(first_input_type, "input_voice")) {
399 evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
400 elm_atspi_accessible_name_set(btn, "IDS_IME_MBODY_VOICE_INPUT");
401 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
402 } else if (!strcmp(first_input_type, "input_emoticon")) {
403 evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
404 elm_atspi_accessible_name_set(btn, "IDS_COM_HEADER_EMOTICON");
405 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
406 } else if (!strcmp(first_input_type, "input_keyboard")) {
407 evas_object_propagate_events_set(btn, EINA_FALSE);
408 evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
409 elm_atspi_accessible_name_set(btn, "IDS_COM_OPT_KEYBOARD");
410 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
412 } else if (!strcmp(part, "elm.icon.2.touch_area")){
413 evas_object_layer_set(btn, 32000);
414 if (!strcmp(second_input_type, "input_voice")) {
415 evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
416 elm_atspi_accessible_name_set(btn, "IDS_IME_MBODY_VOICE_INPUT");
417 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
418 } else if (!strcmp(second_input_type, "input_emoticon")) {
419 evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
420 elm_atspi_accessible_name_set(btn, "IDS_COM_HEADER_EMOTICON");
421 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
422 } else if (!strcmp(second_input_type, "input_keyboard")) {
423 evas_object_propagate_events_set(btn, EINA_FALSE);
424 evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
425 elm_atspi_accessible_name_set(btn, "IDS_COM_OPT_KEYBOARD");
426 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
430 } else if (!strcmp(part, "base")) {
431 Evas_Object* btn = elm_button_add(obj);
432 elm_object_style_set(btn, "ime_transparent");
438 static Evas_Object * __ise_gl_3button_content_get(void *data, Evas_Object *obj, const char *part)
440 if (!strcmp(part, "elm.icon.1") || (!strcmp(part, "elm.icon.2")) || (!strcmp(part, "elm.icon.3"))) {
441 Evas_Object* btn = elm_button_add(obj);
442 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
443 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
444 Evas_Object* ic = elm_image_add(btn);
445 elm_image_resizable_set(ic, EINA_TRUE, EINA_TRUE);
446 string path = get_resource_path();
448 path = path + "wearable/";
452 path = path + "mobile/";
454 if (!strcmp(part, "elm.icon.1")) {
455 elm_object_style_set(btn, "ime_button_stt");
456 string path_ic = path + "images/w_mode_stt_ic.png";
457 elm_image_file_set(ic, path_ic.c_str(), NULL);
458 elm_object_content_set(btn, ic);
459 evas_object_layer_set(btn, 32000);
460 evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
461 elm_atspi_accessible_name_set(btn, "IDS_IME_MBODY_VOICE_INPUT");
462 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
464 } else if (!strcmp(part, "elm.icon.2")){
465 elm_object_style_set(btn, "ime_button_emoticon");
466 string path_ic = path + "images/Delta_w_mode_emoticon_ic.png";
467 elm_image_file_set(ic, path_ic.c_str(), NULL);
468 elm_object_content_set(btn, ic);
469 evas_object_layer_set(btn, 32000);
470 evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
471 elm_atspi_accessible_name_set(btn, "IDS_COM_HEADER_EMOTICON");
472 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
474 } else if (!strcmp(part, "elm.icon.3")){
475 elm_object_style_set(btn, "ime_button_keyboard");
476 string path_ic = path + "images/w_mode_keyboard_ic.png";
477 elm_image_file_set(ic, path_ic.c_str(), NULL);
478 elm_object_content_set(btn, ic);
479 evas_object_layer_set(btn, 32000);
480 evas_object_propagate_events_set(btn, EINA_FALSE);
481 evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
482 elm_atspi_accessible_name_set(btn, "IDS_COM_OPT_KEYBOARD");
483 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
487 } else if (!strcmp(part, "elm.icon.1.touch_area") || (!strcmp(part, "elm.icon.2.touch_area")) || (!strcmp(part, "elm.icon.3.touch_area"))) {
488 Evas_Object* btn = elm_button_add(obj);
489 elm_object_style_set(btn, "touch_area");
490 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
491 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
492 string path = get_resource_path();
493 if (!strcmp(part, "elm.icon.1.touch_area")) {
494 evas_object_layer_set(btn, 32000);
495 evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
496 elm_atspi_accessible_name_set(btn, "IDS_IME_MBODY_VOICE_INPUT");
497 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
499 } else if (!strcmp(part, "elm.icon.2.touch_area")){
500 evas_object_layer_set(btn, 32000);
501 evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
502 elm_atspi_accessible_name_set(btn, "IDS_COM_HEADER_EMOTICON");
503 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
504 } else if (!strcmp(part, "elm.icon.3.touch_area")) {
505 evas_object_layer_set(btn, 32000);
506 evas_object_propagate_events_set(btn, EINA_FALSE);
507 evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
508 elm_atspi_accessible_name_set(btn, "IDS_COM_OPT_KEYBOARD");
509 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
513 } else if (!strcmp(part, "base")) {
514 Evas_Object* btn = elm_button_add(obj);
515 elm_object_style_set(btn, "ime_transparent");
521 static char * __ise_smartreply_gl_text_get(void *data, Evas_Object *obj, const char *part)
523 if(!strcmp(part, "elm.text")) {
526 index = (intptr_t)data;
530 reply = input_smartreply_get_nth_item(index, NULL);
539 static void __ise_gl_lang_changed(void *data, Evas_Object *obj, void *event_info)
541 //Update genlist items. The Item texts will be translated in the _gl_text_get().
542 elm_genlist_realized_items_update(obj);
545 static char * __ise_drawing_text_get(void *data, Evas_Object *obj, const char *part)
547 if(!strcmp(part, "elm.text")) {
548 return(strdup(gettext("WDS_IME_MBODY_DRAWING_M_EMOTICON_ABB")));
553 static Evas_Object * __ise_drawing_content_get(void *data, Evas_Object *obj, const char *part)
555 if (!strcmp(part, "elm.icon")) {
556 Evas_Object* btn = elm_button_add(obj);
557 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
558 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
559 Evas_Object* ic = elm_image_add(btn);
560 elm_image_resizable_set(ic, EINA_TRUE, EINA_TRUE);
561 string path = get_resource_path();
563 path = path + "wearable/";
567 path = path + "mobile/";
568 elm_object_style_set(btn, "ime_button_drawing");
569 string path_ic = path + "images/wi_drawing_icon.png";
570 elm_image_file_set(ic, path_ic.c_str(), NULL);
571 elm_object_content_set(btn, ic);
572 evas_object_layer_set(btn, 32000);
578 void set_source_caller_app_id(app_control_h app_control)
581 PRINTFUNC(DLOG_ERROR, "can't get app_control");
586 app_control_get_caller(app_data->source_app_control, &caller);
589 PRINTFUNC(DLOG_DEBUG, "caller = %s", caller);
590 app_control_add_extra_data(app_control, "caller_appid", caller);
595 void reply_to_sender_by_callback(const char *value, const char *type, const char *path[], const char *cursor_position)
597 PRINTFUNC(DLOG_DEBUG, "");
599 app_control_h app_control;
601 if (app_control_create(&app_control) == 0) {
605 app_control_add_extra_data(app_control, APP_CONTROL_DATA_TEXT, value);
608 app_control_add_extra_data(app_control, "reply_type", type);
611 app_control_add_extra_data_array(app_control, APP_CONTROL_DATA_PATH, path, 1);
614 if (cursor_position != NULL)
615 app_control_add_extra_data(app_control, "cursor_position_get", cursor_position);
617 set_source_caller_app_id(app_control);
619 ret = app_control_reply_to_launch_request(app_control, app_data->source_app_control, APP_CONTROL_RESULT_SUCCEEDED);
620 if (ret != APP_CONTROL_ERROR_NONE)
621 PRINTFUNC(DLOG_ERROR, "reply failed : %d", ret);
623 app_control_destroy(app_control);
624 app_control_destroy(app_data->source_app_control);
625 app_data->source_app_control = NULL;
629 void reply_to_sender_by_callback_for_back()
631 PRINTFUNC(DLOG_DEBUG, "");
633 app_control_h app_control;
635 if (app_control_create(&app_control) == 0) {
638 app_control_add_extra_data(app_control, "back_to_composer", "yes");
640 ret = app_control_reply_to_launch_request(app_control, app_data->source_app_control, APP_CONTROL_RESULT_SUCCEEDED);
641 if (ret != APP_CONTROL_ERROR_NONE)
642 PRINTFUNC(DLOG_ERROR, "reply failed : %d", ret);
644 app_control_destroy(app_control);
645 app_control_destroy(app_data->source_app_control);
646 app_data->source_app_control = NULL;
650 char* get_resource_path()
652 if (NULL == app_data->res_path) {
653 app_data->res_path = app_get_resource_path();
654 PRINTFUNC(DLOG_INFO, "set resource path = %s", app_data->res_path);
656 return (app_data->res_path);
659 char* get_shared_resource_path()
661 if (NULL == app_data->shared_res_path) {
662 app_data->shared_res_path = app_get_shared_resource_path();
663 PRINTFUNC(DLOG_INFO, "set shared resource path = %s", app_data->shared_res_path);
665 return (app_data->shared_res_path);
668 void show_gl_focus(Eina_Bool bVisible){
669 if (app_data->genlist == NULL)
672 if (bVisible == EINA_TRUE){
673 elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,enable", "elm");
674 //elm_layout_theme_set(app_data->genlist, "genlist", "base", "focus_bg");
675 //elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,show", "elm");
677 elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,disable", "elm");
678 //elm_layout_theme_set(app_data->genlist, "genlist", "base", "default");
679 //elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,hide", "elm");
683 void show_popup_toast(const char *text, bool check_img)
685 PRINTFUNC(DLOG_ERROR, "show_popup_toast");
689 popup = elm_popup_add(app_data->win_main);
690 elm_object_style_set(popup, "toast/circle");
691 elm_popup_orient_set(popup, ELM_POPUP_ORIENT_BOTTOM);
692 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
695 string path = get_resource_path();
697 path = path + "wearable/";
701 path = path + "mobile/";
702 string path_ic = path + "/images/toast_check_icon.png";
703 Evas_Object * img = elm_image_add(popup);
704 elm_image_file_set(img, path_ic.c_str(), NULL);
705 elm_object_part_content_set(popup, "toast,icon", img);
708 elm_object_part_text_set(popup, "elm.text", text);
711 eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, _popup_back_cb, NULL);
712 evas_object_smart_callback_add(popup, "dismissed", _popup_close_cb, NULL);
713 evas_object_smart_callback_add(popup, "block,clicked", _popup_back_cb, NULL);
715 elm_popup_timeout_set(popup, 2.0);
716 evas_object_show(popup);
719 static void _popup_close_cb(void *data, Evas_Object *obj, void *event_info)
722 evas_object_hide(obj);
723 evas_object_del(obj);
727 static void _popup_back_cb(void *data, Evas_Object *obj, void *event_info)
730 elm_popup_dismiss(obj);
734 void _back_to_genlist_for_selector()
736 PRINTFUNC(DLOG_DEBUG, "");
738 if (!app_data) return;
741 Evas_Object *circle_genlist = (Evas_Object *) evas_object_data_get(app_data->genlist, "circle");
742 eext_rotary_object_event_activated_set(circle_genlist, EINA_TRUE);
744 if (app_data->app_type == APP_TYPE_STT || app_data->app_type == APP_TYPE_EMOTICON || app_data->app_type == APP_TYPE_KEYBOARD){
745 PRINTFUNC(DLOG_DEBUG, "launched as STT/EMOTICON/KEYBOARD mode, So exit here.");
746 reply_to_sender_by_callback(NULL, NULL, NULL, NULL);
751 static void _item_realized(void *data, Evas_Object *obj, void *event_info) //called when list scrolled
753 PRINTFUNC(DLOG_DEBUG, "%s", __func__);
756 Evas_Object* _create_genlist(Evas_Object* navi)
758 Evas_Object* genlist = elm_genlist_add(navi);
762 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
764 Evas_Object* circle_object_genlist = eext_circle_object_genlist_add(genlist, app_data->circle_surface);
765 eext_circle_object_genlist_scroller_policy_set(circle_object_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
766 evas_object_data_set(genlist, "circle", (void *) circle_object_genlist);
767 eext_rotary_object_event_activated_set(circle_object_genlist, EINA_TRUE);
769 evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
770 evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
772 evas_object_smart_callback_add(genlist, "language,changed", __ise_gl_lang_changed, genlist);
773 evas_object_show(genlist);
775 // uxt_genlist_set_bottom_margin_enabled(genlist, EINA_TRUE);
777 show_gl_focus(EINA_FALSE);
779 const char *item_style = NULL;
781 item_style = "empty";
782 Elm_Object_Item *nf_main_item = elm_naviframe_item_push(navi,
789 elm_naviframe_item_pop_cb_set(nf_main_item, back_cb, app_data);
790 evas_object_smart_callback_add(genlist, "realized", _item_realized, NULL);
795 static void _item_position_changed_cb(void *data, Evas_Object *obj, void *event_info)
800 Evas_Object *genlist = (Evas_Object *)obj;
801 Elm_Object_Item *gen_item = (Elm_Object_Item *)data;
804 elm_scroller_region_get(genlist, NULL, &y, NULL, NULL);
806 // PRINTFUNC(DLOG_DEBUG,"y=%d",y);
808 if (250 > y && y >= 100){
809 if (last_step == 0) return;
811 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.0", "elm");
812 show_gl_focus(EINA_TRUE);
813 } else if (100 > y && y >= 50){
814 if (last_step == 1) return;
816 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.1", "elm");
817 show_gl_focus(EINA_TRUE);
818 } else if (y < 50 && y >=0){
819 if (last_step == 2) return;
821 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.9", "elm");
822 show_gl_focus(EINA_FALSE);
826 void _create_genlist_items(void* user_data)
828 App_Data* app_data = (App_Data*) user_data;
830 if (NULL == app_data->genlist) {
831 app_data->genlist = _create_genlist(app_data->naviframe);
832 if (NULL == app_data->genlist)
836 elm_genlist_clear(app_data->genlist);
838 Elm_Genlist_Item_Class * itc0 = elm_genlist_item_class_new();
839 itc0->item_style = NULL;
840 itc0->func.text_get = NULL;
841 itc0->func.content_get = NULL;
842 itc0->func.state_get = NULL;
843 itc0->func.del = NULL;
845 Elm_Genlist_Item_Class * itc1 = elm_genlist_item_class_new();
846 if (g_input_type_data.input_type_array_len == 2){
847 itc1->item_style = "2button_flat";
848 itc1->func.text_get = NULL;
849 itc1->func.content_get = __ise_gl_2button_content_get;
850 itc1->func.state_get = NULL;
851 itc1->func.del = NULL;
853 itc1->item_style = "3button_flat";
854 itc1->func.text_get = NULL;
855 itc1->func.content_get = __ise_gl_3button_content_get;
856 itc1->func.state_get = NULL;
857 itc1->func.del = NULL;
860 // dummy title for empty space
861 it_empty = elm_genlist_item_append(app_data->genlist, itc0,
863 ELM_GENLIST_ITEM_NONE,
866 if (app_data->app_type != APP_TYPE_REPLY) {
868 it_title = elm_genlist_item_append(app_data->genlist, itc1,
870 ELM_GENLIST_ITEM_NONE,
874 elm_genlist_item_select_mode_set(it_title, ELM_OBJECT_SELECT_MODE_NONE);
876 g_template_item_size = _update_template_items(app_data);
878 Elm_Object_Item *item = elm_genlist_item_next_get(it_title);
879 elm_genlist_item_show(item, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
881 evas_object_smart_callback_add(app_data->genlist, "elm,item,position,changed", _item_position_changed_cb, it_title);
883 elm_genlist_item_class_free(itc0);
884 elm_genlist_item_class_free(itc1);
887 void _create_header_items(void *user_data)
889 Elm_Genlist_Item_Class * itc0 = elm_genlist_item_class_new();
890 itc0->item_style = "title";
891 itc0->func.text_get = NULL;
892 itc0->func.content_get = NULL;
893 itc0->func.state_get = NULL;
894 itc0->func.del = NULL;
896 Elm_Genlist_Item_Class * itc1 = elm_genlist_item_class_new();
897 if (g_input_type_data.input_type_array_len == 2) {
898 itc1->item_style = "2button_flat";
899 itc1->func.text_get = NULL;
900 itc1->func.content_get = __ise_gl_2button_content_get;
901 itc1->func.state_get = NULL;
902 itc1->func.del = NULL;
904 itc1->item_style = "3button_flat";
905 itc1->func.text_get = NULL;
906 itc1->func.content_get = __ise_gl_3button_content_get;
907 itc1->func.state_get = NULL;
908 itc1->func.del = NULL;
911 // dummy title for empty space
912 it_empty = elm_genlist_item_append(app_data->genlist, itc0,
914 ELM_GENLIST_ITEM_NONE,
918 it_title = elm_genlist_item_append(app_data->genlist, itc1,
920 ELM_GENLIST_ITEM_NONE,
923 elm_genlist_item_select_mode_set(it_title, ELM_OBJECT_SELECT_MODE_NONE);
925 elm_genlist_item_class_free(itc0);
926 elm_genlist_item_class_free(itc1);
929 void _update_genlist_items(void *user_data)
931 elm_genlist_clear(app_data->genlist);
933 _create_header_items(user_data);
935 if (input_smartreply_is_enabled())
936 g_smartreply_item_size = _update_smartreply_items(user_data);
938 g_smartreply_item_size = 0;
940 g_template_item_size = _update_template_items(user_data);
942 if (g_input_template_data.input_template_array_len > 0) {
943 _update_user_template_items(user_data);
946 /* Update genlist item position */
947 Elm_Object_Item *item = elm_genlist_item_next_get(it_title);
948 elm_genlist_item_show(item, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
951 unsigned int _update_smartreply_items(void *user_data)
955 Elm_Object_Item *first;
958 unsigned int len = 0;
959 unsigned int item_size = 0;
961 app_data = (App_Data *)user_data;
963 if (app_data == NULL) {
964 PRINTFUNC(DLOG_ERROR, "Can not get app_data");
968 if (app_data->genlist == NULL) {
969 /* smartreply will update when genlist is exist only */
970 PRINTFUNC(DLOG_ERROR, "Can not get getlist");
974 /* Move to smartreply */
975 first = elm_genlist_first_item_get(app_data->genlist);
976 elm_genlist_item_next_get(first);
978 if (input_smartreply_is_enabled() == false)
981 /* Append newly added smartreply list */
982 len = input_smartreply_get_reply_num();
985 const std::vector<TemplateData> template_list = input_template_get_list();
987 Elm_Genlist_Item_Class *itc;
989 itc = elm_genlist_item_class_new();
990 itc->item_style = "1text";
991 itc->func.text_get = __ise_smartreply_gl_text_get;
992 itc->func.content_get = NULL;
993 itc->func.state_get = NULL;
994 itc->func.del = NULL;
996 for (i = 0; i < len; i++) {
997 char *reply = (char *)"hello";
1004 reply = input_smartreply_get_nth_item(i, &type);
1007 SECURE_LOGD("SmartReply = [%d]%s", i, reply);
1009 for (j = 0; j < template_list.size(); j++) {
1010 const char *template_str;
1012 if (template_list[j].use_gettext)
1013 template_str = gettext(template_list[j].text.c_str());
1015 template_str = template_list[j].text.c_str();
1017 if (!__compare_string(reply, template_str)) {
1023 if (matched == true)
1026 elm_genlist_item_append(app_data->genlist,
1028 (void *)(uintptr_t)i,
1030 ELM_GENLIST_ITEM_NONE,
1031 __ise_smartreply_gl_sel,
1038 elm_genlist_item_class_free(itc);
1043 static void _drawing_item_clicked_cb(void *data, Evas_Object * obj, void *event_info)
1045 PRINTFUNC(DLOG_DEBUG, "%s", __func__);
1046 App_Data* ad = (App_Data*) data;
1050 launch_drawing_app(ad);
1053 unsigned int _update_template_items(void *user_data)
1057 Elm_Object_Item *first;
1058 Elm_Object_Item *menu;
1059 Elm_Object_Item *pos;
1062 unsigned int item_size = 0;
1064 app_data = (App_Data *)user_data;
1066 if (app_data == NULL) {
1067 PRINTFUNC(DLOG_ERROR, "Can not get app_data");
1071 if (app_data->genlist == NULL) {
1072 /* smartreply will update when genlist is exist only */
1073 PRINTFUNC(DLOG_ERROR, "Can not get getlist");
1077 first = elm_genlist_first_item_get(app_data->genlist);
1080 menu = elm_genlist_item_next_get(first);
1083 /* move to smartreply next if it need */
1084 if (input_smartreply_is_enabled()) {
1087 for (j = 0; j < g_smartreply_item_size; j++) {
1091 pos = elm_genlist_item_next_get(pos);
1095 /* Append New Template list */
1096 const std::vector<TemplateData> template_list = input_template_get_list();
1098 if (template_list.size() > 0) {
1099 Elm_Genlist_Item_Class *itc;
1101 itc = elm_genlist_item_class_new();
1103 itc->item_style = "1text";
1104 itc->func.text_get = __ise_template_gl_text_get;
1105 itc->func.content_get = NULL;
1106 itc->func.state_get = NULL;
1107 itc->func.del = NULL;
1109 for (i = 0; i < template_list.size(); i++) {
1110 pos = elm_genlist_item_append(app_data->genlist,
1112 (void *)(uintptr_t)i,
1114 ELM_GENLIST_ITEM_NONE,
1115 __ise_template_gl_sel,
1119 elm_genlist_item_class_free(itc);
1121 // drawing button (+)
1122 if (app_data->mime_type == MIME_TYPE_ALL && app_data->app_type == APP_TYPE_SELECT_MODE) {
1123 Elm_Genlist_Item_Class *itc;
1124 itc = elm_genlist_item_class_new();
1126 itc->item_style = "1text.1icon";
1127 itc->func.text_get = __ise_drawing_text_get;;
1128 itc->func.content_get = __ise_drawing_content_get;
1129 itc->func.state_get = NULL;
1130 itc->func.del = NULL;
1132 elm_genlist_item_append(app_data->genlist,
1136 ELM_GENLIST_ITEM_NONE,
1137 _drawing_item_clicked_cb,
1140 elm_genlist_item_class_free(itc);
1143 // dummy item for empty space
1144 Elm_Genlist_Item_Class * itc0 = elm_genlist_item_class_new();
1145 itc0->item_style = "title";
1146 itc0->func.text_get = NULL;
1147 itc0->func.content_get = NULL;
1148 itc0->func.state_get = NULL;
1149 itc0->func.del = NULL;
1151 if (g_input_template_data.input_template_array_len < 1) {
1152 it_empty = elm_genlist_item_append(app_data->genlist, itc0,
1154 ELM_GENLIST_ITEM_NONE,
1157 elm_genlist_item_class_free(itc0);
1163 unsigned int _update_user_template_items(void *user_data)
1167 Elm_Object_Item *first;
1170 unsigned int item_size = 0;
1172 app_data = (App_Data *)user_data;
1174 if (app_data == NULL) {
1175 PRINTFUNC(DLOG_ERROR, "Can not get app_data");
1179 if (app_data->genlist == NULL) {
1180 /* smartreply will update when genlist is exist only */
1181 PRINTFUNC(DLOG_ERROR, "Can not get getlist");
1185 first = elm_genlist_first_item_get(app_data->genlist);
1189 if (g_input_template_data.input_template_array_len > 0) {
1190 Elm_Genlist_Item_Class *itc;
1192 itc = elm_genlist_item_class_new();
1194 itc->item_style = "1text";
1195 itc->func.text_get = __ise_user_template_gl_text_get;
1196 itc->func.content_get = NULL;
1197 itc->func.state_get = NULL;
1198 itc->func.del = NULL;
1200 for (i = 0; i < (unsigned int)g_input_template_data.input_template_array_len; i++) {
1201 elm_genlist_item_append(app_data->genlist,
1203 (void *)(uintptr_t)i,
1205 ELM_GENLIST_ITEM_NONE,
1206 __ise_user_template_gl_sel,
1210 elm_genlist_item_class_free(itc);
1212 // dummy item for empty space
1213 Elm_Genlist_Item_Class * itc0 = elm_genlist_item_class_new();
1214 itc0->item_style = "title";
1215 itc0->func.text_get = NULL;
1216 itc0->func.content_get = NULL;
1217 itc0->func.state_get = NULL;
1218 itc0->func.del = NULL;
1220 it_empty = elm_genlist_item_append(app_data->genlist, itc0,
1222 ELM_GENLIST_ITEM_NONE,
1224 elm_genlist_item_class_free(itc0);
1230 bool __compare_string(const char * smart_str, const char * template_str)
1236 if(!smart_str||!template_str)
1239 src_len = strlen(smart_str);
1240 dst_len = strlen(template_str);
1242 if(smart_str[src_len-1] == '.')
1245 while(template_str[dst_len-1] == ' ')
1247 if(template_str[dst_len-1] == '.')
1250 dst_len = (dst_len > src_len)? dst_len : src_len;
1252 if(!strncmp(smart_str, template_str, (size_t)dst_len))
1258 bool _app_create(void* user_data)
1260 int width = 1000, height = 1000;
1261 // App_Data* app_data = NULL;
1262 Evas_Object* layout = NULL;
1263 Evas_Object* conform = NULL;
1264 Evas_Object* bg = NULL;
1265 Evas_Object* window = NULL;
1266 Eext_Circle_Surface *surface = NULL;
1272 _app_language_changed(NULL, NULL);
1274 app_data = (App_Data*)user_data;
1276 elm_app_base_scale_set(1.3);
1278 window = elm_win_add(NULL, PACKAGE, ELM_WIN_BASIC);
1280 init_customizing_theme();
1282 elm_win_title_set(window, PACKAGE);
1283 elm_win_borderless_set(window, EINA_TRUE);
1284 // ecore_x_window_size_get(ecore_x_window_root_first_get(), &width, &height);
1285 evas_object_resize(window, width, height);
1286 elm_win_indicator_mode_set(window, ELM_WIN_INDICATOR_SHOW);
1288 LOGE("elm_win_add() is failed.");
1292 bg = elm_bg_add(window);
1293 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1294 elm_win_resize_object_add(window, bg);
1295 evas_object_show(bg);
1297 layout = elm_layout_add(window);
1298 elm_layout_theme_set(layout, "layout", "application", "default");
1299 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1301 conform = elm_conformant_add(window);
1303 surface = eext_circle_surface_conformant_add(conform);
1305 evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1307 elm_win_resize_object_add(window, conform);
1308 elm_object_content_set(conform, layout);
1310 evas_object_show(layout);
1311 evas_object_show(conform);
1312 evas_object_show(window);
1313 app_data->win_main = window;
1314 app_data->conform = conform;
1315 app_data->layout_main = layout;
1316 app_data->circle_surface = surface;
1317 app_data->app_type = APP_TYPE_SELECT_MODE;
1319 Evas_Object *naviframe = elm_naviframe_add(layout);
1320 elm_naviframe_prev_btn_auto_pushed_set(naviframe, EINA_FALSE);
1321 eext_object_event_callback_add(naviframe, EEXT_CALLBACK_BACK, eext_naviframe_back_cb, NULL);
1322 elm_object_part_content_set(layout, "elm.swallow.content", naviframe);
1323 evas_object_show(naviframe);
1325 app_data->naviframe = naviframe;
1330 void _app_service(app_control_h service, void* user_data)
1333 char *context = NULL;
1334 char **input_type_array = NULL;
1335 int input_type_array_len = -1;
1336 bool is_extra_data_array = false;
1337 char *mime_type = NULL;
1338 char **user_template_array = NULL;
1339 int user_template_array_len = -1;
1341 app_control_clone(&(app_data->source_app_control), service);
1342 app_data->reply_type = REPLY_APP_NORMAL;
1343 app_data->mime_type = MIME_TYPE_ALL;
1345 ret = app_control_get_extra_data_array(service, "user_template", &user_template_array, &user_template_array_len);
1346 g_input_template_data.input_template_array = user_template_array;
1347 g_input_template_data.input_template_array_len = user_template_array_len;
1349 g_set_mimetype_in_app_service = false;
1351 ret = app_control_get_mime(service, &mime_type);
1352 if (ret != APP_CONTROL_ERROR_NONE) {
1353 LOGD("Fail to get mime type : %d", ret);
1356 LOGD("mime type = %s", mime_type);
1357 if (!strncmp(mime_type, "image/", strlen("image/"))) {
1358 app_data->mime_type = MIME_TYPE_IMAGE;
1359 app_data->app_type = APP_TYPE_DRAWING;
1360 g_set_mimetype_in_app_service = true;
1361 launch_drawing_app((void *)app_data);
1365 } else if (!strncmp(mime_type, "audio/", strlen("audio/"))) {
1366 app_data->mime_type = MIME_TYPE_AUDIO;
1367 app_data->app_type = APP_TYPE_STT;
1368 g_set_mimetype_in_app_service = true;
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);
1447 void _app_pause(void* user_data)
1449 PRINTFUNC(DLOG_DEBUG, "");
1453 void _app_resume(void* user_data)
1455 PRINTFUNC(DLOG_DEBUG, "");
1458 if (g_set_mimetype_in_app_resume) {
1459 app_control_destroy(app_data->source_app_control);
1460 app_data->source_app_control = NULL;
1464 if (g_set_mimetype_in_app_service) {
1465 g_set_mimetype_in_app_resume = true;
1469 void _app_terminate(void* user_data)
1471 App_Data* app_data = NULL;
1472 app_data = (App_Data*)user_data;
1474 if (app_data->genlist){
1475 evas_object_smart_callback_del(app_data->genlist, "elm,item,position,changed", _item_position_changed_cb);
1478 if (app_data->res_path)
1479 free(app_data->res_path);
1481 if (app_data->shared_res_path)
1482 free(app_data->shared_res_path);
1484 input_keyboard_deinit();
1485 input_smartreply_deinit();
1487 input_template_unset_notify();
1488 input_template_deinit();
1490 input_type_deinit();
1493 static int init_i18n(const char *domain, const char *dir, char *lang_str)
1495 if (setlocale(LC_ALL, "") == NULL) {
1496 PRINTFUNC(DLOG_INFO, "Some environment variable is invalid, setlocale(LC_ALL, \"\") has returns\ed a null pointer");
1497 if (setlocale(LC_ALL, lang_str) == NULL)
1500 if (bindtextdomain(domain, dir) == NULL)
1502 if (textdomain(domain) == NULL)
1509 * @brief Set language and locale.
1513 static void _app_language_changed(app_event_info_h event_info, void *user_data)
1515 char* lang_str = vconf_get_str(VCONFKEY_LANGSET);
1517 setenv("LANG", lang_str, 1);
1518 setenv("LC_MESSAGES", lang_str, 1);
1520 setenv("LANG", "en_GB.utf8", 1);
1521 setenv("LC_MESSAGES", "en_GB.utf8", 1);
1522 lang_str = strdup("en_GB.UTF-8");
1525 init_i18n(PACKAGE, LOCALEDIR, lang_str);
1528 elm_language_set(lang_str);
1533 void input_type_deinit(void)
1536 char **data_array = NULL;
1538 data_array = g_input_type_data.input_type_array;
1540 for (i = 0; i < g_input_type_data.input_type_array_len; i++) {
1541 if (*(data_array + i))
1542 free(*(data_array + i));
1546 g_input_type_data.input_type_array = NULL;
1547 g_input_type_data.input_type_array_len = 0;
1550 EXPORTED int main(int argc, char* argv[])
1552 App_Data app_data = {0, };
1553 ui_app_lifecycle_callback_s event_callback = {0, };
1554 app_event_handler_h handlers[5] = {NULL, };
1556 event_callback.create = _app_create;
1557 event_callback.terminate = _app_terminate;
1558 event_callback.pause = _app_pause;
1559 event_callback.resume = _app_resume;
1560 event_callback.app_control = _app_service;
1562 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, NULL, &app_data);
1563 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, NULL, &app_data);
1564 ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, NULL, &app_data);
1565 ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, _app_language_changed, &app_data);
1566 ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, NULL, &app_data);
1568 _init_app_data(&app_data);
1570 int ret = ui_app_main(argc, argv, &event_callback, &app_data);
1571 if (ret != APP_ERROR_NONE) {
1572 LOGD("ui_app_main() is failed. err = %d", ret);