Add to register allowed part as candidate cmd 23/152623/1
authorWonnam Jang <wn.jang@samsung.com>
Mon, 25 Sep 2017 11:08:29 +0000 (20:08 +0900)
committerWonnam Jang <wn.jang@samsung.com>
Tue, 26 Sep 2017 13:45:43 +0000 (13:45 +0000)
Change-Id: Ibb786944b0f6fbc280f7fc6e2b24168e38fd6bb0
Signed-off-by: Wonnam Jang <wn.jang@samsung.com>
(cherry picked from commit 36e7a11f05fe9a14f7bee293685f72ccccd38110)

src/vc_elm_core.c
src/vc_elm_core.h
src/vc_elm_efl_dump.c

index 3bdc4e5..1ac1d9e 100644 (file)
@@ -307,6 +307,11 @@ static Eina_Bool _vc_elm_click_matched_object(const char* cmd, int click_method)
                                                                                        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);
@@ -1262,61 +1267,70 @@ static int __vc_add_commands_for_automode_vt_auto()
        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);
-                                       Object_Info* parent = ea_object_dump_parent_widget_data_get(info);
-                                       Object_Info* grand = ea_object_dump_parent_widget_data_get(parent);
-                                       if (NULL != parent && NULL != grand) {
-                                               const char *widget_type = NULL;
-                                               widget_type = elm_widget_type_get((const Evas_Object*)grand->address);
-                                               while (NULL == widget_type) {
-                                                       grand = ea_object_dump_parent_widget_data_get(grand);
-                                                       if (NULL == grand) {
-                                                               break;
-                                                       }
-                                                       widget_type = elm_widget_type_get((const Evas_Object*)grand->address);
-                                               }
+               if (NULL != info && NULL != info->text) {
+                       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);
+                       Object_Info* parent = ea_object_dump_parent_widget_data_get(info);
+                       Object_Info* grand = ea_object_dump_parent_widget_data_get(parent);
+
+                       const char *widget_type = NULL;
+                       if (NULL != parent && NULL != grand) {
+                               widget_type = elm_widget_type_get((const Evas_Object*)grand->address);
+                               while (NULL == widget_type) {
+                                       grand = ea_object_dump_parent_widget_data_get(grand);
+                                       if (NULL == grand) {
+                                               break;
+                                       }
+                                       widget_type = elm_widget_type_get((const Evas_Object*)grand->address);
+                               }
+                       }
+                       VC_ELM_LOG_DBG("info(%s) parent(%s) grand(%s)", elm_widget_type_get((Evas_Object*)info->address), (!parent) ? "NULL" : elm_widget_type_get((Evas_Object*)parent->address), widget_type);
+                       // VC_ELM_LOG_DBG("info(%s) parent(%s) grand(%s)", evas_object_type_get((Evas_Object*)info->address), evas_object_type_get((Evas_Object*)parent->address), evas_object_type_get((Evas_Object*)grand->address));
 
-                                               VC_ELM_LOG_DBG("info(%s) parent(%s) grand(%s)", elm_widget_type_get((Evas_Object*)info->address), elm_widget_type_get((Evas_Object*)parent->address), widget_type);
-                                               // VC_ELM_LOG_DBG("info(%s) parent(%s) grand(%s)", evas_object_type_get((Evas_Object*)info->address), evas_object_type_get((Evas_Object*)parent->address), evas_object_type_get((Evas_Object*)grand->address));
-
-                                               if (NULL != widget_type && (!strcmp(widget_type, "Elm_Genlist") || !strcmp(widget_type, "Elm_Gengrid") || !strcmp(widget_type, "Elm_List"))) {
-                                                       int x = info->geometry_info.x;
-                                                       int y = info->geometry_info.y;
-                                                       int w = info->geometry_info.w;
-                                                       int h = info->geometry_info.h;
-                                                       Elm_Object_Item *it = __vc_elm_core_get_object_item_from_geometry_info((Evas_Object*)grand->address, widget_type, x, y, w, h);
-                                                       if (NULL != it) {
-                                                               _vc_elm_core_set_auto_item_object_command(it, info->text);
-                                                               VC_ELM_LOG_DBG("Get object from geometry(%p)", it);
-                                                       }
-                                               } else if (NULL != widget_type && (!strcmp(widget_type, "Elm_Toolbar"))) {
-                                                       Elm_Object_Item *it = elm_toolbar_item_find_by_label((Evas_Object*)grand->address, info->text);
-                                                       if (NULL != it) {
-                                                               _vc_elm_core_set_auto_item_object_command(it, info->text);
-                                                               VC_ELM_LOG_DBG("Get object from label(%p)", it);
-                                                       }
-                                               } else if (NULL != widget_type && (!strcmp(widget_type, "Elm_Ctxpopup"))) {
-                                                       /* TODO */
-                                               } else {
-                                                       if (!_vc_elm_core_register_default_widget(_get_ui_object_name((Evas_Object*)info->address), EINA_FALSE, NULL) || (NULL == eina_hash_find(_vc_elm_core_get_config_widget_map(), elm_widget_type_get((Evas_Object*)info->address)))) {
-                                                               VC_ELM_LOG_ERR("Not supported widget");
-                                                       }
-                                                       _vc_elm_core_set_auto_object_command((Evas_Object*)info->address, info->text);
-                                               }
-                                       } else {
-                                               if (!_vc_elm_core_register_default_widget(_get_ui_object_name((Evas_Object*)info->address), EINA_FALSE, NULL) || (NULL == eina_hash_find(_vc_elm_core_get_config_widget_map(), elm_widget_type_get((Evas_Object*)info->address)))) {
-                                                       VC_ELM_LOG_ERR("Not supported widget");
-                                               }
-                                               _vc_elm_core_set_auto_object_command((Evas_Object*)info->address, info->text);
+                       if (NULL != widget_type && (!strcmp(widget_type, "Elm_Genlist") || !strcmp(widget_type, "Elm_Gengrid") || !strcmp(widget_type, "Elm_List"))) {
+                               int x = info->geometry_info.x;
+                               int y = info->geometry_info.y;
+                               int w = info->geometry_info.w;
+                               int h = info->geometry_info.h;
+                               Elm_Object_Item *it = __vc_elm_core_get_object_item_from_geometry_info((Evas_Object*)grand->address, widget_type, x, y, w, h);
+                               if (NULL != it) {
+                                       _vc_elm_core_set_auto_item_object_command(it, info->text);
+                                       VC_ELM_LOG_DBG("Get object from geometry(%p)", it);
+                                       continue;
+                               }
+                       } else if (NULL != widget_type && (!strcmp(widget_type, "Elm_Toolbar"))) {
+                               Elm_Object_Item *it = elm_toolbar_item_find_by_label((Evas_Object*)grand->address, info->text);
+                               if (NULL != it) {
+                                       _vc_elm_core_set_auto_item_object_command(it, info->text);
+                                       VC_ELM_LOG_DBG("Get object from label(%p)", it);
+                                       continue;
+                               }
+                       } else if (NULL != widget_type && (!strcmp(widget_type, "Elm_Ctxpopup"))) {
+                               /* TODO */
+                               VC_ELM_LOG_ERR("TODO - Elm_Ctxpopup");
+                       } else {
+                               VC_ELM_LOG_ERR("Not supported widget manually");
+                       }
+               }
+               if (NULL != info) {
+                       if (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_ERR("Widget is supported automatically with part name");
+                                               _vc_elm_widget_wrapper_add_command(info->text, NULL);
                                        }
-//                             }
-//                     }
+                               }
+                       } else {
+                               if (!_vc_elm_core_register_default_widget(_get_ui_object_name((Evas_Object*)info->address), EINA_FALSE, NULL) 
+                                       || (NULL == eina_hash_find(_vc_elm_core_get_config_widget_map(), elm_widget_type_get((Evas_Object*)info->address)))) {
+                                       VC_ELM_LOG_ERR("Not supported widget");
+                               }
+                               _vc_elm_core_set_auto_object_command((Evas_Object*)info->address, info->text);
+                               continue;
+                       }
                }
        }
 
