Tizen 2.1 base
authorJinkun Jang <jinkun.jang@samsung.com>
Tue, 12 Mar 2013 16:53:52 +0000 (01:53 +0900)
committerJinkun Jang <jinkun.jang@samsung.com>
Tue, 12 Mar 2013 16:53:52 +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]
client/stt.c [changed mode: 0644->0755]
client/stt.h [changed mode: 0644->0755]
client/stt_client.c [changed mode: 0644->0755]
client/stt_client.h [changed mode: 0644->0755]
client/stt_dbus.c [changed mode: 0644->0755]
client/stt_dbus.h [changed mode: 0644->0755]
client/stt_main.h [changed mode: 0644->0755]
client/stt_setting.c [changed mode: 0644->0755]
client/stt_setting.h [changed mode: 0644->0755]
client/stt_setting_dbus.c [changed mode: 0644->0755]
client/stt_setting_dbus.h [changed mode: 0644->0755]
common/stt_defs.h
debian/changelog
packaging/stt.spec
server/CMakeLists.txt
server/sttd.conf [new file with mode: 0644]
server/sttd_client_data.c [changed mode: 0644->0755]
server/sttd_client_data.h [changed mode: 0644->0755]
server/sttd_config.c [changed mode: 0644->0755]
server/sttd_config.h [changed mode: 0644->0755]
server/sttd_dbus.c [changed mode: 0644->0755]
server/sttd_dbus.h [changed mode: 0644->0755]
server/sttd_dbus_server.c [changed mode: 0644->0755]
server/sttd_dbus_server.h [changed mode: 0644->0755]
server/sttd_engine_agent.c [changed mode: 0644->0755]
server/sttd_engine_agent.h [changed mode: 0644->0755]
server/sttd_main.c [changed mode: 0644->0755]
server/sttd_main.h [changed mode: 0644->0755]
server/sttd_network.c [changed mode: 0644->0755]
server/sttd_network.h [changed mode: 0644->0755]
server/sttd_recorder.c [changed mode: 0644->0755]
server/sttd_recorder.h [changed mode: 0644->0755]
server/sttd_server.c [changed mode: 0644->0755]
server/sttd_server.h [changed mode: 0644->0755]
server/sttp.h [changed mode: 0644->0755]
stt-server.manifest [new file with mode: 0644]

diff --git a/AUTHORS b/AUTHORS
old mode 100644 (file)
new mode 100755 (executable)
index cd12545..3e21f67
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,2 +1,3 @@
-Dongyeol Lee <dy3.lee@samsung.com> 
+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 daa263b..1277ddc
@@ -8,7 +8,7 @@ INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/common")
 INCLUDE(FindPkgConfig)
 pkg_check_modules(pkgs REQUIRED 
        glib-2.0 dbus-1 
-       vconf dlog mm-player mm-common mm-camcorder openssl ecore
+       vconf dlog mm-player mm-common mm-camcorder ecore ecore-file
 )
 
 ## Client library ##
@@ -16,3 +16,5 @@ ADD_SUBDIRECTORY(client)
 
 ## Server daemon ##
 ADD_SUBDIRECTORY(server)
+
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.APLv2 RENAME stt 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.
old mode 100644 (file)
new mode 100755 (executable)
index 536c811..6023a2e
@@ -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,9 @@
 #include <sys/wait.h>
 #include <sys/types.h> 
 #include <unistd.h>
+#include <Ecore.h>
+#include <sys/stat.h>
+#include <dirent.h>
 
 #include "stt.h"
 #include "stt_main.h"
 
 #define CONNECTION_RETRY_COUNT 3
 
-int __check_stt_daemon();
+static bool g_is_daemon_started = false;
+
+static int __check_stt_daemon();
+static Eina_Bool __stt_notify_state_changed(void *data);
+static Eina_Bool __stt_notify_error(void *data);
 
 int stt_create(stt_h* stt)
 {
-       int ret = 0; 
-
        SLOG(LOG_DEBUG, TAG_STTC, "===== Create STT");
 
        if (NULL == stt) {
@@ -36,63 +41,188 @@ int stt_create(stt_h* stt)
                return STT_ERROR_INVALID_PARAMETER;
        }
 
-       /* check stt-daemon. */
-       __check_stt_daemon();   
-
        if (0 == stt_client_get_size()) {
                if (0 != stt_dbus_open_connection()) {
-                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to open connection\n ");
+                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to open connection");
                        return STT_ERROR_OPERATION_FAILED;
                }
        }
 
        if (0 != stt_client_new(stt)) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to create client!!!!!");
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to create client!");
                return STT_ERROR_OUT_OF_MEMORY;
        }
 
+       SLOG(LOG_DEBUG, TAG_STTC, "[Success] uid(%d)", (*stt)->handle);
+
+       SLOG(LOG_DEBUG, TAG_STTC, "=====");
+       SLOG(LOG_DEBUG, TAG_STTC, " ");
+
+       return STT_ERROR_NONE;
+}
+
+int stt_destroy(stt_h stt)
+{
+       SLOG(LOG_DEBUG, TAG_STTC, "===== Destroy STT");
+
+       if (NULL == stt) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input handle is null");
+               SLOG(LOG_DEBUG, TAG_STTC, "=====");
+               SLOG(LOG_DEBUG, TAG_STTC, " ");
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+       
+       stt_client_s* client = stt_client_get(stt);
+
+       /* check handle */
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+
+       int ret = -1;
+
+       /* check state */
+       switch (client->current_state) {
+       case STT_STATE_PROCESSING:
+       case STT_STATE_RECORDING:
+       case STT_STATE_READY:
+               ret = stt_dbus_request_finalize(client->uid);
+               if (0 != ret) {
+                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to request finalize");
+               }
+       case STT_STATE_CREATED:
+               /* Free resources */
+               stt_client_destroy(stt);
+               break;
+       }
+
+       SLOG(LOG_DEBUG, TAG_STTC, "Success: destroy");
+
+       if (0 == stt_client_get_size()) {
+               if (0 != stt_dbus_close_connection()) {
+                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to close connection");
+               }
+       }
+
+       SLOG(LOG_DEBUG, TAG_STTC, "=====");
+       SLOG(LOG_DEBUG, TAG_STTC, " ");
+
+       return STT_ERROR_NONE;
+}
+
+static Eina_Bool __stt_connect_daemon(void *data)
+{
+       SLOG(LOG_DEBUG, TAG_STTC, "===== Connect daemon");
+
+       stt_h stt = (stt_h)data;
+
+       stt_client_s* client = stt_client_get(stt);
+
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
+               SLOG(LOG_DEBUG, TAG_STTC, "=====");
+               SLOG(LOG_DEBUG, TAG_STTC, " ");
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+
+       /* Send hello */
+       if (0 != stt_dbus_request_hello()) {
+               if (false == g_is_daemon_started) {
+                       g_is_daemon_started = true;
+                       __check_stt_daemon();
+               }
+               return EINA_TRUE;
+       }
+
        /* request initialization */
-       int i = 0;
+       int ret = -1;
+       int i = 1;
+       bool silence_supported = false;
+       bool profanity_supported = false;
+       bool punctuation_supported = false;
+
        while (1) {
-               ret = stt_dbus_request_initialize((*stt)->handle);
-               
+               ret = stt_dbus_request_initialize(client->uid, &silence_supported, &profanity_supported, &punctuation_supported);
+
                if (STT_ERROR_ENGINE_NOT_FOUND == ret) {
-                       stt_client_destroy(*stt);
-                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to initialize : STT Engine Not founded");
-                       return ret;
+                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to initialize : STT Engine Not found");
+                       
+                       client->reason = STT_ERROR_ENGINE_NOT_FOUND;
+
+                       ecore_timer_add(0, __stt_notify_error, (void*)stt);
+
+                       return EINA_FALSE;
+
                } else if(0 != ret) {
-                       sleep(1);
+                       usleep(1);
                        if(CONNECTION_RETRY_COUNT == i) {
-                               stt_client_destroy(*stt);
                                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to initialize : TIMED OUT");
-                               return STT_ERROR_TIMED_OUT;                         
+
+                               client->reason = STT_ERROR_TIMED_OUT;
+
+                               ecore_timer_add(0, __stt_notify_error, (void*)stt);
+
+                               return EINA_FALSE;
                        }    
                        i++;
                } else {
                        /* success to connect stt-daemon */
+                       stt_client_set_option_supported(client->stt, silence_supported, profanity_supported, punctuation_supported);
+                       SLOG(LOG_DEBUG, TAG_STTC, "Supported options : silence(%s), profanity(%s), punctuation(%s)", 
+                               silence_supported ? "true" : "false", profanity_supported ? "true" : "false", punctuation_supported ? "true" : "false");
                        break;
                }
        }
 
-       SLOG(LOG_DEBUG, TAG_STTC, "[Success] uid(%d)", (*stt)->handle);
-       
+       client->before_state = client->current_state;
+       client->current_state = STT_STATE_READY;
+
+       ecore_timer_add(0, __stt_notify_state_changed, (void*)stt);
+
+       SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] uid(%d)", client->uid);
+
        SLOG(LOG_DEBUG, TAG_STTC, "=====");
-       SLOG(LOG_DEBUG, TAG_STTC, " ");
+       SLOG(LOG_DEBUG, TAG_STTC, "  ");
 
-       return STT_ERROR_NONE;
+       return EINA_FALSE;
 }
 
-int stt_destroy(stt_h stt)
+
+int stt_prepare(stt_h stt)
 {
-       SLOG(LOG_DEBUG, TAG_STTC, "===== Destroy STT");
+       SLOG(LOG_DEBUG, TAG_STTC, "===== Prepare STT");
 
-       if (NULL == stt) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input handle is null");
+       stt_client_s* client = stt_client_get(stt);
+
+       /* check handle */
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
                SLOG(LOG_DEBUG, TAG_STTC, "=====");
                SLOG(LOG_DEBUG, TAG_STTC, " ");
                return STT_ERROR_INVALID_PARAMETER;
        }
-       
+
+       /* check state */
+       if (client->current_state != STT_STATE_CREATED) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state is not 'CREATED'"); 
+               SLOG(LOG_DEBUG, TAG_STTC, "=====");
+               SLOG(LOG_DEBUG, TAG_STTC, " ");
+               return STT_ERROR_INVALID_STATE;
+       }
+
+       ecore_timer_add(0, __stt_connect_daemon, (void*)stt);
+
+       SLOG(LOG_DEBUG, TAG_STTC, "=====");
+       SLOG(LOG_DEBUG, TAG_STTC, " ");
+
+       return STT_ERROR_NONE;
+}
+
+int stt_unprepare(stt_h stt)
+{
+       SLOG(LOG_DEBUG, TAG_STTC, "===== Unprepare STT");
+
        stt_client_s* client = stt_client_get(stt);
 
        /* check handle */
@@ -100,22 +230,24 @@ int stt_destroy(stt_h stt)
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
                return STT_ERROR_INVALID_PARAMETER;
        }
-       
+
+       /* check state */
+       if (client->current_state != STT_STATE_READY) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state is not 'READY'"); 
+               SLOG(LOG_DEBUG, TAG_STTC, "=====");
+               SLOG(LOG_DEBUG, TAG_STTC, " ");
+               return STT_ERROR_INVALID_STATE;
+       }
+
        int ret = stt_dbus_request_finalize(client->uid);
        if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to request finalize");
+               SLOG(LOG_WARN, TAG_STTC, "[ERROR] Fail to request finalize");
        }
-       
-       /* Free resources */
-       stt_client_destroy(stt);
 
-       SLOG(LOG_DEBUG, TAG_STTC, "Success: destroy");
+       client->before_state = client->current_state;
+       client->current_state = STT_STATE_CREATED;
 
-       if (0 == stt_client_get_size()) {
-               if (0 != stt_dbus_close_connection()) {
-                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to close connection\n ");
-               }
-       }
+       ecore_timer_add(0, __stt_notify_state_changed, (void*)stt);
 
        SLOG(LOG_DEBUG, TAG_STTC, "=====");
        SLOG(LOG_DEBUG, TAG_STTC, " ");
@@ -144,6 +276,12 @@ int stt_foreach_supported_languages(stt_h stt, stt_supported_language_cb callbac
                return STT_ERROR_INVALID_PARAMETER;
        }
 
+       /* check state */
+       if (client->current_state != STT_STATE_READY) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state is not READY"); 
+               return STT_ERROR_INVALID_STATE;
+       }
+
        int ret = 0;
        ret = stt_dbus_request_get_support_langs(client->uid, client->stt, callback, user_data);
        if (0 != ret) {
@@ -180,6 +318,12 @@ int stt_get_default_language(stt_h stt, char** language)
                return STT_ERROR_INVALID_PARAMETER;
        }
 
+       /* check state */
+       if (client->current_state != STT_STATE_READY) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state is not READY"); 
+               return STT_ERROR_INVALID_STATE;
+       }
+
        int ret = 0;
        ret = stt_dbus_request_get_default_lang(client->uid, language);
 
@@ -212,6 +356,7 @@ int stt_get_state(stt_h stt, stt_state_e* state)
        *state = client->current_state;
 
        switch(*state) {
+               case STT_STATE_CREATED:         SLOG(LOG_DEBUG, TAG_STTC, "Current state is 'CREATED'");        break;
                case STT_STATE_READY:           SLOG(LOG_DEBUG, TAG_STTC, "Current state is 'Ready'");          break;
                case STT_STATE_RECORDING:       SLOG(LOG_DEBUG, TAG_STTC, "Current state is 'Recording'");      break;
                case STT_STATE_PROCESSING:      SLOG(LOG_DEBUG, TAG_STTC, "Current state is 'Processing'");     break;
@@ -234,6 +379,12 @@ int stt_is_partial_result_supported(stt_h stt, bool* partial_result)
                return STT_ERROR_INVALID_PARAMETER;
        }
 
+       /* check state */
+       if (client->current_state != STT_STATE_READY) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state is not READY"); 
+               return STT_ERROR_INVALID_STATE;
+       }
+
        int ret = 0;
        ret = stt_dbus_request_is_partial_result_supported(client->uid, partial_result);
 
@@ -260,11 +411,21 @@ int stt_set_profanity_filter(stt_h stt, stt_option_profanity_e type)
                return STT_ERROR_INVALID_PARAMETER;
        }
 
-       if (type >= STT_OPTION_PROFANITY_FALSE && type <= STT_OPTION_PROFANITY_AUTO)
-               client->profanity = type;       
-       else {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Type is invalid");
-               return STT_ERROR_INVALID_PARAMETER;
+       /* check state */
+       if (client->current_state != STT_STATE_READY) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state is not READY"); 
+               return STT_ERROR_INVALID_STATE;
+       }
+
+       if (true == client->profanity_supported) {
+               if (type >= STT_OPTION_PROFANITY_FALSE && type <= STT_OPTION_PROFANITY_AUTO)
+                       client->profanity = type;       
+               else {
+                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Type is invalid");
+                       return STT_ERROR_INVALID_PARAMETER;
+               }
+       } else {
+               return STT_ERROR_NOT_SUPPORTED_FEATURE; 
        }
 
        return STT_ERROR_NONE;
@@ -284,11 +445,21 @@ int stt_set_punctuation_override(stt_h stt, stt_option_punctuation_e type)
                return STT_ERROR_INVALID_PARAMETER;
        }
        
-       if (type >= STT_OPTION_PUNCTUATION_FALSE && type <= STT_OPTION_PUNCTUATION_AUTO)
-               client->punctuation = type;     
-       else {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Type is invalid");
-               return STT_ERROR_INVALID_PARAMETER;
+       /* check state */
+       if (client->current_state != STT_STATE_READY) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state is not READY"); 
+               return STT_ERROR_INVALID_STATE;
+       }
+
+       if (true == client->punctuation_supported) {
+               if (type >= STT_OPTION_PUNCTUATION_FALSE && type <= STT_OPTION_PUNCTUATION_AUTO)
+                       client->punctuation = type;     
+               else {
+                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Type is invalid");
+                       return STT_ERROR_INVALID_PARAMETER;
+               }
+       } else {
+               return STT_ERROR_NOT_SUPPORTED_FEATURE; 
        }
 
        return STT_ERROR_NONE;
@@ -308,11 +479,21 @@ int stt_set_silence_detection(stt_h stt, stt_option_silence_detection_e type)
                return STT_ERROR_INVALID_PARAMETER;
        }
 
-       if (type >= STT_OPTION_SILENCE_DETECTION_FALSE && type <= STT_OPTION_SILENCE_DETECTION_AUTO)
-               client->silence = type; 
-       else {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Type is invalid");
-               return STT_ERROR_INVALID_PARAMETER;
+       /* check state */
+       if (client->current_state != STT_STATE_READY) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state is not READY"); 
+               return STT_ERROR_INVALID_STATE;
+       }
+
+       if (true == client->silence_supported) {
+               if (type >= STT_OPTION_SILENCE_DETECTION_FALSE && type <= STT_OPTION_SILENCE_DETECTION_AUTO)
+                       client->silence = type; 
+               else {
+                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Type is invalid");
+                       return STT_ERROR_INVALID_PARAMETER;
+               }
+       } else {
+               return STT_ERROR_NOT_SUPPORTED_FEATURE; 
        }
 
        return STT_ERROR_NONE;
@@ -363,14 +544,10 @@ int stt_start(stt_h stt, const char* language, const char* type)
        } else {
                SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS]");
 
-               if (NULL != client->state_changed_cb) {
-                       client->state_changed_cb(client->stt, client->current_state, STT_STATE_RECORDING, client->state_changed_user_data); 
-                       SLOG(LOG_DEBUG, TAG_STTC, "Called state changed : STT_STATE_RECORDING");
-               } else {
-                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Don't register state changed callback");
-               }    
-
+               client->before_state = client->current_state;
                client->current_state = STT_STATE_RECORDING;
+
+               ecore_timer_add(0, __stt_notify_state_changed, (void*)stt);
        }
 
        free(temp);
@@ -418,14 +595,10 @@ int stt_stop(stt_h stt)
        } else {
                SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS]");
 
-               if (NULL != client->state_changed_cb) {
-                       client->state_changed_cb(client->stt, client->current_state, STT_STATE_PROCESSING, client->state_changed_user_data); 
-                       SLOG(LOG_DEBUG, TAG_STTC, "Called state changed : STT_STATE_PROCESSING");
-               } else {
-                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Don't register state changed callback");
-               }
-
+               client->before_state = client->current_state;
                client->current_state = STT_STATE_PROCESSING;
+
+               ecore_timer_add(0, __stt_notify_state_changed, (void*)stt);
        }
 
        SLOG(LOG_DEBUG, TAG_STTC, "=====");
@@ -471,14 +644,11 @@ int stt_cancel(stt_h stt)
                SLOG(LOG_DEBUG, TAG_STTC, "[ERROR] Fail to cancel");
        } else {
                SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS]");
-               if (NULL != client->state_changed_cb) {
-                       client->state_changed_cb(client->stt, client->current_state, STT_STATE_READY, client->state_changed_user_data); 
-                       SLOG(LOG_DEBUG, TAG_STTC, "Called state changed : STT_STATE_READY");
-               } else {
-                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Don't register state changed callback");
-               }
 
+               client->before_state = client->current_state;
                client->current_state = STT_STATE_READY;
+
+               ecore_timer_add(0, __stt_notify_state_changed, (void*)stt);
        }
 
        SLOG(LOG_DEBUG, TAG_STTC, "=====");
@@ -517,6 +687,30 @@ int stt_get_recording_volume(stt_h stt, float* volume)
        return STT_ERROR_NONE;
 }
 
+static Eina_Bool __stt_notify_error(void *data)
+{
+       stt_h stt = (stt_h)data;
+
+       stt_client_s* client = stt_client_get(stt);
+
+       /* check handle */
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to notify error : A handle is not valid");
+               return EINA_FALSE;
+       }
+
+       if (NULL != client->error_cb) {
+               stt_client_use_callback(client);
+               client->error_cb(client->stt, client->reason, client->error_user_data); 
+               stt_client_not_use_callback(client);
+               SLOG(LOG_DEBUG, TAG_STTC, "Error callback is called");
+       } else {
+               SLOG(LOG_WARN, TAG_STTC, "[WARNING] Error callback is null");
+       }
+
+       return EINA_FALSE;
+}
+
 int __stt_cb_error(int uid, int reason)
 {
        stt_client_s* client = stt_client_get_by_uid(uid);
@@ -525,20 +719,88 @@ int __stt_cb_error(int uid, int reason)
                return -1;
        }
 
-       client->current_state = STT_STATE_READY;
+       client->reason = reason;
 
        if (NULL != client->error_cb) {
-               stt_client_use_callback(client);
-               client->error_cb(client->stt, reason, client->error_user_data); 
-               stt_client_not_use_callback(client);
-               SLOG(LOG_DEBUG, TAG_STTC, "client error callback called");
+               ecore_timer_add(0, __stt_notify_error, client->stt);
        } else {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Error occur but user callback is null");
+               SLOG(LOG_WARN, TAG_STTC, "[WARNING] Error callback is null");
        }    
 
        return 0;
 }
 
+static Eina_Bool __stt_notify_result(void *data)
+{
+       stt_h stt = (stt_h)data;
+
+       stt_client_s* client = stt_client_get(stt);
+
+       /* check handle */
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to notify error : A handle is not valid");
+               return EINA_FALSE;
+       }
+
+       if (NULL != client->result_cb) {
+               stt_client_use_callback(client);
+               client->result_cb(client->stt, client->type, (const char**)client->data_list, client->data_count, client->msg, client->result_user_data);
+               stt_client_not_use_callback(client);
+               SLOG(LOG_DEBUG, TAG_STTC, "client result callback called");
+       } else {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] User result callback is null");
+       } 
+
+       /* Free result */
+       if (NULL != client->type)
+               free(client->type);
+
+       if (NULL != client->data_list) {
+               char **temp = NULL;
+               temp = client->data_list;
+
+               int i = 0;
+               for (i = 0;i < client->data_count;i++) {
+                       if(NULL != temp[i])
+                               free(temp[i]);
+                       else 
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Result data is error");
+               }
+               free(client->data_list);
+       }
+       
+       if (NULL != client->msg) 
+               free(client->msg);
+
+       client->data_count = 0;
+
+       return EINA_FALSE;
+}
+
+static Eina_Bool __stt_notify_state_changed(void *data)
+{
+       stt_h stt = (stt_h)data;
+
+       stt_client_s* client = stt_client_get(stt);
+
+       /* check handle */
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to notify error : A handle is not valid");
+               return EINA_FALSE;
+       }
+
+       if (NULL != client->state_changed_cb) {
+               stt_client_use_callback(client);
+               client->state_changed_cb(client->stt, client->before_state, client->current_state, client->state_changed_user_data); 
+               stt_client_not_use_callback(client);
+               SLOG(LOG_DEBUG, TAG_STTC, "State changed callback is called");
+       } else {
+               SLOG(LOG_WARN, TAG_STTC, "[WARNING] State changed callback is null");
+       }
+
+       return EINA_FALSE;
+}
+
 int __stt_cb_result(int uid, const char* type, const char** data, int data_count, const char* msg)
 {
        stt_client_s* client = NULL;
@@ -558,26 +820,68 @@ int __stt_cb_result(int uid, const char* type, const char** data, int data_count
        }       
 
        if (NULL != client->result_cb) {
-               stt_client_use_callback(client);
-               client->result_cb(client->stt, type, data, data_count, msg, client->result_user_data);
-               stt_client_not_use_callback(client);
-               SLOG(LOG_DEBUG, TAG_STTC, "client result callback called");
+               client->type = strdup(type);
+               client->msg = strdup(msg);
+               client->data_count = data_count;
+
+               if (data_count > 0) {
+                       char **temp = NULL;
+                       temp = malloc( sizeof(char*) * data_count);
+
+                       for (i = 0;i < data_count;i++) {
+                               if(NULL != data[i])
+                                       temp[i] = strdup(data[i]);
+                               else 
+                                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Result data is error");
+                       }
+
+                       client->data_list = temp;
+               }
+
+               ecore_timer_add(0, __stt_notify_result, client->stt);
        } else {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] User result callback is null");
        }   
 
+       client->before_state = client->current_state;
+       client->current_state = STT_STATE_READY;
+
        if (NULL != client->state_changed_cb) {
-               client->state_changed_cb(client->stt, client->current_state, STT_STATE_READY, client->state_changed_user_data); 
-               SLOG(LOG_DEBUG, TAG_STTC, "client state changed callback called");
+               ecore_timer_add(0, __stt_notify_state_changed, client->stt);
        } else {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Don't register result callback");
+               SLOG(LOG_WARN, TAG_STTC, "[WARNING] State changed callback is null");
        }
 
-       client->current_state = STT_STATE_READY;
-
        return 0;
 }
 
+static Eina_Bool __stt_notify_partial_result(void *data)
+{
+       stt_h stt = (stt_h)data;
+
+       stt_client_s* client = stt_client_get(stt);
+
+       /* check handle */
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to notify error : A handle is not valid");
+               return EINA_FALSE;
+       }
+
+       if (client->partial_result_cb) {
+               stt_client_use_callback(client);
+               client->partial_result_cb(client->stt, client->partial_result, client->partial_result_user_data);
+               stt_client_not_use_callback(client);
+               SLOG(LOG_DEBUG, TAG_STTC, "Partial result callback is called");
+       } else {
+               SLOG(LOG_WARN, TAG_STTC, "[WARNING] Partial result callback is null");
+       }   
+
+       if (NULL != client->partial_result)
+               free(client->partial_result);
+
+       return EINA_FALSE;
+}
+
 int __stt_cb_partial_result(int uid, const char* data)
 {
        stt_client_s* client = NULL;
@@ -594,41 +898,34 @@ int __stt_cb_partial_result(int uid, const char* data)
        }
 
        if (client->partial_result_cb) {
-               stt_client_use_callback(client);
-               client->partial_result_cb(client->stt, data, client->partial_result_user_data);
-               stt_client_not_use_callback(client);
-               SLOG(LOG_DEBUG, TAG_STTC, "client partial result callback called");
+               client->partial_result = strdup(data);
+               ecore_timer_add(0, __stt_notify_partial_result, client->stt);
        } else {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Don't register partial result callback");
-       }   
+               SLOG(LOG_WARN, TAG_STTC, "[WARNING] Partial result callback is null");
+       }  
 
        return 0;
 }
 
-int __stt_cb_stop_by_daemon(int uid)
+int __stt_cb_set_state(int uid, int state)
 {
        stt_client_s* client = stt_client_get_by_uid(uid);
        if( NULL == client ) {
-               SLOG(LOG_ERROR, TAG_STTC, "Handle not found\n");
+               SLOG(LOG_ERROR, TAG_STTC, "Handle not found");
                return -1;
        }
 
-       if (client->current_state != STT_STATE_RECORDING) {
-               SLOG(LOG_ERROR, TAG_STTC, "Current state is NOT 'Recording' state");    
-               return 0;
-       }
+       stt_state_e state_from_daemon = (stt_state_e)state;
 
-       if (NULL != client->state_changed_cb) {
-               stt_client_use_callback(client);
-               client->state_changed_cb(client->stt, client->current_state, STT_STATE_PROCESSING, client->state_changed_user_data); 
-               stt_client_not_use_callback(client);
-               SLOG(LOG_DEBUG, TAG_STTC, "client state changed callback called");
-       } else {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Error occur but user callback is null");
+       if (client->current_state == state_from_daemon) {
+               SLOG(LOG_DEBUG, TAG_STTC, "Current state has already been %d", client->current_state);
+               return 0;
        }
 
-       client->current_state = STT_STATE_PROCESSING;
+       client->before_state = client->current_state;
+       client->current_state = state_from_daemon;
 
+       ecore_timer_add(0, __stt_notify_state_changed, client->stt);
        return 0;
 }
 
@@ -645,7 +942,7 @@ int stt_set_result_cb(stt_h stt, stt_result_cb callback, void* user_data)
                return STT_ERROR_INVALID_PARAMETER;
        }
 
-       if (STT_STATE_READY != client->current_state) {
+       if (STT_STATE_CREATED != client->current_state) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state is not 'ready'."); 
                return STT_ERROR_INVALID_STATE;
        }
@@ -669,7 +966,7 @@ int stt_unset_result_cb(stt_h stt)
                return STT_ERROR_INVALID_PARAMETER;
        }
 
