/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+* 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
#include <sys/wait.h>
#include <sys/types.h>
#include <unistd.h>
+#include <Ecore.h>
#include "stt.h"
#include "stt_main.h"
#include "stt_client.h"
#include "stt_dbus.h"
-#define CONNECTION_RETRY_COUNT 2
+#define CONNECTION_RETRY_COUNT 3
+
+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) {
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;
}
}
- /* Send hello */
- if (0 != stt_dbus_request_hello()) {
- __check_stt_daemon();
- }
-
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 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, &silence_supported, &profanity_supported, &punctuation_supported);
-
+ 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) {
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(*stt, silence_supported, profanity_supported, punctuation_supported);
+ 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 */
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, " ");
*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;
} 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);
} 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, "=====");
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, "=====");
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);
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
}
-int __check_stt_daemon()
+static int __check_stt_daemon()
{
if( TRUE == __stt_is_alive() )
return 0;
break;
default:
- sleep(1);
break;
}
* @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;
*
* @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()
*/
*
* @param[in] stt The handle for STT
* @param[in] language A language is specified as an ISO 3166 alpha-2 two letter country-code \n
-* followed by ISO 639-1 for the two-letter language code. \n
-* For example, "ko_KR" for Korean, "en_US" for American English.
+* followed by ISO 639-1 for the two-letter language code. \n
+* For example, "ko_KR" for Korean, "en_US" for American English.
* @param[in] user_data The user data passed from the foreach function
*
* @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop.
/**
-* @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
*
*/
int stt_destroy(stt_h stt);
+/**
+* @brief Connects the daemon.
+*
+* @param[in] stt The handle for STT
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #STT_ERROR_NONE Successful
+* @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #STT_ERROR_INVALID_STATE Invalid state
+*
+* @pre The state should be #STT_STATE_CREATED.
+* @post If this function is called, the STT state will be #STT_STATE_READY.
+*
+* @see stt_unprepare()
+*/
+int stt_prepare(stt_h stt);
+
+/**
+* @brief Disconnects the daemon.
+*
+* @param[in] stt The handle for STT
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #STT_ERROR_NONE Successful
+* @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #STT_ERROR_INVALID_STATE Invalid state
+*
+* @pre The state should be #STT_STATE_READY.
+* @post If this function is called, the STT state will be #STT_STATE_CREATED.
+*
+* @see stt_prepare()
+*/
+int stt_unprepare(stt_h stt);
+
/**
* @brief Retrieves all supported languages of current engine using callback function.
*
*
* @param[in] stt The handle for STT
* @param[out] language A language is specified as an ISO 3166 alpha-2 two letter country-code \n
-* followed by ISO 639-1 for the two-letter language code. \n
-* For example, "ko_KR" for Korean, "en_US" for American English.
+* followed by ISO 639-1 for the two-letter language code. \n
+* For example, "ko_KR" for Korean, "en_US" for American English.
*
* @return 0 on success, otherwise a negative error value
* @retval #STT_ERROR_NONE Successful
* @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #STT_ERROR_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()
* @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()
*/
* @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()
*/
* @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()
*/
* @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()
* @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()
*/
* @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()
* @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()
*/
/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+* 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
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;
/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+* 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
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);
#include "stt_defs.h"
#include <Ecore.h>
+#include "stt_client.h"
static int g_waiting_time = 1500;
static int g_waiting_start_time = 2000;
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)
{
char if_name[64];
snprintf(if_name, 64, "%s%d", STT_CLIENT_SERVICE_INTERFACE, getpid());
- if (dbus_message_is_method_call(msg, if_name, STT_METHOD_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;
SLOG(LOG_ERROR, TAG_STTC, "<<<< stt get result : invalid uid \n");
}
- reply = dbus_message_new_method_return(msg);
- dbus_connection_send(conn, reply, NULL);
- dbus_connection_flush(conn);
- dbus_message_unref(reply);
-
SLOG(LOG_DEBUG, TAG_STTC, "=====");
SLOG(LOG_DEBUG, TAG_STTC, " ");
- }/* STT_METHOD_RESULT */
+ }/* STTD_METHOD_RESULT */
- else if (dbus_message_is_method_call(msg, if_name, STT_METHOD_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;
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< stt get partial result : invalid uid \n");
}
- reply = dbus_message_new_method_return(msg);
- dbus_connection_send(conn, reply, NULL);
- dbus_connection_flush(conn);
- dbus_message_unref(reply);
-
- SLOG(LOG_DEBUG, TAG_STTC, "=====");
- SLOG(LOG_DEBUG, TAG_STTC, " ");
- }/* STT_METHOD_PARTIAL_RESULT */
-
- else if (dbus_message_is_method_call(msg, if_name, STT_METHOD_STOPED)) {
- 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);
- }
-
- reply = dbus_message_new_method_return(msg);
- dbus_connection_send(conn, reply, NULL);
- dbus_connection_flush(conn);
- dbus_message_unref(reply);
SLOG(LOG_DEBUG, TAG_STTC, "=====");
SLOG(LOG_DEBUG, TAG_STTC, " ");
- }/* STT_METHOD_STOP */
+ }/* STTD_METHOD_PARTIAL_RESULT */
- else if (dbus_message_is_method_call(msg, if_name, STT_METHOD_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;
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);
- dbus_connection_send(conn, reply, NULL);
- dbus_connection_flush(conn);
- dbus_message_unref(reply);
+
+ 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_METHOD_ERROR */
+ }/* STTD_METHOD_ERROR */
/* free the message */
dbus_message_unref(msg);
dbus_bus_release_name (g_conn, service_name, &err);
+ dbus_connection_close(g_conn);
+
+ g_fd_handler = NULL;
g_conn = NULL;
return 0;
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;
/**
dbus_bus_release_name(g_conn, service_name, &err);
+ dbus_connection_close(g_conn);
+
g_conn = NULL;
return 0;
int stt_setting_dbus_close_connection();
+int stt_setting_dbus_request_hello();
+
int stt_setting_dbus_request_initialize();
int stt_setting_dbus_request_finalilze();
/******************************************************************************************
-* Message Definition for APIs
+* Message Definition for Client
*******************************************************************************************/
#define STT_METHOD_HELLO "stt_method_hello"
#define STT_METHOD_STOP "stt_method_stop"
#define STT_METHOD_CANCEL "stt_method_cancel"
-#define STT_METHOD_RESULT "sttd_method_result"
-#define STT_METHOD_PARTIAL_RESULT "sttd_method_partial_result"
-#define STT_METHOD_STOPED "sttd_method_stop"
-#define STT_METHOD_ERROR "sttd_method_error"
+#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"
-stt (0.1.1-1) unstable; urgency=low
+stt (0.1.1-24slp2+1) unstable; urgency=low
- * 1.0 release
- * Git: pkgs/s/stt
- * Tag: stt_0.1.1-1
+ * 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
+++ /dev/null
-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.
@PREFIX@/lib/libstt.so*
@PREFIX@/lib/libstt_setting.so*
@PREFIX@/bin/stt-daemon
+@PREFIX@/lib/voice/stt/1.0/sttd.conf
\ No newline at end of file
%defattr(-,root,root,-)
%{_libdir}/libstt.so
%{_libdir}/libstt_setting.so
+%{_libdir}/voice/stt/1.0/sttd.conf
%{_bindir}/stt-daemon
## 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)
--- /dev/null
+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
/* Client list */
static GList *g_client_list = NULL;
+static GList *g_setting_client_list = NULL;
+
int client_show_list()
{
GList *iter = NULL;
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;
{
/*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");
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;
}
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;
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;
}
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;
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)
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;
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
/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+* 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
#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);
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
/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+* 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
* limitations under the License.
*/
-
-#include <vconf.h>
-
#include "sttd_main.h"
#include "sttd_config.h"
-/*
-* stt-daemon config
-*/
+#define CONFIG_FILE_PATH BASE_DIRECTORY_DOWNLOAD"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;
- }
+ FILE* config_fp;
+ config_fp = fopen(CONFIG_FILE_PATH, "w+");
- if (0 != vconf_set_str(key, value)) {
- SLOG(LOG_ERROR, TAG_STTD, "[STTD Config ERROR] Fail to set char type");
+ if (NULL == config_fp) {
+ // make file and file default
+ SLOG(LOG_ERROR, TAG_STTD, "[Config ERROR] Fail to load config (engine id)");
return -1;
}
+ /* Write engine id */
+ fprintf(config_fp, "%s %s\n", ENGINE_ID, g_engine_id);
+
+ /* Write language */
+ fprintf(config_fp, "%s %s\n", LANGUAGE, g_language);
+
+ /* Write silence detection */
+ fprintf(config_fp, "%s %d\n", SILENCE, g_silence);
+
+ /* Write profanity */
+ fprintf(config_fp, "%s %d\n", PROFANITY, g_profanity);
+
+ /* Write punctuation */
+ fprintf(config_fp, "%s %d\n", PUNCTUATION, g_punctuation);
+
+ fclose(config_fp);
+
return 0;
}
-int sttd_config_get_bool_type(const char* key, bool* value)
+int __sttd_config_load()
{
- 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);
- return -1;
+ FILE* config_fp;
+ char buf_id[256] = {0};
+ char buf_param[256] = {0};
+ int int_param = 0;
+
+ 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;
+ }
}
- *value = (bool) result;
+ /* Read engine id */
+ fscanf(config_fp, "%s %s", buf_id, buf_param);
+ 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;
+ }
- return 0;
-}
+ /* Read language */
+ fscanf(config_fp, "%s %s", buf_id, buf_param);
+ 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;
+ }
-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;
+ /* Read silence detection */
+ fscanf(config_fp, "%s %d", buf_id, &int_param);
+ 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;
+ }
+
+ /* Read profanity filter */
+ fscanf(config_fp, "%s %d", buf_id, &int_param);
+ 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 */
+ fscanf(config_fp, "%s %d", buf_id, &int_param);
+ 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;
}
+ 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 0;
}
-/*
-* plug-in daemon interface
-*/
-
-int __make_key_for_engine(const char* engine_id, const char* key, char** out_key)
+int sttd_config_initialize()
{
- int key_size = strlen(STTD_CONFIG_PREFIX) + strlen(engine_id) + strlen(key) + 2; /* 2 means both '/' and '\0'*/
-
- *out_key = (char*) malloc( sizeof(char) * key_size);
+ g_engine_id = NULL;
+ g_language = NULL;
+ g_silence = 1;
+ g_profanity = 0;
+ g_punctuation = 0;
- snprintf(*out_key, key_size, "%s%s/%s", STTD_CONFIG_PREFIX, engine_id, key );
+ __sttd_config_load();
return 0;
}
-int sttd_config_set_persistent_data(const char* engine_id, const char* key, const char* value)
+int sttd_config_finalize()
{
- if (NULL == engine_id || NULL == key || NULL == value) {
- 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()");
- return -1;
- }
+ __sttd_config_save();
+ return 0;
+}
- if (NULL == vconf_key)
+int sttd_config_get_default_engine(char** engine_id)
+{
+ if (NULL == engine_id)
return -1;
- if (0 != vconf_set_str(vconf_key, value)) {
- SLOG(LOG_ERROR, TAG_STTD, "[STTD Config ERROR] Fail to set key, value");
-
- if (vconf_key != NULL)
- free(vconf_key);
+ *engine_id = strdup(g_engine_id);
+ return 0;
+}
+int sttd_config_set_default_engine(const char* engine_id)
+{
+ if (NULL == engine_id)
return -1;
- }
-
- SLOG(LOG_DEBUG, TAG_STTD, "[STTD Config DEBUG] sttd_config_set_persistent_data : key(%s), value(%s)", vconf_key, value);
- if (NULL != vconf_key)
- free(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_persistent_data(const char* engine_id, const char* key, char** value)
+int sttd_config_get_default_language(char** language)
{
- if (NULL == engine_id) {
- SLOG(LOG_ERROR, TAG_STTD, "[STTD Config ERROR] BAD Parameter");
- return STTD_ERROR_INVALID_PARAMETER;
- }
+ if (NULL == language)
+ return -1;
- char* vconf_key = NULL;
+ *language = strdup(g_language);
- 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;
- }
+ return 0;
+}
- if (NULL == vconf_key)
+int sttd_config_set_default_language(const 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");
+ if (NULL != g_language)
+ free(g_language);
- if(vconf_key != NULL)
- free(vconf_key);
+ g_language = strdup(language);
- return -1;
- }
+ __sttd_config_save();
- *value = g_strdup(temp);
+ return 0;
+}
- SLOG(LOG_DEBUG, TAG_STTD, "[STTD Config DEBUG] sttd_config_get_persistent_data : key(%s), value(%s)", vconf_key, *value);
+int sttd_config_get_default_silence_detection(int* silence)
+{
+ if (NULL == silence)
+ return -1;
- if (vconf_key != NULL) free(vconf_key);
- if (temp != NULL) free(temp);
+ *silence = g_silence;
return 0;
}
-int sttd_config_remove_persistent_data(const char* engine_id, const char* key)
+int sttd_config_set_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;
- }
+ g_silence = silence;
+ __sttd_config_save();
+ return 0;
+}
- 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()");
+int sttd_config_get_default_profanity_filter(int* profanity)
+{
+ if (NULL == profanity)
return -1;
- }
- if (NULL == vconf_key)
- return -1;
+ *profanity = g_profanity;
- 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_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;
- }
- SLOG(LOG_DEBUG, TAG_STTD, "[STTD Config DEBUG] sttd_config_remove_persistent_data : key(%s)", vconf_key);
-
- if( NULL != vconf_key )
- free(vconf_key);
+ *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
/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+* 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
#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
#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)
{
service_name,
STT_CLIENT_SERVICE_OBJECT_PATH,
target_if_name,
- STT_METHOD_RESULT);
+ STTD_METHOD_RESULT);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Fail to create message");
service_name,
STT_CLIENT_SERVICE_OBJECT_PATH,
target_if_name,
- STT_METHOD_PARTIAL_RESULT);
+ STTD_METHOD_PARTIAL_RESULT);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Fail to create message");
service_name,
STT_CLIENT_SERVICE_OBJECT_PATH,
target_if_name,
- STT_METHOD_PARTIAL_RESULT);
+ STTD_METHOD_ERROR);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Fail to create message");
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;
}
memset(service_name, 0, 64);
snprintf(service_name, 64, "%s%d", STT_CLIENT_SERVICE_NAME, pid);
- char target_if_name[64];
+ char target_if_name[128];
snprintf(target_if_name, sizeof(target_if_name), "%s%d", STT_CLIENT_SERVICE_INTERFACE, pid);
- SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] send %s signal : ifname(%s), uid(%d)", signal, target_if_name, uid);
-
DBusMessage* msg;
+ 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,
- STT_METHOD_STOPED);
+ 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)
{
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;
}
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);
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);
}
}
/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+* 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
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");
{
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 */
/* 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 */
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");
}
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 ");
}
{
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) {
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);
{
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) {
{
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) {
{
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) {
}
} 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");
{
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) {
{
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) {
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;
}
{
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) {
{
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) {
{
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) {
{
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) {
{
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) {
{
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) {
{
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) {
{
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) {
/* 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;
}
}
/* 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);
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");
}
{
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) {
{
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) {
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);
{
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) {
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);
}
{
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) {
{
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) {
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);
}
{
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) {
{
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) {
}
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);
}
{
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) {
{
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) {
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);
}
{
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) {
{
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) {
/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+* 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
#include "sttd_dbus.h"
#include <Ecore.h>
+#include "sttd_server.h"
+
+#define CLIENT_CLEAN_UP_TIME 500
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...");
/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+* 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
#define TAG_STTD "sttd"
+#define BASE_DIRECTORY_DEFAULT "/usr/lib/voice/stt/1.0/"
#define ENGINE_DIRECTORY_DEFAULT "/usr/lib/voice/stt/1.0/engine"
#define ENGINE_DIRECTORY_DEFAULT_SETTING "/usr/lib/voice/stt/1.0/setting"
+#define BASE_DIRECTORY_DOWNLOAD "/opt/apps/voice/stt/1.0/"
#define ENGINE_DIRECTORY_DOWNLOAD "/opt/apps/voice/stt/1.0/engine"
#define ENGINE_DIRECTORY_DOWNLOAD_SETTING "/opt/apps/voice/stt/1.0/setting"
/* for debug message */
#define RECORDER_DEBUG
+#define CLIENT_DATA_DEBUG
typedef enum {
STTD_ERROR_NONE = 0, /**< Successful */
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);
/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+* 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
*/
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;
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;
}
/* 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)) {
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) {
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 */
}
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, " ");
}
/*
-* 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) {
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
*/
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)
{
/* 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 */
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;
}
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);
* 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()) {
}
}
- /* 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;
}
}
}
- /* 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");
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
return STTD_ERROR_NONE;
}
-
-
/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+* 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
#ifndef __STTD_SERVER_H_
#define __STTD_SERVER_H_
+#include <Ecore.h>
#include "sttd_main.h"
#ifdef __cplusplus
#endif
-/** Daemon initialize */
+/*
+* Daemon functions
+*/
int sttd_initialize();
+Eina_Bool sttd_cleanup_client(void *data);
+
/*
* API for client
*/
* 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