@@ -2189,7 +2203,7 @@ int _vc_elm_core_read_xml_data()
        VC_ELM_LOG_DBG("reading XML start");
        doc = xmlParseFile(VC_ELM_CONFIG_XML);
        if (doc == NULL) {
-               VC_ELM_LOG_ERR("Failed to parse XML file");
+               VC_ELM_LOG_ERR("Failed to parse XML file, path(%s)", VC_ELM_CONFIG_XML);
                return VC_ELM_ERROR_OPERATION_FAILED;
        }
 
index 0b5de30..b241a20 100644 (file)
@@ -32,7 +32,7 @@ extern "C" {
  */
 
 //#define VC_ELM_CONFIG_XML            VOICE_LIBDIR"/voice/vc-elm/1.0/voice-control-elm-config.xml"
-#define VC_ELM_CONFIG_XML              tzplatform_mkpath(TZ_SYS_RO_SHARE, "voice/vc-elm/1.0/voice-control-elm-config.xml")
+#define VC_ELM_CONFIG_XML              tzplatform_mkpath(tzplatform_getid("TZ_SYS_RO_SHARE"), "voice/vc-elm/1.0/voice-control-elm-config.xml")
 #define VC_ELM_TAG_BASE_NAME           "voice-control-elm-config"
 
 #define VC_ELM_TAG_ACTION_LIST         "action-list"
index b71ec35..db8ccb7 100644 (file)
@@ -377,6 +377,32 @@ static Eina_Bool _is_descendant_of_toolbar(Object_Info *object_info)
        return EINA_FALSE;
 }
 
