Voice control data model warning removed 38/124538/2
authorRadek Kintop <r.kintop@samsung.com>
Tue, 11 Apr 2017 13:26:30 +0000 (15:26 +0200)
committerRadek Kintop <r.kintop@samsung.com>
Wed, 12 Apr 2017 09:43:12 +0000 (11:43 +0200)
Change-Id: Ic13c0593932a2ddb0ab8e3c11d5b1048578f6790
Signed-off-by: Radek Kintop <r.kintop@samsung.com>
src/data/system/settings_voice_control.c
src/view/system/view_voice_control.c

index c1a7ad5..d77ff1d 100755 (executable)
@@ -40,7 +40,8 @@ static bool vc_initialised = false;
 typedef struct {
        void (*event_cb)(enum event_type type, void *data);
        void *cb_data;
-       bool voice_control_is_on;
+       Eina_List *voice_control_is_on; /* single data item,
+                                                                       inidicating if VC is on or off */
 } private_data;
 
 struct data_class *get_voice_control_data_class(void)
@@ -86,7 +87,7 @@ static void _voice_control_changed_cb(bool enabled, void *data)
                return;
        }
 
-       priv->voice_control_is_on = enabled;
+       eina_list_data_set(priv->voice_control_is_on, (void *)enabled);
 
        if (priv->event_cb)
                priv->event_cb(EVENT_DATA_CHANGED, priv->cb_data);
@@ -97,21 +98,28 @@ static void *_create(void (*event_cb)(enum event_type type, void *data),
 {
        private_data *priv = NULL;
        int ret = VC_ERROR_NONE;
+       bool enabled = false;
 
        priv = calloc(1, sizeof(private_data));
 
-       if (!priv)
-       {
+       if (!priv) {
                _ERR("Memory allocation error");
                abort();
                return NULL;
        }
 
+       priv->voice_control_is_on = eina_list_append(priv->voice_control_is_on,
+                                                                                               (void *)false);
+       if (!priv->voice_control_is_on) {
+               _ERR("List node allocation error");
+               abort();
+               return NULL;
+       }
+
        priv->event_cb = event_cb;
        priv->cb_data = cb_data;
 
-       if (!vc_initialised)
-       {
+       if (!vc_initialised) {
                ret = vc_setting_initialize();
                if (VC_ERROR_NONE != ret) {
                        free(priv);
@@ -135,7 +143,7 @@ static void *_create(void (*event_cb)(enum event_type type, void *data),
                return NULL;
        }
 
-       ret = vc_setting_get_enabled(&(priv->voice_control_is_on));
+       ret = vc_setting_get_enabled(&enabled);
 
        if (VC_ERROR_NONE != ret) {
                free(priv);
@@ -145,16 +153,26 @@ static void *_create(void (*event_cb)(enum event_type type, void *data),
                return NULL;
        }
 
+       eina_list_data_set(priv->voice_control_is_on, (void *)enabled);
+
        return priv;
 }
 
 static bool _destroy(void *data)
 {
-       int ret =  vc_setting_unset_enabled_changed_cb();
+       private_data *priv = data;
+       int ret = VC_ERROR_NONE;
+
+       if (!priv)
+               return false;
+
+       ret =  vc_setting_unset_enabled_changed_cb();
        if (VC_ERROR_NONE != ret) {
                _ERR("VC unset callback error: %s", get_error_message(ret));
        }
-       free(data);
+
+       priv->voice_control_is_on = eina_list_free(priv->voice_control_is_on);
+       free(priv);
 
        (void)vc_setting_deinitialize();
        vc_initialised = false;
@@ -166,7 +184,11 @@ static bool _update(void *data)
 {
        int ret = VC_ERROR_NONE;
        private_data *priv = data;
-       ret = vc_setting_get_enabled(&(priv->voice_control_is_on));
+       bool enabled = false;
+
+       ret = vc_setting_get_enabled(&enabled);
+
+       eina_list_data_set(priv->voice_control_is_on, (void *)enabled);
 
        if (VC_ERROR_NONE != ret) {
                _ERR("VC get enabled error: %s", get_error_message(ret));
@@ -189,7 +211,7 @@ static bool _select(void *dclass_data, Elm_Object_Item *it, void *data)
                _ERR("VC set enable %d error: %s", request_on, get_error_message(ret));
                return false;
        } else {
-               priv->voice_control_is_on = request_on;
+               eina_list_data_set(priv->voice_control_is_on, (void *)request_on);
        }
 
        if (priv->event_cb)
@@ -206,5 +228,5 @@ static Eina_List *_get_data(void *dclass_data)
                _ERR("!priv");
                return NULL;
        }
-       return (Eina_List *)priv->voice_control_is_on;
+       return priv->voice_control_is_on;
 }
index d21d1d6..fb92439 100644 (file)
@@ -150,15 +150,21 @@ static Evas_Object *_create(Evas_Object *win, void *data)
 static void _show(void *data)
 {
        private_data *priv = data;
-       bool on_off;
+       Eina_List *node = NULL;
+
        if (!priv) {
                _ERR("!priv");
                return;
        }
 
-       on_off = (Eina_Bool)datamgr_get_data(priv->data_mgr);
+       node = datamgr_get_data(priv->data_mgr);
+
+       if (!node) {
+               _ERR("datatmgr data is NULL");
+               return;
+       }
 
-       if (on_off) {
+       if (eina_list_data_get(node)) {
                elm_object_focus_set(priv->on_button, EINA_TRUE);
        } else {
                elm_object_focus_set(priv->off_button, EINA_TRUE);
@@ -222,15 +228,21 @@ static void _key_down_cb(int id, void *data, Evas *e, Evas_Object *obj,
 static void _vc_data_changed_cb(enum event_type type, void *data)
 {
        private_data *priv = data;
-       bool on_off;
+       Eina_List *node = NULL;
+
        if (!priv) {
                _ERR("!priv");
                return;
        }
 
-       on_off = (Eina_Bool)datamgr_get_data(priv->data_mgr);
+       node = datamgr_get_data(priv->data_mgr);
+
+       if (!node) {
+               _ERR("datatmgr data is NULL");
+               return;
+       }
 
-       if (on_off) {
+       if (eina_list_data_get(node)) {
                elm_object_focus_set(priv->on_button, EINA_TRUE);
        } else {
                elm_object_focus_set(priv->off_button, EINA_TRUE);