Add to set voice touch as auto mode 75/119075/4
authorsooyeon.kim <sooyeon.kim@samsung.com>
Wed, 15 Mar 2017 10:40:38 +0000 (19:40 +0900)
committersooyeon.kim <sooyeon.kim@samsung.com>
Mon, 20 Mar 2017 11:54:42 +0000 (20:54 +0900)
Change-Id: Id283dd5a9740a639d87c6be0f7cb7b9c9d4f2714
Signed-off-by: sooyeon.kim <sooyeon.kim@samsung.com>
CMakeLists.txt
include/voice_control_elm_private.h
packaging/voice-control-elm.spec
src/CMakeLists.txt
src/vc_elm.c
src/vc_elm_core.c

index f124b6efe19a9538ef5ff2da7ab8f8b7a57dba85..a8ce1648feaac979d95630c17345459889d39216 100644 (file)
@@ -18,6 +18,9 @@ SET(VERSION 0.2.0)
 
 # pkg config tool
 INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED
+               vconf
+)
 
 # Build type
 SET(CMAKE_BUILD_TYPE "Release")
index 6077ad643f9f669dca3894c6fb5c32ea0d8e2662..5b55088dc0c2d379cc3af338f098b726c9c0f014 100644 (file)
@@ -18,6 +18,7 @@
 #ifndef VOICE_CONTROL_ELEMENTARY_PRIVATE_H_
 #define VOICE_CONTROL_ELEMENTARY_PRIVATE_H_
 
+
 /**
 * @internal
 * @addtogroup VOICE_CONTROL_ELEMENTARY_PRIVATE_MODULE
@@ -110,6 +111,12 @@ int vc_elm_set_click_time(float time);
 
 int vc_elm_unset_click_time();
 
+/**
+ * @brief Function that check whether voice touch is set as auto mode or not
+ * @param[out] is_vt_automode a parameter for checking whether voice touch is set as auto mode or not
+ */
+int vc_elm_is_supported_vt_auto(bool* is_vt_automode);
+
 #ifdef __cplusplus
 }
 #endif
index 2b498ba272ac1d0b23c7b5cef02b476c112ebfba..00a4ed501b2c6149fadeff83494e85c8a7e63f8c 100644 (file)
@@ -25,6 +25,7 @@ BuildRequires:        pkgconfig(evas)
 BuildRequires: pkgconfig(libtzplatform-config)
 BuildRequires: pkgconfig(libxml-2.0)
 BuildRequires: pkgconfig(voice-control-widget)
+BuildRequires: pkgconfig(vconf)
 BuildRequires: gettext-tools
 
 %description
@@ -98,4 +99,4 @@ mkdir -p %{TZ_SYS_RO_SHARE}/voice
 %manifest %{name}-devel.manifest
 %{_includedir}/voice_control_elm.h
 %{_includedir}/voice_control_elm_private.h
-%{_libdir}/pkgconfig/%{name}.pc
\ No newline at end of file
+%{_libdir}/pkgconfig/%{name}.pc
index c00e5ee02f2c63598ca781c024b0ef949aad91ee..c71fa621acfec2bec8b64b90e7d20add2fa7d7be 100644 (file)
@@ -12,6 +12,7 @@ SET(VC_ELM_PKGS
        elementary
        dlog
        libxml-2.0
+       vconf
        )
 
 IF(${SRPOL_DEBUG} EQUAL "1")
index b89a39260ce9376f4a3748b0dc48731d8ecd9044..19fd3ec0ae2a89bbca1f33eeca9fa1411e6f384b 100644 (file)
@@ -21,6 +21,7 @@
 #include "vc_elm_main.h"
 #include <voice_control_elm.h>
 #include <voice_control_elm_private.h>
+#include <vconf.h>
 
 #include "vc_elm.h"
 #include "vc_elm_core.h"
 #include "vc_elm_tooltip.h"
 #include "vc_elm_widget_wrapper.h"
 
