X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fw-input-stt-voice.cpp;h=7fe546f7a6228323b62b858749da1a6787c448f9;hb=refs%2Fchanges%2F26%2F129426%2F2;hp=72b77920b5cbace481acab94f2d67066a5d998a7;hpb=410e0b28138643ae6e7024eead5ef301581fcca4;p=platform%2Fcore%2Fuifw%2Finputdelegator.git diff --git a/src/w-input-stt-voice.cpp b/src/w-input-stt-voice.cpp index 72b7792..7fe546f 100755 --- a/src/w-input-stt-voice.cpp +++ b/src/w-input-stt-voice.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include "Debug.h" #include "w-input-selector.h" @@ -40,7 +41,7 @@ using namespace std; #define GRP_PORTRAIT "mic_control" #define item_append(obj, style, index, cb, udata) \ - elm_genlist_item_append(obj, &(style), (void *)index, NULL, ELM_GENLIST_ITEM_NONE, cb, udata) + elm_genlist_item_append(obj, &(style), (void *)(uintptr_t)index, NULL, ELM_GENLIST_ITEM_NONE, cb, udata) #define VIRTUAL_TEXT_AREA_FONT_STYLE \ "DEFAULT='font=Tizen:style=Regular font_size=32 color=#FFFFFF color_class=AT013 text_class=tizen wrap=mixed align=center' \ @@ -64,7 +65,7 @@ static Elm_Genlist_Item_Class itc_title; static Elm_Genlist_Item_Class itc_1text; static Elm_Genlist_Item_Class itc_2text; - +static Eina_Bool change_guide_text(void *data); static void set_guide_text(VoiceData *vd, const char* text, bool translatable = false); const char *supported_language[] = { @@ -313,7 +314,6 @@ static Eina_Bool _update_textblock_timer_cb(void *data) if(voicedata->state == STT_STATE_VAL_LISTENING){ if(voicedata->guide_text_timer != NULL){ - PRINTFUNC(DLOG_DEBUG, "Skip hide_guide_text"); ecore_timer_del(voicedata->guide_text_timer); voicedata->guide_text_timer = NULL; } @@ -393,21 +393,48 @@ static Eina_Bool _recognition_failure_cb(void *data) void start_by_press(VoiceData *voicedata) { - PRINTFUNC(DLOG_DEBUG, ""); - + LOGD("start_by_press "); edje_object_signal_emit(_EDJ(voicedata->layout_main), "mouse,clicked,1", "background"); - - return; } static void on_mic_button_press_cb(void *data, Evas_Object *obj, void *event_info) { - PRINTFUNC(NO_PRINT, ""); - + LOGD("on_mic_button_press_cb"); VoiceData *voicedata = (VoiceData *)data; - edje_object_signal_emit(_EDJ(voicedata->layout_main), "mouse,clicked,1", "background"); + if (!voicedata) return; - return; + if (voicedata->sttmanager != NULL && + (voicedata->sttmanager->GetCurrent() == STT_STATE_RECORDING + || voicedata->sttmanager->GetCurrent() == STT_STATE_PROCESSING)) { + try { + voicedata->state = STT_STATE_VAL_INIT; + voicedata->sttmanager->Stop(); + } + catch (is::stt::SttException &e) { + } + + if (voicedata->effector) + voicedata->effector->Stop(true); + + if (NULL != voicedata->start_timer) { + ecore_timer_del(voicedata->start_timer); + voicedata->start_timer = NULL; + } + if (NULL != voicedata->guide_text_timer) { + ecore_timer_del(voicedata->guide_text_timer); + voicedata->guide_text_timer = NULL; + } + if (NULL != voicedata->refresh_timer) { + ecore_timer_del(voicedata->refresh_timer); + voicedata->refresh_timer = NULL; + } + } else { + if (NULL != voicedata->guide_text_timer) { + ecore_timer_del(voicedata->guide_text_timer); + voicedata->guide_text_timer = NULL; + } + edje_object_signal_emit(_EDJ(voicedata->layout_main), "mouse,clicked,1", "background"); + } } @@ -525,32 +552,33 @@ static Eina_Bool _idler_cb(void *data) if(true == _app_stt_initialize(voicedata)) { - PRINTFUNC(NO_PRINT, "_app_stt_initialize None Error"); + LOGD("_app_stt_initialize None Error"); voicedata->voicefw_state = 1; voicedata->state = STT_STATE_VAL_INIT; } else { voicedata->voicefw_state = 0; - PRINTFUNC(DLOG_ERROR, "Initialization Fail!
Check STT-daemon is running"); + LOGD("Initialization Fail!
Check STT-daemon is running"); } Evas_Object *canvas = elm_object_part_content_get(voicedata->layout_main, "EFFECT_BG"); - is::ui::WInputSttMicEffect *ieffect = new is::ui::WInputSttMicEffect(); - ieffect->SetSttHandle(voicedata->sttmanager->GetSttHandle()); + if (ieffect) + ieffect->SetSttHandle(voicedata->sttmanager->GetSttHandle()); is::ui::MicEffector *effector = new is::ui::MicEffector(canvas, voicedata->layout_main, *ieffect); voicedata->ieffect = ieffect; voicedata->effector = effector; - ieffect->SetProgressBar(voicedata->progressbar); - ieffect->SetSttHandle(voicedata->sttmanager->GetSttHandle()); + if (ieffect) { + ieffect->SetProgressBar(voicedata->progressbar); + ieffect->SetSttHandle(voicedata->sttmanager->GetSttHandle()); + } voicedata->mo->Update(); elm_access_highlight_set(voicedata->mic_button); - return ECORE_CALLBACK_CANCEL; } @@ -606,23 +634,21 @@ void powerLock(void *data, bool enable) } } +static Eina_Bool change_guide_text(void *data){ + VoiceData *voicedata = (VoiceData *) data; + if (!voicedata) return ECORE_CALLBACK_CANCEL; -static Eina_Bool hide_guide_text(void *data){ - if(data) { - VoiceData *voicedata = (VoiceData *) data; - - voicedata->guide_text_timer = NULL; - + stt_state_e state = voicedata->sttmanager->GetCurrent(); + if (state == STT_STATE_RECORDING || state == STT_STATE_PROCESSING) + elm_object_domain_translatable_part_text_set(voicedata->layout_main, "elm.text", PACKAGE, SK_TAP_TO_PAUSE); - PRINTFUNC(DLOG_ERROR, ""); - elm_object_part_text_set(voicedata->layout_main, "elm.text", ""); - } return ECORE_CALLBACK_CANCEL; } + static void set_guide_text(VoiceData *vd, const char* text, bool translatable) { - //elm_object_signal_emit(vd->layout_main, "idle,state,text,visible", "elm"); + elm_object_signal_emit(vd->layout_main, "idle,state,guide_text,bottom", "elm"); if(translatable) elm_object_domain_translatable_part_text_set(vd->layout_main, "elm.text", PACKAGE, text); @@ -631,7 +657,7 @@ static void set_guide_text(VoiceData *vd, const char* text, bool translatable) if(!strcmp(text, SK_SPEAK_NOW)){ if(vd->guide_text_timer == NULL) - vd->guide_text_timer = ecore_timer_add(2.0, hide_guide_text, vd); + vd->guide_text_timer = ecore_timer_add(2.0, change_guide_text, vd); } } @@ -642,22 +668,6 @@ static void set_guide_text(VoiceData *vd, const char* text, bool translatable) */ void set_animation_state(VoiceData *voicedata) { - PRINTFUNC(DLOG_DEBUG, ""); - - PRINTFUNC(DLOG_ERROR, "voicedata->state == %s", - voicedata->state == STT_STATE_VAL_INIT ? - "STT_STATE_VAL_INIT" : - voicedata->state == STT_STATE_VAL_LISTENING ? - "STT_STATE_VAL_LISTENING" : - voicedata->state == STT_STATE_VAL_PREPARE_LISTENING ? - "STT_STATE_VAL_PREPARE_LISTENING" : - voicedata->state == STT_STATE_VAL_PROCESSING ? - "STT_STATE_VAL_PROCESSING" : - voicedata->state == STT_STATE_VAL_PREPARE_PROCESSING ? - "STT_STATE_VAL_PREPARE_PROCESSING" : - voicedata->state == STT_STATE_VAL_TERMINATING ? - "STT_STATE_VAL_TERMINATING" : "STT_STATE_VAL_NOT_RECOGNISED"); - if (voicedata->state == STT_STATE_VAL_INIT) { #if 0 if (voicedata->sttmanager->GetCurrent() == STT_STATE_READY) { @@ -673,9 +683,8 @@ void set_animation_state(VoiceData *voicedata) if(voicedata->effector) voicedata->effector->Stop(true); - set_guide_text(voicedata, ""); + set_guide_text(voicedata, "Tap mic to speak"); - PRINTFUNC(DLOG_DEBUG, "%d", voicedata->stt_results.size()); powerLock((void*)voicedata, false); } else if (voicedata->state == STT_STATE_VAL_LISTENING) { set_guide_text(voicedata, SK_SPEAK_NOW, true); @@ -691,7 +700,6 @@ void set_animation_state(VoiceData *voicedata) stt_feedback(VIBRATION_STOP); } else { - PRINTFUNC(DLOG_DEBUG, "SK_NETWORK_ERROR"); set_guide_text(voicedata, _(SK_RECOGNITION_FAILED)); //_elm_access_say(voicedata->layout_main, _(SK_RECOGNITION_FAILED)); @@ -705,8 +713,6 @@ void set_animation_state(VoiceData *voicedata) voicedata->effector->Stop(true); voicedata->refresh_timer = ecore_timer_add(2.0, _recognition_failure_cb, voicedata); - - //powerLock((void*)voicedata, false); } } @@ -759,20 +765,15 @@ static Eina_Bool _start_timer_cb(void* data) voicedata->sttmanager->Start(); } catch (is::stt::SttException &e) { - PRINTFUNC(DLOG_ERROR, "%s", e.what()); - if (e.GetEcode() == STT_ERROR_OUT_OF_NETWORK) { - PRINTFUNC(DLOG_DEBUG, "SK_NETWORK_ERROR"); set_guide_text(voicedata, _(SK_NETWORK_ERROR)); voicedata->state = STT_STATE_VAL_INIT; } else if (e.GetEcode() == STT_ERROR_RECORDER_BUSY) { - PRINTFUNC(DLOG_WARN, "STT is used by another application"); - show_popup_toast(_(SK_STT_BUSY), false); + set_guide_text(voicedata, _(SK_STT_BUSY)); voicedata->state = STT_STATE_VAL_INIT; } else { - PRINTFUNC(DLOG_WARN, "Check error code"); - show_popup_toast(_(SK_STT_BUSY), false); + set_guide_text(voicedata, _(SK_STT_BUSY)); voicedata->state = STT_STATE_VAL_INIT; } } @@ -791,6 +792,8 @@ void on_initial_anim_press_cb(void *data, Evas_Object *obj, const char *emission PRINTFUNC(NO_PRINT, ""); VoiceData *vd = (VoiceData *)data; + if (vd == NULL) + return; int tempVal = vd->sttmanager->GetCurrent(); if(tempVal == STT_STATE_CREATED) { @@ -856,6 +859,8 @@ void on_initial_anim_press_cb(void *data, Evas_Object *obj, const char *emission catch (is::stt::SttException &e) { PRINTFUNC(DLOG_ERROR, "%s", e.what()); } + if (vd->effector) + vd->effector->Stop(true); break; @@ -882,11 +887,12 @@ static inline void ea_naviframe_back(void *data, Evas_Object *obj, void *event_i ecore_event_handler_del(g_evt_key_down); g_evt_key_down = NULL; - - //Hide more option - if(g_more_option_layout){ - if(eext_more_option_opened_get(g_more_option_layout) == EINA_TRUE) { - eext_more_option_opened_set(g_more_option_layout, EINA_FALSE); + if (_WEARABLE) { + //Hide more option + if(g_more_option_layout){ + if(eext_more_option_opened_get(g_more_option_layout) == EINA_TRUE) { + eext_more_option_opened_set(g_more_option_layout, EINA_FALSE); + } } } } @@ -902,11 +908,11 @@ char *__get_genlist_item_label(void *data, Evas_Object *obj, const char *part) if(!strcmp(part, "elm.text")) { - if((int)data == 0) { + if((uintptr_t)data == 0) { return strdup(_("IDS_VC_BODY_AUTOMATIC")); } else { char *s = NULL; - s = (char *)disp_lang_array[(int)data]; + s = (char *)disp_lang_array[(uintptr_t)data]; if(s) { char *p = strchr(s, '('); @@ -921,7 +927,7 @@ char *__get_genlist_item_label(void *data, Evas_Object *obj, const char *part) } return strdup(text); } else if (!strcmp(part, "elm.text.1")) { - if ((int)data == 0) { + if ((uintptr_t)data == 0) { char* value = NULL; value = vconf_get_str(VCONFKEY_LANGSET); if (NULL == value) { @@ -941,7 +947,7 @@ char *__get_genlist_item_label(void *data, Evas_Object *obj, const char *part) } else { char *s = NULL; - s = (char *)disp_lang_array[(int)data]; + s = (char *)disp_lang_array[(uintptr_t)data]; if(s) { char *p = strchr(s, '('); @@ -949,6 +955,7 @@ char *__get_genlist_item_label(void *data, Evas_Object *obj, const char *part) strncpy(text, p+1, strlen(s)-(p-s)-2); } else { strncpy(text, s, strlen(s)); + text[strlen(s)] = '\0'; } } else { strncpy(text, "", strlen("")); @@ -965,7 +972,7 @@ static Evas_Object *__get_genlist_item_content(void *data, Evas_Object *obj, con Evas_Object * content = NULL; if (!strcmp(part, "elm.icon") || - !strcmp(part, "elm.swallow.end")) { + !strcmp(part, "elm.swallow.end")) { content = elm_radio_add(obj); elm_object_style_set(content, "list"); elm_radio_state_value_set(content, index); @@ -1099,7 +1106,7 @@ static void language_set_genlist_radio_cb(void *data, Evas_Object *obj, void *ev Elm_Object_Item * item = (Elm_Object_Item *) event_info; if (item) { elm_genlist_item_selected_set(item, 0); - index = (int)elm_object_item_data_get(item); + index = (uintptr_t)elm_object_item_data_get(item); elm_genlist_item_update(item); } set_language_value(index); @@ -1160,21 +1167,21 @@ static Evas_Object *create_language_list(Evas_Object *parent) elm_radio_state_value_set(radio_gp, -1); lang_val = get_language_value(); -#ifdef _WEARABLE + //Title itc_title.item_style = "title"; itc_title.func.text_get = __get_genlist_title_label; itc_title.func.content_get = NULL; - - item = elm_genlist_item_append(genlist, &itc_title, (void *)-1, NULL, ELM_GENLIST_ITEM_GROUP, NULL, genlist); -#endif + if (_WEARABLE) { + item = elm_genlist_item_append(genlist, &itc_title, (void *)-1, NULL, ELM_GENLIST_ITEM_GROUP, NULL, genlist); + } // 2 line text -#ifdef _WEARABLE - itc_2text.item_style = "2text.1icon.1/sub1.multiline"; -#else - itc_2text.item_style = "type1"; -#endif + if (_WEARABLE) { + itc_2text.item_style = "2text.1icon.1/sub1.multiline"; + } else { + itc_2text.item_style = "type1"; + } itc_2text.func.text_get = __get_genlist_item_label; itc_2text.func.content_get = __get_genlist_item_content; @@ -1191,11 +1198,11 @@ static Evas_Object *create_language_list(Evas_Object *parent) } // 1 line text -#ifdef _WEARABLE - itc_1text.item_style = "1text.1icon.1"; -#else - itc_1text.item_style = "type1"; -#endif + if (_WEARABLE) { + itc_1text.item_style = "1text.1icon.1"; + } else { + itc_1text.item_style = "type1"; + } itc_1text.func.text_get = __get_genlist_item_label; itc_1text.func.content_get = __get_genlist_item_content; @@ -1317,8 +1324,11 @@ void create_setting_window(Evas_Object *more_option_layout) */ genlist = create_language_list(naviframe); + const char *item_style = NULL; + if (_WEARABLE) + item_style = "empty"; //item = elm_naviframe_item_push(naviframe, "IDS_VC_HEADER_VOICE_INPUT_LANGUAGE", NULL, NULL, genlist, NULL); - elm_naviframe_item_push(naviframe, NULL, NULL, NULL, genlist, "empty"); + elm_naviframe_item_push(naviframe, NULL, NULL, NULL, genlist, item_style); //elm_object_item_domain_text_translatable_set(item, PACKAGE, EINA_TRUE); g_setting_window = window; @@ -1382,8 +1392,12 @@ static void __stt_detailed_entry_del_cb(void *data, Evas *e, Evas_Object *obj, v static Evas_Object *create_text_detiled_view(Evas_Object *parent) { string edj_path = get_resource_path(); - edj_path = edj_path + STT_EDJ_FILE; - + if(_WEARABLE) + edj_path = edj_path + STT_EDJ_FILE_WEARABLE; + else if (_TV) + edj_path = edj_path + STT_EDJ_FILE_TV; + else + edj_path = edj_path + STT_EDJ_FILE_MOBILE; //layout Evas_Object *layout = elm_layout_add(parent); elm_layout_file_set(layout, edj_path.c_str(), "entry_focused_layout"); @@ -1507,11 +1521,12 @@ void activate_circle_scroller_for_stt_textbox(void* data, Eina_Bool bActivate) VoiceData *voicedata = (VoiceData *)data; Evas_Object *scroller = NULL; - Evas_Object *circle_scroller = NULL; - scroller = elm_layout_content_get((Evas_Object *)voicedata->layout_main, "text_area"); - circle_scroller = (Evas_Object *) evas_object_data_get(scroller, "circle"); - eext_rotary_object_event_activated_set(circle_scroller, bActivate); + if (_WEARABLE) { + Evas_Object *circle_scroller = NULL; + circle_scroller = (Evas_Object *) evas_object_data_get(scroller, "circle"); + eext_rotary_object_event_activated_set(circle_scroller, bActivate); + } } static Evas_Object *create_textblock(void* data) @@ -1527,7 +1542,12 @@ static Evas_Object *create_textblock(void* data) Evas_Object *circle_scroller = NULL; string edj_path = get_resource_path(); - edj_path = edj_path + STT_EDJ_FILE; + if(_WEARABLE) + edj_path = edj_path + STT_EDJ_FILE_WEARABLE; + else if (_TV) + edj_path = edj_path + STT_EDJ_FILE_TV; + else + edj_path = edj_path + STT_EDJ_FILE_MOBILE; scroller = elm_scroller_add(voicedata->layout_main); @@ -1540,13 +1560,11 @@ static Evas_Object *create_textblock(void* data) elm_scroller_page_scroll_limit_set(scroller, 0, 1); elm_object_scroll_lock_x_set(scroller, EINA_TRUE); - -// uxt_scroller_set_auto_scroll_enabled(scroller, EINA_FALSE); - - circle_scroller = eext_circle_object_scroller_add(scroller, app_data->circle_surface); - eext_circle_object_scroller_policy_set(circle_scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO); - eext_rotary_object_event_activated_set(circle_scroller, EINA_TRUE); - + if (_WEARABLE) { + circle_scroller = eext_circle_object_scroller_add(scroller, app_data->circle_surface); + eext_circle_object_scroller_policy_set(circle_scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO); + eext_rotary_object_event_activated_set(circle_scroller, EINA_TRUE); + } box = elm_box_add(scroller); inner_layout = elm_layout_add(scroller); @@ -1633,7 +1651,12 @@ static Evas_Object *create_fullview(Evas_Object *parent, VoiceData *r_voicedata) voicedata->layout_main = layout_main; string edj_path = get_resource_path(); - edj_path = edj_path + STT_EDJ_FILE; + if(_WEARABLE) + edj_path = edj_path + STT_EDJ_FILE_WEARABLE; + else if (_TV) + edj_path = edj_path + STT_EDJ_FILE_TV; + else + edj_path = edj_path + STT_EDJ_FILE_MOBILE; if (vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &is_screen_reader_on) == -1) { PRINTFUNC(DLOG_ERROR, "Cannot read value of screen reader from vconf"); @@ -1865,9 +1888,11 @@ void on_stt_pause(VoiceData *r_voicedata){ //Hide more option and language settings by interrupt scenario. close_setting_window_idler_cb(NULL); Evas_Object *mo_layout = voicedata->mo->getMoreOptionLayout(); - if(mo_layout){ - if(eext_more_option_opened_get(mo_layout) == EINA_TRUE) { - eext_more_option_opened_set(mo_layout, EINA_FALSE); + if (_WEARABLE) { + if(mo_layout){ + if(eext_more_option_opened_get(mo_layout) == EINA_TRUE) { + eext_more_option_opened_set(mo_layout, EINA_FALSE); + } } } }