-       if (STT_STATE_READY != client->current_state) {
+       if (STT_STATE_CREATED != client->current_state) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state is not 'ready'."); 
                return STT_ERROR_INVALID_STATE;
        }
@@ -693,7 +990,7 @@ int stt_set_partial_result_cb(stt_h stt, stt_partial_result_cb callback, void* u
                return STT_ERROR_INVALID_PARAMETER;
        }
 
-       if (STT_STATE_READY != client->current_state) {
+       if (STT_STATE_CREATED != client->current_state) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state is not 'ready'."); 
                return STT_ERROR_INVALID_STATE;
        }
@@ -717,7 +1014,7 @@ int stt_unset_partial_result_cb(stt_h stt)
                return STT_ERROR_INVALID_PARAMETER;
        }
 
-       if (STT_STATE_READY != client->current_state) {
+       if (STT_STATE_CREATED != client->current_state) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state is not 'ready'."); 
                return STT_ERROR_INVALID_STATE;
        }
@@ -741,7 +1038,7 @@ int stt_set_state_changed_cb(stt_h stt, stt_state_changed_cb callback, void* use
                return STT_ERROR_INVALID_PARAMETER;
        }
 
-       if (STT_STATE_READY != client->current_state) {
+       if (STT_STATE_CREATED != client->current_state) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state is not 'ready'."); 
                return STT_ERROR_INVALID_STATE;
        }
@@ -765,7 +1062,7 @@ int stt_unset_state_changed_cb(stt_h stt)
                return STT_ERROR_INVALID_PARAMETER;
        }
 
-       if (STT_STATE_READY != client->current_state) {
+       if (STT_STATE_CREATED != client->current_state) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state is not 'ready'."); 
                return STT_ERROR_INVALID_STATE;
        }
@@ -790,7 +1087,7 @@ int stt_set_error_cb(stt_h stt, stt_error_cb callback, void* user_data)
                return STT_ERROR_INVALID_PARAMETER;
        }
 
-       if (STT_STATE_READY != client->current_state) {
+       if (STT_STATE_CREATED != client->current_state) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state is not 'ready'."); 
                return STT_ERROR_INVALID_STATE;
        }
@@ -814,7 +1111,7 @@ int stt_unset_error_cb(stt_h stt)
                return STT_ERROR_INVALID_PARAMETER;
        }
 
-       if (STT_STATE_READY != client->current_state) {
+       if (STT_STATE_CREATED != client->current_state) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state is not 'ready'."); 
                return STT_ERROR_INVALID_STATE;
        }
@@ -825,43 +1122,70 @@ int stt_unset_error_cb(stt_h stt)
        return 0;
 }
 
-static bool __stt_is_alive()
+int __get_cmd_line(char *file, char *buf) 
 {
        FILE *fp = NULL;
-       char buff[256];
-       char cmd[256];
-       int i=0;
+       int i;
 
-       memset(buff, '\0', 256);
-       memset(cmd, '\0', 256);
+       fp = fopen(file, "r");
+       if (fp == NULL) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Get command line");
+               return -1;
+       }
 
