Tizen 2.1 base
authorJinkun Jang <jinkun.jang@samsung.com>
Tue, 12 Mar 2013 16:53:53 +0000 (01:53 +0900)
committerJinkun Jang <jinkun.jang@samsung.com>
Tue, 12 Mar 2013 16:53:53 +0000 (01:53 +0900)
40 files changed:
AUTHORS [changed mode: 0644->0755]
CMakeLists.txt [changed mode: 0644->0755]
LICENSE.APLv2 [new file with mode: 0755]
NOTICE [new file with mode: 0755]
changelog [new file with mode: 0644]
client/tts.c [changed mode: 0644->0755]
client/tts.h [changed mode: 0644->0755]
client/tts_client.c [changed mode: 0644->0755]
client/tts_client.h [changed mode: 0644->0755]
client/tts_dbus.c [changed mode: 0644->0755]
client/tts_dbus.h [changed mode: 0644->0755]
client/tts_main.h [changed mode: 0644->0755]
client/tts_setting.c [changed mode: 0644->0755]
client/tts_setting.h [changed mode: 0644->0755]
client/tts_setting_dbus.c [changed mode: 0644->0755]
client/tts_setting_dbus.h [changed mode: 0644->0755]
common/tts_defs.h [changed mode: 0644->0755]
packaging/tts.spec
server/CMakeLists.txt [changed mode: 0644->0755]
server/ttsd.conf [new file with mode: 0644]
server/ttsd_config.c [changed mode: 0644->0755]
server/ttsd_config.h [changed mode: 0644->0755]
server/ttsd_data.cpp [changed mode: 0644->0755]
server/ttsd_data.h [changed mode: 0644->0755]
server/ttsd_dbus.c [changed mode: 0644->0755]
server/ttsd_dbus.h [changed mode: 0644->0755]
server/ttsd_dbus_server.c [changed mode: 0644->0755]
server/ttsd_dbus_server.h [changed mode: 0644->0755]
server/ttsd_engine_agent.c [changed mode: 0644->0755]
server/ttsd_engine_agent.h [changed mode: 0644->0755]
server/ttsd_main.c [changed mode: 0644->0755]
server/ttsd_main.h [changed mode: 0644->0755]
server/ttsd_network.c [changed mode: 0644->0755]
server/ttsd_network.h [changed mode: 0644->0755]
server/ttsd_player.cpp [changed mode: 0644->0755]
server/ttsd_player.h [changed mode: 0644->0755]
server/ttsd_server.cpp [changed mode: 0644->0755]
server/ttsd_server.h [changed mode: 0644->0755]
server/ttsp.h [changed mode: 0644->0755]
tts-server.manifest [new file with mode: 0644]

diff --git a/AUTHORS b/AUTHORS
old mode 100644 (file)
new mode 100755 (executable)
index cd12545..95e9681
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,2 +1,3 @@
 Dongyeol Lee <dy3.lee@samsung.com> 
+Kwangyoun Kim <ky85.kim@samsung.com>
 Sehwan Park <sehwan@samsung.com>
\ No newline at end of file
old mode 100644 (file)
new mode 100755 (executable)
index d8e146c..19ad256
@@ -7,7 +7,7 @@ INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/common")
 ## Dependent packages ##
 INCLUDE(FindPkgConfig)
 pkg_check_modules(pkgs REQUIRED  
-       mm-player vconf dlog ecore openssl dbus-1 
+       mm-player vconf dlog ecore ecore-file dbus-1 
 )
 
 ## Client library ##
@@ -15,3 +15,6 @@ ADD_SUBDIRECTORY(client)
 
 ## Server daemon ##
 ADD_SUBDIRECTORY(server)
+
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.APLv2 RENAME tts DESTINATION /usr/share/license)
+
diff --git a/LICENSE.APLv2 b/LICENSE.APLv2
new file mode 100755 (executable)
index 0000000..d645695
--- /dev/null
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   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.
diff --git a/NOTICE b/NOTICE
new file mode 100755 (executable)
index 0000000..1066e15
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,3 @@
+Copyright (c)2012 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.
diff --git a/changelog b/changelog
new file mode 100644 (file)
index 0000000..b4da4d0
--- /dev/null
+++ b/changelog
@@ -0,0 +1,346 @@
+tts (0.1.1-43-1)
+
+  * Fix bug(about daemon connection)
+
+ -- Kwangyoun Kim <ky85.kim@samsung.com>  Tue, 12 Feb 2013
+
+tts (0.1.1-43slp2+1) unstable; urgency=low
+
+  * Change License and notice file
+
+ -- Kwangyoun Kim <ky85.kim@samsung.com>  Wed, 23 Jan 2013 15:15:44 +0900
+
+tts (0.1.1-42slp2+1) unstable; urgency=low
+
+  * Fix prevent issue
+  * Change license file
+
+ -- Kwangyoun Kim <ky85.kim@samsung.com>  Tue, 15 Jan 2013 13:09:08 +0900
+
+tts (0.1.1-41slp2+1) unstable; urgency=low
+
+  * Fix prevent issue
+  * Fix bug when engine result is NULL
+  * Change config path
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Tue, 18 Dec 2012 12:16:38 +0900
+
+tts (0.1.1-40slp2+1) unstable; urgency=low
+
+  * Fix prevent
+  * Git: framework/uifw/voice/tts
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Tue, 04 Dec 2012 16:40:08 +0900
+
+tts (0.1.1-39slp2+1) unstable; urgency=low
+
+  * Remove dependency of openssl
+  * Fix bug of config 
+  * Git: framework/uifw/voice/tts
+  * Tag: tts_0.1.1-39slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Thu, 22 Nov 2012 16:31:53 +0900
+
+tts (0.1.1-38slp2+1) unstable; urgency=low
+
+  * Add manifest and license file
+  * Add tag for binary merge
+  * Git: framework/uifw/voice/tts
+  * Tag: tts_0.1.1-38slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Wed, 10 Oct 2012 14:48:46 +0900
+
+tts (0.1.1-37slp2+1) unstable; urgency=low
+
+  * Fix the bug of player BS
+  * Git: framework/uifw/voice/tts
+  * Tag: tts_0.1.1-37slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Thu, 16 Aug 2012 11:30:47 +0900
+
+tts (0.1.1-36slp2+1) unstable; urgency=low
+
+  * Update Setting API for async init
+  * Git: slp/pkgs/t/tts
+  * Tag: tts_0.1.1-36slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Mon, 06 Aug 2012 19:30:59 +0900
+
+tts (0.1.1-35slp2+1) unstable; urgency=low
+
+  * Remove fd write option of dbus in client lib
+  * Git: slp/pkgs/t/tts
+  * Tag: tts_0.1.1-35slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Tue, 31 Jul 2012 10:17:11 +0900
+
+tts (0.1.1-34slp2+1) unstable; urgency=low
+
+  * Fix the bug of setting client management
+  * Git: slp/pkgs/t/tts
+  * Tag: tts_0.1.1-34slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Tue, 24 Jul 2012 13:47:43 +0900
+
+tts (0.1.1-33slp2+1) unstable; urgency=low
+
+  * Update API for async init
+  * Git: slp/pkgs/t/tts
+  * Tag: tts_0.1.1-33slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Mon, 04 Jun 2012 19:48:29 +0900
+
+tts (0.1.1-32slp2+1) unstable; urgency=low
+
+  * Add config file
+  * Git: slp/pkgs/t/tts
+  * Tag: tts_0.1.1-32slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Thu, 24 May 2012 14:50:30 +0900
+
+tts (0.1.1-31slp2+1) unstable; urgency=low
+
+  * update config not to depend on VConf
+  * Git: slp/pkgs/t/tts
+  * Tag: tts_0.1.1-31slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Fri, 18 May 2012 18:56:19 +0900
+
+tts (0.1.1-30slp2+1) unstable; urgency=low
+
+  * fix bug about fork daemon
+  * Git: slp/pkgs/t/tts
+  * Tag: tts_0.1.1-30slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Mon, 26 Mar 2012 15:48:37 +0900
+
+tts (0.1.1-29slp2+1) unstable; urgency=low
+
+  * udpate changelog
+  * Git: slp/pkgs/t/tts
+  * Tag: tts_0.1.1-29slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Mon, 19 Mar 2012 19:20:22 +0900
+
+tts (0.1.1-28slp2+1) unstable; urgency=low
+
+  * udpate setting api
+  * Git: slp/pkgs/t/tts
+  * Tag: tts_0.1.1-28slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Mon, 19 Mar 2012 11:37:32 +0900
+
+tts (0.1.1-27slp2+1) unstable; urgency=low
+
+  * fix IPC bug
+  * Git: slp/pkgs/t/tts
+  * Tag: tts_0.1.1-27slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Wed, 14 Mar 2012 16:14:08 +0900
+
+tts (0.1.1-26slp2+1) unstable; urgency=low
+
+  * beta release
+  * Git: slp/pkgs/t/tts
+  * Tag: tts_0.1.1-26slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Fri, 17 Feb 2012 17:42:12 +0900
+
+tts (0.1.1-25slp2+1) unstable; urgency=low
+
+  * fix player bug and update doxygen
+  * Git: slp/pkgs/t/tts
+  * Tag: tts_0.1.1-25slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Fri, 17 Feb 2012 10:45:28 +0900
+
+tts (0.1.1-24slp2+1) unstable; urgency=low
+
+  * update engine api
+  * Git: slp/pkgs/t/tts
+  * Tag: tts_0.1.1-24slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Thu, 05 Jan 2012 15:53:48 +0900
+
+tts (0.1.1-23slp2+1) unstable; urgency=low
+
+  * update changelog
+  * Git: slp/pkgs/t/tts
+  * Tag: tts_0.1.1-23slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Mon, 19 Dec 2011 13:50:50 +0900
+
+tts (0.1.1-22slp2+1) unstable; urgency=low
+
+  * code cleanup and update log 
+  * Git: slp/pkgs/t/tts
+  * Tag: tts_0.1.1-22slp2+1 
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Fri, 16 Dec 2011 15:56:08 +0900
+
+tts (0.1.1-21slp2+1) unstable; urgency=low
+
+  * code cleanup and update log 
+  * Git: 165.213.180.234:slp/pkgs/t/tts
+  * Tag: tts_0.1.1-21slp2+1 
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Tue, 06 Dec 2011 19:01:19 +0900
+
+tts (0.1.1-20slp2+1) unstable; urgency=low
+
+  * change boiler plate 
+  * Git: 165.213.180.234:slp/pkgs/t/tts
+  * Tag: tts_0.1.1-20slp2+1 
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Fri, 02 Dec 2011 10:52:46 +0900
+
+tts (0.1.1-19slp2+1) unstable; urgency=low
+
+  * update for connman 
+  * Git: 165.213.180.234:slp/pkgs/t/tts
+  * Tag: tts_0.1.1-19slp2+1 
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Tue, 29 Nov 2011 16:14:14 +0900
+
+tts (0.1.1-18slp2+1) unstable; urgency=low
+
+  * bug fix about unref message
+  * Git: 165.213.180.234:slp/pkgs/t/tts
+  * Tag: tts_0.1.1-18slp2+1 
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Wed, 23 Nov 2011 15:34:46 +0900
+
+tts (0.1.1-17slp2+1) unstable; urgency=low
+
+  * update API : change sync function and use add_text in 'Play' state
+  * Git: 165.213.180.234:slp/pkgs/t/tts
+  * Tag: tts_0.1.1-17slp2+1 
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Wed, 16 Nov 2011 11:28:03 +0900
+
+tts (0.1.1-16slp2+1) unstable; urgency=low
+
+  * update Setting API 
+  * Git: 165.213.180.234:slp/pkgs/t/tts
+  * Tag: tts_0.1.1-16slp2+1 
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Tue, 01 Nov 2011 11:24:58 +0900
+
+tts (0.1.1-15slp2+1) unstable; urgency=low
+
+  * update API doxygen and fix bug about initial default voice 
+  * Git: 165.213.180.234:slp/pkgs/t/tts
+  * Tag: tts_0.1.1-15slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Thu, 27 Oct 2011 11:06:49 +0900
+
+tts (0.1.1-14slp2+1) unstable; urgency=low
+
+  * change API for SDK release
+  * Git: 165.213.180.234:slp/pkgs/t/tts
+  * Tag: tts_0.1.1-14slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Fri, 21 Oct 2011 16:42:51 +0900
+
+tts (0.1.1-13slp2+1) unstable; urgency=low
+
+  * update API's new callback 
+  * Git: 165.213.180.234:slp/pkgs/t/tts
+  * Tag: tts_0.1.1-13slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Thu, 20 Oct 2011 17:49:13 +0900
+
+tts (0.1.1-12slp2+1) unstable; urgency=low
+
+  * update new API for sdk release and change boilerplate
+  * Git: 165.213.180.234:slp/pkgs/t/tts
+  * Tag: tts_0.1.1-12slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Wed, 19 Oct 2011 16:31:50 +0900
+
+tts (0.1.1-11slp2+1) unstable; urgency=low
+
+  * update bug of prevent and remove dependency of gtk
+  * Git: 165.213.180.234:slp/pkgs/t/tts
+  * Tag: tts_0.1.1-11slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Wed, 07 Sep 2011 14:47:34 +0900
+
+tts (0.1.1-10slp2+1) unstable; urgency=low
+
+  * update build file
+  * Git: 165.213.180.234:slp/pkgs/t/tts
+  * Tag: tts_0.1.1-10slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Tue, 19 Jul 2011 16:15:13 +0900
+
+tts (0.1.1-9slp2+1) unstable; urgency=low
+
+  * update build file
+  * Git: 165.213.180.234:slp/pkgs/t/tts
+  * Tag: tts_0.1.1-9slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Mon, 18 Jul 2011 10:27:52 +0900
+
+tts (0.1.1-8slp2+1) unstable; urgency=low
+
+  * Change IPC and Code Cleanup
+  * Git: 165.213.180.234:slp/pkgs/t/tts
+  * Tag: tts_0.1.1-8slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Fri, 15 Jul 2011 18:01:31 +0900
+
+tts (0.1.1-7slp2+1) unstable; urgency=low
+
+  * support multi instance 
+  * Git: 165.213.180.234:slp/pkgs/t/tts
+  * Tag: tts_0.1.1-7slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Fri, 24 Jun 2011 14:36:36 +0900
+
+tts (0.1.1-6slp2+1) unstable; urgency=low
+
+  * fix defect from prevent
+  * Git: 165.213.180.234:slp/pkgs/t/tts
+  * Tag: tts_0.1.1-6slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Tue, 07 Jun 2011 17:05:49 +0900
+
+tts (0.1.1-5slp2+1) unstable; urgency=low
+
+  * Git: 165.213.180.234:slp/pkgs/t/tts
+  * Tag: tts_0.1.1-5slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Mon, 23 May 2011 15:14:10 +0900
+
+tts (0.1.1-4slp2+1) unstable; urgency=low
+
+  * Change API - change error code
+  * Git: 165.213.180.234:slp/pkgs/t/tts
+  * Tag: tts_0.1.1-4slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Mon, 23 May 2011 09:00:57 +0900
+
+tts (0.1.1-3slp2+1) unstable; urgency=low
+
+  * change control file
+  * Git: 165.213.180.234:slp/pkgs/t/tts
+  * Tag: tts_0.1.1-3slp2+1
+
+ -- Jae-Yong Lee <jaeyong911.lee@samsung.com>  Mon, 16 May 2011 10:45:01 +0900
+
+tts (0.1.1-2slp2+1) unstable; urgency=low
+
+  * Initial Release (change files to unix type).
+  * Git: 165.213.180.234:slp/pkgs/t/tts
+  * Tag: tts_0.1.1-2slp2+1
+
+ -- Jae-Yong Lee <jaeyong911.lee@samsung.com>  Mon, 16 May 2011 10:11:02 +0900
+
+tts (0.1.1-1slp2+1) unstable; urgency=low
+
+  * Initial Release.
+  * Git: 165.213.180.234:slp/pkgs/t/tts
+  * Tag: tts_0.1.1-1slp2+1
+
+ -- Jae-Yong Lee <jaeyong911.lee@samsung.com>  Fri, 13 May 2011 16:15:22 +0900
old mode 100644 (file)
new mode 100755 (executable)
index 1ff1576..6974f40
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved 
+*  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
 
 
 #include <sys/wait.h>
+#include <Ecore.h>
+#include <sys/stat.h>
+#include <sys/types.h> 
+#include <dirent.h>
 
 #include "tts_main.h"
 #include "tts_client.h"
 #include "tts_dbus.h"
 
 #define MAX_TEXT_COUNT 1000
-#define CONNECTION_RETRY_COUNT 3
+
+static bool g_is_daemon_started = false;
+
+static Ecore_Timer* g_connect_timer = NULL;
 
 /* Function definition */
-int __tts_check_tts_daemon();
+static int __tts_check_tts_daemon();
+static Eina_Bool __tts_notify_state_changed(void *data);
+static Eina_Bool __tts_notify_error(void *data);
 
 int tts_create(tts_h* tts)
 {
-       int ret = 0; 
-
        SLOG(LOG_DEBUG, TAG_TTSC, "===== Create TTS");
        
        /* check param */
@@ -38,12 +45,9 @@ int tts_create(tts_h* tts)
                return TTS_ERROR_INVALID_PARAMETER;
        }       
 
-       /* Check daemon is running */
-       __tts_check_tts_daemon();
-
        if (0 == tts_client_get_size()) {
                if (0 != tts_dbus_open_connection()) {
-                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to open dbus connection\n ");
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to open dbus connection");
                        SLOG(LOG_DEBUG, TAG_TTSC, "=====");
                        SLOG(LOG_DEBUG, TAG_TTSC, " ");
                        return TTS_ERROR_OPERATION_FAILED;
@@ -57,35 +61,6 @@ int tts_create(tts_h* tts)
                return TTS_ERROR_OUT_OF_MEMORY;
        }
 
-       /* do request initialize */
-       int i = 0;
-       while(1) {
-               ret = tts_dbus_request_initialize((*tts)->handle);
-
-               if (TTS_ERROR_ENGINE_NOT_FOUND == ret) {
-                       tts_client_destroy(*tts);
-                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Engine not found");
-                       SLOG(LOG_DEBUG, TAG_TTSC, "=====");
-                       SLOG(LOG_DEBUG, TAG_TTSC, " ");
-                       return ret;
-               } else if( ret ) {
-                       sleep(1);
-                       if (i == CONNECTION_RETRY_COUNT) {
-                           tts_client_destroy(*tts);
-                           SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Connection Time out");
-                           SLOG(LOG_DEBUG, TAG_TTSC, "=====");
-                           SLOG(LOG_DEBUG, TAG_TTSC, " ");
-                           return TTS_ERROR_TIMED_OUT;                     
-                       }    
-                       i++;
-               } else {
-                       /* success to connect tts-daemon */
-                       break;
-               }
-       }
-
-       SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] uid(%d)", (*tts)->handle);
-
        SLOG(LOG_DEBUG, TAG_TTSC, "=====");
        SLOG(LOG_DEBUG, TAG_TTSC, " ");
 
@@ -113,20 +88,171 @@ int tts_destroy(tts_h tts)
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
-       /* Request Finalize */
-       int ret = tts_dbus_request_finalize(client->uid);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to request finalize ");
-       }    
+       /* check used callback */
+       if (0 != tts_client_get_use_callback(client)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Cannot destroy in Callback function");
+               return TTS_ERROR_OPERATION_FAILED;
+       }
 
-       /* Free resources */
-       tts_client_destroy(tts);
+       int ret = -1;
 
+       /* check state */
+       switch (client->current_state) {
+       case TTS_STATE_PAUSED:
+       case TTS_STATE_PLAYING:
+       case TTS_STATE_READY:
+               /* Request Finalize */
+               ret = tts_dbus_request_finalize(client->uid);
+               if (0 != ret) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to request finalize");
+               }
+               g_is_daemon_started = false;
+       case TTS_STATE_CREATED:
+               if (NULL != g_connect_timer) {
+                       SLOG(LOG_DEBUG, TAG_TTSC, "Connect Timer is deleted");
+                       ecore_timer_del(g_connect_timer);
+               }
+               /* Free resources */
+               tts_client_destroy(tts);
+               break;
+       }
        if (0 == tts_client_get_size()) {
                if (0 != tts_dbus_close_connection()) {
-                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to close connection\n ");
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to close connection");
+               }
+       }
+
+       SLOG(LOG_DEBUG, TAG_TTSC, "=====");
+       SLOG(LOG_DEBUG, TAG_TTSC, " ");
+
+       return TTS_ERROR_NONE;
+}
+
+static Eina_Bool __tts_connect_daemon(void *data)
+{
+       tts_h tts = (tts_h)data;
+
+       tts_client_s* client = tts_client_get(tts);
+
+       /* check handle */
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid");
+               return EINA_FALSE;
+       }
+
+       /* Send hello */
+       if (0 != tts_dbus_request_hello()) {
+               if (false == g_is_daemon_started) {
+                       g_is_daemon_started = true;
+                       __tts_check_tts_daemon();
                }
+               return EINA_TRUE;
+       }
+
+       SLOG(LOG_DEBUG, TAG_TTSC, "===== Connect daemon");
+       
+       /* do request initialize */
+       int ret = -1;
+
+       ret = tts_dbus_request_initialize(client->uid);
+
+       if (TTS_ERROR_ENGINE_NOT_FOUND == ret) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Engine not found");
+               
+               client->reason = TTS_ERROR_ENGINE_NOT_FOUND;
+               client->utt_id = -1;
+
+               ecore_timer_add(0, __tts_notify_error, (void*)client->tts);
+               return EINA_FALSE;
+
+       } else if (TTS_ERROR_NONE != ret) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to connection");
+
+               client->reason = TTS_ERROR_TIMED_OUT;
+               client->utt_id = -1;
+
+               ecore_timer_add(0, __tts_notify_error, (void*)client->tts);
+               return EINA_FALSE;
+       } else {
+               /* success to connect tts-daemon */
+       }
+
+       client->before_state = client->current_state;
+       client->current_state = TTS_STATE_READY;
+
+       ecore_timer_add(0, __tts_notify_state_changed, (void*)client->tts);
+
+       g_connect_timer = NULL;
+
+       SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] uid(%d)", client->uid);
+
+       SLOG(LOG_DEBUG, TAG_TTSC, "=====");
+       SLOG(LOG_DEBUG, TAG_TTSC, " ");
+
+       return EINA_FALSE;
+}
+
+int tts_prepare(tts_h tts)
+{
+       SLOG(LOG_DEBUG, TAG_TTSC, "===== Prepare TTS");
+
+       tts_client_s* client = tts_client_get(tts);
+
+       /* check handle */
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not available");
+               SLOG(LOG_DEBUG, TAG_TTSC, "=====");
+               SLOG(LOG_DEBUG, TAG_TTSC, " ");
+               return TTS_ERROR_INVALID_PARAMETER;
+       }
+
+       /* check state */
+       if (client->current_state != TTS_STATE_CREATED) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Invalid State: Current state is not 'CREATED'"); 
+               SLOG(LOG_DEBUG, TAG_TTSC, "=====");
+               SLOG(LOG_DEBUG, TAG_TTSC, " ");
+               return TTS_ERROR_INVALID_STATE;
+       }
+
+       g_connect_timer = ecore_timer_add(0, __tts_connect_daemon, (void*)tts);
+
+       SLOG(LOG_DEBUG, TAG_TTSC, "=====");
+       SLOG(LOG_DEBUG, TAG_TTSC, " ");
+
+       return TTS_ERROR_NONE;
+}
+
+int tts_unprepare(tts_h tts)
+{
+       SLOG(LOG_DEBUG, TAG_TTSC, "===== Unprepare TTS");
+
+       tts_client_s* client = tts_client_get(tts);
+
+       /* check handle */
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not available");
+               return TTS_ERROR_INVALID_PARAMETER;
+       }
+
+       /* check state */
+       if (client->current_state != TTS_STATE_READY) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Invalid State: Current state is not 'READY'"); 
+               SLOG(LOG_DEBUG, TAG_TTSC, "=====");
+               SLOG(LOG_DEBUG, TAG_TTSC, " ");
+               return TTS_ERROR_INVALID_STATE;
+       }
+
+       int ret = tts_dbus_request_finalize(client->uid);
+       if (0 != ret) {
+               SLOG(LOG_WARN, TAG_TTSC, "[ERROR] Fail to request finalize");
        }
+       g_is_daemon_started = false;
+
+       client->before_state = client->current_state;
+       client->current_state = TTS_STATE_CREATED;
+
+       ecore_timer_add(0, __tts_notify_state_changed, (void*)tts);
 
        SLOG(LOG_DEBUG, TAG_TTSC, "=====");
        SLOG(LOG_DEBUG, TAG_TTSC, " ");
@@ -156,7 +282,7 @@ int tts_foreach_supported_voices(tts_h tts, tts_supported_voice_cb callback, voi
        }
 
        if (TTS_STATE_READY != client->current_state) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Current state is NOT 'READY'.\n");  
+               SLOG(LOG_ERROR, TAG_TTSC, "Current state is NOT 'READY'.");  
                SLOG(LOG_DEBUG, TAG_TTSC, "=====");
                SLOG(LOG_DEBUG, TAG_TTSC, " ");
                return TTS_ERROR_INVALID_STATE;
@@ -257,6 +383,7 @@ int tts_get_state(tts_h tts, tts_state_e* state)
        *state = client->current_state;
 
        switch(*state) {
+               case TTS_STATE_CREATED: SLOG(LOG_DEBUG, TAG_TTSC, "Current state is 'Created'");        break;
                case TTS_STATE_READY:   SLOG(LOG_DEBUG, TAG_TTSC, "Current state is 'Ready'");          break;
                case TTS_STATE_PLAYING: SLOG(LOG_DEBUG, TAG_TTSC, "Current state is 'Playing'");        break;
                case TTS_STATE_PAUSED:  SLOG(LOG_DEBUG, TAG_TTSC, "Current state is 'Paused'");         break;
@@ -285,6 +412,11 @@ int tts_add_text(tts_h tts, const char* text, const char* language, tts_voice_ty
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
+       if (TTS_STATE_CREATED == client->current_state) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Current state is 'CREATED'."); 
+               return TTS_ERROR_INVALID_STATE;
+       }
+
        /* change default language value */
        char* temp = NULL;
 
@@ -321,7 +453,7 @@ int tts_play(tts_h tts)
        SLOG(LOG_DEBUG, TAG_TTSC, "===== Play tts");
 
        if (NULL == tts) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input handle is null");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input handle is null.");
                SLOG(LOG_DEBUG, TAG_TTSC, "=====");
                SLOG(LOG_DEBUG, TAG_TTSC, " ");
                return TTS_ERROR_INVALID_PARAMETER;
@@ -330,29 +462,35 @@ int tts_play(tts_h tts)
        tts_client_s* client = tts_client_get(tts);
 
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid.");
                SLOG(LOG_DEBUG, TAG_TTSC, "=====");
                SLOG(LOG_DEBUG, TAG_TTSC, " ");
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
-       if (TTS_STATE_PLAYING == client->current_state) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Current state is 'playing'. This request should be skipped.\n"); 
+       if (TTS_STATE_PLAYING == client->current_state || TTS_STATE_CREATED == client->current_state) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] The current state is invalid."); 
                return TTS_ERROR_INVALID_STATE;
        } 
 
        int ret = 0;
        ret = tts_dbus_request_play(client->uid);
        if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] result : %d", ret);
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Request play : result(%d)", ret);
                SLOG(LOG_DEBUG, TAG_TTSC, "=====");
                SLOG(LOG_DEBUG, TAG_TTSC, " ");
                return ret;
        }
 
-       /* change state */
+       client->before_state = client->current_state;
        client->current_state = TTS_STATE_PLAYING;
 
+       if (NULL != client->state_changed_cb) {
+               ecore_timer_add(0, __tts_notify_state_changed, (void*)tts);
+       } else {
+               SLOG(LOG_WARN, TAG_TTSC, "[WARNING] State changed callback is null");
+       }
+
        SLOG(LOG_DEBUG, TAG_TTSC, "=====");
        SLOG(LOG_DEBUG, TAG_TTSC, " ");
 
@@ -380,8 +518,10 @@ int tts_stop(tts_h tts)
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
-       SLOG(LOG_DEBUG, TAG_TTSC, "change state to ready\n");
-       client->current_state = TTS_STATE_READY;
+       if (TTS_STATE_CREATED == client->current_state) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Current state is 'CREATED'."); 
+               return TTS_ERROR_INVALID_STATE;
+       }
 
        int ret = 0;
        ret = tts_dbus_request_stop(client->uid);
@@ -392,6 +532,15 @@ int tts_stop(tts_h tts)
                return ret;
        }       
 
+       client->before_state = client->current_state;
+       client->current_state = TTS_STATE_READY;
+
+       if (NULL != client->state_changed_cb) {
+               ecore_timer_add(0, __tts_notify_state_changed, (void*)tts);
+       } else {
+               SLOG(LOG_WARN, TAG_TTSC, "[WARNING] State changed callback is null");
+       }
+
        SLOG(LOG_DEBUG, TAG_TTSC, "=====");
        SLOG(LOG_DEBUG, TAG_TTSC, " ");
 
@@ -420,7 +569,7 @@ int tts_pause(tts_h tts)
        }
 
        if (TTS_STATE_PLAYING != client->current_state) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Error : Current state is NOT 'playing'. So this request should be not running.\n");    
+               SLOG(LOG_ERROR, TAG_TTSC, "[Error] The Current state is NOT 'playing'. So this request should be not running.");    
                SLOG(LOG_DEBUG, TAG_TTSC, "=====");
                SLOG(LOG_DEBUG, TAG_TTSC, " ");
                return TTS_ERROR_INVALID_STATE;
@@ -429,74 +578,146 @@ int tts_pause(tts_h tts)
        int ret = 0;
        ret = tts_dbus_request_pause(client->uid);
        if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] result : %d", ret);
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Request pause : result(%d)", ret);
                SLOG(LOG_DEBUG, TAG_TTSC, "=====");
                SLOG(LOG_DEBUG, TAG_TTSC, " ");
                return ret;
        }
 
+       client->before_state = client->current_state;
        client->current_state = TTS_STATE_PAUSED;
 
+       if (NULL != client->state_changed_cb) {
+               ecore_timer_add(0, __tts_notify_state_changed, (void*)tts);
+       } else {
+               SLOG(LOG_WARN, TAG_TTSC, "[WARNING] State changed callback is null");
+       }
+
        SLOG(LOG_DEBUG, TAG_TTSC, "=====");
        SLOG(LOG_DEBUG, TAG_TTSC, " ");
 
        return TTS_ERROR_NONE;
 }
 
+static Eina_Bool __tts_notify_error(void *data)
+{
+       tts_h tts = (tts_h)data;
+
+       tts_client_s* client = tts_client_get(tts);
+
+       /* check handle */
+       if (NULL == client) {
+               SLOG(LOG_WARN, TAG_TTSC, "Fail to notify error msg : A handle is not valid");
+               return EINA_FALSE;
+       }
+
+       if (NULL != client->error_cb) {
+               SLOG(LOG_DEBUG, TAG_TTSC, "Call callback function of error");
+               tts_client_use_callback(client);
+               client->error_cb(client->tts, client->utt_id, client->reason, client->error_user_data );
+               tts_client_not_use_callback(client);
+       } else {
+               SLOG(LOG_WARN, TAG_TTSC, "No registered callback function of error ");
+       }
+
+       return EINA_FALSE;
+}
+
 int __tts_cb_error(int uid, tts_error_e reason, int utt_id)
 {
        tts_client_s* client = tts_client_get_by_uid(uid);
 
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid");
+               SLOG(LOG_WARN, TAG_TTSC, "[WARNING] A handle is not valid");
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
+       client->utt_id = utt_id;
+       client->reason = reason;
+
        /* call callback function */
        if (NULL != client->error_cb) {
-               SLOG(LOG_DEBUG, TAG_TTSC, "Call callback function of error");
-               tts_client_use_callback(client);
-               client->error_cb(client->tts, utt_id, reason, client->error_user_data );
-               tts_client_not_use_callback(client);
+               ecore_timer_add(0, __tts_notify_error, client->tts);
        } else {
-               SLOG(LOG_WARN, TAG_TTSC, "No registered callback function of error \n");
+               SLOG(LOG_WARN, TAG_TTSC, "No registered callback function of error ");
        }
        
        return 0;
 }
 
