Voice control data model 95/122195/2
authorRadek Kintop <r.kintop@samsung.com>
Thu, 30 Mar 2017 12:36:26 +0000 (14:36 +0200)
committerRadek Kintop <r.kintop@samsung.com>
Thu, 30 Mar 2017 13:31:24 +0000 (15:31 +0200)
Change-Id: I741ca9a99c1ac5e2366a48097a9769bcc1de2d27
Signed-off-by: Radek Kintop <r.kintop@samsung.com>
CMakeLists.txt
include/common/datamgr.h
include/data/system/settings_voice_control.h [new file with mode: 0644]
packaging/org.tizen.settings.spec
src/data/system/settings_voice_control.c [new file with mode: 0644]

index 75ec452..9a6c7d8 100755 (executable)
@@ -32,6 +32,8 @@ pkg_check_modules(PKGS REQUIRED
                dlog
                alarm-service
                libtzplatform-config
+               voice-control
+               voice-control-setting
                )
 
 IF(NOT DEFINED PACKAGE_NAME)
@@ -78,6 +80,7 @@ SET(SRCS
        src/data/system/settings_wireless.c
        src/data/system/data_wired.c
        src/data/system/data_wireless.c
+       src/data/system/settings_voice_control.c
        src/grid/grid_sound.c
        src/grid/grid_wireless.c
        src/layout/layout_network.c
index e5eba98..9e326e1 100644 (file)
@@ -27,6 +27,7 @@ enum event_type {
        EVENT_DATA_INIT_FAIL_WIRELESS,
        EVENT_DATA_INVALID_PWD_WIRELESS,
        EVENT_DATA_UPDATE_DONE,
+       EVENT_DATA_CHANGED,
        EVENT_DATA_SELECT_DONE,
        EVENT_DATA_SELECT_FAIL,
        EVENT_DATA_UPDATE_WIRED,
diff --git a/include/data/system/settings_voice_control.h b/include/data/system/settings_voice_control.h
new file mode 100644 (file)
index 0000000..c3e5255
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * 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_ */
index 30c6c88..6b2c6d5 100755 (executable)
@@ -9,7 +9,7 @@ Source1: %{name}.manifest
 
 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)
@@ -19,10 +19,13 @@ BuildRequires: pkgconfig(capi-system-system-settings)
 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}
diff --git a/src/data/system/settings_voice_control.c b/src/data/system/settings_voice_control.c
new file mode 100644 (file)
index 0000000..4f0037e
--- /dev/null
@@ -0,0 +1,153 @@
+/*
+ * 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;
+}