-       if ((fp = popen("ps -eo \"cmd\"", "r")) == NULL) {
-               SLOG(LOG_DEBUG, TAG_STTC, "[ERROR] popen error \n");
+       memset(buf, 0, 256);
+       fgets(buf, 256, fp);
+       fclose(fp);
+
+       return 0;
+}
+
+static bool __stt_is_alive()
+{
+       DIR *dir;
+       struct dirent *entry;
+       struct stat filestat;
+       
+       int pid;
+       char cmdLine[256];
+       char tempPath[256];
+
+       dir  = opendir("/proc");
+       if (NULL == dir) {
+               SLOG(LOG_ERROR, TAG_STTC, "process checking is FAILED");
                return FALSE;
        }
 
-       while(fgets(buff, 255, fp)) {
-               if (i == 0) {
-                       i++;
+       while ((entry = readdir(dir)) != NULL) {
+               if (0 != lstat(entry->d_name, &filestat))
+                       continue;
+
+               if (!S_ISDIR(filestat.st_mode))
                        continue;
-               }
 
-               sscanf(buff, "%s", cmd);
+               pid = atoi(entry->d_name);
+               if (pid <= 0) continue;
 
-               if( 0 == strncmp(cmd, "[stt-daemon]", strlen("[stt-daemon]")) ||
-                       0 == strncmp(cmd, "stt-daemon", strlen("stt-daemon")) ||
-                       0 == strncmp(cmd, "/usr/bin/stt-daemon", strlen("/usr/bin/stt-daemon"))
-                       ) {
-                       fclose(fp);
-                       return TRUE;
+               sprintf(tempPath, "/proc/%d/cmdline", pid);
+               if (0 != __get_cmd_line(tempPath, cmdLine)) {
+                       continue;
+               }
+               if ( 0 == strncmp(cmdLine, "[stt-daemon]", strlen("[stt-daemon]")) ||
+                       0 == strncmp(cmdLine, "stt-daemon", strlen("stt-daemon")) ||
+                       0 == strncmp(cmdLine, "/usr/bin/stt-daemon", strlen("/usr/bin/stt-daemon"))) {
+                               SLOG(LOG_DEBUG, TAG_STTC, "stt-daemon is ALIVE !! \n");
+                               closedir(dir);
+                               return TRUE;
                }
-               i++;
        }
-       fclose(fp);
+       SLOG(LOG_DEBUG, TAG_STTC, "THERE IS NO stt-daemon !! \n");
 
+       closedir(dir);
        return FALSE;
+
 }
 
+
 static void __my_sig_child(int signo, siginfo_t *info, void *data)
 {
        int status;
@@ -879,14 +1203,12 @@ static void __my_sig_child(int signo, siginfo_t *info, void *data)
 }
 
 
-int __check_stt_daemon()
+static int __check_stt_daemon()
 {
        if( TRUE == __stt_is_alive() )
                return 0;
        
        /* fork-exec stt-daemon */
-       SLOG(LOG_DEBUG, TAG_STTC, "THERE IS NO stt-daemon \n");
-
        int pid, i;
        struct sigaction act, dummy;
 
@@ -916,7 +1238,6 @@ int __check_stt_daemon()
                break;
 
        default:
-               sleep(1);
                break;
        }
 
old mode 100644 (file)
new mode 100755 (executable)
index 0fdf71c..98313db
@@ -1,16 +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 __STT_H__
 #define __STT_H__
@@ -32,114 +34,102 @@ extern "C"
 * @brief Enumerations of error codes.
 */
 typedef enum {
-       STT_ERROR_NONE                  = 0,            /**< Successful */
-       STT_ERROR_OUT_OF_MEMORY         = -ENOMEM,      /**< Out of Memory */
-       STT_ERROR_IO_ERROR              = -EIO,         /**< I/O error */
-       STT_ERROR_INVALID_PARAMETER     = -EINVAL,      /**< Invalid parameter */
-       STT_ERROR_TIMED_OUT             = -ETIMEDOUT,   /**< No answer from the daemon */
-       STT_ERROR_RECORDER_BUSY         = -EBUSY,       /**< Busy recorder */
-       STT_ERROR_OUT_OF_NETWORK        = -ENETDOWN,    /**< Out of network */
-       STT_ERROR_INVALID_STATE         = -0x0100031,   /**< Invalid state */
-       STT_ERROR_INVALID_LANGUAGE      = -0x0100032,   /**< Invalid language */
-       STT_ERROR_ENGINE_NOT_FOUND      = -0x0100033,   /**< No available engine  */    
-       STT_ERROR_OPERATION_FAILED      = -0x0100034    /**< Operation failed  */
+       STT_ERROR_NONE                  = 0,                    /**< Successful */
+       STT_ERROR_OUT_OF_MEMORY         = -ENOMEM,              /**< Out of Memory */
+       STT_ERROR_IO_ERROR              = -EIO,                 /**< I/O error */
+       STT_ERROR_INVALID_PARAMETER     = -EINVAL,              /**< Invalid parameter */
+       STT_ERROR_TIMED_OUT             = -ETIMEDOUT,           /**< No answer from the daemon */
+       STT_ERROR_RECORDER_BUSY         = -EBUSY,               /**< Busy recorder */
+       STT_ERROR_OUT_OF_NETWORK        = -ENETDOWN,            /**< Out of network */
+       STT_ERROR_INVALID_STATE         = -0x0100000 | 0x31,    /**< Invalid state */
+       STT_ERROR_INVALID_LANGUAGE      = -0x0100000 | 0x32,    /**< Invalid language */
+       STT_ERROR_ENGINE_NOT_FOUND      = -0x0100000 | 0x33,    /**< No available engine  */    
+       STT_ERROR_OPERATION_FAILED      = -0x0100000 | 0x34,    /**< Operation failed  */
+       STT_ERROR_NOT_SUPPORTED_FEATURE = -0x0100000 | 0x35     /**< Not supported feature of current engine */
 }stt_error_e;
 
 /** 
 * @brief Recognition type : free form dictation or default type.
 */
-#define STT_RECOGNITION_TYPE_FREE                      "stt.recognition.type.FREE"
+#define STT_RECOGNITION_TYPE_FREE              "stt.recognition.type.FREE"
 
 /** 
 * @brief Recognition type : web search. 
 */
-#define STT_RECOGNITION_TYPE_WEB_SEARCH                        "stt.recognition.type.WEB_SEARCH"
+#define STT_RECOGNITION_TYPE_WEB_SEARCH                "stt.recognition.type.WEB_SEARCH"
 
 /** 
-* @brief Recognition type : all voice commands 
+* @brief Result message : None message
 */
-#define STT_RECOGNITION_TYPE_COMMAND                   "stt.recognition.type.COMMAND"
+#define STT_RESULT_MESSAGE_NONE                        "stt.result.message.none"
 
 /** 
-* @brief Recognition type : call of voice commands 
+* @brief Result warning message : The speech has started too soon
 */
-#define STT_RECOGNITION_TYPE_COMMAND_CALL              "stt.recognition.type.COMMAND.CALL"
+#define STT_RESULT_MESSAGE_WARNING_TOO_SOON    "stt.result.message.warning.too.soon"
 
 /** 
-* @brief Recognition type : music of voice commands 
+* @brief Result warning message : The speech is too short
 */
-#define STT_RECOGNITION_TYPE_COMMAND_MUSIC             "stt.recognition.type.COMMAND.MUSIC"
+#define STT_RESULT_MESSAGE_WARNING_TOO_SHORT   "stt.result.message.warning.too.short"
 
 /** 
-* @brief Recognition type : web search of voice commands 
+* @brief Result warning message : The speech is too long
 */
-#define STT_RECOGNITION_TYPE_COMMAND_WEB_SEARCH                "stt.recognition.type.COMMAND.WEB_SEARCH"
+#define STT_RESULT_MESSAGE_WARNING_TOO_LONG    "stt.result.message.warning.too.long"
 
 /** 
-* @brief Recognition type : schedule of voice commands 
+* @brief Result warning message : The speech is too quiet to listen
 */
-#define STT_RECOGNITION_TYPE_COMMAND_SCHEDULE          "stt.recognition.type.COMMAND.SCHEDULE"
+#define STT_RESULT_MESSAGE_WARNING_TOO_QUIET   "stt.result.message.warning.too.quiet"
 
 /** 
-* @brief Recognition type : search of voice commands 
+* @brief Result warning message : The speech is too loud to listen
 */
-#define STT_RECOGNITION_TYPE_COMMAND_SEARCH            "stt.recognition.type.COMMAND.SEARCH"
+#define STT_RESULT_MESSAGE_WARNING_TOO_LOUD    "stt.result.message.warning.too.loud"
 
 /** 
-* @brief Recognition type : contact of voice commands 
+* @brief Result warning message : The speech is too fast to listen
 */
-#define STT_RECOGNITION_TYPE_COMMAND_CONTACT           "stt.recognition.type.COMMAND.CONTACT"
+#define STT_RESULT_MESSAGE_WARNING_TOO_FAST    "stt.result.message.warning.too.fast"
 
 /** 
-* @brief Recognition type : social of voice commands 
+* @brief Result error message : Recognition was failed because the speech started too soon
 */
-#define STT_RECOGNITION_TYPE_COMMAND_SOCIAL            "stt.recognition.type.COMMAND.SOCIAL"
+#define STT_RESULT_MESSAGE_ERROR_TOO_SOON      "stt.result.message.error.too.soon"
 
 /** 
-* @brief Recognition type : message of voice commands 
+* @brief Result error message : Recognition was failed because the speech started too short
 */
-#define STT_RECOGNITION_TYPE_COMMAND_MESSAGE           "stt.recognition.type.COMMAND.MESSAGE"
+#define STT_RESULT_MESSAGE_ERROR_TOO_SHORT     "stt.result.message.error.too.short"
 
 /** 
-* @brief Recognition type : email of voice commands 
+* @brief Result error message : Recognition was failed because the speech started too long
 */
-#define STT_RECOGNITION_TYPE_COMMAND_EMAIL             "stt.recognition.type.COMMAND.EMAIL"
+#define STT_RESULT_MESSAGE_ERROR_TOO_LONG      "stt.result.message.error.too.long"
 
 /** 
-* @brief Recognition type : memo of voice commands 
+* @brief Result error message : Recognition was failed because the speech started too quiet to listen
 */
-#define STT_RECOGNITION_TYPE_COMMAND_MEMO              "stt.recognition.type.COMMAND.MEMO"
+#define STT_RESULT_MESSAGE_ERROR_TOO_QUIET     "stt.result.message.error.too.quiet"
 
 /** 
-* @brief Recognition type : alarm of voice commands 
+* @brief Result error message : Recognition was failed because the speech started too loud to listen 
 */
-#define STT_RECOGNITION_TYPE_COMMAND_ALARM             "stt.recognition.type.COMMAND.ALARM"
+#define STT_RESULT_MESSAGE_ERROR_TOO_LOUD      "stt.result.message.error.too.loud"
 
 /** 
-* @brief Recognition type : application of voice commands 
+* @brief Result error message : Recognition was failed because the speech started too fast to listen
 */
-#define STT_RECOGNITION_TYPE_COMMAND_APPLICATION       "stt.recognition.type.COMMAND.APPLICATION"
+#define STT_RESULT_MESSAGE_ERROR_TOO_FAST      "stt.result.message.error.too.fast"
 
-/** 
-* @brief Recognition type : driving mode of voice commands 
-*/
-#define STT_RECOGNITION_TYPE_COMMAND_DRIVING_MODE      "stt.recognition.type.COMMAND.DRIVING_MODE"
-
-/** 
-* @brief Recognition type : navigation of voice commands 
-*/
-#define STT_RECOGNITION_TYPE_COMMAND_NAVIGATION                "stt.recognition.type.COMMAND.NAVIGATION"
-
-/** 
-* @brief Recognition type : text-to-speech of voice commands 
-*/
-#define STT_RECOGNITION_TYPE_COMMAND_TTS               "stt.recognition.type.COMMAND.TTS"
 
 /** 
 * @brief Enumerations of state.
 */
 typedef enum {
-       STT_STATE_READY = 0,                    /**< 'READY' state */
+       STT_STATE_CREATED = 0,                  /**< 'CREATED' state */
+       STT_STATE_READY,                        /**< 'READY' state */
        STT_STATE_RECORDING,                    /**< 'RECORDING' state */
        STT_STATE_PROCESSING                    /**< 'PROCESSING' state*/
 }stt_state_e;
@@ -183,10 +173,10 @@ typedef struct stt_s *stt_h;
 *      this function is called. 
 *
 * @param[in] stt The handle for STT
-* @param[in] type Recognition type
-* @param[in] data Result data
-* @param[in] data_count Result count
-* @param[in] msg Engine message
+* @param[in] type Recognition type (e.g. #STT_RECOGNITION_TYPE_FREE, #STT_RECOGNITION_TYPE_WEB_SEARCH)
+* @param[in] data Result texts
+* @param[in] data_count Result text count
+* @param[in] msg Engine message        (e.g. #STT_RESULT_MESSAGE_WARNING_TOO_SOON, #STT_RESULT_MESSAGE_ERROR_TOO_SHORT)
 * @param[in] user_data The user data passed from the callback registration function
 *
 * @pre stt_stop() will invoke this callback if you register it using stt_set_result_cb().
@@ -226,10 +216,6 @@ typedef void (*stt_partial_result_cb)(stt_h stt, const char* data, void *user_da
 *
 * @pre An application registers this callback using stt_set_state_changed_cb() to detect changing state.
 *
-* @see stt_start()
-* @see stt_stop()
-* @see stt_cancel()
-* @see stt_result_cb()
 * @see stt_set_state_changed_cb()
 * @see stt_unset_state_changed_cb()
 */
@@ -267,24 +253,23 @@ typedef bool(*stt_supported_language_cb)(stt_h stt, const char* language, void*
 
 
 /**
-* @brief Creates a handle for STT and connects daemon
+* @brief Creates a handle for STT. 
 *
 * @param[out] stt The handle for STT
 *
 * @return 0 on success, otherwise a negative error value
 * @retval #STT_ERROR_NONE Successful
-* @retval #STT_ERROR_TIMED_OUT The daemon is blocked or do not exist
-* @retval #STT_ERROR_ENGINE_NOT_FOUND No available engine \n Engine should be installed
 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #STT_ERROR_OUT_OF_MEMORY Out of memory
 * @retval #STT_ERROR_OPERATION_FAILED Operation failure
 *
+* @post If this function is called, the STT state will be #STT_STATE_CREATED.
+*
 * @see stt_destroy()
 */
 int stt_create(stt_h* stt);
 
 /**
-* @brief Destroys the handle and disconnects the daemon.
+* @brief Destroys the handle.
 *
 * @param[in] stt The handle for STT
 *
@@ -297,6 +282,40 @@ int stt_create(stt_h* stt);
 int stt_destroy(stt_h stt);
 
 /**
+* @brief Connects the daemon. 
+*
+* @param[in] stt The handle for STT
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #STT_ERROR_NONE Successful
+* @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #STT_ERROR_INVALID_STATE Invalid state
+*
+* @pre The state should be #STT_STATE_CREATED.
+* @post If this function is called, the STT state will be #STT_STATE_READY.
+*
+* @see stt_unprepare()
+*/
+int stt_prepare(stt_h stt);
+
+/**
+* @brief Disconnects the daemon.
+*
+* @param[in] stt The handle for STT
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #STT_ERROR_NONE Successful
+* @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #STT_ERROR_INVALID_STATE Invalid state
+*
+* @pre The state should be #STT_STATE_READY.
+* @post If this function is called, the STT state will be #STT_STATE_CREATED.
+*
+* @see stt_prepare()
+*/
+int stt_unprepare(stt_h stt);
+
+/**
 * @brief Retrieves all supported languages of current engine using callback function.
 *
 * @param[in] stt The handle for STT
@@ -385,6 +404,7 @@ int stt_is_partial_result_supported(stt_h stt, bool* partial_result);
 * @retval #STT_ERROR_NONE Successful
 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #STT_ERROR_INVALID_STATE Invalid state
+* @retval #STT_ERROR_NOT_SUPPORTED_FEATURE Not supported feature of current engine
 *
 * @pre The state should be #STT_STATE_READY.
 */
@@ -400,6 +420,7 @@ int stt_set_profanity_filter(stt_h stt, stt_option_profanity_e type);
 * @retval #STT_ERROR_NONE Successful
 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #STT_ERROR_INVALID_STATE Invalid state
+* @retval #STT_ERROR_NOT_SUPPORTED_FEATURE Not supported feature of current engine
 *
 * @pre The state should be #STT_STATE_READY.
 */
@@ -415,6 +436,7 @@ int stt_set_punctuation_override(stt_h stt, stt_option_punctuation_e type);
 * @retval #STT_ERROR_NONE Successful
 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #STT_ERROR_INVALID_STATE Invalid state
+* @retval #STT_ERROR_NOT_SUPPORTED_FEATURE Not supported feature of current engine
 *
 * @pre The state should be #STT_STATE_READY.
 */
@@ -423,12 +445,12 @@ int stt_set_silence_detection(stt_h stt, stt_option_silence_detection_e type);
 /**
 * @brief Starts recording and recognition.
 *
-* @remark This function starts recording in the daemon and sending recording data to engine.
-*      This work continues until stt_stop(), stt_cancel() or silence detected.
+* @remark This function starts recording in the daemon and sending recording data to engine. \n
+* This work continues until stt_stop(), stt_cancel() or silence detected.
 *
 * @param[in] stt The handle for STT
 * @param[in] language The language selected from stt_foreach_supported_languages()
-* @param[in] type The type for recognition (e.g. #RECOGNITION_TYPE_FREE, #RECOGNITION_TYPE_WEB_SEARCH)
+* @param[in] type The type for recognition (e.g. #STT_RECOGNITION_TYPE_FREE, #STT_RECOGNITION_TYPE_WEB_SEARCH)
 *
 * @return 0 on success, otherwise a negative error value
 * @retval #STT_ERROR_NONE Successful
@@ -439,8 +461,8 @@ int stt_set_silence_detection(stt_h stt, stt_option_silence_detection_e type);
 * @retval #STT_ERROR_INVALID_LANGUAGE Invalid language
 *
 * @pre The state should be #STT_STATE_READY.
-* @post It will invoke stt_state_changed_cb(), if you register a callback with stt_state_changed_cb().
-*      If this function succeeds, the STT state will be #STT_STATE_RECORDING.
+* @post It will invoke stt_state_changed_cb(), if you register a callback with stt_state_changed_cb(). \n
+* If this function succeeds, the STT state will be #STT_STATE_RECORDING.
 *
 * @see stt_stop()
 * @see stt_cancel()
@@ -462,9 +484,9 @@ int stt_start(stt_h stt, const char* language, const char* type);
 * @retval #STT_ERROR_OPERATION_FAILED Operation failure
 *
 * @pre The state should be #STT_STATE_RECORDING.
-* @post It will invoke stt_state_changed_cb(), if you register a callback with stt_state_changed_cb().
-*      If this function succeeds, the STT state will be #STT_STATE_PROCESSING.
-*      After processing of engine, stt_result_cb() is called.
+* @post It will invoke stt_state_changed_cb(), if you register a callback with stt_state_changed_cb(). \n
+* If this function succeeds, the STT state will be #STT_STATE_PROCESSING. \n
+* After processing of engine, stt_result_cb() is called.
 *
 * @see stt_start()
 * @see stt_cancel()
@@ -476,9 +498,8 @@ int stt_stop(stt_h stt);
 /**
 * @brief Cancels processing recognition and recording.
 *
-* @remark This function cancels recording and engine cancels recognition processing.
-*      After successful cancel, stt_state_changed_cb() is called otherwise
-*      if error is occurred, stt_error_cb() is called. 
+* @remark This function cancels recording and engine cancels recognition processing. \n
+* After successful cancel, stt_state_changed_cb() is called otherwise if error is occurred, stt_error_cb() is called. 
 *
 * @param[in] stt The handle for STT
 *
@@ -490,8 +511,8 @@ int stt_stop(stt_h stt);
 * @retval #STT_ERROR_OPERATION_FAILED Operation failure
 *
 * @pre The state should be #STT_STATE_RECORDING or #STT_STATE_PROCESSING.
-* @post It will invoke stt_state_changed_cb(), if you register a callback with stt_state_changed_cb().
-*      If this function succeeds, the STT state will be #STT_STATE_READY.
+* @post It will invoke stt_state_changed_cb(), if you register a callback with stt_state_changed_cb(). \n
+* If this function succeeds, the STT state will be #STT_STATE_READY.
 *
 * @see stt_start()
 * @see stt_stop()
@@ -530,7 +551,7 @@ int stt_get_recording_volume(stt_h stt, float* volume);
 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #STT_ERROR_INVALID_STATE Invalid state
 *
-* @pre The state should be #STT_STATE_READY.
+* @pre The state should be #STT_STATE_CREATED.
 *
 * @see stt_result_cb()
 * @see stt_unset_result_cb()
@@ -547,7 +568,7 @@ int stt_set_result_cb(stt_h stt, stt_result_cb callback, void* user_data);
 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #STT_ERROR_INVALID_STATE Invalid state
 *
-* @pre The state should be #STT_STATE_READY.
+* @pre The state should be #STT_STATE_CREATED.
 *
 * @see stt_set_result_cb()
 */
@@ -565,6 +586,8 @@ int stt_unset_result_cb(stt_h stt);
 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #STT_ERROR_INVALID_STATE Invalid state
 *
+* @pre The state should be #STT_STATE_CREATED.
+*
 * @see stt_partial_result_cb()
 * @see stt_unset_partial_result_cb()
 */
@@ -580,7 +603,7 @@ int stt_set_partial_result_cb(stt_h stt, stt_partial_result_cb callback, void* u
 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #STT_ERROR_INVALID_STATE Invalid state
 *
-* @pre The state should be #STT_STATE_READY.
+* @pre The state should be #STT_STATE_CREATED.
 *
 * @see stt_set_partial_result_cb()
 */
@@ -598,7 +621,7 @@ int stt_unset_partial_result_cb(stt_h stt);
 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #STT_ERROR_INVALID_STATE Invalid state
 *
-* @pre The state should be #STT_STATE_READY.
+* @pre The state should be #STT_STATE_CREATED.
 *
 * @see stt_state_changed_cb()
 * @see stt_unset_state_changed_cb()
@@ -615,7 +638,7 @@ int stt_set_state_changed_cb(stt_h stt, stt_state_changed_cb callback, void* use
 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #STT_ERROR_INVALID_STATE Invalid state
 *
-* @pre The state should be #STT_STATE_READY.
+* @pre The state should be #STT_STATE_CREATED.
 *
 * @see stt_set_state_changed_cb()
 */
@@ -633,7 +656,7 @@ int stt_unset_state_changed_cb(stt_h stt);
 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #STT_ERROR_INVALID_STATE Invalid state
 *
-* @pre The state should be #STT_STATE_READY.
+* @pre The state should be #STT_STATE_CREATED.
 *
 * @see stt_error_cb()
 * @see stt_unset_error_cb()
@@ -650,7 +673,7 @@ int stt_set_error_cb(stt_h stt, stt_error_cb callback, void* user_data);
 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #STT_ERROR_INVALID_STATE Invalid state
 *
-* @pre The state should be #STT_STATE_READY.
+* @pre The state should be #STT_STATE_CREATED.
 *
 * @see stt_set_error_cb()
 */
old mode 100644 (file)
new mode 100755 (executable)
index 6bb5772..a6f59ef
@@ -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
@@ -43,7 +43,7 @@ int stt_client_new(stt_h* stt)
 
        client = (stt_client_s*)g_malloc0 (sizeof(stt_client_s));
 
-       stt_h temp = (stt_h)g_malloc0(sizeof(stt_h));
+       stt_h temp = (stt_h)g_malloc0(sizeof(struct stt_s));
        temp->handle = __client_generate_uid(getpid()); 
 
        /* initialize client data */
@@ -60,11 +60,21 @@ int stt_client_new(stt_h* stt)
        client->error_cb = NULL;
        client->error_user_data = NULL;
 
+       client->silence_supported = false;
+       client->profanity_supported = false;
+       client->punctuation_supported = false;
+
        client->profanity = STT_OPTION_PROFANITY_AUTO;  
        client->punctuation = STT_OPTION_PUNCTUATION_AUTO;
        client->silence = STT_OPTION_SILENCE_DETECTION_AUTO;
 
-       client->current_state = STT_STATE_READY; 
+       client->type = NULL;
+       client->data_list = NULL;
+       client->data_count = 0;
+       client->msg = NULL;
+
+       client->before_state = STT_STATE_CREATED;
+       client->current_state = STT_STATE_CREATED; 
 
        client->cb_ref_count = 0;
 
@@ -194,4 +204,19 @@ int stt_client_not_use_callback(stt_client_s* client)
 }
 
 
+int stt_client_set_option_supported(stt_h stt, bool silence, bool profanity, bool punctuation)
+{
+       stt_client_s* client = stt_client_get(stt);
+       
+       /* check handle */
+       if (NULL == client) 
+               return STT_ERROR_INVALID_PARAMETER;
+       
+       client->silence_supported = silence;
+       client->profanity_supported = profanity;
+       client->punctuation_supported = punctuation;
+
+       return 0;
+}
+
 
old mode 100644 (file)
new mode 100755 (executable)
index 3cfa7a1..b5ac5c1
@@ -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,15 +40,30 @@ typedef struct {
        void*                   error_user_data;
 
        /* option */
+       bool    silence_supported;
+       bool    profanity_supported;
+       bool    punctuation_supported;
+
        stt_option_profanity_e          profanity;      
        stt_option_punctuation_e        punctuation;
        stt_option_silence_detection_e  silence;
 
        /* state */
+       stt_state_e     before_state;
        stt_state_e     current_state;
 
        /* mutex */
        int             cb_ref_count;
+
+       /* result data */
+       char*   partial_result;
+       char*   type;
+       char**  data_list;
+       int     data_count;
+       char*   msg;
+
+       /* error data */
+       int     reason;
 }stt_client_s;
 
 int stt_client_new(stt_h* stt);
@@ -65,6 +80,8 @@ int stt_client_use_callback(stt_client_s* client);
 
 int stt_client_not_use_callback(stt_client_s* client);
 
+int stt_client_set_option_supported(stt_h stt, bool silence, bool profanity, bool punctuation);
+
 #ifdef __cplusplus
 }
 #endif
old mode 100644 (file)
new mode 100755 (executable)
index cbfb0cb..7d56081
@@ -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 "stt_defs.h"
 
 #include <Ecore.h>
+#include "stt_client.h"
+
+static int g_waiting_time = 1500;
+static int g_waiting_start_time = 2000;
 
 static Ecore_Fd_Handler* g_fd_handler = NULL;
 
@@ -29,12 +33,13 @@ extern int __stt_cb_result(int uid, const char* type, const char** data, int dat
        
 extern int __stt_cb_partial_result(int uid, const char* data);
 
-extern int __stt_cb_stop_by_daemon(int uid);
+extern int __stt_cb_set_state(int uid, int state);
 
 static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handler)
 {
        DBusConnection* conn = (DBusConnection*)data;
        DBusMessage* msg = NULL;
+       DBusMessage *reply = NULL;
 
        if (NULL == conn)
                return ECORE_CALLBACK_RENEW;
@@ -50,10 +55,131 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
 
        DBusError err;
        dbus_error_init(&err);
+
        char if_name[64];
        snprintf(if_name, 64, "%s%d", STT_CLIENT_SERVICE_INTERFACE, getpid());
 
-       if( dbus_message_is_signal(msg, if_name, STT_SIGNAL_RESULT)) {
+       if (dbus_message_is_method_call(msg, if_name, STTD_METHOD_HELLO)) {
+               SLOG(LOG_DEBUG, TAG_STTC, "===== 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_STTC, "<<<< stt get hello : uid(%d) \n", uid);
+                       
+                       /* check uid */
+                       stt_client_s* client = stt_client_get_by_uid(uid);
+                       if( NULL != client ) 
+                               response = 1;
+                       else 
+                               response = 0;
+               } else {
+                       SLOG(LOG_ERROR, TAG_STTC, "<<<< stt 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_STTC, ">>>> stt get hello : fail to send reply");
+                       else 
+                               SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt get hello : result(%d)", response);
+
+                       dbus_connection_flush(conn);
+                       dbus_message_unref(reply); 
+               } else {
+                       SLOG(LOG_ERROR, TAG_STTC, ">>>> stt get hello : fail to create reply message");
+               }
+               
+               SLOG(LOG_DEBUG, TAG_STTC, "=====");
+               SLOG(LOG_DEBUG, TAG_STTC, " ");
+       } /* STTD_METHOD_HELLO */
+
+       else if (dbus_message_is_method_call(msg, if_name, STTD_METHOD_SET_STATE)) {
+               SLOG(LOG_DEBUG, TAG_STTC, "===== Set State");
+               int uid = 0;
+               int response = -1;
+               int state = -1;
+
+               dbus_message_get_args(msg, &err, 
+                       DBUS_TYPE_INT32, &uid, 
+                       DBUS_TYPE_INT32, &state,
+                       DBUS_TYPE_INVALID);
+
+               if (uid > 0 && state >= 0) {
+                       SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt set state : uid(%d), state(%d)", uid, state);
+
+                       response = __stt_cb_set_state(uid, state);
+               } else {
+                       SLOG(LOG_ERROR, TAG_STTC, "<<<< stt set state : invalid uid or state");
+               }
+
+               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_STTC, ">>>> stt set state : fail to send reply");
+                       else 
+                               SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt set state : result(%d)", response);
+
+                       dbus_connection_flush(conn);
+                       dbus_message_unref(reply); 
+               } else {
+                       SLOG(LOG_ERROR, TAG_STTC, ">>>> stt set state : fail to create reply message");
+               }
+
+               SLOG(LOG_DEBUG, TAG_STTC, "=====");
+               SLOG(LOG_DEBUG, TAG_STTC, " ");
+       } /* STTD_METHOD_SET_STATE */
+
+       else if (dbus_message_is_method_call(msg, if_name, STTD_METHOD_GET_STATE)) {
+               SLOG(LOG_DEBUG, TAG_STTC, "===== Get state");
+               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_STTC, "<<<< stt get state : uid(%d) \n", uid);
+
+                       /* check state */
+                       stt_client_s* client = stt_client_get_by_uid(uid);
+                       if( NULL != client ) 
+                               response = client->current_state;
+                       else 
+                               SLOG(LOG_ERROR, TAG_STTC, "invalid uid \n");
+                       
+               } else {
+                       SLOG(LOG_ERROR, TAG_STTC, "<<<< stt get state : 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_STTC, ">>>> stt get state : fail to send reply");
+                       else 
+                               SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt get state : result(%d)", response);
+
+                       dbus_connection_flush(conn);
+                       dbus_message_unref(reply); 
+               } else {
+                       SLOG(LOG_ERROR, TAG_STTC, ">>>> stt get hello : fail to create reply message");
+               }
+
+               SLOG(LOG_DEBUG, TAG_STTC, "=====");
+               SLOG(LOG_DEBUG, TAG_STTC, " ");
+       } /* STTD_METHOD_GET_STATE */
+
+       else if (dbus_message_is_method_call(msg, if_name, STTD_METHOD_RESULT)) {
                SLOG(LOG_DEBUG, TAG_STTC, "===== Get Result");
                int uid = 0;
                DBusMessageIter args;
@@ -92,7 +218,7 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
                        }
 
                        if (temp_count <= 0) {
-                               SLOG(LOG_ERROR, TAG_STTC, "Result count is 0");
+                               SLOG(LOG_WARN, TAG_STTC, "Result count is 0");
                                __stt_cb_result(uid, temp_type, NULL, 0, temp_msg);
                        } else {
                                temp_result = g_malloc0(temp_count * sizeof(char*));
@@ -122,11 +248,12 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
                } else {
                        SLOG(LOG_ERROR, TAG_STTC, "<<<< stt get result : invalid uid \n");
                } 
+               
                SLOG(LOG_DEBUG, TAG_STTC, "=====");
                SLOG(LOG_DEBUG, TAG_STTC, " ");
-       }/* STT_SIGNAL_RESULT */
+       }/* STTD_METHOD_RESULT */
 
-       else if( dbus_message_is_signal(msg, if_name, STT_SIGNAL_PARTIAL_RESULT)) {
+       else if (dbus_message_is_method_call(msg, if_name, STTD_METHOD_PARTIAL_RESULT)) {
                SLOG(LOG_DEBUG, TAG_STTC, "===== Get Partial Result");
                int uid = 0;
                DBusMessageIter args;
@@ -152,29 +279,12 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
                } else {
                        SLOG(LOG_ERROR, TAG_STTC, "<<<< stt get partial result : invalid uid \n");
                }
-               SLOG(LOG_DEBUG, TAG_STTC, "=====");
-               SLOG(LOG_DEBUG, TAG_STTC, " ");
-       }/* STT_SIGNAL_PARTIAL_RESULT */
 
-       else if( dbus_message_is_signal(msg, if_name, STT_SIGNAL_STOP)) {
-               SLOG(LOG_DEBUG, TAG_STTC, "===== Get Silence Detection");
-               int uid;
-               dbus_message_get_args(msg, &err,
-                       DBUS_TYPE_INT32, &uid,
-                       DBUS_TYPE_INVALID);
-
-               if (dbus_error_is_set(&err)) { 
-                       SLOG(LOG_ERROR, TAG_STTC, "<<<< Get stop by daemon signal : Get arguments error (%s)\n", err.message);
-                       dbus_error_free(&err); 
-               } else {
-                       SLOG(LOG_DEBUG, TAG_STTC, "<<<< Get stop by daemon signal : uid(%d)\n", uid);
-                       __stt_cb_stop_by_daemon(uid);
-               }
                SLOG(LOG_DEBUG, TAG_STTC, "=====");
                SLOG(LOG_DEBUG, TAG_STTC, " ");
-       }/* STT_SIGNAL_STOP */
+       }/* STTD_METHOD_PARTIAL_RESULT */
 
-       else if( dbus_message_is_signal(msg, if_name, STT_SIGNAL_ERROR)) {
+       else if (dbus_message_is_method_call(msg, if_name, STTD_METHOD_ERROR)) {
                SLOG(LOG_DEBUG, TAG_STTC, "===== Get Error");
                int uid;
                int reason;
@@ -187,15 +297,30 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
                        DBUS_TYPE_INVALID);
 
                if (dbus_error_is_set(&err)) { 
-                       SLOG(LOG_ERROR, TAG_STTC, "<<<< Get Error signal : Get arguments error (%s)\n", err.message);
+                       SLOG(LOG_ERROR, TAG_STTC, "<<<< stt Get Error message : Get arguments error (%s)\n", err.message);
                        dbus_error_free(&err); 
                } else {
-                       SLOG(LOG_DEBUG, TAG_STTC, "<<<< Get Error signal : uid(%d), reason(%d), msg(%s)\n", uid, reason, err_msg);
+                       SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt Get Error message : uid(%d), reason(%d), msg(%s)\n", uid, reason, err_msg);
                        __stt_cb_error(uid, reason);
                }
+
+               reply = dbus_message_new_method_return(msg);
+
+               if (NULL != reply) {
+                       if (!dbus_connection_send(conn, reply, NULL))
+                               SLOG(LOG_ERROR, TAG_STTC, ">>>> stt Error message : fail to send reply");
+                       else 
+                               SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt Error message");
+
+                       dbus_connection_flush(conn);
+                       dbus_message_unref(reply); 
+               } else {
+                       SLOG(LOG_ERROR, TAG_STTC, ">>>> stt Error message : fail to create reply message");
+               }
+
                SLOG(LOG_DEBUG, TAG_STTC, "=====");
                SLOG(LOG_DEBUG, TAG_STTC, " ");
-       }/* STT_SIGNAL_ERROR */
+       }/* STTD_METHOD_ERROR */
 
        /* free the message */
        dbus_message_unref(msg);
@@ -299,12 +424,56 @@ int stt_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 stt_dbus_request_initialize(int uid)
+int stt_dbus_request_hello()
+{
+       DBusMessage* msg;
+
+       msg = dbus_message_new_method_call(
+               STT_SERVER_SERVICE_NAME, 
+               STT_SERVER_SERVICE_OBJECT_PATH, 
+               STT_SERVER_SERVICE_INTERFACE, 
+               STT_METHOD_HELLO);
+
+       if (NULL == msg) { 
+               SLOG(LOG_ERROR, TAG_STTC, ">>>> Request stt hello : Fail to make message \n"); 
+               return STT_ERROR_OPERATION_FAILED;
+       } else {
+               SLOG(LOG_DEBUG, TAG_STTC, ">>>> Request stt 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_STTC, "<<<< stt hello");
+               result = 0;
+       } else {
+               SLOG(LOG_ERROR, TAG_STTC, "<<<< stt hello : no response");
+               result = STT_ERROR_OPERATION_FAILED;
+       }
+
+       return result;
+}
+
+
+int stt_dbus_request_initialize(int uid, bool* silence_supported, bool* profanity_supported, bool* punctuation_supported)
 {
        DBusMessage* msg;
 
@@ -333,10 +502,15 @@ int stt_dbus_request_initialize(int uid)
        DBusMessage* result_msg;
        int result = STT_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, g_waiting_time, &err);
 
        if (NULL != result_msg) {
-               dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
+               dbus_message_get_args(result_msg, &err, 
+                       DBUS_TYPE_INT32, &result, 
+                       DBUS_TYPE_INT32, silence_supported,
+                       DBUS_TYPE_INT32, profanity_supported,
+                       DBUS_TYPE_INT32, punctuation_supported,
+                       DBUS_TYPE_INVALID);
 
                if (dbus_error_is_set(&err)) { 
                        SLOG(LOG_ERROR, TAG_STTC, "<<<< Get arguments error (%s)\n", err.message);
@@ -350,7 +524,8 @@ int stt_dbus_request_initialize(int uid)
        }
 
        if (0 == result) {
-               SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt initialize : result = %d \n", result);
+               SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt initialize : result = %d , silence(%d), profanity(%d), punctuation(%d)", 
+                       result, *silence_supported, *profanity_supported, *punctuation_supported);
        } else {
                SLOG(LOG_ERROR, TAG_STTC, "<<<< stt initialize : result = %d \n", result);
        }
@@ -385,7 +560,7 @@ int stt_dbus_request_finalize(int uid)
        DBusMessage* result_msg;
        int result = STT_ERROR_OPERATION_FAILED;
 
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 3000, &err);
+       result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
 
        if (NULL != result_msg) {
                dbus_message_get_args(result_msg, &err, 
@@ -445,7 +620,7 @@ int stt_dbus_request_get_support_langs(int uid, stt_h stt, stt_supported_languag
        DBusMessageIter args;
        int result = STT_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, g_waiting_time, &err );
 
        if (NULL != result_msg) {
                if (dbus_message_iter_init(result_msg, &args)) {
@@ -528,7 +703,7 @@ int stt_dbus_request_get_default_lang(int uid, char** language)
        int result = STT_ERROR_OPERATION_FAILED;
        char* temp_lang = NULL;
 
-       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, g_waiting_time, &err);
 
        if (NULL != result_msg) {
                dbus_message_get_args(result_msg, &err,
@@ -591,7 +766,7 @@ int stt_dbus_request_is_partial_result_supported(int uid, bool* partial_result)
        int result = STT_ERROR_OPERATION_FAILED;
        int support = -1;
 
-       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, g_waiting_time, &err);
 
        if (NULL != result_msg) {
                dbus_message_get_args(result_msg, &err,
@@ -659,7 +834,7 @@ int stt_dbus_request_start(int uid, const char* lang, const char* type, int prof
        DBusMessage* result_msg;
        int result = STT_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, g_waiting_start_time, &err);
 
        if (NULL != result_msg) {
                dbus_message_get_args(result_msg, &err,
@@ -715,7 +890,7 @@ int stt_dbus_request_stop(int uid)
        DBusMessage* result_msg;
        int result = STT_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, g_waiting_time, &err);
 
        if (NULL != result_msg) {
                dbus_message_get_args(result_msg, &err,
@@ -771,7 +946,7 @@ int stt_dbus_request_cancel(int uid)
        DBusMessage* result_msg;
        int result = STT_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, g_waiting_time, &err);
 
        if (NULL != result_msg) {
                dbus_message_get_args(result_msg, &err,
@@ -833,7 +1008,7 @@ int stt_dbus_request_get_audio_volume(int uid, float* volume)
        int result = STT_ERROR_OPERATION_FAILED;
        double vol = 0;
 
-       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, g_waiting_time, &err);
 
        if (NULL != result_msg) {
                dbus_message_get_args(result_msg, &err,
old mode 100644 (file)
new mode 100755 (executable)
index edc40d4..74b8cfb
@@ -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
@@ -27,7 +27,9 @@ int stt_dbus_open_connection();
 int stt_dbus_close_connection();
 
 
-int stt_dbus_request_initialize(int uid);
+int stt_dbus_request_hello();
+
+int stt_dbus_request_initialize(int uid, bool* silence_supported, bool* profanity_supported, bool* punctuation_supported);
 
 int stt_dbus_request_finalize(int uid);
 
old mode 100644 (file)
new mode 100755 (executable)
index bc1ec80..57fd273
@@ -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 cbe49c8..0120fe9
@@ -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 "stt_main.h"
 #include "stt_setting.h"
 #include "stt_setting_dbus.h"
 
-static bool g_is_setting_initialized = false;
 
-static int __check_stt_daemon();
+static int __check_setting_stt_daemon();
+
+static bool g_is_daemon_started = false;
+
+static stt_setting_state_e g_state = STT_SETTING_STATE_NONE;
+
+static stt_setting_initialized_cb g_initialized_cb;
+
+static void* g_user_data;
+
+static int g_reason;
+
+/* API Implementation */
+static Eina_Bool __stt_setting_initialized(void *data)
+{
+       g_initialized_cb(g_state, g_reason, g_user_data);
+
+       return EINA_FALSE;
+}
+
+static Eina_Bool __stt_setting_connect_daemon(void *data)
+{
+       /* Send hello */
+       if (0 != stt_setting_dbus_request_hello()) {
+               if (false == g_is_daemon_started) {
+                       g_is_daemon_started = true;
+                       __check_setting_stt_daemon();
+               }
+               return EINA_TRUE;
+       }
+
+       SLOG(LOG_DEBUG, TAG_STTC, "===== Connect daemon");
+
+       /* do request initialize */
+       int ret = -1;
+
+       ret = stt_setting_dbus_request_initialize();
+
+       if (STT_SETTING_ERROR_ENGINE_NOT_FOUND == ret) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Engine not found");
+       } else if (STT_SETTING_ERROR_NONE != ret) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to connection : %d", ret);
+       } else {
+               /* success to connect stt-daemon */
+               g_state = STT_SETTING_STATE_READY;
+       }
+
+       g_reason = ret;
+
+       ecore_timer_add(0, __stt_setting_initialized, NULL);
+
+       SLOG(LOG_DEBUG, TAG_STTC, "=====");
+       SLOG(LOG_DEBUG, TAG_STTC, " ");
+
+       return EINA_FALSE;
+}
 
 int stt_setting_initialize ()
 {
        SLOG(LOG_DEBUG, TAG_STTC, "===== Initialize STT Setting");
 
        int ret = 0;
-
-       /* Check daemon */
-       __check_stt_daemon();
-
-       if (true == g_is_setting_initialized) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] STT Setting has already been initialized. \n");
+       if (STT_SETTING_STATE_READY == g_state) {
+               SLOG(LOG_WARN, TAG_STTC, "[WARNING] STT Setting has already been initialized. \n");
                SLOG(LOG_DEBUG, TAG_STTC, "=====");
                SLOG(LOG_DEBUG, TAG_STTC, " ");
-               return STT_SETTING_ERROR_INVALID_STATE;
+               return STT_SETTING_ERROR_NONE;
        }
 
        if (0 != stt_setting_dbus_open_connection()) {
@@ -45,8 +99,13 @@ int stt_setting_initialize ()
                return STT_SETTING_ERROR_OPERATION_FAILED;
        }
 
+       /* Send hello */
+       if (0 != stt_setting_dbus_request_hello()) {
+               __check_setting_stt_daemon();
+       }
+
        /* do request */
-       int i = 0;
+       int i = 1;
        while(1) {
                ret = stt_setting_dbus_request_initialize();
 
@@ -55,7 +114,7 @@ int stt_setting_initialize ()
                        break;
                } else if(ret) {
                        sleep(1);
-                       if (i == 10) {
+                       if (i == 3) {
                                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Connection Time out");
                                ret = STT_SETTING_ERROR_TIMED_OUT;                          
                                break;
@@ -67,8 +126,8 @@ int stt_setting_initialize ()
                }
        }
 
-       if (0 == ret) {
-               g_is_setting_initialized = true;
+       if (STT_SETTING_ERROR_NONE == ret) {
+               g_state = STT_SETTING_STATE_READY;
                SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Initialize");
        }
 
@@ -78,6 +137,34 @@ int stt_setting_initialize ()
        return ret;
 }
 
+int stt_setting_initialize_async(stt_setting_initialized_cb callback, void* user_data)
+{
+       SLOG(LOG_DEBUG, TAG_STTC, "===== Initialize STT Setting");
+
+       if (STT_SETTING_STATE_READY == g_state) {
+               SLOG(LOG_WARN, TAG_STTC, "[WARNING] STT Setting has already been initialized. \n");
+               SLOG(LOG_DEBUG, TAG_STTC, "=====");
+               SLOG(LOG_DEBUG, TAG_STTC, " ");
+               return STT_SETTING_ERROR_NONE;
+       }
+
+       if( 0 != stt_setting_dbus_open_connection() ) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to open connection\n ");
+               SLOG(LOG_DEBUG, TAG_STTC, "=====");
+               SLOG(LOG_DEBUG, TAG_STTC, " ");
+               return STT_SETTING_ERROR_OPERATION_FAILED;
+       }
+
+       g_initialized_cb = callback;
+       g_user_data = user_data;
+
+       ecore_timer_add(0, __stt_setting_connect_daemon, NULL);
+
+       SLOG(LOG_DEBUG, TAG_STTC, "=====");
+       SLOG(LOG_DEBUG, TAG_STTC, " ");
+
+       return STT_SETTING_ERROR_NONE;
+}
 
 int stt_setting_finalize ()
 {
@@ -85,8 +172,8 @@ int stt_setting_finalize ()
        
        int ret = 0;
 
-       if (false == g_is_setting_initialized) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Not initialized");
+       if (STT_SETTING_STATE_NONE == g_state) {
+               SLOG(LOG_WARN, TAG_STTC, "[WARNING] Not initialized");
                SLOG(LOG_DEBUG, TAG_STTC, "=====");
                SLOG(LOG_DEBUG, TAG_STTC, " ");
                return STT_SETTING_ERROR_INVALID_STATE;
@@ -106,7 +193,7 @@ int stt_setting_finalize ()
                SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Finalize");
        }
 
-       g_is_setting_initialized = false;
+       g_state = STT_SETTING_STATE_NONE;
 
        SLOG(LOG_DEBUG, TAG_STTC, "=====");
        SLOG(LOG_DEBUG, TAG_STTC, " ");
@@ -118,7 +205,7 @@ int stt_setting_foreach_supported_engines(stt_setting_supported_engine_cb callba
 {
        SLOG(LOG_DEBUG, TAG_STTC, "===== Foreach supported engines");
 
-       if (false == g_is_setting_initialized) {
+       if (STT_SETTING_STATE_NONE == g_state) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Not initialized");
                SLOG(LOG_DEBUG, TAG_STTC, "=====");
                SLOG(LOG_DEBUG, TAG_STTC, " ");
@@ -149,7 +236,7 @@ int stt_setting_get_engine(char** engine_id)
 {
        SLOG(LOG_DEBUG, TAG_STTC, "===== Get current engine");
 
-       if (false == g_is_setting_initialized) {
+       if (STT_SETTING_STATE_NONE == g_state) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Not initialized");
                SLOG(LOG_DEBUG, TAG_STTC, "=====");
                SLOG(LOG_DEBUG, TAG_STTC, " ");
@@ -180,7 +267,7 @@ int stt_setting_set_engine(const char* engine_id)
 {
        SLOG(LOG_DEBUG, TAG_STTC, "===== Set current engine");
 
-       if (false == g_is_setting_initialized) {
+       if (STT_SETTING_STATE_NONE == g_state) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Not initialized");
                SLOG(LOG_DEBUG, TAG_STTC, "=====");
                SLOG(LOG_DEBUG, TAG_STTC, " ");
@@ -211,7 +298,7 @@ int stt_setting_foreach_supported_languages(stt_setting_supported_language_cb ca
 {
        SLOG(LOG_DEBUG, TAG_STTC, "===== Foreach supported languages");
 
-       if (false == g_is_setting_initialized) {
+       if (STT_SETTING_STATE_NONE == g_state) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Not initialized");
                SLOG(LOG_DEBUG, TAG_STTC, "=====");
                SLOG(LOG_DEBUG, TAG_STTC, " ");
@@ -243,7 +330,7 @@ int stt_setting_get_default_language(char** language)
 {
        SLOG(LOG_DEBUG, TAG_STTC, "===== Get default language");
 
-       if (false == g_is_setting_initialized) {
+       if (STT_SETTING_STATE_NONE == g_state) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Not initialized");
                SLOG(LOG_DEBUG, TAG_STTC, "=====");
                SLOG(LOG_DEBUG, TAG_STTC, " ");
@@ -274,7 +361,7 @@ int stt_setting_set_default_language(const char* language)
 {
        SLOG(LOG_DEBUG, TAG_STTC, "===== Set default language");
 
-       if (false == g_is_setting_initialized) {
+       if (STT_SETTING_STATE_NONE == g_state) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Not initialized");
                SLOG(LOG_DEBUG, TAG_STTC, "=====");
                SLOG(LOG_DEBUG, TAG_STTC, " ");
@@ -307,7 +394,7 @@ int stt_setting_get_profanity_filter(bool* value)
 
        int ret = 0;
 
-       if (false == g_is_setting_initialized) {
+       if (STT_SETTING_STATE_NONE == g_state) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Not initialized");
                SLOG(LOG_DEBUG, TAG_STTC, "=====");
                SLOG(LOG_DEBUG, TAG_STTC, " ");
@@ -340,7 +427,7 @@ int stt_setting_set_profanity_filter(const bool value)
 
        int ret = 0;
 
-       if (!g_is_setting_initialized) {
+       if (STT_SETTING_STATE_NONE == g_state) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] not initialized");
                SLOG(LOG_DEBUG, TAG_STTC, "=====");
                SLOG(LOG_DEBUG, TAG_STTC, " ");
@@ -366,7 +453,7 @@ int stt_setting_get_punctuation_override(bool* value)
 
        int ret = 0;
 
-       if (!g_is_setting_initialized) {
+       if (STT_SETTING_STATE_NONE == g_state) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] not initialized");
                SLOG(LOG_DEBUG, TAG_STTC, "=====");
                SLOG(LOG_DEBUG, TAG_STTC, " ");
@@ -399,7 +486,7 @@ int stt_setting_set_punctuation_override(bool value)
 
        int ret = 0;
 
-       if (!g_is_setting_initialized) {
+       if (STT_SETTING_STATE_NONE == g_state) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] not initialized");
                SLOG(LOG_DEBUG, TAG_STTC, "=====");
                SLOG(LOG_DEBUG, TAG_STTC, " ");
@@ -425,7 +512,7 @@ int stt_setting_get_silence_detection(bool* value)
 
        int ret = 0;
 
-       if (!g_is_setting_initialized) {
+       if (STT_SETTING_STATE_NONE == g_state) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] not initialized");
                SLOG(LOG_DEBUG, TAG_STTC, "=====");
                SLOG(LOG_DEBUG, TAG_STTC, " ");
@@ -458,7 +545,7 @@ int stt_setting_set_silence_detection(bool value)
 
        int ret = 0;
 
-       if (!g_is_setting_initialized) {
+       if (STT_SETTING_STATE_NONE == g_state) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] not initialized");
                SLOG(LOG_DEBUG, TAG_STTC, "=====");
                SLOG(LOG_DEBUG, TAG_STTC, " ");
@@ -484,7 +571,7 @@ int stt_setting_foreach_engine_settings(stt_setting_engine_setting_cb callback,
 
        int ret = 0;
 
-       if (!g_is_setting_initialized) {
+       if (STT_SETTING_STATE_NONE == g_state) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] not initialized");
                SLOG(LOG_DEBUG, TAG_STTC, "=====");
                SLOG(LOG_DEBUG, TAG_STTC, " ");
@@ -517,7 +604,7 @@ int stt_setting_set_engine_setting(const char* key, const char* value)
 
        int ret = 0;
 
-       if (!g_is_setting_initialized) {
+       if (STT_SETTING_STATE_NONE == g_state) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] not initialized");
                return STT_SETTING_ERROR_INVALID_STATE;
        }
@@ -540,48 +627,71 @@ int stt_setting_set_engine_setting(const char* key, const char* value)
        return ret;
 }
 
-static bool __stt_is_alive()
+int __setting_get_cmd_line(char *file, char *buf) 
 {
        FILE *fp = NULL;
-       char buff[256] = {'\0',};
-       char cmd[256] = {'\0',};
-       int i=0;
+       int i;
 
-       memset(buff, '\0', sizeof(char));
-       memset(cmd, '\0', sizeof(char));
+       fp = fopen(file, "r");
+       if (fp == NULL) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Get command line");
+               return -1;
+       }
 
-       if ((fp = popen("ps -eo \"cmd\"", "r")) == NULL) {
-               SLOG(LOG_DEBUG, TAG_STTC, "[STT ERROR] popen error \n");
+       memset(buf, 0, 256);
+       fgets(buf, 256, fp);
+       fclose(fp);
+
+       return 0;
+}
+
+static bool __stt_setting_is_alive()
+{
+       DIR *dir;
+       struct dirent *entry;
+       struct stat filestat;
+       
+       int pid;
+       char cmdLine[256];
+       char tempPath[256];
+
+       dir  = opendir("/proc");
+       if (NULL == dir) {
+               SLOG(LOG_ERROR, TAG_STTC, "process checking is FAILED");
                return FALSE;
        }
 
-       while (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;
+
+               pid = atoi(entry->d_name);
+               if (pid <= 0) continue;
 
-               if( 0 == strncmp(cmd, "[stt-daemon]", strlen("[stt-daemon]")) ||
-                       0 == strncmp(cmd, "stt-daemon", strlen("stt-daemon")) ||
-                       0 == strncmp(cmd, "/usr/bin/stt-daemon", strlen("/usr/bin/stt-daemon"))
-                       ) {
-                       SLOG(LOG_DEBUG, TAG_STTC, "stt-daemon is ALIVE !! \n");
-                       fclose(fp);
-                       return TRUE;
+               sprintf(tempPath, "/proc/%d/cmdline", pid);
+               if (0 != __setting_get_cmd_line(tempPath, cmdLine)) {
+                       continue;
                }
 
-               i++;
+               if ( 0 == strncmp(cmdLine, "[stt-daemon]", strlen("[stt-daemon]")) ||
+                       0 == strncmp(cmdLine, "stt-daemon", strlen("stt-daemon")) ||
+                       0 == strncmp(cmdLine, "/usr/bin/stt-daemon", strlen("/usr/bin/stt-daemon"))) {
+                               SLOG(LOG_DEBUG, TAG_STTC, "stt-daemon is ALIVE !! \n");
+                               closedir(dir);
+                               return TRUE;
+               }
        }
-       fclose(fp);
-
        SLOG(LOG_DEBUG, TAG_STTC, "THERE IS NO stt-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 = 0;
        pid_t child_pid, child_pgid;
@@ -597,18 +707,16 @@ static void __my_sig_child(int signo, siginfo_t *info, void *data)
        return;
 }
 
-int __check_stt_daemon()
+int __check_setting_stt_daemon()
 {
-       if (TRUE == __stt_is_alive()) 
+       if (TRUE == __stt_setting_is_alive()) 
                return 0;
        
        /* fork-exec stt-daemom */
-       SLOG(LOG_DEBUG, TAG_STTC, "THERE IS NO stt-daemon \n");
-
        int pid = 0, i = 0;
        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;
        
@@ -621,7 +729,7 @@ int __check_stt_daemon()
 
        switch(pid) {
        case -1:
-               SLOG(LOG_DEBUG, TAG_STTC, "fail to create STT-DAEMON \n");
+               SLOG(LOG_DEBUG, TAG_STTC, "Fail to create stt-daemon");
                break;
 
        case 0:
@@ -633,7 +741,6 @@ int __check_stt_daemon()
                break;
 
        default:
-               sleep(1);
                break;
        }
 
old mode 100644 (file)
new mode 100755 (executable)
index 69731f9..903f203
@@ -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
@@ -35,13 +35,23 @@ typedef enum {
        STT_SETTING_ERROR_OUT_OF_MEMORY         = -ENOMEM,      /**< Out of Memory */
        STT_SETTING_ERROR_IO_ERROR              = -EIO,         /**< I/O error */
        STT_SETTING_ERROR_INVALID_PARAMETER     = -EINVAL,      /**< Invalid parameter */
-       STT_SETTING_ERROR_INVALID_STATE         = -0x0100021,   /**< Invalid state */
-       STT_SETTING_ERROR_INVALID_LANGUAGE      = -0x0100022,   /**< Invalid language */
-       STT_SETTING_ERROR_ENGINE_NOT_FOUND      = -0x0100023,   /**< No available STT-engine  */
-       STT_SETTING_ERROR_TIMED_OUT             = -0x0100024,   /**< No answer from STT daemon */
-       STT_SETTING_ERROR_OPERATION_FAILED      = -0x0100025,   /**< STT daemon failed  */
+       STT_SETTING_ERROR_TIMED_OUT             = -ETIMEDOUT,   /**< No answer from the daemon */
+       STT_SETTING_ERROR_OUT_OF_NETWORK        = -ENETDOWN,    /**< Out of network */
+       STT_SETTING_ERROR_INVALID_STATE         = -0x0100031,   /**< Invalid state */
+       STT_SETTING_ERROR_INVALID_LANGUAGE      = -0x0100032,   /**< Invalid language */
+       STT_SETTING_ERROR_ENGINE_NOT_FOUND      = -0x0100033,   /**< No available STT-engine  */
+       STT_SETTING_ERROR_OPERATION_FAILED      = -0x0100034,   /**< STT daemon failed  */
+       STT_SETTING_ERROR_NOT_SUPPORTED_FEATURE = -0x0100035    /**< Not supported feature of current engine */
 }stt_setting_error_e;
 
+/** 
+* @brief Enumerations of setting state.
+*/
+typedef enum {
+       STT_SETTING_STATE_NONE = 0,
+       STT_SETTING_STATE_READY
+} stt_setting_state_e;
+
 /**
 * @brief Called to get a engine information.
 *
@@ -88,6 +98,18 @@ typedef bool(*stt_setting_supported_language_cb)(const char* engine_id, const ch
 */
 typedef bool(*stt_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 stt_setting_initialize_async().
+*
+* @pre stt_setting_initialize_async() will invoke this callback. 
+*
+* @see stt_setting_initialize_async()
+*/
+typedef void(*stt_setting_initialized_cb)(stt_setting_state_e state, stt_setting_error_e reason, void* user_data);
 
 /**
 * @brief Initialize STT setting and connect to stt-daemon.
@@ -101,6 +123,7 @@ typedef bool(*stt_setting_engine_setting_cb)(const char* engine_id, const char*
 * @see stt_setting_finalize()
 */
 int stt_setting_initialize(void);
+int stt_setting_initialize_async(stt_setting_initialized_cb callback, void* user_data);
 
 /**
 * @brief finalize stt setting and disconnect to stt-daemon. 
old mode 100644 (file)
new mode 100755 (executable)
index 1b35c61..385b5f6
@@ -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,8 @@
 #include "stt_main.h"
 #include "stt_setting_dbus.h"
 
+static int g_waiting_time = 1500;
+
 static DBusConnection* g_conn = NULL;
 
 int stt_setting_dbus_open_connection()
@@ -80,11 +82,54 @@ int stt_setting_dbus_close_connection()
 
        dbus_bus_release_name(g_conn, service_name, &err);
 
+       dbus_connection_close(g_conn);
+
        g_conn = NULL;
 
        return 0;
 }
 
+
+int stt_setting_dbus_request_hello()
+{
+       DBusMessage* msg;
+
+       msg = dbus_message_new_method_call(
+               STT_SERVER_SERVICE_NAME, 
+               STT_SERVER_SERVICE_OBJECT_PATH, 
+               STT_SERVER_SERVICE_INTERFACE, 
+               STT_SETTING_METHOD_HELLO);
+
+       if (NULL == msg) { 
+               SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting hello : Fail to make message \n"); 
+               return STT_SETTING_ERROR_OPERATION_FAILED;
+       } else {
+               SLOG(LOG_DEBUG, TAG_STTC, ">>>> 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_STTC, "<<<< setting hello");
+               result = 0;
+       } else {
+               SLOG(LOG_ERROR, TAG_STTC, "<<<< setting hello : no response");
+               result = -1;
+       }
+
+       return result;
+}
+
 int stt_setting_dbus_request_initialize()
 {
        DBusMessage* msg;
@@ -114,7 +159,7 @@ int stt_setting_dbus_request_initialize()
        DBusMessage* result_msg;
        int result = STT_SETTING_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, g_waiting_time, &err);
 
        if (NULL != result_msg) {
                dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
@@ -165,7 +210,7 @@ int stt_setting_dbus_request_finalilze(void)
        DBusMessage* result_msg;
        int result = STT_SETTING_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, g_waiting_time, &err);
 
        if (NULL != result_msg) {
                dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
@@ -221,7 +266,7 @@ int stt_setting_dbus_request_get_engine_list(stt_setting_supported_engine_cb cal
        DBusMessage* result_msg;
        int result = STT_SETTING_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, g_waiting_time, &err);
 
        if (NULL != result_msg) {
                DBusMessageIter args;
@@ -313,7 +358,7 @@ int stt_setting_dbus_request_get_engine(char** engine_id)
        int result = STT_SETTING_ERROR_OPERATION_FAILED;
        char* temp;
 
-       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, g_waiting_time, &err);
 
        if (NULL != result_msg) {
                dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_STRING, &temp, DBUS_TYPE_INVALID);
@@ -379,7 +424,7 @@ int stt_setting_dbus_request_set_engine(const char* engine_id)
        DBusMessage* result_msg;
        int result = STT_SETTING_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, g_waiting_time, &err);
 
        if (NULL != result_msg) {
                dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
@@ -437,7 +482,7 @@ int stt_setting_dbus_request_get_language_list(stt_setting_supported_language_cb
        DBusMessage* result_msg;
        int result = STT_SETTING_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, g_waiting_time, &err);
 
        if (NULL != result_msg) {
                DBusMessageIter args;
@@ -531,7 +576,7 @@ int stt_setting_dbus_request_get_default_language(char** language)
        int result = STT_SETTING_ERROR_OPERATION_FAILED;
        char* temp_char;
 
-       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, g_waiting_time, &err);
 
        if (NULL != result_msg) {
                dbus_message_get_args(result_msg, &err, 
@@ -602,7 +647,7 @@ int stt_setting_dbus_request_set_default_language(const char* language)
        DBusMessage* result_msg;
        int result = STT_SETTING_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, g_waiting_time, &err);
 
        if (NULL != result_msg) {
                dbus_message_get_args(result_msg, &err, 
@@ -663,7 +708,7 @@ int stt_setting_dbus_request_get_engine_setting(stt_setting_engine_setting_cb ca
        DBusMessage* result_msg;
        int result = STT_SETTING_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, g_waiting_time, &err);
 
        if (NULL != result_msg) {
                DBusMessageIter args;
@@ -761,7 +806,7 @@ int stt_setting_dbus_request_set_engine_setting(const char* key, const char* val
        DBusMessage* result_msg;
        int result = STT_SETTING_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, g_waiting_time, &err);
 
        if (NULL != result_msg) {
                dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
@@ -819,7 +864,7 @@ int stt_setting_dbus_request_get_profanity_filter(bool* value)
        DBusMessage* result_msg;
        int result = STT_SETTING_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, g_waiting_time, &err);
 
        if (NULL != result_msg) {
                dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INT32, value, DBUS_TYPE_INVALID);
@@ -874,7 +919,7 @@ int stt_setting_dbus_request_set_profanity_filter(const bool value)
        DBusMessage* result_msg;
        int result = STT_SETTING_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, g_waiting_time, &err);
 
        if (NULL != result_msg) {
                dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
@@ -933,7 +978,7 @@ int stt_setting_dbus_request_get_punctuation_override(bool* value)
        DBusMessage* result_msg;
        int result = STT_SETTING_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, g_waiting_time, &err);
 
        if (NULL != result_msg) {
                dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INT32, value, DBUS_TYPE_INVALID);
@@ -988,7 +1033,7 @@ int stt_setting_dbus_request_set_punctuation_override(const bool value )
        DBusMessage* result_msg;
        int result = STT_SETTING_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, g_waiting_time, &err);
 
        if (NULL != result_msg) {
                dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
@@ -1048,7 +1093,7 @@ int stt_setting_dbus_request_get_silence_detection(bool* value)
        DBusMessage* result_msg;
        int result = STT_SETTING_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, g_waiting_time, &err);
 
        if (NULL == result_msg) {
                dbus_message_unref(msg);
@@ -1100,7 +1145,7 @@ int stt_setting_dbus_request_set_silence_detection(const bool value)
        DBusMessage* result_msg;
        int result = STT_SETTING_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, g_waiting_time, &err);
 
        if (NULL != result_msg) {
                dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
old mode 100644 (file)
new mode 100755 (executable)
index 4e5d19f..c642359
@@ -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,8 @@ int stt_setting_dbus_open_connection();
 int stt_setting_dbus_close_connection();
 
 
+int stt_setting_dbus_request_hello();
+
 int stt_setting_dbus_request_initialize();
 
 int stt_setting_dbus_request_finalilze();
index 3efe94c..3f4f4fc 100644 (file)
@@ -37,9 +37,10 @@ extern "C" {
 
 
 /******************************************************************************************
-* Message Definition for APIs
+* Message Definition for Client
 *******************************************************************************************/
 
+#define STT_METHOD_HELLO               "stt_method_hello"
 #define STT_METHOD_INITIALIZE          "stt_method_initialize"
 #define STT_METHOD_FINALIZE            "stt_method_finalilze"
 #define STT_METHOD_GET_SUPPORT_LANGS   "stt_method_get_support_langs"
@@ -51,18 +52,20 @@ extern "C" {
 #define STT_METHOD_STOP                        "stt_method_stop"
 #define STT_METHOD_CANCEL              "stt_method_cancel"
 
-#define STT_SIGNAL_RESULT              "stt_signal_result"
-#define STT_SIGNAL_PARTIAL_RESULT      "stt_signal_partial_result"
-#define STT_SIGNAL_STOP                        "stt_signal_stop"
-#define STT_SIGNAL_ERROR               "stt_signal_error"
-
-#define STT_SIGNAL_STOP_BY_DAEMON      "STT_SIGNAL_STOP_BY_DAEMON"
+#define STTD_METHOD_RESULT             "sttd_method_result"
+#define STTD_METHOD_PARTIAL_RESULT     "sttd_method_partial_result"
+#define STTD_METHOD_ERROR              "sttd_method_error"
+#define STTD_METHOD_HELLO              "sttd_method_hello"
+#define STTD_METHOD_SET_STATE          "sttd_method_set_state"
+#define STTD_METHOD_GET_STATE          "sttd_method_get_state"
 
+#define STTD_METHOD_STOP_BY_DAEMON     "sttd_method_stop_by_daemon"
 
 /******************************************************************************************
 * Message Definition for Setting
 *******************************************************************************************/
 
+#define STT_SETTING_METHOD_HELLO               "stt_setting_method_hello"
 #define STT_SETTING_METHOD_INITIALIZE          "stt_setting_method_initialize"
 #define STT_SETTING_METHOD_FINALIZE            "stt_setting_method_finalilze"
 #define STT_SETTING_METHOD_GET_ENGINE_LIST     "stt_setting_method_get_engine_list"
index f484f8e..cff1fe2 100644 (file)
@@ -1,7 +1,244 @@
-stt (0.1.1) unstable; urgency=low
+stt (0.1.1-31slp2+1) unstable; urgency=low
 
-  * Beta release
-  * Git: tizen2/pkgs/s/stt
-  * Tag: stt_0.1.1
+  * Change License and notice file
 
- -- Dongyeol Lee <dy3.lee@samsung.com>  Fri, 17 Feb 2012 13:49:31 +0900
+ -- Kwangyoun Kim <ky85.kim@samsung.com>  Wed, 23 Jan 2013 15:24:59 +0900
+
+stt (0.1.1-30slp2+1) unstable; urgency=low
+
+  * Change License file
+  * Git: /framework/uifw/voice/stt
+  * Tag: stt_0.1.1-30slp2+1
+
+ -- Kwangyoun Kim <ky85.kim@samsung.com>  Wed, 16 Jan 2013 18:39:32 +0900
+
+stt (0.1.1-29slp2+1) unstable; urgency=low
+
+  * Fix prevent issues and delete unused define
+  * Git: /framework/uifw/voice/stt
+  * Tag: stt_0.1.1-29slp2+1
+
+ -- Kwangyoun Kim <ky85.kim@samsung.com>  Thu, 03 Jan 2013 16:55:13 +0900
+
+stt (0.1.1-28slp2+1) unstable; urgency=low
+
+  * Fix prevent issues
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Tue, 18 Dec 2012 12:59:35 +0900
+
+stt (0.1.1-27slp2+1) unstable; urgency=low
+
+  * Fix prevent issue and PLM issue(popen&pclose)
+  * Git: /framework/uifw/voice/stt
+  * Tag: stt_0.1.1-27slp2+1
+
+ -- Kwangyoun Kim <ky85.kim@samsung.com>  Thu, 13 Dec 2012 17:10:03 +0900
+
+stt (0.1.1-26slp2+1) unstable; urgency=low
+
+  * Remove dependency of openssl
+  * Git: /framework/uifw/voice/stt
+  * Tag: stt_0.1.1-26slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Thu, 22 Nov 2012 17:07:23 +0900
+
+stt (0.1.1-25slp2+1) unstable; urgency=low
+
+  * Add license and manifest files
+  * Fix error code value and config loadiing(include directory change) 
+  * Add tag for binary merge
+  * Git: /framework/uifw/voice/stt
+  * Tag: stt_0.1.1-25slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Fri, 19 Oct 2012 14:54:28 +0900
+
+stt (0.1.1-24slp2+1) unstable; urgency=low
+
+  * update API for asynchronous init 
+  * Git: slp/pkgs/s/stt
+  * Tag: stt_0.1.1-24slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Mon, 04 Jun 2012 16:39:43 +0900
+
+stt (0.1.1-23slp2+1) unstable; urgency=low
+
+  * update config and time out during processing and recording 
+  * Git: slp/pkgs/s/stt
+  * Tag: stt_0.1.1-23slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Wed, 23 May 2012 15:34:39 +0900
+
+stt (0.1.1-22slp2+1) unstable; urgency=low
+
+  * update for identifical state of client and daemon 
+  * Git: slp/pkgs/s/stt
+  * Tag: stt_0.1.1-22slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Wed, 04 Apr 2012 20:42:16 +0900
+
+stt (0.1.1-21slp2+1) unstable; urgency=low
+
+  * fix bug about fork daemon 
+  * Git: slp/pkgs/s/stt
+  * Tag: stt_0.1.1-21slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Mon, 26 Mar 2012 15:57:46 +0900
+
+stt (0.1.1-20slp2+1) unstable; urgency=low
+
+  * update changelog 
+  * Git: slp/pkgs/s/stt
+  * Tag: stt_0.1.1-20slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Mon, 19 Mar 2012 19:05:18 +0900
+
+stt (0.1.1-19slp2+1) unstable; urgency=low
+
+  * update bug fix of ipc 
+  * Git: slp/pkgs/s/stt
+  * Tag: stt_0.1.1-19slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Mon, 19 Mar 2012 10:54:03 +0900
+
+stt (0.1.1-18slp2+1) unstable; urgency=low
+
+  * fix bug for not supported feature of engine 
+  * Git: slp/pkgs/s/stt
+  * Tag: stt_0.1.1-18slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Wed, 14 Mar 2012 17:19:18 +0900
+
+stt (0.1.1-17slp2+1) unstable; urgency=low
+
+  * API update for recognition message 
+  * Git: slp/pkgs/s/stt
+  * Tag: stt_0.1.1-17slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Wed, 07 Mar 2012 16:23:50 +0900
+
+stt (0.1.1-16slp2+1) unstable; urgency=low
+
+  * code cleanup for beta release 
+  * Git: slp/pkgs/s/stt
+  * Tag: stt_0.1.1-16slp2+1 
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Fri, 17 Feb 2012 15:46:19 +0900
+
+stt (0.1.1-15slp2+1) unstable; urgency=low
+
+  * bug fix about recording and update api 
+  * Git: slp/pkgs/s/stt
+  * Tag: stt_0.1.1-15slp2+1 
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Thu, 16 Feb 2012 11:28:54 +0900
+
+stt (0.1.1-14slp2+1) unstable; urgency=low
+
+  * update api for setting options
+  * Git: slp/pkgs/s/stt
+  * Tag: stt_0.1.1-14slp2+1 
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Fri, 20 Jan 2012 10:15:22 +0900
+
+stt (0.1.1-13slp2+1) unstable; urgency=low
+
+  * update engine api
+  * Git: slp/pkgs/s/stt
+  * Tag: stt_0.1.1-13slp2+1 
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Thu, 05 Jan 2012 15:58:32 +0900
+
+stt (0.1.1-12slp2+1) unstable; urgency=low
+
+  * update API
+  * Git: slp/pkgs/s/stt
+  * Tag: stt_0.1.1-12slp2+1 
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Thu, 15 Dec 2011 13:54:55 +0900
+
+stt (0.1.1-11slp2+1) unstable; urgency=low
+
+  * change boiler plate
+  * Git: 165.213.180.234:slp/pkgs/s/stt
+  * Tag: stt_0.1.1-11slp2+1 
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Fri, 02 Dec 2011 10:40:19 +0900
+
+stt (0.1.1-10slp2+1) unstable; urgency=low
+
+  * update for connman
+  * Git: 165.213.180.234:slp/pkgs/s/stt
+  * Tag: stt_0.1.1-10slp2+1 
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Tue, 29 Nov 2011 16:16:10 +0900
+
+stt (0.1.1-9slp2+1) unstable; urgency=low
+
+  * update API for voice talk 
+  * Git: 165.213.180.234:slp/pkgs/s/stt
+  * Tag: stt_0.1.1-9slp2+1 
+
+ -- Dongyeol Lee <dy3.lee@samsung.com> Thu, 24 Nov 2011 15:18:02 +0900
+
+stt (0.1.1-8slp2+1) unstable; urgency=low
+
+  * update bug of prevent and remove dependency of gtk
+  * Git: 165.213.180.234:slp/pkgs/s/stt
+  * Tag: stt_0.1.1-8slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Wed, 07 Sep 2011 14:14:07 +0900
+
+stt (0.1.1-7slp2+1) unstable; urgency=low
+
+  * fix control file for build error
+  * Git: 165.213.180.234:slp/pkgs/s/stt
+  * Tag: stt_0.1.1-7slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Thu, 01 Sep 2011 19:27:24 +0900
+
+stt (0.1.1-6slp2+1) unstable; urgency=low
+
+  * update recorder, IPC and network module. add API for bada
+  * Git: 165.213.180.234:slp/pkgs/s/stt
+  * Tag: stt_0.1.1-6slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Thu, 25 Aug 2011 11:26:32 +0900
+
+stt (0.1.1-5slp2+1) unstable; urgency=low
+
+  * fix defect from prevent
+  * Git: 165.213.180.234:slp/pkgs/s/stt
+  * Tag: stt_0.1.1-5slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Tue, 07 Jun 2011 17:02:49 +0900
+
+stt (0.1.1-4slp2+1) unstable; urgency=low
+
+  * Git: 165.213.180.234:slp/pkgs/s/stt
+  * Tag: stt_0.1.1-4slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Mon, 23 May 2011 15:11:24 +0900
+
+stt (0.1.1-3slp2+1) unstable; urgency=low
+
+  * Update API - change error code
+  * Git: 165.213.180.234:slp/pkgs/s/stt
+  * Tag: stt_0.1.1-3slp2+1
+
+ -- Dongyeol Lee <dy3.lee@samsung.com>  Mon, 23 May 2011 08:56:57 +0900
+ stt (0.1.1-2slp2+1) unstable; urgency=low
+
+  * Initial Release (change files to unix type)
+  * Git: 165.213.180.234:slp/pkgs/s/stt
+  * Tag: stt_0.1.1-2slp2+1
+
+ -- Jae-Yong Lee <jaeyong911.lee@samsung.com>  Mon, 16 May 2011 10:16:57 +0900
+
+stt (0.1.1-1slp2+1) unstable; urgency=low
+
+  * Initial Release
+  * Git: 165.213.180.234:slp/pkgs/s/stt
+  * Tag: stt_0.1.1-1slp2+1
+
+ -- Jae-Yong Lee <jaeyong911.lee@samsung.com>  Fri, 13 May 2011 16:17:56 +0900
index c109a22..929807b 100644 (file)
@@ -10,12 +10,11 @@ Requires(postun): /sbin/ldconfig
 BuildRequires:  pkgconfig(glib-2.0)
 BuildRequires:  pkgconfig(dbus-1)
 BuildRequires:  pkgconfig(ecore)
-BuildRequires:  pkgconfig(openssl)
+BuildRequires:  pkgconfig(ecore-file)
 BuildRequires:  pkgconfig(mm-player)
 BuildRequires:  pkgconfig(mm-common)
 BuildRequires:  pkgconfig(mm-sound)
 BuildRequires:  pkgconfig(mm-camcorder)
-BuildRequires:  pkgconfig(dnet)
 BuildRequires:  pkgconfig(dlog)
 BuildRequires:  pkgconfig(vconf)
 
@@ -44,25 +43,21 @@ 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 stt-server.manifest
 %defattr(-,root,root,-)
 %{_libdir}/libstt.so
 %{_libdir}/libstt_setting.so
+%{_libdir}/voice/stt/1.0/sttd.conf
 %{_bindir}/stt-daemon
-
+/usr/share/license/*
 
 %files devel
 %defattr(-,root,root,-)
index 03cbdb5..525750b 100644 (file)
@@ -24,11 +24,11 @@ INCLUDE_DIRECTORIES(${INCLUDEDIR})
 INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/../common")
 
 ## Dependent packages ##
-INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED 
-       glib-2.0 dbus-1 
-       vconf dlog mm-player mm-common mm-camcorder openssl
-)
+#INCLUDE(FindPkgConfig)
+#pkg_check_modules(pkgs REQUIRED 
+#      glib-2.0 dbus-1 
+#      vconf dlog mm-player mm-common mm-camcorder openssl
+#)
 
 FOREACH(flag ${pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
@@ -43,8 +43,9 @@ ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
 
 ## Executable ##
 ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} -ldl ${pkgs_LDFLAGS})
 
 ## Install
 INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/sttp.h DESTINATION include)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/sttd.conf DESTINATION lib/voice/stt/1.0)
diff --git a/server/sttd.conf b/server/sttd.conf
new file mode 100644 (file)
index 0000000..53f382b
--- /dev/null
@@ -0,0 +1,5 @@
+ENGINE_ID A7AB375F-443B-4924-80DB-FF3DA1506580\r
+LANGUAGE en_US\r
+SILENCE 1\r
+PROFANITY 0\r
+PUNCTUATION 0
\ No newline at end of file
old mode 100644 (file)
new mode 100755 (executable)
index d61931a..618c924
@@ -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
@@ -18,6 +18,8 @@
 /* Client list */
 static GList *g_client_list = NULL;
 
+static GList *g_setting_client_list = NULL;
+
 int client_show_list()
 {
        GList *iter = NULL;
@@ -46,10 +48,35 @@ int client_show_list()
 
        SLOG(LOG_DEBUG, TAG_STTD, "-----"); 
 
+       SLOG(LOG_DEBUG, TAG_STTD, "----- setting client list"); 
+
+       setting_client_info_s *setting_data = NULL;
+
+       if (g_list_length(g_setting_client_list) > 0) {
+               /* Get a first item */
+               iter = g_list_first(g_setting_client_list);
+
+               int i = 1;      
+               while (NULL != iter) {
+                       /*Get handle data from list*/
+                       setting_data = iter->data;
+
+                       SLOG(LOG_DEBUG, TAG_STTD, "[%dth] pid(%d)", i, setting_data->pid); 
+
+                       /*Get next item*/
+                       iter = g_list_next(iter);
+                       i++;
+               }
+       } else {
+               SLOG(LOG_DEBUG, TAG_STTD, "No setting client"); 
+       }
+
+       SLOG(LOG_DEBUG, TAG_STTD, "-----"); 
+
        return 0;
 }
 
-GList* sttd_client_get_item(const int uid)
+GList* __client_get_item(const int uid)
 {
        GList *iter = NULL;
        client_info_s *data = NULL;
@@ -75,7 +102,7 @@ int sttd_client_add(const int pid, const int uid)
 {
        /*Check uid is duplicated*/
        GList *tmp = NULL;
-       tmp = sttd_client_get_item(uid);
+       tmp = __client_get_item(uid);
        
        if (NULL != tmp) {
                SLOG(LOG_WARN, TAG_STTD, "[Client Data] Client uid is already registered"); 
@@ -95,13 +122,12 @@ int sttd_client_add(const int pid, const int uid)
                SLOG(LOG_ERROR, TAG_STTD, "[Client Data ERROR] Fail to add new client"); 
                return -1;
        } else {
-               SLOG(LOG_ERROR, TAG_STTD, "[Client Data SUCCESS] Add new client"); 
+               SLOG(LOG_DEBUG, TAG_STTD, "[Client Data SUCCESS] Add new client"); 
        }
 
 #ifdef CLIENT_DATA_DEBUG
        client_show_list();
 #endif 
-
        return 0;
 }
 
@@ -111,7 +137,7 @@ int sttd_client_delete(const int uid)
        client_info_s* hnd = NULL;
 
        /*Get handle*/
-       tmp = sttd_client_get_item(uid);
+       tmp = __client_get_item(uid);
        if (NULL == tmp) {
                SLOG(LOG_ERROR, TAG_STTD, "[Client Data ERROR] uid(%d) is NOT valid", uid); 
                return STTD_ERROR_INVALID_PARAMETER;
@@ -138,7 +164,7 @@ int sttd_client_get_state(const int uid, app_state_e* state)
        GList *tmp = NULL;
        client_info_s* hnd = NULL;
 
-       tmp = sttd_client_get_item(uid);
+       tmp = __client_get_item(uid);
        if (NULL == tmp) {
                return STTD_ERROR_INVALID_PARAMETER;
        }
@@ -156,7 +182,7 @@ int sttd_client_set_state(const int uid, const app_state_e state)
        GList *tmp = NULL;
        client_info_s* hnd = NULL;
 
-       tmp = sttd_client_get_item(uid);
+       tmp = __client_get_item(uid);
        if (NULL == tmp) {
                SLOG(LOG_ERROR, TAG_STTD, "[Client Data ERROR] uid(%d) is NOT valid", uid); 
                return STTD_ERROR_INVALID_PARAMETER;
@@ -172,7 +198,10 @@ int sttd_client_set_state(const int uid, const app_state_e state)
 
 int sttd_client_get_ref_count()
 {
-       return g_list_length(g_client_list);
+       int count = g_list_length(g_client_list) + g_list_length(g_setting_client_list);
+       SLOG(LOG_DEBUG, TAG_STTD, "[Client Data] client count : %d", count);
+
+       return count;
 }
 
 int sttd_client_get_pid(const int uid)
@@ -180,7 +209,7 @@ int sttd_client_get_pid(const int uid)
        GList *tmp = NULL;
        client_info_s* hnd = NULL;
 
-       tmp = sttd_client_get_item(uid);
+       tmp = __client_get_item(uid);
        if (NULL == tmp) {
                SLOG(LOG_ERROR, TAG_STTD, "[Client Data ERROR] sttd_client_get_pid : uid(%d) is not found", uid); 
                return STTD_ERROR_INVALID_PARAMETER;
@@ -234,3 +263,167 @@ int sttd_client_get_current_thinking()
 
        return -1;
 }
+
+int sttd_cliet_set_timer(int uid, Ecore_Timer* timer)
+{
+       GList *tmp = NULL;
+       client_info_s* hnd = NULL;
+
+       tmp = __client_get_item(uid);
+       if (NULL == tmp) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Client Data ERROR] uid(%d) is NOT valid", uid); 
+               return STTD_ERROR_INVALID_PARAMETER;
+       }
+
+       hnd = tmp->data;
+       hnd->timer = timer;
+
+       SLOG(LOG_DEBUG, TAG_STTD, "[Client Data SUCCESS] Set timer : uid(%d)", uid);
+
+       return 0;
+}
+
+int sttd_cliet_get_timer(int uid, Ecore_Timer** timer)
+{
+       GList *tmp = NULL;
+       client_info_s* hnd = NULL;
+
+       tmp = __client_get_item(uid);
+       if (NULL == tmp) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Client Data ERROR] uid(%d) is NOT valid", uid); 
+               return STTD_ERROR_INVALID_PARAMETER;
+       }
+
+       hnd = tmp->data;
+       *timer = hnd->timer;
+
+       SLOG(LOG_DEBUG, TAG_STTD, "[Client Data SUCCESS] Get timer : uid(%d)", uid);
+
+       return 0;
+}
+
+
+int sttd_client_get_list(int** uids, int* uid_count)
+{
+       if (NULL == uids || NULL == uid_count)
+               return -1;
+       
+       int count = g_list_length(g_client_list);
+
+       if (0 == count)
+               return -1; 
+
+       int *tmp;
+       tmp = (int*)malloc(sizeof(int) * count);
+       
+       GList *iter = NULL;
+       client_info_s *data = NULL;
+       int i = 0;
+
+       iter = g_list_first(g_client_list);
+       for (i = 0;i < count;i++) {
+               data = iter->data;
+               tmp[i] = data->uid;
+               iter = g_list_next(iter);
+       }
+
+       *uids = tmp;
+       *uid_count = count;
+
+       return 0;
+}
+
+/*
+* Functions for setting
+*/
+
+GList* __setting_client_get_item(int pid)
+{
+       GList *iter = NULL;
+       setting_client_info_s *data = NULL;
+
+       if (0 < g_list_length(g_setting_client_list)) {
+               iter = g_list_first(g_setting_client_list);
+
+               while (NULL != iter) {
+                       /* Get handle data from list */
+                       data = iter->data;
+
+                       if (pid == data->pid) 
+                               return iter;
+
+                       iter = g_list_next(iter);
+               }
+       }
+
+       return NULL;
+}
+
+int sttd_setting_client_add(int pid)
+{      
+       /* Check uid is duplicated */
+       GList *tmp = NULL;
+       tmp = __setting_client_get_item(pid);
+
+       if (NULL != tmp) {
+               SLOG(LOG_WARN, TAG_STTD, "[Client Data] Setting client(%d) is already registered", pid); 
+               return STTD_ERROR_INVALID_PARAMETER;
+       }
+
+       setting_client_info_s *info = (setting_client_info_s*)g_malloc0(sizeof(setting_client_info_s));
+
+       info->pid = pid;
+
+       /* Add item to global list */
+       g_setting_client_list = g_list_append(g_setting_client_list, info);
+
+       if (NULL == g_setting_client_list) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Client Data ERROR] Fail to add new client"); 
+               return -1;
+       } else {
+               SLOG(LOG_DEBUG, TAG_STTD, "[Client Data SUCCESS] Add new client"); 
+       }
+
+#ifdef CLIENT_DATA_DEBUG
+       client_show_list();
+#endif 
+       return 0;
+}
+
+int sttd_setting_client_delete(int pid)
+{
+       GList *tmp = NULL;
+       setting_client_info_s* hnd = NULL;
+
+       /*Get handle*/
+       tmp = __setting_client_get_item(pid);
+       if (NULL == tmp) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Client Data ERROR] Setting uid(%d) is NOT valid", pid); 
+               return STTD_ERROR_INVALID_PARAMETER;
+       }
+
+       /*Free client structure*/
+       hnd = tmp->data;
+       if (NULL != hnd) {
+               g_free(hnd);
+       }
+
+       /*Remove handle from list*/
+       g_setting_client_list = g_list_remove_link(g_setting_client_list, tmp);
+
+#ifdef CLIENT_DATA_DEBUG
+       client_show_list();
+#endif 
+
+       return 0;
+}
+
+bool sttd_setting_client_is(int pid)
+{
+       GList *tmp = __setting_client_get_item(pid);
+       if (NULL == tmp) {
+               return false;
+       }
+
+       return true;
+}
\ No newline at end of file
old mode 100644 (file)
new mode 100755 (executable)
index 5a80c84..1433736
@@ -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 __STTD_CLIENT_DATA_H_
 #define __STTD_CLIENT_DATA_H_
 
+#include <glib.h>
+#include <Ecore.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 typedef enum {
-       APP_STATE_READY         = 0,
-       APP_STATE_RECORDING     = 1,
-       APP_STATE_PROCESSING    = 2
+       APP_STATE_CREATED       = 0,
+       APP_STATE_READY         = 1,
+       APP_STATE_RECORDING     = 2,
+       APP_STATE_PROCESSING    = 3
 }app_state_e;
 
 typedef struct {
        int     pid;
        int     uid;
        app_state_e     state;
+       Ecore_Timer*    timer;
 } client_info_s;
 
+typedef struct {
+       int pid;
+} setting_client_info_s;
+
 int sttd_client_add(const int pid, const int uid);
 
 int sttd_client_delete(const int uid);
@@ -48,6 +56,19 @@ int sttd_client_get_current_recording();
 
 int sttd_client_get_current_thinking();
 
+int sttd_cliet_set_timer(int uid, Ecore_Timer* timer);
+
+int sttd_cliet_get_timer(int uid, Ecore_Timer** timer);
+
+int sttd_client_get_list(int** uids, int* uid_count);
+
+
+int sttd_setting_client_add(int pid);
+
+int sttd_setting_client_delete(int pid);
+
+bool sttd_setting_client_is(int pid);
+
 #ifdef __cplusplus
 }
 #endif
old mode 100644 (file)
new mode 100755 (executable)
index de21d3c..563b684
@@ -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 "sttd_main.h"
 #include "sttd_config.h"
 
 
-/*
-* stt-daemon config
-*/
+#define CONFIG_FILE_PATH       CONFIG_DIRECTORY"/sttd.conf"
+#define CONFIG_DEFAULT         BASE_DIRECTORY_DEFAULT"/sttd.conf"
 
-int sttd_config_get_char_type(const char* key, char** value)
-{
-       if (NULL == key || NULL == value) {
-               SLOG(LOG_ERROR, TAG_STTD, "[STTD Config ERROR] Input parameter is NULL");
-               return STTD_ERROR_INVALID_PARAMETER;
-       } 
-
-       *value = vconf_get_str(key);
-       if (NULL == *value) {
-               SLOG(LOG_ERROR, TAG_STTD, "[STTD Config ERROR] Fail to get char type from config : key(%s)", key);
-               return -1;
-       }
+#define ENGINE_ID      "ENGINE_ID"
+#define LANGUAGE       "LANGUAGE"
+#define SILENCE                "SILENCE"
+#define PROFANITY      "PROFANITY"
+#define PUNCTUATION    "PUNCTUATION"
 
-       return 0;
-}
 
-int sttd_config_set_char_type(const char* key, const char* value)
+static char*   g_engine_id;
+static char*   g_language;
+static int     g_silence;
+static int     g_profanity;
+static int     g_punctuation;
+
+int __sttd_config_save()
 {
-       if (NULL == key || NULL == value) {
-               SLOG(LOG_ERROR, TAG_STTD, "[STTD Config ERROR] Input parameter is NULL");
-               return STTD_ERROR_INVALID_PARAMETER;
-       } 
+       if (0 != access(CONFIG_FILE_PATH, R_OK|W_OK)) {
+               if (0 == ecore_file_mkpath(CONFIG_DIRECTORY)) {
+                       SLOG(LOG_ERROR, TAG_STTD, "[Config ERROR ] Fail to create directory (%s)", CONFIG_DIRECTORY);
+                       return -1;
+               }
 
-       if (0 != vconf_set_str(key, value)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[STTD Config ERROR] Fail to set char type"); 
-               return -1;
+               SLOG(LOG_WARN, TAG_STTD, "[Config] Create directory (%s)", CONFIG_DIRECTORY);
        }
 
-       return 0;
-}
+       FILE* config_fp;
+       config_fp = fopen(CONFIG_FILE_PATH, "w+");
 
-int sttd_config_get_bool_type(const char* key, bool* value)
-{
-       if (NULL == key || NULL == value) {
-               SLOG(LOG_ERROR, TAG_STTD, "[STTD Config ERROR] Input parameter is NULL");
-               return STTD_ERROR_INVALID_PARAMETER;
-       } 
-
-       int result ;
-       if (0 != vconf_get_int(key, &result)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[STTD Config ERROR] Fail to get bool type config : key(%s)", key);
+       if (NULL == config_fp) {
+               // make file and file default
+               SLOG(LOG_ERROR, TAG_STTD, "[Config ERROR] Fail to load config (engine id)");
                return -1;
        }
 
-       *value = (bool) result;
+       SLOG(LOG_DEBUG, TAG_STTD, "[Config] Rewrite config file");
 
-       return 0;
-}
+       /* Write engine id */
+       fprintf(config_fp, "%s %s\n", ENGINE_ID, g_engine_id);
 
-int sttd_config_set_bool_type(const char* key, const bool value)
-{
-       if (NULL == key) {
-               SLOG(LOG_ERROR, TAG_STTD, "[STTD Config ERROR] Input parameter is NULL");
-               return STTD_ERROR_INVALID_PARAMETER;
-       } 
-
-       int result = (int)value;
-       if (0 != vconf_set_int(key, result)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[STTD Config ERROR] Fail to get bool type config : key(%s)", key);
-               return -1;
-       }
+       /* Write language */
+       fprintf(config_fp, "%s %s\n", LANGUAGE, g_language);
 
-       return 0;
-}
+       /* Write silence detection */
+       fprintf(config_fp, "%s %d\n", SILENCE, g_silence);
 
-/*
-* plug-in daemon interface
-*/
-
-int __make_key_for_engine(const char* engine_id, const char* key, char** out_key)
-{
-       int key_size = strlen(STTD_CONFIG_PREFIX) + strlen(engine_id) + strlen(key) + 2; /* 2 means both '/' and '\0'*/
+       /* Write profanity */
+       fprintf(config_fp, "%s %d\n", PROFANITY, g_profanity);
 
-       *out_key = (char*) malloc( sizeof(char) * key_size);
+       /* Write punctuation */
+       fprintf(config_fp, "%s %d\n", PUNCTUATION, g_punctuation);
 
-       snprintf(*out_key, key_size, "%s%s/%s", STTD_CONFIG_PREFIX, engine_id, key );
+       fclose(config_fp);
 
        return 0;
 }
 
-int sttd_config_set_persistent_data(const char* engine_id, const char* key, const char* value)
+int __sttd_config_load()
 {
-       if (NULL == engine_id || NULL == key || NULL == value) {
-               SLOG(LOG_ERROR, TAG_STTD, "[STTD Config ERROR] BAD Parameter"); 
-               return STTD_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;
+
+       config_fp = fopen(CONFIG_FILE_PATH, "r");
+
+       if (NULL == config_fp) {
+               SLOG(LOG_WARN, TAG_STTD, "[Config WARNING] Not open file(%s)", CONFIG_FILE_PATH);
+
+               config_fp = fopen(CONFIG_DEFAULT, "r");
+               if (NULL == config_fp) {
+                       SLOG(LOG_WARN, TAG_STTD, "[Config WARNING] Not open original config file(%s)", CONFIG_FILE_PATH);
+                       __sttd_config_save();
+                       return 0;
+               }
+               is_default_open = true;
        }
 
-       char* vconf_key = NULL;
-       if (0 != __make_key_for_engine(engine_id, key, &vconf_key)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[STTD Config ERROR] Fail __make_key_for_engine()");
-               return -1;
+       /* Read engine id */
+       if (EOF == fscanf(config_fp, "%s %s", buf_id, buf_param)) {
+               fclose(config_fp);
+               SLOG(LOG_WARN, TAG_STTD, "[Config WARNING] Fail to load config (engine id)");
+               __sttd_config_save();
+               return 0;
+       } else {
+               if (0 == strncmp(ENGINE_ID, buf_id, strlen(ENGINE_ID))) {
+                       g_engine_id = strdup(buf_param);
+               } else {
+                       fclose(config_fp);
+                       SLOG(LOG_WARN, TAG_STTD, "[Config WARNING] Fail to load config (engine id)");
+                       __sttd_config_save();
+                       return 0;
+               }
        }
 
-       if (NULL == vconf_key)          
-               return -1;
+       /* Read language */
+       if (EOF == fscanf(config_fp, "%s %s", buf_id, buf_param)) {
+               fclose(config_fp);
+               SLOG(LOG_WARN, TAG_STTD, "[Config WARNING] Fail to load config (language)");
+               __sttd_config_save();
+               return 0;
+       } else {
+               if (0 == strncmp(LANGUAGE, buf_id, strlen(LANGUAGE))) {
+                       g_language = strdup(buf_param);
+               } else {
+                       fclose(config_fp);
+                       SLOG(LOG_WARN, TAG_STTD, "[Config WARNING] Fail to load config (language)");
+                       __sttd_config_save();
+                       return 0;
+               }
+       }
+       
+       /* Read silence detection */
+       if (EOF == fscanf(config_fp, "%s %d", buf_id, &int_param)) {
+               fclose(config_fp);
+               SLOG(LOG_WARN, TAG_STTD, "[Config WARNING] Fail to load config (silence)");
+               __sttd_config_save();
+               return 0;
+       } else {
+               if (0 == strncmp(SILENCE, buf_id, strlen(SILENCE))) {
+                       g_silence = int_param;
+               } else {
+                       fclose(config_fp);
+                       SLOG(LOG_WARN, TAG_STTD, "[Config WARNING] Fail to load config (silence)");
+                       __sttd_config_save();
+                       return 0;
+               }
+       }
 
-       if (0 != vconf_set_str(vconf_key, value)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[STTD Config ERROR] Fail to set key, value");
+       /* Read profanity filter */
+       if (EOF == fscanf(config_fp, "%s %d", buf_id, &int_param)) {
+               fclose(config_fp);
+               SLOG(LOG_WARN, TAG_STTD, "[Config WARNING] Fail to load config (profanity filter)");
+               __sttd_config_save();
+               return 0;
+       } else {
+               if (0 == strncmp(PROFANITY, buf_id, strlen(PROFANITY))) {
+                       g_profanity = int_param;
+               } else {
+                       fclose(config_fp);
+                       SLOG(LOG_WARN, TAG_STTD, "[Config WARNING] Fail to load config (profanity filter)");
+                       __sttd_config_save();
+                       return 0;
+               }
+       }
+       
+
+       /* Read punctuation override */
+       if (EOF == fscanf(config_fp, "%s %d", buf_id, &int_param)) {
+               fclose(config_fp);
+               SLOG(LOG_WARN, TAG_STTD, "[Config WARNING] Fail to load config (punctuation override)");
+               __sttd_config_save();
+               return 0;
+       } else {
+               if (0 == strncmp(PUNCTUATION, buf_id, strlen(PUNCTUATION))) {
+                       g_punctuation = int_param;
+               } else {
+                       fclose(config_fp);
+                       SLOG(LOG_WARN, TAG_STTD, "[Config WARNING] Fail to load config (punctuation override)");
+                       __sttd_config_save();
+                       return 0;
+               }
+       }
+       
+       fclose(config_fp);
 
-               if (vconf_key != NULL)  
-                       free(vconf_key);
+       SLOG(LOG_DEBUG, TAG_STTD, "[Config] Load config : engine(%s), language(%s), silence(%d), profanity(%d), punctuation(%d)",
+               g_engine_id, g_language, g_silence, g_profanity, g_punctuation);
 
-               return -1;
+       if (true == is_default_open) {
+               if(0 == __sttd_config_save()) {
+                       SLOG(LOG_DEBUG, TAG_STTD, "[Config] Create config(%s)", CONFIG_FILE_PATH);
+               }
        }
 
-       SLOG(LOG_DEBUG, TAG_STTD, "[STTD Config DEBUG] sttd_config_set_persistent_data : key(%s), value(%s)", vconf_key, value);
+       return 0;
+}
 
-       if (NULL != vconf_key)  
-               free(vconf_key);
+int sttd_config_initialize()
+{
+       g_engine_id = NULL;
+       g_language = NULL;
+       g_silence = 1;
+       g_profanity = 1;
+       g_punctuation = 0;
+
+       __sttd_config_load();
 
        return 0;
 }
 
-int sttd_config_get_persistent_data(const char* engine_id, const char* key, char** value)
+int sttd_config_finalize()
 {
-       if (NULL == engine_id) {
-               SLOG(LOG_ERROR, TAG_STTD, "[STTD Config ERROR] BAD Parameter"); 
-               return STTD_ERROR_INVALID_PARAMETER;
-       }
+       __sttd_config_save();
+       return 0;
+}
 
-       char* vconf_key = NULL;
+int sttd_config_get_default_engine(char** engine_id)
+{
+       if (NULL == engine_id)
+               return -1;
+
+       *engine_id = strdup(g_engine_id);
+       return 0;
+}
 
-       if (0 != __make_key_for_engine(engine_id, key, &vconf_key)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[STTD Config ERROR] Fail __make_key_for_engine()");
+int sttd_config_set_default_engine(const char* engine_id)
+{
+       if (NULL == engine_id)
                return -1;
-       }
 
-       if (NULL == vconf_key)
+       if (NULL != g_engine_id)
+               free(g_engine_id);
+
+       g_engine_id = strdup(engine_id);
+       __sttd_config_save();
+       return 0;
+}
+
+int sttd_config_get_default_language(char** language)
+{
+       if (NULL == language)
                return -1;
 
-       char* temp;
-       temp = vconf_get_str(vconf_key);
-       if (NULL == temp) {
-               SLOG(LOG_ERROR, TAG_STTD, "[STTD Config ERROR] Fail to get value");
+       *language = strdup(g_language);
 
-               if(vconf_key != NULL)   
-                       free(vconf_key);
+       return 0;
+}
 
+int sttd_config_set_default_language(const char* language)
+{
+       if (NULL == language)
                return -1;
-       }
 
-       *value = g_strdup(temp);
+       if (NULL != g_language)
+               free(g_language);
 
-       SLOG(LOG_DEBUG, TAG_STTD, "[STTD Config DEBUG] sttd_config_get_persistent_data : key(%s), value(%s)", vconf_key, *value);
+       g_language = strdup(language);
 
-       if (vconf_key != NULL)  free(vconf_key);
-       if (temp != NULL)       free(temp);
+       __sttd_config_save();
 
        return 0;
 }
 
-int sttd_config_remove_persistent_data(const char* engine_id, const char* key)
+int sttd_config_get_default_silence_detection(int* silence)
 {
-       if (NULL == engine_id || NULL == key) {
-               SLOG(LOG_ERROR, TAG_STTD, "[STTD Config ERROR] BAD Parameter"); 
-               return STTD_ERROR_INVALID_PARAMETER;
-       }
-
-       char* vconf_key = NULL;
-       if (0 != __make_key_for_engine(engine_id, key, &vconf_key)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[STTD Config ERROR] Fail __make_key_for_engine()");
+       if (NULL == silence)
                return -1;
-       }
 
-       if (NULL == vconf_key)          
-               return -1;
+       *silence = g_silence;
 
-       if (0 != vconf_unset(vconf_key)) {      
-               SLOG(LOG_ERROR, TAG_STTD, "[STTD Config ERROR] Fail to remove key");
+       return 0;
+}
 
-               if(vconf_key != NULL)   
-                       free(vconf_key);
+int sttd_config_set_default_silence_detection(int silence)
+{
+       g_silence = silence;
+       __sttd_config_save();
+       return 0;
+}
 
+int sttd_config_get_default_profanity_filter(int* profanity)
+{
+       if (NULL == profanity)
                return -1;
-       }
 
-       SLOG(LOG_DEBUG, TAG_STTD, "[STTD Config DEBUG] sttd_config_remove_persistent_data : key(%s)", vconf_key);
+       *profanity = g_profanity;
 
-       if( NULL != vconf_key )         
-               free(vconf_key);
+       return 0;
+}
 
+int sttd_config_set_default_profanity_filter(int profanity)
+{
+       g_profanity = profanity;
+       __sttd_config_save();
        return 0;
 }
 
+int sttd_config_get_default_punctuation_override(int* punctuation)
+{
+       if (NULL == punctuation)
+               return -1;
 
+       *punctuation = g_punctuation;
+
+       return 0;
+}
+
+int sttd_config_set_default_punctuation_override(int punctuation)
+{
+       g_punctuation = punctuation;
+       __sttd_config_save();
+       return 0;
+}
\ No newline at end of file
old mode 100644 (file)
new mode 100755 (executable)
index d87d290..f2cfe91
@@ -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 __STTD_CONFIG_H_
 #define __STTD_CONFIG_H_
 
-#include <stdbool.h>
-
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#define STTD_CONFIG_PREFIX "db/sttd/"
-
-#define CONFIG_KEY_DEFAULT_ENGINE_ID   STTD_CONFIG_PREFIX"engine"
-#define CONFIG_KEY_DEFAULT_LANGUAGE    STTD_CONFIG_PREFIX"language"
-#define CONFIG_KEY_PROFANITY_FILTER    STTD_CONFIG_PREFIX"profanity"
-#define CONFIG_KEY_PUNCTUATION_OVERRIDE        STTD_CONFIG_PREFIX"punctuation"
-#define CONFIG_KEY_SILENCE_DETECTION   STTD_CONFIG_PREFIX"silence"
+int sttd_config_initialize();
 
+int sttd_config_finalize();
 
-/*
-* stt-daemon config
-*/
+int sttd_config_get_default_engine(char** engine_id);
 
-int sttd_config_get_char_type(const char* key, char** value);
+int sttd_config_set_default_engine(const char* engine_id);
 
-int sttd_config_set_char_type(const char* key, const char* value);
+int sttd_config_get_default_language(char** language);
 
-int sttd_config_get_bool_type(const char* key, bool* value);
+int sttd_config_set_default_language(const char* langauge);
 
-int sttd_config_set_bool_type(const char* key, const bool value);
+int sttd_config_get_default_silence_detection(int* silence);
 
+int sttd_config_set_default_silence_detection(int silence);
 
-/*
-* interface for engine plug-in
-*/
+int sttd_config_get_default_profanity_filter(int* profanity);
 
-int sttd_config_set_persistent_data(const char* engine_id, const char* key, const char* value);
+int sttd_config_set_default_profanity_filter(int profanity);
 
-int sttd_config_get_persistent_data(const char* engine_id, const char* key, char** value);
+int sttd_config_get_default_punctuation_override(int* punctuation);
 
-int sttd_config_remove_persistent_data(const char* engine_id, const char* key);
+int sttd_config_set_default_punctuation_override(int punctuation);
 
 
 #ifdef __cplusplus
old mode 100644 (file)
new mode 100755 (executable)
index 9c6db16..0c5711f
@@ -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 "stt_defs.h"
 
 static DBusConnection* g_conn;
+static int g_waiting_time = 3000;
+
+int sttdc_send_hello(int uid)
+{
+       int pid = sttd_client_get_pid(uid);
+
+       if (0 > pid) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] pid is NOT valid");
+               return -1;
+       }
+
+       char service_name[64];
+       memset(service_name, 0, 64);
+       snprintf(service_name, 64, "%s%d", STT_CLIENT_SERVICE_NAME, pid);
+
+       char target_if_name[128];
+       snprintf(target_if_name, sizeof(target_if_name), "%s%d", STT_CLIENT_SERVICE_INTERFACE, pid);
+
+       DBusMessage* msg;
+
+       SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] Send hello message : uid(%d)", uid);
+
+       msg = dbus_message_new_method_call(
+               service_name, 
+               STT_CLIENT_SERVICE_OBJECT_PATH, 
+               target_if_name, 
+               STTD_METHOD_HELLO);
+
+       if (NULL == msg) { 
+               SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Fail to create message"); 
+               return -1;
+       }
+
+       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_STTD, "[Dbus] Get arguments error (%s)\n", err.message);
+                       dbus_error_free(&err); 
+                       result = -1;
+               }
+
+               dbus_message_unref(result_msg);
+       } else {
+               SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] Result message is NULL. Client is not available");
+               result = 0;
+       }
+
+       return result;
+}
+
+int sttdc_send_get_state(int uid, int* state)
+{
+       int pid = sttd_client_get_pid(uid);
+
+       if (0 > pid) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] pid is NOT valid");
+               return -1;
+       }
+
+       char service_name[64];
+       memset(service_name, 0, 64);
+       snprintf(service_name, 64, "%s%d", STT_CLIENT_SERVICE_NAME, pid);
+
+       char target_if_name[128];
+       snprintf(target_if_name, sizeof(target_if_name), "%s%d", STT_CLIENT_SERVICE_INTERFACE, pid);
+
+       DBusMessage* msg;
+
+       SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] Send get state message : uid(%d)", uid);
+
+       msg = dbus_message_new_method_call(
+               service_name, 
+               STT_CLIENT_SERVICE_OBJECT_PATH, 
+               target_if_name, 
+               STTD_METHOD_GET_STATE);
+
+       if (NULL == msg) { 
+               SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Fail to create message"); 
+               return -1;
+       }
+
+       dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
+
+       DBusError err;
+       dbus_error_init(&err);
+
+       DBusMessage* result_msg;
+       int tmp = -1;
+       int result = 0;
+
+       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, &tmp, DBUS_TYPE_INVALID);
+
+               if (dbus_error_is_set(&err)) { 
+                       SLOG(LOG_ERROR, TAG_STTD, "[Dbus] Get arguments error (%s)\n", err.message);
+                       dbus_error_free(&err); 
+                       result = -1;
+               } else {
+                       *state = tmp;
+                       result = 0;
+               }
+
+               dbus_message_unref(result_msg);
+       } else {
+               SLOG(LOG_ERROR, TAG_STTD, "[Dbus] Result message is NULL. Client is not available");
+               result = -1;
+       }
+       
+       return result;
+}
 
 int sttdc_send_result(int uid, const char* type, const char** data, int data_count, const char* result_msg)
 {
@@ -32,6 +157,10 @@ int sttdc_send_result(int uid, const char* type, const char** data, int data_cou
                return -1;
        }
 
+       char service_name[64];
+       memset(service_name, 0, 64);
+       snprintf(service_name, 64, "%s%d", STT_CLIENT_SERVICE_NAME, pid);
+
        char target_if_name[128];
        snprintf(target_if_name, sizeof(target_if_name), "%s%d", STT_CLIENT_SERVICE_INTERFACE, pid);
 
@@ -39,10 +168,11 @@ int sttdc_send_result(int uid, const char* type, const char** data, int data_cou
        
        SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] send result signal : uid(%d), type(%s), result count(%d)", uid, type, data_count);
 
-       msg = dbus_message_new_signal(
-               STT_CLIENT_SERVICE_OBJECT_PATH,  
-               target_if_name,                  
-               STT_SIGNAL_RESULT );              
+       msg = dbus_message_new_method_call(
+               service_name, 
+               STT_CLIENT_SERVICE_OBJECT_PATH, 
+               target_if_name, 
+               STTD_METHOD_RESULT);
 
        if (NULL == msg) { 
                SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Fail to create message"); 
@@ -135,17 +265,22 @@ int sttdc_send_partial_result(int uid, const char* data)
                return -1;
        }
 
+       char service_name[64];
+       memset(service_name, 0, 64);
+       snprintf(service_name, 64, "%s%d", STT_CLIENT_SERVICE_NAME, pid);
+
        char target_if_name[128];
        snprintf(target_if_name, sizeof(target_if_name), "%s%d", STT_CLIENT_SERVICE_INTERFACE, pid);
 
        DBusMessage* msg;
 
        SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] send result signal : uid(%d), result(%s)", uid, data);
-
-       msg = dbus_message_new_signal(
-               STT_CLIENT_SERVICE_OBJECT_PATH,  
-               target_if_name,                  
-               STT_SIGNAL_PARTIAL_RESULT );              
+       msg = dbus_message_new_method_call(
+               service_name, 
+               STT_CLIENT_SERVICE_OBJECT_PATH, 
+               target_if_name, 
+               STTD_METHOD_PARTIAL_RESULT);
 
        if (NULL == msg) { 
                SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Fail to create message"); 
@@ -190,15 +325,21 @@ int sttdc_send_error_signal(int uid, int reason, char *err_msg)
                return -1;
        }
 
+       char service_name[64];
+       memset(service_name, 0, 64);
+       snprintf(service_name, 64, "%s%d", STT_CLIENT_SERVICE_NAME, pid);
+
        char target_if_name[128];
        snprintf(target_if_name, sizeof(target_if_name), "%s%d", STT_CLIENT_SERVICE_INTERFACE, pid);
 
        DBusMessage* msg;
        SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] send error signal : reason(%d), Error Msg(%s)", reason, err_msg);
-       msg = dbus_message_new_signal(
-               STT_CLIENT_SERVICE_OBJECT_PATH,  /* object name of the signal */
-               target_if_name,                  /* interface name of the signal */
-               STT_SIGNAL_ERROR );              /* name of the signal */
+
+       msg = dbus_message_new_method_call(
+               service_name, 
+               STT_CLIENT_SERVICE_OBJECT_PATH, 
+               target_if_name, 
+               STTD_METHOD_ERROR);
 
        if (NULL == msg) { 
                SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Fail to create message"); 
@@ -211,58 +352,84 @@ int sttdc_send_error_signal(int uid, int reason, char *err_msg)
                DBUS_TYPE_STRING, &err_msg,
                DBUS_TYPE_INVALID);
        
-       if (!dbus_connection_send(g_conn, msg, NULL)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Fail to send message : Out Of Memory !"); 
-               return -1;
-       }
+       DBusError err;
+       dbus_error_init(&err);
 
-       dbus_connection_flush(g_conn);
+       DBusMessage* result_msg;
+
+       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_unref(result_msg);
+       } else {
+               SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] Result message is NULL.");
+       }
+
        return 0;
 }
 
-int sttd_send_stop(int uid)
+int sttdc_send_set_state(int uid, int state)
 {
        int pid = sttd_client_get_pid(uid);
 
        if (0 > pid) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] pid is NOT valid" );
+               SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] pid is NOT valid");
                return -1;
        }
 
-       char target_if_name[64];
-       snprintf(target_if_name, sizeof(target_if_name), "%s%d", STT_CLIENT_SERVICE_INTERFACE, pid);
+       char service_name[64];
+       memset(service_name, 0, 64);
+       snprintf(service_name, 64, "%s%d", STT_CLIENT_SERVICE_NAME, pid);
 
-       SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] send %s signal : ifname(%s), uid(%d)", signal, target_if_name, uid);
+       char target_if_name[128];
+       snprintf(target_if_name, sizeof(target_if_name), "%s%d", STT_CLIENT_SERVICE_INTERFACE, pid);
 
        DBusMessage* msg;
 
-       /* create a signal & check for errors */
-       msg = dbus_message_new_signal(
-               STT_SERVER_SERVICE_OBJECT_PATH, /* object name of the signal */
-               target_if_name,                 /* interface name of the signal */
-               STT_SIGNAL_STOP );              /* name of the signal */
+       SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] Send change state message : uid(%d), state(%d)", uid, state);
+
+       msg = dbus_message_new_method_call(
+               service_name, 
+               STT_CLIENT_SERVICE_OBJECT_PATH, 
+               target_if_name, 
+               STTD_METHOD_SET_STATE);
 
        if (NULL == msg) { 
-               SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Fail to create stop message"); 
+               SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Fail to create message"); 
                return -1;
        }
 
-       dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
+       dbus_message_append_args(msg, 
+               DBUS_TYPE_INT32, &uid, 
+               DBUS_TYPE_INT32, &state, 
+               DBUS_TYPE_INVALID);
 
-       /* send the message and flush the connection */
-       if (!dbus_connection_send(g_conn, msg, NULL)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Out Of Memory!"); 
-               return -1;
-       }
+       DBusError err;
+       dbus_error_init(&err);
 
-       dbus_connection_flush(g_conn);
+       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);
 
-       return 0;
-}
+       if (NULL != result_msg) {
+               dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
+
+               if (dbus_error_is_set(&err)) { 
+                       SLOG(LOG_ERROR, TAG_STTD, "[Dbus] Get arguments error (%s)\n", err.message);
+                       dbus_error_free(&err); 
+                       result = -1;
+               }
+
+               dbus_message_unref(result_msg);
+       } else {
+               SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] Result message is NULL. Client is not available");
+       }
 
+       return result;
+}
 
 static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handler)
 {
@@ -277,16 +444,19 @@ 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;
        }
 
 
        /* daemon internal event */
-       if (dbus_message_is_signal(msg, STT_SERVER_SERVICE_INTERFACE, STT_SIGNAL_STOP_BY_DAEMON))
+       if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STTD_METHOD_STOP_BY_DAEMON))
                sttd_dbus_server_stop_by_daemon(msg);
 
        /* client event */
+       else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_METHOD_HELLO))
+               sttd_dbus_server_hello(conn, msg);
+
        else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_METHOD_INITIALIZE))
                sttd_dbus_server_initialize(conn, msg);
        