-int __tts_cb_interrupt(int uid, tts_interrupted_code_e code)
+static Eina_Bool __tts_notify_state_changed(void *data)
 {
-       tts_client_s* client = tts_client_get_by_uid(uid);
+       tts_h tts = (tts_h)data;
+
+       tts_client_s* client = tts_client_get(tts);
 
+       /* check handle */
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid");
-               return TTS_ERROR_INVALID_PARAMETER;
+               SLOG(LOG_WARN, TAG_TTSC, "Fail to notify state changed : A handle is not valid");
+               return EINA_FALSE;
        }
 
-       /* change state by interrupt code */
-       if (TTS_INTERRUPTED_PAUSED == code) {
-               SLOG(LOG_DEBUG, TAG_TTSC, "change state to ready");
-               client->current_state = TTS_STATE_PAUSED;
-       } else if (TTS_INTERRUPTED_STOPPED == code) {
-               SLOG(LOG_DEBUG, TAG_TTSC, "change state to ready");
-               client->current_state = TTS_STATE_READY;
+       if (NULL != client->state_changed_cb) {
+               tts_client_use_callback(client);
+               client->state_changed_cb(client->tts, client->before_state, client->current_state, client->state_changed_user_data); 
+               tts_client_not_use_callback(client);
+               SLOG(LOG_DEBUG, TAG_TTSC, "State changed callback is called");
        } else {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Interrupt code is not available");
+               SLOG(LOG_WARN, TAG_TTSC, "[WARNING] State changed callback is null");
+       }
+
+       return EINA_FALSE;
+}
+
+int __tts_cb_set_state(int uid, int state)
+{
+       tts_client_s* client = tts_client_get_by_uid(uid);
+       if( NULL == client ) {
+               SLOG(LOG_WARN, TAG_TTSC, "[WARNING] The handle is not valid");
                return -1;
        }
 
-       /* call callback function */
-       if (NULL != client->interrupted_cb) {
-               SLOG(LOG_DEBUG, TAG_TTSC, "Call callback function of stopped \n");
+       tts_state_e state_from_daemon = (tts_state_e)state;
+
+       if (client->current_state == state_from_daemon) {
+               SLOG(LOG_DEBUG, TAG_TTSC, "Current state has already been %d", client->current_state);
+               return 0;
+       }
+
+       if (NULL != client->state_changed_cb) {
+               ecore_timer_add(0, __tts_notify_state_changed, client->tts);
+       } else {
+               SLOG(LOG_WARN, TAG_TTSC, "[WARNING] State changed callback is null");
+       }
+
+       client->before_state = client->current_state;
+       client->current_state = state_from_daemon;
+
+       return 0;
+}
+
+static Eina_Bool __tts_notify_utt_started(void *data)
+{
+       tts_h tts = (tts_h)data;
+
+       tts_client_s* client = tts_client_get(tts);
+
+       /* check handle */
+       if (NULL == client) {
+               SLOG(LOG_WARN, TAG_TTSC, "[WARNING] Fail to notify utt started : A handle is not valid");
+               return EINA_FALSE;
+       }
+       
+       if (NULL != client->utt_started_cb) {
+               SLOG(LOG_DEBUG, TAG_TTSC, "Call callback function of utterance started ");
                tts_client_use_callback(client);
-               client->interrupted_cb(client->tts, code, client->interrupted_user_data);
+               client->utt_started_cb(client->tts, client->utt_id, client->utt_started_user_data);
                tts_client_not_use_callback(client);
        } else {
-               SLOG(LOG_WARN, TAG_TTSC, "No registered callback function of stopped \n");
+               SLOG(LOG_WARN, TAG_TTSC, "No registered callback function of utterance started ");
        }
 
-       return 0;
+       return EINA_FALSE;
 }
 
 int __tts_cb_utt_started(int uid, int utt_id)
@@ -504,23 +725,46 @@ int __tts_cb_utt_started(int uid, int utt_id)
        tts_client_s* client = tts_client_get_by_uid(uid);
 
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid");
+               SLOG(LOG_WARN, TAG_TTSC, "[WARNING] A handle is not valid");
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
-       SLOG(LOG_DEBUG, TAG_TTSC, "utterance started : uttid(%d) \n", utt_id);
+       SLOG(LOG_DEBUG, TAG_TTSC, "utterance started : utt id(%d) ", utt_id);
+
+       client->utt_id = utt_id;
 
        /* call callback function */
        if (NULL != client->utt_started_cb) {
-               SLOG(LOG_DEBUG, TAG_TTSC, "Call callback function of utterance started \n");
+               ecore_timer_add(0, __tts_notify_utt_started, client->tts);
+       } else {
+               SLOG(LOG_WARN, TAG_TTSC, "No registered callback function of utterance started ");
+       }
+
+       return 0;
+}
+
+static Eina_Bool __tts_notify_utt_completed(void *data)
+{
+       tts_h tts = (tts_h)data;
+
+       tts_client_s* client = tts_client_get(tts);
+
+       /* check handle */
+       if (NULL == client) {
+               SLOG(LOG_WARN, TAG_TTSC, "[WARNING] Fail to notify utt completed : A handle is not valid");
+               return EINA_FALSE;
+       }
+
+       if (NULL != client->utt_completeted_cb) {
+               SLOG(LOG_DEBUG, TAG_TTSC, "Call callback function of utterance completed ");
                tts_client_use_callback(client);
-               client->utt_started_cb(client->tts, utt_id, client->utt_started_user_data);
+               client->utt_completeted_cb(client->tts, client->utt_id, client->utt_completed_user_data);
                tts_client_not_use_callback(client);
        } else {
-               SLOG(LOG_WARN, TAG_TTSC, "No registered callback function of utterance started \n");
+               SLOG(LOG_WARN, TAG_TTSC, "No registered callback function of utterance completed ");
        }
 
-       return 0;
+       return EINA_FALSE;
 }
 
 int __tts_cb_utt_completed(int uid, int utt_id)
@@ -528,75 +772,74 @@ int __tts_cb_utt_completed(int uid, int utt_id)
        tts_client_s* client = tts_client_get_by_uid(uid);
 
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid");
+               SLOG(LOG_WARN, TAG_TTSC, "[WARNING] A handle is not valid");
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
-       SLOG(LOG_DEBUG, TAG_TTSC, "utterance completed : uttid(%d) \n", utt_id);
+       SLOG(LOG_DEBUG, TAG_TTSC, "utterance completed : uttid(%d) ", utt_id);
+
+       client->utt_id = utt_id;
 
        /* call callback function */
        if (NULL != client->utt_completeted_cb) {
-               SLOG(LOG_DEBUG, TAG_TTSC, "Call callback function of utterance completed \n");
-               tts_client_use_callback(client);
-               client->utt_completeted_cb(client->tts, utt_id, client->utt_completed_user_data);
-               tts_client_not_use_callback(client);
+               ecore_timer_add(0, __tts_notify_utt_completed, client->tts);
        } else {
-               SLOG(LOG_WARN, TAG_TTSC, "No registered callback function of utterance completed \n");
+               SLOG(LOG_WARN, TAG_TTSC, "No registered callback function of utterance completed ");
        }
 
        return 0;
 }
 
-int tts_set_interrupted_cb(tts_h tts, tts_interrupted_cb callback, void* user_data)
+int tts_set_state_changed_cb(tts_h tts, tts_state_changed_cb callback, void* user_data)
 {
        if (NULL == tts || NULL == callback) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set interrupted cb : Input parameter is null");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set state changed cb : Input parameter is null");
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
        tts_client_s* client = tts_client_get(tts);
 
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set interrupted cb : A handle is not valid");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set state changed cb : A handle is not valid");
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
-       if (TTS_STATE_READY != client->current_state) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set interrupted cb : Current state is not 'ready'."); 
+       if (TTS_STATE_CREATED != client->current_state) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set state changed cb : Current state is not 'Created'."); 
                return TTS_ERROR_INVALID_STATE;
        }
 
-       client->interrupted_cb = callback;
-       client->interrupted_user_data = user_data;
+       client->state_changed_cb = callback;
+       client->state_changed_user_data = user_data;
 
-       SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Set interrupted cb");
+       SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Set state changed cb");
 
        return 0;
 }
 
-int tts_unset_interrupted_cb(tts_h tts)
+int tts_unset_state_changed_cb(tts_h tts)
 {
        if (NULL == tts) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset interrupted cb : Input parameter is null");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset state changed cb : Input parameter is null");
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
        tts_client_s* client = tts_client_get(tts);
 
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset interrupted cb : A handle is not valid");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset state changed cb : A handle is not valid");
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
-       if (TTS_STATE_READY != client->current_state) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset interrupted cb : Current state is not 'ready'."); 
+       if (TTS_STATE_CREATED != client->current_state) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset state changed cb : Current state is not 'Created'."); 
                return TTS_ERROR_INVALID_STATE;
        }
 
-       client->interrupted_cb = NULL;
-       client->interrupted_user_data = NULL;
+       client->state_changed_cb = NULL;
+       client->state_changed_user_data = NULL;
 
-       SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Unset interrupted cb");
+       SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Unset state changed cb");
 
        return 0;
 }
@@ -604,19 +847,19 @@ int tts_unset_interrupted_cb(tts_h tts)
 int tts_set_utterance_started_cb(tts_h tts, tts_utterance_started_cb callback, void* user_data)
 {
        if (NULL == tts || NULL == callback) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input parameter is null");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set utt started cb : Input parameter is null");
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
        tts_client_s* client = tts_client_get(tts);
 
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid");
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set utt started cb : A handle is not valid");
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
-       if (TTS_STATE_READY != client->current_state) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set utt started cb : Current state is not 'ready'."); 
+       if (TTS_STATE_CREATED != client->current_state) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set utt started cb : Current state is not 'Created'."); 
                return TTS_ERROR_INVALID_STATE;
        }
 
@@ -642,8 +885,8 @@ int tts_unset_utterance_started_cb(tts_h tts)
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
-       if (TTS_STATE_READY != client->current_state) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset utt started cb : Current state is not 'ready'."); 
+       if (TTS_STATE_CREATED != client->current_state) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset utt started cb : Current state is not 'Created'."); 
                return TTS_ERROR_INVALID_STATE;
        }
 
@@ -669,8 +912,8 @@ int tts_set_utterance_completed_cb(tts_h tts, tts_utterance_completed_cb callbac
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
-       if (TTS_STATE_READY != client->current_state) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set utt completed cb : Current state is not 'ready'."); 
+       if (TTS_STATE_CREATED != client->current_state) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set utt completed cb : Current state is not 'Created'."); 
                return TTS_ERROR_INVALID_STATE;
        }
 
@@ -696,8 +939,8 @@ int tts_unset_utterance_completed_cb(tts_h tts)
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
-       if (TTS_STATE_READY != client->current_state) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset utt completed cb : Current state is not 'ready'."); 
+       if (TTS_STATE_CREATED != client->current_state) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset utt completed cb : Current state is not 'Created'."); 
                return TTS_ERROR_INVALID_STATE;
        }
 
@@ -722,8 +965,8 @@ int tts_set_error_cb(tts_h tts, tts_error_cb callback, void* user_data)
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
-       if (TTS_STATE_READY != client->current_state) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set error cb : Current state is not 'ready'."); 
+       if (TTS_STATE_CREATED != client->current_state) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Set error cb : Current state is not 'Created'."); 
                return TTS_ERROR_INVALID_STATE;
        }
 
@@ -749,8 +992,8 @@ int tts_unset_error_cb(tts_h tts)
                return TTS_ERROR_INVALID_PARAMETER;
        }
        
-       if (TTS_STATE_READY != client->current_state) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset error cb : Current state is not 'ready'."); 
+       if (TTS_STATE_CREATED != client->current_state) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Unset error cb : Current state is not 'Created'."); 
                return TTS_ERROR_INVALID_STATE;
        }
 
@@ -762,88 +1005,86 @@ int tts_unset_error_cb(tts_h tts)
        return 0;
 }
 
-static bool _tts_is_alive()
+int __get_cmd_line(char *file, char *buf) 
 {
        FILE *fp = NULL;
-       char buff[256];
-       char cmd[256];
-       int i=0;
 
-       memset(buff, 0, sizeof(char));
-       memset(cmd, 0, sizeof(char));
-
-       if ((fp = popen("ps -eo \"cmd\"", "r")) == NULL) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] popen error \n");
-               return FALSE;
+       fp = fopen(file, "r");
+       if (fp == NULL) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Get command line");
+               return -1;
        }
 
-       while(fgets(buff, 255, fp)) {
-               if (0 == i) {
-                       i++;
-                       continue;
-               }
-
-               sscanf(buff, "%s", cmd);
+       memset(buf, 0, 256);
+       if (NULL == fgets(buf, 256, fp)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to fget command line");
+               fclose(fp);
+               return -1;
+       }
+       fclose(fp);
+       return 0;
+}
 
-               if (0 == strncmp(cmd, "[tts-daemon]", strlen("[tts-daemon]")) ||
-                       0 == strncmp(cmd, "tts-daemon", strlen("tts-daemon")) ||
-                       0 == strncmp(cmd, "/usr/bin/tts-daemon", strlen("/usr/bin/tts-daemon"))) {
-                       SLOG(LOG_DEBUG, TAG_TTSC, "tts-daemon is ALIVE !! \n");
-                       fclose(fp);
-                       return TRUE;
-               }
+static bool _tts_is_alive()
+{
+       DIR *dir;
+       struct dirent *entry;
+       struct stat filestat;
+       
+       int pid;
+       char cmdLine[256];
+       char tempPath[256];
 
-               i++;
+       dir  = opendir("/proc");
+       if (NULL == dir) {
+               SLOG(LOG_ERROR, TAG_TTSC, "process checking is FAILED");
+               return FALSE;
        }
-       fclose(fp);
 
-       return FALSE;
-}
+       while ((entry = readdir(dir)) != NULL) {
+               if (0 != lstat(entry->d_name, &filestat))
+                       continue;
 
+               if (!S_ISDIR(filestat.st_mode))
+                       continue;
 
-static void __my_sig_child(int signo, siginfo_t *info, void *data)
-{
-       int status;
-       pid_t child_pid, child_pgid;
+               pid = atoi(entry->d_name);
+               if (pid <= 0) continue;
 
-       child_pgid = getpgid(info->si_pid);
-       SLOG(LOG_DEBUG, TAG_TTSC, "Signal handler: dead pid = %d, pgid = %d\n", info->si_pid, child_pgid);
+               sprintf(tempPath, "/proc/%d/cmdline", pid);
+               if (0 != __get_cmd_line(tempPath, cmdLine)) {
+                       continue;
+               }
 
-       while (0 < (child_pid = waitpid(-1, &status, WNOHANG))) {
-               if(child_pid == child_pgid)
-                       killpg(child_pgid, SIGKILL);
+               if ( 0 == strncmp(cmdLine, "[tts-daemon]", strlen("[tts-daemon]")) ||
+                       0 == strncmp(cmdLine, "tts-daemon", strlen("tts-daemon")) ||
+                       0 == strncmp(cmdLine, "/usr/bin/tts-daemon", strlen("/usr/bin/tts-daemon"))) {
+                               SLOG(LOG_DEBUG, TAG_TTSC, "tts-daemon is ALIVE !!");
+                               closedir(dir);
+                               return TRUE;
+               }
        }
 
-       return;
+       SLOG(LOG_DEBUG, TAG_TTSC, "THERE IS NO tts-daemon !!");
+
+       closedir(dir);
+       return FALSE;
 }
 
-int __tts_check_tts_daemon()
+static int __tts_check_tts_daemon()
 {
-       if (TRUE == _tts_is_alive())
+       if (TRUE == _tts_is_alive()) {
                return 0;
+       }
        
        /* fork-exec tts-daemom */
-       SLOG(LOG_DEBUG, TAG_TTSC, "THERE IS NO tts-daemon \n");
-       SLOG(LOG_DEBUG, TAG_TTSC, "START TTS-DAEMON \n");
-
        int pid, i;
-       struct sigaction act, dummy;
-
-       act.sa_handler = NULL;
-       act.sa_sigaction = __my_sig_child;
-       sigemptyset(&act.sa_mask);
-       act.sa_flags = SA_NOCLDSTOP | SA_SIGINFO;
-       
-       if (sigaction(SIGCHLD, &act, &dummy) < 0) {
-               SLOG(LOG_ERROR, TAG_TTSC, "Cannot make a signal handler");
-               return -1;
-       }
 
        pid = fork();
 
        switch(pid) {
        case -1:
-               SLOG(LOG_ERROR, TAG_TTSC, "fail to create TTS-DAEMON \n");
+               SLOG(LOG_ERROR, TAG_TTSC, "Fail to create tts-daemon");
                break;
 
        case 0:
@@ -855,7 +1096,6 @@ int __tts_check_tts_daemon()
                break;
 
        default:
-               sleep(1);
                break;
        }
 
old mode 100644 (file)
new mode 100755 (executable)
index 6ce02b7..bd8065f
@@ -1,15 +1,18 @@
 /*
-* Copyright (c) 2011 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.
-*/
+ * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
 
 
 #ifndef __TTS_H__
@@ -31,58 +34,51 @@ extern "C" {
 * @brief Enumerations of error codes.
 */
 typedef enum {
-       TTS_ERROR_NONE                  = 0,            /**< Successful */
-       TTS_ERROR_OUT_OF_MEMORY         = -ENOMEM,      /**< Out of Memory */
-       TTS_ERROR_IO_ERROR              = -EIO,         /**< I/O error */
-       TTS_ERROR_INVALID_PARAMETER     = -EINVAL,      /**< Invalid parameter */
-       TTS_ERROR_OUT_OF_NETWORK        = -ENETDOWN,    /**< Out of network */
-       TTS_ERROR_INVALID_STATE         = -0x0100021,   /**< Invalid state */
-       TTS_ERROR_INVALID_VOICE         = -0x0100022,   /**< Invalid voice */
-       TTS_ERROR_ENGINE_NOT_FOUND      = -0x0100023,   /**< No available engine  */
-       TTS_ERROR_TIMED_OUT             = -0x0100024,   /**< No answer from the daemon */
-       TTS_ERROR_OPERATION_FAILED      = -0x0100025    /**< Operation failed  */
+       TTS_ERROR_NONE                  = 0,                    /**< Successful */
+       TTS_ERROR_OUT_OF_MEMORY         = -ENOMEM,              /**< Out of Memory */
+       TTS_ERROR_IO_ERROR              = -EIO,                 /**< I/O error */
+       TTS_ERROR_INVALID_PARAMETER     = -EINVAL,              /**< Invalid parameter */
+       TTS_ERROR_OUT_OF_NETWORK        = -ENETDOWN,            /**< Out of network */
+       TTS_ERROR_INVALID_STATE         = -0x0100000 | 0x21,    /**< Invalid state */
+       TTS_ERROR_INVALID_VOICE         = -0x0100000 | 0x22,    /**< Invalid voice */
+       TTS_ERROR_ENGINE_NOT_FOUND      = -0x0100000 | 0x23,    /**< No available engine  */
+       TTS_ERROR_TIMED_OUT             = -0x0100000 | 0x24,    /**< No answer from the daemon */
+       TTS_ERROR_OPERATION_FAILED      = -0x0100000 | 0x25     /**< Operation failed  */
 } tts_error_e;
 
 /** 
 * @brief Enumerations of speaking speed.
 */
 typedef enum {
-       TTS_SPEED_AUTO,         /**< Speed from settings */
-       TTS_SPEED_VERY_SLOW,    /**< Very slow */
-       TTS_SPEED_SLOW,         /**< Slow */
-       TTS_SPEED_NORMAL,       /**< Normal */
-       TTS_SPEED_FAST,         /**< Fast */
-       TTS_SPEED_VERY_FAST     /**< Very fast */
+       TTS_SPEED_AUTO,                 /**< Speed from settings */
+       TTS_SPEED_VERY_SLOW,            /**< Very slow */
+       TTS_SPEED_SLOW,                 /**< Slow */
+       TTS_SPEED_NORMAL,               /**< Normal */
+       TTS_SPEED_FAST,                 /**< Fast */
+       TTS_SPEED_VERY_FAST             /**< Very fast */
 } tts_speed_e;
 
 /** 
 * @brief Enumerations of voice type.
 */
 typedef enum {
-       TTS_VOICE_TYPE_AUTO,    /**< Voice type from settings or auto selection based language */
-       TTS_VOICE_TYPE_MALE,    /**< Male */
-       TTS_VOICE_TYPE_FEMALE,  /**< Female */
-       TTS_VOICE_TYPE_CHILD,   /**< Child */
-       TTS_VOICE_TYPE_USER1,   /**< Engine defined */
-       TTS_VOICE_TYPE_USER2,   /**< Engine defined */
-       TTS_VOICE_TYPE_USER3    /**< Engine defined */
+       TTS_VOICE_TYPE_AUTO,            /**< Voice type from settings or auto selection based language */
+       TTS_VOICE_TYPE_MALE,            /**< Male */
+       TTS_VOICE_TYPE_FEMALE,          /**< Female */
+       TTS_VOICE_TYPE_CHILD,           /**< Child */
+       TTS_VOICE_TYPE_USER1,           /**< Engine defined */
+       TTS_VOICE_TYPE_USER2,           /**< Engine defined */
+       TTS_VOICE_TYPE_USER3            /**< Engine defined */
 } tts_voice_type_e;
 
 /** 
-* @brief Enumerations of interrupted code.
-*/
-typedef enum {
-       TTS_INTERRUPTED_PAUSED = 0,     /**< The current state be changed #TTS_STATE_PAUSED by the daemon */
-       TTS_INTERRUPTED_STOPPED         /**< The current state be changed #TTS_STATE_READY by the daemon */
-} tts_interrupted_code_e;
-
-/** 
 * @brief Enumerations of state.
 */
 typedef enum {
-       TTS_STATE_READY = 0,    /**< 'READY' state */
-       TTS_STATE_PLAYING,      /**< 'PLAYING' state */
-       TTS_STATE_PAUSED        /**< 'PAUSED' state*/
+       TTS_STATE_CREATED = 0,          /**< 'CREATED' state */
+       TTS_STATE_READY,                /**< 'READY' state */
+       TTS_STATE_PLAYING,              /**< 'PLAYING' state */
+       TTS_STATE_PAUSED                /**< 'PAUSED' state*/
 }tts_state_e;
 
 /** 
@@ -92,22 +88,22 @@ typedef struct tts_s *tts_h;
 
 
 /**
-* @brief Called when the TTS state has changed by the daemon
+* @brief Called when the state of TTS is changed
 *
 * @details If the daemon must stop player because of changing engine and 
 *      the daemon must pause player because of other requests, this callback function is called.
 *
 * @param[in] tts The handle for TTS
-* @param[in] code The interrupt type
-* @param[in] user_data The user data passed from the the callback registration function
+* @param[in] previous A previous state
+* @param[in] current A current state
+* @param[in] user_data The user data passed from the callback registration function.
 *
-* @pre An application registers this callback using tts_set_interrupted_cb() to detect interrupts.
-* @post If this function is called, the TTS state will be #TTS_STATE_READY or #TTS_STATE_PAUSED.
+* @pre An application registers this callback using tts_set_state_changed_cb() to detect changing state.
 *
-* @see tts_set_interrupted_cb()
-* @see tts_unset_interrupted_cb()
+* @see tts_set_state_changed_cb()
+* @see tts_unset_state_changed_cb()
 */
-typedef void (*tts_interrupted_cb)(tts_h tts, tts_interrupted_code_e code, void* user_data); 
+typedef void (*tts_state_changed_cb)(tts_h tts, tts_state_e previous, tts_state_e current, void* user_data);
 
 /**
 * @brief Called when utterance has started.
@@ -174,17 +170,15 @@ typedef void (*tts_error_cb)(tts_h tts, int utt_id, tts_error_e reason, void* us
 */
 typedef bool(*tts_supported_voice_cb)(tts_h tts, const char* language, tts_voice_type_e voice_type, void* user_data);
 
+
 /**
-* @brief Creates a handle for TTS and connects the daemon
+* @brief Creates a handle for TTS. 
 *
 * @param[out] tts The handle for TTS
 *
 * @return 0 on success, otherwise a negative error value
 * @retval #TTS_ERROR_NONE Successful
-* @retval #TTS_ERROR_TIMED_OUT The daemon is blocked or do not exist
-* @retval #TTS_ERROR_ENGINE_NOT_FOUND No available engine \n Engine should be installed
 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #TTS_ERROR_OUT_OF_MEMORY Out of memory
 *
 * @see tts_destroy()
 */
@@ -204,6 +198,40 @@ int tts_create(tts_h* tts);
 int tts_destroy(tts_h tts);
 
 /**
+* @brief Connects the daemon asynchronously. 
+*
+* @param[in] tts The handle for TTS
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #TTS_ERROR_NONE Successful
+* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #TTS_ERROR_INVALID_STATE Invalid state
+*
+* @pre The state should be #TTS_STATE_CREATED.
+* @post If this function is called, the TTS state will be #TTS_STATE_READY.
+*
+* @see tts_unprepare()
+*/
+int tts_prepare(tts_h tts);
+
+/**
+* @brief Disconnects the daemon.
+*
+* @param[in] tts The handle for TTS
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #TTS_ERROR_NONE Successful
+* @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #STT_ERROR_INVALID_STATE Invalid state
+*
+* @pre The state should be #TTS_STATE_READY.
+* @post If this function is called, the TTS state will be #TTS_STATE_CREATED.
+*
+* @see tts_prepare()
+*/
+int tts_unprepare(tts_h tts);
+
+/**
 * @brief Retrieves all supported voices of the current engine using callback function.
 *
 * @param[in] tts The handle for TTS
@@ -214,6 +242,8 @@ int tts_destroy(tts_h tts);
 * @retval #TTS_ERROR_NONE Successful
 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
+*
+* @pre The state should be #TTS_STATE_READY.
 * @post        This function invokes tts_supported_voice_cb() repeatedly for getting voices. 
 *
 * @see tts_get_default_voice()
@@ -237,6 +267,8 @@ int tts_foreach_supported_voices(tts_h tts, tts_supported_voice_cb callback, voi
 * @retval #TTS_ERROR_OUT_OF_MEMORY Out of memory
 * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
 *
+* @pre The state should be #TTS_STATE_READY.
+*
 * @see tts_foreach_supported_voices()
 */
 int tts_get_default_voice(tts_h tts, char** language, tts_voice_type_e* voice_type);
@@ -252,6 +284,8 @@ int tts_get_default_voice(tts_h tts, char** language, tts_voice_type_e* voice_ty
 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
 *
+* @pre The state should be #TTS_STATE_READY.
+*
 * @see tts_add_text()
 */
 int tts_get_max_text_count(tts_h tts, int* count);
@@ -281,7 +315,7 @@ int tts_get_state(tts_h tts, tts_state_e* state);
 * @param[in] language The language selected from the foreach function
 * @param[in] voice_type The voice type selected from the foreach function
 * @param[in] speed A speaking speed
-* @param[out] utt_id The utterance ID passed to the callback function.
+* @param[out] utt_id The utterance ID passed to the callback function
 *
 * @return 0 on success, otherwise a negative error value
 * @retval #TTS_ERROR_NONE Successful
@@ -290,6 +324,7 @@ int tts_get_state(tts_h tts, tts_state_e* state);
 * @retval #TTS_ERROR_OUT_OF_MEMORY Out of memory
 * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
 *
+* @pre The state should be #TTS_STATE_READY, #TTS_STATE_PLAYING or #TTS_STATE_PAUSED.
 * @see tts_get_max_text_count()
 */
 int tts_add_text(tts_h tts, const char* text, const char* language, tts_voice_type_e voice_type, tts_speed_e speed, int* utt_id);
@@ -360,7 +395,7 @@ int tts_stop(tts_h tts);
 int tts_pause(tts_h tts);
 
 /**
-* @brief Registers a callback function for detecting player interrupted.
+* @brief Registers a callback function to be called when TTS state changes.
 *
 * @param[in] tts The handle for TTS
 * @param[in] callback The callback function to register
@@ -370,10 +405,12 @@ int tts_pause(tts_h tts);
 * @retval #TTS_ERROR_NONE Successful
 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
 *
-* @see tts_interrupted_cb()
-* @see tts_unset_interrupted_cb()
+* @pre The state should be #TTS_STATE_CREATED.
+*
+* @see tts_state_changed_cb()
+* @see tts_unset_state_changed_cb()
 */
-int tts_set_interrupted_cb(tts_h tts, tts_interrupted_cb callback, void* user_data);
+int tts_set_state_changed_cb(tts_h tts, tts_state_changed_cb callback, void* user_data);
 
 /**
 * @brief Unregisters the callback function.
@@ -384,9 +421,11 @@ int tts_set_interrupted_cb(tts_h tts, tts_interrupted_cb callback, void* user_da
 * @retval #TTS_ERROR_NONE Successful
 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
 *
-* @see tts_set_interrupted_cb()
+* @pre The state should be #TTS_STATE_CREATED.
+*
+* @see tts_set_state_changed_cb()
 */
-int tts_unset_interrupted_cb(tts_h tts);
+int tts_unset_state_changed_cb(tts_h tts);
 
 /**
 * @brief Registers a callback function for detecting utterance started.
@@ -399,6 +438,8 @@ int tts_unset_interrupted_cb(tts_h tts);
 * @retval #TTS_ERROR_NONE Successful
 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
 *
+* @pre The state should be #TTS_STATE_CREATED.
+*
 * @see tts_utterance_started_cb()
 * @see tts_unset_utterance_started_cb()
 */
@@ -413,6 +454,8 @@ int tts_set_utterance_started_cb(tts_h tts, tts_utterance_started_cb callback, v
 * @retval #TTS_ERROR_NONE Successful
 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
 *
+* @pre The state should be #TTS_STATE_CREATED.
+*
 * @see tts_set_utterance_started_cb()
 */
 int tts_unset_utterance_started_cb(tts_h tts);
@@ -428,6 +471,8 @@ int tts_unset_utterance_started_cb(tts_h tts);
 * @retval #TTS_ERROR_NONE Successful
 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
 *
+* @pre The state should be #TTS_STATE_CREATED.
+*
 * @see tts_utterance_completed_cb()
 * @see tts_unset_utterance_completed_cb()
 */
@@ -442,6 +487,8 @@ int tts_set_utterance_completed_cb(tts_h tts, tts_utterance_completed_cb callbac
 * @retval #TTS_ERROR_NONE Successful
 * @retval #TTS_ERROR_OUT_OF_MEMORY Out of memory
 *
+* @pre The state should be #TTS_STATE_CREATED.
+*
 * @see tts_set_utterance_completed_cb()
 */
 int tts_unset_utterance_completed_cb(tts_h tts);
@@ -457,6 +504,8 @@ int tts_unset_utterance_completed_cb(tts_h tts);
 * @retval #TTS_ERROR_NONE Successful
 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
 *
+* @pre The state should be #TTS_STATE_CREATED.
+*
 * @see tts_error_cb()
 * @see tts_unset_error_cb()
 */
@@ -471,6 +520,8 @@ int tts_set_error_cb(tts_h tts, tts_error_cb callback, void* user_data);
 * @retval #TTS_ERROR_NONE Successful
 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
 *
+* @pre The state should be #TTS_STATE_CREATED.
+*
 * @see tts_set_error_cb()
 */
 int tts_unset_error_cb(tts_h tts);
old mode 100644 (file)
new mode 100755 (executable)
index 450a30a..5b3f67b
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved 
+*  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
@@ -39,7 +39,7 @@ int tts_client_new(tts_h* tts)
        tts_client_s* client = NULL;
        client = (tts_client_s*)g_malloc0 (sizeof(tts_client_s));
 
-       tts_h temp = (tts_h)g_malloc0(sizeof(tts_h));
+       tts_h temp = (tts_h)g_malloc0(sizeof(struct tts_s));
        temp->handle = __client_generate_uid(getpid()); 
 
        /* initialize client data */
@@ -48,8 +48,8 @@ int tts_client_new(tts_h* tts)
        client->uid = temp->handle;
        client->current_utt_id = 0;
 
-       client->interrupted_cb = NULL;
-       client->interrupted_user_data = NULL;
+       client->state_changed_cb = NULL;
+       client->state_changed_user_data = NULL;
        
        client->utt_started_cb = NULL;
        client->utt_started_user_data = NULL;
@@ -59,7 +59,8 @@ int tts_client_new(tts_h* tts)
        client->error_cb = NULL;
        client->error_user_data = NULL;
 
-       client->current_state = TTS_STATE_READY; 
+       client->before_state = TTS_STATE_CREATED; 
+       client->current_state = TTS_STATE_CREATED; 
 
        client->cb_ref_count = 0;
 
@@ -187,3 +188,8 @@ int tts_client_not_use_callback(tts_client_s* client)
        client->cb_ref_count--;
        return 0;
 }
+
+int tts_client_get_use_callback(tts_client_s* client)
+{
+       return client->cb_ref_count;
+}
\ No newline at end of file
old mode 100644 (file)
new mode 100755 (executable)
index ad0a60c..c158f6f
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved 
+*  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
@@ -31,8 +31,8 @@ typedef struct {
        int     current_utt_id;
 
        /* callback info */
-       tts_interrupted_cb              interrupted_cb;
-       void*                           interrupted_user_data;
+       tts_state_changed_cb            state_changed_cb;
+       void*                           state_changed_user_data;
        tts_utterance_started_cb        utt_started_cb;
        void*                           utt_started_user_data;
        tts_utterance_completed_cb      utt_completeted_cb;
@@ -41,10 +41,15 @@ typedef struct {
        void*                           error_user_data;
 
        /* state */
+       tts_state_e     before_state;
        tts_state_e     current_state;
 
        /* semaphore */
        int             cb_ref_count;
+
+       /* callback data */
+       int             utt_id;
+       int             reason;
 }tts_client_s;
 
 int tts_client_new(tts_h* tts);
@@ -61,6 +66,8 @@ int tts_client_use_callback(tts_client_s* client);
 
 int tts_client_not_use_callback(tts_client_s* client);
 
+int tts_client_get_use_callback(tts_client_s* client);
+
 #ifdef __cplusplus
 }
 #endif
old mode 100644 (file)
new mode 100755 (executable)
index 41a2cd2..73a7fc4
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved 
+*  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
 #include "tts_main.h"
 #include "tts_dbus.h"
 #include "tts_defs.h"
+#include "tts_client.h"
 
+#define INIT_WAITING_TIME 5000
+#define WAITING_TIME 1000
 
 static Ecore_Fd_Handler* g_fd_handler = NULL;
 
@@ -25,7 +28,7 @@ static DBusConnection* g_conn = NULL;
 
 extern int __tts_cb_error(int uid, tts_error_e reason, int utt_id);
 
-extern int __tts_cb_interrupt(int uid, tts_interrupted_code_e code);
+extern int __tts_cb_set_state(int uid, int state);
 
 extern int __tts_cb_utt_started(int uid, int utt_id);
 
@@ -50,12 +53,54 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
 
        DBusError err;
        dbus_error_init(&err);
+
+       DBusMessage *reply = NULL; 
        
        char if_name[64];
        snprintf(if_name, 64, "%s%d", TTS_CLIENT_SERVICE_INTERFACE, getpid());
 
        /* check if the message is a signal from the correct interface and with the correct name */
-       if (dbus_message_is_signal(msg, if_name, TTS_SIGNAL_UTTERANCE_STARTED)) {
+       if (dbus_message_is_method_call(msg, if_name, TTSD_METHOD_HELLO)) {
+               SLOG(LOG_DEBUG, TAG_TTSC, "===== Get Hello");
+               int uid = 0;
+               int response = -1;
+
+               dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
+
+               if (uid > 0) {
+                       SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts get hello : uid(%d) \n", uid);
+
+                       /* check uid */
+                       tts_client_s* client = tts_client_get_by_uid(uid);
+                       if (NULL != client) 
+                               response = 1;
+                       else 
+                               response = 0;
+               } else {
+                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts get hello : invalid uid \n");
+               }
+
+               reply = dbus_message_new_method_return(msg);
+
+               if (NULL != reply) {
+                       dbus_message_append_args(reply, DBUS_TYPE_INT32, &response, DBUS_TYPE_INVALID);
+
+                       if (!dbus_connection_send(conn, reply, NULL))
+                               SLOG(LOG_ERROR, TAG_TTSC, ">>>> tts get hello : fail to send reply");
+                       else 
+                               SLOG(LOG_DEBUG, TAG_TTSC, ">>>> tts get hello : result(%d)", response);
+
+                       dbus_connection_flush(conn);
+                       dbus_message_unref(reply); 
+               } else {
+                       SLOG(LOG_ERROR, TAG_TTSC, ">>>> tts get hello : fail to create reply message");
+               }
+
+               SLOG(LOG_DEBUG, TAG_TTSC, "=====");
+               SLOG(LOG_DEBUG, TAG_TTSC, " ");
+       } /* TTSD_METHOD_HELLO */
+
+       else if (dbus_message_is_method_call(msg, if_name, TTSD_METHOD_UTTERANCE_STARTED)) {
                SLOG(LOG_DEBUG, TAG_TTSC, "===== Get utterance started");
                int uid, uttid;
                dbus_message_get_args(msg, &err,
@@ -67,14 +112,15 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
                        SLOG(LOG_ERROR, TAG_TTSC, "<<<< Get Utterance started - Get arguments error (%s)\n", err.message);
                        dbus_error_free(&err); 
                } else {
-                       SLOG(LOG_DEBUG, TAG_TTSC, "<<<< Get Utterance started signal : uid(%d), uttid(%d) \n", uid, uttid);
+                       SLOG(LOG_DEBUG, TAG_TTSC, "<<<< Get Utterance started message : uid(%d), uttid(%d) \n", uid, uttid);
                        __tts_cb_utt_started(uid, uttid);
                }
+
                SLOG(LOG_DEBUG, TAG_TTSC, "=====");
                SLOG(LOG_DEBUG, TAG_TTSC, " ");
        }/* TTS_SIGNAL_UTTERANCE_STARTED */
 
-       else if (dbus_message_is_signal(msg, if_name, TTS_SIGNAL_UTTERANCE_COMPLETED)) {
+       else if (dbus_message_is_method_call(msg, if_name, TTSD_METHOD_UTTERANCE_COMPLETED)) {
                SLOG(LOG_DEBUG, TAG_TTSC, "===== Get utterance completed");
                int uid, uttid;
                dbus_message_get_args(msg, &err,
@@ -86,34 +132,36 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
                        SLOG(LOG_ERROR, TAG_TTSC, "<<<< Get Utterance completed - Get arguments error (%s)\n", err.message);
                        dbus_error_free(&err); 
                } else {
-                       SLOG(LOG_DEBUG, TAG_TTSC, "<<<< Get Utterance completed signal : uid(%d), uttid(%d) \n", uid, uttid);
+                       SLOG(LOG_DEBUG, TAG_TTSC, "<<<< Get Utterance completed message : uid(%d), uttid(%d) \n", uid, uttid);
                        __tts_cb_utt_completed(uid, uttid);
                }
+
                SLOG(LOG_DEBUG, TAG_TTSC, "=====");
                SLOG(LOG_DEBUG, TAG_TTSC, " ");
        }/* TTS_SIGNAL_UTTERANCE_COMPLETED */
 
-       else if (dbus_message_is_signal(msg, if_name, TTS_SIGNAL_INTERRUPT)) {
-               SLOG(LOG_DEBUG, TAG_TTSC, "===== Get interrupt callback");
+       else if (dbus_message_is_method_call(msg, if_name, TTSD_METHOD_SET_STATE)) {
+               SLOG(LOG_DEBUG, TAG_TTSC, "===== Get state changed callback");
                int uid;
-               int code;
+               int state;
                dbus_message_get_args(msg, &err,
                        DBUS_TYPE_INT32, &uid,
-                       DBUS_TYPE_INT32, &code,
+                       DBUS_TYPE_INT32, &state,
                        DBUS_TYPE_INVALID);
 
                if (dbus_error_is_set(&err)) { 
-                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< Get Stop signal - Get arguments error (%s)\n", err.message);
+                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< Get state change - Get arguments error (%s)", err.message);
                        dbus_error_free(&err); 
                } else {
-                       SLOG(LOG_DEBUG, TAG_TTSC, "<<<< Get Interrupt signal : uid(%d) , interrupt code(%d)\n", uid, code);
-                       __tts_cb_interrupt(uid, (tts_interrupted_code_e)code);
+                       SLOG(LOG_DEBUG, TAG_TTSC, "<<<< Get state change : uid(%d) , state(%d)", uid, state);
+                       __tts_cb_set_state(uid, state);
                }
+
                SLOG(LOG_DEBUG, TAG_TTSC, "=====");
                SLOG(LOG_DEBUG, TAG_TTSC, " ");
-       } /* TTS_SIGNAL_INTERRUPT */
+       } /* TTSD_METHOD_SET_STATE */
 
-       else if (dbus_message_is_signal(msg, if_name, TTS_SIGNAL_ERROR)) {
+       else if (dbus_message_is_method_call(msg, if_name, TTSD_METHOD_ERROR)) {
                SLOG(LOG_DEBUG, TAG_TTSC, "===== Get error callback");
 
                int uid;
@@ -133,6 +181,7 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
                        SLOG(LOG_DEBUG, TAG_TTSC, "<<<< Get Error signal : uid(%d), error(%d), uttid(%d)\n", uid, reason, uttid);
                        __tts_cb_error(uid, reason, uttid);
                }
+
                SLOG(LOG_DEBUG, TAG_TTSC, "=====");
                SLOG(LOG_DEBUG, TAG_TTSC, " ");
        }/* TTS_SIGNAL_ERROR */
@@ -170,6 +219,8 @@ int tts_dbus_open_connection()
                return TTS_ERROR_OPERATION_FAILED; 
        }
 
+       dbus_connection_set_exit_on_disconnect(g_conn, false);
+
        int pid = getpid();
 
        char service_name[64];
@@ -222,6 +273,8 @@ int tts_dbus_close_connection()
        DBusError err;
        dbus_error_init(&err);
 
+       ecore_main_fd_handler_del(g_fd_handler);
+
        int pid = getpid();
 
        char service_name[64];
@@ -230,15 +283,77 @@ int tts_dbus_close_connection()
 
        dbus_bus_release_name (g_conn, service_name, &err);
 
+       dbus_connection_close(g_conn);
+       
+       g_fd_handler = NULL;
        g_conn = NULL;
 
        return 0;
 }
 
 
+int tts_dbus_reconnect()
+{
+       bool connected = dbus_connection_get_is_connected(g_conn);
+       SLOG(LOG_DEBUG, "[DBUS] %s\n", connected ? "Connected" : "Not connected");
+
+       if (false == connected) {
+               tts_dbus_close_connection();
+
+               if(0 != tts_dbus_open_connection()) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to reconnect");
+                       return -1;
+               } 
+
+               SLOG(LOG_DEBUG, TAG_TTSC, "[DBUS] Reconnect");
+       }
+       
+       return 0;
+}
+
+
+int tts_dbus_request_hello()
+{
+       DBusMessage* msg;
+
+       msg = dbus_message_new_method_call(
+               TTS_SERVER_SERVICE_NAME, 
+               TTS_SERVER_SERVICE_OBJECT_PATH, 
+               TTS_SERVER_SERVICE_INTERFACE, 
+               TTS_METHOD_HELLO);
+
+       if (NULL == msg) { 
+               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts hello : Fail to make message \n"); 
+               return TTS_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, WAITING_TIME, &err);
+
+       dbus_message_unref(msg);
+
+       if (NULL != result_msg) {
+               dbus_message_unref(result_msg);
+
+               SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts hello");
+               result = 0;
+       } else {
+               result = TTS_ERROR_OPERATION_FAILED;
+       }
+
+       return result;
+}
+
 int tts_dbus_request_initialize(int uid)
 {
        DBusMessage* msg;
+       DBusError err;
+       dbus_error_init(&err);
 
        msg = dbus_message_new_method_call(
                TTS_SERVER_SERVICE_NAME, 
@@ -247,25 +362,31 @@ int tts_dbus_request_initialize(int uid)
                TTS_METHOD_INITIALIZE);
 
        if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts initialize : Fail to make message \n"); 
+               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts initialize : Fail to make message \n");
+               if (dbus_error_is_set(&err))  
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
+       
                return TTS_ERROR_OPERATION_FAILED;
        } else {
                SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request tts initialize : uid(%d)", uid);
        }
 
        int pid = getpid();
-       dbus_message_append_args( msg, 
-               DBUS_TYPE_INT32, &pid,
-               DBUS_TYPE_INT32, &uid,
-               DBUS_TYPE_INVALID);
+       if (true != dbus_message_append_args(msg, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID)) {
+               dbus_message_unref(msg);
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to append args"); 
 
-       DBusError err;
-       dbus_error_init(&err);
+               return TTS_ERROR_OPERATION_FAILED;
+       }
 
        DBusMessage* result_msg;
        int result = TTS_ERROR_OPERATION_FAILED;
 
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 3000, &err);
+       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, INIT_WAITING_TIME, &err);
+       dbus_message_unref(msg);
+
+       if (dbus_error_is_set(&err))  
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
 
        if (NULL != result_msg) {
                dbus_message_get_args(result_msg, &err,
@@ -281,6 +402,9 @@ int tts_dbus_request_initialize(int uid)
                dbus_message_unref(result_msg);
        } else {
                SLOG(LOG_ERROR, TAG_TTSC, "<<<< Result message is NULL ");
+               if (dbus_error_is_set(&err))  
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
+               tts_dbus_reconnect();
        }
 
        if (0 == result) {
@@ -289,8 +413,6 @@ int tts_dbus_request_initialize(int uid)
                SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts initialize : result = %d \n", result);
        }
        
-       dbus_message_unref(msg);
-
        return result;
 }
 
@@ -298,6 +420,8 @@ int tts_dbus_request_initialize(int uid)
 int tts_dbus_request_finalize(int uid)
 {
        DBusMessage* msg;
+       DBusError err;
+       dbus_error_init(&err);
 
        msg = dbus_message_new_method_call(
                TTS_SERVER_SERVICE_NAME, 
@@ -306,21 +430,30 @@ int tts_dbus_request_finalize(int uid)
                TTS_METHOD_FINALIZE);
 
        if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts finalize : Fail to make message \n"); 
+               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts finalize : Fail to make message"); 
+               if (dbus_error_is_set(&err))  
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
+
                return TTS_ERROR_OPERATION_FAILED;
        } else {
                SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request tts finalize : uid(%d)", uid);
        }
 
-       dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
+       if (true != dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID)) {
+               dbus_message_unref(msg);
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to append args"); 
 
-       DBusError err;
-       dbus_error_init(&err);
+               return TTS_ERROR_OPERATION_FAILED;
+       }
 
        DBusMessage* result_msg;
        int result = TTS_ERROR_OPERATION_FAILED;
 
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 3000, &err);
+       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, WAITING_TIME, &err);
+       dbus_message_unref(msg);
+
+       if (dbus_error_is_set(&err))  
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
 
        if (NULL != result_msg) {
                dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
@@ -334,6 +467,9 @@ int tts_dbus_request_finalize(int uid)
                dbus_message_unref(result_msg);
        } else {
                SLOG(LOG_ERROR, TAG_TTSC, "<<<< Result message is NULL ");
+               if (dbus_error_is_set(&err))  
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
+               tts_dbus_reconnect();
        }
 
        if (0 == result) {
@@ -342,14 +478,14 @@ int tts_dbus_request_finalize(int uid)
                SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts finalize : result = %d \n", result);
        }
 
