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 "ui_extension.h"
27 #include "w-input-selector.h"
28 #include "w-input-keyboard.h"
29 #include "w-input-stt-ise.h"
30 #include "w-input-emoticon.h"
31 #include "w-input-stt-tos.h"
38 App_Data* app_data = NULL;
40 InputKeyboardData g_input_keyboard_data;
41 InputTypeData g_input_type_data;
43 static Elm_Object_Item *it_empty;
44 static Elm_Object_Item *it_title;
46 Evas_Coord last_step; // 0 ~ 9 for gesture, 10~11 for rotary
48 void _init_app_data(App_Data* app_data);
49 static void _app_language_changed(app_event_info_h event_info, void *user_data);
51 Evas_Object* _create_genlist(Evas_Object* parent);
52 void _create_genlist_items(void* user_data);
53 static void _popup_close_cb(void *data, Evas_Object *obj, void *event_info);
54 static void _popup_back_cb(void *data, Evas_Object *obj, void *event_info);
55 static void input_type_deinit(void);
59 void _init_app_data(App_Data* app_data)
61 app_data->win_main = NULL;
62 app_data->layout_main = NULL;
63 app_data->conform = NULL;
64 app_data->naviframe = NULL;
65 app_data->genlist = NULL;
67 app_data->res_path = NULL;
72 Evas_Object* load_edj(Evas_Object* parent, const char* file, const char* group)
78 window = elm_layout_add(parent);
80 ret = elm_layout_file_set(window, file, group);
82 evas_object_del(window);
86 content = elm_layout_add(parent);
87 elm_layout_theme_set(content, "layout", "application", "default");
88 elm_object_part_content_set(window, "elm.swallow.content", content);
90 evas_object_size_hint_weight_set(window, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
96 void init_customizing_theme(void)
98 string stt_edj_path = get_resource_path();
99 string app_edj_path = get_resource_path();
101 stt_edj_path = stt_edj_path + STT_EDJ_FILE;
102 app_edj_path = app_edj_path + APP_EDJ_FILE;
104 elm_theme_extension_add(NULL, stt_edj_path.c_str());
105 elm_theme_extension_add(NULL, app_edj_path.c_str());
109 static Eina_Bool back_cb(void *data, Elm_Object_Item *it)
111 reply_to_sender_by_callback_for_back();
116 static void _stt_clicked_cb(void *data, Evas_Object * obj, void *event_info)
118 App_Data* ad = (App_Data*)data;
120 PRINTFUNC(DLOG_DEBUG, "");
126 bool bAgreed = false;
127 stt_get_user_agreement(&bAgreed);
130 if(is_tos_N66_agreed() == EINA_FALSE){
131 if(is_sap_connection() == EINA_TRUE){
132 ise_show_tos_n66_popup(ad);
134 launch_bt_connection_popup(ad);
137 ise_show_stt_popup(ad);
141 static void _emoticon_clicked_cb(void *data, Evas_Object * obj, void *event_info)
143 App_Data* ad = (App_Data*)data;
145 PRINTFUNC(DLOG_DEBUG, "");
150 ise_show_emoticon_list(ad);
153 static void _keyboard_clicked_cb(void *data, Evas_Object * obj, void *event_info)
155 App_Data* ad = (App_Data *)data;
157 PRINTFUNC(DLOG_DEBUG, "");
162 input_keyboard_launch(ad->win_main, data);
165 static Evas_Object * __ise_gl_2button_content_get(void *data, Evas_Object *obj, const char *part)
167 char *first_input_type = *(g_input_type_data.input_type_array + 0);
168 char *second_input_type = *(g_input_type_data.input_type_array + 1);
170 if (!strcmp(part, "elm.icon.1") || (!strcmp(part, "elm.icon.2"))) {
171 Evas_Object* btn = elm_button_add(obj);
172 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
173 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
175 Evas_Object* ic = elm_image_add(btn);
176 elm_image_resizable_set(ic, EINA_TRUE, EINA_TRUE);
177 string path = get_resource_path();
178 if (!strcmp(part, "elm.icon.1")) {
180 if(!strcmp(first_input_type, "input_voice")) {
181 elm_object_style_set(btn, "ime_button_stt");
182 path_ic = path + "images/w_mode_stt_ic.png";
183 } else if (!strcmp(first_input_type, "input_emoticon")) {
184 elm_object_style_set(btn, "ime_button_emoticon");
185 path_ic = path + "images/Delta_w_mode_emoticon_ic.png";
186 } else if (!strcmp(first_input_type, "input_keyboard")) {
187 elm_object_style_set(btn, "ime_button_keyboard");
188 path_ic = path + "images/w_mode_keyboard_ic.png";
189 evas_object_propagate_events_set(btn, EINA_FALSE);
191 elm_image_file_set(ic, path_ic.c_str(), NULL);
192 elm_object_content_set(btn, ic);
193 evas_object_layer_set(btn, 32000);
194 } else if (!strcmp(part, "elm.icon.2")){
196 if(!strcmp(second_input_type, "input_voice")) {
197 elm_object_style_set(btn, "ime_button_stt");
198 path_ic = path + "images/w_mode_stt_ic.png";
199 } else if (!strcmp(second_input_type, "input_emoticon")) {
200 elm_object_style_set(btn, "ime_button_emoticon");
201 path_ic = path + "images/Delta_w_mode_emoticon_ic.png";
202 } else if (!strcmp(second_input_type, "input_keyboard")) {
203 elm_object_style_set(btn, "ime_button_keyboard");
204 path_ic = path + "images/w_mode_keyboard_ic.png";
205 evas_object_propagate_events_set(btn, EINA_FALSE);
207 elm_image_file_set(ic, path_ic.c_str(), NULL);
208 elm_object_content_set(btn, ic);
209 evas_object_layer_set(btn, 32000);
212 } else if (!strcmp(part, "elm.icon.1.touch_area") || (!strcmp(part, "elm.icon.2.touch_area"))) {
213 Evas_Object* btn = elm_button_add(obj);
214 elm_object_style_set(btn, "touch_area");
215 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
216 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
217 string path = get_resource_path();
218 if (!strcmp(part, "elm.icon.1.touch_area")) {
219 evas_object_layer_set(btn, 32000);
220 if(!strcmp(first_input_type, "input_voice")) {
221 evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
222 } else if (!strcmp(first_input_type, "input_emoticon")) {
223 evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
224 } else if (!strcmp(first_input_type, "input_keyboard")) {
225 evas_object_propagate_events_set(btn, EINA_FALSE);
226 evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
228 } else if (!strcmp(part, "elm.icon.2.touch_area")){
229 evas_object_layer_set(btn, 32000);
230 if(!strcmp(second_input_type, "input_voice")) {
231 evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
232 } else if (!strcmp(second_input_type, "input_emoticon")) {
233 evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
234 } else if (!strcmp(second_input_type, "input_keyboard")) {
235 evas_object_propagate_events_set(btn, EINA_FALSE);
236 evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
240 } else if (!strcmp(part, "base")) {
241 Evas_Object* btn = elm_button_add(obj);
242 elm_object_style_set(btn, "ime_transparent");
248 static Evas_Object * __ise_gl_3button_content_get(void *data, Evas_Object *obj, const char *part)
250 if (!strcmp(part, "elm.icon.1") || (!strcmp(part, "elm.icon.2")) || (!strcmp(part, "elm.icon.3"))) {
251 Evas_Object* btn = elm_button_add(obj);
252 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
253 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
254 Evas_Object* ic = elm_image_add(btn);
255 elm_image_resizable_set(ic, EINA_TRUE, EINA_TRUE);
256 string path = get_resource_path();
257 if (!strcmp(part, "elm.icon.1")) {
258 elm_object_style_set(btn, "ime_button_stt");
259 string path_ic = path + "images/w_mode_stt_ic.png";
260 elm_image_file_set(ic, path_ic.c_str(), NULL);
261 elm_object_content_set(btn, ic);
262 evas_object_layer_set(btn, 32000);
264 } else if (!strcmp(part, "elm.icon.2")){
265 elm_object_style_set(btn, "ime_button_emoticon");
266 string path_ic = path + "images/Delta_w_mode_emoticon_ic.png";
267 elm_image_file_set(ic, path_ic.c_str(), NULL);
268 elm_object_content_set(btn, ic);
269 evas_object_layer_set(btn, 32000);
271 } else if (!strcmp(part, "elm.icon.3")){
272 elm_object_style_set(btn, "ime_button_keyboard");
273 string path_ic = path + "images/w_mode_keyboard_ic.png";
274 elm_image_file_set(ic, path_ic.c_str(), NULL);
275 elm_object_content_set(btn, ic);
276 evas_object_layer_set(btn, 32000);
277 evas_object_propagate_events_set(btn, EINA_FALSE);
281 } else if (!strcmp(part, "elm.icon.1.touch_area") || (!strcmp(part, "elm.icon.2.touch_area")) || (!strcmp(part, "elm.icon.3.touch_area"))) {
282 Evas_Object* btn = elm_button_add(obj);
283 elm_object_style_set(btn, "touch_area");
284 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
285 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
286 string path = get_resource_path();
287 if (!strcmp(part, "elm.icon.1.touch_area")) {
288 evas_object_layer_set(btn, 32000);
289 evas_object_smart_callback_add(btn, "clicked", _stt_clicked_cb, app_data);
291 } else if (!strcmp(part, "elm.icon.2.touch_area")){
292 evas_object_layer_set(btn, 32000);
293 evas_object_smart_callback_add(btn, "clicked", _emoticon_clicked_cb, app_data);
294 } else if (!strcmp(part, "elm.icon.3.touch_area")) {
295 evas_object_layer_set(btn, 32000);
296 evas_object_propagate_events_set(btn, EINA_FALSE);
297 evas_object_smart_callback_add(btn, "clicked", _keyboard_clicked_cb, app_data);
301 } else if (!strcmp(part, "base")) {
302 Evas_Object* btn = elm_button_add(obj);
303 elm_object_style_set(btn, "ime_transparent");
310 static void __ise_gl_lang_changed(void *data, Evas_Object *obj, void *event_info)
312 //Update genlist items. The Item texts will be translated in the _gl_text_get().
313 elm_genlist_realized_items_update(obj);
316 void set_source_caller_app_id(app_control_h app_control)
319 PRINTFUNC(DLOG_ERROR, "can't get app_control");
324 app_control_get_caller(app_data->source_app_control, &caller);
327 PRINTFUNC(DLOG_DEBUG, "caller = %s", caller);
328 app_control_add_extra_data(app_control, "caller_appid", caller);
333 void reply_to_sender_by_callback(const char *value, const char *type)
335 PRINTFUNC(DLOG_DEBUG, "");
337 app_control_h app_control;
339 if(app_control_create(&app_control) == 0) {
343 app_control_add_extra_data(app_control, APP_CONTROL_DATA_TEXT, value);
346 app_control_add_extra_data(app_control, "reply_type", type);
348 set_source_caller_app_id(app_control);
350 ret = app_control_reply_to_launch_request(app_control, app_data->source_app_control, APP_CONTROL_RESULT_SUCCEEDED);
351 if (ret != APP_CONTROL_ERROR_NONE)
352 PRINTFUNC(DLOG_ERROR, "reply failed : %d", ret);
354 app_control_destroy(app_control);
355 app_control_destroy(app_data->source_app_control);
356 app_data->source_app_control = NULL;
360 void reply_to_sender_by_callback_for_back()
362 PRINTFUNC(DLOG_DEBUG, "");
364 app_control_h app_control;
366 if(app_control_create(&app_control) == 0) {
369 app_control_add_extra_data(app_control, "back_to_composer", "yes");
371 ret = app_control_reply_to_launch_request(app_control, app_data->source_app_control, APP_CONTROL_RESULT_SUCCEEDED);
372 if (ret != APP_CONTROL_ERROR_NONE)
373 PRINTFUNC(DLOG_ERROR, "reply failed : %d", ret);
375 app_control_destroy(app_control);
376 app_control_destroy(app_data->source_app_control);
377 app_data->source_app_control = NULL;
381 char* get_resource_path()
383 if(NULL == app_data->res_path) {
384 app_data->res_path = app_get_resource_path();
385 PRINTFUNC(DLOG_INFO, "set resource path = %s", app_data->res_path);
387 return (app_data->res_path);
390 char* get_shared_resource_path()
392 if(NULL == app_data->shared_res_path) {
393 app_data->shared_res_path = app_get_shared_resource_path();
394 PRINTFUNC(DLOG_INFO, "set shared resource path = %s", app_data->shared_res_path);
396 return (app_data->shared_res_path);
399 void show_gl_focus(Eina_Bool bVisible){
400 if(app_data->genlist == NULL)
403 if(bVisible == EINA_TRUE){
404 elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,enable", "elm");
405 //elm_layout_theme_set(app_data->genlist, "genlist", "base", "focus_bg");
406 //elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,show", "elm");
408 elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,disable", "elm");
409 //elm_layout_theme_set(app_data->genlist, "genlist", "base", "default");
410 //elm_object_signal_emit(app_data->genlist, "elm,state,focus_bg,hide", "elm");
414 void show_popup_toast(const char *text, bool check_img)
416 PRINTFUNC(DLOG_ERROR, "show_popup_toast");
420 popup = elm_popup_add(app_data->win_main);
421 elm_object_style_set(popup, "toast/circle");
422 elm_popup_orient_set(popup, ELM_POPUP_ORIENT_BOTTOM);
423 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
426 string path = get_resource_path();
427 string path_ic = path + "/images/toast_check_icon.png";
428 Evas_Object * img = elm_image_add(popup);
429 elm_image_file_set(img, path_ic.c_str(), NULL);
430 elm_object_part_content_set(popup, "toast,icon", img);
433 elm_object_part_text_set(popup, "elm.text", text);
436 eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, _popup_back_cb, NULL);
437 evas_object_smart_callback_add(popup, "dismissed", _popup_close_cb, NULL);
438 evas_object_smart_callback_add(popup, "block,clicked", _popup_back_cb, NULL);
440 elm_popup_timeout_set(popup, 2.0);
441 evas_object_show(popup);
444 static void _popup_close_cb(void *data, Evas_Object *obj, void *event_info)
447 evas_object_hide(obj);
448 evas_object_del(obj);
452 static void _popup_back_cb(void *data, Evas_Object *obj, void *event_info)
455 elm_popup_dismiss(obj);
459 void _back_to_genlist_for_selector()
461 PRINTFUNC(DLOG_DEBUG, "");
463 if(!app_data) return;
465 if(app_data->app_type == APP_TYPE_STT || app_data->app_type == APP_TYPE_EMOTICON){
466 PRINTFUNC(DLOG_DEBUG, "launched as STT/EMOTICON mode, So exit here.");
467 reply_to_sender_by_callback(NULL, NULL);
471 Evas_Object *circle_genlist = (Evas_Object *) evas_object_data_get(app_data->genlist, "circle");
473 eext_rotary_object_event_activated_set(circle_genlist, EINA_TRUE);
476 static void _item_realized(void *data, Evas_Object *obj, void *event_info) //called when list scrolled
478 PRINTFUNC(DLOG_DEBUG, "%s", __func__);
481 Evas_Object* _create_genlist(Evas_Object* navi)
483 Evas_Object* genlist = elm_genlist_add(navi);
487 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
489 Evas_Object* circle_object_genlist = eext_circle_object_genlist_add(genlist, app_data->circle_surface);
490 eext_circle_object_genlist_scroller_policy_set(circle_object_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
491 evas_object_data_set(genlist, "circle", (void *) circle_object_genlist);
492 eext_rotary_object_event_activated_set(circle_object_genlist, EINA_TRUE);
494 evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
495 evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
497 evas_object_smart_callback_add(genlist, "language,changed", __ise_gl_lang_changed, genlist);
498 evas_object_show(genlist);
500 // uxt_genlist_set_bottom_margin_enabled(genlist, EINA_TRUE);
502 show_gl_focus(EINA_FALSE);
504 Elm_Object_Item *nf_main_item = elm_naviframe_item_push(navi,
511 elm_naviframe_item_pop_cb_set(nf_main_item, back_cb, app_data);
512 evas_object_smart_callback_add(genlist, "realized", _item_realized, NULL);
517 static void _item_position_changed_cb(void *data, Evas_Object *obj, void *event_info)
522 Evas_Object *genlist = (Evas_Object *)obj;
523 Elm_Object_Item *gen_item = (Elm_Object_Item *)data;
526 elm_scroller_region_get(genlist, NULL, &y, NULL, NULL);
528 // PRINTFUNC(DLOG_DEBUG,"y=%d",y);
530 if (250 > y && y >= 100){
531 if (last_step == 0) return;
533 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.0", "elm");
534 show_gl_focus(EINA_TRUE);
535 } else if (100 > y && y >= 50){
536 if (last_step == 1) return;
538 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.1", "elm");
539 show_gl_focus(EINA_TRUE);
540 } else if (y < 50 && y >=0){
541 if (last_step == 2) return;
543 elm_object_item_signal_emit(gen_item, "elm,action,ime,0.9", "elm");
544 show_gl_focus(EINA_FALSE);
549 _main_menu_title_text_get(void *data, Evas_Object *obj, const char *part)
553 snprintf(buf, 1023, "%s", "Select method");
557 void _create_genlist_items(void* user_data)
559 LOGD("[psw] _create_genlist_items");
561 App_Data* app_data = (App_Data*) user_data;
563 if(NULL == app_data->genlist) {
564 app_data->genlist = _create_genlist(app_data->naviframe);
565 if(NULL == app_data->genlist)
569 elm_genlist_clear(app_data->genlist);
571 Elm_Genlist_Item_Class * itc0 = elm_genlist_item_class_new();
572 itc0->item_style = "title";
573 itc0->func.text_get = _main_menu_title_text_get;
574 itc0->func.content_get = NULL;
575 itc0->func.state_get = NULL;
576 itc0->func.del = NULL;
578 Elm_Genlist_Item_Class * itc1 = elm_genlist_item_class_new();
579 if(g_input_type_data.input_type_array_len == 2){
580 itc1->item_style = "2button_flat";
581 itc1->func.text_get = NULL;
582 itc1->func.content_get = __ise_gl_2button_content_get;
583 itc1->func.state_get = NULL;
584 itc1->func.del = NULL;
586 itc1->item_style = "3button_flat";
587 itc1->func.text_get = NULL;
588 itc1->func.content_get = __ise_gl_3button_content_get;
589 itc1->func.state_get = NULL;
590 itc1->func.del = NULL;
593 // dummy title for empty space
594 it_empty = elm_genlist_item_append(app_data->genlist, itc0,
596 ELM_GENLIST_ITEM_NONE,
600 it_title = elm_genlist_item_append(app_data->genlist, itc1,
602 ELM_GENLIST_ITEM_NONE,
605 elm_genlist_item_select_mode_set(it_title, ELM_OBJECT_SELECT_MODE_NONE);
607 Elm_Object_Item *item = elm_genlist_item_next_get(it_title);
608 elm_genlist_item_show(item, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
610 evas_object_smart_callback_add(app_data->genlist, "elm,item,position,changed", _item_position_changed_cb, it_title);
612 elm_genlist_item_class_free(itc0);
613 elm_genlist_item_class_free(itc1);
616 bool _app_create(void* user_data)
618 int width = 1000, height = 1000;
619 // App_Data* app_data = NULL;
620 Evas_Object* layout = NULL;
621 Evas_Object* conform = NULL;
622 Evas_Object* bg = NULL;
623 Evas_Object* window = NULL;
624 Eext_Circle_Surface *surface;
630 _app_language_changed(NULL, NULL);
632 app_data = (App_Data*)user_data;
634 elm_app_base_scale_set(1.3);
636 window = elm_win_add(NULL, PACKAGE, ELM_WIN_BASIC);
638 init_customizing_theme();
640 elm_win_title_set(window, PACKAGE);
641 elm_win_borderless_set(window, EINA_TRUE);
642 // ecore_x_window_size_get(ecore_x_window_root_first_get(), &width, &height);
643 evas_object_resize(window, width, height);
644 elm_win_indicator_mode_set(window, ELM_WIN_INDICATOR_SHOW);
646 LOGE("elm_win_add() is failed.");
650 bg = elm_bg_add(window);
651 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
652 elm_win_resize_object_add(window, bg);
653 evas_object_show(bg);
655 layout = elm_layout_add(window);
656 elm_layout_theme_set(layout, "layout", "application", "default");
657 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
659 conform = elm_conformant_add(window);
660 surface = eext_circle_surface_conformant_add(conform);
661 evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
664 elm_win_resize_object_add(window, conform);
665 elm_object_content_set(conform, layout);
667 evas_object_show(layout);
668 evas_object_show(conform);
669 evas_object_show(window);
670 app_data->win_main = window;
671 app_data->conform = conform;
672 app_data->layout_main = layout;
673 app_data->circle_surface = surface;
674 app_data->app_type = APP_TYPE_SELECT_MODE;
676 Evas_Object *naviframe = elm_naviframe_add(layout);
677 elm_naviframe_prev_btn_auto_pushed_set(naviframe, EINA_FALSE);
678 eext_object_event_callback_add(naviframe, EEXT_CALLBACK_BACK, eext_naviframe_back_cb, NULL);
679 elm_object_part_content_set(layout, "elm.swallow.content", naviframe);
680 evas_object_show(naviframe);
682 app_data->naviframe = naviframe;
687 void _app_service(app_control_h service, void* user_data)
690 char *context = NULL;
691 char **input_type_array = NULL;
692 int input_type_array_len = -1;
693 bool is_extra_data_array = false;
695 app_control_clone(&(app_data->source_app_control), service);
696 app_data->reply_type = REPLY_APP_NORMAL;
698 ret = app_control_is_extra_data_array(service, APP_CONTROL_DATA_INPUT_TYPE, &is_extra_data_array);
699 if( is_extra_data_array == true) {
700 ret = app_control_get_extra_data_array(service, APP_CONTROL_DATA_INPUT_TYPE, &input_type_array, &input_type_array_len);
701 g_input_type_data.input_type_array = input_type_array;
702 g_input_type_data.input_type_array_len = input_type_array_len;
704 ret = app_control_get_extra_data(service, APP_CONTROL_DATA_INPUT_TYPE, &context);
705 if (ret == APP_CONTROL_ERROR_NONE) {
706 if (!strcmp(context, "input_voice")) {
707 app_data->app_type = APP_TYPE_STT;
708 _stt_clicked_cb((void *)app_data, NULL, NULL);
710 } else if (!strcmp(context, "input_emoticon")) {
711 app_data->app_type = APP_TYPE_EMOTICON;
712 _emoticon_clicked_cb((void *)app_data, NULL, NULL);
714 } else if (!strcmp(context, "input_keyboard")) {
715 app_data->app_type = APP_TYPE_KEYBOARD;
716 input_keyboard_init(service);
717 _keyboard_clicked_cb((void *)app_data, NULL, NULL);
719 } else if (!strcmp(context, "input_reply")) {
720 app_data->app_type = APP_TYPE_REPLY;
725 if (app_data->genlist == NULL)
726 app_data->genlist = _create_genlist(app_data->naviframe);
728 input_keyboard_init(service);
730 _create_genlist_items(app_data);
733 elm_win_activate(app_data->win_main);
740 void _app_pause(void* user_data)
742 PRINTFUNC(DLOG_DEBUG, "");
746 void _app_resume(void* user_data)
748 PRINTFUNC(DLOG_DEBUG, "");
751 void _app_terminate(void* user_data)
753 App_Data* app_data = NULL;
754 app_data = (App_Data*)user_data;
756 if(app_data->genlist){
757 evas_object_smart_callback_del(app_data->genlist, "elm,item,position,changed", _item_position_changed_cb);
760 if(app_data->res_path)
761 free(app_data->res_path);
763 if(app_data->shared_res_path)
764 free(app_data->shared_res_path);
766 input_keyboard_deinit();
770 static int init_i18n(const char *domain, const char *dir, char *lang_str)
772 if (setlocale(LC_ALL, "") == NULL) {
773 PRINTFUNC(DLOG_INFO, "Some environment variable is invalid, setlocale(LC_ALL, \"\") has returns\ed a null pointer");
774 if (setlocale(LC_ALL, lang_str) == NULL)
777 if (bindtextdomain(domain, dir) == NULL)
779 if (textdomain(domain) == NULL)
786 * @brief Set language and locale.
790 static void _app_language_changed(app_event_info_h event_info, void *user_data)
792 char* lang_str = vconf_get_str(VCONFKEY_LANGSET);
794 setenv("LANG", lang_str, 1);
795 setenv("LC_MESSAGES", lang_str, 1);
797 setenv("LANG", "en_GB.utf8", 1);
798 setenv("LC_MESSAGES", "en_GB.utf8", 1);
799 lang_str = strdup("en_GB.UTF-8");
802 init_i18n(PACKAGE, LOCALEDIR, lang_str);
805 elm_language_set(lang_str);
810 void input_type_deinit(void)
813 char **data_array = NULL;
815 data_array = g_input_type_data.input_type_array;
817 for (i = 0; i < g_input_type_data.input_type_array_len; i++) {
818 if (*(data_array + i))
819 free(*(data_array + i));
823 g_input_type_data.input_type_array = NULL;
824 g_input_type_data.input_type_array_len = 0;
827 int main(int argc, char* argv[])
829 App_Data app_data = {0, };
830 ui_app_lifecycle_callback_s event_callback = {0, };
831 app_event_handler_h handlers[5] = {NULL, };
833 event_callback.create = _app_create;
834 event_callback.terminate = _app_terminate;
835 event_callback.pause = _app_pause;
836 event_callback.resume = _app_resume;
837 event_callback.app_control = _app_service;
839 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, NULL, &app_data);
840 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, NULL, &app_data);
841 ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, NULL, &app_data);
842 ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, _app_language_changed, &app_data);
843 ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, NULL, &app_data);
845 _init_app_data(&app_data);
847 int ret = ui_app_main(argc, argv, &event_callback, &app_data);
848 if (ret != APP_ERROR_NONE) {
849 LOGD("ui_app_main() is failed. err = %d", ret);