@@ -316,6 +486,9 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
 
 
        /* setting event */
+       else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_SETTING_METHOD_HELLO))
+               sttd_dbus_server_hello(conn, msg);
+
        else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_SETTING_METHOD_INITIALIZE))
                sttd_dbus_server_setting_initialize(conn, msg);
 
@@ -366,8 +539,9 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
        else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_SETTING_METHOD_SET_ENGINE_SETTING))
                sttd_dbus_server_setting_set_engine_setting(conn, msg);
 
-       else 
-               return ECORE_CALLBACK_RENEW; 
+
+       /* free the message */
+       dbus_message_unref(msg);
 
        return ECORE_CALLBACK_RENEW;
 }
@@ -459,10 +633,11 @@ int sttd_send_stop_recognition_by_daemon(int uid)
 {
        DBusMessage* msg;
 
-       msg = dbus_message_new_signal(
-               STT_SERVER_SERVICE_OBJECT_PATH, /* object name of the signal */
-               STT_SERVER_SERVICE_INTERFACE,   /* interface name of the signal */
-               STT_SIGNAL_STOP_BY_DAEMON );    /* name of the signal */
+       msg = dbus_message_new_method_call(
+               STT_SERVER_SERVICE_NAME, 
+               STT_SERVER_SERVICE_OBJECT_PATH, 
+               STT_SERVER_SERVICE_INTERFACE, 
+               STTD_METHOD_STOP_BY_DAEMON);
 
        if (NULL == msg) { 
                SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] >>>> Fail to make message for 'stop by daemon'"); 
old mode 100644 (file)
new mode 100755 (executable)
index 37dbb13..1720de7
@@ -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,13 +24,17 @@ int sttd_dbus_open_connection();
 int sttd_dbus_close_connection();
 
 
+int sttdc_send_hello(int uid);
+
+int sttdc_send_get_state(int uid, int* state);
+
 int sttdc_send_result(int uid, const char* type, const char** data, int data_count, const char* result_msg);
 
 int sttdc_send_partial_result(int uid, const char* data);
 
 int sttdc_send_error_signal(int uid, int reason, char *err_msg);
 
-int sttd_send_stop(int uid);
+int sttdc_send_set_state(int uid, int state);
 
 int sttd_send_stop_recognition_by_daemon(int uid);
 
old mode 100644 (file)
new mode 100755 (executable)
index cf8b6cb..648ddb6
@@ -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
 * Dbus Client-Daemon Server
 */ 
 
+int sttd_dbus_server_hello(DBusConnection* conn, DBusMessage* msg)
+{
+       SLOG(LOG_DEBUG, TAG_STTD, ">>>>> STT Hello");
+
+       DBusMessage* reply;
+       reply = dbus_message_new_method_return(msg);
+
+       if (NULL != reply) {
+               if (!dbus_connection_send(conn, reply, NULL)) {
+                       SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Out Of Memory!");
+               }
+
+               dbus_connection_flush(conn);
+               dbus_message_unref(reply);
+       } else {
+               SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); 
+       }
+
+       SLOG(LOG_DEBUG, TAG_STTD, "<<<<<");
+       SLOG(LOG_DEBUG, TAG_STTD, "  ");
+
+       return 0;
+}
+
 int sttd_dbus_server_initialize(DBusConnection* conn, DBusMessage* msg)
 {
        DBusError err;
@@ -30,6 +54,10 @@ int sttd_dbus_server_initialize(DBusConnection* conn, DBusMessage* msg)
 
        int pid;
        int uid;
+       bool silence_supported = false;
+       bool profanity_supported = false;
+       bool punctuation_supported = false;
+
        int ret = STTD_ERROR_OPERATION_FAILED;
 
        dbus_message_get_args(msg, &err,
@@ -45,17 +73,23 @@ int sttd_dbus_server_initialize(DBusConnection* conn, DBusMessage* msg)
                ret = STTD_ERROR_OPERATION_FAILED;
        } else {
                SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt initialize : pid(%d), uid(%d)", pid , uid); 
-               ret =  sttd_server_initialize(pid, uid);
+               ret =  sttd_server_initialize(pid, uid, &silence_supported, &profanity_supported, &punctuation_supported);
        }
 
        DBusMessage* reply;
        reply = dbus_message_new_method_return(msg);
 
        if (NULL != reply) {
-               dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
+               dbus_message_append_args(reply, 
+                       DBUS_TYPE_INT32, &ret, 
+                       DBUS_TYPE_INT32, &silence_supported,
+                       DBUS_TYPE_INT32, &profanity_supported,
+                       DBUS_TYPE_INT32, &punctuation_supported,
+                       DBUS_TYPE_INVALID);
 
                if (0 == ret) {
-                       SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); 
+                       SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d), silence(%d), profanity(%d), punctuation(%d)", 
+                               ret, silence_supported, profanity_supported, punctuation_supported); 
                } else {
                        SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); 
                }