-       dbus_message_unref(msg);
-
        return result;
 }
 
 int tts_dbus_request_get_support_voice(int uid, tts_h tts, tts_supported_voice_cb callback, void* user_data)
 {
        DBusMessage* msg;
+       DBusError err;
+       dbus_error_init(&err);
 
        msg = dbus_message_new_method_call(
                TTS_SERVER_SERVICE_NAME, 
@@ -358,24 +494,33 @@ int tts_dbus_request_get_support_voice(int uid, tts_h tts, tts_supported_voice_c
                TTS_METHOD_GET_SUPPORT_VOICES);
 
        if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts get supported voices : Fail to make message \n"); 
+               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts get supported voices : Fail to make message"); 
+               if (dbus_error_is_set(&err))  
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
+
                return TTS_ERROR_OPERATION_FAILED;
        } else {
                SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request tts get supported voices : uid(%d)", uid);
        }
 
-       dbus_message_append_args( msg, 
-               DBUS_TYPE_INT32, &uid,
-               DBUS_TYPE_INVALID);
+       if (true != dbus_message_append_args( msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID)) {
+               dbus_message_unref(msg);
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to append args"); 
 
-       DBusError err;
-       dbus_error_init(&err);
+               return TTS_ERROR_OPERATION_FAILED;
+       }
 
        DBusMessage* result_msg;
        DBusMessageIter args;
        int result = TTS_ERROR_OPERATION_FAILED;
 
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 3000, &err );
+       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, WAITING_TIME, &err );
+       dbus_message_unref(msg);
+
+       if (dbus_error_is_set(&err)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
+               printf("result message : %p\n", result_msg);
+       }
 
        if (NULL != result_msg) {
                if (dbus_message_iter_init(result_msg, &args)) {
@@ -423,10 +568,11 @@ int tts_dbus_request_get_support_voice(int uid, tts_h tts, tts_supported_voice_c
                dbus_message_unref(result_msg);
        } else {
                SLOG(LOG_ERROR, TAG_TTSC, "<<<< Result message is NULL");
+               if (dbus_error_is_set(&err))  
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
+               tts_dbus_reconnect();
        }
 
-       dbus_message_unref(msg);
-
        return result;
 }
 
@@ -438,6 +584,8 @@ int tts_dbus_request_get_default_voice(int uid , char** lang, tts_voice_type_e*
        }
 
        DBusMessage* msg;
+       DBusError err;
+       dbus_error_init(&err);
 
        msg = dbus_message_new_method_call(
                TTS_SERVER_SERVICE_NAME, 
@@ -446,25 +594,34 @@ int tts_dbus_request_get_default_voice(int uid , char** lang, tts_voice_type_e*
                TTS_METHOD_GET_CURRENT_VOICE);
 
        if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts get default voice : Fail to make message \n"); 
+               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts get default voice : Fail to make message"); 
+               if (dbus_error_is_set(&err))  
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
+
                return TTS_ERROR_OPERATION_FAILED;
        } else {
                SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request tts get default voice : uid(%d)", uid);
        }
 
-       dbus_message_append_args( msg, 
-               DBUS_TYPE_INT32, &uid,
-               DBUS_TYPE_INVALID);
+       if (true != dbus_message_append_args( msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID)) {
+               dbus_message_unref(msg);
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to append args"); 
 
-       DBusError err;
-       dbus_error_init(&err);
+               return TTS_ERROR_OPERATION_FAILED;
+       }
 
        DBusMessage* result_msg;
        int result = TTS_ERROR_OPERATION_FAILED;
        char* temp_lang;
        int voice_type;
 
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 3000, &err);
+       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, WAITING_TIME, &err);
+       dbus_message_unref(msg);
+
+       if (dbus_error_is_set(&err)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
+               printf("result message : %p\n", result_msg);
+       }
 
        if (NULL != result_msg) {
                dbus_message_get_args(result_msg, &err,
@@ -481,6 +638,9 @@ int tts_dbus_request_get_default_voice(int uid , char** lang, tts_voice_type_e*
                dbus_message_unref(result_msg);
        } else {
                SLOG(LOG_ERROR, TAG_TTSC, "<<<< Result message is NULL ");
+               if (dbus_error_is_set(&err))  
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
+               tts_dbus_reconnect();
        }
 
        if (0 == result) {
@@ -497,8 +657,6 @@ int tts_dbus_request_get_default_voice(int uid , char** lang, tts_voice_type_e*
                SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts get default voice : result(%d) \n", result);
        }
 
-       dbus_message_unref(msg);
-
        return result;
 }
 
@@ -511,6 +669,8 @@ int tts_dbus_request_add_text(int uid, const char* text, const char* lang, int v
        }
 
        DBusMessage* msg;
+       DBusError err;
+       dbus_error_init(&err);
 
        msg = dbus_message_new_method_call(
                TTS_SERVER_SERVICE_NAME, 
@@ -519,29 +679,38 @@ int tts_dbus_request_add_text(int uid, const char* text, const char* lang, int v
                TTS_METHOD_ADD_QUEUE);
 
        if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts add text : Fail to make message \n"); 
+               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts add text : Fail to make message"); 
+               if (dbus_error_is_set(&err))  
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
+
                return TTS_ERROR_OPERATION_FAILED;
        } else {
                SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request tts add text : uid(%d), text(%s), lang(%s), type(%d), speed(%d), id(%d)", 
                        uid, text, lang, vctype, speed, uttid);
        }
 
-       dbus_message_append_args( msg, 
+       if (true != dbus_message_append_args( msg, 
                DBUS_TYPE_INT32, &uid,
                DBUS_TYPE_STRING, &text,
                DBUS_TYPE_STRING, &lang,
                DBUS_TYPE_INT32, &vctype,
                DBUS_TYPE_INT32, &speed,
                DBUS_TYPE_INT32, &uttid,
-               DBUS_TYPE_INVALID);
+               DBUS_TYPE_INVALID)) {
+               dbus_message_unref(msg);
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to append args"); 
 
-       DBusError err;
-       dbus_error_init(&err);
+               return TTS_ERROR_OPERATION_FAILED;
+       }
 
        DBusMessage* result_msg;
        int result = TTS_ERROR_OPERATION_FAILED;
 
        result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 5000, &err);
+       dbus_message_unref(msg);
+
+       if (dbus_error_is_set(&err))  
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
 
        if (NULL != result_msg) {
                dbus_message_get_args(result_msg, &err,
@@ -556,15 +725,16 @@ int tts_dbus_request_add_text(int uid, const char* text, const char* lang, int v
                dbus_message_unref(result_msg);
        } else {
                SLOG(LOG_ERROR, TAG_TTSC, "<<<< Result message is NULL ");
+               if (dbus_error_is_set(&err))  
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
+               tts_dbus_reconnect();
        }
 
        if (0 == result) {
                SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts add text : result(%d) \n", result);
        } else {
                SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts add text : result(%d) \n", result);
-       }
-
-       dbus_message_unref(msg);
+       }       
 
        return result;
 }
@@ -572,6 +742,8 @@ int tts_dbus_request_add_text(int uid, const char* text, const char* lang, int v
 int tts_dbus_request_play(int uid) 
 {
        DBusMessage* msg;
+       DBusError err;
+       dbus_error_init(&err);
 
        msg = dbus_message_new_method_call(
                TTS_SERVER_SERVICE_NAME,
@@ -580,23 +752,30 @@ int tts_dbus_request_play(int uid)
                TTS_METHOD_PLAY );               
 
        if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts play : Fail to make message \n"); 
+               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts play : Fail to make message"); 
+               if (dbus_error_is_set(&err))  
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
+
                return TTS_ERROR_OPERATION_FAILED;
        } else {
                SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request tts play : uid(%d)", uid);
        }
        
-       dbus_message_append_args( msg, 
-               DBUS_TYPE_INT32, &uid,
-               DBUS_TYPE_INVALID);
+       if (true != dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID)) {
+               dbus_message_unref(msg);
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to append args"); 
 
-       DBusError err;
-       dbus_error_init(&err);
+               return TTS_ERROR_OPERATION_FAILED;
+       }
 
        DBusMessage* result_msg;
        int result = TTS_ERROR_OPERATION_FAILED;
 
        result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 5000, &err);
+       dbus_message_unref(msg);
+
+       if (dbus_error_is_set(&err))  
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
 
        if (NULL != result_msg) {
                dbus_message_get_args(result_msg, &err,
@@ -611,6 +790,9 @@ int tts_dbus_request_play(int uid)
                dbus_message_unref(result_msg);
        } else {
                SLOG(LOG_ERROR, TAG_TTSC, "<<<< Result message is NULL ");
+               if (dbus_error_is_set(&err))  
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
+               tts_dbus_reconnect();
        }
 
        if (0 == result) {
@@ -618,8 +800,6 @@ int tts_dbus_request_play(int uid)
        } else {
                SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts play : result(%d) \n", result);
        }
-
-       dbus_message_unref(msg);
        
        return result;
 }
@@ -628,6 +808,8 @@ int tts_dbus_request_play(int uid)
 int tts_dbus_request_stop(int uid)
 {
        DBusMessage* msg;
+       DBusError err;
+       dbus_error_init(&err);
 
        msg = dbus_message_new_method_call(
                TTS_SERVER_SERVICE_NAME, 
@@ -636,21 +818,30 @@ int tts_dbus_request_stop(int uid)
                TTS_METHOD_STOP);
 
        if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts stop : Fail to make message \n"); 
+               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts stop : Fail to make message"); 
+               if (dbus_error_is_set(&err))  
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
+
                return TTS_ERROR_OPERATION_FAILED;
        } else {
                SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request tts stop : uid(%d)", uid);
        }
 
-       DBusError err;
-       dbus_error_init(&err);
-
        DBusMessage* result_msg;
        int result = TTS_ERROR_OPERATION_FAILED;
 
-       dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
+       if (true != dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID)) {
+               dbus_message_unref(msg);
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to append args"); 
+
+               return TTS_ERROR_OPERATION_FAILED;
+       }
 
        result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 5000, &err);
+       dbus_message_unref(msg);
+
+       if (dbus_error_is_set(&err))  
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
 
        if (NULL != result_msg) {
                dbus_message_get_args(result_msg, &err,
@@ -665,6 +856,9 @@ int tts_dbus_request_stop(int uid)
                dbus_message_unref(result_msg);
        } else {
                SLOG(LOG_ERROR, TAG_TTSC, "<<<< Result message is NULL ");
+               if (dbus_error_is_set(&err))  
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
+               tts_dbus_reconnect();
        }
 
        if (0 == result) {
@@ -673,14 +867,14 @@ int tts_dbus_request_stop(int uid)
                SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts stop : result(%d) \n", result);
        }
 
-       dbus_message_unref(msg);
-
        return result;
 }
 
 int tts_dbus_request_pause(int uid)
 {
        DBusMessage* msg;
+       DBusError err;
+       dbus_error_init(&err);
 
        msg = dbus_message_new_method_call(
                TTS_SERVER_SERVICE_NAME, 
@@ -689,21 +883,30 @@ int tts_dbus_request_pause(int uid)
                TTS_METHOD_PAUSE);
 
        if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts pause : Fail to make message \n"); 
+               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts pause : Fail to make message"); 
+               if (dbus_error_is_set(&err))  
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
+
                return TTS_ERROR_OPERATION_FAILED;
        } else {
                SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request tts pause : uid(%d)", uid);
        }
 
-       DBusError err;
-       dbus_error_init(&err);
-
        DBusMessage* result_msg;
        int result = TTS_ERROR_OPERATION_FAILED;
 
-       dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
+       if (true != dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID)) {
+               dbus_message_unref(msg);
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to append args"); 
+
+               return TTS_ERROR_OPERATION_FAILED;
+       }
 
        result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 5000, &err);
+       dbus_message_unref(msg);
+
+       if (dbus_error_is_set(&err))  
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
 
        if (NULL != result_msg) {
                dbus_message_get_args(result_msg, &err,
@@ -718,6 +921,9 @@ int tts_dbus_request_pause(int uid)
                dbus_message_unref(result_msg);
        } else {
                SLOG(LOG_ERROR, TAG_TTSC, "<<<< Result message is NULL ");
+               if (dbus_error_is_set(&err))  
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] %s", err.message);
+               tts_dbus_reconnect();
        }
 
        if (0 == result) {
@@ -726,7 +932,5 @@ int tts_dbus_request_pause(int uid)
                SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts pause : result(%d) \n", result);
        }
 
-       dbus_message_unref(msg);
-
        return result;
 }
old mode 100644 (file)
new mode 100755 (executable)
index c252fc2..c94973e
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved 
+*  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
@@ -25,6 +25,9 @@ int tts_dbus_open_connection();
 
 int tts_dbus_close_connection();
 
+
+int tts_dbus_request_hello();
+
 int tts_dbus_request_initialize(int uid);
 
 int tts_dbus_request_finalize(int uid);
old mode 100644 (file)
new mode 100755 (executable)
index e2cd331..9dbe328
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved 
+*  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
old mode 100644 (file)
new mode 100755 (executable)
index e8ecf9e..9bdcf06
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved 
+*  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
 
 
 #include <sys/wait.h>
+#include <Ecore.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <dirent.h>
 
 #include "tts_main.h"
 #include "tts_setting.h"
 #include "tts_setting_dbus.h"
 
-static bool g_is_setting_initialized = false;
+static bool g_is_daemon_started = false;
 
-static int __check_tts_daemon();
+static int __check_setting_tts_daemon();
 
+static tts_setting_state_e g_state = TTS_SETTING_STATE_NONE;
+
+static tts_setting_initialized_cb g_initialized_cb;
+static void* g_user_data;
+
+static int g_reason;
 
 /* API Implementation */
+static Eina_Bool __tts_setting_initialized(void *data)
+{
+       g_initialized_cb(g_state, g_reason, g_user_data);
+
+       return EINA_FALSE;
+}
+
+static Eina_Bool __tts_setting_connect_daemon(void *data)
+{
+       /* Send hello */
+       if (0 != tts_setting_dbus_request_hello()) {
+               if (false == g_is_daemon_started) {
+                       g_is_daemon_started = true;
+                       __check_setting_tts_daemon();
+               }
+               return EINA_TRUE;
+       }
+
+       SLOG(LOG_DEBUG, TAG_TTSC, "===== Connect daemon");
+
+       /* do request initialize */
+       int ret = -1;
+
+       ret = tts_setting_dbus_request_initialize();
+
+       if (TTS_SETTING_ERROR_ENGINE_NOT_FOUND == ret) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Engine not found");
+       } else if (TTS_SETTING_ERROR_NONE != ret) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to connection : %d", ret);
+       } else {
+               /* success to connect tts-daemon */
+               g_state = TTS_SETTING_STATE_READY;
+       }
+
+       g_reason = ret;
+
+       ecore_timer_add(0, __tts_setting_initialized, NULL);
+
+       SLOG(LOG_DEBUG, TAG_TTSC, "=====");
+       SLOG(LOG_DEBUG, TAG_TTSC, " ");
+
+       return EINA_FALSE;
+}
+
 int tts_setting_initialize()
 {
        SLOG(LOG_DEBUG, TAG_TTSC, "===== Initialize TTS Setting");
 
-       /* Check daemon */
-       __check_tts_daemon();
-
-       if (true == g_is_setting_initialized) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] TTS Setting has already been initialized. \n");
+       if (TTS_SETTING_STATE_READY == g_state) {
+               SLOG(LOG_WARN, TAG_TTSC, "[WARNING] TTS Setting has already been initialized. \n");
                SLOG(LOG_DEBUG, TAG_TTSC, "=====");
                SLOG(LOG_DEBUG, TAG_TTSC, " ");
-               return TTS_SETTING_ERROR_INVALID_STATE;
+               return TTS_SETTING_ERROR_NONE;
        }
 
        if( 0 != tts_setting_dbus_open_connection() ) {
@@ -44,9 +95,14 @@ int tts_setting_initialize()
                SLOG(LOG_DEBUG, TAG_TTSC, " ");
                return TTS_SETTING_ERROR_OPERATION_FAILED;
        }
