ma_client.c
ma_dbus.c
../common/ma_config_mgr.c
+ ../common/multi_assistant_settings.c
)
SET(UI_SRCS
ma_ui_client.c
ma_ui_dbus.c
../common/ma_config_mgr.c
+ ../common/multi_assistant_settings.c
)
FOREACH(flag ${pkgs_CFLAGS})
--- /dev/null
+#include "multi_assistant_settings.h"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "ma-assistant-setting"
+
+#define APPID_URL "db/multi-assistant/enabled_status/%s"
+
+#define ENABLED_ASSISTANT_URL "db/multi-assistant/enabled_assistants"
+
+#define DEFAULT_ASSISTANT_URL "db/multi-assistant/default_assistant_appid"
+
+#define MODE_URL "db/multi-assistant/multiple_mode"
+
+#define MAX_LEN 100
+
+bool ma_settings_get_multiple_mode() {
+ int res;
+ vconf_get_bool(MODE_URL, &res);
+ return res;
+}
+
+int ma_settings_set_multiple_mode(bool multiple) {
+ if (!ma_settings_get_multiple_mode()) {
+
+ if (vconf_set_bool(MODE_URL, multiple)) {
+ return MA_ERROR_NONE;
+ } else {
+ return MA_ERROR_OPERATION_FAILED;
+ }
+
+ } else {
+ return MA_ERROR_OPERATION_FAILED;
+ }
+}
+
+int ma_settings_change_voice_assistant(const char* app_id) {
+ int res = MA_ERROR_NONE;
+ char* previous_assistant = vconf_get_str(ENABLED_ASSISTANT_URL);
+ if (!ma_settings_get_multiple_mode() &&
+ previous_assistant &&
+ app_id) {
+
+ if(strncmp(app_id, previous_assistant, MAX_LEN) != 0) {
+ char new_assistant_url[MAX_LEN] = "", previous_assistant_url[MAX_LEN] = "";
+ snprintf(new_assistant_url, MAX_LEN, APPID_URL, app_id);
+ snprintf(previous_assistant_url, MAX_LEN, APPID_URL, previous_assistant);
+
+ if (vconf_set_bool(new_assistant_url, true) &&
+ vconf_set_bool(previous_assistant_url, false) &&
+ vconf_set_str(ENABLED_ASSISTANT_URL, app_id)) {
+ res = MA_ERROR_NONE;
+ } else {
+ res = MA_ERROR_OPERATION_FAILED;
+ }
+
+ } else {
+ res = MA_ERROR_NOT_SUPPORTED;
+ }
+
+ } else {
+ res = MA_ERROR_OPERATION_FAILED;
+ }
+
+ if (previous_assistant) {
+ free(previous_assistant);
+ }
+ return res;
+}
+
+int ma_settings_set_voice_assistant_enabled(const char* app_id, bool enabled) {
+ if (ma_settings_get_multiple_mode() && app_id != NULL) {
+ char assistant_url[MAX_LEN] = "";
+ snprintf(assistant_url, MAX_LEN, APPID_URL, app_id);
+
+ if (vconf_set_bool(assistant_url, enabled)) {
+ return MA_ERROR_NONE;
+ } else {
+ return MA_ERROR_OPERATION_FAILED;
+ }
+
+ } else {
+ return MA_ERROR_ENGINE_NOT_FOUND;
+ }
+}
+
+int ma_settings_set_default_voice_assistant(const char* app_id) {
+ int res = MA_ERROR_NONE;
+ char* previous_assistant = vconf_get_str(DEFAULT_ASSISTANT_URL);
+ if (ma_settings_get_multiple_mode() &&
+ previous_assistant &&
+ app_id) {
+
+ if(strncmp(app_id, previous_assistant, MAX_LEN) != 0) {
+
+ if (vconf_set_str(DEFAULT_ASSISTANT_URL, app_id)) {
+ res = MA_ERROR_NONE;
+ } else {
+ res = MA_ERROR_OPERATION_FAILED;
+ }
+
+ } else {
+ res = MA_ERROR_NOT_SUPPORTED;
+ }
+
+ } else {
+ res = MA_ERROR_OPERATION_FAILED;
+ }
+
+ if (previous_assistant) {
+ free(previous_assistant);
+ }
+ return res;
+}
\ No newline at end of file
INSTALL(FILES ${CMAKE_BINARY_DIR}/include/multi_assistant.h DESTINATION ${INCLUDEDIR})
INSTALL(FILES ${CMAKE_BINARY_DIR}/include/multi_assistant_ui.h DESTINATION ${INCLUDEDIR})
INSTALL(FILES ${CMAKE_BINARY_DIR}/include/multi_assistant_common.h DESTINATION ${INCLUDEDIR})
+INSTALL(FILES ${CMAKE_BINARY_DIR}/include/multi_assistant_settings.h DESTINATION ${INCLUDEDIR})
--- /dev/null
+/**
+ * Copyright (c) 2011-2018 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 __TIZEN_UIFW_MULTI_ASSISTANT_SETTINGS_H__
+#define __TIZEN_UIFW_MULTI_ASSISTANT_SETTINGS_H__
+
+#include <tizen.h>
+#include <dlog.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <vconf/vconf.h>
+#include <multi_assistant_common.h>
+
+/**
+ * @addtogroup CAPI_UIX_MULTI_ASSISTANT_MODULE
+ * @{
+ */
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ * @brief Set multi-assistant multiple mode.
+ * @since_tizen 5.5
+ * @privlevel public
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MA_ERROR_NONE Successful
+ * @retval #MA_ERROR_OPERATION_FAILED Operation failed
+ *
+ * @param[in] multiple The state of multi-assistant need to be changed into
+ */
+int ma_settings_set_multiple_mode(bool multiple);
+
+/**
+ * @brief Change system's voice assistant.
+ * @since_tizen 5.5
+ * @remarks Valid only in single voice assistant mode.
+ * @privlevel public
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MA_ERROR_NONE Successful
+ * @retval #MA_ERROR_NOT_SUPPORTED Not supported
+ * @retval #MA_ERROR_OPERATION_FAILED Operation failed
+ *
+ * @param[in] app_id The app id of the voice assistant that need to be activated
+ */
+int ma_settings_change_voice_assistant(const char* app_id);
+
+/**
+ * @brief En/Disable a specific voice assistant.
+ * @since_tizen 5.5
+ * @remarks Valid only in multiple voice assistant mode.
+ * @privlevel public
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MA_ERROR_NONE Successful
+ * @retval #MA_ERROR_NOT_SUPPORTED Not supported
+ * @retval #MA_ERROR_ENGINE_NOT_FOUND Engine not found
+ *
+ * @param[in] app_id The app id of the voice assistant that need to be changed
+ * @param[in] enabled The voice assistant need to be enabled or not
+ */
+int ma_settings_set_voice_assistant_enabled(const char* app_id, bool enabled);
+
+/**
+ * @brief Change system's default voice assistant.
+ * @since_tizen 5.5
+ * @remarks Valid only in multiple voice assistant mode.
+ * @privlevel public
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MA_ERROR_NONE Successful
+ * @retval #MA_ERROR_NOT_SUPPORTED Not supported
+ * @retval #MA_ERROR_OPERATION_FAILED Operation failed
+ *
+ * @param[in] app_id The app id of the voice assistant that need to set as default one
+ */
+int ma_settings_set_default_voice_assistant(const char* app_id);
+
+#ifdef __cplusplus
+}
+#endif
+
+/**
+ * @}
+ */
+
+#endif /* __TIZEN_UIFW_MULTI_ASSISTANT_SETTINGS_H__ */
\ No newline at end of file
%{_includedir}/multi_assistant.h
%{_includedir}/multi_assistant_ui.h
%{_includedir}/multi_assistant_common.h
+%{_includedir}/multi_assistant_settings.h
%files ui-devel
%defattr(-,root,root,-)
%{_libdir}/pkgconfig/multi-assistant-ui.pc
%{_includedir}/multi_assistant_ui.h
%{_includedir}/multi_assistant_common.h
+%{_includedir}/multi_assistant_settings.h