+//#define VC_VOICE_TOUCH_AUTOMODE              VCONFKEY_VC_VOICE_TOUCH_AUTOMODE
+#define VC_VOICE_TOUCH_AUTOMODE                "db/voice/vc/voice_touch/automode"
+
+#define VC_ELM_MODE_MANUAL             0
+
+#define VC_ELM_MODE_AUTO_APP   1
+
+#define VC_ELM_MODE_AUTO_APPFW 2
+
 /**
 * @brief Internal variable. It can check whether voice control elm is initilaized or not.
 */
@@ -928,17 +938,62 @@ int _vc_elm_get_text_domain(char **domain)
        return VC_ELM_ERROR_NONE;
 }
 
+int _vc_elm_is_supported_vt_auto(bool* is_vt_automode)
+{
+       if (0 != __vc_elm_get_feature_enabled()) {
+               return VC_ELM_ERROR_NOT_SUPPORTED;
+       }
+
+       int ret = -1;
+       ret = vconf_get_bool(VC_VOICE_TOUCH_AUTOMODE, is_vt_automode);
+
+       if (0 != ret) {
+               VC_ELM_LOG_DBG("Fail to get vconfkey");
+               return VC_ELM_ERROR_OPERATION_FAILED;
+       }
+
+       VC_ELM_LOG_DBG("Success to get vconfkey(%d)", (int)(*is_vt_automode));
+
+       return ret;
+}
+
+int vc_elm_is_supported_vt_auto(bool* is_vt_automode)
+{
+       if (0 != __vc_elm_get_feature_enabled()) {
+               return VC_ELM_ERROR_NOT_SUPPORTED;
+       }
+
+       return _vc_elm_is_supported_vt_auto(is_vt_automode);
+}
+
 int _vc_elm_set_auto_register_mode(int mode, int click_method)
 {
        g_auto_mode = mode;
        g_click_method = click_method;
 
+       VC_ELM_LOG_DBG("g_auto_mode: %d, g_click_method: %d", g_auto_mode, g_click_method);
+
        return 0;
 }
+
 int _vc_elm_get_auto_register_mode(int* mode, int* click_method)
 {
-       *mode = g_auto_mode;
-       *click_method = g_click_method;
+       bool is_vt_auto;
+       if (0 != _vc_elm_is_supported_vt_auto(&is_vt_auto)) {
+               return VC_ELM_ERROR_OPERATION_FAILED;
+       } else {
+               if (false == is_vt_auto) {
+                       VC_ELM_LOG_DBG("vt_automode is FALSE");
+                       *mode = g_auto_mode;
+                       *click_method = g_click_method;
+               } else {
+                       VC_ELM_LOG_DBG("vt_automode is TRUE");
+                       *mode = (int)VC_ELM_MODE_AUTO_APPFW;
+                       *click_method = g_click_method;
+               }
+       }
+
+       VC_ELM_LOG_DBG("mode: %d, click_method: %d", *mode, *click_method);
 
        return 0;
 }
@@ -949,6 +1004,19 @@ int vc_elm_set_auto_register_mode(int mode, int click_method)
                return VC_ELM_ERROR_NOT_SUPPORTED;
        }
 
+       bool is_vt_auto;
+       if (0 != _vc_elm_is_supported_vt_auto(&is_vt_auto)) {
+               return VC_ELM_ERROR_OPERATION_FAILED;
+       } else {
+               if (false == is_vt_auto) {
+                       VC_ELM_LOG_DBG("vt_automode is FALSE");
+                       return _vc_elm_set_auto_register_mode(mode, click_method);
+               } else {
+                       VC_ELM_LOG_DBG("vt_automode is TRUE");
+                       return _vc_elm_set_auto_register_mode((int)VC_ELM_MODE_AUTO_APPFW, click_method);
+               }
+       }
+
        return _vc_elm_set_auto_register_mode(mode, click_method);
 }
 
