From b6f36bfc2a673deeacc6b3d6527870f02567a7fb Mon Sep 17 00:00:00 2001 From: Wonnam Jang Date: Wed, 23 Dec 2015 07:52:19 +0900 Subject: [PATCH] modify files according to coding rule Change-Id: Ibd9c5a15a04a8396b1730f6d783a27447c3e16e4 Signed-off-by: Wonnam Jang --- client/stt.c | 70 +++++++-------- client/stt_client.c | 15 ++-- client/stt_dbus.c | 206 ++++++++++++++++++++++----------------------- client/stt_file.c | 68 +++++++-------- client/stt_setting.c | 22 ++--- common/stt_config_mgr.c | 44 +++++----- common/stt_config_parser.c | 60 ++++++------- common/stt_engine.c | 54 ++++++------ common/stt_network.c | 6 +- server/sttd_client_data.c | 34 ++++---- server/sttd_config.c | 4 +- server/sttd_dbus.c | 55 ++++++------ server/sttd_dbus_server.c | 186 ++++++++++++++++++++-------------------- server/sttd_engine_agent.c | 180 +++++++++++++++++++-------------------- server/sttd_recorder.c | 30 +++---- server/sttd_server.c | 68 +++++++-------- test/test_main.c | 6 +- 17 files changed, 553 insertions(+), 555 deletions(-) diff --git a/client/stt.c b/client/stt.c index ea44190..0b42088 100644 --- a/client/stt.c +++ b/client/stt.c @@ -1,5 +1,5 @@ /* -* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved +* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include #include @@ -43,7 +43,7 @@ const char* stt_tag() static const char* __stt_get_error_code(stt_error_e err) { - switch(err) { + switch (err) { case STT_ERROR_NONE: return "STT_ERROR_NONE"; case STT_ERROR_OUT_OF_MEMORY: return "STT_ERROR_OUT_OF_MEMORY"; case STT_ERROR_IO_ERROR: return "STT_ERROR_IO_ERROR"; @@ -111,7 +111,7 @@ void __stt_config_lang_changed_cb(const char* before_language, const char* curre } } - return; + return; } int stt_create(stt_h* stt) @@ -198,7 +198,7 @@ int stt_destroy(stt_h stt) SLOG(LOG_DEBUG, TAG_STTC, " "); return STT_ERROR_INVALID_PARAMETER; } - + stt_client_s* client = stt_client_get(stt); /* check handle */ @@ -271,7 +271,7 @@ bool __stt_config_supported_engine_cb(const char* engine_id, const char* engine_ } else { SLOG(LOG_WARN, TAG_STTC, "No registered callback function of supported engine"); } - + return false; } @@ -469,7 +469,7 @@ static Eina_Bool __stt_connect_daemon(void *data) if (STT_ERROR_ENGINE_NOT_FOUND == ret) { SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to initialize : %s", __stt_get_error_code(ret)); - + client->reason = STT_ERROR_ENGINE_NOT_FOUND; ecore_timer_add(0, __stt_notify_error, (void*)client); @@ -813,7 +813,7 @@ int stt_get_state(stt_h stt, stt_state_e* state) *state = client->current_state; - switch(*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; @@ -914,13 +914,13 @@ int stt_set_silence_detection(stt_h stt, stt_option_silence_detection_e type) if (true == client->silence_supported) { if (type >= STT_OPTION_SILENCE_DETECTION_FALSE && type <= STT_OPTION_SILENCE_DETECTION_AUTO) { - client->silence = type; + client->silence = type; } else { SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Type is invalid"); return STT_ERROR_INVALID_PARAMETER; } } else { - return STT_ERROR_NOT_SUPPORTED_FEATURE; + return STT_ERROR_NOT_SUPPORTED_FEATURE; } return STT_ERROR_NONE; @@ -1241,7 +1241,7 @@ int stt_start(stt_h stt, const char* language, const char* type) while (0 != ret) { ret = stt_dbus_request_start(client->uid, temp, type, client->silence, appid); if (0 > ret) { - /* Failure */ + /* Failure */ if (STT_ERROR_TIMED_OUT != ret) { SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to start : %s", __stt_get_error_code(ret)); if (NULL != temp) free(temp); @@ -1318,8 +1318,8 @@ int stt_stop(stt_h stt) SLOG(LOG_DEBUG, TAG_STTC, "====="); SLOG(LOG_DEBUG, TAG_STTC, " "); return STT_ERROR_INVALID_PARAMETER; - } - + } + /* check state */ if (client->current_state != STT_STATE_RECORDING) { SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State : Current state is NOT RECORDING"); @@ -1341,7 +1341,7 @@ int stt_stop(stt_h stt) while (0 != ret) { ret = stt_dbus_request_stop(client->uid); if (0 > ret) { - /* Failure */ + /* Failure */ if (STT_ERROR_TIMED_OUT != ret) { SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to stop : %s", __stt_get_error_code(ret)); return ret; @@ -1414,7 +1414,7 @@ int stt_cancel(stt_h stt) SLOG(LOG_DEBUG, TAG_STTC, "====="); SLOG(LOG_DEBUG, TAG_STTC, " "); return STT_ERROR_INVALID_PARAMETER; - } + } /* check state */ if (STT_STATE_RECORDING != client->current_state && STT_STATE_PROCESSING != client->current_state) { @@ -1436,8 +1436,8 @@ int stt_cancel(stt_h stt) int count = 0; while (0 != ret) { ret = stt_dbus_request_cancel(client->uid); - if (0 != ret) { - /* Failure */ + if (0 != ret) { + /* Failure */ if (STT_ERROR_TIMED_OUT != ret) { SLOG(LOG_DEBUG, TAG_STTC, "[ERROR] Fail to cancel : %s", __stt_get_error_code(ret)); return ret; @@ -1514,13 +1514,13 @@ int stt_get_recording_volume(stt_h stt, float* volume) if (NULL == client) { SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available"); return STT_ERROR_INVALID_PARAMETER; - } - + } + if (STT_STATE_RECORDING != client->current_state) { SLOG(LOG_DEBUG, TAG_STTC, "[ERROR] Invalid state : NO 'Recording' state"); return STT_ERROR_INVALID_STATE; - } - + } + int ret = 0; ret = __stt_get_audio_volume(volume); if (0 != ret) { @@ -1531,7 +1531,7 @@ int stt_get_recording_volume(stt_h stt, float* volume) return STT_ERROR_NONE; } -bool __stt_result_time_cb(int index, int event, const char* text, long start_time, long end_time, void* user_data) +bool __stt_result_time_cb(int index, int event, const char* text, long start_time, long end_time, void* user_data) { stt_client_s* client = (stt_client_s*)user_data; @@ -1616,7 +1616,7 @@ static Eina_Bool __stt_notify_error(void *data) if (NULL != client->error_cb) { stt_client_use_callback(client); - client->error_cb(client->stt, client->reason, client->error_user_data); + 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 { @@ -1629,7 +1629,7 @@ static Eina_Bool __stt_notify_error(void *data) int __stt_cb_error(int uid, int reason) { stt_client_s* client = stt_client_get_by_uid(uid); - if( NULL == client ) { + if (NULL == client) { SLOG(LOG_ERROR, TAG_STTC, "Handle not found\n"); return -1; } @@ -1640,7 +1640,7 @@ int __stt_cb_error(int uid, int reason) ecore_timer_add(0, __stt_notify_error, client); } else { SLOG(LOG_WARN, TAG_STTC, "[WARNING] Error callback is null"); - } + } return 0; } @@ -1714,7 +1714,7 @@ static Eina_Bool __stt_notify_result(void *data) temp = client->data_list; int i = 0; - for (i = 0;i < client->data_count;i++) { + for (i = 0; i < client->data_count; i++) { if (NULL != temp[i]) { free(temp[i]); temp[i] = NULL; @@ -1729,7 +1729,7 @@ static Eina_Bool __stt_notify_result(void *data) client->data_count = 0; stt_config_mgr_remove_time_info_file(); - + if (STT_RESULT_EVENT_FINAL_RESULT == client->event || STT_RESULT_EVENT_ERROR == client->event) { client->before_state = client->current_state; client->current_state = STT_STATE_READY; @@ -1747,7 +1747,7 @@ static Eina_Bool __stt_notify_result(void *data) int __stt_cb_result(int uid, int event, char** data, int data_count, const char* msg) { stt_client_s* client = NULL; - + client = stt_client_get_by_uid(uid); if (NULL == client) { SLOG(LOG_ERROR, TAG_STTC, "Handle is NOT valid"); @@ -1756,10 +1756,10 @@ int __stt_cb_result(int uid, int event, char** data, int data_count, const char* if (NULL != msg) SLOG(LOG_DEBUG, TAG_STTC, "Recognition Result Message = %s", msg); - int i=0; - for (i = 0;i < data_count;i++) { + int i = 0; + for (i = 0; i < data_count; i++) { if (NULL != data[i]) SECURE_SLOG(LOG_DEBUG, TAG_STTC, "Recognition Result[%d] = %s", i, data[i]); - } + } if (NULL != client->recognition_result_cb) { client->event = event; @@ -1777,10 +1777,10 @@ int __stt_cb_result(int uid, int event, char** data, int data_count, const char* return STT_ERROR_OUT_OF_MEMORY; } - for (i = 0;i < data_count;i++) { - if(NULL != data[i]) + for (i = 0; i < data_count; i++) { + if (NULL != data[i]) temp[i] = strdup(data[i]); - else + else SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Result data is error"); } @@ -1798,7 +1798,7 @@ int __stt_cb_result(int uid, int event, char** data, int data_count, const char* int __stt_cb_set_state(int uid, int state) { stt_client_s* client = stt_client_get_by_uid(uid); - if( NULL == client ) { + if (NULL == client) { SLOG(LOG_ERROR, TAG_STTC, "Handle not found"); return -1; } diff --git a/client/stt_client.c b/client/stt_client.c index b31915f..7a4a24b 100644 --- a/client/stt_client.c +++ b/client/stt_client.c @@ -1,5 +1,5 @@ /* -* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved +* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -57,9 +57,9 @@ int stt_client_new(stt_h* stt) /* initialize client data */ client->stt = temp; - client->pid = getpid(); + client->pid = getpid(); client->uid = temp->handle; - + client->recognition_result_cb = NULL; client->recognition_result_user_data = NULL; client->state_changed_cb = NULL; @@ -90,7 +90,7 @@ int stt_client_new(stt_h* stt) *stt = temp; - return 0; + return 0; } int stt_client_destroy(stt_h stt) @@ -113,11 +113,10 @@ int stt_client_destroy(stt_h stt) if (stt->handle == data->stt->handle) { g_client_list = g_list_remove_link(g_client_list, iter); - while (0 != data->cb_ref_count) - { + while (0 != data->cb_ref_count) { /* wait for release callback function */ } - + if (NULL != data->current_engine_id) { free(data->current_engine_id); } @@ -156,7 +155,7 @@ stt_client_s* stt_client_get(stt_h stt) while (NULL != iter) { data = iter->data; if (NULL != data) { - if (stt->handle == data->stt->handle) + if (stt->handle == data->stt->handle) return data; } /* Next item */ diff --git a/client/stt_dbus.c b/client/stt_dbus.c index 6e26ddb..4a3e63a 100644 --- a/client/stt_dbus.c +++ b/client/stt_dbus.c @@ -1,5 +1,5 @@ /* -* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved +* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -48,7 +48,7 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle } /* loop again if we haven't read a message */ - if (NULL == msg) { + if (NULL == msg) { return ECORE_CALLBACK_RENEW; } @@ -73,33 +73,33 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle if (uid > 0) { SECURE_SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt get hello : uid(%d)", uid); - + /* check uid */ stt_client_s* client = stt_client_get_by_uid(uid); - if( NULL != client ) + if (NULL != client) response = 1; - else + else response = 0; } else { SLOG(LOG_ERROR, TAG_STTC, "<<<< stt get hello : invalid uid"); } 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(g_conn_listener, reply, NULL)) SLOG(LOG_ERROR, TAG_STTC, ">>>> stt get hello : fail to send reply"); - else + else SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt get hello : result(%d)", response); dbus_connection_flush(g_conn_listener); - dbus_message_unref(reply); + 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 */ @@ -146,11 +146,11 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle /* check state */ stt_client_s* client = stt_client_get_by_uid(uid); - if( NULL != client ) + if (NULL != client) response = client->current_state; - else + else SLOG(LOG_ERROR, TAG_STTC, "invalid uid"); - + } else { SLOG(LOG_ERROR, TAG_STTC, "<<<< stt get state : invalid uid"); } @@ -162,11 +162,11 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle if (!dbus_connection_send(g_conn_listener, reply, NULL)) SLOG(LOG_ERROR, TAG_STTC, ">>>> stt get state : fail to send reply"); - else + else SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt get state : result(%d)", response); dbus_connection_flush(g_conn_listener); - dbus_message_unref(reply); + dbus_message_unref(reply); } else { SLOG(LOG_ERROR, TAG_STTC, ">>>> stt get hello : fail to create reply message"); } @@ -179,15 +179,15 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle SLOG(LOG_DEBUG, TAG_STTC, "===== Get Result"); int uid = 0; DBusMessageIter args; - + dbus_message_iter_init(msg, &args); - + /* Get result */ if (DBUS_TYPE_INT32 == dbus_message_iter_get_arg_type(&args)) { dbus_message_iter_get_basic(&args, &uid); dbus_message_iter_next(&args); } - + if (uid > 0) { char** temp_result = NULL; char* temp_msg = NULL; @@ -202,7 +202,7 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle } if (DBUS_TYPE_STRING == dbus_message_iter_get_arg_type(&args)) { - dbus_message_iter_get_basic(&args, &(temp_msg) ); + dbus_message_iter_get_basic(&args, &(temp_msg)); dbus_message_iter_next(&args); } @@ -224,8 +224,8 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle SLOG(LOG_ERROR, TAG_STTC, "Fail : memory allocation error"); } else { int i = 0; - for (i = 0;i < temp_count;i++) { - dbus_message_iter_get_basic(&args, &(temp_char) ); + for (i = 0; i < temp_count; i++) { + dbus_message_iter_get_basic(&args, &(temp_char)); dbus_message_iter_next(&args); if (NULL != temp_char) { @@ -236,7 +236,7 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle __stt_cb_result(uid, temp_event, temp_result, temp_count, temp_msg); - for (i = 0;i < temp_count;i++) { + for (i = 0; i < temp_count; i++) { if (NULL != temp_result[i]) free(temp_result[i]); } @@ -250,7 +250,7 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle SLOG(LOG_DEBUG, TAG_STTC, "====="); SLOG(LOG_DEBUG, TAG_STTC, " "); - }/* STTD_METHOD_RESULT */ + } /* STTD_METHOD_RESULT */ else if (dbus_message_is_method_call(msg, if_name, STTD_METHOD_ERROR)) { SLOG(LOG_DEBUG, TAG_STTC, "===== Get Error"); @@ -264,9 +264,9 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle DBUS_TYPE_STRING, &err_msg, DBUS_TYPE_INVALID); - if (dbus_error_is_set(&err)) { + if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_STTC, "<<<< stt Get Error message : Get arguments error (%s)", err.message); - dbus_error_free(&err); + dbus_error_free(&err); } else { SECURE_SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt Get Error message : uid(%d), reason(%d), msg(%s)", uid, reason, err_msg); __stt_cb_error(uid, reason); @@ -274,7 +274,7 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle SLOG(LOG_DEBUG, TAG_STTC, "====="); SLOG(LOG_DEBUG, TAG_STTC, " "); - }/* STTD_METHOD_ERROR */ + } /* STTD_METHOD_ERROR */ /* free the message */ dbus_message_unref(msg); @@ -311,14 +311,14 @@ int stt_dbus_open_connection() /* connect to the DBUS system bus, and check for errors */ g_conn_listener = dbus_bus_get_private(DBUS_BUS_SYSTEM, &err); - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_STTC, "Dbus Connection Error (%s)", err.message); + if (dbus_error_is_set(&err)) { + SLOG(LOG_ERROR, TAG_STTC, "Dbus Connection Error (%s)", err.message); dbus_error_free(&err); } if (NULL == g_conn_listener) { SLOG(LOG_ERROR, TAG_STTC, "Fail to get dbus connection"); - return STT_ERROR_OPERATION_FAILED; + return STT_ERROR_OPERATION_FAILED; } int pid = getpid(); @@ -333,21 +333,21 @@ int stt_dbus_open_connection() dbus_bus_request_name(g_conn_listener, service_name, DBUS_NAME_FLAG_REPLACE_EXISTING , &err); if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_STTC, "Name Error (%s)\n", err.message); - dbus_error_free(&err); + SLOG(LOG_ERROR, TAG_STTC, "Name Error (%s)\n", err.message); + dbus_error_free(&err); } char rule[128]; snprintf(rule, 128, "type='signal',interface='%s'", STT_CLIENT_SERVICE_INTERFACE); /* add a rule for which messages we want to see */ - dbus_bus_add_match(g_conn_listener, rule, &err); + dbus_bus_add_match(g_conn_listener, rule, &err); dbus_connection_flush(g_conn_listener); - if (dbus_error_is_set(&err)) { + if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_STTC, "Match Error (%s)\n", err.message); dbus_error_free(&err); - return STT_ERROR_OPERATION_FAILED; + return STT_ERROR_OPERATION_FAILED; } int fd = 0; @@ -383,7 +383,7 @@ int stt_dbus_close_connection() memset(service_name, '\0', 64); snprintf(service_name, 64, "%s", STT_CLIENT_SERVICE_NAME); - dbus_bus_release_name (g_conn_listener, service_name, &err); + dbus_bus_release_name(g_conn_listener, service_name, &err); if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Release name Error (%s)", err.message); dbus_error_free(&err); @@ -405,14 +405,14 @@ int stt_dbus_reconnect() if (false == sender_connected || false == listener_connected) { stt_dbus_close_connection(); - if(0 != stt_dbus_open_connection()) { + if (0 != stt_dbus_open_connection()) { SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to reconnect"); return -1; - } + } SLOG(LOG_DEBUG, TAG_STTC, "[DBUS] Reconnect"); } - + return 0; } @@ -426,10 +426,10 @@ int stt_dbus_request_hello() STT_SERVER_SERVICE_INTERFACE, STT_METHOD_HELLO); - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_STTC, ">>>> Request stt hello : Fail to make message"); + if (NULL == msg) { + SLOG(LOG_ERROR, TAG_STTC, ">>>> Request stt hello : Fail to make message"); return STT_ERROR_OPERATION_FAILED; - } + } DBusError err; dbus_error_init(&err); @@ -470,15 +470,15 @@ int stt_dbus_request_initialize(int uid, bool* silence_supported) STT_SERVER_SERVICE_INTERFACE, STT_METHOD_INITIALIZE); - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_STTC, ">>>> stt initialize : Fail to make message"); + if (NULL == msg) { + SLOG(LOG_ERROR, TAG_STTC, ">>>> stt initialize : Fail to make message"); return STT_ERROR_OPERATION_FAILED; } else { SECURE_SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt initialize : uid(%d)", uid); } int pid = getpid(); - dbus_message_append_args( msg, + dbus_message_append_args(msg, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID); @@ -502,9 +502,9 @@ int stt_dbus_request_initialize(int uid, bool* silence_supported) DBUS_TYPE_INT32, silence_supported, DBUS_TYPE_INVALID); - if (dbus_error_is_set(&err)) { + if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_STTC, "<<<< Get arguments error (%s)\n", err.message); - dbus_error_free(&err); + dbus_error_free(&err); result = STT_ERROR_OPERATION_FAILED; } @@ -535,8 +535,8 @@ int stt_dbus_request_finalize(int uid) STT_SERVER_SERVICE_INTERFACE, STT_METHOD_FINALIZE); - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_STTC, ">>>> stt finalize : Fail to make message"); + if (NULL == msg) { + SLOG(LOG_ERROR, TAG_STTC, ">>>> stt finalize : Fail to make message"); return STT_ERROR_OPERATION_FAILED; } else { SECURE_SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt finalize : uid(%d)", uid); @@ -562,9 +562,9 @@ int stt_dbus_request_finalize(int uid) DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID); - if (dbus_error_is_set(&err)) { + if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_STTC, "<<<< Get arguments error (%s)", err.message); - dbus_error_free(&err); + dbus_error_free(&err); result = STT_ERROR_OPERATION_FAILED; } @@ -594,14 +594,14 @@ int stt_dbus_request_set_current_engine(int uid, const char* engine_id, bool* si STT_SERVER_SERVICE_INTERFACE, STT_METHOD_SET_CURRENT_ENGINE); - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_STTC, ">>>> stt set engine : Fail to make message"); + if (NULL == msg) { + SLOG(LOG_ERROR, TAG_STTC, ">>>> stt set engine : Fail to make message"); return STT_ERROR_OPERATION_FAILED; } else { SECURE_SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt set engine : uid(%d)", uid); } - dbus_message_append_args( msg, + dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_STRING, &engine_id, DBUS_TYPE_INVALID); @@ -627,7 +627,7 @@ int stt_dbus_request_set_current_engine(int uid, const char* engine_id, bool* si if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_STTC, "<<<< Get arguments error (%s)\n", err.message); - dbus_error_free(&err); + dbus_error_free(&err); result = STT_ERROR_OPERATION_FAILED; } @@ -697,7 +697,7 @@ int stt_dbus_request_check_app_agreed(int uid, const char* appid, bool* value) if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_STTC, "<<<< Get arguments error (%s)", err.message); - dbus_error_free(&err); + dbus_error_free(&err); result = STT_ERROR_OPERATION_FAILED; } dbus_message_unref(result_msg); @@ -732,8 +732,8 @@ int stt_dbus_request_get_support_langs(int uid, stt_h stt, stt_supported_languag STT_SERVER_SERVICE_INTERFACE, STT_METHOD_GET_SUPPORT_LANGS); - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_STTC, ">>>> stt get supported languages : Fail to make message"); + if (NULL == msg) { + SLOG(LOG_ERROR, TAG_STTC, ">>>> stt get supported languages : Fail to make message"); return STT_ERROR_OPERATION_FAILED; } else { SECURE_SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt get supported languages : uid(%d)", uid); @@ -767,7 +767,7 @@ int stt_dbus_request_get_support_langs(int uid, stt_h stt, stt_supported_languag SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt get support languages : result = %d", result); /* Get voice size */ - int size = 0; + int size = 0; if (DBUS_TYPE_INT32 == dbus_message_iter_get_arg_type(&args)) { dbus_message_iter_get_basic(&args, &size); dbus_message_iter_next(&args); @@ -776,10 +776,10 @@ int stt_dbus_request_get_support_langs(int uid, stt_h stt, stt_supported_languag if (0 >= size) { SLOG(LOG_ERROR, TAG_STTC, "<<<< stt size of language error : size = %d", size); } else { - int i=0; + int i = 0; char* temp_lang; - for (i=0 ; i>>> stt get default language : Fail to make message"); + if (NULL == msg) { + SLOG(LOG_ERROR, TAG_STTC, ">>>> stt get default language : Fail to make message"); return STT_ERROR_OPERATION_FAILED; } else { SECURE_SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt get default language : uid(%d)", uid); } - dbus_message_append_args( msg, + dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID); @@ -848,9 +848,9 @@ int stt_dbus_request_get_default_lang(int uid, char** language) DBUS_TYPE_STRING, &temp_lang, DBUS_TYPE_INVALID); - if (dbus_error_is_set(&err)) { + if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_STTC, "<<<< Get arguments error (%s)", err.message); - dbus_error_free(&err); + dbus_error_free(&err); result = STT_ERROR_OPERATION_FAILED; } dbus_message_unref(result_msg); @@ -885,14 +885,14 @@ int stt_dbus_request_is_recognition_type_supported(int uid, const char* type, bo STT_SERVER_SERVICE_INTERFACE, STT_METHOD_IS_TYPE_SUPPORTED); - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_STTC, ">>>> stt is partial result supported : Fail to make message"); + if (NULL == msg) { + SLOG(LOG_ERROR, TAG_STTC, ">>>> stt is partial result supported : Fail to make message"); return STT_ERROR_OPERATION_FAILED; } else { SECURE_SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt is recognition type supported : uid(%d) type(%s)", uid, type); } - dbus_message_append_args( msg, + dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_STRING, &type, DBUS_TYPE_INVALID); @@ -917,9 +917,9 @@ int stt_dbus_request_is_recognition_type_supported(int uid, const char* type, bo DBUS_TYPE_INT32, &result_support, DBUS_TYPE_INVALID); - if (dbus_error_is_set(&err)) { + if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_STTC, "<<<< Get arguments error (%s)", err.message); - dbus_error_free(&err); + dbus_error_free(&err); result = STT_ERROR_OPERATION_FAILED; } dbus_message_unref(result_msg); @@ -954,14 +954,14 @@ int stt_dbus_request_set_start_sound(int uid, const char* file) STT_SERVER_SERVICE_INTERFACE, STT_METHOD_SET_START_SOUND); - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_STTC, ">>>> stt set start sound : Fail to make message"); + if (NULL == msg) { + SLOG(LOG_ERROR, TAG_STTC, ">>>> stt set start sound : Fail to make message"); return STT_ERROR_OPERATION_FAILED; } else { SECURE_SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt set start sound : uid(%d) file(%s)", uid, file); } - dbus_message_append_args( msg, + dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_STRING, &file, DBUS_TYPE_INVALID); @@ -984,9 +984,9 @@ int stt_dbus_request_set_start_sound(int uid, const char* file) DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID); - if (dbus_error_is_set(&err)) { + if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_STTC, "<<<< Get arguments error (%s)", err.message); - dbus_error_free(&err); + dbus_error_free(&err); result = STT_ERROR_OPERATION_FAILED; } dbus_message_unref(result_msg); @@ -1015,14 +1015,14 @@ int stt_dbus_request_unset_start_sound(int uid) STT_SERVER_SERVICE_INTERFACE, STT_METHOD_UNSET_START_SOUND); - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_STTC, ">>>> stt unset start sound : Fail to make message"); + if (NULL == msg) { + SLOG(LOG_ERROR, TAG_STTC, ">>>> stt unset start sound : Fail to make message"); return STT_ERROR_OPERATION_FAILED; } else { SECURE_SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt unset start sound : uid(%d)", uid); } - dbus_message_append_args( msg, + dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID); @@ -1044,9 +1044,9 @@ int stt_dbus_request_unset_start_sound(int uid) DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID); - if (dbus_error_is_set(&err)) { + if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_STTC, "<<<< Get arguments error (%s)", err.message); - dbus_error_free(&err); + dbus_error_free(&err); result = STT_ERROR_OPERATION_FAILED; } dbus_message_unref(result_msg); @@ -1080,14 +1080,14 @@ int stt_dbus_request_set_stop_sound(int uid, const char* file) STT_SERVER_SERVICE_INTERFACE, STT_METHOD_SET_STOP_SOUND); - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_STTC, ">>>> stt set stop sound : Fail to make message"); + if (NULL == msg) { + SLOG(LOG_ERROR, TAG_STTC, ">>>> stt set stop sound : Fail to make message"); return STT_ERROR_OPERATION_FAILED; } else { SECURE_SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt set stop sound : uid(%d) file(%s)", uid, file); } - dbus_message_append_args( msg, + dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_STRING, &file, DBUS_TYPE_INVALID); @@ -1110,9 +1110,9 @@ int stt_dbus_request_set_stop_sound(int uid, const char* file) DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID); - if (dbus_error_is_set(&err)) { + if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_STTC, "<<<< Get arguments error (%s)", err.message); - dbus_error_free(&err); + dbus_error_free(&err); result = STT_ERROR_OPERATION_FAILED; } dbus_message_unref(result_msg); @@ -1141,14 +1141,14 @@ int stt_dbus_request_unset_stop_sound(int uid) STT_SERVER_SERVICE_INTERFACE, STT_METHOD_UNSET_STOP_SOUND); - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_STTC, ">>>> stt unset stop sound : Fail to make message"); + if (NULL == msg) { + SLOG(LOG_ERROR, TAG_STTC, ">>>> stt unset stop sound : Fail to make message"); return STT_ERROR_OPERATION_FAILED; } else { SECURE_SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt unset stop sound : uid(%d)", uid); } - dbus_message_append_args( msg, + dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID); @@ -1170,9 +1170,9 @@ int stt_dbus_request_unset_stop_sound(int uid) DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID); - if (dbus_error_is_set(&err)) { + if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_STTC, "<<<< Get arguments error (%s)", err.message); - dbus_error_free(&err); + dbus_error_free(&err); result = STT_ERROR_OPERATION_FAILED; } dbus_message_unref(result_msg); @@ -1207,14 +1207,14 @@ int stt_dbus_request_start(int uid, const char* lang, const char* type, int sile STT_SERVER_SERVICE_INTERFACE, STT_METHOD_START); - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_STTC, ">>>> stt start : Fail to make message"); + if (NULL == msg) { + SLOG(LOG_ERROR, TAG_STTC, ">>>> stt start : Fail to make message"); return STT_ERROR_OPERATION_FAILED; } else { SECURE_SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt start : uid(%d), language(%s), type(%s)", uid, lang, type); } - dbus_message_append_args( msg, + dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_STRING, &lang, DBUS_TYPE_STRING, &type, @@ -1240,9 +1240,9 @@ int stt_dbus_request_start(int uid, const char* lang, const char* type, int sile DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID); - if (dbus_error_is_set(&err)) { + if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_STTC, "<<<< Get arguments error (%s)", err.message); - dbus_error_free(&err); + dbus_error_free(&err); result = STT_ERROR_OPERATION_FAILED; } dbus_message_unref(result_msg); @@ -1272,8 +1272,8 @@ int stt_dbus_request_stop(int uid) STT_SERVER_SERVICE_INTERFACE, STT_METHOD_STOP); - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_STTC, ">>>> stt stop : Fail to make message"); + if (NULL == msg) { + SLOG(LOG_ERROR, TAG_STTC, ">>>> stt stop : Fail to make message"); return STT_ERROR_OPERATION_FAILED; } else { SECURE_SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt stop : uid(%d)", uid); @@ -1301,9 +1301,9 @@ int stt_dbus_request_stop(int uid) DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID); - if (dbus_error_is_set(&err)) { + if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_STTC, "<<<< Get arguments error (%s)", err.message); - dbus_error_free(&err); + dbus_error_free(&err); result = STT_ERROR_OPERATION_FAILED; } dbus_message_unref(result_msg); @@ -1333,8 +1333,8 @@ int stt_dbus_request_cancel(int uid) STT_SERVER_SERVICE_INTERFACE, /* interface name of the signal */ STT_METHOD_CANCEL); /* name of the signal */ - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_STTC, ">>>> stt cancel : Fail to make message"); + if (NULL == msg) { + SLOG(LOG_ERROR, TAG_STTC, ">>>> stt cancel : Fail to make message"); return STT_ERROR_OPERATION_FAILED; } else { SECURE_SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt cancel : uid(%d)", uid); @@ -1362,9 +1362,9 @@ int stt_dbus_request_cancel(int uid) DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID); - if (dbus_error_is_set(&err)) { + if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_STTC, "<<<< Get arguments error (%s)", err.message); - dbus_error_free(&err); + dbus_error_free(&err); result = STT_ERROR_OPERATION_FAILED; } dbus_message_unref(result_msg); diff --git a/client/stt_file.c b/client/stt_file.c index 1a9d6b3..d67f247 100644 --- a/client/stt_file.c +++ b/client/stt_file.c @@ -1,5 +1,5 @@ /* -* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved +* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -41,7 +41,7 @@ typedef struct _sttengine_info { bool use_network; bool is_loaded; -}sttengine_info_s; +} sttengine_info_s; static GSList* g_engine_list; @@ -58,7 +58,7 @@ const char* stt_tag() static const char* __stt_file_get_error_code(stt_file_error_e err) { - switch(err) { + switch (err) { case STT_FILE_ERROR_NONE: return "STT_FILE_ERROR_NONE"; case STT_FILE_ERROR_OUT_OF_MEMORY: return "STT_FILE_ERROR_OUT_OF_MEMORY"; case STT_FILE_ERROR_IO_ERROR: return "STT_FILE_ERROR_IO_ERROR"; @@ -78,7 +78,7 @@ static const char* __stt_file_get_error_code(stt_file_error_e err) void __stt_file_engine_info_cb(const char* engine_uuid, const char* engine_name, const char* setting_ug_name, bool use_network, void* user_data) { - sttengine_info_s* temp = (sttengine_info_s*)user_data; + sttengine_info_s* temp = (sttengine_info_s*)user_data; temp->engine_uuid = g_strdup(engine_uuid); temp->engine_name = g_strdup(engine_name); @@ -89,7 +89,7 @@ void __stt_file_engine_info_cb(const char* engine_uuid, const char* engine_name, static int __stt_file_get_engine_info(const char* filepath, sttengine_info_s** info) { if (NULL == filepath || NULL == info) { - SLOG(LOG_ERROR, TAG_STTFC, "[Engine Agent ERROR] Invalid Parameter"); + SLOG(LOG_ERROR, TAG_STTFC, "[Engine Agent ERROR] Invalid Parameter"); return STT_FILE_ERROR_INVALID_PARAMETER; } @@ -97,7 +97,7 @@ static int __stt_file_get_engine_info(const char* filepath, sttengine_info_s** i char *error; void* handle; - handle = dlopen (filepath, RTLD_LAZY); + handle = dlopen(filepath, RTLD_LAZY); if (!handle) { SECURE_SLOG(LOG_WARN, TAG_STTFC, "[Engine Agent] Invalid engine : %s", filepath); @@ -107,14 +107,14 @@ static int __stt_file_get_engine_info(const char* filepath, sttengine_info_s** i /* link engine to daemon */ dlsym(handle, "sttp_load_engine"); if ((error = dlerror()) != NULL) { - SLOG(LOG_WARN, TAG_STTFC, "[Engine Agent] Invalid engine. Fail to open sttp_load_engine : %s", error); + SLOG(LOG_WARN, TAG_STTFC, "[Engine Agent] Invalid engine. Fail to open sttp_load_engine : %s", error); dlclose(handle); return STT_FILE_ERROR_ENGINE_NOT_FOUND; } dlsym(handle, "sttp_unload_engine"); if ((error = dlerror()) != NULL) { - SLOG(LOG_WARN, TAG_STTFC, "[Engine Agent] Invalid engine. Fail to open sttp_unload_engine : %s", error); + SLOG(LOG_WARN, TAG_STTFC, "[Engine Agent] Invalid engine. Fail to open sttp_unload_engine : %s", error); dlclose(handle); return STT_FILE_ERROR_ENGINE_NOT_FOUND; } @@ -123,7 +123,7 @@ static int __stt_file_get_engine_info(const char* filepath, sttengine_info_s** i get_engine_info = (int (*)(sttpe_engine_info_cb, void*))dlsym(handle, "sttp_get_engine_info"); if ((error = dlerror()) != NULL || NULL == get_engine_info) { - SLOG(LOG_WARN, TAG_STTFC, "[Engine Agent WARNING] Invalid engine. Fail to open sttp_get_engine_info : %s", error); + SLOG(LOG_WARN, TAG_STTFC, "[Engine Agent WARNING] Invalid engine. Fail to open sttp_get_engine_info : %s", error); dlclose(handle); return -1; } @@ -138,7 +138,7 @@ static int __stt_file_get_engine_info(const char* filepath, sttengine_info_s** i /* get engine info */ if (0 != get_engine_info(__stt_file_engine_info_cb, (void*)temp)) { - SLOG(LOG_ERROR, TAG_STTFC, "[Engine Agent ERROR] Fail to get engine info from engine"); + SLOG(LOG_ERROR, TAG_STTFC, "[Engine Agent ERROR] Fail to get engine info from engine"); dlclose(handle); free(temp); return STT_FILE_ERROR_ENGINE_NOT_FOUND; @@ -159,7 +159,7 @@ static int __stt_file_get_engine_info(const char* filepath, sttengine_info_s** i SECURE_SLOG(LOG_DEBUG, TAG_STTFC, "Engine name : %s", temp->engine_name); SECURE_SLOG(LOG_DEBUG, TAG_STTFC, "Engine path : %s", temp->engine_path); SECURE_SLOG(LOG_DEBUG, TAG_STTFC, "Engine setting path : %s", temp->engine_setting_path); - SECURE_SLOG(LOG_DEBUG, TAG_STTFC, "Use network : %s", temp->use_network ? "true":"false"); + SECURE_SLOG(LOG_DEBUG, TAG_STTFC, "Use network : %s", temp->use_network ? "true" : "false"); SLOG(LOG_DEBUG, TAG_STTFC, "-----"); SLOG(LOG_DEBUG, TAG_STTFC, " "); @@ -184,7 +184,7 @@ static bool __stt_file_is_engine(const char* filepath) if (0 == strcmp(engine->engine_path, filepath)) { return true; } - + iter = g_slist_next(iter); } } @@ -207,13 +207,13 @@ void __stt_file_relseae_engine_info() /* Get handle data from list */ engine = iter->data; g_engine_list = g_slist_remove_link(g_engine_list, iter); - + /* Check engine unload */ if (NULL != engine) { if (engine->is_loaded) { SECURE_SLOG(LOG_DEBUG, TAG_STTFC, "[Engine Agent] Unload engine id(%d)", engine->engine_id); - if (0 != stt_engine_deinitialize(engine->engine_id)) + if (0 != stt_engine_deinitialize(engine->engine_id)) SECURE_SLOG(LOG_WARN, TAG_STTFC, "[Engine Agent] Fail to deinitialize engine id(%d)", engine->engine_id); if (0 != stt_engine_unload(engine->engine_id)) @@ -246,7 +246,7 @@ static sttengine_info_s* __stt_file_get_engine_by_id(int engine_id) data = iter->data; - if (data->engine_id == engine_id) + if (data->engine_id == engine_id) return data; iter = g_slist_next(iter); @@ -258,12 +258,12 @@ static sttengine_info_s* __stt_file_get_engine_by_id(int engine_id) void __stt_file_result_cb(sttp_result_event_e event, const char* type, const char** data, int data_count, const char* msg, void* time_info, void *user_data) { - + SLOG(LOG_DEBUG, TAG_STTFC, "[STT FILE] Result event(%d) type(%s) msg(%s)", event, type, msg); if (NULL != data) { int i = 0; - for (i = 0;i < data_count;i++) { + for (i = 0; i < data_count; i++) { if (NULL != data[i]) { SLOG(LOG_DEBUG, TAG_STTFC, "[STT FILE] [%d] %s", i, data[i]); } @@ -295,13 +295,13 @@ void __stt_file_result_cb(sttp_result_event_e event, const char* type, const cha if (STTP_RESULT_EVENT_FINAL_RESULT == event || STTP_RESULT_EVENT_ERROR == event) { SLOG(LOG_DEBUG, TAG_STTFC, "[STT FILE] State change : 'Ready'"); - + client->before_state = client->current_state; client->current_state = STT_FILE_STATE_READY; if (NULL != client->state_changed_cb) { stt_file_client_use_callback(client); - client->state_changed_cb(client->before_state, client->current_state, client->state_changed_user_data); + client->state_changed_cb(client->before_state, client->current_state, client->state_changed_user_data); stt_file_client_not_use_callback(client); SLOG(LOG_DEBUG, TAG_STTFC, "State changed callback is called"); } else { @@ -398,7 +398,7 @@ int stt_file_initialize() closedir(dp); } else { - SLOG(LOG_WARN, TAG_STTFC, "[Engine Agent WARNING] Fail to open default directory"); + SLOG(LOG_WARN, TAG_STTFC, "[Engine Agent WARNING] Fail to open default directory"); } if (0 >= g_slist_length(g_engine_list)) { @@ -435,7 +435,7 @@ int stt_file_initialize() __stt_file_relseae_engine_info(); return STT_FILE_ERROR_OPERATION_FAILED; } - + SLOG(LOG_DEBUG, TAG_STTFC, "[STT FILE] Get engine id : %s", engine_id); bool is_found = false; @@ -501,7 +501,7 @@ int stt_file_initialize() int stt_file_deinitialize() { SLOG(LOG_DEBUG, TAG_STTFC, "===== Deinitialize STT FILE"); - + stt_file_client_s* client = stt_file_client_get(); if (NULL == client) { SLOG(LOG_ERROR, TAG_STTFC, "[STT FILE ERROR] Not initialized"); @@ -562,7 +562,7 @@ int stt_file_get_state(stt_file_state_e* state) *state = client->current_state; - switch(*state) { + switch (*state) { case STT_FILE_STATE_NONE: SLOG(LOG_DEBUG, TAG_STTFC, "Current state is 'NONE'"); break; case STT_FILE_STATE_READY: SLOG(LOG_DEBUG, TAG_STTFC, "Current state is 'Ready'"); break; case STT_FILE_STATE_PROCESSING: SLOG(LOG_DEBUG, TAG_STTFC, "Current state is 'Processing'"); break; @@ -620,7 +620,7 @@ int stt_file_foreach_supported_engines(stt_file_supported_engine_cb callback, vo SLOG(LOG_DEBUG, TAG_STTFC, "====="); SLOG(LOG_DEBUG, TAG_STTFC, " "); - + return STT_FILE_ERROR_NONE; } @@ -668,7 +668,7 @@ int stt_file_get_engine(char** engine_id) } int stt_file_set_engine(const char* engine_id) -{ +{ SLOG(LOG_DEBUG, TAG_STTFC, "===== Set current engine"); if (NULL == engine_id) { @@ -718,11 +718,11 @@ int stt_file_set_engine(const char* engine_id) break; } - + iter = g_slist_next(iter); engine = NULL; } - + if (NULL == engine) { SLOG(LOG_ERROR, TAG_STTFC, "[Engine Agent ERROR] Engine id is NOT valid"); return STT_FILE_ERROR_INVALID_PARAMETER; @@ -856,8 +856,8 @@ int stt_file_start(const char* language, const char* type, const char* filepath, } } - SLOG(LOG_DEBUG, TAG_STTFC, "[START Info] Engine(%d) Lang(%s) Type(%s) Filepath(%s) Audio(%d) Sample rate(%d)" - ,client->current_engine_id, language, type, filepath, audio_type, sample_rate); + SLOG(LOG_DEBUG, TAG_STTFC, "[START Info] Engine(%d) Lang(%s) Type(%s) Filepath(%s) Audio(%d) Sample rate(%d)", + , client->current_engine_id, language, type, filepath, audio_type, sample_rate); int ret = -1; ret = stt_engine_recognize_start_file(client->current_engine_id, language, type, filepath, audio_type, sample_rate, NULL); @@ -873,7 +873,7 @@ int stt_file_start(const char* language, const char* type, const char* filepath, if (NULL != client->state_changed_cb) { stt_file_client_use_callback(client); - client->state_changed_cb(client->before_state, client->current_state, client->state_changed_user_data); + client->state_changed_cb(client->before_state, client->current_state, client->state_changed_user_data); stt_file_client_not_use_callback(client); SLOG(LOG_DEBUG, TAG_STTFC, "State changed callback is called"); } else { @@ -898,7 +898,7 @@ int stt_file_cancel() SLOG(LOG_DEBUG, TAG_STTFC, "====="); SLOG(LOG_DEBUG, TAG_STTFC, " "); return STT_FILE_ERROR_INVALID_PARAMETER; - } + } /* check state */ if (STT_FILE_STATE_PROCESSING != client->current_state) { @@ -922,7 +922,7 @@ int stt_file_cancel() if (NULL != client->state_changed_cb) { stt_file_client_use_callback(client); - client->state_changed_cb(client->before_state, client->current_state, client->state_changed_user_data); + client->state_changed_cb(client->before_state, client->current_state, client->state_changed_user_data); stt_file_client_not_use_callback(client); SLOG(LOG_DEBUG, TAG_STTFC, "State changed callback is called"); } else { @@ -935,10 +935,10 @@ int stt_file_cancel() return STT_FILE_ERROR_NONE; } -bool __stt_file_result_time_cb(int index, sttp_result_time_event_e event, const char* text, long start_time, long end_time, void* user_data) +bool __stt_file_result_time_cb(int index, sttp_result_time_event_e event, const char* text, long start_time, long end_time, void* user_data) { SLOG(LOG_DEBUG, TAG_STTFC, "(%d) event(%d) text(%s) start(%ld) end(%ld)", - index, event, text, start_time, end_time); + index, event, text, start_time, end_time); stt_file_client_s* client = stt_file_client_get(); diff --git a/client/stt_setting.c b/client/stt_setting.c index 15452e9..974d2b4 100644 --- a/client/stt_setting.c +++ b/client/stt_setting.c @@ -1,5 +1,5 @@ /* -* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved +* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -103,10 +103,10 @@ int stt_setting_initialize(void) return STT_SETTING_ERROR_NONE; } -int stt_setting_finalize () +int stt_setting_finalize() { SLOG(LOG_DEBUG, TAG_STTC, "===== Finalize STT Setting"); - + stt_config_mgr_finalize(getpid()); g_state = STT_SETTING_STATE_NONE; @@ -216,7 +216,7 @@ int stt_setting_set_engine(const char* engine_id) SLOG(LOG_DEBUG, TAG_STTC, "====="); SLOG(LOG_DEBUG, TAG_STTC, " "); - + return ret; } @@ -243,7 +243,7 @@ int stt_setting_foreach_supported_languages(stt_setting_supported_language_cb ca if (0 != ret) { SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to get current engine : %d", ret); return -1; - } + } ret = stt_config_mgr_get_language_list(current_engine, (stt_config_supported_langauge_cb)callback, user_data); @@ -255,7 +255,7 @@ int stt_setting_foreach_supported_languages(stt_setting_supported_language_cb ca } else { SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Foreach supported languages"); } - + SLOG(LOG_DEBUG, TAG_STTC, "====="); SLOG(LOG_DEBUG, TAG_STTC, " "); @@ -378,7 +378,7 @@ int stt_setting_get_auto_language(bool* value) SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Result : %d", ret); } else { /* Copy value */ - SECURE_SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Get auto language (%s)", *value ? "true":"false"); + SECURE_SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Get auto language (%s)", *value ? "true" : "false"); } SLOG(LOG_DEBUG, TAG_STTC, "====="); @@ -407,9 +407,9 @@ int stt_setting_get_silence_detection(bool* value) int ret = stt_config_mgr_get_silence_detection(value); if (0 != ret) { - SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Result (%d)", ret); + SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Result (%d)", ret); } else { - SECURE_SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Get silence detection(%s)", *value ? "true":"false"); + SECURE_SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Get silence detection(%s)", *value ? "true" : "false"); } SLOG(LOG_DEBUG, TAG_STTC, "====="); @@ -431,9 +431,9 @@ int stt_setting_set_silence_detection(bool value) int ret = stt_config_mgr_set_silence_detection(value); if (0 != ret) { - SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Result (%d)", ret); + SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Result (%d)", ret); } else { - SECURE_SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Set silence detection(%s)", value ? "true":"false"); + SECURE_SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Set silence detection(%s)", value ? "true" : "false"); } SLOG(LOG_DEBUG, TAG_STTC, "====="); diff --git a/common/stt_config_mgr.c b/common/stt_config_mgr.c index 8110957..045bc86 100644 --- a/common/stt_config_mgr.c +++ b/common/stt_config_mgr.c @@ -1,5 +1,5 @@ /* -* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved +* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -31,7 +31,7 @@ typedef struct { stt_config_lang_changed_cb lang_cb; stt_config_bool_changed_cb bool_cb; void* user_data; -}stt_config_client_s; +} stt_config_client_s; extern const char* stt_tag(); @@ -85,7 +85,7 @@ bool __stt_config_mgr_check_lang_is_valid(const char* engine_id, const char* lan /* Get a first item */ iter_lang = g_slist_nth(engine_info->languages, 0); - int i = 1; + int i = 1; while (NULL != iter_lang) { /*Get handle data from list*/ engine_lang = iter_lang->data; @@ -137,13 +137,13 @@ int __stt_config_mgr_select_lang(const char* engine_id, char** language) iter = g_slist_next(iter); continue; } - + GSList *iter_lang = NULL; char* engine_lang = NULL; if (g_slist_length(engine_info->languages) > 0) { /* Get a first item */ iter_lang = g_slist_nth(engine_info->languages, 0); - + while (NULL != iter_lang) { engine_lang = iter_lang->data; if (NULL != engine_lang) { @@ -184,7 +184,7 @@ Eina_Bool stt_config_mgr_inotify_event_cb(void* data, Ecore_Fd_Handler *fd_handl SLOG(LOG_ERROR, stt_tag(), "[ERROR] Empty Inotify event"); SLOG(LOG_DEBUG, stt_tag(), "====="); SLOG(LOG_DEBUG, stt_tag(), " "); - return ECORE_CALLBACK_PASS_ON; + return ECORE_CALLBACK_PASS_ON; } if (IN_MODIFY == event.mask) { @@ -320,7 +320,7 @@ int __stt_config_mgr_register_config_event() wd = inotify_add_watch(fd, STT_CONFIG, IN_MODIFY); g_wd_noti = wd; - g_fd_handler_noti = ecore_main_fd_handler_add(fd, ECORE_FD_READ, (Ecore_Fd_Cb)stt_config_mgr_inotify_event_cb, NULL, NULL, NULL); + g_fd_handler_noti = ecore_main_fd_handler_add(fd, ECORE_FD_READ, (Ecore_Fd_Cb)stt_config_mgr_inotify_event_cb, NULL, NULL, NULL); if (NULL == g_fd_handler_noti) { SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to get handler_noti"); return -1; @@ -629,7 +629,7 @@ int __stt_config_mgr_check_engine_is_valid(const char* engine_id) SLOG(LOG_DEBUG, stt_tag(), " language : %s", g_config_info->language); SLOG(LOG_DEBUG, stt_tag(), " Silence detection : %s", g_config_info->silence_detection ? "on" : "off"); - if ( 0 != stt_parser_set_engine(g_config_info->engine_id, g_config_info->setting, g_config_info->language, + if (0 != stt_parser_set_engine(g_config_info->engine_id, g_config_info->setting, g_config_info->language, g_config_info->silence_detection)) { SLOG(LOG_ERROR, stt_tag(), " Fail to save config"); return STT_CONFIG_ERROR_OPERATION_FAILED; @@ -723,7 +723,7 @@ int stt_config_mgr_initialize(int uid) closedir(dp); } else { - SLOG(LOG_WARN, stt_tag(), "[Config WARNING] Fail to open default directory"); + SLOG(LOG_WARN, stt_tag(), "[Config WARNING] Fail to open default directory"); } __stt_config_mgr_print_engine_info(); @@ -732,7 +732,7 @@ int stt_config_mgr_initialize(int uid) SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to parse configure information"); __stt_config_release_client(uid); __stt_config_release_engine(); - return STT_CONFIG_ERROR_OPERATION_FAILED; + return STT_CONFIG_ERROR_OPERATION_FAILED; } /* Check whether engine id is valid */ @@ -896,7 +896,7 @@ int stt_config_mgr_set_callback(int uid, stt_config_engine_changed_cb engine_cb, } int stt_config_mgr_unset_callback(int uid) -{ +{ GSList *iter = NULL; stt_config_client_s* temp_client = NULL; @@ -955,7 +955,7 @@ int stt_config_mgr_get_engine_list(stt_config_supported_engine_cb callback, void engine_info->setting, engine_info->support_silence_detection, user_data)) { break; } - + iter = g_slist_next(iter); } @@ -1101,7 +1101,7 @@ int stt_config_mgr_set_engine(const char* engine) SECURE_SLOG(LOG_DEBUG, stt_tag(), " language : %s", g_config_info->language); SECURE_SLOG(LOG_DEBUG, stt_tag(), " Silence detection : %s", g_config_info->silence_detection ? "on" : "off"); - if ( 0 != stt_parser_set_engine(g_config_info->engine_id, g_config_info->setting, g_config_info->language, + if (0 != stt_parser_set_engine(g_config_info->engine_id, g_config_info->setting, g_config_info->language, g_config_info->silence_detection)) { SLOG(LOG_ERROR, stt_tag(), " Fail to save config"); return STT_CONFIG_ERROR_OPERATION_FAILED; @@ -1180,7 +1180,7 @@ int stt_config_mgr_get_language_list(const char* engine_id, stt_config_supported SLOG(LOG_ERROR, stt_tag(), "Not initialized"); return STT_CONFIG_ERROR_INVALID_STATE; } - + if (0 >= g_slist_length(g_engine_list)) { SLOG(LOG_ERROR, stt_tag(), "There is no engine"); return STT_CONFIG_ERROR_ENGINE_NOT_FOUND; @@ -1207,7 +1207,7 @@ int stt_config_mgr_get_language_list(const char* engine_id, stt_config_supported GSList *iter_lang = NULL; char* lang; - + /* Get a first item */ iter_lang = g_slist_nth(engine_info->languages, 0); @@ -1220,7 +1220,7 @@ int stt_config_mgr_get_language_list(const char* engine_id, stt_config_supported if (false == callback(engine_info->uuid, lang, user_data)) break; } - + /*Get next item*/ iter_lang = g_slist_next(iter_lang); } @@ -1360,7 +1360,7 @@ bool stt_config_check_default_engine_is_valid(const char* engine) return false; } - if (0 >= g_slist_length(g_engine_list)) + if (0 >= g_slist_length(g_engine_list)) return false; GSList *iter = NULL; @@ -1399,7 +1399,7 @@ bool stt_config_check_default_language_is_valid(const char* language) return false; } - if (0 >= g_slist_length(g_engine_list)) + if (0 >= g_slist_length(g_engine_list)) return false; GSList *iter = NULL; @@ -1416,7 +1416,7 @@ bool stt_config_check_default_language_is_valid(const char* language) iter = g_slist_next(iter); continue; } - + if (0 != strcmp(g_config_info->engine_id, engine_info->uuid)) { iter = g_slist_next(iter); continue; @@ -1430,7 +1430,7 @@ bool stt_config_check_default_language_is_valid(const char* language) while (NULL != iter_lang) { lang = iter_lang->data; - + if (0 == strcmp(language, lang)) return true; @@ -1460,7 +1460,7 @@ int __stt_config_mgr_print_engine_info() SLOG(LOG_DEBUG, stt_tag(), "--------------- engine list -----------------"); - int i = 1; + int i = 1; while (NULL != iter) { engine_info = iter->data; @@ -1477,7 +1477,7 @@ int __stt_config_mgr_print_engine_info() /* Get a first item */ iter_lang = g_slist_nth(engine_info->languages, 0); - int j = 1; + int j = 1; while (NULL != iter_lang) { /*Get handle data from list*/ lang = iter_lang->data; diff --git a/common/stt_config_parser.c b/common/stt_config_parser.c index 5446999..a779086 100644 --- a/common/stt_config_parser.c +++ b/common/stt_config_parser.c @@ -1,5 +1,5 @@ /* -* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved +* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -103,7 +103,7 @@ int stt_parser_get_engine_info(const char* path, stt_engine_info_s** engine_info if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_ENGINE_NAME)) { key = xmlNodeGetContent(cur); if (NULL != key) { - // SLOG(LOG_DEBUG, stt_tag(), "Engine name : %s", (char *)key); + /* SLOG(LOG_DEBUG, stt_tag(), "Engine name : %s", (char *)key); */ if (NULL != temp->name) free(temp->name); temp->name = strdup((char*)key); xmlFree(key); @@ -113,7 +113,7 @@ int stt_parser_get_engine_info(const char* path, stt_engine_info_s** engine_info } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_ENGINE_ID)) { key = xmlNodeGetContent(cur); if (NULL != key) { - // SLOG(LOG_DEBUG, stt_tag(), "Engine uuid : %s", (char *)key); + /* SLOG(LOG_DEBUG, stt_tag(), "Engine uuid : %s", (char *)key); */ if (NULL != temp->uuid) free(temp->uuid); temp->uuid = strdup((char*)key); xmlFree(key); @@ -147,10 +147,10 @@ int stt_parser_get_engine_info(const char* path, stt_engine_info_s** engine_info lang_node = cur->xmlChildrenNode; while (lang_node != NULL) { - if (0 == xmlStrcmp(lang_node->name, (const xmlChar *)STT_TAG_ENGINE_LANGUAGE)){ + if (0 == xmlStrcmp(lang_node->name, (const xmlChar *)STT_TAG_ENGINE_LANGUAGE)) { key = xmlNodeGetContent(lang_node); if (NULL != key) { - // SLOG(LOG_DEBUG, stt_tag(), "language : %s", (char *)key); + /* SLOG(LOG_DEBUG, stt_tag(), "language : %s", (char *)key); */ temp_lang = strdup((char*)key); temp->languages = g_slist_append(temp->languages, temp_lang); xmlFree(key); @@ -164,13 +164,13 @@ int stt_parser_get_engine_info(const char* path, stt_engine_info_s** engine_info } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_ENGINE_SILENCE_SUPPORT)) { key = xmlNodeGetContent(cur); if (NULL != key) { - //SLOG(LOG_DEBUG, stt_tag(), "silence-detection-support : %s", (char *)key); + /*SLOG(LOG_DEBUG, stt_tag(), "silence-detection-support : %s", (char *)key); */ if (0 == xmlStrcmp(key, (const xmlChar *)"true")) temp->support_silence_detection = true; else temp->support_silence_detection = false; - + xmlFree(key); } else { SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_ENGINE_SILENCE_SUPPORT); @@ -213,7 +213,7 @@ int stt_parser_free_engine_info(stt_engine_info_s* engine_info) int i ; char *temp_lang; - for (i = 0;i < count ;i++) { + for (i = 0; i < count ; i++) { temp_lang = g_slist_nth_data(engine_info->languages, 0); if (NULL != temp_lang) { @@ -221,12 +221,12 @@ int stt_parser_free_engine_info(stt_engine_info_s* engine_info) if (NULL != temp_lang) free(temp_lang); - } + } } if (NULL != engine_info) free(engine_info); - return 0; + return 0; } int stt_parser_print_engine_info(stt_engine_info_s* engine_info) @@ -246,7 +246,7 @@ int stt_parser_print_engine_info(stt_engine_info_s* engine_info) /* Get a first item */ iter = g_slist_nth(engine_info->languages, 0); - int i = 1; + int i = 1; while (NULL != iter) { /*Get handle data from list*/ lang = iter->data; @@ -325,7 +325,7 @@ int stt_parser_load_config(stt_config_s** config_info) if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_CONFIG_ENGINE_ID)) { key = xmlNodeGetContent(cur); if (NULL != key) { - //SLOG(LOG_DEBUG, stt_tag(), "Engine id : %s", (char *)key); + /*SLOG(LOG_DEBUG, stt_tag(), "Engine id : %s", (char *)key); */ if (NULL != temp->engine_id) free(temp->engine_id); temp->engine_id = strdup((char*)key); xmlFree(key); @@ -335,7 +335,7 @@ int stt_parser_load_config(stt_config_s** config_info) } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_CONFIG_ENGINE_SETTING)) { key = xmlNodeGetContent(cur); if (NULL != key) { - //SECURE_SLOG(LOG_DEBUG, stt_tag(), "Setting path : %s", (char *)key); + /*SECURE_SLOG(LOG_DEBUG, stt_tag(), "Setting path : %s", (char *)key); */ if (NULL != temp->setting) free(temp->setting); temp->setting = strdup((char*)key); xmlFree(key); @@ -346,7 +346,7 @@ int stt_parser_load_config(stt_config_s** config_info) } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_CONFIG_AUTO_LANGUAGE)) { key = xmlNodeGetContent(cur); if (NULL != key) { - //SECURE_SLOG(LOG_DEBUG, stt_tag(), "Auto language : %s", (char *)key); + /*SECURE_SLOG(LOG_DEBUG, stt_tag(), "Auto language : %s", (char *)key); */ if (0 == xmlStrcmp(key, (const xmlChar *)"on")) { temp->auto_lang = true; @@ -364,7 +364,7 @@ int stt_parser_load_config(stt_config_s** config_info) } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_CONFIG_LANGUAGE)) { key = xmlNodeGetContent(cur); if (NULL != key) { - //SLOG(LOG_DEBUG, stt_tag(), "language : %s", (char *)key); + /*SLOG(LOG_DEBUG, stt_tag(), "language : %s", (char *)key); */ if (NULL != temp->language) free(temp->language); temp->language = strdup((char*)key); xmlFree(key); @@ -374,7 +374,7 @@ int stt_parser_load_config(stt_config_s** config_info) } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_CONFIG_SILENCE_DETECTION)) { key = xmlNodeGetContent(cur); if (NULL != key) { - //SLOG(LOG_DEBUG, stt_tag(), "silence-detection : %s", (char *)key); + /*SLOG(LOG_DEBUG, stt_tag(), "silence-detection : %s", (char *)key); */ if (0 == xmlStrcmp(key, (const xmlChar *)"on")) temp->silence_detection = true; @@ -454,7 +454,7 @@ int stt_parser_set_engine(const char* engine_id, const char* setting, const char if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_CONFIG_SILENCE_DETECTION)) { if (true == silence) xmlNodeSetContent(cur, (const xmlChar *)"on"); - else + else xmlNodeSetContent(cur, (const xmlChar *)"off"); } @@ -493,7 +493,7 @@ int stt_parser_set_language(const char* language) while (cur != NULL) { if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_CONFIG_LANGUAGE)) { xmlNodeSetContent(cur, (const xmlChar *)language); - } + } cur = cur->next; } @@ -576,9 +576,9 @@ int stt_parser_set_silence_detection(bool value) if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_CONFIG_SILENCE_DETECTION)) { if (true == value) xmlNodeSetContent(cur, (const xmlChar *)"on"); - else + else xmlNodeSetContent(cur, (const xmlChar *)"off"); - } + } cur = cur->next; } @@ -726,7 +726,7 @@ int stt_parser_find_config_changed(char** engine, char** setting, int* auto_lang *silence = 0; } } - + xmlFree(key_new); } xmlFree(key_old); @@ -741,7 +741,7 @@ int stt_parser_find_config_changed(char** engine, char** setting, int* auto_lang cur_new = cur_new->next; cur_old = cur_old->next; } - + xmlFreeDoc(g_config_doc); g_config_doc = doc; @@ -790,16 +790,16 @@ int stt_parser_set_time_info(GSList* time_list) iter = g_slist_nth(time_list, 0); while (NULL != iter) { data = iter->data; - + xmlNodePtr temp_node = NULL; - SLOG(LOG_DEBUG, stt_tag(), "[%d] i(%d) t(%s) s(%d) e(%d)", - data->index, data->event, data->text, data->start_time, data->end_time); - + SLOG(LOG_DEBUG, stt_tag(), "[%d] i(%d) t(%s) s(%d) e(%d)", + data->index, data->event, data->text, data->start_time, data->end_time); + temp_node = xmlNewNode(NULL, (const xmlChar*)STT_TAG_TIME_TEXT); xmlNodeSetContent(temp_node, (const xmlChar*)data->text); xmlAddChild(inode, temp_node); - + temp_node = xmlNewNode(NULL, (const xmlChar*)STT_TAG_TIME_START); snprintf(temp_str, 256, "%ld", data->start_time); xmlNodeSetContent(temp_node, (const xmlChar*)temp_str); @@ -869,7 +869,7 @@ int stt_parser_get_time_info(GSList** time_list) SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_TIME_COUNT); return -1; } - + SLOG(LOG_DEBUG, stt_tag(), "Count : %s", (char *)key); /* Get time count */ @@ -886,7 +886,7 @@ int stt_parser_get_time_info(GSList** time_list) time_node = cur->xmlChildrenNode; int i = 0; - for (i = 0;i < count;i++) { + for (i = 0; i < count; i++) { /* text */ time_node = time_node->next; @@ -935,7 +935,7 @@ int stt_parser_get_time_info(GSList** time_list) break; } } - + /* text */ time_node = time_node->next; time_node = time_node->next; diff --git a/common/stt_engine.c b/common/stt_engine.c index 5605bb5..1b315bb 100644 --- a/common/stt_engine.c +++ b/common/stt_engine.c @@ -1,5 +1,5 @@ /* -* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved +* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -34,7 +34,7 @@ typedef struct { int (*sttp_load_engine)(sttpd_funcs_s* pdfuncs, sttpe_funcs_s* pefuncs); int (*sttp_unload_engine)(); -}sttengine_s; +} sttengine_s; extern const char* stt_tag(); @@ -43,7 +43,7 @@ static GSList *g_engine_list; static const char* __stt_get_engine_error_code(sttp_error_e err) { - switch(err) { + switch (err) { case STTP_ERROR_NONE: return "STTP_ERROR_NONE"; case STTP_ERROR_OUT_OF_MEMORY: return "STTP_ERROR_OUT_OF_MEMORY"; case STTP_ERROR_IO_ERROR: return "STTP_ERROR_IO_ERROR"; @@ -88,7 +88,7 @@ static sttengine_s* __get_engine(int engine_id) int stt_engine_load(int engine_id, const char* filepath) { if (NULL == filepath || engine_id < 0) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); + SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); return STTP_ERROR_INVALID_PARAMETER; } @@ -147,7 +147,7 @@ int stt_engine_load(int engine_id, const char* filepath) return STTP_ERROR_OPERATION_FAILED; } - engine->sttp_load_engine = (int (*)(sttpd_funcs_s*, sttpe_funcs_s*) )dlsym(engine->handle, "sttp_load_engine"); + engine->sttp_load_engine = (int (*)(sttpd_funcs_s*, sttpe_funcs_s*))dlsym(engine->handle, "sttp_load_engine"); if (NULL != (error = dlerror()) || NULL == engine->sttp_load_engine) { SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to link daemon to sttp_load_engine() : %s", error); dlclose(engine->handle); @@ -162,8 +162,8 @@ int stt_engine_load(int engine_id, const char* filepath) engine->pdfuncs->version = 1; engine->pdfuncs->size = sizeof(sttpd_funcs_s); - - int ret = engine->sttp_load_engine(engine->pdfuncs, engine->pefuncs); + + int ret = engine->sttp_load_engine(engine->pdfuncs, engine->pefuncs); if (0 != ret) { SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail sttp_load_engine() : %s", __stt_get_engine_error_code(ret)); dlclose(engine->handle); @@ -203,10 +203,10 @@ int stt_engine_load(int engine_id, const char* filepath) free(engine->engine_path); free(engine); - return STTP_ERROR_OPERATION_FAILED; + return STTP_ERROR_OPERATION_FAILED; } - SECURE_SLOG(LOG_DEBUG, stt_tag(), "[Engine Success] Load engine : version(%d), size(%d)",engine->pefuncs->version, engine->pefuncs->size); + SECURE_SLOG(LOG_DEBUG, stt_tag(), "[Engine Success] Load engine : version(%d), size(%d)", engine->pefuncs->version, engine->pefuncs->size); g_engine_list = g_slist_append(g_engine_list, engine); @@ -226,7 +226,7 @@ int stt_engine_unload(int engine_id) /* unload engine */ engine->sttp_unload_engine(); dlclose(engine->handle); - + if (NULL != engine->engine_path) free(engine->engine_path); if (NULL != engine->pefuncs) free(engine->pefuncs); if (NULL != engine->pdfuncs) free(engine->pdfuncs); @@ -234,7 +234,7 @@ int stt_engine_unload(int engine_id) g_engine_list = g_slist_remove(g_engine_list, engine); free(engine); - + return 0; } @@ -243,7 +243,7 @@ int stt_engine_unload(int engine_id) int stt_engine_initialize(int engine_id, sttpe_result_cb result_cb, sttpe_silence_detected_cb silence_cb) { if (NULL == result_cb || NULL == silence_cb) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); + SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); return STTP_ERROR_INVALID_PARAMETER; } @@ -302,7 +302,7 @@ static bool __supported_language_cb(const char* language, void* user_data) int stt_engine_get_supported_langs(int engine_id, GSList** lang_list) { if (NULL == lang_list) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); + SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); return STTP_ERROR_INVALID_PARAMETER; } @@ -326,7 +326,7 @@ int stt_engine_get_supported_langs(int engine_id, GSList** lang_list) int stt_engine_is_valid_language(int engine_id, const char* language, bool *is_valid) { if (NULL == language || NULL == is_valid) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); + SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); return STTP_ERROR_INVALID_PARAMETER; } @@ -336,7 +336,7 @@ int stt_engine_is_valid_language(int engine_id, const char* language, bool *is_v SECURE_SLOG(LOG_WARN, stt_tag(), "[Engine WARNING] engine id(%d) is invalid", engine_id); return STTP_ERROR_INVALID_PARAMETER; } - + bool result; result = engine->pefuncs->is_valid_lang(language); @@ -348,7 +348,7 @@ int stt_engine_is_valid_language(int engine_id, const char* language, bool *is_v int stt_engine_get_first_language(int engine_id, char** language) { if (NULL == language) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); + SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); return STTP_ERROR_INVALID_PARAMETER; } @@ -404,7 +404,7 @@ int stt_engine_get_first_language(int engine_id, char** language) int stt_engine_support_silence(int engine_id, bool* support) { if (NULL == support) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); + SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); return STTP_ERROR_INVALID_PARAMETER; } @@ -425,7 +425,7 @@ int stt_engine_support_silence(int engine_id, bool* support) int stt_engine_support_recognition_type(int engine_id, const char* type, bool* support) { if (NULL == type || NULL == support) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); + SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); return STTP_ERROR_INVALID_PARAMETER; } @@ -449,7 +449,7 @@ int stt_engine_support_recognition_type(int engine_id, const char* type, bool* s int stt_engine_get_audio_type(int engine_id, sttp_audio_type_e* types, int* rate, int* channels) { if (NULL == types || NULL == rate || NULL == channels) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); + SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); return STTP_ERROR_INVALID_PARAMETER; } @@ -482,13 +482,13 @@ int stt_engine_set_silence_detection(int engine_id, bool value) int ret = engine->pefuncs->set_silence_detection(value); if (STTP_ERROR_NOT_SUPPORTED_FEATURE == ret) { - SLOG(LOG_WARN, stt_tag(), "[Engine WARNING] Not support silence detection"); + SLOG(LOG_WARN, stt_tag(), "[Engine WARNING] Not support silence detection"); return STTP_ERROR_NOT_SUPPORTED_FEATURE; } else if (0 != ret) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to set silence detection : %d", ret); + SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to set silence detection : %d", ret); return STTP_ERROR_OPERATION_FAILED; } - + return 0; } @@ -513,7 +513,7 @@ int stt_engine_check_app_agreed(int engine_id, const char* appid, bool* value) *value = false; return STTP_ERROR_OPERATION_FAILED; } - + return 0; } @@ -521,7 +521,7 @@ int stt_engine_check_app_agreed(int engine_id, const char* appid, bool* value) int stt_engine_recognize_start(int engine_id, const char* lang, const char* recognition_type, void* user_param) { if (NULL == lang || NULL == recognition_type) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); + SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); return STTP_ERROR_INVALID_PARAMETER; } @@ -544,7 +544,7 @@ int stt_engine_recognize_start(int engine_id, const char* lang, const char* reco int stt_engine_set_recording_data(int engine_id, const void* data, unsigned int length) { if (NULL == data) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); + SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); return STTP_ERROR_INVALID_PARAMETER; } @@ -614,7 +614,7 @@ int stt_engine_foreach_result_time(int engine_id, void* time_info, sttpe_result_ SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to foreach result time : %s", __stt_get_engine_error_code(ret)); return STTP_ERROR_OPERATION_FAILED; } - + return 0; } @@ -622,7 +622,7 @@ int stt_engine_recognize_start_file(int engine_id, const char* lang, const char* const char* filepath, sttp_audio_type_e audio_type, int sample_rate, void* user_param) { if (NULL == filepath || NULL == lang || NULL == recognition_type) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); + SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); return STTP_ERROR_INVALID_PARAMETER; } diff --git a/common/stt_network.c b/common/stt_network.c index ac3210f..dcecd94 100644 --- a/common/stt_network.c +++ b/common/stt_network.c @@ -1,5 +1,5 @@ /* -* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved +* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -35,11 +35,11 @@ bool stt_network_is_connected() int network_status = 0; vconf_get_int(VCONFKEY_NETWORK_STATUS, &network_status); - if(network_status == VCONFKEY_NETWORK_OFF){ + if (network_status == VCONFKEY_NETWORK_OFF) { SLOG(LOG_WARN, stt_tag(), "[Network] Current network connection is OFF."); return false; } - + SLOG(LOG_DEBUG, stt_tag(), "[Network] Network status is %d", network_status); return true; diff --git a/server/sttd_client_data.c b/server/sttd_client_data.c index 4b3daa0..8029b57 100644 --- a/server/sttd_client_data.c +++ b/server/sttd_client_data.c @@ -1,5 +1,5 @@ /* -* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved +* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -31,13 +31,13 @@ int client_show_list() /* Get a first item */ iter = g_slist_nth(g_client_list, 0); - int i = 1; + int i = 1; while (NULL != iter) { /*Get handle data from list*/ data = iter->data; SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[%dth] uid(%d), state(%d)", i, data->uid, data->state); - + /*Get next item*/ iter = g_slist_next(iter); i++; @@ -63,9 +63,9 @@ GSList* __client_get_item(int uid) /* Get handle data from list */ data = iter->data; - if (uid == data->uid) + if (uid == data->uid) return iter; - + iter = g_slist_next(iter); } } @@ -78,7 +78,7 @@ int sttd_client_add(int pid, int uid) /*Check uid is duplicated*/ GSList *tmp = NULL; tmp = __client_get_item(uid); - + if (NULL != tmp) { SLOG(LOG_WARN, TAG_STTD, "[Client Data] Client uid is already registered"); return STTD_ERROR_INVALID_PARAMETER; @@ -100,7 +100,7 @@ int sttd_client_add(int pid, int uid) /* Add item to global list */ g_client_list = g_slist_append(g_client_list, info); - + if (NULL == g_client_list) { SLOG(LOG_ERROR, TAG_STTD, "[Client Data ERROR] Fail to add new client"); return -1; @@ -108,7 +108,7 @@ int sttd_client_add(int pid, int uid) #ifdef CLIENT_DATA_DEBUG client_show_list(); -#endif +#endif return 0; } @@ -137,7 +137,7 @@ int sttd_client_delete(int uid) #ifdef CLIENT_DATA_DEBUG client_show_list(); -#endif +#endif return 0; } @@ -182,7 +182,7 @@ int sttd_client_set_start_sound(int uid, const char* filename) if (NULL != hnd->start_beep) { free(hnd->start_beep); } - + if (NULL != filename) { hnd->start_beep = strdup(filename); SLOG(LOG_DEBUG, TAG_STTD, "[Client Data] Start sound file : %s", hnd->start_beep); @@ -233,7 +233,7 @@ int sttd_client_set_stop_sound(int uid, const char* filename) if (NULL != hnd->stop_beep) { free(hnd->stop_beep); } - + if (NULL != filename) { hnd->stop_beep = strdup(filename); SLOG(LOG_DEBUG, TAG_STTD, "[Client Data] Stop sound file : %s", hnd->stop_beep); @@ -313,7 +313,7 @@ int sttd_client_get_current_recording() /* Get handle data from list */ data = iter->data; - if (APP_STATE_RECORDING == data->state) + if (APP_STATE_RECORDING == data->state) return data->uid; iter = g_slist_next(iter); @@ -335,7 +335,7 @@ int sttd_client_get_current_thinking() /* Get handle data from list */ data = iter->data; - if (APP_STATE_PROCESSING == data->state) + if (APP_STATE_PROCESSING == data->state) return data->uid; iter = g_slist_next(iter); @@ -384,7 +384,7 @@ int sttd_client_get_list(int** uids, int* uid_count) { if (NULL == uids || NULL == uid_count) return -1; - + int count = g_slist_length(g_client_list); if (0 == count) @@ -402,7 +402,7 @@ int sttd_client_get_list(int** uids, int* uid_count) int i = 0; iter = g_slist_nth(g_client_list, 0); - for (i = 0;i < count;i++) { + for (i = 0; i < count; i++) { data = iter->data; tmp[i] = data->uid; iter = g_slist_next(iter); @@ -443,7 +443,7 @@ int stt_client_set_app_agreed(int uid) tmp = __client_get_item(uid); if (NULL == tmp) { - SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Client Data ERROR] uid(%d) is NOT valid", uid); + SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Client Data ERROR] uid(%d) is NOT valid", uid); return STTD_ERROR_INVALID_PARAMETER; } @@ -460,7 +460,7 @@ bool stt_client_get_app_agreed(int uid) tmp = __client_get_item(uid); if (NULL == tmp) { - SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Client Data ERROR] uid(%d) is NOT valid", uid); + SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Client Data ERROR] uid(%d) is NOT valid", uid); return STTD_ERROR_INVALID_PARAMETER; } diff --git a/server/sttd_config.c b/server/sttd_config.c index 0a129bb..229a087 100644 --- a/server/sttd_config.c +++ b/server/sttd_config.c @@ -1,5 +1,5 @@ /* -* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved +* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -64,7 +64,7 @@ void __config_bool_changed_cb(stt_config_type_e type, bool bool_value, void* use SECURE_SLOG(LOG_DEBUG, TAG_STTD, " type(%d) bool(%s)", type, bool_value ? "on" : "off"); if (STT_CONFIG_TYPE_OPTION_SILENCE_DETECTION == type) { - if (NULL != g_silence_cb){ + if (NULL != g_silence_cb) { g_silence_cb(bool_value, g_user_data); SLOG(LOG_DEBUG, TAG_STTD, "Call back silence detection changed"); } diff --git a/server/sttd_dbus.c b/server/sttd_dbus.c index d16d79e..e7b9d09 100644 --- a/server/sttd_dbus.c +++ b/server/sttd_dbus.c @@ -1,5 +1,5 @@ /* -* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved +* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -76,9 +76,9 @@ int sttdc_send_hello(int uid) if (NULL != result_msg) { dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID); - if (dbus_error_is_set(&err)) { + if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_STTD, "[Dbus] Get arguments error (%s)\n", err.message); - dbus_error_free(&err); + dbus_error_free(&err); result = -1; } @@ -130,8 +130,7 @@ int sttdc_send_set_state(int uid, int state) if (!dbus_connection_send(g_conn_sender, msg, NULL)) { SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Fail to send message : Out Of Memory !"); - } - else { + } else { SLOG(LOG_DEBUG, TAG_STTD, "<<<< Send error message : uid(%d), state(%d)", uid, state); dbus_connection_flush(g_conn_sender); } @@ -167,8 +166,8 @@ int sttdc_send_get_state(int uid, int* state) target_if_name, STTD_METHOD_GET_STATE); - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Fail to create message"); + if (NULL == msg) { + SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Fail to create message"); return -1; } @@ -191,9 +190,9 @@ int sttdc_send_get_state(int uid, int* state) if (NULL != result_msg) { dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &tmp, DBUS_TYPE_INVALID); - if (dbus_error_is_set(&err)) { + if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_STTD, "[Dbus] Get arguments error (%s)\n", err.message); - dbus_error_free(&err); + dbus_error_free(&err); result = -1; } else { *state = tmp; @@ -205,7 +204,7 @@ int sttdc_send_get_state(int uid, int* state) SLOG(LOG_ERROR, TAG_STTD, "[Dbus] Result message is NULL. Client is not available"); result = -1; } - + return result; } @@ -213,7 +212,7 @@ int sttdc_send_result(int uid, int event, const char** data, int data_count, con { 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 STTD_ERROR_INVALID_PARAMETER; } @@ -252,24 +251,24 @@ int sttdc_send_result(int uid, int event, const char** data, int data_count, con if (NULL == result_msg) { msg_temp = strdup("None"); dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &msg_temp); - SLOG(LOG_WARN, TAG_STTD, "[Dbus] result message is NULL"); + SLOG(LOG_WARN, TAG_STTD, "[Dbus] result message is NULL"); free(msg_temp); } else { - SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] result message(%s)", result_msg ); + SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] result message(%s)", result_msg); dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(result_msg)); } - + /* Append result size */ if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(data_count))) { - SLOG(LOG_ERROR, TAG_STTD, "[Dbus] response message : Fail to append result size"); + SLOG(LOG_ERROR, TAG_STTD, "[Dbus] response message : Fail to append result size"); return -1; } int i; - SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] result size (%d)", data_count); - for (i = 0;i < data_count;i++) { + SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] result size (%d)", data_count); + for (i = 0; i < data_count; i++) { if (NULL != data[i]) { - SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] result (%d, %s)", i, data[i] ); + SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] result (%d, %s)", i, data[i]); if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &data[i])) { SLOG(LOG_ERROR, TAG_STTD, "[Dbus] response message : Fail to append result data"); @@ -280,7 +279,7 @@ int sttdc_send_result(int uid, int event, const char** data, int data_count, con int reason = (int)STTD_ERROR_OPERATION_FAILED; if (0 != sttdc_send_error_signal(uid, reason, "Fail to get recognition result from engine")) { - SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Fail to send error info. Remove client data"); + SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Fail to send error info. Remove client data"); /* clean client data */ sttd_client_delete(uid); @@ -307,13 +306,13 @@ int sttdc_send_result(int uid, int event, const char** data, int data_count, con int sttdc_send_error_signal(int uid, int reason, const char *err_msg) { if (NULL == err_msg) { - SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Input parameter is NULL"); + SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Input parameter is NULL"); return STTD_ERROR_INVALID_PARAMETER; } 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 STTD_ERROR_INVALID_PARAMETER; } @@ -369,7 +368,7 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle } /* loop again if we haven't read a message */ - if (NULL == msg) { + if (NULL == msg) { return ECORE_CALLBACK_RENEW; } @@ -450,13 +449,13 @@ int sttd_dbus_open_connection() /* connect to the bus and check for errors */ g_conn_listener = dbus_bus_get(DBUS_BUS_SYSTEM, &err); - if (dbus_error_is_set(&err)) { + if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Fail dbus_bus_get : %s", err.message); - dbus_error_free(&err); + dbus_error_free(&err); } - if (NULL == g_conn_listener) { - SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Fail to get dbus connection" ); + if (NULL == g_conn_listener) { + SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Fail to get dbus connection"); return STTD_ERROR_OPERATION_FAILED; } @@ -468,7 +467,7 @@ int sttd_dbus_open_connection() return STTD_ERROR_OPERATION_FAILED; } - if (dbus_error_is_set(&err)) { + if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] dbus_bus_request_name() : %s", err.message); dbus_error_free(&err); return STTD_ERROR_OPERATION_FAILED; @@ -482,7 +481,7 @@ int sttd_dbus_open_connection() dbus_bus_add_match(g_conn_listener, rule, &err); /* see signals from the given interface */ dbus_connection_flush(g_conn_listener); - if (dbus_error_is_set(&err)) { + if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] dbus_bus_add_match() : %s", err.message); return STTD_ERROR_OPERATION_FAILED; } diff --git a/server/sttd_dbus_server.c b/server/sttd_dbus_server.c index 1d3164d..358357d 100644 --- a/server/sttd_dbus_server.c +++ b/server/sttd_dbus_server.c @@ -1,5 +1,5 @@ /* -* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved +* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -21,7 +21,7 @@ /* * Dbus Client-Daemon Server -*/ +*/ int sttd_dbus_server_hello(DBusConnection* conn, DBusMessage* msg) { @@ -37,7 +37,7 @@ int sttd_dbus_server_hello(DBusConnection* conn, DBusMessage* msg) dbus_connection_flush(conn); dbus_message_unref(reply); } else { - SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); + SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); } SLOG(LOG_DEBUG, TAG_STTD, "<<<<<"); @@ -64,12 +64,12 @@ int sttd_dbus_server_initialize(DBusConnection* conn, DBusMessage* msg) SLOG(LOG_DEBUG, TAG_STTD, ">>>>> STT Initialize"); - if (dbus_error_is_set(&err)) { + if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] stt initialize : get arguments error (%s)", err.message); - dbus_error_free(&err); + dbus_error_free(&err); ret = STTD_ERROR_OPERATION_FAILED; } else { - SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt initialize : pid(%d), uid(%d)", pid , uid); + SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt initialize : pid(%d), uid(%d)", pid , uid); ret = sttd_server_initialize(pid, uid, &silence_supported); } @@ -86,7 +86,7 @@ int sttd_dbus_server_initialize(DBusConnection* conn, DBusMessage* msg) SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d), silence(%d)", ret, silence_supported); } else { - SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); + SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); } if (!dbus_connection_send(conn, reply, NULL)) { @@ -96,7 +96,7 @@ int sttd_dbus_server_initialize(DBusConnection* conn, DBusMessage* msg) dbus_connection_flush(conn); dbus_message_unref(reply); } else { - SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); + SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); } SLOG(LOG_DEBUG, TAG_STTD, "<<<<<"); @@ -116,26 +116,26 @@ int sttd_dbus_server_finalize(DBusConnection* conn, DBusMessage* msg) SLOG(LOG_DEBUG, TAG_STTD, ">>>>> STT Finalize"); - if (dbus_error_is_set(&err)) { + if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] stt finalize : get arguments error (%s)", err.message); - dbus_error_free(&err); + dbus_error_free(&err); ret = STTD_ERROR_OPERATION_FAILED; } else { - SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt finalize : uid(%d)", uid); + SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt finalize : uid(%d)", uid); ret = sttd_server_finalize(uid); } DBusMessage* reply; - + reply = dbus_message_new_method_return(msg); if (NULL != reply) { dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); if (0 == ret) { - SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); + SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); } else { - SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); + SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); } if (!dbus_connection_send(conn, reply, NULL)) { @@ -145,7 +145,7 @@ int sttd_dbus_server_finalize(DBusConnection* conn, DBusMessage* msg) dbus_connection_flush(conn); dbus_message_unref(reply); } else { - SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); + SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); } SLOG(LOG_DEBUG, TAG_STTD, "<<<<<"); @@ -167,12 +167,12 @@ int sttd_dbus_server_get_support_engines(DBusConnection* conn, DBusMessage* msg) SLOG(LOG_DEBUG, TAG_STTD, ">>>>> STT Get supported engines"); - if (dbus_error_is_set(&err)) { + if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] stt supported engines : get arguments error (%s)", err.message); - dbus_error_free(&err); + dbus_error_free(&err); ret = STTD_ERROR_OPERATION_FAILED; } else { - SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt supported engines : uid(%d)", uid); + SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt supported engines : uid(%d)", uid); ret = sttd_server_get_supported_engines(uid, &engine_list); } @@ -185,7 +185,7 @@ int sttd_dbus_server_get_support_engines(DBusConnection* conn, DBusMessage* msg) dbus_message_iter_init_append(reply, &args); /* Append result*/ - dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(ret) ); + dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(ret)); if (0 == ret) { /* Append size */ @@ -225,11 +225,11 @@ int sttd_dbus_server_get_support_engines(DBusConnection* conn, DBusMessage* msg) engine_list = g_slist_remove_link(engine_list, iter); iter = g_slist_nth(engine_list, 0); - } + } } - SLOG(LOG_DEBUG, TAG_STTD, "[OUT] Result(%d)", ret); + SLOG(LOG_DEBUG, TAG_STTD, "[OUT] Result(%d)", ret); } else { - SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); + SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); } if (!dbus_connection_send(conn, reply, NULL)) { @@ -239,7 +239,7 @@ int sttd_dbus_server_get_support_engines(DBusConnection* conn, DBusMessage* msg) dbus_connection_flush(conn); dbus_message_unref(reply); } else { - SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); + SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); } SLOG(LOG_DEBUG, TAG_STTD, "<<<<<"); @@ -265,12 +265,12 @@ int sttd_dbus_server_set_current_engine(DBusConnection* conn, DBusMessage* msg) SLOG(LOG_DEBUG, TAG_STTD, ">>>>> STT Set current engine"); - if (dbus_error_is_set(&err)) { + if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] stt set current engine : get arguments error (%s)", err.message); - dbus_error_free(&err); + dbus_error_free(&err); ret = STTD_ERROR_OPERATION_FAILED; } else { - SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt set current engine : uid(%d)", uid); + SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt set current engine : uid(%d)", uid); ret = sttd_server_set_current_engine(uid, engine_id, &silence_supported); } @@ -287,7 +287,7 @@ int sttd_dbus_server_set_current_engine(DBusConnection* conn, DBusMessage* msg) SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d), silence(%d)", ret, silence_supported); } else { - SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d) ", ret); + SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d) ", ret); } if (!dbus_connection_send(conn, reply, NULL)) { @@ -297,7 +297,7 @@ int sttd_dbus_server_set_current_engine(DBusConnection* conn, DBusMessage* msg) dbus_connection_flush(conn); dbus_message_unref(reply); } else { - SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); + SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); } SLOG(LOG_DEBUG, TAG_STTD, "<<<<<"); @@ -319,12 +319,12 @@ int sttd_dbus_server_get_current_engine(DBusConnection* conn, DBusMessage* msg) SLOG(LOG_DEBUG, TAG_STTD, ">>>>> STT Get current engine"); - if (dbus_error_is_set(&err)) { + if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] stt get current engine : get arguments error (%s)", err.message); - dbus_error_free(&err); + dbus_error_free(&err); ret = STTD_ERROR_OPERATION_FAILED; } else { - SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt get current engine : uid(%d)", uid); + SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt get current engine : uid(%d)", uid); ret = sttd_server_get_current_engine(uid, &engine); } @@ -334,16 +334,16 @@ int sttd_dbus_server_get_current_engine(DBusConnection* conn, DBusMessage* msg) if (NULL != reply) { if (0 == ret) { /* Append result and language */ - dbus_message_append_args( reply, + dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_STRING, &engine, DBUS_TYPE_INVALID); - SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); + SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); } else { dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); - SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); + SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); } if (!dbus_connection_send(conn, reply, NULL)) { @@ -353,7 +353,7 @@ int sttd_dbus_server_get_current_engine(DBusConnection* conn, DBusMessage* msg) dbus_connection_flush(conn); dbus_message_unref(reply); } else { - SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); + SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); } if (NULL != engine) free(engine); @@ -374,19 +374,19 @@ int sttd_dbus_server_check_app_agreed(DBusConnection* conn, DBusMessage* msg) int ret = STTD_ERROR_OPERATION_FAILED; bool available = false; - dbus_message_get_args(msg, &err, + dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &uid, DBUS_TYPE_STRING, &appid, DBUS_TYPE_INVALID); SLOG(LOG_DEBUG, TAG_STTD, ">>>>> STT Is engine available"); - if (dbus_error_is_set(&err)) { + if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] stt Is engine available : get arguments error (%s)", err.message); - dbus_error_free(&err); + dbus_error_free(&err); ret = STTD_ERROR_OPERATION_FAILED; } else { - SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt Is engine available : uid(%d)", uid); + SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt Is engine available : uid(%d)", uid); ret = sttd_server_check_agg_agreed(uid, appid, &available); } @@ -401,9 +401,9 @@ int sttd_dbus_server_check_app_agreed(DBusConnection* conn, DBusMessage* msg) DBUS_TYPE_INVALID); if (0 == ret) { - SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); + SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); } else { - SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); + SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); } if (!dbus_connection_send(conn, reply, NULL)) { @@ -413,7 +413,7 @@ int sttd_dbus_server_check_app_agreed(DBusConnection* conn, DBusMessage* msg) dbus_connection_flush(conn); dbus_message_unref(reply); } else { - SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); + SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); } SLOG(LOG_DEBUG, TAG_STTD, "<<<<<"); @@ -435,12 +435,12 @@ int sttd_dbus_server_get_support_lang(DBusConnection* conn, DBusMessage* msg) SLOG(LOG_DEBUG, TAG_STTD, ">>>>> STT Get supported langs"); - if (dbus_error_is_set(&err)) { + if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] stt supported langs : get arguments error (%s)", err.message); - dbus_error_free(&err); + dbus_error_free(&err); ret = STTD_ERROR_OPERATION_FAILED; } else { - SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt supported langs : uid(%d)", uid); + SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt supported langs : uid(%d)", uid); ret = sttd_server_get_supported_languages(uid, &lang_list); } @@ -459,7 +459,7 @@ int sttd_dbus_server_get_support_lang(DBusConnection* conn, DBusMessage* msg) int size = g_slist_length(lang_list); if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(size))) { - SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to append type"); + SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to append type"); ret = STTD_ERROR_OPERATION_FAILED; } else { GSList *iter = NULL; @@ -470,21 +470,21 @@ int sttd_dbus_server_get_support_lang(DBusConnection* conn, DBusMessage* msg) while (NULL != iter) { temp_lang = iter->data; - dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(temp_lang) ); - + dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(temp_lang)); + if (NULL != temp_lang) free(temp_lang); - + lang_list = g_slist_remove_link(lang_list, iter); iter = g_slist_nth(lang_list, 0); - } + } } - SLOG(LOG_DEBUG, TAG_STTD, "[OUT] Result(%d)", ret); + SLOG(LOG_DEBUG, TAG_STTD, "[OUT] Result(%d)", ret); } else { - SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); + SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); } - + if (!dbus_connection_send(conn, reply, NULL)) { SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Out Of Memory!"); } @@ -492,7 +492,7 @@ int sttd_dbus_server_get_support_lang(DBusConnection* conn, DBusMessage* msg) dbus_connection_flush(conn); dbus_message_unref(reply); } else { - SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); + SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); } SLOG(LOG_DEBUG, TAG_STTD, "<<<<<"); @@ -514,12 +514,12 @@ int sttd_dbus_server_get_default_lang(DBusConnection* conn, DBusMessage* msg) SLOG(LOG_DEBUG, TAG_STTD, ">>>>> STT Get default langs"); - if (dbus_error_is_set(&err)) { + if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] stt get default lang : get arguments error (%s)", err.message); - dbus_error_free(&err); + dbus_error_free(&err); ret = STTD_ERROR_OPERATION_FAILED; } else { - SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt get default lang : uid(%d)", uid); + SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt get default lang : uid(%d)", uid); ret = sttd_server_get_current_langauage(uid, &lang); } @@ -529,16 +529,16 @@ int sttd_dbus_server_get_default_lang(DBusConnection* conn, DBusMessage* msg) if (NULL != reply) { if (0 == ret) { /* Append result and language */ - dbus_message_append_args( reply, + dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_STRING, &lang, DBUS_TYPE_INVALID); - SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); + SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); } else { dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); - SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); + SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); } if (!dbus_connection_send(conn, reply, NULL)) { @@ -548,7 +548,7 @@ int sttd_dbus_server_get_default_lang(DBusConnection* conn, DBusMessage* msg) dbus_connection_flush(conn); dbus_message_unref(reply); } else { - SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); + SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); } if (NULL != lang) free(lang); @@ -593,9 +593,9 @@ int sttd_dbus_server_is_recognition_type_supported(DBusConnection* conn, DBusMes DBUS_TYPE_INVALID); if (0 == ret) { - SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d), Support(%s)", ret, support ? "true" : "false"); + SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d), Support(%s)", ret, support ? "true" : "false"); } else { - SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); + SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); } if (!dbus_connection_send(conn, reply, NULL)) { @@ -605,7 +605,7 @@ int sttd_dbus_server_is_recognition_type_supported(DBusConnection* conn, DBusMes dbus_connection_flush(conn); dbus_message_unref(reply); } else { - SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); + SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); } SLOG(LOG_DEBUG, TAG_STTD, "<<<<<"); @@ -646,9 +646,9 @@ int sttd_dbus_server_set_start_sound(DBusConnection* conn, DBusMessage* msg) DBUS_TYPE_INVALID); if (0 == ret) { - SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); + SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); } else { - SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); + SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); } if (!dbus_connection_send(conn, reply, NULL)) { @@ -658,7 +658,7 @@ int sttd_dbus_server_set_start_sound(DBusConnection* conn, DBusMessage* msg) dbus_connection_flush(conn); dbus_message_unref(reply); } else { - SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); + SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); } SLOG(LOG_DEBUG, TAG_STTD, "<<<<<"); @@ -698,9 +698,9 @@ int sttd_dbus_server_unset_start_sound(DBusConnection* conn, DBusMessage* msg) DBUS_TYPE_INVALID); if (0 == ret) { - SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); + SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); } else { - SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); + SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); } if (!dbus_connection_send(conn, reply, NULL)) { @@ -710,7 +710,7 @@ int sttd_dbus_server_unset_start_sound(DBusConnection* conn, DBusMessage* msg) dbus_connection_flush(conn); dbus_message_unref(reply); } else { - SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); + SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); } SLOG(LOG_DEBUG, TAG_STTD, "<<<<<"); @@ -751,9 +751,9 @@ int sttd_dbus_server_set_stop_sound(DBusConnection* conn, DBusMessage* msg) DBUS_TYPE_INVALID); if (0 == ret) { - SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); + SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); } else { - SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); + SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); } if (!dbus_connection_send(conn, reply, NULL)) { @@ -763,7 +763,7 @@ int sttd_dbus_server_set_stop_sound(DBusConnection* conn, DBusMessage* msg) dbus_connection_flush(conn); dbus_message_unref(reply); } else { - SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); + SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); } SLOG(LOG_DEBUG, TAG_STTD, "<<<<<"); @@ -803,9 +803,9 @@ int sttd_dbus_server_unset_stop_sound(DBusConnection* conn, DBusMessage* msg) DBUS_TYPE_INVALID); if (0 == ret) { - SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); + SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); } else { - SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); + SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); } if (!dbus_connection_send(conn, reply, NULL)) { @@ -815,7 +815,7 @@ int sttd_dbus_server_unset_stop_sound(DBusConnection* conn, DBusMessage* msg) dbus_connection_flush(conn); dbus_message_unref(reply); } else { - SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); + SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); } SLOG(LOG_DEBUG, TAG_STTD, "<<<<<"); @@ -846,9 +846,9 @@ int sttd_dbus_server_start(DBusConnection* conn, DBusMessage* msg) SLOG(LOG_DEBUG, TAG_STTD, ">>>>> STT Start"); - if (dbus_error_is_set(&err)) { + if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] stt start : get arguments error (%s)", err.message); - dbus_error_free(&err); + dbus_error_free(&err); ret = STTD_ERROR_OPERATION_FAILED; } else { SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt start : uid(%d), lang(%s), type(%s), silence(%d) appid(%s)" @@ -863,9 +863,9 @@ int sttd_dbus_server_start(DBusConnection* conn, DBusMessage* msg) dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); if (0 <= ret) { - SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); + SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); } else { - SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); + SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); } if (!dbus_connection_send(conn, reply, NULL)) { @@ -875,7 +875,7 @@ int sttd_dbus_server_start(DBusConnection* conn, DBusMessage* msg) dbus_connection_flush(conn); dbus_message_unref(reply); } else { - SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); + SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); } SLOG(LOG_DEBUG, TAG_STTD, "<<<<<"); @@ -895,12 +895,12 @@ int sttd_dbus_server_stop(DBusConnection* conn, DBusMessage* msg) SLOG(LOG_DEBUG, TAG_STTD, ">>>>> STT Stop"); - if (dbus_error_is_set(&err)) { + if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] stt stop : get arguments error (%s)", err.message); - dbus_error_free(&err); + dbus_error_free(&err); ret = STTD_ERROR_OPERATION_FAILED; } else { - SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt stop : uid(%d)", uid); + SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt stop : uid(%d)", uid); ret = sttd_server_stop(uid); } @@ -911,9 +911,9 @@ int sttd_dbus_server_stop(DBusConnection* conn, DBusMessage* msg) dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); if (0 <= ret) { - SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); + SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); } else { - SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); + SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); } if (!dbus_connection_send(conn, reply, NULL)) { @@ -923,7 +923,7 @@ int sttd_dbus_server_stop(DBusConnection* conn, DBusMessage* msg) dbus_connection_flush(conn); dbus_message_unref(reply); } else { - SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); + SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); } SLOG(LOG_DEBUG, TAG_STTD, "<<<<<"); @@ -943,12 +943,12 @@ int sttd_dbus_server_cancel(DBusConnection* conn, DBusMessage* msg) SLOG(LOG_DEBUG, TAG_STTD, ">>>>> STT Cancel"); - if (dbus_error_is_set(&err)) { + if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_STTD, "[IN ERROR] stt cancel : get arguments error (%s)", err.message); - dbus_error_free(&err); + dbus_error_free(&err); ret = STTD_ERROR_OPERATION_FAILED; } else { - SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt cancel : uid(%d)", uid); + SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt cancel : uid(%d)", uid); ret = sttd_server_cancel(uid); } @@ -959,9 +959,9 @@ int sttd_dbus_server_cancel(DBusConnection* conn, DBusMessage* msg) dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); if (0 == ret) { - SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); + SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); } else { - SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); + SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret); } if (!dbus_connection_send(conn, reply, NULL)) { @@ -971,7 +971,7 @@ int sttd_dbus_server_cancel(DBusConnection* conn, DBusMessage* msg) dbus_connection_flush(conn); dbus_message_unref(reply); } else { - SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); + SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!"); } SLOG(LOG_DEBUG, TAG_STTD, "<<<<<"); diff --git a/server/sttd_engine_agent.c b/server/sttd_engine_agent.c index c4ac20b..30c498a 100644 --- a/server/sttd_engine_agent.c +++ b/server/sttd_engine_agent.c @@ -1,5 +1,5 @@ /* -* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved +* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -46,7 +46,7 @@ typedef struct _sttengine_info { bool use_network; bool is_loaded; - + /* engine base setting */ char* first_lang; bool silence_detection; @@ -91,9 +91,9 @@ void __engine_info_cb(const char* engine_uuid, const char* engine_name, const ch bool use_network, void* user_data); /* -* Internal Interfaces +* Internal Interfaces */ - + /** get engine info */ int __internal_get_engine_info(const char* filepath, sttengine_info_s** info); @@ -107,7 +107,7 @@ int sttd_engine_agent_init(result_callback result_cb, result_time_callback time_ { /* initialize static data */ if (NULL == result_cb || NULL == time_cb || NULL == silence_cb) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine agent ERROR] Invalid parameter"); + SLOG(LOG_ERROR, TAG_STTD, "[Engine agent ERROR] Invalid parameter"); return STTD_ERROR_INVALID_PARAMETER; } @@ -121,7 +121,7 @@ int sttd_engine_agent_init(result_callback result_cb, result_time_callback time_ g_recording_engine_id = -1; if (0 != sttd_config_get_default_language(&(g_default_language))) { - SLOG(LOG_WARN, TAG_STTD, "[Engine Agent WARNING] There is No default voice in config"); + SLOG(LOG_WARN, TAG_STTD, "[Engine Agent WARNING] There is No default voice in config"); /* Set default voice */ g_default_language = strdup("en_US"); } else { @@ -130,7 +130,7 @@ int sttd_engine_agent_init(result_callback result_cb, result_time_callback time_ 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"); + SLOG(LOG_WARN, TAG_STTD, "[Server WARNING] There is no silence detection in config"); g_default_silence_detected = true; } else { g_default_silence_detected = (bool)temp; @@ -171,7 +171,7 @@ int sttd_engine_agent_release() client = iter->data; g_engine_client_list = g_slist_remove_link(g_engine_client_list, iter); - if (NULL != client) + if (NULL != client) free(client); iter = g_slist_nth(g_engine_client_list, 0); @@ -191,12 +191,12 @@ int sttd_engine_agent_release() /* Get handle data from list */ engine = iter->data; g_engine_list = g_slist_remove_link(g_engine_list, iter); - + /* Check engine unload */ if (engine->is_loaded) { SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Unload engine id(%d)", engine->engine_id); - if (0 != stt_engine_deinitialize(engine->engine_id)) + if (0 != stt_engine_deinitialize(engine->engine_id)) SECURE_SLOG(LOG_WARN, TAG_STTD, "[Engine Agent] Fail to deinitialize engine id(%d)", engine->engine_id); if (0 != stt_engine_unload(engine->engine_id)) @@ -223,7 +223,7 @@ int sttd_engine_agent_release() void __engine_info_cb(const char* engine_uuid, const char* engine_name, const char* setting_ug_name, bool use_network, void* user_data) { - sttengine_info_s* temp = (sttengine_info_s*)user_data; + sttengine_info_s* temp = (sttengine_info_s*)user_data; temp->engine_uuid = g_strdup(engine_uuid); temp->engine_name = g_strdup(engine_name); @@ -234,7 +234,7 @@ void __engine_info_cb(const char* engine_uuid, const char* engine_name, const ch int __internal_get_engine_info(const char* filepath, sttengine_info_s** info) { if (NULL == filepath || NULL == info) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter"); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter"); return STTD_ERROR_INVALID_PARAMETER; } @@ -242,7 +242,7 @@ int __internal_get_engine_info(const char* filepath, sttengine_info_s** info) char *error; void* handle; - handle = dlopen (filepath, RTLD_LAZY); + handle = dlopen(filepath, RTLD_LAZY); if (!handle) { SECURE_SLOG(LOG_WARN, TAG_STTD, "[Engine Agent] Invalid engine : %s", filepath); @@ -252,14 +252,14 @@ int __internal_get_engine_info(const char* filepath, sttengine_info_s** info) /* link engine to daemon */ dlsym(handle, "sttp_load_engine"); if ((error = dlerror()) != NULL) { - SLOG(LOG_WARN, TAG_STTD, "[Engine Agent] Invalid engine. Fail to open sttp_load_engine : %s", error); + SLOG(LOG_WARN, TAG_STTD, "[Engine Agent] Invalid engine. Fail to open sttp_load_engine : %s", error); dlclose(handle); return STTD_ERROR_ENGINE_NOT_FOUND; } dlsym(handle, "sttp_unload_engine"); if ((error = dlerror()) != NULL) { - SLOG(LOG_WARN, TAG_STTD, "[Engine Agent] Invalid engine. Fail to open sttp_unload_engine : %s", error); + SLOG(LOG_WARN, TAG_STTD, "[Engine Agent] Invalid engine. Fail to open sttp_unload_engine : %s", error); dlclose(handle); return STTD_ERROR_ENGINE_NOT_FOUND; } @@ -268,7 +268,7 @@ int __internal_get_engine_info(const char* filepath, sttengine_info_s** info) get_engine_info = (int (*)(sttpe_engine_info_cb, void*))dlsym(handle, "sttp_get_engine_info"); if ((error = dlerror()) != NULL || NULL == get_engine_info) { - SLOG(LOG_WARN, TAG_STTD, "[Engine Agent WARNING] Invalid engine. Fail to open sttp_get_engine_info : %s", error); + SLOG(LOG_WARN, TAG_STTD, "[Engine Agent WARNING] Invalid engine. Fail to open sttp_get_engine_info : %s", error); dlclose(handle); return STTD_ERROR_ENGINE_NOT_FOUND; } @@ -283,7 +283,7 @@ int __internal_get_engine_info(const char* filepath, sttengine_info_s** info) /* get engine info */ if (0 != get_engine_info(__engine_info_cb, (void*)temp)) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to get engine info from engine"); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to get engine info from engine"); dlclose(handle); free(temp); return STTD_ERROR_ENGINE_NOT_FOUND; @@ -304,7 +304,7 @@ int __internal_get_engine_info(const char* filepath, sttengine_info_s** info) SECURE_SLOG(LOG_DEBUG, TAG_STTD, "Engine name : %s", temp->engine_name); SECURE_SLOG(LOG_DEBUG, TAG_STTD, "Engine path : %s", temp->engine_path); SECURE_SLOG(LOG_DEBUG, TAG_STTD, "Engine setting path : %s", temp->engine_setting_path); - SECURE_SLOG(LOG_DEBUG, TAG_STTD, "Use network : %s", temp->use_network ? "true":"false"); + SECURE_SLOG(LOG_DEBUG, TAG_STTD, "Use network : %s", temp->use_network ? "true" : "false"); SLOG(LOG_DEBUG, TAG_STTD, "-----"); SLOG(LOG_DEBUG, TAG_STTD, " "); @@ -329,7 +329,7 @@ bool __is_engine(const char* filepath) if (0 == strcmp(engine->engine_path, filepath)) { return true; } - + iter = g_slist_next(iter); } } @@ -384,7 +384,7 @@ int sttd_engine_agent_initialize_engine_list() closedir(dp); } else { - SLOG(LOG_WARN, TAG_STTD, "[Engine Agent WARNING] Fail to open default directory"); + SLOG(LOG_WARN, TAG_STTD, "[Engine Agent WARNING] Fail to open default directory"); } /* Get file name from downloadable engine directory */ @@ -425,12 +425,12 @@ int sttd_engine_agent_initialize_engine_list() closedir(dp); } else { - SLOG(LOG_WARN, TAG_STTD, "[Engine Agent WARNING] Fail to open downloadable directory"); + SLOG(LOG_WARN, TAG_STTD, "[Engine Agent WARNING] Fail to open downloadable directory"); } if (0 >= g_slist_length(g_engine_list)) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] No Engine"); - return STTD_ERROR_ENGINE_NOT_FOUND; + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] No Engine"); + return STTD_ERROR_ENGINE_NOT_FOUND; } __log_enginelist(); @@ -463,10 +463,10 @@ int sttd_engine_agent_initialize_engine_list() } } - if (cur_engine_uuid != NULL ) + if (cur_engine_uuid != NULL) free(cur_engine_uuid); } else { - SLOG(LOG_WARN, TAG_STTD, "[Engine Agent WARNING] There is not current engine from config"); + SLOG(LOG_WARN, TAG_STTD, "[Engine Agent WARNING] There is not current engine from config"); } if (false == is_default_engine) { @@ -490,7 +490,7 @@ int sttd_engine_agent_initialize_engine_list() if (false == is_default_engine) { if (0 != sttd_config_set_default_engine(engine->engine_uuid)) - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to set default engine "); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to set default engine "); } } } else { @@ -514,7 +514,7 @@ sttengine_info_s* __engine_agent_get_engine_by_id(int engine_id) data = iter->data; - if (data->engine_id == engine_id) + if (data->engine_id == engine_id) return data; iter = g_slist_next(iter); @@ -534,7 +534,7 @@ sttengine_info_s* __engine_agent_get_engine_by_uuid(const char* engine_uuid) data = iter->data; - if (0 == strcmp(data->engine_uuid, engine_uuid)) + if (0 == strcmp(data->engine_uuid, engine_uuid)) return data; iter = g_slist_next(iter); @@ -555,7 +555,7 @@ sttengine_client_s* __engine_agent_get_client(int uid) /* Get handle data from list */ data = iter->data; - if (uid == data->uid) + if (uid == data->uid) return data; iter = g_slist_next(iter); @@ -570,7 +570,7 @@ sttengine_info_s* __engine_agent_get_engine_by_uid(int uid) sttengine_client_s *data; data = __engine_agent_get_client(uid); - if (NULL != data) + if (NULL != data) return __engine_agent_get_engine_by_id(data->engine_id); return NULL; @@ -582,7 +582,7 @@ int __engine_agent_check_engine_unload(int engine_id) GSList *iter = NULL; int client_count = 0; sttengine_client_s *data = NULL; - + if (0 < g_slist_length(g_engine_client_list)) { iter = g_slist_nth(g_engine_client_list, 0); @@ -628,7 +628,7 @@ int __engine_agent_check_engine_unload(int engine_id) int sttd_engine_agent_load_current_engine(int uid, const char* engine_uuid) { if (false == g_agent_init) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized" ); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); return STTD_ERROR_OPERATION_FAILED; } @@ -637,7 +637,7 @@ int sttd_engine_agent_load_current_engine(int uid, const char* engine_uuid) int before_engine = -1; client = __engine_agent_get_client(uid); - + if (NULL == client) { client = (sttengine_client_s*)calloc(1, sizeof(sttengine_client_s)); if (NULL == client) { @@ -648,11 +648,11 @@ int sttd_engine_agent_load_current_engine(int uid, const char* engine_uuid) /* initialize */ client->uid = uid; client->engine_id = -1; - + g_engine_client_list = g_slist_append(g_engine_client_list, client); SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Registered client(%d)", uid); - } + } if (NULL == engine_uuid) { /* Set default engine */ @@ -745,7 +745,7 @@ int sttd_engine_agent_load_current_engine(int uid, const char* engine_uuid) #endif engine->is_loaded = true; - SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent SUCCESS] The %s(%d) has been loaded !!!", engine->engine_name, engine->engine_id); + SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent SUCCESS] The %s(%d) has been loaded !!!", engine->engine_name, engine->engine_id); return 0; } @@ -753,7 +753,7 @@ int sttd_engine_agent_load_current_engine(int uid, const char* engine_uuid) int sttd_engine_agent_unload_current_engine(int uid) { if (false == g_agent_init) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized "); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized "); return STTD_ERROR_OPERATION_FAILED; } @@ -792,7 +792,7 @@ int sttd_engine_agent_unload_current_engine(int uid) bool sttd_engine_agent_is_default_engine() { - if (g_default_engine_id > 0) + if (g_default_engine_id > 0) return true; return false; @@ -801,7 +801,7 @@ bool sttd_engine_agent_is_default_engine() int sttd_engine_agent_get_engine_list(GSList** engine_list) { if (false == g_agent_init) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); return STTD_ERROR_OPERATION_FAILED; } @@ -831,7 +831,7 @@ int sttd_engine_agent_get_engine_list(GSList** engine_list) iter = g_slist_next(iter); - SECURE_SLOG(LOG_DEBUG, TAG_STTD, " -- Engine id(%s)", temp_engine->engine_id); + SECURE_SLOG(LOG_DEBUG, TAG_STTD, " -- Engine id(%s)", temp_engine->engine_id); SECURE_SLOG(LOG_DEBUG, TAG_STTD, " Engine name(%s)", temp_engine->engine_name); SECURE_SLOG(LOG_DEBUG, TAG_STTD, " Engine ug name(%s)", temp_engine->ug_name); } @@ -844,12 +844,12 @@ int sttd_engine_agent_get_engine_list(GSList** engine_list) int sttd_engine_agent_get_current_engine(int uid, char** engine_uuid) { if (false == g_agent_init) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized" ); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); return STTD_ERROR_OPERATION_FAILED; } if (NULL == engine_uuid) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid parameter" ); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid parameter"); return STTD_ERROR_INVALID_PARAMETER; } @@ -862,7 +862,7 @@ int sttd_engine_agent_get_current_engine(int uid, char** engine_uuid) } if (false == engine->is_loaded) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); return STTD_ERROR_OPERATION_FAILED; } @@ -874,13 +874,13 @@ int sttd_engine_agent_get_current_engine(int uid, char** engine_uuid) bool sttd_engine_agent_need_network(int uid) { if (false == g_agent_init) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized" ); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); return STTD_ERROR_OPERATION_FAILED; } sttengine_info_s* engine; engine = __engine_agent_get_engine_by_uid(uid); - + if (NULL != engine) return engine->use_network; @@ -908,13 +908,13 @@ int sttd_engine_agent_supported_langs(int uid, GSList** lang_list) } if (false == engine->is_loaded) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); return STTD_ERROR_OPERATION_FAILED; } int ret = stt_engine_get_supported_langs(engine->engine_id, lang_list); if (0 != ret) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] get language list error(%d)", ret); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] get language list error(%d)", ret); return STTD_ERROR_OPERATION_FAILED; } @@ -924,12 +924,12 @@ int sttd_engine_agent_supported_langs(int uid, GSList** lang_list) int sttd_engine_agent_get_default_lang(int uid, char** lang) { if (false == g_agent_init) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); return STTD_ERROR_OPERATION_FAILED; } if (NULL == lang) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter"); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter"); return STTD_ERROR_INVALID_PARAMETER; } @@ -942,7 +942,7 @@ int sttd_engine_agent_get_default_lang(int uid, char** lang) } if (false == engine->is_loaded) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); return STTD_ERROR_OPERATION_FAILED; } @@ -955,7 +955,7 @@ int sttd_engine_agent_get_default_lang(int uid, char** lang) if (true == is_valid) { *lang = strdup(g_default_language); - } else + } else *lang = strdup(engine->first_lang); return 0; @@ -969,7 +969,7 @@ int sttd_engine_agent_get_option_supported(int uid, bool* silence) } if (NULL == silence) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter"); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter"); return STTD_ERROR_INVALID_PARAMETER; } @@ -982,7 +982,7 @@ int sttd_engine_agent_get_option_supported(int uid, bool* silence) } if (false == engine->is_loaded) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); return STTD_ERROR_OPERATION_FAILED; } @@ -994,12 +994,12 @@ int sttd_engine_agent_get_option_supported(int uid, bool* silence) int sttd_engine_agent_is_recognition_type_supported(int uid, const char* type, bool* support) { if (false == g_agent_init) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); return STTD_ERROR_OPERATION_FAILED; } if (NULL == type || NULL == support) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter"); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter"); return STTD_ERROR_INVALID_PARAMETER; } @@ -1012,7 +1012,7 @@ int sttd_engine_agent_is_recognition_type_supported(int uid, const char* type, b } if (false == engine->is_loaded) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); return STTD_ERROR_OPERATION_FAILED; } @@ -1021,7 +1021,7 @@ int sttd_engine_agent_is_recognition_type_supported(int uid, const char* type, b ret = stt_engine_support_recognition_type(engine->engine_id, type, &temp); if (0 != ret) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to get to support recognition type : %d", ret); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to get to support recognition type : %d", ret); return STTD_ERROR_OPERATION_FAILED; } @@ -1062,7 +1062,7 @@ int __set_option(sttengine_info_s* engine, int silence) } } } - + return 0; } @@ -1070,12 +1070,12 @@ int sttd_engine_agent_recognize_start_engine(int uid, const char* lang, const ch int silence, void* user_param) { if (false == g_agent_init) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); return STTD_ERROR_OPERATION_FAILED; } - + if (NULL == lang || NULL == recognition_type) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter"); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter"); return STTD_ERROR_INVALID_PARAMETER; } @@ -1088,12 +1088,12 @@ int sttd_engine_agent_recognize_start_engine(int uid, const char* lang, const ch } if (false == engine->is_loaded) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); return STTD_ERROR_OPERATION_FAILED; } if (0 != __set_option(engine, silence)) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to set options"); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to set options"); return STTD_ERROR_OPERATION_FAILED; } @@ -1160,7 +1160,7 @@ int sttd_engine_agent_recognize_start_engine(int uid, const char* lang, const ch } g_recording_engine_id = engine->engine_id; - SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] g_recording_engine_id : %d", g_recording_engine_id); + SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] g_recording_engine_id : %d", g_recording_engine_id); #endif return 0; @@ -1177,7 +1177,7 @@ int sttd_engine_agent_recognize_start_recorder(int uid) } if (false == engine->is_loaded) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); return STTD_ERROR_OPERATION_FAILED; } @@ -1193,7 +1193,7 @@ int sttd_engine_agent_recognize_start_recorder(int uid) } g_recording_engine_id = engine->engine_id; - SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] g_recording_engine_id : %d", g_recording_engine_id); + SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] g_recording_engine_id : %d", g_recording_engine_id); return 0; } @@ -1201,12 +1201,12 @@ int sttd_engine_agent_recognize_start_recorder(int uid) int sttd_engine_agent_set_recording_data(int uid, const void* data, unsigned int length) { if (false == g_agent_init) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); return STTD_ERROR_OPERATION_FAILED; } if (NULL == data || 0 == length) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter"); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter"); return STTD_ERROR_INVALID_PARAMETER; } @@ -1219,13 +1219,13 @@ int sttd_engine_agent_set_recording_data(int uid, const void* data, unsigned int } if (false == engine->is_loaded) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); return STTD_ERROR_OPERATION_FAILED; } int ret = stt_engine_set_recording_data(engine->engine_id, data, length); if (0 != ret) { - SLOG(LOG_WARN, TAG_STTD, "[Engine Agent WARNING] set recording error(%d)", ret); + SLOG(LOG_WARN, TAG_STTD, "[Engine Agent WARNING] set recording error(%d)", ret); return STTD_ERROR_OPERATION_FAILED; } @@ -1235,7 +1235,7 @@ int sttd_engine_agent_set_recording_data(int uid, const void* data, unsigned int int sttd_engine_agent_recognize_stop_recorder(int uid) { if (false == g_agent_init) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); return STTD_ERROR_OPERATION_FAILED; } @@ -1248,7 +1248,7 @@ int sttd_engine_agent_recognize_stop_recorder(int uid) } if (false == engine->is_loaded) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); return STTD_ERROR_OPERATION_FAILED; } @@ -1256,7 +1256,7 @@ int sttd_engine_agent_recognize_stop_recorder(int uid) int ret; ret = sttd_recorder_stop(engine->engine_id); if (0 != ret) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to stop recorder : result(%d)", ret); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to stop recorder : result(%d)", ret); return STTD_ERROR_OPERATION_FAILED; } @@ -1273,7 +1273,7 @@ int sttd_engine_agent_recognize_stop_recorder(int uid) int sttd_engine_agent_recognize_stop_engine(int uid) { if (false == g_agent_init) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); return STTD_ERROR_OPERATION_FAILED; } @@ -1286,7 +1286,7 @@ int sttd_engine_agent_recognize_stop_engine(int uid) } if (false == engine->is_loaded) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); return STTD_ERROR_OPERATION_FAILED; } @@ -1295,7 +1295,7 @@ int sttd_engine_agent_recognize_stop_engine(int uid) int ret; ret = stt_engine_recognize_stop(engine->engine_id); if (0 != ret) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] stop recognition error(%d)", ret); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] stop recognition error(%d)", ret); return STTD_ERROR_OPERATION_FAILED; } @@ -1307,7 +1307,7 @@ int sttd_engine_agent_recognize_stop_engine(int uid) int sttd_engine_agent_recognize_cancel(int uid) { if (false == g_agent_init) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); return STTD_ERROR_OPERATION_FAILED; } @@ -1320,7 +1320,7 @@ int sttd_engine_agent_recognize_cancel(int uid) } if (false == engine->is_loaded) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); return STTD_ERROR_OPERATION_FAILED; } @@ -1329,7 +1329,7 @@ int sttd_engine_agent_recognize_cancel(int uid) int ret; ret = stt_engine_recognize_cancel(engine->engine_id); if (0 != ret) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] cancel recognition error(%d)", ret); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] cancel recognition error(%d)", ret); return STTD_ERROR_OPERATION_FAILED; } @@ -1337,7 +1337,7 @@ int sttd_engine_agent_recognize_cancel(int uid) ret = sttd_recorder_stop(engine->engine_id); if (0 != ret) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to stop recorder : result(%d)", ret); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to stop recorder : result(%d)", ret); return STTD_ERROR_OPERATION_FAILED; } @@ -1362,12 +1362,12 @@ int sttd_engine_agent_recognize_cancel(int uid) int sttd_engine_agent_set_default_engine(const char* engine_uuid) { if (false == g_agent_init) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); return STTD_ERROR_OPERATION_FAILED; } if (NULL == engine_uuid) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter"); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter"); return STTD_ERROR_INVALID_PARAMETER; } @@ -1414,12 +1414,12 @@ int sttd_engine_agent_set_default_engine(const char* engine_uuid) int sttd_engine_agent_set_default_language(const char* language) { if (false == g_agent_init) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); return STTD_ERROR_OPERATION_FAILED; } if (NULL == language) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter"); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter"); return STTD_ERROR_INVALID_PARAMETER; } @@ -1434,7 +1434,7 @@ int sttd_engine_agent_set_default_language(const char* language) int sttd_engine_agent_set_silence_detection(bool value) { if (false == g_agent_init) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); return STTD_ERROR_OPERATION_FAILED; } @@ -1459,18 +1459,18 @@ int sttd_engine_agent_check_app_agreed(int uid, const char* appid, bool* result) } if (false == engine->is_loaded) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine"); return STTD_ERROR_OPERATION_FAILED; } int ret; ret = stt_engine_check_app_agreed(engine->engine_id, appid, result); if (0 != ret) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] cancel recognition error(%d)", ret); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] cancel recognition error(%d)", ret); return STTD_ERROR_OPERATION_FAILED; } - + SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Get engine right : %s", *result ? "true" : "false"); return 0; } @@ -1524,7 +1524,7 @@ bool __result_time_cb(int index, sttp_result_time_event_e event, const char* tex void __detect_silence_cb(sttp_silence_type_e type, void* user_data) { if (false == g_agent_init) { - SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Silence Callback : Not Initialized"); + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Silence Callback : Not Initialized"); return; } @@ -1545,7 +1545,7 @@ int __log_enginelist() SLOG(LOG_DEBUG, TAG_STTD, "--------------- engine list -------------------"); - int i = 1; + int i = 1; while (NULL != iter) { /* Get handle data from list */ data = iter->data; diff --git a/server/sttd_recorder.c b/server/sttd_recorder.c index b300c3a..aee8806 100644 --- a/server/sttd_recorder.c +++ b/server/sttd_recorder.c @@ -1,5 +1,5 @@ /* -* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved +* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -35,7 +35,7 @@ typedef struct { int engine_id; audio_in_h audio_h; sttp_audio_type_e audio_type; -}stt_recorder_s; +} stt_recorder_s; static GSList *g_recorder_list; @@ -61,11 +61,11 @@ static char g_temp_file_name[128] = {'\0',}; static FILE* g_pFile; static int g_count = 1; -#endif +#endif const char* __stt_get_session_interrupt_code(sound_session_interrupted_code_e code) { - switch(code) { + switch (code) { case SOUND_SESSION_INTERRUPTED_COMPLETED: return "SOUND_SESSION_INTERRUPTED_COMPLETED"; case SOUND_SESSION_INTERRUPTED_BY_MEDIA: return "SOUND_SESSION_INTERRUPTED_BY_MEDIA"; case SOUND_SESSION_INTERRUPTED_BY_CALL: return "SOUND_SESSION_INTERRUPTED_BY_CALL"; @@ -81,8 +81,8 @@ const char* __stt_get_session_interrupt_code(sound_session_interrupted_code_e co void __sttd_recorder_sound_interrupted_cb(sound_session_interrupted_code_e code, void *user_data) { - SLOG(LOG_DEBUG, TAG_STTD, "[Recorder] Get the interrupt code from sound mgr : %s", - __stt_get_session_interrupt_code(code)); + SLOG(LOG_DEBUG, TAG_STTD, "[Recorder] Get the interrupt code from sound mgr : %s", + __stt_get_session_interrupt_code(code)); if (SOUND_SESSION_INTERRUPTED_COMPLETED == code || SOUND_SESSION_INTERRUPTED_BY_EARJACK_UNPLUG == code) return; @@ -104,7 +104,7 @@ int sttd_recorder_initialize(stt_recorder_audio_cb audio_cb, stt_recorder_interr SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Current state of recorder is recording"); return STTD_ERROR_INVALID_STATE; } - + g_audio_cb = audio_cb; g_interrupt_cb = interrupt_cb; g_recorder_state = STTD_RECORDER_STATE_NONE; @@ -148,7 +148,7 @@ int sttd_recorder_deinitialize() if (0 == access(STT_AUDIO_VOLUME_PATH, R_OK)) { if (0 != remove(STT_AUDIO_VOLUME_PATH)) { - SLOG(LOG_WARN, TAG_STTD, "[Recorder WARN] Fail to remove volume file"); + SLOG(LOG_WARN, TAG_STTD, "[Recorder WARN] Fail to remove volume file"); } } @@ -199,7 +199,7 @@ int sttd_recorder_create(int engine_id, sttp_audio_type_e type, int channel, uns audio_sample_type_e audio_type; audio_in_h temp_in_h; - switch(channel) { + switch (channel) { case 1: audio_ch = AUDIO_CHANNEL_MONO; break; case 2: audio_ch = AUDIO_CHANNEL_STEREO; break; default: @@ -235,7 +235,7 @@ int sttd_recorder_create(int engine_id, sttp_audio_type_e type, int channel, uns recorder->engine_id = engine_id; recorder->audio_h = temp_in_h; recorder->audio_type = type; - + g_recorder_list = g_slist_append(g_recorder_list, recorder); g_recorder_state = STTD_RECORDER_STATE_READY; @@ -357,7 +357,7 @@ Eina_Bool __read_audio_func(void *data) /* Audio read log */ if (0 == g_buffer_count % 50) { SLOG(LOG_DEBUG, TAG_STTD, "[Recorder][%d] Recording... : read_size(%d)", g_buffer_count, read_byte); - + if (100000 == g_buffer_count) { g_buffer_count = 0; } @@ -386,7 +386,7 @@ int sttd_recorder_start(int engine_id) return STTD_ERROR_INVALID_PARAMETER; } - int ret = -1; + int ret = -1; ret = audio_in_prepare(recorder->audio_h); if (AUDIO_IO_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to start audio : %d", ret); @@ -418,7 +418,7 @@ int sttd_recorder_start(int engine_id) if (!g_pFile) { SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] File not found!"); return -1; - } + } #endif return 0; @@ -437,7 +437,7 @@ int sttd_recorder_stop(int engine_id) return STTD_ERROR_INVALID_PARAMETER; } - int ret; + int ret; ret = audio_in_unprepare(recorder->audio_h); if (AUDIO_IO_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to unprepare audioin : %d", ret); @@ -450,7 +450,7 @@ int sttd_recorder_stop(int engine_id) #ifdef BUF_SAVE_MODE fclose(g_pFile); -#endif +#endif return 0; } diff --git a/server/sttd_server.c b/server/sttd_server.c index 54eee3f..705129e 100644 --- a/server/sttd_server.c +++ b/server/sttd_server.c @@ -1,5 +1,5 @@ /* -* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved +* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -50,11 +50,11 @@ Eina_Bool __stop_by_silence(void *data) int ret; if (0 != uid) { - ret = sttd_server_stop(uid); + ret = sttd_server_stop(uid); if (0 > ret) { return EINA_FALSE; } - + if (STTD_RESULT_STATE_DONE == ret) { ret = sttdc_send_set_state(uid, (int)APP_STATE_PROCESSING); if (0 != ret) { @@ -132,8 +132,8 @@ int __server_audio_recorder_callback(const void* data, const unsigned int length if (0 != uid) { ret = sttd_engine_agent_set_recording_data(uid, data, length); if (ret < 0) { - ecore_timer_add(0, __cancel_by_error, NULL); - return -1; + ecore_timer_add(0, __cancel_by_error, NULL); + return -1; } g_recording_log_count++; if (200 <= g_recording_log_count) { @@ -170,7 +170,7 @@ Eina_Bool __cancel_by_no_record(void *data) SLOG(LOG_DEBUG, TAG_STTD, "====="); SLOG(LOG_DEBUG, TAG_STTD, " "); - + return EINA_FALSE; } @@ -194,7 +194,7 @@ void __server_recognition_result_callback(sttp_result_event_e event, const char* /* send result to client */ if (STTP_RESULT_EVENT_FINAL_RESULT == event) { - if (APP_STATE_PROCESSING != state ) { + if (APP_STATE_PROCESSING != state) { SLOG(LOG_WARN, TAG_STTD, "[Server WARNING] Current state is NOT 'Processing'."); } SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Server] the size of result from engine is '%d'", data_count); @@ -210,7 +210,7 @@ void __server_recognition_result_callback(sttp_result_event_e event, const char* if (NULL == data || 0 == data_count) { if (0 != sttdc_send_result(uid, event, NULL, 0, msg)) { - SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to send result"); + SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to send result"); int reason = (int)STTD_ERROR_OPERATION_FAILED; if (0 != sttdc_send_error_signal(uid, reason, "Fail to send recognition result")) { @@ -219,7 +219,7 @@ void __server_recognition_result_callback(sttp_result_event_e event, const char* } } else { if (0 != sttdc_send_result(uid, event, data, data_count, msg)) { - SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to send result"); + SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to send result"); int reason = (int)STTD_ERROR_OPERATION_FAILED; if (0 != sttdc_send_error_signal(uid, reason, "Fail to send recognition result")) { @@ -261,7 +261,7 @@ void __server_recognition_result_callback(sttp_result_event_e event, const char* SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to send result "); /* send error msg */ - int reason = (int)STTD_ERROR_INVALID_STATE; + 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 "); } @@ -282,8 +282,8 @@ void __server_recognition_result_callback(sttp_result_event_e event, const char* bool __server_result_time_callback(int index, sttp_result_time_event_e event, const char* text, long start_time, long end_time, void* user_data) { - SLOG(LOG_DEBUG, TAG_STTD, "[Server] index(%d) event(%d) text(%s) start(%ld) end(%ld)", - index, event, text, start_time, end_time); + SLOG(LOG_DEBUG, TAG_STTD, "[Server] index(%d) event(%d) text(%s) start(%ld) end(%ld)", + index, event, text, start_time, end_time); if (0 == index) { int ret; @@ -365,7 +365,7 @@ void __sttd_server_engine_changed_cb(const char* engine_id, const char* language if (0 != ret) SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to set default lang : result(%d)", ret); } - + ret = sttd_engine_agent_set_silence_detection(support_silence); if (0 != ret) SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to Result(%d)", ret); @@ -426,7 +426,7 @@ int sttd_initialize() SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to engine agent initialize : result(%d)", ret); return ret; } - + /* Update engine list */ ret = sttd_engine_agent_initialize_engine_list(); if (0 != ret) { @@ -471,7 +471,7 @@ Eina_Bool sttd_cleanup_client(void *data) if (NULL != client_list) { SLOG(LOG_DEBUG, TAG_STTD, "===== Clean up client "); - for (i = 0;i < client_count;i++) { + for (i = 0; i < client_count; i++) { result = sttdc_send_hello(client_list[i]); if (0 == result) { @@ -500,7 +500,7 @@ int sttd_server_initialize(int pid, int uid, bool* silence) if (false == sttd_engine_agent_is_default_engine()) { /* Update installed engine */ sttd_engine_agent_initialize_engine_list(); - + if (false == sttd_engine_agent_is_default_engine()) { SLOG(LOG_WARN, TAG_STTD, "[Server WARNING] No stt-engine"); return STTD_ERROR_ENGINE_NOT_FOUND; @@ -571,7 +571,7 @@ int sttd_server_finalize(int uid) stt_client_unset_current_recognition(); } - + if (0 != sttd_engine_agent_unload_current_engine(uid)) { SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to unload engine"); } @@ -586,7 +586,7 @@ int sttd_server_finalize(int uid) sttd_dbus_close_connection(); ecore_timer_add(0, __quit_ecore_loop, NULL); } - + return STTD_ERROR_NONE; } @@ -660,7 +660,7 @@ int sttd_server_get_current_engine(int uid, char** engine_id) SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] The state of uid(%d) is not Ready", uid); return STTD_ERROR_INVALID_STATE; } - + int ret; ret = sttd_engine_agent_get_current_engine(uid, engine_id); if (0 != ret) { @@ -676,7 +676,7 @@ int sttd_server_check_agg_agreed(int uid, const char* appid, bool* available) /* Check if uid is valid */ app_state_e state; if (0 != sttd_client_get_state(uid, &state)) { - SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid "); + SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid "); return STTD_ERROR_INVALID_PARAMETER; } @@ -743,7 +743,7 @@ int sttd_server_get_current_langauage(int uid, char** current_lang) /*get current language from engine */ int ret = sttd_engine_agent_get_default_lang(uid, current_lang); - if (0 != ret) { + if (0 != ret) { SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to get default language :result(%d)", ret); return STTD_ERROR_OPERATION_FAILED; } @@ -769,11 +769,11 @@ int sttd_server_is_recognition_type_supported(int uid, const char* type, int* su bool temp; int ret = sttd_engine_agent_is_recognition_type_supported(uid, type, &temp); - if (0 != ret) { + if (0 != ret) { SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to get recognition type supported : result(%d)", ret); return STTD_ERROR_OPERATION_FAILED; } - + *support = (int)temp; SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Server SUCCESS] recognition type supporting is %s", *support ? "true" : "false"); @@ -791,7 +791,7 @@ int sttd_server_set_start_sound(int uid, const char* file) } int ret = sttd_client_set_start_sound(uid, file); - if (0 != ret) { + if (0 != ret) { SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to set start sound file : result(%d)", ret); return STTD_ERROR_OPERATION_FAILED; } @@ -809,7 +809,7 @@ int sttd_server_set_stop_sound(int uid, const char* file) } int ret = sttd_client_set_stop_sound(uid, file); - if (0 != ret) { + if (0 != ret) { SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to set start sound file : result(%d)", ret); return STTD_ERROR_OPERATION_FAILED; } @@ -818,7 +818,7 @@ int sttd_server_set_stop_sound(int uid, const char* file) } Eina_Bool __check_recording_state(void *data) -{ +{ /* current uid */ int uid = stt_client_get_current_recognition(); if (0 == uid) @@ -964,8 +964,8 @@ int sttd_server_start(int uid, const char* lang, const char* recognition_type, i } /* engine start recognition */ - SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Server] start : uid(%d), lang(%s), recog_type(%s)", - uid, lang, recognition_type); + SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Server] start : uid(%d), lang(%s), recog_type(%s)", + uid, lang, recognition_type); if (NULL != sound) SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Server] start sound : %s", sound); @@ -1055,7 +1055,7 @@ Eina_Bool __time_out_for_processing(void *data) SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to send result "); /* send error msg */ - int reason = (int)STTD_ERROR_TIMED_OUT; + 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 "); } @@ -1129,7 +1129,7 @@ int sttd_server_stop(int uid) char* sound = NULL; if (0 != sttd_client_get_stop_sound(uid, &sound)) { - SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to get start beep sound"); + SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to get start beep sound"); return STTD_ERROR_OPERATION_FAILED; } @@ -1141,7 +1141,7 @@ int sttd_server_stop(int uid) if (0 != ret) { SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to stop recorder : result(%d)", ret); if (0 != sttd_engine_agent_recognize_cancel(uid)) { - SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to cancel recognize"); + SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to cancel recognize"); } if (NULL != sound) free(sound); return STTD_ERROR_OPERATION_FAILED; @@ -1184,7 +1184,7 @@ int sttd_server_stop(int uid) sttd_client_set_state(uid, APP_STATE_PROCESSING); SLOG(LOG_DEBUG, TAG_STTD, "[Server SUCCESS] Stop recognition"); - + g_processing_timer = ecore_timer_add(g_processing_timeout, __time_out_for_processing, NULL); return STTD_RESULT_STATE_DONE; @@ -1202,7 +1202,7 @@ int sttd_server_cancel(int uid) return STTD_ERROR_INVALID_PARAMETER; } - /* check uid state */ + /* check uid state */ if (APP_STATE_READY == state) { SLOG(LOG_WARN, TAG_STTD, "[Server WARNING] Current state is ready"); return STTD_ERROR_NONE; @@ -1226,7 +1226,7 @@ int sttd_server_cancel(int uid) if (0 != ret) { SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to unset session : %d", ret); return STTD_ERROR_OPERATION_FAILED; - } + } } /* change uid state */ diff --git a/test/test_main.c b/test/test_main.c index 9b913e0..cb74bd7 100644 --- a/test/test_main.c +++ b/test/test_main.c @@ -1,5 +1,5 @@ /* -* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved +* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -116,7 +116,7 @@ static Eina_Bool __get_engine_list(void *data) SLOG(LOG_ERROR, TAG_STT_TEST, "[ERROR] Fail to get engine"); return EINA_FALSE; } - + if (NULL != cur_engine) { SLOG(LOG_DEBUG, TAG_STT_TEST, "Current engine - %s", cur_engine); free(cur_engine); @@ -187,7 +187,7 @@ static void __stt_recognition_result_cb(stt_h stt, stt_result_event_e event, con ecore_timer_add(0, __stt_finalize, NULL); } -int main (int argc, char *argv[]) +int main(int argc, char *argv[]) { if (2 < argc) { SLOG(LOG_DEBUG, TAG_STT_TEST, "Please check parameter"); -- 2.7.4