Support to delegate various MIME types to caller as like voice recording
[platform/core/uifw/inputdelegator.git] / src / w-input-stt-voice.cpp
index 6e50198..595d417 100755 (executable)
@@ -32,6 +32,7 @@
 #include "w-input-stt-voice.h"
 #include "w-input-stt-engine.h"
 #include "w-input-stt-ise.h"
+#include "voice-recorder.h"
 
 using namespace std;
 
@@ -473,10 +474,15 @@ static void on_confirm_button_clicked_cb(void *data, Evas_Object *obj, void *eve
 
        PRINTFUNC(DLOG_DEBUG, "result_text = %s", result_text.c_str());
 
-       reply_to_sender_by_callback(result_text.c_str(), "voice");
+       char *filePath = NULL;
+       voice_recorder *vr = _voice_recorder_get_data();
+       if (!vr)
+               filePath = vr->file_path;
+       char *path[] = {filePath, };
+       reply_to_sender_by_callback(result_text.c_str(), "voice", (const char **)path);
        destroy_voice();
        powerUnlock();
-       elm_exit();
+       ui_app_exit();
 
        return;
 }
@@ -779,6 +785,9 @@ static Eina_Bool _start_timer_cb(void* data)
                }
                voicedata->start_timer = NULL;
        }
+
+       start_voice_recorder();
+
        return ECORE_CALLBACK_CANCEL;
 }
 
@@ -887,11 +896,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);
+                       }
                }
        }
 }
@@ -919,6 +929,7 @@ char *__get_genlist_item_label(void *data, Evas_Object *obj, const char *part)
                                        strncpy(text, s, p-s);
                                } else {
                                        strncpy(text, s, strlen(s));
+                                       text[strlen(s)] = '\0';
                                }
                        } else {
                                strncpy(text, "", strlen(""));
@@ -1171,16 +1182,16 @@ static Evas_Object *create_language_list(Evas_Object *parent)
        itc_title.item_style = "title";
        itc_title.func.text_get = __get_genlist_title_label;
        itc_title.func.content_get = NULL;
-#ifdef _WEARABLE
-       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;
 
@@ -1197,11 +1208,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;
 
@@ -1323,8 +1334,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;
@@ -1388,8 +1402,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");
@@ -1514,11 +1532,11 @@ void activate_circle_scroller_for_stt_textbox(void* data, Eina_Bool bActivate)
 
        Evas_Object *scroller = NULL;
        scroller = elm_layout_content_get((Evas_Object *)voicedata->layout_main, "text_area");
-#ifdef _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);
-#endif
+       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)
@@ -1534,7 +1552,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);
 
@@ -1547,11 +1570,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);
-#ifdef _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);
-#endif
+       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);
@@ -1638,7 +1661,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");
@@ -1790,6 +1818,8 @@ int init_voice(Evas_Object *parent, const char *lang, VoiceData *r_voicedata)
                voicedata->textblock_timer = NULL;
        }
 
+       init_voice_recorder(NULL);
+
        return TRUE;
 }
 
@@ -1870,9 +1900,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);
+                               }
                        }
                }
        }