-       
+
+       /* Send hello */
+       if (0 != tts_setting_dbus_request_hello()) {
+               __check_setting_tts_daemon();
+       }
+
        /* do request */
-       int i = 0;
+       int i = 1;
        int ret = 0;
        while(1) {
                ret = tts_setting_dbus_request_initialize();
@@ -56,7 +112,7 @@ int tts_setting_initialize()
                        break;
                } else if(ret) {
                        sleep(1);
-                       if (i == 10) {
+                       if (i == 3) {
                                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Connection Time out");
                                ret = TTS_SETTING_ERROR_TIMED_OUT;                          
                                break;
@@ -68,8 +124,8 @@ int tts_setting_initialize()
                }
        }
 
-       if (0 == ret) {
-               g_is_setting_initialized = true;
+       if (TTS_SETTING_ERROR_NONE == ret) {
+               g_state = TTS_SETTING_STATE_READY;
                SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Initialize");
        }
 
@@ -79,13 +135,42 @@ int tts_setting_initialize()
        return ret;
 }
 
+int tts_setting_initialize_async(tts_setting_initialized_cb callback, void* user_data)
+{
+       SLOG(LOG_DEBUG, TAG_TTSC, "===== Initialize TTS Setting");
+
+       if (TTS_SETTING_STATE_READY == g_state) {
+               SLOG(LOG_WARN, TAG_TTSC, "[WARNING] TTS Setting has already been initialized. \n");
+               SLOG(LOG_DEBUG, TAG_TTSC, "=====");
+               SLOG(LOG_DEBUG, TAG_TTSC, " ");
+               return TTS_SETTING_ERROR_NONE;
+       }
+
+       if( 0 != tts_setting_dbus_open_connection() ) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to open connection\n ");
+               SLOG(LOG_DEBUG, TAG_TTSC, "=====");
+               SLOG(LOG_DEBUG, TAG_TTSC, " ");
+               return TTS_SETTING_ERROR_OPERATION_FAILED;
+       }
+       
+       g_initialized_cb = callback;
+       g_user_data = user_data;
+
+       ecore_timer_add(0, __tts_setting_connect_daemon, NULL);
+
+       SLOG(LOG_DEBUG, TAG_TTSC, "=====");
+       SLOG(LOG_DEBUG, TAG_TTSC, " ");
+
+       return TTS_SETTING_ERROR_NONE;
+}
+
 
 int tts_setting_finalize()
 {
        SLOG(LOG_DEBUG, TAG_TTSC, "===== Finalize TTS Setting");
 
-       if (false == g_is_setting_initialized) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Not initialized");
+       if (TTS_SETTING_STATE_NONE == g_state) {
+               SLOG(LOG_WARN, TAG_TTSC, "[WARNING] Not initialized");
                SLOG(LOG_DEBUG, TAG_TTSC, "=====");
                SLOG(LOG_DEBUG, TAG_TTSC, " ");
                return TTS_SETTING_ERROR_INVALID_STATE;
@@ -106,7 +191,7 @@ int tts_setting_finalize()
                SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Finalize");
        }
 
-       g_is_setting_initialized = false;
+       g_state = TTS_SETTING_STATE_NONE;
        
        SLOG(LOG_DEBUG, TAG_TTSC, "=====");
        SLOG(LOG_DEBUG, TAG_TTSC, " ");
@@ -118,7 +203,7 @@ int tts_setting_foreach_supported_engines(tts_setting_supported_engine_cb callba
 {    
        SLOG(LOG_DEBUG, TAG_TTSC, "===== Foreach supported engines");
 
-       if (false == g_is_setting_initialized) {
+       if (TTS_SETTING_STATE_NONE == g_state) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Not initialized");
                SLOG(LOG_DEBUG, TAG_TTSC, "=====");
                SLOG(LOG_DEBUG, TAG_TTSC, " ");
@@ -149,7 +234,7 @@ int tts_setting_get_engine(char** engine_id)
 {
        SLOG(LOG_DEBUG, TAG_TTSC, "===== Get current engine");
 
-       if (false == g_is_setting_initialized) {
+       if (TTS_SETTING_STATE_NONE == g_state) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Not initialized");
                SLOG(LOG_DEBUG, TAG_TTSC, "=====");
                SLOG(LOG_DEBUG, TAG_TTSC, " ");
@@ -180,7 +265,7 @@ int tts_setting_set_engine(const char* engine_id)
 {
        SLOG(LOG_DEBUG, TAG_TTSC, "===== Set current engine");
 
-       if (false == g_is_setting_initialized) {
+       if (TTS_SETTING_STATE_NONE == g_state) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Not initialized");
                SLOG(LOG_DEBUG, TAG_TTSC, "=====");
                SLOG(LOG_DEBUG, TAG_TTSC, " ");
@@ -207,11 +292,11 @@ int tts_setting_set_engine(const char* engine_id)
        return ret;
 }
 
-int tts_setting_foreach_surppoted_voices(tts_setting_supported_voice_cb callback, void* user_data)
+int tts_setting_foreach_surpported_voices(tts_setting_supported_voice_cb callback, void* user_data)
 {
        SLOG(LOG_DEBUG, TAG_TTSC, "===== Foreach supported voices");
 
-       if (false == g_is_setting_initialized) {
+       if (TTS_SETTING_STATE_NONE == g_state) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Not initialized");
                SLOG(LOG_DEBUG, TAG_TTSC, "=====");
                SLOG(LOG_DEBUG, TAG_TTSC, " ");
@@ -243,7 +328,7 @@ int tts_setting_get_default_voice(char** language, tts_setting_voice_type_e* voi
 {
        SLOG(LOG_DEBUG, TAG_TTSC, "===== Get default voice");
 
-       if (false == g_is_setting_initialized) {
+       if (TTS_SETTING_STATE_NONE == g_state) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Not initialized");
                SLOG(LOG_DEBUG, TAG_TTSC, "=====");
                SLOG(LOG_DEBUG, TAG_TTSC, " ");
@@ -274,7 +359,7 @@ int tts_setting_set_default_voice(const char* language, tts_setting_voice_type_e
 {
        SLOG(LOG_DEBUG, TAG_TTSC, "===== Set default voice");
 
-       if (false == g_is_setting_initialized) {
+       if (TTS_SETTING_STATE_NONE == g_state) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Not initialized");
                SLOG(LOG_DEBUG, TAG_TTSC, "=====");
                SLOG(LOG_DEBUG, TAG_TTSC, " ");
@@ -288,7 +373,7 @@ int tts_setting_set_default_voice(const char* language, tts_setting_voice_type_e
                return TTS_SETTING_ERROR_INVALID_PARAMETER;
        }
 
-       if (voice_type < TTS_SETTING_VOICE_TYPE_MALE && TTS_SETTING_VOICE_TYPE_USER3 < voice_type ) {
+       if (voice_type < TTS_SETTING_VOICE_TYPE_MALE || TTS_SETTING_VOICE_TYPE_USER3 < voice_type ) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Invalid voice type");
                SLOG(LOG_DEBUG, TAG_TTSC, "=====");
                SLOG(LOG_DEBUG, TAG_TTSC, " ");
@@ -305,7 +390,7 @@ int tts_setting_set_default_voice(const char* language, tts_setting_voice_type_e
        SLOG(LOG_DEBUG, TAG_TTSC, "=====");
        SLOG(LOG_DEBUG, TAG_TTSC, " ");
     
-       return TTS_SETTING_ERROR_NONE;
+       return ret;
 }
 
 
@@ -313,7 +398,7 @@ int tts_setting_get_default_speed(tts_setting_speed_e* speed)
 {
        SLOG(LOG_DEBUG, TAG_TTSC, "===== Get default speed");
 
-       if (!g_is_setting_initialized) {
+       if (TTS_SETTING_STATE_NONE == g_state) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Not initialized");
                SLOG(LOG_DEBUG, TAG_TTSC, "=====");
                SLOG(LOG_DEBUG, TAG_TTSC, " ");
@@ -350,14 +435,14 @@ int tts_setting_set_default_speed(tts_setting_speed_e speed)
 {
        SLOG(LOG_DEBUG, TAG_TTSC, "===== Set default speed");
 
-       if (!g_is_setting_initialized) {
+       if (TTS_SETTING_STATE_NONE == g_state) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Not initialized");
                SLOG(LOG_DEBUG, TAG_TTSC, "=====");
                SLOG(LOG_DEBUG, TAG_TTSC, " ");
                return TTS_SETTING_ERROR_INVALID_STATE;
        }
 
-       if (speed < TTS_SETTING_SPEED_VERY_SLOW && TTS_SETTING_SPEED_VERY_FAST < speed ) {
+       if (speed < TTS_SETTING_SPEED_VERY_SLOW || TTS_SETTING_SPEED_VERY_FAST < speed) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Invalid speed");
                SLOG(LOG_DEBUG, TAG_TTSC, "=====");
                SLOG(LOG_DEBUG, TAG_TTSC, " ");
@@ -381,7 +466,7 @@ int tts_setting_foreach_engine_settings(tts_setting_engine_setting_cb callback,
 {
        SLOG(LOG_DEBUG, TAG_TTSC, "===== Foreach engine setting");
 
-       if (!g_is_setting_initialized) {
+       if (TTS_SETTING_STATE_NONE == g_state) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Not initialized");
                SLOG(LOG_DEBUG, TAG_TTSC, "=====");
                SLOG(LOG_DEBUG, TAG_TTSC, " ");
@@ -412,7 +497,7 @@ int tts_setting_set_engine_setting(const char* key, const char* value)
 {
        SLOG(LOG_DEBUG, TAG_TTSC, "===== Set engine setting");
 
-       if (!g_is_setting_initialized) {
+       if (TTS_SETTING_STATE_NONE == g_state) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Not initialized");
                SLOG(LOG_DEBUG, TAG_TTSC, "=====");
                SLOG(LOG_DEBUG, TAG_TTSC, " ");
@@ -439,49 +524,72 @@ int tts_setting_set_engine_setting(const char* key, const char* value)
        return ret;
 }
 
+int __setting_get_cmd_line(char *file, char *buf) 
+{
+       FILE *fp = NULL;
+       int i;
 
+       fp = fopen(file, "r");
+       if (fp == NULL) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Get command line");
+               return -1;
+       }
+
+       memset(buf, 0, 256);
+       fgets(buf, 256, fp);
+       fclose(fp);
+
+       return 0;
+}
 
 /* Functions for tts-daemon fork */
-static bool __tts_is_alive()
+static bool __tts_setting_is_alive()
 {
-       FILE *fp = NULL;
-       char buff[256];
-       char cmd[256];
-       int i=0;
-
-       memset(buff, 0, sizeof(char));
-       memset(cmd, 0, sizeof(char));
+       DIR *dir;
+       struct dirent *entry;
+       struct stat filestat;
+       
+       int pid;
+       char cmdLine[256];
+       char tempPath[256];
 
-       if ((fp = popen("ps -eo \"cmd\"", "r")) == NULL) {
-               SLOG(LOG_DEBUG, TAG_TTSC, "[TTS ERROR] popen error ");
+       dir  = opendir("/proc");
+       if (NULL == dir) {
+               SLOG(LOG_ERROR, TAG_TTSC, "process checking is FAILED");
                return FALSE;
        }
 
-       while (fgets(buff, 255, fp)) {
-               if (i == 0) {
-                       i++;
+       while ((entry = readdir(dir)) != NULL) {
+               if (0 != lstat(entry->d_name, &filestat))
                        continue;
-               }
 
-               sscanf(buff, "%s", cmd);
+               if (!S_ISDIR(filestat.st_mode))
+                       continue;
 
-               if( 0 == strncmp(cmd, "[tts-daemon]", strlen("[tts-daemon]")) ||
-                       0 == strncmp(cmd, "tts-daemon", strlen("tts-daemon")) ||
-                       0 == strncmp(cmd, "/usr/bin/tts-daemon", strlen("/usr/bin/tts-daemon"))
-                       ) {
-                       SLOG(LOG_DEBUG, TAG_TTSC, "tts-daemon is ALIVE !!");
-                       fclose(fp);
-                       return TRUE;
+               pid = atoi(entry->d_name);
+               if (pid <= 0) continue;
+
+               sprintf(tempPath, "/proc/%d/cmdline", pid);
+               if (0 != __setting_get_cmd_line(tempPath, cmdLine)) {
+                       continue;
                }
 
-               i++;
+               if (0 == strncmp(cmdLine, "[tts-daemon]", strlen("[tts-daemon]")) ||
+                       0 == strncmp(cmdLine, "tts-daemon", strlen("tts-daemon")) ||
+                       0 == strncmp(cmdLine, "/usr/bin/tts-daemon", strlen("/usr/bin/tts-daemon"))) {
+                               SLOG(LOG_DEBUG, TAG_TTSC, "tts-daemon is ALIVE !! \n");
+                               closedir(dir);
+                               return TRUE;
+               }
        }
-       fclose(fp);
+       SLOG(LOG_DEBUG, TAG_TTSC, "THERE IS NO tts-daemon !! \n");
 
+       closedir(dir);
        return FALSE;
+
 }
 
-static void __my_sig_child(int signo, siginfo_t *info, void *data)
+static void __setting_my_sig_child(int signo, siginfo_t *info, void *data)
 {
        int status;
        pid_t child_pid, child_pgid;
@@ -497,19 +605,17 @@ static void __my_sig_child(int signo, siginfo_t *info, void *data)
        return;
 }
 
-static int __check_tts_daemon()
+static int __check_setting_tts_daemon()
 {
-       if( TRUE == __tts_is_alive() )
+       if( TRUE == __tts_setting_is_alive() )
                return 0;
 
        /* fork-exec tts-daemom */
-       SLOG(LOG_DEBUG, TAG_TTSC, "tts-daemon is NOT alive. start tts-daemon.");
-
        int pid, i;
        struct sigaction act, dummy;
 
        act.sa_handler = NULL;
-       act.sa_sigaction = __my_sig_child;
+       act.sa_sigaction = __setting_my_sig_child;
        sigemptyset(&act.sa_mask);
        act.sa_flags = SA_NOCLDSTOP | SA_SIGINFO;
 
@@ -534,7 +640,6 @@ static int __check_tts_daemon()
                break;
 
        default:
-               sleep(1);
                break;
        }
 
old mode 100644 (file)
new mode 100755 (executable)
index a13f143..921e1fa
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved 
+*  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
@@ -67,6 +67,14 @@ typedef enum {
        TTS_SETTING_VOICE_TYPE_USER3            /**< Engine defined */
 } tts_setting_voice_type_e;
 
+/** 
+* @brief Enumerations of setting state.
+*/
+typedef enum {
+       TTS_SETTING_STATE_NONE = 0,
+       TTS_SETTING_STATE_READY
+} tts_setting_state_e;
+
 /**
 * @brief Called to get a engine information.
 *
@@ -90,12 +98,12 @@ typedef bool(*tts_setting_supported_engine_cb)(const char* engine_id, const char
 *              followed by ISO 639-1 for the two-letter language code. 
 *              For example, "ko_KR" for Korean, "en_US" for American English..
 * @param[in] voice_type Voice type.
-* @param[in] user_data User data passed from the tts_setting_foreach_surppoted_voices().
+* @param[in] user_data User data passed from the tts_setting_foreach_surpported_voices().
 *
 * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop.
-* @pre tts_setting_foreach_surppoted_voices() will invoke this callback. 
+* @pre tts_setting_foreach_surpported_voices() will invoke this callback. 
 *
-* @see tts_setting_foreach_surppoted_voices()
+* @see tts_setting_foreach_surpported_voices()
 */
 typedef bool(*tts_setting_supported_voice_cb)(const char* engine_id, const char* language, tts_setting_voice_type_e voice_type, void* user_data);
 
@@ -114,9 +122,21 @@ typedef bool(*tts_setting_supported_voice_cb)(const char* engine_id, const char*
 */
 typedef bool(*tts_setting_engine_setting_cb)(const char* engine_id, const char* key, const char* value, void* user_data);
 
+/**
+* @brief Called to initialize setting.
+*
+* @param[in] state Current state.
+* @param[in] reason Error reason.
+* @param[in] user_data User data passed from the tts_setting_initialize_async().
+*
+* @pre tts_setting_initialize_async() will invoke this callback. 
+*
+* @see tts_setting_initialize_async()
+*/
+typedef void(*tts_setting_initialized_cb)(tts_setting_state_e state, tts_setting_error_e reason, void* user_data);
 
 /**
-* @brief Initialize TTS setting and connect to tts-daemon.
+* @brief Initialize TTS setting and connect to tts-daemon asynchronously.
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #TTS_SETTING_ERROR_NONE Success.
@@ -126,7 +146,9 @@ typedef bool(*tts_setting_engine_setting_cb)(const char* engine_id, const char*
 *
 * @see tts_setting_finalize()
 */
-int tts_setting_initialize(void);
+int tts_setting_initialize();
+
+int tts_setting_initialize_async(tts_setting_initialized_cb callback, void* user_data);
 
 /**
 * @brief finalize tts setting and disconnect to tts-daemon. 
@@ -205,7 +227,7 @@ int tts_setting_set_engine(const char* engine_id);
 *
 * @see tts_setting_supported_voice_cb()
 */
-int tts_setting_foreach_surppoted_voices(tts_setting_supported_voice_cb callback, void* user_data);
+int tts_setting_foreach_surpported_voices(tts_setting_supported_voice_cb callback, void* user_data);
 
 /**
 * @brief Get a default voice of current engine.
old mode 100644 (file)
new mode 100755 (executable)
index b56c099..411f910
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved 
+*  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
@@ -82,11 +82,52 @@ int tts_setting_dbus_close_connection()
 
        dbus_bus_release_name(g_conn, service_name, &err);
 
+       dbus_connection_close(g_conn);
+
        g_conn = NULL;
 
        return 0;
 }
 
+int tts_setting_dbus_request_hello()
+{
+       DBusMessage* msg;
+
+       msg = dbus_message_new_method_call(
+               TTS_SERVER_SERVICE_NAME, 
+               TTS_SERVER_SERVICE_OBJECT_PATH, 
+               TTS_SERVER_SERVICE_INTERFACE, 
+               TTS_SETTING_METHOD_HELLO);
+
+       if (NULL == msg) { 
+               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request setting hello : Fail to make message \n"); 
+               return TTS_SETTING_ERROR_OPERATION_FAILED;
+       } else {
+               SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request setting hello");
+       }
+
+       DBusError err;
+       dbus_error_init(&err);
+
+       DBusMessage* result_msg = NULL;
+       int result = 0;
+
+       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 500, &err);
+
+       dbus_message_unref(msg);
+
+       if (NULL != result_msg) {
+               dbus_message_unref(result_msg);
+
+               SLOG(LOG_DEBUG, TAG_TTSC, "<<<< setting hello");
+               result = 0;
+       } else {
+               SLOG(LOG_ERROR, TAG_TTSC, "<<<< setting hello : no response");
+               result = -1;
+       }
+
+       return result;
+}
 
 int tts_setting_dbus_request_initialize()
 {
@@ -688,7 +729,7 @@ int tts_setting_dbus_request_get_default_speed(int* speed)
 
        if (0 == result) {
                *speed = temp_int;
-               SLOG(LOG_DEBUG, TAG_TTSC, "<<<< setting get default speed : result(%d), speed(%d)", result, speed);
+               SLOG(LOG_DEBUG, TAG_TTSC, "<<<< setting get default speed : result(%d), speed(%d)", result, *speed);
        } else {
                SLOG(LOG_ERROR, TAG_TTSC, "<<<< setting get default speed : result(%d)", result);
        }
old mode 100644 (file)
new mode 100755 (executable)
index 5894afc..cc7185b
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved 
+*  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
@@ -26,6 +26,7 @@ int tts_setting_dbus_open_connection();
 
 int tts_setting_dbus_close_connection();
 
+int tts_setting_dbus_request_hello();
 
 int tts_setting_dbus_request_initialize();
 
old mode 100644 (file)
new mode 100755 (executable)
index 520b6e5..6dab98c
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved 
+*  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
@@ -40,6 +40,7 @@ extern "C" {
 * Message Definition for APIs
 *******************************************************************************************/
 
+#define TTS_METHOD_HELLO               "tts_method_hello"
 #define TTS_METHOD_INITIALIZE          "tts_method_initialize"
 #define TTS_METHOD_FINALIZE            "tts_method_finalilze"
 #define TTS_METHOD_GET_SUPPORT_VOICES  "tts_method_get_support_voices"
@@ -49,16 +50,18 @@ extern "C" {
 #define TTS_METHOD_STOP                        "tts_method_stop"
 #define TTS_METHOD_PAUSE               "tts_method_pause"
 
-#define TTS_SIGNAL_INTERRUPT           "tts_signal_interrupt"
-#define TTS_SIGNAL_UTTERANCE_STARTED   "tts_utterance_started"
-#define TTS_SIGNAL_UTTERANCE_COMPLETED "tts_utterance_completed"
-#define TTS_SIGNAL_ERROR               "tts_signal_error"
-
+#define TTSD_METHOD_HELLO              "ttsd_method_hello"
+#define TTSD_METHOD_UTTERANCE_STARTED  "ttsd_method_utterance_started"
+#define TTSD_METHOD_UTTERANCE_COMPLETED        "ttsd_method_utterance_completed"
+#define TTSD_METHOD_ERROR              "ttsd_method_error"
+#define TTSD_METHOD_SET_STATE          "ttsd_method_set_state"
+#define TTSD_METHOD_GET_STATE          "ttsd_method_get_state"
 
 /******************************************************************************************
 * Message Definition for Setting
 *******************************************************************************************/
 
+#define TTS_SETTING_METHOD_HELLO               "tts_setting_method_hello"
 #define TTS_SETTING_METHOD_INITIALIZE          "tts_setting_method_initialize"
 #define TTS_SETTING_METHOD_FINALIZE            "tts_setting_method_finalilze"
 #define TTS_SETTING_METHOD_GET_ENGINE_LIST     "tts_setting_method_get_engine_list"
@@ -72,13 +75,6 @@ extern "C" {
 #define TTS_SETTING_METHOD_GET_ENGINE_SETTING  "tts_setting_method_get_engine_setting"
 #define TTS_SETTING_METHOD_SET_ENGINE_SETTING  "tts_setting_method_set_engine_setting"
 
-/******************************************************************************************
-* Message Definition for tts-daemon internal
-*******************************************************************************************/
-
-#define TTS_SIGNAL_NEXT_PLAY           "tts_signal_start_play"
-#define TTS_SIGNAL_NEXT_SYNTHESIS      "tts_signal_start_synthesis"
-
 #ifdef __cplusplus
 }
 #endif
index d3788e7..36b9077 100644 (file)
@@ -4,18 +4,17 @@ Version:    0.1.1
 Release:    1
 Group:      libs
 License:    Samsung
-Source0:    tts-0.1.1.tar.gz
+Source0:    %{name}-%{version}.tar.gz
 Requires(post): /sbin/ldconfig
 Requires(postun): /sbin/ldconfig
 BuildRequires:  pkgconfig(glib-2.0)
 BuildRequires:  pkgconfig(dbus-1)
 BuildRequires:  pkgconfig(mm-player)
 BuildRequires:  pkgconfig(mm-common)
-BuildRequires:  pkgconfig(dnet)
 BuildRequires:  pkgconfig(dlog)
 BuildRequires:  pkgconfig(vconf)
-BuildRequires:  pkgconfig(ecore-input)
-BuildRequires:  pkgconfig(openssl)
+BuildRequires:  pkgconfig(ecore)
+BuildRequires:  pkgconfig(ecore-file)
 
 BuildRequires:  cmake
 
@@ -42,22 +41,20 @@ make %{?jobs:-j%jobs}
 
 %install
 rm -rf %{buildroot}
+mkdir -p %{buildroot}/usr/share/license
 %make_install
 
-
-
-
 %post -p /sbin/ldconfig
 
 %postun -p /sbin/ldconfig
 
-
-
 %files
+%manifest tts-server.manifest
 %defattr(-,root,root,-)
 %{_libdir}/lib*.so
+%{_libdir}/voice/tts/1.0/ttsd.conf
 %{_bindir}/tts-daemon
-
+/usr/share/license/*
 
 %files devel
 %defattr(-,root,root,-)
old mode 100644 (file)
new mode 100755 (executable)
index 0c4132f..83f9c28
@@ -31,11 +31,10 @@ INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/../common")
 
 
 ## Dependent packages ##
-INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED 
-       mm-player mm-common vconf dbus-1 
-       dlog openssl
-)
+#INCLUDE(FindPkgConfig)
+#pkg_check_modules(pkgs REQUIRED 
+#      mm-player vconf mm-common dbus-1 dlog
+#)
 
 FOREACH(flag ${pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
@@ -46,7 +45,7 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
 SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
 SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
 SET(CMAKE_C_FLAGS_RELEASE "-O2")
-SET(CMAKE_EXE_LINKER_FLAGS "-Wall,--as-needed")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
 
 ## Add definitions ##
 ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
@@ -60,9 +59,10 @@ ADD_DEFINITIONS("-DIMAGEDIR=\"${IMAGEDIR}\"")
 
 ## Executable ##
 ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
-#ADD_DEPENDENCIES(${PROJECT_NAME} ttsd_dbus_stub.h)
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} -ldl ${pkgs_LDFLAGS})
 
 ## Install ##
 INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/ttsp.h DESTINATION include)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/ttsd.conf DESTINATION lib/voice/tts/1.0)
+
diff --git a/server/ttsd.conf b/server/ttsd.conf
new file mode 100644 (file)
index 0000000..3d23424
--- /dev/null
@@ -0,0 +1,3 @@
+ENGINE_ID 27F277E9-BBC4-4dca-B553-D9884A3CDAA0\r
+VOICE en_US 2\r
+SPEED 3
\ No newline at end of file
old mode 100644 (file)
new mode 100755 (executable)
index ee2a08b..61066c3
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved 
+*  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
 *  limitations under the License.
 */
 
-
-#include <vconf.h>
+#include <Ecore_File.h>
 #include "ttsd_main.h"
 #include "ttsd_config.h"
 
-/*
-* tts-daemon config
-*/
+#define CONFIG_FILE_PATH       CONFIG_DIRECTORY"/ttsd.conf"
+#define CONFIG_DEFAULT         BASE_DIRECTORY_DEFAULT"/ttsd.conf"
 
-int ttsd_config_get_char_type(const char* key, char** value)
-{
-       if (NULL == key || NULL == value) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR] Input parameter is NULL\n");
-               return TTSD_ERROR_INVALID_PARAMETER;
-       } 
-
-       *value = vconf_get_str(key);
-       if (NULL == *value) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR] fail to get char type from config : key(%s)\n", key);
-               return -1;
-       }
+#define ENGINE_ID      "ENGINE_ID"
+#define VOICE          "VOICE"
+#define SPEED          "SPEED"
 
-       return 0;
-}
 
-int ttsd_config_set_char_type(const char* key, const char* value)
+static char*   g_engine_id;
+static char*   g_language;
+static int     g_vc_type;
+static int     g_speed;
+
+int __ttsd_config_save()
 {
-       if (NULL == key || NULL == value) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR] Input parameter is NULL\n");
-               return TTSD_ERROR_INVALID_PARAMETER;
-       } 
+       if (0 != access(CONFIG_FILE_PATH, R_OK|W_OK)) {
+               if (0 == ecore_file_mkpath(CONFIG_DIRECTORY)) {
+                       SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR ] Fail to create directory (%s)", CONFIG_DIRECTORY);
+                       return -1;
+               }
 
-       if (0 != vconf_set_str(key, value)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR] fail to set char type \n"); 
-               return -1;
+               SLOG(LOG_WARN, TAG_TTSD, "[Config] Create directory (%s)", CONFIG_DIRECTORY);
        }
 
-       return 0;
-}
+       FILE* config_fp;
+       config_fp = fopen(CONFIG_FILE_PATH, "w+");
 
-int ttsd_config_get_bool_type(const char* key, bool* value)
-{
-       if (NULL == key || NULL == value) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR] Input parameter is NULL\n");
-               return TTSD_ERROR_INVALID_PARAMETER;
-       } 
-
-       int result ;
-       if (0 != vconf_get_int(key, &result)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR] fail to get bool type config : key(%s)\n", key);
+       if (NULL == config_fp) {
+               /* make file and file default */
+               SLOG(LOG_WARN, TAG_TTSD, "[Config WARNING] Fail to open config (%s)", CONFIG_FILE_PATH);
                return -1;
        }
 
-       *value = (bool) result;
+       SLOG(LOG_DEBUG, TAG_TTSD, "[Config] Rewrite config file");
 
-       return 0;
-}
+       /* Write engine id */
+       fprintf(config_fp, "%s %s\n", ENGINE_ID, g_engine_id);
 
-int ttsd_config_set_bool_type(const char* key, const bool value)
-{
-       if (NULL == key) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR] Input parameter is NULL\n");
-               return TTSD_ERROR_INVALID_PARAMETER;
-       } 
-
-       int result = (int)value;
-       if (0 != vconf_set_int(key, result)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR] fail to set bool type config : key(%s)\n", key);
-               return -1;
-       }
+       /* Write voice */
+       fprintf(config_fp, "%s %s %d\n", VOICE, g_language, g_vc_type);
+
+       /* Read speed */
+       fprintf(config_fp, "%s %d\n", SPEED, g_speed);
+
+       fclose(config_fp);
 
        return 0;
 }
 
-int ttsd_config_get_int_type(const char* key, int* value)
+
+int __ttsd_config_load()
 {
-       if (NULL == key || NULL == value) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR] Input parameter is NULL\n");
-               return TTSD_ERROR_INVALID_PARAMETER;
-       } 
+       FILE* config_fp;
+       char buf_id[256] = {0};
+       char buf_param[256] = {0};
+       int int_param = 0;
+       bool is_default_open = false;
 
-       if (0 != vconf_get_int(key, value)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR] fail to get bool type config : key(%s)\n", key);
-               return -1;
+       config_fp = fopen(CONFIG_FILE_PATH, "r");
+
+       if (NULL == config_fp) {
+               SLOG(LOG_WARN, TAG_TTSD, "[Config WARNING] Not open file(%s)", CONFIG_FILE_PATH);
+               
+               config_fp = fopen(CONFIG_DEFAULT, "r");
+               if (NULL == config_fp) {
+                       SLOG(LOG_ERROR, TAG_TTSD, "[Config WARNING] Not open original config file(%s)", CONFIG_FILE_PATH);
+                       return -1;
+               }
+               is_default_open = true;
        }
 
-       return 0;
-}
+       /* Read engine id */
+       if (EOF == fscanf(config_fp, "%s %s", buf_id, buf_param)) {
+               fclose(config_fp);
+               SLOG(LOG_WARN, TAG_TTSD, "[Config WARNING] Fail to read config (engine id)");
+               __ttsd_config_save();
+               return -1;
+       } else {
+               if (0 == strncmp(ENGINE_ID, buf_id, strlen(ENGINE_ID))) {
+                       g_engine_id = strdup(buf_param);
+               } else {
+                       fclose(config_fp);
+                       SLOG(LOG_WARN, TAG_TTSD, "[Config WARNING] Fail to load config (engine id)");
+                       __ttsd_config_save();
+                       return -1;
+               }
+       }
 
-int ttsd_config_set_int_type(const char* key, const int value)
-{
-       if (NULL == key) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR] Input parameter is NULL\n");
-               return TTSD_ERROR_INVALID_PARAMETER;
-       } 
+       
 
-       if (0 != vconf_set_int(key, value)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR] fail to set int type config : key(%s)\n", key);
+       /* Read voice */
+       if (EOF == fscanf(config_fp, "%s %s %d", buf_id, buf_param, &int_param)) {
+               fclose(config_fp);
+               SLOG(LOG_WARN, TAG_TTSD, "[Config WARNING] Fail to read config (voice)");
+               __ttsd_config_save();
                return -1;
+       } else {
+               if (0 == strncmp(VOICE, buf_id, strlen(VOICE))) {
+                       g_language = strdup(buf_param);
+                       g_vc_type = int_param;
+               } else {
+                       fclose(config_fp);
+                       SLOG(LOG_WARN, TAG_TTSD, "[Config WARNING] Fail to load config (voice)");
+                       __ttsd_config_save();
+                       return -1;
+               }
+       }
+       
+       /* Read speed */
+       if (EOF == fscanf(config_fp, "%s %d", buf_id, &int_param)) {
+               fclose(config_fp);
+               SLOG(LOG_WARN, TAG_TTSD, "[Config WARNING] Fail to read config (speed)");
+               __ttsd_config_save();
+               return -1;
+       } else {
+               if (0 == strncmp(SPEED, buf_id, strlen(SPEED))) {
+                       g_speed = int_param;
+               } else {
+                       fclose(config_fp);
+                       SLOG(LOG_WARN, TAG_TTSD, "[Config WARNING] Fail to load config (speed)");
+                       __ttsd_config_save();
+                       return -1;
+               }
+       }
+       
+       fclose(config_fp);
+
+       SLOG(LOG_DEBUG, TAG_TTSD, "[Config] Load config : engine(%s), voice(%s,%d), speed(%d)",
+               g_engine_id, g_language, g_vc_type, g_speed);
+
+       if (true == is_default_open) {
+               if(0 == __ttsd_config_save()) {
+                       SLOG(LOG_DEBUG, TAG_TTSD, "[Config] Create config(%s)", CONFIG_FILE_PATH);
+               }
        }
 
        return 0;
 }
 
-/*
-* interface for engine plug-in
-*/
-
-int config_make_key_for_engine(const char* engine_id, const char* key, char** out_key)
+int ttsd_config_initialize()
 {
-       int key_size = strlen(TTSD_CONFIG_PREFIX) + strlen(engine_id) + strlen(key) + 2; /* 2 is '/' and '\0' */
+       g_engine_id = NULL;
+       g_language = NULL;
+       g_vc_type = 1;
+       g_speed = 3;
 
-       *out_key = (char*) g_malloc0( sizeof(char) * key_size);
-
-       if (*out_key == NULL) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR] Not enough memory!! \n");
-               return -1;
-       } else {
-               snprintf(*out_key, key_size, "%s%s/%s", TTSD_CONFIG_PREFIX, engine_id, key );
-               SLOG(LOG_DEBUG, TAG_TTSD, "[Config DEBUG] make key (%s) \n", *out_key);
-       }
+       __ttsd_config_load();
 
        return 0;
 }
 
-int ttsd_config_set_persistent_data(const char* engine_id, const char* key, const char* value)
+int ttsd_config_finalize()
 {
-       char* vconf_key = NULL;
+       __ttsd_config_save();
+       return 0;
+}
 
-       if (0 != config_make_key_for_engine(engine_id, key, &vconf_key)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR] fail config_make_key_for_engine()\n"); 
+int ttsd_config_get_default_engine(char** engine_id)
+{
+       if (NULL == engine_id)
                return -1;
-       }
 
-       if (0 != vconf_set_str(vconf_key, value)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR] fail to set key, value\n");
-               
-               if(vconf_key != NULL)   
-                       g_free(vconf_key);
+       *engine_id = strdup(g_engine_id);
+       return 0;
+}
 
+int ttsd_config_set_default_engine(const char* engine_id)
+{
+       if (NULL == engine_id)
                return -1;
-       }
-
-       SLOG(LOG_DEBUG, TAG_TTSD, "[Config DEBUG] Set data : key(%s), value(%s) \n", vconf_key, value);
 
-       if (vconf_key != NULL)  
-               g_free(vconf_key);
+       if (NULL != g_engine_id)
+               free(g_engine_id);
 
+       g_engine_id = strdup(engine_id);
+       __ttsd_config_save();
        return 0;
 }
 
-int ttsd_config_get_persistent_data(const char* engine_id, const char* key, char** value)
+int ttsd_config_get_default_voice(char** language, int* type)
 {
-       char* vconf_key = NULL;
-
-       if (0 != config_make_key_for_engine(engine_id, key, &vconf_key)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR] fail config_make_key_for_engine()\n");
+       if (NULL == language || NULL == type)
                return -1;
-       }
 
-       char* temp;
-       temp = vconf_get_str(vconf_key);
-       if (temp == NULL) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR] fail to get value\n");
+       *language = strdup(g_language);
+       *type = g_vc_type;
 
-               if(vconf_key != NULL)   
-                       g_free(vconf_key);
+       return 0;
+}
 
+int ttsd_config_set_default_voice(const char* language, int type)
+{
+       if (NULL == language)
                return -1;
-       }
-
-       *value = g_strdup(temp);
 
-       SLOG(LOG_DEBUG, TAG_TTSD, "[Config DEBUG] Get data : key(%s), value(%s) \n", vconf_key, *value);
+       if (NULL != g_language)
+               free(g_language);
 
-       if (NULL != vconf_key)  
-               g_free(vconf_key);
+       g_language = strdup(language);
+       g_vc_type = type;
 
-       if (NULL != temp)               
-               g_free(temp);
+       __ttsd_config_save();
 
        return 0;
 }
 
-int ttsd_config_remove_persistent_data(const char* engine_id, const char* key)
+int ttsd_config_get_default_speed(int* speed)
 {
-       char* vconf_key = NULL;
-       int result = 0;
-
-       if (0 != config_make_key_for_engine(engine_id, key, &vconf_key)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR] fail config_make_key_for_engine()\n");
+       if (NULL == speed)
                return -1;
-       }
 
-       if( NULL == vconf_key )         
-               return -1;
-
-       if (0 != vconf_unset(vconf_key)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Config ERROR] fail to remove key\n");
-               result = -1;
-       } else {
-               SLOG(LOG_DEBUG, TAG_TTSD, "[Config DEBUG] Remove data : key(%s)", vconf_key);
-       }
+       *speed = g_speed;
 
-       if( vconf_key != NULL ) 
-               g_free(vconf_key);
+       return 0;
+}
 
-       return result;
+int ttsd_config_set_default_speed(int speed)
+{
+       g_speed = speed;
+       __ttsd_config_save();
+       return 0;
 }
old mode 100644 (file)
new mode 100755 (executable)
index fca7d60..e8b32d8
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved 
+*  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
 #ifndef __TTSD_CONFIG_H_
 #define __TTSD_CONFIG_H_
 
-#include <stdbool.h>
-
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#define TTSD_CONFIG_PREFIX "db/ttsd/"
-
-#define CONFIG_KEY_DEFAULT_ENGINE_ID   TTSD_CONFIG_PREFIX"engine"
-#define CONFIG_KEY_DEFAULT_LANGUAGE    TTSD_CONFIG_PREFIX"language"
-#define CONFIG_KEY_DEFAULT_VOICE_TYPE  TTSD_CONFIG_PREFIX"vctype"
-#define CONFIG_KEY_DEFAULT_SPEED       TTSD_CONFIG_PREFIX"speed"
-
-/*
-* tts-daemon config
-*/
-
-int ttsd_config_get_char_type(const char* key, char** value);
+int ttsd_config_initialize();
 
-int ttsd_config_set_char_type(const char* key, const char* value);
+int ttsd_config_finalize();
 
-int ttsd_config_get_bool_type(const char* key, bool* value);
+int ttsd_config_get_default_engine(char** engine_id);
 
-int ttsd_config_set_bool_type(const char* key, const bool value);
-
-int ttsd_config_get_int_type(const char* key, int* value);
-
-int ttsd_config_set_int_type(const char* key, const int value);
-
-/*
-* interface for engine plug-in
-*/
+int ttsd_config_set_default_engine(const char* engine_id);
 
-int ttsd_config_set_persistent_data(const char* engine_id, const char* key, const char* value);
+int ttsd_config_get_default_voice(char** language, int* type);
 
-int ttsd_config_get_persistent_data(const char* engine_id, const char* key, char** value);
+int ttsd_config_set_default_voice(const char* langauge, int type);
 
-int ttsd_config_remove_persistent_data(const char* engine_id, const char* key);
+int ttsd_config_get_default_speed(int* speed);
 
+int ttsd_config_set_default_speed(int speed);
 
 #ifdef __cplusplus
 }
old mode 100644 (file)
new mode 100755 (executable)
index e2f7fb7..73ab2c1
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved 
+*  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
@@ -19,6 +19,8 @@ using namespace std;
 
 static vector<app_data_s> g_app_list;
 
+static vector<setting_app_data_s> g_setting_list;
+
 static bool g_mutex_state = false;
 
 /*
@@ -40,10 +42,25 @@ int __data_show_list()
        }
 
        SLOG(LOG_DEBUG, TAG_TTSD, "-----------------------");
+
+       SLOG(LOG_DEBUG, TAG_TTSD, "----- setting client list -----");
+
+       vsize = g_setting_list.size();
+
+       for (int i=0; i<vsize; i++) {
+               SLOG(LOG_DEBUG, TAG_TTSD, "[%dth] pid(%d)", i, g_setting_list[i].pid );
+       }
+
+       if (0 == vsize) {
+               SLOG(LOG_DEBUG, TAG_TTSD, "No Setting Client");
+       }
+
+       SLOG(LOG_DEBUG, TAG_TTSD, "--------------------------------");
+
        return TTSD_ERROR_NONE;
 }
 
-int __data_show_sound_list(const int index)
+int __data_show_sound_list(int index)
 {
        SLOG(LOG_DEBUG, TAG_TTSD, "----- Sound list -----");
        
@@ -61,7 +78,7 @@ int __data_show_sound_list(const int index)
        return TTSD_ERROR_NONE;
 }
 
-int __data_show_text_list(const int index)
+int __data_show_text_list(int index)
 {
        SLOG(LOG_DEBUG, TAG_TTSD, "----- Text list -----");
 
@@ -85,7 +102,7 @@ int __data_show_text_list(const int index)
 * ttsd data functions
 */
 
-int ttsd_data_new_client(const int pid, const int uid)
+int ttsd_data_new_client(int pid, int uid)
 {
        if( -1 != ttsd_data_is_client(uid) ) {
                SLOG(LOG_ERROR, TAG_TTSD, "[DATA ERROR] ttsd_data_new_client() : uid is not valid (%d)\n", uid);        
@@ -106,7 +123,7 @@ int ttsd_data_new_client(const int pid, const int uid)
        return TTSD_ERROR_NONE;
 }
 
-int ttsd_data_delete_client(const int uid)
+int ttsd_data_delete_client(int uid)
 {
        int index = 0;
 
@@ -130,7 +147,7 @@ int ttsd_data_delete_client(const int uid)
        return TTSD_ERROR_NONE;
 }
 
-int ttsd_data_is_client(const int uid)
+int ttsd_data_is_client(int uid)
 {
        int vsize = g_app_list.size();
 
@@ -145,10 +162,10 @@ int ttsd_data_is_client(const int uid)
 
 int ttsd_data_get_client_count()
 {
-       return g_app_list.size();
+       return g_app_list.size() + g_setting_list.size();
 }
 
-int ttsd_data_get_pid(const int uid)
+int ttsd_data_get_pid(int uid)
 {
        int index;
 
@@ -162,7 +179,7 @@ int ttsd_data_get_pid(const int uid)
        return g_app_list[index].pid;
 }
 
-int ttsd_data_get_speak_data_size(const int uid)
+int ttsd_data_get_speak_data_size(int uid)
 {
        int index = 0;
        index = ttsd_data_is_client(uid);
@@ -176,7 +193,7 @@ int ttsd_data_get_speak_data_size(const int uid)
        return size;
 }
 
-int ttsd_data_add_speak_data(const int uid, const speak_data_s data)
+int ttsd_data_add_speak_data(int uid, speak_data_s data)
 {
        int index = 0;
        index = ttsd_data_is_client(uid);
@@ -197,7 +214,7 @@ int ttsd_data_add_speak_data(const int uid, const speak_data_s data)
        return TTSD_ERROR_NONE;
 }
 
-int ttsd_data_get_speak_data(const int uid, speak_data_s* data)
+int ttsd_data_get_speak_data(int uid, speak_data_s* data)
 {
        int index = 0;
        index = ttsd_data_is_client(uid);
@@ -227,7 +244,7 @@ int ttsd_data_get_speak_data(const int uid, speak_data_s* data)
        return TTSD_ERROR_NONE;
 }
 
-int ttsd_data_add_sound_data(const int uid, const sound_data_s data)
+int ttsd_data_add_sound_data(int uid, sound_data_s data)
 {
        int index = 0;
        index = ttsd_data_is_client(uid);
@@ -245,7 +262,7 @@ int ttsd_data_add_sound_data(const int uid, const sound_data_s data)
        return TTSD_ERROR_NONE;
 }
 
-int ttsd_data_get_sound_data(const int uid, sound_data_s* data)
+int ttsd_data_get_sound_data(int uid, sound_data_s* data)
 {
        int index = 0;
        index = ttsd_data_is_client(uid);
@@ -276,7 +293,7 @@ int ttsd_data_get_sound_data(const int uid, sound_data_s* data)
        return TTSD_ERROR_NONE;
 }
 
-int ttsd_data_get_sound_data_size(const int uid)
+int ttsd_data_get_sound_data_size(int uid)
 {
        int index = 0;
        index = ttsd_data_is_client(uid);
@@ -289,7 +306,7 @@ int ttsd_data_get_sound_data_size(const int uid)
        return g_app_list[index].m_wav_data.size();
 }
 
-int ttsd_data_clear_data(const int uid)
+int ttsd_data_clear_data(int uid)
 {
        int index = 0;
 
@@ -332,7 +349,7 @@ int ttsd_data_clear_data(const int uid)
        return TTSD_ERROR_NONE;
 }
 
-int ttsd_data_get_client_state(const int uid, app_state_e* state)
+int ttsd_data_get_client_state(int uid, app_state_e* state)
 {
        int index = 0;
 
@@ -347,7 +364,7 @@ int ttsd_data_get_client_state(const int uid, app_state_e* state)
        return TTSD_ERROR_NONE;
 }
 
-int ttsd_data_set_client_state(const int uid, const app_state_e state)
+int ttsd_data_set_client_state(int uid, app_state_e state)
 {
        int index = 0;
 
@@ -431,3 +448,71 @@ bool ttsd_data_is_uttid_valid(int uid, int uttid)
 
        return true;
 }
+
+int ttsd_data_is_current_playing()
+{
+       int vsize = g_app_list.size();
+
+       for (int i=0; i<vsize; i++) {
+               if(g_app_list[i].state == APP_STATE_PLAYING) {
+                       return g_app_list[i].uid;               
+               }
+       }
+
+       return -1;
+}
+
+/*
+* setting data
+*/
+
+int ttsd_setting_data_add(int pid)
+{
+       if (-1 != ttsd_setting_data_is_setting(pid)) {
+               SLOG(LOG_ERROR, TAG_TTSD, "[DATA ERROR] pid(%d) is not valid", pid);    
+               return TTSD_ERROR_INVALID_PARAMETER;
+       }
+
+       setting_app_data_s setting_app;
+       setting_app.pid = pid;
+       
+       g_setting_list.insert(g_setting_list.end(), setting_app);
+
+#ifdef DATA_DEBUG
+       __data_show_list();
+#endif 
+       return TTSD_ERROR_NONE;
+
+}
+
+int ttsd_setting_data_delete(int pid)
+{
+       int index = 0;
+
+       index = ttsd_setting_data_is_setting(pid);
+
+       if (index < 0) {
+               SLOG(LOG_ERROR, TAG_TTSD, "[DATA ERROR] uid is not valid (%d)", pid);   
+               return -1;
+       }
+
+       g_setting_list.erase(g_setting_list.begin()+index);
+
+#ifdef DATA_DEBUG
+       __data_show_list();
+#endif 
+       return TTSD_ERROR_NONE;
+}
+
+int ttsd_setting_data_is_setting(int pid)
+{
+       int vsize = g_setting_list.size();
+
+       for (int i=0; i<vsize; i++) {
+               if(g_setting_list[i].pid == pid) {
+                       return i;               
+               }
+       }
+
+       return -1;
+}
\ No newline at end of file
old mode 100644 (file)
new mode 100755 (executable)
index 2fb2bbc..40f8647
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved 
+*  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
@@ -25,7 +25,8 @@ extern "C" {
 #endif
 
 typedef enum {
-       APP_STATE_READY = 0,
+       APP_STATE_CREATED = 0,
+       APP_STATE_READY,
        APP_STATE_PLAYING,
        APP_STATE_PAUSED
 }app_state_e;
@@ -62,44 +63,55 @@ typedef struct
        std::vector<sound_data_s> m_wav_data;
 }app_data_s;
 
+typedef struct {
+       int pid;
+} setting_app_data_s;
 
-int ttsd_data_new_client(const int pid, const int uid);
+int ttsd_data_new_client(int pid, int uid);
 
-int ttsd_data_delete_client(const int uid);
+int ttsd_data_delete_client(int uid);
 
-int ttsd_data_is_client(const int uid);
+int ttsd_data_is_client(int uid);
 
 int ttsd_data_get_client_count();
 
-int ttsd_data_get_pid(const int uid);
+int ttsd_data_get_pid(int uid);
 
-int ttsd_data_add_speak_data(const int uid, const speak_data_s data);
+int ttsd_data_add_speak_data(int uid, speak_data_s data);
 
-int ttsd_data_get_speak_data(const int uid, speak_data_s* data);
+int ttsd_data_get_speak_data(int uid, speak_data_s* data);
 
-int ttsd_data_get_speak_data_size(const int uid);
+int ttsd_data_get_speak_data_size(int uid);
 
-int ttsd_data_add_sound_data(const int uid, const sound_data_s data);
+int ttsd_data_add_sound_data(int uid, sound_data_s data);
 
-int ttsd_data_get_sound_data(const int uid, sound_data_s* data);
+int ttsd_data_get_sound_data(int uid, sound_data_s* data);
 
-int ttsd_data_get_sound_data_size(const int uid);
+int ttsd_data_get_sound_data_size(int uid);
 
-int ttsd_data_clear_data(const int uid);
+int ttsd_data_clear_data(int uid);
 
-int ttsd_data_get_client_state(const int pid, app_state_e* state);
+int ttsd_data_get_client_state(int pid, app_state_e* state);
 
-int ttsd_data_set_client_state(const int pid, const app_state_e state);
+int ttsd_data_set_client_state(int pid, app_state_e state);
 
 int ttsd_data_get_current_playing();
 
-
 typedef bool(*ttsd_data_get_client_cb)(int pid, int uid, app_state_e state, void* user_data);
 
 int ttsd_data_foreach_clients(ttsd_data_get_client_cb callback, void* user_data);
 
 bool ttsd_data_is_uttid_valid(int uid, int uttid);
 
+int ttsd_data_is_current_playing();
+
+
+int ttsd_setting_data_add(int pid);
+
+int ttsd_setting_data_delete(int pid);
+
+int ttsd_setting_data_is_setting(int pid);
+
 #ifdef __cplusplus
 }
 #endif
old mode 100644 (file)
new mode 100755 (executable)
index 20b5b28..2b71b93
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved 
+*  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
 
 static DBusConnection* g_conn;
 
-int ttsdc_send_signal(int pid, int uid, int uttid, char *signal)
-{   
+static int g_waiting_time = 3000;
+
+int ttsdc_send_hello(int pid, int uid)
+{
+       char service_name[64];
+       memset(service_name, 0, 64);
+       snprintf(service_name, 64, "%s%d", TTS_CLIENT_SERVICE_NAME, pid);
+
        char target_if_name[64];
        snprintf(target_if_name, sizeof(target_if_name), "%s%d", TTS_CLIENT_SERVICE_INTERFACE, pid);
 
        DBusMessage* msg;
 
-       /* create a signal & check for errors */
-       msg = dbus_message_new_signal(
-               TTS_CLIENT_SERVICE_OBJECT_PATH, /* object name of the signal */
-               target_if_name,                 /* interface name of the signal */
-               signal);                        /* name of the signal */
+       /* create a message & check for errors */
+       msg = dbus_message_new_method_call(
+               service_name, 
+               TTS_CLIENT_SERVICE_OBJECT_PATH, 
+               target_if_name, 
+               TTSD_METHOD_HELLO);
 
        if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_TTSD, "[Dbus ERROR] Fail to create signal message : type(%s), uid(%d)\n", signal, uid); 
+               SLOG(LOG_ERROR, TAG_TTSD, "<<<< [Dbus ERROR] Fail to create hello message : uid(%d)", uid); 
                return -1;
+       } else {
+               SLOG(LOG_DEBUG, TAG_TTSD, "<<<< [Dbus] Send hello message : uid(%d)", uid);
+       }
+
+       dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
+
+       DBusError err;
+       dbus_error_init(&err);
+
+       DBusMessage* result_msg;
+       int result = -1;
+
+       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
+       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_TTSD, ">>>> [Dbus] Get arguments error (%s)", err.message);
+                       dbus_error_free(&err); 
+                       result = -1;
+               }
+
+               dbus_message_unref(result_msg);
+       } else {
+               SLOG(LOG_DEBUG, TAG_TTSD, ">>>> [Dbus] Result message is NULL. Client is not available");
+               result = 0;
        }
 