@@ -685,22 +719,32 @@ int sttd_dbus_server_setting_get_engine_list(DBusConnection* conn, DBusMessage*
 
                                while (NULL != iter) {
                                        engine = iter->data;
-                                       SLOG(LOG_DEBUG, TAG_STTD, "engine id : %s, engine name : %s, ug_name, : %s", 
-                                               engine->engine_id, engine->engine_name, engine->ug_name);
-
-                                       dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(engine->engine_id) );
-                                       dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(engine->engine_name) );
-                                       dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(engine->ug_name) );
-
-                                       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);
-                                               g_free(engine);
 
+                                       if (NULL != engine) {
+
+                                               if (NULL != engine->engine_id && NULL != engine->engine_name && NULL != engine->ug_name) {
+                                                       SLOG(LOG_DEBUG, TAG_STTD, "engine id : %s, engine name : %s, ug_name, : %s", 
+                                                               engine->engine_id, engine->engine_name, engine->ug_name);
+
+                                                       dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(engine->engine_id) );
+                                                       dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(engine->engine_name) );
+                                                       dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(engine->ug_name) );
+                                               } else {
+                                                       SLOG(LOG_ERROR, TAG_STTD, "[ERROR] Engine info is NULL");
+                                               }
+                                               
+                                               if (NULL != engine->engine_id)
+                                                       g_free(engine->engine_id);
+                                               if (NULL != engine->engine_name)
+                                                       g_free(engine->engine_name);
+                                               if (NULL != engine->ug_name)
+                                                       g_free(engine->ug_name);
+                                               
+                                               g_free(engine);
+                                       } else {
+                                               SLOG(LOG_ERROR, TAG_STTD, "[ERROR] Engine info is NULL");
+                                       }
+                                       
                                        engine_list = g_list_remove_link(engine_list, iter);
 
                                        iter = g_list_first(engine_list);
