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.
23 #include <efl_assist.h>
25 #include <vconf-keys.h>
27 //#include "ui_extension.h"
28 #include "w-input-selector.h"
29 #include "w-input-template.h"
30 #include "w-input-smartreply.h"
31 #include "w-input-keyboard.h"
32 #include "w-input-stt-ise.h"
33 #include "w-input-emoticon.h"
34 #include "w-input-stt-tos.h"
36 #ifdef SUPPORT_LOG_MANAGER
37 #include <samsung_log_manager.h>
38 #include <samsung_log_manager_uri.h>
46 App_Data* app_data = NULL;
47 #ifdef SUPPORT_LOG_MANAGER
48 static samsung_log_manager_h g_log_manager = NULL;
51 InputKeyboardData g_input_keyboard_data;
53 static Elm_Object_Item *it_empty;
54 static Elm_Object_Item *it_title;
55 static Elm_Object_Item *it_plus;
56 static int g_smartreply_current_number = 0; /* currently loaded smartreply number */
57 static unsigned int g_template_current_number = 0; /* currnetly loaded template number */
59 Evas_Coord last_step; // 0 ~ 9 for gesture, 10~11 for rotary
61 static Eina_Bool force_highlight_to_top = EINA_FALSE;
62 static Eina_Bool force_highlight_to_bottom = EINA_FALSE;
63 static Eina_Bool is_genlist_highlighed = EINA_FALSE;
65 void _init_app_data(App_Data* app_data);
66 static void _app_language_changed(app_event_info_h event_info, void *user_data);
67 static int _app_control_request_transient_app_cb(void *data);
68 #ifdef SUPPORT_LOG_MANAGER
69 static void log_manager_init(void);
70 static void log_manager_exit(void);
71 static void log_manager_set(const char *feature, const char *extra, const char *value);
74 static char *_genlist_text_set_theme_color(const char *str, const char *code);
76 Evas_Object* _create_genlist(Evas_Object* parent);
77 void _create_genlist_items(void* user_data, bool is_type_reply);
78 void _update_genlist_items(void *user_data);
79 void _update_smartreply_items(void *user_data);
80 void _update_template_items(void *user_data);
81 static void _popup_close_cb(void *data, Evas_Object *obj, void *event_info);
82 static void _popup_back_cb(void *data, Evas_Object *obj, void *event_info);
83 char * _toast_delete_popup_access_info_cb(void *data, Evas_Object *obj);
87 void _init_app_data(App_Data* app_data)
89 app_data->win_main = NULL;
90 app_data->layout_main = NULL;
91 app_data->conform = NULL;
92 app_data->naviframe = NULL;
93 app_data->genlist = NULL;
95 app_data->res_path = NULL;
100 Evas_Object* load_edj(Evas_Object* parent, const char* file, const char* group)
103 Evas_Object* content;
106 window = elm_layout_add(parent);
108 ret = elm_layout_file_set(window, file, group);
110 evas_object_del(window);
114 content = elm_layout_add(parent);
115 elm_layout_theme_set(content, "layout", "application", "default");
116 elm_object_part_content_set(window, "elm.swallow.content", content);
118 evas_object_size_hint_weight_set(window, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
124 void init_customizing_theme(void)
126 string stt_edj_path = get_resource_path();
127 string app_edj_path = get_resource_path();
129 stt_edj_path = stt_edj_path + STT_EDJ_FILE;
130 app_edj_path = app_edj_path + APP_EDJ_FILE;
132 elm_theme_extension_add(NULL, stt_edj_path.c_str());
133 elm_theme_extension_add(NULL, app_edj_path.c_str());
137 static Eina_Bool back_cb(void *data, Elm_Object_Item *it)
139 reply_to_sender_by_callback_for_back();
144 static void _stt_clicked_cb(void *data, Evas_Object * obj, void *event_info)
146 App_Data* ad = (App_Data*)data;
148 PRINTFUNC(DLOG_DEBUG, "");
154 bool bAgreed = false;
155 stt_get_user_agreement(&bAgreed);
158 if(is_tos_N66_agreed() == EINA_FALSE){
159 if(is_sap_connection() == EINA_TRUE){
160 ise_show_tos_n66_popup(ad);
162 launch_bt_connection_popup(ad);
165 ise_show_stt_popup(ad);
169 #ifdef SUPPORT_LOG_MANAGER
170 log_manager_set("IM01", "STT", NULL);
174 static void _input_smartreply_notify_cb(void *user_data)
176 ecore_main_loop_iterate();
177 _update_genlist_items((void *)app_data);
180 static void _input_template_notify_cb(void *user_data)
182 _update_genlist_items((void *)app_data);
186 static void _emoticon_clicked_cb(void *data, Evas_Object * obj, void *event_info)
188 App_Data* ad = (App_Data*)data;
190 PRINTFUNC(DLOG_DEBUG, "");
195 // ise_show_emoticon_popup(ad);
196 ise_show_emoticon_popup_rotary(ad);
198 #ifdef SUPPORT_LOG_MANAGER
199 log_manager_set("IM01", "Emoticon", NULL);
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 #ifdef SUPPORT_LOG_MANAGER
213 log_manager_set("IM01", "Keypad", NULL);
216 if (app_data->app_type == APP_TYPE_KEYBOARD_FROM_SMS)
217 input_keyboard_launch(ad->win_main);
219 input_keyboard_launch_with_ui(ad->win_main, data);
222 static void __bt_connection_result_cb(app_control_h request, app_control_h reply, app_control_result_e result, void *user_data)
227 PRINTFUNC(DLOG_ERROR, "service_h is NULL");
231 app_control_get_extra_data(reply, "__BT_CONNECTION__", &val);
233 if ( strcmp(val, "Connected") == 0 ) {
234 PRINTFUNC(DLOG_ERROR, "BT Connected");
236 PRINTFUNC(DLOG_ERROR, "BT Not Connected");
244 static void __ise_smartreply_gl_sel(void *data, Evas_Object *obj, void *event_info)
246 App_Data* app_data = (App_Data*) data;
247 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
250 elm_genlist_item_selected_set(item, EINA_FALSE);
252 int index = (unsigned int) elm_object_item_data_get(item);
254 #ifdef SUPPORT_LOG_MANAGER
255 log_manager_set("IM01", "Preset", NULL);
256 log_manager_set("IM02", "Smart Reply", NULL);
258 char *reply = input_smartreply_get_nth_item(index);
260 input_smartreply_send_feedback(reply);
261 if(app_data->reply_type == REPLY_APP_CONTROL){
262 reply_to_sender_by_appcontrol((void*)app_data, reply, "smartreply");
265 reply_to_sender_by_callback(reply, "smartreply");
273 static void __ise_template_add_gl_sel(void *data, Evas_Object *obj, void *event_info)
275 App_Data* app_data = (App_Data*) data;
276 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
279 elm_genlist_item_selected_set(item, EINA_FALSE);
281 if(is_sap_connection() == EINA_TRUE){
283 show_popup_toast(gettext("WDS_IME_TPOP_ADD_TEMPLATE_ON_YOUR_PHONE_ABB"), true);
285 // send message to Host
286 app_control_h appctrl;
287 app_control_create(&appctrl);
288 app_control_set_app_id(appctrl, "com.samsung.w-manager-service");
289 app_control_add_extra_data(appctrl, "type", "gm_setting");
290 app_control_add_extra_data(appctrl, "data/setting_menu", "texttemplate_setting");
291 app_control_send_launch_request(appctrl, NULL, NULL);
292 app_control_destroy(appctrl);
294 app_control_h app_control;
295 app_control_create(&app_control);
296 app_control_set_app_id(app_control, "com.samsung.bt-connection-popup");
297 app_control_add_extra_data(app_control, "msg", "perform");
298 app_control_send_launch_request(app_control, __bt_connection_result_cb, NULL);
299 app_control_destroy(app_control);
304 static void __ise_template_gl_sel(void *data, Evas_Object *obj, void *event_info)
306 App_Data* app_data = (App_Data*) data;
307 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
311 elm_genlist_item_selected_set(item, EINA_FALSE);
313 index = (unsigned int) elm_object_item_data_get(item);
314 const std::vector<TemplateData> template_list = input_template_get_list();
316 //@ToDo : should call reply function when any template string is selected and confirmed.
317 // Here reply string will be template_list[index].text.c_str();
318 if( index < template_list.size()) {
319 #ifdef SUPPORT_LOG_MANAGER
320 log_manager_set("IM01", "Preset", NULL);
321 log_manager_set("IM02", "Preset except smart reply", NULL);
323 if(app_data->reply_type == REPLY_APP_CONTROL){
324 reply_to_sender_by_appcontrol((void*)app_data, gettext(template_list[index].text.c_str()), "template");
326 reply_to_sender_by_callback(gettext(template_list[index].text.c_str()), "template");
333 static Evas_Object * __ise_gl_3button_content_get(void *data, Evas_Object *obj, const char *part)
335 if (!strcmp(part, "elm.icon.1") || (!strcmp(part, "elm.icon.2")) || (!strcmp(part, "elm.icon.3"))) {
336 Evas_Object* btn = elm_button_add(obj);
337 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
338 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
339 Evas_Object* ic = elm_image_add(btn);
340 elm_image_resizable_set(ic, EINA_TRUE, EINA_TRUE);
341 string path = get_resource_path();
342 if (!strcmp(part, "elm.icon.1")) {
343 elm_object_style_set(btn, "anchor");
344 string path_ic = path + "images/w_mode_stt_ic.png";
345 elm_image_file_set(ic, path_ic.c_str(), NULL);
346 elm_object_content_set(btn, ic);
347 evas_object_layer_set(btn, 32000);
348 if (elm_config_access_get())
349 elm_access_object_unregister(btn);
351 int powerSavingMode = -1;
353 // Power Saving mode check
354 ret = vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &powerSavingMode);
357 PRINTFUNC(DLOG_ERROR, "VCONFKEY_SETAPPL_PSMODE FAILED");
360 if (powerSavingMode == SETTING_PSMODE_WEARABLE_ENHANCED) {
361 PRINTFUNC(DLOG_ERROR, "Power Saving mode, disable stt !!!");
362 elm_object_disabled_set(btn, EINA_TRUE);
364 } else if (!strcmp(part, "elm.icon.2")){
365 elm_object_style_set(btn, "anchor");
366 string path_ic = path + "images/Delta_w_mode_emoticon_ic.png";
367 elm_image_file_set(ic, path_ic.c_str(), NULL);
368 elm_object_content_set(btn, ic);
369 evas_object_layer_set(btn, 32000);
370 if (elm_config_access_get())
371 elm_access_object_unregister(btn);
373 } else if (!strcmp(part, "elm.icon.3")){
374 elm_object_style_set(btn, "anchor");
375 string path_ic = path + "images/w_mode_keyboard_ic.png";
376 elm_image_file_set(ic, path_ic.c_str(), NULL);
377 elm_object_content_set(btn, ic);
378 evas_object_layer_set(btn, 32000);
379 evas_object_propagate_events_set(btn, EINA_FALSE);
380 if (elm_config_access_get())
381 elm_access_object_unregister(btn);
385 } else if (!strcmp(part, "elm.icon.1.touch_area") || (!strcmp(part, "elm.icon.2.touch_area")) || (!strcmp(part, "elm.icon.3.touch_area"))) {
386 Evas_Object* btn = elm_button_add(obj);
387 elm_object_style_set(btn, "touch_area");
388 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
389 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
390 string path = get_resource_path();
391 if (!strcmp(part, "elm.icon.1.touch_area")) {
392 int powerSavingMode = -1;
394 // Power Saving mode check
395 ret = vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &powerSavingMode);
398 PRINTFUNC(DLOG_ERROR, "VCONFKEY_SETAPPL_PSMODE FAILED");
401 if (powerSavingMode == SETTING_PSMODE_WEARABLE_ENHANCED) {
402 PRINTFUNC(DLOG_ERROR, "Power Saving mode, disable stt !!!");
403 elm_object_disabled_set(btn, EINA_TRUE);
406 evas_object_layer_set(btn, 32000);
407 evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
408 if (elm_config_access_get()){
409 elm_access_info_set(btn, ELM_ACCESS_INFO, gettext("IDS_IME_MBODY_VOICE_INPUT"));
410 // elm_access_chain_end_set(btn, ELM_HIGHLIGHT_DIR_PREVIOUS);
413 } else if (!strcmp(part, "elm.icon.2.touch_area")){
414 evas_object_layer_set(btn, 32000);
415 evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
416 if (elm_config_access_get())
417 elm_access_info_set(btn, ELM_ACCESS_INFO, gettext("IDS_COM_HEADER_EMOTICON"));
418 } else if (!strcmp(part, "elm.icon.3.touch_area")) {
419 evas_object_layer_set(btn, 32000);
420 evas_object_propagate_events_set(btn, EINA_FALSE);
421 evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
422 if (elm_config_access_get())
423 elm_access_info_set(btn, ELM_ACCESS_INFO, gettext("IDS_COM_OPT_KEYBOARD"));
427 } else if (!strcmp(part, "base")) {
428 Evas_Object* btn = elm_button_add(obj);
429 if (elm_config_access_get())
430 elm_access_object_unregister(btn);
431 elm_object_style_set(btn, "ime_transparent");
437 static char * __ise_smartreply_gl_text_get(void *data, Evas_Object *obj, const char *part)
439 if(!strcmp(part, "elm.text")) {
447 reply = input_smartreply_get_nth_item(index);
451 /* Set hightlight color on first 3 smartreply items */
453 char *colored = _genlist_text_set_theme_color(reply, "AT0113");
455 if (colored == NULL) {
468 static char * __ise_template_gl_text_get(void *data, Evas_Object *obj, const char *part)
470 if(!strcmp(part, "elm.text")) {
471 unsigned int index = (unsigned int)data;
472 const std::vector<TemplateData> template_list = input_template_get_list();
474 if(index < template_list.size()) {
475 if(template_list[index].use_gettext) {
476 return strdup(gettext(template_list[index].text.c_str()));
478 Eina_Strbuf *buf = NULL;
479 const char *str = NULL;
482 buf = eina_strbuf_new();
484 eina_strbuf_append(buf, template_list[index].text.c_str());
485 eina_strbuf_replace_all(buf, "\n", "");
486 eina_strbuf_replace_all(buf, "\r", "");
488 str = eina_strbuf_string_get(buf);
491 markup = elm_entry_utf8_to_markup(str);
493 eina_strbuf_free(buf);
503 static char * __ise_addtemplate_gl_text_get(void *data, Evas_Object *obj, const char *part)
505 if(!strcmp(part, "elm.text")) {
506 return(strdup(gettext("WDS_IME_MBODY_ADD_TEMPLATE_ABB")));
511 static Evas_Object * __ise_gl_1button_content_get(void *data, Evas_Object *obj, const char *part)
513 if (!strcmp(part, "elm.icon")) {
514 Evas_Object* btn = elm_button_add(obj);
515 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
516 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
517 Evas_Object* ic = elm_image_add(btn);
518 elm_image_resizable_set(ic, EINA_TRUE, EINA_TRUE);
519 string path = get_resource_path();
520 elm_object_style_set(btn, "ime_button_template");
521 string path_ic = path + "/images/w_list_add_ic.png";
522 elm_image_file_set(ic, path_ic.c_str(), NULL);
523 elm_object_content_set(btn, ic);
524 evas_object_layer_set(btn, 32000);
525 if (elm_config_access_get())
526 elm_access_object_unregister(btn);
533 static void __ise_gl_lang_changed(void *data, Evas_Object *obj, void *event_info)
535 //Update genlist items. The Item texts will be translated in the _gl_text_get().
536 elm_genlist_realized_items_update(obj);
539 static int _app_control_request_transient_app_cb(void *data)
545 static char *_genlist_text_set_theme_color(const char *str, const char *code)
548 Eina_Strbuf *buf = NULL;
549 char *colored = NULL;
554 buf = eina_strbuf_new();
556 PRINTFUNC(DLOG_ERROR, "Can not get create strbuf");
560 // ea_theme_color_get(code,
562 // NULL, NULL, NULL, NULL,
563 // NULL, NULL, NULL, NULL);
565 eina_strbuf_append_printf(buf, "<color=#%02x%02x%02x%02x>%s</color>",
568 colored = eina_strbuf_string_steal(buf);
570 eina_strbuf_free(buf);
576 static void _app_control_send_reply_cb(app_control_h request, app_control_h reply,
577 app_control_result_e result, void *user_data)
579 PRINTFUNC(DLOG_DEBUG, "");
580 reply_to_sender_by_callback(NULL, NULL);
584 void set_source_caller_app_id(app_control_h app_control)
587 PRINTFUNC(DLOG_ERROR, "can't get app_control");
591 // CscFeatureBool is_security_permission_manager = CSC_FEATURE_BOOL_FALSE;
592 // is_security_permission_manager = csc_feature_get_bool(CSC_FEATURE_DEF_BOOL_SECURITY_PERMISSION_MANAGER);
594 // if(is_security_permission_manager == CSC_FEATURE_BOOL_TRUE){
597 app_control_get_caller(app_data->source_app_control, &caller);
600 PRINTFUNC(DLOG_DEBUG, "caller = %s", caller);
601 app_control_add_extra_data(app_control, "caller_appid", caller);
607 void reply_to_sender_by_appcontrol(void *data, const char *value, const char *type)
609 PRINTFUNC(DLOG_DEBUG, "");
614 app_control_h app_control;
616 App_Data *appdata = (App_Data *)data;
619 PRINTFUNC(DLOG_ERROR, "Null pointer");
623 ret = app_control_create(&app_control);
624 if (ret != APP_CONTROL_ERROR_NONE) {
625 PRINTFUNC(DLOG_ERROR, "Can not create app_control : %d", ret);
629 app_id = g_input_keyboard_data.app_id;
630 if (app_id == NULL) {
631 PRINTFUNC(DLOG_INFO, "app id is undefined, use defualt");
632 app_id = "com.samsung.message.appcontrol.compose";
635 if(!strcmp(app_id, "com.samsung.message.appcontrol.compose")){
636 app_id = "com.samsung.msg-send";
639 app_control_set_app_id(app_control, app_id);
640 app_control_set_operation(app_control, APP_CONTROL_OPERATION_DEFAULT);
642 ret = app_control_set_window(app_control,
643 elm_win_xwindow_get(appdata->win_main));
644 if (ret != APP_CONTROL_ERROR_NONE) {
645 PRINTFUNC(DLOG_ERROR, "Can not app control set window : %d", ret);
646 app_control_destroy(app_control);
650 if (g_input_keyboard_data.data_array && g_input_keyboard_data.data_array_len > 0) {
651 app_control_add_extra_data_array(app_control,
652 "selector_keyboard_data_array",
653 (const char**)(g_input_keyboard_data.data_array),
654 g_input_keyboard_data.data_array_len);
657 app_control_add_extra_data(app_control, "selector_send_data_array", "sending_popup");
660 app_control_add_extra_data(app_control, "selected_context", value);
663 app_control_add_extra_data(app_control, "reply_type", type);
665 set_source_caller_app_id(app_control);
667 ret = app_control_send_launch_request(app_control,
668 _app_control_send_reply_cb,
671 if (ret != APP_CONTROL_ERROR_NONE)
672 PRINTFUNC(DLOG_ERROR, "Can not launch app_control: %d", ret);
674 app_control_destroy(app_control);
679 void reply_to_sender_by_callback(const char *value, const char *type)
681 PRINTFUNC(DLOG_DEBUG, "");
683 app_control_h app_control;
685 if(app_control_create(&app_control) == 0) {
689 app_control_add_extra_data(app_control, "selected_context", value);
692 app_control_add_extra_data(app_control, "reply_type", type);
694 set_source_caller_app_id(app_control);
696 ret = app_control_reply_to_launch_request(app_control, app_data->source_app_control, APP_CONTROL_RESULT_SUCCEEDED);
697 if (ret != APP_CONTROL_ERROR_NONE)
698 PRINTFUNC(DLOG_ERROR, "reply failed : %d", ret);
700 app_control_destroy(app_control);
701 app_control_destroy(app_data->source_app_control);
702 app_data->source_app_control = NULL;
706 void reply_to_sender_by_callback_for_back()
708 PRINTFUNC(DLOG_DEBUG, "");
710 app_control_h app_control;
712 if(app_control_create(&app_control) == 0) {
715 app_control_add_extra_data(app_control, "back_to_composer", "yes");
717 ret = app_control_reply_to_launch_request(app_control, app_data->source_app_control, APP_CONTROL_RESULT_SUCCEEDED);
718 if (ret != APP_CONTROL_ERROR_NONE)
719 PRINTFUNC(DLOG_ERROR, "reply failed : %d", ret);
721 app_control_destroy(app_control);
722 app_control_destroy(app_data->source_app_control);
723 app_data->source_app_control = NULL;
727 char* get_resource_path()
729 if(NULL == app_data->res_path) {
730 app_data->res_path = app_get_resource_path();
731 PRINTFUNC(DLOG_INFO, "set resource path = %s", app_data->res_path);
733 return (app_data->res_path);
736 char* get_shared_resource_path()
738 if(NULL == app_data->shared_res_path) {
739 app_data->shared_res_path = app_get_shared_resource_path();
740 PRINTFUNC(DLOG_INFO, "set shared resource path = %s", app_data->shared_res_path);
742 return (app_data->shared_res_path);
745 void show_gl_focus(Eina_Bool bVisible){
746 if(app_data->genlist == NULL)
749 if(bVisible == EINA_TRUE){
750 elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,enable", "elm");
751 //elm_layout_theme_set(app_data->genlist, "genlist", "base", "focus_bg");
752 //elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,show", "elm");
754 elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,disable", "elm");
755 //elm_layout_theme_set(app_data->genlist, "genlist", "base", "default");
756 //elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,hide", "elm");
760 void show_popup_toast(const char *text, bool check_img)
762 PRINTFUNC(DLOG_ERROR, "show_popup_toast");
766 popup = elm_popup_add(app_data->win_main);
767 elm_object_style_set(popup, "toast/circle");
768 elm_popup_orient_set(popup, ELM_POPUP_ORIENT_BOTTOM);
769 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
772 string path = get_resource_path();
773 string path_ic = path + "/images/toast_check_icon.png";
774 Evas_Object * img = elm_image_add(popup);
775 elm_image_file_set(img, path_ic.c_str(), NULL);
776 elm_object_part_content_set(popup, "toast,icon", img);
779 elm_object_part_text_set(popup, "elm.text", text);
782 eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, _popup_back_cb, NULL);
783 evas_object_smart_callback_add(popup, "dismissed", _popup_close_cb, NULL);
784 evas_object_smart_callback_add(popup, "block,clicked", _popup_back_cb, NULL);
786 if(elm_config_access_get() == EINA_FALSE) {
787 elm_popup_timeout_set(popup, 2.0);
789 elm_object_access_info_set(popup, text);
790 // Evas_Object *ao = elm_object_part_access_object_get(popup, "access.outline");
791 // elm_access_info_cb_set(ao, ELM_ACCESS_INFO, _toast_delete_popup_access_info_cb, popup);
792 elm_popup_timeout_set(popup, 8.0);
795 evas_object_show(popup);
798 static void _popup_close_cb(void *data, Evas_Object *obj, void *event_info)
801 evas_object_hide(obj);
802 evas_object_del(obj);
806 static void _popup_back_cb(void *data, Evas_Object *obj, void *event_info)
809 elm_popup_dismiss(obj);
812 char * _toast_delete_popup_access_info_cb(void *data, Evas_Object *obj)
814 PRINTFUNC(DLOG_ERROR, "%s", __func__);
815 const char * info = elm_object_part_text_get((Evas_Object*)data, "elm.text");
821 void _back_to_genlist_for_selector()
823 PRINTFUNC(DLOG_DEBUG, "");
825 if(!app_data) return;
827 if(app_data->app_type == APP_TYPE_STT || app_data->app_type == APP_TYPE_EMOTICON){
828 PRINTFUNC(DLOG_DEBUG, "launched as STT/EMOTICON mode, So exit here.");
829 reply_to_sender_by_callback(NULL, NULL);
833 Evas_Object *circle_genlist = (Evas_Object *) evas_object_data_get(app_data->genlist, "circle");
835 eext_rotary_object_event_activated_set(circle_genlist, EINA_TRUE);
839 char *_it_plus_access_info_cb(void *data, Evas_Object *obj)
841 PRINTFUNC(DLOG_DEBUG, "%s", __func__);
842 std::string text = std::string(gettext("IDS_ACCS_BODY_BUTTON_TTS"));
844 return strdup(text.c_str());
847 char *_access_info_cb(void *data, Evas_Object *obj)
849 PRINTFUNC(DLOG_DEBUG, "%s", __func__);
850 return strdup(gettext("WDS_TTS_TBBODY_DOUBLE_TAP_TO_SEND"));
853 Eina_Bool _access_action_next_cb(void *data, Evas_Object *obj, Elm_Access_Action_Info *action_info)
855 Evas_Object *genlist = (Evas_Object*)data;
856 PRINTFUNC(DLOG_ERROR, "[TNT] _access_action_next_cb called, genlist type:%s", evas_object_type_get(genlist));
857 Elm_Object_Item *it = elm_genlist_first_item_get(genlist);//emptry item?
858 PRINTFUNC(DLOG_ERROR, "[TNT] get first item:%p", it);
859 it = elm_genlist_item_next_get(it);//title item(3 button?)
860 PRINTFUNC(DLOG_ERROR, "[TNT] get Second item:%p, title_item:%p", it, it_title);
861 elm_genlist_item_show(it, ELM_GENLIST_ITEM_SCROLLTO_IN);
862 force_highlight_to_top = EINA_TRUE;
866 Eina_Bool _access_action_prev_cb(void *data, Evas_Object *obj, Elm_Access_Action_Info *action_info)
868 Evas_Object *genlist = (Evas_Object*)data;
869 PRINTFUNC(DLOG_ERROR, "[TNT] _access_action_prev_cb called, genlist type:%s", evas_object_type_get(genlist));
870 Elm_Object_Item *it = elm_genlist_last_item_get(genlist);//plus button item
871 PRINTFUNC(DLOG_ERROR, "[TNT] get last item:%p", it);
872 elm_genlist_item_show(it, ELM_GENLIST_ITEM_SCROLLTO_IN);
873 force_highlight_to_bottom = EINA_TRUE;
877 static void _item_realized(void *data, Evas_Object *obj, void *event_info) //called when list scrolled
879 PRINTFUNC(DLOG_DEBUG, "%s", __func__);
880 if (elm_config_access_get()) {
881 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
882 Evas_Object *item_access = elm_object_item_access_object_get(item);
884 if (item == it_empty || item == it_title) {
885 elm_access_object_unregister(item_access);
886 if (item == it_title)
888 Evas_Object *btn = elm_object_item_part_content_get(item, "elm.icon.1.touch_area");
889 PRINTFUNC(DLOG_ERROR, "[TNT] 1st button(%p), type:%s", btn, evas_object_type_get(btn));
890 Evas_Object *btn_access = btn;//elm_access_object_get(btn);
891 PRINTFUNC(DLOG_ERROR, "[TNT] title item realized!!!!, force_highlight_to_top:%d, is_genlist_highlighed:%d", force_highlight_to_top, is_genlist_highlighed);
892 if (force_highlight_to_top || !is_genlist_highlighed)
894 //highlight to first button.
895 PRINTFUNC(DLOG_ERROR, "[TNT] force highlight to 1st button(%p), acces_obj:%p", btn, btn_access);
896 elm_access_highlight_set(btn_access);
897 force_highlight_to_top = EINA_FALSE;
898 is_genlist_highlighed = EINA_TRUE;
900 PRINTFUNC(DLOG_ERROR, "[TNT] set highlight pre callback on btn");
901 elm_access_action_cb_set(btn_access, ELM_ACCESS_ACTION_HIGHLIGHT_PREV, _access_action_prev_cb, obj);
903 } else if (item == it_plus) {
904 //elm_access_object_unregister(item_access); // there is no guide line
905 elm_access_info_cb_set(item_access, ELM_ACCESS_CONTEXT_INFO, _it_plus_access_info_cb, NULL);
906 PRINTFUNC(DLOG_ERROR, "[TNT] set highlight next callback on plus item");
907 elm_access_action_cb_set(item_access, ELM_ACCESS_ACTION_HIGHLIGHT_NEXT, _access_action_next_cb, obj);
908 if (force_highlight_to_bottom) {
909 PRINTFUNC(DLOG_ERROR, "[TNT] Forcely set highlight on plus item!!");
910 elm_access_highlight_set(item_access);
911 force_highlight_to_bottom = EINA_FALSE;
912 is_genlist_highlighed = EINA_TRUE;
915 elm_access_info_cb_set(item_access, ELM_ACCESS_CONTEXT_INFO, _access_info_cb, NULL);
920 Evas_Object* _create_genlist(Evas_Object* navi)
922 Evas_Object* genlist = elm_genlist_add(navi);
926 elm_genlist_scroller_policy_set(genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
928 Evas_Object* circle_object_genlist = eext_circle_object_genlist_add(genlist, app_data->circle_surface);
929 eext_circle_object_genlist_scroller_policy_set(circle_object_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
930 evas_object_data_set(genlist, "circle", (void *) circle_object_genlist);
931 eext_rotary_object_event_activated_set(circle_object_genlist, EINA_TRUE);
933 evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
934 evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
936 evas_object_smart_callback_add(genlist, "language,changed", __ise_gl_lang_changed, genlist);
937 evas_object_show(genlist);
939 // uxt_genlist_set_bottom_margin_enabled(genlist, EINA_TRUE);
941 show_gl_focus(EINA_FALSE);
943 Elm_Object_Item *nf_main_item = elm_naviframe_item_push(navi,
950 elm_naviframe_item_pop_cb_set(nf_main_item, back_cb, app_data);
951 evas_object_smart_callback_add(genlist, "realized", _item_realized, NULL);
956 static void _item_position_changed_cb(void *data, Evas_Object *obj, void *event_info)
961 Evas_Object *genlist = (Evas_Object *)obj;
962 Elm_Object_Item *gen_item = (Elm_Object_Item *)data;
965 elm_scroller_region_get(genlist, NULL, &y, NULL, NULL);
967 // PRINTFUNC(DLOG_DEBUG,"y=%d",y);
969 if (250 > y && y >= 100){
970 if (last_step == 0) return;
972 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.0", "elm");
973 show_gl_focus(EINA_TRUE);
974 } else if (100 > y && y >= 50){
975 if (last_step == 1) return;
977 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.1", "elm");
978 show_gl_focus(EINA_TRUE);
979 } else if (y < 50 && y >=0){
980 if (last_step == 2) return;
982 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.9", "elm");
983 show_gl_focus(EINA_FALSE);
988 _main_menu_title_text_get(void *data, Evas_Object *obj, const char *part)
992 snprintf(buf, 1023, "%s", "Select method");
996 void _create_genlist_items(void* user_data, bool is_type_reply)
998 LOGD("[psw] _create_genlist_items");
1000 App_Data* app_data = (App_Data*) user_data;
1002 if(NULL == app_data->genlist) {
1003 app_data->genlist = _create_genlist(app_data->naviframe);
1004 if(NULL == app_data->genlist)
1008 elm_genlist_clear(app_data->genlist);
1009 g_smartreply_current_number = 0; /* reset previous smartreply size to 0 */
1011 Elm_Genlist_Item_Class * itc0 = elm_genlist_item_class_new();
1012 itc0->item_style = "title";
1013 itc0->func.text_get = _main_menu_title_text_get;
1014 itc0->func.content_get = NULL;
1015 itc0->func.state_get = NULL;
1016 itc0->func.del = NULL;
1018 Elm_Genlist_Item_Class * itc1 = elm_genlist_item_class_new();
1019 itc1->item_style = "3button";
1020 itc1->func.text_get = NULL;
1021 itc1->func.content_get = __ise_gl_3button_content_get;
1022 itc1->func.state_get = NULL;
1023 itc1->func.del = NULL;
1026 // dummy title for empty space
1027 it_empty = elm_genlist_item_append(app_data->genlist, itc0,
1029 ELM_GENLIST_ITEM_NONE,
1032 if (!is_type_reply) {
1034 it_title = elm_genlist_item_append(app_data->genlist, itc1,
1036 ELM_GENLIST_ITEM_NONE,
1039 elm_genlist_item_select_mode_set(it_title, ELM_OBJECT_SELECT_MODE_NONE);
1041 if (input_smartreply_is_enabled() == false) {
1042 _update_template_items(app_data);
1043 if(g_template_current_number > 0) {
1044 Evas_Object *circle_genlist = (Evas_Object *) evas_object_data_get(app_data->genlist, "circle");
1045 eext_circle_object_genlist_scroller_policy_set(circle_genlist,
1046 ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
1049 // dummy title for bottom
1050 Elm_Object_Item *dummy;
1052 dummy = elm_genlist_item_append(app_data->genlist, itc0,
1054 ELM_GENLIST_ITEM_NONE,
1057 elm_genlist_item_select_mode_set(dummy, ELM_OBJECT_SELECT_MODE_NONE);
1061 Elm_Object_Item *item = elm_genlist_item_next_get(it_title);
1062 elm_genlist_item_show(item, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
1064 evas_object_smart_callback_add(app_data->genlist, "elm,item,position,changed", _item_position_changed_cb, it_title);
1066 elm_genlist_item_class_free(itc0);
1067 elm_genlist_item_class_free(itc1);
1070 void _update_genlist_items(void *user_data)
1074 if (input_smartreply_is_enabled())
1075 len = input_smartreply_get_reply_num();
1077 if (g_smartreply_current_number != len)
1078 _update_smartreply_items(user_data);
1080 _update_template_items(user_data);
1082 g_smartreply_current_number = len;
1084 if (g_smartreply_current_number > 0 || g_template_current_number > 0) {
1085 Evas_Object *circle_genlist = (Evas_Object *) evas_object_data_get(app_data->genlist, "circle");
1086 eext_circle_object_genlist_scroller_policy_set(circle_genlist,
1087 ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
1091 void _update_smartreply_items(void *user_data)
1095 Elm_Object_Item *first;
1096 Elm_Object_Item *menu;
1097 Elm_Object_Item *pos;
1102 app_data = (App_Data *)user_data;
1104 if (app_data == NULL) {
1105 PRINTFUNC(DLOG_ERROR, "Can not get app_data");
1109 if (app_data->genlist == NULL) {
1110 /* smartreply will update when genlist is exist only */
1111 PRINTFUNC(DLOG_ERROR, "Can not get getlist");
1115 if (input_smartreply_is_enabled())
1116 len = input_smartreply_get_reply_num();
1118 if (g_smartreply_current_number == len)
1121 first = elm_genlist_first_item_get(app_data->genlist);
1122 menu = elm_genlist_item_next_get(first);
1124 /* Remove current smartreply list */
1125 pos = elm_genlist_item_next_get(menu);
1126 for (i = 0; i < g_smartreply_current_number; i++) {
1127 Elm_Object_Item *next;
1132 next = elm_genlist_item_next_get(pos);
1133 elm_object_item_del(pos);
1137 /* Append newly added smartreply list */
1139 Elm_Genlist_Item_Class *itc;
1141 itc = elm_genlist_item_class_new();
1143 itc->item_style = "1text";
1144 itc->func.text_get = __ise_smartreply_gl_text_get;
1145 itc->func.content_get = NULL;
1146 itc->func.state_get = NULL;
1147 itc->func.del = NULL;
1150 for (i = 0; i < len; i++) {
1151 pos = elm_genlist_item_insert_after(app_data->genlist,
1156 ELM_GENLIST_ITEM_NONE,
1157 __ise_smartreply_gl_sel,
1162 elm_genlist_item_show(menu, ELM_GENLIST_ITEM_SCROLLTO_TOP);
1164 elm_genlist_item_class_free(itc);
1167 g_smartreply_current_number = len;
1171 void _update_template_items(void *user_data)
1175 Elm_Object_Item *first;
1176 Elm_Object_Item *menu;
1177 Elm_Object_Item *pos;
1178 Elm_Object_Item *template_pos;
1180 unsigned int template_len = 0;
1183 app_data = (App_Data *)user_data;
1185 if (app_data == NULL) {
1186 PRINTFUNC(DLOG_ERROR, "Can not get app_data");
1190 if (app_data->genlist == NULL) {
1191 /* smartreply will update when genlist is exist only */
1192 PRINTFUNC(DLOG_ERROR, "Can not get getlist");
1196 if (app_data->app_type == APP_TYPE_REPLY) {
1197 menu = elm_genlist_first_item_get(app_data->genlist);
1199 first = elm_genlist_first_item_get(app_data->genlist);
1200 menu = elm_genlist_item_next_get(first);
1204 /* move to smartreply next if it need */
1205 if (input_smartreply_is_enabled()) {
1206 int smartreply_len = 0;
1208 smartreply_len = input_smartreply_get_reply_num();
1209 if (smartreply_len > 0) {
1212 for (j = 0; j < smartreply_len; j++) {
1216 pos = elm_genlist_item_next_get(pos);
1221 /* Remove Current template list */
1222 template_pos = elm_genlist_item_next_get(pos);
1223 for (i = 0 ; i < g_template_current_number; i++) {
1224 Elm_Object_Item *next;
1226 if (template_pos == NULL) {
1227 PRINTFUNC(DLOG_ERROR, "Template mismatched, iter : %d, current num: %d",
1228 i, g_template_current_number);
1232 next = elm_genlist_item_next_get(template_pos);
1233 elm_object_item_del(template_pos);
1234 template_pos = next;
1237 /* Remove Add or dummpy button */
1239 Elm_Object_Item *next;
1241 next = elm_genlist_item_next_get(template_pos);
1242 elm_object_item_del(template_pos);
1243 template_pos = next;
1246 /* Append New Template list */
1247 const std::vector<TemplateData> template_list = input_template_get_list();
1250 if (template_list.size() > 0) {
1251 Elm_Genlist_Item_Class *itc;
1253 itc = elm_genlist_item_class_new();
1255 itc->item_style = "1text";
1256 itc->func.text_get = __ise_template_gl_text_get;
1257 itc->func.content_get = NULL;
1258 itc->func.state_get = NULL;
1259 itc->func.del = NULL;
1261 for (i = 0; i < template_list.size(); i++) {
1262 bool matched = false;
1264 if(!template_list[i].use_gettext) {
1265 int smartreply_len = 0;
1268 smartreply_len = input_smartreply_get_reply_num();
1269 for (j = 0; j < smartreply_len; j++) {
1272 reply = input_smartreply_get_nth_item(j);
1274 if (!strcmp(reply, template_list[i].text.c_str())) {
1284 if (matched == false) {
1285 pos = elm_genlist_item_insert_after(app_data->genlist,
1290 ELM_GENLIST_ITEM_NONE,
1291 __ise_template_gl_sel,
1297 elm_genlist_item_class_free(itc);
1301 // template add button (+)
1302 /* if (!input_template_is_user_template()) {
1303 Elm_Genlist_Item_Class *itc;
1305 itc = elm_genlist_item_class_new();
1307 itc->item_style = "1text.1icon";
1308 itc->func.text_get = __ise_addtemplate_gl_text_get;;
1309 itc->func.content_get = __ise_gl_1button_content_get;
1310 itc->func.state_get = NULL;
1311 itc->func.del = NULL;
1314 pos = elm_genlist_item_insert_after(app_data->genlist,
1319 ELM_GENLIST_ITEM_NONE,
1320 __ise_template_add_gl_sel,
1323 elm_genlist_item_class_free(itc);
1327 elm_genlist_item_show(menu, ELM_GENLIST_ITEM_SCROLLTO_TOP);
1329 g_template_current_number = template_len;
1333 bool _app_create(void* user_data)
1335 int width = 1000, height = 1000;
1336 // App_Data* app_data = NULL;
1337 Evas_Object* layout = NULL;
1338 Evas_Object* conform = NULL;
1339 Evas_Object* bg = NULL;
1340 Evas_Object* window = NULL;
1341 Eext_Circle_Surface *surface;
1347 _app_language_changed(NULL, NULL);
1348 #ifdef SUPPORT_LOG_MANAGER
1352 app_data = (App_Data*)user_data;
1354 elm_app_base_scale_set(1.3);
1356 window = elm_win_add(NULL, PACKAGE, ELM_WIN_BASIC);
1358 init_customizing_theme();
1360 elm_win_title_set(window, PACKAGE);
1361 elm_win_borderless_set(window, EINA_TRUE);
1362 // ecore_x_window_size_get(ecore_x_window_root_first_get(), &width, &height);
1363 evas_object_resize(window, width, height);
1364 elm_win_indicator_mode_set(window, ELM_WIN_INDICATOR_SHOW);
1366 LOGE("elm_win_add() is failed.");
1370 bg = elm_bg_add(window);
1371 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1372 elm_win_resize_object_add(window, bg);
1373 evas_object_show(bg);
1375 layout = elm_layout_add(window);
1376 elm_layout_theme_set(layout, "layout", "application", "default");
1377 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1379 conform = elm_conformant_add(window);
1380 surface = eext_circle_surface_conformant_add(conform);
1381 evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1384 elm_win_resize_object_add(window, conform);
1385 elm_object_content_set(conform, layout);
1387 evas_object_show(layout);
1388 evas_object_show(conform);
1389 evas_object_show(window);
1390 app_data->win_main = window;
1391 app_data->conform = conform;
1392 app_data->layout_main = layout;
1393 app_data->circle_surface = surface;
1394 app_data->app_type = APP_TYPE_SELECT_MODE;
1396 Evas_Object *naviframe = elm_naviframe_add(layout);
1397 elm_naviframe_prev_btn_auto_pushed_set(naviframe, EINA_FALSE);
1398 eext_object_event_callback_add(naviframe, EEXT_CALLBACK_BACK, eext_naviframe_back_cb, NULL);
1399 elm_object_part_content_set(layout, "elm.swallow.content", naviframe);
1400 evas_object_show(naviframe);
1402 app_data->naviframe = naviframe;
1407 void _app_service(app_control_h service, void* user_data)
1411 char *context = NULL;
1412 char *app_id = NULL;
1414 app_control_clone(&(app_data->source_app_control), service);
1416 app_data->reply_type = REPLY_APP_NORMAL;
1417 ret = app_control_get_extra_data(service, "selector_keyboard_app_id", &app_id);
1418 if (ret == APP_CONTROL_ERROR_NONE) {
1419 PRINTFUNC(DLOG_DEBUG, "app_id = %s", app_id);
1423 if(!strcmp(app_id, "com.samsung.message.appcontrol.compose") || !strcmp(app_id, "com.samsung.wemail-send")) {
1424 app_data->reply_type = REPLY_APP_CONTROL;
1426 app_data->reply_type = REPLY_APP_NORMAL;
1432 bool is_type_reply = false;
1433 ret = app_control_get_extra_data(service, APP_CONTROL_DATA_INPUT_TYPE, &context);
1434 if (ret == APP_CONTROL_ERROR_NONE) {
1435 if (!strcmp(context, "input_voice")) {
1436 app_data->app_type = APP_TYPE_STT;
1437 _stt_clicked_cb((void *)app_data, NULL, NULL);
1439 } else if (!strcmp(context, "input_emoticon")) {
1440 app_data->app_type = APP_TYPE_EMOTICON;
1441 _emoticon_clicked_cb((void *)app_data, NULL, NULL);
1443 } else if (!strcmp(context, "input_keyboard")) {
1444 app_data->app_type = APP_TYPE_KEYBOARD;
1445 input_keyboard_init(service);
1446 _keyboard_clicked_cb((void *)app_data, NULL, NULL);
1448 } else if (!strcmp(context, "keyboard_input_from_sms")) {
1449 app_data->app_type = APP_TYPE_KEYBOARD_FROM_SMS;
1450 input_keyboard_init(service);
1451 _keyboard_clicked_cb((void *)app_data, NULL, NULL);
1453 } else if (!strcmp(context, "input_reply")) {
1454 app_data->app_type = APP_TYPE_REPLY;
1455 is_type_reply = true;
1459 if (app_data->genlist == NULL)
1460 app_data->genlist = _create_genlist(app_data->naviframe);
1462 input_keyboard_init(service);
1464 // input_smartreply_init(service);
1465 // input_smartreply_set_notify(_input_smartreply_notify_cb, NULL);
1467 // if (input_smartreply_is_enabled())
1468 // input_smartreply_get_reply_async();
1471 input_template_init(service);
1472 input_template_set_notify(_input_template_notify_cb, NULL);
1474 _create_genlist_items(app_data, is_type_reply);
1477 elm_win_activate(app_data->win_main);
1479 // app_control_request_transient_app(service, elm_win_xwindow_get(app_data->win_main), _app_control_request_transient_app_cb, NULL);
1485 void _app_pause(void* user_data)
1487 PRINTFUNC(DLOG_DEBUG, "");
1491 void _app_resume(void* user_data)
1493 PRINTFUNC(DLOG_DEBUG, "");
1496 void _app_terminate(void* user_data)
1498 App_Data* app_data = NULL;
1499 app_data = (App_Data*)user_data;
1501 if(app_data->genlist){
1502 evas_object_smart_callback_del(app_data->genlist, "elm,item,position,changed", _item_position_changed_cb);
1505 if(app_data->res_path)
1506 free(app_data->res_path);
1508 if(app_data->shared_res_path)
1509 free(app_data->shared_res_path);
1511 input_keyboard_deinit();
1512 input_smartreply_deinit();
1514 input_template_unset_notify();
1515 input_template_deinit();
1517 #ifdef SUPPORT_LOG_MANAGER
1522 static int init_i18n(const char *domain, const char *dir, char *lang_str)
1524 if (setlocale(LC_ALL, "") == NULL) {
1525 PRINTFUNC(DLOG_INFO, "Some environment variable is invalid, setlocale(LC_ALL, \"\") has returns\ed a null pointer");
1526 if (setlocale(LC_ALL, lang_str) == NULL)
1529 if (bindtextdomain(domain, dir) == NULL)
1531 if (textdomain(domain) == NULL)
1538 * @brief Set language and locale.
1542 static void _app_language_changed(app_event_info_h event_info, void *user_data)
1544 char* lang_str = vconf_get_str(VCONFKEY_LANGSET);
1546 setenv("LANG", lang_str, 1);
1547 setenv("LC_MESSAGES", lang_str, 1);
1549 setenv("LANG", "en_GB.utf8", 1);
1550 setenv("LC_MESSAGES", "en_GB.utf8", 1);
1551 lang_str = strdup("en_GB.UTF-8");
1554 init_i18n(PACKAGE, LOCALEDIR, lang_str);
1557 elm_language_set(lang_str);
1564 int main(int argc, char* argv[])
1566 App_Data app_data = {0, };
1567 ui_app_lifecycle_callback_s event_callback = {0, };
1568 app_event_handler_h handlers[5] = {NULL, };
1570 event_callback.create = _app_create;
1571 event_callback.terminate = _app_terminate;
1572 event_callback.pause = _app_pause;
1573 event_callback.resume = _app_resume;
1574 event_callback.app_control = _app_service;
1576 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, NULL, &app_data);
1577 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, NULL, &app_data);
1578 ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, NULL, &app_data);
1579 ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, _app_language_changed, &app_data);
1580 ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, NULL, &app_data);
1582 _init_app_data(&app_data);
1584 int ret = ui_app_main(argc, argv, &event_callback, &app_data);
1585 if (ret != APP_ERROR_NONE) {
1586 LOGD("ui_app_main() is failed. err = %d", ret);
1592 #ifdef SUPPORT_LOG_MANAGER
1593 static void log_manager_init(void)
1598 samsung_log_manager_create(&g_log_manager);
1601 static void log_manager_exit(void)
1603 samsung_log_manager_destroy(g_log_manager);
1604 g_log_manager = NULL;
1607 static void log_manager_set(const char *feature, const char *extra, const char *value)
1609 const char *uri = USE_APP_FEATURE_SURVEY_URI;
1611 unsigned int request_id;
1614 if (g_log_manager == NULL) {
1615 PRINTFUNC(DLOG_ERROR, "log manager doesn't initialized");
1619 if (feature == NULL) {
1620 PRINTFUNC(DLOG_ERROR, "feature is empty");
1624 log_data = bundle_create();
1626 bundle_add(log_data, "app_id", PACKAGE);
1627 bundle_add(log_data, "feature", feature);
1630 bundle_add(log_data, "extra", extra);
1632 bundle_add(log_data, "value", value);
1634 samsung_log_manager_insert(g_log_manager, uri, log_data, NULL, NULL, &request_id);
1636 bundle_free(log_data);