Add bux2ctl_get for getting buxton key by users 32/89932/5
authorsooyeon.kim <sooyeon.kim@samsung.com>
Tue, 27 Sep 2016 12:58:44 +0000 (21:58 +0900)
committersooyeon.kim <sooyeon.kim@samsung.com>
Wed, 28 Sep 2016 12:00:05 +0000 (21:00 +0900)
Change-Id: I41d54ab5a45fe8477edecc7fd73566a9644a37cf
Signed-off-by: sooyeon.kim <sooyeon.kim@samsung.com>
CMakeLists.txt
bin/aarch64/voice_getengine [new file with mode: 0755]
bin/armv7l/voice_getengine [new file with mode: 0755]
bin/i586/voice_getengine [new file with mode: 0755]
bin/x86_64/voice_getengine [new file with mode: 0755]
common/tts_config_mgr.c
common/tts_defs.h
org.tizen.voice.ttsnotiserver.service
org.tizen.voice.ttsserver.service
org.tizen.voice.ttssrserver.service
packaging/tts.spec

index c57ce33..d1b95f8 100644 (file)
@@ -26,6 +26,9 @@ SET(EXEC_PREFIX "${PREFIX}")
 SET(INCLUDEDIR "${PREFIX}/include")
 SET(VERSION 0.2.44)
 
+FIND_PROGRAM(UNAME NAMES uname)
+EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
+
 ADD_DEFINITIONS("-DTTS_LIBDIR=\"${LIBDIR}\"")
 ADD_DEFINITIONS("-Werror")
 
