Add vconf changed callback and Fix warning 66/131466/2 accepted/tizen/unified/20170531.082759 submit/tizen/20170530.103023
authorsooyeon.kim <sooyeon.kim@samsung.com>
Mon, 29 May 2017 09:40:46 +0000 (18:40 +0900)
committersooyeon.kim <sooyeon.kim@samsung.com>
Tue, 30 May 2017 09:47:49 +0000 (18:47 +0900)
Change-Id: I416ca7e72cd1d7116f80abc6bf05dd631f984302
Signed-off-by: sooyeon.kim <sooyeon.kim@samsung.com>
include/voice_control_elm_private.h
src/vc_elm.c
src/vc_elm_core.c
src/vc_elm_core_default_widgets.c
src/vc_elm_efl_dump.c

index e8e1287b23f5daa3dce46ca97c11b47cf577f6b1..e9d680a6d4d676cef69ebe3a35c277cfcf334281 100644 (file)
@@ -116,7 +116,7 @@ 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);
+int vc_elm_is_supported_vt_auto(int* is_vt_automode);
 
 #ifdef __cplusplus
 }
index 19fd3ec0ae2a89bbca1f33eeca9fa1411e6f384b..12ba9923a80e2afbe1dfbf9ff5acc55cc6ea6be8 100644 (file)
 */
 static unsigned is_vc_elm_initialized = false;
 
+/**
+* @brief An internal variable for checking whether voice touch's auto mode is ON or not.
+*/
+static int g_is_vt_automode = 0;
+
 /**
  * @brief App domain name of the current app.
  */
@@ -109,7 +114,7 @@ static int __check_privilege_initialize()
        int ret = cynara_initialize(&p_cynara, NULL);
        if (CYNARA_API_SUCCESS != ret)
                VC_ELM_LOG_ERR("[ERROR] fail to initialize");
-       
+
        return ret == CYNARA_API_SUCCESS;
 }
 
@@ -172,7 +177,17 @@ static int __vc_elm_check_privilege()
        }
 
        g_privilege_allowed = 1;
-       return VC_ELM_ERROR_NONE;       
+       return VC_ELM_ERROR_NONE;
+}
+
+void __vc_config_vtauto_changed_cb(keynode_t *key, void *data)
+{
+       int ret = vconf_get_bool(VCONFKEY_VC_VOICE_TOUCH_AUTOMODE, &g_is_vt_automode);
+       if (0 != ret) {
+               VC_ELM_LOG_ERR("Fail to get vconfkey(%s), current voice touch mode(%d)", key, g_is_vt_automode);
+       }
+
+       return;
 }
 
 int vc_elm_initialize()
@@ -196,6 +211,11 @@ int vc_elm_initialize()
 
        is_vc_elm_initialized = true;
 
+       /* Initialize voice touch's automode and Register to detect voice touch automode change */
+       vconf_get_bool(VCONFKEY_VC_VOICE_TOUCH_AUTOMODE, &g_is_vt_automode);
+
+       vconf_notify_key_changed(VCONFKEY_VC_VOICE_TOUCH_AUTOMODE, __vc_config_vtauto_changed_cb, NULL);
+
        VC_ELM_LOG_DBG("vc elm is initialized");
        return VC_ELM_ERROR_NONE;
 }
@@ -223,10 +243,14 @@ int vc_elm_deinitialize()
                eina_list_free(g_handlers_list);
        }
 
+       vconf_ignore_key_changed(VCONFKEY_VC_VOICE_TOUCH_AUTOMODE, __vc_config_vtauto_changed_cb);
+
        _vc_elm_core_fini();
 
-       if (NULL != g_app_domain)
+       if (NULL != g_app_domain) {
                free(g_app_domain);
+               g_app_domain = NULL;
+       }
 
        is_vc_elm_initialized = false;
        VC_ELM_LOG_DBG("shutting down vc_elm");
@@ -938,32 +962,16 @@ int _vc_elm_get_text_domain(char **domain)
        return VC_ELM_ERROR_NONE;
 }
 
-int _vc_elm_is_supported_vt_auto(bool* is_vt_automode)
+int vc_elm_is_supported_vt_auto(int* 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;
-       }
+       *is_vt_automode = g_is_vt_automode;
+       VC_ELM_LOG_DBG("Success to get vconfkey(%d)", *is_vt_automode);
 
-       return _vc_elm_is_supported_vt_auto(is_vt_automode);
+       return VC_ELM_ERROR_NONE;
 }
 
 int _vc_elm_set_auto_register_mode(int mode, int click_method)
