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)
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);
{
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);
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);
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;
{
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));
_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)
_ERR("!priv");
return NULL;
}
- return (Eina_List *)priv->voice_control_is_on;
+ return priv->voice_control_is_on;
}
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);
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);