@@ -1399,16 +1443,24 @@ int sttd_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) {
+                                                       if (NULL != setting->key && NULL != setting->value) {
+                                                               dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(setting->key) );
+                                                               dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(setting->value) );
+                                                       } else {
+                                                               SLOG(LOG_ERROR, TAG_STTD, "[ERROR] setting key is NULL"); 
+                                                       }
 
-                                               if (NULL != setting->key)
-                                                       g_free(setting->key);
-                                               if (NULL != setting->value)
-                                                       g_free(setting->value);
-                                               if (NULL != setting);
-                                                       g_free(setting);
+                                                       if (NULL != setting->key) 
+                                                               g_free(setting->key);
+                                                       if (NULL != setting->value) 
+                                                               g_free(setting->value);
 
+                                                       g_free(setting);
+                                               } else {
+                                                       SLOG(LOG_ERROR, TAG_STTD, "[ERROR] setting key is NULL"); 
+                                               }
+                                               
                                                engine_setting_list = g_list_remove_link(engine_setting_list, iter);
 
                                                iter = g_list_first(engine_setting_list);
@@ -1512,11 +1564,13 @@ int sttd_dbus_server_stop_by_daemon(DBusMessage* msg)
                sttd_server_stop(uid);
 
                /* check silence detection option from config */
-               int ret = sttd_send_stop(uid); 
+               int ret = sttdc_send_set_state(uid, (int)APP_STATE_PROCESSING);
                if (0 == ret) {
                        SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); 
                } else {
                        SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); 
+                       /* Remove client */
+                       sttd_server_finalize(uid);
                }
        }
        
old mode 100644 (file)
new mode 100755 (executable)
index 23a55ab..690e409
@@ -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,9 @@ extern "C" {
 
 #include <dbus/dbus.h>
 
+
+int sttd_dbus_server_hello(DBusConnection* conn, DBusMessage* msg);
+
 /*
 * Dbus Server functions for APIs
 */ 
old mode 100644 (file)
new mode 100755 (executable)
index c18e09e..89be638
@@ -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
@@ -36,6 +36,8 @@ typedef struct {
        bool    is_loaded;      
        bool    need_network;
        bool    support_silence_detection;
+       bool    support_profanity_filter;
+       bool    support_punctuation_override;
        void    *handle;
 
        /* engine base setting */
@@ -148,35 +150,32 @@ int sttd_engine_agent_init(result_callback result_cb, partial_result_callback pa
 
        g_agent_init = true;
 
-       if (0 != sttd_config_get_char_type(CONFIG_KEY_DEFAULT_LANGUAGE, &(g_cur_engine.default_lang)) ) {
-               /* Default Voice is NULL */
-               SLOG(LOG_WARN, TAG_STTD, "[Server WARNING] There is No default language in config"); 
-               g_cur_engine.default_lang = NULL;
+       if (0 != sttd_config_get_default_language(&(g_cur_engine.default_lang))) {
+               SLOG(LOG_WARN, TAG_STTD, "[Server WARNING] There is No default voice in config"); 
+               /* Set default voice */
+               g_cur_engine.default_lang = strdup("en_US");
        }
 
-       bool temp;
-       if (0 != sttd_config_get_bool_type(CONFIG_KEY_PROFANITY_FILTER, &temp)) {
-               SLOG(LOG_WARN, TAG_STTD, "[Server WARNING] There is No profanity filter value in config"); 
-               sttd_config_set_bool_type(CONFIG_KEY_PROFANITY_FILTER, false);
-               g_default_profanity_filter = false;
+       int temp;
+       if (0 != sttd_config_get_default_silence_detection(&temp)) {
+               SLOG(LOG_WARN, TAG_STTD, "[Server WARNING] There is no silence detection in config"); 
+               g_default_silence_detected = true;
        } else {
-               g_default_profanity_filter = temp;
+               g_default_silence_detected = (bool)temp;
        }
 
-       if (0 != sttd_config_get_bool_type(CONFIG_KEY_PUNCTUATION_OVERRIDE, &temp)) {
-               SLOG(LOG_WARN, TAG_STTD, "[Server WARNING] There is No punctuation override value in config"); 
-               sttd_config_set_bool_type(CONFIG_KEY_PUNCTUATION_OVERRIDE, false);
-               g_default_punctuation_override = false;
+       if (0 != sttd_config_get_default_profanity_filter(&temp)) {
+               SLOG(LOG_WARN, TAG_STTD, "[Server WARNING] There is no profanity filter in config"); 
+               g_default_profanity_filter = false;
        } else {
-               g_default_punctuation_override = temp;
+               g_default_profanity_filter = (bool)temp;
        }
 
-       if (0 != sttd_config_get_bool_type(CONFIG_KEY_SILENCE_DETECTION, &temp)) {
-               SLOG(LOG_WARN, TAG_STTD, "[Server WARNING] There is no silence detection in config"); 
-               sttd_config_set_bool_type(CONFIG_KEY_SILENCE_DETECTION, true);
-               g_default_silence_detected = true;
+       if (0 != sttd_config_get_default_punctuation_override(&temp)) {
+               SLOG(LOG_WARN, TAG_STTD, "[Server WARNING] There is no punctuation override in config"); 
+               g_default_punctuation_override = false;
        } else {
-               g_default_silence_detected = temp;
+               g_default_punctuation_override = (bool)temp;
        }
 
        SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent SUCCESS] Engine Agent Initialize"); 
@@ -188,7 +187,7 @@ int sttd_engine_agent_release()
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
-               return STTD_ERROR_INVALID_STATE;
+               return STTD_ERROR_OPERATION_FAILED;
        }
 
        /* unload current engine */
@@ -235,7 +234,7 @@ int sttd_engine_agent_initialize_current_engine()
        /* check agent init */
        if (false == g_agent_init ) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
-               return STTD_ERROR_INVALID_STATE;
+               return STTD_ERROR_OPERATION_FAILED;
        }
 
        /* update engine list */
@@ -248,7 +247,7 @@ int sttd_engine_agent_initialize_current_engine()
        char* cur_engine_uuid = NULL;
        bool is_get_engineid_from_config = false;
 
-       if (0 != sttd_config_get_char_type(CONFIG_KEY_DEFAULT_ENGINE_ID, &cur_engine_uuid)) {
+       if (0 != sttd_config_get_default_engine(&cur_engine_uuid)) {
 
                SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] There is not current engine from config"); 
 
@@ -310,7 +309,7 @@ int sttd_engine_agent_initialize_current_engine()
        }
 
        if (false == is_get_engineid_from_config) {
-               if (0 != sttd_config_set_char_type(CONFIG_KEY_DEFAULT_ENGINE_ID, cur_engine_uuid))
+               if (0 != sttd_config_set_default_engine(cur_engine_uuid))
                        SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to set default engine "); 
        }
 
@@ -381,14 +380,14 @@ int __internal_get_engine_info(const char* filepath, sttengine_info_s** info)
        /* link engine to daemon */
        dlsym(handle, "sttp_load_engine");
        if ((error = dlerror()) != NULL) {
-               SLOG(LOG_WARN, TAG_STTD, "[Engine Agent] Invalid engine. Fail to open sttp_load_engine : %s", filepath); 
+               SLOG(LOG_WARN, TAG_STTD, "[Engine Agent] Invalid engine. Fail to open sttp_load_engine : %s", error); 
                dlclose(handle);
                return -1;
        }
 
        dlsym(handle, "sttp_unload_engine");
        if ((error = dlerror()) != NULL) {
-               SLOG(LOG_WARN, TAG_STTD, "[Engine Agent] Invalid engine. Fail to open sttp_unload_engine : %s", filepath); 
+               SLOG(LOG_WARN, TAG_STTD, "[Engine Agent] Invalid engine. Fail to open sttp_unload_engine : %s", error); 
                dlclose(handle);
                return -1;
        }
@@ -396,8 +395,8 @@ int __internal_get_engine_info(const char* filepath, sttengine_info_s** info)
        int (*get_engine_info)(sttpe_engine_info_cb callback, void* user_data);
 
        get_engine_info = (int (*)(sttpe_engine_info_cb, void*))dlsym(handle, "sttp_get_engine_info");
-       if ((error = dlerror()) != NULL) {
-               SLOG(LOG_WARN, TAG_STTD, "[Engine Agent WARNING] Invalid engine. Fail to open sttp_get_engine_info : %s", filepath); 
+       if ((error = dlerror()) != NULL || NULL == get_engine_info) {
+               SLOG(LOG_WARN, TAG_STTD, "[Engine Agent WARNING] Invalid engine. Fail to open sttp_get_engine_info : %s", error); 
                dlclose(handle);
                return -1;
        }
@@ -460,43 +459,78 @@ int __internal_update_engine_list()
                }
        }
 
-       /* get file name from engine directory and get engine infomation from each filename */
+       /* Get file name from default engine directory */
        DIR *dp;
        struct dirent *dirp;
-       dp  = opendir(ENGINE_DIRECTORY);
-       if (NULL == dp) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] __internal_update_engine_list : error opendir"); 
-               return -1;
-       }
 
-       while (NULL != (dirp = readdir(dp))) {
-               sttengine_info_s* info;
-               char* filepath;
-               int filesize;
-               
-               filesize = strlen(ENGINE_DIRECTORY) + strlen(dirp->d_name) + 5;
-               filepath = (char*) g_malloc0(sizeof(char) * filesize);
-               
-               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_STTD, "[Engine Agent ERROR] Memory not enough!!" );
-                       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);
+       dp  = opendir(ENGINE_DIRECTORY_DEFAULT);
+       if (NULL != dp) {
+               while (NULL != (dirp = readdir(dp))) {
+                       sttengine_info_s* info;
+                       char* filepath;
+                       int filesize;
+
+                       filesize = strlen(ENGINE_DIRECTORY_DEFAULT) + strlen(dirp->d_name) + 5;
+                       filepath = (char*) g_malloc0(sizeof(char) * filesize);
+
+                       if (NULL != filepath) {
+                               strncpy(filepath, ENGINE_DIRECTORY_DEFAULT, strlen(ENGINE_DIRECTORY_DEFAULT) );
+                               strncat(filepath, "/", strlen("/") );
+                               strncat(filepath, dirp->d_name, strlen(dirp->d_name) );
+                       } else {
+                               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Memory not enough!!" );
+                               continue;       
+                       }
+
+                       /* 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);
+       } else {
+               SLOG(LOG_WARN, TAG_STTD, "[Engine Agent WARNING] Fail to open default directory"); 
        }
+       
+       /* Get file name from downloadable engine directory */
+       dp  = opendir(ENGINE_DIRECTORY_DOWNLOAD);
+       if (NULL != dp) {
+               while (NULL != (dirp = readdir(dp))) {
+                       sttengine_info_s* info;
+                       char* filepath;
+                       int filesize;
+
+                       filesize = strlen(ENGINE_DIRECTORY_DOWNLOAD) + strlen(dirp->d_name) + 5;
+                       filepath = (char*) g_malloc0(sizeof(char) * filesize);
+
+                       if (NULL != filepath) {
+                               strncpy(filepath, ENGINE_DIRECTORY_DOWNLOAD, strlen(ENGINE_DIRECTORY_DOWNLOAD) );
+                               strncat(filepath, "/", strlen("/") );
+                               strncat(filepath, dirp->d_name, strlen(dirp->d_name) );
+                       } else {
+                               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Memory not enough!!" );
+                               continue;       
+                       }
+
+                       /* 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);
+               }
 
-       closedir(dp);
+               closedir(dp);
+       } else {
+               SLOG(LOG_WARN, TAG_STTD, "[Engine Agent WARNING] Fail to open downloadable directory"); 
+       }
 
        if (0 >= g_list_length(g_engine_list)) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] No Engine"); 
@@ -567,7 +601,6 @@ int __internal_set_current_engine(const char* engine_uuid)
        g_cur_engine.is_loaded = false;
        g_cur_engine.is_set = true;
        g_cur_engine.need_network = data->use_network;
-       g_cur_engine.support_silence_detection = data->support_silence_detection;
 
        g_cur_engine.profanity_filter = g_default_profanity_filter;
        g_cur_engine.punctuation_override = g_default_punctuation_override;
@@ -586,7 +619,7 @@ int sttd_engine_agent_load_current_engine()
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
-               return STTD_ERROR_INVALID_STATE;
+               return STTD_ERROR_OPERATION_FAILED;
        }
 
        if (false == g_cur_engine.is_set) {
@@ -606,20 +639,20 @@ int sttd_engine_agent_load_current_engine()
        char *error;
        g_cur_engine.handle = dlopen(g_cur_engine.engine_path, RTLD_LAZY);
 
-       if ((error = dlerror()) != NULL || !g_cur_engine.handle) {
+       if (NULL != (error = dlerror()) || !g_cur_engine.handle) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to get engine handle"); 
                return STTD_ERROR_OPERATION_FAILED;
        }
        
        g_cur_engine.sttp_unload_engine = (int (*)())dlsym(g_cur_engine.handle, "sttp_unload_engine");
-       if ((error = dlerror()) != NULL) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to link daemon to sttp_unload_engine()"); 
+       if (NULL != (error = dlerror()) || NULL == g_cur_engine.sttp_unload_engine) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to link daemon to sttp_unload_engine() : %s", error); 
                return STTD_ERROR_OPERATION_FAILED;
        }
 
        g_cur_engine.sttp_load_engine = (int (*)(sttpd_funcs_s*, sttpe_funcs_s*) )dlsym(g_cur_engine.handle, "sttp_load_engine");
-       if ((error = dlerror()) != NULL) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to link daemon to sttp_load_engine()"); 
+       if (NULL != (error = dlerror()) || NULL == g_cur_engine.sttp_load_engine) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to link daemon to sttp_load_engine() : %s", error); 
                return STTD_ERROR_OPERATION_FAILED;
        }
 
@@ -654,11 +687,16 @@ int sttd_engine_agent_load_current_engine()
                return STTD_ERROR_OPERATION_FAILED;
        }
        
+       /* check and set profanity filter */
        ret = g_cur_engine.pefuncs->set_profanity_filter(g_cur_engine.profanity_filter);
        if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine ERROR] Fail to set profanity filter value to engine");
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent] Not support profanity filter");
+               g_cur_engine.support_profanity_filter = false;
+       } else {
+               g_cur_engine.support_profanity_filter = true;
        }
        
+       /* check and set punctuation */
        if (NULL == g_cur_engine.pefuncs->set_punctuation) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] set_punctuation of engine is NULL!!");
                return STTD_ERROR_OPERATION_FAILED;