+static Eina_Bool _has_accessible_name(Object_Info *object_info)
+{
+       Object_Info* parent_info = ea_object_dump_parent_widget_data_get(object_info);
+       while (NULL != parent_info) {
+               char* text = NULL;
+               Evas_Object *obj = (Evas_Object *)(parent_info->address);
+               const char* widget_type = elm_widget_type_get(obj);
+
+               if (NULL != widget_type) {
+                       if (elm_atspi_accessible_name_get(obj) && EINA_TRUE == parent_info->focusable && EINA_TRUE == _is_clickable_object(obj)) {
+                               text = elm_atspi_accessible_name_get(obj);
+                               VC_ELM_LOG_DUMP("####### [DEBUG] atspi_text(%s)", text);
+                       } else if (elm_atspi_accessible_name_get(obj) && !strcmp(widget_type, "Elm_Toolbar")) {
+                               text = elm_atspi_accessible_name_get(obj);
+                               VC_ELM_LOG_DUMP("####### [DEBUG] toolbar(%s)", text);
+                       }
+               }
+               if (NULL != text) {
+                       VC_ELM_LOG_DUMP("####### [DEBUG] widget_type(s), text(%s)", widget_type, text);
+                       return EINA_TRUE;
+               }
+               parent_info = ea_object_dump_parent_widget_data_get(parent_info);
+       }
+       return EINA_FALSE;
+}
+
 static void
 _obj_tree_items_exclude_unfocusable_text(Ea_Util_Mgr *util_mgr, Evas_Object *obj, Object_Info *parent, Eina_Bool parent_widget_focusable, Eina_Bool list_type, int cnt)
 {
@@ -582,6 +608,23 @@ _obj_tree_items_exclude_unfocusable_text(Ea_Util_Mgr *util_mgr, Evas_Object *obj
                } else if (elm_atspi_accessible_name_get(obj) && !strcmp(evas_object_type_get(obj), "elm_layout") && EINA_TRUE == _is_descendant_of_toolbar(object_info)) {
                        text = elm_atspi_accessible_name_get(obj);
                        VC_ELM_LOG_DUMP("####### [DEBUG] toolbar(%s)", text);
+               } else {
+                       if (EINA_FALSE == _has_accessible_name(object_info)) {
+                               if (!strcmp(evas_object_type_get(obj), "text")) {
+                                       text = eina_stringshare_add(evas_object_text_text_get(obj));
+                                       VC_ELM_LOG_DUMP("####### [DEBUG] text(%s), part_name(%s)", text, object_info->part_name);
+                               } else if (!strcmp(evas_object_type_get(obj), "textblock")) {
+                                       ret = evas_object_textblock_text_markup_get(obj);
+                                       temp = evas_textblock_text_markup_to_utf8(obj, ret);
+                                       text = eina_stringshare_add(temp);
+                                       VC_ELM_LOG_DUMP("####### [DEBUG] textblock(%s), part_name(%s)", text, object_info->part_name);
+
+                                       if (NULL != temp) {
+                                               free(temp);
+                                               temp = NULL;
+                                       }
+                               }
+                       }
                }
        }
        if (text && strlen(text) > 0) {
@@ -909,6 +952,7 @@ Object_Info*
 ea_object_dump_parent_widget_data_get(const Object_Info *obj_info)
 {
        if (NULL == obj_info) {
+               VC_ELM_LOG_DUMP("obj_info is NULL");
                return NULL;
        }