-       dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INT32, &uttid, DBUS_TYPE_INVALID);
+       return result;
+}
+
+int ttsdc_send_message(int pid, int uid, int data, char *method)
+{   
+       char service_name[64];
+       memset(service_name, 0, 64);
+       snprintf(service_name, 64, "%s%d", TTS_CLIENT_SERVICE_NAME, pid);
+
+       char target_if_name[64];
+       snprintf(target_if_name, sizeof(target_if_name), "%s%d", TTS_CLIENT_SERVICE_INTERFACE, pid);
+
+       DBusMessage* msg;
+
+       /* create a message & check for errors */
+       msg = dbus_message_new_method_call(
+               service_name, 
+               TTS_CLIENT_SERVICE_OBJECT_PATH, 
+               target_if_name, 
+               method);
+
+       if (NULL == msg) { 
+               SLOG(LOG_ERROR, TAG_TTSD, "[Dbus ERROR] Fail to create message : type(%s), uid(%d)\n", method, uid); 
+               return -1;
+       } 
+
+       dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INT32, &data, DBUS_TYPE_INVALID);
 
        /* send the message and flush the connection */
        if (!dbus_connection_send(g_conn, msg, NULL)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Dbus ERROR] <<<< send signal : Out Of Memory, type(%s), ifname(%s), uid(%d), uttid(%d) \n",signal, target_if_name, uid, uttid); 
+               SLOG(LOG_ERROR, TAG_TTSD, "[Dbus ERROR] <<<< send message : Out Of Memory, type(%s), ifname(%s), uid(%d), data(%d)", method, target_if_name, uid, data); 
        } else {
-               SLOG(LOG_DEBUG, TAG_TTSD, "<<<< send signal : type(%s), uid(%d), uttid(%d) \n", signal, uid, uttid);
+               SLOG(LOG_DEBUG, TAG_TTSD, "<<<< send message : type(%s), uid(%d), data(%d)", method, uid, data);
 
                dbus_connection_flush(g_conn);
        }
+
        dbus_message_unref(msg);
 
        return 0;
 }
 
-int ttsdc_send_utt_start_signal(int pid, int uid, int uttid)
+int ttsdc_send_utt_start_message(int pid, int uid, int uttid)
 {
-       return ttsdc_send_signal(pid, uid, uttid, TTS_SIGNAL_UTTERANCE_STARTED);
+       return ttsdc_send_message(pid, uid, uttid, TTSD_METHOD_UTTERANCE_STARTED);
 }
 
-int ttsdc_send_utt_finish_signal(int pid, int uid, int uttid) 
+int ttsdc_send_utt_finish_message(int pid, int uid, int uttid) 
 {
-       return ttsdc_send_signal(pid, uid, uttid, TTS_SIGNAL_UTTERANCE_COMPLETED);
+       return ttsdc_send_message(pid, uid, uttid, TTSD_METHOD_UTTERANCE_COMPLETED);
 }
 
-int ttsdc_send_interrupt_signal(int pid, int uid, ttsd_interrupted_code_e code)
+int ttsdc_send_set_state_message(int pid, int uid, int state)
 {
-       return ttsdc_send_signal(pid, uid, (int)code, TTS_SIGNAL_INTERRUPT);
+       return ttsdc_send_message(pid, uid, state, TTSD_METHOD_SET_STATE);
 }
 
-int ttsdc_send_error_signal(int pid, int uid, int uttid, int reason)
+int ttsdc_send_error_message(int pid, int uid, int uttid, int reason)
 {
+       char service_name[64];
+       memset(service_name, 0, 64);
+       snprintf(service_name, 64, "%s%d", TTS_CLIENT_SERVICE_NAME, pid);
+
        char target_if_name[128];
        snprintf(target_if_name, sizeof(target_if_name), "%s%d", TTS_CLIENT_SERVICE_INTERFACE, pid);
 
        DBusMessage* msg;
-       msg = dbus_message_new_signal(
-               TTS_CLIENT_SERVICE_OBJECT_PATH,  /* object name of the signal   */
-               target_if_name,                  /* interface name of the signal */
-               TTS_SIGNAL_ERROR );              /* name of the signal  */
+
+       msg = dbus_message_new_method_call(
+               service_name, 
+               TTS_CLIENT_SERVICE_OBJECT_PATH, 
+               target_if_name, 
+               TTSD_METHOD_ERROR);
 
        if (NULL == msg) { 
                SLOG(LOG_ERROR, TAG_TTSD, "[Dbus ERROR] Fail to create error message : uid(%d)\n", uid); 
@@ -94,9 +162,9 @@ int ttsdc_send_error_signal(int pid, int uid, int uttid, int reason)
                DBUS_TYPE_INVALID);
        
        if (!dbus_connection_send(g_conn, msg, NULL)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Dbus ERROR] <<<< Send error signal : Out Of Memory !\n"); 
+               SLOG(LOG_ERROR, TAG_TTSD, "[Dbus ERROR] <<<< error message : Out Of Memory !\n"); 
        } else {
-               SLOG(LOG_DEBUG, TAG_TTSD, "<<<< Send error signal : reason(%d), uttid(%d)", reason, uttid);
+               SLOG(LOG_DEBUG, TAG_TTSD, "<<<< Send error signal : uid(%d), reason(%d), uttid(%d)", uid, reason, uttid);
                dbus_connection_flush(g_conn);
        }
 
@@ -105,6 +173,7 @@ int ttsdc_send_error_signal(int pid, int uid, int uttid, int reason)
        return 0;
 }
 
+
 static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handler)
 {
        DBusConnection* conn = (DBusConnection*)data;
@@ -117,12 +186,15 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
        msg = dbus_connection_pop_message(conn);
 
        /* loop again if we haven't read a message */
-       if (NULL == msg) { 
+       if (NULL == msg || NULL == conn) { 
                return ECORE_CALLBACK_RENEW;
        }
        
        /* client event */
-       if( dbus_message_is_method_call(msg, TTS_SERVER_SERVICE_INTERFACE, TTS_METHOD_INITIALIZE) )
+       if (dbus_message_is_method_call(msg, TTS_SERVER_SERVICE_INTERFACE, TTS_METHOD_HELLO))
+               ttsd_dbus_server_hello(conn, msg);
+
+       else if( dbus_message_is_method_call(msg, TTS_SERVER_SERVICE_INTERFACE, TTS_METHOD_INITIALIZE) )
                ttsd_dbus_server_initialize(conn, msg);
        
        else if( dbus_message_is_method_call(msg, TTS_SERVER_SERVICE_INTERFACE, TTS_METHOD_FINALIZE) )
@@ -147,6 +219,9 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
                ttsd_dbus_server_pause(conn, msg);
 
        /* setting event */
+       else if (dbus_message_is_method_call(msg, TTS_SERVER_SERVICE_INTERFACE, TTS_SETTING_METHOD_HELLO))
+               ttsd_dbus_server_hello(conn, msg);
+
        else if (dbus_message_is_method_call(msg, TTS_SERVER_SERVICE_INTERFACE, TTS_SETTING_METHOD_INITIALIZE) )
                ttsd_dbus_server_setting_initialize(conn, msg);
 
@@ -182,13 +257,7 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
 
        else if (dbus_message_is_method_call(msg, TTS_SERVER_SERVICE_INTERFACE, TTS_SETTING_METHOD_SET_ENGINE_SETTING) )
                ttsd_dbus_server_setting_set_engine_setting(conn, msg);
-
-       /* daemon internal event*/
-       else if (dbus_message_is_signal(msg, TTS_SERVER_SERVICE_INTERFACE, TTS_SIGNAL_NEXT_PLAY)) 
-               ttsd_dbus_server_start_next_play(msg);
-
-       else if (dbus_message_is_signal(msg, TTS_SERVER_SERVICE_INTERFACE, TTS_SIGNAL_NEXT_SYNTHESIS)) 
-               ttsd_dbus_server_start_next_synthesis(msg);
+       
 
        /* free the message */
        dbus_message_unref(msg);
@@ -277,57 +346,3 @@ int ttsd_dbus_close_connection()
 
        return 0;
 }
-
-int ttsd_send_start_next_play(int uid)
-{
-       DBusMessage* msg;
-
-       msg = dbus_message_new_signal(
-               TTS_SERVER_SERVICE_OBJECT_PATH, /* object name of the signal */
-               TTS_SERVER_SERVICE_INTERFACE,   /* interface name of the signal */
-               TTS_SIGNAL_NEXT_PLAY ); /* name of the signal */
-
-       if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_TTSD, "[Dbus ERROR] >>>> Fail to make message for 'start next play'"); 
-               return -1;
-       } 
-
-       dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);        
-
-       if (!dbus_connection_send(g_conn, msg, NULL)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Dbus ERROR] >>>> Fail to send message for 'start next play'\n"); 
-               return -1;
-       }
-
-       dbus_connection_flush(g_conn);
-       dbus_message_unref(msg);
-
-       return 0;
-}
-
-int ttsd_send_start_next_synthesis(int uid)
-{
-       DBusMessage* msg;
-
-       msg = dbus_message_new_signal(
-               TTS_SERVER_SERVICE_OBJECT_PATH, /* object name of the signal */
-               TTS_SERVER_SERVICE_INTERFACE,   /* interface name of the signal */
-               TTS_SIGNAL_NEXT_SYNTHESIS );    /* name of the signal */
-
-       if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_TTSD, "[Dbus ERROR] >>>> Fail to make message for 'start next synthesis'\n"); 
-               return -1;
-       } 
-       
-       dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);        
-       
-       if (!dbus_connection_send(g_conn, msg, NULL)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Dbus ERROR] >>>> Fail to send message for 'start next synthesis'\n"); 
-               return -1;
-       }
-
-       dbus_connection_flush(g_conn);
-       dbus_message_unref(msg);
-
-       return 0;
-}
old mode 100644 (file)
new mode 100755 (executable)
index 18716cf..a87af79
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved 
+*  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
@@ -24,17 +24,15 @@ int ttsd_dbus_open_connection();
 int ttsd_dbus_close_connection();
 
 
