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;
47 static Elm_Object_Item *it_empty;
48 static Elm_Object_Item *it_title;
50 static unsigned int g_smartreply_item_size = 0; /* Current Smartreply item size */
51 static unsigned int g_template_item_size = 0; /* Current Template item size */
53 Evas_Coord last_step; // 0 ~ 9 for gesture, 10~11 for rotary
55 tizen_profile_t _get_tizen_profile()
57 static tizen_profile_t profile = TIZEN_PROFILE_UNKNOWN;
58 if (__builtin_expect(profile != TIZEN_PROFILE_UNKNOWN, 1))
62 system_info_get_platform_string("http://tizen.org/feature/profile", &profileName);
67 profile = TIZEN_PROFILE_MOBILE;
71 profile = TIZEN_PROFILE_WEARABLE;
75 profile = TIZEN_PROFILE_TV;
79 profile = TIZEN_PROFILE_IVI;
81 default: // common or unknown ==> ALL ARE COMMON.
82 profile = TIZEN_PROFILE_COMMON;
89 void _init_app_data(App_Data* app_data);
90 static void _app_language_changed(app_event_info_h event_info, void *user_data);
92 Evas_Object* _create_genlist(Evas_Object* parent);
93 void _create_genlist_items(void* user_data);
94 void _create_header_items(void *user_data);
95 void _update_genlist_items(void *user_data);
96 unsigned int _update_smartreply_items(void *user_data);
97 unsigned int _update_template_items(void *user_data);
98 unsigned int _update_user_template_items(void *user_data);
99 static void _popup_close_cb(void *data, Evas_Object *obj, void *event_info);
100 static void _popup_back_cb(void *data, Evas_Object *obj, void *event_info);
101 static void input_type_deinit(void);
103 bool __compare_string(const char * src, const char * dst);
105 void _init_app_data(App_Data* app_data)
107 app_data->win_main = NULL;
108 app_data->layout_main = NULL;
109 app_data->conform = NULL;
110 app_data->naviframe = NULL;
111 app_data->genlist = NULL;
113 app_data->res_path = NULL;
116 Evas_Object* load_edj(Evas_Object* parent, const char* file, const char* group)
119 Evas_Object* content;
122 window = elm_layout_add(parent);
124 ret = elm_layout_file_set(window, file, group);
126 evas_object_del(window);
130 content = elm_layout_add(parent);
131 elm_layout_theme_set(content, "layout", "application", "default");
132 elm_object_part_content_set(window, "elm.swallow.content", content);
134 evas_object_size_hint_weight_set(window, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
139 void init_customizing_theme(void)
141 string stt_edj_path = get_resource_path();
142 string app_edj_path = get_resource_path();
145 stt_edj_path = stt_edj_path + STT_EDJ_FILE_WEARABLE;
146 app_edj_path = app_edj_path + APP_EDJ_FILE_WEARABLE;
148 stt_edj_path = stt_edj_path + STT_EDJ_FILE_TV;
149 app_edj_path = app_edj_path + APP_EDJ_FILE_TV;
151 stt_edj_path = stt_edj_path + STT_EDJ_FILE_MOBILE;
152 app_edj_path = app_edj_path + APP_EDJ_FILE_MOBILE;
155 elm_theme_extension_add(NULL, stt_edj_path.c_str());
156 elm_theme_extension_add(NULL, app_edj_path.c_str());
159 static Eina_Bool back_cb(void *data, Elm_Object_Item *it)
161 reply_to_sender_by_callback_for_back();
166 static void _stt_clicked_cb(void *data, Evas_Object * obj, void *event_info)
168 App_Data* ad = (App_Data*)data;
170 PRINTFUNC(DLOG_DEBUG, "");
175 ise_show_stt_popup(ad);
178 static void _input_smartreply_notify_cb(void *user_data)
180 ecore_main_loop_iterate();
181 _update_genlist_items((void *)app_data);
184 static void _input_template_notify_cb(void *user_data)
186 _update_genlist_items((void *)app_data);
189 static void _emoticon_clicked_cb(void *data, Evas_Object * obj, void *event_info)
191 App_Data* ad = (App_Data*)data;
193 PRINTFUNC(DLOG_DEBUG, "");
198 ise_show_emoticon_list(ad);
201 static void _keyboard_clicked_cb(void *data, Evas_Object * obj, void *event_info)
203 App_Data* ad = (App_Data *)data;
205 PRINTFUNC(DLOG_DEBUG, "");
210 input_keyboard_launch(ad->win_main, data);
213 static void __ise_smartreply_gl_sel(void *data, Evas_Object *obj, void *event_info)
215 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
218 elm_genlist_item_selected_set(item, EINA_FALSE);
220 int index = (intptr_t) elm_object_item_data_get(item);
223 char *reply = input_smartreply_get_nth_item(index, &type);
225 input_smartreply_send_feedback(reply);
226 reply_to_sender_by_callback(reply, "smartreply", NULL, NULL);
233 static void __ise_template_gl_sel(void *data, Evas_Object *obj, void *event_info)
235 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
239 elm_genlist_item_selected_set(item, EINA_FALSE);
241 index = (uintptr_t) elm_object_item_data_get(item);
242 const std::vector<TemplateData> template_list = input_template_get_list();
244 if (index < (int)template_list.size()) {
245 reply_to_sender_by_callback(gettext(template_list[index].text.c_str()), "template", NULL, NULL);
251 static void __ise_user_template_gl_sel(void *data, Evas_Object *obj, void *event_info)
253 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
257 elm_genlist_item_selected_set(item, EINA_FALSE);
259 index = (uintptr_t) elm_object_item_data_get(item);
261 if (index < (int)g_input_template_data.input_template_array_len) {
262 reply_to_sender_by_callback(g_input_template_data.input_template_array[index], "user_template", NULL, NULL);
268 static char * __ise_template_gl_text_get(void *data, Evas_Object *obj, const char *part)
270 if (!strcmp(part, "elm.text")) {
271 unsigned int index = (uintptr_t)data;
272 const std::vector<TemplateData> template_list = input_template_get_list();
274 if (index < template_list.size()) {
275 if (template_list[index].use_gettext) {
276 return strdup(gettext(template_list[index].text.c_str()));
278 Eina_Strbuf *buf = NULL;
279 const char *str = NULL;
282 buf = eina_strbuf_new();
284 eina_strbuf_append(buf, template_list[index].text.c_str());
285 eina_strbuf_replace_all(buf, "\n", "");
286 eina_strbuf_replace_all(buf, "\r", "");
288 str = eina_strbuf_string_get(buf);
291 markup = elm_entry_utf8_to_markup(str);
293 eina_strbuf_free(buf);
302 static char * __ise_user_template_gl_text_get(void *data, Evas_Object *obj, const char *part)
304 if (!strcmp(part, "elm.text")) {
305 unsigned int index = (uintptr_t)data;
306 if (index < (unsigned int)g_input_template_data.input_template_array_len) {
307 if (g_input_template_data.input_template_array[index] != NULL) {
308 return strdup(g_input_template_data.input_template_array[index]);
315 static Evas_Object * __ise_gl_2button_content_get(void *data, Evas_Object *obj, const char *part)
317 char *first_input_type = *(g_input_type_data.input_type_array + 0);
318 char *second_input_type = *(g_input_type_data.input_type_array + 1);
320 if (!strcmp(part, "elm.icon.1") || (!strcmp(part, "elm.icon.2"))) {
321 Evas_Object* btn = elm_button_add(obj);
322 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
323 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
325 Evas_Object* ic = elm_image_add(btn);
326 elm_image_resizable_set(ic, EINA_TRUE, EINA_TRUE);
327 string path = get_resource_path();
329 path = path + "wearable/";
333 path = path + "mobile/";
335 if (!strcmp(part, "elm.icon.1")) {
337 if (!strcmp(first_input_type, "input_voice")) {
338 elm_object_style_set(btn, "ime_button_stt");
339 path_ic = path + "images/w_mode_stt_ic.png";
340 evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
341 elm_atspi_accessible_name_set(btn, "IDS_IME_MBODY_VOICE_INPUT");
342 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
343 } else if (!strcmp(first_input_type, "input_emoticon")) {
344 elm_object_style_set(btn, "ime_button_emoticon");
345 path_ic = path + "images/Delta_w_mode_emoticon_ic.png";
346 evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
347 elm_atspi_accessible_name_set(btn, "IDS_COM_HEADER_EMOTICON");
348 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
349 } else if (!strcmp(first_input_type, "input_keyboard")) {
350 elm_object_style_set(btn, "ime_button_keyboard");
351 path_ic = path + "images/w_mode_keyboard_ic.png";
352 evas_object_propagate_events_set(btn, EINA_FALSE);
353 evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
354 elm_atspi_accessible_name_set(btn, "IDS_COM_OPT_KEYBOARD");
355 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
357 elm_image_file_set(ic, path_ic.c_str(), NULL);
358 elm_object_content_set(btn, ic);
359 evas_object_layer_set(btn, 32000);
360 } else if (!strcmp(part, "elm.icon.2")){
362 if (!strcmp(second_input_type, "input_voice")) {
363 elm_object_style_set(btn, "ime_button_stt");
364 path_ic = path + "images/w_mode_stt_ic.png";
365 evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
366 elm_atspi_accessible_name_set(btn, "IDS_IME_MBODY_VOICE_INPUT");
367 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
368 } else if (!strcmp(second_input_type, "input_emoticon")) {
369 elm_object_style_set(btn, "ime_button_emoticon");
370 path_ic = path + "images/Delta_w_mode_emoticon_ic.png";
371 evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
372 elm_atspi_accessible_name_set(btn, "IDS_COM_HEADER_EMOTICON");
373 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
374 } else if (!strcmp(second_input_type, "input_keyboard")) {
375 elm_object_style_set(btn, "ime_button_keyboard");
376 path_ic = path + "images/w_mode_keyboard_ic.png";
377 evas_object_propagate_events_set(btn, EINA_FALSE);
378 evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
379 elm_atspi_accessible_name_set(btn, "IDS_COM_OPT_KEYBOARD");
380 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
382 elm_image_file_set(ic, path_ic.c_str(), NULL);
383 elm_object_content_set(btn, ic);
384 evas_object_layer_set(btn, 32000);
387 } else if (!strcmp(part, "elm.icon.1.touch_area") || (!strcmp(part, "elm.icon.2.touch_area"))) {
388 Evas_Object* btn = elm_button_add(obj);
389 elm_object_style_set(btn, "touch_area");
390 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
391 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
392 string path = get_resource_path();
393 if (!strcmp(part, "elm.icon.1.touch_area")) {
394 evas_object_layer_set(btn, 32000);
395 if (!strcmp(first_input_type, "input_voice")) {
396 evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
397 elm_atspi_accessible_name_set(btn, "IDS_IME_MBODY_VOICE_INPUT");
398 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
399 } else if (!strcmp(first_input_type, "input_emoticon")) {
400 evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
401 elm_atspi_accessible_name_set(btn, "IDS_COM_HEADER_EMOTICON");
402 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
403 } else if (!strcmp(first_input_type, "input_keyboard")) {
404 evas_object_propagate_events_set(btn, EINA_FALSE);
405 evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
406 elm_atspi_accessible_name_set(btn, "IDS_COM_OPT_KEYBOARD");
407 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
409 } else if (!strcmp(part, "elm.icon.2.touch_area")){
410 evas_object_layer_set(btn, 32000);
411 if (!strcmp(second_input_type, "input_voice")) {
412 evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
413 elm_atspi_accessible_name_set(btn, "IDS_IME_MBODY_VOICE_INPUT");
414 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
415 } else if (!strcmp(second_input_type, "input_emoticon")) {
416 evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
417 elm_atspi_accessible_name_set(btn, "IDS_COM_HEADER_EMOTICON");
418 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
419 } else if (!strcmp(second_input_type, "input_keyboard")) {
420 evas_object_propagate_events_set(btn, EINA_FALSE);
421 evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
422 elm_atspi_accessible_name_set(btn, "IDS_COM_OPT_KEYBOARD");
423 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
427 } else if (!strcmp(part, "base")) {
428 Evas_Object* btn = elm_button_add(obj);
429 elm_object_style_set(btn, "ime_transparent");
435 static Evas_Object * __ise_gl_3button_content_get(void *data, Evas_Object *obj, const char *part)
437 if (!strcmp(part, "elm.icon.1") || (!strcmp(part, "elm.icon.2")) || (!strcmp(part, "elm.icon.3"))) {
438 Evas_Object* btn = elm_button_add(obj);
439 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
440 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
441 Evas_Object* ic = elm_image_add(btn);
442 elm_image_resizable_set(ic, EINA_TRUE, EINA_TRUE);
443 string path = get_resource_path();
445 path = path + "wearable/";
449 path = path + "mobile/";
451 if (!strcmp(part, "elm.icon.1")) {
452 elm_object_style_set(btn, "ime_button_stt");
453 string path_ic = path + "images/w_mode_stt_ic.png";
454 elm_image_file_set(ic, path_ic.c_str(), NULL);
455 elm_object_content_set(btn, ic);
456 evas_object_layer_set(btn, 32000);
457 evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
458 elm_atspi_accessible_name_set(btn, "IDS_IME_MBODY_VOICE_INPUT");
459 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
461 } else if (!strcmp(part, "elm.icon.2")){
462 elm_object_style_set(btn, "ime_button_emoticon");
463 string path_ic = path + "images/Delta_w_mode_emoticon_ic.png";
464 elm_image_file_set(ic, path_ic.c_str(), NULL);
465 elm_object_content_set(btn, ic);
466 evas_object_layer_set(btn, 32000);
467 evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
468 elm_atspi_accessible_name_set(btn, "IDS_COM_HEADER_EMOTICON");
469 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
471 } else if (!strcmp(part, "elm.icon.3")){
472 elm_object_style_set(btn, "ime_button_keyboard");
473 string path_ic = path + "images/w_mode_keyboard_ic.png";
474 elm_image_file_set(ic, path_ic.c_str(), NULL);
475 elm_object_content_set(btn, ic);
476 evas_object_layer_set(btn, 32000);
477 evas_object_propagate_events_set(btn, EINA_FALSE);
478 evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
479 elm_atspi_accessible_name_set(btn, "IDS_COM_OPT_KEYBOARD");
480 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
484 } else if (!strcmp(part, "elm.icon.1.touch_area") || (!strcmp(part, "elm.icon.2.touch_area")) || (!strcmp(part, "elm.icon.3.touch_area"))) {
485 Evas_Object* btn = elm_button_add(obj);
486 elm_object_style_set(btn, "touch_area");
487 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
488 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
489 string path = get_resource_path();
490 if (!strcmp(part, "elm.icon.1.touch_area")) {
491 evas_object_layer_set(btn, 32000);
492 evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
493 elm_atspi_accessible_name_set(btn, "IDS_IME_MBODY_VOICE_INPUT");
494 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
496 } else if (!strcmp(part, "elm.icon.2.touch_area")){
497 evas_object_layer_set(btn, 32000);
498 evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
499 elm_atspi_accessible_name_set(btn, "IDS_COM_HEADER_EMOTICON");
500 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
501 } else if (!strcmp(part, "elm.icon.3.touch_area")) {
502 evas_object_layer_set(btn, 32000);
503 evas_object_propagate_events_set(btn, EINA_FALSE);
504 evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
505 elm_atspi_accessible_name_set(btn, "IDS_COM_OPT_KEYBOARD");
506 elm_atspi_accessible_translation_domain_set(btn, PACKAGE);
510 } else if (!strcmp(part, "base")) {
511 Evas_Object* btn = elm_button_add(obj);
512 elm_object_style_set(btn, "ime_transparent");
518 static char * __ise_smartreply_gl_text_get(void *data, Evas_Object *obj, const char *part)
520 if(!strcmp(part, "elm.text")) {
523 index = (intptr_t)data;
527 reply = input_smartreply_get_nth_item(index, NULL);
536 static void __ise_gl_lang_changed(void *data, Evas_Object *obj, void *event_info)
538 //Update genlist items. The Item texts will be translated in the _gl_text_get().
539 elm_genlist_realized_items_update(obj);
542 static char * __ise_drawing_text_get(void *data, Evas_Object *obj, const char *part)
544 if(!strcmp(part, "elm.text")) {
545 return(strdup(gettext("WDS_IME_MBODY_DRAWING_M_EMOTICON_ABB")));
550 static Evas_Object * __ise_drawing_content_get(void *data, Evas_Object *obj, const char *part)
552 if (!strcmp(part, "elm.icon")) {
553 Evas_Object* btn = elm_button_add(obj);
554 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
555 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
556 Evas_Object* ic = elm_image_add(btn);
557 elm_image_resizable_set(ic, EINA_TRUE, EINA_TRUE);
558 string path = get_resource_path();
560 path = path + "wearable/";
564 path = path + "mobile/";
565 elm_object_style_set(btn, "ime_button_drawing");
566 string path_ic = path + "images/wi_drawing_icon.png";
567 elm_image_file_set(ic, path_ic.c_str(), NULL);
568 elm_object_content_set(btn, ic);
569 evas_object_layer_set(btn, 32000);
575 void set_source_caller_app_id(app_control_h app_control)
578 PRINTFUNC(DLOG_ERROR, "can't get app_control");
583 app_control_get_caller(app_data->source_app_control, &caller);
586 PRINTFUNC(DLOG_DEBUG, "caller = %s", caller);
587 app_control_add_extra_data(app_control, "caller_appid", caller);
592 void reply_to_sender_by_callback(const char *value, const char *type, const char *path[], const char *cursor_position)
594 PRINTFUNC(DLOG_DEBUG, "");
596 app_control_h app_control;
598 if (app_control_create(&app_control) == 0) {
602 app_control_add_extra_data(app_control, APP_CONTROL_DATA_TEXT, value);
605 app_control_add_extra_data(app_control, "reply_type", type);
608 app_control_add_extra_data_array(app_control, APP_CONTROL_DATA_PATH, path, 1);
611 if (cursor_position != NULL)
612 app_control_add_extra_data(app_control, "cursor_position_get", cursor_position);
614 set_source_caller_app_id(app_control);
616 ret = app_control_reply_to_launch_request(app_control, app_data->source_app_control, APP_CONTROL_RESULT_SUCCEEDED);
617 if (ret != APP_CONTROL_ERROR_NONE)
618 PRINTFUNC(DLOG_ERROR, "reply failed : %d", ret);
620 app_control_destroy(app_control);
621 app_control_destroy(app_data->source_app_control);
622 app_data->source_app_control = NULL;
626 void reply_to_sender_by_callback_for_back()
628 PRINTFUNC(DLOG_DEBUG, "");
630 app_control_h app_control;
632 if (app_control_create(&app_control) == 0) {
635 app_control_add_extra_data(app_control, "back_to_composer", "yes");
637 ret = app_control_reply_to_launch_request(app_control, app_data->source_app_control, APP_CONTROL_RESULT_SUCCEEDED);
638 if (ret != APP_CONTROL_ERROR_NONE)
639 PRINTFUNC(DLOG_ERROR, "reply failed : %d", ret);
641 app_control_destroy(app_control);
642 app_control_destroy(app_data->source_app_control);
643 app_data->source_app_control = NULL;
647 char* get_resource_path()
649 if (NULL == app_data->res_path) {
650 app_data->res_path = app_get_resource_path();
651 PRINTFUNC(DLOG_INFO, "set resource path = %s", app_data->res_path);
653 return (app_data->res_path);
656 char* get_shared_resource_path()
658 if (NULL == app_data->shared_res_path) {
659 app_data->shared_res_path = app_get_shared_resource_path();
660 PRINTFUNC(DLOG_INFO, "set shared resource path = %s", app_data->shared_res_path);
662 return (app_data->shared_res_path);
665 void show_gl_focus(Eina_Bool bVisible){
666 if (app_data->genlist == NULL)
669 if (bVisible == EINA_TRUE){
670 elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,enable", "elm");
671 //elm_layout_theme_set(app_data->genlist, "genlist", "base", "focus_bg");
672 //elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,show", "elm");
674 elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,disable", "elm");
675 //elm_layout_theme_set(app_data->genlist, "genlist", "base", "default");
676 //elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,hide", "elm");
680 void show_popup_toast(const char *text, bool check_img)
682 PRINTFUNC(DLOG_ERROR, "show_popup_toast");
686 popup = elm_popup_add(app_data->win_main);
687 elm_object_style_set(popup, "toast/circle");
688 elm_popup_orient_set(popup, ELM_POPUP_ORIENT_BOTTOM);
689 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
692 string path = get_resource_path();
694 path = path + "wearable/";
698 path = path + "mobile/";
699 string path_ic = path + "/images/toast_check_icon.png";
700 Evas_Object * img = elm_image_add(popup);
701 elm_image_file_set(img, path_ic.c_str(), NULL);
702 elm_object_part_content_set(popup, "toast,icon", img);
705 elm_object_part_text_set(popup, "elm.text", text);
708 eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, _popup_back_cb, NULL);
709 evas_object_smart_callback_add(popup, "dismissed", _popup_close_cb, NULL);
710 evas_object_smart_callback_add(popup, "block,clicked", _popup_back_cb, NULL);
712 elm_popup_timeout_set(popup, 2.0);
713 evas_object_show(popup);
716 static void _popup_close_cb(void *data, Evas_Object *obj, void *event_info)
719 evas_object_hide(obj);
720 evas_object_del(obj);
724 static void _popup_back_cb(void *data, Evas_Object *obj, void *event_info)
727 elm_popup_dismiss(obj);
731 void _back_to_genlist_for_selector()
733 PRINTFUNC(DLOG_DEBUG, "");
735 if (!app_data) return;
738 Evas_Object *circle_genlist = (Evas_Object *) evas_object_data_get(app_data->genlist, "circle");
739 eext_rotary_object_event_activated_set(circle_genlist, EINA_TRUE);
741 if (app_data->app_type == APP_TYPE_STT || app_data->app_type == APP_TYPE_EMOTICON || app_data->app_type == APP_TYPE_KEYBOARD){
742 PRINTFUNC(DLOG_DEBUG, "launched as STT/EMOTICON/KEYBOARD mode, So exit here.");
743 reply_to_sender_by_callback(NULL, NULL, NULL, NULL);
748 static void _item_realized(void *data, Evas_Object *obj, void *event_info) //called when list scrolled
750 PRINTFUNC(DLOG_DEBUG, "%s", __func__);
753 Evas_Object* _create_genlist(Evas_Object* navi)
755 Evas_Object* genlist = elm_genlist_add(navi);
759 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
761 Evas_Object* circle_object_genlist = eext_circle_object_genlist_add(genlist, app_data->circle_surface);
762 eext_circle_object_genlist_scroller_policy_set(circle_object_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
763 evas_object_data_set(genlist, "circle", (void *) circle_object_genlist);
764 eext_rotary_object_event_activated_set(circle_object_genlist, EINA_TRUE);
766 evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
767 evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
769 evas_object_smart_callback_add(genlist, "language,changed", __ise_gl_lang_changed, genlist);
770 evas_object_show(genlist);
772 // uxt_genlist_set_bottom_margin_enabled(genlist, EINA_TRUE);
774 show_gl_focus(EINA_FALSE);
776 const char *item_style = NULL;
778 item_style = "empty";
779 Elm_Object_Item *nf_main_item = elm_naviframe_item_push(navi,
786 elm_naviframe_item_pop_cb_set(nf_main_item, back_cb, app_data);
787 evas_object_smart_callback_add(genlist, "realized", _item_realized, NULL);
792 static void _item_position_changed_cb(void *data, Evas_Object *obj, void *event_info)
797 Evas_Object *genlist = (Evas_Object *)obj;
798 Elm_Object_Item *gen_item = (Elm_Object_Item *)data;
801 elm_scroller_region_get(genlist, NULL, &y, NULL, NULL);
803 // PRINTFUNC(DLOG_DEBUG,"y=%d",y);
805 if (250 > y && y >= 100){
806 if (last_step == 0) return;
808 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.0", "elm");
809 show_gl_focus(EINA_TRUE);
810 } else if (100 > y && y >= 50){
811 if (last_step == 1) return;
813 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.1", "elm");
814 show_gl_focus(EINA_TRUE);
815 } else if (y < 50 && y >=0){
816 if (last_step == 2) return;
818 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.9", "elm");
819 show_gl_focus(EINA_FALSE);
823 void _create_genlist_items(void* user_data)
825 App_Data* app_data = (App_Data*) user_data;
827 if (NULL == app_data->genlist) {
828 app_data->genlist = _create_genlist(app_data->naviframe);
829 if (NULL == app_data->genlist)
833 elm_genlist_clear(app_data->genlist);
835 Elm_Genlist_Item_Class * itc0 = elm_genlist_item_class_new();
836 itc0->item_style = NULL;
837 itc0->func.text_get = NULL;
838 itc0->func.content_get = NULL;
839 itc0->func.state_get = NULL;
840 itc0->func.del = NULL;
842 Elm_Genlist_Item_Class * itc1 = elm_genlist_item_class_new();
843 if (g_input_type_data.input_type_array_len == 2){
844 itc1->item_style = "2button_flat";
845 itc1->func.text_get = NULL;
846 itc1->func.content_get = __ise_gl_2button_content_get;
847 itc1->func.state_get = NULL;
848 itc1->func.del = NULL;
850 itc1->item_style = "3button_flat";
851 itc1->func.text_get = NULL;
852 itc1->func.content_get = __ise_gl_3button_content_get;
853 itc1->func.state_get = NULL;
854 itc1->func.del = NULL;
857 // dummy title for empty space
858 it_empty = elm_genlist_item_append(app_data->genlist, itc0,
860 ELM_GENLIST_ITEM_NONE,
863 if (app_data->app_type != APP_TYPE_REPLY) {
865 it_title = elm_genlist_item_append(app_data->genlist, itc1,
867 ELM_GENLIST_ITEM_NONE,
871 elm_genlist_item_select_mode_set(it_title, ELM_OBJECT_SELECT_MODE_NONE);
873 g_template_item_size = _update_template_items(app_data);
875 Elm_Object_Item *item = elm_genlist_item_next_get(it_title);
876 elm_genlist_item_show(item, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
878 evas_object_smart_callback_add(app_data->genlist, "elm,item,position,changed", _item_position_changed_cb, it_title);
880 elm_genlist_item_class_free(itc0);
881 elm_genlist_item_class_free(itc1);
884 void _create_header_items(void *user_data)
886 Elm_Genlist_Item_Class * itc0 = elm_genlist_item_class_new();
887 itc0->item_style = "title";
888 itc0->func.text_get = NULL;
889 itc0->func.content_get = NULL;
890 itc0->func.state_get = NULL;
891 itc0->func.del = NULL;
893 Elm_Genlist_Item_Class * itc1 = elm_genlist_item_class_new();
894 if (g_input_type_data.input_type_array_len == 2) {
895 itc1->item_style = "2button_flat";
896 itc1->func.text_get = NULL;
897 itc1->func.content_get = __ise_gl_2button_content_get;
898 itc1->func.state_get = NULL;
899 itc1->func.del = NULL;
901 itc1->item_style = "3button_flat";
902 itc1->func.text_get = NULL;
903 itc1->func.content_get = __ise_gl_3button_content_get;
904 itc1->func.state_get = NULL;
905 itc1->func.del = NULL;
908 // dummy title for empty space
909 it_empty = elm_genlist_item_append(app_data->genlist, itc0,
911 ELM_GENLIST_ITEM_NONE,
915 it_title = elm_genlist_item_append(app_data->genlist, itc1,
917 ELM_GENLIST_ITEM_NONE,
920 elm_genlist_item_select_mode_set(it_title, ELM_OBJECT_SELECT_MODE_NONE);
922 elm_genlist_item_class_free(itc0);
923 elm_genlist_item_class_free(itc1);
926 void _update_genlist_items(void *user_data)
928 elm_genlist_clear(app_data->genlist);
930 _create_header_items(user_data);
932 if (input_smartreply_is_enabled())
933 g_smartreply_item_size = _update_smartreply_items(user_data);
935 g_smartreply_item_size = 0;
937 g_template_item_size = _update_template_items(user_data);
939 if (g_input_template_data.input_template_array_len > 0) {
940 _update_user_template_items(user_data);
943 /* Update genlist item position */
944 Elm_Object_Item *item = elm_genlist_item_next_get(it_title);
945 elm_genlist_item_show(item, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
948 unsigned int _update_smartreply_items(void *user_data)
952 Elm_Object_Item *first;
955 unsigned int len = 0;
956 unsigned int item_size = 0;
958 app_data = (App_Data *)user_data;
960 if (app_data == NULL) {
961 PRINTFUNC(DLOG_ERROR, "Can not get app_data");
965 if (app_data->genlist == NULL) {
966 /* smartreply will update when genlist is exist only */
967 PRINTFUNC(DLOG_ERROR, "Can not get getlist");
971 /* Move to smartreply */
972 first = elm_genlist_first_item_get(app_data->genlist);
973 elm_genlist_item_next_get(first);
975 if (input_smartreply_is_enabled() == false)
978 /* Append newly added smartreply list */
979 len = input_smartreply_get_reply_num();
982 const std::vector<TemplateData> template_list = input_template_get_list();
984 Elm_Genlist_Item_Class *itc;
986 itc = elm_genlist_item_class_new();
987 itc->item_style = "1text";
988 itc->func.text_get = __ise_smartreply_gl_text_get;
989 itc->func.content_get = NULL;
990 itc->func.state_get = NULL;
991 itc->func.del = NULL;
993 for (i = 0; i < len; i++) {
994 char *reply = (char *)"hello";
1001 reply = input_smartreply_get_nth_item(i, &type);
1004 SECURE_LOGD("SmartReply = [%d]%s", i, reply);
1006 for (j = 0; j < template_list.size(); j++) {
1007 const char *template_str;
1009 if (template_list[j].use_gettext)
1010 template_str = gettext(template_list[j].text.c_str());
1012 template_str = template_list[j].text.c_str();
1014 if (!__compare_string(reply, template_str)) {
1020 if (matched == true)
1023 elm_genlist_item_append(app_data->genlist,
1025 (void *)(uintptr_t)i,
1027 ELM_GENLIST_ITEM_NONE,
1028 __ise_smartreply_gl_sel,
1035 elm_genlist_item_class_free(itc);
1040 static void _drawing_item_clicked_cb(void *data, Evas_Object * obj, void *event_info)
1042 PRINTFUNC(DLOG_DEBUG, "%s", __func__);
1043 App_Data* ad = (App_Data*) data;
1047 launch_drawing_app(ad);
1050 unsigned int _update_template_items(void *user_data)
1054 Elm_Object_Item *first;
1055 Elm_Object_Item *menu;
1056 Elm_Object_Item *pos;
1059 unsigned int item_size = 0;
1061 app_data = (App_Data *)user_data;
1063 if (app_data == NULL) {
1064 PRINTFUNC(DLOG_ERROR, "Can not get app_data");
1068 if (app_data->genlist == NULL) {
1069 /* smartreply will update when genlist is exist only */
1070 PRINTFUNC(DLOG_ERROR, "Can not get getlist");
1074 first = elm_genlist_first_item_get(app_data->genlist);
1077 menu = elm_genlist_item_next_get(first);
1080 /* move to smartreply next if it need */
1081 if (input_smartreply_is_enabled()) {
1084 for (j = 0; j < g_smartreply_item_size; j++) {
1088 pos = elm_genlist_item_next_get(pos);
1092 /* Append New Template list */
1093 const std::vector<TemplateData> template_list = input_template_get_list();
1095 if (template_list.size() > 0) {
1096 Elm_Genlist_Item_Class *itc;
1098 itc = elm_genlist_item_class_new();
1100 itc->item_style = "1text";
1101 itc->func.text_get = __ise_template_gl_text_get;
1102 itc->func.content_get = NULL;
1103 itc->func.state_get = NULL;
1104 itc->func.del = NULL;
1106 for (i = 0; i < template_list.size(); i++) {
1107 pos = elm_genlist_item_append(app_data->genlist,
1109 (void *)(uintptr_t)i,
1111 ELM_GENLIST_ITEM_NONE,
1112 __ise_template_gl_sel,
1116 elm_genlist_item_class_free(itc);
1118 // drawing button (+)
1119 if (app_data->mime_type == MIME_TYPE_ALL && app_data->app_type == APP_TYPE_SELECT_MODE) {
1120 Elm_Genlist_Item_Class *itc;
1121 itc = elm_genlist_item_class_new();
1123 itc->item_style = "1text.1icon";
1124 itc->func.text_get = __ise_drawing_text_get;;
1125 itc->func.content_get = __ise_drawing_content_get;
1126 itc->func.state_get = NULL;
1127 itc->func.del = NULL;
1129 elm_genlist_item_append(app_data->genlist,
1133 ELM_GENLIST_ITEM_NONE,
1134 _drawing_item_clicked_cb,
1137 elm_genlist_item_class_free(itc);
1140 // dummy item for empty space
1141 Elm_Genlist_Item_Class * itc0 = elm_genlist_item_class_new();
1142 itc0->item_style = "title";
1143 itc0->func.text_get = NULL;
1144 itc0->func.content_get = NULL;
1145 itc0->func.state_get = NULL;
1146 itc0->func.del = NULL;
1148 if (g_input_template_data.input_template_array_len < 1) {
1149 it_empty = elm_genlist_item_append(app_data->genlist, itc0,
1151 ELM_GENLIST_ITEM_NONE,
1154 elm_genlist_item_class_free(itc0);
1160 unsigned int _update_user_template_items(void *user_data)
1164 Elm_Object_Item *first;
1167 unsigned int item_size = 0;
1169 app_data = (App_Data *)user_data;
1171 if (app_data == NULL) {
1172 PRINTFUNC(DLOG_ERROR, "Can not get app_data");
1176 if (app_data->genlist == NULL) {
1177 /* smartreply will update when genlist is exist only */
1178 PRINTFUNC(DLOG_ERROR, "Can not get getlist");
1182 first = elm_genlist_first_item_get(app_data->genlist);
1186 if (g_input_template_data.input_template_array_len > 0) {
1187 Elm_Genlist_Item_Class *itc;
1189 itc = elm_genlist_item_class_new();
1191 itc->item_style = "1text";
1192 itc->func.text_get = __ise_user_template_gl_text_get;
1193 itc->func.content_get = NULL;
1194 itc->func.state_get = NULL;
1195 itc->func.del = NULL;
1197 for (i = 0; i < (unsigned int)g_input_template_data.input_template_array_len; i++) {
1198 elm_genlist_item_append(app_data->genlist,
1200 (void *)(uintptr_t)i,
1202 ELM_GENLIST_ITEM_NONE,
1203 __ise_user_template_gl_sel,
1207 elm_genlist_item_class_free(itc);
1209 // dummy item for empty space
1210 Elm_Genlist_Item_Class * itc0 = elm_genlist_item_class_new();
1211 itc0->item_style = "title";
1212 itc0->func.text_get = NULL;
1213 itc0->func.content_get = NULL;
1214 itc0->func.state_get = NULL;
1215 itc0->func.del = NULL;
1217 it_empty = elm_genlist_item_append(app_data->genlist, itc0,
1219 ELM_GENLIST_ITEM_NONE,
1221 elm_genlist_item_class_free(itc0);
1227 bool __compare_string(const char * smart_str, const char * template_str)
1233 if(!smart_str||!template_str)
1236 src_len = strlen(smart_str);
1237 dst_len = strlen(template_str);
1239 if(smart_str[src_len-1] == '.')
1242 while(template_str[dst_len-1] == ' ')
1244 if(template_str[dst_len-1] == '.')
1247 dst_len = (dst_len > src_len)? dst_len : src_len;
1249 if(!strncmp(smart_str, template_str, (size_t)dst_len))
1255 bool _app_create(void* user_data)
1257 int width = 1000, height = 1000;
1258 // App_Data* app_data = NULL;
1259 Evas_Object* layout = NULL;
1260 Evas_Object* conform = NULL;
1261 Evas_Object* bg = NULL;
1262 Evas_Object* window = NULL;
1263 Eext_Circle_Surface *surface = NULL;
1269 _app_language_changed(NULL, NULL);
1271 app_data = (App_Data*)user_data;
1273 elm_app_base_scale_set(1.3);
1275 window = elm_win_add(NULL, PACKAGE, ELM_WIN_BASIC);
1277 init_customizing_theme();
1279 elm_win_title_set(window, PACKAGE);
1280 elm_win_borderless_set(window, EINA_TRUE);
1281 // ecore_x_window_size_get(ecore_x_window_root_first_get(), &width, &height);
1282 evas_object_resize(window, width, height);
1283 elm_win_indicator_mode_set(window, ELM_WIN_INDICATOR_SHOW);
1285 LOGE("elm_win_add() is failed.");
1289 bg = elm_bg_add(window);
1290 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1291 elm_win_resize_object_add(window, bg);
1292 evas_object_show(bg);
1294 layout = elm_layout_add(window);
1295 elm_layout_theme_set(layout, "layout", "application", "default");
1296 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1298 conform = elm_conformant_add(window);
1300 surface = eext_circle_surface_conformant_add(conform);
1302 evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1304 elm_win_resize_object_add(window, conform);
1305 elm_object_content_set(conform, layout);
1307 evas_object_show(layout);
1308 evas_object_show(conform);
1309 evas_object_show(window);
1310 app_data->win_main = window;
1311 app_data->conform = conform;
1312 app_data->layout_main = layout;
1313 app_data->circle_surface = surface;
1314 app_data->app_type = APP_TYPE_SELECT_MODE;
1316 Evas_Object *naviframe = elm_naviframe_add(layout);
1317 elm_naviframe_prev_btn_auto_pushed_set(naviframe, EINA_FALSE);
1318 eext_object_event_callback_add(naviframe, EEXT_CALLBACK_BACK, eext_naviframe_back_cb, NULL);
1319 elm_object_part_content_set(layout, "elm.swallow.content", naviframe);
1320 evas_object_show(naviframe);
1322 app_data->naviframe = naviframe;
1327 void _app_service(app_control_h service, void* user_data)
1330 char *context = NULL;
1331 char **input_type_array = NULL;
1332 int input_type_array_len = -1;
1333 bool is_extra_data_array = false;
1334 char *mime_type = NULL;
1335 char **user_template_array = NULL;
1336 int user_template_array_len = -1;
1338 app_control_clone(&(app_data->source_app_control), service);
1339 app_data->reply_type = REPLY_APP_NORMAL;
1340 app_data->mime_type = MIME_TYPE_ALL;
1342 ret = app_control_get_extra_data_array(service, "user_template", &user_template_array, &user_template_array_len);
1343 g_input_template_data.input_template_array = user_template_array;
1344 g_input_template_data.input_template_array_len = user_template_array_len;
1346 ret = app_control_get_mime(service, &mime_type);
1347 if (ret != APP_CONTROL_ERROR_NONE) {
1348 LOGD("Fail to get mime type : %d", ret);
1351 LOGD("mime type = %s", mime_type);
1352 if (!strncmp(mime_type, "image/", strlen("image/"))) {
1353 app_data->mime_type = MIME_TYPE_IMAGE;
1354 app_data->app_type = APP_TYPE_DRAWING;
1355 launch_drawing_app((void *)app_data);
1359 } else if (!strncmp(mime_type, "audio/", strlen("audio/"))) {
1360 app_data->mime_type = MIME_TYPE_AUDIO;
1361 app_data->app_type = APP_TYPE_STT;
1362 _stt_clicked_cb((void *)app_data, NULL, NULL);
1366 } else if (!strncmp(mime_type, "text/", strlen("text/"))) {
1367 app_data->mime_type = MIME_TYPE_TEXT;
1374 if (_TV || _MOBILE) {
1375 app_data->app_type = APP_TYPE_KEYBOARD;
1376 input_keyboard_init(service);
1377 _keyboard_clicked_cb((void *)app_data, NULL, NULL);
1381 ret = app_control_is_extra_data_array(service, APP_CONTROL_DATA_INPUT_TYPE, &is_extra_data_array);
1382 if ( is_extra_data_array == true) {
1383 ret = app_control_get_extra_data_array(service, APP_CONTROL_DATA_INPUT_TYPE, &input_type_array, &input_type_array_len);
1384 g_input_type_data.input_type_array = input_type_array;
1385 g_input_type_data.input_type_array_len = input_type_array_len;
1387 ret = app_control_get_extra_data(service, APP_CONTROL_DATA_INPUT_TYPE, &context);
1388 if (ret == APP_CONTROL_ERROR_NONE) {
1389 if (!strcmp(context, "input_voice")) {
1390 app_data->app_type = APP_TYPE_STT;
1391 _stt_clicked_cb((void *)app_data, NULL, NULL);
1393 } else if (!strcmp(context, "input_recording")) {
1394 app_data->app_type = APP_TYPE_RECORDING;
1395 _stt_clicked_cb((void *)app_data, NULL, NULL);
1397 } else if (!strcmp(context, "input_emoticon")) {
1398 app_data->app_type = APP_TYPE_EMOTICON;
1399 _emoticon_clicked_cb((void *)app_data, NULL, NULL);
1401 } else if (!strcmp(context, "input_keyboard")) {
1402 app_data->app_type = APP_TYPE_KEYBOARD;
1403 input_keyboard_init(service);
1404 _keyboard_clicked_cb((void *)app_data, NULL, NULL);
1406 } else if (!strcmp(context, "input_drawing")) {
1407 app_data->app_type = APP_TYPE_DRAWING;
1408 _drawing_item_clicked_cb((void *)app_data, NULL, NULL);
1410 } else if (!strcmp(context, "input_reply")) {
1411 app_data->app_type = APP_TYPE_REPLY;
1416 if (app_data->genlist == NULL)
1417 app_data->genlist = _create_genlist(app_data->naviframe);
1419 input_keyboard_init(service);
1421 input_smartreply_init(service);
1422 input_smartreply_set_notify(_input_smartreply_notify_cb, NULL);
1424 if (input_smartreply_is_enabled())
1425 input_smartreply_get_reply_async();
1427 input_template_init(service);
1428 input_template_set_notify(_input_template_notify_cb, NULL);
1430 _create_genlist_items(app_data);
1433 elm_win_activate(app_data->win_main);
1439 void _app_pause(void* user_data)
1441 PRINTFUNC(DLOG_DEBUG, "");
1445 void _app_resume(void* user_data)
1447 PRINTFUNC(DLOG_DEBUG, "");
1451 void _app_terminate(void* user_data)
1453 App_Data* app_data = NULL;
1454 app_data = (App_Data*)user_data;
1456 if (app_data->genlist){
1457 evas_object_smart_callback_del(app_data->genlist, "elm,item,position,changed", _item_position_changed_cb);
1460 if (app_data->res_path)
1461 free(app_data->res_path);
1463 if (app_data->shared_res_path)
1464 free(app_data->shared_res_path);
1466 input_keyboard_deinit();
1467 input_smartreply_deinit();
1469 input_template_unset_notify();
1470 input_template_deinit();
1472 input_type_deinit();
1475 static int init_i18n(const char *domain, const char *dir, char *lang_str)
1477 if (setlocale(LC_ALL, "") == NULL) {
1478 PRINTFUNC(DLOG_INFO, "Some environment variable is invalid, setlocale(LC_ALL, \"\") has returns\ed a null pointer");
1479 if (setlocale(LC_ALL, lang_str) == NULL)
1482 if (bindtextdomain(domain, dir) == NULL)
1484 if (textdomain(domain) == NULL)
1491 * @brief Set language and locale.
1495 static void _app_language_changed(app_event_info_h event_info, void *user_data)
1497 char* lang_str = vconf_get_str(VCONFKEY_LANGSET);
1499 setenv("LANG", lang_str, 1);
1500 setenv("LC_MESSAGES", lang_str, 1);
1502 setenv("LANG", "en_GB.utf8", 1);
1503 setenv("LC_MESSAGES", "en_GB.utf8", 1);
1504 lang_str = strdup("en_GB.UTF-8");
1507 init_i18n(PACKAGE, LOCALEDIR, lang_str);
1510 elm_language_set(lang_str);
1515 void input_type_deinit(void)
1518 char **data_array = NULL;
1520 data_array = g_input_type_data.input_type_array;
1522 for (i = 0; i < g_input_type_data.input_type_array_len; i++) {
1523 if (*(data_array + i))
1524 free(*(data_array + i));
1528 g_input_type_data.input_type_array = NULL;
1529 g_input_type_data.input_type_array_len = 0;
1532 EXPORTED int main(int argc, char* argv[])
1534 App_Data app_data = {0, };
1535 ui_app_lifecycle_callback_s event_callback = {0, };
1536 app_event_handler_h handlers[5] = {NULL, };
1538 event_callback.create = _app_create;
1539 event_callback.terminate = _app_terminate;
1540 event_callback.pause = _app_pause;
1541 event_callback.resume = _app_resume;
1542 event_callback.app_control = _app_service;
1544 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, NULL, &app_data);
1545 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, NULL, &app_data);
1546 ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, NULL, &app_data);
1547 ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, _app_language_changed, &app_data);
1548 ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, NULL, &app_data);
1550 _init_app_data(&app_data);
1552 int ret = ui_app_main(argc, argv, &event_callback, &app_data);
1553 if (ret != APP_ERROR_NONE) {
1554 LOGD("ui_app_main() is failed. err = %d", ret);