index 09909100aecb024e1c06d6c5742cf7c2f8c762b0..83df07314ab80c4e0b5d399f331e54cc9aad2740 100644 (file)
@@ -342,6 +342,128 @@ static Eina_Bool _vc_elm_click_matched_object(const char* cmd, int click_method)
        return text_found;
 }
 
+static Eina_Bool _vc_elm_click_matched_object_vt_auto(const char* cmd, int click_method)
+{
+       VC_ELM_LOG_DBG("inside _vc_elm_click_matched_object_vt_auto()");
+       VC_ELM_LOG_DBG("cmd(%s), click_method(%d)", cmd, click_method);
+
+       Eina_List *dump_iter = NULL;
+       void *data = NULL;
+       Eina_Bool text_found = EINA_FALSE;
+       EINA_LIST_FOREACH(g_dump_list, dump_iter, data) {
+               Object_Info* info = (Object_Info*)data;
+
+               if (NULL != info && NULL != info->text /*&& NULL != info->part_name*/) {
+                       VC_ELM_LOG_DBG("info->text(%s)", info->text);
+//                     Eina_List *iter = NULL;
+//                     char *part_name = NULL;
+//                     EINA_LIST_FOREACH(g_allowed_text_part_list, iter, part_name) {
+//                             if (NULL != part_name && !strcmp(part_name, info->part_name)) {
+                       if (!strcmp(info->text, cmd)) {
+                               int x = info->geometry_info.x;
+                               int y = info->geometry_info.y;
+                               int w = info->geometry_info.w;
+                               int h = info->geometry_info.h;
+                               VC_ELM_LOG_DBG("Click event : %s x(%d) y(%d) w(%d) h(%d), address(%p) type(%s)", info->text, x, y, w, h, info->address, info->type);
+                               if (0 == click_method) {
+                                       evas_event_feed_mouse_move(evas_object_evas_get((Evas_Object*)(info->address)), x + w/2, y + h/2, 0, NULL);
+                                       evas_event_feed_mouse_down(evas_object_evas_get((Evas_Object*)(info->address)), 1, EVAS_BUTTON_NONE, 1, NULL);
+                                       evas_event_feed_mouse_up(evas_object_evas_get((Evas_Object*)(info->address)), 1, EVAS_BUTTON_NONE, 2, NULL);
+                                       VC_ELM_LOG_INFO("click!!!!!");
+                               } else if (1 == click_method) {
+                                       VC_ELM_LOG_DBG("click method - focus/key");
+                                       bool clicked = false;
+                                       if (0 != strcmp(evas_object_type_get((Evas_Object*)info->address), "text") && 0 != strcmp(evas_object_type_get((Evas_Object*)info->address), "textblock")) {
+                                               VC_ELM_LOG_DBG("Click event");
+                                               if (EINA_TRUE == elm_object_focus_get((Evas_Object*)info->address)) {
+                                                       VC_ELM_LOG_DBG("Already focused");
+                                                       ecore_timer_add(g_click_time, __click_event, NULL);
+                                               } else {
+                                                       evas_object_smart_callback_add((Evas_Object*)(info->address), "focused", __focused_cb, "focused");
+                                                       elm_object_focus_set((Evas_Object*)(info->address), EINA_TRUE);
+                                               }
+                                               clicked = true;
+                                       }
+
+                                       if (false == clicked) {
+                                               Object_Info* parent_info = ea_object_dump_parent_widget_data_get(info);
+                                               if (NULL != parent_info) {
+                                                       if (EINA_TRUE == parent_info->focusable) {
+                                                               VC_ELM_LOG_DBG("Focusable Parent");
+                                                               VC_ELM_LOG_DBG("Click event");
+                                                               if (EINA_TRUE == elm_object_focus_get((Evas_Object*)parent_info->address)) {
+                                                                       VC_ELM_LOG_DBG("Already focused");
+                                                                       ecore_timer_add(g_click_time, __click_event, NULL);
+                                                               } else {
+                                                                       evas_object_smart_callback_add((Evas_Object*)(parent_info->address), "focused", __focused_cb, "focused");
+                                                                       elm_object_focus_set((Evas_Object*)(parent_info->address), EINA_TRUE);
+                                                               }
+                                                               clicked = true;
+                                                       }
+                                               }
+
+                                               if (false == clicked && NULL != parent_info) {
+                                                       parent_info = ea_object_dump_parent_widget_data_get(parent_info);
+                                                       while (NULL != parent_info) {
+                                                               if (EINA_TRUE == parent_info->focusable) {
+                                                                       VC_ELM_LOG_DBG("Focusable Parent");
+                                                                       const char* widget_type = elm_widget_type_get((Evas_Object*)(parent_info->address));
+                                                                       VC_ELM_LOG_DBG("type (%s)", widget_type);
+                                                                       Elm_Object_Item* item = NULL;
+                                                                       if (NULL != widget_type && !strcmp(widget_type, "Elm_Genlist")) {
+                                                                               item = elm_genlist_at_xy_item_get((Evas_Object*)(parent_info->address), x + w/2, y + h/2, NULL);
+                                                                               if (NULL == item) {
+                                                                                       item = elm_genlist_at_xy_item_get((Evas_Object*)(parent_info->address), x + w + w/2, y + h/2, NULL);
+                                                                               }
+                                                                       } else if (NULL != widget_type && !strcmp(widget_type, "Elm_List")) {
+                                                                               item = elm_list_at_xy_item_get((Evas_Object*)(parent_info->address), x + w/2, y + h/2, NULL);
+                                                                               if (NULL == item) {
+                                                                                       item = elm_list_at_xy_item_get((Evas_Object*)(parent_info->address), x + w + w/2, y + h/2, NULL);
+                                                                               }
+                                                                       } else if (NULL != widget_type && !strcmp(widget_type, "Elm_Gengrid")) {
+                                                                               int xposret, yposret;
+                                                                               item = elm_gengrid_at_xy_item_get((Evas_Object*)(parent_info->address), x + w/2, y + h/2, &xposret, &yposret);
+                                                                       }
+                                                                       VC_ELM_LOG_DBG("item(%p)(%d)", item, elm_object_item_disabled_get(item));
+
+                                                                       if (NULL != item && EINA_FALSE == elm_object_item_disabled_get(item)) {
+                                                                               VC_ELM_LOG_DBG("Click event");
+                                                                               if (EINA_TRUE == elm_object_item_focus_get(item)) {
+                                                                                       VC_ELM_LOG_DBG("Already focused");
+                                                                                       ecore_timer_add(g_click_time, __click_event, NULL);
+                                                                               } else {
+                                                                                       evas_object_smart_callback_add((Evas_Object*)(parent_info->address), "item,focused", __focused_cb, "item,focused");
+                                                                                       elm_object_item_focus_set(item, EINA_TRUE);
+                                                                                       elm_object_focus_set((Evas_Object*)(parent_info->address), EINA_TRUE);
+                                                                               }
+                                                                               text_found = EINA_TRUE;
+                                                                               break;
+                                                                       }
+                                                               }
+                                                               parent_info = ea_object_dump_parent_widget_data_get(parent_info);
+                                                       }
+                                               }
+                                       }
+                               } else {
+                                       VC_ELM_LOG_DBG("Invalid click method");
+                               }
+
+                               /* Propagation */
+                               //return EINA_TRUE;
+                               text_found = EINA_TRUE;
+                       }
+                       //                              }
+                       //                      }
+               }
+       }
+       ea_object_dump_list_clear();
+       g_dump_list = NULL;
+
+       return text_found;
+}
+
+
+
 /**
  * @brief Function that matches recognition result to the registered actions
  *             and calls for action execution
@@ -388,10 +510,18 @@ Eina_Bool _recognize_command(const char *cmd, const char *param1, const char *pa
                int auto_mode = 0;
                int click_method = 0;
                _vc_elm_get_auto_register_mode(&auto_mode, &click_method);
+
+               Eina_Bool ret;
                if (1 == auto_mode) {
-                       Eina_Bool ret = _vc_elm_click_matched_object(cmd, click_method);
-                       return ret;
+                       /* for Apps */
+                       VC_ELM_LOG_DBG("for App : vt_auto is FALSE");
+                       ret = _vc_elm_click_matched_object(cmd, click_method);
+               } else if (2 == auto_mode) {
+                       /* for App FW */
+                       VC_ELM_LOG_DBG("for AppFW : vt_auto is TRUE");
+                       ret = _vc_elm_click_matched_object_vt_auto(cmd, click_method);
                }