-int ttsdc_send_utt_start_signal(int pid, int uid, int uttid);
+int ttsdc_send_hello(int pid, int uid);
 
-int ttsdc_send_utt_finish_signal(int pid, int uid, int uttid);
+int ttsdc_send_utt_start_message(int pid, int uid, int uttid);
 
-int ttsdc_send_error_signal(int pid, int uid, int uttid, int reason);
+int ttsdc_send_utt_finish_message(int pid, int uid, int uttid);
 
-int ttsdc_send_interrupt_signal(int pid, int uid, ttsd_interrupted_code_e code);
+int ttsdc_send_error_message(int pid, int uid, int uttid, int reason);
 
-int ttsd_send_start_next_play(int uid);
-
-int ttsd_send_start_next_synthesis(int uid);
+int ttsdc_send_set_state_message(int pid, int uid, int state);
 
 #ifdef __cplusplus
 }
old mode 100644 (file)
new mode 100755 (executable)
index 0cc9066..a9d0d36
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved 
+*  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
@@ -23,6 +23,30 @@ extern int ttsd_data_get_pid(const int uid);
 * Dbus Client-Daemon Server
 */ 
 
+int ttsd_dbus_server_hello(DBusConnection* conn, DBusMessage* msg)
+{
+       SLOG(LOG_DEBUG, TAG_TTSD, ">>>>> TTS Hello");
+
+       DBusMessage* reply;
+       reply = dbus_message_new_method_return(msg);
+
+       if (NULL != reply) {
+               if (!dbus_connection_send(conn, reply, NULL)) {
+                       SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] Out Of Memory!");
+               }
+
+               dbus_connection_flush(conn);
+               dbus_message_unref(reply);
+       } else {
+               SLOG(LOG_ERROR, TAG_TTSD, "[OUT ERROR] Fail to create reply message!!"); 
+       }
+
+       SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<");
+       SLOG(LOG_DEBUG, TAG_TTSD, "  ");
+
+       return 0;
+}
+
 int ttsd_dbus_server_initialize(DBusConnection* conn, DBusMessage* msg)
 {
        DBusError err;
@@ -175,14 +199,16 @@ int ttsd_dbus_server_get_support_voices(DBusConnection* conn, DBusMessage* msg)
                                while (NULL != iter) {
                                        voice = iter->data;
 
-                                       dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(voice->language) );
-                                       dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(voice->type) );
+                                       if (NULL != voice) {
+                                               dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(voice->language) );
+                                               dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(voice->type) );
 
-                                       if (NULL != voice->language)
-                                               g_free(voice->language);
-                                       if (NULL != voice);
+                                               if (NULL != voice->language)
+                                                       g_free(voice->language);
+                                               
                                                g_free(voice);
-
+                                       }
+                                       
                                        voice_list = g_list_remove_link(voice_list, iter);
 
                                        iter = g_list_first(voice_list);
@@ -631,22 +657,25 @@ int ttsd_dbus_server_setting_get_engine_list(DBusConnection* conn, DBusMessage*
 
                                while (NULL != iter) {
                                        engine = iter->data;
-                                       SLOG(LOG_DEBUG, TAG_TTSD, "engine id : %s, engine name : %s, ug_name, : %s", 
-                                               engine->engine_id, engine->engine_name, engine->ug_name);
-
-                                       dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(engine->engine_id) );
-                                       dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(engine->engine_name) );
-                                       dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(engine->ug_name) );
-
-                                       if (NULL != engine->engine_id)
-                                               g_free(engine->engine_id);
-                                       if (NULL != engine->engine_name);
-                                               g_free(engine->engine_name);
-                                       if (NULL != engine->ug_name);
-                                               g_free(engine->ug_name);
-                                       if (NULL != engine);
+                                       
+                                       if (NULL != engine) {
+                                               SLOG(LOG_DEBUG, TAG_TTSD, "engine id : %s, engine name : %s, ug_name, : %s", 
+                                                       engine->engine_id, engine->engine_name, engine->ug_name);
+
+                                               dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(engine->engine_id) );
+                                               dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(engine->engine_name) );
+                                               dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(engine->ug_name) );
+
+                                               if (NULL != engine->engine_id)
+                                                       g_free(engine->engine_id);
+                                               if (NULL != engine->engine_name)
+                                                       g_free(engine->engine_name);
+                                               if (NULL != engine->ug_name)
+                                                       g_free(engine->ug_name);
+                                               
                                                g_free(engine);
-
+                                       }
+                                       
                                        engine_list = g_list_remove_link(engine_list, iter);
 
                                        iter = g_list_first(engine_list);
@@ -834,13 +863,15 @@ int ttsd_dbus_server_setting_get_voice_list(DBusConnection* conn, DBusMessage* m
                                        while (NULL != iter) {
                                                voice = iter->data;
 
-                                               dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(voice->language) );
-                                               dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(voice->type) );
+                                               if (NULL != voice) {
+                                                       dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(voice->language) );
+                                                       dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(voice->type) );
+
+                                                       if (NULL != voice->language)
+                                                               g_free(voice->language);
 
-                                               if (NULL != voice->language)
-                                                       g_free(voice->language);
-                                               if (NULL != voice);
                                                        g_free(voice);
+                                               }
 
                                                voice_list = g_list_remove_link(voice_list, iter);
 
@@ -1144,16 +1175,18 @@ int ttsd_dbus_server_setting_get_engine_setting(DBusConnection* conn, DBusMessag
                                        while (NULL != iter) {
                                                setting = iter->data;
 
-                                               dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(setting->key) );
-                                               dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(setting->value) );
+                                               if (NULL != setting) {
+                                                       dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(setting->key) );
+                                                       dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(setting->value) );
 
-                                               if (NULL != setting->key)
-                                                       g_free(setting->key);
-                                               if (NULL != setting->value)
-                                                       g_free(setting->value);
-                                               if (NULL != setting);
+                                                       if (NULL != setting->key)
+                                                               g_free(setting->key);
+                                                       if (NULL != setting->value)
+                                                               g_free(setting->value);
+                                                       
                                                        g_free(setting);
-
+                                               }
+                                               
                                                engine_setting_list = g_list_remove_link(engine_setting_list, iter);
 
                                                iter = g_list_first(engine_setting_list);
@@ -1240,63 +1273,3 @@ int ttsd_dbus_server_setting_set_engine_setting(DBusConnection* conn, DBusMessag
        return 0;
 }
 
-
-/*
-* Dbus Server functions for tts daemon intenal
-*/ 
-
-int ttsd_dbus_server_start_next_play(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_TTSD, ">>>>> TTSD NEXT PLAY");
-
-       if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] ttsd 'start next play' : Get arguments error (%s)\n", err.message);
-               dbus_error_free(&err); 
-       } else {
-               SLOG(LOG_DEBUG, TAG_TTSD, "[IN] ttsd 'start next play' : uid(%d) \n", uid);
-               int ret = ttsd_server_start_next_play(uid);
-               SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] ttsd 'start next play' : result(%d) \n", ret);
-       }
-
-       SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<");
-       SLOG(LOG_DEBUG, TAG_TTSD, "  ");
-
-       return 0;
-}
-
-int ttsd_dbus_server_start_next_synthesis(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_TTSD, ">>>>> TTSD NEXT SYNTHESIS");
-
-       if (dbus_error_is_set(&err)) { 
-               SLOG(LOG_ERROR, TAG_TTSD, "[IN ERROR] ttsd 'start next synthesis' : Get arguments error (%s)\n", err.message);
-               dbus_error_free(&err); 
-       } else {
-               SLOG(LOG_DEBUG, TAG_TTSD, "[IN] ttsd 'start next synthesis' : uid(%d) \n", uid);
-               int ret = ttsd_server_start_next_synthesis(uid);
-               SLOG(LOG_DEBUG, TAG_TTSD, "[OUT] ttsd 'start next synthesis' : result(%d) \n", ret);
-       }
-
-       SLOG(LOG_DEBUG, TAG_TTSD, "<<<<<");
-       SLOG(LOG_DEBUG, TAG_TTSD, "  ");
-
-       return 0;
-}
\ No newline at end of file
old mode 100644 (file)
new mode 100755 (executable)
index 76a7410..c47c628
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved 
+*  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
@@ -21,6 +21,8 @@
 extern "C" {
 #endif
 
+int ttsd_dbus_server_hello(DBusConnection* conn, DBusMessage* msg);
+
 /*
 * Dbus Server functions for APIs
 */ 
@@ -71,14 +73,6 @@ int ttsd_dbus_server_setting_get_engine_setting(DBusConnection* conn, DBusMessag
 int ttsd_dbus_server_setting_set_engine_setting(DBusConnection* conn, DBusMessage* msg);
 
 
-/*
-* Dbus Server functions for tts daemon internal
-*/ 
-
-int ttsd_dbus_server_start_next_play(DBusMessage* msg);
-
-int ttsd_dbus_server_start_next_synthesis(DBusMessage* msg);
-
 #ifdef __cplusplus
 }
 #endif
old mode 100644 (file)
new mode 100755 (executable)
index 08ac5c8..44a1972
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved 
+*  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
@@ -120,17 +120,16 @@ int ttsd_engine_agent_init(synth_result_callback result_cb)
 
        g_agent_init = true;
 
-       if (0 != ttsd_config_get_char_type(CONFIG_KEY_DEFAULT_LANGUAGE, &(g_cur_engine.default_lang)) &&
-               0 != ttsd_config_get_int_type(CONFIG_KEY_DEFAULT_VOICE_TYPE, &(g_cur_engine.default_vctype)) ) {
-               /* Set default voice */
+       if (0 != ttsd_config_get_default_voice(&(g_cur_engine.default_lang), &(g_cur_engine.default_vctype))) {
                SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] There is No default voice in config\n"); 
+               /* Set default voice */
                g_cur_engine.default_lang = strdup("en_US");
                g_cur_engine.default_vctype = TTSP_VOICE_TYPE_FEMALE;
        }
 
-       if (0 != ttsd_config_get_int_type(CONFIG_KEY_DEFAULT_SPEED, &(g_cur_engine.default_speed))) {
+       if (0 != ttsd_config_get_default_speed(&(g_cur_engine.default_speed))) {
                SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] There is No default speed in config\n"); 
-               ttsd_config_set_int_type(CONFIG_KEY_DEFAULT_SPEED, TTSP_SPEED_NORMAL);
+               ttsd_config_set_default_speed((int)TTSP_SPEED_NORMAL);
                g_cur_engine.default_speed = TTSP_SPEED_NORMAL;
        }
 
@@ -156,28 +155,27 @@ int ttsd_engine_agent_release()
        if (g_list_length(g_engine_list) > 0) {
                /* Get a first item */
                iter = g_list_first(g_engine_list);
-
                while (NULL != iter) {
                        /* Get data from item */
                        data = iter->data;
-                       dlclose(data->handle); 
-
                        iter = g_list_remove(iter, data);
                }
        }
-
        g_list_free(iter);
-
        /* release current engine data */
-       ifg_cur_engine.pefuncs != NULL)
+       if (g_cur_engine.pefuncs != NULL)
                g_free(g_cur_engine.pefuncs);
        
-       ifg_cur_engine.pdfuncs != NULL)
+       if (g_cur_engine.pdfuncs != NULL)
                g_free(g_cur_engine.pdfuncs);
 
        g_result_cb = NULL;
        g_agent_init = false;
 
+       if (g_cur_engine.default_lang != NULL) 
+               g_free(g_cur_engine.default_lang);
+
+
        SLOG(LOG_DEBUG, TAG_TTSD, "[Engine Agent SUCCESS] Release Engine Agent\n");
 
        return 0;
@@ -200,7 +198,7 @@ int ttsd_engine_agent_initialize_current_engine()
        char* cur_engine_uuid = NULL;
        bool is_get_engineid_from_config = false;
 
-       if (0 != ttsd_config_get_char_type(CONFIG_KEY_DEFAULT_ENGINE_ID ,&cur_engine_uuid)) {
+       if (0 != ttsd_config_get_default_engine(&cur_engine_uuid)) {
                /*not set current engine */
                /*set system default engine*/
                GList *iter = NULL;
@@ -273,7 +271,7 @@ int ttsd_engine_agent_initialize_current_engine()
        } 
 
        if (false == is_get_engineid_from_config) {
-               if (0 != ttsd_config_set_char_type(CONFIG_KEY_DEFAULT_ENGINE_ID ,cur_engine_uuid))
+               if (0 != ttsd_config_set_default_engine(cur_engine_uuid))
                        SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] fail to set id to config \n"); 
        }
 
@@ -347,8 +345,8 @@ int __internal_get_engine_info(const char* filepath, ttsengine_info_s** info)
        int (*get_engine_info)(ttsp_engine_info_cb callback, void* user_data);
 
        get_engine_info = (int (*)(ttsp_engine_info_cb, void*))dlsym(handle, "ttsp_get_engine_info");
-       if ((error = dlerror()) != NULL) {
-               SLOG(LOG_WARN, TAG_TTSD, "[Engine Agent] ttsp_get_engine_info() link error\n");
+       if (NULL != (error = dlerror()) || NULL == get_engine_info) {
+               SLOG(LOG_WARN, TAG_TTSD, "[Engine Agent] ttsp_get_engine_info() link error");
                dlclose(handle);
                return TTSD_ERROR_OPERATION_FAILED;
        }
@@ -358,7 +356,7 @@ int __internal_get_engine_info(const char* filepath, ttsengine_info_s** info)
 
        /* get engine info */
        if (0 != get_engine_info(&__engine_info_cb, (void*)temp)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] fail to get engine info\n");
+               SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] fail to get engine info");
                dlclose(handle);
                g_free(temp);
                return TTSD_ERROR_OPERATION_FAILED;
@@ -370,11 +368,11 @@ int __internal_get_engine_info(const char* filepath, ttsengine_info_s** info)
        temp->engine_path = g_strdup(filepath);
        
        SLOG(LOG_DEBUG, TAG_TTSD, "----- Valid engine");
-       SLOG(LOG_DEBUG, TAG_TTSD, "Engine uuid : %s\n", temp->engine_uuid);
-       SLOG(LOG_DEBUG, TAG_TTSD, "Engine name : %s\n", temp->engine_name);
-       SLOG(LOG_DEBUG, TAG_TTSD, "Setting ug path : %s\n", temp->setting_ug_path);
-       SLOG(LOG_DEBUG, TAG_TTSD, "Engine path : %s\n", temp->engine_path);
-       SLOG(LOG_DEBUG, TAG_TTSD, "Use network : %s\n", temp->use_network ? "true":"false");
+       SLOG(LOG_DEBUG, TAG_TTSD, "Engine uuid : %s", temp->engine_uuid);
+       SLOG(LOG_DEBUG, TAG_TTSD, "Engine name : %s", temp->engine_name);
+       SLOG(LOG_DEBUG, TAG_TTSD, "Setting ug path : %s", temp->setting_ug_path);
+       SLOG(LOG_DEBUG, TAG_TTSD, "Engine path : %s", temp->engine_path);
+       SLOG(LOG_DEBUG, TAG_TTSD, "Use network : %s", temp->use_network ? "true":"false");
        SLOG(LOG_DEBUG, TAG_TTSD, "-----");
        SLOG(LOG_DEBUG, TAG_TTSD, "  ");
 
@@ -406,44 +404,72 @@ int __internal_update_engine_list()
        /* get file name from engine directory and get engine information from each filename */
        DIR *dp;
        struct dirent *dirp;
-       dp = opendir(ENGINE_DIRECTORY);
+       dp = opendir(ENGINE_DIRECTORY_DEFAULT);
 
-       if (dp == NULL) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] __internal_update_engine_list : error opendir \n");
-               return TTSD_ERROR_OPERATION_FAILED;
-       }
+       if (dp != NULL) {
+               while ((dirp = readdir(dp)) != NULL) {
+                       ttsengine_info_s* info;
+                       char* filepath = NULL;
+                       int file_size;
 
-       SLOG(LOG_DEBUG, TAG_TTSD, "[Engine Agent] Search TTS Engines");
+                       file_size = strlen(ENGINE_DIRECTORY_DEFAULT) + strlen(dirp->d_name) + 5;
+                       filepath = (char*)g_malloc0( sizeof(char) * file_size);
 
-       while ((dirp = readdir(dp)) != NULL) {
-               ttsengine_info_s* info;
-               char* filepath = NULL;
-               int file_size;
+                       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_TTSD, "[Engine Agent ERROR] Not enough memory!! \n" );
+                               continue;       
+                       }
 
-               file_size = strlen(ENGINE_DIRECTORY) + strlen(dirp->d_name) + 5;
-               filepath = (char*)g_malloc0( sizeof(char) * file_size);
+                       /* 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 != filepath) { 
-                       strncpy(filepath, ENGINE_DIRECTORY, strlen(ENGINE_DIRECTORY) );
-                       strncat(filepath, "/", strlen("/") );
-                       strncat(filepath, dirp->d_name, strlen(dirp->d_name) );
-               } else {
-                       SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Not enough memory!! \n" );
-                       continue;       
+                       if (NULL != filepath)
+                               g_free(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_list_append(g_engine_list, info);
+               closedir(dp);
+       }
+
+       dp = opendir(ENGINE_DIRECTORY_DOWNLOAD);
+
+       if (dp != NULL) {
+               while ((dirp = readdir(dp)) != NULL) {
+                       ttsengine_info_s* info;
+                       char* filepath = NULL;
+                       int file_size;
+
+                       file_size = strlen(ENGINE_DIRECTORY_DOWNLOAD) + strlen(dirp->d_name) + 5;
+                       filepath = (char*)g_malloc0( sizeof(char) * file_size);
+
+                       if (NULL != filepath) { 
+                               strcpy(filepath, ENGINE_DIRECTORY_DOWNLOAD);
+                               strcat(filepath, "/");
+                               strcat(filepath, dirp->d_name);
+                       } else {
+                               SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] Not enough memory!! \n" );
+                               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_list_append(g_engine_list, info);
+                       }
+
+                       if (NULL != filepath)
+                               g_free(filepath);
                }
 
-               if (NULL != filepath)
-                       g_free(filepath);
+               closedir(dp);
        }
 
-       closedir(dp);
-
        if (g_list_length(g_engine_list) <= 0) {
                SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] No Engine\n");
                return TTSD_ERROR_OPERATION_FAILED;     
@@ -498,6 +524,11 @@ int __internal_set_current_engine(const char* engine_uuid)
        if (g_cur_engine.engine_name != NULL)   g_free(g_cur_engine.engine_name);
        if (g_cur_engine.engine_path != NULL)   g_free(g_cur_engine.engine_path);
 
+       if (NULL == data->engine_uuid || NULL == data->engine_name || NULL == data->engine_path) {
+               SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] __internal_set_current_engine : Engine data is NULL");
+               return TTSD_ERROR_OPERATION_FAILED;
+       }
+
        g_cur_engine.engine_uuid = g_strdup(data->engine_uuid);
        g_cur_engine.engine_name = g_strdup(data->engine_name);
        g_cur_engine.engine_path = g_strdup(data->engine_path);
@@ -540,20 +571,20 @@ int ttsd_engine_agent_load_current_engine()
        char *error = NULL;
        g_cur_engine.handle = dlopen(g_cur_engine.engine_path, RTLD_LAZY); /* RTLD_LAZY RTLD_NOW*/
 
-       if ((error = dlerror()) != NULL || !g_cur_engine.handle) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] fail to get current engine handle : dlopen error \n");
+       if (NULL != (error = dlerror()) || NULL == g_cur_engine.handle) {
+               SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] fail to get current engine handle : dlopen error ($s)", error);
                return -2;
        }
 
        g_cur_engine.ttsp_unload_engine = (int (*)())dlsym(g_cur_engine.handle, "ttsp_unload_engine");
-       if ((error = dlerror()) != NULL) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] fail to link daemon to ttsp_unload_engine() of current engine\n");
+       if (NULL != (error = dlerror()) || NULL == g_cur_engine.ttsp_unload_engine) {
+               SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] fail to link daemon to ttsp_unload_engine() of current engine : (%s)", error);
                return -3;
        }
 
        g_cur_engine.ttsp_load_engine = (int (*)(const ttspd_funcs_s* , ttspe_funcs_s*) )dlsym(g_cur_engine.handle, "ttsp_load_engine");
-       if ((error = dlerror()) != NULL) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] fail to link daemon to ttsp_load_engine() of current engine \n");
+       if (NULL != (error = dlerror()) || NULL == g_cur_engine.ttsp_load_engine) {
+               SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] fail to link daemon to ttsp_load_engine() of current engine : %s", error);
                return -3;
        }
 
@@ -633,9 +664,8 @@ int ttsd_engine_agent_load_current_engine()
                                        return TTSD_ERROR_OPERATION_FAILED;
                                }
 
-                               ttsd_config_set_char_type(CONFIG_KEY_DEFAULT_LANGUAGE, voice->language);
-                               ttsd_config_set_int_type(CONFIG_KEY_DEFAULT_VOICE_TYPE, voice->type);
-
+                               ttsd_config_set_default_voice(voice->language, (int)voice->type);
+                               
                                g_cur_engine.default_lang = g_strdup(voice->language);
                                g_cur_engine.default_vctype = voice->type;
 
@@ -1072,10 +1102,9 @@ int ttsd_engine_get_default_voice( char** lang, ttsp_voice_type_e* vctype )
                                        SLOG(LOG_ERROR, TAG_TTSD, "[Engine ERROR] Fail voice is NOT valid ");
                                        return TTSD_ERROR_OPERATION_FAILED;
                                }
-
-                               ttsd_config_set_char_type(CONFIG_KEY_DEFAULT_LANGUAGE, voice->language);
-                               ttsd_config_set_int_type(CONFIG_KEY_DEFAULT_VOICE_TYPE, voice->type);
-
+                               
+                               ttsd_config_set_default_voice(voice->language, (int)voice->type);
+                               
                                if (NULL != g_cur_engine.default_lang)
                                        g_free(g_cur_engine.default_lang);
 
@@ -1200,8 +1229,9 @@ int ttsd_engine_setting_set_engine(const char* engine_id)
 
                /* roll back to old current engine. */
                __internal_set_current_engine(tmp_uuid);
-
-               if( tmp_uuid != NULL )  
+               ttsd_engine_agent_load_current_engine();
+               
+               if (tmp_uuid != NULL)   
                        free(tmp_uuid);
 
                return TTSD_ERROR_OPERATION_FAILED;
@@ -1220,7 +1250,7 @@ int ttsd_engine_setting_set_engine(const char* engine_id)
        }
 
        /* save engine id to config */
-       if (0 != ttsd_config_set_char_type(CONFIG_KEY_DEFAULT_ENGINE_ID, engine_id)) {
+       if (0 != ttsd_config_set_default_engine(engine_id)) {
                SLOG(LOG_WARN, TAG_TTSD, "[Engine Agent WARNING] Fail to save engine id to config \n"); 
        }
 
@@ -1320,15 +1350,10 @@ int ttsd_engine_setting_set_default_voice(const char* language, ttsp_voice_type_
        g_cur_engine.default_lang = strdup(language);
        g_cur_engine.default_vctype = vctype;
 
-       ret = ttsd_config_set_char_type(CONFIG_KEY_DEFAULT_LANGUAGE, language);
+       ret = ttsd_config_set_default_voice(language, (int)vctype);
        if (0 == ret) {
-               ret = ttsd_config_set_int_type(CONFIG_KEY_DEFAULT_VOICE_TYPE, vctype);
-               if (0 != ret) {
-                       SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] fail to write default voice to config (%d) \n", ret); 
-               } else {
-                       SLOG(LOG_DEBUG, TAG_TTSD, "[Engine Agent SUCCESS] Set default voice : lang(%s), type(%d) \n",
+               SLOG(LOG_DEBUG, TAG_TTSD, "[Engine Agent SUCCESS] Set default voice : lang(%s), type(%d) \n",
                                g_cur_engine.default_lang, g_cur_engine.default_vctype); 
-               }
        } else {
                SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] fail to write default voice to config (%d) \n", ret); 
        }
@@ -1368,7 +1393,7 @@ int ttsd_engine_setting_set_default_speed(const ttsp_speed_e speed)
 
        g_cur_engine.default_speed = speed;
 
-       if (0 != ttsd_config_set_int_type(CONFIG_KEY_DEFAULT_SPEED, speed)) {
+       if (0 != ttsd_config_set_default_speed(speed)) {
                SLOG(LOG_ERROR, TAG_TTSD, "[Engine Agent ERROR] fail to set default speed to config");
        }
 
@@ -1473,11 +1498,13 @@ void __free_voice_list(GList* voice_list)
                while (NULL != iter) {
                        data = iter->data;
                        
-                       if (NULL != data->language)
-                               g_free(data->language);
-                       if (NULL != data);
-                               g_free(data);
+                       if (NULL != data) {
+                               if (NULL != data->language)
+                                       g_free(data->language);
 
+                               g_free(data);
+                       }
+                       
                        voice_list = g_list_remove_link(voice_list, iter);
                        
                        iter = g_list_first(voice_list);
old mode 100644 (file)
new mode 100755 (executable)
index dfccf33..bd618fb
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved 
+*  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
old mode 100644 (file)
new mode 100755 (executable)
index 0157760..539a2a1
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved 
+*  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
@@ -19,6 +19,8 @@
 
 #include <Ecore.h>
 
+#define CLIENT_CLEAN_UP_TIME 500
+
 /* Main of TTS Daemon */
 int main()
 {
@@ -47,6 +49,8 @@ int main()
                return EXIT_FAILURE;
        }
 
+       ecore_timer_add(CLIENT_CLEAN_UP_TIME, ttsd_cleanup_client, NULL);
+
        SLOG(LOG_DEBUG, TAG_TTSD, "[Main] tts-daemon start...\n"); 
        SLOG(LOG_DEBUG, TAG_TTSD, "=====");
        SLOG(LOG_DEBUG, TAG_TTSD, "  ");
@@ -55,13 +59,19 @@ int main()
        printf("TTS-Daemon Start...\n");
        
        ecore_main_loop_begin();
-       
-       ecore_shutdown();
 
+       SLOG(LOG_DEBUG, TAG_TTSD, "===== TTS DAEMON FINALIZE");
+       
        ttsd_dbus_close_connection();
 
        ttsd_network_finalize();
 
+       ecore_shutdown();
+
+       SLOG(LOG_DEBUG, TAG_TTSD, "=====");
+       SLOG(LOG_DEBUG, TAG_TTSD, "  ");
+       SLOG(LOG_DEBUG, TAG_TTSD, "  ");
+
        return 0;
 }
 
old mode 100644 (file)
new mode 100755 (executable)
index 1d0df35..5fc8ce9
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved 
+*  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
@@ -33,21 +33,31 @@ extern "C" {
 
 /* TTS Daemon Define */ 
 #define TAG_TTSD "ttsd"
-#define ENGINE_DIRECTORY "/usr/lib/voice/tts/1.0/engine"
+
+#define BASE_DIRECTORY_DEFAULT                 "/usr/lib/voice/tts/1.0"
+#define ENGINE_DIRECTORY_DEFAULT               "/usr/lib/voice/tts/1.0/engine"
+#define ENGINE_DIRECTORY_DEFAULT_SETTING       "/usr/lib/voice/tts/1.0/setting"
+
+#define CONFIG_DIRECTORY                       "/opt/home/app/.voice"
+       
+#define ENGINE_DIRECTORY_DOWNLOAD              "/opt/usr/voice/tts/1.0/engine"
+#define ENGINE_DIRECTORY_DOWNLOAD_SETTING      "/opt/usr/voice/tts/1.0/setting"
+
 
 /* for debug message */
 #define DATA_DEBUG
 
 typedef enum {
-       TTSD_ERROR_NONE                 = 0,            /**< Success, No error */
-       TTSD_ERROR_OUT_OF_MEMORY        = -ENOMEM,      /**< Out of Memory */
-       TTSD_ERROR_IO_ERROR             = -EIO,         /**< I/O error */
-       TTSD_ERROR_INVALID_PARAMETER    = -EINVAL,      /**< Invalid parameter */
-       TTSD_ERROR_INVALID_STATE        = -0x0100021,   /**< Invalid state */
-       TTSD_ERROR_INVALID_VOICE        = -0x0100022,   /**< Invalid voice */
-       TTSD_ERROR_ENGINE_NOT_FOUND     = -0x0100023,   /**< No available TTS-engine  */
-       TTSD_ERROR_TIMED_OUT            = -0x0100024,   /**< No answer from TTS daemon */
-       TTSD_ERROR_OPERATION_FAILED     = -0x0100025,   /**< TTS daemon failed  */
+       TTSD_ERROR_NONE                 = 0,                    /**< Successful */
+       TTSD_ERROR_OUT_OF_MEMORY        = -ENOMEM,              /**< Out of Memory */
+       TTSD_ERROR_IO_ERROR             = -EIO,                 /**< I/O error */
+       TTSD_ERROR_INVALID_PARAMETER    = -EINVAL,              /**< Invalid parameter */
+       TTSD_ERROR_OUT_OF_NETWORK       = -ENETDOWN,            /**< Out of network */
+       TTSD_ERROR_INVALID_STATE        = -0x0100000 | 0x21,    /**< Invalid state */
+       TTSD_ERROR_INVALID_VOICE        = -0x0100000 | 0x22,    /**< Invalid voice */
+       TTSD_ERROR_ENGINE_NOT_FOUND     = -0x0100000 | 0x23,    /**< No available engine  */
+       TTSD_ERROR_TIMED_OUT            = -0x0100000 | 0x24,    /**< No answer from the daemon */
+       TTSD_ERROR_OPERATION_FAILED     = -0x0100000 | 0x25     /**< Operation failed  */
 }ttsd_error_e;
 
 
old mode 100644 (file)
new mode 100755 (executable)
index cc1febf..f607a93
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved 
+*  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
@@ -58,7 +58,6 @@ int ttsd_network_initialize()
                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_TTSD, "[Network] Current network connection is OFF.");
                }
                else{
@@ -66,14 +65,13 @@ int ttsd_network_initialize()
                        *       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");
+                       SLOG(LOG_WARN, TAG_TTSD, "network status is wrong or IP is not set\n");
+                       SLOG(LOG_WARN, TAG_TTSD, "network has problem, try again\n");
                        return -1;
                }
 
                g_is_connected = false;
        } else {
-               printf("Current network connection is ON. \n");
                SLOG(LOG_DEBUG, TAG_TTSD, "[Network] Current network connection is ON.");
 
                g_is_connected = true;
old mode 100644 (file)
new mode 100755 (executable)
index a1eaf92..55ef030
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved 
+*  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
old mode 100644 (file)
new mode 100755 (executable)
index 02a825c..3508ce7
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved 
+*  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
@@ -15,6 +15,7 @@
 #include <mm_types.h>
 #include <mm_player.h>
 #include <mm_error.h>
+#include <Ecore.h>
 
 #include "ttsd_main.h"
 #include "ttsd_player.h"
@@ -65,6 +66,7 @@ typedef struct {
 
 #define TEMP_FILE_PATH  "/tmp"
 #define FILE_PATH_SIZE  256
+#define DEFAULT_FILE_SIZE 10
 
 /** player init info */
 static bool g_player_init = false;
@@ -81,11 +83,14 @@ static player_result_callback_func g_result_callback;
 /** numbering for temp file */
 static unsigned int g_index;              
 
+/** For resume when the 'Paused' state of player after end of play */
+static bool g_pause_info;
+static int g_paused_uid;
+
 
 /*
 * Internal Interfaces 
 */
-
 player_s* __player_get_item(int uid);
 
 int __save_file(const int uid, const int index, const sound_data_s data, char** filename);
@@ -96,7 +101,6 @@ int __init_wave_header(WavHeader* hdr, size_t nsamples, size_t sampling_rate, in
 
 static int msg_callback(int message, void *data, void *user_param) ;
 
-
 /*
 * Player Interfaces 
 */
@@ -115,6 +119,8 @@ int ttsd_player_init(player_result_callback_func result_cb)
        g_index = 1;
        g_player_init = true;
 
+       g_pause_info = false;
+       g_paused_uid = -1;
        return 0;
 }
 
@@ -199,12 +205,6 @@ int ttsd_player_destroy_instance(int uid)
        switch (player_state) {
                case MM_PLAYER_STATE_PLAYING:
                case MM_PLAYER_STATE_PAUSED:
-                       ret = mm_player_stop(current->player_handle);
-                       if (MM_ERROR_NONE != ret) {
-                               SLOG(LOG_ERROR, TAG_TTSD, "[Player WARNING] fail mm_player_stop() : %x", ret);
-                       }
-                       /* NO break for unrealize */
-
                case MM_PLAYER_STATE_READY:
                        ret = mm_player_unrealize(current->player_handle);
                        if (MM_ERROR_NONE != ret) {
@@ -213,13 +213,16 @@ int ttsd_player_destroy_instance(int uid)
                        /* NO break for destroy */
 
                case MM_PLAYER_STATE_NULL:
-                       mm_player_destroy(current->player_handle);
+                       ret = mm_player_destroy(current->player_handle);
+                       if (MM_ERROR_NONE != ret) {
+                               SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] fail mm_player_destroy() : %x", ret);
+                       } 
                        break;
 
                default:
                        break;
        }
-
+               
        GList *iter = NULL;
        player_s *data = NULL;
 
@@ -231,20 +234,22 @@ int ttsd_player_destroy_instance(int uid)
                        /* Get handle data from list */
                        data = (player_s*)iter->data;
 
-                       /* compare uid */
-                       if (uid == data->uid) {
-                               g_player_list = g_list_remove_link(g_player_list, iter);                                
-                               if (NULL != data) {
+                       if (NULL != data) {
+                               /* compare uid */
+                               if (uid == data->uid) {
+                                       g_player_list = g_list_remove_link(g_player_list, iter);                                
                                        g_free(data);
+                                       break;
                                }
-                               break;
-                       }       
-
+                       }
+                               
                        /* Get next item */
                        iter = g_list_next(iter);
                }
        }
 
+       SLOG(LOG_DEBUG, TAG_TTSD, "[PLAYER Success] Destroy instance");
+
        return 0;
 }
 