@@ -978,19 +986,14 @@ int _vc_elm_set_auto_register_mode(int mode, int click_method)
 
 int _vc_elm_get_auto_register_mode(int* mode, int* click_method)
 {
-       bool is_vt_auto;
-       if (0 != _vc_elm_is_supported_vt_auto(&is_vt_auto)) {
-               return VC_ELM_ERROR_OPERATION_FAILED;
+       if (0 == g_is_vt_automode) {
+               VC_ELM_LOG_DBG("vt_automode is FALSE");
+               *mode = g_auto_mode;
+               *click_method = g_click_method;
        } 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("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);
@@ -1004,17 +1007,12 @@ 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;
+       if (0 == g_is_vt_automode) {
+               VC_ELM_LOG_DBG("vt_automode is FALSE");
+               return _vc_elm_set_auto_register_mode(mode, click_method);
        } 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);
-               }
+               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 3c32ce785217aeceb5a420a6601217eb77aaa666..d0cab60fc47e5f1f10cb7bc82030966545c9e6ac 100644 (file)
@@ -299,7 +299,7 @@ static Eina_Bool _vc_elm_click_matched_object(const char* cmd, int click_method)
                                                                while (NULL != parent_info) {
                                                                        if (EINA_TRUE == parent_info->focusable) {
                                                                                VC_ELM_LOG_DBG("Focusable Parent");
-                                                                               char* widget_type = elm_widget_type_get((Evas_Object*)(parent_info->address));
+                                                                               const char* widget_type = elm_widget_type_get((const 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")) {
@@ -411,7 +411,7 @@ static Eina_Bool _vc_elm_click_matched_object_vt_auto(const char* cmd, int click
                                                        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));
+                                                                       const char* widget_type = elm_widget_type_get((const 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")) {
@@ -503,7 +503,7 @@ Eina_Bool _recognize_command(const char *cmd, const char *param1, const char *pa
                }
 
                VC_ELM_LOG_DBG("command(%s)", temp);
-               char* action = NULL;
+               const char* action = NULL;
                if (strlen(cmd) > strlen(temp)) {
                        action = &cmd[strlen(temp) + 1];
                        VC_ELM_LOG_DBG("action(%s)", &cmd[strlen(temp) + 1]);
@@ -727,7 +727,7 @@ static Eina_List *__get_objects_of_visible_items(Evas_Object *parent, Elm_Object
                }
 
                evas_object_geometry_get(obj, &x_1, &y_1, &w_1, &h_1);
-               name = elm_widget_type_get(obj);
+               name = elm_widget_type_get((const Evas_Object *)obj);
                if (NULL != name && NULL == eina_hash_find(registered_item_map, name) && NULL != eina_hash_find(g_config_widget_map, name)) {
                        Eina_List *list2 = eina_hash_find(g_config_widget_map, name);
                        VC_ELM_LOG_DBG("CORE LIST action size %u", eina_list_count(list2));
@@ -1280,14 +1280,14 @@ static int __vc_add_commands_for_automode_vt_auto()
                                        Object_Info* parent = ea_object_dump_parent_widget_data_get(info);
                                        Object_Info* grand = ea_object_dump_parent_widget_data_get(parent);
 
-                                       char *widget_type = NULL;
-                                       widget_type = elm_widget_type_get((Evas_Object*)grand->address);
+                                       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((Evas_Object*)grand->address);
+                                               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), elm_widget_type_get((Evas_Object*)parent->address), widget_type);
@@ -2094,7 +2094,7 @@ static Eina_Bool __idle_enter(void *data)
        VC_ELM_LOG_DBG("Focused g_default %ud", elm_win_xwindow_get(g_default_window));
        if (!is_focused) {
                /* window changed, we need to get new one */
-               int count = eina_list_count(ui_objects_list);
+               unsigned int count = eina_list_count(ui_objects_list);
                VC_ELM_LOG_DBG("list count %d", count);
                if (0 == count) {
                        /* TODO - get window object */
@@ -2102,7 +2102,6 @@ static Eina_Bool __idle_enter(void *data)
                        Ecore_Evas *ee = NULL;
                        Evas *evas = NULL;
                        Eina_List *objs = NULL;
-                       Evas_Object *obj = NULL;
                        Evas_Object *window = NULL;
                        EINA_LIST_FREE(ecore_evas_list, ee) {
                                evas = ecore_evas_get(ee);
index 73ed5c25df95f507e05237476c99986848c4cbf2..bdd95b0b167730a52ab61bc40c301f1323429ee9 100644 (file)
@@ -206,7 +206,7 @@ static void __vc_elm_click_by_focus(Evas_Object *obj)
 {
        VC_ELM_LOG_DBG("obj(%p)", (void*)obj);
 
-       if (NULL != elm_widget_type_get(obj)) {
+       if (NULL != elm_widget_type_get((const Evas_Object *)obj)) {
                if (EINA_TRUE == elm_object_focus_get(obj)) {
                        VC_ELM_LOG_DBG("Already focused");
                        ecore_timer_add(g_click_time, __click_event, NULL);
@@ -233,7 +233,7 @@ static void __vc_elm_click_by_focus(Evas_Object *obj)
        }
 }
 
-static void __emulate_click(const Evas_Object *obj)
+static void __emulate_click(Evas_Object *obj)
 {
        int auto_mode = 0;
        int click_method = 0;
@@ -694,7 +694,7 @@ static void __set_tooltips_position_on_visible_items(Evas_Object *parent, Elm_Ob
                evas_object_geometry_get(obj, &x_1, &y_1, &w_1, &h_1);
 
                if (x_1 + (w_1 / 2) >= x && y_1 + (h_1 / 2) >= y && (x_1 + (w_1 / 2)) <= (x + w) && (y_1 + (h_1 / 2)) <= (y + h)) {
-                       const char *name = elm_widget_type_get(obj);
+                       const char *name = elm_widget_type_get((const Evas_Object *)obj);
                        if (name == NULL) {
                                char *item_string = NULL;
                                if (NULL != (item_string = evas_object_data_get(obj, VC_ELM_HINT_DATA_KEY)))
@@ -1037,7 +1037,7 @@ static void __sub_layout_inspect(Eina_List *ret, Evas_Object *widget)
        (void)widget;
 
        EINA_LIST_FOREACH(list, l, obj) {
-               const char *type = elm_widget_type_get(obj);
+               const char *type = elm_widget_type_get((const Evas_Object *)obj);
                if (type && !strcmp(type, "Elm_Layout")) {
                        evas_object_data_set(obj, VC_ELM_COLORSELECTOR_PARENT, widget);
                        evas_object_data_set(obj, _vc_elm_get_custom_widget_name(), "Elm_Button");
@@ -1341,7 +1341,7 @@ static Eina_List *__entry_get_subwidgets(const Evas_Object *entry, void *user_da
        list = elm_widget_can_focus_child_list_get(entry);
 
        EINA_LIST_FOREACH(list, l, obj) {
-               const char *type = elm_widget_type_get(obj);
+               const char *type = elm_widget_type_get((const Evas_Object *)obj);
                const char *part = elm_object_part_text_get(obj, "mbe.label");
                if (part)
                        continue;
index 8cdfc202998eff107db008fb489d5f68b367993a..04604f1e15421992c181957cf8aa52b268293f6d 100644 (file)
@@ -23,6 +23,8 @@
 #include "vc_elm_tools.h"
 #include "vc_elm_efl_dump.h"
 
+#include <voice_control_elm_private.h>
+
 #define EVAS_OBJECT_DUMP_DEBUG
 #ifdef EVAS_OBJECT_DUMP_DEBUG
 #define VC_ELM_LOG_DUMP(fmt, ...) SLOGD("\033[0;32m" fmt "\033[m", ## __VA_ARGS__)
@@ -60,9 +62,9 @@ static int g_geo_x = 0, g_geo_y = 0, g_geo_w = 0, g_geo_h = 0;
 static int find_popup = 0;
 static int skip_text = 0;
 
-bool vc_elm_efl_dump_is_vt_auto_enabled()
+int vc_elm_efl_dump_is_vt_auto_enabled()
 {
-       bool is_vt_automode = false;
+       int is_vt_automode = 0;
        int ret = vc_elm_is_supported_vt_auto(&is_vt_automode);
        if (0 != ret) {
                VC_ELM_LOG_DUMP("Fail to check vt auto mode");
@@ -341,7 +343,7 @@ static Eina_Bool _is_descendant_of_list(Object_Info *object_info)
 {
        Object_Info* parent_info = ea_object_dump_parent_widget_data_get(object_info);
        while (NULL != parent_info) {
-               const char* widget_type = elm_widget_type_get((Evas_Object*)(parent_info->address));
+               const char* widget_type = elm_widget_type_get((const Evas_Object*)(parent_info->address));
                if (NULL != widget_type) {
                        VC_ELM_LOG_DUMP("[DEBUG] object_type(%s), widget_type(%s)", evas_object_type_get((Evas_Object*)(parent_info->address)), widget_type);
                        if (!strcmp(widget_type, "Elm_Genlist") || !strcmp(widget_type, "Elm_Gengrid") || !strcmp(widget_type, "Elm_List") || !strcmp(widget_type, "Elm_Ctxpopup") || !strcmp(widget_type, "Elm_Index"))
@@ -356,7 +358,7 @@ static Eina_Bool _is_descendant_of_toolbar(Object_Info *object_info)
 {
        Object_Info* parent_info = ea_object_dump_parent_widget_data_get(object_info);
        while (NULL != parent_info) {
-               const char* widget_type = elm_widget_type_get((Evas_Object*)(parent_info->address));
+               const char* widget_type = elm_widget_type_get((const Evas_Object*)(parent_info->address));
                if (NULL != widget_type) {
                        VC_ELM_LOG_DUMP("[DEBUG] object_type(%s), widget_type(%s)", evas_object_type_get((Evas_Object*)(parent_info->address)), widget_type);
                        if (!strcmp(widget_type, "Elm_Toolbar"))
@@ -535,7 +537,7 @@ _obj_tree_items_exclude_unfocusable_text(Ea_Util_Mgr *util_mgr, Evas_Object *obj
        }
 
        text = NULL;
-       if (false == vc_elm_efl_dump_is_vt_auto_enabled()) {
+       if (0 == vc_elm_efl_dump_is_vt_auto_enabled()) {
                if (!strcmp(evas_object_type_get(obj), "text"))
                        text = eina_stringshare_add(evas_object_text_text_get(obj));
                else if (!strcmp(evas_object_type_get(obj), "textblock")) {