@@ -666,19 +704,24 @@ int sttd_engine_agent_load_current_engine()
 
        ret = g_cur_engine.pefuncs->set_punctuation(g_cur_engine.punctuation_override);
        if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine ERROR] Fail to set punctuation override value to engine");
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine ERROR] Not support punctuation override");
+               g_cur_engine.support_punctuation_override = false;
+       } else {
+               g_cur_engine.support_punctuation_override = true;
        }
-       
-       if (true == g_cur_engine.support_silence_detection) {
-               if (NULL == g_cur_engine.pefuncs->set_silence_detection) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] set_silence_detection of engine is NULL!!");
-                       return STTD_ERROR_OPERATION_FAILED;
-               }
 
-               ret = g_cur_engine.pefuncs->set_silence_detection(g_cur_engine.silence_detection);
-               if (0 != ret) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[Engine ERROR] Fail to set silence detection value(%s)", g_cur_engine.silence_detection ? "true":"false");
-               }
+       /* check and set silence detection */
+       if (NULL == g_cur_engine.pefuncs->set_silence_detection) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] set_silence_detection of engine is NULL!!");
+               return STTD_ERROR_OPERATION_FAILED;
+       }
+
+       ret = g_cur_engine.pefuncs->set_silence_detection(g_cur_engine.silence_detection);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine ERROR] Not support silence detection");
+               g_cur_engine.support_silence_detection = false;
+       } else {
+               g_cur_engine.support_silence_detection = true;
        }
        
        /* select default language */
@@ -721,8 +764,8 @@ int sttd_engine_agent_load_current_engine()
                                        return STTD_ERROR_OPERATION_FAILED;
                                }
 
-                               sttd_config_set_char_type(CONFIG_KEY_DEFAULT_LANGUAGE, temp_lang);
-                               
+                               sttd_config_set_default_language(temp_lang);
+
                                g_cur_engine.default_lang = g_strdup(temp_lang);
                                
                                SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent SUCCESS] Select default voice : lang(%s)", temp_lang);
@@ -750,7 +793,7 @@ int sttd_engine_agent_unload_current_engine()
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized "); 
-               return STTD_ERROR_INVALID_STATE;
+               return STTD_ERROR_OPERATION_FAILED;
        }
 
        if (false == g_cur_engine.is_set) {
@@ -788,7 +831,7 @@ bool sttd_engine_agent_need_network()
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized" );
-               return STTD_ERROR_INVALID_STATE;
+               return STTD_ERROR_OPERATION_FAILED;
        }
 
        if (false == g_cur_engine.is_loaded) {
@@ -799,6 +842,30 @@ bool sttd_engine_agent_need_network()
        return g_cur_engine.need_network;
 }
 
+int sttd_engine_get_option_supported(bool* silence, bool* profanity, bool* punctuation)
+{
+       if (false == g_agent_init) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized" );
+               return STTD_ERROR_OPERATION_FAILED;
+       }
+
+       if (false == g_cur_engine.is_loaded) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine");
+               return STTD_ERROR_OPERATION_FAILED;
+       }
+
+       if (NULL == silence || NULL == profanity || NULL == punctuation) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter"); 
+               return STTD_ERROR_INVALID_PARAMETER;
+       }
+
+       *silence = g_cur_engine.support_silence_detection;
+       *profanity = g_cur_engine.support_profanity_filter;
+       *punctuation = g_cur_engine.support_punctuation_override;
+
+       return 0;
+}
+
 /*
 * STT Engine Interfaces for client
 */
@@ -888,7 +955,7 @@ int __set_option(int profanity, int punctuation, int silence)
                }
        } else {
                /* Client selection */
-               if (g_cur_engine.silence_detection != punctuation) {
+               if (g_cur_engine.silence_detection != silence) {
                        if (NULL != g_cur_engine.pefuncs->set_silence_detection) {
                                if (0 != g_cur_engine.pefuncs->set_silence_detection((bool)silence)) {
                                        SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to set silence detection");
@@ -912,7 +979,7 @@ int sttd_engine_recognize_start(const char* lang, const char* recognition_type,
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
-               return STTD_ERROR_INVALID_STATE;
+               return STTD_ERROR_OPERATION_FAILED;
        }
 
        if (false == g_cur_engine.is_loaded) {
@@ -959,7 +1026,7 @@ int sttd_engine_recognize_audio(const void* data, unsigned int length)
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
-               return STTD_ERROR_INVALID_STATE;
+               return STTD_ERROR_OPERATION_FAILED;
        }
 
        if (false == g_cur_engine.is_loaded) {
@@ -979,7 +1046,7 @@ int sttd_engine_recognize_audio(const void* data, unsigned int length)
 
        int ret = g_cur_engine.pefuncs->set_recording(data, length);
        if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] set recording error(%d)", ret); 
+               SLOG(LOG_WARN, TAG_STTD, "[Engine Agent WARNING] set recording error(%d)", ret); 
                return ret;
        }
 
@@ -990,7 +1057,7 @@ int sttd_engine_recognize_stop()
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
-               return STTD_ERROR_INVALID_STATE;
+               return STTD_ERROR_OPERATION_FAILED;
        }
 
        if (false == g_cur_engine.is_loaded) {
@@ -1016,7 +1083,7 @@ int sttd_engine_recognize_cancel()
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
-               return STTD_ERROR_INVALID_STATE;
+               return STTD_ERROR_OPERATION_FAILED;
        }
 
        if (false == g_cur_engine.is_loaded) {
@@ -1042,7 +1109,7 @@ int sttd_engine_get_audio_format(sttp_audio_type_e* types, int* rate, int* chann
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
-               return STTD_ERROR_INVALID_STATE;
+               return STTD_ERROR_OPERATION_FAILED;
        }
 
        if (false == g_cur_engine.is_loaded) {
@@ -1090,7 +1157,7 @@ int sttd_engine_supported_langs(GList** lang_list)
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
-               return STTD_ERROR_INVALID_STATE;
+               return STTD_ERROR_OPERATION_FAILED;
        }
 
        if (false == g_cur_engine.is_loaded) {
@@ -1117,7 +1184,7 @@ int sttd_engine_get_default_lang(char** lang)
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
-               return STTD_ERROR_INVALID_STATE;
+               return STTD_ERROR_OPERATION_FAILED;
        }
 
        if (false == g_cur_engine.is_loaded) {
@@ -1140,7 +1207,7 @@ int sttd_engine_is_partial_result_supported(bool* partial_result)
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
-               return STTD_ERROR_INVALID_STATE;
+               return STTD_ERROR_OPERATION_FAILED;
        }
 
        if (false == g_cur_engine.is_loaded) {
@@ -1172,7 +1239,7 @@ int sttd_engine_setting_get_engine_list(GList** engine_list)
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
-               return STTD_ERROR_INVALID_STATE;
+               return STTD_ERROR_OPERATION_FAILED;
        }
 
        if (false == g_cur_engine.is_loaded) {
@@ -1238,7 +1305,7 @@ int sttd_engine_setting_set_engine(const char* engine_id)
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
-               return STTD_ERROR_INVALID_STATE;
+               return STTD_ERROR_OPERATION_FAILED;
        }
 
        if (NULL == engine_id) {
@@ -1249,7 +1316,7 @@ int sttd_engine_setting_set_engine(const char* engine_id)
        /* compare current engine and new engine. */
        if (NULL != g_cur_engine.engine_uuid) {
                if (0 == strncmp(g_cur_engine.engine_uuid, engine_id, strlen(g_cur_engine.engine_uuid))) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent] New engine is the same as current engine"); 
+                       SLOG(LOG_WARN, TAG_STTD, "[Engine Agent] New engine is the same as current engine"); 
                        return 0;
                }
        }
@@ -1273,6 +1340,7 @@ int sttd_engine_setting_set_engine(const char* engine_id)
                
                /* roll back to old current engine. */
                __internal_set_current_engine(tmp_uuid);
+               sttd_engine_agent_load_current_engine();
 
                if (NULL != tmp_uuid)   
                        free(tmp_uuid);
@@ -1295,7 +1363,7 @@ int sttd_engine_setting_set_engine(const char* engine_id)
                free(tmp_uuid);
 
        /* set engine id to config */
-       if (0 != sttd_config_set_char_type(CONFIG_KEY_DEFAULT_ENGINE_ID, engine_id)) {
+       if (0 != sttd_config_set_default_engine(engine_id)) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to set engine id"); 
        }
 
@@ -1306,7 +1374,7 @@ int sttd_engine_setting_get_lang_list(char** engine_id, GList** lang_list)
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
-               return STTD_ERROR_INVALID_STATE;
+               return STTD_ERROR_OPERATION_FAILED;
        }
 
        if (false == g_cur_engine.is_loaded) {
@@ -1335,7 +1403,7 @@ int sttd_engine_setting_get_default_lang(char** language)
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
-               return STTD_ERROR_INVALID_STATE;
+               return STTD_ERROR_OPERATION_FAILED;
        }
 
        if (false == g_cur_engine.is_loaded) {
@@ -1376,7 +1444,7 @@ int sttd_engine_setting_get_default_lang(char** language)
                                        return STTD_ERROR_OPERATION_FAILED;
                                }
 
-                               sttd_config_set_char_type(CONFIG_KEY_DEFAULT_LANGUAGE, temp_lang);
+                               sttd_config_set_default_language(temp_lang);
 
                                g_cur_engine.default_lang = g_strdup(temp_lang);
 
@@ -1402,7 +1470,7 @@ int sttd_engine_setting_set_default_lang(const char* language)
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
-               return STTD_ERROR_INVALID_STATE;
+               return STTD_ERROR_OPERATION_FAILED;
        }
 
        if (false == g_cur_engine.is_loaded) {
@@ -1426,7 +1494,7 @@ int sttd_engine_setting_set_default_lang(const char* language)
 
        g_cur_engine.default_lang = strdup(language);
 
-       ret = sttd_config_set_char_type(CONFIG_KEY_DEFAULT_LANGUAGE, language);
+       ret = sttd_config_set_default_language(language);
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to set default lang (%d)", ret); 
        }
@@ -1438,7 +1506,7 @@ int sttd_engine_setting_get_profanity_filter(bool* value)
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
-               return STTD_ERROR_INVALID_STATE;
+               return STTD_ERROR_OPERATION_FAILED;
        }
 
        if (false == g_cur_engine.is_loaded) {
@@ -1460,7 +1528,7 @@ int sttd_engine_setting_set_profanity_filter(bool value)
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
-               return STTD_ERROR_INVALID_STATE;
+               return STTD_ERROR_OPERATION_FAILED;
        }
 
        if (false == g_cur_engine.is_loaded) {
@@ -1481,7 +1549,7 @@ int sttd_engine_setting_set_profanity_filter(bool value)
 
        g_default_profanity_filter = value;
 
-       ret = sttd_config_set_bool_type(CONFIG_KEY_PROFANITY_FILTER, value);
+       ret = sttd_config_set_default_profanity_filter((int)value);
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to set default lang (%d)", ret); 
        }
@@ -1493,7 +1561,7 @@ int sttd_engine_setting_get_punctuation_override(bool* value)
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
-               return STTD_ERROR_INVALID_STATE;
+               return STTD_ERROR_OPERATION_FAILED;
        }
 
        if (false == g_cur_engine.is_loaded) {
@@ -1515,7 +1583,7 @@ int sttd_engine_setting_set_punctuation_override(bool value)
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
-               return STTD_ERROR_INVALID_STATE;
+               return STTD_ERROR_OPERATION_FAILED;
        }
 
        if (false == g_cur_engine.is_loaded) {
@@ -1535,7 +1603,7 @@ int sttd_engine_setting_set_punctuation_override(bool value)
        }
        g_default_punctuation_override = value;
 
-       ret = sttd_config_set_bool_type(CONFIG_KEY_PUNCTUATION_OVERRIDE, value);
+       ret = sttd_config_set_default_punctuation_override((int)value);
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to set punctuation override (%d)", ret); 
        }
@@ -1547,7 +1615,7 @@ int sttd_engine_setting_get_silence_detection(bool* value)
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
-               return STTD_ERROR_INVALID_STATE;
+               return STTD_ERROR_OPERATION_FAILED;
        }
 
        if (false == g_cur_engine.is_loaded) {
@@ -1569,7 +1637,7 @@ int sttd_engine_setting_set_silence_detection(bool value)
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
-               return STTD_ERROR_INVALID_STATE;
+               return STTD_ERROR_OPERATION_FAILED;
        }
 
        if (false == g_cur_engine.is_loaded) {
@@ -1585,7 +1653,7 @@ int sttd_engine_setting_set_silence_detection(bool value)
        
        g_default_silence_detected = value;
 
-       ret = sttd_config_set_bool_type(CONFIG_KEY_SILENCE_DETECTION, value);
+       ret = sttd_config_set_default_silence_detection((int)value);
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to set silence detection (%d)", ret); 
        }