@@ -340,7 +345,7 @@ int ttsd_player_next_play(int uid)
                        return 0;
                }
        } else {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] Current player do NOT exist"); 
+               SLOG(LOG_WARN, TAG_TTSD, "[Player WARNING] Current player do NOT exist"); 
                return -1;
        }
 
@@ -354,12 +359,6 @@ int ttsd_player_next_play(int uid)
        switch (player_state) {
                case MM_PLAYER_STATE_PLAYING:
                case MM_PLAYER_STATE_PAUSED:
-                       ret = mm_player_stop(current->player_handle);
-                       if (MM_ERROR_NONE != ret) {
-                               SLOG(LOG_ERROR, TAG_TTSD, "[Player WARNING] fail mm_player_stop() : %x", ret);
-                       }
-                       /* NO break for unrealize */
-
                case MM_PLAYER_STATE_READY:
                        ret = mm_player_unrealize(current->player_handle);
                        if (MM_ERROR_NONE != ret) {
@@ -431,12 +430,6 @@ int ttsd_player_stop(const int uid)
        switch (player_state) {
                case MM_PLAYER_STATE_PLAYING:
                case MM_PLAYER_STATE_PAUSED:
-                       ret = mm_player_stop(current->player_handle);
-                       if (MM_ERROR_NONE != ret) {
-                               SLOG(LOG_ERROR, TAG_TTSD, "[Player WARNING] fail mm_player_stop() : %x", ret);
-                       }
-                       /* NO break for unrealize */
-
                case MM_PLAYER_STATE_READY:
                        ret = mm_player_unrealize(current->player_handle);
                        if (MM_ERROR_NONE != ret) {
@@ -532,13 +525,29 @@ int ttsd_player_resume(const int uid)
 
        int ret = -1;
        if (MM_PLAYER_STATE_PAUSED == player_state) {
-               ret = mm_player_resume(current->player_handle);
-               if (MM_ERROR_NONE != ret) {
-                       SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] fail mm_player_resume() : %d", ret);
-                       return -1;
-               }
+               /* When the 'Paused' state of player after end of play */
+               if (g_pause_info == true && g_paused_uid == uid) {
+                       g_playing_info = current;
 
-               g_playing_info = current;
+                       g_pause_info = false;
+                       g_paused_uid = -1;
+                       
+                       /* Current state need load and play */
+                       ret = ttsd_player_next_play(uid);
+                       if (0 != ret) {
+                               SLOG(LOG_ERROR, TAG_TTSD, "[player] Fail to next play in resume function");
+                       }
+               } else {
+                       ret = mm_player_resume(current->player_handle);
+                       if (MM_ERROR_NONE != ret) {
+                               SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] fail mm_player_resume() : %d", ret);
+                               return -1;
+                       } else {
+                               SLOG(LOG_DEBUG, TAG_TTSD, "[Player] Resume player");
+                       }
+
+                       g_playing_info = current;
+               }
        } else {
                SLOG(LOG_WARN, TAG_TTSD, "[Player WARNING] Current uid is NOT paused state.");
        }
@@ -611,11 +620,6 @@ int ttsd_player_all_stop()
                        }
 
                        if (APP_STATE_PLAYING == state || APP_STATE_PAUSED == state) {
-                               ret = mm_player_stop(data->player_handle);
-                               if (MM_ERROR_NONE != ret) {
-                                       SLOG(LOG_WARN, TAG_TTSD, "[player WARNING] fail mm_player_stop() : %x ", ret);
-                               }
-
                                /* unrealize player */
                                ret = mm_player_unrealize(data->player_handle);
                                if (MM_ERROR_NONE != ret) {
@@ -636,15 +640,49 @@ int ttsd_player_all_stop()
        return 0;
 }
 
+static Eina_Bool __player_next_play(void *data)
+{
+       SLOG(LOG_DEBUG, TAG_TTSD, "===== PLAYER NEXT PLAY");
+
+       int* uid = (int*)data;
+
+       if (NULL == uid) {
+               SLOG(LOG_ERROR, TAG_TTSD, "[PLAYER ERROR] uid is NULL");
+               SLOG(LOG_DEBUG, TAG_TTSD, "=====");
+               SLOG(LOG_DEBUG, TAG_TTSD, "  ");
+               return EINA_FALSE;
+       }
+
+       SLOG(LOG_DEBUG, TAG_TTSD, "[PLAYER] uid = %d", *uid);
+       
+       if (0 != ttsd_player_next_play(*uid)) {
+               SLOG(LOG_WARN, TAG_TTSD, "[PLAYER WARNING] Fail to play next");
+       }
+
+       free(uid);
+
+       SLOG(LOG_DEBUG, TAG_TTSD, "=====");
+       SLOG(LOG_DEBUG, TAG_TTSD, "  ");
+
+       return EINA_FALSE;
+}
+
 static int msg_callback(int message, void *data, void *user_param) 
 {
-       user_data_s* user_data;
+       user_data_s* user_data = NULL;
 
        user_data = (user_data_s*)user_param;
 
+       if (NULL == user_data) {
+               SLOG(LOG_ERROR, TAG_TTSD, "[PLAYER ERROR] user_param is NULL");
+               return -1;
+       }
+
        int uid = user_data->uid;
        int utt_id = user_data->utt_id;
 
+       MMMessageParamType *msg = (MMMessageParamType*)data;
+
        switch (message) {
        case MM_MESSAGE_ERROR:
                {
@@ -679,66 +717,16 @@ static int msg_callback(int message, void *data, void *user_param)
                break;  /*MM_MESSAGE_ERROR*/
 
        case MM_MESSAGE_BEGIN_OF_STREAM:
-               {
-                       SLOG(LOG_DEBUG, TAG_TTSD, "===== BEGIN OF STREAM CALLBACK");
-
-                       /* Check uid */
-                       player_s* current;
-                       current = __player_get_item(uid);
-                       if (NULL == current) {
-                               SLOG(LOG_ERROR, TAG_TTSD, "[PLAYER] uid(%d) is NOT valid ", uid);
-                               return -1;
-                       }
-
-                       if (TTSP_RESULT_EVENT_START == user_data->event ||
-                           (TTSP_RESULT_EVENT_FINISH == current->event && TTSP_RESULT_EVENT_FINISH == user_data->event)) {
-                               int pid;
-                               pid = ttsd_data_get_pid(uid);
-
-                               /* send utterance start message */
-                               if (0 == ttsdc_send_utt_start_signal(pid, uid, utt_id)) {
-                                       SLOG(LOG_DEBUG, TAG_TTSD, "[Send SUCCESS] Send Utterance Start Signal : pid(%d), uid(%d), uttid(%d)", pid, uid, utt_id);
-                               } else 
-                                       SLOG(LOG_ERROR, TAG_TTSD, "[Send ERROR] Fail to send Utterance Start Signal : pid(%d), uid(%d), uttid(%d)", pid, uid, utt_id);
-                       } else {
-                               SLOG(LOG_DEBUG, TAG_TTSD, "[PLAYER] Don't need to send Utterance Start Signal");
-                       }
-
-                       /* set current playing info */
-                       current->utt_id = utt_id;
-                       current->event = user_data->event;
-                       g_playing_info = current;
-
-                       app_state_e state;
-                       ttsd_data_get_client_state(uid, &state);
-
-                       /* for sync problem */
-                       if (APP_STATE_PAUSED == state) {
-                               MMPlayerStateType player_state;
-                               mm_player_get_state(current->player_handle, &player_state);
-
-                               SLOG(LOG_DEBUG, TAG_TTSD, "[PLAYER] Current state(%d)", player_state);
-
-                               int ret = 0;
-                               if (MM_PLAYER_STATE_PLAYING == player_state) {
-                                       ret = mm_player_pause(current->player_handle);
-                                       if (MM_ERROR_NONE != ret) {
-                                               SLOG(LOG_ERROR, TAG_TTSD, "[PLAYER ERROR] fail mm_player_pause() : %x", ret);
-                                       } else {
-                                               SLOG(LOG_DEBUG, TAG_TTSD, "[PLAYER] uid(%d) changes 'Pause' state ", uid);
-                                       }
-                               }
-                       }
 
-                       SLOG(LOG_DEBUG, TAG_TTSD, "=====");
-                       SLOG(LOG_DEBUG, TAG_TTSD, "  ");
-               }
                break;
 
        case MM_MESSAGE_END_OF_STREAM:
                {
                        SLOG(LOG_DEBUG, TAG_TTSD, "===== END OF STREAM CALLBACK");
-                       remove(user_data->filename);
+
+                       if (-1 == remove(user_data->filename)) {
+                               SLOG(LOG_WARN, TAG_TTSD, "[PLAYER WARNING] Fail to remove temp file", user_data->filename); 
+                       }
 
                        /* Check uid */
                        player_s* current;
@@ -756,20 +744,34 @@ static int msg_callback(int message, void *data, void *user_param)
                                return -1;
                        }
 
-                       if (NULL != user_data) 
-                               g_free(user_data);
+                       g_free(user_data);
 
                        int pid = ttsd_data_get_pid(uid);
 
                        /* send utterence finish signal */
                        if (TTSP_RESULT_EVENT_FINISH == current->event) {
-                               if (0 == ttsdc_send_utt_finish_signal(pid, uid, utt_id))
+                               if (0 == ttsdc_send_utt_finish_message(pid, uid, utt_id))
                                        SLOG(LOG_DEBUG, TAG_TTSD, "[Send SUCCESS] Send Utterance Completed Signal : pid(%d), uid(%d), uttid(%d)", pid, uid, utt_id);
                                else 
                                        SLOG(LOG_ERROR, TAG_TTSD, "[Send ERROR] Fail to send Utterance Completed Signal : pid(%d), uid(%d), uttid(%d)", pid, uid, utt_id);
                        }
 
-                       ttsd_send_start_next_play(uid);
+                       /* for sync problem */
+                       MMPlayerStateType player_state;
+                       mm_player_get_state(current->player_handle, &player_state);
+                       
+                       if (MM_PLAYER_STATE_PAUSED == player_state) {
+                               g_pause_info = true;    /* The current state of player is 'Paused' */
+                               g_paused_uid = uid;     /* The current uid when the current state player is 'Paused' */
+                       } else {
+                               /* play state */
+                               int* uid_data = (int*) g_malloc0(sizeof(int));
+                               *uid_data = uid;
+
+                               SLOG(LOG_DEBUG, TAG_TTSD, "[PLAYER] uid = %d", *uid_data);
+
+                               ecore_timer_add(0, __player_next_play, (void*)uid_data);
+                       }
 
                        SLOG(LOG_DEBUG, TAG_TTSD, "=====");
                        SLOG(LOG_DEBUG, TAG_TTSD, "  ");
@@ -779,6 +781,22 @@ static int msg_callback(int message, void *data, void *user_param)
        case MM_MESSAGE_STATE_CHANGED:
                break;
 
+       case MM_MESSAGE_STATE_INTERRUPTED:
+               if (MM_PLAYER_STATE_PAUSED == msg->state.current) {
+
+                       SLOG(LOG_DEBUG, TAG_TTSD, "===== INTERRUPTED CALLBACK");
+
+                       ttsd_data_set_client_state(uid, APP_STATE_PAUSED);
+
+                       int pid = ttsd_data_get_pid(uid);
+                       /* send message to client about changing state */
+                       ttsdc_send_set_state_message (pid, uid, APP_STATE_PAUSED);
+
+                       SLOG(LOG_DEBUG, TAG_TTSD, "=====");
+                       SLOG(LOG_DEBUG, TAG_TTSD, "  ");
+               }
+               break;
+
        default:
                break;
        }
@@ -814,18 +832,18 @@ player_s* __player_get_item(int uid)
 int __save_file(const int uid, const int index, const sound_data_s data, char** filename)
 {
        char postfix[5];
-       memset(postfix, 0, 5);
+       memset(postfix, '\0', 5);
 
        switch (data.audio_type) {
        case TTSP_AUDIO_TYPE_RAW:
        case TTSP_AUDIO_TYPE_WAV:
-               strncpy(postfix, "wav", strlen("wav"));
+               strcpy(postfix, "wav");
                break;
        case TTSP_AUDIO_TYPE_MP3:
-               strncpy(postfix, "mp3", strlen("mp3"));
+               strcpy(postfix, "mp3");
                break;
        case TTSP_AUDIO_TYPE_AMR:
-               strncpy(postfix, "amr", strlen("amr"));
+               strcpy(postfix, "amr");
                break;
        default:
                SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] Audio type(%d) is NOT valid", data.audio_type); 
@@ -834,15 +852,27 @@ int __save_file(const int uid, const int index, const sound_data_s data, char**
 
        /* make filename to save */
        char* temp;
-       temp = *filename;
+       temp = (char*)g_malloc0(sizeof(char) * FILE_PATH_SIZE);
+       if (NULL == temp) {
+               SLOG(LOG_ERROR, TAG_TTSD, "[Player Error] make buf is failed");
+               return -1;
+       }
+
+       int ret = snprintf(temp, FILE_PATH_SIZE, "%s/ttstemp%d_%d.%s", TEMP_FILE_PATH, uid, index, postfix);
+
+       if (0 >= ret) {
+               if (NULL != temp)
+                       g_free(temp);
+               return -1;
+       }
 
-       snprintf(temp, FILE_PATH_SIZE, "%s/ttstemp%d_%d.%s", TEMP_FILE_PATH, uid, index, postfix );
-       
        FILE* fp;
        fp = fopen(temp, "wb");
 
        if (fp == NULL) {
                SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] temp file open error");
+               if (NULL != temp)
+                       g_free(temp);
                return -1;
        }
 
@@ -850,27 +880,37 @@ int __save_file(const int uid, const int index, const sound_data_s data, char**
                WavHeader header;
                if (0 != __init_wave_header(&header, data.data_size, data.rate, data.channels)) {
                        fclose(fp);
+                       if (NULL != temp)
+                               g_free(temp);
                        return -1;
                }
 
                if (0 >= fwrite(&header, sizeof(WavHeader), 1, fp)) {
                        SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] fail to write wav header to file");
                        fclose(fp);
+                       if (NULL != temp)
+                               g_free(temp);
                        return -1;
                }
        }
 
        int size = fwrite(data.data, data.data_size, 1,  fp);
        if (size <= 0) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] Fail to write date");
-               fclose(fp);
-               return -1;
+               size = fwrite("0000000000", DEFAULT_FILE_SIZE, 1,  fp);
+               if (size <= 0) {
+                       SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] Fail to write date");
+                       fclose(fp);
+                       if (NULL != temp)
+                               g_free(temp);
+                       return -1;
+               }       
        } 
 
        fclose(fp);
+       *filename = temp;
        
        SLOG(LOG_DEBUG, TAG_TTSD, " ");
-       SLOG(LOG_DEBUG, TAG_TTSD, "Filepath : %s ", temp);
+       SLOG(LOG_DEBUG, TAG_TTSD, "Filepath : %s ", *filename);
        SLOG(LOG_DEBUG, TAG_TTSD, "Header : Data size(%d), Sample rate(%d), Channel(%d) ", data.data_size, data.rate, data.channels);
 
        return 0;
@@ -878,25 +918,34 @@ int __save_file(const int uid, const int index, const sound_data_s data, char**
 
 int __init_wave_header (WavHeader* hdr, size_t nsamples, size_t sampling_rate, int channel)
 {
-       if (hdr == NULL || nsamples <= 0 || sampling_rate <= 0 || channel <= 0) {
+       if (hdr == NULL || sampling_rate <= 0 || channel <= 0) {
                SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] __init_wave_header : input parameter invalid");
+               SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] hdr : %p", hdr);
+               SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] nsample : %d", nsamples);
+               SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] sampling_rate : %", sampling_rate);
+               SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] channel : %", channel);
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
-       size_t bytesize = nsamples;
+       size_t bytesize = DEFAULT_FILE_SIZE;
 
-       strncpy(hdr->riff, "RIFF", 4);
+       if (0 < nsamples) {
+               bytesize = nsamples;    
+       } 
+
+       /* NOT include \0(NULL) */
+       strncpy(hdr->riff, "RIFF", 4);  
        hdr->file_size = (int)(bytesize  + 36);
        strncpy(hdr->wave, "WAVE", 4);
-       strncpy(hdr->fmt, "fmt ", 4);
+       strncpy(hdr->fmt, "fmt ", 4);   /* fmt + space */
        hdr->header_size = 16;
-       hdr->sample_format = 1; /* WAVE_FORMAT_PCM */
+       hdr->sample_format = 1;         /* WAVE_FORMAT_PCM */
        hdr->n_channels = channel;
        hdr->sample_rate = (int)(sampling_rate);
        hdr->bytes_per_second = (int)sampling_rate * sizeof(short);
        hdr->block_align =  sizeof(short);
        hdr->bits_per_sample = sizeof(short)*8;
-       strncpy(hdr->data, "data", 4);
+       strncpy(hdr->data, "data", 4);  
        hdr->data_size = (int)bytesize;
 
        return 0;
@@ -912,15 +961,16 @@ int __set_and_start(player_s* player)
        }
 
        g_index++;
-       if (65534 <= g_index)   {
+       if (10000 <= g_index)   {
                g_index = 1;
        }
 
+       int ret;
+
        /* make sound file for mmplayer */
        char* sound_file = NULL;
-       sound_file = (char*) g_malloc0( sizeof(char) * FILE_PATH_SIZE );
-
-       if (0 != __save_file(player->uid, g_index, wdata, &sound_file)) {
+       ret = __save_file(player->uid, g_index, wdata, &sound_file);
+       if (0 != ret || NULL == sound_file) {
                SLOG(LOG_ERROR, TAG_TTSD, "[Player ERROR] fail to make sound file");
                return -1;
        }
@@ -936,7 +986,6 @@ int __set_and_start(player_s* player)
                user_data->uid, user_data->utt_id, user_data->filename, user_data->event);
        SLOG(LOG_DEBUG, TAG_TTSD, " ");
 
-       int ret;
        
        /* set callback func */
        ret = mm_player_set_message_callback(player->player_handle, msg_callback, (void*)user_data);
@@ -954,7 +1003,7 @@ int __set_and_start(player_s* player)
        }
        
        ret = mm_player_set_attribute(player->player_handle, &err_attr_name,
-               "profile_uri", sound_file , strlen( sound_file ) + 1,
+               "profile_uri", sound_file , strlen(sound_file) + 1,
                "sound_volume_type", MM_SOUND_VOLUME_TYPE_MEDIA,
                "sound_route", MM_AUDIOROUTE_PLAYBACK_NORMAL,
                NULL );
@@ -981,8 +1030,30 @@ int __set_and_start(player_s* player)
                return -3;
        }
 
-       if( NULL != sound_file )        g_free(sound_file);
-       if( NULL != wdata.data )        g_free(wdata.data);
+       /* If wdata's event is 'start', current wdata is first data of engine for synthesis. 
+        * If wdata's event is 'finish', player should check previous event to know whether this wdata is first or not.
+        * When previous wdata's event is 'finish' and current wdata's event is 'finish', 
+        * the player should send utt started event. 
+        */
+       if (TTSP_RESULT_EVENT_START == wdata.event ||
+           (TTSP_RESULT_EVENT_FINISH == player->event && TTSP_RESULT_EVENT_FINISH == wdata.event)) {
+               int pid;
+               pid = ttsd_data_get_pid(player->uid);
+
+               /* send utterance start message */
+               if (0 != ttsdc_send_utt_start_message(pid, player->uid, wdata.utt_id)) {
+                       SLOG(LOG_ERROR, TAG_TTSD, "[Send ERROR] Fail to send Utterance Start Signal : pid(%d), uid(%d), uttid(%d)", pid, player->uid, wdata.utt_id);
+               }
+       } else {
+               SLOG(LOG_DEBUG, TAG_TTSD, "[PLAYER] Don't need to send Utterance Start Signal");
+       }
+
+       g_playing_info = player;
+
+       if (NULL != sound_file) 
+               g_free(sound_file);
+       if (NULL != wdata.data) 
+               g_free(wdata.data);
 
        return 0;
 }
old mode 100644 (file)
new mode 100755 (executable)
index 66af293..9a37340
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved 
+*  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
old mode 100644 (file)
new mode 100755 (executable)
index 5de3618..f5045a8
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved 
+*  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
@@ -11,7 +11,7 @@
 *  limitations under the License.
 */
 
-
+#include <Ecore.h>
 #include "ttsd_main.h"
 #include "ttsd_player.h"
 #include "ttsd_data.h"
@@ -30,66 +30,68 @@ typedef struct {
 } utterance_t;
 
 /* If current engine exist */
-static bool g_is_engine;
+static bool    g_is_engine;
 
 /* If engine is running */
-static bool g_is_synthesizing;
+static bool    g_is_synthesizing;
+
+/* If the daemon get the result */
+static bool    g_is_next_synthesis = false;
+
+/* Function definitions */
+int __server_next_synthesis(int uid);
+
 
 int __server_set_is_synthesizing(bool flag)
 {
        g_is_synthesizing = flag;
+
        return 0;
 }
 
-bool __server_get_current_synthesis()
+bool __server_get_is_synthesizing()
 {
        return g_is_synthesizing;
 }
 
-int __server_send_error(int uid, int utt_id, int error_code)
+int __server_set_is_next_synthesis(bool flag)
 {
-       int pid = ttsd_data_get_pid(uid);
+       g_is_next_synthesis = flag;
 
-       /* send error */
-       if ( 0 != ttsdc_send_error_signal(pid, uid, utt_id, error_code)) {
-               ttsd_data_delete_client(uid);                   
-       } 
-       
        return 0;
 }
 
-int __server_interrupt_client(int org_uid)
+bool __server_get_is_next_synthesis()
 {
-       int pid = ttsd_data_get_pid(org_uid);
-
-       /* pause player */
-       if (0 != ttsd_player_pause(org_uid)) {
-               SLOG(LOG_WARN, TAG_TTSD, "[Server ERROR] fail to ttsd_player_pause() : uid (%d)\n", org_uid);
-       } 
-
-       /* send message to client about changing state */
-       ttsdc_send_interrupt_signal (pid, org_uid, TTSD_INTERRUPTED_PAUSED);
+       return g_is_next_synthesis;
+}
 
-       /* change state */
-       ttsd_data_set_client_state(org_uid, APP_STATE_PAUSED);
+int __server_send_error(int uid, int utt_id, int error_code)
+{
+       int pid = ttsd_data_get_pid(uid);
 
+       /* send error */
+       if ( 0 != ttsdc_send_error_message(pid, uid, utt_id, error_code)) {
+               ttsd_data_delete_client(uid);                   
+       } 
+       
        return 0;
 }
 
-int __server_start_synthesis(int uid)
+int __server_start_synthesis(int uid, int mode)
 {
        int result = 0;
 
        /* check if tts-engine is running */
-       if (true == __server_get_current_synthesis()) {
-               SLOG(LOG_DEBUG, TAG_TTSD, "[Server] TTS-engine is running \n");
+       if (true == __server_get_is_synthesizing()) {
+               SLOG(LOG_DEBUG, TAG_TTSD, "[Server] TTS-engine is running ");
        } else {
                speak_data_s sdata;
                if (0 == ttsd_data_get_speak_data(uid, &sdata)) {
                        utterance_t* utt = (utterance_t*)g_malloc0(sizeof(utterance_t));
 
                        if (NULL == utt) {
-                               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Out of memory : utterance \n");
+                               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Out of memory : utterance ");
                                return TTSD_ERROR_OUT_OF_MEMORY;
                        }
 
@@ -104,7 +106,7 @@ int __server_start_synthesis(int uid)
 
                        __server_set_is_synthesizing(true);
                        int ret = 0;
-                       ret = ttsd_engine_start_synthesis( sdata.lang, sdata.vctype, sdata.text, sdata.speed, (void*)utt);
+                       ret = ttsd_engine_start_synthesis(sdata.lang, sdata.vctype, sdata.text, sdata.speed, (void*)utt);
                        if (0 != ret) {
                                SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] * FAIL to start SYNTHESIS !!!! * ");
 
@@ -113,6 +115,14 @@ int __server_start_synthesis(int uid)
                                result = TTSD_ERROR_OPERATION_FAILED;
 
                                g_free(utt);
+
+                               if (2 == mode) {
+                                       __server_send_error(uid, sdata.utt_id, TTSD_ERROR_OPERATION_FAILED);
+                                       ttsd_server_stop(uid);
+
+                                       int pid = ttsd_data_get_pid(uid);
+                                       ttsdc_send_set_state_message(pid, uid, APP_STATE_READY);
+                               }
                        } else {
                                SLOG(LOG_DEBUG, TAG_TTSD, "[Server] SUCCESS to start synthesis");
                        }
@@ -142,16 +152,17 @@ int __server_play_internal(int uid, app_state_e state)
 
                /* resume player and start speech synthesis */
                if (0 != ttsd_player_resume(uid)) {
-                       SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] fail to ttsd_player_resume() \n");
+                       SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] fail to ttsd_player_resume()");
                } 
                
-               ret = __server_start_synthesis(uid);
+               /* mode 1 for play */
+               ret = __server_start_synthesis(uid, 1);
 
        } else if(APP_STATE_READY == state) {
-
                SLOG(LOG_DEBUG, TAG_TTSD, "[Server] uid(%d) is 'Ready' state : Next step is start synthesis ", uid);
-
-               ret = __server_start_synthesis(uid);
+               
+               /* mode 1 for play */
+               ret = __server_start_synthesis(uid, 1);
        } else {
                /* NO this case */
        }
@@ -161,7 +172,7 @@ int __server_play_internal(int uid, app_state_e state)
 
 int __server_next_synthesis(int uid)
 {
-       SLOG(LOG_DEBUG, TAG_TTSD, "===== START NEXT SYNTHESIS & PLAY");
+       SLOG(LOG_DEBUG, TAG_TTSD, "===== NEXT SYNTHESIS & PLAY START");
 
        /* get current playing client */
        int current_uid = ttsd_data_get_current_playing();
@@ -173,8 +184,8 @@ int __server_next_synthesis(int uid)
                return 0;
        }
 
-       if (true == __server_get_current_synthesis()) {
-               SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] Engine has already been running. \n");
+       if (true == __server_get_is_synthesizing()) {
+               SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] Engine has already been running. ");
                SLOG(LOG_DEBUG, TAG_TTSD, "=====");
                SLOG(LOG_DEBUG, TAG_TTSD, "  ");
                return 0;
@@ -187,7 +198,7 @@ int __server_next_synthesis(int uid)
                utterance_t* utt = (utterance_t*)g_malloc0(sizeof(utterance_t));
 
                if (NULL == utt) {
-                       SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] fail to allocate memory : utterance \n");
+                       SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] fail to allocate memory : utterance ");
 
                        __server_send_error(current_uid, sdata.utt_id, TTSD_ERROR_OUT_OF_MEMORY);
                        return TTSD_ERROR_OUT_OF_MEMORY;
@@ -214,20 +225,29 @@ int __server_next_synthesis(int uid)
                        __server_send_error(current_uid, sdata.utt_id, TTSD_ERROR_OPERATION_FAILED);
 
                        g_free(utt);
+
+                       ttsd_server_stop(current_uid);
+
+                       int pid = ttsd_data_get_pid(current_uid);
+                       ttsdc_send_set_state_message(pid, current_uid, APP_STATE_READY);
                }
 
                if(sdata.text != NULL)  
                        g_free(sdata.text);
+       } else {
+               SLOG(LOG_DEBUG, TAG_TTSD, "[Server] --------------------");
+               SLOG(LOG_DEBUG, TAG_TTSD, "[Server] Text queue is empty.");
+               SLOG(LOG_DEBUG, TAG_TTSD, "[Server] --------------------");
        }
 
        if (0 != ttsd_player_play(current_uid)) {
-               SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] __synthesis_result_callback : fail ttsd_player_play() \n");
+               SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] __server_next_synthesis : fail ttsd_player_play() ");
        } else {
                /* success playing */
                SLOG(LOG_DEBUG, TAG_TTSD, "[Server] Success to start player");
        }
 
-       SLOG(LOG_DEBUG, TAG_TTSD, "=====");
+       SLOG(LOG_DEBUG, TAG_TTSD, "===== NEXT SYNTHESIS & PLAY END");
        SLOG(LOG_DEBUG, TAG_TTSD, "  ");
 
        return 0;
