--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef INCLUDE_DATA_SYSTEM_SETTINGS_VOICE_CONTROL_H_
+#define INCLUDE_DATA_SYSTEM_SETTINGS_VOICE_CONTROL_H_
+
+#include "common/datamgr.h"
+
+struct data_class *get_voice_control_data_class(void);
+
+#endif /* INCLUDE_DATA_SYSTEM_SETTINGS_VOICE_CONTROL_H_ */
BuildRequires: cmake
BuildRequires: gettext-tools
-BuildRequires: pkgconfig(libtzplatform-config)
+BuildRequires: pkgconfig(alarm-service)
BuildRequires: pkgconfig(elementary)
BuildRequires: pkgconfig(capi-appfw-application)
BuildRequires: pkgconfig(capi-appfw-preference)
BuildRequires: pkgconfig(capi-base-utils-i18n)
BuildRequires: pkgconfig(capi-network-wifi)
BuildRequires: pkgconfig(capi-network-connection)
+BuildRequires: pkgconfig(libtzplatform-config)
BuildRequires: pkgconfig(tv-service)
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(vconf)
-BuildRequires: pkgconfig(alarm-service)
+BuildRequires: pkgconfig(voice-control)
+BuildRequires: pkgconfig(voice-control-setting)
+
Requires(post): /usr/bin/vconftool
%define _appdir %{TZ_SYS_RO_APP}/%{name}
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <voice_control_common.h>
+#include <voice_control_setting.h>
+#include "app_debug.h"
+#include "data/system/settings_voice_control.h"
+
+static void *_create(void (*event_cb)(enum event_type type, void *data),
+ void *cb_data);
+static bool _destroy(void *data);
+static bool _update(void *data);
+static bool _select(void *dclass_data, Elm_Object_Item *it, void *data);
+static Eina_List *_get_data(void *dclass_data);
+
+static struct data_class vc_class = {
+ .create = _create,
+ .destroy = _destroy,
+ .update = _update,
+ .select = _select,
+ .get_data = _get_data
+};
+
+typedef struct {
+ void (*event_cb)(enum event_type type, void *data);
+ void *cb_data;
+ bool voice_control_is_on;
+} private_data;
+
+struct data_class *get_voice_control_data_class(void)
+{
+ return &vc_class;
+}
+
+static void _voice_control_changed_cb(bool enabled, void *data)
+{
+ private_data *priv = data;
+
+ if (!priv) {
+ _ERR("!priv");
+ return;
+ }
+
+ priv->voice_control_is_on = enabled;
+
+ if (priv->event_cb)
+ priv->event_cb(EVENT_DATA_CHANGED, priv->cb_data);
+}
+
+static void *_create(void (*event_cb)(enum event_type type, void *data),
+ void *cb_data)
+{
+ private_data *priv = NULL;
+ int ret = VC_ERROR_NONE;
+
+ priv = calloc(1, sizeof(private_data));
+
+ if (!priv)
+ {
+ _ERR("Memory allocation error");
+ abort();
+ return NULL;
+ }
+
+ priv->event_cb = event_cb;
+ priv->cb_data = cb_data;
+
+ ret = vc_setting_set_enabled_changed_cb(_voice_control_changed_cb , priv);
+ if (VC_ERROR_NONE != ret) {
+ free(priv);
+ _ERR("VC callback set error: %s", get_error_message(ret));
+ return NULL;
+ }
+
+ ret = vc_setting_get_enabled(&(priv->voice_control_is_on));
+
+ if (VC_ERROR_NONE != ret) {
+ free(priv);
+ _ERR("VC get enabled error: %s", get_error_message(ret));
+ return NULL;
+ }
+
+ return priv;
+}
+
+static bool _destroy(void *data)
+{
+ int ret = vc_setting_unset_enabled_changed_cb();
+ if (VC_ERROR_NONE != ret) {
+ _ERR("VC unset callback error: %s", get_error_message(ret));
+ }
+ return (VC_ERROR_NONE == ret);
+}
+
+static bool _update(void *data)
+{
+ int ret = VC_ERROR_NONE;
+ private_data *priv = NULL;
+ ret = vc_setting_get_enabled(&(priv->voice_control_is_on));
+
+ if (VC_ERROR_NONE != ret) {
+ _ERR("VC get enabled error: %s", get_error_message(ret));
+ return false;
+ }
+
+ if (priv->event_cb)
+ priv->event_cb(EVENT_DATA_UPDATE_DONE, priv->cb_data);
+
+ return true;
+}
+
+static bool _select(void *dclass_data, Elm_Object_Item *it, void *data)
+{
+ bool request_on = data;
+ private_data *priv = dclass_data;
+ int ret = vc_setting_set_enabled(request_on);
+
+ if (VC_ERROR_NONE != ret) {
+ _ERR("VC set enable %d error: %s", request_on, get_error_message(ret));
+ return false;
+ } else {
+ priv->voice_control_is_on = request_on;
+ }
+
+ if (priv->event_cb)
+ priv->event_cb(EVENT_DATA_SELECT_DONE, priv->cb_data);
+
+ return true;
+}
+
+static Eina_List *_get_data(void *dclass_data)
+{
+ private_data *priv = dclass_data;
+
+ if (!priv) {
+ _ERR("!priv");
+ return NULL;
+ }
+ return (Eina_List *)priv->voice_control_is_on;
+}