@@ -36,7 +39,7 @@ INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/common")
 INCLUDE(FindPkgConfig)
 pkg_check_modules(pkgs REQUIRED  
        aul capi-media-audio-io capi-system-info dbus-1 dlog ecore 
-       glib-2.0 libtzplatform-config libxml-2.0 vconf bundle
+       glib-2.0 libtzplatform-config libxml-2.0 vconf bundle buxton2
 )
 
 pkg_check_modules(pkgs_test REQUIRED
@@ -70,5 +73,19 @@ INSTALL(FILES ${CMAKE_SOURCE_DIR}/org.tizen.voice.ttsserver.service DESTINATION
 INSTALL(FILES ${CMAKE_SOURCE_DIR}/org.tizen.voice.ttsnotiserver.service DESTINATION ${TZ_SYS_RO_SHARE}/dbus-1/services)
 INSTALL(FILES ${CMAKE_SOURCE_DIR}/org.tizen.voice.ttssrserver.service DESTINATION ${TZ_SYS_RO_SHARE}/dbus-1/services)
 
+## voice_getengine ##
+IF("${ARCH}" MATCHES "^arm.*")
+INSTALL(PROGRAMS ${CMAKE_SOURCE_DIR}/bin/armv7l/voice_getengine DESTINATION ${TZ_SYS_BIN})
+ELSEIF("${ARCH}" MATCHES "^i586.*")
+INSTALL(PROGRAMS ${CMAKE_SOURCE_DIR}/bin/i586/voice_getengine DESTINATION ${TZ_SYS_BIN})
+ELSEIF("${ARCH}" MATCHES "^i686.*")
+INSTALL(PROGRAMS ${CMAKE_SOURCE_DIR}/bin/i586/voice_getengine DESTINATION ${TZ_SYS_BIN})
+ELSEIF("${ARCH}" MATCHES "^aarch64.*")
+INSTALL(PROGRAMS ${CMAKE_SOURCE_DIR}/bin/aarch64/voice_getengine DESTINATION ${TZ_SYS_BIN})
+ELSEIF("${ARCH}" MATCHES "^x86_64.*")
+INSTALL(PROGRAMS ${CMAKE_SOURCE_DIR}/bin/x86_64/voice_getengine DESTINATION ${TZ_SYS_BIN})
+ENDIF()
+
+
 ## Sample application ##
 ADD_SUBDIRECTORY(test)
diff --git a/bin/aarch64/voice_getengine b/bin/aarch64/voice_getengine
new file mode 100755 (executable)
index 0000000..9b9c2de
Binary files /dev/null and b/bin/aarch64/voice_getengine differ
diff --git a/bin/armv7l/voice_getengine b/bin/armv7l/voice_getengine
new file mode 100755 (executable)
index 0000000..c101a5f
Binary files /dev/null and b/bin/armv7l/voice_getengine differ
diff --git a/bin/i586/voice_getengine b/bin/i586/voice_getengine
new file mode 100755 (executable)
index 0000000..b01c05b
Binary files /dev/null and b/bin/i586/voice_getengine differ
diff --git a/bin/x86_64/voice_getengine b/bin/x86_64/voice_getengine
new file mode 100755 (executable)
index 0000000..a4e2f60
Binary files /dev/null and b/bin/x86_64/voice_getengine differ
index a3e33d4..fdc2bdd 100644 (file)
@@ -20,6 +20,7 @@
 #include <unistd.h>
 #include <sys/inotify.h>
 #include <vconf.h>
+#include <buxton2.h>
 
 #include "tts_config_mgr.h"
 #include "tts_config_parser.h"
@@ -1381,6 +1382,61 @@ int tts_config_mgr_get_engine(char** engine)
        return TTS_CONFIG_ERROR_OPERATION_FAILED;
 }
 
+int __tts_set_buxtonkey(const char* engine)
+{
+       /* Set vconfkey */
+       struct buxton_client * bux_cli;
+       struct buxton_layer * bux_layer;
+       struct buxton_value * bux_val;
+
+       int ret = buxton_open(&bux_cli, NULL, NULL);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, tta_tag(), "[DBUS-BUXTON2] buxton_open failed!! (%d)", ret);
+               return TTS_CONFIG_ERROR_OPERATION_FAILED;
+       }
+       bux_layer = buxton_create_layer("user");
+       if (NULL == bux_layer) {
+               SLOG(LOG_ERROR, tts_tag(), "[DBUS-BUXTON2] buxton_create_layer FAIL");
+               buxton_close(bux_cli);
+               return TTS_CONFIG_ERROR_OPERATION_FAILED;
+       }
+       bux_val = buxton_value_create_string(engine);
+       if (NULL == bux_val) {
+               SLOG(LOG_ERROR, tts_tag(), "[DBUS-BUXTON2] buxton_value_create_string FAIL");
+               buxton_free_layer(bux_layer);
+               buxton_close(bux_cli);
+               return TTS_CONFIG_ERROR_OPERATION_FAILED;
+       } else {
+               SLOG(LOG_DEBUG, tts_tag(), "[DBUS-BUXTON2] layer: %s", buxton_layer_get_name(bux_layer));
+       }
+
+       ret = buxton_set_value_sync(bux_cli, bux_layer, TTS_ENGINE_DB_DEFAULT, bux_val);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, tta_tag(), "[DBUS-BUXTON2] buxton_set_value_sync failed!! (%d)", ret);
+               buxton_value_free(bux_val);
+               buxton_free_layer(bux_layer);
+               buxton_close(bux_cli);
+
+               bux_cli = NULL;
+               bux_layer = NULL;
+               bux_val = NULL;
+
+               return TTS_CONFIG_ERROR_OPERATION_FAILED;
+       } else {
+               SLOG(LOG_DEBUG, tts_tag(), "[DBUS-BUXTON2] buxton_set_value_sync: %d, %s", ret, TTS_ENGINE_DB_DEFAULT);
+       }
+
+       buxton_value_free(bux_val);
+       buxton_free_layer(bux_layer);
+       buxton_close(bux_cli);
+
+       bux_cli = NULL;
+       bux_layer = NULL;
+       bux_val = NULL;
+
+       return TTS_CONFIG_ERROR_NONE;
+}
+
 int tts_config_mgr_set_engine(const char* engine)
 {
        if (0 >= g_slist_length(g_config_client_list)) {
@@ -1404,6 +1460,12 @@ int tts_config_mgr_set_engine(const char* engine)
 
        SLOG(LOG_DEBUG, tts_tag(), "New engine id : %s", engine);
 
+       int ret = __tts_set_buxtonkey(engine);
+       if (0 != ret) {
+               SLOG(LOG_DEBUG, tts_tag(), "[DEBUG] set_buxtonkey Fail!!");
+               return ret;
+       }
+
        GSList *iter = NULL;
        tts_engine_info_s *engine_info = NULL;
        bool is_valid_engine = false;
index 7d7981f..6e803ac 100644 (file)
@@ -109,6 +109,7 @@ extern "C" {
 
 #define TTS_LANGSET_KEY                        VCONFKEY_LANGSET
 
+#define TTS_ENGINE_DB_DEFAULT       "db/voice/tts/engine/default"
 
 #ifdef __cplusplus
 }
index a48006a..018f8ea 100644 (file)
@@ -1,4 +1,4 @@
 [D-BUS Service]
 Name=org.tizen.voice.ttsnotiserver
-#Exec=/bin/sh -c "buxton2ctl get user db/voice/tts_engine | awk '{print$5}' | xargs -t -i launch_app {}-noti"
-Exec=/bin/sh -c "launch_app org.tizen.tts-engine-default-noti mode noti"
+Exec=/bin/sh -c "voice_getengine get user db/voice/tts/engine/default | awk '{print$5}' | xargs -t -i launch_app {}-noti mode noti"
+#Exec=/bin/sh -c "launch_app org.tizen.tts-engine-default-noti mode noti"
index cb3ee74..432e4f9 100644 (file)
@@ -1,4 +1,4 @@
 [D-BUS Service]
 Name=org.tizen.voice.ttsserver
-#Exec=/bin/sh -c "buxton2ctl get user db/voice/tts_engine | awk '{print$5}' | xargs -t -i launch_app {}"
-Exec=/bin/sh -c "launch_app org.tizen.tts-engine-default"
+Exec=/bin/sh -c "voice_getengine get user db/voice/tts/engine/default | awk '{print$5}' | xargs -t -i launch_app {}"
+#Exec=/bin/sh -c "launch_app org.tizen.tts-engine-default"
index e0cfccf..80b6f77 100644 (file)
@@ -1,4 +1,4 @@
 [D-BUS Service]
 Name=org.tizen.voice.ttssrserver
-#Exec=/bin/sh -c "buxton2ctl get user db/voice/tts_engine | awk '{print$5}' | xargs -t -i launch_app {}-sr"
-Exec=/bin/sh -c "launch_app org.tizen.tts-engine-default-sr mode sr"
+Exec=/bin/sh -c "voice_getengine get user db/voice/tts/engine/default | awk '{print$5}' | xargs -t -i launch_app {}-sr mode sr"
+#Exec=/bin/sh -c "launch_app org.tizen.tts-engine-default-sr mode sr"
index b822fdf..55c3130 100644 (file)
@@ -8,9 +8,11 @@ Source0:    %{name}-%{version}.tar.gz
 Source1001: %{name}.manifest
 Source1002: %{name}-devel.manifest
 Requires(post):   /sbin/ldconfig
+Requires(post): /usr/bin/buxton2ctl
 Requires(postun): /sbin/ldconfig
 BuildRequires:  pkgconfig(aul)
 BuildRequires:  pkgconfig(capi-appfw-app-manager)
+BuildRequires:  pkgconfig(buxton2)
 BuildRequires:  pkgconfig(capi-base-common)
 BuildRequires:  pkgconfig(capi-media-audio-io)
 BuildRequires:  pkgconfig(capi-system-info)
@@ -72,7 +74,7 @@ export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
 export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
 
 
-cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DLIBDIR=%{_libdir} -DINCLUDEDIR=%{_includedir} \
+cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DLIBDIR=%{_libdir} -DBINDIR=%{_bindir} -DINCLUDEDIR=%{_includedir} \
         -DTZ_SYS_RO_SHARE=%TZ_SYS_RO_SHARE -DTZ_SYS_BIN=%TZ_SYS_BIN
 
 make %{?jobs:-j%jobs}
@@ -97,6 +99,9 @@ mkdir -p %{_libdir}/voice
 
 mkdir -p %{TZ_SYS_RO_SHARE}/voice/test
 
+# buxton2ctl create-string #
+buxton2ctl create-string "user" "db/voice/tts/engine/default" "org.tizen.tts-engine-default" "http://tizen.org/privilege/internal/default/public" "http://tizen.org/privilege/internal/default/platform"
+
 %postun -p /sbin/ldconfig
 
 %files
@@ -110,6 +115,7 @@ mkdir -p %{TZ_SYS_RO_SHARE}/voice/test
 %{TZ_SYS_RO_SHARE}/dbus-1/services/org.tizen.voice.ttssrserver.service
 %{TZ_SYS_RO_SHARE}/voice/test/tts-test
 %{TZ_SYS_RO_SHARE}/license/%{name}
+%{_bindir}/voice_getengine
 %{TZ_SYS_RO_ETC}/package-manager/parserlib/metadata/libtts-engine-parser.so*
 #%{TZ_SYS_RO_ETC}/package-manager/parserlib/metadata/libtts-engine-language-pack-parser.so*
 /etc/dbus-1/system.d/tts-server.conf