@@ -1615,7 +1683,7 @@ int sttd_engine_setting_get_engine_setting_info(char** engine_id, GList** settin
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
-               return STTD_ERROR_INVALID_STATE;
+               return STTD_ERROR_OPERATION_FAILED;
        }
 
        if (false == g_cur_engine.is_loaded) {
@@ -1652,7 +1720,7 @@ int sttd_engine_setting_set_engine_setting(const char* key, const char* value)
 {
        if (false == g_agent_init) {
                SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
-               return STTD_ERROR_INVALID_STATE;
+               return STTD_ERROR_OPERATION_FAILED;
        }
 
        if (false == g_cur_engine.is_loaded) {
old mode 100644 (file)
new mode 100755 (executable)
index aa5a875..83bb44f
@@ -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
@@ -63,6 +63,8 @@ int sttd_print_enginelist();
 /** Get state of current engine to need network */
 bool sttd_engine_agent_need_network();
 
+int sttd_engine_get_option_supported(bool* silence, bool* profanity, bool* punctuation);
+
 /*
 * STT Engine Interfaces for client
 */
old mode 100644 (file)
new mode 100755 (executable)
index dc2b307..2153545
@@ -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
@@ -18,6 +18,9 @@
 #include "sttd_dbus.h"
 
 #include <Ecore.h>
+#include "sttd_server.h"
+
+#define CLIENT_CLEAN_UP_TIME 500
 
 int main(int argc, char** argv)
 {
@@ -37,6 +40,8 @@ int main(int argc, char** argv)
 
        sttd_network_initialize();
 
+       ecore_timer_add(CLIENT_CLEAN_UP_TIME, sttd_cleanup_client, NULL);
+
        printf("stt-daemon start...\n");
 
        SLOG(LOG_DEBUG, TAG_STTD, "[Main] stt-daemon start..."); 
old mode 100644 (file)
new mode 100755 (executable)
index 0e0f550..3245197
@@ -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
@@ -34,24 +34,32 @@ extern "C" {
 
 #define TAG_STTD "sttd"
 
-#define ENGINE_DIRECTORY "/usr/lib/voice/stt/1.0/engine"
-#define ENGINE_DIRECTORY_DOWNLOAD "/opt/apps/voice/stt/engine"
+#define BASE_DIRECTORY_DEFAULT                 "/usr/lib/voice/stt/1.0/"
+#define ENGINE_DIRECTORY_DEFAULT               "/usr/lib/voice/stt/1.0/engine"
+#define ENGINE_DIRECTORY_DEFAULT_SETTING       "/usr/lib/voice/stt/1.0/setting"
+
+#define CONFIG_DIRECTORY                       "/opt/home/app/.voice"
+
+#define ENGINE_DIRECTORY_DOWNLOAD              "/opt/usr/voice/stt/1.0/engine"
+#define ENGINE_DIRECTORY_DOWNLOAD_SETTING      "/opt/usr/voice/stt/1.0/setting"
 
 /* for debug message */
 #define RECORDER_DEBUG
+#define CLIENT_DATA_DEBUG
 
 typedef enum {
-       STTD_ERROR_NONE                 = 0,            /**< Successful */
-       STTD_ERROR_OUT_OF_MEMORY        = -ENOMEM,      /**< Out of Memory */
-       STTD_ERROR_IO_ERROR             = -EIO,         /**< I/O error */
-       STTD_ERROR_INVALID_PARAMETER    = -EINVAL,      /**< Invalid parameter */
-       STTD_ERROR_TIMED_OUT            = -ETIMEDOUT,   /**< No answer from the daemon */
-       STTD_ERROR_RECORDER_BUSY        = -EBUSY,       /**< Busy recorder */
-       STTD_ERROR_OUT_OF_NETWORK       = -ENETDOWN,    /**< Out of network */
-       STTD_ERROR_INVALID_STATE        = -0x0100031,   /**< Invalid state */
-       STTD_ERROR_INVALID_LANGUAGE     = -0x0100032,   /**< Invalid language */
-       STTD_ERROR_ENGINE_NOT_FOUND     = -0x0100033,   /**< No available engine  */    
-       STTD_ERROR_OPERATION_FAILED     = -0x0100034    /**< Operation failed  */
+       STTD_ERROR_NONE                 = 0,                    /**< Successful */
+       STTD_ERROR_OUT_OF_MEMORY        = -ENOMEM,              /**< Out of Memory */
+       STTD_ERROR_IO_ERROR             = -EIO,                 /**< I/O error */
+       STTD_ERROR_INVALID_PARAMETER    = -EINVAL,              /**< Invalid parameter */
+       STTD_ERROR_TIMED_OUT            = -ETIMEDOUT,           /**< No answer from the daemon */
+       STTD_ERROR_RECORDER_BUSY        = -EBUSY,               /**< Busy recorder */
+       STTD_ERROR_OUT_OF_NETWORK       = -ENETDOWN,            /**< Out of network */
+       STTD_ERROR_INVALID_STATE        = -0x0100000 | 0x31,    /**< Invalid state */
+       STTD_ERROR_INVALID_LANGUAGE     = -0x0100000 | 0x32,    /**< Invalid language */
+       STTD_ERROR_ENGINE_NOT_FOUND     = -0x0100000 | 0x33,    /**< No available engine  */    
+       STTD_ERROR_OPERATION_FAILED     = -0x0100000 | 0x34,    /**< Operation failed  */
+       STTD_ERROR_NOT_SUPPORTED_FEATURE= -0x0100000 | 0x35     /**< Not supported feature of current engine */
 }stt_error_e;
 
 typedef struct {
old mode 100644 (file)
new mode 100755 (executable)
index 879cf69..1915516
@@ -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 8f76e74..c6d93da
@@ -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 da65b56..21fe79b
@@ -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
@@ -61,6 +61,10 @@ static bool g_init = false;
 
 static char g_temp_file_name[128] = {'\0',};
 
+#ifdef BUF_SAVE_MODE
+static FILE* g_pFile;
+#endif 
+
 /* Recorder obj */
 sttd_recorder_s *__recorder_getinstance();
 void __recorder_state_set(sttd_recorder_state state);
@@ -576,14 +580,16 @@ int sttd_recorder_start()
 
        /* Check if initialized */
        ret = __recorder_setup();
-       if (ret) {
+       if (0 != ret) {
                SLOG(LOG_DEBUG, TAG_STTD, "[Recorder] Fail to call __recorder_setup");
+               return STTD_ERROR_OPERATION_FAILED;
        }
 
        /* Start camcorder */
        ret = __recorder_run();
-       if (ret) {
-               SLOG(LOG_DEBUG, TAG_STTD, "[Recorder] Fail to call __recorder_run");                
+       if (0 != ret) {
+               SLOG(LOG_DEBUG, TAG_STTD, "[Recorder] Fail to call __recorder_run");    
+               return STTD_ERROR_OPERATION_FAILED;
        }
 
        __recorder_state_set(STTD_RECORDER_STATE_RECORDING);
old mode 100644 (file)
new mode 100755 (executable)
index 6bc4928..4a9833f
@@ -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 2ca7130..d5511b9
@@ -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 bool g_is_engine;
 
+static double g_state_check_time = 15.5;
+
 /*
 * STT Server Callback Functions                                                                                        `                                 *
 */
 
+Eina_Bool __stop_by_silence(void *data)
+{
+       SLOG(LOG_DEBUG, TAG_STTD, "===== Stop by silence detection");
+
+       int uid = 0;
+
+       uid = sttd_client_get_current_recording();
+
+       if (uid > 0) {
+               if (0 != sttd_server_stop(uid))
+                       return EINA_FALSE;
+
+               int ret = sttdc_send_set_state(uid, (int)APP_STATE_PROCESSING);
+               if (0 != ret) {
+                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to send state : result(%d)", ret); 
+
+                       /* Remove client */
+                       sttd_server_finalize(uid);
+               }       
+       }
+
+       SLOG(LOG_DEBUG, TAG_STTD, "=====");
+       SLOG(LOG_DEBUG, TAG_STTD, "  ");
+
+       return EINA_FALSE;
+}
+
 int audio_recorder_callback(const void* data, const unsigned int length)
 {
        if (0 != sttd_engine_recognize_audio(data, length)) {
-               
-               /* send message for stop */
-               SLOG(LOG_DEBUG, TAG_STTD, "===== Fail to set recording data ");
-                       
                int uid = sttd_client_get_current_recording();
 
                app_state_e state;
@@ -51,19 +76,16 @@ int audio_recorder_callback(const void* data, const unsigned int length)
                        return -1;
                }
 
-               if (0 != sttd_send_stop_recognition_by_daemon(uid)) {
+               ecore_timer_add(0, __stop_by_silence, NULL);
+
+               /*if (0 != sttd_send_stop_recognition_by_daemon(uid)) {
                        SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail "); 
                } else {
                        SLOG(LOG_DEBUG, TAG_STTD, "[Server SUCCESS] <<<< stop message : uid(%d)", uid); 
-               }
-
-               SLOG(LOG_DEBUG, TAG_STTD, "=====");
-               SLOG(LOG_DEBUG, TAG_STTD, "  ");
+               }*/
                
                return -1;
        }
-       
-       
 
        return 0;
 }
@@ -73,10 +95,17 @@ void sttd_server_recognition_result_callback(sttp_result_event_e event, const ch
 {
        SLOG(LOG_DEBUG, TAG_STTD, "===== Recognition Result Callback");
 
+       if (NULL == user_data) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] user data is NULL"); 
+               SLOG(LOG_DEBUG, TAG_STTD, "=====");
+               SLOG(LOG_DEBUG, TAG_STTD, "  ");
+               return;
+       }
+
        /* check uid */
        int *uid = (int*)user_data;
 
-       SLOG(LOG_DEBUG, TAG_STTD, "[Server] uid (%d), event(%d)", uid, event); 
+       SLOG(LOG_DEBUG, TAG_STTD, "[Server] uid (%d), event(%d)", *uid, event); 
 
        app_state_e state;
        if (0 != sttd_client_get_state(*uid, &state)) {
@@ -86,6 +115,13 @@ void sttd_server_recognition_result_callback(sttp_result_event_e event, const ch
                return;
        }
 
+       /* Delete timer for processing time out */
+       Ecore_Timer* timer;
+       sttd_cliet_get_timer(*uid, &timer);
+
+       if (NULL != timer)
+               ecore_timer_del(timer);
+
        /* send result to client */
        if (STTP_RESULT_EVENT_SUCCESS == event && 0 < data_count && NULL != data) {
 
@@ -98,54 +134,26 @@ void sttd_server_recognition_result_callback(sttp_result_event_e event, const ch
 
                                if (0 != sttdc_send_error_signal(*uid, reason, "Fail to send recognition result")) {
                                        SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to send error info . Remove client data"); 
-
-                                       /* clean client data */
-                                       sttd_client_delete(*uid);
                                }
                        }
                } else {
-                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Current state is NOT thinking"); 
-
-                       int reason = (int)STTD_ERROR_INVALID_STATE;             
-                       if (0 != sttdc_send_error_signal(*uid, reason, "Client state is NOT thinking. Client don't receive recognition result in current state.")) {
-                               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to send error info. Remove client data "); 
-
-                               /* clean client data */
-                               sttd_client_delete(*uid);               
-                       }
+                       SLOG(LOG_WARN, TAG_STTD, "[Server WARNING] Current state is NOT thinking."); 
                }
-       } else if (STTP_RESULT_EVENT_NO_RESULT == event) {
+       } else if (STTP_RESULT_EVENT_NO_RESULT == event || STTP_RESULT_EVENT_ERROR == event) {
 
                if (APP_STATE_PROCESSING == state ) {
-                       if (0 != sttdc_send_result(*uid, NULL, NULL, 0, NULL)) {
+                       if (0 != sttdc_send_result(*uid, type, NULL, 0, msg)) {
                                SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to send result "); 
 
                                /* send error msg */
                                int reason = (int)STTD_ERROR_INVALID_STATE;     
                                if (0 != sttdc_send_error_signal(*uid, reason, "[ERROR] Fail to send recognition result")) {
                                        SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to send error info "); 
-                                       sttd_client_delete(*uid);
                                }
                        }
                } else {
-                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Current state is NOT thinking "); 
-
-                       int reason = (int)STTD_ERROR_INVALID_STATE;             
-
-                       if (0 != sttdc_send_error_signal(*uid, reason, "Client state is NOT thinking. Client don't receive recognition result in current state.")) {
-                               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to send error info. Remove client data"); 
-
-                               /* clean client data */
-                               sttd_client_delete(*uid);               
-                       }
+                       SLOG(LOG_WARN, TAG_STTD, "[Server ERROR] Current state is NOT thinking."); 
                }
-       } else if (STTP_RESULT_EVENT_ERROR == event) {
-               int reason = (int)STTD_ERROR_OPERATION_FAILED;
-
-               if (0 != sttdc_send_error_signal(*uid, reason, "STT Engine ERROR : Recognition fail")) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to send error info"); 
-                       sttd_client_delete(*uid);
-               }       
        } else {
                /* nothing */
        }
@@ -207,11 +215,7 @@ void sttd_server_silence_dectection_callback(void *user_param)
                return;
        }
 
-       if (0 != sttd_send_stop_recognition_by_daemon(uid)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail "); 
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTD, "[Server SUCCESS] <<<< stop message : uid(%d)", uid); 
-       }
+       ecore_timer_add(0, __stop_by_silence, NULL);
 
        SLOG(LOG_DEBUG, TAG_STTD, "=====");
        SLOG(LOG_DEBUG, TAG_STTD, "  ");
@@ -220,13 +224,17 @@ void sttd_server_silence_dectection_callback(void *user_param)
 }
 
 /*
-* Daemon initialize
+* Daemon function
 */
 
 int sttd_initialize()
 {
        int ret = 0;
 
+       if (sttd_config_initialize()) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server WARNING] Fail to initialize config.");
+       }
+
        /* recoder init */
        ret = sttd_recorder_init();
        if (0 != ret) {
@@ -254,11 +262,46 @@ int sttd_initialize()
        return 0;
 }
 
+Eina_Bool sttd_cleanup_client(void *data)
+{
+       int* client_list = NULL;
+       int client_count = 0;
+
+       if (0 != sttd_client_get_list(&client_list, &client_count)) 
+               return EINA_TRUE;
+       
+       if (NULL == client_list)
+               return EINA_TRUE;
+
+       int result;
+       int i = 0;
+
+       SLOG(LOG_DEBUG, TAG_STTD, "===== Clean up client ");
+
+       for (i = 0;i < client_count;i++) {
+               result = sttdc_send_hello(client_list[i]);
+
+               if (0 == result) {
+                       SLOG(LOG_DEBUG, TAG_STTD, "[Server] uid(%d) should be removed.", client_list[i]); 
+                       sttd_server_finalize(client_list[i]);
+               } else if (-1 == result) {
+                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Hello result has error"); 
+               }
+       }
+
+       SLOG(LOG_DEBUG, TAG_STTD, "=====");
+       SLOG(LOG_DEBUG, TAG_STTD, "  ");
+
+       free(client_list);
+
+       return EINA_TRUE;
+}
+
 /*
 * STT Server Functions for Client
 */
 
-int sttd_server_initialize(int pid, int uid)
+int sttd_server_initialize(int pid, int uid, bool* silence, bool* profanity, bool* punctuation)
 {
        if (false == g_is_engine) {
                if (0 != sttd_engine_agent_initialize_current_engine()) {
@@ -295,8 +338,8 @@ int sttd_server_initialize(int pid, int uid)
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       sttd_recorder_channel   sttchannel;
-       sttd_recorder_audio_type        sttatype;
+       sttd_recorder_channel           sttchannel = STTD_RECORDER_CHANNEL_MONO;
+       sttd_recorder_audio_type        sttatype = STTD_RECORDER_PCM_S16;
 
        switch (atype) {
        case STTP_AUDIO_TYPE_PCM_S16_LE:        sttatype = STTD_RECORDER_PCM_S16;       break;
@@ -310,7 +353,7 @@ int sttd_server_initialize(int pid, int uid)
                break;
        }
 
-       switch (sttchannel) {
+       switch (channels) {
        case 1:         sttchannel = STTD_RECORDER_CHANNEL_MONO;        break;
        case 2:         sttchannel = STTD_RECORDER_CHANNEL_STEREO;      break;
        default:        sttchannel = STTD_RECORDER_CHANNEL_MONO;        break;
@@ -321,13 +364,20 @@ int sttd_server_initialize(int pid, int uid)
                return STTD_ERROR_OPERATION_FAILED;
        }
        
+       SLOG(LOG_DEBUG, TAG_STTD, "[Server] audio type(%d), channel(%d)", (int)atype, (int)sttchannel); 
+
        /* Add client information to client manager */
        if (0 != sttd_client_add(pid, uid)) {
                SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to add client info"); 
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       SLOG(LOG_DEBUG, TAG_STTD, "[Server SUCCESS] audio type(%d), channel(%d)", (int)atype, (int)sttchannel); 
+       if (0 != sttd_engine_get_option_supported(silence, profanity, punctuation)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to get engine options supported"); 
+               return STTD_ERROR_OPERATION_FAILED;
+       }
+
+       SLOG(LOG_DEBUG, TAG_STTD, "[Server Success] Initialize"); 
 
        return STTD_ERROR_NONE;
 }
@@ -342,10 +392,7 @@ int sttd_server_finalize(const int uid)
        }
 
        /* release recorder */
-       app_state_e appstate;
-       sttd_client_get_state(uid, &appstate);
-
-       if (APP_STATE_RECORDING == appstate || APP_STATE_PROCESSING == appstate) {
+       if (APP_STATE_RECORDING == state || APP_STATE_PROCESSING == state) {
                sttd_recorder_cancel();
                sttd_engine_recognize_cancel();
        }
@@ -470,6 +517,39 @@ int sttd_server_get_audio_volume( const int uid, float* current_volume)
        return STTD_ERROR_NONE;
 }
 
+Eina_Bool __check_recording_state(void *data)
+{      
+       /* current uid */
+       int uid = sttd_client_get_current_recording();
+       if (-1 == uid)
+               return EINA_FALSE;
+
+       app_state_e state;
+       if (0 != sttdc_send_get_state(uid, (int*)&state)) {
+               /* client is removed */
+               SLOG(LOG_DEBUG, TAG_STTD, "[Server] uid(%d) should be removed.", uid); 
+               sttd_server_finalize(uid);
+               return EINA_FALSE;
+       }
+
+       if (APP_STATE_READY == state) {
+               /* Cancel stt */
+               SLOG(LOG_DEBUG, TAG_STTD, "[Server] The state of uid(%d) is 'Ready'. The daemon should cancel recording", uid); 
+               sttd_server_cancel(uid);
+       } else if (APP_STATE_PROCESSING == state) {
+               /* Cancel stt and send change state */
+               SLOG(LOG_DEBUG, TAG_STTD, "[Server] The state of uid(%d) is 'Processing'. The daemon should cancel recording", uid); 
+               sttd_server_cancel(uid);
+               sttdc_send_set_state(uid, (int)APP_STATE_READY);
+       } else {
+               /* Normal state */
+               SLOG(LOG_DEBUG, TAG_STTD, "[Server] The states of daemon and client are identical"); 
+               return EINA_TRUE;
+       }
+
+       return EINA_FALSE;
+}
+
 int sttd_server_start(const int uid, const char* lang, const char* recognition_type, 
                      int profanity, int punctuation, int silence)
 {
@@ -532,9 +612,42 @@ int sttd_server_start(const int uid, const char* lang, const char* recognition_t
        /* change uid state */
        sttd_client_set_state(uid, APP_STATE_RECORDING);
 
+       Ecore_Timer* timer = ecore_timer_add(g_state_check_time, __check_recording_state, NULL);
+       sttd_cliet_set_timer(uid, timer);
+
        return STTD_ERROR_NONE;
 }
 
+Eina_Bool __time_out_for_processing(void *data)
+{      
+       /* current uid */
+       int uid = sttd_client_get_current_thinking();
+       if (-1 == uid)
+               return EINA_FALSE;
+
+       /* Cancel engine */
+       int ret = sttd_engine_recognize_cancel();
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to cancel : result(%d)", ret); 
+       }
+
+       if (0 != sttdc_send_result(uid, STTP_RECOGNITION_TYPE_FREE, NULL, 0, "Time out not to receive recognition result.")) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to send result "); 
+
+               /* send error msg */
+               int reason = (int)STTD_ERROR_TIMED_OUT; 
+               if (0 != sttdc_send_error_signal(uid, reason, "[ERROR] Fail to send recognition result")) {
+                       SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to send error info "); 
+               }
+       }
+
+       /* Change uid state */
+       sttd_client_set_state(uid, APP_STATE_READY);
+
+       return EINA_FALSE;
+}
+
+
 int sttd_server_stop(const int uid)
 {
        /* check if uid is valid */
@@ -561,10 +674,19 @@ int sttd_server_stop(const int uid)
        
                return STTD_ERROR_OPERATION_FAILED;
        }
+       
+       Ecore_Timer* timer;
+       sttd_cliet_get_timer(uid, &timer);
+
+       if (NULL != timer)
+               ecore_timer_del(timer);
 
        /* change uid state */
        sttd_client_set_state(uid, APP_STATE_PROCESSING);
 
+       timer = ecore_timer_add(g_state_check_time, __time_out_for_processing, NULL);
+       sttd_cliet_set_timer(uid, timer);
+
        return STTD_ERROR_NONE;
 }
 
@@ -594,6 +716,10 @@ int sttd_server_cancel(const int uid)
                return STTD_ERROR_OPERATION_FAILED;
        }
 
+       Ecore_Timer* timer;
+       sttd_cliet_get_timer(uid, &timer);
+       ecore_timer_del(timer);
+
        /* change uid state */
        sttd_client_set_state(uid, APP_STATE_READY);
 
@@ -605,7 +731,7 @@ int sttd_server_cancel(const int uid)
 * STT Server Functions for setting
 *******************************************************************************************/
 
-int sttd_server_setting_initialize(int uid)
+int sttd_server_setting_initialize(int pid)
 {
        if (false == g_is_engine) {
                if (0 != sttd_engine_agent_initialize_current_engine()) {
@@ -617,10 +743,9 @@ int sttd_server_setting_initialize(int uid)
                }
        }
 
-       /* check if uid is valid */
-       app_state_e state;
-       if (0 == sttd_client_get_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid has already been registered"); 
+       /* check whether pid is valid */
+       if (true == sttd_setting_client_is(pid)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Setting pid is NOT valid "); 
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
@@ -632,26 +757,19 @@ int sttd_server_setting_initialize(int uid)
                }
        }
 
-       /* Add client information to client manager (For internal use) */
-       if (0 != sttd_client_add(uid, uid)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to add client info"); 
+       /* Add setting client information to client manager (For internal use) */
+       if (0 != sttd_setting_client_add(pid)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to add setting client"); 
                return STTD_ERROR_OPERATION_FAILED;
        }
 
        return STTD_ERROR_NONE;
 }
 
-int sttd_server_setting_finalize(int uid)
+int sttd_server_setting_finalize(int pid)
 {
-       /* check if uid is valid */
-       app_state_e state;
-       if (0 != sttd_client_get_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid "); 
-               return STTD_ERROR_INVALID_PARAMETER;
-       }
-
        /* Remove client information */
-       if (0 != sttd_client_delete(uid)) {
+       if (0 != sttd_setting_client_delete(pid)) {
                SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to delete setting client"); 
        }
 
@@ -667,12 +785,11 @@ int sttd_server_setting_finalize(int uid)
        return STTD_ERROR_NONE;
 }
 
-int sttd_server_setting_get_engine_list(int uid, GList** engine_list)
+int sttd_server_setting_get_engine_list(int pid, GList** engine_list)
 {
-       /* check if uid is valid */
-       app_state_e state;
-       if (0 != sttd_client_get_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid "); 
+       /* check whether pid is valid */
+       if (true != sttd_setting_client_is(pid)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Setting pid is NOT valid "); 
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
@@ -684,17 +801,17 @@ int sttd_server_setting_get_engine_list(int uid, GList** engine_list)
        int ret = sttd_engine_setting_get_engine_list(engine_list); 
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to get engine list : result(%d)", ret); 
-               return STTD_ERROR_OPERATION_FAILED;
+               return ret;
        }
 
        return STTD_ERROR_NONE;
 }
 
-int sttd_server_setting_get_engine(int uid, char** engine_id)
+int sttd_server_setting_get_engine(int pid, char** engine_id)
 {
-       app_state_e state;
-       if (0 != sttd_client_get_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid "); 
+       /* check whether pid is valid */
+       if (true != sttd_setting_client_is(pid)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Setting pid is NOT valid "); 
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
@@ -707,18 +824,17 @@ int sttd_server_setting_get_engine(int uid, char** engine_id)
        int ret = sttd_engine_setting_get_engine(engine_id); 
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to get engine : result(%d)", ret); 
-               return STTD_ERROR_OPERATION_FAILED;
+               return ret;
        }
 
        return STTD_ERROR_NONE;
 }
 
-int sttd_server_setting_set_engine(const int uid, const char* engine_id)
+int sttd_server_setting_set_engine(int pid, const char* engine_id)
 {
-       /* check if uid is valid */
-       app_state_e state;
-       if (0 != sttd_client_get_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid "); 
+       /* check whether pid is valid */
+       if (true != sttd_setting_client_is(pid)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Setting pid is NOT valid "); 
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
@@ -731,18 +847,17 @@ int sttd_server_setting_set_engine(const int uid, const char* engine_id)
        int ret = sttd_engine_setting_set_engine(engine_id); 
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to set engine : result(%d)", ret); 
-               return STTD_ERROR_OPERATION_FAILED;
+               return ret;
        }
 
        return STTD_ERROR_NONE;
 }
 
-int sttd_server_setting_get_lang_list(int uid, char** engine_id, GList** lang_list)
+int sttd_server_setting_get_lang_list(int pid, char** engine_id, GList** lang_list)
 {
-       /* check if uid is valid */
-       app_state_e state;
-       if (0 != sttd_client_get_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid "); 
+       /* check whether pid is valid */
+       if (true != sttd_setting_client_is(pid)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Setting pid is NOT valid "); 
                return STTD_ERROR_INVALID_PARAMETER;
        }
        
@@ -754,18 +869,17 @@ int sttd_server_setting_get_lang_list(int uid, char** engine_id, GList** lang_li
        int ret = sttd_engine_setting_get_lang_list(engine_id, lang_list); 
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to get language list : result(%d)", ret); 
-               return STTD_ERROR_OPERATION_FAILED;
+               return ret;
        }
 
        return STTD_ERROR_NONE;
 }
 
-int sttd_server_setting_get_default_language(int uid, char** language)
+int sttd_server_setting_get_default_language(int pid, char** language)
 {
-       /* check if uid is valid */
-       app_state_e state;
-       if (0 != sttd_client_get_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid "); 
+       /* check whether pid is valid */
+       if (true != sttd_setting_client_is(pid)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Setting pid is NOT valid "); 
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
@@ -777,18 +891,17 @@ int sttd_server_setting_get_default_language(int uid, char** language)
        int ret = sttd_engine_setting_get_default_lang(language); 
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to get default language : result(%d)", ret); 
-               return STTD_ERROR_OPERATION_FAILED;
+               return ret;
        }       
 
        return STTD_ERROR_NONE;
 }
 
-int sttd_server_setting_set_default_language(int uid, const char* language)
+int sttd_server_setting_set_default_language(int pid, const char* language)
 {
-       /* check if uid is valid */
-       app_state_e state;
-       if (0 != sttd_client_get_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid "); 
+       /* check whether pid is valid */
+       if (true != sttd_setting_client_is(pid)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Setting pid is NOT valid "); 
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
@@ -800,18 +913,17 @@ int sttd_server_setting_set_default_language(int uid, const char* language)
        int ret = sttd_engine_setting_set_default_lang((char*)language); 
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to set default lang : result(%d)", ret); 
-               return STTD_ERROR_OPERATION_FAILED;
+               return ret;
        }       
 
        return STTD_ERROR_NONE;
 }
 
-int sttd_server_setting_get_profanity_filter(int uid, bool* value)
+int sttd_server_setting_get_profanity_filter(int pid, bool* value)
 {
-       /* check if uid is valid */
-       app_state_e state;
-       if (0 != sttd_client_get_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid "); 
+       /* check whether pid is valid */
+       if (true != sttd_setting_client_is(pid)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Setting pid is NOT valid "); 
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
@@ -824,18 +936,17 @@ int sttd_server_setting_get_profanity_filter(int uid, bool* value)
        ret = sttd_engine_setting_get_profanity_filter(value);
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to get profanity filter : result(%d)", ret); 
-               return STTD_ERROR_OPERATION_FAILED;
+               return ret;
        }       
 
        return STTD_ERROR_NONE;
 }
 
-int sttd_server_setting_set_profanity_filter(int uid, bool value)
+int sttd_server_setting_set_profanity_filter(int pid, bool value)
 {
-       /* check if uid is valid */
-       app_state_e state;
-       if (0 != sttd_client_get_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid "); 
+       /* check whether pid is valid */
+       if (true != sttd_setting_client_is(pid)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Setting pid is NOT valid "); 
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
@@ -843,18 +954,17 @@ int sttd_server_setting_set_profanity_filter(int uid, bool value)
        ret = sttd_engine_setting_set_profanity_filter(value);
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to set profanity filter: result(%d)", ret); 
-               return STTD_ERROR_OPERATION_FAILED;
+               return ret;
        }       
 
        return STTD_ERROR_NONE;
 }
 
-int sttd_server_setting_get_punctuation_override(int uid, bool* value)
+int sttd_server_setting_get_punctuation_override(int pid, bool* value)
 {
-       /* check if uid is valid */
-       app_state_e state;
-       if (0 != sttd_client_get_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid "); 
+       /* check whether pid is valid */
+       if (true != sttd_setting_client_is(pid)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Setting pid is NOT valid "); 
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
@@ -867,18 +977,17 @@ int sttd_server_setting_get_punctuation_override(int uid, bool* value)
        ret = sttd_engine_setting_get_punctuation_override(value);
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to get punctuation override : result(%d)", ret); 
-               return STTD_ERROR_OPERATION_FAILED;
+               return ret;
        }       
 
        return STTD_ERROR_NONE;
 }
 
-int sttd_server_setting_set_punctuation_override(int uid, bool value)
+int sttd_server_setting_set_punctuation_override(int pid, bool value)
 {
-       /* check if uid is valid */
-       app_state_e state;
-       if (0 != sttd_client_get_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid "); 
+       /* check whether pid is valid */
+       if (true != sttd_setting_client_is(pid)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Setting pid is NOT valid "); 
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
@@ -886,18 +995,17 @@ int sttd_server_setting_set_punctuation_override(int uid, bool value)
        ret = sttd_engine_setting_set_punctuation_override(value);
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to set punctuation override : result(%d)", ret); 
-               return STTD_ERROR_OPERATION_FAILED;
+               return ret;
        }       
 
        return STTD_ERROR_NONE;
 }
 
-int sttd_server_setting_get_silence_detection(int uid, bool* value)
+int sttd_server_setting_get_silence_detection(int pid, bool* value)
 {
-       /* check if uid is valid */
-       app_state_e state;
-       if (0 != sttd_client_get_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid "); 
+       /* check whether pid is valid */
+       if (true != sttd_setting_client_is(pid)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Setting pid is NOT valid "); 
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
@@ -910,18 +1018,17 @@ int sttd_server_setting_get_silence_detection(int uid, bool* value)
        ret = sttd_engine_setting_get_silence_detection(value);
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to get silence detection : result(%d)", ret); 
-               return STTD_ERROR_OPERATION_FAILED;
+               return ret;
        }       
 
        return STTD_ERROR_NONE;
 }
 
-int sttd_server_setting_set_silence_detection(int uid, bool value)
+int sttd_server_setting_set_silence_detection(int pid, bool value)
 {
-       /* check if uid is valid */
-       app_state_e state;
-       if (0 != sttd_client_get_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid "); 
+       /* check whether pid is valid */
+       if (true != sttd_setting_client_is(pid)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Setting pid is NOT valid "); 
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
@@ -929,18 +1036,17 @@ int sttd_server_setting_set_silence_detection(int uid, bool value)
        ret = sttd_engine_setting_set_silence_detection(value);
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to Result(%d)", ret); 
-               return STTD_ERROR_OPERATION_FAILED;
+               return ret;
        }       
 
        return STTD_ERROR_NONE;
 }
 
-int sttd_server_setting_get_engine_setting(int uid, char** engine_id, GList** lang_list)
+int sttd_server_setting_get_engine_setting(int pid, char** engine_id, GList** lang_list)
 {      
-       /* check if uid is valid */
-       app_state_e state;
-       if (0 != sttd_client_get_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid "); 
+       /* check whether pid is valid */
+       if (true != sttd_setting_client_is(pid)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Setting pid is NOT valid "); 
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
@@ -952,12 +1058,11 @@ int sttd_server_setting_get_engine_setting(int uid, char** engine_id, GList** la
        return STTD_ERROR_NONE;
 }
 
-int sttd_server_setting_set_engine_setting(int uid, const char* key, const char* value)
+int sttd_server_setting_set_engine_setting(int pid, const char* key, const char* value)
 {      
-       /* check if uid is valid */
-       app_state_e state;
-       if (0 != sttd_client_get_state(uid, &state)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid "); 
+       /* check whether pid is valid */
+       if (true != sttd_setting_client_is(pid)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Setting pid is NOT valid "); 
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
@@ -968,5 +1073,3 @@ int sttd_server_setting_set_engine_setting(int uid, const char* key, const char*
 
        return STTD_ERROR_NONE;
 }
-
-
old mode 100644 (file)
new mode 100755 (executable)
index 878998f..d62f218
@@ -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 @@
 #ifndef __STTD_SERVER_H_
 #define __STTD_SERVER_H_
 
+#include <Ecore.h>
 #include "sttd_main.h"
 
 #ifdef __cplusplus
@@ -22,14 +23,18 @@ extern "C" {
 #endif
 
 
-/** Daemon initialize */
+/*
+* Daemon functions
+*/
 int sttd_initialize();
 
+Eina_Bool sttd_cleanup_client(void *data);
+
 /*
 * API for client
 */
 
-int sttd_server_initialize(int pid, int uid);
+int sttd_server_initialize(int pid, int uid, bool* silence, bool* profanity, bool* punctuation);
 
 int sttd_server_finalize(const int uid);
 
@@ -54,37 +59,37 @@ int sttd_server_cancel(const int uid);
 * API for setting
 */
 
-int sttd_server_setting_initialize(int uid);
+int sttd_server_setting_initialize(int pid);
 
-int sttd_server_setting_finalize(int uid);
+int sttd_server_setting_finalize(int pid);
 
-int sttd_server_setting_get_engine_list(int uid, GList** engine_list);
+int sttd_server_setting_get_engine_list(int pid, GList** engine_list);
 
-int sttd_server_setting_get_engine(int uid, char** engine_id);
+int sttd_server_setting_get_engine(int pid, char** engine_id);
 
-int sttd_server_setting_set_engine(const int uid, const char* engine_id);
+int sttd_server_setting_set_engine(int pid, const char* engine_id);
 
-int sttd_server_setting_get_lang_list(int uid, char** engine_id, GList** lang_list);
+int sttd_server_setting_get_lang_list(int pid, char** engine_id, GList** lang_list);
 
-int sttd_server_setting_get_default_language(int uid, char** language);
+int sttd_server_setting_get_default_language(int pid, char** language);
 
-int sttd_server_setting_set_default_language(int uid, const char* language);
+int sttd_server_setting_set_default_language(int pid, const char* language);
 
-int sttd_server_setting_get_profanity_filter(int uid, bool* value);
+int sttd_server_setting_get_profanity_filter(int pid, bool* value);
 
-int sttd_server_setting_set_profanity_filter(int uid, bool value);
+int sttd_server_setting_set_profanity_filter(int pid, bool value);
 
-int sttd_server_setting_get_punctuation_override(int uid, bool* value);
+int sttd_server_setting_get_punctuation_override(int pid, bool* value);
 
-int sttd_server_setting_set_punctuation_override(int uid, bool value);
+int sttd_server_setting_set_punctuation_override(int pid, bool value);
 
-int sttd_server_setting_get_silence_detection(int uid, bool* value);
+int sttd_server_setting_get_silence_detection(int pid, bool* value);
 
-int sttd_server_setting_set_silence_detection(int uid, bool value);
+int sttd_server_setting_set_silence_detection(int pid, bool value);
 
-int sttd_server_setting_get_engine_setting(int uid, char** engine_id, GList** lang_list);
+int sttd_server_setting_get_engine_setting(int pid, char** engine_id, GList** lang_list);
 
-int sttd_server_setting_set_engine_setting(int uid, const char* key, const char* value);
+int sttd_server_setting_set_engine_setting(int pid, const char* key, const char* value);
 
 
 #ifdef __cplusplus
old mode 100644 (file)
new mode 100755 (executable)
index da393f8..9fa59e3
@@ -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
@@ -38,7 +38,7 @@ typedef enum {
        STTP_ERROR_INVALID_STATE        = -0x0100031,   /**< Invalid state */
        STTP_ERROR_INVALID_LANGUAGE     = -0x0100032,   /**< Invalid language */
        STTP_ERROR_OPERATION_FAILED     = -0x0100034,   /**< Operation failed */
-       STTP_ERROR_NOT_SUPPORTED        = -0x0100035    /**< Not supported function */
+       STTP_ERROR_NOT_SUPPORTED_FEATURE= -0x0100035    /**< Not supported feature */
 }sttp_error_e;
 
 /**
@@ -149,15 +149,79 @@ typedef enum {
 */
 #define STTP_RECOGNITION_TYPE_COMMAND_TTS              "stt.recognition.type.COMMAND.TTS"
 
+/** 
+* @brief Result message : None message
+*/
+#define STTP_RESULT_MESSAGE_NONE               "stt.result.message.none"
+
+/** 
+* @brief Result warning message : The speech has started too soon
+*/
+#define STTP_RESULT_MESSAGE_WARNING_TOO_SOON   "stt.result.message.warning.too.soon"
+
+/** 
+* @brief Result warning message : The speech is too short
+*/
+#define STTP_RESULT_MESSAGE_WARNING_TOO_SHORT  "stt.result.message.warning.too.short"
+
+/** 
+* @brief Result warning message : The speech is too long
+*/
+#define STTP_RESULT_MESSAGE_WARNING_TOO_LONG   "stt.result.message.warning.too.long"
+
+/** 
+* @brief Result warning message : The speech is too quiet to listen
+*/
+#define STTP_RESULT_MESSAGE_WARNING_TOO_QUIET  "stt.result.message.warning.too.quiet"
+
+/** 
+* @brief Result warning message : The speech is too loud to listen
+*/
+#define STTP_RESULT_MESSAGE_WARNING_TOO_LOUD   "stt.result.message.warning.too.loud"
+
+/** 
+* @brief Result warning message : The speech is too fast to listen
+*/
+#define STTP_RESULT_MESSAGE_WARNING_TOO_FAST   "stt.result.message.warning.too.fast"
+
+/** 
+* @brief Result error message : Recognition was failed because the speech started too soon
+*/
+#define STTP_RESULT_MESSAGE_ERROR_TOO_SOON     "stt.result.message.error.too.soon"
+
+/** 
+* @brief Result error message : Recognition was failed because the speech started too short
+*/
+#define STTP_RESULT_MESSAGE_ERROR_TOO_SHORT    "stt.result.message.error.too.short"
+
+/** 
+* @brief Result error message : Recognition was failed because the speech started too long
+*/
+#define STTP_RESULT_MESSAGE_ERROR_TOO_LONG     "stt.result.message.error.too.long"
+
+/** 
+* @brief Result error message : Recognition was failed because the speech started too quiet to listen
+*/
+#define STTP_RESULT_MESSAGE_ERROR_TOO_QUIET    "stt.result.message.error.too.quiet"
+
+/** 
+* @brief Result error message : Recognition was failed because the speech started too loud to listen 
+*/
+#define STTP_RESULT_MESSAGE_ERROR_TOO_LOUD     "stt.result.message.error.too.loud"
+
+/** 
+* @brief Result error message : Recognition was failed because the speech started too fast to listen
+*/
+#define STTP_RESULT_MESSAGE_ERROR_TOO_FAST     "stt.result.message.error.too.fast"
 
 /** 
 * @brief Called to get recognition result.
 * 
 * @param[in] event A result event
-* @param[in] type A recognition type
+* @param[in] type A recognition type (e.g. #STTP_RECOGNITION_TYPE_FREE, #STTP_RECOGNITION_TYPE_COMMAND)
 * @param[in] data Result texts
 * @param[in] data_count Result text count
-* @param[in] msg engine A Message
+* @param[in] msg Engine message (e.g. #STTP_RESULT_MESSAGE_WARNING_TOO_SOON, #STTP_RESULT_MESSAGE_ERROR_TOO_SHORT)
 * @param[in] user_data The user data passed from the start function
 *
 * @pre sttpe_stop() will invoke this callback.
@@ -321,7 +385,7 @@ typedef int (* sttpe_get_recording_format)(sttp_audio_type_e* types, int* rate,
 * @return 0 on success, otherwise a negative error value
 * @retval #STTP_ERROR_NONE Successful
 * @retval #STTP_ERROR_INVALID_STATE Not initialized
-* @retval #STTP_ERROR_NOT_SUPPORTED Not supported
+* @retval #STTP_ERROR_NOT_SUPPORTED_FEATURE Not supported feature
 */
 typedef int (* sttpe_set_profanity_filter)(bool value);
 
@@ -333,7 +397,7 @@ typedef int (* sttpe_set_profanity_filter)(bool value);
 * @return 0 on success, otherwise a negative error value
 * @retval #STTP_ERROR_NONE Successful
 * @retval #STTP_ERROR_INVALID_STATE Not initialized
-* @retval #STTP_ERROR_NOT_SUPPORTED Not supported
+* @retval #STTP_ERROR_NOT_SUPPORTED_FEATURE Not supported feature
 */
 typedef int (* sttpe_set_punctuation_override)(bool value);
 
@@ -345,7 +409,7 @@ typedef int (* sttpe_set_punctuation_override)(bool value);
 * @return 0 on success, otherwise a negative error value
 * @retval #STTP_ERROR_NONE Successful
 * @retval #STTP_ERROR_INVALID_STATE Not initialized
-* @retval #STTP_ERROR_NOT_SUPPORTED Not supported
+* @retval #STTP_ERROR_NOT_SUPPORTED_FEATURE Not supported feature
 */
 typedef int (* sttpe_set_silence_detection)(bool value);
 
@@ -353,7 +417,7 @@ typedef int (* sttpe_set_silence_detection)(bool value);
 * @brief Start recognition.
 *
 * @param[in] language A language. 
-* @param[in] type A recognition type.
+* @param[in] type A recognition type. (e.g. #STTP_RECOGNITION_TYPE_FREE, #STTP_RECOGNITION_TYPE_WEB_SEARCH)
 * @param[in] user_data The user data to be passed to the callback function. 
 *
 * @return 0 on success, otherwise a negative error value
diff --git a/stt-server.manifest b/stt-server.manifest
new file mode 100644 (file)
index 0000000..10a15c8
--- /dev/null
@@ -0,0 +1,12 @@
+<manifest>
+        <define>
+                <domain name="stt-server" policy="shared"/>
+        </define>
+       <assign>
+               <filesystem path="/usr/lib/libstt.so" label="_"/>
+               <filesystem path="/usr/lib/libstt_setting.so" label="_"/>
+       </assign>
+        <request>
+                <domain name="stt-server" />
+        </request>
+</manifest>