@@ -242,16 +262,16 @@ int __player_result_callback(player_event_e event, int uid, int utt_id)
        switch(event) {
        case PLAYER_EMPTY_SOUND_QUEUE:
                /* check whether synthesis is running */
-               if (false == __server_get_current_synthesis()) {
+               if (false == __server_get_is_synthesizing()) {
                        /* check text queue is empty */
                        if (0 == ttsd_data_get_speak_data_size(uid) && 0 == ttsd_data_get_sound_data_size(uid)) {
-                               SLOG(LOG_DEBUG, TAG_TTSD, "[SERVER Callback] all play completed \n");
+                               SLOG(LOG_DEBUG, TAG_TTSD, "[SERVER Callback] all play completed ");
                        }
                } 
                break;
 
        case PLAYER_ERROR:
-               SLOG(LOG_ERROR, TAG_TTSD, "[SERVER Callback ERROR] callback : player error \n");
+               SLOG(LOG_ERROR, TAG_TTSD, "[SERVER Callback ERROR] callback : player error ");
 
                __server_send_error(uid, utt_id, TTSD_ERROR_OPERATION_FAILED);
                break;
@@ -263,23 +283,40 @@ int __player_result_callback(player_event_e event, int uid, int utt_id)
        return 0;
 }
 
+Eina_Bool __start_next_synthesis(void *data)
+{
+       /* get current play */
+       int uid = ttsd_data_is_current_playing();
+
+       if (uid < 0) {
+               return EINA_FALSE;
+       }
+
+       if (true == __server_get_is_next_synthesis()) {
+               __server_set_is_next_synthesis(false);
+               __server_next_synthesis(uid);
+       }
+
+       return EINA_TRUE;       
+}
+
 int __synthesis_result_callback(ttsp_result_event_e event, const void* data, unsigned int data_size, void *user_data)
 {
-       SLOG(LOG_DEBUG, TAG_TTSD, "===== SYNTHESIS RESULT CALLBACK");
+       SLOG(LOG_DEBUG, TAG_TTSD, "===== SYNTHESIS RESULT CALLBACK START");
 
        utterance_t* utt_get_param;
        utt_get_param = (utterance_t*)user_data;
 
-       int uid = utt_get_param->uid;
-       int uttid = utt_get_param->uttid;
-
        if (NULL == utt_get_param) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[SERVER ERROR] User data is NULL \n" );
+               SLOG(LOG_ERROR, TAG_TTSD, "[SERVER ERROR] User data is NULL " );
                SLOG(LOG_DEBUG, TAG_TTSD, "=====");
                SLOG(LOG_DEBUG, TAG_TTSD, "  ");
                return -1;
        }
 
+       int uid = utt_get_param->uid;
+       int uttid = utt_get_param->uttid;
+
        /* Synthesis is success */
        if (TTSP_RESULT_EVENT_START == event || TTSP_RESULT_EVENT_CONTINUE == event || TTSP_RESULT_EVENT_FINISH == event) {
                
@@ -288,15 +325,14 @@ int __synthesis_result_callback(ttsp_result_event_e event, const void* data, uns
                if (TTSP_RESULT_EVENT_FINISH == event)          SLOG(LOG_DEBUG, TAG_TTSD, "[SERVER] Event : TTSP_RESULT_EVENT_FINISH");
 
                if (false == ttsd_data_is_uttid_valid(uid, uttid)) {
-                       SLOG(LOG_ERROR, TAG_TTSD, "[SERVER ERROR] uttid is NOT valid !!!! \n" );
+                       SLOG(LOG_ERROR, TAG_TTSD, "[SERVER ERROR] uttid is NOT valid !!!! - uid(%d), uttid(%d)", uid, uttid);
                        SLOG(LOG_DEBUG, TAG_TTSD, "=====");
                        SLOG(LOG_DEBUG, TAG_TTSD, "  ");
 
                        return 0;
                }
 
-
-               SLOG(LOG_DEBUG, TAG_TTSD, "[SERVER] Result Info : uid(%d), utt(%d), data(%p), data size(%d) \n", 
+               SLOG(LOG_DEBUG, TAG_TTSD, "[SERVER] Result Info : uid(%d), utt(%d), data(%p), data size(%d) ", 
                        uid, uttid, data, data_size);
 
                /* add wav data */
@@ -324,37 +360,25 @@ int __synthesis_result_callback(ttsp_result_event_e event, const void* data, uns
                temp_data.channels = channels;
                
                if (0 != ttsd_data_add_sound_data(uid, temp_data)) {
-                       SLOG(LOG_ERROR, TAG_TTSD, "[SERVER ERROR] Fail to add sound data : uid(%d)\n", utt_get_param->uid);
+                       SLOG(LOG_ERROR, TAG_TTSD, "[SERVER ERROR] Fail to add sound data : uid(%d)", utt_get_param->uid);
                }
 
                if (event == TTSP_RESULT_EVENT_FINISH) {
                        __server_set_is_synthesizing(false);
-                       
-                       if (0 != ttsd_send_start_next_synthesis(uid)) {
-                               /* critical error */
-                               SLOG(LOG_ERROR, TAG_TTSD, "[SERVER ERROR] IPC ERROR FOR NEXT SYNTHESIS \n");
-                       }
+                       __server_set_is_next_synthesis(true);
                }
        } 
        
        else if (event == TTSP_RESULT_EVENT_CANCEL) {
                SLOG(LOG_DEBUG, TAG_TTSD, "[SERVER] Event : TTSP_RESULT_EVENT_CANCEL");
                __server_set_is_synthesizing(false);
-
-               if (0 != ttsd_send_start_next_synthesis(uid)) {
-                       /* critical error */
-                       SLOG(LOG_ERROR, TAG_TTSD, "[SERVER ERROR] IPC ERROR FOR NEXT SYNTHESIS \n");
-               }
+               __server_set_is_next_synthesis(true);
        } 
        
        else {
-               SLOG(LOG_DEBUG, TAG_TTSD, "[SERVER] Event : TTSP_RESULT_EVENT_CANCEL");
-               
+               SLOG(LOG_DEBUG, TAG_TTSD, "[SERVER] Event ERROR");
                __server_set_is_synthesizing(false);
-               if (0 != ttsd_send_start_next_synthesis(uid)) {
-                       /* critical error */
-                       SLOG(LOG_ERROR, TAG_TTSD, "[SERVER ERROR] IPC ERROR FOR NEXT SYNTHESIS \n");
-               }
+               __server_set_is_next_synthesis(true);
        } 
 
        if (TTSP_RESULT_EVENT_FINISH == event || TTSP_RESULT_EVENT_CANCEL == event || TTSP_RESULT_EVENT_FAIL == event) {
@@ -362,7 +386,7 @@ int __synthesis_result_callback(ttsp_result_event_e event, const void* data, uns
                        free(utt_get_param);
        }
 
-       SLOG(LOG_DEBUG, TAG_TTSD, "=====");
+       SLOG(LOG_DEBUG, TAG_TTSD, "===== SYNTHESIS RESULT CALLBACK END");
        SLOG(LOG_DEBUG, TAG_TTSD, "  ");
 
        return 0;
@@ -374,29 +398,61 @@ int __synthesis_result_callback(ttsp_result_event_e event, const void* data, uns
 
 int ttsd_initialize()
 {
+       if (ttsd_config_initialize()) {
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server WARNING] Fail to initialize config.");
+       }
+
        /* player init */
        if (ttsd_player_init(__player_result_callback)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to initialize player init \n");
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to initialize player init.");
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
        /* Engine Agent initialize */
        if (0 != ttsd_engine_agent_init(__synthesis_result_callback)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to engine agent initialize \n");
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to engine agent initialize.");
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
        /* set current engine */
        if (0 != ttsd_engine_agent_initialize_current_engine()) {
-               SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] No Engine !!! \n" );
+               SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] No Engine !!!" );
                g_is_engine = false;
        } else 
                g_is_engine = true;
 
+
        return TTSD_ERROR_NONE;
 }
 
 
+bool __get_client_for_clean_up(int pid, int uid, app_state_e state, void* user_data)
+{
+       int result = 1;
+
+       result = ttsdc_send_hello(pid, uid);
+
+       if (0 == result) {
+               SLOG(LOG_DEBUG, TAG_TTSD, "[Server] uid(%d) should be removed.", uid); 
+               ttsd_server_finalize(uid);
+       } else if (-1 == result) {
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Hello result has error"); 
+       }
+
+       return true;
+}
+
+
+Eina_Bool ttsd_cleanup_client(void *data)
+{
+       SLOG(LOG_DEBUG, TAG_TTSD, "===== CLEAN UP CLIENT START");
+       ttsd_data_foreach_clients(__get_client_for_clean_up, NULL);
+       SLOG(LOG_DEBUG, TAG_TTSD, "=====");
+       SLOG(LOG_DEBUG, TAG_TTSD, "  ");
+
+       return EINA_TRUE;
+}
+
 /*
 * TTS Server Functions for Client
 */
@@ -405,7 +461,7 @@ int ttsd_server_initialize(int pid, int uid)
 {
        if (false == g_is_engine) {
                if (0 != ttsd_engine_agent_initialize_current_engine()) {
-                       SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] No Engine !!! \n" );
+                       SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] No Engine !!! " );
                        g_is_engine = false;
 
                        return TTSD_ERROR_ENGINE_NOT_FOUND;
@@ -415,36 +471,42 @@ int ttsd_server_initialize(int pid, int uid)
        }
 
        if (-1 != ttsd_data_is_client(uid)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Uid has already been registered \n");
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Uid has already been registered ");
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
        if (0 == ttsd_data_get_client_count()) {
                if (0 != ttsd_engine_agent_load_current_engine()) {
-                       SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to load current engine \n");
+                       SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to load current engine ");
                        return TTSD_ERROR_OPERATION_FAILED;
                }
        }
 
        if (0 != ttsd_data_new_client(pid, uid)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to add client info \n");
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to add client info ");
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
        if (0 != ttsd_player_create_instance(uid)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to create player \n");
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to create player ");
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
        return TTSD_ERROR_NONE;
 }
 
+static Eina_Bool __quit_ecore_loop(void *data)
+{
+       ecore_main_loop_quit();
+       SLOG(LOG_DEBUG, TAG_TTSD, "[Server] quit ecore main loop");
+       return EINA_FALSE;
+}
 
 int ttsd_server_finalize(int uid)
 {
        app_state_e state;
        if (0 > ttsd_data_get_client_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] ttsd_server_finalize : uid is not valid  \n");
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] ttsd_server_finalize : uid is not valid  ");
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
@@ -456,11 +518,13 @@ int ttsd_server_finalize(int uid)
 
        /* unload engine, if ref count of client is 0 */
        if (0 == ttsd_data_get_client_count()) {
-               if (0 != ttsd_engine_agent_unload_current_engine()) {
-                       SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] fail to unload current engine \n");
+               if (0 != ttsd_engine_agent_release()) {
+                       SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] fail to release engine agent");
                } else {
-                       SLOG(LOG_DEBUG, TAG_TTSD, "[Server SUCCESS] unload current engine \n");
+                       SLOG(LOG_DEBUG, TAG_TTSD, "[Server SUCCESS] release engine agent");
                }
+
+               ecore_timer_add(0, __quit_ecore_loop, NULL);
        }
 
        return TTSD_ERROR_NONE;
@@ -470,7 +534,7 @@ int ttsd_server_add_queue(int uid, const char* text, const char* lang, int voice
 {
        app_state_e state;
        if (0 > ttsd_data_get_client_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] ttsd_server_add_queue : uid is not valid  \n");
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] ttsd_server_add_queue : uid is not valid  ");
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
@@ -478,7 +542,7 @@ int ttsd_server_add_queue(int uid, const char* text, const char* lang, int voice
        char* temp_lang = NULL;
        ttsp_voice_type_e temp_type;
        if (true != ttsd_engine_select_valid_voice((const char*)lang, (const ttsp_voice_type_e)voice_type, &temp_lang, &temp_type)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to select valid voice \n");
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to select valid voice ");
                return TTSD_ERROR_INVALID_VOICE;
        } else {                
                if (NULL == temp_lang)
@@ -497,7 +561,7 @@ int ttsd_server_add_queue(int uid, const char* text, const char* lang, int voice
 
        /* if state is APP_STATE_READY , APP_STATE_PAUSED , only need to add speak data to queue*/
        if (0 != ttsd_data_add_speak_data(uid, data)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] ttsd_server_add_queue : Current state of uid is not 'ready' \n");
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] ttsd_server_add_queue : Current state of uid is not 'ready' ");
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
@@ -505,13 +569,14 @@ int ttsd_server_add_queue(int uid, const char* text, const char* lang, int voice
                /* check if engine use network */
                if (ttsd_engine_agent_need_network()) {
                        if (false == ttsd_network_is_connected()) {
-                               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Disconnect network. Current engine needs network.\n");
+                               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Disconnect network. Current engine needs network.");
                                return TTSD_ERROR_OPERATION_FAILED;
                        }
                }
 
-               if (0 != __server_start_synthesis(uid)) {
-                       SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] fail to schedule synthesis : uid(%d)\n", uid);
+               /* mode 2 for add text */
+               if (0 != __server_start_synthesis(uid, 2)) {
+                       SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] fail to schedule synthesis : uid(%d)", uid);
                        return TTSD_ERROR_OPERATION_FAILED;
                }
        }
@@ -519,24 +584,37 @@ int ttsd_server_add_queue(int uid, const char* text, const char* lang, int voice
        return TTSD_ERROR_NONE;
 }
 
+Eina_Bool __send_interrupt_client(void *data)
+{
+       int* uid = (int*)data;
+       
+       if (NULL != uid) {
+               int pid = ttsd_data_get_pid(*uid);
+               /* send message to client about changing state */
+               ttsdc_send_set_state_message (pid, *uid, APP_STATE_PAUSED);
+               free(uid);
+       }
+       return EINA_FALSE;
+}
+
 int ttsd_server_play(int uid)
 {
        app_state_e state;
        if (0 > ttsd_data_get_client_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] uid(%d) is NOT valid  \n", uid);
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] uid(%d) is NOT valid  ", uid);
                return TTSD_ERROR_INVALID_PARAMETER;
        }
        
        if (APP_STATE_PLAYING == state) {
-               SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] Current state(%d) is 'play' \n", uid);
+               SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] Current state(%d) is 'play' ", uid);
                return TTSD_ERROR_NONE;
        }
 
        /* check if engine use network */
        if (ttsd_engine_agent_need_network()) {
                if (false == ttsd_network_is_connected()) {
-                       SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Disconnect network. Current engine needs network service!!!.\n");
-                       return TTSD_ERROR_OPERATION_FAILED;
+                       SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Disconnect network. Current engine needs network service!!!.");
+                       return TTSD_ERROR_OUT_OF_NETWORK;
                }
        }
 
@@ -544,21 +622,34 @@ int ttsd_server_play(int uid)
 
        if (uid != current_uid && -1 != current_uid) {
                /* Send interrupt message */
-               SLOG(LOG_DEBUG, TAG_TTSD, "[Server] Old uid(%d) will be interrupted into 'Pause' state \n", current_uid);
-               __server_interrupt_client(current_uid);
+               SLOG(LOG_DEBUG, TAG_TTSD, "[Server] Old uid(%d) will be interrupted into 'Pause' state ", current_uid);
+
+               /* pause player */
+               if (0 != ttsd_player_pause(current_uid)) {
+                       SLOG(LOG_WARN, TAG_TTSD, "[Server ERROR] fail to ttsd_player_pause() : uid (%d)", current_uid);
+               } 
+
+               /* change state */
+               ttsd_data_set_client_state(current_uid, APP_STATE_PAUSED);
+
+               int* temp_uid = (int*)malloc(sizeof(int));
+               *temp_uid = current_uid;
+               ecore_timer_add(0, __send_interrupt_client, temp_uid);
        }
        
        /* Change current play */
        if (0 != ttsd_data_set_client_state(uid, APP_STATE_PLAYING)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Current play has already existed \n");
-               return 0;
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to set state : uid(%d)", uid);
+               return TTSD_ERROR_OPERATION_FAILED;
        }
 
        if (0 != __server_play_internal(uid, state)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to start synthesis : uid(%d)\n", uid);
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to start synthesis : uid(%d)", uid);
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
+       ecore_timer_add(0, __start_next_synthesis, NULL);
+
        return TTSD_ERROR_NONE;
 }
 
@@ -567,18 +658,21 @@ int ttsd_server_stop(int uid)
 {
        app_state_e state;
        if (0 > ttsd_data_get_client_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] uid is not valid  \n");
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] uid is not valid  ");
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
+       /* Reset all data */
+       ttsd_data_clear_data(uid);
+
        if (APP_STATE_PLAYING == state || APP_STATE_PAUSED == state) {
                ttsd_data_set_client_state(uid, APP_STATE_READY);
 
                if (0 != ttsd_player_stop(uid)) 
-                       SLOG(LOG_WARN, TAG_TTSD, "[Server] Fail to ttsd_player_stop()\n");
+                       SLOG(LOG_WARN, TAG_TTSD, "[Server] Fail to ttsd_player_stop()");
 
-               if (true == __server_get_current_synthesis()) {
-                       SLOG(LOG_DEBUG, TAG_TTSD, "[Server] TTS-engine is running \n");
+               if (true == __server_get_is_synthesizing()) {
+                       SLOG(LOG_DEBUG, TAG_TTSD, "[Server] TTS-engine is running ");
 
                        int ret = 0;
                        ret = ttsd_engine_cancel_synthesis();
@@ -587,11 +681,8 @@ int ttsd_server_stop(int uid)
 
                        __server_set_is_synthesizing(false);
                } 
-
-               /* Reset all data */
-               ttsd_data_clear_data(uid);
        } else {
-               SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] Current state is 'ready' \n");
+               SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] Current state is 'ready' ");
        }
 
        return TTSD_ERROR_NONE;
@@ -601,19 +692,19 @@ int ttsd_server_pause(int uid, int* utt_id)
 {
        app_state_e state;
        if (0 > ttsd_data_get_client_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] ttsd_server_pause : uid is not valid  \n");
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] ttsd_server_pause : uid is not valid  ");
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
        if (APP_STATE_PLAYING != state) {
-               SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] Current state is not 'play' \n");
+               SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] Current state is not 'play' ");
                return TTSD_ERROR_INVALID_STATE;
        }
 
        int ret = 0;
        ret = ttsd_player_pause(uid);
        if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] fail player_pause() : ret(%d)\n", ret);
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] fail player_pause() : ret(%d)", ret);
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
@@ -626,17 +717,17 @@ int ttsd_server_get_support_voices(int uid, GList** voice_list)
 {
        app_state_e state;
        if (0 > ttsd_data_get_client_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] uid is not valid  \n");
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] uid is not valid  ");
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
        /* get voice list*/
        if (0 != ttsd_engine_get_voice_list(voice_list)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail ttsd_server_get_support_voices() \n");
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail ttsd_server_get_support_voices() ");
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
-       SLOG(LOG_DEBUG, TAG_TTSD, "[Server SUCCESS] Get supported voices \n");
+       SLOG(LOG_DEBUG, TAG_TTSD, "[Server SUCCESS] Get supported voices ");
 
        return TTSD_ERROR_NONE;
 }
@@ -645,18 +736,18 @@ int ttsd_server_get_current_voice(int uid, char** language, int* voice_type)
 {
        app_state_e state;
        if (0 > ttsd_data_get_client_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] ttsd_server_get_current_voice : uid is not valid  \n");
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] ttsd_server_get_current_voice : uid is not valid  ");
                return TTSD_ERROR_INVALID_PARAMETER;
        }               
 
        /* get current voice */
        int ret = ttsd_engine_get_default_voice(language, (ttsp_voice_type_e*)voice_type);
        if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] fail ttsd_server_get_support_voices() \n");
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] fail ttsd_server_get_support_voices() ");
                return ret;
        }
 
-       SLOG(LOG_DEBUG, TAG_TTSD, "[Server] Get default language (%s), voice type(%d) \n", *language, *voice_type); 
+       SLOG(LOG_DEBUG, TAG_TTSD, "[Server] Get default language (%s), voice type(%d) ", *language, *voice_type); 
 
        return TTSD_ERROR_NONE;
 }
@@ -670,7 +761,7 @@ int ttsd_server_setting_initialize(int uid)
 {
        if (false == g_is_engine) {
                if (0 != ttsd_engine_agent_initialize_current_engine()) {
-                       SLOG(LOG_WARN, TAG_TTSD, "[Server Setting WARNING] No Engine !!! \n" );
+                       SLOG(LOG_WARN, TAG_TTSD, "[Server Setting WARNING] No Engine !!! " );
                        g_is_engine = false;
                        return TTSD_ERROR_ENGINE_NOT_FOUND;
                } else {
@@ -678,21 +769,21 @@ int ttsd_server_setting_initialize(int uid)
                }
        }
 
-       if (-1 != ttsd_data_is_client(uid)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] pid has already been registered \n");
+       if (-1 != ttsd_setting_data_is_setting(uid)) {
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] pid has already been registered ");
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
        if (0 == ttsd_data_get_client_count()) {
                if( 0 != ttsd_engine_agent_load_current_engine() ) {
-                       SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] Fail to load current engine \n");
+                       SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] Fail to load current engine ");
                        return TTSD_ERROR_OPERATION_FAILED;
                }
        }
 
        /* register pid */
-       if (0 != ttsd_data_new_client(uid, uid)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] Fail to add client info \n");
+       if (0 != ttsd_setting_data_add(uid)) {
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] Fail to add client info ");
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
@@ -701,21 +792,22 @@ int ttsd_server_setting_initialize(int uid)
 
 int ttsd_server_setting_finalize(int uid)
 {
-       app_state_e state;
-       if (0 > ttsd_data_get_client_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid  (%s)\n", uid);
+       if (-1 == ttsd_setting_data_is_setting(uid)) {
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid  (%s)", uid);
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
-       ttsd_data_delete_client(uid);
+       ttsd_setting_data_delete(uid);
 
        /* unload engine, if ref count of client is 0 */
        if (0 == ttsd_data_get_client_count())
        {
-               if (0 != ttsd_engine_agent_unload_current_engine()) 
-                       SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] fail to unload current engine \n");
-               else
-                       SLOG(LOG_DEBUG, TAG_TTSD, "[Server Setting SUCCESS] unload current engine \n");
+               if (0 != ttsd_engine_agent_release()) {
+                       SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] Fail to release engine agent");
+               } else {
+                       SLOG(LOG_DEBUG, TAG_TTSD, "[Server Setting SUCCESS] Release engine agent");
+               }
+               ecore_timer_add(0, __quit_ecore_loop, NULL);
        }
 
        return TTSD_ERROR_NONE;
@@ -723,16 +815,15 @@ int ttsd_server_setting_finalize(int uid)
 
 int ttsd_server_setting_get_engine_list(int uid, GList** engine_list)
 {
-       app_state_e state;
-       if (0 > ttsd_data_get_client_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid  \n");
+       if (-1 == ttsd_setting_data_is_setting(uid)) {
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid  (%s)", uid);
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
        int ret = 0;
        ret = ttsd_engine_setting_get_engine_list(engine_list);
        if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] fail to get engine list : result(%d)\n", ret);
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] fail to get engine list : result(%d)", ret);
                return ret;
        }
 
@@ -741,16 +832,15 @@ int ttsd_server_setting_get_engine_list(int uid, GList** engine_list)
 
 int ttsd_server_setting_get_current_engine(int uid, char** engine_id)
 {
-       app_state_e state;
-       if (0 > ttsd_data_get_client_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid  \n");
+       if (-1 == ttsd_setting_data_is_setting(uid)) {
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid  (%s)", uid);
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
        int ret = 0;
        ret = ttsd_engine_setting_get_engine(engine_id);
        if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] Fail to get current engine : result(%d) \n", ret);
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] Fail to get current engine : result(%d) ", ret);
                return ret;
        }
 
@@ -765,7 +855,7 @@ bool __get_client_cb(int pid, int uid, app_state_e state, void* user_data)
        ttsd_data_set_client_state(uid, APP_STATE_READY);
 
        /* send message */
-       if ( 0 != ttsdc_send_interrupt_signal(pid, uid, TTSD_INTERRUPTED_STOPPED)) {
+       if ( 0 != ttsdc_send_set_state_message(pid, uid, APP_STATE_READY)) {
                /* remove client */
                ttsd_data_delete_client(uid);
        } 
@@ -775,15 +865,14 @@ bool __get_client_cb(int pid, int uid, app_state_e state, void* user_data)
 
 int ttsd_server_setting_set_current_engine(int uid, const char* engine_id)
 {
-       /* check if pid is valid */
-       app_state_e state;
-       if (0 > ttsd_data_get_client_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid  \n");
+       /* check if uid is valid */
+       if (-1 == ttsd_setting_data_is_setting(uid)) {
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid  (%s)", uid);
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
        if (true == ttsd_engine_agent_is_same_engine(engine_id)) {
-               SLOG(LOG_DEBUG, TAG_TTSD, "[Server Setting] new engine is the same as current engine \n");
+               SLOG(LOG_DEBUG, TAG_TTSD, "[Server Setting] new engine is the same as current engine ");
                return TTSD_ERROR_NONE;
        }
 
@@ -797,7 +886,7 @@ int ttsd_server_setting_set_current_engine(int uid, const char* engine_id)
        int ret = 0;
        ret = ttsd_engine_setting_set_engine(engine_id);
        if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] fail to set current engine : result(%d) \n", ret);
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] fail to set current engine : result(%d) ", ret);
                return ret;
        }
 
@@ -806,9 +895,9 @@ int ttsd_server_setting_set_current_engine(int uid, const char* engine_id)
 
 int ttsd_server_setting_get_voice_list(int uid, char** engine_id, GList** voice_list)
 {
-       app_state_e state;
-       if (0 > ttsd_data_get_client_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid  \n");
+       /* check if uid is valid */
+       if (-1 == ttsd_setting_data_is_setting(uid)) {
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid  (%s)", uid);
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
@@ -816,7 +905,7 @@ int ttsd_server_setting_get_voice_list(int uid, char** engine_id, GList** voice_
        int ret = 0;
        ret = ttsd_engine_setting_get_voice_list(engine_id, voice_list);
        if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] Fail to get voice list : result(%d)\n", ret);
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] Fail to get voice list : result(%d)", ret);
                return ret;
        }
 
@@ -825,16 +914,16 @@ int ttsd_server_setting_get_voice_list(int uid, char** engine_id, GList** voice_
 
 int ttsd_server_setting_get_default_voice(int uid, char** language, ttsp_voice_type_e* vctype)
 {
-       app_state_e state;
-       if (0 > ttsd_data_get_client_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid  \n");
+       /* check if uid is valid */
+       if (-1 == ttsd_setting_data_is_setting(uid)) {
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid  (%s)", uid);
                return TTSD_ERROR_INVALID_PARAMETER;
        }
        
        int ret = 0;
        ret = ttsd_engine_setting_get_default_voice(language, vctype);
        if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] Fail to get default voice : result(%d) \n", ret);
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] Fail to get default voice : result(%d) ", ret);
                return ret;
        }
 
@@ -843,9 +932,9 @@ int ttsd_server_setting_get_default_voice(int uid, char** language, ttsp_voice_t
 
 int ttsd_server_setting_set_default_voice(int uid, const char* language, int vctype)
 {
-       app_state_e state;
-       if (0 > ttsd_data_get_client_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid  \n");
+       /* check if uid is valid */
+       if (-1 == ttsd_setting_data_is_setting(uid)) {
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid  (%s)", uid);
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
@@ -853,7 +942,7 @@ int ttsd_server_setting_set_default_voice(int uid, const char* language, int vct
        int ret = 0;
        ret = ttsd_engine_setting_set_default_voice((const char*)language, (const ttsp_voice_type_e)vctype);
        if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] fail to set default voice : result(%d) \n", ret);
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] fail to set default voice : result(%d) ", ret);
                return ret;
        }       
 
@@ -862,16 +951,16 @@ int ttsd_server_setting_set_default_voice(int uid, const char* language, int vct
 
 int ttsd_server_setting_get_engine_setting(int uid, char** engine_id, GList** engine_setting_list)
 {
-       app_state_e state;
-       if (0 > ttsd_data_get_client_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid  \n");
+       /* check if uid is valid */
+       if (-1 == ttsd_setting_data_is_setting(uid)) {
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid  (%s)", uid);
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
        int ret = 0;
        ret = ttsd_engine_setting_get_engine_setting_info(engine_id, engine_setting_list);
        if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] fail to get engine setting info : result(%d)\n", ret);
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] fail to get engine setting info : result(%d)", ret);
                return ret;
        }
 
@@ -880,16 +969,16 @@ int ttsd_server_setting_get_engine_setting(int uid, char** engine_id, GList** en
 
 int ttsd_server_setting_set_engine_setting(int uid, const char* key, const char* value)
 {
-       app_state_e state;
-       if (0 > ttsd_data_get_client_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid  \n");
+       /* check if uid is valid */
+       if (-1 == ttsd_setting_data_is_setting(uid)) {
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid  (%s)", uid);
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
        int ret = 0;
        ret = ttsd_engine_setting_set_engine_setting(key, value);
        if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] fail to set engine setting info : result(%d)\n", ret);
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] fail to set engine setting info : result(%d)", ret);
                return ret;
        }
 
@@ -898,9 +987,9 @@ int ttsd_server_setting_set_engine_setting(int uid, const char* key, const char*
 
 int ttsd_server_setting_get_default_speed(int uid, int* default_speed)
 {
-       app_state_e state;
-       if (0 > ttsd_data_get_client_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid  \n");
+       /* check if uid is valid */
+       if (-1 == ttsd_setting_data_is_setting(uid)) {
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid  (%s)", uid);
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
@@ -908,7 +997,7 @@ int ttsd_server_setting_get_default_speed(int uid, int* default_speed)
        int ret = 0;
        ret = ttsd_engine_setting_get_default_speed((ttsp_speed_e*)default_speed);
        if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] fail to get default speed : result(%d)\n", ret);
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] fail to get default speed : result(%d)", ret);
                return ret;
        }       
 
@@ -917,9 +1006,9 @@ int ttsd_server_setting_get_default_speed(int uid, int* default_speed)
 
 int ttsd_server_setting_set_default_speed(int uid, int default_speed)
 {
-       app_state_e state;
-       if (0 > ttsd_data_get_client_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid  \n");
+       /* check if uid is valid */
+       if (-1 == ttsd_setting_data_is_setting(uid)) {
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] uid is not valid  (%s)", uid);
                return TTSD_ERROR_INVALID_PARAMETER;
        }
 
@@ -927,32 +1016,11 @@ int ttsd_server_setting_set_default_speed(int uid, int default_speed)
        int ret = 0;
        ret = ttsd_engine_setting_set_default_speed((ttsp_speed_e)default_speed);
        if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] fail to set default speed : result(%d)\n", ret);
+               SLOG(LOG_ERROR, TAG_TTSD, "[Server Setting ERROR] fail to set default speed : result(%d)", ret);
                return ret;
        }       
 
        return TTSD_ERROR_NONE;
 }
 
-/*
-* Server API for Internal event
-*/
-
-int ttsd_server_start_next_play(int uid)
-{
-       SLOG(LOG_DEBUG, TAG_TTSD, "===== NEXT PLAY START");
-       
-       int ret = ttsd_player_next_play(uid);
-
-       SLOG(LOG_DEBUG, TAG_TTSD, "===== ");
-       SLOG(LOG_DEBUG, TAG_TTSD, " ");
-
-       return ret ;
-}
-
-int ttsd_server_start_next_synthesis(int uid)
-{
-       return __server_next_synthesis(uid);
-}
-
 
old mode 100644 (file)
new mode 100755 (executable)
index 7e1f40f..2013b38
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved 
+*  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
@@ -16,6 +16,7 @@
 #define __TTSD_SERVER_CORE_H_
 
 #include <glib.h>
+#include <Ecore.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -28,6 +29,8 @@ extern "C" {
 /** Daemon initialize */
 int ttsd_initialize();
 
+Eina_Bool ttsd_cleanup_client(void *data);
+
 /*
 * Server API for client
 */
@@ -49,14 +52,6 @@ int ttsd_server_stop(int uid);
 int ttsd_server_pause(int uid, int* utt_id);
 
 /*
-* Server API for Internal event
-*/
-
-int ttsd_server_start_next_play(int uid);
-
-int ttsd_server_start_next_synthesis(int uid);
-
-/*
 * Server API for setting
 */
 
old mode 100644 (file)
new mode 100755 (executable)
index 4a49a26..f00eb0c
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved 
+*  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
diff --git a/tts-server.manifest b/tts-server.manifest
new file mode 100644 (file)
index 0000000..4928d08
--- /dev/null
@@ -0,0 +1,12 @@
+<manifest>
+        <define> 
+                <domain name="tts-server" policy="shared"/>
+        </define>
+       <assign>
+               <filesystem path="/usr/lib/libtts.so" label="_"/>
+               <filesystem path="/usr/lib/libtts_setting.so" label="_"/>
+       </assign>
+        <request>
+                <domain name="tts-server" />
+        </request>
+</manifest>