Merge with Tizen 2.3 82/35382/1 tizen_3.0.2015.q2_common accepted/tizen/common/20150506.091347 accepted/tizen/mobile/20150511.004112 accepted/tizen/tv/20150506.233457 accepted/tizen/wearable/20150506.234519 submit/tizen/20150429.013912 submit/tizen_common/20150505.090000
authorky85.kim <ky85.kim@samsung.com>
Fri, 13 Feb 2015 00:30:28 +0000 (09:30 +0900)
committerky85.kim <ky85.kim@samsung.com>
Fri, 13 Feb 2015 00:30:28 +0000 (09:30 +0900)
Apply file message(IPC)
Apply XML for configure setting
Change player to audio out
Support pitch option
Update play start after synthesis

 - Details in changelog -

Change-Id: I0cd0cd5be24873971f3d5e4c45349979585cce6a

59 files changed:
CMakeLists.txt [changed mode: 0755->0644]
NOTICE
changelog
client/CMakeLists.txt
client/tts.c
client/tts.h [deleted file]
client/tts_client.c
client/tts_client.h
client/tts_dbus.c
client/tts_dbus.h
client/tts_main.h
client/tts_setting.c
client/tts_setting.h [deleted file]
client/tts_setting_dbus.c [deleted file]
client/tts_setting_dbus.h [deleted file]
common/tts_config_mgr.c [new file with mode: 0644]
common/tts_config_mgr.h [new file with mode: 0644]
common/tts_config_parser.c [new file with mode: 0644]
common/tts_config_parser.h [new file with mode: 0644]
common/tts_defs.h
doc/doxyfile [new file with mode: 0644]
doc/images/capi_uix_tts_state_diagram.png [new file with mode: 0644]
doc/uix_tts_doc.h [new file with mode: 0644]
include/CMakeLists.txt [new file with mode: 0644]
include/tts-engine.pc.in [new file with mode: 0644]
include/tts-setting.pc.in [moved from client/tts-setting.pc.in with 100% similarity]
include/tts.h [new file with mode: 0644]
include/tts.pc.in [moved from client/tts.pc.in with 100% similarity]
include/tts_setting.h [new file with mode: 0644]
packaging/tts.spec
server/CMakeLists.txt
server/ttsd.conf [deleted file]
server/ttsd_config.c
server/ttsd_config.h
server/ttsd_config_noti.c [deleted file]
server/ttsd_config_sr.c [deleted file]
server/ttsd_data.cpp
server/ttsd_data.h
server/ttsd_dbus.c
server/ttsd_dbus.h
server/ttsd_dbus_server.c
server/ttsd_dbus_server.h
server/ttsd_engine_agent.c
server/ttsd_engine_agent.h
server/ttsd_main.c
server/ttsd_main.h
server/ttsd_main_noti.c
server/ttsd_main_sr.c
server/ttsd_network.c
server/ttsd_network.h
server/ttsd_player.c
server/ttsd_player.h
server/ttsd_server.c
server/ttsd_server.h
server/ttsp.h
sysinfo-tts.xml [deleted file]
test/CMakeLists.txt [new file with mode: 0644]
test/test_main.c [new file with mode: 0644]
tts-config.xml [new file with mode: 0644]

old mode 100755 (executable)
new mode 100644 (file)
index 98baf4d..361a981
@@ -1,5 +1,29 @@
+# Copyright (c) 2011-2014 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.
+#
+#
+# @file        CMakeLists.txt
+# @author      Dongyeol Lee (dy3.lee@samsung.com)
+# @version     0.1
+# @brief
+
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(libtts)
+PROJECT(tts)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(EXEC_PREFIX "${PREFIX}")
+SET(VERSION 0.2.41)
 
 ## Include common directory ##
 INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/common")
@@ -7,9 +31,17 @@ INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/common")
 ## Dependent packages ##
 INCLUDE(FindPkgConfig)
 pkg_check_modules(pkgs REQUIRED  
-       mm-player dlog ecore ecore-file dbus-1 mm-session capi-system-runtime-info vconf vconf-internal-keys libtzplatform-config
+       aul capi-media-audio-io capi-system-info dbus-1 dlog ecore 
+       glib-2.0 libprivilege-control libtzplatform-config libxml-2.0 vconf
+)
+
+pkg_check_modules(pkgs_test REQUIRED
+    ecore dlog
 )
 
+## API ##
+ADD_SUBDIRECTORY(include)
+
 ## Client library ##
 ADD_SUBDIRECTORY(client)
 
@@ -17,4 +49,9 @@ ADD_SUBDIRECTORY(client)
 ADD_SUBDIRECTORY(server)
 
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.APLv2 RENAME tts DESTINATION /usr/share/license)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/sysinfo-tts.xml DESTINATION /etc/config)
+
+## Config ##
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/tts-config.xml DESTINATION /usr/lib/voice/tts/1.0)
+
+## Sample application ##
+ADD_SUBDIRECTORY(test)
diff --git a/NOTICE b/NOTICE
index 1066e15..d08cb4d 100644 (file)
--- a/NOTICE
+++ b/NOTICE
@@ -1,3 +1,3 @@
-Copyright (c)2012 Samsung Electronics Co., Ltd. All rights reserved.
+Copyright (c) 2011-2014 Samsung Electronics Co., Ltd. All rights reserved.
 Except as noted, this software is licensed under Apache License, Version 2.
 Please, see the LICENSE.APLv2 file for Apache License terms and conditions.
index fa6d72c..df3ba0b 100644 (file)
--- a/changelog
+++ b/changelog
@@ -1,3 +1,458 @@
+tts (0.2.41) -- Sat, 13 Aug 2014
+
+  * Update play start after synthesis (Dongyeol Lee <dy3.lee@samsung.com>)
+  * Remove not used error function (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.40) -- Mon, 07 Jul 2014
+
+  * Fix error code (Dongyeol Lee <dy3.lee@samsung.com>)
+  * Fix memory issue (Kwangyoun Kim <ky85.kim@samsung.com>)
+  * Add retry when file read fail (Kwangyoun Kim <ky85.kim@samsung.com>)
+  * Update engine error print (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.39) -- Thu, 26 Jun 2014
+
+  * Update API for speed and pitch value (Dongyeol Lee <dy3.lee@samsung.com>)
+  * Remove legacy code for sound type (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.38) -- Thu, 19 Jun 2014
+
+  * Fix daemon privilege (Dongyeol Lee <dy3.lee@samsung.com>)
+  * Fix config file mode change (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.37) -- Thu, 29 May 2014
+
+  * Fix memory init and warning (Dongyeol Lee <dy3.lee@samsung.com>)
+  * Update audio out type (Dongyeol Lee <dy3.lee@samsung.com>)
+  * Update boilerplate (Kwangyoun Kim <ky85.kim@samsung.com>)
+  * Update License info (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.36) -- Thu, 15 May 2014
+
+  * Fix build for profile support (Kwangyoun Kim <ky85.kim@samsung.com>)
+  * Fix bug audio unprepare (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.35) -- Thu, 24 Apr 2014
+
+  * Add tts sample app (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.34) -- Mon, 14 Apr 2014
+
+  * Delete unused API (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.33) -- Wed, 02 Apr 2014
+
+  * Fix default engine id change bug (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.32) -- Wed, 26 Mar 2014
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.31-2) -- Tue, 25 Mar 2014
+
+  * Update setting api (Dongyeol Lee <dy3.lee@samsung.com>)
+  * Update config error code (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.31-1) -- Mon, 24 Mar 2014
+
+  * Support pitch option in setting (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.31) -- Thu, 13 Feb 2014
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.30-1) -- Wed, 12 Feb 2014
+
+  * Add dbus error free (Kwangyoun Kim <ky85.kim@samsung.com>)
+  * Update smack rule (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.30) -- Thu, 16 Jan 2014
+
+  * Release version (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.29-2) -- Thu, 16 Jan 2014
+
+  * Update smack rule to access vconf key (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.29-1) -- Thu, 16 Jan 2014
+
+  * Fix crash issue (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.29) -- Mon, 6 Jan 2014
+
+  * Release version (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.28-2) -- Mon, 6 Jan 2014
+
+  * Fix audio interrupt bug (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.28-1) -- Mon, 6 Jan 2014
+
+  * Update engine api (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.28) -- Fri, 3 Jan 2014
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.27-1) -- Fri, 3 Jan 2014
+
+  * Update player for race condition (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.27) -- Thu, 26 Dec 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.26-2) -- Thu, 26 Dec 2013
+
+  * Add memory free on player (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.26-1) -- Tue, 24 Dec 2013
+
+  * Change player to audio out on screen reader mode (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.26) -- Mon, 23 Dec 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.25-1) -- Mon, 23 Dec 2013
+
+  * Delete unused code (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.25) -- Fri, 20 Dec 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.24-1) -- Fri, 20 Dec 2013
+
+  * Fix file message bug (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.24) -- Thu, 19 Dec 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.23-1) -- Thu, 19 Dec 2013
+
+  * Add to set sount type (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.23) -- Thu, 12 Dec 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.22-1) -- Mon, 09 Dec 2013
+
+  * Fix bug on initialize timeout (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.22) -- Fri, 06 Dec 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.21-1) -- Fri, 06 Dec 2013
+
+  * Fix crash issue (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.21) -- Thu, 05 Dec 2013
+
+  * Release version (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.20-1) -- Thu, 05 Dec 2013
+
+  * Add load / unload voice of engine (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.20) -- Fri, 30 Nov 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.19-2) -- Fri, 29 Nov 2013
+
+  * Fix spec file (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.19-1) -- Fri, 22 Nov 2013
+
+  * Fix bug on clean up message file (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.19) -- Fri, 15 Nov 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.18-2) -- Fri, 15 Nov 2013
+
+  * Block tts api on screen reader off state (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.18-1) -- Thu, 14 Nov 2013
+
+  * Update file message name from mode (Dongyeol Lee <dy3.lee@samsung.com>)
+  * Clean up file message (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.18) -- Thu, 14 Nov 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.17-1) -- Thu, 14 Nov 2013
+
+  * Fix code about utterance message for screenreader (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.17) -- Tue, 12 Nov 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.16-1) -- Tue, 12 Nov 2013
+
+  * Update screen reader to be stable (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.16) -- Fri, 8 Nov 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.15-3) -- Fri, 8 Nov 2013
+
+  * Fix block issue in inotify (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.15-2) -- Mon, 4 Nov 2013
+
+  * Fix build warning (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.15-1) -- Mon, 4 Nov 2013
+
+  * Add code for check running app when clean up client (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.15) -- Mon, 28 Oct 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.14-1) -- Mon, 28 Oct 2013
+
+  * Disable client clean up (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.14) -- Mon, 28 Oct 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.13-2) -- Mon, 28 Oct 2013
+
+  * Divide devel package (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.13-1) -- Fri, 25 Oct 2013
+
+  * Add code for check text valid (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.13) -- Tue, 22 Oct 2013
+
+  * Release version (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.12-1) -- Tue, 22 Oct 2013
+
+  * Fix memory leak (Dongyeol Lee <dy3.lee@samsung.com>)
+  * Fix dbus time out (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.12) -- Mon, 21 Oct 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.11-3) -- Mon, 21 Oct 2013
+
+  * Update daemon fork to use thread (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.11-2) -- Fri, 18 Oct 2013
+
+  * Remove not used setting api (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.11-1) -- Fri, 27 Sep 2013
+
+  * Fix minor memory bug (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.11) -- Thu, 26 Sep 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.10-1) -- Wed, 25 Sep 2013
+
+  * Fix crash issue (Dongyeol Lee <dy3.lee@samsung.com>)
+  * Clean up engine api (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.10) -- Tue, 24 Sep 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.9-4) -- Tue, 24 Sep 2013
+
+  * Add TC (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.9-3) -- Tue, 24 Sep 2013
+
+  * Fix minor memory bugs (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.9-2) -- Thu, 29 Aug 2013
+
+  * Update docs and change api folder (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.9-1) -- Wed, 28 Aug 2013
+
+  * Add error callback when player fail to start sound (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.9) -- Wed, 21 Aug 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.8-2) -- Tue, 20 Aug 2013
+
+  * Fix crash issue to change display language (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.8-1) -- Mon, 19 Aug 2013
+
+  * Clean up code and log (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.8) -- Wed, 31 Jul 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.7-1) -- Wed, 31 Jul 2013
+
+  * Remove test module (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.7) -- Wed, 31 Jul 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.6-3) -- Wed, 31 Jul 2013
+
+  * Add build config for dlog (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.6-2) -- Wed, 31 Jul 2013
+
+  * Fix bug to set auto language (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.6-1) -- Tue, 30 Jul 2013
+
+  * Add test module (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.6) -- Thu, 25 Jul 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.5-1) -- Thu, 25 Jul 2013
+
+  * Fix setting error handling (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.5) -- Thu, 18 Jul 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.4-2) -- Thu, 18 Jul 2013
+
+  * Fix client create bug (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.4-1) -- Tue, 09 Jul 2013
+
+  * Fix initialize of config client (Dongyeol Lee <dy3.lee@samsung.com>)
+  * Clean up smack rule (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.4) -- Wed, 10 Jul 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.3-5) -- Tue, 09 Jul 2013
+
+  * Fix code to manage config callback (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.3-4) -- Fri, 05 Jul 2013
+
+  * Fix code bug (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.3-3) -- Thr, 04 Jul 2013
+
+  * Change default voice is en_GB (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.3-2) -- Thr, 04 Jul 2013
+
+  * Support auto language setting (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.3-1) -- Sat, 29 Jun 2013
+
+  * Update smack label of voice directory (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.3) -- Wed, 26 Jun 2013
+
+  * Release version (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.2-1) -- Wed, 26 Jun 2013
+
+  * Fix config instance bug (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.2) -- Tue, 25 Jun 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.2.1-2) -- Tue, 25 Jun 2013
+
+  * Fix to remove temp wav file (Dongyeol Lee <dy3.lee@samsung.com>)
+  * Synchronize speech rate vconf key with tts configure (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.1-1) -- Mon, 24 Jun 2013
+
+  * Fix player priority to mix message with TTS (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.1) -- Fri, 21 Jun 2013
+
+  * Release version (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.0-1) -- Fri, 21 Jun 2013
+
+  * Fix to save config init (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.2.0) -- Fri, 21 Jun 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.1.66-1) -- Fri, 21 Jun 2013
+
+  * Fix voice config directroy owner (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.1.66) -- Thu, 20 Jun 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.1.65-3) -- Thu, 20 Jun 2013
+
+  * Fix bug of voice type change (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.1.65-2) -- Thu, 20 Jun 2013
+
+  * Update to get voice of client (Dongyeol Lee <dy3.lee@samsung.com>)
+  * Add auto voice selection (Dongyeol Lee <dy3.lee@samsung.com>)
+  * Fix bug (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.1.65-1) -- Wed, 19 Jun 2013
+
+  * Update XML config based (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.1.65) -- Sat, 15 Jun 2013
+
+  * Release version (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.1.64-1) -- Sat, 15 Jun 2013
+
+  * Fix to free invalid timer in stop (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.1.64) -- Fri, 14 Jun 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.1.63-1) -- Fri, 14 Jun 2013
+
+  * Update smack rule (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.1.63) -- Wed, 12 Jun 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+tts (0.1.62-2) -- Wed, 12 Jun 2013
+
+  * Add api to detect default voice change (Dongyeol Lee <dy3.lee@samsung.com>)
+
+tts (0.1.62-1) -- Wed, 12 Jun 2013
+
+  * Add code for secure log (Kwangyoun Kim <ky85.kim@samsung.com>)
+
 tts (0.1.62) -- Tue, 14 May 2013
 
   * Release version 0.1.62 (Kwangyoun Kim <ky85.kim@samsung.com>)
index ab78fc9..6b6d9b6 100644 (file)
@@ -1,42 +1,21 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(tts C)
-
-SET(PREFIX ${CMAKE_INSTALL_PREFIX})
-SET(EXEC_PREFIX "${PREFIX}")
-SET(LIBDIR "${LIB_INSTALL_DIR}")
-SET(INCLUDEDIR "${PREFIX}/include")
-SET(VERSION 0.1.1)
-
 SET(SRCS 
        tts.c
        tts_client.c
        tts_dbus.c
+       ../common/tts_config_mgr.c
+       ../common/tts_config_parser.c
 )
 
 SET(SETTING_SRCS
        tts_setting.c
-       tts_setting_dbus.c
+       ../common/tts_config_mgr.c
+       ../common/tts_config_parser.c
 )
 
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
-INCLUDE_DIRECTORIES(${INCLUDEDIR})
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../common)
 
-INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED 
-       glib-2.0 dbus-1 dlog ecore
-)
-
-FIND_PROGRAM(UNAME NAMES uname)
-EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
-IF ("${ARCH}" STREQUAL "arm")
-       ADD_DEFINITIONS("-DTARGET_ARM")
-       MESSAGE("[TARGET] Compile")
-ELSE  ("${ARCH}" STREQUAL "arm")
-       ADD_DEFINITIONS("-DTARGET_I386")
-       MESSAGE("[i386] Compile")
-ENDIF ("${ARCH}" STREQUAL "arm")
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
+INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/include)
+INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/common)
 
 FOREACH(flag ${pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
@@ -47,7 +26,6 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
 ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
 
 ## TTS library ##
-ADD_LIBRARY("${PROJECT_NAME}_static" STATIC ${SRCS})
 ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
 TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
 
@@ -55,12 +33,6 @@ TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
 ADD_LIBRARY("${PROJECT_NAME}_setting" SHARED ${SETTING_SRCS})
 TARGET_LINK_LIBRARIES("${PROJECT_NAME}_setting" ${pkgs_LDFLAGS})
 
-## configure pkgconfig files ##
-CONFIGURE_FILE(tts.pc.in "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc" @ONLY)
-CONFIGURE_FILE(tts-setting.pc.in "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}-setting.pc" @ONLY)
-
 ## Install library files ##
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION lib${LIB_SUFFIX} COMPONENT RuntimeLibraries)
-INSTALL(TARGETS ${PROJECT_NAME}_setting DESTINATION lib${LIB_SUFFIX} COMPONENT RuntimeLibraries)
-INSTALL(FILES "${PROJECT_NAME}.pc" "${PROJECT_NAME}-setting.pc" DESTINATION lib${LIB_SUFFIX}/pkgconfig)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/tts.h ${CMAKE_CURRENT_SOURCE_DIR}/tts_setting.h DESTINATION include)
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIBDIR} COMPONENT RuntimeLibraries)
+INSTALL(TARGETS ${PROJECT_NAME}_setting DESTINATION ${LIBDIR} COMPONENT RuntimeLibraries)
index 0a0f5e9..0702e2b 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*  Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd All Rights Reserved 
+*  Copyright (c) 2011-2014 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
 *  limitations under the License.
 */
 
-
-#include <sys/wait.h>
+#include <dirent.h>
 #include <Ecore.h>
+#include <iconv.h>
 #include <sys/stat.h>
 #include <sys/types.h> 
-#include <dirent.h>
+#include <sys/wait.h>
+#include <system_info.h>
+#include <vconf.h>
 
-#include "tts_main.h"
+#include "tts.h"
 #include "tts_client.h"
+#include "tts_config_mgr.h"
 #include "tts_dbus.h"
+#include "tts_main.h"
 
-#define MAX_TEXT_COUNT 2000
 
 static bool g_is_daemon_started = false;
 
@@ -32,13 +35,95 @@ static bool g_is_sr_daemon_started = false;
 
 static Ecore_Timer* g_connect_timer = NULL;
 
+static bool g_screen_reader;
+
 /* Function definition */
-static int __tts_check_tts_daemon(tts_mode_e mode);
 static Eina_Bool __tts_notify_state_changed(void *data);
 static Eina_Bool __tts_notify_error(void *data);
 
+const char* tts_tag()
+{
+       return "ttsc";
+}
+
+static const char* __tts_get_error_code(tts_error_e err)
+{
+       switch(err) {
+       case TTS_ERROR_NONE:                    return "TTS_ERROR_NONE";
+       case TTS_ERROR_OUT_OF_MEMORY:           return "TTS_ERROR_OUT_OF_MEMORY";
+       case TTS_ERROR_IO_ERROR:                return "TTS_ERROR_IO_ERROR";
+       case TTS_ERROR_INVALID_PARAMETER:       return "TTS_ERROR_INVALID_PARAMETER";
+       case TTS_ERROR_OUT_OF_NETWORK:          return "TTS_ERROR_OUT_OF_NETWORK";
+       case TTS_ERROR_TIMED_OUT:               return "TTS_ERROR_TIMED_OUT";
+       case TTS_ERROR_PERMISSION_DENIED:       return "TTS_ERROR_PERMISSION_DENIED";
+       case TTS_ERROR_NOT_SUPPORTED:           return "TTS_ERROR_NOT_SUPPORTED";
+       case TTS_ERROR_INVALID_STATE:           return "TTS_ERROR_INVALID_STATE";
+       case TTS_ERROR_INVALID_VOICE:           return "TTS_ERROR_INVALID_VOICE";
+       case TTS_ERROR_ENGINE_NOT_FOUND:        return "TTS_ERROR_ENGINE_NOT_FOUND";
+       case TTS_ERROR_OPERATION_FAILED:        return "TTS_ERROR_OPERATION_FAILED";
+       case TTS_ERROR_AUDIO_POLICY_BLOCKED:    return "TTS_ERROR_AUDIO_POLICY_BLOCKED";
+       default:
+               return "Invalid error code";
+       }
+       return NULL;
+}
+
+static int __tts_convert_config_error_code(tts_config_error_e code)
+{
+       if (code == TTS_CONFIG_ERROR_NONE)                      return TTS_ERROR_NONE;
+       if (code == TTS_CONFIG_ERROR_OUT_OF_MEMORY)             return TTS_ERROR_OUT_OF_MEMORY;
+       if (code == TTS_CONFIG_ERROR_IO_ERROR)                  return TTS_ERROR_IO_ERROR;
+       if (code == TTS_CONFIG_ERROR_INVALID_PARAMETER)         return TTS_ERROR_INVALID_PARAMETER;
+       if (code == TTS_CONFIG_ERROR_INVALID_STATE)             return TTS_ERROR_INVALID_STATE;
+       if (code == TTS_CONFIG_ERROR_INVALID_VOICE)             return TTS_ERROR_INVALID_VOICE;
+       if (code == TTS_CONFIG_ERROR_ENGINE_NOT_FOUND)          return TTS_ERROR_ENGINE_NOT_FOUND;
+       if (code == TTS_CONFIG_ERROR_OPERATION_FAILED)          return TTS_ERROR_OPERATION_FAILED;
+       if (code == TTS_CONFIG_ERROR_NOT_SUPPORTED_FEATURE)     return TTS_ERROR_OPERATION_FAILED;
+
+       return code;
+}
+
+void __tts_config_voice_changed_cb(const char* before_lang, int before_voice_type, const char* language, int voice_type, bool auto_voice, void* user_data)
+{
+       SECURE_SLOG(LOG_DEBUG, TAG_TTSC, "Voice changed : Before lang(%s) type(%d) , Current lang(%s), type(%d)", 
+               before_lang, before_voice_type, language, voice_type);
+
+       GList* client_list = NULL;
+       client_list = tts_client_get_client_list();
+
+       GList *iter = NULL;
+       tts_client_s *data = NULL;
+
+       if (g_list_length(client_list) > 0) {
+               /* Get a first item */
+               iter = g_list_first(client_list);
+
+               while (NULL != iter) {
+                       data = iter->data;
+                       if (NULL != data->default_voice_changed_cb) {
+                               SECURE_SLOG(LOG_DEBUG, TAG_TTSC, "Call default voice changed callback : uid(%d)", data->uid);
+                               data->default_voice_changed_cb(data->tts, before_lang, before_voice_type, 
+                                       language, voice_type, data->default_voice_changed_user_data);
+                       }
+
+                       /* Next item */
+                       iter = g_list_next(iter);
+               }
+       }
+
+       return; 
+}
+
 int tts_create(tts_h* tts)
 {
+       bool tts_supported = false;
+       if (0 == system_info_get_platform_bool(TTS_FEATURE_PATH, &tts_supported)) {
+               if (false == tts_supported) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] TTS NOT supported");
+                       return TTS_ERROR_NOT_SUPPORTED;
+               }
+       }
+
        SLOG(LOG_DEBUG, TAG_TTSC, "===== Create TTS");
        
        /* check param */
@@ -47,7 +132,7 @@ int tts_create(tts_h* tts)
                SLOG(LOG_DEBUG, TAG_TTSC, "=====");
                SLOG(LOG_DEBUG, TAG_TTSC, " ");
                return TTS_ERROR_INVALID_PARAMETER;
-       }       
+       }
 
        if (0 == tts_client_get_size()) {
                if (0 != tts_dbus_open_connection()) {
@@ -65,6 +150,26 @@ int tts_create(tts_h* tts)
                return TTS_ERROR_OUT_OF_MEMORY;
        }
 
+       tts_client_s* client = tts_client_get(*tts);
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get client");
+               return TTS_ERROR_OPERATION_FAILED;
+       }
+
+       int ret = tts_config_mgr_initialize(client->uid);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to init config manager : %d", ret);
+               tts_client_destroy(*tts);
+               return __tts_convert_config_error_code(ret);
+       }
+
+       ret = tts_config_mgr_set_callback(client->uid, NULL, __tts_config_voice_changed_cb, NULL, NULL, NULL);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to set config changed : %d", ret);
+               tts_client_destroy(*tts);
+               return __tts_convert_config_error_code(ret);
+       }
+
        g_is_daemon_started = false;
        g_is_noti_daemon_started = false;
        g_is_sr_daemon_started = false;
@@ -77,6 +182,14 @@ int tts_create(tts_h* tts)
 
 int tts_destroy(tts_h tts)
 {
+       bool tts_supported = false;
+       if (0 == system_info_get_platform_bool(TTS_FEATURE_PATH, &tts_supported)) {
+               if (false == tts_supported) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] TTS NOT supported");
+                       return TTS_ERROR_NOT_SUPPORTED;
+               }
+       }
+
        SLOG(LOG_DEBUG, TAG_TTSC, "===== Destroy TTS");
 
        if (NULL == tts) {
@@ -102,39 +215,55 @@ int tts_destroy(tts_h tts)
                return TTS_ERROR_OPERATION_FAILED;
        }
 
+       tts_config_mgr_finalize(client->uid);
+
        int ret = -1;
+       int count = 0;
 
        /* check state */
        switch (client->current_state) {
        case TTS_STATE_PAUSED:
        case TTS_STATE_PLAYING:
        case TTS_STATE_READY:
-               /* Request Finalize */
-               ret = tts_dbus_request_finalize(client->uid);
-               if (0 != ret) {
-                       SLOG(LOG_WARN, TAG_TTSC, "[ERROR] Fail to request finalize");
+               if (!(false == g_screen_reader && TTS_MODE_SCREEN_READER == client->mode)) {
+                       while (0 != ret) {
+                               ret = tts_dbus_request_finalize(client->uid);
+                               if (0 != ret) {
+                                       if (TTS_ERROR_TIMED_OUT != ret) {
+                                               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] result : %s", __tts_get_error_code(ret));
+                                               break;
+                                       } else {
+                                               SLOG(LOG_WARN, TAG_TTSC, "[WARNING] retry finalize");
+                                               usleep(10);
+                                               count++;
+                                               if (10 == count) {
+                                                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to request");
+                                                       break;
+                                               }
+                                       }
+                               }
+                       }
+               } else {
+                       SLOG(LOG_WARN, TAG_TTSC, "[WARNING] Do not request finalize : g_sr(%d) mode(%d)", g_screen_reader, client->mode);
                }
 
-               if (TTS_MODE_SCREEN_READER == client->mode) 
+               if (TTS_MODE_SCREEN_READER == client->mode)
                        g_is_sr_daemon_started = false;
-               else if (TTS_MODE_NOTIFICATION == client->mode) 
+               else if (TTS_MODE_NOTIFICATION == client->mode)
                        g_is_noti_daemon_started = false;
-               else 
+               else
                        g_is_daemon_started = false;
 
-               client->before_state = client->current_state;
-               client->current_state = TTS_STATE_CREATED;
-
-               ecore_timer_add(0, __tts_notify_state_changed, (void*)tts);
-
-               /* Close file message connection */
-               if (0 == tts_client_get_connected_client_count()) {
-                       SLOG(LOG_DEBUG, TAG_TTSC, "Close file msg connection");
-                       ret = tts_file_msg_close_connection();
+               if (0 == tts_client_get_mode_client_count(client->mode)) {
+                       SLOG(LOG_DEBUG, TAG_TTSC, "Close file msg connection : mode(%d)", client->mode);
+                       ret = tts_file_msg_close_connection(client->mode);
                        if (0 != ret)
                                SLOG(LOG_WARN, TAG_TTSC, "[ERROR] Fail to close file message connection");
                }
 
+               client->before_state = client->current_state;
+               client->current_state = TTS_STATE_CREATED;
+
        case TTS_STATE_CREATED:
                if (NULL != g_connect_timer) {
                        SLOG(LOG_DEBUG, TAG_TTSC, "Connect Timer is deleted");
@@ -143,6 +272,9 @@ int tts_destroy(tts_h tts)
                /* Free resources */
                tts_client_destroy(tts);
                break;
+
+       default:
+               break;
        }
  
        if (0 == tts_client_get_size()) {
@@ -157,8 +289,21 @@ int tts_destroy(tts_h tts)
        return TTS_ERROR_NONE;
 }
 
+void __tts_screen_reader_changed_cb(bool value)
+{
+       g_screen_reader = value;
+}
+
 int tts_set_mode(tts_h tts, tts_mode_e mode)
 {
+       bool tts_supported = false;
+       if (0 == system_info_get_platform_bool(TTS_FEATURE_PATH, &tts_supported)) {
+               if (false == tts_supported) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] TTS NOT supported");
+                       return TTS_ERROR_NOT_SUPPORTED;
+               }
+       }
+
        SLOG(LOG_DEBUG, TAG_TTSC, "===== Set TTS mode");
 
        tts_client_s* client = tts_client_get(tts);
@@ -188,6 +333,20 @@ int tts_set_mode(tts_h tts, tts_mode_e mode)
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
+       if (TTS_MODE_SCREEN_READER == mode) {
+               int ret;
+               int screen_reader;
+               ret = vconf_get_bool(TTS_ACCESSIBILITY_KEY, &screen_reader);
+               if (0 != ret) {
+                       SLOG(LOG_ERROR, tts_tag(), "[Config ERROR] Fail to get screen reader");
+                       return TTS_ERROR_OPERATION_FAILED;
+               }
+               g_screen_reader = (bool)screen_reader;
+               tts_config_set_screen_reader_callback(client->uid, __tts_screen_reader_changed_cb);
+       } else {
+               tts_config_unset_screen_reader_callback(client->uid);
+       }
+
        SLOG(LOG_DEBUG, TAG_TTSC, "=====");
        SLOG(LOG_DEBUG, TAG_TTSC, " ");
 
@@ -196,6 +355,14 @@ int tts_set_mode(tts_h tts, tts_mode_e mode)
 
 int tts_get_mode(tts_h tts, tts_mode_e* mode)
 {
+       bool tts_supported = false;
+       if (0 == system_info_get_platform_bool(TTS_FEATURE_PATH, &tts_supported)) {
+               if (false == tts_supported) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] TTS NOT supported");
+                       return TTS_ERROR_NOT_SUPPORTED;
+               }
+       }
+
        SLOG(LOG_DEBUG, TAG_TTSC, "===== Get TTS mode");
 
        tts_client_s* client = tts_client_get(tts);
@@ -231,34 +398,97 @@ int tts_get_mode(tts_h tts, tts_mode_e* mode)
        return TTS_ERROR_NONE;
 }
 
+static void* __fork_tts_daemon(void* data)
+{
+       char daemon_path[64] = {'\0',};
+       int pid, i;
+       tts_mode_e mode;
+
+       mode = (tts_mode_e)data;
+
+       if (TTS_MODE_DEFAULT == mode) {
+               snprintf(daemon_path, 64, "%s", "/usr/bin/tts-daemon");
+       } else if (TTS_MODE_NOTIFICATION == mode) {
+               snprintf(daemon_path, 64, "%s", "/usr/bin/tts-daemon-noti");
+       } else if (TTS_MODE_SCREEN_READER == mode) {
+               snprintf(daemon_path, 64, "%s", "/usr/bin/tts-daemon-sr");
+       } else {
+               SLOG(LOG_ERROR, TAG_TTSC, "mode is not valid");
+               return (void*)-1;
+       }
+       
+       /* fork-exec daemom */
+       pid = fork();
+
+       switch(pid) {
+       case -1:
+               SLOG(LOG_ERROR, TAG_TTSC, "Fail to create daemon");
+               break;
+
+       case 0:
+               setsid();
+               for (i = 0;i < _NSIG;i++)
+                       signal(i, SIG_DFL);
+
+               execl(daemon_path, daemon_path, NULL);
+               break;
+
+       default:
+               break;
+       }
+
+       return (void*) 1;
+}
+
 static Eina_Bool __tts_connect_daemon(void *data)
 {
        tts_h tts = (tts_h)data;
-
        tts_client_s* client = tts_client_get(tts);
 
        /* check handle */
        if (NULL == client) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid");
+               g_connect_timer = NULL;
                return EINA_FALSE;
        }
 
        /* Send hello */
        if (0 != tts_dbus_request_hello(client->uid)) {
+               pthread_t thread;
+               int thread_id;
+
                if (TTS_MODE_SCREEN_READER == client->mode) {
                        if (false == g_is_sr_daemon_started) {
                                g_is_sr_daemon_started = true;
-                               __tts_check_tts_daemon(client->mode);
+                               thread_id = pthread_create(&thread, NULL, __fork_tts_daemon, (void*)TTS_MODE_SCREEN_READER);
+                               if (thread_id < 0) {
+                                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to make thread");
+                                       g_connect_timer = NULL;
+                                       return EINA_FALSE;
+                               }
+                               pthread_detach(thread);
                        }
                } else if (TTS_MODE_NOTIFICATION == client->mode) {
                        if (false == g_is_noti_daemon_started) {
                                g_is_noti_daemon_started = true;
-                               __tts_check_tts_daemon(client->mode);
+                               thread_id = pthread_create(&thread, NULL, __fork_tts_daemon, (void*)TTS_MODE_NOTIFICATION);
+                               if (thread_id < 0) {
+                                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to make thread");
+                                       g_connect_timer = NULL;
+                                       return EINA_FALSE;
+                               }
+                               pthread_detach(thread);
                        }
                } else {
                        if (false == g_is_daemon_started) {
                                g_is_daemon_started = true;
-                               __tts_check_tts_daemon(client->mode);
+                               thread_id = pthread_create(&thread, NULL, __fork_tts_daemon, (void*)TTS_MODE_DEFAULT);
+                               if (thread_id < 0) {
+                                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to make thread");
+                                       g_connect_timer = NULL;
+                                       return EINA_FALSE;
+                               }
+                               pthread_detach(thread);
                        }
                }
                
@@ -269,33 +499,31 @@ static Eina_Bool __tts_connect_daemon(void *data)
 
        /* do request initialize */
        int ret = -1;
-
        ret = tts_dbus_request_initialize(client->uid);
 
        if (TTS_ERROR_ENGINE_NOT_FOUND == ret) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Engine not found");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to initialize : %s", __tts_get_error_code(ret));
                
                client->reason = TTS_ERROR_ENGINE_NOT_FOUND;
                client->utt_id = -1;
 
                ecore_timer_add(0, __tts_notify_error, (void*)client->tts);
+               g_connect_timer = NULL;
                return EINA_FALSE;
 
        } else if (TTS_ERROR_NONE != ret) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to connection");
-
-               client->reason = TTS_ERROR_TIMED_OUT;
-               client->utt_id = -1;
+               SLOG(LOG_WARN, TAG_TTSC, "[WARNING] Fail to connection. Retry to connect : %s", __tts_get_error_code(ret));
+               return EINA_TRUE;
 
-               ecore_timer_add(0, __tts_notify_error, (void*)client->tts);
-               return EINA_FALSE;
        } else {
                /* success to connect tts-daemon */
        }
 
-       if (0 == tts_client_get_connected_client_count()) {
-               SLOG(LOG_DEBUG, TAG_TTSC, "Open file msg connection");
-               ret = tts_file_msg_open_connection();
+       g_connect_timer = NULL;
+
+       if (0 == tts_client_get_mode_client_count(client->mode)) {
+               SLOG(LOG_DEBUG, TAG_TTSC, "Open file msg connection : mode(%d)", client->mode);
+               ret = tts_file_msg_open_connection(client->mode);
                if (0 != ret) {
                        SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to open file message connection");
                        ecore_timer_add(0, __tts_notify_error, (void*)client->tts);
@@ -303,14 +531,23 @@ static Eina_Bool __tts_connect_daemon(void *data)
                }
        }
 
+       client = tts_client_get(tts);
+       /* check handle */
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid");
+               return EINA_FALSE;
+       }
+
        client->before_state = client->current_state;
        client->current_state = TTS_STATE_READY;
 
-       ecore_timer_add(0, __tts_notify_state_changed, (void*)client->tts);
-
-       g_connect_timer = NULL;
-
-       SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] uid(%d)", client->uid);
+       if (NULL != client->state_changed_cb) {
+               tts_client_use_callback(client);
+               client->state_changed_cb(client->tts, client->before_state, client->current_state, client->state_changed_user_data); 
+               tts_client_not_use_callback(client);
+       } else {
+               SLOG(LOG_WARN, TAG_TTSC, "State changed callback is NULL");
+       }
 
        SLOG(LOG_DEBUG, TAG_TTSC, "=====");
        SLOG(LOG_DEBUG, TAG_TTSC, " ");
@@ -320,6 +557,14 @@ static Eina_Bool __tts_connect_daemon(void *data)
 
 int tts_prepare(tts_h tts)
 {
+       bool tts_supported = false;
+       if (0 == system_info_get_platform_bool(TTS_FEATURE_PATH, &tts_supported)) {
+               if (false == tts_supported) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] TTS NOT supported");
+                       return TTS_ERROR_NOT_SUPPORTED;
+               }
+       }
+
        SLOG(LOG_DEBUG, TAG_TTSC, "===== Prepare TTS");
 
        tts_client_s* client = tts_client_get(tts);
@@ -350,6 +595,14 @@ int tts_prepare(tts_h tts)
 
 int tts_unprepare(tts_h tts)
 {
+       bool tts_supported = false;
+       if (0 == system_info_get_platform_bool(TTS_FEATURE_PATH, &tts_supported)) {
+               if (false == tts_supported) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] TTS NOT supported");
+                       return TTS_ERROR_NOT_SUPPORTED;
+               }
+       }
+
        SLOG(LOG_DEBUG, TAG_TTSC, "===== Unprepare TTS");
 
        tts_client_s* client = tts_client_get(tts);
@@ -367,12 +620,29 @@ int tts_unprepare(tts_h tts)
                SLOG(LOG_DEBUG, TAG_TTSC, " ");
                return TTS_ERROR_INVALID_STATE;
        }
-       
-       int ret;
 
-       ret = tts_dbus_request_finalize(client->uid);
-       if (0 != ret) {
-               SLOG(LOG_WARN, TAG_TTSC, "[ERROR] Fail to request finalize");
+       int ret = -1;
+       int count = 0;
+       if (!(false == g_screen_reader && TTS_MODE_SCREEN_READER == client->mode)) {
+               while (0 != ret) {
+                       ret = tts_dbus_request_finalize(client->uid);
+                       if (0 != ret) {
+                               if (TTS_ERROR_TIMED_OUT != ret) {
+                                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] result : %s", __tts_get_error_code(ret));
+                                       break;
+                               } else {
+                                       SLOG(LOG_WARN, TAG_TTSC, "[WARNING] retry finalize : %s", __tts_get_error_code(ret));
+                                       usleep(10);
+                                       count++;
+                                       if (10 == count) {
+                                               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to request");
+                                               break;
+                                       }
+                               }
+                       }
+               }
+       } else {
+               SLOG(LOG_WARN, TAG_TTSC, "[WARNING] Do not request finalize : g_sr(%d) mode(%d)", g_screen_reader, client->mode);
        }
 
        if (TTS_MODE_SCREEN_READER == client->mode) 
@@ -385,12 +655,17 @@ int tts_unprepare(tts_h tts)
        client->before_state = client->current_state;
        client->current_state = TTS_STATE_CREATED;
 
-       ecore_timer_add(0, __tts_notify_state_changed, (void*)tts);
+       if (NULL != client->state_changed_cb) {
+               tts_client_use_callback(client);
+               client->state_changed_cb(client->tts, client->before_state, client->current_state, client->state_changed_user_data); 
+               tts_client_not_use_callback(client);
+               SLOG(LOG_DEBUG, TAG_TTSC, "State changed callback is called");
+       }
 
        /* Close file message connection */
-       if (0 == tts_client_get_connected_client_count()) {
-               SLOG(LOG_DEBUG, TAG_TTSC, "Close file msg connection");
-               ret = tts_file_msg_close_connection();
+       if (0 == tts_client_get_mode_client_count(client->mode)) {
+               SLOG(LOG_DEBUG, TAG_TTSC, "Close file msg connection : mode(%d)", client->mode);
+               ret = tts_file_msg_close_connection(client->mode);
                if (0 != ret)
                        SLOG(LOG_WARN, TAG_TTSC, "[ERROR] Fail to close file message connection");
        }
@@ -401,8 +676,36 @@ int tts_unprepare(tts_h tts)
        return TTS_ERROR_NONE;
 }
 
+bool __tts_supported_voice_cb(const char* engine_id, const char* language, int type, void* user_data)
+{
+       tts_h tts = (tts_h)user_data;
+
+       tts_client_s* client = tts_client_get(tts);
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[WARNING] A handle is not valid");
+               return false;
+       }
+
+       /* call callback function */
+       if (NULL != client->supported_voice_cb) {
+               return client->supported_voice_cb(tts, language, type, client->supported_voice_user_data);
+       } else {
+               SLOG(LOG_WARN, TAG_TTSC, "No registered callback function of supported voice");
+       }
+
+       return false;
+}
+
 int tts_foreach_supported_voices(tts_h tts, tts_supported_voice_cb callback, void* user_data)
 {
+       bool tts_supported = false;
+       if (0 == system_info_get_platform_bool(TTS_FEATURE_PATH, &tts_supported)) {
+               if (false == tts_supported) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] TTS NOT supported");
+                       return TTS_ERROR_NOT_SUPPORTED;
+               }
+       }
+
        SLOG(LOG_DEBUG, TAG_TTSC, "===== Foreach supported voices");
 
        if (NULL == tts || NULL == callback) {
@@ -422,17 +725,28 @@ int tts_foreach_supported_voices(tts_h tts, tts_supported_voice_cb callback, voi
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
-       if (TTS_STATE_READY != client->current_state) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Current state is NOT 'READY'.");  
-               SLOG(LOG_DEBUG, TAG_TTSC, "=====");
-               SLOG(LOG_DEBUG, TAG_TTSC, " ");
-               return TTS_ERROR_INVALID_STATE;
+       int ret = 0;
+       char* current_engine = NULL;
+       ret = tts_config_mgr_get_engine(&current_engine);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get current engine : %d", ret);
+               return __tts_convert_config_error_code(ret);
        }
 
-       int ret = 0;
-       ret = tts_dbus_request_get_support_voice(client->uid, client->tts, callback, user_data);
+       client->supported_voice_cb = callback;
+       client->supported_voice_user_data = user_data;
+
+       ret = tts_config_mgr_get_voice_list(current_engine, __tts_supported_voice_cb, client->tts);
+
+       if (NULL != current_engine)
+               free(current_engine);
+
+       client->supported_voice_cb = NULL;
+       client->supported_voice_user_data = NULL;
+
        if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] result : %d", ret);
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Result : %d", ret);
+               ret = TTS_ERROR_OPERATION_FAILED;
        }    
 
        SLOG(LOG_DEBUG, TAG_TTSC, "=====");
@@ -441,8 +755,16 @@ int tts_foreach_supported_voices(tts_h tts, tts_supported_voice_cb callback, voi
        return ret;
 }
 
-int tts_get_default_voice(tts_h tts, char** lang, tts_voice_type_e* vctype)
+int tts_get_default_voice(tts_h tts, char** lang, int* vctype)
 {
+       bool tts_supported = false;
+       if (0 == system_info_get_platform_bool(TTS_FEATURE_PATH, &tts_supported)) {
+               if (false == tts_supported) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] TTS NOT supported");
+                       return TTS_ERROR_NOT_SUPPORTED;
+               }
+       }
+
        SLOG(LOG_DEBUG, TAG_TTSC, "===== Get default voice");
 
        if (NULL == tts) {
@@ -461,19 +783,14 @@ int tts_get_default_voice(tts_h tts, char** lang, tts_voice_type_e* vctype)
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
-       if (TTS_STATE_READY != client->current_state) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Current state is NOT 'READY'. ");
-               SLOG(LOG_DEBUG, TAG_TTSC, "=====");
-               SLOG(LOG_DEBUG, TAG_TTSC, " ");
-               return TTS_ERROR_INVALID_STATE;
-       }
-
        /* Request call remote method */
        int ret = 0;
-       ret = tts_dbus_request_get_default_voice(client->uid, lang, vctype );
-    
-       if (0 != ret) {
+       ret = tts_config_mgr_get_voice(lang, vctype);
+       if (0 != ret) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] result : %d", ret);
+               return __tts_convert_config_error_code(ret);
+       } else {
+               SECURE_SLOG(LOG_DEBUG, TAG_TTSC, "[DEBUG] Default language(%s), type(%d)", *lang, *vctype);
        }
        
        SLOG(LOG_DEBUG, TAG_TTSC, "=====");
@@ -482,9 +799,17 @@ int tts_get_default_voice(tts_h tts, char** lang, tts_voice_type_e* vctype)
        return ret;
 }
 
-int tts_get_max_text_count(tts_h tts, int* count)
+int tts_get_max_text_size(tts_h tts, unsigned int* size)
 {
-       if (NULL == tts || NULL == count) {
+       bool tts_supported = false;
+       if (0 == system_info_get_platform_bool(TTS_FEATURE_PATH, &tts_supported)) {
+               if (false == tts_supported) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] TTS NOT supported");
+                       return TTS_ERROR_NOT_SUPPORTED;
+               }
+       }
+
+       if (NULL == tts || NULL == size) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Get max text count : Input parameter is null");
                return TTS_ERROR_INVALID_PARAMETER;
        }
@@ -501,14 +826,22 @@ int tts_get_max_text_count(tts_h tts, int* count)
                return TTS_ERROR_INVALID_STATE;
        }
 
-       *count = MAX_TEXT_COUNT;
+       *size = TTS_MAX_TEXT_SIZE;
 
-       SLOG(LOG_DEBUG, TAG_TTSC, "[Suceess] Get max text count");
+       SLOG(LOG_DEBUG, TAG_TTSC, "Get max text count : %d", *size);
        return TTS_ERROR_NONE;
 }
 
 int tts_get_state(tts_h tts, tts_state_e* state)
 {
+       bool tts_supported = false;
+       if (0 == system_info_get_platform_bool(TTS_FEATURE_PATH, &tts_supported)) {
+               if (false == tts_supported) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] TTS NOT supported");
+                       return TTS_ERROR_NOT_SUPPORTED;
+               }
+       }
+
        if (NULL == tts || NULL == state) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Get state : Input parameter is null");
                return TTS_ERROR_INVALID_PARAMETER;
@@ -528,13 +861,51 @@ int tts_get_state(tts_h tts, tts_state_e* state)
                case TTS_STATE_READY:   SLOG(LOG_DEBUG, TAG_TTSC, "Current state is 'Ready'");          break;
                case TTS_STATE_PLAYING: SLOG(LOG_DEBUG, TAG_TTSC, "Current state is 'Playing'");        break;
                case TTS_STATE_PAUSED:  SLOG(LOG_DEBUG, TAG_TTSC, "Current state is 'Paused'");         break;
+               default:                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Invalid value");             break;
        }
 
        return TTS_ERROR_NONE;
 }
 
-int tts_add_text(tts_h tts, const char* text, const char* language, tts_voice_type_e voice_type, tts_speed_e speed, int* utt_id)
+int tts_get_speed_range(tts_h tts, int* min, int* normal, int* max)
 {
+       bool tts_supported = false;
+       if (0 == system_info_get_platform_bool(TTS_FEATURE_PATH, &tts_supported)) {
+               if (false == tts_supported) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] TTS NOT supported");
+                       return TTS_ERROR_NOT_SUPPORTED;
+               }
+       }
+
+       if (NULL == tts || NULL == min || NULL == normal || NULL == max) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input parameter is null");
+               return TTS_ERROR_INVALID_PARAMETER;
+       }
+
+       tts_client_s* client = tts_client_get(tts);
+
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Get state : A handle is not valid");
+               return TTS_ERROR_INVALID_PARAMETER;
+       }
+
+       *min = TTS_SPEED_MIN;
+       *normal = TTS_SPEED_NORMAL;
+       *max = TTS_SPEED_MAX;
+
+       return TTS_ERROR_NONE;
+}
+
+int tts_add_text(tts_h tts, const char* text, const char* language, int voice_type, int speed, int* utt_id)
+{
+       bool tts_supported = false;
+       if (0 == system_info_get_platform_bool(TTS_FEATURE_PATH, &tts_supported)) {
+               if (false == tts_supported) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] TTS NOT supported");
+                       return TTS_ERROR_NOT_SUPPORTED;
+               }
+       }
+
        SLOG(LOG_DEBUG, TAG_TTSC, "===== Add text");
 
        if (NULL == tts || NULL == utt_id) {
@@ -558,13 +929,50 @@ int tts_add_text(tts_h tts, const char* text, const char* language, tts_voice_ty
                return TTS_ERROR_INVALID_STATE;
        }
 
-       if (MAX_TEXT_COUNT < strlen(text)) {
+       if (TTS_MAX_TEXT_SIZE < strlen(text)) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input text size is too big.");
                SLOG(LOG_DEBUG, TAG_TTSC, "=====");
                SLOG(LOG_DEBUG, TAG_TTSC, " ");
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
+       if (false == g_screen_reader && TTS_MODE_SCREEN_READER == client->mode) {
+               SLOG(LOG_WARN, TAG_TTSC, "[WARNING] Screen reader option is NOT available. Ignore this request");
+               return TTS_ERROR_INVALID_STATE;
+       }
+
+       /* check valid utf8 */
+       iconv_t *ict;
+       ict = iconv_open("utf-8", "");
+       if ((iconv_t)-1 == ict) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to init for text check");
+               return TTS_ERROR_OPERATION_FAILED;
+       }
+
+       size_t len = strlen(text);
+       char *in_tmp = NULL;
+       char in_buf[TTS_MAX_TEXT_SIZE];
+       char *out_tmp = NULL;
+       char out_buf[TTS_MAX_TEXT_SIZE];
+       size_t len_tmp = sizeof(out_buf);
+
+       memset(in_buf, 0, TTS_MAX_TEXT_SIZE);
+       snprintf(in_buf, TTS_MAX_TEXT_SIZE, "%s", text);
+       in_tmp = in_buf;
+
+       memset(out_buf, 0, TTS_MAX_TEXT_SIZE);
+       out_tmp = out_buf;
+
+       size_t st;
+       st = iconv(ict, &in_tmp, &len, &out_tmp, &len_tmp);
+       if ((size_t)-1 == st) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Text is invalid - '%s'", in_buf);
+               iconv_close(ict);
+               return TTS_ERROR_INVALID_PARAMETER;
+       }
+       iconv_close(ict);
+       SECURE_SLOG(LOG_DEBUG, TAG_TTSC, "Text is valid - Converted text is '%s'", out_buf);
+
        /* change default language value */
        char* temp = NULL;
 
@@ -579,16 +987,29 @@ int tts_add_text(tts_h tts, const char* text, const char* language, tts_voice_ty
        }
 
        /* do request */
-       int ret = 0;
-       ret = tts_dbus_request_add_text(client->uid, text, temp, voice_type, speed, client->current_utt_id);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] result : %d", ret);
-       } else {
-               *utt_id = client->current_utt_id;
+       int ret = -1;
+       int count = 0;
+       while (0 != ret) {
+               ret = tts_dbus_request_add_text(client->uid, out_buf, temp, voice_type, speed, client->current_utt_id);
+               if (0 != ret) {
+                       if (TTS_ERROR_TIMED_OUT != ret) {
+                               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] result : %s", __tts_get_error_code(ret));
+                               break;
+                       } else {
+                               SLOG(LOG_WARN, TAG_TTSC, "[WARNING] retry add text : %s", __tts_get_error_code(ret));
+                               usleep(10);
+                               count++;
+                               if (10 == count) {
+                                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to request");
+                                       break;
+                               }
+                       }
+               } else {
+                       *utt_id = client->current_utt_id;
+               }
        }
 
-       if (NULL != temp)
-               free(temp);
+       if (NULL != temp)       free(temp);
 
        SLOG(LOG_DEBUG, TAG_TTSC, "=====");
        SLOG(LOG_DEBUG, TAG_TTSC, " ");
@@ -598,6 +1019,14 @@ int tts_add_text(tts_h tts, const char* text, const char* language, tts_voice_ty
 
 int tts_play(tts_h tts)
 {
+       bool tts_supported = false;
+       if (0 == system_info_get_platform_bool(TTS_FEATURE_PATH, &tts_supported)) {
+               if (false == tts_supported) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] TTS NOT supported");
+                       return TTS_ERROR_NOT_SUPPORTED;
+               }
+       }
+
        SLOG(LOG_DEBUG, TAG_TTSC, "===== Play tts");
 
        if (NULL == tts) {
@@ -619,24 +1048,41 @@ int tts_play(tts_h tts)
        if (TTS_STATE_PLAYING == client->current_state || TTS_STATE_CREATED == client->current_state) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] The current state is invalid."); 
                return TTS_ERROR_INVALID_STATE;
-       } 
+       }
 
-       int ret = 0;
-       ret = tts_dbus_request_play(client->uid);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Request play : result(%d)", ret);
-               SLOG(LOG_DEBUG, TAG_TTSC, "=====");
-               SLOG(LOG_DEBUG, TAG_TTSC, " ");
-               return ret;
+       if (false == g_screen_reader && TTS_MODE_SCREEN_READER == client->mode) {
+               SLOG(LOG_WARN, TAG_TTSC, "[WARNING] Screen reader option is NOT available. Ignore this request");
+               return TTS_ERROR_INVALID_STATE;
+       }
+
+       int ret = -1;
+       int count = 0;
+       while (0 != ret) {
+               ret = tts_dbus_request_play(client->uid);
+               if (0 != ret) {
+                       if (TTS_ERROR_TIMED_OUT != ret) {
+                               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] result : %s", __tts_get_error_code(ret));
+                               return ret;
+                       } else {
+                               SLOG(LOG_WARN, TAG_TTSC, "[WARNING] retry play : %s", __tts_get_error_code(ret));
+                               usleep(10);
+                               count++;
+                               if (10 == count) {
+                                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to request");
+                                       return ret;
+                               }
+                       }
+               }
        }
 
        client->before_state = client->current_state;
        client->current_state = TTS_STATE_PLAYING;
 
        if (NULL != client->state_changed_cb) {
-               ecore_timer_add(0, __tts_notify_state_changed, (void*)tts);
-       } else {
-               SLOG(LOG_WARN, TAG_TTSC, "[WARNING] State changed callback is null");
+               tts_client_use_callback(client);
+               client->state_changed_cb(client->tts, client->before_state, client->current_state, client->state_changed_user_data); 
+               tts_client_not_use_callback(client);
+               SLOG(LOG_DEBUG, TAG_TTSC, "State changed callback is called");
        }
 
        SLOG(LOG_DEBUG, TAG_TTSC, "=====");
@@ -648,6 +1094,14 @@ int tts_play(tts_h tts)
 
 int tts_stop(tts_h tts)
 {
+       bool tts_supported = false;
+       if (0 == system_info_get_platform_bool(TTS_FEATURE_PATH, &tts_supported)) {
+               if (false == tts_supported) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] TTS NOT supported");
+                       return TTS_ERROR_NOT_SUPPORTED;
+               }
+       }
+
        SLOG(LOG_DEBUG, TAG_TTSC, "===== Stop tts");
 
        if (NULL == tts) {
@@ -671,22 +1125,39 @@ int tts_stop(tts_h tts)
                return TTS_ERROR_INVALID_STATE;
        }
 
-       int ret = 0;
-       ret = tts_dbus_request_stop(client->uid);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] result : %d", ret);
-               SLOG(LOG_DEBUG, TAG_TTSC, "=====");
-               SLOG(LOG_DEBUG, TAG_TTSC, " ");
-               return ret;
-       }       
+       if (false == g_screen_reader && TTS_MODE_SCREEN_READER == client->mode) {
+               SLOG(LOG_WARN, TAG_TTSC, "[WARNING] Screen reader option is NOT available. Ignore this request");
+               return TTS_ERROR_INVALID_STATE;
+       }
+
+       int ret = -1;
+       int count = 0;
+       while (0 != ret) {
+               ret = tts_dbus_request_stop(client->uid);
+               if (0 != ret) {
+                       if (TTS_ERROR_TIMED_OUT != ret) {
+                               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] result : %s", __tts_get_error_code(ret));
+                               return ret;
+                       } else {
+                               SLOG(LOG_WARN, TAG_TTSC, "[WARNING] retry stop : %s", __tts_get_error_code(ret));
+                               usleep(10);
+                               count++;
+                               if (10 == count) {
+                                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to request");
+                                       return ret;
+                               }
+                       }
+               }
+       }
 
        client->before_state = client->current_state;
        client->current_state = TTS_STATE_READY;
 
        if (NULL != client->state_changed_cb) {
-               ecore_timer_add(0, __tts_notify_state_changed, (void*)tts);
-       } else {
-               SLOG(LOG_WARN, TAG_TTSC, "[WARNING] State changed callback is null");
+               tts_client_use_callback(client);
+               client->state_changed_cb(client->tts, client->before_state, client->current_state, client->state_changed_user_data); 
+               tts_client_not_use_callback(client);
+               SLOG(LOG_DEBUG, TAG_TTSC, "State changed callback is called");
        }
 
        SLOG(LOG_DEBUG, TAG_TTSC, "=====");
@@ -698,6 +1169,14 @@ int tts_stop(tts_h tts)
 
 int tts_pause(tts_h tts)
 {
+       bool tts_supported = false;
+       if (0 == system_info_get_platform_bool(TTS_FEATURE_PATH, &tts_supported)) {
+               if (false == tts_supported) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] TTS NOT supported");
+                       return TTS_ERROR_NOT_SUPPORTED;
+               }
+       }
+
        SLOG(LOG_DEBUG, TAG_TTSC, "===== Pause tts");
 
        if (NULL == tts) {
@@ -721,24 +1200,41 @@ int tts_pause(tts_h tts)
                SLOG(LOG_DEBUG, TAG_TTSC, "=====");
                SLOG(LOG_DEBUG, TAG_TTSC, " ");
                return TTS_ERROR_INVALID_STATE;
-       }       
-       
-       int ret = 0;
-       ret = tts_dbus_request_pause(client->uid);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Request pause : result(%d)", ret);
-               SLOG(LOG_DEBUG, TAG_TTSC, "=====");
-               SLOG(LOG_DEBUG, TAG_TTSC, " ");
-               return ret;
        }
 
+       if (false == g_screen_reader && TTS_MODE_SCREEN_READER == client->mode) {
+               SLOG(LOG_WARN, TAG_TTSC, "[WARNING] Screen reader option is NOT available. Ignore this request");
+               return TTS_ERROR_INVALID_STATE;
+       }
+
+       int ret = -1;
+       int count = 0;
+       while (0 != ret) {
+               ret = tts_dbus_request_pause(client->uid);
+               if (0 != ret) {
+                       if (TTS_ERROR_TIMED_OUT != ret) {
+                               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] result : %s", __tts_get_error_code(ret));
+                               return ret;
+                       } else {
+                               SLOG(LOG_WARN, TAG_TTSC, "[WARNING] retry pause : %s", __tts_get_error_code(ret));
+                               usleep(10);
+                               count++;
+                               if (10 == count) {
+                                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to request");
+                                       return ret;
+                               }
+                       }
+               }
+       }
+       
        client->before_state = client->current_state;
        client->current_state = TTS_STATE_PAUSED;
 
        if (NULL != client->state_changed_cb) {
-               ecore_timer_add(0, __tts_notify_state_changed, (void*)tts);
-       } else {
-               SLOG(LOG_WARN, TAG_TTSC, "[WARNING] State changed callback is null");
+               tts_client_use_callback(client);
+               client->state_changed_cb(client->tts, client->before_state, client->current_state, client->state_changed_user_data); 
+               tts_client_not_use_callback(client);
+               SLOG(LOG_DEBUG, TAG_TTSC, "State changed callback is called");
        }
 
        SLOG(LOG_DEBUG, TAG_TTSC, "=====");
@@ -759,6 +1255,8 @@ static Eina_Bool __tts_notify_error(void *data)
                return EINA_FALSE;
        }
 
+       SLOG(LOG_DEBUG, TAG_TTSC, "Error data : uttid(%d) reason(%s)", client->utt_id, __tts_get_error_code(client->reason));
+
        if (NULL != client->error_cb) {
                SLOG(LOG_DEBUG, TAG_TTSC, "Call callback function of error");
                tts_client_use_callback(client);
@@ -809,7 +1307,7 @@ static Eina_Bool __tts_notify_state_changed(void *data)
                tts_client_use_callback(client);
                client->state_changed_cb(client->tts, client->before_state, client->current_state, client->state_changed_user_data); 
                tts_client_not_use_callback(client);
-               SLOG(LOG_DEBUG, TAG_TTSC, "State changed callback is called");
+               SLOG(LOG_DEBUG, TAG_TTSC, "State changed callback is called : pre(%d) cur(%d)", client->before_state, client->current_state);
        } else {
                SLOG(LOG_WARN, TAG_TTSC, "[WARNING] State changed callback is null");
        }
@@ -877,7 +1375,7 @@ int __tts_cb_utt_started(int uid, int utt_id)
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
-       SLOG(LOG_DEBUG, TAG_TTSC, "utterance started : utt id(%d) ", utt_id);
+       SECURE_SLOG(LOG_DEBUG, TAG_TTSC, "utterance started : utt id(%d) ", utt_id);
 
        client->utt_id = utt_id;
 
@@ -924,7 +1422,7 @@ int __tts_cb_utt_completed(int uid, int utt_id)
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
-       SLOG(LOG_DEBUG, TAG_TTSC, "utterance completed : uttid(%d) ", utt_id);
+       SECURE_SLOG(LOG_DEBUG, TAG_TTSC, "utterance completed : uttid(%d) ", utt_id);
 
        client->utt_id = utt_id;
 
@@ -940,6 +1438,14 @@ int __tts_cb_utt_completed(int uid, int utt_id)
 
 int tts_set_state_changed_cb(tts_h tts, tts_state_changed_cb callback, void* user_data)
 {
+       bool tts_supported = false;
+       if (0 == system_info_get_platform_bool(TTS_FEATURE_PATH, &tts_supported)) {
+               if (false == tts_supported) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] TTS NOT supported");
+                       return TTS_ERROR_NOT_SUPPORTED;
+               }
+       }
+
        if (NULL == tts || NULL == callback) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set state changed cb : Input parameter is null");
                return TTS_ERROR_INVALID_PARAMETER;
@@ -967,6 +1473,14 @@ int tts_set_state_changed_cb(tts_h tts, tts_state_changed_cb callback, void* use
 
 int tts_unset_state_changed_cb(tts_h tts)
 {
+       bool tts_supported = false;
+       if (0 == system_info_get_platform_bool(TTS_FEATURE_PATH, &tts_supported)) {
+               if (false == tts_supported) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] TTS NOT supported");
+                       return TTS_ERROR_NOT_SUPPORTED;
+               }
+       }
+
        if (NULL == tts) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset state changed cb : Input parameter is null");
                return TTS_ERROR_INVALID_PARAMETER;
@@ -994,6 +1508,14 @@ int tts_unset_state_changed_cb(tts_h tts)
 
 int tts_set_utterance_started_cb(tts_h tts, tts_utterance_started_cb callback, void* user_data)
 {
+       bool tts_supported = false;
+       if (0 == system_info_get_platform_bool(TTS_FEATURE_PATH, &tts_supported)) {
+               if (false == tts_supported) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] TTS NOT supported");
+                       return TTS_ERROR_NOT_SUPPORTED;
+               }
+       }
+
        if (NULL == tts || NULL == callback) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set utt started cb : Input parameter is null");
                return TTS_ERROR_INVALID_PARAMETER;
@@ -1021,6 +1543,14 @@ int tts_set_utterance_started_cb(tts_h tts, tts_utterance_started_cb callback, v
 
 int tts_unset_utterance_started_cb(tts_h tts)
 {
+       bool tts_supported = false;
+       if (0 == system_info_get_platform_bool(TTS_FEATURE_PATH, &tts_supported)) {
+               if (false == tts_supported) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] TTS NOT supported");
+                       return TTS_ERROR_NOT_SUPPORTED;
+               }
+       }
+
        if (NULL == tts) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset utt started cb : Input parameter is null");
                return TTS_ERROR_INVALID_PARAMETER;
@@ -1048,6 +1578,14 @@ int tts_unset_utterance_started_cb(tts_h tts)
 
 int tts_set_utterance_completed_cb(tts_h tts, tts_utterance_completed_cb callback, void* user_data)
 {
+       bool tts_supported = false;
+       if (0 == system_info_get_platform_bool(TTS_FEATURE_PATH, &tts_supported)) {
+               if (false == tts_supported) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] TTS NOT supported");
+                       return TTS_ERROR_NOT_SUPPORTED;
+               }
+       }
+
        if (NULL == tts || NULL == callback) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set utt completed cb : Input parameter is null");
                return TTS_ERROR_INVALID_PARAMETER;
@@ -1075,6 +1613,14 @@ int tts_set_utterance_completed_cb(tts_h tts, tts_utterance_completed_cb callbac
 
 int tts_unset_utterance_completed_cb(tts_h tts)
 {
+       bool tts_supported = false;
+       if (0 == system_info_get_platform_bool(TTS_FEATURE_PATH, &tts_supported)) {
+               if (false == tts_supported) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] TTS NOT supported");
+                       return TTS_ERROR_NOT_SUPPORTED;
+               }
+       }
+
        if (NULL == tts) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset utt completed cb : Input parameter is null");
                return TTS_ERROR_INVALID_PARAMETER;
@@ -1101,6 +1647,14 @@ int tts_unset_utterance_completed_cb(tts_h tts)
 
 int tts_set_error_cb(tts_h tts, tts_error_cb callback, void* user_data)
 {
+       bool tts_supported = false;
+       if (0 == system_info_get_platform_bool(TTS_FEATURE_PATH, &tts_supported)) {
+               if (false == tts_supported) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] TTS NOT supported");
+                       return TTS_ERROR_NOT_SUPPORTED;
+               }
+       }
+
        if (NULL == tts || NULL == callback) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set error cb : Input parameter is null");
                return TTS_ERROR_INVALID_PARAMETER;
@@ -1128,6 +1682,14 @@ int tts_set_error_cb(tts_h tts, tts_error_cb callback, void* user_data)
 
 int tts_unset_error_cb(tts_h tts)
 {
+       bool tts_supported = false;
+       if (0 == system_info_get_platform_bool(TTS_FEATURE_PATH, &tts_supported)) {
+               if (false == tts_supported) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] TTS NOT supported");
+                       return TTS_ERROR_NOT_SUPPORTED;
+               }
+       }
+
        if (NULL == tts) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset error cb : Input parameter is null");
                return TTS_ERROR_INVALID_PARAMETER;
@@ -1153,112 +1715,72 @@ int tts_unset_error_cb(tts_h tts)
        return 0;
 }
 
-static int __get_cmd_line(char *file, char *buf) 
+int tts_set_default_voice_changed_cb(tts_h tts, tts_default_voice_changed_cb callback, void* user_data)
 {
-       FILE *fp = NULL;
-
-       fp = fopen(file, "r");
-       if (fp == NULL) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Get command line");
-               return -1;
+       bool tts_supported = false;
+       if (0 == system_info_get_platform_bool(TTS_FEATURE_PATH, &tts_supported)) {
+               if (false == tts_supported) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] TTS NOT supported");
+                       return TTS_ERROR_NOT_SUPPORTED;
+               }
        }
 
-       memset(buf, 0, 256);
-       if (NULL == fgets(buf, 256, fp)) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to fget command line");
-               fclose(fp);
-               return -1;
+       if (NULL == tts || NULL == callback) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set default voice changed cb : Input parameter is null");
+               return TTS_ERROR_INVALID_PARAMETER;
        }
-       fclose(fp);
 
-       return 0;
-}
-
-static bool __tts_is_alive(char* daemon_path)
-{
-       DIR *dir;
-       struct dirent *entry;
-       struct stat filestat;
-       
-       int pid;
-       char cmdLine[256] = {'\0',};
-       char tempPath[256] = {'\0',};
+       tts_client_s* client = tts_client_get(tts);
 
-       dir  = opendir("/proc");
-       if (NULL == dir) {
-               SLOG(LOG_ERROR, TAG_TTSC, "process checking is FAILED");
-               return FALSE;
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set default voice changed cb : A handle is not valid");
+               return TTS_ERROR_INVALID_PARAMETER;
        }
 
-       while ((entry = readdir(dir)) != NULL) {
-               if (0 != lstat(entry->d_name, &filestat)) {
-                       continue;
-               }
+       if (TTS_STATE_CREATED != client->current_state) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set default voice changed cb : Current state is not 'Created'."); 
+               return TTS_ERROR_INVALID_STATE;
+       }
 
-               if (!S_ISDIR(filestat.st_mode)) {
-                       continue;
-               }
+       client->default_voice_changed_cb = callback;
+       client->default_voice_changed_user_data = user_data;
 
-               pid = atoi(entry->d_name);
-               if (pid <= 0) continue;
+       SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Set default voice changed cb");
 
-               sprintf(tempPath, "/proc/%d/cmdline", pid);
-               if (0 != __get_cmd_line(tempPath, cmdLine)) {
-                       continue;
-               }
+       return 0;
+}
 
-               if (0 == strncmp(cmdLine, daemon_path, strlen(daemon_path))) {
-                       SLOG(LOG_DEBUG, TAG_TTSC, "%s is ALIVE !!", daemon_path);
-                       closedir(dir);
-                       return TRUE;
+int tts_unset_default_voice_changed_cb(tts_h tts)
+{
+       bool tts_supported = false;
+       if (0 == system_info_get_platform_bool(TTS_FEATURE_PATH, &tts_supported)) {
+               if (false == tts_supported) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] TTS NOT supported");
+                       return TTS_ERROR_NOT_SUPPORTED;
                }
        }
 
-       SLOG(LOG_DEBUG, TAG_TTSC, "THERE IS NO %s !!", daemon_path);
-
-       closedir(dir);
-       return FALSE;
-}
+       if (NULL == tts) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset default voice changed cb : Input parameter is null");
+               return TTS_ERROR_INVALID_PARAMETER;
+       }
 
-static int __tts_check_tts_daemon(tts_mode_e mode)
-{
-       char daemon_path[64] = {'\0',};
-       int pid, i;
+       tts_client_s* client = tts_client_get(tts);
 
-       if (TTS_MODE_DEFAULT == mode) {
-               strcpy(daemon_path, "/usr/bin/tts-daemon");
-       } else if (TTS_MODE_NOTIFICATION == mode) {
-               strcpy(daemon_path, "/usr/bin/tts-daemon-noti");
-       } else if (TTS_MODE_SCREEN_READER == mode) {
-               strcpy(daemon_path, "/usr/bin/tts-daemon-sr");
-       } else {
-               SLOG(LOG_ERROR, TAG_TTSC, "mode is not valid");
-               return -1;
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset default voice changed cb : A handle is not valid");
+               return TTS_ERROR_INVALID_PARAMETER;
        }
 
-       if (TRUE == __tts_is_alive(daemon_path)) {
-               return 0;
+       if (TTS_STATE_CREATED != client->current_state) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset default voice changed cb : Current state is not 'Created'."); 
+               return TTS_ERROR_INVALID_STATE;
        }
-       
-       /* fork-exec daemom */
-       pid = fork();
-
-       switch(pid) {
-       case -1:
-               SLOG(LOG_ERROR, TAG_TTSC, "Fail to create daemon");
-               break;
-
-       case 0:
-               setsid();
-               for (i = 0;i < _NSIG;i++)
-                       signal(i, SIG_DFL);
 
-               execl(daemon_path, daemon_path, NULL);
-               break;
+       client->default_voice_changed_cb = NULL;
+       client->default_voice_changed_user_data = NULL;
 
-       default:
-               break;
-       }
+       SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Unset default voice changed cb");
 
        return 0;
 }
diff --git a/client/tts.h b/client/tts.h
deleted file mode 100644 (file)
index 8f975ec..0000000
+++ /dev/null
@@ -1,582 +0,0 @@
-/*
- * Copyright (c) 2012, 2013 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 __TTS_H__
-#define __TTS_H__
-
-#include <errno.h>
-#include <stdbool.h>
-
-/**
-* @addtogroup CAPI_UIX_TTS_MODULE
-* @{
-*/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/** 
-* @brief Enumerations of error codes.
-*/
-typedef enum {
-       TTS_ERROR_NONE                  = 0,                    /**< Successful */
-       TTS_ERROR_OUT_OF_MEMORY         = -ENOMEM,              /**< Out of Memory */
-       TTS_ERROR_IO_ERROR              = -EIO,                 /**< I/O error */
-       TTS_ERROR_INVALID_PARAMETER     = -EINVAL,              /**< Invalid parameter */
-       TTS_ERROR_OUT_OF_NETWORK        = -ENETDOWN,            /**< Out of network */
-       TTS_ERROR_INVALID_STATE         = -0x0100000 | 0x21,    /**< Invalid state */
-       TTS_ERROR_INVALID_VOICE         = -0x0100000 | 0x22,    /**< Invalid voice */
-       TTS_ERROR_ENGINE_NOT_FOUND      = -0x0100000 | 0x23,    /**< No available engine */
-       TTS_ERROR_TIMED_OUT             = -0x0100000 | 0x24,    /**< No answer from the daemon */
-       TTS_ERROR_OPERATION_FAILED      = -0x0100000 | 0x25,    /**< Operation failed */
-       TTS_ERROR_AUDIO_POLICY_BLOCKED  = -0x0100000 | 0x26     /**< Audio policy blocked */
-} tts_error_e;
-
-/** 
-* @brief Enumerations of tts mode.
-*/
-typedef enum {
-       TTS_MODE_DEFAULT = 0,           /**< Default mode for normal application */
-       TTS_MODE_NOTIFICATION,          /**< Notification mode */
-       TTS_MODE_SCREEN_READER          /**< Screen reader mode */
-}tts_mode_e;
-
-/** 
-* @brief Enumerations of speaking speed.
-*/
-typedef enum {
-       TTS_SPEED_AUTO,                 /**< Speed from settings */
-       TTS_SPEED_VERY_SLOW,            /**< Very slow */
-       TTS_SPEED_SLOW,                 /**< Slow */
-       TTS_SPEED_NORMAL,               /**< Normal */
-       TTS_SPEED_FAST,                 /**< Fast */
-       TTS_SPEED_VERY_FAST             /**< Very fast */
-}tts_speed_e;
-
-/** 
-* @brief Enumerations of voice type.
-*/
-typedef enum {
-       TTS_VOICE_TYPE_AUTO,            /**< Voice type from settings or auto selection based language */
-       TTS_VOICE_TYPE_MALE,            /**< Male */
-       TTS_VOICE_TYPE_FEMALE,          /**< Female */
-       TTS_VOICE_TYPE_CHILD,           /**< Child */
-       TTS_VOICE_TYPE_USER1,           /**< Engine defined */
-       TTS_VOICE_TYPE_USER2,           /**< Engine defined */
-       TTS_VOICE_TYPE_USER3            /**< Engine defined */
-}tts_voice_type_e;
-
-/** 
-* @brief Enumerations of state.
-*/
-typedef enum {
-       TTS_STATE_CREATED = 0,          /**< 'CREATED' state */
-       TTS_STATE_READY,                /**< 'READY' state */
-       TTS_STATE_PLAYING,              /**< 'PLAYING' state */
-       TTS_STATE_PAUSED                /**< 'PAUSED' state*/
-}tts_state_e;
-
-/** 
-* @brief A structure of handle for identification
-*/
-typedef struct tts_s *tts_h;
-
-
-/**
-* @brief Called when the state of TTS is changed. 
-*
-* @details If the daemon must stop player because of changing engine and 
-*      the daemon must pause player because of other requests, this callback function is called.
-*
-* @param[in] tts The handle for TTS
-* @param[in] previous A previous state
-* @param[in] current A current state
-* @param[in] user_data The user data passed from the callback registration function.
-*
-* @pre An application registers this callback using tts_set_state_changed_cb() to detect changing state.
-*
-* @see tts_set_state_changed_cb()
-* @see tts_unset_state_changed_cb()
-*/
-typedef void (*tts_state_changed_cb)(tts_h tts, tts_state_e previous, tts_state_e current, void* user_data);
-
-/**
-* @brief Called when utterance has started.
-*
-* @param[in] tts The handle for TTS
-* @param[in] utt_id The utterance ID passed from the add text function
-* @param[in] user_data The user data passed from the callback registration function
-*
-* @pre An application registers this callback using tts_set_utterance_started_cb() to detect utterance started.
-*
-* @see tts_add_text()
-* @see tts_set_utterance_started_cb()
-* @see tts_unset_utterance_started_cb()
-*/
-typedef void (*tts_utterance_started_cb)(tts_h tts, int utt_id, void* user_data);
-
-/**
-* @brief Called when utterance is finished.
-*
-* @param[in] tts The handle for TTS
-* @param[in] utt_id The utterance ID passed from the add text function
-* @param[in] user_data The user data passed from from the callback registration function
-*
-* @pre An application registers this callback using tts_set_utterance_completed_cb() to detect utterance completed.
-*
-* @see tts_add_text()
-* @see tts_set_utterance_completed_cb()
-* @see tts_unset_utterance_completed_cb()
-*/
-typedef void (*tts_utterance_completed_cb)(tts_h tts, int utt_id, void *user_data);
-
-/**
-* @brief Called when error occurred. 
-*
-* @param[in] tts The handle for TTS
-* @param[in] utt_id The utterance ID passed from the add text function 
-* @param[in] reason The error code
-* @param[in] user_data The user data passed from the callback registration function
-*
-* @pre An application registers this callback using tts_set_error_cb() to detect error.
-*
-* @see tts_play()
-* @see tts_pause()
-* @see tts_stop()
-* @see tts_set_error_cb()
-* @see tts_unset_error_cb()
-*/
-typedef void (*tts_error_cb)(tts_h tts, int utt_id, tts_error_e reason, void* user_data);
-
-/**
-* @brief Called to retrieve the supported voice.
-*
-* @param[in] tts The handle for TTS
-* @param[in] language A language is specified as an ISO 3166 alpha-2 two letter country-code \n
-*                      followed by ISO 639-1 for the two-letter language code. \n
-*                      For example, "ko_KR" for Korean, "en_US" for American English
-* @param[in] voice_type A voice type
-* @param[in] user_data The user data passed from the foreach function
-*
-* @return @c true to continue with the next iteration of the loop \n @c false to break out of the loop
-* @pre tts_foreach_supported_voices() will invoke this callback. 
-*
-* @see tts_foreach_supported_voices()
-*/
-typedef bool(*tts_supported_voice_cb)(tts_h tts, const char* language, tts_voice_type_e voice_type, void* user_data);
-
-
-/**
-* @brief Creates a handle for TTS. 
-*
-* @param[out] tts The handle for TTS
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #TTS_ERROR_NONE Successful
-* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
-*
-* @see tts_destroy()
-*/
-int tts_create(tts_h* tts);
-
-/**
-* @brief Destroys the handle and disconnects the daemon. 
-*
-* @param[in] tts The handle for TTS
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #TTS_ERROR_NONE Successful
-* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
-*
-* @see tts_create()
-*/
-int tts_destroy(tts_h tts);
-
-/**
-* @brief Set tts mode. 
-*
-* @param[in] tts The handle for TTS
-* @param[in] mode The mode
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #TTS_ERROR_NONE Successful
-* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #TTS_ERROR_INVALID_STATE Invalid state
-*
-* @pre The state should be #TTS_STATE_CREATED.
-*
-* @see tts_get_mode()
-*/
-int tts_set_mode(tts_h tts, tts_mode_e mode);
-
-/**
-* @brief Get tts mode. 
-*
-* @param[in] tts The handle for TTS
-* @param[out] mode The mode
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #TTS_ERROR_NONE Successful
-* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #TTS_ERROR_INVALID_STATE Invalid state
-*
-* @pre The state should be #TTS_STATE_CREATED.
-*
-* @see tts_set_mode()
-*/
-int tts_get_mode(tts_h tts, tts_mode_e* mode);
-
-/**
-* @brief Connects the daemon asynchronously. 
-*
-* @param[in] tts The handle for TTS
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #TTS_ERROR_NONE Successful
-* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #TTS_ERROR_INVALID_STATE Invalid state
-*
-* @pre The state should be #TTS_STATE_CREATED.
-* @post If this function is called, the TTS state will be #TTS_STATE_READY.
-*
-* @see tts_unprepare()
-*/
-int tts_prepare(tts_h tts);
-
-/**
-* @brief Disconnects the daemon.
-*
-* @param[in] tts The handle for TTS
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #TTS_ERROR_NONE Successful
-* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #STT_ERROR_INVALID_STATE Invalid state
-*
-* @pre The state should be #TTS_STATE_READY.
-* @post If this function is called, the TTS state will be #TTS_STATE_CREATED.
-*
-* @see tts_prepare()
-*/
-int tts_unprepare(tts_h tts);
-
-/**
-* @brief Retrieves all supported voices of the current engine using callback function.
-*
-* @param[in] tts The handle for TTS
-* @param[in] callback The callback function to invoke
-* @param[in] user_data The user data to be passed to the callback function
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #TTS_ERROR_NONE Successful
-* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #TTS_ERROR_OPERATION_FAILED Operation failure
-*
-* @pre The state should be #TTS_STATE_READY.
-* @post        This function invokes tts_supported_voice_cb() repeatedly for getting voices. 
-*
-* @see tts_get_default_voice()
-*/
-int tts_foreach_supported_voices(tts_h tts, tts_supported_voice_cb callback, void* user_data);
-
-/**
-* @brief Gets the default voice set by user.
-*
-* @remark If the function succeeds, @a language must be released with free() by you.
-*
-* @param[in] tts The handle for TTS
-* @param[out] language A language is specified as an ISO 3166 alpha-2 two letter country-code \n
-*                      followed by ISO 639-1 for the two-letter language code. \n
-*                      For example, "ko_KR" for Korean, "en_US" for American English.
-* @param[out] voice_type The voice type
-*
-* @return 0 on success, otherwise a negative error value.
-* @retval #TTS_ERROR_NONE Successful
-* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #TTS_ERROR_OUT_OF_MEMORY Out of memory
-* @retval #TTS_ERROR_OPERATION_FAILED Operation failure
-*
-* @pre The state should be #TTS_STATE_READY.
-*
-* @see tts_foreach_supported_voices()
-*/
-int tts_get_default_voice(tts_h tts, char** language, tts_voice_type_e* voice_type);
-
-/**
-* @brief Gets the maximum text count of a current engine.
-*
-* @param[in] tts The handle for TTS
-* @param[out] count The maximum text count of the current engine
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #TTS_ERROR_NONE Successful
-* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #TTS_ERROR_OPERATION_FAILED Operation failure
-*
-* @pre The state should be #TTS_STATE_READY.
-*
-* @see tts_add_text()
-*/
-int tts_get_max_text_count(tts_h tts, int* count);
-
-/**
-* @brief Gets the current state of tts.
-*
-* @param[in] tts The handle for TTS
-* @param[out] state The current state of TTS
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #TTS_ERROR_NONE Successful
-* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #TTS_ERROR_OPERATION_FAILED Operation failure
-*
-* @see tts_play()
-* @see tts_stop()
-* @see tts_pause()
-*/
-int tts_get_state(tts_h tts, tts_state_e* state);
-
-/**
-* @brief Adds a text to the queue.
-*
-* @param[in] tts The handle for TTS
-* @param[in] text A input text
-* @param[in] language The language selected from the foreach function
-* @param[in] voice_type The voice type selected from the foreach function
-* @param[in] speed A speaking speed
-* @param[out] utt_id The utterance ID passed to the callback function
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #TTS_ERROR_NONE Successful
-* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #TTS_ERROR_INVALID_VOICE Invalid voice about language, voice type
-* @retval #TTS_ERROR_OUT_OF_MEMORY Out of memory
-* @retval #TTS_ERROR_OPERATION_FAILED Operation failure
-*
-* @pre The state should be #TTS_STATE_READY, #TTS_STATE_PLAYING or #TTS_STATE_PAUSED.
-* @see tts_get_max_text_count()
-*/
-int tts_add_text(tts_h tts, const char* text, const char* language, tts_voice_type_e voice_type, tts_speed_e speed, int* utt_id);
-
-/**
-* @brief Starts synthesizing voice from text and plays synthesized audio data.
-*
-* @param[in] tts The handle for TTS
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #TTS_ERROR_NONE Successful
-* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #TTS_ERROR_INVALID_STATE Invalid state
-* @retval #TTS_ERROR_OPERATION_FAILED Operation failure
-*
-* @pre The current state should be #TTS_STATE_READY or #TTS_STATE_PAUSED.
-* @post If this function succeeds, the TTS state will be #TTS_STATE_PLAYING.
-*
-* @see tts_add_text()
-* @see tts_pause()
-* @see tts_stop()
-* @see tts_utterance_started_cb()
-* @see tts_utterance_completed_cb()
-* @see tts_error_cb()
-* @see tts_interrupted_cb()
-*/
-int tts_play(tts_h tts);
-
-/**
-* @brief Stops playing utterance and clears queue.
-*
-* @param[in] tts The handle for TTS
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #TTS_ERROR_NONE Successful
-* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #TTS_ERROR_INVALID_STATE Invalid state
-* @retval #TTS_ERROR_OPERATION_FAILED Operation failure
-*
-* @pre The TTS state should be #TTS_STATE_PLAYING or #TTS_STATE_PAUSED.
-* @post If this function succeeds, the TTS state will be #TTS_STATE_READY. 
-*      This function will remove all text via tts_add_text() and synthesized sound data.
-*
-* @see tts_play()
-* @see tts_pause()
-*/
-int tts_stop(tts_h tts);
-
-/**
-* @brief Pauses currently playing utterance.
-*
-* @param[in] tts The handle for TTS
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #TTS_ERROR_NONE Successful
-* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #TTS_ERROR_INVALID_STATE Invalid state
-* @retval #TTS_ERROR_OPERATION_FAILED Operation failure
-*
-* @pre The TTS state should be #TTS_STATE_PLAYING.
-* @post If this function succeeds, the TTS state will be #TTS_STATE_PAUSED. 
-*
-* @see tts_play()
-* @see tts_stop()
-* @see tts_error_cb()
-* @see tts_interrupted_cb()
-*/
-int tts_pause(tts_h tts);
-
-/**
-* @brief Registers a callback function to be called when TTS state changes.
-*
-* @param[in] tts The handle for TTS
-* @param[in] callback The callback function to register
-* @param[in] user_data The user data to be passed to the callback function
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #TTS_ERROR_NONE Successful
-* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
-*
-* @pre The state should be #TTS_STATE_CREATED.
-*
-* @see tts_state_changed_cb()
-* @see tts_unset_state_changed_cb()
-*/
-int tts_set_state_changed_cb(tts_h tts, tts_state_changed_cb callback, void* user_data);
-
-/**
-* @brief Unregisters the callback function.
-*
-* @param[in] tts The handle for TTS
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #TTS_ERROR_NONE Successful
-* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
-*
-* @pre The state should be #TTS_STATE_CREATED.
-*
-* @see tts_set_state_changed_cb()
-*/
-int tts_unset_state_changed_cb(tts_h tts);
-
-/**
-* @brief Registers a callback function for detecting utterance started.
-*
-* @param[in] tts The handle for TTS
-* @param[in] callback The callback function to register
-* @param[in] user_data The user data to be passed to the callback function
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #TTS_ERROR_NONE Successful
-* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
-*
-* @pre The state should be #TTS_STATE_CREATED.
-*
-* @see tts_utterance_started_cb()
-* @see tts_unset_utterance_started_cb()
-*/
-int tts_set_utterance_started_cb(tts_h tts, tts_utterance_started_cb callback, void* user_data);
-
-/**
-* @brief Unregisters the callback function.
-*
-* @param[in] tts The handle for TTS
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #TTS_ERROR_NONE Successful
-* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
-*
-* @pre The state should be #TTS_STATE_CREATED.
-*
-* @see tts_set_utterance_started_cb()
-*/
-int tts_unset_utterance_started_cb(tts_h tts);
-
-/**
-* @brief Registers a callback function for detecting utterance completed.
-*
-* @param[in] tts The handle for TTS
-* @param[in] callback The callback function to register
-* @param[in] user_data The user data to be passed to the callback function
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #TTS_ERROR_NONE Successful
-* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
-*
-* @pre The state should be #TTS_STATE_CREATED.
-*
-* @see tts_utterance_completed_cb()
-* @see tts_unset_utterance_completed_cb()
-*/
-int tts_set_utterance_completed_cb(tts_h tts, tts_utterance_completed_cb callback, void* user_data);
-
-/**
-* @brief Unregisters the callback function.
-*
-* @param[in] tts The handle for TTS
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #TTS_ERROR_NONE Successful
-* @retval #TTS_ERROR_OUT_OF_MEMORY Out of memory
-*
-* @pre The state should be #TTS_STATE_CREATED.
-*
-* @see tts_set_utterance_completed_cb()
-*/
-int tts_unset_utterance_completed_cb(tts_h tts);
-
-/**
-* @brief Registers a callback function for detecting error.
-*
-* @param[in] tts The handle for TTS
-* @param[in] callback The callback function to register
-* @param[in] user_data The user data to be passed to the callback function
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #TTS_ERROR_NONE Successful
-* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
-*
-* @pre The state should be #TTS_STATE_CREATED.
-*
-* @see tts_error_cb()
-* @see tts_unset_error_cb()
-*/
-int tts_set_error_cb(tts_h tts, tts_error_cb callback, void* user_data);
-
-/**
-* @brief Unregisters the callback function.
-*
-* @param[in] tts The handle for TTS
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #TTS_ERROR_NONE Successful
-* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
-*
-* @pre The state should be #TTS_STATE_CREATED.
-*
-* @see tts_set_error_cb()
-*/
-int tts_unset_error_cb(tts_h tts);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-/**
-* @}
-*/
-
-#endif /* __TTS_H__ */
index 574e095..57dedd4 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*  Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd All Rights Reserved 
+*  Copyright (c) 2011-2014 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
@@ -37,9 +37,9 @@ static int __client_generate_uid(int pid)
 int tts_client_new(tts_h* tts)
 {
        tts_client_s* client = NULL;
-       client = (tts_client_s*)g_malloc0 (sizeof(tts_client_s));
+       client = (tts_client_s*)calloc(1, sizeof(tts_client_s));
 
-       tts_h temp = (tts_h)g_malloc0(sizeof(struct tts_s));
+       tts_h temp = (tts_h)calloc(1, sizeof(struct tts_s));
        temp->handle = __client_generate_uid(getpid()); 
 
        /* initialize client data */
@@ -58,6 +58,10 @@ int tts_client_new(tts_h* tts)
 
        client->error_cb = NULL;
        client->error_user_data = NULL;
+       client->default_voice_changed_cb = NULL;
+       client->default_voice_changed_user_data = NULL;
+       client->supported_voice_cb = NULL;
+       client->supported_voice_user_data = NULL;
 
        client->mode = TTS_MODE_DEFAULT;
        client->before_state = TTS_STATE_CREATED; 
@@ -69,7 +73,7 @@ int tts_client_new(tts_h* tts)
 
        *tts = temp;
 
-       SLOG(LOG_DEBUG, TAG_TTSC, "[Success] Create client object : uid(%d)", client->uid); 
+       SECURE_SLOG(LOG_DEBUG, TAG_TTSC, "[Success] Create client object : uid(%d)", client->uid); 
 
        return 0;
 }
@@ -216,4 +220,32 @@ int tts_client_get_connected_client_count()
                }
        }
        return number;
+}
+
+int tts_client_get_mode_client_count(tts_mode_e mode)
+{
+       GList *iter = NULL;
+       tts_client_s *data = NULL;
+       int number = 0;
+
+       if (g_list_length(g_client_list) > 0) {
+               /* Get a first item */
+               iter = g_list_first(g_client_list);
+
+               while (NULL != iter) {
+                       data = iter->data;
+                       if (0 < data->current_state && data->mode == mode) {
+                               number++;
+                       }
+
+                       /* Next item */
+                       iter = g_list_next(iter);
+               }
+       }
+       return number;
+}
+
+GList* tts_client_get_client_list()
+{
+       return g_client_list;
 }
\ No newline at end of file
index 1790977..c9e1755 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*  Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd All Rights Reserved 
+*  Copyright (c) 2011-2014 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
@@ -15,8 +15,8 @@
 #ifndef __TTS_CLIENT_H_
 #define __TTS_CLIENT_H_
 
-#include <pthread.h>
 #include "tts.h"
+#include "tts_config_mgr.h"
 #include "tts_main.h"
 
 #ifdef __cplusplus
@@ -39,8 +39,12 @@ typedef struct {
        void*                           utt_completed_user_data;
        tts_error_cb                    error_cb;
        void*                           error_user_data;
+       tts_default_voice_changed_cb    default_voice_changed_cb;
+       void*                           default_voice_changed_user_data;
+       tts_supported_voice_cb          supported_voice_cb;
+       void*                           supported_voice_user_data;
 
-       /* mode & state */
+       /* mode / state */
        tts_mode_e      mode;
        tts_state_e     before_state;
        tts_state_e     current_state;
@@ -71,6 +75,10 @@ int tts_client_get_use_callback(tts_client_s* client);
 
 int tts_client_get_connected_client_count();
 
+int tts_client_get_mode_client_count(tts_mode_e mode);
+
+GList* tts_client_get_client_list();
+
 #ifdef __cplusplus
 }
 #endif
index 6d1607e..8f8f276 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*  Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd All Rights Reserved 
+*  Copyright (c) 2011-2014 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
 *  limitations under the License.
 */
 
-
 #include <Ecore.h>
+#include <errno.h>
+#include <fcntl.h>
 #include <sys/inotify.h>
 
-#include "tts_main.h"
+#include "tts_client.h"
+#include "tts_config_mgr.h"
 #include "tts_dbus.h"
 #include "tts_defs.h"
-#include "tts_client.h"
-
-#define INIT_WAITING_TIME 5000
-#define WAITING_TIME 1000
+#include "tts_main.h"
 
 
-static Ecore_Fd_Handler* g_fd_handler = NULL;
+#define HELLO_WAITING_TIME 500
+#define WAITING_TIME 5000
 
 static DBusConnection* g_conn = NULL;
 
-static Ecore_Fd_Handler* g_fd_handler_noti = NULL;
-static int g_fd_noti;
-static int g_wd_noti;
+static Ecore_Fd_Handler* g_dbus_fd_handler = NULL;
+
+static Ecore_Fd_Handler* g_file_fd_handler = NULL;
+static Ecore_Fd_Handler* g_file_fd_handler_sr = NULL;
+static Ecore_Fd_Handler* g_file_fd_handler_noti = NULL;
+
+static int g_file_fd;
+static int g_file_fd_sr;
+static int g_file_fd_noti;
+
+static int g_file_wd;
+static int g_file_wd_sr;
+static int g_file_wd_noti;
 
 extern int __tts_cb_error(int uid, tts_error_e reason, int utt_id);
 
@@ -52,6 +62,11 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
        DBusMessage* msg = NULL;
        msg = dbus_connection_pop_message(conn);
 
+       if (true != dbus_connection_get_is_connected(conn)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Connection is disconnected");
+               return ECORE_CALLBACK_RENEW;
+       }
+
        /* loop again if we haven't read a message */
        if (NULL == msg) { 
                return ECORE_CALLBACK_RENEW;
@@ -72,9 +87,13 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
                int response = -1;
 
                dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
+               if (dbus_error_is_set(&err)) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Get arguments error (%s)", err.message);
+                       dbus_error_free(&err);
+               }
 
                if (uid > 0) {
-                       SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts get hello : uid(%d) \n", uid);
+                       SECURE_SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts get hello : uid(%d)", uid);
 
                        /* check uid */
                        tts_client_s* client = tts_client_get_by_uid(uid);
@@ -83,7 +102,7 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
                        else 
                                response = 0;
                } else {
-                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts get hello : invalid uid \n");
+                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts get hello : invalid uid");
                }
 
                reply = dbus_message_new_method_return(msg);
@@ -106,69 +125,6 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
                SLOG(LOG_DEBUG, TAG_TTSC, " ");
        } /* TTSD_METHOD_HELLO */
 
-#if 0
-       else if (dbus_message_is_method_call(msg, if_name, TTSD_METHOD_UTTERANCE_STARTED)) {
-               SLOG(LOG_DEBUG, TAG_TTSC, "===== Get utterance started");
-               int uid, uttid;
-               dbus_message_get_args(msg, &err,
-                       DBUS_TYPE_INT32, &uid,
-                       DBUS_TYPE_INT32, &uttid,
-                       DBUS_TYPE_INVALID);
-
-               if (dbus_error_is_set(&err)) { 
-                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< Get Utterance started - Get arguments error (%s)\n", err.message);
-                       dbus_error_free(&err); 
-               } else {
-                       SLOG(LOG_DEBUG, TAG_TTSC, "<<<< Get Utterance started message : uid(%d), uttid(%d) \n", uid, uttid);
-                       __tts_cb_utt_started(uid, uttid);
-               }
-
-               SLOG(LOG_DEBUG, TAG_TTSC, "=====");
-               SLOG(LOG_DEBUG, TAG_TTSC, " ");
-       }/* TTS_SIGNAL_UTTERANCE_STARTED */
-
-       else if (dbus_message_is_method_call(msg, if_name, TTSD_METHOD_UTTERANCE_COMPLETED)) {
-               SLOG(LOG_DEBUG, TAG_TTSC, "===== Get utterance completed");
-               int uid, uttid;
-               dbus_message_get_args(msg, &err,
-                       DBUS_TYPE_INT32, &uid,
-                       DBUS_TYPE_INT32, &uttid,
-                       DBUS_TYPE_INVALID);
-
-               if (dbus_error_is_set(&err)) { 
-                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< Get Utterance completed - Get arguments error (%s)\n", err.message);
-                       dbus_error_free(&err); 
-               } else {
-                       SLOG(LOG_DEBUG, TAG_TTSC, "<<<< Get Utterance completed message : uid(%d), uttid(%d) \n", uid, uttid);
-                       __tts_cb_utt_completed(uid, uttid);
-               }
-
-               SLOG(LOG_DEBUG, TAG_TTSC, "=====");
-               SLOG(LOG_DEBUG, TAG_TTSC, " ");
-       }/* TTS_SIGNAL_UTTERANCE_COMPLETED */
-
-       else if (dbus_message_is_method_call(msg, if_name, TTSD_METHOD_SET_STATE)) {
-               SLOG(LOG_DEBUG, TAG_TTSC, "===== Get state changed callback");
-               int uid;
-               int state;
-               dbus_message_get_args(msg, &err,
-                       DBUS_TYPE_INT32, &uid,
-                       DBUS_TYPE_INT32, &state,
-                       DBUS_TYPE_INVALID);
-
-               if (dbus_error_is_set(&err)) { 
-                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< Get state change - Get arguments error (%s)", err.message);
-                       dbus_error_free(&err); 
-               } else {
-                       SLOG(LOG_DEBUG, TAG_TTSC, "<<<< Get state change : uid(%d) , state(%d)", uid, state);
-                       __tts_cb_set_state(uid, state);
-               }
-
-               SLOG(LOG_DEBUG, TAG_TTSC, "=====");
-               SLOG(LOG_DEBUG, TAG_TTSC, " ");
-       } /* TTSD_METHOD_SET_STATE */
-#endif
-
        else if (dbus_message_is_method_call(msg, if_name, TTSD_METHOD_ERROR)) {
                SLOG(LOG_DEBUG, TAG_TTSC, "===== Get error callback");
 
@@ -183,10 +139,10 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
                        DBUS_TYPE_INVALID);
 
                if (dbus_error_is_set(&err)) { 
-                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< Get Error signal - Get arguments error (%s)\n", err.message);
+                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< Get Error signal - Get arguments error (%s)", err.message);
                        dbus_error_free(&err); 
                } else {
-                       SLOG(LOG_DEBUG, TAG_TTSC, "<<<< Get Error signal : uid(%d), error(%d), uttid(%d)\n", uid, reason, uttid);
+                       SECURE_SLOG(LOG_DEBUG, TAG_TTSC, "<<<< Get Error signal : uid(%d), error(%d), uttid(%d)", uid, reason, uttid);
                        __tts_cb_error(uid, reason, uttid);
                }
 
@@ -217,12 +173,12 @@ int tts_dbus_open_connection()
        g_conn = dbus_bus_get_private(DBUS_BUS_SYSTEM, &err);
 
        if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Dbus Connection Error (%s)\n", err.message); 
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Dbus Connection Error (%s)", err.message); 
                dbus_error_free(&err); 
        }
 
        if (NULL == g_conn) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] fail to get dbus connection \n");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] fail to get dbus connection");
                return TTS_ERROR_OPERATION_FAILED; 
        }
 
@@ -234,18 +190,17 @@ int tts_dbus_open_connection()
        memset(service_name, 0, 64);
        snprintf(service_name, 64, "%s%d", TTS_CLIENT_SERVICE_NAME, pid);
 
-       SLOG(LOG_DEBUG, TAG_TTSC, "Service name is %s\n", service_name);
-
        /* register our name on the bus, and check for errors */
        ret = dbus_bus_request_name(g_conn, service_name, DBUS_NAME_FLAG_REPLACE_EXISTING , &err);
 
        if (dbus_error_is_set(&err)) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Name Error (%s)\n", err.message); 
+               SLOG(LOG_DEBUG, TAG_TTSC, "Service name is %s", service_name);
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Name Error (%s)", err.message); 
                dbus_error_free(&err); 
        }
 
        if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to open connection : Service name has already been existed. \n");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to open connection : Service name has already been existed.");
                return TTS_ERROR_OPERATION_FAILED;
        }
 
@@ -257,17 +212,17 @@ int tts_dbus_open_connection()
        dbus_connection_flush(g_conn);
 
        if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Match Error (%s)\n", err.message);
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Match Error (%s)", err.message);
                return TTS_ERROR_OPERATION_FAILED; 
        }
 
        int fd = 0;
        dbus_connection_get_unix_fd(g_conn, &fd);
 
-       g_fd_handler = ecore_main_fd_handler_add(fd, ECORE_FD_READ, (Ecore_Fd_Cb)listener_event_callback, g_conn, NULL, NULL);
+       g_dbus_fd_handler = ecore_main_fd_handler_add(fd, ECORE_FD_READ, (Ecore_Fd_Cb)listener_event_callback, g_conn, NULL, NULL);
 
-       if (NULL == g_fd_handler) { 
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get fd handler from ecore \n");
+       if (NULL == g_dbus_fd_handler) { 
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get fd handler from ecore");
                return TTS_ERROR_OPERATION_FAILED;
        }
 
@@ -280,7 +235,7 @@ int tts_dbus_close_connection()
        DBusError err;
        dbus_error_init(&err);
 
-       ecore_main_fd_handler_del(g_fd_handler);
+       ecore_main_fd_handler_del(g_dbus_fd_handler);
 
        int pid = getpid();
 
@@ -289,10 +244,14 @@ int tts_dbus_close_connection()
        snprintf(service_name, 64, "%s%d", TTS_CLIENT_SERVICE_NAME, pid);
 
        dbus_bus_release_name (g_conn, service_name, &err);
+       if (dbus_error_is_set(&err)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Release name error (%s)", err.message);
+               dbus_error_free(&err);
+       }
 
        dbus_connection_close(g_conn);
        
-       g_fd_handler = NULL;
+       g_dbus_fd_handler = NULL;
        g_conn = NULL;
 
        return 0;
@@ -302,7 +261,7 @@ int tts_dbus_close_connection()
 int tts_dbus_reconnect()
 {
        bool connected = dbus_connection_get_is_connected(g_conn);
-       SLOG(LOG_DEBUG, TAG_TTSC, "[DBUS] %s\n", connected ? "Connected" : "Not connected");
+       SECURE_SLOG(LOG_DEBUG, TAG_TTSC, "[DBUS] %s", connected ? "Connected" : "Not connected");
 
        if (false == connected) {
                tts_dbus_close_connection();
@@ -368,7 +327,7 @@ int tts_dbus_request_hello(int uid)
        msg = __tts_dbus_make_message(uid, TTS_METHOD_HELLO);
 
        if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts hello : Fail to make message \n"); 
+               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts hello : Fail to make message");
                return TTS_ERROR_OPERATION_FAILED;
        } 
 
@@ -378,9 +337,11 @@ int tts_dbus_request_hello(int uid)
        DBusMessage* result_msg = NULL;
        int result = 0;
 
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, WAITING_TIME, &err);
-
+       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, HELLO_WAITING_TIME, &err);
        dbus_message_unref(msg);
+       if (dbus_error_is_set(&err)) {
+               dbus_error_free(&err);
+       }
 
        if (NULL != result_msg) {
                dbus_message_unref(result_msg);
@@ -388,7 +349,7 @@ int tts_dbus_request_hello(int uid)
                SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts hello");
                result = 0;
        } else {
-               result = TTS_ERROR_OPERATION_FAILED;
+               result = TTS_ERROR_TIMED_OUT;
        }
 
        return result;
@@ -403,13 +364,10 @@ int tts_dbus_request_initialize(int uid)
        msg = __tts_dbus_make_message(uid, TTS_METHOD_INITIALIZE);
 
        if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts initialize : Fail to make message \n");
-               if (dbus_error_is_set(&err))  
-                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
-       
+               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts initialize : Fail to make message");
                return TTS_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request tts initialize : uid(%d)", uid);
+               SECURE_SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request tts initialize : uid(%d)", uid);
        }
 
        int pid = getpid();
@@ -423,11 +381,12 @@ int tts_dbus_request_initialize(int uid)
        DBusMessage* result_msg;
        int result = TTS_ERROR_OPERATION_FAILED;
 
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, INIT_WAITING_TIME, &err);
+       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, WAITING_TIME, &err);
        dbus_message_unref(msg);
-
-       if (dbus_error_is_set(&err))  
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
+       if (dbus_error_is_set(&err)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Send error (%s)", err.message);
+               dbus_error_free(&err);
+       }
 
        if (NULL != result_msg) {
                dbus_message_get_args(result_msg, &err,
@@ -435,25 +394,24 @@ int tts_dbus_request_initialize(int uid)
                                  DBUS_TYPE_INVALID);
 
                if (dbus_error_is_set(&err)) { 
-                       SLOG(LOG_ERROR, TAG_TTSC, "Get arguments error (%s)\n", err.message);
+                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< Get arguments error (%s)", err.message);
                        dbus_error_free(&err); 
                        result = TTS_ERROR_OPERATION_FAILED;
                }
 
                dbus_message_unref(result_msg);
+
+               if (0 == result) {
+                       SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts initialize : result = %d", result);
+               } else {
+                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts initialize : result = %d", result);
+               }
        } else {
                SLOG(LOG_ERROR, TAG_TTSC, "<<<< Result message is NULL ");
-               if (dbus_error_is_set(&err))  
-                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
                tts_dbus_reconnect();
+               result = TTS_ERROR_TIMED_OUT;
        }
 
-       if (0 == result) {
-               SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts initialize : result = %d \n", result);
-       } else {
-               SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts initialize : result = %d \n", result);
-       }
-       
        return result;
 }
 
@@ -468,12 +426,9 @@ int tts_dbus_request_finalize(int uid)
 
        if (NULL == msg) { 
                SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts finalize : Fail to make message"); 
-               if (dbus_error_is_set(&err))  
-                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
-
                return TTS_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request tts finalize : uid(%d)", uid);
+               SECURE_SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request tts finalize : uid(%d)", uid);
        }
 
        if (true != dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID)) {
@@ -488,202 +443,31 @@ int tts_dbus_request_finalize(int uid)
 
        result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, WAITING_TIME, &err);
        dbus_message_unref(msg);
-
-       if (dbus_error_is_set(&err))  
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
+       if (dbus_error_is_set(&err)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Send error %s", err.message);
+               dbus_error_free(&err);
+       }
 
        if (NULL != result_msg) {
                dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
 
                if (dbus_error_is_set(&err)) { 
-                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< Get arguments error (%s)\n", err.message);
+                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< Get arguments error (%s)", err.message);
                        dbus_error_free(&err); 
                        result = TTS_ERROR_OPERATION_FAILED;
                }
 
                dbus_message_unref(result_msg);
-       } else {
-               SLOG(LOG_ERROR, TAG_TTSC, "<<<< Result message is NULL ");
-               if (dbus_error_is_set(&err))  
-                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
-               tts_dbus_reconnect();
-       }
-
-       if (0 == result) {
-               SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts finalize : result = %d \n", result);
-       } else {
-               SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts finalize : result = %d \n", result);
-       }
-
-       return result;
-}
-
-int tts_dbus_request_get_support_voice(int uid, tts_h tts, tts_supported_voice_cb callback, void* user_data)
-{
-       DBusMessage* msg;
-       DBusError err;
-       dbus_error_init(&err);
-
-       msg = __tts_dbus_make_message(uid, TTS_METHOD_GET_SUPPORT_VOICES);
 
-       if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts get supported voices : Fail to make message"); 
-               if (dbus_error_is_set(&err))  
-                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
-
-               return TTS_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request tts get supported voices : uid(%d)", uid);
-       }
-
-       if (true != dbus_message_append_args( msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID)) {
-               dbus_message_unref(msg);
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to append args"); 
-
-               return TTS_ERROR_OPERATION_FAILED;
-       }
-
-       DBusMessage* result_msg;
-       DBusMessageIter args;
-       int result = TTS_ERROR_OPERATION_FAILED;
-
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, WAITING_TIME, &err );
-       dbus_message_unref(msg);
-
-       if (dbus_error_is_set(&err)) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] result message : %p", result_msg);
-       }
-
-       if (NULL != result_msg) {
-               if (dbus_message_iter_init(result_msg, &args)) {
-                       /* Get result */
-                       if (DBUS_TYPE_INT32 == dbus_message_iter_get_arg_type(&args)) {
-                               dbus_message_iter_get_basic(&args, &result);
-                               dbus_message_iter_next(&args);
-                       }
-
-                       if (0 == result) {
-                               SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts get supported voices : result = %d \n", result);
-
-                               int size ; 
-                               char* temp_char;
-                               int temp_int;
-
-                               /* Get voice size */
-                               if (DBUS_TYPE_INT32 == dbus_message_iter_get_arg_type(&args)) {
-                                       dbus_message_iter_get_basic(&args, &size);
-                                       dbus_message_iter_next(&args);
-                               }
-
-                               if (0 >= size) {
-                                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts size of voice error : size = %d \n", size);
-                               } else {
-                                       int i=0;
-                                       for (i=0 ; i<size ; i++) {
-                                               dbus_message_iter_get_basic(&args, &(temp_char) );
-                                               dbus_message_iter_next(&args);
-                                               dbus_message_iter_get_basic(&args, &(temp_int) );
-                                               dbus_message_iter_next(&args);
-                                               
-                                               if (true != callback(tts, temp_char, (tts_voice_type_e)temp_int, user_data)) {
-                                                       break;
-                                               }
-                                       }
-                               }
-                       } else {
-                               SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts get supported voices : result = %d \n", result);
-                       }
-               } else  {
-                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts get supported voices : result message is invalid \n");
-                       result = TTS_ERROR_OPERATION_FAILED;
+               if (0 == result) {
+                       SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts finalize : result = %d", result);
+               } else {
+                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts finalize : result = %d", result);
                }
-               dbus_message_unref(result_msg);
-       } else {
-               SLOG(LOG_ERROR, TAG_TTSC, "<<<< Result message is NULL");
-               if (dbus_error_is_set(&err))  
-                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
-               tts_dbus_reconnect();
-       }
-
-       return result;
-}
-
-int tts_dbus_request_get_default_voice(int uid , char** lang, tts_voice_type_e* vctype)
-{
-       if (NULL == lang || NULL == vctype) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Input parameter is NULL");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
-
-       DBusMessage* msg;
-       DBusError err;
-       dbus_error_init(&err);
-
-       msg = __tts_dbus_make_message(uid, TTS_METHOD_GET_CURRENT_VOICE);
-
-       if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts get default voice : Fail to make message"); 
-               if (dbus_error_is_set(&err))  
-                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
-
-               return TTS_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request tts get default voice : uid(%d)", uid);
-       }
-
-       if (true != dbus_message_append_args( msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID)) {
-               dbus_message_unref(msg);
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to append args"); 
-
-               return TTS_ERROR_OPERATION_FAILED;
-       }
-
-       DBusMessage* result_msg;
-       int result = TTS_ERROR_OPERATION_FAILED;
-       char* temp_lang;
-       int voice_type;
-
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, WAITING_TIME, &err);
-       dbus_message_unref(msg);
-
-       if (dbus_error_is_set(&err)) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] result message : %p", result_msg);
-       }
-
-       if (NULL != result_msg) {
-               dbus_message_get_args(result_msg, &err,
-                       DBUS_TYPE_INT32, &result,
-                       DBUS_TYPE_STRING, &temp_lang,
-                       DBUS_TYPE_INT32, &voice_type,
-                       DBUS_TYPE_INVALID);
-
-               if (dbus_error_is_set(&err)) { 
-                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< Get arguments error (%s)\n", err.message);
-                       dbus_error_free(&err); 
-                       result = TTS_ERROR_OPERATION_FAILED;
-               } 
-               dbus_message_unref(result_msg);
        } else {
                SLOG(LOG_ERROR, TAG_TTSC, "<<<< Result message is NULL ");
-               if (dbus_error_is_set(&err))  
-                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
                tts_dbus_reconnect();
-       }
-
-       if (0 == result) {
-               *lang = strdup(temp_lang);
-               *vctype = (tts_voice_type_e)voice_type;
-
-               if (NULL == *lang) {
-                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts get default voice : Out of memory \n");
-                       result = TTS_ERROR_OUT_OF_MEMORY;
-               } else {
-                       SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts get default voice : result(%d), lang(%s), vctype(%d) \n", result, *lang, *vctype);
-               }
-       } else {
-               SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts get default voice : result(%d) \n", result);
+               result = TTS_ERROR_TIMED_OUT;
        }
 
        return result;
@@ -704,12 +488,9 @@ int tts_dbus_request_add_text(int uid, const char* text, const char* lang, int v
 
        if (NULL == msg) { 
                SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts add text : Fail to make message"); 
-               if (dbus_error_is_set(&err))  
-                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
-
                return TTS_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request tts add text : uid(%d), text(%s), lang(%s), type(%d), speed(%d), id(%d)", 
+               SECURE_SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request tts add text : uid(%d), text(%s), lang(%s), type(%d), speed(%d), id(%d)", 
                        uid, text, lang, vctype, speed, uttid);
        }
 
@@ -730,11 +511,12 @@ int tts_dbus_request_add_text(int uid, const char* text, const char* lang, int v
        DBusMessage* result_msg;
        int result = TTS_ERROR_OPERATION_FAILED;
 
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 5000, &err);
+       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, WAITING_TIME, &err);
        dbus_message_unref(msg);
-
-       if (dbus_error_is_set(&err))  
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
+       if (dbus_error_is_set(&err)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Send error (%s)", err.message);
+               dbus_error_free(&err);
+       }
 
        if (NULL != result_msg) {
                dbus_message_get_args(result_msg, &err,
@@ -742,24 +524,23 @@ int tts_dbus_request_add_text(int uid, const char* text, const char* lang, int v
                        DBUS_TYPE_INVALID);
 
                if (dbus_error_is_set(&err)) { 
-                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts add text : Get arguments error (%s)\n", err.message);
+                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts add text : Get arguments error (%s)", err.message);
                        dbus_error_free(&err); 
                        result = TTS_ERROR_OPERATION_FAILED;
                }
                dbus_message_unref(result_msg);
+               
+               if (0 == result) {
+                       SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts add text : result(%d)", result);
+               } else {
+                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts add text : result(%d)", result);
+               }       
        } else {
                SLOG(LOG_ERROR, TAG_TTSC, "<<<< Result message is NULL ");
-               if (dbus_error_is_set(&err))  
-                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
                tts_dbus_reconnect();
+               result = TTS_ERROR_TIMED_OUT;
        }
 
-       if (0 == result) {
-               SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts add text : result(%d) \n", result);
-       } else {
-               SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts add text : result(%d) \n", result);
-       }       
-
        return result;
 }
 
@@ -773,12 +554,9 @@ int tts_dbus_request_play(int uid)
 
        if (NULL == msg) { 
                SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts play : Fail to make message"); 
-               if (dbus_error_is_set(&err))  
-                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
-
                return TTS_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request tts play : uid(%d)", uid);
+               SECURE_SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request tts play : uid(%d)", uid);
        }
        
        if (true != dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID)) {
@@ -791,11 +569,12 @@ int tts_dbus_request_play(int uid)
        DBusMessage* result_msg;
        int result = TTS_ERROR_OPERATION_FAILED;
 
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 5000, &err);
+       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, WAITING_TIME, &err);
        dbus_message_unref(msg);
-
-       if (dbus_error_is_set(&err))  
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
+       if (dbus_error_is_set(&err)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Send error (%s)", err.message);
+               dbus_error_free(&err);
+       }
 
        if (NULL != result_msg) {
                dbus_message_get_args(result_msg, &err,
@@ -803,28 +582,26 @@ int tts_dbus_request_play(int uid)
                        DBUS_TYPE_INVALID);
 
                if (dbus_error_is_set(&err)) { 
-                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts play : Get arguments error (%s)\n", err.message);
+                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts play : Get arguments error (%s)", err.message);
                        dbus_error_free(&err); 
                        result = TTS_ERROR_OPERATION_FAILED;
                }
                dbus_message_unref(result_msg);
+
+               if (0 == result) {
+                       SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts play : result(%d)", result);
+               } else {
+                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts play : result(%d)", result);
+               }
        } else {
                SLOG(LOG_ERROR, TAG_TTSC, "<<<< Result message is NULL ");
-               if (dbus_error_is_set(&err))  
-                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
                tts_dbus_reconnect();
+               result = TTS_ERROR_TIMED_OUT;
        }
 
-       if (0 == result) {
-               SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts play : result(%d) \n", result);
-       } else {
-               SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts play : result(%d) \n", result);
-       }
-       
        return result;
 }
 
-
 int tts_dbus_request_stop(int uid)
 {
        DBusMessage* msg;
@@ -835,12 +612,9 @@ int tts_dbus_request_stop(int uid)
 
        if (NULL == msg) { 
                SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts stop : Fail to make message"); 
-               if (dbus_error_is_set(&err))  
-                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
-
                return TTS_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request tts stop : uid(%d)", uid);
+               SECURE_SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request tts stop : uid(%d)", uid);
        }
 
        DBusMessage* result_msg;
@@ -853,11 +627,12 @@ int tts_dbus_request_stop(int uid)
                return TTS_ERROR_OPERATION_FAILED;
        }
 
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 5000, &err);
+       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, WAITING_TIME, &err);
        dbus_message_unref(msg);
-
-       if (dbus_error_is_set(&err))  
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
+       if (dbus_error_is_set(&err)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Send error (%s)", err.message);
+               dbus_error_free(&err);
+       }
 
        if (NULL != result_msg) {
                dbus_message_get_args(result_msg, &err,
@@ -865,22 +640,21 @@ int tts_dbus_request_stop(int uid)
                        DBUS_TYPE_INVALID);
 
                if (dbus_error_is_set(&err)) { 
-                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts stop : Get arguments error (%s)\n", err.message);
+                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts stop : Get arguments error (%s)", err.message);
                        dbus_error_free(&err); 
                        result = TTS_ERROR_OPERATION_FAILED;
                }
                dbus_message_unref(result_msg);
+
+               if (0 == result) {
+                       SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts stop : result(%d)", result);
+               } else {
+                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts stop : result(%d)", result);
+               }
        } else {
                SLOG(LOG_ERROR, TAG_TTSC, "<<<< Result message is NULL ");
-               if (dbus_error_is_set(&err))  
-                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
                tts_dbus_reconnect();
-       }
-
-       if (0 == result) {
-               SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts stop : result(%d) \n", result);
-       } else {
-               SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts stop : result(%d) \n", result);
+               result = TTS_ERROR_TIMED_OUT;
        }
 
        return result;
@@ -896,12 +670,9 @@ int tts_dbus_request_pause(int uid)
 
        if (NULL == msg) { 
                SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts pause : Fail to make message"); 
-               if (dbus_error_is_set(&err))  
-                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
-
                return TTS_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request tts pause : uid(%d)", uid);
+               SECURE_SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request tts pause : uid(%d)", uid);
        }
 
        DBusMessage* result_msg;
@@ -914,11 +685,12 @@ int tts_dbus_request_pause(int uid)
                return TTS_ERROR_OPERATION_FAILED;
        }
 
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 5000, &err);
+       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, WAITING_TIME, &err);
        dbus_message_unref(msg);
-
-       if (dbus_error_is_set(&err))  
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
+       if (dbus_error_is_set(&err)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Send error (%s)", err.message);
+               dbus_error_free(&err);
+       }
 
        if (NULL != result_msg) {
                dbus_message_get_args(result_msg, &err,
@@ -926,147 +698,262 @@ int tts_dbus_request_pause(int uid)
                        DBUS_TYPE_INVALID);
 
                if (dbus_error_is_set(&err)) { 
-                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts pause : Get arguments error (%s)\n", err.message);
+                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts pause : Get arguments error (%s)", err.message);
                        dbus_error_free(&err); 
                        result = TTS_ERROR_OPERATION_FAILED;
                }
                dbus_message_unref(result_msg);
+
+               if (0 == result) {
+                       SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts pause : result(%d)", result);
+               } else {
+                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts pause : result(%d)", result);
+               }
        } else {
                SLOG(LOG_ERROR, TAG_TTSC, "<<<< Result message is NULL ");
-               if (dbus_error_is_set(&err))  
-                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
                tts_dbus_reconnect();
-       }
-
-       if (0 == result) {
-               SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts pause : result(%d) \n", result);
-       } else {
-               SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts pause : result(%d) \n", result);
+               result = TTS_ERROR_TIMED_OUT;
        }
 
        return result;
 }
 
 
-static Eina_Bool inotify_event_callback(void* data, Ecore_Fd_Handler *fd_handler)
+static int __check_file(int mode)
 {
-       SLOG(LOG_DEBUG, TAG_TTSC, "===== [File message] Inotify event call");
-
-       int length;
+       int length = 0;
+       int temp_fd;
+
+       switch(mode) {
+       case TTS_MODE_DEFAULT:          temp_fd = g_file_fd;            break;
+       case TTS_MODE_NOTIFICATION:     temp_fd = g_file_fd_noti;       break;
+       case TTS_MODE_SCREEN_READER:    temp_fd = g_file_fd_sr;         break;
+       default:
+               SLOG(LOG_ERROR, TAG_TTSC, "[File message ERROR] Mode is NOT valid : %d", mode);
+               return -1;
+       }
 
-       char buffer[sizeof(struct inotify_event)];
-       memset(buffer, 0, (sizeof(struct inotify_event)));
+       struct inotify_event event;
+       memset(&event, '\0', sizeof(struct inotify_event));
 
-       length = read(g_fd_noti, buffer, (sizeof(struct inotify_event)));
+       length = read(temp_fd, &event, sizeof(struct inotify_event));
        if (0 > length) {
                SLOG(LOG_ERROR, TAG_TTSC, "[File message] Empty Inotify event");
-               SLOG(LOG_DEBUG, TAG_TTSC, "=====");
-               SLOG(LOG_DEBUG, TAG_TTSC, " ");
-               return ECORE_CALLBACK_RENEW; 
+               return ECORE_CALLBACK_DONE;
        }
 
-       bool is_empty_file = true;
+       if (IN_MODIFY != event.mask) {
+               SLOG(LOG_WARN, TAG_TTSC, "[File message] Undefined event");
+               return ECORE_CALLBACK_PASS_ON;
+       }
 
-       char filename[64];
-       memset(filename, 0, 64);
-       snprintf(filename, 64, "%s_%d", MESSAGE_FILE_PATH, getpid());
-       FILE *fp;
+       char* filename;
+       filename = tts_config_get_message_path(mode, getpid());
 
-       char text[256];
+       if (NULL == filename) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[Message ERROR] Fail to get message file path");
+               return ECORE_CALLBACK_PASS_ON;
+       }
+
+       FILE *fp;
+       bool is_empty_file = true;
+       char text[256] = {0, };
        char msg[256];
-       int uid, send_data;
+       int uid = -1;
+       int send_data = -1;
 
-       struct inotify_event *event = (struct inotify_event *)&buffer;
+       fp = fopen(filename, "r");
+       if (NULL == fp) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[File message ERROR] Fail to open file");
+               if (NULL != filename)   free(filename);
+               return ECORE_CALLBACK_RENEW;
+       }
 
-       if (IN_CLOSE_WRITE == event->mask) {
+       SLOG(LOG_DEBUG, TAG_TTSC, "Opened message file : path (%s)", filename);
 
-               fp = fopen(filename, "r");
-               if (NULL == fp) {
-                       SLOG(LOG_ERROR, TAG_TTSC, "[File message ERROR] open file failed");
-                       SLOG(LOG_DEBUG, TAG_TTSC, "=====");
-                       SLOG(LOG_DEBUG, TAG_TTSC, " ");
-                       return ECORE_CALLBACK_RENEW;
+       while (NULL != fgets(text, 256, fp)) {
+               if (0 > sscanf(text, "%s %d %d", msg, &uid, &send_data)) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[File message ERROR] Fail to sscanf");
+                       continue;
                }
+               is_empty_file = false;
 
-               while (NULL != fgets(text, 256, fp)) {
-                       if (0 > sscanf(text, "%s %d %d", msg, &uid, &send_data)) {
-                               SLOG(LOG_ERROR, TAG_TTSC, "[File message] sscanf failed");
-                               continue;
-                       }
-                       SLOG(LOG_DEBUG, TAG_TTSC, "[File message] message - %s, uid - %d, send_data - %d", msg, uid, send_data);
-                       is_empty_file = false;
-
-                       int uttid;
-                       if (!strcmp(TTSD_METHOD_UTTERANCE_STARTED, msg)) {
-                               uttid = send_data;
-                               SLOG(LOG_DEBUG, TAG_TTSC, "<<<< Get Utterance started message : uid(%d), uttid(%d) \n", uid, uttid);
-                               __tts_cb_utt_started(uid, uttid);
-                       } else if (!strcmp(TTSD_METHOD_UTTERANCE_COMPLETED, msg)) {
-                               uttid = send_data;
-                               SLOG(LOG_DEBUG, TAG_TTSC, "<<<< Get Utterance completed message : uid(%d), uttid(%d) \n", uid, uttid);
-                               __tts_cb_utt_completed(uid, uttid);
-
-                       } else if (!strcmp(TTSD_METHOD_SET_STATE, msg)) {
-                               int state = send_data;
-                               SLOG(LOG_DEBUG, TAG_TTSC, "<<<< Get state change : uid(%d) , state(%d)", uid, state);
-                               __tts_cb_set_state(uid, state);
-                       }
+               int uttid;
+               if (!strcmp(TTSD_METHOD_UTTERANCE_STARTED, msg)) {
+                       uttid = send_data;
+                       SECURE_SLOG(LOG_DEBUG, TAG_TTSC, "<<<< Get Utterance started message : uid(%d), uttid(%d)", uid, uttid);
+                       __tts_cb_utt_started(uid, uttid);
+               } else if (!strcmp(TTSD_METHOD_UTTERANCE_COMPLETED, msg)) {
+                       uttid = send_data;
+                       SECURE_SLOG(LOG_DEBUG, TAG_TTSC, "<<<< Get Utterance completed message : uid(%d), uttid(%d)", uid, uttid);
+                       __tts_cb_utt_completed(uid, uttid);
+
+               } else if (!strcmp(TTSD_METHOD_SET_STATE, msg)) {
+                       int state = send_data;
+                       SECURE_SLOG(LOG_DEBUG, TAG_TTSC, "<<<< Get state change : uid(%d) , state(%d)", uid, state);
+                       __tts_cb_set_state(uid, state);
+               } else {
+                       SLOG(LOG_WARN, TAG_TTSC, "<<<< Get undefined message : uid(%d), data(%d)", uid, send_data);
                }
-               fclose(fp);
-       } else {
-               SLOG(LOG_ERROR, TAG_TTSC, "[File message] Undefined event");
+
+               memset(text, 0, 256);
        }
 
-       if (true == is_empty_file)
-               return ECORE_CALLBACK_PASS_ON;
+       fclose(fp);
 
-       fp = fopen(filename, "w+");
-       if (NULL == fp) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[File message ERROR] open file failed");
+       struct stat stbuf;
+       if (-1 != stat(filename, &stbuf)) {     
+               if (false == is_empty_file) {
+                       fp = fopen(filename, "w+");
+                       if (NULL == fp) {
+                               SLOG(LOG_ERROR, TAG_TTSC, "[File message ERROR] Fail to make new file");
+                       } else {
+                               fclose(fp);
+                       }
+               }
        } else {
-               fclose(fp);
+               SLOG(LOG_ERROR, TAG_TTSC, "[File message ERROR] Fail to access file");
        }
 
+       if (NULL != filename)   free(filename);
+
+       return ECORE_CALLBACK_PASS_ON;
+}
+
+static Eina_Bool __noti_inotify_event_callback(void* data, Ecore_Fd_Handler *fd_handler)
+{
+       SLOG(LOG_DEBUG, TAG_TTSC, "===== [File message] Notification inotify event call");
+
+       int ret = __check_file(TTS_MODE_NOTIFICATION);
+
        SLOG(LOG_DEBUG, TAG_TTSC, "=====");
        SLOG(LOG_DEBUG, TAG_TTSC, " ");
 
-       return ECORE_CALLBACK_PASS_ON;
+       return ret;
 }
 
-int tts_file_msg_open_connection()
+static Eina_Bool __sr_inotify_event_callback(void* data, Ecore_Fd_Handler *fd_handler)
 {
-       /* get file notification handler */
-       int fd;
-       int wd;
+       SLOG(LOG_DEBUG, TAG_TTSC, "===== [File message] Screen reader inotify event call");
 
-       fd = inotify_init();
-       if (fd < 0) {
+       int ret = __check_file(TTS_MODE_SCREEN_READER);
+
+       SLOG(LOG_DEBUG, TAG_TTSC, "=====");
+       SLOG(LOG_DEBUG, TAG_TTSC, " ");
+
+       return ret;
+}
+
+static Eina_Bool __inotify_event_callback(void* data, Ecore_Fd_Handler *fd_handler)
+{
+       SLOG(LOG_DEBUG, TAG_TTSC, "===== [File message] Noraml inotify event call");
+
+       int ret = __check_file(TTS_MODE_DEFAULT);
+
+       SLOG(LOG_DEBUG, TAG_TTSC, "=====");
+       SLOG(LOG_DEBUG, TAG_TTSC, " ");
+
+       return ret;
+}
+
+int tts_file_msg_open_connection(tts_mode_e mode)
+{
+       int temp_fd;
+       int temp_wd;
+
+       temp_fd = inotify_init();
+       if (temp_fd < 0) {
                SLOG(LOG_ERROR, TAG_TTSC, "[File message ERROR] Fail get inotify_fd");
                return -1;
        }
-       g_fd_noti = fd;
 
-       int pid = getpid();
-       char path[64];
-       memset(path, 0, 64);
-       snprintf(path, 64, "%s_%d", MESSAGE_FILE_PATH, pid);
-
-       wd = inotify_add_watch(fd, path, IN_CLOSE_WRITE);
-       g_wd_noti = wd;
-       g_fd_handler_noti = ecore_main_fd_handler_add(fd, ECORE_FD_READ, (Ecore_Fd_Cb)inotify_event_callback, NULL, NULL, NULL);                
-       if (NULL == g_fd_handler_noti) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[File message ERROR] Fail to get handler_noti");
+       char* path;
+       path = tts_config_get_message_path((int)mode, getpid());
+       if (NULL == path) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[Message ERROR] Fail to get message file path");
+               return -1;
+       }
+
+       temp_wd = inotify_add_watch(temp_fd, path, IN_MODIFY);
+       
+       if (NULL != path)       free(path);
+
+       switch(mode) {
+       case TTS_MODE_DEFAULT:
+               g_file_fd = temp_fd;
+               g_file_wd = temp_wd;
+               g_file_fd_handler = ecore_main_fd_handler_add(g_file_fd, ECORE_FD_READ, 
+                       (Ecore_Fd_Cb)__inotify_event_callback, NULL, NULL, NULL);
+
+               if (NULL == g_file_fd_handler) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[File message ERROR] Fail to get handler");
+                       return -1;
+               }
+               break;
+       case TTS_MODE_NOTIFICATION:
+               g_file_fd_noti = temp_fd;
+               g_file_wd_noti = temp_wd;
+               g_file_fd_handler_noti = ecore_main_fd_handler_add(g_file_fd_noti, ECORE_FD_READ, 
+                       (Ecore_Fd_Cb)__noti_inotify_event_callback, NULL, NULL, NULL);
+
+               if (NULL == g_file_fd_handler_noti) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[File message ERROR] Fail to get handler");
+                       return -1;
+               }
+               break;
+       case TTS_MODE_SCREEN_READER:
+               g_file_fd_sr = temp_fd;
+               g_file_wd_sr = temp_wd;
+               g_file_fd_handler_sr = ecore_main_fd_handler_add(g_file_fd_sr, ECORE_FD_READ, 
+                       (Ecore_Fd_Cb)__sr_inotify_event_callback, NULL, NULL, NULL);
+
+               if (NULL == g_file_fd_handler_sr) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[File message ERROR] Fail to get handler");
+                       return -1;
+               }
+               break;
+       default:
+               SLOG(LOG_ERROR, TAG_TTSC, "[File message ERROR] Mode is NOT valid : %d", mode);
                return -1;
        }
+
+       /* Set non-blocking mode of file */
+       int value;
+       value = fcntl(temp_fd, F_GETFL, 0);
+       value |= O_NONBLOCK;
+       
+       if (0 > fcntl(temp_fd, F_SETFL, value)) {
+               SLOG(LOG_WARN, TAG_TTSC, "[WARNING] Fail to set non-block mode");
+       }
+
        return 0;
 }
 
-int tts_file_msg_close_connection()
+int tts_file_msg_close_connection(tts_mode_e mode)
 {
-       /* del inotify variable */
-       ecore_main_fd_handler_del(g_fd_handler_noti);
-       inotify_rm_watch(g_fd_noti, g_wd_noti);
-       close(g_fd_noti);
+       switch(mode) {
+       case TTS_MODE_DEFAULT:
+               ecore_main_fd_handler_del(g_file_fd_handler);
+               inotify_rm_watch(g_file_fd, g_file_wd);
+               close(g_file_fd);
+               break;
+
+       case TTS_MODE_NOTIFICATION:
+               ecore_main_fd_handler_del(g_file_fd_handler_noti);
+               inotify_rm_watch(g_file_fd_noti, g_file_wd_noti);
+               close(g_file_fd_noti);
+               break;
+
+       case TTS_MODE_SCREEN_READER:
+               ecore_main_fd_handler_del(g_file_fd_handler_sr);
+               inotify_rm_watch(g_file_fd_sr, g_file_wd_sr);
+               close(g_file_fd_sr);
+               break;
+
+       default:
+               SLOG(LOG_ERROR, TAG_TTSC, "[File message ERROR] Mode is NOT valid : %d", mode);
+               return -1;
+       }
 
        return 0;
-}
\ No newline at end of file
+}
index 3636e8f..631f6c3 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*  Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd All Rights Reserved 
+*  Copyright (c) 2011-2014 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
@@ -31,15 +31,11 @@ int tts_dbus_request_initialize(int uid);
 
 int tts_dbus_request_finalize(int uid);
 
-int tts_dbus_request_get_support_voice(int uid, tts_h tts, tts_supported_voice_cb callback, void* user_data);
+int tts_dbus_set_sound_type(int uid, int type);
 
-int tts_dbus_request_get_default_voice(int uid , char** lang, tts_voice_type_e* vctype);
 
 int tts_dbus_request_add_text(int uid, const char* text, const char* lang, int vctype, int speed, int uttid); 
 
-int tts_dbus_request_remove_all_text(int uid); 
-
-
 int tts_dbus_request_play(int uid) ;
 
 int tts_dbus_request_stop(int uid);
@@ -47,9 +43,9 @@ int tts_dbus_request_stop(int uid);
 int tts_dbus_request_pause(int uid);
 
 
-int tts_file_msg_open_connection();
+int tts_file_msg_open_connection(tts_mode_e mode);
 
-int tts_file_msg_close_connection();
+int tts_file_msg_close_connection(tts_mode_e mode);
 
 #ifdef __cplusplus
 }
index 9dbe328..2a0af6a 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*  Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd All Rights Reserved 
+*  Copyright (c) 2011-2014 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
index ee79206..a2b43b2 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*  Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd All Rights Reserved 
+*  Copyright (c) 2011-2014 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
 *  limitations under the License.
 */
 
-
-#include <sys/wait.h>
+#include <dirent.h>
 #include <Ecore.h>
+#include <sys/wait.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <dirent.h>
 
+#include "tts_config_mgr.h"
 #include "tts_main.h"
 #include "tts_setting.h"
-#include "tts_setting_dbus.h"
-
-static bool g_is_daemon_started = false;
 
-static Ecore_Timer* g_setting_connect_timer = NULL;
+/** 
+* @brief Enumerations of setting state.
+*/
+typedef enum {
+       TTS_SETTING_STATE_NONE = 0,
+       TTS_SETTING_STATE_READY
+}tts_setting_state_e;
 
-static int __check_setting_tts_daemon();
 
 static tts_setting_state_e g_state = TTS_SETTING_STATE_NONE;
 
-static tts_setting_initialized_cb g_initialized_cb;
-static void* g_user_data;
+static tts_setting_supported_engine_cb g_engine_cb;
 
-static int g_reason;
+static tts_setting_engine_changed_cb g_engine_changed_cb;
+static void* g_engine_changed_user_data;
+
+static tts_setting_voice_changed_cb g_voice_changed_cb;
+static void* g_voice_changed_user_data;
+
+static tts_setting_speed_changed_cb g_speed_changed_cb;
+static void* g_speed_changed_user_data;
+
+static tts_setting_pitch_changed_cb g_pitch_changed_cb;
+static void* g_pitch_changed_user_data;
 
-/* API Implementation */
-static Eina_Bool __tts_setting_initialized(void *data)
-{
-       g_initialized_cb(g_state, g_reason, g_user_data);
 
-       return EINA_FALSE;
+
+const char* tts_tag()
+{
+       return "ttsc";
 }
 
-static Eina_Bool __tts_setting_connect_daemon(void *data)
+static int __setting_convert_config_error_code(tts_config_error_e code)
 {
-       /* Send hello */
-       if (0 != tts_setting_dbus_request_hello()) {
-               if (false == g_is_daemon_started) {
-                       g_is_daemon_started = true;
-                       __check_setting_tts_daemon();
-               }
-               return EINA_TRUE;
-       }
+       if (code == TTS_CONFIG_ERROR_NONE)                      return TTS_SETTING_ERROR_NONE;
+       if (code == TTS_CONFIG_ERROR_OUT_OF_MEMORY)             return TTS_SETTING_ERROR_OUT_OF_MEMORY;
+       if (code == TTS_CONFIG_ERROR_IO_ERROR)                  return TTS_SETTING_ERROR_IO_ERROR;
+       if (code == TTS_CONFIG_ERROR_INVALID_PARAMETER)         return TTS_SETTING_ERROR_INVALID_PARAMETER;
+       if (code == TTS_CONFIG_ERROR_INVALID_STATE)             return TTS_SETTING_ERROR_INVALID_STATE;
+       if (code == TTS_CONFIG_ERROR_INVALID_VOICE)             return TTS_SETTING_ERROR_INVALID_VOICE;
+       if (code == TTS_CONFIG_ERROR_ENGINE_NOT_FOUND)          return TTS_SETTING_ERROR_ENGINE_NOT_FOUND;
+       if (code == TTS_CONFIG_ERROR_OPERATION_FAILED)          return TTS_SETTING_ERROR_OPERATION_FAILED;
+       if (code == TTS_CONFIG_ERROR_NOT_SUPPORTED_FEATURE)     return TTS_SETTING_ERROR_NOT_SUPPORTED_FEATURE;
 
-       SLOG(LOG_DEBUG, TAG_TTSC, "===== Connect daemon");
+       return TTS_SETTING_ERROR_NONE;
+}
 
-       /* do request initialize */
-       int ret = -1;
+void __setting_config_engine_changed_cb(const char* engine_id, const char* setting, const char* language, int voice_type, bool auto_voice, void* user_data)
+{
+       SLOG(LOG_DEBUG, TAG_TTSC, "Engine chagned : engine(%s) setting(%s) lang(%s) type(%d)", 
+               engine_id, setting, language, language, voice_type);
 
-       ret = tts_setting_dbus_request_initialize();
+       if (NULL != g_engine_changed_cb)
+               g_engine_changed_cb(engine_id, g_engine_changed_user_data);
 
-       if (TTS_SETTING_ERROR_ENGINE_NOT_FOUND == ret) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Engine not found");
-       } else if (TTS_SETTING_ERROR_NONE != ret) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to connection : %d", ret);
-       } else {
-               /* success to connect tts-daemon */
-               g_state = TTS_SETTING_STATE_READY;
-       }
+       if (NULL != g_voice_changed_cb)
+               g_voice_changed_cb(language, voice_type, auto_voice, g_voice_changed_user_data);
+}
 
-       g_reason = ret;
+void __setting_config_voice_changed_cb(const char* before_language, int before_type, const char* language, int voice_type, bool auto_voice, void* user_data)
+{
+       SLOG(LOG_DEBUG, TAG_TTSC, "Voice changed : lang(%s) type(%d) auto(%s)", language, voice_type, auto_voice ? "on" : "off");
 
-       ecore_timer_add(0, __tts_setting_initialized, NULL);
+       if (NULL != g_voice_changed_cb)
+               g_voice_changed_cb(language, voice_type, auto_voice, g_voice_changed_user_data);
+}
 
-       g_setting_connect_timer = NULL;
+void __setting_config_speech_rate_changed_cb(int value, void* user_data)
+{
+       SLOG(LOG_DEBUG, TAG_TTSC, "Speech rate : %d", value);
 
-       SLOG(LOG_DEBUG, TAG_TTSC, "=====");
-       SLOG(LOG_DEBUG, TAG_TTSC, " ");
+       if (NULL != g_speed_changed_cb)
+               g_speed_changed_cb(value, g_speed_changed_user_data);
+}
+
+void __setting_config_pitch_changed_cb(int value, void* user_data)
+{
+       SLOG(LOG_DEBUG, TAG_TTSC, "Pitch : %d", value);
 
-       return EINA_FALSE;
+       if (NULL != g_pitch_changed_cb)
+               g_pitch_changed_cb(value, g_pitch_changed_user_data);
 }
 
-int tts_setting_initialize(tts_setting_initialized_cb callback, void* user_data)
+int tts_setting_initialize()
 {
        SLOG(LOG_DEBUG, TAG_TTSC, "===== Initialize TTS Setting");
 
@@ -93,17 +115,32 @@ int tts_setting_initialize(tts_setting_initialized_cb callback, void* user_data)
                return TTS_SETTING_ERROR_NONE;
        }
 
-       if( 0 != tts_setting_dbus_open_connection() ) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to open connection");
-               SLOG(LOG_DEBUG, TAG_TTSC, "=====");
-               SLOG(LOG_DEBUG, TAG_TTSC, " ");
-               return TTS_SETTING_ERROR_OPERATION_FAILED;
+       int ret = tts_config_mgr_initialize(getpid());
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to initialize config manager : %d", ret);
+               return __setting_convert_config_error_code(ret);
+       }
+
+       ret = tts_config_mgr_set_callback(getpid(), __setting_config_engine_changed_cb, __setting_config_voice_changed_cb, 
+               __setting_config_speech_rate_changed_cb, __setting_config_pitch_changed_cb, NULL);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to set config changed : %d", ret);
+               return __setting_convert_config_error_code(ret);
        }
 
-       g_initialized_cb = callback;
-       g_user_data = user_data;
+       g_state = TTS_SETTING_STATE_READY;
+
+       g_engine_changed_cb = NULL;
+       g_engine_changed_user_data = NULL;
+
+       g_voice_changed_cb = NULL;
+       g_voice_changed_user_data = NULL;
+
+       g_speed_changed_cb = NULL;
+       g_speed_changed_user_data = NULL;
 
-       g_setting_connect_timer = ecore_timer_add(0, __tts_setting_connect_daemon, NULL);
+       g_pitch_changed_cb = NULL;
+       g_pitch_changed_user_data = NULL;
 
        SLOG(LOG_DEBUG, TAG_TTSC, "=====");
        SLOG(LOG_DEBUG, TAG_TTSC, " ");
@@ -115,65 +152,52 @@ int tts_setting_finalize()
 {
        SLOG(LOG_DEBUG, TAG_TTSC, "===== Finalize TTS Setting");
 
-       int ret = 0;
-
-       if (TTS_SETTING_STATE_READY == g_state) {
-               ret = tts_setting_dbus_request_finalilze(); 
-               if (0 != ret) {
-                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] result : %d", ret);
-               }
-       }
-
-       if (NULL != g_setting_connect_timer) {
-               SLOG(LOG_DEBUG, TAG_TTSC, "Setting Connect Timer is remained");
-               ecore_timer_del(g_setting_connect_timer);
-       }
-
-       g_is_daemon_started = false;
-       
-       if (0 != tts_setting_dbus_close_connection()) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to close connection");
-       } else {
-               SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Finalize");
-       }
+       tts_config_mgr_finalize(getpid());
 
        g_state = TTS_SETTING_STATE_NONE;
-       
+
        SLOG(LOG_DEBUG, TAG_TTSC, "=====");
        SLOG(LOG_DEBUG, TAG_TTSC, " ");
 
        return TTS_SETTING_ERROR_NONE;
 }
 
+bool __tts_config_mgr_get_engine_list(const char* engine_id, const char* engine_name, const char* setting, void* user_data)
+{
+       if (NULL != g_engine_cb) {
+               return g_engine_cb(engine_id, engine_name, setting, user_data);
+       }
+
+       return false;
+}
+
 int tts_setting_foreach_supported_engines(tts_setting_supported_engine_cb callback, void* user_data)
 {    
        SLOG(LOG_DEBUG, TAG_TTSC, "===== Foreach supported engines");
 
        if (TTS_SETTING_STATE_NONE == g_state) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Not initialized");
-               SLOG(LOG_DEBUG, TAG_TTSC, "=====");
-               SLOG(LOG_DEBUG, TAG_TTSC, " ");
                return TTS_SETTING_ERROR_INVALID_STATE;
        }
 
        if (NULL == callback) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Callback is NULL");
-               SLOG(LOG_DEBUG, TAG_TTSC, "=====");
-               SLOG(LOG_DEBUG, TAG_TTSC, " ");
                return TTS_SETTING_ERROR_INVALID_PARAMETER;
        }
 
-       int ret = tts_setting_dbus_request_get_engine_list(callback, user_data);
+       g_engine_cb = callback;
+
+       int ret = tts_config_mgr_get_engine_list(__tts_config_mgr_get_engine_list, user_data);
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Result : %d", ret);
-       } else {
-               SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Foreach supported engines");
        }
-       
+
+       g_engine_cb = NULL;
+
        SLOG(LOG_DEBUG, TAG_TTSC, "=====");
        SLOG(LOG_DEBUG, TAG_TTSC, " ");
-               
-       return ret;
+
+       return __setting_convert_config_error_code(ret);
 }
 
 int tts_setting_get_engine(char** engine_id)
@@ -194,7 +218,7 @@ int tts_setting_get_engine(char** engine_id)
                return TTS_SETTING_ERROR_INVALID_PARAMETER;
        }
 
-       int ret = tts_setting_dbus_request_get_engine(engine_id);
+       int ret = tts_config_mgr_get_engine(engine_id);
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Result : %d", ret);
        } else {
@@ -204,7 +228,7 @@ int tts_setting_get_engine(char** engine_id)
        SLOG(LOG_DEBUG, TAG_TTSC, "=====");
        SLOG(LOG_DEBUG, TAG_TTSC, " ");
 
-       return ret;
+       return __setting_convert_config_error_code(ret);
 }
 
 int tts_setting_set_engine(const char* engine_id)
@@ -225,17 +249,17 @@ int tts_setting_set_engine(const char* engine_id)
                return TTS_SETTING_ERROR_INVALID_PARAMETER;
        }
 
-       int ret = tts_setting_dbus_request_set_engine(engine_id);
+       int ret = tts_config_mgr_set_engine(engine_id);
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Result : %d", ret);
        } else {
-               SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Set current engine");
+               SECURE_SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Set current engine : %s", engine_id);
        }
        
        SLOG(LOG_DEBUG, TAG_TTSC, "=====");
        SLOG(LOG_DEBUG, TAG_TTSC, " ");
     
-       return ret;
+       return __setting_convert_config_error_code(ret);
 }
 
 int tts_setting_foreach_surpported_voices(tts_setting_supported_voice_cb callback, void* user_data)
@@ -244,19 +268,25 @@ int tts_setting_foreach_surpported_voices(tts_setting_supported_voice_cb callbac
 
        if (TTS_SETTING_STATE_NONE == g_state) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Not initialized");
-               SLOG(LOG_DEBUG, TAG_TTSC, "=====");
-               SLOG(LOG_DEBUG, TAG_TTSC, " ");
                return TTS_SETTING_ERROR_INVALID_STATE;
        }
 
        if (NULL == callback) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Param is NULL");
-               SLOG(LOG_DEBUG, TAG_TTSC, "=====");
-               SLOG(LOG_DEBUG, TAG_TTSC, " ");
                return TTS_SETTING_ERROR_INVALID_PARAMETER;
        }
 
-       int ret = tts_setting_dbus_request_get_voice_list(callback, user_data);
+       char* current_engine = NULL;
+       int ret = tts_config_mgr_get_engine(&current_engine);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get current engine : %d", ret);
+               return TTS_SETTING_ERROR_OPERATION_FAILED;
+       }
+
+       ret = tts_config_mgr_get_voice_list(current_engine, (tts_config_supported_voice_cb)callback, user_data);
+
+       if (NULL != current_engine)
+               free(current_engine);
 
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Result : %d", ret);
@@ -267,303 +297,364 @@ int tts_setting_foreach_surpported_voices(tts_setting_supported_voice_cb callbac
        SLOG(LOG_DEBUG, TAG_TTSC, "=====");
        SLOG(LOG_DEBUG, TAG_TTSC, " ");
 
-       return ret;
+       return __setting_convert_config_error_code(ret);
 }
 
-int tts_setting_get_default_voice(char** language, tts_setting_voice_type_e* voice_type)
+int tts_setting_get_voice(char** language, int* voice_type)
 {
        SLOG(LOG_DEBUG, TAG_TTSC, "===== Get default voice");
 
        if (TTS_SETTING_STATE_NONE == g_state) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Not initialized");
-               SLOG(LOG_DEBUG, TAG_TTSC, "=====");
-               SLOG(LOG_DEBUG, TAG_TTSC, " ");
                return TTS_SETTING_ERROR_INVALID_STATE;
        }
 
        if (NULL == language || NULL == voice_type) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input parameter is NULL");
-               SLOG(LOG_DEBUG, TAG_TTSC, "=====");
-               SLOG(LOG_DEBUG, TAG_TTSC, " ");
                return TTS_SETTING_ERROR_INVALID_PARAMETER;
        }
 
-       int ret = tts_setting_dbus_request_get_default_voice(language, voice_type);
+       int ret = tts_config_mgr_get_voice(language, (int*)voice_type);
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Result : %d", ret);
        } else {
-               SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Foreach supported voices");
+               SECURE_SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Get default voices : lang(%s) type(%d)", *language, *voice_type);
        }
 
        SLOG(LOG_DEBUG, TAG_TTSC, "=====");
        SLOG(LOG_DEBUG, TAG_TTSC, " ");
 
-       return ret;
+       return __setting_convert_config_error_code(ret);
 }
 
-int tts_setting_set_default_voice(const char* language, tts_setting_voice_type_e voice_type)
+int tts_setting_set_voice(const char* language, int voice_type)
 {
        SLOG(LOG_DEBUG, TAG_TTSC, "===== Set default voice");
 
        if (TTS_SETTING_STATE_NONE == g_state) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Not initialized");
-               SLOG(LOG_DEBUG, TAG_TTSC, "=====");
-               SLOG(LOG_DEBUG, TAG_TTSC, " ");
                return TTS_SETTING_ERROR_INVALID_STATE;
        }
 
        if (NULL == language) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input parameter is NULL");
-               SLOG(LOG_DEBUG, TAG_TTSC, "=====");
-               SLOG(LOG_DEBUG, TAG_TTSC, " ");
                return TTS_SETTING_ERROR_INVALID_PARAMETER;
        }
 
-       if (voice_type < TTS_SETTING_VOICE_TYPE_MALE || TTS_SETTING_VOICE_TYPE_USER3 < voice_type ) {
+       if (voice_type < TTS_SETTING_VOICE_TYPE_MALE || TTS_SETTING_VOICE_TYPE_CHILD < voice_type) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Invalid voice type");
-               SLOG(LOG_DEBUG, TAG_TTSC, "=====");
-               SLOG(LOG_DEBUG, TAG_TTSC, " ");
                return TTS_SETTING_ERROR_INVALID_PARAMETER;
        }
 
-       int ret = tts_setting_dbus_request_set_default_voice(language, voice_type);
+       int ret = tts_config_mgr_set_voice(language, (int)voice_type);
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Result : %d", ret);
        } else {
-               SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Set default voice");
+               SECURE_SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Set default voice : lang(%s) type(%d)",language, voice_type);
        }
 
        SLOG(LOG_DEBUG, TAG_TTSC, "=====");
        SLOG(LOG_DEBUG, TAG_TTSC, " ");
     
-       return ret;
+       return __setting_convert_config_error_code(ret);
 }
 
+int tts_setting_set_auto_voice(bool value)
+{
+       SLOG(LOG_DEBUG, TAG_TTSC, "===== Set auto voice");
+
+       if (TTS_SETTING_STATE_NONE == g_state) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Not initialized");
+               return TTS_SETTING_ERROR_INVALID_STATE;
+       }
+
+       if (value != true && value != false) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Invalid value");
+               return TTS_SETTING_ERROR_INVALID_PARAMETER;
+       }
 
-int tts_setting_get_default_speed(tts_setting_speed_e* speed)
+       int ret = tts_config_mgr_set_auto_voice(value);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Result : %d", ret);
+       } else {
+               SECURE_SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Set auto voice %s", value ? "on" : "off");
+       }
+
+       SLOG(LOG_DEBUG, TAG_TTSC, "=====");
+       SLOG(LOG_DEBUG, TAG_TTSC, " ");
+
+       return __setting_convert_config_error_code(ret);
+}
+
+int tts_setting_get_auto_voice(bool* value)
+{
+       SLOG(LOG_DEBUG, TAG_TTSC, "===== Get auto voice");
+
+       if (TTS_SETTING_STATE_NONE == g_state) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Not initialized");
+               return TTS_SETTING_ERROR_INVALID_STATE;
+       }
+
+       if (NULL == value) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Param is NULL");
+               return TTS_SETTING_ERROR_INVALID_PARAMETER;
+       }
+
+       int ret = tts_config_mgr_get_auto_voice(value);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Result : %d", ret);
+       } else {
+               SECURE_SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Get auto voice : %d ", (int)*value);
+       }
+
+       SLOG(LOG_DEBUG, TAG_TTSC, "=====");
+       SLOG(LOG_DEBUG, TAG_TTSC, " ");
+
+       return __setting_convert_config_error_code(ret);
+}
+
+int tts_setting_get_speed_range(int* min, int* normal, int* max)
+{
+       SLOG(LOG_DEBUG, TAG_TTSC, "===== Get speed range");
+
+       if (TTS_SETTING_STATE_NONE == g_state) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Not initialized");
+               return TTS_SETTING_ERROR_INVALID_STATE;
+       }
+
+       if (NULL == min || NULL == normal || NULL == max) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input parameter is null");
+               return TTS_SETTING_ERROR_INVALID_PARAMETER;
+       }
+
+       *min = TTS_SPEED_MIN;
+       *normal = TTS_SPEED_NORMAL;
+       *max = TTS_SPEED_MAX;
+
+       SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Get speed range : min(%d) normal(%d) max(%d)", *min, *normal, *max);
+
+       return TTS_SETTING_ERROR_NONE;
+}
+
+int tts_setting_get_speed(int* speed)
 {
        SLOG(LOG_DEBUG, TAG_TTSC, "===== Get default speed");
 
        if (TTS_SETTING_STATE_NONE == g_state) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Not initialized");
-               SLOG(LOG_DEBUG, TAG_TTSC, "=====");
-               SLOG(LOG_DEBUG, TAG_TTSC, " ");
                return TTS_SETTING_ERROR_INVALID_STATE;
        }
 
        if (NULL == speed) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Param is NULL");
-               SLOG(LOG_DEBUG, TAG_TTSC, "=====");
-               SLOG(LOG_DEBUG, TAG_TTSC, " ");
                return TTS_SETTING_ERROR_INVALID_PARAMETER;
        }
 
        int temp;
        temp = 0;
 
-       int ret = tts_setting_dbus_request_get_default_speed(&temp);
+       int ret = tts_config_mgr_get_speech_rate(&temp);
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Result : %d", ret);
        } else {
                /* Copy value */
-               *speed = (tts_setting_speed_e)temp;
-               SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Get default speed : %d ", (int)*speed);
+               *speed = temp;
+               SECURE_SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Get default speed : %d ", *speed);
        }
 
        SLOG(LOG_DEBUG, TAG_TTSC, "=====");
        SLOG(LOG_DEBUG, TAG_TTSC, " ");
 
-       return ret;
+       return __setting_convert_config_error_code(ret);
 }
 
-
-int tts_setting_set_default_speed(tts_setting_speed_e speed)
+int tts_setting_set_speed(int speed)
 {
        SLOG(LOG_DEBUG, TAG_TTSC, "===== Set default speed");
 
        if (TTS_SETTING_STATE_NONE == g_state) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Not initialized");
-               SLOG(LOG_DEBUG, TAG_TTSC, "=====");
-               SLOG(LOG_DEBUG, TAG_TTSC, " ");
                return TTS_SETTING_ERROR_INVALID_STATE;
        }
 
-       if (speed < TTS_SETTING_SPEED_VERY_SLOW || TTS_SETTING_SPEED_VERY_FAST < speed) {
+       if (TTS_SPEED_MIN > speed || speed > TTS_SPEED_MAX) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Invalid speed");
-               SLOG(LOG_DEBUG, TAG_TTSC, "=====");
-               SLOG(LOG_DEBUG, TAG_TTSC, " ");
                return TTS_SETTING_ERROR_INVALID_PARAMETER;
        }
 
-       int ret = tts_setting_dbus_request_set_default_speed((int)speed);
+       int ret = tts_config_mgr_set_speech_rate(speed);
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Result : %d", ret);
        } else {
-               SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Set default speed");
+               SECURE_SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Set default speed, %d", speed);
        }
        
        SLOG(LOG_DEBUG, TAG_TTSC, "=====");
        SLOG(LOG_DEBUG, TAG_TTSC, " ");
 
-       return ret;
+       return __setting_convert_config_error_code(ret);
 }
 
-int tts_setting_foreach_engine_settings(tts_setting_engine_setting_cb callback, void* user_data)
+int tts_setting_get_pitch_range(int* min, int* normal, int* max)
 {
-       SLOG(LOG_DEBUG, TAG_TTSC, "===== Foreach engine setting");
+       SLOG(LOG_DEBUG, TAG_TTSC, "===== Get speed range");
 
        if (TTS_SETTING_STATE_NONE == g_state) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Not initialized");
-               SLOG(LOG_DEBUG, TAG_TTSC, "=====");
-               SLOG(LOG_DEBUG, TAG_TTSC, " ");
                return TTS_SETTING_ERROR_INVALID_STATE;
        }
 
-       if (NULL == callback) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input parameter is NULL");
-               SLOG(LOG_DEBUG, TAG_TTSC, "=====");
-               SLOG(LOG_DEBUG, TAG_TTSC, " ");
+       if (NULL == min || NULL == normal || NULL == max) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input parameter is null");
                return TTS_SETTING_ERROR_INVALID_PARAMETER;
        }
 
-       int ret = tts_setting_dbus_request_get_engine_setting(callback, user_data);
+       *min = TTS_PITCH_MIN;
+       *normal = TTS_PITCH_NORMAL;
+       *max = TTS_PITCH_MAX;
+
+       SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Get pitch range : min(%d) normal(%d) max(%d)", *min, *normal, *max);
+
+       return TTS_SETTING_ERROR_NONE;
+}
+
+int tts_setting_set_pitch(int pitch)
+{
+       SLOG(LOG_DEBUG, TAG_TTSC, "===== Set default pitch");
+
+       if (TTS_SETTING_STATE_NONE == g_state) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Not initialized");
+               return TTS_SETTING_ERROR_INVALID_STATE;
+       }
+
+       if (TTS_PITCH_MIN > pitch || pitch > TTS_PITCH_MAX) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Invalid pitch");
+               return TTS_SETTING_ERROR_INVALID_PARAMETER;
+       }
+
+       int ret = tts_config_mgr_set_pitch(pitch);
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Result : %d", ret);
        } else {
-               SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Foreach engine setting");
+               SECURE_SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Set default pitch, %d", pitch);
        }
 
        SLOG(LOG_DEBUG, TAG_TTSC, "=====");
        SLOG(LOG_DEBUG, TAG_TTSC, " ");
 
-       return ret;
+       return __setting_convert_config_error_code(ret);
 }
 
-int tts_setting_set_engine_setting(const char* key, const char* value)
+int tts_setting_get_pitch(int* pitch)
 {
-       SLOG(LOG_DEBUG, TAG_TTSC, "===== Set engine setting");
+       SLOG(LOG_DEBUG, TAG_TTSC, "===== Get default pitch");
 
        if (TTS_SETTING_STATE_NONE == g_state) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Not initialized");
-               SLOG(LOG_DEBUG, TAG_TTSC, "=====");
-               SLOG(LOG_DEBUG, TAG_TTSC, " ");
                return TTS_SETTING_ERROR_INVALID_STATE;
        }
 
-       if(NULL == key || NULL == value) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Param is NULL");
-               SLOG(LOG_DEBUG, TAG_TTSC, "=====");
-               SLOG(LOG_DEBUG, TAG_TTSC, " ");
+       if (NULL == pitch) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input parameter is NULL");
                return TTS_SETTING_ERROR_INVALID_PARAMETER;
        }
 
-       int ret = tts_setting_dbus_request_set_engine_setting(key, value);
+       int temp;
+       temp = 0;
+
+       int ret = tts_config_mgr_get_pitch(&temp);
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Result : %d", ret);
        } else {
-               SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Foreach engine setting");
+               /* Copy value */
+               *pitch = temp;
+               SECURE_SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Get default pitch : %d ", *pitch);
        }
 
-       SLOG(LOG_DEBUG, TAG_TTSC, "=====");
-       SLOG(LOG_DEBUG, TAG_TTSC, " ");
-
-       return ret;
+       return __setting_convert_config_error_code(ret);
 }
 
-int __setting_get_cmd_line(char *file, char *buf) 
+int tts_setting_set_engine_changed_cb(tts_setting_engine_changed_cb callback, void* user_data)
 {
-       FILE *fp = NULL;
-
-       fp = fopen(file, "r");
-       if (fp == NULL) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Get command line");
-               return -1;
+       if (NULL == callback) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input param is NULL");
+               return TTS_SETTING_ERROR_INVALID_PARAMETER;
        }
 
-       memset(buf, 0, 256);
-       if (NULL == fgets(buf, 256, fp)) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail fgets command line");
-               fclose(fp);
-               return -1;
-       }
-       fclose(fp);
+       g_engine_changed_cb = callback;
+       g_engine_changed_user_data = user_data;
 
-       return 0;
+       return TTS_SETTING_ERROR_NONE;
 }
 
-/* Functions for tts-daemon fork */
-static bool __tts_setting_is_alive()
+int tts_setting_unset_engine_changed_cb()
 {
-       DIR *dir;
-       struct dirent *entry;
-       struct stat filestat;
-       
-       int pid;
-       char cmdLine[256];
-       char tempPath[256];
+       g_engine_changed_cb = NULL;
+       g_engine_changed_user_data = NULL;
 
-       dir  = opendir("/proc");
-       if (NULL == dir) {
-               SLOG(LOG_ERROR, TAG_TTSC, "process checking is FAILED");
-               return FALSE;
+       return TTS_SETTING_ERROR_NONE;
+}
+
+int tts_setting_set_voice_changed_cb(tts_setting_voice_changed_cb callback, void* user_data)
+{
+       if (NULL == callback) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input param is NULL");
+               return TTS_SETTING_ERROR_INVALID_PARAMETER;
        }
 
-       while ((entry = readdir(dir)) != NULL) {
-               if (0 != lstat(entry->d_name, &filestat))
-                       continue;
+       g_voice_changed_cb = callback;
+       g_voice_changed_user_data = user_data;
 
-               if (!S_ISDIR(filestat.st_mode))
-                       continue;
+       return TTS_SETTING_ERROR_NONE;
+}
 
-               pid = atoi(entry->d_name);
-               if (pid <= 0) continue;
+int tts_setting_unset_voice_changed_cb()
+{
+       g_voice_changed_cb = NULL;
+       g_voice_changed_user_data = NULL;
 
-               sprintf(tempPath, "/proc/%d/cmdline", pid);
-               if (0 != __setting_get_cmd_line(tempPath, cmdLine)) {
-                       continue;
-               }
+       return TTS_SETTING_ERROR_NONE;
+}
 
-               if (0 == strncmp(cmdLine, "[tts-daemon]", strlen("[tts-daemon]")) ||
-                       0 == strncmp(cmdLine, "tts-daemon", strlen("tts-daemon")) ||
-                       0 == strncmp(cmdLine, "/usr/bin/tts-daemon", strlen("/usr/bin/tts-daemon"))) {
-                               SLOG(LOG_DEBUG, TAG_TTSC, "tts-daemon is ALIVE !!");
-                               closedir(dir);
-                               return TRUE;
-               }
+int tts_setting_set_speed_changed_cb(tts_setting_speed_changed_cb callback, void* user_data)
+{
+       if (NULL == callback) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input param is NULL");
+               return TTS_SETTING_ERROR_INVALID_PARAMETER;
        }
-       SLOG(LOG_DEBUG, TAG_TTSC, "THERE IS NO tts-daemon !!");
 
-       closedir(dir);
-       return FALSE;
+       g_speed_changed_cb = callback;
+       g_speed_changed_user_data = user_data;
 
+       return TTS_SETTING_ERROR_NONE;
 }
 
-static int __check_setting_tts_daemon()
+int tts_setting_unset_speed_changed_cb()
 {
-       if( TRUE == __tts_setting_is_alive() )
-               return 0;
+       g_speed_changed_cb = NULL;
+       g_speed_changed_user_data = NULL;
 
-       /* fork-exec tts-daemom */
-       int pid, i;
+       return TTS_SETTING_ERROR_NONE;
+}
 
-       pid = fork();
 
-       switch(pid) {
-       case -1:
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to create tts-daemon ");
-               break;
+int tts_setting_set_pitch_changed_cb(tts_setting_pitch_changed_cb callback, void* user_data)
+{
+       if (NULL == callback) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input param is NULL");
+               return TTS_SETTING_ERROR_INVALID_PARAMETER;
+       }
 
-       case 0:
-               setsid();
-               for( i = 0 ; i < _NSIG ; i++ )
-                       signal(i, SIG_DFL);
+       g_pitch_changed_cb = callback;
+       g_pitch_changed_user_data = user_data;
 
-               execl("/usr/bin/tts-daemon", "/usr/bin/tts-daemon", NULL);
-               break;
+       return TTS_SETTING_ERROR_NONE;
+}
 
-       default:
-               break;
-       }
+int tts_setting_unset_pitch_changed_cb()
+{
+       g_pitch_changed_cb = NULL;
+       g_pitch_changed_user_data = NULL;
 
-       return 0;
-}
\ No newline at end of file
+       return TTS_SETTING_ERROR_NONE;
+}
diff --git a/client/tts_setting.h b/client/tts_setting.h
deleted file mode 100644 (file)
index 55caf70..0000000
+++ /dev/null
@@ -1,337 +0,0 @@
-/*
-*  Copyright (c) 2012, 2013 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 __TTS_SETTING_H__
-#define __TTS_SETTING_H__
-
-#include <errno.h>
-#include <stdbool.h>
-
-/**
-* @addtogroup TTS_SETTING_MODULE
-* @{
-*/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/** 
-* @brief Enumerations of error codes.
-*/
-typedef enum {
-       TTS_SETTING_ERROR_NONE                  = 0,            /**< Success, No error */
-       TTS_SETTING_ERROR_OUT_OF_MEMORY         = -ENOMEM,      /**< Out of Memory */
-       TTS_SETTING_ERROR_IO_ERROR              = -EIO,         /**< I/O error */
-       TTS_SETTING_ERROR_INVALID_PARAMETER     = -EINVAL,      /**< Invalid parameter */
-       TTS_SETTING_ERROR_INVALID_STATE         = -0x0100021,   /**< Invalid state */
-       TTS_SETTING_ERROR_INVALID_VOICE         = -0x0100022,   /**< Invalid voice */
-       TTS_SETTING_ERROR_ENGINE_NOT_FOUND      = -0x0100023,   /**< No available TTS-engine  */
-       TTS_SETTING_ERROR_TIMED_OUT             = -0x0100024,   /**< No answer from TTS daemon */
-       TTS_SETTING_ERROR_OPERATION_FAILED      = -0x0100025,   /**< TTS daemon failed  */
-} tts_setting_error_e;
-
-/** 
-* @brief Enumerations of speaking speed.
-*/
-typedef enum {
-       TTS_SETTING_SPEED_AUTO  = 0,    /**< Speed from settings */
-       TTS_SETTING_SPEED_VERY_SLOW,    /**< Very slow */
-       TTS_SETTING_SPEED_SLOW,         /**< Slow */
-       TTS_SETTING_SPEED_NORMAL,       /**< Normal */
-       TTS_SETTING_SPEED_FAST,         /**< Fast */
-       TTS_SETTING_SPEED_VERY_FAST     /**< Very fast */
-} tts_setting_speed_e;
-
-/** 
-* @brief Enumerations of voice type.
-*/
-typedef enum {
-       TTS_SETTING_VOICE_TYPE_AUTO = 0,        /**< Voice type from settings or auto selection based language*/
-       TTS_SETTING_VOICE_TYPE_MALE,            /**< Male */
-       TTS_SETTING_VOICE_TYPE_FEMALE,          /**< Female */
-       TTS_SETTING_VOICE_TYPE_CHILD,           /**< Child */
-       TTS_SETTING_VOICE_TYPE_USER1,           /**< Engine defined */
-       TTS_SETTING_VOICE_TYPE_USER2,           /**< Engine defined */
-       TTS_SETTING_VOICE_TYPE_USER3            /**< Engine defined */
-} tts_setting_voice_type_e;
-
-/** 
-* @brief Enumerations of setting state.
-*/
-typedef enum {
-       TTS_SETTING_STATE_NONE = 0,
-       TTS_SETTING_STATE_READY
-} tts_setting_state_e;
-
-/**
-* @brief Called to get a engine information.
-*
-* @param[in] engine_id Engine id.
-* @param[in] engine_name engine name.
-* @param[in] setting_path gadget path of engine specific setting.
-* @param[in] user_data User data passed from the tts_setting_foreach_supported_engines().
-*
-* @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop.
-* @pre tts_setting_foreach_supported_engines() will invoke this callback. 
-*
-* @see tts_setting_foreach_supported_engines()
-*/
-typedef bool(*tts_setting_supported_engine_cb)(const char* engine_id, const char* engine_name, const char* setting_path, void* user_data);
-
-/**
-* @brief Called to get a voice.
-*
-* @param[in] engine_id Engine id.
-* @param[in] language A language is specified as an ISO 3166 alpha-2 two letter country-code
-*              followed by ISO 639-1 for the two-letter language code. 
-*              For example, "ko_KR" for Korean, "en_US" for American English..
-* @param[in] voice_type Voice type.
-* @param[in] user_data User data passed from the tts_setting_foreach_surpported_voices().
-*
-* @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop.
-* @pre tts_setting_foreach_surpported_voices() will invoke this callback. 
-*
-* @see tts_setting_foreach_surpported_voices()
-*/
-typedef bool(*tts_setting_supported_voice_cb)(const char* engine_id, const char* language, tts_setting_voice_type_e voice_type, void* user_data);
-
-/**
-* @brief Called to get a engine setting.
-*
-* @param[in] engine_id Engine id.
-* @param[in] key Key.
-* @param[in] value Value.
-* @param[in] user_data User data passed from the tts_setting_foreach_engine_settings().
-*
-* @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop.
-* @pre tts_setting_foreach_engine_settings() will invoke this callback. 
-*
-* @see tts_setting_foreach_engine_settings()
-*/
-typedef bool(*tts_setting_engine_setting_cb)(const char* engine_id, const char* key, const char* value, void* user_data);
-
-/**
-* @brief Called to initialize setting.
-*
-* @param[in] state Current state.
-* @param[in] reason Error reason.
-* @param[in] user_data User data passed from the tts_setting_initialize_async().
-*
-* @pre tts_setting_initialize_async() will invoke this callback. 
-*
-* @see tts_setting_initialize_async()
-*/
-typedef void(*tts_setting_initialized_cb)(tts_setting_state_e state, tts_setting_error_e reason, void* user_data);
-
-/**
-* @brief Initialize TTS setting and connect to tts-daemon asynchronously.
-*
-* @return 0 on success, otherwise a negative error value.
-* @retval #TTS_SETTING_ERROR_NONE Success.
-* @retval #TTS_SETTING_ERROR_TIMED_OUT tts daemon is blocked or tts daemon do not exist.
-* @retval #TTS_SETTING_ERROR_INVALID_STATE TTS setting has Already been initialized. 
-* @retval #TTS_SETTING_ERROR_ENGINE_NOT_FOUND No available tts-engine. Engine should be installed.
-*
-* @see tts_setting_finalize()
-*/
-int tts_setting_initialize(tts_setting_initialized_cb callback, void* user_data);
-
-/**
-* @brief finalize tts setting and disconnect to tts-daemon. 
-*
-* @return 0 on success, otherwise a negative error value.
-* @retval #TTS_SETTING_ERROR_NONE Success.
-* @retval #TTS_SETTING_ERROR_INVALID_STATE TTS Not initialized. 
-* @retval #TTS_SETTING_ERROR_OPERATION_FAILED Operation failure.
-*
-* @see tts_setting_initialize()
-*/
-int tts_setting_finalize(void);
-
-/**
-* @brief Retrieve supported engine informations using callback function.
-*
-* @param[in] callback callback function
-* @param[in] user_data User data to be passed to the callback function.
-*
-* @return 0 on success, otherwise a negative error value.
-* @retval #TTS_SETTING_ERROR_NONE Success.
-* @retval #TTS_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
-* @retval #TTS_SETTING_ERROR_INVALID_STATE TTS Not initialized. 
-* @post        This function invokes tts_setting_supported_engine_cb() repeatedly for getting engine information. 
-*
-* @see tts_setting_supported_engine_cb()
-*/
-int tts_setting_foreach_supported_engines(tts_setting_supported_engine_cb callback, void* user_data);
-
-/**
-* @brief Get current engine id.
-*
-* @remark If the function is success, @a engine_id must be released with free() by you.
-*
-* @param[out] engine_id engine id.
-*
-* @return 0 on success, otherwise a negative error value.
-* @retval #TTS_SETTING_ERROR_NONE Success.
-* @retval #TTS_SETTING_ERROR_OUT_OF_MEMORY Out of memory.
-* @retval #TTS_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
-* @retval #TTS_SETTING_ERROR_INVALID_STATE TTS Not initialized. 
-* @retval #TTS_SETTING_ERROR_OPERATION_FAILED Operation failure.
-*
-* @see tts_setting_set_engine()
-*/
-int tts_setting_get_engine(char** engine_id);
-
-/**
-* @brief Set current engine id.
-*
-* @param[in] engine_id engine id.
-*
-* @return 0 on success, otherwise a negative error value.
-* @retval #TTS_SETTING_ERROR_NONE Success.
-* @retval #TTS_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
-* @retval #TTS_SETTING_ERROR_INVALID_STATE TTS Not initialized. 
-* @retval #TTS_SETTING_ERROR_OPERATION_FAILED Operation failure.
-*
-* @see tts_setting_get_engine()
-*/
-int tts_setting_set_engine(const char* engine_id);
-
-/**
-* @brief Get supported voices of current engine.
-*
-* @param[in] callback callback function.
-* @param[in] user_data User data to be passed to the callback function.
-*
-* @return 0 on success, otherwise a negative error value.
-* @retval #TTS_SETTING_ERROR_NONE Success.
-* @retval #TTS_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
-* @retval #TTS_SETTING_ERROR_INVALID_STATE TTS Not initialized. 
-* @retval #TTS_SETTING_ERROR_OPERATION_FAILED Operation failure.
-*
-* @post        This function invokes tts_setting_supported_voice_cb() repeatedly for getting supported voices. 
-*
-* @see tts_setting_supported_voice_cb()
-*/
-int tts_setting_foreach_surpported_voices(tts_setting_supported_voice_cb callback, void* user_data);
-
-/**
-* @brief Get a default voice of current engine.
-*
-* @remark If the function is success, @a language must be released with free() by you.
-*
-* @param[out] language current language
-* @param[out] voice_type current voice type
-*
-* @return 0 on success, otherwise a negative error value.
-* @retval #TTS_SETTING_ERROR_NONE Success.
-* @retval #TTS_SETTING_ERROR_OUT_OF_MEMORY Out of memory.
-* @retval #TTS_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
-* @retval #TTS_SETTING_ERROR_INVALID_STATE TTS Not initialized. 
-* @retval #TTS_SETTING_ERROR_OPERATION_FAILED Operation failure.
-*
-* @see tts_setting_set_default_voice()
-*/
-int tts_setting_get_default_voice(char** language, tts_setting_voice_type_e* voice_type);
-
-/**
-* @brief Set a default voice of current engine.
-*
-* @param[in] language language
-* @param[in] voice_type voice type.
-*
-* @return 0 on success, otherwise a negative error value.
-* @retval #TTS_SETTING_ERROR_NONE Success.
-* @retval #TTS_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
-* @retval #TTS_SETTING_ERROR_INVALID_STATE TTS Not initialized. 
-* @retval #TTS_SETTING_ERROR_OPERATION_FAILED Operation failure.
-*
-* @see tts_setting_get_default_voice()
-*/
-int tts_setting_set_default_voice(const char* language, tts_setting_voice_type_e voice_type);
-
-/**
-* @brief Get default speed.
-*
-* @param[out] speed voice speed.
-*
-* @return 0 on success, otherwise a negative error value.
-* @retval #TTS_SETTING_ERROR_NONE Success.
-* @retval #TTS_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
-* @retval #TTS_SETTING_ERROR_INVALID_STATE TTS Not initialized. 
-* @retval #TTS_SETTING_ERROR_OPERATION_FAILED Operation failure.
-*
-* @see tts_setting_set_default_speed()
-*/
-int tts_setting_get_default_speed(tts_setting_speed_e* speed);
-
-/**
-* @brief Set a default speed.
-*
-* @param[in] speed voice speed
-*
-* @return 0 on success, otherwise a negative error value.
-* @retval #TTS_SETTING_ERROR_NONE Success.
-* @retval #TTS_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
-* @retval #TTS_SETTING_ERROR_INVALID_STATE TTS Not initialized. 
-* @retval #TTS_SETTING_ERROR_OPERATION_FAILED Operation failure.
-*
-* @see tts_setting_get_default_speed()
-*/
-int tts_setting_set_default_speed(tts_setting_speed_e speed);
-
-/**
-* @brief Get setting information of current engine.
-*
-* @param[in] callback callback function
-* @param[in] user_data User data to be passed to the callback function.
-*
-* @return 0 on success, otherwise a negative error value.
-* @retval #TTS_SETTING_ERROR_NONE Success.
-* @retval #TTS_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
-* @retval #TTS_SETTING_ERROR_INVALID_STATE TTS Not initialized. 
-* @retval #TTS_SETTING_ERROR_OPERATION_FAILED Operation failure.
-*
-* @post        This function invokes tts_setting_engine_setting_cb() repeatedly for getting engine settings. 
-*
-* @see tts_setting_engine_setting_cb()
-*/
-int tts_setting_foreach_engine_settings(tts_setting_engine_setting_cb callback, void* user_data);
-
-/**
-* @brief Set setting information.
-*
-* @param[in] key Key.
-* @param[in] value Value.
-*
-* @return 0 on success, otherwise a negative error value.
-* @retval #TTS_SETTING_ERROR_NONE Success.
-* @retval #TTS_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
-* @retval #TTS_SETTING_ERROR_INVALID_STATE TTS Not initialized. 
-* @retval #TTS_SETTING_ERROR_OPERATION_FAILED Operation failure.
-*
-* @see tts_setting_foreach_engine_settings()
-*/
-int tts_setting_set_engine_setting(const char* key, const char* value);
-
-#ifdef __cplusplus
-}
-#endif
-
-/**
-* @}
-*/
-
-#endif /* __TTS_SETTING_H__ */
diff --git a/client/tts_setting_dbus.c b/client/tts_setting_dbus.c
deleted file mode 100644 (file)
index 093f376..0000000
+++ /dev/null
@@ -1,947 +0,0 @@
-/*
-*  Copyright (c) 2012, 2013 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 "tts_setting.h"
-#include "tts_main.h"
-#include "tts_setting_dbus.h"
-
-
-static DBusConnection* g_conn = NULL;
-
-int tts_setting_dbus_open_connection()
-{
-       if (NULL != g_conn) {
-               SLOG(LOG_WARN, TAG_TTSC, "Already existed connection");
-               return 0;
-       }
-
-       DBusError err;
-       int ret;
-
-       /* initialise the error value */
-       dbus_error_init(&err);
-
-       /* connect to the DBUS system bus, and check for errors */
-       g_conn = dbus_bus_get_private(DBUS_BUS_SYSTEM, &err);
-
-       if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, TAG_TTSC, "Dbus Connection Error (%s)\n", err.message); 
-               dbus_error_free(&err); 
-       }
-
-       if (NULL == g_conn) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get dbus connection \n");
-               return TTS_SETTING_ERROR_OPERATION_FAILED; 
-       }
-
-       int pid = getpid();
-
-       char service_name[64];
-       memset(service_name, 0, 64);
-       snprintf(service_name, 64, "%s%d", TTS_SETTING_SERVICE_NAME, pid);
-
-       SLOG(LOG_DEBUG, TAG_TTSC, "service name is %s\n", service_name);
-
-       /* register our name on the bus, and check for errors */
-       ret = dbus_bus_request_name(g_conn, service_name, DBUS_NAME_FLAG_REPLACE_EXISTING , &err);
-
-       if (dbus_error_is_set(&err)) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Name Error (%s)\n", err.message); 
-               dbus_error_free(&err); 
-       }
-
-       if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[Dbus ERROR] fail to be primary owner \n");
-               return TTS_SETTING_ERROR_OPERATION_FAILED;
-       }
-
-       return 0;
-}
-
-int tts_setting_dbus_close_connection()
-{
-       DBusError err;
-       dbus_error_init(&err);
-
-       int pid = getpid();
-
-       char service_name[64];
-       memset(service_name, 0, 64);
-       snprintf(service_name, 64, "%s%d", TTS_SETTING_SERVICE_NAME, pid);
-
-       dbus_bus_release_name(g_conn, service_name, &err);
-
-       dbus_connection_close(g_conn);
-
-       g_conn = NULL;
-
-       return 0;
-}
-
-int tts_setting_dbus_request_hello()
-{
-       DBusMessage* msg;
-
-       msg = dbus_message_new_method_call(
-               TTS_SERVER_SERVICE_NAME, 
-               TTS_SERVER_SERVICE_OBJECT_PATH, 
-               TTS_SERVER_SERVICE_INTERFACE, 
-               TTS_SETTING_METHOD_HELLO);
-
-       if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request setting hello : Fail to make message \n"); 
-               return TTS_SETTING_ERROR_OPERATION_FAILED;
-       } 
-
-       DBusError err;
-       dbus_error_init(&err);
-
-       DBusMessage* result_msg = NULL;
-       int result = 0;
-
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 500, &err);
-
-       dbus_message_unref(msg);
-
-       if (NULL != result_msg) {
-               dbus_message_unref(result_msg);
-
-               SLOG(LOG_DEBUG, TAG_TTSC, "<<<< setting hello");
-               result = 0;
-       } else {
-               result = -1;
-       }
-
-       return result;
-}
-
-int tts_setting_dbus_request_initialize()
-{
-       DBusMessage* msg;
-
-       msg = dbus_message_new_method_call(
-               TTS_SERVER_SERVICE_NAME, 
-               TTS_SERVER_SERVICE_OBJECT_PATH, 
-               TTS_SERVER_SERVICE_INTERFACE, 
-               TTS_SETTING_METHOD_INITIALIZE);
-
-       if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request setting initialize : Fail to make message \n"); 
-               return TTS_SETTING_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request setting initialize");
-       }
-
-       int pid = getpid();
-
-       dbus_message_append_args( msg, 
-               DBUS_TYPE_INT32, &pid,
-               DBUS_TYPE_INVALID);
-
-       DBusError err;
-       dbus_error_init(&err);
-
-       DBusMessage* result_msg;
-       int result = TTS_SETTING_ERROR_OPERATION_FAILED;
-
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 3000, &err);
-
-       if (NULL != result_msg) {
-               dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
-
-               if (dbus_error_is_set(&err)) { 
-                       SLOG(LOG_ERROR, TAG_TTSC, "Get arguments error (%s)\n", err.message);
-                       dbus_error_free(&err); 
-                       result = TTS_SETTING_ERROR_OPERATION_FAILED;
-               }
-               dbus_message_unref(result_msg);
-       }
-
-       if (0 == result) {
-               SLOG(LOG_DEBUG, TAG_TTSC, "<<<< setting initialize : result = %d \n", result);
-       } else {
-               SLOG(LOG_ERROR, TAG_TTSC, "<<<< setting initialize : result = %d \n", result);
-       }
-
-       dbus_message_unref(msg);
-
-       return result;
-}
-
-int tts_setting_dbus_request_finalilze()
-{
-       DBusMessage* msg;
-
-       msg = dbus_message_new_method_call(
-               TTS_SERVER_SERVICE_NAME, 
-               TTS_SERVER_SERVICE_OBJECT_PATH, 
-               TTS_SERVER_SERVICE_INTERFACE, 
-               TTS_SETTING_METHOD_FINALIZE);
-
-       if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request setting finalize : Fail to make message \n"); 
-               return TTS_SETTING_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request setting finalize");
-       }
-
-       int pid = getpid();
-
-       dbus_message_append_args(msg, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID);
-
-       DBusError err;
-       dbus_error_init(&err);
-
-       DBusMessage* result_msg;
-       int result = 0;
-
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 3000, &err);
-
-       if (NULL != result_msg) {
-               dbus_message_get_args(result_msg, &err,
-                       DBUS_TYPE_INT32, &result,
-                       DBUS_TYPE_INVALID);
-
-               if (dbus_error_is_set(&err)) { 
-                       SLOG(LOG_ERROR, TAG_TTSC, "Get arguments error (%s)\n", err.message);
-                       dbus_error_free(&err); 
-                       result = TTS_SETTING_ERROR_OPERATION_FAILED;
-               }
-               dbus_message_unref(result_msg);
-       }
-
-       if (0 == result) {
-               SLOG(LOG_DEBUG, TAG_TTSC, "<<<< setting finalize : result = %d \n", result);
-       } else {
-               SLOG(LOG_ERROR, TAG_TTSC, "<<<< setting finalize : result = %d \n", result);
-       }
-
-       dbus_message_unref(msg);
-
-       return result;
-}
-
-int tts_setting_dbus_request_get_engine_list(tts_setting_supported_engine_cb callback, void* user_data)
-{
-       DBusMessage* msg;
-
-       msg = dbus_message_new_method_call(
-               TTS_SERVER_SERVICE_NAME, 
-               TTS_SERVER_SERVICE_OBJECT_PATH, 
-               TTS_SERVER_SERVICE_INTERFACE, 
-               TTS_SETTING_METHOD_GET_ENGINE_LIST);
-
-       if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request setting get engine list : Fail to make message \n"); 
-               return TTS_SETTING_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request setting get engine list");
-       }
-
-       int pid = getpid();
-
-       dbus_message_append_args(msg, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID);
-
-       DBusError err;
-       dbus_error_init(&err);
-
-       DBusMessage* result_msg;
-       int result = TTS_SETTING_ERROR_OPERATION_FAILED;
-
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 3000, &err);
-       
-       if (NULL != result_msg) {
-               DBusMessageIter args;
-               
-               if (dbus_message_iter_init(result_msg, &args)) {
-                       /* Get result */
-                       if (DBUS_TYPE_INT32 == dbus_message_iter_get_arg_type(&args)) {
-                               dbus_message_iter_get_basic(&args, &result);
-                               dbus_message_iter_next(&args);
-                       } 
-
-                       if (0 == result) {
-                               SLOG(LOG_DEBUG, TAG_TTSC, "<<<< setting get engine list : result = %d \n", result);
-
-                               int size ; 
-                               char* temp_id;
-                               char* temp_name;
-                               char* temp_path;
-
-                               /* Get engine count */
-                               if (DBUS_TYPE_INT32 == dbus_message_iter_get_arg_type(&args)) {
-                                       dbus_message_iter_get_basic(&args, &size);
-                                       dbus_message_iter_next(&args);
-                               }
-
-                               int i=0;
-                               for (i=0 ; i<size ; i++) {
-                                       dbus_message_iter_get_basic(&args, &(temp_id));
-                                       dbus_message_iter_next(&args);
-                               
-                                       dbus_message_iter_get_basic(&args, &(temp_name));
-                                       dbus_message_iter_next(&args);
-                               
-                                       dbus_message_iter_get_basic(&args, &(temp_path));
-                                       dbus_message_iter_next(&args);
-                               
-                                       if (true != callback(temp_id, temp_name, temp_path, user_data)) {
-                                               break;
-                                       }
-                               }
-                       }  else {
-                               SLOG(LOG_ERROR, TAG_TTSC, "<<<< setting get engine list : result = %d \n", result);
-                       }
-               } else {
-                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< setting get engine list : invalid message \n");
-               }
-
-               dbus_message_unref(result_msg);
-       } else {
-               SLOG(LOG_ERROR, TAG_TTSC, "<<<< setting get engine list : result message is NULL!! \n");
-       }
-
-       dbus_message_unref(msg);
-
-       return result;
-}
-
-int tts_setting_dbus_request_get_engine(char** engine_id)
-{
-       if (NULL == engine_id)  {
-               SLOG(LOG_ERROR, TAG_TTSC, "Input parameter is NULL");
-               return TTS_SETTING_ERROR_INVALID_PARAMETER;
-       }
-
-       DBusMessage* msg;
-
-       msg = dbus_message_new_method_call(
-               TTS_SERVER_SERVICE_NAME, 
-               TTS_SERVER_SERVICE_OBJECT_PATH, 
-               TTS_SERVER_SERVICE_INTERFACE, 
-               TTS_SETTING_METHOD_GET_ENGINE);
-
-       if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request setting get engine : Fail to make message \n"); 
-               return TTS_SETTING_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request setting get engine ");
-       }
-
-       int pid = getpid();
-
-       dbus_message_append_args( msg, 
-               DBUS_TYPE_INT32, &pid,
-               DBUS_TYPE_INVALID);
-
-       DBusError err;
-       dbus_error_init(&err);
-
-       DBusMessage* result_msg;
-       int result = TTS_SETTING_ERROR_OPERATION_FAILED;
-       char* temp;
-
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 3000, &err);
-
-       if (NULL != result_msg) {
-               dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_STRING, &temp, DBUS_TYPE_INVALID);
-       
-               if (dbus_error_is_set(&err)) { 
-                       SLOG(LOG_ERROR, TAG_TTSC, "Get arguments error (%s)\n", err.message);
-                       dbus_error_free(&err); 
-                       result = TTS_SETTING_ERROR_OPERATION_FAILED;
-               }
-               dbus_message_unref(result_msg);
-       }
-
-       if (0 == result) {
-               *engine_id = strdup(temp);
-
-               if (NULL == *engine_id) {
-                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< setting get engine : Out of memory \n");
-                       result = TTS_SETTING_ERROR_OUT_OF_MEMORY;
-               } else {
-                       SLOG(LOG_DEBUG, TAG_TTSC, "<<<< setting get engine : result(%d), engine id(%s)\n", result, *engine_id);
-               }
-       } else {
-               SLOG(LOG_ERROR, TAG_TTSC, "<<<< setting get engine : result(%d) \n", result);
-       }
-
-       dbus_message_unref(msg);
-
-       return result;
-}
-
-
-int tts_setting_dbus_request_set_engine(const char* engine_id)
-{
-       if (NULL == engine_id)  {
-               SLOG(LOG_ERROR, TAG_TTSC, "Input parameter is NULL");
-               return TTS_SETTING_ERROR_INVALID_PARAMETER;
-       }
-
-       DBusMessage* msg;
-
-       msg = dbus_message_new_method_call(
-               TTS_SERVER_SERVICE_NAME, 
-               TTS_SERVER_SERVICE_OBJECT_PATH, 
-               TTS_SERVER_SERVICE_INTERFACE, 
-               TTS_SETTING_METHOD_SET_ENGINE);
-
-       if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request setting set engine : Fail to make message \n"); 
-               return TTS_SETTING_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request setting set engine : engine id(%s)", engine_id);
-       }
-
-       int pid = getpid();
-
-       dbus_message_append_args( msg, 
-               DBUS_TYPE_INT32, &pid,
-               DBUS_TYPE_STRING, &engine_id,
-               DBUS_TYPE_INVALID);
-
-       DBusError err;
-       dbus_error_init(&err);
-
-       DBusMessage* result_msg;
-       int result = TTS_SETTING_ERROR_OPERATION_FAILED;
-
-       result_msg = dbus_connection_send_with_reply_and_block  ( g_conn, msg, 3000, &err);
-
-       if (NULL != result_msg) {
-               dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
-
-               if (dbus_error_is_set(&err)) { 
-                       SLOG(LOG_ERROR, TAG_TTSC, "Get arguments error (%s)\n", err.message);
-                       dbus_error_free(&err); 
-                       result = TTS_SETTING_ERROR_OPERATION_FAILED;
-               }
-               dbus_message_unref(result_msg);
-       }
-
-       if (0 == result) {
-               SLOG(LOG_DEBUG, TAG_TTSC, "<<<< setting set engine : result(%d) \n", result);
-       } else {
-               SLOG(LOG_ERROR, TAG_TTSC, "<<<< setting set engine : result(%d) \n", result);
-       }
-
-       dbus_message_unref(msg);
-
-       return result;
-}
-
-int tts_setting_dbus_request_get_voice_list(tts_setting_supported_voice_cb callback, void* user_data)
-{
-       if (NULL == callback) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Input parameter is NULL");
-               return TTS_SETTING_ERROR_INVALID_PARAMETER;
-       }
-
-       DBusMessage* msg;
-
-       msg = dbus_message_new_method_call(
-               TTS_SERVER_SERVICE_NAME, 
-               TTS_SERVER_SERVICE_OBJECT_PATH, 
-               TTS_SERVER_SERVICE_INTERFACE, 
-               TTS_SETTING_METHOD_GET_VOICE_LIST);
-
-       if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request setting get voice list : Fail to make message \n"); 
-               return TTS_SETTING_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request setting get voice list");
-       }
-
-       int pid = getpid();
-
-       dbus_message_append_args( msg, 
-               DBUS_TYPE_INT32, &pid,
-               DBUS_TYPE_INVALID);
-
-       DBusError err;
-       dbus_error_init(&err);
-
-       DBusMessage* result_msg;
-       int result = TTS_SETTING_ERROR_OPERATION_FAILED;
-
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 3000, &err);
-
-       DBusMessageIter args;
-
-       if (NULL != result_msg) {
-               if (dbus_message_iter_init(result_msg, &args)) {
-                       /* Get result */
-                       if (DBUS_TYPE_INT32 == dbus_message_iter_get_arg_type(&args)) {
-                               dbus_message_iter_get_basic(&args, &result);
-                               dbus_message_iter_next(&args);
-                       } 
-
-                       if (0 == result) {
-                               SLOG(LOG_DEBUG, TAG_TTSC, "<<<< setting get voice list : result = %d \n", result);
-
-                               int size = 0; 
-                               char* temp_id = NULL;
-                               char* temp_lang = NULL;
-                               int temp_type;
-
-                               /* Get current voice */
-                               dbus_message_iter_get_basic(&args, &temp_id);
-                               dbus_message_iter_next(&args);
-
-                               if (NULL != temp_id) {
-                                       /* Get voice count */
-                                       if (DBUS_TYPE_INT32 == dbus_message_iter_get_arg_type(&args)) {
-                                               dbus_message_iter_get_basic(&args, &size);
-                                               dbus_message_iter_next(&args);
-                                       }
-                                       
-                                       int i=0;
-                                       for (i=0 ; i<size ; i++) {
-                                               dbus_message_iter_get_basic(&args, &(temp_lang) );
-                                               dbus_message_iter_next(&args);
-
-                                               dbus_message_iter_get_basic(&args, &(temp_type) );
-                                               dbus_message_iter_next(&args);
-                               
-                                               if (true != callback(temp_id, temp_lang, temp_type, user_data)) {
-                                                       break;
-                                               }
-                                       }
-                               } else {
-                                       SLOG(LOG_ERROR, TAG_TTSC, "Engine ID is NULL \n");
-                                       result = TTS_SETTING_ERROR_OPERATION_FAILED;
-                               }
-
-                       } else {
-                               SLOG(LOG_ERROR, TAG_TTSC, "<<<< setting get voice list : result = %d \n", result);
-                       }
-               } 
-
-               dbus_message_unref(result_msg);
-       } else {
-               SLOG(LOG_ERROR, TAG_TTSC, "<<<< setting get voice list : Result message is NULL!!");
-       }
-
-       dbus_message_unref(msg);
-
-       return result;
-}
-
-int tts_setting_dbus_request_get_default_voice(char** language, tts_setting_voice_type_e* voice_type)
-{
-       if (NULL == language || NULL == voice_type) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Input Parameter is NULL");
-               return TTS_SETTING_ERROR_INVALID_PARAMETER;
-       }
-
-       DBusMessage* msg;
-
-       msg = dbus_message_new_method_call(
-               TTS_SERVER_SERVICE_NAME, 
-               TTS_SERVER_SERVICE_OBJECT_PATH, 
-               TTS_SERVER_SERVICE_INTERFACE, 
-               TTS_SETTING_METHOD_GET_DEFAULT_VOICE);
-
-       if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request setting get default voice : Fail to make message \n"); 
-               return TTS_SETTING_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request setting get default voice");
-       }
-
-       int pid = getpid();
-
-       dbus_message_append_args( msg, 
-               DBUS_TYPE_INT32, &pid,
-               DBUS_TYPE_INVALID);
-
-       DBusError err;
-       dbus_error_init(&err);
-
-       DBusMessage* result_msg;
-       int result = TTS_SETTING_ERROR_OPERATION_FAILED;
-       char* temp_char;
-       int temp_int;
-
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 3000, &err);
-
-       if (NULL != result_msg) {
-               dbus_message_get_args(result_msg, &err, 
-                       DBUS_TYPE_INT32, &result, 
-                       DBUS_TYPE_STRING, &temp_char,
-                       DBUS_TYPE_INT32, &temp_int,
-                       DBUS_TYPE_INVALID);
-
-               if (dbus_error_is_set(&err)) { 
-                       SLOG(LOG_ERROR, TAG_TTSC, "Get arguments error (%s)\n", err.message);
-                       dbus_error_free(&err); 
-                       result = TTS_SETTING_ERROR_OPERATION_FAILED;
-               }
-
-               dbus_message_unref(result_msg);
-       }
-
-       if (0 == result) {
-               *language = strdup(temp_char);
-               *voice_type = (tts_setting_voice_type_e)temp_int;
-
-               if (NULL == *language) {
-                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< setting get default voice : Out of memory \n");
-                       result = TTS_SETTING_ERROR_OUT_OF_MEMORY;
-               } else {
-                       SLOG(LOG_DEBUG, TAG_TTSC, "<<<< setting get default voice : result(%d), lang(%s), vctype(%d) \n", result, *language, *voice_type);
-               }
-       } else {
-               SLOG(LOG_ERROR, TAG_TTSC, "<<<< setting get default voice : result(%d) \n", result);
-       }
-
-       dbus_message_unref(msg);
-
-       return result;
-}
-
-int tts_setting_dbus_request_set_default_voice(const char* language, const int voicetype )
-{
-       if (NULL == language) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Input Parameter is NULL");
-               return TTS_SETTING_ERROR_INVALID_PARAMETER;
-       }
-
-       DBusMessage* msg;
-
-       msg = dbus_message_new_method_call(
-               TTS_SERVER_SERVICE_NAME, 
-               TTS_SERVER_SERVICE_OBJECT_PATH, 
-               TTS_SERVER_SERVICE_INTERFACE, 
-               TTS_SETTING_METHOD_SET_DEFAULT_VOICE);
-
-       if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request setting set default voice : Fail to make message \n"); 
-               return TTS_SETTING_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request setting set default voice : language(%s), type(%d)", language, voicetype);
-       }
-
-       int pid = getpid();
-
-       dbus_message_append_args( msg, 
-               DBUS_TYPE_INT32, &pid,
-               DBUS_TYPE_STRING, &language,
-               DBUS_TYPE_INT32, &voicetype,
-               DBUS_TYPE_INVALID);
-
-       DBusError err;
-       dbus_error_init(&err);
-
-       DBusMessage* result_msg;
-       int result = TTS_SETTING_ERROR_OPERATION_FAILED;
-
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 3000, &err);
-
-       if (NULL != result_msg) {
-               dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
-
-               if (dbus_error_is_set(&err)) { 
-                       SLOG(LOG_ERROR, TAG_TTSC, "Get arguments error (%s)\n", err.message);
-                       dbus_error_free(&err); 
-                       result = TTS_SETTING_ERROR_OPERATION_FAILED;
-               }
-               dbus_message_unref(result_msg);
-       }
-
-       if (0 == result) {
-               SLOG(LOG_DEBUG, TAG_TTSC, "<<<< setting set default voice : result(%d)", result);
-       } else {
-               SLOG(LOG_ERROR, TAG_TTSC, "<<<< setting set default voice : result(%d)", result);
-       }
-
-       dbus_message_unref(msg);
-
-       return result;
-}
-
-int tts_setting_dbus_request_get_default_speed(int* speed)
-{
-       if (NULL == speed) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Input Parameter is NULL");
-               return TTS_SETTING_ERROR_INVALID_PARAMETER;
-       }
-
-       DBusMessage* msg;
-
-       msg = dbus_message_new_method_call(
-               TTS_SERVER_SERVICE_NAME, 
-               TTS_SERVER_SERVICE_OBJECT_PATH, 
-               TTS_SERVER_SERVICE_INTERFACE, 
-               TTS_SETTING_METHOD_GET_DEFAULT_SPEED);
-
-       if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request setting get default speed : Fail to make message \n"); 
-               return TTS_SETTING_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request setting get default speed ");
-       }
-
-       int pid = getpid();
-
-       dbus_message_append_args( msg, 
-               DBUS_TYPE_INT32, &pid,
-               DBUS_TYPE_INVALID);
-
-       DBusError err;
-       dbus_error_init(&err);
-
-       DBusMessage* result_msg;
-       int temp_int;
-       int result = TTS_SETTING_ERROR_OPERATION_FAILED;
-
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 3000, &err);
-
-       if (NULL != result_msg) {
-               dbus_message_get_args(result_msg, &err,
-                       DBUS_TYPE_INT32, &result,
-                       DBUS_TYPE_INT32, &temp_int,
-                       DBUS_TYPE_INVALID);
-
-               if (dbus_error_is_set(&err)) { 
-                       SLOG(LOG_ERROR, TAG_TTSC, "Get arguments error (%s)\n", err.message);
-                       dbus_error_free(&err); 
-                       result = TTS_SETTING_ERROR_OPERATION_FAILED;
-               }
-               dbus_message_unref(result_msg);
-       }
-
-       if (0 == result) {
-               *speed = temp_int;
-               SLOG(LOG_DEBUG, TAG_TTSC, "<<<< setting get default speed : result(%d), speed(%d)", result, *speed);
-       } else {
-               SLOG(LOG_ERROR, TAG_TTSC, "<<<< setting get default speed : result(%d)", result);
-       }
-
-       dbus_message_unref(msg);
-
-       return result;
-}
-
-int tts_setting_dbus_request_set_default_speed(const int speed)
-{
-       DBusMessage* msg;
-
-       msg = dbus_message_new_method_call(
-               TTS_SERVER_SERVICE_NAME, 
-               TTS_SERVER_SERVICE_OBJECT_PATH, 
-               TTS_SERVER_SERVICE_INTERFACE, 
-               TTS_SETTING_METHOD_SET_DEFAULT_SPEED);
-
-       if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request setting set default speed : Fail to make message \n"); 
-               return TTS_SETTING_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request setting set default speed : speed(%d)", speed);
-       }
-
-       int pid = getpid();
-
-       dbus_message_append_args(msg, 
-               DBUS_TYPE_INT32, &pid,
-               DBUS_TYPE_INT32, &speed,
-               DBUS_TYPE_INVALID);
-
-       DBusError err;
-       dbus_error_init(&err);
-
-       DBusMessage* result_msg;
-       int result = TTS_SETTING_ERROR_OPERATION_FAILED;
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 3000, &err);
-
-       if (NULL != result_msg) {
-               dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
-
-               if (dbus_error_is_set(&err)) { 
-                       SLOG(LOG_ERROR, TAG_TTSC, "Get arguments error (%s)\n", err.message);
-                       dbus_error_free(&err); 
-                       result = TTS_SETTING_ERROR_OPERATION_FAILED;
-               }
-               dbus_message_unref(result_msg);
-       }
-
-       if (0 == result) {
-               SLOG(LOG_DEBUG, TAG_TTSC, "<<<< setting set default speed : result(%d)", result);
-       } else {
-               SLOG(LOG_ERROR, TAG_TTSC, "<<<< setting set default speed : result(%d)", result);
-       }
-
-       dbus_message_unref(msg);
-
-       return result;
-}
-
-int tts_setting_dbus_request_get_engine_setting(tts_setting_engine_setting_cb callback, void* user_data)
-{
-       if (NULL == callback) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Input Parameter is NULL");
-               return TTS_SETTING_ERROR_INVALID_PARAMETER;
-       }
-
-       DBusMessage* msg;
-
-       msg = dbus_message_new_method_call(
-                  TTS_SERVER_SERVICE_NAME, 
-                  TTS_SERVER_SERVICE_OBJECT_PATH, 
-                  TTS_SERVER_SERVICE_INTERFACE, 
-                  TTS_SETTING_METHOD_GET_ENGINE_SETTING);
-
-       if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request setting get engine setting : Fail to make message \n"); 
-               return TTS_SETTING_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request setting get engine setting");
-       }
-
-       int pid = getpid();
-
-       dbus_message_append_args( msg, 
-               DBUS_TYPE_INT32, &pid,
-               DBUS_TYPE_INVALID);
-
-       DBusError err;
-       dbus_error_init(&err);
-
-       DBusMessage* result_msg;
-       int result = TTS_SETTING_ERROR_OPERATION_FAILED;
-
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 3000, &err);
-
-       if (NULL != result_msg) {
-               DBusMessageIter args;
-
-               if (dbus_message_iter_init(result_msg, &args)) {
-                       /* Get result */
-                       if (DBUS_TYPE_INT32 == dbus_message_iter_get_arg_type(&args)) {
-                               dbus_message_iter_get_basic(&args, &result);
-                               dbus_message_iter_next(&args);
-                       } 
-
-                       if (0 == result) {
-                               SLOG(LOG_DEBUG, TAG_TTSC, "<<<< get engine setting : result = %d \n", result);
-                               int size; 
-                               char* temp_id = NULL;
-                               char* temp_key;
-                               char* temp_value;
-                               
-                               /* Get engine id */
-                               dbus_message_iter_get_basic(&args, &temp_id);
-                               dbus_message_iter_next(&args);
-               
-                               if (NULL != temp_id) {
-                                       /* Get setting count */
-                                       if (DBUS_TYPE_INT32 == dbus_message_iter_get_arg_type(&args)) {
-                                               dbus_message_iter_get_basic(&args, &size);
-                                               dbus_message_iter_next(&args);
-                                       }
-
-                                       int i=0;
-                                       for (i=0 ; i<size ; i++) {
-                                               dbus_message_iter_get_basic(&args, &(temp_key) );
-                                               dbus_message_iter_next(&args);
-
-                                               dbus_message_iter_get_basic(&args, &(temp_value) );
-                                               dbus_message_iter_next(&args);
-
-                                               if (true != callback(temp_id, temp_key, temp_value, user_data)) {
-                                                       break;
-                                               }
-                                       } 
-                               } else {
-                                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< get engine setting : result message is invalid \n");
-                                       result = TTS_SETTING_ERROR_OPERATION_FAILED;
-                               }
-                       } 
-               } else {
-                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< get engine setting : result message is invalid \n");
-                       result = TTS_SETTING_ERROR_OPERATION_FAILED;
-               }
-
-               dbus_message_unref(result_msg);
-       } else {
-               SLOG(LOG_ERROR, TAG_TTSC, "<<<< get engine setting : Result message is NULL!! \n");
-       }       
-
-       dbus_message_unref(msg);
-
-       return result;
-}
-
-int tts_setting_dbus_request_set_engine_setting(const char* key, const char* value)
-{
-       if (NULL == key || NULL == value) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Input Parameter is NULL");
-               return TTS_SETTING_ERROR_INVALID_PARAMETER;
-       }
-
-       DBusMessage* msg;
-
-       msg = dbus_message_new_method_call(
-               TTS_SERVER_SERVICE_NAME, 
-               TTS_SERVER_SERVICE_OBJECT_PATH, 
-               TTS_SERVER_SERVICE_INTERFACE, 
-               TTS_SETTING_METHOD_SET_ENGINE_SETTING);
-
-       if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request setting set engine setting : Fail to make message \n"); 
-               return TTS_SETTING_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request setting set engine setting : key(%s), value(%s)", key, value);
-       }
-
-       int pid = getpid();
-
-       dbus_message_append_args( msg, 
-               DBUS_TYPE_INT32, &pid,
-               DBUS_TYPE_STRING, &key,
-               DBUS_TYPE_STRING, &value, 
-               DBUS_TYPE_INVALID);
-
-       DBusError err;
-       dbus_error_init(&err);
-
-       DBusMessage* result_msg;
-       int result = TTS_SETTING_ERROR_OPERATION_FAILED;
-
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 3000, &err);
-
-       if (NULL != result_msg) {
-               dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
-
-               if (dbus_error_is_set(&err)) { 
-                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< Get arguments error (%s)\n", err.message);
-                       dbus_error_free(&err); 
-                       result = -1;
-               }
-               dbus_message_unref(result_msg);
-       }
-
-       if (0 == result) {
-               SLOG(LOG_DEBUG, TAG_TTSC, "<<<< setting set engine setting : result(%d)", result);
-       } else {
-               SLOG(LOG_ERROR, TAG_TTSC, "<<<< setting set engine setting : result(%d)", result);
-       }
-
-       dbus_message_unref(msg);
-
-       return result;
-}
-
diff --git a/client/tts_setting_dbus.h b/client/tts_setting_dbus.h
deleted file mode 100644 (file)
index cc7185b..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
-*  Copyright (c) 2012, 2013 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 __TTS_SETTING_DBUS_H_
-#define __TTS_SETTING_DBUS_H_
-
-#include "tts_setting.h"
-
-#ifdef __cplusplus
-extern "C" 
-{
-#endif
-
-int tts_setting_dbus_open_connection();
-
-int tts_setting_dbus_close_connection();
-
-int tts_setting_dbus_request_hello();
-
-int tts_setting_dbus_request_initialize();
-
-int tts_setting_dbus_request_finalilze();
-
-int tts_setting_dbus_request_get_engine_list(tts_setting_supported_engine_cb callback, void* user_data);
-
-int tts_setting_dbus_request_get_engine(char** engine_id);
-
-int tts_setting_dbus_request_set_engine(const char* engine_id );
-
-int tts_setting_dbus_request_get_voice_list(tts_setting_supported_voice_cb callback, void* user_data);
-
-int tts_setting_dbus_request_get_default_voice(char** language, tts_setting_voice_type_e* voice_type);
-
-int tts_setting_dbus_request_set_default_voice(const char* language, const int voicetype );
-
-int tts_setting_dbus_request_get_default_speed(int* speed);
-
-int tts_setting_dbus_request_set_default_speed(int speed);
-
-int tts_setting_dbus_request_get_engine_setting(tts_setting_engine_setting_cb callback, void* user_data);
-
-int tts_setting_dbus_request_set_engine_setting(const char* key, const char* value);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __TTS_SETTING_DBUS_H_ */
diff --git a/common/tts_config_mgr.c b/common/tts_config_mgr.c
new file mode 100644 (file)
index 0000000..be4ce0b
--- /dev/null
@@ -0,0 +1,1898 @@
+/*
+*  Copyright (c) 2011-2014 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 <dirent.h>
+#include <dlfcn.h>
+#include <dlog.h>
+#include <Ecore.h>
+#include <fcntl.h>
+#include <glib.h>
+#include <unistd.h>
+#include <sys/inotify.h>
+#include <vconf.h>
+
+#include "tts_config_mgr.h"
+#include "tts_config_parser.h"
+#include "tts_defs.h"
+
+typedef struct {
+       int     uid;
+       tts_config_engine_changed_cb            engine_cb;
+       tts_config_voice_changed_cb             voice_cb;
+       tts_config_speech_rate_changed_cb       speech_cb;
+       tts_config_screen_reader_changed_cb     screen_cb;
+       tts_config_pitch_changed_cb             pitch_cb;
+       void*   user_data;
+}tts_config_client_s;
+
+extern char* tts_tag();
+
+static GSList* g_engine_list = NULL;
+
+static GSList* g_config_client_list = NULL;
+
+static tts_config_s* g_config_info;
+
+static Ecore_Fd_Handler* g_config_fd_handler_noti = NULL;
+static int g_config_fd_noti;
+static int g_config_wd_noti;
+
+/* For engine directory monitoring */
+static Ecore_Fd_Handler* g_dir_fd_handler = NULL;
+static int g_dir_fd;
+static int g_dir_wd;
+
+int __tts_config_mgr_print_engine_info();
+
+int __tts_config_mgr_check_engine_is_valid(const char* engine_id)
+{
+       if (NULL == engine_id) {
+               SLOG(LOG_ERROR, tts_tag(), "Input parameter is NULL");
+               return -1;
+       }
+
+       GSList *iter = NULL;
+       tts_engine_info_s *engine_info = NULL;
+
+       if (0 >= g_slist_length(g_engine_list)) {
+               SLOG(LOG_ERROR, tts_tag(), "There is no engine!!");
+               return -1;
+       }
+
+       /* Get a first item */
+       iter = g_slist_nth(g_engine_list, 0);
+
+       while (NULL != iter) {
+               engine_info = iter->data;
+
+               if (NULL == engine_info) {
+                       SLOG(LOG_ERROR, tts_tag(), "engine info is NULL");
+                       return -1;
+               }
+
+               if (0 == strcmp(engine_id, engine_info->uuid)) {
+                       SLOG(LOG_DEBUG, tts_tag(), "Default engine is valid : %s", engine_id);
+                       return 0;
+               }
+
+               iter = g_slist_next(iter);
+       }
+
+       /* Change default engine */
+       iter = g_slist_nth(g_engine_list, 0);
+       engine_info = iter->data;
+       
+       if (NULL != g_config_info->engine_id)   free(g_config_info->engine_id);
+       if (NULL != g_config_info->setting)     free(g_config_info->setting);
+
+       g_config_info->engine_id = strdup(engine_info->uuid);
+       g_config_info->setting = strdup(engine_info->setting);
+
+       SLOG(LOG_DEBUG, tts_tag(), "Default engine is changed : %s", g_config_info->engine_id);
+
+       /* Change is default voice */
+       GSList *iter_voice = NULL;
+       tts_config_voice_s* voice = NULL;
+       bool is_valid_voice = false;
+
+       /* Get a first item */
+       iter_voice = g_slist_nth(engine_info->voices, 0);
+
+       while (NULL != iter_voice) {
+               /*Get handle data from list*/
+               voice = iter_voice->data;
+               
+               if (NULL != voice && NULL != g_config_info) {
+                       if (NULL != voice->language && NULL != g_config_info->language) {
+                               if (0 == strcmp(voice->language, g_config_info->language)) {
+                                       if (voice->type == g_config_info->type) {
+                                               /* language is valid */
+                                               is_valid_voice = true;
+
+                                               free(g_config_info->language);
+                                               g_config_info->language = strdup(voice->language);
+                                               g_config_info->type = voice->type;
+
+                                               SLOG(LOG_DEBUG, tts_tag(), "Default voice is changed : lang(%s) type(%d)", voice->language, voice->type);
+                                       }
+                                       break;
+                               }
+                       }
+               }
+
+               iter_voice = g_slist_next(iter_voice);
+       }
+
+       if (false == is_valid_voice) {
+               /* Select first voice as default */
+               if (NULL != g_config_info->language) {
+                       free(g_config_info->language);
+
+                       iter_voice = g_slist_nth(engine_info->voices, 0);
+                       voice = iter_voice->data;
+
+                       g_config_info->language = strdup(voice->language);
+                       g_config_info->type = voice->type;
+                       SLOG(LOG_DEBUG, tts_tag(), "Default voice is changed : lang(%s) type(%d)", voice->language, voice->type);
+               }
+       }
+
+       if ( 0 != tts_parser_set_engine(g_config_info->engine_id, g_config_info->setting, 
+               g_config_info->language, g_config_info->type)) {
+               SLOG(LOG_ERROR, tts_tag(), " Fail to save config");
+               return TTS_CONFIG_ERROR_OPERATION_FAILED;
+       }
+
+       return 0;
+}
+
+bool __tts_config_mgr_check_lang_is_valid(const char* engine_id, const char* language, int type)
+{
+       if (NULL == engine_id || NULL == language) {
+               SLOG(LOG_ERROR, tts_tag(), "Input parameter is NULL");
+               return false;
+       }
+
+       GSList *iter = NULL;
+       tts_engine_info_s *engine_info = NULL;
+
+       if (0 >= g_slist_length(g_engine_list)) {
+               SLOG(LOG_ERROR, tts_tag(), "There is no engine!!");
+               return false;
+       }
+
+       /* Get a first item */
+       iter = g_slist_nth(g_engine_list, 0);
+
+       while (NULL != iter) {
+               engine_info = iter->data;
+
+               if (NULL == engine_info) {
+                       SLOG(LOG_ERROR, tts_tag(), "engine info is NULL");
+                       return false;
+               }
+
+               if (0 != strcmp(engine_id, engine_info->uuid)) {
+                       iter = g_slist_next(iter);
+                       continue;
+               }
+
+               GSList *iter_voice = NULL;
+               tts_config_voice_s* voice = NULL;
+
+               if (g_slist_length(engine_info->voices) <= 0) {
+                       SLOG(LOG_ERROR, tts_tag(), "There is no voice : %s", engine_info->uuid);
+                       iter = g_slist_next(iter);
+                       return false;
+               }
+               
+               /* Get a first item */
+               iter_voice = g_slist_nth(engine_info->voices, 0);
+
+               int i = 1;
+               while (NULL != iter_voice) {
+                       /*Get handle data from list*/
+                       voice = iter_voice->data;
+
+                       if (NULL != voice) {
+                               if (0 == strcmp(language, voice->language)) {
+                                       if (type == voice->type) {
+                                               return true;
+                                       }
+                               }
+                       }
+                       
+                       /*Get next item*/
+                       iter_voice = g_slist_next(iter_voice);
+                       i++;
+               }
+
+               return false;
+       }
+
+       return false;
+}
+
+int __tts_config_mgr_select_lang(const char* engine_id, char** language, int* type)
+{
+       if (NULL == engine_id || NULL == language) {
+               SLOG(LOG_ERROR, tts_tag(), "Input parameter is NULL");
+               return false;
+       }
+
+       GSList *iter = NULL;
+       tts_engine_info_s *engine_info = NULL;
+
+       if (0 >= g_slist_length(g_engine_list)) {
+               SLOG(LOG_ERROR, tts_tag(), "There is no engine!!");
+               return false;
+       }
+       
+       /* Get a first item */
+       iter = g_slist_nth(g_engine_list, 0);
+
+       while (NULL != iter) {
+               engine_info = iter->data;
+
+               if (NULL == engine_info) {
+                       SLOG(LOG_ERROR, tts_tag(), "engine info is NULL");
+                       return false;
+               }
+               
+               if (0 != strcmp(engine_id, engine_info->uuid)) {
+                       iter = g_slist_next(iter);
+                       continue;
+               }
+
+               GSList *iter_voice = NULL;
+               tts_config_voice_s* voice = NULL;
+
+               if (g_slist_length(engine_info->voices) <= 0) {
+                       SLOG(LOG_ERROR, tts_tag(), "There is no voice : %s", engine_info->uuid);
+                       return -1;
+               }
+
+               /* Get a first item */
+               iter_voice = g_slist_nth(engine_info->voices, 0);
+
+               while (NULL != iter_voice) {
+                       voice = iter_voice->data;
+                       if (NULL != voice) {
+                               /* Default language */
+                               if (0 == strcmp(TTS_BASE_LANGUAGE, voice->language)) {
+                                       *language = strdup(voice->language);
+                                       *type = voice->type;
+
+                                       SECURE_SLOG(LOG_DEBUG, tts_tag(), "Selected language(%s) type(%d)", *language, *type);
+                                       return 0;
+                               }
+                       }
+                       iter_voice = g_slist_next(iter_voice);
+               }
+
+               /* Not support base language */
+               if (NULL != voice) {
+                       *language = strdup(voice->language);
+                       *type = voice->type;
+
+                       SECURE_SLOG(LOG_DEBUG, tts_tag(), "Selected language(%s) type(%d)", *language, *type);
+                       return 0;
+               }
+               break;
+       }
+
+       return -1;
+}
+
+Eina_Bool tts_config_mgr_inotify_event_cb(void* data, Ecore_Fd_Handler *fd_handler)
+{
+       SLOG(LOG_DEBUG, tts_tag(), "===== Config changed callback event");
+
+       int length;
+       struct inotify_event event;
+       memset(&event, '\0', sizeof(struct inotify_event));
+
+       length = read(g_config_fd_noti, &event, sizeof(struct inotify_event));
+       if (0 > length) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Empty Inotify event");
+               SLOG(LOG_DEBUG, tts_tag(), "=====");
+               SLOG(LOG_DEBUG, tts_tag(), " ");
+               return ECORE_CALLBACK_DONE;
+       }
+
+       if (IN_CLOSE_WRITE == event.mask) {
+               /* check config changed state */
+               char* engine = NULL;
+               char* setting = NULL;
+               char* lang = NULL;
+               bool auto_voice = g_config_info->auto_voice;
+               int voice_type = -1;
+               int speech_rate = -1;
+               int pitch = -1;
+
+               GSList *iter = NULL;
+               tts_config_client_s* temp_client = NULL;
+
+               if (0 != tts_parser_find_config_changed(&engine, &setting, &auto_voice, &lang, &voice_type, &speech_rate, &pitch))
+                       return ECORE_CALLBACK_PASS_ON;
+
+               /* engine changed */
+               if (NULL != engine || NULL != setting) {
+                       if (NULL != engine) {
+                               if (NULL != g_config_info->engine_id)
+                                       free(g_config_info->engine_id);
+
+                               g_config_info->engine_id = strdup(engine);
+                       }
+                       if (NULL != setting) {
+                               if (NULL != g_config_info->setting)
+                                       free(g_config_info->setting);
+
+                               g_config_info->setting = strdup(setting);
+                       }
+
+                       SECURE_SLOG(LOG_DEBUG, tts_tag(), "Engine change(%s)", g_config_info->engine_id);
+
+                       /* Call all callbacks of client*/
+                       iter = g_slist_nth(g_config_client_list, 0);
+
+                       while (NULL != iter) {
+                               temp_client = iter->data;
+
+                               if (NULL != temp_client) {
+                                       if (NULL != temp_client->engine_cb) {
+                                               SECURE_SLOG(LOG_DEBUG, tts_tag(), "Engine changed callback : uid(%d)", temp_client->uid);
+                                               temp_client->engine_cb(g_config_info->engine_id, g_config_info->setting, 
+                                                       g_config_info->language, g_config_info->type, 
+                                                       g_config_info->auto_voice, temp_client->user_data);
+                                       }
+                               }
+
+                               iter = g_slist_next(iter);
+                       }
+               }
+
+               if (auto_voice != g_config_info->auto_voice) {
+                       g_config_info->auto_voice = auto_voice;
+               }
+
+               if (NULL != lang || -1 != voice_type) {
+                       char* before_lang = NULL;
+                       int before_type;
+
+                       before_lang = strdup(g_config_info->language);
+                       before_type = g_config_info->type;
+
+                       if (NULL != lang) {
+                               if (NULL != g_config_info->language)
+                                       free(g_config_info->language);
+
+                               g_config_info->language = strdup(lang);
+                       }
+                       if (-1 != voice_type) {
+                               g_config_info->type = voice_type;
+                       }
+
+                       SECURE_SLOG(LOG_DEBUG, tts_tag(), "Voice change(%s, %d)", g_config_info->language, g_config_info->type);
+
+                       /* Call all callbacks of client*/
+                       iter = g_slist_nth(g_config_client_list, 0);
+
+                       while (NULL != iter) {
+                               temp_client = iter->data;
+
+                               if (NULL != temp_client) {
+                                       if (NULL != temp_client->voice_cb) {
+                                               SECURE_SLOG(LOG_DEBUG, tts_tag(), "Voice changed callback : uid(%d)", temp_client->uid);
+                                               temp_client->voice_cb(before_lang, before_type, 
+                                                       g_config_info->language, g_config_info->type, 
+                                                       g_config_info->auto_voice, temp_client->user_data);
+                                       }
+                               }
+
+                               iter = g_slist_next(iter);
+                       }
+                       
+                       if (NULL != before_lang) {
+                               free(before_lang);
+                       }
+               }
+
+               if (-1 != speech_rate) {
+                       g_config_info->speech_rate = speech_rate;
+
+                       SECURE_SLOG(LOG_DEBUG, tts_tag(), "Speech rate change(%d)", g_config_info->speech_rate);
+
+                       /* Call all callbacks of client*/
+                       iter = g_slist_nth(g_config_client_list, 0);
+
+                       while (NULL != iter) {
+                               temp_client = iter->data;
+
+                               if (NULL != temp_client) {
+                                       if (NULL != temp_client->speech_cb) {
+                                               SECURE_SLOG(LOG_DEBUG, tts_tag(), "Speech rate changed callback : uid(%d)", temp_client->uid);
+                                               temp_client->speech_cb(g_config_info->speech_rate, temp_client->user_data);
+                                       }
+                               }
+
+                               iter = g_slist_next(iter);
+                       }
+               }
+
+               if (-1 != pitch) {
+                       g_config_info->pitch = pitch;
+
+                       SECURE_SLOG(LOG_DEBUG, tts_tag(), "pitch change(%d)", g_config_info->pitch);
+
+                       /* Call all callbacks of client*/
+                       iter = g_slist_nth(g_config_client_list, 0);
+
+                       while (NULL != iter) {
+                               temp_client = iter->data;
+
+                               if (NULL != temp_client) {
+                                       if (NULL != temp_client->pitch_cb) {
+                                               SECURE_SLOG(LOG_DEBUG, tts_tag(), "Pitch changed callback : uid(%d)", temp_client->uid);
+                                               temp_client->pitch_cb(g_config_info->pitch, temp_client->user_data);
+                                       }
+                               }
+
+                               iter = g_slist_next(iter);
+                       }
+               }
+
+               if (NULL != engine)     free(engine);
+               if (NULL != setting)    free(setting);
+               if (NULL != lang)       free(lang);
+       } else {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Undefined event");
+       }
+
+       SLOG(LOG_DEBUG, tts_tag(), "=====");
+       SLOG(LOG_DEBUG, tts_tag(), " ");
+
+       return ECORE_CALLBACK_PASS_ON;
+}
+
+int __tts_config_mgr_register_config_event()
+{
+       /* get file notification handler */
+       int fd;
+       int wd;
+
+       fd = inotify_init();
+       if (fd < 0) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail get inotify fd");
+               return -1;
+       }
+       g_config_fd_noti = fd;
+
+       wd = inotify_add_watch(fd, TTS_CONFIG, IN_CLOSE_WRITE);
+       g_config_wd_noti = wd;
+
+       g_config_fd_handler_noti = ecore_main_fd_handler_add(fd, ECORE_FD_READ, 
+               (Ecore_Fd_Cb)tts_config_mgr_inotify_event_cb, NULL, NULL, NULL);                
+       if (NULL == g_config_fd_handler_noti) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to get handler_noti");
+               return -1;
+       }
+
+       /* Set non-blocking mode of file */
+       int value;
+       value = fcntl(fd, F_GETFL, 0);
+       value |= O_NONBLOCK;
+       
+       if (0 > fcntl(fd, F_SETFL, value)) {
+               SLOG(LOG_WARN, tts_tag(), "[WARNING] Fail to set non-block mode");
+       }
+
+       return 0;
+}
+
+int __tts_config_mgr_unregister_config_event()
+{
+       /* delete inotify variable */
+       ecore_main_fd_handler_del(g_config_fd_handler_noti);
+       inotify_rm_watch(g_config_fd_noti, g_config_wd_noti);
+       close(g_config_fd_noti);
+
+       return 0;
+}
+
+void __tts_config_speech_rate_key_changed_cb(keynode_t *key, void *data)
+{
+       int ret;
+       int speech_rate;
+       ret = vconf_get_int(TTS_ACCESSIBILITY_SPEED_KEY, &speech_rate);
+
+       if (0 != ret) {
+               SLOG(LOG_ERROR, tts_tag(), "[Config ERROR] Fail to get speech rate");
+               return;
+       }
+       
+       /* Check speech rate is valid */
+       if (TTS_CONFIG_SPEED_MIN <= speech_rate && speech_rate <= TTS_CONFIG_SPEED_MAX) {
+               SLOG(LOG_DEBUG, tts_tag(), "[Config] Speech rate  : %d", speech_rate);
+               
+               if (g_config_info->speech_rate != speech_rate) {
+                       g_config_info->speech_rate = speech_rate;
+
+                       tts_parser_set_speech_rate(g_config_info->speech_rate);
+
+                       GSList *iter = NULL;
+                       tts_config_client_s* temp_client = NULL;
+
+                       /* Call all callbacks of client*/
+                       iter = g_slist_nth(g_config_client_list, 0);
+
+                       while (NULL != iter) {
+                               temp_client = iter->data;
+
+                               if (NULL != temp_client) {
+                                       if (NULL != temp_client->speech_cb) {
+                                               temp_client->speech_cb(g_config_info->speech_rate, temp_client->user_data);
+                                       }
+                               }
+
+                               iter = g_slist_next(iter);
+                       }
+               }
+       } else {
+               SLOG(LOG_ERROR, tts_tag(), "[Config ERROR] Speech rate is not valid : %d", speech_rate);
+       }
+
+       return;
+}
+
+int __tts_config_set_auto_language()
+{
+       char* value = NULL;
+       value = vconf_get_str(TTS_LANGSET_KEY);
+       if (NULL == value) {
+               SLOG(LOG_ERROR, tts_tag(), "[Config ERROR] Fail to get display language");
+               return -1;
+       }
+
+       char temp_lang[6] = {'\0', };
+       strncpy(temp_lang, value, 5);
+       free(value);
+
+       if (true == __tts_config_mgr_check_lang_is_valid(g_config_info->engine_id, temp_lang, g_config_info->type)) {
+               /* tts default voice change */
+               if (NULL == g_config_info->language) {
+                       SLOG(LOG_ERROR, tts_tag(), "Current config language is NULL");
+                       return -1;
+               }
+
+               char* before_lang = NULL;
+               int before_type;
+
+               if (0 != tts_parser_set_voice(temp_lang, g_config_info->type)) {
+                       SLOG(LOG_ERROR, tts_tag(), "Fail to save default voice");
+                       return -1;
+               }
+
+               before_lang = strdup(g_config_info->language);
+               before_type = g_config_info->type;
+
+               free(g_config_info->language);
+               g_config_info->language = strdup(temp_lang);
+
+               SECURE_SLOG(LOG_DEBUG, tts_tag(), "[Config] Default voice : lang(%s) type(%d)", 
+                       g_config_info->language, g_config_info->type);
+
+               GSList *iter = NULL;
+               tts_config_client_s* temp_client = NULL;
+
+               /* Call all callbacks of client*/
+               iter = g_slist_nth(g_config_client_list, 0);
+
+               while (NULL != iter) {
+                       temp_client = iter->data;
+
+                       if (NULL != temp_client) {
+                               if (NULL != temp_client->voice_cb) {
+                                       temp_client->voice_cb(before_lang, before_type, 
+                                               g_config_info->language, g_config_info->type, 
+                                               g_config_info->auto_voice, temp_client->user_data);
+                               }
+                       }
+
+                       iter = g_slist_next(iter);
+               }
+
+               if (NULL != before_lang) {
+                       free(before_lang);
+               }
+       } else {
+               /* Display language is not valid */
+               char* tmp_language = NULL;
+               int tmp_type = -1;
+               if (0 != __tts_config_mgr_select_lang(g_config_info->engine_id, &tmp_language, &tmp_type)) {
+                       SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to select language");
+                       return -1;
+               }
+
+               if (NULL == tmp_language) {
+                       SLOG(LOG_ERROR, tts_tag(), "[ERROR] language is NULL");
+                       return -1;
+               }
+
+               if (0 != tts_parser_set_voice(tmp_language, tmp_type)) {
+                       SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to save config");
+                       return -1;
+               }
+
+               SECURE_SLOG(LOG_DEBUG, tts_tag(), "[Config] Default voice : lang(%s) type(%d)", 
+                       tmp_language, tmp_type);
+
+               GSList *iter = NULL;
+               tts_config_client_s* temp_client = NULL;
+
+               /* Call all callbacks of client*/
+               iter = g_slist_nth(g_config_client_list, 0);
+
+               while (NULL != iter) {
+                       temp_client = iter->data;
+
+                       if (NULL != temp_client) {
+                               if (NULL != temp_client->voice_cb) {
+                                       temp_client->voice_cb(g_config_info->language, g_config_info->type, 
+                                               tmp_language, tmp_type, g_config_info->auto_voice, temp_client->user_data);
+                               }
+                       }
+
+                       iter = g_slist_next(iter);
+               }
+
+               if (NULL != g_config_info->language) {
+                       free(g_config_info->language);
+                       g_config_info->language = strdup(tmp_language);
+               }
+
+               g_config_info->type = tmp_type;
+
+               free(tmp_language);
+       }
+
+       return 0;
+}
+
+void __tts_config_display_language_changed_cb(keynode_t *key, void *data)
+{
+       if (true == g_config_info->auto_voice) {
+               __tts_config_set_auto_language();
+       }
+
+       return;
+}
+
+void __tts_config_screen_reader_changed_cb(keynode_t *key, void *data)
+{
+       int ret;
+       int screen_reader;
+       ret = vconf_get_int(TTS_ACCESSIBILITY_KEY, &screen_reader);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, tts_tag(), "[Config ERROR] Fail to get screen reader");
+               return;
+       }
+
+       GSList *iter = NULL;
+       tts_config_client_s* temp_client = NULL;
+
+       /* Call all callbacks of client*/
+       iter = g_slist_nth(g_config_client_list, 0);
+
+       while (NULL != iter) {
+               temp_client = iter->data;
+
+               if (NULL != temp_client) {
+                       if (NULL != temp_client->screen_cb) {
+                               temp_client->screen_cb((bool)screen_reader);
+                       }
+               }
+
+               iter = g_slist_next(iter);
+       }
+}
+
+int __tts_config_release_client(int uid)
+{
+       GSList *iter = NULL;
+       tts_config_client_s* temp_client = NULL;
+
+       if (0 < g_slist_length(g_config_client_list)) {
+               /* Check uid */
+               iter = g_slist_nth(g_config_client_list, 0);
+
+               while (NULL != iter) {
+                       temp_client = iter->data;
+
+                       if (NULL != temp_client) {
+                               if (uid == temp_client->uid) {
+                                       g_config_client_list = g_slist_remove(g_config_client_list, temp_client);
+                                       free(temp_client);
+                                       break;
+                               }
+                       }
+
+                       iter = g_slist_next(iter);
+               }
+       }
+
+       SLOG(LOG_DEBUG, tts_tag(), "Client count (%d)", g_slist_length(g_config_client_list));
+
+       return g_slist_length(g_config_client_list);
+}
+
+void __tts_config_release_engine()
+{
+       GSList *iter = NULL;
+       tts_engine_info_s *engine_info = NULL;
+
+       if (0 < g_slist_length(g_engine_list)) {
+
+               /* Get a first item */
+               iter = g_slist_nth(g_engine_list, 0);
+
+               while (NULL != iter) {
+                       engine_info = iter->data;
+
+                       if (NULL != engine_info) {
+                               g_engine_list = g_slist_remove(g_engine_list, engine_info);
+
+                               tts_parser_free_engine_info(engine_info);
+                       }
+
+                       iter = g_slist_nth(g_engine_list, 0);
+               }
+       }
+
+       return;
+}
+
+int __tts_config_mgr_get_engine_info()
+{
+       DIR *dp = NULL;
+       int ret = -1;
+       struct dirent entry;
+       struct dirent *dirp = NULL;
+
+       char filepath[512] = {'\0',};
+       int filesize;
+       tts_engine_info_s* info = NULL;
+
+       g_engine_list = NULL;
+
+       /* Get engine info from default engine directory */
+       dp  = opendir(TTS_DEFAULT_ENGINE_INFO);
+       if (NULL == dp) {
+               SLOG(LOG_DEBUG, tts_tag(), "[CONFIG] No downloadable directory : %s", TTS_DEFAULT_ENGINE_INFO);
+       } else {
+               do {
+                       ret = readdir_r(dp, &entry, &dirp);
+                       if (0 != ret) {
+                               SLOG(LOG_ERROR, tts_tag(), "[CONFIG] Fail to read directory");
+                               break;
+                       }
+
+                       if (NULL != dirp) {
+                               filesize = strlen(TTS_DEFAULT_ENGINE_INFO) + strlen(dirp->d_name) + 2;
+                               if (filesize >= 512) {
+                                       SECURE_SLOG(LOG_ERROR, tts_tag(), "[CONFIG ERROR] File path is too long : %s", dirp->d_name);
+                                       closedir(dp);
+                                       return -1;
+                               }
+                               
+                               memset(filepath, '\0', 512);
+                               snprintf(filepath, 512, "%s/%s", TTS_DEFAULT_ENGINE_INFO, dirp->d_name);
+
+                               SECURE_SLOG(LOG_DEBUG, tts_tag(), "[CONFIG] Filepath(%s)", filepath);
+
+                               if (0 == tts_parser_get_engine_info(filepath, &info)) {
+                                       g_engine_list = g_slist_append(g_engine_list, info);
+                               }
+                       }
+               } while (NULL != dirp);
+
+               closedir(dp);
+       }
+
+       /* Get engine info from downloadable engine directory */
+       dp  = opendir(TTS_DOWNLOAD_ENGINE_INFO);
+       if (NULL == dp) {
+               SLOG(LOG_DEBUG, tts_tag(), "[CONFIG] No downloadable directory : %s", TTS_DOWNLOAD_ENGINE_INFO);
+       } else {
+               do {
+                       ret = readdir_r(dp, &entry, &dirp);
+                       if (0 != ret) {
+                               SLOG(LOG_ERROR, tts_tag(), "[CONFIG] Fail to read directory");
+                               break;
+                       }
+
+                       if (NULL != dirp) {
+                               filesize = strlen(TTS_DOWNLOAD_ENGINE_INFO) + strlen(dirp->d_name) + 2;
+                               if (filesize >= 512) {
+                                       SECURE_SLOG(LOG_ERROR, tts_tag(), "[CONFIG ERROR] File path is too long : %s", dirp->d_name);
+                                       closedir(dp);
+                                       return -1;
+                               }
+                               
+                               memset(filepath, '\0', 512);
+                               snprintf(filepath, 512, "%s/%s", TTS_DOWNLOAD_ENGINE_INFO, dirp->d_name);
+
+                               SECURE_SLOG(LOG_DEBUG, tts_tag(), "[CONFIG] Filepath(%s)", filepath);
+
+                               if (0 == tts_parser_get_engine_info(filepath, &info)) {
+                                       /* Compare id */
+                                       GSList *iter = NULL;
+                                       tts_engine_info_s *engine_info = NULL;
+
+                                       /* Get a first item */
+                                       iter = g_slist_nth(g_engine_list, 0);
+
+                                       while (NULL != iter) {
+                                               engine_info = iter->data;
+
+                                               if (NULL != engine_info) {
+                                                       /* Remove old engine info */
+                                                       if (0 == strncmp(engine_info->uuid, info->uuid, strlen(engine_info->uuid))) {
+                                                               SLOG(LOG_DEBUG, tts_tag(), "[CONFIG] Remove old engine : %s", engine_info->name);
+                                                               g_engine_list = g_slist_remove(g_engine_list, engine_info);
+                                                               tts_parser_free_engine_info(engine_info);
+                                                               break;
+                                                       }
+                                               }
+                                               iter = iter->next;
+                                       }
+
+                                       g_engine_list = g_slist_append(g_engine_list, info);
+                               }
+                       }
+               } while (NULL != dirp);
+
+               closedir(dp);
+       }
+
+       if (0 >= g_slist_length(g_engine_list)) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] No engine");
+               return -1;
+       }
+
+       return 0;
+}
+
+static Eina_Bool __tts_config_mgr_engine_config_inotify_event_callback(void* data, Ecore_Fd_Handler *fd_handler)
+{
+       SLOG(LOG_DEBUG, tts_tag(), "===== Engine config updated callback event");
+
+       int length;
+       struct inotify_event event;
+       memset(&event, '\0', sizeof(struct inotify_event));
+
+       length = read(g_dir_fd, &event, sizeof(struct inotify_event));
+       if (0 > length) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Empty Inotify event");
+               SLOG(LOG_DEBUG, tts_tag(), "=====");
+               SLOG(LOG_DEBUG, tts_tag(), " ");
+               return ECORE_CALLBACK_DONE;
+       }
+
+       if (IN_CLOSE_WRITE == event.mask) {
+               int ret = __tts_config_mgr_get_engine_info();
+               if (0 != ret) {
+                       SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to get engine info when config updated");
+               }
+               __tts_config_mgr_print_engine_info();
+               bool support = tts_config_check_default_voice_is_valid(g_config_info->language, g_config_info->type);
+               if (false == support) {
+                       SLOG(LOG_DEBUG, tts_tag(), "[ERROR] Default voice is valid");
+                       char* temp_lang = NULL;
+                       int temp_type;
+                       ret = __tts_config_mgr_select_lang(g_config_info->engine_id, &temp_lang, &temp_type);
+                       if (0 != ret) {
+                               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to get voice");
+                       }
+                       
+                       ret = tts_config_mgr_set_voice(temp_lang, temp_type);
+                       if (0 != ret) {
+                               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to set voice");
+                       } else {
+                               SLOG(LOG_DEBUG, tts_tag(), "[DEBUG] Saved default voice : lang(%s), type(%d)", g_config_info->language, g_config_info->type);
+                       }
+                       if (NULL != temp_lang)  free(temp_lang);
+               }
+       } else {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Undefined event");
+       }
+
+       SLOG(LOG_DEBUG, tts_tag(), "=====");
+       SLOG(LOG_DEBUG, tts_tag(), " ");
+
+       return ECORE_CALLBACK_PASS_ON;
+}
+
+static int __tts_config_mgr_register_engine_config_updated_event()
+{
+       /* For engine directory monitoring */
+       g_dir_fd = inotify_init();
+       if (g_dir_fd < 0) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to init inotify");
+               return -1;
+       }
+
+       g_dir_wd = inotify_add_watch(g_dir_fd, TTS_OPT_BASE"/engine-info/", IN_CLOSE_WRITE);
+       if (g_dir_wd < 0) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to add watch");
+               return -1;
+       }
+
+       g_dir_fd_handler = ecore_main_fd_handler_add(g_dir_fd, ECORE_FD_READ, (Ecore_Fd_Cb)__tts_config_mgr_engine_config_inotify_event_callback, NULL, NULL, NULL);
+       if (NULL == g_dir_fd_handler) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to add fd handler");
+               return -1;
+       }
+
+       /* Set non-blocking mode of file */
+       int value;
+       value = fcntl(g_dir_fd, F_GETFL, 0);
+       value |= O_NONBLOCK;
+       
+       if (0 > fcntl(g_dir_fd, F_SETFL, value)) {
+               SLOG(LOG_WARN, tts_tag(), "[WARNING] Fail to set non-block mode");
+       }
+
+       return 0;
+}
+
+static int __tts_config_mgr_unregister_engine_config_updated_event()
+{
+       /* delete inotify variable */
+       ecore_main_fd_handler_del(g_dir_fd_handler);
+       inotify_rm_watch(g_dir_fd, g_dir_wd);
+       close(g_dir_fd);
+
+       return 0;
+}
+
+int tts_config_mgr_initialize(int uid)
+{
+       GSList *iter = NULL;
+       int* get_uid;
+       tts_config_client_s* temp_client = NULL;
+
+       /* Register uid */
+       if (0 < g_slist_length(g_config_client_list)) {
+               /* Check uid */
+               iter = g_slist_nth(g_config_client_list, 0);
+
+               while (NULL != iter) {
+                       get_uid = iter->data;
+
+                       if (uid == *get_uid) {
+                               SECURE_SLOG(LOG_WARN, tts_tag(), "[CONFIG] uid(%d) has already registered", uid);
+                               return 0;
+                       }
+
+                       iter = g_slist_next(iter);
+               }
+
+               temp_client = (tts_config_client_s*)calloc(1, sizeof(tts_config_client_s));
+               temp_client->uid = uid;
+
+               g_config_client_list = g_slist_append(g_config_client_list, temp_client);
+
+               SECURE_SLOG(LOG_WARN, tts_tag(), "[CONFIG] Add uid(%d) but config has already initialized", uid);
+               return 0;
+       } else {
+               temp_client = (tts_config_client_s*)calloc(1, sizeof(tts_config_client_s));
+               temp_client->uid = uid;
+
+               g_config_client_list = g_slist_append(g_config_client_list, temp_client);
+       }
+
+       if (0 != __tts_config_mgr_get_engine_info()) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to get engine info");
+               __tts_config_release_client(uid);
+               __tts_config_release_engine();
+               return TTS_CONFIG_ERROR_ENGINE_NOT_FOUND;
+       }
+
+       __tts_config_mgr_print_engine_info();
+
+       if (0 != tts_parser_load_config(&g_config_info)) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to parse configure information");
+               __tts_config_release_client(uid);
+               __tts_config_release_engine();
+               return TTS_CONFIG_ERROR_OPERATION_FAILED; 
+       }
+       
+       /* Check whether engine id is valid */
+       if (0 != __tts_config_mgr_check_engine_is_valid(g_config_info->engine_id)) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to get default engine");
+               __tts_config_release_client(uid);
+               __tts_config_release_engine();
+               tts_parser_unload_config(g_config_info);
+               return TTS_CONFIG_ERROR_ENGINE_NOT_FOUND;
+       }
+       
+       if (true == g_config_info->auto_voice) {
+               /* Check language with display language */
+               __tts_config_set_auto_language();
+       } else {
+               if (false == __tts_config_mgr_check_lang_is_valid(g_config_info->engine_id, g_config_info->language, g_config_info->type)) {
+                       /* Default language is not valid */
+                       char* tmp_language = NULL;
+                       int tmp_type = -1;
+                       if (0 != __tts_config_mgr_select_lang(g_config_info->engine_id, &tmp_language, &tmp_type)) {
+                               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to select language");
+                               __tts_config_release_client(uid);
+                               __tts_config_release_engine();
+                               tts_parser_unload_config(g_config_info);
+                               return TTS_CONFIG_ERROR_OPERATION_FAILED;
+                       }
+
+                       if (NULL != tmp_language) {
+                               if (NULL != g_config_info->language) {
+                                       free(g_config_info->language);
+                                       g_config_info->language = strdup(tmp_language);
+                               }
+
+                               g_config_info->type = tmp_type;
+
+                               free(tmp_language);
+
+                               if (0 != tts_parser_set_voice(g_config_info->language, g_config_info->type)) {
+                                       SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to save config");
+                                       __tts_config_release_client(uid);
+                                       __tts_config_release_engine();
+                                       tts_parser_unload_config(g_config_info);
+                                       return TTS_CONFIG_ERROR_OPERATION_FAILED;
+                               }
+                       }
+               }
+       }
+
+       /* print daemon config */
+       SLOG(LOG_DEBUG, tts_tag(), "== TTS config ==");
+       SECURE_SLOG(LOG_DEBUG, tts_tag(), " engine : %s", g_config_info->engine_id);
+       SECURE_SLOG(LOG_DEBUG, tts_tag(), " setting : %s", g_config_info->setting);
+       SECURE_SLOG(LOG_DEBUG, tts_tag(), " auto voice : %s", g_config_info->auto_voice ? "on" : "off");
+       SECURE_SLOG(LOG_DEBUG, tts_tag(), " language : %s", g_config_info->language);
+       SECURE_SLOG(LOG_DEBUG, tts_tag(), " voice type : %d", g_config_info->type);
+       SECURE_SLOG(LOG_DEBUG, tts_tag(), " speech rate : %d", g_config_info->speech_rate);
+       SECURE_SLOG(LOG_DEBUG, tts_tag(), " pitch : %d", g_config_info->pitch);
+       SLOG(LOG_DEBUG, tts_tag(), "=================");
+
+       if (0 != __tts_config_mgr_register_config_event()) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to register config event");
+               __tts_config_release_client(uid);
+               __tts_config_release_engine();
+               tts_parser_unload_config(g_config_info);
+               return TTS_CONFIG_ERROR_OPERATION_FAILED;
+       }
+
+       /* Register to detect display language change */
+       vconf_notify_key_changed(TTS_LANGSET_KEY, __tts_config_display_language_changed_cb, NULL);
+       vconf_notify_key_changed(TTS_ACCESSIBILITY_SPEED_KEY, __tts_config_speech_rate_key_changed_cb, NULL);
+       vconf_notify_key_changed(TTS_ACCESSIBILITY_KEY, __tts_config_screen_reader_changed_cb, NULL);
+
+       /* For engine directory monitoring */
+       if (0 != __tts_config_mgr_register_engine_config_updated_event()) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to register engine config updated event");
+               __tts_config_release_client(uid);
+               __tts_config_release_engine();
+               tts_parser_unload_config(g_config_info);
+               __tts_config_mgr_unregister_config_event();
+               return TTS_CONFIG_ERROR_OPERATION_FAILED;
+       }
+
+       return 0;
+}
+
+int tts_config_mgr_finalize(int uid)
+{
+       if (0 < __tts_config_release_client(uid)) {
+               return 0;
+       }
+
+       __tts_config_release_engine();
+
+       tts_parser_unload_config(g_config_info);
+
+       __tts_config_mgr_unregister_engine_config_updated_event();
+
+       __tts_config_mgr_unregister_config_event();
+
+       vconf_ignore_key_changed(TTS_LANGSET_KEY, __tts_config_display_language_changed_cb);
+       vconf_ignore_key_changed(TTS_ACCESSIBILITY_SPEED_KEY, __tts_config_speech_rate_key_changed_cb);
+       vconf_ignore_key_changed(TTS_ACCESSIBILITY_KEY, __tts_config_screen_reader_changed_cb);
+
+       return 0;
+}
+
+int tts_config_mgr_set_callback(int uid, 
+                               tts_config_engine_changed_cb engine_cb, 
+                               tts_config_voice_changed_cb voice_cb, 
+                               tts_config_speech_rate_changed_cb speech_cb, 
+                               tts_config_pitch_changed_cb pitch_cb,
+                               void* user_data)
+{
+       GSList *iter = NULL;
+       tts_config_client_s* temp_client = NULL;
+
+       /* Call all callbacks of client*/
+       iter = g_slist_nth(g_config_client_list, 0);
+
+       while (NULL != iter) {
+               temp_client = iter->data;
+
+               if (NULL != temp_client) {
+                       if (uid == temp_client->uid) {
+                               temp_client->engine_cb = engine_cb;
+                               temp_client->voice_cb = voice_cb;
+                               temp_client->speech_cb = speech_cb;
+                               temp_client->pitch_cb = pitch_cb;
+                               temp_client->user_data = user_data;
+                       }
+               }
+
+               iter = g_slist_next(iter);
+       }
+       return 0;
+}
+
+int tts_config_mgr_unset_callback(int uid)
+{
+       GSList *iter = NULL;
+       tts_config_client_s* temp_client = NULL;
+
+       /* Call all callbacks of client*/
+       iter = g_slist_nth(g_config_client_list, 0);
+
+       while (NULL != iter) {
+               temp_client = iter->data;
+
+               if (NULL != temp_client) {
+                       if (uid == temp_client->uid) {
+                               temp_client->engine_cb = NULL;
+                               temp_client->voice_cb = NULL;
+                               temp_client->speech_cb = NULL;
+                               temp_client->pitch_cb = NULL;
+                               temp_client->user_data = NULL;
+                       }
+               }
+
+               iter = g_slist_next(iter);
+       }
+
+       return 0;
+}
+
+int tts_config_set_screen_reader_callback(int uid, tts_config_screen_reader_changed_cb callback)
+{
+       if (NULL == callback) {
+               SLOG(LOG_ERROR, tts_tag(), "Input parameter is NULL");
+               return TTS_CONFIG_ERROR_INVALID_PARAMETER;
+       }
+
+       GSList *iter = NULL;
+       tts_config_client_s* temp_client = NULL;
+
+       /* Call all callbacks of client*/
+       iter = g_slist_nth(g_config_client_list, 0);
+
+       while (NULL != iter) {
+               temp_client = iter->data;
+
+               if (NULL != temp_client) {
+                       if (uid == temp_client->uid) {
+                               temp_client->screen_cb = callback;
+                       }
+               }
+
+               iter = g_slist_next(iter);
+       }
+       return 0;
+}
+
+int tts_config_unset_screen_reader_callback(int uid)
+{
+       GSList *iter = NULL;
+       tts_config_client_s* temp_client = NULL;
+
+       /* Call all callbacks of client*/
+       iter = g_slist_nth(g_config_client_list, 0);
+
+       while (NULL != iter) {
+               temp_client = iter->data;
+
+               if (NULL != temp_client) {
+                       if (uid == temp_client->uid) {
+                               temp_client->screen_cb = NULL;
+                       }
+               }
+
+               iter = g_slist_next(iter);
+       }
+       return 0;
+}
+
+
+int tts_config_mgr_get_engine_list(tts_config_supported_engine_cb callback, void* user_data)
+{
+       if (0 >= g_slist_length(g_config_client_list)) {
+               SLOG(LOG_ERROR, tts_tag(), "Not initialized");
+               return TTS_CONFIG_ERROR_INVALID_STATE;
+       }
+
+       GSList *iter = NULL;
+       tts_engine_info_s *engine_info = NULL;
+
+       if (0 >= g_slist_length(g_engine_list)) {
+               SLOG(LOG_ERROR, tts_tag(), "There is no engine!!");
+               return TTS_CONFIG_ERROR_ENGINE_NOT_FOUND;
+       }
+
+       /* Get a first item */
+       iter = g_slist_nth(g_engine_list, 0);
+
+       while (NULL != iter) {
+               engine_info = iter->data;
+
+               if (NULL != engine_info) {
+                       if (false == callback(engine_info->uuid, engine_info->name, engine_info->setting, user_data)) {
+                               break;
+                       }
+               }
+
+               iter = g_slist_next(iter);
+       }
+
+       return 0;
+}
+
+int tts_config_mgr_get_engine(char** engine)
+{
+       if (0 >= g_slist_length(g_config_client_list)) {
+               SLOG(LOG_ERROR, tts_tag(), "Not initialized");
+               return TTS_CONFIG_ERROR_INVALID_STATE;
+       }
+
+       if (NULL == engine) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Input parameter is NULL");
+               return TTS_CONFIG_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL != g_config_info->engine_id) {
+               /* Check engine id is valid */
+               GSList *iter = NULL;
+               tts_engine_info_s *engine_info = NULL;
+
+               if (0 >= g_slist_length(g_engine_list)) {
+                       SLOG(LOG_ERROR, tts_tag(), "[ERROR] There is no engine!!");
+                       return TTS_CONFIG_ERROR_ENGINE_NOT_FOUND;
+               }
+
+               /* Get a first item */
+               iter = g_slist_nth(g_engine_list, 0);
+
+               while (NULL != iter) {
+                       engine_info = iter->data;
+
+                       if (NULL != engine_info) {
+                               if (0 == strcmp(engine_info->uuid, g_config_info->engine_id)) {
+                                       *engine = strdup(g_config_info->engine_id);
+                                       return 0;
+                               }
+                       }
+                       iter = g_slist_next(iter);
+               }
+               
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Current engine id is not valid");
+       } else {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Engine id is NULL");
+       }
+
+       return TTS_CONFIG_ERROR_OPERATION_FAILED;
+}
+
+int tts_config_mgr_set_engine(const char* engine)
+{
+       if (0 >= g_slist_length(g_config_client_list)) {
+               SLOG(LOG_ERROR, tts_tag(), "Not initialized");
+               return TTS_CONFIG_ERROR_INVALID_STATE;
+       }
+
+       if (NULL == engine)
+               return TTS_CONFIG_ERROR_INVALID_PARAMETER;
+
+       /* Check current engine id with new engine id */
+       if (0 == strcmp(g_config_info->engine_id, engine)) 
+               return 0;
+
+       if (0 >= g_slist_length(g_engine_list)) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] There is no engine!!");
+               return TTS_CONFIG_ERROR_ENGINE_NOT_FOUND;
+       }
+
+       SLOG(LOG_DEBUG, tts_tag(), "New engine id : %s", engine);
+
+       GSList *iter = NULL;
+       tts_engine_info_s *engine_info = NULL;
+       bool is_valid_engine = false;
+
+       /* Get a first item */
+       iter = g_slist_nth(g_engine_list, 0);
+
+       while (NULL != iter) {
+               engine_info = iter->data;
+
+               if (NULL == engine_info) {
+                       SLOG(LOG_ERROR, tts_tag(), "[ERROR] Engine info is NULL");
+                       iter = g_slist_next(iter);
+                       continue;
+               }
+
+               /* Check engine id is valid */
+               if (0 != strcmp(engine, engine_info->uuid)) {
+                       iter = g_slist_next(iter);
+                       continue;
+               }
+
+               if (NULL != g_config_info->engine_id)
+                       free(g_config_info->engine_id);
+
+               g_config_info->engine_id = strdup(engine);
+
+               if (NULL != g_config_info->setting)
+                       free(g_config_info->setting);
+
+               if (NULL != engine_info->setting)
+                       g_config_info->setting = strdup(engine_info->setting);
+
+               /* Engine is valid*/
+               GSList *iter_voice = NULL;
+               tts_config_voice_s* voice = NULL;
+               bool is_valid_voice = false;
+
+               /* Get a first item */
+               iter_voice = g_slist_nth(engine_info->voices, 0);
+
+               while (NULL != iter_voice) {
+                       /*Get handle data from list*/
+                       voice = iter_voice->data;
+                       
+                       if (NULL != voice) {
+                               if (NULL == voice->language)
+                                       continue;
+                               SLOG(LOG_DEBUG, tts_tag(), " lang(%s) type(%d)", voice->language, voice->type);
+
+                               if (0 == strcmp(voice->language, g_config_info->language)) {
+                                       if (voice->type == g_config_info->type) {
+                                               /* language is valid */
+                                               is_valid_voice = true;
+
+                                               if (NULL != g_config_info->language) {
+                                                       free(g_config_info->language);
+
+                                                       g_config_info->language = strdup(voice->language);
+                                                       g_config_info->type = voice->type;
+                                               }
+                                       }
+                                       break;
+                               }
+                       }
+
+                       /*Get next item*/
+                       iter_voice = g_slist_next(iter_voice);
+               }
+
+               if (false == is_valid_voice) {
+                       if (NULL != g_config_info->language) {
+                               free(g_config_info->language);
+
+                               iter_voice = g_slist_nth(engine_info->voices, 0);
+                               if (NULL != iter_voice) {
+                                       voice = iter_voice->data;
+                                       if (NULL != voice) {
+                                               if (NULL != voice->language)
+                                                       g_config_info->language = strdup(voice->language);
+                                               g_config_info->type = voice->type;
+                                       }
+                               }
+                       }
+               }
+
+               is_valid_engine = true;
+               break;
+       }
+
+       if (true == is_valid_engine) {
+               SLOG(LOG_DEBUG, tts_tag(), "[Config] Engine changed");
+               SECURE_SLOG(LOG_DEBUG, tts_tag(), "  Engine : %s", g_config_info->engine_id);
+               SECURE_SLOG(LOG_DEBUG, tts_tag(), "  Setting : %s", g_config_info->setting);
+               SECURE_SLOG(LOG_DEBUG, tts_tag(), "  Language : %s", g_config_info->language);
+               SECURE_SLOG(LOG_DEBUG, tts_tag(), "  Type : %d", g_config_info->type);
+               
+               if ( 0 != tts_parser_set_engine(g_config_info->engine_id, g_config_info->setting, 
+                       g_config_info->language, g_config_info->type)) {
+                               SLOG(LOG_ERROR, tts_tag(), " Fail to save config");
+                               return TTS_CONFIG_ERROR_OPERATION_FAILED;
+               }
+       } else {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Engine id is not valid");
+               return TTS_CONFIG_ERROR_OPERATION_FAILED;
+       }
+
+       return 0;
+}
+
+int tts_config_mgr_get_voice_list(const char* engine_id, tts_config_supported_voice_cb callback, void* user_data)
+{
+       if (0 >= g_slist_length(g_config_client_list)) {
+               SLOG(LOG_ERROR, tts_tag(), "Not initialized");
+               return TTS_CONFIG_ERROR_INVALID_STATE;
+       }
+
+       if (0 >= g_slist_length(g_engine_list)) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] There is no engine");
+               return TTS_CONFIG_ERROR_ENGINE_NOT_FOUND;
+       }
+
+       GSList *iter = NULL;
+       tts_engine_info_s *engine_info = NULL;
+
+       /* Get a first item */
+       iter = g_slist_nth(g_engine_list, 0);
+
+       while (NULL != iter) {
+               engine_info = iter->data;
+
+               if (NULL == engine_info) {
+                       SLOG(LOG_ERROR, tts_tag(), "[ERROR] engine info is NULL");
+                       return TTS_CONFIG_ERROR_OPERATION_FAILED;
+               }
+
+               if (0 != strcmp(engine_id, engine_info->uuid)) {
+                       iter = g_slist_next(iter);
+                       continue;
+               }
+
+               GSList *iter_voice = NULL;
+               tts_config_voice_s* voice = NULL;
+               
+               /* Get a first item */
+               iter_voice = g_slist_nth(engine_info->voices, 0);
+
+               while (NULL != iter_voice) {
+                       /*Get handle data from list*/
+                       voice = iter_voice->data;
+
+                       SLOG(LOG_DEBUG, tts_tag(), " lang(%s) type(%d)", voice->language, voice->type);
+                       if (NULL != voice->language) {
+                               if (false == callback(engine_info->uuid, voice->language, voice->type, user_data))
+                                       break;
+                       }
+                       
+                       /*Get next item*/
+                       iter_voice = g_slist_next(iter_voice);
+               }
+               break;
+       }
+
+       return 0;
+}
+
+int tts_config_mgr_get_voice(char** language, int* type)
+{
+       if (0 >= g_slist_length(g_config_client_list)) {
+               SLOG(LOG_ERROR, tts_tag(), "Not initialized");
+               return TTS_CONFIG_ERROR_INVALID_PARAMETER;
+       }
+
+       if (0 >= g_slist_length(g_engine_list)) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] There is no engine");
+               return TTS_CONFIG_ERROR_ENGINE_NOT_FOUND;
+       }
+
+       if (NULL == language || NULL == type)
+               return TTS_CONFIG_ERROR_INVALID_PARAMETER;
+
+       if (NULL != g_config_info->language) {
+               *language = strdup(g_config_info->language);
+               *type = g_config_info->type;
+       } else {
+               SLOG(LOG_ERROR, tts_tag(), "language is NULL");
+               return TTS_CONFIG_ERROR_OPERATION_FAILED;
+       }
+
+       return 0;
+}
+
+int tts_config_mgr_set_voice(const char* language, int type)
+{
+       if (0 >= g_slist_length(g_config_client_list)) {
+               SLOG(LOG_ERROR, tts_tag(), "Not initialized");
+               return TTS_CONFIG_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == language) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Input parameter is NULL");
+               return TTS_CONFIG_ERROR_INVALID_PARAMETER;
+       }
+
+       if (0 >= g_slist_length(g_engine_list)) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] There is no engine");
+               return TTS_CONFIG_ERROR_ENGINE_NOT_FOUND;
+       }
+
+       /* Check language is valid */
+       if (NULL != g_config_info->language) {
+               if (0 != tts_parser_set_voice(language, type)) {
+                       SLOG(LOG_ERROR, tts_tag(), "Fail to save default voice");
+                       return TTS_CONFIG_ERROR_OPERATION_FAILED;
+               }
+               free(g_config_info->language);
+               g_config_info->language = strdup(language);
+               g_config_info->type = type;
+
+       } else {
+               SLOG(LOG_ERROR, tts_tag(), "language is NULL");
+               return TTS_CONFIG_ERROR_OPERATION_FAILED;
+       }
+
+       return 0;
+}
+
+int tts_config_mgr_get_auto_voice(bool* value)
+{
+       if (0 >= g_slist_length(g_config_client_list)) {
+               SLOG(LOG_ERROR, tts_tag(), "Not initialized");
+               return TTS_CONFIG_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == value)
+               return TTS_CONFIG_ERROR_INVALID_PARAMETER;
+
+       *value = g_config_info->auto_voice;
+
+       return 0;
+}
+
+int tts_config_mgr_set_auto_voice(bool value)
+{
+       if (0 >= g_slist_length(g_config_client_list)) {
+               SLOG(LOG_ERROR, tts_tag(), "Not initialized");
+               return TTS_CONFIG_ERROR_INVALID_PARAMETER;
+       }
+
+       if (g_config_info->auto_voice != value) {
+               /* Check language is valid */
+               if (0 != tts_parser_set_auto_voice(value)) {
+                       SLOG(LOG_ERROR, tts_tag(), "Fail to save auto voice option");
+                       return TTS_CONFIG_ERROR_OPERATION_FAILED;
+               }
+               g_config_info->auto_voice = value;
+
+               if (true == g_config_info->auto_voice) {
+                       __tts_config_set_auto_language();
+               }
+       }
+
+       return 0;
+}
+
+int tts_config_mgr_get_speech_rate(int* value)
+{
+       if (0 >= g_slist_length(g_config_client_list)) {
+               SLOG(LOG_ERROR, tts_tag(), "Not initialized");
+               return TTS_CONFIG_ERROR_INVALID_PARAMETER;
+       }
+       
+       if (NULL == value) {
+               return TTS_CONFIG_ERROR_INVALID_PARAMETER;
+       }
+
+       *value = g_config_info->speech_rate;
+
+       return 0;
+}
+
+int tts_config_mgr_set_speech_rate(int value)
+{
+       if (0 >= g_slist_length(g_config_client_list)) {
+               SLOG(LOG_ERROR, tts_tag(), "Not initialized");
+               return TTS_CONFIG_ERROR_INVALID_PARAMETER;
+       }
+
+       if (TTS_CONFIG_SPEED_MIN <= value && value <= TTS_CONFIG_SPEED_MAX) {
+               SLOG(LOG_DEBUG, tts_tag(), "[Config] Set speech rate : %d", value);
+               if (0 != tts_parser_set_speech_rate(value)) {
+                       SLOG(LOG_ERROR, tts_tag(), "Fail to save speech rate");
+                       return TTS_CONFIG_ERROR_OPERATION_FAILED;
+               }
+               
+               g_config_info->speech_rate = value;
+
+               vconf_set_int(TTS_ACCESSIBILITY_SPEED_KEY, value);
+       } else {
+               SLOG(LOG_ERROR, tts_tag(), "[Config ERROR] Speech rate is invalid : %d", value);
+       }
+       
+       return 0;
+}
+
+int tts_config_mgr_get_pitch(int* value)
+{
+       if (0 >= g_slist_length(g_config_client_list)) {
+               SLOG(LOG_ERROR, tts_tag(), "Not initialized");
+               return TTS_CONFIG_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == value) {
+               return TTS_CONFIG_ERROR_INVALID_PARAMETER;
+       }
+
+       GSList *iter = NULL;
+       tts_engine_info_s *engine_info = NULL;
+
+       if (0 >= g_slist_length(g_engine_list)) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] There is no engine!!");
+               return TTS_CONFIG_ERROR_ENGINE_NOT_FOUND;
+       }
+
+       /* Get a first item */
+       iter = g_slist_nth(g_engine_list, 0);
+
+       while (NULL != iter) {
+               engine_info = iter->data;
+
+               if (NULL == engine_info) {
+                       SLOG(LOG_ERROR, tts_tag(), "engine info is NULL");
+                       return TTS_CONFIG_ERROR_OPERATION_FAILED;
+               }
+               
+               if (0 != strcmp(g_config_info->engine_id, engine_info->uuid)) {
+                       iter = g_slist_next(iter);
+                       continue;
+               }
+
+               if (false == engine_info->pitch_support) {
+                       return TTS_CONFIG_ERROR_NOT_SUPPORTED_FEATURE;
+               }  else {
+                       break;
+               }
+       }
+
+       *value = g_config_info->pitch;
+
+       return 0;
+}
+
+int tts_config_mgr_set_pitch(int value)
+{
+       if (0 >= g_slist_length(g_config_client_list)) {
+               SLOG(LOG_ERROR, tts_tag(), "Not initialized");
+               return -1;
+       }
+
+       GSList *iter = NULL;
+       tts_engine_info_s *engine_info = NULL;
+
+       if (0 >= g_slist_length(g_engine_list)) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] There is no engine!!");
+               return TTS_CONFIG_ERROR_ENGINE_NOT_FOUND;
+       }
+       
+       /* Get a first item */
+       iter = g_slist_nth(g_engine_list, 0);
+
+       while (NULL != iter) {
+               engine_info = iter->data;
+
+               if (NULL == engine_info) {
+                       SLOG(LOG_ERROR, tts_tag(), "engine info is NULL");
+                       return TTS_CONFIG_ERROR_OPERATION_FAILED;
+               }
+               
+               if (0 != strcmp(g_config_info->engine_id, engine_info->uuid)) {
+                       iter = g_slist_next(iter);
+                       continue;
+               }
+
+               if (false == engine_info->pitch_support) {
+                       return TTS_CONFIG_ERROR_NOT_SUPPORTED_FEATURE;
+               } else {
+                       break;
+               }
+       }
+
+       if (0 != tts_parser_set_pitch(value)) {
+               SLOG(LOG_ERROR, tts_tag(), "Fail to save speech rate");
+               return TTS_CONFIG_ERROR_OPERATION_FAILED;
+       }
+       
+       g_config_info->pitch = value;
+
+       return 0;
+}
+
+bool tts_config_check_default_engine_is_valid(const char* engine)
+{
+       if (0 >= g_slist_length(g_config_client_list)) {
+               SLOG(LOG_ERROR, tts_tag(), "Not initialized");
+               return -1;
+       }
+
+       if (NULL == engine)
+               return false;
+
+       if (0 >= g_slist_length(g_engine_list)) 
+               return false;
+
+       GSList *iter = NULL;
+       tts_engine_info_s *engine_info = NULL;
+
+       /* Get a first item */
+       iter = g_slist_nth(g_engine_list, 0);
+
+       while (NULL != iter) {
+               engine_info = iter->data;
+
+               if (NULL != engine_info) {
+                       if (0 == strcmp(engine, engine_info->uuid)) {
+                               return true;
+                       }
+               }
+               iter = g_slist_next(iter);
+       }
+
+       return false;
+}
+
+bool tts_config_check_default_voice_is_valid(const char* language, int type)
+{
+       if (0 >= g_slist_length(g_config_client_list)) {
+               SLOG(LOG_ERROR, tts_tag(), "Not initialized");
+               return -1;
+       }
+
+       if (NULL == language)
+               return false;
+
+       if (NULL == g_config_info->engine_id) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Default engine id is NULL");
+               return false;
+       }
+
+       if (0 >= g_slist_length(g_engine_list)) 
+               return false;
+
+       GSList *iter = NULL;
+       tts_engine_info_s *engine_info = NULL;
+
+       /* Get a first item */
+       iter = g_slist_nth(g_engine_list, 0);
+
+       while (NULL != iter) {
+               engine_info = iter->data;
+
+               if (NULL == engine_info) {
+                       SLOG(LOG_ERROR, tts_tag(), "[ERROR] Engine info is NULL");
+                       iter = g_slist_next(iter);
+                       continue;
+               }
+
+               if (0 != strcmp(g_config_info->engine_id, engine_info->uuid)) {
+                       iter = g_slist_next(iter);
+                       continue;
+               }
+
+               GSList *iter_voice = NULL;
+               tts_config_voice_s* voice = NULL;
+
+               /* Get a first item */
+               iter_voice = g_slist_nth(engine_info->voices, 0);
+
+               while (NULL != iter_voice) {
+                       voice = iter_voice->data;
+                       
+                       if (0 == strcmp(language, voice->language) && voice->type == type)
+                               return true;
+
+                       /*Get next item*/
+                       iter_voice = g_slist_next(iter_voice);
+               }
+
+               break;
+       }
+
+       return false;
+}
+
+
+int __tts_config_mgr_print_engine_info()
+{
+       GSList *iter = NULL;
+       tts_engine_info_s *engine_info = NULL;
+
+       if (0 >= g_slist_length(g_engine_list)) {
+               SLOG(LOG_DEBUG, tts_tag(), "-------------- engine list -----------------");
+               SLOG(LOG_DEBUG, tts_tag(), "  No Engine in engine directory");
+               SLOG(LOG_DEBUG, tts_tag(), "--------------------------------------------");
+               return 0;
+       }
+
+       /* Get a first item */
+       iter = g_slist_nth(g_engine_list, 0);
+
+       SLOG(LOG_DEBUG, tts_tag(), "--------------- engine list -----------------");
+
+       int i = 1;      
+       while (NULL != iter) {
+               engine_info = iter->data;
+
+               SLOG(LOG_DEBUG, tts_tag(), "[%dth]", i);
+               SLOG(LOG_DEBUG, tts_tag(), " name : %s", engine_info->name);
+               SLOG(LOG_DEBUG, tts_tag(), " id   : %s", engine_info->uuid);
+               SLOG(LOG_DEBUG, tts_tag(), " setting : %s", engine_info->setting);
+
+               SLOG(LOG_DEBUG, tts_tag(), " Voices");
+               GSList *iter_voice = NULL;
+               tts_config_voice_s* voice = NULL;
+
+               if (g_slist_length(engine_info->voices) > 0) {
+                       /* Get a first item */
+                       iter_voice = g_slist_nth(engine_info->voices, 0);
+
+                       int j = 1;
+                       while (NULL != iter_voice) {
+                               /*Get handle data from list*/
+                               voice = iter_voice->data;
+
+                               SLOG(LOG_DEBUG, tts_tag(), "  [%dth] lang(%s) type(%d)", j, voice->language, voice->type);
+
+                               /*Get next item*/
+                               iter_voice = g_slist_next(iter_voice);
+                               j++;
+                       }
+               } else {
+                       SLOG(LOG_ERROR, tts_tag(), "  Voice is NONE");
+               }
+               iter = g_slist_next(iter);
+               i++;
+       }
+       SLOG(LOG_DEBUG, tts_tag(), "--------------------------------------------");
+
+       return 0;
+}
+
+char* tts_config_get_message_path(int mode, int pid)
+{
+       char* path = NULL;
+       path = calloc(128, sizeof(char));
+
+       switch(mode) {
+       case 0: snprintf(path, 128, "%s%s_%d", MESSAGE_FILE_PATH_ROOT, MESSAGE_FILE_PREFIX_DEFAULT, pid);       break;
+       case 1: snprintf(path, 128, "%s%s_%d", MESSAGE_FILE_PATH_ROOT, MESSAGE_FILE_PREFIX_NOTIFICATION, pid);  break;
+       case 2: snprintf(path, 128, "%s%s_%d", MESSAGE_FILE_PATH_ROOT, MESSAGE_FILE_PREFIX_SCREEN_READER, pid); break;
+       default:
+               if (NULL != path)       free(path);
+               SLOG(LOG_ERROR, tts_tag(), "[Config] Invalid mode (%d)", mode);
+               return NULL;
+       }
+
+       return path;
+}
\ No newline at end of file
diff --git a/common/tts_config_mgr.h b/common/tts_config_mgr.h
new file mode 100644 (file)
index 0000000..2e5c21c
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+*  Copyright (c) 2011-2014 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 __TTS_CONFIG_MANAGER_H_
+#define __TTS_CONFIG_MANAGER_H_
+
+#include <errno.h>
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum {
+       TTS_CONFIG_ERROR_NONE                   = 0,            /**< Success, No error */
+       TTS_CONFIG_ERROR_OUT_OF_MEMORY          = -ENOMEM,      /**< Out of Memory */
+       TTS_CONFIG_ERROR_IO_ERROR               = -EIO,         /**< I/O error */
+       TTS_CONFIG_ERROR_INVALID_PARAMETER      = -EINVAL,      /**< Invalid parameter */
+       TTS_CONFIG_ERROR_INVALID_STATE          = -0x0100021,   /**< Invalid state */
+       TTS_CONFIG_ERROR_INVALID_VOICE          = -0x0100022,   /**< Invalid voice */
+       TTS_CONFIG_ERROR_ENGINE_NOT_FOUND       = -0x0100023,   /**< No available TTS-engine  */
+       TTS_CONFIG_ERROR_OPERATION_FAILED       = -0x0100024,   /**< Operation failed  */
+       TTS_CONFIG_ERROR_NOT_SUPPORTED_FEATURE  = -0x0100025    /**< Not supported feature of current engine */
+} tts_config_error_e;
+
+typedef enum {
+       TTS_CONFIG_SPEED_AUTO           = 0,    /**< Speed from settings */
+       TTS_CONFIG_SPEED_MIN            = 1,    /**< Min value */
+       TTS_CONFIG_SPEED_VERY_SLOW      = 2,    /**< Very slow */
+       TTS_CONFIG_SPEED_SLOW           = 5,    /**< Slow */
+       TTS_CONFIG_SPEED_NORMAL         = 8,    /**< Normal */
+       TTS_CONFIG_SPEED_FAST           = 11,   /**< Fast */
+       TTS_CONFIG_SPEED_VERY_FAST      = 14,   /**< Very fast */
+       TTS_CONFIG_SPEED_MAX            = 15    /**< Max value */
+}tts_config_speed_e;
+
+
+typedef bool (*tts_config_supported_engine_cb)(const char* engine_id, const char* engine_name, const char* setting, void* user_data);
+
+typedef bool (*tts_config_supported_voice_cb)(const char* engine_id, const char* language, int type, void* user_data);
+
+typedef void (*tts_config_engine_changed_cb)(const char* engine_id, const char* setting, 
+                                            const char* language, int voice_type, bool auto_voice, void* user_data);
+
+typedef void (*tts_config_voice_changed_cb)(const char* before_language, int before_voice_type, 
+                                           const char* current_language, int current_voice_type, 
+                                           bool auto_voice, void* user_data);
+
+typedef void (*tts_config_speech_rate_changed_cb)(int value, void* user_data);
+
+typedef void (*tts_config_pitch_changed_cb)(int value, void* user_data);
+
+typedef void (*tts_config_screen_reader_changed_cb)(bool value);
+
+
+int tts_config_mgr_initialize(int uid);
+
+int tts_config_mgr_finalize(int uid);
+
+
+int tts_config_mgr_set_callback(int uid, 
+                               tts_config_engine_changed_cb engine_cb, 
+                               tts_config_voice_changed_cb voice_cb, 
+                               tts_config_speech_rate_changed_cb speech_cb, 
+                               tts_config_pitch_changed_cb pitch_cb,
+                               void* user_data);
+
+int tts_config_mgr_unset_callback(int uid);
+
+/* Only for screen reader option */
+int tts_config_set_screen_reader_callback(int uid, tts_config_screen_reader_changed_cb callback);
+
+int tts_config_unset_screen_reader_callback(int uid);
+
+
+int tts_config_mgr_get_engine_list(tts_config_supported_engine_cb callback, void* user_data);
+
+int tts_config_mgr_get_engine(char** engine);
+
+int tts_config_mgr_set_engine(const char* engine);
+
+int tts_config_mgr_get_voice_list(const char* engine_id, tts_config_supported_voice_cb callback, void* user_data);
+
+int tts_config_mgr_get_voice(char** language, int* type);
+
+int tts_config_mgr_set_voice(const char* language, int type);
+
+int tts_config_mgr_get_auto_voice(bool* value);
+
+int tts_config_mgr_set_auto_voice(bool value);
+
+int tts_config_mgr_get_speech_rate(int* value);
+
+int tts_config_mgr_set_speech_rate(int value);
+
+int tts_config_mgr_get_pitch(int* value);
+
+int tts_config_mgr_set_pitch(int value);
+
+bool tts_config_check_default_engine_is_valid(const char* engine);
+
+bool tts_config_check_default_voice_is_valid(const char* language, int type);
+
+char* tts_config_get_message_path(int mode, int pid);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TTS_CONFIG_MANAGER_H_ */
diff --git a/common/tts_config_parser.c b/common/tts_config_parser.c
new file mode 100644 (file)
index 0000000..7c5a3e2
--- /dev/null
@@ -0,0 +1,895 @@
+/*
+*  Copyright (c) 2011-2014 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 <dlog.h>
+#include <stdio.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <vconf.h>
+
+#include "tts_config_parser.h"
+#include "tts_defs.h"
+
+
+#define TTS_TAG_ENGINE_BASE_TAG                "tts-engine"
+#define TTS_TAG_ENGINE_NAME            "name"
+#define TTS_TAG_ENGINE_ID              "id"
+#define TTS_TAG_ENGINE_SETTING         "setting"
+#define TTS_TAG_ENGINE_VOICE_SET       "voices"
+#define TTS_TAG_ENGINE_VOICE           "voice"
+#define TTS_TAG_ENGINE_VOICE_TYPE      "type"
+#define TTS_TAG_ENGINE_PITCH_SUPPORT   "pitch-support"
+
+#define TTS_TAG_CONFIG_BASE_TAG                "tts-config"
+#define TTS_TAG_CONFIG_ENGINE_ID       "engine"
+#define TTS_TAG_CONFIG_ENGINE_SETTING  "engine-setting"
+#define TTS_TAG_CONFIG_AUTO_VOICE      "auto"
+#define TTS_TAG_CONFIG_VOICE_TYPE      "voice-type"
+#define TTS_TAG_CONFIG_LANGUAGE                "language"
+#define TTS_TAG_CONFIG_SPEECH_RATE     "speech-rate"
+#define TTS_TAG_CONFIG_PITCH           "pitch"
+#define TTS_TAG_VOICE_TYPE_FEMALE      "female"
+#define TTS_TAG_VOICE_TYPE_MALE                "male"
+#define TTS_TAG_VOICE_TYPE_CHILD       "child"
+
+
+extern char* tts_tag();
+
+static xmlDocPtr g_config_doc = NULL;
+
+int tts_parser_get_engine_info(const char* path, tts_engine_info_s** engine_info)
+{
+       if (NULL == path || NULL == engine_info) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Input parameter is NULL");
+               return -1;
+       }
+
+       xmlDocPtr doc = NULL;
+       xmlNodePtr cur = NULL;
+       xmlChar *key = NULL;
+       xmlChar *attr = NULL;
+
+       doc = xmlParseFile(path);
+       if (doc == NULL) {
+               return -1;
+       }
+
+       cur = xmlDocGetRootElement(doc);
+       if (cur == NULL) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Empty document");
+               xmlFreeDoc(doc);
+               return -1;
+       }
+
+       if (xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_ENGINE_BASE_TAG)) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] The wrong type, root node is NOT 'tts-engine'");
+               xmlFreeDoc(doc);
+               return -1;
+       }
+
+       cur = cur->xmlChildrenNode;
+       if (cur == NULL) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Empty document");
+               xmlFreeDoc(doc);
+               return -1;
+       }
+
+       /* alloc engine info */
+       tts_engine_info_s* temp;
+       temp = (tts_engine_info_s*)calloc(1, sizeof(tts_engine_info_s));
+
+       temp->name = NULL;
+       temp->uuid = NULL;
+       temp->voices = NULL;
+       temp->setting = NULL;
+       temp->pitch_support = false;
+
+       while (cur != NULL) {
+               if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_ENGINE_NAME)) {
+                       key = xmlNodeGetContent(cur);
+                       if (NULL != key) {
+                               if (NULL != temp->name) free(temp->name);
+                               temp->name = strdup((char*)key);
+                               xmlFree(key);
+                       } else {
+                               SLOG(LOG_ERROR, tts_tag(), "[ERROR] <%s> has no content", TTS_TAG_ENGINE_NAME);
+                       }
+               } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_ENGINE_ID)) {
+                       key = xmlNodeGetContent(cur);
+                       if (NULL != key) {
+                               if (NULL != temp->uuid) free(temp->uuid);
+                               temp->uuid = strdup((char*)key);
+                               xmlFree(key);
+                       } else {
+                               SLOG(LOG_ERROR, tts_tag(), "[ERROR] <%s> has no content", TTS_TAG_ENGINE_ID);
+                       }
+               } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_ENGINE_SETTING)) {
+                       key = xmlNodeGetContent(cur);
+                       if (NULL != key) {
+                               if (NULL != temp->setting)      free(temp->setting);
+                               temp->setting = strdup((char*)key);
+                               xmlFree(key);
+                       } else {
+                               SLOG(LOG_ERROR, tts_tag(), "[ERROR] <%s> has no content", TTS_TAG_ENGINE_SETTING);
+                       }
+               } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_ENGINE_VOICE_SET)) {
+                       xmlNodePtr voice_node = NULL;
+                       voice_node = cur->xmlChildrenNode;
+
+                       while (NULL != voice_node) {
+                               if (0 == xmlStrcmp(voice_node->name, (const xmlChar *)TTS_TAG_ENGINE_VOICE)) {
+
+                                       tts_config_voice_s* temp_voice = (tts_config_voice_s*)calloc(1, sizeof(tts_config_voice_s));
+
+                                       attr = xmlGetProp(voice_node, (const xmlChar*)TTS_TAG_ENGINE_VOICE_TYPE);
+                                       if (NULL != attr) {
+                                               if (0 == xmlStrcmp(attr, (const xmlChar *)TTS_TAG_VOICE_TYPE_FEMALE)) {
+                                                       temp_voice->type = (int)TTS_CONFIG_VOICE_TYPE_FEMALE;
+                                               } else if (0 == xmlStrcmp(attr, (const xmlChar *)TTS_TAG_VOICE_TYPE_MALE)) {
+                                                       temp_voice->type = (int)TTS_CONFIG_VOICE_TYPE_MALE;
+                                               } else if (0 == xmlStrcmp(attr, (const xmlChar *)TTS_TAG_VOICE_TYPE_CHILD)) {
+                                                       temp_voice->type = (int)TTS_CONFIG_VOICE_TYPE_CHILD;
+                                               } else {
+                                                       temp_voice->type = (int)TTS_CONFIG_VOICE_TYPE_USER_DEFINED;
+                                               }
+                                               xmlFree(attr);
+                                       } else {
+                                               SLOG(LOG_ERROR, tts_tag(), "[ERROR] <%s> has no content", TTS_TAG_ENGINE_VOICE_TYPE);
+                                       }
+
+                                       key = xmlNodeGetContent(voice_node);
+                                       if (NULL != key) {
+                                               if (NULL != temp_voice->language)       free(temp_voice->language);
+                                               temp_voice->language = strdup((char*)key);
+                                               xmlFree(key);
+                                       } else {
+                                               SLOG(LOG_ERROR, tts_tag(), "[ERROR] <%s> has no content", TTS_TAG_ENGINE_VOICE);
+                                       }
+
+                                       temp->voices = g_slist_append(temp->voices, temp_voice);
+                               }
+                               voice_node = voice_node->next;
+                       }
+               } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_ENGINE_PITCH_SUPPORT)) {
+                       key = xmlNodeGetContent(cur);
+                       if (NULL != key) {
+                               if (0 == xmlStrcmp(key, (const xmlChar *)"true")) {
+                                       temp->pitch_support = true;
+                               }
+                               xmlFree(key);
+                       } else {
+                               SLOG(LOG_ERROR, tts_tag(), "[ERROR] <%s> has no content", TTS_TAG_ENGINE_PITCH_SUPPORT);
+                       }
+               }
+               cur = cur->next;
+       }
+
+       xmlFreeDoc(doc);
+
+       if (NULL == temp->name || NULL == temp->uuid) {
+               /* Invalid engine */
+               SECURE_SLOG(LOG_ERROR, tts_tag(), "[ERROR] Invalid engine : %s", path);
+               tts_parser_free_engine_info(temp);
+               return -1;
+       }
+
+       *engine_info = temp;
+
+       return 0;
+}
+
+int tts_parser_free_engine_info(tts_engine_info_s* engine_info)
+{
+       if (NULL == engine_info) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Input parameter is NULL");
+               return -1;
+       }
+
+       if (NULL != engine_info->name)          free(engine_info->name);
+       if (NULL != engine_info->uuid)          free(engine_info->uuid);
+       if (NULL != engine_info->setting)       free(engine_info->setting);
+
+       tts_config_voice_s *temp_voice;
+       temp_voice = g_slist_nth_data(engine_info->voices, 0);
+
+       while (NULL != temp_voice) {
+               if (NULL != temp_voice) {
+                       if (NULL != temp_voice->language)       free(temp_voice->language);
+                       engine_info->voices = g_slist_remove(engine_info->voices, temp_voice);
+                       free(temp_voice);
+               }
+
+               temp_voice = g_slist_nth_data(engine_info->voices, 0);
+       }
+
+       if (NULL != engine_info)        free(engine_info);
+
+       return 0;       
+}
+
+int tts_parser_print_engine_info(tts_engine_info_s* engine_info)
+{
+       if (NULL == engine_info) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Input parameter is NULL");
+               return -1;
+       }
+
+       SLOG(LOG_DEBUG, tts_tag(), "== get engine info ==");
+       SLOG(LOG_DEBUG, tts_tag(), " name : %s", engine_info->name);
+       SLOG(LOG_DEBUG, tts_tag(), " id   : %s", engine_info->uuid);
+       if (NULL != engine_info->setting)
+               SLOG(LOG_DEBUG, tts_tag(), " setting : %s", engine_info->setting);
+
+       SLOG(LOG_DEBUG, tts_tag(), " voices");
+       GSList *iter = NULL;
+       tts_config_voice_s *temp_voice;
+
+       if (g_slist_length(engine_info->voices) > 0) {
+               /* Get a first item */
+               iter = g_slist_nth(engine_info->voices, 0);
+
+               int i = 1;      
+               while (NULL != iter) {
+                       /*Get handle data from list*/
+                       temp_voice = iter->data;
+
+                       SLOG(LOG_DEBUG, tts_tag(), "  [%dth] type(%d) lang(%s)", 
+                               i, temp_voice->type, temp_voice->language);
+
+                       /*Get next item*/
+                       iter = g_slist_next(iter);
+                       i++;
+               }
+       } else {
+               SLOG(LOG_ERROR, tts_tag(), "  Voice is NONE");
+       }
+
+       SLOG(LOG_DEBUG, tts_tag(), "=====================");
+
+       return 0;
+}
+
+int tts_parser_load_config(tts_config_s** config_info)
+{
+       if (NULL == config_info) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Input parameter is NULL");
+               return -1;
+       }
+
+       xmlDocPtr doc = NULL;
+       xmlNodePtr cur = NULL;
+       xmlChar *key;
+       bool is_default_open = false;
+
+       if (0 != access(TTS_CONFIG, F_OK)) {
+               doc = xmlParseFile(TTS_DEFAULT_CONFIG);
+               if (doc == NULL) {
+                       SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to parse file error : %s", TTS_DEFAULT_CONFIG);
+                       return -1;
+               }
+               is_default_open = true;
+       } else {
+               int retry_count = 0;
+
+               while (NULL == doc) {
+                       doc = xmlParseFile(TTS_CONFIG);
+                       if (NULL != doc) {
+                               break;
+                       }
+                       retry_count++;
+                       usleep(1000);
+
+                       if (100 == retry_count) {
+                               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to parse file error : %s", TTS_CONFIG);
+                               return -1;
+                       }
+               }
+       }
+
+       cur = xmlDocGetRootElement(doc);
+       if (cur == NULL) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Empty document");
+               xmlFreeDoc(doc);
+               return -1;
+       }
+
+       if (xmlStrcmp(cur->name, (const xmlChar *) TTS_TAG_CONFIG_BASE_TAG)) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] The wrong type, root node is NOT %s", TTS_TAG_CONFIG_BASE_TAG);
+               xmlFreeDoc(doc);
+               return -1;
+       }
+
+       cur = cur->xmlChildrenNode;
+       if (cur == NULL) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Empty document");
+               xmlFreeDoc(doc);
+               return -1;
+       }
+
+       /* alloc engine info */
+       tts_config_s* temp;
+       temp = (tts_config_s*)calloc(1, sizeof(tts_config_s));
+
+       temp->engine_id = NULL;
+       temp->setting = NULL;
+       temp->language = NULL;
+
+       while (cur != NULL) {
+               if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_CONFIG_ENGINE_ID)) {
+                       key = xmlNodeGetContent(cur);
+                       if (NULL != key) {
+                               if (NULL != temp->engine_id)    free(temp->engine_id);
+                               temp->engine_id = strdup((char*)key);
+                               xmlFree(key);
+                       } else {
+                               SLOG(LOG_ERROR, tts_tag(), "[ERROR] engine id is NULL");
+                       }
+               } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_CONFIG_ENGINE_SETTING)) {
+                       key = xmlNodeGetContent(cur);
+                       if (NULL != key) {
+                               if (NULL != temp->setting)      free(temp->setting);
+                               temp->setting = strdup((char*)key);
+                               xmlFree(key);
+                       } else {
+                               SLOG(LOG_ERROR, tts_tag(), "[ERROR] setting path is NULL");
+                       }
+                       
+               } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_CONFIG_AUTO_VOICE)) {
+                       key = xmlNodeGetContent(cur);
+                       if (NULL != key) {
+                               if (0 == xmlStrcmp(key, (const xmlChar *)"on")) {
+                                       temp->auto_voice = true;
+                               } else if (0 == xmlStrcmp(key, (const xmlChar *)"off")) {
+                                       temp->auto_voice = false;
+                               } else {
+                                       SLOG(LOG_ERROR, tts_tag(), "Auto voice is wrong");
+                                       temp->auto_voice = true;
+                               }
+
+                               xmlFree(key);
+                       } else {
+                               SLOG(LOG_ERROR, tts_tag(), "[ERROR] voice type is NULL");
+                       }
+               } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_CONFIG_VOICE_TYPE)) {
+                       key = xmlNodeGetContent(cur);
+                       if (NULL != key) {
+                               if (0 == xmlStrcmp(key, (const xmlChar *)TTS_TAG_VOICE_TYPE_MALE)) {
+                                       temp->type = (int)TTS_CONFIG_VOICE_TYPE_MALE;
+                               } else if (0 == xmlStrcmp(key, (const xmlChar *)TTS_TAG_VOICE_TYPE_FEMALE)) {
+                                       temp->type = (int)TTS_CONFIG_VOICE_TYPE_FEMALE;
+                               } else if (0 == xmlStrcmp(key, (const xmlChar *)TTS_TAG_VOICE_TYPE_CHILD)) {
+                                       temp->type = (int)TTS_CONFIG_VOICE_TYPE_CHILD;
+                               } else {
+                                       SLOG(LOG_WARN, tts_tag(), "Voice type is user defined");
+                                       temp->type = (int)TTS_CONFIG_VOICE_TYPE_USER_DEFINED;
+                               }
+
+                               xmlFree(key);
+                       } else {
+                               SLOG(LOG_ERROR, tts_tag(), "[ERROR] voice type is NULL");
+                       }
+               } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_CONFIG_LANGUAGE)) {
+                       key = xmlNodeGetContent(cur);
+                       if (NULL != key) {
+                               if (NULL != temp->language)     free(temp->language);
+                               temp->language = strdup((char*)key);
+                               xmlFree(key);
+                       } else {
+                               SLOG(LOG_ERROR, tts_tag(), "[ERROR] engine uuid is NULL");
+                       }
+
+               } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_CONFIG_SPEECH_RATE)) {
+                       key = xmlNodeGetContent(cur);
+                       if (NULL != key) {
+                               temp->speech_rate = atoi((char*)key);
+                               xmlFree(key);
+                       } else {
+                               SLOG(LOG_ERROR, tts_tag(), "[ERROR] speech rate is NULL");
+                       }
+               } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_CONFIG_PITCH)) {
+                       key = xmlNodeGetContent(cur);
+                       if (NULL != key) {
+                               temp->pitch = atoi((char*)key);
+                               xmlFree(key);
+                       } else {
+                               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Pitch is NULL");
+                       }
+               } else {
+
+               }
+
+               cur = cur->next;
+       }
+
+       *config_info = temp;
+       g_config_doc = doc;
+
+       if (true == is_default_open) {
+               int ret = xmlSaveFile(TTS_CONFIG, g_config_doc);
+               if (0 > ret) {
+                       SLOG(LOG_ERROR, tts_tag(), "[ERROR] Save result : %d", ret);
+               }
+
+               /* Set mode */
+               if (0 > chmod(TTS_CONFIG, 0666)) {
+                       SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to change file mode : %d", ret);
+               }
+
+               /* Set owner */
+               if (0 > chown(TTS_CONFIG, 5000, 5000)) {
+                       SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to change file owner : %d", ret);
+               }
+               SLOG(LOG_DEBUG, tts_tag(), "Default config is changed : pid(%d)", getpid());
+       }
+
+       return 0;
+}
+
+int tts_parser_unload_config(tts_config_s* config_info)
+{
+       if (NULL != g_config_doc)       xmlFreeDoc(g_config_doc);
+       if (NULL != config_info) {
+               if (NULL != config_info->engine_id)     free(config_info->engine_id);
+               if (NULL != config_info->setting)       free(config_info->setting);
+               if (NULL != config_info->language)      free(config_info->language);
+               free(config_info);
+       }
+
+       return 0;
+}
+
+int tts_parser_set_engine(const char* engine_id, const char* setting, const char* language, int type)
+{
+       if (NULL == engine_id) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Input parameter is NULL");
+               return -1;
+       }
+
+       xmlNodePtr cur = NULL;
+       cur = xmlDocGetRootElement(g_config_doc);
+       if (cur == NULL) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Empty document");
+               return -1;
+       }
+
+       if (xmlStrcmp(cur->name, (const xmlChar *) TTS_TAG_CONFIG_BASE_TAG)) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] The wrong type, root node is NOT %s", TTS_TAG_CONFIG_BASE_TAG);
+               return -1;
+       }
+
+       cur = cur->xmlChildrenNode;
+       if (cur == NULL) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Empty document");
+               return -1;
+       }
+
+       while (cur != NULL) {
+               if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_CONFIG_ENGINE_ID)) {
+                       xmlNodeSetContent(cur, (const xmlChar *)engine_id);
+               }
+
+               if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_CONFIG_LANGUAGE)) {
+                       xmlNodeSetContent(cur, (const xmlChar *)language);
+               }
+
+               if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_CONFIG_ENGINE_SETTING)) {
+                       xmlNodeSetContent(cur, (const xmlChar *)setting);
+               }
+
+               if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_CONFIG_VOICE_TYPE)) {
+                       switch (type) {
+                       case TTS_CONFIG_VOICE_TYPE_MALE:        xmlNodeSetContent(cur, (const xmlChar*)TTS_TAG_VOICE_TYPE_MALE);        break;
+                       case TTS_CONFIG_VOICE_TYPE_FEMALE:      xmlNodeSetContent(cur, (const xmlChar*)TTS_TAG_VOICE_TYPE_FEMALE);      break;
+                       case TTS_CONFIG_VOICE_TYPE_CHILD:       xmlNodeSetContent(cur, (const xmlChar*)TTS_TAG_VOICE_TYPE_CHILD);       break;
+                       default:                                xmlNodeSetContent(cur, (const xmlChar*)TTS_TAG_VOICE_TYPE_FEMALE);      break;
+                       }
+               }
+               
+               cur = cur->next;
+       }
+
+       int ret = xmlSaveFile(TTS_CONFIG, g_config_doc);
+       if (0 > ret) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Save result : %d", ret);
+       }
+
+       return 0;
+}
+
+int tts_parser_set_voice(const char* language, int type)
+{
+       if (NULL == language) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Input parameter is NULL");
+               return -1;
+       }
+
+       xmlNodePtr cur = NULL;
+       cur = xmlDocGetRootElement(g_config_doc);
+       if (cur == NULL) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Empty document");
+               return -1;
+       }
+
+       if (xmlStrcmp(cur->name, (const xmlChar *) TTS_TAG_CONFIG_BASE_TAG)) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] The wrong type, root node is NOT %s", TTS_TAG_CONFIG_BASE_TAG);
+               return -1;
+       }
+
+       cur = cur->xmlChildrenNode;
+       if (cur == NULL) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Empty document");
+               return -1;
+       }
+
+       while (cur != NULL) {
+               if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_CONFIG_LANGUAGE)) {
+                       xmlNodeSetContent(cur, (const xmlChar *)language);
+               } 
+
+               if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_CONFIG_VOICE_TYPE)) {
+                       switch (type) {
+                       case TTS_CONFIG_VOICE_TYPE_MALE:        xmlNodeSetContent(cur, (const xmlChar*)TTS_TAG_VOICE_TYPE_MALE);        break;
+                       case TTS_CONFIG_VOICE_TYPE_FEMALE:      xmlNodeSetContent(cur, (const xmlChar*)TTS_TAG_VOICE_TYPE_FEMALE);      break;
+                       case TTS_CONFIG_VOICE_TYPE_CHILD:       xmlNodeSetContent(cur, (const xmlChar*)TTS_TAG_VOICE_TYPE_CHILD);       break;
+                       default:
+                               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Invalid type : %d", type);
+                               xmlNodeSetContent(cur, (const xmlChar*)TTS_TAG_VOICE_TYPE_FEMALE);
+                               break;
+                       }
+               }
+
+               cur = cur->next;
+       }
+
+       int ret = xmlSaveFile(TTS_CONFIG, g_config_doc);
+       if (0 > ret) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Save result : %d", ret);
+       }
+
+       return 0;
+}
+
+int tts_parser_set_auto_voice(bool value)
+{
+       xmlNodePtr cur = NULL;
+       cur = xmlDocGetRootElement(g_config_doc);
+       if (cur == NULL) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Empty document");
+               return -1;
+       }
+
+       if (xmlStrcmp(cur->name, (const xmlChar *) TTS_TAG_CONFIG_BASE_TAG)) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] The wrong type, root node is NOT %s", TTS_TAG_CONFIG_BASE_TAG);
+               return -1;
+       }
+
+       cur = cur->xmlChildrenNode;
+       if (cur == NULL) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Empty document");
+               return -1;
+       }
+
+       while (cur != NULL) {
+               if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_CONFIG_AUTO_VOICE)) {
+                       if (true == value) {
+                               xmlNodeSetContent(cur, (const xmlChar *)"on");
+                       } else if (false == value) {
+                               xmlNodeSetContent(cur, (const xmlChar *)"off");
+                       } else {
+                               SLOG(LOG_ERROR, tts_tag(), "[ERROR] The wrong value of auto voice");
+                               return -1;
+                       }
+                       break;
+               }
+               cur = cur->next;
+       }
+
+       int ret = xmlSaveFile(TTS_CONFIG, g_config_doc);
+       if (0 > ret) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Save result : %d", ret);
+       }
+
+       return 0;
+}
+
+int tts_parser_set_speech_rate(int value)
+{
+       xmlNodePtr cur = NULL;
+       cur = xmlDocGetRootElement(g_config_doc);
+       if (cur == NULL) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Empty document");
+               return -1;
+       }
+
+       if (xmlStrcmp(cur->name, (const xmlChar *) TTS_TAG_CONFIG_BASE_TAG)) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] The wrong type, root node is NOT %s", TTS_TAG_CONFIG_BASE_TAG);
+               return -1;
+       }
+
+       cur = cur->xmlChildrenNode;
+       if (cur == NULL) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Empty document");
+               return -1;
+       }
+
+       while (cur != NULL) {
+               if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_CONFIG_SPEECH_RATE)) {
+                       char temp[10];
+                       memset(temp, '\0', 10);
+                       snprintf(temp, 10, "%d", value);
+
+                       xmlNodeSetContent(cur, (const xmlChar *)temp);
+
+                       SLOG(LOG_DEBUG, tts_tag(), "Set speech rate : %s", temp);
+                       break;
+               }
+
+               cur = cur->next;
+       }
+
+       int ret = xmlSaveFile(TTS_CONFIG, g_config_doc);
+       if (0 > ret) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Save result : %d", ret);
+       }
+
+       return 0;
+}
+
+int tts_parser_set_pitch(int value)
+{
+       xmlNodePtr cur = NULL;
+       cur = xmlDocGetRootElement(g_config_doc);
+       if (cur == NULL) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Empty document");
+               return -1;
+       }
+
+       if (xmlStrcmp(cur->name, (const xmlChar *) TTS_TAG_CONFIG_BASE_TAG)) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] The wrong type, root node is NOT %s", TTS_TAG_CONFIG_BASE_TAG);
+               return -1;
+       }
+
+       cur = cur->xmlChildrenNode;
+       if (cur == NULL) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Empty document");
+               return -1;
+       }
+
+       while (cur != NULL) {
+               if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_CONFIG_PITCH)) {
+                       char temp[10];
+                       memset(temp, '\0', 10);
+                       snprintf(temp, 10, "%d", value);
+                       xmlNodeSetContent(cur, (const xmlChar *)temp);
+                       break;
+               } 
+
+               cur = cur->next;
+       }
+
+       int ret = xmlSaveFile(TTS_CONFIG, g_config_doc);
+       if (0 > ret) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Save result : %d", ret);
+       }
+
+       return 0;
+}
+
+int tts_parser_find_config_changed(char** engine, char**setting, bool* auto_voice, char** language, int* voice_type, 
+                                  int* speech_rate, int* pitch)
+{
+       if (NULL == engine || NULL == setting || NULL == language || NULL == voice_type || NULL == speech_rate) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Input parameter is NULL");
+               return -1;
+       }
+
+       xmlDocPtr doc = NULL;
+       xmlNodePtr cur_new = NULL;
+       xmlNodePtr cur_old = NULL;
+
+       xmlChar *key_new;
+       xmlChar *key_old;
+
+       int retry_count = 0;
+       while (NULL == doc) {
+               doc = xmlParseFile(TTS_CONFIG);
+               if (NULL != doc) {
+                       break;
+               }
+               retry_count++;
+               usleep(1000);
+
+               if (100 == retry_count) {
+                       SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to parse file error : %s", TTS_CONFIG);
+                       return -1;
+               }
+       }
+
+       cur_new = xmlDocGetRootElement(doc);
+       cur_old = xmlDocGetRootElement(g_config_doc);
+       if (cur_new == NULL || cur_old == NULL) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Empty document");
+               xmlFreeDoc(doc);
+               return -1;
+       }
+
+       if (xmlStrcmp(cur_new->name, (const xmlChar*)TTS_TAG_CONFIG_BASE_TAG) || 
+       xmlStrcmp(cur_old->name, (const xmlChar*)TTS_TAG_CONFIG_BASE_TAG)) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] The wrong type, root node is NOT %s", TTS_TAG_CONFIG_BASE_TAG);
+               xmlFreeDoc(doc);
+               return -1;
+       }
+
+       cur_new = cur_new->xmlChildrenNode;
+       cur_old = cur_old->xmlChildrenNode;
+       if (cur_new == NULL || cur_old == NULL) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Empty document");
+               xmlFreeDoc(doc);
+               return -1;
+       }
+
+       while (cur_new != NULL && cur_old != NULL) {
+               if (0 == xmlStrcmp(cur_new->name, (const xmlChar*)TTS_TAG_CONFIG_ENGINE_ID)) {
+                       if (0 == xmlStrcmp(cur_old->name, (const xmlChar*)TTS_TAG_CONFIG_ENGINE_ID)) {
+                               key_old = xmlNodeGetContent(cur_old);
+                               if (NULL != key_old) {
+                                       key_new = xmlNodeGetContent(cur_new);
+                                       if (NULL != key_new) {
+                                               if (0 != xmlStrcmp(key_old, key_new)) {
+                                                       SLOG(LOG_DEBUG, tts_tag(), "Old engine id(%s), New engine(%s)", 
+                                                               (char*)key_old, (char*)key_new);
+                                                       if (NULL != *engine)    free(*engine);
+                                                       *engine = strdup((char*)key_new);
+                                               }
+                                               xmlFree(key_new);
+                                       }
+                                       xmlFree(key_old);
+                               }
+                       } else {
+                               SLOG(LOG_ERROR, tts_tag(), "[ERROR] old config and new config are different");
+                       }
+               } else if (0 == xmlStrcmp(cur_new->name, (const xmlChar*)TTS_TAG_CONFIG_ENGINE_SETTING)) {
+                       if (0 == xmlStrcmp(cur_old->name, (const xmlChar*)TTS_TAG_CONFIG_ENGINE_SETTING)) {
+                               key_old = xmlNodeGetContent(cur_old);
+                               if (NULL != key_old) {
+                                       key_new = xmlNodeGetContent(cur_new);
+                                       if (NULL != key_new) {
+                                               if (0 != xmlStrcmp(key_old, key_new)) {
+                                                       SLOG(LOG_DEBUG, tts_tag(), "Old engine setting(%s), New engine setting(%s)", 
+                                                               (char*)key_old, (char*)key_new);
+                                                       if (NULL != *setting)   free(*setting);
+                                                       *setting = strdup((char*)key_new);
+                                               }
+                                               xmlFree(key_new);
+                                       }
+                                       xmlFree(key_old);
+                               }
+                       } else {
+                               SLOG(LOG_ERROR, tts_tag(), "[ERROR] old config and new config are different");
+                       }
+               } else if (0 == xmlStrcmp(cur_new->name, (const xmlChar*)TTS_TAG_CONFIG_AUTO_VOICE)) {
+                       if (0 == xmlStrcmp(cur_old->name, (const xmlChar*)TTS_TAG_CONFIG_AUTO_VOICE)) {
+                               key_old = xmlNodeGetContent(cur_old);
+                               if (NULL != key_old) {
+                                       key_new = xmlNodeGetContent(cur_new);
+                                       if (NULL != key_new) {
+                                               if (0 != xmlStrcmp(key_old, key_new)) {
+                                                       SLOG(LOG_DEBUG, tts_tag(), "Old auto voice (%s), New auto voice(%s)", 
+                                                               (char*)key_old, (char*)key_new);
+                                                       if (0 == xmlStrcmp((const xmlChar*)"on", key_new)) {
+                                                               *auto_voice = true;
+                                                       } else {
+                                                               *auto_voice = false;
+                                                       }
+                                               }
+                                               xmlFree(key_new);
+                                       }
+                                       xmlFree(key_old);
+                               }
+                       } else {
+                               SLOG(LOG_ERROR, tts_tag(), "[ERROR] old config and new config are different");
+                       }
+               } else if (0 == xmlStrcmp(cur_new->name, (const xmlChar*)TTS_TAG_CONFIG_LANGUAGE)) {
+                       if (0 == xmlStrcmp(cur_old->name, (const xmlChar*)TTS_TAG_CONFIG_LANGUAGE)) {
+                               key_old = xmlNodeGetContent(cur_old);
+                               if (NULL != key_old) {
+                                       key_new = xmlNodeGetContent(cur_new);
+                                       if (NULL != key_new) {
+                                               if (0 != xmlStrcmp(key_old, key_new)) {
+                                                       SLOG(LOG_DEBUG, tts_tag(), "Old language(%s), New language(%s)", 
+                                                               (char*)key_old, (char*)key_new);
+                                                       if (NULL != *language)  free(*language);
+                                                       *language = strdup((char*)key_new);
+                                               }
+                                               xmlFree(key_new);
+                                       }
+                                       xmlFree(key_old);
+                               }
+                       } else {
+                               SLOG(LOG_ERROR, tts_tag(), "[ERROR] old config and new config are different");
+                       }
+               } else if (0 == xmlStrcmp(cur_new->name, (const xmlChar*)TTS_TAG_CONFIG_VOICE_TYPE)) {
+                       if (0 == xmlStrcmp(cur_old->name, (const xmlChar*)TTS_TAG_CONFIG_VOICE_TYPE)) {
+                               key_old = xmlNodeGetContent(cur_old);
+                               if (NULL != key_old) {
+                                       key_new = xmlNodeGetContent(cur_new);
+                                       if (NULL != key_new) {
+                                               if (0 != xmlStrcmp(key_old, key_new)) {
+                                                       SLOG(LOG_DEBUG, tts_tag(), "Old voice type(%s), New voice type(%s)", 
+                                                               (char*)key_old, (char*)key_new);
+                                                       if (0 == xmlStrcmp(key_new, (const xmlChar *)TTS_TAG_VOICE_TYPE_FEMALE)) {
+                                                               *voice_type = (int)TTS_CONFIG_VOICE_TYPE_FEMALE;
+                                                       } else if (0 == xmlStrcmp(key_new, (const xmlChar *)TTS_TAG_VOICE_TYPE_MALE)) {
+                                                               *voice_type = (int)TTS_CONFIG_VOICE_TYPE_MALE;
+                                                       } else if (0 == xmlStrcmp(key_new, (const xmlChar *)TTS_TAG_VOICE_TYPE_CHILD)) {
+                                                               *voice_type = (int)TTS_CONFIG_VOICE_TYPE_CHILD;
+                                                       } else {
+                                                               SLOG(LOG_ERROR, tts_tag(), "[ERROR] New voice type is not valid");
+                                                       }
+                                               }
+                                               xmlFree(key_new);
+                                       }
+                                       xmlFree(key_old);
+                               }
+                       } else {
+                               SLOG(LOG_ERROR, tts_tag(), "[ERROR] old config and new config are different");
+                       }
+               } else if (0 == xmlStrcmp(cur_new->name, (const xmlChar*)TTS_TAG_CONFIG_SPEECH_RATE)) {
+                       if (0 == xmlStrcmp(cur_old->name, (const xmlChar*)TTS_TAG_CONFIG_SPEECH_RATE)) {
+                               key_old = xmlNodeGetContent(cur_old);
+                               if (NULL != key_old) {
+                                       key_new = xmlNodeGetContent(cur_new);
+                                       if (NULL != key_new) {
+                                               if (0 != xmlStrcmp(key_old, key_new)) {
+                                                       SLOG(LOG_DEBUG, tts_tag(), "Old speech rate(%s), New speech rate(%s)", 
+                                                               (char*)key_old, (char*)key_new);
+                                                       *speech_rate = atoi((char*)key_new);
+                                               }
+                                               xmlFree(key_new);
+                                       }
+                                       xmlFree(key_old);
+                               }
+                       } else {
+                               SLOG(LOG_ERROR, tts_tag(), "[ERROR] old config and new config are different");
+                       }
+               } else if (0 == xmlStrcmp(cur_new->name, (const xmlChar*)TTS_TAG_CONFIG_PITCH)) {
+                       if (0 == xmlStrcmp(cur_old->name, (const xmlChar*)TTS_TAG_CONFIG_PITCH)) {
+                               key_old = xmlNodeGetContent(cur_old);
+                               if (NULL != key_old) {
+                                       key_new = xmlNodeGetContent(cur_new);
+                                       if (NULL != key_new) {
+                                               if (0 != xmlStrcmp(key_old, key_new)) {
+                                                       SLOG(LOG_DEBUG, tts_tag(), "Old pitch(%s), New pitch(%s)", 
+                                                               (char*)key_old, (char*)key_new);
+                                                       *pitch = atoi((char*)key_new);
+                                               }
+                                               xmlFree(key_new);
+                                       }
+                                       xmlFree(key_old);
+                               }
+                       } else {
+                               SLOG(LOG_ERROR, tts_tag(), "[ERROR] old config and new config are different");
+                       }
+               } else {
+
+               }
+
+               cur_new = cur_new->next;
+               cur_old = cur_old->next;
+       }
+       
+       xmlFreeDoc(g_config_doc);
+       g_config_doc = doc;
+
+       return 0;
+}
\ No newline at end of file
diff --git a/common/tts_config_parser.h b/common/tts_config_parser.h
new file mode 100644 (file)
index 0000000..40cbf64
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+*  Copyright (c) 2011-2014 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 __TTS_CONFIG_PARSER_H_
+#define __TTS_CONFIG_PARSER_H_
+
+#include <glib.h>
+#include <libxml/parser.h>
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum {
+       TTS_CONFIG_VOICE_TYPE_MALE = 1,         /**< Male */
+       TTS_CONFIG_VOICE_TYPE_FEMALE = 2,       /**< Female */
+       TTS_CONFIG_VOICE_TYPE_CHILD = 3,        /**< Child */
+       TTS_CONFIG_VOICE_TYPE_USER_DEFINED = 4  /**< Engine defined */
+}tts_config_voice_type_e;
+
+typedef struct {
+       char*   language;
+       int     type;
+}tts_config_voice_s;
+
+typedef struct {
+       char*   name;
+       char*   uuid;
+       char*   setting;
+       GSList* voices;
+       bool    pitch_support;
+}tts_engine_info_s;
+
+typedef struct {
+       char*   engine_id;
+       char*   setting;
+       bool    auto_voice;
+       char*   language;
+       int     type;
+       int     speech_rate;
+       int     pitch;
+}tts_config_s;
+
+
+/* Get engine information */
+int tts_parser_get_engine_info(const char* path, tts_engine_info_s** engine_info);
+
+int tts_parser_free_engine_info(tts_engine_info_s* engine_info);
+
+
+int tts_parser_load_config(tts_config_s** config_info);
+
+int tts_parser_unload_config(tts_config_s* config_info);
+
+int tts_parser_set_engine(const char* engine_id, const char* setting, const char* language, int type);
+
+int tts_parser_set_voice(const char* language, int type);
+
+int tts_parser_set_auto_voice(bool value);
+
+int tts_parser_set_speech_rate(int value);
+
+int tts_parser_set_pitch(int value);
+
+int tts_parser_find_config_changed(char** engine, char**setting, bool* auto_voice, char** language, int* voice_type, 
+                                  int* speech_rate, int* pitch);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TTS_CONFIG_PARSER_H_ */
index 3597b1c..d7e98f5 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*  Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd All Rights Reserved 
+*  Copyright (c) 2011-2014 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
@@ -17,6 +17,7 @@
 
 /* For multi-user support */
 #include <tzplatform_config.h>
+#include <vconf.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -26,25 +27,21 @@ extern "C" {
 * Definition for IPC
 *******************************************************************************************/
 
-#define TTS_CLIENT_SERVICE_NAME         "com.samsung.voice.ttsclient"
-#define TTS_CLIENT_SERVICE_OBJECT_PATH "/com/samsung/voice/ttsclient"
-#define TTS_CLIENT_SERVICE_INTERFACE   "com.samsung.voice.ttsclient"
-
-#define TTS_SETTING_SERVICE_NAME       "com.samsung.voice.ttssetting"
-#define TTS_SETTING_SERVICE_OBJECT_PATH        "/com/samsung/voice/ttssetting"
-#define TTS_SETTING_SERVICE_INTERFACE  "com.samsung.voice.ttssetting"
+#define TTS_CLIENT_SERVICE_NAME         "org.tizen.voice.ttsclient"
+#define TTS_CLIENT_SERVICE_OBJECT_PATH "/org/tizen/voice/ttsclient"
+#define TTS_CLIENT_SERVICE_INTERFACE   "org.tizen.voice.ttsclient"
 
 #define TTS_SERVER_SERVICE_NAME                "service.connect.ttsserver"
-#define TTS_SERVER_SERVICE_OBJECT_PATH "/com/samsung/voice/ttsserver"
-#define TTS_SERVER_SERVICE_INTERFACE   "com.samsung.voice.ttsserver"
+#define TTS_SERVER_SERVICE_OBJECT_PATH "/org/tizen/voice/ttsserver"
+#define TTS_SERVER_SERVICE_INTERFACE   "org.tizen.voice.ttsserver"
 
 #define TTS_NOTI_SERVER_SERVICE_NAME           "service.connect.ttsnotiserver"
-#define TTS_NOTI_SERVER_SERVICE_OBJECT_PATH    "/com/samsung/voice/ttsnotiserver"
-#define TTS_NOTI_SERVER_SERVICE_INTERFACE      "com.samsung.voice.ttsnotiserver"
+#define TTS_NOTI_SERVER_SERVICE_OBJECT_PATH    "/org/tizen/voice/ttsnotiserver"
+#define TTS_NOTI_SERVER_SERVICE_INTERFACE      "org.tizen.voice.ttsnotiserver"
 
 #define TTS_SR_SERVER_SERVICE_NAME             "service.connect.ttssrserver"
-#define TTS_SR_SERVER_SERVICE_OBJECT_PATH      "/com/samsung/voice/ttssrserver"
-#define TTS_SR_SERVER_SERVICE_INTERFACE                "com.samsung.voice.ttssrserver"
+#define TTS_SR_SERVER_SERVICE_OBJECT_PATH      "/org/tizen/voice/ttssrserver"
+#define TTS_SR_SERVER_SERVICE_INTERFACE                "org.tizen.voice.ttssrserver"
 
 /******************************************************************************************
 * Message Definition for APIs
@@ -67,33 +64,56 @@ extern "C" {
 #define TTSD_METHOD_SET_STATE          "ttsd_method_set_state"
 #define TTSD_METHOD_GET_STATE          "ttsd_method_get_state"
 
-#define MESSAGE_FILE_PATH              tzplatform_mkpath(TZ_USER_HOME, ".voice/tts")
 
 /******************************************************************************************
-* Message Definition for Setting
+* Defines for configuration
 *******************************************************************************************/
 
-#define TTS_SETTING_METHOD_HELLO               "tts_setting_method_hello"
-#define TTS_SETTING_METHOD_INITIALIZE          "tts_setting_method_initialize"
-#define TTS_SETTING_METHOD_FINALIZE            "tts_setting_method_finalilze"
-#define TTS_SETTING_METHOD_GET_ENGINE_LIST     "tts_setting_method_get_engine_list"
-#define TTS_SETTING_METHOD_GET_ENGINE          "tts_setting_method_get_engine"
-#define TTS_SETTING_METHOD_SET_ENGINE          "tts_setting_method_set_engine"
-#define TTS_SETTING_METHOD_GET_VOICE_LIST      "tts_setting_method_get_voice_list"
-#define TTS_SETTING_METHOD_GET_DEFAULT_VOICE   "tts_setting_method_get_voice"
-#define TTS_SETTING_METHOD_SET_DEFAULT_VOICE   "tts_setting_method_set_voice"
-#define TTS_SETTING_METHOD_GET_DEFAULT_SPEED   "tts_setting_method_get_speed"
-#define TTS_SETTING_METHOD_SET_DEFAULT_SPEED   "tts_setting_method_set_speed"
-#define TTS_SETTING_METHOD_GET_ENGINE_SETTING  "tts_setting_method_get_engine_setting"
-#define TTS_SETTING_METHOD_SET_ENGINE_SETTING  "tts_setting_method_set_engine_setting"
-
-#if 0
+#define TTS_USR_BASE                   "/usr/lib/voice/tts/1.0"
+#define TTS_OPT_BASE                   "/opt/usr/data/voice/tts/1.0"
+
+#define TTS_DEFAULT_CONFIG             TTS_USR_BASE"/tts-config.xml"
+#define TTS_CONFIG                     tzplatform_mkpath(TZ_USER_HOME, ".voice/tts-config.xml")
+
+#define MESSAGE_FILE_PATH_ROOT         tzplatform_mkpath(TZ_USER_HOME, ".voice/")
+
+#define MESSAGE_FILE_PREFIX_DEFAULT            "ttsd_msg"
+#define MESSAGE_FILE_PREFIX_NOTIFICATION       "ttsdnoti_msg"
+#define MESSAGE_FILE_PREFIX_SCREEN_READER      "ttsdsr_msg"
+
+#define TTS_DEFAULT_ENGINE             TTS_USR_BASE"/engine"
+#define TTS_DOWNLOAD_ENGINE            TTS_OPT_BASE"/engine"
+
+#define TTS_DEFAULT_ENGINE_INFO                TTS_USR_BASE"/engine-info"
+#define TTS_DOWNLOAD_ENGINE_INFO       TTS_OPT_BASE"/engine-info"
+
+#define TTS_DEFAULT_ENGINE_SETTING     TTS_USR_BASE"/engine-setting"
+#define TTS_DOWNLOAD_ENGINE_SETTING    TTS_OPT_BASE"/engine-setting"
+
+#define TTS_BASE_LANGUAGE              "en_US"
+
+#define TTS_SPEED_MIN          1
+#define TTS_SPEED_NORMAL       8
+#define TTS_SPEED_MAX          15
+
+#define TTS_PITCH_MIN          1
+#define TTS_PITCH_NORMAL       8
+#define TTS_PITCH_MAX          15
+
+#define TTS_MAX_TEXT_SIZE      2000
+
+#define TTS_FEATURE_PATH       "tizen.org/feature/speech.synthesis"
+
 /******************************************************************************************
-* Message Definition for tts-daemon internal
+* Defines for vconf key
 *******************************************************************************************/
 
-#define TTSD_SIGNAL_NEXT_SYNTHESIS     "ttsd_signal_start_synthesis"
-#endif
+#define TTS_ACCESSIBILITY_KEY          VCONFKEY_SETAPPL_ACCESSIBILITY_TTS
+
+#define TTS_ACCESSIBILITY_SPEED_KEY    VCONFKEY_SETAPPL_ACCESSIBILITY_SPEECH_RATE
+
+#define TTS_LANGSET_KEY                        VCONFKEY_LANGSET
+
 
 #ifdef __cplusplus
 }
diff --git a/doc/doxyfile b/doc/doxyfile
new file mode 100644 (file)
index 0000000..7a944ac
--- /dev/null
@@ -0,0 +1,2370 @@
+# Doxyfile 1.8.7
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project.
+#
+# All text after a double hash (##) is considered a comment and is placed in
+# front of the TAG it is preceding.
+#
+# All text after a single hash (#) is considered a comment and will be ignored.
+# The format is:
+# TAG = value [value, ...]
+# For lists, items can also be appended using:
+# TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (\" \").
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# This tag specifies the encoding used for all characters in the config file
+# that follow. The default is UTF-8 which is also the encoding used for all text
+# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv
+# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv
+# for the list of possible encodings.
+# The default value is: UTF-8.
+
+DOXYFILE_ENCODING      = UTF-8
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by
+# double-quotes, unless you are using Doxywizard) that should identify the
+# project for which the documentation is generated. This name is used in the
+# title of most generated pages and in a few other places.
+# The default value is: My Project.
+
+PROJECT_NAME           = TTS
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
+# could be handy for archiving the generated documentation or if some version
+# control system is used.
+
+PROJECT_NUMBER         = 
+
+# Using the PROJECT_BRIEF tag one can provide an optional one line description
+# for a project that appears at the top of each page and should give viewer a
+# quick idea about the purpose of the project. Keep the description short.
+
+PROJECT_BRIEF          = 
+
+# With the PROJECT_LOGO tag one can specify an logo or icon that is included in
+# the documentation. The maximum height of the logo should not exceed 55 pixels
+# and the maximum width should not exceed 200 pixels. Doxygen will copy the logo
+# to the output directory.
+
+PROJECT_LOGO           = 
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path
+# into which the generated documentation will be written. If a relative path is
+# entered, it will be relative to the location where doxygen was started. If
+# left blank the current directory will be used.
+
+OUTPUT_DIRECTORY       = 
+
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 4096 sub-
+# directories (in 2 levels) under the output directory of each output format and
+# will distribute the generated files over these directories. Enabling this
+# option can be useful when feeding doxygen a huge amount of source files, where
+# putting all generated files in the same directory would otherwise causes
+# performance problems for the file system.
+# The default value is: NO.
+
+CREATE_SUBDIRS         = NO
+
+# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII
+# characters to appear in the names of generated files. If set to NO, non-ASCII
+# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode
+# U+3044.
+# The default value is: NO.
+
+ALLOW_UNICODE_NAMES    = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all
+# documentation generated by doxygen is written. Doxygen will use this
+# information to generate all constant output in the proper language.
+# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese,
+# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States),
+# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian,
+# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages),
+# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian,
+# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian,
+# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish,
+# Ukrainian and Vietnamese.
+# The default value is: English.
+
+OUTPUT_LANGUAGE        = English
+
+# If the BRIEF_MEMBER_DESC tag is set to YES doxygen will include brief member
+# descriptions after the members that are listed in the file and class
+# documentation (similar to Javadoc). Set to NO to disable this.
+# The default value is: YES.
+
+BRIEF_MEMBER_DESC      = YES
+
+# If the REPEAT_BRIEF tag is set to YES doxygen will prepend the brief
+# description of a member or function before the detailed description
+#
+# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
+# brief descriptions will be completely suppressed.
+# The default value is: YES.
+
+REPEAT_BRIEF           = YES
+
+# This tag implements a quasi-intelligent brief description abbreviator that is
+# used to form the text in various listings. Each string in this list, if found
+# as the leading text of the brief description, will be stripped from the text
+# and the result, after processing the whole list, is used as the annotated
+# text. Otherwise, the brief description is used as-is. If left blank, the
+# following values are used ($name is automatically replaced with the name of
+# the entity):The $name class, The $name widget, The $name file, is, provides,
+# specifies, contains, represents, a, an and the.
+
+ABBREVIATE_BRIEF       = "The $name class" \
+                         "The $name widget" \
+                         "The $name file" \
+                         is \
+                         provides \
+                         specifies \
+                         contains \
+                         represents \
+                         a \
+                         an \
+                         the
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
+# doxygen will generate a detailed section even if there is only a brief
+# description.
+# The default value is: NO.
+
+ALWAYS_DETAILED_SEC    = NO
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
+# inherited members of a class in the documentation of that class as if those
+# members were ordinary class members. Constructors, destructors and assignment
+# operators of the base classes will not be shown.
+# The default value is: NO.
+
+INLINE_INHERITED_MEMB  = NO
+
+# If the FULL_PATH_NAMES tag is set to YES doxygen will prepend the full path
+# before files name in the file list and in the header files. If set to NO the
+# shortest path that makes the file name unique will be used
+# The default value is: YES.
+
+FULL_PATH_NAMES        = YES
+
+# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path.
+# Stripping is only done if one of the specified strings matches the left-hand
+# part of the path. The tag can be used to show relative paths in the file list.
+# If left blank the directory from which doxygen is run is used as the path to
+# strip.
+#
+# Note that you can specify absolute paths here, but also relative paths, which
+# will be relative from the directory where doxygen is started.
+# This tag requires that the tag FULL_PATH_NAMES is set to YES.
+
+STRIP_FROM_PATH        = 
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the
+# path mentioned in the documentation of a class, which tells the reader which
+# header file to include in order to use a class. If left blank only the name of
+# the header file containing the class definition is used. Otherwise one should
+# specify the list of include paths that are normally passed to the compiler
+# using the -I flag.
+
+STRIP_FROM_INC_PATH    = 
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but
+# less readable) file names. This can be useful is your file systems doesn't
+# support long names like on DOS, Mac, or CD-ROM.
+# The default value is: NO.
+
+SHORT_NAMES            = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the
+# first line (until the first dot) of a Javadoc-style comment as the brief
+# description. If set to NO, the Javadoc-style will behave just like regular Qt-
+# style comments (thus requiring an explicit @brief command for a brief
+# description.)
+# The default value is: NO.
+
+JAVADOC_AUTOBRIEF      = NO
+
+# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first
+# line (until the first dot) of a Qt-style comment as the brief description. If
+# set to NO, the Qt-style will behave just like regular Qt-style comments (thus
+# requiring an explicit \brief command for a brief description.)
+# The default value is: NO.
+
+QT_AUTOBRIEF           = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a
+# multi-line C++ special comment block (i.e. a block of //! or /// comments) as
+# a brief description. This used to be the default behavior. The new default is
+# to treat a multi-line C++ comment block as a detailed description. Set this
+# tag to YES if you prefer the old behavior instead.
+#
+# Note that setting this tag to YES also means that rational rose comments are
+# not recognized any more.
+# The default value is: NO.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the
+# documentation from any documented member that it re-implements.
+# The default value is: YES.
+
+INHERIT_DOCS           = YES
+
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce a
+# new page for each member. If set to NO, the documentation of a member will be
+# part of the file/class/namespace that contains it.
+# The default value is: NO.
+
+SEPARATE_MEMBER_PAGES  = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen
+# uses this value to replace tabs by spaces in code fragments.
+# Minimum value: 1, maximum value: 16, default value: 4.
+
+TAB_SIZE               = 8
+
+# This tag can be used to specify a number of aliases that act as commands in
+# the documentation. An alias has the form:
+# name=value
+# For example adding
+# "sideeffect=@par Side Effects:\n"
+# will allow you to put the command \sideeffect (or @sideeffect) in the
+# documentation, which will result in a user-defined paragraph with heading
+# "Side Effects:". You can put \n's in the value part of an alias to insert
+# newlines.
+
+ALIASES                = 
+
+# This tag can be used to specify a number of word-keyword mappings (TCL only).
+# A mapping has the form "name=value". For example adding "class=itcl::class"
+# will allow you to use the command class in the itcl::class meaning.
+
+TCL_SUBST              = 
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources
+# only. Doxygen will then generate output that is more tailored for C. For
+# instance, some of the names that are used will be different. The list of all
+# members will be omitted, etc.
+# The default value is: NO.
+
+OPTIMIZE_OUTPUT_FOR_C  = YES
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or
+# Python sources only. Doxygen will then generate output that is more tailored
+# for that language. For instance, namespaces will be presented as packages,
+# qualified scopes will look different, etc.
+# The default value is: NO.
+
+OPTIMIZE_OUTPUT_JAVA   = NO
+
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
+# sources. Doxygen will then generate output that is tailored for Fortran.
+# The default value is: NO.
+
+OPTIMIZE_FOR_FORTRAN   = NO
+
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
+# sources. Doxygen will then generate output that is tailored for VHDL.
+# The default value is: NO.
+
+OPTIMIZE_OUTPUT_VHDL   = NO
+
+# Doxygen selects the parser to use depending on the extension of the files it
+# parses. With this tag you can assign which parser to use for a given
+# extension. Doxygen has a built-in mapping, but you can override or extend it
+# using this tag. The format is ext=language, where ext is a file extension, and
+# language is one of the parsers supported by doxygen: IDL, Java, Javascript,
+# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran:
+# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran:
+# Fortran. In the later case the parser tries to guess whether the code is fixed
+# or free formatted code, this is the default for Fortran type files), VHDL. For
+# instance to make doxygen treat .inc files as Fortran files (default is PHP),
+# and .f files as C (default is Fortran), use: inc=Fortran f=C.
+#
+# Note For files without extension you can use no_extension as a placeholder.
+#
+# Note that for custom extensions you also need to set FILE_PATTERNS otherwise
+# the files are not read by doxygen.
+
+EXTENSION_MAPPING      = 
+
+# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments
+# according to the Markdown format, which allows for more readable
+# documentation. See http://daringfireball.net/projects/markdown/ for details.
+# The output of markdown processing is further processed by doxygen, so you can
+# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in
+# case of backward compatibilities issues.
+# The default value is: YES.
+
+MARKDOWN_SUPPORT       = YES
+
+# When enabled doxygen tries to link words that correspond to documented
+# classes, or namespaces to their corresponding documentation. Such a link can
+# be prevented in individual cases by by putting a % sign in front of the word
+# or globally by setting AUTOLINK_SUPPORT to NO.
+# The default value is: YES.
+
+AUTOLINK_SUPPORT       = YES
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
+# to include (a tag file for) the STL sources as input, then you should set this
+# tag to YES in order to let doxygen match functions declarations and
+# definitions whose arguments contain STL classes (e.g. func(std::string);
+# versus func(std::string) {}). This also make the inheritance and collaboration
+# diagrams that involve STL classes more complete and accurate.
+# The default value is: NO.
+
+BUILTIN_STL_SUPPORT    = NO
+
+# If you use Microsoft's C++/CLI language, you should set this option to YES to
+# enable parsing support.
+# The default value is: NO.
+
+CPP_CLI_SUPPORT        = NO
+
+# Set the SIP_SUPPORT tag to YES if your project consists of sip (see:
+# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen
+# will parse them like normal C++ but will assume all classes use public instead
+# of private inheritance when no explicit protection keyword is present.
+# The default value is: NO.
+
+SIP_SUPPORT            = NO
+
+# For Microsoft's IDL there are propget and propput attributes to indicate
+# getter and setter methods for a property. Setting this option to YES will make
+# doxygen to replace the get and set methods by a property in the documentation.
+# This will only work if the methods are indeed getting or setting a simple
+# type. If this is not the case, or you want to show the methods anyway, you
+# should set this option to NO.
+# The default value is: YES.
+
+IDL_PROPERTY_SUPPORT   = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
+# tag is set to YES, then doxygen will reuse the documentation of the first
+# member in the group (if any) for the other members of the group. By default
+# all members of a group must be documented explicitly.
+# The default value is: NO.
+
+DISTRIBUTE_GROUP_DOC   = NO
+
+# Set the SUBGROUPING tag to YES to allow class member groups of the same type
+# (for instance a group of public functions) to be put as a subgroup of that
+# type (e.g. under the Public Functions section). Set it to NO to prevent
+# subgrouping. Alternatively, this can be done per class using the
+# \nosubgrouping command.
+# The default value is: YES.
+
+SUBGROUPING            = YES
+
+# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions
+# are shown inside the group in which they are included (e.g. using \ingroup)
+# instead of on a separate page (for HTML and Man pages) or section (for LaTeX
+# and RTF).
+#
+# Note that this feature does not work in combination with
+# SEPARATE_MEMBER_PAGES.
+# The default value is: NO.
+
+INLINE_GROUPED_CLASSES = NO
+
+# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions
+# with only public data fields or simple typedef fields will be shown inline in
+# the documentation of the scope in which they are defined (i.e. file,
+# namespace, or group documentation), provided this scope is documented. If set
+# to NO, structs, classes, and unions are shown on a separate page (for HTML and
+# Man pages) or section (for LaTeX and RTF).
+# The default value is: NO.
+
+INLINE_SIMPLE_STRUCTS  = NO
+
+# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or
+# enum is documented as struct, union, or enum with the name of the typedef. So
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
+# with name TypeT. When disabled the typedef will appear as a member of a file,
+# namespace, or class. And the struct will be named TypeS. This can typically be
+# useful for C code in case the coding convention dictates that all compound
+# types are typedef'ed and only the typedef is referenced, never the tag name.
+# The default value is: NO.
+
+TYPEDEF_HIDES_STRUCT   = NO
+
+# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This
+# cache is used to resolve symbols given their name and scope. Since this can be
+# an expensive process and often the same symbol appears multiple times in the
+# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small
+# doxygen will become slower. If the cache is too large, memory is wasted. The
+# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range
+# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536
+# symbols. At the end of a run doxygen will report the cache usage and suggest
+# the optimal cache size from a speed point of view.
+# Minimum value: 0, maximum value: 9, default value: 0.
+
+LOOKUP_CACHE_SIZE      = 0
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
+# documentation are documented, even if no documentation was available. Private
+# class members and static file members will be hidden unless the
+# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES.
+# Note: This will also disable the warnings about undocumented members that are
+# normally produced when WARNINGS is set to YES.
+# The default value is: NO.
+
+EXTRACT_ALL            = NO
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class will
+# be included in the documentation.
+# The default value is: NO.
+
+EXTRACT_PRIVATE        = NO
+
+# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal
+# scope will be included in the documentation.
+# The default value is: NO.
+
+EXTRACT_PACKAGE        = NO
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file will be
+# included in the documentation.
+# The default value is: NO.
+
+EXTRACT_STATIC         = NO
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) defined
+# locally in source files will be included in the documentation. If set to NO
+# only classes defined in header files are included. Does not have any effect
+# for Java sources.
+# The default value is: YES.
+
+EXTRACT_LOCAL_CLASSES  = YES
+
+# This flag is only useful for Objective-C code. When set to YES local methods,
+# which are defined in the implementation section but not in the interface are
+# included in the documentation. If set to NO only methods in the interface are
+# included.
+# The default value is: NO.
+
+EXTRACT_LOCAL_METHODS  = NO
+
+# If this flag is set to YES, the members of anonymous namespaces will be
+# extracted and appear in the documentation as a namespace called
+# 'anonymous_namespace{file}', where file will be replaced with the base name of
+# the file that contains the anonymous namespace. By default anonymous namespace
+# are hidden.
+# The default value is: NO.
+
+EXTRACT_ANON_NSPACES   = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all
+# undocumented members inside documented classes or files. If set to NO these
+# members will be included in the various overviews, but no documentation
+# section is generated. This option has no effect if EXTRACT_ALL is enabled.
+# The default value is: NO.
+
+HIDE_UNDOC_MEMBERS     = NO
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all
+# undocumented classes that are normally visible in the class hierarchy. If set
+# to NO these classes will be included in the various overviews. This option has
+# no effect if EXTRACT_ALL is enabled.
+# The default value is: NO.
+
+HIDE_UNDOC_CLASSES     = NO
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend
+# (class|struct|union) declarations. If set to NO these declarations will be
+# included in the documentation.
+# The default value is: NO.
+
+HIDE_FRIEND_COMPOUNDS  = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any
+# documentation blocks found inside the body of a function. If set to NO these
+# blocks will be appended to the function's detailed documentation block.
+# The default value is: NO.
+
+HIDE_IN_BODY_DOCS      = NO
+
+# The INTERNAL_DOCS tag determines if documentation that is typed after a
+# \internal command is included. If the tag is set to NO then the documentation
+# will be excluded. Set it to YES to include the internal documentation.
+# The default value is: NO.
+
+INTERNAL_DOCS          = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file
+# names in lower-case letters. If set to YES upper-case letters are also
+# allowed. This is useful if you have classes or files whose names only differ
+# in case and if your file system supports case sensitive file names. Windows
+# and Mac users are advised to set this option to NO.
+# The default value is: system dependent.
+
+CASE_SENSE_NAMES       = NO
+
+# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with
+# their full class and namespace scopes in the documentation. If set to YES the
+# scope will be hidden.
+# The default value is: NO.
+
+HIDE_SCOPE_NAMES       = YES
+
+# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of
+# the files that are included by a file in the documentation of that file.
+# The default value is: YES.
+
+SHOW_INCLUDE_FILES     = YES
+
+# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each
+# grouped member an include statement to the documentation, telling the reader
+# which file to include in order to use the member.
+# The default value is: NO.
+
+SHOW_GROUPED_MEMB_INC  = NO
+
+# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include
+# files with double quotes in the documentation rather than with sharp brackets.
+# The default value is: NO.
+
+FORCE_LOCAL_INCLUDES   = NO
+
+# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the
+# documentation for inline members.
+# The default value is: YES.
+
+INLINE_INFO            = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the
+# (detailed) documentation of file and class members alphabetically by member
+# name. If set to NO the members will appear in declaration order.
+# The default value is: YES.
+
+SORT_MEMBER_DOCS       = YES
+
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief
+# descriptions of file, namespace and class members alphabetically by member
+# name. If set to NO the members will appear in declaration order. Note that
+# this will also influence the order of the classes in the class list.
+# The default value is: NO.
+
+SORT_BRIEF_DOCS        = NO
+
+# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the
+# (brief and detailed) documentation of class members so that constructors and
+# destructors are listed first. If set to NO the constructors will appear in the
+# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS.
+# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief
+# member documentation.
+# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting
+# detailed member documentation.
+# The default value is: NO.
+
+SORT_MEMBERS_CTORS_1ST = NO
+
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy
+# of group names into alphabetical order. If set to NO the group names will
+# appear in their defined order.
+# The default value is: NO.
+
+SORT_GROUP_NAMES       = NO
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by
+# fully-qualified names, including namespaces. If set to NO, the class list will
+# be sorted only by class name, not including the namespace part.
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
+# Note: This option applies only to the class list, not to the alphabetical
+# list.
+# The default value is: NO.
+
+SORT_BY_SCOPE_NAME     = NO
+
+# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper
+# type resolution of all parameters of a function it will reject a match between
+# the prototype and the implementation of a member function even if there is
+# only one candidate or it is obvious which candidate to choose by doing a
+# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still
+# accept a match between prototype and implementation in such cases.
+# The default value is: NO.
+
+STRICT_PROTO_MATCHING  = NO
+
+# The GENERATE_TODOLIST tag can be used to enable ( YES) or disable ( NO) the
+# todo list. This list is created by putting \todo commands in the
+# documentation.
+# The default value is: YES.
+
+GENERATE_TODOLIST      = YES
+
+# The GENERATE_TESTLIST tag can be used to enable ( YES) or disable ( NO) the
+# test list. This list is created by putting \test commands in the
+# documentation.
+# The default value is: YES.
+
+GENERATE_TESTLIST      = YES
+
+# The GENERATE_BUGLIST tag can be used to enable ( YES) or disable ( NO) the bug
+# list. This list is created by putting \bug commands in the documentation.
+# The default value is: YES.
+
+GENERATE_BUGLIST       = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable ( YES) or disable ( NO)
+# the deprecated list. This list is created by putting \deprecated commands in
+# the documentation.
+# The default value is: YES.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# The ENABLED_SECTIONS tag can be used to enable conditional documentation
+# sections, marked by \if <section_label> ... \endif and \cond <section_label>
+# ... \endcond blocks.
+
+ENABLED_SECTIONS       = 
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the
+# initial value of a variable or macro / define can have for it to appear in the
+# documentation. If the initializer consists of more lines than specified here
+# it will be hidden. Use a value of 0 to hide initializers completely. The
+# appearance of the value of individual variables and macros / defines can be
+# controlled using \showinitializer or \hideinitializer command in the
+# documentation regardless of this setting.
+# Minimum value: 0, maximum value: 10000, default value: 30.
+
+MAX_INITIALIZER_LINES  = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at
+# the bottom of the documentation of classes and structs. If set to YES the list
+# will mention the files that were used to generate the documentation.
+# The default value is: YES.
+
+SHOW_USED_FILES        = YES
+
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This
+# will remove the Files entry from the Quick Index and from the Folder Tree View
+# (if specified).
+# The default value is: YES.
+
+SHOW_FILES             = YES
+
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces
+# page. This will remove the Namespaces entry from the Quick Index and from the
+# Folder Tree View (if specified).
+# The default value is: YES.
+
+SHOW_NAMESPACES        = YES
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that
+# doxygen should invoke to get the current version for each file (typically from
+# the version control system). Doxygen will invoke the program by executing (via
+# popen()) the command command input-file, where command is the value of the
+# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided
+# by doxygen. Whatever the program writes to standard output is used as the file
+# version. For an example see the documentation.
+
+FILE_VERSION_FILTER    = 
+
+# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed
+# by doxygen. The layout file controls the global structure of the generated
+# output files in an output format independent way. To create the layout file
+# that represents doxygen's defaults, run doxygen with the -l option. You can
+# optionally specify a file name after the option, if omitted DoxygenLayout.xml
+# will be used as the name of the layout file.
+#
+# Note that if you run doxygen from a directory containing a file called
+# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE
+# tag is left empty.
+
+LAYOUT_FILE            = 
+
+# The CITE_BIB_FILES tag can be used to specify one or more bib files containing
+# the reference definitions. This must be a list of .bib files. The .bib
+# extension is automatically appended if omitted. This requires the bibtex tool
+# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info.
+# For LaTeX the style of the bibliography can be controlled using
+# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the
+# search path. Do not use file names with spaces, bibtex cannot handle them. See
+# also \cite for info how to create references.
+
+CITE_BIB_FILES         = 
+
+#---------------------------------------------------------------------------
+# Configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated to
+# standard output by doxygen. If QUIET is set to YES this implies that the
+# messages are off.
+# The default value is: NO.
+
+QUIET                  = NO
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are
+# generated to standard error ( stderr) by doxygen. If WARNINGS is set to YES
+# this implies that the warnings are on.
+#
+# Tip: Turn warnings on while writing the documentation.
+# The default value is: YES.
+
+WARNINGS               = YES
+
+# If the WARN_IF_UNDOCUMENTED tag is set to YES, then doxygen will generate
+# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag
+# will automatically be disabled.
+# The default value is: YES.
+
+WARN_IF_UNDOCUMENTED   = YES
+
+# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for
+# potential errors in the documentation, such as not documenting some parameters
+# in a documented function, or documenting parameters that don't exist or using
+# markup commands wrongly.
+# The default value is: YES.
+
+WARN_IF_DOC_ERROR      = YES
+
+# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that
+# are documented, but have no documentation for their parameters or return
+# value. If set to NO doxygen will only warn about wrong or incomplete parameter
+# documentation, but not about the absence of documentation.
+# The default value is: NO.
+
+WARN_NO_PARAMDOC       = NO
+
+# The WARN_FORMAT tag determines the format of the warning messages that doxygen
+# can produce. The string should contain the $file, $line, and $text tags, which
+# will be replaced by the file and line number from which the warning originated
+# and the warning text. Optionally the format may contain $version, which will
+# be replaced by the version of the file (if it could be obtained via
+# FILE_VERSION_FILTER)
+# The default value is: $file:$line: $text.
+
+WARN_FORMAT            = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning and error
+# messages should be written. If left blank the output is written to standard
+# error (stderr).
+
+WARN_LOGFILE           = 
+
+#---------------------------------------------------------------------------
+# Configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag is used to specify the files and/or directories that contain
+# documented source files. You may enter file names like myfile.cpp or
+# directories like /usr/src/myproject. Separate the files or directories with
+# spaces.
+# Note: If this tag is empty the current directory is searched.
+
+INPUT                  = ../include/tts.h \
+                         uix_tts_doc.h
+
+# This tag can be used to specify the character encoding of the source files
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
+# libiconv (or the iconv built into libc) for the transcoding. See the libiconv
+# documentation (see: http://www.gnu.org/software/libiconv) for the list of
+# possible encodings.
+# The default value is: UTF-8.
+
+INPUT_ENCODING         = UTF-8
+
+# If the value of the INPUT tag contains directories, you can use the
+# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and
+# *.h) to filter out the source-files in the directories. If left blank the
+# following patterns are tested:*.c, *.cc, *.cxx, *.cpp, *.c++, *.java, *.ii,
+# *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, *.hh, *.hxx, *.hpp,
+# *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, *.m, *.markdown,
+# *.md, *.mm, *.dox, *.py, *.f90, *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf,
+# *.qsf, *.as and *.js.
+
+FILE_PATTERNS          = *.c \
+                         *.cc \
+                         *.cxx \
+                         *.cpp \
+                         *.c++ \
+                         *.d \
+                         *.java \
+                         *.ii \
+                         *.ixx \
+                         *.ipp \
+                         *.i++ \
+                         *.inl \
+                         *.h \
+                         *.hh \
+                         *.hxx \
+                         *.hpp \
+                         *.h++ \
+                         *.idl \
+                         *.odl \
+                         *.cs \
+                         *.php \
+                         *.php3 \
+                         *.inc \
+                         *.m \
+                         *.mm \
+                         *.dox \
+                         *.py \
+                         *.f90 \
+                         *.f \
+                         *.vhd \
+                         *.vhdl
+
+# The RECURSIVE tag can be used to specify whether or not subdirectories should
+# be searched for input files as well.
+# The default value is: NO.
+
+RECURSIVE              = NO
+
+# The EXCLUDE tag can be used to specify files and/or directories that should be
+# excluded from the INPUT source files. This way you can easily exclude a
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+#
+# Note that relative paths are relative to the directory from which doxygen is
+# run.
+
+EXCLUDE                = 
+
+# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
+# directories that are symbolic links (a Unix file system feature) are excluded
+# from the input.
+# The default value is: NO.
+
+EXCLUDE_SYMLINKS       = NO
+
+# If the value of the INPUT tag contains directories, you can use the
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
+# certain files from those directories.
+#
+# Note that the wildcards are matched against the file with absolute path, so to
+# exclude all test directories for example use the pattern */test/*
+
+EXCLUDE_PATTERNS       = 
+
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
+# (namespaces, classes, functions, etc.) that should be excluded from the
+# output. The symbol name can be a fully qualified name, a word, or if the
+# wildcard * is used, a substring. Examples: ANamespace, AClass,
+# AClass::ANamespace, ANamespace::*Test
+#
+# Note that the wildcards are matched against the file with absolute path, so to
+# exclude all test directories use the pattern */test/*
+
+EXCLUDE_SYMBOLS        = 
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or directories
+# that contain example code fragments that are included (see the \include
+# command).
+
+EXAMPLE_PATH           = 
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and
+# *.h) to filter out the source-files in the directories. If left blank all
+# files are included.
+
+EXAMPLE_PATTERNS       = *
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
+# searched for input files to be used with the \include or \dontinclude commands
+# irrespective of the value of the RECURSIVE tag.
+# The default value is: NO.
+
+EXAMPLE_RECURSIVE      = NO
+
+# The IMAGE_PATH tag can be used to specify one or more files or directories
+# that contain images that are to be included in the documentation (see the
+# \image command).
+
+IMAGE_PATH             = images/capi_uix_tts_state_diagram.png
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should
+# invoke to filter for each input file. Doxygen will invoke the filter program
+# by executing (via popen()) the command:
+#
+# <filter> <input-file>
+#
+# where <filter> is the value of the INPUT_FILTER tag, and <input-file> is the
+# name of an input file. Doxygen will then use the output that the filter
+# program writes to standard output. If FILTER_PATTERNS is specified, this tag
+# will be ignored.
+#
+# Note that the filter must not add or remove lines; it is applied before the
+# code is scanned, but not when the output code is generated. If lines are added
+# or removed, the anchors will not be placed correctly.
+
+INPUT_FILTER           = 
+
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
+# basis. Doxygen will compare the file name with each pattern and apply the
+# filter if there is a match. The filters are a list of the form: pattern=filter
+# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how
+# filters are used. If the FILTER_PATTERNS tag is empty or if none of the
+# patterns match the file name, INPUT_FILTER is applied.
+
+FILTER_PATTERNS        = 
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
+# INPUT_FILTER ) will also be used to filter the input files that are used for
+# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES).
+# The default value is: NO.
+
+FILTER_SOURCE_FILES    = NO
+
+# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file
+# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and
+# it is also possible to disable source filtering for a specific pattern using
+# *.ext= (so without naming a filter).
+# This tag requires that the tag FILTER_SOURCE_FILES is set to YES.
+
+FILTER_SOURCE_PATTERNS = 
+
+# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that
+# is part of the input, its contents will be placed on the main page
+# (index.html). This can be useful if you have a project on for instance GitHub
+# and want to reuse the introduction page also for the doxygen output.
+
+USE_MDFILE_AS_MAINPAGE = 
+
+#---------------------------------------------------------------------------
+# Configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will be
+# generated. Documented entities will be cross-referenced with these sources.
+#
+# Note: To get rid of all source code in the generated output, make sure that
+# also VERBATIM_HEADERS is set to NO.
+# The default value is: NO.
+
+SOURCE_BROWSER         = NO
+
+# Setting the INLINE_SOURCES tag to YES will include the body of functions,
+# classes and enums directly into the documentation.
+# The default value is: NO.
+
+INLINE_SOURCES         = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any
+# special comment blocks from generated source code fragments. Normal C, C++ and
+# Fortran comments will always remain visible.
+# The default value is: YES.
+
+STRIP_CODE_COMMENTS    = YES
+
+# If the REFERENCED_BY_RELATION tag is set to YES then for each documented
+# function all documented functions referencing it will be listed.
+# The default value is: NO.
+
+REFERENCED_BY_RELATION = NO
+
+# If the REFERENCES_RELATION tag is set to YES then for each documented function
+# all documented entities called/used by that function will be listed.
+# The default value is: NO.
+
+REFERENCES_RELATION    = NO
+
+# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set
+# to YES, then the hyperlinks from functions in REFERENCES_RELATION and
+# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will
+# link to the documentation.
+# The default value is: YES.
+
+REFERENCES_LINK_SOURCE = YES
+
+# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the
+# source code will show a tooltip with additional information such as prototype,
+# brief description and links to the definition and documentation. Since this
+# will make the HTML file larger and loading of large files a bit slower, you
+# can opt to disable this feature.
+# The default value is: YES.
+# This tag requires that the tag SOURCE_BROWSER is set to YES.
+
+SOURCE_TOOLTIPS        = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code will
+# point to the HTML generated by the htags(1) tool instead of doxygen built-in
+# source browser. The htags tool is part of GNU's global source tagging system
+# (see http://www.gnu.org/software/global/global.html). You will need version
+# 4.8.6 or higher.
+#
+# To use it do the following:
+# - Install the latest version of global
+# - Enable SOURCE_BROWSER and USE_HTAGS in the config file
+# - Make sure the INPUT points to the root of the source tree
+# - Run doxygen as normal
+#
+# Doxygen will invoke htags (and that will in turn invoke gtags), so these
+# tools must be available from the command line (i.e. in the search path).
+#
+# The result: instead of the source browser generated by doxygen, the links to
+# source code will now point to the output of htags.
+# The default value is: NO.
+# This tag requires that the tag SOURCE_BROWSER is set to YES.
+
+USE_HTAGS              = NO
+
+# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a
+# verbatim copy of the header file for each class for which an include is
+# specified. Set to NO to disable this.
+# See also: Section \class.
+# The default value is: YES.
+
+VERBATIM_HEADERS       = YES
+
+# If the CLANG_ASSISTED_PARSING tag is set to YES, then doxygen will use the
+# clang parser (see: http://clang.llvm.org/) for more accurate parsing at the
+# cost of reduced performance. This can be particularly helpful with template
+# rich C++ code for which doxygen's built-in parser lacks the necessary type
+# information.
+# Note: The availability of this option depends on whether or not doxygen was
+# compiled with the --with-libclang option.
+# The default value is: NO.
+
+CLANG_ASSISTED_PARSING = NO
+
+# If clang assisted parsing is enabled you can provide the compiler with command
+# line options that you would normally use when invoking the compiler. Note that
+# the include paths will already be set by doxygen for the files and directories
+# specified with INPUT and INCLUDE_PATH.
+# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES.
+
+CLANG_OPTIONS          = 
+
+#---------------------------------------------------------------------------
+# Configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all
+# compounds will be generated. Enable this if the project contains a lot of
+# classes, structs, unions or interfaces.
+# The default value is: YES.
+
+ALPHABETICAL_INDEX     = YES
+
+# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in
+# which the alphabetical index list will be split.
+# Minimum value: 1, maximum value: 20, default value: 5.
+# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.
+
+COLS_IN_ALPHA_INDEX    = 5
+
+# In case all classes in a project start with a common prefix, all classes will
+# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag
+# can be used to specify a prefix (or a list of prefixes) that should be ignored
+# while generating the index headers.
+# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.
+
+IGNORE_PREFIX          = 
+
+#---------------------------------------------------------------------------
+# Configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES doxygen will generate HTML output
+# The default value is: YES.
+
+GENERATE_HTML          = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it.
+# The default directory is: html.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_OUTPUT            = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each
+# generated HTML page (for example: .htm, .php, .asp).
+# The default value is: .html.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_FILE_EXTENSION    = .html
+
+# The HTML_HEADER tag can be used to specify a user-defined HTML header file for
+# each generated HTML page. If the tag is left blank doxygen will generate a
+# standard header.
+#
+# To get valid HTML the header file that includes any scripts and style sheets
+# that doxygen needs, which is dependent on the configuration options used (e.g.
+# the setting GENERATE_TREEVIEW). It is highly recommended to start with a
+# default header using
+# doxygen -w html new_header.html new_footer.html new_stylesheet.css
+# YourConfigFile
+# and then modify the file new_header.html. See also section "Doxygen usage"
+# for information on how to generate the default header that doxygen normally
+# uses.
+# Note: The header is subject to change so you typically have to regenerate the
+# default header when upgrading to a newer version of doxygen. For a description
+# of the possible markers and block names see the documentation.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_HEADER            = 
+
+# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each
+# generated HTML page. If the tag is left blank doxygen will generate a standard
+# footer. See HTML_HEADER for more information on how to generate a default
+# footer and what special commands can be used inside the footer. See also
+# section "Doxygen usage" for information on how to generate the default footer
+# that doxygen normally uses.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_FOOTER            = 
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style
+# sheet that is used by each HTML page. It can be used to fine-tune the look of
+# the HTML output. If left blank doxygen will generate a default style sheet.
+# See also section "Doxygen usage" for information on how to generate the style
+# sheet that doxygen normally uses.
+# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as
+# it is more robust and this tag (HTML_STYLESHEET) will in the future become
+# obsolete.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_STYLESHEET        = 
+
+# The HTML_EXTRA_STYLESHEET tag can be used to specify an additional user-
+# defined cascading style sheet that is included after the standard style sheets
+# created by doxygen. Using this option one can overrule certain style aspects.
+# This is preferred over using HTML_STYLESHEET since it does not replace the
+# standard style sheet and is therefor more robust against future updates.
+# Doxygen will copy the style sheet file to the output directory. For an example
+# see the documentation.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_EXTRA_STYLESHEET  = 
+
+# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
+# other source files which should be copied to the HTML output directory. Note
+# that these files will be copied to the base HTML output directory. Use the
+# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these
+# files. In the HTML_STYLESHEET file, use the file name only. Also note that the
+# files will be copied as-is; there are no commands or markers available.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_EXTRA_FILES       = 
+
+# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen
+# will adjust the colors in the stylesheet and background images according to
+# this color. Hue is specified as an angle on a colorwheel, see
+# http://en.wikipedia.org/wiki/Hue for more information. For instance the value
+# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300
+# purple, and 360 is red again.
+# Minimum value: 0, maximum value: 359, default value: 220.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_COLORSTYLE_HUE    = 220
+
+# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors
+# in the HTML output. For a value of 0 the output will use grayscales only. A
+# value of 255 will produce the most vivid colors.
+# Minimum value: 0, maximum value: 255, default value: 100.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_COLORSTYLE_SAT    = 100
+
+# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the
+# luminance component of the colors in the HTML output. Values below 100
+# gradually make the output lighter, whereas values above 100 make the output
+# darker. The value divided by 100 is the actual gamma applied, so 80 represents
+# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not
+# change the gamma.
+# Minimum value: 40, maximum value: 240, default value: 80.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_COLORSTYLE_GAMMA  = 80
+
+# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML
+# page will contain the date and time when the page was generated. Setting this
+# to NO can help when comparing the output of multiple runs.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_TIMESTAMP         = YES
+
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
+# documentation will contain sections that can be hidden and shown after the
+# page has loaded.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_DYNAMIC_SECTIONS  = NO
+
+# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries
+# shown in the various tree structured indices initially; the user can expand
+# and collapse entries dynamically later on. Doxygen will expand the tree to
+# such a level that at most the specified number of entries are visible (unless
+# a fully collapsed tree already exceeds this amount). So setting the number of
+# entries 1 will produce a full collapsed tree by default. 0 is a special value
+# representing an infinite number of entries and will result in a full expanded
+# tree by default.
+# Minimum value: 0, maximum value: 9999, default value: 100.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_INDEX_NUM_ENTRIES = 100
+
+# If the GENERATE_DOCSET tag is set to YES, additional index files will be
+# generated that can be used as input for Apple's Xcode 3 integrated development
+# environment (see: http://developer.apple.com/tools/xcode/), introduced with
+# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a
+# Makefile in the HTML output directory. Running make will produce the docset in
+# that directory and running make install will install the docset in
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at
+# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html
+# for more information.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+GENERATE_DOCSET        = NO
+
+# This tag determines the name of the docset feed. A documentation feed provides
+# an umbrella under which multiple documentation sets from a single provider
+# (such as a company or product suite) can be grouped.
+# The default value is: Doxygen generated docs.
+# This tag requires that the tag GENERATE_DOCSET is set to YES.
+
+DOCSET_FEEDNAME        = "Doxygen generated docs"
+
+# This tag specifies a string that should uniquely identify the documentation
+# set bundle. This should be a reverse domain-name style string, e.g.
+# com.mycompany.MyDocSet. Doxygen will append .docset to the name.
+# The default value is: org.doxygen.Project.
+# This tag requires that the tag GENERATE_DOCSET is set to YES.
+
+DOCSET_BUNDLE_ID       = org.doxygen.Project
+
+# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify
+# the documentation publisher. This should be a reverse domain-name style
+# string, e.g. com.mycompany.MyDocSet.documentation.
+# The default value is: org.doxygen.Publisher.
+# This tag requires that the tag GENERATE_DOCSET is set to YES.
+
+DOCSET_PUBLISHER_ID    = org.doxygen.Publisher
+
+# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher.
+# The default value is: Publisher.
+# This tag requires that the tag GENERATE_DOCSET is set to YES.
+
+DOCSET_PUBLISHER_NAME  = Publisher
+
+# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three
+# additional HTML index files: index.hhp, index.hhc, and index.hhk. The
+# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop
+# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on
+# Windows.
+#
+# The HTML Help Workshop contains a compiler that can convert all HTML output
+# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML
+# files are now used as the Windows 98 help format, and will replace the old
+# Windows help format (.hlp) on all Windows platforms in the future. Compressed
+# HTML files also contain an index, a table of contents, and you can search for
+# words in the documentation. The HTML workshop also contains a viewer for
+# compressed HTML files.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+GENERATE_HTMLHELP      = NO
+
+# The CHM_FILE tag can be used to specify the file name of the resulting .chm
+# file. You can add a path in front of the file if the result should not be
+# written to the html output directory.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+CHM_FILE               = 
+
+# The HHC_LOCATION tag can be used to specify the location (absolute path
+# including file name) of the HTML help compiler ( hhc.exe). If non-empty
+# doxygen will try to run the HTML help compiler on the generated index.hhp.
+# The file has to be specified with full path.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+HHC_LOCATION           = 
+
+# The GENERATE_CHI flag controls if a separate .chi index file is generated (
+# YES) or that it should be included in the master .chm file ( NO).
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+GENERATE_CHI           = NO
+
+# The CHM_INDEX_ENCODING is used to encode HtmlHelp index ( hhk), content ( hhc)
+# and project file content.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+CHM_INDEX_ENCODING     = 
+
+# The BINARY_TOC flag controls whether a binary table of contents is generated (
+# YES) or a normal table of contents ( NO) in the .chm file. Furthermore it
+# enables the Previous and Next buttons.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+BINARY_TOC             = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members to
+# the table of contents of the HTML help documentation and to the tree view.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+TOC_EXPAND             = NO
+
+# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and
+# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that
+# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help
+# (.qch) of the generated HTML documentation.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+GENERATE_QHP           = NO
+
+# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify
+# the file name of the resulting .qch file. The path specified is relative to
+# the HTML output folder.
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QCH_FILE               = 
+
+# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help
+# Project output. For more information please see Qt Help Project / Namespace
+# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace).
+# The default value is: org.doxygen.Project.
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHP_NAMESPACE          = org.doxygen.Project
+
+# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt
+# Help Project output. For more information please see Qt Help Project / Virtual
+# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual-
+# folders).
+# The default value is: doc.
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHP_VIRTUAL_FOLDER     = doc
+
+# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom
+# filter to add. For more information please see Qt Help Project / Custom
+# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-
+# filters).
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHP_CUST_FILTER_NAME   = 
+
+# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the
+# custom filter to add. For more information please see Qt Help Project / Custom
+# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-
+# filters).
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHP_CUST_FILTER_ATTRS  = 
+
+# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this
+# project's filter section matches. Qt Help Project / Filter Attributes (see:
+# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes).
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHP_SECT_FILTER_ATTRS  = 
+
+# The QHG_LOCATION tag can be used to specify the location of Qt's
+# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the
+# generated .qhp file.
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHG_LOCATION           = 
+
+# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be
+# generated, together with the HTML files, they form an Eclipse help plugin. To
+# install this plugin and make it available under the help contents menu in
+# Eclipse, the contents of the directory containing the HTML and XML files needs
+# to be copied into the plugins directory of eclipse. The name of the directory
+# within the plugins directory should be the same as the ECLIPSE_DOC_ID value.
+# After copying Eclipse needs to be restarted before the help appears.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+GENERATE_ECLIPSEHELP   = NO
+
+# A unique identifier for the Eclipse help plugin. When installing the plugin
+# the directory name containing the HTML and XML files should also have this
+# name. Each documentation set should have its own identifier.
+# The default value is: org.doxygen.Project.
+# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES.
+
+ECLIPSE_DOC_ID         = org.doxygen.Project
+
+# If you want full control over the layout of the generated HTML pages it might
+# be necessary to disable the index and replace it with your own. The
+# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top
+# of each HTML page. A value of NO enables the index and the value YES disables
+# it. Since the tabs in the index contain the same information as the navigation
+# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+DISABLE_INDEX          = NO
+
+# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
+# structure should be generated to display hierarchical information. If the tag
+# value is set to YES, a side panel will be generated containing a tree-like
+# index structure (just like the one that is generated for HTML Help). For this
+# to work a browser that supports JavaScript, DHTML, CSS and frames is required
+# (i.e. any modern browser). Windows users are probably better off using the
+# HTML help feature. Via custom stylesheets (see HTML_EXTRA_STYLESHEET) one can
+# further fine-tune the look of the index. As an example, the default style
+# sheet generated by doxygen has an example that shows how to put an image at
+# the root of the tree instead of the PROJECT_NAME. Since the tree basically has
+# the same information as the tab index, you could consider setting
+# DISABLE_INDEX to YES when enabling this option.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+GENERATE_TREEVIEW      = NO
+
+# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that
+# doxygen will group on one line in the generated HTML documentation.
+#
+# Note that a value of 0 will completely suppress the enum values from appearing
+# in the overview section.
+# Minimum value: 0, maximum value: 20, default value: 4.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+ENUM_VALUES_PER_LINE   = 4
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used
+# to set the initial width (in pixels) of the frame in which the tree is shown.
+# Minimum value: 0, maximum value: 1500, default value: 250.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+TREEVIEW_WIDTH         = 250
+
+# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open links to
+# external symbols imported via tag files in a separate window.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+EXT_LINKS_IN_WINDOW    = NO
+
+# Use this tag to change the font size of LaTeX formulas included as images in
+# the HTML documentation. When you change the font size after a successful
+# doxygen run you need to manually remove any form_*.png images from the HTML
+# output directory to force them to be regenerated.
+# Minimum value: 8, maximum value: 50, default value: 10.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+FORMULA_FONTSIZE       = 10
+
+# Use the FORMULA_TRANPARENT tag to determine whether or not the images
+# generated for formulas are transparent PNGs. Transparent PNGs are not
+# supported properly for IE 6.0, but are supported on all modern browsers.
+#
+# Note that when changing this option you need to delete any form_*.png files in
+# the HTML output directory before the changes have effect.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+FORMULA_TRANSPARENT    = YES
+
+# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see
+# http://www.mathjax.org) which uses client side Javascript for the rendering
+# instead of using prerendered bitmaps. Use this if you do not have LaTeX
+# installed or if you want to formulas look prettier in the HTML output. When
+# enabled you may also need to install MathJax separately and configure the path
+# to it using the MATHJAX_RELPATH option.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+USE_MATHJAX            = NO
+
+# When MathJax is enabled you can set the default output format to be used for
+# the MathJax output. See the MathJax site (see:
+# http://docs.mathjax.org/en/latest/output.html) for more details.
+# Possible values are: HTML-CSS (which is slower, but has the best
+# compatibility), NativeMML (i.e. MathML) and SVG.
+# The default value is: HTML-CSS.
+# This tag requires that the tag USE_MATHJAX is set to YES.
+
+MATHJAX_FORMAT         = HTML-CSS
+
+# When MathJax is enabled you need to specify the location relative to the HTML
+# output directory using the MATHJAX_RELPATH option. The destination directory
+# should contain the MathJax.js script. For instance, if the mathjax directory
+# is located at the same level as the HTML output directory, then
+# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax
+# Content Delivery Network so you can quickly see the result without installing
+# MathJax. However, it is strongly recommended to install a local copy of
+# MathJax from http://www.mathjax.org before deployment.
+# The default value is: http://cdn.mathjax.org/mathjax/latest.
+# This tag requires that the tag USE_MATHJAX is set to YES.
+
+MATHJAX_RELPATH        = http://cdn.mathjax.org/mathjax/latest
+
+# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax
+# extension names that should be enabled during MathJax rendering. For example
+# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols
+# This tag requires that the tag USE_MATHJAX is set to YES.
+
+MATHJAX_EXTENSIONS     = 
+
+# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces
+# of code that will be used on startup of the MathJax code. See the MathJax site
+# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an
+# example see the documentation.
+# This tag requires that the tag USE_MATHJAX is set to YES.
+
+MATHJAX_CODEFILE       = 
+
+# When the SEARCHENGINE tag is enabled doxygen will generate a search box for
+# the HTML output. The underlying search engine uses javascript and DHTML and
+# should work on any modern browser. Note that when using HTML help
+# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET)
+# there is already a search function so this one should typically be disabled.
+# For large projects the javascript based search engine can be slow, then
+# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to
+# search using the keyboard; to jump to the search box use <access key> + S
+# (what the <access key> is depends on the OS and browser, but it is typically
+# <CTRL>, <ALT>/<option>, or both). Inside the search box use the <cursor down
+# key> to jump into the search results window, the results can be navigated
+# using the <cursor keys>. Press <Enter> to select an item or <escape> to cancel
+# the search. The filter options can be selected when the cursor is inside the
+# search box by pressing <Shift>+<cursor down>. Also here use the <cursor keys>
+# to select a filter and <Enter> or <escape> to activate or cancel the filter
+# option.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+SEARCHENGINE           = YES
+
+# When the SERVER_BASED_SEARCH tag is enabled the search engine will be
+# implemented using a web server instead of a web client using Javascript. There
+# are two flavors of web server based searching depending on the EXTERNAL_SEARCH
+# setting. When disabled, doxygen will generate a PHP script for searching and
+# an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing
+# and searching needs to be provided by external tools. See the section
+# "External Indexing and Searching" for details.
+# The default value is: NO.
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+SERVER_BASED_SEARCH    = NO
+
+# When EXTERNAL_SEARCH tag is enabled doxygen will no longer generate the PHP
+# script for searching. Instead the search results are written to an XML file
+# which needs to be processed by an external indexer. Doxygen will invoke an
+# external search engine pointed to by the SEARCHENGINE_URL option to obtain the
+# search results.
+#
+# Doxygen ships with an example indexer ( doxyindexer) and search engine
+# (doxysearch.cgi) which are based on the open source search engine library
+# Xapian (see: http://xapian.org/).
+#
+# See the section "External Indexing and Searching" for details.
+# The default value is: NO.
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+EXTERNAL_SEARCH        = NO
+
+# The SEARCHENGINE_URL should point to a search engine hosted by a web server
+# which will return the search results when EXTERNAL_SEARCH is enabled.
+#
+# Doxygen ships with an example indexer ( doxyindexer) and search engine
+# (doxysearch.cgi) which are based on the open source search engine library
+# Xapian (see: http://xapian.org/). See the section "External Indexing and
+# Searching" for details.
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+SEARCHENGINE_URL       = 
+
+# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed
+# search data is written to a file for indexing by an external tool. With the
+# SEARCHDATA_FILE tag the name of this file can be specified.
+# The default file is: searchdata.xml.
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+SEARCHDATA_FILE        = searchdata.xml
+
+# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the
+# EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is
+# useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple
+# projects and redirect the results back to the right project.
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+EXTERNAL_SEARCH_ID     = 
+
+# The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen
+# projects other than the one defined by this configuration file, but that are
+# all added to the same external search index. Each project needs to have a
+# unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id of
+# to a relative location where the documentation can be found. The format is:
+# EXTRA_SEARCH_MAPPINGS = tagname1=loc1 tagname2=loc2 ...
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+EXTRA_SEARCH_MAPPINGS  = 
+
+#---------------------------------------------------------------------------
+# Configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES doxygen will generate LaTeX output.
+# The default value is: YES.
+
+GENERATE_LATEX         = NO
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it.
+# The default directory is: latex.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_OUTPUT           = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
+# invoked.
+#
+# Note that when enabling USE_PDFLATEX this option is only used for generating
+# bitmaps for formulas in the HTML output, but not in the Makefile that is
+# written to the output directory.
+# The default file is: latex.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_CMD_NAME         = latex
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to generate
+# index for LaTeX.
+# The default file is: makeindex.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+MAKEINDEX_CMD_NAME     = makeindex
+
+# If the COMPACT_LATEX tag is set to YES doxygen generates more compact LaTeX
+# documents. This may be useful for small projects and may help to save some
+# trees in general.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+COMPACT_LATEX          = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used by the
+# printer.
+# Possible values are: a4 (210 x 297 mm), letter (8.5 x 11 inches), legal (8.5 x
+# 14 inches) and executive (7.25 x 10.5 inches).
+# The default value is: a4.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+PAPER_TYPE             = a4wide
+
+# The EXTRA_PACKAGES tag can be used to specify one or more LaTeX package names
+# that should be included in the LaTeX output. To get the times font for
+# instance you can specify
+# EXTRA_PACKAGES=times
+# If left blank no extra packages will be included.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+EXTRA_PACKAGES         = 
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for the
+# generated LaTeX document. The header should contain everything until the first
+# chapter. If it is left blank doxygen will generate a standard header. See
+# section "Doxygen usage" for information on how to let doxygen write the
+# default header to a separate file.
+#
+# Note: Only use a user-defined header if you know what you are doing! The
+# following commands have a special meaning inside the header: $title,
+# $datetime, $date, $doxygenversion, $projectname, $projectnumber. Doxygen will
+# replace them by respectively the title of the page, the current date and time,
+# only the current date, the version number of doxygen, the project name (see
+# PROJECT_NAME), or the project number (see PROJECT_NUMBER).
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_HEADER           = 
+
+# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for the
+# generated LaTeX document. The footer should contain everything after the last
+# chapter. If it is left blank doxygen will generate a standard footer.
+#
+# Note: Only use a user-defined footer if you know what you are doing!
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_FOOTER           = 
+
+# The LATEX_EXTRA_FILES tag can be used to specify one or more extra images or
+# other source files which should be copied to the LATEX_OUTPUT output
+# directory. Note that the files will be copied as-is; there are no commands or
+# markers available.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_EXTRA_FILES      = 
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated is
+# prepared for conversion to PDF (using ps2pdf or pdflatex). The PDF file will
+# contain links (just like the HTML output) instead of page references. This
+# makes the output suitable for online browsing using a PDF viewer.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+PDF_HYPERLINKS         = YES
+
+# If the LATEX_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate
+# the PDF file directly from the LaTeX files. Set this option to YES to get a
+# higher quality PDF documentation.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+USE_PDFLATEX           = YES
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \batchmode
+# command to the generated LaTeX files. This will instruct LaTeX to keep running
+# if errors occur, instead of asking the user for help. This option is also used
+# when generating formulas in HTML.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_BATCHMODE        = NO
+
+# If the LATEX_HIDE_INDICES tag is set to YES then doxygen will not include the
+# index chapters (such as File Index, Compound Index, etc.) in the output.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_HIDE_INDICES     = NO
+
+# If the LATEX_SOURCE_CODE tag is set to YES then doxygen will include source
+# code with syntax highlighting in the LaTeX output.
+#
+# Note that which sources are shown also depends on other settings such as
+# SOURCE_BROWSER.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_SOURCE_CODE      = NO
+
+# The LATEX_BIB_STYLE tag can be used to specify the style to use for the
+# bibliography, e.g. plainnat, or ieeetr. See
+# http://en.wikipedia.org/wiki/BibTeX and \cite for more info.
+# The default value is: plain.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_BIB_STYLE        = plain
+
+#---------------------------------------------------------------------------
+# Configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES doxygen will generate RTF output. The
+# RTF output is optimized for Word 97 and may not look too pretty with other RTF
+# readers/editors.
+# The default value is: NO.
+
+GENERATE_RTF           = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it.
+# The default directory is: rtf.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
+RTF_OUTPUT             = rtf
+
+# If the COMPACT_RTF tag is set to YES doxygen generates more compact RTF
+# documents. This may be useful for small projects and may help to save some
+# trees in general.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
+COMPACT_RTF            = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated will
+# contain hyperlink fields. The RTF file will contain links (just like the HTML
+# output) instead of page references. This makes the output suitable for online
+# browsing using Word or some other Word compatible readers that support those
+# fields.
+#
+# Note: WordPad (write) and others do not support links.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
+RTF_HYPERLINKS         = NO
+
+# Load stylesheet definitions from file. Syntax is similar to doxygen's config
+# file, i.e. a series of assignments. You only have to provide replacements,
+# missing definitions are set to their default value.
+#
+# See also section "Doxygen usage" for information on how to generate the
+# default style sheet that doxygen normally uses.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
+RTF_STYLESHEET_FILE    = 
+
+# Set optional variables used in the generation of an RTF document. Syntax is
+# similar to doxygen's config file. A template extensions file can be generated
+# using doxygen -e rtf extensionFile.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
+RTF_EXTENSIONS_FILE    = 
+
+#---------------------------------------------------------------------------
+# Configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES doxygen will generate man pages for
+# classes and files.
+# The default value is: NO.
+
+GENERATE_MAN           = NO
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it. A directory man3 will be created inside the directory specified by
+# MAN_OUTPUT.
+# The default directory is: man.
+# This tag requires that the tag GENERATE_MAN is set to YES.
+
+MAN_OUTPUT             = man
+
+# The MAN_EXTENSION tag determines the extension that is added to the generated
+# man pages. In case the manual section does not start with a number, the number
+# 3 is prepended. The dot (.) at the beginning of the MAN_EXTENSION tag is
+# optional.
+# The default value is: .3.
+# This tag requires that the tag GENERATE_MAN is set to YES.
+
+MAN_EXTENSION          = .3
+
+# The MAN_SUBDIR tag determines the name of the directory created within
+# MAN_OUTPUT in which the man pages are placed. If defaults to man followed by
+# MAN_EXTENSION with the initial . removed.
+# This tag requires that the tag GENERATE_MAN is set to YES.
+
+MAN_SUBDIR             = 
+
+# If the MAN_LINKS tag is set to YES and doxygen generates man output, then it
+# will generate one additional man file for each entity documented in the real
+# man page(s). These additional files only source the real man page, but without
+# them the man command would be unable to find the correct page.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_MAN is set to YES.
+
+MAN_LINKS              = NO
+
+#---------------------------------------------------------------------------
+# Configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES doxygen will generate an XML file that
+# captures the structure of the code including all documentation.
+# The default value is: NO.
+
+GENERATE_XML           = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it.
+# The default directory is: xml.
+# This tag requires that the tag GENERATE_XML is set to YES.
+
+XML_OUTPUT             = xml
+
+# If the XML_PROGRAMLISTING tag is set to YES doxygen will dump the program
+# listings (including syntax highlighting and cross-referencing information) to
+# the XML output. Note that enabling this will significantly increase the size
+# of the XML output.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_XML is set to YES.
+
+XML_PROGRAMLISTING     = YES
+
+#---------------------------------------------------------------------------
+# Configuration options related to the DOCBOOK output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_DOCBOOK tag is set to YES doxygen will generate Docbook files
+# that can be used to generate PDF.
+# The default value is: NO.
+
+GENERATE_DOCBOOK       = NO
+
+# The DOCBOOK_OUTPUT tag is used to specify where the Docbook pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be put in
+# front of it.
+# The default directory is: docbook.
+# This tag requires that the tag GENERATE_DOCBOOK is set to YES.
+
+DOCBOOK_OUTPUT         = docbook
+
+#---------------------------------------------------------------------------
+# Configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES doxygen will generate an AutoGen
+# Definitions (see http://autogen.sf.net) file that captures the structure of
+# the code including all documentation. Note that this feature is still
+# experimental and incomplete at the moment.
+# The default value is: NO.
+
+GENERATE_AUTOGEN_DEF   = NO
+
+#---------------------------------------------------------------------------
+# Configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES doxygen will generate a Perl module
+# file that captures the structure of the code including all documentation.
+#
+# Note that this feature is still experimental and incomplete at the moment.
+# The default value is: NO.
+
+GENERATE_PERLMOD       = NO
+
+# If the PERLMOD_LATEX tag is set to YES doxygen will generate the necessary
+# Makefile rules, Perl scripts and LaTeX code to be able to generate PDF and DVI
+# output from the Perl module output.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_PERLMOD is set to YES.
+
+PERLMOD_LATEX          = NO
+
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be nicely
+# formatted so it can be parsed by a human reader. This is useful if you want to
+# understand what is going on. On the other hand, if this tag is set to NO the
+# size of the Perl module output will be much smaller and Perl will parse it
+# just the same.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_PERLMOD is set to YES.
+
+PERLMOD_PRETTY         = YES
+
+# The names of the make variables in the generated doxyrules.make file are
+# prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. This is useful
+# so different doxyrules.make files included by the same Makefile don't
+# overwrite each other's variables.
+# This tag requires that the tag GENERATE_PERLMOD is set to YES.
+
+PERLMOD_MAKEVAR_PREFIX = 
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES doxygen will evaluate all
+# C-preprocessor directives found in the sources and include files.
+# The default value is: YES.
+
+ENABLE_PREPROCESSING   = YES
+
+# If the MACRO_EXPANSION tag is set to YES doxygen will expand all macro names
+# in the source code. If set to NO only conditional compilation will be
+# performed. Macro expansion can be done in a controlled way by setting
+# EXPAND_ONLY_PREDEF to YES.
+# The default value is: NO.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+MACRO_EXPANSION        = NO
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then
+# the macro expansion is limited to the macros specified with the PREDEFINED and
+# EXPAND_AS_DEFINED tags.
+# The default value is: NO.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+EXPAND_ONLY_PREDEF     = NO
+
+# If the SEARCH_INCLUDES tag is set to YES the includes files in the
+# INCLUDE_PATH will be searched if a #include is found.
+# The default value is: YES.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+SEARCH_INCLUDES        = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that
+# contain include files that are not input files but should be processed by the
+# preprocessor.
+# This tag requires that the tag SEARCH_INCLUDES is set to YES.
+
+INCLUDE_PATH           = 
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
+# patterns (like *.h and *.hpp) to filter out the header-files in the
+# directories. If left blank, the patterns specified with FILE_PATTERNS will be
+# used.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+INCLUDE_FILE_PATTERNS  = 
+
+# The PREDEFINED tag can be used to specify one or more macro names that are
+# defined before the preprocessor is started (similar to the -D option of e.g.
+# gcc). The argument of the tag is a list of macros of the form: name or
+# name=definition (no spaces). If the definition and the "=" are omitted, "=1"
+# is assumed. To prevent a macro definition from being undefined via #undef or
+# recursively expanded use the := operator instead of the = operator.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+PREDEFINED             = 
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
+# tag can be used to specify a list of macro names that should be expanded. The
+# macro definition that is found in the sources will be used. Use the PREDEFINED
+# tag if you want to use a different macro definition that overrules the
+# definition found in the source code.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+EXPAND_AS_DEFINED      = 
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will
+# remove all references to function-like macros that are alone on a line, have
+# an all uppercase name, and do not end with a semicolon. Such function macros
+# are typically used for boiler-plate code, and will confuse the parser if not
+# removed.
+# The default value is: YES.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+SKIP_FUNCTION_MACROS   = YES
+
+#---------------------------------------------------------------------------
+# Configuration options related to external references
+#---------------------------------------------------------------------------
+
+# The TAGFILES tag can be used to specify one or more tag files. For each tag
+# file the location of the external documentation should be added. The format of
+# a tag file without this location is as follows:
+# TAGFILES = file1 file2 ...
+# Adding location for the tag files is done as follows:
+# TAGFILES = file1=loc1 "file2 = loc2" ...
+# where loc1 and loc2 can be relative or absolute paths or URLs. See the
+# section "Linking to external documentation" for more information about the use
+# of tag files.
+# Note: Each tag file must have a unique name (where the name does NOT include
+# the path). If a tag file is not located in the directory in which doxygen is
+# run, you must also specify the path to the tagfile here.
+
+TAGFILES               = 
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create a
+# tag file that is based on the input files it reads. See section "Linking to
+# external documentation" for more information about the usage of tag files.
+
+GENERATE_TAGFILE       = 
+
+# If the ALLEXTERNALS tag is set to YES all external class will be listed in the
+# class index. If set to NO only the inherited external classes will be listed.
+# The default value is: NO.
+
+ALLEXTERNALS           = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed in
+# the modules index. If set to NO, only the current project's groups will be
+# listed.
+# The default value is: YES.
+
+EXTERNAL_GROUPS        = YES
+
+# If the EXTERNAL_PAGES tag is set to YES all external pages will be listed in
+# the related pages index. If set to NO, only the current project's pages will
+# be listed.
+# The default value is: YES.
+
+EXTERNAL_PAGES         = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script
+# interpreter (i.e. the result of 'which perl').
+# The default file (with absolute path) is: /usr/bin/perl.
+
+PERL_PATH              = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES doxygen will generate a class diagram
+# (in HTML and LaTeX) for classes with base or super classes. Setting the tag to
+# NO turns the diagrams off. Note that this option also works with HAVE_DOT
+# disabled, but it is recommended to install and use dot, since it yields more
+# powerful graphs.
+# The default value is: YES.
+
+CLASS_DIAGRAMS         = YES
+
+# You can define message sequence charts within doxygen comments using the \msc
+# command. Doxygen will then run the mscgen tool (see:
+# http://www.mcternan.me.uk/mscgen/)) to produce the chart and insert it in the
+# documentation. The MSCGEN_PATH tag allows you to specify the directory where
+# the mscgen tool resides. If left empty the tool is assumed to be found in the
+# default search path.
+
+MSCGEN_PATH            = 
+
+# You can include diagrams made with dia in doxygen documentation. Doxygen will
+# then run dia to produce the diagram and insert it in the documentation. The
+# DIA_PATH tag allows you to specify the directory where the dia binary resides.
+# If left empty dia is assumed to be found in the default search path.
+
+DIA_PATH               = 
+
+# If set to YES, the inheritance and collaboration graphs will hide inheritance
+# and usage relations if the target is undocumented or is not a class.
+# The default value is: YES.
+
+HIDE_UNDOC_RELATIONS   = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
+# available from the path. This tool is part of Graphviz (see:
+# http://www.graphviz.org/), a graph visualization toolkit from AT&T and Lucent
+# Bell Labs. The other options in this section have no effect if this option is
+# set to NO
+# The default value is: NO.
+
+HAVE_DOT               = NO
+
+# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed
+# to run in parallel. When set to 0 doxygen will base this on the number of
+# processors available in the system. You can set it explicitly to a value
+# larger than 0 to get control over the balance between CPU load and processing
+# speed.
+# Minimum value: 0, maximum value: 32, default value: 0.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_NUM_THREADS        = 0
+
+# When you want a differently looking font n the dot files that doxygen
+# generates you can specify the font name using DOT_FONTNAME. You need to make
+# sure dot is able to find the font, which can be done by putting it in a
+# standard location or by setting the DOTFONTPATH environment variable or by
+# setting DOT_FONTPATH to the directory containing the font.
+# The default value is: Helvetica.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_FONTNAME           = FreeSans.ttf
+
+# The DOT_FONTSIZE tag can be used to set the size (in points) of the font of
+# dot graphs.
+# Minimum value: 4, maximum value: 24, default value: 10.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_FONTSIZE           = 10
+
+# By default doxygen will tell dot to use the default font as specified with
+# DOT_FONTNAME. If you specify a different font using DOT_FONTNAME you can set
+# the path where dot can find it using this tag.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_FONTPATH           = 
+
+# If the CLASS_GRAPH tag is set to YES then doxygen will generate a graph for
+# each documented class showing the direct and indirect inheritance relations.
+# Setting this tag to YES will force the CLASS_DIAGRAMS tag to NO.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+CLASS_GRAPH            = YES
+
+# If the COLLABORATION_GRAPH tag is set to YES then doxygen will generate a
+# graph for each documented class showing the direct and indirect implementation
+# dependencies (inheritance, containment, and class references variables) of the
+# class with other documented classes.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+COLLABORATION_GRAPH    = YES
+
+# If the GROUP_GRAPHS tag is set to YES then doxygen will generate a graph for
+# groups, showing the direct groups dependencies.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+GROUP_GRAPHS           = YES
+
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
+# collaboration diagrams in a style similar to the OMG's Unified Modeling
+# Language.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+UML_LOOK               = NO
+
+# If the UML_LOOK tag is enabled, the fields and methods are shown inside the
+# class node. If there are many fields or methods and many nodes the graph may
+# become too big to be useful. The UML_LIMIT_NUM_FIELDS threshold limits the
+# number of items for each type to make the size more manageable. Set this to 0
+# for no limit. Note that the threshold may be exceeded by 50% before the limit
+# is enforced. So when you set the threshold to 10, up to 15 fields may appear,
+# but if the number exceeds 15, the total amount of fields shown is limited to
+# 10.
+# Minimum value: 0, maximum value: 100, default value: 10.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+UML_LIMIT_NUM_FIELDS   = 10
+
+# If the TEMPLATE_RELATIONS tag is set to YES then the inheritance and
+# collaboration graphs will show the relations between templates and their
+# instances.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+TEMPLATE_RELATIONS     = NO
+
+# If the INCLUDE_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are set to
+# YES then doxygen will generate a graph for each documented file showing the
+# direct and indirect include dependencies of the file with other documented
+# files.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+INCLUDE_GRAPH          = YES
+
+# If the INCLUDED_BY_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are
+# set to YES then doxygen will generate a graph for each documented file showing
+# the direct and indirect include dependencies of the file with other documented
+# files.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+INCLUDED_BY_GRAPH      = YES
+
+# If the CALL_GRAPH tag is set to YES then doxygen will generate a call
+# dependency graph for every global function or class method.
+#
+# Note that enabling this option will significantly increase the time of a run.
+# So in most cases it will be better to enable call graphs for selected
+# functions only using the \callgraph command.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+CALL_GRAPH             = NO
+
+# If the CALLER_GRAPH tag is set to YES then doxygen will generate a caller
+# dependency graph for every global function or class method.
+#
+# Note that enabling this option will significantly increase the time of a run.
+# So in most cases it will be better to enable caller graphs for selected
+# functions only using the \callergraph command.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+CALLER_GRAPH           = NO
+
+# If the GRAPHICAL_HIERARCHY tag is set to YES then doxygen will graphical
+# hierarchy of all classes instead of a textual one.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+GRAPHICAL_HIERARCHY    = YES
+
+# If the DIRECTORY_GRAPH tag is set to YES then doxygen will show the
+# dependencies a directory has on other directories in a graphical way. The
+# dependency relations are determined by the #include relations between the
+# files in the directories.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DIRECTORY_GRAPH        = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
+# generated by dot.
+# Note: If you choose svg you need to set HTML_FILE_EXTENSION to xhtml in order
+# to make the SVG files visible in IE 9+ (other browsers do not have this
+# requirement).
+# Possible values are: png, jpg, gif and svg.
+# The default value is: png.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_IMAGE_FORMAT       = png
+
+# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to
+# enable generation of interactive SVG images that allow zooming and panning.
+#
+# Note that this requires a modern browser other than Internet Explorer. Tested
+# and working are Firefox, Chrome, Safari, and Opera.
+# Note: For IE 9+ you need to set HTML_FILE_EXTENSION to xhtml in order to make
+# the SVG files visible. Older versions of IE do not have SVG support.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+INTERACTIVE_SVG        = NO
+
+# The DOT_PATH tag can be used to specify the path where the dot tool can be
+# found. If left blank, it is assumed the dot tool can be found in the path.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_PATH               = 
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that
+# contain dot files that are included in the documentation (see the \dotfile
+# command).
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOTFILE_DIRS           = 
+
+# The MSCFILE_DIRS tag can be used to specify one or more directories that
+# contain msc files that are included in the documentation (see the \mscfile
+# command).
+
+MSCFILE_DIRS           = 
+
+# The DIAFILE_DIRS tag can be used to specify one or more directories that
+# contain dia files that are included in the documentation (see the \diafile
+# command).
+
+DIAFILE_DIRS           = 
+
+# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of nodes
+# that will be shown in the graph. If the number of nodes in a graph becomes
+# larger than this value, doxygen will truncate the graph, which is visualized
+# by representing a node as a red box. Note that doxygen if the number of direct
+# children of the root node in a graph is already larger than
+# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note that
+# the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
+# Minimum value: 0, maximum value: 10000, default value: 50.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_GRAPH_MAX_NODES    = 50
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the graphs
+# generated by dot. A depth value of 3 means that only nodes reachable from the
+# root by following a path via at most 3 edges will be shown. Nodes that lay
+# further from the root node will be omitted. Note that setting this option to 1
+# or 2 may greatly reduce the computation time needed for large code bases. Also
+# note that the size of a graph can be further restricted by
+# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
+# Minimum value: 0, maximum value: 1000, default value: 0.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+MAX_DOT_GRAPH_DEPTH    = 0
+
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
+# background. This is disabled by default, because dot on Windows does not seem
+# to support this out of the box.
+#
+# Warning: Depending on the platform used, enabling this option may lead to
+# badly anti-aliased labels on the edges of a graph (i.e. they become hard to
+# read).
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_TRANSPARENT        = NO
+
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
+# files in one run (i.e. multiple -o and -T options on the command line). This
+# makes dot run faster, but since only newer versions of dot (>1.8.10) support
+# this, this feature is disabled by default.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_MULTI_TARGETS      = NO
+
+# If the GENERATE_LEGEND tag is set to YES doxygen will generate a legend page
+# explaining the meaning of the various boxes and arrows in the dot generated
+# graphs.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+GENERATE_LEGEND        = YES
+
+# If the DOT_CLEANUP tag is set to YES doxygen will remove the intermediate dot
+# files that are used to generate the various graphs.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_CLEANUP            = YES
diff --git a/doc/images/capi_uix_tts_state_diagram.png b/doc/images/capi_uix_tts_state_diagram.png
new file mode 100644 (file)
index 0000000..83efe11
Binary files /dev/null and b/doc/images/capi_uix_tts_state_diagram.png differ
diff --git a/doc/uix_tts_doc.h b/doc/uix_tts_doc.h
new file mode 100644 (file)
index 0000000..6636bd6
--- /dev/null
@@ -0,0 +1,204 @@
+/*
+ * Copyright (c) 2011-2014 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_UIX_TTS_DOC_H__
+#define __TIZEN_UIX_TTS_DOC_H__
+
+/**
+ * @defgroup CAPI_UIX_TTS_MODULE TTS
+ * @ingroup CAPI_UIX_FRAMEWORK
+ * @brief The @ref CAPI_UIX_TTS_MODULE API provides functions for synthesizing voice from text and playing synthesized sound data.
+ * 
+ * @section CAPI_UIX_TTS_MODULE_HEADER Required Header
+ *   \#include <tts.h>
+ * 
+ * @section CAPI_UIX_TTS_MODULE_OVERVIEW Overview
+ * A main function of Text-To-Speech(below TTS) API reads sound data transformed by the engine using input texts.
+ * Applications can add input-text to queue for reading continuously and control a player that can play, pause, and stop sound data synthesized from text.
+ *
+ * To use of TTS, use the following steps:<br>
+ * 1. Create a handle <br>
+ * 2. Register callback functions for notifications <br> 
+ * 3. Prepare tts-daemon asynchronously <br>
+ * 4. Add text to queue for speech <br>
+ * 5. Start synthesizing voice from text and play synthesized sound data <br>
+ * 6. Pause the player <br>
+ * 7. Resume the player <br>
+ * 8. Stop the player <br>
+ * 9. Destroy a handle <br>
+ * 
+ * The TTS API also notifies you (by callback mechanism) when the state of TTS is changed, 
+ * utterance is started and completed, default voice is changed or an error occured.
+ * An application should register callback functions: tts_state_changed_cb(), tts_utterance_started_cb(), 
+ * tts_utterance_completed_cb(), tts_default_voice_changed_cb(), tts_error_cb().
+ *
+ * @section CAPI_UIX_TTS_MODULE_STATE_DIAGRAM State Diagram
+ * The following diagram shows the life cycle and the states of the TTS.
+ *
+ * @image html capi_uix_tts_state_diagram.png "State diagram"
+ *
+ * @section CAPI_UIX_TTS_MODULE_STATE_TRANSITIONS State Transitions
+ *
+ * <table>
+ * <tr>
+ * <th>FUNCTION</th>
+ * <th>PRE-STATE</th>
+ * <th>POST-STATE</th>
+ * <th>SYNC TYPE</th>
+ * </tr>
+ * <tr>
+ * <td>tts_prepare()</td>
+ * <td>Created</td>
+ * <td>Ready</td>
+ * <td>ASYNC</td>
+ * </tr>
+ * <tr>
+ * <td>tts_play()</td>
+ * <td>Ready, Paused</td>
+ * <td>Playing</td>
+ * <td>SYNC</td>
+ * </tr>
+ * <tr>
+ * <td>tts_stop()</td>
+ * <td>Ready, Playing, Paused</td>
+ * <td>Ready</td>
+ * <td>SYNC</td>
+ * </tr>
+ * <tr>
+ * <td>tts_pause()</td>
+ * <td>Playing</td>
+ * <td>Paused</td>
+ * <td>SYNC</td>
+ * </tr>
+ * </table>
+ *
+ * @section CAPI_UIX_TTS_MODULE_STATE_DEPENDENT_FUNCTION_CALLS State Dependent Function Calls
+ * The following table shows state-dependent function calls.
+ * It is forbidden to call functions listed below in wrong states.
+ * Violation of this rule may result in an unpredictable behavior.
+ * 
+ * <table>
+ * <tr>
+ * <th>FUNCTION</th>
+ * <th>VALID STATES</th>
+ * <th>DESCRIPTION</th>
+ * </tr>
+ * <tr>
+ * <td>tts_create()</td>
+ * <td>None</td>
+ * <td>All functions must be called after tts_create()</td>
+ * </tr>
+ * <tr>
+ * <td>tts_destroy()</td>
+ * <td>Created, Ready, Playing, Paused</td>
+ * <td></td>
+ * </tr>
+ * <tr>
+ * <td>tts_set_mode()</td>
+ * <td>Created</td>
+ * <td>The application should set mode to use TTS for screen reader or notification like driving mode.</td>
+ * </tr>
+ * <tr>
+ * <td>tts_get_mode()</td>
+ * <td>Created</td>
+ * <td></td>
+ * </tr>
+ * <tr>
+ * <td>tts_prepare()</td>
+ * <td>Created</td>
+ * <td>This function works asynchronously. If daemon fork is failed, application gets the error callback.</td>
+ * </tr>
+ * <tr>
+ * <td>tts_unprepare()</td>
+ * <td>Ready</td>
+ * <td></td>
+ * </tr>
+ * <tr>
+ * <td>tts_foreach_supported_voices()</td>
+ * <td>Created, Ready, Playing, Paused</td>
+ * <td></td>
+ * </tr>
+ * <tr>
+ * <td>tts_get_default_voice()</td>
+ * <td>Created, Ready, Playing, Paused</td>
+ * <td></td>
+ * </tr>
+ * <tr>
+ * <td>tts_get_state()</td>
+ * <td>Created, Ready, Playing, Paused</td>
+ * <td></td>
+ * </tr>
+ * <tr>
+ * <td>tts_get_max_text_size()</td>
+ * <td>Ready</td>
+ * <td></td>
+ * </tr>
+ * <tr>
+ * <td>tts_get_speed_range()</td>
+ * <td>Ready</td>
+ * <td></td>
+ * </tr>
+ * <tr>
+ * <td>tts_add_text()</td>
+ * <td>Ready, Playing, Paused</td>
+ * <td></td>
+ * </tr>
+ * <tr>
+ * <td>tts_play()</td>
+ * <td>Ready, Paused</td>
+ * <td></td>
+ * </tr>
+ * <tr>
+ * <td>tts_stop()</td>
+ * <td>Ready, Playing, Paused</td>
+ * <td></td>
+ * </tr>
+ * <tr>
+ * <td>tts_pause()</td>
+ * <td>Playing</td>
+ * <td></td>
+ * </tr>
+ * <tr>
+ * <td>
+ * tts_set_state_changed_cb()<br>
+ * tts_unset_state_changed_cb()<br>
+ * tts_set_utterance_started_cb()<br>
+ * tts_unset_utterance_started_cb()<br>
+ * tts_set_utterance_completed_cb()<br>
+ * tts_unset_utterance_completed_cb()<br>
+ * tts_set_default_voice_changed_cb()<br>
+ * tts_unset_default_voice_changed_cb()<br>
+ * tts_set_error_cb()<br>
+ * tts_unset_error_cb()</td>
+ * <td>Created</td>
+ * <td> All callback function should be registered in Created state </td>
+ * </tr>
+ * </table>
+ * 
+ * @section CAPI_UIX_TTS_MODULE_FEATURE Related Features
+ * This API is related with the following features:<br>
+ *  - http://tizen.org/feature/speech.synthesis<br>
+ *
+ * It is recommended to design feature related codes in your application for reliability.<br>
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.<br>
+ * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.<br>
+ * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a>
+ *
+ */
+
+#endif /* __TIZEN_UIX_TTS_DOC_H__ */
+
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
new file mode 100644 (file)
index 0000000..cda0d5b
--- /dev/null
@@ -0,0 +1,12 @@
+## configure pkgconfig files ##
+CONFIGURE_FILE(tts.pc.in "${PROJECT_NAME}.pc" @ONLY)
+CONFIGURE_FILE(tts-setting.pc.in "${PROJECT_NAME}-setting.pc" @ONLY)
+CONFIGURE_FILE(tts-engine.pc.in "${PROJECT_NAME}-engine.pc" @ONLY)
+
+## Install header, pc files ##
+INSTALL(FILES "${CMAKE_BINARY_DIR}/include/${PROJECT_NAME}.pc" DESTINATION ${LIBDIR}/pkgconfig)
+INSTALL(FILES "${CMAKE_BINARY_DIR}/include/${PROJECT_NAME}-setting.pc" DESTINATION ${LIBDIR}/pkgconfig)
+INSTALL(FILES "${CMAKE_BINARY_DIR}/include/${PROJECT_NAME}-engine.pc" DESTINATION ${LIBDIR}/pkgconfig)
+INSTALL(FILES "${CMAKE_BINARY_DIR}/include/tts.h" DESTINATION ${INCLUDEDIR})
+INSTALL(FILES "${CMAKE_BINARY_DIR}/include/tts_setting.h" DESTINATION ${INCLUDEDIR})
+INSTALL(FILES "${CMAKE_BINARY_DIR}/server/ttsp.h" DESTINATION ${INCLUDEDIR})
diff --git a/include/tts-engine.pc.in b/include/tts-engine.pc.in
new file mode 100644 (file)
index 0000000..4f68dd5
--- /dev/null
@@ -0,0 +1,10 @@
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
+
+Name: lib@PROJECT_NAME@_engine
+Description: Text To Speech client engine header
+Requires: glib-2.0 dbus-1 
+Version: @VERSION@
+Cflags: -I${includedir}
diff --git a/include/tts.h b/include/tts.h
new file mode 100644 (file)
index 0000000..5b6758d
--- /dev/null
@@ -0,0 +1,735 @@
+/*
+ * Copyright (c) 2011-2014 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 __TTS_H__
+#define __TTS_H__
+
+#include <tizen.h>
+
+/**
+* @file tts.h
+*/
+
+/**
+* @addtogroup CAPI_UIX_TTS_MODULE
+* @{
+*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** 
+ * @brief Enumeration for error code.
+ * @since_tizen 2.3
+*/
+typedef enum {
+       TTS_ERROR_NONE                  = TIZEN_ERROR_NONE,             /**< Successful */
+       TTS_ERROR_OUT_OF_MEMORY         = TIZEN_ERROR_OUT_OF_MEMORY,    /**< Out of Memory */
+       TTS_ERROR_IO_ERROR              = TIZEN_ERROR_IO_ERROR,         /**< I/O error */
+       TTS_ERROR_INVALID_PARAMETER     = TIZEN_ERROR_INVALID_PARAMETER,/**< Invalid parameter */
+       TTS_ERROR_OUT_OF_NETWORK        = TIZEN_ERROR_NETWORK_DOWN,     /**< Network is down */
+       TTS_ERROR_TIMED_OUT             = TIZEN_ERROR_TIMED_OUT,        /**< No answer from the daemon */
+       TTS_ERROR_PERMISSION_DENIED     = TIZEN_ERROR_PERMISSION_DENIED,/**< Permission denied */
+       TTS_ERROR_NOT_SUPPORTED         = TIZEN_ERROR_NOT_SUPPORTED,    /**< TTS NOT supported */
+       TTS_ERROR_INVALID_STATE         = TIZEN_ERROR_TTS | 0x01,       /**< Invalid state */
+       TTS_ERROR_INVALID_VOICE         = TIZEN_ERROR_TTS | 0x02,       /**< Invalid voice */
+       TTS_ERROR_ENGINE_NOT_FOUND      = TIZEN_ERROR_TTS | 0x03,       /**< No available engine */
+       TTS_ERROR_OPERATION_FAILED      = TIZEN_ERROR_TTS | 0x04,       /**< Operation failed */
+       TTS_ERROR_AUDIO_POLICY_BLOCKED  = TIZEN_ERROR_TTS | 0x05        /**< Audio policy blocked */
+} tts_error_e;
+
+/** 
+ * @brief Enumeration for TTS mode.
+ * @since_tizen 2.3
+*/
+typedef enum {
+       TTS_MODE_DEFAULT        = 0,    /**< Default mode for normal application */
+       TTS_MODE_NOTIFICATION   = 1,    /**< Notification mode */
+       TTS_MODE_SCREEN_READER  = 2     /**< Accessibiliity mode */
+}tts_mode_e;
+
+/** 
+ * @brief Enumerations for state.
+ * @since_tizen 2.3
+*/
+typedef enum {
+       TTS_STATE_CREATED       = 0,    /**< 'CREATED' state */
+       TTS_STATE_READY         = 1,    /**< 'READY' state */
+       TTS_STATE_PLAYING       = 2,    /**< 'PLAYING' state */
+       TTS_STATE_PAUSED        = 3     /**< 'PAUSED' state*/
+}tts_state_e;
+
+/** 
+ * @brief Definitions for automatic speaking speed.
+ * @since_tizen 2.3
+*/
+#define TTS_SPEED_AUTO         0
+
+/** 
+ * @brief Definitions for automatic voice type.
+ * @since_tizen 2.3
+*/
+#define TTS_VOICE_TYPE_AUTO    0
+
+/** 
+ * @brief Definitions for male voice type.
+ * @since_tizen 2.3
+*/
+#define TTS_VOICE_TYPE_MALE    1
+
+/** 
+ * @brief Definitions for female voice type.
+ * @since_tizen 2.3
+*/
+#define TTS_VOICE_TYPE_FEMALE  2
+
+/** 
+ * @brief Definitions for child voice type.
+ * @since_tizen 2.3
+*/
+#define TTS_VOICE_TYPE_CHILD   3
+
+/** 
+ * @brief The TTS handle.
+ * @since_tizen 2.3
+*/
+typedef struct tts_s *tts_h;
+
+
+/**
+ * @brief Called when the state of TTS is changed.
+ * @since_tizen 2.3
+ *
+ * @details If the daemon must stop player because of changing engine and
+ *     the daemon must pause player because of other requests, this callback function is called.
+ *
+ * @param[in] tts The TTS handle
+ * @param[in] previous The previous state
+ * @param[in] current The current state
+ * @param[in] user_data The user data passed from the callback registration function
+ *
+ * @pre An application registers this callback using tts_set_state_changed_cb() to detect changing state.
+ *
+ * @see tts_set_state_changed_cb()
+ * @see tts_unset_state_changed_cb()
+*/
+typedef void (*tts_state_changed_cb)(tts_h tts, tts_state_e previous, tts_state_e current, void* user_data);
+
+/**
+ * @brief Called when utterance has started.
+ * @since_tizen 2.3
+ *
+ * @param[in] tts The TTS handle
+ * @param[in] utt_id The utterance ID passed from the add text function
+ * @param[in] user_data The user data passed from the callback registration function
+ *
+ * @pre An application registers this callback using tts_set_utterance_started_cb() to detect utterance started.
+ *
+ * @see tts_add_text()
+ * @see tts_set_utterance_started_cb()
+ * @see tts_unset_utterance_started_cb()
+*/
+typedef void (*tts_utterance_started_cb)(tts_h tts, int utt_id, void* user_data);
+
+/**
+ * @brief Called when utterance is finished.
+ * @since_tizen 2.3
+ *
+ * @param[in] tts The TTS handle
+ * @param[in] utt_id The utterance ID passed from the add text function
+ * @param[in] user_data The user data passed from the callback registration function
+ *
+ * @pre An application registers this callback using tts_set_utterance_completed_cb() to detect utterance completed.
+ *
+ * @see tts_add_text()
+ * @see tts_set_utterance_completed_cb()
+ * @see tts_unset_utterance_completed_cb()
+*/
+typedef void (*tts_utterance_completed_cb)(tts_h tts, int utt_id, void *user_data);
+
+/**
+ * @brief Called when an error occurs.
+ * @since_tizen 2.3
+ *
+ * @param[in] tts The TTS handle
+ * @param[in] utt_id The utterance ID passed from the add text function
+ * @param[in] reason The error code
+ * @param[in] user_data The user data passed from the callback registration function
+ *
+ * @pre An application registers this callback using tts_set_error_cb() to detect error.
+ *
+ * @see tts_play()
+ * @see tts_pause()
+ * @see tts_stop()
+ * @see tts_set_error_cb()
+ * @see tts_unset_error_cb()
+*/
+typedef void (*tts_error_cb)(tts_h tts, int utt_id, tts_error_e reason, void* user_data);
+
+/**
+ * @brief Called to retrieve the supported voice.
+ * @since_tizen 2.3
+ *
+ * @param[in] tts The TTS handle
+ * @param[in] language Language specified as an ISO 3166 alpha-2 two letter country-code followed by ISO 639-1 for the two-letter language code (for example, "ko_KR" for Korean, "en_US" for American English)
+ * @param[in] voice_type A voice type (e.g. #TTS_VOICE_TYPE_MALE, #TTS_VOICE_TYPE_FEMALE)
+ * @param[in] user_data The user data passed from the foreach function
+ *
+ * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop
+ * @pre tts_foreach_supported_voices() will invoke this callback function.
+ *
+ * @see tts_foreach_supported_voices()
+*/
+typedef bool(*tts_supported_voice_cb)(tts_h tts, const char* language, int voice_type, void* user_data);
+
+/**
+ * @brief Called when the default voice is changed.
+ * @since_tizen 2.3
+ *
+ * @param[in] tts The TTS handle
+ * @param[in] previous_language The previous language
+ * @param[in] previous_voice_type The previous voice type
+ * @param[in] current_language The current language
+ * @param[in] current_voice_type The current voice type
+ * @param[in] user_data The user data passed from the callback registration function
+ *
+ * @see tts_set_default_voice_changed_cb()
+*/
+typedef void (*tts_default_voice_changed_cb)(tts_h tts, const char* previous_language, int previous_voice_type,
+                               const char* current_language, int current_voice_type, void* user_data);
+
+
+/**
+ * @brief Creates a handle for TTS.
+ * @since_tizen 2.3
+ *
+ * @remarks If the function succeeds, @a tts handle must be released with tts_destroy().
+ *
+ * @param[out] tts The TTS handle
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #TTS_ERROR_NONE Successful
+ * @retval #TTS_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TTS_ERROR_ENGINE_NOT_FOUND Engine not found
+ * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
+ * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
+ *
+ * @post If this function is called, the TTS state will be #TTS_STATE_CREATED.
+ *
+ * @see tts_destroy()
+*/
+int tts_create(tts_h* tts);
+
+/**
+ * @brief Destroys the handle and disconnects the daemon.
+ * @since_tizen 2.3
+ *
+ * @param[in] tts The TTS handle
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #TTS_ERROR_NONE Successful
+ * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
+ * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
+ *
+ * @see tts_create()
+*/
+int tts_destroy(tts_h tts);
+
+/**
+ * @brief Sets the TTS mode.
+ * @since_tizen 2.3
+ *
+ * @param[in] tts The TTS handle
+ * @param[in] mode The mode
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #TTS_ERROR_NONE Successful
+ * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TTS_ERROR_INVALID_STATE Invalid state
+ * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
+ * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
+ *
+ * @pre The state should be #TTS_STATE_CREATED.
+ *
+ * @see tts_get_mode()
+*/
+int tts_set_mode(tts_h tts, tts_mode_e mode);
+
+/**
+ * @brief Gets the TTS mode.
+ * @since_tizen 2.3
+ *
+ * @param[in] tts The TTS handle
+ * @param[out] mode The mode
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #TTS_ERROR_NONE Successful
+ * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TTS_ERROR_INVALID_STATE Invalid state
+ * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
+ *
+ * @pre The state should be #TTS_STATE_CREATED.
+ *
+ * @see tts_set_mode()
+*/
+int tts_get_mode(tts_h tts, tts_mode_e* mode);
+
+/**
+ * @brief Connects the daemon asynchronously.
+ * @since_tizen 2.3
+ *
+ * @param[in] tts The TTS handle
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #TTS_ERROR_NONE Successful
+ * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TTS_ERROR_INVALID_STATE Invalid state
+ * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
+ *
+ * @pre The state should be #TTS_STATE_CREATED.
+ * @post If this function is successful, the TTS state will be #TTS_STATE_READY. \n
+ *     If this function is failed, the error callback is called. (e.g. #TTS_ERROR_ENGINE_NOT_FOUND)
+ *
+ * @see tts_unprepare()
+*/
+int tts_prepare(tts_h tts);
+
+/**
+ * @brief Disconnects the daemon.
+ * @since_tizen 2.3
+ *
+ * @param[in] tts The TTS handle
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #TTS_ERROR_NONE Successful
+ * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TTS_ERROR_INVALID_STATE Invalid state
+ * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
+ *
+ * @pre The state should be #TTS_STATE_READY.
+ * @post If this function is called, the TTS state will be #TTS_STATE_CREATED.
+ *
+ * @see tts_prepare()
+*/
+int tts_unprepare(tts_h tts);
+
+/**
+ * @brief Retrieves all supported voices of the current engine using callback function.
+ * @since_tizen 2.3
+ *
+ * @param[in] tts The TTS handle
+ * @param[in] callback The callback function to invoke
+ * @param[in] user_data The user data to be passed to the callback function
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #TTS_ERROR_NONE Successful
+ * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TTS_ERROR_ENGINE_NOT_FOUND Engine not found
+ * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
+ * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
+ *
+ * @post This function invokes tts_supported_voice_cb() repeatedly for getting voices.
+ *
+ * @see tts_get_default_voice()
+*/
+int tts_foreach_supported_voices(tts_h tts, tts_supported_voice_cb callback, void* user_data);
+
+/**
+ * @brief Gets the default voice set by the user.
+ * @since_tizen 2.3
+ *
+ * @remarks If the function succeeds, @a language must be released with free().
+ *
+ * @param[in] tts The TTS handle
+ * @param[out] language Language specified as an ISO 3166 alpha-2 two letter country-code followed by ISO 639-1 for the two-letter language code (for example, "ko_KR" for Korean, "en_US" for American English)
+ * @param[out] voice_type The voice type
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #TTS_ERROR_NONE Successful
+ * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TTS_ERROR_ENGINE_NOT_FOUND Engine not found
+ * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
+ * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
+ *
+ * @see tts_foreach_supported_voices()
+*/
+int tts_get_default_voice(tts_h tts, char** language, int* voice_type);
+
+/**
+ * @brief Gets the maximum byte size for text.
+ * @since_tizen 2.3
+ *
+ * @param[in] tts The TTS handle
+ * @param[out] size The maximum byte size for text
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #TTS_ERROR_NONE Successful
+ * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TTS_ERROR_INVALID_STATE Invalid state
+ * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
+ *
+ * @pre The state should be #TTS_STATE_READY.
+ *
+ * @see tts_add_text()
+*/
+int tts_get_max_text_size(tts_h tts, unsigned int* size);
+
+/**
+ * @brief Gets the current state of TTS.
+ * @since_tizen 2.3
+ *
+ * @param[in] tts The TTS handle
+ * @param[out] state The current state of TTS
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #TTS_ERROR_NONE Successful
+ * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
+ *
+ * @see tts_play()
+ * @see tts_stop()
+ * @see tts_pause()
+*/
+int tts_get_state(tts_h tts, tts_state_e* state);
+
+/**
+ * @brief Gets the speed range.
+ * @since_tizen 2.3
+ *
+ * @param[in] tts The TTS handle
+ * @param[out] min The minimun speed value
+ * @param[out] normal The normal speed value
+ * @param[out] max The maximum speed value
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #TTS_ERROR_NONE Successful
+ * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TTS_ERROR_INVALID_STATE Invalid state
+ * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
+ * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
+ *
+ * @pre The state should be #TTS_STATE_CREATED.
+ *
+ * @see tts_add_text()
+*/
+int tts_get_speed_range(tts_h tts, int* min, int* normal, int* max);
+
+/**
+ * @brief Adds a text to the queue.
+ * @since_tizen 2.3
+ *
+ * @remarks Locale(e.g. setlocale()) MUST be set for utf8 text validation check.
+ *
+ * @param[in] tts The TTS handle
+ * @param[in] text An input text based utf8
+ * @param[in] language The language selected from the tts_foreach_supported_voices() (e.g. 'NULL'(Automatic), 'en_US')
+ * @param[in] voice_type The voice type selected from the tts_foreach_supported_voices() (e.g. #TTS_VOICE_TYPE_AUTO, #TTS_VOICE_TYPE_FEMALE)
+ * @param[in] speed A speaking speed (e.g. #TTS_SPEED_AUTO or the value from tts_get_speed_range())
+ * @param[out] utt_id The utterance ID passed to the callback function
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #TTS_ERROR_NONE Successful
+ * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TTS_ERROR_INVALID_STATE Invalid state
+ * @retval #TTS_ERROR_INVALID_VOICE Invalid voice about language, voice type
+ * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
+ * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
+ *
+ * @pre The state should be #TTS_STATE_READY, #TTS_STATE_PLAYING or #TTS_STATE_PAUSED.
+ * @see tts_get_max_text_size()
+*/
+int tts_add_text(tts_h tts, const char* text, const char* language, int voice_type, int speed, int* utt_id);
+
+/**
+ * @brief Starts synthesizing voice from the text and plays the synthesized audio data.
+ * @since_tizen 2.3
+ *
+ * @param[in] tts The TTS handle
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #TTS_ERROR_NONE Successful
+ * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TTS_ERROR_OUT_OF_NETWORK Out of network
+ * @retval #TTS_ERROR_INVALID_STATE Invalid state
+ * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
+ * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
+ *
+ * @pre The current state should be #TTS_STATE_READY or #TTS_STATE_PAUSED.
+ * @post If this function succeeds, the TTS state will be #TTS_STATE_PLAYING.
+ *
+ * @see tts_add_text()
+ * @see tts_pause()
+ * @see tts_stop()
+ * @see tts_utterance_started_cb()
+ * @see tts_utterance_completed_cb()
+ * @see tts_error_cb()
+*/
+int tts_play(tts_h tts);
+
+/**
+ * @brief Stops playing the utterance and clears the queue.
+ * @since_tizen 2.3
+ *
+ * @param[in] tts The TTS handle
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #TTS_ERROR_NONE Successful
+ * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TTS_ERROR_INVALID_STATE Invalid state
+ * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
+ * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
+ *
+ * @pre The TTS state should be #TTS_STATE_READY or #TTS_STATE_PLAYING or #TTS_STATE_PAUSED.
+ * @post If this function succeeds, the TTS state will be #TTS_STATE_READY.
+ *     This function will remove all text via tts_add_text() and synthesized sound data.
+ *
+ * @see tts_play()
+ * @see tts_pause()
+*/
+int tts_stop(tts_h tts);
+
+/**
+ * @brief Pauses the currently playing utterance.
+ * @since_tizen 2.3
+ *
+ * @param[in] tts The TTS handle
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #TTS_ERROR_NONE Successful
+ * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TTS_ERROR_INVALID_STATE Invalid state
+ * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
+ * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
+ *
+ * @pre The TTS state should be #TTS_STATE_PLAYING.
+ * @post If this function succeeds, the TTS state will be #TTS_STATE_PAUSED.
+ *
+ * @see tts_play()
+ * @see tts_stop()
+ * @see tts_error_cb()
+ * @see tts_interrupted_cb()
+*/
+int tts_pause(tts_h tts);
+
+/**
+ * @brief Registers a callback function to be called when the TTS state changes.
+ * @since_tizen 2.3
+ *
+ * @param[in] tts The TTS handle
+ * @param[in] callback The callback function to register
+ * @param[in] user_data The user data to be passed to the callback function
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #TTS_ERROR_NONE Successful
+ * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TTS_ERROR_INVALID_STATE Invalid state
+ * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
+ *
+ * @pre The state should be #TTS_STATE_CREATED.
+ *
+ * @see tts_state_changed_cb()
+ * @see tts_unset_state_changed_cb()
+*/
+int tts_set_state_changed_cb(tts_h tts, tts_state_changed_cb callback, void* user_data);
+
+/**
+ * @brief Unregisters the callback function.
+ * @since_tizen 2.3
+ *
+ * @param[in] tts The TTS handle
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #TTS_ERROR_NONE Successful
+ * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TTS_ERROR_INVALID_STATE Invalid state
+ * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
+ *
+ * @pre The state should be #TTS_STATE_CREATED.
+ *
+ * @see tts_set_state_changed_cb()
+*/
+int tts_unset_state_changed_cb(tts_h tts);
+
+/**
+ * @brief Registers a callback function to detect utterance start.
+ * @since_tizen 2.3
+ *
+ * @param[in] tts The TTS handle
+ * @param[in] callback The callback function to register
+ * @param[in] user_data The user data to be passed to the callback function
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #TTS_ERROR_NONE Successful
+ * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TTS_ERROR_INVALID_STATE Invalid state
+ * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
+ *
+ * @pre The state should be #TTS_STATE_CREATED.
+ *
+ * @see tts_utterance_started_cb()
+ * @see tts_unset_utterance_started_cb()
+*/
+int tts_set_utterance_started_cb(tts_h tts, tts_utterance_started_cb callback, void* user_data);
+
+/**
+ * @brief Unregisters the callback function.
+ * @since_tizen 2.3
+ *
+ * @param[in] tts The TTS handle
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #TTS_ERROR_NONE Successful
+ * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TTS_ERROR_INVALID_STATE Invalid state
+ * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
+ *
+ * @pre The state should be #TTS_STATE_CREATED.
+ *
+ * @see tts_set_utterance_started_cb()
+*/
+int tts_unset_utterance_started_cb(tts_h tts);
+
+/**
+ * @brief Registers a callback function to detect utterance completion.
+ * @since_tizen 2.3
+ *
+ * @param[in] tts The TTS handle
+ * @param[in] callback The callback function to register
+ * @param[in] user_data The user data to be passed to the callback function
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #TTS_ERROR_NONE Successful
+ * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TTS_ERROR_INVALID_STATE Invalid state
+ * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
+ *
+ * @pre The state should be #TTS_STATE_CREATED.
+ *
+ * @see tts_utterance_completed_cb()
+ * @see tts_unset_utterance_completed_cb()
+*/
+int tts_set_utterance_completed_cb(tts_h tts, tts_utterance_completed_cb callback, void* user_data);
+
+/**
+ * @brief Unregisters the callback function.
+ * @since_tizen 2.3
+ *
+ * @param[in] tts The TTS handle
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #TTS_ERROR_NONE Successful
+ * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TTS_ERROR_INVALID_STATE Invalid state
+ * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
+ *
+ * @pre The state should be #TTS_STATE_CREATED.
+ *
+ * @see tts_set_utterance_completed_cb()
+*/
+int tts_unset_utterance_completed_cb(tts_h tts);
+
+/**
+ * @brief Registers a callback function to detect errors.
+ * @since_tizen 2.3
+ *
+ * @param[in] tts The TTS handle
+ * @param[in] callback The callback function to register
+ * @param[in] user_data The user data to be passed to the callback function
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #TTS_ERROR_NONE Successful
+ * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TTS_ERROR_INVALID_STATE Invalid state
+ * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
+ *
+ * @pre The state should be #TTS_STATE_CREATED.
+ *
+ * @see tts_error_cb()
+ * @see tts_unset_error_cb()
+*/
+int tts_set_error_cb(tts_h tts, tts_error_cb callback, void* user_data);
+
+/**
+ * @brief Unregisters the callback function.
+ * @since_tizen 2.3
+ *
+ * @param[in] tts The TTS handle
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #TTS_ERROR_NONE Successful
+ * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TTS_ERROR_INVALID_STATE Invalid state
+ * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
+ *
+ * @pre The state should be #TTS_STATE_CREATED.
+ *
+ * @see tts_set_error_cb()
+*/
+int tts_unset_error_cb(tts_h tts);
+
+/**
+ * @brief Registers a callback function to detect default voice change.
+ * @since_tizen 2.3
+ *
+ * @param[in] tts The TTS handle
+ * @param[in] callback The callback function to register
+ * @param[in] user_data The user data to be passed to the callback function
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #TTS_ERROR_NONE Successful
+ * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TTS_ERROR_INVALID_STATE Invalid state
+ * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
+ *
+ * @pre The state should be #TTS_STATE_CREATED.
+ *
+ * @see tts_default_voice_changed_cb()
+ * @see tts_unset_default_voice_changed_cb()
+*/
+int tts_set_default_voice_changed_cb(tts_h tts, tts_default_voice_changed_cb callback, void* user_data);
+
+/**
+ * @brief Unregisters the callback function.
+ * @since_tizen 2.3
+ *
+ * @param[in] tts The TTS handle
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #TTS_ERROR_NONE Successful
+ * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TTS_ERROR_INVALID_STATE Invalid state
+ * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
+ *
+ * @pre The state should be #TTS_STATE_CREATED.
+ *
+ * @see tts_set_default_voice_changed_cb()
+*/
+int tts_unset_default_voice_changed_cb(tts_h tts);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+/**
+* @}
+*/
+
+#endif /* __TTS_H__ */
similarity index 100%
rename from client/tts.pc.in
rename to include/tts.pc.in
diff --git a/include/tts_setting.h b/include/tts_setting.h
new file mode 100644 (file)
index 0000000..cce268e
--- /dev/null
@@ -0,0 +1,553 @@
+/*
+*  Copyright (c) 2011-2014 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 __TTS_SETTING_H__
+#define __TTS_SETTING_H__
+
+#include <tizen.h>
+
+/**
+* @file tts_setting.h
+*/
+
+/**
+* @addtogroup TTS_SETTING_MODULE
+* @{
+*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** 
+* @brief Enumerations of error codes.
+*/
+typedef enum {
+       TTS_SETTING_ERROR_NONE                  = TIZEN_ERROR_NONE,             /**< Success, No error */
+       TTS_SETTING_ERROR_OUT_OF_MEMORY         = TIZEN_ERROR_OUT_OF_MEMORY,    /**< Out of Memory */
+       TTS_SETTING_ERROR_IO_ERROR              = TIZEN_ERROR_IO_ERROR,         /**< I/O error */
+       TTS_SETTING_ERROR_INVALID_PARAMETER     = TIZEN_ERROR_INVALID_PARAMETER,/**< Invalid parameter */
+       TTS_SETTING_ERROR_PERMISSION_DENIED     = TIZEN_ERROR_PERMISSION_DENIED,/**< Permission denied */
+       TTS_SETTING_ERROR_NOT_SUPPORTED         = TIZEN_ERROR_NOT_SUPPORTED,    /**< TTS is NOT supported */
+       TTS_SETTING_ERROR_INVALID_STATE         = TIZEN_ERROR_TTS | 0x01,       /**< Invalid state */
+       TTS_SETTING_ERROR_INVALID_VOICE         = TIZEN_ERROR_TTS | 0x02,       /**< Invalid voice */
+       TTS_SETTING_ERROR_ENGINE_NOT_FOUND      = TIZEN_ERROR_TTS | 0x03,       /**< No available TTS-engine  */
+       TTS_SETTING_ERROR_OPERATION_FAILED      = TIZEN_ERROR_TTS | 0x04,       /**< Operation failed  */
+       TTS_SETTING_ERROR_NOT_SUPPORTED_FEATURE = TIZEN_ERROR_TTS | 0x06        /**< Not supported feature of current engine */
+} tts_setting_error_e;
+
+/** 
+* @brief Definitions for male voice type.
+*/
+#define TTS_SETTING_VOICE_TYPE_MALE    1
+
+/** 
+* @brief Definitions for female voice type.
+*/
+#define TTS_SETTING_VOICE_TYPE_FEMALE  2
+
+/** 
+* @brief Definitions for child voice type.
+*/
+#define TTS_SETTING_VOICE_TYPE_CHILD   3
+
+/**
+* @brief Called to get a engine information.
+*
+* @param[in] engine_id Engine id.
+* @param[in] engine_name Engine name.
+* @param[in] setting_path Gadget path of engine specific setting.
+* @param[in] user_data User data passed from the tts_setting_foreach_supported_engines().
+*
+* @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop.
+* @pre tts_setting_foreach_supported_engines() will invoke this callback. 
+*
+* @see tts_setting_foreach_supported_engines()
+*/
+typedef bool(*tts_setting_supported_engine_cb)(const char* engine_id, const char* engine_name, const char* setting_path, void* user_data);
+
+/**
+* @brief Called to get a voice.
+*
+* @param[in] engine_id Engine id
+* @param[in] language A language is specified as an ISO 3166 alpha-2 two letter country-code \n
+*              followed by ISO 639-1 for the two-letter language code. 
+*              For example, "ko_KR" for Korean, "en_US" for American English..
+* @param[in] voice_type Voice type
+* @param[in] user_data User data passed from the tts_setting_foreach_surpported_voices()
+*
+* @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop.
+* @pre tts_setting_foreach_surpported_voices() will invoke this callback. 
+*
+* @see tts_setting_foreach_surpported_voices()
+*/
+typedef bool(*tts_setting_supported_voice_cb)(const char* engine_id, const char* language, int voice_type, void* user_data);
+
+/**
+* @brief Called when the default engine is changed.
+*
+* @param[in] engine_id Engine id
+* @param[in] user_data The user data passed from the callback registration function
+*
+* @pre An application registers this callback using tts_setting_set_engine_changed_cb().
+*
+* @see tts_setting_set_engine_changed_cb()
+* @see tts_setting_unset_engine_changed_cb()
+*/
+typedef void (*tts_setting_engine_changed_cb)(const char* engine_id, void *user_data);
+
+/**
+* @brief Called when the default voice is changed.
+*
+* @param[in] language A language
+* @param[in] voice_type Voice type
+* @param[in] auto_voice Auto voice
+* @param[in] user_data The user data passed from the callback registration function
+*
+* @pre An application registers this callback using registration function.
+*
+* @see tts_setting_set_voice_changed_cb()
+* @see tts_setting_unset_voice_changed_cb()
+*/
+typedef void (*tts_setting_voice_changed_cb)(const char* language, int voice_type, bool auto_voice, void *user_data);
+
+/**
+* @brief Called when the default speed is changed.
+*
+* @param[in] speed Default speed
+* @param[in] user_data The user data passed from the callback registration function
+*
+* @pre An application registers this callback using registration function.
+*
+* @see tts_setting_set_speed_changed_cb()
+* @see tts_setting_unset_speed_changed_cb()
+*/
+typedef void (*tts_setting_speed_changed_cb)(int speed, void *user_data);
+
+/**
+* @brief Called when the default pitch is changed.
+*
+* @param[in] pitch Default pitch
+* @param[in] user_data The user data passed from the callback registration function
+*
+* @pre An application registers this callback using registration function.
+*
+* @see tts_setting_set_pitch_changed_cb()
+* @see tts_setting_unset_pitch_changed_cb()
+*/
+typedef void (*tts_setting_pitch_changed_cb)(int pitch, void *user_data);
+
+
+/**
+* @brief Initialize TTS setting.
+*
+* @remarks If the function succeeds, @a tts setting must be released with tts_setting_finalize().
+*
+* @return 0 on success, otherwise a negative error value.
+* @retval #TTS_SETTING_ERROR_NONE Success.
+* @retval #TTS_SETTING_ERROR_INVALID_STATE TTS setting has Already been initialized.
+* @retval #TTS_SETTING_ERROR_OPERATION_FAILED Operation failure.
+* @retval #TTS_SETTING_ERROR_NOT_SUPPORTED TTS NOT supported
+*
+* @see tts_setting_finalize()
+*/
+int tts_setting_initialize();
+
+/**
+* @brief finalize TTS setting. 
+*
+* @return 0 on success, otherwise a negative error value.
+* @retval #TTS_SETTING_ERROR_NONE Success.
+* @retval #TTS_SETTING_ERROR_INVALID_STATE Not initialized.
+* @retval #TTS_SETTING_ERROR_OPERATION_FAILED Operation failure.
+* @retval #TTS_SETTING_ERROR_NOT_SUPPORTED TTS NOT supported
+*
+* @see tts_setting_initialize()
+*/
+int tts_setting_finalize(void);
+
+/**
+* @brief Retrieve supported engine informations using callback function.
+*
+* @param[in] callback Callback function
+* @param[in] user_data User data to be passed to the callback function
+*
+* @return 0 on success, otherwise a negative error value.
+* @retval #TTS_SETTING_ERROR_NONE Success.
+* @retval #TTS_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
+* @retval #TTS_SETTING_ERROR_INVALID_STATE Not initialized.
+* @retval #TTS_SETTING_ERROR_NOT_SUPPORTED TTS NOT supported
+*
+* @post        This function invokes tts_setting_supported_engine_cb() repeatedly for getting engine information. 
+*
+* @see tts_setting_supported_engine_cb()
+*/
+int tts_setting_foreach_supported_engines(tts_setting_supported_engine_cb callback, void* user_data);
+
+/**
+* @brief Get current engine id.
+*
+* @remark If the function is success, @a engine_id must be released with free() by you.
+*
+* @param[out] engine_id Engine id
+*
+* @return 0 on success, otherwise a negative error value.
+* @retval #TTS_SETTING_ERROR_NONE Success.
+* @retval #TTS_SETTING_ERROR_OUT_OF_MEMORY Out of memory.
+* @retval #TTS_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
+* @retval #TTS_SETTING_ERROR_INVALID_STATE Not initialized.
+* @retval #TTS_SETTING_ERROR_OPERATION_FAILED Operation failure.
+* @retval #TTS_SETTING_ERROR_NOT_SUPPORTED TTS NOT supported
+*
+* @see tts_setting_set_engine()
+*/
+int tts_setting_get_engine(char** engine_id);
+
+/**
+* @brief Set current engine id.
+*
+* @param[in] engine_id Engine id
+*
+* @return 0 on success, otherwise a negative error value.
+* @retval #TTS_SETTING_ERROR_NONE Success.
+* @retval #TTS_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
+* @retval #TTS_SETTING_ERROR_INVALID_STATE Not initialized.
+* @retval #TTS_SETTING_ERROR_OPERATION_FAILED Operation failure.
+* @retval #TTS_SETTING_ERROR_NOT_SUPPORTED TTS NOT supported
+*
+* @see tts_setting_get_engine()
+*/
+int tts_setting_set_engine(const char* engine_id);
+
+/**
+* @brief Get supported voices of current engine.
+*
+* @param[in] callback Callback function
+* @param[in] user_data User data to be passed to the callback function
+*
+* @return 0 on success, otherwise a negative error value.
+* @retval #TTS_SETTING_ERROR_NONE Success.
+* @retval #TTS_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
+* @retval #TTS_SETTING_ERROR_INVALID_STATE Not initialized.
+* @retval #TTS_SETTING_ERROR_OPERATION_FAILED Operation failure.
+* @retval #TTS_SETTING_ERROR_NOT_SUPPORTED TTS NOT supported
+*
+* @post        This function invokes tts_setting_supported_voice_cb() repeatedly for getting supported voices. 
+*
+* @see tts_setting_supported_voice_cb()
+*/
+int tts_setting_foreach_surpported_voices(tts_setting_supported_voice_cb callback, void* user_data);
+
+/**
+* @brief Get a default voice of current engine.
+*
+* @remark If the function is success, @a language must be released with free() by you.
+*
+* @param[out] language Default language
+* @param[out] voice_type Default voice type
+*
+* @return 0 on success, otherwise a negative error value.
+* @retval #TTS_SETTING_ERROR_NONE Success.
+* @retval #TTS_SETTING_ERROR_OUT_OF_MEMORY Out of memory.
+* @retval #TTS_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
+* @retval #TTS_SETTING_ERROR_INVALID_STATE Not initialized.
+* @retval #TTS_SETTING_ERROR_OPERATION_FAILED Operation failure.
+* @retval #TTS_SETTING_ERROR_NOT_SUPPORTED TTS NOT supported
+*
+* @see tts_setting_set_voice()
+*/
+int tts_setting_get_voice(char** language, int* voice_type);
+
+/**
+* @brief Set a default voice of current engine.
+*
+* @param[in] language Default language
+* @param[in] voice_type Default voice type
+*
+* @return 0 on success, otherwise a negative error value.
+* @retval #TTS_SETTING_ERROR_NONE Success.
+* @retval #TTS_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
+* @retval #TTS_SETTING_ERROR_INVALID_STATE Not initialized.
+* @retval #TTS_SETTING_ERROR_INVALID_VOICE Invalid voice.
+* @retval #TTS_SETTING_ERROR_OPERATION_FAILED Operation failure.
+* @retval #TTS_SETTING_ERROR_NOT_SUPPORTED TTS NOT supported
+*
+* @see tts_setting_get_voice()
+*/
+int tts_setting_set_voice(const char* language, int voice_type);
+
+/**
+* @brief Get a automatic option of voice.
+*
+* @param[out] value Automatic option
+*
+* @return 0 on success, otherwise a negative error value.
+* @retval #TTS_SETTING_ERROR_NONE Success.
+* @retval #TTS_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
+* @retval #TTS_SETTING_ERROR_INVALID_STATE Not initialized.
+* @retval #TTS_SETTING_ERROR_OPERATION_FAILED Operation failure.
+* @retval #TTS_SETTING_ERROR_NOT_SUPPORTED TTS NOT supported
+*
+* @see tts_setting_set_auto_voice()
+*/
+int tts_setting_get_auto_voice(bool* value);
+
+/**
+* @brief Set a automatic option of voice.
+*
+* @param[in] value Automatic option
+*
+* @return 0 on success, otherwise a negative error value.
+* @retval #TTS_SETTING_ERROR_NONE Success.
+* @retval #TTS_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
+* @retval #TTS_SETTING_ERROR_INVALID_STATE Not initialized.
+* @retval #TTS_SETTING_ERROR_OPERATION_FAILED Operation failure.
+* @retval #TTS_SETTING_ERROR_NOT_SUPPORTED TTS NOT supported
+*
+* @see tts_setting_get_auto_voice()
+*/
+int tts_setting_set_auto_voice(bool value);
+
+/**
+* @brief Gets the speed range.
+*
+* @param[out] min The minimun speed value
+* @param[out] normal The normal speed value
+* @param[out] max The maximum speed value
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #TTS_SETTING_ERROR_NONE Success.
+* @retval #TTS_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
+* @retval #TTS_SETTING_ERROR_INVALID_STATE Not initialized.
+* @retval #TTS_SETTING_ERROR_NOT_SUPPORTED TTS NOT supported
+*
+* @see tts_setting_get_speed()
+* @see tts_setting_set_speed()
+*/
+int tts_setting_get_speed_range(int* min, int* normal, int* max);
+
+/**
+* @brief Get default speed.
+*
+* @param[out] speed Default voice speed
+*
+* @return 0 on success, otherwise a negative error value.
+* @retval #TTS_SETTING_ERROR_NONE Success.
+* @retval #TTS_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
+* @retval #TTS_SETTING_ERROR_INVALID_STATE Not initialized.
+* @retval #TTS_SETTING_ERROR_OPERATION_FAILED Operation failure.
+* @retval #TTS_SETTING_ERROR_NOT_SUPPORTED TTS NOT supported
+*
+* @see tts_setting_get_speed_range()
+* @see tts_setting_set_speed()
+*/
+int tts_setting_get_speed(int* speed);
+
+/**
+* @brief Set default speed.
+*
+* @param[in] speed Default voice speed
+*
+* @return 0 on success, otherwise a negative error value.
+* @retval #TTS_SETTING_ERROR_NONE Success.
+* @retval #TTS_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
+* @retval #TTS_SETTING_ERROR_INVALID_STATE Not initialized.
+* @retval #TTS_SETTING_ERROR_OPERATION_FAILED Operation failure.
+* @retval #TTS_SETTING_ERROR_NOT_SUPPORTED TTS NOT supported
+*
+* @see tts_setting_get_speed_range()
+* @see tts_setting_get_speed()
+*/
+int tts_setting_set_speed(int speed);
+
+/**
+* @brief Gets the pitch range.
+*
+* @param[out] min The minimun pitch value
+* @param[out] normal The normal pitch value
+* @param[out] max The maximum pitch value
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #TTS_SETTING_ERROR_NONE Success.
+* @retval #TTS_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
+* @retval #TTS_SETTING_ERROR_INVALID_STATE Not initialized.
+* @retval #TTS_SETTING_ERROR_NOT_SUPPORTED TTS NOT supported
+*
+* @see tts_setting_get_pitch()
+* @see tts_setting_set_pitch()
+*/
+int tts_setting_get_pitch_range(int* min, int* normal, int* max);
+
+/**
+* @brief Set a default pitch.
+*
+* @param[out] pitch Default voice pitch
+*
+* @return 0 on success, otherwise a negative error value.
+* @retval #TTS_SETTING_ERROR_NONE Success.
+* @retval #TTS_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
+* @retval #TTS_SETTING_ERROR_INVALID_STATE Not initialized.
+* @retval #TTS_SETTING_ERROR_OPERATION_FAILED Operation failure.
+* @retval #TTS_SETTING_ERROR_NOT_SUPPORTED_FEATURE Not supported feature.
+* @retval #TTS_SETTING_ERROR_NOT_SUPPORTED TTS NOT supported
+*
+* @see tts_setting_get_pitch_range()
+* @see tts_setting_set_pitch()
+*/
+int tts_setting_get_pitch(int* pitch);
+
+/**
+* @brief Set a default pitch.
+*
+* @param[in] pitch Default voice pitch
+*
+* @return 0 on success, otherwise a negative error value.
+* @retval #TTS_SETTING_ERROR_NONE Success.
+* @retval #TTS_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
+* @retval #TTS_SETTING_ERROR_INVALID_STATE Not initialized.
+* @retval #TTS_SETTING_ERROR_OPERATION_FAILED Operation failure.
+* @retval #TTS_SETTING_ERROR_NOT_SUPPORTED_FEATURE Not supported feature.
+* @retval #TTS_SETTING_ERROR_NOT_SUPPORTED TTS NOT supported
+*
+* @see tts_setting_get_pitch_range()
+* @see tts_setting_get_pitch()
+*/
+int tts_setting_set_pitch(int pitch);
+
+/**
+* @brief Registers a callback function to be called when engine information is changed
+*
+* @param[in] callback The callback function to register
+* @param[in] user_data The user data to be passed to the callback function
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #TTS_SETTING_ERROR_NONE Successful
+* @retval #TTS_SETTING_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #TTS_SETTING_ERROR_OPERATION_FAILED Invalid state
+* @retval #TTS_SETTING_ERROR_NOT_SUPPORTED TTS NOT supported
+*
+* @see tts_setting_engine_changed_cb()
+* @see tts_setting_unset_engine_changed_cb()
+*/
+int tts_setting_set_engine_changed_cb(tts_setting_engine_changed_cb callback, void* user_data);
+
+/**
+* @brief Unregisters the callback function
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #TTS_SETTING_ERROR_NONE Successful
+* @retval #TTS_SETTING_ERROR_OPERATION_FAILED Invalid state
+* @retval #TTS_SETTING_ERROR_NOT_SUPPORTED TTS NOT supported
+*
+* @see tts_setting_set_engine_changed_cb()
+*/
+int tts_setting_unset_engine_changed_cb();
+
+/**
+* @brief Registers a callback function to be called when default voice is changed
+*
+* @param[in] callback The callback function to register
+* @param[in] user_data The user data to be passed to the callback function
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #TTS_SETTING_ERROR_NONE Successful
+* @retval #TTS_SETTING_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #TTS_SETTING_ERROR_OPERATION_FAILED Invalid state
+* @retval #TTS_SETTING_ERROR_NOT_SUPPORTED TTS NOT supported
+*
+* @see tts_setting_voice_changed_cb()
+* @see tts_setting_unset_voice_changed_cb()
+*/
+int tts_setting_set_voice_changed_cb(tts_setting_voice_changed_cb callback, void* user_data);
+
+/**
+* @brief Unregisters the callback function
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #TTS_SETTING_ERROR_NONE Successful
+* @retval #TTS_SETTING_ERROR_OPERATION_FAILED Invalid state
+* @retval #TTS_SETTING_ERROR_NOT_SUPPORTED TTS NOT supported
+*
+* @see tts_setting_set_voice_changed_cb()
+*/
+int tts_setting_unset_voice_changed_cb();
+
+/**
+* @brief Registers a callback function to be called when default speed is changed
+*
+* @param[in] callback The callback function to register
+* @param[in] user_data The user data to be passed to the callback function
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #TTS_SETTING_ERROR_NONE Successful
+* @retval #TTS_SETTING_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #TTS_SETTING_ERROR_OPERATION_FAILED Invalid state
+* @retval #TTS_SETTING_ERROR_NOT_SUPPORTED TTS NOT supported
+*
+* @see tts_setting_speed_changed_cb()
+* @see tts_setting_unset_speed_changed_cb()
+*/
+int tts_setting_set_speed_changed_cb(tts_setting_speed_changed_cb callback, void* user_data);
+
+/**
+* @brief Unregisters the callback function
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #TTS_SETTING_ERROR_NONE Successful
+* @retval #TTS_SETTING_ERROR_OPERATION_FAILED Invalid state
+* @retval #TTS_SETTING_ERROR_NOT_SUPPORTED TTS NOT supported
+*
+* @see tts_setting_set_speed_changed_cb()
+*/
+int tts_setting_unset_speed_changed_cb();
+
+/**
+* @brief Registers a callback function to be called when default pitch is changed
+*
+* @param[in] callback The callback function to register
+* @param[in] user_data The user data to be passed to the callback function
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #TTS_SETTING_ERROR_NONE Successful
+* @retval #TTS_SETTING_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #TTS_SETTING_ERROR_OPERATION_FAILED Invalid state
+* @retval #TTS_SETTING_ERROR_NOT_SUPPORTED TTS NOT supported
+*
+* @see tts_setting_pitch_changed_cb()
+* @see tts_setting_unset_pitch_changed_cb()
+*/
+int tts_setting_set_pitch_changed_cb(tts_setting_pitch_changed_cb callback, void* user_data);
+
+/**
+* @brief Unregisters the callback function
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #TTS_SETTING_ERROR_NONE Successful
+* @retval #TTS_SETTING_ERROR_OPERATION_FAILED Invalid state
+* @retval #TTS_SETTING_ERROR_NOT_SUPPORTED TTS NOT supported
+*
+* @see tts_setting_set_pitch_changed_cb()
+*/
+int tts_setting_unset_pitch_changed_cb();
+
+
+#ifdef __cplusplus
+}
+#endif
+
+/**
+* @}
+*/
+
+#endif /* __TTS_SETTING_H__ */
index 1fbfc33..b5f2ace 100644 (file)
@@ -1,27 +1,28 @@
 Name:       tts
 Summary:    Text To Speech client library and daemon
-Version:    0.1.62
-Release:    0
-Group:      Graphics & UI Framework/Libraries
+Version:    0.2.41
+Release:    1
+Group:      Graphics & UI Framework/Voice Framework
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
 Source1001: %{name}.manifest
 Source1002: %{name}-devel.manifest
 Requires(post):   /sbin/ldconfig
 Requires(postun): /sbin/ldconfig
-BuildRequires:    pkgconfig(glib-2.0)
-BuildRequires:    pkgconfig(dbus-1)
-BuildRequires:    pkgconfig(mm-player)
-BuildRequires:    pkgconfig(mm-common)
-BuildRequires:    pkgconfig(mm-session)
-BuildRequires:    pkgconfig(dlog)
-BuildRequires:    pkgconfig(vconf)
-BuildRequires:    pkgconfig(vconf-internal-keys)
-BuildRequires:    pkgconfig(ecore)
-BuildRequires:    pkgconfig(ecore-file)
-BuildRequires:    pkgconfig(capi-system-runtime-info)
-BuildRequires:    pkgconfig(libtzplatform-config)
-BuildRequires:    cmake
+BuildRequires:  pkgconfig(aul)
+BuildRequires:  pkgconfig(capi-media-audio-io)
+BuildRequires:  pkgconfig(capi-system-info)
+BuildRequires:  pkgconfig(dbus-1)
+BuildRequires:  pkgconfig(dlog)
+BuildRequires:  pkgconfig(ecore)
+BuildRequires:  pkgconfig(glib-2.0)
+BuildRequires:  pkgconfig(libprivilege-control)
+BuildRequires:  pkgconfig(libtzplatform-config)
+BuildRequires:  pkgconfig(libxml-2.0)
+BuildRequires:  pkgconfig(vconf)
+
+
+BuildRequires:  cmake
 
 %description
 Text To Speech client library and daemon.
@@ -32,9 +33,25 @@ Summary:    Text To Speech header files for TTS development
 Group:      libdevel
 Requires:   %{name} = %{version}-%{release}
 
+%package setting-devel
+Summary:    Text To Speech setting header files for TTS development
+Group:      libdevel
+Requires:   %{name} = %{version}-%{release}
+
+%package engine-devel
+Summary:    Text To Speech engine header files for TTS development
+Group:      libdevel
+Requires:   %{name} = %{version}-%{release}
+
 %description devel
 Text To Speech header files for TTS development.
 
+%description setting-devel
+Text To Speech setting header files for TTS development.
+
+%description engine-devel
+Text To Speech engine header files for TTS development.
+
 
 %prep
 %setup -q -n %{name}-%{version}
@@ -42,32 +59,72 @@ cp %{SOURCE1001} %{SOURCE1002} .
 
 
 %build
-%cmake .
+export CFLAGS="$CFLAGS -DTIZEN_ENGINEER_MODE"
+export CXXFLAGS="$CXXFLAGS -DTIZEN_ENGINEER_MODE"
+export FFLAGS="$FFLAGS -DTIZEN_ENGINEER_MODE"
+
+export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE"
+export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
+export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
+
+
+cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DLIBDIR=%{_libdir} -DINCLUDEDIR=%{_includedir}
 make %{?jobs:-j%jobs}
 
 %install
 rm -rf %{buildroot}
 mkdir -p %{buildroot}/usr/share/license
+install LICENSE.APLv2 %{buildroot}/usr/share/license/%{name}
+
 %make_install
 
-%post -p /sbin/ldconfig
+%post 
+/sbin/ldconfig
+
+mkdir -p /usr/lib/voice
+chsmack -a '_' /usr/lib/voice
+
+mkdir -p /usr/share/voice
+chsmack -a '_' /usr/share/voice
+
+mkdir -p /opt/home/app/.voice
+chown 5000:5000 /opt/home/app/.voice
+
+mkdir -p /opt/usr/data/voice/tts/1.0/engine-info
+
+chsmack -a '_' /opt/usr/data/voice/
+chsmack -a 'tts-server' /opt/usr/data/voice/tts/
+chsmack -a 'tts-server' /opt/usr/data/voice/tts/1.0
+chsmack -a 'tts-server' /opt/usr/data/voice/tts/1.0/engine-info
+
+chown 5000:5000 /opt/usr/data/voice
+chown 5000:5000 /opt/usr/data/voice/tts
+chown 5000:5000 /opt/usr/data/voice/tts/1.0
+chown 5000:5000 /opt/usr/data/voice/tts/1.0/engine-info
 
 %postun -p /sbin/ldconfig
 
 %files
 %manifest %{name}.manifest
-%config %{_sysconfdir}/config/sysinfo-tts.xml
 %defattr(-,root,root,-)
 %{_libdir}/lib*.so
-%{_libdir}/voice/tts/1.0/ttsd.conf
+/usr/lib/voice/tts/1.0/tts-config.xml
 %{_bindir}/tts-daemon*
-/usr/share/license/*
+/opt/usr/devel/bin/tts-test
+/usr/share/license/%{name}
 
 %files devel
 %manifest %{name}-devel.manifest
 %defattr(-,root,root,-)
 %{_libdir}/pkgconfig/tts.pc
-%{_libdir}/pkgconfig/tts-setting.pc
 %{_includedir}/tts.h
+
+%files setting-devel
+%defattr(-,root,root,-)
+%{_libdir}/pkgconfig/tts-setting.pc
 %{_includedir}/tts_setting.h
+
+%files engine-devel
+%defattr(-,root,root,-)
+%{_libdir}/pkgconfig/tts-engine.pc
 %{_includedir}/ttsp.h
index f4a0d5d..1837a5f 100644 (file)
@@ -1,94 +1,69 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(tts-daemon)
-
-SET(PREFIX ${CMAKE_INSTALL_PREFIX})
-SET(EXEC_PREFIX "${PREFIX}")
-SET(LIBDIR "${LIB_INSTALL_DIR}")
-SET(INCLUDEDIR "${PREFIX}/include")
-SET(VERSION 0.0.1)
-
-SET(PREFIX ${CMAKE_INSTALL_PREFIX})
-SET(EXEC_PREFIX "${PREFIX}")
-SET(LIBDIR "${LIB_INSTALL_DIR}/voice/tts/1.0/engine")
-SET(INCLUDEDIR "${PREFIX}/include")
-SET(VERSION 0.0.1)
-
 SET(SRCS 
-       ttsd_data.cpp
-       ttsd_player.c
-       ttsd_engine_agent.c
        ttsd_config.c
-       ttsd_server.c
-       ttsd_network.c
+       ttsd_data.cpp
        ttsd_dbus.c
        ttsd_dbus_server.c
+       ttsd_engine_agent.c
        ttsd_main.c
+       ttsd_network.c
+       ttsd_player.c
+       ttsd_server.c
+       ../common/tts_config_mgr.c
+       ../common/tts_config_parser.c
 )
        
 SET(NOTI_SRCS
-    ttsd_data.cpp
-       ttsd_player.c
-       ttsd_engine_agent.c
-       ttsd_config_noti.c
-       ttsd_server.c
-       ttsd_network.c
+       ttsd_config.c
+       ttsd_data.cpp
        ttsd_dbus.c
        ttsd_dbus_server.c
+       ttsd_engine_agent.c
        ttsd_main_noti.c
+       ttsd_network.c
+       ttsd_player.c
+       ttsd_server.c
+       ../common/tts_config_mgr.c
+       ../common/tts_config_parser.c
 )      
 
 SET(SR_SRCS
-    ttsd_data.cpp
-       ttsd_player.c
-       ttsd_engine_agent.c
-       ttsd_config_sr.c
-       ttsd_server.c
-       ttsd_network.c
+       ttsd_config.c
+       ttsd_data.cpp
        ttsd_dbus.c
        ttsd_dbus_server.c
+       ttsd_engine_agent.c
        ttsd_main_sr.c
+       ttsd_network.c
+       ttsd_player.c
+       ttsd_server.c
+       ../common/tts_config_mgr.c
+       ../common/tts_config_parser.c
 )
 
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
-INCLUDE_DIRECTORIES(${INCLUDEDIR})     
-INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/../common")
+INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/common)
 
 FOREACH(flag ${pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
 ENDFOREACH(flag)
 
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE")
+SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE")
 SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
 SET(CMAKE_C_FLAGS_RELEASE "-O2")
-SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
-
-## Add definitions ##
-ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
-ADD_DEFINITIONS("-DVENDOR=\"${VENDOR}\"")
-ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE}\"")
-ADD_DEFINITIONS("-DPACKAGE_NAME=\"${PKGNAME}\"")
-ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
-ADD_DEFINITIONS("-DLOCALEDIR=\"${LOCALEDIR}\"")
-ADD_DEFINITIONS("-DEDJDIR=\"${EDJDIR}\"")
-ADD_DEFINITIONS("-DIMAGEDIR=\"${IMAGEDIR}\"")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
 
 ## Executable ##
-ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} -ldl ${pkgs_LDFLAGS})
-
-ADD_EXECUTABLE("${PROJECT_NAME}-noti" ${NOTI_SRCS})
-TARGET_LINK_LIBRARIES("${PROJECT_NAME}-noti" -ldl ${pkgs_LDFLAGS})
+ADD_EXECUTABLE("${PROJECT_NAME}-daemon" ${SRCS})
+TARGET_LINK_LIBRARIES("${PROJECT_NAME}-daemon" -ldl ${pkgs_LDFLAGS})
 
-ADD_EXECUTABLE("${PROJECT_NAME}-sr" ${SR_SRCS})
-TARGET_LINK_LIBRARIES("${PROJECT_NAME}-sr" -ldl ${pkgs_LDFLAGS})
+ADD_EXECUTABLE("${PROJECT_NAME}-daemon-noti" ${NOTI_SRCS})
+TARGET_LINK_LIBRARIES("${PROJECT_NAME}-daemon-noti" -ldl ${pkgs_LDFLAGS})
 
+ADD_EXECUTABLE("${PROJECT_NAME}-daemon-sr" ${SR_SRCS})
+TARGET_LINK_LIBRARIES("${PROJECT_NAME}-daemon-sr" -ldl ${pkgs_LDFLAGS})
 
 ## Install ##
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)
-INSTALL(TARGETS "${PROJECT_NAME}-noti" DESTINATION bin)
-INSTALL(TARGETS "${PROJECT_NAME}-sr" DESTINATION bin)
-
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/ttsp.h DESTINATION include)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/ttsd.conf DESTINATION lib${LIB_SUFFIX}/voice/tts/1.0)
-
+INSTALL(TARGETS "${PROJECT_NAME}-daemon" DESTINATION bin)
+INSTALL(TARGETS "${PROJECT_NAME}-daemon-noti" DESTINATION bin)
+INSTALL(TARGETS "${PROJECT_NAME}-daemon-sr" DESTINATION bin)
diff --git a/server/ttsd.conf b/server/ttsd.conf
deleted file mode 100644 (file)
index 3d23424..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-ENGINE_ID 27F277E9-BBC4-4dca-B553-D9884A3CDAA0\r
-VOICE en_US 2\r
-SPEED 3
\ No newline at end of file
index 623637d..3442c5d 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*  Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd All Rights Reserved 
+*  Copyright (c) 2011-2014 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
 *  limitations under the License.
 */
 
-#include <Ecore_File.h>
-#include <runtime_info.h>
-#include <vconf.h>
 
 /* For multi-user support */
 #include <tzplatform_config.h>
 
-#include "ttsd_main.h"
+#include "tts_config_mgr.h"
 #include "ttsd_config.h"
-#include "ttsd_engine_agent.h"
-#include "ttsd_data.h"
-
-#define CONFIG_DEFAULT                 BASE_DIRECTORY_DEFAULT"/ttsd.conf"
-
-#define DEFAULT_ERROR_FILE_NAME                tzplatform_mkpath(TZ_USER_HOME, ".voice/ttsd_default.err")
-
-#define ENGINE_ID      "ENGINE_ID"
-#define VOICE          "VOICE"
-#define SPEED          "SPEED"
+#include "ttsd_main.h"
 
-static char*   g_engine_id;
-static char*   g_language;
-static int     g_vc_type;
-static int     g_speed;
 
 static ttsd_config_changed_cb g_callback;
 
-int __ttsd_config_save()
+static ttsd_config_screen_reader_changed_cb g_sr_callback;
+
+void __ttsd_config_engine_changed_cb(const char* engine_id, const char* setting, const char* language, int voice_type, bool auto_voice, void* user_data)
 {
-       if (0 != access(DEFAULT_CONFIG_FILE_NAME, R_OK|W_OK)) {
-               if (0 == ecore_file_mkpath(CONFIG_DIRECTORY)) {
-                       SLOG(LOG_WARN, get_tag(), "[Config WARNING] Fail to create directory (%s)", CONFIG_DIRECTORY);
-               } else {
-                       SLOG(LOG_DEBUG, get_tag(), "[Config] Create directory (%s)", CONFIG_DIRECTORY);
-               }
+       /* Need to check engine is valid */
+       if (false == tts_config_check_default_engine_is_valid(engine_id)) {
+               SLOG(LOG_ERROR, get_tag(), "Engine id is NOT valid : %s", engine_id);
+               return;
        }
 
-       FILE* config_fp;
-       config_fp = fopen(DEFAULT_CONFIG_FILE_NAME, "w+");
-
-       if (NULL == config_fp) {
-               /* make file and file default */
-               SLOG(LOG_WARN, get_tag(), "[Config WARNING] Fail to open config (%s)", DEFAULT_CONFIG_FILE_NAME);
-               return -1;
+       if (NULL != g_callback) {
+               SECURE_SLOG(LOG_DEBUG, get_tag(), "Call the engine reload callback : engine id(%s)", engine_id);
+               g_callback(TTS_CONFIG_TYPE_ENGINE, engine_id, 0);
+               SECURE_SLOG(LOG_DEBUG, get_tag(), "Call the voice changed callback : lang(%s), type(%d)", language, voice_type);
+               g_callback(TTS_CONFIG_TYPE_VOICE, language, voice_type);
+       } else {
+               SLOG(LOG_ERROR, get_tag(), "Config changed callback is NULL");
        }
-
-       SLOG(LOG_DEBUG, get_tag(), "[Config] Rewrite config file");
-
-       /* Write engine id */
-       fprintf(config_fp, "%s %s\n", ENGINE_ID, g_engine_id);
-
-       /* Write voice */
-       fprintf(config_fp, "%s %s %d\n", VOICE, g_language, g_vc_type);
-
-       /* Read speed */
-       fprintf(config_fp, "%s %d\n", SPEED, g_speed);
-
-       fclose(config_fp);
-
-       return 0;
 }
 
-int __ttsd_config_load()
+void __ttsd_config_voice_changed_cb(const char* before_language, int before_type, const char* language, int type, bool auto_voice, void* user_data)
 {
-       FILE* config_fp;
-       char buf_id[256] = {0};
-       char buf_param[256] = {0};
-       int int_param = 0;
-       bool is_default_open = false;
-
-       config_fp = fopen(DEFAULT_CONFIG_FILE_NAME, "r");
-
-       if (NULL == config_fp) {
-               SLOG(LOG_WARN, get_tag(), "[Config WARNING] Not open file(%s)", DEFAULT_CONFIG_FILE_NAME);
-               
-               config_fp = fopen(CONFIG_DEFAULT, "r");
-               if (NULL == config_fp) {
-                       SLOG(LOG_ERROR, get_tag(), "[Config WARNING] Not open original config file(%s)", CONFIG_DEFAULT);
-                       return -1;
-               }
-               is_default_open = true;
+       /* Need to check voice is valid */
+       if (false == tts_config_check_default_voice_is_valid(language, type)) {
+               SLOG(LOG_ERROR, get_tag(), "Lang(%s) type(%d) is NOT valid : %s", language, type);
+               return;
        }
 
-       /* Read engine id */
-       if (EOF == fscanf(config_fp, "%s %s", buf_id, buf_param)) {
-               fclose(config_fp);
-               SLOG(LOG_WARN, get_tag(), "[Config WARNING] Fail to read config (engine id)");
-               __ttsd_config_save();
-               return -1;
+       if (NULL != g_callback) {
+               g_callback(TTS_CONFIG_TYPE_VOICE, language, type);
        } else {
-               if (0 == strncmp(ENGINE_ID, buf_id, strlen(ENGINE_ID))) {
-                       g_engine_id = strdup(buf_param);
-               } else {
-                       fclose(config_fp);
-                       SLOG(LOG_WARN, get_tag(), "[Config WARNING] Fail to load config (engine id)");
-                       __ttsd_config_save();
-                       return -1;
-               }
+               SLOG(LOG_ERROR, get_tag(), "Config changed callback is NULL");
        }
+}
 
-       /* Read voice */
-       if (EOF == fscanf(config_fp, "%s %s %d", buf_id, buf_param, &int_param)) {
-               fclose(config_fp);
-               SLOG(LOG_WARN, get_tag(), "[Config WARNING] Fail to read config (voice)");
-               __ttsd_config_save();
-               return -1;
+void __ttsd_config_speech_rate_changed_cb(int value, void* user_data)
+{
+       if (NULL != g_callback) {
+               g_callback(TTS_CONFIG_TYPE_SPEED, NULL, value);
        } else {
-               if (0 == strncmp(VOICE, buf_id, strlen(VOICE))) {
-                       g_language = strdup(buf_param);
-                       g_vc_type = int_param;
-               } else {
-                       fclose(config_fp);
-                       SLOG(LOG_WARN, get_tag(), "[Config WARNING] Fail to load config (voice)");
-                       __ttsd_config_save();
-                       return -1;
-               }
-       }
-       
-       if (true == is_default_open) {
-               /* Change default language to display language */
-               char* value;
-               value = vconf_get_str(VCONFKEY_LANGSET);
-
-               if (NULL != value) {
-                       SLOG(LOG_DEBUG, get_tag(), "[Config] System language : %s", value);
-                       strncpy(g_language, value, strlen(g_language));
-                       SLOG(LOG_DEBUG, get_tag(), "[Config] Default language : %s", g_language);
-
-                       free(value);
-               } else {
-                       SLOG(LOG_ERROR, get_tag(), "[Config ERROR] Fail to get system language");
-               }
+               SLOG(LOG_ERROR, get_tag(), "Config changed callback is NULL");
        }
+}
 
-       /* Read speed */
-       if (EOF == fscanf(config_fp, "%s %d", buf_id, &int_param)) {
-               fclose(config_fp);
-               SLOG(LOG_WARN, get_tag(), "[Config WARNING] Fail to read config (speed)");
-               __ttsd_config_save();
-               return -1;
+void __ttsd_config_pitch_changed_cb(int value, void* user_data)
+{
+       if (NULL != g_callback) {
+               g_callback(TTS_CONFIG_TYPE_PITCH, NULL, value);
        } else {
-               if (0 == strncmp(SPEED, buf_id, strlen(SPEED))) {
-                       g_speed = int_param;
-               } else {
-                       fclose(config_fp);
-                       SLOG(LOG_WARN, get_tag(), "[Config WARNING] Fail to load config (speed)");
-                       __ttsd_config_save();
-                       return -1;
-               }
+               SLOG(LOG_ERROR, get_tag(), "Config changed callback is NULL");
        }
-       
-       fclose(config_fp);
-
-       SLOG(LOG_DEBUG, get_tag(), "[Config] Load config : engine(%s), voice(%s,%d), speed(%d)",
-               g_engine_id, g_language, g_vc_type, g_speed);
+}
 
-       if (true == is_default_open) {
-               if(0 == __ttsd_config_save()) {
-                       SLOG(LOG_DEBUG, get_tag(), "[Config] Create config(%s)", DEFAULT_CONFIG_FILE_NAME);
-               }
+void __ttsd_config_screen_reader_changed_cb(bool value)
+{
+       if (NULL != g_sr_callback) {
+               g_sr_callback(value);
        }
-
-       return 0;
 }
 
-int ttsd_config_initialize(ttsd_config_changed_cb callback)
+int ttsd_config_initialize(ttsd_config_changed_cb config_cb)
 {
-       g_engine_id = NULL;
-       g_language = NULL;
-       g_vc_type = 1;
-       g_speed = 3;
+       if (NULL == config_cb) {
+               SLOG(LOG_ERROR, get_tag(), "[Config] Invalid parameter");
+               return -1;
+       }
 
-       g_callback = callback;
-       
-       ecore_file_mkpath(CONFIG_DIRECTORY);
+       g_callback = config_cb;
+       g_sr_callback = NULL;
+
+       int ret = -1;
+       ret = tts_config_mgr_initialize(getpid());
+       if (0 != ret) {
+               SLOG(LOG_ERROR, get_tag(), "[Config] Fail to initialize config manager");
+               return -1;
+       }
 
-       __ttsd_config_load();
+       ret = tts_config_mgr_set_callback(getpid(), __ttsd_config_engine_changed_cb, __ttsd_config_voice_changed_cb, 
+               __ttsd_config_speech_rate_changed_cb, __ttsd_config_pitch_changed_cb, NULL);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, get_tag(), "[ERROR] Fail to set config changed : %d", ret);
+               return -1;
+       }
 
        return 0;
 }
 
 int ttsd_config_finalize()
 {
-       __ttsd_config_save();
+       tts_config_unset_screen_reader_callback(getpid());
 
-       if (NULL != g_language) {
-               free(g_language);
-       }
-
-       if (NULL != g_engine_id) {
-               free(g_engine_id);
-       }
+       tts_config_mgr_finalize(getpid());
 
        return 0;
 }
 
-int ttsd_config_update_language()
+int ttsd_config_set_screen_reader_callback(ttsd_config_screen_reader_changed_cb sr_cb)
 {
-       /* no work in default mode */
+       if (NULL == sr_cb) {
+               SLOG(LOG_ERROR, get_tag(), "[Config] Invalid parameter");
+               return -1;
+       }
+
+       g_sr_callback = sr_cb;
+
+       int ret = tts_config_set_screen_reader_callback(getpid(), __ttsd_config_screen_reader_changed_cb) ;
+       if (0 != ret) {
+               SLOG(LOG_ERROR, get_tag(), "[Config] Fail to set screen reader callback");
+               return -1;
+       }
        return 0;
 }
 
@@ -218,10 +140,8 @@ int ttsd_config_get_default_engine(char** engine_id)
        if (NULL == engine_id)
                return -1;
 
-       if (NULL != g_engine_id) {
-               *engine_id = strdup(g_engine_id);
-       } else {
-               SLOG(LOG_ERROR, get_tag(), "[Config ERROR] Current engine id is NULL");
+       if (0 != tts_config_mgr_get_engine(engine_id)) {
+               SLOG(LOG_ERROR, get_tag(), "[Config ERROR] Fail to get engine id");
                return -1;
        }
 
@@ -233,12 +153,12 @@ int ttsd_config_set_default_engine(const char* engine_id)
        if (NULL == engine_id)
                return -1;
 
-       if (NULL != g_engine_id)
-               free(g_engine_id);
-
-       g_engine_id = strdup(engine_id);
+       if (true == tts_config_check_default_engine_is_valid(engine_id)) {
+               if (0 != tts_config_mgr_set_engine(engine_id)) {
+                       SLOG(LOG_ERROR, get_tag(), "[Config ERROR] Fail to set engine id");
+               }
+       }
 
-       __ttsd_config_save();
        return 0;
 }
 
@@ -247,29 +167,10 @@ int ttsd_config_get_default_voice(char** language, int* type)
        if (NULL == language || NULL == type)
                return -1;
 
-       if (NULL != g_language) {
-               *language = strdup(g_language);
-               *type = g_vc_type;
-       } else {
-               SLOG(LOG_ERROR, get_tag(), "[Config ERROR] Current language is NULL");
-               return -1;
+       if (0 != tts_config_mgr_get_voice(language, type)) {
+               SLOG(LOG_ERROR, get_tag(), "[Config ERROR] Fail to get default voice");
        }
-       
-       return 0;
-}
-
-int ttsd_config_set_default_voice(const char* language, int type)
-{
-       if (NULL == language)
-               return -1;
-
-       if (NULL != g_language)
-               free(g_language);
 
-       g_language = strdup(language);
-       g_vc_type = type;
-
-       __ttsd_config_save();
        return 0;
 }
 
@@ -278,16 +179,22 @@ int ttsd_config_get_default_speed(int* speed)
        if (NULL == speed)
                return -1;
 
-       *speed = g_speed;
+       if (0 != tts_config_mgr_get_speech_rate(speed)) {
+               SLOG(LOG_ERROR, get_tag(), "[Config ERROR] Fail to get default speech rate");
+       }
 
        return 0;
 }
 
-int ttsd_config_set_default_speed(int speed)
+int ttsd_config_get_default_pitch(int* pitch)
 {
-       g_speed = speed;
+       if (NULL == pitch)
+               return -1;
+
+       if (0 != tts_config_mgr_get_pitch(pitch)) {
+               SLOG(LOG_ERROR, get_tag(), "[Config ERROR] Fail to get default pitch");
+       }
 
-       __ttsd_config_save();
        return 0;
 }
 
@@ -306,4 +213,4 @@ int ttsd_config_save_error(int uid, int uttid, const char* lang, int vctype, con
        SLOG(LOG_ERROR, get_tag(), "==================================================");
 
        return 0;
-}
+}
\ No newline at end of file
index 1b6adba..76e4597 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*  Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd All Rights Reserved 
+*  Copyright (c) 2011-2014 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
@@ -15,6 +15,8 @@
 #ifndef __TTSD_CONFIG_H_
 #define __TTSD_CONFIG_H_
 
+#include <stdbool.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -22,16 +24,19 @@ extern "C" {
 typedef enum {
        TTS_CONFIG_TYPE_ENGINE,
        TTS_CONFIG_TYPE_VOICE,
-       TTS_CONFIG_TYPE_SPEED
+       TTS_CONFIG_TYPE_SPEED,
+       TTS_CONFIG_TYPE_PITCH
 }tts_config_type_e;
 
-typedef void (*ttsd_config_changed_cb)(tts_config_type_e type, const char* str_param, int int_param); 
+typedef void (*ttsd_config_changed_cb)(tts_config_type_e type, const char* str_param, int int_param);
+
+typedef void (*ttsd_config_screen_reader_changed_cb)(bool value);
 
-int ttsd_config_initialize(ttsd_config_changed_cb callback);
+int ttsd_config_initialize(ttsd_config_changed_cb config_cb);
 
 int ttsd_config_finalize();
 
-int ttsd_config_update_language();
+int ttsd_config_set_screen_reader_callback(ttsd_config_screen_reader_changed_cb sr_cb);
 
 int ttsd_config_get_default_engine(char** engine_id);
 
@@ -39,11 +44,9 @@ int ttsd_config_set_default_engine(const char* engine_id);
 
 int ttsd_config_get_default_voice(char** language, int* type);
 
-int ttsd_config_set_default_voice(const char* langauge, int type);
-
 int ttsd_config_get_default_speed(int* speed);
 
-int ttsd_config_set_default_speed(int speed);
+int ttsd_config_get_default_pitch(int* pitch);
 
 int ttsd_config_save_error(int uid, int uttid, const char* lang, int vctype, const char* text, 
                           const char* func, int line, const char* message);
diff --git a/server/ttsd_config_noti.c b/server/ttsd_config_noti.c
deleted file mode 100644 (file)
index d5a7110..0000000
+++ /dev/null
@@ -1,459 +0,0 @@
-/*
-*  Copyright (c) 2012, 2013 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 <Ecore.h>
-#include <Ecore_File.h>
-#include <runtime_info.h>
-#include <sys/inotify.h>
-#include <vconf.h>
-
-/* For multi-user support */
-#include <tzplatform_config.h>
-
-#include "ttsd_main.h"
-#include "ttsd_config.h"
-#include "ttsd_engine_agent.h"
-#include "ttsd_data.h"
-
-#define NOTI_ERROR_FILE_NAME           tzplatform_mkpath(TZ_USER_HOME, ".voice/ttsd_noti.err")
-
-#define ENGINE_ID      "ENGINE_ID"
-#define VOICE          "VOICE"
-#define SPEED          "SPEED"
-
-
-static char*   g_engine_id;
-static char*   g_language;
-static int     g_vc_type;
-static int     g_speed;
-
-static Ecore_Fd_Handler* g_fd_handler_noti = NULL;
-static int g_fd_noti;
-static int g_wd_noti;
-
-static ttsd_config_changed_cb g_callback;
-
-
-int __ttsd_config_compare()
-{
-       FILE* config_fp;
-       char buf_id[256] = {0};
-       char buf_param[256] = {0};
-       int int_param = 0;
-
-       config_fp = fopen(DEFAULT_CONFIG_FILE_NAME, "r");
-
-       if (NULL == config_fp) {
-               SLOG(LOG_ERROR, get_tag(), "[Config ERROR] Not open file(%s)", DEFAULT_CONFIG_FILE_NAME);
-
-               return -1;
-       }
-
-       /* Read engine id */
-       if (EOF == fscanf(config_fp, "%s %s", buf_id, buf_param)) {
-               fclose(config_fp);
-               SLOG(LOG_ERROR, get_tag(), "[Config WARNING] Fail to read config (engine id)");
-               return -1;
-       } else {
-               if (0 == strncmp(ENGINE_ID, buf_id, strlen(ENGINE_ID))) {
-                       if (NULL != g_engine_id) {
-                               if (0 != strcmp(g_engine_id, buf_param)) {
-                                       free(g_engine_id);
-                                       g_engine_id = strdup(buf_param);
-
-                                       SLOG(LOG_DEBUG, get_tag(), "[Config] engine id is changed : %s", g_engine_id);
-
-                                       if (NULL != g_callback)
-                                               g_callback(TTS_CONFIG_TYPE_ENGINE, g_engine_id, 0);
-                               }
-                       } else {
-                               SLOG(LOG_ERROR, get_tag(), "[Config ERROR] Current engine id is not available");
-                               g_engine_id = strdup(buf_param);
-                               if (NULL != g_callback)
-                                       g_callback(TTS_CONFIG_TYPE_ENGINE, g_engine_id, 0);
-                       }
-               } else {
-                       fclose(config_fp);
-                       SLOG(LOG_ERROR, get_tag(), "[Config] Fail to load config (engine id)");
-                       return -1;
-               }
-       }
-
-       /* Read voice */
-       if (EOF == fscanf(config_fp, "%s %s %d", buf_id, buf_param, &int_param)) {
-               fclose(config_fp);
-               SLOG(LOG_WARN, get_tag(), "[Config WARNING] Fail to read config (voice)");
-               return -1;
-       } else {
-               if (0 == strncmp(VOICE, buf_id, strlen(VOICE))) {
-                       if (NULL != g_language) {
-                               if ((0 != strcmp(g_language, buf_param)) || (g_vc_type != int_param)) {
-                                       free(g_language);
-                                       g_language = strdup(buf_param);
-                                       g_vc_type = int_param;
-
-                                       SLOG(LOG_DEBUG, get_tag(), "[Config] voice is changed : lang(%s) type(%d)", g_language, g_vc_type);
-
-                                       if (NULL != g_callback)
-                                               g_callback(TTS_CONFIG_TYPE_VOICE, g_language, g_vc_type);
-                               }
-                       } else {
-                               SLOG(LOG_ERROR, get_tag(), "[Config ERROR] Current voice is not available");
-                               g_language = strdup(buf_param);
-                               g_vc_type = int_param;
-
-                               if (NULL != g_callback)
-                                       g_callback(TTS_CONFIG_TYPE_VOICE, g_language, g_vc_type);
-                       }
-               } else {
-                       fclose(config_fp);
-                       SLOG(LOG_WARN, get_tag(), "[Config WARNING] Fail to load config (voice)");
-                       return -1;
-               }
-       }
-
-       /* Read speed */
-       if (EOF == fscanf(config_fp, "%s %d", buf_id, &int_param)) {
-               fclose(config_fp);
-               SLOG(LOG_WARN, get_tag(), "[Config WARNING] Fail to read config (speed)");
-               return -1;
-       } else {
-               if (0 == strncmp(SPEED, buf_id, strlen(SPEED))) {
-                       if (g_speed != int_param) {
-                               g_speed = int_param;
-
-                               SLOG(LOG_DEBUG, get_tag(), "[Config] speech rate is changed : %d", g_speed);
-
-                               if (NULL != g_callback)
-                                       g_callback(TTS_CONFIG_TYPE_SPEED, NULL, g_speed);
-                       }
-               } else {
-                       fclose(config_fp);
-                       SLOG(LOG_WARN, get_tag(), "[Config WARNING] Fail to load config (speed)");
-                       return -1;
-               }
-       }
-
-       fclose(config_fp);
-
-       return 0;
-}
-
-int __ttsd_config_save()
-{
-       if (0 != access(DEFAULT_CONFIG_FILE_NAME, R_OK|W_OK)) {
-               if (0 == ecore_file_mkpath(CONFIG_DIRECTORY)) {
-                       SLOG(LOG_WARN, get_tag(), "[Config WARNING] Fail to create directory (%s)", CONFIG_DIRECTORY);
-               } else {
-                       SLOG(LOG_DEBUG, get_tag(), "[Config] Create directory (%s)", CONFIG_DIRECTORY);
-               }
-       }
-
-       FILE* config_fp;
-       config_fp = fopen(DEFAULT_CONFIG_FILE_NAME, "w+");
-
-       if (NULL == config_fp) {
-               /* make file and file default */
-               SLOG(LOG_WARN, get_tag(), "[Config WARNING] Fail to open config (%s)", DEFAULT_CONFIG_FILE_NAME);
-               return -1;
-       }
-
-       SLOG(LOG_DEBUG, get_tag(), "[Config] Rewrite config file");
-
-       /* Write engine id */
-       fprintf(config_fp, "%s %s\n", ENGINE_ID, g_engine_id);
-
-       /* Write voice */
-       fprintf(config_fp, "%s %s %d\n", VOICE, g_language, g_vc_type);
-
-       /* Read speed */
-       fprintf(config_fp, "%s %d\n", SPEED, g_speed);
-
-       fclose(config_fp);
-
-       return 0;
-}
-
-int __ttsd_config_load()
-{
-       FILE* config_fp;
-       char buf_id[256] = {0};
-       char buf_param[256] = {0};
-       int int_param = 0;
-       bool is_default_open = false;
-
-       config_fp = fopen(DEFAULT_CONFIG_FILE_NAME, "r");
-
-       if (NULL == config_fp) {
-               SLOG(LOG_WARN, get_tag(), "[Config WARNING] Not open file(%s)", DEFAULT_CONFIG_FILE_NAME);
-
-               config_fp = fopen(CONFIG_DEFAULT, "r");
-               if (NULL == config_fp) {
-                       SLOG(LOG_ERROR, get_tag(), "[Config WARNING] Not open original config file(%s)", CONFIG_DEFAULT);
-                       return -1;
-               }
-
-               is_default_open = true;
-       }
-
-       /* Read engine id */
-       if (EOF == fscanf(config_fp, "%s %s", buf_id, buf_param)) {
-               fclose(config_fp);
-               SLOG(LOG_WARN, get_tag(), "[Config WARNING] Fail to read config (engine id)");
-               return -1;
-       } else {
-               if (0 == strncmp(ENGINE_ID, buf_id, strlen(ENGINE_ID))) {
-                       g_engine_id = strdup(buf_param);
-               } else {
-                       fclose(config_fp);
-                       SLOG(LOG_WARN, get_tag(), "[Config WARNING] Fail to load config (engine id)");
-                       return -1;
-               }
-       }
-
-       /* Read voice */
-       if (EOF == fscanf(config_fp, "%s %s %d", buf_id, buf_param, &int_param)) {
-               fclose(config_fp);
-               SLOG(LOG_WARN, get_tag(), "[Config WARNING] Fail to read config (voice)");
-               __ttsd_config_save();
-               return -1;
-       } else {
-               if (0 == strncmp(VOICE, buf_id, strlen(VOICE))) {
-                       g_language = strdup(buf_param);
-                       g_vc_type = int_param;
-               } else {
-                       fclose(config_fp);
-                       SLOG(LOG_WARN, get_tag(), "[Config WARNING] Fail to load config (voice)");
-                       return -1;
-               }
-       }
-
-       if (true == is_default_open) {
-               /* Change default language to display language */
-               char* value;
-               value = vconf_get_str(VCONFKEY_LANGSET);
-
-               if (NULL != value) {
-                       SLOG(LOG_DEBUG, get_tag(), "[Config] System language : %s", value);
-                       strncpy(g_language, value, strlen(g_language));
-                       SLOG(LOG_DEBUG, get_tag(), "[Config] Default language : %s", g_language);
-
-                       free(value);
-               } else {
-                       SLOG(LOG_ERROR, get_tag(), "[Config ERROR] Fail to get system language");
-               }
-       }
-
-       /* Read speed */
-       if (EOF == fscanf(config_fp, "%s %d", buf_id, &int_param)) {
-               fclose(config_fp);
-               SLOG(LOG_WARN, get_tag(), "[Config WARNING] Fail to read config (speed)");
-               return -1;
-       } else {
-               if (0 == strncmp(SPEED, buf_id, strlen(SPEED))) {
-                       g_speed = int_param;
-               } else {
-                       fclose(config_fp);
-                       SLOG(LOG_WARN, get_tag(), "[Config WARNING] Fail to load config (speed)");
-                       return -1;
-               }
-       }
-
-       fclose(config_fp);
-
-       SLOG(LOG_DEBUG, get_tag(), "[Config] Load config : engine(%s), voice(%s,%d), speed(%d)",
-               g_engine_id, g_language, g_vc_type, g_speed);
-
-       if (true == is_default_open) {
-               if(0 == __ttsd_config_save()) {
-                       SLOG(LOG_DEBUG, get_tag(), "[Config] Create config(%s)", DEFAULT_CONFIG_FILE_NAME);
-               }
-       }
-
-       return 0;
-}
-
-static Eina_Bool inotify_event_callback(void* data, Ecore_Fd_Handler *fd_handler)
-{
-       SLOG(LOG_DEBUG, get_tag(), "===== [Config] Inotify event call");
-
-       int length;
-       char buffer[sizeof(struct inotify_event)];
-       memset(buffer, 0, (sizeof(struct inotify_event)));
-
-       length = read(g_fd_noti, buffer, (sizeof(struct inotify_event)));
-       if (0 > length) {
-               SLOG(LOG_ERROR, get_tag(), "[Config] Empty Inotify event");
-               SLOG(LOG_DEBUG, get_tag(), "=====");
-               SLOG(LOG_DEBUG, get_tag(), " ");
-               return ECORE_CALLBACK_RENEW; 
-       }
-
-       struct inotify_event *event;
-       event = (struct inotify_event *)&buffer;
-
-       if (IN_CLOSE_WRITE == event->mask) {
-               __ttsd_config_compare();
-       } else {
-               SLOG(LOG_ERROR, get_tag(), "[Config] Undefined event");
-       }
-
-       SLOG(LOG_DEBUG, get_tag(), "=====");
-       SLOG(LOG_DEBUG, get_tag(), " ");
-
-       return ECORE_CALLBACK_PASS_ON;
-}
-
-int __config_file_open_connection()
-{
-       /* get file notification handler */
-       int fd;
-       int wd;
-
-       fd = inotify_init();
-       if (fd < 0) {
-               SLOG(LOG_ERROR, get_tag(), "[Config ERROR] Fail get inotify_fd");
-               return -1;
-       }
-       g_fd_noti = fd;
-
-       wd = inotify_add_watch(fd, DEFAULT_CONFIG_FILE_NAME, IN_CLOSE_WRITE);
-       g_wd_noti = wd;
-       g_fd_handler_noti = ecore_main_fd_handler_add(fd, ECORE_FD_READ, (Ecore_Fd_Cb)inotify_event_callback, NULL, NULL, NULL);                
-       if (NULL == g_fd_handler_noti) {
-               SLOG(LOG_ERROR, get_tag(), "[Config ERROR] Fail to get handler_noti");
-               return -1;
-       }
-
-       return 0;
-}
-
-int ttsd_config_initialize(ttsd_config_changed_cb callback)
-{
-       g_engine_id = NULL;
-       g_language = NULL;
-       g_vc_type = 1;
-       g_speed = 3;
-
-       g_callback = callback;
-
-       ecore_file_mkpath(CONFIG_DIRECTORY);
-
-       __ttsd_config_load();
-
-       if (0 != __config_file_open_connection()) {
-               return -1;
-       }
-
-       return 0;
-}
-
-int ttsd_config_finalize()
-{
-       if (NULL != g_language) {
-               free(g_language);
-       }
-
-       if (NULL != g_engine_id) {
-               free(g_engine_id);
-       }
-
-       /* del inotify variable */
-       ecore_main_fd_handler_del(g_fd_handler_noti);
-       inotify_rm_watch(g_fd_noti, g_wd_noti);
-       close(g_fd_noti);
-
-       return 0;
-}
-
-int ttsd_config_update_language()
-{
-       /* no work in notification mode */
-       return 0;
-}
-
-int ttsd_config_get_default_engine(char** engine_id)
-{
-       if (NULL == engine_id)
-               return -1;
-
-       if (NULL != g_engine_id) {
-               *engine_id = strdup(g_engine_id);
-       } else {
-               SLOG(LOG_ERROR, get_tag(), "[Config ERROR] Current engine id is NULL");
-               return -1;
-       }
-
-       return 0;
-}
-
-int ttsd_config_set_default_engine(const char* engine_id)
-{
-       /* Not available in notification mode */
-       return 0;
-}
-
-int ttsd_config_get_default_voice(char** language, int* type)
-{
-       if (NULL == language || NULL == type)
-               return -1;
-
-       if (NULL != g_language) {
-               *language = strdup(g_language);
-               *type = g_vc_type;
-       } else {
-               SLOG(LOG_ERROR, get_tag(), "[Config ERROR] Current language is NULL");
-               return -1;
-       }
-       
-       return 0;
-}
-
-int ttsd_config_set_default_voice(const char* language, int type)
-{
-       /* Not available in notification mode */
-       return 0;
-}
-
-int ttsd_config_get_default_speed(int* speed)
-{
-       if (NULL == speed)
-               return -1;
-
-       *speed = g_speed;
-
-       return 0;
-}
-
-int ttsd_config_set_default_speed(int speed)
-{
-       /* Not available in notification mode */
-       return 0;
-}
-
-int ttsd_config_save_error(int uid, int uttid, const char* lang, int vctype, const char* text, 
-                          const char* func, int line, const char* message)
-{
-       SLOG(LOG_ERROR, get_tag(), "=============== TTS ERROR LOG ====================");
-
-       SLOG(LOG_ERROR, get_tag(), "uid(%d) uttid(%d)", uid, uttid);
-
-       if (NULL != func)       SLOG(LOG_ERROR, get_tag(), "Function(%s) Line(%d)", func, line);
-       if (NULL != message)    SLOG(LOG_ERROR, get_tag(), "Message(%s)", message);
-       if (NULL != lang)       SLOG(LOG_ERROR, get_tag(), "Lang(%s), type(%d)", lang, vctype);
-       if (NULL != text)       SLOG(LOG_ERROR, get_tag(), "Text(%s)", text);
-
-       SLOG(LOG_ERROR, get_tag(), "==================================================");
-
-       return 0;
-}
diff --git a/server/ttsd_config_sr.c b/server/ttsd_config_sr.c
deleted file mode 100644 (file)
index b5230b8..0000000
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
-*  Copyright (c) 2012, 2013 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 <Ecore_File.h>
-#include <vconf-internal-keys.h>
-#include <vconf.h>
-#include <runtime_info.h>
-
-/* For multi-user support */
-#include <tzplatform_config.h>
-
-#include "ttsd_main.h"
-#include "ttsd_config.h"
-#include "ttsd_engine_agent.h"
-#include "ttsd_data.h"
-
-#define SR_ERROR_FILE_NAME             tzplatform_mkpath(TZ_USER_HOME, ".voice/ttsd_sr.err")
-
-#define ENGINE_ID      "ENGINE_ID"
-
-static char*   g_engine_id;
-static char*   g_language;
-static int     g_vc_type;
-static int     g_speed;
-
-static ttsd_config_changed_cb g_callback;
-
-void __sr_system_language_changed_cb(runtime_info_key_e key, void *user_data)
-{
-       if (RUNTIME_INFO_KEY_LANGUAGE == key) {
-               if (TTSD_MODE_SCREEN_READER == ttsd_get_mode()) {
-                       int ret = -1;
-                       char *value;
-
-                       ret = runtime_info_get_value_string(RUNTIME_INFO_KEY_LANGUAGE, &value);
-                       if (0 != ret) {
-                               SLOG(LOG_ERROR, get_tag(), "[Config ERROR] Fail to get system language : %d", ret);
-                               return;
-                       } else {
-                               SLOG(LOG_DEBUG, get_tag(), "[Config] System language changed : %s", value);
-                               if (NULL != g_callback)
-                                       g_callback(TTS_CONFIG_TYPE_VOICE, value, g_vc_type);
-               
-                               if (NULL != value)
-                                       free(value);
-                       }
-               }
-       }
-
-       return;
-}
-
-void __sr_speech_rate_changed_cb(keynode_t *key, void *data)
-{
-       char buf[255];
-       sprintf(buf, "%s", vconf_keynode_get_name(key));
-
-       if (!strcmp(buf, VCONFKEY_SETAPPL_ACCESSIBILITY_SPEECH_RATE)) {
-               int temp_speech_rate = vconf_keynode_get_int(key);
-
-               temp_speech_rate ++;
-               if (g_speed != temp_speech_rate) {
-                       SLOG(LOG_DEBUG, get_tag(), "[Config] Speech rate changed : current(%d), previous(%d)", 
-                               temp_speech_rate, g_speed);
-                       g_speed = temp_speech_rate;
-
-                       if (NULL != g_callback)
-                               g_callback(TTS_CONFIG_TYPE_SPEED, NULL, g_speed);
-               }
-       }
-}
-
-int ttsd_config_initialize(ttsd_config_changed_cb callback)
-{
-       int ret = -1;
-       char* value = NULL;
-       FILE* config_fp;
-       char buf_id[256] = {0};
-       char buf_param[256] = {0};
-
-       g_engine_id = NULL;
-       g_language = NULL;
-       g_vc_type = 2;
-       g_speed = 3;
-
-       g_callback = callback;
-
-       ecore_file_mkpath(CONFIG_DIRECTORY);
-
-       /* Get default engine id */
-       config_fp = fopen(CONFIG_DEFAULT, "r");
-       if (NULL == config_fp) {
-               SLOG(LOG_ERROR, get_tag(), "[Config ERROR] Not open original config file(%s)", CONFIG_DEFAULT);
-               return -1;
-       }
-
-       /* Read engine id */
-       if (EOF == fscanf(config_fp, "%s %s", buf_id, buf_param)) {
-               fclose(config_fp);
-               SLOG(LOG_ERROR, get_tag(), "[Config ERROR] Fail to read config (engine id)");
-               return -1;
-       }
-
-       if (0 == strncmp(ENGINE_ID, buf_id, strlen(ENGINE_ID))) {
-               g_engine_id = strdup(buf_param);
-               SLOG(LOG_DEBUG, get_tag(), "[Config] Current engine id : %s", g_engine_id);
-
-               fclose(config_fp);
-       } else {
-               fclose(config_fp);
-               SLOG(LOG_WARN, get_tag(), "[Config WARNING] Fail to load config (engine id)");
-               return -1;
-       }
-
-       /* Get display language */
-       ret = runtime_info_get_value_string(RUNTIME_INFO_KEY_LANGUAGE, &value);
-       if (0 != ret || NULL == value) {
-               SLOG(LOG_ERROR, get_tag(), "[Config ERROR] Fail to get system language : %d", ret);
-               return -1;
-       } else {
-               SLOG(LOG_DEBUG, get_tag(), "[Config] Current system language : %s", value);
-
-               g_language = strdup(value);
-
-               if (NULL != value)
-                       free(value);
-       }
-
-       /* Register system language changed callback */
-       ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_LANGUAGE, __sr_system_language_changed_cb, NULL);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Config ERROR] Fail to register callback : %d", ret);
-               return TTSD_ERROR_OPERATION_FAILED;
-       }
-
-       /* Get speech rate */
-       ret = vconf_get_int(VCONFKEY_SETAPPL_ACCESSIBILITY_SPEECH_RATE, &g_speed);
-       
-       /**
-       * vconf key value scope
-       * 0 : Very slow 
-       * 1 : Slow 
-       * 2 : Normal 
-       * 3 : Fast 
-       * 4 : Very fast 
-       */
-       /* vconf key value is between 0 ~ 4 but tts speech rate value is between 1 ~ 5 */
-       g_speed ++;
-       SLOG(LOG_DEBUG, get_tag(), "[Config] Current speech rate : %d", g_speed);
-
-       /* register callback function */
-       vconf_notify_key_changed (VCONFKEY_SETAPPL_ACCESSIBILITY_SPEECH_RATE, __sr_speech_rate_changed_cb, NULL);
-
-       return 0;
-}
-
-int ttsd_config_finalize()
-{
-       vconf_ignore_key_changed (VCONFKEY_SETAPPL_ACCESSIBILITY_SPEECH_RATE, __sr_speech_rate_changed_cb);
-
-       if (NULL != g_language) {
-               free(g_language);
-       }
-
-       if (NULL != g_engine_id) {
-               free(g_engine_id);
-       }
-       
-       return 0;
-}
-
-int ttsd_config_update_language()
-{
-       if (TTSD_MODE_SCREEN_READER == ttsd_get_mode()) {
-               int ret = -1;
-               char *value;
-
-               ret = runtime_info_get_value_string(RUNTIME_INFO_KEY_LANGUAGE, &value);
-               if (0 != ret) {
-                       SLOG(LOG_ERROR, get_tag(), "[Config ERROR] Fail to get system language : %d", ret);
-                       return -1;
-               } else {
-                       if (NULL == value) {
-                               SLOG(LOG_ERROR, get_tag(), "[Config] Fail to get system language");
-                               return -1;
-                       } else {
-                               SLOG(LOG_DEBUG, get_tag(), "[Config] System language : %s", value);
-
-                               if (0 != strcmp(value, g_language)) {
-                                       if (NULL != g_callback)
-                                               g_callback(TTS_CONFIG_TYPE_VOICE, value, g_vc_type);
-                               }
-
-                               free(value);
-                       }
-               }
-       }
-
-       return 0;
-}
-
-int ttsd_config_get_default_engine(char** engine_id)
-{
-       if (NULL == engine_id)
-               return -1;
-
-       if (NULL != g_engine_id) {
-               *engine_id = strdup(g_engine_id);
-       } else {
-               SLOG(LOG_ERROR, get_tag(), "[Config ERROR] Current engine id is NULL");
-               return -1;
-       }
-       return 0;
-}
-
-int ttsd_config_set_default_engine(const char* engine_id)
-{
-       /* Not available in screen mode */
-       return 0;
-}
-
-int ttsd_config_get_default_voice(char** language, int* type)
-{
-       if (NULL == language || NULL == type)
-               return -1;
-
-       if (NULL != g_language) {
-               *language = strdup(g_language);
-               *type = g_vc_type;
-       } else {
-               SLOG(LOG_ERROR, get_tag(), "[Config ERROR] Current language is NULL");
-               return -1;
-       }
-       return 0;
-}
-
-int ttsd_config_set_default_voice(const char* language, int type)
-{
-       /* Not available in screen mode */
-       return 0;
-}
-
-int ttsd_config_get_default_speed(int* speed)
-{
-       if (NULL == speed)
-               return -1;
-
-       *speed = g_speed;
-
-       return 0;
-}
-
-int ttsd_config_set_default_speed(int speed)
-{
-       /* Not available in screen mode */
-       return 0;
-}
-
-int ttsd_config_save_error(int uid, int uttid, const char* lang, int vctype, const char* text, 
-                          const char* func, int line, const char* message)
-{
-       SLOG(LOG_ERROR, get_tag(), "=============== TTS ERROR LOG ====================");
-
-       SLOG(LOG_ERROR, get_tag(), "uid(%d) uttid(%d)", uid, uttid);
-
-       if (NULL != func)       SLOG(LOG_ERROR, get_tag(), "Function(%s) Line(%d)", func, line);
-       if (NULL != message)    SLOG(LOG_ERROR, get_tag(), "Message(%s)", message);
-       if (NULL != lang)       SLOG(LOG_ERROR, get_tag(), "Lang(%s), type(%d)", lang, vctype);
-       if (NULL != text)       SLOG(LOG_ERROR, get_tag(), "Text(%s)", text);
-
-       SLOG(LOG_ERROR, get_tag(), "==================================================");
-
-       return 0;
-}
\ No newline at end of file
index 14afe7e..e295294 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*  Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd All Rights Reserved 
+*  Copyright (c) 2011-2014 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
@@ -19,24 +19,25 @@ using namespace std;
 
 typedef struct 
 {
+       char*   lang;
+       int     vctype;
+}used_voice_s;
+
+typedef struct 
+{
        int             pid;
        int             uid;
        int             utt_id_stopped;
        app_state_e     state;
-       
-       std::vector<speak_data_s> m_speak_data; 
+
+       std::vector<speak_data_s> m_speak_data;
        std::vector<sound_data_s> m_wav_data;
-}app_data_s;
 
-typedef struct {
-       int pid;
-} setting_app_data_s;
+       std::vector<used_voice_s> m_used_voice; 
+}app_data_s;
 
 static vector<app_data_s> g_app_list;
 
-static vector<setting_app_data_s> g_setting_list;
-
-static bool g_mutex_state = false;
 
 /*
 * functions for debug
@@ -49,29 +50,15 @@ int __data_show_list()
        SLOG(LOG_DEBUG, get_tag(), "----- client list -----");
 
        for (int i=0; i<vsize; i++) {
-               SLOG(LOG_DEBUG, get_tag(), "[%dth] pid(%d), uid(%d), state(%d) \n", i, g_app_list[i].pid, g_app_list[i].uid, g_app_list[i].state );
+               SECURE_SLOG(LOG_DEBUG, get_tag(), "[%dth] pid(%d), uid(%d), state(%d)", i, g_app_list[i].pid, g_app_list[i].uid, g_app_list[i].state);
        }
 
        if (0 == vsize) {
-               SLOG(LOG_DEBUG, get_tag(), "No Client \n");
+               SLOG(LOG_DEBUG, get_tag(), "No Client");
        }
 
        SLOG(LOG_DEBUG, get_tag(), "-----------------------");
 
-       SLOG(LOG_DEBUG, get_tag(), "----- setting client list -----");
-
-       vsize = g_setting_list.size();
-
-       for (int i=0; i<vsize; i++) {
-               SLOG(LOG_DEBUG, get_tag(), "[%dth] pid(%d)", i, g_setting_list[i].pid );
-       }
-
-       if (0 == vsize) {
-               SLOG(LOG_DEBUG, get_tag(), "No Setting Client");
-       }
-
-       SLOG(LOG_DEBUG, get_tag(), "--------------------------------");
-
        return TTSD_ERROR_NONE;
 }
 
@@ -81,12 +68,12 @@ int __data_show_sound_list(int index)
        
        unsigned int i;
        for (i=0 ; i < g_app_list[index].m_wav_data.size() ; i++) {
-               SLOG(LOG_DEBUG, get_tag(), "[%dth] data size(%ld), uttid(%d), type(%d) \n", 
-                       i+1, g_app_list[index].m_wav_data[i].data_size, g_app_list[index].m_wav_data[i].utt_id, g_app_list[index].m_wav_data[i].audio_type );
+               SECURE_SLOG(LOG_DEBUG, get_tag(), "[%dth] data size(%ld), uttid(%d), type(%d)", 
+                       i+1, g_app_list[index].m_wav_data[i].data_size, g_app_list[index].m_wav_data[i].utt_id, g_app_list[index].m_wav_data[i].audio_type);
        }
 
        if (i == 0) {
-               SLOG(LOG_DEBUG, get_tag(), "No Sound Data \n");
+               SLOG(LOG_DEBUG, get_tag(), "No Sound Data");
        }
 
        SLOG(LOG_DEBUG, get_tag(), "----------------------");
@@ -99,19 +86,36 @@ int __data_show_text_list(int index)
 
        unsigned int i;
        for (i=0 ; i< g_app_list[index].m_speak_data.size() ; i++) {
-               SLOG(LOG_DEBUG, get_tag(), "[%dth] lang(%s), vctype(%d), speed(%d), uttid(%d), text(%s) \n", 
+               SECURE_SLOG(LOG_DEBUG, get_tag(), "[%dth] lang(%s), vctype(%d), speed(%d), uttid(%d), text(%s)", 
                                i+1, g_app_list[index].m_speak_data[i].lang, g_app_list[index].m_speak_data[i].vctype, g_app_list[index].m_speak_data[i].speed,
-                               g_app_list[index].m_speak_data[i].utt_id, g_app_list[index].m_speak_data[i].text );     
+                               g_app_list[index].m_speak_data[i].utt_id, g_app_list[index].m_speak_data[i].text);      
        }
 
        if (0 == i) {
-               SLOG(LOG_DEBUG, get_tag(), "No Text Data \n");
+               SLOG(LOG_DEBUG, get_tag(), "No Text Data");
        }
 
        SLOG(LOG_DEBUG, get_tag(), "---------------------");
        return TTSD_ERROR_NONE;
 }
 
+int __data_show_used_voice_list(int index)
+{
+       SLOG(LOG_DEBUG, get_tag(), "----- Voice list -----");
+
+       unsigned int i;
+       for (i=0 ; i< g_app_list[index].m_speak_data.size() ; i++) {
+               SECURE_SLOG(LOG_DEBUG, get_tag(), "[%dth] lang(%s), vctype(%d)", 
+                               i+1, g_app_list[index].m_used_voice[i].lang, g_app_list[index].m_used_voice[i].vctype); 
+       }
+
+       if (0 == i) {
+               SLOG(LOG_DEBUG, get_tag(), "No Voice Data");
+       }
+
+       SLOG(LOG_DEBUG, get_tag(), "---------------------");
+       return TTSD_ERROR_NONE;
+}
 
 /*
 * ttsd data functions
@@ -120,7 +124,7 @@ int __data_show_text_list(int index)
 int ttsd_data_new_client(int pid, int uid)
 {
        if( -1 != ttsd_data_is_client(uid) ) {
-               SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] ttsd_data_new_client() : uid is not valid (%d)\n", uid);       
+               SECURE_SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] uid is not valid (%d)", uid);   
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
@@ -145,12 +149,12 @@ int ttsd_data_delete_client(int uid)
        index = ttsd_data_is_client(uid);
        
        if (index < 0) {
-               SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] ttsd_data_delete_client() : uid is not valid (%d)\n", uid);    
+               SECURE_SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] uid is not valid (%d)", uid);   
                return -1;
        }
 
        if (0 != ttsd_data_clear_data(uid)) {
-               SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] fail ttsd_data_clear_data()\n");
+               SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] Fail to clear data");
                return -1;
        }
 
@@ -177,7 +181,7 @@ int ttsd_data_is_client(int uid)
 
 int ttsd_data_get_client_count()
 {
-       return g_app_list.size() + g_setting_list.size();
+       return g_app_list.size();
 }
 
 int ttsd_data_get_pid(int uid)
@@ -187,7 +191,7 @@ int ttsd_data_get_pid(int uid)
        index = ttsd_data_is_client(uid);
        
        if (index < 0)  {
-               SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] ttsd_data_delete_client() : uid is not valid (%d)\n", uid);    
+               SECURE_SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] uid is not valid (%d)", uid);   
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
@@ -200,7 +204,7 @@ int ttsd_data_get_speak_data_size(int uid)
        index = ttsd_data_is_client(uid);
        
        if (index < 0) {
-               SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] ttsd_data_get_speak_data_size() : uid is not valid (%d)\n", uid);      
+               SECURE_SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] uid is not valid (%d)", uid);
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
@@ -208,13 +212,80 @@ int ttsd_data_get_speak_data_size(int uid)
        return size;
 }
 
+int ttsd_data_set_used_voice(int uid, const char* lang, int type)
+{
+       int index = 0;
+       index = ttsd_data_is_client(uid);
+
+       if (index < 0) {
+               SECURE_SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] uid is not valid (%d)", uid);   
+               return TTSD_ERROR_INVALID_PARAMETER;
+       }
+
+       /* Find voice */
+       int vsize = g_app_list[index].m_used_voice.size();
+       int i = 0;
+
+       for (i = 0;i < vsize;i++) {
+               if (0 == strcmp(lang, g_app_list[index].m_used_voice[i].lang) && 
+                       type == g_app_list[index].m_used_voice[i].vctype) {
+                       SLOG(LOG_DEBUG, get_tag(), "[DATA] The voice is already registered (%s)(%d)", lang, type);
+                       return 0;
+               }
+       }
+
+       /* Add voice */
+       used_voice_s used_voice;
+       used_voice.lang = strdup(lang);
+       used_voice.vctype = type;
+
+       g_app_list[index].m_used_voice.insert(g_app_list[index].m_used_voice.end(), used_voice);
+
+#ifdef DATA_DEBUG
+       __data_show_used_voice_list(index);
+#endif
+
+       return -1;      /* Need to load voice*/
+}
+
+int ttsd_data_reset_used_voice(int uid, ttsd_used_voice_cb callback)
+{
+       int index = 0;
+       index = ttsd_data_is_client(uid);
+
+       if (index < 0) {
+               SECURE_SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] uid is not valid (%d)", uid);
+               return TTSD_ERROR_INVALID_PARAMETER;
+       }
+
+       /* Find voice */
+       int vsize = g_app_list[index].m_used_voice.size();
+       int i = 0;
+
+       for (i = 0;i < vsize;i++) {
+               if (NULL != callback) {
+                       callback(g_app_list[index].m_used_voice[i].lang, g_app_list[index].m_used_voice[i].vctype);
+               } else {
+                       SECURE_SLOG(LOG_WARN, get_tag(), "[DATA WARNING] Used voice callback is NULL");
+               }
+
+               if (NULL != g_app_list[index].m_used_voice[i].lang) {
+                       free(g_app_list[index].m_used_voice[i].lang);
+               }
+       } 
+
+       g_app_list[index].m_used_voice.clear();
+
+       return TTSD_ERROR_NONE;
+}
+
 int ttsd_data_add_speak_data(int uid, speak_data_s data)
 {
        int index = 0;
        index = ttsd_data_is_client(uid);
 
        if (index < 0) {
-               SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] ttsd_data_add_speak_data() : uid is not valid (%d)\n", uid);   
+               SECURE_SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] uid is not valid (%d)", uid);   
                return TTSD_ERROR_INVALID_PARAMETER;
        }
        
@@ -235,12 +306,14 @@ int ttsd_data_get_speak_data(int uid, speak_data_s* data)
        index = ttsd_data_is_client(uid);
 
        if (index < 0) {
-               SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] ttsd_data_get_speak_data() : uid is not valid(%d)\n", uid);    
+               SECURE_SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] uid is not valid(%d)", uid);    
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
        if (0 == g_app_list[index].m_speak_data.size()) {
-               SLOG(LOG_WARN, get_tag(), "[DATA WARNING] There is no speak data\n"); 
+#ifdef DATA_DEBUG
+               SLOG(LOG_WARN, get_tag(), "[DATA WARNING] There is no speak data"); 
+#endif 
                return -1;
        }
 
@@ -265,7 +338,7 @@ int ttsd_data_add_sound_data(int uid, sound_data_s data)
        index = ttsd_data_is_client(uid);
 
        if(index < 0) {
-               SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] ttsd_data_add_sound_data() : uid is not valid (%d)\n", uid);   
+               SECURE_SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] uid is not valid (%d)", uid);   
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
@@ -283,12 +356,14 @@ int ttsd_data_get_sound_data(int uid, sound_data_s* data)
        index = ttsd_data_is_client(uid);
 
        if (index < 0)  {
-               SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] ttsd_data_get_sound_data() : uid is not valid (%d)\n", uid);   
+               SECURE_SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] uid is not valid (%d)", uid);   
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
        if (0 == g_app_list[index].m_wav_data.size()) {
-               SLOG(LOG_WARN, get_tag(), "[DATA WARNING] There is no wav data\n"); 
+#ifdef DATA_DEBUG
+               SLOG(LOG_DEBUG, get_tag(), "[DATA] There is no wav data");
+#endif
                return -1;
        }
 
@@ -314,7 +389,7 @@ int ttsd_data_get_sound_data_size(int uid)
        index = ttsd_data_is_client(uid);
 
        if (index < 0)  {
-               SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] ttsd_data_get_sound_data_size() : uid is not valid (%d)\n", uid);      
+               SECURE_SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] uid is not valid (%d)", uid);   
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
@@ -327,7 +402,7 @@ int ttsd_data_clear_data(int uid)
 
        index = ttsd_data_is_client(uid);
        if (index < 0) {
-               SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] ttsd_data_clear_data() : uid is not valid (%d)\n", uid);       
+               SECURE_SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] uid is not valid (%d)", uid);   
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
@@ -355,7 +430,11 @@ int ttsd_data_clear_data(int uid)
                        break;
                }
 
-               if (NULL != temp.data)  free(temp.data);
+               if (0 < temp.data_size) {
+                       if (NULL != temp.data)  free(temp.data);
+               } else {
+                       SLOG(LOG_ERROR, get_tag(), "Sound data is NULL");
+               }
        }
 
        g_app_list[index].m_speak_data.clear();
@@ -370,7 +449,7 @@ int ttsd_data_get_client_state(int uid, app_state_e* state)
 
        index = ttsd_data_is_client(uid);
        if (index < 0)  {
-               SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] ttsd_data_get_client_state() : uid is not valid (%d)\n", uid); 
+               SECURE_SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] uid is not valid (%d)", uid);   
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
@@ -385,24 +464,16 @@ int ttsd_data_set_client_state(int uid, app_state_e state)
 
        index = ttsd_data_is_client(uid);
        if (index < 0)  {
-               SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] ttsd_data_set_client_state() : uid is not valid (%d)\n", uid); 
+               SECURE_SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] uid is not valid (%d)", uid);   
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
-       if (true == g_mutex_state) {
-               while(true == g_mutex_state)    {
-               }
-       }
-       
-       g_mutex_state = true;
-
        /* The client of playing state of all clients is only one. need to check state. */
        if (APP_STATE_PLAYING == state) {
                int vsize = g_app_list.size();
                for (int i=0 ; i<vsize ; i++) {
                        if(g_app_list[i].state == APP_STATE_PLAYING) {
-                               SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] ttsd_data_set_client_state() : a playing client has already existed. \n");     
-                               g_mutex_state = false;
+                               SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] A playing client has already existed.");       
                                return -1;
                        }
                }
@@ -410,8 +481,6 @@ int ttsd_data_set_client_state(int uid, app_state_e state)
 
        g_app_list[index].state = state;
 
-       g_mutex_state = false;
-
        return TTSD_ERROR_NONE;
 }
 
@@ -421,12 +490,11 @@ int ttsd_data_get_current_playing()
 
        for (int i=0; i<vsize; i++) {
                if (APP_STATE_PLAYING == g_app_list[i].state) {
+                       SLOG(LOG_DEBUG, get_tag(), "[DATA] uid(%d) is playing", g_app_list[i].uid);
                        return g_app_list[i].uid;
                }
        }
 
-       SLOG(LOG_DEBUG, get_tag(), "[DATA] NO CURRENT PLAYING !!");     
-
        return -1;
 }
 
@@ -437,13 +505,35 @@ int ttsd_data_foreach_clients(ttsd_data_get_client_cb callback, void* user_data)
                return -1;
        }
 
+#ifdef DATA_DEBUG
+       __data_show_list();
+#endif 
+       
+       /* Copy app info */
+       vector<app_data_s> temp_app_list;
        int vsize = g_app_list.size();
 
-       for (int i=0; i<vsize; i++) {
-               if (false == callback(g_app_list[i].pid, g_app_list[i].uid, g_app_list[i].state, user_data)) {
+       int i = 0;
+       for (i = 0;i < vsize;i++) {
+               app_data_s app;
+               app.pid = g_app_list[i].pid;
+               app.uid = g_app_list[i].uid;
+               app.utt_id_stopped = 0;
+               app.state = g_app_list[i].state;
+
+               temp_app_list.insert(temp_app_list.end(), app);
+       }
+
+       for (i = 0;i < vsize;i++) {
+               SECURE_SLOG(LOG_DEBUG, get_tag(), "[%dth] pid(%d), uid(%d), state(%d)", i, temp_app_list[i].pid, temp_app_list[i].uid, temp_app_list[i].state);
+               if (false == callback(temp_app_list[i].pid, temp_app_list[i].uid, temp_app_list[i].state, user_data)) {
                        break;
                }
        }
+
+       for (i = 0;i < vsize;i++) {
+               temp_app_list.erase(temp_app_list.begin());
+       }
        
        return 0;
 }
@@ -454,7 +544,7 @@ bool ttsd_data_is_uttid_valid(int uid, int uttid)
 
        index = ttsd_data_is_client(uid);
        if (index < 0)  {
-               SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] ttsd_data_set_client_state() : uid is not valid (%d)\n", uid); 
+               SECURE_SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] uid is not valid (%d)", uid);   
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
@@ -477,58 +567,18 @@ int ttsd_data_is_current_playing()
        return -1;
 }
 
-/*
-* setting data
-*/
-
-int ttsd_setting_data_add(int pid)
-{
-       if (-1 != ttsd_setting_data_is_setting(pid)) {
-               SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] pid(%d) is not valid", pid);   
-               return TTSD_ERROR_INVALID_PARAMETER;
-       }
-
-       setting_app_data_s setting_app;
-       setting_app.pid = pid;
-       
-       g_setting_list.insert(g_setting_list.end(), setting_app);
-
-#ifdef DATA_DEBUG
-       __data_show_list();
-#endif 
-       return TTSD_ERROR_NONE;
-
-}
-
-int ttsd_setting_data_delete(int pid)
+int ttsd_data_get_same_pid_client_count(int pid)
 {
-       int index = 0;
-
-       index = ttsd_setting_data_is_setting(pid);
-
-       if (index < 0) {
-               SLOG(LOG_ERROR, get_tag(), "[DATA ERROR] uid is not valid (%d)", pid);  
-               return -1;
-       }
-
-       g_setting_list.erase(g_setting_list.begin()+index);
-
-#ifdef DATA_DEBUG
-       __data_show_list();
-#endif 
-       return TTSD_ERROR_NONE;
-}
+       int vsize = g_app_list.size();
+       int number = 0;
 
-int ttsd_setting_data_is_setting(int pid)
-{
-       int vsize = g_setting_list.size();
-       for (int i=0; i<vsize; i++) {
-               if(g_setting_list[i].pid == pid) {
-                       return i;               
+       for (int i = 0;i < vsize;i++) {
+               if(g_app_list[i].pid == pid) {
+                       number++;               
                }
        }
-       
-       return -1;
+
+       return number;
 }
 
 int ttsd_data_save_error_log(int uid, FILE* fp)
@@ -540,7 +590,7 @@ int ttsd_data_save_error_log(int uid, FILE* fp)
        if (0 > pid) {
                SLOG(LOG_ERROR, get_tag(), "[ERROR] Fail to get pid");
        } else {
-               fprintf(fp, "pid - %d\n", pid);
+               fprintf(fp, "pid - %d", pid);
        }
        /* app state */
        app_state_e state;
@@ -548,7 +598,7 @@ int ttsd_data_save_error_log(int uid, FILE* fp)
        if (0 != ret) {
                SLOG(LOG_ERROR, get_tag(), "[ERROR] Fail to get app state");
        } else {
-               fprintf(fp, "app state - %d\n", state);
+               fprintf(fp, "app state - %d", state);
        }
 
        int index = 0;
@@ -557,19 +607,19 @@ int ttsd_data_save_error_log(int uid, FILE* fp)
        index = ttsd_data_is_client(uid);
 
        /* get sound data */
-       fprintf(fp, "----- Sound list -----\n");
+       fprintf(fp, "----- Sound list -----");
        
        for (i=0 ; i < g_app_list[index].m_wav_data.size() ; i++) {
-               fprintf(fp, "[%dth] data size(%d), uttid(%d), type(%d) \n", 
+               fprintf(fp, "[%dth] data size(%d), uttid(%d), type(%d)", 
                        i+1, g_app_list[index].m_wav_data[i].data_size, g_app_list[index].m_wav_data[i].utt_id, g_app_list[index].m_wav_data[i].audio_type );
        }
-       fprintf(fp, "----------------------\n");
+       fprintf(fp, "----------------------");
        
        /* get speck data */
-       fprintf(fp, "----- Text list -----\n");
+       fprintf(fp, "----- Text list -----");
 
        for (i=0 ; i< g_app_list[index].m_speak_data.size() ; i++) {
-               fprintf(fp, "[%dth] lang(%s), vctype(%d), speed(%d), uttid(%d), text(%s) \n", 
+               fprintf(fp, "[%dth] lang(%s), vctype(%d), speed(%d), uttid(%d), text(%s)", 
                                i+1, g_app_list[index].m_speak_data[i].lang, g_app_list[index].m_speak_data[i].vctype, g_app_list[index].m_speak_data[i].speed,
                                g_app_list[index].m_speak_data[i].utt_id, g_app_list[index].m_speak_data[i].text );     
        }
@@ -577,54 +627,3 @@ int ttsd_data_save_error_log(int uid, FILE* fp)
        
        return 0;
 }
-
-int ttsd_data_get_same_pid_client_count(int pid)
-{
-       int vsize = g_app_list.size();
-       int number = 0;
-
-       for (int i=0; i<vsize; i++) {
-               if(g_app_list[i].pid == pid) {
-                       number++;               
-               }
-       }
-
-       return number;
-}
-
-typedef struct 
-{
-       bool is_set;
-       int uid;
-       int uttid;
-       int error_code;
-}error_data_s;
-
-static error_data_s g_error;
-
-int ttsd_data_set_error_data(int uid, int uttid, int error_code)
-{
-       g_error.uid = uid;
-       g_error.uttid = uttid;
-       g_error.error_code = error_code;
-       g_error.is_set = true;
-       return 0;
-}
-
-int ttsd_data_get_error_data(int* uid, int* uttid, int* error_code)
-{
-       if (false == g_error.is_set) {
-               return -1;
-       }
-
-       if (NULL == uid || NULL == uttid || NULL == error_code) {
-               return -1;
-       }
-
-       *uid = g_error.uid;
-       *uttid = g_error.uttid;
-       *error_code = g_error.error_code;
-
-       g_error.is_set = false;
-       return 0;
-}
\ No newline at end of file
index 363dd2c..1c94ebf 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*  Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd All Rights Reserved 
+*  Copyright (c) 2011-2014 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
@@ -30,11 +30,11 @@ typedef enum {
 
 typedef struct 
 {
-       int                     utt_id; 
-       char*                   text;
-       char*                   lang;
-       ttsp_voice_type_e       vctype;
-       ttsp_speed_e            speed;
+       int     utt_id; 
+       char*   text;
+       char*   lang;
+       int     vctype;
+       int     speed;
 }speak_data_s;
 
 typedef struct 
@@ -49,6 +49,8 @@ typedef struct
        int                     channels;
 }sound_data_s;
 
+typedef void (* ttsd_used_voice_cb)(const char* lang, int type);
+
 int ttsd_data_new_client(int pid, int uid);
 
 int ttsd_data_delete_client(int uid);
@@ -59,12 +61,14 @@ int ttsd_data_get_client_count();
 
 int ttsd_data_get_pid(int uid);
 
+/* speak data */
 int ttsd_data_add_speak_data(int uid, speak_data_s data);
 
 int ttsd_data_get_speak_data(int uid, speak_data_s* data);
 
 int ttsd_data_get_speak_data_size(int uid);
 
+/* sound data */
 int ttsd_data_add_sound_data(int uid, sound_data_s data);
 
 int ttsd_data_get_sound_data(int uid, sound_data_s* data);
@@ -73,10 +77,16 @@ int ttsd_data_get_sound_data_size(int uid);
 
 int ttsd_data_clear_data(int uid);
 
+
+int ttsd_data_set_used_voice(int uid, const char* lang, int type);
+
+int ttsd_data_reset_used_voice(int uid, ttsd_used_voice_cb callback);
+
 int ttsd_data_get_client_state(int pid, app_state_e* state);
 
 int ttsd_data_set_client_state(int pid, app_state_e state);
 
+
 int ttsd_data_get_current_playing();
 
 typedef bool(*ttsd_data_get_client_cb)(int pid, int uid, app_state_e state, void* user_data);
@@ -89,20 +99,9 @@ int ttsd_data_is_current_playing();
 
 int ttsd_data_get_same_pid_client_count(int pid);
 
-
-int ttsd_setting_data_add(int pid);
-
-int ttsd_setting_data_delete(int pid);
-
-int ttsd_setting_data_is_setting(int pid);
-
-
-/* for error log */
+/* For error handing */
 int ttsd_data_save_error_log(int uid, FILE* fp);
 
-int ttsd_data_set_error_data(int uid, int uttid, int error_code);
-
-int ttsd_data_get_error_data(int* uid, int* uttid, int* error_code);
 
 #ifdef __cplusplus
 }
index 4866ab7..42df611 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*  Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd All Rights Reserved 
+*  Copyright (c) 2011-2014 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
 *  limitations under the License.
 */
 
-
 #include <dbus/dbus.h>
+#include <dirent.h>
+#include <dlfcn.h>
 #include <Ecore.h>
 
+#include "tts_config_mgr.h"
 #include "ttsd_main.h"
 #include "ttsd_dbus_server.h"
 #include "ttsd_dbus.h"
@@ -29,6 +31,27 @@ static char *g_service_name;
 static char *g_service_object;
 static char *g_service_interface;
 
+const char* __ttsd_get_error_code(ttsd_error_e err)
+{
+       switch(err) {
+       case TTSD_ERROR_NONE:                   return "TTS_ERROR_NONE";
+       case TTSD_ERROR_OUT_OF_MEMORY:          return "TTS_ERROR_OUT_OF_MEMORY";
+       case TTSD_ERROR_IO_ERROR:               return "TTS_ERROR_IO_ERROR";
+       case TTSD_ERROR_INVALID_PARAMETER:      return "TTS_ERROR_INVALID_PARAMETER";
+       case TTSD_ERROR_OUT_OF_NETWORK:         return "TTS_ERROR_OUT_OF_NETWORK";
+       case TTSD_ERROR_INVALID_STATE:          return "TTS_ERROR_INVALID_STATE";
+       case TTSD_ERROR_INVALID_VOICE:          return "TTS_ERROR_INVALID_VOICE";
+       case TTSD_ERROR_ENGINE_NOT_FOUND:       return "TTS_ERROR_ENGINE_NOT_FOUND";
+       case TTSD_ERROR_TIMED_OUT:              return "TTS_ERROR_TIMED_OUT";
+       case TTSD_ERROR_OPERATION_FAILED:       return "TTS_ERROR_OPERATION_FAILED";
+       case TTSD_ERROR_AUDIO_POLICY_BLOCKED:   return "TTS_ERROR_AUDIO_POLICY_BLOCKED";
+       default:
+               return "Invalid error code";
+       }
+
+       return NULL;
+}
+
 int ttsdc_send_hello(int pid, int uid)
 {
        if (NULL == g_conn) { 
@@ -53,10 +76,10 @@ int ttsdc_send_hello(int pid, int uid)
                TTSD_METHOD_HELLO);
 
        if (NULL == msg) { 
-               SLOG(LOG_ERROR, get_tag(), "<<<< [Dbus ERROR] Fail to create hello message : uid(%d)", uid); 
+               SECURE_SLOG(LOG_ERROR, get_tag(), "<<<< [Dbus ERROR] Fail to create hello message : uid(%d)", uid); 
                return -1;
        } else {
-               SLOG(LOG_DEBUG, get_tag(), "<<<< [Dbus] Send hello message : uid(%d)", uid);
+               SECURE_SLOG(LOG_DEBUG, get_tag(), "<<<< [Dbus] Send hello message : uid(%d)", uid);
        }
 
        dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
@@ -69,6 +92,10 @@ int ttsdc_send_hello(int pid, int uid)
 
        result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
        dbus_message_unref(msg);
+       if (dbus_error_is_set(&err)) {
+               SLOG(LOG_ERROR, get_tag(), "[ERROR] Send error (%s)", err.message);
+               dbus_error_free(&err);
+       }
 
        if (NULL != result_msg) {
                dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
@@ -88,65 +115,33 @@ int ttsdc_send_hello(int pid, int uid)
        return result;
 }
 
-int ttsdc_send_message(int pid, int uid, int data, char *method)
+int ttsdc_send_message(int pid, int uid, int data, const char *method)
 {
-#if 0
-       if (NULL == g_conn) { 
-               SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] Dbus connection is not available" );
-               return -1;
-       }
+       char* send_filename;
+       send_filename = tts_config_get_message_path((int)ttsd_get_mode(), pid);
 
-       char service_name[64];
-       memset(service_name, 0, 64);
-       snprintf(service_name, 64, "%s%d", TTS_CLIENT_SERVICE_NAME, pid);
-
-       char target_if_name[64];
-       snprintf(target_if_name, sizeof(target_if_name), "%s%d", TTS_CLIENT_SERVICE_INTERFACE, pid);
-
-       DBusMessage* msg;
-
-       /* create a message & check for errors */
-       msg = dbus_message_new_method_call(
-               service_name, 
-               TTS_CLIENT_SERVICE_OBJECT_PATH, 
-               target_if_name, 
-               method);
-
-       if (NULL == msg) { 
-               SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] Fail to create message : type(%s), uid(%d)\n", method, uid); 
+       if (NULL == send_filename) {
+               SLOG(LOG_ERROR, get_tag(), "[Message ERROR] Fail to get message file path");
                return -1;
-       } 
-
-       dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INT32, &data, DBUS_TYPE_INVALID);
-
-       /* send the message and flush the connection */
-       if (!dbus_connection_send(g_conn, msg, NULL)) {
-               SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] <<<< send message : Out Of Memory, type(%s), ifname(%s), uid(%d), data(%d)", method, target_if_name, uid, data); 
-       } else {
-               SLOG(LOG_DEBUG, get_tag(), "<<<< send message : type(%s), uid(%d), data(%d)", method, uid, data);
-
-               dbus_connection_flush(g_conn);
        }
 
-       dbus_message_unref(msg);
-#endif
-       char send_filename[64];
-       memset(send_filename, 0, 64);
-       snprintf(send_filename, 64, "/%s_%d", MESSAGE_FILE_PATH, pid);
-
        FILE* fp;
        fp = fopen(send_filename, "a+");
+
+       if (NULL != send_filename) {
+               free(send_filename);
+       }
+
        if (NULL == fp) {
                SLOG(LOG_ERROR, get_tag(), "[File message ERROR] Fail to open message file");
                return -1;
        }
-       SLOG(LOG_DEBUG, get_tag(), "[File message] Write send file - %s, uid=%d, send_data=%d", method, uid, data);
+       SECURE_SLOG(LOG_DEBUG, get_tag(), "[File message] Write send file - %s, uid=%d, send_data=%d", method, uid, data);
 
        fprintf(fp, "%s %d %d\n", method, uid, data);
 
        fclose(fp);
 
-
        return 0;
 }
 
@@ -188,7 +183,7 @@ int ttsdc_send_error_message(int pid, int uid, int uttid, int reason)
                TTSD_METHOD_ERROR);
 
        if (NULL == msg) { 
-               SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] Fail to create error message : uid(%d)\n", uid); 
+               SECURE_SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] Fail to create error message : uid(%d)", uid); 
                return -1;
        }
 
@@ -199,9 +194,10 @@ int ttsdc_send_error_message(int pid, int uid, int uttid, int reason)
                DBUS_TYPE_INVALID);
        
        if (!dbus_connection_send(g_conn, msg, NULL)) {
-               SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] <<<< error message : Out Of Memory !\n"); 
+               SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] <<<< error message : Out Of Memory !"); 
        } else {
-               SLOG(LOG_DEBUG, get_tag(), "<<<< Send error signal : uid(%d), reason(%d), uttid(%d)", uid, reason, uttid);
+               SECURE_SLOG(LOG_DEBUG, get_tag(), "<<<< Send error signal : uid(%d), reason(%s), uttid(%d)", 
+                       uid, __ttsd_get_error_code(reason), uttid);
                dbus_connection_flush(g_conn);
        }
 
@@ -210,40 +206,6 @@ int ttsdc_send_error_message(int pid, int uid, int uttid, int reason)
        return 0;
 }
 
-#if 0
-int ttsd_send_start_next_synthesis()
-{
-       if (NULL == g_conn) { 
-               SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] Dbus connection is not available" );
-               return -1;
-       }
-
-       DBusMessage* msg;
-
-       msg = dbus_message_new_signal(
-               g_service_object,               /* object name of the signal */
-               g_service_interface,            /* interface name of the signal */
-               TTSD_SIGNAL_NEXT_SYNTHESIS);    /* name of the signal */
-
-       if (NULL == msg) { 
-               SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] >>>> Fail to make message for 'start next synthesis'"); 
-               return -1;
-       }
-
-       if (!dbus_connection_send(g_conn, msg, NULL)) {
-               SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] >>>> Fail to send message for 'start next synthesis'"); 
-               return -1;
-       }
-
-       SLOG(LOG_DEBUG, get_tag(), "[Dbus] >>>> Send message for 'start next synthesis'"); 
-
-       dbus_connection_flush(g_conn);
-       dbus_message_unref(msg);
-
-       return 0;
-}
-#endif
-
 static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handler)
 {
        DBusConnection* conn = (DBusConnection*)data;
@@ -255,84 +217,47 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
        DBusMessage* msg = NULL;
        msg = dbus_connection_pop_message(conn);
 
+       if (true != dbus_connection_get_is_connected(conn)) {
+               SLOG(LOG_ERROR, get_tag(), "[ERROR] Connection is disconnected");
+               return ECORE_CALLBACK_RENEW;
+       }
+
        /* loop again if we haven't read a message */
-       if (NULL == msg || NULL == conn) { 
+       if (NULL == msg) {
                return ECORE_CALLBACK_RENEW;
        }
 
        /* client event */
-       if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_HELLO))
+       if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_HELLO)) {
                ttsd_dbus_server_hello(conn, msg);
 
-       else if( dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_INITIALIZE) )
+       } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_INITIALIZE)) {
                ttsd_dbus_server_initialize(conn, msg);
        
-       else if( dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_FINALIZE) )
+       } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_FINALIZE)) {
                ttsd_dbus_server_finalize(conn, msg);
        
-       else if( dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_GET_SUPPORT_VOICES) )
+       } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_GET_SUPPORT_VOICES)) {
                ttsd_dbus_server_get_support_voices(conn, msg);
 
-       else if( dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_GET_CURRENT_VOICE) )
+       } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_GET_CURRENT_VOICE)) {
                ttsd_dbus_server_get_current_voice(conn, msg);
 
-       else if( dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_ADD_QUEUE) )
+       } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_ADD_QUEUE)) {
                ttsd_dbus_server_add_text(conn, msg);
 
-       else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_PLAY)) 
+       } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_PLAY)) {
                ttsd_dbus_server_play(conn, msg);
        
-       else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_STOP)) 
+       } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_STOP)) {
                ttsd_dbus_server_stop(conn, msg);
 
-       else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_PAUSE)) 
+       } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_PAUSE)) {
                ttsd_dbus_server_pause(conn, msg);
-#if 0
-       /* daemon internal event*/
-       else if (dbus_message_is_signal(msg, g_service_interface, TTSD_SIGNAL_NEXT_SYNTHESIS)) 
-               ttsd_dbus_server_start_next_synthesis();
-#endif
-
-       /* setting event */
-       else if (dbus_message_is_method_call(msg, g_service_interface, TTS_SETTING_METHOD_HELLO))
-               ttsd_dbus_server_hello(conn, msg);
-
-       else if (dbus_message_is_method_call(msg, g_service_interface, TTS_SETTING_METHOD_INITIALIZE) )
-               ttsd_dbus_server_setting_initialize(conn, msg);
-
-       else if (dbus_message_is_method_call(msg, g_service_interface, TTS_SETTING_METHOD_FINALIZE) )
-               ttsd_dbus_server_setting_finalize(conn, msg);
-
-       else if (dbus_message_is_method_call(msg, g_service_interface, TTS_SETTING_METHOD_GET_ENGINE_LIST) )
-               ttsd_dbus_server_setting_get_engine_list(conn, msg);
 
-       else if (dbus_message_is_method_call(msg, g_service_interface, TTS_SETTING_METHOD_GET_ENGINE) )
-               ttsd_dbus_server_setting_get_engine(conn, msg);
-
-       else if (dbus_message_is_method_call(msg, g_service_interface, TTS_SETTING_METHOD_SET_ENGINE) )
-               ttsd_dbus_server_setting_set_engine(conn, msg);
-
-       else if (dbus_message_is_method_call(msg, g_service_interface, TTS_SETTING_METHOD_GET_VOICE_LIST) )
-               ttsd_dbus_server_setting_get_voice_list(conn, msg);
-
-       else if (dbus_message_is_method_call(msg, g_service_interface, TTS_SETTING_METHOD_GET_DEFAULT_VOICE) )
-               ttsd_dbus_server_setting_get_default_voice(conn, msg);
-
-       else if (dbus_message_is_method_call(msg, g_service_interface, TTS_SETTING_METHOD_SET_DEFAULT_VOICE) )
-               ttsd_dbus_server_setting_set_default_voice(conn, msg);
-
-       else if (dbus_message_is_method_call(msg, g_service_interface, TTS_SETTING_METHOD_GET_DEFAULT_SPEED) )
-               ttsd_dbus_server_setting_get_speed(conn, msg);
-
-       else if (dbus_message_is_method_call(msg, g_service_interface, TTS_SETTING_METHOD_SET_DEFAULT_SPEED) )
-               ttsd_dbus_server_setting_set_speed(conn, msg);
-
-       else if (dbus_message_is_method_call(msg, g_service_interface, TTS_SETTING_METHOD_GET_ENGINE_SETTING) )
-               ttsd_dbus_server_setting_get_engine_setting(conn, msg);
-
-       else if (dbus_message_is_method_call(msg, g_service_interface, TTS_SETTING_METHOD_SET_ENGINE_SETTING) )
-               ttsd_dbus_server_setting_set_engine_setting(conn, msg);
-       
+       } else {
+               /* Invalid method */
+       }
 
        /* free the message */
        dbus_message_unref(msg);
@@ -351,51 +276,51 @@ int ttsd_dbus_open_connection()
        g_conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
 
        if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] fail dbus_bus_get : %s\n", err.message);
+               SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] Fail dbus_bus_get : %s", err.message);
                dbus_error_free(&err); 
        }
 
        if (NULL == g_conn) { 
-               SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] fail to get dbus connection \n" );
+               SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] Fail to get dbus connection" );
                return -1;
        }
 
        if (TTSD_MODE_SCREEN_READER == ttsd_get_mode()) {
-               g_service_name = (char*)malloc(sizeof(char) * strlen(TTS_SR_SERVER_SERVICE_NAME) + 1);
-               g_service_object = (char*)malloc(sizeof(char) * strlen(TTS_SR_SERVER_SERVICE_OBJECT_PATH) + 1);
-               g_service_interface = (char*)malloc(sizeof(char) * strlen(TTS_SR_SERVER_SERVICE_INTERFACE) + 1);
+               g_service_name = (char*)calloc(strlen(TTS_SR_SERVER_SERVICE_NAME) + 1, sizeof(char));
+               g_service_object = (char*)calloc(strlen(TTS_SR_SERVER_SERVICE_OBJECT_PATH) + 1, sizeof(char));
+               g_service_interface = (char*)calloc(strlen(TTS_SR_SERVER_SERVICE_INTERFACE) + 1, sizeof(char));
 
-               strcpy(g_service_name, TTS_SR_SERVER_SERVICE_NAME);
-               strcpy(g_service_object, TTS_SR_SERVER_SERVICE_OBJECT_PATH);
-               strcpy(g_service_interface, TTS_SR_SERVER_SERVICE_INTERFACE);
+               snprintf(g_service_name, strlen(TTS_SR_SERVER_SERVICE_NAME) + 1, "%s", TTS_SR_SERVER_SERVICE_NAME);
+               snprintf(g_service_object, strlen(TTS_SR_SERVER_SERVICE_OBJECT_PATH) + 1, "%s", TTS_SR_SERVER_SERVICE_OBJECT_PATH);
+               snprintf(g_service_interface, strlen(TTS_SR_SERVER_SERVICE_INTERFACE) + 1, "%s", TTS_SR_SERVER_SERVICE_INTERFACE);
        } else if (TTSD_MODE_NOTIFICATION == ttsd_get_mode()) {
-               g_service_name = (char*)malloc(sizeof(char) * strlen(TTS_NOTI_SERVER_SERVICE_NAME) + 1);
-               g_service_object = (char*)malloc(sizeof(char) * strlen(TTS_NOTI_SERVER_SERVICE_OBJECT_PATH) + 1);
-               g_service_interface = (char*)malloc(sizeof(char) * strlen(TTS_NOTI_SERVER_SERVICE_INTERFACE) + 1);
+               g_service_name = (char*)calloc(strlen(TTS_NOTI_SERVER_SERVICE_NAME) + 1, sizeof(char));
+               g_service_object = (char*)calloc(strlen(TTS_NOTI_SERVER_SERVICE_OBJECT_PATH) + 1, sizeof(char));
+               g_service_interface = (char*)calloc(strlen(TTS_NOTI_SERVER_SERVICE_INTERFACE) + 1, sizeof(char));
 
-               strcpy(g_service_name, TTS_NOTI_SERVER_SERVICE_NAME);
-               strcpy(g_service_object, TTS_NOTI_SERVER_SERVICE_OBJECT_PATH);
-               strcpy(g_service_interface, TTS_NOTI_SERVER_SERVICE_INTERFACE);
+               snprintf(g_service_name, strlen(TTS_NOTI_SERVER_SERVICE_NAME) + 1, "%s", TTS_NOTI_SERVER_SERVICE_NAME);
+               snprintf(g_service_object, strlen(TTS_NOTI_SERVER_SERVICE_OBJECT_PATH) + 1, "%s", TTS_NOTI_SERVER_SERVICE_OBJECT_PATH);
+               snprintf(g_service_interface, strlen(TTS_NOTI_SERVER_SERVICE_INTERFACE) + 1, "%s", TTS_NOTI_SERVER_SERVICE_INTERFACE);
        } else {
-               g_service_name = (char*)malloc(sizeof(char) * strlen(TTS_SERVER_SERVICE_NAME) + 1);
-               g_service_object = (char*)malloc(sizeof(char) * strlen(TTS_SERVER_SERVICE_OBJECT_PATH) + 1);
-               g_service_interface = (char*)malloc(sizeof(char) * strlen(TTS_SERVER_SERVICE_INTERFACE) + 1);
+               g_service_name = (char*)calloc(strlen(TTS_SERVER_SERVICE_NAME) + 1, sizeof(char));
+               g_service_object = (char*)calloc(strlen(TTS_SERVER_SERVICE_OBJECT_PATH) + 1, sizeof(char));
+               g_service_interface = (char*)calloc(strlen(TTS_SERVER_SERVICE_INTERFACE) + 1, sizeof(char));
 
-               strcpy(g_service_name, TTS_SERVER_SERVICE_NAME);
-               strcpy(g_service_object, TTS_SERVER_SERVICE_OBJECT_PATH);
-               strcpy(g_service_interface, TTS_SERVER_SERVICE_INTERFACE);
+               snprintf(g_service_name, strlen(TTS_SERVER_SERVICE_NAME) + 1, "%s", TTS_SERVER_SERVICE_NAME);
+               snprintf(g_service_object, strlen(TTS_SERVER_SERVICE_OBJECT_PATH) + 1, "%s", TTS_SERVER_SERVICE_OBJECT_PATH);
+               snprintf(g_service_interface, strlen(TTS_SERVER_SERVICE_INTERFACE)+ 1, "%s", TTS_SERVER_SERVICE_INTERFACE);
        }
 
        /* request our name on the bus and check for errors */
-       ret = dbus_bus_request_name(g_conn, g_service_name, DBUS_NAME_FLAG_REPLACE_EXISTING , &err);
+       ret = dbus_bus_request_name(g_conn, g_service_name, DBUS_NAME_FLAG_REPLACE_EXISTING, &err);
 
        if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] fail to be primary owner \n");
+               SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] Fail to be primary owner");
                return -1;
        }
 
        if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] dbus_bus_request_name() : %s \n", err.message);
+               SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] Fail to request dbus name : %s", err.message);
                dbus_error_free(&err); 
 
                return -1;
@@ -410,22 +335,20 @@ int ttsd_dbus_open_connection()
        dbus_connection_flush(g_conn);
 
        if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] dbus_bus_add_match() : %s \n", err.message);
+               SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] dbus_bus_add_match() : %s", err.message);
                return -1; 
        }
 
        int fd = 0;
        dbus_connection_get_unix_fd(g_conn, &fd);
 
-       Ecore_Fd_Handler* fd_handler;
-       fd_handler = ecore_main_fd_handler_add(fd, ECORE_FD_READ , (Ecore_Fd_Cb)listener_event_callback, g_conn, NULL, NULL);
-
+       Ecore_Fd_Handler* fd_handler = NULL;
+       fd_handler = ecore_main_fd_handler_add(fd, ECORE_FD_READ, (Ecore_Fd_Cb)listener_event_callback, g_conn, NULL, NULL);
        if (NULL == fd_handler) {
-               SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] ecore_main_fd_handler_add() : fail to get fd handler \n");
+               SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] Fail to get fd handler");
                return -1;
        }
 
-       SLOG(LOG_DEBUG, get_tag(), "[Dbus SUCCESS] Open connection. ");
        return 0;
 }
 
@@ -437,21 +360,14 @@ int ttsd_dbus_close_connection()
        dbus_bus_release_name (g_conn, g_service_name, &err);
 
        if (dbus_error_is_set(&err)) {
-               SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] dbus_bus_release_name() : %s\n", err.message); 
+               SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] dbus_bus_release_name() : %s", err.message); 
                dbus_error_free(&err); 
                return -1;
        }
 
-       if (NULL != g_service_name)
-               free(g_service_name);
-
-       if (NULL != g_service_object)
-               free(g_service_object);
-
-       if (NULL != g_service_interface)
-               free(g_service_interface);
-
-       SLOG(LOG_DEBUG, get_tag(), "[Dbus SUCCESS] Close connection. ");
+       if (NULL != g_service_name)     free(g_service_name);
+       if (NULL != g_service_object)   free(g_service_object);
+       if (NULL != g_service_interface)free(g_service_interface);
 
        return 0;
 }
@@ -459,32 +375,97 @@ int ttsd_dbus_close_connection()
 int ttsd_file_msg_open_connection(int pid)
 {
        /* Make file for Inotify */
-       char send_filename[64];
-       memset(send_filename, 0, 64);
-       snprintf(send_filename, 64, "%s_%d", MESSAGE_FILE_PATH, pid);
+       char* send_filename;
+       send_filename = tts_config_get_message_path((int)ttsd_get_mode(), pid);
+
+       if (NULL == send_filename) {
+               SLOG(LOG_ERROR, get_tag(), "[Message ERROR] Fail to get message file path");
+               return -1;
+       }
 
        FILE* fp;
        fp = fopen(send_filename, "a+");
        if (NULL == fp) {
                SLOG(LOG_ERROR, get_tag(), "[File message ERROR] Fail to make message file");
+               if (NULL != send_filename)      free(send_filename);
                return -1;
        }
-       SLOG(LOG_DEBUG, get_tag(), "[File message] Make message file");
        fclose(fp);
+
+       if (NULL != send_filename)      free(send_filename);
        return 0;
 }
 
 int ttsd_file_msg_close_connection(int pid)
 {
        /* delete inotify file */
-       char path[64];
-       memset(path, 0, 64);
-       snprintf(path, 64, "%s_%d", MESSAGE_FILE_PATH, pid);
-       if (0 == access(path, R_OK)) {
-               if (0 != remove(path)) {
-                       SLOG(LOG_WARN, get_tag(), "[File message WARN] Fail to remove message file");
-               }
+       char* path = NULL;
+       path = tts_config_get_message_path((int)ttsd_get_mode(), pid);
+
+       if (NULL == path) {
+               SLOG(LOG_ERROR, get_tag(), "[Message ERROR] Fail to get message file path");
+               return -1;
+       }
+
+       if (0 != remove(path)) {
+               SLOG(LOG_WARN, get_tag(), "[File message WARN] Fail to remove message file");
        }
-       SLOG(LOG_DEBUG, get_tag(), "[File message] Delete message file");
+
+       if (NULL != path)       free(path);
        return 0;
 }
+
+int ttsd_file_clean_up()
+{
+       SLOG(LOG_DEBUG, get_tag(), "== Old message file clean up == ");
+
+       DIR *dp = NULL;
+       int ret = -1;
+       struct dirent entry;
+       struct dirent *dirp = NULL;
+
+       dp = opendir(MESSAGE_FILE_PATH_ROOT);
+       if (dp == NULL) {
+               SLOG(LOG_ERROR, get_tag(), "[File message WARN] Fail to open path : %s", MESSAGE_FILE_PATH_ROOT);
+               return -1;
+       }
+
+       char prefix[36] = {0, };
+       char remove_path[256] = {0, };
+
+       switch(ttsd_get_mode()) {
+       case TTSD_MODE_DEFAULT:         snprintf(prefix, 36, "%s", MESSAGE_FILE_PREFIX_DEFAULT);                break;
+       case TTSD_MODE_NOTIFICATION:    snprintf(prefix, 36, "%s", MESSAGE_FILE_PREFIX_NOTIFICATION);   break;
+       case TTSD_MODE_SCREEN_READER:   snprintf(prefix, 36, "%s", MESSAGE_FILE_PREFIX_SCREEN_READER);  break;
+       default:
+               SLOG(LOG_ERROR, get_tag(), "[File ERROR] Fail to get mode : %d", ttsd_get_mode());
+               closedir(dp);
+               return -1;
+       }
+
+       do {
+               ret = readdir_r(dp, &entry, &dirp);
+               if (0 != ret) {
+                       SLOG(LOG_ERROR, get_tag(), "[File ERROR] Fail to read directory");
+                       break;
+               }
+
+               if (NULL != dirp) {
+                       if (!strncmp(prefix, dirp->d_name, strlen(prefix))) {
+                               memset(remove_path, 0, 256);
+                               snprintf(remove_path, 256, "%s%s", MESSAGE_FILE_PATH_ROOT, dirp->d_name);
+
+                               /* Clean up code */
+                               if (0 != remove(remove_path)) {
+                                       SLOG(LOG_WARN, get_tag(), "[File message WARN] Fail to remove message file : %s", remove_path);
+                               } else {
+                                       SLOG(LOG_DEBUG, get_tag(), "[File message] Remove message file : %s", remove_path);
+                               }
+                       }
+               }
+       } while (NULL != dirp);
+
+       closedir(dp);
+
+       return 0;
+}
\ No newline at end of file
index 2862afd..6d6cfa4 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*  Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd All Rights Reserved 
+*  Copyright (c) 2011-2014 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
@@ -27,6 +27,8 @@ int ttsd_file_msg_open_connection(int pid);
 
 int ttsd_file_msg_close_connection(int pid);
 
+int ttsd_file_clean_up();
+
 int ttsdc_send_hello(int pid, int uid);
 
 int ttsdc_send_utt_start_message(int pid, int uid, int uttid);
@@ -37,9 +39,6 @@ int ttsdc_send_error_message(int pid, int uid, int uttid, int reason);
 
 int ttsdc_send_set_state_message(int pid, int uid, int state);
 
-#if 0
-int ttsd_send_start_next_synthesis();
-#endif
 
 #ifdef __cplusplus
 }
index 1662200..ee875cb 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*  Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd All Rights Reserved 
+*  Copyright (c) 2011-2014 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
@@ -21,8 +21,7 @@ extern int ttsd_data_get_pid(const int uid);
 
 /*
 * Dbus Client-Daemon Server
-*/ 
-
+*/
 int ttsd_dbus_server_hello(DBusConnection* conn, DBusMessage* msg)
 {
        SLOG(LOG_DEBUG, get_tag(), ">>>>> TTS Hello");
@@ -41,9 +40,6 @@ int ttsd_dbus_server_hello(DBusConnection* conn, DBusMessage* msg)
                SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] Fail to create reply message!!"); 
        }
 
-       SLOG(LOG_DEBUG, get_tag(), "<<<<<");
-       SLOG(LOG_DEBUG, get_tag(), "  ");
-
        return 0;
 }
 
@@ -63,12 +59,12 @@ int ttsd_dbus_server_initialize(DBusConnection* conn, DBusMessage* msg)
        SLOG(LOG_DEBUG, get_tag(), ">>>>> TTS INITIALIZE");
 
        if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, get_tag(), "[IN ERROR] tts initialize : get arguments error (%s)\n", err.message);
+               SLOG(LOG_ERROR, get_tag(), "[IN ERROR] tts initialize : get arguments error (%s)", err.message);
                dbus_error_free(&err); 
                ret = TTSD_ERROR_OPERATION_FAILED;
        } else {
 
-               SLOG(LOG_DEBUG, get_tag(), "[IN] tts initialize : pid(%d), uid(%d) \n", pid , uid); 
+               SECURE_SLOG(LOG_DEBUG, get_tag(), "[IN] tts initialize : pid(%d), uid(%d)", pid , uid); 
                ret =  ttsd_server_initialize(pid, uid);
        }
 
@@ -79,24 +75,21 @@ int ttsd_dbus_server_initialize(DBusConnection* conn, DBusMessage* msg)
                dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
 
                if (0 == ret) {
-                       SLOG(LOG_DEBUG, get_tag(), "[OUT] tts initialize : result(%d) \n", ret); 
+                       SLOG(LOG_DEBUG, get_tag(), "[OUT] tts initialize : result(%d)", ret); 
                } else {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts initialize : result(%d) \n", ret); 
+                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts initialize : result(%d)", ret); 
                }
 
                if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts initialize : Out Of Memory!\n");
+                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts initialize : Out Of Memory!");
                }
 
                dbus_connection_flush(conn);
                dbus_message_unref(reply);
        } else {
-               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts initialize : fail to create reply message!!"); 
+               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts initialize : Fail to create reply message!!"); 
        }
 
-       SLOG(LOG_DEBUG, get_tag(), "<<<<<");
-       SLOG(LOG_DEBUG, get_tag(), "  ");
-
        return 0;
 }
 
@@ -113,13 +106,11 @@ int ttsd_dbus_server_finalize(DBusConnection* conn, DBusMessage* msg)
        SLOG(LOG_DEBUG, get_tag(), ">>>>> TTS FINALIZE");
 
        if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, get_tag(), "[IN ERROR] tts finalize : get arguments error (%s)\n", err.message);
+               SLOG(LOG_ERROR, get_tag(), "[IN ERROR] tts finalize : get arguments error (%s)", err.message);
                dbus_error_free(&err); 
                ret = TTSD_ERROR_OPERATION_FAILED;
        } else {
-               
-               SLOG(LOG_DEBUG, get_tag(), "[IN] tts finalize : uid(%d) \n", uid); 
-
+               SECURE_SLOG(LOG_DEBUG, get_tag(), "[IN] tts finalize : uid(%d)", uid); 
                ret =  ttsd_server_finalize(uid);
        }
 
@@ -130,24 +121,21 @@ int ttsd_dbus_server_finalize(DBusConnection* conn, DBusMessage* msg)
                dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
 
                if (0 == ret) {
-                       SLOG(LOG_DEBUG, get_tag(), "[OUT] tts finalize : result(%d) \n", ret); 
+                       SLOG(LOG_DEBUG, get_tag(), "[OUT] tts finalize : result(%d)", ret); 
                } else {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts finalize : result(%d) \n", ret); 
+                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts finalize : result(%d)", ret); 
                }
 
                if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts finalize : Out Of Memory!\n");
+                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts finalize : Out Of Memory!");
                }
 
                dbus_connection_flush(conn);
                dbus_message_unref(reply);
        } else {
-               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts finalize : fail to create reply message!!"); 
+               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts finalize : Fail to create reply message!!"); 
        }
 
-       SLOG(LOG_DEBUG, get_tag(), "<<<<<");
-       SLOG(LOG_DEBUG, get_tag(), "  ");
-
        return 0;
 }
 
@@ -165,11 +153,11 @@ int ttsd_dbus_server_get_support_voices(DBusConnection* conn, DBusMessage* msg)
        SLOG(LOG_DEBUG, get_tag(), ">>>>> TTS GET VOICES");
 
        if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, get_tag(), "[IN ERROR] tts get supported voices : get arguments error (%s)\n", err.message);
+               SLOG(LOG_ERROR, get_tag(), "[IN ERROR] tts get supported voices : get arguments error (%s)", err.message);
                dbus_error_free(&err); 
                ret = TTSD_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_DEBUG, get_tag(), "[IN] get supported voices : uid(%d) \n", uid ); 
+               SECURE_SLOG(LOG_DEBUG, get_tag(), "[IN] get supported voices : uid(%d)", uid ); 
                ret = ttsd_server_get_support_voices(uid, &voice_list);
        }
 
@@ -188,7 +176,7 @@ int ttsd_dbus_server_get_support_voices(DBusConnection* conn, DBusMessage* msg)
                        int size = g_list_length(voice_list);
                        
                        if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(size))) {
-                               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts supported voices : Fail to append type \n"); 
+                               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts supported voices : Fail to append type"); 
                                ret = TTSD_ERROR_OPERATION_FAILED;
                        } else {
 
@@ -215,24 +203,21 @@ int ttsd_dbus_server_get_support_voices(DBusConnection* conn, DBusMessage* msg)
                                        iter = g_list_first(voice_list);
                                } 
                        }
-                       SLOG(LOG_DEBUG, get_tag(), "[OUT] tts supported voices : result(%d) \n", ret); 
+                       SLOG(LOG_DEBUG, get_tag(), "[OUT] tts supported voices : result(%d)", ret); 
                } else {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts supported voices : result(%d) \n", ret); 
+                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts supported voices : result(%d)", ret); 
                }
 
                if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] error : Out Of Memory!\n");
+                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] error : Out Of Memory!");
                }
 
                dbus_connection_flush(conn);
                dbus_message_unref(reply);
        } else {
-               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts supported voices : fail to create reply message!!");                
+               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts supported voices : Fail to create reply message!!");                
        }
 
-       SLOG(LOG_DEBUG, get_tag(), "<<<<<");
-       SLOG(LOG_DEBUG, get_tag(), "  ");
-
        return 0;
 }
 
@@ -242,7 +227,7 @@ int ttsd_dbus_server_get_current_voice(DBusConnection* conn, DBusMessage* msg)
        dbus_error_init(&err);
 
        int uid;
-       char* lang;
+       char* lang = NULL;
        int voice_type;
        int ret;
 
@@ -251,11 +236,11 @@ int ttsd_dbus_server_get_current_voice(DBusConnection* conn, DBusMessage* msg)
        SLOG(LOG_DEBUG, get_tag(), ">>>>> TTS GET DEFAULT VOICE");
 
        if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, get_tag(), "[IN ERROR] tts get default voice : Get arguments error (%s)\n", err.message);
+               SLOG(LOG_ERROR, get_tag(), "[IN ERROR] tts get default voice : Get arguments error (%s)", err.message);
                dbus_error_free(&err);
                ret = TTSD_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_DEBUG, get_tag(), "[IN] tts get default voice : uid(%d) \n", uid); 
+               SECURE_SLOG(LOG_DEBUG, get_tag(), "[IN] tts get default voice : uid(%d)", uid); 
                ret = ttsd_server_get_current_voice(uid, &lang, &voice_type);
        }
 
@@ -270,27 +255,25 @@ int ttsd_dbus_server_get_current_voice(DBusConnection* conn, DBusMessage* msg)
                                DBUS_TYPE_STRING, &lang,
                                DBUS_TYPE_INT32, &voice_type,
                                DBUS_TYPE_INVALID);
-                       SLOG(LOG_DEBUG, get_tag(), "[OUT] tts default voice : lang(%s), vctype(%d)\n", lang, voice_type );
+                       SECURE_SLOG(LOG_DEBUG, get_tag(), "[OUT] tts default voice : lang(%s), vctype(%d)", lang, voice_type );
                } else {
                        dbus_message_append_args( reply, 
                                DBUS_TYPE_INT32, &ret,
                                DBUS_TYPE_INVALID);
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts default voice : result(%d) \n", ret); 
+                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts default voice : result(%d)", ret); 
                }
 
                if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts default voice : Out Of Memory!\n");
+                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts default voice : Out Of Memory!");
                }
 
                dbus_connection_flush(conn);
                dbus_message_unref(reply);
        } else {
-               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts default voice : fail to create reply message!!"); 
+               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts default voice : Fail to create reply message!!"); 
        }
 
-       SLOG(LOG_DEBUG, get_tag(), "<<<<<");
-       SLOG(LOG_DEBUG, get_tag(), "  ");
-
+       if (NULL != lang)       free(lang);
        return 0;
 }
 
@@ -315,12 +298,12 @@ int ttsd_dbus_server_add_text(DBusConnection* conn, DBusMessage* msg)
        SLOG(LOG_DEBUG, get_tag(), ">>>>> TTS ADD TEXT");
 
        if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, get_tag(), "[IN ERROR] tts add text : Get arguments error (%s)\n", err.message);
+               SLOG(LOG_ERROR, get_tag(), "[IN ERROR] tts add text : Get arguments error (%s)", err.message);
                dbus_error_free(&err); 
                ret = TTSD_ERROR_OPERATION_FAILED;
        } else {
                
-               SLOG(LOG_DEBUG, get_tag(), "[IN] tts add text : uid(%d), text(%s), lang(%s), type(%d), speed(%d), uttid(%d) \n", 
+               SECURE_SLOG(LOG_DEBUG, get_tag(), "[IN] tts add text : uid(%d), text(%s), lang(%s), type(%d), speed(%d), uttid(%d)", 
                        uid, text, lang, voicetype, speed, uttid); 
                ret =  ttsd_server_add_queue(uid, text, lang, voicetype, speed, uttid);
        }
@@ -332,21 +315,21 @@ int ttsd_dbus_server_add_text(DBusConnection* conn, DBusMessage* msg)
                dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
 
                if (0 == ret) {
-                       SLOG(LOG_DEBUG, get_tag(), "[OUT] tts add text : result(%d) \n", ret); 
+                       SLOG(LOG_DEBUG, get_tag(), "[OUT] tts add text : result(%d)", ret); 
                } else {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts add text : result(%d) \n", ret); 
+                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts add text : result(%d)", ret); 
                }
 
                if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts add text : Out Of Memory!\n");
+                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts add text : Out Of Memory!");
                }
 
                dbus_connection_flush(conn);
                dbus_message_unref(reply);
        } else {
-               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts add text : fail to create reply message!!"); 
+               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts add text : Fail to create reply message!!"); 
        }
-
+       
        SLOG(LOG_DEBUG, get_tag(), "<<<<<");
        SLOG(LOG_DEBUG, get_tag(), "  ");
 
@@ -366,11 +349,11 @@ int ttsd_dbus_server_play(DBusConnection* conn, DBusMessage* msg)
        SLOG(LOG_DEBUG, get_tag(), ">>>>> TTS PLAY");
 
        if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, get_tag(), "[IN ERROR] tts play : Get arguments error (%s)\n", err.message);
+               SLOG(LOG_ERROR, get_tag(), "[IN ERROR] tts play : Get arguments error (%s)", err.message);
                dbus_error_free(&err); 
                ret = TTSD_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_DEBUG, get_tag(), "[IN] tts play : uid(%d) \n", uid ); 
+               SECURE_SLOG(LOG_DEBUG, get_tag(), "[IN] tts play : uid(%d)", uid ); 
                ret =  ttsd_server_play(uid);
        }
 
@@ -381,19 +364,19 @@ int ttsd_dbus_server_play(DBusConnection* conn, DBusMessage* msg)
                dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
 
                if (0 == ret) {
-                       SLOG(LOG_DEBUG, get_tag(), "[OUT] tts play : result(%d) \n", ret); 
+                       SLOG(LOG_DEBUG, get_tag(), "[OUT] tts play : result(%d)", ret); 
                } else {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts play : result(%d) \n", ret); 
+                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts play : result(%d)", ret); 
                }
        
                if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts play : Out Of Memory!\n");
+                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts play : Out Of Memory!");
                }
 
                dbus_connection_flush(conn);
                dbus_message_unref(reply);
        } else {
-               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts play : fail to create reply message!!"); 
+               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts play : Fail to create reply message!!"); 
        }
 
        SLOG(LOG_DEBUG, get_tag(), "<<<<<");
@@ -416,11 +399,11 @@ int ttsd_dbus_server_stop(DBusConnection* conn, DBusMessage* msg)
        SLOG(LOG_DEBUG, get_tag(), ">>>>> TTS STOP");
 
        if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, get_tag(), "[IN ERROR] tts stop : Get arguments error (%s)\n", err.message);
+               SLOG(LOG_ERROR, get_tag(), "[IN ERROR] tts stop : Get arguments error (%s)", err.message);
                dbus_error_free(&err); 
                ret = TTSD_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_DEBUG, get_tag(), "[IN] tts stop : uid(%d)\n", uid);
+               SECURE_SLOG(LOG_DEBUG, get_tag(), "[IN] tts stop : uid(%d)", uid);
                ret = ttsd_server_stop(uid);
        }
 
@@ -433,19 +416,19 @@ int ttsd_dbus_server_stop(DBusConnection* conn, DBusMessage* msg)
                        DBUS_TYPE_INVALID);
 
                if (0 == ret) {
-                       SLOG(LOG_DEBUG, get_tag(), "[OUT] tts stop : result(%d) \n", ret); 
+                       SLOG(LOG_DEBUG, get_tag(), "[OUT] tts stop : result(%d)", ret); 
                } else {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts stop : result(%d) \n", ret); 
+                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts stop : result(%d)", ret); 
                }
 
                if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts stop : Out Of Memory!\n");
+                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts stop : Out Of Memory!");
                }
 
                dbus_connection_flush(conn);
                dbus_message_unref(reply);
        } else {
-               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts stop : fail to create reply message!!"); 
+               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts stop : Fail to create reply message!!"); 
        }
 
        SLOG(LOG_DEBUG, get_tag(), "<<<<<");
@@ -469,11 +452,11 @@ int ttsd_dbus_server_pause(DBusConnection* conn, DBusMessage* msg)
        SLOG(LOG_DEBUG, get_tag(), ">>>>> TTS PAUSE");
 
        if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, get_tag(), "[IN ERROR] tts pause : Get arguments error (%s)\n", err.message);
+               SLOG(LOG_ERROR, get_tag(), "[IN ERROR] tts pause : Get arguments error (%s)", err.message);
                dbus_error_free(&err); 
                ret = TTSD_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_DEBUG, get_tag(), "[IN] tts pause : uid(%d)\n", uid);
+               SECURE_SLOG(LOG_DEBUG, get_tag(), "[IN] tts pause : uid(%d)", uid);
                ret = ttsd_server_pause(uid, &uttid);
        }
 
@@ -486,332 +469,19 @@ int ttsd_dbus_server_pause(DBusConnection* conn, DBusMessage* msg)
                        DBUS_TYPE_INVALID);
 
                if (0 == ret) {
-                       SLOG(LOG_DEBUG, get_tag(), "[OUT] tts pause : result(%d) \n", ret); 
-               } else {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts pause : result(%d) \n", ret); 
-               }
-
-               if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts pause : Out Of Memory!\n");
-               }
-
-               dbus_connection_flush(conn);
-               dbus_message_unref(reply);
-       } else {
-               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts pause : fail to create reply message!!"); 
-       }
-
-       SLOG(LOG_DEBUG, get_tag(), "<<<<<");
-       SLOG(LOG_DEBUG, get_tag(), "  ");
-
-       return 0;
-}
-
-#if 0
-/*
-* Dbus Server functions for tts daemon internal
-*/ 
-int ttsd_dbus_server_start_next_synthesis()
-{
-       return ttsd_server_start_next_synthesis();
-}
-#endif
-
-/*
-* Dbus Setting-Daemon Server
-*/ 
-
-int ttsd_dbus_server_setting_initialize(DBusConnection* conn, DBusMessage* msg)
-{
-       DBusError err;
-       dbus_error_init(&err);
-
-       int pid;
-       int ret = 0;
-
-       dbus_message_get_args(msg, &err,
-               DBUS_TYPE_INT32, &pid,
-               DBUS_TYPE_INVALID);
-
-       SLOG(LOG_DEBUG, get_tag(), ">>>>> SETTING INITIALIZE");
-
-       if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, get_tag(), "[IN ERROR] Receivce setting initialize : Get arguments error (%s)\n", err.message);
-               dbus_error_free(&err);
-               ret = TTSD_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, get_tag(), "[IN] Receivce setting initialize : pid(%d) \n", pid); 
-               ret =  ttsd_server_setting_initialize(pid);
-       }
-       
-       DBusMessage* reply;
-       reply = dbus_message_new_method_return(msg);
-
-       if (NULL != reply) {
-               dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
-
-               if (0 == ret) {
-                       SLOG(LOG_DEBUG, get_tag(), "[OUT] setting initialize : result(%d) \n", ret);
-               } else {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting initialize : result(%d) \n", ret);
-               }
-
-               if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting initialize : Out Of Memory!\n");
-               }
-
-               dbus_connection_flush(conn);
-               dbus_message_unref(reply);
-       } else {
-               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting initialize : fail to create reply message!!"); 
-       }
-
-       SLOG(LOG_DEBUG, get_tag(), "<<<<<");
-       SLOG(LOG_DEBUG, get_tag(), "  ");
-
-       return 0;
-}
-
-int ttsd_dbus_server_setting_finalize(DBusConnection* conn, DBusMessage* msg)
-{
-       DBusError err;
-       dbus_error_init(&err);
-
-       int pid;
-       int ret = 0;
-
-       dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID);
-
-       SLOG(LOG_DEBUG, get_tag(), ">>>>> SETTING FINALIZE");
-
-       if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, get_tag(), "[IN ERROR] setting finalize : Get arguments error (%s)\n", err.message);
-               dbus_error_free(&err); 
-               ret = TTSD_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, get_tag(), "[IN] setting finalize : pid(%d)\n", pid); 
-               ret =  ttsd_server_setting_finalize(pid);       
-       }
-
-       DBusMessage* reply;
-       reply = dbus_message_new_method_return(msg);
-
-       if (NULL != reply) {
-               dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
-
-               if (0 == ret) {
-                       SLOG(LOG_DEBUG, get_tag(), "[OUT] setting finalize : result(%d) \n", ret);
-               } else {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting finalize : result(%d) \n", ret);
-               }
-               
-               if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting finalize : Out Of Memory!\n");
-               }
-
-               dbus_connection_flush(conn);
-               dbus_message_unref(reply);
-       } else {
-               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting finalize : fail to create reply message!!"); 
-       }
-
-       SLOG(LOG_DEBUG, get_tag(), "<<<<<");
-       SLOG(LOG_DEBUG, get_tag(), "  ");
-
-       return 0;
-}
-
-int ttsd_dbus_server_setting_get_engine_list(DBusConnection* conn, DBusMessage* msg)
-{
-       DBusError err;
-       dbus_error_init(&err);
-
-       int pid;
-       int ret = 0;
-       GList* engine_list = NULL;
-       
-       dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID);
-
-       SLOG(LOG_DEBUG, get_tag(), ">>>>> SETTING GET ENGINE LIST");
-
-       if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, get_tag(), "[IN ERROR] setting engine list : Get arguments error (%s)\n", err.message);
-               dbus_error_free(&err); 
-               ret = TTSD_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, get_tag(), "[IN] setting engine list : pid(%d) \n", pid); 
-               ret = ttsd_server_setting_get_engine_list(pid, &engine_list);   
-       }
-       
-       DBusMessage* reply;
-       reply = dbus_message_new_method_return(msg);
-
-       if (NULL != reply) {
-               DBusMessageIter args;
-               dbus_message_iter_init_append(reply, &args);
-
-               /* Append result*/
-               dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(ret) );
-
-               if (0 == ret) {
-                       /* Append size */
-                       int size = g_list_length(engine_list);
-                       if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(size))) {
-                               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting engine list : fail to append engine size \n");
-                       } else {
-
-                               GList *iter = NULL;
-                               engine_s* engine;
-
-                               iter = g_list_first(engine_list);
-
-                               while (NULL != iter) {
-                                       engine = iter->data;
-                                       
-                                       if (NULL != engine) {
-                                               SLOG(LOG_DEBUG, get_tag(), "engine id : %s, engine name : %s, ug_name, : %s", 
-                                                       engine->engine_id, engine->engine_name, engine->ug_name);
-
-                                               dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(engine->engine_id) );
-                                               dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(engine->engine_name) );
-                                               dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(engine->ug_name) );
-
-                                               if (NULL != engine->engine_id)
-                                                       g_free(engine->engine_id);
-                                               if (NULL != engine->engine_name)
-                                                       g_free(engine->engine_name);
-                                               if (NULL != engine->ug_name)
-                                                       g_free(engine->ug_name);
-                                               
-                                               g_free(engine);
-                                       }
-                                       
-                                       engine_list = g_list_remove_link(engine_list, iter);
-
-                                       iter = g_list_first(engine_list);
-                               } 
-                               SLOG(LOG_DEBUG, get_tag(), "[OUT] setting engine list : result(%d) \n", ret);
-                       }
-               } else {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting engine list : result(%d) \n", ret);
-               }
-
-               if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting engine list : Out Of Memory!\n");
-               }
-
-               dbus_connection_flush(conn);
-               dbus_message_unref(reply);
-       } else {
-               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting engine list : fail to create reply message!!"); 
-       }
-
-       SLOG(LOG_DEBUG, get_tag(), "<<<<<");
-       SLOG(LOG_DEBUG, get_tag(), "  ");
-
-       return 0;
-}
-
-int ttsd_dbus_server_setting_get_engine(DBusConnection* conn, DBusMessage* msg)
-{
-       DBusError err;
-       dbus_error_init(&err);
-
-       int pid;
-       int ret = 0;
-       char* engine_id = NULL;
-
-       dbus_message_get_args(msg, &err,
-               DBUS_TYPE_INT32, &pid,
-               DBUS_TYPE_INVALID);
-
-       SLOG(LOG_DEBUG, get_tag(), ">>>>> SETTING GET ENGINE");
-
-       if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, get_tag(), "[IN ERROR] setting get engine : Get arguments error (%s)\n", err.message);
-               dbus_error_free(&err); 
-               ret = TTSD_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, get_tag(), "[IN] setting get engine : pid(%d)\n", pid); 
-               ret = ttsd_server_setting_get_current_engine(pid, &engine_id);
-       }
-
-       DBusMessage* reply;
-       reply = dbus_message_new_method_return(msg);
-
-       if (NULL != reply) {
-               if (0 == ret) {
-                       dbus_message_append_args( reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_STRING, &engine_id, DBUS_TYPE_INVALID);
-                       SLOG(LOG_DEBUG, get_tag(), "[OUT] setting get engine : result(%d), engine id(%s)\n", ret, engine_id);
-               } else {
-                       dbus_message_append_args( reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting get engine : result(%d)", ret);
-               }
-
-               if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting get engine : Out Of Memory!\n");
-               }
-
-               dbus_connection_flush(conn);
-               dbus_message_unref(reply);
-       } else {
-               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting get engine : fail to create reply message!!"); 
-       }
-
-       if (NULL != engine_id)
-               free(engine_id);
-
-       SLOG(LOG_DEBUG, get_tag(), "<<<<<");
-       SLOG(LOG_DEBUG, get_tag(), "  ");
-
-       return 0;
-}
-
-int ttsd_dbus_server_setting_set_engine(DBusConnection* conn, DBusMessage* msg)
-{
-       DBusError err;
-       dbus_error_init(&err);
-
-       int pid;
-       char* engine_id;
-       int ret = 0;
-
-       dbus_message_get_args(msg, &err,
-               DBUS_TYPE_INT32, &pid,
-               DBUS_TYPE_STRING, &engine_id,
-               DBUS_TYPE_INVALID);
-
-       SLOG(LOG_DEBUG, get_tag(), ">>>>> SETTING SET ENGINE");
-
-       if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, get_tag(), "[IN ERROR] setting set engine : Get arguments error (%s)\n", err.message);
-               dbus_error_free(&err); 
-               ret = TTSD_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, get_tag(), "[IN] setting set engine : pid(%d), engine id(%s)\n", pid,  engine_id); 
-               ret = ttsd_server_setting_set_current_engine(pid, engine_id);
-       }
-       
-       DBusMessage* reply;
-       reply = dbus_message_new_method_return(msg);
-
-       if (NULL != reply) {
-               dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
-
-               if (0 == ret) {
-                       SLOG(LOG_DEBUG, get_tag(), "[OUT] setting set engine : result(%d) \n", ret);
+                       SLOG(LOG_DEBUG, get_tag(), "[OUT] tts pause : result(%d)", ret); 
                } else {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting set engine : result(%d) \n", ret);
+                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts pause : result(%d)", ret); 
                }
 
                if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting set engine : Out Of Memory!\n");
+                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts pause : Out Of Memory!");
                }
 
                dbus_connection_flush(conn);
                dbus_message_unref(reply);
        } else {
-               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting set engine : fail to create reply message!!"); 
+               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts pause : Fail to create reply message!!"); 
        }
 
        SLOG(LOG_DEBUG, get_tag(), "<<<<<");
@@ -819,467 +489,3 @@ int ttsd_dbus_server_setting_set_engine(DBusConnection* conn, DBusMessage* msg)
 
        return 0;
 }
-
-int ttsd_dbus_server_setting_get_voice_list(DBusConnection* conn, DBusMessage* msg)
-{
-       DBusError err;
-       dbus_error_init(&err);
-
-       int pid;
-       char* engine_id = NULL;
-       int ret = 0;
-       GList* voice_list = NULL;
-
-       dbus_message_get_args(msg, &err,
-               DBUS_TYPE_INT32, &pid,
-               DBUS_TYPE_INVALID);
-
-       SLOG(LOG_DEBUG, get_tag(), ">>>>> SETTING GET VOICE LIST");
-
-       if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, get_tag(), "[IN ERROR] setting voice list : Get arguments error (%s)\n", err.message);
-               dbus_error_free(&err); 
-               ret = TTSD_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, get_tag(), "[IN] setting voice list : pid(%d)\n", pid); 
-               ret = ttsd_server_setting_get_voice_list(pid, &engine_id, &voice_list);
-       }
-       
-       DBusMessage* reply;
-       reply = dbus_message_new_method_return(msg);
-
-       if (NULL != reply) {
-               DBusMessageIter args;
-
-               dbus_message_iter_init_append(reply, &args);
-
-               /* Append result*/
-               dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(ret) );
-
-               if (0 == ret) {
-                       if (dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(engine_id))) {
-                               /* Append voice size */
-                               int size = g_list_length(voice_list);
-                               if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(size))) {
-                                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting voice list : Fail to append type \n"); 
-                                       ret = TTSD_ERROR_OPERATION_FAILED;
-                               } else {
-
-                                       GList *iter = NULL;
-                                       voice_s* voice;
-
-                                       iter = g_list_first(voice_list);
-
-                                       while (NULL != iter) {
-                                               voice = iter->data;
-
-                                               if (NULL != voice) {
-                                                       dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(voice->language) );
-                                                       dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(voice->type) );
-
-                                                       if (NULL != voice->language)
-                                                               g_free(voice->language);
-
-                                                       g_free(voice);
-                                               }
-
-                                               voice_list = g_list_remove_link(voice_list, iter);
-
-                                               iter = g_list_first(voice_list);
-                                       } 
-                               }
-                               SLOG(LOG_DEBUG, get_tag(), "[OUT] setting voice list : result(%d) \n", ret); 
-                       } else {
-                               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting voice list : Fail to append engine_id \n"); 
-                       }
-
-                       if (NULL != engine_id)
-                               free(engine_id);
-               } else {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting voice list : result(%d) \n", ret);
-               }
-
-               if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting voice list : Out Of Memory!\n");
-               }
-
-               dbus_connection_flush(conn);
-               dbus_message_unref(reply);
-       } else {
-               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting voice list : fail to create reply message!!"); 
-       }
-
-       SLOG(LOG_DEBUG, get_tag(), "<<<<<");
-       SLOG(LOG_DEBUG, get_tag(), "  ");
-
-       return 0;
-}
-
-int ttsd_dbus_server_setting_get_default_voice(DBusConnection* conn, DBusMessage* msg)
-{
-       DBusError err;
-       dbus_error_init(&err);
-
-       int pid;
-       int ret = 0;
-       char* lang;
-       ttsp_voice_type_e type;
-
-       dbus_message_get_args(msg, &err,
-               DBUS_TYPE_INT32, &pid,
-               DBUS_TYPE_INVALID);
-
-       SLOG(LOG_DEBUG, get_tag(), ">>>>> SETTING GET DEFAULT VOICE");
-
-       if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, get_tag(), "[IN ERROR] setting get default voice : Get arguments error (%s)\n", err.message);
-               dbus_error_free(&err); 
-               ret = TTSD_ERROR_OPERATION_FAILED;
-       } else {        
-               SLOG(LOG_DEBUG, get_tag(), "[IN] setting get default voice : pid(%d)\n", pid); 
-               ret = ttsd_server_setting_get_default_voice(pid, &lang, &type);
-       }
-       
-       DBusMessage* reply;
-       reply = dbus_message_new_method_return(msg);
-
-       if (NULL != reply) {
-               if (0 == ret) {
-                       dbus_message_append_args(reply, 
-                               DBUS_TYPE_INT32, &ret, 
-                               DBUS_TYPE_STRING, &lang, 
-                               DBUS_TYPE_INT32, &type, 
-                               DBUS_TYPE_INVALID);
-                       SLOG(LOG_DEBUG, get_tag(), "[OUT] setting get default voice : result(%d), language(%s), type(%d) \n", ret, lang, type);
-               } else {
-                       dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting get default voice : result(%d) \n", ret);
-               }
-
-               if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting get default voice : Out Of Memory!\n");
-               }
-
-               dbus_connection_flush(conn);
-               dbus_message_unref(reply);
-       } else {
-               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting get default voice : fail to create reply message!!"); 
-       }
-
-       SLOG(LOG_DEBUG, get_tag(), "<<<<<");
-       SLOG(LOG_DEBUG, get_tag(), "  ");
-
-       return 0;
-}
-
-int ttsd_dbus_server_setting_set_default_voice(DBusConnection* conn, DBusMessage* msg)
-{
-       DBusError err;
-       dbus_error_init(&err);
-
-       int pid;
-       char* language;
-       int voicetype;
-       int ret = 0;
-
-       dbus_message_get_args(msg, &err,
-               DBUS_TYPE_INT32, &pid,
-               DBUS_TYPE_STRING, &language,
-               DBUS_TYPE_INT32, &voicetype,
-               DBUS_TYPE_INVALID);
-
-       SLOG(LOG_DEBUG, get_tag(), ">>>>> SET DEFAULT VOICE");
-
-       if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, get_tag(), "[IN ERROR] setting set default voice : Get arguments error (%s)\n", err.message);
-               dbus_error_free(&err); 
-               ret = TTSD_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, get_tag(), "[IN] setting set default voice : pid(%d), lang(%s), type(%d)\n"
-                       , pid, language, voicetype); 
-               ret =  ttsd_server_setting_set_default_voice(pid, language, voicetype);
-       }
-       
-       DBusMessage* reply;
-       reply = dbus_message_new_method_return(msg);
-
-       if (NULL != reply) {
-               dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
-
-               if (0 == ret) {
-                       SLOG(LOG_DEBUG, get_tag(), "[OUT] setting set default voice : result(%d) \n", ret);
-               } else {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting set default voice : result(%d) \n", ret);
-               }
-
-               if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting set default voice : Out Of Memory!\n");
-               }
-
-               dbus_connection_flush(conn);
-               dbus_message_unref(reply);
-       } else {
-               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting set default voice : fail to create reply message!!"); 
-       }
-
-       SLOG(LOG_DEBUG, get_tag(), "<<<<<");
-       SLOG(LOG_DEBUG, get_tag(), "  ");
-
-       return 0;
-}
-
-int ttsd_dbus_server_setting_get_speed(DBusConnection* conn, DBusMessage* msg)
-{
-       DBusError err;
-       dbus_error_init(&err);
-
-       int pid;
-       int ret = 0;
-       int speed;
-
-       dbus_message_get_args(msg, &err,
-               DBUS_TYPE_INT32, &pid,
-               DBUS_TYPE_INVALID);
-
-       SLOG(LOG_DEBUG, get_tag(), ">>>>> SETTING GET SPEED");
-
-       if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, get_tag(), "[IN ERROR] setting get speed : Get arguments error (%s)\n", err.message);
-               dbus_error_free(&err); 
-               ret = TTSD_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, get_tag(), "[IN] setting get default speed : pid(%d)\n", pid); 
-               ret =  ttsd_server_setting_get_default_speed(pid, &speed);
-       }
-       
-       DBusMessage* reply;
-       reply = dbus_message_new_method_return(msg);
-
-       if (NULL != reply) {
-               if (0 == ret) {
-                       dbus_message_append_args( reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INT32, &speed, DBUS_TYPE_INVALID);
-                       SLOG(LOG_DEBUG, get_tag(), "[OUT] setting get default speed : result(%d), speed(%d) \n", ret, speed);
-               } else {
-                       dbus_message_append_args( reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting get default speed : result(%d) \n", ret);
-               }
-
-               if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting get default speed : Out Of Memory!\n");
-               }
-
-               dbus_connection_flush(conn);
-               dbus_message_unref(reply);
-       } else {
-               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting get default speed : fail to create reply message!!"); 
-       }
-
-       SLOG(LOG_DEBUG, get_tag(), "<<<<<");
-       SLOG(LOG_DEBUG, get_tag(), "  ");
-
-       return 0;
-}
-
-int ttsd_dbus_server_setting_set_speed(DBusConnection* conn, DBusMessage* msg)
-{
-       DBusError err;
-       dbus_error_init(&err);
-
-       int pid;
-       int speed;
-       int ret = 0;
-
-       dbus_message_get_args(msg, &err,
-               DBUS_TYPE_INT32, &pid,
-               DBUS_TYPE_INT32, &speed,
-               DBUS_TYPE_INVALID);
-
-       SLOG(LOG_DEBUG, get_tag(), ">>>>> SETTING GET SPEED");
-
-       if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, get_tag(), "[IN ERROR] setting set default speed : Get arguments error (%s)\n", err.message);
-               dbus_error_free(&err); 
-               ret = TTSD_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, get_tag(), "[IN] setting set default speed : pid(%d), speed(%d)\n", pid, speed); 
-               ret = ttsd_server_setting_set_default_speed(pid, speed);
-       }
-
-       DBusMessage* reply;
-       reply = dbus_message_new_method_return(msg);
-
-       if (NULL != reply) {
-               dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
-
-               if (0 == ret) {
-                       SLOG(LOG_DEBUG, get_tag(), "[OUT] setting set default speed : result(%d)", ret);
-               } else {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting set default speed : result(%d)", ret);
-               }
-
-               if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting set default speed : Out Of Memory!\n");
-               }
-
-               dbus_connection_flush(conn);
-               dbus_message_unref(reply);
-       } else {
-               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting set default speed : fail to create reply message!!"); 
-       }
-
-       SLOG(LOG_DEBUG, get_tag(), "<<<<<");
-       SLOG(LOG_DEBUG, get_tag(), "  ");
-
-       return 0;
-}
-
-int ttsd_dbus_server_setting_get_engine_setting(DBusConnection* conn, DBusMessage* msg)
-{
-       DBusError err;
-       dbus_error_init(&err);
-
-       int pid;
-       int ret = 0;
-       char* engine_id;
-       GList* engine_setting_list = NULL;
-
-       dbus_message_get_args(msg, &err,
-               DBUS_TYPE_INT32, &pid,
-               DBUS_TYPE_INVALID);
-
-       SLOG(LOG_DEBUG, get_tag(), ">>>>> SETTING GET ENGINE SETTING");
-
-       if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, get_tag(), "[IN ERROR] setting get engine option : Get arguments error (%s)\n", err.message);
-               dbus_error_free(&err); 
-               ret = TTSD_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, get_tag(), "[IN] setting get engine option : pid(%d)", pid); 
-               ret = ttsd_server_setting_get_engine_setting(pid, &engine_id, &engine_setting_list);
-       }
-
-       DBusMessage* reply;
-       reply = dbus_message_new_method_return(msg);
-
-       if (NULL != reply) {
-               DBusMessageIter args;
-               dbus_message_iter_init_append(reply, &args);
-
-               /* Append result*/
-               dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(ret) );
-
-               if (0 == ret) {
-                       if (dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(engine_id))) {
-                               /* Append voice size */
-                               int size = g_list_length(engine_setting_list);
-                               if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(size))) {
-                                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting voice list : Fail to append type \n"); 
-                                       ret = TTSD_ERROR_OPERATION_FAILED;
-                               } else {
-
-                                       GList *iter = NULL;
-                                       engine_setting_s* setting;
-
-                                       iter = g_list_first(engine_setting_list);
-
-                                       while (NULL != iter) {
-                                               setting = iter->data;
-
-                                               if (NULL != setting) {
-                                                       dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(setting->key) );
-                                                       dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(setting->value) );
-
-                                                       if (NULL != setting->key)
-                                                               g_free(setting->key);
-                                                       if (NULL != setting->value)
-                                                               g_free(setting->value);
-                                                       
-                                                       g_free(setting);
-                                               }
-                                               
-                                               engine_setting_list = g_list_remove_link(engine_setting_list, iter);
-
-                                               iter = g_list_first(engine_setting_list);
-                                       } 
-                               }
-                               SLOG(LOG_DEBUG, get_tag(), "[OUT] setting engine setting list : result(%d) \n", ret); 
-                       } else {
-                               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting voice list : Fail to append engine_id \n"); 
-                       }
-
-                       if (NULL != engine_id)
-                               free(engine_id);
-               } else {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting get engine option : result(%d) \n", ret);
-               }
-
-               if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting get engine option : Out Of Memory!\n");
-               }
-
-               dbus_connection_flush(conn);
-               dbus_message_unref(reply);
-       } else {
-               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting get engine option : fail to create reply message!!"); 
-       }
-
-       SLOG(LOG_DEBUG, get_tag(), "<<<<<");
-       SLOG(LOG_DEBUG, get_tag(), "  ");
-
-       return 0;
-}
-
-int ttsd_dbus_server_setting_set_engine_setting(DBusConnection* conn, DBusMessage* msg)
-{
-       DBusError err;
-       dbus_error_init(&err);
-
-       int pid;
-       char* key;
-       char* value;
-       int ret = 0;
-
-       dbus_message_get_args(msg, &err,
-               DBUS_TYPE_INT32, &pid,
-               DBUS_TYPE_STRING, &key,
-               DBUS_TYPE_STRING, &value,
-               DBUS_TYPE_INVALID);
-
-       SLOG(LOG_DEBUG, get_tag(), ">>>>> SETTING SET ENGINE SETTING");
-
-       if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, get_tag(), "[IN ERROR] setting set engine option : Get arguments error (%s)\n", err.message);
-               dbus_error_free(&err); 
-               ret = TTSD_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, get_tag(), "[IN] setting set engine option : pid(%d), key(%s), value(%s)\n", pid, key, value); 
-               ret = ttsd_server_setting_set_engine_setting(pid, key, value);
-       }
-       
-       DBusMessage* reply;
-       reply = dbus_message_new_method_return(msg);
-
-       if (NULL != reply) {
-               dbus_message_append_args( reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
-
-               if (0 == ret) {
-                       SLOG(LOG_DEBUG, get_tag(), "[OUT] setting set engine option : result(%d)", ret);
-               } else {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting set engine option : result(%d)", ret);
-               }
-
-               if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting set engine option : Out Of Memory!\n");
-               }
-               dbus_connection_flush(conn);
-               dbus_message_unref(reply);
-       } else {
-               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] setting set engine option : fail to create reply message!!"); 
-       }
-
-       SLOG(LOG_DEBUG, get_tag(), "<<<<<");
-       SLOG(LOG_DEBUG, get_tag(), "  ");
-
-       return 0;
-}
-
index d1e2aff..04a5e3a 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*  Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd All Rights Reserved 
+*  Copyright (c) 2011-2014 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
@@ -43,41 +43,6 @@ int ttsd_dbus_server_stop(DBusConnection* conn, DBusMessage* msg);
 
 int ttsd_dbus_server_pause(DBusConnection* conn, DBusMessage* msg);
 
-#if 0
-/*
-* Dbus Server functions for tts daemon internal
-*/ 
-int ttsd_dbus_server_start_next_synthesis();
-#endif
-
-/*
-* Dbus Server functions for Setting
-*/ 
-
-int ttsd_dbus_server_setting_initialize(DBusConnection* conn, DBusMessage* msg);
-
-int ttsd_dbus_server_setting_finalize(DBusConnection* conn, DBusMessage* msg);
-
-int ttsd_dbus_server_setting_get_engine_list(DBusConnection* conn, DBusMessage* msg);
-
-int ttsd_dbus_server_setting_get_engine(DBusConnection* conn, DBusMessage* msg);
-
-int ttsd_dbus_server_setting_set_engine(DBusConnection* conn, DBusMessage* msg);
-
-int ttsd_dbus_server_setting_get_voice_list(DBusConnection* conn, DBusMessage* msg);
-
-int ttsd_dbus_server_setting_get_default_voice(DBusConnection* conn, DBusMessage* msg);
-
-int ttsd_dbus_server_setting_set_default_voice(DBusConnection* conn, DBusMessage* msg);
-
-int ttsd_dbus_server_setting_get_speed(DBusConnection* conn, DBusMessage* msg);
-
-int ttsd_dbus_server_setting_set_speed(DBusConnection* conn, DBusMessage* msg);
-
-int ttsd_dbus_server_setting_get_engine_setting(DBusConnection* conn, DBusMessage* msg);
-
-int ttsd_dbus_server_setting_set_engine_setting(DBusConnection* conn, DBusMessage* msg);
-
 
 #ifdef __cplusplus
 }
index 0301d64..9f0312e 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*  Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd All Rights Reserved 
+*  Copyright (c) 2011-2014 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
@@ -15,6 +15,7 @@
 #include <dlfcn.h>
 #include <dirent.h>
 
+#include "tts_defs.h"
 #include "ttsd_main.h"
 #include "ttsd_engine_agent.h"
 #include "ttsd_config.h"
@@ -30,7 +31,7 @@ typedef struct {
        char*   engine_name; 
        char*   engine_path;
 
-       /* info for using engine load*/
+       /* info for using engine load */
        bool    is_set;
        bool    is_loaded;              
        bool    need_network;
@@ -40,13 +41,14 @@ typedef struct {
        char*   default_lang;
        int     default_vctype;
        int     default_speed;
+       int     default_pitch;
 
        ttspe_funcs_s*  pefuncs;
        ttspd_funcs_s*  pdfuncs;
 
        int (*ttsp_load_engine)(const ttspd_funcs_s* pdfuncs, ttspe_funcs_s* pefuncs);
        int (*ttsp_unload_engine)();
-} ttsengine_s;
+}ttsengine_s;
 
 typedef struct {
        char*   engine_uuid;
@@ -54,18 +56,31 @@ typedef struct {
        char*   engine_name;
        char*   setting_ug_path;
        bool    use_network;
-} ttsengine_info_s;
+}ttsengine_info_s;
+
+typedef struct 
+{
+       bool    is_default;
+       bool    is_loaded;
+       int     client_ref_count;
+
+       char*   lang;
+       int     type;
+}ttsvoice_s;
 
 
 /** Init flag */
 static bool g_agent_init;
 
 /** TTS engine list */
-static GList *g_engine_list;           
+static GList *g_engine_list;
 
 /** Current engine information */
 static ttsengine_s g_cur_engine;
 
+/** Current voice information */
+static GSList* g_cur_voices;
+
 /** Result callback function */
 static synth_result_callback g_result_cb;
 
@@ -83,10 +98,11 @@ int __internal_update_engine_list();
 int __internal_get_engine_info(const char* filepath, ttsengine_info_s** info);
 
 /** Callback function for result */
-bool __result_cb(ttsp_result_event_e event, const void* data, unsigned int data_size, void *user_data);
+bool __result_cb(ttsp_result_event_e event, const void* data, unsigned int data_size, 
+                ttsp_audio_type_e audio_type, int rate, void *user_data);
 
 /** Callback function for voice list */
-bool __supported_voice_cb(const char* language, ttsp_voice_type_e type, void* user_data);
+bool __supported_voice_cb(const char* language, int type, void* user_data);
 
 /** Free voice list */
 void __free_voice_list(GList* voice_list);
@@ -99,6 +115,27 @@ void __engine_info_cb(const char* engine_uuid, const char* engine_name, const ch
 bool __engine_setting_cb(const char* key, const char* value, void* user_data);
 
 
+/** Print list */
+int ttsd_print_enginelist();
+
+int ttsd_print_voicelist();
+
+static const char* __ttsd_get_engine_error_code(ttsp_error_e err)
+{
+       switch(err) {
+       case TTSP_ERROR_NONE:                   return "TTSP_ERROR_NONE";
+       case TTSP_ERROR_OUT_OF_MEMORY:          return "TTSP_ERROR_OUT_OF_MEMORY";
+       case TTSP_ERROR_IO_ERROR:               return "TTSP_ERROR_IO_ERROR";
+       case TTSP_ERROR_INVALID_PARAMETER:      return "TTSP_ERROR_INVALID_PARAMETER";
+       case TTSP_ERROR_OUT_OF_NETWORK:         return "TTSP_ERROR_OUT_OF_NETWORK";
+       case TTSP_ERROR_INVALID_STATE:          return "TTSP_ERROR_INVALID_STATE";
+       case TTSP_ERROR_INVALID_VOICE:          return "TTSP_ERROR_INVALID_VOICE";
+       case TTSP_ERROR_OPERATION_FAILED:       return "TTSP_ERROR_OPERATION_FAILED";
+       default:
+               return "Invalid error code";
+       }
+}
+
 int ttsd_engine_agent_init(synth_result_callback result_cb)
 {
        /* initialize static data */
@@ -115,22 +152,26 @@ int ttsd_engine_agent_init(synth_result_callback result_cb)
 
        g_cur_engine.is_set = false;
        g_cur_engine.handle = NULL;
-       g_cur_engine.pefuncs = (ttspe_funcs_s*)g_malloc0( sizeof(ttspe_funcs_s) );
-       g_cur_engine.pdfuncs = (ttspd_funcs_s*)g_malloc0( sizeof(ttspd_funcs_s) );
+       g_cur_engine.pefuncs = (ttspe_funcs_s*)calloc(1, sizeof(ttspe_funcs_s));
+       g_cur_engine.pdfuncs = (ttspd_funcs_s*)calloc(1, sizeof(ttspd_funcs_s));
 
        g_agent_init = true;
 
        if (0 != ttsd_config_get_default_voice(&(g_cur_engine.default_lang), &(g_cur_engine.default_vctype))) {
                SLOG(LOG_WARN, get_tag(), "[Server WARNING] There is No default voice in config"); 
                /* Set default voice */
-               g_cur_engine.default_lang = strdup("en_US");
+               g_cur_engine.default_lang = strdup(TTS_BASE_LANGUAGE);
                g_cur_engine.default_vctype = TTSP_VOICE_TYPE_FEMALE;
        }
 
        if (0 != ttsd_config_get_default_speed(&(g_cur_engine.default_speed))) {
                SLOG(LOG_WARN, get_tag(), "[Server WARNING] There is No default speed in config"); 
-               ttsd_config_set_default_speed((int)TTSP_SPEED_NORMAL);
-               g_cur_engine.default_speed = TTSP_SPEED_NORMAL;
+               g_cur_engine.default_speed = TTS_SPEED_NORMAL;
+       }
+
+       if (0 != ttsd_config_get_default_pitch(&(g_cur_engine.default_pitch))) {
+               SLOG(LOG_WARN, get_tag(), "[Server WARNING] There is No default pitch in config"); 
+               g_cur_engine.default_pitch = TTS_PITCH_NORMAL;
        }
 
        SLOG(LOG_DEBUG, get_tag(), "[Engine Agent SUCCESS] Initialize Engine Agent");
@@ -150,7 +191,7 @@ int ttsd_engine_agent_release()
 
        /* release engine list */
        GList *iter = NULL;
-       ttsengine_s *data = NULL;
+       ttsengine_info_s *data = NULL;
 
        if (g_list_length(g_engine_list) > 0) {
                /* Get a first item */
@@ -159,23 +200,29 @@ int ttsd_engine_agent_release()
                        /* Get data from item */
                        data = iter->data;
                        iter = g_list_remove(iter, data);
+
+                       if (NULL != data) {
+                               if (NULL != data->engine_uuid)          free(data->engine_uuid);
+                               if (NULL != data->engine_name)          free(data->engine_name);
+                               if (NULL != data->setting_ug_path)      free(data->setting_ug_path);
+                               if (NULL != data->engine_path)          free(data->engine_path);
+                               free(data);
+                       }
                }
        }
        g_list_free(iter);
+
        /* release current engine data */
-       if (g_cur_engine.pefuncs != NULL)
-               g_free(g_cur_engine.pefuncs);
-       
-       if (g_cur_engine.pdfuncs != NULL)
-               g_free(g_cur_engine.pdfuncs);
+       if (g_cur_engine.engine_uuid != NULL)   free(g_cur_engine.engine_uuid);
+       if (g_cur_engine.engine_name != NULL)   free(g_cur_engine.engine_name);
+       if (g_cur_engine.engine_path != NULL)   free(g_cur_engine.engine_path);
 
+       if (g_cur_engine.pefuncs != NULL)       free(g_cur_engine.pefuncs);
+       if (g_cur_engine.pdfuncs != NULL)       free(g_cur_engine.pdfuncs);
+       if (g_cur_engine.default_lang != NULL)  free(g_cur_engine.default_lang);
        g_result_cb = NULL;
        g_agent_init = false;
 
-       if (g_cur_engine.default_lang != NULL) 
-               g_free(g_cur_engine.default_lang);
-
-
        SLOG(LOG_DEBUG, get_tag(), "[Engine Agent SUCCESS] Release Engine Agent");
 
        return 0;
@@ -206,35 +253,32 @@ int ttsd_engine_agent_initialize_current_engine()
 
                if (g_list_length(g_engine_list) > 0) {
                        iter = g_list_first(g_engine_list);
-                       char* default_engine = "27F277E9-BBC4-4dca-B553-D9884A3CDAA0";
-
-                       while (NULL != iter) {
-                               data = iter->data;
+                       data = iter->data;
 
-                               if (0 == strncmp(data->engine_uuid, default_engine, strlen(default_engine))) {
-                                       /* current data is default engine */
-                                       break;
+                       if (NULL != data) {
+                               if (NULL != data->engine_uuid) {
+                                       cur_engine_uuid = strdup(data->engine_uuid);
+                                       ttsd_config_set_default_engine(cur_engine_uuid);
+                               } else {
+                                       SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Data of current engine is corrupt");
+                                       return TTSD_ERROR_OPERATION_FAILED;
                                }
-
-                               iter = g_list_next(iter);
                        }
                } else {
                        SLOG(LOG_WARN, get_tag(), "[Engine Agent WARNING] Fail to set a engine of engine list");
                        return TTSD_ERROR_OPERATION_FAILED;     
                }
-
-               if (NULL != data->engine_uuid) {
-                       cur_engine_uuid = strdup(data->engine_uuid); 
-               } else {
-                       SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Data of current engine is corrupt");
-                       return TTSD_ERROR_OPERATION_FAILED;
-               }
                
                is_get_engineid_from_config = false;
        } else {
                is_get_engineid_from_config = true;
        }
 
+       if (NULL == cur_engine_uuid) {
+                       SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Current engine id is NULL");
+                       return TTSD_ERROR_OPERATION_FAILED;
+       }
+
        /* check whether cur engine uuid is valid or not. */
        if (0 != __internal_check_engine_id(cur_engine_uuid)) {
                SLOG(LOG_WARN, get_tag(), "[Engine Agent WARNING] It is not valid engine id from config");
@@ -245,38 +289,38 @@ int ttsd_engine_agent_initialize_current_engine()
                        iter = g_list_first(g_engine_list);
                else {
                        SLOG(LOG_WARN, get_tag(), "[Engine Agent ERROR] NO TTS Engine !!");
+                       if (NULL != cur_engine_uuid)    free(cur_engine_uuid);
                        return TTSD_ERROR_OPERATION_FAILED;     
                }
 
-               if (cur_engine_uuid != NULL)    
-                       g_free(cur_engine_uuid);
-
+               if (cur_engine_uuid != NULL)    free(cur_engine_uuid);
                ttsengine_info_s *data = NULL;
                data = iter->data;
 
-               cur_engine_uuid = g_strdup(data->engine_uuid);
+               cur_engine_uuid = strdup(data->engine_uuid);
 
                is_get_engineid_from_config = false;
        }
 
        if (NULL != cur_engine_uuid) 
-               SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] Current Engine Id : %s", cur_engine_uuid);
+               SECURE_SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] Current Engine Id : %s", cur_engine_uuid);
        else 
                return TTSD_ERROR_OPERATION_FAILED;
 
        /* set current engine */
        if (0 != __internal_set_current_engine(cur_engine_uuid)) {
                SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail to set current engine ");
+               if (NULL != cur_engine_uuid)    free(cur_engine_uuid);
                return TTSD_ERROR_OPERATION_FAILED;
        } 
 
        if (false == is_get_engineid_from_config) {
-               if (0 != ttsd_config_set_default_engine(cur_engine_uuid))
-                       SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail to set id to config"); 
+               if (0 != ttsd_config_set_default_engine(cur_engine_uuid)) {
+                       SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail to set id to config");
+               }
        }
 
-       if (NULL != cur_engine_uuid)    
-               g_free(cur_engine_uuid);
+       if (NULL != cur_engine_uuid)    free(cur_engine_uuid);
 
        SLOG(LOG_DEBUG, get_tag(), "[Engine Agent SUCCESS] Set current engine"); 
 
@@ -309,10 +353,17 @@ void __engine_info_cb(const char* engine_uuid, const char* engine_name, const ch
 {
        ttsengine_info_s* temp = (ttsengine_info_s*)user_data; 
 
-       temp->engine_uuid = g_strdup(engine_uuid);
-       temp->engine_name = g_strdup(engine_name);
-       temp->setting_ug_path = g_strdup(setting_ug_name);
+       if (NULL != engine_uuid)
+               temp->engine_uuid = strdup(engine_uuid);
+       
+       if (NULL != engine_name)
+               temp->engine_name = strdup(engine_name);
+
+       if (NULL != setting_ug_name)
+               temp->setting_ug_path = strdup(setting_ug_name);
+
        temp->use_network = use_network;
+       return;
 }
 
 int __internal_get_engine_info(const char* filepath, ttsengine_info_s** info)
@@ -320,24 +371,24 @@ int __internal_get_engine_info(const char* filepath, ttsengine_info_s** info)
        char *error;
        void* handle;
 
-       handle = dlopen (filepath, RTLD_LAZY );
+       handle = dlopen(filepath, RTLD_LAZY);
 
        if (!handle) {
-               SLOG(LOG_WARN, get_tag(), "[Engine Agent] Invalid engine : %s", filepath); 
+               SECURE_SLOG(LOG_WARN, get_tag(), "[Engine Agent] Invalid engine : %s", filepath); 
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
        /* link engine to daemon */
        dlsym(handle, "ttsp_load_engine");
        if ((error = dlerror()) != NULL) {
-               SLOG(LOG_WARN, get_tag(), "[Engine Agent] Invalid engine. Fail to open ttsp_load_engine : %s", filepath);
+               SECURE_SLOG(LOG_WARN, get_tag(), "[Engine Agent] Fail to open ttsp_load_engine : path(%s) message(%s)", filepath, error);
                dlclose(handle);
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
        dlsym(handle, "ttsp_unload_engine");
        if ((error = dlerror()) != NULL) {
-               SLOG(LOG_WARN, get_tag(), "[Engine Agent] Invalid engine. Fail to open ttsp_unload_engine : %s", filepath);
+               SECURE_SLOG(LOG_WARN, get_tag(), "[Engine Agent] Fail to open ttsp_unload_engine : path(%s) message(%s)", filepath, error);
                dlclose(handle);
                return TTSD_ERROR_OPERATION_FAILED;
        }
@@ -346,41 +397,47 @@ int __internal_get_engine_info(const char* filepath, ttsengine_info_s** info)
 
        get_engine_info = (int (*)(ttsp_engine_info_cb, void*))dlsym(handle, "ttsp_get_engine_info");
        if (NULL != (error = dlerror()) || NULL == get_engine_info) {
-               SLOG(LOG_WARN, get_tag(), "[Engine Agent] ttsp_get_engine_info() link error");
+               SLOG(LOG_WARN, get_tag(), "[Engine Agent] Fail to open ttsp_get_engine_info() :path(%s) message(%s)", filepath, error);
                dlclose(handle);
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
        ttsengine_info_s* temp;
-       temp = (ttsengine_info_s*)g_malloc0(sizeof(ttsengine_info_s));
+       temp = (ttsengine_info_s*)calloc(1, sizeof(ttsengine_info_s));
+       if (NULL == temp) {
+               SLOG(LOG_WARN, get_tag(), "[Engine Agent] Fail to alloc memory");
+               dlclose(handle);
+               return TTSD_ERROR_OUT_OF_MEMORY;
+       }
 
        /* get engine info */
        if (0 != get_engine_info(&__engine_info_cb, (void*)temp)) {
                SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail to get engine info");
                dlclose(handle);
-               g_free(temp);
+               free(temp);
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
        /* close engine */
        dlclose(handle);
 
-       if (TTSD_MODE_SCREEN_READER == ttsd_get_mode()) {
-               if (true == temp->use_network) {
-                       free(temp);
-                       SLOG(LOG_ERROR, get_tag(), "[Engine Agent WARNING] %s is invalid because of network based engine.", temp->engine_name);
-                       return TTSD_ERROR_OPERATION_FAILED;
-               }
+       if (TTSD_MODE_SCREEN_READER == ttsd_get_mode() && true == temp->use_network) {
+               SECURE_SLOG(LOG_ERROR, get_tag(), "[Engine Agent WARNING] %s is invalid because of network based", temp->engine_name);
+               if (NULL != temp->engine_uuid)          free(temp->engine_uuid);
+               if (NULL != temp->engine_name)          free(temp->engine_name);
+               if (NULL != temp->setting_ug_path)      free(temp->setting_ug_path);
+               free(temp);
+               return TTSD_ERROR_OPERATION_FAILED;
        }
 
-       temp->engine_path = g_strdup(filepath);
+       temp->engine_path = strdup(filepath);
        
        SLOG(LOG_DEBUG, get_tag(), "----- Valid engine");
-       SLOG(LOG_DEBUG, get_tag(), "Engine uuid : %s", temp->engine_uuid);
-       SLOG(LOG_DEBUG, get_tag(), "Engine name : %s", temp->engine_name);
-       SLOG(LOG_DEBUG, get_tag(), "Setting ug path : %s", temp->setting_ug_path);
-       SLOG(LOG_DEBUG, get_tag(), "Engine path : %s", temp->engine_path);
-       SLOG(LOG_DEBUG, get_tag(), "Use network : %s", temp->use_network ? "true":"false");
+       SECURE_SLOG(LOG_DEBUG, get_tag(), "Engine uuid : %s", temp->engine_uuid);
+       SECURE_SLOG(LOG_DEBUG, get_tag(), "Engine name : %s", temp->engine_name);
+       SECURE_SLOG(LOG_DEBUG, get_tag(), "Setting path : %s", temp->setting_ug_path);
+       SECURE_SLOG(LOG_DEBUG, get_tag(), "Engine path : %s", temp->engine_path);
+       SECURE_SLOG(LOG_DEBUG, get_tag(), "Use network : %s", temp->use_network ? "true":"false");
        SLOG(LOG_DEBUG, get_tag(), "-----");
        SLOG(LOG_DEBUG, get_tag(), "  ");
 
@@ -401,9 +458,7 @@ int __internal_update_engine_list()
                while (NULL != iter) {
                        data = iter->data;
 
-                       if (data != NULL)
-                               g_free(data);
-
+                       if (data != NULL)       free(data);
                        g_engine_list = g_list_remove_link(g_engine_list, iter);
                        iter = g_list_first(g_engine_list);
                }
@@ -412,7 +467,7 @@ int __internal_update_engine_list()
        /* get file name from engine directory and get engine information from each filename */
        DIR *dp;
        struct dirent *dirp;
-       dp = opendir(ENGINE_DIRECTORY_DEFAULT);
+       dp = opendir(TTS_DEFAULT_ENGINE);
 
        if (dp != NULL) {
                while ((dirp = readdir(dp)) != NULL) {
@@ -420,13 +475,11 @@ int __internal_update_engine_list()
                        char* filepath = NULL;
                        int file_size;
 
-                       file_size = strlen(ENGINE_DIRECTORY_DEFAULT) + strlen(dirp->d_name) + 5;
-                       filepath = (char*)g_malloc0( sizeof(char) * file_size);
+                       file_size = strlen(TTS_DEFAULT_ENGINE) + strlen(dirp->d_name) + 5;
+                       filepath = (char*)calloc(file_size, sizeof(char));
 
                        if (NULL != filepath) { 
-                               strncpy(filepath, ENGINE_DIRECTORY_DEFAULT, strlen(ENGINE_DIRECTORY_DEFAULT) );
-                               strncat(filepath, "/", strlen("/") );
-                               strncat(filepath, dirp->d_name, strlen(dirp->d_name) );
+                               snprintf(filepath, file_size, "%s/%s", TTS_DEFAULT_ENGINE, dirp->d_name);
                        } else {
                                SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not enough memory!!" );
                                continue;       
@@ -438,14 +491,13 @@ int __internal_update_engine_list()
                                g_engine_list = g_list_append(g_engine_list, info);
                        }
 
-                       if (NULL != filepath)
-                               g_free(filepath);
+                       if (NULL != filepath)   free(filepath);
                }
 
                closedir(dp);
        }
 
-       dp = opendir(ENGINE_DIRECTORY_DOWNLOAD);
+       dp = opendir(TTS_DOWNLOAD_ENGINE);
 
        if (dp != NULL) {
                while ((dirp = readdir(dp)) != NULL) {
@@ -453,13 +505,11 @@ int __internal_update_engine_list()
                        char* filepath = NULL;
                        int file_size;
 
-                       file_size = strlen(ENGINE_DIRECTORY_DOWNLOAD) + strlen(dirp->d_name) + 5;
-                       filepath = (char*)g_malloc0( sizeof(char) * file_size);
+                       file_size = strlen(TTS_DOWNLOAD_ENGINE) + strlen(dirp->d_name) + 5;
+                       filepath = (char*)calloc(file_size, sizeof(char));
 
-                       if (NULL != filepath) { 
-                               strcpy(filepath, ENGINE_DIRECTORY_DOWNLOAD);
-                               strcat(filepath, "/");
-                               strcat(filepath, dirp->d_name);
+                       if (NULL != filepath) {
+                               snprintf(filepath, file_size, "%s/%s", TTS_DOWNLOAD_ENGINE, dirp->d_name);
                        } else {
                                SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not enough memory!!" );
                                continue;       
@@ -471,8 +521,7 @@ int __internal_update_engine_list()
                                g_engine_list = g_list_append(g_engine_list, info);
                        }
 
-                       if (NULL != filepath)
-                               g_free(filepath);
+                       if (NULL != filepath)   free(filepath);
                }
 
                closedir(dp);
@@ -483,10 +532,9 @@ int __internal_update_engine_list()
                return TTSD_ERROR_OPERATION_FAILED;     
        }
 
-#ifdef ENGINE_AGENT_DEBUG      
+#ifdef ENGINE_AGENT_DEBUG
        ttsd_print_enginelist();
 #endif
-
        return 0;
 }
 
@@ -515,7 +563,7 @@ int __internal_set_current_engine(const char* engine_uuid)
 
        /* If current engine does not exist, return error */
        if (false == flag) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] __internal_set_current_engine : Cannot find engine id");
+               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Cannot find engine id");
                return TTSD_ERROR_OPERATION_FAILED;
        } else {
                if (g_cur_engine.engine_uuid != NULL) {
@@ -528,18 +576,18 @@ int __internal_set_current_engine(const char* engine_uuid)
        }
 
        /* set data from g_engine_list */
-       if (g_cur_engine.engine_uuid != NULL)   g_free(g_cur_engine.engine_uuid);
-       if (g_cur_engine.engine_name != NULL)   g_free(g_cur_engine.engine_name);
-       if (g_cur_engine.engine_path != NULL)   g_free(g_cur_engine.engine_path);
+       if (g_cur_engine.engine_uuid != NULL)   free(g_cur_engine.engine_uuid);
+       if (g_cur_engine.engine_name != NULL)   free(g_cur_engine.engine_name);
+       if (g_cur_engine.engine_path != NULL)   free(g_cur_engine.engine_path);
 
        if (NULL == data->engine_uuid || NULL == data->engine_name || NULL == data->engine_path) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] __internal_set_current_engine : Engine data is NULL");
+               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Engine data is NULL");
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
-       g_cur_engine.engine_uuid = g_strdup(data->engine_uuid);
-       g_cur_engine.engine_name = g_strdup(data->engine_name);
-       g_cur_engine.engine_path = g_strdup(data->engine_path);
+       g_cur_engine.engine_uuid = strdup(data->engine_uuid);
+       g_cur_engine.engine_name = strdup(data->engine_name);
+       g_cur_engine.engine_path = strdup(data->engine_path);
 
        g_cur_engine.handle = NULL;
        g_cur_engine.is_loaded = false;
@@ -547,14 +595,58 @@ int __internal_set_current_engine(const char* engine_uuid)
        g_cur_engine.need_network = data->use_network;
 
        SLOG(LOG_DEBUG, get_tag(), "-----");
-       SLOG(LOG_DEBUG, get_tag(), "Current engine uuid : %s", g_cur_engine.engine_uuid);
-       SLOG(LOG_DEBUG, get_tag(), "Current engine name : %s", g_cur_engine.engine_name);
-       SLOG(LOG_DEBUG, get_tag(), "Current engine path : %s", g_cur_engine.engine_path);
+       SECURE_SLOG(LOG_DEBUG, get_tag(), "Current engine uuid : %s", g_cur_engine.engine_uuid);
+       SECURE_SLOG(LOG_DEBUG, get_tag(), "Current engine name : %s", g_cur_engine.engine_name);
+       SECURE_SLOG(LOG_DEBUG, get_tag(), "Current engine path : %s", g_cur_engine.engine_path);
        SLOG(LOG_DEBUG, get_tag(), "-----");
 
        return 0;
 }
 
+bool __set_voice_info_cb(const char* language, int type, void* user_data)
+{
+       if (NULL == language) {
+               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Input parameter is NULL in voice list callback!!!!");
+               return false;
+       }
+
+       ttsvoice_s* voice = calloc(1, sizeof(ttsvoice_s));
+       voice->lang = strdup(language);
+       voice->type = type;
+
+       voice->client_ref_count = 0;
+       voice->is_loaded = false;
+
+       if (0 == strcmp(g_cur_engine.default_lang, language) && g_cur_engine.default_vctype == type) {
+               voice->is_default = true;
+               voice->is_loaded = true;
+       } else {
+               voice->is_default = false;
+       }
+
+       g_cur_voices = g_slist_append(g_cur_voices, voice);
+
+       return true;
+}
+
+int __update_voice_list()
+{
+       /* Get voice list */
+       g_cur_voices = NULL;
+       int ret = 0;
+
+       ret = g_cur_engine.pefuncs->foreach_voices(__set_voice_info_cb, NULL);
+       if (0 != ret || 0 >= g_slist_length(g_cur_voices)) {
+               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail to get voice list : result(%d)", ret);
+               return -1;
+       }
+
+#ifdef ENGINE_AGENT_DEBUG
+       ttsd_print_voicelist();
+#endif
+       return 0;
+}
+
 int ttsd_engine_agent_load_current_engine()
 {
        if (false == g_agent_init) {
@@ -563,36 +655,34 @@ int ttsd_engine_agent_load_current_engine()
        }
 
        if (false == g_cur_engine.is_set) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] ttsd_engine_agent_load_current_engine : No Current Engine ");
+               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] No Current Engine ");
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
        /* check whether current engine is loaded or not */
        if (true == g_cur_engine.is_loaded ) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent] ttsd_engine_agent_load_current_engine : Engine has already been loaded " );
+               SLOG(LOG_ERROR, get_tag(), "[Engine Agent] Engine has already been loaded " );
                return 0;
        }
 
-       SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] current engine path : %s", g_cur_engine.engine_path);
-
        /* open engine */
        char *error = NULL;
        g_cur_engine.handle = dlopen(g_cur_engine.engine_path, RTLD_LAZY); /* RTLD_LAZY RTLD_NOW*/
 
        if (NULL != (error = dlerror()) || NULL == g_cur_engine.handle) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail to get current engine handle : dlopen error ($s)", error);
+               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Fail to get current engine handle : %s", error);
                return -2;
        }
 
        g_cur_engine.ttsp_unload_engine = (int (*)())dlsym(g_cur_engine.handle, "ttsp_unload_engine");
        if (NULL != (error = dlerror()) || NULL == g_cur_engine.ttsp_unload_engine) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail to link daemon to ttsp_unload_engine() of current engine : (%s)", error);
+               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Fail to link daemon to ttsp_unload_engine() : %s", error);
                return -3;
        }
 
        g_cur_engine.ttsp_load_engine = (int (*)(const ttspd_funcs_s* , ttspe_funcs_s*) )dlsym(g_cur_engine.handle, "ttsp_load_engine");
        if (NULL != (error = dlerror()) || NULL == g_cur_engine.ttsp_load_engine) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail to link daemon to ttsp_load_engine() of current engine : %s", error);
+               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Fail to link daemon to ttsp_load_engine() : %s", error);
                return -3;
        }
 
@@ -603,54 +693,68 @@ int ttsd_engine_agent_load_current_engine()
        int ret = 0;
        ret = g_cur_engine.ttsp_load_engine(g_cur_engine.pdfuncs, g_cur_engine.pefuncs); 
        if (0 != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail to load engine - %s : result(%d)", g_cur_engine.engine_path, ret);
+               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail to load engine - %s : result(%s)", 
+                       g_cur_engine.engine_path, __ttsd_get_engine_error_code(ret));
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
-       SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] engine info : version(%d), size(%d)",g_cur_engine.pefuncs->version, g_cur_engine.pefuncs->size );
-
        /* engine error check */
        if (g_cur_engine.pefuncs->size != sizeof(ttspe_funcs_s)) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] ttsd_engine_agent_load_current_engine : current engine is not valid");
-               return TTSD_ERROR_OPERATION_FAILED;
+               SLOG(LOG_WARN, get_tag(), "[Engine Agent WARNING] The size of engine function is not valid");
        }
 
-       /* initalize engine */
-       if (NULL == g_cur_engine.pefuncs->initialize) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] init function of engine is NULL!!");
-               return TTSD_ERROR_OPERATION_FAILED;
+       if (NULL == g_cur_engine.pefuncs->initialize ||
+               NULL == g_cur_engine.pefuncs->deinitialize ||
+               NULL == g_cur_engine.pefuncs->foreach_voices ||
+               NULL == g_cur_engine.pefuncs->is_valid_voice ||
+               NULL == g_cur_engine.pefuncs->start_synth ||
+               NULL == g_cur_engine.pefuncs->cancel_synth) {
+               SLOG(LOG_ERROR, get_tag(), "[Engine ERROR] The engine functions are NOT valid");
+               return TTSD_ERROR_OPERATION_FAILED; 
        }
 
        ret = g_cur_engine.pefuncs->initialize(__result_cb);
        if (0 != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail to initialize current engine : result(%d)", ret);
+               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Fail to initialize current engine : %s", __ttsd_get_engine_error_code(ret));
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
-       /* select default voice */
-       bool set_voice = false;
-       if (NULL != g_cur_engine.default_lang) {
-               if (NULL == g_cur_engine.pefuncs->is_valid_voice) {
-                       SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] is_valid_voice() of engine is NULL!!");
-                       return TTSD_ERROR_OPERATION_FAILED;
-               }
+       /* Get voice info of current engine */
+       ret = __update_voice_list();
+       if (0 != ret) {
+               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Fail to set voice info : result(%d)", ret);
+               return TTSD_ERROR_OPERATION_FAILED;
+       }
 
+       /* Select default voice */
+       if (NULL != g_cur_engine.default_lang) {
                if (true == g_cur_engine.pefuncs->is_valid_voice(g_cur_engine.default_lang, g_cur_engine.default_vctype)) {
-                       set_voice = true;
                        SLOG(LOG_DEBUG, get_tag(), "[Engine Agent SUCCESS] Set origin default voice to current engine : lang(%s), type(%d)", 
                                g_cur_engine.default_lang,  g_cur_engine.default_vctype);
                } else {
                        SLOG(LOG_WARN, get_tag(), "[Engine Agent WARNING] Fail set origin default voice : lang(%s), type(%d)",
                                g_cur_engine.default_lang, g_cur_engine.default_vctype);
+
+                       return TTSD_ERROR_OPERATION_FAILED;
                }
        }
 
-       if (false == set_voice) {
-               if (NULL == g_cur_engine.pefuncs->foreach_voices) {
-                       SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] get_voice_list of engine is NULL!!");
+       /* load default voice */
+       if (NULL != g_cur_engine.pefuncs->load_voice) {
+               ret = g_cur_engine.pefuncs->load_voice(g_cur_engine.default_lang, g_cur_engine.default_vctype);
+               if (0 == ret) {
+                       SLOG(LOG_DEBUG, get_tag(), "[Engine Agent SUCCESS] Load default voice : lang(%s), type(%d)", 
+                               g_cur_engine.default_lang,  g_cur_engine.default_vctype);
+               } else {
+                       SLOG(LOG_WARN, get_tag(), "[Engine Agent ERROR] Fail to load default voice : lang(%s), type(%d) result(%s)",
+                               g_cur_engine.default_lang, g_cur_engine.default_vctype, __ttsd_get_engine_error_code(ret));
+
                        return TTSD_ERROR_OPERATION_FAILED;
                }
+       }
 
+#if 0
+       if (false == set_voice) {
                /* get language list */
                int ret;
                GList* voice_list = NULL;
@@ -687,7 +791,7 @@ int ttsd_engine_agent_load_current_engine()
 
                        ttsd_config_set_default_voice(voice->language, (int)voice->type);
                        
-                       g_cur_engine.default_lang = g_strdup(voice->language);
+                       g_cur_engine.default_lang = strdup(voice->language);
                        g_cur_engine.default_vctype = voice->type;
 
                        SLOG(LOG_DEBUG, get_tag(), "[Engine Agent SUCCESS] Select default voice : lang(%s), type(%d)", 
@@ -698,8 +802,8 @@ int ttsd_engine_agent_load_current_engine()
                        SLOG(LOG_ERROR, get_tag(), "[Engine ERROR] Fail to get language list : result(%d)", ret);
                        return TTSD_ERROR_OPERATION_FAILED;
                }
-       } 
+       }
+#endif
        g_cur_engine.is_loaded = true;
 
        return 0;
@@ -723,14 +827,10 @@ int ttsd_engine_agent_unload_current_engine()
        }
 
        /* shutdown engine */
-       if (NULL == g_cur_engine.pefuncs->deinitialize) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] The deinitialize() of engine is NULL!!");
-       } else {
-               int ret = 0;
-               ret = g_cur_engine.pefuncs->deinitialize();
-               if (0 != ret) {
-                       SLOG(LOG_ERROR, get_tag(), "[Engine Agent] Fail deinitialize() : result(%d)", ret);
-               }
+       int ret = 0;
+       ret = g_cur_engine.pefuncs->deinitialize();
+       if (0 != ret) {
+               SLOG(LOG_ERROR, get_tag(), "[Engine Agent] Fail deinitialize() : %s", __ttsd_get_engine_error_code(ret));
        }
 
        /* unload engine */
@@ -742,6 +842,23 @@ int ttsd_engine_agent_unload_current_engine()
        g_cur_engine.handle = NULL;
        g_cur_engine.is_loaded = false;
 
+       GSList *iter = NULL;
+       ttsvoice_s* data = NULL;
+
+       iter = g_slist_nth(g_cur_voices, 0);
+       while (NULL != iter) {
+               data = iter->data;
+
+               if (NULL != data) {
+                       if (NULL != data->lang)         free(data->lang);
+                       g_cur_voices = g_slist_remove(g_cur_voices, data);
+                       free(data);
+                       data = NULL;
+               }
+
+               iter = g_slist_nth(g_cur_voices, 0);
+       }
+
        return 0;
 }
 
@@ -760,13 +877,18 @@ bool ttsd_engine_agent_need_network()
        return g_cur_engine.need_network;
 }
 
-bool ttsd_engine_select_valid_voice(const char* lang, int type, char** out_lang, ttsp_voice_type_e* out_type)
+bool ttsd_engine_select_valid_voice(const char* lang, int type, char** out_lang, int* out_type)
 {
        if (NULL == lang || NULL == out_lang || NULL == out_type) {
                return false;
        }
 
-       SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] Select voice : input lang(%s) , input type(%d), default lang(%s), default type(%d)", 
+       if (false == g_cur_engine.is_loaded) {
+               SLOG(LOG_WARN, get_tag(), "[Engine Agent WARNING] Not loaded engine");
+               return false;
+       }
+
+       SECURE_SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] Select voice : input lang(%s), input type(%d), default lang(%s), default type(%d)", 
                lang, type, g_cur_engine.default_lang, g_cur_engine.default_vctype);
 
        
@@ -775,14 +897,9 @@ bool ttsd_engine_select_valid_voice(const char* lang, int type, char** out_lang,
                *out_lang = strdup(g_cur_engine.default_lang);
                *out_type = g_cur_engine.default_vctype;
                return true;
-       } 
+       }
        
        /* Get voice list */
-       if (NULL == g_cur_engine.pefuncs->foreach_voices) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] foreach_voices of engine is NULL!!");
-               return TTSD_ERROR_OPERATION_FAILED;
-       }
-
        GList* voice_list = NULL;
        int ret = 0;
 
@@ -877,7 +994,7 @@ bool ttsd_engine_select_valid_voice(const char* lang, int type, char** out_lang,
        }
 
        if (true == result) {
-               SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] Selected voice : lang(%s), type(%d)", *out_lang, *out_type);
+               SECURE_SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] Selected voice : lang(%s), type(%d)", *out_lang, *out_type);
        }
 
        __free_voice_list(voice_list);
@@ -905,55 +1022,74 @@ bool ttsd_engine_agent_is_same_engine(const char* engine_id)
        return false;
 }
 
-int ttsd_engine_agent_set_default_voice(const char* language, ttsp_voice_type_e vctype)
+int ttsd_engine_agent_set_default_engine(const char* engine_id)
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" );
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
-       if (false == g_cur_engine.is_loaded) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not loaded engine");
-               return TTSD_ERROR_OPERATION_FAILED;
+       /* compare current engine and new engine.*/
+       if (0 == strncmp(g_cur_engine.engine_uuid, engine_id, strlen(engine_id))) {
+               SECURE_SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] new engine(%s) is the same as current engine", engine_id);
+               return 0;
        }
 
-       if (NULL == g_cur_engine.pefuncs->is_valid_voice) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] The function of engine is NULL!!");
-               return TTSD_ERROR_OPERATION_FAILED;
+       bool is_engine_loaded = false; 
+       char* tmp_uuid = NULL;
+       tmp_uuid = strdup(g_cur_engine.engine_uuid);
+       if (NULL == tmp_uuid) {
+                       SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Current engine id is NULL");
+                       return TTSD_ERROR_OPERATION_FAILED;
        }
 
-       int ret = -1;
-       if(false == g_cur_engine.pefuncs->is_valid_voice(language, vctype)) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Voice is NOT valid !!");
-               return TTSD_ERROR_INVALID_VOICE;
-       }
+       is_engine_loaded = g_cur_engine.is_loaded;
 
-       if (NULL != g_cur_engine.default_lang)
-               free(g_cur_engine.default_lang);
+       if (true == is_engine_loaded) {
+               /* unload engine */
+               if (0 != ttsd_engine_agent_unload_current_engine()) {
+                       SLOG(LOG_ERROR, get_tag(), "[Engine Agent Error] fail to unload current engine");
+               }
+       }
 
-       g_cur_engine.default_lang = strdup(language);
-       g_cur_engine.default_vctype = vctype;
+       /* change current engine */
+       if (0 != __internal_set_current_engine(engine_id)) {
+               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Fail to set current engine. Recovery origin engine");
 
-       ret = ttsd_config_set_default_voice(language, (int)vctype);
-       if (0 == ret) {
-               SLOG(LOG_DEBUG, get_tag(), "[Engine Agent SUCCESS] Set default voice : lang(%s), type(%d)",
-                       g_cur_engine.default_lang, g_cur_engine.default_vctype); 
-       } else {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail to write default voice to config (%d)", ret); 
+               /* roll back to old current engine. */
+               __internal_set_current_engine(tmp_uuid);
+               if (true == is_engine_loaded) {
+                       ttsd_engine_agent_load_current_engine();
+               }
+               
+               if (tmp_uuid != NULL)   free(tmp_uuid);
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
+       if (true == is_engine_loaded) {
+               /* load engine */
+               if (0 != ttsd_engine_agent_load_current_engine()) {
+                       SLOG(LOG_ERROR, get_tag(), "[Engine Agent Error] Fail to load new engine. Recovery origin engine");
+                       
+                       /* roll back to old current engine. */
+                       __internal_set_current_engine(tmp_uuid);
+                       if (true == is_engine_loaded) {
+                               ttsd_engine_agent_load_current_engine();
+                       }
+
+                       if (tmp_uuid != NULL)   free(tmp_uuid);
+                       return TTSD_ERROR_OPERATION_FAILED;
+               } else {
+                       SECURE_SLOG(LOG_DEBUG, get_tag(), "[Engine Agent SUCCESS] load new engine : %s", engine_id);
+               }
+       }
+
+       if (tmp_uuid != NULL)   free(tmp_uuid);
        return 0;
 }
 
-/******************************************************************************************
-* TTS Engine Interfaces for client
-*******************************************************************************************/
-
-int ttsd_engine_start_synthesis(const char* lang, const ttsp_voice_type_e vctype, const char* text, const int speed, void* user_param)
+int ttsd_engine_agent_set_default_voice(const char* language, int vctype)
 {
-       SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] start ttsd_engine_start_synthesis()");
-
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" );
                return TTSD_ERROR_OPERATION_FAILED;
@@ -964,78 +1100,119 @@ int ttsd_engine_start_synthesis(const char* lang, const ttsp_voice_type_e vctype
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
-       /* select voice for default */
-       char* temp_lang = NULL;
-       ttsp_voice_type_e temp_type;
-       if (true != ttsd_engine_select_valid_voice(lang, vctype, &temp_lang, &temp_type)) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Fail to select default voice");
+       if (false == g_cur_engine.pefuncs->is_valid_voice(language, vctype)) {
+               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Voice is NOT valid !!");
                return TTSD_ERROR_INVALID_VOICE;
-       } else {
-               SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] Start synthesis : language(%s), type(%d), speed(%d), text(%s)", 
-                       temp_lang, temp_type, speed, text);
        }
 
-       if (NULL == g_cur_engine.pefuncs->start_synth) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] start_synth() of engine is NULL!!");
-               return TTSD_ERROR_OPERATION_FAILED;
-       }
+       int ret = -1;
+       GSList *iter = NULL;
+       ttsvoice_s* data = NULL;
 
-       ttsp_speed_e temp_speed;
+       /* Update new default voice info */
+       iter = g_slist_nth(g_cur_voices, 0);
+       while (NULL != iter) {
+               /* Get handle data from list */
+               data = iter->data;
 
-       if (0 == speed) {
-               temp_speed = g_cur_engine.default_speed;
-       } else {
-               temp_speed = speed;
+               if (NULL == data) {
+                       SECURE_SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Voice data is NULL");
+                       return TTSD_ERROR_OPERATION_FAILED;
+               }
+
+               if (0 == strcmp(data->lang, language) && data->type == vctype) {
+                       data->is_default = true;
+                       if (0 == data->client_ref_count) {
+                               /* load voice */
+                               if (NULL != g_cur_engine.pefuncs->load_voice) {
+                                       ret = g_cur_engine.pefuncs->load_voice(data->lang, data->type);
+                                       if (0 == ret) {
+                                               SECURE_SLOG(LOG_DEBUG, get_tag(), "[Engine Agent SUCCESS] load voice : lang(%s), type(%d)", 
+                                                       data->lang, data->type);
+                                               data->is_loaded = true;
+                                       } else {
+                                               SECURE_SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Fail to load voice : lang(%s), type(%d), result(%s)",
+                                                       data->lang, data->type, __ttsd_get_engine_error_code(ret));
+                                       }
+                               } else {
+                                       SECURE_SLOG(LOG_DEBUG, get_tag(), "[Engine Agent ERROR] Load voice of engine function is NULL");
+                               }
+                       }
+                       break;
+               }
+               
+               /*Get next item*/
+               iter = g_slist_next(iter);
        }
 
-       /* synthesize text */
-       int ret = 0;
-       ret = g_cur_engine.pefuncs->start_synth(temp_lang, temp_type, text, temp_speed, user_param);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] ***************************************", ret);
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] * synthesize error : result(%6d) *", ret);
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] ***************************************", ret);
-               return TTSD_ERROR_OPERATION_FAILED;
+#ifdef ENGINE_AGENT_DEBUG
+       ttsd_print_voicelist();
+#endif
+
+       /* Update old default voice info */
+       iter = g_slist_nth(g_cur_voices, 0);
+       while (NULL != iter) {
+               /*Get handle data from list*/
+               data = iter->data;
+
+               if (NULL == data) {
+                       SECURE_SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Voice data is NULL");
+                       return TTSD_ERROR_OPERATION_FAILED;
+               }
+
+               if (0 == strcmp(data->lang, g_cur_engine.default_lang) && data->type == g_cur_engine.default_vctype) {
+                       data->is_default = false;
+                       if (0 == data->client_ref_count) {
+                               /* Unload voice */
+                               if (NULL != g_cur_engine.pefuncs->unload_voice) {
+                                       ret = g_cur_engine.pefuncs->unload_voice(data->lang, data->type);
+                                       if (0 == ret) {
+                                               SECURE_SLOG(LOG_DEBUG, get_tag(), "[Engine Agent SUCCESS] Unload voice : lang(%s), type(%d)", 
+                                                       data->lang, data->type);
+                                               data->is_loaded = false;
+                                       } else {
+                                               SECURE_SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Fail to unload voice : lang(%s), type(%d), result(%s)",
+                                                       data->lang, data->type, __ttsd_get_engine_error_code(ret));
+                                       }
+                               } else {
+                                       SECURE_SLOG(LOG_DEBUG, get_tag(), "[Engine Agent ERROR] Unload voice of engine function is NULL");
+                               }
+                       }
+                       break;
+               }
+               
+               /*Get next item*/
+               iter = g_slist_next(iter);
        }
 
-       if (NULL == temp_lang)
-               free(temp_lang);
+       if (NULL != g_cur_engine.default_lang)  free(g_cur_engine.default_lang);
+
+       g_cur_engine.default_lang = strdup(language);
+       g_cur_engine.default_vctype = vctype;
+
+#ifdef ENGINE_AGENT_DEBUG
+       ttsd_print_voicelist();
+#endif
+
+       SECURE_SLOG(LOG_DEBUG, get_tag(), "[Engine Agent SUCCESS] Set default voice : lang(%s), type(%d)",
+               g_cur_engine.default_lang, g_cur_engine.default_vctype);
 
        return 0;
 }
 
-
-int ttsd_engine_cancel_synthesis()
+int ttsd_engine_agent_set_default_speed(int speed)
 {
-       SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] start ttsd_engine_cancel_synthesis()");
-       
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" );
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
-       if (false == g_cur_engine.is_loaded) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not loaded engine");
-               return TTSD_ERROR_OPERATION_FAILED;
-       }
-       
-       if (NULL == g_cur_engine.pefuncs->cancel_synth) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] cancel_synth() of engine is NULL!!");
-               return TTSD_ERROR_OPERATION_FAILED;
-       }
-
-       /* stop synthesis */
-       int ret = 0;
-       ret = g_cur_engine.pefuncs->cancel_synth();
-       if (0 != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail cancel synthesis : result(%d)", ret);
-               return TTSD_ERROR_OPERATION_FAILED;
-       }
+       g_cur_engine.default_speed = speed;
 
        return 0;
 }
 
-int ttsd_engine_get_audio_format( ttsp_audio_type_e* type, int* rate, int* channels)
+int ttsd_engine_agent_set_default_pitch(int pitch)
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" );
@@ -1047,275 +1224,153 @@ int ttsd_engine_get_audio_format( ttsp_audio_type_e* type, int* rate, int* chann
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
-       if (NULL == g_cur_engine.pefuncs->get_audio_format) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] get_audio_format() of engine is NULL!!");
+       if (NULL == g_cur_engine.pefuncs->set_pitch) {
+               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not support pitch");
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
-       int ret = 0;
-       ret = g_cur_engine.pefuncs->get_audio_format(type, rate, channels);
+       int ret = g_cur_engine.pefuncs->set_pitch(pitch);
        if (0 != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail to get audio format : result(%d)", ret);
+               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Fail to set pitch : pitch(%d), result(%s)", 
+                       pitch, __ttsd_get_engine_error_code(ret));
                return TTSD_ERROR_OPERATION_FAILED;
-       } else
-               SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] get audio format : type(%d), rate(%d), channel(%d)", *type, *rate, *channels);
-       
+       }
+
+       g_cur_engine.default_pitch = pitch;
+
        return 0;
 }
 
-bool __supported_voice_cb(const char* language, ttsp_voice_type_e type, void* user_data)
+/******************************************************************************************
+* TTS Engine Interfaces for client
+*******************************************************************************************/
+
+int ttsd_engine_load_voice(const char* lang, const int vctype)
 {
-       GList** voice_list = (GList**)user_data;
+       /* 1. Find voice info */
+       int ret = -1;
+       GSList *iter = NULL;
+       ttsvoice_s* data = NULL;
 
-       if (NULL == language || NULL == voice_list) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Input parameter is NULL in voice list callback!!!!");
-               return false;
-       }
+       iter = g_slist_nth(g_cur_voices, 0);
+       while (NULL != iter) {
+               /*Get handle data from list*/
+               data = iter->data;
 
-       SLOG(LOG_DEBUG, get_tag(), "-- Language(%s), Type(%d)", language, type);
+               if (NULL != data) {
+                       if (0 == strcmp(data->lang, lang) && data->type == vctype) {
+                               SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] Find voice : default(%d) loaded(%d) ref(%d) lang(%s) type(%d)", 
+                                       data->is_default, data->is_loaded,  data->client_ref_count, data->lang, data->type);
+                               break;
+                       }
+               }
+               
+               /*Get next item*/
+               iter = g_slist_next(iter);
+               data = NULL;
+       }
 
-       voice_s* voice = g_malloc0(sizeof(voice_s));
-       voice->language = strdup(language);
-       voice->type = type;
+       if (NULL == data) {
+               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] This voice is not supported voice : lang(%s) type(%d)", lang, vctype);
+               return TTSD_ERROR_OPERATION_FAILED;
+       }
 
-       *voice_list = g_list_append(*voice_list, voice);
+       /* 2. increse ref count */
+       data->client_ref_count++;
 
-       return true;
-}
+       /* 3. if ref count change 0 to 1 and not default, load voice */
+       if (1 == data->client_ref_count && false == data->is_default) {
+               /* load voice */
+               if (NULL != g_cur_engine.pefuncs->load_voice) {
+                       ret = g_cur_engine.pefuncs->load_voice(data->lang, data->type);
+                       if (0 == ret) {
+                               SECURE_SLOG(LOG_DEBUG, get_tag(), "[Engine Agent SUCCESS] Load voice : lang(%s), type(%d)", 
+                                       data->lang, data->type);
+                               data->is_loaded = true;
+                       } else {
+                               SECURE_SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Fail to load voice : lang(%s), type(%d), result(%s)",
+                                       data->lang, data->type, __ttsd_get_engine_error_code(ret));
 
-int ttsd_engine_get_voice_list(GList** voice_list)
-{
-       if (false == g_agent_init) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" );
-               return TTSD_ERROR_OPERATION_FAILED;
-       }
-
-       if (false == g_cur_engine.is_loaded) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not loaded engine");
-               return TTSD_ERROR_OPERATION_FAILED;
-       }
-
-       if (NULL == g_cur_engine.pefuncs->foreach_voices) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] The function of engine is NULL!!");
-               return TTSD_ERROR_OPERATION_FAILED;
-       }
-
-       int ret = 0;
-       ret = g_cur_engine.pefuncs->foreach_voices(__supported_voice_cb, (void*)voice_list);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Fail to get voice list : result(%d)", ret);
-               return TTSD_ERROR_OPERATION_FAILED;
-       }
-
-       return 0;
-}
-
-int ttsd_engine_get_default_voice( char** lang, ttsp_voice_type_e* vctype )
-{
-       if (false == g_agent_init) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" );
-               return TTSD_ERROR_OPERATION_FAILED;
-       }
-
-       if (false == g_cur_engine.is_loaded) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not loaded engine");
-               return TTSD_ERROR_OPERATION_FAILED;
-       }
-
-       if (NULL == lang || NULL == vctype) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] BAD Parameter"); 
-               return TTSD_ERROR_INVALID_PARAMETER;
-       }
-
-       if (NULL != g_cur_engine.default_lang) {
-               *lang = g_strdup(g_cur_engine.default_lang);
-               *vctype = g_cur_engine.default_vctype;
-
-               SLOG(LOG_DEBUG, get_tag(), "[Engine] Get default voice : language(%s), type(%d)", *lang, *vctype);
-       } else {
-               if (NULL == g_cur_engine.pefuncs->foreach_voices) {
-                       SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] get_voice_list of engine is NULL!!");
-                       return TTSD_ERROR_OPERATION_FAILED;
-               }
-
-               /* get language list */
-               int ret;
-               GList* voice_list = NULL;
-
-               ret = g_cur_engine.pefuncs->foreach_voices(__supported_voice_cb, &voice_list);
-
-               if (0 == ret && 0 < g_list_length(voice_list)) {
-                       GList *iter = NULL;
-                       voice_s* voice;
-
-                       iter = g_list_first(voice_list);
-
-                       if (NULL != iter) {
-                               voice = iter->data;
-                               
-                               if (true != g_cur_engine.pefuncs->is_valid_voice(voice->language, voice->type)) {
-                                       SLOG(LOG_ERROR, get_tag(), "[Engine ERROR] Fail voice is NOT valid ");
-                                       return TTSD_ERROR_OPERATION_FAILED;
-                               }
-                               
-                               ttsd_config_set_default_voice(voice->language, (int)voice->type);
-                               
-                               if (NULL != g_cur_engine.default_lang)
-                                       g_free(g_cur_engine.default_lang);
-
-                               g_cur_engine.default_lang = g_strdup(voice->language);
-                               g_cur_engine.default_vctype = voice->type;
-
-                               *lang = g_strdup(g_cur_engine.default_lang);
-                               *vctype = g_cur_engine.default_vctype = voice->type;
-
-                               SLOG(LOG_DEBUG, get_tag(), "[Engine] Get default voice (New selected) : language(%s), type(%d)", *lang, *vctype);
-                       } else {
-                               SLOG(LOG_ERROR, get_tag(), "[Engine ERROR] Fail to get language list : result(%d)", ret);
                                return TTSD_ERROR_OPERATION_FAILED;
                        }
-
-                       __free_voice_list(voice_list);
                } else {
-                       SLOG(LOG_ERROR, get_tag(), "[Engine ERROR] Fail to get language list : result(%d)", ret);
-                       return TTSD_ERROR_OPERATION_FAILED;
+                       SECURE_SLOG(LOG_DEBUG, get_tag(), "[Engine Agent ERROR] Load voice of engine function is NULL");
                }
+       } else {
+               SECURE_SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] Not load voice : default voice(%d) or ref count(%d)",
+                       data->is_default, data->client_ref_count);
        }
-       
+
+#ifdef ENGINE_AGENT_DEBUG
+       ttsd_print_voicelist();
+#endif
+
        return 0;
 }
 
-/*
-* TTS Engine Interfaces for setting
-*/
-int ttsd_engine_setting_get_engine_list(GList** engine_list)
+int ttsd_engine_unload_voice(const char* lang, const int vctype)
 {
-       if (false == g_agent_init) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" );
-               return TTSD_ERROR_OPERATION_FAILED;
-       }
-
-       if (NULL == engine_list) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Input parameter is NULL" );
-               return TTSD_ERROR_INVALID_PARAMETER;
-       }
-
-       /* update engine list */
-       if (0 != __internal_update_engine_list()) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail __internal_update_engine_list()");
-               return TTSD_ERROR_OPERATION_FAILED;
-       }
-
-       GList *iter = NULL;
-       ttsengine_info_s *data = NULL;
-
-       iter = g_list_first(g_engine_list);
+       /* 1. Find voice info */
+       int ret = -1;
+       GSList *iter = NULL;
+       ttsvoice_s* data = NULL;
 
-       SLOG(LOG_DEBUG, get_tag(), "----- [Engine Agent] engine list -----");
-       
+       iter = g_slist_nth(g_cur_voices, 0);
        while (NULL != iter) {
-               engine_s* temp_engine;
-       
-               temp_engine = (engine_s*)g_malloc0(sizeof(engine_s));
-
+               /*Get handle data from list*/
                data = iter->data;
 
-               temp_engine->engine_id = strdup(data->engine_uuid);
-               temp_engine->engine_name = strdup(data->engine_name);
-               temp_engine->ug_name = strdup(data->setting_ug_path);
-
-               *engine_list = g_list_append(*engine_list, temp_engine);
-
-               iter = g_list_next(iter);
-
-               SLOG(LOG_DEBUG, get_tag(), " -- engine id(%s) engine name(%s) ug name(%s)", 
-                       temp_engine->engine_id, temp_engine->engine_name, temp_engine->ug_name);
+               if (NULL != data) {
+                       if (0 == strcmp(data->lang, lang) && data->type == vctype) {
+                               SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] Find voice : default(%d) loaded(%d) ref(%d) lang(%s) type(%d)", 
+                                       data->is_default, data->is_loaded,  data->client_ref_count, data->lang, data->type);
+                               break;
+                       }
+               }
                
+               /*Get next item*/
+               iter = g_slist_next(iter);
+               data = NULL;
        }
 
-       SLOG(LOG_DEBUG, get_tag(), "--------------------------------------");
-       
-       return 0;
-}
-
-int ttsd_engine_setting_get_engine(char** engine_id)
-{
-       if (false == g_agent_init) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" );
-               return TTSD_ERROR_OPERATION_FAILED;
-       }
-
-       if (false == g_cur_engine.is_loaded) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not loaded engine");
-               return TTSD_ERROR_ENGINE_NOT_FOUND;
-       }
-
-       *engine_id = strdup(g_cur_engine.engine_uuid);
-
-       return 0;
-}
-
-int ttsd_engine_setting_set_engine(const char* engine_id)
-{
-       if (false == g_agent_init) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" );
+       if (NULL == data) {
+               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] This voice is not supported voice : lang(%s) type(%d)", lang, vctype);
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
-       /* compare current engine and new engine.*/
-       if (0 == strncmp(g_cur_engine.engine_uuid, engine_id, strlen(engine_id))) {
-               SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] new engine(%s) is the same as current engine(%s)", engine_id, g_cur_engine.engine_uuid);
-               return 0;
-       }
-
-       char* tmp_uuid = NULL;
-       tmp_uuid = strdup(g_cur_engine.engine_uuid);
-
-       /* unload engine */
-       if (0 != ttsd_engine_agent_unload_current_engine()) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent Error] fail to unload current engine");
-       } else {
-               SLOG(LOG_DEBUG, get_tag(), "[Engine Agent SUCCESS] unload current engine");
-       }
-
-       /* change current engine */
-       if (0 != __internal_set_current_engine(engine_id)) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail __internal_set_current_engine()");
-
-               /* roll back to old current engine. */
-               __internal_set_current_engine(tmp_uuid);
-               ttsd_engine_agent_load_current_engine();
-               
-               if (tmp_uuid != NULL)   
-                       free(tmp_uuid);
-
-               return TTSD_ERROR_OPERATION_FAILED;
-       }
+       /* 2. Decrese ref count */
+       data->client_ref_count--;
 
-       /* load engine */
-       if (0 != ttsd_engine_agent_load_current_engine()) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent Error] fail to load new engine");
-               
-               if( tmp_uuid != NULL )  
-                       free(tmp_uuid);
+       /* 3. if ref count change 0 and not default, load voice */
+       if (0 == data->client_ref_count && false == data->is_default) {
+               /* load voice */
+               if (NULL != g_cur_engine.pefuncs->unload_voice) {
+                       ret = g_cur_engine.pefuncs->unload_voice(data->lang, data->type);
+                       if (0 == ret) {
+                               SECURE_SLOG(LOG_DEBUG, get_tag(), "[Engine Agent SUCCESS] Unload voice : lang(%s), type(%d)", 
+                                       data->lang, data->type);
+                               data->is_loaded = false;
+                       } else {
+                               SECURE_SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Fail to unload voice : lang(%s), type(%d), result(%s)",
+                                       data->lang, data->type, __ttsd_get_engine_error_code(ret));
 
-               return TTSD_ERROR_OPERATION_FAILED;
+                               return TTSD_ERROR_OPERATION_FAILED;
+                       }
+               } else {
+                       SECURE_SLOG(LOG_DEBUG, get_tag(), "[Engine Agent ERROR] Unload voice of engine function is NULL");
+               }
        } else {
-               SLOG(LOG_DEBUG, get_tag(), "[Engine Agent SUCCESS] load new engine");
-       }
-
-       /* save engine id to config */
-       if (0 != ttsd_config_set_default_engine(engine_id)) {
-               SLOG(LOG_WARN, get_tag(), "[Engine Agent WARNING] Fail to save engine id to config"); 
+               SECURE_SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] Not unload voice : default voice(%d) or ref count(%d)",
+                       data->is_default, data->client_ref_count);
        }
 
-       if (tmp_uuid != NULL)   
-               free(tmp_uuid);
-
+#ifdef ENGINE_AGENT_DEBUG
+       ttsd_print_voicelist();
+#endif
        return 0;
 }
 
-int ttsd_engine_setting_get_voice_list(char** engine_id, GList** voice_list)
+int ttsd_engine_start_synthesis(const char* lang, int vctype, const char* text, int speed, void* user_param)
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" );
@@ -1327,96 +1382,48 @@ int ttsd_engine_setting_get_voice_list(char** engine_id, GList** voice_list)
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
-       int ret = 0;
-
-       /* get language list from engine*/
-       ret = ttsd_engine_get_voice_list(voice_list);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Server Error] fail ttsd_engine_get_voice_list() ");
-               return ret;
-       }
-
-       *engine_id = strdup(g_cur_engine.engine_uuid);
-       
-       return 0;
-}
-
-int ttsd_engine_setting_get_default_voice(char** language, ttsp_voice_type_e* vctype)
-{
-       if (false == g_agent_init) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" );
-               return TTSD_ERROR_OPERATION_FAILED;
+       /* select voice for default */
+       char* temp_lang = NULL;
+       int temp_type;
+       if (true != ttsd_engine_select_valid_voice(lang, vctype, &temp_lang, &temp_type)) {
+               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Fail to select default voice");
+               if (NULL != temp_lang)  free(temp_lang);
+               return TTSD_ERROR_INVALID_VOICE;
+       } else {
+               SECURE_SLOG(LOG_DEBUG, get_tag(), "[Engine Agent] Start synthesis : language(%s), type(%d), speed(%d), text(%s)", 
+                       temp_lang, temp_type, speed, text);
        }
 
-       if (false == g_cur_engine.is_loaded) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not loaded engine");
+       if (NULL == g_cur_engine.pefuncs->start_synth) {
+               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] start_synth() of engine is NULL!!");
+               if (NULL != temp_lang)  free(temp_lang);
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
-       /* get current language from engine*/
-       int ret = 0;
-       char* temp_lang;
-       ttsp_voice_type_e temp_int;
+       int temp_speed;
 
-       ret = ttsd_engine_get_default_voice(&temp_lang, &temp_int);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Server Error] fail ttsd_engine_get_default_voice()");
-               return ret;
-       } 
-
-       if (NULL != temp_lang) {
-               *language = strdup(temp_lang);
-               *vctype = temp_int;
-               free(temp_lang);
+       if (0 == speed) {
+               temp_speed = g_cur_engine.default_speed;
        } else {
-               SLOG(LOG_ERROR, get_tag(), "[Server Error] fail to get default language");
-               return TTSD_ERROR_OPERATION_FAILED;
-       }
-
-       return 0;
-}
-
-int ttsd_engine_setting_set_default_voice(const char* language, ttsp_voice_type_e vctype)
-{
-       if (false == g_agent_init) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" );
-               return TTSD_ERROR_OPERATION_FAILED;
-       }
-
-       if (false == g_cur_engine.is_loaded) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not loaded engine");
-               return TTSD_ERROR_OPERATION_FAILED;
+               temp_speed = speed;
        }
 
-       if (NULL == g_cur_engine.pefuncs->is_valid_voice) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] The function of engine is NULL!!");
+       /* synthesize text */
+       int ret = 0;
+       ret = g_cur_engine.pefuncs->start_synth(temp_lang, temp_type, text, temp_speed, user_param);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] ***************************************");
+               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] * synthesize error : %s *", __ttsd_get_engine_error_code(ret));
+               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] ***************************************");
+               if (NULL != temp_lang)  free(temp_lang);
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
-       int ret = -1;
-       if(false == g_cur_engine.pefuncs->is_valid_voice(language, vctype)) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Voice is NOT valid !!");
-               return TTSD_ERROR_INVALID_VOICE;
-       }
-
-       if (NULL != g_cur_engine.default_lang)
-               free(g_cur_engine.default_lang);
-
-       g_cur_engine.default_lang = strdup(language);
-       g_cur_engine.default_vctype = vctype;
-
-       ret = ttsd_config_set_default_voice(language, (int)vctype);
-       if (0 == ret) {
-               SLOG(LOG_DEBUG, get_tag(), "[Engine Agent SUCCESS] Set default voice : lang(%s), type(%d)",
-                               g_cur_engine.default_lang, g_cur_engine.default_vctype); 
-       } else {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail to write default voice to config (%d)", ret); 
-       }
-
+       if (NULL != temp_lang)  free(temp_lang);
        return 0;
 }
 
-int ttsd_engine_setting_get_default_speed(ttsp_speed_e* speed)
+int ttsd_engine_cancel_synthesis()
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" );
@@ -1428,53 +1435,41 @@ int ttsd_engine_setting_get_default_speed(ttsp_speed_e* speed)
                return TTSD_ERROR_OPERATION_FAILED;
        }
        
-       /* get current language */
-       *speed = g_cur_engine.default_speed;
-
-       return 0;
-}
-
-int ttsd_engine_setting_set_default_speed(const ttsp_speed_e speed)
-{
-       if (false == g_agent_init) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" );
+       if (NULL == g_cur_engine.pefuncs->cancel_synth) {
+               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] cancel_synth() of engine is NULL!!");
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
-       if (false == g_cur_engine.is_loaded) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not loaded engine");
+       /* stop synthesis */
+       int ret = 0;
+       ret = g_cur_engine.pefuncs->cancel_synth();
+       if (0 != ret) {
+               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail cancel synthesis : %s", __ttsd_get_engine_error_code(ret));
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
-       g_cur_engine.default_speed = speed;
-
-       if (0 != ttsd_config_set_default_speed(speed)) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail to set default speed to config");
-       }
-
        return 0;
 }
 
-bool __engine_setting_cb(const char* key, const char* value, void* user_data)
+bool __supported_voice_cb(const char* language, int type, void* user_data)
 {
-       GList** engine_setting_list = (GList**)user_data;
+       GList** voice_list = (GList**)user_data;
 
-       if (NULL == engine_setting_list || NULL == key || NULL == value) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Input parameter is NULL in engine setting callback!!!!");
+       if (NULL == language || NULL == voice_list) {
+               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Input parameter is NULL in voice list callback!!!!");
                return false;
        }
 
-       engine_setting_s* temp = g_malloc0(sizeof(engine_setting_s));
-       temp->key = g_strdup(key);
-       temp->value = g_strdup(value);
+       voice_s* voice = calloc(1, sizeof(voice_s));
+       voice->language = strdup(language);
+       voice->type = type;
 
-       *engine_setting_list = g_list_append(*engine_setting_list, temp);
+       *voice_list = g_list_append(*voice_list, voice);
 
        return true;
 }
 
-
-int ttsd_engine_setting_get_engine_setting_info(char** engine_id, GList** setting_list)
+int ttsd_engine_get_voice_list(GList** voice_list)
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" );
@@ -1486,32 +1481,17 @@ int ttsd_engine_setting_get_engine_setting_info(char** engine_id, GList** settin
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
-       if (NULL == setting_list) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Input parameter is NULL");
-               return TTSD_ERROR_INVALID_PARAMETER;
-       }
-
-       if (NULL == g_cur_engine.pefuncs->foreach_engine_setting) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] foreach_engine_setting() of engine is NULL!!");
+       int ret = 0;
+       ret = g_cur_engine.pefuncs->foreach_voices(__supported_voice_cb, (void*)voice_list);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Fail to get voice list : %s", __ttsd_get_engine_error_code(ret));
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
-       /* get setting info and move setting info to input parameter */
-       int result = 0;
-
-       result = g_cur_engine.pefuncs->foreach_engine_setting(__engine_setting_cb, setting_list);
-
-       if (0 == result && 0 < g_list_length(*setting_list)) {
-               *engine_id = strdup(g_cur_engine.engine_uuid);
-       } else {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail to get setting info : result(%d)", result);
-               result = TTSD_ERROR_OPERATION_FAILED;
-       }
-
-       return result;
+       return 0;
 }
 
-int ttsd_engine_setting_set_engine_setting(const char* key, const char* value)
+int ttsd_engine_get_default_voice(char** lang, int* vctype)
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized" );
@@ -1523,20 +1503,21 @@ int ttsd_engine_setting_set_engine_setting(const char* key, const char* value)
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
-       if (NULL == g_cur_engine.pefuncs->set_engine_setting) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] set_setting_info of engine is NULL!!");
-               return TTSD_ERROR_OPERATION_FAILED;
+       if (NULL == lang || NULL == vctype) {
+               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] BAD Parameter"); 
+               return TTSD_ERROR_INVALID_PARAMETER;
        }
 
-       /* get setting info and move setting info to input parameter */
-       int ret = 0;
-       ret = g_cur_engine.pefuncs->set_engine_setting(key, value);
+       if (NULL != g_cur_engine.default_lang) {
+               *lang = strdup(g_cur_engine.default_lang);
+               *vctype = g_cur_engine.default_vctype;
 
-       if (0 != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] fail to set engine setting : result(%d)", ret); 
+               SECURE_SLOG(LOG_DEBUG, get_tag(), "[Engine] Get default voice : language(%s), type(%d)", *lang, *vctype);
+       } else {
+               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Default voice is NULL");
                return TTSD_ERROR_OPERATION_FAILED;
-       } 
-
+       }
+       
        return 0;
 }
 
@@ -1554,10 +1535,8 @@ void __free_voice_list(GList* voice_list)
                        data = iter->data;
                        
                        if (NULL != data) {
-                               if (NULL != data->language)
-                                       g_free(data->language);
-
-                               g_free(data);
+                               if (NULL != data->language)     free(data->language);
+                               free(data);
                        }
                        
                        voice_list = g_list_remove_link(voice_list, iter);
@@ -1570,10 +1549,9 @@ void __free_voice_list(GList* voice_list)
 /*
 * TTS Engine Callback Functions                                                                                        `                                 *
 */
-bool __result_cb(ttsp_result_event_e event, const void* data, unsigned int data_size, void *user_data)
+bool __result_cb(ttsp_result_event_e event, const void* data, unsigned int data_size, ttsp_audio_type_e audio_type, int rate, void *user_data)
 {
-       g_result_cb(event, data, data_size, user_data);
-
+       g_result_cb(event, data, data_size, audio_type, rate, user_data);
        return true;
 }
 
@@ -1592,11 +1570,11 @@ int ttsd_print_enginelist()
                while (NULL != iter) {
                        data = iter->data;
 
-                       SLOG(LOG_DEBUG, get_tag(), "[%dth]", i);
-                       SLOG(LOG_DEBUG, get_tag(), "engine uuid : %s", data->engine_uuid);
-                       SLOG(LOG_DEBUG, get_tag(), "engine name : %s", data->engine_name);
-                       SLOG(LOG_DEBUG, get_tag(), "engine path : %s", data->engine_path);
-                       SLOG(LOG_DEBUG, get_tag(), "setting ug path : %s", data->setting_ug_path);
+                       SECURE_SLOG(LOG_DEBUG, get_tag(), "[%dth]", i);
+                       SECURE_SLOG(LOG_DEBUG, get_tag(), "engine uuid : %s", data->engine_uuid);
+                       SECURE_SLOG(LOG_DEBUG, get_tag(), "engine name : %s", data->engine_name);
+                       SECURE_SLOG(LOG_DEBUG, get_tag(), "engine path : %s", data->engine_path);
+                       SECURE_SLOG(LOG_DEBUG, get_tag(), "setting ug path : %s", data->setting_ug_path);
 
                        iter = g_list_next(iter);
                        i++;
@@ -1612,9 +1590,38 @@ int ttsd_print_enginelist()
        return 0;
 }
 
+int ttsd_print_voicelist()
+{
+       /* Test log */
+       GSList *iter = NULL;
+       ttsvoice_s* data = NULL;
 
+       SLOG(LOG_DEBUG, get_tag(), "=== Voice list ===");
 
+       if (g_slist_length(g_cur_voices) > 0) {
+               /* Get a first item */
+               iter = g_slist_nth(g_cur_voices, 0);
+
+               int i = 1;      
+               while (NULL != iter) {
+                       /*Get handle data from list*/
+                       data = iter->data;
 
+                       if (NULL == data || NULL == data->lang) {
+                               SLOG(LOG_ERROR, get_tag(), "[ERROR] Data is invalid");
+                               return 0;
+                       }
 
+                       SLOG(LOG_DEBUG, get_tag(), "[%dth] default(%d) loaded(%d) ref(%d) lang(%s) type(%d)", 
+                               i, data->is_default, data->is_loaded,  data->client_ref_count, data->lang, data->type);
+                       
+                       /*Get next item*/
+                       iter = g_slist_next(iter);
+                       i++;
+               }
+       }
 
+       SLOG(LOG_DEBUG, get_tag(), "==================");
 
+       return 0;
+}
\ No newline at end of file
index bd618fb..08f6fa4 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*  Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd All Rights Reserved 
+*  Copyright (c) 2011-2014 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
@@ -22,7 +22,8 @@
 extern "C" {
 #endif
 
-typedef int (*synth_result_callback)(ttsp_result_event_e event, const void* data, unsigned int data_size, void *user_data);
+typedef int (*synth_result_callback)(ttsp_result_event_e event, const void* data, unsigned int data_size, 
+                                    ttsp_audio_type_e audio_type, int rate, void *user_data);
 
 /*
 * tts Engine Agent Interfaces
@@ -43,62 +44,39 @@ int ttsd_engine_agent_load_current_engine();
 /** Unload current engine */
 int ttsd_engine_agent_unload_current_engine();
 
-/** test for language list */
-int ttsd_print_enginelist();
-
 /** Get state of current engine to need network */
 bool ttsd_engine_agent_need_network();
 
-bool ttsd_engine_select_valid_voice(const char* lang, int type, char** out_lang, ttsp_voice_type_e* out_type);
+bool ttsd_engine_select_valid_voice(const char* lang, int type, char** out_lang, int* out_type);
 
 bool ttsd_engine_agent_is_same_engine(const char* engine_id);
 
-/*
-* TTS Engine Interfaces for client
-*/
-int ttsd_engine_start_synthesis(const char* lang, const ttsp_voice_type_e vctype, const char* text, const int speed, void* user_param);
-
-int ttsd_engine_cancel_synthesis();
+/** Get/Set app option */
+int ttsd_engine_agent_set_default_engine(const char* engine_id);
 
-int ttsd_engine_get_voice_list(GList** voice_list);
+int ttsd_engine_agent_set_default_voice(const char* language, int vctype);
 
-int ttsd_engine_get_default_voice(char** lang, ttsp_voice_type_e* vctype );
+int ttsd_engine_agent_set_default_speed(int speed);
 
-int ttsd_engine_get_audio_format(ttsp_audio_type_e* type, int* rate, int* channels);
+int ttsd_engine_agent_set_default_pitch(int pitch);
 
 /*
-* TTS Engine Interfaces for setting
+* TTS Engine Interfaces for client
 */
 
-/** Get engine list */
-int ttsd_engine_setting_get_engine_list(GList** engine_list);
-
-/** Get engine */
-int ttsd_engine_setting_get_engine(char** engine_id);
+int ttsd_engine_load_voice(const char* lang, int vctype);
 
-/** Set engine */
-int ttsd_engine_setting_set_engine(const char* engine_id);
+int ttsd_engine_unload_voice(const char* lang, int vctype);
 
-/** Get voice list for engine setting */
-int ttsd_engine_setting_get_voice_list(char** engine_id, GList** voice_list);
+int ttsd_engine_start_synthesis(const char* lang, int vctype, const char* text, int speed, void* user_param);
 
-/** Get default voice */
-int ttsd_engine_setting_get_default_voice(char** language, ttsp_voice_type_e* vctype);
-
-/** Set voice for engine setting */
-int ttsd_engine_setting_set_default_voice(const char* language, ttsp_voice_type_e vctype);
+int ttsd_engine_cancel_synthesis();
 
-/** Get voice speed for engine setting */
-int ttsd_engine_setting_get_default_speed(ttsp_speed_e* speed);
+int ttsd_engine_get_voice_list(GList** voice_list);
 
-/** Set voice speed for engine setting */
-int ttsd_engine_setting_set_default_speed(ttsp_speed_e speed);
+int ttsd_engine_get_default_voice(char** lang, int* vctype);
 
-/** Get setting info */
-int ttsd_engine_setting_get_engine_setting_info(char** engine_id, GList** setting_list); 
 
-/** Set setting info */
-int ttsd_engine_setting_set_engine_setting(const char* key, const char* value);
 
 #ifdef __cplusplus
 }
index 06b534b..14d842c 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*  Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd All Rights Reserved 
+*  Copyright (c) 2011-2014 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
 #include "ttsd_network.h"
 
 #include <Ecore.h>
+#include <privilege-control.h>
 
 #define CLIENT_CLEAN_UP_TIME 500
 
 static Ecore_Timer* g_check_client_timer = NULL;
 
-char* get_tag()
+const char* get_tag()
+{
+       return "ttsd";
+}
+
+const char* tts_tag()
 {
        return "ttsd";
 }
@@ -39,32 +45,37 @@ int main()
        SLOG(LOG_DEBUG, get_tag(), "  ");
        SLOG(LOG_DEBUG, get_tag(), "  ");
        SLOG(LOG_DEBUG, get_tag(), "===== TTS DAEMON DEFAULT INITIALIZE");
+
        if (!ecore_init()) {
                SLOG(LOG_ERROR, get_tag(), "[Main ERROR] Fail ecore_init()");
                return -1;
        }
 
-       if (0 != ttsd_initialize()) {
-               SLOG(LOG_ERROR, get_tag(), "[Main ERROR] Fail to initialize tts-daemon"); 
-               return EXIT_FAILURE;
+       if (0 == setuid(0)) {
+               /* daemon has root previlege */
+               perm_app_set_privilege("tts", NULL, NULL);
        }
-       
+
        if (0 != ttsd_dbus_open_connection()) {
                SLOG(LOG_ERROR, get_tag(), "[Main ERROR] Fail to open dbus connection");
                return EXIT_FAILURE;
        }
 
-       if (0 != ttsd_network_initialize()) {
-               SLOG(LOG_ERROR, get_tag(), "[Main ERROR] Fail to initialize network");
+       if (0 != ttsd_initialize()) {
+               SLOG(LOG_ERROR, get_tag(), "[Main ERROR] Fail to initialize tts-daemon"); 
                return EXIT_FAILURE;
        }
 
+       if (0 != ttsd_network_initialize()) {
+               SLOG(LOG_WARN, get_tag(), "[Main WARNING] Fail to initialize network");
+       }
+
        g_check_client_timer = ecore_timer_add(CLIENT_CLEAN_UP_TIME, ttsd_cleanup_client, NULL);
        if (NULL == g_check_client_timer) {
                SLOG(LOG_WARN, get_tag(), "[Main Warning] Fail to create timer of client check");
        }
 
-       SLOG(LOG_DEBUG, get_tag(), "[Main] tts-daemon start...\n"); 
+       SLOG(LOG_DEBUG, get_tag(), "[Main] tts-daemon start..."); 
        SLOG(LOG_DEBUG, get_tag(), "=====");
        SLOG(LOG_DEBUG, get_tag(), "  ");
        SLOG(LOG_DEBUG, get_tag(), "  ");
@@ -72,15 +83,15 @@ int main()
        ecore_main_loop_begin();
 
        SLOG(LOG_DEBUG, get_tag(), "===== TTS DAEMON DEFAULT FINALIZE");
-       
+
        if (NULL != g_check_client_timer) {
                ecore_timer_del(g_check_client_timer);
        }
 
-       ttsd_network_finalize();
-
        ttsd_dbus_close_connection();
 
+       ttsd_network_finalize();
+
        ttsd_finalize();
 
        ecore_shutdown();
index 6ac5cff..04fd7af 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*  Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd All Rights Reserved 
+*  Copyright (c) 2011-2014 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
 #include <stdio.h>
 #include <stdbool.h>
 #include <stdlib.h>
+#include <tizen.h>
 #include <unistd.h>
 #include <string.h>
 #include <glib.h>
 #include <dlog.h>
 #include <errno.h>
 
-/* For multi-user support */
-#include <tzplatform_config.h>
-
 #include "ttsp.h"
 #include "tts_defs.h"
 
 extern "C" {
 #endif
 
-/* TTS Daemon Define */ 
-#define BASE_DIRECTORY_DEFAULT                 "/usr/lib/voice/tts/1.0"
-#define ENGINE_DIRECTORY_DEFAULT               "/usr/lib/voice/tts/1.0/engine"
-#define ENGINE_DIRECTORY_DEFAULT_SETTING       "/usr/lib/voice/tts/1.0/setting"
-
-#define CONFIG_DIRECTORY               tzplatform_mkpath(TZ_USER_HOME, ".voice")
-
-#define ENGINE_DIRECTORY_DOWNLOAD              tzplatform_mkpath(TZ_USER_HOME, ".voice/tts/1.0/engine")
-#define ENGINE_DIRECTORY_DOWNLOAD_SETTING      tzplatform_mkpath(TZ_USER_HOME, ".voice/tts/1.0/setting")
-
-#define CONFIG_DEFAULT                         BASE_DIRECTORY_DEFAULT"/ttsd.conf"
-#define DEFAULT_CONFIG_FILE_NAME               tzplatform_mkpath(TZ_USER_HOME, ".voice/ttsd_default.conf")
-
 /* for debug message */
 #define DATA_DEBUG
+#define ENGINE_AGENT_DEBUG
 
 typedef enum {
-       TTSD_ERROR_NONE                 = 0,                    /**< Successful */
-       TTSD_ERROR_OUT_OF_MEMORY        = -ENOMEM,              /**< Out of Memory */
-       TTSD_ERROR_IO_ERROR             = -EIO,                 /**< I/O error */
-       TTSD_ERROR_INVALID_PARAMETER    = -EINVAL,              /**< Invalid parameter */
-       TTSD_ERROR_OUT_OF_NETWORK       = -ENETDOWN,            /**< Out of network */
-       TTSD_ERROR_INVALID_STATE        = -0x0100000 | 0x21,    /**< Invalid state */
-       TTSD_ERROR_INVALID_VOICE        = -0x0100000 | 0x22,    /**< Invalid voice */
-       TTSD_ERROR_ENGINE_NOT_FOUND     = -0x0100000 | 0x23,    /**< No available engine  */
-       TTSD_ERROR_TIMED_OUT            = -0x0100000 | 0x24,    /**< No answer from the daemon */
-       TTSD_ERROR_OPERATION_FAILED     = -0x0100000 | 0x25,    /**< Operation failed  */
-       TTSD_ERROR_AUDIO_POLICY_BLOCKED = -0x0100000 | 0x26     /**< Audio policy blocked */
+       TTSD_ERROR_NONE                 = TIZEN_ERROR_NONE,             /**< Successful */
+       TTSD_ERROR_OUT_OF_MEMORY        = TIZEN_ERROR_OUT_OF_MEMORY,    /**< Out of Memory */
+       TTSD_ERROR_IO_ERROR             = TIZEN_ERROR_IO_ERROR,         /**< I/O error */
+       TTSD_ERROR_INVALID_PARAMETER    = TIZEN_ERROR_INVALID_PARAMETER,/**< Invalid parameter */
+       TTSD_ERROR_OUT_OF_NETWORK       = TIZEN_ERROR_NETWORK_DOWN,     /**< Out of network */
+       TTSD_ERROR_TIMED_OUT            = TIZEN_ERROR_TIMED_OUT,        /**< No answer from the daemon */
+       TTSD_ERROR_PERMISSION_DENIED    = TIZEN_ERROR_PERMISSION_DENIED,/**< Permission denied */
+       TTSD_ERROR_NOT_SUPPORTED        = TIZEN_ERROR_NOT_SUPPORTED,    /**< TTS NOT supported */
+       TTSD_ERROR_INVALID_STATE        = TIZEN_ERROR_TTS | 0x01,       /**< Invalid state */
+       TTSD_ERROR_INVALID_VOICE        = TIZEN_ERROR_TTS | 0x02,       /**< Invalid voice */
+       TTSD_ERROR_ENGINE_NOT_FOUND     = TIZEN_ERROR_TTS | 0x03,       /**< No available engine */
+       TTSD_ERROR_OPERATION_FAILED     = TIZEN_ERROR_TTS | 0x04,       /**< Operation failed */
+       TTSD_ERROR_AUDIO_POLICY_BLOCKED = TIZEN_ERROR_TTS | 0x05        /**< Audio policy blocked */
 }ttsd_error_e;
 
 typedef enum {
@@ -75,7 +63,6 @@ typedef enum {
        TTSD_INTERRUPTED_STOPPED        /**< Current state change 'Ready' */
 }ttsd_interrupted_code_e;
 
-
 typedef struct {
        char* engine_id;
        char* engine_name;
@@ -84,19 +71,14 @@ typedef struct {
 
 typedef struct {
        char* language;
-       ttsp_voice_type_e type;
+       int type;
 }voice_s;
 
-typedef struct {
-       char* key;
-       char* value;
-}engine_setting_s;
-
 /* get daemon mode : default, notification or screen reader */
 ttsd_mode_e ttsd_get_mode();
 
 /* Get log tag : default, notification, screen reader */
-char* get_tag();
+const char* get_tag();
 
 #ifdef __cplusplus
 }
index 267fd92..1914ede 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*  Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd All Rights Reserved 
+*  Copyright (c) 2011-2014 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
 #include "ttsd_network.h"
 
 #include <Ecore.h>
+#include <privilege-control.h>
 
 #define CLIENT_CLEAN_UP_TIME 500
 
 static Ecore_Timer* g_check_client_timer = NULL;
 
-char* get_tag()
+const char* get_tag()
+{
+       return "ttsdnoti";
+}
+
+const char* tts_tag()
 {
        return "ttsdnoti";
 }
@@ -39,26 +45,31 @@ int main()
        SLOG(LOG_DEBUG, get_tag(), "  ");
        SLOG(LOG_DEBUG, get_tag(), "  ");
        SLOG(LOG_DEBUG, get_tag(), "===== TTS DAEMON NOTI INITIALIZE");
+
        if (!ecore_init()) {
-               SLOG(LOG_ERROR, get_tag(), "[Main ERROR] fail ecore_init()");
+               SLOG(LOG_ERROR, get_tag(), "[Main ERROR] Fail ecore_init()");
                return -1;
        }
 
-       if (0 != ttsd_initialize()) {
-               SLOG(LOG_ERROR, get_tag(), "[Main ERROR] fail to initialize tts-daemon-noti"); 
-               return EXIT_FAILURE;
+       if (0 == setuid(0)) {
+               /* daemon has root previlege */
+               perm_app_set_privilege("tts", NULL, NULL);
        }
 
        if (0 != ttsd_dbus_open_connection()) {
-               SLOG(LOG_ERROR, get_tag(), "[Main ERROR] fail to open dbus connection");
+               SLOG(LOG_ERROR, get_tag(), "[Main ERROR] Fail to open dbus connection");
                return EXIT_FAILURE;
        }
 
-       if (0 != ttsd_network_initialize()) {
-               SLOG(LOG_ERROR, get_tag(), "[Main ERROR] fail to initialize network");
+       if (0 != ttsd_initialize()) {
+               SLOG(LOG_ERROR, get_tag(), "[Main ERROR] Fail to initialize tts-daemon-noti"); 
                return EXIT_FAILURE;
        }
 
+       if (0 != ttsd_network_initialize()) {
+               SLOG(LOG_WARN, get_tag(), "[Main WARNING] Fail to initialize network");
+       }
+
        g_check_client_timer = ecore_timer_add(CLIENT_CLEAN_UP_TIME, ttsd_cleanup_client, NULL);
        if (NULL == g_check_client_timer) {
                SLOG(LOG_WARN, get_tag(), "[Main Warning] Fail to create timer of client check");
@@ -77,10 +88,10 @@ int main()
                ecore_timer_del(g_check_client_timer);
        }
 
-       ttsd_network_finalize();
-
        ttsd_dbus_close_connection();
 
+       ttsd_network_finalize();
+
        ttsd_finalize();
 
        ecore_shutdown();
index a970765..a93bf11 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*  Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd All Rights Reserved 
+*  Copyright (c) 2011-2014 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
 #include "ttsd_network.h"
 
 #include <Ecore.h>
+#include <privilege-control.h>
 
 #define CLIENT_CLEAN_UP_TIME 500
 
 static Ecore_Timer* g_check_client_timer = NULL;
 
-char* get_tag()
+const char* get_tag()
+{
+       return "ttsdsr";
+}
+
+const char* tts_tag()
 {
        return "ttsdsr";
 }
@@ -38,32 +44,37 @@ int main()
        SLOG(LOG_DEBUG, get_tag(), "  ");
        SLOG(LOG_DEBUG, get_tag(), "  ");
        SLOG(LOG_DEBUG, get_tag(), "===== TTS DAEMON SR INITIALIZE");
+
        if (!ecore_init()) {
-               SLOG(LOG_ERROR, get_tag(), "[Main ERROR] fail ecore_init()");
+               SLOG(LOG_ERROR, get_tag(), "[Main ERROR] Fail ecore_init()");
                return -1;
        }
 
-       if (0 != ttsd_initialize()) {
-               SLOG(LOG_ERROR, get_tag(), "[Main ERROR] fail to initialize tts-daemon-sr"); 
-               return EXIT_FAILURE;
+       if (0 == setuid(0)) {
+               /* daemon has root previlege */
+               perm_app_set_privilege("tts", NULL, NULL);
        }
 
        if (0 != ttsd_dbus_open_connection()) {
-               SLOG(LOG_ERROR, get_tag(), "[Main ERROR] fail to open dbus connection");
+               SLOG(LOG_ERROR, get_tag(), "[Main ERROR] Fail to open dbus connection");
                return EXIT_FAILURE;
        }
 
-       if (0 != ttsd_network_initialize()) {
-               SLOG(LOG_ERROR, get_tag(), "[Main ERROR] fail to initialize network \n");
+       if (0 != ttsd_initialize()) {
+               SLOG(LOG_ERROR, get_tag(), "[Main ERROR] Fail to initialize tts-daemon-sr"); 
                return EXIT_FAILURE;
        }
 
+       if (0 != ttsd_network_initialize()) {
+               SLOG(LOG_WARN, get_tag(), "[Main WARNING] Fail to initialize network");
+       }
+
        g_check_client_timer = ecore_timer_add(CLIENT_CLEAN_UP_TIME, ttsd_cleanup_client, NULL);
        if (NULL == g_check_client_timer) {
                SLOG(LOG_WARN, get_tag(), "[Main Warning] Fail to create timer of client check");
        }
 
-       SLOG(LOG_DEBUG, get_tag(), "[Main] tts-daemon-sr start...\n"); 
+       SLOG(LOG_DEBUG, get_tag(), "[Main] tts-daemon-sr start..."); 
        SLOG(LOG_DEBUG, get_tag(), "=====");
        SLOG(LOG_DEBUG, get_tag(), "  ");
        SLOG(LOG_DEBUG, get_tag(), "  ");
@@ -76,10 +87,10 @@ int main()
                ecore_timer_del(g_check_client_timer);
        }
 
-       ttsd_network_finalize();
-
        ttsd_dbus_close_connection();
 
+       ttsd_network_finalize();
+
        ttsd_finalize();
 
        ecore_shutdown();
index da2e18f..0af3329 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*  Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd All Rights Reserved 
+*  Copyright (c) 2011-2014 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
 
 #include <vconf.h>
 
-bool g_is_connected;
-
-bool ttsd_network_is_connected()
-{
-       return g_is_connected;
-}
-
-void __net_config_change_cb(keynode_t* node, void *data) 
-{
-       int network_configuration = 0;
-       vconf_get_int(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND , &network_configuration);
-       SLOG(LOG_DEBUG, get_tag(), "[Network DEBUG] Network configuration : %d", network_configuration);
-
-       if (network_configuration == 0) {
-               SLOG(LOG_DEBUG, get_tag(), "[Network] Notification : Network connection is OFF ");
-               g_is_connected = false;
-       } else {
-               SLOG(LOG_DEBUG, get_tag(), "[Network] Notification : Network connection is ON ");
-               g_is_connected = true;
-
-               /* need to notify changing net to engine. */
-       }
-
-       return;
-}
-
 int ttsd_network_initialize()
 {
-       int network_configuration = 0;
-       vconf_get_int(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND , &network_configuration);
-       SLOG(LOG_DEBUG, get_tag(), "[Network DEBUG] Network configuration : %d", network_configuration);
-
-       if (network_configuration == 0) {
-               /*      "0" means the network configuration is not set. 
-               *       It could be network connection is not open
-               */
-
-               int network_status = 0;
-               vconf_get_int(VCONFKEY_NETWORK_STATUS, &network_status);
-
-               if(network_status == VCONFKEY_NETWORK_OFF){
-                       SLOG(LOG_DEBUG, get_tag(), "[Network] Current network connection is OFF.");
-               }
-               else{
-                       /*
-                       *       This is the problem of network connection
-                       *       Just terminate the application, network f/w will fix the problem automatically.
-                       */
-                       SLOG(LOG_WARN, get_tag(), "network status is wrong or IP is not set\n");
-                       SLOG(LOG_WARN, get_tag(), "network has problem, try again\n");
-                       return -1;
-               }
-
-               g_is_connected = false;
-       } else {
-               SLOG(LOG_DEBUG, get_tag(), "[Network] Current network connection is ON.");
-
-               g_is_connected = true;
-       }
-
-       vconf_notify_key_changed(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, __net_config_change_cb, NULL);
-
-       SLOG(LOG_DEBUG, get_tag(), "[Network SUCCESS] Initialize network ...\n");
-
        return 0;
 }
 
 int ttsd_network_finalize()
 {
-       vconf_ignore_key_changed(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, __net_config_change_cb);
-
        return 0;
 }
 
+
+bool ttsd_network_is_connected()
+{
+       /* Check network */
+       int network_status = 0;
+       vconf_get_int(VCONFKEY_NETWORK_STATUS, &network_status);
+
+       if(network_status == VCONFKEY_NETWORK_OFF){
+               SLOG(LOG_WARN, get_tag(), "[Network] Current network connection is OFF.");
+               return false;
+       }
+       
+       SLOG(LOG_DEBUG, get_tag(), "[Network] Network status is %d", network_status);
+
+       return true;
+}
\ No newline at end of file
index 55ef030..51aaf71 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*  Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd All Rights Reserved 
+*  Copyright (c) 2011-2014 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
index be9e904..edeab08 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*  Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd All Rights Reserved 
+*  Copyright (c) 2011-2014 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
 *  limitations under the License.
 */
 
-
-#include <mm_types.h>
-#include <mm_player.h>
-#include <mm_player_internal.h>
-#include <mm_session.h>
-#include <mm_error.h>
+#include <audio_io.h>
 #include <Ecore.h>
+#include <sound_manager.h>
 
 #include "ttsd_main.h"
 #include "ttsd_player.h"
 #include "ttsd_data.h"
 #include "ttsd_dbus.h"
 
-
 /*
 * Internal data structure
 */
 
-#define TEMP_FILE_MAX  36
-
-typedef struct {
-       char    riff[4];
-       int     file_size;
-       char    wave[4];
-       char    fmt[4];
-       int     header_size;
-       short   sample_format;
-       short   n_channels;
-       int     sample_rate;
-       int     bytes_per_second;
-       short   block_align;
-       short   bits_per_sample;
-       char    data[4];
-       int     data_size;
-} WavHeader;
-
-typedef struct {
-       int             uid;            /** client id */
-       MMHandleType    player_handle;  /** mm player handle */
-       int             utt_id;         /** utt_id of next file */
-       ttsp_result_event_e event;      /** event of callback */
-       bool            pause_after_complete;   /** For resume when the 'Paused' state of player after end callback */
-} player_s;
+typedef enum {
+       AUDIO_STATE_NONE = 0,
+       AUDIO_STATE_READY,
+       AUDIO_STATE_PLAY
+}audio_state_e;
 
 typedef struct {
-       int  uid;
-       int  utt_id;
-       ttsp_result_event_e event;
-       char filename[TEMP_FILE_MAX];
-} user_data_s;
+       int                     uid;    /** client id */
+       app_state_e             state;  /** client state */
 
+       /* Current utterance information */
+       ttsp_result_event_e     event;  /** event of last utterance */
 
-/*
-* static data
-*/
+       bool                    is_paused_data;
+       int                     idx;
+       sound_data_s            paused_data;
+}player_s;
 
-#define TEMP_FILE_PATH  "/tmp"
-#define FILE_PATH_SIZE  256
-#define DEFAULT_FILE_SIZE 10
+#define SOUND_BUFFER_LENGTH    2048
 
 /** player init info */
 static bool g_player_init = false;
 
-/** tts engine list */
+/** Client list */
 static GList *g_player_list;
 
 /** current player information */
 static player_s* g_playing_info;
 
-/** player callback function */
-static player_result_callback_func g_result_callback;
+/* player state */
+static audio_state_e g_audio_state;
 
-/** numbering for temp file */
-static unsigned int g_index;              
+static ttsp_audio_type_e g_audio_type;
+
+static int g_sampling_rate;
+
+static audio_out_h g_audio_h;
 
 /*
 * Internal Interfaces 
 */
-player_s* __player_get_item(int uid);
 
-int __save_file(int uid, int index, sound_data_s data, char** filename);
+player_s* __player_get_item(int uid)
+{
+       GList *iter = NULL;
+       player_s *data = NULL;
+
+       if (0 < g_list_length(g_player_list)) {
+               /* Get a first item */
+               iter = g_list_first(g_player_list);
 
-int __set_and_start(player_s* player);
+               while (NULL != iter) {
+                       /* Get handle data from list */
+                       data = (player_s*)iter->data;
 
-int __init_wave_header(WavHeader* hdr, size_t nsamples, size_t sampling_rate, int channel);
+                       /* compare uid */
+                       if (uid == data->uid)
+                               return data;
 
-static int msg_callback(int message, void *data, void *user_param) ;
+                       /* Get next item */
+                       iter = g_list_next(iter);
+               }
+       }
 
+       return NULL;
+}
 
-/*
-* Player Interfaces 
-*/
+void __player_audio_io_interrupted_cb(audio_io_interrupted_code_e code, void *user_data)
+{
+       SLOG(LOG_DEBUG, get_tag(), "===== INTERRUPTED CALLBACK");
+
+       SLOG(LOG_WARN, get_tag(), "[Player] code : %d", (int)code);
+
+       g_audio_state = AUDIO_STATE_READY;
+
+       if (NULL == g_playing_info) {
+               SLOG(LOG_WARN, get_tag(), "[Player WARNING] No current player");
+               return;
+       }
+
+       if (APP_STATE_PLAYING == g_playing_info->state) {
+               g_playing_info->state = APP_STATE_PAUSED;
+
+               ttsd_data_set_client_state(g_playing_info->uid, APP_STATE_PAUSED);
+
+               int pid = ttsd_data_get_pid(g_playing_info->uid);
+
+               /* send message to client about changing state */
+               ttsdc_send_set_state_message (pid, g_playing_info->uid, APP_STATE_PAUSED);
+       }
+
+       SLOG(LOG_DEBUG, get_tag(), "=====");
+       SLOG(LOG_DEBUG, get_tag(), "  ");
+
+       return;
+}
+
+static int __create_audio_out(ttsp_audio_type_e type, int rate)
+{
+       int ret = -1;
+       audio_sample_type_e sample_type;
+
+       if (TTSP_AUDIO_TYPE_RAW_S16 == type) {
+               sample_type = AUDIO_SAMPLE_TYPE_S16_LE;
+       } else {
+               sample_type = AUDIO_SAMPLE_TYPE_U8;
+       }
+
+       ret = audio_out_create(rate, AUDIO_CHANNEL_MONO, sample_type, SOUND_TYPE_MEDIA, &g_audio_h);
+       if (AUDIO_IO_ERROR_NONE != ret) {
+               g_audio_state = AUDIO_STATE_NONE;
+               g_audio_h = NULL;
+               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Fail to create audio");
+               return -1;
+       } else {
+               SLOG(LOG_DEBUG, get_tag(), "[Player SUCCESS] Create audio");
+       }
+
+       if (TTSD_MODE_DEFAULT != ttsd_get_mode()) {
+               ret = audio_out_ignore_session(g_audio_h);
+               if (AUDIO_IO_ERROR_NONE != ret) {
+                       g_audio_state = AUDIO_STATE_NONE;
+                       g_audio_h = NULL;
+                       SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Fail to set ignore session");
+                       return -1;
+               }
+       }
+
+       ret = audio_out_set_interrupted_cb(g_audio_h, __player_audio_io_interrupted_cb, NULL);
+       if (AUDIO_IO_ERROR_NONE != ret) {
+               g_audio_state = AUDIO_STATE_NONE;
+               g_audio_h = NULL;
+               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Fail to set callback function");
+               return -1;
+       }
+
+       g_audio_type = type;
+       g_sampling_rate = rate;
+
+       g_audio_state = AUDIO_STATE_READY;
+
+       return 0;
+}
+
+static int __destroy_audio_out()
+{
+       if (NULL == g_audio_h) {
+               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Current handle is not valid");
+               return -1;
+       }
+
+       int ret = -1;
+       ret = audio_out_destroy(g_audio_h);
+       if (AUDIO_IO_ERROR_NONE != ret) {
+               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Fail to destroy audio");
+               return -1;
+       } else {
+               SLOG(LOG_DEBUG, get_tag(), "[Player SUCCESS] Destroy audio");
+       }
+       
+       g_audio_type = 0;
+       g_sampling_rate = 0;
 
-int ttsd_player_init(player_result_callback_func result_cb)
+       g_audio_state = AUDIO_STATE_NONE;
+       g_audio_h = NULL;
+
+       return 0;
+}
+
+static void __end_play_thread(void *data, Ecore_Thread *thread)
 {
-       if (NULL == result_cb) {
-               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] invalid parameter");
-               return TTSD_ERROR_INVALID_PARAMETER;
+       SLOG(LOG_DEBUG, get_tag(), "===== End thread");
+       return;
+}
+
+static void __play_thread(void *data, Ecore_Thread *thread)
+{
+       SLOG(LOG_DEBUG, get_tag(), "===== Start thread");
+
+       if (NULL == g_playing_info) {
+               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] No current player");
+               return;
        }
 
-       g_result_callback = result_cb;
+       player_s* player = g_playing_info;
+       sound_data_s wdata;
+
+       int ret = -1;
+       int len = SOUND_BUFFER_LENGTH;
+       int idx = 0;
+
+       while (1) {
+               if (true == player->is_paused_data) {
+                       /* Resume player */
+                       wdata.data = player->paused_data.data;
+                       wdata.data_size = player->paused_data.data_size;
+                       wdata.utt_id = player->paused_data.utt_id;
+                       wdata.audio_type = player->paused_data.audio_type;
+                       wdata.rate = player->paused_data.rate;
+                       wdata.channels = player->paused_data.channels;
+                       wdata.event = player->paused_data.event;
+
+                       idx = player->idx;
+
+                       player->is_paused_data = false;
+                       player->idx = 0;
+               } else {
+                       if (0 != ttsd_data_get_sound_data(player->uid, &wdata)) {
+                               g_playing_info = NULL;
+                               SLOG(LOG_DEBUG, get_tag(), "[Player] No sound data. Finish thread");
+
+                               /* Request unprepare */
+                               ret = audio_out_unprepare(g_audio_h);
+                               if (AUDIO_IO_ERROR_NONE != ret) {
+                                       SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Fail to unprepare audio : %d", ret);
+                               } else {
+                                       SLOG(LOG_DEBUG, get_tag(), "[Player SUCCESS] Unprepare audio");
+                               }
+
+                               g_audio_state = AUDIO_STATE_READY;
+                               return;
+                       }
+
+                       /* If wdata's event is 'start', current wdata is first data of engine for synthesis. 
+                        * If wdata's event is 'finish', player should check previous event to know whether this wdata is first or not.
+                        * When previous wdata's event is 'finish' and current wdata's event is 'finish', 
+                        * the player should send utt started event. 
+                        */
+                       if (TTSP_RESULT_EVENT_START == wdata.event ||
+                          (TTSP_RESULT_EVENT_FINISH == player->event && TTSP_RESULT_EVENT_FINISH == wdata.event)) {
+                               int pid = ttsd_data_get_pid(player->uid);
+
+                               if (pid <= 0) {
+                                       SLOG(LOG_WARN, get_tag(), "[Send WARNIING] Current player is not valid");
+                                       return;
+                               }
+
+                               if (0 != ttsdc_send_utt_start_message(pid, player->uid, wdata.utt_id)) {
+                                       SLOG(LOG_ERROR, get_tag(), "[Send ERROR] Fail to send Utterance Start Signal : pid(%d), uid(%d), uttid(%d)", 
+                                               pid, player->uid, wdata.utt_id);
+                               }
+                               SLOG(LOG_DEBUG, get_tag(), "[Player] Start utterance : uid(%d), uttid(%d)", player->uid, wdata.utt_id);
+                       }
+
+                       /* Save last event to check utterance start */
+                       player->event = wdata.event;
+                       idx = 0;
+
+                       if (NULL == wdata.data || 0 >= wdata.data_size) {
+                               if (TTSP_RESULT_EVENT_FINISH == wdata.event) {
+                                       SLOG(LOG_DEBUG, get_tag(), "No sound data");
+                                       /* send utterence finish signal */
+                                       int pid = ttsd_data_get_pid(player->uid);
+
+                                       if (pid <= 0) {
+                                               SLOG(LOG_WARN, get_tag(), "[Send WARNIING] Current player is not valid");
+                                               return;
+                                       }
+                                       if (0 != ttsdc_send_utt_finish_message(pid, player->uid, wdata.utt_id)) {
+                                               SECURE_SLOG(LOG_ERROR, get_tag(), "[Send ERROR] Fail to send Utterance Completed Signal : pid(%d), uid(%d), uttid(%d)", pid, player->uid, wdata.utt_id);
+                                       }
+                               }
+                               SLOG(LOG_DEBUG, get_tag(), "[Player] Finish utterance : uid(%d), uttid(%d)", player->uid, wdata.utt_id);
+                               continue;
+                       }
+               }
+
+               SLOG(LOG_DEBUG, get_tag(), "[Player] Sound info : id(%d) size(%d) audiotype(%d) rate(%d) event(%d)", 
+                       wdata.utt_id, wdata.data_size, wdata.audio_type, wdata.rate, wdata.event);
+
+               if (g_sampling_rate != wdata.rate || g_audio_type != wdata.audio_type) {
+                       SLOG(LOG_DEBUG, get_tag(), "[Player] Change audio handle : org type(%d) org rate(%d)", g_audio_type, g_sampling_rate);
+                       if (NULL != g_audio_h) {
+                               __destroy_audio_out();
+                       }
+
+                       if (0 > __create_audio_out(wdata.audio_type, wdata.rate)) {
+                               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Fail to create audio out");
+                               return;
+                       }
+               }
+
+               while (APP_STATE_PLAYING == player->state || APP_STATE_PAUSED == player->state) {
+                       if ((unsigned int)idx >= wdata.data_size)
+                               break;
+
+                       if ((unsigned int)idx + SOUND_BUFFER_LENGTH > wdata.data_size) {
+                               len = wdata.data_size - idx;
+                       } else {
+                               len = SOUND_BUFFER_LENGTH;
+                       }
+
+                       if (AUDIO_STATE_READY == g_audio_state) {
+                               /* Request prepare */
+                               ret = audio_out_prepare(g_audio_h);
+                               if (AUDIO_IO_ERROR_NONE != ret) {
+                                       SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Fail to prepare audio : %d", ret);
+                                       g_playing_info = NULL;
+                                       return;
+                               }
+                               SLOG(LOG_DEBUG, get_tag(), "[Player SUCCESS] Prepare audio");
+                               g_audio_state = AUDIO_STATE_PLAY;
+                       }
+
+                       char* temp_data = wdata.data;
+                       ret = audio_out_write(g_audio_h, &temp_data[idx], len);
+                       if (0 > ret) {
+                               SLOG(LOG_WARN, get_tag(), "[Player WARNING] Fail to audio write - %d", ret);
+                       } else {
+                               idx += len;
+                       }
+
+                       if (APP_STATE_PAUSED == player->state) {
+                               /* Save data */
+                               player->paused_data.data = wdata.data;
+                               player->paused_data.data_size = wdata.data_size;
+                               player->paused_data.utt_id = wdata.utt_id;
+                               player->paused_data.audio_type = wdata.audio_type;
+                               player->paused_data.rate = wdata.rate;
+                               player->paused_data.channels = wdata.channels;
+                               player->paused_data.event = wdata.event;
+
+                               player->is_paused_data = true;
+                               player->idx = idx;
+
+                               g_audio_state = AUDIO_STATE_READY;
+                               SLOG(LOG_DEBUG, get_tag(), "[Player] Stop player thread by pause");
+
+                               /* Request prepare */
+                               ret = audio_out_unprepare(g_audio_h);
+                               if (AUDIO_IO_ERROR_NONE != ret) {
+                                       SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Fail to unprepare audio : %d", ret);
+                               } else {
+                                       SLOG(LOG_DEBUG, get_tag(), "[Player SUCCESS] Unprepare audio");
+                               }
+                               return;
+                       }
+               }
+
+               if (NULL != wdata.data) {
+                       free(wdata.data);
+                       wdata.data = NULL;
+               }
+
+               if (APP_STATE_READY == player->state) {
+                       g_audio_state = AUDIO_STATE_READY;
+                       SLOG(LOG_DEBUG, get_tag(), "[Player] Stop player thread");
+
+                       /* Request prepare */
+                       ret = audio_out_unprepare(g_audio_h);
+                       if (AUDIO_IO_ERROR_NONE != ret) {
+                               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Fail to unprepare audio : %d", ret);
+                       } else {
+                               SLOG(LOG_DEBUG, get_tag(), "[Player SUCCESS] Unprepare audio");
+                       }
+                       return;
+               }
+
+               if (TTSP_RESULT_EVENT_FINISH == wdata.event) {
+                       /* send utterence finish signal */
+                       int pid = ttsd_data_get_pid(player->uid);
+
+                       if (pid <= 0) {
+                               SLOG(LOG_WARN, get_tag(), "[Send WARNIING] Current player is not valid");
+                               return;
+                       }
+
+                       if (0 != ttsdc_send_utt_finish_message(pid, player->uid, wdata.utt_id)) {
+                               SLOG(LOG_ERROR, get_tag(), "[Send ERROR] Fail to send Utterance Completed Signal : pid(%d), uid(%d), uttid(%d)", 
+                                       pid, player->uid, wdata.utt_id);
+                               return;
+                       }
+
+                       SLOG(LOG_DEBUG, get_tag(), "[Player] Finish utterance : uid(%d), uttid(%d)", player->uid, wdata.utt_id);
+               }
+       }
+}
 
+/*
+* Player Interfaces 
+*/
+int ttsd_player_init()
+{
        g_playing_info = NULL;
+       g_audio_state = AUDIO_STATE_NONE;
+       g_audio_h = NULL;
        
-       g_index = 1;
-       g_player_init = true;
+       int ret;
 
        if (TTSD_MODE_DEFAULT == ttsd_get_mode()) {
-               if (MM_ERROR_NONE != mm_session_init(MM_SESSION_TYPE_EXCLUSIVE)) {
-                       SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Fail mm_session_init(MM_SESSION_TYPE_EXCLUSIVE)");   
+               ret = sound_manager_set_session_type(SOUND_SESSION_TYPE_MEDIA);
+               if (0 != ret) {
+                       SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Fail to set session type");
+               }
+               
+               ret = sound_manager_set_media_session_option(SOUND_SESSION_OPTION_PAUSE_OTHERS_WHEN_START, SOUND_SESSION_OPTION_INTERRUPTIBLE_DURING_PLAY);
+               if (0 != ret) {
+                       SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Fail set media session option");     
                } else {
-                       SLOG(LOG_ERROR, get_tag(), "[Player SUCCESS] mm_session_init(MM_SESSION_TYPE_EXCLUSIVE)");      
+                       SLOG(LOG_DEBUG, get_tag(), "[Player SUCCESS] set media session option");        
                }
        }
 
+       ecore_thread_max_set(1);
+               
+       ret = __create_audio_out(TTSP_AUDIO_TYPE_RAW_S16, 16000);
+       if (0 != ret)
+               return -1;
+
+       g_player_init = true;
+
        return 0;
 }
 
@@ -136,6 +445,33 @@ int ttsd_player_release(void)
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
+       int ret;
+
+       ret = __destroy_audio_out();
+       if (0 != ret)
+               return -1;
+
+       SLOG(LOG_DEBUG, get_tag(), "[Player DEBUG] ==========================");
+       SLOG(LOG_DEBUG, get_tag(), "[Player DEBUG] Active thread count : %d", ecore_thread_active_get());
+       SLOG(LOG_DEBUG, get_tag(), "[Player DEBUG] ==========================");
+
+       /* The thread should be released */
+       int thread_count = ecore_thread_active_get();
+       int count = 0;
+       while (0 < thread_count) {
+               usleep(10);
+
+               count++;
+               if (100 == count) {
+                       SLOG(LOG_WARN, get_tag(), "[Player WARNING!!] Thread is blocked. Player release continue.");
+                       break;
+               }
+
+               thread_count = ecore_thread_active_get();
+       }
+
+       SLOG(LOG_DEBUG, get_tag(), "[Player DEBUG] Thread is released");
+
        /* clear g_player_list */
        g_playing_info = NULL;
        g_player_init = false;
@@ -156,24 +492,16 @@ int ttsd_player_create_instance(int uid)
                return -1;
        }
 
-       int ret = MM_ERROR_NONE; 
-       MMHandleType player_handle;
-       
-       ret = mm_player_create(&player_handle);
-       if (ret != MM_ERROR_NONE || 0 == player_handle) {
-               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] fail mm_player_create() : %x", ret);
-               return -2;
-       }
-
-       player_s* new_client = (player_s*)g_malloc0( sizeof(player_s) * 1);
+       player_s* new_client = (player_s*)calloc(1, sizeof(player_s));
 
        new_client->uid = uid;
-       new_client->player_handle = player_handle;
-       new_client->utt_id = -1;
        new_client->event = TTSP_RESULT_EVENT_FINISH;
-       new_client->pause_after_complete = false;
+       new_client->state = APP_STATE_READY;
+       new_client->is_paused_data = false;
+       new_client->idx = 0;
+       new_client->paused_data.data = NULL;
        
-       SECURE_SLOG(LOG_DEBUG, get_tag(), "[Player] Create player : uid(%d), handle(%d)", uid, player_handle );
+       SECURE_SLOG(LOG_DEBUG, get_tag(), "[Player] Create player : uid(%d)", uid);
 
        g_player_list = g_list_append(g_player_list, new_client);
 
@@ -200,34 +528,6 @@ int ttsd_player_destroy_instance(int uid)
                }
        }
 
-       MMPlayerStateType player_state;
-       mm_player_get_state(current->player_handle, &player_state);
-
-       SLOG(LOG_DEBUG, get_tag(), "[PLAYER] State changed : state(%d)", player_state);
-
-       int ret = -1;
-       /* destroy player */
-       switch (player_state) {
-               case MM_PLAYER_STATE_PLAYING:
-               case MM_PLAYER_STATE_PAUSED:
-               case MM_PLAYER_STATE_READY:
-                       ret = mm_player_unrealize(current->player_handle);
-                       if (MM_ERROR_NONE != ret) {
-                               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] fail mm_player_unrealize() : %x", ret);
-                       } 
-                       /* NO break for destroy */
-
-               case MM_PLAYER_STATE_NULL:
-                       ret = mm_player_destroy(current->player_handle);
-                       if (MM_ERROR_NONE != ret) {
-                               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] fail mm_player_destroy() : %x", ret);
-                       } 
-                       break;
-
-               default:
-                       break;
-       }
-               
        GList *iter = NULL;
        player_s *data = NULL;
 
@@ -243,7 +543,7 @@ int ttsd_player_destroy_instance(int uid)
                                /* compare uid */
                                if (uid == data->uid) {
                                        g_player_list = g_list_remove_link(g_player_list, iter);                                
-                                       g_free(data);
+                                       free(data);
                                        break;
                                }
                        }
@@ -260,8 +560,6 @@ int ttsd_player_destroy_instance(int uid)
 
 int ttsd_player_play(int uid)
 {
-       SECURE_SLOG(LOG_DEBUG, get_tag(), "[Player] start play : uid(%d)", uid );
-
        if (false == g_player_init) {
                SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized" );
                return -1;
@@ -269,11 +567,13 @@ int ttsd_player_play(int uid)
 
        if (NULL != g_playing_info) {
                if (uid == g_playing_info->uid) {
-                       SECURE_SLOG(LOG_WARN, get_tag(), "[Player WARNING] uid(%d) has already played", g_playing_info->uid); 
+                       SECURE_SLOG(LOG_DEBUG, get_tag(), "[Player] uid(%d) has already played", g_playing_info->uid);
                        return 0;
                }
        }
 
+       SECURE_SLOG(LOG_DEBUG, get_tag(), "[Player] start play : uid(%d)", uid );
+
        /* Check sound queue size */
        if (0 == ttsd_data_get_sound_data_size(uid)) {
                SECURE_SLOG(LOG_WARN, get_tag(), "[Player WARNING] A sound queue of current player(%d) is empty", uid); 
@@ -288,51 +588,24 @@ int ttsd_player_play(int uid)
                return -1;
        }
 
-       MMPlayerStateType player_state;
-       mm_player_get_state(current->player_handle, &player_state);
-
-       SLOG(LOG_DEBUG, get_tag(), "[PLAYER] State changed : state(%d)", player_state);
-
-       switch (player_state) {
-               case MM_PLAYER_STATE_PLAYING:
-                       SLOG(LOG_WARN, get_tag(), "[Player] Current player is playing. Do not start new sound.");
-                       return 0;
-
-               case MM_PLAYER_STATE_PAUSED:
-                       SLOG(LOG_WARN, get_tag(), "[Player] Player is paused. Do not start new sound.");
-                       return -1;
-
-               case MM_PLAYER_STATE_READY:
-                       SLOG(LOG_WARN, get_tag(), "[Player] Player is ready for next play. Do not start new sound.");
-                       return -1;
-
-               case MM_PLAYER_STATE_NULL:
-                       break;
-
-               case MM_PLAYER_STATE_NONE:
-                       SLOG(LOG_WARN, get_tag(), "[Player] Player is created. Do not start new sound.");
-                       return -1;
+       current->state = APP_STATE_PLAYING;
+       
+       g_playing_info = current;
 
-               default:
-                       return -1;
-       }
+       SLOG(LOG_DEBUG, get_tag(), "[Player DEBUG] Active thread count : %d", ecore_thread_active_get());
 
-       int ret;
-       ret = __set_and_start(current);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] fail to set or start mm_player");
-               return ret;
+       if (0 < ttsd_data_get_sound_data_size(current->uid)) {
+               SLOG(LOG_DEBUG, get_tag(), "[Player] Run thread");
+               ecore_thread_run(__play_thread, __end_play_thread, NULL, NULL);
        }
 
-       SECURE_SLOG(LOG_DEBUG, get_tag(), "[Player] Started play and wait for played callback : uid(%d)", uid);
-
        return 0;
 }
 
-int __ttsd_player_next_play(int uid)
+int ttsd_player_stop(int uid)
 {
        if (false == g_player_init) {
-               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized" );
+               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized");
                return -1;
        }
 
@@ -341,67 +614,39 @@ int __ttsd_player_next_play(int uid)
        current = __player_get_item(uid);
        if (NULL == current) {
                SECURE_SLOG(LOG_ERROR, get_tag(), "[Player ERROR] uid(%d) is not valid", uid); 
-               g_playing_info = NULL;
                return -1;
        }
 
+       /* check whether uid is current playing or not */
        if (NULL != g_playing_info) {
-               if (uid != g_playing_info->uid) {
-                       SECURE_SLOG(LOG_WARN, get_tag(), "[Player WARNING] Current player(%d) is NOT uid(%d)", g_playing_info->uid, uid); 
-                       return 0;
+               if (uid == g_playing_info->uid) {
+                       /* release current playing info */
+                       g_playing_info = NULL;
                }
        } else {
-               SLOG(LOG_WARN, get_tag(), "[Player WARNING] Current player do NOT exist"); 
-               return -1;
-       }
-
-       MMPlayerStateType player_state;
-       mm_player_get_state(current->player_handle, &player_state);
-
-       SLOG(LOG_DEBUG, get_tag(), "[PLAYER] State changed : state(%d)", player_state);
-
-       int ret = -1;
-       /* stop player */
-       switch (player_state) {
-               case MM_PLAYER_STATE_PLAYING:
-               case MM_PLAYER_STATE_PAUSED:
-               case MM_PLAYER_STATE_READY:
-                       ret = mm_player_unrealize(current->player_handle);
-                       if (MM_ERROR_NONE != ret) {
-                               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] fail mm_player_unrealize() : %x", ret);
-                               return -1;
-                       } 
-                       break;
-
-               case MM_PLAYER_STATE_NULL:
-                       break;
-
-               default:
-                       break;
+               SLOG(LOG_DEBUG, get_tag(), "[Player] No current playing"); 
        }
 
-       /* Check sound queue size */
-       if (0 == ttsd_data_get_sound_data_size(uid)) {
-               SECURE_SLOG(LOG_WARN, get_tag(), "[Player WARNING] A sound queue of current player(%d) is empty", uid); 
-               g_playing_info = NULL;
-               return -1;
+       if (true == current->is_paused_data) {
+               if (NULL != current->paused_data.data) {
+                       free(current->paused_data.data);
+                       current->paused_data.data = NULL;
+               }
        }
 
-       ret = __set_and_start(current);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] fail to set or start mm_player");
-               return ret;
-       }
+       current->event = TTSP_RESULT_EVENT_FINISH;
+       current->state = APP_STATE_READY;
+       current->is_paused_data = false;
+       current->idx = 0;
 
-       SECURE_SLOG(LOG_DEBUG, get_tag(), "[Player] Started play and wait for played callback : uid(%d)", uid);
+       SECURE_SLOG(LOG_DEBUG, get_tag(), "[Player SUCCESS] Stop player : uid(%d)", uid);
 
        return 0;
 }
 
-
-int ttsd_player_stop(int uid)
+int ttsd_player_pause(int uid)
 {
-       SECURE_SLOG(LOG_DEBUG, get_tag(), "[Player] stop player : uid(%d)", uid );
+       SECURE_SLOG(LOG_DEBUG, get_tag(), "[Player] pause player : uid(%d)", uid );
 
        if (false == g_player_init) {
                SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized" );
@@ -412,7 +657,7 @@ int ttsd_player_stop(int uid)
        player_s* current;
        current = __player_get_item(uid);
        if (NULL == current) {
-               SECURE_SLOG(LOG_ERROR, get_tag(), "[Player ERROR] uid(%d) is not valid", uid); 
+               SECURE_SLOG(LOG_ERROR, get_tag(), "[Player ERROR] ttsd_player_pause() : uid(%d) is not valid", uid); 
                return -1;
        }
 
@@ -421,90 +666,17 @@ int ttsd_player_stop(int uid)
                if (uid == g_playing_info->uid) {
                        /* release current playing info */
                        g_playing_info = NULL;
+               } else {
+                       /* error case */
                }
-       } else {
-               SLOG(LOG_DEBUG, get_tag(), "[Player] No current playing"); 
-       }
-
-       current->utt_id = -1;
-       current->pause_after_complete = false;
-
-       MMPlayerStateType player_state;
-       mm_player_get_state(current->player_handle, &player_state);
-
-       SLOG(LOG_DEBUG, get_tag(), "[PLAYER] Current state(%d)", player_state);
-
-       int ret = -1;
-       switch (player_state) {
-               case MM_PLAYER_STATE_PLAYING:
-               case MM_PLAYER_STATE_PAUSED:
-               case MM_PLAYER_STATE_READY:
-                       ret = mm_player_unrealize(current->player_handle);
-                       if (MM_ERROR_NONE != ret) {
-                               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] fail mm_player_unrealize() : %x", ret);
-                               return -1;
-                       } 
-                       break;
-
-               case MM_PLAYER_STATE_NULL:
-                       break;
-               
-               default:
-                       break;
        }
 
-       SECURE_SLOG(LOG_DEBUG, get_tag(), "[Player SUCCESS] Stop player : uid(%d)", uid);
+       current->state = APP_STATE_PAUSED;
 
        return 0;
 }
 
-int ttsd_player_pause(int uid)
-{
-       SECURE_SLOG(LOG_DEBUG, get_tag(), "[Player] pause player : uid(%d)", uid );
-
-       if (false == g_player_init) {
-               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized" );
-               return -1;
-       }
-
-       /* Check uid */
-       player_s* current;
-       current = __player_get_item(uid);
-       if (NULL == current) {
-               SECURE_SLOG(LOG_ERROR, get_tag(), "[Player ERROR] ttsd_player_pause() : uid(%d) is not valid", uid); 
-               return -1;
-       }
-
-       /* check whether uid is current playing or not */
-       if (NULL != g_playing_info) {
-               if (uid == g_playing_info->uid) {
-                       /* release current playing info */
-                       g_playing_info = NULL;
-               } else {
-                       /* error case */
-               }
-       }
-
-       MMPlayerStateType player_state;
-       mm_player_get_state(current->player_handle, &player_state);
-
-       SLOG(LOG_DEBUG, get_tag(), "[PLAYER] Current state(%d)", player_state);
-
-       int ret = 0;
-       if (MM_PLAYER_STATE_PLAYING == player_state) {
-               ret = mm_player_pause(current->player_handle);
-               if (MM_ERROR_NONE != ret) {
-                       SLOG(LOG_ERROR, get_tag(), "[Player ERROR] fail mm_player_pause : %x ", ret);
-               }
-       } else {
-               SLOG(LOG_WARN, get_tag(), "[Player WARNING] Current player is NOT 'playing'");
-       }
-       
-
-       return 0;
-}
-
-int ttsd_player_resume(int uid)
+int ttsd_player_resume(int uid)
 {
        SECURE_SLOG(LOG_DEBUG, get_tag(), "[Player] Resume player : uid(%d)", uid );
 
@@ -525,120 +697,15 @@ int ttsd_player_resume(int uid)
        if (NULL != g_playing_info)
                g_playing_info = NULL;
 
-       
-       MMPlayerStateType player_state;
-       mm_player_get_state(current->player_handle, &player_state);
-
-       SLOG(LOG_DEBUG, get_tag(), "[PLAYER] Current state(%d)", player_state);
-
-       int ret = -1;
-       if (MM_PLAYER_STATE_PAUSED == player_state) {
-               /* When the 'Paused' state of player after end of play */
-               if (true == current->pause_after_complete) {
-                       g_playing_info = current;
-
-                       current->pause_after_complete = false;
-                       
-                       /* Current state need load and play */
-                       ret = __ttsd_player_next_play(uid);
-                       if (0 != ret) {
-                               SLOG(LOG_ERROR, get_tag(), "[player] Fail to next play in resume function");
-                       }
-               } else {
-                       ret = mm_player_resume(current->player_handle);
-                       if (MM_ERROR_NONE != ret) {
-                               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] fail mm_player_resume() : %d", ret);
-                               return -1;
-                       } else {
-                               SLOG(LOG_DEBUG, get_tag(), "[Player] Resume player");
-                       }
-
-                       g_playing_info = current;
-               }
-       } else {
-               SLOG(LOG_WARN, get_tag(), "[Player WARNING] Current uid is NOT paused state.");
-       }
-
-       return 0;
-}
-
-int ttsd_player_get_state(int uid, ttsd_player_state_e* state)
-{
-       if (false == g_player_init) {
-               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized" );
-               return -1;
-       }
-
-       player_s* current;
-       current = __player_get_item(uid);
-       if (NULL == current) {
-               SECURE_SLOG(LOG_ERROR, get_tag(), "[Player ERROR] uid(%d) is not valid", uid); 
-               return -1;
-       }
-
-       MMPlayerStateType player_state;
-       mm_player_get_state(current->player_handle, &player_state);
-
-       SLOG(LOG_DEBUG, get_tag(), "[PLAYER] State changed : state(%d)", player_state);
-
-       /* destroy player */
-       switch (player_state) {
-               case MM_PLAYER_STATE_PLAYING:
-                       *state = TTSD_PLAYER_STATE_PLAYING;
-                       break;
-               case MM_PLAYER_STATE_PAUSED:
-                       *state = TTSD_PLAYER_STATE_PAUSED;
-                       break;
-               
-               case MM_PLAYER_STATE_NULL:
-                       *state = TTSD_PLAYER_STATE_NULL;
-                       break;
-
-               case MM_PLAYER_STATE_READY:
-               default:
-                       SECURE_SLOG(LOG_ERROR, get_tag(), "[Player ERROR] player state of uid(%d) is not valid", uid); 
-                       return -1;
-                       break;
-       }
-
-       return 0;
-}
-
-int ttsd_player_get_current_client()
-{
-       if (false == g_player_init) {
-               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized" );
-               return -1;
-       }
+       current->state = APP_STATE_PLAYING;
+       g_playing_info = current;
 
-       if (NULL != g_playing_info) 
-               return g_playing_info->uid;
-
-       SLOG(LOG_WARN, get_tag(), "[Player WARNING] No current player"); 
+       SLOG(LOG_DEBUG, get_tag(), "[Player] Run thread");
+       ecore_thread_run(__play_thread, __end_play_thread, NULL, NULL);
 
        return 0;
 }
 
-int ttsd_player_get_current_utterance_id(int uid)
-{
-       SECURE_SLOG(LOG_DEBUG, get_tag(), "[Player] get current utt id : uid(%d)", uid );
-
-       if (false == g_player_init) {
-               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized" );
-               return -1;
-       }
-
-       /* Check uid */
-       player_s* current;
-       current = __player_get_item(uid);
-       if (NULL == current) {
-               SECURE_SLOG(LOG_ERROR, get_tag(), "[Player ERROR] uid(%d) is not valid", uid); 
-               return -1;
-       }
-
-       return current->utt_id;
-}
-
 int ttsd_player_all_stop()
 {
        if (false == g_player_init) {
@@ -648,7 +715,6 @@ int ttsd_player_all_stop()
 
        g_playing_info = NULL;
 
-       int ret = -1;
        GList *iter = NULL;
        player_s *data = NULL;
 
@@ -662,473 +728,33 @@ int ttsd_player_all_stop()
 
                        app_state_e state;
                        if (0 > ttsd_data_get_client_state(data->uid, &state)) {
-                               SLOG(LOG_ERROR, get_tag(), "[player ERROR] ttsd_player_all_stop : uid is not valid ");
+                               SLOG(LOG_ERROR, get_tag(), "[player ERROR] uid(%d) is not valid", data->uid);
                                ttsd_player_destroy_instance(data->uid);
                                iter = g_list_next(iter);
                                continue;
                        }
 
                        if (APP_STATE_PLAYING == state || APP_STATE_PAUSED == state) {
-                               /* unrealize player */
-                               ret = mm_player_unrealize(data->player_handle);
-                               if (MM_ERROR_NONE != ret) {
-                                       SLOG(LOG_ERROR, get_tag(), "[Player ERROR] fail mm_player_unrealize() : %x", ret);
-                               } 
-
-                               data->utt_id = -1;
                                data->event = TTSP_RESULT_EVENT_FINISH;
-                       }
-                       
-                       /* Get next item */
-                       iter = g_list_next(iter);
-               }
-       }
-
-       SLOG(LOG_DEBUG, get_tag(), "[Player SUCCESS] player all stop!! ");
-
-       return 0;
-}
-
-static Eina_Bool __player_next_play(void *data)
-{
-       SLOG(LOG_DEBUG, get_tag(), "===== PLAYER NEXT PLAY");
-
-       int* uid = (int*)data;
-
-       if (NULL == uid) {
-               SLOG(LOG_ERROR, get_tag(), "[PLAYER ERROR] uid is NULL");
-               SLOG(LOG_DEBUG, get_tag(), "=====");
-               SLOG(LOG_DEBUG, get_tag(), "  ");
-               return EINA_FALSE;
-       }
-
-       SECURE_SLOG(LOG_DEBUG, get_tag(), "[PLAYER] uid = %d", *uid);
-       
-       if (0 != __ttsd_player_next_play(*uid)) {
-               SLOG(LOG_WARN, get_tag(), "[PLAYER WARNING] Fail to play next");
-       }
-
-       free(uid);
-
-       SLOG(LOG_DEBUG, get_tag(), "=====");
-       SLOG(LOG_DEBUG, get_tag(), "  ");
-
-       return EINA_FALSE;
-}
-
-static int msg_callback(int message, void *data, void *user_param) 
-{
-       user_data_s* user_data = NULL;
-
-       user_data = (user_data_s*)user_param;
-
-       if (NULL == user_data) {
-               SLOG(LOG_ERROR, get_tag(), "[PLAYER ERROR] user_param is NULL");
-               return -1;
-       }
-
-       int uid = user_data->uid;
-       int utt_id = user_data->utt_id;
-
-       MMMessageParamType *msg = (MMMessageParamType*)data;
-
-       switch (message) {
-       case MM_MESSAGE_ERROR:
-               {
-                       SLOG(LOG_DEBUG, get_tag(), "===== PLAYER ERROR CALLBACK");
-                       SECURE_SLOG(LOG_ERROR, get_tag(), "[PLAYER ERROR] Info : uid(%d), utt id(%d), error file(%s)", uid, utt_id, user_data->filename);
-
-                       /* send error info */
-                       g_result_callback(PLAYER_ERROR, uid, utt_id);
-
-                       player_s* current;
-                       current = __player_get_item(uid);
-                       if (NULL == current) {
-                               SECURE_SLOG(LOG_ERROR, get_tag(), "[PLAYER ERROR] uid(%d) is NOT valid ", uid); 
-                       } else {
-                               current->event = TTSP_RESULT_EVENT_FINISH;
-                       }
-
-                       if (NULL != user_data) 
-                               g_free(user_data);
-
-                       /* check current player */
-                       if (NULL != g_playing_info) {
-                               if (uid == g_playing_info->uid) {
-                                       g_playing_info = NULL;
-                                       SECURE_SLOG(LOG_WARN, get_tag(), "[PLAYER] Current Player is NOT uid(%d)", uid);
-                               }
-                       }
-
-                       SLOG(LOG_DEBUG, get_tag(), "=====");
-                       SLOG(LOG_DEBUG, get_tag(), "  ");
-               }
-               break;  /*MM_MESSAGE_ERROR*/
+                               data->state = APP_STATE_READY;
 
-       case MM_MESSAGE_BEGIN_OF_STREAM:
-
-               break;
-
-       case MM_MESSAGE_END_OF_STREAM:
-               {
-                       SLOG(LOG_DEBUG, get_tag(), "===== END OF STREAM CALLBACK");
-
-                       if (-1 == remove(user_data->filename)) {
-                               SECURE_SLOG(LOG_WARN, get_tag(), "[PLAYER WARNING] Fail to remove temp file", user_data->filename); 
-                       }
-
-                       /* Check uid */
-                       player_s* current;
-                       current = __player_get_item(uid);
-                       if (NULL == current) {
-                               SECURE_SLOG(LOG_ERROR, get_tag(), "[PLAYER ERROR] uid(%d) is NOT valid", uid); 
-                               if (NULL != g_playing_info) {
-                                       if (uid == g_playing_info->uid) {
-                                               g_playing_info = NULL;
-                                               SECURE_SLOG(LOG_WARN, get_tag(), "[PLAYER] Current Player is NOT uid(%d)", uid);
+                               if (true == data->is_paused_data) {
+                                       if (NULL != data->paused_data.data) {
+                                               free(data->paused_data.data);
+                                               data->paused_data.data = NULL;
                                        }
                                }
-                               SLOG(LOG_DEBUG, get_tag(), "=====");
-                               SLOG(LOG_DEBUG, get_tag(), "  ");
-                               return -1;
-                       }
-
-                       g_free(user_data);
-
-                       int pid = ttsd_data_get_pid(uid);
-
-                       /* send utterence finish signal */
-                       if (TTSP_RESULT_EVENT_FINISH == current->event) {
-                               if (0 == ttsdc_send_utt_finish_message(pid, uid, utt_id))
-                                       SECURE_SLOG(LOG_DEBUG, get_tag(), "[Send SUCCESS] Send Utterance Completed Signal : pid(%d), uid(%d), uttid(%d)", pid, uid, utt_id);
-                               else 
-                                       SECURE_SLOG(LOG_ERROR, get_tag(), "[Send ERROR] Fail to send Utterance Completed Signal : pid(%d), uid(%d), uttid(%d)", pid, uid, utt_id);
+                               
+                               data->is_paused_data = false;
+                               data->idx = 0;
                        }
-
-                       /* for sync problem */
-                       MMPlayerStateType player_state;
-                       mm_player_get_state(current->player_handle, &player_state);
                        
-                       if (MM_PLAYER_STATE_PAUSED == player_state) {
-                               /* The current state of player is 'Paused' */
-                               current->pause_after_complete = true;
-                       } else {
-                               /* play state */
-                               int* uid_data = (int*) g_malloc0(sizeof(int));
-                               *uid_data = uid;
-
-                               SECURE_SLOG(LOG_DEBUG, get_tag(), "[PLAYER] uid = %d", *uid_data);
-
-                               ecore_timer_add(0, __player_next_play, (void*)uid_data);
-                       }
-
-                       SLOG(LOG_DEBUG, get_tag(), "=====");
-                       SLOG(LOG_DEBUG, get_tag(), "  ");
-               }
-               break;  /*MM_MESSAGE_END_OF_STREAM*/
-
-       case MM_MESSAGE_STATE_CHANGED:
-               break;
-
-       case MM_MESSAGE_STATE_INTERRUPTED:
-               if (MM_PLAYER_STATE_PAUSED == msg->state.current) {
-
-                       SLOG(LOG_DEBUG, get_tag(), "===== INTERRUPTED CALLBACK");
-
-                       ttsd_data_set_client_state(uid, APP_STATE_PAUSED);
-
-                       int pid = ttsd_data_get_pid(uid);
-                       /* send message to client about changing state */
-                       ttsdc_send_set_state_message (pid, uid, APP_STATE_PAUSED);
-
-                       SLOG(LOG_DEBUG, get_tag(), "=====");
-                       SLOG(LOG_DEBUG, get_tag(), "  ");
-               }
-               break;
-
-       default:
-               break;
-       }
-
-       return TRUE;
-}
-
-player_s* __player_get_item(int uid)
-{
-       GList *iter = NULL;
-       player_s *data = NULL;
-
-       if (0 < g_list_length(g_player_list)) {
-               /* Get a first item */
-               iter = g_list_first(g_player_list);
-
-               while (NULL != iter) {
-                       /* Get handle data from list */
-                       data = (player_s*)iter->data;
-
-                       /* compare uid */
-                       if (uid == data->uid)   
-                               return data;
-
                        /* Get next item */
                        iter = g_list_next(iter);
                }
        }
 
-       return NULL;
-}
-
-int __save_file(int uid, int index, sound_data_s data, char** filename)
-{
-       char postfix[5];
-       memset(postfix, '\0', 5);
-
-       switch (data.audio_type) {
-       case TTSP_AUDIO_TYPE_RAW:
-       case TTSP_AUDIO_TYPE_WAV:
-               strcpy(postfix, "wav");
-               break;
-       case TTSP_AUDIO_TYPE_MP3:
-               strcpy(postfix, "mp3");
-               break;
-       case TTSP_AUDIO_TYPE_AMR:
-               strcpy(postfix, "amr");
-               break;
-       default:
-               SECURE_SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Audio type(%d) is NOT valid", data.audio_type); 
-               return -1;
-       }
-
-       /* make filename to save */
-       char* temp;
-       temp = (char*)g_malloc0(sizeof(char) * FILE_PATH_SIZE);
-       if (NULL == temp) {
-               SLOG(LOG_ERROR, get_tag(), "[Player Error] make buf is failed");
-               return -1;
-       }
-
-       int ret = snprintf(temp, FILE_PATH_SIZE, "%s/ttstemp%d_%d.%s", TEMP_FILE_PATH, uid, index, postfix);
-
-       if (0 >= ret) {
-               if (NULL != temp)
-                       g_free(temp);
-               return -1;
-       }
-
-       FILE* fp;
-       fp = fopen(temp, "wb");
-
-       if (fp == NULL) {
-               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] temp file open error");
-               if (NULL != temp)
-                       g_free(temp);
-               return -1;
-       }
-
-       if (data.audio_type == TTSP_AUDIO_TYPE_RAW) {
-               WavHeader header;
-               if (0 != __init_wave_header(&header, data.data_size, data.rate, data.channels)) {
-                       fclose(fp);
-                       if (NULL != temp)
-                               g_free(temp);
-                       return -1;
-               }
-
-               if (0 >= fwrite(&header, sizeof(WavHeader), 1, fp)) {
-                       SLOG(LOG_ERROR, get_tag(), "[Player ERROR] fail to write wav header to file");
-                       fclose(fp);
-                       if (NULL != temp)
-                               g_free(temp);
-                       return -1;
-               }
-       }
-
-       int size = fwrite(data.data, data.data_size, 1,  fp);
-       if (size <= 0) {
-               size = fwrite("0000000000", DEFAULT_FILE_SIZE, 1,  fp);
-               if (size <= 0) {
-                       SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Fail to write date");
-                       fclose(fp);
-                       if (NULL != temp)
-                               g_free(temp);
-                       return -1;
-               }       
-       } 
-
-       fclose(fp);
-       *filename = temp;
-       
-       SLOG(LOG_DEBUG, get_tag(), " ");
-       SECURE_SLOG(LOG_DEBUG, get_tag(), "Filepath : %s ", *filename);
-       SECURE_SLOG(LOG_DEBUG, get_tag(), "Header : Data size(%d), Sample rate(%d), Channel(%d) ", data.data_size, data.rate, data.channels);
-
-       return 0;
-}
-
-int __init_wave_header (WavHeader* hdr, size_t nsamples, size_t sampling_rate, int channel)
-{
-       if (hdr == NULL || sampling_rate <= 0 || channel <= 0) {
-               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] __init_wave_header : input parameter invalid");
-               SECURE_SLOG(LOG_ERROR, get_tag(), "[Player ERROR] hdr : %p", hdr);
-               SECURE_SLOG(LOG_ERROR, get_tag(), "[Player ERROR] nsample : %d", nsamples);
-               SECURE_SLOG(LOG_ERROR, get_tag(), "[Player ERROR] sampling_rate : %", sampling_rate);
-               SECURE_SLOG(LOG_ERROR, get_tag(), "[Player ERROR] channel : %", channel);
-               return TTSD_ERROR_INVALID_PARAMETER;
-       }
-
-       size_t bytesize = DEFAULT_FILE_SIZE;
-
-       if (0 < nsamples) {
-               bytesize = nsamples;    
-       } 
-
-       /* NOT include \0(NULL) */
-       strncpy(hdr->riff, "RIFF", 4);  
-       hdr->file_size = (int)(bytesize  + 36);
-       strncpy(hdr->wave, "WAVE", 4);
-       strncpy(hdr->fmt, "fmt ", 4);   /* fmt + space */
-       hdr->header_size = 16;
-       hdr->sample_format = 1;         /* WAVE_FORMAT_PCM */
-       hdr->n_channels = channel;
-       hdr->sample_rate = (int)(sampling_rate);
-       hdr->bytes_per_second = (int)sampling_rate * sizeof(short);
-       hdr->block_align =  sizeof(short);
-       hdr->bits_per_sample = sizeof(short)*8;
-       strncpy(hdr->data, "data", 4);  
-       hdr->data_size = (int)bytesize;
+       SLOG(LOG_DEBUG, get_tag(), "[Player SUCCESS] player all stop!!");
 
        return 0;
 }
-
-int __set_and_start(player_s* player)
-{
-       /* get sound data */
-       sound_data_s wdata;
-       if (0 != ttsd_data_get_sound_data(player->uid, &wdata)) {
-               SECURE_SLOG(LOG_WARN, get_tag(), "[Player WARNING] A sound queue of current player(%d) is empty", player->uid); 
-               return -1;
-       }
-
-       g_index++;
-       if (10000 <= g_index)   {
-               g_index = 1;
-       }
-
-       int ret;
-
-       /* make sound file for mmplayer */
-       char* sound_file = NULL;
-       ret = __save_file(player->uid, g_index, wdata, &sound_file);
-       if (0 != ret || NULL == sound_file) {
-               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] fail to make sound file");
-               return -1;
-       }
-       
-       user_data_s* user_data = (user_data_s*)g_malloc0(sizeof(user_data_s));
-       user_data->uid = player->uid;
-       user_data->utt_id = wdata.utt_id;
-       user_data->event = wdata.event;
-       memset(user_data->filename, 0, TEMP_FILE_MAX); 
-       strncpy( user_data->filename, sound_file, strlen(sound_file) );
-
-       SECURE_SLOG(LOG_DEBUG, get_tag(), "Info : uid(%d), utt(%d), filename(%s) , event(%d)", 
-               user_data->uid, user_data->utt_id, user_data->filename, user_data->event);
-       SLOG(LOG_DEBUG, get_tag(), " ");
-
-       
-       /* set callback func */
-       ret = mm_player_set_message_callback(player->player_handle, msg_callback, (void*)user_data);
-       if (MM_ERROR_NONE != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Fail mm_player_set_message_callback() : %x ", ret);
-               if (NULL != user_data)  g_free(user_data);
-               return -1;
-       }
-
-       /* set playing info to mm player */
-       char* err_attr_name = NULL;
-
-       if (0 != access(sound_file, R_OK)) {
-               SECURE_SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Fail to read sound file (%s)", sound_file);
-               if (NULL != user_data)  g_free(user_data);
-               return -1;
-       }
-
-       ret = mm_player_set_attribute(player->player_handle, &err_attr_name,
-               "profile_uri", sound_file , strlen(sound_file) + 1,
-               "sound_volume_type", MM_SOUND_VOLUME_TYPE_MEDIA,
-               "sound_route", MM_AUDIOROUTE_PLAYBACK_NORMAL,
-               NULL );
-
-       if (MM_ERROR_NONE != ret) {
-               if (NULL != err_attr_name) {
-                       SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Fail mm_player_set_attribute() : msg(%s), result(%x) ", err_attr_name, ret);
-               }
-               if (NULL != user_data)  g_free(user_data);
-               return -1;
-       }
-
-       if (TTSD_MODE_DEFAULT != ttsd_get_mode()) {
-               ret = mm_player_ignore_session(player->player_handle);
-               if (MM_ERROR_NONE != ret) {
-                       SLOG(LOG_WARN, get_tag(), "[Player WARNING] fail mm_player_ignore_session() : %x", ret);
-               }
-       }
-       
-       /* realize and start mm player */ 
-       ret = mm_player_realize(player->player_handle);
-       if (MM_ERROR_NONE != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] fail mm_player_realize() : %x", ret);
-
-               if (NULL != user_data)  g_free(user_data);
-               return -2;
-       }
-
-       ret = mm_player_start(player->player_handle);
-       if (MM_ERROR_NONE != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Player ERROR] fail mm_player_start() : %x", ret);
-               mm_player_unrealize(player->player_handle);
-
-               int reason;
-               if (MM_ERROR_POLICY_BLOCKED == ret) {
-                       SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Blocked to start player by policy : %x", ret);
-                       reason = TTSD_ERROR_AUDIO_POLICY_BLOCKED;
-               } else {
-                       reason = TTSD_ERROR_OPERATION_FAILED;
-               }
-
-               if (NULL != user_data) {
-                       ttsd_data_set_error_data(user_data->uid, user_data->utt_id, reason);
-                       g_free(user_data);
-               }
-               return -3;
-       }
-
-       /* If wdata's event is 'start', current wdata is first data of engine for synthesis. 
-        * If wdata's event is 'finish', player should check previous event to know whether this wdata is first or not.
-        * When previous wdata's event is 'finish' and current wdata's event is 'finish', 
-        * the player should send utt started event. 
-        */
-       if (TTSP_RESULT_EVENT_START == wdata.event ||
-           (TTSP_RESULT_EVENT_FINISH == player->event && TTSP_RESULT_EVENT_FINISH == wdata.event)) {
-               int pid;
-               pid = ttsd_data_get_pid(player->uid);
-
-               /* send utterance start message */
-               if (0 != ttsdc_send_utt_start_message(pid, player->uid, wdata.utt_id)) {
-                       SECURE_SLOG(LOG_ERROR, get_tag(), "[Send ERROR] Fail to send Utterance Start Signal : pid(%d), uid(%d), uttid(%d)", pid, player->uid, wdata.utt_id);
-               }
-       } else {
-               SLOG(LOG_DEBUG, get_tag(), "[PLAYER] Don't need to send Utterance Start Signal");
-       }
-
-       g_playing_info = player;
-
-       if (NULL != sound_file) 
-               g_free(sound_file);
-       if (NULL != wdata.data) 
-               g_free(wdata.data);
-
-       return 0;
-}
-
-
index fb73bb5..5fcbbe5 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*  Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd All Rights Reserved 
+*  Copyright (c) 2011-2014 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
@@ -31,13 +31,11 @@ typedef enum {
        TTSD_PLAYER_STATE_PLAYING
 }ttsd_player_state_e;
 
-typedef int (*player_result_callback_func)(player_event_e event, int uid, int utt_id);
-
 /*
 * TTSD Player Interfaces 
 */
 
-int ttsd_player_init(player_result_callback_func result_cb);
+int ttsd_player_init();
 
 int ttsd_player_release(void);
 
@@ -53,12 +51,6 @@ int ttsd_player_pause(int uid);
 
 int ttsd_player_resume(int uid);
 
-int ttsd_player_get_state(int uid, ttsd_player_state_e* state);
-
-int ttsd_player_get_current_client();
-
-int ttsd_player_get_current_utterance_id(int uid);
-
 int ttsd_player_all_stop();
 
 #ifdef __cplusplus
index b7c0c9f..95566f9 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*  Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd All Rights Reserved 
+*  Copyright (c) 2011-2014 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
 *  limitations under the License.
 */
 
+#include <aul.h>
 #include <Ecore.h>
-#include "ttsd_main.h"
-#include "ttsd_player.h"
+
+#include "ttsd_config.h"
 #include "ttsd_data.h"
+#include "ttsd_dbus.h"
+#include "ttsd_dbus_server.h"
 #include "ttsd_engine_agent.h"
+#include "ttsd_main.h"
+#include "ttsd_network.h"
+#include "ttsd_player.h"
 #include "ttsd_server.h"
-#include "ttsd_dbus_server.h"
 #include "ttsp.h"
-#include "ttsd_dbus.h"
-#include "ttsd_config.h"
-#include "ttsd_network.h"
+
 
 typedef enum {
        TTSD_SYNTHESIS_CONTROL_DOING    = 0,
@@ -42,46 +45,36 @@ static ttsd_synthesis_control_e     g_synth_control;
 
 static Ecore_Timer* g_wait_timer = NULL;
 
-/* Function definitions */
-int __server_next_synthesis(int uid);
+static utterance_t g_utt;
 
+/* Function definitions */
+static int __synthesis(int uid);
 
-int __server_set_synth_control(ttsd_synthesis_control_e control)
+static int __server_set_synth_control(ttsd_synthesis_control_e control)
 {
        g_synth_control = control;
        return 0;
 }
 
-ttsd_synthesis_control_e __server_get_synth_control()
+static ttsd_synthesis_control_e __server_get_synth_control()
 {
        return g_synth_control;
 }
 
-int __server_send_error(int uid, int utt_id, int error_code)
-{
-       int pid = ttsd_data_get_pid(uid);
-
-       /* send error */
-       if ( 0 != ttsdc_send_error_message(pid, uid, utt_id, error_code)) {
-               ttsd_data_delete_client(uid);                   
-       } 
-       
-       return 0;
-}
-
-Eina_Bool __wait_synthesis(void *data)
+static Eina_Bool __wait_synthesis(void *data)
 {
        /* get current play */
-       int uid = ttsd_data_is_current_playing();
+       int uid = ttsd_data_get_current_playing();
 
        if (uid > 0) {
                if (TTSD_SYNTHESIS_CONTROL_DOING == __server_get_synth_control()) {
+                       usleep(100000);
                        return EINA_TRUE;
                } else {
                        g_wait_timer = NULL;
                        if (TTSD_SYNTHESIS_CONTROL_DONE == __server_get_synth_control()) {
                                /* Start next synthesis */
-                               __server_next_synthesis(uid);
+                               __synthesis(uid);
                        }
                }       
        } else {
@@ -91,39 +84,42 @@ Eina_Bool __wait_synthesis(void *data)
        return EINA_FALSE;
 }
 
-int __synthesis(int uid)
+static int __synthesis(int uid)
 {
+       SLOG(LOG_DEBUG, get_tag(), "===== SYNTHESIS  START");
+
        speak_data_s sdata;
        if (0 == ttsd_data_get_speak_data(uid, &sdata)) {
 
-               utterance_t* utt = (utterance_t*)g_malloc0(sizeof(utterance_t));
+               if (NULL == sdata.lang || NULL == sdata.text) {
+                       SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Current data is NOT valid");
+                       ttsd_server_stop(uid);
+                       
+                       int pid = ttsd_data_get_pid(uid);
+                       ttsdc_send_set_state_message(pid, uid, APP_STATE_READY);
 
-               if (NULL == utt) {
-                       SLOG(LOG_ERROR, get_tag(), "[Server ERROR][%s] fail to allocate memory : utterance ", __FUNCTION__);
-                       return TTSD_ERROR_OUT_OF_MEMORY;
+                       if (NULL != sdata.lang) free(sdata.lang);
+                       
+                       return 0;
                }
 
-               utt->uid = uid;
-               utt->uttid = sdata.utt_id;
+               g_utt.uid = uid;
+               g_utt.uttid = sdata.utt_id;
 
                SLOG(LOG_DEBUG, get_tag(), "-----------------------------------------------------------");
-               SLOG(LOG_DEBUG, get_tag(), "ID : uid (%d), uttid(%d) ", utt->uid, utt->uttid );
-               SLOG(LOG_DEBUG, get_tag(), "Voice : langauge(%s), type(%d), speed(%d)", sdata.lang, sdata.vctype, sdata.speed);
-               SLOG(LOG_DEBUG, get_tag(), "Text : %s", sdata.text);
+               SECURE_SLOG(LOG_DEBUG, get_tag(), "ID : uid (%d), uttid(%d) ", g_utt.uid, g_utt.uttid);
+               SECURE_SLOG(LOG_DEBUG, get_tag(), "Voice : langauge(%s), type(%d), speed(%d)", sdata.lang, sdata.vctype, sdata.speed);
+               SECURE_SLOG(LOG_DEBUG, get_tag(), "Text : %s", sdata.text);
                SLOG(LOG_DEBUG, get_tag(), "-----------------------------------------------------------");
 
                int ret = 0;
                __server_set_synth_control(TTSD_SYNTHESIS_CONTROL_DOING);
-               ret = ttsd_engine_start_synthesis(sdata.lang, sdata.vctype, sdata.text, sdata.speed, (void*)utt);
+               ret = ttsd_engine_start_synthesis(sdata.lang, sdata.vctype, sdata.text, sdata.speed, NULL);
                if (0 != ret) {
-                       SLOG(LOG_ERROR, get_tag(), "[Server ERROR][%s] * FAIL to start SYNTHESIS !!!! * ", __FUNCTION__);
+                       SLOG(LOG_ERROR, get_tag(), "[Server ERROR] * FAIL to start SYNTHESIS !!!! * ");
 
                        __server_set_synth_control(TTSD_SYNTHESIS_CONTROL_DONE);
 
-                       ttsd_config_save_error(utt->uid, utt->uttid, sdata.lang, sdata.vctype, sdata.text, __FUNCTION__, __LINE__, "fail to start synthesis");
-
-                       g_free(utt);
-
                        ttsd_server_stop(uid);
 
                        int pid = ttsd_data_get_pid(uid);
@@ -132,68 +128,11 @@ int __synthesis(int uid)
                        g_wait_timer = ecore_timer_add(0, __wait_synthesis, NULL);
                }
 
-               if(sdata.text != NULL)  
-                       g_free(sdata.text);
-       } else {
-               SLOG(LOG_DEBUG, get_tag(), "[Server] --------------------");
-               SLOG(LOG_DEBUG, get_tag(), "[Server] Text queue is empty.");
-               SLOG(LOG_DEBUG, get_tag(), "[Server] --------------------");
-       }
-
-       return 0;
-}
-
-int __server_next_synthesis(int uid)
-{
-       SLOG(LOG_DEBUG, get_tag(), "===== NEXT SYNTHESIS & PLAY START");
-
-       /* get current playing client */
-       int current_uid = ttsd_data_get_current_playing();
-
-       if (0 > current_uid) {
-               SLOG(LOG_WARN, get_tag(), "[Server WARNING] Current uid is not valid");
-               SLOG(LOG_DEBUG, get_tag(), "=====");
-               SLOG(LOG_DEBUG, get_tag(), "  ");
-               return 0;
-       }
-
-       if (TTSD_SYNTHESIS_CONTROL_DOING == __server_get_synth_control()) {
-               SLOG(LOG_WARN, get_tag(), "[Server WARNING] Engine has already been running. ");
-               SLOG(LOG_DEBUG, get_tag(), "=====");
-               SLOG(LOG_DEBUG, get_tag(), "  ");
-               return 0;
+               free(sdata.lang);
+               free(sdata.text);
        }
 
-       __synthesis(current_uid);
-
-       if (0 != ttsd_player_play(current_uid)) {
-               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to play sound");
-
-               int pid;
-               int uid;
-               int uttid;
-               int reason;
-               if (0 == ttsd_data_get_error_data(&uid, &uttid, &reason)) {
-                       if (current_uid == uid) {
-                               /* Send error message */
-                               pid = ttsd_data_get_pid(uid);
-                               ttsdc_send_error_message(pid, uid, uttid, reason);
-                       } else {
-                               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Not matched uid : uid(%d) uttid(%d) reason(%d)", uid, uttid, reason);
-                       }
-               }
-
-               /* Change ready state */
-               ttsd_server_stop(current_uid);
-               
-               pid = ttsd_data_get_pid(current_uid);
-               ttsdc_send_set_state_message(pid, current_uid, APP_STATE_READY);
-       } else {
-               /* success playing */
-               SLOG(LOG_DEBUG, get_tag(), "[Server] Success to start player");
-       }
-
-       SLOG(LOG_DEBUG, get_tag(), "===== NEXT SYNTHESIS & PLAY END");
+       SLOG(LOG_DEBUG, get_tag(), "===== SYNTHESIS  END");
        SLOG(LOG_DEBUG, get_tag(), "  ");
 
        return 0;
@@ -202,47 +141,13 @@ int __server_next_synthesis(int uid)
 /*
 * TTS Server Callback Functions        
 */
-
-int __player_result_callback(player_event_e event, int uid, int utt_id)
-{
-       switch(event) {
-       case PLAYER_ERROR:
-               SLOG(LOG_ERROR, get_tag(), "[SERVER ERROR][%s] player result error", __FUNCTION__);
-               ttsd_config_save_error(uid, utt_id, NULL, -1, NULL, __FUNCTION__, __LINE__, "PLAYER_ERROR");
-
-       case PLAYER_EMPTY_SOUND_QUEUE:
-               /* check whether synthesis is running */
-               if (TTSD_SYNTHESIS_CONTROL_DONE == __server_get_synth_control()) {
-                       /* check text queue is empty */
-                       if (0 == ttsd_data_get_speak_data_size(uid) && 0 == ttsd_data_get_sound_data_size(uid)) {
-                               SLOG(LOG_DEBUG, get_tag(), "[SERVER Callback] all play completed ");
-                       }
-               } 
-               break;
-       
-       case PLAYER_END_OF_PLAYING:
-               break;
-       }
-
-       return 0;
-}
-
-int __synthesis_result_callback(ttsp_result_event_e event, const void* data, unsigned int data_size, void *user_data)
+int __synthesis_result_callback(ttsp_result_event_e event, const void* data, unsigned int data_size, 
+                               ttsp_audio_type_e audio_type, int rate, void *user_data)
 {
        SLOG(LOG_DEBUG, get_tag(), "===== SYNTHESIS RESULT CALLBACK START");
 
-       utterance_t* utt_get_param;
-       utt_get_param = (utterance_t*)user_data;
-
-       if (NULL == utt_get_param) {
-               SLOG(LOG_ERROR, get_tag(), "[SERVER ERROR] User data is NULL " );
-               SLOG(LOG_DEBUG, get_tag(), "=====");
-               SLOG(LOG_DEBUG, get_tag(), "  ");
-               return -1;
-       }
-
-       int uid = utt_get_param->uid;
-       int uttid = utt_get_param->uttid;
+       int uid = g_utt.uid;
+       int uttid = g_utt.uttid;
 
        /* Synthesis is success */
        if (TTSP_RESULT_EVENT_START == event || TTSP_RESULT_EVENT_CONTINUE == event || TTSP_RESULT_EVENT_FINISH == event) {
@@ -252,73 +157,70 @@ int __synthesis_result_callback(ttsp_result_event_e event, const void* data, uns
                if (TTSP_RESULT_EVENT_FINISH == event)          SLOG(LOG_DEBUG, get_tag(), "[SERVER] Event : TTSP_RESULT_EVENT_FINISH");
 
                if (false == ttsd_data_is_uttid_valid(uid, uttid)) {
-                       SLOG(LOG_ERROR, get_tag(), "[SERVER ERROR] uttid is NOT valid !!!! - uid(%d), uttid(%d)", uid, uttid);
+                       __server_set_synth_control(TTSD_SYNTHESIS_CONTROL_DONE);
+                       SECURE_SLOG(LOG_ERROR, get_tag(), "[SERVER ERROR] uttid is NOT valid !!!! - uid(%d), uttid(%d)", uid, uttid);
                        SLOG(LOG_DEBUG, get_tag(), "=====");
                        SLOG(LOG_DEBUG, get_tag(), "  ");
-
                        return 0;
                }
 
-               SLOG(LOG_DEBUG, get_tag(), "[SERVER] Result Info : uid(%d), utt(%d), data(%p), data size(%d) ", 
-                       uid, uttid, data, data_size);
+               SECURE_SLOG(LOG_DEBUG, get_tag(), "[SERVER] Result Info : uid(%d), utt(%d), data(%p), data size(%d) audiotype(%d) rate(%d)", 
+                       uid, uttid, data, data_size, audio_type, rate);
+
+               if (rate <= 0 || audio_type < 0 || audio_type > TTSP_AUDIO_TYPE_MAX) {
+                       __server_set_synth_control(TTSD_SYNTHESIS_CONTROL_DONE);
+                       SECURE_SLOG(LOG_ERROR, get_tag(), "[SERVER ERROR] audio data is invalid");
+                       SLOG(LOG_DEBUG, get_tag(), "=====");
+                       SLOG(LOG_DEBUG, get_tag(), "  ");
+                       return 0;
+               }
 
                /* add wav data */
                sound_data_s temp_data;
-               temp_data.data = (char*)g_malloc0( sizeof(char) * data_size );
-               memcpy(temp_data.data, data, data_size);
+               temp_data.data = NULL;
+               temp_data.rate = 0;
+               temp_data.data_size = 0;
+
+               if (0 < data_size) {
+                       temp_data.data = (char*)calloc(data_size, sizeof(char));
+                       memcpy(temp_data.data, data, data_size);
+               } else {
+                       SLOG(LOG_ERROR, get_tag(), "Sound data is NULL");
+               }
 
                temp_data.data_size = data_size;
-               temp_data.utt_id = utt_get_param->uttid;
+               temp_data.utt_id = uttid;
                temp_data.event = event;
-
-               ttsp_audio_type_e audio_type;
-               int rate;
-               int channels;
-
-               if (ttsd_engine_get_audio_format(&audio_type, &rate, &channels)) {
-                       SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to get audio format ");
-                       SLOG(LOG_DEBUG, get_tag(), "=====");
-                       SLOG(LOG_DEBUG, get_tag(), "  ");
-                       return -1;
-               }
-               
                temp_data.audio_type = audio_type;
                temp_data.rate = rate;
-               temp_data.channels = channels;
                
                if (0 != ttsd_data_add_sound_data(uid, temp_data)) {
-                       SLOG(LOG_ERROR, get_tag(), "[SERVER ERROR] Fail to add sound data : uid(%d)", utt_get_param->uid);
+                       SECURE_SLOG(LOG_ERROR, get_tag(), "[SERVER ERROR] Fail to add sound data : uid(%d)", uid);
                }
 
                if (event == TTSP_RESULT_EVENT_FINISH) {
                        __server_set_synth_control(TTSD_SYNTHESIS_CONTROL_DONE);
                }
-       } else if (event == TTSP_RESULT_EVENT_CANCEL) {
-               SLOG(LOG_DEBUG, get_tag(), "[SERVER] Event : TTSP_RESULT_EVENT_CANCEL");
-               __server_set_synth_control(TTSD_SYNTHESIS_CONTROL_EXPIRED);
+
+               if (0 != ttsd_player_play(uid)) {
+                       SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to play sound : uid(%d)", uid);
+
+                       /* Change ready state */
+                       ttsd_server_stop(uid);
+
+                       int tmp_pid;
+                       tmp_pid = ttsd_data_get_pid(uid);
+                       ttsdc_send_set_state_message(tmp_pid, uid, APP_STATE_READY);
+               }
        } else {
                SLOG(LOG_DEBUG, get_tag(), "[SERVER] Event : TTSP_RESULT_EVENT_ERROR");
                __server_set_synth_control(TTSD_SYNTHESIS_CONTROL_EXPIRED);
        } 
 
-       if (TTSP_RESULT_EVENT_FINISH == event || TTSP_RESULT_EVENT_CANCEL == event || TTSP_RESULT_EVENT_FAIL == event) {
-               if (NULL != utt_get_param)              
-                       free(utt_get_param);
-       }
 
        SLOG(LOG_DEBUG, get_tag(), "===== SYNTHESIS RESULT CALLBACK END");
        SLOG(LOG_DEBUG, get_tag(), "  ");
 
-#if 0
-       if (true == __server_get_is_next_synthesis()) {
-               __server_set_is_next_synthesis(false);
-
-               /* Do NOT work ecore timer because of This function is thread callbacked */ 
-               /* need to send dbus message event */
-               ttsd_send_start_next_synthesis();
-       }
-#endif
-
        return 0;
 }
 
@@ -347,8 +249,18 @@ void __config_changed_cb(tts_config_type_e type, const char* str_param, int int_
                        return;
                }
 
+               int ret = 0;
                if (true == ttsd_engine_agent_is_same_engine(str_param)) {
-                       SLOG(LOG_DEBUG, get_tag(), "[Server Setting] new engine is the same as current engine ");
+                       SLOG(LOG_DEBUG, get_tag(), "[Server Setting] new engine is the same as current engine");
+                       ret = ttsd_engine_agent_unload_current_engine();
+                       if (0 != ret) {
+                               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to unload current engine : result(%d)", ret);
+                       }
+
+                       ret = ttsd_engine_agent_load_current_engine();
+                       if (0 != ret) {
+                               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to load current engine : result (%d)", ret);
+                       }
                        return;
                }
 
@@ -361,15 +273,14 @@ void __config_changed_cb(tts_config_type_e type, const char* str_param, int int_
                ttsd_engine_cancel_synthesis();
 
                /* set engine */
-               int ret = 0;
-               ret = ttsd_engine_setting_set_engine(str_param);
+               ret = ttsd_engine_agent_set_default_engine(str_param);
                if (0 != ret) {
-                       SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] fail to set current engine : result(%d) ", ret);
+                       SLOG(LOG_WARN, get_tag(), "[Server Setting WARNING] Fail to set current engine : result(%d)", ret);
                }
 
                break;
        }
-               
+
        case TTS_CONFIG_TYPE_VOICE:
        {
                if (NULL == str_param) {
@@ -377,45 +288,49 @@ void __config_changed_cb(tts_config_type_e type, const char* str_param, int int_
                        return;
                }
 
-               char* out_lang;
-               ttsp_voice_type_e out_type;
+               char* out_lang = NULL;
+               int out_type;
                int ret = -1;
 
                if (true == ttsd_engine_select_valid_voice(str_param, int_param, &out_lang, &out_type)) {
-                       SLOG(LOG_ERROR, get_tag(), "[Server] valid language : lang(%s), type(%d)", out_lang, out_type);
-                       ret = ttsd_engine_setting_set_default_voice(out_lang, out_type);
+                       SECURE_SLOG(LOG_ERROR, get_tag(), "[Server] valid language : lang(%s), type(%d)", out_lang, out_type);
+                       ret = ttsd_engine_agent_set_default_voice(out_lang, out_type);
                        if (0 != ret)
-                               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to set valid language : lang(%s), type(%d)", out_lang, out_type);
-
-                       if (NULL == out_lang)
-                               free(out_lang);
+                               SECURE_SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to set valid language : lang(%s), type(%d)", out_lang, out_type);
                } else {
                        /* Current language is not available */
-                       if (true == ttsd_engine_select_valid_voice("en_US", 2, &out_lang, &out_type)) {
-                               ret = ttsd_engine_setting_set_default_voice(out_lang, out_type);
-                               if (0 != ret) 
-                                       SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to set valid language : lang(%s), type(%d)", out_lang, out_type);
-
-                               if (NULL == out_lang)
-                                       free(out_lang);
-                       }
+                       SECURE_SLOG(LOG_WARN, get_tag(), "[Server WARNING] Fail to set voice : lang(%s), type(%d)", str_param, int_param);
                }
+               if (NULL != out_lang)   free(out_lang);
                break;
        }
-       
+
        case TTS_CONFIG_TYPE_SPEED:
        {
-               if (TTSP_SPEED_VERY_SLOW <= int_param && int_param <= TTSP_SPEED_VERY_FAST) {
+               if (TTS_SPEED_MIN <= int_param && int_param <= TTS_SPEED_MAX) {
                        /* set default speed */
                        int ret = 0;
-                       ret = ttsd_engine_setting_set_default_speed((ttsp_speed_e)int_param);
+                       ret = ttsd_engine_agent_set_default_speed(int_param);
                        if (0 != ret) {
-                               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] fail to set default speed : result(%d)", ret);
+                               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to set default speed : result(%d)", ret);
                        }       
                }
                break;
        }
-               
+
+       case TTS_CONFIG_TYPE_PITCH:
+       {
+               if (TTS_PITCH_MIN <= int_param && int_param <= TTS_PITCH_MAX) {
+                       /* set default speed */
+                       int ret = 0;
+                       ret = ttsd_engine_agent_set_default_pitch(int_param);
+                       if (0 != ret) {
+                               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to set default pitch : result(%d)", ret);
+                       }       
+               }
+               break;
+       }
+
        default:
                break;
        }
@@ -423,6 +338,29 @@ void __config_changed_cb(tts_config_type_e type, const char* str_param, int int_
        return;
 }
 
+bool __terminate_client(int pid, int uid, app_state_e state, void* user_data)
+{
+       SLOG(LOG_DEBUG, get_tag(), "=== Start to terminate client [%d] ===", uid);
+       ttsd_server_finalize(uid);
+       return true;
+}
+
+Eina_Bool ttsd_terminate_daemon(void *data) 
+{
+       ttsd_data_foreach_clients(__terminate_client, NULL);
+       return EINA_FALSE;
+}
+
+void __screen_reader_changed_cb(bool value)
+{
+       if (TTSD_MODE_SCREEN_READER == ttsd_get_mode() && false == value) {
+               SLOG(LOG_DEBUG, get_tag(), "[Server] Screen reader is OFF. Start to terminate tts daemon");
+               ecore_timer_add(1, ttsd_terminate_daemon, NULL);
+       } else {
+               SLOG(LOG_DEBUG, get_tag(), "[Server] Screen reader is %s", value ? "ON" : "OFF");
+       }
+       return;
+}
 
 /*
 * Server APIs
@@ -435,7 +373,7 @@ int ttsd_initialize()
        }
 
        /* player init */
-       if (ttsd_player_init(__player_result_callback)) {
+       if (ttsd_player_init()) {
                SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to initialize player init.");
                return TTSD_ERROR_OPERATION_FAILED;
        }
@@ -455,6 +393,12 @@ int ttsd_initialize()
        
        __server_set_synth_control(TTSD_SYNTHESIS_CONTROL_EXPIRED);
 
+       if (TTSD_MODE_SCREEN_READER == ttsd_get_mode()) {
+               ttsd_config_set_screen_reader_callback(__screen_reader_changed_cb);
+       }
+
+       ttsd_file_clean_up();
+
        return TTSD_ERROR_NONE;
 }
 
@@ -471,17 +415,26 @@ int ttsd_finalize()
 
 bool __get_client_for_clean_up(int pid, int uid, app_state_e state, void* user_data)
 {
-       int result = 1;
+       char appid[128] = {0, };
+       if (0 != aul_app_get_appid_bypid(pid, appid, sizeof(appid))) {
+               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to get app id");
+       }
 
-       result = ttsdc_send_hello(pid, uid);
+       if (0 < strlen(appid)) {
+               SECURE_SLOG(LOG_DEBUG, get_tag(), "[%d] is running app - %s", pid, appid);
+       } else {
+               SECURE_SLOG(LOG_DEBUG, get_tag(), "[%d] is daemon or no_running app", pid);
 
-       if (0 == result) {
-               SLOG(LOG_DEBUG, get_tag(), "[Server] uid(%d) should be removed.", uid); 
-               ttsd_server_finalize(uid);
-       } else if (-1 == result) {
-               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Hello result has error"); 
-       }
+               int result = 1;
+               result = ttsdc_send_hello(pid, uid);
 
+               if (0 == result) {
+                       SECURE_SLOG(LOG_DEBUG, get_tag(), "[Server] uid(%d) should be removed.", uid); 
+                       ttsd_server_finalize(uid);
+               } else if (-1 == result) {
+                       SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Hello result has error"); 
+               }
+       }
        return true;
 }
 
@@ -504,7 +457,7 @@ int ttsd_server_initialize(int pid, int uid)
 {
        if (false == g_is_engine) {
                if (0 != ttsd_engine_agent_initialize_current_engine()) {
-                       SLOG(LOG_WARN, get_tag(), "[Server WARNING] No Engine !!! " );
+                       SLOG(LOG_WARN, get_tag(), "[Server WARNING] No Engine !!!");
                        g_is_engine = false;
 
                        return TTSD_ERROR_ENGINE_NOT_FOUND;
@@ -514,34 +467,31 @@ int ttsd_server_initialize(int pid, int uid)
        }
 
        if (-1 != ttsd_data_is_client(uid)) {
-               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Uid has already been registered ");
-               return TTSD_ERROR_INVALID_PARAMETER;
+               SLOG(LOG_WARN, get_tag(), "[Server WARNING] Uid has already been registered");
+               return TTSD_ERROR_NONE;
        }
 
        if (0 == ttsd_data_get_client_count()) {
                if (0 != ttsd_engine_agent_load_current_engine()) {
-                       SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to load current engine ");
+                       SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to load current engine");
                        return TTSD_ERROR_OPERATION_FAILED;
                }
-               /* Check system language */
-               ttsd_config_update_language();
        }
 
        if (0 == ttsd_data_get_same_pid_client_count(pid)) {
-               SLOG(LOG_DEBUG, get_tag(), "[Server] open file msg connection");
                if (0 != ttsd_file_msg_open_connection(pid)) {
-                       SLOG(LOG_ERROR, get_tag(), "[Server ERROR] fail to open file message connection");
+                       SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to open file message connection");
                        return TTSD_ERROR_OPERATION_FAILED;
                }
        }
 
        if (0 != ttsd_data_new_client(pid, uid)) {
-               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to add client info ");
+               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to add client info");
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
        if (0 != ttsd_player_create_instance(uid)) {
-               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to create player ");
+               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to create player");
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
@@ -551,33 +501,45 @@ int ttsd_server_initialize(int pid, int uid)
 static Eina_Bool __quit_ecore_loop(void *data)
 {
        ecore_main_loop_quit();
-       SLOG(LOG_DEBUG, get_tag(), "[Server] quit ecore main loop");
        return EINA_FALSE;
 }
 
+void __used_voice_cb(const char* lang, int type)
+{
+       SLOG(LOG_DEBUG, get_tag(), "[Server] Request to unload voice (%s,%d)", lang, type);
+       if (0 != ttsd_engine_unload_voice(lang, type)) {
+               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to unload voice");
+       }
+}
+
 int ttsd_server_finalize(int uid)
 {
        app_state_e state;
        if (0 > ttsd_data_get_client_state(uid, &state)) {
-               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] ttsd_server_finalize : uid is not valid  ");
-               return TTSD_ERROR_INVALID_PARAMETER;
+               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] ttsd_server_finalize : uid is not valid");
        }
 
        ttsd_server_stop(uid);
        
        ttsd_player_destroy_instance(uid);
 
+       /* Need to unload voice when used voice is unregistered */
+       if (0 != ttsd_data_reset_used_voice(uid, __used_voice_cb)) {
+               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to set used voice");
+               return TTSD_ERROR_OPERATION_FAILED;
+       }
+
        int pid = ttsd_data_get_pid(uid);
 
        ttsd_data_delete_client(uid);
 
        if (0 == ttsd_data_get_same_pid_client_count(pid)) {
-               SLOG(LOG_DEBUG, get_tag(), "[Sever] File msg close connection");
                ttsd_file_msg_close_connection(pid);
        }
 
        /* unload engine, if ref count of client is 0 */
        if (0 == ttsd_data_get_client_count()) {
+               SLOG(LOG_DEBUG, get_tag(), "[Server] Quit main loop");
                ecore_timer_add(0, __quit_ecore_loop, NULL);
        }
 
@@ -588,37 +550,51 @@ int ttsd_server_add_queue(int uid, const char* text, const char* lang, int voice
 {
        app_state_e state;
        if (0 > ttsd_data_get_client_state(uid, &state)) {
-               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] ttsd_server_add_queue : uid is not valid  ");
+               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] ttsd_server_add_queue : uid is not valid");
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
        /* check valid voice */
        char* temp_lang = NULL;
-       ttsp_voice_type_e temp_type;
-       if (true != ttsd_engine_select_valid_voice((const char*)lang, (const ttsp_voice_type_e)voice_type, &temp_lang, &temp_type)) {
-               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to select valid voice ");
+       int temp_type;
+       if (true != ttsd_engine_select_valid_voice((const char*)lang, voice_type, &temp_lang, &temp_type)) {
+               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to select valid voice");
+               if (NULL != temp_lang)  free(temp_lang);
+               return TTSD_ERROR_INVALID_VOICE;
+       }
+
+       if (NULL == temp_lang) {
+               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to select valid voice : result lang is NULL");
                return TTSD_ERROR_INVALID_VOICE;
-       } else {                
-               if (NULL == temp_lang)
-                       free(temp_lang);
        }
        
        speak_data_s data;
 
        data.lang = strdup(lang);
-       data.vctype = (ttsp_voice_type_e)voice_type;
+       data.vctype = voice_type;
 
-       data.speed = (ttsp_speed_e)speed;
+       data.speed = speed;
        data.utt_id = utt_id;
-               
+
        data.text = strdup(text);
 
        /* if state is APP_STATE_READY , APP_STATE_PAUSED , only need to add speak data to queue*/
        if (0 != ttsd_data_add_speak_data(uid, data)) {
-               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] ttsd_server_add_queue : Current state of uid is not 'ready' ");
+               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to add speak data");
+               if (NULL != temp_lang)  free(temp_lang);
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
+       if (0 != ttsd_data_set_used_voice(uid, temp_lang, temp_type)) {
+               /* Request load voice */
+               SLOG(LOG_DEBUG, get_tag(), "[Server] Request to load voice");
+               if (0 != ttsd_engine_load_voice(temp_lang, temp_type)) {
+                       SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to load voice");
+               }
+       }
+
+       if (NULL != temp_lang)  free(temp_lang);
+
        if (APP_STATE_PLAYING == state) {
                /* check if engine use network */
                if (ttsd_engine_agent_need_network()) {
@@ -641,19 +617,17 @@ int ttsd_server_add_queue(int uid, const char* text, const char* lang, int voice
 
 Eina_Bool __send_interrupt_client(void *data)
 {
-       int* uid = (int*)data;
+       int uid = (int)data;
        
-       if (NULL != uid) {
-               int pid = ttsd_data_get_pid(*uid);
+       int pid = ttsd_data_get_pid(uid);
+
+       if (TTSD_MODE_DEFAULT != ttsd_get_mode()) {
+               /* send message to client about changing state */
+               ttsdc_send_set_state_message (pid, uid, APP_STATE_READY);
+       } else {
+               ttsdc_send_set_state_message (pid, uid, APP_STATE_PAUSED);
+       }
 
-               if (TTSD_MODE_SCREEN_READER == ttsd_get_mode()) {
-                       /* send message to client about changing state */
-                       ttsdc_send_set_state_message (pid, *uid, APP_STATE_READY);
-               } else {
-                       ttsdc_send_set_state_message (pid, *uid, APP_STATE_PAUSED);
-               }
-               free(uid);
-       }       
        return EINA_FALSE;
 }
 
@@ -661,12 +635,12 @@ int ttsd_server_play(int uid)
 {
        app_state_e state;
        if (0 > ttsd_data_get_client_state(uid, &state)) {
-               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] uid(%d) is NOT valid  ", uid);
+               SECURE_SLOG(LOG_ERROR, get_tag(), "[Server ERROR] uid(%d) is NOT valid  ", uid);
                return TTSD_ERROR_INVALID_PARAMETER;
        }
        
        if (APP_STATE_PLAYING == state) {
-               SLOG(LOG_WARN, get_tag(), "[Server WARNING] Current state(%d) is 'play' ", uid);
+               SECURE_SLOG(LOG_WARN, get_tag(), "[Server WARNING] Current state(%d) is 'play' ", uid);
                return TTSD_ERROR_NONE;
        }
 
@@ -681,69 +655,46 @@ int ttsd_server_play(int uid)
        int current_uid = ttsd_data_get_current_playing();
 
        if (uid != current_uid && -1 != current_uid) {
-               if (TTSD_MODE_SCREEN_READER == ttsd_get_mode()) {
+               if (TTSD_MODE_DEFAULT != ttsd_get_mode()) {
                        /* Send interrupt message */
-                       SLOG(LOG_DEBUG, get_tag(), "[Server] Old uid(%d) will be interrupted into 'Stop' state ", current_uid);
+                       SECURE_SLOG(LOG_DEBUG, get_tag(), "[Server] Old uid(%d) will be interrupted into 'Stop' state ", current_uid);
 
                        /* pause player */
                        if (0 != ttsd_server_stop(current_uid)) {
-                               SLOG(LOG_WARN, get_tag(), "[Server ERROR] fail to stop : uid (%d)", current_uid);
+                               SECURE_SLOG(LOG_WARN, get_tag(), "[Server ERROR] Fail to stop : uid (%d)", current_uid);
                        } 
                        
-                       int* temp_uid = (int*)malloc(sizeof(int));
-                       *temp_uid = current_uid;
-                       ecore_timer_add(0, __send_interrupt_client, temp_uid);
+                       ecore_timer_add(0, __send_interrupt_client, (void*)current_uid);
                } else {
+                       /* Default mode policy of interrupt is "Pause" */
+
                        /* Send interrupt message */
-                       SLOG(LOG_DEBUG, get_tag(), "[Server] Old uid(%d) will be interrupted into 'Pause' state ", current_uid);
+                       SECURE_SLOG(LOG_DEBUG, get_tag(), "[Server] Old uid(%d) will be interrupted into 'Pause' state ", current_uid);
 
                        /* pause player */
                        if (0 != ttsd_player_pause(current_uid)) {
-                               SLOG(LOG_WARN, get_tag(), "[Server ERROR] fail to ttsd_player_pause() : uid (%d)", current_uid);
-                       } 
+                               SECURE_SLOG(LOG_WARN, get_tag(), "[Server ERROR] Fail to ttsd_player_pause() : uid (%d)", current_uid);
+                       }
 
                        /* change state */
                        ttsd_data_set_client_state(current_uid, APP_STATE_PAUSED);
 
-                       int* temp_uid = (int*)malloc(sizeof(int));
-                       *temp_uid = current_uid;
-                       ecore_timer_add(0, __send_interrupt_client, temp_uid);
+                       ecore_timer_add(0, __send_interrupt_client, (void*)current_uid);
                }
        }
-       
+
        /* Change current play */
        if (0 != ttsd_data_set_client_state(uid, APP_STATE_PLAYING)) {
-               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to set state : uid(%d)", uid);
+               SECURE_SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to set state : uid(%d)", uid);
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
        if (APP_STATE_PAUSED == state) {
-               SLOG(LOG_DEBUG, get_tag(), "[Server] uid(%d) is 'Pause' state : Next step is resume player and start synthesis ", uid);
-
-               ttsd_player_state_e state;
-               if (0 != ttsd_player_get_state(uid, &state)) {
-                       SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to get player state : uid(%d)", uid);
-                       return TTSD_ERROR_OPERATION_FAILED;
-               }
+               SECURE_SLOG(LOG_DEBUG, get_tag(), "[Server] uid(%d) is 'Pause' state : resume player", uid);
 
-               if (TTSD_PLAYER_STATE_PAUSED == state) {
-                       /* Resume player */
-                       if (0 != ttsd_player_resume(uid)) {
-                               SLOG(LOG_WARN, get_tag(), "[Server WARNING] fail to ttsd_player_resume()");
-                       }
-               } else if (TTSD_PLAYER_STATE_NULL == state) {
-                       if (0 != ttsd_player_play(uid)) {
-                               SLOG(LOG_WARN, get_tag(), "[Server WARNING] Fail ttsd_player_play() ");
-                               
-                               /* Need to wait synthesis */
-                               if (NULL == g_wait_timer)
-                                       g_wait_timer = ecore_timer_add(0, __wait_synthesis, NULL);
-                       } else {
-                               /* success playing */
-                               SLOG(LOG_DEBUG, get_tag(), "[Server] Success to start player");
-                       }       
-               } else {
-                       /* error */
+               /* Resume player */
+               if (0 != ttsd_player_resume(uid)) {
+                       SLOG(LOG_WARN, get_tag(), "[Server WARNING] Fail to ttsd_player_resume()");
                }
        }
 
@@ -762,21 +713,13 @@ int ttsd_server_stop(int uid)
 {
        app_state_e state;
        if (0 > ttsd_data_get_client_state(uid, &state)) {
-               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] uid is not valid  ");
+               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] uid is not valid");
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
-       /* Reset all data */
-       ttsd_data_clear_data(uid);
-
        if (APP_STATE_PLAYING == state || APP_STATE_PAUSED == state) {
-               ttsd_data_set_client_state(uid, APP_STATE_READY);
-
-               if (0 != ttsd_player_stop(uid)) 
-                       SLOG(LOG_WARN, get_tag(), "[Server] Fail to ttsd_player_stop()");
-
                if (TTSD_SYNTHESIS_CONTROL_DOING == __server_get_synth_control()) {
-                       SLOG(LOG_DEBUG, get_tag(), "[Server] TTS-engine is running ");
+                       SLOG(LOG_DEBUG, get_tag(), "[Server] TTS-engine is running");
 
                        int ret = 0;
                        ret = ttsd_engine_cancel_synthesis();
@@ -785,10 +728,16 @@ int ttsd_server_stop(int uid)
                }
 
                __server_set_synth_control(TTSD_SYNTHESIS_CONTROL_EXPIRED);
-       } else {
-               SLOG(LOG_WARN, get_tag(), "[Server WARNING] Current state is 'ready' ");
+
+               if (0 != ttsd_player_stop(uid))
+                       SLOG(LOG_WARN, get_tag(), "[Server] Fail to ttsd_player_stop()");
+
+               ttsd_data_set_client_state(uid, APP_STATE_READY);
        }
 
+       /* Reset all data */
+       ttsd_data_clear_data(uid);
+
        return TTSD_ERROR_NONE;
 }
 
@@ -796,19 +745,19 @@ int ttsd_server_pause(int uid, int* utt_id)
 {
        app_state_e state;
        if (0 > ttsd_data_get_client_state(uid, &state)) {
-               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] ttsd_server_pause : uid is not valid  ");
+               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] ttsd_server_pause : uid is not valid");
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
        if (APP_STATE_PLAYING != state) {
-               SLOG(LOG_WARN, get_tag(), "[Server WARNING] Current state is not 'play' ");
+               SLOG(LOG_WARN, get_tag(), "[Server WARNING] Current state is not 'play'");
                return TTSD_ERROR_INVALID_STATE;
        }
 
        int ret = 0;
        ret = ttsd_player_pause(uid);
        if (0 != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] fail player_pause() : ret(%d)", ret);
+               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail player_pause() : ret(%d)", ret);
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
@@ -821,17 +770,17 @@ int ttsd_server_get_support_voices(int uid, GList** voice_list)
 {
        app_state_e state;
        if (0 > ttsd_data_get_client_state(uid, &state)) {
-               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] uid is not valid  ");
+               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] uid is not valid");
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
        /* get voice list*/
        if (0 != ttsd_engine_get_voice_list(voice_list)) {
-               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail ttsd_server_get_support_voices() ");
+               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail ttsd_server_get_support_voices()");
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
-       SLOG(LOG_DEBUG, get_tag(), "[Server SUCCESS] Get supported voices ");
+       SLOG(LOG_DEBUG, get_tag(), "[Server SUCCESS] Get supported voices");
 
        return TTSD_ERROR_NONE;
 }
@@ -840,285 +789,18 @@ int ttsd_server_get_current_voice(int uid, char** language, int* voice_type)
 {
        app_state_e state;
        if (0 > ttsd_data_get_client_state(uid, &state)) {
-               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] ttsd_server_get_current_voice : uid is not valid  ");
+               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] ttsd_server_get_current_voice : uid is not valid");
                return TTSD_ERROR_INVALID_PARAMETER;
        }               
 
        /* get current voice */
-       int ret = ttsd_engine_get_default_voice(language, (ttsp_voice_type_e*)voice_type);
+       int ret = ttsd_engine_get_default_voice(language, voice_type);
        if (0 != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] fail ttsd_server_get_support_voices() ");
+               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail ttsd_server_get_support_voices()");
                return ret;
        }
 
-       SLOG(LOG_DEBUG, get_tag(), "[Server] Get default language (%s), voice type(%d) ", *language, *voice_type); 
-
-       return TTSD_ERROR_NONE;
-}
-
-#if 0
-/*
-* Server API for Internal event
-*/
-int ttsd_server_start_next_synthesis()
-{
-       /* get current play */
-       int uid = ttsd_data_is_current_playing();
-
-       if (uid < 0) {
-               return 0;
-       }
-
-       return __server_next_synthesis(uid);
-}
-#endif
-
-/*
-* TTS Server Functions for Setting                                                                                                               *
-*/
-
-int ttsd_server_setting_initialize(int uid)
-{
-       if (false == g_is_engine) {
-               if (0 != ttsd_engine_agent_initialize_current_engine()) {
-                       SLOG(LOG_WARN, get_tag(), "[Server Setting WARNING] No Engine !!! " );
-                       g_is_engine = false;
-                       return TTSD_ERROR_ENGINE_NOT_FOUND;
-               } else {
-                       g_is_engine = true;
-               }
-       }
-
-       if (-1 != ttsd_setting_data_is_setting(uid)) {
-               SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] pid has already been registered ");
-               return TTSD_ERROR_INVALID_PARAMETER;
-       }
-
-       if (0 == ttsd_data_get_client_count()) {
-               if( 0 != ttsd_engine_agent_load_current_engine() ) {
-                       SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] Fail to load current engine ");
-                       return TTSD_ERROR_OPERATION_FAILED;
-               }
-       }
-
-       /* register pid */
-       if (0 != ttsd_setting_data_add(uid)) {
-               SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] Fail to add client info ");
-               return TTSD_ERROR_OPERATION_FAILED;
-       }
-
-       return TTSD_ERROR_NONE;
-}
-
-int ttsd_server_setting_finalize(int uid)
-{
-       if (-1 == ttsd_setting_data_is_setting(uid)) {
-               SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] uid is not valid  (%s)", uid);
-               return TTSD_ERROR_INVALID_PARAMETER;
-       }
-
-       ttsd_setting_data_delete(uid);
-
-       /* unload engine, if ref count of client is 0 */
-       if (0 == ttsd_data_get_client_count()) {
-               ecore_timer_add(0, __quit_ecore_loop, NULL);
-       }
-
-       return TTSD_ERROR_NONE;
-}
-
-int ttsd_server_setting_get_engine_list(int uid, GList** engine_list)
-{
-       if (-1 == ttsd_setting_data_is_setting(uid)) {
-               SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] uid is not valid  (%s)", uid);
-               return TTSD_ERROR_INVALID_PARAMETER;
-       }
-
-       int ret = 0;
-       ret = ttsd_engine_setting_get_engine_list(engine_list);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] fail to get engine list : result(%d)", ret);
-               return ret;
-       }
-
-       return TTSD_ERROR_NONE;
-}
-
-int ttsd_server_setting_get_current_engine(int uid, char** engine_id)
-{
-       if (-1 == ttsd_setting_data_is_setting(uid)) {
-               SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] uid is not valid  (%s)", uid);
-               return TTSD_ERROR_INVALID_PARAMETER;
-       }
-
-       int ret = 0;
-       ret = ttsd_engine_setting_get_engine(engine_id);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] Fail to get current engine : result(%d) ", ret);
-               return ret;
-       }
-
-       return TTSD_ERROR_NONE;
-}
-
-int ttsd_server_setting_set_current_engine(int uid, const char* engine_id)
-{
-       /* check if uid is valid */
-       if (-1 == ttsd_setting_data_is_setting(uid)) {
-               SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] uid is not valid  (%s)", uid);
-               return TTSD_ERROR_INVALID_PARAMETER;
-       }
-
-       if (true == ttsd_engine_agent_is_same_engine(engine_id)) {
-               SLOG(LOG_DEBUG, get_tag(), "[Server Setting] new engine is the same as current engine ");
-               return TTSD_ERROR_NONE;
-       }
-
-       /* stop all player */ 
-       ttsd_player_all_stop();
-
-       /* send interrupt message to  all clients */
-       ttsd_data_foreach_clients(__get_client_cb, NULL);
-
-       ttsd_engine_cancel_synthesis();
-
-       /* set engine */
-       int ret = 0;
-       ret = ttsd_engine_setting_set_engine(engine_id);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] fail to set current engine : result(%d) ", ret);
-               return ret;
-       }
-
-       return TTSD_ERROR_NONE;
-}
-
-int ttsd_server_setting_get_voice_list(int uid, char** engine_id, GList** voice_list)
-{
-       /* check if uid is valid */
-       if (-1 == ttsd_setting_data_is_setting(uid)) {
-               SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] uid is not valid  (%s)", uid);
-               return TTSD_ERROR_INVALID_PARAMETER;
-       }
-
-       /* get language list from engine */
-       int ret = 0;
-       ret = ttsd_engine_setting_get_voice_list(engine_id, voice_list);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] Fail to get voice list : result(%d)", ret);
-               return ret;
-       }
-
-       return TTSD_ERROR_NONE;
-}
-
-int ttsd_server_setting_get_default_voice(int uid, char** language, ttsp_voice_type_e* vctype)
-{
-       /* check if uid is valid */
-       if (-1 == ttsd_setting_data_is_setting(uid)) {
-               SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] uid is not valid  (%s)", uid);
-               return TTSD_ERROR_INVALID_PARAMETER;
-       }
-       
-       int ret = 0;
-       ret = ttsd_engine_setting_get_default_voice(language, vctype);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] Fail to get default voice : result(%d) ", ret);
-               return ret;
-       }
-
-       return TTSD_ERROR_NONE;
-}
-
-int ttsd_server_setting_set_default_voice(int uid, const char* language, int vctype)
-{
-       /* check if uid is valid */
-       if (-1 == ttsd_setting_data_is_setting(uid)) {
-               SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] uid is not valid  (%s)", uid);
-               return TTSD_ERROR_INVALID_PARAMETER;
-       }
-
-       /* set current language */
-       int ret = 0;
-       ret = ttsd_engine_setting_set_default_voice((const char*)language, (const ttsp_voice_type_e)vctype);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] fail to set default voice : result(%d) ", ret);
-               return ret;
-       }       
-
-       return TTSD_ERROR_NONE;
-}
-
-int ttsd_server_setting_get_engine_setting(int uid, char** engine_id, GList** engine_setting_list)
-{
-       /* check if uid is valid */
-       if (-1 == ttsd_setting_data_is_setting(uid)) {
-               SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] uid is not valid  (%s)", uid);
-               return TTSD_ERROR_INVALID_PARAMETER;
-       }
-
-       int ret = 0;
-       ret = ttsd_engine_setting_get_engine_setting_info(engine_id, engine_setting_list);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] fail to get engine setting info : result(%d)", ret);
-               return ret;
-       }
-
-       return TTSD_ERROR_NONE;
-}
-
-int ttsd_server_setting_set_engine_setting(int uid, const char* key, const char* value)
-{
-       /* check if uid is valid */
-       if (-1 == ttsd_setting_data_is_setting(uid)) {
-               SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] uid is not valid  (%s)", uid);
-               return TTSD_ERROR_INVALID_PARAMETER;
-       }
-
-       int ret = 0;
-       ret = ttsd_engine_setting_set_engine_setting(key, value);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] fail to set engine setting info : result(%d)", ret);
-               return ret;
-       }
-
-       return TTSD_ERROR_NONE;
-}
-
-int ttsd_server_setting_get_default_speed(int uid, int* default_speed)
-{
-       /* check if uid is valid */
-       if (-1 == ttsd_setting_data_is_setting(uid)) {
-               SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] uid is not valid  (%s)", uid);
-               return TTSD_ERROR_INVALID_PARAMETER;
-       }
-
-       /* get current speed */
-       int ret = 0;
-       ret = ttsd_engine_setting_get_default_speed((ttsp_speed_e*)default_speed);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] fail to get default speed : result(%d)", ret);
-               return ret;
-       }       
-
-       return TTSD_ERROR_NONE;
-}
-
-int ttsd_server_setting_set_default_speed(int uid, int default_speed)
-{
-       /* check if uid is valid */
-       if (-1 == ttsd_setting_data_is_setting(uid)) {
-               SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] uid is not valid  (%s)", uid);
-               return TTSD_ERROR_INVALID_PARAMETER;
-       }
-
-       /* set default speed */
-       int ret = 0;
-       ret = ttsd_engine_setting_set_default_speed((ttsp_speed_e)default_speed);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, get_tag(), "[Server Setting ERROR] fail to set default speed : result(%d)", ret);
-               return ret;
-       }       
+       SECURE_SLOG(LOG_DEBUG, get_tag(), "[Server] Get default language (%s), voice type(%d) ", *language, *voice_type); 
 
        return TTSD_ERROR_NONE;
 }
index 5221668..326667d 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*  Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd All Rights Reserved 
+*  Copyright (c) 2011-2014 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
@@ -51,41 +51,6 @@ int ttsd_server_stop(int uid);
 
 int ttsd_server_pause(int uid, int* utt_id);
 
-#if 0
-/*
-* Server API for internal event
-*/
-int ttsd_server_start_next_synthesis();
-#endif
-
-/*
-* Server API for setting
-*/
-
-int ttsd_server_setting_initialize(int uid);
-
-int ttsd_server_setting_finalize(int uid);
-
-int ttsd_server_setting_get_engine_list(int uid, GList** engine_list);
-
-int ttsd_server_setting_get_current_engine(int uid, char** engine_id);
-
-int ttsd_server_setting_set_current_engine(int uid, const char* engine_id);
-
-int ttsd_server_setting_get_voice_list(int uid, char** engine_id, GList** voice_list);
-
-int ttsd_server_setting_get_default_voice(int uid, char** language, ttsp_voice_type_e* vctype);
-
-int ttsd_server_setting_set_default_voice(int uid, const char* language, int vctype);
-
-int ttsd_server_setting_get_default_speed(int uid, int* default_speed);
-
-int ttsd_server_setting_set_default_speed(int uid, int default_speed);
-
-int ttsd_server_setting_get_engine_setting(int uid, char** engine_id, GList** engine_setting_list);
-
-int ttsd_server_setting_set_engine_setting(int uid, const char* key, const char* value);
-
 
 #ifdef __cplusplus
 }
index f00eb0c..9414d25 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*  Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd All Rights Reserved 
+*  Copyright (c) 2011-2014 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
@@ -42,36 +42,12 @@ typedef enum {
 }ttsp_error_e;
 
 /**
-* @brief Enumerations of speaking speed.
-*/
-typedef enum {
-       TTSP_SPEED_VERY_SLOW = 1,       /**< Very slow */
-       TTSP_SPEED_SLOW,                /**< Slow */
-       TTSP_SPEED_NORMAL,              /**< Normal */
-       TTSP_SPEED_FAST,                /**< Fast */
-       TTSP_SPEED_VERY_FAST            /**< Very fast */
-}ttsp_speed_e;
-
-/** 
-* @brief Enumerations of voice type.
-*/
-typedef enum {
-       TTSP_VOICE_TYPE_MALE = 1,       /**< Male */
-       TTSP_VOICE_TYPE_FEMALE,         /**< Female */
-       TTSP_VOICE_TYPE_CHILD,          /**< Child */
-       TTSP_VOICE_TYPE_USER1,          /**< Engine defined */
-       TTSP_VOICE_TYPE_USER2,          /**< Engine defined */
-       TTSP_VOICE_TYPE_USER3           /**< Engine defined */
-}ttsp_voice_type_e;
-
-/**
 * @brief Enumerations of audio type.
 */
 typedef enum {
-       TTSP_AUDIO_TYPE_RAW = 0,        /**< PCM audio type */
-       TTSP_AUDIO_TYPE_WAV,            /**< Wave audio type */
-       TTSP_AUDIO_TYPE_MP3,            /**< MP3 audio type */
-       TTSP_AUDIO_TYPE_AMR             /**< AMR audio type */
+       TTSP_AUDIO_TYPE_RAW_S16 = 0,    /**< Signed 16-bit audio sample */
+       TTSP_AUDIO_TYPE_RAW_U8,         /**< Unsigned 8-bit audio sample */
+       TTSP_AUDIO_TYPE_MAX
 }ttsp_audio_type_e;
 
 /**
@@ -81,16 +57,38 @@ typedef enum {
        TTSP_RESULT_EVENT_FAIL          = -1, /**< event when the voice synthesis is failed */
        TTSP_RESULT_EVENT_START         = 1,  /**< event when the sound data is first data by callback function */
        TTSP_RESULT_EVENT_CONTINUE      = 2,  /**< event when the next sound data exist, not first and not last */
-       TTSP_RESULT_EVENT_FINISH        = 3,  /**< event when the sound data is last data or sound data is only one result */
-       TTSP_RESULT_EVENT_CANCEL        = 4,  /**< event when the voice synthesis has been canceled */
+       TTSP_RESULT_EVENT_FINISH        = 3   /**< event when the sound data is last data or sound data is only one result */
 }ttsp_result_event_e;
 
 /** 
+* @brief Defines of speaking speed.
+*/
+#define TTSP_SPEED_MIN         1
+#define TTSP_SPEED_NORMAL      8
+#define TTSP_SPEED_MAX         15
+
+/** 
+* @brief Defines of speaking pitch.
+*/
+#define TTSP_PITCH_MIN         1
+#define TTSP_PITCH_NORMAL      8
+#define TTSP_PITCH_MAX         15
+
+/** 
+* @brief Defines of voice type.
+*/
+#define TTSP_VOICE_TYPE_MALE   1
+#define TTSP_VOICE_TYPE_FEMALE 2
+#define TTSP_VOICE_TYPE_CHILD  3
+
+/** 
 * @brief Called when the daemon gets synthesized result.
 * 
 * @param[in] event A result event
 * @param[in] data Result data
 * @param[in] data_size Result data size
+* @param[in] audio_type A audio type 
+* @param[in] rate A sample rate 
 * @param[in] user_data The user data passed from the start synthesis function
 *
 * @return @c true to continue with the next iteration of synthesis \n @c false to stop
@@ -99,7 +97,8 @@ typedef enum {
 *
 * @see ttspe_start_synthesis()
 */
-typedef bool (*ttspe_result_cb)(ttsp_result_event_e event, const void* data, unsigned int data_size, void *user_data);
+typedef bool (*ttspe_result_cb)(ttsp_result_event_e event, const void* data, unsigned int data_size, 
+                       ttsp_audio_type_e audio_type, int rate, void *user_data);
 
 /**
 * @brief Called when the daemon gets a language and a voice type.
@@ -116,22 +115,7 @@ typedef bool (*ttspe_result_cb)(ttsp_result_event_e event, const void* data, uns
 *
 * @see ttspe_foreach_supported_voices()
 */
-typedef bool (*ttspe_supported_voice_cb)(const char* language, ttsp_voice_type_e type, void* user_data);
-
-/**
-* @brief Called when the daemon gets a engine setting.
-*
-* @param[in] key A key
-* @param[in] value A value
-* @param[in] user_data The user data passed from the foreach function
-*
-* @return @c true to continue with the next iteration of the loop \n @c false to break out of the loop
-*
-* @pre ttspe_foreach_engine_settings() will invoke this callback. 
-*
-* @see ttspe_foreach_engine_settings()
-*/
-typedef bool (*ttspe_engine_setting_cb)(const char* key, const char* value, void* user_data);
+typedef bool (*ttspe_supported_voice_cb)(const char* language, int type, void* user_data);
 
 /**
 * @brief Initializes the engine.
@@ -186,21 +170,55 @@ typedef int (* ttspe_foreach_supported_voices)(ttspe_supported_voice_cb callback
 *
 * @see ttspe_foreach_supported_voices()
 */
-typedef bool (* ttspe_is_valid_voice)(const char* language, ttsp_voice_type_e type);
+typedef bool (* ttspe_is_valid_voice)(const char* language, int type);
+
+/**
+* @brief Sets default pitch.
+*
+* @param[in] pitch default pitch
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #TTSP_ERROR_NONE Successful
+* @retval #TTSP_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #TTSP_ERROR_INVALID_STATE Not initialized
+* @retval #TTSP_ERROR_OPERATION_FAILED Fail
+*/
+typedef int (* ttspe_set_pitch)(int pitch);
+
+/**
+* @brief Load voice of the engine.
+*
+* @param[in] language language
+* @param[in] type voice type
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #TTSP_ERROR_NONE Successful
+* @retval #TTSP_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #TTSP_ERROR_INVALID_STATE Not initialized
+* @retval #TTSP_ERROR_OUT_OF_MEMORY Out of memory
+* @retval #TTSP_ERROR_INVALID_VOICE Invalid voice
+* @retval #TTSP_ERROR_OPERATION_FAILED Fail
+*
+* @see ttspe_unload_voice()
+*/
+typedef int (* ttspe_load_voice)(const char* language, int type);
 
 /**
-* @brief Gets audio format of the engine.
+* @brief Unload voice of the engine.
 *
-* @param[out] types A audio type 
-* @param[out] rate A sample rate 
-* @param[out] channels Channels
+* @param[in] language language
+* @param[in] type voice type
 *
 * @return 0 on success, otherwise a negative error value
 * @retval #TTSP_ERROR_NONE Successful
 * @retval #TTSP_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #TTSP_ERROR_INVALID_STATE Not initialized
+* @retval #TTSP_ERROR_INVALID_VOICE Invalid voice
+* @retval #TTSP_ERROR_OPERATION_FAILED Fail
+*
+* @see ttspe_load_voice()
 */
-typedef int (* ttspe_get_audio_format)(ttsp_audio_type_e* audio_type, int* rate, int* channel);
+typedef int (* ttspe_unload_voice)(const char* language, int type);
 
 /**
 * @brief Starts voice synthesis, asynchronously.
@@ -224,7 +242,7 @@ typedef int (* ttspe_get_audio_format)(ttsp_audio_type_e* audio_type, int* rate,
 * @see ttspe_result_cb()
 * @see ttspe_cancel_synthesis()
 */
-typedef int (* ttspe_start_synthesis)(const char* language, ttsp_voice_type_e type, const char* text, ttsp_speed_e speed, void* user_data);
+typedef int (* ttspe_start_synthesis)(const char* language, int type, const char* text, int speed, void* user_data);
 
 /**
 * @brief Cancels voice synthesis.
@@ -240,40 +258,6 @@ typedef int (* ttspe_start_synthesis)(const char* language, ttsp_voice_type_e ty
 typedef int (* ttspe_cancel_synthesis)(void);
 
 /**
-* @brief Gets setting information of the engine.
-*
-* @param[in] callback A callback function.
-* @param[in] user_data The user data to be passed to the callback function.
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #TTSP_ERROR_NONE Successful
-* @retval #TTSP_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #TTSP_ERROR_INVALID_STATE Not initialized
-* @retval #TTSP_ERROR_OPERATION_FAILED Operation failed
-*
-* @post        This function invokes ttspe_engine_setting_cb() repeatedly for getting all engine settings. 
-*
-* @see ttspe_engine_setting_cb()
-*/
-typedef int (* ttspe_foreach_engine_settings)(ttspe_engine_setting_cb callback, void* user_data);
-
-/**
-* @brief Sets setting information of the engine.
-*
-* @param[in] key A key.
-* @param[in] value A value.
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #TTSP_ERROR_NONE Successful
-* @retval #TTSP_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #TTSP_ERROR_INVALID_STATE Not initialized
-* @retval #TTSP_ERROR_OPERATION_FAILED Operation failed
-*
-* @see ttspe_foreach_engine_settings()
-*/
-typedef int (* ttspe_set_engine_setting)(const char* key, const char* value);
-
-/**
 * @brief A structure of the engine functions
 */
 typedef struct {
@@ -286,28 +270,28 @@ typedef struct {
        /* Get / Set engine information */
        ttspe_foreach_supported_voices  foreach_voices;         /**< Get voice list */
        ttspe_is_valid_voice            is_valid_voice;         /**< Check voice */
-       ttspe_get_audio_format          get_audio_format;       /**< Get audio format function */
+       ttspe_set_pitch                 set_pitch;              /**< Set default pitch */
+
+       /* Load / Unload voice */
+       ttspe_load_voice                load_voice;             /**< Load voice */
+       ttspe_unload_voice              unload_voice;           /**< Unload voice */
 
        /* Control synthesis */
        ttspe_start_synthesis           start_synth;            /**< Start synthesis */
        ttspe_cancel_synthesis          cancel_synth;           /**< Cancel synthesis */
-
-       /* Engine setting */
-       ttspe_foreach_engine_settings   foreach_engine_setting; /**< Foreach engine setting */
-       ttspe_set_engine_setting        set_engine_setting;     /**< Set engine setting */
 } ttspe_funcs_s;
 
 /**
 * @brief A structure of the daemon functions
 */
 typedef struct {
-       int size;                                       /**< size */
-       int version;                                    /**< version */
+       int size;                                               /**< size */
+       int version;                                            /**< version */
 
 }ttspd_funcs_s;
 
 /**
-* @brief Loads the engine by the daemon. 
+* @brief Loads the engine by the daemon.
 *
 * @param[in] pdfuncs The daemon functions
 * @param[out] pefuncs The engine functions
@@ -351,7 +335,7 @@ typedef void (*ttsp_engine_info_cb)(const char* engine_uuid, const char* engine_
                                     bool use_network, void* user_data);
 
 /**
-* @brief Gets base information of the engine by the daemon. 
+* @brief Gets base information of the engine by the daemon.
 *
 * @param[in] callback A callback function
 * @param[in] user_data The user data to be passed to the callback function
diff --git a/sysinfo-tts.xml b/sysinfo-tts.xml
deleted file mode 100644 (file)
index 4e9fb47..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0"?>\r
-<sys-info>\r
-  <default>\r
-    <key id="tts-support" string="true"/>\r
-  </default>\r
-</sys-info>\r
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100644 (file)
index 0000000..b23f449
--- /dev/null
@@ -0,0 +1,27 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(tts-test C)
+
+SET(SRCS
+       test_main.c
+)
+
+INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/include)
+
+FOREACH(flag ${pkgs_test_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+FIND_PROGRAM(UNAME NAMES uname)
+EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
+IF("${ARCH}" STREQUAL "arm")
+       ADD_DEFINITIONS("-DTARGET")
+       MESSAGE("add -DTARGET")
+ENDIF("${ARCH}" STREQUAL "arm")
+
+ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
+
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_test_LDFLAGS} tts)
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /opt/usr/devel/bin)
\ No newline at end of file
diff --git a/test/test_main.c b/test/test_main.c
new file mode 100644 (file)
index 0000000..944f2f6
--- /dev/null
@@ -0,0 +1,286 @@
+/*
+*  Copyright (c) 2011-2014 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 <stdio.h>
+#include <Ecore.h>
+
+#include <tts.h>
+#include <dlog.h>
+
+#define TTS_STRDUP(src)                ((src != NULL) ? strdup(src) : NULL )
+
+static tts_h g_tts;
+static char* g_text = NULL;
+
+const char* tts_tag()
+{
+       return "ttstest";
+}
+
+Eina_Bool __tts_test_destroy(void *data);
+
+static bool __tts_test_get_text_from_file(const char* path, char** text)
+{
+       if(!path) return 0;
+       if(!text) return 0;
+
+       FILE *fp = NULL;
+
+       if((fp = fopen(path, "rb")) == NULL ) {
+               SLOG(LOG_ERROR, tts_tag(), "Fail to open file (%s)", path);
+               return 0;
+       }
+
+       fseek(fp , 0 , SEEK_END);  
+       
+       int text_len = ftell(fp);
+       if (0 >= text_len) {
+               SLOG(LOG_ERROR, tts_tag(), "File has no contents\n");
+               fclose(fp);
+               return 0;
+       }
+       SLOG(LOG_ERROR, tts_tag(), "text_len(%d)\n", text_len);
+       rewind(fp);
+
+       *text = (char*)calloc(1, text_len+1);
+
+       if (text == NULL) {
+               SLOG(LOG_ERROR, tts_tag(), "Fail to memory allocation\n");              
+               return 0;
+       }
+       
+       int result_len = 1;
+       while (!feof(fp)) {
+               result_len = fread(*text, sizeof(char), text_len, fp);
+               if (result_len != text_len) {
+                       SLOG(LOG_ERROR, tts_tag(), "Fail to read\n");
+                       return 0;
+               }
+       }
+
+       *text[result_len] = '\0';
+
+       fclose(fp);
+       return 1;
+}
+
+Eina_Bool __tts_test_play(void *data)
+{
+       int utt_id;
+       int ret;
+       char* lang = NULL;
+
+       lang = (char*)data;
+       
+       ret = tts_add_text(g_tts, g_text, lang, TTS_VOICE_TYPE_AUTO, TTS_SPEED_AUTO, &utt_id);
+       if (TTS_ERROR_NONE != ret) {
+               SLOG(LOG_ERROR, tts_tag(), "Fail to add text\n");
+               ecore_timer_add(0, __tts_test_destroy, NULL);
+               return EINA_FALSE;
+       }
+
+       SLOG(LOG_ERROR, tts_tag(), "Play : utt id(%d)\n", utt_id);
+       ret = tts_play(g_tts);
+       if (TTS_ERROR_NONE != ret) {
+               SLOG(LOG_ERROR, tts_tag(), "Fail to play\n");
+               ecore_timer_add(0, __tts_test_destroy, NULL);
+               return EINA_FALSE;
+       }
+
+       return EINA_FALSE;
+}
+
+Eina_Bool __tts_test_destroy(void *data)
+{
+       int ret;
+       SLOG(LOG_ERROR, tts_tag(), "Stop\n");
+       ret = tts_stop(g_tts);
+       if (TTS_ERROR_NONE != ret) {
+               SLOG(LOG_ERROR, tts_tag(), "Fail to stop\n");
+       }
+
+       SLOG(LOG_ERROR, tts_tag(), "Unprepare (Disconnection)\n");
+       ret = tts_unprepare(g_tts);
+       if (TTS_ERROR_NONE != ret) {
+               SLOG(LOG_ERROR, tts_tag(), "Fail to unprepare\n");
+       }
+
+       SLOG(LOG_ERROR, tts_tag(), "Destory tts client\n");
+       ret = tts_destroy(g_tts);
+       if (TTS_ERROR_NONE != ret) {
+               SLOG(LOG_ERROR, tts_tag(), "Fail to destroy\n");
+       }
+
+       ecore_main_loop_quit();
+
+       return EINA_FALSE;
+}
+
+static void __tts_test_state_changed_cb(tts_h tts, tts_state_e previous, tts_state_e current, void* user_data)
+{
+       if (TTS_STATE_CREATED == previous && TTS_STATE_READY == current) {
+               SLOG(LOG_ERROR, tts_tag(), "State is ready after prepare\n");
+               ecore_timer_add(0, __tts_test_play, user_data);
+       }
+
+       return;
+}
+
+static void __tts_test_utt_started_cb(tts_h tts, int utt_id, void* user_data)
+{
+       SLOG(LOG_DEBUG, tts_tag(), "Utterance started : utt id(%d) \n", utt_id);
+
+       return;
+}
+
+static void __tts_test_utt_completed_cb(tts_h tts, int utt_id, void* user_data)
+{
+       SLOG(LOG_DEBUG, tts_tag(), "Utterance completed : utt id(%d) \n", utt_id);
+       ecore_timer_add(0, __tts_test_destroy, NULL);
+
+       return;
+}
+
+int main (int argc, char *argv[])
+{
+       if (1 == argc || 5 < argc) {
+               SLOG(LOG_DEBUG, tts_tag(), "Please check parameter\n");
+               SLOG(LOG_DEBUG, tts_tag(), "Ex> tts-test 'text'\n");
+               SLOG(LOG_DEBUG, tts_tag(), "Specific mode> tts-test 'text' '-sr || -noti'\n");
+               return 0;
+       }
+
+       char* lang = NULL;
+       char* src_path = NULL;
+
+       int n = 0;
+
+       while(NULL != argv[n]) {
+
+               if(!strcmp("-h", argv[n])) {
+                       SLOG(LOG_DEBUG, tts_tag(), "\n");
+                       SLOG(LOG_DEBUG, tts_tag(), " ==========================================\n");
+                       SLOG(LOG_DEBUG, tts_tag(), "  TTS test usage\n");
+                       SLOG(LOG_DEBUG, tts_tag(), " ==========================================\n\n");
+                       SLOG(LOG_DEBUG, tts_tag(), "  -t : Synthesize text \n");
+                       SLOG(LOG_DEBUG, tts_tag(), "  -l : Determine langage to synthesize text, ex) en_US, ko_KR ...\n");
+                       SLOG(LOG_DEBUG, tts_tag(), "  -f : Determine file path which include text\n\n");
+                       SLOG(LOG_DEBUG, tts_tag(), " ***************************************************\n");
+                       SLOG(LOG_DEBUG, tts_tag(), "    Example : #tts-test -l en_US -t \"1 2 3 4\" \n");
+                       SLOG(LOG_DEBUG, tts_tag(), " ***************************************************\n");
+                       SLOG(LOG_DEBUG, tts_tag(), "\n");
+                       return 0;
+               }
+               
+               // check langage option
+               if(!strcmp("-l", argv[n])) {
+                       lang = TTS_STRDUP(argv[n+1]);
+                       SLOG(LOG_ERROR, tts_tag(), "Language : %s\n", lang);
+               }
+               // check text to synthesize
+               else if (!strcmp("-t", argv[n])) {
+                       g_text = TTS_STRDUP(argv[n+1]);
+                       SLOG(LOG_ERROR, tts_tag(), "Text : %s\n", g_text);
+               }
+               // check file path to synthesize
+               else if (!strcmp("-f", argv[n])) {
+                       src_path = TTS_STRDUP(argv[n+1]);
+                       SLOG(LOG_ERROR, tts_tag(), "File path : %s\n", src_path);
+                       if(!__tts_test_get_text_from_file(src_path, &g_text)) {
+                               return 0;
+                       }
+               }
+               n++;
+       }
+       
+       if(!g_text && !src_path) {
+               SLOG(LOG_ERROR, tts_tag(), "Invalid parameter, check help with command tts-test -h");
+               return 0;
+       }
+
+//===================================
+
+       tts_mode_e mode = TTS_MODE_DEFAULT;
+
+       SLOG(LOG_DEBUG, tts_tag(), "  ");
+       SLOG(LOG_DEBUG, tts_tag(), "  ");
+       SLOG(LOG_DEBUG, tts_tag(), "===== TTS Sample start =====\n");
+
+       SLOG(LOG_DEBUG, tts_tag(), "Input text : %s\n", g_text ? g_text : "NULL");
+       SLOG(LOG_DEBUG, tts_tag(), "Input lang : %s\n", lang ? lang : "NULL");
+       SLOG(LOG_DEBUG, tts_tag(), "Input file path : %s\n", src_path ? src_path : "NULL");
+
+       if (!ecore_init()) {
+               SLOG(LOG_ERROR, tts_tag(), "[Main ERROR] Fail ecore_init()\n");
+               return 0;
+       }
+
+       int ret;
+
+       SLOG(LOG_DEBUG, tts_tag(), "Create tts client\n");
+       ret = tts_create(&g_tts);
+       if (TTS_ERROR_NONE != ret) {
+               SLOG(LOG_ERROR, tts_tag(), "Fail to create\n");
+               return 0;
+       }
+
+       SLOG(LOG_DEBUG, tts_tag(), "Set tts mode - %d\n", mode);
+       ret = tts_set_mode(g_tts, mode);
+       if (TTS_ERROR_NONE != ret) {
+               SLOG(LOG_ERROR, tts_tag(), "Fail to set mode\n");
+               tts_destroy(g_tts);
+               return 0;
+       }
+
+       SLOG(LOG_DEBUG, tts_tag(), "Set Callback func\n");
+       ret = tts_set_state_changed_cb(g_tts, __tts_test_state_changed_cb, (void*)lang);
+       if (TTS_ERROR_NONE != ret) {
+               SLOG(LOG_ERROR, tts_tag(), "Fail to set state changed cb\n");
+               tts_destroy(g_tts);
+               return 0;
+       }
+
+       ret = tts_set_utterance_started_cb(g_tts, __tts_test_utt_started_cb, NULL);
+       if (TTS_ERROR_NONE != ret) {
+               SLOG(LOG_ERROR, tts_tag(), "Fail to set utt started cb\n");
+               tts_destroy(g_tts);
+               return 0;
+       }
+
+       ret = tts_set_utterance_completed_cb(g_tts, __tts_test_utt_completed_cb, NULL);
+       if (TTS_ERROR_NONE != ret) {
+               SLOG(LOG_ERROR, tts_tag(), "Fail to set utt completed cb\n");
+               tts_destroy(g_tts);
+               return 0;
+       }
+
+       SLOG(LOG_DEBUG, tts_tag(), "Prepare (Daemon Connection) asynchronously : Wait for ready state \n");
+       ret = tts_prepare(g_tts);
+       if (TTS_ERROR_NONE != ret) {
+               SLOG(LOG_ERROR, tts_tag(), "Fail to prepare\n");
+               tts_destroy(g_tts);
+               return 0;
+       }
+
+       ecore_main_loop_begin();
+
+       ecore_shutdown();
+
+       if(src_path) free(src_path);
+       if(lang) free(lang);
+       if(g_text) free(g_text);
+
+       SLOG(LOG_DEBUG, tts_tag(), "===== TTS END =====\n\n\n");
+
+       return 0;
+}
diff --git a/tts-config.xml b/tts-config.xml
new file mode 100644 (file)
index 0000000..61b9161
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<tts-config>
+        <engine>27F277E9-BBC4-4dca-B553-D9884A3CDAA0</engine>
+        <engine-setting/>
+        <auto>on</auto>
+        <language>en_US</language>
+        <voice-type>female</voice-type>
+        <speech-rate>8</speech-rate>
+        <pitch>8</pitch>
+</tts-config>