Merge with Tizen 2.3 18/35318/2 tizen_3.0.2015.q2_common accepted/tizen/common/20150601.145816 accepted/tizen/mobile/20150602.003447 accepted/tizen/tv/20150602.003424 accepted/tizen/wearable/20150602.003429 submit/tizen/20150601.072633
authorky85.kim <ky85.kim@samsung.com>
Thu, 12 Feb 2015 04:07:43 +0000 (13:07 +0900)
committerky85.kim <ky85.kim@samsung.com>
Thu, 12 Feb 2015 04:09:13 +0000 (13:09 +0900)
Update configure to XML based
Update audion session
Change api for partial result
Support result time stamp
Remove api for hide offensive word
Support start and stop sound

 - Details in changelog -

Change-Id: I556b3f71482a82c5b8064c53a27a7ff6c7268e8c

63 files changed:
AUTHORS
CMakeLists.txt [changed mode: 0755->0644]
NOTICE
changelog
client/CMakeLists.txt
client/stt.c
client/stt.h [deleted file]
client/stt_client.c
client/stt_client.h
client/stt_dbus.c
client/stt_dbus.h
client/stt_file.c [new file with mode: 0644]
client/stt_file_client.c [new file with mode: 0644]
client/stt_file_client.h [new file with mode: 0644]
client/stt_main.h
client/stt_setting.c
client/stt_setting_dbus.c [deleted file]
client/stt_setting_dbus.h [deleted file]
common/stt_config_mgr.c [new file with mode: 0644]
common/stt_config_mgr.h [new file with mode: 0644]
common/stt_config_parser.c [new file with mode: 0644]
common/stt_config_parser.h [new file with mode: 0644]
common/stt_defs.h
common/stt_engine.c [new file with mode: 0644]
common/stt_engine.h [new file with mode: 0644]
common/stt_network.c [new file with mode: 0644]
common/stt_network.h [moved from server/sttd_network.h with 69% similarity]
doc/doxyfile [new file with mode: 0644]
doc/images/capi_uix_stt_state_diagram.png [new file with mode: 0644]
doc/uix_stt_doc.h [new file with mode: 0644]
include/CMakeLists.txt [new file with mode: 0644]
include/stt-engine.pc.in [new file with mode: 0644]
include/stt-file.pc.in [new file with mode: 0644]
include/stt-setting.pc.in [moved from client/stt-setting.pc.in with 100% similarity]
include/stt.h [new file with mode: 0644]
include/stt.pc.in [moved from client/stt.pc.in with 100% similarity]
include/stt_file.h [new file with mode: 0644]
include/stt_setting.h [moved from client/stt_setting.h with 61% similarity]
packaging/stt.spec [changed mode: 0755->0644]
server/CMakeLists.txt
server/sttd.conf [deleted file]
server/sttd_client_data.c
server/sttd_client_data.h
server/sttd_config.c
server/sttd_config.h
server/sttd_dbus.c
server/sttd_dbus.h
server/sttd_dbus_server.c
server/sttd_dbus_server.h
server/sttd_engine_agent.c
server/sttd_engine_agent.h
server/sttd_main.c
server/sttd_main.h
server/sttd_network.c [deleted file]
server/sttd_recorder.c
server/sttd_recorder.h
server/sttd_server.c
server/sttd_server.h
server/sttp.h
stt-config.xml [new file with mode: 0644]
sysinfo-stt.xml [deleted file]
test/CMakeLists.txt [new file with mode: 0644]
test/test_main.c [new file with mode: 0644]

diff --git a/AUTHORS b/AUTHORS
index 3e21f67..d4434b8 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,3 +1,3 @@
 Dongyeol Lee <dy3.lee@samsung.com>
-Kwangyoun Kim <ky85.kim@samsung.com> 
+Kwangyoun Kim <ky85.kim@samsung.com>
 Sehwan Park <sehwan@samsung.com>
\ No newline at end of file
old mode 100755 (executable)
new mode 100644 (file)
index 35c7f5d..6bfaa53
@@ -1,19 +1,57 @@
+# 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(libstt)
+PROJECT(stt)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(EXEC_PREFIX "${PREFIX}")
+SET(VERSION 0.2.53)
 
 ## Include common directory ##
 INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/common")
+INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/include")
 
 ## Dependent packages ##
 INCLUDE(FindPkgConfig)
 pkg_check_modules(pkgs REQUIRED 
-       glib-2.0 dbus-1 vconf dlog ecore ecore-file capi-media-audio-io capi-media-sound-manager libtzplatform-config
+       aul capi-media-audio-io capi-media-wav-player capi-system-info dbus-1 dlog ecore glib-2.0
+       libtzplatform-config libxml-2.0 vconf vconf-internal-keys
+)
+
+pkg_check_modules(pkgs_test REQUIRED
+    dlog ecore
 )
 
+## API ##
+ADD_SUBDIRECTORY(include)
+
 ## Client library ##
 ADD_SUBDIRECTORY(client)
 
 ## Server daemon ##
 ADD_SUBDIRECTORY(server)
 
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/sysinfo-stt.xml DESTINATION /etc/config)
+## Test ##
+ADD_SUBDIRECTORY(test)
+
+## config ##
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/stt-config.xml DESTINATION /usr/lib/voice/stt/1.0)
+
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 9f7bb23..97cbeb1 100644 (file)
--- a/changelog
+++ b/changelog
@@ -1,3 +1,603 @@
+stt (0.2.53) -- Thu, 21 Aug 2014
+
+  * Remove agreement api (Dongyeol Lee <dy3.lee@samsung.com>)
+  * Add privilege http://tizen.org/privilege/recorder (Dongyeol Lee <dy3.lee@samsung.com>)
+  * Update engine error print (Dongyeol Lee <dy3.lee@samsung.com>)
+  * Update network check (Dongyeol Lee <dy3.lee@samsung.com>)
+  * Check dbus connection valid (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.52) -- Mon, 14 Jul 2014
+
+  * Apply sound session manager api change (Kwangyoun Kim <ky85.kim@samsung.com>)
+  * include header files (Kwangyoun Kim <ky85.kim@samsung.com>)
+  * Fix dbus timeout and retry (Dongyeol Lee <dy3.lee@samsung.com>)
+  * Update header (Kwangyoun Kim <ky85.kim@samsung.com>)
+  * Fix memory issue (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.51) -- Fri, 16 Jun 2014
+  
+  * Add file recognition library (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.50) -- Fri, 23 May 2014
+
+  * Fix memory initialize bug (Dongyeol Lee <dy3.lee@samsung.com>)
+  * Update License info (Kwangyoun Kim <ky85.kim@samsung.com>)
+  * Fix bug on notify state changed (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.49) -- Mon, 31 Mar 2014
+
+  * Remove build dependency of vconf key (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.48) -- Mon, 24 Mar 2014
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.47-1) -- Fri, 21 Mar 2014
+
+  * Error Handling for record fail (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.47) -- Thu, 13 Feb 2014
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.46-1) -- Wed, 12 Feb 2014
+
+  * Add dbus error free (Kwangyoun Kim <ky85.kim@samsung.com>)
+  * Update smack rule (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.46) -- Wed, 22 Jan 2014
+
+  * Release version (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.45-1) -- Wed, 22 Jan 2014
+
+  * Update smack rule to access vconf key (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.45) -- Thu, 16 Jan 2014
+
+  * Release version (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.44-1) -- Thu, 16 Jan 2014
+
+  * Update smack rule to access vconf key (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.44) -- Fri, 27 Dec 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.43-1) -- Fri, 27 Dec 2013
+
+  * Update dbus retry (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.43) -- Wed, 18 Dec 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.42-2) -- Wed, 18 Dec 2013
+
+  * Add map type (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.42-1) -- Wed, 18 Dec 2013
+
+  * Fix session blocking (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.42) -- Mon, 16 Dec 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.41-1) -- Mon, 16 Dec 2013
+
+  * Fix minor bug (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.41) -- Fri, 13 Dec 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.40-1) -- Fri, 13 Dec 2013
+
+  * Fix bug not to notify state (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.40) -- Fri, 13 Dec 2013
+
+  * Release version (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.39-2) -- Thu, 12 Dec 2013
+
+  * Support engine disclaimer (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.39-1) -- Thu, 12 Dec 2013
+
+  * Fix bug on initialize timeout (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.39) -- Wed, 11 Dec 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.38-1) -- Wed, 11 Dec 2013
+
+  * Fix bug to notify state not to use sound (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.38) -- Wed, 11 Dec 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.37-3) -- Wed, 11 Dec 2013
+
+  * Fix session bug (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.37-2) -- Wed, 11 Dec 2013
+
+  * Fix bug to play sound (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.37-1) -- Tue, 10 Dec 2013
+
+  * Support start sound and stop sound in daemon (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.37) -- Tue, 03 Dec 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.36-1) -- Mon, 02 Dec 2013
+
+  * Fix log crash bug (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.36) -- Fri, 29 Nov 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.35-2) -- Fri, 29 Nov 2013
+
+  * Fix spec file (Kwangyoun Kim <ky85.kim@samsung.com>)
+  * Change sequence at start (Kwangyoun KIm <ky85.kim@samsung.com>)
+
+stt (0.2.35-1) -- Fri, 29 Nov 2013
+
+  * Update recognition start (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.35) -- Thu, 28 Nov 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.34-1) -- Thu, 28 Nov 2013
+
+  * Update recorder to improve loading time (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.34) -- Thu, 28 Nov 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.33-1) -- Wed, 27 Nov 2013
+
+  * Add silence detection type for no speech (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.33) -- Wed, 27 Nov 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.32-3) -- Wed, 27 Nov 2013
+
+  * Add ignored case for interrupt callback (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.32-2) -- Wed, 27 Nov 2013
+
+  * Update interrupt callback of sound manager (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.32-1) -- Mon, 25 Nov 2013
+
+  * Remove not used engine api (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.32) -- Wed, 20 Nov 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.31-2) -- Wed, 20 Nov 2013
+
+  * Update dbus time out (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.31-1) -- Wed, 20 Nov 2013
+
+  * Add new api to notify default language change (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.31) -- Tue, 19 Nov 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.30-1) -- Tue, 19 Nov 2013
+
+  * Update audio session (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.30) -- Sat, 16 Nov 2013
+
+  * Release version (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.29-1) -- Fri, 15 Nov 2013
+
+  * Fix daemon language change bug (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.29) -- Wed, 13 Nov 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.28-2) -- Wed, 13 Nov 2013
+
+  * Update session manager and recorder type (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.28-1) -- Thu, 7 Nov 2013
+
+  * Update error log and clean up code (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.28) -- Wed, 6 Nov 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.27-2) -- Tue, 5 Nov 2013
+
+  * Fix time info file management (Dongyeol Lee <dy3.lee@samsung.com>)
+  * Remove setting api of hide offensive word (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.27-1) -- Tue, 5 Nov 2013
+
+  * Add return value check (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.27) -- Tue, 5 Nov 2013
+
+  * Release version (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.26-2) -- Mon, 4 Nov 2013
+
+  * Remove pause state and clean up code (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.26-1) -- Mon, 4 Nov 2013
+
+  * Update time stamp using XML file (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.26) -- Fri, 1 Nov 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.25-2) -- Thu, 31 Oct 2013
+
+  * Fix timing bug when daemon intialize and finalize (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.25-1) -- Thu, 31 Oct 2013
+
+  * Fix time stamp size (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.25) -- Thu, 31 Oct 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.24-5) -- Wed, 30 Oct 2013
+
+  * Update TC (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.24-4) -- Wed, 30 Oct 2013
+
+  * Fix bug on recognition result callback (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.24-3) -- Wed, 30 Oct 2013
+
+  * Change dbus waiting time (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.24-2) -- Tue, 29 Oct 2013
+
+  * Update time stamp api and engine api(Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.24-1) -- Mon, 28 Oct 2013
+
+  * Remove hide offensive word api (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.24) -- Mon, 28 Oct 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.23-2) -- Thu, 24 Oct 2013
+
+  * Update TC for added API (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.23-1) -- Wed, 23 Oct 2013
+
+  * Divide devel package (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.23) -- Tue, 22 Oct 2013
+
+  * Release version (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.22-3) -- Tue, 22 Oct 2013
+
+  * Add pluseaudio rule (Dongyeol Lee <dy3.lee@samsung.com>)
+  * Update recorder create in daemon engine init (Dongyeol Lee <dy3.lee@samsung.com>)
+  * Update daemon fork to use thread (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.22-2) -- Tue, 22 Oct 2013
+
+  * Remove not used setting api (Dongyeol Lee <dy3.lee@samsung.com>)
+  * Fix error handling of recorder (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.22-1) -- Thu, 17 Oct 2013
+
+  * Add to unload engine in finalize (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.22) -- Wed, 16 Oct 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.21-3) -- Tue, 15 Oct 2013
+
+  * Fix crash issue from result callback (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.21-2) -- Mon, 14 Oct 2013
+
+  * Support time stamp (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.21-1) -- Tue, 08 Oct 2013
+
+  * Remove old api (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.21) -- Tue, 08 Oct 2013
+
+  * Release version (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.20-2) -- Tue, 08 Oct 2013
+
+  * Fix bug about recording and processing timer (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.20-1) -- Fri, 04 Oct 2013
+
+  * Update engine api for time stamp (Dongyeol Lee <dy3.lee@samsung.com>)
+  * Fix small bug (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.20) -- Mon, 30 Sep 2013
+
+  * Release version (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.19-2) -- Fri, 27 Aug 2013
+
+  * Clean up code and fix bug (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.19-1) -- Thu, 26 Aug 2013
+
+  * Change api for partial result (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.19) -- Thu, 26 Sep 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.18-1) -- Wed, 25 Sep 2013
+
+  * Change engine api for partial result (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.18) -- Tue, 24 Sep 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.17-1) -- Tue, 24 Sep 2013
+
+  * Add TC (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.17) -- Mon, 23 Sep 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.16-1) -- Mon, 16 Sep 2013
+
+  * Fix engine id (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.16) -- Tue, 10 Sep 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.15-4) -- Mon, 9 Sep 2013
+
+  * Fix bug on dbus connection block (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.15-3) -- Fri, 30 Aug 2013
+
+  * Fix CMakeList (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.15-2) -- Thu, 29 Aug 2013
+
+  * Update docs and change api folder (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.15-1) -- Tue, 27 Aug 2013
+
+  * Fix bug of memory check (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.15) -- Thu, 22 Aug 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.14-1) -- Thu, 22 Aug 2013
+
+  * Update engine plugin interface (Dongyeol Lee <dy3.lee@samsung.com>)
+  * Fix the bug about memory clean up (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.14) -- Tue, 20 Aug 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.13-2) -- Fri, 16 Aug 2013
+
+  * Clean up log (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.13-1) -- Fri, 16 Aug 2013
+
+  * Remove punctuation override option (Dongyeol Lee <dy3.lee@samsung.com>)
+  * Add error handling of recording fail (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.13) -- Thu, 08 Aug 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.12-1) -- Thu, 08 Aug 2013
+
+  * Remove ignore session of recording (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.12) -- Wed, 31 Aug 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.11-1) -- Wed, 31 Jul 2013
+
+  * Remove test module (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.11) -- Wed, 31 Jul 2013
+
+  * Fix bug on NULL callback (Kwangyoun Kim <ky85.kim@samsung.com>)
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.11) -- Wed, 31 Jul 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.10-3) -- Wed, 31 Jul 2013
+
+  * Add build config for dlog (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.10-2) -- Wed, 31 Jul 2013
+
+  * Add ignore session of recording (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.10-1) -- Tue, 30 Jul 2013
+
+  * Add test module (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.10) -- Thu, 18 Jul 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.9-1) -- Thu, 18 Jul 2013
+
+  * Fix client create bug (Dongyeol Lee <dy3.lee@samsung.com>)
+  * Clean up directory path (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.9) -- Thu, 13 Jul 2013
+
+  * Release version (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.8-1) -- Thu, 13 Jul 2013
+
+  * Fix memory init error of config (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.8) -- Thu, 11 Jul 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.7-1) -- Thu, 11 Jul 2013
+
+  * Fix prevent issue (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.7) -- Wed, 10 Jul 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.6-5) -- Tue, 09 Jul 2013
+
+  * Update to get info from config (Dongyeol Lee <dy3.lee@samsung.com>)
+  * Fix code to manage config callback (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.6-4) -- Fri, 05 Jul 2013
+
+  * Fix bug to set engine id (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.6-3) -- Thu, 04 Jul 2013
+
+  * Set default language en_GB (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.6-2) -- Wed, 03 Jul 2013
+
+  * Update auto language (Dongyeol Lee <dy3.lee@samsung.com>)
+  * Clean up config code (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.6-1) -- Sat, 29 Jun 2013
+
+  * Update smack label of voice directory (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.6) -- Wed, 12 Jun 2013
+
+  * Release version (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.5-2) -- Wed, 12 Jun 2013
+
+  * Add code for secure log (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.5-1) -- Wed, 12 Jun 2013
+
+  * Fix bug to get wrong default language (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.5) -- Fri, 07 May 2013
+
+  * Release version 0.2.5 (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.4-2) -- Fri, 07 May 2013
+
+  * Fix timer issue (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.4-1) -- Fri, 07 May 2013
+
+  * Fix timer double free (Dongyeol Lee <dy3.lee@samsung.com>)
+  * Fix prevent issue (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.4) -- Mon, 17 May 2013
+
+  * Release version 0.2.4 (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.3-2) -- Mon, 27 May 2013
+
+  * Delete unused log (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.3-1) -- Sat, 25 May 2013
+
+  * Update configure to XML based (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.3) -- Tue, 14 May 2013
+
+  * Release version 0.2.3 (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.2-1) -- Tue, 14 May 2013
+
+  * Fix bug about client check in callback (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.2) -- Wed, 08 May 2013
+
+  * Release version 0.2.2 (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.1-2) -- Wed, 08 May 2013
+
+  * Update to set default language from display language (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.1-1) -- Tue, 07 May 2013
+
+  * Delete code about print (Kwangyoun Kim <ky85.kim@samsung.com>)
+
+stt (0.2.1) -- Mon, 06 May 2013
+
+  * Release version 0.2.1 (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.0-4) -- Mon, 06 May 2013
+
+  * Fix BS issue (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.0-3) -- Fri, 03 May 2013
+
+  * Update to retry daemon fork (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.0-2) -- Fri, 03 May 2013
+
+  * Add recording timeout (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.0-1) -- Tue, 23 Apr 2013
+
+  * Fix prevent issues (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.2.0) -- Fri, 19 Apr 2013
+
+  * Release version 0.2.0 (Dongyeol Lee <dy3.lee@samsung.com>)
+
+stt (0.1.41-1) -- Thu, 18 Apr 2013
+
+  * Support multi-engine of application (Dongyeol Lee <dy3.lee@samsung.com>)
+
 stt (0.1.41) -- Tue, 16 Apr 2013
 
   * Release version 0.1.41 (Kwangyoun Kim <ky85.kim@samsung.com>)
index 659fa72..1c2662c 100644 (file)
@@ -1,43 +1,29 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(stt C)
-
-SET(PREFIX ${CMAKE_INSTALL_PREFIX})
-SET(EXEC_PREFIX "${PREFIX}")
-SET(LIBDIR "${PREFIX}/lib")
-SET(INCLUDEDIR "${PREFIX}/include")
-SET(VERSION 0.0.1)
-
 SET(SRCS 
        stt.c
        stt_client.c
        stt_dbus.c
+       ../common/stt_config_mgr.c
+       ../common/stt_config_parser.c
+)
+
+SET(FILE_SRCS
+       stt_file.c
+       stt_file_client.c
+       ../common/stt_config_mgr.c
+       ../common/stt_config_parser.c
+       ../common/stt_engine.c
+       ../common/stt_network.c
 )
 
 set(SETTING_SRCS
        stt_setting.c
-       stt_setting_dbus.c      
+       ../common/stt_config_mgr.c
+       ../common/stt_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)
-
-## Dependent packages ##
-#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_BINARY_DIR}/include)
+INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/server)
 
 FOREACH(flag ${pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
@@ -46,23 +32,20 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
 
 ## Add definitions ##
 ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
-#ADD_DEFINITIONS(-DSLP_DEBUG)
 
 ## stt library ##
-ADD_LIBRARY("${PROJECT_NAME}_static" STATIC ${SRCS})
 ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
 TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
 
+## stt file library ##
+ADD_LIBRARY("${PROJECT_NAME}_file" SHARED ${FILE_SRCS})
+TARGET_LINK_LIBRARIES("${PROJECT_NAME}_file" ${pkgs_LDFLAGS})
+
 ## stt-setting library ##
 ADD_LIBRARY("${PROJECT_NAME}_setting" SHARED ${SETTING_SRCS})
 TARGET_LINK_LIBRARIES("${PROJECT_NAME}_setting" ${pkgs_LDFLAGS})
 
-## configure pkgconfig files ##
-CONFIGURE_FILE(stt.pc.in "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc" @ONLY)
-CONFIGURE_FILE(stt-setting.pc.in "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}-setting.pc" @ONLY)
-
 ## Install library files ##
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
-INSTALL(TARGETS "${PROJECT_NAME}_setting" DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
-INSTALL(FILES "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc" "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}-setting.pc" DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/stt.h ${CMAKE_CURRENT_SOURCE_DIR}/stt_setting.h DESTINATION include)
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIBDIR} COMPONENT RuntimeLibraries)
+INSTALL(TARGETS "${PROJECT_NAME}_file" DESTINATION ${LIBDIR} COMPONENT RuntimeLibraries)
+INSTALL(TARGETS "${PROJECT_NAME}_setting" DESTINATION ${LIBDIR} COMPONENT RuntimeLibraries)
index 76aa110..ec0aeed 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 <sys/types.h> 
-#include <unistd.h>
+#include <aul.h>
+#include <dirent.h>
 #include <Ecore.h>
+#include <fcntl.h>
+#include <pthread.h>
 #include <sys/stat.h>
-#include <dirent.h>
+#include <sys/types.h> 
+#include <sys/wait.h>
+#include <system_info.h>
+#include <unistd.h>
 
 #include "stt.h"
-#include "stt_main.h"
 #include "stt_client.h"
 #include "stt_dbus.h"
+#include "stt_config_mgr.h"
+#include "stt_main.h"
 
-#define CONNECTION_RETRY_COUNT 3
 
 static bool g_is_daemon_started = false;
 
 static Ecore_Timer* g_connect_timer = NULL;
 
-static int __check_stt_daemon();
 static Eina_Bool __stt_notify_state_changed(void *data);
 static Eina_Bool __stt_notify_error(void *data);
 
+static int g_stt_daemon_pid = -1;
+static int g_count_check_daemon = 0;
+
+const char* stt_tag()
+{
+       return "sttc";
+}
+
+static const char* __stt_get_error_code(stt_error_e err)
+{
+       switch(err) {
+       case STT_ERROR_NONE:                    return "STT_ERROR_NONE";
+       case STT_ERROR_OUT_OF_MEMORY:           return "STT_ERROR_OUT_OF_MEMORY";
+       case STT_ERROR_IO_ERROR:                return "STT_ERROR_IO_ERROR";
+       case STT_ERROR_INVALID_PARAMETER:       return "STT_ERROR_INVALID_PARAMETER";
+       case STT_ERROR_TIMED_OUT:               return "STT_ERROR_TIMED_OUT";
+       case STT_ERROR_RECORDER_BUSY:           return "STT_ERROR_RECORDER_BUSY";
+       case STT_ERROR_OUT_OF_NETWORK:          return "STT_ERROR_OUT_OF_NETWORK";
+       case STT_ERROR_PERMISSION_DENIED:       return "STT_ERROR_PERMISSION_DENIED";
+       case STT_ERROR_NOT_SUPPORTED:           return "STT_ERROR_NOT_SUPPORTED";
+       case STT_ERROR_INVALID_STATE:           return "STT_ERROR_INVALID_STATE";
+       case STT_ERROR_INVALID_LANGUAGE:        return "STT_ERROR_INVALID_LANGUAGE";
+       case STT_ERROR_ENGINE_NOT_FOUND:        return "STT_ERROR_ENGINE_NOT_FOUND";
+       case STT_ERROR_OPERATION_FAILED:        return "STT_ERROR_OPERATION_FAILED";
+       case STT_ERROR_NOT_SUPPORTED_FEATURE:   return "STT_ERROR_NOT_SUPPORTED_FEATURE";
+       default:
+               return "Invalid error code";
+       }
+}
+
+static int __stt_convert_config_error_code(stt_config_error_e code)
+{
+       if (code == STT_CONFIG_ERROR_NONE)                      return STT_ERROR_NONE;
+       if (code == STT_CONFIG_ERROR_OUT_OF_MEMORY)             return STT_ERROR_OUT_OF_MEMORY;
+       if (code == STT_CONFIG_ERROR_IO_ERROR)                  return STT_ERROR_IO_ERROR;
+       if (code == STT_CONFIG_ERROR_INVALID_PARAMETER)         return STT_ERROR_INVALID_PARAMETER;
+       if (code == STT_CONFIG_ERROR_PERMISSION_DENIED)         return STT_ERROR_PERMISSION_DENIED;
+       if (code == STT_CONFIG_ERROR_NOT_SUPPORTED)             return STT_ERROR_NOT_SUPPORTED;
+       if (code == STT_CONFIG_ERROR_INVALID_STATE)             return STT_ERROR_INVALID_STATE;
+       if (code == STT_CONFIG_ERROR_INVALID_LANGUAGE)          return STT_ERROR_INVALID_LANGUAGE;
+       if (code == STT_CONFIG_ERROR_ENGINE_NOT_FOUND)          return STT_ERROR_ENGINE_NOT_FOUND;
+       if (code == STT_CONFIG_ERROR_OPERATION_FAILED)          return STT_ERROR_OPERATION_FAILED;
+
+       return code;
+}
+
+void __stt_config_lang_changed_cb(const char* before_language, const char* current_language, void* user_data)
+{
+       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "Language changed : Before lang(%s) Current lang(%s)", 
+               before_language, current_language);
+
+       if (0 == strcmp(before_language, current_language)) {
+               return;
+       }
+
+       GList* client_list = NULL;
+       client_list = stt_client_get_client_list();
+
+       GList *iter = NULL;
+       stt_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_lang_changed_cb) {
+                               SECURE_SLOG(LOG_DEBUG, TAG_STTC, "Call default language changed callback : uid(%d)", data->uid);
+                               data->default_lang_changed_cb(data->stt, before_language, current_language, 
+                                       data->default_lang_changed_user_data);
+                       }
+
+                       /* Next item */
+                       iter = g_list_next(iter);
+               }
+       }
+
+       return; 
+}
+
 int stt_create(stt_h* stt)
 {
+       bool stt_supported = false;
+       bool mic_supported = false;
+       if (0 == system_info_get_platform_bool(STT_FEATURE_PATH, &stt_supported)) {
+               if (0 == system_info_get_platform_bool(STT_MIC_FEATURE_PATH, &mic_supported)) {
+                       if (false == stt_supported || false == mic_supported) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] STT NOT supported");
+                               return STT_ERROR_NOT_SUPPORTED;
+                       }
+               }
+       }
+
        SLOG(LOG_DEBUG, TAG_STTC, "===== Create STT");
 
        if (NULL == stt) {
@@ -55,7 +149,30 @@ int stt_create(stt_h* stt)
                return STT_ERROR_OUT_OF_MEMORY;
        }
 
-       SLOG(LOG_DEBUG, TAG_STTC, "[Success] uid(%d)", (*stt)->handle);
+       stt_client_s* client = stt_client_get(*stt);
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to create client");
+               stt_client_destroy(*stt);
+               return STT_ERROR_OPERATION_FAILED;
+       }
+
+       int ret = stt_config_mgr_initialize(client->uid);
+       ret = __stt_convert_config_error_code(ret);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to init config manager : %s", __stt_get_error_code(ret));
+               stt_client_destroy(*stt);
+               return ret;
+       }
+
+       ret = stt_config_mgr_set_callback(client->uid, NULL, __stt_config_lang_changed_cb, NULL, NULL);
+       ret = __stt_convert_config_error_code(ret);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to set config changed : %s", __stt_get_error_code(ret));
+               stt_client_destroy(*stt);
+               return ret;
+       }
+
+       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "[Success] uid(%d)", (*stt)->handle);
 
        SLOG(LOG_DEBUG, TAG_STTC, "=====");
        SLOG(LOG_DEBUG, TAG_STTC, " ");
@@ -65,6 +182,17 @@ int stt_create(stt_h* stt)
 
 int stt_destroy(stt_h stt)
 {
+       bool stt_supported = false;
+       bool mic_supported = false;
+       if (0 == system_info_get_platform_bool(STT_FEATURE_PATH, &stt_supported)) {
+               if (0 == system_info_get_platform_bool(STT_MIC_FEATURE_PATH, &mic_supported)) {
+                       if (false == stt_supported || false == mic_supported) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] STT NOT supported");
+                               return STT_ERROR_NOT_SUPPORTED;
+                       }
+               }
+       }
+
        SLOG(LOG_DEBUG, TAG_STTC, "===== Destroy STT");
 
        if (NULL == stt) {
@@ -88,6 +216,8 @@ int stt_destroy(stt_h stt)
                return STT_ERROR_OPERATION_FAILED;
        }
 
+       stt_config_mgr_finalize(client->uid);
+
        int ret = -1;
 
        /* check state */
@@ -97,21 +227,24 @@ int stt_destroy(stt_h stt)
        case STT_STATE_READY:
                ret = stt_dbus_request_finalize(client->uid);
                if (0 != ret) {
-                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to request finalize");
+                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to request finalize : %s", __stt_get_error_code(ret));
                }
+
                g_is_daemon_started = false;
        case STT_STATE_CREATED:
                if (NULL != g_connect_timer) {
                        SLOG(LOG_DEBUG, TAG_STTC, "Connect Timer is deleted");
                        ecore_timer_del(g_connect_timer);
+                       g_connect_timer = NULL;
                }
+
                /* Free resources */
                stt_client_destroy(stt);
                break;
+       default:
+               break;
        }
 
-       SLOG(LOG_DEBUG, TAG_STTC, "Success: destroy");
-
        if (0 == stt_client_get_size()) {
                if (0 != stt_dbus_close_connection()) {
                        SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to close connection");
@@ -124,76 +257,417 @@ int stt_destroy(stt_h stt)
        return STT_ERROR_NONE;
 }
 
-static Eina_Bool __stt_connect_daemon(void *data)
+bool __stt_config_supported_engine_cb(const char* engine_id, const char* engine_name, 
+                                     const char* setting, bool support_silence, void* user_data)
 {
-       stt_h stt = (stt_h)data;
+       stt_h stt = (stt_h)user_data;
 
        stt_client_s* client = stt_client_get(stt);
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_STTC, "[WARNING] A handle is not valid");
+               return false;
+       }
 
+       /* call callback function */
+       if (NULL != client->supported_engine_cb) {
+               return client->supported_engine_cb(stt, engine_id, engine_name, client->supported_engine_user_data);
+       } else {
+               SLOG(LOG_WARN, TAG_STTC, "No registered callback function of supported engine");
+       }
+       
+       return false;
+}
+
+int stt_foreach_supported_engines(stt_h stt, stt_supported_engine_cb callback, void* user_data)
+{
+       bool stt_supported = false;
+       bool mic_supported = false;
+       if (0 == system_info_get_platform_bool(STT_FEATURE_PATH, &stt_supported)) {
+               if (0 == system_info_get_platform_bool(STT_MIC_FEATURE_PATH, &mic_supported)) {
+                       if (false == stt_supported || false == mic_supported) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] STT NOT supported");
+                               return STT_ERROR_NOT_SUPPORTED;
+                       }
+               }
+       }
+
+       SLOG(LOG_DEBUG, TAG_STTC, "===== Foreach Supported engine");
+
+       if (NULL == stt || NULL == callback) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
+               SLOG(LOG_DEBUG, TAG_STTC, "=====");
+               SLOG(LOG_DEBUG, TAG_STTC, " ");
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+
+       stt_client_s* client = stt_client_get(stt);
+
+       /* check handle */
        if (NULL == client) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
+               SLOG(LOG_DEBUG, TAG_STTC, "=====");
+               SLOG(LOG_DEBUG, TAG_STTC, " ");
                return STT_ERROR_INVALID_PARAMETER;
        }
 
-       /* Send hello */
-       if (0 != stt_dbus_request_hello()) {
-               if (false == g_is_daemon_started) {
-                       g_is_daemon_started = true;
-                       __check_stt_daemon();
+       if (client->current_state != STT_STATE_CREATED) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state is not CREATE");
+               SLOG(LOG_DEBUG, TAG_STTC, "=====");
+               SLOG(LOG_DEBUG, TAG_STTC, " ");
+               return STT_ERROR_INVALID_STATE;
+       }
+
+       client->supported_engine_cb = callback;
+       client->supported_engine_user_data = user_data;
+
+       int ret = 0;
+       ret = stt_config_mgr_get_engine_list(__stt_config_supported_engine_cb, client->stt);
+       ret = __stt_convert_config_error_code(ret);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to get engines : %s", __stt_get_error_code(ret));
+       }
+
+       client->supported_engine_cb = NULL;
+       client->supported_engine_user_data = NULL;
+
+       SLOG(LOG_DEBUG, TAG_STTC, "=====");
+       SLOG(LOG_DEBUG, TAG_STTC, " ");
+
+       return ret;
+}
+
+int stt_get_engine(stt_h stt, char** engine_id)
+{
+       bool stt_supported = false;
+       bool mic_supported = false;
+       if (0 == system_info_get_platform_bool(STT_FEATURE_PATH, &stt_supported)) {
+               if (0 == system_info_get_platform_bool(STT_MIC_FEATURE_PATH, &mic_supported)) {
+                       if (false == stt_supported || false == mic_supported) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] STT NOT supported");
+                               return STT_ERROR_NOT_SUPPORTED;
+                       }
                }
-               return EINA_TRUE;
        }
 
-       SLOG(LOG_DEBUG, TAG_STTC, "===== Connect daemon");
+       SLOG(LOG_DEBUG, TAG_STTC, "===== Get current engine");
 
-       /* request initialization */
-       int ret = -1;
-       int i = 1;
-       bool silence_supported = false;
-       bool profanity_supported = false;
-       bool punctuation_supported = false;
+       if (NULL == stt || NULL == engine_id) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
+               SLOG(LOG_DEBUG, TAG_STTC, "=====");
+               SLOG(LOG_DEBUG, TAG_STTC, " ");
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+
+       stt_client_s* client = stt_client_get(stt);
+
+       /* check handle */
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
+               SLOG(LOG_DEBUG, TAG_STTC, "=====");
+               SLOG(LOG_DEBUG, TAG_STTC, " ");
+               return STT_ERROR_INVALID_PARAMETER;
+       }
 
-       while (1) {
-               ret = stt_dbus_request_initialize(client->uid, &silence_supported, &profanity_supported, &punctuation_supported);
+       if (client->current_state != STT_STATE_CREATED) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state is not CREATE");
+               SLOG(LOG_DEBUG, TAG_STTC, "=====");
+               SLOG(LOG_DEBUG, TAG_STTC, " ");
+               return STT_ERROR_INVALID_STATE;
+       }
+
+       int ret = 0;
+       ret = stt_config_mgr_get_engine(engine_id);
+       ret = __stt_convert_config_error_code(ret);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to request get current engine : %s", __stt_get_error_code(ret));
+       } else {
+               SECURE_SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Current engine uuid = %s", *engine_id);
+       }
 
-               if (STT_ERROR_ENGINE_NOT_FOUND == ret) {
-                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to initialize : STT Engine Not found");
-                       
-                       client->reason = STT_ERROR_ENGINE_NOT_FOUND;
+       SLOG(LOG_DEBUG, TAG_STTC, "=====");
+       SLOG(LOG_DEBUG, TAG_STTC, " ");
 
-                       ecore_timer_add(0, __stt_notify_error, (void*)stt);
+       return ret;
+}
 
-                       return EINA_FALSE;
+int stt_set_engine(stt_h stt, const char* engine_id)
+{
+       bool stt_supported = false;
+       bool mic_supported = false;
+       if (0 == system_info_get_platform_bool(STT_FEATURE_PATH, &stt_supported)) {
+               if (0 == system_info_get_platform_bool(STT_MIC_FEATURE_PATH, &mic_supported)) {
+                       if (false == stt_supported || false == mic_supported) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] STT NOT supported");
+                               return STT_ERROR_NOT_SUPPORTED;
+                       }
+               }
+       }
 
-               } else if(0 != ret) {
-                       usleep(1);
-                       if(CONNECTION_RETRY_COUNT == i) {
-                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to initialize : TIMED OUT");
+       SLOG(LOG_DEBUG, TAG_STTC, "===== Set current engine");
 
-                               client->reason = STT_ERROR_TIMED_OUT;
+       if (NULL == stt || NULL == engine_id) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
+               SLOG(LOG_DEBUG, TAG_STTC, "=====");
+               SLOG(LOG_DEBUG, TAG_STTC, " ");
+               return STT_ERROR_INVALID_PARAMETER;
+       }
 
-                               ecore_timer_add(0, __stt_notify_error, (void*)stt);
+       stt_client_s* client = stt_client_get(stt);
 
-                               return EINA_FALSE;
-                       }    
-                       i++;
+       /* check handle */
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
+               SLOG(LOG_DEBUG, TAG_STTC, "=====");
+               SLOG(LOG_DEBUG, TAG_STTC, " ");
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+
+       /* check state */
+       if (client->current_state != STT_STATE_CREATED) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state is not CREATE");
+               SLOG(LOG_DEBUG, TAG_STTC, "=====");
+               SLOG(LOG_DEBUG, TAG_STTC, " ");
+               return STT_ERROR_INVALID_STATE;
+       }
+
+       if (NULL != client->current_engine_id) {
+               free(client->current_engine_id);
+       }
+
+       client->current_engine_id = strdup(engine_id);
+#if 0
+       if (client->current_state == STT_STATE_READY) {
+               int ret = 0;
+               bool silence_supported = false;
+
+               ret = stt_dbus_request_set_current_engine(client->uid, engine_id, &silence_supported);
+
+               if (0 != ret) {
+                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to set current engine : %s", __stt_get_error_code(ret));
+                       return ret;
                } else {
-                       /* success to connect stt-daemon */
-                       stt_client_set_option_supported(client->stt, silence_supported, profanity_supported, punctuation_supported);
-                       SLOG(LOG_DEBUG, TAG_STTC, "Supported options : silence(%s), profanity(%s), punctuation(%s)", 
-                               silence_supported ? "true" : "false", profanity_supported ? "true" : "false", punctuation_supported ? "true" : "false");
-                       break;
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Current engine uuid = %s", engine_id);
+
+                       /* success to change engine */
+                       client->silence_supported = silence_supported;
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "Supported options : silence(%s)", silence_supported ? "true" : "false");
                }
        }
+#endif
+       SLOG(LOG_DEBUG, TAG_STTC, "=====");
+       SLOG(LOG_DEBUG, TAG_STTC, " ");
 
-       client->before_state = client->current_state;
-       client->current_state = STT_STATE_READY;
+       return 0;
+}
 
-       ecore_timer_add(0, __stt_notify_state_changed, (void*)stt);
+static int __read_proc(const char *path, char *buf, int size)
+{
+       int fd;
+       int ret;
+
+       if (NULL == buf || NULL == path) {
+               return -1;
+       }
+
+       fd = open(path, O_RDONLY);
+       if (fd < 0) {
+               return -1;
+       }
+
+       ret = read(fd, buf, size - 1);
+       if (0 >= ret) {
+               close(fd);
+               return -1;
+       } else {
+               buf[ret] = 0;
+       }
+       close(fd);
+       return ret;
+}
+
+static bool __stt_check_daemon_exist()
+{
+       char buf[128];
+       int ret;
+
+       FILE* fp;
+       fp = fopen(STT_PID_FILE_PATH, "r");
+       if (NULL == fp) {
+               return false;
+       }
+
+       g_stt_daemon_pid = -1;
+       int pid;
+       if (0 >= fscanf(fp, "%d", &pid)) {
+               SECURE_SLOG(LOG_DEBUG, TAG_STTC, "Fail to read pid");
+               fclose(fp);
+               return false;
+       }
+
+       fclose(fp);
+       snprintf(buf, sizeof(buf), "/proc/%d/cmdline", pid);
+       ret = __read_proc(buf, buf, sizeof(buf));
+       if (0 >= ret) {
+               return false;
+       } else {
+               if (!strcmp(buf, "/usr/bin/stt-daemon")) {
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "Daemon existed - [%d]%s", pid, buf);
+                       g_stt_daemon_pid = pid;
+                       return true;
+               }
+       }
+       return false;
+}
+
+static void* __fork_stt_daemon(void* NotUsed)
+{
+       int pid, i;
+       pid = fork();
+
+       switch(pid) {
+       case -1:
+               SLOG(LOG_DEBUG, TAG_STTC, "[STT ERROR] fail to create STT-DAEMON");
+               break;
+
+       case 0:
+               setsid();
+               for (i = 0;i < _NSIG;i++)
+                       signal(i, SIG_DFL);
+
+               execl("/usr/bin/stt-daemon", "/usr/bin/stt-daemon", NULL);
+               break;
+
+       default:
+               break;
+       }
+
+       return (void*) 1;
+}
+
+static Eina_Bool __stt_connect_daemon(void *data)
+{
+       stt_client_s* client = (stt_client_s*)data;
+
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
+               return EINA_FALSE;
+       }
+
+       /* Send hello */
+       int ret = -1;
+       ret = stt_dbus_request_hello();
+
+       if (STT_DAEMON_NORMAL != ret) {
+               if (STT_ERROR_INVALID_STATE == ret) {
+                       return EINA_FALSE;
+               }
+
+               if (STT_DAEMON_ON_TERMINATING == ret) {
+                       /* Todo - Wait for terminating and do it again*/
+                       usleep(50);
+                       return EINA_TRUE;
+               } else {
+                       /* for new daemon */
+                       bool check = __stt_check_daemon_exist();
+                       if (true == check) {
+                               g_count_check_daemon++;
+                               if (3 < g_count_check_daemon) {
+                                       /* Todo - Kill daemon and restart */
+                                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "Need to Kill daemon");
+                               }
+                               usleep(50);
+                               return EINA_TRUE;
+                       } else {
+                               if (false == g_is_daemon_started) {
+                                       g_is_daemon_started = true;
+                                       
+                                       pthread_t thread;
+                                       int thread_id;
+                                       thread_id = pthread_create(&thread, NULL, __fork_stt_daemon, NULL);
+                                       if (thread_id < 0) {
+                                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to make thread");
+                                               g_connect_timer = NULL;
+                                               return EINA_FALSE;
+                                       }
+
+                                       pthread_detach(thread);
+                               }
+
+                               usleep(50);
+                               return EINA_TRUE;
+                       }
+               }
+       }
 
        g_connect_timer = NULL;
+       SLOG(LOG_DEBUG, TAG_STTC, "===== Connect daemon");
+
+       /* request initialization */
+
+       bool silence_supported = false;
+
+       ret = stt_dbus_request_initialize(client->uid, &silence_supported);
+
+       if (STT_ERROR_ENGINE_NOT_FOUND == ret) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to initialize : %s", __stt_get_error_code(ret));
+               
+               client->reason = STT_ERROR_ENGINE_NOT_FOUND;
+               ecore_timer_add(0, __stt_notify_error, (void*)client);
+
+               return EINA_FALSE;
+
+       } else if (STT_ERROR_NONE != ret) {
+               SLOG(LOG_ERROR, TAG_STTC, "[WARNING] Fail to connection. Retry to connect");
+               return EINA_TRUE;
+       } else {
+               /* success to connect stt-daemon */
+               client->silence_supported = silence_supported;
+               SECURE_SLOG(LOG_DEBUG, TAG_STTC, "Supported options : silence(%s)", silence_supported ? "true" : "false");
+       }
+
+       if (NULL != client->current_engine_id) {
+               ret = -1;
+               int count = 0;
+               silence_supported = false;
+               while (0 != ret) {
+                       ret = stt_dbus_request_set_current_engine(client->uid, client->current_engine_id, &silence_supported);
+                       if (0 != ret) {
+                               if (STT_ERROR_TIMED_OUT != ret) {
+                                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to set current engine : %s", __stt_get_error_code(ret));
+                                       return ret;
+                               } else {
+                                       SLOG(LOG_WARN, TAG_STTC, "[WARNING] retry");
+                                       usleep(10);
+                                       count++;
+                                       if (10 == count) {
+                                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to request");
+                                               return ret;
+                                       }
+                               }
+                       } else {
+                               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Current engine uuid = %s", client->current_engine_id);
+
+                               /* success to change engine */
+                               client->silence_supported = silence_supported;
+                               SLOG(LOG_DEBUG, TAG_STTC, "Supported options : silence(%s)", silence_supported ? "true" : "false");
+                       }
+               }
+       }
+
+       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] uid(%d)", client->uid);
 
-       SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] uid(%d)", client->uid);
+       client->before_state = client->current_state;
+       client->current_state = STT_STATE_READY;
+
+       if (NULL != client->state_changed_cb) {
+               stt_client_use_callback(client);
+               client->state_changed_cb(client->stt, client->before_state, 
+                       client->current_state, client->state_changed_user_data); 
+               stt_client_not_use_callback(client);
+               SLOG(LOG_DEBUG, TAG_STTC, "State changed callback is called");
+       } else {
+               SLOG(LOG_WARN, TAG_STTC, "[WARNING] State changed callback is null");
+       }
 
        SLOG(LOG_DEBUG, TAG_STTC, "=====");
        SLOG(LOG_DEBUG, TAG_STTC, "  ");
@@ -201,9 +675,19 @@ static Eina_Bool __stt_connect_daemon(void *data)
        return EINA_FALSE;
 }
 
-
 int stt_prepare(stt_h stt)
 {
+       bool stt_supported = false;
+       bool mic_supported = false;
+       if (0 == system_info_get_platform_bool(STT_FEATURE_PATH, &stt_supported)) {
+               if (0 == system_info_get_platform_bool(STT_MIC_FEATURE_PATH, &mic_supported)) {
+                       if (false == stt_supported || false == mic_supported) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] STT NOT supported");
+                               return STT_ERROR_NOT_SUPPORTED;
+                       }
+               }
+       }
+
        SLOG(LOG_DEBUG, TAG_STTC, "===== Prepare STT");
 
        stt_client_s* client = stt_client_get(stt);
@@ -218,13 +702,14 @@ int stt_prepare(stt_h stt)
 
        /* check state */
        if (client->current_state != STT_STATE_CREATED) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state is not 'CREATED'"); 
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state is not 'CREATED'");
                SLOG(LOG_DEBUG, TAG_STTC, "=====");
                SLOG(LOG_DEBUG, TAG_STTC, " ");
                return STT_ERROR_INVALID_STATE;
        }
 
-       g_connect_timer = ecore_timer_add(0, __stt_connect_daemon, (void*)stt);
+       g_count_check_daemon = 0;
+       g_connect_timer = ecore_timer_add(0, __stt_connect_daemon, (void*)client);
 
        SLOG(LOG_DEBUG, TAG_STTC, "=====");
        SLOG(LOG_DEBUG, TAG_STTC, " ");
@@ -234,6 +719,14 @@ int stt_prepare(stt_h stt)
 
 int stt_unprepare(stt_h stt)
 {
+       bool supported = false;
+       if (0 == system_info_get_platform_bool(STT_FEATURE_PATH, &supported)) {
+               if (false == supported) {
+                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] STT NOT supported");
+                       return STT_ERROR_NOT_SUPPORTED;
+               }
+       }
+
        SLOG(LOG_DEBUG, TAG_STTC, "===== Unprepare STT");
 
        stt_client_s* client = stt_client_get(stt);
@@ -246,22 +739,47 @@ int stt_unprepare(stt_h stt)
 
        /* check state */
        if (client->current_state != STT_STATE_READY) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state is not 'READY'"); 
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state is not 'READY'");
                SLOG(LOG_DEBUG, TAG_STTC, "=====");
                SLOG(LOG_DEBUG, TAG_STTC, " ");
                return STT_ERROR_INVALID_STATE;
        }
 
-       int ret = stt_dbus_request_finalize(client->uid);
-       if (0 != ret) {
-               SLOG(LOG_WARN, TAG_STTC, "[ERROR] Fail to request finalize");
+       int ret = -1;
+       int count = 0;
+       while (0 != ret) {
+               ret = stt_dbus_request_finalize(client->uid);
+               if (0 != ret) {
+                       if (STT_ERROR_TIMED_OUT != ret) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to request finalize : %s", __stt_get_error_code(ret));
+                               break;
+                       } else {
+                               SLOG(LOG_WARN, TAG_STTC, "[WARNING] retry");
+                               usleep(10);
+                               count++;
+                               if (10 == count) {
+                                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to request");
+                                       break;
+                               }
+                       }
+               }
        }
+
        g_is_daemon_started = false;
 
+       client->internal_state = STT_INTERNAL_STATE_NONE;
+
        client->before_state = client->current_state;
        client->current_state = STT_STATE_CREATED;
 
-       ecore_timer_add(0, __stt_notify_state_changed, (void*)stt);
+       if (NULL != client->state_changed_cb) {
+               stt_client_use_callback(client);
+               client->state_changed_cb(client->stt, client->before_state, 
+                       client->current_state, client->state_changed_user_data); 
+               stt_client_not_use_callback(client);
+       } else {
+               SLOG(LOG_WARN, TAG_STTC, "[WARNING] State changed callback is null");
+       }
 
        SLOG(LOG_DEBUG, TAG_STTC, "=====");
        SLOG(LOG_DEBUG, TAG_STTC, " ");
@@ -269,8 +787,39 @@ int stt_unprepare(stt_h stt)
        return STT_ERROR_NONE;
 }
 
+bool __stt_config_supported_language_cb(const char* engine_id, const char* language, void* user_data)
+{
+       stt_h stt = (stt_h)user_data;
+
+       stt_client_s* client = stt_client_get(stt);
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_STTC, "[WARNING] A handle is not valid");
+               return false;
+       }
+
+       /* call callback function */
+       if (NULL != client->supported_lang_cb) {
+               return client->supported_lang_cb(stt, language, client->supported_lang_user_data);
+       } else {
+               SLOG(LOG_WARN, TAG_STTC, "No registered callback function of supported languages");
+       }
+
+       return false;
+}
+
 int stt_foreach_supported_languages(stt_h stt, stt_supported_language_cb callback, void* user_data)
 {
+       bool stt_supported = false;
+       bool mic_supported = false;
+       if (0 == system_info_get_platform_bool(STT_FEATURE_PATH, &stt_supported)) {
+               if (0 == system_info_get_platform_bool(STT_MIC_FEATURE_PATH, &mic_supported)) {
+                       if (false == stt_supported || false == mic_supported) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] STT NOT supported");
+                               return STT_ERROR_NOT_SUPPORTED;
+                       }
+               }
+       }
+
        SLOG(LOG_DEBUG, TAG_STTC, "===== Foreach Supported Language");
 
        if (NULL == stt || NULL == callback) {
@@ -290,29 +839,55 @@ int stt_foreach_supported_languages(stt_h stt, stt_supported_language_cb callbac
                return STT_ERROR_INVALID_PARAMETER;
        }
 
-       /* check state */
-       if (client->current_state != STT_STATE_READY) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state is not READY"); 
-               return STT_ERROR_INVALID_STATE;
+       int ret;
+       char* current_engine_id = NULL;
+
+       if (NULL == client->current_engine_id) {
+               ret = stt_config_mgr_get_engine(&current_engine_id);
+               ret = __stt_convert_config_error_code(ret);
+               if (0 != ret) {
+                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to get default engine id : %s", __stt_get_error_code(ret));
+                       return ret;
+               }
+       } else {
+               current_engine_id = strdup(client->current_engine_id);
        }
 
-       int ret = 0;
-       ret = stt_dbus_request_get_support_langs(client->uid, client->stt, callback, user_data);
+       client->supported_lang_cb = callback;
+       client->supported_lang_user_data = user_data;
+
+       ret = stt_config_mgr_get_language_list(current_engine_id, __stt_config_supported_language_cb, client->stt);
+       ret = __stt_convert_config_error_code(ret);
        if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to get languages");
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS]");
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to get languages : %s", __stt_get_error_code(ret));
+       }
+
+       if (NULL != current_engine_id) {
+               free(current_engine_id);
        }
 
+       client->supported_lang_cb = NULL;
+       client->supported_lang_user_data = NULL;
+
        SLOG(LOG_DEBUG, TAG_STTC, "=====");
        SLOG(LOG_DEBUG, TAG_STTC, " ");
 
-       return STT_ERROR_NONE;
+       return ret;
 }
 
-
 int stt_get_default_language(stt_h stt, char** language)
 {
+       bool stt_supported = false;
+       bool mic_supported = false;
+       if (0 == system_info_get_platform_bool(STT_FEATURE_PATH, &stt_supported)) {
+               if (0 == system_info_get_platform_bool(STT_MIC_FEATURE_PATH, &mic_supported)) {
+                       if (false == stt_supported || false == mic_supported) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] STT NOT supported");
+                               return STT_ERROR_NOT_SUPPORTED;
+                       }
+               }
+       }
+
        SLOG(LOG_DEBUG, TAG_STTC, "===== Get Default Language");
 
        if (NULL == stt || NULL == language) {
@@ -332,17 +907,11 @@ int stt_get_default_language(stt_h stt, char** language)
                return STT_ERROR_INVALID_PARAMETER;
        }
 
-       /* check state */
-       if (client->current_state != STT_STATE_READY) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state is not READY"); 
-               return STT_ERROR_INVALID_STATE;
-       }
-
        int ret = 0;
-       ret = stt_dbus_request_get_default_lang(client->uid, language);
-
+       ret = stt_config_mgr_get_default_language(language);
+       ret = __stt_convert_config_error_code(ret);
        if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail : request get default language");
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to get default language : %s", __stt_get_error_code(ret));
        } else {
                SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Current language = %s", *language);
        }
@@ -355,6 +924,17 @@ int stt_get_default_language(stt_h stt, char** language)
 
 int stt_get_state(stt_h stt, stt_state_e* state)
 {
+       bool stt_supported = false;
+       bool mic_supported = false;
+       if (0 == system_info_get_platform_bool(STT_FEATURE_PATH, &stt_supported)) {
+               if (0 == system_info_get_platform_bool(STT_MIC_FEATURE_PATH, &mic_supported)) {
+                       if (false == stt_supported || false == mic_supported) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] STT NOT supported");
+                               return STT_ERROR_NOT_SUPPORTED;
+                       }
+               }
+       }
+
        if (NULL == stt || NULL == state) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
                return STT_ERROR_INVALID_PARAMETER;
@@ -374,14 +954,26 @@ int stt_get_state(stt_h stt, stt_state_e* state)
                case STT_STATE_READY:           SLOG(LOG_DEBUG, TAG_STTC, "Current state is 'Ready'");          break;
                case STT_STATE_RECORDING:       SLOG(LOG_DEBUG, TAG_STTC, "Current state is 'Recording'");      break;
                case STT_STATE_PROCESSING:      SLOG(LOG_DEBUG, TAG_STTC, "Current state is 'Processing'");     break;
+               default:                        SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid value");             break;
        }
 
        return STT_ERROR_NONE;
 }
 
-int stt_is_partial_result_supported(stt_h stt, bool* partial_result)
+int stt_is_recognition_type_supported(stt_h stt, const char* type, bool* support)
 {
-       if (NULL == stt || NULL == partial_result) {
+       bool stt_supported = false;
+       bool mic_supported = false;
+       if (0 == system_info_get_platform_bool(STT_FEATURE_PATH, &stt_supported)) {
+               if (0 == system_info_get_platform_bool(STT_MIC_FEATURE_PATH, &mic_supported)) {
+                       if (false == stt_supported || false == mic_supported) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] STT NOT supported");
+                               return STT_ERROR_NOT_SUPPORTED;
+                       }
+               }
+       }
+
+       if (NULL == stt || NULL == type || NULL == support) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
                return STT_ERROR_INVALID_PARAMETER;
        }
@@ -395,24 +987,49 @@ int stt_is_partial_result_supported(stt_h stt, bool* partial_result)
 
        /* check state */
        if (client->current_state != STT_STATE_READY) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state is not READY"); 
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state is not READY");
                return STT_ERROR_INVALID_STATE;
        }
 
-       int ret = 0;
-       ret = stt_dbus_request_is_partial_result_supported(client->uid, partial_result);
-
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to get partial result supported");
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Partial result supporting is %s", *partial_result ? "true " : "false");
+       int ret = -1;
+       int count = 0;
+       while (0 != ret) {
+               ret = stt_dbus_request_is_recognition_type_supported(client->uid, type, support);
+               if (0 != ret) {
+                       if (STT_ERROR_TIMED_OUT != ret) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to get recognition type supported : %s", __stt_get_error_code(ret));
+                               return ret;
+                       } else {
+                               SLOG(LOG_WARN, TAG_STTC, "[WARNING] retry");
+                               usleep(10);
+                               count++;
+                               if (10 == count) {
+                                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to request");
+                                       return ret;
+                               }
+                       }
+               } else {
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] recognition type is %s", *support ? "true " : "false");
+                       break;
+               }
        }
 
        return STT_ERROR_NONE;
 }
 
-int stt_set_profanity_filter(stt_h stt, stt_option_profanity_e type)
+int stt_set_silence_detection(stt_h stt, stt_option_silence_detection_e type)
 {
+       bool stt_supported = false;
+       bool mic_supported = false;
+       if (0 == system_info_get_platform_bool(STT_FEATURE_PATH, &stt_supported)) {
+               if (0 == system_info_get_platform_bool(STT_MIC_FEATURE_PATH, &mic_supported)) {
+                       if (false == stt_supported || false == mic_supported) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] STT NOT supported");
+                               return STT_ERROR_NOT_SUPPORTED;
+                       }
+               }
+       }
+
        if (NULL == stt) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
                return STT_ERROR_INVALID_PARAMETER;
@@ -427,14 +1044,14 @@ int stt_set_profanity_filter(stt_h stt, stt_option_profanity_e type)
 
        /* check state */
        if (client->current_state != STT_STATE_READY) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state is not READY"); 
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state is not READY");
                return STT_ERROR_INVALID_STATE;
        }
 
-       if (true == client->profanity_supported) {
-               if (type >= STT_OPTION_PROFANITY_FALSE && type <= STT_OPTION_PROFANITY_AUTO)
-                       client->profanity = type;       
-               else {
+       if (true == client->silence_supported) {
+               if (type >= STT_OPTION_SILENCE_DETECTION_FALSE && type <= STT_OPTION_SILENCE_DETECTION_AUTO) {
+                       client->silence = type; 
+               else {
                        SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Type is invalid");
                        return STT_ERROR_INVALID_PARAMETER;
                }
@@ -445,8 +1062,80 @@ int stt_set_profanity_filter(stt_h stt, stt_option_profanity_e type)
        return STT_ERROR_NONE;
 }
 
-int stt_set_punctuation_override(stt_h stt, stt_option_punctuation_e type)
+int stt_set_start_sound(stt_h stt, const char* filename)
+{
+       bool stt_supported = false;
+       bool mic_supported = false;
+       if (0 == system_info_get_platform_bool(STT_FEATURE_PATH, &stt_supported)) {
+               if (0 == system_info_get_platform_bool(STT_MIC_FEATURE_PATH, &mic_supported)) {
+                       if (false == stt_supported || false == mic_supported) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] STT NOT supported");
+                               return STT_ERROR_NOT_SUPPORTED;
+                       }
+               }
+       }
+
+       SLOG(LOG_DEBUG, TAG_STTC, "===== STT SET START SOUND");
+
+       if (NULL == stt || NULL == filename) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+
+       stt_client_s* client = stt_client_get(stt);
+
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Get state : A handle is not valid");
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+
+       /* check state */
+       if (client->current_state != STT_STATE_READY) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state is not READY");
+               return STT_ERROR_INVALID_STATE;
+       }
+
+       int ret = -1;
+       int count = 0;
+       while (0 != ret) {
+               ret = stt_dbus_request_set_start_sound(client->uid, filename);
+               if (0 != ret) {
+                       if (STT_ERROR_TIMED_OUT != ret) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to set start sound : %s", __stt_get_error_code(ret));
+                               return ret;
+                       } else {
+                               SLOG(LOG_WARN, TAG_STTC, "[WARNING] retry");
+                               usleep(10);
+                               count++;
+                               if (10 == count) {
+                                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to request");
+                                       return ret;
+                               }
+                       }
+               } else {
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Set start sound : %s", filename);
+                       break;
+               }
+       }
+
+       return STT_ERROR_NONE;
+}
+
+int stt_unset_start_sound(stt_h stt)
 {
+       bool stt_supported = false;
+       bool mic_supported = false;
+       if (0 == system_info_get_platform_bool(STT_FEATURE_PATH, &stt_supported)) {
+               if (0 == system_info_get_platform_bool(STT_MIC_FEATURE_PATH, &mic_supported)) {
+                       if (false == stt_supported || false == mic_supported) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] STT NOT supported");
+                               return STT_ERROR_NOT_SUPPORTED;
+                       }
+               }
+       }
+
+       SLOG(LOG_DEBUG, TAG_STTC, "===== STT UNSET START SOUND");
+
        if (NULL == stt) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
                return STT_ERROR_INVALID_PARAMETER;
@@ -458,29 +1147,113 @@ int stt_set_punctuation_override(stt_h stt, stt_option_punctuation_e type)
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Get state : A handle is not valid");
                return STT_ERROR_INVALID_PARAMETER;
        }
-       
+
        /* check state */
        if (client->current_state != STT_STATE_READY) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state is not READY"); 
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state is not READY");
                return STT_ERROR_INVALID_STATE;
        }
 
-       if (true == client->punctuation_supported) {
-               if (type >= STT_OPTION_PUNCTUATION_FALSE && type <= STT_OPTION_PUNCTUATION_AUTO)
-                       client->punctuation = type;     
-               else {
-                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Type is invalid");
-                       return STT_ERROR_INVALID_PARAMETER;
+       int ret = -1;
+       int count = 0;
+       while (0 != ret) {
+               ret = stt_dbus_request_unset_start_sound(client->uid);
+               if (0 != ret) {
+                       if (STT_ERROR_TIMED_OUT != ret) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to unset start sound : %s", __stt_get_error_code(ret));
+                               return ret;
+                       } else {
+                               SLOG(LOG_WARN, TAG_STTC, "[WARNING] retry");
+                               usleep(10);
+                               count++;
+                               if (10 == count) {
+                                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to request");
+                                       return ret;
+                               }
+                       }
+               } else {
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Unset start sound");
+                       break;
                }
-       } else {
-               return STT_ERROR_NOT_SUPPORTED_FEATURE; 
        }
 
        return STT_ERROR_NONE;
 }
 
-int stt_set_silence_detection(stt_h stt, stt_option_silence_detection_e type)
+int stt_set_stop_sound(stt_h stt, const char* filename)
+{
+       bool stt_supported = false;
+       bool mic_supported = false;
+       if (0 == system_info_get_platform_bool(STT_FEATURE_PATH, &stt_supported)) {
+               if (0 == system_info_get_platform_bool(STT_MIC_FEATURE_PATH, &mic_supported)) {
+                       if (false == stt_supported || false == mic_supported) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] STT NOT supported");
+                               return STT_ERROR_NOT_SUPPORTED;
+                       }
+               }
+       }
+
+       SLOG(LOG_DEBUG, TAG_STTC, "===== STT SET STOP SOUND");
+
+       if (NULL == stt || NULL == filename) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+
+       stt_client_s* client = stt_client_get(stt);
+
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Get state : A handle is not valid");
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+
+       /* check state */
+       if (client->current_state != STT_STATE_READY) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state is not READY");
+               return STT_ERROR_INVALID_STATE;
+       }
+
+       int ret = -1;
+       int count = 0;
+       while (0 != ret) {
+               ret = stt_dbus_request_set_stop_sound(client->uid, filename);
+               if (0 != ret) {
+                       if (STT_ERROR_TIMED_OUT != ret) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to set stop sound : %s", __stt_get_error_code(ret));
+                               return ret;
+                       } else {
+                               SLOG(LOG_WARN, TAG_STTC, "[WARNING] retry");
+                               usleep(10);
+                               count++;
+                               if (10 == count) {
+                                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to request");
+                                       return ret;
+                               }
+                       }
+               } else {
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Set stop sound : %s", filename);
+                       break;
+               }
+       }
+
+       return STT_ERROR_NONE;
+}
+
+int stt_unset_stop_sound(stt_h stt)
 {
+       bool stt_supported = false;
+       bool mic_supported = false;
+       if (0 == system_info_get_platform_bool(STT_FEATURE_PATH, &stt_supported)) {
+               if (0 == system_info_get_platform_bool(STT_MIC_FEATURE_PATH, &mic_supported)) {
+                       if (false == stt_supported || false == mic_supported) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] STT NOT supported");
+                               return STT_ERROR_NOT_SUPPORTED;
+                       }
+               }
+       }
+
+       SLOG(LOG_DEBUG, TAG_STTC, "===== STT UNSET STOP SOUND");
+
        if (NULL == stt) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
                return STT_ERROR_INVALID_PARAMETER;
@@ -495,19 +1268,31 @@ int stt_set_silence_detection(stt_h stt, stt_option_silence_detection_e type)
 
        /* check state */
        if (client->current_state != STT_STATE_READY) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state is not READY"); 
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state is not READY");
                return STT_ERROR_INVALID_STATE;
        }
 
-       if (true == client->silence_supported) {
-               if (type >= STT_OPTION_SILENCE_DETECTION_FALSE && type <= STT_OPTION_SILENCE_DETECTION_AUTO)
-                       client->silence = type; 
-               else {
-                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Type is invalid");
-                       return STT_ERROR_INVALID_PARAMETER;
+       int ret = -1;
+       int count = 0;
+       while (0 != ret) {
+               ret = stt_dbus_request_unset_stop_sound(client->uid);
+               if (0 != ret) {
+                       if (STT_ERROR_TIMED_OUT != ret) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to unset stop sound : %s", __stt_get_error_code(ret));
+                               return ret;
+                       } else {
+                               SLOG(LOG_WARN, TAG_STTC, "[WARNING] retry");
+                               usleep(10);
+                               count++;
+                               if (10 == count) {
+                                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to request");
+                                       return ret;
+                               }
+                       }
+               } else {
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Unset stop sound");
+                       break;
                }
-       } else {
-               return STT_ERROR_NOT_SUPPORTED_FEATURE; 
        }
 
        return STT_ERROR_NONE;
@@ -515,6 +1300,17 @@ int stt_set_silence_detection(stt_h stt, stt_option_silence_detection_e type)
 
 int stt_start(stt_h stt, const char* language, const char* type)
 {
+       bool stt_supported = false;
+       bool mic_supported = false;
+       if (0 == system_info_get_platform_bool(STT_FEATURE_PATH, &stt_supported)) {
+               if (0 == system_info_get_platform_bool(STT_MIC_FEATURE_PATH, &mic_supported)) {
+                       if (false == stt_supported || false == mic_supported) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] STT NOT supported");
+                               return STT_ERROR_NOT_SUPPORTED;
+                       }
+               }
+       }
+
        SLOG(LOG_DEBUG, TAG_STTC, "===== STT START");
 
        if (NULL == stt) {
@@ -536,36 +1332,86 @@ int stt_start(stt_h stt, const char* language, const char* type)
 
        /* check state */
        if (client->current_state != STT_STATE_READY) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state is not READY"); 
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state is not READY");
+               SLOG(LOG_DEBUG, TAG_STTC, "=====");
+               SLOG(LOG_DEBUG, TAG_STTC, " ");
+               return STT_ERROR_INVALID_STATE;
+       }
+
+       if (STT_INTERNAL_STATE_NONE != client->internal_state) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State : Internal state is NOT none : %d", client->internal_state);
                SLOG(LOG_DEBUG, TAG_STTC, "=====");
                SLOG(LOG_DEBUG, TAG_STTC, " ");
                return STT_ERROR_INVALID_STATE;
        }
 
-       char* temp;
+       char appid[128] = {0, };
+       aul_app_get_appid_bypid(getpid(), appid, sizeof(appid));
+       
+       if (0 == strlen(appid)) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to get application ID");
+       } else {
+               SLOG(LOG_DEBUG, TAG_STTC, "[DEBUG] Current app id is %s", appid);
+       }
+
+       char* temp = NULL;
        if (NULL == language) {
                temp = strdup("default");
        } else {
                temp = strdup(language);
        }
 
-       int ret
+       int ret = -1;
        /* do request */
-       ret = stt_dbus_request_start(client->uid, temp, type, client->profanity, client->punctuation, client->silence);
-
-       if (ret) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to start");
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS]");
-
-               client->before_state = client->current_state;
-               client->current_state = STT_STATE_RECORDING;
+       int count = 0;
+       while (0 != ret) {
+               ret = stt_dbus_request_start(client->uid, temp, type, client->silence, appid);
+               if (0 > ret) {
+                       /* Failure */                   
+                       if (STT_ERROR_TIMED_OUT != ret) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to start : %s", __stt_get_error_code(ret));
+                               if (NULL != temp)       free(temp);
+                               return ret;
+                       } else {
+                               SLOG(LOG_WARN, TAG_STTC, "[WARNING] retry to start");
+                               usleep(10);
+                               count++;
+                               if (10 == count) {
+                                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to request");
+                                       if (NULL != temp)       free(temp);
+                                       return ret;
+                               }
+                       }
+               } else {
+                       /* Success */
+                       if (NULL != temp)       free(temp);
+
+                       if (STT_RESULT_STATE_DONE == ret) {
+                               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Start is done : %d", ret);
+                               client->before_state = client->current_state;
+                               client->current_state = STT_STATE_RECORDING;
+
+                               if (NULL != client->state_changed_cb) {
+                                       stt_client_use_callback(client);
+                                       client->state_changed_cb(client->stt, client->before_state, 
+                                               client->current_state, client->state_changed_user_data);
+                                       stt_client_not_use_callback(client);
+                                       SLOG(LOG_DEBUG, TAG_STTC, "State changed callback is called");
+                               } else {
+                                       SLOG(LOG_WARN, TAG_STTC, "[WARNING] State changed callback is null");
+                               }
+                       } else if (STT_RESULT_STATE_NOT_DONE == ret) {
+                               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Start is not done : %d", ret);
+                               client->internal_state = STT_INTERNAL_STATE_STARTING;
+                       } else {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid result : %d", ret);
+                       }
 
-               ecore_timer_add(0, __stt_notify_state_changed, (void*)stt);
+                       ret = STT_ERROR_NONE;
+                       break;
+               }
        }
 
-       free(temp);
-
        SLOG(LOG_DEBUG, TAG_STTC, "=====");
        SLOG(LOG_DEBUG, TAG_STTC, " ");
 
@@ -574,10 +1420,21 @@ int stt_start(stt_h stt, const char* language, const char* type)
 
 int stt_stop(stt_h stt)
 {
+       bool stt_supported = false;
+       bool mic_supported = false;
+       if (0 == system_info_get_platform_bool(STT_FEATURE_PATH, &stt_supported)) {
+               if (0 == system_info_get_platform_bool(STT_MIC_FEATURE_PATH, &mic_supported)) {
+                       if (false == stt_supported || false == mic_supported) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] STT NOT supported");
+                               return STT_ERROR_NOT_SUPPORTED;
+                       }
+               }
+       }
+
        SLOG(LOG_DEBUG, TAG_STTC, "===== STT STOP");
 
        if (NULL == stt) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] [ERROR] Input parameter is NULL");
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
                SLOG(LOG_DEBUG, TAG_STTC, "=====");
                SLOG(LOG_DEBUG, TAG_STTC, " ");
                return STT_ERROR_INVALID_PARAMETER;
@@ -595,24 +1452,62 @@ int stt_stop(stt_h stt)
        
        /* check state */
        if (client->current_state != STT_STATE_RECORDING) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State : Current state is NOT RECORDING"); 
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State : Current state is NOT RECORDING");
                SLOG(LOG_DEBUG, TAG_STTC, "=====");
                SLOG(LOG_DEBUG, TAG_STTC, " ");
                return STT_ERROR_INVALID_STATE;
        }
 
-       int ret = 0; 
-       /* do request */
-       ret = stt_dbus_request_stop(client->uid);
-       if (0 != ret) {
-               SLOG(LOG_DEBUG, TAG_STTC, "[ERROR] Fail to stop");
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS]");
-
-               client->before_state = client->current_state;
-               client->current_state = STT_STATE_PROCESSING;
+       if (STT_INTERNAL_STATE_NONE != client->internal_state) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State : Internal state is NOT none : %d", client->internal_state);
+               SLOG(LOG_DEBUG, TAG_STTC, "=====");
+               SLOG(LOG_DEBUG, TAG_STTC, " ");
+               return STT_ERROR_INVALID_STATE;
+       }
 
-               ecore_timer_add(0, __stt_notify_state_changed, (void*)stt);
+       int ret = -1;
+       /* do request */
+       int count = 0;
+       while (0 != ret) {
+               ret = stt_dbus_request_stop(client->uid);
+               if (0 > ret) {
+                       /* Failure */                   
+                       if (STT_ERROR_TIMED_OUT != ret) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to stop : %s", __stt_get_error_code(ret));
+                               return ret;
+                       } else {
+                               SLOG(LOG_WARN, TAG_STTC, "[WARNING] retry stop");
+                               usleep(10);
+                               count++;
+                               if (10 == count) {
+                                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to request");
+                                       return ret;
+                               }
+                       }
+               } else {
+                       if (STT_RESULT_STATE_DONE == ret) {
+                               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Stop is done : %d", ret);
+                               client->before_state = client->current_state;
+                               client->current_state = STT_STATE_PROCESSING;
+
+                               if (NULL != client->state_changed_cb) {
+                                       stt_client_use_callback(client);
+                                       client->state_changed_cb(client->stt, client->before_state, 
+                                               client->current_state, client->state_changed_user_data); 
+                                       stt_client_not_use_callback(client);
+                                       SLOG(LOG_DEBUG, TAG_STTC, "State changed callback is called");
+                               } else {
+                                       SLOG(LOG_WARN, TAG_STTC, "[WARNING] State changed callback is null");
+                               }
+                       } else if (STT_RESULT_STATE_NOT_DONE == ret) {
+                               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Stop is not done : %d", ret);
+                               client->internal_state = STT_INTERNAL_STATE_STOPING;
+                       } else {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid result : %d", ret);
+                       }
+                       ret = STT_ERROR_NONE;
+                       break;
+               }
        }
 
        SLOG(LOG_DEBUG, TAG_STTC, "=====");
@@ -624,6 +1519,17 @@ int stt_stop(stt_h stt)
 
 int stt_cancel(stt_h stt)
 {
+       bool stt_supported = false;
+       bool mic_supported = false;
+       if (0 == system_info_get_platform_bool(STT_FEATURE_PATH, &stt_supported)) {
+               if (0 == system_info_get_platform_bool(STT_MIC_FEATURE_PATH, &mic_supported)) {
+                       if (false == stt_supported || false == mic_supported) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] STT NOT supported");
+                               return STT_ERROR_NOT_SUPPORTED;
+                       }
+               }
+       }
+
        SLOG(LOG_DEBUG, TAG_STTC, "===== STT CANCEL");
 
        if (NULL == stt) {
@@ -645,24 +1551,56 @@ int stt_cancel(stt_h stt)
 
        /* check state */
        if (STT_STATE_RECORDING != client->current_state && STT_STATE_PROCESSING != client->current_state) {
-               SLOG(LOG_DEBUG, TAG_STTC, "[ERROR] Invalid state : Current state is 'Ready'");
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid state : Current state is 'Ready'");
                SLOG(LOG_DEBUG, TAG_STTC, "=====");
                SLOG(LOG_DEBUG, TAG_STTC, " ");
                return STT_ERROR_INVALID_STATE;
        }
 
-       int ret; 
-       /* do request */
-       ret = stt_dbus_request_cancel(client->uid);
-       if (0 != ret) {
-               SLOG(LOG_DEBUG, TAG_STTC, "[ERROR] Fail to cancel");
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS]");
-
-               client->before_state = client->current_state;
-               client->current_state = STT_STATE_READY;
+       if (STT_INTERNAL_STATE_NONE != client->internal_state) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State : Internal state is NOT none : %d", client->internal_state);
+               SLOG(LOG_DEBUG, TAG_STTC, "=====");
+               SLOG(LOG_DEBUG, TAG_STTC, " ");
+               return STT_ERROR_INVALID_STATE;
+       }
 
-               ecore_timer_add(0, __stt_notify_state_changed, (void*)stt);
+       int ret = -1;
+       /* do request */
+       int count = 0;
+       while (0 != ret) {
+               ret = stt_dbus_request_cancel(client->uid);
+               if (0 != ret) { 
+                       /* Failure */                   
+                       if (STT_ERROR_TIMED_OUT != ret) {
+                               SLOG(LOG_DEBUG, TAG_STTC, "[ERROR] Fail to cancel : %s", __stt_get_error_code(ret));
+                               return ret;
+                       } else {
+                               SLOG(LOG_WARN, TAG_STTC, "[WARNING] retry");
+                               usleep(10);
+                               count++;
+                               if (10 == count) {
+                                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to request");
+                                       return ret;
+                               }
+                       }
+               } else {
+                       SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS]");
+
+                       client->before_state = client->current_state;
+                       client->current_state = STT_STATE_READY;
+
+                       if (NULL != client->state_changed_cb) {
+                               stt_client_use_callback(client);
+                               client->state_changed_cb(client->stt, client->before_state, 
+                                       client->current_state, client->state_changed_user_data); 
+                               stt_client_not_use_callback(client);
+                               SLOG(LOG_DEBUG, TAG_STTC, "State changed callback is called");
+                       } else {
+                               SLOG(LOG_WARN, TAG_STTC, "[WARNING] State changed callback is null");
+                       }
+                       ret = STT_ERROR_NONE;
+                       break;
+               }
        }
 
        SLOG(LOG_DEBUG, TAG_STTC, "=====");
@@ -690,6 +1628,17 @@ static int __stt_get_audio_volume(float* volume)
 
 int stt_get_recording_volume(stt_h stt, float* volume)
 {
+       bool stt_supported = false;
+       bool mic_supported = false;
+       if (0 == system_info_get_platform_bool(STT_FEATURE_PATH, &stt_supported)) {
+               if (0 == system_info_get_platform_bool(STT_MIC_FEATURE_PATH, &mic_supported)) {
+                       if (false == stt_supported || false == mic_supported) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] STT NOT supported");
+                               return STT_ERROR_NOT_SUPPORTED;
+                       }
+               }
+       }
+
        if (NULL == stt || NULL == volume) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
                return STT_ERROR_INVALID_PARAMETER;
@@ -711,16 +1660,52 @@ int stt_get_recording_volume(stt_h stt, float* volume)
        int ret = 0;
        ret = __stt_get_audio_volume(volume);
        if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to get audio volume");
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to get audio volume : %s", __stt_get_error_code(ret));
                return STT_ERROR_OPERATION_FAILED;
        }
 
-       return STT_ERROR_NONE;
+       return STT_ERROR_NONE;
+}
+
+bool __stt_result_time_cb(int index, int event, const char* text, long start_time, long end_time, void* user_data) 
+{
+       stt_client_s* client = (stt_client_s*)user_data;
+
+       /* check handle */
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to notify error : A handle is not valid");
+               return EINA_FALSE;
+       }
+
+       if (NULL != client->result_time_cb) {
+               SLOG(LOG_DEBUG, TAG_STTC, "(%d) event(%d) text(%s) start(%ld) end(%ld)",
+                       index, event, text, start_time, end_time);
+               client->result_time_cb(client->stt, index, (stt_result_time_event_e)event, 
+                       text, start_time, end_time, client->result_time_user_data);
+       } else {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Callback is NULL");
+               return false;
+       }
+
+       return true;
 }
 
-int stt_start_file_recognition(stt_h stt, const char* filepath, const char* language, const char* type)
+int stt_foreach_detailed_result(stt_h stt, stt_result_time_cb callback, void* user_data)
 {
-       if (NULL == stt || NULL == type || NULL == filepath) {
+       bool stt_supported = false;
+       bool mic_supported = false;
+       if (0 == system_info_get_platform_bool(STT_FEATURE_PATH, &stt_supported)) {
+               if (0 == system_info_get_platform_bool(STT_MIC_FEATURE_PATH, &mic_supported)) {
+                       if (false == stt_supported || false == mic_supported) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] STT NOT supported");
+                               return STT_ERROR_NOT_SUPPORTED;
+                       }
+               }
+       }
+
+       SLOG(LOG_DEBUG, TAG_STTC, "===== STT FOREACH DETAILED RESULT");
+
+       if (NULL == callback) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
                return STT_ERROR_INVALID_PARAMETER;
        }
@@ -729,46 +1714,32 @@ int stt_start_file_recognition(stt_h stt, const char* filepath, const char* lang
 
        /* check handle */
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail : A handle is not valid");
                return STT_ERROR_INVALID_PARAMETER;
-       } 
-
-       if (STT_STATE_READY != client->current_state) {
-               SLOG(LOG_DEBUG, TAG_STTC, "[ERROR] Invalid state : NO 'Ready' state");
-               return STT_ERROR_INVALID_STATE;
-       }
-
-       char* temp;
-       if (NULL == language) {
-               temp = strdup("default");
-       } else {
-               temp = strdup(language);
        }
 
-       int ret; 
-       ret = stt_dbus_request_start_file_recognition(client->uid, filepath, temp, type, client->profanity, client->punctuation);
-
-       if (ret) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to start");
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS]");
-
-               client->before_state = client->current_state;
-               client->current_state = STT_STATE_PROCESSING;
+       client->result_time_cb = callback;
+       client->result_time_user_data = user_data;
 
-               ecore_timer_add(0, __stt_notify_state_changed, (void*)stt);
+       int ret = -1;
+       ret = stt_config_mgr_foreach_time_info(__stt_result_time_cb, client);
+       ret = __stt_convert_config_error_code(ret);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to foreach time info : %s", __stt_get_error_code(ret));
        }
 
-       free(temp);
+       client->result_time_cb = NULL;
+       client->result_time_user_data = NULL;
 
-       return STT_ERROR_NONE;
+       SLOG(LOG_DEBUG, TAG_STTC, "=====");
+       SLOG(LOG_DEBUG, TAG_STTC, " ");
+
+       return ret;
 }
 
 static Eina_Bool __stt_notify_error(void *data)
 {
-       stt_h stt = (stt_h)data;
-
-       stt_client_s* client = stt_client_get(stt);
+       stt_client_s* client = (stt_client_s*)data;
 
        /* check handle */
        if (NULL == client) {
@@ -776,6 +1747,9 @@ static Eina_Bool __stt_notify_error(void *data)
                return EINA_FALSE;
        }
 
+       if (NULL == stt_client_get_by_uid(client->uid))
+               return EINA_FALSE;
+
        if (NULL != client->error_cb) {
                stt_client_use_callback(client);
                client->error_cb(client->stt, client->reason, client->error_user_data); 
@@ -799,7 +1773,7 @@ int __stt_cb_error(int uid, int reason)
        client->reason = reason;
 
        if (NULL != client->error_cb) {
-               ecore_timer_add(0, __stt_notify_error, client->stt);
+               ecore_timer_add(0, __stt_notify_error, client);
        } else {
                SLOG(LOG_WARN, TAG_STTC, "[WARNING] Error callback is null");
        }    
@@ -807,11 +1781,42 @@ int __stt_cb_error(int uid, int reason)
        return 0;
 }
 
-static Eina_Bool __stt_notify_result(void *data)
+static Eina_Bool __stt_notify_state_changed(void *data)
 {
-       stt_h stt = (stt_h)data;
+       stt_client_s* client = (stt_client_s*)data;
 
-       stt_client_s* client = stt_client_get(stt);
+       /* check handle */
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to notify error : A handle is not valid");
+               return EINA_FALSE;
+       }
+
+       if (NULL == stt_client_get_by_uid(client->uid))
+               return EINA_FALSE;
+
+       if (STT_INTERNAL_STATE_STARTING == client->internal_state && STT_STATE_RECORDING == client->current_state) {
+               client->internal_state = STT_INTERNAL_STATE_NONE;
+               SLOG(LOG_DEBUG, TAG_STTC, "Internal state change NULL");
+       } else if (STT_INTERNAL_STATE_STOPING == client->internal_state && STT_STATE_PROCESSING == client->current_state) {
+               client->internal_state = STT_INTERNAL_STATE_NONE;
+               SLOG(LOG_DEBUG, TAG_STTC, "Internal state change NULL");
+       }
+
+       if (NULL != client->state_changed_cb) {
+               stt_client_use_callback(client);
+               client->state_changed_cb(client->stt, client->before_state, 
+                       client->current_state, client->state_changed_user_data); 
+               stt_client_not_use_callback(client);
+       } else {
+               SLOG(LOG_WARN, TAG_STTC, "[WARNING] State changed callback is null");
+       }
+
+       return EINA_FALSE;
+}
+
+static Eina_Bool __stt_notify_result(void *data)
+{
+       stt_client_s* client = (stt_client_s*)data;
 
        /* check handle */
        if (NULL == client) {
@@ -819,18 +1824,24 @@ static Eina_Bool __stt_notify_result(void *data)
                return EINA_FALSE;
        }
 
-       if (NULL != client->result_cb) {
+       if (NULL == stt_client_get_by_uid(client->uid)) {
+               return EINA_FALSE;
+       }
+
+       if (NULL != client->recognition_result_cb) {
                stt_client_use_callback(client);
-               client->result_cb(client->stt, client->type, (const char**)client->data_list, client->data_count, client->msg, client->result_user_data);
+               client->recognition_result_cb(client->stt, client->event, (const char**)client->data_list, client->data_count, 
+                       client->msg, client->recognition_result_user_data);
                stt_client_not_use_callback(client);
-               SLOG(LOG_DEBUG, TAG_STTC, "client result callback called");
+               SLOG(LOG_DEBUG, TAG_STTC, "client recognition result callback called");
        } else {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] User result callback is null");
-       } 
+               SLOG(LOG_WARN, TAG_STTC, "[WARNING] User recognition result callback is NULL");
+       }
 
-       /* Free result */
-       if (NULL != client->type)
-               free(client->type);
+       if (NULL != client->msg) {
+               free(client->msg);
+               client->msg = NULL;
+       }
 
        if (NULL != client->data_list) {
                char **temp = NULL;
@@ -838,47 +1849,36 @@ static Eina_Bool __stt_notify_result(void *data)
 
                int i = 0;
                for (i = 0;i < client->data_count;i++) {
-                       if(NULL != temp[i])
+                       if (NULL != temp[i]) {
                                free(temp[i]);
-                       else 
+                               temp[i] = NULL;
+                       } else {
                                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Result data is error");
+                       }
                }
                free(client->data_list);
+               client->data_list = NULL;
        }
-       
-       if (NULL != client->msg) 
-               free(client->msg);
 
        client->data_count = 0;
 
-       return EINA_FALSE;
-}
-
-static Eina_Bool __stt_notify_state_changed(void *data)
-{
-       stt_h stt = (stt_h)data;
-
-       stt_client_s* client = stt_client_get(stt);
-
-       /* check handle */
-       if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to notify error : A handle is not valid");
-               return EINA_FALSE;
-       }
+       stt_config_mgr_remove_time_info_file();
+       
+       if (STT_RESULT_EVENT_FINAL_RESULT == client->event || STT_RESULT_EVENT_ERROR == client->event) {
+               client->before_state = client->current_state;
+               client->current_state = STT_STATE_READY;
 
-       if (NULL != client->state_changed_cb) {
-               stt_client_use_callback(client);
-               client->state_changed_cb(client->stt, client->before_state, client->current_state, client->state_changed_user_data); 
-               stt_client_not_use_callback(client);
-               SLOG(LOG_DEBUG, TAG_STTC, "State changed callback is called");
-       } else {
-               SLOG(LOG_WARN, TAG_STTC, "[WARNING] State changed callback is null");
+               if (NULL != client->state_changed_cb) {
+                       ecore_timer_add(0, __stt_notify_state_changed, client);
+               } else {
+                       SLOG(LOG_WARN, TAG_STTC, "[WARNING] State changed callback is null");
+               }
        }
 
        return EINA_FALSE;
 }
 
-int __stt_cb_result(int uid, const char* type, const char** data, int data_count, const char* msg)
+int __stt_cb_result(int uid, int event, char** data, int data_count, const char* msg)
 {
        stt_client_s* client = NULL;
        
@@ -888,22 +1888,24 @@ int __stt_cb_result(int uid, const char* type, const char** data, int data_count
                return -1;
        }
 
-       SLOG(LOG_DEBUG, TAG_STTC, "Recognition Result Message = %s", msg);
+       if (NULL != msg)        SLOG(LOG_DEBUG, TAG_STTC, "Recognition Result Message = %s", msg);
 
        int i=0;
        for (i = 0;i < data_count;i++) {
-               if(NULL != data[i])
-                       SLOG(LOG_DEBUG, TAG_STTC, "Recognition Result[%d] = %s", i, data[i]);
+               if (NULL != data[i])    SECURE_SLOG(LOG_DEBUG, TAG_STTC, "Recognition Result[%d] = %s", i, data[i]);
        }       
 
-       if (NULL != client->result_cb) {
-               client->type = strdup(type);
-               client->msg = strdup(msg);
+       if (NULL != client->recognition_result_cb) {
+               client->event = event;
+               if (NULL != msg) {
+                       client->msg = strdup(msg);
+               }
+
                client->data_count = data_count;
 
                if (data_count > 0) {
                        char **temp = NULL;
-                       temp = malloc( sizeof(char*) * data_count);
+                       temp = (char**)calloc(data_count, sizeof(char*));
 
                        for (i = 0;i < data_count;i++) {
                                if(NULL != data[i])
@@ -915,72 +1917,11 @@ int __stt_cb_result(int uid, const char* type, const char** data, int data_count
                        client->data_list = temp;
                }
 
-               ecore_timer_add(0, __stt_notify_result, client->stt);
+               ecore_timer_add(0, __stt_notify_result, client);
        } else {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] User result callback is null");
-       }   
-
-       client->before_state = client->current_state;
-       client->current_state = STT_STATE_READY;
-
-       if (NULL != client->state_changed_cb) {
-               ecore_timer_add(0, __stt_notify_state_changed, client->stt);
-       } else {
-               SLOG(LOG_WARN, TAG_STTC, "[WARNING] State changed callback is null");
-       }
-
-       return 0;
-}
-
-static Eina_Bool __stt_notify_partial_result(void *data)
-{
-       stt_h stt = (stt_h)data;
-
-       stt_client_s* client = stt_client_get(stt);
-
-       /* check handle */
-       if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to notify error : A handle is not valid");
-               return EINA_FALSE;
-       }
-
-       if (client->partial_result_cb) {
-               stt_client_use_callback(client);
-               client->partial_result_cb(client->stt, client->partial_result, client->partial_result_user_data);
-               stt_client_not_use_callback(client);
-               SLOG(LOG_DEBUG, TAG_STTC, "Partial result callback is called");
-       } else {
-               SLOG(LOG_WARN, TAG_STTC, "[WARNING] Partial result callback is null");
-       }   
-
-       if (NULL != client->partial_result)
-               free(client->partial_result);
-
-       return EINA_FALSE;
-}
-
-int __stt_cb_partial_result(int uid, const char* data)
-{
-       stt_client_s* client = NULL;
-
-       client = stt_client_get_by_uid(uid);
-       if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_STTC, "Handle is NOT valid");
-               return -1;
-       }
-
-       if (client->current_state == STT_STATE_READY) {
-               SLOG(LOG_ERROR, TAG_STTC, "Current state has already been 'Ready' state");      
-               return 0;
        }
 
-       if (client->partial_result_cb) {
-               client->partial_result = strdup(data);
-               ecore_timer_add(0, __stt_notify_partial_result, client->stt);
-       } else {
-               SLOG(LOG_WARN, TAG_STTC, "[WARNING] Partial result callback is null");
-       }  
-
        return 0;
 }
 
@@ -1002,12 +1943,23 @@ int __stt_cb_set_state(int uid, int state)
        client->before_state = client->current_state;
        client->current_state = state_from_daemon;
 
-       ecore_timer_add(0, __stt_notify_state_changed, client->stt);
+       ecore_timer_add(0, __stt_notify_state_changed, client);
        return 0;
 }
 
-int stt_set_result_cb(stt_h stt, stt_result_cb callback, void* user_data)
+int stt_set_recognition_result_cb(stt_h stt, stt_recognition_result_cb callback, void* user_data)
 {
+       bool stt_supported = false;
+       bool mic_supported = false;
+       if (0 == system_info_get_platform_bool(STT_FEATURE_PATH, &stt_supported)) {
+               if (0 == system_info_get_platform_bool(STT_MIC_FEATURE_PATH, &mic_supported)) {
+                       if (false == stt_supported || false == mic_supported) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] STT NOT supported");
+                               return STT_ERROR_NOT_SUPPORTED;
+                       }
+               }
+       }
+
        if (stt == NULL || callback == NULL)
                return STT_ERROR_INVALID_PARAMETER;
 
@@ -1020,18 +1972,29 @@ int stt_set_result_cb(stt_h stt, stt_result_cb callback, void* user_data)
        }
 
        if (STT_STATE_CREATED != client->current_state) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state is not 'ready'."); 
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state is not 'ready'");
                return STT_ERROR_INVALID_STATE;
        }
 
-       client->result_cb = callback;
-       client->result_user_data = user_data;
+       client->recognition_result_cb = callback;
+       client->recognition_result_user_data = user_data;
 
        return 0;
 }
 
-int stt_unset_result_cb(stt_h stt)
+int stt_unset_recognition_result_cb(stt_h stt)
 {
+       bool stt_supported = false;
+       bool mic_supported = false;
+       if (0 == system_info_get_platform_bool(STT_FEATURE_PATH, &stt_supported)) {
+               if (0 == system_info_get_platform_bool(STT_MIC_FEATURE_PATH, &mic_supported)) {
+                       if (false == stt_supported || false == mic_supported) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] STT NOT supported");
+                               return STT_ERROR_NOT_SUPPORTED;
+                       }
+               }
+       }
+
        if (NULL == stt)
                return STT_ERROR_INVALID_PARAMETER;
 
@@ -1044,18 +2007,29 @@ int stt_unset_result_cb(stt_h stt)
        }
 
        if (STT_STATE_CREATED != client->current_state) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state is not 'ready'."); 
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state is not 'ready'");
                return STT_ERROR_INVALID_STATE;
        }
 
-       client->result_cb = NULL;
-       client->result_user_data = NULL;
+       client->recognition_result_cb = NULL;
+       client->recognition_result_user_data = NULL;
 
        return 0;
 }
 
-int stt_set_partial_result_cb(stt_h stt, stt_partial_result_cb callback, void* user_data)
+int stt_set_state_changed_cb(stt_h stt, stt_state_changed_cb callback, void* user_data)
 {
+       bool stt_supported = false;
+       bool mic_supported = false;
+       if (0 == system_info_get_platform_bool(STT_FEATURE_PATH, &stt_supported)) {
+               if (0 == system_info_get_platform_bool(STT_MIC_FEATURE_PATH, &mic_supported)) {
+                       if (false == stt_supported || false == mic_supported) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] STT NOT supported");
+                               return STT_ERROR_NOT_SUPPORTED;
+                       }
+               }
+       }
+
        if (NULL == stt || NULL == callback)
                return STT_ERROR_INVALID_PARAMETER;
 
@@ -1068,18 +2042,29 @@ int stt_set_partial_result_cb(stt_h stt, stt_partial_result_cb callback, void* u
        }
 
        if (STT_STATE_CREATED != client->current_state) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state is not 'ready'."); 
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state is not 'ready'");
                return STT_ERROR_INVALID_STATE;
        }
 
-       client->partial_result_cb = callback;
-       client->partial_result_user_data = user_data;
+       client->state_changed_cb = callback;
+       client->state_changed_user_data = user_data;
 
        return 0;
 }
 
-int stt_unset_partial_result_cb(stt_h stt)
+int stt_unset_state_changed_cb(stt_h stt)
 {
+       bool stt_supported = false;
+       bool mic_supported = false;
+       if (0 == system_info_get_platform_bool(STT_FEATURE_PATH, &stt_supported)) {
+               if (0 == system_info_get_platform_bool(STT_MIC_FEATURE_PATH, &mic_supported)) {
+                       if (false == stt_supported || false == mic_supported) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] STT NOT supported");
+                               return STT_ERROR_NOT_SUPPORTED;
+                       }
+               }
+       }
+
        if (NULL == stt)
                return STT_ERROR_INVALID_PARAMETER;
 
@@ -1092,18 +2077,29 @@ int stt_unset_partial_result_cb(stt_h stt)
        }
 
        if (STT_STATE_CREATED != client->current_state) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state is not 'ready'."); 
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state is not 'ready'");
                return STT_ERROR_INVALID_STATE;
        }
 
-       client->partial_result_cb = NULL;
-       client->partial_result_user_data = NULL;
+       client->state_changed_cb = NULL;
+       client->state_changed_user_data = NULL;
 
        return 0;
 }
 
-int stt_set_state_changed_cb(stt_h stt, stt_state_changed_cb callback, void* user_data)
+int stt_set_error_cb(stt_h stt, stt_error_cb callback, void* user_data)
 {
+       bool stt_supported = false;
+       bool mic_supported = false;
+       if (0 == system_info_get_platform_bool(STT_FEATURE_PATH, &stt_supported)) {
+               if (0 == system_info_get_platform_bool(STT_MIC_FEATURE_PATH, &mic_supported)) {
+                       if (false == stt_supported || false == mic_supported) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] STT NOT supported");
+                               return STT_ERROR_NOT_SUPPORTED;
+                       }
+               }
+       }
+
        if (NULL == stt || NULL == callback)
                return STT_ERROR_INVALID_PARAMETER;
 
@@ -1116,18 +2112,29 @@ int stt_set_state_changed_cb(stt_h stt, stt_state_changed_cb callback, void* use
        }
 
        if (STT_STATE_CREATED != client->current_state) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state is not 'ready'."); 
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state is not 'ready'");
                return STT_ERROR_INVALID_STATE;
        }
 
-       client->state_changed_cb = callback;
-       client->state_changed_user_data = user_data;
+       client->error_cb = callback;
+       client->error_user_data = user_data;
 
        return 0;
 }
 
-int stt_unset_state_changed_cb(stt_h stt)
+int stt_unset_error_cb(stt_h stt)
 {
+       bool stt_supported = false;
+       bool mic_supported = false;
+       if (0 == system_info_get_platform_bool(STT_FEATURE_PATH, &stt_supported)) {
+               if (0 == system_info_get_platform_bool(STT_MIC_FEATURE_PATH, &mic_supported)) {
+                       if (false == stt_supported || false == mic_supported) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] STT NOT supported");
+                               return STT_ERROR_NOT_SUPPORTED;
+                       }
+               }
+       }
+
        if (NULL == stt)
                return STT_ERROR_INVALID_PARAMETER;
 
@@ -1140,19 +2147,29 @@ int stt_unset_state_changed_cb(stt_h stt)
        }
 
        if (STT_STATE_CREATED != client->current_state) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state is not 'ready'."); 
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state is not 'ready'");
                return STT_ERROR_INVALID_STATE;
        }
 
-       client->state_changed_cb = NULL;
-       client->state_changed_user_data = NULL;
+       client->error_cb = NULL;
+       client->error_user_data = NULL;
 
        return 0;
 }
 
-
-int stt_set_error_cb(stt_h stt, stt_error_cb callback, void* user_data)
+int stt_set_default_language_changed_cb(stt_h stt, stt_default_language_changed_cb callback, void* user_data)
 {
+       bool stt_supported = false;
+       bool mic_supported = false;
+       if (0 == system_info_get_platform_bool(STT_FEATURE_PATH, &stt_supported)) {
+               if (0 == system_info_get_platform_bool(STT_MIC_FEATURE_PATH, &mic_supported)) {
+                       if (false == stt_supported || false == mic_supported) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] STT NOT supported");
+                               return STT_ERROR_NOT_SUPPORTED;
+                       }
+               }
+       }
+
        if (NULL == stt || NULL == callback)
                return STT_ERROR_INVALID_PARAMETER;
 
@@ -1165,18 +2182,29 @@ int stt_set_error_cb(stt_h stt, stt_error_cb callback, void* user_data)
        }
 
        if (STT_STATE_CREATED != client->current_state) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state is not 'ready'."); 
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state is not 'ready'");
                return STT_ERROR_INVALID_STATE;
        }
 
-       client->error_cb = callback;
-       client->error_user_data = user_data;
+       client->default_lang_changed_cb = callback;
+       client->default_lang_changed_user_data = user_data;
 
        return 0;
 }
 
-int stt_unset_error_cb(stt_h stt)
+int stt_unset_default_language_changed_cb(stt_h stt)
 {
+       bool stt_supported = false;
+       bool mic_supported = false;
+       if (0 == system_info_get_platform_bool(STT_FEATURE_PATH, &stt_supported)) {
+               if (0 == system_info_get_platform_bool(STT_MIC_FEATURE_PATH, &mic_supported)) {
+                       if (false == stt_supported || false == mic_supported) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] STT NOT supported");
+                               return STT_ERROR_NOT_SUPPORTED;
+                       }
+               }
+       }
+
        if (NULL == stt)
                return STT_ERROR_INVALID_PARAMETER;
 
@@ -1189,112 +2217,12 @@ int stt_unset_error_cb(stt_h stt)
        }
 
        if (STT_STATE_CREATED != client->current_state) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state is not 'ready'."); 
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state is not 'ready'");
                return STT_ERROR_INVALID_STATE;
        }
 
-       client->error_cb = NULL;
-       client->error_user_data = NULL;
-
-       return 0;
-}
-
-int __get_cmd_line(char *file, char *buf) 
-{
-       FILE *fp = NULL;
-
-       fp = fopen(file, "r");
-       if (fp == NULL) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Get command line");
-               return -1;
-       }
-
-       memset(buf, 0, 256);
-       if (NULL == fgets(buf, 256, fp)) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to fget command line");
-               fclose(fp);
-               return -1;
-       }
-       fclose(fp);
-
-       return 0;
-}
-
-static bool __stt_is_alive()
-{
-       DIR *dir;
-       struct dirent *entry;
-       struct stat filestat;
-       
-       int pid;
-       char cmdLine[256];
-       char tempPath[256];
-
-       dir  = opendir("/proc");
-       if (NULL == dir) {
-               SLOG(LOG_ERROR, TAG_STTC, "process checking is FAILED");
-               return FALSE;
-       }
-
-       while ((entry = readdir(dir)) != NULL) {
-               if (0 != lstat(entry->d_name, &filestat))
-                       continue;
-
-               if (!S_ISDIR(filestat.st_mode))
-                       continue;
-
-               pid = atoi(entry->d_name);
-               if (pid <= 0) continue;
-
-               sprintf(tempPath, "/proc/%d/cmdline", pid);
-               if (0 != __get_cmd_line(tempPath, cmdLine)) {
-                       continue;
-               }
-               if ( 0 == strncmp(cmdLine, "[stt-daemon]", strlen("[stt-daemon]")) ||
-                       0 == strncmp(cmdLine, "stt-daemon", strlen("stt-daemon")) ||
-                       0 == strncmp(cmdLine, "/usr/bin/stt-daemon", strlen("/usr/bin/stt-daemon"))) {
-                               SLOG(LOG_DEBUG, TAG_STTC, "stt-daemon is ALIVE !! \n");
-                               closedir(dir);
-                               return TRUE;
-               }
-       }
-       SLOG(LOG_DEBUG, TAG_STTC, "THERE IS NO stt-daemon !! \n");
-
-       closedir(dir);
-       return FALSE;
-
-}
-
-static int __check_stt_daemon()
-{
-       if( TRUE == __stt_is_alive() )
-               return 0;
-       
-       /* fork-exec stt-daemon */
-       int pid, i;
-
-       pid = fork();
-
-       switch(pid) {
-       case -1:
-               SLOG(LOG_DEBUG, TAG_STTC, "[STT ERROR] fail to create STT-DAEMON \n");
-               break;
-
-       case 0:
-               setsid();
-               for (i = 0;i < _NSIG;i++)
-                       signal(i, SIG_DFL);
-
-               execl("/usr/bin/stt-daemon", "/usr/bin/stt-daemon", NULL);
-               break;
-
-       default:
-               break;
-       }
+       client->default_lang_changed_cb = NULL;
+       client->default_lang_changed_user_data = NULL;
 
        return 0;
 }
-
-
-
-
diff --git a/client/stt.h b/client/stt.h
deleted file mode 100644 (file)
index 98313db..0000000
+++ /dev/null
@@ -1,691 +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 __STT_H__
-#define __STT_H__
-
-#include <errno.h>
-#include <stdbool.h>
-
-/**
-* @addtogroup CAPI_UIX_STT_MODULE
-* @{
-*/
-
-#ifdef __cplusplus
-extern "C" 
-{
-#endif
-
-/** 
-* @brief Enumerations of error codes.
-*/
-typedef enum {
-       STT_ERROR_NONE                  = 0,                    /**< Successful */
-       STT_ERROR_OUT_OF_MEMORY         = -ENOMEM,              /**< Out of Memory */
-       STT_ERROR_IO_ERROR              = -EIO,                 /**< I/O error */
-       STT_ERROR_INVALID_PARAMETER     = -EINVAL,              /**< Invalid parameter */
-       STT_ERROR_TIMED_OUT             = -ETIMEDOUT,           /**< No answer from the daemon */
-       STT_ERROR_RECORDER_BUSY         = -EBUSY,               /**< Busy recorder */
-       STT_ERROR_OUT_OF_NETWORK        = -ENETDOWN,            /**< Out of network */
-       STT_ERROR_INVALID_STATE         = -0x0100000 | 0x31,    /**< Invalid state */
-       STT_ERROR_INVALID_LANGUAGE      = -0x0100000 | 0x32,    /**< Invalid language */
-       STT_ERROR_ENGINE_NOT_FOUND      = -0x0100000 | 0x33,    /**< No available engine  */    
-       STT_ERROR_OPERATION_FAILED      = -0x0100000 | 0x34,    /**< Operation failed  */
-       STT_ERROR_NOT_SUPPORTED_FEATURE = -0x0100000 | 0x35     /**< Not supported feature of current engine */
-}stt_error_e;
-
-/** 
-* @brief Recognition type : free form dictation or default type.
-*/
-#define STT_RECOGNITION_TYPE_FREE              "stt.recognition.type.FREE"
-
-/** 
-* @brief Recognition type : web search. 
-*/
-#define STT_RECOGNITION_TYPE_WEB_SEARCH                "stt.recognition.type.WEB_SEARCH"
-
-/** 
-* @brief Result message : None message
-*/
-#define STT_RESULT_MESSAGE_NONE                        "stt.result.message.none"
-
-/** 
-* @brief Result warning message : The speech has started too soon
-*/
-#define STT_RESULT_MESSAGE_WARNING_TOO_SOON    "stt.result.message.warning.too.soon"
-
-/** 
-* @brief Result warning message : The speech is too short
-*/
-#define STT_RESULT_MESSAGE_WARNING_TOO_SHORT   "stt.result.message.warning.too.short"
-
-/** 
-* @brief Result warning message : The speech is too long
-*/
-#define STT_RESULT_MESSAGE_WARNING_TOO_LONG    "stt.result.message.warning.too.long"
-
-/** 
-* @brief Result warning message : The speech is too quiet to listen
-*/
-#define STT_RESULT_MESSAGE_WARNING_TOO_QUIET   "stt.result.message.warning.too.quiet"
-
-/** 
-* @brief Result warning message : The speech is too loud to listen
-*/
-#define STT_RESULT_MESSAGE_WARNING_TOO_LOUD    "stt.result.message.warning.too.loud"
-
-/** 
-* @brief Result warning message : The speech is too fast to listen
-*/
-#define STT_RESULT_MESSAGE_WARNING_TOO_FAST    "stt.result.message.warning.too.fast"
-
-/** 
-* @brief Result error message : Recognition was failed because the speech started too soon
-*/
-#define STT_RESULT_MESSAGE_ERROR_TOO_SOON      "stt.result.message.error.too.soon"
-
-/** 
-* @brief Result error message : Recognition was failed because the speech started too short
-*/
-#define STT_RESULT_MESSAGE_ERROR_TOO_SHORT     "stt.result.message.error.too.short"
-
-/** 
-* @brief Result error message : Recognition was failed because the speech started too long
-*/
-#define STT_RESULT_MESSAGE_ERROR_TOO_LONG      "stt.result.message.error.too.long"
-
-/** 
-* @brief Result error message : Recognition was failed because the speech started too quiet to listen
-*/
-#define STT_RESULT_MESSAGE_ERROR_TOO_QUIET     "stt.result.message.error.too.quiet"
-
-/** 
-* @brief Result error message : Recognition was failed because the speech started too loud to listen 
-*/
-#define STT_RESULT_MESSAGE_ERROR_TOO_LOUD      "stt.result.message.error.too.loud"
-
-/** 
-* @brief Result error message : Recognition was failed because the speech started too fast to listen
-*/
-#define STT_RESULT_MESSAGE_ERROR_TOO_FAST      "stt.result.message.error.too.fast"
-
-
-/** 
-* @brief Enumerations of state.
-*/
-typedef enum {
-       STT_STATE_CREATED = 0,                  /**< 'CREATED' state */
-       STT_STATE_READY,                        /**< 'READY' state */
-       STT_STATE_RECORDING,                    /**< 'RECORDING' state */
-       STT_STATE_PROCESSING                    /**< 'PROCESSING' state*/
-}stt_state_e;
-
-/** 
-* @brief Enumerations of profanity type.
-*/
-typedef enum {
-       STT_OPTION_PROFANITY_FALSE = 0,         /**< Profanity type - False */
-       STT_OPTION_PROFANITY_TRUE = 1,          /**< Profanity type - True */
-       STT_OPTION_PROFANITY_AUTO = 2           /**< Profanity type - Auto */
-}stt_option_profanity_e;
-
-/** 
-* @brief Enumerations of punctuation type.
-*/
-typedef enum {
-       STT_OPTION_PUNCTUATION_FALSE = 0,       /**< Punctuation type - False */
-       STT_OPTION_PUNCTUATION_TRUE = 1,        /**< Punctuation type - True */
-       STT_OPTION_PUNCTUATION_AUTO = 2         /**< Punctuation type - Auto */
-}stt_option_punctuation_e;
-
-/** 
-* @brief Enumerations of silence detection type.
-*/
-typedef enum {
-       STT_OPTION_SILENCE_DETECTION_FALSE = 0, /**< Silence detection type - False */
-       STT_OPTION_SILENCE_DETECTION_TRUE = 1,  /**< Silence detection type - True */
-       STT_OPTION_SILENCE_DETECTION_AUTO = 2   /**< Silence detection type - Auto */   
-}stt_option_silence_detection_e;
-
-/** 
-* @brief A structure of handle for STT
-*/
-typedef struct stt_s *stt_h;
-
-/**
-* @brief Called when STT gets the recognition result from engine after the application call stt_stop().
-*
-* @remark If results of recognition is valid after stt_stop() is called or silence is detected from recording, 
-*      this function is called. 
-*
-* @param[in] stt The handle for STT
-* @param[in] type Recognition type (e.g. #STT_RECOGNITION_TYPE_FREE, #STT_RECOGNITION_TYPE_WEB_SEARCH)
-* @param[in] data Result texts
-* @param[in] data_count Result text count
-* @param[in] msg Engine message        (e.g. #STT_RESULT_MESSAGE_WARNING_TOO_SOON, #STT_RESULT_MESSAGE_ERROR_TOO_SHORT)
-* @param[in] user_data The user data passed from the callback registration function
-*
-* @pre stt_stop() will invoke this callback if you register it using stt_set_result_cb().
-* @post If this function is called, the STT state will be #STT_STATE_READY.
-*
-* @see stt_stop()
-* @see stt_set_result_cb()
-* @see stt_unset_result_cb()
-*/
-typedef void (*stt_result_cb)(stt_h stt, const char* type, const char** data, int data_count, const char* msg, void *user_data);
-
-/**
-* @brief Called when STT gets recognition the partial result from engine after the application calls stt_start().
-*
-* @remark If a current engine supports partial result of recognition, this function can be called.
-*
-* @param[in] stt The handle for STT
-* @param[in] data Result data
-* @param[in] user_data The user data passed from the callback registration function
-*
-* @pre stt_start() will invoke this callback if you register it using stt_set_partial_result_cb().
-*
-* @see stt_start()
-* @see stt_set_partial_result_cb()
-* @see stt_unset_partial_result_cb()
-* @see stt_is_partial_result_supported()
-*/
-typedef void (*stt_partial_result_cb)(stt_h stt, const char* data, void *user_data);
-
-/**
-* @brief Called when the state of STT is changed. 
-*
-* @param[in] stt The handle for STT
-* @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 stt_set_state_changed_cb() to detect changing state.
-*
-* @see stt_set_state_changed_cb()
-* @see stt_unset_state_changed_cb()
-*/
-typedef void (*stt_state_changed_cb)(stt_h stt, stt_state_e previous, stt_state_e current, void* user_data);
-
-/**
-* @brief Called when error occurred. 
-*
-* @param[in] stt The handle for STT
-* @param[in] reason The error type (e.g. #STT_ERROR_OUT_OF_NETWORK, #STT_ERROR_IO_ERROR)
-* @param[in] user_data The user data passed from the callback registration function
-*
-* @pre An application registers this callback using stt_set_error_cb() to detect error.
-*
-* @see stt_set_error_cb()
-* @see stt_unset_error_cb()
-*/
-typedef void (*stt_error_cb)(stt_h stt, stt_error_e reason, void *user_data);
-
-/**
-* @brief Called to retrieve the supported languages. 
-*
-* @param[in] stt The handle for STT
-* @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] 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 stt_foreach_supported_languages() will invoke this callback. 
-*
-* @see stt_foreach_supported_languages()
-*/
-typedef bool(*stt_supported_language_cb)(stt_h stt, const char* language, void* user_data);
-
-
-/**
-* @brief Creates a handle for STT. 
-*
-* @param[out] stt The handle for STT
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #STT_ERROR_NONE Successful
-* @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #STT_ERROR_OPERATION_FAILED Operation failure
-*
-* @post If this function is called, the STT state will be #STT_STATE_CREATED.
-*
-* @see stt_destroy()
-*/
-int stt_create(stt_h* stt);
-
-/**
-* @brief Destroys the handle.
-*
-* @param[in] stt The handle for STT
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #STT_ERROR_NONE Successful
-* @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
-*
-* @see stt_create()
-*/
-int stt_destroy(stt_h stt);
-
-/**
-* @brief Connects the daemon. 
-*
-* @param[in] stt The handle for STT
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #STT_ERROR_NONE Successful
-* @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #STT_ERROR_INVALID_STATE Invalid state
-*
-* @pre The state should be #STT_STATE_CREATED.
-* @post If this function is called, the STT state will be #STT_STATE_READY.
-*
-* @see stt_unprepare()
-*/
-int stt_prepare(stt_h stt);
-
-/**
-* @brief Disconnects the daemon.
-*
-* @param[in] stt The handle for STT
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #STT_ERROR_NONE Successful
-* @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #STT_ERROR_INVALID_STATE Invalid state
-*
-* @pre The state should be #STT_STATE_READY.
-* @post If this function is called, the STT state will be #STT_STATE_CREATED.
-*
-* @see stt_prepare()
-*/
-int stt_unprepare(stt_h stt);
-
-/**
-* @brief Retrieves all supported languages of current engine using callback function.
-*
-* @param[in] stt The handle for STT
-* @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 #STT_ERROR_NONE Successful
-* @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #STT_ERROR_OPERATION_FAILED Operation failure
-* @retval #STT_ERROR_INVALID_STATE Invalid state
-*
-* @pre The state should be #STT_STATE_READY.
-* @post        This function invokes stt_supported_language_cb() repeatedly for getting languages. 
-*
-* @see stt_supported_language_cb()
-* @see stt_get_default_language()
-*/
-int stt_foreach_supported_languages(stt_h stt, stt_supported_language_cb callback, void* user_data);
-
-/**
-* @brief Gets the default language set by user.
-*
-* @remark If the function succeeds, @a language must be released with free() by you when you no longer need it.
-*
-* @param[in] stt The handle for STT
-* @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.
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #STT_ERROR_NONE Successful
-* @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #STT_ERROR_OUT_OF_MEMORY Out of memory
-* @retval #STT_ERROR_OPERATION_FAILED Operation failure
-* @retval #STT_ERROR_INVALID_STATE Invalid state
-*
-* @pre The state should be #STT_STATE_READY.
-*
-* @see stt_foreach_supported_languages()
-*/
-int stt_get_default_language(stt_h stt, char** language);
-
-/**
-* @brief Gets the current state of STT.
-*
-* @param[in] stt The handle for STT
-* @param[out] state The current state of STT
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #STT_ERROR_NONE Successful
-* @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
-*
-* @see stt_start()
-* @see stt_stop()
-* @see stt_cancel()
-* @see stt_state_changed_cb()
-*/
-int stt_get_state(stt_h stt, stt_state_e* state);
-
-/**
-* @brief Checks whether the partial results can be returned while a recognition is in process.
-*
-* @param[in] stt The handle for STT
-* @param[out] partial_result The partial result status : (@c true = supported, @c false = not supported)
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #STT_ERROR_NONE Successful
-* @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #STT_ERROR_OPERATION_FAILED Operation failure
-* @retval #STT_ERROR_INVALID_STATE Invalid state
-*
-* @pre The state should be #STT_STATE_READY.
-*
-* @see stt_partial_result_cb()
-*/
-int stt_is_partial_result_supported(stt_h stt, bool* partial_result);
-
-/**
-* @brief Sets profanity filter.
-*
-* @param[in] stt The handle for STT
-* @param[in] type The option type
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #STT_ERROR_NONE Successful
-* @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #STT_ERROR_INVALID_STATE Invalid state
-* @retval #STT_ERROR_NOT_SUPPORTED_FEATURE Not supported feature of current engine
-*
-* @pre The state should be #STT_STATE_READY.
-*/
-int stt_set_profanity_filter(stt_h stt, stt_option_profanity_e type);
-
-/**
-* @brief Sets punctuation override.
-*
-* @param[in] stt The handle for STT
-* @param[in] type The option type
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #STT_ERROR_NONE Successful
-* @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #STT_ERROR_INVALID_STATE Invalid state
-* @retval #STT_ERROR_NOT_SUPPORTED_FEATURE Not supported feature of current engine
-*
-* @pre The state should be #STT_STATE_READY.
-*/
-int stt_set_punctuation_override(stt_h stt, stt_option_punctuation_e type);
-
-/**
-* @brief Sets silence detection.
-*
-* @param[in] stt The handle for STT
-* @param[in] type The option type
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #STT_ERROR_NONE Successful
-* @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #STT_ERROR_INVALID_STATE Invalid state
-* @retval #STT_ERROR_NOT_SUPPORTED_FEATURE Not supported feature of current engine
-*
-* @pre The state should be #STT_STATE_READY.
-*/
-int stt_set_silence_detection(stt_h stt, stt_option_silence_detection_e type);
-
-/**
-* @brief Starts recording and recognition.
-*
-* @remark This function starts recording in the daemon and sending recording data to engine. \n
-* This work continues until stt_stop(), stt_cancel() or silence detected.
-*
-* @param[in] stt The handle for STT
-* @param[in] language The language selected from stt_foreach_supported_languages()
-* @param[in] type The type for recognition (e.g. #STT_RECOGNITION_TYPE_FREE, #STT_RECOGNITION_TYPE_WEB_SEARCH)
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #STT_ERROR_NONE Successful
-* @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter.
-* @retval #STT_ERROR_INVALID_STATE Invalid state
-* @retval #STT_ERROR_OPERATION_FAILED Operation failure
-* @retval #STT_ERROR_RECORDER_BUSY Recorder busy
-* @retval #STT_ERROR_INVALID_LANGUAGE Invalid language
-*
-* @pre The state should be #STT_STATE_READY.
-* @post It will invoke stt_state_changed_cb(), if you register a callback with stt_state_changed_cb(). \n
-* If this function succeeds, the STT state will be #STT_STATE_RECORDING.
-*
-* @see stt_stop()
-* @see stt_cancel()
-* @see stt_state_changed_cb()
-* @see stt_error_cb()
-*/
-int stt_start(stt_h stt, const char* language, const char* type);
-
-/**
-* @brief Finishes recording and starts recognition processing in engine.
-*
-* @param[in] stt The handle for STT
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #STT_ERROR_NONE Successful
-* @retval #STT_ERROR_OUT_OF_MEMORY Not enough memory
-* @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #STT_ERROR_INVALID_STATE Invalid state
-* @retval #STT_ERROR_OPERATION_FAILED Operation failure
-*
-* @pre The state should be #STT_STATE_RECORDING.
-* @post It will invoke stt_state_changed_cb(), if you register a callback with stt_state_changed_cb(). \n
-* If this function succeeds, the STT state will be #STT_STATE_PROCESSING. \n
-* After processing of engine, stt_result_cb() is called.
-*
-* @see stt_start()
-* @see stt_cancel()
-* @see stt_state_changed_cb()
-* @see stt_error_cb()
-*/
-int stt_stop(stt_h stt);
-
-/**
-* @brief Cancels processing recognition and recording.
-*
-* @remark This function cancels recording and engine cancels recognition processing. \n
-* After successful cancel, stt_state_changed_cb() is called otherwise if error is occurred, stt_error_cb() is called. 
-*
-* @param[in] stt The handle for STT
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #STT_ERROR_NONE Successful
-* @retval #STT_ERROR_OUT_OF_MEMORY Not enough memory
-* @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #STT_ERROR_INVALID_STATE Invalid state
-* @retval #STT_ERROR_OPERATION_FAILED Operation failure
-*
-* @pre The state should be #STT_STATE_RECORDING or #STT_STATE_PROCESSING.
-* @post It will invoke stt_state_changed_cb(), if you register a callback with stt_state_changed_cb(). \n
-* If this function succeeds, the STT state will be #STT_STATE_READY.
-*
-* @see stt_start()
-* @see stt_stop()
-* @see stt_state_changed_cb()
-* @see stt_error_cb()
-*/
-int stt_cancel(stt_h stt);
-
-/**
-* @brief Gets the microphone volume during recording.
-*      
-* @param[in] stt The handle for STT
-* @param[out] volume Recording volume
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #STT_ERROR_NONE Successful
-* @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #STT_ERROR_INVALID_STATE Invalid state
-* @retval #STT_ERROR_OPERATION_FAILED Operation failure
-*
-* @pre The state should be #STT_STATE_RECORDING.
-* 
-* @see stt_start()
-*/
-int stt_get_recording_volume(stt_h stt, float* volume);
-
-/**
-* @brief Registers a callback function for getting recognition result.
-*
-* @param[in] stt The handle for STT
-* @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 #STT_ERROR_NONE Successful
-* @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #STT_ERROR_INVALID_STATE Invalid state
-*
-* @pre The state should be #STT_STATE_CREATED.
-*
-* @see stt_result_cb()
-* @see stt_unset_result_cb()
-*/
-int stt_set_result_cb(stt_h stt, stt_result_cb callback, void* user_data);
-
-/**
-* @brief Unregisters the callback function.
-*
-* @param[in] stt The handle for STT
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #STT_ERROR_NONE Successful
-* @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #STT_ERROR_INVALID_STATE Invalid state
-*
-* @pre The state should be #STT_STATE_CREATED.
-*
-* @see stt_set_result_cb()
-*/
-int stt_unset_result_cb(stt_h stt);
-
-/**
-* @brief Registers a callback function for getting partial result of recognition.
-*
-* @param[in] stt The handle for STT
-* @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 #STT_ERROR_NONE Successful
-* @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #STT_ERROR_INVALID_STATE Invalid state
-*
-* @pre The state should be #STT_STATE_CREATED.
-*
-* @see stt_partial_result_cb()
-* @see stt_unset_partial_result_cb()
-*/
-int stt_set_partial_result_cb(stt_h stt, stt_partial_result_cb callback, void* user_data);
-
-/**
-* @brief Unregisters the callback function.
-*
-* @param[in] stt The handle for STT
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #STT_ERROR_NONE Successful
-* @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #STT_ERROR_INVALID_STATE Invalid state
-*
-* @pre The state should be #STT_STATE_CREATED.
-*
-* @see stt_set_partial_result_cb()
-*/
-int stt_unset_partial_result_cb(stt_h stt);
-
-/**
-* @brief Registers a callback function to be called when STT state changes.
-*
-* @param[in] stt The handle for STT
-* @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 #STT_ERROR_NONE Successful
-* @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #STT_ERROR_INVALID_STATE Invalid state
-*
-* @pre The state should be #STT_STATE_CREATED.
-*
-* @see stt_state_changed_cb()
-* @see stt_unset_state_changed_cb()
-*/
-int stt_set_state_changed_cb(stt_h stt, stt_state_changed_cb callback, void* user_data);
-
-/**
-* @brief Unregisters the callback function.
-*
-* @param[in] stt The handle for STT
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #STT_ERROR_NONE Successful
-* @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #STT_ERROR_INVALID_STATE Invalid state
-*
-* @pre The state should be #STT_STATE_CREATED.
-*
-* @see stt_set_state_changed_cb()
-*/
-int stt_unset_state_changed_cb(stt_h stt);
-
-/**
-* @brief Registers a callback function to be called when an error occurred.
-*
-* @param[in] stt The handle for STT
-* @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 #STT_ERROR_NONE Successful
-* @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #STT_ERROR_INVALID_STATE Invalid state
-*
-* @pre The state should be #STT_STATE_CREATED.
-*
-* @see stt_error_cb()
-* @see stt_unset_error_cb()
-*/
-int stt_set_error_cb(stt_h stt, stt_error_cb callback, void* user_data);
-
-/**
-* @brief Unregisters the callback function.
-*
-* @param[in] stt The handle for STT
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #STT_ERROR_NONE Successful
-* @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #STT_ERROR_INVALID_STATE Invalid state
-*
-* @pre The state should be #STT_STATE_CREATED.
-*
-* @see stt_set_error_cb()
-*/
-int stt_unset_error_cb(stt_h stt);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-/**
- * @}@}
- */
-
-#endif /* __STT_H__ */
index 0c00a06..f9e28e2 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,30 +51,29 @@ int stt_client_new(stt_h* stt)
        client->pid = getpid(); 
        client->uid = temp->handle;
        
-       client->result_cb = NULL;
-       client->result_user_data = NULL;
-       client->partial_result_cb = NULL;
-       client->partial_result_user_data = NULL;
+       client->recognition_result_cb = NULL;
+       client->recognition_result_user_data = NULL;
        client->state_changed_cb = NULL;
        client->state_changed_user_data = NULL;
        client->error_cb = NULL;
        client->error_user_data = NULL;
+       client->default_lang_changed_cb = NULL;
+       client->default_lang_changed_user_data = NULL;
 
-       client->silence_supported = false;
-       client->profanity_supported = false;
-       client->punctuation_supported = false;
+       client->current_engine_id = NULL;
 
-       client->profanity = STT_OPTION_PROFANITY_AUTO;  
-       client->punctuation = STT_OPTION_PUNCTUATION_AUTO;
+       client->silence_supported = false;
        client->silence = STT_OPTION_SILENCE_DETECTION_AUTO;
 
-       client->type = NULL;
+       client->event = 0;
        client->data_list = NULL;
        client->data_count = 0;
        client->msg = NULL;
 
        client->before_state = STT_STATE_CREATED;
-       client->current_state = STT_STATE_CREATED; 
+       client->current_state = STT_STATE_CREATED;
+
+       client->internal_state = STT_INTERNAL_STATE_NONE;
 
        client->cb_ref_count = 0;
 
@@ -90,7 +89,7 @@ int stt_client_destroy(stt_h stt)
        if (stt == NULL) {
                SLOG(LOG_ERROR, TAG_STTC, "Input parameter is NULL");
                return 0;
-       }       
+       }
 
        GList *iter = NULL;
        stt_client_s *data = NULL;
@@ -109,6 +108,11 @@ int stt_client_destroy(stt_h stt)
                                {
                                        /* wait for release callback function */
                                }
+                               
+                               if (NULL != data->current_engine_id) {
+                                       free(data->current_engine_id);
+                               }
+
                                free(data);
                                free(stt);
 
@@ -128,7 +132,7 @@ int stt_client_destroy(stt_h stt)
 
 stt_client_s* stt_client_get(stt_h stt)
 {
-       if (stt == NULL) {
+       if (NULL == stt) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
                return NULL;
        }
@@ -142,10 +146,10 @@ stt_client_s* stt_client_get(stt_h stt)
 
                while (NULL != iter) {
                        data = iter->data;
-
-                       if (stt->handle == data->stt->handle) 
-                               return data;
-
+                       if (NULL != data) {
+                               if (stt->handle == data->stt->handle) 
+                                       return data;
+                       }
                        /* Next item */
                        iter = g_list_next(iter);
                }
@@ -208,19 +212,7 @@ int stt_client_get_use_callback(stt_client_s* client)
        return client->cb_ref_count;
 }
 
-int stt_client_set_option_supported(stt_h stt, bool silence, bool profanity, bool punctuation)
+GList* stt_client_get_client_list()
 {
-       stt_client_s* client = stt_client_get(stt);
-       
-       /* check handle */
-       if (NULL == client) 
-               return STT_ERROR_INVALID_PARAMETER;
-       
-       client->silence_supported = silence;
-       client->profanity_supported = profanity;
-       client->punctuation_supported = punctuation;
-
-       return 0;
-}
-
-
+       return g_client_list;
+}
\ No newline at end of file
index 7d0525c..6bbdbe1 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
 extern "C" {
 #endif
 
+typedef enum {
+       STT_INTERNAL_STATE_NONE         = 0,
+       STT_INTERNAL_STATE_STARTING     = 1,
+       STT_INTERNAL_STATE_STOPING      = 2
+}stt_internal_state_e;
 
 typedef struct {
        /* base info */
@@ -30,42 +35,51 @@ typedef struct {
        int     pid; 
        int     uid;    /*<< unique id = pid + handle */
 
-       stt_result_cb           result_cb;
-       void*                   result_user_data;
-       stt_partial_result_cb   partial_result_cb;
-       void*                   partial_result_user_data;
-       stt_state_changed_cb    state_changed_cb;
-       void*                   state_changed_user_data;
-       stt_error_cb            error_cb;
-       void*                   error_user_data;
+       stt_recognition_result_cb       recognition_result_cb;
+       void*                           recognition_result_user_data;
+       stt_result_time_cb              result_time_cb;
+       void*                           result_time_user_data;
 
-       /* option */
-       bool    silence_supported;
-       bool    profanity_supported;
-       bool    punctuation_supported;
+       stt_state_changed_cb            state_changed_cb;
+       void*                           state_changed_user_data;
+       stt_error_cb                    error_cb;
+       void*                           error_user_data;
+       stt_default_language_changed_cb default_lang_changed_cb;
+       void*                           default_lang_changed_user_data;
+
+       stt_supported_engine_cb         supported_engine_cb;
+       void*                           supported_engine_user_data;
+       stt_supported_language_cb       supported_lang_cb;
+       void*                           supported_lang_user_data;
 
-       stt_option_profanity_e          profanity;      
-       stt_option_punctuation_e        punctuation;
+       char*           current_engine_id;
+
+       /* option */
+       bool            silence_supported;
        stt_option_silence_detection_e  silence;
 
        /* state */
        stt_state_e     before_state;
        stt_state_e     current_state;
 
+       stt_internal_state_e    internal_state;
+
        /* mutex */
        int             cb_ref_count;
 
        /* result data */
-       char*   partial_result;
-       char*   type;
+       int     event;
        char**  data_list;
        int     data_count;
        char*   msg;
-
+       
        /* error data */
        int     reason;
 }stt_client_s;
 
+
+typedef bool (*stt_time_cb)(int index, int event, const char* text, long start_time, long end_time, void *user_data);
+
 int stt_client_new(stt_h* stt);
 
 int stt_client_destroy(stt_h stt);
@@ -82,7 +96,7 @@ int stt_client_not_use_callback(stt_client_s* client);
 
 int stt_client_get_use_callback(stt_client_s* client);
 
-int stt_client_set_option_supported(stt_h stt, bool silence, bool profanity, bool punctuation);
+GList* stt_client_get_client_list();
 
 #ifdef __cplusplus
 }
index 4925037..f453a45 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 "stt_dbus.h"
 #include "stt_defs.h"
 
-#include <Ecore.h>
 #include "stt_client.h"
 
-static int g_waiting_time = 1500;
-static int g_waiting_start_time = 2000;
+static int g_waiting_time = 3000;
+static int g_waiting_short_time = 500;
 
 static Ecore_Fd_Handler* g_fd_handler = NULL;
 
@@ -29,9 +28,7 @@ static DBusConnection* g_conn = NULL;
 
 extern int __stt_cb_error(int uid, int reason);
 
-extern int __stt_cb_result(int uid, const char* type, const char** data, int data_count, const char* msg);
-       
-extern int __stt_cb_partial_result(int uid, const char* data);
+extern int __stt_cb_result(int uid, int event, char** data, int data_count, const char* msg);
 
 extern int __stt_cb_set_state(int uid, int state);
 
@@ -48,6 +45,11 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
 
        msg = dbus_connection_pop_message(conn);
 
+       if (true != dbus_connection_get_is_connected(conn)) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Conn is disconnected");
+               return ECORE_CALLBACK_RENEW;
+       }
+
        /* loop again if we haven't read a message */
        if (NULL == msg) { 
                return ECORE_CALLBACK_RENEW;
@@ -65,9 +67,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_STTC, "[ERROR] Get arguments error (%s)", err.message);
+                       dbus_error_free(&err);
+               }
 
                if (uid > 0) {
-                       SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt get hello : uid(%d) \n", uid);
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt get hello : uid(%d)", uid);
                        
                        /* check uid */
                        stt_client_s* client = stt_client_get_by_uid(uid);
@@ -76,7 +82,7 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
                        else 
                                response = 0;
                } else {
-                       SLOG(LOG_ERROR, TAG_STTC, "<<<< stt get hello : invalid uid \n");
+                       SLOG(LOG_ERROR, TAG_STTC, "<<<< stt get hello : invalid uid");
                }
 
                reply = dbus_message_new_method_return(msg);
@@ -110,8 +116,13 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
                        DBUS_TYPE_INT32, &state,
                        DBUS_TYPE_INVALID);
 
+               if (dbus_error_is_set(&err)) {
+                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Get arguments error (%s)", err.message);
+                       dbus_error_free(&err);
+               }
+
                if (uid > 0 && state >= 0) {
-                       SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt set state : uid(%d), state(%d)", uid, state);
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt set state : uid(%d), state(%d)", uid, state);
 
                        response = __stt_cb_set_state(uid, state);
                } else {
@@ -123,10 +134,9 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
                if (NULL != reply) {
                        dbus_message_append_args(reply, DBUS_TYPE_INT32, &response, DBUS_TYPE_INVALID);
 
-                       if (!dbus_connection_send(conn, reply, NULL))
+                       if (!dbus_connection_send(conn, reply, NULL)) {
                                SLOG(LOG_ERROR, TAG_STTC, ">>>> stt set state : fail to send reply");
-                       else 
-                               SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt set state : result(%d)", response);
+                       }
 
                        dbus_connection_flush(conn);
                        dbus_message_unref(reply); 
@@ -145,18 +155,23 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
 
                dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
 
+               if (dbus_error_is_set(&err)) {
+                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Get arguments error (%s)", err.message);
+                       dbus_error_free(&err);
+               }
+
                if (uid > 0) {
-                       SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt get state : uid(%d) \n", uid);
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt get state : uid(%d)", uid);
 
                        /* check state */
                        stt_client_s* client = stt_client_get_by_uid(uid);
                        if( NULL != client ) 
                                response = client->current_state;
                        else 
-                               SLOG(LOG_ERROR, TAG_STTC, "invalid uid \n");
+                               SLOG(LOG_ERROR, TAG_STTC, "invalid uid");
                        
                } else {
-                       SLOG(LOG_ERROR, TAG_STTC, "<<<< stt get state : invalid uid \n");
+                       SLOG(LOG_ERROR, TAG_STTC, "<<<< stt get state : invalid uid");
                }
 
                reply = dbus_message_new_method_return(msg);
@@ -193,16 +208,15 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
                }
                
                if (uid > 0) {
-                       SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt get result : uid(%d) \n", uid);
-                       char** temp_result;
+                       char** temp_result = NULL;
                        char* temp_msg = NULL;
                        char* temp_char = NULL;
-                       char* temp_type = 0;
+                       int temp_event = 0;
                        int temp_count = 0;
 
                        /* Get recognition type */
-                       if (DBUS_TYPE_STRING == dbus_message_iter_get_arg_type(&args)) {
-                               dbus_message_iter_get_basic(&args, &temp_type);
+                       if (DBUS_TYPE_INT32 == dbus_message_iter_get_arg_type(&args)) {
+                               dbus_message_iter_get_basic(&args, &temp_event);
                                dbus_message_iter_next(&args);
                        }
 
@@ -217,72 +231,45 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
                                dbus_message_iter_next(&args);
                        }
 
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt get result : uid(%d) event(%d) message(%s) count(%d)", 
+                               uid, temp_event, temp_msg, temp_count);
+
                        if (temp_count <= 0) {
-                               SLOG(LOG_WARN, TAG_STTC, "Result count is 0");
-                               __stt_cb_result(uid, temp_type, NULL, 0, temp_msg);
+                               __stt_cb_result(uid, temp_event, NULL, 0, temp_msg);
                        } else {
-                               temp_result = g_malloc0(temp_count * sizeof(char*));
+                               temp_result = (char**)calloc(temp_count, sizeof(char*));
 
                                if (NULL == temp_result)        {
-                                       SLOG(LOG_ERROR, TAG_STTC, "Fail : memory allocation error \n");
+                                       SLOG(LOG_ERROR, TAG_STTC, "Fail : memory allocation error");
                                } else {
                                        int i = 0;
                                        for (i = 0;i < temp_count;i++) {
                                                dbus_message_iter_get_basic(&args, &(temp_char) );
                                                dbus_message_iter_next(&args);
-                                               
-                                               if (NULL != temp_char)
+
+                                               if (NULL != temp_char) {
                                                        temp_result[i] = strdup(temp_char);
+                                                       SLOG(LOG_DEBUG, TAG_STTC, "result[%d] : %s", i, temp_result[i]);
+                                               }
                                        }
-               
-                                       __stt_cb_result(uid, temp_type, (const char**)temp_result, temp_count, temp_msg);
+
+                                       __stt_cb_result(uid, temp_event, temp_result, temp_count, temp_msg);
 
                                        for (i = 0;i < temp_count;i++) {
                                                if (NULL != temp_result[i])
                                                        free(temp_result[i]);
                                        }
 
-                                       g_free(temp_result);
+                                       free(temp_result);
                                }
-                       }       
-               } else {
-                       SLOG(LOG_ERROR, TAG_STTC, "<<<< stt get result : invalid uid \n");
-               } 
-               
-               SLOG(LOG_DEBUG, TAG_STTC, "=====");
-               SLOG(LOG_DEBUG, TAG_STTC, " ");
-       }/* STTD_METHOD_RESULT */
-
-       else if (dbus_message_is_method_call(msg, if_name, STTD_METHOD_PARTIAL_RESULT)) {
-               SLOG(LOG_DEBUG, TAG_STTC, "===== Get Partial Result");
-               int uid = 0;
-               DBusMessageIter args;
-
-               dbus_message_iter_init(msg, &args);
-
-               /* Get result */
-               if (DBUS_TYPE_INT32 == dbus_message_iter_get_arg_type(&args)) {
-                       dbus_message_iter_get_basic(&args, &uid);
-                       dbus_message_iter_next(&args);
-               }
-
-               if (uid > 0) {
-                       SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt get partial result : uid(%d) \n", uid);
-                       char* temp_char = NULL;
-
-                       if (DBUS_TYPE_STRING == dbus_message_iter_get_arg_type(&args)) {
-                               dbus_message_iter_get_basic(&args, &(temp_char) );
-                               dbus_message_iter_next(&args);
                        }
-
-                       __stt_cb_partial_result(uid, temp_char);
                } else {
-                       SLOG(LOG_ERROR, TAG_STTC, "<<<< stt get partial result : invalid uid \n");
+                       SLOG(LOG_ERROR, TAG_STTC, "<<<< stt get result : invalid uid");
                }
 
                SLOG(LOG_DEBUG, TAG_STTC, "=====");
                SLOG(LOG_DEBUG, TAG_STTC, " ");
-       }/* STTD_METHOD_PARTIAL_RESULT */
+       }/* STTD_METHOD_RESULT */
 
        else if (dbus_message_is_method_call(msg, if_name, STTD_METHOD_ERROR)) {
                SLOG(LOG_DEBUG, TAG_STTC, "===== Get Error");
@@ -300,7 +287,7 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
                        SLOG(LOG_ERROR, TAG_STTC, "<<<< stt Get Error message : Get arguments error (%s)\n", err.message);
                        dbus_error_free(&err); 
                } else {
-                       SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt Get Error message : uid(%d), reason(%d), msg(%s)\n", uid, reason, err_msg);
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt Get Error message : uid(%d), reason(%d), msg(%s)\n", uid, reason, err_msg);
                        __stt_cb_error(uid, reason);
                }
 
@@ -346,11 +333,11 @@ int stt_dbus_open_connection()
 
        if (dbus_error_is_set(&err)) { 
                SLOG(LOG_ERROR, TAG_STTC, "Dbus Connection Error (%s)\n", err.message); 
-               dbus_error_free(&err); 
+               dbus_error_free(&err);
        }
 
        if (NULL == g_conn) {
-               SLOG(LOG_ERROR, TAG_STTC, "Fail to get dbus connection \n");
+               SLOG(LOG_ERROR, TAG_STTC, "Fail to get dbus connection");
                return STT_ERROR_OPERATION_FAILED; 
        }
 
@@ -360,7 +347,7 @@ int stt_dbus_open_connection()
        memset(service_name, '\0', 64);
        snprintf(service_name, 64, "%s%d", STT_CLIENT_SERVICE_NAME, pid);
 
-       SLOG(LOG_DEBUG, TAG_STTC, "service name is %s\n", service_name);
+       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "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);
@@ -371,7 +358,7 @@ int stt_dbus_open_connection()
        }
 
        if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) {
-               printf("fail dbus_bus_request_name()\n");
+               SLOG(LOG_ERROR, TAG_STTC, "[Dbus ERROR] Fail to be primary owner");
                return -2;
        }
 
@@ -387,24 +374,24 @@ int stt_dbus_open_connection()
        dbus_bus_add_match(g_conn, rule, &err); 
        dbus_connection_flush(g_conn);
 
-       if (dbus_error_is_set(&err)) 
-       { 
+       if (dbus_error_is_set(&err)) { 
                SLOG(LOG_ERROR, TAG_STTC, "Match Error (%s)\n", err.message);
+               dbus_error_free(&err);
                return STT_ERROR_OPERATION_FAILED; 
        }
 
        int fd = 0;
        if (1 != dbus_connection_get_unix_fd(g_conn, &fd)) {
-               SLOG(LOG_ERROR, TAG_STTC, "fail to get fd from dbus \n");
+               SLOG(LOG_ERROR, TAG_STTC, "fail to get fd from dbus");
                return STT_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_DEBUG, TAG_STTC, "Get fd from dbus : %d\n", fd);
+               SECURE_SLOG(LOG_DEBUG, TAG_STTC, "Get fd from dbus : %d\n", fd);
        }
 
        g_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_STTC, "fail to get fd handler from ecore \n");
+               SLOG(LOG_ERROR, TAG_STTC, "fail to get fd handler from ecore");
                return STT_ERROR_OPERATION_FAILED;
        }
 
@@ -424,6 +411,11 @@ int stt_dbus_close_connection()
 
        dbus_bus_release_name (g_conn, service_name, &err);
 
+       if (dbus_error_is_set(&err)) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Release name Error (%s)", err.message);
+               dbus_error_free(&err);
+       }
+
        dbus_connection_close(g_conn);
 
        g_fd_handler = NULL;
@@ -432,6 +424,25 @@ int stt_dbus_close_connection()
        return 0;
 }
 
+int stt_dbus_reconnect()
+{
+       bool connected = dbus_connection_get_is_connected(g_conn);
+       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "[DBUS] %s", connected ? "Connected" : "Not connected");
+
+       if (false == connected) {
+               stt_dbus_close_connection();
+
+               if(0 != stt_dbus_open_connection()) {
+                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to reconnect");
+                       return -1;
+               } 
+
+               SLOG(LOG_DEBUG, TAG_STTC, "[DBUS] Reconnect");
+       }
+       
+       return 0;
+}
+
 int stt_dbus_request_hello()
 {
        DBusMessage* msg;
@@ -443,34 +454,52 @@ int stt_dbus_request_hello()
                STT_METHOD_HELLO);
 
        if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_STTC, ">>>> Request stt hello : Fail to make message \n"); 
+               SLOG(LOG_ERROR, TAG_STTC, ">>>> Request stt hello : Fail to make message"); 
                return STT_ERROR_OPERATION_FAILED;
        } 
 
+       if (NULL == g_conn) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Connection is NOT valid");
+               dbus_message_unref(msg);
+               return STT_ERROR_INVALID_STATE;
+       }
+
        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);
+       int result = STT_DAEMON_NORMAL;
 
+       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_short_time, &err);
        dbus_message_unref(msg);
+       if (dbus_error_is_set(&err)) {
+               dbus_error_free(&err);
+       }
 
+       int status = 0;
        if (NULL != result_msg) {
+               dbus_message_get_args(result_msg, &err,
+                               DBUS_TYPE_INT32, &status,
+                               DBUS_TYPE_INVALID);
+
                dbus_message_unref(result_msg);
 
-               SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt hello");
-               result = 0;
+               if (dbus_error_is_set(&err)) {
+                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Get arguments error (%s)", err.message);
+                       dbus_error_free(&err);
+               }
+
+               SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt hello - %d", status);
+               result = status;
        } else {
-               result = STT_ERROR_OPERATION_FAILED;
+               result = STT_ERROR_TIMED_OUT;
        }
 
        return result;
 }
 
 
-int stt_dbus_request_initialize(int uid, bool* silence_supported, bool* profanity_supported, bool* punctuation_supported)
+int stt_dbus_request_initialize(int uid, bool* silence_supported)
 {
        DBusMessage* msg;
 
@@ -481,10 +510,16 @@ int stt_dbus_request_initialize(int uid, bool* silence_supported, bool* profanit
                STT_METHOD_INITIALIZE);
 
        if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_STTC, ">>>> stt initialize : Fail to make message \n"); 
+               SLOG(LOG_ERROR, TAG_STTC, ">>>> stt initialize : Fail to make message"); 
                return STT_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt initialize : uid(%d)", uid);
+               SECURE_SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt initialize : uid(%d)", uid);
+       }
+
+       if (NULL == g_conn) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Connection is NOT valid");
+               dbus_message_unref(msg);
+               return STT_ERROR_INVALID_STATE;
        }
 
        int pid = getpid();
@@ -500,13 +535,16 @@ int stt_dbus_request_initialize(int uid, bool* silence_supported, bool* profanit
        int result = STT_ERROR_OPERATION_FAILED;
 
        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, TAG_STTC, "[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_INT32, silence_supported,
-                       DBUS_TYPE_INT32, profanity_supported,
-                       DBUS_TYPE_INT32, punctuation_supported,
                        DBUS_TYPE_INVALID);
 
                if (dbus_error_is_set(&err)) { 
@@ -515,19 +553,19 @@ int stt_dbus_request_initialize(int uid, bool* silence_supported, bool* profanit
                        result = STT_ERROR_OPERATION_FAILED;
                }
 
-               dbus_message_unref(result_msg);
-       } else {
-               SLOG(LOG_ERROR, TAG_STTC, "<<<< Result message is NULL \n");
-       }
+               if (0 == result) {
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt initialize : result = %d, silence(%d)",
+                               result, *silence_supported);
+               } else {
+                       SLOG(LOG_ERROR, TAG_STTC, "<<<< stt initialize : result = %d", result);
+               }
 
-       if (0 == result) {
-               SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt initialize : result = %d , silence(%d), profanity(%d), punctuation(%d)", 
-                       result, *silence_supported, *profanity_supported, *punctuation_supported);
+               dbus_message_unref(result_msg);
        } else {
-               SLOG(LOG_ERROR, TAG_STTC, "<<<< stt initialize : result = %d \n", result);
+               SLOG(LOG_ERROR, TAG_STTC, "<<<< Result message is NULL");
+               stt_dbus_reconnect();
+               result = STT_ERROR_TIMED_OUT;
        }
-       
-       dbus_message_unref(msg);
 
        return result;
 }
@@ -543,10 +581,16 @@ int stt_dbus_request_finalize(int uid)
                STT_METHOD_FINALIZE);
 
        if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_STTC, ">>>> stt finalize : Fail to make message \n"); 
+               SLOG(LOG_ERROR, TAG_STTC, ">>>> stt finalize : Fail to make message"); 
                return STT_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt finalize : uid(%d)", uid);
+               SECURE_SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt finalize : uid(%d)", uid);
+       }
+
+       if (NULL == g_conn) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Connection is NOT valid");
+               dbus_message_unref(msg);
+               return STT_ERROR_INVALID_STATE;
        }
 
        dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
@@ -557,7 +601,12 @@ int stt_dbus_request_finalize(int uid)
        DBusMessage* result_msg;
        int result = STT_ERROR_OPERATION_FAILED;
 
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
+       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_short_time, &err);
+       dbus_message_unref(msg);
+       if (dbus_error_is_set(&err)) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Send Error (%s)", err.message);
+               dbus_error_free(&err);
+       }
 
        if (NULL != result_msg) {
                dbus_message_get_args(result_msg, &err, 
@@ -565,23 +614,168 @@ int stt_dbus_request_finalize(int uid)
                                DBUS_TYPE_INVALID);
 
                if (dbus_error_is_set(&err)) { 
-                       printf("<<<< Get arguments error (%s)\n", err.message);
+                       SLOG(LOG_ERROR, TAG_STTC, "<<<< Get arguments error (%s)", err.message);
+                       dbus_error_free(&err); 
+                       result = STT_ERROR_OPERATION_FAILED;
+               }
+
+               dbus_message_unref(result_msg);
+
+               if (0 == result) {
+                       SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt finalize : result = %d", result);
+               } else {
+                       SLOG(LOG_ERROR, TAG_STTC, "<<<< stt finalize : result = %d", result);
+               }
+       } else {
+               SLOG(LOG_ERROR, TAG_STTC, "<<<< Result message is NULL");
+               stt_dbus_reconnect();
+               result = STT_ERROR_TIMED_OUT;
+       }
+
+       return result;
+}
+
+int stt_dbus_request_set_current_engine(int uid, const char* engine_id, bool* silence_supported)
+{
+       DBusMessage* msg;
+
+       msg = dbus_message_new_method_call(
+               STT_SERVER_SERVICE_NAME, 
+               STT_SERVER_SERVICE_OBJECT_PATH, 
+               STT_SERVER_SERVICE_INTERFACE, 
+               STT_METHOD_SET_CURRENT_ENGINE);
+
+       if (NULL == msg) { 
+               SLOG(LOG_ERROR, TAG_STTC, ">>>> stt set engine : Fail to make message"); 
+               return STT_ERROR_OPERATION_FAILED;
+       } else {
+               SECURE_SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt set engine : uid(%d)", uid);
+       }
+
+       if (NULL == g_conn) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Connection is NOT valid");
+               dbus_message_unref(msg);
+               return STT_ERROR_INVALID_STATE;
+       }
+
+       dbus_message_append_args( msg, 
+               DBUS_TYPE_INT32, &uid,
+               DBUS_TYPE_STRING, &engine_id,
+               DBUS_TYPE_INVALID);
+
+       DBusError err;
+       dbus_error_init(&err);
+
+       DBusMessage* result_msg;
+       int result = STT_ERROR_OPERATION_FAILED;
+
+       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, TAG_STTC, "[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_INT32, silence_supported,
+                       DBUS_TYPE_INVALID);
+
+               if (dbus_error_is_set(&err)) {
+                       SLOG(LOG_ERROR, TAG_STTC, "<<<< Get arguments error (%s)\n", err.message);
                        dbus_error_free(&err); 
                        result = STT_ERROR_OPERATION_FAILED;
                }
 
                dbus_message_unref(result_msg);
+
+               if (0 == result) {
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt set engine : result = %d , silence(%d)", 
+                               result, *silence_supported);
+               } else {
+                       SLOG(LOG_ERROR, TAG_STTC, "<<<< stt set engine : result = %d", result);
+               }
        } else {
-               SLOG(LOG_ERROR, TAG_STTC, "<<<< Result message is NULL \n");
+               SLOG(LOG_ERROR, TAG_STTC, "<<<< Result message is NULL");
+               stt_dbus_reconnect();
+               result = STT_ERROR_TIMED_OUT;
        }
 
-       if (0 == result) {
-               SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt finalize : result = %d \n", result);
+       return result;
+}
+
+int stt_dbus_request_check_app_agreed(int uid, const char* appid, bool* value)
+{
+       if (NULL == appid || NULL == value) {
+               SLOG(LOG_ERROR, TAG_STTC, "Input parameter is NULL");
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+
+       DBusMessage* msg;
+
+       msg = dbus_message_new_method_call(
+               STT_SERVER_SERVICE_NAME, 
+               STT_SERVER_SERVICE_OBJECT_PATH, 
+               STT_SERVER_SERVICE_INTERFACE, 
+               STT_METHOD_CHECK_APP_AGREED);
+
+       if (NULL == msg) {
+               SLOG(LOG_ERROR, TAG_STTC, ">>>> stt check app agreed : Fail to make message");
+               return STT_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_ERROR, TAG_STTC, "<<<< stt finalize : result = %d \n", result);
+               SECURE_SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt check app agreed : uid(%d) appid(%s)", uid, appid);
        }
 
+       if (NULL == g_conn) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Connection is NOT valid");
+               dbus_message_unref(msg);
+               return STT_ERROR_INVALID_STATE;
+       }
+
+       dbus_message_append_args(msg,
+               DBUS_TYPE_INT32, &uid,
+               DBUS_TYPE_STRING, &appid,
+               DBUS_TYPE_INVALID);
+
+       DBusError err;
+       dbus_error_init(&err);
+
+       DBusMessage* result_msg;
+       int result = STT_ERROR_OPERATION_FAILED;
+       int available = -1;
+
+       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, TAG_STTC, "[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_INT32, &available,
+                       DBUS_TYPE_INVALID);
+
+               if (dbus_error_is_set(&err)) {
+                       SLOG(LOG_ERROR, TAG_STTC, "<<<< Get arguments error (%s)", err.message);
+                       dbus_error_free(&err); 
+                       result = STT_ERROR_OPERATION_FAILED;
+               }
+               dbus_message_unref(result_msg);
+
+               if (0 == result) {
+                       *value = (bool)available;
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt check app agreed : result = %d, available = %d", result, *value);
+               } else {
+                       SLOG(LOG_ERROR, TAG_STTC, "<<<< stt check app agreed : result = %d", result);
+               }
+       } else {
+               SLOG(LOG_ERROR, TAG_STTC, "<<<< Result message is NULL");
+               stt_dbus_reconnect();
+               result = STT_ERROR_TIMED_OUT;
+       }
 
        return result;
 }
@@ -602,10 +796,16 @@ int stt_dbus_request_get_support_langs(int uid, stt_h stt, stt_supported_languag
                STT_METHOD_GET_SUPPORT_LANGS);
 
        if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_STTC, ">>>> stt get supported languages : Fail to make message \n"); 
+               SLOG(LOG_ERROR, TAG_STTC, ">>>> stt get supported languages : Fail to make message"); 
                return STT_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt get supported languages : uid(%d)", uid);
+               SECURE_SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt get supported languages : uid(%d)", uid);
+       }
+
+       if (NULL == g_conn) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Connection is NOT valid");
+               dbus_message_unref(msg);
+               return STT_ERROR_INVALID_STATE;
        }
 
        dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
@@ -618,6 +818,11 @@ int stt_dbus_request_get_support_langs(int uid, stt_h stt, stt_supported_languag
        int result = STT_ERROR_OPERATION_FAILED;
 
        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, TAG_STTC, "[ERROR] Send Error (%s)", err.message);
+               dbus_error_free(&err);
+       }
 
        if (NULL != result_msg) {
                if (dbus_message_iter_init(result_msg, &args)) {
@@ -628,17 +833,17 @@ int stt_dbus_request_get_support_langs(int uid, stt_h stt, stt_supported_languag
                        }
 
                        if (0 == result) {
-                               SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt get support languages : result = %d \n", result);
+                               SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt get support languages : result = %d", result);
 
                                /* Get voice size */
-                               int size ; 
+                               int size = 0
                                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_STTC, "<<<< stt size of language error : size = %d \n", size);
+                                       SLOG(LOG_ERROR, TAG_STTC, "<<<< stt size of language error : size = %d", size);
                                } else {
                                        int i=0;
                                        char* temp_lang;
@@ -653,16 +858,16 @@ int stt_dbus_request_get_support_langs(int uid, stt_h stt, stt_supported_languag
                                        }
                                }
                        } else {
-                               SLOG(LOG_ERROR, TAG_STTC, "<<<< stt get support languages : result = %d \n", result);
+                               SLOG(LOG_ERROR, TAG_STTC, "<<<< stt get support languages : result = %d", result);
                        }
                } 
                dbus_message_unref(result_msg);
        } else {
-               SLOG(LOG_ERROR, TAG_STTC, "<<<< stt get support languages : result message is NULL \n");
+               SLOG(LOG_ERROR, TAG_STTC, "<<<< stt get support languages : result message is NULL");
+               stt_dbus_reconnect();
+               result = STT_ERROR_TIMED_OUT;
        }
 
-       dbus_message_unref(msg);
-
        return result;
 }
 
@@ -673,7 +878,6 @@ int stt_dbus_request_get_default_lang(int uid, char** language)
                return STT_ERROR_INVALID_PARAMETER;
        }
 
-
        DBusMessage* msg;
 
        msg = dbus_message_new_method_call(
@@ -683,10 +887,16 @@ int stt_dbus_request_get_default_lang(int uid, char** language)
                STT_METHOD_GET_CURRENT_LANG);
 
        if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_STTC, ">>>> stt get default language : Fail to make message \n"); 
+               SLOG(LOG_ERROR, TAG_STTC, ">>>> stt get default language : Fail to make message"); 
                return STT_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt get default language  : uid(%d)", uid);
+               SECURE_SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt get default language  : uid(%d)", uid);
+       }
+
+       if (NULL == g_conn) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Connection is NOT valid");
+               dbus_message_unref(msg);
+               return STT_ERROR_INVALID_STATE;
        }
 
        dbus_message_append_args( msg, 
@@ -701,6 +911,11 @@ int stt_dbus_request_get_default_lang(int uid, char** language)
        char* temp_lang = NULL;
 
        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, TAG_STTC, "[ERROR] Send Error (%s)", err.message);
+               dbus_error_free(&err);
+       }
 
        if (NULL != result_msg) {
                dbus_message_get_args(result_msg, &err,
@@ -709,30 +924,105 @@ int stt_dbus_request_get_default_lang(int uid, char** language)
                        DBUS_TYPE_INVALID);
 
                if (dbus_error_is_set(&err)) { 
-                       printf("<<<< Get arguments error (%s)\n", err.message);
+                       SLOG(LOG_ERROR, TAG_STTC, "<<<< Get arguments error (%s)", err.message);
                        dbus_error_free(&err); 
                        result = STT_ERROR_OPERATION_FAILED;
                }
                dbus_message_unref(result_msg);
+
+               if (0 == result) {
+                       *language = strdup(temp_lang);
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt get default language : result = %d, language = %s", result, *language);
+               } else {
+                       SLOG(LOG_ERROR, TAG_STTC, "<<<< stt get default language : result = %d", result);
+               }
        } else {
-               SLOG(LOG_ERROR, TAG_STTC, "<<<< Result message is NULL \n");
+               SLOG(LOG_ERROR, TAG_STTC, "<<<< Result message is NULL");
+               stt_dbus_reconnect();
+               result = STT_ERROR_TIMED_OUT;
+       }
+
+       return result;
+}
+
+int stt_dbus_request_is_recognition_type_supported(int uid, const char* type, bool* support)
+{
+       if (NULL == support || NULL == type) {
+               SLOG(LOG_ERROR, TAG_STTC, "Input parameter is NULL");
+               return STT_ERROR_INVALID_PARAMETER;
        }
 
-       if (0 == result) {
-               *language = strdup(temp_lang);
-               SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt get default language : result = %d, language = %s \n", result, *language);
+       DBusMessage* msg;
+
+       msg = dbus_message_new_method_call(
+                  STT_SERVER_SERVICE_NAME, 
+                  STT_SERVER_SERVICE_OBJECT_PATH, 
+                  STT_SERVER_SERVICE_INTERFACE, 
+                  STT_METHOD_IS_TYPE_SUPPORTED);
+
+       if (NULL == msg) { 
+               SLOG(LOG_ERROR, TAG_STTC, ">>>> stt is partial result supported : Fail to make message"); 
+               return STT_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_ERROR, TAG_STTC, "<<<< stt get default language : result = %d \n", result);
+               SECURE_SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt is recognition type supported : uid(%d) type(%s)", uid, type);
        }
 
+       if (NULL == g_conn) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Connection is NOT valid");
+               dbus_message_unref(msg);
+               return STT_ERROR_INVALID_STATE;
+       }
+
+       dbus_message_append_args( msg, 
+               DBUS_TYPE_INT32, &uid,
+               DBUS_TYPE_STRING, &type,
+               DBUS_TYPE_INVALID);
+
+       DBusError err;
+       dbus_error_init(&err);
+
+       DBusMessage* result_msg;
+       int result = STT_ERROR_OPERATION_FAILED;
+       int result_support = -1;
+
+       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, TAG_STTC, "[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_INT32, &result_support,
+                       DBUS_TYPE_INVALID);
+
+               if (dbus_error_is_set(&err)) { 
+                       SLOG(LOG_ERROR, TAG_STTC, "<<<< Get arguments error (%s)", err.message);
+                       dbus_error_free(&err); 
+                       result = STT_ERROR_OPERATION_FAILED;
+               }
+               dbus_message_unref(result_msg);
+
+               if (0 == result) {
+                       *support = (bool)result_support;
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt is recognition type supported : result = %d, support = %s", result, *support ? "true" : "false");
+               } else {
+                       SLOG(LOG_ERROR, TAG_STTC, "<<<< stt is recognition type supported : result = %d", result);
+               }
+       } else {
+               SLOG(LOG_ERROR, TAG_STTC, "<<<< Result message is NULL");
+               stt_dbus_reconnect();
+               result = STT_ERROR_TIMED_OUT;
+       }
 
        return result;
 }
 
-int stt_dbus_request_is_partial_result_supported(int uid, bool* partial_result)
+int stt_dbus_request_set_start_sound(int uid, const char* file)
 {
-       if (NULL == partial_result) {
+       if (NULL == file) {
                SLOG(LOG_ERROR, TAG_STTC, "Input parameter is NULL");
                return STT_ERROR_INVALID_PARAMETER;
        }
@@ -743,17 +1033,24 @@ int stt_dbus_request_is_partial_result_supported(int uid, bool* partial_result)
                   STT_SERVER_SERVICE_NAME, 
                   STT_SERVER_SERVICE_OBJECT_PATH, 
                   STT_SERVER_SERVICE_INTERFACE, 
-                  STT_METHOD_IS_PARTIAL_SUPPORTED);
+                  STT_METHOD_SET_START_SOUND);
 
        if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_STTC, ">>>> stt is partial result supported : Fail to make message \n"); 
+               SLOG(LOG_ERROR, TAG_STTC, ">>>> stt set start sound : Fail to make message"); 
                return STT_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt is partial result supported : uid(%d)", uid);
+               SECURE_SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt set start sound : uid(%d) file(%s)", uid, file);
+       }
+
+       if (NULL == g_conn) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Connection is NOT valid");
+               dbus_message_unref(msg);
+               return STT_ERROR_INVALID_STATE;
        }
 
        dbus_message_append_args( msg, 
                DBUS_TYPE_INT32, &uid,
+               DBUS_TYPE_STRING, &file,
                DBUS_TYPE_INVALID);
 
        DBusError err;
@@ -761,77 +1058,151 @@ int stt_dbus_request_is_partial_result_supported(int uid, bool* partial_result)
 
        DBusMessage* result_msg;
        int result = STT_ERROR_OPERATION_FAILED;
-       int support = -1;
 
        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, TAG_STTC, "[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_INT32, &support,
                        DBUS_TYPE_INVALID);
 
                if (dbus_error_is_set(&err)) { 
-                       printf("<<<< Get arguments error (%s)\n", err.message);
+                       SLOG(LOG_ERROR, TAG_STTC, "<<<< Get arguments error (%s)", err.message);
                        dbus_error_free(&err); 
                        result = STT_ERROR_OPERATION_FAILED;
                }
                dbus_message_unref(result_msg);
+
+               if (0 == result) {
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt set start sound : result = %d", result);
+               } else {
+                       SLOG(LOG_ERROR, TAG_STTC, "<<<< stt set start sound : result = %d", result);
+               }
        } else {
-               SLOG(LOG_ERROR, TAG_STTC, "<<<< Result message is NULL \n");
+               SLOG(LOG_ERROR, TAG_STTC, "<<<< Result message is NULL");
+               stt_dbus_reconnect();
+               result = STT_ERROR_TIMED_OUT;
        }
 
-       if (0 == result) {
-               *partial_result = (bool)support;
-               SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt is partial result supported : result = %d, support = %s \n", result, *partial_result ? "true" : "false");
+       return result;
+}
+
+int stt_dbus_request_unset_start_sound(int uid)
+{
+       DBusMessage* msg;
+
+       msg = dbus_message_new_method_call(
+                  STT_SERVER_SERVICE_NAME, 
+                  STT_SERVER_SERVICE_OBJECT_PATH, 
+                  STT_SERVER_SERVICE_INTERFACE, 
+                  STT_METHOD_UNSET_START_SOUND);
+
+       if (NULL == msg) { 
+               SLOG(LOG_ERROR, TAG_STTC, ">>>> stt unset start sound : Fail to make message"); 
+               return STT_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_ERROR, TAG_STTC, "<<<< stt is partial result supported : result = %d \n", result);
+               SECURE_SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt unset start sound : uid(%d)", uid);
+       }
+
+       if (NULL == g_conn) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Connection is NOT valid");
+               dbus_message_unref(msg);
+               return STT_ERROR_INVALID_STATE;
        }
 
+       dbus_message_append_args( msg, 
+               DBUS_TYPE_INT32, &uid,
+               DBUS_TYPE_INVALID);
+
+       DBusError err;
+       dbus_error_init(&err);
+
+       DBusMessage* result_msg;
+       int result = STT_ERROR_OPERATION_FAILED;
+
+       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, TAG_STTC, "[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_STTC, "<<<< Get arguments error (%s)", err.message);
+                       dbus_error_free(&err); 
+                       result = STT_ERROR_OPERATION_FAILED;
+               }
+               dbus_message_unref(result_msg);
+
+               if (0 == result) {
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt unset start sound : result = %d", result);
+               } else {
+                       SLOG(LOG_ERROR, TAG_STTC, "<<<< stt unset start sound : result = %d", result);
+               }
+       } else {
+               SLOG(LOG_ERROR, TAG_STTC, "<<<< Result message is NULL");
+               stt_dbus_reconnect();
+               result = STT_ERROR_TIMED_OUT;
+       }
 
        return result;
 }
 
-int stt_dbus_request_start(int uid, const char* lang, const char* type, int profanity, int punctuation, int silence)
+int stt_dbus_request_set_stop_sound(int uid, const char* file)
 {
-       if (NULL == lang || NULL == type) {
+       if (NULL == file) {
                SLOG(LOG_ERROR, TAG_STTC, "Input parameter is NULL");
                return STT_ERROR_INVALID_PARAMETER;
        }
 
        DBusMessage* msg;
 
-       /* create a signal & check for errors */
        msg = dbus_message_new_method_call(
-               STT_SERVER_SERVICE_NAME,
-               STT_SERVER_SERVICE_OBJECT_PATH, 
-               STT_SERVER_SERVICE_INTERFACE,   
-               STT_METHOD_START);              
+                  STT_SERVER_SERVICE_NAME, 
+                  STT_SERVER_SERVICE_OBJECT_PATH, 
+                  STT_SERVER_SERVICE_INTERFACE, 
+                  STT_METHOD_SET_STOP_SOUND);
 
        if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_STTC, ">>>> stt start : Fail to make message \n"); 
+               SLOG(LOG_ERROR, TAG_STTC, ">>>> stt set stop sound : Fail to make message"); 
                return STT_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt start : uid(%d), language(%s), type(%s)", uid, lang, type);
+               SECURE_SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt set stop sound : uid(%d) file(%s)", uid, file);
+       }
+
+       if (NULL == g_conn) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Connection is NOT valid");
+               dbus_message_unref(msg);
+               return STT_ERROR_INVALID_STATE;
        }
 
        dbus_message_append_args( msg, 
-               DBUS_TYPE_INT32, &uid, 
-               DBUS_TYPE_STRING, &lang,   
-               DBUS_TYPE_STRING, &type,
-               DBUS_TYPE_INT32, &profanity,
-               DBUS_TYPE_INT32, &punctuation,
-               DBUS_TYPE_INT32, &silence,
+               DBUS_TYPE_INT32, &uid,
+               DBUS_TYPE_STRING, &file,
                DBUS_TYPE_INVALID);
-       
+
        DBusError err;
        dbus_error_init(&err);
 
        DBusMessage* result_msg;
        int result = STT_ERROR_OPERATION_FAILED;
 
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_start_time, &err);
+       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, TAG_STTC, "[ERROR] Send Error (%s)", err.message);
+               dbus_error_free(&err);
+       }
 
        if (NULL != result_msg) {
                dbus_message_get_args(result_msg, &err,
@@ -839,28 +1210,99 @@ int stt_dbus_request_start(int uid, const char* lang, const char* type, int prof
                        DBUS_TYPE_INVALID);
 
                if (dbus_error_is_set(&err)) { 
-                       printf("<<<< Get arguments error (%s)\n", err.message);
+                       SLOG(LOG_ERROR, TAG_STTC, "<<<< Get arguments error (%s)", err.message);
                        dbus_error_free(&err); 
                        result = STT_ERROR_OPERATION_FAILED;
                }
                dbus_message_unref(result_msg);
+
+               if (0 == result) {
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt set stop sound : result = %d", result);
+               } else {
+                       SLOG(LOG_ERROR, TAG_STTC, "<<<< stt set stop sound : result = %d", result);
+               }
        } else {
-               SLOG(LOG_DEBUG, TAG_STTC, "<<<< Result Message is NULL");
+               SLOG(LOG_ERROR, TAG_STTC, "<<<< Result message is NULL");
+               stt_dbus_reconnect();
+               result = STT_ERROR_TIMED_OUT;
        }
 
-       if (0 == result) {
-               SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt start : result = %d ", result);
+       return result;
+}
+
+int stt_dbus_request_unset_stop_sound(int uid)
+{
+       DBusMessage* msg;
+
+       msg = dbus_message_new_method_call(
+                  STT_SERVER_SERVICE_NAME, 
+                  STT_SERVER_SERVICE_OBJECT_PATH, 
+                  STT_SERVER_SERVICE_INTERFACE, 
+                  STT_METHOD_UNSET_STOP_SOUND);
+
+       if (NULL == msg) { 
+               SLOG(LOG_ERROR, TAG_STTC, ">>>> stt unset stop sound : Fail to make message"); 
+               return STT_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_ERROR, TAG_STTC, "<<<< stt start : result = %d ", result);
+               SECURE_SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt unset stop sound : uid(%d)", uid);
+       }
+
+       if (NULL == g_conn) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Connection is NOT valid");
+               dbus_message_unref(msg);
+               return STT_ERROR_INVALID_STATE;
        }
 
+       dbus_message_append_args( msg, 
+               DBUS_TYPE_INT32, &uid,
+               DBUS_TYPE_INVALID);
+
+       DBusError err;
+       dbus_error_init(&err);
+
+       DBusMessage* result_msg;
+       int result = STT_ERROR_OPERATION_FAILED;
+
+       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, TAG_STTC, "[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_STTC, "<<<< Get arguments error (%s)", err.message);
+                       dbus_error_free(&err); 
+                       result = STT_ERROR_OPERATION_FAILED;
+               }
+               dbus_message_unref(result_msg);
+
+               if (0 == result) {
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt unset stop sound : result = %d", result);
+               } else {
+                       SLOG(LOG_ERROR, TAG_STTC, "<<<< stt unset stop sound : result = %d", result);
+               }
+       } else {
+               SLOG(LOG_ERROR, TAG_STTC, "<<<< Result message is NULL");
+               stt_dbus_reconnect();
+               result = STT_ERROR_TIMED_OUT;
+       }
 
        return result;
 }
 
-int stt_dbus_request_stop(int uid)
+int stt_dbus_request_start(int uid, const char* lang, const char* type, int silence, const char* appid)
 {
+       if (NULL == lang || NULL == type || NULL == appid) {
+               SLOG(LOG_ERROR, TAG_STTC, "Input parameter is NULL");
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+
        DBusMessage* msg;
 
        /* create a signal & check for errors */
@@ -868,19 +1310,29 @@ int stt_dbus_request_stop(int uid)
                STT_SERVER_SERVICE_NAME,
                STT_SERVER_SERVICE_OBJECT_PATH, 
                STT_SERVER_SERVICE_INTERFACE,   
-               STT_METHOD_STOP);
+               STT_METHOD_START);              
 
        if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_STTC, ">>>> stt stop : Fail to make message \n"); 
+               SLOG(LOG_ERROR, TAG_STTC, ">>>> stt start : Fail to make message"); 
                return STT_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt stop : uid(%d)", uid);
+               SECURE_SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt start : uid(%d), language(%s), type(%s)", uid, lang, type);
        }
 
-       dbus_message_append_args(msg, 
+       if (NULL == g_conn) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Connection is NOT valid");
+               dbus_message_unref(msg);
+               return STT_ERROR_INVALID_STATE;
+       }
+
+       dbus_message_append_args( msg, 
                DBUS_TYPE_INT32, &uid, 
+               DBUS_TYPE_STRING, &lang,   
+               DBUS_TYPE_STRING, &type,
+               DBUS_TYPE_INT32, &silence,
+               DBUS_TYPE_STRING, &appid,
                DBUS_TYPE_INVALID);
-
+       
        DBusError err;
        dbus_error_init(&err);
 
@@ -888,6 +1340,11 @@ int stt_dbus_request_stop(int uid)
        int result = STT_ERROR_OPERATION_FAILED;
 
        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, TAG_STTC, "[ERROR] Send Error (%s)", err.message);
+               dbus_error_free(&err);
+       }
 
        if (NULL != result_msg) {
                dbus_message_get_args(result_msg, &err,
@@ -895,42 +1352,48 @@ int stt_dbus_request_stop(int uid)
                        DBUS_TYPE_INVALID);
 
                if (dbus_error_is_set(&err)) { 
-                       printf("<<<< Get arguments error (%s)\n", err.message);
+                       SLOG(LOG_ERROR, TAG_STTC, "<<<< Get arguments error (%s)", err.message);
                        dbus_error_free(&err); 
                        result = STT_ERROR_OPERATION_FAILED;
                }
                dbus_message_unref(result_msg);
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTC, "<<<< Result Message is NULL");
-       }
 
-       if (0 == result) {
-               SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt stop : result = %d ", result);
+               if (0 == result) {
+                       SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt start : result = %d ", result);
+               } else {
+                       SLOG(LOG_ERROR, TAG_STTC, "<<<< stt start : result = %d ", result);
+               }
        } else {
-               SLOG(LOG_ERROR, TAG_STTC, "<<<< stt stop : result = %d ", result);
+               SLOG(LOG_DEBUG, TAG_STTC, "<<<< Result Message is NULL");
+               stt_dbus_reconnect();
+               result = STT_ERROR_TIMED_OUT;
        }
 
-       dbus_message_unref(msg);
-
        return result;
 }
 
-int stt_dbus_request_cancel(int uid)
+int stt_dbus_request_stop(int uid)
 {
        DBusMessage* msg;
 
        /* create a signal & check for errors */
        msg = dbus_message_new_method_call(
                STT_SERVER_SERVICE_NAME,
-               STT_SERVER_SERVICE_OBJECT_PATH, /* object name of the signal */
-               STT_SERVER_SERVICE_INTERFACE,   /* interface name of the signal */
-               STT_METHOD_CANCEL);     /* name of the signal */
+               STT_SERVER_SERVICE_OBJECT_PATH, 
+               STT_SERVER_SERVICE_INTERFACE,   
+               STT_METHOD_STOP);
 
        if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_STTC, ">>>> stt cancel : Fail to make message \n"); 
+               SLOG(LOG_ERROR, TAG_STTC, ">>>> stt stop : Fail to make message"); 
                return STT_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt cancel : uid(%d)", uid);
+               SECURE_SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt stop : uid(%d)", uid);
+       }
+
+       if (NULL == g_conn) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Connection is NOT valid");
+               dbus_message_unref(msg);
+               return STT_ERROR_INVALID_STATE;
        }
 
        dbus_message_append_args(msg, 
@@ -944,6 +1407,11 @@ int stt_dbus_request_cancel(int uid)
        int result = STT_ERROR_OPERATION_FAILED;
 
        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, TAG_STTC, "[ERROR] Send Error (%s)", err.message);
+               dbus_error_free(&err);
+       }
 
        if (NULL != result_msg) {
                dbus_message_get_args(result_msg, &err,
@@ -951,57 +1419,52 @@ int stt_dbus_request_cancel(int uid)
                        DBUS_TYPE_INVALID);
 
                if (dbus_error_is_set(&err)) { 
-                       printf("<<<< Get arguments error (%s)\n", err.message);
+                       SLOG(LOG_ERROR, TAG_STTC, "<<<< Get arguments error (%s)", err.message);
                        dbus_error_free(&err); 
                        result = STT_ERROR_OPERATION_FAILED;
                }
                dbus_message_unref(result_msg);
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTC, "<<<< Result Message is NULL");
-       }
 
-       if (0 == result) {
-               SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt cancel : result = %d ", result);
+               if (0 == result) {
+                       SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt stop : result = %d ", result);
+               } else {
+                       SLOG(LOG_ERROR, TAG_STTC, "<<<< stt stop : result = %d ", result);
+               }
        } else {
-               SLOG(LOG_ERROR, TAG_STTC, "<<<< stt cancel : result = %d ", result);
+               SLOG(LOG_DEBUG, TAG_STTC, "<<<< Result Message is NULL");
+               stt_dbus_reconnect();
+               result = STT_ERROR_TIMED_OUT;
        }
 
-       dbus_message_unref(msg);
-
        return result;
 }
 
-int stt_dbus_request_start_file_recognition(int uid, const char* filepath, const char* lang, const char* type, int profanity, int punctuation)
+int stt_dbus_request_cancel(int uid)
 {
-       if (NULL == filepath || NULL == lang || NULL == type) {
-               SLOG(LOG_ERROR, TAG_STTC, "Input parameter is NULL");
-               return STT_ERROR_INVALID_PARAMETER;
-       }
-
        DBusMessage* msg;
 
        /* create a signal & check for errors */
        msg = dbus_message_new_method_call(
                STT_SERVER_SERVICE_NAME,
-               STT_SERVER_SERVICE_OBJECT_PATH, 
-               STT_SERVER_SERVICE_INTERFACE,   
-               STT_METHOD_START_FILE_RECONITION);              
+               STT_SERVER_SERVICE_OBJECT_PATH, /* object name of the signal */
+               STT_SERVER_SERVICE_INTERFACE,   /* interface name of the signal */
+               STT_METHOD_CANCEL);     /* name of the signal */
 
        if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_STTC, ">>>> stt start file recognition : Fail to make message"); 
+               SLOG(LOG_ERROR, TAG_STTC, ">>>> stt cancel : Fail to make message"); 
                return STT_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt start file recogntion : uid(%d), filepath(%s) language(%s), type(%s)", 
-                       uid, filepath, lang, type);
+               SECURE_SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt cancel : uid(%d)", uid);
        }
 
-       dbus_message_append_args( msg, 
+       if (NULL == g_conn) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Connection is NOT valid");
+               dbus_message_unref(msg);
+               return STT_ERROR_INVALID_STATE;
+       }
+
+       dbus_message_append_args(msg, 
                DBUS_TYPE_INT32, &uid, 
-               DBUS_TYPE_STRING, &filepath,
-               DBUS_TYPE_STRING, &lang,
-               DBUS_TYPE_STRING, &type,
-               DBUS_TYPE_INT32, &profanity,
-               DBUS_TYPE_INT32, &punctuation,
                DBUS_TYPE_INVALID);
 
        DBusError err;
@@ -1010,7 +1473,12 @@ int stt_dbus_request_start_file_recognition(int uid, const char* filepath, const
        DBusMessage* result_msg;
        int result = STT_ERROR_OPERATION_FAILED;
 
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_start_time, &err);
+       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, TAG_STTC, "[ERROR] Send Error (%s)", err.message);
+               dbus_error_free(&err);
+       }
 
        if (NULL != result_msg) {
                dbus_message_get_args(result_msg, &err,
@@ -1018,22 +1486,22 @@ int stt_dbus_request_start_file_recognition(int uid, const char* filepath, const
                        DBUS_TYPE_INVALID);
 
                if (dbus_error_is_set(&err)) { 
-                       printf("<<<< Get arguments error (%s)", err.message);
+                       SLOG(LOG_ERROR, TAG_STTC, "<<<< Get arguments error (%s)", err.message);
                        dbus_error_free(&err); 
                        result = STT_ERROR_OPERATION_FAILED;
                }
                dbus_message_unref(result_msg);
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTC, "<<<< Result Message is NULL");
-       }
 
-       if (0 == result) {
-               SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt start file recognition : result = %d ", result);
+               if (0 == result) {
+                       SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt cancel : result = %d ", result);
+               } else {
+                       SLOG(LOG_ERROR, TAG_STTC, "<<<< stt cancel : result = %d ", result);
+               }
        } else {
-               SLOG(LOG_ERROR, TAG_STTC, "<<<< stt start file recognition : result = %d ", result);
+               SLOG(LOG_DEBUG, TAG_STTC, "<<<< Result Message is NULL");
+               stt_dbus_reconnect();
+               result = STT_ERROR_TIMED_OUT;
        }
 
-       dbus_message_unref(msg);
-
        return result;
-}
\ No newline at end of file
+}
index 4208232..5c2ad00 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
@@ -29,23 +29,35 @@ int stt_dbus_close_connection();
 
 int stt_dbus_request_hello();
 
-int stt_dbus_request_initialize(int uid, bool* silence_supported, bool* profanity_supported, bool* punctuation_supported);
+int stt_dbus_request_initialize(int uid, bool* silence_supported);
 
 int stt_dbus_request_finalize(int uid);
 
+int stt_dbus_request_set_current_engine(int uid, const char* engine_id, bool* silence_supported);
+
+int stt_dbus_request_check_app_agreed(int uid, const char* appid, bool* value);
+
 int stt_dbus_request_get_support_langs(int uid, stt_h stt, stt_supported_language_cb callback, void* user_data);
 
 int stt_dbus_request_get_default_lang(int uid, char** language);
 
-int stt_dbus_request_is_partial_result_supported(int uid, bool* partial_result);
+int stt_dbus_request_is_recognition_type_supported(int uid, const char* type, bool* support);
+
+int stt_dbus_request_set_start_sound(int uid, const char* file);
+
+int stt_dbus_request_unset_start_sound(int uid);
+
+int stt_dbus_request_set_stop_sound(int uid, const char* file);
+
+int stt_dbus_request_unset_stop_sound(int uid);
+
 
-int stt_dbus_request_start(int uid, const char* lang, const char* type, int profanity, int punctuation, int silence);
+int stt_dbus_request_start(int uid, const char* lang, const char* type, int silence, const char* appid);
 
 int stt_dbus_request_stop(int uid);
 
 int stt_dbus_request_cancel(int uid);
 
-int stt_dbus_request_start_file_recognition(int uid, const char* filepath, const char* lang, const char* type, int profanity, int punctuation);
 
 #ifdef __cplusplus
 }
diff --git a/client/stt_file.c b/client/stt_file.c
new file mode 100644 (file)
index 0000000..00fccd2
--- /dev/null
@@ -0,0 +1,1076 @@
+/*
+*  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 <aul.h>
+#include <dlfcn.h>
+#include <dirent.h>
+#include <dlog.h>
+#include <Ecore.h>
+#include <glib.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "stt_config_mgr.h"
+#include "stt_defs.h"
+#include "stt_engine.h"
+#include "stt_file.h"
+#include "stt_file_client.h"
+#include "stt_network.h"
+
+
+typedef struct _sttengine_info {
+       int     engine_id;
+
+       char*   engine_uuid;
+       char*   engine_path;
+       char*   engine_name;
+       char*   engine_setting_path;
+       bool    use_network;
+
+       bool    is_loaded;
+}sttengine_info_s;
+
+static GSList* g_engine_list;
+
+static int     g_engine_id_count = 0;
+
+
+#define STT_FILE_CONFIG_HANDLE 100000
+
+
+const char* stt_tag()
+{
+       return TAG_STTFC;
+}
+
+static const char* __stt_file_get_error_code(stt_file_error_e err)
+{
+       switch(err) {
+       case STT_FILE_ERROR_NONE:                       return "STT_FILE_ERROR_NONE";
+       case STT_FILE_ERROR_OUT_OF_MEMORY:              return "STT_FILE_ERROR_OUT_OF_MEMORY";
+       case STT_FILE_ERROR_IO_ERROR:                   return "STT_FILE_ERROR_IO_ERROR";
+       case STT_FILE_ERROR_INVALID_PARAMETER:          return "STT_FILE_ERROR_INVALID_PARAMETER";
+       case STT_FILE_ERROR_OUT_OF_NETWORK:             return "STT_FILE_ERROR_OUT_OF_NETWORK";
+       case STT_FILE_ERROR_INVALID_STATE:              return "STT_FILE_ERROR_INVALID_STATE";
+       case STT_FILE_ERROR_INVALID_LANGUAGE:           return "STT_FILE_ERROR_INVALID_LANGUAGE";
+       case STT_FILE_ERROR_ENGINE_NOT_FOUND:           return "STT_FILE_ERROR_ENGINE_NOT_FOUND";
+       case STT_FILE_ERROR_OPERATION_FAILED:           return "STT_FILE_ERROR_OPERATION_FAILED";
+       case STT_FILE_ERROR_NOT_SUPPORTED_FEATURE:      return "STT_FILE_ERROR_NOT_SUPPORTED_FEATURE";
+       case STT_FILE_ERROR_NOT_AGREE_SERVICE:          return "STT_FILE_ERROR_NOT_AGREE_SERVICE";
+       default:
+               return "Invalid error code";
+       }
+}
+
+void __stt_file_engine_info_cb(const char* engine_uuid, const char* engine_name, const char* setting_ug_name, 
+                     bool use_network, void* user_data)
+{
+       sttengine_info_s* temp = (sttengine_info_s*)user_data; 
+
+       temp->engine_uuid = g_strdup(engine_uuid);
+       temp->engine_name = g_strdup(engine_name);
+       temp->engine_setting_path = g_strdup(setting_ug_name);
+       temp->use_network = use_network;
+}
+
+static int __stt_file_get_engine_info(const char* filepath, sttengine_info_s** info)
+{
+       if (NULL == filepath || NULL == info) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[Engine Agent ERROR] Invalid Parameter"); 
+               return STT_FILE_ERROR_INVALID_PARAMETER;
+       }
+
+       /* load engine */
+       char *error;
+       void* handle;
+
+       handle = dlopen (filepath, RTLD_LAZY);
+
+       if (!handle) {
+               SECURE_SLOG(LOG_WARN, TAG_STTFC, "[Engine Agent] Invalid engine : %s", filepath); 
+               return -1;
+       }
+
+       /* link engine to daemon */
+       dlsym(handle, "sttp_load_engine");
+       if ((error = dlerror()) != NULL) {
+               SLOG(LOG_WARN, TAG_STTFC, "[Engine Agent] Invalid engine. Fail to open sttp_load_engine : %s", error); 
+               dlclose(handle);
+               return -1;
+       }
+
+       dlsym(handle, "sttp_unload_engine");
+       if ((error = dlerror()) != NULL) {
+               SLOG(LOG_WARN, TAG_STTFC, "[Engine Agent] Invalid engine. Fail to open sttp_unload_engine : %s", error); 
+               dlclose(handle);
+               return -1;
+       }
+
+       int (*get_engine_info)(sttpe_engine_info_cb callback, void* user_data);
+
+       get_engine_info = (int (*)(sttpe_engine_info_cb, void*))dlsym(handle, "sttp_get_engine_info");
+       if ((error = dlerror()) != NULL || NULL == get_engine_info) {
+               SLOG(LOG_WARN, TAG_STTFC, "[Engine Agent WARNING] Invalid engine. Fail to open sttp_get_engine_info : %s", error); 
+               dlclose(handle);
+               return -1;
+       }
+
+       sttengine_info_s* temp;
+       temp = (sttengine_info_s*)calloc(1, sizeof(sttengine_info_s));
+
+       /* get engine info */
+       if (0 != get_engine_info(__stt_file_engine_info_cb, (void*)temp)) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[Engine Agent ERROR] Fail to get engine info from engine"); 
+               dlclose(handle);
+               free(temp);
+               return -1;
+       }
+
+       /* close engine */
+       dlclose(handle);
+
+       temp->engine_id = g_engine_id_count;
+       g_engine_id_count++;
+
+       temp->engine_path = g_strdup(filepath);
+       temp->is_loaded = false;
+
+       SLOG(LOG_DEBUG, TAG_STTFC, "----- Valid Engine");
+       SECURE_SLOG(LOG_DEBUG, TAG_STTFC, "Engine id : %d", temp->engine_id);
+       SECURE_SLOG(LOG_DEBUG, TAG_STTFC, "Engine uuid : %s", temp->engine_uuid);
+       SECURE_SLOG(LOG_DEBUG, TAG_STTFC, "Engine name : %s", temp->engine_name);
+       SECURE_SLOG(LOG_DEBUG, TAG_STTFC, "Engine path : %s", temp->engine_path);
+       SECURE_SLOG(LOG_DEBUG, TAG_STTFC, "Engine setting path : %s", temp->engine_setting_path);
+       SECURE_SLOG(LOG_DEBUG, TAG_STTFC, "Use network : %s", temp->use_network ? "true":"false");
+       SLOG(LOG_DEBUG, TAG_STTFC, "-----");
+       SLOG(LOG_DEBUG, TAG_STTFC, "  ");
+
+       *info = temp;
+
+       return 0;
+}
+
+static bool __stt_file_is_engine(const char* filepath)
+{
+       GSList *iter = NULL;
+       sttengine_info_s *engine = NULL;
+
+       if (0 < g_slist_length(g_engine_list)) {
+               /* Get a first item */
+               iter = g_slist_nth(g_engine_list, 0);
+
+               while (NULL != iter) {
+                       /* Get handle data from list */
+                       engine = iter->data;
+
+                       if (0 == strcmp(engine->engine_path, filepath)) {
+                               return true;
+                       }
+               
+                       iter = g_slist_next(iter);
+               }
+       }
+
+       return false;
+}
+
+void __stt_file_relseae_engine_info()
+{
+       GSList *iter = NULL;
+
+       /* Release engine list */
+       sttengine_info_s *engine = NULL;
+
+       if (0 < g_slist_length(g_engine_list)) {
+               /* Get a first item */
+               iter = g_slist_nth(g_engine_list, 0);
+
+               while (NULL != iter) {
+                       /* Get handle data from list */
+                       engine = iter->data;
+                       g_engine_list = g_slist_remove_link(g_engine_list, iter);
+                       
+                       /* Check engine unload */
+                       if (NULL != engine) {
+                               if (engine->is_loaded) {
+                                       SECURE_SLOG(LOG_DEBUG, TAG_STTFC, "[Engine Agent] Unload engine id(%d)", engine->engine_id);
+
+                                       if (0 != stt_engine_deinitialize(engine->engine_id)) 
+                                               SECURE_SLOG(LOG_WARN, TAG_STTFC, "[Engine Agent] Fail to deinitialize engine id(%d)", engine->engine_id);
+
+                                       if (0 != stt_engine_unload(engine->engine_id))
+                                               SECURE_SLOG(LOG_WARN, TAG_STTFC, "[Engine Agent] Fail to unload engine id(%d)", engine->engine_id);
+
+                                       engine->is_loaded = false;
+                               }
+
+                               if (NULL != engine->engine_uuid)        free(engine->engine_uuid);
+                               if (NULL != engine->engine_path)        free(engine->engine_path);
+                               if (NULL != engine->engine_name)        free(engine->engine_name);
+                               if (NULL != engine->engine_setting_path)free(engine->engine_setting_path);
+
+                               free(engine);
+                       }
+
+                       iter = g_slist_nth(g_engine_list, 0);
+               }
+       }
+}
+
+static sttengine_info_s* __stt_file_get_engine_by_id(int engine_id)
+{
+       GSList *iter = NULL;
+       sttengine_info_s *data = NULL;
+
+       iter = g_slist_nth(g_engine_list, 0);
+
+       while (NULL != iter) {
+
+               data = iter->data;
+
+               if (data->engine_id == engine_id) 
+                       return data;
+
+               iter = g_slist_next(iter);
+       }
+
+       return NULL;
+}
+
+void __stt_file_result_cb(sttp_result_event_e event, const char* type, const char** data, int data_count, 
+                const char* msg, void* time_info, void *user_data)
+{
+       
+       SLOG(LOG_DEBUG, TAG_STTFC, "[STT FILE] Result event(%d) type(%s) msg(%s)", event, type, msg);
+
+       if (NULL != data) {
+               int i = 0;
+               for (i = 0;i < data_count;i++) {
+                       if (NULL != data[i]) {
+                               SLOG(LOG_DEBUG, TAG_STTFC, "[STT FILE] [%d] %s", i, data[i]);
+                       }
+               }
+       }
+
+       stt_file_client_s* client = stt_file_client_get();
+
+       /* check handle */
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Fail to notify error : A handle is not valid");
+               return;
+       }
+
+       if (NULL != time_info) {
+               client->time_info = time_info;
+       }
+
+       if (NULL != client->recognition_result_cb) {
+               stt_file_client_use_callback(client);
+               client->recognition_result_cb(event, data, data_count, msg, client->recognition_result_user_data);
+               stt_file_client_not_use_callback(client);
+               SLOG(LOG_DEBUG, TAG_STTFC, "client recognition result callback called");
+       } else {
+               SLOG(LOG_WARN, TAG_STTFC, "[WARNING] User recognition result callback is NULL");
+       }
+
+       client->time_info = NULL;
+
+       if (STTP_RESULT_EVENT_FINAL_RESULT == event || STTP_RESULT_EVENT_ERROR == event) {
+               SLOG(LOG_DEBUG, TAG_STTFC, "[STT FILE] State change : 'Ready'");
+               
+               client->before_state = client->current_state;
+               client->current_state = STT_FILE_STATE_READY;
+
+               if (NULL != client->state_changed_cb) {
+                       stt_file_client_use_callback(client);
+                       client->state_changed_cb(client->before_state, client->current_state, client->state_changed_user_data); 
+                       stt_file_client_not_use_callback(client);
+                       SLOG(LOG_DEBUG, TAG_STTFC, "State changed callback is called");
+               } else {
+                       SLOG(LOG_WARN, TAG_STTFC, "[WARNING] State changed callback is null");
+               }
+       }
+
+       return;
+}
+
+void __stt_file_silence_cb(sttp_silence_type_e type, void *user_data)
+{
+       SLOG(LOG_WARN, TAG_STTFC, "[WARNING] This callback should NOT be called.");
+       return;
+}
+
+static int __stt_file_load_engine(sttengine_info_s* engine)
+{
+       if (NULL == engine) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[STT FILE ERROR] Input engine is NULL");
+               return STT_FILE_ERROR_INVALID_PARAMETER;
+       }
+
+       if (0 != stt_engine_load(engine->engine_id, engine->engine_path)) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[STT FILE ERROR] Fail to load engine(%s)", engine->engine_path);
+               return STT_FILE_ERROR_OPERATION_FAILED;
+       }
+
+       int ret = stt_engine_initialize(engine->engine_id, __stt_file_result_cb, __stt_file_silence_cb);
+       if (0 != ret) {
+               SECURE_SLOG(LOG_ERROR, TAG_STTFC, "[Engine Agent ERROR] Fail to initialize engine : id(%d) path(%s)", engine->engine_id, engine->engine_path);
+               return STT_FILE_ERROR_OPERATION_FAILED;
+       }
+
+       engine->is_loaded = true;
+
+       SECURE_SLOG(LOG_DEBUG, TAG_STTFC, "[STT FILE Success] Load engine id(%d) path(%s)", engine->engine_id, engine->engine_path);
+
+       return STT_FILE_ERROR_NONE;
+}
+
+int stt_file_initialize()
+{
+       SLOG(LOG_DEBUG, TAG_STTFC, "===== Initialize STT FILE");
+
+       stt_file_client_s* client = stt_file_client_get();
+       if (NULL != client) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[STT FILE ERROR] Already initialized");
+               return STT_FILE_ERROR_INVALID_STATE;
+       }
+
+       /* Get file name from default engine directory */
+       DIR *dp = NULL;
+       int ret = -1;
+       struct dirent entry;
+       struct dirent *dirp = NULL;
+       dp  = opendir(STT_DEFAULT_ENGINE);
+       if (NULL != dp) {
+               do {
+                       ret = readdir_r(dp, &entry, &dirp);
+                       if (0 != ret) {
+                               SLOG(LOG_ERROR, TAG_STTFC, "[File ERROR] Fail to read directory");
+                               break;
+                       }
+
+                       if (NULL != dirp) {
+                               sttengine_info_s* info;
+                               char* filepath;
+                               int filesize;
+
+                               filesize = strlen(STT_DEFAULT_ENGINE) + strlen(dirp->d_name) + 5;
+                               filepath = (char*)calloc(filesize, sizeof(char));
+
+
+                               if (NULL != filepath) {
+                                       snprintf(filepath, filesize, "%s/%s", STT_DEFAULT_ENGINE, dirp->d_name);
+                               } else {
+                                       SLOG(LOG_ERROR, TAG_STTFC, "[Engine Agent ERROR] Memory not enough!!");
+                                       continue;
+                               }
+
+                               if (false == __stt_file_is_engine(filepath)) {
+                                       /* get its and update engine list */
+                                       if (0 == __stt_file_get_engine_info(filepath, &info)) {
+                                               /* add engine info to g_engine_list */
+                                               g_engine_list = g_slist_append(g_engine_list, info);
+                                       }
+                               }
+
+                               if (NULL != filepath)
+                                       free(filepath);
+                       }
+               } while (NULL != dirp);
+
+               closedir(dp);
+       } else {
+               SLOG(LOG_WARN, TAG_STTFC, "[Engine Agent WARNING] Fail to open default directory"); 
+       }
+
+       if (0 >= g_slist_length(g_engine_list)) {
+               SLOG(LOG_WARN, TAG_STTFC, "[STT FILE WARNING] Not found engine");
+               return STT_FILE_ERROR_ENGINE_NOT_FOUND;
+       }
+
+       ret = stt_file_client_new();
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[STT FILE ERROR] Fail to create client : %s", __stt_file_get_error_code(ret));
+               return STT_FILE_ERROR_OPERATION_FAILED;
+       }
+
+       client = stt_file_client_get();
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[STT FILE ERROR] Not initialized");
+               return STT_FILE_ERROR_OPERATION_FAILED;
+       }
+
+       ret = stt_config_mgr_initialize(getpid() + STT_FILE_CONFIG_HANDLE);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[STT FILE ERROR] Fail to init config manager : %s", __stt_file_get_error_code(ret));
+               stt_file_client_destroy();
+               return STT_FILE_ERROR_OPERATION_FAILED;
+       }
+
+       /* Get engine */
+       char* engine_id = NULL;
+       ret = stt_config_mgr_get_engine(&engine_id);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[STT FILE ERROR] Fail to get engine id : %s", __stt_file_get_error_code(ret));
+               stt_file_client_destroy();
+               stt_config_mgr_finalize(getpid() + STT_FILE_CONFIG_HANDLE);
+               __stt_file_relseae_engine_info();
+               return STT_FILE_ERROR_OPERATION_FAILED;
+       }
+       
+       SLOG(LOG_DEBUG, TAG_STTFC, "[STT FILE] Get engine id : %s", engine_id);
+
+       bool is_found = false;
+
+       sttengine_info_s* engine = NULL;
+       GSList *iter = NULL;
+       /* load engine */
+       if (0 < g_slist_length(g_engine_list)) {
+               /* Get a first item */
+               iter = g_slist_nth(g_engine_list, 0);
+
+               while (NULL != iter) {
+                       /* Get handle data from list */
+                       engine = iter->data;
+
+                       if (0 == strcmp(engine->engine_uuid, engine_id)) {
+                               is_found = true;
+                               break;
+                       }
+
+                       iter = g_slist_next(iter);
+               }
+       }
+
+       if (NULL != engine_id)  free(engine_id);
+
+       if (false == is_found) {
+               SLOG(LOG_WARN, TAG_STTFC, "[STT FILE WARNING] Fail to find default engine");
+               iter = g_slist_nth(g_engine_list, 0);
+               engine = iter->data;
+
+               if (NULL == engine) {
+                       SLOG(LOG_ERROR, TAG_STTFC, "[Engine Agent ERROR] Fail to initialize engine");
+                       stt_file_client_destroy();
+                       stt_config_mgr_finalize(getpid() + STT_FILE_CONFIG_HANDLE);
+                       __stt_file_relseae_engine_info();
+                       return STT_FILE_ERROR_OPERATION_FAILED;
+               }
+               SLOG(LOG_WARN, TAG_STTFC, "[STT FILE WARNING] Set default engine (%s)", engine->engine_name);
+       }
+
+       ret = __stt_file_load_engine(engine);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[Engine Agent ERROR] Fail to initialize engine");
+               stt_file_client_destroy();
+               stt_config_mgr_finalize(getpid() + STT_FILE_CONFIG_HANDLE);
+               __stt_file_relseae_engine_info();
+               return STT_FILE_ERROR_OPERATION_FAILED;
+       }
+
+       client->current_engine_id = engine->engine_id;
+
+       stt_network_initialize();
+
+       SECURE_SLOG(LOG_DEBUG, TAG_STTFC, "[STT FILE Success] Initialize : pid(%d)", getpid());
+
+       SLOG(LOG_DEBUG, TAG_STTFC, "=====");
+       SLOG(LOG_DEBUG, TAG_STTFC, " ");
+
+       return STT_FILE_ERROR_NONE;
+}
+
+int stt_file_deinitialize()
+{
+       SLOG(LOG_DEBUG, TAG_STTFC, "===== Deinitialize STT FILE");
+       
+       stt_file_client_s* client = stt_file_client_get();
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[STT FILE ERROR] Not initialized");
+               return STT_FILE_ERROR_INVALID_STATE;
+       }
+
+       /* check used callback */
+       if (0 != stt_file_client_get_use_callback(client)) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[STT FILE ERROR] Client should NOT deinitialize STT FILE in callback function");
+               return STT_FILE_ERROR_OPERATION_FAILED;
+       }
+
+       stt_network_finalize();
+
+       stt_config_mgr_finalize(getpid() + STT_FILE_CONFIG_HANDLE);
+
+       /* check state */
+       switch (client->current_state) {
+       case STT_FILE_STATE_PROCESSING:
+               /* Cancel file recognition */
+               stt_engine_recognize_cancel_file(client->current_engine_id);
+
+       case STT_FILE_STATE_READY:
+               /* Unload engine */
+               __stt_file_relseae_engine_info();
+
+               /* Free resources */
+               stt_file_client_destroy();
+               break;
+
+       case STT_FILE_STATE_NONE:
+               SLOG(LOG_WARN, TAG_STTFC, "[STT FILE WARNING] NOT initialized");
+               return 0;
+       default:
+               break;
+       }
+
+       SLOG(LOG_DEBUG, TAG_STTFC, "=====");
+       SLOG(LOG_DEBUG, TAG_STTFC, " ");
+
+       return STT_FILE_ERROR_NONE;
+}
+
+int stt_file_get_state(stt_file_state_e* state)
+{
+       if (NULL == state) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Input parameter is NULL");
+               return STT_FILE_ERROR_INVALID_PARAMETER;
+       }
+
+       stt_file_client_s* client = stt_file_client_get();
+
+       if (NULL == client) {
+               SLOG(LOG_DEBUG, TAG_STTFC, "[STT FILE] Not initialized");
+               *state = STT_FILE_STATE_NONE;
+               return STT_FILE_ERROR_NONE;
+       }
+
+       *state = client->current_state;
+
+       switch(*state) {
+               case STT_FILE_STATE_NONE:       SLOG(LOG_DEBUG, TAG_STTFC, "Current state is 'NONE'");          break;
+               case STT_FILE_STATE_READY:      SLOG(LOG_DEBUG, TAG_STTFC, "Current state is 'Ready'");         break;
+               case STT_FILE_STATE_PROCESSING: SLOG(LOG_DEBUG, TAG_STTFC, "Current state is 'Processing'");    break;
+               default:                        SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Invalid value");            break;
+       }
+
+       return STT_FILE_ERROR_NONE;
+}
+
+int stt_file_foreach_supported_engines(stt_file_supported_engine_cb callback, void* user_data)
+{
+       SLOG(LOG_DEBUG, TAG_STTFC, "===== Foreach Supported engine");
+
+       if (NULL == callback) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Input parameter is NULL");
+               SLOG(LOG_DEBUG, TAG_STTFC, "=====");
+               SLOG(LOG_DEBUG, TAG_STTFC, " ");
+               return STT_FILE_ERROR_INVALID_PARAMETER;
+       }
+
+       stt_file_client_s* client = stt_file_client_get();
+
+       /* check handle */
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] A handle is not available");
+               SLOG(LOG_DEBUG, TAG_STTFC, "=====");
+               SLOG(LOG_DEBUG, TAG_STTFC, " ");
+               return STT_FILE_ERROR_INVALID_PARAMETER;
+       }
+
+       if (client->current_state != STT_FILE_STATE_READY) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Invalid State: Current state is not 'Ready'");
+               SLOG(LOG_DEBUG, TAG_STTFC, "=====");
+               SLOG(LOG_DEBUG, TAG_STTFC, " ");
+               return STT_FILE_ERROR_INVALID_STATE;
+       }
+
+       GSList *iter = NULL;
+       sttengine_info_s *engine = NULL;
+
+       /* Get a first item */
+       iter = g_slist_nth(g_engine_list, 0);
+
+       while (NULL != iter) {
+               /* Get handle data from list */
+               engine = iter->data;
+
+               if (NULL != engine) {
+                       if (false == callback(engine->engine_uuid, engine->engine_name, user_data)) {
+                               break;
+                       }
+               }
+               iter = g_slist_next(iter);
+       }
+
+       SLOG(LOG_DEBUG, TAG_STTFC, "=====");
+       SLOG(LOG_DEBUG, TAG_STTFC, " ");
+       
+       return STT_FILE_ERROR_NONE;
+}
+
+int stt_file_get_engine(char** engine_id)
+{
+       SLOG(LOG_DEBUG, TAG_STTFC, "===== Get current engine");
+
+       if (NULL == engine_id) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Input parameter is NULL");
+               SLOG(LOG_DEBUG, TAG_STTFC, "=====");
+               SLOG(LOG_DEBUG, TAG_STTFC, " ");
+               return STT_FILE_ERROR_INVALID_PARAMETER;
+       }
+
+       stt_file_client_s* client = stt_file_client_get();
+
+       /* check handle */
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] A handle is not available");
+               SLOG(LOG_DEBUG, TAG_STTFC, "=====");
+               SLOG(LOG_DEBUG, TAG_STTFC, " ");
+               return STT_FILE_ERROR_INVALID_PARAMETER;
+       }
+
+       if (client->current_state != STT_FILE_STATE_READY) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Invalid State: Current state is not 'Ready'");
+               SLOG(LOG_DEBUG, TAG_STTFC, "=====");
+               SLOG(LOG_DEBUG, TAG_STTFC, " ");
+               return STT_FILE_ERROR_INVALID_STATE;
+       }
+
+       sttengine_info_s* engine = NULL;
+       engine = __stt_file_get_engine_by_id(client->current_engine_id);
+       if (NULL == engine) {
+               SECURE_SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Fail to get engine info(%d)", client->current_engine_id);
+               return STT_FILE_ERROR_OPERATION_FAILED;
+       }
+
+       *engine_id = strdup(engine->engine_uuid);
+
+       SLOG(LOG_DEBUG, TAG_STTFC, "=====");
+       SLOG(LOG_DEBUG, TAG_STTFC, " ");
+
+       return STT_FILE_ERROR_NONE;
+}
+
+int stt_file_set_engine(const char* engine_id)
+{      
+       SLOG(LOG_DEBUG, TAG_STTFC, "===== Set current engine");
+
+       if (NULL == engine_id) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Input parameter is NULL");
+               SLOG(LOG_DEBUG, TAG_STTFC, "=====");
+               SLOG(LOG_DEBUG, TAG_STTFC, " ");
+               return STT_FILE_ERROR_INVALID_PARAMETER;
+       }
+
+       stt_file_client_s* client = stt_file_client_get();
+
+       /* check handle */
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] A handle is not available");
+               SLOG(LOG_DEBUG, TAG_STTFC, "=====");
+               SLOG(LOG_DEBUG, TAG_STTFC, " ");
+               return STT_FILE_ERROR_INVALID_PARAMETER;
+       }
+
+       /* check state */
+       if (client->current_state != STT_FILE_STATE_READY) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Invalid State: Current state is not 'Ready'");
+               SLOG(LOG_DEBUG, TAG_STTFC, "=====");
+               SLOG(LOG_DEBUG, TAG_STTFC, " ");
+               return STT_FILE_ERROR_INVALID_STATE;
+       }
+
+       GSList *iter = NULL;
+       sttengine_info_s *engine = NULL;
+
+       int temp_old_engine = -1;
+
+       /* Get a first item */
+       iter = g_slist_nth(g_engine_list, 0);
+
+       while (NULL != iter) {
+               /* Get handle data from list */
+               engine = iter->data;
+
+               if (0 == strcmp(engine->engine_uuid, engine_id)) {
+                       if (client->current_engine_id != engine->engine_id) {
+                               temp_old_engine = client->current_engine_id;
+                       } else {
+                               SLOG(LOG_DEBUG, TAG_STTFC, "Already loaded engine : %s", engine_id);
+                               return 0;
+                       }
+
+                       break;
+               }
+       
+               iter = g_slist_next(iter);
+               engine = NULL;
+       }
+       
+       if (NULL == engine) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[Engine Agent ERROR] Engine id is NOT valid");
+               return STT_FILE_ERROR_INVALID_PARAMETER;
+       }
+
+       int ret = __stt_file_load_engine(engine);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[Engine Agent ERROR] Fail to initialize engine");
+               return STT_FILE_ERROR_OPERATION_FAILED;
+       }
+
+       client->current_engine_id = engine->engine_id;
+
+       if (-1 != temp_old_engine) {
+               stt_engine_deinitialize(temp_old_engine);
+               stt_engine_unload(temp_old_engine);
+       }
+
+       SLOG(LOG_DEBUG, TAG_STTFC, "=====");
+       SLOG(LOG_DEBUG, TAG_STTFC, " ");
+
+       return 0;
+}
+
+bool __stt_config_supported_language_cb(const char* engine_id, const char* language, void* user_data)
+{
+       stt_file_client_s* client = stt_file_client_get();
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[WARNING] A handle is not valid");
+               return false;
+       }
+
+       /* call callback function */
+       if (NULL != client->supported_lang_cb) {
+               return client->supported_lang_cb(language, client->supported_lang_user_data);
+       } else {
+               SLOG(LOG_WARN, TAG_STTFC, "No registered callback function of supported languages");
+       }
+
+       return false;
+}
+
+int stt_file_foreach_supported_languages(stt_file_supported_language_cb callback, void* user_data)
+{
+       SLOG(LOG_DEBUG, TAG_STTFC, "===== Foreach Supported Language");
+
+       if (NULL == callback) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Input parameter is NULL");
+               SLOG(LOG_DEBUG, TAG_STTFC, "=====");
+               SLOG(LOG_DEBUG, TAG_STTFC, " ");
+               return STT_FILE_ERROR_INVALID_PARAMETER;
+       }
+
+       stt_file_client_s* client = stt_file_client_get();
+
+       /* check handle */
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] A handle is not available");
+               SLOG(LOG_DEBUG, TAG_STTFC, "=====");
+               SLOG(LOG_DEBUG, TAG_STTFC, " ");
+               return STT_FILE_ERROR_INVALID_PARAMETER;
+       }
+
+       sttengine_info_s* engine = NULL;
+       engine = __stt_file_get_engine_by_id(client->current_engine_id);
+       if (NULL == engine) {
+               SECURE_SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Fail to get engine info(%d)", client->current_engine_id);
+               return STT_FILE_ERROR_OPERATION_FAILED;
+       }
+
+       client->supported_lang_cb = callback;
+       client->supported_lang_user_data = user_data;
+
+       int ret = -1;
+       ret = stt_config_mgr_get_language_list(engine->engine_uuid, __stt_config_supported_language_cb, NULL);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Fail to get languages");
+       }
+
+       client->supported_lang_cb = NULL;
+       client->supported_lang_user_data = NULL;
+
+       SLOG(LOG_DEBUG, TAG_STTFC, "=====");
+       SLOG(LOG_DEBUG, TAG_STTFC, " ");
+
+       return STT_FILE_ERROR_NONE;
+}
+
+int stt_file_start(const char* language, const char* type, const char* filepath, 
+               stt_file_audio_type_e audio_type, int sample_rate)
+{
+       SLOG(LOG_DEBUG, TAG_STTFC, "===== STT FILE START");
+
+       stt_file_client_s* client = stt_file_client_get();
+
+       /* check handle */
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] A handle is not available");
+               SLOG(LOG_DEBUG, TAG_STTFC, "=====");
+               SLOG(LOG_DEBUG, TAG_STTFC, " ");
+               return STT_FILE_ERROR_INVALID_STATE;
+       }
+
+       /* check state */
+       if (client->current_state != STT_FILE_STATE_READY) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Invalid State: Current state is not READY");
+               SLOG(LOG_DEBUG, TAG_STTFC, "=====");
+               SLOG(LOG_DEBUG, TAG_STTFC, " ");
+               return STT_FILE_ERROR_INVALID_STATE;
+       }
+
+       if (NULL == language || NULL == filepath) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Input parameter is NULL");
+               SLOG(LOG_DEBUG, TAG_STTFC, "=====");
+               SLOG(LOG_DEBUG, TAG_STTFC, " ");
+               return STT_FILE_ERROR_INVALID_PARAMETER;
+       }
+
+       /* check if engine use network */
+       sttengine_info_s* engine = NULL;
+       engine = __stt_file_get_engine_by_id(client->current_engine_id);
+       if (NULL == engine) {
+               SECURE_SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Fail to get engine info(%d)", client->current_engine_id);
+               return STT_FILE_ERROR_OPERATION_FAILED;
+       }
+
+       if (true == engine->use_network) {
+               if (false == stt_network_is_connected()) {
+                       SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Disconnect network. Current engine needs to network connection.");
+                       return STT_FILE_ERROR_OUT_OF_NETWORK;
+               }
+       }
+
+       SLOG(LOG_DEBUG, TAG_STTFC, "[START Info] Engine(%d) Lang(%s) Type(%s) Filepath(%s) Audio(%d) Sample rate(%d)"
+               ,client->current_engine_id, language, type, filepath, audio_type, sample_rate);
+
+       int ret = -1;
+       ret = stt_engine_recognize_start_file(client->current_engine_id, language, type, filepath, audio_type, sample_rate, NULL);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Fail to start file recognition");
+               SLOG(LOG_DEBUG, TAG_STTFC, "=====");
+               SLOG(LOG_DEBUG, TAG_STTFC, " ");
+               return STT_FILE_ERROR_OPERATION_FAILED;
+       }
+
+       client->before_state = client->current_state;
+       client->current_state = STT_FILE_STATE_PROCESSING;
+
+       if (NULL != client->state_changed_cb) {
+               stt_file_client_use_callback(client);
+               client->state_changed_cb(client->before_state, client->current_state, client->state_changed_user_data); 
+               stt_file_client_not_use_callback(client);
+               SLOG(LOG_DEBUG, TAG_STTFC, "State changed callback is called");
+       } else {
+               SLOG(LOG_WARN, TAG_STTFC, "[WARNING] State changed callback is null");
+       }
+
+       SLOG(LOG_DEBUG, TAG_STTFC, "=====");
+       SLOG(LOG_DEBUG, TAG_STTFC, " ");
+
+       return STT_FILE_ERROR_NONE;
+}
+
+int stt_file_cancel()
+{
+       SLOG(LOG_DEBUG, TAG_STTFC, "===== STT FILE CANCEL");
+
+       stt_file_client_s* client = stt_file_client_get();
+
+       /* check handle */
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] A handle is not available");
+               SLOG(LOG_DEBUG, TAG_STTFC, "=====");
+               SLOG(LOG_DEBUG, TAG_STTFC, " ");
+               return STT_FILE_ERROR_INVALID_PARAMETER;
+       }       
+
+       /* check state */
+       if (STT_FILE_STATE_PROCESSING != client->current_state) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Invalid state : Current state is NOT 'Processing'");
+               SLOG(LOG_DEBUG, TAG_STTFC, "=====");
+               SLOG(LOG_DEBUG, TAG_STTFC, " ");
+               return STT_FILE_ERROR_INVALID_STATE;
+       }
+
+       int ret = -1;
+       ret = stt_engine_recognize_cancel_file(client->current_engine_id);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Fail to cancel file recognition");
+               SLOG(LOG_DEBUG, TAG_STTFC, "=====");
+               SLOG(LOG_DEBUG, TAG_STTFC, " ");
+               return STT_FILE_ERROR_OPERATION_FAILED;
+       }
+
+       client->before_state = client->current_state;
+       client->current_state = STT_FILE_STATE_READY;
+
+       if (NULL != client->state_changed_cb) {
+               stt_file_client_use_callback(client);
+               client->state_changed_cb(client->before_state, client->current_state, client->state_changed_user_data); 
+               stt_file_client_not_use_callback(client);
+               SLOG(LOG_DEBUG, TAG_STTFC, "State changed callback is called");
+       } else {
+               SLOG(LOG_WARN, TAG_STTFC, "[WARNING] State changed callback is null");
+       }
+
+       SLOG(LOG_DEBUG, TAG_STTFC, "=====");
+       SLOG(LOG_DEBUG, TAG_STTFC, " ");
+
+       return STT_FILE_ERROR_NONE;
+}
+
+bool __stt_file_result_time_cb(int index, sttp_result_time_event_e event, const char* text, long start_time, long end_time, void* user_data) 
+{
+       SLOG(LOG_DEBUG, TAG_STTFC, "(%d) event(%d) text(%s) start(%ld) end(%ld)",
+                       index, event, text, start_time, end_time);
+
+       stt_file_client_s* client = stt_file_client_get();
+
+       /* check handle */
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Fail to notify error : A handle is not valid");
+               return EINA_FALSE;
+       }
+
+       if (NULL != client->result_time_cb) {
+               client->result_time_cb(index, (stt_file_result_time_event_e)event, 
+                       text, start_time, end_time, client->result_time_user_data);
+       } else {
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Callback is NULL");
+               return false;
+       }
+
+       return true;
+}
+
+int stt_file_foreach_detailed_result(stt_file_result_time_cb callback, void* user_data)
+{
+       SLOG(LOG_DEBUG, TAG_STTFC, "===== STT FILE FOREACH DETAILED RESULT");
+
+       if (NULL == callback) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Input parameter is NULL");
+               return STT_FILE_ERROR_INVALID_PARAMETER;
+       }
+
+       stt_file_client_s* client = stt_file_client_get();
+
+       /* check handle */
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Fail : A handle is not valid");
+               return STT_FILE_ERROR_INVALID_PARAMETER;
+       }
+
+       client->result_time_cb = callback;
+       client->result_time_user_data = user_data;
+
+       stt_engine_foreach_result_time(client->current_engine_id, client->time_info, __stt_file_result_time_cb, NULL);
+
+       client->result_time_cb = NULL;
+       client->result_time_user_data = NULL;
+
+       SLOG(LOG_DEBUG, TAG_STTFC, "=====");
+       SLOG(LOG_DEBUG, TAG_STTFC, " ");
+
+       return STT_FILE_ERROR_NONE;
+}
+
+int stt_file_set_recognition_result_cb(stt_file_recognition_result_cb callback, void* user_data)
+{
+       if (NULL == callback)
+               return STT_FILE_ERROR_INVALID_PARAMETER;
+
+       stt_file_client_s* client = stt_file_client_get();
+
+       /* check handle */
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] A handle is not available");
+               return STT_FILE_ERROR_INVALID_PARAMETER;
+       }
+
+       if (STT_FILE_STATE_READY != client->current_state) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Current state is not 'ready'");
+               return STT_FILE_ERROR_INVALID_STATE;
+       }
+
+       client->recognition_result_cb = callback;
+       client->recognition_result_user_data = user_data;
+
+       return 0;
+}
+
+int stt_file_unset_recognition_result_cb()
+{
+       stt_file_client_s* client = stt_file_client_get();
+
+       /* check handle */
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] A handle is not available");
+               return STT_FILE_ERROR_INVALID_PARAMETER;
+       }
+
+       if (STT_FILE_STATE_READY != client->current_state) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Current state is not 'ready'");
+               return STT_FILE_ERROR_INVALID_STATE;
+       }
+
+       client->recognition_result_cb = NULL;
+       client->recognition_result_user_data = NULL;
+
+       return 0;
+}
+
+int stt_file_set_state_changed_cb(stt_file_state_changed_cb callback, void* user_data)
+{
+       if (NULL == callback)
+               return STT_FILE_ERROR_INVALID_PARAMETER;
+
+       stt_file_client_s* client = stt_file_client_get();
+
+       /* check handle */
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] A handle is not available");
+               return STT_FILE_ERROR_INVALID_PARAMETER;
+       }
+
+       if (STT_FILE_STATE_READY != client->current_state) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Current state is not 'ready'");
+               return STT_FILE_ERROR_INVALID_STATE;
+       }
+
+       client->state_changed_cb = callback;
+       client->state_changed_user_data = user_data;
+
+       return 0;
+}
+
+int stt_file_unset_state_changed_cb()
+{
+       stt_file_client_s* client = stt_file_client_get();
+
+       /* check handle */
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] A handle is not available");
+               return STT_FILE_ERROR_INVALID_PARAMETER;
+       }
+
+       if (STT_FILE_STATE_READY != client->current_state) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Current state is not 'ready'");
+               return STT_FILE_ERROR_INVALID_STATE;
+       }
+
+       client->state_changed_cb = NULL;
+       client->state_changed_user_data = NULL;
+
+       return 0;
+}
diff --git a/client/stt_file_client.c b/client/stt_file_client.c
new file mode 100644 (file)
index 0000000..893c920
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+*  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 <stdlib.h>
+#include <unistd.h>
+
+#include "stt_file_client.h"
+
+static stt_file_client_s* g_client_info = NULL;
+
+int stt_file_client_new()
+{
+       if (NULL != g_client_info) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Already allocated client info");
+               return STT_FILE_ERROR_INVALID_STATE;
+       }
+
+       g_client_info = (stt_file_client_s*)calloc(1, sizeof(stt_file_client_s));
+
+       /* initialize client data */
+       g_client_info->recognition_result_cb = NULL;
+       g_client_info->recognition_result_user_data = NULL;
+
+       g_client_info->result_time_cb = NULL;
+       g_client_info->result_time_user_data = NULL;
+
+       g_client_info->state_changed_cb = NULL;
+       g_client_info->state_changed_user_data = NULL;
+
+       g_client_info->supported_lang_cb = NULL;
+       g_client_info->supported_lang_user_data = NULL;
+
+       g_client_info->current_engine_id = -1;
+
+       g_client_info->time_info = NULL;
+       
+       g_client_info->before_state = STT_FILE_STATE_READY;
+       g_client_info->current_state = STT_FILE_STATE_READY;
+
+       g_client_info->cb_ref_count = 0;
+
+       return 0;       
+}
+
+int stt_file_client_destroy()
+{
+       if (NULL == g_client_info) {
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Client info is NULL");
+               return STT_FILE_ERROR_INVALID_STATE;
+       } else {
+               while (0 != g_client_info->cb_ref_count) {
+                       /* wait for release callback function */
+               }
+               
+               free(g_client_info);
+
+               g_client_info = NULL;
+       }
+
+       return 0;
+}
+
+stt_file_client_s* stt_file_client_get()
+{
+       return g_client_info;
+}
+
+int stt_file_client_use_callback(stt_file_client_s* client)
+{
+       client->cb_ref_count++;
+       return 0;
+}
+
+int stt_file_client_not_use_callback(stt_file_client_s* client)
+{
+       client->cb_ref_count--;
+       return 0;
+}
+
+int stt_file_client_get_use_callback(stt_file_client_s* client)
+{
+       return client->cb_ref_count;
+}
diff --git a/client/stt_file_client.h b/client/stt_file_client.h
new file mode 100644 (file)
index 0000000..5db6fed
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+*  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 __STT_FILE_CLIENT_H_
+#define __STT_FILE_CLIENT_H_
+
+
+#include "stt_file.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define TAG_STTFC "sttfile"
+
+typedef struct {
+       /* callback functions */
+       stt_file_recognition_result_cb  recognition_result_cb;
+       void*                           recognition_result_user_data;
+
+       stt_file_result_time_cb         result_time_cb;
+       void*                           result_time_user_data;
+
+       stt_file_state_changed_cb       state_changed_cb;
+       void*                           state_changed_user_data;
+
+       stt_file_supported_language_cb  supported_lang_cb;
+       void*                           supported_lang_user_data;
+
+       /* current engine */
+       int     current_engine_id;
+
+       /* state */
+       stt_file_state_e        before_state;
+       stt_file_state_e        current_state;
+
+       /* mutex */
+       int     cb_ref_count;
+
+       /* result data */
+       void*   time_info;
+       
+       /* error data */
+       int     reason;
+}stt_file_client_s;
+
+
+int stt_file_client_new();
+
+int stt_file_client_destroy();
+
+stt_file_client_s* stt_file_client_get();
+
+int stt_file_client_use_callback(stt_file_client_s* client);
+
+int stt_file_client_not_use_callback(stt_file_client_s* client);
+
+int stt_file_client_get_use_callback(stt_file_client_s* client);
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STT_FILE_CLIENT_H_ */
index 57fd273..b10e429 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
 #ifndef __STT_MAIN_H_
 #define __STT_MAIN_H_
 
+#include <dbus/dbus.h>
+#include <dlog.h>
+#include <Ecore.h>
+#include <glib.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdbool.h>
 #include <string.h>
 #include <unistd.h>
-#include <glib.h>
-#include <dbus/dbus.h>
-#include <dlog.h>
 
 #include "stt_defs.h"
 
@@ -39,6 +40,15 @@ struct stt_s {
        int handle;
 };
 
+typedef enum {
+       STT_DAEMON_NORMAL               = 0,
+       STT_DAEMON_ON_TERMINATING       = -1
+} stt_daemon_status_e;
+
+typedef enum {
+       STT_RESULT_STATE_DONE           = 0,                    /**< Sync state change */
+       STT_RESULT_STATE_NOT_DONE       = 1                     /**< Async state change */
+} stt_result_state_e;
 
 #ifdef __cplusplus
 }
index f6347b3..15452e9 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/types.h>
+#include <libxml/parser.h>
 #include <sys/stat.h>
-#include <dirent.h>
+#include <sys/types.h>
+#include <sys/wait.h>
 
+#include "stt_config_mgr.h"
 #include "stt_main.h"
 #include "stt_setting.h"
-#include "stt_setting_dbus.h"
-
-
-static int __check_setting_stt_daemon();
 
-static bool g_is_daemon_started = false;
-
-static Ecore_Timer* g_setting_connect_timer = NULL;
 
 static stt_setting_state_e g_state = STT_SETTING_STATE_NONE;
 
-static stt_setting_initialized_cb g_initialized_cb;
-
+static stt_setting_supported_engine_cb g_engine_cb;
 static void* g_user_data;
 
-static int g_reason;
+static stt_setting_config_changed_cb g_config_changed_cb;
+static void* g_config_changed_user_data;
 
-/* API Implementation */
-static Eina_Bool __stt_setting_initialized(void *data)
-{
-       g_initialized_cb(g_state, g_reason, g_user_data);
+static stt_setting_engine_changed_cb g_engine_changed_cb;
+static void* g_engine_changed_user_data;
 
-       return EINA_FALSE;
+const char* stt_tag()
+{
+       return "sttc";
 }
 
-static Eina_Bool __stt_setting_connect_daemon(void *data)
+void __config_engine_changed_cb(const char* engine_id, const char* setting, const char* language, bool support_silence, void* user_data)
 {
-       /* Send hello */
-       if (0 != stt_setting_dbus_request_hello()) {
-               if (false == g_is_daemon_started) {
-                       g_is_daemon_started = true;
-                       __check_setting_stt_daemon();
-               }
-               return EINA_TRUE;
-       }
-
-       SLOG(LOG_DEBUG, TAG_STTC, "===== Connect daemon");
+       if (NULL != engine_id)  SECURE_SLOG(LOG_DEBUG, TAG_STTC, "Engine id(%s)", engine_id);
+       if (NULL != setting)    SECURE_SLOG(LOG_DEBUG, TAG_STTC, "Engine setting(%s)", setting);
+       if (NULL != language)   SECURE_SLOG(LOG_DEBUG, TAG_STTC, "Language(%s)", language);
+       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "Silence(%s)", support_silence ? "on" : "off");
 
-       /* do request initialize */
-       int ret = -1;
-
-       ret = stt_setting_dbus_request_initialize();
-
-       if (STT_SETTING_ERROR_ENGINE_NOT_FOUND == ret) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Engine not found");
-       } else if (STT_SETTING_ERROR_NONE != ret) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to connection : %d", ret);
-       } else {
-               /* success to connect stt-daemon */
-               g_state = STT_SETTING_STATE_READY;
-       }
-
-       g_reason = ret;
+       if (NULL != g_config_changed_cb)
+               g_engine_changed_cb(g_config_changed_user_data);
+}
 
-       ecore_timer_add(0, __stt_setting_initialized, NULL);
+void __config_lang_changed_cb(const char* before_language, const char* current_language, void* user_data)
+{
+       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "Lang changed : lang(%s)", current_language);
 
-       g_setting_connect_timer = NULL;
+       if (NULL != g_config_changed_cb)
+               g_config_changed_cb(g_config_changed_user_data);
+}
 
-       SLOG(LOG_DEBUG, TAG_STTC, "=====");
-       SLOG(LOG_DEBUG, TAG_STTC, " ");
+void __config_bool_changed_cb(stt_config_type_e type, bool bool_value, void* user_data)
+{
+       SECURE_SLOG(LOG_DEBUG, TAG_STTC, " type(%d) bool(%s)", type, bool_value ? "on" : "off");
 
-       return EINA_FALSE;
+       if (NULL != g_config_changed_cb)
+               g_config_changed_cb(g_config_changed_user_data);
 }
 
-int stt_setting_initialize(stt_setting_initialized_cb callback, void* user_data)
+int stt_setting_initialize(void)
 {
        SLOG(LOG_DEBUG, TAG_STTC, "===== Initialize STT Setting");
 
        if (STT_SETTING_STATE_READY == g_state) {
-               SLOG(LOG_WARN, TAG_STTC, "[WARNING] STT Setting has already been initialized. \n");
+               SLOG(LOG_WARN, TAG_STTC, "[WARNING] STT Setting has already been initialized. ");
                SLOG(LOG_DEBUG, TAG_STTC, "=====");
                SLOG(LOG_DEBUG, TAG_STTC, " ");
                return STT_SETTING_ERROR_NONE;
        }
 
-       if( 0 != stt_setting_dbus_open_connection() ) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to open connection\n ");
-               SLOG(LOG_DEBUG, TAG_STTC, "=====");
-               SLOG(LOG_DEBUG, TAG_STTC, " ");
+       int ret = stt_config_mgr_initialize(getpid());
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to initialize config manager : %d", ret);
                return STT_SETTING_ERROR_OPERATION_FAILED;
        }
 
-       g_initialized_cb = callback;
-       g_user_data = user_data;
+       ret = stt_config_mgr_set_callback(getpid(), __config_engine_changed_cb, __config_lang_changed_cb, __config_bool_changed_cb, NULL);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to set config changed : %d", ret);
+               return STT_SETTING_ERROR_OPERATION_FAILED;
+       }
+
+       g_state = STT_SETTING_STATE_READY;
+
+       g_engine_changed_cb = NULL;
+       g_engine_changed_user_data = NULL;
 
-       g_setting_connect_timer = ecore_timer_add(0, __stt_setting_connect_daemon, NULL);
+       g_config_changed_cb = NULL;
+       g_config_changed_user_data = NULL;
 
        SLOG(LOG_DEBUG, TAG_STTC, "=====");
        SLOG(LOG_DEBUG, TAG_STTC, " ");
@@ -117,27 +107,7 @@ int stt_setting_finalize ()
 {
        SLOG(LOG_DEBUG, TAG_STTC, "===== Finalize STT Setting");
        
-       int ret = 0;
-
-       if (STT_SETTING_STATE_READY == g_state) {
-               ret = stt_setting_dbus_request_finalilze();
-               if (0 != ret) {
-                       SLOG(LOG_ERROR, TAG_STTC, "Fail : finialize(%d)", ret);
-               }
-       }
-
-       if (NULL != g_setting_connect_timer) {
-               SLOG(LOG_DEBUG, TAG_STTC, "Setting Connect Timer is deleted");
-               ecore_timer_del(g_setting_connect_timer);
-       }
-
-       g_is_daemon_started = false;
-
-       if (0 != stt_setting_dbus_close_connection()) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to close connection");
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Finalize");
-       }
+       stt_config_mgr_finalize(getpid());
 
        g_state = STT_SETTING_STATE_NONE;
 
@@ -147,6 +117,11 @@ int stt_setting_finalize ()
        return STT_SETTING_ERROR_NONE;
 }
 
+bool __config_mgr_get_engine_list(const char* engine_id, const char* engine_name, const char* setting, bool support_silence, void* user_data)
+{
+       return g_engine_cb(engine_id, engine_name, setting, g_user_data);
+}
+
 int stt_setting_foreach_supported_engines(stt_setting_supported_engine_cb callback, void* user_data)
 {
        SLOG(LOG_DEBUG, TAG_STTC, "===== Foreach supported engines");
@@ -165,13 +140,16 @@ int stt_setting_foreach_supported_engines(stt_setting_supported_engine_cb callba
                return STT_SETTING_ERROR_INVALID_PARAMETER;
        }
 
-       int ret = stt_setting_dbus_request_get_engine_list(callback, user_data);
+       g_engine_cb = callback;
+       g_user_data = user_data;
+
+       int ret = stt_config_mgr_get_engine_list(__config_mgr_get_engine_list, NULL);
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Result : %d", ret);
        } else {
                SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Foreach supported engines");
        }
-       
+
        SLOG(LOG_DEBUG, TAG_STTC, "=====");
        SLOG(LOG_DEBUG, TAG_STTC, " ");
 
@@ -196,7 +174,7 @@ int stt_setting_get_engine(char** engine_id)
                return STT_SETTING_ERROR_INVALID_PARAMETER;
        }
 
-       int ret = stt_setting_dbus_request_get_engine(engine_id);
+       int ret = stt_config_mgr_get_engine(engine_id);
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Result : %d", ret);
        } else {
@@ -227,7 +205,9 @@ int stt_setting_set_engine(const char* engine_id)
                return STT_SETTING_ERROR_INVALID_PARAMETER;
        }
 
-       int ret = stt_setting_dbus_request_set_engine(engine_id);
+       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "New engine id : %s", engine_id);
+
+       int ret = stt_config_mgr_set_engine(engine_id);
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Result : %d", ret);
        } else {
@@ -258,7 +238,17 @@ int stt_setting_foreach_supported_languages(stt_setting_supported_language_cb ca
                return STT_SETTING_ERROR_INVALID_PARAMETER;
        }
 
-       int ret = stt_setting_dbus_request_get_language_list(callback, user_data);
+       char* current_engine;
+       int ret = stt_config_mgr_get_engine(&current_engine);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to get current engine : %d", ret);
+               return -1;
+       } 
+
+       ret = stt_config_mgr_get_language_list(current_engine, (stt_config_supported_langauge_cb)callback, user_data);
+
+       if (NULL != current_engine)
+               free(current_engine);
 
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Result : %d", ret);
@@ -290,11 +280,11 @@ int stt_setting_get_default_language(char** language)
                return STT_SETTING_ERROR_INVALID_PARAMETER;
        }
 
-       int ret = stt_setting_dbus_request_get_default_language(language);
+       int ret = stt_config_mgr_get_default_language(language);
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Result : %d", ret);
        } else {
-               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Foreach supported voices");
+               SECURE_SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Default language : %s", *language);
        }
 
        SLOG(LOG_DEBUG, TAG_STTC, "=====");
@@ -321,11 +311,11 @@ int stt_setting_set_default_language(const char* language)
                return STT_SETTING_ERROR_INVALID_PARAMETER;
        }
 
-       int ret = stt_setting_dbus_request_set_default_language(language);
+       int ret = stt_config_mgr_set_default_language(language);
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Result : %d", ret);
        } else {
-               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Set default voice");
+               SECURE_SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Set default language : %s", language);
        }
 
        SLOG(LOG_DEBUG, TAG_STTC, "=====");
@@ -334,11 +324,9 @@ int stt_setting_set_default_language(const char* language)
        return ret;
 }
 
-int stt_setting_get_profanity_filter(bool* value)
+int stt_setting_set_auto_language(bool value)
 {
-       SLOG(LOG_DEBUG, TAG_STTC, "===== Get profanity filter");
-
-       int ret = 0;
+       SLOG(LOG_DEBUG, TAG_STTC, "===== Set auto voice");
 
        if (STT_SETTING_STATE_NONE == g_state) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Not initialized");
@@ -347,44 +335,18 @@ int stt_setting_get_profanity_filter(bool* value)
                return STT_SETTING_ERROR_INVALID_STATE;
        }
 
-       if (NULL == value) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
+       if (value != true && value != false) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid value");
                SLOG(LOG_DEBUG, TAG_STTC, "=====");
                SLOG(LOG_DEBUG, TAG_STTC, " ");
                return STT_SETTING_ERROR_INVALID_PARAMETER;
        }
 
-       ret = stt_setting_dbus_request_get_profanity_filter(value);
+       int ret = stt_config_mgr_set_auto_language(value);
        if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Result (%d)", ret);    
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Get profanity filter(%s)", *value ? "true":"false");
-       }
-       
-       SLOG(LOG_DEBUG, TAG_STTC, "=====");
-       SLOG(LOG_DEBUG, TAG_STTC, " ");
-
-       return ret;
-}
-
-int stt_setting_set_profanity_filter(const bool value)
-{
-       SLOG(LOG_DEBUG, TAG_STTC, "===== Set profanity filter");
-
-       int ret = 0;
-
-       if (STT_SETTING_STATE_NONE == g_state) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] not initialized");
-               SLOG(LOG_DEBUG, TAG_STTC, "=====");
-               SLOG(LOG_DEBUG, TAG_STTC, " ");
-               return STT_SETTING_ERROR_INVALID_STATE;
-       }
-
-       ret = stt_setting_dbus_request_set_profanity_filter(value);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Result (%d)", ret);    
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Result : %d", ret);
        } else {
-               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Set profanity filter(%s)", value ? "true":"false");
+               SECURE_SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Set auto language (%s)", value ? "on" : "off");
        }
 
        SLOG(LOG_DEBUG, TAG_STTC, "=====");
@@ -393,71 +355,42 @@ int stt_setting_set_profanity_filter(const bool value)
        return ret;
 }
 
-int stt_setting_get_punctuation_override(bool* value)
+int stt_setting_get_auto_language(bool* value)
 {
-       SLOG(LOG_DEBUG, TAG_STTC, "===== Get punctuation override");
-
-       int ret = 0;
+       SLOG(LOG_DEBUG, TAG_STTC, "===== Get auto language");
 
        if (STT_SETTING_STATE_NONE == g_state) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] not initialized");
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Not initialized");
                SLOG(LOG_DEBUG, TAG_STTC, "=====");
                SLOG(LOG_DEBUG, TAG_STTC, " ");
                return STT_SETTING_ERROR_INVALID_STATE;
        }
 
        if (NULL == value) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] param is NULL");
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Param is NULL");
                SLOG(LOG_DEBUG, TAG_STTC, "=====");
                SLOG(LOG_DEBUG, TAG_STTC, " ");
                return STT_SETTING_ERROR_INVALID_PARAMETER;
        }
 
-       ret = stt_setting_dbus_request_get_punctuation_override(value);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Result (%d)", ret); 
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Get punctuation override(%s)", *value ? "true":"false");
-       }
-
-       SLOG(LOG_DEBUG, TAG_STTC, "=====");
-       SLOG(LOG_DEBUG, TAG_STTC, " ");
-
-       return ret;
-}
-
-int stt_setting_set_punctuation_override(bool value)
-{
-       SLOG(LOG_DEBUG, TAG_STTC, "===== Set punctuation override");
-
-       int ret = 0;
-
-       if (STT_SETTING_STATE_NONE == g_state) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] not initialized");
-               SLOG(LOG_DEBUG, TAG_STTC, "=====");
-               SLOG(LOG_DEBUG, TAG_STTC, " ");
-               return STT_SETTING_ERROR_INVALID_STATE;
-       }
-
-       ret = stt_setting_dbus_request_set_punctuation_override(value);
+       int ret = stt_config_mgr_get_auto_language(value);
        if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Result (%d)", ret);    
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Result : %d", ret);
        } else {
-               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Set punctuation override(%s)", value ? "true":"false");
+               /* Copy value */
+               SECURE_SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Get auto language (%s)", *value ? "true":"false");
        }
 
        SLOG(LOG_DEBUG, TAG_STTC, "=====");
        SLOG(LOG_DEBUG, TAG_STTC, " ");
 
-       return ret;
+       return 0;
 }
 
 int stt_setting_get_silence_detection(bool* value)
 {
        SLOG(LOG_DEBUG, TAG_STTC, "===== Get silence detection");
 
-       int ret = 0;
-
        if (STT_SETTING_STATE_NONE == g_state) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] not initialized");
                SLOG(LOG_DEBUG, TAG_STTC, "=====");
@@ -472,11 +405,11 @@ int stt_setting_get_silence_detection(bool* value)
                return STT_SETTING_ERROR_INVALID_PARAMETER;
        }
 
-       ret = stt_setting_dbus_request_get_silence_detection(value);
+       int ret = stt_config_mgr_get_silence_detection(value);
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Result (%d)", ret);    
        } else {
-               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Get silence detection(%s)", *value ? "true":"false");
+               SECURE_SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Get silence detection(%s)", *value ? "true":"false");
        }
 
        SLOG(LOG_DEBUG, TAG_STTC, "=====");
@@ -489,8 +422,6 @@ int stt_setting_set_silence_detection(bool value)
 {
        SLOG(LOG_DEBUG, TAG_STTC, "===== Set silence detection");
 
-       int ret = 0;
-
        if (STT_SETTING_STATE_NONE == g_state) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] not initialized");
                SLOG(LOG_DEBUG, TAG_STTC, "=====");
@@ -498,11 +429,11 @@ int stt_setting_set_silence_detection(bool value)
                return STT_SETTING_ERROR_INVALID_STATE;
        }
 
-       ret = stt_setting_dbus_request_set_silence_detection(value);
+       int ret = stt_config_mgr_set_silence_detection(value);
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Result (%d)", ret);    
        } else {
-               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Set silence detection(%s)", value ? "true":"false");
+               SECURE_SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Set silence detection(%s)", value ? "true":"false");
        }
 
        SLOG(LOG_DEBUG, TAG_STTC, "=====");
@@ -511,159 +442,44 @@ int stt_setting_set_silence_detection(bool value)
        return ret;
 }
 
-int stt_setting_foreach_engine_settings(stt_setting_engine_setting_cb callback, void* user_data)
+int stt_setting_set_engine_changed_cb(stt_setting_engine_changed_cb callback, void* user_data)
 {
-       SLOG(LOG_DEBUG, TAG_STTC, "===== Foreach engine setting");
-
-       int ret = 0;
-
-       if (STT_SETTING_STATE_NONE == g_state) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] not initialized");
-               SLOG(LOG_DEBUG, TAG_STTC, "=====");
-               SLOG(LOG_DEBUG, TAG_STTC, " ");
-               return STT_SETTING_ERROR_INVALID_STATE;
-       }
-
        if (NULL == callback) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] parameter is NULL");
-               SLOG(LOG_DEBUG, TAG_STTC, "=====");
-               SLOG(LOG_DEBUG, TAG_STTC, " ");
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input param is NULL");
                return STT_SETTING_ERROR_INVALID_PARAMETER;
        }
 
-       ret = stt_setting_dbus_request_get_engine_setting(callback, user_data);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Result (%d)", ret);    
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Foreach engine setting");
-       }
-
-       SLOG(LOG_DEBUG, TAG_STTC, "=====");
-       SLOG(LOG_DEBUG, TAG_STTC, " ");
-
-       return ret;
-}
-
-int stt_setting_set_engine_setting(const char* key, const char* value)
-{
-       SLOG(LOG_DEBUG, TAG_STTC, "===== Set engine setting");
-
-       int ret = 0;
+       g_engine_changed_cb = callback;
+       g_engine_changed_user_data = user_data;
 
-       if (STT_SETTING_STATE_NONE == g_state) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] not initialized");
-               return STT_SETTING_ERROR_INVALID_STATE;
-       }
-
-       if (NULL == key || NULL == value) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] parameter is NULL");
-               return STT_SETTING_ERROR_INVALID_PARAMETER;
-       }
-
-       ret = stt_setting_dbus_request_set_engine_setting(key, value);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR]  Result (%d)", ret);    
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Set engine setting(%s)", *value ? "true":"false");
-       }
-
-       SLOG(LOG_DEBUG, TAG_STTC, "=====");
-       SLOG(LOG_DEBUG, TAG_STTC, " ");
-
-       return ret;
+       return STT_SETTING_ERROR_NONE;
 }
 
-int __setting_get_cmd_line(char *file, char *buf) 
+int stt_setting_unset_engine_changed_cb()
 {
-       FILE *fp = NULL;
-       int i;
+       g_engine_changed_cb = NULL;
+       g_engine_changed_user_data = NULL;
 
-       fp = fopen(file, "r");
-       if (fp == NULL) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Get command line");
-               return -1;
-       }
-
-       memset(buf, 0, 256);
-       fgets(buf, 256, fp);
-       fclose(fp);
-
-       return 0;
+       return STT_SETTING_ERROR_NONE;
 }
 
-static bool __stt_setting_is_alive()
+int stt_setting_set_config_changed_cb(stt_setting_config_changed_cb callback, void* user_data)
 {
-       DIR *dir;
-       struct dirent *entry;
-       struct stat filestat;
-       
-       int pid;
-       char cmdLine[256];
-       char tempPath[256];
-
-       dir  = opendir("/proc");
-       if (NULL == dir) {
-               SLOG(LOG_ERROR, TAG_STTC, "process checking is FAILED");
-               return FALSE;
-       }
-
-       while ((entry = readdir(dir)) != NULL) {
-               if (0 != lstat(entry->d_name, &filestat))
-                       continue;
-
-               if (!S_ISDIR(filestat.st_mode))
-                       continue;
-
-               pid = atoi(entry->d_name);
-               if (pid <= 0) continue;
-
-               sprintf(tempPath, "/proc/%d/cmdline", pid);
-               if (0 != __setting_get_cmd_line(tempPath, cmdLine)) {
-                       continue;
-               }
-
-               if ( 0 == strncmp(cmdLine, "[stt-daemon]", strlen("[stt-daemon]")) ||
-                       0 == strncmp(cmdLine, "stt-daemon", strlen("stt-daemon")) ||
-                       0 == strncmp(cmdLine, "/usr/bin/stt-daemon", strlen("/usr/bin/stt-daemon"))) {
-                               SLOG(LOG_DEBUG, TAG_STTC, "stt-daemon is ALIVE !! \n");
-                               closedir(dir);
-                               return TRUE;
-               }
+       if (NULL == callback) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input param is NULL");
+               return STT_SETTING_ERROR_INVALID_PARAMETER;
        }
-       SLOG(LOG_DEBUG, TAG_STTC, "THERE IS NO stt-daemon !! \n");
 
-       closedir(dir);
-       return FALSE;
+       g_config_changed_cb = callback;
+       g_config_changed_user_data = user_data;
 
+       return STT_SETTING_ERROR_NONE;
 }
 
-int __check_setting_stt_daemon()
+int stt_setting_unset_config_changed_cb()
 {
-       if (TRUE == __stt_setting_is_alive()) 
-               return 0;
-       
-       /* fork-exec stt-daemom */
-       int pid = 0, i = 0;
-
-       pid = fork();
-
-       switch(pid) {
-       case -1:
-               SLOG(LOG_DEBUG, TAG_STTC, "Fail to create stt-daemon");
-               break;
-
-       case 0:
-               setsid();
-               for( i = 0 ; i < _NSIG ; i++ )
-                       signal(i, SIG_DFL);
-
-               execl("/usr/bin/stt-daemon", "/usr/bin/stt-daemon", NULL);
-               break;
-
-       default:
-               break;
-       }
-
-       return 0;
-}
+       g_config_changed_cb = NULL;
+       g_config_changed_user_data = NULL;
 
+       return STT_SETTING_ERROR_NONE;
+}
\ No newline at end of file
diff --git a/client/stt_setting_dbus.c b/client/stt_setting_dbus.c
deleted file mode 100644 (file)
index 2ce9faa..0000000
+++ /dev/null
@@ -1,1175 +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 "stt_main.h"
-#include "stt_setting_dbus.h"
-
-static int g_waiting_time = 1500;
-
-static DBusConnection* g_conn = NULL;
-
-int stt_setting_dbus_open_connection()
-{
-       if( NULL != g_conn ) {
-               SLOG(LOG_WARN, TAG_STTC, "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_STTC, "Dbus Connection Error (%s)\n", err.message); 
-               dbus_error_free(&err); 
-       }
-
-       if (NULL == g_conn) {
-               SLOG(LOG_ERROR, TAG_STTC, "fail to get dbus connection \n");
-               return STT_SETTING_ERROR_OPERATION_FAILED; 
-       }
-
-       int pid = getpid();
-
-       char service_name[64];
-       memset(service_name, 0, 64);
-       snprintf(service_name, 64, "%s%d", STT_SETTING_SERVICE_NAME, pid);
-
-       SLOG(LOG_DEBUG, TAG_STTC, "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_STTC, "Name Error (%s)\n", err.message); 
-               dbus_error_free(&err); 
-       }
-
-       if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) {
-               SLOG(LOG_ERROR, TAG_STTC, "fail dbus_bus_request_name()\n");
-               return STT_SETTING_ERROR_OPERATION_FAILED;
-       }
-
-       return 0;
-}
-
-int stt_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", STT_SETTING_SERVICE_NAME, pid);
-
-       dbus_bus_release_name(g_conn, service_name, &err);
-
-       dbus_connection_close(g_conn);
-
-       g_conn = NULL;
-
-       return 0;
-}
-
-
-int stt_setting_dbus_request_hello()
-{
-       DBusMessage* msg;
-
-       msg = dbus_message_new_method_call(
-               STT_SERVER_SERVICE_NAME, 
-               STT_SERVER_SERVICE_OBJECT_PATH, 
-               STT_SERVER_SERVICE_INTERFACE, 
-               STT_SETTING_METHOD_HELLO);
-
-       if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting hello : Fail to make message \n"); 
-               return STT_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_STTC, "<<<< setting hello");
-               result = 0;
-       } else {
-               result = -1;
-       }
-
-       return result;
-}
-
-int stt_setting_dbus_request_initialize()
-{
-       DBusMessage* msg;
-
-       msg = dbus_message_new_method_call(
-               STT_SERVER_SERVICE_NAME, 
-               STT_SERVER_SERVICE_OBJECT_PATH, 
-               STT_SERVER_SERVICE_INTERFACE, 
-               STT_SETTING_METHOD_INITIALIZE);
-
-       if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting initialize : Fail to make message \n"); 
-               return STT_SETTING_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTC, ">>>> 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 = STT_SETTING_ERROR_OPERATION_FAILED;
-
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &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_STTC, "Get arguments error (%s)\n", err.message);
-                       dbus_error_free(&err); 
-                       result = STT_SETTING_ERROR_OPERATION_FAILED;
-               }
-               dbus_message_unref(result_msg);
-       }
-
-       if (0 == result) {
-               SLOG(LOG_DEBUG, TAG_STTC, "<<<< setting initialize : result = %d", result);
-       } else {
-               SLOG(LOG_ERROR, TAG_STTC, "<<<< setting initialize : result = %d", result);
-       }
-
-       dbus_message_unref(msg);
-
-       return result;
-}
-
-int stt_setting_dbus_request_finalilze(void)
-{
-       DBusMessage* msg;
-
-       msg = dbus_message_new_method_call(
-               STT_SERVER_SERVICE_NAME, 
-               STT_SERVER_SERVICE_OBJECT_PATH, 
-               STT_SERVER_SERVICE_INTERFACE, 
-               STT_SETTING_METHOD_FINALIZE);
-
-       if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting finalize : Fail to make message \n"); 
-               return STT_SETTING_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTC, ">>>> 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 = STT_SETTING_ERROR_OPERATION_FAILED;
-
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &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_STTC, "Get arguments error (%s)\n", err.message);
-                       dbus_error_free(&err); 
-                       result = STT_SETTING_ERROR_OPERATION_FAILED;
-               }
-               dbus_message_unref(result_msg);
-       }
-
-       if (0 == result) {
-               SLOG(LOG_DEBUG, TAG_STTC, "<<<< setting finallize : result = %d", result);
-       } else {
-               SLOG(LOG_ERROR, TAG_STTC, "<<<< setting finallize : result = %d", result);
-       }
-
-       dbus_message_unref(msg);
-
-       return result;
-}
-
-int stt_setting_dbus_request_get_engine_list(stt_setting_supported_engine_cb callback, void* user_data)
-{
-       if (NULL == callback) {
-               SLOG(LOG_ERROR, TAG_STTC, "Input parameter is NULL");
-               return -1;
-       }
-
-       DBusMessage* msg;
-
-       msg = dbus_message_new_method_call(
-               STT_SERVER_SERVICE_NAME, 
-               STT_SERVER_SERVICE_OBJECT_PATH, 
-               STT_SERVER_SERVICE_INTERFACE, 
-               STT_SETTING_METHOD_GET_ENGINE_LIST);
-
-       if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting get engine list : Fail to make message \n"); 
-               return STT_SETTING_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTC, ">>>> 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 = STT_SETTING_ERROR_OPERATION_FAILED;
-
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &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_STTC, "<<<< 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_STTC, "<<<< setting get engine list : result = %d \n", result);
-                       }
-               } else {
-                       SLOG(LOG_ERROR, TAG_STTC, "<<<< setting get engine list : invalid message \n");
-               }
-
-               dbus_message_unref(result_msg);
-       } else {
-               SLOG(LOG_ERROR, TAG_STTC, "<<<< setting get engine list : result message is NULL!! \n");
-       }
-
-       dbus_message_unref(msg);
-
-       return result;
-}
-
-int stt_setting_dbus_request_get_engine(char** engine_id)
-{
-       if (NULL == engine_id)  {
-               SLOG(LOG_ERROR, TAG_STTC, "Input parameter is NULL");
-               return STT_SETTING_ERROR_INVALID_PARAMETER;
-       }
-
-       DBusMessage* msg;
-
-       msg = dbus_message_new_method_call(
-               STT_SERVER_SERVICE_NAME, 
-               STT_SERVER_SERVICE_OBJECT_PATH, 
-               STT_SERVER_SERVICE_INTERFACE, 
-               STT_SETTING_METHOD_GET_ENGINE);
-
-       if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting get engine : Fail to make message \n"); 
-               return STT_SETTING_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTC, ">>>> 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 = STT_SETTING_ERROR_OPERATION_FAILED;
-       char* temp;
-
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &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_STTC, "Get arguments error (%s)\n", err.message);
-                       dbus_error_free(&err); 
-                       result = STT_SETTING_ERROR_OPERATION_FAILED;
-               }
-               dbus_message_unref(result_msg);
-       }
-
-       if (0 == result) {
-               *engine_id = strdup(temp);
-
-               if (NULL == *engine_id) {
-                       SLOG(LOG_ERROR, TAG_STTC, "<<<< setting get engine : Out of memory \n");
-                       result = STT_SETTING_ERROR_OUT_OF_MEMORY;
-               } else {
-                       SLOG(LOG_DEBUG, TAG_STTC, "<<<< setting get engine : result(%d), engine id(%s)\n", result, *engine_id);
-               }
-       } else {
-               SLOG(LOG_ERROR, TAG_STTC, "<<<< setting get engine : result(%d) \n", result);
-       }
-
-       dbus_message_unref(msg);
-
-       return result;
-}
-
-int stt_setting_dbus_request_set_engine(const char* engine_id)
-{
-       if (NULL == engine_id) {
-               SLOG(LOG_ERROR, TAG_STTC, "Input parameter is NULL");
-               return STT_SETTING_ERROR_INVALID_PARAMETER;
-       }
-
-       DBusMessage* msg;
-
-       msg = dbus_message_new_method_call(
-               STT_SERVER_SERVICE_NAME, 
-               STT_SERVER_SERVICE_OBJECT_PATH, 
-               STT_SERVER_SERVICE_INTERFACE, 
-               STT_SETTING_METHOD_SET_ENGINE);
-
-       if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting set engine : Fail to make message \n"); 
-               return STT_SETTING_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTC, ">>>> 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 = STT_SETTING_ERROR_OPERATION_FAILED;
-
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &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_STTC, "Get arguments error (%s)\n", err.message);
-                       dbus_error_free(&err); 
-                       result = STT_SETTING_ERROR_OPERATION_FAILED;
-               }
-               dbus_message_unref(result_msg);
-       }
-
-       if (0 == result) {
-               SLOG(LOG_DEBUG, TAG_STTC, "<<<< setting set engine : result(%d) \n", result);
-       } else {
-               SLOG(LOG_ERROR, TAG_STTC, "<<<< setting set engine : result(%d) \n", result);
-       }
-
-       dbus_message_unref(msg);
-
-       return result;
-}
-
-int stt_setting_dbus_request_get_language_list(stt_setting_supported_language_cb callback, void* user_data)
-{
-       if (NULL == callback) {
-               SLOG(LOG_ERROR, TAG_STTC, "Input parameter is NULL");
-               return STT_SETTING_ERROR_INVALID_PARAMETER;
-       }
-
-       DBusMessage* msg;
-
-       msg = dbus_message_new_method_call(
-               STT_SERVER_SERVICE_NAME, 
-               STT_SERVER_SERVICE_OBJECT_PATH, 
-               STT_SERVER_SERVICE_INTERFACE, 
-               STT_SETTING_METHOD_GET_LANG_LIST);
-
-       if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting get language list : Fail to make message \n"); 
-               return STT_SETTING_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTC, ">>>> Request setting get language 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 = STT_SETTING_ERROR_OPERATION_FAILED;
-
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &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_STTC, "<<<< setting get language list : result = %d \n", result);
-
-                               int size = 0; 
-                               char* temp_id = NULL;
-                               char* temp_lang = NULL;
-
-                               /* Get engine id */
-                               dbus_message_iter_get_basic(&args, &temp_id);
-                               dbus_message_iter_next(&args);
-
-                               if (NULL != temp_id) {
-                                       /* Get language 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);
-
-                                               if (true != callback(temp_id, temp_lang, user_data)) {
-                                                       break;
-                                               }
-                                       }
-                               } else {
-                                       SLOG(LOG_ERROR, TAG_STTC, "Engine ID is NULL \n");
-                                       result = STT_SETTING_ERROR_OPERATION_FAILED;
-                               }
-
-                       } else {
-                               SLOG(LOG_ERROR, TAG_STTC, "<<<< setting get language list : result = %d \n", result);
-                       }
-               } 
-
-               dbus_message_unref(result_msg);
-       } else {
-               SLOG(LOG_ERROR, TAG_STTC, "<<<< setting get language list : Result message is NULL!!");
-       }
-
-       dbus_message_unref(msg);
-       
-       return result;
-}
-
-int stt_setting_dbus_request_get_default_language(char** language)
-{
-       if (NULL == language) {
-               SLOG(LOG_ERROR, TAG_STTC, "Input Parameter is NULL");
-               return STT_SETTING_ERROR_INVALID_PARAMETER;
-       }
-
-       DBusMessage* msg;
-
-       msg = dbus_message_new_method_call(
-               STT_SERVER_SERVICE_NAME, 
-               STT_SERVER_SERVICE_OBJECT_PATH, 
-               STT_SERVER_SERVICE_INTERFACE, 
-               STT_SETTING_METHOD_GET_DEFAULT_LANG);
-
-       if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting get default language : Fail to make message \n"); 
-               return STT_SETTING_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTC, ">>>> Request setting get default language");
-       }
-
-       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 = STT_SETTING_ERROR_OPERATION_FAILED;
-       char* temp_char;
-
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
-
-       if (NULL != result_msg) {
-               dbus_message_get_args(result_msg, &err, 
-                       DBUS_TYPE_INT32, &result, 
-                       DBUS_TYPE_STRING, &temp_char,
-                       DBUS_TYPE_INVALID);
-
-               if (dbus_error_is_set(&err)) { 
-                       SLOG(LOG_ERROR, TAG_STTC, "Get arguments error (%s)\n", err.message);
-                       dbus_error_free(&err); 
-                       result = STT_SETTING_ERROR_OPERATION_FAILED;
-               }
-
-               dbus_message_unref(result_msg);
-       }
-
-       if (0 == result) {
-               *language = strdup(temp_char);
-
-               if (NULL == *language) {
-                       SLOG(LOG_ERROR, TAG_STTC, "<<<< setting get default language : Out of memory \n");
-                       result = STT_SETTING_ERROR_OUT_OF_MEMORY;
-               } else {
-                       SLOG(LOG_DEBUG, TAG_STTC, "<<<< setting get default language : result(%d), lang(%s)\n", result, *language);
-               }
-       } else {
-               SLOG(LOG_ERROR, TAG_STTC, "<<<< setting get default language : result(%d) \n", result);
-       }
-
-       dbus_message_unref(msg);
-
-       return result;
-}
-
-
-int stt_setting_dbus_request_set_default_language(const char* language)
-{
-       if (NULL == language) {
-               SLOG(LOG_ERROR, TAG_STTC, "Input Parameter is NULL");
-               return STT_SETTING_ERROR_INVALID_PARAMETER;
-       }
-
-       DBusMessage* msg;
-
-       msg = dbus_message_new_method_call(
-               STT_SERVER_SERVICE_NAME, 
-               STT_SERVER_SERVICE_OBJECT_PATH, 
-               STT_SERVER_SERVICE_INTERFACE, 
-               STT_SETTING_METHOD_SET_DEFAULT_LANG);
-
-       if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting set default language : Fail to make message \n"); 
-               return STT_SETTING_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTC, ">>>> Request setting set default language : lang(%s)\n", language);
-       }
-
-       int pid = getpid();
-
-       dbus_message_append_args( msg, 
-               DBUS_TYPE_INT32, &pid,
-               DBUS_TYPE_STRING, &language,
-               DBUS_TYPE_INVALID);
-
-       DBusError err;
-       dbus_error_init(&err);
-
-       DBusMessage* result_msg;
-       int result = STT_SETTING_ERROR_OPERATION_FAILED;
-
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &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_STTC, "Get arguments error (%s)\n", err.message);
-                       dbus_error_free(&err); 
-                       result = STT_SETTING_ERROR_OPERATION_FAILED;
-               }
-
-               dbus_message_unref(result_msg);
-       }
-
-       if (0 == result) {
-               SLOG(LOG_DEBUG, TAG_STTC, "<<<< setting set default language : result(%d)", result);
-       } else {
-               SLOG(LOG_ERROR, TAG_STTC, "<<<< setting set default language : result(%d)", result);
-       }
-
-       dbus_message_unref(msg);
-       
-       return result;
-}
-
-int stt_setting_dbus_request_get_engine_setting(stt_setting_engine_setting_cb callback, void* user_data)
-{
-       if (NULL == callback) {
-               SLOG(LOG_ERROR, TAG_STTC, "Input Parameter is NULL");
-               return STT_SETTING_ERROR_INVALID_PARAMETER;
-       }
-
-       DBusMessage* msg;
-
-       msg = dbus_message_new_method_call(
-               STT_SERVER_SERVICE_NAME, 
-               STT_SERVER_SERVICE_OBJECT_PATH, 
-               STT_SERVER_SERVICE_INTERFACE, 
-               STT_SETTING_METHOD_GET_ENGINE_SETTING);
-
-       if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting get engine setting : Fail to make message \n"); 
-               return STT_SETTING_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTC, ">>>> 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 = STT_SETTING_ERROR_OPERATION_FAILED;
-
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &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_STTC, "<<<< 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_STTC, "<<<< get engine setting : result message is invalid \n");
-                                       result = STT_SETTING_ERROR_OPERATION_FAILED;
-                               }
-                       } 
-               } else {
-                       SLOG(LOG_ERROR, TAG_STTC, "<<<< get engine setting : result message is invalid \n");
-                       result = STT_SETTING_ERROR_OPERATION_FAILED;
-               }
-
-               dbus_message_unref(result_msg);
-       } else {
-               SLOG(LOG_ERROR, TAG_STTC, "<<<< get engine setting : Result message is NULL!! \n");
-       }       
-
-       dbus_message_unref(msg);
-
-       return result;
-}
-
-int stt_setting_dbus_request_set_engine_setting(const char* key, const char* value)
-{
-       if (NULL == key || NULL == value) {
-               SLOG(LOG_ERROR, TAG_STTC, "Input Parameter is NULL");
-               return STT_SETTING_ERROR_INVALID_PARAMETER;
-       }
-
-       DBusMessage* msg;
-
-       msg = dbus_message_new_method_call(
-               STT_SERVER_SERVICE_NAME, 
-               STT_SERVER_SERVICE_OBJECT_PATH, 
-               STT_SERVER_SERVICE_INTERFACE, 
-               STT_SETTING_METHOD_SET_ENGINE_SETTING);
-
-       if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting set engine setting : Fail to make message \n"); 
-               return STT_SETTING_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTC, ">>>> 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 = STT_SETTING_ERROR_OPERATION_FAILED;
-
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &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_STTC, "<<<< 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_STTC, "<<<< setting set engine setting : result(%d)", result);
-       } else {
-               SLOG(LOG_ERROR, TAG_STTC, "<<<< setting set engine setting : result(%d)", result);
-       }
-
-       dbus_message_unref(msg);
-
-       return result;
-}
-
-int stt_setting_dbus_request_get_profanity_filter(bool* value)
-{
-       if (NULL == value) {
-               SLOG(LOG_ERROR, TAG_STTC, "Input Parameter is NULL");
-               return STT_SETTING_ERROR_INVALID_PARAMETER;
-       }
-
-       DBusMessage* msg;
-
-       msg = dbus_message_new_method_call(
-               STT_SERVER_SERVICE_NAME, 
-               STT_SERVER_SERVICE_OBJECT_PATH, 
-               STT_SERVER_SERVICE_INTERFACE, 
-               STT_SETTING_METHOD_GET_PROFANITY);
-
-       if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting set profanity filter : Fail to make message \n"); 
-               return STT_SETTING_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTC, ">>>> Request setting set profanity filter");
-       }
-
-       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 = STT_SETTING_ERROR_OPERATION_FAILED;
-
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
-
-       if (NULL != result_msg) {
-               dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INT32, value, DBUS_TYPE_INVALID);
-
-               if (dbus_error_is_set(&err)) { 
-                       SLOG(LOG_ERROR, TAG_STTC, "Get arguments error (%s)\n", err.message);
-                       dbus_error_free(&err); 
-                       result = STT_SETTING_ERROR_OPERATION_FAILED;
-               }
-
-               dbus_message_unref(result_msg);
-       } 
-
-       if (0 == result) {
-               SLOG(LOG_DEBUG, TAG_STTC, "<<<< setting get profanity filter : result(%d), value(%s)", result, *value ? "true":"false");
-       } else {
-               SLOG(LOG_ERROR, TAG_STTC, "<<<< setting get profanity filter : result(%d)", result);
-       }
-       
-       dbus_message_unref(msg);
-
-       return result;
-}
-
-int stt_setting_dbus_request_set_profanity_filter(const bool value)
-{
-       DBusMessage* msg;
-
-       msg = dbus_message_new_method_call(
-               STT_SERVER_SERVICE_NAME, 
-               STT_SERVER_SERVICE_OBJECT_PATH, 
-               STT_SERVER_SERVICE_INTERFACE, 
-               STT_SETTING_METHOD_SET_PROFANITY);
-
-       if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting set profanity filter : Fail to make message \n"); 
-               return STT_SETTING_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTC, ">>>> Request setting set profanity filter : value(%s)", value ? "true":"false");
-       }
-
-       int pid = getpid();
-
-       dbus_message_append_args( msg, 
-               DBUS_TYPE_INT32, &pid,
-               DBUS_TYPE_INT32, &value, 
-               DBUS_TYPE_INVALID);
-
-       DBusError err;
-       dbus_error_init(&err);
-
-       DBusMessage* result_msg;
-       int result = STT_SETTING_ERROR_OPERATION_FAILED;
-
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &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_STTC, "Get arguments error (%s)\n", err.message);
-                       dbus_error_free(&err); 
-                       result = STT_SETTING_ERROR_OPERATION_FAILED;
-               }
-
-               dbus_message_unref(result_msg);
-       } 
-
-       if (0 == result) {
-               SLOG(LOG_DEBUG, TAG_STTC, "<<<< setting set profanity filter : result(%d)", result);
-       } else {
-               SLOG(LOG_ERROR, TAG_STTC, "<<<< setting set profanity filter : result(%d)", result);
-       }
-
-       dbus_message_unref(msg);
-
-       return result;
-}
-
-int stt_setting_dbus_request_get_punctuation_override(bool* value)
-{
-       if (NULL == value) {
-               SLOG(LOG_ERROR, TAG_STTC, "Input Parameter is NULL");
-               return STT_SETTING_ERROR_INVALID_PARAMETER;
-       }
-
-       DBusMessage* msg;
-
-       msg = dbus_message_new_method_call(
-               STT_SERVER_SERVICE_NAME, 
-               STT_SERVER_SERVICE_OBJECT_PATH, 
-               STT_SERVER_SERVICE_INTERFACE, 
-               STT_SETTING_METHOD_GET_PUNCTUATION);
-
-       if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting get punctuation override : Fail to make message \n"); 
-               return STT_SETTING_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTC, ">>>> Request setting get punctuation override ");
-       }
-
-       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 = STT_SETTING_ERROR_OPERATION_FAILED;
-
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
-
-       if (NULL != result_msg) {
-               dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INT32, value, DBUS_TYPE_INVALID);
-
-               if (dbus_error_is_set(&err)) { 
-                       SLOG(LOG_ERROR, TAG_STTC, "Get arguments error (%s)\n", err.message);
-                       dbus_error_free(&err); 
-                       result = STT_SETTING_ERROR_OPERATION_FAILED;
-               }
-
-               dbus_message_unref(result_msg);
-       } 
-
-       if (0 == result) {
-               SLOG(LOG_DEBUG, TAG_STTC, "<<<< setting get punctuation override : result(%d), value(%s)", result, *value ? "true":"false");
-       } else {
-               SLOG(LOG_ERROR, TAG_STTC, "<<<< setting get punctuation override : result(%d)", result);
-       }
-
-       dbus_message_unref(msg);
-
-       return result;
-}
-
-int stt_setting_dbus_request_set_punctuation_override(const bool value )
-{
-       DBusMessage* msg;
-
-       msg = dbus_message_new_method_call(
-               STT_SERVER_SERVICE_NAME, 
-               STT_SERVER_SERVICE_OBJECT_PATH, 
-               STT_SERVER_SERVICE_INTERFACE, 
-               STT_SETTING_METHOD_SET_PUNCTUATION);
-
-       if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting set punctuation override : Fail to make message \n"); 
-               return STT_SETTING_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTC, ">>>> Request setting set punctuation override : value(%s)", value ? "true":"false");
-       }
-
-       int pid = getpid();
-
-       dbus_message_append_args( msg, 
-               DBUS_TYPE_INT32, &pid,
-               DBUS_TYPE_INT32, &value, 
-               DBUS_TYPE_INVALID);
-
-       DBusError err;
-       dbus_error_init(&err);
-
-       DBusMessage* result_msg;
-       int result = STT_SETTING_ERROR_OPERATION_FAILED;
-
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &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_STTC, "Get arguments error (%s)\n", err.message);
-                       dbus_error_free(&err); 
-                       result = STT_SETTING_ERROR_OPERATION_FAILED;
-               }
-
-               dbus_message_unref(result_msg);
-       } 
-
-       if (0 == result) {
-               SLOG(LOG_DEBUG, TAG_STTC, "<<<< setting set punctuation override : result(%d)", result);
-       } else {
-               SLOG(LOG_ERROR, TAG_STTC, "<<<< setting set punctuation override : result(%d)", result);
-       }
-
-       dbus_message_unref(msg);
-
-       return result;
-}
-
-int stt_setting_dbus_request_get_silence_detection(bool* value)
-{
-       if (NULL == value) {
-               SLOG(LOG_ERROR, TAG_STTC, "Input Parameter is NULL");
-               return STT_SETTING_ERROR_INVALID_PARAMETER;
-       }
-
-       DBusMessage* msg;
-
-       msg = dbus_message_new_method_call(
-               STT_SERVER_SERVICE_NAME, 
-               STT_SERVER_SERVICE_OBJECT_PATH, 
-               STT_SERVER_SERVICE_INTERFACE, 
-               STT_SETTING_METHOD_GET_SILENCE);
-
-       if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting get silence detection : Fail to make message \n"); 
-               return STT_SETTING_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTC, ">>>> Request setting get silence detection : value(%s)", value ? "true":"false");
-       }
-
-       int pid = getpid();
-
-       dbus_message_append_args( msg, 
-               DBUS_TYPE_INT32, &pid,
-               DBUS_TYPE_INT32, &value, 
-               DBUS_TYPE_INVALID);
-
-       DBusError err;
-       dbus_error_init(&err);
-
-       DBusMessage* result_msg;
-       int result = STT_SETTING_ERROR_OPERATION_FAILED;
-
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
-
-       if (NULL == result_msg) {
-               dbus_message_unref(msg);
-               return STT_SETTING_ERROR_OPERATION_FAILED;
-       }
-
-       dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INT32, value, DBUS_TYPE_INVALID);
-
-       if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, TAG_STTC, "Get arguments error (%s)\n", err.message);
-               dbus_error_free(&err); 
-               result = STT_SETTING_ERROR_OPERATION_FAILED;
-       }
-
-       SLOG(LOG_DEBUG, TAG_STTC, "Get Silence Detection : result(%d), value(%d) \n", result, *value);
-
-       dbus_message_unref(msg);
-
-       return result;
-}
-
-int stt_setting_dbus_request_set_silence_detection(const bool value)
-{
-       DBusMessage* msg;
-
-       msg = dbus_message_new_method_call(
-               STT_SERVER_SERVICE_NAME, 
-               STT_SERVER_SERVICE_OBJECT_PATH, 
-               STT_SERVER_SERVICE_INTERFACE, 
-               STT_SETTING_METHOD_SET_SILENCE);
-
-       if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting set silence detection : Fail to make message \n"); 
-               return STT_SETTING_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTC, ">>>> Request setting set silence detection : value(%s)", value ? "true":"false");
-       }
-
-       int pid = getpid();
-
-       dbus_message_append_args( msg, 
-               DBUS_TYPE_INT32, &pid,
-               DBUS_TYPE_INT32, &value, 
-               DBUS_TYPE_INVALID);
-
-       DBusError err;
-       dbus_error_init(&err);
-
-       DBusMessage* result_msg;
-       int result = STT_SETTING_ERROR_OPERATION_FAILED;
-
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &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_STTC, "Get arguments error (%s)\n", err.message);
-                       dbus_error_free(&err); 
-                       result = STT_SETTING_ERROR_OPERATION_FAILED;
-               }
-
-               dbus_message_unref(result_msg);
-       } 
-
-       if (0 == result) {
-               SLOG(LOG_DEBUG, TAG_STTC, "<<<< setting set set silence detection : result(%d)", result);
-       } else {
-               SLOG(LOG_ERROR, TAG_STTC, "<<<< setting set set silence detection : result(%d)", result);
-       }
-
-       dbus_message_unref(msg);
-
-       return result;
-}
-
-
-
-
-
-
-
diff --git a/client/stt_setting_dbus.h b/client/stt_setting_dbus.h
deleted file mode 100644 (file)
index c642359..0000000
+++ /dev/null
@@ -1,67 +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 __STT_SETTING_DBUS_H_
-#define __STT_SETTING_DBUS_H_
-
-#include "stt_setting.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int stt_setting_dbus_open_connection();
-
-int stt_setting_dbus_close_connection();
-
-
-int stt_setting_dbus_request_hello();
-
-int stt_setting_dbus_request_initialize();
-
-int stt_setting_dbus_request_finalilze();
-
-int stt_setting_dbus_request_get_engine_list(stt_setting_supported_engine_cb callback, void* user_data);
-
-int stt_setting_dbus_request_get_engine(char** engine_id);
-
-int stt_setting_dbus_request_set_engine(const char* engine_id );
-
-int stt_setting_dbus_request_get_language_list(stt_setting_supported_language_cb callback, void* user_data);
-
-int stt_setting_dbus_request_get_default_language(char** language);
-
-int stt_setting_dbus_request_set_default_language(const char* language);
-
-int stt_setting_dbus_request_get_profanity_filter(bool* value);
-
-int stt_setting_dbus_request_set_profanity_filter(const bool value);
-
-int stt_setting_dbus_request_get_punctuation_override(bool* value);
-
-int stt_setting_dbus_request_set_punctuation_override(const bool value);
-
-int stt_setting_dbus_request_get_silence_detection(bool* value);
-
-int stt_setting_dbus_request_set_silence_detection(const bool value);
-
-int stt_setting_dbus_request_get_engine_setting(stt_setting_engine_setting_cb callback, void* user_data);
-
-int stt_setting_dbus_request_set_engine_setting(const char* key, const char* value);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __STT_SETTING_DBUS_H_ */
diff --git a/common/stt_config_mgr.c b/common/stt_config_mgr.c
new file mode 100644 (file)
index 0000000..8d44b98
--- /dev/null
@@ -0,0 +1,1441 @@
+/*
+*  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 <glib.h>
+#include <unistd.h>
+#include <sys/inotify.h>
+#include <vconf.h>
+
+#include "stt_config_mgr.h"
+#include "stt_defs.h"
+#include "stt_config_parser.h"
+
+#define VCONFKEY_VOICE_INPUT_LANGUAGE     "db/voice_input/language"
+
+typedef struct {
+       int     uid;
+       stt_config_engine_changed_cb    engine_cb;
+       stt_config_lang_changed_cb      lang_cb;
+       stt_config_bool_changed_cb      bool_cb;
+       void*   user_data;
+}stt_config_client_s;
+
+
+extern const char* stt_tag();
+
+static GSList* g_engine_list = NULL;
+
+static GSList* g_config_client_list = NULL;
+
+static stt_config_s* g_config_info;
+
+static Ecore_Fd_Handler* g_fd_handler_noti = NULL;
+static int g_fd_noti;
+static int g_wd_noti;
+
+int __stt_config_mgr_print_engine_info();
+
+bool __stt_config_mgr_check_lang_is_valid(const char* engine_id, const char* language)
+{
+       if (NULL == engine_id || NULL == language) {
+               SLOG(LOG_ERROR, stt_tag(), "[ERROR] Input parameter is NULL");
+               return false;
+       }
+
+       GSList *iter = NULL;
+       stt_engine_info_s *engine_info = NULL;
+
+       if (0 >= g_slist_length(g_engine_list)) {
+               SLOG(LOG_ERROR, stt_tag(), "[ERROR] 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, stt_tag(), "[ERROR] Engine info is NULL");
+                       return false;
+               }
+
+               if (0 != strcmp(engine_id, engine_info->uuid)) {
+                       iter = g_slist_next(iter);
+                       continue;
+               }
+
+               GSList *iter_lang = NULL;
+               char* engine_lang;
+               if (g_slist_length(engine_info->languages) > 0) {
+                       /* Get a first item */
+                       iter_lang = g_slist_nth(engine_info->languages, 0);
+
+                       int i = 1;      
+                       while (NULL != iter_lang) {
+                               /*Get handle data from list*/
+                               engine_lang = iter_lang->data;
+
+                               SECURE_SLOG(LOG_DEBUG, stt_tag(), "  [%dth] %s", i, engine_lang);
+
+                               if (0 == strcmp(language, engine_lang)) {
+                                       return true;
+                               }
+
+                               /*Get next item*/
+                               iter_lang = g_slist_next(iter_lang);
+                               i++;
+                       }
+               }
+               break;
+       }
+
+       return false;
+}
+
+int __stt_config_mgr_select_lang(const char* engine_id, char** language)
+{
+       if (NULL == engine_id || NULL == language) {
+               SLOG(LOG_ERROR, stt_tag(), "[ERROR] Input parameter is NULL");
+               return false;
+       }
+
+       GSList *iter = NULL;
+       stt_engine_info_s *engine_info = NULL;
+
+       if (0 >= g_slist_length(g_engine_list)) {
+               SLOG(LOG_ERROR, stt_tag(), "[ERROR] 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, stt_tag(), "engine info is NULL");
+                       return false;
+               }
+
+               if (0 != strcmp(engine_id, engine_info->uuid)) {
+                       iter = g_slist_next(iter);
+                       continue;
+               }
+               
+               GSList *iter_lang = NULL;
+               char* engine_lang = NULL;
+               if (g_slist_length(engine_info->languages) > 0) {
+                       /* Get a first item */
+                       iter_lang = g_slist_nth(engine_info->languages, 0);
+                       
+                       while (NULL != iter_lang) {
+                               engine_lang = iter_lang->data;
+                               if (NULL != engine_lang) {
+                                       /* Default language is STT_BASE_LANGUAGE */
+                                       if (0 == strcmp(STT_BASE_LANGUAGE, engine_lang)) {
+                                               *language = strdup(engine_lang);
+                                               SECURE_SLOG(LOG_DEBUG, stt_tag(), "Selected language : %s", *language);
+                                               return 0;
+                                       }
+                               }
+
+                               iter_lang = g_slist_next(iter_lang);
+                       }
+
+                       /* Not support STT_BASE_LANGUAGE */
+                       if (NULL != engine_lang) {
+                               *language = strdup(engine_lang);
+                               SECURE_SLOG(LOG_DEBUG, stt_tag(), "Selected language : %s", *language);
+                               return 0;
+                       }
+               }
+               break;
+       }
+
+       return -1;
+}
+
+Eina_Bool stt_config_mgr_inotify_event_cb(void* data, Ecore_Fd_Handler *fd_handler)
+{
+       SLOG(LOG_DEBUG, stt_tag(), "===== Config changed callback event");
+
+       int length;
+       struct inotify_event event;
+       memset(&event, '\0', sizeof(struct inotify_event));
+
+       length = read(g_fd_noti, &event, sizeof(struct inotify_event));
+       if (0 > length) {
+               SLOG(LOG_ERROR, stt_tag(), "[ERROR] Empty Inotify event");
+               SLOG(LOG_DEBUG, stt_tag(), "=====");
+               SLOG(LOG_DEBUG, stt_tag(), " ");
+               return ECORE_CALLBACK_PASS_ON; 
+       }
+
+       if (IN_MODIFY == event.mask) {
+               char* engine = NULL;
+               char* setting = NULL;
+               char* lang = NULL;
+               int auto_lang = -1;
+               int silence = -1;
+
+               GSList *iter = NULL;
+               stt_config_client_s* temp_client = NULL;
+
+               if (0 != stt_parser_find_config_changed(&engine, &setting, &auto_lang, &lang, &silence))
+                       return ECORE_CALLBACK_PASS_ON;
+
+               /* Engine changed */
+               if (NULL != engine || NULL != setting) {
+                       /* engine changed */
+                       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);
+                       }
+
+                       if (NULL != lang) {
+                               if (NULL != g_config_info->language)    free(g_config_info->language);
+                               g_config_info->language = strdup(lang);
+                       }
+
+                       if (-1 != silence)      g_config_info->silence_detection = silence;
+
+                       /* 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) {
+                                               temp_client->engine_cb(g_config_info->engine_id, g_config_info->setting, g_config_info->language,
+                                                       g_config_info->silence_detection, temp_client->user_data);
+                                       }
+                               }
+
+                               iter = g_slist_next(iter);
+                       }
+               }
+
+               if (-1 != auto_lang) {
+                       g_config_info->auto_lang = auto_lang;
+               }
+
+               /* Only language changed */
+               if (NULL == engine && NULL != lang) {
+                       char* before_lang = NULL;
+                       before_lang = strdup(g_config_info->language);
+
+                       if (NULL != lang) {
+                               if (NULL != g_config_info->language)    free(g_config_info->language);
+                               g_config_info->language = strdup(lang);
+                       }
+
+                       /* 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->lang_cb) {
+                                               temp_client->lang_cb(before_lang, g_config_info->language, temp_client->user_data);
+                                       }
+                               }
+
+                               iter = g_slist_next(iter);
+                       }
+
+                       if (NULL != before_lang) {
+                               free(before_lang);
+                       }
+               }
+
+               if (-1 != silence) {
+                       /* silence detection changed */
+                       g_config_info->silence_detection = silence;
+
+                       /* 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->bool_cb) {
+                                               temp_client->bool_cb(STT_CONFIG_TYPE_OPTION_SILENCE_DETECTION, silence, 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, stt_tag(), "[ERROR] Undefined event");
+       }
+
+       SLOG(LOG_DEBUG, stt_tag(), "=====");
+       SLOG(LOG_DEBUG, stt_tag(), " ");
+
+       return ECORE_CALLBACK_PASS_ON;
+}
+
+int __stt_config_mgr_register_config_event()
+{
+       /* get file notification handler */
+       int fd;
+       int wd;
+
+       fd = inotify_init();
+       if (fd < 0) {
+               SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail get inotify fd");
+               return -1;
+       }
+       g_fd_noti = fd;
+
+       wd = inotify_add_watch(fd, STT_CONFIG, IN_MODIFY);
+       g_wd_noti = wd;
+
+       g_fd_handler_noti = ecore_main_fd_handler_add(fd, ECORE_FD_READ, (Ecore_Fd_Cb)stt_config_mgr_inotify_event_cb, NULL, NULL, NULL);               
+       if (NULL == g_fd_handler_noti) {
+               SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to get handler_noti");
+               return -1;
+       }
+
+       return 0;
+}
+
+int __stt_config_mgr_unregister_config_event()
+{
+       /* delete 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 __stt_config_set_auto_language()
+{
+       char* value = NULL;
+       value = vconf_get_str(VCONFKEY_VOICE_INPUT_LANGUAGE);
+       if (NULL == value) {
+               SLOG(LOG_ERROR, stt_tag(), "[Config ERROR] Fail to get voice input language");
+               return -1;
+       }
+
+       char candidate_lang[6] = {'\0', };
+
+       /* Check auto is on or not */
+       if (0 == strncmp(value, "auto", 4)) {
+               free(value);
+       
+               value = vconf_get_str(VCONFKEY_LANGSET);
+               if (NULL == value) {
+                       SLOG(LOG_ERROR, stt_tag(), "[Config ERROR] Fail to get display language");
+                       return -1;
+               }
+
+               strncpy(candidate_lang, value, 5);
+               free(value);
+
+               /* Check current language */
+               if (0 == strncmp(g_config_info->language, candidate_lang, 5)) {
+                       SECURE_SLOG(LOG_DEBUG, stt_tag(), "[Config] Language is auto. STT language(%s) is same with display lang", g_config_info->language);
+                       return 0;
+               } else {
+                       SECURE_SLOG(LOG_DEBUG, stt_tag(), "[Config] Display language : %s", candidate_lang);
+               }
+       } else {
+               strncpy(candidate_lang, value, 5);
+               SECURE_SLOG(LOG_DEBUG, stt_tag(), "[Config] Voice input language is NOT auto. Voice input language : %s", candidate_lang);
+
+               free(value);
+       }
+
+       if (true == __stt_config_mgr_check_lang_is_valid(g_config_info->engine_id, candidate_lang)) {
+               /* stt default language change */
+               if (NULL == g_config_info->language) {
+                       SLOG(LOG_ERROR, stt_tag(), "Current config language is NULL");
+                       return -1;
+               }
+
+               char* before_lang = NULL;
+               if (0 != stt_parser_set_language(candidate_lang)) {
+                       SLOG(LOG_ERROR, stt_tag(), "Fail to save default language");
+                       return -1;
+               }
+
+               before_lang = strdup(g_config_info->language);
+
+               free(g_config_info->language);
+               g_config_info->language = strdup(candidate_lang);
+
+               SECURE_SLOG(LOG_DEBUG, stt_tag(), "[Config] Language is auto. Set default language(%s)", g_config_info->language);
+
+               /* Call all callbacks of client*/
+               GSList *iter = NULL;
+               stt_config_client_s* temp_client = NULL;
+
+               iter = g_slist_nth(g_config_client_list, 0);
+
+               while (NULL != iter) {
+                       temp_client = iter->data;
+
+                       if (NULL != temp_client) {
+                               if (NULL != temp_client->lang_cb) {
+                                       temp_client->lang_cb(before_lang, g_config_info->language, temp_client->user_data);
+                               }
+                       }
+
+                       iter = g_slist_next(iter);
+               }
+
+               if (NULL != before_lang) {
+                       free(before_lang);
+               }
+       } else {
+               /* Candidate language is not valid */
+               char* tmp_language = NULL;
+               if (0 != __stt_config_mgr_select_lang(g_config_info->engine_id, &tmp_language)) {
+                       SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to select language");
+                       return -1;
+               }
+
+               if (NULL == tmp_language) {
+                       SLOG(LOG_ERROR, stt_tag(), "[ERROR] Selected language is NULL");
+                       return -1;
+               }
+
+               if (0 != stt_parser_set_language(tmp_language)) {
+                       free(tmp_language);
+                       SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to save config");
+                       return -1;
+               }
+
+               SECURE_SLOG(LOG_DEBUG, stt_tag(), "[Config] Language is auto but display lang is not supported. Default language change(%s)", tmp_language);
+
+               /* Call all callbacks of client*/
+               GSList *iter = NULL;
+               stt_config_client_s* temp_client = NULL;
+
+               iter = g_slist_nth(g_config_client_list, 0);
+
+               while (NULL != iter) {
+                       temp_client = iter->data;
+
+                       if (NULL != temp_client) {
+                               if (NULL != temp_client->lang_cb) {
+                                       temp_client->lang_cb(g_config_info->language, tmp_language, 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);
+               }
+
+               free(tmp_language);
+       }
+
+       return 0;
+}
+
+void __stt_config_language_changed_cb(keynode_t *key, void *data)
+{
+       if (true == g_config_info->auto_lang) {
+               /* Get voice input vconf key */
+               __stt_config_set_auto_language();
+       }
+
+       return;
+}
+
+int stt_config_mgr_initialize(int uid)
+{
+       GSList *iter = NULL;
+       int* get_uid;
+       stt_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) {
+                       get_uid = iter->data;
+
+                       if (uid == *get_uid) {
+                               SECURE_SLOG(LOG_WARN, stt_tag(), "[CONFIG] uid(%d) has already registered", uid);
+                               return 0;
+                       }
+
+                       iter = g_slist_next(iter);
+               }
+
+               temp_client = (stt_config_client_s*)calloc(1, sizeof(stt_config_client_s));
+               temp_client->uid = uid;
+               temp_client->bool_cb = NULL;
+               temp_client->engine_cb = NULL;
+               temp_client->lang_cb = NULL;
+               temp_client->user_data = NULL;
+
+               /* Add uid */
+               g_config_client_list = g_slist_append(g_config_client_list, temp_client);
+
+               SECURE_SLOG(LOG_WARN, stt_tag(), "[CONFIG] Add uid(%d) but config has already initialized", uid);
+               return STT_CONFIG_ERROR_NONE;
+       }
+
+       /* Get file name from default engine directory */
+       DIR *dp = NULL;
+       int ret = -1;
+       struct dirent entry;
+       struct dirent *dirp = NULL;
+
+       g_engine_list = NULL;
+
+       dp  = opendir(STT_DEFAULT_ENGINE_INFO);
+       if (NULL != dp) {
+               do {
+                       ret = readdir_r(dp, &entry, &dirp);
+                       if (0 != ret) {
+                               SLOG(LOG_ERROR, stt_tag(), "[File ERROR] Fail to read directory");
+                               break;
+                       }
+
+                       if (NULL != dirp) {
+                               if (!strcmp(".", dirp->d_name) || !strcmp("..", dirp->d_name))
+                                       continue;
+
+                               stt_engine_info_s* info;
+                               char* filepath;
+                               int filesize;
+
+                               filesize = strlen(STT_DEFAULT_ENGINE_INFO) + strlen(dirp->d_name) + 5;
+                               filepath = (char*)calloc(filesize, sizeof(char));
+
+                               if (NULL != filepath) {
+                                       snprintf(filepath, filesize, "%s/%s", STT_DEFAULT_ENGINE_INFO, dirp->d_name);
+                               } else {
+                                       SLOG(LOG_ERROR, stt_tag(), "[Config ERROR] Memory not enough!!");
+                                       continue;
+                               }
+
+                               if (0 == stt_parser_get_engine_info(filepath, &info)) {
+                                       g_engine_list = g_slist_append(g_engine_list, info);
+                               }
+
+                               if (NULL != filepath)
+                                       free(filepath);
+                       }
+               } while (NULL != dirp);
+
+               closedir(dp);
+       } else {
+               SLOG(LOG_WARN, stt_tag(), "[Config WARNING] Fail to open default directory"); 
+       }
+
+       __stt_config_mgr_print_engine_info();
+
+       if (0 != stt_parser_load_config(&g_config_info)) {
+               SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to parse configure information");
+               return -1; 
+       }
+
+       if (true == g_config_info->auto_lang) {
+               /* Check language with display language */
+               __stt_config_set_auto_language();
+       } else {
+               if (false == __stt_config_mgr_check_lang_is_valid(g_config_info->engine_id, g_config_info->language)) {
+                       /* Default language is not valid */
+                       char* tmp_language;
+                       if (0 != __stt_config_mgr_select_lang(g_config_info->engine_id, &tmp_language)) {
+                               SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to select language");
+                               return -1;
+                       }
+
+                       if (NULL != tmp_language) {
+                               if (NULL != g_config_info->language) {
+                                       free(g_config_info->language);
+                                       g_config_info->language = strdup(tmp_language);
+                               }
+
+                               free(tmp_language);
+                       }
+               }
+       }
+
+       /* print daemon config */
+       SLOG(LOG_DEBUG, stt_tag(), "== Daemon config ==");
+       SECURE_SLOG(LOG_DEBUG, stt_tag(), " engine : %s", g_config_info->engine_id);
+       SECURE_SLOG(LOG_DEBUG, stt_tag(), " setting : %s", g_config_info->setting);
+       SECURE_SLOG(LOG_DEBUG, stt_tag(), " auto language : %s", g_config_info->auto_lang ? "on" : "off");
+       SECURE_SLOG(LOG_DEBUG, stt_tag(), " language : %s", g_config_info->language);
+       SECURE_SLOG(LOG_DEBUG, stt_tag(), " silence detection : %s", g_config_info->silence_detection ? "on" : "off");
+       SLOG(LOG_DEBUG, stt_tag(), "===================");
+
+       if (0 != __stt_config_mgr_register_config_event()) {
+               SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to register config event");
+               return STT_CONFIG_ERROR_OPERATION_FAILED;
+       }
+
+       /* Register to detect display language change */
+       vconf_notify_key_changed(VCONFKEY_LANGSET, __stt_config_language_changed_cb, NULL);
+       vconf_notify_key_changed(VCONFKEY_VOICE_INPUT_LANGUAGE, __stt_config_language_changed_cb, NULL);
+
+       temp_client = (stt_config_client_s*)calloc(1, sizeof(stt_config_client_s));
+       temp_client->uid = uid;
+       temp_client->bool_cb = NULL;
+       temp_client->engine_cb = NULL;
+       temp_client->lang_cb = NULL;
+       temp_client->user_data = NULL;
+
+       /* Add uid */
+       g_config_client_list = g_slist_append(g_config_client_list, temp_client);
+
+       return STT_CONFIG_ERROR_NONE;
+}
+
+int stt_config_mgr_finalize(int uid)
+{
+       GSList *iter = NULL;
+       stt_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);
+                                       temp_client = NULL;
+                                       break;
+                               }
+                       }
+
+                       iter = g_slist_next(iter);
+               }
+       }
+
+       if (0 < g_slist_length(g_config_client_list)) {
+               SLOG(LOG_DEBUG, stt_tag(), "Client count (%d)", g_slist_length(g_config_client_list));
+               return STT_CONFIG_ERROR_NONE;
+       }
+
+       stt_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);
+
+                               stt_parser_free_engine_info(engine_info);
+                       }
+
+                       iter = g_slist_nth(g_engine_list, 0);
+               }
+       }
+
+       vconf_ignore_key_changed(VCONFKEY_LANGSET, __stt_config_language_changed_cb);
+       vconf_ignore_key_changed(VCONFKEY_VOICE_INPUT_LANGUAGE, __stt_config_language_changed_cb);
+
+       __stt_config_mgr_unregister_config_event();
+
+       if (NULL != g_config_info) {
+               stt_parser_unload_config(g_config_info);
+               g_config_info = NULL;
+       }
+
+       return STT_CONFIG_ERROR_NONE;
+}
+
+int stt_config_mgr_set_callback(int uid, stt_config_engine_changed_cb engine_cb, stt_config_lang_changed_cb lang_cb, stt_config_bool_changed_cb bool_cb, void* user_data)
+{
+       GSList *iter = NULL;
+       stt_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->lang_cb = lang_cb;
+                               temp_client->bool_cb = bool_cb;
+                               temp_client->user_data = user_data;
+                       }
+               }
+
+               iter = g_slist_next(iter);
+       }
+
+       return STT_CONFIG_ERROR_NONE;
+}
+
+int stt_config_mgr_unset_callback(int uid)
+{      
+       GSList *iter = NULL;
+       stt_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->lang_cb = NULL;
+                               temp_client->bool_cb = NULL;
+                               temp_client->user_data = NULL;
+                       }
+               }
+
+               iter = g_slist_next(iter);
+       }
+
+       return STT_CONFIG_ERROR_NONE;
+}
+
+int stt_config_mgr_get_engine_list(stt_config_supported_engine_cb callback, void* user_data)
+{
+       if (0 >= g_slist_length(g_config_client_list)) {
+               SLOG(LOG_ERROR, stt_tag(), "Not initialized");
+               return STT_CONFIG_ERROR_INVALID_STATE;
+       }
+
+       if (NULL == callback) {
+               return STT_CONFIG_ERROR_INVALID_PARAMETER;
+       }
+
+       GSList *iter = NULL;
+       stt_engine_info_s *engine_info = NULL;
+
+       if (0 >= g_slist_length(g_engine_list)) {
+               SLOG(LOG_WARN, stt_tag(), "[ERROR] Engine list is NULL");
+               return STT_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, stt_tag(), " Engine info is NULL");
+                       return STT_CONFIG_ERROR_OPERATION_FAILED;
+               }
+
+               if (false == callback(engine_info->uuid, engine_info->name, 
+                       engine_info->setting, engine_info->support_silence_detection, user_data)) {
+                       break;
+               }
+               
+               iter = g_slist_next(iter);
+       }
+
+       return STT_CONFIG_ERROR_NONE;
+}
+
+int stt_config_mgr_get_engine(char** engine)
+{
+       if (0 >= g_slist_length(g_config_client_list)) {
+               SLOG(LOG_ERROR, stt_tag(), "Not initialized");
+               return STT_CONFIG_ERROR_INVALID_STATE;
+       }
+
+       if (NULL == engine) {
+               return STT_CONFIG_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL != g_config_info->engine_id) {
+               *engine = strdup(g_config_info->engine_id);
+       } else {
+               SLOG(LOG_ERROR, stt_tag(), " Engine id is NULL");
+               return STT_CONFIG_ERROR_ENGINE_NOT_FOUND;
+       }
+
+       return STT_CONFIG_ERROR_NONE;
+}
+
+int stt_config_mgr_set_engine(const char* engine)
+{
+       if (0 >= g_slist_length(g_config_client_list)) {
+               SLOG(LOG_ERROR, stt_tag(), "Not initialized");
+               return STT_CONFIG_ERROR_INVALID_STATE;
+       }
+
+       if (NULL == g_config_info) {
+               return STT_CONFIG_ERROR_OPERATION_FAILED;
+       }
+
+       if (NULL == engine || NULL == g_config_info->engine_id) {
+               return STT_CONFIG_ERROR_INVALID_PARAMETER;
+       }
+
+       /* Check current engine id with new engine id */
+       if (0 == strcmp(g_config_info->engine_id, engine)) {
+               return 0;
+       }
+
+       SECURE_SLOG(LOG_DEBUG, stt_tag(), "New engine id : %s", engine);
+
+       GSList *iter = NULL;
+       stt_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, stt_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);
+               } else {
+                       g_config_info->setting = NULL;
+               }
+
+               /* Engine is valid*/
+               GSList *iter_lang = NULL;
+               char* lang;
+               bool is_valid_lang = false;
+
+               /* Get a first item */
+               iter_lang = g_slist_nth(engine_info->languages, 0);
+
+               while (NULL != iter_lang) {
+                       /*Get handle data from list*/
+                       lang = iter_lang->data;
+
+                       SECURE_SLOG(LOG_DEBUG, stt_tag(), " %s", lang);
+                       if (NULL != lang) {
+                               if (0 == strcmp(lang, g_config_info->language)) {
+                                       /* language is valid */
+                                       is_valid_lang = true;
+
+                                       if (NULL != g_config_info->language) {
+                                               free(g_config_info->language);
+
+                                               g_config_info->language = strdup(lang);
+                                       }
+                                       break;
+                               }
+                       }
+
+                       /*Get next item*/
+                       iter_lang = g_slist_next(iter_lang);
+               }
+
+               if (false == is_valid_lang) {
+                       if (NULL != g_config_info->language) {
+                               free(g_config_info->language);
+
+                               iter_lang = g_slist_nth(engine_info->languages, 0);
+                               lang = iter_lang->data;
+
+                               g_config_info->language = strdup(lang);
+                       }
+               }
+
+               /* Check options */
+               if (false == engine_info->support_silence_detection) {
+                       if (true == g_config_info->silence_detection)
+                               g_config_info->silence_detection = false;
+               }
+
+               is_valid_engine = true;
+               break;
+       }
+
+       if (true == is_valid_engine) {
+               SLOG(LOG_DEBUG, stt_tag(), "[Config] Engine changed");
+               SECURE_SLOG(LOG_DEBUG, stt_tag(), "  Engine : %s", g_config_info->engine_id);
+               SECURE_SLOG(LOG_DEBUG, stt_tag(), "  Setting : %s", g_config_info->setting);
+               SECURE_SLOG(LOG_DEBUG, stt_tag(), "  language : %s", g_config_info->language);
+               SECURE_SLOG(LOG_DEBUG, stt_tag(), "  Silence detection : %s", g_config_info->silence_detection ? "on" : "off");
+
+               if ( 0 != stt_parser_set_engine(g_config_info->engine_id, g_config_info->setting, g_config_info->language,
+                       g_config_info->silence_detection)) {
+                               SLOG(LOG_ERROR, stt_tag(), " Fail to save config");
+                               return STT_CONFIG_ERROR_OPERATION_FAILED;
+               }
+       } else {
+               SLOG(LOG_ERROR, stt_tag(), "[ERROR] Engine id is not valid");
+               return STT_CONFIG_ERROR_INVALID_PARAMETER;
+       }
+
+       return 0;
+}
+
+int stt_config_mgr_get_engine_agreement(const char* engine, char** agreement)
+{
+       if (0 >= g_slist_length(g_engine_list)) {
+               SLOG(LOG_ERROR, stt_tag(), "There is no engine");
+               return STT_CONFIG_ERROR_INVALID_STATE;
+       }
+
+       if (NULL == agreement) {
+               SLOG(LOG_ERROR, stt_tag(), "Input parameter is NULL");
+               return STT_CONFIG_ERROR_INVALID_PARAMETER;
+       }
+
+       GSList *iter = NULL;
+       stt_engine_info_s *engine_info = NULL;
+       char* current_engine = NULL;
+
+       if (NULL == engine) {
+               current_engine = strdup(g_config_info->engine_id);
+       } else {
+               current_engine = strdup(engine);
+       }
+
+       /* 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, stt_tag(), "[ERROR] engine info is NULL");
+                       if (NULL != current_engine)     free(current_engine);
+                       return STT_CONFIG_ERROR_OPERATION_FAILED;
+               }
+
+               if (0 != strcmp(current_engine, engine_info->uuid)) {
+                       iter = g_slist_next(iter);
+                       continue;
+               }
+
+               if (NULL != engine_info->agreement) {
+                       *agreement = strdup(engine_info->agreement);
+               } else {
+                       SLOG(LOG_WARN, stt_tag(), "[WARNING] engine agreement is not support");
+               }
+               break;
+       }
+
+       if (NULL != current_engine)     free(current_engine);
+
+       return STT_CONFIG_ERROR_NONE;
+}
+
+int stt_config_mgr_get_language_list(const char* engine_id, stt_config_supported_langauge_cb callback, void* user_data)
+{
+       if (0 >= g_slist_length(g_config_client_list)) {
+               SLOG(LOG_ERROR, stt_tag(), "Not initialized");
+               return STT_CONFIG_ERROR_INVALID_STATE;
+       }
+       
+       if (0 >= g_slist_length(g_engine_list)) {
+               SLOG(LOG_ERROR, stt_tag(), "There is no engine");
+               return STT_CONFIG_ERROR_ENGINE_NOT_FOUND;
+       }
+
+       GSList *iter = NULL;
+       stt_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, stt_tag(), "[ERROR] engine info is NULL");
+                       return STT_CONFIG_ERROR_OPERATION_FAILED;
+               }
+
+               if (0 != strcmp(engine_id, engine_info->uuid)) {
+                       iter = g_slist_next(iter);
+                       continue;
+               }
+
+               GSList *iter_lang = NULL;
+               char* lang;
+               
+               /* Get a first item */
+               iter_lang = g_slist_nth(engine_info->languages, 0);
+
+               while (NULL != iter_lang) {
+                       /*Get handle data from list*/
+                       lang = iter_lang->data;
+
+                       SECURE_SLOG(LOG_DEBUG, stt_tag(), " %s", lang);
+                       if (NULL != lang) {
+                               if (false == callback(engine_info->uuid, lang, user_data))
+                                       break;
+                       }
+                       
+                       /*Get next item*/
+                       iter_lang = g_slist_next(iter_lang);
+               }
+               break;
+       }
+
+       return STT_CONFIG_ERROR_NONE;
+}
+
+int stt_config_mgr_get_default_language(char** language)
+{
+       if (0 >= g_slist_length(g_config_client_list)) {
+               SLOG(LOG_ERROR, stt_tag(), "Not initialized");
+               return STT_CONFIG_ERROR_INVALID_STATE;
+       }
+
+       if (NULL == language) {
+               return STT_CONFIG_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL != g_config_info->language) {
+               *language = strdup(g_config_info->language);
+       } else {
+               SLOG(LOG_ERROR, stt_tag(), " language is NULL");
+               return STT_CONFIG_ERROR_OPERATION_FAILED;
+       }
+
+       return STT_CONFIG_ERROR_NONE;
+}
+
+int stt_config_mgr_set_default_language(const char* language)
+{
+       if (0 >= g_slist_length(g_config_client_list)) {
+               SLOG(LOG_ERROR, stt_tag(), "Not initialized");
+               return STT_CONFIG_ERROR_INVALID_STATE;
+       }
+
+       if (NULL == language) {
+               return STT_CONFIG_ERROR_INVALID_PARAMETER;
+       }
+
+       /* Check language is valid */
+       if (NULL != g_config_info->language) {
+               if (0 != stt_parser_set_language(language)) {
+                       SLOG(LOG_ERROR, stt_tag(), "Fail to save engine id");
+                       return STT_CONFIG_ERROR_OPERATION_FAILED;
+               }
+               free(g_config_info->language);
+               g_config_info->language = strdup(language);
+       } else {
+               SLOG(LOG_ERROR, stt_tag(), " language is NULL");
+               return STT_CONFIG_ERROR_OPERATION_FAILED;
+       }
+
+       return STT_CONFIG_ERROR_NONE;
+}
+
+int stt_config_mgr_get_auto_language(bool* value)
+{
+       if (0 >= g_slist_length(g_config_client_list)) {
+               SLOG(LOG_ERROR, stt_tag(), "Not initialized");
+               return STT_CONFIG_ERROR_INVALID_STATE;
+       }
+
+       if (NULL == value) {
+               return STT_CONFIG_ERROR_INVALID_PARAMETER;
+       }
+
+       *value = g_config_info->auto_lang;
+
+       return STT_CONFIG_ERROR_NONE;
+}
+
+int stt_config_mgr_set_auto_language(bool value)
+{
+       if (0 >= g_slist_length(g_config_client_list)) {
+               SLOG(LOG_ERROR, stt_tag(), "Not initialized");
+               return STT_CONFIG_ERROR_INVALID_STATE;
+       }
+
+       if (g_config_info->auto_lang != value) {
+               /* Check language is valid */
+               if (0 != stt_parser_set_auto_lang(value)) {
+                       SLOG(LOG_ERROR, stt_tag(), "Fail to save engine id");
+                       return STT_CONFIG_ERROR_OPERATION_FAILED;
+               }
+               g_config_info->auto_lang = value;
+
+               if (true == g_config_info->auto_lang) {
+                       __stt_config_set_auto_language();
+               }
+       }
+
+       return STT_CONFIG_ERROR_NONE;
+}
+
+int stt_config_mgr_get_silence_detection(bool* value)
+{
+       if (0 >= g_slist_length(g_config_client_list)) {
+               SLOG(LOG_ERROR, stt_tag(), "Not initialized");
+               return STT_CONFIG_ERROR_INVALID_STATE;
+       }
+
+       if (NULL == value)
+               return STT_CONFIG_ERROR_INVALID_PARAMETER;
+
+       *value = g_config_info->silence_detection;
+
+       return STT_CONFIG_ERROR_NONE;
+}
+
+int stt_config_mgr_set_silence_detection(bool value)
+{
+       if (0 >= g_slist_length(g_config_client_list)) {
+               SLOG(LOG_ERROR, stt_tag(), "Not initialized");
+               return STT_CONFIG_ERROR_INVALID_STATE;
+       }
+
+       if (0 != stt_parser_set_silence_detection(value)) {
+               SLOG(LOG_ERROR, stt_tag(), "Fail to save engine id");
+               return STT_CONFIG_ERROR_OPERATION_FAILED;
+       }
+
+       g_config_info->silence_detection = value;
+
+       return STT_CONFIG_ERROR_NONE;
+}
+
+bool stt_config_check_default_engine_is_valid(const char* engine)
+{
+       if (0 >= g_slist_length(g_config_client_list)) {
+               SLOG(LOG_ERROR, stt_tag(), "Not initialized");
+               return false;
+       }
+
+       if (NULL == engine) {
+               return false;
+       }
+
+       if (0 >= g_slist_length(g_engine_list)) 
+               return false;
+
+       GSList *iter = NULL;
+       stt_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 stt_config_check_default_language_is_valid(const char* language)
+{
+       if (0 >= g_slist_length(g_config_client_list)) {
+               SLOG(LOG_ERROR, stt_tag(), "Not initialized");
+               return false;
+       }
+
+       if (NULL == language) {
+               return false;
+       }
+
+       if (NULL == g_config_info->engine_id) {
+               SLOG(LOG_ERROR, stt_tag(), "[ERROR] Default engine id is NULL");
+               return false;
+       }
+
+       if (0 >= g_slist_length(g_engine_list)) 
+               return false;
+
+       GSList *iter = NULL;
+       stt_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, stt_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_lang = NULL;
+               char* lang;
+
+               /* Get a first item */
+               iter_lang = g_slist_nth(engine_info->languages, 0);
+
+               while (NULL != iter_lang) {
+                       lang = iter_lang->data;
+                       
+                       if (0 == strcmp(language, lang))
+                               return true;
+
+                       /*Get next item*/
+                       iter_lang = g_slist_next(iter_lang);
+               }
+               break;
+       }
+
+       return false;
+}
+
+int __stt_config_mgr_print_engine_info()
+{
+       GSList *iter = NULL;
+       stt_engine_info_s *engine_info = NULL;
+
+       if (0 >= g_slist_length(g_engine_list)) {
+               SLOG(LOG_DEBUG, stt_tag(), "-------------- engine list -----------------");
+               SLOG(LOG_DEBUG, stt_tag(), "  No Engine in engine directory");
+               SLOG(LOG_DEBUG, stt_tag(), "--------------------------------------------");
+               return 0;
+       }
+
+       /* Get a first item */
+       iter = g_slist_nth(g_engine_list, 0);
+
+       SLOG(LOG_DEBUG, stt_tag(), "--------------- engine list -----------------");
+
+       int i = 1;      
+       while (NULL != iter) {
+               engine_info = iter->data;
+
+               SECURE_SLOG(LOG_DEBUG, stt_tag(), "[%dth]", i);
+               SECURE_SLOG(LOG_DEBUG, stt_tag(), " name : %s", engine_info->name);
+               SECURE_SLOG(LOG_DEBUG, stt_tag(), " id   : %s", engine_info->uuid);
+               SECURE_SLOG(LOG_DEBUG, stt_tag(), " setting : %s", engine_info->setting);
+               SECURE_SLOG(LOG_DEBUG, stt_tag(), " agreement : %s", engine_info->agreement);
+
+               SLOG(LOG_DEBUG, stt_tag(), " languages");
+               GSList *iter_lang = NULL;
+               char* lang;
+               if (g_slist_length(engine_info->languages) > 0) {
+                       /* Get a first item */
+                       iter_lang = g_slist_nth(engine_info->languages, 0);
+
+                       int j = 1;      
+                       while (NULL != iter_lang) {
+                               /*Get handle data from list*/
+                               lang = iter_lang->data;
+
+                               SECURE_SLOG(LOG_DEBUG, stt_tag(), "  [%dth] %s", j, lang);
+
+                               /*Get next item*/
+                               iter_lang = g_slist_next(iter_lang);
+                               j++;
+                       }
+               } else {
+                       SLOG(LOG_ERROR, stt_tag(), "  language is NONE");
+               }
+               SECURE_SLOG(LOG_DEBUG, stt_tag(), " silence support : %s", 
+                       engine_info->support_silence_detection ? "true" : "false");
+               iter = g_slist_next(iter);
+               i++;
+       }
+       SLOG(LOG_DEBUG, stt_tag(), "--------------------------------------------");
+
+       return 0;
+}
+
+
+
+/**
+* time info functions
+*/
+static GSList* g_time_list = NULL;
+
+int stt_config_mgr_reset_time_info()
+{
+       /* Remove time info */
+       GSList *iter = NULL;
+       stt_result_time_info_s *data = NULL;
+
+       /* Remove time info */
+       iter = g_slist_nth(g_time_list, 0);
+       while (NULL != iter) {
+               data = iter->data;
+
+               g_time_list = g_slist_remove(g_time_list, data);
+               if (NULL != data) {
+                       if (NULL == data->text) free(data->text);
+                       free(data);
+               }
+
+               /*Get next item*/
+               iter = g_slist_nth(g_time_list, 0);
+       }
+
+       return 0;
+}
+
+int stt_config_mgr_add_time_info(int index, int event, const char* text, long start_time, long end_time)
+{
+       if (NULL == text) {
+               SLOG(LOG_ERROR, stt_tag(), "Invalid paramter : text is NULL");
+               return -1;
+       }
+
+       stt_result_time_info_s *info = (stt_result_time_info_s*)calloc(1, sizeof(stt_result_time_info_s));
+
+       info->index = index;
+       info->event = event;
+       if (NULL != text) {
+               info->text = strdup(text);
+       }
+       info->start_time = start_time;
+       info->end_time = end_time;
+
+       /* Add item to global list */
+       g_time_list = g_slist_append(g_time_list, info);
+
+       return 0;
+}
+
+int stt_config_mgr_foreach_time_info(stt_config_result_time_cb callback, void* user_data)
+{
+       if (NULL == callback) {
+               SLOG(LOG_ERROR, stt_tag(), "[ERROR] Input paramter is NULL : callback function");
+               return STT_CONFIG_ERROR_INVALID_PARAMETER;
+       }
+
+       GSList* temp_time = NULL;
+       int ret;
+       ret = stt_parser_get_time_info(&temp_time);
+       if (0 != ret) {
+               SLOG(LOG_WARN, stt_tag(), "[WARNING] Fail to get time info : %d", ret);
+               return STT_CONFIG_ERROR_OPERATION_FAILED;
+       }
+
+       GSList *iter = NULL;
+       stt_result_time_info_s *data = NULL;
+
+       /* Get a first item */
+       iter = g_slist_nth(temp_time, 0);
+       while (NULL != iter) {
+               data = iter->data;
+
+               if (false == callback(data->index, data->event, data->text, 
+                       data->start_time, data->end_time, user_data)) {
+                       break;
+               }
+
+               /*Get next item*/
+               iter = g_slist_next(iter);
+       }
+
+       /* Remove time info */
+       iter = g_slist_nth(temp_time, 0);
+       while (NULL != iter) {
+               data = iter->data;
+
+               if (NULL != data) {
+                       temp_time = g_slist_remove(temp_time, data);
+
+                       if (NULL == data->text) free(data->text);
+                       free(data);
+               }
+
+               /*Get next item*/
+               iter = g_slist_nth(temp_time, 0);
+       }
+
+       return STT_CONFIG_ERROR_NONE;
+}
+
+int stt_config_mgr_save_time_info_file()
+{
+       if (0 == g_slist_length(g_time_list)) {
+               SLOG(LOG_WARN, stt_tag(), "[WARNING] There is no time info to save");
+               return STT_CONFIG_ERROR_OPERATION_FAILED;
+       }
+
+       int ret = 0;
+       ret = stt_parser_set_time_info(g_time_list);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to save time info : %d", ret);
+               return STT_CONFIG_ERROR_OPERATION_FAILED;
+       }
+
+       return STT_CONFIG_ERROR_NONE;
+}
+
+int stt_config_mgr_remove_time_info_file()
+{
+       stt_parser_clear_time_info();
+
+       return STT_CONFIG_ERROR_NONE;
+}
\ No newline at end of file
diff --git a/common/stt_config_mgr.h b/common/stt_config_mgr.h
new file mode 100644 (file)
index 0000000..010f80e
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+*  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 __STT_CONFIG_MANAGER_H_
+#define __STT_CONFIG_MANAGER_H_
+
+#include <tizen.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum {
+       STT_CONFIG_ERROR_NONE                   = TIZEN_ERROR_NONE,             /**< Successful */
+       STT_CONFIG_ERROR_OUT_OF_MEMORY          = TIZEN_ERROR_OUT_OF_MEMORY,    /**< Out of Memory */
+       STT_CONFIG_ERROR_IO_ERROR               = TIZEN_ERROR_IO_ERROR,         /**< I/O error */
+       STT_CONFIG_ERROR_INVALID_PARAMETER      = TIZEN_ERROR_INVALID_PARAMETER,/**< Invalid parameter */
+       STT_CONFIG_ERROR_PERMISSION_DENIED      = TIZEN_ERROR_PERMISSION_DENIED,/**< Permission denied */
+       STT_CONFIG_ERROR_NOT_SUPPORTED          = TIZEN_ERROR_NOT_SUPPORTED,    /**< STT NOT supported */
+       STT_CONFIG_ERROR_INVALID_STATE          = TIZEN_ERROR_STT | 0x01,       /**< Invalid state */
+       STT_CONFIG_ERROR_INVALID_LANGUAGE       = TIZEN_ERROR_STT | 0x02,       /**< Invalid language */
+       STT_CONFIG_ERROR_ENGINE_NOT_FOUND       = TIZEN_ERROR_STT | 0x03,       /**< No available engine  */    
+       STT_CONFIG_ERROR_OPERATION_FAILED       = TIZEN_ERROR_STT | 0x04,       /**< Operation failed  */
+}stt_config_error_e;
+
+typedef enum {
+       STT_CONFIG_TYPE_OPTION_SILENCE_DETECTION
+}stt_config_type_e;
+
+typedef bool (*stt_config_supported_engine_cb)(const char* engine_id, const char* engine_name, const char* setting, bool support_silence, void* user_data);
+
+typedef bool (*stt_config_supported_langauge_cb)(const char* engine_id, const char* language, void* user_data);
+
+typedef void (*stt_config_engine_changed_cb)(const char* engine_id, const char* setting, const char* language, bool support_silence, void* user_data);
+
+typedef void (*stt_config_lang_changed_cb)(const char* before_language, const char* current_language, void* user_data);
+
+typedef void (*stt_config_bool_changed_cb)(stt_config_type_e type, bool bool_value, void* user_data);
+
+typedef bool (*stt_config_result_time_cb)(int index, int event, const char* text, long start_time, long end_time, void* user_data);
+
+
+int stt_config_mgr_initialize(int uid);
+
+int stt_config_mgr_finalize(int uid);
+
+
+int stt_config_mgr_set_callback(int uid, stt_config_engine_changed_cb engine_cb, stt_config_lang_changed_cb lang_cb, stt_config_bool_changed_cb bool_cb, void* user_data);
+
+int stt_config_mgr_unset_callback(int uid);
+
+
+int stt_config_mgr_get_engine_list(stt_config_supported_engine_cb callback, void* user_data);
+
+int stt_config_mgr_get_engine(char** engine);
+
+int stt_config_mgr_set_engine(const char* engine);
+
+int stt_config_mgr_get_engine_agreement(const char* engine, char** agreement);
+
+int stt_config_mgr_get_language_list(const char* engine_id, stt_config_supported_langauge_cb callback, void* user_data);
+
+int stt_config_mgr_get_default_language(char** language);
+
+int stt_config_mgr_set_default_language(const char* language);
+
+int stt_config_mgr_get_auto_language(bool* value);
+
+int stt_config_mgr_set_auto_language(bool value);
+
+int stt_config_mgr_get_silence_detection(bool* value);
+
+int stt_config_mgr_set_silence_detection(bool value);
+
+bool stt_config_check_default_engine_is_valid(const char* engine);
+
+bool stt_config_check_default_language_is_valid(const char* language);
+
+
+int stt_config_mgr_reset_time_info();
+
+int stt_config_mgr_add_time_info(int index, int event, const char* text, long start_time, long end_time);
+
+int stt_config_mgr_foreach_time_info(stt_config_result_time_cb callback, void* user_data);
+
+
+int stt_config_mgr_save_time_info_file();
+
+int stt_config_mgr_remove_time_info_file();
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STT_CONFIG_MANAGER_H_ */
diff --git a/common/stt_config_parser.c b/common/stt_config_parser.c
new file mode 100644 (file)
index 0000000..564705d
--- /dev/null
@@ -0,0 +1,970 @@
+/*
+*  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 <vconf.h>
+
+#include "stt_defs.h"
+#include "stt_config_parser.h"
+
+
+#define STT_TAG_ENGINE_BASE_TAG                "stt-engine"
+#define STT_TAG_ENGINE_NAME            "name"
+#define STT_TAG_ENGINE_ID              "id"
+#define STT_TAG_ENGINE_SETTING         "setting"
+#define STT_TAG_ENGINE_AGREEMENT       "agreement"
+#define STT_TAG_ENGINE_LANGUAGE_SET    "languages"
+#define STT_TAG_ENGINE_LANGUAGE                "lang"
+#define STT_TAG_ENGINE_SILENCE_SUPPORT "silence-detection-support"
+
+#define STT_TAG_CONFIG_BASE_TAG                "stt-config"
+#define STT_TAG_CONFIG_ENGINE_ID       "engine"
+#define STT_TAG_CONFIG_ENGINE_SETTING  "engine-setting"
+#define STT_TAG_CONFIG_AUTO_LANGUAGE   "auto"
+#define STT_TAG_CONFIG_LANGUAGE                "language"
+#define STT_TAG_CONFIG_SILENCE_DETECTION "silence-detection"
+
+
+#define STT_TAG_TIME_BASE_TAG          "stt-time"
+#define STT_TAG_TIME_INDEX             "index"
+#define STT_TAG_TIME_COUNT             "count"
+#define STT_TAG_TIME_TIME_INFO         "time-info"
+#define STT_TAG_TIME_TEXT              "text-info"
+#define STT_TAG_TIME_START             "start"
+#define STT_TAG_TIME_END               "end"
+
+extern const char* stt_tag();
+
+static xmlDocPtr g_config_doc = NULL;
+
+int stt_parser_get_engine_info(const char* path, stt_engine_info_s** engine_info)
+{
+       if (NULL == path || NULL == engine_info) {
+               SLOG(LOG_ERROR, stt_tag(), "[ERROR] Input parameter is NULL");
+               return -1;
+       }
+
+       xmlDocPtr doc = NULL;
+       xmlNodePtr cur = NULL;
+       xmlChar *key;
+
+       doc = xmlParseFile(path);
+       if (doc == NULL) {
+               return -1;
+       }
+
+       cur = xmlDocGetRootElement(doc);
+       if (cur == NULL) {
+               SLOG(LOG_ERROR, stt_tag(), "[ERROR] Empty document");
+               xmlFreeDoc(doc);
+               return -1;
+       }
+
+       if (xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_ENGINE_BASE_TAG)) {
+               SLOG(LOG_ERROR, stt_tag(), "[ERROR] The wrong type, root node is NOT 'stt-engine'");
+               xmlFreeDoc(doc);
+               return -1;
+       }
+
+       cur = cur->xmlChildrenNode;
+       if (cur == NULL) {
+               SLOG(LOG_ERROR, stt_tag(), "[ERROR] Empty document");
+               xmlFreeDoc(doc);
+               return -1;
+       }
+
+       /* alloc engine info */
+       stt_engine_info_s* temp;
+       temp = (stt_engine_info_s*)calloc(1, sizeof(stt_engine_info_s));
+
+       temp->name = NULL;
+       temp->uuid = NULL;
+       temp->setting = NULL;
+       temp->agreement = NULL;
+       temp->languages = NULL;
+       temp->support_silence_detection = false;
+
+       while (cur != NULL) {
+               if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_ENGINE_NAME)) {
+                       key = xmlNodeGetContent(cur);
+                       if (NULL != key) {
+                               // SLOG(LOG_DEBUG, stt_tag(), "Engine name : %s", (char *)key);
+                               if (NULL != temp->name) free(temp->name);
+                               temp->name = strdup((char*)key);
+                               xmlFree(key);
+                       } else {
+                               SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_ENGINE_NAME);
+                       }
+               } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_ENGINE_ID)) {
+                       key = xmlNodeGetContent(cur);
+                       if (NULL != key) {
+                               // SLOG(LOG_DEBUG, stt_tag(), "Engine uuid : %s", (char *)key);
+                               if (NULL != temp->uuid) free(temp->uuid);
+                               temp->uuid = strdup((char*)key);
+                               xmlFree(key);
+                       } else {
+                               SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_ENGINE_ID);
+                       }
+               } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_ENGINE_SETTING)) {
+                       key = xmlNodeGetContent(cur);
+                       if (NULL != key) {
+                               SLOG(LOG_DEBUG, stt_tag(), "Engine setting : %s", (char *)key);
+                               if (NULL != temp->setting)      free(temp->setting);
+                               temp->setting = strdup((char*)key);
+                               xmlFree(key);
+                       } else {
+                               SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_ENGINE_SETTING);
+                       }
+               } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_ENGINE_AGREEMENT)) {
+                       key = xmlNodeGetContent(cur);
+                       if (NULL != key) {
+                               SLOG(LOG_DEBUG, stt_tag(), "Engine agreement : %s", (char *)key);
+                               if (NULL != temp->agreement)    free(temp->agreement);
+                               temp->agreement = strdup((char*)key);
+                               xmlFree(key);
+                       } else {
+                               SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_ENGINE_AGREEMENT);
+                       }
+               } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_ENGINE_LANGUAGE_SET)) {
+                       xmlNodePtr lang_node = NULL;
+                       char* temp_lang = NULL;
+
+                       lang_node = cur->xmlChildrenNode;
+
+                       while (lang_node != NULL) {
+                               if (0 == xmlStrcmp(lang_node->name, (const xmlChar *)STT_TAG_ENGINE_LANGUAGE)){
+                                       key = xmlNodeGetContent(lang_node);
+                                       if (NULL != key) {
+                                               // SLOG(LOG_DEBUG, stt_tag(), "language : %s", (char *)key);
+                                               temp_lang = strdup((char*)key);
+                                               temp->languages = g_slist_append(temp->languages, temp_lang);
+                                               xmlFree(key);
+                                       } else {
+                                               SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_ENGINE_LANGUAGE);
+                                       }
+                               }
+
+                               lang_node = lang_node->next;
+                       }
+               } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_ENGINE_SILENCE_SUPPORT)) {
+                       key = xmlNodeGetContent(cur);
+                       if (NULL != key) {
+                               //SLOG(LOG_DEBUG, stt_tag(), "silence-detection-support : %s", (char *)key);
+
+                               if (0 == xmlStrcmp(key, (const xmlChar *)"true"))
+                                       temp->support_silence_detection = true;
+                               else
+                                       temp->support_silence_detection = false;
+                               
+                               xmlFree(key);
+                       } else {
+                               SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_ENGINE_SILENCE_SUPPORT);
+                       }
+               } else {
+
+               }
+
+               cur = cur->next;
+       }
+
+       xmlFreeDoc(doc);
+
+       if (NULL == temp->name || NULL == temp->uuid) {
+               /* Invalid engine */
+               SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] Invalid engine : %s", path);
+               stt_parser_free_engine_info(temp);
+               return -1;
+       }
+
+       *engine_info = temp;
+
+       return 0;
+}
+
+int stt_parser_free_engine_info(stt_engine_info_s* engine_info)
+{
+       if (NULL == engine_info) {
+               SLOG(LOG_ERROR, stt_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);
+       if (NULL != engine_info->agreement)     free(engine_info->agreement);
+
+       int count = g_slist_length(engine_info->languages);
+
+       int i ;
+       char *temp_lang;
+
+       for (i = 0;i < count ;i++) {
+               temp_lang = g_slist_nth_data(engine_info->languages, 0);
+
+               if (NULL != temp_lang) {
+                       engine_info->languages = g_slist_remove(engine_info->languages, temp_lang);
+
+                       if (NULL != temp_lang)
+                               free(temp_lang);
+               } 
+       }
+
+       if (NULL != engine_info)        free(engine_info);
+
+       return 0;       
+}
+
+int stt_parser_print_engine_info(stt_engine_info_s* engine_info)
+{
+       if (NULL == engine_info)
+               return -1;
+
+       SLOG(LOG_DEBUG, stt_tag(), "== get engine info ==");
+       SECURE_SLOG(LOG_DEBUG, stt_tag(), " name : %s", engine_info->name);
+       SECURE_SLOG(LOG_DEBUG, stt_tag(), " id   : %s", engine_info->uuid);
+       if (NULL != engine_info->setting)       SECURE_SLOG(LOG_DEBUG, stt_tag(), " setting : %s", engine_info->setting);
+
+       SLOG(LOG_DEBUG, stt_tag(), " languages");
+       GSList *iter = NULL;
+       char* lang;
+       if (g_slist_length(engine_info->languages) > 0) {
+               /* Get a first item */
+               iter = g_slist_nth(engine_info->languages, 0);
+
+               int i = 1;      
+               while (NULL != iter) {
+                       /*Get handle data from list*/
+                       lang = iter->data;
+
+                       SECURE_SLOG(LOG_DEBUG, stt_tag(), "  [%dth] %s", i, lang);
+
+                       /*Get next item*/
+                       iter = g_slist_next(iter);
+                       i++;
+               }
+       } else {
+               SLOG(LOG_ERROR, stt_tag(), "  language is NONE");
+       }
+       SECURE_SLOG(LOG_DEBUG, stt_tag(), " silence support : %s", engine_info->support_silence_detection ? "true" : "false");
+       SLOG(LOG_DEBUG, stt_tag(), "=====================");
+
+       return 0;
+}
+
+int stt_parser_load_config(stt_config_s** config_info)
+{
+       if (NULL == config_info) {
+               SLOG(LOG_ERROR, stt_tag(), "[ERROR] Input parameter is NULL");
+               return -1;
+       }
+
+       xmlDocPtr doc = NULL;
+       xmlNodePtr cur = NULL;
+       xmlChar *key;
+       bool is_default_open = false;
+
+       doc = xmlParseFile(STT_CONFIG);
+       if (doc == NULL) {
+               doc = xmlParseFile(STT_DEFAULT_CONFIG);
+               if (doc == NULL) {
+                       SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to parse file error : %s", STT_DEFAULT_CONFIG);
+                       return -1;
+               }
+               is_default_open = true;
+       }
+
+       cur = xmlDocGetRootElement(doc);
+       if (cur == NULL) {
+               SLOG(LOG_ERROR, stt_tag(), "[ERROR] Empty document");
+               xmlFreeDoc(doc);
+               return -1;
+       }
+
+       if (xmlStrcmp(cur->name, (const xmlChar *) STT_TAG_CONFIG_BASE_TAG)) {
+               SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] The wrong type, root node is NOT %s", STT_TAG_CONFIG_BASE_TAG);
+               xmlFreeDoc(doc);
+               return -1;
+       }
+
+       cur = cur->xmlChildrenNode;
+       if (cur == NULL) {
+               SLOG(LOG_ERROR, stt_tag(), "[ERROR] Empty document");
+               xmlFreeDoc(doc);
+               return -1;
+       }
+
+       /* alloc engine info */
+       stt_config_s* temp;
+       temp = (stt_config_s*)calloc(1, sizeof(stt_config_s));
+
+       temp->engine_id = NULL;
+       temp->setting = NULL;
+       temp->language = NULL;
+
+       while (cur != NULL) {
+               if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_CONFIG_ENGINE_ID)) {
+                       key = xmlNodeGetContent(cur);
+                       if (NULL != key) {
+                               //SLOG(LOG_DEBUG, stt_tag(), "Engine id : %s", (char *)key);
+                               if (NULL != temp->engine_id)    free(temp->engine_id);
+                               temp->engine_id = strdup((char*)key);
+                               xmlFree(key);
+                       } else {
+                               SLOG(LOG_ERROR, stt_tag(), "[ERROR] engine id is NULL");
+                       }
+               } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_CONFIG_ENGINE_SETTING)) {
+                       key = xmlNodeGetContent(cur);
+                       if (NULL != key) {
+                               //SECURE_SLOG(LOG_DEBUG, stt_tag(), "Setting path : %s", (char *)key);
+                               if (NULL != temp->setting)      free(temp->setting);
+                               temp->setting = strdup((char*)key);
+                               xmlFree(key);
+                       } else {
+                               SLOG(LOG_ERROR, stt_tag(), "[ERROR] setting path is NULL");
+                       }
+
+               } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_CONFIG_AUTO_LANGUAGE)) {
+                       key = xmlNodeGetContent(cur);
+                       if (NULL != key) {
+                               //SECURE_SLOG(LOG_DEBUG, stt_tag(), "Auto language : %s", (char *)key);
+
+                               if (0 == xmlStrcmp(key, (const xmlChar *)"on")) {
+                                       temp->auto_lang = true;
+                               } else if (0 == xmlStrcmp(key, (const xmlChar *)"off")) {
+                                       temp->auto_lang = false;
+                               } else {
+                                       SLOG(LOG_ERROR, stt_tag(), "Auto voice is wrong");
+                                       temp->auto_lang = true;
+                               }
+
+                               xmlFree(key);
+                       } else {
+                               SLOG(LOG_ERROR, stt_tag(), "[ERROR] auto langauge is NULL");
+                       }
+               } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_CONFIG_LANGUAGE)) {
+                       key = xmlNodeGetContent(cur);
+                       if (NULL != key) {
+                               //SLOG(LOG_DEBUG, stt_tag(), "language : %s", (char *)key);
+                               if (NULL != temp->language)     free(temp->language);
+                               temp->language = strdup((char*)key);
+                               xmlFree(key);
+                       } else {
+                               SLOG(LOG_ERROR, stt_tag(), "[ERROR] language is NULL");
+                       }
+               } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_CONFIG_SILENCE_DETECTION)) {
+                       key = xmlNodeGetContent(cur);
+                       if (NULL != key) {
+                               //SLOG(LOG_DEBUG, stt_tag(), "silence-detection : %s", (char *)key);
+
+                               if (0 == xmlStrcmp(key, (const xmlChar *)"on"))
+                                       temp->silence_detection = true;
+                               else
+                                       temp->silence_detection = false;
+
+                               xmlFree(key);
+                       } else {
+                               SLOG(LOG_ERROR, stt_tag(), "[ERROR] silence-detection is NULL");
+                       }
+               } else {
+
+               }
+
+               cur = cur->next;
+       }
+
+       *config_info = temp;
+       g_config_doc = doc;
+
+       if (is_default_open)
+               xmlSaveFile(STT_CONFIG, g_config_doc);
+
+       return 0;
+}
+
+int stt_parser_unload_config(stt_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 stt_parser_set_engine(const char* engine_id, const char* setting, const char* language, bool silence)
+{
+       if (NULL == g_config_doc || NULL == engine_id)
+               return -1;
+
+       xmlNodePtr cur = NULL;
+       cur = xmlDocGetRootElement(g_config_doc);
+       if (cur == NULL) {
+               SLOG(LOG_ERROR, stt_tag(), "[ERROR] Empty document");
+               return -1;
+       }
+
+       if (xmlStrcmp(cur->name, (const xmlChar *) STT_TAG_CONFIG_BASE_TAG)) {
+               SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] The wrong type, root node is NOT %s", STT_TAG_CONFIG_BASE_TAG);
+               return -1;
+       }
+
+       cur = cur->xmlChildrenNode;
+       if (cur == NULL) {
+               SLOG(LOG_ERROR, stt_tag(), "[ERROR] Empty document");
+               return -1;
+       }
+
+       while (cur != NULL) {
+               if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_CONFIG_ENGINE_ID)) {
+                       xmlNodeSetContent(cur, (const xmlChar *)engine_id);
+               }
+
+               if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_CONFIG_LANGUAGE)) {
+                       xmlNodeSetContent(cur, (const xmlChar *)language);
+               }
+
+               if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_CONFIG_ENGINE_SETTING)) {
+                       xmlNodeSetContent(cur, (const xmlChar *)setting);
+               }
+
+               if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_CONFIG_SILENCE_DETECTION)) {
+                       if (true == silence)
+                               xmlNodeSetContent(cur, (const xmlChar *)"on");
+                       else 
+                               xmlNodeSetContent(cur, (const xmlChar *)"off");
+               }
+
+               cur = cur->next;
+       }
+
+       int ret = xmlSaveFile(STT_CONFIG, g_config_doc);
+       SLOG(LOG_DEBUG, stt_tag(), "Save result : %d", ret);
+
+       return 0;
+}
+
+int stt_parser_set_language(const char* language)
+{
+       if (NULL == g_config_doc || NULL == language)
+               return -1;
+
+       xmlNodePtr cur = NULL;
+       cur = xmlDocGetRootElement(g_config_doc);
+       if (cur == NULL) {
+               SLOG(LOG_ERROR, stt_tag(), "[ERROR] Empty document");
+               return -1;
+       }
+
+       if (xmlStrcmp(cur->name, (const xmlChar *) STT_TAG_CONFIG_BASE_TAG)) {
+               SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] The wrong type, root node is NOT %s", STT_TAG_CONFIG_BASE_TAG);
+               return -1;
+       }
+
+       cur = cur->xmlChildrenNode;
+       if (cur == NULL) {
+               SLOG(LOG_ERROR, stt_tag(), "[ERROR] Empty document");
+               return -1;
+       }
+
+       while (cur != NULL) {
+               if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_CONFIG_LANGUAGE)) {
+                       xmlNodeSetContent(cur, (const xmlChar *)language);
+               } 
+
+               cur = cur->next;
+       }
+
+       int ret = xmlSaveFile(STT_CONFIG, g_config_doc);
+       SLOG(LOG_DEBUG, stt_tag(), "Save result : %d", ret);
+
+
+       return 0;
+}
+
+int stt_parser_set_auto_lang(bool value)
+{
+       if (NULL == g_config_doc)
+               return -1;
+
+       xmlNodePtr cur = NULL;
+       cur = xmlDocGetRootElement(g_config_doc);
+       if (cur == NULL) {
+               SLOG(LOG_ERROR, stt_tag(), "[ERROR] Empty document");
+               return -1;
+       }
+
+       if (xmlStrcmp(cur->name, (const xmlChar *) STT_TAG_CONFIG_BASE_TAG)) {
+               SLOG(LOG_ERROR, stt_tag(), "[ERROR] The wrong type, root node is NOT %s", STT_TAG_CONFIG_BASE_TAG);
+               return -1;
+       }
+
+       cur = cur->xmlChildrenNode;
+       if (cur == NULL) {
+               SLOG(LOG_ERROR, stt_tag(), "[ERROR] Empty document");
+               return -1;
+       }
+
+       while (cur != NULL) {
+               if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_CONFIG_AUTO_LANGUAGE)) {
+                       if (true == value) {
+                               xmlNodeSetContent(cur, (const xmlChar *)"on");
+                       } else if (false == value) {
+                               xmlNodeSetContent(cur, (const xmlChar *)"off");
+                       } else {
+                               SLOG(LOG_ERROR, stt_tag(), "[ERROR] The wrong value of auto voice");
+                               return -1;
+                       }
+                       break;
+               }
+               cur = cur->next;
+       }
+
+       int ret = xmlSaveFile(STT_CONFIG, g_config_doc);
+       SLOG(LOG_DEBUG, stt_tag(), "Save result : %d", ret);
+
+       return 0;
+}
+
+int stt_parser_set_silence_detection(bool value)
+{
+       if (NULL == g_config_doc)
+               return -1;
+
+       xmlNodePtr cur = NULL;
+       cur = xmlDocGetRootElement(g_config_doc);
+       if (cur == NULL) {
+               SLOG(LOG_ERROR, stt_tag(), "[ERROR] Empty document");
+               return -1;
+       }
+
+       if (xmlStrcmp(cur->name, (const xmlChar *) STT_TAG_CONFIG_BASE_TAG)) {
+               SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] The wrong type, root node is NOT %s", STT_TAG_CONFIG_BASE_TAG);
+               return -1;
+       }
+
+       cur = cur->xmlChildrenNode;
+       if (cur == NULL) {
+               SLOG(LOG_ERROR, stt_tag(), "[ERROR] Empty document");
+               return -1;
+       }
+
+       while (cur != NULL) {
+               if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_CONFIG_SILENCE_DETECTION)) {
+                       if (true == value)
+                               xmlNodeSetContent(cur, (const xmlChar *)"on");
+                       else 
+                               xmlNodeSetContent(cur, (const xmlChar *)"off");
+               } 
+
+               cur = cur->next;
+       }
+
+       int ret = xmlSaveFile(STT_CONFIG, g_config_doc);
+       SLOG(LOG_DEBUG, stt_tag(), "Save result : %d", ret);
+
+       return 0;
+}
+
+int stt_parser_find_config_changed(char** engine, char** setting, int* auto_lang, char** language, int* silence)
+{
+       if (NULL == engine || NULL == language || NULL == silence) {
+               SLOG(LOG_ERROR, stt_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;
+
+       doc = xmlParseFile(STT_CONFIG);
+       if (doc == NULL) {
+               SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to parse file error : %s", STT_CONFIG);
+               return -1;
+       }
+
+       cur_new = xmlDocGetRootElement(doc);
+       cur_old = xmlDocGetRootElement(g_config_doc);
+       if (cur_new == NULL || cur_old == NULL) {
+               SLOG(LOG_ERROR, stt_tag(), "[ERROR] Empty document");
+               xmlFreeDoc(doc);
+               return -1;
+       }
+
+       if (xmlStrcmp(cur_new->name, (const xmlChar*)STT_TAG_CONFIG_BASE_TAG) || xmlStrcmp(cur_old->name, (const xmlChar*)STT_TAG_CONFIG_BASE_TAG)) {
+               SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] The wrong type, root node is NOT %s", STT_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, stt_tag(), "[ERROR] Empty document");
+               xmlFreeDoc(doc);
+               return -1;
+       }
+
+       *engine = NULL;
+       *setting = NULL;
+       *language = NULL;
+
+       while (cur_new != NULL && cur_old != NULL) {
+               if (0 == xmlStrcmp(cur_new->name, (const xmlChar*)STT_TAG_CONFIG_ENGINE_ID)) {
+                       if (0 == xmlStrcmp(cur_old->name, (const xmlChar*)STT_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)) {
+                                                       SECURE_SLOG(LOG_DEBUG, stt_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, stt_tag(), "[ERROR] Old config and new config are different");
+                       }
+               } else if (0 == xmlStrcmp(cur_new->name, (const xmlChar*)STT_TAG_CONFIG_ENGINE_SETTING)) {
+                       if (0 == xmlStrcmp(cur_old->name, (const xmlChar*)STT_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, stt_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, stt_tag(), "[ERROR] Old config and new config are different");
+                       }
+               } else if (0 == xmlStrcmp(cur_new->name, (const xmlChar*)STT_TAG_CONFIG_AUTO_LANGUAGE)) {
+                       if (0 == xmlStrcmp(cur_old->name, (const xmlChar*)STT_TAG_CONFIG_AUTO_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, stt_tag(), "Old auto lang(%s), New auto lang(%s)", (char*)key_old, (char*)key_new);
+                                                       if (0 == xmlStrcmp((const xmlChar*)"on", key_new)) {
+                                                               *auto_lang = (int)true;
+                                                       } else {
+                                                               *auto_lang = (int)false;
+                                                       }
+                                               }
+
+                                               xmlFree(key_new);
+                                       }
+                                       xmlFree(key_old);
+                               }
+                       } else {
+                               SLOG(LOG_ERROR, stt_tag(), "[ERROR] old config and new config are different");
+                       }
+               } else if (0 == xmlStrcmp(cur_new->name, (const xmlChar*)STT_TAG_CONFIG_LANGUAGE)) {
+                       if (0 == xmlStrcmp(cur_old->name, (const xmlChar*)STT_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)) {
+                                                       SECURE_SLOG(LOG_DEBUG, stt_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, stt_tag(), "[ERROR] old config and new config are different");
+                       }
+               } else if (0 == xmlStrcmp(cur_new->name, (const xmlChar*)STT_TAG_CONFIG_SILENCE_DETECTION)) {
+                       if (0 == xmlStrcmp(cur_old->name, (const xmlChar*)STT_TAG_CONFIG_SILENCE_DETECTION)) {
+                               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)) {
+                                                       SECURE_SLOG(LOG_DEBUG, stt_tag(), "Old silence(%s), New silence(%s)", (char*)key_old, (char*)key_new);
+                                                       if (0 == xmlStrcmp(key_new, (const xmlChar*)"on")) {
+                                                               *silence = 1;
+                                                       } else {
+                                                               *silence = 0;
+                                                       }
+                                               }
+                                               
+                                               xmlFree(key_new);
+                                       }
+                                       xmlFree(key_old);
+                               }
+                       } else {
+                               SLOG(LOG_ERROR, stt_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;
+}
+
+/**
+* time function
+*/
+
+int stt_parser_set_time_info(GSList* time_list)
+{
+       if (0 == g_slist_length(time_list)) {
+               SLOG(LOG_WARN, stt_tag(), "[WARNING] There is no time info to save");
+               return -1;
+       }
+
+       if (-1 == remove(STT_TIME_INFO_PATH)) {
+               SECURE_SLOG(LOG_WARN, stt_tag(), "[PLAYER WARNING] Fail to remove file(%s)", STT_TIME_INFO_PATH);
+       }
+
+       xmlDocPtr doc = NULL;
+       xmlNodePtr cur = NULL;
+
+       doc = xmlNewDoc((const xmlChar*)"1.0");
+       if (doc == NULL) {
+               SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to make new doc");
+               return -1;
+       }
+
+       cur = xmlNewNode(NULL, (const xmlChar*)STT_TAG_TIME_BASE_TAG);
+       xmlDocSetRootElement(doc, cur);
+
+       xmlNodePtr inode = NULL;
+       GSList *iter = NULL;
+       stt_result_time_info_s *data = NULL;
+       char temp_str[256];
+
+       snprintf(temp_str, 256, "%d", g_slist_length(time_list));
+
+       inode = xmlNewNode(NULL, (const xmlChar*)STT_TAG_TIME_INDEX);
+       xmlNewProp(inode, (const xmlChar*)STT_TAG_TIME_COUNT, (const xmlChar*)temp_str);
+       xmlAddChild(cur, inode);
+
+       /* Get a first item */
+       iter = g_slist_nth(time_list, 0);
+       while (NULL != iter) {
+               data = iter->data;
+               
+               xmlNodePtr temp_node = NULL;
+
+               SLOG(LOG_DEBUG, stt_tag(), "[%d] i(%d) t(%s) s(%d) e(%d)", 
+                       data->index, data->event, data->text, data->start_time, data->end_time);
+               
+               temp_node = xmlNewNode(NULL, (const xmlChar*)STT_TAG_TIME_TEXT);
+               xmlNodeSetContent(temp_node, (const xmlChar*)data->text);
+               xmlAddChild(inode, temp_node);
+       
+               temp_node = xmlNewNode(NULL, (const xmlChar*)STT_TAG_TIME_START);
+               snprintf(temp_str, 256, "%ld", data->start_time);
+               xmlNodeSetContent(temp_node, (const xmlChar*)temp_str);
+               xmlAddChild(inode, temp_node);
+
+               temp_node = xmlNewNode(NULL, (const xmlChar*)STT_TAG_TIME_END);
+               snprintf(temp_str, 256, "%ld", data->end_time);
+               xmlNodeSetContent(temp_node, (const xmlChar*)temp_str);
+               xmlAddChild(inode, temp_node);
+
+               /*Get next item*/
+               iter = g_slist_next(iter);
+       }
+
+       int ret = xmlSaveFormatFile(STT_TIME_INFO_PATH, doc, 1);
+       SLOG(LOG_DEBUG, stt_tag(), "Save result : %d", ret);
+
+       xmlFreeDoc(doc);
+       return 0;
+}
+
+int stt_parser_get_time_info(GSList** time_list)
+{
+       if (NULL == time_list) {
+               SLOG(LOG_ERROR, stt_tag(), "Invalid paramter : text is NULL");
+               return -1;
+       }
+
+       xmlDocPtr doc = NULL;
+       xmlNodePtr cur = NULL;
+
+       doc = xmlParseFile(STT_TIME_INFO_PATH);
+       if (doc == NULL) {
+               SLOG(LOG_WARN, stt_tag(), "[WARNING] File is not exist");
+               return -1;
+       }
+
+       cur = xmlDocGetRootElement(doc);
+       if (cur == NULL) {
+               SLOG(LOG_ERROR, stt_tag(), "[ERROR] Empty document");
+               xmlFreeDoc(doc);
+               return -1;
+       }
+
+       if (xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_TIME_BASE_TAG)) {
+               SLOG(LOG_ERROR, stt_tag(), "[ERROR] The wrong type, root node is NOT '%s'", STT_TAG_TIME_BASE_TAG);
+               xmlFreeDoc(doc);
+               return -1;
+       }
+
+       cur = cur->xmlChildrenNode;
+       if (cur == NULL) {
+               SLOG(LOG_ERROR, stt_tag(), "[ERROR] Empty document");
+               xmlFreeDoc(doc);
+               return -1;
+       }
+
+       /* alloc time info */
+       GSList *temp_time_list = NULL;
+       xmlChar *key = NULL;
+       int index = 0;
+
+       while (cur != NULL) {
+               if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_TIME_INDEX)) {
+                       key = xmlGetProp(cur, (const xmlChar*)STT_TAG_TIME_COUNT);
+                       if (NULL == key) {
+                               SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_TIME_COUNT);
+                               return -1;
+                       }
+                       
+                       SLOG(LOG_DEBUG, stt_tag(), "Count : %s", (char *)key);
+
+                       /* Get time count */
+                       int count = 0;
+                       count = atoi((char*)key);
+                       xmlFree(key);
+
+                       if (count <= 0) {
+                               SLOG(LOG_ERROR, stt_tag(), "[ERROR] count is invalid : %d", count);
+                               break;
+                       }
+
+                       xmlNodePtr time_node = NULL;
+                       time_node = cur->xmlChildrenNode;
+
+                       int i = 0;
+                       for (i = 0;i < count;i++) {
+                               /* text */
+                               time_node = time_node->next;
+
+                               stt_result_time_info_s* temp_info;
+                               temp_info = (stt_result_time_info_s*)calloc(1, sizeof(stt_result_time_info_s));
+
+                               if (NULL == temp_info) {
+                                       SLOG(LOG_ERROR, stt_tag(), "[ERROR] Memory alloc error!!");
+                                       return -1;
+                               }
+
+                               temp_info->index = index;
+                               SLOG(LOG_DEBUG, stt_tag(), "index : %d", temp_info->index);
+
+                               if (0 == i)             temp_info->event = 0;
+                               else if (count -1 == i) temp_info->event = 2;
+                               else                    temp_info->event = 1;
+
+                               if (0 == xmlStrcmp(time_node->name, (const xmlChar *)STT_TAG_TIME_TEXT)) {
+                                       key = xmlNodeGetContent(time_node);
+                                       if (NULL != key) {
+                                               SLOG(LOG_DEBUG, stt_tag(), "text : %s", (char *)key);
+                                               temp_info->text = strdup((char*)key);
+                                               xmlFree(key);
+                                       } else {
+                                               SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_TIME_TEXT);
+                                               free(temp_info);
+                                               break;
+                                       }
+                               }
+
+                               /* text */
+                               time_node = time_node->next;
+                               time_node = time_node->next;
+
+                               if (0 == xmlStrcmp(time_node->name, (const xmlChar *)STT_TAG_TIME_START)) {
+                                       key = xmlNodeGetContent(time_node);
+                                       if (NULL != key) {
+                                               SLOG(LOG_DEBUG, stt_tag(), "Start time : %s", (char *)key);
+                                               temp_info->start_time = atoi((char*)key);
+                                               xmlFree(key);
+                                       } else {
+                                               SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_TIME_START);
+                                               if (NULL != temp_info->text)    free(temp_info->text);
+                                               free(temp_info);
+                                               break;
+                                       }
+                               }
+                               
+                               /* text */
+                               time_node = time_node->next;
+                               time_node = time_node->next;
+
+                               if (0 == xmlStrcmp(time_node->name, (const xmlChar *)STT_TAG_TIME_END)) {
+                                       key = xmlNodeGetContent(time_node);
+                                       if (NULL != key) {
+                                               SLOG(LOG_DEBUG, stt_tag(), "End time : %s", (char *)key);
+                                               temp_info->end_time = atoi((char*)key);
+                                               xmlFree(key);
+                                       } else {
+                                               SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_TIME_END);
+                                               if (NULL != temp_info->text)    free(temp_info->text);
+                                               free(temp_info);
+                                               break;
+                                       }
+                               }
+
+                               time_node = time_node->next;
+
+                               temp_time_list = g_slist_append(temp_time_list, temp_info);
+                       } /* for */
+                       index++;
+               } /* if */
+               cur = cur->next;
+       }
+
+       xmlFreeDoc(doc);
+
+       *time_list = temp_time_list;
+
+       return 0;
+}
+
+int stt_parser_clear_time_info()
+{
+       if (-1 == remove(STT_TIME_INFO_PATH)) {
+               SECURE_SLOG(LOG_WARN, stt_tag(), "[PLAYER WARNING] Fail to remove file(%s)", STT_TIME_INFO_PATH);
+       }
+
+       return 0;
+}
diff --git a/common/stt_config_parser.h b/common/stt_config_parser.h
new file mode 100644 (file)
index 0000000..6fa65ad
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+*  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 __STT_CONFIG_PARSER_H_
+#define __STT_CONFIG_PARSER_H_
+
+#include <glib.h>
+#include <libxml/parser.h>
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+       char*   name;
+       char*   uuid;
+       char*   setting;
+       char*   agreement;
+       GSList* languages;
+       bool    support_silence_detection;
+}stt_engine_info_s;
+
+typedef struct {
+       char*   engine_id;
+       char*   setting;
+       bool    auto_lang;
+       char*   language;
+       bool    silence_detection;
+}stt_config_s;
+
+typedef struct {
+       int     index;
+       int     event;
+       char*   text;
+       long    start_time;
+       long    end_time;
+}stt_result_time_info_s;
+
+/* Get engine information */
+int stt_parser_get_engine_info(const char* path, stt_engine_info_s** engine_info);
+
+int stt_parser_free_engine_info(stt_engine_info_s* engine_info);
+
+
+int stt_parser_load_config(stt_config_s** config_info);
+
+int stt_parser_unload_config(stt_config_s* config_info);
+
+int stt_parser_set_engine(const char* engine_id, const char* setting, const char* language, bool silence);
+
+int stt_parser_set_language(const char* language);
+
+int stt_parser_set_auto_lang(bool value);
+
+int stt_parser_set_silence_detection(bool value);
+
+int stt_parser_find_config_changed(char** engine, char** setting, int* auto_lang, char** language, int* silence);
+
+
+/* Time info */
+int stt_parser_set_time_info(GSList* time_list);
+
+int stt_parser_get_time_info(GSList** time_list);
+
+int stt_parser_clear_time_info();
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STT_CONFIG_PARSER_H_ */
index b97f9ab..4f6fb23 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
@@ -23,17 +23,13 @@ extern "C" {
 * Definition for Dbus
 *******************************************************************************************/
 
-#define STT_CLIENT_SERVICE_NAME         "com.samsung.voice.sttclient"
-#define STT_CLIENT_SERVICE_OBJECT_PATH  "/com/samsung/voice/sttclient"
-#define STT_CLIENT_SERVICE_INTERFACE    "com.samsung.voice.sttclient"
-
-#define STT_SETTING_SERVICE_NAME        "com.samsung.voice.sttsetting"
-#define STT_SETTING_SERVICE_OBJECT_PATH "/com/samsung/voice/sttsetting"
-#define STT_SETTING_SERVICE_INTERFACE   "com.samsung.voice.sttsetting"
+#define STT_CLIENT_SERVICE_NAME         "org.tizen.voice.sttclient"
+#define STT_CLIENT_SERVICE_OBJECT_PATH  "/org/tizen/voice/sttclient"
+#define STT_CLIENT_SERVICE_INTERFACE    "org.tizen.voice.sttclient"
 
 #define STT_SERVER_SERVICE_NAME         "service.connect.sttserver"
-#define STT_SERVER_SERVICE_OBJECT_PATH  "/com/samsung/voice/sttserver"
-#define STT_SERVER_SERVICE_INTERFACE    "com.samsung.voice.sttserver"
+#define STT_SERVER_SERVICE_OBJECT_PATH  "/org/tizen/voice/sttserver"
+#define STT_SERVER_SERVICE_INTERFACE    "org.tizen.voice.sttserver"
 
 
 /******************************************************************************************
@@ -43,9 +39,16 @@ extern "C" {
 #define STT_METHOD_HELLO               "stt_method_hello"
 #define STT_METHOD_INITIALIZE          "stt_method_initialize"
 #define STT_METHOD_FINALIZE            "stt_method_finalilze"
+#define STT_METHOD_SET_CURRENT_ENGINE  "stt_method_set_current_engine"
 #define STT_METHOD_GET_SUPPORT_LANGS   "stt_method_get_support_langs"
 #define STT_METHOD_GET_CURRENT_LANG    "stt_method_get_current_lang"
-#define STT_METHOD_IS_PARTIAL_SUPPORTED        "stt_method_is_partial_result_supported"
+#define STT_METHOD_IS_TYPE_SUPPORTED   "stt_method_is_recognition_type_supported"
+#define STT_METHOD_CHECK_APP_AGREED    "stt_method_check_app_agreed"
+
+#define STT_METHOD_SET_START_SOUND     "stt_method_set_start_sound"
+#define STT_METHOD_UNSET_START_SOUND   "stt_method_unset_start_sound"
+#define STT_METHOD_SET_STOP_SOUND      "stt_method_set_stop_sound"
+#define STT_METHOD_UNSET_STOP_SOUND    "stt_method_unset_stop_sound"
 
 #define STT_METHOD_START               "stt_method_start"
 #define STT_METHOD_STOP                        "stt_method_stop"
@@ -53,39 +56,40 @@ extern "C" {
 #define STT_METHOD_START_FILE_RECONITION "stt_method_start_recognition"
 
 #define STTD_METHOD_RESULT             "sttd_method_result"
-#define STTD_METHOD_PARTIAL_RESULT     "sttd_method_partial_result"
 #define STTD_METHOD_ERROR              "sttd_method_error"
 #define STTD_METHOD_HELLO              "sttd_method_hello"
 #define STTD_METHOD_SET_STATE          "sttd_method_set_state"
 #define STTD_METHOD_GET_STATE          "sttd_method_get_state"
 
 /******************************************************************************************
-* Message Definition for Setting
+* Defines for configuration
 *******************************************************************************************/
 
-#define STT_SETTING_METHOD_HELLO               "stt_setting_method_hello"
-#define STT_SETTING_METHOD_INITIALIZE          "stt_setting_method_initialize"
-#define STT_SETTING_METHOD_FINALIZE            "stt_setting_method_finalilze"
-#define STT_SETTING_METHOD_GET_ENGINE_LIST     "stt_setting_method_get_engine_list"
-#define STT_SETTING_METHOD_GET_ENGINE          "stt_setting_method_get_engine"
-#define STT_SETTING_METHOD_SET_ENGINE          "stt_setting_method_set_engine"
-#define STT_SETTING_METHOD_GET_LANG_LIST       "stt_setting_method_get_lang_list"
-#define STT_SETTING_METHOD_GET_DEFAULT_LANG    "stt_setting_method_get_default_lang"
-#define STT_SETTING_METHOD_SET_DEFAULT_LANG    "stt_setting_method_set_default_lang"
-#define STT_SETTING_METHOD_GET_PROFANITY       "stt_setting_method_get_profanity"
-#define STT_SETTING_METHOD_SET_PROFANITY       "stt_setting_method_set_profanity"
-#define STT_SETTING_METHOD_GET_PUNCTUATION     "stt_setting_method_get_punctuation"
-#define STT_SETTING_METHOD_SET_PUNCTUATION     "stt_setting_method_set_punctuation"
-#define STT_SETTING_METHOD_GET_SILENCE         "stt_setting_method_get_silence_detection"
-#define STT_SETTING_METHOD_SET_SILENCE         "stt_setting_method_set_silence_detection"
-#define STT_SETTING_METHOD_GET_ENGINE_SETTING  "stt_setting_method_get_engine_setting"
-#define STT_SETTING_METHOD_SET_ENGINE_SETTING  "stt_setting_method_set_engine_setting"
+#define STT_AUDIO_VOLUME_PATH          "/tmp/stt_vol"
 
-/******************************************************************************************
-* Temp file for audio volume
-*******************************************************************************************/
+#define STT_PID_FILE_PATH              "/opt/home/app/.voice/sttd_info"
+
+#define STT_TIME_INFO_PATH             "/opt/home/app/.voice/stt-time.xml"
+
+#define STT_USR_BASE                   "/usr/lib/voice"
+#define STT_OPT_BASE                   "/opt/usr/data/voice"
+
+#define STT_DEFAULT_CONFIG             STT_USR_BASE"/stt/1.0/stt-config.xml"
+#define STT_CONFIG                     "/opt/home/app/.voice/stt-config.xml"
+
+#define STT_DEFAULT_ENGINE             STT_USR_BASE"/stt/1.0/engine"
+#define STT_DOWNLOAD_ENGINE            STT_OPT_BASE"/stt/1.0/engine"
+
+#define STT_DEFAULT_ENGINE_INFO                STT_USR_BASE"/stt/1.0/engine-info"
+#define STT_DOWNLOAD_ENGINE_INFO       STT_OPT_BASE"/stt/1.0/engine-info"
+
+#define STT_DEFAULT_ENGINE_SETTING     STT_USR_BASE"/stt/1.0/engine-setting"
+#define STT_DOWNLOAD_ENGINE_SETTING    STT_OPT_BASE"/stt/1.0/engine-setting"
+
+#define STT_BASE_LANGUAGE              "en_US"
 
-#define STT_AUDIO_VOLUME_PATH                  "/tmp/stt_vol"
+#define STT_FEATURE_PATH               "tizen.org/feature/speech.recognition"
+#define STT_MIC_FEATURE_PATH           "tizen.org/feature/microphone"
 
 #ifdef __cplusplus
 }
diff --git a/common/stt_engine.c b/common/stt_engine.c
new file mode 100644 (file)
index 0000000..3ddc644
--- /dev/null
@@ -0,0 +1,654 @@
+/*
+*  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 <dlfcn.h>
+#include <dirent.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+
+#include "stt_engine.h"
+
+/*
+* Internal data structure
+*/
+
+typedef struct {
+       int     engine_id;
+       char*   engine_path;
+       void    *handle;
+
+       sttpe_funcs_s*  pefuncs;
+       sttpd_funcs_s*  pdfuncs;
+
+       int (*sttp_load_engine)(sttpd_funcs_s* pdfuncs, sttpe_funcs_s* pefuncs);
+       int (*sttp_unload_engine)();
+}sttengine_s;
+
+extern const char* stt_tag();
+
+/** stt engine list */
+static GSList *g_engine_list;
+
+static const char* __stt_get_engine_error_code(sttp_error_e err)
+{
+       switch(err) {
+       case STTP_ERROR_NONE:                   return "STTP_ERROR_NONE";
+       case STTP_ERROR_OUT_OF_MEMORY:          return "STTP_ERROR_OUT_OF_MEMORY";
+       case STTP_ERROR_IO_ERROR:               return "STTP_ERROR_IO_ERROR";
+       case STTP_ERROR_INVALID_PARAMETER:      return "STTP_ERROR_INVALID_PARAMETER";
+       case STTP_ERROR_OUT_OF_NETWORK:         return "STTP_ERROR_OUT_OF_NETWORK";
+       case STTP_ERROR_INVALID_STATE:          return "STTP_ERROR_INVALID_STATE";
+       case STTP_ERROR_INVALID_LANGUAGE:       return "STTP_ERROR_INVALID_LANGUAGE";
+       case STTP_ERROR_OPERATION_FAILED:       return "STTP_ERROR_OPERATION_FAILED";
+       case STTP_ERROR_NOT_SUPPORTED_FEATURE:  return "STTP_ERROR_NOT_SUPPORTED_FEATURE";
+       default:
+               return "Invalid error code";
+       }
+}
+
+static sttengine_s* __get_engine(int engine_id)
+{
+       /* check whether engine id is valid or not.*/
+       GSList *iter = NULL;
+       sttengine_s *engine = NULL;
+
+       if (g_slist_length(g_engine_list) > 0) {
+               /*Get a first item*/
+               iter = g_slist_nth(g_engine_list, 0);
+
+               while (NULL != iter) {
+                       /*Get handle data from list*/
+                       engine = iter->data;
+
+                       if (engine_id == engine->engine_id) {
+                               return engine;
+                       }
+
+                       /*Get next item*/
+                       iter = g_slist_next(iter);
+               }
+       }
+
+       return NULL;
+}
+
+/* Register engine id */
+int stt_engine_load(int engine_id, const char* filepath)
+{
+       if (NULL == filepath || engine_id < 0) {
+               SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); 
+               return STTP_ERROR_INVALID_PARAMETER;
+       }
+
+       sttengine_s* engine = NULL;
+       engine = __get_engine(engine_id);
+       if (NULL != engine) {
+               SECURE_SLOG(LOG_WARN, stt_tag(), "[Engine WARNING] engine id(%d) is already loaded", engine_id);
+               return 0;
+       }
+
+       SECURE_SLOG(LOG_DEBUG, stt_tag(), "[Engine] Load engine id(%d), path(%s)", engine_id, filepath);
+
+       /* allocation memory */
+       engine = (sttengine_s*)calloc(1, sizeof(sttengine_s));
+
+       /* load engine */
+       char *error;
+
+       engine->handle = dlopen(filepath, RTLD_LAZY);
+       if (!engine->handle) {
+               SECURE_SLOG(LOG_WARN, stt_tag(), "[Engine] Invalid engine (Fail dlopen) : %s", filepath);
+               free(engine);
+               return STTP_ERROR_OPERATION_FAILED;
+       }
+
+       engine->pefuncs = (sttpe_funcs_s*)calloc(1, sizeof(sttpe_funcs_s));
+       engine->pdfuncs = (sttpd_funcs_s*)calloc(1, sizeof(sttpd_funcs_s));
+
+       engine->sttp_unload_engine = NULL;
+       engine->sttp_load_engine = NULL;
+
+       engine->sttp_unload_engine = (int (*)())dlsym(engine->handle, "sttp_unload_engine");
+       if (NULL != (error = dlerror()) || NULL == engine->sttp_unload_engine) {
+               SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to link daemon to sttp_unload_engine() : %s", error);
+               dlclose(engine->handle);
+               free(engine->pefuncs);
+               free(engine->pdfuncs);
+               free(engine);
+               return STTP_ERROR_OPERATION_FAILED;
+       }
+
+       engine->sttp_load_engine = (int (*)(sttpd_funcs_s*, sttpe_funcs_s*) )dlsym(engine->handle, "sttp_load_engine");
+       if (NULL != (error = dlerror()) || NULL == engine->sttp_load_engine) {
+               SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to link daemon to sttp_load_engine() : %s", error);
+               dlclose(engine->handle);
+               free(engine->pefuncs);
+               free(engine->pdfuncs);
+               free(engine);
+               return STTP_ERROR_OPERATION_FAILED;
+       }
+
+       engine->engine_id = engine_id;
+       engine->engine_path = strdup(filepath);
+
+       engine->pdfuncs->version = 1;
+       engine->pdfuncs->size = sizeof(sttpd_funcs_s);
+       
+       int ret = engine->sttp_load_engine(engine->pdfuncs, engine->pefuncs); 
+       if (0 != ret) {
+               SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail sttp_load_engine() : %s", __stt_get_engine_error_code(ret));
+               dlclose(engine->handle);
+               free(engine->pefuncs);
+               free(engine->pdfuncs);
+               free(engine->engine_path);
+               free(engine);
+               return STTP_ERROR_OPERATION_FAILED;
+       }
+
+       /* engine error check */
+       if (engine->pefuncs->size != sizeof(sttpe_funcs_s)) {
+               SLOG(LOG_WARN, stt_tag(), "[Engine WARNING] engine is not valid : function size is not matched");
+       }
+
+       if (NULL == engine->pefuncs->initialize ||
+               NULL == engine->pefuncs->deinitialize ||
+               NULL == engine->pefuncs->foreach_langs ||
+               NULL == engine->pefuncs->is_valid_lang ||
+               NULL == engine->pefuncs->support_silence ||
+               NULL == engine->pefuncs->support_recognition_type ||
+               NULL == engine->pefuncs->get_audio_format ||
+               NULL == engine->pefuncs->set_silence_detection ||
+               NULL == engine->pefuncs->start ||
+               NULL == engine->pefuncs->set_recording ||
+               NULL == engine->pefuncs->stop ||
+               NULL == engine->pefuncs->cancel ||
+               NULL == engine->pefuncs->foreach_result_time)
+               /* Current unused functions
+               NULL == engine->pefuncs->start_file_recognition ||
+               */
+       {
+               SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] The engine functions are NOT valid");
+               dlclose(engine->handle);
+               free(engine->pefuncs);
+               free(engine->pdfuncs);
+               free(engine->engine_path);
+               free(engine);
+
+               return STTP_ERROR_OPERATION_FAILED; 
+       }
+
+       SECURE_SLOG(LOG_DEBUG, stt_tag(), "[Engine Success] Load engine : version(%d), size(%d)",engine->pefuncs->version, engine->pefuncs->size);
+
+       g_engine_list = g_slist_append(g_engine_list, engine);
+
+       return 0;
+}
+
+/* Unregister engine id */
+int stt_engine_unload(int engine_id)
+{
+       sttengine_s* engine = NULL;
+       engine = __get_engine(engine_id);
+       if (NULL == engine) {
+               SECURE_SLOG(LOG_WARN, stt_tag(), "[Engine WARNING] engine id(%d) is invalid", engine_id);
+               return STTP_ERROR_INVALID_PARAMETER;
+       }
+
+       /* unload engine */
+       engine->sttp_unload_engine();
+       dlclose(engine->handle);
+       
+       if (NULL != engine->engine_path)        free(engine->engine_path);
+       if (NULL != engine->pefuncs)            free(engine->pefuncs);
+       if (NULL != engine->pdfuncs)            free(engine->pdfuncs);
+
+       g_engine_list = g_slist_remove(g_engine_list, engine);
+
+       free(engine);
+       
+       return 0;
+}
+
+
+/* Initialize / Deinitialize */
+int stt_engine_initialize(int engine_id, sttpe_result_cb result_cb, sttpe_silence_detected_cb silence_cb)
+{
+       if (NULL == result_cb || NULL == silence_cb) {
+               SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); 
+               return STTP_ERROR_INVALID_PARAMETER;
+       }
+
+       sttengine_s* engine = NULL;
+       engine = __get_engine(engine_id);
+       if (NULL == engine) {
+               SECURE_SLOG(LOG_WARN, stt_tag(), "[Engine WARNING] engine id(%d) is invalid", engine_id);
+               return STTP_ERROR_INVALID_PARAMETER;
+       }
+
+       int ret;
+       ret = engine->pefuncs->initialize(result_cb, silence_cb);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to initialize : %s", __stt_get_engine_error_code(ret));
+               return STTP_ERROR_OPERATION_FAILED;
+       }
+
+       return 0;
+}
+
+int stt_engine_deinitialize(int engine_id)
+{
+       sttengine_s* engine = NULL;
+       engine = __get_engine(engine_id);
+       if (NULL == engine) {
+               SECURE_SLOG(LOG_WARN, stt_tag(), "[Engine WARNING] engine id(%d) is invalid", engine_id);
+               return STTP_ERROR_INVALID_PARAMETER;
+       }
+
+       int ret;
+       ret = engine->pefuncs->deinitialize();
+       if (0 != ret) {
+               SLOG(LOG_WARN, stt_tag(), "[Engine WARNING] Fail to deinitialize : %s", __stt_get_engine_error_code(ret));
+       }
+
+       return 0;
+}
+
+static bool __supported_language_cb(const char* language, void* user_data)
+{
+       GSList** lang_list = (GSList**)user_data;
+
+       if (NULL == language || NULL == lang_list) {
+               SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Input parameter is NULL in callback!!!!");
+               return false;
+       }
+
+       char* temp_lang = g_strdup(language);
+
+       *lang_list = g_slist_append(*lang_list, temp_lang);
+
+       return true;
+}
+
+/* Get option */
+int stt_engine_get_supported_langs(int engine_id, GSList** lang_list)
+{
+       if (NULL == lang_list) {
+               SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); 
+               return STTP_ERROR_INVALID_PARAMETER;
+       }
+
+       sttengine_s* engine = NULL;
+       engine = __get_engine(engine_id);
+       if (NULL == engine) {
+               SECURE_SLOG(LOG_WARN, stt_tag(), "[Engine WARNING] engine id(%d) is invalid", engine_id);
+               return STTP_ERROR_INVALID_PARAMETER;
+       }
+
+       int ret;
+       ret = engine->pefuncs->foreach_langs(__supported_language_cb, (void*)lang_list);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] get language list error : %s", __stt_get_engine_error_code(ret));
+               return STTP_ERROR_OPERATION_FAILED;
+       }
+
+       return 0;
+}
+
+int stt_engine_is_valid_language(int engine_id, const char* language, bool *is_valid)
+{
+       if (NULL == language || NULL == is_valid) {
+               SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); 
+               return STTP_ERROR_INVALID_PARAMETER;
+       }
+
+       sttengine_s* engine = NULL;
+       engine = __get_engine(engine_id);
+       if (NULL == engine) {
+               SECURE_SLOG(LOG_WARN, stt_tag(), "[Engine WARNING] engine id(%d) is invalid", engine_id);
+               return STTP_ERROR_INVALID_PARAMETER;
+       }
+       
+       bool result;
+       result = engine->pefuncs->is_valid_lang(language);
+
+       *is_valid = result;
+
+       return 0;
+}
+
+int stt_engine_get_first_language(int engine_id, char** language)
+{
+       if (NULL == language) {
+               SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); 
+               return STTP_ERROR_INVALID_PARAMETER;
+       }
+
+       sttengine_s* engine = NULL;
+       engine = __get_engine(engine_id);
+       if (NULL == engine) {
+               SECURE_SLOG(LOG_WARN, stt_tag(), "[Engine WARNING] engine id(%d) is invalid", engine_id);
+               return STTP_ERROR_INVALID_PARAMETER;
+       }
+
+       GSList* lang_list = NULL;
+       int ret;
+       ret = engine->pefuncs->foreach_langs(__supported_language_cb, &lang_list);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] get language list error : %s", __stt_get_engine_error_code(ret));
+               return STTP_ERROR_OPERATION_FAILED;
+       }
+
+       GSList *iter = NULL;
+       char* data = NULL;
+
+       iter = g_slist_nth(lang_list, 0);
+       if (NULL != iter) {
+               data = iter->data;
+
+               if (true == engine->pefuncs->is_valid_lang(data)) {
+                       *language = strdup(data);
+               } else {
+                       ret = STTP_ERROR_OPERATION_FAILED;
+               }
+       }
+
+       /* if list have item */
+       if (g_slist_length(lang_list) > 0) {
+               /* Get a first item */
+               iter = g_slist_nth(lang_list, 0);
+
+               while (NULL != iter) {
+                       data = iter->data;
+
+                       if (NULL != data)
+                               free(data);
+
+                       lang_list = g_slist_remove_link(lang_list, iter);
+
+                       iter = g_slist_nth(lang_list, 0);
+               }
+       }
+
+       return ret;
+}
+
+int stt_engine_support_silence(int engine_id, bool* support)
+{
+       if (NULL == support) {
+               SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); 
+               return STTP_ERROR_INVALID_PARAMETER;
+       }
+
+       sttengine_s* engine = NULL;
+       engine = __get_engine(engine_id);
+       if (NULL == engine) {
+               SECURE_SLOG(LOG_WARN, stt_tag(), "[Engine WARNING] engine id(%d) is invalid", engine_id);
+               return STTP_ERROR_INVALID_PARAMETER;
+       }
+
+       bool result;
+       result = engine->pefuncs->support_silence();
+       *support = result;
+
+       return 0;
+}
+
+int stt_engine_support_recognition_type(int engine_id, const char* type, bool* support)
+{
+       if (NULL == type || NULL == support) {
+               SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); 
+               return STTP_ERROR_INVALID_PARAMETER;
+       }
+
+       sttengine_s* engine = NULL;
+       engine = __get_engine(engine_id);
+       if (NULL == engine) {
+               SECURE_SLOG(LOG_WARN, stt_tag(), "[Engine WARNING] engine id(%d) is invalid", engine_id);
+               return STTP_ERROR_INVALID_PARAMETER;
+       }
+
+       bool result;
+       if (NULL != engine->pefuncs->support_recognition_type) {
+               result = engine->pefuncs->support_recognition_type(type);
+               *support = result;
+               return 0;
+       }
+
+       return STTP_ERROR_OPERATION_FAILED;
+}
+
+int stt_engine_get_audio_type(int engine_id, sttp_audio_type_e* types, int* rate, int* channels)
+{
+       if (NULL == types || NULL == rate || NULL == channels) {
+               SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); 
+               return STTP_ERROR_INVALID_PARAMETER;
+       }
+
+       sttengine_s* engine = NULL;
+       engine = __get_engine(engine_id);
+       if (NULL == engine) {
+               SECURE_SLOG(LOG_WARN, stt_tag(), "[Engine WARNING] engine id(%d) is invalid", engine_id);
+               return STTP_ERROR_INVALID_PARAMETER;
+       }
+
+       int ret;
+       ret = engine->pefuncs->get_audio_format(types, rate, channels);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to get audio format : %s", __stt_get_engine_error_code(ret));
+               return STTP_ERROR_OPERATION_FAILED;
+       }
+
+       return 0;
+}
+
+/* Set option */
+int stt_engine_set_silence_detection(int engine_id, bool value)
+{
+       sttengine_s* engine = NULL;
+       engine = __get_engine(engine_id);
+       if (NULL == engine) {
+               SECURE_SLOG(LOG_WARN, stt_tag(), "[Engine WARNING] engine id(%d) is invalid", engine_id);
+               return STTP_ERROR_INVALID_PARAMETER;
+       }
+
+       int ret = engine->pefuncs->set_silence_detection(value);
+       if (STTP_ERROR_NOT_SUPPORTED_FEATURE == ret) {
+               SLOG(LOG_WARN, stt_tag(), "[Engine WARNING] Not support silence detection"); 
+               return STTP_ERROR_NOT_SUPPORTED_FEATURE;
+       } else if (0 != ret) {
+               SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to set silence detection : %d", ret); 
+               return STTP_ERROR_OPERATION_FAILED;
+       }
+       
+       return 0;
+}
+
+int stt_engine_check_app_agreed(int engine_id, const char* appid, bool* value)
+{
+       sttengine_s* engine = NULL;
+       engine = __get_engine(engine_id);
+       if (NULL == engine) {
+               SECURE_SLOG(LOG_WARN, stt_tag(), "[Engine WARNING] engine id(%d) is invalid", engine_id);
+               return STTP_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == engine->pefuncs->check_app_agreed) {
+               SLOG(LOG_WARN, stt_tag(), "[Engine WARNING] Not support app agreement. All app is available");
+               *value = true;
+               return 0;
+       }
+
+       int ret = engine->pefuncs->check_app_agreed(appid, value);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to get app agreement : %s", __stt_get_engine_error_code(ret));
+               *value = false;
+               return STTP_ERROR_OPERATION_FAILED;
+       }
+       
+       return 0;
+}
+
+/* Recognition */
+int stt_engine_recognize_start(int engine_id, const char* lang, const char* recognition_type, void* user_param)
+{
+       if (NULL == lang || NULL == recognition_type) {
+               SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); 
+               return STTP_ERROR_INVALID_PARAMETER;
+       }
+
+       sttengine_s* engine = NULL;
+       engine = __get_engine(engine_id);
+       if (NULL == engine) {
+               SECURE_SLOG(LOG_WARN, stt_tag(), "[Engine WARNING] engine id(%d) is invalid", engine_id);
+               return STTP_ERROR_INVALID_PARAMETER;
+       }
+
+       int ret = engine->pefuncs->start(lang, recognition_type, user_param);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to start recognition : %s", __stt_get_engine_error_code(ret));
+               return STTP_ERROR_OPERATION_FAILED;
+       }
+
+       return 0;
+}
+
+int stt_engine_set_recording_data(int engine_id, const void* data, unsigned int length)
+{
+       if (NULL == data) {
+               SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); 
+               return STTP_ERROR_INVALID_PARAMETER;
+       }
+
+       sttengine_s* engine = NULL;
+       engine = __get_engine(engine_id);
+       if (NULL == engine) {
+               SECURE_SLOG(LOG_WARN, stt_tag(), "[Engine WARNING] engine id(%d) is invalid", engine_id);
+               return STTP_ERROR_INVALID_PARAMETER;
+       }
+
+       int ret = engine->pefuncs->set_recording(data, length);
+       if (0 != ret) {
+               SLOG(LOG_WARN, stt_tag(), "[Engine WARNING] Fail to set recording : %s", __stt_get_engine_error_code(ret));
+               return STTP_ERROR_OPERATION_FAILED;
+       }
+
+       return 0;
+}
+
+int stt_engine_recognize_stop(int engine_id)
+{
+       sttengine_s* engine = NULL;
+       engine = __get_engine(engine_id);
+       if (NULL == engine) {
+               SECURE_SLOG(LOG_WARN, stt_tag(), "[Engine WARNING] engine id(%d) is invalid", engine_id);
+               return STTP_ERROR_INVALID_PARAMETER;
+       }
+
+       int ret = engine->pefuncs->stop();
+       if (0 != ret) {
+               SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to stop : %s", __stt_get_engine_error_code(ret));
+               return STTP_ERROR_OPERATION_FAILED;
+       }
+
+       return 0;
+}
+
+int stt_engine_recognize_cancel(int engine_id)
+{
+       sttengine_s* engine = NULL;
+       engine = __get_engine(engine_id);
+       if (NULL == engine) {
+               SECURE_SLOG(LOG_WARN, stt_tag(), "[Engine WARNING] engine id(%d) is invalid", engine_id);
+               return STTP_ERROR_INVALID_PARAMETER;
+       }
+
+       int ret = engine->pefuncs->cancel();
+       if (0 != ret) {
+               SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to cancel : %s", __stt_get_engine_error_code(ret));
+               return STTP_ERROR_OPERATION_FAILED;
+       }
+
+       return 0;
+}
+
+int stt_engine_foreach_result_time(int engine_id, void* time_info, sttpe_result_time_cb callback, void* user_data)
+{
+       sttengine_s* engine = NULL;
+       engine = __get_engine(engine_id);
+       if (NULL == engine) {
+               SECURE_SLOG(LOG_WARN, stt_tag(), "[Engine WARNING] engine id(%d) is invalid", engine_id);
+               return STTP_ERROR_INVALID_PARAMETER;
+       }
+
+       int ret = engine->pefuncs->foreach_result_time(time_info, callback, user_data);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to foreach result time : %s", __stt_get_engine_error_code(ret));
+               return STTP_ERROR_OPERATION_FAILED;
+       }
+       
+       return 0;
+}
+
+int stt_engine_recognize_start_file(int engine_id, const char* lang, const char* recognition_type, 
+                                    const char* filepath, sttp_audio_type_e audio_type, int sample_rate, void* user_param)
+{
+       if (NULL == filepath || NULL == lang || NULL == recognition_type) {
+               SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); 
+               return STTP_ERROR_INVALID_PARAMETER;
+       }
+
+       sttengine_s* engine = NULL;
+       engine = __get_engine(engine_id);
+       if (NULL == engine) {
+               SECURE_SLOG(LOG_WARN, stt_tag(), "[Engine WARNING] engine id(%d) is invalid", engine_id);
+               return STTP_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == engine->pefuncs->start_file) {
+               SLOG(LOG_WARN, stt_tag(), "[Engine WARNING] engine API is invalid");
+               return STTP_ERROR_NOT_SUPPORTED_FEATURE;
+       }
+
+       int ret = engine->pefuncs->start_file(lang, recognition_type, filepath, audio_type, sample_rate, user_param);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to start file recognition : %s", __stt_get_engine_error_code(ret));
+               return STTP_ERROR_OPERATION_FAILED;
+       }
+
+       return 0;
+}
+
+int stt_engine_recognize_cancel_file(int engine_id)
+{
+       sttengine_s* engine = NULL;
+       engine = __get_engine(engine_id);
+       if (NULL == engine) {
+               SECURE_SLOG(LOG_WARN, stt_tag(), "[Engine WARNING] engine id(%d) is invalid", engine_id);
+               return STTP_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == engine->pefuncs->cancel_file) {
+               SLOG(LOG_WARN, stt_tag(), "[Engine WARNING] engine API is invalid");
+               return STTP_ERROR_NOT_SUPPORTED_FEATURE;
+       }
+
+       int ret = engine->pefuncs->cancel_file();
+       if (0 != ret) {
+               SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to start file recognition : %s", __stt_get_engine_error_code(ret));
+               return STTP_ERROR_OPERATION_FAILED;
+       }
+
+       return 0;
+}
\ No newline at end of file
diff --git a/common/stt_engine.h b/common/stt_engine.h
new file mode 100644 (file)
index 0000000..2e80eb1
--- /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 __STT_ENGINE_H_
+#define __STT_ENGINE_H_
+
+#include <glib.h>
+#include "sttp.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+* STT Engine Interfaces
+*/
+
+
+/* Register engine id */
+int stt_engine_load(int engine_id, const char* filepath);
+
+/* Unregister engine id */
+int stt_engine_unload(int engine_id);
+
+
+/* Init / Deinit */
+int stt_engine_initialize(int engine_id, sttpe_result_cb result_cb, sttpe_silence_detected_cb silence_cb);
+
+int stt_engine_deinitialize(int engine_id);
+
+/* Get option */
+int stt_engine_get_supported_langs(int engine_id, GSList** lang_list);
+
+int stt_engine_is_valid_language(int engine_id, const char* language, bool *is_valid);
+
+int stt_engine_get_first_language(int engine_id, char** language);
+
+int stt_engine_support_silence(int engine_id, bool* support);
+
+int stt_engine_support_recognition_type(int engine_id, const char* type, bool* support);
+
+int stt_engine_get_audio_type(int engine_id, sttp_audio_type_e* types, int* rate, int* channels);
+
+/* Set option */
+int stt_engine_set_silence_detection(int engine_id, bool value);
+
+/* Get right */
+int stt_engine_check_app_agreed(int engine_id, const char* appid, bool* value);
+
+/* Recognition */
+int stt_engine_recognize_start(int engine_id, const char* lang, const char* recognition_type, void* user_param);
+
+int stt_engine_set_recording_data(int engine_id, const void* data, unsigned int length);
+
+int stt_engine_recognize_stop(int engine_id);
+
+int stt_engine_recognize_cancel(int engine_id);
+
+int stt_engine_foreach_result_time(int engine_id, void* time_info, sttpe_result_time_cb callback, void* user_data);
+
+
+/* File recognition */
+int stt_engine_recognize_start_file(int engine_id, const char* lang, const char* recognition_type, 
+                               const char* filepath, sttp_audio_type_e audio_type, int sample_rate, void* user_param);
+
+int stt_engine_recognize_cancel_file(int engine_id);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STT_ENGINE_H_ */
diff --git a/common/stt_network.c b/common/stt_network.c
new file mode 100644 (file)
index 0000000..ac3210f
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+*  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 <vconf.h>
+
+#include "stt_network.h"
+
+extern const char* stt_tag();
+
+int stt_network_initialize()
+{
+       return 0;
+}
+
+int stt_network_finalize()
+{
+       return 0;
+}
+
+bool stt_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, stt_tag(), "[Network] Current network connection is OFF.");
+               return false;
+       }
+       
+       SLOG(LOG_DEBUG, stt_tag(), "[Network] Network status is %d", network_status);
+
+       return true;
+}
\ No newline at end of file
similarity index 69%
rename from server/sttd_network.h
rename to common/stt_network.h
index 659b69f..fbda52d 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
 */
 
 
-#ifndef __STTD_NETWORK_H_
-#define __STTD_NETWORK_H_
+#ifndef __STT_NETWORK_H_
+#define __STT_NETWORK_H_
+
+#include <stdbool.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-int sttd_network_initialize();
+int stt_network_initialize();
 
-int sttd_network_finalize();
+int stt_network_finalize();
 
-bool sttd_network_is_connected();
+bool stt_network_is_connected();
 
 
 #ifdef __cplusplus
@@ -31,4 +33,4 @@ bool sttd_network_is_connected();
 #endif
 
 
-#endif /* __STTD_NETWORK_H_ */
+#endif /* __STT_NETWORK_H_ */
diff --git a/doc/doxyfile b/doc/doxyfile
new file mode 100644 (file)
index 0000000..c061f3d
--- /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           = STT
+
+# 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/stt.h \
+                         uix_stt_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_stt_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_stt_state_diagram.png b/doc/images/capi_uix_stt_state_diagram.png
new file mode 100644 (file)
index 0000000..19b130a
Binary files /dev/null and b/doc/images/capi_uix_stt_state_diagram.png differ
diff --git a/doc/uix_stt_doc.h b/doc/uix_stt_doc.h
new file mode 100644 (file)
index 0000000..e1cc2e0
--- /dev/null
@@ -0,0 +1,213 @@
+/*
+ * 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_STT_DOC_H__
+#define __TIZEN_UIX_STT_DOC_H__
+
+/**
+ * @defgroup CAPI_UIX_STT_MODULE STT
+ * @ingroup CAPI_UIX_FRAMEWORK
+ * @brief The @ref CAPI_UIX_STT_MODULE API provides functions to recognize the speech.
+ * 
+ * @section CAPI_UIX_STT_MODULE_HEADER Required Header
+ *   \#include <stt.h>
+ * 
+ * @section CAPI_UIX_STT_MODULE_OVERVIEW Overview
+ * A main function of Speech-To-Text (below STT) API recognizes sound data recorded by users.
+ * After choosing a language, applications will start recording and recognizing.
+ * After recording, the applications will receive the recognized result.
+ *
+ * To use of STT, use the following steps:<br>
+ * 1. Create a handle <br>
+ * 2. Register callback functions for notifications <br> 
+ * 3. Prepare stt-daemon asynchronously <br>
+ * 4. Start recording for recognition <br>
+ * 5. Stop recording <br>
+ * 6. Get result after processing <br>
+ * 7. Destroy a handle <br>
+ *
+ * The STT has a client-server for the service of multi-applications.
+ * The STT daemon as a server always works in the background for the STT service.
+ * If the daemon is not working, client library will invoke it and client will communicate with it.
+ * The daemon has engines and the recorder so client does not have the recorder itself.
+ * Only the client request commands to the daemon for the service.
+ *
+ * @section CAPI_STT_MODULE_STATE_DIAGRAM State Diagram
+ * The following diagram shows the life cycle and the states of the STT.
+ *
+ * @image html capi_uix_stt_state_diagram.png "State diagram"
+ *
+ * @section CAPI_STT_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>stt_prepare()</td>
+ * <td>Created</td>
+ * <td>Ready</td>
+ * <td>ASYNC</td>
+ * </tr>
+ * <tr>
+ * <td>stt_start()</td>
+ * <td>Ready</td>
+ * <td>Recording</td>
+ * <td>ASYNC</td>
+ * </tr>
+ * <tr>
+ * <td>stt_stop()</td>
+ * <td>Recording</td>
+ * <td>Processing</td>
+ * <td>ASYNC</td>
+ * </tr>
+ * </tr>
+ * <tr>
+ * <td>stt_cancel()</td>
+ * <td>Recording or Processing</td>
+ * <td>Ready</td>
+ * <td>SYNC</td>
+ * </tr>
+ * </table>
+ * 
+ * @section CAPI_STT_MODULE_STATE_DEPENDENT_FUNCTION_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>stt_create()</td>
+ * <td>None</td>
+ * <td>All functions must be called after stt_create().</td>
+ * </tr>
+ * <tr>
+ * <td>stt_destroy()</td>
+ * <td>Created, Ready, Recording, Processing</td>
+ * <td></td>
+ * </tr>
+ * <tr>
+ * <td>stt_prepare()</td>
+ * <td>Created</td>
+ * <td>This function works asynchronously. If daemon fork is failed, application gets the error callback.</td>
+ * </tr>
+ * <tr>
+ * <td>stt_unprepare()</td>
+ * <td>Ready</td>
+ * <td></td>
+ * </tr>
+ * <tr>
+ * <td>stt_foreach_supported_engines()</td>
+ * <td>Created</td>
+ * <td></td>
+ * </tr>
+ * <tr>
+ * <td>stt_get_engine()</td>
+ * <td>Created</td>
+ * <td></td>
+ * </tr>
+ * <tr>
+ * <td>stt_set_engine()</td>
+ * <td>Created</td>
+ * <td></td>
+ * </tr>
+ * <tr>
+ * <td>stt_foreach_supported_languages()</td>
+ * <td>Created, Ready, Recording, Processing</td>
+ * <td></td>
+ * </tr>
+ * <tr>
+ * <td>stt_get_default_language()</td>
+ * <td>Created, Ready, Recording, Processing</td>
+ * <td></td>
+ * </tr>
+ * <tr>
+ * <td>stt_get_state()</td>
+ * <td>Created, Ready, Recording, Processing</td>
+ * <td></td>
+ * </tr>
+ * <tr>
+ * <td>stt_is_recognition_type_supported()</td>
+ * <td>Ready</td>
+ * <td></td>
+ * </tr>
+ * <tr>
+ * <td>stt_set_silence_detection()</td>
+ * <td>Ready</td>
+ * <td></td>
+ * </tr>
+ * <tr>
+ * <td>stt_set_start_sound()<br>stt_unset_start_sound()<br>stt_set_stop_sound()<br>stt_unset_stop_sound()</td>
+ * <td>Ready</td>
+ * <td></td>
+ * </tr>
+ * <tr>
+ * <td>stt_start()</td>
+ * <td>Ready</td>
+ * <td></td>
+ * </tr>
+ * <tr>
+ * <td>stt_stop()</td>
+ * <td>Recording</td>
+ * <td></td>
+ * </tr>
+ * <tr>
+ * <td>stt_cancel()</td>
+ * <td>Recording, Processing</td>
+ * <td></td>
+ * </tr>
+ * <tr>
+ * <td>stt_get_recording_volume()</td>
+ * <td>Recording</td>
+ * <td></td>
+ * </tr>
+ * <tr>
+ * <td>stt_foreach_detailed_result()</td>
+ * <td>Processing</td>
+ * <td>This must be called in stt_recognition_result_cb()</td>
+ * </tr>
+ * <tr>
+ * <td>stt_set_recognition_result_cb()<br>stt_unset_recognition_result_cb()<br>
+ * stt_set_state_changed_cb()<br>stt_unset_state_changed_cb()<br>stt_set_error_cb()<br>stt_unset_error_cb()<br>
+ * stt_set_default_language_changed_cb()<br>stt_unset_default_language_changed_cb()
+ * </td>
+ * <td>Created</td>
+ * <td>All callback function should be registered / unregistered in Created state</td>
+ * </tr>
+ * </table>
+ * 
+ * @section CAPI_UIX_STT_MODULE_FEATURE Related Features
+ * This API is related with the following features:<br>
+ *  - http://tizen.org/feature/speech.recognition<br>
+ *  - http://tizen.org/feature/microphone<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_STT_DOC_H__ */
+
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
new file mode 100644 (file)
index 0000000..aa165da
--- /dev/null
@@ -0,0 +1,15 @@
+## configure pkgconfig files ##
+CONFIGURE_FILE(stt.pc.in "${PROJECT_NAME}.pc" @ONLY)
+CONFIGURE_FILE(stt-file.pc.in "${PROJECT_NAME}-file.pc" @ONLY)
+CONFIGURE_FILE(stt-setting.pc.in "${PROJECT_NAME}-setting.pc" @ONLY)
+CONFIGURE_FILE(stt-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}-file.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/stt.h" DESTINATION ${INCLUDEDIR})
+INSTALL(FILES "${CMAKE_BINARY_DIR}/include/stt_file.h" DESTINATION ${INCLUDEDIR})
+INSTALL(FILES "${CMAKE_BINARY_DIR}/include/stt_setting.h" DESTINATION ${INCLUDEDIR})
+INSTALL(FILES "${CMAKE_BINARY_DIR}/server/sttp.h" DESTINATION ${INCLUDEDIR})
diff --git a/include/stt-engine.pc.in b/include/stt-engine.pc.in
new file mode 100644 (file)
index 0000000..36f4cb2
--- /dev/null
@@ -0,0 +1,10 @@
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
+
+Name: lib@PROJECT_NAME@_engine
+Description: Speech To Text client engine header
+Requires: glib-2.0 dbus-1
+Version: @VERSION@
+Cflags: -I${includedir}
diff --git a/include/stt-file.pc.in b/include/stt-file.pc.in
new file mode 100644 (file)
index 0000000..ffe80e5
--- /dev/null
@@ -0,0 +1,11 @@
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
+
+Name: lib@PROJECT_NAME@_file
+Description: File To Text client library
+Requires: glib-2.0
+Version: @VERSION@
+Libs: -L${libdir} -l@PROJECT_NAME@_file
+Cflags: -I${includedir}
diff --git a/include/stt.h b/include/stt.h
new file mode 100644 (file)
index 0000000..6d52bda
--- /dev/null
@@ -0,0 +1,959 @@
+/*
+ * 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 __STT_H__
+#define __STT_H__
+
+#include <tizen.h>
+
+/**
+ * @file stt.h
+ */
+
+/**
+* @addtogroup CAPI_UIX_STT_MODULE
+* @{
+*/
+
+#ifdef __cplusplus
+extern "C" 
+{
+#endif
+
+/**
+ * @brief Enumerations for error codes.
+ * @since_tizen 2.3
+*/
+typedef enum {
+       STT_ERROR_NONE                  = TIZEN_ERROR_NONE,             /**< Successful */
+       STT_ERROR_OUT_OF_MEMORY         = TIZEN_ERROR_OUT_OF_MEMORY,    /**< Out of Memory */
+       STT_ERROR_IO_ERROR              = TIZEN_ERROR_IO_ERROR,         /**< I/O error */
+       STT_ERROR_INVALID_PARAMETER     = TIZEN_ERROR_INVALID_PARAMETER,/**< Invalid parameter */
+       STT_ERROR_TIMED_OUT             = TIZEN_ERROR_TIMED_OUT,        /**< No answer from the daemon */
+       STT_ERROR_RECORDER_BUSY         = TIZEN_ERROR_RESOURCE_BUSY,    /**< Device or resource busy */
+       STT_ERROR_OUT_OF_NETWORK        = TIZEN_ERROR_NETWORK_DOWN,     /**< Network is down */
+       STT_ERROR_PERMISSION_DENIED     = TIZEN_ERROR_PERMISSION_DENIED,/**< Permission denied */
+       STT_ERROR_NOT_SUPPORTED         = TIZEN_ERROR_NOT_SUPPORTED,    /**< STT NOT supported */
+       STT_ERROR_INVALID_STATE         = TIZEN_ERROR_STT | 0x01,       /**< Invalid state */
+       STT_ERROR_INVALID_LANGUAGE      = TIZEN_ERROR_STT | 0x02,       /**< Invalid language */
+       STT_ERROR_ENGINE_NOT_FOUND      = TIZEN_ERROR_STT | 0x03,       /**< No available engine  */    
+       STT_ERROR_OPERATION_FAILED      = TIZEN_ERROR_STT | 0x04,       /**< Operation failed  */
+       STT_ERROR_NOT_SUPPORTED_FEATURE = TIZEN_ERROR_STT | 0x05        /**< Not supported feature of current engine */
+}stt_error_e;
+
+/**
+ * @brief Definition for free form dictation and default type.
+ * @since_tizen 2.3
+*/
+#define STT_RECOGNITION_TYPE_FREE              "stt.recognition.type.FREE"
+
+/**
+ * @brief Definition for continuous free dictation.
+ * @since_tizen 2.3
+*/
+#define STT_RECOGNITION_TYPE_FREE_PARTIAL      "stt.recognition.type.FREE.PARTIAL"
+
+/**
+ * @brief Definition for search.
+ * @since_tizen 2.3
+*/
+#define STT_RECOGNITION_TYPE_SEARCH            "stt.recognition.type.SEARCH"
+
+/**
+ * @brief Definition for web search.
+ * @since_tizen 2.3
+*/
+#define STT_RECOGNITION_TYPE_WEB_SEARCH                "stt.recognition.type.WEB_SEARCH"
+
+/**
+ * @brief Definition for map.
+ * @since_tizen 2.3
+*/
+#define STT_RECOGNITION_TYPE_MAP               "stt.recognition.type.MAP"
+
+/**
+ * @brief Definition for none message.
+ * @since_tizen 2.3
+*/
+#define STT_RESULT_MESSAGE_NONE                        "stt.result.message.none"
+
+/**
+ * @brief Definition for failed recognition because the speech started too soon.
+ * @since_tizen 2.3
+*/
+#define STT_RESULT_MESSAGE_ERROR_TOO_SOON      "stt.result.message.error.too.soon"
+
+/**
+ * @brief Definition for failed recognition because the speech is too short.
+ * @since_tizen 2.3
+*/
+#define STT_RESULT_MESSAGE_ERROR_TOO_SHORT     "stt.result.message.error.too.short"
+
+/**
+ * @brief Definition for failed recognition because the speech is too long.
+ * @since_tizen 2.3
+*/
+#define STT_RESULT_MESSAGE_ERROR_TOO_LONG      "stt.result.message.error.too.long"
+
+/**
+ * @brief Definition for failed recognition because the speech is too quiet to listen.
+ * @since_tizen 2.3
+*/
+#define STT_RESULT_MESSAGE_ERROR_TOO_QUIET     "stt.result.message.error.too.quiet"
+
+/**
+ * @brief Definition for failed recognition because the speech is too loud to listen.
+ * @since_tizen 2.3
+*/
+#define STT_RESULT_MESSAGE_ERROR_TOO_LOUD      "stt.result.message.error.too.loud"
+
+/**
+ * @brief Definition for failed recognition because the speech is too fast to listen.
+ * @since_tizen 2.3
+*/
+#define STT_RESULT_MESSAGE_ERROR_TOO_FAST      "stt.result.message.error.too.fast"
+
+
+/**
+ * @brief Enumeration for state.
+ * @since_tizen 2.3
+*/
+typedef enum {
+       STT_STATE_CREATED       = 0,            /**< 'CREATED' state */
+       STT_STATE_READY         = 1,            /**< 'READY' state */
+       STT_STATE_RECORDING     = 2,            /**< 'RECORDING' state */
+       STT_STATE_PROCESSING    = 3             /**< 'PROCESSING' state*/
+}stt_state_e;
+
+/**
+ * @brief Enumeration for result event.
+ * @since_tizen 2.3
+*/
+typedef enum {
+       STT_RESULT_EVENT_FINAL_RESULT = 0,      /**< Event when the recognition full or last result is ready  */
+       STT_RESULT_EVENT_PARTIAL_RESULT,        /**< Event when the recognition partial result is ready  */
+       STT_RESULT_EVENT_ERROR                  /**< Event when the recognition has failed */
+}stt_result_event_e;
+
+/**
+ * @brief Enumeration for result time callback event.
+ * @since_tizen 2.3
+*/
+typedef enum {
+       STT_RESULT_TIME_EVENT_BEGINNING = 0,    /**< Event when the token is beginning type */
+       STT_RESULT_TIME_EVENT_MIDDLE = 1,       /**< Event when the token is middle type */
+       STT_RESULT_TIME_EVENT_END = 2           /**< Event when the token is end type */
+}stt_result_time_event_e;
+
+/**
+ * @brief Enumeration for silence detection type.
+ * @since_tizen 2.3
+*/
+typedef enum {
+       STT_OPTION_SILENCE_DETECTION_FALSE = 0, /**< Silence detection type - False */
+       STT_OPTION_SILENCE_DETECTION_TRUE = 1,  /**< Silence detection type - True */
+       STT_OPTION_SILENCE_DETECTION_AUTO = 2   /**< Silence detection type - Auto */   
+}stt_option_silence_detection_e;
+
+/**
+ * @brief A structure of STT handler.
+ * @since_tizen 2.3
+*/
+typedef struct stt_s *stt_h;
+
+/**
+ * @brief Called to get the engine information.
+ * @since_tizen 2.3
+ *
+ * @param[in] engine_id Engine id
+ * @param[in] engine_name Engine name
+ * @param[in] user_data User data passed from the stt_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 stt_foreach_supported_engines() will invoke this callback.
+ *
+ * @see stt_foreach_supported_engines()
+*/
+typedef bool(*stt_supported_engine_cb)(stt_h stt, const char* engine_id, const char* engine_name, void* user_data);
+
+/**
+ * @brief Called when STT gets the recognition result from the engine.
+ * @since_tizen 2.3
+ *
+ * @remarks After stt_stop() is called, silence is detected from recording, or partial result is occured,
+ *     this function is called.
+ *
+ * @param[in] stt The STT handle
+ * @param[in] event The result event
+ * @param[in] data Result texts
+ * @param[in] data_count Result text count
+ * @param[in] msg Engine message (e.g. #STT_RESULT_MESSAGE_NONE, #STT_RESULT_MESSAGE_ERROR_TOO_SHORT)
+ * @param[in] user_data The user data passed from the callback registration function
+ *
+ * @pre stt_stop() will invoke this callback if you register it using stt_set_result_cb().
+ * @post If this function is called and event is #STT_RESULT_EVENT_FINAL_RESULT, the STT state will be #STT_STATE_READY.
+ *
+ * @see stt_stop()
+ * @see stt_set_recognition_result_cb()
+ * @see stt_unset_recognition_result_cb()
+*/
+typedef void (*stt_recognition_result_cb)(stt_h stt, stt_result_event_e event, const char** data, int data_count, 
+                                         const char* msg, void *user_data);
+
+/**
+ * @brief Called when STT get the result time stamp in free partial type.
+ * @since_tizen 2.3
+ *
+ * @param[in] stt The STT handle
+ * @param[in] index The result index
+ * @param[in] event The token event
+ * @param[in] text The result text
+ * @param[in] start_time The start time of result text
+ * @param[in] end_time The end time of result text
+ * @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 stt_recognition_result_cb() should be called.
+ *
+ * @see stt_recognition_result_cb()
+*/
+typedef bool (*stt_result_time_cb)(stt_h stt, int index, stt_result_time_event_e event, const char* text, 
+                                  long start_time, long end_time, void* user_data);
+
+/**
+ * @brief Called when the state of STT is changed.
+ * @since_tizen 2.3
+ *
+ * @param[in] stt The STT handle
+ * @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 stt_set_state_changed_cb() to detect changing state.
+ *
+ * @see stt_set_state_changed_cb()
+ * @see stt_unset_state_changed_cb()
+*/
+typedef void (*stt_state_changed_cb)(stt_h stt, stt_state_e previous, stt_state_e current, void* user_data);
+
+/**
+ * @brief Called when an error occurs.
+ * @since_tizen 2.3
+ *
+ * @param[in] stt The STT handle
+ * @param[in] reason The error type (e.g. #STT_ERROR_OUT_OF_NETWORK, #STT_ERROR_IO_ERROR)
+ * @param[in] user_data The user data passed from the callback registration function
+ *
+ * @pre An application registers this callback using stt_set_error_cb() to detect error.
+ *
+ * @see stt_set_error_cb()
+ * @see stt_unset_error_cb()
+*/
+typedef void (*stt_error_cb)(stt_h stt, stt_error_e reason, void *user_data);
+
+/**
+ * @brief Called to retrieve the supported languages.
+ * @since_tizen 2.3
+ * @remarks The 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] stt The STT handle
+ * @param[in] language The language
+ * @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 stt_foreach_supported_languages() will invoke this callback.
+ *
+ * @see stt_foreach_supported_languages()
+*/
+typedef bool (*stt_supported_language_cb)(stt_h stt, const char* language, void* user_data);
+
+/**
+ * @brief Called when the default language is changed.
+ * @since_tizen 2.3
+ *
+ * @param[in] stt The STT handle
+ * @param[in] previous_language A previous language
+ * @param[in] current_language A current language
+ * @param[in] user_data The user data passed from the callback registration function
+ *
+ * @see stt_set_default_language_changed_cb()
+*/
+typedef void (*stt_default_language_changed_cb)(stt_h stt, const char* previous_language, 
+                                               const char* current_language, void* user_data);
+
+/**
+ * @brief Creates a STT handle.
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/recorder
+ *
+ * @remarks If the function succeeds, @a stt handle must be released with stt_destroy().
+ *
+ * @param[out] stt The STT handle
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STT_ERROR_NONE Successful
+ * @retval #STT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STT_ERROR_OPERATION_FAILED Operation failure
+ * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
+ *
+ * @post If this function is called, the STT state will be #STT_STATE_CREATED.
+ *
+ * @see stt_destroy()
+*/
+int stt_create(stt_h* stt);
+
+/**
+ * @brief Destroys a STT handle.
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/recorder
+ *
+ * @param[in] stt The STT handle
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STT_ERROR_NONE Successful
+ * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STT_ERROR_OPERATION_FAILED Operation failure
+ * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
+ *
+ * @see stt_create()
+*/
+int stt_destroy(stt_h stt);
+
+/**
+ * @brief Retrieves supported engine information using a callback function.
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/recorder
+ *
+ * @param[in] stt The STT 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 #STT_ERROR_NONE Success
+ * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STT_ERROR_INVALID_STATE STT Not initialized
+ * @retval #STT_ERROR_OPERATION_FAILED Operation failure
+ * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
+ *
+ * @pre The state should be #STT_STATE_CREATED.
+ * @post This function invokes stt_supported_engine_cb() repeatedly for getting engine information.
+ *
+ * @see stt_supported_engine_cb()
+*/
+int stt_foreach_supported_engines(stt_h stt, stt_supported_engine_cb callback, void* user_data);
+
+/**
+ * @brief Gets the current engine id.
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/recorder
+ *
+ * @remarks If the function is success, @a engine_id must be released using free().
+ *
+ * @param[in] stt The STT handle
+ * @param[out] engine_id Engine id
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STT_ERROR_NONE Success
+ * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STT_ERROR_INVALID_STATE STT Not initialized
+ * @retval #STT_ERROR_OPERATION_FAILED Operation failure
+ * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
+ *
+ * @pre The state should be #STT_STATE_CREATED.
+ *
+ * @see stt_set_engine()
+*/
+int stt_get_engine(stt_h stt, char** engine_id);
+
+/**
+ * @brief Sets the engine id.
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/recorder
+ *
+ * @param[in] stt The STT handle
+ * @param[in] engine_id Engine id
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STT_ERROR_NONE Success
+ * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STT_ERROR_INVALID_STATE STT Not initialized
+ * @retval #STT_ERROR_OPERATION_FAILED Operation failure
+ * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
+ *
+ * @pre The state should be #STT_STATE_CREATED.
+ *
+ * @see stt_get_engine()
+*/
+int stt_set_engine(stt_h stt, const char* engine_id);
+
+/**
+ * @brief Connects the daemon asynchronously.
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/recorder
+ *
+ * @param[in] stt The STT handle
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STT_ERROR_NONE Successful
+ * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STT_ERROR_INVALID_STATE Invalid state
+ * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
+ *
+ * @pre The state should be #STT_STATE_CREATED.
+ * @post If this function is successful, the STT state will be #STT_STATE_READY. \n 
+ *     If this function is failed, the error callback is called. (e.g. #STT_ERROR_ENGINE_NOT_FOUND)
+ *
+ * @see stt_unprepare()
+*/
+int stt_prepare(stt_h stt);
+
+/**
+ * @brief Disconnects the daemon.
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/recorder
+ *
+ * @param[in] stt The STT handle
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STT_ERROR_NONE Successful
+ * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STT_ERROR_INVALID_STATE Invalid state
+ * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
+ *
+ * @pre The state should be #STT_STATE_READY.
+ * @post If this function is called, the STT state will be #STT_STATE_CREATED.
+ *
+ * @see stt_prepare()
+*/
+int stt_unprepare(stt_h stt);
+
+/**
+ * @brief Retrieves all supported languages of current engine using callback function.
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/recorder
+ *
+ * @param[in] stt The STT 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 #STT_ERROR_NONE Successful
+ * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STT_ERROR_OPERATION_FAILED Operation failure
+ * @retval #STT_ERROR_ENGINE_NOT_FOUND No available engine
+ * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
+ *
+ * @post This function invokes stt_supported_language_cb() repeatedly for getting languages.
+ *
+ * @see stt_supported_language_cb()
+ * @see stt_get_default_language()
+*/
+int stt_foreach_supported_languages(stt_h stt, stt_supported_language_cb callback, void* user_data);
+
+/**
+ * @brief Gets the default language set by the user.
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/recorder
+ * @remarks The language is specified as an ISO 3166 alpha-2 two letter country-code followed by ISO 639-1 for the two-letter language code. \n
+ * For example, "ko_KR" for Korean, "en_US" for American English. \n
+ * If the function succeeds, @a language must be released using free() when it is no longer required.
+ *
+ * @param[in] stt The STT handle
+ * @param[out] language The language
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STT_ERROR_NONE Successful
+ * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STT_ERROR_OPERATION_FAILED Operation failure
+ * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
+ *
+ * @see stt_foreach_supported_languages()
+*/
+int stt_get_default_language(stt_h stt, char** language);
+
+/**
+ * @brief Gets the current STT state.
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/recorder
+ *
+ * @param[in] stt The STT handle
+ * @param[out] state The current STT state
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STT_ERROR_NONE Successful
+ * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
+ *
+ * @see stt_start()
+ * @see stt_stop()
+ * @see stt_cancel()
+ * @see stt_state_changed_cb()
+*/
+int stt_get_state(stt_h stt, stt_state_e* state);
+
+/**
+ * @brief Checks whether the recognition type is supported.
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/recorder
+ *
+ * @param[in] stt The STT handle
+ * @param[in] type The type for recognition (e.g. #STT_RECOGNITION_TYPE_FREE, #STT_RECOGNITION_TYPE_FREE_PARTIAL)
+ * @param[out] support The result status @c true = supported, @c false = not supported
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STT_ERROR_NONE Successful
+ * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STT_ERROR_OPERATION_FAILED Operation failure
+ * @retval #STT_ERROR_INVALID_STATE Invalid state
+ * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
+ *
+ * @pre The state should be #STT_STATE_READY.
+*/
+int stt_is_recognition_type_supported(stt_h stt, const char* type, bool* support);
+
+/**
+ * @brief Sets the silence detection.
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/recorder
+ *
+ * @param[in] stt The STT handle
+ * @param[in] type The option type
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STT_ERROR_NONE Successful
+ * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STT_ERROR_INVALID_STATE Invalid state
+ * @retval #STT_ERROR_NOT_SUPPORTED_FEATURE Not supported feature of current engine
+ * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
+ *
+ * @pre The state should be #STT_STATE_READY.
+*/
+int stt_set_silence_detection(stt_h stt, stt_option_silence_detection_e type);
+
+/**
+ * @brief Sets the sound to start recording.
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/recorder
+ *
+ * @remarks Sound file type should be wav type.
+ *
+ * @param[in] stt The STT handle
+ * @param[in] filename The sound file path
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STT_ERROR_NONE Successful
+ * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STT_ERROR_INVALID_STATE Invalid state
+ * @retval #STT_ERROR_OPERATION_FAILED Operation failure
+ * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
+ *
+ * @pre The state should be #STT_STATE_READY.
+*/
+int stt_set_start_sound(stt_h stt, const char* filename);
+
+/**
+ * @brief Unsets the sound to start recording.
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/recorder
+ *
+ * @param[in] stt The STT handle
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STT_ERROR_NONE Successful
+ * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STT_ERROR_INVALID_STATE Invalid state
+ * @retval #STT_ERROR_OPERATION_FAILED Operation failure
+ * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
+ *
+ * @pre The state should be #STT_STATE_READY.
+*/
+int stt_unset_start_sound(stt_h stt);
+
+/**
+ * @brief Sets the sound to stop recording.
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/recorder
+ *
+ * @remarks Sound file type should be wav type.
+ *
+ * @param[in] stt The STT handle
+ * @param[in] filename The sound file path
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STT_ERROR_NONE Successful
+ * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STT_ERROR_INVALID_STATE Invalid state
+ * @retval #STT_ERROR_OPERATION_FAILED Operation failure
+ * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
+ *
+ * @pre The state should be #STT_STATE_READY.
+*/
+int stt_set_stop_sound(stt_h stt, const char* filename);
+
+/**
+ * @brief Unsets the sound to stop recording.
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/recorder
+ *
+ * @param[in] stt The STT handle
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STT_ERROR_NONE Successful
+ * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STT_ERROR_INVALID_STATE Invalid state
+ * @retval #STT_ERROR_OPERATION_FAILED Operation failure
+ * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
+ *
+ * @pre The state should be #STT_STATE_READY.
+*/
+int stt_unset_stop_sound(stt_h stt);
+
+/**
+ * @brief Starts recording and recognition asynchronously.
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/recorder
+ *
+ * @remarks This function starts recording in the daemon and sending recording data to engine. \n
+ * This work continues until stt_stop(), stt_cancel() or silence detected by engine.
+ *
+ * @param[in] stt The STT handle
+ * @param[in] language The language selected from stt_foreach_supported_languages()
+ * @param[in] type The type for recognition (e.g. #STT_RECOGNITION_TYPE_FREE, #STT_RECOGNITION_TYPE_FREE_PARTIAL)
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STT_ERROR_NONE Successful
+ * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STT_ERROR_INVALID_STATE Invalid state
+ * @retval #STT_ERROR_OPERATION_FAILED Operation failure
+ * @retval #STT_ERROR_RECORDER_BUSY Recorder busy
+ * @retval #STT_ERROR_INVALID_LANGUAGE Invalid language
+ * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
+ *
+ * @pre The state should be #STT_STATE_READY.
+ * @post It will invoke stt_state_changed_cb(), if you register a callback with stt_state_changed_cb(). \n
+ * If this function succeeds, the STT state will be #STT_STATE_RECORDING.
+ *
+ * @see stt_stop()
+ * @see stt_cancel()
+ * @see stt_state_changed_cb()
+*/
+int stt_start(stt_h stt, const char* language, const char* type);
+
+/**
+ * @brief Finishes the recording and starts recognition processing in engine asynchronously.
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/recorder
+ *
+ * @param[in] stt The STT handle
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STT_ERROR_NONE Successful
+ * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STT_ERROR_INVALID_STATE Invalid state
+ * @retval #STT_ERROR_OPERATION_FAILED Operation failure
+ * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
+ *
+ * @pre The state should be #STT_STATE_RECORDING.
+ * @post It will invoke stt_state_changed_cb(), if you register a callback with stt_state_changed_cb(). \n
+ * If this function succeeds, the STT state will be #STT_STATE_PROCESSING. \n
+ * After processing of engine, stt_result_cb() is called.
+ *
+ * @see stt_start()
+ * @see stt_cancel()
+ * @see stt_state_changed_cb()
+*/
+int stt_stop(stt_h stt);
+
+/**
+ * @brief Cancels processing recognition and recording.
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/recorder
+ *
+ * @remarks This function cancels recording and engine cancels recognition processing. \n
+ * After successful cancel, stt_state_changed_cb() is called otherwise if error is occurred, stt_error_cb() is called.
+ *
+ * @param[in] stt The STT handle
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STT_ERROR_NONE Successful
+ * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STT_ERROR_INVALID_STATE Invalid state
+ * @retval #STT_ERROR_OPERATION_FAILED Operation failure
+ * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
+ *
+ * @pre The state should be #STT_STATE_RECORDING or #STT_STATE_PROCESSING.
+ * @post It will invoke stt_state_changed_cb(), if you register a callback with stt_state_changed_cb(). \n
+ * If this function succeeds, the STT state will be #STT_STATE_READY.
+ *
+ * @see stt_start()
+ * @see stt_stop()
+ * @see stt_state_changed_cb()
+*/
+int stt_cancel(stt_h stt);
+
+/**
+ * @brief Gets the microphone volume during recording.
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/recorder
+ *
+ * @param[in] stt The STT handle
+ * @param[out] volume Recording volume
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STT_ERROR_NONE Successful
+ * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STT_ERROR_INVALID_STATE Invalid state
+ * @retval #STT_ERROR_OPERATION_FAILED Operation failure
+ * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
+ *
+ * @pre The state should be #STT_STATE_RECORDING.
+ *
+ * @see stt_start()
+*/
+int stt_get_recording_volume(stt_h stt, float* volume);
+
+/**
+ * @brief Retrieves the time stamp of the current recognition result using the callback function.
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/recorder
+ *
+ * @remarks This function should be called in stt_recognition_result_cb(). 
+ *     After stt_recognition_result_cb(), result data is NOT valid.
+ *
+ * @param[in] stt The STT 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 #STT_ERROR_NONE Successful
+ * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STT_ERROR_OPERATION_FAILED Operation failure
+ * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
+ *
+ * @pre This function should be called in stt_recognition_result_cb().
+ * @post This function invokes stt_result_time_cb() repeatedly for getting time information.
+ *
+ * @see stt_result_time_cb()
+ * @see stt_recognition_result_cb()
+*/
+int stt_foreach_detailed_result(stt_h stt, stt_result_time_cb callback, void* user_data);
+
+/**
+ * @brief Registers a callback function to get the recognition result.
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/recorder
+ *
+ * @param[in] stt The STT 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 #STT_ERROR_NONE Successful
+ * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STT_ERROR_INVALID_STATE Invalid state
+ * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
+ *
+ * @pre The state should be #STT_STATE_CREATED.
+ *
+ * @see stt_recognition_result_cb()
+ * @see stt_unset_recognition_result_cb()
+*/
+int stt_set_recognition_result_cb(stt_h stt, stt_recognition_result_cb callback, void* user_data);
+
+/**
+ * @brief Unregisters the callback function.
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/recorder
+ *
+ * @param[in] stt The STT handle
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STT_ERROR_NONE Successful
+ * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STT_ERROR_INVALID_STATE Invalid state
+ * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
+ *
+ * @pre The state should be #STT_STATE_CREATED.
+ *
+ * @see stt_set_recognition_result_cb()
+*/
+int stt_unset_recognition_result_cb(stt_h stt);
+
+/**
+ * @brief Registers a callback function to be called when STT state changes.
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/recorder
+ *
+ * @param[in] stt The STT 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 #STT_ERROR_NONE Successful
+ * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STT_ERROR_INVALID_STATE Invalid state
+ * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
+ *
+ * @pre The state should be #STT_STATE_CREATED.
+ *
+ * @see stt_state_changed_cb()
+ * @see stt_unset_state_changed_cb()
+*/
+int stt_set_state_changed_cb(stt_h stt, stt_state_changed_cb callback, void* user_data);
+
+/**
+ * @brief Unregisters the callback function.
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/recorder
+ *
+ * @param[in] stt The STT handle
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STT_ERROR_NONE Successful
+ * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STT_ERROR_INVALID_STATE Invalid state
+ * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
+ *
+ * @pre The state should be #STT_STATE_CREATED.
+ *
+ * @see stt_set_state_changed_cb()
+*/
+int stt_unset_state_changed_cb(stt_h stt);
+
+/**
+ * @brief Registers a callback function to be called when an error occurred.
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/recorder
+ *
+ * @param[in] stt The STT 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 #STT_ERROR_NONE Successful
+ * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STT_ERROR_INVALID_STATE Invalid state
+ * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
+ *
+ * @pre The state should be #STT_STATE_CREATED.
+ *
+ * @see stt_error_cb()
+ * @see stt_unset_error_cb()
+*/
+int stt_set_error_cb(stt_h stt, stt_error_cb callback, void* user_data);
+
+/**
+ * @brief Unregisters the callback function.
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/recorder
+ *
+ * @param[in] stt The STT handle
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STT_ERROR_NONE Successful
+ * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STT_ERROR_INVALID_STATE Invalid state
+ * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
+ *
+ * @pre The state should be #STT_STATE_CREATED.
+ *
+ * @see stt_set_error_cb()
+*/
+int stt_unset_error_cb(stt_h stt);
+
+/**
+ * @brief Registers a callback function to detect the default language change.
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/recorder
+ *
+ * @param[in] stt The STT 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 #STT_ERROR_NONE Successful
+ * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STT_ERROR_INVALID_STATE Invalid state
+ * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
+ *
+ * @pre The state should be #STT_STATE_CREATED.
+ *
+ * @see stt_default_language_changed_cb()
+ * @see stt_unset_default_language_changed_cb()
+*/
+int stt_set_default_language_changed_cb(stt_h stt, stt_default_language_changed_cb callback, void* user_data);
+
+/**
+ * @brief Unregisters the callback function.
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/recorder
+ *
+ * @param[in] stt The STT handle
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STT_ERROR_NONE Successful
+ * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STT_ERROR_INVALID_STATE Invalid state
+ * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
+ *
+ * @pre The state should be #STT_STATE_CREATED.
+ *
+ * @see stt_set_default_language_changed_cb()
+*/
+int stt_unset_default_language_changed_cb(stt_h stt);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+/**
+ * @}@}
+ */
+
+#endif /* __STT_H__ */
+
similarity index 100%
rename from client/stt.pc.in
rename to include/stt.pc.in
diff --git a/include/stt_file.h b/include/stt_file.h
new file mode 100644 (file)
index 0000000..3e99067
--- /dev/null
@@ -0,0 +1,432 @@
+/*
+ * 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 __STT_FILE_H__
+#define __STT_FILE_H__
+
+#include <errno.h>
+#include <stdbool.h>
+
+/**
+* @addtogroup STT_FILE_MODULE
+* @{
+*/
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+* @brief Enumerations of error codes.
+*/
+typedef enum {
+       STT_FILE_ERROR_NONE                     = 0,                    /**< Successful */
+       STT_FILE_ERROR_OUT_OF_MEMORY            = -ENOMEM,              /**< Out of Memory */
+       STT_FILE_ERROR_IO_ERROR                 = -EIO,                 /**< I/O error */
+       STT_FILE_ERROR_INVALID_PARAMETER        = -EINVAL,              /**< Invalid parameter */
+       STT_FILE_ERROR_OUT_OF_NETWORK           = -ENETDOWN,            /**< Out of network */
+       STT_FILE_ERROR_INVALID_STATE            = -0x0100000 | 0x31,    /**< Invalid state */
+       STT_FILE_ERROR_INVALID_LANGUAGE         = -0x0100000 | 0x32,    /**< Invalid language */
+       STT_FILE_ERROR_ENGINE_NOT_FOUND         = -0x0100000 | 0x33,    /**< No available engine  */
+       STT_FILE_ERROR_OPERATION_FAILED         = -0x0100000 | 0x34,    /**< Operation failed  */
+       STT_FILE_ERROR_NOT_SUPPORTED_FEATURE    = -0x0100000 | 0x35,    /**< Not supported feature of current engine */
+       STT_FILE_ERROR_NOT_AGREE_SERVICE        = -0x0100000 | 0x36     /**< Not agreed service of engine*/
+}stt_file_error_e;
+
+/**
+* @brief Enumerations of state.
+*/
+typedef enum {
+       STT_FILE_STATE_NONE             = 0,    /**< 'NONE' state */
+       STT_FILE_STATE_READY            = 1,    /**< 'READY' state */
+       STT_FILE_STATE_PROCESSING       = 2,    /**< 'PROCESSING' state */
+}stt_file_state_e;
+
+/**
+* @brief Enumerations of audio type.
+*/
+typedef enum {
+       STT_FILE_AUDIO_TYPE_RAW_S16 = 0,        /**< Signed 16-bit audio sample */
+       STT_FILE_AUDIO_TYPE_RAW_U8,             /**< Unsigned 8-bit audio sample */
+       STT_FILE_AUDIO_TYPE_MAX
+}stt_file_audio_type_e;
+
+/**
+* @brief Enumerations of result event.
+*/
+typedef enum {
+       STT_FILE_RESULT_EVENT_FINAL_RESULT = 0, /**< Event when the recognition full or last result is ready  */
+       STT_FILE_RESULT_EVENT_PARTIAL_RESULT,   /**< Event when the recognition partial result is ready  */
+       STT_FILE_RESULT_EVENT_ERROR             /**< Event when the recognition has failed */
+}stt_file_result_event_e;
+
+/**
+* @brief Enumerations of result time callback event.
+*/
+typedef enum {
+       STT_FILE_RESULT_TIME_EVENT_BEGINNING = 0,       /**< Event when the token is beginning type */
+       STT_FILE_RESULT_TIME_EVENT_MIDDLE = 1,          /**< Event when the token is middle type */
+       STT_FILE_RESULT_TIME_EVENT_END = 2              /**< Event when the token is end type */
+}stt_file_result_time_event_e;
+
+/**
+* @brief Recognition type : Continuous free dictation. 
+*/
+#define STT_RECOGNITION_TYPE_FREE_PARTIAL      "stt.recognition.type.FREE.PARTIAL"
+
+
+/**
+* @brief Called to get a engine information.
+*
+* @param[in] engine_id Engine id.
+* @param[in] engine_name Engine name.
+* @param[in] user_data User data passed from the stt_file_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 stt_file_foreach_supported_engines() will invoke this callback. 
+*
+* @see stt_file_foreach_supported_engines()
+*/
+typedef bool(*stt_file_supported_engine_cb)(const char* engine_id, const char* engine_name, void* user_data);
+
+/**
+* @brief Called when STT gets the recognition result from engine.
+*
+* @remark After stt_file_start() is called and recognition result is occured, this function is called.
+*
+* @param[in] event The result event
+* @param[in] data Result texts
+* @param[in] data_count Result text count
+* @param[in] msg Engine message        (e.g. #STT_RESULT_MESSAGE_NONE, #STT_RESULT_MESSAGE_ERROR_TOO_SHORT)
+* @param[in] user_data The user data passed from the callback registration function
+*
+* @pre stt_file_start() will invoke this callback if you register it using stt_file_set_recognition_result_cb().
+* @post If this function is called and event is #STT_RESULT_EVENT_FINAL_RESULT, the STT FILE state will be #STT_FILE_STATE_READY.
+*
+* @see stt_file_set_recognition_result_cb()
+* @see stt_file_unset_recognition_result_cb()
+*/
+typedef void (*stt_file_recognition_result_cb)(stt_file_result_event_e event, const char** data, int data_count, 
+                                         const char* msg, void *user_data);
+
+/**
+* @brief Called when STT get the time stamp of recognition result.
+*
+* @param[in] index The result index
+* @param[in] event The token event
+* @param[in] text The result text
+* @param[in] start_time The start time of result text
+* @param[in] end_time The end time of result text
+* @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 stt_file_recognition_result_cb() should be called.
+*
+* @see stt_file_recognition_result_cb()
+*/
+typedef bool (*stt_file_result_time_cb)(int index, stt_file_result_time_event_e event, const char* text, 
+                                  long start_time, long end_time, void* user_data);
+
+/**
+* @brief Called when the state of STT FILE is changed. 
+*
+* @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 stt_file_set_state_changed_cb() to detect changing state.
+*
+* @see stt_file_set_state_changed_cb()
+* @see stt_file_unset_state_changed_cb()
+*/
+typedef void (*stt_file_state_changed_cb)(stt_file_state_e previous, stt_file_state_e current, void* user_data);
+
+/**
+* @brief Called to retrieve the supported languages. 
+*
+* @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] 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 stt_file_foreach_supported_languages() will invoke this callback. 
+*
+* @see stt_file_foreach_supported_languages()
+*/
+typedef bool (*stt_file_supported_language_cb)(const char* language, void* user_data);
+
+
+/**
+* @brief Initialize STT FILE.
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #STT_FILE_ERROR_NONE Successful
+* @retval #STT_FILE_ERROR_INVALID_STATE Invalid state
+* @retval #STT_FILE_ERROR_OPERATION_FAILED Operation failure
+* @retval #STT_FILE_ERROR_ENGINE_NOT_FOUND Engine not found
+*
+* @pre The state should be #STT_FILE_STATE_NONE.
+* @post If this function is called, the STT state will be #STT_FILE_STATE_READY.
+*
+* @see stt_file_deinitialize()
+*/
+int stt_file_initialize();
+
+/**
+* @brief Deinitialize STT FILE.
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #STT_FILE_ERROR_NONE Successful
+* @retval #STT_FILE_ERROR_INVALID_STATE Invalid state
+*
+* @pre The state should be #STT_FILE_STATE_READY.
+* @post If this function is called, the STT FILE state will be #STT_FILE_STATE_NONE.
+*
+* @see stt_file_initialize()
+*/
+int stt_file_deinitialize();
+
+/**
+* @brief Gets the current state.
+*
+* @param[out] state The current state of STT
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #STT_FILE_ERROR_NONE Successful
+* @retval #STT_FILE_ERROR_INVALID_PARAMETER Invalid parameter
+*
+* @see stt_file_state_changed_cb()
+*/
+int stt_file_get_state(stt_file_state_e* state);
+
+/**
+* @brief Retrieve supported engine informations using callback function.
+*
+* @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 #STT_FILE_ERROR_NONE Success.
+* @retval #STT_FILE_ERROR_INVALID_PARAMETER Invalid parameter.
+* @retval #STT_FILE_ERROR_INVALID_STATE STT Not initialized.
+* @retval #STT_FILE_ERROR_OPERATION_FAILED Operation failure.
+*
+* @pre The state should be #STT_FILE_STATE_READY.
+* @post        This function invokes stt_file_supported_engine_cb() repeatedly for getting engine information. 
+*
+* @see stt_file_supported_engine_cb()
+*/
+int stt_file_foreach_supported_engines(stt_file_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 #STT_FILE_ERROR_NONE Success.
+* @retval #STT_FILE_ERROR_OUT_OF_MEMORY Out of memory.
+* @retval #STT_FILE_ERROR_INVALID_PARAMETER Invalid parameter.
+* @retval #STT_FILE_ERROR_INVALID_STATE Invalid state. 
+* @retval #STT_FILE_ERROR_OPERATION_FAILED Operation failure.
+*
+* @pre The state should be #STT_FILE_STATE_READY.
+*
+* @see stt_file_foreach_supported_engines()
+* @see stt_file_set_engine()
+*/
+int stt_file_get_engine(char** engine_id);
+
+/**
+* @brief Set engine id.
+*
+* @param[in] engine_id engine id.
+*
+* @return 0 on success, otherwise a negative error value.
+* @retval #STT_FILE_ERROR_NONE Success.
+* @retval #STT_FILE_ERROR_INVALID_PARAMETER Invalid parameter.
+* @retval #STT_FILE_ERROR_INVALID_STATE Invalid state.
+* @retval #STT_FILE_ERROR_OPERATION_FAILED Operation failure.
+*
+* @pre The state should be #STT_FILE_STATE_READY.
+*
+* @see stt_file_get_engine()
+*/
+int stt_file_set_engine(const char* engine_id);
+
+/**
+* @brief Retrieves all supported languages of current engine using callback function.
+*
+* @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 #STT_FILE_ERROR_NONE Successful
+* @retval #STT_FILE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #STT_FILE_ERROR_OPERATION_FAILED Operation failure
+* @retval #STT_FILE_ERROR_INVALID_STATE Invalid state
+*
+* @pre The state should be #STT_FILE_STATE_READY.
+* @post        This function invokes stt_file_supported_language_cb() repeatedly for getting languages. 
+*
+* @see stt_file_supported_language_cb()
+* @see stt_file_get_default_language()
+*/
+int stt_file_foreach_supported_languages(stt_file_supported_language_cb callback, void* user_data);
+
+
+/**
+* @brief Starts file recognition asynchronously.
+*
+* @param[in] language The language selected from stt_file_foreach_supported_languages()
+* @param[in] type The type for recognition (e.g. #STT_RECOGNITION_TYPE_FREE_PARTIAL)
+* @param[in] filepath PCM filepath for recognition
+* @param[in] audio_type audio type of file
+* @param[in] sample_rate sample rate of file
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #STT_FILE_ERROR_NONE Successful
+* @retval #STT_FILE_ERROR_INVALID_PARAMETER Invalid parameter.
+* @retval #STT_FILE_ERROR_INVALID_STATE Invalid state
+* @retval #STT_FILE_ERROR_OPERATION_FAILED Operation failure
+* @retval #STT_FILE_ERROR_INVALID_LANGUAGE Invalid language
+* @retval #STT_FILE_ERROR_OUT_OF_NETWORK Out of network
+*
+* @pre The state should be #STT_FILE_STATE_READY.
+* @post It will invoke stt_file_state_changed_cb(), if you register a callback with stt_file_state_changed_cb(). \n
+* If this function succeeds, the STT state will be #STT_FILE_STATE_PROCESSING.
+*
+* @see stt_file_cancel()
+*/
+int stt_file_start(const char* language, const char* type, const char* filepath, 
+                       stt_file_audio_type_e audio_type, int sample_rate);
+
+/**
+* @brief Cancels processing recognition.
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #STT_FILE_ERROR_NONE Successful
+* @retval #STT_FILE_ERROR_INVALID_STATE Invalid state
+* @retval #STT_FILE_ERROR_OPERATION_FAILED Operation failure
+*
+* @pre The state should be #STT_FILE_STATE_PROCESSING.
+* @post It will invoke stt_file_state_changed_cb(), if you register a callback with stt_file_state_changed_cb(). \n
+* If this function succeeds, the STT state will be #STT_FILE_STATE_READY.
+*
+* @see stt_file_start()
+*/
+int stt_file_cancel();
+
+
+/**
+* @brief Retrieves time stamp of current recognition result using callback function.
+*
+* @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 #STT_FILE_ERROR_NONE Successful
+* @retval #STT_FILE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #STT_FILE_ERROR_OPERATION_FAILED Operation failure
+* @retval #STT_FILE_ERROR_INVALID_STATE Invalid state
+*
+* @pre This function should be called in stt_file_recognition_result_cb().
+* @post        This function invokes stt_file_result_time_cb() repeatedly for getting time information. 
+*
+* @see stt_file_result_time_cb()
+* @see stt_file_recognition_result_cb()
+*/
+int stt_file_foreach_detailed_result(stt_file_result_time_cb callback, void* user_data);
+
+/**
+* @brief Registers a callback function for getting recognition result.
+*
+* @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 #STT_FILE_ERROR_NONE Successful
+* @retval #STT_FILE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #STT_FILE_ERROR_INVALID_STATE Invalid state
+*
+* @pre The state should be #STT_FILE_STATE_READY.
+*
+* @see stt_file_recognition_result_cb()
+* @see stt_file_unset_recognition_result_cb()
+*/
+int stt_file_set_recognition_result_cb(stt_file_recognition_result_cb callback, void* user_data);
+
+/**
+* @brief Unregisters the callback function.
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #STT_FILE_ERROR_NONE Successful
+* @retval #STT_FILE_ERROR_INVALID_STATE Invalid state
+*
+* @pre The state should be #STT_FILE_STATE_READY.
+*
+* @see stt_file_set_recognition_result_cb()
+*/
+int stt_file_unset_recognition_result_cb();
+
+/**
+* @brief Registers a callback function to be called when STT FILE state changes.
+*
+* @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 #STT_FILE_ERROR_NONE Successful
+* @retval #STT_FILE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #STT_FILE_ERROR_INVALID_STATE Invalid state
+*
+* @pre The state should be #STT_FILE_STATE_READY.
+*
+* @see stt_file_state_changed_cb()
+* @see stt_file_unset_state_changed_cb()
+*/
+int stt_file_set_state_changed_cb(stt_file_state_changed_cb callback, void* user_data);
+
+/**
+* @brief Unregisters the callback function.
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #STT_FILE_ERROR_NONE Successful
+* @retval #STT_FILE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #STT_FILE_ERROR_INVALID_STATE Invalid state
+*
+* @pre The state should be #STT_FILE_STATE_READY.
+*
+* @see stt_file_set_state_changed_cb()
+*/
+int stt_file_unset_state_changed_cb();
+
+
+#ifdef __cplusplus
+}
+#endif
+
+/**
+ * @}@}
+ */
+
+#endif /* __STT_FILE_H__ */
+
similarity index 61%
rename from client/stt_setting.h
rename to include/stt_setting.h
index d82473d..1733858 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
 #ifndef __STT_SETTING_H_
 #define __STT_SETTING_H_
 
-#include <errno.h>
-#include <stdbool.h>
+#include <tizen.h>
+
+/**
+ * @file stt_setting.h
+ */
 
 /**
 * @addtogroup STT_SETTING_MODULE
@@ -31,17 +34,19 @@ extern "C" {
 * @brief Enumerations of error codes.
 */
 typedef enum {
-       STT_SETTING_ERROR_NONE                  = 0,            /**< Success, No error */
-       STT_SETTING_ERROR_OUT_OF_MEMORY         = -ENOMEM,      /**< Out of Memory */
-       STT_SETTING_ERROR_IO_ERROR              = -EIO,         /**< I/O error */
-       STT_SETTING_ERROR_INVALID_PARAMETER     = -EINVAL,      /**< Invalid parameter */
-       STT_SETTING_ERROR_TIMED_OUT             = -ETIMEDOUT,   /**< No answer from the daemon */
-       STT_SETTING_ERROR_OUT_OF_NETWORK        = -ENETDOWN,    /**< Out of network */
-       STT_SETTING_ERROR_INVALID_STATE         = -0x0100031,   /**< Invalid state */
-       STT_SETTING_ERROR_INVALID_LANGUAGE      = -0x0100032,   /**< Invalid language */
-       STT_SETTING_ERROR_ENGINE_NOT_FOUND      = -0x0100033,   /**< No available STT-engine  */
-       STT_SETTING_ERROR_OPERATION_FAILED      = -0x0100034,   /**< STT daemon failed  */
-       STT_SETTING_ERROR_NOT_SUPPORTED_FEATURE = -0x0100035    /**< Not supported feature of current engine */
+       STT_SETTING_ERROR_NONE                  = TIZEN_ERROR_NONE,             /**< Successful */
+       STT_SETTING_ERROR_OUT_OF_MEMORY         = TIZEN_ERROR_OUT_OF_MEMORY,    /**< Out of Memory */
+       STT_SETTING_ERROR_IO_ERROR              = TIZEN_ERROR_IO_ERROR,         /**< I/O error */
+       STT_SETTING_ERROR_INVALID_PARAMETER     = TIZEN_ERROR_INVALID_PARAMETER,/**< Invalid parameter */
+       STT_SETTING_ERROR_TIMED_OUT             = TIZEN_ERROR_TIMED_OUT,        /**< No answer from the daemon */
+       STT_SETTING_ERROR_OUT_OF_NETWORK        = TIZEN_ERROR_NETWORK_DOWN,     /**< Out of network */
+       STT_SETTING_ERROR_PERMISSION_DENIED     = TIZEN_ERROR_PERMISSION_DENIED,/**< Permission denied */
+       STT_SETTING_ERROR_NOT_SUPPORTED         = TIZEN_ERROR_NOT_SUPPORTED,    /**< STT is NOT supported */
+       STT_SETTING_ERROR_INVALID_STATE         = TIZEN_ERROR_STT | 0x01,       /**< Invalid state */
+       STT_SETTING_ERROR_INVALID_LANGUAGE      = TIZEN_ERROR_STT | 0x02,       /**< Invalid language */
+       STT_SETTING_ERROR_ENGINE_NOT_FOUND      = TIZEN_ERROR_STT | 0x03,       /**< No available engine  */    
+       STT_SETTING_ERROR_OPERATION_FAILED      = TIZEN_ERROR_STT | 0x04,       /**< Operation failed  */
+       STT_SETTING_ERROR_NOT_SUPPORTED_FEATURE = TIZEN_ERROR_STT | 0x05        /**< Not supported feature of current engine */
 }stt_setting_error_e;
 
 /** 
@@ -52,6 +57,7 @@ typedef enum {
        STT_SETTING_STATE_READY
 } stt_setting_state_e;
 
+
 /**
 * @brief Called to get a engine information.
 *
@@ -84,45 +90,44 @@ typedef bool(*stt_setting_supported_engine_cb)(const char* engine_id, const char
 typedef bool(*stt_setting_supported_language_cb)(const char* engine_id, const char* language, void* user_data);
 
 /**
-* @brief Called to get a engine setting.
+* @brief Called when the engine information is changed.
 *
-* @param[in] engine_id Engine id.
-* @param[in] key Key.
-* @param[in] value Value.
-* @param[in] user_data User data passed from the stt_setting_foreach_engine_settings().
+* @param[in] user_data The user data passed from the callback registration function
 *
-* @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop.
-* @pre stt_setting_foreach_engine_settings() will invoke this callback. 
+* @pre An application registers this callback using stt_setting_set_engine_changed_cb().
 *
-* @see stt_setting_foreach_engine_settings()
+* @see stt_setting_set_engine_changed_cb()
+* @see stt_setting_unset_engine_changed_cb()
 */
-typedef bool(*stt_setting_engine_setting_cb)(const char* engine_id, const char* key, const char* value, void* user_data);
+typedef void (*stt_setting_engine_changed_cb)(void *user_data);
 
 /**
-* @brief Called to initialize setting.
+* @brief Called when the STT configure is changed.
 *
-* @param[in] state Current state.
-* @param[in] reason Error reason.
-* @param[in] user_data User data passed from the stt_setting_initialize_async().
+* @param[in] user_data The user data passed from the callback registration function
 *
-* @pre stt_setting_initialize_async() will invoke this callback. 
+* @pre An application registers this callback using stt_setting_set_config_changed_cb().
 *
-* @see stt_setting_initialize_async()
+* @see stt_setting_set_config_changed_cb()
+* @see stt_setting_unset_config_changed_cb()
 */
-typedef void(*stt_setting_initialized_cb)(stt_setting_state_e state, stt_setting_error_e reason, void* user_data);
+typedef void (*stt_setting_config_changed_cb)(void *user_data);
 
 /**
-* @brief Initialize STT setting and connect to stt-daemon.
+* @brief Initialize STT setting.
+*
+* @remarks If the function succeeds, @a stt setting must be released with stt_setting_finalize().
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #STT_SETTING_ERROR_NONE Success.
 * @retval #STT_SETTING_ERROR_TIMED_OUT stt daemon is blocked or stt daemon do not exist.
 * @retval #STT_SETTING_ERROR_INVALID_STATE STT setting has Already been initialized. 
 * @retval #STT_SETTING_ERROR_ENGINE_NOT_FOUND No available stt-engine. Engine should be installed.
+* @retval #STT_SETTING_ERROR_NOT_SUPPORTED STT NOT supported
 *
 * @see stt_setting_finalize()
 */
-int stt_setting_initialize(stt_setting_initialized_cb callback, void* user_data);
+int stt_setting_initialize(void);
 
 /**
 * @brief finalize stt setting and disconnect to stt-daemon. 
@@ -131,6 +136,7 @@ int stt_setting_initialize(stt_setting_initialized_cb callback, void* user_data)
 * @retval #STT_SETTING_ERROR_NONE Success.
 * @retval #STT_SETTING_ERROR_INVALID_STATE STT Not initialized. 
 * @retval #STT_SETTING_ERROR_OPERATION_FAILED Operation failure.
+* @retval #STT_SETTING_ERROR_NOT_SUPPORTED STT NOT supported
 *
 * @see stt_setting_initialize()
 */
@@ -145,7 +151,9 @@ int stt_setting_finalize(void);
 * @return 0 on success, otherwise a negative error value.
 * @retval #STT_SETTING_ERROR_NONE Success.
 * @retval #STT_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
-* @retval #STT_SETTING_ERROR_INVALID_STATE STT Not initialized. 
+* @retval #STT_SETTING_ERROR_INVALID_STATE STT Not initialized.
+* @retval #STT_SETTING_ERROR_NOT_SUPPORTED STT NOT supported
+*
 * @post        This function invokes stt_setting_supported_engine_cb() repeatedly for getting engine information. 
 *
 * @see stt_setting_supported_engine_cb()
@@ -165,6 +173,7 @@ int stt_setting_foreach_supported_engines(stt_setting_supported_engine_cb callba
 * @retval #STT_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
 * @retval #STT_SETTING_ERROR_INVALID_STATE STT Not initialized. 
 * @retval #STT_SETTING_ERROR_OPERATION_FAILED Operation failure.
+* @retval #STT_SETTING_ERROR_NOT_SUPPORTED STT NOT supported
 *
 * @see stt_setting_set_engine()
 */
@@ -180,6 +189,7 @@ int stt_setting_get_engine(char** engine_id);
 * @retval #STT_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
 * @retval #STT_SETTING_ERROR_INVALID_STATE STT Not initialized. 
 * @retval #STT_SETTING_ERROR_OPERATION_FAILED Operation failure.
+* @retval #STT_SETTING_ERROR_NOT_SUPPORTED STT NOT supported
 *
 * @see stt_setting_get_engine()
 */
@@ -196,6 +206,7 @@ int stt_setting_set_engine(const char* engine_id);
 * @retval #STT_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
 * @retval #STT_SETTING_ERROR_INVALID_STATE STT Not initialized. 
 * @retval #STT_SETTING_ERROR_OPERATION_FAILED Operation failure.
+* @retval #STT_SETTING_ERROR_NOT_SUPPORTED STT NOT supported
 *
 * @post        This function invokes stt_setting_supported_language_cb() repeatedly for getting supported languages. 
 *
@@ -216,6 +227,7 @@ int stt_setting_foreach_supported_languages(stt_setting_supported_language_cb ca
 * @retval #STT_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
 * @retval #STT_SETTING_ERROR_INVALID_STATE STT Not initialized. 
 * @retval #STT_SETTING_ERROR_OPERATION_FAILED Operation failure.
+* @retval #STT_SETTING_ERROR_NOT_SUPPORTED STT NOT supported
 *
 * @see stt_setting_set_default_language()
 */
@@ -231,129 +243,132 @@ int stt_setting_get_default_language(char** language);
 * @retval #STT_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
 * @retval #STT_SETTING_ERROR_INVALID_STATE STT Not initialized. 
 * @retval #STT_SETTING_ERROR_OPERATION_FAILED Operation failure.
+* @retval #STT_SETTING_ERROR_NOT_SUPPORTED STT NOT supported
 *
 * @see stt_setting_get_default_language()
 */
 int stt_setting_set_default_language(const char* language);
 
 /**
-* @brief Get profanity filter 
+* @brief Set a automatic option of language.
 *
-* @param[out] value Value. 
+* @param[in] value The automatic option
 *
+* @return 0 on success, otherwise a negative error value.
 * @retval #STT_SETTING_ERROR_NONE Success.
 * @retval #STT_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
 * @retval #STT_SETTING_ERROR_INVALID_STATE STT Not initialized. 
 * @retval #STT_SETTING_ERROR_OPERATION_FAILED Operation failure.
+* @retval #STT_SETTING_ERROR_NOT_SUPPORTED STT NOT supported
 *
-* @see stt_setting_set_profanity_filter()
+* @see stt_setting_get_auto_language()
 */
-int stt_setting_get_profanity_filter(bool* value);
+int stt_setting_set_auto_language(bool value);
 
 /**
-* @brief Set profanity filter.
+* @brief Get a automatic option of voice.
 *
-* @param[in] value Value.
+* @param[out] value The automatic option
 *
+* @return 0 on success, otherwise a negative error value.
 * @retval #STT_SETTING_ERROR_NONE Success.
 * @retval #STT_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
 * @retval #STT_SETTING_ERROR_INVALID_STATE STT Not initialized. 
 * @retval #STT_SETTING_ERROR_OPERATION_FAILED Operation failure.
+* @retval #STT_SETTING_ERROR_NOT_SUPPORTED STT NOT supported
 *
-* @see stt_setting_get_profanity_filter()
+* @see stt_setting_set_auto_language()
 */
-int stt_setting_set_profanity_filter(const bool value);
+int stt_setting_get_auto_language(bool* value);
 
 /**
-* @brief Get punctuation override.
+* @brief Get silence detection.
 *
 * @param[out] value Value. 
 *
+* @return 0 on success, otherwise a negative error value
 * @retval #STT_SETTING_ERROR_NONE Success.
 * @retval #STT_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
 * @retval #STT_SETTING_ERROR_INVALID_STATE STT Not initialized. 
 * @retval #STT_SETTING_ERROR_OPERATION_FAILED Operation failure.
+* @retval #STT_SETTING_ERROR_NOT_SUPPORTED STT NOT supported
 *
-* @see stt_setting_set_punctuation_override()
+* @see stt_setting_set_silence_detection()
 */
-int stt_setting_get_punctuation_override(bool* value);
+int stt_setting_get_silence_detection(bool* value);
 
 /**
-* @brief Set punctuation override.
+* @brief Set silence detection.
 *
-* @param[in] value Value.
+* @param[in] value Value. 
 *
+* @return 0 on success, otherwise a negative error value
 * @retval #STT_SETTING_ERROR_NONE Success.
 * @retval #STT_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
 * @retval #STT_SETTING_ERROR_INVALID_STATE STT Not initialized. 
 * @retval #STT_SETTING_ERROR_OPERATION_FAILED Operation failure.
+* @retval #STT_SETTING_ERROR_NOT_SUPPORTED STT NOT supported
 *
-* @see stt_setting_get_punctuation_override()
+* @see stt_setting_get_silence_detection()
 */
-int stt_setting_set_punctuation_override(const bool value);
+int stt_setting_set_silence_detection(const bool value);
 
 /**
-* @brief Get silence detection.
+* @brief Registers a callback function to be called when engine information is changed
 *
-* @param[out] value Value. 
+* @param[in] callback The callback function to register
+* @param[in] user_data The user data to be passed to the callback function
 *
-* @retval #STT_SETTING_ERROR_NONE Success.
-* @retval #STT_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
-* @retval #STT_SETTING_ERROR_INVALID_STATE STT Not initialized. 
-* @retval #STT_SETTING_ERROR_OPERATION_FAILED Operation failure.
+* @return 0 on success, otherwise a negative error value
+* @retval #STT_SETTING_ERROR_NONE Successful
+* @retval #STT_SETTING_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #STT_SETTING_ERROR_OPERATION_FAILED Invalid state
+* @retval #STT_SETTING_ERROR_NOT_SUPPORTED STT NOT supported
 *
-* @see stt_setting_set_silence_detection()
+* @see stt_setting_engine_changed_cb()
+* @see stt_setting_unset_engine_changed_cb()
 */
-int stt_setting_get_silence_detection(bool* value);
+int stt_setting_set_engine_changed_cb(stt_setting_engine_changed_cb callback, void* user_data);
 
 /**
-* @brief Set silence detection.
+* @brief Unregisters the callback function
 *
-* @param[in] value Value. 
+* @return 0 on success, otherwise a negative error value
+* @retval #STT_SETTING_ERROR_NONE Successful
+* @retval #STT_SETTING_ERROR_OPERATION_FAILED Invalid state
 *
-* @retval #STT_SETTING_ERROR_NONE Success.
-* @retval #STT_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
-* @retval #STT_SETTING_ERROR_INVALID_STATE STT Not initialized. 
-* @retval #STT_SETTING_ERROR_OPERATION_FAILED Operation failure.
-*
-* @see stt_setting_get_silence_detection()
+* @see stt_setting_set_engine_changed_cb()
 */
-int stt_setting_set_silence_detection(const bool value);
+int stt_setting_unset_engine_changed_cb();
 
 /**
-* @brief Get setting information of current engine.
+* @brief Registers a callback function to be called when stt configure is changed
 *
-* @param[in] callback callback function
-* @param[in] user_data User data to be passed to the callback function.
+* @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 #STT_SETTING_ERROR_NONE Success.
-* @retval #STT_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
-* @retval #STT_SETTING_ERROR_INVALID_STATE STT Not initialized. 
-* @retval #STT_SETTING_ERROR_OPERATION_FAILED Operation failure.
-*
-* @post        This function invokes stt_setting_engine_setting_cb() repeatedly for getting engine settings. 
+* @return 0 on success, otherwise a negative error value
+* @retval #STT_SETTING_ERROR_NONE Successful
+* @retval #STT_SETTING_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #STT_SETTING_ERROR_OPERATION_FAILED Invalid state
+* @retval #STT_SETTING_ERROR_NOT_SUPPORTED STT NOT supported
 *
-* @see stt_setting_engine_setting_cb()
+* @see stt_setting_config_changed_cb()
+* @see stt_setting_unset_config_changed_cb()
 */
-int stt_setting_foreach_engine_settings(stt_setting_engine_setting_cb callback, void* user_data);
+int stt_setting_set_config_changed_cb(stt_setting_config_changed_cb callback, void* user_data);
 
 /**
-* @brief Set setting information.
-*
-* @param[in] key Key.
-* @param[in] value Value.
+* @brief Unregisters the callback function
 *
-* @return 0 on success, otherwise a negative error value.
-* @retval #STT_SETTING_ERROR_NONE Success.
-* @retval #STT_SETTING_ERROR_INVALID_PARAMETER Invalid parameter.
-* @retval #STT_SETTING_ERROR_INVALID_STATE STT Not initialized. 
-* @retval #STT_SETTING_ERROR_OPERATION_FAILED Operation failure.
+* @return 0 on success, otherwise a negative error value
+* @retval #STT_SETTING_ERROR_NONE Successful
+* @retval #STT_SETTING_ERROR_OPERATION_FAILED Invalid state
+* @retval #STT_SETTING_ERROR_NOT_SUPPORTED STT NOT supported
 *
-* @see stt_setting_foreach_engine_settings()
+* @see stt_setting_set_config_changed_cb()
 */
-int stt_setting_set_engine_setting(const char* key, const char* value);
-
+int stt_setting_unset_config_changed_cb();
 
 #ifdef __cplusplus
 }
old mode 100755 (executable)
new mode 100644 (file)
index ccb224a..dd0aba7
@@ -1,21 +1,28 @@
 Name:       stt
 Summary:    Speech To Text client library and daemon
-Version:    0.1.41
-Release:    0
+Version:    0.2.53
+Release:    1
 Group:      Graphics & UI Framework/Libraries
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
 Source1001: %{name}.manifest
 Source1002: %{name}-devel.manifest
-BuildRequires:  pkgconfig(glib-2.0)
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+BuildRequires:  pkgconfig(aul)
+BuildRequires:  pkgconfig(capi-base-common)
+BuildRequires:  pkgconfig(capi-media-audio-io)
+BuildRequires:  pkgconfig(capi-media-wav-player)
+BuildRequires:  pkgconfig(capi-system-info)
 BuildRequires:  pkgconfig(dbus-1)
-BuildRequires:  pkgconfig(ecore)
-BuildRequires:  pkgconfig(ecore-file)
 BuildRequires:  pkgconfig(dlog)
-BuildRequires:  pkgconfig(vconf)
-BuildRequires:  pkgconfig(capi-media-audio-io)
-BuildRequires:  pkgconfig(capi-media-sound-manager)
+BuildRequires:  pkgconfig(ecore)
+BuildRequires:  pkgconfig(glib-2.0)
 BuildRequires:  pkgconfig(libtzplatform-config)
+BuildRequires:  pkgconfig(libxml-2.0)
+BuildRequires:  pkgconfig(vconf)
+
+
 BuildRequires:  cmake
 
 %description
@@ -27,42 +34,112 @@ Summary:    Speech To Text header files for STT development
 Group:      Graphics & UI Framework/Development
 Requires:   %{name} = %{version}-%{release}
 
+%package file-devel
+Summary:    File To Text header files for STT FILE development
+Group:      Graphics & UI Framework/Development
+Requires:   %{name} = %{version}-%{release}
+
+%package setting-devel
+Summary:    Speech To Text setting header files for STT development
+Group:      Graphics & UI Framework/Development
+Requires:   %{name} = %{version}-%{release}
+
+%package engine-devel
+Summary:    Speech To Text engine header files for STT development
+Group:      Graphics & UI Framework/Development
+Requires:   %{name} = %{version}-%{release}
+
 %description devel
 Speech To Text header files for STT development.
 
+%description file-devel
+File To Text header files for STT FILE development.
+
+%description setting-devel
+Speech To Text setting header files for STT development.
+
+%description engine-devel
+Speech To Text engine header files for STT development.
 
 %prep
-%setup -q
+%setup -q -n %{name}-%{version}
 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=/usr -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/stt/1.0
+chsmack -a '_' /opt/usr/data/voice/
+chsmack -a 'stt-server' /opt/usr/data/voice/stt/
+chsmack -a 'stt-server' /opt/usr/data/voice/stt/1.0
+chown 5000:5000 /opt/usr/data/voice
+chown 5000:5000 /opt/usr/data/voice/stt
+chown 5000:5000 /opt/usr/data/voice/stt/1.0
+
 
 %postun -p /sbin/ldconfig
 
+/usr/bin/vconftool set -t string db/voice_input/language "auto" -g 5000 -f -s system::vconf_inhouse
+
 %files
 %manifest %{name}.manifest
 %license LICENSE.APLv2
-%config %{_sysconfdir}/config/sysinfo-stt.xml
 %defattr(-,root,root,-)
 %{_libdir}/libstt.so
+%{_libdir}/libstt_file.so
 %{_libdir}/libstt_setting.so
-%{_prefix}/lib/voice/stt/1.0/sttd.conf
+/usr/lib/voice/stt/1.0/stt-config.xml
 %{_bindir}/stt-daemon
+/opt/usr/devel/bin/stt-test
+/usr/share/license/%{name}
 
 %files devel
 %manifest %{name}-devel.manifest
 %defattr(-,root,root,-)
 %{_libdir}/pkgconfig/stt.pc
-%{_libdir}/pkgconfig/stt-setting.pc
 %{_includedir}/stt.h
+
+%files file-devel
+%defattr(-,root,root,-)
+%{_libdir}/pkgconfig/stt-file.pc
+%{_includedir}/stt_file.h
+
+%files setting-devel
+%defattr(-,root,root,-)
+%{_libdir}/pkgconfig/stt-setting.pc
 %{_includedir}/stt_setting.h
+
+%files engine-devel
+%defattr(-,root,root,-)
+%{_libdir}/pkgconfig/stt-engine.pc
 %{_includedir}/sttp.h
index 15ff446..841cd9c 100644 (file)
@@ -1,51 +1,37 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(stt-daemon)
-
-SET(PREFIX ${CMAKE_INSTALL_PREFIX})
-SET(EXEC_PREFIX "${PREFIX}")
-SET(LIBDIR "${PREFIX}/lib")
-SET(INCLUDEDIR "${PREFIX}/include")
-SET(VERSION 0.0.1)
-
 SET(SRCS
-       sttd_config.c
        sttd_client_data.c
-       sttd_engine_agent.c
-       sttd_server.c
-       sttd_recorder.c
-       sttd_network.c
+       sttd_config.c
        sttd_dbus_server.c
        sttd_dbus.c
+       sttd_engine_agent.c
        sttd_main.c
+       sttd_recorder.c
+       sttd_server.c
+       ../common/stt_config_mgr.c
+       ../common/stt_config_parser.c
+       ../common/stt_engine.c
+       ../common/stt_network.c
 )
 
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
-INCLUDE_DIRECTORIES(${INCLUDEDIR})
-INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/../common")
-
-## Dependent packages ##
-#INCLUDE(FindPkgConfig)
-#pkg_check_modules(pkgs REQUIRED 
-#      glib-2.0 dbus-1 
-#      vconf dlog mm-player mm-common mm-camcorder openssl
-#)
+INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/common)
+INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/server)
 
 FOREACH(flag ${pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
 ENDFOREACH(flag)
 
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_C_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")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
 
 ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
 
 ## Executable ##
-ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} -ldl -lm ${pkgs_LDFLAGS})
+ADD_EXECUTABLE("${PROJECT_NAME}-daemon" ${SRCS})
+TARGET_LINK_LIBRARIES("${PROJECT_NAME}-daemon" -ldl -lm ${pkgs_LDFLAGS})
 
 ## Install
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/sttp.h DESTINATION include)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/sttd.conf DESTINATION lib/voice/stt/1.0)
+INSTALL(TARGETS "${PROJECT_NAME}-daemon" DESTINATION bin)
+
diff --git a/server/sttd.conf b/server/sttd.conf
deleted file mode 100644 (file)
index 53f382b..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-ENGINE_ID A7AB375F-443B-4924-80DB-FF3DA1506580\r
-LANGUAGE en_US\r
-SILENCE 1\r
-PROFANITY 0\r
-PUNCTUATION 0
\ No newline at end of file
index 618c924..d02c68a 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 "sttd_client_data.h"
 
 /* Client list */
-static GList *g_client_list = NULL;
+static GSList *g_client_list = NULL;
 
-static GList *g_setting_client_list = NULL;
+static int g_cur_recog_uid = 0;
 
 int client_show_list()
 {
-       GList *iter = NULL;
+       GSList *iter = NULL;
        client_info_s *data = NULL;
 
-       SLOG(LOG_DEBUG, TAG_STTD, "----- client list"); 
+       SLOG(LOG_DEBUG, TAG_STTD, "----- client list");
 
-       if (g_list_length(g_client_list) > 0) {
+       if (g_slist_length(g_client_list) > 0) {
                /* Get a first item */
-               iter = g_list_first(g_client_list);
+               iter = g_slist_nth(g_client_list, 0);
 
                int i = 1;      
                while (NULL != iter) {
                        /*Get handle data from list*/
                        data = iter->data;
 
-                       SLOG(LOG_DEBUG, TAG_STTD, "[%dth] uid(%d), state(%d)", i, data->uid, data->state); 
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[%dth] uid(%d), state(%d)", i, data->uid, data->state);
                        
                        /*Get next item*/
-                       iter = g_list_next(iter);
+                       iter = g_slist_next(iter);
                        i++;
                }
        } else {
-               SLOG(LOG_DEBUG, TAG_STTD, "No Client"); 
+               SLOG(LOG_DEBUG, TAG_STTD, "No Client");
        }
 
-       SLOG(LOG_DEBUG, TAG_STTD, "-----"); 
-
-       SLOG(LOG_DEBUG, TAG_STTD, "----- setting client list"); 
-
-       setting_client_info_s *setting_data = NULL;
-
-       if (g_list_length(g_setting_client_list) > 0) {
-               /* Get a first item */
-               iter = g_list_first(g_setting_client_list);
-
-               int i = 1;      
-               while (NULL != iter) {
-                       /*Get handle data from list*/
-                       setting_data = iter->data;
-
-                       SLOG(LOG_DEBUG, TAG_STTD, "[%dth] pid(%d)", i, setting_data->pid); 
-
-                       /*Get next item*/
-                       iter = g_list_next(iter);
-                       i++;
-               }
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTD, "No setting client"); 
-       }
-
-       SLOG(LOG_DEBUG, TAG_STTD, "-----"); 
+       SLOG(LOG_DEBUG, TAG_STTD, "-----");
 
        return 0;
 }
 
-GList* __client_get_item(const int uid)
+GSList* __client_get_item(int uid)
 {
-       GList *iter = NULL;
+       GSList *iter = NULL;
        client_info_s *data = NULL;
 
-       if (0 < g_list_length(g_client_list)) {
-               iter = g_list_first(g_client_list);
+       if (0 < g_slist_length(g_client_list)) {
+               iter = g_slist_nth(g_client_list, 0);
 
                while (NULL != iter) {
                        /* Get handle data from list */
@@ -91,38 +66,40 @@ GList* __client_get_item(const int uid)
                        if (uid == data->uid) 
                                return iter;
                        
-                       iter = g_list_next(iter);
+                       iter = g_slist_next(iter);
                }
        }
 
        return NULL;
 }
 
-int sttd_client_add(const int pid, const int uid)
+int sttd_client_add(int pid, int uid)
 {
        /*Check uid is duplicated*/
-       GList *tmp = NULL;
+       GSList *tmp = NULL;
        tmp = __client_get_item(uid);
        
        if (NULL != tmp) {
-               SLOG(LOG_WARN, TAG_STTD, "[Client Data] Client uid is already registered"); 
+               SLOG(LOG_WARN, TAG_STTD, "[Client Data] Client uid is already registered");
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
-       client_info_s *info = (client_info_s*)g_malloc0(sizeof(client_info_s));
+       client_info_s *info = (client_info_s*)calloc(1, sizeof(client_info_s));
 
        info->pid = pid;
        info->uid = uid;
+       info->start_beep = NULL;
+       info->stop_beep = NULL;
        info->state = APP_STATE_READY;
 
+       info->app_agreed = false;
+
        /* Add item to global list */
-       g_client_list = g_list_append(g_client_list, info);
+       g_client_list = g_slist_append(g_client_list, info);
        
        if (NULL == g_client_list) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Client Data ERROR] Fail to add new client"); 
+               SLOG(LOG_ERROR, TAG_STTD, "[Client Data ERROR] Fail to add new client");
                return -1;
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTD, "[Client Data SUCCESS] Add new client"); 
        }
 
 #ifdef CLIENT_DATA_DEBUG
@@ -131,26 +108,28 @@ int sttd_client_add(const int pid, const int uid)
        return 0;
 }
 
-int sttd_client_delete(const int uid)
+int sttd_client_delete(int uid)
 {
-       GList *tmp = NULL;
+       GSList *tmp = NULL;
        client_info_s* hnd = NULL;
 
        /*Get handle*/
        tmp = __client_get_item(uid);
        if (NULL == tmp) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Client Data ERROR] uid(%d) is NOT valid", uid); 
+               SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Client Data ERROR] uid(%d) is NOT valid", uid);
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
        /*Free client structure*/
        hnd = tmp->data;
        if (NULL != hnd) {
-               g_free(hnd);
+               if (NULL != hnd->start_beep)    free(hnd->start_beep);
+               if (NULL != hnd->stop_beep)     free(hnd->stop_beep);
+               free(hnd);
        }
 
        /*Remove handle from list*/
-       g_client_list = g_list_remove_link(g_client_list, tmp);
+       g_client_list = g_slist_remove_link(g_client_list, tmp);
 
 #ifdef CLIENT_DATA_DEBUG
        client_show_list();
@@ -159,9 +138,14 @@ int sttd_client_delete(const int uid)
        return 0;
 }
 
-int sttd_client_get_state(const int uid, app_state_e* state)
+int sttd_client_get_start_sound(int uid, char** filename)
 {
-       GList *tmp = NULL;
+       if (NULL == filename) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Client Data ERROR] Filename is NULL");
+               return STTD_ERROR_INVALID_PARAMETER;
+       }
+
+       GSList *tmp = NULL;
        client_info_s* hnd = NULL;
 
        tmp = __client_get_item(uid);
@@ -170,48 +154,140 @@ int sttd_client_get_state(const int uid, app_state_e* state)
        }
 
        hnd = tmp->data;
-       *state = hnd->state;
+       if (NULL != hnd->start_beep) {
+               *filename = strdup(hnd->start_beep);
+       } else {
+               *filename = NULL;
+       }
+
+       return 0;
+}
+
+int sttd_client_set_start_sound(int uid, const char* filename)
+{
+       GSList *tmp = NULL;
+       client_info_s* hnd = NULL;
 
-       SLOG(LOG_DEBUG, TAG_STTD, "[Client Data] Get state : uid(%d), state(%d)", uid, *state);
+       tmp = __client_get_item(uid);
+       if (NULL == tmp) {
+               SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Client Data ERROR] uid(%d) is NOT valid", uid);
+               return STTD_ERROR_INVALID_PARAMETER;
+       }
+
+       hnd = tmp->data;
+       if (NULL != hnd->start_beep) {
+               free(hnd->start_beep);
+       }
+       
+       if (NULL != filename) {
+               hnd->start_beep = strdup(filename);
+               SLOG(LOG_DEBUG, TAG_STTD, "[Client Data] Start sound file : %s", hnd->start_beep);
+       } else {
+               hnd->start_beep = NULL;
+       }
 
        return 0;
 }
 
-int sttd_client_set_state(const int uid, const app_state_e state)
+int sttd_client_get_stop_sound(int uid, char** filename)
 {
-       GList *tmp = NULL;
+       if (NULL == filename) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Client Data ERROR] Filename is NULL");
+               return STTD_ERROR_INVALID_PARAMETER;
+       }
+
+       GSList *tmp = NULL;
        client_info_s* hnd = NULL;
 
        tmp = __client_get_item(uid);
        if (NULL == tmp) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Client Data ERROR] uid(%d) is NOT valid", uid); 
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
        hnd = tmp->data;
-       hnd->state = state ;
+       if (NULL != hnd->stop_beep) {
+               *filename = strdup(hnd->stop_beep);
+       } else {
+               *filename = NULL;
+       }
+
+       return 0;
+}
+
+int sttd_client_set_stop_sound(int uid, const char* filename)
+{
+       GSList *tmp = NULL;
+       client_info_s* hnd = NULL;
+
+       tmp = __client_get_item(uid);
+       if (NULL == tmp) {
+               SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Client Data ERROR] uid(%d) is NOT valid", uid);
+               return STTD_ERROR_INVALID_PARAMETER;
+       }
+
+       hnd = tmp->data;
+       if (NULL != hnd->stop_beep) {
+               free(hnd->stop_beep);
+       }
+       
+       if (NULL != filename) {
+               hnd->stop_beep = strdup(filename);
+               SLOG(LOG_DEBUG, TAG_STTD, "[Client Data] Stop sound file : %s", hnd->stop_beep);
+       } else {
+               hnd->stop_beep = NULL;
+       }
+
+       return 0;
+}
+
+int sttd_client_get_state(int uid, app_state_e* state)
+{
+       GSList *tmp = NULL;
+       client_info_s* hnd = NULL;
+
+       tmp = __client_get_item(uid);
+       if (NULL == tmp) {
+               return STTD_ERROR_INVALID_PARAMETER;
+       }
 
-       SLOG(LOG_DEBUG, TAG_STTD, "[Client Data SUCCESS] Set state : uid(%d), state(%d)", uid, state);
+       hnd = tmp->data;
+       *state = hnd->state;
+
+       return 0;
+}
+
+int sttd_client_set_state(int uid, app_state_e state)
+{
+       GSList *tmp = NULL;
+       client_info_s* hnd = NULL;
+
+       tmp = __client_get_item(uid);
+       if (NULL == tmp) {
+               SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Client Data ERROR] uid(%d) is NOT valid", uid);
+               return STTD_ERROR_INVALID_PARAMETER;
+       }
+
+       hnd = tmp->data;
+       hnd->state = state ;
 
        return 0;
 }
 
 int sttd_client_get_ref_count()
 {
-       int count = g_list_length(g_client_list) + g_list_length(g_setting_client_list);
-       SLOG(LOG_DEBUG, TAG_STTD, "[Client Data] client count : %d", count);
+       int count = g_slist_length(g_client_list);
 
        return count;
 }
 
-int sttd_client_get_pid(const int uid)
+int sttd_client_get_pid(int uid)
 {
-       GList *tmp = NULL;
+       GSList *tmp = NULL;
        client_info_s* hnd = NULL;
 
        tmp = __client_get_item(uid);
        if (NULL == tmp) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Client Data ERROR] sttd_client_get_pid : uid(%d) is not found", uid); 
+               SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Client Data ERROR] sttd_client_get_pid : uid(%d) is not found", uid);
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
@@ -220,13 +296,14 @@ int sttd_client_get_pid(const int uid)
        return hnd->pid;
 }
 
+#if 0
 int sttd_client_get_current_recording()
 {
-       GList *iter = NULL;
+       GSList *iter = NULL;
        client_info_s *data = NULL;
 
-       if (0 < g_list_length(g_client_list)) {
-               iter = g_list_first(g_client_list);
+       if (0 < g_slist_length(g_client_list)) {
+               iter = g_slist_nth(g_client_list, 0);
 
                while (NULL != iter) {
                        /* Get handle data from list */
@@ -235,7 +312,7 @@ int sttd_client_get_current_recording()
                        if (APP_STATE_RECORDING == data->state) 
                                return data->uid;
 
-                       iter = g_list_next(iter);
+                       iter = g_slist_next(iter);
                }
        }
 
@@ -244,11 +321,11 @@ int sttd_client_get_current_recording()
 
 int sttd_client_get_current_thinking()
 {
-       GList *iter = NULL;
+       GSList *iter = NULL;
        client_info_s *data = NULL;
 
-       if (0 < g_list_length(g_client_list)) {
-               iter = g_list_first(g_client_list);
+       if (0 < g_slist_length(g_client_list)) {
+               iter = g_slist_nth(g_client_list, 0);
 
                while (NULL != iter) {
                        /* Get handle data from list */
@@ -257,7 +334,7 @@ int sttd_client_get_current_thinking()
                        if (APP_STATE_PROCESSING == data->state) 
                                return data->uid;
 
-                       iter = g_list_next(iter);
+                       iter = g_slist_next(iter);
                }
        }
 
@@ -266,65 +343,61 @@ int sttd_client_get_current_thinking()
 
 int sttd_cliet_set_timer(int uid, Ecore_Timer* timer)
 {
-       GList *tmp = NULL;
+       GSList *tmp = NULL;
        client_info_s* hnd = NULL;
 
        tmp = __client_get_item(uid);
        if (NULL == tmp) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Client Data ERROR] uid(%d) is NOT valid", uid); 
+               SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Client Data ERROR] uid(%d) is NOT valid", uid);
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
        hnd = tmp->data;
        hnd->timer = timer;
 
-       SLOG(LOG_DEBUG, TAG_STTD, "[Client Data SUCCESS] Set timer : uid(%d)", uid);
-
        return 0;
 }
 
 int sttd_cliet_get_timer(int uid, Ecore_Timer** timer)
 {
-       GList *tmp = NULL;
+       GSList *tmp = NULL;
        client_info_s* hnd = NULL;
 
        tmp = __client_get_item(uid);
        if (NULL == tmp) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Client Data ERROR] uid(%d) is NOT valid", uid); 
+               SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Client Data ERROR] uid(%d) is NOT valid", uid);
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
        hnd = tmp->data;
        *timer = hnd->timer;
 
-       SLOG(LOG_DEBUG, TAG_STTD, "[Client Data SUCCESS] Get timer : uid(%d)", uid);
-
        return 0;
 }
-
+#endif
 
 int sttd_client_get_list(int** uids, int* uid_count)
 {
        if (NULL == uids || NULL == uid_count)
                return -1;
        
-       int count = g_list_length(g_client_list);
+       int count = g_slist_length(g_client_list);
 
        if (0 == count)
-               return -1; 
+               return -1;
 
        int *tmp;
-       tmp = (int*)malloc(sizeof(int) * count);
+       tmp = (int*)calloc(count, sizeof(int));
        
-       GList *iter = NULL;
+       GSList *iter = NULL;
        client_info_s *data = NULL;
        int i = 0;
 
-       iter = g_list_first(g_client_list);
+       iter = g_slist_nth(g_client_list, 0);
        for (i = 0;i < count;i++) {
                data = iter->data;
                tmp[i] = data->uid;
-               iter = g_list_next(iter);
+               iter = g_slist_next(iter);
        }
 
        *uids = tmp;
@@ -333,97 +406,56 @@ int sttd_client_get_list(int** uids, int* uid_count)
        return 0;
 }
 
-/*
-* Functions for setting
-*/
-
-GList* __setting_client_get_item(int pid)
+int stt_client_set_current_recognition(int uid)
 {
-       GList *iter = NULL;
-       setting_client_info_s *data = NULL;
-
-       if (0 < g_list_length(g_setting_client_list)) {
-               iter = g_list_first(g_setting_client_list);
-
-               while (NULL != iter) {
-                       /* Get handle data from list */
-                       data = iter->data;
-
-                       if (pid == data->pid) 
-                               return iter;
-
-                       iter = g_list_next(iter);
-               }
-       }
-
-       return NULL;
-}
-
-int sttd_setting_client_add(int pid)
-{      
-       /* Check uid is duplicated */
-       GList *tmp = NULL;
-       tmp = __setting_client_get_item(pid);
-
-       if (NULL != tmp) {
-               SLOG(LOG_WARN, TAG_STTD, "[Client Data] Setting client(%d) is already registered", pid); 
-               return STTD_ERROR_INVALID_PARAMETER;
+       if (0 != g_cur_recog_uid) {
+               return -1;
        }
 
-       setting_client_info_s *info = (setting_client_info_s*)g_malloc0(sizeof(setting_client_info_s));
+       g_cur_recog_uid = uid;
 
-       info->pid = pid;
-
-       /* Add item to global list */
-       g_setting_client_list = g_list_append(g_setting_client_list, info);
+       return 0;
+}
 
-       if (NULL == g_setting_client_list) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Client Data ERROR] Fail to add new client"); 
-               return -1;
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTD, "[Client Data SUCCESS] Add new client"); 
-       }
+int stt_client_get_current_recognition()
+{
+       return g_cur_recog_uid;
+}
 
-#ifdef CLIENT_DATA_DEBUG
-       client_show_list();
-#endif 
+int stt_client_unset_current_recognition()
+{
+       g_cur_recog_uid = 0;
        return 0;
 }
 
-int sttd_setting_client_delete(int pid)
+int stt_client_set_app_agreed(int uid)
 {
-       GList *tmp = NULL;
-       setting_client_info_s* hnd = NULL;
+       GSList *tmp = NULL;
+       client_info_s* hnd = NULL;
 
-       /*Get handle*/
-       tmp = __setting_client_get_item(pid);
+       tmp = __client_get_item(uid);
        if (NULL == tmp) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Client Data ERROR] Setting uid(%d) is NOT valid", pid); 
+               SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Client Data ERROR] uid(%d) is NOT valid", uid); 
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
-       /*Free client structure*/
        hnd = tmp->data;
-       if (NULL != hnd) {
-               g_free(hnd);
-       }
-
-       /*Remove handle from list*/
-       g_setting_client_list = g_list_remove_link(g_setting_client_list, tmp);
-
-#ifdef CLIENT_DATA_DEBUG
-       client_show_list();
-#endif 
+       hnd->app_agreed = true;
 
        return 0;
 }
 
-bool sttd_setting_client_is(int pid)
+bool stt_client_get_app_agreed(int uid)
 {
-       GList *tmp = __setting_client_get_item(pid);
+       GSList *tmp = NULL;
+       client_info_s* hnd = NULL;
+
+       tmp = __client_get_item(uid);
        if (NULL == tmp) {
-               return false;
+               SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Client Data ERROR] uid(%d) is NOT valid", uid); 
+               return STTD_ERROR_INVALID_PARAMETER;
        }
 
-       return true;
+       hnd = tmp->data;
+       return hnd->app_agreed;
 }
\ No newline at end of file
index 1433736..ba03259 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
@@ -32,26 +32,47 @@ typedef enum {
 typedef struct {
        int     pid;
        int     uid;
+       char*   start_beep;
+       char*   stop_beep;
+
        app_state_e     state;
-       Ecore_Timer*    timer;
-} client_info_s;
+/*     Ecore_Timer*    timer;  */
+
+       bool    app_agreed;
+}client_info_s;
 
 typedef struct {
-       int pid;
-} setting_client_info_s;
+       int     index;
+       int     event;
+       char*   text;
+       long    start_time;
+       long    end_time;
+}result_time_info_s;
+
+typedef bool (*time_callback)(int index, int event, const char* text, long start_time, long end_time, void *user_data);
+
+
+int sttd_client_add(int pid, int uid);
+
+int sttd_client_delete(int uid);
 
-int sttd_client_add(const int pid, const int uid);
+int sttd_client_get_start_sound(int uid, char** filename);
 
-int sttd_client_delete(const int uid);
+int sttd_client_set_start_sound(int uid, const char* filename);
 
-int sttd_client_get_state(const int uid, app_state_e* state);
+int sttd_client_get_stop_sound(int uid, char** filename);
 
-int sttd_client_set_state(const int uid, const app_state_e state);
+int sttd_client_set_stop_sound(int uid, const char* filename);
+
+int sttd_client_get_state(int uid, app_state_e* state);
+
+int sttd_client_set_state(int uid, app_state_e state);
 
 int sttd_client_get_ref_count();
 
-int sttd_client_get_pid(const int uid);
+int sttd_client_get_pid(int uid);
 
+#if 0
 int sttd_client_get_current_recording();
 
 int sttd_client_get_current_thinking();
@@ -59,15 +80,21 @@ int sttd_client_get_current_thinking();
 int sttd_cliet_set_timer(int uid, Ecore_Timer* timer);
 
 int sttd_cliet_get_timer(int uid, Ecore_Timer** timer);
+#endif
 
 int sttd_client_get_list(int** uids, int* uid_count);
 
+int stt_client_set_current_recognition(int uid);
+
+int stt_client_get_current_recognition();
+
+int stt_client_unset_current_recognition();
+
 
-int sttd_setting_client_add(int pid);
+int stt_client_set_app_agreed(int uid);
 
-int sttd_setting_client_delete(int pid);
+bool stt_client_get_app_agreed(int uid);
 
-bool sttd_setting_client_is(int pid);
 
 #ifdef __cplusplus
 }
index 4632c3c..0a129bb 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>
 
-/* For multi-user support */
-#include <tzplatform_config.h>
-
-#include "sttd_main.h"
+#include "stt_config_mgr.h"
 #include "sttd_config.h"
+#include "sttd_main.h"
 
 
-#define CONFIG_FILE_PATH       tzplatform_mkpath(TZ_USER_HOME, ".voice/sttd.conf")
-#define CONFIG_DEFAULT         BASE_DIRECTORY_DEFAULT"/sttd.conf"
+static sttd_config_engine_changed_cb g_engine_cb;
 
-#define ENGINE_ID      "ENGINE_ID"
-#define LANGUAGE       "LANGUAGE"
-#define SILENCE                "SILENCE"
-#define PROFANITY      "PROFANITY"
-#define PUNCTUATION    "PUNCTUATION"
+static sttd_config_language_changed_cb g_lang_cb;
 
+static sttd_config_silence_changed_cb g_silence_cb;
 
-static char*   g_engine_id;
-static char*   g_language;
-static int     g_silence;
-static int     g_profanity;
-static int     g_punctuation;
+static void* g_user_data;
 
-int __sttd_config_save()
-{
-       if (0 != access(CONFIG_FILE_PATH, R_OK|W_OK)) {
-               if (0 == ecore_file_mkpath(CONFIG_DIRECTORY)) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[Config ERROR ] Fail to create directory (%s)", CONFIG_DIRECTORY);
-                       return -1;
-               }
 
-               SLOG(LOG_WARN, TAG_STTD, "[Config] Create directory (%s)", CONFIG_DIRECTORY);
-       }
+const char* stt_tag()
+{
+       return "sttd";
+}
 
-       FILE* config_fp;
-       config_fp = fopen(CONFIG_FILE_PATH, "w+");
 
-       if (NULL == config_fp) {
-               /* make file and file default */
-               SLOG(LOG_ERROR, TAG_STTD, "[Config ERROR] Fail to load config (engine id)");
-               return -1;
+void __sttd_config_engine_changed_cb(const char* engine_id, const char* setting, const char* language, bool support_silence, void* user_data)
+{
+       /* Need to check engine is valid */
+       if (false == stt_config_check_default_engine_is_valid(engine_id)) {
+               SECURE_SLOG(LOG_ERROR, TAG_STTD, "Engine id is NOT valid : %s", engine_id);
+               return;
        }
 
-       SLOG(LOG_DEBUG, TAG_STTD, "[Config] Rewrite config file");
-
-       /* Write engine id */
-       fprintf(config_fp, "%s %s\n", ENGINE_ID, g_engine_id);
-
-       /* Write language */
-       fprintf(config_fp, "%s %s\n", LANGUAGE, g_language);
-
-       /* Write silence detection */
-       fprintf(config_fp, "%s %d\n", SILENCE, g_silence);
-
-       /* Write profanity */
-       fprintf(config_fp, "%s %d\n", PROFANITY, g_profanity);
-
-       /* Write punctuation */
-       fprintf(config_fp, "%s %d\n", PUNCTUATION, g_punctuation);
-
-       fclose(config_fp);
-
-       return 0;
+       if (NULL != g_engine_cb)
+               g_engine_cb(engine_id, language, support_silence, g_user_data);
+       else
+               SLOG(LOG_ERROR, TAG_STTD, "Engine changed callback is NULL");
 }
 
-int __sttd_config_load()
+void __sttd_config_lang_changed_cb(const char* before_language, const char* current_language, 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(CONFIG_FILE_PATH, "r");
-
-       if (NULL == config_fp) {
-               SLOG(LOG_WARN, TAG_STTD, "[Config WARNING] Not open file(%s)", CONFIG_FILE_PATH);
-
-               config_fp = fopen(CONFIG_DEFAULT, "r");
-               if (NULL == config_fp) {
-                       SLOG(LOG_WARN, TAG_STTD, "[Config WARNING] Not open original config file(%s)", CONFIG_FILE_PATH);
-                       __sttd_config_save();
-                       return 0;
-               }
-               is_default_open = true;
+       if (false == stt_config_check_default_language_is_valid(current_language)) {
+               SECURE_SLOG(LOG_ERROR, TAG_STTD, "Language is NOT valid : %s", current_language);
+               return;
        }
 
-       /* Read engine id */
-       if (EOF == fscanf(config_fp, "%s %s", buf_id, buf_param)) {
-               fclose(config_fp);
-               SLOG(LOG_WARN, TAG_STTD, "[Config WARNING] Fail to load config (engine id)");
-               __sttd_config_save();
-               return 0;
-       } else {
-               if (0 == strncmp(ENGINE_ID, buf_id, strlen(ENGINE_ID))) {
-                       g_engine_id = strdup(buf_param);
-               } else {
-                       fclose(config_fp);
-                       SLOG(LOG_WARN, TAG_STTD, "[Config WARNING] Fail to load config (engine id)");
-                       __sttd_config_save();
-                       return 0;
-               }
-       }
+       if (NULL != g_lang_cb)
+               g_lang_cb(current_language, g_user_data);
+       else
+               SLOG(LOG_ERROR, TAG_STTD, "Language changed callback is NULL");
+}
 
-       /* Read language */
-       if (EOF == fscanf(config_fp, "%s %s", buf_id, buf_param)) {
-               fclose(config_fp);
-               SLOG(LOG_WARN, TAG_STTD, "[Config WARNING] Fail to load config (language)");
-               __sttd_config_save();
-               return 0;
-       } else {
-               if (0 == strncmp(LANGUAGE, buf_id, strlen(LANGUAGE))) {
-                       g_language = strdup(buf_param);
-               } else {
-                       fclose(config_fp);
-                       SLOG(LOG_WARN, TAG_STTD, "[Config WARNING] Fail to load config (language)");
-                       __sttd_config_save();
-                       return 0;
-               }
-       }
-       
-       /* Read silence detection */
-       if (EOF == fscanf(config_fp, "%s %d", buf_id, &int_param)) {
-               fclose(config_fp);
-               SLOG(LOG_WARN, TAG_STTD, "[Config WARNING] Fail to load config (silence)");
-               __sttd_config_save();
-               return 0;
-       } else {
-               if (0 == strncmp(SILENCE, buf_id, strlen(SILENCE))) {
-                       g_silence = int_param;
-               } else {
-                       fclose(config_fp);
-                       SLOG(LOG_WARN, TAG_STTD, "[Config WARNING] Fail to load config (silence)");
-                       __sttd_config_save();
-                       return 0;
-               }
-       }
+void __config_bool_changed_cb(stt_config_type_e type, bool bool_value, void* user_data)
+{
+       SECURE_SLOG(LOG_DEBUG, TAG_STTD, " type(%d) bool(%s)", type, bool_value ? "on" : "off");
 
-       /* Read profanity filter */
-       if (EOF == fscanf(config_fp, "%s %d", buf_id, &int_param)) {
-               fclose(config_fp);
-               SLOG(LOG_WARN, TAG_STTD, "[Config WARNING] Fail to load config (profanity filter)");
-               __sttd_config_save();
-               return 0;
-       } else {
-               if (0 == strncmp(PROFANITY, buf_id, strlen(PROFANITY))) {
-                       g_profanity = int_param;
-               } else {
-                       fclose(config_fp);
-                       SLOG(LOG_WARN, TAG_STTD, "[Config WARNING] Fail to load config (profanity filter)");
-                       __sttd_config_save();
-                       return 0;
+       if (STT_CONFIG_TYPE_OPTION_SILENCE_DETECTION == type) {
+               if (NULL != g_silence_cb){
+                       g_silence_cb(bool_value, g_user_data);
+                       SLOG(LOG_DEBUG, TAG_STTD, "Call back silence detection changed");
                }
        }
-       
-
-       /* Read punctuation override */
-       if (EOF == fscanf(config_fp, "%s %d", buf_id, &int_param)) {
-               fclose(config_fp);
-               SLOG(LOG_WARN, TAG_STTD, "[Config WARNING] Fail to load config (punctuation override)");
-               __sttd_config_save();
-               return 0;
-       } else {
-               if (0 == strncmp(PUNCTUATION, buf_id, strlen(PUNCTUATION))) {
-                       g_punctuation = int_param;
-               } else {
-                       fclose(config_fp);
-                       SLOG(LOG_WARN, TAG_STTD, "[Config WARNING] Fail to load config (punctuation override)");
-                       __sttd_config_save();
-                       return 0;
-               }
-       }
-       
-       fclose(config_fp);
 
-       SLOG(LOG_DEBUG, TAG_STTD, "[Config] Load config : engine(%s), language(%s), silence(%d), profanity(%d), punctuation(%d)",
-               g_engine_id, g_language, g_silence, g_profanity, g_punctuation);
+       return;
+}
 
-       if (true == is_default_open) {
-               if(0 == __sttd_config_save()) {
-                       SLOG(LOG_DEBUG, TAG_STTD, "[Config] Create config(%s)", CONFIG_FILE_PATH);
-               }
+int sttd_config_initialize(sttd_config_engine_changed_cb engine_cb, 
+                          sttd_config_language_changed_cb lang_cb, 
+                          sttd_config_silence_changed_cb silence_cb, 
+                          void* user_data)
+{
+       if (NULL == engine_cb || NULL == lang_cb || NULL == silence_cb) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Config] Invalid parameter");
+               return -1;
        }
 
-       return 0;
-}
+       int ret = -1;
+       ret = stt_config_mgr_initialize(getpid());
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Config] Fail to initialize config manager");
+               return -1;
+       }
 
-int sttd_config_initialize()
-{
-       g_engine_id = NULL;
-       g_language = NULL;
-       g_silence = 1;
-       g_profanity = 1;
-       g_punctuation = 0;
+       ret = stt_config_mgr_set_callback(getpid(), __sttd_config_engine_changed_cb, __sttd_config_lang_changed_cb, 
+               __config_bool_changed_cb, NULL);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTD, "[ERROR] Fail to set config changed : %d", ret);
+               return -1;
+       }
 
-       __sttd_config_load();
+       g_engine_cb = engine_cb;
+       g_lang_cb = lang_cb;
+       g_silence_cb = silence_cb;
+       g_user_data = user_data;
 
        return 0;
 }
 
 int sttd_config_finalize()
 {
-       __sttd_config_save();
+       stt_config_mgr_finalize(getpid());
+
        return 0;
 }
 
@@ -224,7 +117,10 @@ int sttd_config_get_default_engine(char** engine_id)
        if (NULL == engine_id)
                return -1;
 
-       *engine_id = strdup(g_engine_id);
+       if (0 != stt_config_mgr_get_engine(engine_id)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Config ERROR] Fail to get engine id");
+       }
+
        return 0;
 }
 
@@ -233,11 +129,10 @@ int sttd_config_set_default_engine(const char* engine_id)
        if (NULL == engine_id)
                return -1;
 
-       if (NULL != g_engine_id)
-               free(g_engine_id);
+       if (0 != stt_config_mgr_set_engine(engine_id)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Config ERROR] Fail to set engine id");
+       }
 
-       g_engine_id = strdup(engine_id);
-       __sttd_config_save();
        return 0;
 }
 
@@ -246,22 +141,10 @@ int sttd_config_get_default_language(char** language)
        if (NULL == language)
                return -1;
 
-       *language = strdup(g_language);
-
-       return 0;
-}
-
-int sttd_config_set_default_language(const char* language)
-{
-       if (NULL == language)
+       if (0 != stt_config_mgr_get_default_language(language)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Config ERROR] Fail to get language");
                return -1;
-
-       if (NULL != g_language)
-               free(g_language);
-
-       g_language = strdup(language);
-
-       __sttd_config_save();
+       }
 
        return 0;
 }
@@ -271,48 +154,28 @@ int sttd_config_get_default_silence_detection(int* silence)
        if (NULL == silence)
                return -1;
 
-       *silence = g_silence;
-
-       return 0;
-}
-
-int sttd_config_set_default_silence_detection(int silence)
-{
-       g_silence = silence;
-       __sttd_config_save();
-       return 0;
-}
-
-int sttd_config_get_default_profanity_filter(int* profanity)
-{
-       if (NULL == profanity)
+       bool value;
+       if (0 != stt_config_mgr_get_silence_detection(&value)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Config ERROR] Fail to set language");
                return -1;
+       }
 
-       *profanity = g_profanity;
+       *silence = (int)value;
 
        return 0;
 }
 
-int sttd_config_set_default_profanity_filter(int profanity)
+int sttd_config_time_add(int index, int event, const char* text, long start_time, long end_time)
 {
-       g_profanity = profanity;
-       __sttd_config_save();
-       return 0;
+       return stt_config_mgr_add_time_info(index, event, text, start_time, end_time);
 }
 
-int sttd_config_get_default_punctuation_override(int* punctuation)
+int sttd_config_time_save()
 {
-       if (NULL == punctuation)
-               return -1;
-
-       *punctuation = g_punctuation;
-
-       return 0;
+       return stt_config_mgr_save_time_info_file();
 }
 
-int sttd_config_set_default_punctuation_override(int punctuation)
+int sttd_config_time_reset()
 {
-       g_punctuation = punctuation;
-       __sttd_config_save();
-       return 0;
+       return stt_config_mgr_reset_time_info();
 }
\ No newline at end of file
index f2cfe91..c14a6f0 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
 extern "C" {
 #endif
 
-int sttd_config_initialize();
+typedef void (*sttd_config_engine_changed_cb)(const char* engine_id, const char* language, bool support_silence, void* user_data);
 
-int sttd_config_finalize();
+typedef void (*sttd_config_language_changed_cb)(const char* language, void* user_data);
 
-int sttd_config_get_default_engine(char** engine_id);
+typedef void (*sttd_config_silence_changed_cb)(bool value, void* user_data);
 
-int sttd_config_set_default_engine(const char* engine_id);
 
-int sttd_config_get_default_language(char** language);
+int sttd_config_initialize(sttd_config_engine_changed_cb engine_cb, 
+                       sttd_config_language_changed_cb lang_cb, 
+                       sttd_config_silence_changed_cb silence_cb, 
+                       void* user_data);
 
-int sttd_config_set_default_language(const char* langauge);
+int sttd_config_finalize();
 
-int sttd_config_get_default_silence_detection(int* silence);
+int sttd_config_set_default_engine(const char* engine_id);
 
-int sttd_config_set_default_silence_detection(int silence);
+int sttd_config_get_default_engine(char** engine_id);
 
-int sttd_config_get_default_profanity_filter(int* profanity);
+int sttd_config_get_default_language(char** language);
+
+int sttd_config_get_default_silence_detection(int* silence);
 
-int sttd_config_set_default_profanity_filter(int profanity);
 
-int sttd_config_get_default_punctuation_override(int* punctuation);
+int sttd_config_time_add(int index, int event, const char* text, long start_time, long end_time);
 
-int sttd_config_set_default_punctuation_override(int punctuation);
+int sttd_config_time_save();
 
+int sttd_config_time_reset();
 
 #ifdef __cplusplus
 }
index 28ed7ac..e23a0d8 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,7 +42,7 @@ int sttdc_send_hello(int uid)
 
        DBusMessage* msg;
 
-       SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] Send hello message : uid(%d)", uid);
+       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] Send hello message : uid(%d)", uid);
 
        msg = dbus_message_new_method_call(
                service_name, 
@@ -65,6 +65,10 @@ int sttdc_send_hello(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, TAG_STTD, "[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);
@@ -102,7 +106,7 @@ int sttdc_send_get_state(int uid, int* state)
 
        DBusMessage* msg;
 
-       SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] Send get state message : uid(%d)", uid);
+       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] Send get state message : uid(%d)", uid);
 
        msg = dbus_message_new_method_call(
                service_name, 
@@ -126,6 +130,10 @@ int sttdc_send_get_state(int uid, int* state)
 
        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, TAG_STTD, "[ERROR] Send error (%s)", err.message);
+               dbus_error_free(&err);
+       }
 
        if (NULL != result_msg) {
                dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &tmp, DBUS_TYPE_INVALID);
@@ -148,7 +156,7 @@ int sttdc_send_get_state(int uid, int* state)
        return result;
 }
 
-int sttdc_send_result(int uid, const char* type, const char** data, int data_count, const char* result_msg)
+int sttdc_send_result(int uid, int event, const char** data, int data_count, const char* result_msg)
 {
        int pid = sttd_client_get_pid(uid);
 
@@ -165,8 +173,8 @@ int sttdc_send_result(int uid, const char* type, const char** data, int data_cou
        snprintf(target_if_name, sizeof(target_if_name), "%s%d", STT_CLIENT_SERVICE_INTERFACE, pid);
 
        DBusMessage* msg;
-       
-       SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] send result signal : uid(%d), type(%s), result count(%d)", uid, type, data_count);
+
+       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] send result signal : uid(%d), event(%d), result count(%d)", uid, event, data_count);
 
        msg = dbus_message_new_method_call(
                service_name, 
@@ -186,15 +194,7 @@ int sttdc_send_result(int uid, const char* type, const char** data, int data_cou
        dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &uid);
 
        char* msg_temp;
-       if (NULL == type) {
-               msg_temp = strdup("None");
-               dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(msg_temp));
-               SLOG(LOG_WARN, TAG_STTD, "[Dbus] result type is NULL"); 
-               free(msg_temp);
-       } else {
-               dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(type));
-               SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] result type(%s)", type ); 
-       }       
+       dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &event);
 
        /* Append result msg */
        if (NULL == result_msg) {
@@ -214,11 +214,10 @@ int sttdc_send_result(int uid, const char* type, const char** data, int data_cou
        }
 
        int i;
-
-       SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] result size (%d)", data_count); 
-       for (i=0 ; i<data_count ; i++) {
+       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] result size (%d)", data_count); 
+       for (i = 0;i < data_count;i++) {
                if (NULL != data[i]) {
-                       SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] result (%d, %s)", i, data[i] ); 
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] result (%d, %s)", i, data[i] ); 
 
                        if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &data[i])) {
                                SLOG(LOG_ERROR, TAG_STTD, "[Dbus] response message : Fail to append result data");
@@ -234,8 +233,7 @@ int sttdc_send_result(int uid, const char* type, const char** data, int data_cou
                                sttd_client_delete(uid);
                        }
 
-                       SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Result from engine is NULL(%d) %s", i); 
-
+                       SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Result from engine is NULL(%d)", i); 
                        return -1;
                }
        }
@@ -251,67 +249,7 @@ int sttdc_send_result(int uid, const char* type, const char** data, int data_cou
        return 0;
 }
 
-int sttdc_send_partial_result(int uid, const char* data)
-{
-       int pid = sttd_client_get_pid(uid);
-
-       if (0 > pid) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] pid is NOT valid" );
-               return -1;
-       }
-
-       if (NULL == data) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Input data is NULL" );
-               return -1;
-       }
-
-       char service_name[64];
-       memset(service_name, 0, 64);
-       snprintf(service_name, 64, "%s%d", STT_CLIENT_SERVICE_NAME, pid);
-
-       char target_if_name[128];
-       snprintf(target_if_name, sizeof(target_if_name), "%s%d", STT_CLIENT_SERVICE_INTERFACE, pid);
-
-       DBusMessage* msg;
-
-       SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] send result signal : uid(%d), result(%s)", uid, data);
-       msg = dbus_message_new_method_call(
-               service_name, 
-               STT_CLIENT_SERVICE_OBJECT_PATH, 
-               target_if_name, 
-               STTD_METHOD_PARTIAL_RESULT);
-
-       if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Fail to create message"); 
-               return -1;
-       }
-
-       DBusMessageIter args;
-       dbus_message_iter_init_append(msg, &args);
-
-       /* Append uid & type */
-       dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &uid);
-
-       SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] Partial result (%s)", data ); 
-
-       if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, data)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Dbus] response message : Fail to append result data");
-               return -1;
-       }
-       
-       if (!dbus_connection_send(g_conn, msg, NULL)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Fail to send message : Out Of Memory !"); 
-               return -1;
-       }
-
-       dbus_connection_flush(g_conn);
-       dbus_message_unref(msg);
-
-       return 0;
-}
-
-int sttdc_send_error_signal(int uid, int reason, char *err_msg)
+int sttdc_send_error_signal(int uid, int reason, const char *err_msg)
 {
        if (NULL == err_msg) {
                SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Input parameter is NULL"); 
@@ -359,6 +297,10 @@ int sttdc_send_error_signal(int uid, int reason, char *err_msg)
 
        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, TAG_STTD, "[ERROR] Send error (%s)", err.message);
+               dbus_error_free(&err);
+       }
 
        if (NULL != result_msg) {
                dbus_message_unref(result_msg);
@@ -387,7 +329,7 @@ int sttdc_send_set_state(int uid, int state)
 
        DBusMessage* msg;
 
-       SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] Send change state message : uid(%d), state(%d)", uid, state);
+       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] Send change state message : uid(%d), state(%d)", uid, state);
 
        msg = dbus_message_new_method_call(
                service_name, 
@@ -405,30 +347,15 @@ int sttdc_send_set_state(int uid, int state)
                DBUS_TYPE_INT32, &state, 
                DBUS_TYPE_INVALID);
 
-       DBusError err;
-       dbus_error_init(&err);
-
-       DBusMessage* result_msg;
-       int result = -1;
+       if (!dbus_connection_send(g_conn, msg, NULL)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Fail to send message : Out Of Memory !"); 
+               return -1;
+       }
 
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
+       dbus_connection_flush(g_conn);
        dbus_message_unref(msg);
 
-       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_STTD, "[Dbus] Get arguments error (%s)\n", err.message);
-                       dbus_error_free(&err); 
-                       result = -1;
-               }
-
-               dbus_message_unref(result_msg);
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] Result message is NULL. Client is not available");
-       }
-
-       return result;
+       return 0;
 }
 
 static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handler)
@@ -443,8 +370,13 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
        
        msg = dbus_connection_pop_message(conn);
 
+       if (true != dbus_connection_get_is_connected(conn)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Conn 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;
        }
 
@@ -457,15 +389,35 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
        
        else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_METHOD_FINALIZE))
                sttd_dbus_server_finalize(conn, msg);
-       
+
+       else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_METHOD_SET_CURRENT_ENGINE))
+               sttd_dbus_server_set_current_engine(conn, msg);
+
+       else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_METHOD_CHECK_APP_AGREED))
+               sttd_dbus_server_check_app_agreed(conn, msg);
+
        else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_METHOD_GET_SUPPORT_LANGS))
                sttd_dbus_server_get_support_lang(conn, msg);
 
        else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_METHOD_GET_CURRENT_LANG))
                sttd_dbus_server_get_default_lang(conn, msg);
 
-       else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_METHOD_IS_PARTIAL_SUPPORTED))
-               sttd_dbus_server_is_partial_result_supported(conn, msg);
+       else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_METHOD_IS_TYPE_SUPPORTED))
+               sttd_dbus_server_is_recognition_type_supported(conn, msg);
+
+
+       else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_METHOD_SET_START_SOUND))
+               sttd_dbus_server_set_start_sound(conn, msg);
+
+       else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_METHOD_UNSET_START_SOUND))
+               sttd_dbus_server_unset_start_sound(conn, msg);
+
+       else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_METHOD_SET_STOP_SOUND))
+               sttd_dbus_server_set_stop_sound(conn, msg);
+
+       else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_METHOD_UNSET_STOP_SOUND))
+               sttd_dbus_server_unset_stop_sound(conn, msg);
+
 
        else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_METHOD_START)) 
                sttd_dbus_server_start(conn, msg);
@@ -476,63 +428,6 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
        else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_METHOD_CANCEL)) 
                sttd_dbus_server_cancel(conn, msg);
 
-       else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_METHOD_START_FILE_RECONITION)) 
-               sttd_dbus_server_start_file_recognition(conn, msg);
-
-       /* setting event */
-       else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_SETTING_METHOD_HELLO))
-               sttd_dbus_server_hello(conn, msg);
-
-       else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_SETTING_METHOD_INITIALIZE))
-               sttd_dbus_server_setting_initialize(conn, msg);
-
-       else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_SETTING_METHOD_FINALIZE))
-               sttd_dbus_server_setting_finalize(conn, msg);
-
-       else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_SETTING_METHOD_GET_ENGINE_LIST))
-               sttd_dbus_server_setting_get_engine_list(conn, msg);
-
-       else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_SETTING_METHOD_GET_ENGINE))
-               sttd_dbus_server_setting_get_engine(conn, msg);
-
-       else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_SETTING_METHOD_SET_ENGINE))
-               sttd_dbus_server_setting_set_engine(conn, msg);
-
-       else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_SETTING_METHOD_GET_LANG_LIST))
-               sttd_dbus_server_setting_get_language_list(conn, msg);
-
-       else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_SETTING_METHOD_GET_DEFAULT_LANG))
-               sttd_dbus_server_setting_get_default_language(conn, msg);
-
-       else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_SETTING_METHOD_SET_DEFAULT_LANG))
-               sttd_dbus_server_setting_set_default_language(conn, msg);
-
-
-       else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_SETTING_METHOD_GET_PROFANITY))
-               sttd_dbus_server_setting_get_profanity_filter(conn, msg);
-
-       else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_SETTING_METHOD_SET_PROFANITY))
-               sttd_dbus_server_setting_set_profanity_filter(conn, msg);
-
-       else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_SETTING_METHOD_GET_PUNCTUATION))
-               sttd_dbus_server_setting_get_punctuation_override(conn, msg);
-
-       else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_SETTING_METHOD_SET_PUNCTUATION))
-               sttd_dbus_server_setting_set_punctuation_override(conn, msg);
-
-       else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_SETTING_METHOD_GET_SILENCE))
-               sttd_dbus_server_setting_get_silence_detection(conn, msg);
-
-       else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_SETTING_METHOD_SET_SILENCE))
-               sttd_dbus_server_setting_set_silence_detection(conn, msg);
-
-
-       else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_SETTING_METHOD_GET_ENGINE_SETTING))
-               sttd_dbus_server_setting_get_engine_setting(conn, msg);
-
-       else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_SETTING_METHOD_SET_ENGINE_SETTING))
-               sttd_dbus_server_setting_set_engine_setting(conn, msg);
-
 
        /* free the message */
        dbus_message_unref(msg);
@@ -564,7 +459,6 @@ int sttd_dbus_open_connection()
        ret = dbus_bus_request_name(g_conn, STT_SERVER_SERVICE_NAME, DBUS_NAME_FLAG_REPLACE_EXISTING , &err);
 
        if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) {
-               printf("Fail to be primary owner in dbus request.");
                SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Fail to be primary owner");
                return -1;
        }
index 4b92929..6e1d11f 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
@@ -28,11 +28,9 @@ int sttdc_send_hello(int uid);
 
 int sttdc_send_get_state(int uid, int* state);
 
-int sttdc_send_result(int uid, const char* type, const char** data, int data_count, const char* result_msg);
+int sttdc_send_result(int uid, int event, const char** data, int data_count, const char* result_msg);
 
-int sttdc_send_partial_result(int uid, const char* data);
-
-int sttdc_send_error_signal(int uid, int reason, char *err_msg);
+int sttdc_send_error_signal(int uid, int reason, const char *err_msg);
 
 int sttdc_send_set_state(int uid, int state);
 
index 4fe2e25..bcd6c82 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,7 +30,16 @@ int sttd_dbus_server_hello(DBusConnection* conn, DBusMessage* msg)
        DBusMessage* reply;
        reply = dbus_message_new_method_return(msg);
 
+       int status = -1;
+       if (EINA_TRUE == sttd_get_daemon_exist()) {
+               status = STTD_DAEMON_NORMAL;
+       } else {
+               status = STTD_DAEMON_ON_TERMINATING;
+       }
+
        if (NULL != reply) {
+               dbus_message_append_args(reply, DBUS_TYPE_INT32, &status, DBUS_TYPE_INVALID);
+
                if (!dbus_connection_send(conn, reply, NULL)) {
                        SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Out Of Memory!");
                }
@@ -55,8 +64,6 @@ int sttd_dbus_server_initialize(DBusConnection* conn, DBusMessage* msg)
        int pid;
        int uid;
        bool silence_supported = false;
-       bool profanity_supported = false;
-       bool punctuation_supported = false;
 
        int ret = STTD_ERROR_OPERATION_FAILED;
 
@@ -72,8 +79,8 @@ int sttd_dbus_server_initialize(DBusConnection* conn, DBusMessage* msg)
                dbus_error_free(&err); 
                ret = STTD_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt initialize : pid(%d), uid(%d)", pid , uid); 
-               ret =  sttd_server_initialize(pid, uid, &silence_supported, &profanity_supported, &punctuation_supported);
+               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt initialize : pid(%d), uid(%d)", pid , uid); 
+               ret =  sttd_server_initialize(pid, uid, &silence_supported);
        }
 
        DBusMessage* reply;
@@ -83,13 +90,11 @@ int sttd_dbus_server_initialize(DBusConnection* conn, DBusMessage* msg)
                dbus_message_append_args(reply, 
                        DBUS_TYPE_INT32, &ret, 
                        DBUS_TYPE_INT32, &silence_supported,
-                       DBUS_TYPE_INT32, &profanity_supported,
-                       DBUS_TYPE_INT32, &punctuation_supported,
                        DBUS_TYPE_INVALID);
 
                if (0 == ret) {
-                       SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d), silence(%d), profanity(%d), punctuation(%d)", 
-                               ret, silence_supported, profanity_supported, punctuation_supported); 
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d), silence(%d)", 
+                               ret, silence_supported); 
                } else {
                        SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); 
                }
@@ -126,7 +131,7 @@ int sttd_dbus_server_finalize(DBusConnection* conn, DBusMessage* msg)
                dbus_error_free(&err); 
                ret = STTD_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt finalize : uid(%d)", uid); 
+               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt finalize : uid(%d)", uid); 
                ret =  sttd_server_finalize(uid);
        }
 
@@ -159,26 +164,26 @@ int sttd_dbus_server_finalize(DBusConnection* conn, DBusMessage* msg)
        return 0;
 }
 
-int sttd_dbus_server_get_support_lang(DBusConnection* conn, DBusMessage* msg)
+int sttd_dbus_server_get_support_engines(DBusConnection* conn, DBusMessage* msg)
 {
        DBusError err;
        dbus_error_init(&err);
 
        int uid;
        int ret = STTD_ERROR_OPERATION_FAILED;
-       GList* lang_list = NULL;
+       GSList* engine_list = NULL;
 
        dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
 
-       SLOG(LOG_DEBUG, TAG_STTD, ">>>>> STT Get supported langs");
+       SLOG(LOG_DEBUG, TAG_STTD, ">>>>> STT Get supported engines");
 
        if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] stt supported langs : get arguments error (%s)", err.message);
+               SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] stt supported engines : get arguments error (%s)", err.message);
                dbus_error_free(&err); 
                ret = STTD_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt supported langs : uid(%d)", uid); 
-               ret = sttd_server_get_supported_languages(uid, &lang_list);
+               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt supported engines : uid(%d)", uid); 
+               ret = sttd_server_get_supported_engines(uid, &engine_list);
        }
 
        DBusMessage* reply;
@@ -186,42 +191,57 @@ int sttd_dbus_server_get_support_lang(DBusConnection* conn, DBusMessage* 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));
+               dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(ret) );
 
                if (0 == ret) {
-                       /* Append language size */
-                       int size = g_list_length(lang_list);
-
+                       /* Append size */
+                       int size = g_slist_length(engine_list);
                        if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(size))) {
-                               SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to append type"); 
                                ret = STTD_ERROR_OPERATION_FAILED;
                        } else {
-                               GList *iter = NULL;
-                               char* temp_lang;
+                               GSList *iter = NULL;
+                               engine_s* engine;
 
-                               iter = g_list_first(lang_list);
+                               iter = g_slist_nth(engine_list, 0);
 
                                while (NULL != iter) {
-                                       temp_lang = iter->data;
+                                       engine = iter->data;
 
-                                       dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(temp_lang) );
-                                       
-                                       if (NULL != temp_lang)
-                                               free(temp_lang);
-                                       
-                                       lang_list = g_list_remove_link(lang_list, iter);
+                                       if (NULL != engine) {
+                                               if (NULL != engine->engine_id && NULL != engine->engine_name && NULL != engine->ug_name) {
+                                                       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "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)); */
+                                               } else {
+                                                       SLOG(LOG_ERROR, TAG_STTD, "[ERROR] Engine info is NULL");
+                                               }
+
+                                               if (NULL != engine->engine_id)          free(engine->engine_id);
+                                               if (NULL != engine->engine_name)        free(engine->engine_name);
+                                               if (NULL != engine->ug_name)            free(engine->ug_name);
 
-                                       iter = g_list_first(lang_list);
+                                               free(engine);
+                                       } else {
+                                               SLOG(LOG_ERROR, TAG_STTD, "[ERROR] Engine info is NULL");
+                                       }
+
+                                       engine_list = g_slist_remove_link(engine_list, iter);
+
+                                       iter = g_slist_nth(engine_list, 0);
                                } 
                        }
                        SLOG(LOG_DEBUG, TAG_STTD, "[OUT] Result(%d)", ret); 
                } else {
                        SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); 
                }
-               
+
                if (!dbus_connection_send(conn, reply, NULL)) {
                        SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Out Of Memory!");
                }
@@ -238,48 +258,46 @@ int sttd_dbus_server_get_support_lang(DBusConnection* conn, DBusMessage* msg)
        return 0;
 }
 
-int sttd_dbus_server_get_default_lang(DBusConnection* conn, DBusMessage* msg)
+int sttd_dbus_server_set_current_engine(DBusConnection* conn, DBusMessage* msg)
 {
        DBusError err;
        dbus_error_init(&err);
 
        int uid;
-       char* lang;
+       char* engine_id;
+       bool silence_supported = false;
        int ret = STTD_ERROR_OPERATION_FAILED;
 
-       dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
+       dbus_message_get_args(msg, &err,
+               DBUS_TYPE_INT32, &uid,
+               DBUS_TYPE_STRING, &engine_id,
+               DBUS_TYPE_INVALID);
 
-       SLOG(LOG_DEBUG, TAG_STTD, ">>>>> STT Get default langs");
+       SLOG(LOG_DEBUG, TAG_STTD, ">>>>> STT Set current engine");
 
        if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] stt get default lang : get arguments error (%s)", err.message);
+               SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] stt set current engine : get arguments error (%s)", err.message);
                dbus_error_free(&err); 
                ret = STTD_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt get default lang : uid(%d)", uid); 
-               ret = sttd_server_get_current_langauage(uid, &lang);
+               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt set current engine : uid(%d)", uid); 
+               ret = sttd_server_set_current_engine(uid, engine_id, &silence_supported);
        }
 
        DBusMessage* reply;
        reply = dbus_message_new_method_return(msg);
 
        if (NULL != reply) {
-               if (0 == ret) {
-                       /* Append result and language */
-                       dbus_message_append_args( reply, 
-                               DBUS_TYPE_INT32, &ret,
-                               DBUS_TYPE_STRING, &lang,
-                               DBUS_TYPE_INVALID);
-
-                       SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); 
+               dbus_message_append_args(reply, 
+                       DBUS_TYPE_INT32, &ret, 
+                       DBUS_TYPE_INT32, &silence_supported,
+                       DBUS_TYPE_INVALID);
 
-                       if (NULL != lang) {
-                               g_free(lang);
-                       }
+               if (0 == ret) {
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d), silence(%d)", 
+                               ret, silence_supported);
                } else {
-                       dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
-
-                       SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); 
+                       SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d) ", ret); 
                }
 
                if (!dbus_connection_send(conn, reply, NULL)) {
@@ -298,41 +316,43 @@ int sttd_dbus_server_get_default_lang(DBusConnection* conn, DBusMessage* msg)
        return 0;
 }
 
-int sttd_dbus_server_is_partial_result_supported(DBusConnection* conn, DBusMessage* msg)
+int sttd_dbus_server_get_current_engine(DBusConnection* conn, DBusMessage* msg)
 {
        DBusError err;
        dbus_error_init(&err);
 
        int uid;
-       int support = -1;
+       char* engine = NULL;
        int ret = STTD_ERROR_OPERATION_FAILED;
 
        dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
 
-       SLOG(LOG_DEBUG, TAG_STTD, ">>>>> STT is partial result supported");
+       SLOG(LOG_DEBUG, TAG_STTD, ">>>>> STT Get current engine");
 
        if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] stt is partial result supported : get arguments error (%s)", err.message);
+               SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] stt get current engine : get arguments error (%s)", err.message);
                dbus_error_free(&err); 
                ret = STTD_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt is partial result supported : uid(%d)", uid); 
-               ret = sttd_server_is_partial_result_supported(uid, &support);
+               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt get current engine : uid(%d)", uid); 
+               ret = sttd_server_get_current_engine(uid, &engine);
        }
 
        DBusMessage* reply;
        reply = dbus_message_new_method_return(msg);
 
        if (NULL != reply) {
-               /* Append result and language */
-               dbus_message_append_args(reply, 
-                       DBUS_TYPE_INT32, &ret,
-                       DBUS_TYPE_INT32, &support,
-                       DBUS_TYPE_INVALID);
-
                if (0 == ret) {
-                       SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d), Support(%s)", ret, support ? "true" : "false"); 
+                       /* Append result and language */
+                       dbus_message_append_args( reply, 
+                               DBUS_TYPE_INT32, &ret,
+                               DBUS_TYPE_STRING, &engine,
+                               DBUS_TYPE_INVALID);
+
+                       SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); 
                } else {
+                       dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
+
                        SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); 
                }
 
@@ -346,51 +366,49 @@ int sttd_dbus_server_is_partial_result_supported(DBusConnection* conn, DBusMessa
                SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); 
        }
 
+       if (NULL != engine)     free(engine);
+
        SLOG(LOG_DEBUG, TAG_STTD, "<<<<<");
        SLOG(LOG_DEBUG, TAG_STTD, "  ");
 
        return 0;
 }
 
-int sttd_dbus_server_start(DBusConnection* conn, DBusMessage* msg)
+int sttd_dbus_server_check_app_agreed(DBusConnection* conn, DBusMessage* msg)
 {
        DBusError err;
        dbus_error_init(&err);
 
        int uid;
-       char* lang;
-       char* type;
-       int profanity;
-       int punctuation;
-       int silence;
+       char* appid;
        int ret = STTD_ERROR_OPERATION_FAILED;
+       bool available = false;
 
        dbus_message_get_args(msg, &err, 
                DBUS_TYPE_INT32, &uid, 
-               DBUS_TYPE_STRING, &lang,   
-               DBUS_TYPE_STRING, &type,
-               DBUS_TYPE_INT32, &profanity,
-               DBUS_TYPE_INT32, &punctuation,
-               DBUS_TYPE_INT32, &silence,
+               DBUS_TYPE_STRING, &appid, 
                DBUS_TYPE_INVALID);
 
-       SLOG(LOG_DEBUG, TAG_STTD, ">>>>> STT Start");
+       SLOG(LOG_DEBUG, TAG_STTD, ">>>>> STT Is engine available");
 
        if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] stt start : get arguments error (%s)", err.message);
+               SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] stt Is engine available : get arguments error (%s)", err.message);
                dbus_error_free(&err); 
                ret = STTD_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt start : uid(%d), lang(%s), type(%s), profanity(%d), punctuation(%d), silence(%d)"
-                                       , uid, lang, type, profanity, punctuation, silence); 
-               ret = sttd_server_start(uid, lang, type, profanity, punctuation, silence);
+               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt Is engine available : uid(%d)", uid); 
+               ret = sttd_server_check_agg_agreed(uid, appid, &available);
        }
 
        DBusMessage* reply;
        reply = dbus_message_new_method_return(msg);
 
        if (NULL != reply) {
-               dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
+               /* Append result and language */
+               dbus_message_append_args(reply, 
+                       DBUS_TYPE_INT32, &ret,
+                       DBUS_TYPE_INT32, &available,
+                       DBUS_TYPE_INVALID);
 
                if (0 == ret) {
                        SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); 
@@ -414,38 +432,69 @@ int sttd_dbus_server_start(DBusConnection* conn, DBusMessage* msg)
        return 0;
 }
 
-int sttd_dbus_server_stop(DBusConnection* conn, DBusMessage* msg)
+int sttd_dbus_server_get_support_lang(DBusConnection* conn, DBusMessage* msg)
 {
        DBusError err;
        dbus_error_init(&err);
 
        int uid;
        int ret = STTD_ERROR_OPERATION_FAILED;
+       GSList* lang_list = NULL;
+
        dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
 
-       SLOG(LOG_DEBUG, TAG_STTD, ">>>>> STT Stop");
+       SLOG(LOG_DEBUG, TAG_STTD, ">>>>> STT Get supported langs");
 
        if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] stt stop : get arguments error (%s)", err.message);
+               SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] stt supported langs : get arguments error (%s)", err.message);
                dbus_error_free(&err); 
                ret = STTD_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt stop : uid(%d)", uid); 
-               ret = sttd_server_stop(uid);
+               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt supported langs : uid(%d)", uid); 
+               ret = sttd_server_get_supported_languages(uid, &lang_list);
        }
 
        DBusMessage* reply;
        reply = dbus_message_new_method_return(msg);
 
        if (NULL != reply) {
-               dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
+               DBusMessageIter args;
+               dbus_message_iter_init_append(reply, &args);
+
+               /* Append result*/
+               dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(ret));
 
                if (0 == ret) {
-                       SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); 
+                       /* Append language size */
+                       int size = g_slist_length(lang_list);
+
+                       if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(size))) {
+                               SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to append type"); 
+                               ret = STTD_ERROR_OPERATION_FAILED;
+                       } else {
+                               GSList *iter = NULL;
+                               char* temp_lang;
+
+                               iter = g_slist_nth(lang_list, 0);
+
+                               while (NULL != iter) {
+                                       temp_lang = iter->data;
+
+                                       dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(temp_lang) );
+                                       
+                                       if (NULL != temp_lang)
+                                               free(temp_lang);
+                                       
+                                       lang_list = g_slist_remove_link(lang_list, iter);
+
+                                       iter = g_slist_nth(lang_list, 0);
+                               } 
+                       }
+                       SLOG(LOG_DEBUG, TAG_STTD, "[OUT] Result(%d)", ret); 
                } else {
                        SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); 
                }
-
+               
                if (!dbus_connection_send(conn, reply, NULL)) {
                        SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Out Of Memory!");
                }
@@ -462,35 +511,43 @@ int sttd_dbus_server_stop(DBusConnection* conn, DBusMessage* msg)
        return 0;
 }
 
-int sttd_dbus_server_cancel(DBusConnection* conn, DBusMessage* msg)
+int sttd_dbus_server_get_default_lang(DBusConnection* conn, DBusMessage* msg)
 {
        DBusError err;
        dbus_error_init(&err);
 
        int uid;
+       char* lang = NULL;
        int ret = STTD_ERROR_OPERATION_FAILED;
+
        dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
 
-       SLOG(LOG_DEBUG, TAG_STTD, ">>>>> STT Cancel");
+       SLOG(LOG_DEBUG, TAG_STTD, ">>>>> STT Get default langs");
 
        if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] stt cancel : get arguments error (%s)", err.message);
+               SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] stt get default lang : get arguments error (%s)", err.message);
                dbus_error_free(&err); 
                ret = STTD_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt cancel : uid(%d)", uid); 
-               ret = sttd_server_cancel(uid);
+               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt get default lang : uid(%d)", uid); 
+               ret = sttd_server_get_current_langauage(uid, &lang);
        }
 
        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) {
+                       /* Append result and language */
+                       dbus_message_append_args( reply, 
+                               DBUS_TYPE_INT32, &ret,
+                               DBUS_TYPE_STRING, &lang,
+                               DBUS_TYPE_INVALID);
+
                        SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); 
                } else {
+                       dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
+
                        SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); 
                }
 
@@ -504,55 +561,49 @@ int sttd_dbus_server_cancel(DBusConnection* conn, DBusMessage* msg)
                SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); 
        }
 
+       if (NULL != lang)       free(lang);
+
        SLOG(LOG_DEBUG, TAG_STTD, "<<<<<");
        SLOG(LOG_DEBUG, TAG_STTD, "  ");
 
        return 0;
 }
 
-int sttd_dbus_server_start_file_recognition(DBusConnection* conn, DBusMessage* msg)
+int sttd_dbus_server_is_recognition_type_supported(DBusConnection* conn, DBusMessage* msg)
 {
        DBusError err;
        dbus_error_init(&err);
 
        int uid;
-       char* filepath;
-       char* lang;
-       char* type;
-       int profanity;
-       int punctuation;
+       char* type = NULL;
+       int support = -1;
        int ret = STTD_ERROR_OPERATION_FAILED;
 
-       dbus_message_get_args(msg, &err, 
-               DBUS_TYPE_INT32, &uid, 
-               DBUS_TYPE_STRING, &filepath,
-               DBUS_TYPE_STRING, &lang,
-               DBUS_TYPE_STRING, &type,
-               DBUS_TYPE_INT32, &profanity,
-               DBUS_TYPE_INT32, &punctuation,
-               DBUS_TYPE_INVALID);
+       dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &uid, DBUS_TYPE_STRING, &type, DBUS_TYPE_INVALID);
 
-       SLOG(LOG_DEBUG, TAG_STTD, ">>>>> STT Start File Recognition");
+       SLOG(LOG_DEBUG, TAG_STTD, ">>>>> STT is recognition type supported");
 
-       if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] stt start file recognition : get arguments error (%s)", err.message);
-               dbus_error_free(&err); 
+       if (dbus_error_is_set(&err)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] stt is recognition type supported : get arguments error (%s)", err.message);
+               dbus_error_free(&err);
                ret = STTD_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt start file recognition : uid(%d), filepath(%s), lang(%s), type(%s), profanity(%d), punctuation(%d)"
-                       , uid, filepath, lang, type, profanity, punctuation); 
-
-               ret = sttd_server_start_file_recognition(uid, filepath, lang, type,profanity, punctuation);
+               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt is recognition type supported : uid(%d)", uid);
+               ret = sttd_server_is_recognition_type_supported(uid, type, &support);
        }
 
        DBusMessage* reply;
        reply = dbus_message_new_method_return(msg);
 
        if (NULL != reply) {
-               dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
+               /* Append result and language */
+               dbus_message_append_args(reply, 
+                       DBUS_TYPE_INT32, &ret,
+                       DBUS_TYPE_INT32, &support,
+                       DBUS_TYPE_INVALID);
 
                if (0 == ret) {
-                       SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); 
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d), Support(%s)", ret, support ? "true" : "false"); 
                } else {
                        SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); 
                }
@@ -573,41 +624,39 @@ int sttd_dbus_server_start_file_recognition(DBusConnection* conn, DBusMessage* m
        return 0;
 }
 
-/*
-* Dbus Setting-Daemon Server
-*/ 
-
-int sttd_dbus_server_setting_initialize(DBusConnection* conn, DBusMessage* msg)
+int sttd_dbus_server_set_start_sound(DBusConnection* conn, DBusMessage* msg)
 {
        DBusError err;
        dbus_error_init(&err);
 
-       int pid;
+       int uid;
+       char* file = NULL;
        int ret = STTD_ERROR_OPERATION_FAILED;
 
-       dbus_message_get_args(msg, &err,
-               DBUS_TYPE_INT32, &pid,
-               DBUS_TYPE_INVALID);
+       dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &uid, DBUS_TYPE_STRING, &file, DBUS_TYPE_INVALID);
 
-       SLOG(LOG_DEBUG, TAG_STTD, ">>>>> Setting Initialize");
+       SLOG(LOG_DEBUG, TAG_STTD, ">>>>> STT set start sound");
 
-       if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] setting initializie : get arguments error (%s)", err.message);
-               dbus_error_free(&err); 
+       if (dbus_error_is_set(&err)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] stt set start sound : get arguments error (%s)", err.message);
+               dbus_error_free(&err);
                ret = STTD_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_DEBUG, TAG_STTD, "[IN] setting initializie : uid(%d)", pid); 
-               ret =  sttd_server_setting_initialize(pid);
+               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt set start sound : uid(%d) file(%s)", uid, file);
+               ret = sttd_server_set_start_sound(uid, file);
        }
 
        DBusMessage* reply;
        reply = dbus_message_new_method_return(msg);
 
        if (NULL != reply) {
-               dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
+               /* Append result and language */
+               dbus_message_append_args(reply, 
+                       DBUS_TYPE_INT32, &ret,
+                       DBUS_TYPE_INVALID);
 
                if (0 == ret) {
-                       SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); 
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); 
                } else {
                        SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); 
                }
@@ -615,6 +664,7 @@ int sttd_dbus_server_setting_initialize(DBusConnection* conn, DBusMessage* msg)
                if (!dbus_connection_send(conn, reply, NULL)) {
                        SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Out Of Memory!");
                }
+
                dbus_connection_flush(conn);
                dbus_message_unref(reply);
        } else {
@@ -627,37 +677,38 @@ int sttd_dbus_server_setting_initialize(DBusConnection* conn, DBusMessage* msg)
        return 0;
 }
 
-int sttd_dbus_server_setting_finalize(DBusConnection* conn, DBusMessage* msg)
+int sttd_dbus_server_unset_start_sound(DBusConnection* conn, DBusMessage* msg)
 {
        DBusError err;
        dbus_error_init(&err);
 
-       int pid;
+       int uid;
        int ret = STTD_ERROR_OPERATION_FAILED;
 
-       dbus_message_get_args(msg, &err, 
-               DBUS_TYPE_INT32, &pid, 
-               DBUS_TYPE_INVALID);
+       dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
 
-       SLOG(LOG_DEBUG, TAG_STTD, ">>>>> Setting Finalize");
+       SLOG(LOG_DEBUG, TAG_STTD, ">>>>> STT unset start sound");
 
-       if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] setting finalize : get arguments error (%s)", err.message);
-               dbus_error_free(&err); 
+       if (dbus_error_is_set(&err)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] stt unset start sound : get arguments error (%s)", err.message);
+               dbus_error_free(&err);
                ret = STTD_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_DEBUG, TAG_STTD, "[IN] setting finalize : uid(%d)", pid); 
-               ret =  sttd_server_setting_finalize(pid);
+               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt unset start sound : uid(%d)", uid);
+               ret = sttd_server_set_start_sound(uid, NULL);
        }
 
        DBusMessage* reply;
        reply = dbus_message_new_method_return(msg);
 
        if (NULL != reply) {
-               dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
+               /* Append result and language */
+               dbus_message_append_args(reply, 
+                       DBUS_TYPE_INT32, &ret,
+                       DBUS_TYPE_INVALID);
 
                if (0 == ret) {
-                       SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); 
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); 
                } else {
                        SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); 
                }
@@ -678,86 +729,39 @@ int sttd_dbus_server_setting_finalize(DBusConnection* conn, DBusMessage* msg)
        return 0;
 }
 
-int sttd_dbus_server_setting_get_engine_list(DBusConnection* conn, DBusMessage* msg)
+int sttd_dbus_server_set_stop_sound(DBusConnection* conn, DBusMessage* msg)
 {
        DBusError err;
        dbus_error_init(&err);
 
-       int pid;
-       GList* engine_list = NULL;
+       int uid;
+       char* file = NULL;
        int ret = STTD_ERROR_OPERATION_FAILED;
 
-       dbus_message_get_args(msg, &err, 
-               DBUS_TYPE_INT32, &pid, 
-               DBUS_TYPE_INVALID);
+       dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &uid, DBUS_TYPE_STRING, &file, DBUS_TYPE_INVALID);
 
-       SLOG(LOG_DEBUG, TAG_STTD, ">>>>> Setting Get Engine List");
+       SLOG(LOG_DEBUG, TAG_STTD, ">>>>> STT set stop sound");
 
-       if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] setting get engine list : get arguments error (%s)", err.message);
-               dbus_error_free(&err); 
+       if (dbus_error_is_set(&err)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] stt set stop sound : get arguments error (%s)", err.message);
+               dbus_error_free(&err);
                ret = STTD_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_DEBUG, TAG_STTD, "[IN] setting get engine list : uid(%d)", pid); 
-               ret = sttd_server_setting_get_engine_list(pid, &engine_list);
+               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt set stop sound : uid(%d) file(%s)", uid, file);
+               ret = sttd_server_set_stop_sound(uid, file);
        }
 
        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) );
+               /* Append result and language */
+               dbus_message_append_args(reply, 
+                       DBUS_TYPE_INT32, &ret,
+                       DBUS_TYPE_INVALID);
 
                if (0 == ret) {
-                       /* Append size */
-                       int size = g_list_length(engine_list);
-                       if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(size))) {
-                               ret = STTD_ERROR_OPERATION_FAILED;
-                       } else {
-                               GList *iter = NULL;
-                               engine_s* engine;
-
-                               iter = g_list_first(engine_list);
-
-                               while (NULL != iter) {
-                                       engine = iter->data;
-
-                                       if (NULL != engine) {
-
-                                               if (NULL != engine->engine_id && NULL != engine->engine_name && NULL != engine->ug_name) {
-                                                       SLOG(LOG_DEBUG, TAG_STTD, "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) );
-                                               } else {
-                                                       SLOG(LOG_ERROR, TAG_STTD, "[ERROR] Engine info is NULL");
-                                               }
-                                               
-                                               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);
-                                       } else {
-                                               SLOG(LOG_ERROR, TAG_STTD, "[ERROR] Engine info is NULL");
-                                       }
-                                       
-                                       engine_list = g_list_remove_link(engine_list, iter);
-
-                                       iter = g_list_first(engine_list);
-                               } 
-                       }
-                       SLOG(LOG_DEBUG, TAG_STTD, "[OUT] Result(%d)", ret); 
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); 
                } else {
                        SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); 
                }
@@ -778,232 +782,39 @@ int sttd_dbus_server_setting_get_engine_list(DBusConnection* conn, DBusMessage*
        return 0;
 }
 
-int sttd_dbus_server_setting_get_engine(DBusConnection* conn, DBusMessage* msg)
+int sttd_dbus_server_unset_stop_sound(DBusConnection* conn, DBusMessage* msg)
 {
        DBusError err;
        dbus_error_init(&err);
 
-       int pid;
-       char* engine_id;
+       int uid;
        int ret = STTD_ERROR_OPERATION_FAILED;
 
-       dbus_message_get_args(msg, &err,
-               DBUS_TYPE_INT32, &pid,
-               DBUS_TYPE_INVALID);
+       dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
 
-       SLOG(LOG_DEBUG, TAG_STTD, ">>>>> Setting Get Engine");
+       SLOG(LOG_DEBUG, TAG_STTD, ">>>>> STT unset stop sound");
 
-       if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] setting get engine : get arguments error (%s)", err.message);
-               dbus_error_free(&err); 
+       if (dbus_error_is_set(&err)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] stt unset stop sound : get arguments error (%s)", err.message);
+               dbus_error_free(&err);
                ret = STTD_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_DEBUG, TAG_STTD, "[IN] setting get engine : uid(%d)", pid); 
-               ret = sttd_server_setting_get_engine(pid, &engine_id);
+               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt unset stop sound : uid(%d)", uid);
+               ret = sttd_server_set_stop_sound(uid, NULL);
        }
 
        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, TAG_STTD, "[OUT SUCCESS] Result(%d), Engine id(%s)", ret, engine_id); 
-                       g_free(engine_id);              
-               } else {
-                       dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
-                       SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); 
-               }
-
-               if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Out Of Memory!");
-               }
-
-               dbus_connection_flush(conn);
-               dbus_message_unref(reply);
-       } else {
-               SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); 
-       }
-
-       SLOG(LOG_DEBUG, TAG_STTD, "<<<<<");
-       SLOG(LOG_DEBUG, TAG_STTD, "  ");
-
-       return 0;
-}
-
-int sttd_dbus_server_setting_set_engine(DBusConnection* conn, DBusMessage* msg)
-{
-       DBusError err;
-       dbus_error_init(&err);
-
-       int pid;
-       char* engine_id;
-       int ret = STTD_ERROR_OPERATION_FAILED;
-
-       dbus_message_get_args(msg, &err,
-               DBUS_TYPE_INT32, &pid,
-               DBUS_TYPE_STRING, &engine_id,
-               DBUS_TYPE_INVALID);
-
-       SLOG(LOG_DEBUG, TAG_STTD, ">>>>> Setting Set Engine");
-
-       if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] setting set engine : get arguments error (%s)", err.message);
-               dbus_error_free(&err); 
-               ret = STTD_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTD, "[IN] setting set engine : uid(%d)", pid); 
-               ret = sttd_server_setting_set_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, TAG_STTD, "[OUT SUCCESS] Result(%d) ", ret); 
-               } else {
-                       SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d) ", ret); 
-               }
-
-               if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Out Of Memory!");
-               }
-
-               dbus_connection_flush(conn);
-               dbus_message_unref(reply);
-       } else {
-               SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); 
-       }
-
-       SLOG(LOG_DEBUG, TAG_STTD, "<<<<<");
-       SLOG(LOG_DEBUG, TAG_STTD, "  ");
-
-       return 0;
-}
-
-int sttd_dbus_server_setting_get_language_list(DBusConnection* conn, DBusMessage* msg)
-{
-       DBusError err;
-       dbus_error_init(&err);
-
-       int pid;
-       GList* lang_list = NULL;
-       char* engine_id;
-       int ret = STTD_ERROR_OPERATION_FAILED;
-
-       dbus_message_get_args(msg, &err,
-               DBUS_TYPE_INT32, &pid,
-               DBUS_TYPE_INVALID);
-
-       SLOG(LOG_DEBUG, TAG_STTD, ">>>>> Setting Get Language List");
-
-       if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] setting get language list : get arguments error (%s)", err.message);
-               dbus_error_free(&err); 
-               ret = STTD_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTD, "[IN] setting get language list : uid(%d)", pid); 
-               ret = sttd_server_setting_get_lang_list(pid, &engine_id, &lang_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) {
-                       dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(engine_id));
-
-                       int size = g_list_length(lang_list);
-                       SLOG(LOG_ERROR, TAG_STTD, "[OUT DEBUG] Count(%d) ", size); 
-
-                       /* Append size */
-                       if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(size))) {
-                               ret = STTD_ERROR_OPERATION_FAILED;
-                               SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d) ", ret); 
-                       } else {
-                               GList *iter = NULL;
-                               char* temp_lang;
-
-                               iter = g_list_first(lang_list);
-
-                               while (NULL != iter) {
-                                       temp_lang = iter->data;
-
-                                       dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(temp_lang) );
-                                       
-                                       if (NULL != temp_lang)
-                                               free(temp_lang);
-                                       
-                                       lang_list = g_list_remove_link(lang_list, iter);
-
-                                       iter = g_list_first(lang_list);
-                               } 
-                               SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d) ", ret); 
-                       }
-               } else {
-                       SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d) ", ret); 
-               }
-
-               if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Out Of Memory!");
-               }
-
-               dbus_connection_flush(conn);
-               dbus_message_unref(reply);
-       } else {
-               SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); 
-       }
-
-       SLOG(LOG_DEBUG, TAG_STTD, "<<<<<");
-       SLOG(LOG_DEBUG, TAG_STTD, "  ");
-
-       return 0;
-}
-
-int sttd_dbus_server_setting_get_default_language(DBusConnection* conn, DBusMessage* msg)
-{
-       DBusError err;
-       dbus_error_init(&err);
-
-       int pid;
-       char* language;
-       int ret = STTD_ERROR_OPERATION_FAILED;
-
-       dbus_message_get_args(msg, &err,
-               DBUS_TYPE_INT32, &pid,
-               DBUS_TYPE_INVALID);
-
-       SLOG(LOG_DEBUG, TAG_STTD, ">>>>> Setting Get Default Language");
-
-       if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] setting get default language : get arguments error (%s)", err.message);
-               dbus_error_free(&err); 
-               ret = STTD_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTD, "[IN] setting get default language : uid(%d)", pid); 
-               ret = sttd_server_setting_get_default_language(pid, &language);
-       }
-
-       DBusMessage* reply;
-       reply = dbus_message_new_method_return(msg);
+               /* Append result and language */
+               dbus_message_append_args(reply, 
+                       DBUS_TYPE_INT32, &ret,
+                       DBUS_TYPE_INVALID);
 
-       if (NULL != reply) {
                if (0 == ret) {
-                       dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_STRING, &language, DBUS_TYPE_INVALID);
-                       SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d), Default Language(%s)", ret, language); 
-                       free(language);         
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); 
                } else {
-                       dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
                        SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); 
                }
 
@@ -1023,29 +834,36 @@ int sttd_dbus_server_setting_get_default_language(DBusConnection* conn, DBusMess
        return 0;
 }
 
-int sttd_dbus_server_setting_set_default_language(DBusConnection* conn, DBusMessage* msg)
+int sttd_dbus_server_start(DBusConnection* conn, DBusMessage* msg)
 {
        DBusError err;
        dbus_error_init(&err);
 
-       int pid;
-       char* language;
+       int uid;
+       char* lang;
+       char* type;
+       char* appid;
+       int silence;
        int ret = STTD_ERROR_OPERATION_FAILED;
 
-       dbus_message_get_args(msg, &err,
-               DBUS_TYPE_INT32, &pid,
-               DBUS_TYPE_STRING, &language,
+       dbus_message_get_args(msg, &err, 
+               DBUS_TYPE_INT32, &uid, 
+               DBUS_TYPE_STRING, &lang,   
+               DBUS_TYPE_STRING, &type,
+               DBUS_TYPE_INT32, &silence,
+               DBUS_TYPE_STRING, &appid,
                DBUS_TYPE_INVALID);
 
-       SLOG(LOG_DEBUG, TAG_STTD, ">>>>> Setting Set Default Language");
+       SLOG(LOG_DEBUG, TAG_STTD, ">>>>> STT Start");
 
        if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] setting set default language : get arguments error (%s)", err.message);
+               SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] stt start : get arguments error (%s)", err.message);
                dbus_error_free(&err); 
                ret = STTD_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_DEBUG, TAG_STTD, "[IN] setting set default language : uid(%d), language(%s)", pid, language); 
-               ret = sttd_server_setting_set_default_language(pid, language);
+               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt start : uid(%d), lang(%s), type(%s), silence(%d) appid(%s)"
+                       , uid, lang, type, silence, appid); 
+               ret = sttd_server_start(uid, lang, type, silence, appid);
        }
 
        DBusMessage* reply;
@@ -1054,218 +872,7 @@ int sttd_dbus_server_setting_set_default_language(DBusConnection* conn, DBusMess
        if (NULL != reply) {
                dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
 
-               if (0 == ret) {
-                       SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); 
-               } else {
-                       SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); 
-               }
-
-               if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Out Of Memory!");
-               }
-
-               dbus_connection_flush(conn);
-               dbus_message_unref(reply);
-       } else {
-               SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); 
-       }
-
-       SLOG(LOG_DEBUG, TAG_STTD, "<<<<<");
-       SLOG(LOG_DEBUG, TAG_STTD, "  ");
-
-       return 0;
-}
-
-int sttd_dbus_server_setting_get_profanity_filter(DBusConnection* conn, DBusMessage* msg)
-{
-       DBusError err;
-       dbus_error_init(&err);
-
-       int pid;
-       bool value;
-       int ret = STTD_ERROR_OPERATION_FAILED;
-
-       dbus_message_get_args(msg, &err,
-               DBUS_TYPE_INT32, &pid,
-               DBUS_TYPE_INVALID);
-
-       SLOG(LOG_DEBUG, TAG_STTD, ">>>>> Setting Get Profanity Filter");
-
-       if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] setting get profanity filter : get arguments error (%s)", err.message);
-               dbus_error_free(&err); 
-               ret = STTD_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTD, "[IN] setting get profanity filter : uid(%d)", pid); 
-               ret = sttd_server_setting_get_profanity_filter(pid, &value);
-       }
-
-       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, &value, DBUS_TYPE_INVALID);
-                       SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d) , value(%s)", ret, value ? "true":"false"); 
-               } else {
-                       dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
-                       SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); 
-               }
-
-               if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Out Of Memory!");
-               }
-
-               dbus_connection_flush(conn);
-               dbus_message_unref(reply);
-       } else {
-               SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); 
-       }
-
-       SLOG(LOG_DEBUG, TAG_STTD, "<<<<<");
-       SLOG(LOG_DEBUG, TAG_STTD, "  ");
-
-       return 0;
-}
-
-int sttd_dbus_server_setting_set_profanity_filter(DBusConnection* conn, DBusMessage* msg)
-{
-       DBusError err;
-       dbus_error_init(&err);
-
-       int pid;
-       bool value;
-       int ret = STTD_ERROR_OPERATION_FAILED;
-
-       dbus_message_get_args(msg, &err,
-               DBUS_TYPE_INT32, &pid,
-               DBUS_TYPE_INT32, &value,
-               DBUS_TYPE_INVALID);
-
-       SLOG(LOG_DEBUG, TAG_STTD, ">>>>> Setting Set Profanity Filter");
-
-       if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] setting set profanity filter : get arguments error (%s)", err.message);
-               dbus_error_free(&err); 
-               ret = STTD_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTD, "[IN] setting set profanity filter : uid(%d), value(%s)", pid, value ? "true":"false"); 
-               ret =  sttd_server_setting_set_profanity_filter(pid, (bool)value);
-       }
-
-       DBusMessage* reply;
-       reply = dbus_message_new_method_return(msg);
-
-       dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
-
-       if (NULL != reply) {
-               if (0 == ret) {
-                       SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); 
-               } else {
-                       SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); 
-               }
-
-               if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Out Of Memory!");
-               }
-
-               dbus_connection_flush(conn);
-               dbus_message_unref(reply);
-       } else {
-               SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); 
-       }
-
-       SLOG(LOG_DEBUG, TAG_STTD, "<<<<<");
-       SLOG(LOG_DEBUG, TAG_STTD, "  ");
-
-       return 0;
-}
-
-int sttd_dbus_server_setting_get_punctuation_override(DBusConnection* conn, DBusMessage* msg)
-{
-       DBusError err;
-       dbus_error_init(&err);
-
-       int pid;
-       bool value;
-       int ret = STTD_ERROR_OPERATION_FAILED;
-
-       dbus_message_get_args(msg, &err,
-               DBUS_TYPE_INT32, &pid,
-               DBUS_TYPE_INVALID);
-
-       SLOG(LOG_DEBUG, TAG_STTD, ">>>>> Setting Get Punctuation Override");
-       
-       if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] setting get punctuation override : get arguments error (%s)", err.message);
-               dbus_error_free(&err); 
-               ret = STTD_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTD, "[IN] setting get punctuation override : uid(%d)", pid); 
-               ret =  sttd_server_setting_get_punctuation_override(pid, &value);
-       }
-
-       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, &value, DBUS_TYPE_INVALID);
-                       SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d) , value(%s)", ret, value ? "true":"false"); 
-               } else {
-                       dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
-                       SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); 
-               }
-
-               if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Out Of Memory!");
-                       return -1;
-               }
-
-               dbus_connection_flush(conn);
-               dbus_message_unref(reply);
-       } else {
-               SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); 
-       }
-
-       SLOG(LOG_DEBUG, TAG_STTD, "<<<<<");
-       SLOG(LOG_DEBUG, TAG_STTD, "  ");
-
-       return 0;
-}
-
-int sttd_dbus_server_setting_set_punctuation_override(DBusConnection* conn, DBusMessage* msg)
-{
-       DBusError err;
-       dbus_error_init(&err);
-
-       int pid;
-       bool value;
-       int ret = STTD_ERROR_OPERATION_FAILED;
-
-       dbus_message_get_args(msg, &err,
-               DBUS_TYPE_INT32, &pid,
-               DBUS_TYPE_INT32, &value,
-               DBUS_TYPE_INVALID);
-
-       SLOG(LOG_DEBUG, TAG_STTD, ">>>>> Setting Set Profanity Filter");
-       
-       if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] setting set punctuation override : get arguments error (%s)", err.message);
-               dbus_error_free(&err); 
-               ret = STTD_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTD, "[IN] setting set punctuation override : uid(%d), value(%s)", pid, value ? "true":"false"); 
-               ret =  sttd_server_setting_set_punctuation_override(pid, value);
-       }
-
-       DBusMessage* reply;
-       reply = dbus_message_new_method_return(msg);
-
-       dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
-
-       if (NULL != reply) {
-               if (0 == ret) {
+               if (0 <= ret) {
                        SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); 
                } else {
                        SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); 
@@ -1273,7 +880,6 @@ int sttd_dbus_server_setting_set_punctuation_override(DBusConnection* conn, DBus
 
                if (!dbus_connection_send(conn, reply, NULL)) {
                        SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Out Of Memory!");
-                       return -1;
                }
 
                dbus_connection_flush(conn);
@@ -1288,90 +894,33 @@ int sttd_dbus_server_setting_set_punctuation_override(DBusConnection* conn, DBus
        return 0;
 }
 
-int sttd_dbus_server_setting_get_silence_detection(DBusConnection* conn, DBusMessage* msg)
+int sttd_dbus_server_stop(DBusConnection* conn, DBusMessage* msg)
 {
        DBusError err;
        dbus_error_init(&err);
 
-       int pid;
-       bool value;
+       int uid;
        int ret = STTD_ERROR_OPERATION_FAILED;
+       dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
 
-       dbus_message_get_args(msg, &err,
-               DBUS_TYPE_INT32, &pid,
-               DBUS_TYPE_INVALID);
-
-       SLOG(LOG_DEBUG, TAG_STTD, ">>>>> Setting Get Silence Detection");
+       SLOG(LOG_DEBUG, TAG_STTD, ">>>>> STT Stop");
 
        if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] setting get silence detection : get arguments error (%s)", err.message);
+               SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] stt stop : get arguments error (%s)", err.message);
                dbus_error_free(&err); 
                ret = STTD_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_DEBUG, TAG_STTD, "[IN] setting get silence detection : uid(%d)", pid); 
-               ret =  sttd_server_setting_get_silence_detection(pid, &value);
+               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt stop : uid(%d)", uid); 
+               ret = sttd_server_stop(uid);
        }
 
        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, &value, DBUS_TYPE_INVALID);
-                       SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d) , Value(%s)", ret, value ? "true":"false"); 
-               } else {
-                       dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
-                       SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); 
-               }
-
-               if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Out Of Memory!");
-                       return -1;
-               }
-
-               dbus_connection_flush(conn);
-               dbus_message_unref(reply);
-       } else {
-               SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); 
-       }
-
-       SLOG(LOG_DEBUG, TAG_STTD, "<<<<<");
-       SLOG(LOG_DEBUG, TAG_STTD, "  ");
-
-       return 0;
-}
-
-int sttd_dbus_server_setting_set_silence_detection(DBusConnection* conn, DBusMessage* msg)
-{
-       DBusError err;
-       dbus_error_init(&err);
-
-       int pid;
-       bool value;
-       int ret = STTD_ERROR_OPERATION_FAILED;
-
-       dbus_message_get_args(msg, &err,
-               DBUS_TYPE_INT32, &pid,
-               DBUS_TYPE_INT32, &value,
-               DBUS_TYPE_INVALID);
-       SLOG(LOG_DEBUG, TAG_STTD, ">>>>> Setting Set Silence Detection");
-
-       if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] setting set silence detection : get arguments error (%s)", err.message);
-               dbus_error_free(&err); 
-               ret = STTD_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTD, "[IN] setting set silence detection : uid(%d), value(%s)", pid, value ? "true":"false"); 
-               ret =  sttd_server_setting_set_silence_detection(pid, value);
-       }
-
-       DBusMessage* reply;
-       reply = dbus_message_new_method_return(msg);
-
-       dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
+               dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
 
-       if (NULL != reply) {
-               if (0 == ret) {
+               if (0 <= ret) {
                        SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); 
                } else {
                        SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); 
@@ -1393,141 +942,32 @@ int sttd_dbus_server_setting_set_silence_detection(DBusConnection* conn, DBusMes
        return 0;
 }
 
-
-int sttd_dbus_server_setting_get_engine_setting(DBusConnection* conn, DBusMessage* msg)
+int sttd_dbus_server_cancel(DBusConnection* conn, DBusMessage* msg)
 {
        DBusError err;
        dbus_error_init(&err);
 
-       int pid;
-       char* engine_id;
-       GList* engine_setting_list = NULL;
+       int uid;
        int ret = STTD_ERROR_OPERATION_FAILED;
+       dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
 
-       dbus_message_get_args(msg, &err,
-               DBUS_TYPE_INT32, &pid,
-               DBUS_TYPE_INVALID);
-
-       SLOG(LOG_DEBUG, TAG_STTD, ">>>>> Setting Get Engine Setting");
+       SLOG(LOG_DEBUG, TAG_STTD, ">>>>> STT Cancel");
 
        if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] setting get engine setting : get arguments error (%s)", err.message);
+               SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] stt cancel : get arguments error (%s)", err.message);
                dbus_error_free(&err); 
                ret = STTD_ERROR_OPERATION_FAILED;
        } else {
-               SLOG(LOG_DEBUG, TAG_STTD, "[IN] setting get engine setting : uid(%d)", pid); 
-               ret = sttd_server_setting_get_engine_setting(pid, &engine_id, &engine_setting_list);
+               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt cancel : uid(%d)", uid); 
+               ret = sttd_server_cancel(uid);
        }
 
        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))) {
-                               ret = STTD_ERROR_OPERATION_FAILED;
-                               SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to add engine id");
-                       } else {
-                               if (NULL != engine_id)  free(engine_id);
-
-                               /* Append size */
-                               int size = g_list_length(engine_setting_list);
-                               if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(size))) {
-                                       ret = STTD_ERROR_OPERATION_FAILED;
-                                       SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] setting get engine setting : result(%d)", ret);
-                               } else {
-                                       GList *iter = NULL;
-                                       engine_setting_s* setting;
-
-                                       iter = g_list_first(engine_setting_list);
-
-                                       while (NULL != iter) {
-                                               setting = iter->data;
-
-                                               if (NULL != setting) {
-                                                       if (NULL != setting->key && NULL != setting->value) {
-                                                               dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(setting->key) );
-                                                               dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(setting->value) );
-                                                       } else {
-                                                               SLOG(LOG_ERROR, TAG_STTD, "[ERROR] setting key is NULL"); 
-                                                       }
-
-                                                       if (NULL != setting->key) 
-                                                               g_free(setting->key);
-                                                       if (NULL != setting->value) 
-                                                               g_free(setting->value);
-
-                                                       g_free(setting);
-                                               } else {
-                                                       SLOG(LOG_ERROR, TAG_STTD, "[ERROR] setting key is NULL"); 
-                                               }
-                                               
-                                               engine_setting_list = g_list_remove_link(engine_setting_list, iter);
-
-                                               iter = g_list_first(engine_setting_list);
-                                       } 
-                                       SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] setting engine setting list : result(%d) \n", ret); 
-                               }
-                       }
-               } else {
-                       SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); 
-               }
-
-               if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Out Of Memory!");
-               }
-
-               dbus_connection_flush(conn);
-               dbus_message_unref(reply);
-       } else {
-               SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); 
-       }
-
-       SLOG(LOG_DEBUG, TAG_STTD, "<<<<<");
-       SLOG(LOG_DEBUG, TAG_STTD, "  ");
-
-       return 0;
-}
-
-int sttd_dbus_server_setting_set_engine_setting(DBusConnection* conn, DBusMessage* msg)
-{
-       DBusError err;
-       dbus_error_init(&err);
-
-       int pid;
-       char* key;
-       char* value;
-       int ret = STTD_ERROR_OPERATION_FAILED;
-
-       dbus_message_get_args(msg, &err,
-               DBUS_TYPE_INT32, &pid,
-               DBUS_TYPE_STRING, &key,
-               DBUS_TYPE_STRING, &value,
-               DBUS_TYPE_INVALID);
-
-       SLOG(LOG_DEBUG, TAG_STTD, ">>>>> Setting Set Engine Setting");
-
-       if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] setting set engine setting : get arguments error (%s)", err.message);
-               dbus_error_free(&err); 
-               ret = STTD_ERROR_OPERATION_FAILED;
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTD, "[IN] setting set engine setting : uid(%d), key(%s), value(%s)", pid, key, value); 
-               ret = sttd_server_setting_set_engine_setting(pid, key, value);
-       }
-
-       DBusMessage* reply;
-       reply = dbus_message_new_method_return(msg);
-
-       dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
+               dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
 
-       if (NULL != reply) {
                if (0 == ret) {
                        SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); 
                } else {
@@ -1549,40 +989,3 @@ int sttd_dbus_server_setting_set_engine_setting(DBusConnection* conn, DBusMessag
 
        return 0;
 }
-
-int sttd_dbus_server_stop_by_daemon(DBusMessage* msg)
-{
-       DBusError err;
-       dbus_error_init(&err);
-
-       int uid;
-
-       dbus_message_get_args(msg, &err,
-               DBUS_TYPE_INT32, &uid,
-               DBUS_TYPE_INVALID);
-
-       SLOG(LOG_DEBUG, TAG_STTD, ">>>>> Stop by daemon");
-
-       if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] sttd stop by daemon : Get arguments error (%s)", err.message);
-               dbus_error_free(&err); 
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTD, "[IN] sttd stop by daemon : uid(%d)", uid);
-               sttd_server_stop(uid);
-
-               /* check silence detection option from config */
-               int ret = sttdc_send_set_state(uid, (int)APP_STATE_PROCESSING);
-               if (0 == ret) {
-                       SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); 
-               } else {
-                       SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); 
-                       /* Remove client */
-                       sttd_server_finalize(uid);
-               }
-       }
-       
-       SLOG(LOG_DEBUG, TAG_STTD, "<<<<<");
-       SLOG(LOG_DEBUG, TAG_STTD, "  ");
-
-       return 0;
-}
index 4582016..68425ad 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
@@ -34,61 +34,36 @@ int sttd_dbus_server_initialize(DBusConnection* conn, DBusMessage* msg);
 
 int sttd_dbus_server_finalize(DBusConnection* conn, DBusMessage* msg);
 
-int sttd_dbus_server_get_support_lang(DBusConnection* conn, DBusMessage* msg);
-
-int sttd_dbus_server_get_default_lang(DBusConnection* conn, DBusMessage* msg);
-
-int sttd_dbus_server_is_partial_result_supported(DBusConnection* conn, DBusMessage* msg);
-
-int sttd_dbus_server_start(DBusConnection* conn, DBusMessage* msg);
+int sttd_dbus_server_get_support_engines(DBusConnection* conn, DBusMessage* msg);
 
-int sttd_dbus_server_stop(DBusConnection* conn, DBusMessage* msg);
-
-int sttd_dbus_server_cancel(DBusConnection* conn, DBusMessage* msg);
+int sttd_dbus_server_set_current_engine(DBusConnection* conn, DBusMessage* msg);
 
-int sttd_dbus_server_start_file_recognition(DBusConnection* conn, DBusMessage* msg);
-
-/*
-* Dbus Server functions for Setting
-*/ 
+int sttd_dbus_server_get_current_engine(DBusConnection* conn, DBusMessage* msg);
 
-int sttd_dbus_server_setting_initialize(DBusConnection* conn, DBusMessage* msg);
+int sttd_dbus_server_check_app_agreed(DBusConnection* conn, DBusMessage* msg);
 
-int sttd_dbus_server_setting_finalize(DBusConnection* conn, DBusMessage* msg);
-
-int sttd_dbus_server_setting_get_engine_list(DBusConnection* conn, DBusMessage* msg);
-
-int sttd_dbus_server_setting_get_engine(DBusConnection* conn, DBusMessage* msg);
-
-int sttd_dbus_server_setting_set_engine(DBusConnection* conn, DBusMessage* msg);
-
-int sttd_dbus_server_setting_get_language_list(DBusConnection* conn, DBusMessage* msg);
+int sttd_dbus_server_get_support_lang(DBusConnection* conn, DBusMessage* msg);
 
-int sttd_dbus_server_setting_get_default_language(DBusConnection* conn, DBusMessage* msg);
+int sttd_dbus_server_get_default_lang(DBusConnection* conn, DBusMessage* msg);
 
-int sttd_dbus_server_setting_set_default_language(DBusConnection* conn, DBusMessage* msg);
+int sttd_dbus_server_is_recognition_type_supported(DBusConnection* conn, DBusMessage* msg);
 
-int sttd_dbus_server_setting_get_profanity_filter(DBusConnection* conn, DBusMessage* msg);
 
-int sttd_dbus_server_setting_set_profanity_filter(DBusConnection* conn, DBusMessage* msg);
+int sttd_dbus_server_set_start_sound(DBusConnection* conn, DBusMessage* msg);
 
-int sttd_dbus_server_setting_get_punctuation_override(DBusConnection* conn, DBusMessage* msg);
+int sttd_dbus_server_unset_start_sound(DBusConnection* conn, DBusMessage* msg);
 
-int sttd_dbus_server_setting_set_punctuation_override(DBusConnection* conn, DBusMessage* msg);
+int sttd_dbus_server_set_stop_sound(DBusConnection* conn, DBusMessage* msg);
 
-int sttd_dbus_server_setting_get_silence_detection(DBusConnection* conn, DBusMessage* msg);
+int sttd_dbus_server_unset_stop_sound(DBusConnection* conn, DBusMessage* msg);
 
-int sttd_dbus_server_setting_set_silence_detection(DBusConnection* conn, DBusMessage* msg);
 
-int sttd_dbus_server_setting_get_engine_setting(DBusConnection* conn, DBusMessage* msg);
+int sttd_dbus_server_start(DBusConnection* conn, DBusMessage* msg);
 
-int sttd_dbus_server_setting_set_engine_setting(DBusConnection* conn, DBusMessage* msg);
+int sttd_dbus_server_stop(DBusConnection* conn, DBusMessage* msg);
 
-/*
-* Dbus Server functions for stt daemon internal
-*/ 
+int sttd_dbus_server_cancel(DBusConnection* conn, DBusMessage* msg);
 
-int sttd_dbus_server_stop_by_daemon(DBusMessage* msg);
 
 
 #ifdef __cplusplus
index cba5e96..ad96c5e 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 <dlfcn.h>
 #include <dirent.h>
 
+#include "stt_defs.h"
+#include "stt_engine.h"
 #include "sttd_main.h"
 #include "sttd_client_data.h"
 #include "sttd_config.h"
+#include "sttd_recorder.h"
 #include "sttd_engine_agent.h"
 
 
+#define AUDIO_CREATE_ON_START
+
 /*
 * Internal data structure
 */
 
 typedef struct {
-       /* engine info */
-       char*   engine_uuid;
-       char*   engine_name; 
-       char*   engine_path;
-
-       /* engine load info */
-       bool    is_set;
-       bool    is_loaded;      
-       bool    need_network;
-       bool    support_silence_detection;
-       bool    support_profanity_filter;
-       bool    support_punctuation_override;
-       void    *handle;
-
-       /* engine base setting */
-       char*   default_lang;
-       bool    profanity_filter;
-       bool    punctuation_override;
-       bool    silence_detection;
-
-       sttpe_funcs_s*  pefuncs;
-       sttpd_funcs_s*  pdfuncs;
-
-       int (*sttp_load_engine)(sttpd_funcs_s* pdfuncs, sttpe_funcs_s* pefuncs);
-       int (*sttp_unload_engine)();
-} sttengine_s;
+       int     uid;
+       int     engine_id;
+       bool    use_default_engine;
+} sttengine_client_s;
 
 typedef struct _sttengine_info {
+       int     engine_id;
+
        char*   engine_uuid;
        char*   engine_path;
        char*   engine_name;
-       char*   setting_ug_path;
+       char*   engine_setting_path;
        bool    use_network;
+
+       bool    is_loaded;
+       
+       /* engine base setting */
+       char*   first_lang;
+       bool    silence_detection;
        bool    support_silence_detection;
 } sttengine_info_s;
 
-
-/*
-* static data
-*/
-
 /** stt engine agent init */
-static bool g_agent_init;
+static bool    g_agent_init;
+
+/** list */
+static GSList* g_engine_client_list;
+static GSList* g_engine_list;
 
-/** stt engine list */
-static GList *g_engine_list;           
+/** default engine info */
+static int     g_default_engine_id;
+static char*   g_default_language;
+static bool    g_default_silence_detected;
 
-/** current engine infomation */
-static sttengine_s g_cur_engine;
+static int     g_engine_id_count;
 
-/** default option value */
-static bool g_default_profanity_filter;
-static bool g_default_punctuation_override;
-static bool g_default_silence_detected;
+/** current engine id */
+static int     g_recording_engine_id;
 
 /** callback functions */
 static result_callback g_result_cb;
-static partial_result_callback g_partial_result_cb;
+static result_time_callback g_result_time_cb;
 static silence_dectection_callback g_silence_cb;
 
 
 /** callback functions */
-void __result_cb(sttp_result_event_e event, const char* type, 
-                       const char** data, int data_count, const char* msg, void *user_data);
+void __result_cb(sttp_result_event_e event, const char* type, const char** data, int data_count, 
+                const char* msg, void* time_info, void *user_data);
 
-void __partial_result_cb(sttp_result_event_e event, const char* data, void *user_data);
+bool __result_time_cb(int index, sttp_result_time_event_e event, const char* text, 
+                     long start_time, long end_time, void* user_data);
 
-void __detect_silence_cb(void* user_data);
+void __detect_silence_cb(sttp_silence_type_e type, void* user_data);
 
 bool __supported_language_cb(const char* language, void* user_data);
 
 void __engine_info_cb(const char* engine_uuid, const char* engine_name, const char* setting_ug_name, 
                      bool use_network, void* user_data);
 
-bool __engine_setting_cb(const char* key, const char* value, void* user_data);
-
-/** Free voice list */
-void __free_language_list(GList* lang_list);
-
-
 /*
 * Internal Interfaces 
 */
  
-/** Set current engine */
-int __internal_set_current_engine(const char* engine_uuid);
-
-/** check engine id */
-int __internal_check_engine_id(const char* engine_uuid);
-
-/** update engine list */
-int __internal_update_engine_list();
-
 /** get engine info */
 int __internal_get_engine_info(const char* filepath, sttengine_info_s** info);
 
@@ -127,33 +102,30 @@ int __log_enginelist();
 /*
 * STT Engine Agent Interfaces
 */
-int sttd_engine_agent_init(result_callback result_cb, partial_result_callback partial_result_cb, silence_dectection_callback silence_cb)
+int sttd_engine_agent_init(result_callback result_cb, result_time_callback time_cb, 
+                          silence_dectection_callback silence_cb)
 {
        /* initialize static data */
-       if (NULL == result_cb || NULL == silence_cb) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine agent ERROR] sttd_engine_agent_init : invalid parameter"); 
+       if (NULL == result_cb || NULL == time_cb || NULL == silence_cb) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine agent ERROR] Invalid parameter"); 
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
        g_result_cb = result_cb;
-       g_partial_result_cb = partial_result_cb;
+       g_result_time_cb = time_cb;
        g_silence_cb = silence_cb;
 
-       g_cur_engine.engine_uuid = NULL;
-       g_cur_engine.engine_name = NULL;
-       g_cur_engine.engine_path = NULL;
-
-       g_cur_engine.is_set = false;
-       g_cur_engine.handle = NULL;
-       g_cur_engine.pefuncs = (sttpe_funcs_s*)malloc( sizeof(sttpe_funcs_s) );
-       g_cur_engine.pdfuncs = (sttpd_funcs_s*)malloc( sizeof(sttpd_funcs_s) );
-
-       g_agent_init = true;
+       g_default_engine_id = -1;
+       g_default_language = NULL;
+       g_engine_id_count = 1;
+       g_recording_engine_id = -1;
 
-       if (0 != sttd_config_get_default_language(&(g_cur_engine.default_lang))) {
-               SLOG(LOG_WARN, TAG_STTD, "[Server WARNING] There is No default voice in config"); 
+       if (0 != sttd_config_get_default_language(&(g_default_language))) {
+               SLOG(LOG_WARN, TAG_STTD, "[Engine Agent WARNING] There is No default voice in config"); 
                /* Set default voice */
-               g_cur_engine.default_lang = strdup("en_US");
+               g_default_language = strdup("en_US");
+       } else {
+               SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Default language is %s", g_default_language);
        }
 
        int temp;
@@ -164,186 +136,88 @@ int sttd_engine_agent_init(result_callback result_cb, partial_result_callback pa
                g_default_silence_detected = (bool)temp;
        }
 
-       if (0 != sttd_config_get_default_profanity_filter(&temp)) {
-               SLOG(LOG_WARN, TAG_STTD, "[Server WARNING] There is no profanity filter in config"); 
-               g_default_profanity_filter = false;
-       } else {
-               g_default_profanity_filter = (bool)temp;
-       }
-
-       if (0 != sttd_config_get_default_punctuation_override(&temp)) {
-               SLOG(LOG_WARN, TAG_STTD, "[Server WARNING] There is no punctuation override in config"); 
-               g_default_punctuation_override = false;
-       } else {
-               g_default_punctuation_override = (bool)temp;
-       }
-
-       SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent SUCCESS] Engine Agent Initialize"); 
+       g_agent_init = false;
 
        return 0;
 }
 
-int sttd_engine_agent_release()
+int __engine_agent_clear_engine(sttengine_info_s *engine)
 {
-       if (false == g_agent_init) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
-               return STTD_ERROR_OPERATION_FAILED;
-       }
-
-       /* unload current engine */
-       sttd_engine_agent_unload_current_engine();
-
-       /* release engine list */
-       GList *iter = NULL;
-       sttengine_s *data = NULL;
-
-       if (g_list_length(g_engine_list) > 0) {
-               /* Get a first item */
-               iter = g_list_first(g_engine_list);
-
-               while (NULL != iter) {
-                       /* Get handle data from list */
-                       data = iter->data;
+       if (NULL != engine) {
+               if (NULL != engine->engine_uuid)        free(engine->engine_uuid);
+               if (NULL != engine->engine_path)        free(engine->engine_path);
+               if (NULL != engine->engine_name)        free(engine->engine_name);
+               if (NULL != engine->engine_setting_path)free(engine->engine_setting_path);
+               if (NULL != engine->first_lang)         free(engine->first_lang);
 
-                       iter = g_list_remove(iter, data);
-               }
+               free(engine);
        }
 
-       g_list_free(iter);
-       
-       /* release current engine data */
-       if( NULL != g_cur_engine.pefuncs )
-               free(g_cur_engine.pefuncs);
-
-       if( NULL != g_cur_engine.pdfuncs )
-               free(g_cur_engine.pdfuncs);
-
-       g_result_cb = NULL;
-       g_silence_cb = NULL;
-
-       g_agent_init = false;
-
-       SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent SUCCESS] Engine Agent release"); 
-
        return 0;
 }
 
-int sttd_engine_agent_initialize_current_engine()
+int sttd_engine_agent_release()
 {
-       /* check agent init */
-       if (false == g_agent_init ) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
-               return STTD_ERROR_OPERATION_FAILED;
-       }
+       /* Release client list */
+       GSList *iter = NULL;
+       sttengine_client_s *client = NULL;
 
-       /* update engine list */
-       if (0 != __internal_update_engine_list()) {
-               SLOG(LOG_ERROR, TAG_STTD, "[engine agent] sttd_engine_agent_init : __internal_update_engine_list : no engine error"); 
-               return STTD_ERROR_ENGINE_NOT_FOUND;
-       }
-
-       /* get current engine from config */
-       char* cur_engine_uuid = NULL;
-       bool is_get_engineid_from_config = false;
+       if (g_slist_length(g_engine_client_list) > 0) {
+               /* Get a first item */
+               iter = g_slist_nth(g_engine_client_list, 0);
 
-       if (0 != sttd_config_get_default_engine(&cur_engine_uuid)) {
+               while (NULL != iter) {
+                       /* Get handle data from list */
+                       client = iter->data;
+                       g_engine_client_list = g_slist_remove_link(g_engine_client_list, iter);
 
-               SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] There is not current engine from config"); 
+                       if (NULL != client) 
+                               free(client);
 
-               /* not set current engine */
-               /* set system default engine */
-               GList *iter = NULL;
-               if (0 < g_list_length(g_engine_list)) {
-                       iter = g_list_first(g_engine_list);
-               } else {
-                       SLOG(LOG_ERROR, TAG_STTD, "[engine agent ERROR] sttd_engine_agent_initialize_current_engine() : no engine error"); 
-                       return -1;      
+                       iter = g_slist_nth(g_engine_client_list, 0);
                }
-
-               sttengine_info_s *data = NULL;
-               data = iter->data;
-
-               cur_engine_uuid = g_strdup(data->engine_uuid);
-
-               is_get_engineid_from_config = false;
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] current engine from config : %s", cur_engine_uuid); 
-
-               is_get_engineid_from_config = true;
        }
 
-       /* check whether cur engine uuid is valid or not. */
-       if (0 != __internal_check_engine_id(cur_engine_uuid)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] It is not valid engine id and find other engine id");
-
-               GList *iter = NULL;
-               if (0 < g_list_length(g_engine_list)) {
-                       iter = g_list_first(g_engine_list);
-               } else {
-                       SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] sttd_engine_agent_initialize_current_engine() : no engine error"); 
-                       return -1;      
-               }
-
-               if (NULL != cur_engine_uuid)    
-                       free(cur_engine_uuid);
-               
-               sttengine_info_s *data = NULL;
-               data = iter->data;
-
-               cur_engine_uuid = g_strdup(data->engine_uuid);
-               
-               is_get_engineid_from_config = false;
-       }
+       g_slist_free(g_engine_client_list);
 
-       SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Current Engine Id : %s", cur_engine_uuid);
+       /* Release engine list */
+       sttengine_info_s *engine = NULL;
 
-       /* set current engine */
-       if (0 != __internal_set_current_engine(cur_engine_uuid)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[engine agent ERROR] __internal_set_current_engine : no engine error"); 
+       if (0 < g_slist_length(g_engine_list)) {
+               /* Get a first item */
+               iter = g_slist_nth(g_engine_list, 0);
 
-               if( cur_engine_uuid != NULL)    
-                       free(cur_engine_uuid);
+               while (NULL != iter) {
+                       /* Get handle data from list */
+                       engine = iter->data;
+                       g_engine_list = g_slist_remove_link(g_engine_list, iter);
+                       
+                       /* Check engine unload */
+                       if (engine->is_loaded) {
+                               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Unload engine id(%d)", engine->engine_id);
 
-               return STTD_ERROR_ENGINE_NOT_FOUND;
-       }
+                               if (0 != stt_engine_deinitialize(engine->engine_id)) 
+                                       SECURE_SLOG(LOG_WARN, TAG_STTD, "[Engine Agent] Fail to deinitialize engine id(%d)", engine->engine_id);
 
-       if (false == is_get_engineid_from_config) {
-               if (0 != sttd_config_set_default_engine(cur_engine_uuid))
-                       SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to set default engine "); 
-       }
+                               if (0 != stt_engine_unload(engine->engine_id))
+                                       SECURE_SLOG(LOG_WARN, TAG_STTD, "[Engine Agent] Fail to unload engine id(%d)", engine->engine_id);
 
-       if( cur_engine_uuid != NULL )   
-               free(cur_engine_uuid);
+                               engine->is_loaded = false;
+                       }
 
-       return 0;
-}
+                       __engine_agent_clear_engine(engine);
 
-int __internal_check_engine_id(const char* engine_uuid)
-{
-       if (NULL == engine_uuid) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter"); 
-               return STTD_ERROR_INVALID_PARAMETER;
+                       iter = g_slist_nth(g_engine_list, 0);
+               }
        }
 
-       GList *iter = NULL;
-       sttengine_s *data = NULL;
-
-       if (0 < g_list_length(g_engine_list)) {
-               /*Get a first item*/
-               iter = g_list_first(g_engine_list);
-
-               while (NULL != iter) {
-                       data = iter->data;
-                       
-                       if (0 == strncmp(engine_uuid, data->engine_uuid, strlen(data->engine_uuid))) {
-                               return 0;
-                       }
+       g_result_cb = NULL;
+       g_silence_cb = NULL;
 
-                       iter = g_list_next(iter);
-               }
-       }
+       g_agent_init = false;
+       g_default_engine_id = -1;
 
-       return -1;
+       return 0;
 }
 
 void __engine_info_cb(const char* engine_uuid, const char* engine_name, const char* setting_ug_name, 
@@ -353,11 +227,10 @@ void __engine_info_cb(const char* engine_uuid, const char* engine_name, const ch
 
        temp->engine_uuid = g_strdup(engine_uuid);
        temp->engine_name = g_strdup(engine_name);
-       temp->setting_ug_path = g_strdup(setting_ug_name);
+       temp->engine_setting_path = g_strdup(setting_ug_name);
        temp->use_network = use_network;
 }
 
-
 int __internal_get_engine_info(const char* filepath, sttengine_info_s** info)
 {
        if (NULL == filepath || NULL == info) {
@@ -372,7 +245,7 @@ int __internal_get_engine_info(const char* filepath, sttengine_info_s** info)
        handle = dlopen (filepath, RTLD_LAZY);
 
        if (!handle) {
-               SLOG(LOG_WARN, TAG_STTD, "[Engine Agent] Invalid engine : %s", filepath); 
+               SECURE_SLOG(LOG_WARN, TAG_STTD, "[Engine Agent] Invalid engine : %s", filepath); 
                return -1;
        }
 
@@ -401,27 +274,32 @@ int __internal_get_engine_info(const char* filepath, sttengine_info_s** info)
        }
 
        sttengine_info_s* temp;
-       temp = (sttengine_info_s*)g_malloc0( sizeof(sttengine_info_s) );
+       temp = (sttengine_info_s*)calloc(1, sizeof(sttengine_info_s));
 
        /* get engine info */
        if (0 != get_engine_info(__engine_info_cb, (void*)temp)) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to get engine info from engine"); 
                dlclose(handle);
-               g_free(temp);
+               free(temp);
                return -1;
        }
 
        /* close engine */
        dlclose(handle);
 
+       temp->engine_id = g_engine_id_count;
+       g_engine_id_count++;
+
        temp->engine_path = g_strdup(filepath);
+       temp->is_loaded = false;
 
        SLOG(LOG_DEBUG, TAG_STTD, "----- Valid Engine");
-       SLOG(LOG_DEBUG, TAG_STTD, "Engine uuid : %s", temp->engine_uuid);
-       SLOG(LOG_DEBUG, TAG_STTD, "Engine name : %s", temp->engine_name);
-       SLOG(LOG_DEBUG, TAG_STTD, "Setting ug path : %s", temp->setting_ug_path);
-       SLOG(LOG_DEBUG, TAG_STTD, "Engine path : %s", temp->engine_path);
-       SLOG(LOG_DEBUG, TAG_STTD, "Use network : %s", temp->use_network ? "true":"false");
+       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "Engine id : %d", temp->engine_id);
+       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "Engine uuid : %s", temp->engine_uuid);
+       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "Engine name : %s", temp->engine_name);
+       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "Engine path : %s", temp->engine_path);
+       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "Engine setting path : %s", temp->engine_setting_path);
+       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "Use network : %s", temp->use_network ? "true":"false");
        SLOG(LOG_DEBUG, TAG_STTD, "-----");
        SLOG(LOG_DEBUG, TAG_STTD, "  ");
 
@@ -430,1367 +308,1157 @@ int __internal_get_engine_info(const char* filepath, sttengine_info_s** info)
        return 0;
 }
 
-int __internal_update_engine_list()
+bool __is_engine(const char* filepath)
 {
-       /* relsease engine list */
-       GList *iter = NULL;
-       sttengine_info_s *data = NULL;
+       GSList *iter = NULL;
+       sttengine_info_s *engine = NULL;
 
-       if (0 < g_list_length(g_engine_list)) {
+       if (0 < g_slist_length(g_engine_list)) {
                /* Get a first item */
-               iter = g_list_first(g_engine_list);
+               iter = g_slist_nth(g_engine_list, 0);
 
                while (NULL != iter) {
                        /* Get handle data from list */
-                       data = iter->data;
+                       engine = iter->data;
 
-                       if (NULL != data) {
-                               if (NULL != data->engine_uuid)          free(data->engine_uuid);
-                               if (NULL != data->engine_path)          free(data->engine_path);
-                               if (NULL != data->engine_name)          free(data->engine_name);
-                               if (NULL != data->setting_ug_path)      free(data->setting_ug_path);
-                               
-                               free(data);
+                       if (0 == strcmp(engine->engine_path, filepath)) {
+                               return true;
                        }
-
-                       g_engine_list = g_list_remove_link(g_engine_list, iter);
-                       iter = g_list_first(g_engine_list);
+               
+                       iter = g_slist_next(iter);
                }
        }
 
+       return false;
+}
+
+int sttd_engine_agent_initialize_engine_list()
+{
        /* Get file name from default engine directory */
-       DIR *dp;
-       struct dirent *dirp;
+       DIR *dp = NULL;
+       int ret = -1;
+       struct dirent entry;
+       struct dirent *dirp = NULL;
 
-       dp  = opendir(ENGINE_DIRECTORY_DEFAULT);
+       dp  = opendir(STT_DEFAULT_ENGINE);
        if (NULL != dp) {
-               while (NULL != (dirp = readdir(dp))) {
-                       sttengine_info_s* info;
-                       char* filepath;
-                       int filesize;
-
-                       filesize = strlen(ENGINE_DIRECTORY_DEFAULT) + strlen(dirp->d_name) + 5;
-                       filepath = (char*) g_malloc0(sizeof(char) * filesize);
-
-                       if (NULL != filepath) {
-                               strncpy(filepath, ENGINE_DIRECTORY_DEFAULT, strlen(ENGINE_DIRECTORY_DEFAULT) );
-                               strncat(filepath, "/", strlen("/") );
-                               strncat(filepath, dirp->d_name, strlen(dirp->d_name) );
-                       } else {
-                               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Memory not enough!!" );
-                               continue;       
+               do {
+                       ret = readdir_r(dp, &entry, &dirp);
+                       if (0 != ret) {
+                               SLOG(LOG_ERROR, TAG_STTD, "[File ERROR] Fail to read directory");
+                               break;
                        }
 
-                       /* get its info and update engine list */
-                       if (0 == __internal_get_engine_info(filepath, &info)) {
-                               /* add engine info to g_engine_list */
-                               g_engine_list = g_list_append(g_engine_list, info);
-                       }
+                       if (NULL != dirp) {
+                               sttengine_info_s* info;
+                               char* filepath;
+                               int filesize;
 
-                       if (NULL != filepath)
-                               g_free(filepath);
-               }
+                               filesize = strlen(STT_DEFAULT_ENGINE) + strlen(dirp->d_name) + 5;
+                               filepath = (char*)calloc(filesize, sizeof(char));
+
+                               if (NULL != filepath) {
+                                       snprintf(filepath, filesize, "%s/%s", STT_DEFAULT_ENGINE, dirp->d_name);
+                               } else {
+                                       SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Memory not enough!!");
+                                       continue;
+                               }
+
+                               if (false  == __is_engine(filepath)) {
+                                       /* get its info and update engine list */
+                                       if (0 == __internal_get_engine_info(filepath, &info)) {
+                                               /* add engine info to g_engine_list */
+                                               g_engine_list = g_slist_append(g_engine_list, info);
+                                       }
+                               }
+
+                               if (NULL != filepath)
+                                       free(filepath);
+                       }
+               } while (NULL != dirp);
 
                closedir(dp);
        } else {
                SLOG(LOG_WARN, TAG_STTD, "[Engine Agent WARNING] Fail to open default directory"); 
        }
-       
+
        /* Get file name from downloadable engine directory */
-       dp  = opendir(ENGINE_DIRECTORY_DOWNLOAD);
+       dp  = opendir(STT_DOWNLOAD_ENGINE);
        if (NULL != dp) {
-               while (NULL != (dirp = readdir(dp))) {
-                       sttengine_info_s* info;
-                       char* filepath;
-                       int filesize;
-
-                       filesize = strlen(ENGINE_DIRECTORY_DOWNLOAD) + strlen(dirp->d_name) + 5;
-                       filepath = (char*) g_malloc0(sizeof(char) * filesize);
-
-                       if (NULL != filepath) {
-                               strncpy(filepath, ENGINE_DIRECTORY_DOWNLOAD, strlen(ENGINE_DIRECTORY_DOWNLOAD) );
-                               strncat(filepath, "/", strlen("/") );
-                               strncat(filepath, dirp->d_name, strlen(dirp->d_name) );
-                       } else {
-                               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Memory not enough!!" );
-                               continue;
+               do {
+                       ret = readdir_r(dp, &entry, &dirp);
+                       if (0 != ret) {
+                               SLOG(LOG_ERROR, TAG_STTD, "[File ERROR] Fail to read directory");
+                               break;
                        }
 
-                       /* get its info and update engine list */
-                       if (0 == __internal_get_engine_info(filepath, &info)) {
-                               /* add engine info to g_engine_list */
-                               g_engine_list = g_list_append(g_engine_list, info);
-                       }
+                       if (NULL != dirp) {
+                               sttengine_info_s* info;
+                               char* filepath;
+                               int filesize;
 
-                       if (NULL != filepath)
-                               g_free(filepath);
-               }
+                               filesize = strlen(STT_DOWNLOAD_ENGINE) + strlen(dirp->d_name) + 5;
+                               filepath = (char*)calloc(filesize, sizeof(char));
+
+                               if (NULL != filepath) {
+                                       snprintf(filepath, filesize, "%s/%s", STT_DOWNLOAD_ENGINE, dirp->d_name);
+                               } else {
+                                       SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Memory not enouth!!");
+                                       continue;
+                               }
+
+                               /* get its info and update engine list */
+                               if (0 == __internal_get_engine_info(filepath, &info)) {
+                                       /* add engine info to g_engine_list */
+                                       g_engine_list = g_slist_append(g_engine_list, info);
+                               }
+
+                               if (NULL != filepath)
+                                       free(filepath);
+                       }
+               } while (NULL != dirp);
 
                closedir(dp);
        } else {
                SLOG(LOG_WARN, TAG_STTD, "[Engine Agent WARNING] Fail to open downloadable directory"); 
        }
 
-       if (0 >= g_list_length(g_engine_list)) {
+       if (0 >= g_slist_length(g_engine_list)) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] No Engine"); 
                return STTD_ERROR_ENGINE_NOT_FOUND;     
        }
 
        __log_enginelist();
-       
-       return 0;
-}
 
-int __internal_set_current_engine(const char* engine_uuid)
-{
-       if (NULL == engine_uuid) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter"); 
-               return STTD_ERROR_INVALID_PARAMETER;
-       }
+       /* Set default engine */
+       GSList *iter = NULL;
+       sttengine_info_s *engine = NULL;
+       char* cur_engine_uuid = NULL;
+       bool is_default_engine = false;
 
-       /* check whether engine id is valid or not.*/
-       GList *iter = NULL;
-       sttengine_info_s *data = NULL;
+       /* get current engine from config */
+       if (0 == sttd_config_get_default_engine(&cur_engine_uuid)) {
+               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] current engine from config : %s", cur_engine_uuid);
 
-       bool flag = false;
-       if (g_list_length(g_engine_list) > 0) {
-               /*Get a first item*/
-               iter = g_list_first(g_engine_list);
+               if (0 < g_slist_length(g_engine_list)) {
+                       /* Get a first item */
+                       iter = g_slist_nth(g_engine_list, 0);
 
-               while (NULL != iter) {
-                       /*Get handle data from list*/
-                       data = iter->data;
+                       while (NULL != iter) {
+                               /* Get handle data from list */
+                               engine = iter->data;
 
-                       SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] engine_uuid(%s) engine list->uuid(%s)", engine_uuid, data->engine_uuid);
+                               if (0 == strcmp(engine->engine_uuid, cur_engine_uuid)) {
+                                       is_default_engine = true;
+                                       g_default_engine_id = engine->engine_id;
+                                       break;
+                               }
 
-                       if (0 == strncmp(data->engine_uuid, engine_uuid, strlen(engine_uuid))) {
-                               flag = true;
-                               break;
+                               iter = g_slist_next(iter);
                        }
-
-                       /*Get next item*/
-                       iter = g_list_next(iter);
                }
-       }
 
-       /* If current engine does not exist, return error */
-       if (false == flag) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] __internal_set_current_engine : Cannot find engine id"); 
-               return STTD_ERROR_INVALID_PARAMETER;
+               if (cur_engine_uuid != NULL )
+                       free(cur_engine_uuid);
        } else {
-               if (NULL != g_cur_engine.engine_uuid) {
-                       /*compare current engine uuid */
-                       if (0 == strncmp(g_cur_engine.engine_uuid, data->engine_uuid, strlen(engine_uuid))) {
-                               SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent Check] stt engine has already been set");
-                               return 0;
-                       }
-               }
+               SLOG(LOG_WARN, TAG_STTD, "[Engine Agent WARNING] There is not current engine from config"); 
        }
 
-       /* set data from g_engine_list */
-       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 (false == is_default_engine) {
+               if (0 < g_slist_length(g_engine_list)) {
+                       /* Get a first item */
+                       iter = g_slist_nth(g_engine_list, 0);
 
-       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);
+                       /* Get handle data from list */
+                       engine = iter->data;
 
-       g_cur_engine.handle = NULL;
-       g_cur_engine.is_loaded = false;
-       g_cur_engine.is_set = true;
-       g_cur_engine.need_network = data->use_network;
+                       if (NULL != engine) {
+                               is_default_engine = true;
+                               g_default_engine_id = engine->engine_id;
+                       }
+               }
+       }
 
-       g_cur_engine.profanity_filter = g_default_profanity_filter;
-       g_cur_engine.punctuation_override = g_default_punctuation_override;
-       g_cur_engine.silence_detection = g_default_silence_detected;
+       if (NULL != engine) {
+               if (NULL != engine->engine_uuid) {
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Default engine Id(%d) uuid(%s)", engine->engine_id, engine->engine_uuid);
 
-       SLOG(LOG_DEBUG, TAG_STTD, "-----");
-       SLOG(LOG_DEBUG, TAG_STTD, " Current engine uuid : %s", g_cur_engine.engine_uuid);
-       SLOG(LOG_DEBUG, TAG_STTD, " Current engine name : %s", g_cur_engine.engine_name);
-       SLOG(LOG_DEBUG, TAG_STTD, " Current engine path : %s", g_cur_engine.engine_path);
-       SLOG(LOG_DEBUG, TAG_STTD, "-----");
+                       if (false == is_default_engine) {
+                               if (0 != sttd_config_set_default_engine(engine->engine_uuid))
+                                       SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to set default engine "); 
+                       }
+               }
+       } else {
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Default engine is NULL");
+               return STTD_ERROR_ENGINE_NOT_FOUND;
+       }
+
+       g_agent_init = true;
 
        return 0;
 }
 
-int sttd_engine_agent_load_current_engine()
+sttengine_info_s* __engine_agent_get_engine_by_id(int engine_id)
 {
-       if (false == g_agent_init) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
-               return STTD_ERROR_OPERATION_FAILED;
-       }
+       GSList *iter = NULL;
+       sttengine_info_s *data = NULL;
 
-       if (false == g_cur_engine.is_set) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] sttd_engine_agent_load_current_engine : No Current Engine "); 
-               return -1;
-       }
+       iter = g_slist_nth(g_engine_list, 0);
 
-       /* check whether current engine is loaded or not */
-       if (true == g_cur_engine.is_loaded) {
-               SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] sttd_engine_agent_load_current_engine : Engine has already been loaded ");
-               return 0;
-       }
-       
-       SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Current engine path : %s", g_cur_engine.engine_path);
+       while (NULL != iter) {
 
-       /* open engine */
-       char *error;
-       g_cur_engine.handle = dlopen(g_cur_engine.engine_path, RTLD_LAZY);
+               data = iter->data;
 
-       if (NULL != (error = dlerror()) || !g_cur_engine.handle) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to get engine handle"); 
-               return STTD_ERROR_OPERATION_FAILED;
-       }
-       
-       g_cur_engine.sttp_unload_engine = (int (*)())dlsym(g_cur_engine.handle, "sttp_unload_engine");
-       if (NULL != (error = dlerror()) || NULL == g_cur_engine.sttp_unload_engine) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to link daemon to sttp_unload_engine() : %s", error); 
-               return STTD_ERROR_OPERATION_FAILED;
-       }
+               if (data->engine_id == engine_id) 
+                       return data;
 
-       g_cur_engine.sttp_load_engine = (int (*)(sttpd_funcs_s*, sttpe_funcs_s*) )dlsym(g_cur_engine.handle, "sttp_load_engine");
-       if (NULL != (error = dlerror()) || NULL == g_cur_engine.sttp_load_engine) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to link daemon to sttp_load_engine() : %s", error); 
-               return STTD_ERROR_OPERATION_FAILED;
+               iter = g_slist_next(iter);
        }
 
-       /* load engine */
-       g_cur_engine.pdfuncs->version = 1;
-       g_cur_engine.pdfuncs->size = sizeof(sttpd_funcs_s);
+       return NULL;
+}
 
-       if (0 != g_cur_engine.sttp_load_engine(g_cur_engine.pdfuncs, g_cur_engine.pefuncs)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail sttp_load_engine()"); 
-               return STTD_ERROR_OPERATION_FAILED;
-       }
+sttengine_info_s* __engine_agent_get_engine_by_uuid(const char* engine_uuid)
+{
+       GSList *iter = NULL;
+       sttengine_info_s *data = NULL;
 
-       SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] engine info : version(%d), size(%d)",g_cur_engine.pefuncs->version, g_cur_engine.pefuncs->size); 
+       iter = g_slist_nth(g_engine_list, 0);
 
-       /* engine error check */
-       if (g_cur_engine.pefuncs->size != sizeof(sttpe_funcs_s)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] sttd_engine_agent_load_current_engine : engine is not valid"); 
-               return STTD_ERROR_OPERATION_FAILED;
-       }
+       while (NULL != iter) {
 
-       /* initalize engine */
-       if (0 != g_cur_engine.pefuncs->initialize(__result_cb, __partial_result_cb, __detect_silence_cb)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to initialize stt-engine"); 
-               return STTD_ERROR_OPERATION_FAILED;
-       }
+               data = iter->data;
 
-       /* set default setting */
-       int ret = 0;
+               if (0 == strcmp(data->engine_uuid, engine_uuid)) 
+                       return data;
 
-       if (NULL == g_cur_engine.pefuncs->set_profanity_filter) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] set_profanity_filter of engine is NULL!!");
-               return STTD_ERROR_OPERATION_FAILED;
-       }
-       
-       /* check and set profanity filter */
-       ret = g_cur_engine.pefuncs->set_profanity_filter(g_cur_engine.profanity_filter);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent] Not support profanity filter");
-               g_cur_engine.support_profanity_filter = false;
-       } else {
-               g_cur_engine.support_profanity_filter = true;
-       }
-       
-       /* check and set punctuation */
-       if (NULL == g_cur_engine.pefuncs->set_punctuation) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] set_punctuation of engine is NULL!!");
-               return STTD_ERROR_OPERATION_FAILED;
+               iter = g_slist_next(iter);
        }
 
-       ret = g_cur_engine.pefuncs->set_punctuation(g_cur_engine.punctuation_override);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine ERROR] Not support punctuation override");
-               g_cur_engine.support_punctuation_override = false;
-       } else {
-               g_cur_engine.support_punctuation_override = true;
-       }
+       return NULL;
+}
 
-       /* check and set silence detection */
-       if (NULL == g_cur_engine.pefuncs->set_silence_detection) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] set_silence_detection of engine is NULL!!");
-               return STTD_ERROR_OPERATION_FAILED;
-       }
+sttengine_client_s* __engine_agent_get_client(int uid)
+{
+       GSList *iter = NULL;
+       sttengine_client_s *data = NULL;
 
-       ret = g_cur_engine.pefuncs->set_silence_detection(g_cur_engine.silence_detection);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine ERROR] Not support silence detection");
-               g_cur_engine.support_silence_detection = false;
-       } else {
-               g_cur_engine.support_silence_detection = true;
-       }
-       
-       /* select default language */
-       bool set_voice = false;
-       if (NULL != g_cur_engine.default_lang) {
-               if (NULL == g_cur_engine.pefuncs->is_valid_lang) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] set_default_lang of engine is NULL!!");
-                       return STTD_ERROR_OPERATION_FAILED;
-               }
+       if (0 < g_slist_length(g_engine_client_list)) {
+               iter = g_slist_nth(g_engine_client_list, 0);
 
-               if (true == g_cur_engine.pefuncs->is_valid_lang(g_cur_engine.default_lang)) {
-                       set_voice = true;
-                       SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent SUCCESS] Set origin default voice to current engine : lang(%s)", g_cur_engine.default_lang);
-               } else {
-                       SLOG(LOG_WARN, TAG_STTD, "[Engine Agent WARNING] Fail set origin default language : lang(%s)", g_cur_engine.default_lang);
+               while (NULL != iter) {
+                       /* Get handle data from list */
+                       data = iter->data;
+
+                       if (uid == data->uid) 
+                               return data;
+
+                       iter = g_slist_next(iter);
                }
        }
 
-       if (false == set_voice) {
-               if (NULL == g_cur_engine.pefuncs->foreach_langs) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] foreach_langs of engine is NULL!!");
-                       return STTD_ERROR_OPERATION_FAILED;
-               }
+       return NULL;
+}
 
-               /* get language list */
-               int ret;
-               GList* lang_list = NULL;
+sttengine_info_s* __engine_agent_get_engine_by_uid(int uid)
+{
+       sttengine_client_s *data;
 
-               ret = g_cur_engine.pefuncs->foreach_langs(__supported_language_cb, &lang_list);
+       data = __engine_agent_get_client(uid);
+       if (NULL != data) 
+               return __engine_agent_get_engine_by_id(data->engine_id);
 
-               if (0 == ret && 0 < g_list_length(lang_list)) {
-                       GList *iter = NULL;
-                       iter = g_list_first(lang_list);
+       return NULL;
+}
 
-                       if (NULL != iter) {
-                               char* temp_lang = iter->data;
+int __engine_agent_check_engine_unload(int engine_id)
+{
+       /* Check the count of client to use this engine */
+       GSList *iter = NULL;
+       int client_count = 0;
+       sttengine_client_s *data = NULL;
+       
+       if (0 < g_slist_length(g_engine_client_list)) {
+               iter = g_slist_nth(g_engine_client_list, 0);
 
-                               if (true != g_cur_engine.pefuncs->is_valid_lang(temp_lang)) {
-                                       SLOG(LOG_ERROR, TAG_STTD, "[Engine ERROR] Fail voice is NOT valid");
-                                       return STTD_ERROR_OPERATION_FAILED;
-                               }
+               while (NULL != iter) {
+                       /* Get handle data from list */
+                       data = iter->data;
 
-                               sttd_config_set_default_language(temp_lang);
+                       if (data->engine_id == engine_id)
+                               client_count++;
 
-                               g_cur_engine.default_lang = g_strdup(temp_lang);
-                               
-                               SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent SUCCESS] Select default voice : lang(%s)", temp_lang);
-                       } else {
-                               SLOG(LOG_ERROR, TAG_STTD, "[Engine ERROR] Fail to get language list : result(%d)\n", ret);
-                               return STTD_ERROR_OPERATION_FAILED;
-                       }
+                       iter = g_slist_next(iter);
+               }
+       }
 
-                       __free_language_list(lang_list);
+       if (0 == client_count) {
+               sttengine_info_s* engine = NULL;
+               engine = __engine_agent_get_engine_by_id(engine_id);
+               if (NULL == engine) {
+                       SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to get engine from client(%d)", engine_id);
                } else {
-                       SLOG(LOG_ERROR, TAG_STTD, "[Engine ERROR] Fail to get language list : result(%d)\n", ret);
-                       return STTD_ERROR_OPERATION_FAILED;
+                       if (engine->is_loaded) {
+                               /* unload engine */
+#ifndef AUDIO_CREATE_ON_START
+                               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Destroy recorder");
+                               if (0 != sttd_recorder_destroy(engine->engine_id))
+                                       SECURE_SLOG(LOG_WARN, TAG_STTD, "[Engine Agent] Fail to destroy recorder(%d)", engine->engine_id);
+#endif
+                               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Unload engine id(%d)", engine_id);
+                               if (0 != stt_engine_deinitialize(engine->engine_id))
+                                       SECURE_SLOG(LOG_WARN, TAG_STTD, "[Engine Agent] Fail to deinitialize engine id(%d)", engine->engine_id);
+
+                               if (0 != stt_engine_unload(engine->engine_id))
+                                       SECURE_SLOG(LOG_WARN, TAG_STTD, "[Engine Agent] Fail to unload engine id(%d)", engine->engine_id);
+
+                               engine->is_loaded = false;
+                       }
                }
-
-       } 
-
-       g_cur_engine.is_loaded = true;
-
-       SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent SUCCESS] The %s has been loaded !!!", g_cur_engine.engine_name); 
-
-       return 0;
-}
-
-int sttd_engine_agent_unload_current_engine()
-{
-       if (false == g_agent_init) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized "); 
-               return STTD_ERROR_OPERATION_FAILED;
-       }
-
-       if (false == g_cur_engine.is_set) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] sttd_engine_agent_unload_current_engine : No Current Engine "); 
-               return -1;
-       }
-
-       if (false == g_cur_engine.is_loaded) {
-               SLOG(LOG_WARN, TAG_STTD, "[Engine Agent WARNING] Current engine has already been unloaded "); 
-               return 0;
        }
 
-       /* shutdown engine */
-       if (NULL == g_cur_engine.pefuncs->deinitialize) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] shutdown of engine is NULL!!");
-       } else {
-               g_cur_engine.pefuncs->deinitialize();
-       }
-
-       /* unload engine */
-       if (0 != g_cur_engine.sttp_unload_engine()) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to unload engine"); 
-       }
-
-       dlclose(g_cur_engine.handle);
-
-       /* reset current engine data */
-       g_cur_engine.handle = NULL;
-       g_cur_engine.is_loaded = false;
-
        return 0;
 }
 
-bool sttd_engine_agent_need_network()
+int sttd_engine_agent_load_current_engine(int uid, const char* engine_uuid)
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized" );
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       if (false == g_cur_engine.is_loaded) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine");
-               return STTD_ERROR_OPERATION_FAILED;
-       }
-
-       return g_cur_engine.need_network;
-}
+       sttengine_client_s* client = NULL;
+       sttengine_info_s* engine = NULL;
+       int before_engine = -1;
 
-int sttd_engine_get_option_supported(bool* silence, bool* profanity, bool* punctuation)
-{
-       if (false == g_agent_init) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized" );
-               return STTD_ERROR_OPERATION_FAILED;
-       }
-
-       if (false == g_cur_engine.is_loaded) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine");
-               return STTD_ERROR_OPERATION_FAILED;
-       }
-
-       if (NULL == silence || NULL == profanity || NULL == punctuation) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter"); 
-               return STTD_ERROR_INVALID_PARAMETER;
-       }
-
-       *silence = g_cur_engine.support_silence_detection;
-       *profanity = g_cur_engine.support_profanity_filter;
-       *punctuation = g_cur_engine.support_punctuation_override;
-
-       return 0;
-}
+       client = __engine_agent_get_client(uid);
+       
+       if (NULL == client) {
+               client = (sttengine_client_s*)calloc(1, sizeof(sttengine_client_s));
+               
+               /* initialize */
+               client->uid = uid;
+               client->engine_id = -1;
+       
+               g_engine_client_list = g_slist_append(g_engine_client_list, client);
 
-/*
-* STT Engine Interfaces for client
-*/
+               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Registered client(%d)", uid);
+       } 
 
-int __set_option(int profanity, int punctuation, int silence)
-{
-       if (2 == profanity) {
-               /* Default selection */
-               if (g_default_profanity_filter != g_cur_engine.profanity_filter) {
-                       if (NULL != g_cur_engine.pefuncs->set_profanity_filter) {
-                               if (0 != g_cur_engine.pefuncs->set_profanity_filter(g_default_profanity_filter)) {
-                                       SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to set profanity filter");
-                                       return STTD_ERROR_OPERATION_FAILED;
-                               }
-                               g_cur_engine.profanity_filter = g_default_profanity_filter;
-                               SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Set profanity filter : %s", g_cur_engine.profanity_filter ? "true" : "false");
-                       } else {
-                               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] profanity_filter() of engine is NULL!!");
-                               return STTD_ERROR_OPERATION_FAILED;
-                       }
-               }
-       } else {
-               /* Client selection */
-               if (g_cur_engine.profanity_filter != profanity) {
-                       if (NULL != g_cur_engine.pefuncs->set_profanity_filter) {
-                               if (0 != g_cur_engine.pefuncs->set_profanity_filter((bool)profanity)) {
-                                       SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to set profanity filter");
-                                       return STTD_ERROR_OPERATION_FAILED;
-                               }
+       if (NULL == engine_uuid) {
+               /* Set default engine */
+               engine = __engine_agent_get_engine_by_id(g_default_engine_id);
 
-                               g_cur_engine.profanity_filter = (bool)profanity;
-                               SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Set profanity filter : %s", g_cur_engine.profanity_filter ? "true" : "false");
-                       } else {
-                               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] profanity_filter() of engine is NULL!!");
-                               return STTD_ERROR_OPERATION_FAILED;
-                       }
+               if (NULL == engine) {
+                       SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to get default engine : %d", g_default_engine_id);
+                       return STTD_ERROR_OPERATION_FAILED;
                }
-       }
+               before_engine = client->engine_id;
 
-       if (2 == punctuation) {
-               /* Default selection */
-               if (g_default_punctuation_override != g_cur_engine.punctuation_override) {
-                       if (NULL != g_cur_engine.pefuncs->set_punctuation) {
-                               if (0 != g_cur_engine.pefuncs->set_punctuation(g_default_punctuation_override)) {
-                                       SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to set punctuation override");
-                                       return STTD_ERROR_OPERATION_FAILED;
-                               }
-                               g_cur_engine.punctuation_override = g_default_punctuation_override;
-                               SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Set punctuation override : %s", g_cur_engine.punctuation_override ? "true" : "false");
-                       } else {
-                               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] set_punctuation() of engine is NULL!!");
-                               return STTD_ERROR_OPERATION_FAILED;
-                       }
-               }
+               client->engine_id = engine->engine_id;
+               client->use_default_engine = true;
        } else {
-               /* Client selection */
-               if (g_cur_engine.punctuation_override != punctuation) {
-                       if (NULL != g_cur_engine.pefuncs->set_punctuation) {
-                               if (0 != g_cur_engine.pefuncs->set_punctuation((bool)punctuation)) {
-                                       SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to set punctuation override");
-                                       return STTD_ERROR_OPERATION_FAILED;
-                               }
-
-                               g_cur_engine.punctuation_override = (bool)punctuation;
-                               SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Set punctuation override : %s", g_cur_engine.punctuation_override ? "true" : "false");
-                       } else {
-                               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] set_punctuation() of engine is NULL!!");
-                               return STTD_ERROR_OPERATION_FAILED;
-                       }
-               }
-       }
+               /* Set engine by uid */
+               engine = __engine_agent_get_engine_by_uuid(engine_uuid);
 
-       if (2 == silence) {
-               /* Default selection */
-               if (g_default_silence_detected != g_cur_engine.silence_detection) {
-                       if (NULL != g_cur_engine.pefuncs->set_silence_detection) {
-                               if (0 != g_cur_engine.pefuncs->set_silence_detection(g_default_silence_detected)) {
-                                       SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to set silence detection");
-                                       return STTD_ERROR_OPERATION_FAILED;
-                               }
-                               g_cur_engine.silence_detection = g_default_silence_detected;
-                               SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Set silence detection : %s", g_cur_engine.silence_detection ? "true" : "false");
-                       } else {
-                               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] set_silence() of engine is NULL!!");
-                               return STTD_ERROR_OPERATION_FAILED;
-                       }
-               }
-       } else {
-               /* Client selection */
-               if (g_cur_engine.silence_detection != silence) {
-                       if (NULL != g_cur_engine.pefuncs->set_silence_detection) {
-                               if (0 != g_cur_engine.pefuncs->set_silence_detection((bool)silence)) {
-                                       SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to set silence detection");
-                                       return STTD_ERROR_OPERATION_FAILED;
-                               }
-
-                               g_cur_engine.silence_detection = (bool)silence;
-                               SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Set silence detection : %s", g_cur_engine.silence_detection ? "true" : "false");
-                       } else {
-                               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] set_silence() of engine is NULL!!");
-                               return STTD_ERROR_OPERATION_FAILED;
-                       }
+               if (NULL == engine) {
+                       SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to get engine : %s", engine_uuid);
+                       return STTD_ERROR_OPERATION_FAILED;
                }
-       }
-       
-       return 0;
-}
+               before_engine = client->engine_id;
 
-int sttd_engine_recognize_start(const char* lang, const char* recognition_type, 
-                               int profanity, int punctuation, int silence, void* user_param)
-{
-       if (false == g_agent_init) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
-               return STTD_ERROR_OPERATION_FAILED;
+               client->engine_id = engine->engine_id;
+               client->use_default_engine = false;
        }
 
-       if (false == g_cur_engine.is_loaded) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); 
-               return STTD_ERROR_OPERATION_FAILED;
+       if (-1 != before_engine) {
+               /* Unload engine if reference count is 0 */
+               __engine_agent_check_engine_unload(before_engine);
        }
 
-       if (NULL == lang || NULL == recognition_type) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter"); 
-               return STTD_ERROR_INVALID_PARAMETER;
+       if (true == engine->is_loaded) {
+               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Engine] engine id(%d) is already loaded", engine->engine_id);
+               return 0;
        }
 
-       if (0 != __set_option(profanity, punctuation, g_default_silence_detected)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to set options"); 
+       /* Load engine */
+       int ret;
+       ret = stt_engine_load(engine->engine_id, engine->engine_path);
+       if (0 != ret) {
+               SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to load engine : id(%d) path(%s)", engine->engine_id, engine->engine_path);
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       if (NULL == g_cur_engine.pefuncs->start) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] start() of engine is NULL!!");
+       ret = stt_engine_initialize(engine->engine_id, __result_cb, __detect_silence_cb);
+       if (0 != ret) {
+               SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to initialize engine : id(%d) path(%s)", engine->engine_id, engine->engine_path);
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       char* temp;
-       if (0 == strncmp(lang, "default", strlen("default"))) {
-               temp = strdup(g_cur_engine.default_lang);
+       ret = stt_engine_set_silence_detection(engine->engine_id, g_default_silence_detected);
+       if (0 != ret) {
+               SLOG(LOG_WARN, TAG_STTD, "[Engine Agent WARNING] Not support silence detection");
+               engine->support_silence_detection = false;
        } else {
-               temp = strdup(lang);
+               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Silence detection : %s", g_default_silence_detected ? "true" : "false");
+               engine->support_silence_detection = true;
+               engine->silence_detection = g_default_silence_detected;
        }
 
-       int ret = g_cur_engine.pefuncs->start(temp, recognition_type, user_param);
-       free(temp);
-
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] sttd_engine_recognize_start : recognition start error(%d)", ret); 
+       /* Set first language */
+       char* tmp_lang = NULL;
+       ret = stt_engine_get_first_language(engine->engine_id, &tmp_lang);
+       if (0 == ret && NULL != tmp_lang) {
+               engine->first_lang = strdup(tmp_lang);
+               free(tmp_lang);
+       } else {
+               SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to get first language from engine : %d %s", engine->engine_id, engine->engine_name);
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent SUCCESS] sttd_engine_recognize_start");
-
-       return 0;
-}
-
-int sttd_engine_recognize_audio(const void* data, unsigned int length)
-{
-       if (false == g_agent_init) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
-               return STTD_ERROR_OPERATION_FAILED;
-       }
+#ifndef AUDIO_CREATE_ON_START
+       /* Ready recorder */
+       sttp_audio_type_e atype;
+       int rate;
+       int channels;
 
-       if (false == g_cur_engine.is_loaded) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); 
+       ret = stt_engine_get_audio_type(engine->engine_id, &atype, &rate, &channels);
+       if (0 != ret) {
+               SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to get audio type : %d %s", engine->engine_id, engine->engine_name);
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       if (NULL == data) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter"); 
-               return STTD_ERROR_INVALID_PARAMETER;
-       }
-
-       if (NULL == g_cur_engine.pefuncs->set_recording) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] The function of engine is NULL!!");
+       ret = sttd_recorder_create(engine->engine_id, atype, channels, rate);
+       if (0 != ret) {
+               SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to create recorder : %d %s", engine->engine_id, engine->engine_name);
                return STTD_ERROR_OPERATION_FAILED;
        }
+#endif
 
-       int ret = g_cur_engine.pefuncs->set_recording(data, length);
-       if (0 != ret) {
-               SLOG(LOG_WARN, TAG_STTD, "[Engine Agent WARNING] set recording error(%d)", ret); 
-               return ret;
-       }
+       engine->is_loaded = true;
+       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent SUCCESS] The %s(%d) has been loaded !!!", engine->engine_name, engine->engine_id); 
 
        return 0;
 }
 
-int sttd_engine_recognize_stop()
+int sttd_engine_agent_unload_current_engine(int uid)
 {
        if (false == g_agent_init) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized "); 
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       if (false == g_cur_engine.is_loaded) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); 
-               return STTD_ERROR_OPERATION_FAILED;
-       }
+       /* Remove client */
+       int engine_id = -1;
 
-       if (NULL == g_cur_engine.pefuncs->stop) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] The function of engine is NULL!!");
-               return STTD_ERROR_OPERATION_FAILED;
-       }
+       GSList *iter = NULL;
+       sttengine_client_s *data = NULL;
 
-       int ret = g_cur_engine.pefuncs->stop();
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] stop recognition error(%d)", ret); 
-               return STTD_ERROR_OPERATION_FAILED;
-       }
+       if (0 < g_slist_length(g_engine_client_list)) {
+               iter = g_slist_nth(g_engine_client_list, 0);
 
-       return 0;
-}
+               while (NULL != iter) {
+                       /* Get handle data from list */
+                       data = iter->data;
 
-int sttd_engine_recognize_cancel()
-{
-       if (false == g_agent_init) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
-               return STTD_ERROR_OPERATION_FAILED;
-       }
+                       if (NULL != data) {
+                               if (uid == data->uid) {
+                                       g_engine_client_list = g_slist_remove_link(g_engine_client_list, iter);
+                                       engine_id = data->engine_id;
+                                       free(data);
+                                       break;
+                               }
+                       }
 
-       if (false == g_cur_engine.is_loaded) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); 
-               return STTD_ERROR_OPERATION_FAILED;
-       }
-       
-       if (NULL == g_cur_engine.pefuncs->cancel) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] The function of engine is NULL!!");
-               return STTD_ERROR_OPERATION_FAILED;
+                       iter = g_slist_next(iter);
+               }
        }
 
-       int ret = g_cur_engine.pefuncs->cancel();
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] cancel recognition error(%d)", ret); 
-               return STTD_ERROR_OPERATION_FAILED;
+       if (-1 != engine_id) {
+               __engine_agent_check_engine_unload(engine_id);
        }
 
        return 0;
 }
 
-int sttd_engine_get_audio_format(sttp_audio_type_e* types, int* rate, int* channels)
+bool sttd_engine_agent_is_default_engine()
 {
-       if (false == g_agent_init) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
-               return STTD_ERROR_OPERATION_FAILED;
-       }
-
-       if (false == g_cur_engine.is_loaded) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); 
-               return STTD_ERROR_OPERATION_FAILED;
-       }
-
-       if (NULL == g_cur_engine.pefuncs->get_audio_format) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] The function of engine is NULL!!");
-               return STTD_ERROR_OPERATION_FAILED;
-       }
-
-       int ret = g_cur_engine.pefuncs->get_audio_format(types, rate, channels);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] get audio format error(%d)", ret); 
-               return STTD_ERROR_OPERATION_FAILED;
-       }
+       if (g_default_engine_id > 0) 
+               return true;
 
-       return 0;
+       return false;
 }
 
-int sttd_engine_recognize_start_file(const char* filepath, const char* lang, const char* recognition_type, 
-                                    int profanity, int punctuation, void* user_param)
+int sttd_engine_agent_get_engine_list(GSList** engine_list)
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       if (false == g_cur_engine.is_loaded) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); 
-               return STTD_ERROR_OPERATION_FAILED;
-       }
-
-       if (NULL == filepath || NULL == lang || NULL == recognition_type) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter"); 
-               return STTD_ERROR_INVALID_PARAMETER;
-       }
-
-       if (0 != __set_option(profanity, punctuation, g_default_silence_detected)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to set options"); 
-               return STTD_ERROR_OPERATION_FAILED;
-       }
-
-       if (NULL == g_cur_engine.pefuncs->start_file_recognition) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] start() of engine is NULL!!");
-               return STTD_ERROR_OPERATION_FAILED;
-       }
-
-       char* temp;
-       if (0 == strncmp(lang, "default", strlen("default"))) {
-               temp = strdup(g_cur_engine.default_lang);
-       } else {
-               temp = strdup(lang);
-       }
-
-       int ret = g_cur_engine.pefuncs->start_file_recognition(filepath, temp, recognition_type, user_param);
-       free(temp);
-
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to start file recognition(%d)", ret); 
-               return ret;
-       }
+       GSList *iter = NULL;
+       sttengine_info_s *data = NULL;
 
-       SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent SUCCESS] File recognition");
+       iter = g_slist_nth(g_engine_list, 0);
 
-       return 0;
-}
+       SLOG(LOG_DEBUG, TAG_STTD, "----- [Engine Agent] engine list -----");
 
-/*
-* STT Engine Interfaces for client and setting
-*/
-bool __supported_language_cb(const char* language, void* user_data)
-{
-       GList** lang_list = (GList**)user_data;
+       while (NULL != iter) {
+               engine_s* temp_engine;
 
-       if (NULL == language || NULL == lang_list) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Input parameter is NULL in callback!!!!");
-               return false;
-       }
+               temp_engine = (engine_s*)calloc(1, sizeof(engine_s));
 
-       SLOG(LOG_DEBUG, TAG_STTD, "-- Language(%s)", language);
+               data = iter->data;
 
-       char* temp_lang = g_strdup(language);
+               temp_engine->engine_id = strdup(data->engine_uuid);
+               temp_engine->engine_name = strdup(data->engine_name);
+               temp_engine->ug_name = strdup(data->engine_setting_path);
 
-       *lang_list = g_list_append(*lang_list, temp_lang);
+               *engine_list = g_slist_append(*engine_list, temp_engine);
 
-       return true;
-}
+               iter = g_slist_next(iter);
 
-int sttd_engine_supported_langs(GList** lang_list)
-{
-       if (false == g_agent_init) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
-               return STTD_ERROR_OPERATION_FAILED;
+               SECURE_SLOG(LOG_DEBUG, TAG_STTD, " -- Engine id(%s)", temp_engine->engine_id); 
+               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "    Engine name(%s)", temp_engine->engine_name);
+               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "    Engine ug name(%s)", temp_engine->ug_name);
        }
 
-       if (false == g_cur_engine.is_loaded) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); 
-               return STTD_ERROR_OPERATION_FAILED;
-       }
-
-       if (NULL == g_cur_engine.pefuncs->foreach_langs) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] The function of engine is NULL!!");
-               return STTD_ERROR_OPERATION_FAILED;
-       }
-
-       int ret = g_cur_engine.pefuncs->foreach_langs(__supported_language_cb, (void*)lang_list);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] get language list error(%d)", ret); 
-               return STTD_ERROR_OPERATION_FAILED;
-       }
+       SLOG(LOG_DEBUG, TAG_STTD, "--------------------------------------");
 
        return 0;
 }
 
-
-int sttd_engine_get_default_lang(char** lang)
+int sttd_engine_agent_get_current_engine(int uid, char** engine_uuid)
 {
        if (false == g_agent_init) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
-               return STTD_ERROR_OPERATION_FAILED;
-       }
-
-       if (false == g_cur_engine.is_loaded) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); 
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized" );
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       if (NULL == lang) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter"); 
+       if (NULL == engine_uuid) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid parameter" );
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
-       /* get default language */
-       *lang = g_strdup(g_cur_engine.default_lang);
-
-       return 0;
-}
-
-int sttd_engine_is_partial_result_supported(bool* partial_result)
-{
-       if (false == g_agent_init) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
-               return STTD_ERROR_OPERATION_FAILED;
-       }
-
-       if (false == g_cur_engine.is_loaded) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); 
-               return STTD_ERROR_OPERATION_FAILED;
-       }
+       sttengine_info_s* engine;
+       engine = __engine_agent_get_engine_by_uid(uid);
 
-       if (NULL == partial_result) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter"); 
+       if (NULL == engine) {
+               SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] The engine of uid(%d) is not valid", uid);
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
-       if (NULL == g_cur_engine.pefuncs->support_partial_result) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] The function of engine is NULL!!");
+       if (false == engine->is_loaded) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); 
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       *partial_result = g_cur_engine.pefuncs->support_partial_result();
+       *engine_uuid = strdup(engine->engine_uuid);
 
        return 0;
 }
 
-
-/*
-* STT Engine Interfaces for setting
-*/
-
-int sttd_engine_setting_get_engine_list(GList** engine_list)
+bool sttd_engine_agent_need_network(int uid)
 {
        if (false == g_agent_init) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
-               return STTD_ERROR_OPERATION_FAILED;
-       }
-
-       if (false == g_cur_engine.is_loaded) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); 
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized" );
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       /* update engine list */
-       if (0 != __internal_update_engine_list()) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] sttd_engine_setting_get_engine_list : __internal_update_engine_list()"); 
-               return -1;
-       }
-
-       GList *iter = NULL;
-       sttengine_info_s *data = NULL;
-
-       iter = g_list_first(g_engine_list);
-
-       SLOG(LOG_DEBUG, TAG_STTD, "----- [Engine Agent] engine list -----");
-
-       while (NULL != iter) {
-               engine_s* temp_engine;
-
-               temp_engine = (engine_s*)g_malloc0(sizeof(engine_s));
-
-               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, TAG_STTD, " -- engine id(%s) engine name(%s) ug name(%s) \n", 
-                       temp_engine->engine_id, temp_engine->engine_name, temp_engine->ug_name);
-       }
-
-       SLOG(LOG_DEBUG, TAG_STTD, "--------------------------------------");
+       sttengine_info_s* engine;
+       engine = __engine_agent_get_engine_by_uid(uid);
+       
+       if (NULL != engine)
+               return engine->use_network;
 
-       return 0;
+       return false;
 }
 
-int sttd_engine_setting_get_engine(char** engine_id)
+int sttd_engine_agent_supported_langs(int uid, GSList** lang_list)
 {
        if (false == g_agent_init) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized" );
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized");
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       if (false == g_cur_engine.is_loaded) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine");
-               return STTD_ERROR_ENGINE_NOT_FOUND;
+       if (NULL == lang_list) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Input parameter is NULL");
+               return STTD_ERROR_INVALID_PARAMETER;
+       }
+
+       sttengine_info_s* engine = NULL;
+       engine = __engine_agent_get_engine_by_uid(uid);
+
+       if (NULL == engine) {
+               SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] The engine of uid(%d) is not valid", uid);
+               return STTD_ERROR_INVALID_PARAMETER;
+       }
+
+       if (false == engine->is_loaded) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); 
+               return STTD_ERROR_OPERATION_FAILED;
        }
 
-       *engine_id = strdup(g_cur_engine.engine_uuid);
+       int ret = stt_engine_get_supported_langs(engine->engine_id, lang_list);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] get language list error(%d)", ret); 
+               return STTD_ERROR_OPERATION_FAILED;
+       }
 
        return 0;
 }
 
-int sttd_engine_setting_set_engine(const char* engine_id)
+int sttd_engine_agent_get_default_lang(int uid, char** lang)
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       if (NULL == engine_id) {
+       if (NULL == lang) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter"); 
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
-       /* compare current engine and new engine. */
-       if (NULL != g_cur_engine.engine_uuid) {
-               if (0 == strncmp(g_cur_engine.engine_uuid, engine_id, strlen(g_cur_engine.engine_uuid))) {
-                       SLOG(LOG_WARN, TAG_STTD, "[Engine Agent] New engine is the same as current engine"); 
-                       return 0;
-               }
-       }
+       sttengine_info_s* engine = NULL;
+       engine = __engine_agent_get_engine_by_uid(uid);
 
-       char* tmp_uuid = NULL;
-       tmp_uuid = g_strdup(g_cur_engine.engine_uuid);
-       if (NULL == tmp_uuid) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not enough memory!!"); 
-               return STTD_ERROR_OUT_OF_MEMORY;
+       if (NULL == engine) {
+               SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] The engine of uid(%d) is not valid", uid);
+               return STTD_ERROR_INVALID_PARAMETER;
        }
 
-       /* unload engine */
-       if (0 != sttd_engine_agent_unload_current_engine()) 
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to unload current engine"); 
-       else
-               SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent SUCCESS] unload current engine");
-
-       /* change current engine */
-       if (0 != __internal_set_current_engine(engine_id)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] __internal_set_current_engine : no engine error"); 
-               
-               /* roll back to old current engine. */
-               __internal_set_current_engine(tmp_uuid);
-               sttd_engine_agent_load_current_engine();
-
-               if (NULL != tmp_uuid)   
-                       free(tmp_uuid);
-
+       if (false == engine->is_loaded) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); 
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       if (0 != sttd_engine_agent_load_current_engine()) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to load new engine"); 
-
-               if (NULL != tmp_uuid)   
-                       free(tmp_uuid);
-
+       /* get default language */
+       bool is_valid = false;
+       if (0 != stt_engine_is_valid_language(engine->engine_id, g_default_language, &is_valid)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to check valid language");
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent SUCCESS] sttd_engine_setting_set_engine() : Load new engine");
-
-       if( tmp_uuid != NULL )  
-               free(tmp_uuid);
-
-       /* set engine id to config */
-       if (0 != sttd_config_set_default_engine(engine_id)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to set engine id"); 
-       }
+       if (true == is_valid) {
+               *lang = strdup(g_default_language);
+       } else 
+               *lang = strdup(engine->first_lang);
 
        return 0;
 }
 
-int sttd_engine_setting_get_lang_list(char** engine_id, GList** lang_list)
+int sttd_engine_agent_get_option_supported(int uid, bool* silence)
 {
        if (false == g_agent_init) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized");
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       if (false == g_cur_engine.is_loaded) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); 
-               return STTD_ERROR_OPERATION_FAILED;
+       if (NULL == silence) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter"); 
+               return STTD_ERROR_INVALID_PARAMETER;
        }
 
-       if (NULL == lang_list || NULL == engine_id) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter"); 
+       sttengine_info_s* engine = NULL;
+       engine = __engine_agent_get_engine_by_uid(uid);
+
+       if (NULL == engine) {
+               SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] uid(%d) is not valid", uid);
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
-       /* get language list from engine */
-       int ret = sttd_engine_supported_langs(lang_list); 
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail get lang list (%d)", ret); 
+       if (false == engine->is_loaded) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); 
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       *engine_id = strdup(g_cur_engine.engine_uuid);
+       *silence = engine->support_silence_detection;
 
        return 0;
 }
 
-int sttd_engine_setting_get_default_lang(char** language)
+int sttd_engine_agent_is_recognition_type_supported(int uid, const char* type, bool* support)
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       if (false == g_cur_engine.is_loaded) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); 
-               return STTD_ERROR_OPERATION_FAILED;
-       }
-
-       if (NULL == language) {
+       if (NULL == type || NULL == support) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter"); 
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
-       if (NULL != g_cur_engine.default_lang) {
-               *language = strdup(g_cur_engine.default_lang);
-
-               SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent SUCCESS] Get default lanaguae : language(%s)", *language);
-       } else {
-               if (NULL == g_cur_engine.pefuncs->foreach_langs) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] foreach_langs of engine is NULL!!");
-                       return STTD_ERROR_OPERATION_FAILED;
-               }
+       sttengine_info_s* engine = NULL;
+       engine = __engine_agent_get_engine_by_uid(uid);
 
-               /* get language list */
-               int ret;
-               GList* lang_list = NULL;
+       if (NULL == engine) {
+               SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] The engine of uid(%d) is not valid", uid);
+               return STTD_ERROR_INVALID_PARAMETER;
+       }
 
-               ret = g_cur_engine.pefuncs->foreach_langs(__supported_language_cb, &lang_list);
+       if (false == engine->is_loaded) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); 
+               return STTD_ERROR_OPERATION_FAILED;
+       }
 
-               if (0 == ret && 0 < g_list_length(lang_list)) {
-                       GList *iter = NULL;
-                       iter = g_list_first(lang_list);
+       bool temp = false;
+       int ret;
 
-                       if (NULL != iter) {
-                               char* temp_lang = iter->data;
+       ret = stt_engine_support_recognition_type(engine->engine_id, type, &temp);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to get to support recognition type : %d", ret); 
+               return STTD_ERROR_OPERATION_FAILED;
+       }
 
-                               if (true != g_cur_engine.pefuncs->is_valid_lang(temp_lang)) {
-                                       SLOG(LOG_ERROR, TAG_STTD, "[Engine ERROR] Fail voice is NOT valid");
-                                       return STTD_ERROR_OPERATION_FAILED;
-                               }
+       *support = temp;
 
-                               sttd_config_set_default_language(temp_lang);
+       return 0;
+}
 
-                               g_cur_engine.default_lang = g_strdup(temp_lang);
+/*
+* STT Engine Interfaces for client
+*/
 
-                               *language = strdup(g_cur_engine.default_lang);
+int __set_option(sttengine_info_s* engine, int silence)
+{
+       if (NULL == engine)
+               return -1;
 
-                               SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent SUCCESS] Select default voice : lang(%s)", temp_lang);
-                       } else {
-                               SLOG(LOG_ERROR, TAG_STTD, "[Engine ERROR] Fail to get language list : result(%d)\n", ret);
-                               return STTD_ERROR_OPERATION_FAILED;
+       /* Check silence detection */
+       if (engine->support_silence_detection) {
+               if (2 == silence) {
+                       /* default option set */
+                       if (g_default_silence_detected != engine->silence_detection) {
+                               if (0 != stt_engine_set_silence_detection(engine->engine_id, g_default_silence_detected)) {
+                                       SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to set silence detection : %s", g_default_silence_detected ? "true" : "false");
+                               } else {
+                                       engine->silence_detection = g_default_silence_detected;
+                                       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Set silence detection : %s", g_default_silence_detected ? "true" : "false");
+                               }
                        }
-
-                       __free_language_list(lang_list);
                } else {
-                       SLOG(LOG_ERROR, TAG_STTD, "[Engine ERROR] Fail to get language list : result(%d)\n", ret);
-                       return STTD_ERROR_OPERATION_FAILED;
+                       if (silence != engine->silence_detection) {
+                               if (0 != stt_engine_set_silence_detection(engine->engine_id, silence)) {
+                                       SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to set silence detection : %s", silence ? "true" : "false");
+                               } else {
+                                       engine->silence_detection = silence;
+                                       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Set silence detection : %s", silence ? "true" : "false");
+                               }
+                       }
                }
        }
        
        return 0;
 }
 
-int sttd_engine_setting_set_default_lang(const char* language)
+int sttd_engine_agent_recognize_start_engine(int uid, const char* lang, const char* recognition_type, 
+                                     int silence, void* user_param)
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
                return STTD_ERROR_OPERATION_FAILED;
        }
+       
+       if (NULL == lang || NULL == recognition_type) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter"); 
+               return STTD_ERROR_INVALID_PARAMETER;
+       }
+
+       sttengine_info_s* engine = NULL;
+       engine = __engine_agent_get_engine_by_uid(uid);
+
+       if (NULL == engine) {
+               SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] The engine of uid(%d) is not valid", uid);
+               return STTD_ERROR_INVALID_PARAMETER;
+       }
 
-       if (false == g_cur_engine.is_loaded) {
+       if (false == engine->is_loaded) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); 
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       if (NULL == g_cur_engine.pefuncs->is_valid_lang) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] get_voice_list() of engine is NULL!!");
+       if (0 != __set_option(engine, silence)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to set options"); 
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       int ret = -1;
-       if(false == g_cur_engine.pefuncs->is_valid_lang(language)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Language is NOT valid !!");
-               return STTD_ERROR_INVALID_LANGUAGE;
-       }
+       SLOG(LOG_DEBUG, TAG_STTD, "g_default_language %s", g_default_language);
+
+       int ret;
+       char* temp = NULL;
+       if (0 == strncmp(lang, "default", strlen("default"))) {
+               bool is_valid = false;
+               if (0 != stt_engine_is_valid_language(engine->engine_id, g_default_language, &is_valid)) {
+                       SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to check valid language");
+                       return STTD_ERROR_OPERATION_FAILED;
+               }
 
-       if (NULL != g_cur_engine.default_lang)
-               g_free(g_cur_engine.default_lang);
+               if (true == is_valid) {
+                       temp = strdup(g_default_language);
+                       SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent DEBUG] Default language is %s", temp);
+               } else {
+                       temp = strdup(engine->first_lang);
+                       SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent DEBUG] Default language is engine first lang : %s", temp);
+               }
+       } else {
+               temp = strdup(lang);
+       }
 
-       g_cur_engine.default_lang = strdup(language);
+       SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Start engine");
 
-       ret = sttd_config_set_default_language(language);
+       ret = stt_engine_recognize_start(engine->engine_id, temp, recognition_type, user_param);
+       if (NULL != temp)       free(temp);
        if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to set default lang (%d)", ret); 
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Recognition start error(%d)", ret);
+               sttd_recorder_destroy(engine->engine_id);
+               return STTD_ERROR_OPERATION_FAILED;
        }
 
-       return 0;
-}
+#ifdef AUDIO_CREATE_ON_START
+       /* Ready recorder */
+       sttp_audio_type_e atype;
+       int rate;
+       int channels;
 
-int sttd_engine_setting_get_profanity_filter(bool* value)
-{
-       if (false == g_agent_init) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
+       ret = stt_engine_get_audio_type(engine->engine_id, &atype, &rate, &channels);
+       if (0 != ret) {
+               SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to get audio type : %d %s", engine->engine_id, engine->engine_name);
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       if (false == g_cur_engine.is_loaded) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); 
+       SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Create recorder");
+
+       ret = sttd_recorder_create(engine->engine_id, atype, channels, rate);
+       if (0 != ret) {
+               SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to create recorder : %d %s", engine->engine_id, engine->engine_name);
                return STTD_ERROR_OPERATION_FAILED;
        }
+#endif
 
-       if (NULL == value) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter"); 
-               return STTD_ERROR_INVALID_PARAMETER;
+#if 0
+       SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Start recorder");
+
+       ret = sttd_recorder_start(engine->engine_id);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to start recorder : result(%d)", ret);
+               return ret;
        }
 
-       *value = g_default_profanity_filter;    
+       g_recording_engine_id = engine->engine_id;
+       SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] g_recording_engine_id : %d", g_recording_engine_id); 
+#endif
 
        return 0;
 }
 
-int sttd_engine_setting_set_profanity_filter(bool value)
+int sttd_engine_agent_recognize_start_recorder(int uid)
 {
-       if (false == g_agent_init) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
-               return STTD_ERROR_OPERATION_FAILED;
+       sttengine_info_s* engine = NULL;
+       engine = __engine_agent_get_engine_by_uid(uid);
+
+       if (NULL == engine) {
+               SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] The engine of uid(%d) is not valid", uid);
+               return STTD_ERROR_INVALID_PARAMETER;
        }
 
-       if (false == g_cur_engine.is_loaded) {
+       if (false == engine->is_loaded) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); 
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       if (NULL == g_cur_engine.pefuncs->set_profanity_filter) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] The function of engine is NULL!!");
-               return STTD_ERROR_OPERATION_FAILED;
-       }
+       SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Start recorder");
 
-       int ret = g_cur_engine.pefuncs->set_profanity_filter(value);
+       int ret;
+       ret = sttd_recorder_start(engine->engine_id);
        if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail set profanity filter : result(%d)", ret); 
-               return STTD_ERROR_OPERATION_FAILED;
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to start recorder : result(%d)", ret);
+               stt_engine_recognize_cancel(engine->engine_id);
+               sttd_recorder_stop(engine->engine_id);
+               return ret;
        }
 
-       g_default_profanity_filter = value;
-
-       ret = sttd_config_set_default_profanity_filter((int)value);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to set default lang (%d)", ret); 
-       }
+       g_recording_engine_id = engine->engine_id;
+       SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] g_recording_engine_id : %d", g_recording_engine_id); 
 
        return 0;
 }
 
-int sttd_engine_setting_get_punctuation_override(bool* value)
+int sttd_engine_agent_set_recording_data(int uid, const void* data, unsigned int length)
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       if (false == g_cur_engine.is_loaded) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); 
-               return STTD_ERROR_OPERATION_FAILED;
+       if (NULL == data || 0 == length) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter"); 
+               return STTD_ERROR_INVALID_PARAMETER;
        }
 
-       if (NULL == value) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter"); 
+       sttengine_info_s* engine = NULL;
+       engine = __engine_agent_get_engine_by_uid(uid);
+
+       if (NULL == engine) {
+               SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] The engine of uid(%d) is not valid", uid);
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
-       *value = g_default_punctuation_override;
+       if (false == engine->is_loaded) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); 
+               return STTD_ERROR_OPERATION_FAILED;
+       }
+
+       int ret = stt_engine_set_recording_data(engine->engine_id, data, length);
+       if (0 != ret) {
+               SLOG(LOG_WARN, TAG_STTD, "[Engine Agent WARNING] set recording error(%d)", ret); 
+               return STTD_ERROR_OPERATION_FAILED;
+       }
 
        return 0;
 }
 
-int sttd_engine_setting_set_punctuation_override(bool value)
+int sttd_engine_agent_recognize_stop_recorder(int uid)
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       if (false == g_cur_engine.is_loaded) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); 
-               return STTD_ERROR_OPERATION_FAILED;
+       sttengine_info_s* engine = NULL;
+       engine = __engine_agent_get_engine_by_uid(uid);
+
+       if (NULL == engine) {
+               SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] The engine of uid(%d) is not valid", uid);
+               return STTD_ERROR_INVALID_PARAMETER;
        }
 
-       if (NULL == g_cur_engine.pefuncs->set_punctuation) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] The function of engine is NULL!!");
+       if (false == engine->is_loaded) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); 
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       int ret = g_cur_engine.pefuncs->set_punctuation(value);
+       SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Stop recorder");
+       int ret;
+       ret = sttd_recorder_stop(engine->engine_id);
        if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail set punctuation override : result(%d)", ret); 
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to stop recorder : result(%d)", ret); 
                return STTD_ERROR_OPERATION_FAILED;
        }
-       g_default_punctuation_override = value;
 
-       ret = sttd_config_set_default_punctuation_override((int)value);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to set punctuation override (%d)", ret); 
-       }
+#ifdef AUDIO_CREATE_ON_START
+       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Destroy recorder");
+       if (0 != sttd_recorder_destroy(engine->engine_id))
+               SECURE_SLOG(LOG_WARN, TAG_STTD, "[Engine Agent] Fail to destroy recorder(%d)", engine->engine_id);
+#endif
 
+       SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent Success] Stop recorder");
        return 0;
 }
 
-int sttd_engine_setting_get_silence_detection(bool* value)
+int sttd_engine_agent_recognize_stop_engine(int uid)
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       if (false == g_cur_engine.is_loaded) {
+       sttengine_info_s* engine = NULL;
+       engine = __engine_agent_get_engine_by_uid(uid);
+
+       if (NULL == engine) {
+               SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] The engine of uid(%d) is not valid", uid);
+               return STTD_ERROR_INVALID_PARAMETER;
+       }
+
+       if (false == engine->is_loaded) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); 
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       if (NULL == value) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter"); 
-               return STTD_ERROR_INVALID_PARAMETER;
+       SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Stop engine");
+
+       int ret;
+       ret = stt_engine_recognize_stop(engine->engine_id);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] stop recognition error(%d)", ret); 
+               return STTD_ERROR_OPERATION_FAILED;
        }
 
-       *value = g_default_silence_detected;
+       SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent Success] Stop engine");
 
        return 0;
 }
 
-int sttd_engine_setting_set_silence_detection(bool value)
+int sttd_engine_agent_recognize_cancel(int uid)
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       if (false == g_cur_engine.is_loaded) {
+       sttengine_info_s* engine = NULL;
+       engine = __engine_agent_get_engine_by_uid(uid);
+
+       if (NULL == engine) {
+               SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] The engine of uid(%d) is not valid", uid);
+               return STTD_ERROR_INVALID_PARAMETER;
+       }
+
+       if (false == engine->is_loaded) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); 
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       int ret = g_cur_engine.pefuncs->set_silence_detection(value);
+       SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Cancel engine");
+
+       int ret;
+       ret = stt_engine_recognize_cancel(engine->engine_id);
        if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail set silence detection : result(%d)", ret); 
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] cancel recognition error(%d)", ret); 
                return STTD_ERROR_OPERATION_FAILED;
        }
-       
-       g_default_silence_detected = value;
 
-       ret = sttd_config_set_default_silence_detection((int)value);
+       SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Stop recorder");
+
+       ret = sttd_recorder_stop(engine->engine_id);
        if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to set silence detection (%d)", ret); 
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to stop recorder : result(%d)", ret); 
+               return STTD_ERROR_OPERATION_FAILED;
        }
-       
+
+#ifdef AUDIO_CREATE_ON_START
+       SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Destroy recorder");
+       if (0 != sttd_recorder_destroy(engine->engine_id))
+               SECURE_SLOG(LOG_WARN, TAG_STTD, "[Engine Agent] Fail to destroy recorder(%d)", engine->engine_id);
+#endif
+
+       g_recording_engine_id = -1;
+
+       SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent Success] Cancel recognition");
+
        return 0;
 }
 
-bool __engine_setting_cb(const char* key, const char* value, void* user_data)
+
+/*
+* STT Engine Interfaces for configure
+*/
+
+int sttd_engine_agent_set_default_engine(const char* engine_uuid)
 {
-       GList** engine_setting_list = (GList**)user_data;
+       if (false == g_agent_init) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
+               return STTD_ERROR_OPERATION_FAILED;
+       }
+
+       if (NULL == engine_uuid) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter"); 
+               return STTD_ERROR_INVALID_PARAMETER;
+       }
+
+       __log_enginelist();
 
-       if (NULL == engine_setting_list || NULL == key || NULL == value) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Input parameter is NULL in engine setting callback!!!!");
-               return false;
+       sttengine_info_s* engine;
+       engine = __engine_agent_get_engine_by_uuid(engine_uuid);
+       if (NULL == engine) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Default engine is not valid");
+               return STTD_ERROR_ENGINE_NOT_FOUND;
        }
 
-       engine_setting_s* temp = g_malloc0(sizeof(engine_setting_s));
-       temp->key = g_strdup(key);
-       temp->value = g_strdup(value);
+       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Default engine id(%d) engine uuid(%s)", engine->engine_id, engine->engine_uuid);
+
+       g_default_engine_id = engine->engine_id;
+
+       /* Update default engine of client */
+       GSList *iter = NULL;
+       sttengine_client_s *data = NULL;
+
+       if (0 < g_slist_length(g_engine_client_list)) {
+               iter = g_slist_nth(g_engine_client_list, 0);
+
+               while (NULL != iter) {
+                       /* Get handle data from list */
+                       data = iter->data;
+
+                       if (true == data->use_default_engine) {
+                               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] uid(%d) change engine from id(%d) to id(%d)", 
+                                       data->uid, data->engine_id, engine->engine_id);
+
+                               if (0 != sttd_engine_agent_load_current_engine(data->uid, NULL)) {
+                                       SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to load current engine : uid(%d)", data->uid);
+                               }
+                       }
 
-       *engine_setting_list = g_list_append(*engine_setting_list, temp);
+                       iter = g_slist_next(iter);
+               }
+       }
 
-       return true;
+       return 0;
 }
 
-int sttd_engine_setting_get_engine_setting_info(char** engine_id, GList** setting_list)
+int sttd_engine_agent_set_default_language(const char* language)
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       if (false == g_cur_engine.is_loaded) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); 
-               return STTD_ERROR_OPERATION_FAILED;
-       }
-
-       if (NULL == setting_list) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Input parameter is NULL");
+       if (NULL == language) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter"); 
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
-       if (NULL == g_cur_engine.pefuncs->foreach_engine_settings) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] foreach_engine_settings() of engine is NULL!!");
-               return STTD_ERROR_OPERATION_FAILED;
-       }
+       if (NULL != g_default_language)
+               free(g_default_language);
 
-       /* get setting info and move setting info to input parameter */
-       int result = 0;
+       g_default_language = strdup(language);
 
-       result = g_cur_engine.pefuncs->foreach_engine_settings(__engine_setting_cb, setting_list);
+       return 0;
+}
 
-       if (0 == result && 0 < g_list_length(*setting_list)) {
-               *engine_id = strdup(g_cur_engine.engine_uuid);
-       } else {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] fail to get setting info : result(%d)\n", result);
-               result = STTD_ERROR_OPERATION_FAILED;
+int sttd_engine_agent_set_silence_detection(bool value)
+{
+       if (false == g_agent_init) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
+               return STTD_ERROR_OPERATION_FAILED;
        }
 
-       return result;
+       g_default_silence_detected = value;
+
+       return 0;
 }
 
-int sttd_engine_setting_set_engine_setting(const char* key, const char* value)
+int sttd_engine_agent_check_app_agreed(int uid, const char* appid, bool* result)
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       if (false == g_cur_engine.is_loaded) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); 
-               return STTD_ERROR_OPERATION_FAILED;
-       }
+       sttengine_info_s* engine = NULL;
+       engine = __engine_agent_get_engine_by_uid(uid);
 
-       if (NULL == key || NULL == value) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter"); 
+       if (NULL == engine) {
+               SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] The engine of uid(%d) is not valid", uid);
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
-       if (NULL == g_cur_engine.pefuncs->set_engine_setting) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] set_engine_setting() of engine is NULL!!");
+       if (false == engine->is_loaded) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); 
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       /* get setting info and move setting info to input parameter */
-       int ret = g_cur_engine.pefuncs->set_engine_setting(key, value);
+       int ret;
+       ret = stt_engine_check_app_agreed(engine->engine_id, appid, result);
        if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail set setting info (%d) ", ret); 
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] cancel recognition error(%d)", ret); 
                return STTD_ERROR_OPERATION_FAILED;
        }
 
+       
+       SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Get engine right : %s", *result ? "true" : "false");
        return 0;
 }
 
@@ -1798,89 +1466,69 @@ int sttd_engine_setting_set_engine_setting(const char* key, const char* value)
 * STT Engine Callback Functions                                                                                        `                                 *
 */
 
-void __result_cb(sttp_result_event_e event, const char* type, 
-                                       const char** data, int data_count, const char* msg, void *user_data)
+void __result_cb(sttp_result_event_e event, const char* type, const char** data, int data_count, 
+                const char* msg, void* time_info, void *user_data)
 {
        if (false == g_agent_init) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Result Callback : Not Initialized"); 
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Result Callback : Not Initialized");
                return;
        }
 
-       if (false == g_cur_engine.is_loaded) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Result Callback : Not loaded engine"); 
-               return;
+       SLOG(LOG_DEBUG, TAG_STTD, "[Server] === Result time callback ===");
+
+       if (NULL != time_info) {
+               /* Get the time info */
+               int ret = stt_engine_foreach_result_time(g_recording_engine_id, time_info, __result_time_cb, NULL);
+               if (0 != ret) {
+                       SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to get time info : %d", ret);
+               }
        }
 
-       return g_result_cb(event, type, data, data_count, msg, user_data);
-}
+       SLOG(LOG_DEBUG, TAG_STTD, "[Server] ============================");
 
-void __partial_result_cb(sttp_result_event_e event, const char* data, void *user_data)
-{
-       if (false == g_agent_init) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Partial Result Callback : Not Initialized"); 
-               return;
+       g_result_cb(event, type, data, data_count, msg, user_data);
+
+#ifdef AUDIO_CREATE_ON_START
+       if (event == STTP_RESULT_EVENT_ERROR) {
+               SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Destroy recorder");
+               if (0 != sttd_recorder_destroy(g_recording_engine_id))
+                       SECURE_SLOG(LOG_WARN, TAG_STTD, "[Engine Agent] Fail to destroy recorder(%d)", g_recording_engine_id);
        }
+#endif
 
-       if (false == g_cur_engine.is_loaded) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Partial Result Callback : Not loaded engine"); 
-               return;
+       if (event == STTP_RESULT_EVENT_FINAL_RESULT || event == STTP_RESULT_EVENT_ERROR) {
+               g_recording_engine_id = -1;
        }
 
-       return g_partial_result_cb(event, data, user_data);
+       return;
+}
+
+bool __result_time_cb(int index, sttp_result_time_event_e event, const char* text, long start_time, long end_time, void* user_data)
+{
+       return g_result_time_cb(index, event, text, start_time, end_time, user_data);
 }
 
-void __detect_silence_cb(void* user_data)
+void __detect_silence_cb(sttp_silence_type_e type, void* user_data)
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Silence Callback : Not Initialized"); 
                return;
        }
 
-       if (false == g_cur_engine.is_loaded) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Silence Callback : Not loaded engine"); 
-               return;
-       }
-
-       if (true == g_cur_engine.silence_detection) {
-               g_silence_cb(user_data);
-       } else {
-               SLOG(LOG_WARN, TAG_STTD, "[Engine Agent] Silence detection callback is blocked because option value is false.");
-       }
-}
-
-void __free_language_list(GList* lang_list)
-{
-       GList *iter = NULL;
-       char* data = NULL;
-
-       /* if list have item */
-       if (g_list_length(lang_list) > 0) {
-               /* Get a first item */
-               iter = g_list_first(lang_list);
-
-               while (NULL != iter) {
-                       data = iter->data;
-
-                       if (NULL != data)
-                               g_free(data);
-                       
-                       lang_list = g_list_remove_link(lang_list, iter);
-
-                       iter = g_list_first(lang_list);
-               }
-       }
+       g_silence_cb(type, user_data);
+       return;
 }
 
 /* A function forging */
 int __log_enginelist()
 {
-       GList *iter = NULL;
+       GSList *iter = NULL;
        sttengine_info_s *data = NULL;
 
-       if (0 < g_list_length(g_engine_list)) {
+       if (0 < g_slist_length(g_engine_list)) {
 
                /* Get a first item */
-               iter = g_list_first(g_engine_list);
+               iter = g_slist_nth(g_engine_list, 0);
 
                SLOG(LOG_DEBUG, TAG_STTD, "--------------- engine list -------------------");
 
@@ -1889,13 +1537,16 @@ int __log_enginelist()
                        /* Get handle data from list */
                        data = iter->data;
 
-                       SLOG(LOG_DEBUG, TAG_STTD, "[%dth]", i);
-                       SLOG(LOG_DEBUG, TAG_STTD, "  engine uuid : %s", data->engine_uuid);
-                       SLOG(LOG_DEBUG, TAG_STTD, "  engine name : %s", data->engine_name);
-                       SLOG(LOG_DEBUG, TAG_STTD, "  engine path : %s", data->engine_path);
-                       SLOG(LOG_DEBUG, TAG_STTD, "  setting ug path : %s", data->setting_ug_path);
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[%dth]", i);
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "  engine uuid : %s", data->engine_uuid);
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "  engine name : %s", data->engine_name);
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "  engine path : %s", data->engine_path);
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "  use network : %s", data->use_network ? "true" : "false");
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "  is loaded : %s", data->is_loaded ? "true" : "false");
+                       if (NULL != data->first_lang)
+                               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "  default lang : %s", data->first_lang);
 
-                       iter = g_list_next(iter);
+                       iter = g_slist_next(iter);
                        i++;
                }
                SLOG(LOG_DEBUG, TAG_STTD, "----------------------------------------------");
@@ -1906,7 +1557,4 @@ int __log_enginelist()
        }
 
        return 0;
-}
-
-
-
+}
\ No newline at end of file
index e807c37..dc2ebf2 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
@@ -32,9 +32,10 @@ extern "C" {
 typedef void (*result_callback)(sttp_result_event_e event, const char* type, 
                                const char** data, int data_count, const char* msg, void *user_data);
 
-typedef void (*partial_result_callback)(sttp_result_event_e event, const char* data, void *user_data);
+typedef bool (*result_time_callback)(int index, sttp_result_time_event_e event, const char* text, 
+                               long start_time, long end_time, void *user_data);
 
-typedef void (*silence_dectection_callback)(void *user_data);
+typedef void (*silence_dectection_callback)(sttp_silence_type_e type, void *user_data);
 
 
 
@@ -42,84 +43,63 @@ typedef void (*silence_dectection_callback)(void *user_data);
 * STT Engine Agent Interfaces
 */
 
-/** Init engine agent */
-int sttd_engine_agent_init(result_callback result_cb, partial_result_callback partial_result_cb, silence_dectection_callback silence_cb);
+/** Init / Release engine agent */
+int sttd_engine_agent_init(result_callback result_cb, result_time_callback time_cb, 
+                          silence_dectection_callback silence_cb);
 
-/** Release engine agent */
 int sttd_engine_agent_release();
 
-/** Set current engine */
-int sttd_engine_agent_initialize_current_engine();
 
-/** load current engine */
-int sttd_engine_agent_load_current_engine();
+/** Manage engine */
+int sttd_engine_agent_initialize_engine_list();
 
-/** Unload current engine */
-int sttd_engine_agent_unload_current_engine();
 
-/** test for language list */
-int sttd_print_enginelist();
+/** load / unload engine */
+int sttd_engine_agent_load_current_engine(int uid, const char* engine_uuid);
 
-/** Get state of current engine to need network */
-bool sttd_engine_agent_need_network();
+int sttd_engine_agent_unload_current_engine(int uid);
 
-int sttd_engine_get_option_supported(bool* silence, bool* profanity, bool* punctuation);
+bool sttd_engine_agent_is_default_engine();
 
-/*
-* STT Engine Interfaces for client
-*/
-
-int sttd_engine_supported_langs(GList** lang_list);
-
-int sttd_engine_get_default_lang(char** lang);
-
-int sttd_engine_recognize_start(const char* lang, const char* recognition_type, 
-                               int profanity, int punctuation, int silence, void* user_param);
+int sttd_engine_agent_get_engine_list(GSList** engine_list);
 
-int sttd_engine_recognize_audio(const void* data, unsigned int length);
+int sttd_engine_agent_get_current_engine(int uid, char** engine_uuid);
 
-int sttd_engine_is_partial_result_supported(bool* partial_result);
 
-int sttd_engine_recognize_stop();
+/** Get/Set app option */
+bool sttd_engine_agent_need_network(int uid);
 
-int sttd_engine_recognize_cancel();
-
-int sttd_engine_get_audio_format(sttp_audio_type_e* types, int* rate, int* channels);
-
-int sttd_engine_recognize_start_file(const char* filepath, const char* lang, const char* recognition_type, 
-                                    int profanity, int punctuation, void* user_param);
-
-/*
-* STT Engine Interfaces for setting
-*/
+int sttd_engine_agent_supported_langs(int uid, GSList** lang_list);
 
-int sttd_engine_setting_get_engine_list(GList** engine_list);
+int sttd_engine_agent_get_default_lang(int uid, char** lang);
 
-int sttd_engine_setting_get_engine(char** engine_id);
+int sttd_engine_agent_get_option_supported(int uid, bool* silence);
 
-int sttd_engine_setting_set_engine(const char* engine_id);
+int sttd_engine_agent_is_recognition_type_supported(int uid, const char* type, bool* support);
 
-int sttd_engine_setting_get_lang_list(char** engine_id, GList** lang_list);
+int sttd_engine_agent_set_default_engine(const char* engine_uuid);
 
-int sttd_engine_setting_get_default_lang(char** language);
+int sttd_engine_agent_set_default_language(const char* language);
 
-int sttd_engine_setting_set_default_lang(const char* language);
+int sttd_engine_agent_set_silence_detection(bool value);
 
-int sttd_engine_setting_get_profanity_filter(bool* value);
+int sttd_engine_agent_check_app_agreed(int uid, const char* appid, bool* result);
 
-int sttd_engine_setting_set_profanity_filter(bool value);
+/** Control engine */
+int sttd_engine_agent_recognize_start_engine(int uid, const char* lang, const char* recognition_type, 
+                               int silence, void* user_param);
 
-int sttd_engine_setting_get_punctuation_override(bool* value);
+int sttd_engine_agent_recognize_start_recorder(int uid);
 
-int sttd_engine_setting_set_punctuation_override(bool value);
+int sttd_engine_agent_set_recording_data(int uid, const void* data, unsigned int length);
 
-int sttd_engine_setting_get_silence_detection(bool* value);
+int sttd_engine_agent_recognize_stop(int uid);
 
-int sttd_engine_setting_set_silence_detection(bool value);
+int sttd_engine_agent_recognize_stop_recorder(int uid);
 
-int sttd_engine_setting_get_engine_setting_info(char** engine_id, GList** setting_list); 
+int sttd_engine_agent_recognize_stop_engine(int uid);
 
-int sttd_engine_setting_set_engine_setting(const char* key, const char* value);
+int sttd_engine_agent_recognize_cancel(int uid);
 
 
 #ifdef __cplusplus
index 2d32af7..0a5baf1 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 "stt_defs.h"
+#include "stt_network.h"
+#include "sttd_dbus.h"
 #include "sttd_main.h"
 #include "sttd_server.h"
-#include "sttd_network.h"
-#include "sttd_dbus.h"
 
-#include <Ecore.h>
-#include "sttd_server.h"
 
 #define CLIENT_CLEAN_UP_TIME 500
 
+static Ecore_Timer* g_check_client_timer = NULL;
+
+static int __save_stt_daemon_info()
+{
+       FILE* fp;
+       int pid = getpid();
+       fp = fopen(STT_PID_FILE_PATH, "w");
+       if (NULL == fp) {
+               SLOG(LOG_ERROR, TAG_STTD, "[ERROR] Fail to make pid file");
+               return -1;
+       }
+       fprintf(fp, "%d", pid);
+       fclose(fp);
+       return 0;
+}
+
+static int __delete_stt_daemon_info()
+{
+       if (0 == access(STT_PID_FILE_PATH, R_OK)) {
+               if (0 != remove(STT_PID_FILE_PATH)) {
+                       SLOG(LOG_WARN, TAG_STTD, "[WARN] Fail to remove pid file");
+                       return -1;
+               }
+       }
+       return 0;
+}
+
 int main(int argc, char** argv)
 {
        SLOG(LOG_DEBUG, TAG_STTD, "  ");
        SLOG(LOG_DEBUG, TAG_STTD, "  ");
        SLOG(LOG_DEBUG, TAG_STTD, "===== STT Daemon Initialize");
 
-       if (0 != sttd_initialize()) {
-               SLOG(LOG_ERROR, TAG_STTD, "[ERROR] Fail to initialize stt-daemon"); 
+       if (!ecore_init()) {
+               SLOG(LOG_ERROR, TAG_STTD, "[ERROR] Fail to initialize Ecore"); 
                return EXIT_FAILURE;
        }
 
@@ -38,11 +65,19 @@ int main(int argc, char** argv)
                return EXIT_FAILURE;
        }
 
-       sttd_network_initialize();
+       if (0 != sttd_initialize()) {
+               SLOG(LOG_ERROR, TAG_STTD, "[ERROR] Fail to initialize stt-daemon");
+               return EXIT_FAILURE;
+       }
+
+       __save_stt_daemon_info();
 
-       ecore_timer_add(CLIENT_CLEAN_UP_TIME, sttd_cleanup_client, NULL);
+       stt_network_initialize();
 
-       printf("stt-daemon start...\n");
+       g_check_client_timer = ecore_timer_add(CLIENT_CLEAN_UP_TIME, sttd_cleanup_client, NULL);
+       if (NULL == g_check_client_timer) {
+               SLOG(LOG_WARN, TAG_STTD, "[Main Warning] Fail to create timer of client check");
+       }
 
        SLOG(LOG_DEBUG, TAG_STTD, "[Main] stt-daemon start..."); 
 
@@ -54,9 +89,15 @@ int main(int argc, char** argv)
 
        SLOG(LOG_DEBUG, TAG_STTD, "===== STT Daemon Finalize");
 
+       if (NULL != g_check_client_timer) {
+               ecore_timer_del(g_check_client_timer);
+       }
+
        sttd_dbus_close_connection();
 
-       sttd_network_finalize();
+       __delete_stt_daemon_info();
+
+       stt_network_finalize();
 
        sttd_finalize();
 
index 0ce3bd9..5747b48 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
 #ifndef __STTD_MAIN_H_
 #define __STTD_MAIN_H_
 
+#include <dlog.h>
+#include <errno.h>
+#include <glib.h>
 #include <stdio.h>
-#include <stdbool.h>
 #include <stdlib.h>
 #include <string.h>
+#include <tizen.h>
 #include <unistd.h>
-#include <glib.h>
-#include <dlog.h>
-#include <errno.h>
 
-/* For multi-user support */
-#include <tzplatform_config.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -37,44 +35,42 @@ extern "C" {
 
 #define TAG_STTD "sttd"
 
-#define BASE_DIRECTORY_DEFAULT                 "/usr/lib/voice/stt/1.0/"
-#define ENGINE_DIRECTORY_DEFAULT               "/usr/lib/voice/stt/1.0/engine"
-#define ENGINE_DIRECTORY_DEFAULT_SETTING       "/usr/lib/voice/stt/1.0/setting"
-
-#define CONFIG_DIRECTORY                       tzplatform_mkpath(TZ_USER_HOME, ".voice")
-
-#define ENGINE_DIRECTORY_DOWNLOAD              tzplatform_mkpath(TZ_USER_HOME, ".voice/stt/1.0/engine")
-#define ENGINE_DIRECTORY_DOWNLOAD_SETTING      tzplatform_mkpath(TZ_USER_HOME, ".voice/stt/1.0/setting")
-
 /* for debug message */
-#define RECORDER_DEBUG
-#define CLIENT_DATA_DEBUG
+//#define CLIENT_DATA_DEBUG
 
 typedef enum {
-       STTD_ERROR_NONE                 = 0,                    /**< Successful */
-       STTD_ERROR_OUT_OF_MEMORY        = -ENOMEM,              /**< Out of Memory */
-       STTD_ERROR_IO_ERROR             = -EIO,                 /**< I/O error */
-       STTD_ERROR_INVALID_PARAMETER    = -EINVAL,              /**< Invalid parameter */
-       STTD_ERROR_TIMED_OUT            = -ETIMEDOUT,           /**< No answer from the daemon */
-       STTD_ERROR_RECORDER_BUSY        = -EBUSY,               /**< Busy recorder */
-       STTD_ERROR_OUT_OF_NETWORK       = -ENETDOWN,            /**< Out of network */
-       STTD_ERROR_INVALID_STATE        = -0x0100000 | 0x31,    /**< Invalid state */
-       STTD_ERROR_INVALID_LANGUAGE     = -0x0100000 | 0x32,    /**< Invalid language */
-       STTD_ERROR_ENGINE_NOT_FOUND     = -0x0100000 | 0x33,    /**< No available engine  */    
-       STTD_ERROR_OPERATION_FAILED     = -0x0100000 | 0x34,    /**< Operation failed  */
-       STTD_ERROR_NOT_SUPPORTED_FEATURE= -0x0100000 | 0x35     /**< Not supported feature of current engine */
+       STTD_ERROR_NONE                 = TIZEN_ERROR_NONE,             /**< Successful */
+       STTD_ERROR_OUT_OF_MEMORY        = TIZEN_ERROR_OUT_OF_MEMORY,    /**< Out of Memory */
+       STTD_ERROR_IO_ERROR             = TIZEN_ERROR_IO_ERROR,         /**< I/O error */
+       STTD_ERROR_INVALID_PARAMETER    = TIZEN_ERROR_INVALID_PARAMETER,/**< Invalid parameter */
+       STTD_ERROR_TIMED_OUT            = TIZEN_ERROR_TIMED_OUT,        /**< No answer from the daemon */
+       STTD_ERROR_RECORDER_BUSY        = TIZEN_ERROR_RESOURCE_BUSY,    /**< Device or resource busy */
+       STTD_ERROR_OUT_OF_NETWORK       = TIZEN_ERROR_NETWORK_DOWN,     /**< Network is down */
+       STTD_ERROR_PERMISSION_DENIED    = TIZEN_ERROR_PERMISSION_DENIED,/**< Permission denied */
+       STTD_ERROR_NOT_SUPPORTED        = TIZEN_ERROR_NOT_SUPPORTED,    /**< STT NOT supported */
+       STTD_ERROR_INVALID_STATE        = TIZEN_ERROR_STT | 0x01,       /**< Invalid state */
+       STTD_ERROR_INVALID_LANGUAGE     = TIZEN_ERROR_STT | 0x02,       /**< Invalid language */
+       STTD_ERROR_ENGINE_NOT_FOUND     = TIZEN_ERROR_STT | 0x03,       /**< No available engine  */    
+       STTD_ERROR_OPERATION_FAILED     = TIZEN_ERROR_STT | 0x04,       /**< Operation failed  */
+       STTD_ERROR_NOT_SUPPORTED_FEATURE= TIZEN_ERROR_STT | 0x05        /**< Not supported feature of current engine */
 }stt_error_e;
 
+typedef enum {
+       STTD_RESULT_STATE_DONE          = 0,                    /**< Sync state change */
+       STTD_RESULT_STATE_NOT_DONE      = 1                     /**< Async state change */
+}sttd_result_state_e;
+
 typedef struct {
        char* engine_id;
        char* engine_name;
        char* ug_name;
 }engine_s;
 
-typedef struct {
-       char* key;
-       char* value;
-}engine_setting_s;
+typedef enum {
+       STTD_DAEMON_NORMAL              = 0,
+       STTD_DAEMON_ON_TERMINATING      = -1
+} sttd_daemon_status_e;
+
 
 #ifdef __cplusplus
 }
diff --git a/server/sttd_network.c b/server/sttd_network.c
deleted file mode 100644 (file)
index 3621ba3..0000000
+++ /dev/null
@@ -1,91 +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 "sttd_main.h"
-#include "sttd_network.h"
-
-#include <vconf.h>
-
-static bool g_is_connected;
-
-bool sttd_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);
-
-       if (network_configuration == 0) {
-               SLOG(LOG_DEBUG, TAG_STTD, "[Network DEBUG] Change Network Connection is OFF ");
-               g_is_connected = false;
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTD, "[Network DEBUG] Change Network Connection is ON ");
-               g_is_connected = true;
-               
-               /* need to notify changing net to engine. */
-       }
-
-       return;
-}
-
-int sttd_network_initialize()
-{
-       int network_configuration = 0;
-       vconf_get_int(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND , &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){
-                       printf("Current network connection is OFF!! \n");
-                       SLOG(LOG_DEBUG, TAG_STTD, "[Network DEBUG] 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.
-                       */
-                       printf("network status is wrong or IP is not set\n");
-                       printf("network has problem, try again\n");
-                       exit(0);
-               }
-
-               g_is_connected = false;
-       } else {
-               printf("Current network connection is ON. \n");
-               SLOG(LOG_DEBUG, TAG_STTD, "[Network DEBUG] Current network connection is ON.");
-                       
-               g_is_connected = true;
-       }
-
-       vconf_notify_key_changed(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, __net_config_change_cb, NULL);
-       
-       return 0;
-}
-
-int sttd_network_finalize()
-{
-       vconf_ignore_key_changed(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, __net_config_change_cb);
-
-       return 0;
-}
-
index 6e0e340..6db1ed0 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 <audio_io.h> 
+#include <audio_io.h>
 #include <Ecore.h>
 #include <math.h>
+#include <sound_manager.h>
+
+#include "stt_defs.h"
 #include "sttd_recorder.h"
 #include "sttd_main.h"
-#include "stt_defs.h"
+#include "sttp.h"
 
 
 #define FRAME_LENGTH 160
 #define BUFFER_LENGTH FRAME_LENGTH * 2
 
-static stt_recorder_audio_cb   g_audio_cb;
-static audio_in_h              g_audio_in_h;
+typedef enum {
+       STTD_RECORDER_STATE_NONE = -1,
+       STTD_RECORDER_STATE_READY = 0,  /**< Recorder is ready to start */
+       STTD_RECORDER_STATE_RECORDING   /**< In the middle of recording */
+} sttd_recorder_state;
 
-static sttd_recorder_state     g_recorder_state = -1;
+typedef struct {
+       int                     engine_id;
+       audio_in_h              audio_h;
+       sttp_audio_type_e       audio_type;
+}stt_recorder_s;
+
+static GSList *g_recorder_list;
+
+static int g_recording_engine_id;
+
+static stt_recorder_audio_cb   g_audio_cb;
 
-static sttp_audio_type_e       g_audio_type;
+static stt_recorder_interrupt_cb       g_interrupt_cb;
 
-static char g_buffer[BUFFER_LENGTH];
+static sttd_recorder_state     g_recorder_state = STTD_RECORDER_STATE_NONE;
 
 static FILE* g_pFile_vol;
 
-static char g_temp_vol[64];
+static int g_buffer_count;
 
-/* Sound buf save */
+/* Sound buf save for test */
 /*
 #define BUF_SAVE_MODE
 */
-
 #ifdef BUF_SAVE_MODE
 static char g_temp_file_name[128] = {'\0',};
 
@@ -48,15 +63,141 @@ static FILE* g_pFile;
 static int g_count = 1;
 #endif 
 
-int sttd_recorder_create(stt_recorder_audio_cb callback, sttp_audio_type_e type, int channel, unsigned int sample_rate)
+const char* __stt_get_session_interrupt_code(sound_session_interrupted_code_e code)
 {
-       if (NULL == callback) {
+       switch(code) {
+       case SOUND_SESSION_INTERRUPTED_COMPLETED:               return "SOUND_SESSION_INTERRUPTED_COMPLETED";
+       case SOUND_SESSION_INTERRUPTED_BY_MEDIA:                return "SOUND_SESSION_INTERRUPTED_BY_MEDIA";
+       case SOUND_SESSION_INTERRUPTED_BY_CALL:                 return "SOUND_SESSION_INTERRUPTED_BY_CALL";
+       case SOUND_SESSION_INTERRUPTED_BY_EARJACK_UNPLUG:       return "SOUND_SESSION_INTERRUPTED_BY_EARJACK_UNPLUG";
+       case SOUND_SESSION_INTERRUPTED_BY_RESOURCE_CONFLICT:    return "SOUND_SESSION_INTERRUPTED_BY_RESOURCE_CONFLICT";
+       case SOUND_SESSION_INTERRUPTED_BY_ALARM:                return "SOUND_SESSION_INTERRUPTED_BY_ALARM";
+       case SOUND_SESSION_INTERRUPTED_BY_EMERGENCY:            return "SOUND_SESSION_INTERRUPTED_BY_EMERGENCY";
+       case SOUND_SESSION_INTERRUPTED_BY_NOTIFICATION:         return "SOUND_SESSION_INTERRUPTED_BY_NOTIFICATION";
+       default:
+               return "Undefined error code";
+       }
+}
+
+void __sttd_recorder_sound_interrupted_cb(sound_session_interrupted_code_e code, void *user_data)
+{
+       SLOG(LOG_DEBUG, TAG_STTD, "[Recorder] Get the interrupt code from sound mgr : %s", 
+               __stt_get_session_interrupt_code(code));
+
+       if (SOUND_SESSION_INTERRUPTED_COMPLETED == code || SOUND_SESSION_INTERRUPTED_BY_EARJACK_UNPLUG == code)
+               return;
+
+       if (NULL != g_interrupt_cb) {
+               g_interrupt_cb();
+       }
+       return;
+}
+
+int sttd_recorder_initialize(stt_recorder_audio_cb audio_cb, stt_recorder_interrupt_cb interrupt_cb)
+{
+       if (NULL == audio_cb || NULL == interrupt_cb) {
                SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Input param is NOT valid");
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
+       if (STTD_RECORDER_STATE_NONE != g_recorder_state) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Current state of recorder is recording");
+               return STTD_ERROR_INVALID_STATE;
+       }
+       
+       g_audio_cb = audio_cb;
+       g_interrupt_cb = interrupt_cb;
+       g_recorder_state = STTD_RECORDER_STATE_NONE;
+       g_recording_engine_id = -1;
+
+       if (0 != sound_manager_set_session_type(SOUND_SESSION_TYPE_MEDIA)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to set exclusive session");
+       }
+
+       if (0 != sound_manager_set_session_interrupted_cb(__sttd_recorder_sound_interrupted_cb, NULL)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to set sound interrupt callback");
+       }
+
+       return 0;
+}
+
+int sttd_recorder_deinitialize()
+{
+       if (0 != sound_manager_unset_session_interrupted_cb()) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to unset sound interrupt callback");
+       }
+
+       /* Remove all recorder */
+       GSList *iter = NULL;
+       stt_recorder_s *recorder = NULL;
+
+       iter = g_slist_nth(g_recorder_list, 0);
+
+       while (NULL != iter) {
+               recorder = iter->data;
+
+               if (NULL != recorder) {
+                       g_recorder_list = g_slist_remove(g_recorder_list, recorder);
+                       audio_in_destroy(recorder->audio_h);
+
+                       free(recorder);
+               }
+
+               iter = g_slist_nth(g_recorder_list, 0);
+       }
+
+       if (0 == access(STT_AUDIO_VOLUME_PATH, R_OK)) {
+               if (0 != remove(STT_AUDIO_VOLUME_PATH)) {
+                       SLOG(LOG_WARN, TAG_STTD, "[Recorder WARN] Fail to remove volume file"); 
+               }
+       }
+
+       g_recorder_state = STTD_RECORDER_STATE_NONE;
+
+       return 0;
+}
+
+static stt_recorder_s* __get_recorder(int engine_id)
+{
+       GSList *iter = NULL;
+       stt_recorder_s *recorder = NULL;
+
+       iter = g_slist_nth(g_recorder_list, 0);
+
+       while (NULL != iter) {
+               recorder = iter->data;
+
+               if (recorder->engine_id == engine_id) {
+                       return recorder;
+               }
+
+               iter = g_slist_next(iter);
+       }
+
+       return NULL;
+}
+
+int sttd_recorder_set_audio_session()
+{
+       return 0;
+}
+
+int sttd_recorder_unset_audio_session()
+{
+       return 0;
+}
+
+int sttd_recorder_create(int engine_id, sttp_audio_type_e type, int channel, unsigned int sample_rate)
+{
+       /* Check engine id is valid */
+       if (NULL != __get_recorder(engine_id)) {
+               SLOG(LOG_WARN, TAG_STTD, "[Recorder WARNING] Engine id is already registered");
+               return STTD_ERROR_INVALID_PARAMETER;
+       }
+
        audio_channel_e audio_ch;
        audio_sample_type_e audio_type;
+       audio_in_h temp_in_h;
 
        switch(channel) {
                case 1: audio_ch = AUDIO_CHANNEL_MONO;          break;
@@ -77,42 +218,54 @@ int sttd_recorder_create(stt_recorder_audio_cb callback, sttp_audio_type_e type,
        }
 
        int ret;
-       ret = audio_in_create(sample_rate, audio_ch, audio_type, &g_audio_in_h);
+       ret = audio_in_create(sample_rate, audio_ch, audio_type, &temp_in_h);
        if (AUDIO_IO_ERROR_NONE != ret) {
                SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to create audio handle : %d", ret);
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       g_audio_cb = callback;
+       stt_recorder_s* recorder;
+       recorder = (stt_recorder_s*)calloc(1, sizeof(stt_recorder_s));
+
+       recorder->engine_id = engine_id;
+       recorder->audio_h = temp_in_h;
+       recorder->audio_type = type;
+       
+       g_recorder_list = g_slist_append(g_recorder_list, recorder);
+
        g_recorder_state = STTD_RECORDER_STATE_READY;
-       g_audio_type = type;
 
        return 0;
 }
 
-int sttd_recorder_destroy()
+int sttd_recorder_destroy(int engine_id)
 {
+       /* Check engine id is valid */
+       stt_recorder_s* recorder;
+       recorder = __get_recorder(engine_id);
+       if (NULL == recorder) {
+               SLOG(LOG_WARN, TAG_STTD, "[Recorder WARNING] Engine id is not valid");
+               return STTD_ERROR_INVALID_PARAMETER;
+       }
+
        int ret;
        if (STTD_RECORDER_STATE_RECORDING == g_recorder_state) {
-               ret = audio_in_unprepare(g_audio_in_h);
+               ret = audio_in_unprepare(recorder->audio_h);
                if (AUDIO_IO_ERROR_NONE != ret) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to unprepare audio_in");
+                       SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to unprepare audioin : %d", ret);
                }
+
+               g_recorder_state = STTD_RECORDER_STATE_READY;
        }
 
-       ret = audio_in_destroy(g_audio_in_h);
+       ret = audio_in_destroy(recorder->audio_h);
        if (AUDIO_IO_ERROR_NONE != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to destroy audio_in");
+               SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to destroy audioin : %d", ret);
        }
 
-       g_audio_cb = NULL;
-       g_recorder_state = -1;
+       g_recorder_list = g_slist_remove(g_recorder_list, recorder);
 
-       if (0 == access(STT_AUDIO_VOLUME_PATH, R_OK)) {
-               if (0 == remove(STT_AUDIO_VOLUME_PATH)) {
-                       SLOG(LOG_WARN, TAG_STTD, "[Recorder WARN] Fail to remove volume file"); 
-               }
-       }
+       free(recorder);
 
        return 0;
 }
@@ -125,9 +278,6 @@ static float get_volume_decibel(char* data, int size, sttp_audio_type_e type)
        int i, depthByte;
        int count = 0;
 
-       short* pcm16 = 0;
-       char* pcm8 = 0;
-
        float db = 0.0;
        float rms = 0.0;
        unsigned long long square_sum = 0;
@@ -139,16 +289,21 @@ static float get_volume_decibel(char* data, int size, sttp_audio_type_e type)
 
        for (i = 0; i < size; i += (depthByte<<1)) {
                if (depthByte == 2) {
-                       pcm16 = (short*)(data + i);
-                       square_sum += (*pcm16) * (*pcm16);
+                       short pcm16 = 0;
+                       memcpy(&pcm16, data + i, sizeof(short));
+                       square_sum += pcm16 * pcm16;
                } else {
-                       pcm8 = (char*)(data +i);
-                       square_sum += (*pcm8) * (*pcm8);
+                       char pcm8 = 0;
+                       memcpy(&pcm8, data + i, sizeof(char));
+                       square_sum += pcm8 * pcm8;
                }
                count++;
        }
 
-       rms = sqrt(square_sum/count);
+       if (0 == count)
+               rms = 0.0;
+       else
+               rms = sqrt(square_sum/count);
 
        if (depthByte == 2)
                db = 20 * log10(rms/MAX_AMPLITUDE_MEAN_16);
@@ -161,13 +316,21 @@ static float get_volume_decibel(char* data, int size, sttp_audio_type_e type)
 Eina_Bool __read_audio_func(void *data)
 {
        int read_byte = -1;
+       static char g_buffer[BUFFER_LENGTH];
+
+       /* Check engine id is valid */
+       stt_recorder_s* recorder;
+       recorder = __get_recorder(g_recording_engine_id);
+       if (NULL == recorder) {
+               return EINA_FALSE;
+       }
 
        if (STTD_RECORDER_STATE_READY == g_recorder_state) {
                SLOG(LOG_DEBUG, TAG_STTD, "[Recorder] Exit audio reading func");
                return EINA_FALSE;
        }
 
-       read_byte = audio_in_read(g_audio_in_h, g_buffer, BUFFER_LENGTH);
+       read_byte = audio_in_read(recorder->audio_h, g_buffer, BUFFER_LENGTH);
        if (0 > read_byte) {
                SLOG(LOG_WARN, TAG_STTD, "[Recorder WARNING] Fail to read audio : %d", read_byte);
                g_recorder_state = STTD_RECORDER_STATE_READY;
@@ -176,15 +339,27 @@ Eina_Bool __read_audio_func(void *data)
 
        if (0 != g_audio_cb(g_buffer, read_byte)) {
                SLOG(LOG_WARN, TAG_STTD, "[Recorder WARNING] Fail audio callback");
-               sttd_recorder_stop();
+               sttd_recorder_stop(g_recording_engine_id);
                return EINA_FALSE;
        }
 
-       float vol_db = get_volume_decibel(g_buffer, BUFFER_LENGTH, g_audio_type);
+       float vol_db = get_volume_decibel(g_buffer, BUFFER_LENGTH, recorder->audio_type);
 
        rewind(g_pFile_vol);
+
        fwrite((void*)(&vol_db), sizeof(vol_db), 1, g_pFile_vol);
 
+       /* Audio read log */
+       if (0 == g_buffer_count % 50) {
+               SLOG(LOG_DEBUG, TAG_STTD, "[Recorder][%d] Recording... : read_size(%d)", g_buffer_count, read_byte);
+               
+               if (100000 == g_buffer_count) {
+                       g_buffer_count = 0;
+               }
+       }
+
+       g_buffer_count++;
+
 #ifdef BUF_SAVE_MODE
        /* write pcm buffer */
        fwrite(g_buffer, 1, BUFFER_LENGTH, g_pFile);
@@ -193,22 +368,31 @@ Eina_Bool __read_audio_func(void *data)
        return EINA_TRUE;
 }
 
-int sttd_recorder_start()
+int sttd_recorder_start(int engine_id)
 {
        if (STTD_RECORDER_STATE_RECORDING == g_recorder_state)
                return 0;
 
+       /* Check engine id is valid */
+       stt_recorder_s* recorder;
+       recorder = __get_recorder(engine_id);
+       if (NULL == recorder) {
+               SLOG(LOG_WARN, TAG_STTD, "[Recorder WARNING] Engine id is not valid");
+               return STTD_ERROR_INVALID_PARAMETER;
+       }
+
        int ret = -1; 
-       ret = audio_in_prepare(g_audio_in_h);
+       ret = audio_in_prepare(recorder->audio_h);
        if (AUDIO_IO_ERROR_NONE != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to prepare audio in : %d", ret);
-               return STTD_ERROR_OPERATION_FAILED;
+               SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to start audio : %d", ret);
+               return STTD_ERROR_RECORDER_BUSY;
        }
 
        /* Add ecore timer to read audio data */
        ecore_timer_add(0, __read_audio_func, NULL);
 
        g_recorder_state = STTD_RECORDER_STATE_RECORDING;
+       g_recording_engine_id = engine_id;
 
        g_pFile_vol = fopen(STT_AUDIO_VOLUME_PATH, "wb+");
        if (!g_pFile_vol) {
@@ -216,12 +400,13 @@ int sttd_recorder_start()
                return -1;
        }
 
+       g_buffer_count = 0;
 
 #ifdef BUF_SAVE_MODE
        g_count++;
 
        snprintf(g_temp_file_name, sizeof(g_temp_file_name), "/tmp/stt_temp_%d_%d", getpid(), g_count);
-       SLOG(LOG_DEBUG, TAG_STTD, "[Recorder] Temp file name=[%s]", g_temp_file_name);
+       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Recorder] Temp file name=[%s]", g_temp_file_name);
 
        /* open test file */
        g_pFile = fopen(g_temp_file_name, "wb+");
@@ -229,30 +414,62 @@ int sttd_recorder_start()
                SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] File not found!");
                return -1;
        }       
-#endif 
+#endif
 
        return 0;
 }
 
-int sttd_recorder_stop()
+int sttd_recorder_stop(int engine_id)
 {
        if (STTD_RECORDER_STATE_READY == g_recorder_state)
                return 0;
 
-       g_recorder_state = STTD_RECORDER_STATE_READY;
+       /* Check engine id is valid */
+       stt_recorder_s* recorder;
+       recorder = __get_recorder(engine_id);
+       if (NULL == recorder) {
+               SLOG(LOG_WARN, TAG_STTD, "[Recorder WARNING] Engine id is not valid");
+               return STTD_ERROR_INVALID_PARAMETER;
+       }
 
-       int ret = STTD_ERROR_OPERATION_FAILED
-       ret = audio_in_unprepare(g_audio_in_h);
+       int ret; 
+       ret = audio_in_unprepare(recorder->audio_h);
        if (AUDIO_IO_ERROR_NONE != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to unprepare audio_in : %d", ret);
+               SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to unprepare audioin : %d", ret);
        }
 
+       g_recorder_state = STTD_RECORDER_STATE_READY;
+       g_recording_engine_id = -1;
+
        fclose(g_pFile_vol);
 
 #ifdef BUF_SAVE_MODE
        fclose(g_pFile);
 #endif 
 
-       SLOG(LOG_ERROR, TAG_STTD, "[Recorder] Recorder stop success");
+       return 0;
+}
+
+int sttd_recorder_set_ignore_session(int engine_id)
+{
+       if (STTD_RECORDER_STATE_READY != g_recorder_state) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Record is working.");
+               return -1;
+       }
+
+       /* Check engine id is valid */
+       stt_recorder_s* recorder;
+       recorder = __get_recorder(engine_id);
+       if (NULL == recorder) {
+               SLOG(LOG_WARN, TAG_STTD, "[Recorder WARNING] Engine id is not valid");
+               return STTD_ERROR_INVALID_PARAMETER;
+       }
+
+       int ret = audio_in_ignore_session(recorder->audio_h);
+       if (AUDIO_IO_ERROR_NONE != ret) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to ignore session : %d", ret);
+               return STTD_ERROR_OPERATION_FAILED;
+       }
+
        return 0;
 }
\ No newline at end of file
index 580c7d8..377e8c0 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
 extern "C" {
 #endif
 
-typedef enum {
-       STTD_RECORDER_STATE_READY,      /**< Recorder is ready to start */
-       STTD_RECORDER_STATE_RECORDING   /**< In the middle of recording */
-} sttd_recorder_state;
-
 
 typedef int (*stt_recorder_audio_cb)(const void* data, const unsigned int length);
 
-int sttd_recorder_create(stt_recorder_audio_cb callback, sttp_audio_type_e type, int channel, unsigned int sample_rate);
+typedef void (*stt_recorder_interrupt_cb)();
+
+int sttd_recorder_initialize(stt_recorder_audio_cb audio_cb, stt_recorder_interrupt_cb interrupt_cb);
+
+int sttd_recorder_deinitialize();
+
+int sttd_recorder_set_audio_session();
+
+int sttd_recorder_unset_audio_session();
+
+int sttd_recorder_create(int engine_id, sttp_audio_type_e type, int channel, unsigned int sample_rate);
+
+int sttd_recorder_destroy(int engine_id);
 
-int sttd_recorder_destroy();
+int sttd_recorder_start(int engine_id);
 
-int sttd_recorder_start();
+int sttd_recorder_stop(int engine_id);
 
-int sttd_recorder_stop();
+int sttd_recorder_set_ignore_session(int engine_id);
 
 
 #ifdef __cplusplus
index 441bb81..5416556 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 <sound_manager.h>
-#include "sttd_main.h"
-#include "sttd_server.h"
+#include <wav_player.h>
 
+#include "stt_network.h"
 #include "sttd_client_data.h"
-#include "sttd_engine_agent.h"
 #include "sttd_config.h"
-#include "sttd_recorder.h"
-#include "sttd_network.h"
 #include "sttd_dbus.h"
+#include "sttd_engine_agent.h"
+#include "sttd_main.h"
+#include "sttd_recorder.h"
+#include "sttd_server.h"
+
 
 /*
 * STT Server static variable
 */
-static bool g_is_engine;
+static double g_processing_timeout = 30;
+
+static double g_recording_timeout = 60;
+
+Ecore_Timer*   g_recording_timer = NULL;
+Ecore_Timer*   g_processing_timer = NULL;
+
+static Eina_Bool g_stt_daemon_exist = EINA_TRUE;
 
-static double g_state_check_time = 15.5;
+static int g_recording_log_count = 0;
 
 /*
-* STT Server Callback Functions                                                                                        `                                 *
+* STT Server Callback Functions
 */
 
+Eina_Bool sttd_get_daemon_exist()
+{
+       return g_stt_daemon_exist;
+}
+
 Eina_Bool __stop_by_silence(void *data)
 {
        SLOG(LOG_DEBUG, TAG_STTD, "===== Stop by silence detection");
 
        int uid = 0;
 
-       uid = sttd_client_get_current_recording();
+       uid = stt_client_get_current_recognition();
 
-       if (uid > 0) {
-               if (0 != sttd_server_stop(uid))
+       int ret;
+       if (0 != uid) {
+               ret = sttd_server_stop(uid); 
+               if (0 > ret) {
                        return EINA_FALSE;
+               }
+       
+               if (STTD_RESULT_STATE_DONE == ret) {
+                       ret = sttdc_send_set_state(uid, (int)APP_STATE_PROCESSING);
+                       if (0 != ret) {
+                               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to send state : result(%d)", ret);
+
+                               /* Remove client */
+                               sttd_server_finalize(uid);
+                               stt_client_unset_current_recognition();
+                       }
+               }
+       } else {
+               SLOG(LOG_WARN, TAG_STTD, "[Server WARNING] uid is NOT valid");
+       }
+
+       SLOG(LOG_DEBUG, TAG_STTD, "=====");
+       SLOG(LOG_DEBUG, TAG_STTD, "  ");
+
+       return EINA_FALSE;
+}
+
+static void __cancel_recognition_internal()
+{
+       if (NULL != g_recording_timer)  {
+               ecore_timer_del(g_recording_timer);
+               g_recording_timer = NULL;
+       }
+
+       int uid = 0;
+       uid = stt_client_get_current_recognition();
 
-               int ret = sttdc_send_set_state(uid, (int)APP_STATE_PROCESSING);
+       if (0 != uid) {
+               /* cancel engine recognition */
+               int ret = sttd_engine_agent_recognize_cancel(uid);
                if (0 != ret) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to send state : result(%d)", ret); 
+                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to cancel : result(%d)", ret);
+               }
+
+               /* change uid state */
+               sttd_client_set_state(uid, APP_STATE_READY);
+               stt_client_unset_current_recognition();
 
-                       /* Remove client */
-                       sttd_server_finalize(uid);
-               }       
+               ret = sttdc_send_set_state(uid, (int)APP_STATE_READY);
+               if (0 != ret) {
+                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to send state change : result(%d)", ret);
+               }
+       } else {
+               SLOG(LOG_WARN, TAG_STTD, "[Server WARNING] uid is NOT valid");
        }
+}
+
+Eina_Bool __cancel_by_error(void *data)
+{
+       SLOG(LOG_DEBUG, TAG_STTD, "===== Cancel by error");
+
+       __cancel_recognition_internal();
 
        SLOG(LOG_DEBUG, TAG_STTD, "=====");
        SLOG(LOG_DEBUG, TAG_STTD, "  ");
@@ -60,159 +124,286 @@ Eina_Bool __stop_by_silence(void *data)
        return EINA_FALSE;
 }
 
-int audio_recorder_callback(const void* data, const unsigned int length)
+int __server_audio_recorder_callback(const void* data, const unsigned int length)
 {
-       if (0 != sttd_engine_recognize_audio(data, length)) {
-               int uid = sttd_client_get_current_recording();
+       int uid = -1;
+       int ret;
 
-               app_state_e state;
-               if (0 != sttd_client_get_state(uid, &state)) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is not valid "); 
-                       return -1;
-               }
+       if (NULL == data || 0 == length) {
+               SLOG(LOG_WARN, TAG_STTD, "[Server WARNING] Recording data is not valid");
+               ecore_timer_add(0, __cancel_by_error, NULL);
+               return -1;
+       }
 
-               if (APP_STATE_RECORDING != state) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Current state is not recording"); 
-                       return -1;
+       uid = stt_client_get_current_recognition();
+       if (0 != uid) {
+               ret = sttd_engine_agent_set_recording_data(uid, data, length);
+               if (ret < 0) {
+                        ecore_timer_add(0, __cancel_by_error, NULL);
+                        return -1;
                }
-
-               ecore_timer_add(0, __stop_by_silence, NULL);
-               
+               g_recording_log_count++;
+               if (200 <= g_recording_log_count) {
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "=== Set recording data ===");
+                       g_recording_log_count = 0;
+               }
+       } else {
+               if (NULL != g_recording_timer)  {
+                       ecore_timer_del(g_recording_timer);
+                       g_recording_timer = NULL;
+               }
+               SLOG(LOG_WARN, TAG_STTD, "[Server WARNING] Current uid in recording is is not valid");
                return -1;
        }
 
        return 0;
 }
 
-void sttd_server_recognition_result_callback(sttp_result_event_e event, const char* type, 
+void __server_audio_interrupt_callback()
+{
+       SLOG(LOG_DEBUG, TAG_STTD, "===== Cancel by sound interrupt");
+
+       __cancel_recognition_internal();
+
+       SLOG(LOG_DEBUG, TAG_STTD, "=====");
+       SLOG(LOG_DEBUG, TAG_STTD, "  ");
+}
+
+Eina_Bool __cancel_by_no_record(void *data)
+{
+       SLOG(LOG_DEBUG, TAG_STTD, "===== Cancel by no record");
+
+       __cancel_recognition_internal();
+
+       SLOG(LOG_DEBUG, TAG_STTD, "=====");
+       SLOG(LOG_DEBUG, TAG_STTD, "  ");
+       
+       return EINA_FALSE;
+}
+
+void __server_recognition_result_callback(sttp_result_event_e event, const char* type,
                                        const char** data, int data_count, const char* msg, void *user_data)
 {
        SLOG(LOG_DEBUG, TAG_STTD, "===== Recognition Result Callback");
 
-       if (NULL == user_data) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] user data is NULL"); 
-               SLOG(LOG_DEBUG, TAG_STTD, "=====");
-               SLOG(LOG_DEBUG, TAG_STTD, "  ");
-               return;
-       }
-
        /* check uid */
-       int *uid = (int*)user_data;
-
-       SLOG(LOG_DEBUG, TAG_STTD, "[Server] uid (%d), event(%d)", *uid, event); 
+       int uid = stt_client_get_current_recognition();
 
        app_state_e state;
-       if (0 != sttd_client_get_state(*uid, &state)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid "); 
+       if (0 == uid || 0 != sttd_client_get_state(uid, &state)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid ");
                SLOG(LOG_DEBUG, TAG_STTD, "=====");
                SLOG(LOG_DEBUG, TAG_STTD, "  ");
                return;
        }
 
-       /* Delete timer for processing time out */
-       Ecore_Timer* timer;
-       sttd_cliet_get_timer(*uid, &timer);
-
-       if (NULL != timer)
-               ecore_timer_del(timer);
+       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Server] uid (%d), event(%d)", uid, event);
 
        /* send result to client */
-       if (STTP_RESULT_EVENT_SUCCESS == event && 0 < data_count && NULL != data) {
+       if (STTP_RESULT_EVENT_FINAL_RESULT == event) {
+               if (APP_STATE_PROCESSING != state ) {
+                       SLOG(LOG_WARN, TAG_STTD, "[Server WARNING] Current state is NOT 'Processing'.");
+               }
+               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Server] the size of result from engine is '%d'", data_count);
+
+               /* Delete timer for processing time out */
+               if (NULL != g_processing_timer) {
+                       ecore_timer_del(g_processing_timer);
+                       g_processing_timer = NULL;
+               }
 
-               if (APP_STATE_PROCESSING == state ) {
-                       SLOG(LOG_DEBUG, TAG_STTD, "[Server] the size of result from engine is '%d' %s", data_count); 
+               sttd_config_time_save();
+               sttd_config_time_reset();
 
-                       if (0 != sttdc_send_result(*uid, type, data, data_count, msg)) {
-                               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to send result");        
+               if (NULL == data || 0 == data_count) {
+                       if (0 != sttdc_send_result(uid, event, NULL, 0, msg)) {
+                               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to send result");        
                                int reason = (int)STTD_ERROR_OPERATION_FAILED;
 
-                               if (0 != sttdc_send_error_signal(*uid, reason, "Fail to send recognition result")) {
-                                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to send error info . Remove client data"); 
+                               if (0 != sttdc_send_error_signal(uid, reason, "Fail to send recognition result")) {
+                                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to send error info . Remove client data");
                                }
                        }
                } else {
-                       SLOG(LOG_WARN, TAG_STTD, "[Server WARNING] Current state is NOT thinking."); 
+                       if (0 != sttdc_send_result(uid, event, data, data_count, msg)) {
+                               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to send result");        
+                               int reason = (int)STTD_ERROR_OPERATION_FAILED;
+
+                               if (0 != sttdc_send_error_signal(uid, reason, "Fail to send recognition result")) {
+                                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to send error info . Remove client data");
+                               }
+                       }
                }
-       } else if (STTP_RESULT_EVENT_NO_RESULT == event || STTP_RESULT_EVENT_ERROR == event) {
 
-               if (APP_STATE_PROCESSING == state ) {
-                       if (0 != sttdc_send_result(*uid, type, NULL, 0, msg)) {
-                               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to send result "); 
+               /* change state of uid */
+               sttd_client_set_state(uid, APP_STATE_READY);
+               stt_client_unset_current_recognition();
 
-                               /* send error msg */
-                               int reason = (int)STTD_ERROR_INVALID_STATE;     
-                               if (0 != sttdc_send_error_signal(*uid, reason, "[ERROR] Fail to send recognition result")) {
-                                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to send error info "); 
-                               }
+       } else if (STTP_RESULT_EVENT_PARTIAL_RESULT == event) {
+               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Server] The partial result from engine is event[%d] data_count[%d]", event,  data_count);
+
+               sttd_config_time_save();
+               sttd_config_time_reset();
+
+               if (0 != sttdc_send_result(uid, event, data, data_count, msg)) {
+                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to send result");
+                       int reason = (int)STTD_ERROR_OPERATION_FAILED;
+
+                       if (0 != sttdc_send_error_signal(uid, reason, "Fail to send recognition result")) {
+                               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to send error info . Remove client data");
                        }
-               } else {
-                       SLOG(LOG_WARN, TAG_STTD, "[Server ERROR] Current state is NOT thinking."); 
                }
+
+       } else if (STTP_RESULT_EVENT_ERROR == event) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] The event of recognition result is ERROR");
+
+               /* Delete timer for processing time out */
+               if (NULL != g_processing_timer) {
+                       ecore_timer_del(g_processing_timer);
+                       g_processing_timer = NULL;
+               }
+               sttd_config_time_reset();
+
+               if (0 != sttdc_send_result(uid, event, NULL, 0, msg)) {
+                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to send result ");
+
+                       /* send error msg */
+                       int reason = (int)STTD_ERROR_INVALID_STATE;     
+                       if (0 != sttdc_send_error_signal(uid, reason, "[ERROR] Fail to send recognition result")) {
+                               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to send error info ");
+                       }
+               }
+
+               /* change state of uid */
+               sttd_client_set_state(uid, APP_STATE_READY);
+               stt_client_unset_current_recognition();
        } else {
                /* nothing */
        }
 
-       /* change state of uid */
-       sttd_client_set_state(*uid, APP_STATE_READY);
-
-       if (NULL != user_data)  
-               free(user_data);
-
        SLOG(LOG_DEBUG, TAG_STTD, "=====");
        SLOG(LOG_DEBUG, TAG_STTD, "  ");
 
        return;
 }
 
-void sttd_server_partial_result_callback(sttp_result_event_e event, const char* data, void *user_data)
+bool __server_result_time_callback(int index, sttp_result_time_event_e event, const char* text, long start_time, long end_time, void* user_data)
 {
-       SLOG(LOG_DEBUG, TAG_STTD, "===== Partial Result Callback");
+       SLOG(LOG_DEBUG, TAG_STTD, "[Server] index(%d) event(%d) text(%s) start(%ld) end(%ld)", 
+               index, event, text, start_time, end_time);
 
-       /* check uid */
-       int *uid = (int*)user_data;
+       if (0 == index) {
+               int ret;
+               ret = sttd_config_time_add(index, (int)event, text, start_time, end_time);
+               if (0 != ret) {
+                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to add time info");
+                       return false;
+               }
+       } else {
+               return false;
+       }
 
-       SLOG(LOG_DEBUG, TAG_STTD, "[Server] uid (%d), event(%d)", uid, event); 
+       return true;
+}
 
-       app_state_e state;
-       if (0 != sttd_client_get_state(*uid, &state)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid "); 
-               SLOG(LOG_DEBUG, TAG_STTD, "=====");
-               SLOG(LOG_DEBUG, TAG_STTD, "  ");
-               return;
-       }
+void __server_silence_dectection_callback(sttp_silence_type_e type, void *user_param)
+{
+       SLOG(LOG_DEBUG, TAG_STTD, "===== Silence Detection Callback");
 
-       /* send result to client */
-       if (STTP_RESULT_EVENT_SUCCESS == event && NULL != data) {
-               if (0 != sttdc_send_partial_result(*uid, data)) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to send partial result");        
+       int uid = stt_client_get_current_recognition();
+       if (0 != uid) {
+               app_state_e state;
+               if (0 != sttd_client_get_state(uid, &state)) {
+                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is not valid ");
+                       return;
+               }
+
+               if (APP_STATE_RECORDING != state) {
+                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Current state is not recording");
+                       return;
+               }
+
+               if (STTP_SILENCE_TYPE_NO_RECORD_TIMEOUT == type) {
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "Silence Detection type - No Record");
+                       ecore_timer_add(0, __cancel_by_no_record, NULL);
+               } else if (STTP_SILENCE_TYPE_END_OF_SPEECH_DETECTED == type) {
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "Silence Detection type - End of Speech");
+                       ecore_timer_add(0, __stop_by_silence, NULL);
                }
-       } 
+       } else {
+               SLOG(LOG_WARN, TAG_STTD, "[Server WARNING] Current recogntion uid is not valid ");
+       }
 
        SLOG(LOG_DEBUG, TAG_STTD, "=====");
        SLOG(LOG_DEBUG, TAG_STTD, "  ");
+
+       return;
 }
 
-void sttd_server_silence_dectection_callback(void *user_param)
+void __sttd_server_engine_changed_cb(const char* engine_id, const char* language, bool support_silence, void* user_data)
 {
-       SLOG(LOG_DEBUG, TAG_STTD, "===== Silence Detection Callback");
+       if (NULL == engine_id) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Engine id is NULL");
+               return;
+       } else {
+               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Server] New default engine : %s", engine_id);
+       }
 
-       int uid = sttd_client_get_current_recording();
+       /* need to change state of app to ready */
+       int uid;
+       uid = stt_client_get_current_recognition();
 
-       app_state_e state;
-       if (0 != sttd_client_get_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is not valid "); 
-               return;
+       if (0 != uid) {
+               SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Server] Set ready state of uid(%d)", uid);
+
+               sttd_server_cancel(uid);
+               sttdc_send_set_state(uid, (int)APP_STATE_READY);
+
+               stt_client_unset_current_recognition();
        }
 
-       if (APP_STATE_RECORDING != state) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Current state is not recording"); 
+       /* set engine */
+       int ret = sttd_engine_agent_set_default_engine(engine_id);
+       if (0 != ret)
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to set engine : result(%d)", ret);
+
+       if (NULL != language) {
+               ret = sttd_engine_agent_set_default_language(language);
+               if (0 != ret)
+                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to set default lang : result(%d)", ret);
+       }
+       
+       ret = sttd_engine_agent_set_silence_detection(support_silence);
+       if (0 != ret)
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to Result(%d)", ret);
+
+       return;
+}
+
+void __sttd_server_language_changed_cb(const char* language, void* user_data)
+{
+       if (NULL == language) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] language is NULL");
                return;
+       } else {
+               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Server] Get language changed : %s", language);
        }
 
-       ecore_timer_add(0, __stop_by_silence, NULL);
+       int ret = sttd_engine_agent_set_default_language(language);
+       if (0 != ret)
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to set default lang : result(%d)", ret);
 
-       SLOG(LOG_DEBUG, TAG_STTD, "=====");
-       SLOG(LOG_DEBUG, TAG_STTD, "  ");
+       return;
+}
+
+void __sttd_server_silence_changed_cb(bool value, void* user_data)
+{
+       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Server] Get silence detection changed : %s", value ? "on" : "off");
+
+       int ret = 0;
+       ret = sttd_engine_agent_set_silence_detection(value);
+       if (0 != ret)
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to Result(%d)", ret);
 
        return;
 }
@@ -225,39 +416,44 @@ int sttd_initialize()
 {
        int ret = 0;
 
-       if (sttd_config_initialize()) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server WARNING] Fail to initialize config.");
+       if (sttd_config_initialize(__sttd_server_engine_changed_cb, __sttd_server_language_changed_cb, 
+               __sttd_server_silence_changed_cb, NULL)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to initialize config.");
+       }
+
+       ret = sttd_recorder_initialize(__server_audio_recorder_callback, __server_audio_interrupt_callback);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to initialize recorder : result(%d)", ret);
        }
 
        /* Engine Agent initialize */
-       ret = sttd_engine_agent_init(sttd_server_recognition_result_callback, sttd_server_partial_result_callback, 
-                               sttd_server_silence_dectection_callback);
+       ret = sttd_engine_agent_init(__server_recognition_result_callback, __server_result_time_callback,
+               __server_silence_dectection_callback);
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to engine agent initialize : result(%d)", ret);
                return ret;
        }
        
-       if (0 != sttd_engine_agent_initialize_current_engine()) {
-               SLOG(LOG_WARN, TAG_STTD, "[Server WARNING] There is No STT-Engine !!!!!"); 
-               g_is_engine = false;
-       } else {
-               g_is_engine = true;
-       }
-
-       /* Set audio session */
-       ret = sound_manager_set_session_type(SOUND_SESSION_TYPE_EXCLUSIVE);
-       if (SOUND_MANAGER_ERROR_NONE != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to set sound session : result(%d)", ret);
-               return STTD_ERROR_OPERATION_FAILED;
+       /* Update engine list */
+       ret = sttd_engine_agent_initialize_engine_list();
+       if (0 != ret) {
+               if (STTD_ERROR_ENGINE_NOT_FOUND == ret) {
+                       SLOG(LOG_WARN, TAG_STTD, "[Server WARNING] There is no stt engine");
+               } else {
+                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to update engine list : %d", ret);
+                       return ret;
+               }
        }
 
-       SLOG(LOG_DEBUG, TAG_STTD, "[Server SUCCESS] initialize"); 
+       SLOG(LOG_DEBUG, TAG_STTD, "[Server SUCCESS] initialize");
 
        return 0;
 }
 
 int sttd_finalize()
 {
+       sttd_recorder_deinitialize();
+
        sttd_config_finalize();
 
        sttd_engine_agent_release();
@@ -269,33 +465,35 @@ Eina_Bool sttd_cleanup_client(void *data)
 {
        int* client_list = NULL;
        int client_count = 0;
-
-       if (0 != sttd_client_get_list(&client_list, &client_count)) 
-               return EINA_TRUE;
-       
-       if (NULL == client_list)
-               return EINA_TRUE;
-
        int result;
        int i = 0;
 
-       SLOG(LOG_DEBUG, TAG_STTD, "===== Clean up client ");
+       if (0 != sttd_client_get_list(&client_list, &client_count)) {
+               if (NULL != client_list)
+                       free(client_list);
+
+               return EINA_TRUE;
+       }
+
+       if (NULL != client_list) {
+               SLOG(LOG_DEBUG, TAG_STTD, "===== Clean up client ");
 
-       for (i = 0;i < client_count;i++) {
-               result = sttdc_send_hello(client_list[i]);
+               for (i = 0;i < client_count;i++) {
+                       result = sttdc_send_hello(client_list[i]);
 
-               if (0 == result) {
-                       SLOG(LOG_DEBUG, TAG_STTD, "[Server] uid(%d) should be removed.", client_list[i]); 
-                       sttd_server_finalize(client_list[i]);
-               } else if (-1 == result) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Hello result has error"); 
+                       if (0 == result) {
+                               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Server] uid(%d) should be removed.", client_list[i]);
+                               sttd_server_finalize(client_list[i]);
+                       } else if (-1 == result) {
+                               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Hello result has error");
+                       }
                }
-       }
 
-       SLOG(LOG_DEBUG, TAG_STTD, "=====");
-       SLOG(LOG_DEBUG, TAG_STTD, "  ");
+               SLOG(LOG_DEBUG, TAG_STTD, "=====");
+               SLOG(LOG_DEBUG, TAG_STTD, "  ");
 
-       free(client_list);
+               free(client_list);
+       }
 
        return EINA_TRUE;
 }
@@ -304,70 +502,48 @@ Eina_Bool sttd_cleanup_client(void *data)
 * STT Server Functions for Client
 */
 
-int sttd_server_initialize(int pid, int uid, bool* silence, bool* profanity, bool* punctuation)
+int sttd_server_initialize(int pid, int uid, bool* silence)
 {
-       if (false == g_is_engine) {
-               if (0 != sttd_engine_agent_initialize_current_engine()) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] No Engine"); 
-                       g_is_engine = false;
+       if (false == sttd_engine_agent_is_default_engine()) {
+               /* Update installed engine */
+               sttd_engine_agent_initialize_engine_list();
+               
+               if (false == sttd_engine_agent_is_default_engine()) {
+                       SLOG(LOG_WARN, TAG_STTD, "[Server WARNING] No stt-engine");
                        return STTD_ERROR_ENGINE_NOT_FOUND;
-               } else {
-                       g_is_engine = true;
                }
        }
 
        /* check if uid is valid */
        app_state_e state;
        if (0 == sttd_client_get_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid has already been registered"); 
-               return STTD_ERROR_INVALID_PARAMETER;
+               SLOG(LOG_WARN, TAG_STTD, "[Server WARNING] uid has already been registered");
+               return STTD_ERROR_NONE;
        }
-       
-       /* load if engine is unloaded */
-       if (0 == sttd_client_get_ref_count()) {
-               if (0 != sttd_engine_agent_load_current_engine()) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to load current engine"); 
-                       return STTD_ERROR_OPERATION_FAILED;
-               }
-
-               /* set type, channel, sample rate */
-               sttp_audio_type_e atype;
-               int rate;
-               int channels;
-
-               if (0 != sttd_engine_get_audio_format(&atype, &rate, &channels)) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to get audio format of engine."); 
-                       return STTD_ERROR_OPERATION_FAILED;
-               }
-
-               if (0 != sttd_recorder_create(audio_recorder_callback, atype, channels, rate)) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to set recorder"); 
-                       return STTD_ERROR_OPERATION_FAILED;
-               }
 
-               SLOG(LOG_DEBUG, TAG_STTD, "[Server] audio type(%d), channel(%d)", (int)atype, (int)channels);
+       /* load engine */
+       if (0 != sttd_engine_agent_load_current_engine(uid, NULL)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to load default engine");
+               return STTD_ERROR_OPERATION_FAILED;
        }
 
-       /* Add client information to client manager */
-       if (0 != sttd_client_add(pid, uid)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to add client info"); 
+       if (0 != sttd_engine_agent_get_option_supported(uid, silence)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to get engine options supported");
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       if (0 != sttd_engine_get_option_supported(silence, profanity, punctuation)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to get engine options supported"); 
+       /* Add client information to client manager */
+       if (0 != sttd_client_add(pid, uid)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to add client info");
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       SLOG(LOG_DEBUG, TAG_STTD, "[Server Success] Initialize"); 
-
        return STTD_ERROR_NONE;
 }
 
 static Eina_Bool __quit_ecore_loop(void *data)
 {
        ecore_main_loop_quit();
-       SLOG(LOG_DEBUG, TAG_STTD, "[Server] quit ecore main loop");
        return EINA_FALSE;
 }
 
@@ -376,736 +552,697 @@ int sttd_server_finalize(int uid)
        /* check if uid is valid */
        app_state_e state;
        if (0 != sttd_client_get_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid "); 
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid ");
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
        /* release recorder */
        if (APP_STATE_RECORDING == state || APP_STATE_PROCESSING == state) {
-               sttd_recorder_stop();
-               sttd_engine_recognize_cancel();
+               if (APP_STATE_RECORDING == state) {
+                       if (NULL != g_recording_timer)  {
+                               ecore_timer_del(g_recording_timer);
+                               g_recording_timer = NULL;
+                       }
+               }
+
+               if (APP_STATE_PROCESSING == state) {
+                       if (NULL != g_processing_timer) {
+                               ecore_timer_del(g_processing_timer);
+                               g_processing_timer = NULL;
+                       }
+               }
+
+               if (0 != sttd_engine_agent_recognize_cancel(uid)) {
+                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to cancel recognition");
+               }
+
+               stt_client_unset_current_recognition();
        }
        
+       if (0 != sttd_engine_agent_unload_current_engine(uid)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to unload engine");
+       }
+
        /* Remove client information */
        if (0 != sttd_client_delete(uid)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to delete client"); 
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to delete client");
        }
 
        /* unload engine, if ref count of client is 0 */
        if (0 == sttd_client_get_ref_count()) {
-               sttd_recorder_destroy();
-
+               g_stt_daemon_exist = EINA_FALSE;
                ecore_timer_add(0, __quit_ecore_loop, NULL);
        }
        
        return STTD_ERROR_NONE;
 }
 
-int sttd_server_get_supported_languages(int uid, GList** lang_list)
+int sttd_server_get_supported_engines(int uid, GSList** engine_list)
 {
-       /* check if uid is valid */
+       /* Check if uid is valid */
        app_state_e state;
        if (0 != sttd_client_get_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid "); 
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid ");
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
-       /* get language list from engine */
-       int ret = sttd_engine_supported_langs(lang_list);
+       /* Check state of uid */
+       if (APP_STATE_READY != state) {
+               SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] The state of uid(%d) is not Ready", uid);
+               return STTD_ERROR_INVALID_STATE;
+       }
+
+       int ret;
+       ret = sttd_engine_agent_get_engine_list(engine_list);
        if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to get supported languages"); 
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to get engine list");
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       SLOG(LOG_DEBUG, TAG_STTD, "[Server SUCCESS] sttd_server_get_supported_languages"); 
-
        return STTD_ERROR_NONE;
 }
 
-int sttd_server_get_current_langauage(int uid, char** current_lang)
+int sttd_server_set_current_engine(int uid, const char* engine_id, bool* silence)
 {
-       /* check if uid is valid */
+       /* Check if uid is valid */
        app_state_e state;
        if (0 != sttd_client_get_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid "); 
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid ");
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
-       if (NULL == current_lang) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Input parameter is NULL"); 
-               return STTD_ERROR_INVALID_PARAMETER;
+       /* Check state of uid */
+       if (APP_STATE_READY != state) {
+               SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] The state of uid(%d) is not Ready", uid);
+               return STTD_ERROR_INVALID_STATE;
        }
 
-       /*get current language from engine */
-       int ret = sttd_engine_get_default_lang(current_lang);
-       if (0 != ret) { 
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to get default language :result(%d)", ret); 
+       int ret;
+       ret = sttd_engine_agent_load_current_engine(uid, engine_id);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to set engine : %d", ret);
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       SLOG(LOG_DEBUG, TAG_STTD, "[Server SUCCESS] sttd_engine_get_default_lang"); 
+       ret = sttd_engine_agent_get_option_supported(uid, silence);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to engine options : %d", ret);
+               return STTD_ERROR_OPERATION_FAILED;
+       }
 
        return STTD_ERROR_NONE;
 }
 
-int sttd_server_is_partial_result_supported(int uid, int* partial_result)
+int sttd_server_get_current_engine(int uid, char** engine_id)
 {
-       /* check if uid is valid */
+       /* Check if uid is valid */
        app_state_e state;
        if (0 != sttd_client_get_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid "); 
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid ");
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
-       if (NULL == partial_result) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Input parameter is NULL"); 
-               return STTD_ERROR_INVALID_PARAMETER;
+       /* Check state of uid */
+       if (APP_STATE_READY != state) {
+               SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] The state of uid(%d) is not Ready", uid);
+               return STTD_ERROR_INVALID_STATE;
        }
-
-       bool temp;
-       int ret = sttd_engine_is_partial_result_supported(&temp);
-       if (0 != ret) { 
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to get partial result supported : result(%d)", ret); 
+       
+       int ret;
+       ret = sttd_engine_agent_get_current_engine(uid, engine_id);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to get engine : %d", ret);
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       SLOG(LOG_DEBUG, TAG_STTD, "[Server SUCCESS] Partial result supporting is %s", temp ? "true" : "false"); 
-
        return STTD_ERROR_NONE;
 }
 
-Eina_Bool __check_recording_state(void *data)
-{      
-       /* current uid */
-       int uid = sttd_client_get_current_recording();
-       if (-1 == uid)
-               return EINA_FALSE;
-
-       app_state_e state;
-       if (0 != sttdc_send_get_state(uid, (int*)&state)) {
-               /* client is removed */
-               SLOG(LOG_DEBUG, TAG_STTD, "[Server] uid(%d) should be removed.", uid); 
-               sttd_server_finalize(uid);
-               return EINA_FALSE;
-       }
-
-       if (APP_STATE_READY == state) {
-               /* Cancel stt */
-               SLOG(LOG_DEBUG, TAG_STTD, "[Server] The state of uid(%d) is 'Ready'. The daemon should cancel recording", uid); 
-               sttd_server_cancel(uid);
-       } else if (APP_STATE_PROCESSING == state) {
-               /* Cancel stt and send change state */
-               SLOG(LOG_DEBUG, TAG_STTD, "[Server] The state of uid(%d) is 'Processing'. The daemon should cancel recording", uid); 
-               sttd_server_cancel(uid);
-               sttdc_send_set_state(uid, (int)APP_STATE_READY);
-       } else {
-               /* Normal state */
-               SLOG(LOG_DEBUG, TAG_STTD, "[Server] The states of daemon and client are identical"); 
-               return EINA_TRUE;
-       }
-
-       return EINA_FALSE;
-}
-
-int sttd_server_start(int uid, const char* lang, const char* recognition_type, 
-                     int profanity, int punctuation, int silence)
-{
-       /* check if uid is valid */
+int sttd_server_check_agg_agreed(int uid, const char* appid, bool* available)
+{
+       /* Check if uid is valid */
        app_state_e state;
        if (0 != sttd_client_get_state(uid, &state)) {
                SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid "); 
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
-       /* check uid state */
+       /* Check state of uid */
        if (APP_STATE_READY != state) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] sttd_server_start : current state is not ready"); 
+               SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] The state of uid(%d) is not Ready", uid);
                return STTD_ERROR_INVALID_STATE;
        }
 
-       if (0 < sttd_client_get_current_recording()) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Current STT Engine is busy because of recording");
-               return STTD_ERROR_RECORDER_BUSY;
+       /* Ask engine available */
+       int ret;
+       bool temp = false;
+       ret = sttd_engine_agent_check_app_agreed(uid, appid, &temp);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to get engine available : %d", ret);
+               return STTD_ERROR_OPERATION_FAILED;
        }
 
-       if (0 < sttd_client_get_current_thinking()) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Current STT Engine is busy because of thinking");
-               return STTD_ERROR_RECORDER_BUSY;
+       if (true == temp) {
+               stt_client_set_app_agreed(uid);
+               SLOG(LOG_DEBUG, TAG_STTD, "[Server] App(%s) confirmed that engine is available", appid);
        }
 
-       /* check if engine use network */
-       if (true == sttd_engine_agent_need_network()) {
-               if (false == sttd_network_is_connected()) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Disconnect network. Current engine needs to network connection.");
-                       return STTD_ERROR_OUT_OF_NETWORK;
-               }
-       }
+       *available = temp;
 
-       /* engine start recognition */
-       int* user_data;
-       user_data = (int*)malloc( sizeof(int) * 1);
-       
-       /* free on result callback */
-       *user_data = uid;
+       return STTD_ERROR_NONE;
+}
 
-       SLOG(LOG_DEBUG, TAG_STTD, "[Server] start : uid(%d), lang(%s), recog_type(%s)", *user_data, lang, recognition_type ); 
 
-       int ret = sttd_engine_recognize_start((char*)lang, recognition_type, profanity, punctuation, silence, (void*)user_data);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to start recognition : result(%d)", ret); 
-               return STTD_ERROR_OPERATION_FAILED;
+int sttd_server_get_supported_languages(int uid, GSList** lang_list)
+{
+       /* check if uid is valid */
+       app_state_e state;
+       if (0 != sttd_client_get_state(uid, &state)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid ");
+               return STTD_ERROR_INVALID_PARAMETER;
        }
 
-       /* recorder start */
-       ret = sttd_recorder_start();
+       /* get language list from engine */
+       int ret = sttd_engine_agent_supported_langs(uid, lang_list);
        if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to start recorder : result(%d)", ret); 
-               sttd_engine_recognize_cancel();
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to get supported languages");
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       SLOG(LOG_DEBUG, TAG_STTD, "[Server] start recording"); 
-
-       /* change uid state */
-       sttd_client_set_state(uid, APP_STATE_RECORDING);
-
-       Ecore_Timer* timer = ecore_timer_add(g_state_check_time, __check_recording_state, NULL);
-       sttd_cliet_set_timer(uid, timer);
+       SLOG(LOG_DEBUG, TAG_STTD, "[Server SUCCESS] sttd_server_get_supported_languages");
 
        return STTD_ERROR_NONE;
 }
 
-Eina_Bool __time_out_for_processing(void *data)
-{      
-       /* current uid */
-       int uid = sttd_client_get_current_thinking();
-       if (-1 == uid)
-               return EINA_FALSE;
-
-       /* Cancel engine */
-       int ret = sttd_engine_recognize_cancel();
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to cancel : result(%d)", ret); 
+int sttd_server_get_current_langauage(int uid, char** current_lang)
+{
+       /* check if uid is valid */
+       app_state_e state;
+       if (0 != sttd_client_get_state(uid, &state)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid ");
+               return STTD_ERROR_INVALID_PARAMETER;
        }
 
-       if (0 != sttdc_send_result(uid, STTP_RECOGNITION_TYPE_FREE, NULL, 0, "Time out not to receive recognition result.")) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to send result "); 
+       if (NULL == current_lang) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Input parameter is NULL");
+               return STTD_ERROR_INVALID_PARAMETER;
+       }
 
-               /* send error msg */
-               int reason = (int)STTD_ERROR_TIMED_OUT; 
-               if (0 != sttdc_send_error_signal(uid, reason, "[ERROR] Fail to send recognition result")) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to send error info "); 
-               }
+       /*get current language from engine */
+       int ret = sttd_engine_agent_get_default_lang(uid, current_lang);
+       if (0 != ret) { 
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to get default language :result(%d)", ret);
+               return STTD_ERROR_OPERATION_FAILED;
        }
 
-       /* Change uid state */
-       sttd_client_set_state(uid, APP_STATE_READY);
+       SLOG(LOG_DEBUG, TAG_STTD, "[Server SUCCESS] Get default language");
 
-       return EINA_FALSE;
+       return STTD_ERROR_NONE;
 }
 
-
-int sttd_server_stop(int uid)
+int sttd_server_is_recognition_type_supported(int uid, const char* type, int* support)
 {
        /* check if uid is valid */
        app_state_e state;
        if (0 != sttd_client_get_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid "); 
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid ");
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
-       /* check uid state */
-       if (APP_STATE_RECORDING != state) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Current state is not recording"); 
-               return STTD_ERROR_INVALID_STATE;
+       if (NULL == type || NULL == support) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Input parameter is NULL");
+               return STTD_ERROR_INVALID_PARAMETER;
        }
 
-       /* stop recorder */
-       sttd_recorder_stop();
-
-       /* stop engine recognition */
-       int ret = sttd_engine_recognize_stop();
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to stop : result(%d)", ret); 
-               sttd_client_set_state(uid, APP_STATE_READY);            
-       
+       bool temp;
+       int ret = sttd_engine_agent_is_recognition_type_supported(uid, type, &temp);
+       if (0 != ret) { 
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to get recognition type supported : result(%d)", ret);
                return STTD_ERROR_OPERATION_FAILED;
        }
        
-       Ecore_Timer* timer;
-       sttd_cliet_get_timer(uid, &timer);
-
-       if (NULL != timer)
-               ecore_timer_del(timer);
-
-       /* change uid state */
-       sttd_client_set_state(uid, APP_STATE_PROCESSING);
+       *support = (int)temp;
 
-       timer = ecore_timer_add(g_state_check_time, __time_out_for_processing, NULL);
-       sttd_cliet_set_timer(uid, timer);
+       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Server SUCCESS] recognition type supporting is %s", *support ? "true" : "false");
 
        return STTD_ERROR_NONE;
 }
 
-int sttd_server_cancel(int uid)
+int sttd_server_set_start_sound(int uid, const char* file)
 {
        /* check if uid is valid */
        app_state_e state;
        if (0 != sttd_client_get_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid "); 
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid ");
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
-       /* check uid state */ 
-       if (APP_STATE_READY == state) {
-               SLOG(LOG_WARN, TAG_STTD, "[Server WARNING] Current state is ready"); 
-               return STTD_ERROR_INVALID_STATE;
-       }
-
-       /* stop recorder */
-       if (APP_STATE_RECORDING == state) 
-               sttd_recorder_stop();
-
-       /* cancel engine recognition */
-       int ret = sttd_engine_recognize_cancel();
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to cancel : result(%d)", ret); 
+       int ret = sttd_client_set_start_sound(uid, file);
+       if (0 != ret) { 
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to set start sound file : result(%d)", ret);
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       Ecore_Timer* timer;
-       sttd_cliet_get_timer(uid, &timer);
-       ecore_timer_del(timer);
-
-       /* change uid state */
-       sttd_client_set_state(uid, APP_STATE_READY);
-
-       return STTD_ERROR_NONE;
+       return 0;
 }
 
-int sttd_server_start_file_recognition(int uid, const char* filepath, const char* lang, const char* type, 
-                                      int profanity, int punctuation)
+int sttd_server_set_stop_sound(int uid, const char* file)
 {
        /* check if uid is valid */
        app_state_e state;
        if (0 != sttd_client_get_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid "); 
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid ");
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
-       /* check uid state */
-       if (APP_STATE_READY != state) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Current state is not ready"); 
-               return STTD_ERROR_INVALID_STATE;
+       int ret = sttd_client_set_stop_sound(uid, file);
+       if (0 != ret) { 
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to set start sound file : result(%d)", ret);
+               return STTD_ERROR_OPERATION_FAILED;
        }
 
-       if (0 < sttd_client_get_current_recording()) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Current STT Engine is busy because of recording");
-               return STTD_ERROR_RECORDER_BUSY;
+       return 0;
+}
+
+Eina_Bool __check_recording_state(void *data)
+{      
+       /* current uid */
+       int uid = stt_client_get_current_recognition();
+       if (0 == uid)
+               return EINA_FALSE;
+
+       app_state_e state;
+       if (0 != sttdc_send_get_state(uid, (int*)&state)) {
+               /* client is removed */
+               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Server] uid(%d) should be removed.", uid);
+               sttd_server_finalize(uid);
+               return EINA_FALSE;
        }
 
-       if (0 < sttd_client_get_current_thinking()) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Current STT Engine is busy because of thinking");
-               return STTD_ERROR_RECORDER_BUSY;
+       if (APP_STATE_READY == state) {
+               /* Cancel stt */
+               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Server] The state of uid(%d) is 'Ready'. The daemon should cancel recording", uid);
+               sttd_server_cancel(uid);
+       } else if (APP_STATE_PROCESSING == state) {
+               /* Cancel stt and send change state */
+               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Server] The state of uid(%d) is 'Processing'. The daemon should cancel recording", uid);
+               sttd_server_cancel(uid);
+               sttdc_send_set_state(uid, (int)APP_STATE_READY);
+       } else {
+               /* Normal state */
+               SLOG(LOG_DEBUG, TAG_STTD, "[Server] The states of daemon and client are identical");
+               return EINA_TRUE;
        }
 
-       /* check if engine use network */
-       if (true == sttd_engine_agent_need_network()) {
-               if (false == sttd_network_is_connected()) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Disconnect network. Current engine needs to network connection.");
-                       return STTD_ERROR_OUT_OF_NETWORK;
+       return EINA_FALSE;
+}
+
+Eina_Bool __stop_by_recording_timeout(void *data)
+{
+       SLOG(LOG_DEBUG, TAG_STTD, "===== Stop by timeout");
+
+       g_recording_timer = NULL;
+
+       int uid = 0;
+       uid = stt_client_get_current_recognition();
+       if (0 != uid) {
+               /* cancel engine recognition */
+               int ret = sttd_server_stop(uid);
+               if (0 != ret) {
+                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to stop : result(%d)", ret);
                }
        }
 
-       /* engine start recognition */
-       int* user_data;
-       user_data = (int*)malloc( sizeof(int) * 1);
+       SLOG(LOG_DEBUG, TAG_STTD, "=====");
+       SLOG(LOG_DEBUG, TAG_STTD, "  ");
 
-       /* free on result callback */
-       *user_data = uid;
+       return EINA_FALSE;
+}
 
-       SLOG(LOG_DEBUG, TAG_STTD, "[Server] start file recognition : uid(%d), filepath(%s), lang(%s), recog_type(%s)", 
-               *user_data, filepath, lang, type ); 
+void __sttd_server_recorder_start(int uid)
+{
+       int current_uid = stt_client_get_current_recognition();
 
-       int ret = sttd_engine_recognize_start_file(filepath, (char*)lang, type, profanity, punctuation, (void*)user_data);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to start recognition : result(%d)", ret); 
-               return STTD_ERROR_OPERATION_FAILED;
+       if (uid != current_uid) {
+               stt_client_unset_current_recognition();
+               return;
        }
 
-       SLOG(LOG_DEBUG, TAG_STTD, "[Server] start file recognition"); 
+       int ret = sttd_engine_agent_recognize_start_recorder(uid);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to start recognition : result(%d)", ret);
+               return;
+       }
 
-       Ecore_Timer* timer;
-       sttd_cliet_get_timer(uid, &timer);
+       /* Notify uid state change */
+       sttdc_send_set_state(uid, APP_STATE_RECORDING);
 
-       if (NULL != timer)
-               ecore_timer_del(timer);
+       SLOG(LOG_DEBUG, TAG_STTD, "[Server SUCCESS] Start recognition");
+}
 
-       /* change uid state */
-       sttd_client_set_state(uid, APP_STATE_PROCESSING);
+void __sttd_start_sound_completed_cb(int id, void *user_data)
+{
+       SLOG(LOG_DEBUG, TAG_STTD, "===== Start sound completed");
 
-       timer = ecore_timer_add(g_state_check_time, __time_out_for_processing, NULL);
-       sttd_cliet_set_timer(uid, timer);
+       int uid = (int)user_data;
+       /* 4. after wav play callback, recorder start */
+       __sttd_server_recorder_start(uid);
 
-       return STTD_ERROR_NONE;
+       SLOG(LOG_DEBUG, TAG_STTD, "=====");
+       SLOG(LOG_DEBUG, TAG_STTD, "  ");
+       return;
 }
 
-/******************************************************************************************
-* STT Server Functions for setting
-*******************************************************************************************/
-
-int sttd_server_setting_initialize(int pid)
+int sttd_server_start(int uid, const char* lang, const char* recognition_type, int silence, const char* appid)
 {
-       if (false == g_is_engine) {
-               if (0 != sttd_engine_agent_initialize_current_engine()) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] No Engine"); 
-                       g_is_engine = false;
-                       return STTD_ERROR_ENGINE_NOT_FOUND;
-               } else {
-                       g_is_engine = true;
-               }
+       if (NULL == lang || NULL == recognition_type) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Input parameter is NULL");
+               return STTD_ERROR_INVALID_PARAMETER;
        }
 
-       /* check whether pid is valid */
-       if (true == sttd_setting_client_is(pid)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Setting pid is NOT valid "); 
+       /* check if uid is valid */
+       app_state_e state;
+       if (0 != sttd_client_get_state(uid, &state)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid ");
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
-       /* load if engine is unloaded */
-       if (0 == sttd_client_get_ref_count()) {
-               if (0 != sttd_engine_agent_load_current_engine()) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to load current engine"); 
-                       return STTD_ERROR_OPERATION_FAILED;
-               }
-
-               /* set type, channel, sample rate */
-               sttp_audio_type_e atype;
-               int rate;
-               int channels;
+       /* check uid state */
+       if (APP_STATE_READY != state) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] sttd_server_start : current state is not ready");
+               return STTD_ERROR_INVALID_STATE;
+       }
 
-               if (0 != sttd_engine_get_audio_format(&atype, &rate, &channels)) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to get audio format of engine."); 
+       int ret = 0;
+       if (false == stt_client_get_app_agreed(uid)) {
+               bool temp = false;
+               ret = sttd_engine_agent_check_app_agreed(uid, appid, &temp);
+               if (0 != ret) {
+                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to get engine available : %d", ret);
                        return STTD_ERROR_OPERATION_FAILED;
                }
 
-               if (0 != sttd_recorder_create(audio_recorder_callback, atype, channels, rate)) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to set recorder"); 
-                       return STTD_ERROR_OPERATION_FAILED;
+               if (false == temp) {
+                       SLOG(LOG_ERROR, TAG_STTD, "[Server] App(%s) NOT confirmed that engine is available", appid);
+                       return STTD_ERROR_PERMISSION_DENIED;
                }
 
-               SLOG(LOG_DEBUG, TAG_STTD, "[Server] audio type(%d), channel(%d)", (int)atype, (int)channels);
+               stt_client_set_app_agreed(uid);
        }
 
-       /* Add setting client information to client manager (For internal use) */
-       if (0 != sttd_setting_client_add(pid)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to add setting client"); 
-               return STTD_ERROR_OPERATION_FAILED;
+       /* check if engine use network */
+       if (true == sttd_engine_agent_need_network(uid)) {
+               if (false == stt_network_is_connected()) {
+                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Disconnect network. Current engine needs to network connection.");
+                       return STTD_ERROR_OUT_OF_NETWORK;
+               }
        }
 
-       return STTD_ERROR_NONE;
-}
-
-int sttd_server_setting_finalize(int pid)
-{
-       /* Remove client information */
-       if (0 != sttd_setting_client_delete(pid)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to delete setting client"); 
+       char* sound = NULL;
+       if (0 != sttd_client_get_start_sound(uid, &sound)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to get start beep sound");
+               return STTD_ERROR_OPERATION_FAILED;
        }
 
-       /* unload engine, if ref count of client is 0 */
-       if (0 == sttd_client_get_ref_count()) {
-               sttd_recorder_destroy();
-
-               ecore_timer_add(0, __quit_ecore_loop, NULL);
+       if (0 != stt_client_set_current_recognition(uid)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Current STT is busy because of recording or processing");
+               if (NULL != sound)      free(sound);
+               return STTD_ERROR_RECORDER_BUSY;
        }
 
-       return STTD_ERROR_NONE;
-}
+       /* engine start recognition */
+       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Server] start : uid(%d), lang(%s), recog_type(%s)", 
+                       uid, lang, recognition_type);
+       if (NULL != sound)
+               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Server] start sound : %s", sound);
 
-int sttd_server_setting_get_engine_list(int pid, GList** engine_list)
-{
-       /* check whether pid is valid */
-       if (true != sttd_setting_client_is(pid)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Setting pid is NOT valid "); 
-               return STTD_ERROR_INVALID_PARAMETER;
+       /* 1. Set audio session */
+       ret = sttd_recorder_set_audio_session();
+       if (0 != ret) {
+               stt_client_unset_current_recognition();
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to set session : %d", ret);
+               if (NULL != sound)      free(sound);
+               return ret;
        }
 
-       if (NULL == engine_list) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Input parameter is NULL"); 
-               return STTD_ERROR_INVALID_PARAMETER;
+       bool is_sound_done = false;
+
+       /* 2. Request wav play */
+       if (NULL != sound) {
+               int id = 0;
+               ret = wav_player_start(sound, SOUND_TYPE_MEDIA, __sttd_start_sound_completed_cb, (void*)uid, &id);
+               if (WAV_PLAYER_ERROR_NONE != ret) {
+                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to play wav");
+                       is_sound_done = true;
+               }
+               free(sound);
+               sound = NULL;
+       } else {
+               is_sound_done = true;
        }
 
-       int ret = sttd_engine_setting_get_engine_list(engine_list); 
+       /* 3. Create recorder & engine initialize */
+       ret = sttd_engine_agent_recognize_start_engine(uid, lang, recognition_type, silence, NULL);
        if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to get engine list : result(%d)", ret); 
+               stt_client_unset_current_recognition();
+               sttd_recorder_unset_audio_session();
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to start recognition : result(%d)", ret);
                return ret;
        }
 
-       return STTD_ERROR_NONE;
-}
-
-int sttd_server_setting_get_engine(int pid, char** engine_id)
-{
-       /* check whether pid is valid */
-       if (true != sttd_setting_client_is(pid)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Setting pid is NOT valid "); 
-               return STTD_ERROR_INVALID_PARAMETER;
+       if (0 != strcmp(STTP_RECOGNITION_TYPE_FREE_PARTIAL, recognition_type)) {
+               g_recording_timer = ecore_timer_add(g_recording_timeout, __stop_by_recording_timeout, NULL);
        }
 
-       if (NULL == engine_id) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Input parameter is NULL"); 
-               return STTD_ERROR_INVALID_PARAMETER;
-       }
+       /* change uid state */
+       sttd_client_set_state(uid, APP_STATE_RECORDING);
 
-       /* get engine */
-       int ret = sttd_engine_setting_get_engine(engine_id); 
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to get engine : result(%d)", ret); 
-               return ret;
-       }
+       g_recording_log_count = 0;
 
-       return STTD_ERROR_NONE;
-}
+       if (true == is_sound_done) {
+               SLOG(LOG_DEBUG, TAG_STTD, "[Server] No sound play");
 
-int sttd_server_setting_set_engine(int pid, const char* engine_id)
-{
-       /* check whether pid is valid */
-       if (true != sttd_setting_client_is(pid)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Setting pid is NOT valid "); 
-               return STTD_ERROR_INVALID_PARAMETER;
-       }
+               ret = sttd_engine_agent_recognize_start_recorder(uid);
+               if (0 != ret) {
+                       stt_client_unset_current_recognition();
+                       sttd_recorder_unset_audio_session();
 
-       if (NULL == engine_id) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Input parameter is NULL"); 
-               return STTD_ERROR_INVALID_PARAMETER;
-       }
+                       sttd_engine_agent_recognize_cancel(uid);
+                       ecore_timer_del(g_recording_timer);
+                       sttd_client_set_state(uid, APP_STATE_READY);
 
-       /* set engine */
-       int ret = sttd_engine_setting_set_engine(engine_id); 
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to set engine : result(%d)", ret); 
-               return ret;
+                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to start recorder : result(%d)", ret);
+                       return STTD_ERROR_OPERATION_FAILED;
+               }
+
+               SLOG(LOG_DEBUG, TAG_STTD, "[Server SUCCESS] Start recognition");
+               return STTD_RESULT_STATE_DONE;
        }
 
-       return STTD_ERROR_NONE;
+       SLOG(LOG_DEBUG, TAG_STTD, "[Server] Wait sound finish");
+
+       return STTD_RESULT_STATE_NOT_DONE;
 }
 
-int sttd_server_setting_get_lang_list(int pid, char** engine_id, GList** lang_list)
+Eina_Bool __time_out_for_processing(void *data)
 {
-       /* check whether pid is valid */
-       if (true != sttd_setting_client_is(pid)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Setting pid is NOT valid "); 
-               return STTD_ERROR_INVALID_PARAMETER;
-       }
-       
-       if (NULL == lang_list) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] language is NULL"); 
-               return STTD_ERROR_INVALID_PARAMETER;
-       }
-       
-       int ret = sttd_engine_setting_get_lang_list(engine_id, lang_list); 
+       g_processing_timer = NULL;
+
+       /* current uid */
+       int uid = stt_client_get_current_recognition();
+       if (0 == uid)   return EINA_FALSE;
+
+       /* Cancel engine */
+       int ret = sttd_engine_agent_recognize_cancel(uid);
        if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to get language list : result(%d)", ret); 
-               return ret;
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to cancel : result(%d)", ret);
        }
 
-       return STTD_ERROR_NONE;
-}
+       if (0 != sttdc_send_result(uid, STTP_RESULT_EVENT_FINAL_RESULT, NULL, 0, "Time out not to receive recognition result.")) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to send result ");
 
-int sttd_server_setting_get_default_language(int pid, char** language)
-{
-       /* check whether pid is valid */
-       if (true != sttd_setting_client_is(pid)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Setting pid is NOT valid "); 
-               return STTD_ERROR_INVALID_PARAMETER;
+               /* send error msg */
+               int reason = (int)STTD_ERROR_TIMED_OUT; 
+               if (0 != sttdc_send_error_signal(uid, reason, "[ERROR] Fail to send recognition result")) {
+                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to send error info ");
+               }
        }
 
-       if (NULL == language) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] language is NULL"); 
-               return STTD_ERROR_INVALID_PARAMETER;
-       }
+       /* Change uid state */
+       sttd_client_set_state(uid, APP_STATE_READY);
 
-       int ret = sttd_engine_setting_get_default_lang(language); 
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to get default language : result(%d)", ret); 
-               return ret;
-       }       
+       stt_client_unset_current_recognition();
 
-       return STTD_ERROR_NONE;
+       return EINA_FALSE;
 }
 
-int sttd_server_setting_set_default_language(int pid, const char* language)
+void __sttd_server_engine_stop(int uid)
 {
-       /* check whether pid is valid */
-       if (true != sttd_setting_client_is(pid)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Setting pid is NOT valid "); 
-               return STTD_ERROR_INVALID_PARAMETER;
-       }
+       /* change uid state */
+       sttd_client_set_state(uid, APP_STATE_PROCESSING);
 
-       if (NULL == language) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] language is NULL"); 
-               return STTD_ERROR_INVALID_PARAMETER;
+       /* Notify uid state change */
+       sttdc_send_set_state(uid, APP_STATE_PROCESSING);
+
+       /* Unset audio session */
+       int ret = sttd_recorder_unset_audio_session();
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to unset session : %d", ret);
+               return;
        }
 
-       int ret = sttd_engine_setting_set_default_lang((char*)language); 
+       /* Stop engine */
+       ret = sttd_engine_agent_recognize_stop_engine(uid);
        if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to set default lang : result(%d)", ret); 
-               return ret;
-       }       
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to stop engine : result(%d)", ret);
+               return;
+       }
 
-       return STTD_ERROR_NONE;
+       SLOG(LOG_DEBUG, TAG_STTD, "[Server SUCCESS] Stop recognition");
 }
 
-int sttd_server_setting_get_profanity_filter(int pid, bool* value)
+void __sttd_stop_sound_completed_cb(int id, void *user_data)
 {
-       /* check whether pid is valid */
-       if (true != sttd_setting_client_is(pid)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Setting pid is NOT valid "); 
-               return STTD_ERROR_INVALID_PARAMETER;
-       }
-
-       if (NULL == value) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Input parameter is NULL"); 
-               return STTD_ERROR_INVALID_PARAMETER;
-       }
+       SLOG(LOG_DEBUG, TAG_STTD, "===== Stop sound completed");
 
-       int ret = 0;
-       ret = sttd_engine_setting_get_profanity_filter(value);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to get profanity filter : result(%d)", ret); 
-               return ret;
-       }       
+       int uid = (int)user_data;
+       /* After wav play callback, engine stop */
+       __sttd_server_engine_stop(uid);
 
-       return STTD_ERROR_NONE;
+       SLOG(LOG_DEBUG, TAG_STTD, "=====");
+       SLOG(LOG_DEBUG, TAG_STTD, "  ");
+       return;
 }
 
-int sttd_server_setting_set_profanity_filter(int pid, bool value)
+int sttd_server_stop(int uid)
 {
-       /* check whether pid is valid */
-       if (true != sttd_setting_client_is(pid)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Setting pid is NOT valid "); 
+       /* check if uid is valid */
+       app_state_e state;
+       if (0 != sttd_client_get_state(uid, &state)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid ");
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
-       int ret = 0;
-       ret = sttd_engine_setting_set_profanity_filter(value);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to set profanity filter: result(%d)", ret); 
-               return ret;
-       }       
-
-       return STTD_ERROR_NONE;
-}
+       /* check uid state */
+       if (APP_STATE_RECORDING != state) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Current state is not recording");
+               return STTD_ERROR_INVALID_STATE;
+       }
 
-int sttd_server_setting_get_punctuation_override(int pid, bool* value)
-{
-       /* check whether pid is valid */
-       if (true != sttd_setting_client_is(pid)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Setting pid is NOT valid "); 
-               return STTD_ERROR_INVALID_PARAMETER;
+       if (NULL != g_recording_timer)  {
+               ecore_timer_del(g_recording_timer);
+               g_recording_timer = NULL;
        }
 
-       if (NULL == value) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Input parameter is NULL"); 
-               return STTD_ERROR_INVALID_PARAMETER;
+       char* sound = NULL;
+       if (0 != sttd_client_get_stop_sound(uid, &sound)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to get start beep sound"); 
+               return STTD_ERROR_OPERATION_FAILED;
        }
 
-       int ret = 0;
-       ret = sttd_engine_setting_get_punctuation_override(value);
+       SLOG(LOG_DEBUG, TAG_STTD, "[Server] stop sound path : %s", sound);
+
+       int ret;
+       /* 1. Stop recorder */
+       ret = sttd_engine_agent_recognize_stop_recorder(uid);
        if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to get punctuation override : result(%d)", ret); 
-               return ret;
-       }       
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to stop recorder : result(%d)", ret);
+               if (0 != sttd_engine_agent_recognize_cancel(uid)) {
+                               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to cancel recognize");
+               }
+               if (NULL != sound)      free(sound);
+               return STTD_ERROR_OPERATION_FAILED;
+       }
 
-       return STTD_ERROR_NONE;
-}
+       /* 2. Request wav play */
+       if (NULL != sound) {
+               int id = 0;
+               ret = wav_player_start(sound, SOUND_TYPE_MEDIA, __sttd_stop_sound_completed_cb, (void*)uid, &id);
+               if (WAV_PLAYER_ERROR_NONE != ret) {
+                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to play wav");
+               } else {
+                       SLOG(LOG_DEBUG, TAG_STTD, "[Server] Play wav : %s", sound);
+               }
 
-int sttd_server_setting_set_punctuation_override(int pid, bool value)
-{
-       /* check whether pid is valid */
-       if (true != sttd_setting_client_is(pid)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Setting pid is NOT valid "); 
-               return STTD_ERROR_INVALID_PARAMETER;
-       }
+               free(sound);
 
-       int ret = 0;
-       ret = sttd_engine_setting_set_punctuation_override(value);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to set punctuation override : result(%d)", ret); 
-               return ret;
-       }       
+               g_processing_timer = ecore_timer_add(g_processing_timeout, __time_out_for_processing, NULL);
 
-       return STTD_ERROR_NONE;
-}
+               return STTD_RESULT_STATE_NOT_DONE;
+       } else {
+               SLOG(LOG_DEBUG, TAG_STTD, "[Server] No sound play");
 
-int sttd_server_setting_get_silence_detection(int pid, bool* value)
-{
-       /* check whether pid is valid */
-       if (true != sttd_setting_client_is(pid)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Setting pid is NOT valid "); 
-               return STTD_ERROR_INVALID_PARAMETER;
-       }
+               /* Unset audio session */
+               ret = sttd_recorder_unset_audio_session();
+               if (0 != ret) {
+                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to unset session : %d", ret);
+                       return STTD_ERROR_OPERATION_FAILED;
+               }
 
-       if (NULL == value) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Input parameter is NULL"); 
-               return STTD_ERROR_INVALID_PARAMETER;
-       }
+               /* Stop engine */
+               ret = sttd_engine_agent_recognize_stop_engine(uid);
+               if (0 != ret) {
+                       stt_client_unset_current_recognition();
+                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to stop engine : result(%d)", ret);
+                       return STTD_ERROR_OPERATION_FAILED;
+               }
 
-       int ret = 0;
-       ret = sttd_engine_setting_get_silence_detection(value);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to get silence detection : result(%d)", ret); 
-               return ret;
-       }       
+               /* change uid state */
+               sttd_client_set_state(uid, APP_STATE_PROCESSING);
+
+               SLOG(LOG_DEBUG, TAG_STTD, "[Server SUCCESS] Stop recognition");
+               
+               g_processing_timer = ecore_timer_add(g_processing_timeout, __time_out_for_processing, NULL);
+
+               return STTD_RESULT_STATE_DONE;
+       }
 
        return STTD_ERROR_NONE;
 }
 
-int sttd_server_setting_set_silence_detection(int pid, bool value)
+int sttd_server_cancel(int uid)
 {
-       /* check whether pid is valid */
-       if (true != sttd_setting_client_is(pid)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Setting pid is NOT valid "); 
+       /* check if uid is valid */
+       app_state_e state;
+       if (0 != sttd_client_get_state(uid, &state)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid ");
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
-       int ret = 0;
-       ret = sttd_engine_setting_set_silence_detection(value);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to Result(%d)", ret); 
-               return ret;
-       }       
+       /* check uid state */ 
+       if (APP_STATE_READY == state) {
+               SLOG(LOG_WARN, TAG_STTD, "[Server WARNING] Current state is ready");
+               return STTD_ERROR_NONE;
+       }
 
-       return STTD_ERROR_NONE;
-}
+       stt_client_unset_current_recognition();
 
-int sttd_server_setting_get_engine_setting(int pid, char** engine_id, GList** lang_list)
-{      
-       /* check whether pid is valid */
-       if (true != sttd_setting_client_is(pid)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Setting pid is NOT valid "); 
-               return STTD_ERROR_INVALID_PARAMETER;
+       if (NULL != g_recording_timer) {
+               ecore_timer_del(g_recording_timer);
+               g_recording_timer = NULL;
        }
 
-       if (0 != sttd_engine_setting_get_engine_setting_info(engine_id, lang_list)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to get engine setting info"); 
-               return STTD_ERROR_OPERATION_FAILED;
+       if (NULL != g_processing_timer) {
+               ecore_timer_del(g_processing_timer);
+               g_processing_timer = NULL;
        }
 
-       return STTD_ERROR_NONE;
-}
-
-int sttd_server_setting_set_engine_setting(int pid, const char* key, const char* value)
-{      
-       /* check whether pid is valid */
-       if (true != sttd_setting_client_is(pid)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Setting pid is NOT valid "); 
-               return STTD_ERROR_INVALID_PARAMETER;
+       if (APP_STATE_RECORDING == state) {
+               /* Unset audio session */
+               int ret = sttd_recorder_unset_audio_session();
+               if (0 != ret) {
+                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to unset session : %d", ret);
+                       return STTD_ERROR_OPERATION_FAILED;
+               }               
        }
 
-       if (0 != sttd_engine_setting_set_engine_setting(key, value)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to set engine setting info"); 
+       /* change uid state */
+       sttd_client_set_state(uid, APP_STATE_READY);
+
+       /* cancel engine recognition */
+       int ret = sttd_engine_agent_recognize_cancel(uid);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to cancel : result(%d)", ret);
                return STTD_ERROR_OPERATION_FAILED;
        }
 
index 6fe4c96..ac32122 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
@@ -32,68 +32,45 @@ int sttd_finalize();
 
 Eina_Bool sttd_cleanup_client(void *data);
 
+Eina_Bool sttd_get_daemon_exist();
+
 /*
 * API for client
 */
 
-int sttd_server_initialize(int pid, int uid, bool* silence, bool* profanity, bool* punctuation);
+int sttd_server_initialize(int pid, int uid, bool* silence);
 
 int sttd_server_finalize(int uid);
 
-int sttd_server_get_supported_languages(int uid, GList** lang_list);
-
-int sttd_server_get_current_langauage(int uid, char** current_lang);
-
-int sttd_server_set_engine_data(int uid, const char* key, const char* value);
-
-int sttd_server_is_partial_result_supported(int uid, int* partial_result);
-
-int sttd_server_get_audio_volume(int uid, float* current_volume);
-
-int sttd_server_start(int uid, const char* lang, const char* recognition_type, 
-                       int profanity, int punctuation, int silence);
-
-int sttd_server_stop(int uid);
-
-int sttd_server_cancel(int uid);
-
-int sttd_server_start_file_recognition(int uid, const char* filepath, const char* lang, const char* type, 
-                                      int profanity, int punctuation);
-/*
-* API for setting
-*/
-
-int sttd_server_setting_initialize(int pid);
+int sttd_server_get_supported_engines(int uid, GSList** engine_list);
 
-int sttd_server_setting_finalize(int pid);
+int sttd_server_set_current_engine(int uid, const char* engine_id, bool* silence);
 
-int sttd_server_setting_get_engine_list(int pid, GList** engine_list);
+int sttd_server_get_current_engine(int uid, char** engine_id);
 
-int sttd_server_setting_get_engine(int pid, char** engine_id);
+int sttd_server_check_agg_agreed(int uid, const char* appid, bool* available);
 
-int sttd_server_setting_set_engine(int pid, const char* engine_id);
+int sttd_server_get_supported_languages(int uid, GSList** lang_list);
 
-int sttd_server_setting_get_lang_list(int pid, char** engine_id, GList** lang_list);
+int sttd_server_get_current_langauage(int uid, char** current_lang);
 
-int sttd_server_setting_get_default_language(int pid, char** language);
+int sttd_server_set_engine_data(int uid, const char* key, const char* value);
 
-int sttd_server_setting_set_default_language(int pid, const char* language);
+int sttd_server_is_recognition_type_supported(int uid, const char* type, int* support);
 
-int sttd_server_setting_get_profanity_filter(int pid, bool* value);
+int sttd_server_set_start_sound(int uid, const char* file);
 
-int sttd_server_setting_set_profanity_filter(int pid, bool value);
+int sttd_server_set_stop_sound(int uid, const char* file);
 
-int sttd_server_setting_get_punctuation_override(int pid, bool* value);
 
-int sttd_server_setting_set_punctuation_override(int pid, bool value);
+int sttd_server_get_audio_volume(int uid, float* current_volume);
 
-int sttd_server_setting_get_silence_detection(int pid, bool* value);
+int sttd_server_start(int uid, const char* lang, const char* recognition_type, int silence, const char* appid);
 
-int sttd_server_setting_set_silence_detection(int pid, bool value);
+int sttd_server_stop(int uid);
 
-int sttd_server_setting_get_engine_setting(int pid, char** engine_id, GList** lang_list);
+int sttd_server_cancel(int uid);
 
-int sttd_server_setting_set_engine_setting(int pid, const char* key, const char* value);
 
 
 #ifdef __cplusplus
index 5f6814d..13e03ae 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
@@ -53,55 +53,58 @@ typedef enum {
 * @brief Enumerations of callback event.
 */
 typedef enum {
-       STTP_RESULT_EVENT_SUCCESS = 0,  /**< Event when the recognition full result is ready  */
-       STTP_RESULT_EVENT_NO_RESULT,    /**< Event when the recognition result is not */
-       STTP_RESULT_EVENT_ERROR         /**< Event when the recognition has failed */
+       STTP_RESULT_EVENT_FINAL_RESULT = 0,     /**< Event when the recognition full or last result is ready  */
+       STTP_RESULT_EVENT_PARTIAL_RESULT,       /**< Event when the recognition partial result is ready  */
+       STTP_RESULT_EVENT_ERROR                 /**< Event when the recognition has failed */
 }sttp_result_event_e;
 
-/** 
-* @brief Recognition type : free form dictation or default type.
+/**
+* @brief Enumerations of result time callback event.
 */
-#define STTP_RECOGNITION_TYPE_FREE                     "stt.recognition.type.FREE"
+typedef enum {
+       STTP_RESULT_TIME_EVENT_BEGINNING = 0,   /**< Event when the token is beginning type */
+       STTP_RESULT_TIME_EVENT_MIDDLE,          /**< Event when the token is middle type */
+       STTP_RESULT_TIME_EVENT_END              /**< Event when the token is end type */
+}sttp_result_time_event_e;
 
-/** 
-* @brief Recognition type : web search. 
+/**
+* @brief Enumerations of silence type.
 */
-#define STTP_RECOGNITION_TYPE_WEB_SEARCH               "stt.recognition.type.WEB_SEARCH"
+typedef enum {
+       STTP_SILENCE_TYPE_NO_RECORD_TIMEOUT = 0,        /**< No sound is recorded */
+       STTP_SILENCE_TYPE_END_OF_SPEECH_DETECTED        /**< End of speech is detected */
+}sttp_silence_type_e;
 
 /** 
-* @brief Result message : None message
+* @brief Recognition type : free form dictation and default type.
 */
-#define STTP_RESULT_MESSAGE_NONE               "stt.result.message.none"
+#define STTP_RECOGNITION_TYPE_FREE             "stt.recognition.type.FREE"
 
 /** 
-* @brief Result warning message : The speech has started too soon
+* @brief Recognition type : free form dictation continuously. 
 */
-#define STTP_RESULT_MESSAGE_WARNING_TOO_SOON   "stt.result.message.warning.too.soon"
+#define STTP_RECOGNITION_TYPE_FREE_PARTIAL     "stt.recognition.type.FREE.PARTIAL"
 
-/** 
-* @brief Result warning message : The speech is too short
+/**
+* @brief Recognition type : Search. 
 */
-#define STTP_RESULT_MESSAGE_WARNING_TOO_SHORT  "stt.result.message.warning.too.short"
+#define STTP_RECOGNITION_TYPE_SEARCH           "stt.recognition.type.SEARCH"
 
 /** 
-* @brief Result warning message : The speech is too long
+* @brief Recognition type : web search. 
 */
-#define STTP_RESULT_MESSAGE_WARNING_TOO_LONG   "stt.result.message.warning.too.long"
+#define STTP_RECOGNITION_TYPE_WEB_SEARCH       "stt.recognition.type.WEB_SEARCH"
 
-/** 
-* @brief Result warning message : The speech is too quiet to listen
+/**
+* @brief Recognition type : Map. 
 */
-#define STTP_RESULT_MESSAGE_WARNING_TOO_QUIET  "stt.result.message.warning.too.quiet"
+#define STTP_RECOGNITION_TYPE_MAP              "stt.recognition.type.MAP"
 
-/** 
-* @brief Result warning message : The speech is too loud to listen
-*/
-#define STTP_RESULT_MESSAGE_WARNING_TOO_LOUD   "stt.result.message.warning.too.loud"
 
 /** 
-* @brief Result warning message : The speech is too fast to listen
+* @brief Result message : None message
 */
-#define STTP_RESULT_MESSAGE_WARNING_TOO_FAST   "stt.result.message.warning.too.fast"
+#define STTP_RESULT_MESSAGE_NONE               "stt.result.message.none"
 
 /** 
 * @brief Result error message : Recognition was failed because the speech started too soon
@@ -137,10 +140,10 @@ typedef enum {
 * @brief Called to get recognition result.
 * 
 * @param[in] event A result event
-* @param[in] type A recognition type (e.g. #STTP_RECOGNITION_TYPE_FREE, #STTP_RECOGNITION_TYPE_COMMAND)
+* @param[in] type A recognition type (e.g. #STTP_RECOGNITION_TYPE_FREE, #STTP_RECOGNITION_TYPE_FREE_PARTIAL)
 * @param[in] data Result texts
 * @param[in] data_count Result text count
-* @param[in] msg Engine message (e.g. #STTP_RESULT_MESSAGE_WARNING_TOO_SOON, #STTP_RESULT_MESSAGE_ERROR_TOO_SHORT)
+* @param[in] msg Engine message (e.g. #STTP_RESULT_MESSAGE_NONE, #STTP_RESULT_MESSAGE_ERROR_TOO_SHORT)
 * @param[in] user_data The user data passed from the start function
 *
 * @pre sttpe_stop() will invoke this callback.
@@ -148,21 +151,27 @@ typedef enum {
 * @see sttpe_start()
 * @see sttpe_stop()
 */
-typedef void (*sttpe_result_cb)(sttp_result_event_e event, const char* type, 
-                               const char** data, int data_count, const char* msg, void *user_data);
+typedef void (*sttpe_result_cb)(sttp_result_event_e event, const char* type, const char** data, int data_count, 
+                               const char* msg, void* time_info, void* user_data);
 
-/** 
-* @brief Called to get partial recognition result.
-* 
-* @param[in] event A result event
-* @param[in] data A result text
-* @param[in] user_data The user data passed from the start function.
+/**
+* @brief Called to retrieve the time stamp of result. 
 *
-* @pre sttpe_set_recording_data() will invoke this callback
+* @param[in] index The result index
+* @param[in] event The token event
+* @param[in] text The result text
+* @param[in] start_time The start time of result text
+* @param[in] end_time The end time of result text
+* @param[in] user_data The user data passed from the foreach function
 *
-* @see sttpe_set_recording_data()
+* @return @c true to continue with the next iteration of the loop \n @c false to break out of the loop
+*
+* @pre sttpe_result_cb() should be called. 
+*
+* @see sttpe_result_cb()
 */
-typedef void (*sttpe_partial_result_cb)(sttp_result_event_e event, const char* data, void *user_data);
+typedef bool (*sttpe_result_time_cb)(int index, sttp_result_time_event_e event, const char* text, 
+                               long start_time, long end_time, void* user_data);
 
 /** 
 * @brief Called to detect silence from recording data.
@@ -173,7 +182,7 @@ typedef void (*sttpe_partial_result_cb)(sttp_result_event_e event, const char* d
 *
 * @see sttpe_set_recording_data()
 */
-typedef void (*sttpe_silence_detected_cb)(void *user_data);
+typedef void (*sttpe_silence_detected_cb)(sttp_silence_type_e type, void* user_data);
 
 /**
 * @brief Called to retrieve the supported languages. 
@@ -192,24 +201,9 @@ typedef void (*sttpe_silence_detected_cb)(void *user_data);
 typedef bool (*sttpe_supported_language_cb)(const char* language, void* user_data);
 
 /**
-* @brief Called to retrieve the supported engine settings.
-*
-* @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 sttpe_foreach_engine_settings() will invoke this callback. 
-*
-* @see sttpe_foreach_engine_settings()
-*/
-typedef bool (*sttpe_engine_setting_cb)(const char* key, const char* value, void* user_data);
-
-/**
 * @brief Initializes the engine.
 *
 * @param[in] result_cb A callback function for recognition result
-* @param[in] partial_result_cb A callback function for partial recognition result
 * @param[in] silence_cb A callback function for silence detection
 *
 * @return 0 on success, otherwise a negative error value
@@ -220,8 +214,7 @@ typedef bool (*sttpe_engine_setting_cb)(const char* key, const char* value, void
 * 
 * @see sttpe_deinitialize()
 */
-typedef int (* sttpe_initialize)(sttpe_result_cb result_cb, sttpe_partial_result_cb partial_result_cb, 
-                                sttpe_silence_detected_cb silence_cb);
+typedef int (* sttpe_initialize)(sttpe_result_cb result_cb, sttpe_silence_detected_cb silence_cb);
 
 /**
 * @brief Deinitializes the engine
@@ -249,17 +242,14 @@ typedef int (* sttpe_deinitialize)(void);
 *
 * @see sttpe_supported_language_cb()
 */
-typedef int (* sttpe_foreach_supported_languages)(sttpe_supported_language_cb callback, void* user_data);
+typedef int (* sttpe_foreach_supported_langs)(sttpe_supported_language_cb callback, void* user_data);
 
 /**
 * @brief Checks whether a language is valid or not.
 *
 * @param[in] language A language
 *
-* @return 0 on success, otherwise a negative error value
-* @retval #STTP_ERROR_NONE Successful
-* @retval #STTP_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #STTP_ERROR_INVALID_STATE Not initialized
+* @return @c true to valid language, \n @c false to invalid language.
 *
 * @see sttpe_foreach_supported_languages()
 */
@@ -268,20 +258,19 @@ typedef bool (* sttpe_is_valid_language)(const char* language);
 /**
 * @brief Gets whether the engine supports silence detection. 
 *
-* @return 0 on success, otherwise a negative error value
-* @retval #STTP_ERROR_NONE Successful
-* @retval #STTP_ERROR_INVALID_STATE Not initialized
+* @return @c true to support silence detection, \n @c false not to support silence detection.
+*
+* @see sttpe_set_silence_detection()
 */
 typedef bool (* sttpe_support_silence_detection)(void);
 
 /**
-* @brief Gets supporting partial result. 
+* @brief Gets supporting recognition type. 
+*
+* @return @c true to support recognition type, \n @c false not to support recognition type.
 *
-* @return 0 on success, otherwise a negative error value
-* @retval #STTP_ERROR_NONE Successful
-* @retval #STTP_ERROR_INVALID_STATE Not initialized
 */
-typedef bool (* sttpe_support_partial_result)(void);
+typedef bool (* sttpe_support_recognition_type)(const char* type);
 
 /**
 * @brief Gets recording format of the engine. 
@@ -297,7 +286,7 @@ typedef bool (* sttpe_support_partial_result)(void);
 typedef int (* sttpe_get_recording_format)(sttp_audio_type_e* types, int* rate, int* channels);
 
 /**
-* @brief Sets profanity filter option.
+* @brief Sets silence detection option.
 * 
 * @param[in] value A value
 *
@@ -306,11 +295,12 @@ typedef int (* sttpe_get_recording_format)(sttp_audio_type_e* types, int* rate,
 * @retval #STTP_ERROR_INVALID_STATE Not initialized
 * @retval #STTP_ERROR_NOT_SUPPORTED_FEATURE Not supported feature
 */
-typedef int (* sttpe_set_profanity_filter)(bool value);
+typedef int (* sttpe_set_silence_detection)(bool value);
 
 /**
-* @brief Sets punctuation option.
+* @brief Gets whether application is agreed to get engine service.
 * 
+* @param[in] appid Application ID
 * @param[in] value A value
 *
 * @return 0 on success, otherwise a negative error value
@@ -318,19 +308,25 @@ typedef int (* sttpe_set_profanity_filter)(bool value);
 * @retval #STTP_ERROR_INVALID_STATE Not initialized
 * @retval #STTP_ERROR_NOT_SUPPORTED_FEATURE Not supported feature
 */
-typedef int (* sttpe_set_punctuation_override)(bool value);
+typedef int (* sttpe_check_app_agreed)(const char* appid, bool* value);
 
 /**
-* @brief Sets silence detection option.
-* 
-* @param[in] value A value
+* @brief Retrieves result time info in recognition callback of daemon.
+*
+* @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 #STTP_ERROR_NONE Successful
+* @retval #STTP_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #STTP_ERROR_INVALID_STATE Not initialized
-* @retval #STTP_ERROR_NOT_SUPPORTED_FEATURE Not supported feature
+*
+* @pre sttpe_result_cb() will be invoke this function.
+* @post        This function invokes sttpe_result_time_cb() repeatedly for getting result time information. 
+*
+* @see sttpe_result_time_cb()
 */
-typedef int (* sttpe_set_silence_detection)(bool value);
+typedef int (* sttpe_foreach_result_time)(void* time_info, sttpe_result_time_cb callback, void* user_data);
 
 /**
 * @brief Start recognition.
@@ -367,14 +363,14 @@ typedef int (* sttpe_start)(const char* language, const char* type, void *user_d
 * @retval #STTP_ERROR_NONE Successful
 * @retval #STTP_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #STTP_ERROR_INVALID_STATE Invalid state
+* @retval #STTP_ERROR_OPERATION_FAILED Operation failed
 *
 * @pre sttpe_start() should succeed.
-* @post If the engine supports partial result, it will invoke sttpe_partial_result_cb().
+* @post If the engine supports partial result, it will invoke sttpe_result_cb().
 *
 * @see sttpe_start()
 * @see sttpe_cancel()
 * @see sttpe_stop()
-* @see sttpe_partial_result_cb()
 */
 typedef int (* sttpe_set_recording_data)(const void* data, unsigned int length);
 
@@ -403,7 +399,7 @@ typedef int (* sttpe_stop)(void);
 * @return 0 on success, otherwise a negative error value.
 * @retval #STTP_ERROR_NONE Successful.
 * @retval #STTP_ERROR_INVALID_STATE Invalid state.
-* @pre STT engine is in recognition processing.
+* @pre STT engine is in recognition processing or recording.
 *
 * @see sttpe_start()
 * @see sttpe_stop()
@@ -411,11 +407,13 @@ typedef int (* sttpe_stop)(void);
 typedef int (* sttpe_cancel)(void);
 
 /**
-* @brief Convert file to text.
+* @brief Start recognition of file.
 *
-* @param[in] filepath Sound file. 
 * @param[in] language A language. 
 * @param[in] type A recognition type. (e.g. #STTP_RECOGNITION_TYPE_FREE, #STTP_RECOGNITION_TYPE_WEB_SEARCH)
+* @param[in] filepath A filepath for recognition.
+* @param[in] audio_type A audio type of file.
+* @param[in] sample_rate A sample rate of file.
 * @param[in] user_data The user data to be passed to the callback function. 
 *
 * @return 0 on success, otherwise a negative error value
@@ -428,44 +426,22 @@ typedef int (* sttpe_cancel)(void);
 *
 * @pre The engine is not in recognition processing.
 *
-* @see sttpe_result_cb()
-*/
-typedef int (* sttpe_start_file_recognition)(const char* filepath, const char* language, const char* type, void *user_data);
-
-/**
-* @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 #STTP_ERROR_NONE Successful
-* @retval #STTP_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #STTP_ERROR_INVALID_STATE Not initialized
-* @retval #STTP_ERROR_OPERATION_FAILED Operation failed
-*
-* @post        This function invokes sttpe_engine_setting_cb() repeatedly for getting engine settings. 
-*
-* @see sttpe_engine_setting_cb()
+* @see sttpe_cancel_file()
 */
-typedef int (* sttpe_foreach_engine_settings)(sttpe_engine_setting_cb callback, void* user_data);
+typedef int (* sttpe_start_file)(const char* language, const char* type, const char* filepath, 
+                                sttp_audio_type_e audio_type, int sample_rate, void *user_data);
 
 /**
-* @brief Set engine specific information. 
-*
-* @param[in] key A key
-* @param[in] value A value
+* @brief Cancels the recognition process of file.
 *
-* @return 0 on success, otherwise a negative error value
-* @retval #STTP_ERROR_NONE Successful
-* @retval #STTP_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #STTP_ERROR_INVALID_STATE Not initialized
-* @retval #STTP_ERROR_OPERATION_FAILED Operation failed
+* @return 0 on success, otherwise a negative error value.
+* @retval #STTP_ERROR_NONE Successful.
+* @retval #STTP_ERROR_INVALID_STATE Invalid state.
+* @pre STT engine is in recognition processing.
 *
-* @see sttpe_foreach_engine_settings()
+* @see sttpe_start_file()
 */
-typedef int (* sttpe_set_engine_setting)(const char* key, const char* value);
-
+typedef int (* sttpe_cancel_file)(void);
 
 /**
 * @brief A structure of the engine functions.
@@ -478,27 +454,28 @@ typedef struct {
        sttpe_deinitialize              deinitialize;           /**< Shutdown engine */
 
        /* Get engine information */
-       sttpe_foreach_supported_languages foreach_langs;        /**< Foreach language list */
+       sttpe_foreach_supported_langs   foreach_langs;          /**< Foreach language list */
        sttpe_is_valid_language         is_valid_lang;          /**< Check language */
        sttpe_support_silence_detection support_silence;        /**< Get silence detection support */
-       sttpe_support_partial_result    support_partial_result; /**< Get partial result support */
+       sttpe_support_recognition_type  support_recognition_type; /**< Get recognition type support */
        sttpe_get_recording_format      get_audio_format;       /**< Get audio format */
+       sttpe_foreach_result_time       foreach_result_time;    /**< Foreach result time */
        
        /* Set engine information */
-       sttpe_set_profanity_filter      set_profanity_filter;   /**< Set profanity filter */
-       sttpe_set_punctuation_override  set_punctuation;        /**< Set punctuation override */
        sttpe_set_silence_detection     set_silence_detection;  /**< Set silence detection */
 
+       /* Check app agreement */
+       sttpe_check_app_agreed          check_app_agreed;       /**< Get app agreement */
+
        /* Control recognition */
        sttpe_start                     start;                  /**< Start recognition */
        sttpe_set_recording_data        set_recording;          /**< Set recording data */
        sttpe_stop                      stop;                   /**< Shutdown function */
-       sttpe_cancel                    cancel;                 /**< Cancel recognition or cancel thinking */
-       sttpe_start_file_recognition    start_file_recognition; /**< Start file recognition */
-       
-       /* Engine setting */
-       sttpe_foreach_engine_settings   foreach_engine_settings;/**< Foreach engine specific info */
-       sttpe_set_engine_setting        set_engine_setting;     /**< Set engine specific info */
+       sttpe_cancel                    cancel;                 /**< Cancel recognition */
+
+       /* Control file recognition */
+       sttpe_start_file                start_file;             /**< Start recognition */
+       sttpe_cancel_file               cancel_file;            /**< Cancel recognition */
 } sttpe_funcs_s;
 
 /**
@@ -543,7 +520,7 @@ void sttp_unload_engine(void);
 *
 * @param[in] engine_uuid The engine id
 * @param[in] engine_name The engine name
-* @param[in] setting_ug_name The setting ug name
+* @param[in] engine_setting The setting name
 * @param[in] use_network @c true to need network @c false not to need network.
 * @param[in] user_data The User data passed from sttp_get_engine_info()
 *
@@ -551,7 +528,7 @@ void sttp_unload_engine(void);
 *
 * @see sttp_get_engine_info()
 */
-typedef void (*sttpe_engine_info_cb)(const char* engine_uuid, const char* engine_name, const char* setting_ug_name
+typedef void (*sttpe_engine_info_cb)(const char* engine_uuid, const char* engine_name, const char* engine_setting
                                     bool use_network, void* user_data);
 
 /**
diff --git a/stt-config.xml b/stt-config.xml
new file mode 100644 (file)
index 0000000..5f4108e
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<stt-config>
+        <engine>1D1AC768-D818-4E65-A732-3639D4759632</engine>
+        <engine-setting/>
+        <auto>on</auto>
+        <language>en_US</language>
+        <silence-detection>on</silence-detection>
+</stt-config>
diff --git a/sysinfo-stt.xml b/sysinfo-stt.xml
deleted file mode 100644 (file)
index 94a4ae4..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0"?>\r
-<sys-info>\r
-  <default>\r
-    <key id="stt-support" string="false"/>\r
-  </default>\r
-</sys-info>\r
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100644 (file)
index 0000000..e2b79e1
--- /dev/null
@@ -0,0 +1,27 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(stt-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} stt stt_file)
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /opt/usr/devel/bin)
diff --git a/test/test_main.c b/test/test_main.c
new file mode 100644 (file)
index 0000000..9b913e0
--- /dev/null
@@ -0,0 +1,294 @@
+/*
+*  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 <dlog/dlog.h>
+
+#include <stt.h>
+#include <stt_file.h>
+#include <unistd.h>
+
+#define TAG_STT_TEST "stt_test"
+
+static stt_h g_stt = NULL;
+
+static Eina_Bool __stt_test_finalize(void *data)
+{
+       int ret;
+       SLOG(LOG_DEBUG, TAG_STT_TEST, "Unset callbacks");
+       ret = stt_file_unset_recognition_result_cb();
+       if (STT_FILE_ERROR_NONE != ret) {
+               SLOG(LOG_ERROR, TAG_STT_TEST, "[ERROR] Fail to unset recognition cb");
+       }
+
+       SLOG(LOG_DEBUG, TAG_STT_TEST, "STT file deinitialize");
+       ret = stt_file_deinitialize();
+       if (STT_FILE_ERROR_NONE != ret) {
+               SLOG(LOG_ERROR, TAG_STT_TEST, "[ERROR] Fail to deinitialize");
+       }
+
+       ecore_main_loop_quit();
+
+       return EINA_FALSE;
+}
+
+static void __stt_file_state_changed_cb(stt_file_state_e previous, stt_file_state_e current, void* user_data)
+{
+}
+
+static bool __stt_file_supported_language_cb(const char* language, void* user_data)
+{
+       if (NULL == language)
+               return false;
+
+       SLOG(LOG_DEBUG, TAG_STT_TEST, "=== %s ===", language);
+       return true;
+}
+
+static bool __stt_file_result_time_cb(int index, stt_file_result_time_event_e event, const char* text,
+                                     long start_time, long end_time, void* user_data)
+{
+       if (NULL != text) {
+               SLOG(LOG_DEBUG, TAG_STT_TEST, "[%d] %s - %ld to %ld", index, text, start_time, end_time);
+               return true;
+       }
+       return false;
+}
+
+static void __stt_file_recognition_result_cb(stt_file_result_event_e event, const char** data, int data_count, const char* msg, void *user_data)
+{
+       SLOG(LOG_DEBUG, TAG_STT_TEST, "==== Result Callback ====");
+       if (STT_FILE_RESULT_EVENT_ERROR == event) {
+               SLOG(LOG_ERROR, TAG_STT_TEST, "[ERROR] Error Result");
+               ecore_timer_add(0, __stt_test_finalize, NULL);
+               return;
+       }
+
+       if (NULL != data) {
+               SLOG(LOG_DEBUG, TAG_STT_TEST, "( %s )", data[0]);
+       }
+
+
+       int ret;
+       ret = stt_file_foreach_detailed_result(__stt_file_result_time_cb, NULL);
+       if (STT_FILE_ERROR_NONE != ret) {
+               SLOG(LOG_ERROR, TAG_STT_TEST, "[ERROR] Fail to get result time");
+       }
+
+       if (STT_FILE_RESULT_EVENT_FINAL_RESULT == event) {
+               ecore_timer_add(0, __stt_test_finalize, NULL);
+       }
+
+       return;
+}
+
+static bool __supported_engine_cb(const char* engine_id, const char* engine_name, void* user_data)
+{
+       SLOG(LOG_DEBUG, TAG_STT_TEST, "Engine id(%s) name(%s)", engine_id, engine_name);
+
+       return true;
+}
+
+static Eina_Bool __get_engine_list(void *data)
+{
+       int ret;
+       SLOG(LOG_DEBUG, TAG_STT_TEST, "STT get engine list");
+       ret = stt_file_foreach_supported_engines(__supported_engine_cb, NULL);
+       if (STT_FILE_ERROR_NONE != ret) {
+               SLOG(LOG_ERROR, TAG_STT_TEST, "Fail to get engine list");
+       }
+
+       char *cur_engine;
+       SLOG(LOG_DEBUG, TAG_STT_TEST, "STT get engine");
+       ret = stt_file_get_engine(&cur_engine);
+       if (STT_FILE_ERROR_NONE != ret) {
+               SLOG(LOG_ERROR, TAG_STT_TEST, "[ERROR] Fail to get engine");
+               return EINA_FALSE;
+       }
+       
+       if (NULL != cur_engine) {
+               SLOG(LOG_DEBUG, TAG_STT_TEST, "Current engine - %s", cur_engine);
+               free(cur_engine);
+       }
+
+       return EINA_FALSE;
+}
+
+static Eina_Bool __file_start(void *data)
+{
+       char *tmp = (char *)data;
+       int ret;
+       SLOG(LOG_DEBUG, TAG_STT_TEST, "STT start file recognition");
+       ret = stt_file_start("en_US", "stt.recognition.type.FREE", tmp, STT_FILE_AUDIO_TYPE_RAW_S16, 16000);
+       if (STT_FILE_ERROR_NONE != ret) {
+               SLOG(LOG_ERROR, TAG_STT_TEST, "[ERROR] Fail to start");
+       }
+
+       return EINA_FALSE;
+}
+
+static Eina_Bool __stt_start(void *data)
+{
+       int ret;
+       SLOG(LOG_DEBUG, TAG_STT_TEST, "STT set silence detection");
+       ret = stt_set_silence_detection(g_stt, STT_OPTION_SILENCE_DETECTION_TRUE);
+       if (STT_ERROR_NONE != ret) {
+               SLOG(LOG_ERROR, TAG_STT_TEST, "[ERROR] Fail to set silence detection");
+       }
+
+       SLOG(LOG_DEBUG, TAG_STT_TEST, "STT start");
+       ret = stt_start(g_stt, "en_US", "stt.recognition.type.FREE");
+       if (STT_ERROR_NONE != ret) {
+               SLOG(LOG_ERROR, TAG_STT_TEST, "[ERROR] Fail to start");
+       }
+       return EINA_FALSE;
+}
+
+static void __stt_state_changed_cb(stt_h stt, stt_state_e previous, stt_state_e current, void* user_data)
+{
+       if (STT_STATE_CREATED == previous && STT_STATE_READY == current) {
+               SLOG(LOG_DEBUG, TAG_STT_TEST, "State is Created -> Ready");
+               ecore_timer_add(0, __stt_start, NULL);
+       }
+}
+
+static Eina_Bool __stt_finalize(void *data)
+{
+       int ret;
+       SLOG(LOG_DEBUG, TAG_STT_TEST, "STT destroy");
+       ret = stt_destroy(g_stt);
+       if (STT_ERROR_NONE != ret) {
+               SLOG(LOG_ERROR, TAG_STT_TEST, "[ERROR] Fail to stt destroy");
+       }
+
+       ecore_main_loop_quit();
+       return EINA_FALSE;
+}
+
+static void __stt_recognition_result_cb(stt_h stt, stt_result_event_e event, const char** data, int data_count, const char* msg, void *user_data)
+{
+       SLOG(LOG_DEBUG, TAG_STT_TEST, "==== STT result cb ====");
+
+       if (NULL != data) {
+               SLOG(LOG_DEBUG, TAG_STT_TEST, "( %s )", data[0]);
+       }
+
+       ecore_timer_add(0, __stt_finalize, NULL);
+}
+
+int main (int argc, char *argv[])
+{
+       if (2 < argc) {
+               SLOG(LOG_DEBUG, TAG_STT_TEST, "Please check parameter");
+               SLOG(LOG_DEBUG, TAG_STT_TEST, "Ex> stt-test -f <file path>");
+               SLOG(LOG_DEBUG, TAG_STT_TEST, "Ex> stt-test -m");
+               return 0;
+       }
+
+       if (strcmp("-f", argv[1]) && strcmp("-m", argv[1])) {
+               SLOG(LOG_DEBUG, TAG_STT_TEST, "Please check parameter");
+               SLOG(LOG_DEBUG, TAG_STT_TEST, "Ex> stt-test -f <file path>");
+               SLOG(LOG_DEBUG, TAG_STT_TEST, "Ex> stt-test -m");
+               return 0;
+       }
+
+       if (!strcmp("-f", argv[1])) {
+               if (0 != access(argv[2], F_OK)) {
+                       SLOG(LOG_DEBUG, TAG_STT_TEST, "Please check filepath");
+                       return 0;
+               }
+
+               SLOG(LOG_DEBUG, TAG_STT_TEST, "===== STT File (%s) Sample start =====", argv[2]);
+
+               if (!ecore_init()) {
+                       SLOG(LOG_ERROR, TAG_STT_TEST, "[Main ERROR] Fail ecore_init()");
+                       return 0;
+               }
+
+               int ret;
+               SLOG(LOG_DEBUG, TAG_STT_TEST, "STT File initialize");
+               ret = stt_file_initialize();
+               if (STT_FILE_ERROR_NONE != ret) {
+                       SLOG(LOG_ERROR, TAG_STT_TEST, "Fail to initialize");
+                       return 0;
+               }
+
+               SLOG(LOG_DEBUG, TAG_STT_TEST, "STT Set Callbacks");
+               ret = stt_file_set_recognition_result_cb(__stt_file_recognition_result_cb, NULL);
+               if (STT_FILE_ERROR_NONE != ret) {
+                       SLOG(LOG_ERROR, TAG_STT_TEST, "Fail to set recognition result cb");
+                       return 0;
+               }
+
+               ret = stt_file_set_state_changed_cb(__stt_file_state_changed_cb, NULL);
+               if (STT_FILE_ERROR_NONE != ret) {
+                       SLOG(LOG_ERROR, TAG_STT_TEST, "Fail to set state changed cb");
+                       return 0;
+               }
+
+               SLOG(LOG_DEBUG, TAG_STT_TEST, "Get supported langauge");
+               ret = stt_file_foreach_supported_languages(__stt_file_supported_language_cb, NULL);
+               if (STT_FILE_ERROR_NONE != ret) {
+                       SLOG(LOG_ERROR, TAG_STT_TEST, "Fail to get supported language");
+                       return 0;
+               }
+
+               ecore_timer_add(1, __get_engine_list, NULL);
+
+               char *tmp = strdup(argv[2]);
+               ecore_timer_add(1, __file_start, tmp);
+       } else if (!strcmp("-m", argv[1])) {
+
+               ecore_init();
+
+               int ret;
+
+               SLOG(LOG_DEBUG, TAG_STT_TEST, "STT Create");
+               ret = stt_create(&g_stt);
+               if (STT_ERROR_NONE != ret) {
+                       SLOG(LOG_ERROR, TAG_STT_TEST, "Fail to create");
+                       return 0;
+               }
+
+               SLOG(LOG_DEBUG, TAG_STT_TEST, "Set callback");
+               ret = stt_set_state_changed_cb(g_stt, __stt_state_changed_cb, NULL);
+               if (STT_ERROR_NONE != ret) {
+                       stt_destroy(g_stt);
+                       SLOG(LOG_ERROR, TAG_STT_TEST, "Fail to set state changed cb");
+                       return 0;
+               }
+               ret = stt_set_recognition_result_cb(g_stt, __stt_recognition_result_cb, NULL);
+               if (STT_ERROR_NONE != ret) {
+                       stt_destroy(g_stt);
+                       SLOG(LOG_ERROR, TAG_STT_TEST, "Fail to set recognition result cb");
+                       return 0;
+               }
+
+               SLOG(LOG_DEBUG, TAG_STT_TEST, "STT prepare");
+               ret = stt_prepare(g_stt);
+               if (STT_ERROR_NONE != ret) {
+                       stt_destroy(g_stt);
+                       SLOG(LOG_ERROR, TAG_STT_TEST, "Fail to prepare");
+                       return 0;
+               }
+       }
+
+       ecore_main_loop_begin();
+
+       ecore_shutdown();
+
+       SLOG(LOG_DEBUG, TAG_STT_TEST, "===== STT END =====");
+
+       return 0;
+}