+               return ret;
        }
 
        return EINA_FALSE;
@@ -1053,6 +1183,8 @@ void _vc_elm_core_register_action(struct vc_elm_core_widget_info *info, const ch
 
 static int __vc_add_commands_for_automode()
 {
+       VC_ELM_LOG_DBG("inside __vc_add_commands_for_automode()");
+
        if (NULL != g_dump_list) {
                ea_object_dump_list_clear();
                g_dump_list = NULL;
@@ -1080,8 +1212,40 @@ static int __vc_add_commands_for_automode()
        return 0;
 }
 
+static int __vc_add_commands_for_automode_vt_auto()
+{
+       VC_ELM_LOG_DBG("inside __vc_add_commands_for_automode_vt_auto()");
+       if (NULL != g_dump_list) {
+               ea_object_dump_list_clear();
+               g_dump_list = NULL;
+       }
+       g_dump_list = ea_object_dump_full_list_get(EINA_TRUE);
+       VC_ELM_LOG_DBG("Count (%d)", eina_list_count(g_dump_list));
+
+       Eina_List *dump_iter = NULL;
+       void *data = NULL;
+       EINA_LIST_FOREACH(g_dump_list, dump_iter, data) {
+               Object_Info* info = (Object_Info*)data;
+
+               if (NULL != info && NULL != info->text /*&& NULL != info->part_name*/) {
+//                     Eina_List *iter = NULL;
+//                     char *part_name = NULL;
+//                     EINA_LIST_FOREACH(g_allowed_text_part_list, iter, part_name) {
+//                             if (NULL != part_name && !strcmp(part_name, info->part_name)) {
+                                       VC_ELM_LOG_DBG("Text (%s), Part(%s)", info->text, info->part_name);
+                                       VC_ELM_LOG_DBG("x(%d) y(%d) w(%d) h(%d)", info->geometry_info.x, info->geometry_info.y, info->geometry_info.w, info->geometry_info.h);
+                                       _vc_elm_widget_wrapper_add_command(info->text, NULL);
+//                             }
+//                     }
+               }
+       }
+       return 0;
+}
+
 static void __vc_add_commands()
 {
+       VC_ELM_LOG_DBG("inside __vc_add_commands()");
+
        Eina_List *_l;
        Evas_Object *obj;
        size_t idx;
@@ -1200,10 +1364,17 @@ static void __vc_add_commands()
        _vc_elm_get_auto_register_mode(&auto_mode, &click_method);
        VC_ELM_LOG_DBG("Auto mode (%d) Click method (%d)", auto_mode, click_method);
        if (1 == auto_mode) {
-               if (0 != __vc_add_commands_for_automode()) {
-                       VC_ELM_LOG_ERR("Fail to add command in auto mode");
-               }
+               /* for Apps */
+               VC_ELM_LOG_DBG("for App : vt_auto is FALSE");
+               __vc_add_commands_for_automode();
+       } else if (2 == auto_mode) {
+               /* for App FW */
+               VC_ELM_LOG_DBG("for AppFW : vt_auto is TRUE");
+               __vc_add_commands_for_automode_vt_auto();
        }
+//             if (0 != __vc_add_commands_for_automode()) {
+//                     VC_ELM_LOG_ERR("Fail to add command in auto mode");
+//             }
 
        _vc_elm_widget_wrapper_commit_commands(&__result_cb, NULL);
 }