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) {
1027 elm_genlist_item_append(app_data->genlist,
1029 (void *)(uintptr_t)i,
1031 ELM_GENLIST_ITEM_NONE,
1032 __ise_smartreply_gl_sel,
1037 if (item_size >= 3) {
1041 elm_genlist_item_class_free(itc);
1046 static void _drawing_item_clicked_cb(void *data, Evas_Object * obj, void *event_info)
1048 PRINTFUNC(DLOG_DEBUG, "%s", __func__);
1049 App_Data* ad = (App_Data*) data;
1053 launch_drawing_app(ad);
1056 unsigned int _update_template_items(void *user_data)
1060 Elm_Object_Item *first;
1061 Elm_Object_Item *menu;
1062 Elm_Object_Item *pos;
1065 unsigned int item_size = 0;
1067 app_data = (App_Data *)user_data;
1069 if (app_data == NULL) {
1070 PRINTFUNC(DLOG_ERROR, "Can not get app_data");
1074 if (app_data->genlist == NULL) {
1075 /* smartreply will update when genlist is exist only */
1076 PRINTFUNC(DLOG_ERROR, "Can not get getlist");
1080 first = elm_genlist_first_item_get(app_data->genlist);
1083 menu = elm_genlist_item_next_get(first);
1086 /* move to smartreply next if it need */
1087 if (input_smartreply_is_enabled()) {
1090 for (j = 0; j < g_smartreply_item_size; j++) {
1094 pos = elm_genlist_item_next_get(pos);
1098 /* Append New Template list */
1099 const std::vector<TemplateData> template_list = input_template_get_list();
1101 if (template_list.size() > 0) {
1102 Elm_Genlist_Item_Class *itc;
1104 itc = elm_genlist_item_class_new();
1106 itc->item_style = "1text";
1107 itc->func.text_get = __ise_template_gl_text_get;
1108 itc->func.content_get = NULL;
1109 itc->func.state_get = NULL;
1110 itc->func.del = NULL;
1112 for (i = 0; i < template_list.size(); i++) {
1113 pos = elm_genlist_item_append(app_data->genlist,
1115 (void *)(uintptr_t)i,
1117 ELM_GENLIST_ITEM_NONE,
1118 __ise_template_gl_sel,
1122 elm_genlist_item_class_free(itc);
1124 // drawing button (+)
1125 if (app_data->mime_type == MIME_TYPE_ALL && app_data->app_type == APP_TYPE_SELECT_MODE) {
1126 Elm_Genlist_Item_Class *itc;
1127 itc = elm_genlist_item_class_new();
1129 itc->item_style = "1text.1icon";
1130 itc->func.text_get = __ise_drawing_text_get;;
1131 itc->func.content_get = __ise_drawing_content_get;
1132 itc->func.state_get = NULL;
1133 itc->func.del = NULL;
1135 elm_genlist_item_append(app_data->genlist,
1139 ELM_GENLIST_ITEM_NONE,
1140 _drawing_item_clicked_cb,
1143 elm_genlist_item_class_free(itc);
1146 // dummy item for empty space
1147 Elm_Genlist_Item_Class * itc0 = elm_genlist_item_class_new();
1148 itc0->item_style = "title";
1149 itc0->func.text_get = NULL;
1150 itc0->func.content_get = NULL;
1151 itc0->func.state_get = NULL;
1152 itc0->func.del = NULL;
1154 if (g_input_template_data.input_template_array_len < 1) {
1155 it_empty = elm_genlist_item_append(app_data->genlist, itc0,
1157 ELM_GENLIST_ITEM_NONE,
1160 elm_genlist_item_class_free(itc0);
1166 unsigned int _update_user_template_items(void *user_data)
1170 Elm_Object_Item *first;
1173 unsigned int item_size = 0;
1175 app_data = (App_Data *)user_data;
1177 if (app_data == NULL) {
1178 PRINTFUNC(DLOG_ERROR, "Can not get app_data");
1182 if (app_data->genlist == NULL) {
1183 /* smartreply will update when genlist is exist only */
1184 PRINTFUNC(DLOG_ERROR, "Can not get getlist");
1188 first = elm_genlist_first_item_get(app_data->genlist);
1192 if (g_input_template_data.input_template_array_len > 0) {
1193 Elm_Genlist_Item_Class *itc;
1195 itc = elm_genlist_item_class_new();
1197 itc->item_style = "1text";
1198 itc->func.text_get = __ise_user_template_gl_text_get;
1199 itc->func.content_get = NULL;
1200 itc->func.state_get = NULL;
1201 itc->func.del = NULL;
1203 for (i = 0; i < (unsigned int)g_input_template_data.input_template_array_len; i++) {
1204 elm_genlist_item_append(app_data->genlist,
1206 (void *)(uintptr_t)i,
1208 ELM_GENLIST_ITEM_NONE,
1209 __ise_user_template_gl_sel,
1213 elm_genlist_item_class_free(itc);
1215 // dummy item for empty space
1216 Elm_Genlist_Item_Class * itc0 = elm_genlist_item_class_new();
1217 itc0->item_style = "title";
1218 itc0->func.text_get = NULL;
1219 itc0->func.content_get = NULL;
1220 itc0->func.state_get = NULL;
1221 itc0->func.del = NULL;
1223 it_empty = elm_genlist_item_append(app_data->genlist, itc0,
1225 ELM_GENLIST_ITEM_NONE,
1227 elm_genlist_item_class_free(itc0);
1233 bool __compare_string(const char * smart_str, const char * template_str)
1239 if(!smart_str||!template_str)
1242 src_len = strlen(smart_str);
1243 dst_len = strlen(template_str);
1245 if(smart_str[src_len-1] == '.')
1248 while(template_str[dst_len-1] == ' ')
1250 if(template_str[dst_len-1] == '.')
1253 dst_len = (dst_len > src_len)? dst_len : src_len;
1255 if(!strncmp(smart_str, template_str, (size_t)dst_len))
1261 bool _app_create(void* user_data)
1263 // App_Data* app_data = NULL;
1264 Evas_Object* layout = NULL;
1265 Evas_Object* conform = NULL;
1266 Evas_Object* bg = NULL;
1267 Evas_Object* window = NULL;
1268 Eext_Circle_Surface *surface = NULL;
1274 _app_language_changed(NULL, NULL);
1276 app_data = (App_Data*)user_data;
1278 elm_app_base_scale_set(1.3);
1280 window = elm_win_add(NULL, PACKAGE, ELM_WIN_BASIC);
1282 init_customizing_theme();
1284 elm_win_title_set(window, PACKAGE);
1285 elm_win_borderless_set(window, EINA_TRUE);
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 _stt_clicked_cb((void *)app_data, NULL, NULL);
1372 } else if (!strncmp(mime_type, "text/", strlen("text/"))) {
1373 app_data->mime_type = MIME_TYPE_TEXT;
1380 if (_TV || _MOBILE) {
1381 app_data->app_type = APP_TYPE_KEYBOARD;
1382 input_keyboard_init(service);
1383 _keyboard_clicked_cb((void *)app_data, NULL, NULL);
1387 ret = app_control_is_extra_data_array(service, APP_CONTROL_DATA_INPUT_TYPE, &is_extra_data_array);
1388 if ( is_extra_data_array == true) {
1389 ret = app_control_get_extra_data_array(service, APP_CONTROL_DATA_INPUT_TYPE, &input_type_array, &input_type_array_len);
1390 g_input_type_data.input_type_array = input_type_array;
1391 g_input_type_data.input_type_array_len = input_type_array_len;
1393 ret = app_control_get_extra_data(service, APP_CONTROL_DATA_INPUT_TYPE, &context);
1394 if (ret == APP_CONTROL_ERROR_NONE) {
1395 if (!strcmp(context, "input_voice")) {
1396 app_data->app_type = APP_TYPE_STT;
1397 _stt_clicked_cb((void *)app_data, NULL, NULL);
1399 } else if (!strcmp(context, "input_recording")) {
1400 app_data->app_type = APP_TYPE_RECORDING;
1401 _stt_clicked_cb((void *)app_data, NULL, NULL);
1403 } else if (!strcmp(context, "input_emoticon")) {
1404 app_data->app_type = APP_TYPE_EMOTICON;
1405 _emoticon_clicked_cb((void *)app_data, NULL, NULL);
1407 } else if (!strcmp(context, "input_keyboard")) {
1408 app_data->app_type = APP_TYPE_KEYBOARD;
1409 input_keyboard_init(service);
1410 _keyboard_clicked_cb((void *)app_data, NULL, NULL);
1412 } else if (!strcmp(context, "input_drawing")) {
1413 app_data->app_type = APP_TYPE_DRAWING;
1414 _drawing_item_clicked_cb((void *)app_data, NULL, NULL);
1416 } else if (!strcmp(context, "input_reply")) {
1417 app_data->app_type = APP_TYPE_REPLY;
1422 if (app_data->genlist == NULL)
1423 app_data->genlist = _create_genlist(app_data->naviframe);
1425 input_keyboard_init(service);
1427 input_smartreply_init(service);
1428 input_smartreply_set_notify(_input_smartreply_notify_cb, NULL);
1430 if (input_smartreply_is_enabled())
1431 input_smartreply_get_reply_async();
1433 input_template_init(service);
1434 input_template_set_notify(_input_template_notify_cb, NULL);
1436 _create_genlist_items(app_data);
1439 elm_win_activate(app_data->win_main);
1445 void _app_pause(void* user_data)
1447 PRINTFUNC(DLOG_DEBUG, "");
1451 void _app_resume(void* user_data)
1453 PRINTFUNC(DLOG_DEBUG, "");
1456 if (g_set_mimetype_in_app_resume) {
1457 app_control_destroy(app_data->source_app_control);
1458 app_data->source_app_control = NULL;
1462 if (g_set_mimetype_in_app_service) {
1463 g_set_mimetype_in_app_resume = true;
1467 void _app_terminate(void* user_data)
1469 App_Data* app_data = NULL;
1470 app_data = (App_Data*)user_data;
1472 if (app_data->genlist){
1473 evas_object_smart_callback_del(app_data->genlist, "elm,item,position,changed", _item_position_changed_cb);
1476 if (app_data->res_path)
1477 free(app_data->res_path);
1479 if (app_data->shared_res_path)
1480 free(app_data->shared_res_path);
1482 input_keyboard_deinit();
1483 input_smartreply_deinit();
1485 input_template_unset_notify();
1486 input_template_deinit();
1488 input_type_deinit();
1491 static int init_i18n(const char *domain, const char *dir, char *lang_str)
1493 if (setlocale(LC_ALL, "") == NULL) {
1494 PRINTFUNC(DLOG_INFO, "Some environment variable is invalid, setlocale(LC_ALL, \"\") has returns\ed a null pointer");
1495 if (setlocale(LC_ALL, lang_str) == NULL)
1498 if (bindtextdomain(domain, dir) == NULL)
1500 if (textdomain(domain) == NULL)
1507 * @brief Set language and locale.
1511 static void _app_language_changed(app_event_info_h event_info, void *user_data)
1513 char* lang_str = vconf_get_str(VCONFKEY_LANGSET);
1515 setenv("LANG", lang_str, 1);
1516 setenv("LC_MESSAGES", lang_str, 1);
1518 setenv("LANG", "en_GB.utf8", 1);
1519 setenv("LC_MESSAGES", "en_GB.utf8", 1);
1520 lang_str = strdup("en_GB.UTF-8");
1523 init_i18n(PACKAGE, LOCALEDIR, lang_str);
1526 elm_language_set(lang_str);
1531 void input_type_deinit(void)
1534 char **data_array = NULL;
1536 data_array = g_input_type_data.input_type_array;
1538 for (i = 0; i < g_input_type_data.input_type_array_len; i++) {
1539 if (*(data_array + i))
1540 free(*(data_array + i));
1544 g_input_type_data.input_type_array = NULL;
1545 g_input_type_data.input_type_array_len = 0;
1548 EXPORTED int main(int argc, char* argv[])
1550 App_Data app_data = {0, };
1551 ui_app_lifecycle_callback_s event_callback = {0, };
1552 app_event_handler_h handlers[5] = {NULL, };
1554 event_callback.create = _app_create;
1555 event_callback.terminate = _app_terminate;
1556 event_callback.pause = _app_pause;
1557 event_callback.resume = _app_resume;
1558 event_callback.app_control = _app_service;
1560 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, NULL, &app_data);
1561 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, NULL, &app_data);
1562 ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, NULL, &app_data);
1563 ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, _app_language_changed, &app_data);
1564 ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, NULL, &app_data);
1566 _init_app_data(&app_data);
1568 int ret = ui_app_main(argc, argv, &event_callback, &app_data);
1569 if (ret != APP_ERROR_NONE) {
1570 LOGD("ui_app_main() is failed. err = %d", ret);